@ujet/websdk-headless 3.5.1 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";var D$=Object.defineProperty;var j$=(e,r,t)=>r in e?D$(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var ut=(e,r,t)=>j$(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function F$(e,r){for(var t=0;t<r.length;t++){const n=r[t];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(n,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Vs=(e=>(e.WAITING="waiting",e.READY="ready",e.IN_PROGRESS="in_progress",e.FINISHED="finished",e))(Vs||{});const U$="prod",gv="3.5.1",bg="https://main.api.ujet.co",Pr={companyId:"",tenant:"",trackerId:"",deviceId:"",application:"websdk",version:gv};function B$(e){return(e==null?void 0:e.constructor)===Object}async function _g(e,r=3){let t=0,n;for(;t<=r;){t+=1;try{return await e()}catch(i){n=i,console.error(i),await q$(1e3*Math.pow(2,t))}}throw n}function q$(e){return new Promise(r=>{setTimeout(()=>{r(0)},e)})}function z$(){return Math.random().toString(36).slice(2)}const W$=new TextDecoder,V$=e=>{const r=atob(e),t=new Uint8Array(r.length);for(let n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return W$.decode(t)},wg=[];class Sa{constructor(r){ut(this,"channel");this.channel=r}static addHandler(r){wg.push(r)}debug(...r){this._log("debug",...r)}info(...r){this._log("info",...r)}warn(...r){this._log("warn",...r)}error(...r){this._log("error",...r)}_log(r,...t){wg.forEach(n=>{n(this.channel,r,...t)})}}const G$=(e,r,...t)=>{console[r](`[${r}][${e}]`,...t)},H$=e=>{let r=[],t;return(i,a,...s)=>{a==="debug"||i==="communicator"||(r.push(K$(i,a,...s)),clearTimeout(t),t=window.setTimeout(()=>{if(r.length){const o={num_of_logs:r.length,logs:r};e(o)}r=[]},2e3))}};function K$(e,r,...t){let n=t.pop();typeof n=="string"&&(t.push(n),n={});const i=t.join(" "),a={loglevel:r,channel:e,timestamp:new Date().toISOString(),application:Pr.application,version:Pr.version,device:Pr.deviceId,tenant:Pr.tenant,company_id:Pr.companyId,location_url:location.href,data:X$(n),message:yv(i)};return Pr.trackerId&&(a.tracker_id=Pr.trackerId),a}const J$=["user","phone","phone_number","phoneNumber","email"],Y$=[/(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}/g,/(?!(000|666|9))\d{3}-(?!00)\d{2}-(?!0000)\d{4}/g,/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/g];function yv(e){return typeof e=="string"?Y$.forEach(r=>{e=e.replace(r,"__MASKED__")}):e&&B$(e)&&(e={...e},Object.keys(e).forEach(r=>{J$.indexOf(r)!==-1?e[r]="__MASKED__":yv(e[r])})),e}function X$(e){if(e.error){const r=e.error;return{error:{name:r.name,message:r.message,stack:r.stack}}}return yv(e.data)}const Af=new Sa("communicator");let Sg=!1;class Q${constructor(r,t){ut(this,"events");ut(this,"options");ut(this,"channel");ut(this,"authenticate");ut(this,"channelReady",!1);ut(this,"__authed",!1);ut(this,"pending",[]);ut(this,"promises",{});ut(this,"user");ut(this,"iframe");this.authenticate=r.authenticate,this.events=t,this.options=Z$(r),this.channel=new MessageChannel,this.useConnect(this.options)}useConnect(r){const t=document.createElement("iframe");t.src=r.bridge,t.setAttribute("style","display:none");let n="*";/^https:/.test(r.bridge)&&(n=new URL(r.bridge).origin),t.addEventListener("load",()=>{if(Af.debug("iframe bridge ready for",n),!this.channelReady){const i={type:"_init",data:r};t.contentWindow.postMessage(i,n,[this.channel.port2])}}),this.channel.port1.onmessage=i=>{this.receiveMessage(i)},document.body.appendChild(t),this.iframe=t}receiveMessage(r){const t=r.data;if(t){if(Af.debug("receiveMessage",t),t.type==="ready")this.channelReady=!0,Pr.deviceId=t.result.deviceId,this.runPending(),this.events.triggerEvent("ready");else if(t.type==="callback"&&t.callbackId){const[n,i]=this.promises[t.callbackId];t.error?i(t.error):n(t.result),delete this.promises[t.callbackId]}else if(t.type==="refreshToken")this.refreshToken();else if(t.request==="_auth"&&(this.events.triggerEvent("authenticated"),t.result&&t.result.log_proxy_url&&!Sg)){Sg=!0;const n=H$(i=>{this.postMessage({type:"_log",data:i})});Sa.addHandler(n)}}}postMessage(r){this.channelReady?(Af.debug("postMessage",r),this.channel.port1.postMessage(r)):this.pending.push(r)}runPending(){for(;this.pending.length;){const r=this.pending.shift();this.postMessage(r)}}postPromise(r,t){return new Promise((n,i)=>{const a=z$()+"_"+Date.now();this.promises[a]=[n,i];const s={type:r,callbackId:a,data:t};this.postMessage(s)})}async refreshToken(){this.__authed=!0;const r=await this.authenticate(),t=["twilio_chat","nexmo_chat"];this.options.cobrowse&&t.push("cobrowse");const i={type:"_auth",data:{modules:t,user:{token:r.token,company_id:this.options.companyId}}};this.postMessage(i);const a=JSON.parse(V$(r.token.split(".")[1]));if(this.user={identity:a.identity,name:a.name,email:a.email},this.events.triggerEvent("authenticate"),a.exp){let s;a.exp.toString().length===13?s=a.exp:a.exp.toString().length===10&&(s=a.exp*1e3),s&&setTimeout(()=>{this.refreshToken()},s-Date.now()-12e4)}}request(r,t){!this.__authed&&r!=="proactive_chat_triggers"&&this.refreshToken();const n={url:r,options:t};return this.postPromise("request",n)}destroy(){delete this.channel,this.iframe&&(document.body.removeChild(this.iframe),this.iframe=void 0)}}function Z$(e){var i;let r=e.host;r||(e.tenant?r=bg.replace("main.api",e.tenant+".api"):r=bg);const t=e.lang||"en",n=!!((i=e.cobrowse)!=null&&i.enabled);return{host:r,lang:t,cobrowse:n,companyId:e.companyId,location:location.href,version:e.version||"3.5.1",bridge:e.bridge||"https://websdk.ujet.co/v3/bridge.html"}}class bv{constructor(){ut(this,"handlers",{})}addEventListener(r,t){this.handlers[r]||(this.handlers[r]=[]),this.handlers[r].push(t)}triggerEvent(r,t){const n=this.handlers[r];n&&n.forEach(i=>{i(t)})}removeEventListener(r,t){if(this.handlers[r]){const n=this.handlers[r].indexOf(t);n!==-1&&this.handlers[r].splice(n,1)}}destroy(){this.handlers={}}}function eI(e,r){const t={};return r.forEach(n=>{t[n.id]=n}),e.map(n=>{if(n.type==="server_message"){const i=n.message_id,a=t[i];w0(n,a.content)}return n})}function tI(e,r){return w0(e,r.content)}function w0(e,r){return Object.keys(r).forEach(t=>{e[t]=r[t]}),e}const Cg={photo:2,video:2,audio:1,document:1};function rI(e){const r=e.toSorted((t,n)=>!t.groupMessageId||!n.groupMessageId||t.groupMessageId!==n.groupMessageId?0:(Cg[n.type]||0)-(Cg[t.type]||0));return r.forEach((t,n,i)=>{const a=i[n+1];a&&a.groupMessageId===t.groupMessageId&&t.$time&&(a.$time=t.$time,t.$time=null)}),r}const Tg=new Sa("MediaStore"),nI=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,iI="chat-media",Eg=1,cl="file";class S0{constructor(){ut(this,"db")}store(){return new Promise((r,t)=>{if(this.db)return r(kg(this.db));const n=nI.open(iI,Eg);n.onerror=()=>{t(new Error("indexedDB open failed"))},n.onsuccess=()=>{const i=n.result;this.db=i,r(kg(i))},n.onupgradeneeded=i=>{const a=n.result;i.oldVersion>0&&i.oldVersion<Eg&&(Tg.info("deprecating media store"),a.deleteObjectStore(cl)),Tg.info("creating media store"),a.createObjectStore(cl)}})}async save(r,t){(await this.store()).put({index:r,file:t},r)}async getAll(){const r=await this.store();return await new Promise((t,n)=>{const i=r.getAll();i.onerror=()=>{n(new Error("indexedDB getAll failed"))},i.onsuccess=()=>{t(i.result)}})}async getAllFiles(){const r={};return(await this.getAll()).forEach(n=>{r[n.index]=n.file}),r}async clear(){(await this.store()).clear()}}function kg(e){return e.transaction(cl,"readwrite").objectStore(cl)}const aI=new Sa("chat-provider");class _v{constructor(r,t,n){ut(this,"audio");ut(this,"issueChatToken");ut(this,"identity");ut(this,"channelId");ut(this,"region");ut(this,"inTask",!1);ut(this,"muted",!1);ut(this,"events");this.events=r,this.region=t.region,this.issueChatToken=n}ping(){if(!this.muted){this.audio||(this.audio=new window.Audio("https://websdk.ujet.co/v3/ping.mp3"));try{this.audio.play()}catch(r){aI.warn("Chat audio play failed",{error:r})}}}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}trackInTask(r){r.type==="noti"&&r.event==="taskVaStarted"?this.inTask=!0:r.type==="noti"&&r.event==="taskVaFinished"&&(this.inTask=!1)}}ut(_v,"type","base");const C0={};function wv(e){C0[e.type]=e}function sI(e){return C0[e]}const T0=["assigned","va_assigned"],E0=["dismissed","va_dismissed"],oI=["va_assigned","va_dismissed"],uI=["queued",...T0,...E0],cI=["timeout","canceled","failed","finished"],Mf=new Sa("Chat");class lI{constructor(r,t){ut(this,"provider");ut(this,"store");ut(this,"globalEvents");ut(this,"state");ut(this,"connected",!1);ut(this,"allowSkipVirtualAgent",!1);ut(this,"inEscalation",!1);ut(this,"events");ut(this,"cachedFiles");this.state=r,this.store=new S0,this.cachedFiles={},this.events=new bv;const n=sI(this.state.provider_type);this.provider=new n(this.events,r,t)}_setGlobalEvents(r,t){this.globalEvents=r,this.on("message",n=>{if(n.type==="server_message"){const i=n.message_id;t(this.id,i).then(a=>{n=tI(n,a),r.triggerEvent("chat.message",n)})}else n.type==="photo"||n.type==="video"?setTimeout(()=>{const i=n.$index.toString();n.file=this.cachedFiles[i],r.triggerEvent("chat.message",n)},100):(r.triggerEvent("chat.message",n),this.registerMessageEvents(n))}),this.on("memberJoined",n=>{r.triggerEvent("chat.memberJoined",n)}),this.on("memberLeft",n=>{r.triggerEvent("chat.memberLeft",n)}),this.on("typingStarted",n=>{r.triggerEvent("chat.typingStarted",n)}),this.on("typingEnded",n=>{r.triggerEvent("chat.typingEnded",n)})}get id(){return this.state.id}get menuId(){return this.state.menus[this.state.menus.length-1].id}get channelId(){return this.state.provider_channel_id}get lang(){return this.state.lang}get virtual(){return oI.indexOf(this.state.status)!==-1}get muted(){return this.provider.muted}set muted(r){this.provider.muted=r}get agent(){return this.virtual?this.state.external_agent?this.state.external_agent:this.state.virtual_agent:this.state.agent||this.state.virtual_agent}get allAgents(){return{virtual:this.state.all_virtual_agents,human:this.state.all_agents}}get userIdentity(){return this.provider.identity}get status(){return this.state.status}get postSessionStatus(){return this.state.post_session_transfer_status}get statusText(){return this.state.status_text}get cobrowsable(){return this.state.features.indexOf("cobrowse")!==-1}get ongoing(){return uI.indexOf(this.state.status)!=-1}get assigned(){return T0.indexOf(this.state.status)!=-1}get dismissed(){return E0.indexOf(this.state.status)!=-1}get ended(){return cI.indexOf(this.state.status)!=-1}get transcriptCount(){return this.state.transcript_requested_count}get createdAt(){return this.state.created_at}get inTask(){return this.provider.inTask}get feedbackType(){var r;return this.state.survey_enabled?"survey":(r=this.state.csat_settings)!=null&&r.enabled?"rate":"none"}get optInRequired(){return this.state.post_session_opt_in_required}get postSessionRequired(){return this.state.post_session_required}get postSessionInProgress(){return this.state.post_session_transfer_status===Vs.IN_PROGRESS}update(r){r.id==this.state.id&&(this.state=r,r.status==="canceled"?this.triggerEvent("ended",this):this.triggerEvent("updated",this))}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}async connect(){try{return await _g(()=>{var r;return(r=this.provider)==null?void 0:r.create()},3),await _g(()=>{var r;return(r=this.provider)==null?void 0:r.join(this.state.provider_channel_id)},3),this.provider?(this.connected=!0,this.triggerEvent("connected",this),Mf.info("connected with provider",this.state.provider_type),!0):(Mf.info("connecting interrupted"),!1)}catch{return!1}}async disconnect(){this.connected=!1,this.triggerEvent("disconnected",this),this.events.destroy(),this.provider&&(await this.provider.destroy(),Mf.info("disconnect with provider",this.state.provider_type))}async sendMessage(r,t){const n=await this.provider.sendMessage(r);return t&&this.saveMedia(n,t),n}preview(r){if(!this.inTask)return this.provider.preview(r)}async fetchMessages(){if(this.connected){const r=await this.store.getAllFiles();return this.provider.fetchMessages(r)}else throw new Error("Please fetchMessages after chat connected.")}startTyping(){return this.provider.startTyping()}stopTyping(){return this.provider.stopTyping()}saveMedia(r,t){this.cachedFiles[r.toString()]=t,this.store.save(r,t)}async destroy(){await this.clearMediaStore(),this.connected&&await this.disconnect(),this.provider&&(this.triggerEvent("destroyed"),this.provider=null),this.events.destroy(),this.state=null}async clearMediaStore(){await this.store.clear()}_handleChatEndedEvent(r){this.disconnect(),r.timeout?(this.state.status="timeout",this.triggerEvent("timeout",this)):(this.state.status="finished",this.triggerEvent("ended",this))}triggerEvent(r,t){this.events.triggerEvent(r,t),this.globalEvents&&this.globalEvents.triggerEvent("chat."+r,t)}registerMessageEvents(r){r.event==="cobrowseRequestedFromAgent"?this.events.triggerEvent("_requestCobrowse","agent"):r.event==="cobrowseRequestedFromEndUser"?this.events.triggerEvent("_requestCobrowse","end_user"):r.event==="chatDismissed"?(this.state.status="dismissed",this.triggerEvent("dismissed",this)):r.event==="chatEnded"?this.events.triggerEvent("_chatEnded",r):r.event==="escalationStarted"?this.inEscalation=!0:(r.event==="escalationFailed"||r.event==="escalationAccepted")&&(this.inEscalation=!1)}}function k0(e){return e.map(fI).filter(r=>r.enabled)}function fI(e){const r={id:e.id,enabled:!0,channels:[],hidden:!!e.hidden};if(!e.name||!e.name.trim())return r.enabled=!1,r;r.name=e.name.trim();const t=dI(e);if(t&&(r.redirection=e.redirection),e.children&&e.children.length){const n=k0(e.children);return r.enabled=n.length>0||t,r.children=n,r}if(!e.channels)r.enabled=t;else{const{channels:n,deflection:i}=pI(e.channels);r.deflection=i,t||(r.channels=n),r.enabled=n.length>0||t}return r}function dI(e){let r=!1;const t=e.redirection;return t&&(t.option==="message"||t.option==="url")&&(r=!!t.data),r}function pI(e){let r=null;const t=[],n=e.chat,i=a=>{!a.deflection_type&&a.deflected_reason&&(a.deflection_type=a.deflected_reason),a.deflected===void 0&&a.deflection_type&&(a.deflected=!0),t.push(a)};return n&&n.deflected&&(r={enabled:!0,type:n.deflected_reason}),n&&(n.enabled||n.virtual_agent_available)&&i({...e.chat,type:"chat"}),e.voice_call&&e.voice_call.instant_enabled&&i({...e.voice_call,type:"instant_call"}),e.voice_call&&e.voice_call.schedule_enabled&&i({...e.voice_call,type:"scheduled_call",deflection_type:e.voice_call.schedule_deflection_type}),e.email&&e.email.enabled&&i({...e.email,type:"email"}),n&&n.deflected&&n.deflected_reason==="over_capacity"&&n.keep_waiting&&i({...n,enabled:!0,type:"keep_waiting",deflection_type:n.deflected_reason}),e.external_deflection_link&&e.external_deflection_link.enabled&&e.external_deflection_link.links.forEach(s=>{s.enabled&&i({...s,type:"external_link"})}),{channels:t,deflection:r}}const hI={en:"English (US)","en-CA":"English (Canada)","en-GB":"English (UK)",es:"Español (España)","es-MX":"Español (México)",fr:"Français (France)","fr-CA":"Français (Canada)",de:"Deutsch",ja:"日本語",ko:"한국어",it:"Italiano",zh:"中文 (简体)","zh-Hant":"中文 (繁體)",sv:"Svenska",pt:"Português (Portugal)","pt-BR":"Português (Brasil)",fi:"Suomi",nb:"Norsk",da:"Dansk",nl:"Nederlands",tr:"Türk",vi:"Tiếng Việt",th:"คนไทย",ar:"اَلْعَرَبِيَّةُ",cs:"Czech",pl:"Polish",hu:"Hungarian"};function vI(e){var t,n;return{languages:e.languages.filter(i=>i.enabled).map(i=>({lang:i.lang,name:i.name,localeName:hI[i.lang]})),name:e.display_name,subdomain:e.subdomain,support_email:e.support_email,action_tracking:e.action_tracking_enabled,email_transcripts:e.chat_settings.email_transcripts,message_preview:e.chat_settings.message_preview,email_enhancement:e.email_enhancement_enabled,display_history:((t=e.chat_settings.display_history)==null?void 0:t.enabled)&&((n=e.chat_settings.display_history)==null?void 0:n.to_end_user),use_recording:e.use_recording,use_web:e.use_web}}function Rg(e){return e.chats=e.chats.map(r=>{const t=r.entries.map((n,i)=>mI(n,`${r.comm_id}-${i}`));return r.entries=rI(t),r}),e}function mI(e,r){var t;return{$index:e.timestamp,$sid:r,$timestamp:new Date(e.timestamp),$userType:e.role,$userId:((t=e.user_data)==null?void 0:t.id)||0,user:e.user_data,type:e.type,...e.body}}const $g=/Chrome/.test(navigator.userAgent);class gI{constructor(r){ut(this,"request");this.request=r}get(r,t){if(t){const n=[];Object.keys(t).forEach(i=>{const a=t[i];a!==void 0&&n.push(`${encodeURIComponent(i)}=${encodeURIComponent(a)}`)}),r+="?"+n.join("&")}return this.request(r,{method:"GET"})}post(r,t){const n={method:"POST"};return n.body=JSON.stringify(t),this.request(r,n)}patch(r,t){const n={method:"PATCH"};return n.body=JSON.stringify(t),this.request(r,n)}put(r,t){const n={method:"PUT"};return n.body=JSON.stringify(t),this.request(r,n)}async getTriggers(r){const t={"UJET-Company-Id":r};return(await this.request("proactive_chat_triggers",{method:"GET",headers:t})).data}trackClientEvents(r){return this.post("/client_events",{events:r})}async getCompany(){const r=await this.get("company");return vI(r.data)}async getMenus(r,t){const n={type:"web_menu",lang:r,direct_access_key:t},i=await this.get("menus",n),a={key:!!t,user:!1},s=i.headers["ujet-direct-access"];return s&&s!="false"&&(a.user=!0),{menus:k0(i.data),direct:a}}async getAfterHourMessage(r){return(await this.get(`audible_messages/${r}`)).data["after_hours.message"].text}async getTimeSlots(r,t="en"){return(await this.get(`menus/${r}/time_slots`,{type:"web_menu",lang:t})).data}async getWaitTimes(r,t="en"){return(await this.get(`menus/${r}/wait_times`,{type:"web_menu",lang:t})).data}async verifyForm(r){try{return await this.post("forms/verify",r),!0}catch{return!1}}async finishChat(r){return(await this.patch(`chats/${r}`,{status:"finished"})).data}async updatePostSession(r,t){const n={post_session_transfer_status:t};try{return(await this.patch(`chats/${r}`,n)).data}catch(i){if(t===Vs.IN_PROGRESS&&i.status===400)return(await this.patch(`chats/${r}`,n)).data;throw i}}async getChatDeflection(r){const{data:t}=await this.get(`chats/${r}/deflections`);return t&&t.enabled?t:null}sendChatCustomData(r,t){let n;return typeof t=="string"?n={signed:!0,signed_data:t}:n={signed:!1,data:t},this.post(`chats/${r}/custom_data`,n)}async downloadChatTranscript(r){return(await this.post(`chats/${r}/generate_transcript_pdf`,{})).data}async getPdfStatus(r){return await this.get(`chat_transcript_pdfs/${r}/download_transcript`)}sendChatTranscripts(r,t){return this.post(`chats/${r}/transcripts`,{emails:t.join(",")})}async listChatTaskMessages(r){return(await this.get(`chats/${r}/task_va_messages`)).data}async getChatTaskMessage(r,t){return(await this.get(`chats/${r}/task_va_messages/${t}`)).data}async sendChatTaskMessage(r,t){const n={content:{content:t,type:"text"}};return(await this.post(`chats/${r}/task_va_messages`,n)).data}escalateChat(r,t){return this.post(`chats/${r}/escalations`,t)}trackEscalation(r,t,n){return this.put(`chats/${r}/escalations/${t}`,{escalation_id:t,deflection_channel:n})}requestChatCobrowse(r,t){return this.post(`chats/${r}/cobrowse`,t)}rateChat(r,t){return this.patch(`chats/${r}/rating`,t)}async getChatSurvey(r){return(await this.get(`chats/${r}/survey`)).data}sendChatSurvey(r,t){const n={chat_id:r,answers:t};return this.put(`chats/${r}/survey`,n)}trackChatEndUserEvent(r,t){return this.post(`chats/${r}/end_user_event`,t)}async createChat(r,t,n,i){const a={chat:{menu_id:r,lang:t,email:n.email,greeting:n.greeting,trigger_id:n.trigger_id,ticket_id:n.ticket_id,custom_data:n.custom_data},cobrowsable:n.cobrowsable},o=(await this.post("chats",a)).data;return this.wrapChat(o,i)}async loadChat(r,t){const n=await this.getChat(r);return this.wrapChat(n,t)}async resumeChat(r,t){const n=await this.patch(`chats/${r}`,{status:"queued"});return this.wrapChat(n.data,t)}async getChatHistory(r=1){if(r===1){const{data:t}=await this.get("/chats/histories?page=1&per_page=2");return Rg(t)}else{const{data:t}=await this.get(`/chats/histories?page=${r}&per_page=1`);return Rg(t)}}async uploadChatFile(r,t){let n="file";/^image/.test(t.type)?n="photo":/^video/.test(t.type)?n="video":n="file";const i=t.name.replace(/\.[^.]+$/i,""),a=await this.post(`chats/${r}/${n}s/upload`,{filename:i}),s={file:t,fields:a.data.fields};$g&&(s.file=await R0(t));const u=(await this.request(a.data.url,s)).data.key,l=(await this.post(`chats/${r}/${n}s`,{chat_id:r,[n]:{s3_path:u,photo_type:n}})).data;return l.type=n,l}async getChat(r){return(await this.get(`chats/${r}`)).data}wrapChat(r,t){const n=async()=>(await this.post(`chats/${r.id}/tokens`,{provider_type:r.provider_type,device_id:t})).data,i=new lI(r,n),a=async s=>{if(i.status==="va_assigned"){const u=(await this.get(`menus/${i.menuId}/virtual_agent_settings`,{lang:i.lang})).data.allow_skip_virtual_agent;i.allowSkipVirtualAgent=u,i.update(s)}};if(i.channelId)i.connect(),a(r);else{const s=setInterval(async()=>{const o=await this.getChat(i.id);o.provider_channel_id?(clearInterval(s),i.state&&(i.update(o),i.connect(),a(o))):(o.status==="canceled"||o.status==="finished")&&clearInterval(s)},1500)}return i.on("initialized",async()=>{if(i.status==="queued"){const s=await this.getChat(i.id);i.update(s)}}),i.on("memberJoined",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("memberLeft",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("_chatEnded",async s=>{const o=await this.getChat(i.id);i.update(o),i.ended&&i._handleChatEndedEvent(s)}),i}async createCall(r,t,n){const i={type:n.scheduled_at?"web_scheduled_call":"web_instant_call",menu_id:r,lang:t,email:n.email,ticket_id:n.ticket_id,recording_permission:n.recording_permission||"recording_permission_not_asked",scheduled_at:n.scheduled_at,custom_data:n.custom_data,end_user:{phone_number:n.phone_number}},s=(await this.post("calls",{call:i,cobrowsable:!1})).data;return s.menu_id=s.selected_menu.id,s}async fetchCall(r){const n=(await this.get(`calls/${r}`)).data;return n.menu_id=n.selected_menu.id,n}async cancelCall(r){const n=(await this.patch(`calls/${r}`,{status:"failed",fail_reason:"canceled"})).data;return n.menu_id=n.selected_menu.id,n}async listFileTypes(){return(await this.get("email_prohibited_file_types")).data}async createEmail(r,t,n){const i={end_user_email:n.email,email_body:n.content,menu_id:r.toString(),lang:t};return n.name&&(i.end_user_name=n.name),n.recaptcha&&(i.recaptcha_response=n.recaptcha),n.files&&$g?i["email_attachments[]"]=await yI(n.files):n.files&&(i["email_attachments[]"]=[...n.files]),this.request("emails",{form:i})}async getMedia(r,t){const n=await this.get(`media/${r}?type=${t}`);if(!n.data)return null;const i=n.headers["x-file-name"];return new File([n.data],i,{type:n.data.type})}}function yI(e){return Promise.all(e.map(R0))}function R0(e){return new Promise((r,t)=>{const n=new FileReader;n.onload=()=>{const i=[n.result],a={type:e.type,lastModified:e.lastModified};r({name:e.name,fileBits:i,options:a})},n.onerror=t,n.readAsArrayBuffer(e)})}const xf="ujet:",Or={set(e,r){return localStorage.setItem(xf+e,r)},get(e){return localStorage.getItem(xf+e)},del(e){return localStorage.removeItem(xf+e)}},bI=Date.now(),$0={href:window.location.href,interval:24*60*60};function _I(e){if(!Array.isArray(e)||!e.length)return null;const r=EI(),t=r===0,n=r+1;return kI(n),e.filter(a=>{const s=SI(a,$0.href),o=CI(a.visitor_type,t),u=n>=a.page_visit_count,c=!TI(a.id);return s&&o&&u&&c}).sort((a,s)=>a.stay_time-s.stay_time)[0]||null}function wI(e,r){const t=e.stay_time*1e3,n=Math.max(t-(Date.now()-bI),0);setTimeout(()=>{r(e),Or.set(`trigger:${e.id}`,(Date.now()/1e3).toString())},n)}function SI(e,r){const t=e.keywords_included||[],n=e.keywords_excluded||[];if(!t.length&&!n.length)return!0;const i=t.filter(s=>r.indexOf(s)!==-1).length,a=n.filter(s=>r.indexOf(s)===-1).length;return!!i||!!a}function CI(e,r){return e==="visitor_type_new"?r:e==="visitor_type_returning"?!r:!0}function TI(e){try{const r=parseInt(Or.get(`trigger:${e}`),10);return Date.now()/1e3-r<$0.interval}catch{return!1}}function EI(){try{const e=Or.get("visits");return e?parseInt(e,10):0}catch{return 0}}function kI(e){try{Or.set("visits",e.toString())}catch(r){console.error(r)}}const RI=`<dialog open class="cobrowse-dialog" data-test-id="cobrowse-dialog">
1
+ "use strict";var j$=Object.defineProperty;var F$=(e,r,t)=>r in e?j$(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var ut=(e,r,t)=>F$(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function U$(e,r){for(var t=0;t<r.length;t++){const n=r[t];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(n,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Vs=(e=>(e.WAITING="waiting",e.READY="ready",e.IN_PROGRESS="in_progress",e.FINISHED="finished",e))(Vs||{});const B$="prod",gv="3.6.1",bg="https://main.api.ujet.co",Er={companyId:"",tenant:"",trackerId:"",deviceId:"",application:"websdk",version:gv};function q$(e){return(e==null?void 0:e.constructor)===Object}async function _g(e,r=3){let t=0,n;for(;t<=r;){t+=1;try{return await e()}catch(i){n=i,console.error(i),await z$(1e3*Math.pow(2,t))}}throw n}function z$(e){return new Promise(r=>{setTimeout(()=>{r(0)},e)})}function W$(){return Math.random().toString(36).slice(2)}const V$=new TextDecoder,G$=e=>{const r=atob(e),t=new Uint8Array(r.length);for(let n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return V$.decode(t)},H$=e=>e.length===0,wg=(...e)=>e.every(H$),Sg=[];class Sa{constructor(r){ut(this,"channel");this.channel=r}static addHandler(r){Sg.push(r)}debug(...r){this._log("debug",...r)}info(...r){this._log("info",...r)}warn(...r){this._log("warn",...r)}error(...r){this._log("error",...r)}_log(r,...t){Sg.forEach(n=>{n(this.channel,r,...t)})}}const K$=(e,r,...t)=>{console[r](`[${r}][${e}]`,...t)},J$=e=>{let r=[],t;return(i,a,...s)=>{a==="debug"||i==="communicator"||(r.push(Y$(i,a,...s)),clearTimeout(t),t=window.setTimeout(()=>{if(r.length){const o={num_of_logs:r.length,logs:r};e(o)}r=[]},2e3))}};function Y$(e,r,...t){let n=t.pop();typeof n=="string"&&(t.push(n),n={});const i=t.join(" "),a={loglevel:r,channel:e,timestamp:new Date().toISOString(),application:Er.application,version:Er.version,device:Er.deviceId,tenant:Er.tenant,company_id:Er.companyId,location_url:location.href,data:Z$(n),message:yv(i)};return Er.trackerId&&(a.tracker_id=Er.trackerId),a}const X$=["user","phone","phone_number","phoneNumber","email"],Q$=[/(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}/g,/(?!(000|666|9))\d{3}-(?!00)\d{2}-(?!0000)\d{4}/g,/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/g];function yv(e){return typeof e=="string"?Q$.forEach(r=>{e=e.replace(r,"__MASKED__")}):e&&q$(e)&&(e={...e},Object.keys(e).forEach(r=>{X$.indexOf(r)!==-1?e[r]="__MASKED__":yv(e[r])})),e}function Z$(e){if(e.error){const r=e.error;return{error:{name:r.name,message:r.message,stack:r.stack}}}return yv(e.data)}const Af=new Sa("communicator");let Cg=!1;class eI{constructor(r,t){ut(this,"events");ut(this,"options");ut(this,"channel");ut(this,"authenticate");ut(this,"channelReady",!1);ut(this,"__authed",!1);ut(this,"pending",[]);ut(this,"promises",{});ut(this,"user");ut(this,"iframe");this.authenticate=r.authenticate,this.events=t,this.options=tI(r),this.channel=new MessageChannel,this.useConnect(this.options)}useConnect(r){const t=document.createElement("iframe");t.src=r.bridge,t.setAttribute("style","display:none");let n="*";/^https:/.test(r.bridge)&&(n=new URL(r.bridge).origin),t.addEventListener("load",()=>{if(Af.debug("iframe bridge ready for",n),!this.channelReady){const i={type:"_init",data:r};t.contentWindow.postMessage(i,n,[this.channel.port2])}}),this.channel.port1.onmessage=i=>{this.receiveMessage(i)},document.body.appendChild(t),this.iframe=t}receiveMessage(r){const t=r.data;if(t){if(Af.debug("receiveMessage",t),t.type==="ready")this.channelReady=!0,Er.deviceId=t.result.deviceId,Er.deviceId||console.error("Device Id has not been provided. SDK will not work properly."),this.runPending(),this.events.triggerEvent("ready");else if(t.type==="callback"&&t.callbackId){const[n,i]=this.promises[t.callbackId];t.error?i(t.error):n(t.result),delete this.promises[t.callbackId]}else if(t.type==="refreshToken")this.refreshToken();else if(t.request==="_auth"&&(this.events.triggerEvent("authenticated"),t.result&&t.result.log_proxy_url&&!Cg)){Cg=!0;const n=J$(i=>{this.postMessage({type:"_log",data:i})});Sa.addHandler(n)}}}postMessage(r){this.channelReady?(Af.debug("postMessage",r),this.channel.port1.postMessage(r)):this.pending.push(r)}runPending(){for(;this.pending.length;){const r=this.pending.shift();this.postMessage(r)}}postPromise(r,t){return new Promise((n,i)=>{const a=W$()+"_"+Date.now();this.promises[a]=[n,i];const s={type:r,callbackId:a,data:t};this.postMessage(s)})}async refreshToken(){this.__authed=!0;const r=await this.authenticate(),t=["twilio_chat","nexmo_chat"];this.options.cobrowse&&t.push("cobrowse");const i={type:"_auth",data:{modules:t,user:{token:r.token,company_id:this.options.companyId}}};this.postMessage(i);const a=JSON.parse(G$(r.token.split(".")[1]));if(this.user={identifier:a.identifier,name:a.name,email:a.email},this.events.triggerEvent("authenticate"),a.exp){let s;a.exp.toString().length===13?s=a.exp:a.exp.toString().length===10&&(s=a.exp*1e3),s&&setTimeout(()=>{this.refreshToken()},s-Date.now()-12e4)}}request(r,t){!this.__authed&&r!=="proactive_chat_triggers"&&this.refreshToken();const n={url:r,options:t};return this.postPromise("request",n)}destroy(){delete this.channel,this.iframe&&(document.body.removeChild(this.iframe),this.iframe=void 0)}}function tI(e){var i;let r=e.host;r||(e.tenant?r=bg.replace("main.api",e.tenant+".api"):r=bg);const t=e.lang||"en",n=!!((i=e.cobrowse)!=null&&i.enabled);return{host:r,lang:t,cobrowse:n,companyId:e.companyId,location:location.href,version:e.version||"3.6.1",bridge:e.bridge||"https://websdk.ujet.co/v3/bridge.html"}}class bv{constructor(){ut(this,"handlers",{})}addEventListener(r,t){this.handlers[r]||(this.handlers[r]=[]),this.handlers[r].push(t)}triggerEvent(r,t){const n=this.handlers[r];n&&n.forEach(i=>{i(t)})}removeEventListener(r,t){if(this.handlers[r]){const n=this.handlers[r].indexOf(t);n!==-1&&this.handlers[r].splice(n,1)}}destroy(){this.handlers={}}}function rI(e,r){const t={};return r.forEach(n=>{t[n.id]=n}),e.map(n=>{if(n.type==="server_message"){const i=n.message_id,a=t[i];S0(n,a.content)}return n})}function nI(e,r){return S0(e,r.content)}function S0(e,r){return Object.keys(r).forEach(t=>{e[t]=r[t]}),e}const Tg={photo:2,video:2,audio:1,document:1};function iI(e){const r=e.toSorted((t,n)=>!t.groupMessageId||!n.groupMessageId||t.groupMessageId!==n.groupMessageId?0:(Tg[n.type]||0)-(Tg[t.type]||0));return r.forEach((t,n,i)=>{const a=i[n+1];a&&a.groupMessageId===t.groupMessageId&&t.$time&&(a.$time=t.$time,t.$time=null)}),r}const Eg=new Sa("MediaStore"),aI=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,sI="chat-media",kg=1,cl="file";class C0{constructor(){ut(this,"db")}store(){return new Promise((r,t)=>{if(this.db)return r(Rg(this.db));const n=aI.open(sI,kg);n.onerror=()=>{t(new Error("indexedDB open failed"))},n.onsuccess=()=>{const i=n.result;this.db=i,r(Rg(i))},n.onupgradeneeded=i=>{const a=n.result;i.oldVersion>0&&i.oldVersion<kg&&(Eg.info("deprecating media store"),a.deleteObjectStore(cl)),Eg.info("creating media store"),a.createObjectStore(cl)}})}async save(r,t){(await this.store()).put({index:r,file:t},r)}async getAll(){const r=await this.store();return await new Promise((t,n)=>{const i=r.getAll();i.onerror=()=>{n(new Error("indexedDB getAll failed"))},i.onsuccess=()=>{t(i.result)}})}async getAllFiles(){const r={};return(await this.getAll()).forEach(n=>{r[n.index]=n.file}),r}async clear(){(await this.store()).clear()}}function Rg(e){return e.transaction(cl,"readwrite").objectStore(cl)}const oI=new Sa("chat-provider");class _v{constructor(r,t,n){ut(this,"audio");ut(this,"issueChatToken");ut(this,"identity");ut(this,"channelId");ut(this,"region");ut(this,"inTask",!1);ut(this,"muted",!1);ut(this,"events");this.events=r,this.region=t.region,this.issueChatToken=n}ping(){if(!this.muted){this.audio||(this.audio=new window.Audio("https://websdk.ujet.co/v3/ping.mp3"));try{this.audio.play()}catch(r){oI.warn("Chat audio play failed",{error:r})}}}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}trackInTask(r){r.type==="noti"&&r.event==="taskVaStarted"?this.inTask=!0:r.type==="noti"&&r.event==="taskVaFinished"&&(this.inTask=!1)}}ut(_v,"type","base");const T0={};function wv(e){T0[e.type]=e}function uI(e){return T0[e]}const E0=["assigned","va_assigned"],k0=["dismissed","va_dismissed"],cI=["va_assigned","va_dismissed"],lI=["queued",...E0,...k0],fI=["timeout","canceled","failed","finished"],Mf=new Sa("Chat");class dI{constructor(r,t){ut(this,"provider");ut(this,"store");ut(this,"globalEvents");ut(this,"state");ut(this,"connected",!1);ut(this,"allowSkipVirtualAgent",!1);ut(this,"inEscalation",!1);ut(this,"events");ut(this,"cachedFiles");this.state=r,this.store=new C0,this.cachedFiles={},this.events=new bv;const n=uI(this.state.provider_type);this.provider=new n(this.events,r,t)}_setGlobalEvents(r,t){this.globalEvents=r,this.on("message",n=>{if(n.type==="server_message"){const i=n.message_id;t(this.id,i).then(a=>{n=nI(n,a),r.triggerEvent("chat.message",n)})}else n.type==="photo"||n.type==="video"?setTimeout(()=>{const i=n.$index.toString();n.file=this.cachedFiles[i],r.triggerEvent("chat.message",n)},100):(r.triggerEvent("chat.message",n),this.registerMessageEvents(n))}),this.on("memberJoined",n=>{r.triggerEvent("chat.memberJoined",n)}),this.on("memberLeft",n=>{r.triggerEvent("chat.memberLeft",n)}),this.on("typingStarted",n=>{r.triggerEvent("chat.typingStarted",n)}),this.on("typingEnded",n=>{r.triggerEvent("chat.typingEnded",n)})}get id(){return this.state.id}get menuId(){return this.state.menus[this.state.menus.length-1].id}get channelId(){return this.state.provider_channel_id}get lang(){return this.state.lang}get virtual(){return cI.indexOf(this.state.status)!==-1}get muted(){return this.provider.muted}set muted(r){this.provider.muted=r}get agent(){return this.virtual?this.state.external_agent?this.state.external_agent:this.state.virtual_agent:this.state.agent||this.state.virtual_agent}get allAgents(){return{virtual:this.state.all_virtual_agents,human:this.state.all_agents}}get userIdentity(){return this.provider.identity}get status(){return this.state.status}get postSessionStatus(){return this.state.post_session_transfer_status}get statusText(){return this.state.status_text}get cobrowsable(){return this.state.features.indexOf("cobrowse")!==-1}get ongoing(){return lI.indexOf(this.state.status)!=-1}get assigned(){return E0.indexOf(this.state.status)!=-1}get dismissed(){return k0.indexOf(this.state.status)!=-1}get ended(){return fI.indexOf(this.state.status)!=-1}get transcriptCount(){return this.state.transcript_requested_count}get createdAt(){return this.state.created_at}get inTask(){return this.provider.inTask}get feedbackType(){var r;return this.state.survey_enabled?"survey":(r=this.state.csat_settings)!=null&&r.enabled?"rate":"none"}get optInRequired(){return this.state.post_session_opt_in_required}get postSessionRequired(){return this.state.post_session_required}get postSessionInProgress(){return this.state.post_session_transfer_status===Vs.IN_PROGRESS}update(r){r.id==this.state.id&&(this.state=r,r.status==="canceled"?this.triggerEvent("ended",this):this.triggerEvent("updated",this))}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}async connect(){try{return await _g(()=>{var r;return(r=this.provider)==null?void 0:r.create()},3),await _g(()=>{var r;return(r=this.provider)==null?void 0:r.join(this.state.provider_channel_id)},3),this.provider?(this.connected=!0,this.triggerEvent("connected",this),Mf.info("connected with provider",this.state.provider_type),!0):(Mf.info("connecting interrupted"),!1)}catch{return!1}}async disconnect(){this.connected=!1,this.triggerEvent("disconnected",this),this.events.destroy(),this.provider&&(await this.provider.destroy(),Mf.info("disconnect with provider",this.state.provider_type))}async sendMessage(r,t){const n=await this.provider.sendMessage(r);return t&&this.saveMedia(n,t),n}preview(r){if(!this.inTask)return this.provider.preview(r)}async fetchMessages(){if(this.connected){const r=await this.store.getAllFiles();return this.provider.fetchMessages(r)}else throw new Error("Please fetchMessages after chat connected.")}startTyping(){return this.provider.startTyping()}stopTyping(){return this.provider.stopTyping()}saveMedia(r,t){this.cachedFiles[r.toString()]=t,this.store.save(r,t)}async destroy(){await this.clearMediaStore(),this.connected&&await this.disconnect(),this.provider&&(this.triggerEvent("destroyed"),this.provider=null),this.events.destroy(),this.state=null}async clearMediaStore(){await this.store.clear()}_handleChatEndedEvent(r){this.disconnect(),r.timeout?(this.state.status="timeout",this.triggerEvent("timeout",this)):(this.state.status="finished",this.triggerEvent("ended",this))}triggerEvent(r,t){this.events.triggerEvent(r,t),this.globalEvents&&this.globalEvents.triggerEvent("chat."+r,t)}registerMessageEvents(r){r.event==="cobrowseRequestedFromAgent"?this.events.triggerEvent("_requestCobrowse","agent"):r.event==="cobrowseRequestedFromEndUser"?this.events.triggerEvent("_requestCobrowse","end_user"):r.event==="chatDismissed"?(this.state.status="dismissed",this.triggerEvent("dismissed",this)):r.event==="chatEnded"?this.events.triggerEvent("_chatEnded",r):r.event==="escalationStarted"?this.inEscalation=!0:(r.event==="escalationFailed"||r.event==="escalationAccepted")&&(this.inEscalation=!1)}}function R0(e){return e.map(pI).filter(r=>r.enabled)}function pI(e){const r={id:e.id,enabled:!0,channels:[],hidden:!!e.hidden};if(!e.name||!e.name.trim())return r.enabled=!1,r;r.name=e.name.trim();const t=hI(e);if(t&&(r.redirection=e.redirection),e.children&&e.children.length){const n=R0(e.children);return r.enabled=n.length>0||t,r.children=n,r}if(!e.channels)r.enabled=t;else{const{channels:n,deflection:i}=vI(e.channels);r.deflection=i,t||(r.channels=n),r.enabled=n.length>0||t}return r}function hI(e){let r=!1;const t=e.redirection;return t&&(t.option==="message"||t.option==="url")&&(r=!!t.data),r}function vI(e){let r=null;const t=[],n=e.chat,i=a=>{!a.deflection_type&&a.deflected_reason&&(a.deflection_type=a.deflected_reason),a.deflected===void 0&&a.deflection_type&&(a.deflected=!0),t.push(a)};return n&&n.deflected&&(r={enabled:!0,type:n.deflected_reason}),n&&(n.enabled||n.virtual_agent_available)&&i({...e.chat,type:"chat"}),e.voice_call&&e.voice_call.instant_enabled&&i({...e.voice_call,type:"instant_call"}),e.voice_call&&e.voice_call.schedule_enabled&&i({...e.voice_call,type:"scheduled_call",deflection_type:e.voice_call.schedule_deflection_type}),e.email&&e.email.enabled&&i({...e.email,type:"email"}),n&&n.deflected&&n.deflected_reason==="over_capacity"&&n.keep_waiting&&i({...n,enabled:!0,type:"keep_waiting",deflection_type:n.deflected_reason}),e.external_deflection_link&&e.external_deflection_link.enabled&&e.external_deflection_link.links.forEach(s=>{s.enabled&&i({...s,type:"external_link"})}),{channels:t,deflection:r}}const mI={en:"English (US)","en-CA":"English (Canada)","en-GB":"English (UK)",es:"Español (España)","es-MX":"Español (México)",fr:"Français (France)","fr-CA":"Français (Canada)",de:"Deutsch",ja:"日本語",ko:"한국어",it:"Italiano",zh:"中文 (简体)","zh-Hant":"中文 (繁體)",sv:"Svenska",pt:"Português (Portugal)","pt-BR":"Português (Brasil)",fi:"Suomi",nb:"Norsk",da:"Dansk",nl:"Nederlands",tr:"Türk",vi:"Tiếng Việt",th:"คนไทย",ar:"اَلْعَرَبِيَّةُ",cs:"Czech",pl:"Polish",hu:"Hungarian"};function gI(e){var t,n;return{languages:e.languages.filter(i=>i.enabled).map(i=>({lang:i.lang,name:i.name,localeName:mI[i.lang]})),name:e.display_name,subdomain:e.subdomain,support_email:e.support_email,action_tracking:e.action_tracking_enabled,email_transcripts:e.chat_settings.email_transcripts,message_preview:e.chat_settings.message_preview,email_enhancement:e.email_enhancement_enabled,display_history:((t=e.chat_settings.display_history)==null?void 0:t.enabled)&&((n=e.chat_settings.display_history)==null?void 0:n.to_end_user),use_recording:e.use_recording,use_web:e.use_web,cobrowse_domain:e.cobrowse_domain}}function $g(e){return e.chats=e.chats.map(r=>{const t=r.entries.map((n,i)=>yI(n,`${r.comm_id}-${i}`));return r.entries=iI(t),r}),e}function yI(e,r){var t;return{$index:e.timestamp,$sid:r,$timestamp:new Date(e.timestamp),$userType:e.role,$userId:((t=e.user_data)==null?void 0:t.id)||0,user:e.user_data,type:e.type,...e.body}}const Ig=/Chrome/.test(navigator.userAgent);class bI{constructor(r){ut(this,"request");this.request=r}get(r,t){if(t){const n=[];Object.keys(t).forEach(i=>{const a=t[i];a!==void 0&&n.push(`${encodeURIComponent(i)}=${encodeURIComponent(a)}`)}),r+="?"+n.join("&")}return this.request(r,{method:"GET"})}post(r,t){const n={method:"POST"};return n.body=JSON.stringify(t),this.request(r,n)}patch(r,t){const n={method:"PATCH"};return n.body=JSON.stringify(t),this.request(r,n)}put(r,t){const n={method:"PUT"};return n.body=JSON.stringify(t),this.request(r,n)}async getTriggers(r){const t={"UJET-Company-Id":r};return(await this.request("proactive_chat_triggers",{method:"GET",headers:t})).data}trackClientEvents(r){return this.post("/client_events",{events:r})}async getCompany(){const r=await this.get("company");return gI(r.data)}async getMenus(r,t){const n={type:"web_menu",lang:r,direct_access_key:t},i=await this.get("menus",n),a={key:!!t,user:!1},s=i.headers["ujet-direct-access"];return s&&s!="false"&&(a.user=!0),{menus:R0(i.data),direct:a}}async getAfterHourMessage(r){return(await this.get(`audible_messages/${r}`)).data["after_hours.message"].text}async getTimeSlots(r,t="en"){return(await this.get(`menus/${r}/time_slots`,{type:"web_menu",lang:t})).data}async getWaitTimes(r,t="en"){return(await this.get(`menus/${r}/wait_times`,{type:"web_menu",lang:t})).data}async verifyForm(r){try{return await this.post("forms/verify",r),!0}catch{return!1}}async finishChat(r){return(await this.patch(`chats/${r}`,{status:"finished"})).data}async updatePostSession(r,t){const n={post_session_transfer_status:t};try{return(await this.patch(`chats/${r}`,n)).data}catch(i){if(t===Vs.IN_PROGRESS&&i.status===400)return(await this.patch(`chats/${r}`,n)).data;throw i}}async getChatDeflection(r){const{data:t}=await this.get(`chats/${r}/deflections`);return t&&t.enabled?t:null}sendChatCustomData(r,t){let n;return typeof t=="string"?n={signed:!0,signed_data:t}:n={signed:!1,data:t},this.post(`chats/${r}/custom_data`,n)}async downloadChatTranscript(r){return(await this.post(`chats/${r}/generate_transcript_pdf`,{})).data}async getPdfStatus(r){return await this.get(`chat_transcript_pdfs/${r}/download_transcript`)}sendChatTranscripts(r,t){return this.post(`chats/${r}/transcripts`,{emails:t.join(",")})}async listChatTaskMessages(r){return(await this.get(`chats/${r}/task_va_messages`)).data}async getChatTaskMessage(r,t){return(await this.get(`chats/${r}/task_va_messages/${t}`)).data}async sendChatTaskMessage(r,t){const n={content:{content:t,type:"text"}};return(await this.post(`chats/${r}/task_va_messages`,n)).data}escalateChat(r,t){return this.post(`chats/${r}/escalations`,t)}trackEscalation(r,t,n){return this.put(`chats/${r}/escalations/${t}`,{escalation_id:t,deflection_channel:n})}requestChatCobrowse(r,t){return this.post(`chats/${r}/cobrowse`,t)}rateChat(r,t){return this.patch(`chats/${r}/rating`,t)}async getChatSurvey(r){return(await this.get(`chats/${r}/survey`)).data}sendChatSurvey(r,t){const n={chat_id:r,answers:t};return this.put(`chats/${r}/survey`,n)}trackChatEndUserEvent(r,t){return this.post(`chats/${r}/end_user_event`,t)}async createChat(r,t,n,i){const a={chat:{menu_id:r,lang:t,email:n.email,greeting:n.greeting,trigger_id:n.trigger_id,ticket_id:n.ticket_id,custom_data:n.custom_data},cobrowsable:n.cobrowsable},o=(await this.post("chats",a)).data;return this.wrapChat(o,i)}async loadChat(r,t){const n=await this.getChat(r);return this.wrapChat(n,t)}async resumeChat(r,t){const n=await this.patch(`chats/${r}`,{status:"queued"});return this.wrapChat(n.data,t)}async getChatHistory(r=1){if(r===1){const{data:t}=await this.get("/chats/histories?page=1&per_page=2");return $g(t)}else{const{data:t}=await this.get(`/chats/histories?page=${r}&per_page=1`);return $g(t)}}async uploadChatFile(r,t){let n="file";/^image/.test(t.type)?n="photo":/^video/.test(t.type)?n="video":n="file";const i=t.name.replace(/\.[^.]+$/i,""),a=await this.post(`chats/${r}/${n}s/upload`,{filename:i}),s={file:t,fields:a.data.fields};Ig&&(s.file=await $0(t));const u=(await this.request(a.data.url,s)).data.key,l=(await this.post(`chats/${r}/${n}s`,{chat_id:r,[n]:{s3_path:u,photo_type:n}})).data;return l.type=n,l}async getChat(r){return(await this.get(`chats/${r}`)).data}wrapChat(r,t){const n=async()=>(await this.post(`chats/${r.id}/tokens`,{provider_type:r.provider_type,device_id:t})).data,i=new dI(r,n),a=async s=>{if(i.status==="va_assigned"){const u=(await this.get(`menus/${i.menuId}/virtual_agent_settings`,{lang:i.lang})).data.allow_skip_virtual_agent;i.allowSkipVirtualAgent=u,i.update(s)}};if(i.channelId)i.connect(),a(r);else{const s=setInterval(async()=>{const o=await this.getChat(i.id);o.provider_channel_id?(clearInterval(s),i.state&&(i.update(o),i.connect(),a(o))):(o.status==="canceled"||o.status==="finished")&&clearInterval(s)},1500)}return i.on("initialized",async()=>{if(i.status==="queued"){const s=await this.getChat(i.id);i.update(s)}}),i.on("memberJoined",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("memberLeft",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("_chatEnded",async s=>{const o=await this.getChat(i.id);i.update(o),i.ended&&i._handleChatEndedEvent(s)}),i}async createCall(r,t,n){const i={type:n.scheduled_at?"web_scheduled_call":"web_instant_call",menu_id:r,lang:t,email:n.email,ticket_id:n.ticket_id,recording_permission:n.recording_permission||"recording_permission_not_asked",scheduled_at:n.scheduled_at,custom_data:n.custom_data,end_user:{phone_number:n.phone_number}},s=(await this.post("calls",{call:i,cobrowsable:!1})).data;return s.menu_id=s.selected_menu.id,s}async fetchCall(r){const n=(await this.get(`calls/${r}`)).data;return n.menu_id=n.selected_menu.id,n}async cancelCall(r){const n=(await this.patch(`calls/${r}`,{status:"failed",fail_reason:"canceled"})).data;return n.menu_id=n.selected_menu.id,n}async listFileTypes(){return(await this.get("email_prohibited_file_types")).data}async createEmail(r,t,n){const i={end_user_email:n.email,email_body:n.content,menu_id:r.toString(),lang:t};return n.name&&(i.end_user_name=n.name),n.recaptcha&&(i.recaptcha_response=n.recaptcha),n.files&&Ig?i["email_attachments[]"]=await _I(n.files):n.files&&(i["email_attachments[]"]=[...n.files]),this.request("emails",{form:i})}async getMedia(r,t){const n=await this.get(`media/${r}?type=${t}`);if(!n.data)return null;const i=n.headers["x-file-name"];return new File([n.data],i,{type:n.data.type})}}function _I(e){return Promise.all(e.map($0))}function $0(e){return new Promise((r,t)=>{const n=new FileReader;n.onload=()=>{const i=[n.result],a={type:e.type,lastModified:e.lastModified};r({name:e.name,fileBits:i,options:a})},n.onerror=t,n.readAsArrayBuffer(e)})}const xf="ujet:",Pr={set(e,r){return localStorage.setItem(xf+e,r)},get(e){return localStorage.getItem(xf+e)},del(e){return localStorage.removeItem(xf+e)}},wI=Date.now(),I0={href:window.location.href,interval:24*60*60};function SI(e){if(!Array.isArray(e)||!e.length)return null;const r=RI(),t=r===0,n=r+1;return $I(n),e.filter(a=>{const s=TI(a,I0.href),o=EI(a.visitor_type,t),u=n>=a.page_visit_count,c=!kI(a.id);return s&&o&&u&&c}).sort((a,s)=>a.stay_time-s.stay_time)[0]||null}function CI(e,r){const t=e.stay_time*1e3,n=Math.max(t-(Date.now()-wI),0);setTimeout(()=>{r(e),Pr.set(`trigger:${e.id}`,(Date.now()/1e3).toString())},n)}const TI=(e,r)=>{const{keywords_included_or:t=[],keywords_excluded_or:n=[],keywords_included:i=[],keywords_excluded:a=[]}=e;if(wg(t,n)||wg(i,a))return!0;if(t.length||n.length){const u=t.some(l=>l.every(h=>r.includes(h))),c=n.length>0&&n.every(l=>l.every(h=>!r.includes(h)));return u||c}const s=i.filter(u=>r.indexOf(u)!==-1).length,o=a.filter(u=>r.indexOf(u)===-1).length;return!!s||!!o};function EI(e,r){return e==="visitor_type_new"?r:e==="visitor_type_returning"?!r:!0}function kI(e){try{const r=parseInt(Pr.get(`trigger:${e}`),10);return Date.now()/1e3-r<I0.interval}catch{return!1}}function RI(){try{const e=Pr.get("visits");return e?parseInt(e,10):0}catch{return 0}}function $I(e){try{Pr.set("visits",e.toString())}catch(r){console.error(r)}}const II=`<dialog open class="cobrowse-dialog" data-test-id="cobrowse-dialog">
2
2
  <h1>$title</h1>
3
3
  <div class="cobrowse-dialog_content">$content</div>
4
4
  <div class="cobrowse-dialog_footer">
5
5
  <button class="cobrowse-dialog_allow js-cobrowse-allow" data-test-id="cobrowse-dialog_allow">$allow</button>
6
6
  <button class="cobrowse-dialog_deny js-cobrowse-deny" data-test-id="cobrowse-dialog_deny">$deny</button>
7
7
  </div>
8
- </dialog>`,$I='<button class="cobrowse-end js-cobrowse-end">$end</button>';class Sv{constructor(r,t){ut(this,"_cobrowse");ut(this,"_options");ut(this,"_started",!1);this._cobrowse=r,this._options=t}get root(){return this._options.root||document.body}get lang(){return this._options.lang}get messages(){return this._options.messages}get template(){return this._options.template||RI}static async create(r){const t=await II();t.license=r.license;const n=r.trustedOrigins||[];return n.push(location.origin),t.trustedOrigins=n,["api","capabilities","registration","redactedViews","unredactedViews"].forEach(a=>{r[a]!==void 0&&(t[a]=r[a])}),new Sv(t,r)}setCustomData(r){this._cobrowse.customData=r}on(r,t){this._cobrowse.on(r,t)}async start(){this._started||(await this._cobrowse.client(),await this._cobrowse.start(),this._started=!0,this.setupConfirms(),this.setupSessionControl())}async stop(){await this._cobrowse.stop(),this._started=!1}async endSession(){this._cobrowse.currentSession&&await this._cobrowse.currentSession.end()}async createSessionCode(){return this._cobrowse.currentSession?this._cobrowse.currentSession.code():await this._cobrowse.createSessionCode()}createConfirmConsent(r){return()=>{const t=document.createElement("div");t.className="cobrowse-wrapper",t.lang=this.lang,t.innerHTML=r;const n=()=>{t.parentNode&&t.parentNode.removeChild(t)};return new Promise(i=>{this.root.appendChild(t);const a=t.querySelector(".js-cobrowse-allow");a==null||a.addEventListener("click",()=>{i(!0),n()});const s=t.querySelector(".js-cobrowse-deny");s==null||s.addEventListener("click",()=>{i(!1),n()})})}}setupConfirms(){this._cobrowse.confirmSession=this.createConfirmConsent(Uu(this._options.confirmSessionTemplate||this.template,{title:this.messages.confirmSessionTitle,content:this.messages.confirmSessionContent,allow:this.messages.allowText,deny:this.messages.denyText})),this._cobrowse.confirmRemoteControl=this.createConfirmConsent(Uu(this._options.confirmRemoteControlTemplate||this.template,{title:this.messages.confirmRemoteControlTitle,content:this.messages.confirmRemoteControlContent,allow:this.messages.allowText,deny:this.messages.denyText})),this._cobrowse.confirmFullDevice=this.createConfirmConsent(Uu(this._options.confirmFullDeviceTemplate||this.template,{title:this.messages.confirmFullDeviceTitle,content:this.messages.confirmFullDeviceContent,allow:this.messages.allowText,deny:this.messages.denyText}))}setupSessionControl(){const r=this._options.sessionControlsTemplate||$I,t=document.createElement("div");t.className="cobrowse-end-wrapper",t.setAttribute("lang",this.lang),t.innerHTML=Uu(r,{end:this.messages.endSessionText});const n=()=>{this.endSession()};this._cobrowse.showSessionControls=()=>{if(!this.root.contains(t)){const i=t.querySelector(".js-cobrowse-end");i&&i.addEventListener("click",n),this.root.appendChild(t)}},this._cobrowse.hideSessionControls=()=>{if(this.root.contains(t)){const i=t.querySelector(".js-cobrowse-end");i&&i.removeEventListener("click",n),this.root.removeChild(t)}}}}function II(){return window.CobrowseIO?window.CobrowseIO:new Promise(e=>{const r=document.createElement("script");r.src="https://js.cobrowse.io/CobrowseIO.js",r.async=!0;const t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(r,t),r.onload=function(){e(window.CobrowseIO)}})}function Uu(e,r){let t=e;return Object.keys(r).forEach(n=>{const i=new RegExp("\\$"+n,"g");t=t.replace(i,r[n])}),t}const OI={confirmSessionTitle:"Co-browse Session Request",confirmSessionContent:"Do you want to share your current screen with the agent?",endSessionText:"End Co-browse Session",confirmRemoteControlTitle:"Remote Access Request",confirmRemoteControlContent:"The agent would like to have access to your currently shared screen to further assist you. Do you want to allow this?",confirmFullDeviceTitle:"Screen Share Request",confirmFullDeviceContent:"Do you want to share your full screen with the agent? The agent will not be able to control anything on the screen.",allowText:"Allow",denyText:"Deny"},PI={confirmSessionTitle:"Solicitud de sesión de conavegación",confirmSessionContent:"¿Desea compartir su pantalla actual con el agente?",endSessionText:"Fin de la sesión de conavegación",confirmRemoteControlTitle:"Solicitud de acceso remoto",confirmRemoteControlContent:"El agente desea tener acceso a su pantalla actual compartida para seguir asistiéndole. ¿Desea permitirlo?",confirmFullDeviceTitle:"Solicitud de compartir pantalla",confirmFullDeviceContent:"¿Desea compartir su pantalla completa con el agente? El agente no podrá controlar nada de la pantalla.",allowText:"Permitir",denyText:"Denegar"},AI={confirmSessionTitle:"Demande de session de co-navigation",confirmSessionContent:"Voulez-vous partager votre écran actuel avec l'agent ?",endSessionText:"Terminer la session de co-navigation",confirmRemoteControlTitle:"Demande d'accès à distance",confirmRemoteControlContent:"L'agent souhaite avoir accès à l'écran que vous partagez actuellement pour mieux vous aider. Voulez-vous l'y autoriser ?",confirmFullDeviceTitle:"Demande de partage d'écran",confirmFullDeviceContent:"Voulez-vous partager votre écran complet avec l'agent ? L'agent ne sera pas en mesure de contrôler quoi que ce soit sur l'écran.",allowText:"Autoriser",denyText:"Refuser"},MI={confirmSessionTitle:"Co-Browsing-Sitzungsanfrage",confirmSessionContent:"Möchten Sie Ihren aktuellen Bildschirm für den Agenten freigeben?",endSessionText:"Co-Browsing-Sitzung beenden",confirmRemoteControlTitle:"Fernzugriff-Anfrage",confirmRemoteControlContent:"Der Agent möchte Zugriff auf Ihren aktuell freigegebenen Bildschirm erhalten, um Ihnen weiterhelfen zu können. Möchten Sie dies erlauben?",confirmFullDeviceTitle:"Bildschirmfreigabe",confirmFullDeviceContent:"Möchten Sie Ihren gesamten Bildschirm für den Agenten freigeben? Der Agent ist dadurch nicht in der Lage, Elemente auf Ihrem Bildschirm zu steuern.",allowText:"Erlauben",denyText:"Verweigern"},xI={confirmSessionTitle:"共同ブラウジングセッションリクエスト",confirmSessionContent:"現在の画面を担当者と共有したいですか。",endSessionText:"共同ブラウジングセッションを終了",confirmRemoteControlTitle:"リモートアクセスリクエスト",confirmRemoteControlContent:"担当者は、お客様をさらにお手伝いするために、現在共有中の画面へのアクセスを希望しています。許可しますか。",confirmFullDeviceTitle:"画面共有リクエスト",confirmFullDeviceContent:"画面全体を担当者と共有したいですか。担当者は画面上で一切の操作ができません。",allowText:"許可",denyText:"拒否"},NI={confirmSessionTitle:"코브라우징 세션 요청",confirmSessionContent:"현재 화면을 상담원과 공유하시겠습니까?",endSessionText:"코브라우징 세션 종료",confirmRemoteControlTitle:"원격 액세스 요청",confirmRemoteControlContent:"상담원이 추가 지원을 위해 현재 공유된 화면에 액세스할 수 있기를 원합니다. 허용하시겠습니까?",confirmFullDeviceTitle:"화면 공유 요청",confirmFullDeviceContent:"상담원과 전체 화면을 공유하시겠습니까? 상담원은 화면의 어떤 부분도 제어할 수 없습니다.",allowText:"허용",denyText:"거절"},LI={confirmSessionTitle:"Richiesta di sessione di co-browsing",confirmSessionContent:"Vuoi condividere la tua schermata attuale con l'operatore?",endSessionText:"Termina sessione di co-browsing",confirmRemoteControlTitle:"Richiesta di accesso remoto",confirmRemoteControlContent:"L'operatore vorrebbe accedere alla tua schermata attualmente condivisa per assisterti al meglio. Acconsenti?",confirmFullDeviceTitle:"Richiesta di condivisione schermo",confirmFullDeviceContent:"Vuoi condividere il tuo intero schermo con l'operatore? L'operatore non potrà controllare nessun elemento sullo schermo.",allowText:"Consenti",denyText:"Rifiuta"},DI={confirmSessionTitle:"同步浏览会话请求",confirmSessionContent:"您是否要向该客服代表共享当前的屏幕?",endSessionText:"结束同步浏览会话",confirmRemoteControlTitle:"远程访问请求",confirmRemoteControlContent:"为了进一步协助您,客服代表想访问您当前的共享屏幕。您是否允许这样做?",confirmFullDeviceTitle:"屏幕共享请求",confirmFullDeviceContent:"您是否要向该客服代表共享全屏?客服代表将不能控制屏幕上的任何东西。",allowText:"允许",denyText:"拒绝"},jI={confirmSessionTitle:"Samwebbläsningssession har begärts",confirmSessionContent:"Vill du dela din aktuella skärm med vår medarbetare?",endSessionText:"Avsluta samwebbläsningssession",confirmRemoteControlTitle:"Begäran om fjärråtkomst",confirmRemoteControlContent:"Vår medarbetare skulle vilja få åtkomst till skärmen som du delar just nu för att kunna hjälpa dig vidare. Vill du tillåta detta?",confirmFullDeviceTitle:"Begäran om skärmdelning",confirmFullDeviceContent:"Vill du dela hela skärmen med medarbetaren? Medarbetaren kommer inte kunna kontrollera något på skärmen.",allowText:"Tillåt",denyText:"Neka"},FI={confirmSessionTitle:"Solicitação de Sessão de Co-navegação",confirmSessionContent:"Deseja partilhar o seu ecrã atual com o agente?",endSessionText:"Terminar Sessão de Co-navegação",confirmRemoteControlTitle:"Solicitação de Acesso Remoto",confirmRemoteControlContent:"O agente gostaria de ter acesso ao seu ecrã partilhado atualmente para ajudá-lo ainda mais. Quer permitir isto?",confirmFullDeviceTitle:"Solicitação de Partilha de Ecrã",confirmFullDeviceContent:"Deseja partilhar o seu ecrã inteiro com o agente? O agente não poderá controlar nada no ecrã.",allowText:"Permitir",denyText:"Negar"},UI={confirmSessionTitle:"Pyyntö yhteisselausistunnosta",confirmSessionContent:"Haluatko jakaa nykyisen näyttösi edustajan kanssa?",endSessionText:"Lopeta yhteisselausistunto",confirmRemoteControlTitle:"Etäkäyttöpyyntö",confirmRemoteControlContent:"Edustaja haluaisi saada käyttää tällä hetkellä jakamaasi näyttöä voidakseen auttaa sinua enemmän. Haluatko antaa siihen luvan?",confirmFullDeviceTitle:"Näytön jakamispyyntö",confirmFullDeviceContent:"Haluatko jakaa koko näyttösi edustajan kanssa? Edustaja ei pysty käyttämään mitään näytöllä olevaa.",allowText:"Salli",denyText:"Estä"},BI={confirmSessionTitle:"Samlesingsøkten er startet",confirmSessionContent:"Vil du dele skjermen din med agenten?",endSessionText:"Avslutt samlesingsøkt",confirmRemoteControlTitle:"Forespørsel om fjerntilgang",confirmRemoteControlContent:"Agenten vil ha tilgang til skjermen din for å kunne hjelpe deg videre. Vil du tillate dette?",confirmFullDeviceTitle:"Forespørsel om skjermdeling",confirmFullDeviceContent:"Vil du dele hele skjermen din med agenten? Agenten kan ikke kontrollere noe på skjermen.",allowText:"Tillat",denyText:"Avvis"},qI={confirmSessionTitle:"Forespørgsel om sambrowsingsession",confirmSessionContent:"Vil du dele din nuværende skærm med agenten",endSessionText:"Afslut sambrowsingsession",confirmRemoteControlTitle:"Anmodning om fjernadgang",confirmRemoteControlContent:"Agenten vil gerne have adgang til din nuværende delte skærm for at kunne hjælpe dig yderligere. Ønsker du at tillade dette?",confirmFullDeviceTitle:"Forespørgsel om skærmdeling",confirmFullDeviceContent:"Vil du dele din fulde skærm med agenten? Agenten vil ikke kunne styre noget på skærmen",allowText:"Tillad",denyText:"Afvis"},zI={confirmSessionTitle:"Verzoek om cobrowse-sessie",confirmSessionContent:"Wilt u uw huidige scherm delen met de agent?",endSessionText:"Cobrowse-sessie beëindigen",confirmRemoteControlTitle:"Verzoek om toegang op afstand",confirmRemoteControlContent:"De agent wil graag toegang hebben tot uw momenteel gedeelde scherm om u verder te helpen. Wilt u dit toestaan?",confirmFullDeviceTitle:"Verzoek om scherm te delen",confirmFullDeviceContent:"Wilt u uw volledige scherm delen met de agent? De agent kan niets op het scherm bedienen.",allowText:"Toestaan",denyText:"Weigeren"},WI={confirmSessionTitle:"Oturum İsteğini Eş Zamanlı Tara",confirmSessionContent:"Mevcut ekranınızı temsilciyle paylaşmak ister misiniz?",endSessionText:"Eş zamanlı Oturum Taramayı Sonlandır",confirmRemoteControlTitle:"Uzaktan Erişim İsteği",confirmRemoteControlContent:"Temsilci şu anda paylaşılan ekranınıza size daha fazla yardımcı olabilmek için erişim sağlamak istiyor. Buna izin vermek istiyor musunuz?",confirmFullDeviceTitle:"Ekran Paylaşım İsteği",confirmFullDeviceContent:"Temsilciyle tam ekranınızı paylaşmak istiyor musunuz? Temsilci ekrandaki hiçbir şeyi kontrol edemez.",allowText:"İzin Ver",denyText:"Reddet"},VI={confirmSessionTitle:"Yêu cầu phiên cùng duyệt",confirmSessionContent:"Bạn có muốn chia sẻ màn hình hiện tại của mình với chuyên viên không?",endSessionText:"Kết thúc phiên cùng duyệt",confirmRemoteControlTitle:"Yêu cầu truy cập từ xa",confirmRemoteControlContent:"Chuyên viên muốn được cấp quyền truy cập vào màn hình bạn đang chia sẻ để hỗ trợ bạn nhiều hơn. Bạn có muốn cho phép không?",confirmFullDeviceTitle:"Yêu cầu chia sẻ màn hình",confirmFullDeviceContent:"Bạn có muốn chia sẻ toàn bộ màn hình của mình với chuyên viên không? Chuyên viên sẽ không thể điều khiển bất cứ phần nào trên màn hình.",allowText:"Cho phép",denyText:"Từ chối"},GI={confirmSessionTitle:"ขอเซสชันเรียกดูร่วม",confirmSessionContent:"คุณต้องการแชร์หน้าจอปัจจุบันกับตัวแทนหรือไม่",endSessionText:"สิ้นสุดเซสชันเรียกดูร่วม",confirmRemoteControlTitle:"ขอการเข้าถึงระยะไกล",confirmRemoteControlContent:"ตัวแทนต้องการเข้าถึงหน้าจอของคุณที่แชร์อยู่ในปัจจุบันเพื่อให้ความช่วยเหลือคุณต่อไป คุณจะอนุญาตหรือไม่",confirmFullDeviceTitle:"ขอแชร์หน้าจอ",confirmFullDeviceContent:"คุณต้องการแชร์ทั้งหน้าของคุณกับตัวแทนหรือไม่ ตัวแทนจะไม่สามารถควบคุมอะไรบนหน้าจอ",allowText:"ยินยอม",denyText:"ปฏิเสธ"},HI={confirmSessionTitle:"طلب جلسة تصفح مشترك",confirmSessionContent:"هل تريد مشاركة شاشتك الحالية مع الموظف؟",endSessionText:"إنهاء جلسة التصفح المشترك",confirmRemoteControlTitle:"طلب التحكم عن بعد",confirmRemoteControlContent:"يرغب مسئول الدعم في رؤية شاشتك المشاركة حالياً لمساعدتك بشكلٍ أكبر. هل تسمح بذلك؟",confirmFullDeviceTitle:"طلب مشاركة الشاشة",confirmFullDeviceContent:"هل تريد مشاركة شاشتك الكاملة مع مسئول الدعم؟ لن يتمكن المسئول من التحكم في أي شيء على الشاشة.",allowText:"السماح",denyText:"الرفض"},KI={confirmSessionTitle:"Žádost o relaci Co-browse",confirmSessionContent:"Chcete svou současnou obrazovku sdílet s agentem?",endSessionText:"Ukončit relaci Co-browse",confirmRemoteControlTitle:"Žádost o vzdálený přístup",confirmRemoteControlContent:"Agent by rád získal přístup k vaší stávající sdílené obrazovce, aby vám mohl dál pomoci. Chcete mu přístup povolit?",confirmFullDeviceTitle:"Žádost o sdílení obrazovky",confirmFullDeviceContent:"Chcete svou celou obrazovku sdílet s agentem? Agent nebude moci ovládat nic, co na obrazovce je.",allowText:"Povolit",denyText:"Zamítnout"},JI={confirmSessionTitle:"Prośba o sesję Co-browse",confirmSessionContent:"Czy chcesz udostępnić konsultantowi swój bieżący ekran?",endSessionText:"Zakończ sesję Co-browse",confirmRemoteControlTitle:"Prośba o zdalny dostęp",confirmRemoteControlContent:"Konsultant prosi o dostęp do Twojego aktualnie udostępnionego ekranu, aby udzielić Ci dalszej pomocy. Czy chcesz na to zezwolić?",confirmFullDeviceTitle:"Prośba o udostępnienie ekranu",confirmFullDeviceContent:"Czy chcesz udostępnić konsultantowi swój cały ekran? Konsultant nie będzie mógł kontrolować niczego na ekranie.",allowText:"Zezwól",denyText:"Odmów"},YI={confirmSessionTitle:"Co-browse munkameneti kérés",confirmSessionContent:"Megosztja az aktuális képernyőjét a képviselővel?",endSessionText:"Co-browse munkamenet befejezése",confirmRemoteControlTitle:"Távoli hozzáférési kérés",confirmRemoteControlContent:"A képviselő szeretne hozzáférni a jelenleg megosztott képernyőjéhez, hogy további segítséget nyújthasson. Engedélyezi ezt?",confirmFullDeviceTitle:"Képernyőmegosztási kérelem",confirmFullDeviceContent:"Megosztja a teljes képernyőjét az ügynökkel? Az ügynök semmit sem tud majd irányítani a képernyőn.",allowText:"Engedélyezés",denyText:"Elutasítás"},XI={confirmSessionTitle:"Запрос сеанса совместного просмотра веб-страниц",confirmSessionContent:"Хотите поделиться вашим текущим экраном с представителем?",endSessionText:"Завершить сеанс совместного просмотра веб-страниц",confirmRemoteControlTitle:"Запрос на удаленный доступ",confirmRemoteControlContent:"Представитель хочет получить доступ к вашему текущему экрану, которым вы делитесь, чтобы помочь вам. Хотите разрешить это?",confirmFullDeviceTitle:"Запрос на совместный просмотр экрана",confirmFullDeviceContent:"Хотите поделиться вашим полный экраном с представителем? Агент не сможет выполнять никаких действий на экране.",allowText:"Разрешить",denyText:"Отказать"},QI={confirmSessionTitle:"सह-ब्राउज़ सत्र अनुरोध किया गया",confirmSessionContent:"क्या आप अपनी वर्तमान स्क्रीन को एजेंट के साथ साझा करना चाहते हैं?",endSessionText:"सह-ब्राउज़ सत्र समाप्त करें",confirmRemoteControlTitle:"रिमोट पहुँच का अनुरोध किया गया",confirmRemoteControlContent:"एजेंट आपकी वर्तमान साझा स्क्रीन तक पहुँच प्राप्त करना चाहेगा ताकि वह आपकी और सहायता कर सके। क्या आप इसकी अनुमति देना चाहते हैं?",confirmFullDeviceTitle:"स्क्रीन साझाकरण अनुरोध",confirmFullDeviceContent:"क्या आप अपनी पूरी स्क्रीन एजेंट के साथ साझा करना चाहते हैं? एजेंट स्क्रीन पर कुछ भी नियंत्रित नहीं कर पाएगा।",allowText:"अनुमति दें",denyText:"अस्वीकार करें"},ZI={confirmSessionTitle:"Solicitare sesiune de co-navigare",confirmSessionContent:"Doriți să partajați ecranul dumneavoastră curent cu agentul?",endSessionText:"Încheiați sesiunea de co-navigare",confirmRemoteControlTitle:"Cerere de acces la distanță",confirmRemoteControlContent:"Agentul ar dori să aibă acces la ecranul dumneavoastră partajat pentru a vă ajuta în continuare. Doriți să permiteți acest lucru?",confirmFullDeviceTitle:"Cerere de partajare a ecranului",confirmFullDeviceContent:"Doriți să partajați ecranul dumneavoastră complet cu agentul? Agentul nu va putea controla nimic de pe ecran.",allowText:"Permiteți",denyText:"Refuzați"},eO={confirmSessionTitle:"Zahtjev za sesiju zajedničkog pregledavanja",confirmSessionContent:"Želite li podijeliti svoj trenutni zaslon s agentom?",endSessionText:"Završi sesiju zajedničkog pregledavanja",confirmRemoteControlTitle:"Zahtjev za daljinski pristup",confirmRemoteControlContent:"Agent želi imati pristup vašem trenutno dijeljenom zaslonu kako bi Vam dodatno pomogao. Želite li to dopustiti?",confirmFullDeviceTitle:"Zahtjev za dijeljenje zaslona",confirmFullDeviceContent:"Želite li s agentom podijeliti svoj cijeli zaslon? Agent neće moći ništa kontrolirati na ekranu.",allowText:"Dopustiti",denyText:"Odbiti"},tO={confirmSessionTitle:"Запит на сесію спільного перегляду",confirmSessionContent:"Чи Ви хочете поділитись з агентом своїм поточним екраном?",endSessionText:"Завершити сесію спільного перегляду",confirmRemoteControlTitle:"Запит на віддалений доступ",confirmRemoteControlContent:"Агент хоче отримати доступ до Вашого поточного екрану, який переглядається спільно, щоб допомогти Вам. Ви дозволяєте?",confirmFullDeviceTitle:"Запит на спільний перегляд екрану",confirmFullDeviceContent:"Чи Ви хочете поділитись з агентом своїм екраном повністю? Агент не зможе нічого на ньому контролювати.",allowText:"Дозволити",denyText:"Відмовити"},rO={confirmSessionTitle:"Kahilingan sa Co-browse na Sesyon",confirmSessionContent:"Gusto mo bang ibahagi ang iyong kasalukuyang screen sa agent?",endSessionText:"Tapusin ang Co-browse na Sesyon",confirmRemoteControlTitle:"Kahilingan sa Remote Access",confirmRemoteControlContent:"Gusto ng agent na magkaroon ng access sa iyong nakabahaging screen sa kasalukuyan upang mas matulungan ka. Gusto mo bang payagan ito?",confirmFullDeviceTitle:"Kahilingan sa Pagbahagi ng Screen",confirmFullDeviceContent:"Gusto mo bang ibahagi ang buong screen sa agent? Hindi makokontrol ng agent ang kahit ano sa screen.",allowText:"Payagan",denyText:"Tanggihan"},go={en:OI,es:PI,"es-MX":{confirmSessionTitle:"Solicitud de Sesión de Co-navegación",confirmSessionContent:"¿Quiere compartir su pantalla actual con el agente?",endSessionText:"Fin de la sesión de co-navegación",confirmRemoteControlContent:"El agente desea tener acceso a su pantalla actualmente compartida para poder ayudarlo. ¿Quiere permitirlo?",confirmFullDeviceTitle:"Petición de pantalla compartida",confirmFullDeviceContent:"¿Quiere compartir su pantalla completa con el agente? El agente no podrá controlar nada en la pantalla."},fr:AI,"fr-CA":{confirmSessionTitle:"Demande de session co-navigation",confirmSessionContent:"Voulez-vous partager votre écran actuel avec l'agent?",endSessionText:"Fin de la session de co-navigation",confirmRemoteControlContent:"L'agent souhaiterait avoir accès à votre écran actuellement partagé pour mieux vous aider. Voulez-vous l'autoriser?",confirmFullDeviceContent:"Voulez-vous partager votre écran complet avec l'agent? L'agent ne sera pas en mesure de contrôler quoi que ce soit sur l'écran."},de:MI,ja:xI,ko:NI,it:LI,zh:DI,"zh-Hant":{confirmSessionTitle:"共同瀏覽工作階段要求",confirmSessionContent:"要與專員分享您目前的畫面嗎?",endSessionText:"結束共同瀏覽工作階段",confirmRemoteControlTitle:"遠端存取要求",confirmRemoteControlContent:"專員想要存取您目前分享的螢幕畫面以進一步協助您。要允許嗎?",confirmFullDeviceTitle:"螢幕畫面分享要求",confirmFullDeviceContent:"要與專員分享全螢幕嗎?專員將無法控制畫面上的任何項目。",allowText:"允許",denyText:"拒絕"},sv:jI,pt:FI,"pt-BR":{confirmSessionContent:"Você deseja compartilhar sua tela atual com o agente?",endSessionText:"Encerrar Sessão de Co-navegação",confirmRemoteControlContent:"O agente gostaria de acessar sua tela atualmente compartilhada para melhor ajudá-lo. Você deseja permitir isso?",confirmFullDeviceTitle:"Solicitação de Compartilhamento de Tela",confirmFullDeviceContent:"Você deseja compartilhar sua tela inteira com o agente? O agente não poderá controlar nada na tela."},fi:UI,nb:BI,da:qI,nl:zI,tr:WI,vi:VI,th:GI,ar:HI,cs:KI,pl:JI,hu:YI,ru:XI,hi:QI,ro:ZI,hr:eO,uk:tO,tl:rO};function nO(e){const r=e.split("-")[0];return go[e]?e===r?go[e]:{...go[r],...go[e]}:go[r]}const iO=["photo","video","audio","document"];let aO=class{constructor(r){ut(this,"VERSION",gv);ut(this,"options");ut(this,"communicator");ut(this,"methods");ut(this,"events",new bv);ut(this,"request");ut(this,"chat");ut(this,"cobrowse");this.options=r,this.communicator=new Q$(r,this.events);const t=this.communicator.request.bind(this.communicator);this.methods=new gI(t),this.request=t,Pr.companyId=r.companyId,r.tenant&&(Pr.tenant=r.tenant)}get deviceId(){return Pr.deviceId}get user(){return this.communicator.user}get lang(){return this.options.lang?this.options.lang:Or.get("lang")||"en"}set lang(r){this.options.lang||Or.set("lang",r)}destroy(){this.communicator.destroy(),this.events.destroy()}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}_triggerEvent(r,t){this.events.triggerEvent(r,t)}async getCompany(){const r=await this.methods.getCompany();return Pr.tenant=r.subdomain,r}async runTrigger(r){const t=await this.methods.getTriggers(this.options.companyId),n=_I(t);n&&wI(n,r)}trackClientEvents(r){return this.methods.trackClientEvents(r)}getProhibitedFileTypes(){return this.methods.listFileTypes()}getMenus(r,t){return this.methods.getMenus(t||this.lang,r)}getAfterHourMessage(r){return this.methods.getAfterHourMessage(r||this.lang)}getTimeSlots(r,t){return this.methods.getTimeSlots(r,t||this.lang)}getWaitTimes(r,t){return this.methods.getWaitTimes(r,t||this.lang)}verifyForm(r){return this.methods.verifyForm(r)}createCall(r,t){var n;return!t.email&&((n=this.user)!=null&&n.email)&&(t.email=this.user.email),this.methods.createCall(Number(r),t.lang||this.lang,t)}loadCall(r){return this.methods.fetchCall(r)}cancelCall(r){return this.methods.cancelCall(r)}createEmail(r,t){return this.methods.createEmail(r,t.lang||this.lang,t)}async createChat(r,t={}){var i,a;if(this.chat&&this.chat.ongoing)throw new Error("There is an ongoing chat.");!t.email&&((i=this.user)!=null&&i.email)&&(t.email=this.user.email),t.cobrowsable===void 0&&(t.cobrowsable=!!((a=this.options.cobrowse)!=null&&a.enabled));const n=await this.methods.createChat(Number(r),t.lang||this.lang,t,this.deviceId);return this.registerOngoingChat(n),await n.clearMediaStore(),n}async loadChat(r){const t=await this.methods.loadChat(r,this.deviceId);return t.ongoing?this.registerOngoingChat(t):(Or.del("chat"),Or.del("cobrowse")),t}async resumeChat(r){var t;if(((t=this.chat)==null?void 0:t.id)===Number(r)){const n=await this.methods.patch(`chats/${r}`,{status:"queued"});return this.chat.update(n.data),this.chat}else{const n=await this.methods.resumeChat(r,this.deviceId);return this.registerOngoingChat(n),n}}async loadOngoingChat(){const r=Or.get("chat");if(r){const t=await this.loadChat(r);if(t.ongoing)return t;Or.del("chat")}}async finishChat(){if(!this.chat)return;const r=await this.methods.finishChat(this.chat.id);this.chat.update(r),this.chat.connected&&this.chat.ended&&await this.chat.disconnect()}async updatePostSession(r){if(!this.chat||r===Vs.FINISHED||r===Vs.WAITING)return;const t=await this.methods.updatePostSession(this.chat.id,r);this.chat.update(t)}async destroyChat(){if(this.chat){if(this.chat.ongoing){const r=await this.methods.finishChat(this.chat.id);this.chat.update(r)}await this.chat.destroy(),this.chat=null,Pr.trackerId=""}}getChatDeflection(){return this.methods.getChatDeflection(this.chat.id)}sendChatTranscripts(r){return this.methods.sendChatTranscripts(this.chat.id,r)}async downloadChatTranscript(){return await this.methods.downloadChatTranscript(this.chat.id)}async getPdfStatus(r){return await this.methods.getPdfStatus(r)}getChatSurvey(){return this.methods.getChatSurvey(this.chat.id)}sendChatSurvey(r){if(this.chat.feedbackType!=="survey")throw new Error("Chat feedback type is: "+this.chat.feedbackType);return this.methods.sendChatSurvey(this.chat.id,r)}sendChatRate(r){if(this.chat.feedbackType!=="rate")throw new Error("Chat feedback type is: "+this.chat.feedbackType);return this.methods.rateChat(this.chat.id,r)}escalateChat(r){return this.methods.escalateChat(this.chat.id,r)}trackChatEscalation(r,t){return this.methods.trackEscalation(this.chat.id,r,t)}trackChatEndUserEvent(r){var t;return!r.end_user_name&&((t=this.user)!=null&&t.name)&&(r.end_user_name=this.user.name),this.methods.trackChatEndUserEvent(this.chat.id,r)}getChatHistory(r=1){return this.methods.getChatHistory(r)}async fetchMessages(){const r=await this.chat.fetchMessages();if(r.filter(t=>t.type==="server_message").length>0){const t=await this.methods.listChatTaskMessages(this.chat.id);return eI(r,t)}return r}async sendFileMessage(r){const t=await this.methods.uploadChatFile(this.chat.id,r);return this.chat.sendMessage(t,r)}async sendTextMessage(r){let t;return this.chat.inTask?t={type:"server_message",visibility:"task_virtual_agent",message_id:(await this.methods.sendChatTaskMessage(this.chat.id,r)).id}:t={type:"text",content:r},this.chat.sendMessage(t)}async createCobrowseCode(r,t){var a;await this.initializeCobrowse(r||this.lang);let n=Or.get("cobrowse");n||(n=Date.now().toString(),Or.set("cobrowse",n));const i={device_id:this.deviceId,device_name:`${Pr.application} / ${Pr.version}`,nonce:n,...t};return(a=this.user)!=null&&a.name&&(i.user_name=this.user.name),this.cobrowse.setCustomData(i),this.cobrowse.createSessionCode()}async startCobrowse(r="end_user"){if(!this.chat.cobrowsable)throw new Error(`Chat ${this.chat.id} does not support cobrowse.`);const t={chatId:`chat_${this.chat.id}`},n=await this.createCobrowseCode(this.chat.lang,t);if(n){const i=Or.get("cobrowse");await this.methods.requestChatCobrowse(this.chat.id,{code:n,from:r,nonce:i})}}async getMessageAttachment(r){if(r.$userType!=="end_user"&&iO.includes(r.type)){const t=await this.methods.getMedia(r.media_id,r.type);return this.chat&&this.chat.saveMedia(r.$index,t),t}return null}async initializeCobrowse(r){if(!this.cobrowse){const t=this.options.cobrowse.messages||nO(r),n={...this.options.cobrowse,messages:t,lang:r};this.cobrowse=await Sv.create(n),this.cobrowse.start(),["loaded","updated","ended"].forEach(a=>{this.cobrowse.on(`session.${a}`,s=>{this.events.triggerEvent(`cobrowse.${a}`,s)})})}}registerOngoingChat(r){this.events.triggerEvent("chat.ongoing",r),r._setGlobalEvents(this.events,this.methods.getChatTaskMessage.bind(this.methods)),r.on("_requestCobrowse",t=>{t==="agent"?this.startCobrowse(t):this.initializeCobrowse(r.lang),this.events.triggerEvent("cobrowse.request",{from:t})}),r.on("disconnected",()=>{Or.del("chat"),Or.del("cobrowse")}),this.chat=r,Pr.trackerId=`chat_${r.id}`,Or.set("chat",r.id.toString()),r.cobrowsable&&Or.get("cobrowse")&&this.initializeCobrowse(r.lang)}};var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function I0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function O0(e){if(e.__esModule)return e;var r=e.default;if(typeof r=="function"){var t=function n(){return this instanceof n?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),t}var P0={},yo=function(e){return e&&e.Math===Math&&e},_t=yo(typeof globalThis=="object"&&globalThis)||yo(typeof window=="object"&&window)||yo(typeof self=="object"&&self)||yo(typeof Ae=="object"&&Ae)||yo(typeof Ae=="object"&&Ae)||function(){return this}()||Function("return this")(),Bi={},lt=function(e){try{return!!e()}catch{return!0}},sO=lt,Wt=!sO(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),oO=lt,nu=!oO(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),uO=nu,Bu=Function.prototype.call,Ft=uO?Bu.bind(Bu):function(){return Bu.apply(Bu,arguments)},iu={},A0={}.propertyIsEnumerable,M0=Object.getOwnPropertyDescriptor,cO=M0&&!A0.call({1:2},1);iu.f=cO?function(r){var t=M0(this,r);return!!t&&t.enumerable}:A0;var ts=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},x0=nu,N0=Function.prototype,Dp=N0.call,lO=x0&&N0.bind.bind(Dp,Dp),vt=x0?lO:function(e){return function(){return Dp.apply(e,arguments)}},L0=vt,fO=L0({}.toString),dO=L0("".slice),li=function(e){return dO(fO(e),8,-1)},pO=vt,hO=lt,vO=li,Nf=Object,mO=pO("".split),au=hO(function(){return!Nf("z").propertyIsEnumerable(0)})?function(e){return vO(e)==="String"?mO(e,""):Nf(e)}:Nf,Hn=function(e){return e==null},gO=Hn,yO=TypeError,Kn=function(e){if(gO(e))throw new yO("Can't call method on "+e);return e},bO=au,_O=Kn,dn=function(e){return bO(_O(e))},Lf=typeof document=="object"&&document.all,Ut=typeof Lf>"u"&&Lf!==void 0?function(e){return typeof e=="function"||e===Lf}:function(e){return typeof e=="function"},wO=Ut,Jt=function(e){return typeof e=="object"?e!==null:wO(e)},Df=_t,SO=Ut,CO=function(e){return SO(e)?e:void 0},$n=function(e,r){return arguments.length<2?CO(Df[e]):Df[e]&&Df[e][r]},TO=vt,qi=TO({}.isPrototypeOf),EO=_t,Ig=EO.navigator,Og=Ig&&Ig.userAgent,Ca=Og?String(Og):"",D0=_t,jf=Ca,Pg=D0.process,Ag=D0.Deno,Mg=Pg&&Pg.versions||Ag&&Ag.version,xg=Mg&&Mg.v8,Bn,ll;xg&&(Bn=xg.split("."),ll=Bn[0]>0&&Bn[0]<4?1:+(Bn[0]+Bn[1]));!ll&&jf&&(Bn=jf.match(/Edge\/(\d+)/),(!Bn||Bn[1]>=74)&&(Bn=jf.match(/Chrome\/(\d+)/),Bn&&(ll=+Bn[1])));var ro=ll,Ng=ro,kO=lt,RO=_t,$O=RO.String,no=!!Object.getOwnPropertySymbols&&!kO(function(){var e=Symbol("symbol detection");return!$O(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Ng&&Ng<41}),IO=no,j0=IO&&!Symbol.sham&&typeof Symbol.iterator=="symbol",OO=$n,PO=Ut,AO=qi,MO=j0,xO=Object,io=MO?function(e){return typeof e=="symbol"}:function(e){var r=OO("Symbol");return PO(r)&&AO(r.prototype,xO(e))},NO=String,rs=function(e){try{return NO(e)}catch{return"Object"}},LO=Ut,DO=rs,jO=TypeError,In=function(e){if(LO(e))return e;throw new jO(DO(e)+" is not a function")},FO=In,UO=Hn,ns=function(e,r){var t=e[r];return UO(t)?void 0:FO(t)},Ff=Ft,Uf=Ut,Bf=Jt,BO=TypeError,qO=function(e,r){var t,n;if(r==="string"&&Uf(t=e.toString)&&!Bf(n=Ff(t,e))||Uf(t=e.valueOf)&&!Bf(n=Ff(t,e))||r!=="string"&&Uf(t=e.toString)&&!Bf(n=Ff(t,e)))return n;throw new BO("Can't convert object to primitive value")},F0={exports:{}},U0=!1,Lg=_t,zO=Object.defineProperty,Cv=function(e,r){try{zO(Lg,e,{value:r,configurable:!0,writable:!0})}catch{Lg[e]=r}return r},WO=_t,VO=Cv,Dg="__core-js_shared__",jg=F0.exports=WO[Dg]||VO(Dg,{});(jg.versions||(jg.versions=[])).push({version:"3.39.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Tv=F0.exports,Fg=Tv,ao=function(e,r){return Fg[e]||(Fg[e]=r||{})},GO=Kn,HO=Object,Mr=function(e){return HO(GO(e))},KO=vt,JO=Mr,YO=KO({}.hasOwnProperty),tr=Object.hasOwn||function(r,t){return YO(JO(r),t)},XO=vt,QO=0,ZO=Math.random(),eP=XO(1 .toString),su=function(e){return"Symbol("+(e===void 0?"":e)+")_"+eP(++QO+ZO,36)},tP=_t,rP=ao,Ug=tr,nP=su,iP=no,aP=j0,Is=tP.Symbol,qf=rP("wks"),sP=aP?Is.for||Is:Is&&Is.withoutSetter||nP,Bt=function(e){return Ug(qf,e)||(qf[e]=iP&&Ug(Is,e)?Is[e]:sP("Symbol."+e)),qf[e]},oP=Ft,Bg=Jt,qg=io,uP=ns,cP=qO,lP=Bt,fP=TypeError,dP=lP("toPrimitive"),Ev=function(e,r){if(!Bg(e)||qg(e))return e;var t=uP(e,dP),n;if(t){if(r===void 0&&(r="default"),n=oP(t,e,r),!Bg(n)||qg(n))return n;throw new fP("Can't convert object to primitive value")}return r===void 0&&(r="number"),cP(e,r)},pP=Ev,hP=io,Al=function(e){var r=pP(e,"string");return hP(r)?r:r+""},vP=_t,zg=Jt,jp=vP.document,mP=zg(jp)&&zg(jp.createElement),Ml=function(e){return mP?jp.createElement(e):{}},gP=Wt,yP=lt,bP=Ml,B0=!gP&&!yP(function(){return Object.defineProperty(bP("div"),"a",{get:function(){return 7}}).a!==7}),_P=Wt,wP=Ft,SP=iu,CP=ts,TP=dn,EP=Al,kP=tr,RP=B0,Wg=Object.getOwnPropertyDescriptor;Bi.f=_P?Wg:function(r,t){if(r=TP(r),t=EP(t),RP)try{return Wg(r,t)}catch{}if(kP(r,t))return CP(!wP(SP.f,r,t),r[t])};var Fr={},$P=Wt,IP=lt,q0=$P&&IP(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),OP=Jt,PP=String,AP=TypeError,ar=function(e){if(OP(e))return e;throw new AP(PP(e)+" is not an object")},MP=Wt,xP=B0,NP=q0,qu=ar,Vg=Al,LP=TypeError,zf=Object.defineProperty,DP=Object.getOwnPropertyDescriptor,Wf="enumerable",Vf="configurable",Gf="writable";Fr.f=MP?NP?function(r,t,n){if(qu(r),t=Vg(t),qu(n),typeof r=="function"&&t==="prototype"&&"value"in n&&Gf in n&&!n[Gf]){var i=DP(r,t);i&&i[Gf]&&(r[t]=n.value,n={configurable:Vf in n?n[Vf]:i[Vf],enumerable:Wf in n?n[Wf]:i[Wf],writable:!1})}return zf(r,t,n)}:zf:function(r,t,n){if(qu(r),t=Vg(t),qu(n),xP)try{return zf(r,t,n)}catch{}if("get"in n||"set"in n)throw new LP("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var jP=Wt,FP=Fr,UP=ts,zi=jP?function(e,r,t){return FP.f(e,r,UP(1,t))}:function(e,r,t){return e[r]=t,e},z0={exports:{}},Fp=Wt,BP=tr,W0=Function.prototype,qP=Fp&&Object.getOwnPropertyDescriptor,kv=BP(W0,"name"),zP=kv&&(function(){}).name==="something",WP=kv&&(!Fp||Fp&&qP(W0,"name").configurable),ou={EXISTS:kv,PROPER:zP,CONFIGURABLE:WP},VP=vt,GP=Ut,Up=Tv,HP=VP(Function.toString);GP(Up.inspectSource)||(Up.inspectSource=function(e){return HP(e)});var Rv=Up.inspectSource,KP=_t,JP=Ut,Gg=KP.WeakMap,YP=JP(Gg)&&/native code/.test(String(Gg)),XP=ao,QP=su,Hg=XP("keys"),xl=function(e){return Hg[e]||(Hg[e]=QP(e))},uu={},ZP=YP,V0=_t,eA=Jt,tA=zi,Hf=tr,Kf=Tv,rA=xl,nA=uu,Kg="Object already initialized",Bp=V0.TypeError,iA=V0.WeakMap,fl,Ko,dl,aA=function(e){return dl(e)?Ko(e):fl(e,{})},sA=function(e){return function(r){var t;if(!eA(r)||(t=Ko(r)).type!==e)throw new Bp("Incompatible receiver, "+e+" required");return t}};if(ZP||Kf.state){var ri=Kf.state||(Kf.state=new iA);ri.get=ri.get,ri.has=ri.has,ri.set=ri.set,fl=function(e,r){if(ri.has(e))throw new Bp(Kg);return r.facade=e,ri.set(e,r),r},Ko=function(e){return ri.get(e)||{}},dl=function(e){return ri.has(e)}}else{var ms=rA("state");nA[ms]=!0,fl=function(e,r){if(Hf(e,ms))throw new Bp(Kg);return r.facade=e,tA(e,ms,r),r},Ko=function(e){return Hf(e,ms)?e[ms]:{}},dl=function(e){return Hf(e,ms)}}var pn={set:fl,get:Ko,has:dl,enforce:aA,getterFor:sA},$v=vt,oA=lt,uA=Ut,zu=tr,qp=Wt,cA=ou.CONFIGURABLE,lA=Rv,G0=pn,fA=G0.enforce,dA=G0.get,Jg=String,Hc=Object.defineProperty,pA=$v("".slice),hA=$v("".replace),vA=$v([].join),mA=qp&&!oA(function(){return Hc(function(){},"length",{value:8}).length!==8}),gA=String(String).split("String"),yA=z0.exports=function(e,r,t){pA(Jg(r),0,7)==="Symbol("&&(r="["+hA(Jg(r),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(r="get "+r),t&&t.setter&&(r="set "+r),(!zu(e,"name")||cA&&e.name!==r)&&(qp?Hc(e,"name",{value:r,configurable:!0}):e.name=r),mA&&t&&zu(t,"arity")&&e.length!==t.arity&&Hc(e,"length",{value:t.arity});try{t&&zu(t,"constructor")&&t.constructor?qp&&Hc(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var n=fA(e);return zu(n,"source")||(n.source=vA(gA,typeof r=="string"?r:"")),e};Function.prototype.toString=yA(function(){return uA(this)&&dA(this).source||lA(this)},"toString");var H0=z0.exports,bA=Ut,_A=Fr,wA=H0,SA=Cv,Ur=function(e,r,t,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:r;if(bA(t)&&wA(t,a,n),n.global)i?e[r]=t:SA(r,t);else{try{n.unsafe?e[r]&&(i=!0):delete e[r]}catch{}i?e[r]=t:_A.f(e,r,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},is={},CA=Math.ceil,TA=Math.floor,EA=Math.trunc||function(r){var t=+r;return(t>0?TA:CA)(t)},kA=EA,fi=function(e){var r=+e;return r!==r||r===0?0:kA(r)},RA=fi,$A=Math.max,IA=Math.min,as=function(e,r){var t=RA(e);return t<0?$A(t+r,0):IA(t,r)},OA=fi,PA=Math.min,Wi=function(e){var r=OA(e);return r>0?PA(r,9007199254740991):0},AA=Wi,xr=function(e){return AA(e.length)},MA=dn,xA=as,NA=xr,Yg=function(e){return function(r,t,n){var i=MA(r),a=NA(i);if(a===0)return!e&&-1;var s=xA(n,a),o;if(e&&t!==t){for(;a>s;)if(o=i[s++],o!==o)return!0}else for(;a>s;s++)if((e||s in i)&&i[s]===t)return e||s||0;return!e&&-1}},Nl={includes:Yg(!0),indexOf:Yg(!1)},LA=vt,Jf=tr,DA=dn,jA=Nl.indexOf,FA=uu,Xg=LA([].push),K0=function(e,r){var t=DA(e),n=0,i=[],a;for(a in t)!Jf(FA,a)&&Jf(t,a)&&Xg(i,a);for(;r.length>n;)Jf(t,a=r[n++])&&(~jA(i,a)||Xg(i,a));return i},Iv=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],UA=K0,BA=Iv,qA=BA.concat("length","prototype");is.f=Object.getOwnPropertyNames||function(r){return UA(r,qA)};var cu={};cu.f=Object.getOwnPropertySymbols;var zA=$n,WA=vt,VA=is,GA=cu,HA=ar,KA=WA([].concat),J0=zA("Reflect","ownKeys")||function(r){var t=VA.f(HA(r)),n=GA.f;return n?KA(t,n(r)):t},Qg=tr,JA=J0,YA=Bi,XA=Fr,Ov=function(e,r,t){for(var n=JA(r),i=XA.f,a=YA.f,s=0;s<n.length;s++){var o=n[s];!Qg(e,o)&&!(t&&Qg(t,o))&&i(e,o,a(r,o))}},QA=lt,ZA=Ut,eM=/#|\.prototype\./,lu=function(e,r){var t=rM[tM(e)];return t===iM?!0:t===nM?!1:ZA(r)?QA(r):!!r},tM=lu.normalize=function(e){return String(e).replace(eM,".").toLowerCase()},rM=lu.data={},nM=lu.NATIVE="N",iM=lu.POLYFILL="P",Ll=lu,Wu=_t,aM=Bi.f,sM=zi,oM=Ur,uM=Cv,cM=Ov,lM=Ll,gt=function(e,r){var t=e.target,n=e.global,i=e.stat,a,s,o,u,c,l;if(n?s=Wu:i?s=Wu[t]||uM(t,{}):s=Wu[t]&&Wu[t].prototype,s)for(o in r){if(c=r[o],e.dontCallGetSet?(l=aM(s,o),u=l&&l.value):u=s[o],a=lM(n?o:t+(i?".":"#")+o,e.forced),!a&&u!==void 0){if(typeof c==typeof u)continue;cM(c,u)}(e.sham||u&&u.sham)&&sM(c,"sham",!0),oM(s,o,c,e)}},fM=Fr.f,dM=tr,pM=Bt,Zg=pM("toStringTag"),di=function(e,r,t){e&&!t&&(e=e.prototype),e&&!dM(e,Zg)&&fM(e,Zg,{configurable:!0,value:r})},hM=gt,vM=_t,mM=di;hM({global:!0},{Reflect:{}});mM(vM.Reflect,"Reflect",!0);var gM=nu,Y0=Function.prototype,ey=Y0.apply,ty=Y0.call,ss=typeof Reflect=="object"&&Reflect.apply||(gM?ty.bind(ey):function(){return ty.apply(ey,arguments)}),yM=vt,pi=yM([].slice),X0=vt,bM=In,_M=Jt,wM=tr,ry=pi,SM=nu,Q0=Function,CM=X0([].concat),TM=X0([].join),Yf={},EM=function(e,r,t){if(!wM(Yf,r)){for(var n=[],i=0;i<r;i++)n[i]="a["+i+"]";Yf[r]=Q0("C,a","return new C("+TM(n,",")+")")}return Yf[r](e,t)},kM=SM?Q0.bind:function(r){var t=bM(this),n=t.prototype,i=ry(arguments,1),a=function(){var o=CM(i,ry(arguments));return this instanceof a?EM(t,o.length,o):t.apply(r,o)};return _M(n)&&(a.prototype=n),a},RM=Bt,$M=RM("toStringTag"),Z0={};Z0[$M]="z";var Pv=String(Z0)==="[object z]",IM=Pv,OM=Ut,Kc=li,PM=Bt,AM=PM("toStringTag"),MM=Object,xM=Kc(function(){return arguments}())==="Arguments",NM=function(e,r){try{return e[r]}catch{}},Vi=IM?Kc:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=NM(r=MM(e),AM))=="string"?t:xM?Kc(r):(n=Kc(r))==="Object"&&OM(r.callee)?"Arguments":n},LM=vt,DM=lt,eC=Ut,jM=Vi,FM=$n,UM=Rv,tC=function(){},rC=FM("Reflect","construct"),Av=/^\s*(?:class|function)\b/,BM=LM(Av.exec),qM=!Av.test(tC),bo=function(r){if(!eC(r))return!1;try{return rC(tC,[],r),!0}catch{return!1}},nC=function(r){if(!eC(r))return!1;switch(jM(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return qM||!!BM(Av,UM(r))}catch{return!0}};nC.sham=!0;var Dl=!rC||DM(function(){var e;return bo(bo.call)||!bo(Object)||!bo(function(){e=!0})||e})?nC:bo,zM=Dl,WM=rs,VM=TypeError,Mv=function(e){if(zM(e))return e;throw new VM(WM(e)+" is not a constructor")},xv={},GM=K0,HM=Iv,fu=Object.keys||function(r){return GM(r,HM)},KM=Wt,JM=q0,YM=Fr,XM=ar,QM=dn,ZM=fu;xv.f=KM&&!JM?Object.defineProperties:function(r,t){XM(r);for(var n=QM(t),i=ZM(t),a=i.length,s=0,o;a>s;)YM.f(r,o=i[s++],n[o]);return r};var ex=$n,iC=ex("document","documentElement"),tx=ar,rx=xv,ny=Iv,nx=uu,ix=iC,ax=Ml,sx=xl,iy=">",ay="<",zp="prototype",Wp="script",aC=sx("IE_PROTO"),Xf=function(){},sC=function(e){return ay+Wp+iy+e+ay+"/"+Wp+iy},sy=function(e){e.write(sC("")),e.close();var r=e.parentWindow.Object;return e=null,r},ox=function(){var e=ax("iframe"),r="java"+Wp+":",t;return e.style.display="none",ix.appendChild(e),e.src=String(r),t=e.contentWindow.document,t.open(),t.write(sC("document.F=Object")),t.close(),t.F},Vu,Jc=function(){try{Vu=new ActiveXObject("htmlfile")}catch{}Jc=typeof document<"u"?document.domain&&Vu?sy(Vu):ox():sy(Vu);for(var e=ny.length;e--;)delete Jc[zp][ny[e]];return Jc()};nx[aC]=!0;var Ta=Object.create||function(r,t){var n;return r!==null?(Xf[zp]=tx(r),n=new Xf,Xf[zp]=null,n[aC]=r):n=Jc(),t===void 0?n:rx.f(n,t)},ux=gt,cx=$n,Qf=ss,lx=kM,oy=Mv,fx=ar,uy=Jt,dx=Ta,oC=lt,Nv=cx("Reflect","construct"),px=Object.prototype,hx=[].push,uC=oC(function(){function e(){}return!(Nv(function(){},[],e)instanceof e)}),cC=!oC(function(){Nv(function(){})}),cy=uC||cC;ux({target:"Reflect",stat:!0,forced:cy,sham:cy},{construct:function(r,t){oy(r),fx(t);var n=arguments.length<3?r:oy(arguments[2]);if(cC&&!uC)return Nv(r,t,n);if(r===n){switch(t.length){case 0:return new r;case 1:return new r(t[0]);case 2:return new r(t[0],t[1]);case 3:return new r(t[0],t[1],t[2]);case 4:return new r(t[0],t[1],t[2],t[3])}var i=[null];return Qf(hx,i,t),new(Qf(lx,r,i))}var a=n.prototype,s=dx(uy(a)?a:px),o=Qf(r,s,t);return uy(o)?o:s}});var vx=gt,mx=Mr,lC=fu,gx=lt,yx=gx(function(){lC(1)});vx({target:"Object",stat:!0,forced:yx},{keys:function(r){return lC(mx(r))}});var bx=Vi,_x=String,wr=function(e){if(bx(e)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return _x(e)},Lv={},wx=li,Sx=dn,fC=is.f,Cx=pi,dC=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Tx=function(e){try{return fC(e)}catch{return Cx(dC)}};Lv.f=function(r){return dC&&wx(r)==="Window"?Tx(r):fC(Sx(r))};var ly=H0,Ex=Fr,hi=function(e,r,t){return t.get&&ly(t.get,r,{getter:!0}),t.set&&ly(t.set,r,{setter:!0}),Ex.f(e,r,t)},Dv={},kx=Bt;Dv.f=kx;var Rx=_t,pC=Rx,fy=pC,$x=tr,Ix=Dv,Ox=Fr.f,hC=function(e){var r=fy.Symbol||(fy.Symbol={});$x(r,e)||Ox(r,e,{value:Ix.f(e)})},Px=Ft,Ax=$n,Mx=Bt,xx=Ur,Nx=function(){var e=Ax("Symbol"),r=e&&e.prototype,t=r&&r.valueOf,n=Mx("toPrimitive");r&&!r[n]&&xx(r,n,function(i){return Px(t,this)},{arity:1})},Lx=li,Dx=vt,jv=function(e){if(Lx(e)==="Function")return Dx(e)},dy=jv,jx=In,Fx=nu,Ux=dy(dy.bind),Gi=function(e,r){return jx(e),r===void 0?e:Fx?Ux(e,r):function(){return e.apply(r,arguments)}},Bx=li,du=Array.isArray||function(r){return Bx(r)==="Array"},py=du,qx=Dl,zx=Jt,Wx=Bt,Vx=Wx("species"),hy=Array,Gx=function(e){var r;return py(e)&&(r=e.constructor,qx(r)&&(r===hy||py(r.prototype))?r=void 0:zx(r)&&(r=r[Vx],r===null&&(r=void 0))),r===void 0?hy:r},Hx=Gx,Fv=function(e,r){return new(Hx(e))(r===0?0:r)},Kx=Gi,Jx=vt,Yx=au,Xx=Mr,Qx=xr,Zx=Fv,vy=Jx([].push),Da=function(e){var r=e===1,t=e===2,n=e===3,i=e===4,a=e===6,s=e===7,o=e===5||a;return function(u,c,l,h){for(var v=Xx(u),m=Yx(v),_=Qx(m),C=Kx(c,l),I=0,$=h||Zx,x=r?$(u,_):t||s?$(u,0):void 0,N,q;_>I;I++)if((o||I in m)&&(N=m[I],q=C(N,I,v),e))if(r)x[I]=q;else if(q)switch(e){case 3:return!0;case 5:return N;case 6:return I;case 2:vy(x,N)}else switch(e){case 4:return!1;case 7:vy(x,N)}return a?-1:n||i?i:x}},Zr={forEach:Da(0),map:Da(1),filter:Da(2),some:Da(3),every:Da(4),find:Da(5),findIndex:Da(6)},jl=gt,pu=_t,Uv=Ft,eN=vt,Gs=Wt,Hs=no,tN=lt,Er=tr,rN=qi,Vp=ar,Fl=dn,Bv=Al,nN=wr,Gp=ts,Ks=Ta,vC=fu,iN=is,mC=Lv,aN=cu,gC=Bi,yC=Fr,sN=xv,bC=iu,Zf=Ur,oN=hi,qv=ao,uN=xl,_C=uu,my=su,cN=Bt,lN=Dv,fN=hC,dN=Nx,pN=di,wC=pn,Ul=Zr.forEach,Jr=uN("hidden"),Bl="Symbol",Jo="prototype",hN=wC.set,gy=wC.getterFor(Bl),Rn=Object[Jo],Ka=pu.Symbol,xo=Ka&&Ka[Jo],vN=pu.RangeError,mN=pu.TypeError,ed=pu.QObject,SC=gC.f,Ja=yC.f,CC=mC.f,gN=bC.f,TC=eN([].push),Di=qv("symbols"),hu=qv("op-symbols"),yN=qv("wks"),Hp=!ed||!ed[Jo]||!ed[Jo].findChild,EC=function(e,r,t){var n=SC(Rn,r);n&&delete Rn[r],Ja(e,r,t),n&&e!==Rn&&Ja(Rn,r,n)},Kp=Gs&&tN(function(){return Ks(Ja({},"a",{get:function(){return Ja(this,"a",{value:7}).a}})).a!==7})?EC:Ja,td=function(e,r){var t=Di[e]=Ks(xo);return hN(t,{type:Bl,tag:e,description:r}),Gs||(t.description=r),t},ql=function(r,t,n){r===Rn&&ql(hu,t,n),Vp(r);var i=Bv(t);return Vp(n),Er(Di,i)?(n.enumerable?(Er(r,Jr)&&r[Jr][i]&&(r[Jr][i]=!1),n=Ks(n,{enumerable:Gp(0,!1)})):(Er(r,Jr)||Ja(r,Jr,Gp(1,Ks(null))),r[Jr][i]=!0),Kp(r,i,n)):Ja(r,i,n)},zv=function(r,t){Vp(r);var n=Fl(t),i=vC(n).concat($C(n));return Ul(i,function(a){(!Gs||Uv(Jp,n,a))&&ql(r,a,n[a])}),r},bN=function(r,t){return t===void 0?Ks(r):zv(Ks(r),t)},Jp=function(r){var t=Bv(r),n=Uv(gN,this,t);return this===Rn&&Er(Di,t)&&!Er(hu,t)?!1:n||!Er(this,t)||!Er(Di,t)||Er(this,Jr)&&this[Jr][t]?n:!0},kC=function(r,t){var n=Fl(r),i=Bv(t);if(!(n===Rn&&Er(Di,i)&&!Er(hu,i))){var a=SC(n,i);return a&&Er(Di,i)&&!(Er(n,Jr)&&n[Jr][i])&&(a.enumerable=!0),a}},RC=function(r){var t=CC(Fl(r)),n=[];return Ul(t,function(i){!Er(Di,i)&&!Er(_C,i)&&TC(n,i)}),n},$C=function(e){var r=e===Rn,t=CC(r?hu:Fl(e)),n=[];return Ul(t,function(i){Er(Di,i)&&(!r||Er(Rn,i))&&TC(n,Di[i])}),n};Hs||(Ka=function(){if(rN(xo,this))throw new mN("Symbol is not a constructor");var r=!arguments.length||arguments[0]===void 0?void 0:nN(arguments[0]),t=my(r),n=function(i){var a=this===void 0?pu:this;a===Rn&&Uv(n,hu,i),Er(a,Jr)&&Er(a[Jr],t)&&(a[Jr][t]=!1);var s=Gp(1,i);try{Kp(a,t,s)}catch(o){if(!(o instanceof vN))throw o;EC(a,t,s)}};return Gs&&Hp&&Kp(Rn,t,{configurable:!0,set:n}),td(t,r)},xo=Ka[Jo],Zf(xo,"toString",function(){return gy(this).tag}),Zf(Ka,"withoutSetter",function(e){return td(my(e),e)}),bC.f=Jp,yC.f=ql,sN.f=zv,gC.f=kC,iN.f=mC.f=RC,aN.f=$C,lN.f=function(e){return td(cN(e),e)},Gs&&(oN(xo,"description",{configurable:!0,get:function(){return gy(this).description}}),Zf(Rn,"propertyIsEnumerable",Jp,{unsafe:!0})));jl({global:!0,constructor:!0,wrap:!0,forced:!Hs,sham:!Hs},{Symbol:Ka});Ul(vC(yN),function(e){fN(e)});jl({target:Bl,stat:!0,forced:!Hs},{useSetter:function(){Hp=!0},useSimple:function(){Hp=!1}});jl({target:"Object",stat:!0,forced:!Hs,sham:!Gs},{create:bN,defineProperty:ql,defineProperties:zv,getOwnPropertyDescriptor:kC});jl({target:"Object",stat:!0,forced:!Hs},{getOwnPropertyNames:RC});dN();pN(Ka,Bl);_C[Jr]=!0;var _N=no,IC=_N&&!!Symbol.for&&!!Symbol.keyFor,wN=gt,SN=$n,CN=tr,TN=wr,OC=ao,EN=IC,rd=OC("string-to-symbol-registry"),kN=OC("symbol-to-string-registry");wN({target:"Symbol",stat:!0,forced:!EN},{for:function(e){var r=TN(e);if(CN(rd,r))return rd[r];var t=SN("Symbol")(r);return rd[r]=t,kN[t]=r,t}});var RN=gt,$N=tr,IN=io,ON=rs,PN=ao,AN=IC,yy=PN("symbol-to-string-registry");RN({target:"Symbol",stat:!0,forced:!AN},{keyFor:function(r){if(!IN(r))throw new TypeError(ON(r)+" is not a symbol");if($N(yy,r))return yy[r]}});var MN=vt,by=du,xN=Ut,_y=li,NN=wr,wy=MN([].push),LN=function(e){if(xN(e))return e;if(by(e)){for(var r=e.length,t=[],n=0;n<r;n++){var i=e[n];typeof i=="string"?wy(t,i):(typeof i=="number"||_y(i)==="Number"||_y(i)==="String")&&wy(t,NN(i))}var a=t.length,s=!0;return function(o,u){if(s)return s=!1,u;if(by(this))return u;for(var c=0;c<a;c++)if(t[c]===o)return u}}},DN=gt,PC=$n,AC=ss,jN=Ft,vu=vt,MC=lt,Sy=Ut,Cy=io,xC=pi,FN=LN,UN=no,BN=String,va=PC("JSON","stringify"),Gu=vu(/./.exec),Ty=vu("".charAt),qN=vu("".charCodeAt),zN=vu("".replace),WN=vu(1 .toString),VN=/[\uD800-\uDFFF]/g,Ey=/^[\uD800-\uDBFF]$/,ky=/^[\uDC00-\uDFFF]$/,Ry=!UN||MC(function(){var e=PC("Symbol")("stringify detection");return va([e])!=="[null]"||va({a:e})!=="{}"||va(Object(e))!=="{}"}),$y=MC(function(){return va("\uDF06\uD834")!=='"\\udf06\\ud834"'||va("\uDEAD")!=='"\\udead"'}),GN=function(e,r){var t=xC(arguments),n=FN(r);if(!(!Sy(n)&&(e===void 0||Cy(e))))return t[1]=function(i,a){if(Sy(n)&&(a=jN(n,this,BN(i),a)),!Cy(a))return a},AC(va,null,t)},HN=function(e,r,t){var n=Ty(t,r-1),i=Ty(t,r+1);return Gu(Ey,e)&&!Gu(ky,i)||Gu(ky,e)&&!Gu(Ey,n)?"\\u"+WN(qN(e,0),16):e};va&&DN({target:"JSON",stat:!0,arity:3,forced:Ry||$y},{stringify:function(r,t,n){var i=xC(arguments),a=AC(Ry?GN:va,null,i);return $y&&typeof a=="string"?zN(a,VN,HN):a}});var KN=gt,JN=no,YN=lt,NC=cu,XN=Mr,QN=!JN||YN(function(){NC.f(1)});KN({target:"Object",stat:!0,forced:QN},{getOwnPropertySymbols:function(r){var t=NC.f;return t?t(XN(r)):[]}});var ZN=lt,eL=Bt,tL=ro,rL=eL("species"),mu=function(e){return tL>=51||!ZN(function(){var r=[],t=r.constructor={};return t[rL]=function(){return{foo:1}},r[e](Boolean).foo!==1})},nL=gt,iL=Zr.filter,aL=mu,sL=aL("filter");nL({target:"Array",proto:!0,forced:!sL},{filter:function(r){return iL(this,r,arguments.length>1?arguments[1]:void 0)}});var oL=gt,uL=lt,cL=dn,LC=Bi.f,DC=Wt,lL=!DC||uL(function(){LC(1)});oL({target:"Object",stat:!0,forced:lL,sham:!DC},{getOwnPropertyDescriptor:function(r,t){return LC(cL(r),t)}});var fL=Wt,dL=Fr,pL=ts,gu=function(e,r,t){fL?dL.f(e,r,pL(0,t)):e[r]=t},hL=gt,vL=Wt,mL=J0,gL=dn,yL=Bi,bL=gu;hL({target:"Object",stat:!0,sham:!vL},{getOwnPropertyDescriptors:function(r){for(var t=gL(r),n=yL.f,i=mL(t),a={},s=0,o,u;i.length>s;)u=n(t,o=i[s++]),u!==void 0&&bL(a,o,u);return a}});var jC={exports:{}};(function(e){function r(n,i,a,s,o,u,c){try{var l=n[u](c),h=l.value}catch(v){return void a(v)}l.done?i(h):Promise.resolve(h).then(s,o)}function t(n){return function(){var i=this,a=arguments;return new Promise(function(s,o){var u=n.apply(i,a);function c(h){r(u,s,o,c,l,"next",h)}function l(h){r(u,s,o,c,l,"throw",h)}c(void 0)})}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(jC);var yu=jC.exports,FC={exports:{}};(function(e){function r(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(FC);var os=FC.exports,UC={exports:{}},BC={exports:{}};(function(e){function r(t,n){return e.exports=r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,a){return i.__proto__=a,i},e.exports.__esModule=!0,e.exports.default=e.exports,r(t,n)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(BC);var Wv=BC.exports;(function(e){var r=Wv;function t(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&&r(n,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(UC);var vi=UC.exports,qC={exports:{}},zC={exports:{}};(function(e){function r(t){"@babel/helpers - typeof";return e.exports=r=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},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(zC);var On=zC.exports;(function(e){var r=On.default,t=os;function n(i,a){if(a&&(r(a)=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return t(i)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(qC);var mi=qC.exports,WC={exports:{}};(function(e){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(WC);var Pn=WC.exports,VC={exports:{}},GC={exports:{}},HC={exports:{}};(function(e){var r=On.default;function t(n,i){if(r(n)!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(r(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(HC);var _L=HC.exports;(function(e){var r=On.default,t=_L;function n(i){var a=t(i,"string");return r(a)=="symbol"?a:a+""}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(GC);var KC=GC.exports;(function(e){var r=KC;function t(n,i,a){return(i=r(i))in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(VC);var us=VC.exports,JC={exports:{}};(function(e){var r=KC;function t(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,r(o.key),o)}}function n(i,a,s){return a&&t(i.prototype,a),s&&t(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(JC);var Ea=JC.exports,YC={exports:{}};(function(e){function r(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(YC);var gi=YC.exports,wL=gt,SL=Zr.map,CL=mu,TL=CL("map");wL({target:"Array",proto:!0,forced:!TL},{map:function(r){return SL(this,r,arguments.length>1?arguments[1]:void 0)}});var EL=Pv,kL=Vi,RL=EL?{}.toString:function(){return"[object "+kL(this)+"]"},$L=Pv,IL=Ur,OL=RL;$L||IL(Object.prototype,"toString",OL,{unsafe:!0});var XC={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},PL=Ml,nd=PL("span").classList,Iy=nd&&nd.constructor&&nd.constructor.prototype,QC=Iy===Object.prototype?void 0:Iy,AL=lt,zl=function(e,r){var t=[][e];return!!t&&AL(function(){t.call(null,r||function(){return 1},1)})},ML=Zr.forEach,xL=zl,NL=xL("forEach"),LL=NL?[].forEach:function(r){return ML(this,r,arguments.length>1?arguments[1]:void 0)},Oy=_t,Py=XC,DL=QC,id=LL,jL=zi,ZC=function(e){if(e&&e.forEach!==id)try{jL(e,"forEach",id)}catch{e.forEach=id}};for(var ad in Py)Py[ad]&&ZC(Oy[ad]&&Oy[ad].prototype);ZC(DL);var _o=_t,FL=Ca,UL=li,Hu=function(e){return FL.slice(0,e.length)===e},eT=function(){return Hu("Bun/")?"BUN":Hu("Cloudflare-Workers")?"CLOUDFLARE":Hu("Deno/")?"DENO":Hu("Node.js/")?"NODE":_o.Bun&&typeof Bun.version=="string"?"BUN":_o.Deno&&typeof Deno.version=="object"?"DENO":UL(_o.process)==="process"?"NODE":_o.window&&_o.document?"BROWSER":"REST"}(),BL=eT,Vv=BL==="NODE",qL=vt,zL=In,WL=function(e,r,t){try{return qL(zL(Object.getOwnPropertyDescriptor(e,r)[t]))}catch{}},VL=Jt,GL=function(e){return VL(e)||e===null},HL=GL,KL=String,JL=TypeError,YL=function(e){if(HL(e))return e;throw new JL("Can't set "+KL(e)+" as a prototype")},XL=WL,QL=Jt,ZL=Kn,e2=YL,so=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=XL(Object.prototype,"__proto__","set"),t(r,[]),e=r instanceof Array}catch{}return function(i,a){return ZL(i),e2(a),QL(i)&&(e?t(i,a):i.__proto__=a),i}}():void 0),t2=$n,r2=hi,n2=Bt,i2=Wt,Ay=n2("species"),Wl=function(e){var r=t2(e);i2&&r&&!r[Ay]&&r2(r,Ay,{configurable:!0,get:function(){return this}})},a2=qi,s2=TypeError,ka=function(e,r){if(a2(r,e))return e;throw new s2("Incorrect invocation")},My=ar,o2=Mv,u2=Hn,c2=Bt,l2=c2("species"),tT=function(e,r){var t=My(e).constructor,n;return t===void 0||u2(n=My(t)[l2])?r:o2(n)},f2=TypeError,Gv=function(e,r){if(e<r)throw new f2("Not enough arguments");return e},d2=Ca,rT=/(?:ipad|iphone|ipod).*applewebkit/i.test(d2),ln=_t,p2=ss,h2=Gi,xy=Ut,v2=tr,nT=lt,Ny=iC,m2=pi,Ly=Ml,g2=Gv,y2=rT,b2=Vv,Yp=ln.setImmediate,Dy=ln.clearImmediate,_2=ln.process,sd=ln.Dispatch,w2=ln.Function,jy=ln.MessageChannel,S2=ln.String,od=0,Uo={},Fy="onreadystatechange",Yo,ja,ud,cd;nT(function(){Yo=ln.location});var Hv=function(e){if(v2(Uo,e)){var r=Uo[e];delete Uo[e],r()}},ld=function(e){return function(){Hv(e)}},Uy=function(e){Hv(e.data)},By=function(e){ln.postMessage(S2(e),Yo.protocol+"//"+Yo.host)};(!Yp||!Dy)&&(Yp=function(r){g2(arguments.length,1);var t=xy(r)?r:w2(r),n=m2(arguments,1);return Uo[++od]=function(){p2(t,void 0,n)},ja(od),od},Dy=function(r){delete Uo[r]},b2?ja=function(e){_2.nextTick(ld(e))}:sd&&sd.now?ja=function(e){sd.now(ld(e))}:jy&&!y2?(ud=new jy,cd=ud.port2,ud.port1.onmessage=Uy,ja=h2(cd.postMessage,cd)):ln.addEventListener&&xy(ln.postMessage)&&!ln.importScripts&&Yo&&Yo.protocol!=="file:"&&!nT(By)?(ja=By,ln.addEventListener("message",Uy,!1)):Fy in Ly("script")?ja=function(e){Ny.appendChild(Ly("script"))[Fy]=function(){Ny.removeChild(this),Hv(e)}}:ja=function(e){setTimeout(ld(e),0)});var iT={set:Yp},qy=_t,C2=Wt,T2=Object.getOwnPropertyDescriptor,aT=function(e){if(!C2)return qy[e];var r=T2(qy,e);return r&&r.value},sT=function(){this.head=null,this.tail=null};sT.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var oT=sT,E2=Ca,k2=/ipad|iphone|ipod/i.test(E2)&&typeof Pebble<"u",R2=Ca,$2=/web0s(?!.*chrome)/i.test(R2),Js=_t,I2=aT,zy=Gi,fd=iT.set,O2=oT,P2=rT,A2=k2,M2=$2,dd=Vv,Wy=Js.MutationObserver||Js.WebKitMutationObserver,Vy=Js.document,Gy=Js.process,Ku=Js.Promise,Xp=I2("queueMicrotask"),gs,pd,hd,Ju,Hy;if(!Xp){var Yu=new O2,Xu=function(){var e,r;for(dd&&(e=Gy.domain)&&e.exit();r=Yu.get();)try{r()}catch(t){throw Yu.head&&gs(),t}e&&e.enter()};!P2&&!dd&&!M2&&Wy&&Vy?(pd=!0,hd=Vy.createTextNode(""),new Wy(Xu).observe(hd,{characterData:!0}),gs=function(){hd.data=pd=!pd}):!A2&&Ku&&Ku.resolve?(Ju=Ku.resolve(void 0),Ju.constructor=Ku,Hy=zy(Ju.then,Ju),gs=function(){Hy(Xu)}):dd?gs=function(){Gy.nextTick(Xu)}:(fd=zy(fd,Js),gs=function(){fd(Xu)}),Xp=function(e){Yu.head||gs(),Yu.add(e)}}var x2=Xp,N2=function(e,r){try{arguments.length===1?console.error(e):console.error(e,r)}catch{}},Kv=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},L2=_t,Vl=L2.Promise,D2=_t,Bo=Vl,j2=Ut,F2=Ll,U2=Rv,B2=Bt,Ky=eT,vd=ro;Bo&&Bo.prototype;var q2=B2("species"),Qp=!1,uT=j2(D2.PromiseRejectionEvent),z2=F2("Promise",function(){var e=U2(Bo),r=e!==String(Bo);if(!r&&vd===66)return!0;if(!vd||vd<51||!/native code/.test(e)){var t=new Bo(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=t.constructor={};if(i[q2]=n,Qp=t.then(function(){})instanceof n,!Qp)return!0}return!r&&(Ky==="BROWSER"||Ky==="DENO")&&!uT}),bu={CONSTRUCTOR:z2,REJECTION_EVENT:uT,SUBCLASSING:Qp},oo={},Jy=In,W2=TypeError,V2=function(e){var r,t;this.promise=new e(function(n,i){if(r!==void 0||t!==void 0)throw new W2("Bad Promise constructor");r=n,t=i}),this.resolve=Jy(r),this.reject=Jy(t)};oo.f=function(e){return new V2(e)};var G2=gt,pl=Vv,ba=_t,Ys=Ft,Yy=Ur,Xy=so,H2=di,K2=Wl,J2=In,Yc=Ut,Y2=Jt,X2=ka,Q2=tT,cT=iT.set,Jv=x2,Z2=N2,eD=Kv,tD=oT,lT=pn,hl=Vl,Yv=bu,fT=oo,Gl="Promise",dT=Yv.CONSTRUCTOR,rD=Yv.REJECTION_EVENT,nD=Yv.SUBCLASSING,md=lT.getterFor(Gl),iD=lT.set,ks=hl&&hl.prototype,Ga=hl,Qu=ks,pT=ba.TypeError,Zp=ba.document,Xv=ba.process,eh=fT.f,aD=eh,sD=!!(Zp&&Zp.createEvent&&ba.dispatchEvent),hT="unhandledrejection",oD="rejectionhandled",Qy=0,vT=1,uD=2,Qv=1,mT=2,Zu,Zy,cD,eb,gT=function(e){var r;return Y2(e)&&Yc(r=e.then)?r:!1},yT=function(e,r){var t=r.value,n=r.state===vT,i=n?e.ok:e.fail,a=e.resolve,s=e.reject,o=e.domain,u,c,l;try{i?(n||(r.rejection===mT&&fD(r),r.rejection=Qv),i===!0?u=t:(o&&o.enter(),u=i(t),o&&(o.exit(),l=!0)),u===e.promise?s(new pT("Promise-chain cycle")):(c=gT(u))?Ys(c,u,a,s):a(u)):s(t)}catch(h){o&&!l&&o.exit(),s(h)}},bT=function(e,r){e.notified||(e.notified=!0,Jv(function(){for(var t=e.reactions,n;n=t.get();)yT(n,e);e.notified=!1,r&&!e.rejection&&lD(e)}))},_T=function(e,r,t){var n,i;sD?(n=Zp.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),ba.dispatchEvent(n)):n={promise:r,reason:t},!rD&&(i=ba["on"+e])?i(n):e===hT&&Z2("Unhandled promise rejection",t)},lD=function(e){Ys(cT,ba,function(){var r=e.facade,t=e.value,n=tb(e),i;if(n&&(i=eD(function(){pl?Xv.emit("unhandledRejection",t,r):_T(hT,r,t)}),e.rejection=pl||tb(e)?mT:Qv,i.error))throw i.value})},tb=function(e){return e.rejection!==Qv&&!e.parent},fD=function(e){Ys(cT,ba,function(){var r=e.facade;pl?Xv.emit("rejectionHandled",r):_T(oD,r,e.value)})},Os=function(e,r,t){return function(n){e(r,n,t)}},xs=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=uD,bT(e,!0))},th=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw new pT("Promise can't be resolved itself");var n=gT(r);n?Jv(function(){var i={done:!1};try{Ys(n,r,Os(th,i,e),Os(xs,i,e))}catch(a){xs(i,a,e)}}):(e.value=r,e.state=vT,bT(e,!1))}catch(i){xs({done:!1},i,e)}}};if(dT&&(Ga=function(r){X2(this,Qu),J2(r),Ys(Zu,this);var t=md(this);try{r(Os(th,t),Os(xs,t))}catch(n){xs(t,n)}},Qu=Ga.prototype,Zu=function(r){iD(this,{type:Gl,done:!1,notified:!1,parent:!1,reactions:new tD,rejection:!1,state:Qy,value:null})},Zu.prototype=Yy(Qu,"then",function(r,t){var n=md(this),i=eh(Q2(this,Ga));return n.parent=!0,i.ok=Yc(r)?r:!0,i.fail=Yc(t)&&t,i.domain=pl?Xv.domain:void 0,n.state===Qy?n.reactions.add(i):Jv(function(){yT(i,n)}),i.promise}),Zy=function(){var e=new Zu,r=md(e);this.promise=e,this.resolve=Os(th,r),this.reject=Os(xs,r)},fT.f=eh=function(e){return e===Ga||e===cD?new Zy(e):aD(e)},Yc(hl)&&ks!==Object.prototype)){eb=ks.then,nD||Yy(ks,"then",function(r,t){var n=this;return new Ga(function(i,a){Ys(eb,n,i,a)}).then(r,t)},{unsafe:!0});try{delete ks.constructor}catch{}Xy&&Xy(ks,Qu)}G2({global:!0,constructor:!0,wrap:!0,forced:dT},{Promise:Ga});H2(Ga,Gl,!1);K2(Gl);var _u={},dD=Bt,pD=_u,hD=dD("iterator"),vD=Array.prototype,Zv=function(e){return e!==void 0&&(pD.Array===e||vD[hD]===e)},mD=Vi,rb=ns,gD=Hn,yD=_u,bD=Bt,_D=bD("iterator"),wu=function(e){if(!gD(e))return rb(e,_D)||rb(e,"@@iterator")||yD[mD(e)]},wD=Ft,SD=In,CD=ar,TD=rs,ED=wu,kD=TypeError,Hl=function(e,r){var t=arguments.length<2?ED(e):r;if(SD(t))return CD(wD(t,e));throw new kD(TD(e)+" is not iterable")},RD=Ft,nb=ar,$D=ns,wT=function(e,r,t){var n,i;nb(e);try{if(n=$D(e,"return"),!n){if(r==="throw")throw t;return t}n=RD(n,e)}catch(a){i=!0,n=a}if(r==="throw")throw t;if(i)throw n;return nb(n),t},ID=Gi,OD=Ft,PD=ar,AD=rs,MD=Zv,xD=xr,ib=qi,ND=Hl,LD=wu,ab=wT,DD=TypeError,Xc=function(e,r){this.stopped=e,this.result=r},sb=Xc.prototype,Su=function(e,r,t){var n=t&&t.that,i=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),s=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=ID(r,n),c,l,h,v,m,_,C,I=function(x){return c&&ab(c,"normal",x),new Xc(!0,x)},$=function(x){return i?(PD(x),o?u(x[0],x[1],I):u(x[0],x[1])):o?u(x,I):u(x)};if(a)c=e.iterator;else if(s)c=e;else{if(l=LD(e),!l)throw new DD(AD(e)+" is not iterable");if(MD(l)){for(h=0,v=xD(e);v>h;h++)if(m=$(e[h]),m&&ib(sb,m))return m;return new Xc(!1)}c=ND(e,l)}for(_=a?e.next:c.next;!(C=OD(_,c)).done;){try{m=$(C.value)}catch(x){ab(c,"throw",x)}if(typeof m=="object"&&m&&ib(sb,m))return m}return new Xc(!1)},jD=Bt,ST=jD("iterator"),CT=!1;try{var FD=0,ob={next:function(){return{done:!!FD++}},return:function(){CT=!0}};ob[ST]=function(){return this},Array.from(ob,function(){throw 2})}catch{}var Kl=function(e,r){try{if(!r&&!CT)return!1}catch{return!1}var t=!1;try{var n={};n[ST]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch{}return t},UD=Vl,BD=Kl,qD=bu.CONSTRUCTOR,TT=qD||!BD(function(e){UD.all(e).then(void 0,function(){})}),zD=gt,WD=Ft,VD=In,GD=oo,HD=Kv,KD=Su,JD=TT;zD({target:"Promise",stat:!0,forced:JD},{all:function(r){var t=this,n=GD.f(t),i=n.resolve,a=n.reject,s=HD(function(){var o=VD(t.resolve),u=[],c=0,l=1;KD(r,function(h){var v=c++,m=!1;l++,WD(o,t,h).then(function(_){m||(m=!0,u[v]=_,--l||i(u))},a)}),--l||i(u)});return s.error&&a(s.value),n.promise}});var YD=gt,XD=bu.CONSTRUCTOR,rh=Vl,QD=$n,ZD=Ut,ej=Ur,ub=rh&&rh.prototype;YD({target:"Promise",proto:!0,forced:XD,real:!0},{catch:function(e){return this.then(void 0,e)}});if(ZD(rh)){var cb=QD("Promise").prototype.catch;ub.catch!==cb&&ej(ub,"catch",cb,{unsafe:!0})}var tj=gt,rj=Ft,nj=In,ij=oo,aj=Kv,sj=Su,oj=TT;tj({target:"Promise",stat:!0,forced:oj},{race:function(r){var t=this,n=ij.f(t),i=n.reject,a=aj(function(){var s=nj(t.resolve);sj(r,function(o){rj(s,t,o).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var uj=gt,cj=oo,lj=bu.CONSTRUCTOR;uj({target:"Promise",stat:!0,forced:lj},{reject:function(r){var t=cj.f(this),n=t.reject;return n(r),t.promise}});var fj=ar,dj=Jt,pj=oo,hj=function(e,r){if(fj(e),dj(r)&&r.constructor===e)return r;var t=pj.f(e),n=t.resolve;return n(r),t.promise},vj=gt,mj=$n,gj=bu.CONSTRUCTOR,yj=hj;mj("Promise");vj({target:"Promise",stat:!0,forced:gj},{resolve:function(r){return yj(this,r)}});var ET={exports:{}};(function(e){var r=On.default;function t(){e.exports=t=function(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var n,i={},a=Object.prototype,s=a.hasOwnProperty,o=Object.defineProperty||function(he,pe,M){he[pe]=M.value},u=typeof Symbol=="function"?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",h=u.toStringTag||"@@toStringTag";function v(he,pe,M){return Object.defineProperty(he,pe,{value:M,enumerable:!0,configurable:!0,writable:!0}),he[pe]}try{v({},"")}catch{v=function(M,Oe,Je){return M[Oe]=Je}}function m(he,pe,M,Oe){var Je=pe&&pe.prototype instanceof q?pe:q,De=Object.create(Je.prototype),we=new ft(Oe||[]);return o(De,"_invoke",{value:Y(he,M,we)}),De}function _(he,pe,M){try{return{type:"normal",arg:he.call(pe,M)}}catch(Oe){return{type:"throw",arg:Oe}}}i.wrap=m;var C="suspendedStart",I="suspendedYield",$="executing",x="completed",N={};function q(){}function X(){}function J(){}var G={};v(G,c,function(){return this});var L=Object.getPrototypeOf,te=L&&L(L(Pe([])));te&&te!==a&&s.call(te,c)&&(G=te);var se=J.prototype=q.prototype=Object.create(G);function ne(he){["next","throw","return"].forEach(function(pe){v(he,pe,function(M){return this._invoke(pe,M)})})}function ge(he,pe){function M(Je,De,we,Q){var $t=_(he[Je],he,De);if($t.type!=="throw"){var _e=$t.arg,le=_e.value;return le&&r(le)=="object"&&s.call(le,"__await")?pe.resolve(le.__await).then(function(St){M("next",St,we,Q)},function(St){M("throw",St,we,Q)}):pe.resolve(le).then(function(St){_e.value=St,we(_e)},function(St){return M("throw",St,we,Q)})}Q($t.arg)}var Oe;o(this,"_invoke",{value:function(De,we){function Q(){return new pe(function($t,_e){M(De,we,$t,_e)})}return Oe=Oe?Oe.then(Q,Q):Q()}})}function Y(he,pe,M){var Oe=C;return function(Je,De){if(Oe===$)throw Error("Generator is already running");if(Oe===x){if(Je==="throw")throw De;return{value:n,done:!0}}for(M.method=Je,M.arg=De;;){var we=M.delegate;if(we){var Q=Ue(we,M);if(Q){if(Q===N)continue;return Q}}if(M.method==="next")M.sent=M._sent=M.arg;else if(M.method==="throw"){if(Oe===C)throw Oe=x,M.arg;M.dispatchException(M.arg)}else M.method==="return"&&M.abrupt("return",M.arg);Oe=$;var $t=_(he,pe,M);if($t.type==="normal"){if(Oe=M.done?x:I,$t.arg===N)continue;return{value:$t.arg,done:M.done}}$t.type==="throw"&&(Oe=x,M.method="throw",M.arg=$t.arg)}}}function Ue(he,pe){var M=pe.method,Oe=he.iterator[M];if(Oe===n)return pe.delegate=null,M==="throw"&&he.iterator.return&&(pe.method="return",pe.arg=n,Ue(he,pe),pe.method==="throw")||M!=="return"&&(pe.method="throw",pe.arg=new TypeError("The iterator does not provide a '"+M+"' method")),N;var Je=_(Oe,he.iterator,pe.arg);if(Je.type==="throw")return pe.method="throw",pe.arg=Je.arg,pe.delegate=null,N;var De=Je.arg;return De?De.done?(pe[he.resultName]=De.value,pe.next=he.nextLoc,pe.method!=="return"&&(pe.method="next",pe.arg=n),pe.delegate=null,N):De:(pe.method="throw",pe.arg=new TypeError("iterator result is not an object"),pe.delegate=null,N)}function He(he){var pe={tryLoc:he[0]};1 in he&&(pe.catchLoc=he[1]),2 in he&&(pe.finallyLoc=he[2],pe.afterLoc=he[3]),this.tryEntries.push(pe)}function Rt(he){var pe=he.completion||{};pe.type="normal",delete pe.arg,he.completion=pe}function ft(he){this.tryEntries=[{tryLoc:"root"}],he.forEach(He,this),this.reset(!0)}function Pe(he){if(he||he===""){var pe=he[c];if(pe)return pe.call(he);if(typeof he.next=="function")return he;if(!isNaN(he.length)){var M=-1,Oe=function Je(){for(;++M<he.length;)if(s.call(he,M))return Je.value=he[M],Je.done=!1,Je;return Je.value=n,Je.done=!0,Je};return Oe.next=Oe}}throw new TypeError(r(he)+" is not iterable")}return X.prototype=J,o(se,"constructor",{value:J,configurable:!0}),o(J,"constructor",{value:X,configurable:!0}),X.displayName=v(J,h,"GeneratorFunction"),i.isGeneratorFunction=function(he){var pe=typeof he=="function"&&he.constructor;return!!pe&&(pe===X||(pe.displayName||pe.name)==="GeneratorFunction")},i.mark=function(he){return Object.setPrototypeOf?Object.setPrototypeOf(he,J):(he.__proto__=J,v(he,h,"GeneratorFunction")),he.prototype=Object.create(se),he},i.awrap=function(he){return{__await:he}},ne(ge.prototype),v(ge.prototype,l,function(){return this}),i.AsyncIterator=ge,i.async=function(he,pe,M,Oe,Je){Je===void 0&&(Je=Promise);var De=new ge(m(he,pe,M,Oe),Je);return i.isGeneratorFunction(pe)?De:De.next().then(function(we){return we.done?we.value:De.next()})},ne(se),v(se,h,"Generator"),v(se,c,function(){return this}),v(se,"toString",function(){return"[object Generator]"}),i.keys=function(he){var pe=Object(he),M=[];for(var Oe in pe)M.push(Oe);return M.reverse(),function Je(){for(;M.length;){var De=M.pop();if(De in pe)return Je.value=De,Je.done=!1,Je}return Je.done=!0,Je}},i.values=Pe,ft.prototype={constructor:ft,reset:function(pe){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(Rt),!pe)for(var M in this)M.charAt(0)==="t"&&s.call(this,M)&&!isNaN(+M.slice(1))&&(this[M]=n)},stop:function(){this.done=!0;var pe=this.tryEntries[0].completion;if(pe.type==="throw")throw pe.arg;return this.rval},dispatchException:function(pe){if(this.done)throw pe;var M=this;function Oe(_e,le){return we.type="throw",we.arg=pe,M.next=_e,le&&(M.method="next",M.arg=n),!!le}for(var Je=this.tryEntries.length-1;Je>=0;--Je){var De=this.tryEntries[Je],we=De.completion;if(De.tryLoc==="root")return Oe("end");if(De.tryLoc<=this.prev){var Q=s.call(De,"catchLoc"),$t=s.call(De,"finallyLoc");if(Q&&$t){if(this.prev<De.catchLoc)return Oe(De.catchLoc,!0);if(this.prev<De.finallyLoc)return Oe(De.finallyLoc)}else if(Q){if(this.prev<De.catchLoc)return Oe(De.catchLoc,!0)}else{if(!$t)throw Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return Oe(De.finallyLoc)}}}},abrupt:function(pe,M){for(var Oe=this.tryEntries.length-1;Oe>=0;--Oe){var Je=this.tryEntries[Oe];if(Je.tryLoc<=this.prev&&s.call(Je,"finallyLoc")&&this.prev<Je.finallyLoc){var De=Je;break}}De&&(pe==="break"||pe==="continue")&&De.tryLoc<=M&&M<=De.finallyLoc&&(De=null);var we=De?De.completion:{};return we.type=pe,we.arg=M,De?(this.method="next",this.next=De.finallyLoc,N):this.complete(we)},complete:function(pe,M){if(pe.type==="throw")throw pe.arg;return pe.type==="break"||pe.type==="continue"?this.next=pe.arg:pe.type==="return"?(this.rval=this.arg=pe.arg,this.method="return",this.next="end"):pe.type==="normal"&&M&&(this.next=M),N},finish:function(pe){for(var M=this.tryEntries.length-1;M>=0;--M){var Oe=this.tryEntries[M];if(Oe.finallyLoc===pe)return this.complete(Oe.completion,Oe.afterLoc),Rt(Oe),N}},catch:function(pe){for(var M=this.tryEntries.length-1;M>=0;--M){var Oe=this.tryEntries[M];if(Oe.tryLoc===pe){var Je=Oe.completion;if(Je.type==="throw"){var De=Je.arg;Rt(Oe)}return De}}throw Error("illegal catch attempt")},delegateYield:function(pe,M,Oe){return this.delegate={iterator:Pe(pe),resultName:M,nextLoc:Oe},this.method==="next"&&(this.arg=n),N}},i}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(ET);var bj=ET.exports,Qc=bj(),Cu=Qc;try{regeneratorRuntime=Qc}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Qc:Function("r","regeneratorRuntime = r")(Qc)}var _j=TypeError,wj=9007199254740991,kT=function(e){if(e>wj)throw _j("Maximum allowed index exceeded");return e},Sj=gt,Cj=lt,Tj=du,Ej=Jt,kj=Mr,Rj=xr,lb=kT,fb=gu,$j=Fv,Ij=mu,Oj=Bt,Pj=ro,RT=Oj("isConcatSpreadable"),Aj=Pj>=51||!Cj(function(){var e=[];return e[RT]=!1,e.concat()[0]!==e}),Mj=function(e){if(!Ej(e))return!1;var r=e[RT];return r!==void 0?!!r:Tj(e)},xj=!Aj||!Ij("concat");Sj({target:"Array",proto:!0,arity:1,forced:xj},{concat:function(r){var t=kj(this),n=$j(t,0),i=0,a,s,o,u,c;for(a=-1,o=arguments.length;a<o;a++)if(c=a===-1?t:arguments[a],Mj(c))for(u=Rj(c),lb(i+u),s=0;s<u;s++,i++)s in c&&fb(n,i,c[s]);else lb(i+1),fb(n,i++,c);return n.length=i,n}});var Nj=ar,Lj=wT,Dj=function(e,r,t,n){try{return n?r(Nj(t)[0],t[1]):r(t)}catch(i){Lj(e,"throw",i)}},jj=Gi,Fj=Ft,Uj=Mr,Bj=Dj,qj=Zv,zj=Dl,Wj=xr,db=gu,Vj=Hl,Gj=wu,pb=Array,$T=function(r){var t=Uj(r),n=zj(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=jj(a,i>2?arguments[2]:void 0));var o=Gj(t),u=0,c,l,h,v,m,_;if(o&&!(this===pb&&qj(o)))for(l=n?new this:[],v=Vj(t,o),m=v.next;!(h=Fj(m,v)).done;u++)_=s?Bj(v,a,[h.value,u],!0):h.value,db(l,u,_);else for(c=Wj(t),l=n?new this(c):pb(c);c>u;u++)_=s?a(t[u],u):t[u],db(l,u,_);return l.length=u,l},Hj=gt,Kj=$T,Jj=Kl,Yj=!Jj(function(e){Array.from(e)});Hj({target:"Array",stat:!0,forced:Yj},{from:Kj});var em=vt,Xj=fi,Qj=wr,Zj=Kn,eF=em("".charAt),hb=em("".charCodeAt),tF=em("".slice),vb=function(e){return function(r,t){var n=Qj(Zj(r)),i=Xj(t),a=n.length,s,o;return i<0||i>=a?e?"":void 0:(s=hb(n,i),s<55296||s>56319||i+1===a||(o=hb(n,i+1))<56320||o>57343?e?eF(n,i):s:e?tF(n,i,i+2):(s-55296<<10)+(o-56320)+65536)}},tm={codeAt:vb(!1),charAt:vb(!0)},rF=lt,nF=!rF(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),iF=tr,aF=Ut,sF=Mr,oF=xl,uF=nF,mb=oF("IE_PROTO"),nh=Object,cF=nh.prototype,Tu=uF?nh.getPrototypeOf:function(e){var r=sF(e);if(iF(r,mb))return r[mb];var t=r.constructor;return aF(t)&&r instanceof t?t.prototype:r instanceof nh?cF:null},lF=lt,fF=Ut,dF=Jt,gb=Tu,pF=Ur,hF=Bt,ih=hF("iterator"),IT=!1,Xa,gd,yd;[].keys&&(yd=[].keys(),"next"in yd?(gd=gb(gb(yd)),gd!==Object.prototype&&(Xa=gd)):IT=!0);var vF=!dF(Xa)||lF(function(){var e={};return Xa[ih].call(e)!==e});vF&&(Xa={});fF(Xa[ih])||pF(Xa,ih,function(){return this});var OT={IteratorPrototype:Xa,BUGGY_SAFARI_ITERATORS:IT},mF=OT.IteratorPrototype,gF=Ta,yF=ts,bF=di,_F=_u,wF=function(){return this},PT=function(e,r,t,n){var i=r+" Iterator";return e.prototype=gF(mF,{next:yF(+!n,t)}),bF(e,i,!1),_F[i]=wF,e},SF=gt,CF=Ft,AT=ou,TF=Ut,EF=PT,yb=Tu,bb=so,kF=di,RF=zi,bd=Ur,$F=Bt,IF=_u,MT=OT,OF=AT.PROPER,PF=AT.CONFIGURABLE,_b=MT.IteratorPrototype,ec=MT.BUGGY_SAFARI_ITERATORS,wo=$F("iterator"),wb="keys",So="values",Sb="entries",AF=function(){return this},rm=function(e,r,t,n,i,a,s){EF(t,r,n);var o=function($){if($===i&&v)return v;if(!ec&&$&&$ in l)return l[$];switch($){case wb:return function(){return new t(this,$)};case So:return function(){return new t(this,$)};case Sb:return function(){return new t(this,$)}}return function(){return new t(this)}},u=r+" Iterator",c=!1,l=e.prototype,h=l[wo]||l["@@iterator"]||i&&l[i],v=!ec&&h||o(i),m=r==="Array"&&l.entries||h,_,C,I;if(m&&(_=yb(m.call(new e)),_!==Object.prototype&&_.next&&(yb(_)!==_b&&(bb?bb(_,_b):TF(_[wo])||bd(_,wo,AF)),kF(_,u,!0))),OF&&i===So&&h&&h.name!==So&&(PF?RF(l,"name",So):(c=!0,v=function(){return CF(h,this)})),i)if(C={values:o(So),keys:a?v:o(wb),entries:o(Sb)},s)for(I in C)(ec||c||!(I in l))&&bd(l,I,C[I]);else SF({target:r,proto:!0,forced:ec||c},C);return l[wo]!==v&&bd(l,wo,v,{name:i}),IF[r]=v,C},Jl=function(e,r){return{value:e,done:r}},MF=tm.charAt,xF=wr,xT=pn,NF=rm,Cb=Jl,NT="String Iterator",LF=xT.set,DF=xT.getterFor(NT);NF(String,"String",function(e){LF(this,{type:NT,string:xF(e),index:0})},function(){var r=DF(this),t=r.string,n=r.index,i;return n>=t.length?Cb(void 0,!0):(i=MF(t,n),r.index+=i.length,Cb(i,!1))});var LT={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(Ae,function(){var r=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],a={},s=null;function o(C,I){var $=C[I];if(typeof $.bind=="function")return $.bind(C);try{return Function.prototype.bind.call($,C)}catch{return function(){return Function.prototype.apply.apply($,[C,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 c(C){return C==="debug"&&(C="log"),typeof console===t?!1:C==="trace"&&n?u:console[C]!==void 0?o(console,C):console.log!==void 0?o(console,"log"):r}function l(){for(var C=this.getLevel(),I=0;I<i.length;I++){var $=i[I];this[$]=I<C?r:this.methodFactory($,C,this.name)}if(this.log=this.debug,typeof console===t&&C<this.levels.SILENT)return"No console available for logging"}function h(C){return function(){typeof console!==t&&(l.call(this),this[C].apply(this,arguments))}}function v(C,I,$){return c(C)||h.apply(this,arguments)}function m(C,I){var $=this,x,N,q,X="loglevel";typeof C=="string"?X+=":"+C:typeof C=="symbol"&&(X=void 0);function J(ne){var ge=(i[ne]||"silent").toUpperCase();if(!(typeof window===t||!X)){try{window.localStorage[X]=ge;return}catch{}try{window.document.cookie=encodeURIComponent(X)+"="+ge+";"}catch{}}}function G(){var ne;if(!(typeof window===t||!X)){try{ne=window.localStorage[X]}catch{}if(typeof ne===t)try{var ge=window.document.cookie,Y=encodeURIComponent(X),Ue=ge.indexOf(Y+"=");Ue!==-1&&(ne=/^([^;]+)/.exec(ge.slice(Ue+Y.length+1))[1])}catch{}return $.levels[ne]===void 0&&(ne=void 0),ne}}function L(){if(!(typeof window===t||!X)){try{window.localStorage.removeItem(X)}catch{}try{window.document.cookie=encodeURIComponent(X)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function te(ne){var ge=ne;if(typeof ge=="string"&&$.levels[ge.toUpperCase()]!==void 0&&(ge=$.levels[ge.toUpperCase()]),typeof ge=="number"&&ge>=0&&ge<=$.levels.SILENT)return ge;throw new TypeError("log.setLevel() called with invalid level: "+ne)}$.name=C,$.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},$.methodFactory=I||v,$.getLevel=function(){return q??N??x},$.setLevel=function(ne,ge){return q=te(ne),ge!==!1&&J(q),l.call($)},$.setDefaultLevel=function(ne){N=te(ne),G()||$.setLevel(ne,!1)},$.resetLevel=function(){q=null,L(),l.call($)},$.enableAll=function(ne){$.setLevel($.levels.TRACE,ne)},$.disableAll=function(ne){$.setLevel($.levels.SILENT,ne)},$.rebuild=function(){if(s!==$&&(x=te(s.getLevel())),l.call($),s===$)for(var ne in a)a[ne].rebuild()},x=te(s?s.getLevel():"WARN");var se=G();se!=null&&(q=te(se)),l.call($)}s=new m,s.getLogger=function(I){if(typeof I!="symbol"&&typeof I!="string"||I==="")throw new TypeError("You must supply a name when creating a logger.");var $=a[I];return $||($=a[I]=new m(I,s.methodFactory)),$};var _=typeof window!==t?window.log:void 0;return s.noConflict=function(){return typeof window!==t&&window.log===s&&(window.log=_),s},s.getLoggers=function(){return a},s.default=s,s})})(LT);var gr=LT.exports;const Ya="\\d+(?:[\\.,]\\d+)?",jF=`(${Ya}W)`,FF=`(${Ya}Y)?(${Ya}M)?(${Ya}D)?`,UF=`T(${Ya}H)?(${Ya}M)?(${Ya}S)?`,BF=`P(?:${jF}|${FF}(?:${UF})?)`,qF=["weeks","years","months","days","hours","minutes","seconds"],nm=new RegExp(BF),DT=e=>e.match(nm).slice(1).reduce((r,t,n)=>(r[qF[n]]=parseFloat(t)||0,r),{}),im=(e,r)=>{const t=r?r.getTime():Date.now(),n=new Date(t);return n.setFullYear(n.getFullYear()+e.years),n.setMonth(n.getMonth()+e.months),n.setDate(n.getDate()+e.days),n.setHours(n.getHours()+e.hours),n.setMinutes(n.getMinutes()+e.minutes),n.setMilliseconds(n.getMilliseconds()+e.seconds*1e3),n.setDate(n.getDate()+e.weeks*7),n},jT=(e,r)=>{const t=r?r.getTime():Date.now(),n=new Date(t);return(im(e,n).getTime()-n.getTime())/1e3},zF={end:im,toSeconds:jT,pattern:nm,parse:DT},WF=Object.freeze(Object.defineProperty({__proto__:null,default:zF,end:im,parse:DT,pattern:nm,toSeconds:jT},Symbol.toStringTag,{value:"Module"})),VF=O0(WF);var GF=Bt,HF=Ta,KF=Fr.f,ah=GF("unscopables"),sh=Array.prototype;sh[ah]===void 0&&KF(sh,ah,{configurable:!0,value:HF(null)});var am=function(e){sh[ah][e]=!0},JF=dn,sm=am,Tb=_u,FT=pn,YF=Fr.f,XF=rm,tc=Jl,QF=Wt,UT="Array Iterator",ZF=FT.set,eU=FT.getterFor(UT),BT=XF(Array,"Array",function(e,r){ZF(this,{type:UT,target:JF(e),index:0,kind:r})},function(){var e=eU(this),r=e.target,t=e.index++;if(!r||t>=r.length)return e.target=null,tc(void 0,!0);switch(e.kind){case"keys":return tc(t,!1);case"values":return tc(r[t],!1)}return tc([t,r[t]],!1)},"values"),Eb=Tb.Arguments=Tb.Array;sm("keys");sm("values");sm("entries");if(QF&&Eb.name!=="values")try{YF(Eb,"name",{value:"values"})}catch{}var kb=_t,qT=XC,tU=QC,No=BT,Rb=zi,rU=di,nU=Bt,_d=nU("iterator"),wd=No.values,zT=function(e,r){if(e){if(e[_d]!==wd)try{Rb(e,_d,wd)}catch{e[_d]=wd}if(rU(e,r,!0),qT[r]){for(var t in No)if(e[t]!==No[t])try{Rb(e,t,No[t])}catch{e[t]=No[t]}}}};for(var Sd in qT)zT(kb[Sd]&&kb[Sd].prototype,Sd);zT(tU,"DOMTokenList");var iU=Ut,aU=Jt,$b=so,Yl=function(e,r,t){var n,i;return $b&&iU(n=r.constructor)&&n!==t&&aU(i=n.prototype)&&i!==t.prototype&&$b(e,i),e},sU=vt,oU=sU(1 .valueOf),uU=`
9
- \v\f\r                 \u2028\u2029\uFEFF`,cU=vt,lU=Kn,fU=wr,oh=uU,Ib=cU("".replace),dU=RegExp("^["+oh+"]+"),pU=RegExp("(^|[^"+oh+"])["+oh+"]+$"),hU=function(e){return function(r){var t=fU(lU(r));return e&1&&(t=Ib(t,dU,"")),e&2&&(t=Ib(t,pU,"$1")),t}},vU={trim:hU(3)},mU=gt,WT=U0,gU=Wt,VT=_t,GT=pC,HT=vt,yU=Ll,Ob=tr,bU=Yl,_U=qi,wU=io,KT=Ev,SU=lt,CU=is.f,TU=Bi.f,EU=Fr.f,kU=oU,RU=vU.trim,Xl="Number",Ns=VT[Xl];GT[Xl];var om=Ns.prototype,$U=VT.TypeError,IU=HT("".slice),rc=HT("".charCodeAt),OU=function(e){var r=KT(e,"number");return typeof r=="bigint"?r:PU(r)},PU=function(e){var r=KT(e,"number"),t,n,i,a,s,o,u,c;if(wU(r))throw new $U("Cannot convert a Symbol value to a number");if(typeof r=="string"&&r.length>2){if(r=RU(r),t=rc(r,0),t===43||t===45){if(n=rc(r,2),n===88||n===120)return NaN}else if(t===48){switch(rc(r,1)){case 66:case 98:i=2,a=49;break;case 79:case 111:i=8,a=55;break;default:return+r}for(s=IU(r,2),o=s.length,u=0;u<o;u++)if(c=rc(s,u),c<48||c>a)return NaN;return parseInt(s,i)}}return+r},um=yU(Xl,!Ns(" 0o1")||!Ns("0b1")||Ns("+0x1")),AU=function(e){return _U(om,e)&&SU(function(){kU(e)})},Ql=function(r){var t=arguments.length<1?0:Ns(OU(r));return AU(this)?bU(Object(t),this,Ql):t};Ql.prototype=om;um&&!WT&&(om.constructor=Ql);mU({global:!0,constructor:!0,wrap:!0,forced:um},{Number:Ql});var MU=function(e,r){for(var t=gU?CU(r):"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;t.length>n;n++)Ob(r,i=t[n])&&!Ob(e,i)&&EU(e,i,TU(r,i))};(um||WT)&&MU(GT[Xl],Ns);var xU=ar,JT=function(){var e=xU(this),r="";return e.hasIndices&&(r+="d"),e.global&&(r+="g"),e.ignoreCase&&(r+="i"),e.multiline&&(r+="m"),e.dotAll&&(r+="s"),e.unicode&&(r+="u"),e.unicodeSets&&(r+="v"),e.sticky&&(r+="y"),r},cm=lt,NU=_t,lm=NU.RegExp,fm=cm(function(){var e=lm("a","y");return e.lastIndex=2,e.exec("abcd")!==null});fm||cm(function(){return!lm("a","y").sticky});var LU=fm||cm(function(){var e=lm("^r","gy");return e.lastIndex=2,e.exec("str")!==null}),YT={BROKEN_CARET:LU,UNSUPPORTED_Y:fm},DU=lt,jU=_t,FU=jU.RegExp,UU=DU(function(){var e=FU(".","s");return!(e.dotAll&&e.test(`
10
- `)&&e.flags==="s")}),BU=lt,qU=_t,zU=qU.RegExp,WU=BU(function(){var e=zU("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ps=Ft,Zl=vt,VU=wr,GU=JT,HU=YT,KU=ao,JU=Ta,YU=pn.get,XU=UU,QU=WU,ZU=KU("native-string-replace",String.prototype.replace),vl=RegExp.prototype.exec,uh=vl,e3=Zl("".charAt),t3=Zl("".indexOf),r3=Zl("".replace),Cd=Zl("".slice),ch=function(){var e=/a/,r=/b*/g;return Ps(vl,e,"a"),Ps(vl,r,"a"),e.lastIndex!==0||r.lastIndex!==0}(),XT=HU.BROKEN_CARET,lh=/()??/.exec("")[1]!==void 0,n3=ch||lh||XT||XU||QU;n3&&(uh=function(r){var t=this,n=YU(t),i=VU(r),a=n.raw,s,o,u,c,l,h,v;if(a)return a.lastIndex=t.lastIndex,s=Ps(uh,a,i),t.lastIndex=a.lastIndex,s;var m=n.groups,_=XT&&t.sticky,C=Ps(GU,t),I=t.source,$=0,x=i;if(_&&(C=r3(C,"y",""),t3(C,"g")===-1&&(C+="g"),x=Cd(i,t.lastIndex),t.lastIndex>0&&(!t.multiline||t.multiline&&e3(i,t.lastIndex-1)!==`
11
- `)&&(I="(?: "+I+")",x=" "+x,$++),o=new RegExp("^(?:"+I+")",C)),lh&&(o=new RegExp("^"+I+"$(?!\\s)",C)),ch&&(u=t.lastIndex),c=Ps(vl,_?o:t,x),_?c?(c.input=Cd(c.input,$),c[0]=Cd(c[0],$),c.index=t.lastIndex,t.lastIndex+=c[0].length):t.lastIndex=0:ch&&c&&(t.lastIndex=t.global?c.index+c[0].length:u),lh&&c&&c.length>1&&Ps(ZU,c[0],o,function(){for(l=1;l<arguments.length-2;l++)arguments[l]===void 0&&(c[l]=void 0)}),c&&m)for(c.groups=h=JU(null),l=0;l<m.length;l++)v=m[l],h[v[0]]=c[v[1]];return c});var dm=uh,i3=gt,Pb=dm;i3({target:"RegExp",proto:!0,forced:/./.exec!==Pb},{exec:Pb});var Ab=Ft,Mb=Ur,a3=dm,xb=lt,QT=Bt,s3=zi,o3=QT("species"),Td=RegExp.prototype,ef=function(e,r,t,n){var i=QT(e),a=!xb(function(){var c={};return c[i]=function(){return 7},""[e](c)!==7}),s=a&&!xb(function(){var c=!1,l=/a/;return e==="split"&&(l={},l.constructor={},l.constructor[o3]=function(){return l},l.flags="",l[i]=/./[i]),l.exec=function(){return c=!0,null},l[i](""),!c});if(!a||!s||t){var o=/./[i],u=r(i,""[e],function(c,l,h,v,m){var _=l.exec;return _===a3||_===Td.exec?a&&!m?{done:!0,value:Ab(o,l,h,v)}:{done:!0,value:Ab(c,h,l,v)}:{done:!1}});Mb(String.prototype,e,u[0]),Mb(Td,i,u[1])}n&&s3(Td[i],"sham",!0)},u3=tm.charAt,pm=function(e,r,t){return r+(t?u3(e,r).length:1)},hm=vt,c3=Mr,l3=Math.floor,Ed=hm("".charAt),f3=hm("".replace),kd=hm("".slice),d3=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,p3=/\$([$&'`]|\d{1,2})/g,h3=function(e,r,t,n,i,a){var s=t+e.length,o=n.length,u=p3;return i!==void 0&&(i=c3(i),u=d3),f3(a,u,function(c,l){var h;switch(Ed(l,0)){case"$":return"$";case"&":return e;case"`":return kd(r,0,t);case"'":return kd(r,s);case"<":h=i[kd(l,1,-1)];break;default:var v=+l;if(v===0)return c;if(v>o){var m=l3(v/10);return m===0?c:m<=o?n[m-1]===void 0?Ed(l,1):n[m-1]+Ed(l,1):c}h=n[v-1]}return h===void 0?"":h})},Nb=Ft,v3=ar,m3=Ut,g3=li,y3=dm,b3=TypeError,tf=function(e,r){var t=e.exec;if(m3(t)){var n=Nb(t,e,r);return n!==null&&v3(n),n}if(g3(e)==="RegExp")return Nb(y3,e,r);throw new b3("RegExp#exec called on incompatible receiver")},_3=ss,Lb=Ft,rf=vt,w3=ef,S3=lt,C3=ar,T3=Ut,E3=Hn,k3=fi,R3=Wi,ys=wr,$3=Kn,I3=pm,O3=ns,P3=h3,A3=tf,M3=Bt,fh=M3("replace"),x3=Math.max,N3=Math.min,L3=rf([].concat),Rd=rf([].push),Db=rf("".indexOf),jb=rf("".slice),D3=function(e){return e===void 0?e:String(e)},j3=function(){return"a".replace(/./,"$0")==="$0"}(),Fb=function(){return/./[fh]?/./[fh]("a","$0")==="":!1}(),F3=!S3(function(){var e=/./;return e.exec=function(){var r=[];return r.groups={a:"7"},r},"".replace(e,"$<a>")!=="7"});w3("replace",function(e,r,t){var n=Fb?"$":"$0";return[function(a,s){var o=$3(this),u=E3(a)?void 0:O3(a,fh);return u?Lb(u,a,o,s):Lb(r,ys(o),a,s)},function(i,a){var s=C3(this),o=ys(i);if(typeof a=="string"&&Db(a,n)===-1&&Db(a,"$<")===-1){var u=t(r,s,o,a);if(u.done)return u.value}var c=T3(a);c||(a=ys(a));var l=s.global,h;l&&(h=s.unicode,s.lastIndex=0);for(var v=[],m;m=A3(s,o),!(m===null||(Rd(v,m),!l));){var _=ys(m[0]);_===""&&(s.lastIndex=I3(o,R3(s.lastIndex),h))}for(var C="",I=0,$=0;$<v.length;$++){m=v[$];for(var x=ys(m[0]),N=x3(N3(k3(m.index),o.length),0),q=[],X,J=1;J<m.length;J++)Rd(q,D3(m[J]));var G=m.groups;if(c){var L=L3([x],q,N,o);G!==void 0&&Rd(L,G),X=ys(_3(a,void 0,L))}else X=P3(x,o,N,q,G,a);N>=I&&(C+=jb(o,I,N)+X,I=N+x.length)}return C+jb(o,I)}]},!F3||!j3||Fb);var U3=gt,B3=vt,q3=au,z3=dn,W3=zl,V3=B3([].join),G3=q3!==Object,H3=G3||!W3("join",",");U3({target:"Array",proto:!0,forced:H3},{join:function(r){return V3(z3(this),r===void 0?",":r)}});var kr={},K3=Wt,J3=ou.EXISTS,ZT=vt,Y3=hi,eE=Function.prototype,X3=ZT(eE.toString),tE=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Q3=ZT(tE.exec),Z3="name";K3&&!J3&&Y3(eE,Z3,{configurable:!0,get:function(){try{return Q3(tE,X3(this))[1]}catch{return""}}});var rE={exports:{}},nE={exports:{}};(function(e){function r(t){if(Array.isArray(t))return t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(nE);var eB=nE.exports,iE={exports:{}};(function(e){function r(t,n){var i=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(i!=null){var a,s,o,u,c=[],l=!0,h=!1;try{if(o=(i=i.call(t)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=o.call(i)).done)&&(c.push(a.value),c.length!==n);l=!0);}catch(v){h=!0,s=v}finally{try{if(!l&&i.return!=null&&(u=i.return(),Object(u)!==u))return}finally{if(h)throw s}}return c}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(iE);var tB=iE.exports,aE={exports:{}},sE={exports:{}};(function(e){function r(t,n){(n==null||n>t.length)&&(n=t.length);for(var i=0,a=Array(n);i<n;i++)a[i]=t[i];return a}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(sE);var oE=sE.exports;(function(e){var r=oE;function t(n,i){if(n){if(typeof n=="string")return r(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)?r(n,i):void 0}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(aE);var uE=aE.exports,cE={exports:{}};(function(e){function r(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
12
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(cE);var rB=cE.exports;(function(e){var r=eB,t=tB,n=uE,i=rB;function a(s,o){return r(s)||t(s,o)||n(s,o)||i()}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(rE);var uo=rE.exports,nB=gt,Ub=du,iB=Dl,aB=Jt,Bb=as,sB=xr,oB=dn,uB=gu,cB=Bt,lB=mu,fB=pi,dB=lB("slice"),pB=cB("species"),$d=Array,hB=Math.max;nB({target:"Array",proto:!0,forced:!dB},{slice:function(r,t){var n=oB(this),i=sB(n),a=Bb(r,i),s=Bb(t===void 0?i:t,i),o,u,c;if(Ub(n)&&(o=n.constructor,iB(o)&&(o===$d||Ub(o.prototype))?o=void 0:aB(o)&&(o=o[pB],o===null&&(o=void 0)),o===$d||o===void 0))return fB(n,a,s);for(u=new(o===void 0?$d:o)(hB(s-a,0)),c=0;a<s;a++,c++)a in n&&uB(u,c,n[a]);return u.length=c,u}});var vB=gt,qb=Ft,mB=Ut,zb=ar,gB=wr,yB=function(){var e=!1,r=/[ac]/;return r.exec=function(){return e=!0,/./.exec.apply(this,arguments)},r.test("abc")===!0&&e}(),bB=/./.test;vB({target:"RegExp",proto:!0,forced:!yB},{test:function(e){var r=zb(this),t=gB(e),n=r.exec;if(!mB(n))return qb(bB,r,t);var i=qb(n,r,t);return i===null?!1:(zb(i),!0)}});var _B=gt,wB=Wt,SB=_t,nc=vt,CB=tr,TB=Ut,EB=qi,kB=wr,RB=hi,$B=Ov,Ii=SB.Symbol,Fa=Ii&&Ii.prototype;if(wB&&TB(Ii)&&(!("description"in Fa)||Ii().description!==void 0)){var Wb={},ic=function(){var r=arguments.length<1||arguments[0]===void 0?void 0:kB(arguments[0]),t=EB(Fa,this)?new Ii(r):r===void 0?Ii():Ii(r);return r===""&&(Wb[t]=!0),t};$B(ic,Ii),ic.prototype=Fa,Fa.constructor=ic;var IB=String(Ii("description detection"))==="Symbol(description detection)",OB=nc(Fa.valueOf),PB=nc(Fa.toString),AB=/^Symbol\((.*)\)[^)]+$/,MB=nc("".replace),xB=nc("".slice);RB(Fa,"description",{configurable:!0,get:function(){var r=OB(this);if(CB(Wb,r))return"";var t=PB(r),n=IB?xB(t,7,-1):MB(t,AB,"$1");return n===""?void 0:n}}),_B({global:!0,constructor:!0,forced:!0},{Symbol:ic})}var NB=hC;NB("iterator");var lE={exports:{}},fE={exports:{}};(function(e){var r=oE;function t(n){if(Array.isArray(n))return r(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(fE);var LB=fE.exports,dE={exports:{}};(function(e){function r(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(dE);var DB=dE.exports,pE={exports:{}};(function(e){function r(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
13
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(pE);var jB=pE.exports;(function(e){var r=LB,t=DB,n=uE,i=jB;function a(s){return r(s)||t(s)||n(s)||i()}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(lE);var co=lE.exports,FB=gt,UB=Nl.includes,BB=lt,qB=am,zB=BB(function(){return!Array(1).includes()});FB({target:"Array",proto:!0,forced:zB},{includes:function(r){return UB(this,r,arguments.length>1?arguments[1]:void 0)}});qB("includes");var WB=Jt,VB=Math.floor,hE=Number.isInteger||function(r){return!WB(r)&&isFinite(r)&&VB(r)===r},GB=gt,HB=hE;GB({target:"Number",stat:!0},{isInteger:HB});var vE=Wt,KB=lt,mE=vt,JB=Tu,YB=fu,XB=dn,QB=iu.f,gE=mE(QB),ZB=mE([].push),e4=vE&&KB(function(){var e=Object.create(null);return e[2]=2,!gE(e,2)}),t4=function(e){return function(r){for(var t=XB(r),n=YB(t),i=e4&&JB(t)===null,a=n.length,s=0,o=[],u;a>s;)u=n[s++],(!vE||(i?u in t:gE(t,u)))&&ZB(o,e?[u,t[u]]:t[u]);return o}},r4={entries:t4(!0)},n4=gt,i4=r4.entries;n4({target:"Object",stat:!0},{entries:function(r){return i4(r)}});/*
8
+ </dialog>`,OI='<button class="cobrowse-end js-cobrowse-end">$end</button>';class Sv{constructor(r,t){ut(this,"_cobrowse");ut(this,"_options");ut(this,"_started",!1);this._cobrowse=r,this._options=t}get root(){return this._options.root||document.body}get lang(){return this._options.lang}get messages(){return this._options.messages}get template(){return this._options.template||II}static async create(r,t){const n=await PI(t);n.license=r.license;const i=r.trustedOrigins||[];return i.push(location.origin),n.trustedOrigins=i,["api","capabilities","registration","redactedViews","unredactedViews"].forEach(s=>{r[s]!==void 0&&(n[s]=r[s])}),new Sv(n,r)}setCustomData(r){this._cobrowse.customData=r}on(r,t){this._cobrowse.on(r,t)}async start(){this._started||(await this._cobrowse.client(),await this._cobrowse.start(),this._started=!0,this.setupConfirms(),this.setupSessionControl())}async stop(){await this._cobrowse.stop(),this._started=!1}async endSession(){this._cobrowse.currentSession&&await this._cobrowse.currentSession.end()}async createSessionCode(){return this._cobrowse.currentSession?this._cobrowse.currentSession.code():await this._cobrowse.createSessionCode()}createConfirmConsent(r){return()=>{const t=document.createElement("div");t.className="cobrowse-wrapper",t.lang=this.lang,t.innerHTML=r;const n=()=>{t.parentNode&&t.parentNode.removeChild(t)};return new Promise(i=>{this.root.appendChild(t);const a=t.querySelector(".js-cobrowse-allow");a==null||a.addEventListener("click",()=>{i(!0),n()});const s=t.querySelector(".js-cobrowse-deny");s==null||s.addEventListener("click",()=>{i(!1),n()})})}}setupConfirms(){this._cobrowse.confirmSession=this.createConfirmConsent(Uu(this._options.confirmSessionTemplate||this.template,{title:this.messages.confirmSessionTitle,content:this.messages.confirmSessionContent,allow:this.messages.allowText,deny:this.messages.denyText})),this._cobrowse.confirmRemoteControl=this.createConfirmConsent(Uu(this._options.confirmRemoteControlTemplate||this.template,{title:this.messages.confirmRemoteControlTitle,content:this.messages.confirmRemoteControlContent,allow:this.messages.allowText,deny:this.messages.denyText})),this._cobrowse.confirmFullDevice=this.createConfirmConsent(Uu(this._options.confirmFullDeviceTemplate||this.template,{title:this.messages.confirmFullDeviceTitle,content:this.messages.confirmFullDeviceContent,allow:this.messages.allowText,deny:this.messages.denyText}))}setupSessionControl(){const r=this._options.sessionControlsTemplate||OI,t=document.createElement("div");t.className="cobrowse-end-wrapper",t.setAttribute("lang",this.lang),t.innerHTML=Uu(r,{end:this.messages.endSessionText});const n=()=>{this.endSession()};this._cobrowse.showSessionControls=()=>{if(!this.root.contains(t)){const i=t.querySelector(".js-cobrowse-end");i&&i.addEventListener("click",n),this.root.appendChild(t)}},this._cobrowse.hideSessionControls=()=>{if(this.root.contains(t)){const i=t.querySelector(".js-cobrowse-end");i&&i.removeEventListener("click",n),this.root.removeChild(t)}}}}function PI(e){return window.CobrowseIO?window.CobrowseIO:new Promise(r=>{const t=document.createElement("script");t.src=e,t.async=!0;const n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n),t.onload=function(){r(window.CobrowseIO)}})}function Uu(e,r){let t=e;return Object.keys(r).forEach(n=>{const i=new RegExp("\\$"+n,"g");t=t.replace(i,r[n])}),t}const AI={confirmSessionTitle:"Screen Share Session Request",confirmSessionContent:"Do you want to share your current screen with the agent?",endSessionText:"End Screen Share Session",confirmRemoteControlTitle:"Remote Access Request",confirmRemoteControlContent:"The agent would like to have access to your currently shared screen to further assist you. Do you want to allow this?",confirmFullDeviceTitle:"Screen Share Request",confirmFullDeviceContent:"Do you want to share your full screen with the agent? The agent will not be able to control anything on the screen.",allowText:"Allow",denyText:"Deny"},MI={confirmSessionTitle:"Solicitud de sesión de conavegación",confirmSessionContent:"¿Desea compartir su pantalla actual con el agente?",endSessionText:"Fin de la sesión de conavegación",confirmRemoteControlTitle:"Solicitud de acceso remoto",confirmRemoteControlContent:"El agente desea tener acceso a su pantalla actual compartida para seguir asistiéndole. ¿Desea permitirlo?",confirmFullDeviceTitle:"Solicitud de compartir pantalla",confirmFullDeviceContent:"¿Desea compartir su pantalla completa con el agente? El agente no podrá controlar nada de la pantalla.",allowText:"Permitir",denyText:"Denegar"},xI={confirmSessionTitle:"Demande de session de co-navigation",confirmSessionContent:"Voulez-vous partager votre écran actuel avec l'agent ?",endSessionText:"Terminer la session de co-navigation",confirmRemoteControlTitle:"Demande d'accès à distance",confirmRemoteControlContent:"L'agent souhaite avoir accès à l'écran que vous partagez actuellement pour mieux vous aider. Voulez-vous l'y autoriser ?",confirmFullDeviceTitle:"Demande de partage d'écran",confirmFullDeviceContent:"Voulez-vous partager votre écran complet avec l'agent ? L'agent ne sera pas en mesure de contrôler quoi que ce soit sur l'écran.",allowText:"Autoriser",denyText:"Refuser"},NI={confirmSessionTitle:"Screen Share-Sitzungsanfrage",confirmSessionContent:"Möchten Sie Ihren aktuellen Bildschirm für den Agenten freigeben?",endSessionText:"Screen Share-Sitzung beenden",confirmRemoteControlTitle:"Fernzugriff-Anfrage",confirmRemoteControlContent:"Der Agent möchte Zugriff auf Ihren aktuell freigegebenen Bildschirm erhalten, um Ihnen weiterhelfen zu können. Möchten Sie dies erlauben?",confirmFullDeviceTitle:"Bildschirmfreigabe",confirmFullDeviceContent:"Möchten Sie Ihren gesamten Bildschirm für den Agenten freigeben? Der Agent ist dadurch nicht in der Lage, Elemente auf Ihrem Bildschirm zu steuern.",allowText:"Erlauben",denyText:"Verweigern"},LI={confirmSessionTitle:"共同ブラウジングセッションリクエスト",confirmSessionContent:"現在の画面を担当者と共有したいですか。",endSessionText:"共同ブラウジングセッションを終了",confirmRemoteControlTitle:"リモートアクセスリクエスト",confirmRemoteControlContent:"担当者は、お客様をさらにお手伝いするために、現在共有中の画面へのアクセスを希望しています。許可しますか。",confirmFullDeviceTitle:"画面共有リクエスト",confirmFullDeviceContent:"画面全体を担当者と共有したいですか。担当者は画面上で一切の操作ができません。",allowText:"許可",denyText:"拒否"},DI={confirmSessionTitle:"코브라우징 세션 요청",confirmSessionContent:"현재 화면을 상담원과 공유하시겠습니까?",endSessionText:"코브라우징 세션 종료",confirmRemoteControlTitle:"원격 액세스 요청",confirmRemoteControlContent:"상담원이 추가 지원을 위해 현재 공유된 화면에 액세스할 수 있기를 원합니다. 허용하시겠습니까?",confirmFullDeviceTitle:"화면 공유 요청",confirmFullDeviceContent:"상담원과 전체 화면을 공유하시겠습니까? 상담원은 화면의 어떤 부분도 제어할 수 없습니다.",allowText:"허용",denyText:"거절"},jI={confirmSessionTitle:"Richiesta di sessione di Screen Share",confirmSessionContent:"Vuoi condividere la tua schermata attuale con l'operatore?",endSessionText:"Termina sessione di Screen Share",confirmRemoteControlTitle:"Richiesta di accesso remoto",confirmRemoteControlContent:"L'operatore vorrebbe accedere alla tua schermata attualmente condivisa per assisterti al meglio. Acconsenti?",confirmFullDeviceTitle:"Richiesta di condivisione schermo",confirmFullDeviceContent:"Vuoi condividere il tuo intero schermo con l'operatore? L'operatore non potrà controllare nessun elemento sullo schermo.",allowText:"Consenti",denyText:"Rifiuta"},FI={confirmSessionTitle:"同步浏览会话请求",confirmSessionContent:"您是否要向该客服代表共享当前的屏幕?",endSessionText:"结束同步浏览会话",confirmRemoteControlTitle:"远程访问请求",confirmRemoteControlContent:"为了进一步协助您,客服代表想访问您当前的共享屏幕。您是否允许这样做?",confirmFullDeviceTitle:"屏幕共享请求",confirmFullDeviceContent:"您是否要向该客服代表共享全屏?客服代表将不能控制屏幕上的任何东西。",allowText:"允许",denyText:"拒绝"},UI={confirmSessionTitle:"Samwebbläsningssession har begärts",confirmSessionContent:"Vill du dela din aktuella skärm med vår medarbetare?",endSessionText:"Avsluta samwebbläsningssession",confirmRemoteControlTitle:"Begäran om fjärråtkomst",confirmRemoteControlContent:"Vår medarbetare skulle vilja få åtkomst till skärmen som du delar just nu för att kunna hjälpa dig vidare. Vill du tillåta detta?",confirmFullDeviceTitle:"Begäran om skärmdelning",confirmFullDeviceContent:"Vill du dela hela skärmen med medarbetaren? Medarbetaren kommer inte kunna kontrollera något på skärmen.",allowText:"Tillåt",denyText:"Neka"},BI={confirmSessionTitle:"Solicitação de Sessão de Co-navegação",confirmSessionContent:"Deseja partilhar o seu ecrã atual com o agente?",endSessionText:"Terminar Sessão de Co-navegação",confirmRemoteControlTitle:"Solicitação de Acesso Remoto",confirmRemoteControlContent:"O agente gostaria de ter acesso ao seu ecrã partilhado atualmente para ajudá-lo ainda mais. Quer permitir isto?",confirmFullDeviceTitle:"Solicitação de Partilha de Ecrã",confirmFullDeviceContent:"Deseja partilhar o seu ecrã inteiro com o agente? O agente não poderá controlar nada no ecrã.",allowText:"Permitir",denyText:"Negar"},qI={confirmSessionTitle:"Pyyntö yhteisselausistunnosta",confirmSessionContent:"Haluatko jakaa nykyisen näyttösi edustajan kanssa?",endSessionText:"Lopeta yhteisselausistunto",confirmRemoteControlTitle:"Etäkäyttöpyyntö",confirmRemoteControlContent:"Edustaja haluaisi saada käyttää tällä hetkellä jakamaasi näyttöä voidakseen auttaa sinua enemmän. Haluatko antaa siihen luvan?",confirmFullDeviceTitle:"Näytön jakamispyyntö",confirmFullDeviceContent:"Haluatko jakaa koko näyttösi edustajan kanssa? Edustaja ei pysty käyttämään mitään näytöllä olevaa.",allowText:"Salli",denyText:"Estä"},zI={confirmSessionTitle:"Samlesingsøkten er startet",confirmSessionContent:"Vil du dele skjermen din med agenten?",endSessionText:"Avslutt samlesingsøkt",confirmRemoteControlTitle:"Forespørsel om fjerntilgang",confirmRemoteControlContent:"Agenten vil ha tilgang til skjermen din for å kunne hjelpe deg videre. Vil du tillate dette?",confirmFullDeviceTitle:"Forespørsel om skjermdeling",confirmFullDeviceContent:"Vil du dele hele skjermen din med agenten? Agenten kan ikke kontrollere noe på skjermen.",allowText:"Tillat",denyText:"Avvis"},WI={confirmSessionTitle:"Forespørgsel om sambrowsingsession",confirmSessionContent:"Vil du dele din nuværende skærm med agenten",endSessionText:"Afslut sambrowsingsession",confirmRemoteControlTitle:"Anmodning om fjernadgang",confirmRemoteControlContent:"Agenten vil gerne have adgang til din nuværende delte skærm for at kunne hjælpe dig yderligere. Ønsker du at tillade dette?",confirmFullDeviceTitle:"Forespørgsel om skærmdeling",confirmFullDeviceContent:"Vil du dele din fulde skærm med agenten? Agenten vil ikke kunne styre noget på skærmen",allowText:"Tillad",denyText:"Afvis"},VI={confirmSessionTitle:"Verzoek om cobrowse-sessie",confirmSessionContent:"Wilt u uw huidige scherm delen met de agent?",endSessionText:"Cobrowse-sessie beëindigen",confirmRemoteControlTitle:"Verzoek om toegang op afstand",confirmRemoteControlContent:"De agent wil graag toegang hebben tot uw momenteel gedeelde scherm om u verder te helpen. Wilt u dit toestaan?",confirmFullDeviceTitle:"Verzoek om scherm te delen",confirmFullDeviceContent:"Wilt u uw volledige scherm delen met de agent? De agent kan niets op het scherm bedienen.",allowText:"Toestaan",denyText:"Weigeren"},GI={confirmSessionTitle:"Oturum İsteğini Eş Zamanlı Tara",confirmSessionContent:"Mevcut ekranınızı temsilciyle paylaşmak ister misiniz?",endSessionText:"Eş zamanlı Oturum Taramayı Sonlandır",confirmRemoteControlTitle:"Uzaktan Erişim İsteği",confirmRemoteControlContent:"Temsilci şu anda paylaşılan ekranınıza size daha fazla yardımcı olabilmek için erişim sağlamak istiyor. Buna izin vermek istiyor musunuz?",confirmFullDeviceTitle:"Ekran Paylaşım İsteği",confirmFullDeviceContent:"Temsilciyle tam ekranınızı paylaşmak istiyor musunuz? Temsilci ekrandaki hiçbir şeyi kontrol edemez.",allowText:"İzin Ver",denyText:"Reddet"},HI={confirmSessionTitle:"Yêu cầu phiên cùng duyệt",confirmSessionContent:"Bạn có muốn chia sẻ màn hình hiện tại của mình với chuyên viên không?",endSessionText:"Kết thúc phiên cùng duyệt",confirmRemoteControlTitle:"Yêu cầu truy cập từ xa",confirmRemoteControlContent:"Chuyên viên muốn được cấp quyền truy cập vào màn hình bạn đang chia sẻ để hỗ trợ bạn nhiều hơn. Bạn có muốn cho phép không?",confirmFullDeviceTitle:"Yêu cầu chia sẻ màn hình",confirmFullDeviceContent:"Bạn có muốn chia sẻ toàn bộ màn hình của mình với chuyên viên không? Chuyên viên sẽ không thể điều khiển bất cứ phần nào trên màn hình.",allowText:"Cho phép",denyText:"Từ chối"},KI={confirmSessionTitle:"ขอเซสชันเรียกดูร่วม",confirmSessionContent:"คุณต้องการแชร์หน้าจอปัจจุบันกับตัวแทนหรือไม่",endSessionText:"สิ้นสุดเซสชันเรียกดูร่วม",confirmRemoteControlTitle:"ขอการเข้าถึงระยะไกล",confirmRemoteControlContent:"ตัวแทนต้องการเข้าถึงหน้าจอของคุณที่แชร์อยู่ในปัจจุบันเพื่อให้ความช่วยเหลือคุณต่อไป คุณจะอนุญาตหรือไม่",confirmFullDeviceTitle:"ขอแชร์หน้าจอ",confirmFullDeviceContent:"คุณต้องการแชร์ทั้งหน้าของคุณกับตัวแทนหรือไม่ ตัวแทนจะไม่สามารถควบคุมอะไรบนหน้าจอ",allowText:"ยินยอม",denyText:"ปฏิเสธ"},JI={confirmSessionTitle:"طلب جلسة تصفح مشترك",confirmSessionContent:"هل تريد مشاركة شاشتك الحالية مع الموظف؟",endSessionText:"إنهاء جلسة التصفح المشترك",confirmRemoteControlTitle:"طلب التحكم عن بعد",confirmRemoteControlContent:"يرغب مسئول الدعم في رؤية شاشتك المشاركة حالياً لمساعدتك بشكلٍ أكبر. هل تسمح بذلك؟",confirmFullDeviceTitle:"طلب مشاركة الشاشة",confirmFullDeviceContent:"هل تريد مشاركة شاشتك الكاملة مع مسئول الدعم؟ لن يتمكن المسئول من التحكم في أي شيء على الشاشة.",allowText:"السماح",denyText:"الرفض"},YI={confirmSessionTitle:"Žádost o relaci Screen Share",confirmSessionContent:"Chcete svou současnou obrazovku sdílet s agentem?",endSessionText:"Ukončit relaci Screen Share",confirmRemoteControlTitle:"Žádost o vzdálený přístup",confirmRemoteControlContent:"Agent by rád získal přístup k vaší stávající sdílené obrazovce, aby vám mohl dál pomoci. Chcete mu přístup povolit?",confirmFullDeviceTitle:"Žádost o sdílení obrazovky",confirmFullDeviceContent:"Chcete svou celou obrazovku sdílet s agentem? Agent nebude moci ovládat nic, co na obrazovce je.",allowText:"Povolit",denyText:"Zamítnout"},XI={confirmSessionTitle:"Prośba o sesję Screen Share",confirmSessionContent:"Czy chcesz udostępnić konsultantowi swój bieżący ekran?",endSessionText:"Zakończ sesję Screen Share",confirmRemoteControlTitle:"Prośba o zdalny dostęp",confirmRemoteControlContent:"Konsultant prosi o dostęp do Twojego aktualnie udostępnionego ekranu, aby udzielić Ci dalszej pomocy. Czy chcesz na to zezwolić?",confirmFullDeviceTitle:"Prośba o udostępnienie ekranu",confirmFullDeviceContent:"Czy chcesz udostępnić konsultantowi swój cały ekran? Konsultant nie będzie mógł kontrolować niczego na ekranie.",allowText:"Zezwól",denyText:"Odmów"},QI={confirmSessionTitle:"Screen Share munkameneti kérés",confirmSessionContent:"Megosztja az aktuális képernyőjét a képviselővel?",endSessionText:"Screen Share munkamenet befejezése",confirmRemoteControlTitle:"Távoli hozzáférési kérés",confirmRemoteControlContent:"A képviselő szeretne hozzáférni a jelenleg megosztott képernyőjéhez, hogy további segítséget nyújthasson. Engedélyezi ezt?",confirmFullDeviceTitle:"Képernyőmegosztási kérelem",confirmFullDeviceContent:"Megosztja a teljes képernyőjét az ügynökkel? Az ügynök semmit sem tud majd irányítani a képernyőn.",allowText:"Engedélyezés",denyText:"Elutasítás"},ZI={confirmSessionTitle:"Запрос сеанса совместного просмотра веб-страниц",confirmSessionContent:"Хотите поделиться вашим текущим экраном с представителем?",endSessionText:"Завершить сеанс совместного просмотра веб-страниц",confirmRemoteControlTitle:"Запрос на удаленный доступ",confirmRemoteControlContent:"Представитель хочет получить доступ к вашему текущему экрану, которым вы делитесь, чтобы помочь вам. Хотите разрешить это?",confirmFullDeviceTitle:"Запрос на совместный просмотр экрана",confirmFullDeviceContent:"Хотите поделиться вашим полный экраном с представителем? Агент не сможет выполнять никаких действий на экране.",allowText:"Разрешить",denyText:"Отказать"},eO={confirmSessionTitle:"सह-ब्राउज़ सत्र अनुरोध किया गया",confirmSessionContent:"क्या आप अपनी वर्तमान स्क्रीन को एजेंट के साथ साझा करना चाहते हैं?",endSessionText:"सह-ब्राउज़ सत्र समाप्त करें",confirmRemoteControlTitle:"रिमोट पहुँच का अनुरोध किया गया",confirmRemoteControlContent:"एजेंट आपकी वर्तमान साझा स्क्रीन तक पहुँच प्राप्त करना चाहेगा ताकि वह आपकी और सहायता कर सके। क्या आप इसकी अनुमति देना चाहते हैं?",confirmFullDeviceTitle:"स्क्रीन साझाकरण अनुरोध",confirmFullDeviceContent:"क्या आप अपनी पूरी स्क्रीन एजेंट के साथ साझा करना चाहते हैं? एजेंट स्क्रीन पर कुछ भी नियंत्रित नहीं कर पाएगा।",allowText:"अनुमति दें",denyText:"अस्वीकार करें"},tO={confirmSessionTitle:"Solicitare sesiune de co-navigare",confirmSessionContent:"Doriți să partajați ecranul dumneavoastră curent cu agentul?",endSessionText:"Încheiați sesiunea de co-navigare",confirmRemoteControlTitle:"Cerere de acces la distanță",confirmRemoteControlContent:"Agentul ar dori să aibă acces la ecranul dumneavoastră partajat pentru a vă ajuta în continuare. Doriți să permiteți acest lucru?",confirmFullDeviceTitle:"Cerere de partajare a ecranului",confirmFullDeviceContent:"Doriți să partajați ecranul dumneavoastră complet cu agentul? Agentul nu va putea controla nimic de pe ecran.",allowText:"Permiteți",denyText:"Refuzați"},rO={confirmSessionTitle:"Zahtjev za sesiju zajedničkog pregledavanja",confirmSessionContent:"Želite li podijeliti svoj trenutni zaslon s agentom?",endSessionText:"Završi sesiju zajedničkog pregledavanja",confirmRemoteControlTitle:"Zahtjev za daljinski pristup",confirmRemoteControlContent:"Agent želi imati pristup vašem trenutno dijeljenom zaslonu kako bi Vam dodatno pomogao. Želite li to dopustiti?",confirmFullDeviceTitle:"Zahtjev za dijeljenje zaslona",confirmFullDeviceContent:"Želite li s agentom podijeliti svoj cijeli zaslon? Agent neće moći ništa kontrolirati na ekranu.",allowText:"Dopustiti",denyText:"Odbiti"},nO={confirmSessionTitle:"Запит на сесію спільного перегляду",confirmSessionContent:"Чи Ви хочете поділитись з агентом своїм поточним екраном?",endSessionText:"Завершити сесію спільного перегляду",confirmRemoteControlTitle:"Запит на віддалений доступ",confirmRemoteControlContent:"Агент хоче отримати доступ до Вашого поточного екрану, який переглядається спільно, щоб допомогти Вам. Ви дозволяєте?",confirmFullDeviceTitle:"Запит на спільний перегляд екрану",confirmFullDeviceContent:"Чи Ви хочете поділитись з агентом своїм екраном повністю? Агент не зможе нічого на ньому контролювати.",allowText:"Дозволити",denyText:"Відмовити"},iO={confirmSessionTitle:"Kahilingan sa Screen Share na Sesyon",confirmSessionContent:"Gusto mo bang ibahagi ang iyong kasalukuyang screen sa agent?",endSessionText:"Tapusin ang Screen Share na Sesyon",confirmRemoteControlTitle:"Kahilingan sa Remote Access",confirmRemoteControlContent:"Gusto ng agent na magkaroon ng access sa iyong nakabahaging screen sa kasalukuyan upang mas matulungan ka. Gusto mo bang payagan ito?",confirmFullDeviceTitle:"Kahilingan sa Pagbahagi ng Screen",confirmFullDeviceContent:"Gusto mo bang ibahagi ang buong screen sa agent? Hindi makokontrol ng agent ang kahit ano sa screen.",allowText:"Payagan",denyText:"Tanggihan"},go={en:AI,es:MI,"es-MX":{confirmSessionTitle:"Solicitud de Sesión de Co-navegación",confirmSessionContent:"¿Quiere compartir su pantalla actual con el agente?",endSessionText:"Fin de la sesión de co-navegación",confirmRemoteControlContent:"El agente desea tener acceso a su pantalla actualmente compartida para poder ayudarlo. ¿Quiere permitirlo?",confirmFullDeviceTitle:"Petición de pantalla compartida",confirmFullDeviceContent:"¿Quiere compartir su pantalla completa con el agente? El agente no podrá controlar nada en la pantalla."},fr:xI,"fr-CA":{confirmSessionTitle:"Demande de session co-navigation",confirmSessionContent:"Voulez-vous partager votre écran actuel avec l'agent?",endSessionText:"Fin de la session de co-navigation",confirmRemoteControlContent:"L'agent souhaiterait avoir accès à votre écran actuellement partagé pour mieux vous aider. Voulez-vous l'autoriser?",confirmFullDeviceContent:"Voulez-vous partager votre écran complet avec l'agent? L'agent ne sera pas en mesure de contrôler quoi que ce soit sur l'écran."},de:NI,ja:LI,ko:DI,it:jI,zh:FI,"zh-Hant":{confirmSessionTitle:"共同瀏覽工作階段要求",confirmSessionContent:"要與專員分享您目前的畫面嗎?",endSessionText:"結束共同瀏覽工作階段",confirmRemoteControlTitle:"遠端存取要求",confirmRemoteControlContent:"專員想要存取您目前分享的螢幕畫面以進一步協助您。要允許嗎?",confirmFullDeviceTitle:"螢幕畫面分享要求",confirmFullDeviceContent:"要與專員分享全螢幕嗎?專員將無法控制畫面上的任何項目。",allowText:"允許",denyText:"拒絕"},sv:UI,pt:BI,"pt-BR":{confirmSessionContent:"Você deseja compartilhar sua tela atual com o agente?",endSessionText:"Encerrar Sessão de Co-navegação",confirmRemoteControlContent:"O agente gostaria de acessar sua tela atualmente compartilhada para melhor ajudá-lo. Você deseja permitir isso?",confirmFullDeviceTitle:"Solicitação de Compartilhamento de Tela",confirmFullDeviceContent:"Você deseja compartilhar sua tela inteira com o agente? O agente não poderá controlar nada na tela."},fi:qI,nb:zI,da:WI,nl:VI,tr:GI,vi:HI,th:KI,ar:JI,cs:YI,pl:XI,hu:QI,ru:ZI,hi:eO,ro:tO,hr:rO,uk:nO,tl:iO};function aO(e){const r=e.split("-")[0];return go[e]?e===r?go[e]:{...go[r],...go[e]}:go[r]}const sO=["photo","video","audio","document"];let oO=class{constructor(r){ut(this,"VERSION",gv);ut(this,"options");ut(this,"communicator");ut(this,"methods");ut(this,"events",new bv);ut(this,"request");ut(this,"chat");ut(this,"cobrowse");this.options=r,this.communicator=new eI(r,this.events);const t=this.communicator.request.bind(this.communicator);this.methods=new bI(t),this.request=t,Er.companyId=r.companyId,r.tenant&&(Er.tenant=r.tenant)}get deviceId(){return Er.deviceId}get user(){return this.communicator.user}get lang(){return this.options.lang?this.options.lang:Pr.get("lang")||"en"}set lang(r){this.options.lang||Pr.set("lang",r)}destroy(){this.communicator.destroy(),this.events.destroy()}on(r,t){this.events.addEventListener(r,t)}off(r,t){this.events.removeEventListener(r,t)}_triggerEvent(r,t){this.events.triggerEvent(r,t)}async getCompany(){const r=await this.methods.getCompany();return Er.tenant=r.subdomain,r}async runTrigger(r){const t=await this.methods.getTriggers(this.options.companyId),n=SI(t);n&&CI(n,r)}trackClientEvents(r){return this.methods.trackClientEvents(r)}getProhibitedFileTypes(){return this.methods.listFileTypes()}getMenus(r,t){return this.methods.getMenus(t||this.lang,r)}getAfterHourMessage(r){return this.methods.getAfterHourMessage(r||this.lang)}getTimeSlots(r,t){return this.methods.getTimeSlots(r,t||this.lang)}getWaitTimes(r,t){return this.methods.getWaitTimes(r,t||this.lang)}verifyForm(r){return this.methods.verifyForm(r)}createCall(r,t){var n;return!t.email&&((n=this.user)!=null&&n.email)&&(t.email=this.user.email),this.methods.createCall(Number(r),t.lang||this.lang,t)}loadCall(r){return this.methods.fetchCall(r)}cancelCall(r){return this.methods.cancelCall(r)}createEmail(r,t){return this.methods.createEmail(r,t.lang||this.lang,t)}async createChat(r,t={}){var i,a;if(this.chat&&this.chat.ongoing)throw new Error("There is an ongoing chat.");!t.email&&((i=this.user)!=null&&i.email)&&(t.email=this.user.email),t.cobrowsable===void 0&&(t.cobrowsable=!!((a=this.options.cobrowse)!=null&&a.enabled));const n=await this.methods.createChat(Number(r),t.lang||this.lang,t,this.deviceId);return this.registerOngoingChat(n),await n.clearMediaStore(),n}async loadChat(r){const t=await this.methods.loadChat(r,this.deviceId);return t.ongoing?this.registerOngoingChat(t):(Pr.del("chat"),Pr.del("cobrowse")),t}async resumeChat(r){var t;if(((t=this.chat)==null?void 0:t.id)===Number(r)){const n=await this.methods.patch(`chats/${r}`,{status:"queued"});return this.chat.update(n.data),this.chat}else{const n=await this.methods.resumeChat(r,this.deviceId);return this.registerOngoingChat(n),n}}async loadOngoingChat(){const r=Pr.get("chat");if(r){const t=await this.loadChat(r);if(t.ongoing)return t;Pr.del("chat")}}async finishChat(){if(!this.chat)return;const r=await this.methods.finishChat(this.chat.id);this.chat.update(r),this.chat.connected&&this.chat.ended&&await this.chat.disconnect()}async updatePostSession(r){if(!this.chat||r===Vs.FINISHED||r===Vs.WAITING)return;const t=await this.methods.updatePostSession(this.chat.id,r);this.chat.update(t)}async destroyChat(){if(this.chat){if(this.chat.ongoing){const r=await this.methods.finishChat(this.chat.id);this.chat.update(r)}await this.chat.destroy(),this.chat=null,Er.trackerId=""}}getChatDeflection(){return this.methods.getChatDeflection(this.chat.id)}sendChatTranscripts(r){return this.methods.sendChatTranscripts(this.chat.id,r)}async downloadChatTranscript(){return await this.methods.downloadChatTranscript(this.chat.id)}async getPdfStatus(r){return await this.methods.getPdfStatus(r)}getChatSurvey(){return this.methods.getChatSurvey(this.chat.id)}sendChatSurvey(r){if(this.chat.feedbackType!=="survey")throw new Error("Chat feedback type is: "+this.chat.feedbackType);return this.methods.sendChatSurvey(this.chat.id,r)}sendChatRate(r){if(this.chat.feedbackType!=="rate")throw new Error("Chat feedback type is: "+this.chat.feedbackType);return this.methods.rateChat(this.chat.id,r)}escalateChat(r){return this.methods.escalateChat(this.chat.id,r)}trackChatEscalation(r,t){return this.methods.trackEscalation(this.chat.id,r,t)}trackChatEndUserEvent(r){var t;return!r.end_user_name&&((t=this.user)!=null&&t.name)&&(r.end_user_name=this.user.name),this.methods.trackChatEndUserEvent(this.chat.id,r)}getChatHistory(r=1){return this.methods.getChatHistory(r)}async fetchMessages(){const r=await this.chat.fetchMessages();if(r.filter(t=>t.type==="server_message").length>0){const t=await this.methods.listChatTaskMessages(this.chat.id);return rI(r,t)}return r}async sendFileMessage(r){const t=await this.methods.uploadChatFile(this.chat.id,r);return this.chat.sendMessage(t,r)}async sendTextMessage(r){let t;return this.chat.inTask?t={type:"server_message",visibility:"task_virtual_agent",message_id:(await this.methods.sendChatTaskMessage(this.chat.id,r)).id}:t={type:"text",content:r},this.chat.sendMessage(t)}async createCobrowseCode(r,t){var a;await this.initializeCobrowse(r||this.lang);let n=Pr.get("cobrowse");n||(n=Date.now().toString(),Pr.set("cobrowse",n));const i={device_id:this.deviceId,device_name:`${Er.application} / ${Er.version}`,nonce:n,...t};return(a=this.user)!=null&&a.name&&(i.user_name=this.user.name),this.cobrowse.setCustomData(i),this.cobrowse.createSessionCode()}async startCobrowse(r="end_user"){if(!this.chat.cobrowsable)throw new Error(`Chat ${this.chat.id} does not support cobrowse.`);const t={chatId:`chat_${this.chat.id}`},n=await this.createCobrowseCode(this.chat.lang,t);if(n){const i=Pr.get("cobrowse");await this.methods.requestChatCobrowse(this.chat.id,{code:n,from:r,nonce:i})}}async getMessageAttachment(r){if(r.$userType!=="end_user"&&sO.includes(r.type)){const t=await this.methods.getMedia(r.media_id,r.type);return this.chat&&this.chat.saveMedia(r.$index,t),t}return null}async initializeCobrowse(r){if(!this.cobrowse){const t=await this.getCompany(),n=this.getCobrowseScript(t.cobrowse_domain),i=this.options.cobrowse.messages||aO(r),a={...this.options.cobrowse,messages:i,lang:r};this.cobrowse=await Sv.create(a,n),this.cobrowse.start(),["loaded","updated","ended"].forEach(o=>{this.cobrowse.on(`session.${o}`,u=>{this.events.triggerEvent(`cobrowse.${o}`,u)})})}}registerOngoingChat(r){this.events.triggerEvent("chat.ongoing",r),r._setGlobalEvents(this.events,this.methods.getChatTaskMessage.bind(this.methods)),r.on("_requestCobrowse",t=>{t==="agent"?this.startCobrowse(t):this.initializeCobrowse(r.lang),this.events.triggerEvent("cobrowse.request",{from:t})}),r.on("disconnected",()=>{Pr.del("chat"),Pr.del("cobrowse")}),this.chat=r,Er.trackerId=`chat_${r.id}`,Pr.set("chat",r.id.toString()),r.cobrowsable&&Pr.get("cobrowse")&&this.initializeCobrowse(r.lang)}getCobrowseScript(r){return!r||r.toLowerCase()==="https://cobrowse.io"?"https://js.cobrowse.io/CobrowseIO.js":`${r}/sdk-js/CobrowseIO.js`}};var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function O0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function P0(e){if(e.__esModule)return e;var r=e.default;if(typeof r=="function"){var t=function n(){return this instanceof n?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),t}var A0={},yo=function(e){return e&&e.Math===Math&&e},_t=yo(typeof globalThis=="object"&&globalThis)||yo(typeof window=="object"&&window)||yo(typeof self=="object"&&self)||yo(typeof Ae=="object"&&Ae)||yo(typeof Ae=="object"&&Ae)||function(){return this}()||Function("return this")(),Bi={},lt=function(e){try{return!!e()}catch{return!0}},uO=lt,Wt=!uO(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),cO=lt,nu=!cO(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),lO=nu,Bu=Function.prototype.call,Ft=lO?Bu.bind(Bu):function(){return Bu.apply(Bu,arguments)},iu={},M0={}.propertyIsEnumerable,x0=Object.getOwnPropertyDescriptor,fO=x0&&!M0.call({1:2},1);iu.f=fO?function(r){var t=x0(this,r);return!!t&&t.enumerable}:M0;var ts=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},N0=nu,L0=Function.prototype,Dp=L0.call,dO=N0&&L0.bind.bind(Dp,Dp),vt=N0?dO:function(e){return function(){return Dp.apply(e,arguments)}},D0=vt,pO=D0({}.toString),hO=D0("".slice),li=function(e){return hO(pO(e),8,-1)},vO=vt,mO=lt,gO=li,Nf=Object,yO=vO("".split),au=mO(function(){return!Nf("z").propertyIsEnumerable(0)})?function(e){return gO(e)==="String"?yO(e,""):Nf(e)}:Nf,Hn=function(e){return e==null},bO=Hn,_O=TypeError,Kn=function(e){if(bO(e))throw new _O("Can't call method on "+e);return e},wO=au,SO=Kn,dn=function(e){return wO(SO(e))},Lf=typeof document=="object"&&document.all,Ut=typeof Lf>"u"&&Lf!==void 0?function(e){return typeof e=="function"||e===Lf}:function(e){return typeof e=="function"},CO=Ut,Jt=function(e){return typeof e=="object"?e!==null:CO(e)},Df=_t,TO=Ut,EO=function(e){return TO(e)?e:void 0},$n=function(e,r){return arguments.length<2?EO(Df[e]):Df[e]&&Df[e][r]},kO=vt,qi=kO({}.isPrototypeOf),RO=_t,Og=RO.navigator,Pg=Og&&Og.userAgent,Ca=Pg?String(Pg):"",j0=_t,jf=Ca,Ag=j0.process,Mg=j0.Deno,xg=Ag&&Ag.versions||Mg&&Mg.version,Ng=xg&&xg.v8,Bn,ll;Ng&&(Bn=Ng.split("."),ll=Bn[0]>0&&Bn[0]<4?1:+(Bn[0]+Bn[1]));!ll&&jf&&(Bn=jf.match(/Edge\/(\d+)/),(!Bn||Bn[1]>=74)&&(Bn=jf.match(/Chrome\/(\d+)/),Bn&&(ll=+Bn[1])));var ro=ll,Lg=ro,$O=lt,IO=_t,OO=IO.String,no=!!Object.getOwnPropertySymbols&&!$O(function(){var e=Symbol("symbol detection");return!OO(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Lg&&Lg<41}),PO=no,F0=PO&&!Symbol.sham&&typeof Symbol.iterator=="symbol",AO=$n,MO=Ut,xO=qi,NO=F0,LO=Object,io=NO?function(e){return typeof e=="symbol"}:function(e){var r=AO("Symbol");return MO(r)&&xO(r.prototype,LO(e))},DO=String,rs=function(e){try{return DO(e)}catch{return"Object"}},jO=Ut,FO=rs,UO=TypeError,In=function(e){if(jO(e))return e;throw new UO(FO(e)+" is not a function")},BO=In,qO=Hn,ns=function(e,r){var t=e[r];return qO(t)?void 0:BO(t)},Ff=Ft,Uf=Ut,Bf=Jt,zO=TypeError,WO=function(e,r){var t,n;if(r==="string"&&Uf(t=e.toString)&&!Bf(n=Ff(t,e))||Uf(t=e.valueOf)&&!Bf(n=Ff(t,e))||r!=="string"&&Uf(t=e.toString)&&!Bf(n=Ff(t,e)))return n;throw new zO("Can't convert object to primitive value")},U0={exports:{}},B0=!1,Dg=_t,VO=Object.defineProperty,Cv=function(e,r){try{VO(Dg,e,{value:r,configurable:!0,writable:!0})}catch{Dg[e]=r}return r},GO=_t,HO=Cv,jg="__core-js_shared__",Fg=U0.exports=GO[jg]||HO(jg,{});(Fg.versions||(Fg.versions=[])).push({version:"3.39.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Tv=U0.exports,Ug=Tv,ao=function(e,r){return Ug[e]||(Ug[e]=r||{})},KO=Kn,JO=Object,Mr=function(e){return JO(KO(e))},YO=vt,XO=Mr,QO=YO({}.hasOwnProperty),tr=Object.hasOwn||function(r,t){return QO(XO(r),t)},ZO=vt,eP=0,tP=Math.random(),rP=ZO(1 .toString),su=function(e){return"Symbol("+(e===void 0?"":e)+")_"+rP(++eP+tP,36)},nP=_t,iP=ao,Bg=tr,aP=su,sP=no,oP=F0,Is=nP.Symbol,qf=iP("wks"),uP=oP?Is.for||Is:Is&&Is.withoutSetter||aP,Bt=function(e){return Bg(qf,e)||(qf[e]=sP&&Bg(Is,e)?Is[e]:uP("Symbol."+e)),qf[e]},cP=Ft,qg=Jt,zg=io,lP=ns,fP=WO,dP=Bt,pP=TypeError,hP=dP("toPrimitive"),Ev=function(e,r){if(!qg(e)||zg(e))return e;var t=lP(e,hP),n;if(t){if(r===void 0&&(r="default"),n=cP(t,e,r),!qg(n)||zg(n))return n;throw new pP("Can't convert object to primitive value")}return r===void 0&&(r="number"),fP(e,r)},vP=Ev,mP=io,Al=function(e){var r=vP(e,"string");return mP(r)?r:r+""},gP=_t,Wg=Jt,jp=gP.document,yP=Wg(jp)&&Wg(jp.createElement),Ml=function(e){return yP?jp.createElement(e):{}},bP=Wt,_P=lt,wP=Ml,q0=!bP&&!_P(function(){return Object.defineProperty(wP("div"),"a",{get:function(){return 7}}).a!==7}),SP=Wt,CP=Ft,TP=iu,EP=ts,kP=dn,RP=Al,$P=tr,IP=q0,Vg=Object.getOwnPropertyDescriptor;Bi.f=SP?Vg:function(r,t){if(r=kP(r),t=RP(t),IP)try{return Vg(r,t)}catch{}if($P(r,t))return EP(!CP(TP.f,r,t),r[t])};var Fr={},OP=Wt,PP=lt,z0=OP&&PP(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),AP=Jt,MP=String,xP=TypeError,ar=function(e){if(AP(e))return e;throw new xP(MP(e)+" is not an object")},NP=Wt,LP=q0,DP=z0,qu=ar,Gg=Al,jP=TypeError,zf=Object.defineProperty,FP=Object.getOwnPropertyDescriptor,Wf="enumerable",Vf="configurable",Gf="writable";Fr.f=NP?DP?function(r,t,n){if(qu(r),t=Gg(t),qu(n),typeof r=="function"&&t==="prototype"&&"value"in n&&Gf in n&&!n[Gf]){var i=FP(r,t);i&&i[Gf]&&(r[t]=n.value,n={configurable:Vf in n?n[Vf]:i[Vf],enumerable:Wf in n?n[Wf]:i[Wf],writable:!1})}return zf(r,t,n)}:zf:function(r,t,n){if(qu(r),t=Gg(t),qu(n),LP)try{return zf(r,t,n)}catch{}if("get"in n||"set"in n)throw new jP("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var UP=Wt,BP=Fr,qP=ts,zi=UP?function(e,r,t){return BP.f(e,r,qP(1,t))}:function(e,r,t){return e[r]=t,e},W0={exports:{}},Fp=Wt,zP=tr,V0=Function.prototype,WP=Fp&&Object.getOwnPropertyDescriptor,kv=zP(V0,"name"),VP=kv&&(function(){}).name==="something",GP=kv&&(!Fp||Fp&&WP(V0,"name").configurable),ou={EXISTS:kv,PROPER:VP,CONFIGURABLE:GP},HP=vt,KP=Ut,Up=Tv,JP=HP(Function.toString);KP(Up.inspectSource)||(Up.inspectSource=function(e){return JP(e)});var Rv=Up.inspectSource,YP=_t,XP=Ut,Hg=YP.WeakMap,QP=XP(Hg)&&/native code/.test(String(Hg)),ZP=ao,eA=su,Kg=ZP("keys"),xl=function(e){return Kg[e]||(Kg[e]=eA(e))},uu={},tA=QP,G0=_t,rA=Jt,nA=zi,Hf=tr,Kf=Tv,iA=xl,aA=uu,Jg="Object already initialized",Bp=G0.TypeError,sA=G0.WeakMap,fl,Ko,dl,oA=function(e){return dl(e)?Ko(e):fl(e,{})},uA=function(e){return function(r){var t;if(!rA(r)||(t=Ko(r)).type!==e)throw new Bp("Incompatible receiver, "+e+" required");return t}};if(tA||Kf.state){var ri=Kf.state||(Kf.state=new sA);ri.get=ri.get,ri.has=ri.has,ri.set=ri.set,fl=function(e,r){if(ri.has(e))throw new Bp(Jg);return r.facade=e,ri.set(e,r),r},Ko=function(e){return ri.get(e)||{}},dl=function(e){return ri.has(e)}}else{var ms=iA("state");aA[ms]=!0,fl=function(e,r){if(Hf(e,ms))throw new Bp(Jg);return r.facade=e,nA(e,ms,r),r},Ko=function(e){return Hf(e,ms)?e[ms]:{}},dl=function(e){return Hf(e,ms)}}var pn={set:fl,get:Ko,has:dl,enforce:oA,getterFor:uA},$v=vt,cA=lt,lA=Ut,zu=tr,qp=Wt,fA=ou.CONFIGURABLE,dA=Rv,H0=pn,pA=H0.enforce,hA=H0.get,Yg=String,Hc=Object.defineProperty,vA=$v("".slice),mA=$v("".replace),gA=$v([].join),yA=qp&&!cA(function(){return Hc(function(){},"length",{value:8}).length!==8}),bA=String(String).split("String"),_A=W0.exports=function(e,r,t){vA(Yg(r),0,7)==="Symbol("&&(r="["+mA(Yg(r),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(r="get "+r),t&&t.setter&&(r="set "+r),(!zu(e,"name")||fA&&e.name!==r)&&(qp?Hc(e,"name",{value:r,configurable:!0}):e.name=r),yA&&t&&zu(t,"arity")&&e.length!==t.arity&&Hc(e,"length",{value:t.arity});try{t&&zu(t,"constructor")&&t.constructor?qp&&Hc(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var n=pA(e);return zu(n,"source")||(n.source=gA(bA,typeof r=="string"?r:"")),e};Function.prototype.toString=_A(function(){return lA(this)&&hA(this).source||dA(this)},"toString");var K0=W0.exports,wA=Ut,SA=Fr,CA=K0,TA=Cv,Ur=function(e,r,t,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:r;if(wA(t)&&CA(t,a,n),n.global)i?e[r]=t:TA(r,t);else{try{n.unsafe?e[r]&&(i=!0):delete e[r]}catch{}i?e[r]=t:SA.f(e,r,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},is={},EA=Math.ceil,kA=Math.floor,RA=Math.trunc||function(r){var t=+r;return(t>0?kA:EA)(t)},$A=RA,fi=function(e){var r=+e;return r!==r||r===0?0:$A(r)},IA=fi,OA=Math.max,PA=Math.min,as=function(e,r){var t=IA(e);return t<0?OA(t+r,0):PA(t,r)},AA=fi,MA=Math.min,Wi=function(e){var r=AA(e);return r>0?MA(r,9007199254740991):0},xA=Wi,xr=function(e){return xA(e.length)},NA=dn,LA=as,DA=xr,Xg=function(e){return function(r,t,n){var i=NA(r),a=DA(i);if(a===0)return!e&&-1;var s=LA(n,a),o;if(e&&t!==t){for(;a>s;)if(o=i[s++],o!==o)return!0}else for(;a>s;s++)if((e||s in i)&&i[s]===t)return e||s||0;return!e&&-1}},Nl={includes:Xg(!0),indexOf:Xg(!1)},jA=vt,Jf=tr,FA=dn,UA=Nl.indexOf,BA=uu,Qg=jA([].push),J0=function(e,r){var t=FA(e),n=0,i=[],a;for(a in t)!Jf(BA,a)&&Jf(t,a)&&Qg(i,a);for(;r.length>n;)Jf(t,a=r[n++])&&(~UA(i,a)||Qg(i,a));return i},Iv=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],qA=J0,zA=Iv,WA=zA.concat("length","prototype");is.f=Object.getOwnPropertyNames||function(r){return qA(r,WA)};var cu={};cu.f=Object.getOwnPropertySymbols;var VA=$n,GA=vt,HA=is,KA=cu,JA=ar,YA=GA([].concat),Y0=VA("Reflect","ownKeys")||function(r){var t=HA.f(JA(r)),n=KA.f;return n?YA(t,n(r)):t},Zg=tr,XA=Y0,QA=Bi,ZA=Fr,Ov=function(e,r,t){for(var n=XA(r),i=ZA.f,a=QA.f,s=0;s<n.length;s++){var o=n[s];!Zg(e,o)&&!(t&&Zg(t,o))&&i(e,o,a(r,o))}},eM=lt,tM=Ut,rM=/#|\.prototype\./,lu=function(e,r){var t=iM[nM(e)];return t===sM?!0:t===aM?!1:tM(r)?eM(r):!!r},nM=lu.normalize=function(e){return String(e).replace(rM,".").toLowerCase()},iM=lu.data={},aM=lu.NATIVE="N",sM=lu.POLYFILL="P",Ll=lu,Wu=_t,oM=Bi.f,uM=zi,cM=Ur,lM=Cv,fM=Ov,dM=Ll,gt=function(e,r){var t=e.target,n=e.global,i=e.stat,a,s,o,u,c,l;if(n?s=Wu:i?s=Wu[t]||lM(t,{}):s=Wu[t]&&Wu[t].prototype,s)for(o in r){if(c=r[o],e.dontCallGetSet?(l=oM(s,o),u=l&&l.value):u=s[o],a=dM(n?o:t+(i?".":"#")+o,e.forced),!a&&u!==void 0){if(typeof c==typeof u)continue;fM(c,u)}(e.sham||u&&u.sham)&&uM(c,"sham",!0),cM(s,o,c,e)}},pM=Fr.f,hM=tr,vM=Bt,ey=vM("toStringTag"),di=function(e,r,t){e&&!t&&(e=e.prototype),e&&!hM(e,ey)&&pM(e,ey,{configurable:!0,value:r})},mM=gt,gM=_t,yM=di;mM({global:!0},{Reflect:{}});yM(gM.Reflect,"Reflect",!0);var bM=nu,X0=Function.prototype,ty=X0.apply,ry=X0.call,ss=typeof Reflect=="object"&&Reflect.apply||(bM?ry.bind(ty):function(){return ry.apply(ty,arguments)}),_M=vt,pi=_M([].slice),Q0=vt,wM=In,SM=Jt,CM=tr,ny=pi,TM=nu,Z0=Function,EM=Q0([].concat),kM=Q0([].join),Yf={},RM=function(e,r,t){if(!CM(Yf,r)){for(var n=[],i=0;i<r;i++)n[i]="a["+i+"]";Yf[r]=Z0("C,a","return new C("+kM(n,",")+")")}return Yf[r](e,t)},$M=TM?Z0.bind:function(r){var t=wM(this),n=t.prototype,i=ny(arguments,1),a=function(){var o=EM(i,ny(arguments));return this instanceof a?RM(t,o.length,o):t.apply(r,o)};return SM(n)&&(a.prototype=n),a},IM=Bt,OM=IM("toStringTag"),eC={};eC[OM]="z";var Pv=String(eC)==="[object z]",PM=Pv,AM=Ut,Kc=li,MM=Bt,xM=MM("toStringTag"),NM=Object,LM=Kc(function(){return arguments}())==="Arguments",DM=function(e,r){try{return e[r]}catch{}},Vi=PM?Kc:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=DM(r=NM(e),xM))=="string"?t:LM?Kc(r):(n=Kc(r))==="Object"&&AM(r.callee)?"Arguments":n},jM=vt,FM=lt,tC=Ut,UM=Vi,BM=$n,qM=Rv,rC=function(){},nC=BM("Reflect","construct"),Av=/^\s*(?:class|function)\b/,zM=jM(Av.exec),WM=!Av.test(rC),bo=function(r){if(!tC(r))return!1;try{return nC(rC,[],r),!0}catch{return!1}},iC=function(r){if(!tC(r))return!1;switch(UM(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return WM||!!zM(Av,qM(r))}catch{return!0}};iC.sham=!0;var Dl=!nC||FM(function(){var e;return bo(bo.call)||!bo(Object)||!bo(function(){e=!0})||e})?iC:bo,VM=Dl,GM=rs,HM=TypeError,Mv=function(e){if(VM(e))return e;throw new HM(GM(e)+" is not a constructor")},xv={},KM=J0,JM=Iv,fu=Object.keys||function(r){return KM(r,JM)},YM=Wt,XM=z0,QM=Fr,ZM=ar,ex=dn,tx=fu;xv.f=YM&&!XM?Object.defineProperties:function(r,t){ZM(r);for(var n=ex(t),i=tx(t),a=i.length,s=0,o;a>s;)QM.f(r,o=i[s++],n[o]);return r};var rx=$n,aC=rx("document","documentElement"),nx=ar,ix=xv,iy=Iv,ax=uu,sx=aC,ox=Ml,ux=xl,ay=">",sy="<",zp="prototype",Wp="script",sC=ux("IE_PROTO"),Xf=function(){},oC=function(e){return sy+Wp+ay+e+sy+"/"+Wp+ay},oy=function(e){e.write(oC("")),e.close();var r=e.parentWindow.Object;return e=null,r},cx=function(){var e=ox("iframe"),r="java"+Wp+":",t;return e.style.display="none",sx.appendChild(e),e.src=String(r),t=e.contentWindow.document,t.open(),t.write(oC("document.F=Object")),t.close(),t.F},Vu,Jc=function(){try{Vu=new ActiveXObject("htmlfile")}catch{}Jc=typeof document<"u"?document.domain&&Vu?oy(Vu):cx():oy(Vu);for(var e=iy.length;e--;)delete Jc[zp][iy[e]];return Jc()};ax[sC]=!0;var Ta=Object.create||function(r,t){var n;return r!==null?(Xf[zp]=nx(r),n=new Xf,Xf[zp]=null,n[sC]=r):n=Jc(),t===void 0?n:ix.f(n,t)},lx=gt,fx=$n,Qf=ss,dx=$M,uy=Mv,px=ar,cy=Jt,hx=Ta,uC=lt,Nv=fx("Reflect","construct"),vx=Object.prototype,mx=[].push,cC=uC(function(){function e(){}return!(Nv(function(){},[],e)instanceof e)}),lC=!uC(function(){Nv(function(){})}),ly=cC||lC;lx({target:"Reflect",stat:!0,forced:ly,sham:ly},{construct:function(r,t){uy(r),px(t);var n=arguments.length<3?r:uy(arguments[2]);if(lC&&!cC)return Nv(r,t,n);if(r===n){switch(t.length){case 0:return new r;case 1:return new r(t[0]);case 2:return new r(t[0],t[1]);case 3:return new r(t[0],t[1],t[2]);case 4:return new r(t[0],t[1],t[2],t[3])}var i=[null];return Qf(mx,i,t),new(Qf(dx,r,i))}var a=n.prototype,s=hx(cy(a)?a:vx),o=Qf(r,s,t);return cy(o)?o:s}});var gx=gt,yx=Mr,fC=fu,bx=lt,_x=bx(function(){fC(1)});gx({target:"Object",stat:!0,forced:_x},{keys:function(r){return fC(yx(r))}});var wx=Vi,Sx=String,wr=function(e){if(wx(e)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return Sx(e)},Lv={},Cx=li,Tx=dn,dC=is.f,Ex=pi,pC=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],kx=function(e){try{return dC(e)}catch{return Ex(pC)}};Lv.f=function(r){return pC&&Cx(r)==="Window"?kx(r):dC(Tx(r))};var fy=K0,Rx=Fr,hi=function(e,r,t){return t.get&&fy(t.get,r,{getter:!0}),t.set&&fy(t.set,r,{setter:!0}),Rx.f(e,r,t)},Dv={},$x=Bt;Dv.f=$x;var Ix=_t,hC=Ix,dy=hC,Ox=tr,Px=Dv,Ax=Fr.f,vC=function(e){var r=dy.Symbol||(dy.Symbol={});Ox(r,e)||Ax(r,e,{value:Px.f(e)})},Mx=Ft,xx=$n,Nx=Bt,Lx=Ur,Dx=function(){var e=xx("Symbol"),r=e&&e.prototype,t=r&&r.valueOf,n=Nx("toPrimitive");r&&!r[n]&&Lx(r,n,function(i){return Mx(t,this)},{arity:1})},jx=li,Fx=vt,jv=function(e){if(jx(e)==="Function")return Fx(e)},py=jv,Ux=In,Bx=nu,qx=py(py.bind),Gi=function(e,r){return Ux(e),r===void 0?e:Bx?qx(e,r):function(){return e.apply(r,arguments)}},zx=li,du=Array.isArray||function(r){return zx(r)==="Array"},hy=du,Wx=Dl,Vx=Jt,Gx=Bt,Hx=Gx("species"),vy=Array,Kx=function(e){var r;return hy(e)&&(r=e.constructor,Wx(r)&&(r===vy||hy(r.prototype))?r=void 0:Vx(r)&&(r=r[Hx],r===null&&(r=void 0))),r===void 0?vy:r},Jx=Kx,Fv=function(e,r){return new(Jx(e))(r===0?0:r)},Yx=Gi,Xx=vt,Qx=au,Zx=Mr,eN=xr,tN=Fv,my=Xx([].push),Da=function(e){var r=e===1,t=e===2,n=e===3,i=e===4,a=e===6,s=e===7,o=e===5||a;return function(u,c,l,h){for(var v=Zx(u),m=Qx(v),_=eN(m),C=Yx(c,l),I=0,$=h||tN,x=r?$(u,_):t||s?$(u,0):void 0,N,q;_>I;I++)if((o||I in m)&&(N=m[I],q=C(N,I,v),e))if(r)x[I]=q;else if(q)switch(e){case 3:return!0;case 5:return N;case 6:return I;case 2:my(x,N)}else switch(e){case 4:return!1;case 7:my(x,N)}return a?-1:n||i?i:x}},Zr={forEach:Da(0),map:Da(1),filter:Da(2),some:Da(3),every:Da(4),find:Da(5),findIndex:Da(6)},jl=gt,pu=_t,Uv=Ft,rN=vt,Gs=Wt,Hs=no,nN=lt,kr=tr,iN=qi,Vp=ar,Fl=dn,Bv=Al,aN=wr,Gp=ts,Ks=Ta,mC=fu,sN=is,gC=Lv,oN=cu,yC=Bi,bC=Fr,uN=xv,_C=iu,Zf=Ur,cN=hi,qv=ao,lN=xl,wC=uu,gy=su,fN=Bt,dN=Dv,pN=vC,hN=Dx,vN=di,SC=pn,Ul=Zr.forEach,Jr=lN("hidden"),Bl="Symbol",Jo="prototype",mN=SC.set,yy=SC.getterFor(Bl),Rn=Object[Jo],Ka=pu.Symbol,xo=Ka&&Ka[Jo],gN=pu.RangeError,yN=pu.TypeError,ed=pu.QObject,CC=yC.f,Ja=bC.f,TC=gC.f,bN=_C.f,EC=rN([].push),Di=qv("symbols"),hu=qv("op-symbols"),_N=qv("wks"),Hp=!ed||!ed[Jo]||!ed[Jo].findChild,kC=function(e,r,t){var n=CC(Rn,r);n&&delete Rn[r],Ja(e,r,t),n&&e!==Rn&&Ja(Rn,r,n)},Kp=Gs&&nN(function(){return Ks(Ja({},"a",{get:function(){return Ja(this,"a",{value:7}).a}})).a!==7})?kC:Ja,td=function(e,r){var t=Di[e]=Ks(xo);return mN(t,{type:Bl,tag:e,description:r}),Gs||(t.description=r),t},ql=function(r,t,n){r===Rn&&ql(hu,t,n),Vp(r);var i=Bv(t);return Vp(n),kr(Di,i)?(n.enumerable?(kr(r,Jr)&&r[Jr][i]&&(r[Jr][i]=!1),n=Ks(n,{enumerable:Gp(0,!1)})):(kr(r,Jr)||Ja(r,Jr,Gp(1,Ks(null))),r[Jr][i]=!0),Kp(r,i,n)):Ja(r,i,n)},zv=function(r,t){Vp(r);var n=Fl(t),i=mC(n).concat(IC(n));return Ul(i,function(a){(!Gs||Uv(Jp,n,a))&&ql(r,a,n[a])}),r},wN=function(r,t){return t===void 0?Ks(r):zv(Ks(r),t)},Jp=function(r){var t=Bv(r),n=Uv(bN,this,t);return this===Rn&&kr(Di,t)&&!kr(hu,t)?!1:n||!kr(this,t)||!kr(Di,t)||kr(this,Jr)&&this[Jr][t]?n:!0},RC=function(r,t){var n=Fl(r),i=Bv(t);if(!(n===Rn&&kr(Di,i)&&!kr(hu,i))){var a=CC(n,i);return a&&kr(Di,i)&&!(kr(n,Jr)&&n[Jr][i])&&(a.enumerable=!0),a}},$C=function(r){var t=TC(Fl(r)),n=[];return Ul(t,function(i){!kr(Di,i)&&!kr(wC,i)&&EC(n,i)}),n},IC=function(e){var r=e===Rn,t=TC(r?hu:Fl(e)),n=[];return Ul(t,function(i){kr(Di,i)&&(!r||kr(Rn,i))&&EC(n,Di[i])}),n};Hs||(Ka=function(){if(iN(xo,this))throw new yN("Symbol is not a constructor");var r=!arguments.length||arguments[0]===void 0?void 0:aN(arguments[0]),t=gy(r),n=function(i){var a=this===void 0?pu:this;a===Rn&&Uv(n,hu,i),kr(a,Jr)&&kr(a[Jr],t)&&(a[Jr][t]=!1);var s=Gp(1,i);try{Kp(a,t,s)}catch(o){if(!(o instanceof gN))throw o;kC(a,t,s)}};return Gs&&Hp&&Kp(Rn,t,{configurable:!0,set:n}),td(t,r)},xo=Ka[Jo],Zf(xo,"toString",function(){return yy(this).tag}),Zf(Ka,"withoutSetter",function(e){return td(gy(e),e)}),_C.f=Jp,bC.f=ql,uN.f=zv,yC.f=RC,sN.f=gC.f=$C,oN.f=IC,dN.f=function(e){return td(fN(e),e)},Gs&&(cN(xo,"description",{configurable:!0,get:function(){return yy(this).description}}),Zf(Rn,"propertyIsEnumerable",Jp,{unsafe:!0})));jl({global:!0,constructor:!0,wrap:!0,forced:!Hs,sham:!Hs},{Symbol:Ka});Ul(mC(_N),function(e){pN(e)});jl({target:Bl,stat:!0,forced:!Hs},{useSetter:function(){Hp=!0},useSimple:function(){Hp=!1}});jl({target:"Object",stat:!0,forced:!Hs,sham:!Gs},{create:wN,defineProperty:ql,defineProperties:zv,getOwnPropertyDescriptor:RC});jl({target:"Object",stat:!0,forced:!Hs},{getOwnPropertyNames:$C});hN();vN(Ka,Bl);wC[Jr]=!0;var SN=no,OC=SN&&!!Symbol.for&&!!Symbol.keyFor,CN=gt,TN=$n,EN=tr,kN=wr,PC=ao,RN=OC,rd=PC("string-to-symbol-registry"),$N=PC("symbol-to-string-registry");CN({target:"Symbol",stat:!0,forced:!RN},{for:function(e){var r=kN(e);if(EN(rd,r))return rd[r];var t=TN("Symbol")(r);return rd[r]=t,$N[t]=r,t}});var IN=gt,ON=tr,PN=io,AN=rs,MN=ao,xN=OC,by=MN("symbol-to-string-registry");IN({target:"Symbol",stat:!0,forced:!xN},{keyFor:function(r){if(!PN(r))throw new TypeError(AN(r)+" is not a symbol");if(ON(by,r))return by[r]}});var NN=vt,_y=du,LN=Ut,wy=li,DN=wr,Sy=NN([].push),jN=function(e){if(LN(e))return e;if(_y(e)){for(var r=e.length,t=[],n=0;n<r;n++){var i=e[n];typeof i=="string"?Sy(t,i):(typeof i=="number"||wy(i)==="Number"||wy(i)==="String")&&Sy(t,DN(i))}var a=t.length,s=!0;return function(o,u){if(s)return s=!1,u;if(_y(this))return u;for(var c=0;c<a;c++)if(t[c]===o)return u}}},FN=gt,AC=$n,MC=ss,UN=Ft,vu=vt,xC=lt,Cy=Ut,Ty=io,NC=pi,BN=jN,qN=no,zN=String,va=AC("JSON","stringify"),Gu=vu(/./.exec),Ey=vu("".charAt),WN=vu("".charCodeAt),VN=vu("".replace),GN=vu(1 .toString),HN=/[\uD800-\uDFFF]/g,ky=/^[\uD800-\uDBFF]$/,Ry=/^[\uDC00-\uDFFF]$/,$y=!qN||xC(function(){var e=AC("Symbol")("stringify detection");return va([e])!=="[null]"||va({a:e})!=="{}"||va(Object(e))!=="{}"}),Iy=xC(function(){return va("\uDF06\uD834")!=='"\\udf06\\ud834"'||va("\uDEAD")!=='"\\udead"'}),KN=function(e,r){var t=NC(arguments),n=BN(r);if(!(!Cy(n)&&(e===void 0||Ty(e))))return t[1]=function(i,a){if(Cy(n)&&(a=UN(n,this,zN(i),a)),!Ty(a))return a},MC(va,null,t)},JN=function(e,r,t){var n=Ey(t,r-1),i=Ey(t,r+1);return Gu(ky,e)&&!Gu(Ry,i)||Gu(Ry,e)&&!Gu(ky,n)?"\\u"+GN(WN(e,0),16):e};va&&FN({target:"JSON",stat:!0,arity:3,forced:$y||Iy},{stringify:function(r,t,n){var i=NC(arguments),a=MC($y?KN:va,null,i);return Iy&&typeof a=="string"?VN(a,HN,JN):a}});var YN=gt,XN=no,QN=lt,LC=cu,ZN=Mr,eL=!XN||QN(function(){LC.f(1)});YN({target:"Object",stat:!0,forced:eL},{getOwnPropertySymbols:function(r){var t=LC.f;return t?t(ZN(r)):[]}});var tL=lt,rL=Bt,nL=ro,iL=rL("species"),mu=function(e){return nL>=51||!tL(function(){var r=[],t=r.constructor={};return t[iL]=function(){return{foo:1}},r[e](Boolean).foo!==1})},aL=gt,sL=Zr.filter,oL=mu,uL=oL("filter");aL({target:"Array",proto:!0,forced:!uL},{filter:function(r){return sL(this,r,arguments.length>1?arguments[1]:void 0)}});var cL=gt,lL=lt,fL=dn,DC=Bi.f,jC=Wt,dL=!jC||lL(function(){DC(1)});cL({target:"Object",stat:!0,forced:dL,sham:!jC},{getOwnPropertyDescriptor:function(r,t){return DC(fL(r),t)}});var pL=Wt,hL=Fr,vL=ts,gu=function(e,r,t){pL?hL.f(e,r,vL(0,t)):e[r]=t},mL=gt,gL=Wt,yL=Y0,bL=dn,_L=Bi,wL=gu;mL({target:"Object",stat:!0,sham:!gL},{getOwnPropertyDescriptors:function(r){for(var t=bL(r),n=_L.f,i=yL(t),a={},s=0,o,u;i.length>s;)u=n(t,o=i[s++]),u!==void 0&&wL(a,o,u);return a}});var FC={exports:{}};(function(e){function r(n,i,a,s,o,u,c){try{var l=n[u](c),h=l.value}catch(v){return void a(v)}l.done?i(h):Promise.resolve(h).then(s,o)}function t(n){return function(){var i=this,a=arguments;return new Promise(function(s,o){var u=n.apply(i,a);function c(h){r(u,s,o,c,l,"next",h)}function l(h){r(u,s,o,c,l,"throw",h)}c(void 0)})}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(FC);var yu=FC.exports,UC={exports:{}};(function(e){function r(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(UC);var os=UC.exports,BC={exports:{}},qC={exports:{}};(function(e){function r(t,n){return e.exports=r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,a){return i.__proto__=a,i},e.exports.__esModule=!0,e.exports.default=e.exports,r(t,n)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(qC);var Wv=qC.exports;(function(e){var r=Wv;function t(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&&r(n,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(BC);var vi=BC.exports,zC={exports:{}},WC={exports:{}};(function(e){function r(t){"@babel/helpers - typeof";return e.exports=r=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},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(WC);var On=WC.exports;(function(e){var r=On.default,t=os;function n(i,a){if(a&&(r(a)=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return t(i)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(zC);var mi=zC.exports,VC={exports:{}};(function(e){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(VC);var Pn=VC.exports,GC={exports:{}},HC={exports:{}},KC={exports:{}};(function(e){var r=On.default;function t(n,i){if(r(n)!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(r(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(KC);var SL=KC.exports;(function(e){var r=On.default,t=SL;function n(i){var a=t(i,"string");return r(a)=="symbol"?a:a+""}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(HC);var JC=HC.exports;(function(e){var r=JC;function t(n,i,a){return(i=r(i))in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(GC);var us=GC.exports,YC={exports:{}};(function(e){var r=JC;function t(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,r(o.key),o)}}function n(i,a,s){return a&&t(i.prototype,a),s&&t(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(YC);var Ea=YC.exports,XC={exports:{}};(function(e){function r(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(XC);var gi=XC.exports,CL=gt,TL=Zr.map,EL=mu,kL=EL("map");CL({target:"Array",proto:!0,forced:!kL},{map:function(r){return TL(this,r,arguments.length>1?arguments[1]:void 0)}});var RL=Pv,$L=Vi,IL=RL?{}.toString:function(){return"[object "+$L(this)+"]"},OL=Pv,PL=Ur,AL=IL;OL||PL(Object.prototype,"toString",AL,{unsafe:!0});var QC={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},ML=Ml,nd=ML("span").classList,Oy=nd&&nd.constructor&&nd.constructor.prototype,ZC=Oy===Object.prototype?void 0:Oy,xL=lt,zl=function(e,r){var t=[][e];return!!t&&xL(function(){t.call(null,r||function(){return 1},1)})},NL=Zr.forEach,LL=zl,DL=LL("forEach"),jL=DL?[].forEach:function(r){return NL(this,r,arguments.length>1?arguments[1]:void 0)},Py=_t,Ay=QC,FL=ZC,id=jL,UL=zi,eT=function(e){if(e&&e.forEach!==id)try{UL(e,"forEach",id)}catch{e.forEach=id}};for(var ad in Ay)Ay[ad]&&eT(Py[ad]&&Py[ad].prototype);eT(FL);var _o=_t,BL=Ca,qL=li,Hu=function(e){return BL.slice(0,e.length)===e},tT=function(){return Hu("Bun/")?"BUN":Hu("Cloudflare-Workers")?"CLOUDFLARE":Hu("Deno/")?"DENO":Hu("Node.js/")?"NODE":_o.Bun&&typeof Bun.version=="string"?"BUN":_o.Deno&&typeof Deno.version=="object"?"DENO":qL(_o.process)==="process"?"NODE":_o.window&&_o.document?"BROWSER":"REST"}(),zL=tT,Vv=zL==="NODE",WL=vt,VL=In,GL=function(e,r,t){try{return WL(VL(Object.getOwnPropertyDescriptor(e,r)[t]))}catch{}},HL=Jt,KL=function(e){return HL(e)||e===null},JL=KL,YL=String,XL=TypeError,QL=function(e){if(JL(e))return e;throw new XL("Can't set "+YL(e)+" as a prototype")},ZL=GL,e2=Jt,t2=Kn,r2=QL,so=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=ZL(Object.prototype,"__proto__","set"),t(r,[]),e=r instanceof Array}catch{}return function(i,a){return t2(i),r2(a),e2(i)&&(e?t(i,a):i.__proto__=a),i}}():void 0),n2=$n,i2=hi,a2=Bt,s2=Wt,My=a2("species"),Wl=function(e){var r=n2(e);s2&&r&&!r[My]&&i2(r,My,{configurable:!0,get:function(){return this}})},o2=qi,u2=TypeError,ka=function(e,r){if(o2(r,e))return e;throw new u2("Incorrect invocation")},xy=ar,c2=Mv,l2=Hn,f2=Bt,d2=f2("species"),rT=function(e,r){var t=xy(e).constructor,n;return t===void 0||l2(n=xy(t)[d2])?r:c2(n)},p2=TypeError,Gv=function(e,r){if(e<r)throw new p2("Not enough arguments");return e},h2=Ca,nT=/(?:ipad|iphone|ipod).*applewebkit/i.test(h2),ln=_t,v2=ss,m2=Gi,Ny=Ut,g2=tr,iT=lt,Ly=aC,y2=pi,Dy=Ml,b2=Gv,_2=nT,w2=Vv,Yp=ln.setImmediate,jy=ln.clearImmediate,S2=ln.process,sd=ln.Dispatch,C2=ln.Function,Fy=ln.MessageChannel,T2=ln.String,od=0,Uo={},Uy="onreadystatechange",Yo,ja,ud,cd;iT(function(){Yo=ln.location});var Hv=function(e){if(g2(Uo,e)){var r=Uo[e];delete Uo[e],r()}},ld=function(e){return function(){Hv(e)}},By=function(e){Hv(e.data)},qy=function(e){ln.postMessage(T2(e),Yo.protocol+"//"+Yo.host)};(!Yp||!jy)&&(Yp=function(r){b2(arguments.length,1);var t=Ny(r)?r:C2(r),n=y2(arguments,1);return Uo[++od]=function(){v2(t,void 0,n)},ja(od),od},jy=function(r){delete Uo[r]},w2?ja=function(e){S2.nextTick(ld(e))}:sd&&sd.now?ja=function(e){sd.now(ld(e))}:Fy&&!_2?(ud=new Fy,cd=ud.port2,ud.port1.onmessage=By,ja=m2(cd.postMessage,cd)):ln.addEventListener&&Ny(ln.postMessage)&&!ln.importScripts&&Yo&&Yo.protocol!=="file:"&&!iT(qy)?(ja=qy,ln.addEventListener("message",By,!1)):Uy in Dy("script")?ja=function(e){Ly.appendChild(Dy("script"))[Uy]=function(){Ly.removeChild(this),Hv(e)}}:ja=function(e){setTimeout(ld(e),0)});var aT={set:Yp},zy=_t,E2=Wt,k2=Object.getOwnPropertyDescriptor,sT=function(e){if(!E2)return zy[e];var r=k2(zy,e);return r&&r.value},oT=function(){this.head=null,this.tail=null};oT.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var uT=oT,R2=Ca,$2=/ipad|iphone|ipod/i.test(R2)&&typeof Pebble<"u",I2=Ca,O2=/web0s(?!.*chrome)/i.test(I2),Js=_t,P2=sT,Wy=Gi,fd=aT.set,A2=uT,M2=nT,x2=$2,N2=O2,dd=Vv,Vy=Js.MutationObserver||Js.WebKitMutationObserver,Gy=Js.document,Hy=Js.process,Ku=Js.Promise,Xp=P2("queueMicrotask"),gs,pd,hd,Ju,Ky;if(!Xp){var Yu=new A2,Xu=function(){var e,r;for(dd&&(e=Hy.domain)&&e.exit();r=Yu.get();)try{r()}catch(t){throw Yu.head&&gs(),t}e&&e.enter()};!M2&&!dd&&!N2&&Vy&&Gy?(pd=!0,hd=Gy.createTextNode(""),new Vy(Xu).observe(hd,{characterData:!0}),gs=function(){hd.data=pd=!pd}):!x2&&Ku&&Ku.resolve?(Ju=Ku.resolve(void 0),Ju.constructor=Ku,Ky=Wy(Ju.then,Ju),gs=function(){Ky(Xu)}):dd?gs=function(){Hy.nextTick(Xu)}:(fd=Wy(fd,Js),gs=function(){fd(Xu)}),Xp=function(e){Yu.head||gs(),Yu.add(e)}}var L2=Xp,D2=function(e,r){try{arguments.length===1?console.error(e):console.error(e,r)}catch{}},Kv=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},j2=_t,Vl=j2.Promise,F2=_t,Bo=Vl,U2=Ut,B2=Ll,q2=Rv,z2=Bt,Jy=tT,vd=ro;Bo&&Bo.prototype;var W2=z2("species"),Qp=!1,cT=U2(F2.PromiseRejectionEvent),V2=B2("Promise",function(){var e=q2(Bo),r=e!==String(Bo);if(!r&&vd===66)return!0;if(!vd||vd<51||!/native code/.test(e)){var t=new Bo(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=t.constructor={};if(i[W2]=n,Qp=t.then(function(){})instanceof n,!Qp)return!0}return!r&&(Jy==="BROWSER"||Jy==="DENO")&&!cT}),bu={CONSTRUCTOR:V2,REJECTION_EVENT:cT,SUBCLASSING:Qp},oo={},Yy=In,G2=TypeError,H2=function(e){var r,t;this.promise=new e(function(n,i){if(r!==void 0||t!==void 0)throw new G2("Bad Promise constructor");r=n,t=i}),this.resolve=Yy(r),this.reject=Yy(t)};oo.f=function(e){return new H2(e)};var K2=gt,pl=Vv,ba=_t,Ys=Ft,Xy=Ur,Qy=so,J2=di,Y2=Wl,X2=In,Yc=Ut,Q2=Jt,Z2=ka,eD=rT,lT=aT.set,Jv=L2,tD=D2,rD=Kv,nD=uT,fT=pn,hl=Vl,Yv=bu,dT=oo,Gl="Promise",pT=Yv.CONSTRUCTOR,iD=Yv.REJECTION_EVENT,aD=Yv.SUBCLASSING,md=fT.getterFor(Gl),sD=fT.set,ks=hl&&hl.prototype,Ga=hl,Qu=ks,hT=ba.TypeError,Zp=ba.document,Xv=ba.process,eh=dT.f,oD=eh,uD=!!(Zp&&Zp.createEvent&&ba.dispatchEvent),vT="unhandledrejection",cD="rejectionhandled",Zy=0,mT=1,lD=2,Qv=1,gT=2,Zu,eb,fD,tb,yT=function(e){var r;return Q2(e)&&Yc(r=e.then)?r:!1},bT=function(e,r){var t=r.value,n=r.state===mT,i=n?e.ok:e.fail,a=e.resolve,s=e.reject,o=e.domain,u,c,l;try{i?(n||(r.rejection===gT&&pD(r),r.rejection=Qv),i===!0?u=t:(o&&o.enter(),u=i(t),o&&(o.exit(),l=!0)),u===e.promise?s(new hT("Promise-chain cycle")):(c=yT(u))?Ys(c,u,a,s):a(u)):s(t)}catch(h){o&&!l&&o.exit(),s(h)}},_T=function(e,r){e.notified||(e.notified=!0,Jv(function(){for(var t=e.reactions,n;n=t.get();)bT(n,e);e.notified=!1,r&&!e.rejection&&dD(e)}))},wT=function(e,r,t){var n,i;uD?(n=Zp.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),ba.dispatchEvent(n)):n={promise:r,reason:t},!iD&&(i=ba["on"+e])?i(n):e===vT&&tD("Unhandled promise rejection",t)},dD=function(e){Ys(lT,ba,function(){var r=e.facade,t=e.value,n=rb(e),i;if(n&&(i=rD(function(){pl?Xv.emit("unhandledRejection",t,r):wT(vT,r,t)}),e.rejection=pl||rb(e)?gT:Qv,i.error))throw i.value})},rb=function(e){return e.rejection!==Qv&&!e.parent},pD=function(e){Ys(lT,ba,function(){var r=e.facade;pl?Xv.emit("rejectionHandled",r):wT(cD,r,e.value)})},Os=function(e,r,t){return function(n){e(r,n,t)}},xs=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=lD,_T(e,!0))},th=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw new hT("Promise can't be resolved itself");var n=yT(r);n?Jv(function(){var i={done:!1};try{Ys(n,r,Os(th,i,e),Os(xs,i,e))}catch(a){xs(i,a,e)}}):(e.value=r,e.state=mT,_T(e,!1))}catch(i){xs({done:!1},i,e)}}};if(pT&&(Ga=function(r){Z2(this,Qu),X2(r),Ys(Zu,this);var t=md(this);try{r(Os(th,t),Os(xs,t))}catch(n){xs(t,n)}},Qu=Ga.prototype,Zu=function(r){sD(this,{type:Gl,done:!1,notified:!1,parent:!1,reactions:new nD,rejection:!1,state:Zy,value:null})},Zu.prototype=Xy(Qu,"then",function(r,t){var n=md(this),i=eh(eD(this,Ga));return n.parent=!0,i.ok=Yc(r)?r:!0,i.fail=Yc(t)&&t,i.domain=pl?Xv.domain:void 0,n.state===Zy?n.reactions.add(i):Jv(function(){bT(i,n)}),i.promise}),eb=function(){var e=new Zu,r=md(e);this.promise=e,this.resolve=Os(th,r),this.reject=Os(xs,r)},dT.f=eh=function(e){return e===Ga||e===fD?new eb(e):oD(e)},Yc(hl)&&ks!==Object.prototype)){tb=ks.then,aD||Xy(ks,"then",function(r,t){var n=this;return new Ga(function(i,a){Ys(tb,n,i,a)}).then(r,t)},{unsafe:!0});try{delete ks.constructor}catch{}Qy&&Qy(ks,Qu)}K2({global:!0,constructor:!0,wrap:!0,forced:pT},{Promise:Ga});J2(Ga,Gl,!1);Y2(Gl);var _u={},hD=Bt,vD=_u,mD=hD("iterator"),gD=Array.prototype,Zv=function(e){return e!==void 0&&(vD.Array===e||gD[mD]===e)},yD=Vi,nb=ns,bD=Hn,_D=_u,wD=Bt,SD=wD("iterator"),wu=function(e){if(!bD(e))return nb(e,SD)||nb(e,"@@iterator")||_D[yD(e)]},CD=Ft,TD=In,ED=ar,kD=rs,RD=wu,$D=TypeError,Hl=function(e,r){var t=arguments.length<2?RD(e):r;if(TD(t))return ED(CD(t,e));throw new $D(kD(e)+" is not iterable")},ID=Ft,ib=ar,OD=ns,ST=function(e,r,t){var n,i;ib(e);try{if(n=OD(e,"return"),!n){if(r==="throw")throw t;return t}n=ID(n,e)}catch(a){i=!0,n=a}if(r==="throw")throw t;if(i)throw n;return ib(n),t},PD=Gi,AD=Ft,MD=ar,xD=rs,ND=Zv,LD=xr,ab=qi,DD=Hl,jD=wu,sb=ST,FD=TypeError,Xc=function(e,r){this.stopped=e,this.result=r},ob=Xc.prototype,Su=function(e,r,t){var n=t&&t.that,i=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),s=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=PD(r,n),c,l,h,v,m,_,C,I=function(x){return c&&sb(c,"normal",x),new Xc(!0,x)},$=function(x){return i?(MD(x),o?u(x[0],x[1],I):u(x[0],x[1])):o?u(x,I):u(x)};if(a)c=e.iterator;else if(s)c=e;else{if(l=jD(e),!l)throw new FD(xD(e)+" is not iterable");if(ND(l)){for(h=0,v=LD(e);v>h;h++)if(m=$(e[h]),m&&ab(ob,m))return m;return new Xc(!1)}c=DD(e,l)}for(_=a?e.next:c.next;!(C=AD(_,c)).done;){try{m=$(C.value)}catch(x){sb(c,"throw",x)}if(typeof m=="object"&&m&&ab(ob,m))return m}return new Xc(!1)},UD=Bt,CT=UD("iterator"),TT=!1;try{var BD=0,ub={next:function(){return{done:!!BD++}},return:function(){TT=!0}};ub[CT]=function(){return this},Array.from(ub,function(){throw 2})}catch{}var Kl=function(e,r){try{if(!r&&!TT)return!1}catch{return!1}var t=!1;try{var n={};n[CT]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch{}return t},qD=Vl,zD=Kl,WD=bu.CONSTRUCTOR,ET=WD||!zD(function(e){qD.all(e).then(void 0,function(){})}),VD=gt,GD=Ft,HD=In,KD=oo,JD=Kv,YD=Su,XD=ET;VD({target:"Promise",stat:!0,forced:XD},{all:function(r){var t=this,n=KD.f(t),i=n.resolve,a=n.reject,s=JD(function(){var o=HD(t.resolve),u=[],c=0,l=1;YD(r,function(h){var v=c++,m=!1;l++,GD(o,t,h).then(function(_){m||(m=!0,u[v]=_,--l||i(u))},a)}),--l||i(u)});return s.error&&a(s.value),n.promise}});var QD=gt,ZD=bu.CONSTRUCTOR,rh=Vl,ej=$n,tj=Ut,rj=Ur,cb=rh&&rh.prototype;QD({target:"Promise",proto:!0,forced:ZD,real:!0},{catch:function(e){return this.then(void 0,e)}});if(tj(rh)){var lb=ej("Promise").prototype.catch;cb.catch!==lb&&rj(cb,"catch",lb,{unsafe:!0})}var nj=gt,ij=Ft,aj=In,sj=oo,oj=Kv,uj=Su,cj=ET;nj({target:"Promise",stat:!0,forced:cj},{race:function(r){var t=this,n=sj.f(t),i=n.reject,a=oj(function(){var s=aj(t.resolve);uj(r,function(o){ij(s,t,o).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var lj=gt,fj=oo,dj=bu.CONSTRUCTOR;lj({target:"Promise",stat:!0,forced:dj},{reject:function(r){var t=fj.f(this),n=t.reject;return n(r),t.promise}});var pj=ar,hj=Jt,vj=oo,mj=function(e,r){if(pj(e),hj(r)&&r.constructor===e)return r;var t=vj.f(e),n=t.resolve;return n(r),t.promise},gj=gt,yj=$n,bj=bu.CONSTRUCTOR,_j=mj;yj("Promise");gj({target:"Promise",stat:!0,forced:bj},{resolve:function(r){return _j(this,r)}});var kT={exports:{}};(function(e){var r=On.default;function t(){e.exports=t=function(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var n,i={},a=Object.prototype,s=a.hasOwnProperty,o=Object.defineProperty||function(he,pe,M){he[pe]=M.value},u=typeof Symbol=="function"?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",h=u.toStringTag||"@@toStringTag";function v(he,pe,M){return Object.defineProperty(he,pe,{value:M,enumerable:!0,configurable:!0,writable:!0}),he[pe]}try{v({},"")}catch{v=function(M,Oe,Je){return M[Oe]=Je}}function m(he,pe,M,Oe){var Je=pe&&pe.prototype instanceof q?pe:q,De=Object.create(Je.prototype),we=new ft(Oe||[]);return o(De,"_invoke",{value:Y(he,M,we)}),De}function _(he,pe,M){try{return{type:"normal",arg:he.call(pe,M)}}catch(Oe){return{type:"throw",arg:Oe}}}i.wrap=m;var C="suspendedStart",I="suspendedYield",$="executing",x="completed",N={};function q(){}function X(){}function J(){}var G={};v(G,c,function(){return this});var L=Object.getPrototypeOf,te=L&&L(L(Pe([])));te&&te!==a&&s.call(te,c)&&(G=te);var se=J.prototype=q.prototype=Object.create(G);function ne(he){["next","throw","return"].forEach(function(pe){v(he,pe,function(M){return this._invoke(pe,M)})})}function ge(he,pe){function M(Je,De,we,Q){var $t=_(he[Je],he,De);if($t.type!=="throw"){var _e=$t.arg,le=_e.value;return le&&r(le)=="object"&&s.call(le,"__await")?pe.resolve(le.__await).then(function(St){M("next",St,we,Q)},function(St){M("throw",St,we,Q)}):pe.resolve(le).then(function(St){_e.value=St,we(_e)},function(St){return M("throw",St,we,Q)})}Q($t.arg)}var Oe;o(this,"_invoke",{value:function(De,we){function Q(){return new pe(function($t,_e){M(De,we,$t,_e)})}return Oe=Oe?Oe.then(Q,Q):Q()}})}function Y(he,pe,M){var Oe=C;return function(Je,De){if(Oe===$)throw Error("Generator is already running");if(Oe===x){if(Je==="throw")throw De;return{value:n,done:!0}}for(M.method=Je,M.arg=De;;){var we=M.delegate;if(we){var Q=Ue(we,M);if(Q){if(Q===N)continue;return Q}}if(M.method==="next")M.sent=M._sent=M.arg;else if(M.method==="throw"){if(Oe===C)throw Oe=x,M.arg;M.dispatchException(M.arg)}else M.method==="return"&&M.abrupt("return",M.arg);Oe=$;var $t=_(he,pe,M);if($t.type==="normal"){if(Oe=M.done?x:I,$t.arg===N)continue;return{value:$t.arg,done:M.done}}$t.type==="throw"&&(Oe=x,M.method="throw",M.arg=$t.arg)}}}function Ue(he,pe){var M=pe.method,Oe=he.iterator[M];if(Oe===n)return pe.delegate=null,M==="throw"&&he.iterator.return&&(pe.method="return",pe.arg=n,Ue(he,pe),pe.method==="throw")||M!=="return"&&(pe.method="throw",pe.arg=new TypeError("The iterator does not provide a '"+M+"' method")),N;var Je=_(Oe,he.iterator,pe.arg);if(Je.type==="throw")return pe.method="throw",pe.arg=Je.arg,pe.delegate=null,N;var De=Je.arg;return De?De.done?(pe[he.resultName]=De.value,pe.next=he.nextLoc,pe.method!=="return"&&(pe.method="next",pe.arg=n),pe.delegate=null,N):De:(pe.method="throw",pe.arg=new TypeError("iterator result is not an object"),pe.delegate=null,N)}function He(he){var pe={tryLoc:he[0]};1 in he&&(pe.catchLoc=he[1]),2 in he&&(pe.finallyLoc=he[2],pe.afterLoc=he[3]),this.tryEntries.push(pe)}function Rt(he){var pe=he.completion||{};pe.type="normal",delete pe.arg,he.completion=pe}function ft(he){this.tryEntries=[{tryLoc:"root"}],he.forEach(He,this),this.reset(!0)}function Pe(he){if(he||he===""){var pe=he[c];if(pe)return pe.call(he);if(typeof he.next=="function")return he;if(!isNaN(he.length)){var M=-1,Oe=function Je(){for(;++M<he.length;)if(s.call(he,M))return Je.value=he[M],Je.done=!1,Je;return Je.value=n,Je.done=!0,Je};return Oe.next=Oe}}throw new TypeError(r(he)+" is not iterable")}return X.prototype=J,o(se,"constructor",{value:J,configurable:!0}),o(J,"constructor",{value:X,configurable:!0}),X.displayName=v(J,h,"GeneratorFunction"),i.isGeneratorFunction=function(he){var pe=typeof he=="function"&&he.constructor;return!!pe&&(pe===X||(pe.displayName||pe.name)==="GeneratorFunction")},i.mark=function(he){return Object.setPrototypeOf?Object.setPrototypeOf(he,J):(he.__proto__=J,v(he,h,"GeneratorFunction")),he.prototype=Object.create(se),he},i.awrap=function(he){return{__await:he}},ne(ge.prototype),v(ge.prototype,l,function(){return this}),i.AsyncIterator=ge,i.async=function(he,pe,M,Oe,Je){Je===void 0&&(Je=Promise);var De=new ge(m(he,pe,M,Oe),Je);return i.isGeneratorFunction(pe)?De:De.next().then(function(we){return we.done?we.value:De.next()})},ne(se),v(se,h,"Generator"),v(se,c,function(){return this}),v(se,"toString",function(){return"[object Generator]"}),i.keys=function(he){var pe=Object(he),M=[];for(var Oe in pe)M.push(Oe);return M.reverse(),function Je(){for(;M.length;){var De=M.pop();if(De in pe)return Je.value=De,Je.done=!1,Je}return Je.done=!0,Je}},i.values=Pe,ft.prototype={constructor:ft,reset:function(pe){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(Rt),!pe)for(var M in this)M.charAt(0)==="t"&&s.call(this,M)&&!isNaN(+M.slice(1))&&(this[M]=n)},stop:function(){this.done=!0;var pe=this.tryEntries[0].completion;if(pe.type==="throw")throw pe.arg;return this.rval},dispatchException:function(pe){if(this.done)throw pe;var M=this;function Oe(_e,le){return we.type="throw",we.arg=pe,M.next=_e,le&&(M.method="next",M.arg=n),!!le}for(var Je=this.tryEntries.length-1;Je>=0;--Je){var De=this.tryEntries[Je],we=De.completion;if(De.tryLoc==="root")return Oe("end");if(De.tryLoc<=this.prev){var Q=s.call(De,"catchLoc"),$t=s.call(De,"finallyLoc");if(Q&&$t){if(this.prev<De.catchLoc)return Oe(De.catchLoc,!0);if(this.prev<De.finallyLoc)return Oe(De.finallyLoc)}else if(Q){if(this.prev<De.catchLoc)return Oe(De.catchLoc,!0)}else{if(!$t)throw Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return Oe(De.finallyLoc)}}}},abrupt:function(pe,M){for(var Oe=this.tryEntries.length-1;Oe>=0;--Oe){var Je=this.tryEntries[Oe];if(Je.tryLoc<=this.prev&&s.call(Je,"finallyLoc")&&this.prev<Je.finallyLoc){var De=Je;break}}De&&(pe==="break"||pe==="continue")&&De.tryLoc<=M&&M<=De.finallyLoc&&(De=null);var we=De?De.completion:{};return we.type=pe,we.arg=M,De?(this.method="next",this.next=De.finallyLoc,N):this.complete(we)},complete:function(pe,M){if(pe.type==="throw")throw pe.arg;return pe.type==="break"||pe.type==="continue"?this.next=pe.arg:pe.type==="return"?(this.rval=this.arg=pe.arg,this.method="return",this.next="end"):pe.type==="normal"&&M&&(this.next=M),N},finish:function(pe){for(var M=this.tryEntries.length-1;M>=0;--M){var Oe=this.tryEntries[M];if(Oe.finallyLoc===pe)return this.complete(Oe.completion,Oe.afterLoc),Rt(Oe),N}},catch:function(pe){for(var M=this.tryEntries.length-1;M>=0;--M){var Oe=this.tryEntries[M];if(Oe.tryLoc===pe){var Je=Oe.completion;if(Je.type==="throw"){var De=Je.arg;Rt(Oe)}return De}}throw Error("illegal catch attempt")},delegateYield:function(pe,M,Oe){return this.delegate={iterator:Pe(pe),resultName:M,nextLoc:Oe},this.method==="next"&&(this.arg=n),N}},i}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(kT);var wj=kT.exports,Qc=wj(),Cu=Qc;try{regeneratorRuntime=Qc}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Qc:Function("r","regeneratorRuntime = r")(Qc)}var Sj=TypeError,Cj=9007199254740991,RT=function(e){if(e>Cj)throw Sj("Maximum allowed index exceeded");return e},Tj=gt,Ej=lt,kj=du,Rj=Jt,$j=Mr,Ij=xr,fb=RT,db=gu,Oj=Fv,Pj=mu,Aj=Bt,Mj=ro,$T=Aj("isConcatSpreadable"),xj=Mj>=51||!Ej(function(){var e=[];return e[$T]=!1,e.concat()[0]!==e}),Nj=function(e){if(!Rj(e))return!1;var r=e[$T];return r!==void 0?!!r:kj(e)},Lj=!xj||!Pj("concat");Tj({target:"Array",proto:!0,arity:1,forced:Lj},{concat:function(r){var t=$j(this),n=Oj(t,0),i=0,a,s,o,u,c;for(a=-1,o=arguments.length;a<o;a++)if(c=a===-1?t:arguments[a],Nj(c))for(u=Ij(c),fb(i+u),s=0;s<u;s++,i++)s in c&&db(n,i,c[s]);else fb(i+1),db(n,i++,c);return n.length=i,n}});var Dj=ar,jj=ST,Fj=function(e,r,t,n){try{return n?r(Dj(t)[0],t[1]):r(t)}catch(i){jj(e,"throw",i)}},Uj=Gi,Bj=Ft,qj=Mr,zj=Fj,Wj=Zv,Vj=Dl,Gj=xr,pb=gu,Hj=Hl,Kj=wu,hb=Array,IT=function(r){var t=qj(r),n=Vj(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=Uj(a,i>2?arguments[2]:void 0));var o=Kj(t),u=0,c,l,h,v,m,_;if(o&&!(this===hb&&Wj(o)))for(l=n?new this:[],v=Hj(t,o),m=v.next;!(h=Bj(m,v)).done;u++)_=s?zj(v,a,[h.value,u],!0):h.value,pb(l,u,_);else for(c=Gj(t),l=n?new this(c):hb(c);c>u;u++)_=s?a(t[u],u):t[u],pb(l,u,_);return l.length=u,l},Jj=gt,Yj=IT,Xj=Kl,Qj=!Xj(function(e){Array.from(e)});Jj({target:"Array",stat:!0,forced:Qj},{from:Yj});var em=vt,Zj=fi,eF=wr,tF=Kn,rF=em("".charAt),vb=em("".charCodeAt),nF=em("".slice),mb=function(e){return function(r,t){var n=eF(tF(r)),i=Zj(t),a=n.length,s,o;return i<0||i>=a?e?"":void 0:(s=vb(n,i),s<55296||s>56319||i+1===a||(o=vb(n,i+1))<56320||o>57343?e?rF(n,i):s:e?nF(n,i,i+2):(s-55296<<10)+(o-56320)+65536)}},tm={codeAt:mb(!1),charAt:mb(!0)},iF=lt,aF=!iF(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),sF=tr,oF=Ut,uF=Mr,cF=xl,lF=aF,gb=cF("IE_PROTO"),nh=Object,fF=nh.prototype,Tu=lF?nh.getPrototypeOf:function(e){var r=uF(e);if(sF(r,gb))return r[gb];var t=r.constructor;return oF(t)&&r instanceof t?t.prototype:r instanceof nh?fF:null},dF=lt,pF=Ut,hF=Jt,yb=Tu,vF=Ur,mF=Bt,ih=mF("iterator"),OT=!1,Xa,gd,yd;[].keys&&(yd=[].keys(),"next"in yd?(gd=yb(yb(yd)),gd!==Object.prototype&&(Xa=gd)):OT=!0);var gF=!hF(Xa)||dF(function(){var e={};return Xa[ih].call(e)!==e});gF&&(Xa={});pF(Xa[ih])||vF(Xa,ih,function(){return this});var PT={IteratorPrototype:Xa,BUGGY_SAFARI_ITERATORS:OT},yF=PT.IteratorPrototype,bF=Ta,_F=ts,wF=di,SF=_u,CF=function(){return this},AT=function(e,r,t,n){var i=r+" Iterator";return e.prototype=bF(yF,{next:_F(+!n,t)}),wF(e,i,!1),SF[i]=CF,e},TF=gt,EF=Ft,MT=ou,kF=Ut,RF=AT,bb=Tu,_b=so,$F=di,IF=zi,bd=Ur,OF=Bt,PF=_u,xT=PT,AF=MT.PROPER,MF=MT.CONFIGURABLE,wb=xT.IteratorPrototype,ec=xT.BUGGY_SAFARI_ITERATORS,wo=OF("iterator"),Sb="keys",So="values",Cb="entries",xF=function(){return this},rm=function(e,r,t,n,i,a,s){RF(t,r,n);var o=function($){if($===i&&v)return v;if(!ec&&$&&$ in l)return l[$];switch($){case Sb:return function(){return new t(this,$)};case So:return function(){return new t(this,$)};case Cb:return function(){return new t(this,$)}}return function(){return new t(this)}},u=r+" Iterator",c=!1,l=e.prototype,h=l[wo]||l["@@iterator"]||i&&l[i],v=!ec&&h||o(i),m=r==="Array"&&l.entries||h,_,C,I;if(m&&(_=bb(m.call(new e)),_!==Object.prototype&&_.next&&(bb(_)!==wb&&(_b?_b(_,wb):kF(_[wo])||bd(_,wo,xF)),$F(_,u,!0))),AF&&i===So&&h&&h.name!==So&&(MF?IF(l,"name",So):(c=!0,v=function(){return EF(h,this)})),i)if(C={values:o(So),keys:a?v:o(Sb),entries:o(Cb)},s)for(I in C)(ec||c||!(I in l))&&bd(l,I,C[I]);else TF({target:r,proto:!0,forced:ec||c},C);return l[wo]!==v&&bd(l,wo,v,{name:i}),PF[r]=v,C},Jl=function(e,r){return{value:e,done:r}},NF=tm.charAt,LF=wr,NT=pn,DF=rm,Tb=Jl,LT="String Iterator",jF=NT.set,FF=NT.getterFor(LT);DF(String,"String",function(e){jF(this,{type:LT,string:LF(e),index:0})},function(){var r=FF(this),t=r.string,n=r.index,i;return n>=t.length?Tb(void 0,!0):(i=NF(t,n),r.index+=i.length,Tb(i,!1))});var DT={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(Ae,function(){var r=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],a={},s=null;function o(C,I){var $=C[I];if(typeof $.bind=="function")return $.bind(C);try{return Function.prototype.bind.call($,C)}catch{return function(){return Function.prototype.apply.apply($,[C,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 c(C){return C==="debug"&&(C="log"),typeof console===t?!1:C==="trace"&&n?u:console[C]!==void 0?o(console,C):console.log!==void 0?o(console,"log"):r}function l(){for(var C=this.getLevel(),I=0;I<i.length;I++){var $=i[I];this[$]=I<C?r:this.methodFactory($,C,this.name)}if(this.log=this.debug,typeof console===t&&C<this.levels.SILENT)return"No console available for logging"}function h(C){return function(){typeof console!==t&&(l.call(this),this[C].apply(this,arguments))}}function v(C,I,$){return c(C)||h.apply(this,arguments)}function m(C,I){var $=this,x,N,q,X="loglevel";typeof C=="string"?X+=":"+C:typeof C=="symbol"&&(X=void 0);function J(ne){var ge=(i[ne]||"silent").toUpperCase();if(!(typeof window===t||!X)){try{window.localStorage[X]=ge;return}catch{}try{window.document.cookie=encodeURIComponent(X)+"="+ge+";"}catch{}}}function G(){var ne;if(!(typeof window===t||!X)){try{ne=window.localStorage[X]}catch{}if(typeof ne===t)try{var ge=window.document.cookie,Y=encodeURIComponent(X),Ue=ge.indexOf(Y+"=");Ue!==-1&&(ne=/^([^;]+)/.exec(ge.slice(Ue+Y.length+1))[1])}catch{}return $.levels[ne]===void 0&&(ne=void 0),ne}}function L(){if(!(typeof window===t||!X)){try{window.localStorage.removeItem(X)}catch{}try{window.document.cookie=encodeURIComponent(X)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function te(ne){var ge=ne;if(typeof ge=="string"&&$.levels[ge.toUpperCase()]!==void 0&&(ge=$.levels[ge.toUpperCase()]),typeof ge=="number"&&ge>=0&&ge<=$.levels.SILENT)return ge;throw new TypeError("log.setLevel() called with invalid level: "+ne)}$.name=C,$.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},$.methodFactory=I||v,$.getLevel=function(){return q??N??x},$.setLevel=function(ne,ge){return q=te(ne),ge!==!1&&J(q),l.call($)},$.setDefaultLevel=function(ne){N=te(ne),G()||$.setLevel(ne,!1)},$.resetLevel=function(){q=null,L(),l.call($)},$.enableAll=function(ne){$.setLevel($.levels.TRACE,ne)},$.disableAll=function(ne){$.setLevel($.levels.SILENT,ne)},$.rebuild=function(){if(s!==$&&(x=te(s.getLevel())),l.call($),s===$)for(var ne in a)a[ne].rebuild()},x=te(s?s.getLevel():"WARN");var se=G();se!=null&&(q=te(se)),l.call($)}s=new m,s.getLogger=function(I){if(typeof I!="symbol"&&typeof I!="string"||I==="")throw new TypeError("You must supply a name when creating a logger.");var $=a[I];return $||($=a[I]=new m(I,s.methodFactory)),$};var _=typeof window!==t?window.log:void 0;return s.noConflict=function(){return typeof window!==t&&window.log===s&&(window.log=_),s},s.getLoggers=function(){return a},s.default=s,s})})(DT);var gr=DT.exports;const Ya="\\d+(?:[\\.,]\\d+)?",UF=`(${Ya}W)`,BF=`(${Ya}Y)?(${Ya}M)?(${Ya}D)?`,qF=`T(${Ya}H)?(${Ya}M)?(${Ya}S)?`,zF=`P(?:${UF}|${BF}(?:${qF})?)`,WF=["weeks","years","months","days","hours","minutes","seconds"],nm=new RegExp(zF),jT=e=>e.match(nm).slice(1).reduce((r,t,n)=>(r[WF[n]]=parseFloat(t)||0,r),{}),im=(e,r)=>{const t=r?r.getTime():Date.now(),n=new Date(t);return n.setFullYear(n.getFullYear()+e.years),n.setMonth(n.getMonth()+e.months),n.setDate(n.getDate()+e.days),n.setHours(n.getHours()+e.hours),n.setMinutes(n.getMinutes()+e.minutes),n.setMilliseconds(n.getMilliseconds()+e.seconds*1e3),n.setDate(n.getDate()+e.weeks*7),n},FT=(e,r)=>{const t=r?r.getTime():Date.now(),n=new Date(t);return(im(e,n).getTime()-n.getTime())/1e3},VF={end:im,toSeconds:FT,pattern:nm,parse:jT},GF=Object.freeze(Object.defineProperty({__proto__:null,default:VF,end:im,parse:jT,pattern:nm,toSeconds:FT},Symbol.toStringTag,{value:"Module"})),HF=P0(GF);var KF=Bt,JF=Ta,YF=Fr.f,ah=KF("unscopables"),sh=Array.prototype;sh[ah]===void 0&&YF(sh,ah,{configurable:!0,value:JF(null)});var am=function(e){sh[ah][e]=!0},XF=dn,sm=am,Eb=_u,UT=pn,QF=Fr.f,ZF=rm,tc=Jl,eU=Wt,BT="Array Iterator",tU=UT.set,rU=UT.getterFor(BT),qT=ZF(Array,"Array",function(e,r){tU(this,{type:BT,target:XF(e),index:0,kind:r})},function(){var e=rU(this),r=e.target,t=e.index++;if(!r||t>=r.length)return e.target=null,tc(void 0,!0);switch(e.kind){case"keys":return tc(t,!1);case"values":return tc(r[t],!1)}return tc([t,r[t]],!1)},"values"),kb=Eb.Arguments=Eb.Array;sm("keys");sm("values");sm("entries");if(eU&&kb.name!=="values")try{QF(kb,"name",{value:"values"})}catch{}var Rb=_t,zT=QC,nU=ZC,No=qT,$b=zi,iU=di,aU=Bt,_d=aU("iterator"),wd=No.values,WT=function(e,r){if(e){if(e[_d]!==wd)try{$b(e,_d,wd)}catch{e[_d]=wd}if(iU(e,r,!0),zT[r]){for(var t in No)if(e[t]!==No[t])try{$b(e,t,No[t])}catch{e[t]=No[t]}}}};for(var Sd in zT)WT(Rb[Sd]&&Rb[Sd].prototype,Sd);WT(nU,"DOMTokenList");var sU=Ut,oU=Jt,Ib=so,Yl=function(e,r,t){var n,i;return Ib&&sU(n=r.constructor)&&n!==t&&oU(i=n.prototype)&&i!==t.prototype&&Ib(e,i),e},uU=vt,cU=uU(1 .valueOf),lU=`
9
+ \v\f\r                 \u2028\u2029\uFEFF`,fU=vt,dU=Kn,pU=wr,oh=lU,Ob=fU("".replace),hU=RegExp("^["+oh+"]+"),vU=RegExp("(^|[^"+oh+"])["+oh+"]+$"),mU=function(e){return function(r){var t=pU(dU(r));return e&1&&(t=Ob(t,hU,"")),e&2&&(t=Ob(t,vU,"$1")),t}},gU={trim:mU(3)},yU=gt,VT=B0,bU=Wt,GT=_t,HT=hC,KT=vt,_U=Ll,Pb=tr,wU=Yl,SU=qi,CU=io,JT=Ev,TU=lt,EU=is.f,kU=Bi.f,RU=Fr.f,$U=cU,IU=gU.trim,Xl="Number",Ns=GT[Xl];HT[Xl];var om=Ns.prototype,OU=GT.TypeError,PU=KT("".slice),rc=KT("".charCodeAt),AU=function(e){var r=JT(e,"number");return typeof r=="bigint"?r:MU(r)},MU=function(e){var r=JT(e,"number"),t,n,i,a,s,o,u,c;if(CU(r))throw new OU("Cannot convert a Symbol value to a number");if(typeof r=="string"&&r.length>2){if(r=IU(r),t=rc(r,0),t===43||t===45){if(n=rc(r,2),n===88||n===120)return NaN}else if(t===48){switch(rc(r,1)){case 66:case 98:i=2,a=49;break;case 79:case 111:i=8,a=55;break;default:return+r}for(s=PU(r,2),o=s.length,u=0;u<o;u++)if(c=rc(s,u),c<48||c>a)return NaN;return parseInt(s,i)}}return+r},um=_U(Xl,!Ns(" 0o1")||!Ns("0b1")||Ns("+0x1")),xU=function(e){return SU(om,e)&&TU(function(){$U(e)})},Ql=function(r){var t=arguments.length<1?0:Ns(AU(r));return xU(this)?wU(Object(t),this,Ql):t};Ql.prototype=om;um&&!VT&&(om.constructor=Ql);yU({global:!0,constructor:!0,wrap:!0,forced:um},{Number:Ql});var NU=function(e,r){for(var t=bU?EU(r):"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;t.length>n;n++)Pb(r,i=t[n])&&!Pb(e,i)&&RU(e,i,kU(r,i))};(um||VT)&&NU(HT[Xl],Ns);var LU=ar,YT=function(){var e=LU(this),r="";return e.hasIndices&&(r+="d"),e.global&&(r+="g"),e.ignoreCase&&(r+="i"),e.multiline&&(r+="m"),e.dotAll&&(r+="s"),e.unicode&&(r+="u"),e.unicodeSets&&(r+="v"),e.sticky&&(r+="y"),r},cm=lt,DU=_t,lm=DU.RegExp,fm=cm(function(){var e=lm("a","y");return e.lastIndex=2,e.exec("abcd")!==null});fm||cm(function(){return!lm("a","y").sticky});var jU=fm||cm(function(){var e=lm("^r","gy");return e.lastIndex=2,e.exec("str")!==null}),XT={BROKEN_CARET:jU,UNSUPPORTED_Y:fm},FU=lt,UU=_t,BU=UU.RegExp,qU=FU(function(){var e=BU(".","s");return!(e.dotAll&&e.test(`
10
+ `)&&e.flags==="s")}),zU=lt,WU=_t,VU=WU.RegExp,GU=zU(function(){var e=VU("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ps=Ft,Zl=vt,HU=wr,KU=YT,JU=XT,YU=ao,XU=Ta,QU=pn.get,ZU=qU,e3=GU,t3=YU("native-string-replace",String.prototype.replace),vl=RegExp.prototype.exec,uh=vl,r3=Zl("".charAt),n3=Zl("".indexOf),i3=Zl("".replace),Cd=Zl("".slice),ch=function(){var e=/a/,r=/b*/g;return Ps(vl,e,"a"),Ps(vl,r,"a"),e.lastIndex!==0||r.lastIndex!==0}(),QT=JU.BROKEN_CARET,lh=/()??/.exec("")[1]!==void 0,a3=ch||lh||QT||ZU||e3;a3&&(uh=function(r){var t=this,n=QU(t),i=HU(r),a=n.raw,s,o,u,c,l,h,v;if(a)return a.lastIndex=t.lastIndex,s=Ps(uh,a,i),t.lastIndex=a.lastIndex,s;var m=n.groups,_=QT&&t.sticky,C=Ps(KU,t),I=t.source,$=0,x=i;if(_&&(C=i3(C,"y",""),n3(C,"g")===-1&&(C+="g"),x=Cd(i,t.lastIndex),t.lastIndex>0&&(!t.multiline||t.multiline&&r3(i,t.lastIndex-1)!==`
11
+ `)&&(I="(?: "+I+")",x=" "+x,$++),o=new RegExp("^(?:"+I+")",C)),lh&&(o=new RegExp("^"+I+"$(?!\\s)",C)),ch&&(u=t.lastIndex),c=Ps(vl,_?o:t,x),_?c?(c.input=Cd(c.input,$),c[0]=Cd(c[0],$),c.index=t.lastIndex,t.lastIndex+=c[0].length):t.lastIndex=0:ch&&c&&(t.lastIndex=t.global?c.index+c[0].length:u),lh&&c&&c.length>1&&Ps(t3,c[0],o,function(){for(l=1;l<arguments.length-2;l++)arguments[l]===void 0&&(c[l]=void 0)}),c&&m)for(c.groups=h=XU(null),l=0;l<m.length;l++)v=m[l],h[v[0]]=c[v[1]];return c});var dm=uh,s3=gt,Ab=dm;s3({target:"RegExp",proto:!0,forced:/./.exec!==Ab},{exec:Ab});var Mb=Ft,xb=Ur,o3=dm,Nb=lt,ZT=Bt,u3=zi,c3=ZT("species"),Td=RegExp.prototype,ef=function(e,r,t,n){var i=ZT(e),a=!Nb(function(){var c={};return c[i]=function(){return 7},""[e](c)!==7}),s=a&&!Nb(function(){var c=!1,l=/a/;return e==="split"&&(l={},l.constructor={},l.constructor[c3]=function(){return l},l.flags="",l[i]=/./[i]),l.exec=function(){return c=!0,null},l[i](""),!c});if(!a||!s||t){var o=/./[i],u=r(i,""[e],function(c,l,h,v,m){var _=l.exec;return _===o3||_===Td.exec?a&&!m?{done:!0,value:Mb(o,l,h,v)}:{done:!0,value:Mb(c,h,l,v)}:{done:!1}});xb(String.prototype,e,u[0]),xb(Td,i,u[1])}n&&u3(Td[i],"sham",!0)},l3=tm.charAt,pm=function(e,r,t){return r+(t?l3(e,r).length:1)},hm=vt,f3=Mr,d3=Math.floor,Ed=hm("".charAt),p3=hm("".replace),kd=hm("".slice),h3=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,v3=/\$([$&'`]|\d{1,2})/g,m3=function(e,r,t,n,i,a){var s=t+e.length,o=n.length,u=v3;return i!==void 0&&(i=f3(i),u=h3),p3(a,u,function(c,l){var h;switch(Ed(l,0)){case"$":return"$";case"&":return e;case"`":return kd(r,0,t);case"'":return kd(r,s);case"<":h=i[kd(l,1,-1)];break;default:var v=+l;if(v===0)return c;if(v>o){var m=d3(v/10);return m===0?c:m<=o?n[m-1]===void 0?Ed(l,1):n[m-1]+Ed(l,1):c}h=n[v-1]}return h===void 0?"":h})},Lb=Ft,g3=ar,y3=Ut,b3=li,_3=dm,w3=TypeError,tf=function(e,r){var t=e.exec;if(y3(t)){var n=Lb(t,e,r);return n!==null&&g3(n),n}if(b3(e)==="RegExp")return Lb(_3,e,r);throw new w3("RegExp#exec called on incompatible receiver")},S3=ss,Db=Ft,rf=vt,C3=ef,T3=lt,E3=ar,k3=Ut,R3=Hn,$3=fi,I3=Wi,ys=wr,O3=Kn,P3=pm,A3=ns,M3=m3,x3=tf,N3=Bt,fh=N3("replace"),L3=Math.max,D3=Math.min,j3=rf([].concat),Rd=rf([].push),jb=rf("".indexOf),Fb=rf("".slice),F3=function(e){return e===void 0?e:String(e)},U3=function(){return"a".replace(/./,"$0")==="$0"}(),Ub=function(){return/./[fh]?/./[fh]("a","$0")==="":!1}(),B3=!T3(function(){var e=/./;return e.exec=function(){var r=[];return r.groups={a:"7"},r},"".replace(e,"$<a>")!=="7"});C3("replace",function(e,r,t){var n=Ub?"$":"$0";return[function(a,s){var o=O3(this),u=R3(a)?void 0:A3(a,fh);return u?Db(u,a,o,s):Db(r,ys(o),a,s)},function(i,a){var s=E3(this),o=ys(i);if(typeof a=="string"&&jb(a,n)===-1&&jb(a,"$<")===-1){var u=t(r,s,o,a);if(u.done)return u.value}var c=k3(a);c||(a=ys(a));var l=s.global,h;l&&(h=s.unicode,s.lastIndex=0);for(var v=[],m;m=x3(s,o),!(m===null||(Rd(v,m),!l));){var _=ys(m[0]);_===""&&(s.lastIndex=P3(o,I3(s.lastIndex),h))}for(var C="",I=0,$=0;$<v.length;$++){m=v[$];for(var x=ys(m[0]),N=L3(D3($3(m.index),o.length),0),q=[],X,J=1;J<m.length;J++)Rd(q,F3(m[J]));var G=m.groups;if(c){var L=j3([x],q,N,o);G!==void 0&&Rd(L,G),X=ys(S3(a,void 0,L))}else X=M3(x,o,N,q,G,a);N>=I&&(C+=Fb(o,I,N)+X,I=N+x.length)}return C+Fb(o,I)}]},!B3||!U3||Ub);var q3=gt,z3=vt,W3=au,V3=dn,G3=zl,H3=z3([].join),K3=W3!==Object,J3=K3||!G3("join",",");q3({target:"Array",proto:!0,forced:J3},{join:function(r){return H3(V3(this),r===void 0?",":r)}});var Rr={},Y3=Wt,X3=ou.EXISTS,eE=vt,Q3=hi,tE=Function.prototype,Z3=eE(tE.toString),rE=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,eB=eE(rE.exec),tB="name";Y3&&!X3&&Q3(tE,tB,{configurable:!0,get:function(){try{return eB(rE,Z3(this))[1]}catch{return""}}});var nE={exports:{}},iE={exports:{}};(function(e){function r(t){if(Array.isArray(t))return t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(iE);var rB=iE.exports,aE={exports:{}};(function(e){function r(t,n){var i=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(i!=null){var a,s,o,u,c=[],l=!0,h=!1;try{if(o=(i=i.call(t)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=o.call(i)).done)&&(c.push(a.value),c.length!==n);l=!0);}catch(v){h=!0,s=v}finally{try{if(!l&&i.return!=null&&(u=i.return(),Object(u)!==u))return}finally{if(h)throw s}}return c}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(aE);var nB=aE.exports,sE={exports:{}},oE={exports:{}};(function(e){function r(t,n){(n==null||n>t.length)&&(n=t.length);for(var i=0,a=Array(n);i<n;i++)a[i]=t[i];return a}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(oE);var uE=oE.exports;(function(e){var r=uE;function t(n,i){if(n){if(typeof n=="string")return r(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)?r(n,i):void 0}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(sE);var cE=sE.exports,lE={exports:{}};(function(e){function r(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
12
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(lE);var iB=lE.exports;(function(e){var r=rB,t=nB,n=cE,i=iB;function a(s,o){return r(s)||t(s,o)||n(s,o)||i()}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(nE);var uo=nE.exports,aB=gt,Bb=du,sB=Dl,oB=Jt,qb=as,uB=xr,cB=dn,lB=gu,fB=Bt,dB=mu,pB=pi,hB=dB("slice"),vB=fB("species"),$d=Array,mB=Math.max;aB({target:"Array",proto:!0,forced:!hB},{slice:function(r,t){var n=cB(this),i=uB(n),a=qb(r,i),s=qb(t===void 0?i:t,i),o,u,c;if(Bb(n)&&(o=n.constructor,sB(o)&&(o===$d||Bb(o.prototype))?o=void 0:oB(o)&&(o=o[vB],o===null&&(o=void 0)),o===$d||o===void 0))return pB(n,a,s);for(u=new(o===void 0?$d:o)(mB(s-a,0)),c=0;a<s;a++,c++)a in n&&lB(u,c,n[a]);return u.length=c,u}});var gB=gt,zb=Ft,yB=Ut,Wb=ar,bB=wr,_B=function(){var e=!1,r=/[ac]/;return r.exec=function(){return e=!0,/./.exec.apply(this,arguments)},r.test("abc")===!0&&e}(),wB=/./.test;gB({target:"RegExp",proto:!0,forced:!_B},{test:function(e){var r=Wb(this),t=bB(e),n=r.exec;if(!yB(n))return zb(wB,r,t);var i=zb(n,r,t);return i===null?!1:(Wb(i),!0)}});var SB=gt,CB=Wt,TB=_t,nc=vt,EB=tr,kB=Ut,RB=qi,$B=wr,IB=hi,OB=Ov,Ii=TB.Symbol,Fa=Ii&&Ii.prototype;if(CB&&kB(Ii)&&(!("description"in Fa)||Ii().description!==void 0)){var Vb={},ic=function(){var r=arguments.length<1||arguments[0]===void 0?void 0:$B(arguments[0]),t=RB(Fa,this)?new Ii(r):r===void 0?Ii():Ii(r);return r===""&&(Vb[t]=!0),t};OB(ic,Ii),ic.prototype=Fa,Fa.constructor=ic;var PB=String(Ii("description detection"))==="Symbol(description detection)",AB=nc(Fa.valueOf),MB=nc(Fa.toString),xB=/^Symbol\((.*)\)[^)]+$/,NB=nc("".replace),LB=nc("".slice);IB(Fa,"description",{configurable:!0,get:function(){var r=AB(this);if(EB(Vb,r))return"";var t=MB(r),n=PB?LB(t,7,-1):NB(t,xB,"$1");return n===""?void 0:n}}),SB({global:!0,constructor:!0,forced:!0},{Symbol:ic})}var DB=vC;DB("iterator");var fE={exports:{}},dE={exports:{}};(function(e){var r=uE;function t(n){if(Array.isArray(n))return r(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(dE);var jB=dE.exports,pE={exports:{}};(function(e){function r(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(pE);var FB=pE.exports,hE={exports:{}};(function(e){function r(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
13
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(hE);var UB=hE.exports;(function(e){var r=jB,t=FB,n=cE,i=UB;function a(s){return r(s)||t(s)||n(s)||i()}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(fE);var co=fE.exports,BB=gt,qB=Nl.includes,zB=lt,WB=am,VB=zB(function(){return!Array(1).includes()});BB({target:"Array",proto:!0,forced:VB},{includes:function(r){return qB(this,r,arguments.length>1?arguments[1]:void 0)}});WB("includes");var GB=Jt,HB=Math.floor,vE=Number.isInteger||function(r){return!GB(r)&&isFinite(r)&&HB(r)===r},KB=gt,JB=vE;KB({target:"Number",stat:!0},{isInteger:JB});var mE=Wt,YB=lt,gE=vt,XB=Tu,QB=fu,ZB=dn,e4=iu.f,yE=gE(e4),t4=gE([].push),r4=mE&&YB(function(){var e=Object.create(null);return e[2]=2,!yE(e,2)}),n4=function(e){return function(r){for(var t=ZB(r),n=QB(t),i=r4&&XB(t)===null,a=n.length,s=0,o=[],u;a>s;)u=n[s++],(!mE||(i?u in t:yE(t,u)))&&t4(o,e?[u,t[u]]:t[u]);return o}},i4={entries:n4(!0)},a4=gt,s4=i4.entries;a4({target:"Object",stat:!0},{entries:function(r){return s4(r)}});/*
14
14
  @license
15
15
  Copyright (c) 2021 Twilio Inc.
16
16
 
@@ -21,10 +21,10 @@ The above copyright notice and this permission notice shall be included in all c
21
21
  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.
22
22
 
23
23
 
24
- */Object.defineProperty(kr,"__esModule",{value:!0});var a4=On,s4=uo,o4=co,u4=Ea,c4=gi,l4=vi,f4=mi,d4=Pn;function Ra(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ls=Ra(a4),ji=Ra(s4),Id=Ra(o4),p4=Ra(u4),h4=Ra(c4),v4=Ra(l4),m4=Ra(f4),Vb=Ra(d4),Hi=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}},yE=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Hi(function(i){for(var a=!1,s=[],o=0,u=t;o<u.length;o++){var c=u[o];if(typeof c=="string"){a=a||Ls.default(i)===c,s.push("of type ".concat(c));continue}a=a||i instanceof c,s.push("an instance of ".concat(c.name))}return[a,s]})},g4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Hi(function(i){for(var a=!1,s=[],o=0,u=t;o<u.length;o++){var c=u[o];a=a||i===c,s.push(typeof c=="string"?'"'.concat(c,'"'):"".concat(c))}return[a,s]})};function y4(e){var r=b4();return function(){var n=Vb.default(e),i;if(r){var a=Vb.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return m4.default(this,i)}}function b4(){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 Xo(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=_4(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
25
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function _4(e,r){if(e){if(typeof e=="string")return Gb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Gb(e,r)}}function Gb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var nf=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=Xo(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=ji.default(i.value,2),s=a[0],o=a[1],u=sf(r[s],o),c=ji.default(u,4),l=c[0],h=c[1],v=c[2],m=c[3];if(!l){var _=s+1;throw new Error("Argument ".concat(_," is expected to be ").concat(v).concat(m," but got ").concat(h))}}}catch(C){n.e(C)}finally{n.f()}},bE=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(Ls.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),Ls.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=Ls.default(r)),n},w4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a){return function(s){v4.default(u,s);var o=y4(u);function u(){h4.default(this,u);for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return nf(i,l),o.call.apply(o,[this].concat(l))}return p4.default(u)}(a)}},S4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return nf(i,l),u.apply(this,l)}}},C4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];try{nf(i,l)}catch(v){return Promise.reject(v)}return u.apply(this,l)}}},vm=function(r){var t=[],n=Xo(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(af(a))}}catch(s){n.e(s)}finally{n.f()}return t},af=function(r){var t=[],n=Array.isArray(r)?r:[r],i=Xo(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(yE(s));continue}t.push(s)}}catch(o){i.e(o)}finally{i.f()}return t},sf=function(r,t){var n=[],i,a=!1,s=Xo(r),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,c=Xo(u.checks),l;try{for(c.s();!(l=c.n()).done;){var h=l.value,v=h(t),m=ji.default(v,3),_=m[0],C=m[1],I=m[2];a=a||_,!i&&I&&(i=I),C&&(n=typeof C=="string"?[].concat(Id.default(n),[C]):[].concat(Id.default(n),Id.default(C)))}}catch(q){c.e(q)}finally{c.f()}}}catch(q){s.e(q)}finally{s.f()}if(a)return[!0];var $=i||bE(t),x=n.length-1,N=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,$,N,x>1?";":","]};function T4(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=E4(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
26
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function E4(e,r){if(e){if(typeof e=="string")return Hb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Hb(e,r)}}function Hb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var k4=function(r,t){return Hi(function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(r)];var i=T4(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=ji.default(a.value,2),o=s[0],u=s[1],c=sf(af(t),u),l=ji.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid non-empty array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})},R4=Hi(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),$4=Hi(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),I4=Hi(function(e){return[Ls.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]}),O4=function(r,t){return Hi(function(n){if(Ls.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=ji.default(a[i],2),o=s[0],u=s[1],c=sf(af(u),n[o]),l=ji.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"valid ".concat(r,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(r,' (key "').concat(o,'" is ').concat(v,")")]}return[!0]})};function P4(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=A4(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
27
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function A4(e,r){if(e){if(typeof e=="string")return Kb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Kb(e,r)}}function Kb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var M4=function(r,t){return Hi(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=P4(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=ji.default(a.value,2),o=s[0],u=s[1],c=sf(af(t),u),l=ji.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})};kr.array=M4;kr.custom=Hi;kr.literal=g4;kr.nonEmptyArray=k4;kr.nonEmptyString=R4;kr.nonNegativeInteger=$4;kr.objectSchema=O4;kr.pureObject=I4;kr.runtimeTypeValidation=nf;kr.stringifyReceivedType=bE;kr.type=yE;kr.validateConstructorTypes=w4;kr.validateTypes=S4;kr.validateTypesAsync=C4;var mm={},_E={exports:{}},wE={exports:{}};(function(e){var r=Pn;function t(n,i){for(;!{}.hasOwnProperty.call(n,i)&&(n=r(n))!==null;);return n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(wE);var x4=wE.exports;(function(e){var r=x4;function t(){return e.exports=t=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,i,a){var s=r(n,i);if(s){var o=Object.getOwnPropertyDescriptor(s,i);return o.get?o.get.call(arguments.length<3?n:a):o.value}},e.exports.__esModule=!0,e.exports.default=e.exports,t.apply(null,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(_E);var gm=_E.exports;/*
24
+ */Object.defineProperty(Rr,"__esModule",{value:!0});var o4=On,u4=uo,c4=co,l4=Ea,f4=gi,d4=vi,p4=mi,h4=Pn;function Ra(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ls=Ra(o4),ji=Ra(u4),Id=Ra(c4),v4=Ra(l4),m4=Ra(f4),g4=Ra(d4),y4=Ra(p4),Gb=Ra(h4),Hi=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}},bE=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Hi(function(i){for(var a=!1,s=[],o=0,u=t;o<u.length;o++){var c=u[o];if(typeof c=="string"){a=a||Ls.default(i)===c,s.push("of type ".concat(c));continue}a=a||i instanceof c,s.push("an instance of ".concat(c.name))}return[a,s]})},b4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Hi(function(i){for(var a=!1,s=[],o=0,u=t;o<u.length;o++){var c=u[o];a=a||i===c,s.push(typeof c=="string"?'"'.concat(c,'"'):"".concat(c))}return[a,s]})};function _4(e){var r=w4();return function(){var n=Gb.default(e),i;if(r){var a=Gb.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return y4.default(this,i)}}function w4(){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 Xo(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=S4(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
25
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function S4(e,r){if(e){if(typeof e=="string")return Hb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Hb(e,r)}}function Hb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var nf=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=Xo(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=ji.default(i.value,2),s=a[0],o=a[1],u=sf(r[s],o),c=ji.default(u,4),l=c[0],h=c[1],v=c[2],m=c[3];if(!l){var _=s+1;throw new Error("Argument ".concat(_," is expected to be ").concat(v).concat(m," but got ").concat(h))}}}catch(C){n.e(C)}finally{n.f()}},_E=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(Ls.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),Ls.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=Ls.default(r)),n},C4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a){return function(s){g4.default(u,s);var o=_4(u);function u(){m4.default(this,u);for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return nf(i,l),o.call.apply(o,[this].concat(l))}return v4.default(u)}(a)}},T4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return nf(i,l),u.apply(this,l)}}},E4=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=vm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];try{nf(i,l)}catch(v){return Promise.reject(v)}return u.apply(this,l)}}},vm=function(r){var t=[],n=Xo(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(af(a))}}catch(s){n.e(s)}finally{n.f()}return t},af=function(r){var t=[],n=Array.isArray(r)?r:[r],i=Xo(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(bE(s));continue}t.push(s)}}catch(o){i.e(o)}finally{i.f()}return t},sf=function(r,t){var n=[],i,a=!1,s=Xo(r),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,c=Xo(u.checks),l;try{for(c.s();!(l=c.n()).done;){var h=l.value,v=h(t),m=ji.default(v,3),_=m[0],C=m[1],I=m[2];a=a||_,!i&&I&&(i=I),C&&(n=typeof C=="string"?[].concat(Id.default(n),[C]):[].concat(Id.default(n),Id.default(C)))}}catch(q){c.e(q)}finally{c.f()}}}catch(q){s.e(q)}finally{s.f()}if(a)return[!0];var $=i||_E(t),x=n.length-1,N=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,$,N,x>1?";":","]};function k4(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=R4(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
26
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function R4(e,r){if(e){if(typeof e=="string")return Kb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Kb(e,r)}}function Kb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var $4=function(r,t){return Hi(function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(r)];var i=k4(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=ji.default(a.value,2),o=s[0],u=s[1],c=sf(af(t),u),l=ji.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid non-empty array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})},I4=Hi(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),O4=Hi(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),P4=Hi(function(e){return[Ls.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]}),A4=function(r,t){return Hi(function(n){if(Ls.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=ji.default(a[i],2),o=s[0],u=s[1],c=sf(af(u),n[o]),l=ji.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"valid ".concat(r,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(r,' (key "').concat(o,'" is ').concat(v,")")]}return[!0]})};function M4(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=x4(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
27
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function x4(e,r){if(e){if(typeof e=="string")return Jb(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Jb(e,r)}}function Jb(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var N4=function(r,t){return Hi(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=M4(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=ji.default(a.value,2),o=s[0],u=s[1],c=sf(af(t),u),l=ji.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})};Rr.array=N4;Rr.custom=Hi;Rr.literal=b4;Rr.nonEmptyArray=$4;Rr.nonEmptyString=I4;Rr.nonNegativeInteger=O4;Rr.objectSchema=A4;Rr.pureObject=P4;Rr.runtimeTypeValidation=nf;Rr.stringifyReceivedType=_E;Rr.type=bE;Rr.validateConstructorTypes=C4;Rr.validateTypes=T4;Rr.validateTypesAsync=E4;var mm={},wE={exports:{}},SE={exports:{}};(function(e){var r=Pn;function t(n,i){for(;!{}.hasOwnProperty.call(n,i)&&(n=r(n))!==null;);return n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(SE);var L4=SE.exports;(function(e){var r=L4;function t(){return e.exports=t=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,i,a){var s=r(n,i);if(s){var o=Object.getOwnPropertyDescriptor(s,i);return o.get?o.get.call(arguments.length<3?n:a):o.value}},e.exports.__esModule=!0,e.exports.default=e.exports,t.apply(null,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(wE);var gm=wE.exports;/*
28
28
  @license
29
29
  Copyright (c) 2021 Twilio Inc.
30
30
 
@@ -34,7 +34,7 @@ The above copyright notice and this permission notice shall be included in all c
34
34
 
35
35
  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.
36
36
 
37
- */Object.defineProperty(mm,"__esModule",{value:!0});var N4=co,L4=gi,D4=Ea,j4=os,F4=gm,U4=vi,B4=mi,q4=Pn,z4=us;function Ki(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Jb=Ki(N4),W4=Ki(L4),V4=Ki(D4),G4=Ki(j4),Ua=Ki(F4),H4=Ki(U4),K4=Ki(B4),Oi=Ki(q4),J4=Ki(z4),Y4;function ma(){}ma.prototype=Object.create(null);function zt(){zt.init.call(this)}zt.EventEmitter=zt;zt.usingDomains=!1;zt.prototype.domain=void 0;zt.prototype._events=void 0;zt.prototype._maxListeners=void 0;zt.defaultMaxListeners=10;zt.init=function(){this.domain=null,zt.usingDomains&&Y4.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ma,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};zt.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function SE(e){return e._maxListeners===void 0?zt.defaultMaxListeners:e._maxListeners}zt.prototype.getMaxListeners=function(){return SE(this)};function X4(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Eu(e,n),a=0;a<n;++a)i[a].call(t)}function Q4(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Eu(e,i),s=0;s<i;++s)a[s].call(t,n)}function Z4(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Eu(e,a),o=0;o<a;++o)s[o].call(t,n,i)}function eq(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,o=Eu(e,s),u=0;u<s;++u)o[u].call(t,n,i,a)}function tq(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Eu(e,i),s=0;s<i;++s)a[s].apply(t,n)}zt.prototype.emit=function(r){var t,n,i,a,s,o,u,c=r==="error";if(o=this._events,o)c=c&&o.error==null;else if(!c)return!1;if(u=this.domain,c){if(t=arguments[1],u)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=u,t.domainThrown=!1,u.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=o[r],!n)return!1;var h=typeof n=="function";switch(i=arguments.length,i){case 1:X4(n,h,this);break;case 2:Q4(n,h,this,arguments[1]);break;case 3:Z4(n,h,this,arguments[1],arguments[2]);break;case 4:eq(n,h,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];tq(n,h,this,a)}return!0};function CE(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new ma,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=SE(e),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=r,o.count=s.length,rq(o)}return e}function rq(e){typeof console.warn=="function"?console.warn(e):console.log(e)}zt.prototype.addListener=function(r,t){return CE(this,r,t,!1)};zt.prototype.on=zt.prototype.addListener;zt.prototype.prependListener=function(r,t){return CE(this,r,t,!0)};function TE(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}zt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,TE(this,r,t)),this};zt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,TE(this,r,t)),this};zt.prototype.removeListener=function(r,t){var n,i,a,s,o;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new ma:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){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 ma,this;delete i[r]}else nq(n,a);i.removeListener&&this.emit("removeListener",r,o||t)}return this};zt.prototype.off=function(e,r){return this.removeListener(e,r)};zt.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ma,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new ma:delete n[r]),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 ma,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};zt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=iq(t):n=[]):n=[],n};zt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):EE.call(e,r)};zt.prototype.listenerCount=EE;function EE(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}zt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function nq(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function Eu(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function iq(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function aq(e){var r=sq();return function(){var n=Oi.default(e),i;if(r){var a=Oi.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return K4.default(this,i)}}function sq(){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 oq=function(e){H4.default(t,e);var r=aq(t);function t(){var n;return W4.default(this,t),n=r.call(this),J4.default(G4.default(n),"eventHistory",new Map),n}return V4.default(t,[{key:"on",value:function(i,a){return Ua.default(Oi.default(t.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return Ua.default(Oi.default(t.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return Ua.default(Oi.default(t.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=Ua.default(Oi.default(t.prototype),"emit",this)).call.apply(a,[this,i].concat(o))}},{key:"addListener",value:function(i,a){return Ua.default(Oi.default(t.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return Ua.default(Oi.default(t.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,Jb.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,Jb.default(s)),this):Ua.default(Oi.default(t.prototype),"once",this).call(this,i,a)}}]),t}(zt);mm.ReplayEventEmitter=oq;var ml={exports:{}};ml.exports;(function(e,r){var t=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,o="[object Arguments]",u="[object Array]",c="[object AsyncFunction]",l="[object Boolean]",h="[object Date]",v="[object Error]",m="[object Function]",_="[object GeneratorFunction]",C="[object Map]",I="[object Number]",$="[object Null]",x="[object Object]",N="[object Promise]",q="[object Proxy]",X="[object RegExp]",J="[object Set]",G="[object String]",L="[object Symbol]",te="[object Undefined]",se="[object WeakMap]",ne="[object ArrayBuffer]",ge="[object DataView]",Y="[object Float32Array]",Ue="[object Float64Array]",He="[object Int8Array]",Rt="[object Int16Array]",ft="[object Int32Array]",Pe="[object Uint8Array]",he="[object Uint8ClampedArray]",pe="[object Uint16Array]",M="[object Uint32Array]",Oe=/[\\^$.*+?()[\]{}|]/g,Je=/^\[object .+?Constructor\]$/,De=/^(?:0|[1-9]\d*)$/,we={};we[Y]=we[Ue]=we[He]=we[Rt]=we[ft]=we[Pe]=we[he]=we[pe]=we[M]=!0,we[o]=we[u]=we[ne]=we[l]=we[ge]=we[h]=we[v]=we[m]=we[C]=we[I]=we[x]=we[X]=we[J]=we[G]=we[se]=!1;var Q=typeof Ae=="object"&&Ae&&Ae.Object===Object&&Ae,$t=typeof self=="object"&&self&&self.Object===Object&&self,_e=Q||$t||Function("return this")(),le=r&&!r.nodeType&&r,St=le&&!0&&e&&!e.nodeType&&e,Le=St&&St.exports===le,Gt=Le&&Q.process,pt=function(){try{return Gt&&Gt.binding&&Gt.binding("util")}catch{}}(),ke=pt&&pt.isTypedArray;function ot(z,re){for(var be=-1,Ge=z==null?0:z.length,Dt=0,ht=[];++be<Ge;){var jt=z[be];re(jt,be,z)&&(ht[Dt++]=jt)}return ht}function bt(z,re){for(var be=-1,Ge=re.length,Dt=z.length;++be<Ge;)z[Dt+be]=re[be];return z}function $e(z,re){for(var be=-1,Ge=z==null?0:z.length;++be<Ge;)if(re(z[be],be,z))return!0;return!1}function Kt(z,re){for(var be=-1,Ge=Array(z);++be<z;)Ge[be]=re(be);return Ge}function dt(z){return function(re){return z(re)}}function qt(z,re){return z.has(re)}function rr(z,re){return z==null?void 0:z[re]}function Fe(z){var re=-1,be=Array(z.size);return z.forEach(function(Ge,Dt){be[++re]=[Dt,Ge]}),be}function Ar(z,re){return function(be){return z(re(be))}}function Rr(z){var re=-1,be=Array(z.size);return z.forEach(function(Ge){be[++re]=Ge}),be}var Ct=Array.prototype,Pt=Function.prototype,yt=Object.prototype,it=_e["__core-js_shared__"],Mt=Pt.toString,It=yt.hasOwnProperty,sr=function(){var z=/[^.]+$/.exec(it&&it.keys&&it.keys.IE_PROTO||"");return z?"Symbol(src)_1."+z:""}(),Nr=yt.toString,tn=RegExp("^"+Mt.call(It).replace(Oe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rn=Le?_e.Buffer:void 0,Qt=_e.Symbol,lr=_e.Uint8Array,ve=yt.propertyIsEnumerable,ye=Ct.splice,ae=Qt?Qt.toStringTag:void 0,de=Object.getOwnPropertySymbols,oe=rn?rn.isBuffer:void 0,me=Ar(Object.keys,Object),Se=dr(_e,"DataView"),Z=dr(_e,"Map"),ce=dr(_e,"Promise"),H=dr(_e,"Set"),ie=dr(_e,"WeakMap"),K=dr(Object,"create"),xe=k(Se),Ce=k(Z),We=k(ce),Be=k(H),Ve=k(ie),Ye=Qt?Qt.prototype:void 0,Qe=Ye?Ye.valueOf:void 0;function Ke(z){var re=-1,be=z==null?0:z.length;for(this.clear();++re<be;){var Ge=z[re];this.set(Ge[0],Ge[1])}}function Xe(){this.__data__=K?K(null):{},this.size=0}function Ze(z){var re=this.has(z)&&delete this.__data__[z];return this.size-=re?1:0,re}function at(z){var re=this.__data__;if(K){var be=re[z];return be===n?void 0:be}return It.call(re,z)?re[z]:void 0}function yr(z){var re=this.__data__;return K?re[z]!==void 0:It.call(re,z)}function or(z,re){var be=this.__data__;return this.size+=this.has(z)?0:1,be[z]=K&&re===void 0?n:re,this}Ke.prototype.clear=Xe,Ke.prototype.delete=Ze,Ke.prototype.get=at,Ke.prototype.has=yr,Ke.prototype.set=or;function st(z){var re=-1,be=z==null?0:z.length;for(this.clear();++re<be;){var Ge=z[re];this.set(Ge[0],Ge[1])}}function Wr(){this.__data__=[],this.size=0}function mn(z){var re=this.__data__,be=Yt(re,z);if(be<0)return!1;var Ge=re.length-1;return be==Ge?re.pop():ye.call(re,be,1),--this.size,!0}function bi(z){var re=this.__data__,be=Yt(re,z);return be<0?void 0:re[be][1]}function Vr(z){return Yt(this.__data__,z)>-1}function Xn(z,re){var be=this.__data__,Ge=Yt(be,z);return Ge<0?(++this.size,be.push([z,re])):be[Ge][1]=re,this}st.prototype.clear=Wr,st.prototype.delete=mn,st.prototype.get=bi,st.prototype.has=Vr,st.prototype.set=Xn;function Gr(z){var re=-1,be=z==null?0:z.length;for(this.clear();++re<be;){var Ge=z[re];this.set(Ge[0],Ge[1])}}function gn(){this.size=0,this.__data__={hash:new Ke,map:new(Z||st),string:new Ke}}function _i(z){var re=Nn(this,z).delete(z);return this.size-=re?1:0,re}function ur(z){return Nn(this,z).get(z)}function xn(z){return Nn(this,z).has(z)}function Zi(z,re){var be=Nn(this,z),Ge=be.size;return be.set(z,re),this.size+=be.size==Ge?0:1,this}Gr.prototype.clear=gn,Gr.prototype.delete=_i,Gr.prototype.get=ur,Gr.prototype.has=xn,Gr.prototype.set=Zi;function nn(z){var re=-1,be=z==null?0:z.length;for(this.__data__=new Gr;++re<be;)this.add(z[re])}function ea(z){return this.__data__.set(z,n),this}function wi(z){return this.__data__.has(z)}nn.prototype.add=nn.prototype.push=ea,nn.prototype.has=wi;function Hr(z){var re=this.__data__=new st(z);this.size=re.size}function ta(){this.__data__=new st,this.size=0}function Aa(z){var re=this.__data__,be=re.delete(z);return this.size=re.size,be}function Ma(z){return this.__data__.get(z)}function fr(z){return this.__data__.has(z)}function xa(z,re){var be=this.__data__;if(be instanceof st){var Ge=be.__data__;if(!Z||Ge.length<t-1)return Ge.push([z,re]),this.size=++be.size,this;be=this.__data__=new Gr(Ge)}return be.set(z,re),this.size=be.size,this}Hr.prototype.clear=ta,Hr.prototype.delete=Aa,Hr.prototype.get=Ma,Hr.prototype.has=fr,Hr.prototype.set=xa;function Qn(z,re){var be=A(z),Ge=!be&&U(z),Dt=!be&&!Ge&&ue(z),ht=!be&&!Ge&&!Dt&&nr(z),jt=be||Ge||Dt||ht,Xt=jt?Kt(z.length,String):[],ir=Xt.length;for(var rt in z)It.call(z,rt)&&!(jt&&(rt=="length"||Dt&&(rt=="offset"||rt=="parent")||ht&&(rt=="buffer"||rt=="byteLength"||rt=="byteOffset")||on(rt,ir)))&&Xt.push(rt);return Xt}function Yt(z,re){for(var be=z.length;be--;)if(E(z[be][0],re))return be;return-1}function Na(z,re,be){var Ge=re(z);return A(z)?Ge:bt(Ge,be(z))}function an(z){return z==null?z===void 0?te:$:ae&&ae in Object(z)?ia(z):R(z)}function Si(z){return Kr(z)&&an(z)==o}function Ci(z,re,be,Ge,Dt){return z===re?!0:z==null||re==null||!Kr(z)&&!Kr(re)?z!==z&&re!==re:La(z,re,be,Ge,Ci,Dt)}function La(z,re,be,Ge,Dt,ht){var jt=A(z),Xt=A(re),ir=jt?u:$r(z),rt=Xt?u:$r(re);ir=ir==o?x:ir,rt=rt==o?x:rt;var Sr=ir==x,Cr=rt==x,Zt=ir==rt;if(Zt&&ue(z)){if(!ue(re))return!1;jt=!0,Sr=!1}if(Zt&&!Sr)return ht||(ht=new Hr),jt||nr(z)?na(z,re,be,Ge,Dt,ht):Ti(z,re,ir,be,Ge,Dt,ht);if(!(be&i)){var Tr=Sr&&It.call(z,"__wrapped__"),ct=Cr&&It.call(re,"__wrapped__");if(Tr||ct){var yn=Tr?z.value():z,O=ct?re.value():re;return ht||(ht=new Hr),Dt(yn,O,be,Ge,ht)}}return Zt?(ht||(ht=new Hr),Ei(z,re,be,Ge,Dt,ht)):!1}function sn(z){if(!hr(z)||D(z))return!1;var re=Ne(z)?tn:Je;return re.test(k(z))}function wt(z){return Kr(z)&&et(z.length)&&!!we[an(z)]}function ra(z){if(!B(z))return me(z);var re=[];for(var be in Object(z))It.call(z,be)&&be!="constructor"&&re.push(be);return re}function na(z,re,be,Ge,Dt,ht){var jt=be&i,Xt=z.length,ir=re.length;if(Xt!=ir&&!(jt&&ir>Xt))return!1;var rt=ht.get(z);if(rt&&ht.get(re))return rt==re;var Sr=-1,Cr=!0,Zt=be&a?new nn:void 0;for(ht.set(z,re),ht.set(re,z);++Sr<Xt;){var Tr=z[Sr],ct=re[Sr];if(Ge)var yn=jt?Ge(ct,Tr,Sr,re,z,ht):Ge(Tr,ct,Sr,z,re,ht);if(yn!==void 0){if(yn)continue;Cr=!1;break}if(Zt){if(!$e(re,function(O,P){if(!qt(Zt,P)&&(Tr===O||Dt(Tr,O,be,Ge,ht)))return Zt.push(P)})){Cr=!1;break}}else if(!(Tr===ct||Dt(Tr,ct,be,Ge,ht))){Cr=!1;break}}return ht.delete(z),ht.delete(re),Cr}function Ti(z,re,be,Ge,Dt,ht,jt){switch(be){case ge:if(z.byteLength!=re.byteLength||z.byteOffset!=re.byteOffset)return!1;z=z.buffer,re=re.buffer;case ne:return!(z.byteLength!=re.byteLength||!ht(new lr(z),new lr(re)));case l:case h:case I:return E(+z,+re);case v:return z.name==re.name&&z.message==re.message;case X:case G:return z==re+"";case C:var Xt=Fe;case J:var ir=Ge&i;if(Xt||(Xt=Rr),z.size!=re.size&&!ir)return!1;var rt=jt.get(z);if(rt)return rt==re;Ge|=a,jt.set(z,re);var Sr=na(Xt(z),Xt(re),Ge,Dt,ht,jt);return jt.delete(z),Sr;case L:if(Qe)return Qe.call(z)==Qe.call(re)}return!1}function Ei(z,re,be,Ge,Dt,ht){var jt=be&i,Xt=Zn(z),ir=Xt.length,rt=Zn(re),Sr=rt.length;if(ir!=Sr&&!jt)return!1;for(var Cr=ir;Cr--;){var Zt=Xt[Cr];if(!(jt?Zt in re:It.call(re,Zt)))return!1}var Tr=ht.get(z);if(Tr&&ht.get(re))return Tr==re;var ct=!0;ht.set(z,re),ht.set(re,z);for(var yn=jt;++Cr<ir;){Zt=Xt[Cr];var O=z[Zt],P=re[Zt];if(Ge)var f=jt?Ge(P,O,Zt,re,z,ht):Ge(O,P,Zt,z,re,ht);if(!(f===void 0?O===P||Dt(O,P,be,Ge,ht):f)){ct=!1;break}yn||(yn=Zt=="constructor")}if(ct&&!yn){var d=z.constructor,p=re.constructor;d!=p&&"constructor"in z&&"constructor"in re&&!(typeof d=="function"&&d instanceof d&&typeof p=="function"&&p instanceof p)&&(ct=!1)}return ht.delete(z),ht.delete(re),ct}function Zn(z){return Na(z,un,pr)}function Nn(z,re){var be=z.__data__;return aa(re)?be[typeof re=="string"?"string":"hash"]:be.map}function dr(z,re){var be=rr(z,re);return sn(be)?be:void 0}function ia(z){var re=It.call(z,ae),be=z[ae];try{z[ae]=void 0;var Ge=!0}catch{}var Dt=Nr.call(z);return Ge&&(re?z[ae]=be:delete z[ae]),Dt}var pr=de?function(z){return z==null?[]:(z=Object(z),ot(de(z),function(re){return ve.call(z,re)}))}:vs,$r=an;(Se&&$r(new Se(new ArrayBuffer(1)))!=ge||Z&&$r(new Z)!=C||ce&&$r(ce.resolve())!=N||H&&$r(new H)!=J||ie&&$r(new ie)!=se)&&($r=function(z){var re=an(z),be=re==x?z.constructor:void 0,Ge=be?k(be):"";if(Ge)switch(Ge){case xe:return ge;case Ce:return C;case We:return N;case Be:return J;case Ve:return se}return re});function on(z,re){return re=re??s,!!re&&(typeof z=="number"||De.test(z))&&z>-1&&z%1==0&&z<re}function aa(z){var re=typeof z;return re=="string"||re=="number"||re=="symbol"||re=="boolean"?z!=="__proto__":z===null}function D(z){return!!sr&&sr in z}function B(z){var re=z&&z.constructor,be=typeof re=="function"&&re.prototype||yt;return z===be}function R(z){return Nr.call(z)}function k(z){if(z!=null){try{return Mt.call(z)}catch{}try{return z+""}catch{}}return""}function E(z,re){return z===re||z!==z&&re!==re}var U=Si(function(){return arguments}())?Si:function(z){return Kr(z)&&It.call(z,"callee")&&!ve.call(z,"callee")},A=Array.isArray;function fe(z){return z!=null&&et(z.length)&&!Ne(z)}var ue=oe||mo;function Te(z,re){return Ci(z,re)}function Ne(z){if(!hr(z))return!1;var re=an(z);return re==m||re==_||re==c||re==q}function et(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=s}function hr(z){var re=typeof z;return z!=null&&(re=="object"||re=="function")}function Kr(z){return z!=null&&typeof z=="object"}var nr=ke?dt(ke):wt;function un(z){return fe(z)?Qn(z):ra(z)}function vs(){return[]}function mo(){return!1}e.exports=Te})(ml,ml.exports);var uq=ml.exports,kE={exports:{}},cq=lt,lq=cq(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),fq=lt,dq=Jt,pq=li,Yb=lq,Zc=Object.isExtensible,hq=fq(function(){Zc(1)}),vq=hq||Yb?function(r){return!dq(r)||Yb&&pq(r)==="ArrayBuffer"?!1:Zc?Zc(r):!0}:Zc,mq=lt,RE=!mq(function(){return Object.isExtensible(Object.preventExtensions({}))}),gq=gt,yq=vt,bq=uu,_q=Jt,ym=tr,wq=Fr.f,Xb=is,Sq=Lv,bm=vq,Cq=su,Tq=RE,$E=!1,Fi=Cq("meta"),Eq=0,_m=function(e){wq(e,Fi,{value:{objectID:"O"+Eq++,weakData:{}}})},kq=function(e,r){if(!_q(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!ym(e,Fi)){if(!bm(e))return"F";if(!r)return"E";_m(e)}return e[Fi].objectID},Rq=function(e,r){if(!ym(e,Fi)){if(!bm(e))return!0;if(!r)return!1;_m(e)}return e[Fi].weakData},$q=function(e){return Tq&&$E&&bm(e)&&!ym(e,Fi)&&_m(e),e},Iq=function(){Oq.enable=function(){},$E=!0;var e=Xb.f,r=yq([].splice),t={};t[Fi]=1,e(t).length&&(Xb.f=function(n){for(var i=e(n),a=0,s=i.length;a<s;a++)if(i[a]===Fi){r(i,a,1);break}return i},gq({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Sq.f}))},Oq=kE.exports={enable:Iq,fastKey:kq,getWeakData:Rq,onFreeze:$q};bq[Fi]=!0;var of=kE.exports,Pq=gt,Aq=_t,Mq=vt,Qb=Ll,xq=Ur,Nq=of,Lq=Su,Dq=ka,jq=Ut,Fq=Hn,Od=Jt,Pd=lt,Uq=Kl,Bq=di,qq=Yl,wm=function(e,r,t){var n=e.indexOf("Map")!==-1,i=e.indexOf("Weak")!==-1,a=n?"set":"add",s=Aq[e],o=s&&s.prototype,u=s,c={},l=function($){var x=Mq(o[$]);xq(o,$,$==="add"?function(q){return x(this,q===0?0:q),this}:$==="delete"?function(N){return i&&!Od(N)?!1:x(this,N===0?0:N)}:$==="get"?function(q){return i&&!Od(q)?void 0:x(this,q===0?0:q)}:$==="has"?function(q){return i&&!Od(q)?!1:x(this,q===0?0:q)}:function(q,X){return x(this,q===0?0:q,X),this})},h=Qb(e,!jq(s)||!(i||o.forEach&&!Pd(function(){new s().entries().next()})));if(h)u=t.getConstructor(r,e,n,a),Nq.enable();else if(Qb(e,!0)){var v=new u,m=v[a](i?{}:-0,1)!==v,_=Pd(function(){v.has(1)}),C=Uq(function($){new s($)}),I=!i&&Pd(function(){for(var $=new s,x=5;x--;)$[a](x,x);return!$.has(-0)});C||(u=r(function($,x){Dq($,o);var N=qq(new s,$,u);return Fq(x)||Lq(x,N[a],{that:N,AS_ENTRIES:n}),N}),u.prototype=o,o.constructor=u),(_||I)&&(l("delete"),l("has"),n&&l("get")),(I||m)&&l(a),i&&o.clear&&delete o.clear}return c[e]=u,Pq({global:!0,constructor:!0,forced:u!==s},c),Bq(u,e),i||t.setStrong(u,e,n),u},zq=Ur,uf=function(e,r,t){for(var n in r)zq(e,n,r[n],t);return e},Zb=Ta,Wq=hi,e_=uf,Vq=Gi,Gq=ka,Hq=Hn,Kq=Su,Jq=rm,ac=Jl,Yq=Wl,Co=Wt,t_=of.fastKey,IE=pn,r_=IE.set,Ad=IE.getterFor,OE={getConstructor:function(e,r,t,n){var i=e(function(c,l){Gq(c,a),r_(c,{type:r,index:Zb(null),first:null,last:null,size:0}),Co||(c.size=0),Hq(l)||Kq(l,c[n],{that:c,AS_ENTRIES:t})}),a=i.prototype,s=Ad(r),o=function(c,l,h){var v=s(c),m=u(c,l),_,C;return m?m.value=h:(v.last=m={index:C=t_(l,!0),key:l,value:h,previous:_=v.last,next:null,removed:!1},v.first||(v.first=m),_&&(_.next=m),Co?v.size++:c.size++,C!=="F"&&(v.index[C]=m)),c},u=function(c,l){var h=s(c),v=t_(l),m;if(v!=="F")return h.index[v];for(m=h.first;m;m=m.next)if(m.key===l)return m};return e_(a,{clear:function(){for(var l=this,h=s(l),v=h.first;v;)v.removed=!0,v.previous&&(v.previous=v.previous.next=null),v=v.next;h.first=h.last=null,h.index=Zb(null),Co?h.size=0:l.size=0},delete:function(c){var l=this,h=s(l),v=u(l,c);if(v){var m=v.next,_=v.previous;delete h.index[v.index],v.removed=!0,_&&(_.next=m),m&&(m.previous=_),h.first===v&&(h.first=m),h.last===v&&(h.last=_),Co?h.size--:l.size--}return!!v},forEach:function(l){for(var h=s(this),v=Vq(l,arguments.length>1?arguments[1]:void 0),m;m=m?m.next:h.first;)for(v(m.value,m.key,this);m&&m.removed;)m=m.previous},has:function(l){return!!u(this,l)}}),e_(a,t?{get:function(l){var h=u(this,l);return h&&h.value},set:function(l,h){return o(this,l===0?0:l,h)}}:{add:function(l){return o(this,l=l===0?0:l,l)}}),Co&&Wq(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(e,r,t){var n=r+" Iterator",i=Ad(r),a=Ad(n);Jq(e,r,function(s,o){r_(this,{type:n,target:s,state:i(s),kind:o,last:null})},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=null,ac(void 0,!0)):ac(o==="keys"?u.key:o==="values"?u.value:[u.key,u.value],!1)},t?"entries":"values",!t,!0),Yq(r)}},Xq=wm,Qq=OE;Xq("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Qq);var Ji={};/*
37
+ */Object.defineProperty(mm,"__esModule",{value:!0});var D4=co,j4=gi,F4=Ea,U4=os,B4=gm,q4=vi,z4=mi,W4=Pn,V4=us;function Ki(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Yb=Ki(D4),G4=Ki(j4),H4=Ki(F4),K4=Ki(U4),Ua=Ki(B4),J4=Ki(q4),Y4=Ki(z4),Oi=Ki(W4),X4=Ki(V4),Q4;function ma(){}ma.prototype=Object.create(null);function zt(){zt.init.call(this)}zt.EventEmitter=zt;zt.usingDomains=!1;zt.prototype.domain=void 0;zt.prototype._events=void 0;zt.prototype._maxListeners=void 0;zt.defaultMaxListeners=10;zt.init=function(){this.domain=null,zt.usingDomains&&Q4.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ma,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};zt.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function CE(e){return e._maxListeners===void 0?zt.defaultMaxListeners:e._maxListeners}zt.prototype.getMaxListeners=function(){return CE(this)};function Z4(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Eu(e,n),a=0;a<n;++a)i[a].call(t)}function eq(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Eu(e,i),s=0;s<i;++s)a[s].call(t,n)}function tq(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Eu(e,a),o=0;o<a;++o)s[o].call(t,n,i)}function rq(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,o=Eu(e,s),u=0;u<s;++u)o[u].call(t,n,i,a)}function nq(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Eu(e,i),s=0;s<i;++s)a[s].apply(t,n)}zt.prototype.emit=function(r){var t,n,i,a,s,o,u,c=r==="error";if(o=this._events,o)c=c&&o.error==null;else if(!c)return!1;if(u=this.domain,c){if(t=arguments[1],u)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=u,t.domainThrown=!1,u.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=o[r],!n)return!1;var h=typeof n=="function";switch(i=arguments.length,i){case 1:Z4(n,h,this);break;case 2:eq(n,h,this,arguments[1]);break;case 3:tq(n,h,this,arguments[1],arguments[2]);break;case 4:rq(n,h,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];nq(n,h,this,a)}return!0};function TE(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new ma,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=CE(e),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=r,o.count=s.length,iq(o)}return e}function iq(e){typeof console.warn=="function"?console.warn(e):console.log(e)}zt.prototype.addListener=function(r,t){return TE(this,r,t,!1)};zt.prototype.on=zt.prototype.addListener;zt.prototype.prependListener=function(r,t){return TE(this,r,t,!0)};function EE(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}zt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,EE(this,r,t)),this};zt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,EE(this,r,t)),this};zt.prototype.removeListener=function(r,t){var n,i,a,s,o;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new ma:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){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 ma,this;delete i[r]}else aq(n,a);i.removeListener&&this.emit("removeListener",r,o||t)}return this};zt.prototype.off=function(e,r){return this.removeListener(e,r)};zt.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ma,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new ma:delete n[r]),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 ma,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};zt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=sq(t):n=[]):n=[],n};zt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):kE.call(e,r)};zt.prototype.listenerCount=kE;function kE(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}zt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function aq(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function Eu(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function sq(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function oq(e){var r=uq();return function(){var n=Oi.default(e),i;if(r){var a=Oi.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Y4.default(this,i)}}function uq(){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 cq=function(e){J4.default(t,e);var r=oq(t);function t(){var n;return G4.default(this,t),n=r.call(this),X4.default(K4.default(n),"eventHistory",new Map),n}return H4.default(t,[{key:"on",value:function(i,a){return Ua.default(Oi.default(t.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return Ua.default(Oi.default(t.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return Ua.default(Oi.default(t.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=Ua.default(Oi.default(t.prototype),"emit",this)).call.apply(a,[this,i].concat(o))}},{key:"addListener",value:function(i,a){return Ua.default(Oi.default(t.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return Ua.default(Oi.default(t.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,Yb.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,Yb.default(s)),this):Ua.default(Oi.default(t.prototype),"once",this).call(this,i,a)}}]),t}(zt);mm.ReplayEventEmitter=cq;var ml={exports:{}};ml.exports;(function(e,r){var t=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,o="[object Arguments]",u="[object Array]",c="[object AsyncFunction]",l="[object Boolean]",h="[object Date]",v="[object Error]",m="[object Function]",_="[object GeneratorFunction]",C="[object Map]",I="[object Number]",$="[object Null]",x="[object Object]",N="[object Promise]",q="[object Proxy]",X="[object RegExp]",J="[object Set]",G="[object String]",L="[object Symbol]",te="[object Undefined]",se="[object WeakMap]",ne="[object ArrayBuffer]",ge="[object DataView]",Y="[object Float32Array]",Ue="[object Float64Array]",He="[object Int8Array]",Rt="[object Int16Array]",ft="[object Int32Array]",Pe="[object Uint8Array]",he="[object Uint8ClampedArray]",pe="[object Uint16Array]",M="[object Uint32Array]",Oe=/[\\^$.*+?()[\]{}|]/g,Je=/^\[object .+?Constructor\]$/,De=/^(?:0|[1-9]\d*)$/,we={};we[Y]=we[Ue]=we[He]=we[Rt]=we[ft]=we[Pe]=we[he]=we[pe]=we[M]=!0,we[o]=we[u]=we[ne]=we[l]=we[ge]=we[h]=we[v]=we[m]=we[C]=we[I]=we[x]=we[X]=we[J]=we[G]=we[se]=!1;var Q=typeof Ae=="object"&&Ae&&Ae.Object===Object&&Ae,$t=typeof self=="object"&&self&&self.Object===Object&&self,_e=Q||$t||Function("return this")(),le=r&&!r.nodeType&&r,St=le&&!0&&e&&!e.nodeType&&e,Le=St&&St.exports===le,Gt=Le&&Q.process,pt=function(){try{return Gt&&Gt.binding&&Gt.binding("util")}catch{}}(),ke=pt&&pt.isTypedArray;function ot(z,re){for(var be=-1,Ge=z==null?0:z.length,Dt=0,ht=[];++be<Ge;){var jt=z[be];re(jt,be,z)&&(ht[Dt++]=jt)}return ht}function bt(z,re){for(var be=-1,Ge=re.length,Dt=z.length;++be<Ge;)z[Dt+be]=re[be];return z}function $e(z,re){for(var be=-1,Ge=z==null?0:z.length;++be<Ge;)if(re(z[be],be,z))return!0;return!1}function Kt(z,re){for(var be=-1,Ge=Array(z);++be<z;)Ge[be]=re(be);return Ge}function dt(z){return function(re){return z(re)}}function qt(z,re){return z.has(re)}function rr(z,re){return z==null?void 0:z[re]}function Fe(z){var re=-1,be=Array(z.size);return z.forEach(function(Ge,Dt){be[++re]=[Dt,Ge]}),be}function Ar(z,re){return function(be){return z(re(be))}}function $r(z){var re=-1,be=Array(z.size);return z.forEach(function(Ge){be[++re]=Ge}),be}var Ct=Array.prototype,Pt=Function.prototype,yt=Object.prototype,it=_e["__core-js_shared__"],Mt=Pt.toString,It=yt.hasOwnProperty,sr=function(){var z=/[^.]+$/.exec(it&&it.keys&&it.keys.IE_PROTO||"");return z?"Symbol(src)_1."+z:""}(),Nr=yt.toString,tn=RegExp("^"+Mt.call(It).replace(Oe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rn=Le?_e.Buffer:void 0,Qt=_e.Symbol,lr=_e.Uint8Array,ve=yt.propertyIsEnumerable,ye=Ct.splice,ae=Qt?Qt.toStringTag:void 0,de=Object.getOwnPropertySymbols,oe=rn?rn.isBuffer:void 0,me=Ar(Object.keys,Object),Se=dr(_e,"DataView"),Z=dr(_e,"Map"),ce=dr(_e,"Promise"),H=dr(_e,"Set"),ie=dr(_e,"WeakMap"),K=dr(Object,"create"),xe=k(Se),Ce=k(Z),We=k(ce),Be=k(H),Ve=k(ie),Ye=Qt?Qt.prototype:void 0,Qe=Ye?Ye.valueOf:void 0;function Ke(z){var re=-1,be=z==null?0:z.length;for(this.clear();++re<be;){var Ge=z[re];this.set(Ge[0],Ge[1])}}function Xe(){this.__data__=K?K(null):{},this.size=0}function Ze(z){var re=this.has(z)&&delete this.__data__[z];return this.size-=re?1:0,re}function at(z){var re=this.__data__;if(K){var be=re[z];return be===n?void 0:be}return It.call(re,z)?re[z]:void 0}function yr(z){var re=this.__data__;return K?re[z]!==void 0:It.call(re,z)}function or(z,re){var be=this.__data__;return this.size+=this.has(z)?0:1,be[z]=K&&re===void 0?n:re,this}Ke.prototype.clear=Xe,Ke.prototype.delete=Ze,Ke.prototype.get=at,Ke.prototype.has=yr,Ke.prototype.set=or;function st(z){var re=-1,be=z==null?0:z.length;for(this.clear();++re<be;){var Ge=z[re];this.set(Ge[0],Ge[1])}}function Wr(){this.__data__=[],this.size=0}function mn(z){var re=this.__data__,be=Yt(re,z);if(be<0)return!1;var Ge=re.length-1;return be==Ge?re.pop():ye.call(re,be,1),--this.size,!0}function bi(z){var re=this.__data__,be=Yt(re,z);return be<0?void 0:re[be][1]}function Vr(z){return Yt(this.__data__,z)>-1}function Xn(z,re){var be=this.__data__,Ge=Yt(be,z);return Ge<0?(++this.size,be.push([z,re])):be[Ge][1]=re,this}st.prototype.clear=Wr,st.prototype.delete=mn,st.prototype.get=bi,st.prototype.has=Vr,st.prototype.set=Xn;function Gr(z){var re=-1,be=z==null?0:z.length;for(this.clear();++re<be;){var Ge=z[re];this.set(Ge[0],Ge[1])}}function gn(){this.size=0,this.__data__={hash:new Ke,map:new(Z||st),string:new Ke}}function _i(z){var re=Nn(this,z).delete(z);return this.size-=re?1:0,re}function ur(z){return Nn(this,z).get(z)}function xn(z){return Nn(this,z).has(z)}function Zi(z,re){var be=Nn(this,z),Ge=be.size;return be.set(z,re),this.size+=be.size==Ge?0:1,this}Gr.prototype.clear=gn,Gr.prototype.delete=_i,Gr.prototype.get=ur,Gr.prototype.has=xn,Gr.prototype.set=Zi;function nn(z){var re=-1,be=z==null?0:z.length;for(this.__data__=new Gr;++re<be;)this.add(z[re])}function ea(z){return this.__data__.set(z,n),this}function wi(z){return this.__data__.has(z)}nn.prototype.add=nn.prototype.push=ea,nn.prototype.has=wi;function Hr(z){var re=this.__data__=new st(z);this.size=re.size}function ta(){this.__data__=new st,this.size=0}function Aa(z){var re=this.__data__,be=re.delete(z);return this.size=re.size,be}function Ma(z){return this.__data__.get(z)}function fr(z){return this.__data__.has(z)}function xa(z,re){var be=this.__data__;if(be instanceof st){var Ge=be.__data__;if(!Z||Ge.length<t-1)return Ge.push([z,re]),this.size=++be.size,this;be=this.__data__=new Gr(Ge)}return be.set(z,re),this.size=be.size,this}Hr.prototype.clear=ta,Hr.prototype.delete=Aa,Hr.prototype.get=Ma,Hr.prototype.has=fr,Hr.prototype.set=xa;function Qn(z,re){var be=A(z),Ge=!be&&U(z),Dt=!be&&!Ge&&ue(z),ht=!be&&!Ge&&!Dt&&nr(z),jt=be||Ge||Dt||ht,Xt=jt?Kt(z.length,String):[],ir=Xt.length;for(var rt in z)It.call(z,rt)&&!(jt&&(rt=="length"||Dt&&(rt=="offset"||rt=="parent")||ht&&(rt=="buffer"||rt=="byteLength"||rt=="byteOffset")||on(rt,ir)))&&Xt.push(rt);return Xt}function Yt(z,re){for(var be=z.length;be--;)if(E(z[be][0],re))return be;return-1}function Na(z,re,be){var Ge=re(z);return A(z)?Ge:bt(Ge,be(z))}function an(z){return z==null?z===void 0?te:$:ae&&ae in Object(z)?ia(z):R(z)}function Si(z){return Kr(z)&&an(z)==o}function Ci(z,re,be,Ge,Dt){return z===re?!0:z==null||re==null||!Kr(z)&&!Kr(re)?z!==z&&re!==re:La(z,re,be,Ge,Ci,Dt)}function La(z,re,be,Ge,Dt,ht){var jt=A(z),Xt=A(re),ir=jt?u:Ir(z),rt=Xt?u:Ir(re);ir=ir==o?x:ir,rt=rt==o?x:rt;var Sr=ir==x,Cr=rt==x,Zt=ir==rt;if(Zt&&ue(z)){if(!ue(re))return!1;jt=!0,Sr=!1}if(Zt&&!Sr)return ht||(ht=new Hr),jt||nr(z)?na(z,re,be,Ge,Dt,ht):Ti(z,re,ir,be,Ge,Dt,ht);if(!(be&i)){var Tr=Sr&&It.call(z,"__wrapped__"),ct=Cr&&It.call(re,"__wrapped__");if(Tr||ct){var yn=Tr?z.value():z,O=ct?re.value():re;return ht||(ht=new Hr),Dt(yn,O,be,Ge,ht)}}return Zt?(ht||(ht=new Hr),Ei(z,re,be,Ge,Dt,ht)):!1}function sn(z){if(!hr(z)||D(z))return!1;var re=Ne(z)?tn:Je;return re.test(k(z))}function wt(z){return Kr(z)&&et(z.length)&&!!we[an(z)]}function ra(z){if(!B(z))return me(z);var re=[];for(var be in Object(z))It.call(z,be)&&be!="constructor"&&re.push(be);return re}function na(z,re,be,Ge,Dt,ht){var jt=be&i,Xt=z.length,ir=re.length;if(Xt!=ir&&!(jt&&ir>Xt))return!1;var rt=ht.get(z);if(rt&&ht.get(re))return rt==re;var Sr=-1,Cr=!0,Zt=be&a?new nn:void 0;for(ht.set(z,re),ht.set(re,z);++Sr<Xt;){var Tr=z[Sr],ct=re[Sr];if(Ge)var yn=jt?Ge(ct,Tr,Sr,re,z,ht):Ge(Tr,ct,Sr,z,re,ht);if(yn!==void 0){if(yn)continue;Cr=!1;break}if(Zt){if(!$e(re,function(O,P){if(!qt(Zt,P)&&(Tr===O||Dt(Tr,O,be,Ge,ht)))return Zt.push(P)})){Cr=!1;break}}else if(!(Tr===ct||Dt(Tr,ct,be,Ge,ht))){Cr=!1;break}}return ht.delete(z),ht.delete(re),Cr}function Ti(z,re,be,Ge,Dt,ht,jt){switch(be){case ge:if(z.byteLength!=re.byteLength||z.byteOffset!=re.byteOffset)return!1;z=z.buffer,re=re.buffer;case ne:return!(z.byteLength!=re.byteLength||!ht(new lr(z),new lr(re)));case l:case h:case I:return E(+z,+re);case v:return z.name==re.name&&z.message==re.message;case X:case G:return z==re+"";case C:var Xt=Fe;case J:var ir=Ge&i;if(Xt||(Xt=$r),z.size!=re.size&&!ir)return!1;var rt=jt.get(z);if(rt)return rt==re;Ge|=a,jt.set(z,re);var Sr=na(Xt(z),Xt(re),Ge,Dt,ht,jt);return jt.delete(z),Sr;case L:if(Qe)return Qe.call(z)==Qe.call(re)}return!1}function Ei(z,re,be,Ge,Dt,ht){var jt=be&i,Xt=Zn(z),ir=Xt.length,rt=Zn(re),Sr=rt.length;if(ir!=Sr&&!jt)return!1;for(var Cr=ir;Cr--;){var Zt=Xt[Cr];if(!(jt?Zt in re:It.call(re,Zt)))return!1}var Tr=ht.get(z);if(Tr&&ht.get(re))return Tr==re;var ct=!0;ht.set(z,re),ht.set(re,z);for(var yn=jt;++Cr<ir;){Zt=Xt[Cr];var O=z[Zt],P=re[Zt];if(Ge)var f=jt?Ge(P,O,Zt,re,z,ht):Ge(O,P,Zt,z,re,ht);if(!(f===void 0?O===P||Dt(O,P,be,Ge,ht):f)){ct=!1;break}yn||(yn=Zt=="constructor")}if(ct&&!yn){var d=z.constructor,p=re.constructor;d!=p&&"constructor"in z&&"constructor"in re&&!(typeof d=="function"&&d instanceof d&&typeof p=="function"&&p instanceof p)&&(ct=!1)}return ht.delete(z),ht.delete(re),ct}function Zn(z){return Na(z,un,pr)}function Nn(z,re){var be=z.__data__;return aa(re)?be[typeof re=="string"?"string":"hash"]:be.map}function dr(z,re){var be=rr(z,re);return sn(be)?be:void 0}function ia(z){var re=It.call(z,ae),be=z[ae];try{z[ae]=void 0;var Ge=!0}catch{}var Dt=Nr.call(z);return Ge&&(re?z[ae]=be:delete z[ae]),Dt}var pr=de?function(z){return z==null?[]:(z=Object(z),ot(de(z),function(re){return ve.call(z,re)}))}:vs,Ir=an;(Se&&Ir(new Se(new ArrayBuffer(1)))!=ge||Z&&Ir(new Z)!=C||ce&&Ir(ce.resolve())!=N||H&&Ir(new H)!=J||ie&&Ir(new ie)!=se)&&(Ir=function(z){var re=an(z),be=re==x?z.constructor:void 0,Ge=be?k(be):"";if(Ge)switch(Ge){case xe:return ge;case Ce:return C;case We:return N;case Be:return J;case Ve:return se}return re});function on(z,re){return re=re??s,!!re&&(typeof z=="number"||De.test(z))&&z>-1&&z%1==0&&z<re}function aa(z){var re=typeof z;return re=="string"||re=="number"||re=="symbol"||re=="boolean"?z!=="__proto__":z===null}function D(z){return!!sr&&sr in z}function B(z){var re=z&&z.constructor,be=typeof re=="function"&&re.prototype||yt;return z===be}function R(z){return Nr.call(z)}function k(z){if(z!=null){try{return Mt.call(z)}catch{}try{return z+""}catch{}}return""}function E(z,re){return z===re||z!==z&&re!==re}var U=Si(function(){return arguments}())?Si:function(z){return Kr(z)&&It.call(z,"callee")&&!ve.call(z,"callee")},A=Array.isArray;function fe(z){return z!=null&&et(z.length)&&!Ne(z)}var ue=oe||mo;function Te(z,re){return Ci(z,re)}function Ne(z){if(!hr(z))return!1;var re=an(z);return re==m||re==_||re==c||re==q}function et(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=s}function hr(z){var re=typeof z;return z!=null&&(re=="object"||re=="function")}function Kr(z){return z!=null&&typeof z=="object"}var nr=ke?dt(ke):wt;function un(z){return fe(z)?Qn(z):ra(z)}function vs(){return[]}function mo(){return!1}e.exports=Te})(ml,ml.exports);var lq=ml.exports,RE={exports:{}},fq=lt,dq=fq(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),pq=lt,hq=Jt,vq=li,Xb=dq,Zc=Object.isExtensible,mq=pq(function(){Zc(1)}),gq=mq||Xb?function(r){return!hq(r)||Xb&&vq(r)==="ArrayBuffer"?!1:Zc?Zc(r):!0}:Zc,yq=lt,$E=!yq(function(){return Object.isExtensible(Object.preventExtensions({}))}),bq=gt,_q=vt,wq=uu,Sq=Jt,ym=tr,Cq=Fr.f,Qb=is,Tq=Lv,bm=gq,Eq=su,kq=$E,IE=!1,Fi=Eq("meta"),Rq=0,_m=function(e){Cq(e,Fi,{value:{objectID:"O"+Rq++,weakData:{}}})},$q=function(e,r){if(!Sq(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!ym(e,Fi)){if(!bm(e))return"F";if(!r)return"E";_m(e)}return e[Fi].objectID},Iq=function(e,r){if(!ym(e,Fi)){if(!bm(e))return!0;if(!r)return!1;_m(e)}return e[Fi].weakData},Oq=function(e){return kq&&IE&&bm(e)&&!ym(e,Fi)&&_m(e),e},Pq=function(){Aq.enable=function(){},IE=!0;var e=Qb.f,r=_q([].splice),t={};t[Fi]=1,e(t).length&&(Qb.f=function(n){for(var i=e(n),a=0,s=i.length;a<s;a++)if(i[a]===Fi){r(i,a,1);break}return i},bq({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Tq.f}))},Aq=RE.exports={enable:Pq,fastKey:$q,getWeakData:Iq,onFreeze:Oq};wq[Fi]=!0;var of=RE.exports,Mq=gt,xq=_t,Nq=vt,Zb=Ll,Lq=Ur,Dq=of,jq=Su,Fq=ka,Uq=Ut,Bq=Hn,Od=Jt,Pd=lt,qq=Kl,zq=di,Wq=Yl,wm=function(e,r,t){var n=e.indexOf("Map")!==-1,i=e.indexOf("Weak")!==-1,a=n?"set":"add",s=xq[e],o=s&&s.prototype,u=s,c={},l=function($){var x=Nq(o[$]);Lq(o,$,$==="add"?function(q){return x(this,q===0?0:q),this}:$==="delete"?function(N){return i&&!Od(N)?!1:x(this,N===0?0:N)}:$==="get"?function(q){return i&&!Od(q)?void 0:x(this,q===0?0:q)}:$==="has"?function(q){return i&&!Od(q)?!1:x(this,q===0?0:q)}:function(q,X){return x(this,q===0?0:q,X),this})},h=Zb(e,!Uq(s)||!(i||o.forEach&&!Pd(function(){new s().entries().next()})));if(h)u=t.getConstructor(r,e,n,a),Dq.enable();else if(Zb(e,!0)){var v=new u,m=v[a](i?{}:-0,1)!==v,_=Pd(function(){v.has(1)}),C=qq(function($){new s($)}),I=!i&&Pd(function(){for(var $=new s,x=5;x--;)$[a](x,x);return!$.has(-0)});C||(u=r(function($,x){Fq($,o);var N=Wq(new s,$,u);return Bq(x)||jq(x,N[a],{that:N,AS_ENTRIES:n}),N}),u.prototype=o,o.constructor=u),(_||I)&&(l("delete"),l("has"),n&&l("get")),(I||m)&&l(a),i&&o.clear&&delete o.clear}return c[e]=u,Mq({global:!0,constructor:!0,forced:u!==s},c),zq(u,e),i||t.setStrong(u,e,n),u},Vq=Ur,uf=function(e,r,t){for(var n in r)Vq(e,n,r[n],t);return e},e_=Ta,Gq=hi,t_=uf,Hq=Gi,Kq=ka,Jq=Hn,Yq=Su,Xq=rm,ac=Jl,Qq=Wl,Co=Wt,r_=of.fastKey,OE=pn,n_=OE.set,Ad=OE.getterFor,PE={getConstructor:function(e,r,t,n){var i=e(function(c,l){Kq(c,a),n_(c,{type:r,index:e_(null),first:null,last:null,size:0}),Co||(c.size=0),Jq(l)||Yq(l,c[n],{that:c,AS_ENTRIES:t})}),a=i.prototype,s=Ad(r),o=function(c,l,h){var v=s(c),m=u(c,l),_,C;return m?m.value=h:(v.last=m={index:C=r_(l,!0),key:l,value:h,previous:_=v.last,next:null,removed:!1},v.first||(v.first=m),_&&(_.next=m),Co?v.size++:c.size++,C!=="F"&&(v.index[C]=m)),c},u=function(c,l){var h=s(c),v=r_(l),m;if(v!=="F")return h.index[v];for(m=h.first;m;m=m.next)if(m.key===l)return m};return t_(a,{clear:function(){for(var l=this,h=s(l),v=h.first;v;)v.removed=!0,v.previous&&(v.previous=v.previous.next=null),v=v.next;h.first=h.last=null,h.index=e_(null),Co?h.size=0:l.size=0},delete:function(c){var l=this,h=s(l),v=u(l,c);if(v){var m=v.next,_=v.previous;delete h.index[v.index],v.removed=!0,_&&(_.next=m),m&&(m.previous=_),h.first===v&&(h.first=m),h.last===v&&(h.last=_),Co?h.size--:l.size--}return!!v},forEach:function(l){for(var h=s(this),v=Hq(l,arguments.length>1?arguments[1]:void 0),m;m=m?m.next:h.first;)for(v(m.value,m.key,this);m&&m.removed;)m=m.previous},has:function(l){return!!u(this,l)}}),t_(a,t?{get:function(l){var h=u(this,l);return h&&h.value},set:function(l,h){return o(this,l===0?0:l,h)}}:{add:function(l){return o(this,l=l===0?0:l,l)}}),Co&&Gq(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(e,r,t){var n=r+" Iterator",i=Ad(r),a=Ad(n);Xq(e,r,function(s,o){n_(this,{type:n,target:s,state:i(s),kind:o,last:null})},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=null,ac(void 0,!0)):ac(o==="keys"?u.key:o==="values"?u.value:[u.key,u.value],!1)},t?"entries":"values",!t,!0),Qq(r)}},Zq=wm,e6=PE;Zq("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},e6);var Ji={};/*
38
38
  @license
39
39
  Copyright (c) 2016, Twilio, Inc.
40
40
 
@@ -50,7 +50,7 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
50
50
  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
51
51
  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52
52
 
53
- */Object.defineProperty(Ji,"__esModule",{value:!0});var Zq=gi,e6=Ea,t6=os,r6=vi,n6=mi,i6=Pn,a6=us;function cs(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Sm=cs(Zq),Cm=cs(e6),Ai=cs(t6),Tm=cs(r6),PE=cs(n6),gl=cs(i6),Mi=cs(a6),s6;function ga(){}ga.prototype=Object.create(null);function Nt(){Nt.init.call(this)}Nt.EventEmitter=Nt;Nt.usingDomains=!1;Nt.prototype.domain=void 0;Nt.prototype._events=void 0;Nt.prototype._maxListeners=void 0;Nt.defaultMaxListeners=10;Nt.init=function(){this.domain=null,Nt.usingDomains&&s6.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ga,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Nt.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function AE(e){return e._maxListeners===void 0?Nt.defaultMaxListeners:e._maxListeners}Nt.prototype.getMaxListeners=function(){return AE(this)};function o6(e,r,t){if(r)e.call(t);else for(var n=e.length,i=ku(e,n),a=0;a<n;++a)i[a].call(t)}function u6(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=ku(e,i),s=0;s<i;++s)a[s].call(t,n)}function c6(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=ku(e,a),o=0;o<a;++o)s[o].call(t,n,i)}function l6(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,o=ku(e,s),u=0;u<s;++u)o[u].call(t,n,i,a)}function f6(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=ku(e,i),s=0;s<i;++s)a[s].apply(t,n)}Nt.prototype.emit=function(r){var t,n,i,a,s,o,u,c=r==="error";if(o=this._events,o)c=c&&o.error==null;else if(!c)return!1;if(u=this.domain,c){if(t=arguments[1],u)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=u,t.domainThrown=!1,u.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=o[r],!n)return!1;var h=typeof n=="function";switch(i=arguments.length,i){case 1:o6(n,h,this);break;case 2:u6(n,h,this,arguments[1]);break;case 3:c6(n,h,this,arguments[1],arguments[2]);break;case 4:l6(n,h,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];f6(n,h,this,a)}return!0};function ME(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new ga,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=AE(e),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=r,o.count=s.length,d6(o)}return e}function d6(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Nt.prototype.addListener=function(r,t){return ME(this,r,t,!1)};Nt.prototype.on=Nt.prototype.addListener;Nt.prototype.prependListener=function(r,t){return ME(this,r,t,!0)};function xE(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Nt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,xE(this,r,t)),this};Nt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,xE(this,r,t)),this};Nt.prototype.removeListener=function(r,t){var n,i,a,s,o;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new ga:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){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 ga,this;delete i[r]}else p6(n,a);i.removeListener&&this.emit("removeListener",r,o||t)}return this};Nt.prototype.off=function(e,r){return this.removeListener(e,r)};Nt.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ga,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new ga:delete n[r]),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 ga,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};Nt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=h6(t):n=[]):n=[],n};Nt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):NE.call(e,r)};Nt.prototype.listenerCount=NE;function NE(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Nt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function p6(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function ku(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function h6(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function LE(e){var r=v6();return function(){var n=gl.default(e),i;if(r){var a=gl.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return PE.default(this,i)}}function v6(){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 DE=function(e){Tm.default(t,e);var r=LE(t);function t(n){var i;return Sm.default(this,t),i=r.call(this),Mi.default(Ai.default(i),"timeout",null),Mi.default(Ai.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 Cm.default(t,[{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)}}]),t}(Nt),m6=function(e){Tm.default(t,e);var r=LE(t);function t(n){var i;return Sm.default(this,t),i=r.call(this),Mi.default(Ai.default(i),"resolve",function(){}),Mi.default(Ai.default(i),"reject",function(){}),i.retrier=new DE(n),i}return Cm.default(t,[{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()}}]),t}(Nt);function g6(e){var r=y6();return function(){var n=gl.default(e),i;if(r){var a=gl.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return PE.default(this,i)}}function y6(){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 sc(e){return e!=null}var b6=function(e){Tm.default(t,e);var r=g6(t);function t(n){var i;Sm.default(this,t),i=r.call(this),Mi.default(Ai.default(i),"backoffDelay",0),Mi.default(Ai.default(i),"nextBackoffDelay",0),Mi.default(Ai.default(i),"backoffNumber",0),Mi.default(Ai.default(i),"timeoutID",null),Mi.default(Ai.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,o=a.maxDelay,u=a.randomisationFactor,c=a.factor;if(sc(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(sc(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(sc(u)&&(u<0||u>1))throw new Error("The randomisation factor must be between 0 and 1.");if(sc(c)&&c<=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=c||2,i.reset(),i}return Cm.default(t,[{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 t(i)}}]),t}(Nt);Ji.AsyncRetrier=m6;Ji.Backoff=b6;Ji.Retrier=DE;var cf={},_6=Ft,w6=tr,S6=qi,C6=JT,n_=RegExp.prototype,T6=function(e){var r=e.flags;return r===void 0&&!("flags"in n_)&&!w6(e,"flags")&&S6(n_,e)?_6(C6,e):r},E6=ou.PROPER,k6=Ur,R6=ar,i_=wr,$6=lt,I6=T6,Em="toString",jE=RegExp.prototype,FE=jE[Em],O6=$6(function(){return FE.call({source:"a",flags:"b"})!=="/a/b"}),P6=E6&&FE.name!==Em;(O6||P6)&&k6(jE,Em,function(){var r=R6(this),t=i_(r.source),n=i_(I6(r));return"/"+t+"/"+n},{unsafe:!0});var Br={};/*
53
+ */Object.defineProperty(Ji,"__esModule",{value:!0});var t6=gi,r6=Ea,n6=os,i6=vi,a6=mi,s6=Pn,o6=us;function cs(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Sm=cs(t6),Cm=cs(r6),Ai=cs(n6),Tm=cs(i6),AE=cs(a6),gl=cs(s6),Mi=cs(o6),u6;function ga(){}ga.prototype=Object.create(null);function Nt(){Nt.init.call(this)}Nt.EventEmitter=Nt;Nt.usingDomains=!1;Nt.prototype.domain=void 0;Nt.prototype._events=void 0;Nt.prototype._maxListeners=void 0;Nt.defaultMaxListeners=10;Nt.init=function(){this.domain=null,Nt.usingDomains&&u6.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ga,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Nt.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function ME(e){return e._maxListeners===void 0?Nt.defaultMaxListeners:e._maxListeners}Nt.prototype.getMaxListeners=function(){return ME(this)};function c6(e,r,t){if(r)e.call(t);else for(var n=e.length,i=ku(e,n),a=0;a<n;++a)i[a].call(t)}function l6(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=ku(e,i),s=0;s<i;++s)a[s].call(t,n)}function f6(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=ku(e,a),o=0;o<a;++o)s[o].call(t,n,i)}function d6(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,o=ku(e,s),u=0;u<s;++u)o[u].call(t,n,i,a)}function p6(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=ku(e,i),s=0;s<i;++s)a[s].apply(t,n)}Nt.prototype.emit=function(r){var t,n,i,a,s,o,u,c=r==="error";if(o=this._events,o)c=c&&o.error==null;else if(!c)return!1;if(u=this.domain,c){if(t=arguments[1],u)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=u,t.domainThrown=!1,u.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=o[r],!n)return!1;var h=typeof n=="function";switch(i=arguments.length,i){case 1:c6(n,h,this);break;case 2:l6(n,h,this,arguments[1]);break;case 3:f6(n,h,this,arguments[1],arguments[2]);break;case 4:d6(n,h,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];p6(n,h,this,a)}return!0};function xE(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new ga,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=ME(e),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=r,o.count=s.length,h6(o)}return e}function h6(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Nt.prototype.addListener=function(r,t){return xE(this,r,t,!1)};Nt.prototype.on=Nt.prototype.addListener;Nt.prototype.prependListener=function(r,t){return xE(this,r,t,!0)};function NE(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Nt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,NE(this,r,t)),this};Nt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,NE(this,r,t)),this};Nt.prototype.removeListener=function(r,t){var n,i,a,s,o;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new ga:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){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 ga,this;delete i[r]}else v6(n,a);i.removeListener&&this.emit("removeListener",r,o||t)}return this};Nt.prototype.off=function(e,r){return this.removeListener(e,r)};Nt.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ga,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new ga:delete n[r]),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 ga,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};Nt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=m6(t):n=[]):n=[],n};Nt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):LE.call(e,r)};Nt.prototype.listenerCount=LE;function LE(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Nt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function v6(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function ku(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function m6(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}function DE(e){var r=g6();return function(){var n=gl.default(e),i;if(r){var a=gl.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return AE.default(this,i)}}function g6(){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(e){Tm.default(t,e);var r=DE(t);function t(n){var i;return Sm.default(this,t),i=r.call(this),Mi.default(Ai.default(i),"timeout",null),Mi.default(Ai.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 Cm.default(t,[{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)}}]),t}(Nt),y6=function(e){Tm.default(t,e);var r=DE(t);function t(n){var i;return Sm.default(this,t),i=r.call(this),Mi.default(Ai.default(i),"resolve",function(){}),Mi.default(Ai.default(i),"reject",function(){}),i.retrier=new jE(n),i}return Cm.default(t,[{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()}}]),t}(Nt);function b6(e){var r=_6();return function(){var n=gl.default(e),i;if(r){var a=gl.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return AE.default(this,i)}}function _6(){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 sc(e){return e!=null}var w6=function(e){Tm.default(t,e);var r=b6(t);function t(n){var i;Sm.default(this,t),i=r.call(this),Mi.default(Ai.default(i),"backoffDelay",0),Mi.default(Ai.default(i),"nextBackoffDelay",0),Mi.default(Ai.default(i),"backoffNumber",0),Mi.default(Ai.default(i),"timeoutID",null),Mi.default(Ai.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,o=a.maxDelay,u=a.randomisationFactor,c=a.factor;if(sc(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(sc(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(sc(u)&&(u<0||u>1))throw new Error("The randomisation factor must be between 0 and 1.");if(sc(c)&&c<=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=c||2,i.reset(),i}return Cm.default(t,[{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 t(i)}}]),t}(Nt);Ji.AsyncRetrier=y6;Ji.Backoff=w6;Ji.Retrier=jE;var cf={},S6=Ft,C6=tr,T6=qi,E6=YT,i_=RegExp.prototype,k6=function(e){var r=e.flags;return r===void 0&&!("flags"in i_)&&!C6(e,"flags")&&T6(i_,e)?S6(E6,e):r},R6=ou.PROPER,$6=Ur,I6=ar,a_=wr,O6=lt,P6=k6,Em="toString",FE=RegExp.prototype,UE=FE[Em],A6=O6(function(){return UE.call({source:"a",flags:"b"})!=="/a/b"}),M6=R6&&UE.name!==Em;(A6||M6)&&$6(FE,Em,function(){var r=I6(this),t=a_(r.source),n=a_(P6(r));return"/"+t+"/"+n},{unsafe:!0});var Br={};/*
54
54
  @license
55
55
  Copyright (c) 2021 Twilio Inc.
56
56
 
@@ -61,16 +61,16 @@ The above copyright notice and this permission notice shall be included in all c
61
61
  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.
62
62
 
63
63
 
64
- */Object.defineProperty(Br,"__esModule",{value:!0});var A6=On,M6=uo,x6=co,N6=gi,L6=vi,D6=mi,j6=Pn;function ls(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ds=ls(A6),Qa=ls(M6),Md=ls(x6),F6=ls(N6),U6=ls(L6),B6=ls(D6),a_=ls(j6),$a=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function q6(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=z6(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
65
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function z6(e,r){if(e){if(typeof e=="string")return s_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return s_(e,r)}}function s_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var UE=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return $a(function(i){var a=!1,s=[],o=q6(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;if(typeof c=="string"){a=a||Ds.default(i)===c,s.push("of type ".concat(c));continue}a=a||i instanceof c,s.push("an instance of ".concat(c.name))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})};function W6(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=V6(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
66
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function V6(e,r){if(e){if(typeof e=="string")return o_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o_(e,r)}}function o_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var G6=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return $a(function(i){var a=!1,s=[],o=W6(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;a=a||i===c,s.push(typeof c=="string"?'"'.concat(c,'"'):"".concat(c))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})},H6=$a(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),K6=$a(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),J6=$a(function(e){return[Ds.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function Y6(e){var r=X6();return function(){var n=a_.default(e),i;if(r){var a=a_.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return B6.default(this,i)}}function X6(){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 Qo(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=Q6(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
67
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function Q6(e,r){if(e){if(typeof e=="string")return u_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u_(e,r)}}function u_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var lf=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=Qo(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Qa.default(i.value,2),s=a[0],o=a[1],u=$m(r[s],o),c=Qa.default(u,4),l=c[0],h=c[1],v=c[2],m=c[3];if(!l){var _=s+1;throw new Error("Argument ".concat(_," is expected to be ").concat(v).concat(m," but got ").concat(h))}}}catch(C){n.e(C)}finally{n.f()}},BE=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(Ds.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),Ds.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=Ds.default(r)),n},Z6=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=km(t);return function(a){return function(s){U6.default(u,s);var o=Y6(u);function u(){F6.default(this,u);for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return lf(i,l),o.call.apply(o,[this].concat(l))}return u}(a)}},ez=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=km(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return lf(i,l),u.apply(this,l)}}},tz=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=km(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];try{lf(i,l)}catch(v){return Promise.reject(v)}return u.apply(this,l)}}},km=function(r){var t=[],n=Qo(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Rm(a))}}catch(s){n.e(s)}finally{n.f()}return t},Rm=function(r){var t=[],n=Array.isArray(r)?r:[r],i=Qo(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(UE(s));continue}t.push(s)}}catch(o){i.e(o)}finally{i.f()}return t},$m=function(r,t){var n=[],i,a=!1,s=Qo(r),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,c=Qo(u.checks),l;try{for(c.s();!(l=c.n()).done;){var h=l.value,v=h(t),m=Qa.default(v,3),_=m[0],C=m[1],I=m[2];a=a||_,!i&&I&&(i=I),C&&(n=typeof C=="string"?[].concat(Md.default(n),[C]):[].concat(Md.default(n),Md.default(C)))}}catch(q){c.e(q)}finally{c.f()}}}catch(q){s.e(q)}finally{s.f()}if(a)return[!0];var $=i||BE(t),x=n.length-1,N=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,$,N,x>1?";":","]},rz=function(r,t){return $a(function(n){if(Ds.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=Qa.default(a[i],2),o=s[0],u=s[1],c=$m(Rm(u),n[o]),l=Qa.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"valid ".concat(r,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(r,' (key "').concat(o,'" is ').concat(v,")")]}return[!0]})};function nz(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=iz(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
68
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function iz(e,r){if(e){if(typeof e=="string")return c_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c_(e,r)}}function c_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var az=function(r,t){return $a(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=nz(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Qa.default(a.value,2),o=s[0],u=s[1],c=$m(Rm(t),u),l=Qa.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})};Br.array=az;Br.custom=$a;Br.literal=G6;Br.nonEmptyString=H6;Br.nonNegativeInteger=K6;Br.objectSchema=rz;Br.pureObject=J6;Br.runtimeTypeValidation=lf;Br.stringifyReceivedType=BE;Br.type=UE;Br.validateConstructorTypes=Z6;Br.validateTypes=ez;Br.validateTypesAsync=tz;var sz=wm,oz=OE;sz("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},oz);var qE={exports:{}};(function(e,r){(function(n,i){e.exports=i()})(Ae,function(){return function(t){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return t[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,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(t,n,i){t.exports=function(a,s){var o,u,c;for(o=1;o<arguments.length;o++){u=arguments[o];for(c in u)u.hasOwnProperty(c)&&(a[c]=u[c])}return a}},function(t,n,i){var a=i(0);t.exports={build:function(s,o){var u,c,l,h=o.plugins;for(u=0,c=h.length;u<c;u++)l=h[u],l.methods&&a(s,l.methods),l.properties&&Object.defineProperties(s,l.properties)},hook:function(s,o,u){var c,l,h,v,m=s.config.plugins,_=[s.context];for(u&&(_=_.concat(u)),c=0,l=m.length;c<l;c++)v=m[c],h=m[c][o],h&&h.apply(v,_)}}},function(t,n,i){function a(s){if(s.length===0)return s;var o,u,c=s.split(/[_-]/);if(c.length===1&&c[0][0].toLowerCase()===c[0][0])return s;for(u=c[0].toLowerCase(),o=1;o<c.length;o++)u=u+c[o].charAt(0).toUpperCase()+c[o].substring(1).toLowerCase();return u}a.prepended=function(s,o){return o=a(o),s+o[0].toUpperCase()+o.substring(1)},t.exports=a},function(t,n,i){var a=i(0),s=i(2);function o(u,c){u=u||{},this.options=u,this.defaults=c.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,c.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 c=u.name,l=u.from,h=u.to;return this.addState(l),typeof h!="function"&&this.addState(h),this.addTransition(c),this.map[l][c]=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,c){u=u||[];var l,h,v;for(l=0,h=u.length;l<h;l++)v=u[l],typeof v=="function"&&(u[l]=v=v()),v.configure&&v.configure(this);return u},configureTransitions:function(u){var c,l,h,v,m,_=this.defaults.wildcard;for(l=0;l<u.length;l++)for(h=u[l],v=Array.isArray(h.from)?h.from:[h.from||_],m=h.to||_,c=0;c<v.length;c++)this.mapTransition({name:h.name,from:v[c],to:m})},transitionFor:function(u,c){var l=this.defaults.wildcard;return this.map[u][c]||this.map[l][c]},transitionsFor:function(u){var c=this.defaults.wildcard;return Object.keys(this.map[u]).concat(Object.keys(this.map[c]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),t.exports=o},function(t,n,i){var a=i(0),s=i(6),o=i(1),u=[null,[]];function c(l,h){this.context=l,this.config=h,this.state=h.init.from,this.observers=[l]}a(c.prototype,{init:function(l){if(a(this.context,this.config.data.apply(this.context,l)),o.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(l){return Array.isArray(l)?l.indexOf(this.state)>=0:this.state===l},isPending:function(){return this.pending},can:function(l){return!this.isPending()&&!!this.seek(l)},cannot:function(l){return!this.can(l)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(l,h){var v=this.config.defaults.wildcard,m=this.config.transitionFor(this.state,l),_=m&&m.to;return typeof _=="function"?_.apply(this.context,h):_===v?this.state:_},fire:function(l,h){return this.transit(l,this.state,this.seek(l,h),h)},transit:function(l,h,v,m){var _=this.config.lifecycle,C=this.config.options.observeUnchangedState||h!==v;return v?this.isPending()?this.context.onPendingTransition(l,h,v):(this.config.addState(v),this.beginTransit(),m.unshift({transition:l,from:h,to:v,fsm:this.context}),this.observeEvents([this.observersForEvent(_.onBefore.transition),this.observersForEvent(_.onBefore[l]),C?this.observersForEvent(_.onLeave.state):u,C?this.observersForEvent(_.onLeave[h]):u,this.observersForEvent(_.on.transition),C?["doTransit",[this]]:u,C?this.observersForEvent(_.onEnter.state):u,C?this.observersForEvent(_.onEnter[v]):u,C?this.observersForEvent(_.on[v]):u,this.observersForEvent(_.onAfter.transition),this.observersForEvent(_.onAfter[l]),this.observersForEvent(_.on[l])],m)):this.context.onInvalidTransition(l,h,v)},beginTransit:function(){this.pending=!0},endTransit:function(l){return this.pending=!1,l},failTransit:function(l){throw this.pending=!1,l},doTransit:function(l){this.state=l.to},observe:function(l){if(l.length===2){var h={};h[l[0]]=l[1],this.observers.push(h)}else this.observers.push(l[0])},observersForEvent:function(l){for(var h=0,v=this.observers.length,m,_=[];h<v;h++)m=this.observers[h],m[l]&&_.push(m);return[l,_,!0]},observeEvents:function(l,h,v,m){if(l.length===0)return this.endTransit(m===void 0?!0:m);var _=l[0][0],C=l[0][1],I=l[0][2];if(h[0].event=_,_&&I&&_!==v&&o.hook(this,"lifecycle",h),C.length===0)return l.shift(),this.observeEvents(l,h,_,m);var $=C.shift(),x=$[_].apply($,h);return x&&typeof x.then=="function"?x.then(this.observeEvents.bind(this,l,h,_)).catch(this.failTransit.bind(this)):x===!1?this.endTransit(!1):this.observeEvents(l,h,_,x)},onInvalidTransition:function(l,h,v){throw new s("transition is invalid in current state",l,h,v,this.state)},onPendingTransition:function(l,h,v){throw new s("transition is invalid while previous transition is still in progress",l,h,v,this.state)}}),t.exports=c},function(t,n,i){var a=i(0),s=i(2),o=i(1),u=i(3),c=i(4),l={is:function(I){return this._fsm.is(I)},can:function(I){return this._fsm.can(I)},cannot:function(I){return this._fsm.cannot(I)},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(I,$,x){return this._fsm.onInvalidTransition(I,$,x)},onPendingTransition:function(I,$,x){return this._fsm.onPendingTransition(I,$,x)}},h={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(I){throw Error("use transitions to change state")}}};function v(I){return _(this||{},I)}function m(){var I,$;typeof arguments[0]=="function"?(I=arguments[0],$=arguments[1]||{}):(I=function(){this._fsm.apply(this,arguments)},$=arguments[0]||{});var x=new u($,v);return C(I.prototype,x),I.prototype._fsm.config=x,I}function _(I,$){var x=new u($,v);return C(I,x),I._fsm(),I}function C(I,$){if(typeof I!="object"||Array.isArray(I))throw Error("StateMachine can only be applied to objects");o.build(I,$),Object.defineProperties(I,h),a(I,l),a(I,$.methods),$.allTransitions().forEach(function(x){I[s(x)]=function(){return this._fsm.fire(x,[].slice.call(arguments))}}),I._fsm=function(){this._fsm=new c(this,$),this._fsm.init(arguments)}}v.version="3.0.1",v.factory=m,v.apply=_,v.defaults={wildcard:"*",init:{name:"init",from:"none"}},t.exports=v},function(t,n,i){t.exports=function(a,s,o,u,c){this.message=a,this.transition=s,this.from=o,this.to=u,this.current=c}}])})})(qE);var uz=qE.exports,dh={exports:{}},l_=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(l_){var f_=new Uint8Array(16);dh.exports=function(){return l_(f_),f_}}else{var d_=new Array(16);dh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),d_[r]=t>>>((r&3)<<3)&255;return d_}}var zE=dh.exports,WE=[];for(var oc=0;oc<256;++oc)WE[oc]=(oc+256).toString(16).substr(1);function cz(e,r){var t=r||0,n=WE;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var VE=cz,lz=zE,fz=VE,p_,xd,Nd=0,Ld=0;function dz(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||p_,s=e.clockseq!==void 0?e.clockseq:xd;if(a==null||s==null){var o=lz();a==null&&(a=p_=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=xd=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Ld+1,l=u-Nd+(c-Ld)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>Nd)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Nd=u,Ld=c,xd=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||fz(i)}var pz=dz,hz=zE,vz=VE;function mz(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||hz)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||vz(i)}var gz=mz,yz=pz,GE=gz,Im=GE;Im.v1=yz;Im.v4=GE;var bz=Im,ph={exports:{}},HE=typeof ArrayBuffer<"u"&&typeof DataView<"u",_z=HE,KE=Wt,fn=_t,JE=Ut,Om=Jt,Zo=tr,YE=Vi,wz=rs,Sz=zi,Cz=Ur,Tz=hi,Ez=qi,ff=Tu,Ru=so,kz=Bt,Rz=su,XE=pn,QE=XE.enforce,$z=XE.get,yl=fn.Int8Array,hh=yl&&yl.prototype,h_=fn.Uint8ClampedArray,v_=h_&&h_.prototype,Ha=yl&&ff(yl),zn=hh&&ff(hh),Iz=Object.prototype,Pm=fn.TypeError,m_=kz("toStringTag"),vh=Rz("TYPED_ARRAY_TAG"),bl="TypedArrayConstructor",_a=_z&&!!Ru&&YE(fn.opera)!=="Opera",ZE=!1,Yr,la,js,lo={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},ek={BigInt64Array:8,BigUint64Array:8},tk=function(e){var r=ff(e);if(Om(r)){var t=$z(r);return t&&Zo(t,bl)?t[bl]:tk(r)}},rk=function(e){if(!Om(e))return!1;var r=YE(e);return Zo(lo,r)||Zo(ek,r)},Oz=function(e){if(rk(e))return e;throw new Pm("Target is not a typed array")},Pz=function(e){if(JE(e)&&(!Ru||Ez(Ha,e)))return e;throw new Pm(wz(e)+" is not a typed array constructor")},Az=function(e,r,t,n){if(KE){if(t)for(var i in lo){var a=fn[i];if(a&&Zo(a.prototype,e))try{delete a.prototype[e]}catch{try{a.prototype[e]=r}catch{}}}(!zn[e]||t)&&Cz(zn,e,t?r:_a&&hh[e]||r,n)}};for(Yr in lo)la=fn[Yr],js=la&&la.prototype,js?QE(js)[bl]=la:_a=!1;for(Yr in ek)la=fn[Yr],js=la&&la.prototype,js&&(QE(js)[bl]=la);if((!_a||!JE(Ha)||Ha===Function.prototype)&&(Ha=function(){throw new Pm("Incorrect invocation")},_a))for(Yr in lo)fn[Yr]&&Ru(fn[Yr],Ha);if((!_a||!zn||zn===Iz)&&(zn=Ha.prototype,_a))for(Yr in lo)fn[Yr]&&Ru(fn[Yr].prototype,zn);_a&&ff(v_)!==zn&&Ru(v_,zn);if(KE&&!Zo(zn,m_)){ZE=!0,Tz(zn,m_,{configurable:!0,get:function(){return Om(this)?this[vh]:void 0}});for(Yr in lo)fn[Yr]&&Sz(fn[Yr],vh,Yr)}var Vt={NATIVE_ARRAY_BUFFER_VIEWS:_a,TYPED_ARRAY_TAG:ZE&&vh,aTypedArray:Oz,aTypedArrayConstructor:Pz,exportTypedArrayMethod:Az,getTypedArrayConstructor:tk,isTypedArray:rk,TypedArray:Ha,TypedArrayPrototype:zn},nk=_t,Dd=lt,Mz=Kl,xz=Vt.NATIVE_ARRAY_BUFFER_VIEWS,Nz=nk.ArrayBuffer,Ba=nk.Int8Array,Lz=!xz||!Dd(function(){Ba(1)})||!Dd(function(){new Ba(-1)})||!Mz(function(e){new Ba,new Ba(null),new Ba(1.5),new Ba(e)},!0)||Dd(function(){return new Ba(new Nz(2),1,void 0).length!==1}),Dz=fi,jz=Wi,Fz=RangeError,ik=function(e){if(e===void 0)return 0;var r=Dz(e),t=jz(r);if(r!==t)throw new Fz("Wrong length or index");return t},Uz=Math.sign||function(r){var t=+r;return t===0||t!==t?t:t<0?-1:1},Bz=Uz,qz=Math.abs,ak=2220446049250313e-31,g_=1/ak,zz=function(e){return e+g_-g_},Wz=function(e,r,t,n){var i=+e,a=qz(i),s=Bz(i);if(a<n)return s*zz(a/n/r)*n*r;var o=(1+r/ak)*a,u=o-(o-a);return u>t||u!==u?s*(1/0):s*u},Vz=Wz,Gz=11920928955078125e-23,Hz=34028234663852886e22,Kz=11754943508222875e-54,Jz=Math.fround||function(r){return Vz(r,Gz,Hz,Kz)},Yz=Array,Xz=Math.abs,Pi=Math.pow,Qz=Math.floor,Zz=Math.log,eW=Math.LN2,tW=function(e,r,t){var n=Yz(t),i=t*8-r-1,a=(1<<i)-1,s=a>>1,o=r===23?Pi(2,-24)-Pi(2,-77):0,u=e<0||e===0&&1/e<0?1:0,c=0,l,h,v;for(e=Xz(e),e!==e||e===1/0?(h=e!==e?1:0,l=a):(l=Qz(Zz(e)/eW),v=Pi(2,-l),e*v<1&&(l--,v*=2),l+s>=1?e+=o/v:e+=o*Pi(2,1-s),e*v>=2&&(l++,v/=2),l+s>=a?(h=0,l=a):l+s>=1?(h=(e*v-1)*Pi(2,r),l+=s):(h=e*Pi(2,s-1)*Pi(2,r),l=0));r>=8;)n[c++]=h&255,h/=256,r-=8;for(l=l<<r|h,i+=r;i>0;)n[c++]=l&255,l/=256,i-=8;return n[c-1]|=u*128,n},rW=function(e,r){var t=e.length,n=t*8-r-1,i=(1<<n)-1,a=i>>1,s=n-7,o=t-1,u=e[o--],c=u&127,l;for(u>>=7;s>0;)c=c*256+e[o--],s-=8;for(l=c&(1<<-s)-1,c>>=-s,s+=r;s>0;)l=l*256+e[o--],s-=8;if(c===0)c=1-a;else{if(c===i)return l?NaN:u?-1/0:1/0;l+=Pi(2,r),c-=a}return(u?-1:1)*l*Pi(2,c-r)},nW={pack:tW,unpack:rW},iW=Mr,y_=as,aW=xr,sk=function(r){for(var t=iW(this),n=aW(t),i=arguments.length,a=y_(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,o=s===void 0?n:y_(s,n);o>a;)t[a++]=r;return t},df=_t,Am=vt,jd=Wt,sW=HE,ok=ou,oW=zi,uW=hi,b_=uf,Fd=lt,uc=ka,cW=fi,lW=Wi,_l=ik,fW=Jz,uk=nW,dW=Tu,__=so,pW=sk,hW=pi,vW=Yl,mW=Ov,ck=di,Mm=pn,gW=ok.PROPER,w_=ok.CONFIGURABLE,Fs="ArrayBuffer",pf="DataView",Us="prototype",yW="Wrong length",lk="Wrong index",S_=Mm.getterFor(Fs),qo=Mm.getterFor(pf),C_=Mm.set,Fn=df[Fs],cn=Fn,bs=cn&&cn[Us],ii=df[pf],qa=ii&&ii[Us],T_=Object.prototype,bW=df.Array,wl=df.RangeError,_W=Am(pW),wW=Am([].reverse),fk=uk.pack,E_=uk.unpack,k_=function(e){return[e&255]},R_=function(e){return[e&255,e>>8&255]},$_=function(e){return[e&255,e>>8&255,e>>16&255,e>>24&255]},I_=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},SW=function(e){return fk(fW(e),23,4)},CW=function(e){return fk(e,52,8)},cc=function(e,r,t){uW(e[Us],r,{configurable:!0,get:function(){return t(this)[r]}})},sa=function(e,r,t,n){var i=qo(e),a=_l(t),s=!!n;if(a+r>i.byteLength)throw new wl(lk);var o=i.bytes,u=a+i.byteOffset,c=hW(o,u,u+r);return s?c:wW(c)},oa=function(e,r,t,n,i,a){var s=qo(e),o=_l(t),u=n(+i),c=!!a;if(o+r>s.byteLength)throw new wl(lk);for(var l=s.bytes,h=o+s.byteOffset,v=0;v<r;v++)l[h+v]=u[c?v:r-v-1]};if(!sW)cn=function(r){uc(this,bs);var t=_l(r);C_(this,{type:Fs,bytes:_W(bW(t),0),byteLength:t}),jd||(this.byteLength=t,this.detached=!1)},bs=cn[Us],ii=function(r,t,n){uc(this,qa),uc(r,bs);var i=S_(r),a=i.byteLength,s=cW(t);if(s<0||s>a)throw new wl("Wrong offset");if(n=n===void 0?a-s:lW(n),s+n>a)throw new wl(yW);C_(this,{type:pf,buffer:r,byteLength:n,byteOffset:s,bytes:i.bytes}),jd||(this.buffer=r,this.byteLength=n,this.byteOffset=s)},qa=ii[Us],jd&&(cc(cn,"byteLength",S_),cc(ii,"buffer",qo),cc(ii,"byteLength",qo),cc(ii,"byteOffset",qo)),b_(qa,{getInt8:function(r){return sa(this,1,r)[0]<<24>>24},getUint8:function(r){return sa(this,1,r)[0]},getInt16:function(r){var t=sa(this,2,r,arguments.length>1?arguments[1]:!1);return(t[1]<<8|t[0])<<16>>16},getUint16:function(r){var t=sa(this,2,r,arguments.length>1?arguments[1]:!1);return t[1]<<8|t[0]},getInt32:function(r){return I_(sa(this,4,r,arguments.length>1?arguments[1]:!1))},getUint32:function(r){return I_(sa(this,4,r,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(r){return E_(sa(this,4,r,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(r){return E_(sa(this,8,r,arguments.length>1?arguments[1]:!1),52)},setInt8:function(r,t){oa(this,1,r,k_,t)},setUint8:function(r,t){oa(this,1,r,k_,t)},setInt16:function(r,t){oa(this,2,r,R_,t,arguments.length>2?arguments[2]:!1)},setUint16:function(r,t){oa(this,2,r,R_,t,arguments.length>2?arguments[2]:!1)},setInt32:function(r,t){oa(this,4,r,$_,t,arguments.length>2?arguments[2]:!1)},setUint32:function(r,t){oa(this,4,r,$_,t,arguments.length>2?arguments[2]:!1)},setFloat32:function(r,t){oa(this,4,r,SW,t,arguments.length>2?arguments[2]:!1)},setFloat64:function(r,t){oa(this,8,r,CW,t,arguments.length>2?arguments[2]:!1)}});else{var O_=gW&&Fn.name!==Fs;!Fd(function(){Fn(1)})||!Fd(function(){new Fn(-1)})||Fd(function(){return new Fn,new Fn(1.5),new Fn(NaN),Fn.length!==1||O_&&!w_})?(cn=function(r){return uc(this,bs),vW(new Fn(_l(r)),this,cn)},cn[Us]=bs,bs.constructor=cn,mW(cn,Fn)):O_&&w_&&oW(Fn,"name",Fs),__&&dW(qa)!==T_&&__(qa,T_);var lc=new ii(new cn(2)),P_=Am(qa.setInt8);lc.setInt8(0,2147483648),lc.setInt8(1,2147483649),(lc.getInt8(0)||!lc.getInt8(1))&&b_(qa,{setInt8:function(r,t){P_(this,r,t<<24>>24)},setUint8:function(r,t){P_(this,r,t<<24>>24)}},{unsafe:!0})}ck(cn,Fs);ck(ii,pf);var dk={ArrayBuffer:cn,DataView:ii},TW=fi,EW=RangeError,kW=function(e){var r=TW(e);if(r<0)throw new EW("The argument can't be less than 0");return r},RW=kW,$W=RangeError,pk=function(e,r){var t=RW(e);if(t%r)throw new $W("Wrong offset");return t},IW=Math.round,OW=function(e){var r=IW(e);return r<0?0:r>255?255:r&255},PW=Vi,AW=function(e){var r=PW(e);return r==="BigInt64Array"||r==="BigUint64Array"},MW=Ev,xW=TypeError,hk=function(e){var r=MW(e,"number");if(typeof r=="number")throw new xW("Can't convert number to bigint");return BigInt(r)},NW=Gi,LW=Ft,DW=Mv,jW=Mr,FW=xr,UW=Hl,BW=wu,qW=Zv,zW=AW,WW=Vt.aTypedArrayConstructor,VW=hk,GW=function(r){var t=DW(this),n=jW(r),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,o=BW(n),u,c,l,h,v,m,_,C;if(o&&!qW(o))for(_=UW(n,o),C=_.next,n=[];!(m=LW(C,_)).done;)n.push(m.value);for(s&&i>2&&(a=NW(a,arguments[2])),c=FW(n),l=new(WW(t))(c),h=zW(l),u=0;c>u;u++)v=s?a(n[u],u):n[u],l[u]=h?VW(v):+v;return l},HW=xr,vk=function(e,r,t){for(var n=0,i=arguments.length>2?t:HW(r),a=new e(i);i>n;)a[n]=r[n++];return a},A_=gt,mk=_t,M_=Ft,KW=Wt,JW=Lz,$u=Vt,gk=dk,x_=ka,YW=ts,To=zi,XW=hE,QW=Wi,N_=ik,Ud=pk,ZW=OW,yk=Al,Eo=tr,e8=Vi,mh=Jt,t8=io,r8=Ta,n8=qi,fc=so,i8=is.f,L_=GW,a8=Zr.forEach,s8=Wl,o8=hi,bk=Fr,_k=Bi,D_=vk,xm=pn,u8=Yl,gh=xm.get,c8=xm.set,l8=xm.enforce,wk=bk.f,f8=_k.f,Bd=mk.RangeError,Sk=gk.ArrayBuffer,d8=Sk.prototype,p8=gk.DataView,dc=$u.NATIVE_ARRAY_BUFFER_VIEWS,j_=$u.TYPED_ARRAY_TAG,F_=$u.TypedArray,ko=$u.TypedArrayPrototype,yh=$u.isTypedArray,pc="BYTES_PER_ELEMENT",qd="Wrong length",hc=function(e,r){o8(e,r,{configurable:!0,get:function(){return gh(this)[r]}})},U_=function(e){var r;return n8(d8,e)||(r=e8(e))==="ArrayBuffer"||r==="SharedArrayBuffer"},Ck=function(e,r){return yh(e)&&!t8(r)&&r in e&&XW(+r)&&r>=0},B_=function(r,t){return t=yk(t),Ck(r,t)?YW(2,r[t]):f8(r,t)},q_=function(r,t,n){return t=yk(t),Ck(r,t)&&mh(n)&&Eo(n,"value")&&!Eo(n,"get")&&!Eo(n,"set")&&!n.configurable&&(!Eo(n,"writable")||n.writable)&&(!Eo(n,"enumerable")||n.enumerable)?(r[t]=n.value,r):wk(r,t,n)};KW?(dc||(_k.f=B_,bk.f=q_,hc(ko,"buffer"),hc(ko,"byteOffset"),hc(ko,"byteLength"),hc(ko,"length")),A_({target:"Object",stat:!0,forced:!dc},{getOwnPropertyDescriptor:B_,defineProperty:q_}),ph.exports=function(e,r,t){var n=e.match(/\d+/)[0]/8,i=e+(t?"Clamped":"")+"Array",a="get"+e,s="set"+e,o=mk[i],u=o,c=u&&u.prototype,l={},h=function(C,I){var $=gh(C);return $.view[a](I*n+$.byteOffset,!0)},v=function(C,I,$){var x=gh(C);x.view[s](I*n+x.byteOffset,t?ZW($):$,!0)},m=function(C,I){wk(C,I,{get:function(){return h(this,I)},set:function($){return v(this,I,$)},enumerable:!0})};dc?JW&&(u=r(function(C,I,$,x){return x_(C,c),u8(function(){return mh(I)?U_(I)?x!==void 0?new o(I,Ud($,n),x):$!==void 0?new o(I,Ud($,n)):new o(I):yh(I)?D_(u,I):M_(L_,u,I):new o(N_(I))}(),C,u)}),fc&&fc(u,F_),a8(i8(o),function(C){C in u||To(u,C,o[C])}),u.prototype=c):(u=r(function(C,I,$,x){x_(C,c);var N=0,q=0,X,J,G;if(!mh(I))G=N_(I),J=G*n,X=new Sk(J);else if(U_(I)){X=I,q=Ud($,n);var L=I.byteLength;if(x===void 0){if(L%n)throw new Bd(qd);if(J=L-q,J<0)throw new Bd(qd)}else if(J=QW(x)*n,J+q>L)throw new Bd(qd);G=J/n}else return yh(I)?D_(u,I):M_(L_,u,I);for(c8(C,{buffer:X,byteOffset:q,byteLength:J,length:G,view:new p8(X)});N<G;)m(C,N++)}),fc&&fc(u,F_),c=u.prototype=r8(ko)),c.constructor!==u&&To(c,"constructor",u),l8(c).TypedArrayConstructor=u,j_&&To(c,j_,i);var _=u!==o;l[i]=u,A_({global:!0,constructor:!0,forced:_,sham:!dc},l),pc in u||To(u,pc,n),pc in c||To(c,pc,n),s8(i)}):ph.exports=function(){};var h8=ph.exports,v8=h8;v8("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var z_=rs,m8=TypeError,Nm=function(e,r){if(!delete e[r])throw new m8("Cannot delete property "+z_(r)+" of "+z_(e))},g8=Mr,zd=as,y8=xr,b8=Nm,_8=Math.min,w8=[].copyWithin||function(r,t){var n=g8(this),i=y8(n),a=zd(r,i),s=zd(t,i),o=arguments.length>2?arguments[2]:void 0,u=_8((o===void 0?i:zd(o,i))-s,i-a),c=1;for(s<a&&a<s+u&&(c=-1,s+=u-1,a+=u-1);u-- >0;)s in n?n[a]=n[s]:b8(n,a),a+=c,s+=c;return n},S8=vt,Tk=Vt,C8=w8,T8=S8(C8),E8=Tk.aTypedArray,k8=Tk.exportTypedArrayMethod;k8("copyWithin",function(r,t){return T8(E8(this),r,t,arguments.length>2?arguments[2]:void 0)});var Ek=Vt,R8=Zr.every,$8=Ek.aTypedArray,I8=Ek.exportTypedArrayMethod;I8("every",function(r){return R8($8(this),r,arguments.length>1?arguments[1]:void 0)});var kk=Vt,O8=sk,P8=hk,A8=Vi,M8=Ft,x8=vt,N8=lt,L8=kk.aTypedArray,D8=kk.exportTypedArrayMethod,j8=x8("".slice),F8=N8(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1});D8("fill",function(r){var t=arguments.length;L8(this);var n=j8(A8(this),0,3)==="Big"?P8(r):+r;return M8(O8,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},F8);var U8=vk,B8=Vt.getTypedArrayConstructor,q8=function(e,r){return U8(B8(e),r)},Rk=Vt,z8=Zr.filter,W8=q8,V8=Rk.aTypedArray,G8=Rk.exportTypedArrayMethod;G8("filter",function(r){var t=z8(V8(this),r,arguments.length>1?arguments[1]:void 0);return W8(this,t)});var $k=Vt,H8=Zr.find,K8=$k.aTypedArray,J8=$k.exportTypedArrayMethod;J8("find",function(r){return H8(K8(this),r,arguments.length>1?arguments[1]:void 0)});var Ik=Vt,Y8=Zr.findIndex,X8=Ik.aTypedArray,Q8=Ik.exportTypedArrayMethod;Q8("findIndex",function(r){return Y8(X8(this),r,arguments.length>1?arguments[1]:void 0)});var Ok=Vt,Z8=Zr.forEach,e5=Ok.aTypedArray,t5=Ok.exportTypedArrayMethod;t5("forEach",function(r){Z8(e5(this),r,arguments.length>1?arguments[1]:void 0)});var Pk=Vt,r5=Nl.includes,n5=Pk.aTypedArray,i5=Pk.exportTypedArrayMethod;i5("includes",function(r){return r5(n5(this),r,arguments.length>1?arguments[1]:void 0)});var Ak=Vt,a5=Nl.indexOf,s5=Ak.aTypedArray,o5=Ak.exportTypedArrayMethod;o5("indexOf",function(r){return a5(s5(this),r,arguments.length>1?arguments[1]:void 0)});var u5=_t,c5=lt,Lm=vt,Mk=Vt,Dm=BT,l5=Bt,jm=l5("iterator"),W_=u5.Uint8Array,f5=Lm(Dm.values),d5=Lm(Dm.keys),p5=Lm(Dm.entries),Fm=Mk.aTypedArray,hf=Mk.exportTypedArrayMethod,Rs=W_&&W_.prototype,vf=!c5(function(){Rs[jm].call([1])}),xk=!!Rs&&Rs.values&&Rs[jm]===Rs.values&&Rs.values.name==="values",Nk=function(){return f5(Fm(this))};hf("entries",function(){return p5(Fm(this))},vf);hf("keys",function(){return d5(Fm(this))},vf);hf("values",Nk,vf||!xk,{name:"values"});hf(jm,Nk,vf||!xk,{name:"values"});var Lk=Vt,h5=vt,v5=Lk.aTypedArray,m5=Lk.exportTypedArrayMethod,g5=h5([].join);m5("join",function(r){return g5(v5(this),r)});var y5=ss,b5=dn,_5=fi,w5=xr,S5=zl,C5=Math.min,bh=[].lastIndexOf,Dk=!!bh&&1/[1].lastIndexOf(1,-0)<0,T5=S5("lastIndexOf"),E5=Dk||!T5,k5=E5?function(r){if(Dk)return y5(bh,this,arguments)||0;var t=b5(this),n=w5(t);if(n===0)return-1;var i=n-1;for(arguments.length>1&&(i=C5(i,_5(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===r)return i||0;return-1}:bh,jk=Vt,R5=ss,$5=k5,I5=jk.aTypedArray,O5=jk.exportTypedArrayMethod;O5("lastIndexOf",function(r){var t=arguments.length;return R5($5,I5(this),t>1?[r,arguments[1]]:[r])});var Um=Vt,P5=Zr.map,A5=Um.aTypedArray,M5=Um.getTypedArrayConstructor,x5=Um.exportTypedArrayMethod;x5("map",function(r){return P5(A5(this),r,arguments.length>1?arguments[1]:void 0,function(t,n){return new(M5(t))(n)})});var N5=In,L5=Mr,D5=au,j5=xr,V_=TypeError,G_="Reduce of empty array with no initial value",H_=function(e){return function(r,t,n,i){var a=L5(r),s=D5(a),o=j5(a);if(N5(t),o===0&&n<2)throw new V_(G_);var u=e?o-1:0,c=e?-1:1;if(n<2)for(;;){if(u in s){i=s[u],u+=c;break}if(u+=c,e?u<0:o<=u)throw new V_(G_)}for(;e?u>=0:o>u;u+=c)u in s&&(i=t(i,s[u],u,a));return i}},Fk={left:H_(!1),right:H_(!0)},Uk=Vt,F5=Fk.left,U5=Uk.aTypedArray,B5=Uk.exportTypedArrayMethod;B5("reduce",function(r){var t=arguments.length;return F5(U5(this),r,t,t>1?arguments[1]:void 0)});var Bk=Vt,q5=Fk.right,z5=Bk.aTypedArray,W5=Bk.exportTypedArrayMethod;W5("reduceRight",function(r){var t=arguments.length;return q5(z5(this),r,t,t>1?arguments[1]:void 0)});var qk=Vt,V5=qk.aTypedArray,G5=qk.exportTypedArrayMethod,H5=Math.floor;G5("reverse",function(){for(var r=this,t=V5(r).length,n=H5(t/2),i=0,a;i<n;)a=r[i],r[i++]=r[--t],r[t]=a;return r});var zk=_t,Wk=Ft,Bm=Vt,K5=xr,J5=pk,Y5=Mr,Vk=lt,X5=zk.RangeError,_h=zk.Int8Array,K_=_h&&_h.prototype,Gk=K_&&K_.set,Q5=Bm.aTypedArray,Z5=Bm.exportTypedArrayMethod,wh=!Vk(function(){var e=new Uint8ClampedArray(2);return Wk(Gk,e,{length:1,0:3},1),e[1]!==3}),eV=wh&&Bm.NATIVE_ARRAY_BUFFER_VIEWS&&Vk(function(){var e=new _h(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});Z5("set",function(r){Q5(this);var t=J5(arguments.length>1?arguments[1]:void 0,1),n=Y5(r);if(wh)return Wk(Gk,this,n,t);var i=this.length,a=K5(n),s=0;if(a+t>i)throw new X5("Wrong length");for(;s<a;)this[t+s]=n[s++]},!wh||eV);var qm=Vt,tV=lt,rV=pi,nV=qm.aTypedArray,iV=qm.getTypedArrayConstructor,aV=qm.exportTypedArrayMethod,sV=tV(function(){new Int8Array(1).slice()});aV("slice",function(r,t){for(var n=rV(nV(this),r,t),i=iV(this),a=0,s=n.length,o=new i(s);s>a;)o[a]=n[a++];return o},sV);var Hk=Vt,oV=Zr.some,uV=Hk.aTypedArray,cV=Hk.exportTypedArrayMethod;cV("some",function(r){return oV(uV(this),r,arguments.length>1?arguments[1]:void 0)});var J_=pi,lV=Math.floor,Sh=function(e,r){var t=e.length;if(t<8)for(var n=1,i,a;n<t;){for(a=n,i=e[n];a&&r(e[a-1],i)>0;)e[a]=e[--a];a!==n++&&(e[a]=i)}else for(var s=lV(t/2),o=Sh(J_(e,0,s),r),u=Sh(J_(e,s),r),c=o.length,l=u.length,h=0,v=0;h<c||v<l;)e[h+v]=h<c&&v<l?r(o[h],u[v])<=0?o[h++]:u[v++]:h<c?o[h++]:u[v++];return e},zm=Sh,fV=Ca,Y_=fV.match(/firefox\/(\d+)/i),Kk=!!Y_&&+Y_[1],dV=Ca,Jk=/MSIE|Trident/.test(dV),pV=Ca,X_=pV.match(/AppleWebKit\/(\d+)\./),Yk=!!X_&&+X_[1],hV=_t,vV=jv,Ch=lt,mV=In,gV=zm,Xk=Vt,Q_=Kk,yV=Jk,Z_=ro,ew=Yk,bV=Xk.aTypedArray,_V=Xk.exportTypedArrayMethod,eu=hV.Uint16Array,Bs=eu&&vV(eu.prototype.sort),wV=!!Bs&&!(Ch(function(){Bs(new eu(2),null)})&&Ch(function(){Bs(new eu(2),{})})),tw=!!Bs&&!Ch(function(){if(Z_)return Z_<74;if(Q_)return Q_<67;if(yV)return!0;if(ew)return ew<602;var e=new eu(516),r=Array(516),t,n;for(t=0;t<516;t++)n=t%4,e[t]=515-t,r[t]=t-2*n+3;for(Bs(e,function(i,a){return(i/4|0)-(a/4|0)}),t=0;t<516;t++)if(e[t]!==r[t])return!0}),SV=function(e){return function(r,t){return e!==void 0?+e(r,t)||0:t!==t?-1:r!==r?1:r===0&&t===0?1/r>0&&1/t<0?1:-1:r>t}};_V("sort",function(r){return r!==void 0&&mV(r),tw?Bs(this,r):gV(bV(this),SV(r))},!tw||wV);var Wm=Vt,CV=Wi,rw=as,TV=Wm.aTypedArray,EV=Wm.getTypedArrayConstructor,kV=Wm.exportTypedArrayMethod;kV("subarray",function(r,t){var n=TV(this),i=n.length,a=rw(r,i),s=EV(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,CV((t===void 0?i:rw(t,i))-a))});var RV=_t,$V=ss,Qk=Vt,Th=lt,nw=pi,Sl=RV.Int8Array,iw=Qk.aTypedArray,IV=Qk.exportTypedArrayMethod,Zk=[].toLocaleString,OV=!!Sl&&Th(function(){Zk.call(new Sl(1))}),PV=Th(function(){return[1,2].toLocaleString()!==new Sl([1,2]).toLocaleString()})||!Th(function(){Sl.prototype.toLocaleString.call([1,2])});IV("toLocaleString",function(){return $V(Zk,OV?nw(iw(this)):iw(this),nw(arguments))},PV);var AV=Vt.exportTypedArrayMethod,MV=lt,xV=_t,NV=vt,aw=xV.Uint8Array,LV=aw&&aw.prototype||{},Cl=[].toString,DV=NV([].join);MV(function(){Cl.call({})})&&(Cl=function(){return DV(this)});var jV=LV.toString!==Cl;AV("toString",Cl,jV);var Wd=Ft,eR=vt,FV=ef,UV=ar,BV=Hn,qV=Kn,zV=tT,WV=pm,VV=Wi,sw=wr,GV=ns,ow=tf,HV=YT,KV=lt,_s=HV.UNSUPPORTED_Y,JV=4294967295,YV=Math.min,Vd=eR([].push),Gd=eR("".slice),XV=!KV(function(){var e=/(?:)/,r=e.exec;e.exec=function(){return r.apply(this,arguments)};var t="ab".split(e);return t.length!==2||t[0]!=="a"||t[1]!=="b"}),uw="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;FV("split",function(e,r,t){var n="0".split(void 0,0).length?function(i,a){return i===void 0&&a===0?[]:Wd(r,this,i,a)}:r;return[function(a,s){var o=qV(this),u=BV(a)?void 0:GV(a,e);return u?Wd(u,a,o,s):Wd(n,sw(o),a,s)},function(i,a){var s=UV(this),o=sw(i);if(!uw){var u=t(n,s,o,a,n!==r);if(u.done)return u.value}var c=zV(s,RegExp),l=s.unicode,h=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(_s?"g":"y"),v=new c(_s?"^(?:"+s.source+")":s,h),m=a===void 0?JV:a>>>0;if(m===0)return[];if(o.length===0)return ow(v,o)===null?[o]:[];for(var _=0,C=0,I=[];C<o.length;){v.lastIndex=_s?0:C;var $=ow(v,_s?Gd(o,C):o),x;if($===null||(x=YV(VV(v.lastIndex+(_s?C:0)),o.length))===_)C=WV(o,C,l);else{if(Vd(I,Gd(o,_,C)),I.length===m)return I;for(var N=1;N<=$.length-1;N++)if(Vd(I,$[N]),I.length===m)return I;C=_=x}}return Vd(I,Gd(o,_)),I}]},uw||!XV,_s);var tR={exports:{}},rR={exports:{}};(function(e){function r(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch{return typeof t=="function"}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(rR);var QV=rR.exports,nR={exports:{}},iR={exports:{}};(function(e){function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(e.exports=r=function(){return!!t},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(iR);var ZV=iR.exports;(function(e){var r=ZV,t=Wv;function n(i,a,s){if(r())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,a);var u=new(i.bind.apply(i,o));return s&&t(u,s.prototype),u}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(nR);var eG=nR.exports;(function(e){var r=Pn,t=Wv,n=QV,i=eG;function a(s){var o=typeof Map=="function"?new Map:void 0;return e.exports=a=function(c){if(c===null||!n(c))return c;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(c))return o.get(c);o.set(c,l)}function l(){return i(c,arguments,r(this).constructor)}return l.prototype=Object.create(c.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),t(l,c)},e.exports.__esModule=!0,e.exports.default=e.exports,a(s)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(tR);var mf=tR.exports,Tl={exports:{}};/*!
64
+ */Object.defineProperty(Br,"__esModule",{value:!0});var x6=On,N6=uo,L6=co,D6=gi,j6=vi,F6=mi,U6=Pn;function ls(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ds=ls(x6),Qa=ls(N6),Md=ls(L6),B6=ls(D6),q6=ls(j6),z6=ls(F6),s_=ls(U6),$a=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function W6(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=V6(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
65
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function V6(e,r){if(e){if(typeof e=="string")return o_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o_(e,r)}}function o_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var BE=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return $a(function(i){var a=!1,s=[],o=W6(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;if(typeof c=="string"){a=a||Ds.default(i)===c,s.push("of type ".concat(c));continue}a=a||i instanceof c,s.push("an instance of ".concat(c.name))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})};function G6(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=H6(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
66
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function H6(e,r){if(e){if(typeof e=="string")return u_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u_(e,r)}}function u_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var K6=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return $a(function(i){var a=!1,s=[],o=G6(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;a=a||i===c,s.push(typeof c=="string"?'"'.concat(c,'"'):"".concat(c))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})},J6=$a(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),Y6=$a(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),X6=$a(function(e){return[Ds.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function Q6(e){var r=Z6();return function(){var n=s_.default(e),i;if(r){var a=s_.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return z6.default(this,i)}}function Z6(){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 Qo(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=ez(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
67
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function ez(e,r){if(e){if(typeof e=="string")return c_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c_(e,r)}}function c_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var lf=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=Qo(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Qa.default(i.value,2),s=a[0],o=a[1],u=$m(r[s],o),c=Qa.default(u,4),l=c[0],h=c[1],v=c[2],m=c[3];if(!l){var _=s+1;throw new Error("Argument ".concat(_," is expected to be ").concat(v).concat(m," but got ").concat(h))}}}catch(C){n.e(C)}finally{n.f()}},qE=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(Ds.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),Ds.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=Ds.default(r)),n},tz=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=km(t);return function(a){return function(s){q6.default(u,s);var o=Q6(u);function u(){B6.default(this,u);for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return lf(i,l),o.call.apply(o,[this].concat(l))}return u}(a)}},rz=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=km(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return lf(i,l),u.apply(this,l)}}},nz=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=km(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];try{lf(i,l)}catch(v){return Promise.reject(v)}return u.apply(this,l)}}},km=function(r){var t=[],n=Qo(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Rm(a))}}catch(s){n.e(s)}finally{n.f()}return t},Rm=function(r){var t=[],n=Array.isArray(r)?r:[r],i=Qo(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(BE(s));continue}t.push(s)}}catch(o){i.e(o)}finally{i.f()}return t},$m=function(r,t){var n=[],i,a=!1,s=Qo(r),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,c=Qo(u.checks),l;try{for(c.s();!(l=c.n()).done;){var h=l.value,v=h(t),m=Qa.default(v,3),_=m[0],C=m[1],I=m[2];a=a||_,!i&&I&&(i=I),C&&(n=typeof C=="string"?[].concat(Md.default(n),[C]):[].concat(Md.default(n),Md.default(C)))}}catch(q){c.e(q)}finally{c.f()}}}catch(q){s.e(q)}finally{s.f()}if(a)return[!0];var $=i||qE(t),x=n.length-1,N=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,$,N,x>1?";":","]},iz=function(r,t){return $a(function(n){if(Ds.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=Qa.default(a[i],2),o=s[0],u=s[1],c=$m(Rm(u),n[o]),l=Qa.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"valid ".concat(r,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(r,' (key "').concat(o,'" is ').concat(v,")")]}return[!0]})};function az(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=sz(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
68
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function sz(e,r){if(e){if(typeof e=="string")return l_(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l_(e,r)}}function l_(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var oz=function(r,t){return $a(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=az(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Qa.default(a.value,2),o=s[0],u=s[1],c=$m(Rm(t),u),l=Qa.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})};Br.array=oz;Br.custom=$a;Br.literal=K6;Br.nonEmptyString=J6;Br.nonNegativeInteger=Y6;Br.objectSchema=iz;Br.pureObject=X6;Br.runtimeTypeValidation=lf;Br.stringifyReceivedType=qE;Br.type=BE;Br.validateConstructorTypes=tz;Br.validateTypes=rz;Br.validateTypesAsync=nz;var uz=wm,cz=PE;uz("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},cz);var zE={exports:{}};(function(e,r){(function(n,i){e.exports=i()})(Ae,function(){return function(t){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return t[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,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(t,n,i){t.exports=function(a,s){var o,u,c;for(o=1;o<arguments.length;o++){u=arguments[o];for(c in u)u.hasOwnProperty(c)&&(a[c]=u[c])}return a}},function(t,n,i){var a=i(0);t.exports={build:function(s,o){var u,c,l,h=o.plugins;for(u=0,c=h.length;u<c;u++)l=h[u],l.methods&&a(s,l.methods),l.properties&&Object.defineProperties(s,l.properties)},hook:function(s,o,u){var c,l,h,v,m=s.config.plugins,_=[s.context];for(u&&(_=_.concat(u)),c=0,l=m.length;c<l;c++)v=m[c],h=m[c][o],h&&h.apply(v,_)}}},function(t,n,i){function a(s){if(s.length===0)return s;var o,u,c=s.split(/[_-]/);if(c.length===1&&c[0][0].toLowerCase()===c[0][0])return s;for(u=c[0].toLowerCase(),o=1;o<c.length;o++)u=u+c[o].charAt(0).toUpperCase()+c[o].substring(1).toLowerCase();return u}a.prepended=function(s,o){return o=a(o),s+o[0].toUpperCase()+o.substring(1)},t.exports=a},function(t,n,i){var a=i(0),s=i(2);function o(u,c){u=u||{},this.options=u,this.defaults=c.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,c.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 c=u.name,l=u.from,h=u.to;return this.addState(l),typeof h!="function"&&this.addState(h),this.addTransition(c),this.map[l][c]=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,c){u=u||[];var l,h,v;for(l=0,h=u.length;l<h;l++)v=u[l],typeof v=="function"&&(u[l]=v=v()),v.configure&&v.configure(this);return u},configureTransitions:function(u){var c,l,h,v,m,_=this.defaults.wildcard;for(l=0;l<u.length;l++)for(h=u[l],v=Array.isArray(h.from)?h.from:[h.from||_],m=h.to||_,c=0;c<v.length;c++)this.mapTransition({name:h.name,from:v[c],to:m})},transitionFor:function(u,c){var l=this.defaults.wildcard;return this.map[u][c]||this.map[l][c]},transitionsFor:function(u){var c=this.defaults.wildcard;return Object.keys(this.map[u]).concat(Object.keys(this.map[c]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),t.exports=o},function(t,n,i){var a=i(0),s=i(6),o=i(1),u=[null,[]];function c(l,h){this.context=l,this.config=h,this.state=h.init.from,this.observers=[l]}a(c.prototype,{init:function(l){if(a(this.context,this.config.data.apply(this.context,l)),o.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(l){return Array.isArray(l)?l.indexOf(this.state)>=0:this.state===l},isPending:function(){return this.pending},can:function(l){return!this.isPending()&&!!this.seek(l)},cannot:function(l){return!this.can(l)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(l,h){var v=this.config.defaults.wildcard,m=this.config.transitionFor(this.state,l),_=m&&m.to;return typeof _=="function"?_.apply(this.context,h):_===v?this.state:_},fire:function(l,h){return this.transit(l,this.state,this.seek(l,h),h)},transit:function(l,h,v,m){var _=this.config.lifecycle,C=this.config.options.observeUnchangedState||h!==v;return v?this.isPending()?this.context.onPendingTransition(l,h,v):(this.config.addState(v),this.beginTransit(),m.unshift({transition:l,from:h,to:v,fsm:this.context}),this.observeEvents([this.observersForEvent(_.onBefore.transition),this.observersForEvent(_.onBefore[l]),C?this.observersForEvent(_.onLeave.state):u,C?this.observersForEvent(_.onLeave[h]):u,this.observersForEvent(_.on.transition),C?["doTransit",[this]]:u,C?this.observersForEvent(_.onEnter.state):u,C?this.observersForEvent(_.onEnter[v]):u,C?this.observersForEvent(_.on[v]):u,this.observersForEvent(_.onAfter.transition),this.observersForEvent(_.onAfter[l]),this.observersForEvent(_.on[l])],m)):this.context.onInvalidTransition(l,h,v)},beginTransit:function(){this.pending=!0},endTransit:function(l){return this.pending=!1,l},failTransit:function(l){throw this.pending=!1,l},doTransit:function(l){this.state=l.to},observe:function(l){if(l.length===2){var h={};h[l[0]]=l[1],this.observers.push(h)}else this.observers.push(l[0])},observersForEvent:function(l){for(var h=0,v=this.observers.length,m,_=[];h<v;h++)m=this.observers[h],m[l]&&_.push(m);return[l,_,!0]},observeEvents:function(l,h,v,m){if(l.length===0)return this.endTransit(m===void 0?!0:m);var _=l[0][0],C=l[0][1],I=l[0][2];if(h[0].event=_,_&&I&&_!==v&&o.hook(this,"lifecycle",h),C.length===0)return l.shift(),this.observeEvents(l,h,_,m);var $=C.shift(),x=$[_].apply($,h);return x&&typeof x.then=="function"?x.then(this.observeEvents.bind(this,l,h,_)).catch(this.failTransit.bind(this)):x===!1?this.endTransit(!1):this.observeEvents(l,h,_,x)},onInvalidTransition:function(l,h,v){throw new s("transition is invalid in current state",l,h,v,this.state)},onPendingTransition:function(l,h,v){throw new s("transition is invalid while previous transition is still in progress",l,h,v,this.state)}}),t.exports=c},function(t,n,i){var a=i(0),s=i(2),o=i(1),u=i(3),c=i(4),l={is:function(I){return this._fsm.is(I)},can:function(I){return this._fsm.can(I)},cannot:function(I){return this._fsm.cannot(I)},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(I,$,x){return this._fsm.onInvalidTransition(I,$,x)},onPendingTransition:function(I,$,x){return this._fsm.onPendingTransition(I,$,x)}},h={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(I){throw Error("use transitions to change state")}}};function v(I){return _(this||{},I)}function m(){var I,$;typeof arguments[0]=="function"?(I=arguments[0],$=arguments[1]||{}):(I=function(){this._fsm.apply(this,arguments)},$=arguments[0]||{});var x=new u($,v);return C(I.prototype,x),I.prototype._fsm.config=x,I}function _(I,$){var x=new u($,v);return C(I,x),I._fsm(),I}function C(I,$){if(typeof I!="object"||Array.isArray(I))throw Error("StateMachine can only be applied to objects");o.build(I,$),Object.defineProperties(I,h),a(I,l),a(I,$.methods),$.allTransitions().forEach(function(x){I[s(x)]=function(){return this._fsm.fire(x,[].slice.call(arguments))}}),I._fsm=function(){this._fsm=new c(this,$),this._fsm.init(arguments)}}v.version="3.0.1",v.factory=m,v.apply=_,v.defaults={wildcard:"*",init:{name:"init",from:"none"}},t.exports=v},function(t,n,i){t.exports=function(a,s,o,u,c){this.message=a,this.transition=s,this.from=o,this.to=u,this.current=c}}])})})(zE);var lz=zE.exports,dh={exports:{}},f_=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(f_){var d_=new Uint8Array(16);dh.exports=function(){return f_(d_),d_}}else{var p_=new Array(16);dh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),p_[r]=t>>>((r&3)<<3)&255;return p_}}var WE=dh.exports,VE=[];for(var oc=0;oc<256;++oc)VE[oc]=(oc+256).toString(16).substr(1);function fz(e,r){var t=r||0,n=VE;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var GE=fz,dz=WE,pz=GE,h_,xd,Nd=0,Ld=0;function hz(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||h_,s=e.clockseq!==void 0?e.clockseq:xd;if(a==null||s==null){var o=dz();a==null&&(a=h_=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=xd=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Ld+1,l=u-Nd+(c-Ld)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>Nd)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Nd=u,Ld=c,xd=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||pz(i)}var vz=hz,mz=WE,gz=GE;function yz(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||mz)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||gz(i)}var bz=yz,_z=vz,HE=bz,Im=HE;Im.v1=_z;Im.v4=HE;var wz=Im,ph={exports:{}},KE=typeof ArrayBuffer<"u"&&typeof DataView<"u",Sz=KE,JE=Wt,fn=_t,YE=Ut,Om=Jt,Zo=tr,XE=Vi,Cz=rs,Tz=zi,Ez=Ur,kz=hi,Rz=qi,ff=Tu,Ru=so,$z=Bt,Iz=su,QE=pn,ZE=QE.enforce,Oz=QE.get,yl=fn.Int8Array,hh=yl&&yl.prototype,v_=fn.Uint8ClampedArray,m_=v_&&v_.prototype,Ha=yl&&ff(yl),zn=hh&&ff(hh),Pz=Object.prototype,Pm=fn.TypeError,g_=$z("toStringTag"),vh=Iz("TYPED_ARRAY_TAG"),bl="TypedArrayConstructor",_a=Sz&&!!Ru&&XE(fn.opera)!=="Opera",ek=!1,Yr,la,js,lo={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},tk={BigInt64Array:8,BigUint64Array:8},rk=function(e){var r=ff(e);if(Om(r)){var t=Oz(r);return t&&Zo(t,bl)?t[bl]:rk(r)}},nk=function(e){if(!Om(e))return!1;var r=XE(e);return Zo(lo,r)||Zo(tk,r)},Az=function(e){if(nk(e))return e;throw new Pm("Target is not a typed array")},Mz=function(e){if(YE(e)&&(!Ru||Rz(Ha,e)))return e;throw new Pm(Cz(e)+" is not a typed array constructor")},xz=function(e,r,t,n){if(JE){if(t)for(var i in lo){var a=fn[i];if(a&&Zo(a.prototype,e))try{delete a.prototype[e]}catch{try{a.prototype[e]=r}catch{}}}(!zn[e]||t)&&Ez(zn,e,t?r:_a&&hh[e]||r,n)}};for(Yr in lo)la=fn[Yr],js=la&&la.prototype,js?ZE(js)[bl]=la:_a=!1;for(Yr in tk)la=fn[Yr],js=la&&la.prototype,js&&(ZE(js)[bl]=la);if((!_a||!YE(Ha)||Ha===Function.prototype)&&(Ha=function(){throw new Pm("Incorrect invocation")},_a))for(Yr in lo)fn[Yr]&&Ru(fn[Yr],Ha);if((!_a||!zn||zn===Pz)&&(zn=Ha.prototype,_a))for(Yr in lo)fn[Yr]&&Ru(fn[Yr].prototype,zn);_a&&ff(m_)!==zn&&Ru(m_,zn);if(JE&&!Zo(zn,g_)){ek=!0,kz(zn,g_,{configurable:!0,get:function(){return Om(this)?this[vh]:void 0}});for(Yr in lo)fn[Yr]&&Tz(fn[Yr],vh,Yr)}var Vt={NATIVE_ARRAY_BUFFER_VIEWS:_a,TYPED_ARRAY_TAG:ek&&vh,aTypedArray:Az,aTypedArrayConstructor:Mz,exportTypedArrayMethod:xz,getTypedArrayConstructor:rk,isTypedArray:nk,TypedArray:Ha,TypedArrayPrototype:zn},ik=_t,Dd=lt,Nz=Kl,Lz=Vt.NATIVE_ARRAY_BUFFER_VIEWS,Dz=ik.ArrayBuffer,Ba=ik.Int8Array,jz=!Lz||!Dd(function(){Ba(1)})||!Dd(function(){new Ba(-1)})||!Nz(function(e){new Ba,new Ba(null),new Ba(1.5),new Ba(e)},!0)||Dd(function(){return new Ba(new Dz(2),1,void 0).length!==1}),Fz=fi,Uz=Wi,Bz=RangeError,ak=function(e){if(e===void 0)return 0;var r=Fz(e),t=Uz(r);if(r!==t)throw new Bz("Wrong length or index");return t},qz=Math.sign||function(r){var t=+r;return t===0||t!==t?t:t<0?-1:1},zz=qz,Wz=Math.abs,sk=2220446049250313e-31,y_=1/sk,Vz=function(e){return e+y_-y_},Gz=function(e,r,t,n){var i=+e,a=Wz(i),s=zz(i);if(a<n)return s*Vz(a/n/r)*n*r;var o=(1+r/sk)*a,u=o-(o-a);return u>t||u!==u?s*(1/0):s*u},Hz=Gz,Kz=11920928955078125e-23,Jz=34028234663852886e22,Yz=11754943508222875e-54,Xz=Math.fround||function(r){return Hz(r,Kz,Jz,Yz)},Qz=Array,Zz=Math.abs,Pi=Math.pow,eW=Math.floor,tW=Math.log,rW=Math.LN2,nW=function(e,r,t){var n=Qz(t),i=t*8-r-1,a=(1<<i)-1,s=a>>1,o=r===23?Pi(2,-24)-Pi(2,-77):0,u=e<0||e===0&&1/e<0?1:0,c=0,l,h,v;for(e=Zz(e),e!==e||e===1/0?(h=e!==e?1:0,l=a):(l=eW(tW(e)/rW),v=Pi(2,-l),e*v<1&&(l--,v*=2),l+s>=1?e+=o/v:e+=o*Pi(2,1-s),e*v>=2&&(l++,v/=2),l+s>=a?(h=0,l=a):l+s>=1?(h=(e*v-1)*Pi(2,r),l+=s):(h=e*Pi(2,s-1)*Pi(2,r),l=0));r>=8;)n[c++]=h&255,h/=256,r-=8;for(l=l<<r|h,i+=r;i>0;)n[c++]=l&255,l/=256,i-=8;return n[c-1]|=u*128,n},iW=function(e,r){var t=e.length,n=t*8-r-1,i=(1<<n)-1,a=i>>1,s=n-7,o=t-1,u=e[o--],c=u&127,l;for(u>>=7;s>0;)c=c*256+e[o--],s-=8;for(l=c&(1<<-s)-1,c>>=-s,s+=r;s>0;)l=l*256+e[o--],s-=8;if(c===0)c=1-a;else{if(c===i)return l?NaN:u?-1/0:1/0;l+=Pi(2,r),c-=a}return(u?-1:1)*l*Pi(2,c-r)},aW={pack:nW,unpack:iW},sW=Mr,b_=as,oW=xr,ok=function(r){for(var t=sW(this),n=oW(t),i=arguments.length,a=b_(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,o=s===void 0?n:b_(s,n);o>a;)t[a++]=r;return t},df=_t,Am=vt,jd=Wt,uW=KE,uk=ou,cW=zi,lW=hi,__=uf,Fd=lt,uc=ka,fW=fi,dW=Wi,_l=ak,pW=Xz,ck=aW,hW=Tu,w_=so,vW=ok,mW=pi,gW=Yl,yW=Ov,lk=di,Mm=pn,bW=uk.PROPER,S_=uk.CONFIGURABLE,Fs="ArrayBuffer",pf="DataView",Us="prototype",_W="Wrong length",fk="Wrong index",C_=Mm.getterFor(Fs),qo=Mm.getterFor(pf),T_=Mm.set,Fn=df[Fs],cn=Fn,bs=cn&&cn[Us],ii=df[pf],qa=ii&&ii[Us],E_=Object.prototype,wW=df.Array,wl=df.RangeError,SW=Am(vW),CW=Am([].reverse),dk=ck.pack,k_=ck.unpack,R_=function(e){return[e&255]},$_=function(e){return[e&255,e>>8&255]},I_=function(e){return[e&255,e>>8&255,e>>16&255,e>>24&255]},O_=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},TW=function(e){return dk(pW(e),23,4)},EW=function(e){return dk(e,52,8)},cc=function(e,r,t){lW(e[Us],r,{configurable:!0,get:function(){return t(this)[r]}})},sa=function(e,r,t,n){var i=qo(e),a=_l(t),s=!!n;if(a+r>i.byteLength)throw new wl(fk);var o=i.bytes,u=a+i.byteOffset,c=mW(o,u,u+r);return s?c:CW(c)},oa=function(e,r,t,n,i,a){var s=qo(e),o=_l(t),u=n(+i),c=!!a;if(o+r>s.byteLength)throw new wl(fk);for(var l=s.bytes,h=o+s.byteOffset,v=0;v<r;v++)l[h+v]=u[c?v:r-v-1]};if(!uW)cn=function(r){uc(this,bs);var t=_l(r);T_(this,{type:Fs,bytes:SW(wW(t),0),byteLength:t}),jd||(this.byteLength=t,this.detached=!1)},bs=cn[Us],ii=function(r,t,n){uc(this,qa),uc(r,bs);var i=C_(r),a=i.byteLength,s=fW(t);if(s<0||s>a)throw new wl("Wrong offset");if(n=n===void 0?a-s:dW(n),s+n>a)throw new wl(_W);T_(this,{type:pf,buffer:r,byteLength:n,byteOffset:s,bytes:i.bytes}),jd||(this.buffer=r,this.byteLength=n,this.byteOffset=s)},qa=ii[Us],jd&&(cc(cn,"byteLength",C_),cc(ii,"buffer",qo),cc(ii,"byteLength",qo),cc(ii,"byteOffset",qo)),__(qa,{getInt8:function(r){return sa(this,1,r)[0]<<24>>24},getUint8:function(r){return sa(this,1,r)[0]},getInt16:function(r){var t=sa(this,2,r,arguments.length>1?arguments[1]:!1);return(t[1]<<8|t[0])<<16>>16},getUint16:function(r){var t=sa(this,2,r,arguments.length>1?arguments[1]:!1);return t[1]<<8|t[0]},getInt32:function(r){return O_(sa(this,4,r,arguments.length>1?arguments[1]:!1))},getUint32:function(r){return O_(sa(this,4,r,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(r){return k_(sa(this,4,r,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(r){return k_(sa(this,8,r,arguments.length>1?arguments[1]:!1),52)},setInt8:function(r,t){oa(this,1,r,R_,t)},setUint8:function(r,t){oa(this,1,r,R_,t)},setInt16:function(r,t){oa(this,2,r,$_,t,arguments.length>2?arguments[2]:!1)},setUint16:function(r,t){oa(this,2,r,$_,t,arguments.length>2?arguments[2]:!1)},setInt32:function(r,t){oa(this,4,r,I_,t,arguments.length>2?arguments[2]:!1)},setUint32:function(r,t){oa(this,4,r,I_,t,arguments.length>2?arguments[2]:!1)},setFloat32:function(r,t){oa(this,4,r,TW,t,arguments.length>2?arguments[2]:!1)},setFloat64:function(r,t){oa(this,8,r,EW,t,arguments.length>2?arguments[2]:!1)}});else{var P_=bW&&Fn.name!==Fs;!Fd(function(){Fn(1)})||!Fd(function(){new Fn(-1)})||Fd(function(){return new Fn,new Fn(1.5),new Fn(NaN),Fn.length!==1||P_&&!S_})?(cn=function(r){return uc(this,bs),gW(new Fn(_l(r)),this,cn)},cn[Us]=bs,bs.constructor=cn,yW(cn,Fn)):P_&&S_&&cW(Fn,"name",Fs),w_&&hW(qa)!==E_&&w_(qa,E_);var lc=new ii(new cn(2)),A_=Am(qa.setInt8);lc.setInt8(0,2147483648),lc.setInt8(1,2147483649),(lc.getInt8(0)||!lc.getInt8(1))&&__(qa,{setInt8:function(r,t){A_(this,r,t<<24>>24)},setUint8:function(r,t){A_(this,r,t<<24>>24)}},{unsafe:!0})}lk(cn,Fs);lk(ii,pf);var pk={ArrayBuffer:cn,DataView:ii},kW=fi,RW=RangeError,$W=function(e){var r=kW(e);if(r<0)throw new RW("The argument can't be less than 0");return r},IW=$W,OW=RangeError,hk=function(e,r){var t=IW(e);if(t%r)throw new OW("Wrong offset");return t},PW=Math.round,AW=function(e){var r=PW(e);return r<0?0:r>255?255:r&255},MW=Vi,xW=function(e){var r=MW(e);return r==="BigInt64Array"||r==="BigUint64Array"},NW=Ev,LW=TypeError,vk=function(e){var r=NW(e,"number");if(typeof r=="number")throw new LW("Can't convert number to bigint");return BigInt(r)},DW=Gi,jW=Ft,FW=Mv,UW=Mr,BW=xr,qW=Hl,zW=wu,WW=Zv,VW=xW,GW=Vt.aTypedArrayConstructor,HW=vk,KW=function(r){var t=FW(this),n=UW(r),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,o=zW(n),u,c,l,h,v,m,_,C;if(o&&!WW(o))for(_=qW(n,o),C=_.next,n=[];!(m=jW(C,_)).done;)n.push(m.value);for(s&&i>2&&(a=DW(a,arguments[2])),c=BW(n),l=new(GW(t))(c),h=VW(l),u=0;c>u;u++)v=s?a(n[u],u):n[u],l[u]=h?HW(v):+v;return l},JW=xr,mk=function(e,r,t){for(var n=0,i=arguments.length>2?t:JW(r),a=new e(i);i>n;)a[n]=r[n++];return a},M_=gt,gk=_t,x_=Ft,YW=Wt,XW=jz,$u=Vt,yk=pk,N_=ka,QW=ts,To=zi,ZW=vE,e8=Wi,L_=ak,Ud=hk,t8=AW,bk=Al,Eo=tr,r8=Vi,mh=Jt,n8=io,i8=Ta,a8=qi,fc=so,s8=is.f,D_=KW,o8=Zr.forEach,u8=Wl,c8=hi,_k=Fr,wk=Bi,j_=mk,xm=pn,l8=Yl,gh=xm.get,f8=xm.set,d8=xm.enforce,Sk=_k.f,p8=wk.f,Bd=gk.RangeError,Ck=yk.ArrayBuffer,h8=Ck.prototype,v8=yk.DataView,dc=$u.NATIVE_ARRAY_BUFFER_VIEWS,F_=$u.TYPED_ARRAY_TAG,U_=$u.TypedArray,ko=$u.TypedArrayPrototype,yh=$u.isTypedArray,pc="BYTES_PER_ELEMENT",qd="Wrong length",hc=function(e,r){c8(e,r,{configurable:!0,get:function(){return gh(this)[r]}})},B_=function(e){var r;return a8(h8,e)||(r=r8(e))==="ArrayBuffer"||r==="SharedArrayBuffer"},Tk=function(e,r){return yh(e)&&!n8(r)&&r in e&&ZW(+r)&&r>=0},q_=function(r,t){return t=bk(t),Tk(r,t)?QW(2,r[t]):p8(r,t)},z_=function(r,t,n){return t=bk(t),Tk(r,t)&&mh(n)&&Eo(n,"value")&&!Eo(n,"get")&&!Eo(n,"set")&&!n.configurable&&(!Eo(n,"writable")||n.writable)&&(!Eo(n,"enumerable")||n.enumerable)?(r[t]=n.value,r):Sk(r,t,n)};YW?(dc||(wk.f=q_,_k.f=z_,hc(ko,"buffer"),hc(ko,"byteOffset"),hc(ko,"byteLength"),hc(ko,"length")),M_({target:"Object",stat:!0,forced:!dc},{getOwnPropertyDescriptor:q_,defineProperty:z_}),ph.exports=function(e,r,t){var n=e.match(/\d+/)[0]/8,i=e+(t?"Clamped":"")+"Array",a="get"+e,s="set"+e,o=gk[i],u=o,c=u&&u.prototype,l={},h=function(C,I){var $=gh(C);return $.view[a](I*n+$.byteOffset,!0)},v=function(C,I,$){var x=gh(C);x.view[s](I*n+x.byteOffset,t?t8($):$,!0)},m=function(C,I){Sk(C,I,{get:function(){return h(this,I)},set:function($){return v(this,I,$)},enumerable:!0})};dc?XW&&(u=r(function(C,I,$,x){return N_(C,c),l8(function(){return mh(I)?B_(I)?x!==void 0?new o(I,Ud($,n),x):$!==void 0?new o(I,Ud($,n)):new o(I):yh(I)?j_(u,I):x_(D_,u,I):new o(L_(I))}(),C,u)}),fc&&fc(u,U_),o8(s8(o),function(C){C in u||To(u,C,o[C])}),u.prototype=c):(u=r(function(C,I,$,x){N_(C,c);var N=0,q=0,X,J,G;if(!mh(I))G=L_(I),J=G*n,X=new Ck(J);else if(B_(I)){X=I,q=Ud($,n);var L=I.byteLength;if(x===void 0){if(L%n)throw new Bd(qd);if(J=L-q,J<0)throw new Bd(qd)}else if(J=e8(x)*n,J+q>L)throw new Bd(qd);G=J/n}else return yh(I)?j_(u,I):x_(D_,u,I);for(f8(C,{buffer:X,byteOffset:q,byteLength:J,length:G,view:new v8(X)});N<G;)m(C,N++)}),fc&&fc(u,U_),c=u.prototype=i8(ko)),c.constructor!==u&&To(c,"constructor",u),d8(c).TypedArrayConstructor=u,F_&&To(c,F_,i);var _=u!==o;l[i]=u,M_({global:!0,constructor:!0,forced:_,sham:!dc},l),pc in u||To(u,pc,n),pc in c||To(c,pc,n),u8(i)}):ph.exports=function(){};var m8=ph.exports,g8=m8;g8("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var W_=rs,y8=TypeError,Nm=function(e,r){if(!delete e[r])throw new y8("Cannot delete property "+W_(r)+" of "+W_(e))},b8=Mr,zd=as,_8=xr,w8=Nm,S8=Math.min,C8=[].copyWithin||function(r,t){var n=b8(this),i=_8(n),a=zd(r,i),s=zd(t,i),o=arguments.length>2?arguments[2]:void 0,u=S8((o===void 0?i:zd(o,i))-s,i-a),c=1;for(s<a&&a<s+u&&(c=-1,s+=u-1,a+=u-1);u-- >0;)s in n?n[a]=n[s]:w8(n,a),a+=c,s+=c;return n},T8=vt,Ek=Vt,E8=C8,k8=T8(E8),R8=Ek.aTypedArray,$8=Ek.exportTypedArrayMethod;$8("copyWithin",function(r,t){return k8(R8(this),r,t,arguments.length>2?arguments[2]:void 0)});var kk=Vt,I8=Zr.every,O8=kk.aTypedArray,P8=kk.exportTypedArrayMethod;P8("every",function(r){return I8(O8(this),r,arguments.length>1?arguments[1]:void 0)});var Rk=Vt,A8=ok,M8=vk,x8=Vi,N8=Ft,L8=vt,D8=lt,j8=Rk.aTypedArray,F8=Rk.exportTypedArrayMethod,U8=L8("".slice),B8=D8(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1});F8("fill",function(r){var t=arguments.length;j8(this);var n=U8(x8(this),0,3)==="Big"?M8(r):+r;return N8(A8,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},B8);var q8=mk,z8=Vt.getTypedArrayConstructor,W8=function(e,r){return q8(z8(e),r)},$k=Vt,V8=Zr.filter,G8=W8,H8=$k.aTypedArray,K8=$k.exportTypedArrayMethod;K8("filter",function(r){var t=V8(H8(this),r,arguments.length>1?arguments[1]:void 0);return G8(this,t)});var Ik=Vt,J8=Zr.find,Y8=Ik.aTypedArray,X8=Ik.exportTypedArrayMethod;X8("find",function(r){return J8(Y8(this),r,arguments.length>1?arguments[1]:void 0)});var Ok=Vt,Q8=Zr.findIndex,Z8=Ok.aTypedArray,e5=Ok.exportTypedArrayMethod;e5("findIndex",function(r){return Q8(Z8(this),r,arguments.length>1?arguments[1]:void 0)});var Pk=Vt,t5=Zr.forEach,r5=Pk.aTypedArray,n5=Pk.exportTypedArrayMethod;n5("forEach",function(r){t5(r5(this),r,arguments.length>1?arguments[1]:void 0)});var Ak=Vt,i5=Nl.includes,a5=Ak.aTypedArray,s5=Ak.exportTypedArrayMethod;s5("includes",function(r){return i5(a5(this),r,arguments.length>1?arguments[1]:void 0)});var Mk=Vt,o5=Nl.indexOf,u5=Mk.aTypedArray,c5=Mk.exportTypedArrayMethod;c5("indexOf",function(r){return o5(u5(this),r,arguments.length>1?arguments[1]:void 0)});var l5=_t,f5=lt,Lm=vt,xk=Vt,Dm=qT,d5=Bt,jm=d5("iterator"),V_=l5.Uint8Array,p5=Lm(Dm.values),h5=Lm(Dm.keys),v5=Lm(Dm.entries),Fm=xk.aTypedArray,hf=xk.exportTypedArrayMethod,Rs=V_&&V_.prototype,vf=!f5(function(){Rs[jm].call([1])}),Nk=!!Rs&&Rs.values&&Rs[jm]===Rs.values&&Rs.values.name==="values",Lk=function(){return p5(Fm(this))};hf("entries",function(){return v5(Fm(this))},vf);hf("keys",function(){return h5(Fm(this))},vf);hf("values",Lk,vf||!Nk,{name:"values"});hf(jm,Lk,vf||!Nk,{name:"values"});var Dk=Vt,m5=vt,g5=Dk.aTypedArray,y5=Dk.exportTypedArrayMethod,b5=m5([].join);y5("join",function(r){return b5(g5(this),r)});var _5=ss,w5=dn,S5=fi,C5=xr,T5=zl,E5=Math.min,bh=[].lastIndexOf,jk=!!bh&&1/[1].lastIndexOf(1,-0)<0,k5=T5("lastIndexOf"),R5=jk||!k5,$5=R5?function(r){if(jk)return _5(bh,this,arguments)||0;var t=w5(this),n=C5(t);if(n===0)return-1;var i=n-1;for(arguments.length>1&&(i=E5(i,S5(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===r)return i||0;return-1}:bh,Fk=Vt,I5=ss,O5=$5,P5=Fk.aTypedArray,A5=Fk.exportTypedArrayMethod;A5("lastIndexOf",function(r){var t=arguments.length;return I5(O5,P5(this),t>1?[r,arguments[1]]:[r])});var Um=Vt,M5=Zr.map,x5=Um.aTypedArray,N5=Um.getTypedArrayConstructor,L5=Um.exportTypedArrayMethod;L5("map",function(r){return M5(x5(this),r,arguments.length>1?arguments[1]:void 0,function(t,n){return new(N5(t))(n)})});var D5=In,j5=Mr,F5=au,U5=xr,G_=TypeError,H_="Reduce of empty array with no initial value",K_=function(e){return function(r,t,n,i){var a=j5(r),s=F5(a),o=U5(a);if(D5(t),o===0&&n<2)throw new G_(H_);var u=e?o-1:0,c=e?-1:1;if(n<2)for(;;){if(u in s){i=s[u],u+=c;break}if(u+=c,e?u<0:o<=u)throw new G_(H_)}for(;e?u>=0:o>u;u+=c)u in s&&(i=t(i,s[u],u,a));return i}},Uk={left:K_(!1),right:K_(!0)},Bk=Vt,B5=Uk.left,q5=Bk.aTypedArray,z5=Bk.exportTypedArrayMethod;z5("reduce",function(r){var t=arguments.length;return B5(q5(this),r,t,t>1?arguments[1]:void 0)});var qk=Vt,W5=Uk.right,V5=qk.aTypedArray,G5=qk.exportTypedArrayMethod;G5("reduceRight",function(r){var t=arguments.length;return W5(V5(this),r,t,t>1?arguments[1]:void 0)});var zk=Vt,H5=zk.aTypedArray,K5=zk.exportTypedArrayMethod,J5=Math.floor;K5("reverse",function(){for(var r=this,t=H5(r).length,n=J5(t/2),i=0,a;i<n;)a=r[i],r[i++]=r[--t],r[t]=a;return r});var Wk=_t,Vk=Ft,Bm=Vt,Y5=xr,X5=hk,Q5=Mr,Gk=lt,Z5=Wk.RangeError,_h=Wk.Int8Array,J_=_h&&_h.prototype,Hk=J_&&J_.set,eV=Bm.aTypedArray,tV=Bm.exportTypedArrayMethod,wh=!Gk(function(){var e=new Uint8ClampedArray(2);return Vk(Hk,e,{length:1,0:3},1),e[1]!==3}),rV=wh&&Bm.NATIVE_ARRAY_BUFFER_VIEWS&&Gk(function(){var e=new _h(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});tV("set",function(r){eV(this);var t=X5(arguments.length>1?arguments[1]:void 0,1),n=Q5(r);if(wh)return Vk(Hk,this,n,t);var i=this.length,a=Y5(n),s=0;if(a+t>i)throw new Z5("Wrong length");for(;s<a;)this[t+s]=n[s++]},!wh||rV);var qm=Vt,nV=lt,iV=pi,aV=qm.aTypedArray,sV=qm.getTypedArrayConstructor,oV=qm.exportTypedArrayMethod,uV=nV(function(){new Int8Array(1).slice()});oV("slice",function(r,t){for(var n=iV(aV(this),r,t),i=sV(this),a=0,s=n.length,o=new i(s);s>a;)o[a]=n[a++];return o},uV);var Kk=Vt,cV=Zr.some,lV=Kk.aTypedArray,fV=Kk.exportTypedArrayMethod;fV("some",function(r){return cV(lV(this),r,arguments.length>1?arguments[1]:void 0)});var Y_=pi,dV=Math.floor,Sh=function(e,r){var t=e.length;if(t<8)for(var n=1,i,a;n<t;){for(a=n,i=e[n];a&&r(e[a-1],i)>0;)e[a]=e[--a];a!==n++&&(e[a]=i)}else for(var s=dV(t/2),o=Sh(Y_(e,0,s),r),u=Sh(Y_(e,s),r),c=o.length,l=u.length,h=0,v=0;h<c||v<l;)e[h+v]=h<c&&v<l?r(o[h],u[v])<=0?o[h++]:u[v++]:h<c?o[h++]:u[v++];return e},zm=Sh,pV=Ca,X_=pV.match(/firefox\/(\d+)/i),Jk=!!X_&&+X_[1],hV=Ca,Yk=/MSIE|Trident/.test(hV),vV=Ca,Q_=vV.match(/AppleWebKit\/(\d+)\./),Xk=!!Q_&&+Q_[1],mV=_t,gV=jv,Ch=lt,yV=In,bV=zm,Qk=Vt,Z_=Jk,_V=Yk,ew=ro,tw=Xk,wV=Qk.aTypedArray,SV=Qk.exportTypedArrayMethod,eu=mV.Uint16Array,Bs=eu&&gV(eu.prototype.sort),CV=!!Bs&&!(Ch(function(){Bs(new eu(2),null)})&&Ch(function(){Bs(new eu(2),{})})),rw=!!Bs&&!Ch(function(){if(ew)return ew<74;if(Z_)return Z_<67;if(_V)return!0;if(tw)return tw<602;var e=new eu(516),r=Array(516),t,n;for(t=0;t<516;t++)n=t%4,e[t]=515-t,r[t]=t-2*n+3;for(Bs(e,function(i,a){return(i/4|0)-(a/4|0)}),t=0;t<516;t++)if(e[t]!==r[t])return!0}),TV=function(e){return function(r,t){return e!==void 0?+e(r,t)||0:t!==t?-1:r!==r?1:r===0&&t===0?1/r>0&&1/t<0?1:-1:r>t}};SV("sort",function(r){return r!==void 0&&yV(r),rw?Bs(this,r):bV(wV(this),TV(r))},!rw||CV);var Wm=Vt,EV=Wi,nw=as,kV=Wm.aTypedArray,RV=Wm.getTypedArrayConstructor,$V=Wm.exportTypedArrayMethod;$V("subarray",function(r,t){var n=kV(this),i=n.length,a=nw(r,i),s=RV(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,EV((t===void 0?i:nw(t,i))-a))});var IV=_t,OV=ss,Zk=Vt,Th=lt,iw=pi,Sl=IV.Int8Array,aw=Zk.aTypedArray,PV=Zk.exportTypedArrayMethod,eR=[].toLocaleString,AV=!!Sl&&Th(function(){eR.call(new Sl(1))}),MV=Th(function(){return[1,2].toLocaleString()!==new Sl([1,2]).toLocaleString()})||!Th(function(){Sl.prototype.toLocaleString.call([1,2])});PV("toLocaleString",function(){return OV(eR,AV?iw(aw(this)):aw(this),iw(arguments))},MV);var xV=Vt.exportTypedArrayMethod,NV=lt,LV=_t,DV=vt,sw=LV.Uint8Array,jV=sw&&sw.prototype||{},Cl=[].toString,FV=DV([].join);NV(function(){Cl.call({})})&&(Cl=function(){return FV(this)});var UV=jV.toString!==Cl;xV("toString",Cl,UV);var Wd=Ft,tR=vt,BV=ef,qV=ar,zV=Hn,WV=Kn,VV=rT,GV=pm,HV=Wi,ow=wr,KV=ns,uw=tf,JV=XT,YV=lt,_s=JV.UNSUPPORTED_Y,XV=4294967295,QV=Math.min,Vd=tR([].push),Gd=tR("".slice),ZV=!YV(function(){var e=/(?:)/,r=e.exec;e.exec=function(){return r.apply(this,arguments)};var t="ab".split(e);return t.length!==2||t[0]!=="a"||t[1]!=="b"}),cw="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;BV("split",function(e,r,t){var n="0".split(void 0,0).length?function(i,a){return i===void 0&&a===0?[]:Wd(r,this,i,a)}:r;return[function(a,s){var o=WV(this),u=zV(a)?void 0:KV(a,e);return u?Wd(u,a,o,s):Wd(n,ow(o),a,s)},function(i,a){var s=qV(this),o=ow(i);if(!cw){var u=t(n,s,o,a,n!==r);if(u.done)return u.value}var c=VV(s,RegExp),l=s.unicode,h=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(_s?"g":"y"),v=new c(_s?"^(?:"+s.source+")":s,h),m=a===void 0?XV:a>>>0;if(m===0)return[];if(o.length===0)return uw(v,o)===null?[o]:[];for(var _=0,C=0,I=[];C<o.length;){v.lastIndex=_s?0:C;var $=uw(v,_s?Gd(o,C):o),x;if($===null||(x=QV(HV(v.lastIndex+(_s?C:0)),o.length))===_)C=GV(o,C,l);else{if(Vd(I,Gd(o,_,C)),I.length===m)return I;for(var N=1;N<=$.length-1;N++)if(Vd(I,$[N]),I.length===m)return I;C=_=x}}return Vd(I,Gd(o,_)),I}]},cw||!ZV,_s);var rR={exports:{}},nR={exports:{}};(function(e){function r(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch{return typeof t=="function"}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(nR);var eG=nR.exports,iR={exports:{}},aR={exports:{}};(function(e){function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(e.exports=r=function(){return!!t},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(aR);var tG=aR.exports;(function(e){var r=tG,t=Wv;function n(i,a,s){if(r())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,a);var u=new(i.bind.apply(i,o));return s&&t(u,s.prototype),u}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(iR);var rG=iR.exports;(function(e){var r=Pn,t=Wv,n=eG,i=rG;function a(s){var o=typeof Map=="function"?new Map:void 0;return e.exports=a=function(c){if(c===null||!n(c))return c;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(c))return o.get(c);o.set(c,l)}function l(){return i(c,arguments,r(this).constructor)}return l.prototype=Object.create(c.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),t(l,c)},e.exports.__esModule=!0,e.exports.default=e.exports,a(s)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports})(rR);var mf=rR.exports,Tl={exports:{}};/*!
69
69
  * Platform.js v1.3.6
70
70
  * Copyright 2014-2020 Benjamin Tan
71
71
  * Copyright 2011-2013 John-David Dalton
72
72
  * Available under MIT license
73
- */Tl.exports;(function(e,r){(function(){var t={function:!0,object:!0},n=t[typeof window]&&window||this,i=r,a=e&&!e.nodeType&&e,s=i&&a&&typeof Ae=="object"&&Ae;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var o=Math.pow(2,53)-1,u=/\bOpera/,c=Object.prototype,l=c.hasOwnProperty,h=c.toString;function v(L){return L=String(L),L.charAt(0).toUpperCase()+L.slice(1)}function m(L,te,se){var ne={"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 te&&se&&/^Win/i.test(L)&&!/^Windows Phone /i.test(L)&&(ne=ne[/[\d.]+$/.exec(L)])&&(L="Windows "+ne),L=String(L),te&&se&&(L=L.replace(RegExp(te,"i"),se)),L=C(L.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]),L}function _(L,te){var se=-1,ne=L?L.length:0;if(typeof ne=="number"&&ne>-1&&ne<=o)for(;++se<ne;)te(L[se],se,L);else I(L,te)}function C(L){return L=X(L),/^(?:webOS|i(?:OS|P))/.test(L)?L:v(L)}function I(L,te){for(var se in L)l.call(L,se)&&te(L[se],se,L)}function $(L){return L==null?v(L):h.call(L).slice(8,-1)}function x(L,te){var se=L!=null?typeof L[te]:"number";return!/^(?:boolean|number|string|undefined)$/.test(se)&&(se=="object"?!!L[te]:!0)}function N(L){return String(L).replace(/([ -])(?!$)/g,"$1?")}function q(L,te){var se=null;return _(L,function(ne,ge){se=te(se,ne,ge,L)}),se}function X(L){return String(L).replace(/^ +| +$/g,"")}function J(L){var te=n,se=L&&typeof L=="object"&&$(L)!="String";se&&(te=L,L=null);var ne=te.navigator||{},ge=ne.userAgent||"";L||(L=ge);var Y=se?!!ne.likeChrome:/\bChrome\b/.test(L)&&!/internal|\n/i.test(h.toString()),Ue="Object",He=se?Ue:"ScriptBridgingProxyObject",Rt=se?Ue:"Environment",ft=se&&te.java?"JavaPackage":$(te.java),Pe=se?Ue:"RuntimeObject",he=/\bJava/.test(ft)&&te.java,pe=he&&$(te.environment)==Rt,M=he?"a":"α",Oe=he?"b":"β",Je=te.document||{},De=te.operamini||te.opera,we=u.test(we=se&&De?De["[[Class]]"]:$(De))?we:De=null,Q,$t=L,_e=[],le=null,St=L==ge,Le=St&&De&&typeof De.version=="function"&&De.version(),Gt,pt=Kt([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),ke=qt(["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"]),ot=Fe([{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"]),bt=dt({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}}),$e=rr(["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(Pt){return q(Pt,function(yt,it){return yt||RegExp("\\b"+(it.pattern||N(it))+"\\b","i").exec(L)&&(it.label||it)})}function dt(Pt){return q(Pt,function(yt,it,Mt){return yt||(it[ot]||it[/^[a-z]+(?: +[a-z]+\b)*/i.exec(ot)]||RegExp("\\b"+N(Mt)+"(?:\\b|\\w*\\d)","i").exec(L))&&Mt})}function qt(Pt){return q(Pt,function(yt,it){return yt||RegExp("\\b"+(it.pattern||N(it))+"\\b","i").exec(L)&&(it.label||it)})}function rr(Pt){return q(Pt,function(yt,it){var Mt=it.pattern||N(it);return!yt&&(yt=RegExp("\\b"+Mt+"(?:/[\\d.]+|[ \\w.]*)","i").exec(L))&&(yt=m(yt,Mt,it.label||it)),yt})}function Fe(Pt){return q(Pt,function(yt,it){var Mt=it.pattern||N(it);return!yt&&(yt=RegExp("\\b"+Mt+" *\\d+[.\\w_]*","i").exec(L)||RegExp("\\b"+Mt+" *\\w+-[\\w]*","i").exec(L)||RegExp("\\b"+Mt+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(L))&&((yt=String(it.label&&!RegExp(Mt,"i").test(it.label)?it.label:yt).split("/"))[1]&&!/[\d.]+/.test(yt[0])&&(yt[0]+=" "+yt[1]),it=it.label||it,yt=C(yt[0].replace(RegExp(Mt,"i"),it).replace(RegExp("; *(?:"+it+"[_-])?","i")," ").replace(RegExp("("+it+")[-_.]?(\\w)","i"),"$1 $2"))),yt})}function Ar(Pt){return q(Pt,function(yt,it){return yt||(RegExp(it+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(L)||0)[1]||null})}function Rr(){return this.description||""}if(pt&&(pt=[pt]),/\bAndroid\b/.test($e)&&!ot&&(Q=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(L))&&(ot=X(Q[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),bt&&!ot?ot=Fe([bt]):bt&&ot&&(ot=ot.replace(RegExp("^("+N(bt)+")[-_.\\s]","i"),bt+" ").replace(RegExp("^("+N(bt)+")[-_.]?(\\w)","i"),bt+" $2")),(Q=/\bGoogle TV\b/.exec(ot))&&(ot=Q[0]),/\bSimulator\b/i.test(L)&&(ot=(ot?ot+" ":"")+"Simulator"),ke=="Opera Mini"&&/\bOPiOS\b/.test(L)&&_e.push("running in Turbo/Uncompressed mode"),ke=="IE"&&/\blike iPhone OS\b/.test(L)?(Q=J(L.replace(/like iPhone OS/,"")),bt=Q.manufacturer,ot=Q.product):/^iP/.test(ot)?(ke||(ke="Safari"),$e="iOS"+((Q=/ OS ([\d_]+)/i.exec(L))?" "+Q[1].replace(/_/g,"."):"")):ke=="Konqueror"&&/^Linux\b/i.test($e)?$e="Kubuntu":bt&&bt!="Google"&&(/Chrome/.test(ke)&&!/\bMobile Safari\b/i.test(L)||/\bVita\b/.test(ot))||/\bAndroid\b/.test($e)&&/^Chrome/.test(ke)&&/\bVersion\//i.test(L)?(ke="Android Browser",$e=/\bAndroid\b/.test($e)?$e:"Android"):ke=="Silk"?(/\bMobi/i.test(L)||($e="Android",_e.unshift("desktop mode")),/Accelerated *= *true/i.test(L)&&_e.unshift("accelerated")):ke=="UC Browser"&&/\bUCWEB\b/.test(L)?_e.push("speed mode"):ke=="PaleMoon"&&(Q=/\bFirefox\/([\d.]+)\b/.exec(L))?_e.push("identifying as Firefox "+Q[1]):ke=="Firefox"&&(Q=/\b(Mobile|Tablet|TV)\b/i.exec(L))?($e||($e="Firefox OS"),ot||(ot=Q[1])):!ke||(Q=!/\bMinefield\b/i.test(L)&&/\b(?:Firefox|Safari)\b/.exec(ke))?(ke&&!ot&&/[\/,]|^[^(]+?\)/.test(L.slice(L.indexOf(Q+"/")+8))&&(ke=null),(Q=ot||bt||$e)&&(ot||bt||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test($e))&&(ke=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test($e)?$e:Q)+" Browser")):ke=="Electron"&&(Q=(/\bChrome\/([\d.]+)\b/.exec(L)||0)[1])&&_e.push("Chromium "+Q),Le||(Le=Ar(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",N(ke),"(?:Firefox|Minefield|NetFront)"])),(Q=pt=="iCab"&&parseFloat(Le)>3&&"WebKit"||/\bOpera\b/.test(ke)&&(/\bOPR\b/.test(L)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(L)&&!/^(?:Trident|EdgeHTML)$/.test(pt)&&"WebKit"||!pt&&/\bMSIE\b/i.test(L)&&($e=="Mac OS"?"Tasman":"Trident")||pt=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(ke)&&"NetFront")&&(pt=[Q]),ke=="IE"&&(Q=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(L)||0)[1])?(ke+=" Mobile",$e="Windows Phone "+(/\+$/.test(Q)?Q:Q+".x"),_e.unshift("desktop mode")):/\bWPDesktop\b/i.test(L)?(ke="IE Mobile",$e="Windows Phone 8.x",_e.unshift("desktop mode"),Le||(Le=(/\brv:([\d.]+)/.exec(L)||0)[1])):ke!="IE"&&pt=="Trident"&&(Q=/\brv:([\d.]+)/.exec(L))&&(ke&&_e.push("identifying as "+ke+(Le?" "+Le:"")),ke="IE",Le=Q[1]),St){if(x(te,"global"))if(he&&(Q=he.lang.System,$t=Q.getProperty("os.arch"),$e=$e||Q.getProperty("os.name")+" "+Q.getProperty("os.version")),pe){try{Le=te.require("ringo/engine").version.join("."),ke="RingoJS"}catch{(Q=te.system)&&Q.global.system==te.system&&(ke="Narwhal",$e||($e=Q[0].os||null))}ke||(ke="Rhino")}else typeof te.process=="object"&&!te.process.browser&&(Q=te.process)&&(typeof Q.versions=="object"&&(typeof Q.versions.electron=="string"?(_e.push("Node "+Q.versions.node),ke="Electron",Le=Q.versions.electron):typeof Q.versions.nw=="string"&&(_e.push("Chromium "+Le,"Node "+Q.versions.node),ke="NW.js",Le=Q.versions.nw)),ke||(ke="Node.js",$t=Q.arch,$e=Q.platform,Le=/[\d.]+/.exec(Q.version),Le=Le?Le[0]:null));else $(Q=te.runtime)==He?(ke="Adobe AIR",$e=Q.flash.system.Capabilities.os):$(Q=te.phantom)==Pe?(ke="PhantomJS",Le=(Q=Q.version||null)&&Q.major+"."+Q.minor+"."+Q.patch):typeof Je.documentMode=="number"&&(Q=/\bTrident\/(\d+)/i.exec(L))?(Le=[Le,Je.documentMode],(Q=+Q[1]+4)!=Le[1]&&(_e.push("IE "+Le[1]+" mode"),pt&&(pt[1]=""),Le[1]=Q),Le=ke=="IE"?String(Le[1].toFixed(1)):Le[0]):typeof Je.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(ke)&&(_e.push("masking as "+ke+" "+Le),ke="IE",Le="11.0",pt=["Trident"],$e="Windows");$e=$e&&C($e)}if(Le&&(Q=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Le)||/(?:alpha|beta)(?: ?\d)?/i.exec(L+";"+(St&&ne.appMinorVersion))||/\bMinefield\b/i.test(L)&&"a")&&(le=/b/i.test(Q)?"beta":"alpha",Le=Le.replace(RegExp(Q+"\\+?$"),"")+(le=="beta"?Oe:M)+(/\d+\+?/.exec(Q)||"")),ke=="Fennec"||ke=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test($e))ke="Firefox Mobile";else if(ke=="Maxthon"&&Le)Le=Le.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(ot))ot=="Xbox 360"&&($e=null),ot=="Xbox 360"&&/\bIEMobile\b/.test(L)&&_e.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(ke)||ke&&!ot&&!/Browser|Mobi/.test(ke))&&($e=="Windows CE"||/Mobi/i.test(L)))ke+=" Mobile";else if(ke=="IE"&&St)try{te.external===null&&_e.unshift("platform preview")}catch{_e.unshift("embedded")}else(/\bBlackBerry\b/.test(ot)||/\bBB10\b/.test(L))&&(Q=(RegExp(ot.replace(/ +/g," *")+"/([.\\d]+)","i").exec(L)||0)[1]||Le)?(Q=[Q,/BB10/.test(L)],$e=(Q[1]?(ot=null,bt="BlackBerry"):"Device Software")+" "+Q[0],Le=null):this!=I&&ot!="Wii"&&(St&&De||/Opera/.test(ke)&&/\b(?:MSIE|Firefox)\b/i.test(L)||ke=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test($e)||ke=="IE"&&($e&&!/^Win/.test($e)&&Le>5.5||/\bWindows XP\b/.test($e)&&Le>8||Le==8&&!/\bTrident\b/.test(L)))&&!u.test(Q=J.call(I,L.replace(u,"")+";"))&&Q.name&&(Q="ing as "+Q.name+((Q=Q.version)?" "+Q:""),u.test(ke)?(/\bIE\b/.test(Q)&&$e=="Mac OS"&&($e=null),Q="identify"+Q):(Q="mask"+Q,we?ke=C(we.replace(/([a-z])([A-Z])/g,"$1 $2")):ke="Opera",/\bIE\b/.test(Q)&&($e=null),St||(Le=null)),pt=["Presto"],_e.push(Q));(Q=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(L)||0)[1])&&(Q=[parseFloat(Q.replace(/\.(\d)$/,".0$1")),Q],ke=="Safari"&&Q[1].slice(-1)=="+"?(ke="WebKit Nightly",le="alpha",Le=Q[1].slice(0,-1)):(Le==Q[1]||Le==(Q[2]=(/\bSafari\/([\d.]+\+?)/i.exec(L)||0)[1]))&&(Le=null),Q[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(L)||0)[1],Q[0]==537.36&&Q[2]==537.36&&parseFloat(Q[1])>=28&&pt=="WebKit"&&(pt=["Blink"]),!St||!Y&&!Q[1]?(pt&&(pt[1]="like Safari"),Q=(Q=Q[0],Q<400?1:Q<500?2:Q<526?3:Q<533?4:Q<534?"4+":Q<535?5:Q<537?6:Q<538?7:Q<601?8:Q<602?9:Q<604?10:Q<606?11:Q<608?12:"12")):(pt&&(pt[1]="like Chrome"),Q=Q[1]||(Q=Q[0],Q<530?1:Q<532?2:Q<532.05?3:Q<533?4:Q<534.03?5:Q<534.07?6:Q<534.1?7:Q<534.13?8:Q<534.16?9:Q<534.24?10:Q<534.3?11:Q<535.01?12:Q<535.02?"13+":Q<535.07?15:Q<535.11?16:Q<535.19?17:Q<536.05?18:Q<536.1?19:Q<537.01?20:Q<537.11?"21+":Q<537.13?23:Q<537.18?24:Q<537.24?25:Q<537.36?26:pt!="Blink"?"27":"28")),pt&&(pt[1]+=" "+(Q+=typeof Q=="number"?".x":/[.+]/.test(Q)?"":"+")),ke=="Safari"&&(!Le||parseInt(Le)>45)?Le=Q:ke=="Chrome"&&/\bHeadlessChrome/i.test(L)&&_e.unshift("headless")),ke=="Opera"&&(Q=/\bzbov|zvav$/.exec($e))?(ke+=" ",_e.unshift("desktop mode"),Q=="zvav"?(ke+="Mini",Le=null):ke+="Mobile",$e=$e.replace(RegExp(" *"+Q+"$"),"")):ke=="Safari"&&/\bChrome\b/.exec(pt&&pt[1])?(_e.unshift("desktop mode"),ke="Chrome Mobile",Le=null,/\bOS X\b/.test($e)?(bt="Apple",$e="iOS 4.3+"):$e=null):/\bSRWare Iron\b/.test(ke)&&!Le&&(Le=Ar("Chrome")),Le&&Le.indexOf(Q=/[\d.]+$/.exec($e))==0&&L.indexOf("/"+Q+"-")>-1&&($e=X($e.replace(Q,""))),$e&&$e.indexOf(ke)!=-1&&!RegExp(ke+" OS").test($e)&&($e=$e.replace(RegExp(" *"+N(ke)+" *"),"")),pt&&!/\b(?:Avant|Nook)\b/.test(ke)&&(/Browser|Lunascape|Maxthon/.test(ke)||ke!="Safari"&&/^iOS/.test($e)&&/\bSafari\b/.test(pt[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(ke)&&pt[1])&&(Q=pt[pt.length-1])&&_e.push(Q),_e.length&&(_e=["("+_e.join("; ")+")"]),bt&&ot&&ot.indexOf(bt)<0&&_e.push("on "+bt),ot&&_e.push((/^on /.test(_e[_e.length-1])?"":"on ")+ot),$e&&(Q=/ ([\d.+]+)$/.exec($e),Gt=Q&&$e.charAt($e.length-Q[0].length-1)=="/",$e={architecture:32,family:Q&&!Gt?$e.replace(Q[0],""):$e,version:Q?Q[1]:null,toString:function(){var Pt=this.version;return this.family+(Pt&&!Gt?" "+Pt:"")+(this.architecture==64?" 64-bit":"")}}),(Q=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec($t))&&!/\bi686\b/i.test($t)?($e&&($e.architecture=64,$e.family=$e.family.replace(RegExp(" *"+Q),"")),ke&&(/\bWOW64\b/i.test(L)||St&&/\w(?:86|32)$/.test(ne.cpuClass||ne.platform)&&!/\bWin64; x64\b/i.test(L))&&_e.unshift("32-bit")):$e&&/^OS X/.test($e.family)&&ke=="Chrome"&&parseFloat(Le)>=39&&($e.architecture=64),L||(L=null);var Ct={};return Ct.description=L,Ct.layout=pt&&pt[0],Ct.manufacturer=bt,Ct.name=ke,Ct.prerelease=le,Ct.product=ot,Ct.ua=L,Ct.version=ke&&Le,Ct.os=$e||{architecture:null,family:null,version:null,toString:function(){return"null"}},Ct.parse=J,Ct.toString=Rr,Ct.version&&_e.unshift(Le),Ct.name&&_e.unshift(ke),$e&&ke&&!($e==String($e).split(" ")[0]&&($e==ke.split(" ")[0]||ot))&&_e.push(ot?"("+$e+")":"on "+$e),_e.length&&(Ct.description=_e.join(" ")),Ct}var G=J();i&&a?I(G,function(L,te){i[te]=L}):n.platform=G}).call(Ae)})(Tl,Tl.exports);var aR=Tl.exports,tG=Ft,rG=ef,nG=ar,iG=Hn,aG=Wi,Hd=wr,sG=Kn,oG=ns,uG=pm,cw=tf;rG("match",function(e,r,t){return[function(i){var a=sG(this),s=iG(i)?void 0:oG(i,e);return s?tG(s,i,a):new RegExp(i)[e](Hd(a))},function(n){var i=nG(this),a=Hd(n),s=t(r,i,a);if(s.done)return s.value;if(!i.global)return cw(i,a);var o=i.unicode;i.lastIndex=0;for(var u=[],c=0,l;(l=cw(i,a))!==null;){var h=Hd(l[0]);u[c]=h,h===""&&(i.lastIndex=uG(a,aG(i.lastIndex),o)),c++}return c===0?null:u}]});var cG=Object.is||function(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t},lG=Ft,fG=ef,dG=ar,pG=Hn,hG=Kn,lw=cG,fw=wr,vG=ns,mG=tf;fG("search",function(e,r,t){return[function(i){var a=hG(this),s=pG(i)?void 0:vG(i,e);return s?lG(s,i,a):new RegExp(i)[e](fw(a))},function(n){var i=dG(this),a=fw(n),s=t(r,i,a);if(s.done)return s.value;var o=i.lastIndex;lw(o,0)||(i.lastIndex=0);var u=mG(i,a);return lw(i.lastIndex,o)||(i.lastIndex=o),u===null?-1:u.index}]});var gG=Wt,yG=du,bG=TypeError,_G=Object.getOwnPropertyDescriptor,wG=gG&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),SG=wG?function(e,r){if(yG(e)&&!_G(e,"length").writable)throw new bG("Cannot set read only .length");return e.length=r}:function(e,r){return e.length=r},CG=gt,TG=Mr,EG=as,kG=fi,RG=xr,$G=SG,IG=kT,OG=Fv,PG=gu,Kd=Nm,AG=mu,MG=AG("splice"),xG=Math.max,NG=Math.min;CG({target:"Array",proto:!0,forced:!MG},{splice:function(r,t){var n=TG(this),i=RG(n),a=EG(r,i),s=arguments.length,o,u,c,l,h,v;for(s===0?o=u=0:s===1?(o=0,u=i-a):(o=s-2,u=NG(xG(kG(t),0),i-a)),IG(i+o-u),c=OG(n,u),l=0;l<u;l++)h=a+l,h in n&&PG(c,l,n[h]);if(c.length=u,o<u){for(l=a;l<i-u;l++)h=l+u,v=l+o,h in n?n[v]=n[h]:Kd(n,v);for(l=i;l>i-u+o;l--)Kd(n,l-1)}else if(o>u)for(l=i-u;l>a;l--)h=l+u-1,v=l+o-1,h in n?n[v]=n[h]:Kd(n,v);for(l=0;l<o;l++)n[l+a]=arguments[l+2];return $G(n,i-u+o),c}});/*
73
+ */Tl.exports;(function(e,r){(function(){var t={function:!0,object:!0},n=t[typeof window]&&window||this,i=r,a=e&&!e.nodeType&&e,s=i&&a&&typeof Ae=="object"&&Ae;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var o=Math.pow(2,53)-1,u=/\bOpera/,c=Object.prototype,l=c.hasOwnProperty,h=c.toString;function v(L){return L=String(L),L.charAt(0).toUpperCase()+L.slice(1)}function m(L,te,se){var ne={"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 te&&se&&/^Win/i.test(L)&&!/^Windows Phone /i.test(L)&&(ne=ne[/[\d.]+$/.exec(L)])&&(L="Windows "+ne),L=String(L),te&&se&&(L=L.replace(RegExp(te,"i"),se)),L=C(L.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]),L}function _(L,te){var se=-1,ne=L?L.length:0;if(typeof ne=="number"&&ne>-1&&ne<=o)for(;++se<ne;)te(L[se],se,L);else I(L,te)}function C(L){return L=X(L),/^(?:webOS|i(?:OS|P))/.test(L)?L:v(L)}function I(L,te){for(var se in L)l.call(L,se)&&te(L[se],se,L)}function $(L){return L==null?v(L):h.call(L).slice(8,-1)}function x(L,te){var se=L!=null?typeof L[te]:"number";return!/^(?:boolean|number|string|undefined)$/.test(se)&&(se=="object"?!!L[te]:!0)}function N(L){return String(L).replace(/([ -])(?!$)/g,"$1?")}function q(L,te){var se=null;return _(L,function(ne,ge){se=te(se,ne,ge,L)}),se}function X(L){return String(L).replace(/^ +| +$/g,"")}function J(L){var te=n,se=L&&typeof L=="object"&&$(L)!="String";se&&(te=L,L=null);var ne=te.navigator||{},ge=ne.userAgent||"";L||(L=ge);var Y=se?!!ne.likeChrome:/\bChrome\b/.test(L)&&!/internal|\n/i.test(h.toString()),Ue="Object",He=se?Ue:"ScriptBridgingProxyObject",Rt=se?Ue:"Environment",ft=se&&te.java?"JavaPackage":$(te.java),Pe=se?Ue:"RuntimeObject",he=/\bJava/.test(ft)&&te.java,pe=he&&$(te.environment)==Rt,M=he?"a":"α",Oe=he?"b":"β",Je=te.document||{},De=te.operamini||te.opera,we=u.test(we=se&&De?De["[[Class]]"]:$(De))?we:De=null,Q,$t=L,_e=[],le=null,St=L==ge,Le=St&&De&&typeof De.version=="function"&&De.version(),Gt,pt=Kt([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),ke=qt(["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"]),ot=Fe([{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"]),bt=dt({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}}),$e=rr(["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(Pt){return q(Pt,function(yt,it){return yt||RegExp("\\b"+(it.pattern||N(it))+"\\b","i").exec(L)&&(it.label||it)})}function dt(Pt){return q(Pt,function(yt,it,Mt){return yt||(it[ot]||it[/^[a-z]+(?: +[a-z]+\b)*/i.exec(ot)]||RegExp("\\b"+N(Mt)+"(?:\\b|\\w*\\d)","i").exec(L))&&Mt})}function qt(Pt){return q(Pt,function(yt,it){return yt||RegExp("\\b"+(it.pattern||N(it))+"\\b","i").exec(L)&&(it.label||it)})}function rr(Pt){return q(Pt,function(yt,it){var Mt=it.pattern||N(it);return!yt&&(yt=RegExp("\\b"+Mt+"(?:/[\\d.]+|[ \\w.]*)","i").exec(L))&&(yt=m(yt,Mt,it.label||it)),yt})}function Fe(Pt){return q(Pt,function(yt,it){var Mt=it.pattern||N(it);return!yt&&(yt=RegExp("\\b"+Mt+" *\\d+[.\\w_]*","i").exec(L)||RegExp("\\b"+Mt+" *\\w+-[\\w]*","i").exec(L)||RegExp("\\b"+Mt+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(L))&&((yt=String(it.label&&!RegExp(Mt,"i").test(it.label)?it.label:yt).split("/"))[1]&&!/[\d.]+/.test(yt[0])&&(yt[0]+=" "+yt[1]),it=it.label||it,yt=C(yt[0].replace(RegExp(Mt,"i"),it).replace(RegExp("; *(?:"+it+"[_-])?","i")," ").replace(RegExp("("+it+")[-_.]?(\\w)","i"),"$1 $2"))),yt})}function Ar(Pt){return q(Pt,function(yt,it){return yt||(RegExp(it+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(L)||0)[1]||null})}function $r(){return this.description||""}if(pt&&(pt=[pt]),/\bAndroid\b/.test($e)&&!ot&&(Q=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(L))&&(ot=X(Q[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),bt&&!ot?ot=Fe([bt]):bt&&ot&&(ot=ot.replace(RegExp("^("+N(bt)+")[-_.\\s]","i"),bt+" ").replace(RegExp("^("+N(bt)+")[-_.]?(\\w)","i"),bt+" $2")),(Q=/\bGoogle TV\b/.exec(ot))&&(ot=Q[0]),/\bSimulator\b/i.test(L)&&(ot=(ot?ot+" ":"")+"Simulator"),ke=="Opera Mini"&&/\bOPiOS\b/.test(L)&&_e.push("running in Turbo/Uncompressed mode"),ke=="IE"&&/\blike iPhone OS\b/.test(L)?(Q=J(L.replace(/like iPhone OS/,"")),bt=Q.manufacturer,ot=Q.product):/^iP/.test(ot)?(ke||(ke="Safari"),$e="iOS"+((Q=/ OS ([\d_]+)/i.exec(L))?" "+Q[1].replace(/_/g,"."):"")):ke=="Konqueror"&&/^Linux\b/i.test($e)?$e="Kubuntu":bt&&bt!="Google"&&(/Chrome/.test(ke)&&!/\bMobile Safari\b/i.test(L)||/\bVita\b/.test(ot))||/\bAndroid\b/.test($e)&&/^Chrome/.test(ke)&&/\bVersion\//i.test(L)?(ke="Android Browser",$e=/\bAndroid\b/.test($e)?$e:"Android"):ke=="Silk"?(/\bMobi/i.test(L)||($e="Android",_e.unshift("desktop mode")),/Accelerated *= *true/i.test(L)&&_e.unshift("accelerated")):ke=="UC Browser"&&/\bUCWEB\b/.test(L)?_e.push("speed mode"):ke=="PaleMoon"&&(Q=/\bFirefox\/([\d.]+)\b/.exec(L))?_e.push("identifying as Firefox "+Q[1]):ke=="Firefox"&&(Q=/\b(Mobile|Tablet|TV)\b/i.exec(L))?($e||($e="Firefox OS"),ot||(ot=Q[1])):!ke||(Q=!/\bMinefield\b/i.test(L)&&/\b(?:Firefox|Safari)\b/.exec(ke))?(ke&&!ot&&/[\/,]|^[^(]+?\)/.test(L.slice(L.indexOf(Q+"/")+8))&&(ke=null),(Q=ot||bt||$e)&&(ot||bt||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test($e))&&(ke=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test($e)?$e:Q)+" Browser")):ke=="Electron"&&(Q=(/\bChrome\/([\d.]+)\b/.exec(L)||0)[1])&&_e.push("Chromium "+Q),Le||(Le=Ar(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",N(ke),"(?:Firefox|Minefield|NetFront)"])),(Q=pt=="iCab"&&parseFloat(Le)>3&&"WebKit"||/\bOpera\b/.test(ke)&&(/\bOPR\b/.test(L)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(L)&&!/^(?:Trident|EdgeHTML)$/.test(pt)&&"WebKit"||!pt&&/\bMSIE\b/i.test(L)&&($e=="Mac OS"?"Tasman":"Trident")||pt=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(ke)&&"NetFront")&&(pt=[Q]),ke=="IE"&&(Q=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(L)||0)[1])?(ke+=" Mobile",$e="Windows Phone "+(/\+$/.test(Q)?Q:Q+".x"),_e.unshift("desktop mode")):/\bWPDesktop\b/i.test(L)?(ke="IE Mobile",$e="Windows Phone 8.x",_e.unshift("desktop mode"),Le||(Le=(/\brv:([\d.]+)/.exec(L)||0)[1])):ke!="IE"&&pt=="Trident"&&(Q=/\brv:([\d.]+)/.exec(L))&&(ke&&_e.push("identifying as "+ke+(Le?" "+Le:"")),ke="IE",Le=Q[1]),St){if(x(te,"global"))if(he&&(Q=he.lang.System,$t=Q.getProperty("os.arch"),$e=$e||Q.getProperty("os.name")+" "+Q.getProperty("os.version")),pe){try{Le=te.require("ringo/engine").version.join("."),ke="RingoJS"}catch{(Q=te.system)&&Q.global.system==te.system&&(ke="Narwhal",$e||($e=Q[0].os||null))}ke||(ke="Rhino")}else typeof te.process=="object"&&!te.process.browser&&(Q=te.process)&&(typeof Q.versions=="object"&&(typeof Q.versions.electron=="string"?(_e.push("Node "+Q.versions.node),ke="Electron",Le=Q.versions.electron):typeof Q.versions.nw=="string"&&(_e.push("Chromium "+Le,"Node "+Q.versions.node),ke="NW.js",Le=Q.versions.nw)),ke||(ke="Node.js",$t=Q.arch,$e=Q.platform,Le=/[\d.]+/.exec(Q.version),Le=Le?Le[0]:null));else $(Q=te.runtime)==He?(ke="Adobe AIR",$e=Q.flash.system.Capabilities.os):$(Q=te.phantom)==Pe?(ke="PhantomJS",Le=(Q=Q.version||null)&&Q.major+"."+Q.minor+"."+Q.patch):typeof Je.documentMode=="number"&&(Q=/\bTrident\/(\d+)/i.exec(L))?(Le=[Le,Je.documentMode],(Q=+Q[1]+4)!=Le[1]&&(_e.push("IE "+Le[1]+" mode"),pt&&(pt[1]=""),Le[1]=Q),Le=ke=="IE"?String(Le[1].toFixed(1)):Le[0]):typeof Je.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(ke)&&(_e.push("masking as "+ke+" "+Le),ke="IE",Le="11.0",pt=["Trident"],$e="Windows");$e=$e&&C($e)}if(Le&&(Q=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Le)||/(?:alpha|beta)(?: ?\d)?/i.exec(L+";"+(St&&ne.appMinorVersion))||/\bMinefield\b/i.test(L)&&"a")&&(le=/b/i.test(Q)?"beta":"alpha",Le=Le.replace(RegExp(Q+"\\+?$"),"")+(le=="beta"?Oe:M)+(/\d+\+?/.exec(Q)||"")),ke=="Fennec"||ke=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test($e))ke="Firefox Mobile";else if(ke=="Maxthon"&&Le)Le=Le.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(ot))ot=="Xbox 360"&&($e=null),ot=="Xbox 360"&&/\bIEMobile\b/.test(L)&&_e.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(ke)||ke&&!ot&&!/Browser|Mobi/.test(ke))&&($e=="Windows CE"||/Mobi/i.test(L)))ke+=" Mobile";else if(ke=="IE"&&St)try{te.external===null&&_e.unshift("platform preview")}catch{_e.unshift("embedded")}else(/\bBlackBerry\b/.test(ot)||/\bBB10\b/.test(L))&&(Q=(RegExp(ot.replace(/ +/g," *")+"/([.\\d]+)","i").exec(L)||0)[1]||Le)?(Q=[Q,/BB10/.test(L)],$e=(Q[1]?(ot=null,bt="BlackBerry"):"Device Software")+" "+Q[0],Le=null):this!=I&&ot!="Wii"&&(St&&De||/Opera/.test(ke)&&/\b(?:MSIE|Firefox)\b/i.test(L)||ke=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test($e)||ke=="IE"&&($e&&!/^Win/.test($e)&&Le>5.5||/\bWindows XP\b/.test($e)&&Le>8||Le==8&&!/\bTrident\b/.test(L)))&&!u.test(Q=J.call(I,L.replace(u,"")+";"))&&Q.name&&(Q="ing as "+Q.name+((Q=Q.version)?" "+Q:""),u.test(ke)?(/\bIE\b/.test(Q)&&$e=="Mac OS"&&($e=null),Q="identify"+Q):(Q="mask"+Q,we?ke=C(we.replace(/([a-z])([A-Z])/g,"$1 $2")):ke="Opera",/\bIE\b/.test(Q)&&($e=null),St||(Le=null)),pt=["Presto"],_e.push(Q));(Q=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(L)||0)[1])&&(Q=[parseFloat(Q.replace(/\.(\d)$/,".0$1")),Q],ke=="Safari"&&Q[1].slice(-1)=="+"?(ke="WebKit Nightly",le="alpha",Le=Q[1].slice(0,-1)):(Le==Q[1]||Le==(Q[2]=(/\bSafari\/([\d.]+\+?)/i.exec(L)||0)[1]))&&(Le=null),Q[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(L)||0)[1],Q[0]==537.36&&Q[2]==537.36&&parseFloat(Q[1])>=28&&pt=="WebKit"&&(pt=["Blink"]),!St||!Y&&!Q[1]?(pt&&(pt[1]="like Safari"),Q=(Q=Q[0],Q<400?1:Q<500?2:Q<526?3:Q<533?4:Q<534?"4+":Q<535?5:Q<537?6:Q<538?7:Q<601?8:Q<602?9:Q<604?10:Q<606?11:Q<608?12:"12")):(pt&&(pt[1]="like Chrome"),Q=Q[1]||(Q=Q[0],Q<530?1:Q<532?2:Q<532.05?3:Q<533?4:Q<534.03?5:Q<534.07?6:Q<534.1?7:Q<534.13?8:Q<534.16?9:Q<534.24?10:Q<534.3?11:Q<535.01?12:Q<535.02?"13+":Q<535.07?15:Q<535.11?16:Q<535.19?17:Q<536.05?18:Q<536.1?19:Q<537.01?20:Q<537.11?"21+":Q<537.13?23:Q<537.18?24:Q<537.24?25:Q<537.36?26:pt!="Blink"?"27":"28")),pt&&(pt[1]+=" "+(Q+=typeof Q=="number"?".x":/[.+]/.test(Q)?"":"+")),ke=="Safari"&&(!Le||parseInt(Le)>45)?Le=Q:ke=="Chrome"&&/\bHeadlessChrome/i.test(L)&&_e.unshift("headless")),ke=="Opera"&&(Q=/\bzbov|zvav$/.exec($e))?(ke+=" ",_e.unshift("desktop mode"),Q=="zvav"?(ke+="Mini",Le=null):ke+="Mobile",$e=$e.replace(RegExp(" *"+Q+"$"),"")):ke=="Safari"&&/\bChrome\b/.exec(pt&&pt[1])?(_e.unshift("desktop mode"),ke="Chrome Mobile",Le=null,/\bOS X\b/.test($e)?(bt="Apple",$e="iOS 4.3+"):$e=null):/\bSRWare Iron\b/.test(ke)&&!Le&&(Le=Ar("Chrome")),Le&&Le.indexOf(Q=/[\d.]+$/.exec($e))==0&&L.indexOf("/"+Q+"-")>-1&&($e=X($e.replace(Q,""))),$e&&$e.indexOf(ke)!=-1&&!RegExp(ke+" OS").test($e)&&($e=$e.replace(RegExp(" *"+N(ke)+" *"),"")),pt&&!/\b(?:Avant|Nook)\b/.test(ke)&&(/Browser|Lunascape|Maxthon/.test(ke)||ke!="Safari"&&/^iOS/.test($e)&&/\bSafari\b/.test(pt[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(ke)&&pt[1])&&(Q=pt[pt.length-1])&&_e.push(Q),_e.length&&(_e=["("+_e.join("; ")+")"]),bt&&ot&&ot.indexOf(bt)<0&&_e.push("on "+bt),ot&&_e.push((/^on /.test(_e[_e.length-1])?"":"on ")+ot),$e&&(Q=/ ([\d.+]+)$/.exec($e),Gt=Q&&$e.charAt($e.length-Q[0].length-1)=="/",$e={architecture:32,family:Q&&!Gt?$e.replace(Q[0],""):$e,version:Q?Q[1]:null,toString:function(){var Pt=this.version;return this.family+(Pt&&!Gt?" "+Pt:"")+(this.architecture==64?" 64-bit":"")}}),(Q=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec($t))&&!/\bi686\b/i.test($t)?($e&&($e.architecture=64,$e.family=$e.family.replace(RegExp(" *"+Q),"")),ke&&(/\bWOW64\b/i.test(L)||St&&/\w(?:86|32)$/.test(ne.cpuClass||ne.platform)&&!/\bWin64; x64\b/i.test(L))&&_e.unshift("32-bit")):$e&&/^OS X/.test($e.family)&&ke=="Chrome"&&parseFloat(Le)>=39&&($e.architecture=64),L||(L=null);var Ct={};return Ct.description=L,Ct.layout=pt&&pt[0],Ct.manufacturer=bt,Ct.name=ke,Ct.prerelease=le,Ct.product=ot,Ct.ua=L,Ct.version=ke&&Le,Ct.os=$e||{architecture:null,family:null,version:null,toString:function(){return"null"}},Ct.parse=J,Ct.toString=$r,Ct.version&&_e.unshift(Le),Ct.name&&_e.unshift(ke),$e&&ke&&!($e==String($e).split(" ")[0]&&($e==ke.split(" ")[0]||ot))&&_e.push(ot?"("+$e+")":"on "+$e),_e.length&&(Ct.description=_e.join(" ")),Ct}var G=J();i&&a?I(G,function(L,te){i[te]=L}):n.platform=G}).call(Ae)})(Tl,Tl.exports);var sR=Tl.exports,nG=Ft,iG=ef,aG=ar,sG=Hn,oG=Wi,Hd=wr,uG=Kn,cG=ns,lG=pm,lw=tf;iG("match",function(e,r,t){return[function(i){var a=uG(this),s=sG(i)?void 0:cG(i,e);return s?nG(s,i,a):new RegExp(i)[e](Hd(a))},function(n){var i=aG(this),a=Hd(n),s=t(r,i,a);if(s.done)return s.value;if(!i.global)return lw(i,a);var o=i.unicode;i.lastIndex=0;for(var u=[],c=0,l;(l=lw(i,a))!==null;){var h=Hd(l[0]);u[c]=h,h===""&&(i.lastIndex=lG(a,oG(i.lastIndex),o)),c++}return c===0?null:u}]});var fG=Object.is||function(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t},dG=Ft,pG=ef,hG=ar,vG=Hn,mG=Kn,fw=fG,dw=wr,gG=ns,yG=tf;pG("search",function(e,r,t){return[function(i){var a=mG(this),s=vG(i)?void 0:gG(i,e);return s?dG(s,i,a):new RegExp(i)[e](dw(a))},function(n){var i=hG(this),a=dw(n),s=t(r,i,a);if(s.done)return s.value;var o=i.lastIndex;fw(o,0)||(i.lastIndex=0);var u=yG(i,a);return fw(i.lastIndex,o)||(i.lastIndex=o),u===null?-1:u.index}]});var bG=Wt,_G=du,wG=TypeError,SG=Object.getOwnPropertyDescriptor,CG=bG&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),TG=CG?function(e,r){if(_G(e)&&!SG(e,"length").writable)throw new wG("Cannot set read only .length");return e.length=r}:function(e,r){return e.length=r},EG=gt,kG=Mr,RG=as,$G=fi,IG=xr,OG=TG,PG=RT,AG=Fv,MG=gu,Kd=Nm,xG=mu,NG=xG("splice"),LG=Math.max,DG=Math.min;EG({target:"Array",proto:!0,forced:!NG},{splice:function(r,t){var n=kG(this),i=IG(n),a=RG(r,i),s=arguments.length,o,u,c,l,h,v;for(s===0?o=u=0:s===1?(o=0,u=i-a):(o=s-2,u=DG(LG($G(t),0),i-a)),PG(i+o-u),c=AG(n,u),l=0;l<u;l++)h=a+l,h in n&&MG(c,l,n[h]);if(c.length=u,o<u){for(l=a;l<i-u;l++)h=l+u,v=l+o,h in n?n[v]=n[h]:Kd(n,v);for(l=i;l>i-u+o;l--)Kd(n,l-1)}else if(o>u)for(l=i-u;l>a;l--)h=l+u-1,v=l+o-1,h in n?n[v]=n[h]:Kd(n,v);for(l=0;l<o;l++)n[l+a]=arguments[l+2];return OG(n,i-u+o),c}});/*
74
74
  @license
75
75
  The following license applies to all parts of this software except as
76
76
  documented below.
@@ -153,10 +153,10 @@ This software includes loglevel under the following license.
153
153
  OTHER DEALINGS IN THE SOFTWARE.
154
154
 
155
155
 
156
- */(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=yu,n=Ea,i=os,a=gm,s=vi,o=mi,u=Pn,c=gi,l=us,h=Cu,v=On,m=Br,_=gr,C=uz,I=bz,$=mf,x=Ji,N=aR;function q(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}function X(D){if(D&&D.__esModule)return D;var B=Object.create(null);return D&&Object.keys(D).forEach(function(R){if(R!=="default"){var k=Object.getOwnPropertyDescriptor(D,R);Object.defineProperty(B,R,k.get?k:{enumerable:!0,get:function(){return D[R]}})}}),B.default=D,Object.freeze(B)}var J=q(t),G=q(n),L=q(i),te=q(a),se=q(s),ne=q(o),ge=q(u),Y=q(c),Ue=q(l),He=q(h),Rt=q(v),ft=X(_),Pe=X(C),he=q($),pe=X(N);function M(D,B,R,k){var E=arguments.length,U=E<3?B:k===null?k=Object.getOwnPropertyDescriptor(B,R):k,A;if((typeof Reflect>"u"?"undefined":Rt.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(D,B,R,k);else for(var fe=D.length-1;fe>=0;fe--)(A=D[fe])&&(U=(E<3?A(U):E>3?A(B,R,U):A(B,R))||U);return E>3&&U&&Object.defineProperty(B,R,U),U}function Oe(D,B){if((typeof Reflect>"u"?"undefined":Rt.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(D,B)}var Je;function De(){}De.prototype=Object.create(null);function we(){we.init.call(this)}we.EventEmitter=we,we.usingDomains=!1,we.prototype.domain=void 0,we.prototype._events=void 0,we.prototype._maxListeners=void 0,we.defaultMaxListeners=10,we.init=function(){this.domain=null,we.usingDomains&&Je.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new De,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},we.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 Q(D){return D._maxListeners===void 0?we.defaultMaxListeners:D._maxListeners}we.prototype.getMaxListeners=function(){return Q(this)};function $t(D,B,R){if(B)D.call(R);else for(var k=D.length,E=$e(D,k),U=0;U<k;++U)E[U].call(R)}function _e(D,B,R,k){if(B)D.call(R,k);else for(var E=D.length,U=$e(D,E),A=0;A<E;++A)U[A].call(R,k)}function le(D,B,R,k,E){if(B)D.call(R,k,E);else for(var U=D.length,A=$e(D,U),fe=0;fe<U;++fe)A[fe].call(R,k,E)}function St(D,B,R,k,E,U){if(B)D.call(R,k,E,U);else for(var A=D.length,fe=$e(D,A),ue=0;ue<A;++ue)fe[ue].call(R,k,E,U)}function Le(D,B,R,k){if(B)D.apply(R,k);else for(var E=D.length,U=$e(D,E),A=0;A<E;++A)U[A].apply(R,k)}we.prototype.emit=function(B){var R,k,E,U,A,fe,ue,Te=B==="error";if(fe=this._events,fe)Te=Te&&fe.error==null;else if(!Te)return!1;if(ue=this.domain,Te){if(R=arguments[1],ue)R||(R=new Error('Uncaught, unspecified "error" event')),R.domainEmitter=this,R.domain=ue,R.domainThrown=!1,ue.emit("error",R);else{if(R instanceof Error)throw R;var Ne=new Error('Uncaught, unspecified "error" event. ('+R+")");throw Ne.context=R,Ne}return!1}if(k=fe[B],!k)return!1;var et=typeof k=="function";switch(E=arguments.length,E){case 1:$t(k,et,this);break;case 2:_e(k,et,this,arguments[1]);break;case 3:le(k,et,this,arguments[1],arguments[2]);break;case 4:St(k,et,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array(E-1),A=1;A<E;A++)U[A-1]=arguments[A];Le(k,et,this,U)}return!0};function Gt(D,B,R,k){var E,U,A;if(typeof R!="function")throw new TypeError('"listener" argument must be a function');if(U=D._events,U?(U.newListener&&(D.emit("newListener",B,R.listener?R.listener:R),U=D._events),A=U[B]):(U=D._events=new De,D._eventsCount=0),!A)A=U[B]=R,++D._eventsCount;else if(typeof A=="function"?A=U[B]=k?[R,A]:[A,R]:k?A.unshift(R):A.push(R),!A.warned&&(E=Q(D),E&&E>0&&A.length>E)){A.warned=!0;var fe=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+B+" listeners added. Use emitter.setMaxListeners() to increase limit");fe.name="MaxListenersExceededWarning",fe.emitter=D,fe.type=B,fe.count=A.length,pt(fe)}return D}function pt(D){typeof console.warn=="function"?console.warn(D):console.log(D)}we.prototype.addListener=function(B,R){return Gt(this,B,R,!1)},we.prototype.on=we.prototype.addListener,we.prototype.prependListener=function(B,R){return Gt(this,B,R,!0)};function ke(D,B,R){var k=!1;function E(){D.removeListener(B,E),k||(k=!0,R.apply(D,arguments))}return E.listener=R,E}we.prototype.once=function(B,R){if(typeof R!="function")throw new TypeError('"listener" argument must be a function');return this.on(B,ke(this,B,R)),this},we.prototype.prependOnceListener=function(B,R){if(typeof R!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(B,ke(this,B,R)),this},we.prototype.removeListener=function(B,R){var k,E,U,A,fe;if(typeof R!="function")throw new TypeError('"listener" argument must be a function');if(E=this._events,!E)return this;if(k=E[B],!k)return this;if(k===R||k.listener&&k.listener===R)--this._eventsCount===0?this._events=new De:(delete E[B],E.removeListener&&this.emit("removeListener",B,k.listener||R));else if(typeof k!="function"){for(U=-1,A=k.length;A-- >0;)if(k[A]===R||k[A].listener&&k[A].listener===R){fe=k[A].listener,U=A;break}if(U<0)return this;if(k.length===1){if(k[0]=void 0,--this._eventsCount===0)return this._events=new De,this;delete E[B]}else bt(k,U);E.removeListener&&this.emit("removeListener",B,fe||R)}return this},we.prototype.off=function(D,B){return this.removeListener(D,B)},we.prototype.removeAllListeners=function(B){var R,k;if(k=this._events,!k)return this;if(!k.removeListener)return arguments.length===0?(this._events=new De,this._eventsCount=0):k[B]&&(--this._eventsCount===0?this._events=new De:delete k[B]),this;if(arguments.length===0){for(var E=Object.keys(k),U=0,A;U<E.length;++U)A=E[U],A!=="removeListener"&&this.removeAllListeners(A);return this.removeAllListeners("removeListener"),this._events=new De,this._eventsCount=0,this}if(R=k[B],typeof R=="function")this.removeListener(B,R);else if(R)do this.removeListener(B,R[R.length-1]);while(R[0]);return this},we.prototype.listeners=function(B){var R,k,E=this._events;return E?(R=E[B],R?typeof R=="function"?k=[R.listener||R]:k=Kt(R):k=[]):k=[],k},we.listenerCount=function(D,B){return typeof D.listenerCount=="function"?D.listenerCount(B):ot.call(D,B)},we.prototype.listenerCount=ot;function ot(D){var B=this._events;if(B){var R=B[D];if(typeof R=="function")return 1;if(R)return R.length}return 0}we.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function bt(D,B){for(var R=B,k=R+1,E=D.length;k<E;R+=1,k+=1)D[R]=D[k];D.pop()}function $e(D,B){for(var R=new Array(B);B--;)R[B]=D[B];return R}function Kt(D){for(var B=new Array(D.length),R=0;R<B.length;++R)B[R]=D[R].listener||D[R];return B}var dt=ft.getLogger("twilsock");function qt(D,B){return["".concat(new Date().toISOString()," Twilsock ").concat(D,":")].concat(Array.from(B))}var rr=function(){function D(B){Y.default(this,D),Ue.default(this,"prefix",""),this.prefix=B!=null&&B.length>0?" "+B+":":""}return G.default(D,[{key:"setLevel",value:function(R){dt.setLevel(R)}},{key:"trace",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.trace.apply(null,qt("T",k))}},{key:"debug",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.debug.apply(null,qt("D",k))}},{key:"info",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.info.apply(null,qt("I",k))}},{key:"warn",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.warn.apply(null,qt("W",k))}},{key:"error",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.error.apply(null,qt("E",k))}}],[{key:"setLevel",value:function(R){dt.setLevel(R)}},{key:"trace",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.trace.apply(null,qt("T",k))}},{key:"debug",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.debug.apply(null,qt("D",k))}},{key:"info",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.info.apply(null,qt("I",k))}},{key:"warn",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.warn.apply(null,qt("W",k))}},{key:"error",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.error.apply(null,qt("E",k))}}]),D}(),Fe=new rr(""),Ar="0.12.2",Rr=function(){function D(B,R,k){Y.default(this,D),Ue.default(this,"confirmedCapabilities",new Set),this.activeGrant=R,this._token=B;var E=k.region||"us1",U="wss://tsock.".concat(E,".twilio.com/v3/wsconnect"),A=k.twilsock||k.Twilsock||{};this.url=A.uri||U,this._continuationToken=k.continuationToken?k.continuationToken:null,this.logLevel=k.logLevel?k.logLevel:"error",this.retryPolicy=k.retryPolicy?k.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=k.clientMetadata?k.clientMetadata:{},this.clientMetadata.ver=Ar,this.initRegistrations=k.initRegistrations?k.initRegistrations:null,this.tweaks=k.tweaks?k.tweaks:null}return G.default(D,[{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}}]),D}(),Ct=function D(B){Y.default(this,D),this.id=B||"TM".concat(I.v4())};function Pt(D){var B=yt();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}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 it=function(D){se.default(R,D);var B=Pt(R);function R(k,E,U,A,fe){var ue;return Y.default(this,R),ue=B.call(this),Ue.default(L.default(ue),"method","init"),ue.token=k,ue.continuation_token=E,ue.metadata=U,ue.registrations=A,ue.tweaks=fe,ue.capabilities=["client_update","offline_storage","telemetry.v1"],ue}return R}(Ct);function Mt(D){var B=It();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}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 sr=function(D){se.default(R,D);var B=Mt(R);function R(k,E,U,A,fe,ue,Te){var Ne;return Y.default(this,R),Ne=B.call(this,k),Ne.continuationToken=E,Ne.continuationTokenStatus=A,Ne.offlineStorage=fe,Ne.initRegistrations=ue,Ne.debugInfo=Te,Ne.confirmedCapabilities=U,Ne}return R}(Ct);function Nr(D){var B=tn();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function tn(){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){se.default(R,D);var B=Nr(R);function R(k){var E;return Y.default(this,R),E=B.call(this),Ue.default(L.default(E),"method","update"),E.token=k,E}return R}(Ct);function Qt(D){var B=lr();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function lr(){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 ve=function(D){se.default(R,D);var B=Qt(R);function R(k,E,U){var A;return Y.default(this,R),A=B.call(this),Ue.default(L.default(A),"method","message"),A.active_grant=k,A.payload_type=E,A.http_request=U,A}return R}(Ct);function ye(D){var B=ae();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function ae(){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 de=function(D){se.default(R,D);var B=ye(R);function R(k){var E;return Y.default(this,R),E=B.call(this,k),Ue.default(L.default(E),"method","reply"),Ue.default(L.default(E),"payload_type","application/json"),Ue.default(L.default(E),"status",{code:200,status:"OK"}),E}return R}(Ct);function oe(D){var B=me();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function me(){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 Se=function(D){se.default(R,D);var B=oe(R);function R(){var k;return Y.default(this,R),k=B.call(this),Ue.default(L.default(k),"method","close"),k}return R}(Ct);function Z(D){var B=ce();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}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 H=function D(B,R,k,E,U,A){Y.default(this,D),this.start=B,this.end=R,this.title=k,this.details=E,this.id=U,this.type=A},ie=function(D){se.default(R,D);var B=Z(R);function R(k){var E;return Y.default(this,R),E=B.call(this),Ue.default(L.default(E),"method","telemetry.v1"),E.events=k,E}return R}(Ct);function K(D){var B=encodeURIComponent(D),R=B.replace(/%([0-9A-F]{2})/g,function(k,E){return String.fromCharCode(+("0x"+E))});return R.length}function xe(D){var B=encodeURIComponent(D),R=B.replace(/%([0-9A-F]{2})/g,function(E,U){return String.fromCharCode(+("0x"+U))}),k=new Uint8Array(R.length);return Array.prototype.forEach.call(R,function(E,U){k[U]=E.charCodeAt(0)}),k}function Ce(D){var B=Array.prototype.map.call(D,function(k){return String.fromCharCode(k)}).join(""),R=B.replace(/(.)/g,function(k,E){var U=E.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(R)}function We(D){return JSON.parse(Ce(D))}function Be(D){for(var B="",R=0;R<D.length;++R){var k=String.fromCharCode(D[R]);if(B+=k,k==="\r"){R+=2;break}}var E=B.split(" ");return{size:R,protocol:E[0],version:E[1],headerSize:Number(E[2])}}var Ve=function(){function D(){Y.default(this,D)}return G.default(D,null,[{key:"parse",value:function(R){var k=2,E=new Uint8Array(R),U=Be(E);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return Fe.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var A;try{A=We(E.subarray(U.size,U.size+U.headerSize))}catch(Ne){return Fe.error("failed to parse message header",Ne,R),null}Fe.debug("message received: ",A.method),Fe.trace("message received: ",A);var fe;if(A.payload_size>0){var ue=k+U.size+U.headerSize,Te=A.payload_size;if(!A.hasOwnProperty("payload_type")||A.payload_type.indexOf("application/json")===0)try{fe=We(E.subarray(ue,ue+Te))}catch(Ne){return Fe.error("failed to parse message body",Ne,R),null}else A.payload_type.indexOf("text/plain")===0&&(fe=Ce(E.subarray(ue,ue+Te)))}return{method:A.method,header:A,payload:fe}}},{key:"createPacket",value:function(R){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";R.payload_size=K(k);var E=JSON.stringify(R),U="TWILSOCK V3.0 "+K(E);Fe.debug("send request:",U+E+k);var A=xe(U+`\r
156
+ */(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=yu,n=Ea,i=os,a=gm,s=vi,o=mi,u=Pn,c=gi,l=us,h=Cu,v=On,m=Br,_=gr,C=lz,I=wz,$=mf,x=Ji,N=sR;function q(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}function X(D){if(D&&D.__esModule)return D;var B=Object.create(null);return D&&Object.keys(D).forEach(function(R){if(R!=="default"){var k=Object.getOwnPropertyDescriptor(D,R);Object.defineProperty(B,R,k.get?k:{enumerable:!0,get:function(){return D[R]}})}}),B.default=D,Object.freeze(B)}var J=q(t),G=q(n),L=q(i),te=q(a),se=q(s),ne=q(o),ge=q(u),Y=q(c),Ue=q(l),He=q(h),Rt=q(v),ft=X(_),Pe=X(C),he=q($),pe=X(N);function M(D,B,R,k){var E=arguments.length,U=E<3?B:k===null?k=Object.getOwnPropertyDescriptor(B,R):k,A;if((typeof Reflect>"u"?"undefined":Rt.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(D,B,R,k);else for(var fe=D.length-1;fe>=0;fe--)(A=D[fe])&&(U=(E<3?A(U):E>3?A(B,R,U):A(B,R))||U);return E>3&&U&&Object.defineProperty(B,R,U),U}function Oe(D,B){if((typeof Reflect>"u"?"undefined":Rt.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(D,B)}var Je;function De(){}De.prototype=Object.create(null);function we(){we.init.call(this)}we.EventEmitter=we,we.usingDomains=!1,we.prototype.domain=void 0,we.prototype._events=void 0,we.prototype._maxListeners=void 0,we.defaultMaxListeners=10,we.init=function(){this.domain=null,we.usingDomains&&Je.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new De,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},we.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 Q(D){return D._maxListeners===void 0?we.defaultMaxListeners:D._maxListeners}we.prototype.getMaxListeners=function(){return Q(this)};function $t(D,B,R){if(B)D.call(R);else for(var k=D.length,E=$e(D,k),U=0;U<k;++U)E[U].call(R)}function _e(D,B,R,k){if(B)D.call(R,k);else for(var E=D.length,U=$e(D,E),A=0;A<E;++A)U[A].call(R,k)}function le(D,B,R,k,E){if(B)D.call(R,k,E);else for(var U=D.length,A=$e(D,U),fe=0;fe<U;++fe)A[fe].call(R,k,E)}function St(D,B,R,k,E,U){if(B)D.call(R,k,E,U);else for(var A=D.length,fe=$e(D,A),ue=0;ue<A;++ue)fe[ue].call(R,k,E,U)}function Le(D,B,R,k){if(B)D.apply(R,k);else for(var E=D.length,U=$e(D,E),A=0;A<E;++A)U[A].apply(R,k)}we.prototype.emit=function(B){var R,k,E,U,A,fe,ue,Te=B==="error";if(fe=this._events,fe)Te=Te&&fe.error==null;else if(!Te)return!1;if(ue=this.domain,Te){if(R=arguments[1],ue)R||(R=new Error('Uncaught, unspecified "error" event')),R.domainEmitter=this,R.domain=ue,R.domainThrown=!1,ue.emit("error",R);else{if(R instanceof Error)throw R;var Ne=new Error('Uncaught, unspecified "error" event. ('+R+")");throw Ne.context=R,Ne}return!1}if(k=fe[B],!k)return!1;var et=typeof k=="function";switch(E=arguments.length,E){case 1:$t(k,et,this);break;case 2:_e(k,et,this,arguments[1]);break;case 3:le(k,et,this,arguments[1],arguments[2]);break;case 4:St(k,et,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array(E-1),A=1;A<E;A++)U[A-1]=arguments[A];Le(k,et,this,U)}return!0};function Gt(D,B,R,k){var E,U,A;if(typeof R!="function")throw new TypeError('"listener" argument must be a function');if(U=D._events,U?(U.newListener&&(D.emit("newListener",B,R.listener?R.listener:R),U=D._events),A=U[B]):(U=D._events=new De,D._eventsCount=0),!A)A=U[B]=R,++D._eventsCount;else if(typeof A=="function"?A=U[B]=k?[R,A]:[A,R]:k?A.unshift(R):A.push(R),!A.warned&&(E=Q(D),E&&E>0&&A.length>E)){A.warned=!0;var fe=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+B+" listeners added. Use emitter.setMaxListeners() to increase limit");fe.name="MaxListenersExceededWarning",fe.emitter=D,fe.type=B,fe.count=A.length,pt(fe)}return D}function pt(D){typeof console.warn=="function"?console.warn(D):console.log(D)}we.prototype.addListener=function(B,R){return Gt(this,B,R,!1)},we.prototype.on=we.prototype.addListener,we.prototype.prependListener=function(B,R){return Gt(this,B,R,!0)};function ke(D,B,R){var k=!1;function E(){D.removeListener(B,E),k||(k=!0,R.apply(D,arguments))}return E.listener=R,E}we.prototype.once=function(B,R){if(typeof R!="function")throw new TypeError('"listener" argument must be a function');return this.on(B,ke(this,B,R)),this},we.prototype.prependOnceListener=function(B,R){if(typeof R!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(B,ke(this,B,R)),this},we.prototype.removeListener=function(B,R){var k,E,U,A,fe;if(typeof R!="function")throw new TypeError('"listener" argument must be a function');if(E=this._events,!E)return this;if(k=E[B],!k)return this;if(k===R||k.listener&&k.listener===R)--this._eventsCount===0?this._events=new De:(delete E[B],E.removeListener&&this.emit("removeListener",B,k.listener||R));else if(typeof k!="function"){for(U=-1,A=k.length;A-- >0;)if(k[A]===R||k[A].listener&&k[A].listener===R){fe=k[A].listener,U=A;break}if(U<0)return this;if(k.length===1){if(k[0]=void 0,--this._eventsCount===0)return this._events=new De,this;delete E[B]}else bt(k,U);E.removeListener&&this.emit("removeListener",B,fe||R)}return this},we.prototype.off=function(D,B){return this.removeListener(D,B)},we.prototype.removeAllListeners=function(B){var R,k;if(k=this._events,!k)return this;if(!k.removeListener)return arguments.length===0?(this._events=new De,this._eventsCount=0):k[B]&&(--this._eventsCount===0?this._events=new De:delete k[B]),this;if(arguments.length===0){for(var E=Object.keys(k),U=0,A;U<E.length;++U)A=E[U],A!=="removeListener"&&this.removeAllListeners(A);return this.removeAllListeners("removeListener"),this._events=new De,this._eventsCount=0,this}if(R=k[B],typeof R=="function")this.removeListener(B,R);else if(R)do this.removeListener(B,R[R.length-1]);while(R[0]);return this},we.prototype.listeners=function(B){var R,k,E=this._events;return E?(R=E[B],R?typeof R=="function"?k=[R.listener||R]:k=Kt(R):k=[]):k=[],k},we.listenerCount=function(D,B){return typeof D.listenerCount=="function"?D.listenerCount(B):ot.call(D,B)},we.prototype.listenerCount=ot;function ot(D){var B=this._events;if(B){var R=B[D];if(typeof R=="function")return 1;if(R)return R.length}return 0}we.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function bt(D,B){for(var R=B,k=R+1,E=D.length;k<E;R+=1,k+=1)D[R]=D[k];D.pop()}function $e(D,B){for(var R=new Array(B);B--;)R[B]=D[B];return R}function Kt(D){for(var B=new Array(D.length),R=0;R<B.length;++R)B[R]=D[R].listener||D[R];return B}var dt=ft.getLogger("twilsock");function qt(D,B){return["".concat(new Date().toISOString()," Twilsock ").concat(D,":")].concat(Array.from(B))}var rr=function(){function D(B){Y.default(this,D),Ue.default(this,"prefix",""),this.prefix=B!=null&&B.length>0?" "+B+":":""}return G.default(D,[{key:"setLevel",value:function(R){dt.setLevel(R)}},{key:"trace",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.trace.apply(null,qt("T",k))}},{key:"debug",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.debug.apply(null,qt("D",k))}},{key:"info",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.info.apply(null,qt("I",k))}},{key:"warn",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.warn.apply(null,qt("W",k))}},{key:"error",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.error.apply(null,qt("E",k))}}],[{key:"setLevel",value:function(R){dt.setLevel(R)}},{key:"trace",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.trace.apply(null,qt("T",k))}},{key:"debug",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.debug.apply(null,qt("D",k))}},{key:"info",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.info.apply(null,qt("I",k))}},{key:"warn",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.warn.apply(null,qt("W",k))}},{key:"error",value:function(){for(var R=arguments.length,k=new Array(R),E=0;E<R;E++)k[E]=arguments[E];dt.error.apply(null,qt("E",k))}}]),D}(),Fe=new rr(""),Ar="0.12.2",$r=function(){function D(B,R,k){Y.default(this,D),Ue.default(this,"confirmedCapabilities",new Set),this.activeGrant=R,this._token=B;var E=k.region||"us1",U="wss://tsock.".concat(E,".twilio.com/v3/wsconnect"),A=k.twilsock||k.Twilsock||{};this.url=A.uri||U,this._continuationToken=k.continuationToken?k.continuationToken:null,this.logLevel=k.logLevel?k.logLevel:"error",this.retryPolicy=k.retryPolicy?k.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=k.clientMetadata?k.clientMetadata:{},this.clientMetadata.ver=Ar,this.initRegistrations=k.initRegistrations?k.initRegistrations:null,this.tweaks=k.tweaks?k.tweaks:null}return G.default(D,[{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}}]),D}(),Ct=function D(B){Y.default(this,D),this.id=B||"TM".concat(I.v4())};function Pt(D){var B=yt();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}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 it=function(D){se.default(R,D);var B=Pt(R);function R(k,E,U,A,fe){var ue;return Y.default(this,R),ue=B.call(this),Ue.default(L.default(ue),"method","init"),ue.token=k,ue.continuation_token=E,ue.metadata=U,ue.registrations=A,ue.tweaks=fe,ue.capabilities=["client_update","offline_storage","telemetry.v1"],ue}return R}(Ct);function Mt(D){var B=It();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}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 sr=function(D){se.default(R,D);var B=Mt(R);function R(k,E,U,A,fe,ue,Te){var Ne;return Y.default(this,R),Ne=B.call(this,k),Ne.continuationToken=E,Ne.continuationTokenStatus=A,Ne.offlineStorage=fe,Ne.initRegistrations=ue,Ne.debugInfo=Te,Ne.confirmedCapabilities=U,Ne}return R}(Ct);function Nr(D){var B=tn();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function tn(){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){se.default(R,D);var B=Nr(R);function R(k){var E;return Y.default(this,R),E=B.call(this),Ue.default(L.default(E),"method","update"),E.token=k,E}return R}(Ct);function Qt(D){var B=lr();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function lr(){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 ve=function(D){se.default(R,D);var B=Qt(R);function R(k,E,U){var A;return Y.default(this,R),A=B.call(this),Ue.default(L.default(A),"method","message"),A.active_grant=k,A.payload_type=E,A.http_request=U,A}return R}(Ct);function ye(D){var B=ae();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function ae(){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 de=function(D){se.default(R,D);var B=ye(R);function R(k){var E;return Y.default(this,R),E=B.call(this,k),Ue.default(L.default(E),"method","reply"),Ue.default(L.default(E),"payload_type","application/json"),Ue.default(L.default(E),"status",{code:200,status:"OK"}),E}return R}(Ct);function oe(D){var B=me();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function me(){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 Se=function(D){se.default(R,D);var B=oe(R);function R(){var k;return Y.default(this,R),k=B.call(this),Ue.default(L.default(k),"method","close"),k}return R}(Ct);function Z(D){var B=ce();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}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 H=function D(B,R,k,E,U,A){Y.default(this,D),this.start=B,this.end=R,this.title=k,this.details=E,this.id=U,this.type=A},ie=function(D){se.default(R,D);var B=Z(R);function R(k){var E;return Y.default(this,R),E=B.call(this),Ue.default(L.default(E),"method","telemetry.v1"),E.events=k,E}return R}(Ct);function K(D){var B=encodeURIComponent(D),R=B.replace(/%([0-9A-F]{2})/g,function(k,E){return String.fromCharCode(+("0x"+E))});return R.length}function xe(D){var B=encodeURIComponent(D),R=B.replace(/%([0-9A-F]{2})/g,function(E,U){return String.fromCharCode(+("0x"+U))}),k=new Uint8Array(R.length);return Array.prototype.forEach.call(R,function(E,U){k[U]=E.charCodeAt(0)}),k}function Ce(D){var B=Array.prototype.map.call(D,function(k){return String.fromCharCode(k)}).join(""),R=B.replace(/(.)/g,function(k,E){var U=E.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(R)}function We(D){return JSON.parse(Ce(D))}function Be(D){for(var B="",R=0;R<D.length;++R){var k=String.fromCharCode(D[R]);if(B+=k,k==="\r"){R+=2;break}}var E=B.split(" ");return{size:R,protocol:E[0],version:E[1],headerSize:Number(E[2])}}var Ve=function(){function D(){Y.default(this,D)}return G.default(D,null,[{key:"parse",value:function(R){var k=2,E=new Uint8Array(R),U=Be(E);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return Fe.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var A;try{A=We(E.subarray(U.size,U.size+U.headerSize))}catch(Ne){return Fe.error("failed to parse message header",Ne,R),null}Fe.debug("message received: ",A.method),Fe.trace("message received: ",A);var fe;if(A.payload_size>0){var ue=k+U.size+U.headerSize,Te=A.payload_size;if(!A.hasOwnProperty("payload_type")||A.payload_type.indexOf("application/json")===0)try{fe=We(E.subarray(ue,ue+Te))}catch(Ne){return Fe.error("failed to parse message body",Ne,R),null}else A.payload_type.indexOf("text/plain")===0&&(fe=Ce(E.subarray(ue,ue+Te)))}return{method:A.method,header:A,payload:fe}}},{key:"createPacket",value:function(R){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";R.payload_size=K(k);var E=JSON.stringify(R),U="TWILSOCK V3.0 "+K(E);Fe.debug("send request:",U+E+k);var A=xe(U+`\r
157
157
  `+E+`\r
158
158
  `+k);return A.buffer}}]),D}();function Ye(D){var B=Qe();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Qe(){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 Ke=function(D){se.default(R,D);var B=Ye(R);function R(k){return Y.default(this,R),B.call(this,k)}return R}(he.default(Error));function Xe(D){var B=Ze();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Ze(){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){se.default(R,D);var B=Xe(R);function R(k,E){var U;return Y.default(this,R),U=B.call(this,k),U.reply=E,U}return R}(Ke);function yr(D,B){var R=Object.keys(D);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(D);B&&(k=k.filter(function(E){return Object.getOwnPropertyDescriptor(D,E).enumerable})),R.push.apply(R,k)}return R}function or(D){for(var B=1;B<arguments.length;B++){var R=arguments[B]!=null?arguments[B]:{};B%2?yr(Object(R),!0).forEach(function(k){Ue.default(D,k,R[k])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(R)):yr(Object(R)).forEach(function(k){Object.defineProperty(D,k,Object.getOwnPropertyDescriptor(R,k))})}return D}function st(D){var B=Wr();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Wr(){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 mn=function(D){se.default(R,D);var B=st(R);function R(k){var E;return Y.default(this,R),E=B.call(this),Ue.default(L.default(E),"newBackoff",null),Ue.default(L.default(E),"usedBackoff",null),Ue.default(L.default(E),"retrier",null),E.options=k?or({},k):{},E}return G.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(E){this.newBackoff=E}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var E=!this.usedBackoff||this.usedBackoff<this.newBackoff;if(E)this.createRetrier();else{var U;(U=this.retrier)===null||U===void 0||U.failed(new Error)}}else{var A;(A=this.retrier)===null||A===void 0||A.failed(new Error)}}},{key:"cancel",value:function(){var E;(E=this.retrier)===null||E===void 0||E.cancel()}},{key:"cleanRetrier",value:function(){var E,U;(E=this.retrier)===null||E===void 0||E.removeAllListeners(),(U=this.retrier)===null||U===void 0||U.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var E=or({},this.options);return this.newBackoff&&(E.min=this.newBackoff,E.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),E.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,E}},{key:"createRetrier",value:function(){var E=this;this.cleanRetrier();var U=this.getRetryPolicy();this.retrier=new x.Retrier(U),this.retrier.once("attempt",function(){var A,fe;(A=E.retrier)===null||A===void 0||A.on("attempt",function(){return E.emit("attempt")}),(fe=E.retrier)===null||fe===void 0||fe.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(A){return E.emit("failed",A)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),R}(we);function bi(D){var B=Vr();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Vr(){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=3e3;function Gr(D){setTimeout(D,0)}var gn=function(D){se.default(R,D);var B=bi(R);function R(k,E,U){var A;Y.default(this,R),A=B.call(this),Ue.default(L.default(A),"disconnectingTimer",null),Ue.default(L.default(A),"disconnectedPromiseResolve",null),Ue.default(L.default(A),"terminalStates",["disconnected","rejected"]),Ue.default(L.default(A),"tokenExpiredSasCode",20104),Ue.default(L.default(A),"terminationReason","Connection is not initialized"),A.websocket=k,A.websocket.on("connected",function(){return A.fsm.socketConnected()}),A.websocket.on("disconnected",function(){return A.fsm.socketClosed()}),A.websocket.on("message",function(ue){return A.onIncomingMessage(ue)}),A.websocket.on("socketError",function(ue){return A.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(ue.message),httpStatusCode:null,errorCode:null})}),A.transport=E,A.config=U,A.retrier=new mn(U.retryPolicy),A.retrier.on("attempt",function(){return A.retry()}),A.retrier.on("failed",function(ue){Fe.warn("Retrying failed: ".concat(ue.message)),A.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){Fe.debug("Browser reported connectivity state: online"),A.resetBackoff(),A.fsm.systemOnline()}),window.addEventListener("offline",function(){Fe.debug("Browser reported connectivity state: offline"),A.websocket.close(),A.fsm.socketClosed()}));var fe=Pe.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(){A.setupSocket(),A.emit("connecting")},onEnterInitialising:function(){A.sendInit()},onLeaveInitialising:function(){A.cancelInit()},onEnterUpdating:function(){A.sendUpdate()},onLeaveUpdating:function(){A.cancelUpdate()},onEnterRetrying:function(){A.initRetry(),A.emit("connecting")},onEnterConnected:function(){A.resetBackoff(),A.onConnected()},onUserUpdateToken:function(){A.resetBackoff()},onTokenRejected:function(){A.resetBackoff(),A.closeSocket(!0),A.finalizeSocket()},onUserDisconnect:function(){A.closeSocket(!0)},onEnterDisconnecting:function(){A.startDisconnectTimer()},onLeaveDisconnecting:function(){A.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){A.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){A.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){A.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){A.cancelDisconnectTimer()},onDisconnected:function(){A.resetBackoff(),A.finalizeSocket()},onReceiveClose:function(){A.onCloseReceived()},onReceiveOffload:function(Te,Ne){Fe.debug("onreceiveoffload: ",Ne),A.modifyBackoff(Ne.body),A.onCloseReceived()},onUnsupported:function(){A.closeSocket(!0),A.finalizeSocket()},onError:function(Te,Ne){A.closeSocket(Ne),A.finalizeSocket()},onEnterState:function(Te){Te.from!=="none"&&A.changeState(Te)},onInvalidTransition:function(Te,Ne,et){Fe.warn("FSM: unexpected transition",Ne,et)}}});return A.fsm=new fe,A}return G.default(R,[{key:"changeState",value:function(E){Fe.debug("FSM: ".concat(E.transition,": ").concat(E.from," --> ").concat(E.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){Fe.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(E){Fe.trace("modifyBackoff",E);var U=E?E.backoff_policy:null;U&&typeof U.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(U.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var E=this;Fe.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){Fe.debug("disconnecting is timed out"),E.closeSocket(!0)},Xn)}},{key:"cancelDisconnectTimer",value:function(){Fe.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(){Fe.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(Fe.trace("retry"),this.websocket.close(),this.fsm.userRetry()):Fe.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){Fe.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){Fe.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(E){var U=Ve.parse(E);if(U){var A=U.method,fe=U.header,ue=U.payload;if(A!=="reply"&&this.confirmReceiving(fe),A==="notification")this.emit("message",fe.message_type,ue);else if(fe.method==="reply")this.transport.processReply({id:fe.id,status:fe.status,header:fe,body:ue});else if(fe.method==="client_update")fe.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(fe.method==="close")if(fe.status.code===308)Fe.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:fe.status.status,body:ue});else if(fe.status.code===406){var Te="Server closed connection because can't parse protocol: ".concat(JSON.stringify(fe.status));this.emitReplyConnectionError(Te,fe,!0),Fe.error(Te),this.fsm.receiveFatalClose()}else fe.status.code===417?(Fe.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(fe.status))),this.fsm.receiveFatalClose(fe.status.status)):fe.status.code===410?(Fe.warn("Server closed connection: ".concat(JSON.stringify(fe.status))),this.fsm.receiveClose(fe.status.status),this.emit("tokenExpired")):fe.status.code===401?(Fe.error("Server closed connection: ".concat(JSON.stringify(fe.status))),this.fsm.receiveClose(fe.status.status)):(Fe.warn("unexpected message: ",fe.status),this.fsm.receiveOffload({status:fe.status.status,body:null}))}}},{key:"sendInit",value:function(){var k=J.default(He.default.mark(function U(){var A,fe;return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return Fe.trace("sendInit"),Te.prev=1,this.emit("beforeSendInit"),Te.next=5,this.transport.sendInit();case 5:A=Te.sent,this.config.updateContinuationToken(A.continuationToken),this.config.confirmedCapabilities=A.confirmedCapabilities,this.fsm.initSuccess(A),this.emit("initialized",A),this.emit("tokenUpdated"),Te.next=17;break;case 13:Te.prev=13,Te.t0=Te.catch(1),Te.t0 instanceof at?(fe=!1,Fe.warn("Init rejected by server: ".concat(JSON.stringify(Te.t0.reply.status))),this.emit("sendInitFailed"),Te.t0.reply.status.code===401||Te.t0.reply.status.code===403?(fe=!0,this.fsm.tokenRejected(Te.t0.reply.status),Te.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Te.t0.reply.status.code===429?(this.modifyBackoff(Te.t0.reply.body),this.fsm.initError(!0)):Te.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(Te.t0.message,Te.t0.reply,fe)):(this.terminationReason=Te.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(Te.t0.message,`
159
- `).concat(JSON.stringify(Te.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Te.t0);case 17:case"end":return Te.stop()}},U,this,[[1,13]])}));function E(){return k.apply(this,arguments)}return E}()},{key:"sendUpdate",value:function(){var k=J.default(He.default.mark(function U(){var A,fe,ue;return He.default.wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:return Fe.trace("sendUpdate"),A=new rn(this.config.token),Ne.prev=2,Ne.next=5,this.transport.sendWithReply(A);case 5:fe=Ne.sent,this.fsm.updateSuccess(fe.body),this.emit("tokenUpdated"),Ne.next=14;break;case 10:Ne.prev=10,Ne.t0=Ne.catch(2),Ne.t0 instanceof at?(ue=!1,Fe.warn("Token update rejected by server: ".concat(JSON.stringify(Ne.t0.reply.status))),Ne.t0.reply.status.code===401||Ne.t0.reply.status.code===403?(ue=!0,this.fsm.tokenRejected(Ne.t0.reply.status),Ne.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Ne.t0.reply.status.code===429?(this.modifyBackoff(Ne.t0.reply.body),this.fsm.updateError(Ne.t0.reply.status)):this.fsm.updateError(Ne.t0.reply.status),this.emitReplyConnectionError(Ne.t0.message,Ne.t0.reply,ue)):(this.emit("error",!1,Ne.t0.message,null,null),this.fsm.updateError(Ne.t0)),this.emit("tokenUpdated",Ne.t0);case 14:case"end":return Ne.stop()}},U,this,[[2,10]])}));function E(){return k.apply(this,arguments)}return E}()},{key:"emitReplyConnectionError",value:function(E,U,A){var fe=U.status&&U.status.description?U.status.description:E,ue=U.status.code,Te=U.status&&U.status.errorCode?U.status.errorCode:null;A&&(this.terminationReason=fe),this.emit("connectionError",{terminal:A,message:"Connection error: ".concat(fe),httpStatusCode:ue,errorCode:Te})}},{key:"cancelInit",value:function(){Fe.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Fe.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(E){Fe.trace("confirmReceiving");try{this.transport.send(new de(E.id))}catch(U){Fe.debug("failed to confirm packet receiving",U)}}},{key:"closeSocket",value:function(E){var U=this;Fe.trace("closeSocket (graceful: ".concat(E,")")),E&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),Gr(function(){return U.fsm.socketClosed()})}},{key:"connect",value:function(){Fe.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var E=this;return Fe.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(U){E.disconnectedPromiseResolve=U,E.fsm.userDisconnect()})}},{key:"updateToken",value:function(E){var U=this;return Fe.trace("updateToken:",E),new Promise(function(A,fe){U.once("tokenUpdated",function(ue){ue?fe(ue):A()}),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()}}]),R}(we),_i=function(){function D(){Y.default(this,D)}return G.default(D,null,[{key:"getMetadata",value:function(R){var k,E,U,A,fe,ue,Te,Ne,et=R&&R.clientMetadata?R.clientMetadata:{},hr=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Kr={env:(k=pe.name)!==null&&k!==void 0?k:"unknown",envv:(E=pe.version)!==null&&E!==void 0?E:"unknown",os:(U=(A=pe.os)===null||A===void 0?void 0:A.family)!==null&&U!==void 0?U:"unknown",osv:(fe=(ue=pe.os)===null||ue===void 0?void 0:ue.version)!==null&&fe!==void 0?fe:"unknown",osa:(Te=(Ne=pe.os)===null||Ne===void 0?void 0:Ne.architecture)!==null&&Te!==void 0?Te:"unknown",sdk:"js-default"},nr={};return hr.filter(function(un){return un in et||un in Kr}).forEach(function(un){return nr[un]=un in et?et[un]:Kr[un]}),nr}}]),D}(),ur=3e4;function xn(D){return D>=200&&D<300}function Zi(D){switch(Rt.default(D)){case"undefined":return"";case"object":return JSON.stringify(D);default:return D}}var nn=function(){function D(B,R){var k=this;Y.default(this,D),this.config=R,this.activeRequests=new Map,this.channel=B,this.channel.on("reply",function(E){return k.processReply(E)}),this.channel.on("disconnected",function(){k.activeRequests.forEach(function(E){clearTimeout(E.timeout),E.reject(new Ke("disconnected"))}),k.activeRequests.clear()})}return G.default(D,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(R){var k=this.activeRequests.get(R.id);k&&(clearTimeout(k.timeout),this.activeRequests.delete(R.id),xn(R.status.code)?k.resolve(R):(k.reject(new at("Transport failure: "+R.status.status,R)),Fe.trace("message rejected")))}},{key:"storeRequest",value:function(R,k,E){var U={resolve:k,reject:E,timeout:setTimeout(function(){Fe.trace("request",R,"is timed out"),E(new Ke("Twilsock: request timeout: "+R))},ur)};this.activeRequests.set(R,U)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new Ke("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var B=J.default(He.default.mark(function k(){var E,U,A;return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:return Fe.trace("sendInit"),E=_i.getMetadata(this.config),U=new it(this.config.token,this.config.continuationToken,E,this.config.initRegistrations,this.config.tweaks),ue.next=5,this.sendWithReply(U);case 5:return A=ue.sent,ue.abrupt("return",new sr(A.id,A.header.continuation_token,new Set(A.header.capabilities),A.header.continuation_token_status,A.header.offline_storage,A.header.init_registrations,A.header.debug_info));case 7:case"end":return ue.stop()}},k,this)}));function R(){return B.apply(this,arguments)}return R}()},{key:"sendClose",value:function(){var R=new Se;this.send(R)}},{key:"sendWithReply",value:function(R,k){var E=this;return new Promise(function(U,A){var fe=E.send(R,k);E.storeRequest(fe,U,A)})}},{key:"send",value:function(R,k){R.id=R.id||"TM".concat(I.v4());var E=Ve.createPacket(R,Zi(k));try{return this.channel.send(E),R.id}catch(U){throw Fe.debug("failed to send ",R,U),Fe.trace(U.stack),U}}}]),D}();function ea(D){var B=wi();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function wi(){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 Hr=function(D){se.default(R,D);var B=ea(R);function R(k){var E;return Y.default(this,R),E=B.call(this),Ue.default(L.default(E),"socket",null),E.url=k,E.url=k,E.WebSocket=r.WebSocket||r.MozWebSocket||{},E}return G.default(R,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var E=this;Fe.trace("connecting to socket");var U;try{U=new this.WebSocket(this.url)}catch(A){Fe.debug("Socket error: ".concat(this.url)),this.emit("socketError",A);return}U.binaryType="arraybuffer",U.onopen=function(){Fe.debug("socket opened ".concat(E.url)),E.emit("connected")},U.onclose=function(A){Fe.debug("socket closed",A),E.emit("disconnected",A)},U.onerror=function(A){Fe.debug("Socket error:",A),E.emit("socketError",A)},U.onmessage=function(A){E.emit("message",A.data)},this.socket=U}},{key:"send",value:function(E){return this.socket&&this.socket.send(E)}},{key:"close",value:function(){if(Fe.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}(we);function ta(D){var B=Aa();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Aa(){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 Ma=function(D){se.default(R,D);var B=ta(R);function R(k){var E;return Y.default(this,R),E=B.call(this),E.transport=k,E.registrations=new Map,E.registrationsInProgress=new Map,E}return G.default(R,[{key:"putNotificationContext",value:function(){var k=J.default(He.default.mark(function U(A,fe){var ue;return He.default.wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:return ue={method:"put_notification_ctx",notification_ctx_id:A},Ne.next=3,this.transport.sendWithReply(ue,fe);case 3:case"end":return Ne.stop()}},U,this)}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"deleteNotificationContext",value:function(){var k=J.default(He.default.mark(function U(A){var fe;return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return fe={method:"delete_notification_ctx",notification_ctx_id:A},Te.next=3,this.transport.sendWithReply(fe);case 3:case"end":return Te.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()},{key:"updateRegistration",value:function(){var k=J.default(He.default.mark(function U(A,fe){var ue,Te;return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return Fe.debug("update registration for context",A),ue=this.registrationsInProgress.get(A),ue||(ue=new Set,this.registrationsInProgress.set(A,ue)),Te=I.v4(),ue.add(Te),et.prev=5,et.next=8,this.putNotificationContext(A,fe);case 8:Fe.debug("registration attempt succeeded for context",fe),ue.delete(Te),ue.size===0&&(this.registrationsInProgress.delete(A),this.emit("registered",A)),et.next=19;break;case 13:et.prev=13,et.t0=et.catch(5),Fe.warn("registration attempt failed for context",fe),Fe.debug(et.t0),ue.delete(Te),ue.size===0&&(this.registrationsInProgress.delete(A),this.emit("registrationFailed",A,et.t0));case 19:case"end":return et.stop()}},U,this,[[5,13]])}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"updateRegistrations",value:function(){var k=J.default(He.default.mark(function U(){var A=this,fe;return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return Fe.trace("refreshing ".concat(this.registrations.size," registrations")),fe=[],this.registrations.forEach(function(Ne,et){fe.push(A.updateRegistration(et,Ne))}),Te.next=5,Promise.all(fe);case 5:case"end":return Te.stop()}},U,this)}));function E(){return k.apply(this,arguments)}return E}()},{key:"setNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A,fe){return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:if(!(!A||!fe)){Te.next=2;break}throw new Ke("Invalid arguments provided");case 2:return this.registrations.set(A,fe),Te.next=5,this.updateRegistration(A,fe);case 5:return Te.abrupt("return",Te.sent);case 6:case"end":return Te.stop()}},U,this)}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"removeNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A){return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(this.registrations.has(A)){ue.next=2;break}return ue.abrupt("return");case 2:return ue.next=4,this.deleteNotificationContext(A);case 4:this.transport.isConnected&&this.registrations.delete(A);case 5:case"end":return ue.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()}]),R}(we);function fr(D){var B=xa();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function xa(){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(D){se.default(R,D);var B=fr(R);function R(k,E,U){var A;return Y.default(this,R),A=B.call(this,E),A.status=k,A.description=E,A.body=U,A}return R}(Ke);function Yt(D){var B=Na();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Na(){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=function(D){se.default(R,D);var B=Yt(R);function R(k){return Y.default(this,R),B.call(this,k)}return R}(Ke),Si=2e4;function Ci(D){return D>=200&&D<300}function La(D){return D&&D.header&&D.header.http_status}function sn(D){var B=D.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(B){var R={protocol:B[1],host:B[2],hostname:B[3],port:B[4],pathname:B[5],search:B[6],hash:B[7],params:{}};if(R.search.length>0){var k=R.search.substring(1);R.params=k.split("&").map(function(E){return E.split("=")}).reduce(function(E,U){return E.hasOwnProperty(U[0])?Array.isArray(E[U[0]])?E[U[0]].push(U[1]):E[U[0]]=[E[U[0]],U[1]]:E[U[0]]=U[1],E},{})}return R}throw new Ke("Incorrect URI: "+D)}function wt(D,B){var R=sn(B),k={method:D,host:R.host,path:R.pathname};return R.params&&(k.params=R.params),k}function ra(D,B,R,k,E){return{to:wt(D,B),headers:R,body:k,grant:E}}var na=function(){function D(B,R,k){Y.default(this,D),this.config=k,this.transport=B,this.pendingMessages=[],this.twilsock=R}return G.default(D,[{key:"saveMessage",value:function(R){var k=this;return new Promise(function(E,U){var A={message:R,resolve:E,reject:U,alreadyRejected:!1,timeout:setTimeout(function(){Fe.debug("request is timed out"),U(new Ke("request '".concat(R.to.method,"' to '").concat(R.to.host,"' timed out"))),A.alreadyRejected=!0},Si)};k.pendingMessages.push(A)})}},{key:"sendPendingMessages",value:function(){for(var R=this,k=function(){var A=R.pendingMessages[0];if(!A.alreadyRejected)try{var fe=A.message;R.actualSend(fe).then(function(ue){return A.resolve(ue)}).catch(function(ue){return A.reject(ue)}),clearTimeout(A.timeout)}catch(ue){return Fe.debug("Failed to send pending message",ue),"break"}R.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var E=k();if(E==="break")break}}},{key:"rejectPendingMessages",value:function(){var R=this;this.pendingMessages.forEach(function(k){k.reject(new an("Unable to connect: "+R.twilsock.getTerminationReason)),k.alreadyRejected=!0,clearTimeout(k.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var B=J.default(He.default.mark(function k(E){var U,A,fe,ue,Te,Ne,et,hr;return He.default.wrap(function(nr){for(;;)switch(nr.prev=nr.next){case 0:return A=E.to,fe=E.headers,ue=E.body,Te=(U=E.grant)!==null&&U!==void 0?U:this.config.activeGrant,Ne={host:A.host,path:A.path,method:A.method,params:A.params,headers:fe},et=new ve(Te,fe["Content-Type"]||"application/json",Ne),Fe.trace("Sending upstream message",et),nr.next=9,this.transport.sendWithReply(et,ue);case 9:if(hr=nr.sent,Fe.trace("Received upstream message response",hr),!(La(hr)&&!Ci(hr.header.http_status.code))){nr.next=13;break}throw new Qn(hr.header.http_status.code,hr.header.http_status.status,hr.body);case 13:return nr.abrupt("return",{status:hr.header.http_status,headers:hr.header.http_headers,body:hr.body});case 14:case"end":return nr.stop()}},k,this)}));function R(k){return B.apply(this,arguments)}return R}()},{key:"send",value:function(R,k){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},U=arguments.length>3?arguments[3]:void 0,A=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new an("Unable to connect: "+this.twilsock.getTerminationReason));var fe=ra(R,k,E,U,A);return this.twilsock.isConnected?this.actualSend(fe):this.saveMessage(fe)}}]),D}(),Ti=function(){function D(){var B=this;Y.default(this,D),this._promise=new Promise(function(R,k){B._resolve=R,B._reject=k})}return G.default(D,[{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)}}]),D}(),Ei=function(){function D(B){Y.default(this,D),this.id=B}return G.default(D,null,[{key:"create",value:function(R){if(R instanceof Object&&"storage_id"in R)return new D(R.storage_id);throw new Ke('Field "storage_id" is missing')}}]),D}(),Zn=function(){function D(){return Y.default(this,D),Ue.default(this,"initializedFlag","twilio_twilsock_token_storage"),Ue.default(this,"tokenStoragePrefix","twilio_continuation_token_"),D._instance||(this.initialize(),D._instance=this),D._instance}return G.default(D,[{key:"sessionStorage",value:function(){try{return r.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return r.window}catch{return null}}},{key:"storeToken",value:function(R,k){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(k),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 k=this.sessionStorage.getItem(this.initializedFlag);k&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var E=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){E(R.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var R=[],k=0;k<this.sessionStorage.length;k++){var E=this.sessionStorage.key(k);E&&E.indexOf(this.tokenStoragePrefix)===0&&R.push(E)}var U=this.sessionStorage.removeItem;R.forEach(function(A){return U(A)}),U(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)}}]),D}();Ue.default(Zn,"_instance",null);var Nn=new Zn,dr=function(){function D(B,R,k,E,U,A){Y.default(this,D),this.title=B,this.details=R,this.start=k,this.type=U,this.id=A,this.end=E}return G.default(D,[{key:"toTelemetryEvent",value:function(){var R=new Date,k=this.start,E=this.end?this.end:R;if(E<k){var U=E;E=k,k=U}var A=k.getTime()-R.getTime(),fe=E.getTime()-R.getTime(),ue=new H(A,fe,this.title,this.details,this.id,this.type);return ue}}]),D}();e.TelemetryPoint=void 0,function(D){D[D.Start=0]="Start",D[D.End=1]="End"}(e.TelemetryPoint||(e.TelemetryPoint={})),e.EventSendingLimitation=void 0,function(D){D[D.MinEventsPortion=0]="MinEventsPortion",D[D.AnyEvents=1]="AnyEvents",D[D.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(e.EventSendingLimitation||(e.EventSendingLimitation={}));var ia=function(){function D(B,R){Y.default(this,D),Ue.default(this,"minEventsPortionToSend",50),Ue.default(this,"maxEventsPortionToSend",100),Ue.default(this,"pendingEvents",new Map),Ue.default(this,"readyEvents",[]),Ue.default(this,"hasInitializationFinished",!1),Ue.default(this,"_canSendTelemetry",!1),this.config=B,this.packetInterface=R}return G.default(D,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(R){Fe.debug("TelemetryTracker.canSendTelemetry: ".concat(R," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!R&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=R,R&&this.sendTelemetry(e.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,k,E){Fe.debug("Adding ".concat(E===e.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(k,"' event"));var U=this.pendingEvents.has(k);if(E===e.TelemetryPoint.Start)U&&Fe.debug("Overwriting starting point for '".concat(k,"' event")),this.pendingEvents.set(k,R);else{if(!U){Fe.info("Could not find started event for '".concat(k,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(k),R)),this.pendingEvents.delete(k)}}},{key:"getTelemetryToSend",value:function(R){return!this.canSendTelemetry||this.readyEvents.length==0?[]:R==e.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(R==e.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(R){var k=this,E=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),U=this.readyEvents.splice(0,E);return R&&U.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(A,fe){if(!(U.length>=k.maxEventsPortionToSend)){var ue=k.pendingEvents.get(fe);k.pendingEvents.delete(fe),U.push(new dr("[UNFINISHED] ".concat(ue.title),ue.details,ue.start,null,ue.type,ue.id))}}),U}},{key:"merge",value:function(R,k){return new dr(k.title?k.title:R.title,k.details?k.details:R.details,R.start,k.end,k.type?k.type:R.type,k.id?k.id:R.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(e.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(R){var k=this.getTelemetryToSend(R);if(k.length!==0)try{this.packetInterface.send(new ie(k.map(function(E){return E.toTelemetryEvent()})))}catch(E){Fe.debug("Error while sending ".concat(k.length," telemetry events due to ").concat(E,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(k)}}}]),D}();function pr(D){var B=$r();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function $r(){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(){Y.default(this,D)};Ue.default(on,"TWILSOCK_CONNECT","twilsock.sdk.connect"),Ue.default(on,"TWILSOCK_INIT","twilsock.sdk.init"),e.TwilsockClient=function(D){se.default(R,D);var B=pr(R);function R(k,E,U){var A;Y.default(this,R),A=B.call(this),Ue.default(L.default(A),"version",Ar),Ue.default(L.default(A),"offlineStorageDeferred",new Ti),U.continuationToken=U.continuationToken?U.continuationToken:Nn.getStoredToken(E);var fe=A.config=new Rr(k,E,U);Fe.setLevel(fe.logLevel);var ue=new Hr(fe.url),Te=new nn(ue,fe);return A.channel=new gn(ue,Te,fe),A.registrations=new Ma(Te),A.upstream=new na(Te,A.channel,fe),A.telemetryTracker=new ia(fe,Te),A.channel.on("initialized",function(){return A.telemetryTracker.canSendTelemetry=!0}),ue.on("disconnected",function(){return A.telemetryTracker.canSendTelemetry=!1}),A.registrations.on("registered",function(Ne){return A.emit("registered",Ne)}),A.channel.on("message",function(Ne,et){return setTimeout(function(){return A.emit("message",Ne,et)},0)}),A.channel.on("stateChanged",function(Ne){return setTimeout(function(){return A.emit("stateChanged",Ne)},0)}),A.channel.on("connectionError",function(Ne){return setTimeout(function(){return A.emit("connectionError",Ne)},0)}),A.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return A.emit("tokenAboutToExpire")},0)}),A.channel.on("tokenExpired",function(){return setTimeout(function(){return A.emit("tokenExpired")},0)}),A.channel.on("connected",function(){return A.registrations.updateRegistrations()}),A.channel.on("connected",function(){return A.upstream.sendPendingMessages()}),A.channel.on("connected",function(){return setTimeout(function(){return A.emit("connected")},0)}),A.channel.on("beforeConnect",function(){return A.telemetryTracker.addPartialEvent(new dr("Establish WebSocket connection","",new Date),on.TWILSOCK_CONNECT,e.TelemetryPoint.Start)}),A.channel.on("connected",function(){return A.telemetryTracker.addPartialEvent(new dr("Establish WebSocket connection","",new Date,new Date),on.TWILSOCK_CONNECT,e.TelemetryPoint.End)}),A.channel.on("beforeSendInit",function(){return A.telemetryTracker.addPartialEvent(new dr("Send Twilsock init","",new Date),on.TWILSOCK_INIT,e.TelemetryPoint.Start)}),A.channel.on("initialized",function(){return A.telemetryTracker.addPartialEvent(new dr("Send Twilsock init","Succeeded",new Date,new Date),on.TWILSOCK_INIT,e.TelemetryPoint.End)}),A.channel.on("sendInitFailed",function(){return A.telemetryTracker.addPartialEvent(new dr("Send Twilsock init","Failed",new Date,new Date),on.TWILSOCK_INIT,e.TelemetryPoint.End)}),A.channel.on("initialized",function(Ne){A.handleStorageId(E,Ne),Nn.storeToken(Ne.continuationToken,E),setTimeout(function(){return A.emit("initialized",Ne)},0)}),A.channel.on("disconnected",function(){return setTimeout(function(){return A.emit("disconnected")},0)}),A.channel.on("disconnected",function(){return A.upstream.rejectPendingMessages()}),A.channel.on("disconnected",function(){return A.offlineStorageDeferred.fail(new Ke("Client disconnected"))}),A.offlineStorageDeferred.promise.catch(function(){}),A}return G.default(R,[{key:"emit",value:function(E){for(var U,A=arguments.length,fe=new Array(A>1?A-1:0),ue=1;ue<A;ue++)fe[ue-1]=arguments[ue];return Fe.debug("Emitting ".concat(E.toString(),"(").concat(fe.map(function(Te){return JSON.stringify(Te)}).join(", "),")")),(U=te.default(ge.default(R.prototype),"emit",this)).call.apply(U,[this,E].concat(fe))}},{key:"handleStorageId",value:function(E,U){if(!U.offlineStorage)this.offlineStorageDeferred.fail(new Ke("No offline storage id"));else if(U.offlineStorage.hasOwnProperty(E))try{this.offlineStorageDeferred.set(Ei.create(U.offlineStorage[E])),Fe.debug("Offline storage for '".concat(E,"' product: ").concat(JSON.stringify(U.offlineStorage[E]),"."))}catch(A){this.offlineStorageDeferred.fail(new Ke("Failed to parse offline storage for ".concat(E," ").concat(JSON.stringify(U.offlineStorage[E]),". ").concat(A,".")))}else this.offlineStorageDeferred.fail(new Ke("No offline storage id for '".concat(E,"' 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 k=J.default(He.default.mark(function U(A){return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(Fe.trace("updating token '".concat(A,"'")),this.config.token!==A){ue.next=3;break}return ue.abrupt("return");case 3:return this.config.updateToken(A),ue.next=6,this.channel.updateToken(A);case 6:return ue.abrupt("return",ue.sent);case 7:case"end":return ue.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()},{key:"setNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A,fe){return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return Te.next=2,this.registrations.setNotificationsContext(A,fe);case 2:case"end":return Te.stop()}},U,this)}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"removeNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A){return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:return ue.next=2,this.registrations.removeNotificationsContext(A);case 2:case"end":return ue.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var k=J.default(He.default.mark(function U(){return He.default.wrap(function(fe){for(;;)switch(fe.prev=fe.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEventsIncludingUnfinished),fe.next=3,this.channel.disconnect();case 3:return fe.abrupt("return",fe.sent);case 4:case"end":return fe.stop()}},U,this)}));function E(){return k.apply(this,arguments)}return E}()},{key:"get",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue){return He.default.wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),Ne.next=3,this.upstream.send("GET",A,fe,void 0,ue);case 3:return Ne.abrupt("return",Ne.sent);case 4:case"end":return Ne.stop()}},U,this)}));function E(U,A,fe){return k.apply(this,arguments)}return E}()},{key:"post",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue,Te){return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),et.next=3,this.upstream.send("POST",A,fe,ue,Te);case 3:return et.abrupt("return",et.sent);case 4:case"end":return et.stop()}},U,this)}));function E(U,A,fe,ue){return k.apply(this,arguments)}return E}()},{key:"put",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue,Te){return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),et.next=3,this.upstream.send("PUT",A,fe,ue,Te);case 3:return et.abrupt("return",et.sent);case 4:case"end":return et.stop()}},U,this)}));function E(U,A,fe,ue){return k.apply(this,arguments)}return E}()},{key:"delete",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue,Te){return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),et.next=3,this.upstream.send("DELETE",A,fe,ue,Te);case 3:return et.abrupt("return",et.sent);case 4:case"end":return et.stop()}},U,this)}));function E(U,A,fe,ue){return k.apply(this,arguments)}return E}()},{key:"addTelemetryEvent",value:function(E){this.telemetryTracker.addTelemetryEvent(E),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(E,U,A){this.telemetryTracker.addPartialEvent(E,U,A),A===e.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),R}(we),e.TwilsockClient=M([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Oe("design:paramtypes",[String,String,Object])],e.TwilsockClient);var aa=function(){function D(B){Y.default(this,D),this.product=B,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return G.default(D,[{key:"populateInitRegistrations",value:function(R){var k=new Set(this.message_types);for(var E in R)k.add(R[E]);this.message_types=Array.from(k)}}]),D}();e.InitRegistration=aa,e.TelemetryEventDescription=dr,e.TelemetryTracker=ia,e.TransportUnavailableError=an,e.Twilsock=e.TwilsockClient,e.TwilsockError=Ke})(cf);var sR={},dw=Wt,LG=vt,DG=Ft,jG=lt,Jd=fu,FG=cu,UG=iu,BG=Mr,qG=au,ws=Object.assign,pw=Object.defineProperty,zG=LG([].concat),oR=!ws||jG(function(){if(dw&&ws({b:1},ws(pw({},"a",{enumerable:!0,get:function(){pw(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},r={},t=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[t]=7,n.split("").forEach(function(i){r[i]=i}),ws({},e)[t]!==7||Jd(ws({},r)).join("")!==n})?function(r,t){for(var n=BG(r),i=arguments.length,a=1,s=FG.f,o=UG.f;i>a;)for(var u=qG(arguments[a++]),c=s?zG(Jd(u),s(u)):Jd(u),l=c.length,h=0,v;l>h;)v=c[h++],(!dw||DG(o,u,v))&&(n[v]=u[v]);return n}:ws,WG=gt,hw=oR;WG({target:"Object",stat:!0,arity:2,forced:Object.assign!==hw},{assign:hw});var Eh={exports:{}},vw=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(vw){var mw=new Uint8Array(16);Eh.exports=function(){return vw(mw),mw}}else{var gw=new Array(16);Eh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),gw[r]=t>>>((r&3)<<3)&255;return gw}}var uR=Eh.exports,cR=[];for(var vc=0;vc<256;++vc)cR[vc]=(vc+256).toString(16).substr(1);function VG(e,r){var t=r||0,n=cR;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var lR=VG,GG=uR,HG=lR,yw,Yd,Xd=0,Qd=0;function KG(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||yw,s=e.clockseq!==void 0?e.clockseq:Yd;if(a==null||s==null){var o=GG();a==null&&(a=yw=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=Yd=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Qd+1,l=u-Xd+(c-Qd)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>Xd)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Xd=u,Qd=c,Yd=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||HG(i)}var JG=KG,YG=uR,XG=lR;function QG(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||YG)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||XG(i)}var ZG=QG,eH=JG,fR=ZG,Vm=fR;Vm.v1=eH;Vm.v4=fR;var tH=Vm;/*
159
+ `).concat(JSON.stringify(Te.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Te.t0);case 17:case"end":return Te.stop()}},U,this,[[1,13]])}));function E(){return k.apply(this,arguments)}return E}()},{key:"sendUpdate",value:function(){var k=J.default(He.default.mark(function U(){var A,fe,ue;return He.default.wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:return Fe.trace("sendUpdate"),A=new rn(this.config.token),Ne.prev=2,Ne.next=5,this.transport.sendWithReply(A);case 5:fe=Ne.sent,this.fsm.updateSuccess(fe.body),this.emit("tokenUpdated"),Ne.next=14;break;case 10:Ne.prev=10,Ne.t0=Ne.catch(2),Ne.t0 instanceof at?(ue=!1,Fe.warn("Token update rejected by server: ".concat(JSON.stringify(Ne.t0.reply.status))),Ne.t0.reply.status.code===401||Ne.t0.reply.status.code===403?(ue=!0,this.fsm.tokenRejected(Ne.t0.reply.status),Ne.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Ne.t0.reply.status.code===429?(this.modifyBackoff(Ne.t0.reply.body),this.fsm.updateError(Ne.t0.reply.status)):this.fsm.updateError(Ne.t0.reply.status),this.emitReplyConnectionError(Ne.t0.message,Ne.t0.reply,ue)):(this.emit("error",!1,Ne.t0.message,null,null),this.fsm.updateError(Ne.t0)),this.emit("tokenUpdated",Ne.t0);case 14:case"end":return Ne.stop()}},U,this,[[2,10]])}));function E(){return k.apply(this,arguments)}return E}()},{key:"emitReplyConnectionError",value:function(E,U,A){var fe=U.status&&U.status.description?U.status.description:E,ue=U.status.code,Te=U.status&&U.status.errorCode?U.status.errorCode:null;A&&(this.terminationReason=fe),this.emit("connectionError",{terminal:A,message:"Connection error: ".concat(fe),httpStatusCode:ue,errorCode:Te})}},{key:"cancelInit",value:function(){Fe.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Fe.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(E){Fe.trace("confirmReceiving");try{this.transport.send(new de(E.id))}catch(U){Fe.debug("failed to confirm packet receiving",U)}}},{key:"closeSocket",value:function(E){var U=this;Fe.trace("closeSocket (graceful: ".concat(E,")")),E&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),Gr(function(){return U.fsm.socketClosed()})}},{key:"connect",value:function(){Fe.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var E=this;return Fe.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(U){E.disconnectedPromiseResolve=U,E.fsm.userDisconnect()})}},{key:"updateToken",value:function(E){var U=this;return Fe.trace("updateToken:",E),new Promise(function(A,fe){U.once("tokenUpdated",function(ue){ue?fe(ue):A()}),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()}}]),R}(we),_i=function(){function D(){Y.default(this,D)}return G.default(D,null,[{key:"getMetadata",value:function(R){var k,E,U,A,fe,ue,Te,Ne,et=R&&R.clientMetadata?R.clientMetadata:{},hr=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Kr={env:(k=pe.name)!==null&&k!==void 0?k:"unknown",envv:(E=pe.version)!==null&&E!==void 0?E:"unknown",os:(U=(A=pe.os)===null||A===void 0?void 0:A.family)!==null&&U!==void 0?U:"unknown",osv:(fe=(ue=pe.os)===null||ue===void 0?void 0:ue.version)!==null&&fe!==void 0?fe:"unknown",osa:(Te=(Ne=pe.os)===null||Ne===void 0?void 0:Ne.architecture)!==null&&Te!==void 0?Te:"unknown",sdk:"js-default"},nr={};return hr.filter(function(un){return un in et||un in Kr}).forEach(function(un){return nr[un]=un in et?et[un]:Kr[un]}),nr}}]),D}(),ur=3e4;function xn(D){return D>=200&&D<300}function Zi(D){switch(Rt.default(D)){case"undefined":return"";case"object":return JSON.stringify(D);default:return D}}var nn=function(){function D(B,R){var k=this;Y.default(this,D),this.config=R,this.activeRequests=new Map,this.channel=B,this.channel.on("reply",function(E){return k.processReply(E)}),this.channel.on("disconnected",function(){k.activeRequests.forEach(function(E){clearTimeout(E.timeout),E.reject(new Ke("disconnected"))}),k.activeRequests.clear()})}return G.default(D,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(R){var k=this.activeRequests.get(R.id);k&&(clearTimeout(k.timeout),this.activeRequests.delete(R.id),xn(R.status.code)?k.resolve(R):(k.reject(new at("Transport failure: "+R.status.status,R)),Fe.trace("message rejected")))}},{key:"storeRequest",value:function(R,k,E){var U={resolve:k,reject:E,timeout:setTimeout(function(){Fe.trace("request",R,"is timed out"),E(new Ke("Twilsock: request timeout: "+R))},ur)};this.activeRequests.set(R,U)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new Ke("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var B=J.default(He.default.mark(function k(){var E,U,A;return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:return Fe.trace("sendInit"),E=_i.getMetadata(this.config),U=new it(this.config.token,this.config.continuationToken,E,this.config.initRegistrations,this.config.tweaks),ue.next=5,this.sendWithReply(U);case 5:return A=ue.sent,ue.abrupt("return",new sr(A.id,A.header.continuation_token,new Set(A.header.capabilities),A.header.continuation_token_status,A.header.offline_storage,A.header.init_registrations,A.header.debug_info));case 7:case"end":return ue.stop()}},k,this)}));function R(){return B.apply(this,arguments)}return R}()},{key:"sendClose",value:function(){var R=new Se;this.send(R)}},{key:"sendWithReply",value:function(R,k){var E=this;return new Promise(function(U,A){var fe=E.send(R,k);E.storeRequest(fe,U,A)})}},{key:"send",value:function(R,k){R.id=R.id||"TM".concat(I.v4());var E=Ve.createPacket(R,Zi(k));try{return this.channel.send(E),R.id}catch(U){throw Fe.debug("failed to send ",R,U),Fe.trace(U.stack),U}}}]),D}();function ea(D){var B=wi();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function wi(){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 Hr=function(D){se.default(R,D);var B=ea(R);function R(k){var E;return Y.default(this,R),E=B.call(this),Ue.default(L.default(E),"socket",null),E.url=k,E.url=k,E.WebSocket=r.WebSocket||r.MozWebSocket||{},E}return G.default(R,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var E=this;Fe.trace("connecting to socket");var U;try{U=new this.WebSocket(this.url)}catch(A){Fe.debug("Socket error: ".concat(this.url)),this.emit("socketError",A);return}U.binaryType="arraybuffer",U.onopen=function(){Fe.debug("socket opened ".concat(E.url)),E.emit("connected")},U.onclose=function(A){Fe.debug("socket closed",A),E.emit("disconnected",A)},U.onerror=function(A){Fe.debug("Socket error:",A),E.emit("socketError",A)},U.onmessage=function(A){E.emit("message",A.data)},this.socket=U}},{key:"send",value:function(E){return this.socket&&this.socket.send(E)}},{key:"close",value:function(){if(Fe.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}(we);function ta(D){var B=Aa();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Aa(){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 Ma=function(D){se.default(R,D);var B=ta(R);function R(k){var E;return Y.default(this,R),E=B.call(this),E.transport=k,E.registrations=new Map,E.registrationsInProgress=new Map,E}return G.default(R,[{key:"putNotificationContext",value:function(){var k=J.default(He.default.mark(function U(A,fe){var ue;return He.default.wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:return ue={method:"put_notification_ctx",notification_ctx_id:A},Ne.next=3,this.transport.sendWithReply(ue,fe);case 3:case"end":return Ne.stop()}},U,this)}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"deleteNotificationContext",value:function(){var k=J.default(He.default.mark(function U(A){var fe;return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return fe={method:"delete_notification_ctx",notification_ctx_id:A},Te.next=3,this.transport.sendWithReply(fe);case 3:case"end":return Te.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()},{key:"updateRegistration",value:function(){var k=J.default(He.default.mark(function U(A,fe){var ue,Te;return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return Fe.debug("update registration for context",A),ue=this.registrationsInProgress.get(A),ue||(ue=new Set,this.registrationsInProgress.set(A,ue)),Te=I.v4(),ue.add(Te),et.prev=5,et.next=8,this.putNotificationContext(A,fe);case 8:Fe.debug("registration attempt succeeded for context",fe),ue.delete(Te),ue.size===0&&(this.registrationsInProgress.delete(A),this.emit("registered",A)),et.next=19;break;case 13:et.prev=13,et.t0=et.catch(5),Fe.warn("registration attempt failed for context",fe),Fe.debug(et.t0),ue.delete(Te),ue.size===0&&(this.registrationsInProgress.delete(A),this.emit("registrationFailed",A,et.t0));case 19:case"end":return et.stop()}},U,this,[[5,13]])}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"updateRegistrations",value:function(){var k=J.default(He.default.mark(function U(){var A=this,fe;return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return Fe.trace("refreshing ".concat(this.registrations.size," registrations")),fe=[],this.registrations.forEach(function(Ne,et){fe.push(A.updateRegistration(et,Ne))}),Te.next=5,Promise.all(fe);case 5:case"end":return Te.stop()}},U,this)}));function E(){return k.apply(this,arguments)}return E}()},{key:"setNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A,fe){return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:if(!(!A||!fe)){Te.next=2;break}throw new Ke("Invalid arguments provided");case 2:return this.registrations.set(A,fe),Te.next=5,this.updateRegistration(A,fe);case 5:return Te.abrupt("return",Te.sent);case 6:case"end":return Te.stop()}},U,this)}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"removeNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A){return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(this.registrations.has(A)){ue.next=2;break}return ue.abrupt("return");case 2:return ue.next=4,this.deleteNotificationContext(A);case 4:this.transport.isConnected&&this.registrations.delete(A);case 5:case"end":return ue.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()}]),R}(we);function fr(D){var B=xa();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function xa(){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(D){se.default(R,D);var B=fr(R);function R(k,E,U){var A;return Y.default(this,R),A=B.call(this,E),A.status=k,A.description=E,A.body=U,A}return R}(Ke);function Yt(D){var B=Na();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Na(){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=function(D){se.default(R,D);var B=Yt(R);function R(k){return Y.default(this,R),B.call(this,k)}return R}(Ke),Si=2e4;function Ci(D){return D>=200&&D<300}function La(D){return D&&D.header&&D.header.http_status}function sn(D){var B=D.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(B){var R={protocol:B[1],host:B[2],hostname:B[3],port:B[4],pathname:B[5],search:B[6],hash:B[7],params:{}};if(R.search.length>0){var k=R.search.substring(1);R.params=k.split("&").map(function(E){return E.split("=")}).reduce(function(E,U){return E.hasOwnProperty(U[0])?Array.isArray(E[U[0]])?E[U[0]].push(U[1]):E[U[0]]=[E[U[0]],U[1]]:E[U[0]]=U[1],E},{})}return R}throw new Ke("Incorrect URI: "+D)}function wt(D,B){var R=sn(B),k={method:D,host:R.host,path:R.pathname};return R.params&&(k.params=R.params),k}function ra(D,B,R,k,E){return{to:wt(D,B),headers:R,body:k,grant:E}}var na=function(){function D(B,R,k){Y.default(this,D),this.config=k,this.transport=B,this.pendingMessages=[],this.twilsock=R}return G.default(D,[{key:"saveMessage",value:function(R){var k=this;return new Promise(function(E,U){var A={message:R,resolve:E,reject:U,alreadyRejected:!1,timeout:setTimeout(function(){Fe.debug("request is timed out"),U(new Ke("request '".concat(R.to.method,"' to '").concat(R.to.host,"' timed out"))),A.alreadyRejected=!0},Si)};k.pendingMessages.push(A)})}},{key:"sendPendingMessages",value:function(){for(var R=this,k=function(){var A=R.pendingMessages[0];if(!A.alreadyRejected)try{var fe=A.message;R.actualSend(fe).then(function(ue){return A.resolve(ue)}).catch(function(ue){return A.reject(ue)}),clearTimeout(A.timeout)}catch(ue){return Fe.debug("Failed to send pending message",ue),"break"}R.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var E=k();if(E==="break")break}}},{key:"rejectPendingMessages",value:function(){var R=this;this.pendingMessages.forEach(function(k){k.reject(new an("Unable to connect: "+R.twilsock.getTerminationReason)),k.alreadyRejected=!0,clearTimeout(k.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var B=J.default(He.default.mark(function k(E){var U,A,fe,ue,Te,Ne,et,hr;return He.default.wrap(function(nr){for(;;)switch(nr.prev=nr.next){case 0:return A=E.to,fe=E.headers,ue=E.body,Te=(U=E.grant)!==null&&U!==void 0?U:this.config.activeGrant,Ne={host:A.host,path:A.path,method:A.method,params:A.params,headers:fe},et=new ve(Te,fe["Content-Type"]||"application/json",Ne),Fe.trace("Sending upstream message",et),nr.next=9,this.transport.sendWithReply(et,ue);case 9:if(hr=nr.sent,Fe.trace("Received upstream message response",hr),!(La(hr)&&!Ci(hr.header.http_status.code))){nr.next=13;break}throw new Qn(hr.header.http_status.code,hr.header.http_status.status,hr.body);case 13:return nr.abrupt("return",{status:hr.header.http_status,headers:hr.header.http_headers,body:hr.body});case 14:case"end":return nr.stop()}},k,this)}));function R(k){return B.apply(this,arguments)}return R}()},{key:"send",value:function(R,k){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},U=arguments.length>3?arguments[3]:void 0,A=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new an("Unable to connect: "+this.twilsock.getTerminationReason));var fe=ra(R,k,E,U,A);return this.twilsock.isConnected?this.actualSend(fe):this.saveMessage(fe)}}]),D}(),Ti=function(){function D(){var B=this;Y.default(this,D),this._promise=new Promise(function(R,k){B._resolve=R,B._reject=k})}return G.default(D,[{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)}}]),D}(),Ei=function(){function D(B){Y.default(this,D),this.id=B}return G.default(D,null,[{key:"create",value:function(R){if(R instanceof Object&&"storage_id"in R)return new D(R.storage_id);throw new Ke('Field "storage_id" is missing')}}]),D}(),Zn=function(){function D(){return Y.default(this,D),Ue.default(this,"initializedFlag","twilio_twilsock_token_storage"),Ue.default(this,"tokenStoragePrefix","twilio_continuation_token_"),D._instance||(this.initialize(),D._instance=this),D._instance}return G.default(D,[{key:"sessionStorage",value:function(){try{return r.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return r.window}catch{return null}}},{key:"storeToken",value:function(R,k){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(k),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 k=this.sessionStorage.getItem(this.initializedFlag);k&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var E=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){E(R.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var R=[],k=0;k<this.sessionStorage.length;k++){var E=this.sessionStorage.key(k);E&&E.indexOf(this.tokenStoragePrefix)===0&&R.push(E)}var U=this.sessionStorage.removeItem;R.forEach(function(A){return U(A)}),U(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)}}]),D}();Ue.default(Zn,"_instance",null);var Nn=new Zn,dr=function(){function D(B,R,k,E,U,A){Y.default(this,D),this.title=B,this.details=R,this.start=k,this.type=U,this.id=A,this.end=E}return G.default(D,[{key:"toTelemetryEvent",value:function(){var R=new Date,k=this.start,E=this.end?this.end:R;if(E<k){var U=E;E=k,k=U}var A=k.getTime()-R.getTime(),fe=E.getTime()-R.getTime(),ue=new H(A,fe,this.title,this.details,this.id,this.type);return ue}}]),D}();e.TelemetryPoint=void 0,function(D){D[D.Start=0]="Start",D[D.End=1]="End"}(e.TelemetryPoint||(e.TelemetryPoint={})),e.EventSendingLimitation=void 0,function(D){D[D.MinEventsPortion=0]="MinEventsPortion",D[D.AnyEvents=1]="AnyEvents",D[D.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(e.EventSendingLimitation||(e.EventSendingLimitation={}));var ia=function(){function D(B,R){Y.default(this,D),Ue.default(this,"minEventsPortionToSend",50),Ue.default(this,"maxEventsPortionToSend",100),Ue.default(this,"pendingEvents",new Map),Ue.default(this,"readyEvents",[]),Ue.default(this,"hasInitializationFinished",!1),Ue.default(this,"_canSendTelemetry",!1),this.config=B,this.packetInterface=R}return G.default(D,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(R){Fe.debug("TelemetryTracker.canSendTelemetry: ".concat(R," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!R&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=R,R&&this.sendTelemetry(e.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,k,E){Fe.debug("Adding ".concat(E===e.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(k,"' event"));var U=this.pendingEvents.has(k);if(E===e.TelemetryPoint.Start)U&&Fe.debug("Overwriting starting point for '".concat(k,"' event")),this.pendingEvents.set(k,R);else{if(!U){Fe.info("Could not find started event for '".concat(k,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(k),R)),this.pendingEvents.delete(k)}}},{key:"getTelemetryToSend",value:function(R){return!this.canSendTelemetry||this.readyEvents.length==0?[]:R==e.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(R==e.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(R){var k=this,E=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),U=this.readyEvents.splice(0,E);return R&&U.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(A,fe){if(!(U.length>=k.maxEventsPortionToSend)){var ue=k.pendingEvents.get(fe);k.pendingEvents.delete(fe),U.push(new dr("[UNFINISHED] ".concat(ue.title),ue.details,ue.start,null,ue.type,ue.id))}}),U}},{key:"merge",value:function(R,k){return new dr(k.title?k.title:R.title,k.details?k.details:R.details,R.start,k.end,k.type?k.type:R.type,k.id?k.id:R.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(e.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(R){var k=this.getTelemetryToSend(R);if(k.length!==0)try{this.packetInterface.send(new ie(k.map(function(E){return E.toTelemetryEvent()})))}catch(E){Fe.debug("Error while sending ".concat(k.length," telemetry events due to ").concat(E,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(k)}}}]),D}();function pr(D){var B=Ir();return function(){var k=ge.default(D),E;if(B){var U=ge.default(this).constructor;E=Reflect.construct(k,arguments,U)}else E=k.apply(this,arguments);return ne.default(this,E)}}function Ir(){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(){Y.default(this,D)};Ue.default(on,"TWILSOCK_CONNECT","twilsock.sdk.connect"),Ue.default(on,"TWILSOCK_INIT","twilsock.sdk.init"),e.TwilsockClient=function(D){se.default(R,D);var B=pr(R);function R(k,E,U){var A;Y.default(this,R),A=B.call(this),Ue.default(L.default(A),"version",Ar),Ue.default(L.default(A),"offlineStorageDeferred",new Ti),U.continuationToken=U.continuationToken?U.continuationToken:Nn.getStoredToken(E);var fe=A.config=new $r(k,E,U);Fe.setLevel(fe.logLevel);var ue=new Hr(fe.url),Te=new nn(ue,fe);return A.channel=new gn(ue,Te,fe),A.registrations=new Ma(Te),A.upstream=new na(Te,A.channel,fe),A.telemetryTracker=new ia(fe,Te),A.channel.on("initialized",function(){return A.telemetryTracker.canSendTelemetry=!0}),ue.on("disconnected",function(){return A.telemetryTracker.canSendTelemetry=!1}),A.registrations.on("registered",function(Ne){return A.emit("registered",Ne)}),A.channel.on("message",function(Ne,et){return setTimeout(function(){return A.emit("message",Ne,et)},0)}),A.channel.on("stateChanged",function(Ne){return setTimeout(function(){return A.emit("stateChanged",Ne)},0)}),A.channel.on("connectionError",function(Ne){return setTimeout(function(){return A.emit("connectionError",Ne)},0)}),A.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return A.emit("tokenAboutToExpire")},0)}),A.channel.on("tokenExpired",function(){return setTimeout(function(){return A.emit("tokenExpired")},0)}),A.channel.on("connected",function(){return A.registrations.updateRegistrations()}),A.channel.on("connected",function(){return A.upstream.sendPendingMessages()}),A.channel.on("connected",function(){return setTimeout(function(){return A.emit("connected")},0)}),A.channel.on("beforeConnect",function(){return A.telemetryTracker.addPartialEvent(new dr("Establish WebSocket connection","",new Date),on.TWILSOCK_CONNECT,e.TelemetryPoint.Start)}),A.channel.on("connected",function(){return A.telemetryTracker.addPartialEvent(new dr("Establish WebSocket connection","",new Date,new Date),on.TWILSOCK_CONNECT,e.TelemetryPoint.End)}),A.channel.on("beforeSendInit",function(){return A.telemetryTracker.addPartialEvent(new dr("Send Twilsock init","",new Date),on.TWILSOCK_INIT,e.TelemetryPoint.Start)}),A.channel.on("initialized",function(){return A.telemetryTracker.addPartialEvent(new dr("Send Twilsock init","Succeeded",new Date,new Date),on.TWILSOCK_INIT,e.TelemetryPoint.End)}),A.channel.on("sendInitFailed",function(){return A.telemetryTracker.addPartialEvent(new dr("Send Twilsock init","Failed",new Date,new Date),on.TWILSOCK_INIT,e.TelemetryPoint.End)}),A.channel.on("initialized",function(Ne){A.handleStorageId(E,Ne),Nn.storeToken(Ne.continuationToken,E),setTimeout(function(){return A.emit("initialized",Ne)},0)}),A.channel.on("disconnected",function(){return setTimeout(function(){return A.emit("disconnected")},0)}),A.channel.on("disconnected",function(){return A.upstream.rejectPendingMessages()}),A.channel.on("disconnected",function(){return A.offlineStorageDeferred.fail(new Ke("Client disconnected"))}),A.offlineStorageDeferred.promise.catch(function(){}),A}return G.default(R,[{key:"emit",value:function(E){for(var U,A=arguments.length,fe=new Array(A>1?A-1:0),ue=1;ue<A;ue++)fe[ue-1]=arguments[ue];return Fe.debug("Emitting ".concat(E.toString(),"(").concat(fe.map(function(Te){return JSON.stringify(Te)}).join(", "),")")),(U=te.default(ge.default(R.prototype),"emit",this)).call.apply(U,[this,E].concat(fe))}},{key:"handleStorageId",value:function(E,U){if(!U.offlineStorage)this.offlineStorageDeferred.fail(new Ke("No offline storage id"));else if(U.offlineStorage.hasOwnProperty(E))try{this.offlineStorageDeferred.set(Ei.create(U.offlineStorage[E])),Fe.debug("Offline storage for '".concat(E,"' product: ").concat(JSON.stringify(U.offlineStorage[E]),"."))}catch(A){this.offlineStorageDeferred.fail(new Ke("Failed to parse offline storage for ".concat(E," ").concat(JSON.stringify(U.offlineStorage[E]),". ").concat(A,".")))}else this.offlineStorageDeferred.fail(new Ke("No offline storage id for '".concat(E,"' 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 k=J.default(He.default.mark(function U(A){return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(Fe.trace("updating token '".concat(A,"'")),this.config.token!==A){ue.next=3;break}return ue.abrupt("return");case 3:return this.config.updateToken(A),ue.next=6,this.channel.updateToken(A);case 6:return ue.abrupt("return",ue.sent);case 7:case"end":return ue.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()},{key:"setNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A,fe){return He.default.wrap(function(Te){for(;;)switch(Te.prev=Te.next){case 0:return Te.next=2,this.registrations.setNotificationsContext(A,fe);case 2:case"end":return Te.stop()}},U,this)}));function E(U,A){return k.apply(this,arguments)}return E}()},{key:"removeNotificationsContext",value:function(){var k=J.default(He.default.mark(function U(A){return He.default.wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:return ue.next=2,this.registrations.removeNotificationsContext(A);case 2:case"end":return ue.stop()}},U,this)}));function E(U){return k.apply(this,arguments)}return E}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var k=J.default(He.default.mark(function U(){return He.default.wrap(function(fe){for(;;)switch(fe.prev=fe.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEventsIncludingUnfinished),fe.next=3,this.channel.disconnect();case 3:return fe.abrupt("return",fe.sent);case 4:case"end":return fe.stop()}},U,this)}));function E(){return k.apply(this,arguments)}return E}()},{key:"get",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue){return He.default.wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),Ne.next=3,this.upstream.send("GET",A,fe,void 0,ue);case 3:return Ne.abrupt("return",Ne.sent);case 4:case"end":return Ne.stop()}},U,this)}));function E(U,A,fe){return k.apply(this,arguments)}return E}()},{key:"post",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue,Te){return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),et.next=3,this.upstream.send("POST",A,fe,ue,Te);case 3:return et.abrupt("return",et.sent);case 4:case"end":return et.stop()}},U,this)}));function E(U,A,fe,ue){return k.apply(this,arguments)}return E}()},{key:"put",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue,Te){return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),et.next=3,this.upstream.send("PUT",A,fe,ue,Te);case 3:return et.abrupt("return",et.sent);case 4:case"end":return et.stop()}},U,this)}));function E(U,A,fe,ue){return k.apply(this,arguments)}return E}()},{key:"delete",value:function(){var k=J.default(He.default.mark(function U(A,fe,ue,Te){return He.default.wrap(function(et){for(;;)switch(et.prev=et.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),et.next=3,this.upstream.send("DELETE",A,fe,ue,Te);case 3:return et.abrupt("return",et.sent);case 4:case"end":return et.stop()}},U,this)}));function E(U,A,fe,ue){return k.apply(this,arguments)}return E}()},{key:"addTelemetryEvent",value:function(E){this.telemetryTracker.addTelemetryEvent(E),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(E,U,A){this.telemetryTracker.addPartialEvent(E,U,A),A===e.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),R}(we),e.TwilsockClient=M([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Oe("design:paramtypes",[String,String,Object])],e.TwilsockClient);var aa=function(){function D(B){Y.default(this,D),this.product=B,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return G.default(D,[{key:"populateInitRegistrations",value:function(R){var k=new Set(this.message_types);for(var E in R)k.add(R[E]);this.message_types=Array.from(k)}}]),D}();e.InitRegistration=aa,e.TelemetryEventDescription=dr,e.TelemetryTracker=ia,e.TransportUnavailableError=an,e.Twilsock=e.TwilsockClient,e.TwilsockError=Ke})(cf);var oR={},pw=Wt,jG=vt,FG=Ft,UG=lt,Jd=fu,BG=cu,qG=iu,zG=Mr,WG=au,ws=Object.assign,hw=Object.defineProperty,VG=jG([].concat),uR=!ws||UG(function(){if(pw&&ws({b:1},ws(hw({},"a",{enumerable:!0,get:function(){hw(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},r={},t=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[t]=7,n.split("").forEach(function(i){r[i]=i}),ws({},e)[t]!==7||Jd(ws({},r)).join("")!==n})?function(r,t){for(var n=zG(r),i=arguments.length,a=1,s=BG.f,o=qG.f;i>a;)for(var u=WG(arguments[a++]),c=s?VG(Jd(u),s(u)):Jd(u),l=c.length,h=0,v;l>h;)v=c[h++],(!pw||FG(o,u,v))&&(n[v]=u[v]);return n}:ws,GG=gt,vw=uR;GG({target:"Object",stat:!0,arity:2,forced:Object.assign!==vw},{assign:vw});var Eh={exports:{}},mw=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(mw){var gw=new Uint8Array(16);Eh.exports=function(){return mw(gw),gw}}else{var yw=new Array(16);Eh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),yw[r]=t>>>((r&3)<<3)&255;return yw}}var cR=Eh.exports,lR=[];for(var vc=0;vc<256;++vc)lR[vc]=(vc+256).toString(16).substr(1);function HG(e,r){var t=r||0,n=lR;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var fR=HG,KG=cR,JG=fR,bw,Yd,Xd=0,Qd=0;function YG(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||bw,s=e.clockseq!==void 0?e.clockseq:Yd;if(a==null||s==null){var o=KG();a==null&&(a=bw=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=Yd=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Qd+1,l=u-Xd+(c-Qd)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>Xd)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Xd=u,Qd=c,Yd=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||JG(i)}var XG=YG,QG=cR,ZG=fR;function eH(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||QG)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||ZG(i)}var tH=eH,rH=XG,dR=tH,Vm=dR;Vm.v1=rH;Vm.v4=dR;var nH=Vm;/*
160
160
  @license
161
161
  The MIT License (MIT)
162
162
 
@@ -180,7 +180,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
180
180
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
181
181
  SOFTWARE.
182
182
 
183
- */(function(e){Object.defineProperty(e,"__esModule",{value:!0});var r=yu,t=gi,n=Ea,i=vi,a=mi,s=Pn,o=Cu,u=On,c=cf,l=os,h=us,v=Ji,m=uo,_=co,C=gr,I=tH,$=kr;function x(ve){return ve&&typeof ve=="object"&&"default"in ve?ve:{default:ve}}function N(ve){if(ve&&ve.__esModule)return ve;var ye=Object.create(null);return ve&&Object.keys(ve).forEach(function(ae){if(ae!=="default"){var de=Object.getOwnPropertyDescriptor(ve,ae);Object.defineProperty(ye,ae,de.get?de:{enumerable:!0,get:function(){return ve[ae]}})}}),ye.default=ve,Object.freeze(ye)}var q=x(r),X=x(t),J=x(n),G=x(i),L=x(a),te=x(s),se=x(o),ne=x(u),ge=x(l),Y=x(h),Ue=x(m),He=x(_),Rt=N(C),ft=N(I);function Pe(ve,ye,ae,de){var oe=arguments.length,me=oe<3?ye:de===null?de=Object.getOwnPropertyDescriptor(ye,ae):de,Se;if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.decorate=="function")me=Reflect.decorate(ve,ye,ae,de);else for(var Z=ve.length-1;Z>=0;Z--)(Se=ve[Z])&&(me=(oe<3?Se(me):oe>3?Se(ye,ae,me):Se(ye,ae))||me);return oe>3&&me&&Object.defineProperty(ye,ae,me),me}function he(ve,ye){if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(ve,ye)}var pe;function M(){}M.prototype=Object.create(null);function Oe(){Oe.init.call(this)}Oe.EventEmitter=Oe,Oe.usingDomains=!1,Oe.prototype.domain=void 0,Oe.prototype._events=void 0,Oe.prototype._maxListeners=void 0,Oe.defaultMaxListeners=10,Oe.init=function(){this.domain=null,Oe.usingDomains&&pe.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new M,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Oe.prototype.setMaxListeners=function(ye){if(typeof ye!="number"||ye<0||isNaN(ye))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=ye,this};function Je(ve){return ve._maxListeners===void 0?Oe.defaultMaxListeners:ve._maxListeners}Oe.prototype.getMaxListeners=function(){return Je(this)};function De(ve,ye,ae){if(ye)ve.call(ae);else for(var de=ve.length,oe=ke(ve,de),me=0;me<de;++me)oe[me].call(ae)}function we(ve,ye,ae,de){if(ye)ve.call(ae,de);else for(var oe=ve.length,me=ke(ve,oe),Se=0;Se<oe;++Se)me[Se].call(ae,de)}function Q(ve,ye,ae,de,oe){if(ye)ve.call(ae,de,oe);else for(var me=ve.length,Se=ke(ve,me),Z=0;Z<me;++Z)Se[Z].call(ae,de,oe)}function $t(ve,ye,ae,de,oe,me){if(ye)ve.call(ae,de,oe,me);else for(var Se=ve.length,Z=ke(ve,Se),ce=0;ce<Se;++ce)Z[ce].call(ae,de,oe,me)}function _e(ve,ye,ae,de){if(ye)ve.apply(ae,de);else for(var oe=ve.length,me=ke(ve,oe),Se=0;Se<oe;++Se)me[Se].apply(ae,de)}Oe.prototype.emit=function(ye){var ae,de,oe,me,Se,Z,ce,H=ye==="error";if(Z=this._events,Z)H=H&&Z.error==null;else if(!H)return!1;if(ce=this.domain,H){if(ae=arguments[1],ce)ae||(ae=new Error('Uncaught, unspecified "error" event')),ae.domainEmitter=this,ae.domain=ce,ae.domainThrown=!1,ce.emit("error",ae);else{if(ae instanceof Error)throw ae;var ie=new Error('Uncaught, unspecified "error" event. ('+ae+")");throw ie.context=ae,ie}return!1}if(de=Z[ye],!de)return!1;var K=typeof de=="function";switch(oe=arguments.length,oe){case 1:De(de,K,this);break;case 2:we(de,K,this,arguments[1]);break;case 3:Q(de,K,this,arguments[1],arguments[2]);break;case 4:$t(de,K,this,arguments[1],arguments[2],arguments[3]);break;default:for(me=new Array(oe-1),Se=1;Se<oe;Se++)me[Se-1]=arguments[Se];_e(de,K,this,me)}return!0};function le(ve,ye,ae,de){var oe,me,Se;if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');if(me=ve._events,me?(me.newListener&&(ve.emit("newListener",ye,ae.listener?ae.listener:ae),me=ve._events),Se=me[ye]):(me=ve._events=new M,ve._eventsCount=0),!Se)Se=me[ye]=ae,++ve._eventsCount;else if(typeof Se=="function"?Se=me[ye]=de?[ae,Se]:[Se,ae]:de?Se.unshift(ae):Se.push(ae),!Se.warned&&(oe=Je(ve),oe&&oe>0&&Se.length>oe)){Se.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+Se.length+" "+ye+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=ve,Z.type=ye,Z.count=Se.length,St(Z)}return ve}function St(ve){typeof console.warn=="function"?console.warn(ve):console.log(ve)}Oe.prototype.addListener=function(ye,ae){return le(this,ye,ae,!1)},Oe.prototype.on=Oe.prototype.addListener,Oe.prototype.prependListener=function(ye,ae){return le(this,ye,ae,!0)};function Le(ve,ye,ae){var de=!1;function oe(){ve.removeListener(ye,oe),de||(de=!0,ae.apply(ve,arguments))}return oe.listener=ae,oe}Oe.prototype.once=function(ye,ae){if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');return this.on(ye,Le(this,ye,ae)),this},Oe.prototype.prependOnceListener=function(ye,ae){if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(ye,Le(this,ye,ae)),this},Oe.prototype.removeListener=function(ye,ae){var de,oe,me,Se,Z;if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');if(oe=this._events,!oe)return this;if(de=oe[ye],!de)return this;if(de===ae||de.listener&&de.listener===ae)--this._eventsCount===0?this._events=new M:(delete oe[ye],oe.removeListener&&this.emit("removeListener",ye,de.listener||ae));else if(typeof de!="function"){for(me=-1,Se=de.length;Se-- >0;)if(de[Se]===ae||de[Se].listener&&de[Se].listener===ae){Z=de[Se].listener,me=Se;break}if(me<0)return this;if(de.length===1){if(de[0]=void 0,--this._eventsCount===0)return this._events=new M,this;delete oe[ye]}else pt(de,me);oe.removeListener&&this.emit("removeListener",ye,Z||ae)}return this},Oe.prototype.off=function(ve,ye){return this.removeListener(ve,ye)},Oe.prototype.removeAllListeners=function(ye){var ae,de;if(de=this._events,!de)return this;if(!de.removeListener)return arguments.length===0?(this._events=new M,this._eventsCount=0):de[ye]&&(--this._eventsCount===0?this._events=new M:delete de[ye]),this;if(arguments.length===0){for(var oe=Object.keys(de),me=0,Se;me<oe.length;++me)Se=oe[me],Se!=="removeListener"&&this.removeAllListeners(Se);return this.removeAllListeners("removeListener"),this._events=new M,this._eventsCount=0,this}if(ae=de[ye],typeof ae=="function")this.removeListener(ye,ae);else if(ae)do this.removeListener(ye,ae[ae.length-1]);while(ae[0]);return this},Oe.prototype.listeners=function(ye){var ae,de,oe=this._events;return oe?(ae=oe[ye],ae?typeof ae=="function"?de=[ae.listener||ae]:de=ot(ae):de=[]):de=[],de},Oe.listenerCount=function(ve,ye){return typeof ve.listenerCount=="function"?ve.listenerCount(ye):Gt.call(ve,ye)},Oe.prototype.listenerCount=Gt;function Gt(ve){var ye=this._events;if(ye){var ae=ye[ve];if(typeof ae=="function")return 1;if(ae)return ae.length}return 0}Oe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function pt(ve,ye){for(var ae=ye,de=ae+1,oe=ve.length;de<oe;ae+=1,de+=1)ve[ae]=ve[de];ve.pop()}function ke(ve,ye){for(var ae=new Array(ye);ye--;)ae[ye]=ve[ye];return ae}function ot(ve){for(var ye=new Array(ve.length),ae=0;ae<ye.length;++ae)ye[ae]=ve[ae].listener||ve[ae];return ye}var bt=Rt.getLogger("twilio-notificatiions");function $e(ve,ye){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(ve,":")].concat(Array.from(ye))}var Kt=function(){function ve(){X.default(this,ve)}return J.default(ve,[{key:"setLevel",value:function(ae){bt.setLevel(ae)}},{key:"trace",value:function(){if(bt.getLevel()==bt.levels.TRACE){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.debug.apply(null,$e("T",de))}}},{key:"debug",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.debug.apply(null,$e("D",de))}},{key:"info",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.info.apply(null,$e("I",de))}},{key:"warn",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.warn.apply(null,$e("W",de))}},{key:"error",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.error.apply(null,$e("E",de))}}]),ve}(),dt=new Kt;function qt(ve){var ye=rr();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}function rr(){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=J.default(function ve(){var ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",de=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;X.default(this,ve),this.token=ye,this.notificationId=ae,this.messageTypes=de});function Ar(ve,ye){return[].concat(He.default(He.default(ve).filter(function(ae){return!ye.has(ae)})),He.default(He.default(ye).filter(function(ae){return!ve.has(ae)})))}function Rr(ve,ye){var ae=new Set;return ve.notificationId!==ye.notificationId&&ae.add("notificationId"),ve.token!==ye.token&&ae.add("token"),Ar(ve.messageTypes,ye.messageTypes).length>0&&ae.add("messageType"),[ae.size>0,ae]}var Ct=function(ve){G.default(ae,ve);var ye=qt(ae);function ae(de){var oe;return X.default(this,ae),oe=ye.call(this),Y.default(ge.default(oe),"desiredState",new Fe),Y.default(ge.default(oe),"currentState",new Fe),Y.default(ge.default(oe),"_hasActiveAttempt",!1),oe.channelType=de,oe}return J.default(ae,[{key:"setNotificationId",value:function(oe){this.desiredState.notificationId=oe}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(oe){if(this.desiredState.messageTypes.has(oe)){dt.debug("message type '".concat(oe,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(oe)}},{key:"unsubscribe",value:function(oe){this.desiredState.messageTypes.has(oe)&&this.desiredState.messageTypes.delete(oe)}},{key:"updateToken",value:function(oe){this.desiredState.token=oe}},{key:"commitChanges",value:function(){var de=q.default(se.default.mark(function me(){var Se,Z,ce,H,ie,K;return se.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(!this._hasActiveAttempt){Ce.next=3;break}throw dt.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(Se=Rr(this.desiredState,this.currentState),Z=Ue.default(Se,2),ce=Z[0],H=Z[1],ce){Ce.next=6;break}return Ce.abrupt("return");case 6:if(this.currentState.notificationId||H.delete("notificationId"),dt.trace("Persisting ".concat(this.channelType," registration"),H,this.desiredState),Ce.prev=8,this._hasActiveAttempt=!0,ie=new Fe,ie.token=this.desiredState.token,ie.notificationId=this.desiredState.notificationId,ie.messageTypes=new Set(this.desiredState.messageTypes),!(ie.messageTypes.size>0)){Ce.next=24;break}return Ce.next=17,this.updateRegistration(ie,H);case 17:K=Ce.sent,this.currentState.token=K.token,this.currentState.notificationId=K.notificationId,this.currentState.messageTypes=new Set(K.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),Ce.next=30;break;case 24:return Ce.next=26,this.removeRegistration();case 26:this.currentState.token=ie.token,this.currentState.notificationId=ie.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:Ce.next=35;break;case 32:throw Ce.prev=32,Ce.t0=Ce.catch(8),Ce.t0;case 35:return Ce.prev=35,this._hasActiveAttempt=!1,Ce.finish(35);case 38:case"end":return Ce.stop()}},me,this,[[8,32,35,38]])}));function oe(){return de.apply(this,arguments)}return oe}()}]),ae}(Oe);function Pt(ve){var ye=yt();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}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 it={min:2e3,max:12e4,randomness:.2},Mt=function(ve){G.default(ae,ve);var ye=Pt(ae);function ae(de,oe,me,Se){var Z;return X.default(this,ae),Z=ye.call(this,de),Y.default(ge.default(Z),"registrationId",null),Z.context=oe,Z.twilsock=me,Z.registrarUrl=Se,Z}return J.default(ae,[{key:"updateRegistration",value:function(){var de=q.default(se.default.mark(function me(Se,Z){var ce=this,H,ie,K,xe,Ce;return se.default.wrap(function(Be){for(;;)switch(Be.prev=Be.next){case 0:if(!Z.has("notificationId")){Be.next=3;break}return Be.next=3,this.removeRegistration();case 3:if(!(!Se.notificationId||!Se.notificationId.length)){Be.next=6;break}throw dt.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return dt.trace("Registering",this.channelType,Se),H={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(Se.messageTypes),data:{registration_id:Se.notificationId}},ie=this.context.productId,K="".concat(this.registrarUrl,"?productId=").concat(ie),xe={"Content-Type":"application/json"},dt.trace("Creating registration for channel ".concat(this.channelType)),Be.prev=12,Be.next=15,new v.AsyncRetrier(it).run(function(){return ce.twilsock.post(K,xe,H,ie)});case 15:Ce=Be.sent,this.registrationId=Ce.body.id,dt.debug("Registration created: ",Ce),Be.next=24;break;case 20:throw Be.prev=20,Be.t0=Be.catch(12),dt.error("Registration failed: ",Be.t0),Be.t0;case 24:return Be.abrupt("return",Se);case 25:case"end":return Be.stop()}},me,this,[[12,20]])}));function oe(me,Se){return de.apply(this,arguments)}return oe}()},{key:"removeRegistration",value:function(){var de=q.default(se.default.mark(function me(){var Se=this,Z,ce,H;return se.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.registrationId){K.next=2;break}return K.abrupt("return");case 2:return Z=this.context.productId,ce="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(Z),H={"Content-Type":"application/json"},dt.trace("Removing registration for ".concat(this.channelType)),K.prev=6,K.next=9,new v.AsyncRetrier(Object.assign(it,{maxAttemptsCount:3})).run(function(){return Se.twilsock.delete(ce,H,{},Z)});case 9:this.registrationId=null,this.currentState.notificationId="",dt.debug("Registration removed for ".concat(this.channelType)),K.next=18;break;case 14:throw K.prev=14,K.t0=K.catch(6),dt.error("Failed to remove registration ",this.channelType,K.t0),K.t0;case 18:case"end":return K.stop()}},me,this,[[6,14]])}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"sendDeviceRemoveRequest",value:function(){var de=q.default(se.default.mark(function me(Se){var Z=this,ce,H,ie,K;return se.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(Se!==""){Ce.next=2;break}throw new Error("Empty registration ID");case 2:return ce=this.context.productId,H="".concat(this.registrarUrl,"?productId=").concat(ce),ie={"Content-Type":"application/json"},K={binding_type:this.channelType,address:Se},Ce.prev=6,dt.trace("Removing old registrations for ".concat(this.channelType)),Ce.next=10,new v.AsyncRetrier(Object.assign(it,{maxAttemptsCount:3})).run(function(){return Z.twilsock.delete(H,ie,K,ce)});case 10:this.registrationId=null,this.currentState.notificationId="",dt.debug("Registration removed for ".concat(this.channelType)),Ce.next=19;break;case 15:throw Ce.prev=15,Ce.t0=Ce.catch(6),dt.error("Failed to remove registration ",this.channelType,Ce.t0),Ce.t0;case 19:case"end":return Ce.stop()}},me,this,[[6,15]])}));function oe(me){return de.apply(this,arguments)}return oe}()}]),ae}(Ct);function It(ve){var ye=sr();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}function sr(){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 Nr=function(ve){G.default(ae,ve);var ye=It(ae);function ae(de,oe,me){var Se;return X.default(this,ae),Se=ye.call(this,"twilsock"),Y.default(ge.default(Se),"contextId",ft.v4()),Se.productId=de,Se.platform=oe,Se.twilsock=me,Se}return J.default(ae,[{key:"updateRegistration",value:function(){var de=q.default(se.default.mark(function me(Se,Z){var ce,H;return se.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(Z.has("messageType")){K.next=2;break}return K.abrupt("return",Se);case 2:return ce=Array.from(Se.messageTypes),H={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:ce},K.prev=4,K.next=7,this.twilsock.setNotificationsContext(this.contextId,H);case 7:K.next=13;break;case 9:throw K.prev=9,K.t0=K.catch(4),dt.error("Failed to update twilsock notification context: ".concat(K.t0)),K.t0;case 13:return K.abrupt("return",Se);case 14:case"end":return K.stop()}},me,this,[[4,9]])}));function oe(me,Se){return de.apply(this,arguments)}return oe}()},{key:"removeRegistration",value:function(){var de=q.default(se.default.mark(function me(){return se.default.wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:return Z.prev=0,Z.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:Z.next=9;break;case 5:throw Z.prev=5,Z.t0=Z.catch(0),dt.error("Failed to remove twilsock notification context: ".concat(Z.t0)),Z.t0;case 9:case"end":return Z.stop()}},me,this,[[0,5]])}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"sendDeviceRemoveRequest",value:function(){var de=q.default(se.default.mark(function me(Se){return se.default.wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:case"end":return ce.stop()}},me)}));function oe(me){return de.apply(this,arguments)}return oe}()}]),ae}(Ct);function tn(ve){var ye=rn();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}function rn(){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 Qt,lr=$.literal("apn","fcm","twilsock");e.Notifications=Qt=function(ve){G.default(ae,ve);var ye=tn(ae);function ae(de){var oe,me,Se,Z,ce,H,ie,K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};X.default(this,ae),ie=ye.call(this),K.logLevel=(oe=K.logLevel)!==null&&oe!==void 0?oe:"error",dt.setLevel(K.logLevel);var xe=(me=K.productId)!==null&&me!==void 0?me:"notifications",Ce=!K.twilsockClient,We=K.twilsockClient=(Se=K.twilsockClient)!==null&&Se!==void 0?Se:new c.TwilsockClient(de,xe,K),Be=(Z=K.notifications)!==null&&Z!==void 0?Z:{},Ve=(ce=(H=Be.region)!==null&&H!==void 0?H:K.region)!==null&&ce!==void 0?ce:"us1",Ye="https://ers.".concat(Ve,".twilio.com/v1/registrations"),Qe=Be.ersUrl||Ye;ie.connectors=new Map;var Ke=Qt._detectPlatform();return ie.connectors.set("apn",new Mt("apn",{protocolVersion:4,productId:xe,platform:Ke},We,Qe)),ie.connectors.set("fcm",new Mt("fcm",{protocolVersion:3,productId:xe,platform:Ke},We,Qe)),ie.connectors.set("twilsock",new Nr(xe,Ke,We)),We.on("stateChanged",function(Xe){return ie.emit("transportState",Xe)}),ie._connector("twilsock").on("stateChanged",function(Xe,Ze,at){return ie.emit("stateChanged",Xe,Ze,at)}),ie._connector("apn").on("stateChanged",function(Xe,Ze,at){return ie.emit("stateChanged",Xe,Ze,at)}),ie._connector("fcm").on("stateChanged",function(Xe,Ze,at){return ie.emit("stateChanged",Xe,Ze,at)}),We.on("message",function(Xe,Ze){return ie._routeMessage(Xe,Ze)}),ie.updateToken(de),Ce&&(We.connect(),ie.twilsock=We),ie}return J.default(ae,[{key:"shutdown",value:function(){var de=q.default(se.default.mark(function me(){return se.default.wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(this.connectors.clear(),!this.twilsock){Z.next=4;break}return Z.next=4,this.twilsock.disconnect();case 4:case"end":return Z.stop()}},me,this)}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"setPushRegistrationId",value:function(oe,me){dt.debug("Set ".concat(oe," push registration id '").concat(me,"'")),this._connector(oe).setNotificationId(me)}},{key:"subscribe",value:function(oe,me){dt.debug("Add ".concat(oe," subscriptions for message type ").concat(me)),this._connector(oe).subscribe(me)}},{key:"unsubscribe",value:function(oe,me){dt.debug("Remove ".concat(oe," subscriptions for message type ").concat(me)),this._connector(oe).unsubscribe(me)}},{key:"updateToken",value:function(oe){this.connectors.forEach(function(me){return me.updateToken(oe)})}},{key:"commitChanges",value:function(){var de=q.default(se.default.mark(function me(){var Se;return se.default.wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:return Se=[],this.connectors.forEach(function(H){H.isActive()&&Se.push(H.commitChanges())}),ce.next=4,Promise.all(Se);case 4:case"end":return ce.stop()}},me,this)}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"removeRegistrations",value:function(){var de=q.default(se.default.mark(function me(Se,Z){return se.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return H.next=2,this._connector(Se).sendDeviceRemoveRequest(Z);case 2:case"end":return H.stop()}},me,this)}));function oe(me,Se){return de.apply(this,arguments)}return oe}()},{key:"handlePushNotification",value:function(oe){return{messageType:oe.twi_message_type,payload:oe.payload}}},{key:"_routeMessage",value:function(oe,me){dt.debug("Notification message arrived: ",oe,me),this.emit("message",oe,me)}},{key:"_connector",value:function(oe){var me=this.connectors.get(oe);if(!me)throw new Error("Unknown channel type: ".concat(oe));return me}}],[{key:"_detectPlatform",value:function(){var oe="";return typeof navigator<"u"?(oe="unknown",typeof navigator.product<"u"&&(oe=navigator.product),typeof navigator.userAgent<"u"&&(oe=navigator.userAgent)):oe="web",oe.substring(0,128)}}]),ae}(Oe),Pe([$.validateTypes(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),Pe([$.validateTypes(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),Pe([$.validateTypes(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),Pe([$.validateTypes($.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String]),he("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),Pe([$.validateTypesAsync(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=Qt=Pe([$.validateConstructorTypes($.nonEmptyString,[$.pureObject,"undefined",$.literal(null)]),he("design:paramtypes",[String,Object])],e.Notifications)})(sR);var en={},qr={};/*
183
+ */(function(e){Object.defineProperty(e,"__esModule",{value:!0});var r=yu,t=gi,n=Ea,i=vi,a=mi,s=Pn,o=Cu,u=On,c=cf,l=os,h=us,v=Ji,m=uo,_=co,C=gr,I=nH,$=Rr;function x(ve){return ve&&typeof ve=="object"&&"default"in ve?ve:{default:ve}}function N(ve){if(ve&&ve.__esModule)return ve;var ye=Object.create(null);return ve&&Object.keys(ve).forEach(function(ae){if(ae!=="default"){var de=Object.getOwnPropertyDescriptor(ve,ae);Object.defineProperty(ye,ae,de.get?de:{enumerable:!0,get:function(){return ve[ae]}})}}),ye.default=ve,Object.freeze(ye)}var q=x(r),X=x(t),J=x(n),G=x(i),L=x(a),te=x(s),se=x(o),ne=x(u),ge=x(l),Y=x(h),Ue=x(m),He=x(_),Rt=N(C),ft=N(I);function Pe(ve,ye,ae,de){var oe=arguments.length,me=oe<3?ye:de===null?de=Object.getOwnPropertyDescriptor(ye,ae):de,Se;if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.decorate=="function")me=Reflect.decorate(ve,ye,ae,de);else for(var Z=ve.length-1;Z>=0;Z--)(Se=ve[Z])&&(me=(oe<3?Se(me):oe>3?Se(ye,ae,me):Se(ye,ae))||me);return oe>3&&me&&Object.defineProperty(ye,ae,me),me}function he(ve,ye){if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(ve,ye)}var pe;function M(){}M.prototype=Object.create(null);function Oe(){Oe.init.call(this)}Oe.EventEmitter=Oe,Oe.usingDomains=!1,Oe.prototype.domain=void 0,Oe.prototype._events=void 0,Oe.prototype._maxListeners=void 0,Oe.defaultMaxListeners=10,Oe.init=function(){this.domain=null,Oe.usingDomains&&pe.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new M,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Oe.prototype.setMaxListeners=function(ye){if(typeof ye!="number"||ye<0||isNaN(ye))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=ye,this};function Je(ve){return ve._maxListeners===void 0?Oe.defaultMaxListeners:ve._maxListeners}Oe.prototype.getMaxListeners=function(){return Je(this)};function De(ve,ye,ae){if(ye)ve.call(ae);else for(var de=ve.length,oe=ke(ve,de),me=0;me<de;++me)oe[me].call(ae)}function we(ve,ye,ae,de){if(ye)ve.call(ae,de);else for(var oe=ve.length,me=ke(ve,oe),Se=0;Se<oe;++Se)me[Se].call(ae,de)}function Q(ve,ye,ae,de,oe){if(ye)ve.call(ae,de,oe);else for(var me=ve.length,Se=ke(ve,me),Z=0;Z<me;++Z)Se[Z].call(ae,de,oe)}function $t(ve,ye,ae,de,oe,me){if(ye)ve.call(ae,de,oe,me);else for(var Se=ve.length,Z=ke(ve,Se),ce=0;ce<Se;++ce)Z[ce].call(ae,de,oe,me)}function _e(ve,ye,ae,de){if(ye)ve.apply(ae,de);else for(var oe=ve.length,me=ke(ve,oe),Se=0;Se<oe;++Se)me[Se].apply(ae,de)}Oe.prototype.emit=function(ye){var ae,de,oe,me,Se,Z,ce,H=ye==="error";if(Z=this._events,Z)H=H&&Z.error==null;else if(!H)return!1;if(ce=this.domain,H){if(ae=arguments[1],ce)ae||(ae=new Error('Uncaught, unspecified "error" event')),ae.domainEmitter=this,ae.domain=ce,ae.domainThrown=!1,ce.emit("error",ae);else{if(ae instanceof Error)throw ae;var ie=new Error('Uncaught, unspecified "error" event. ('+ae+")");throw ie.context=ae,ie}return!1}if(de=Z[ye],!de)return!1;var K=typeof de=="function";switch(oe=arguments.length,oe){case 1:De(de,K,this);break;case 2:we(de,K,this,arguments[1]);break;case 3:Q(de,K,this,arguments[1],arguments[2]);break;case 4:$t(de,K,this,arguments[1],arguments[2],arguments[3]);break;default:for(me=new Array(oe-1),Se=1;Se<oe;Se++)me[Se-1]=arguments[Se];_e(de,K,this,me)}return!0};function le(ve,ye,ae,de){var oe,me,Se;if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');if(me=ve._events,me?(me.newListener&&(ve.emit("newListener",ye,ae.listener?ae.listener:ae),me=ve._events),Se=me[ye]):(me=ve._events=new M,ve._eventsCount=0),!Se)Se=me[ye]=ae,++ve._eventsCount;else if(typeof Se=="function"?Se=me[ye]=de?[ae,Se]:[Se,ae]:de?Se.unshift(ae):Se.push(ae),!Se.warned&&(oe=Je(ve),oe&&oe>0&&Se.length>oe)){Se.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+Se.length+" "+ye+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=ve,Z.type=ye,Z.count=Se.length,St(Z)}return ve}function St(ve){typeof console.warn=="function"?console.warn(ve):console.log(ve)}Oe.prototype.addListener=function(ye,ae){return le(this,ye,ae,!1)},Oe.prototype.on=Oe.prototype.addListener,Oe.prototype.prependListener=function(ye,ae){return le(this,ye,ae,!0)};function Le(ve,ye,ae){var de=!1;function oe(){ve.removeListener(ye,oe),de||(de=!0,ae.apply(ve,arguments))}return oe.listener=ae,oe}Oe.prototype.once=function(ye,ae){if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');return this.on(ye,Le(this,ye,ae)),this},Oe.prototype.prependOnceListener=function(ye,ae){if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(ye,Le(this,ye,ae)),this},Oe.prototype.removeListener=function(ye,ae){var de,oe,me,Se,Z;if(typeof ae!="function")throw new TypeError('"listener" argument must be a function');if(oe=this._events,!oe)return this;if(de=oe[ye],!de)return this;if(de===ae||de.listener&&de.listener===ae)--this._eventsCount===0?this._events=new M:(delete oe[ye],oe.removeListener&&this.emit("removeListener",ye,de.listener||ae));else if(typeof de!="function"){for(me=-1,Se=de.length;Se-- >0;)if(de[Se]===ae||de[Se].listener&&de[Se].listener===ae){Z=de[Se].listener,me=Se;break}if(me<0)return this;if(de.length===1){if(de[0]=void 0,--this._eventsCount===0)return this._events=new M,this;delete oe[ye]}else pt(de,me);oe.removeListener&&this.emit("removeListener",ye,Z||ae)}return this},Oe.prototype.off=function(ve,ye){return this.removeListener(ve,ye)},Oe.prototype.removeAllListeners=function(ye){var ae,de;if(de=this._events,!de)return this;if(!de.removeListener)return arguments.length===0?(this._events=new M,this._eventsCount=0):de[ye]&&(--this._eventsCount===0?this._events=new M:delete de[ye]),this;if(arguments.length===0){for(var oe=Object.keys(de),me=0,Se;me<oe.length;++me)Se=oe[me],Se!=="removeListener"&&this.removeAllListeners(Se);return this.removeAllListeners("removeListener"),this._events=new M,this._eventsCount=0,this}if(ae=de[ye],typeof ae=="function")this.removeListener(ye,ae);else if(ae)do this.removeListener(ye,ae[ae.length-1]);while(ae[0]);return this},Oe.prototype.listeners=function(ye){var ae,de,oe=this._events;return oe?(ae=oe[ye],ae?typeof ae=="function"?de=[ae.listener||ae]:de=ot(ae):de=[]):de=[],de},Oe.listenerCount=function(ve,ye){return typeof ve.listenerCount=="function"?ve.listenerCount(ye):Gt.call(ve,ye)},Oe.prototype.listenerCount=Gt;function Gt(ve){var ye=this._events;if(ye){var ae=ye[ve];if(typeof ae=="function")return 1;if(ae)return ae.length}return 0}Oe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function pt(ve,ye){for(var ae=ye,de=ae+1,oe=ve.length;de<oe;ae+=1,de+=1)ve[ae]=ve[de];ve.pop()}function ke(ve,ye){for(var ae=new Array(ye);ye--;)ae[ye]=ve[ye];return ae}function ot(ve){for(var ye=new Array(ve.length),ae=0;ae<ye.length;++ae)ye[ae]=ve[ae].listener||ve[ae];return ye}var bt=Rt.getLogger("twilio-notificatiions");function $e(ve,ye){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(ve,":")].concat(Array.from(ye))}var Kt=function(){function ve(){X.default(this,ve)}return J.default(ve,[{key:"setLevel",value:function(ae){bt.setLevel(ae)}},{key:"trace",value:function(){if(bt.getLevel()==bt.levels.TRACE){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.debug.apply(null,$e("T",de))}}},{key:"debug",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.debug.apply(null,$e("D",de))}},{key:"info",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.info.apply(null,$e("I",de))}},{key:"warn",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.warn.apply(null,$e("W",de))}},{key:"error",value:function(){for(var ae=arguments.length,de=new Array(ae),oe=0;oe<ae;oe++)de[oe]=arguments[oe];bt.error.apply(null,$e("E",de))}}]),ve}(),dt=new Kt;function qt(ve){var ye=rr();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}function rr(){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=J.default(function ve(){var ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",de=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;X.default(this,ve),this.token=ye,this.notificationId=ae,this.messageTypes=de});function Ar(ve,ye){return[].concat(He.default(He.default(ve).filter(function(ae){return!ye.has(ae)})),He.default(He.default(ye).filter(function(ae){return!ve.has(ae)})))}function $r(ve,ye){var ae=new Set;return ve.notificationId!==ye.notificationId&&ae.add("notificationId"),ve.token!==ye.token&&ae.add("token"),Ar(ve.messageTypes,ye.messageTypes).length>0&&ae.add("messageType"),[ae.size>0,ae]}var Ct=function(ve){G.default(ae,ve);var ye=qt(ae);function ae(de){var oe;return X.default(this,ae),oe=ye.call(this),Y.default(ge.default(oe),"desiredState",new Fe),Y.default(ge.default(oe),"currentState",new Fe),Y.default(ge.default(oe),"_hasActiveAttempt",!1),oe.channelType=de,oe}return J.default(ae,[{key:"setNotificationId",value:function(oe){this.desiredState.notificationId=oe}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(oe){if(this.desiredState.messageTypes.has(oe)){dt.debug("message type '".concat(oe,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(oe)}},{key:"unsubscribe",value:function(oe){this.desiredState.messageTypes.has(oe)&&this.desiredState.messageTypes.delete(oe)}},{key:"updateToken",value:function(oe){this.desiredState.token=oe}},{key:"commitChanges",value:function(){var de=q.default(se.default.mark(function me(){var Se,Z,ce,H,ie,K;return se.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(!this._hasActiveAttempt){Ce.next=3;break}throw dt.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(Se=$r(this.desiredState,this.currentState),Z=Ue.default(Se,2),ce=Z[0],H=Z[1],ce){Ce.next=6;break}return Ce.abrupt("return");case 6:if(this.currentState.notificationId||H.delete("notificationId"),dt.trace("Persisting ".concat(this.channelType," registration"),H,this.desiredState),Ce.prev=8,this._hasActiveAttempt=!0,ie=new Fe,ie.token=this.desiredState.token,ie.notificationId=this.desiredState.notificationId,ie.messageTypes=new Set(this.desiredState.messageTypes),!(ie.messageTypes.size>0)){Ce.next=24;break}return Ce.next=17,this.updateRegistration(ie,H);case 17:K=Ce.sent,this.currentState.token=K.token,this.currentState.notificationId=K.notificationId,this.currentState.messageTypes=new Set(K.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),Ce.next=30;break;case 24:return Ce.next=26,this.removeRegistration();case 26:this.currentState.token=ie.token,this.currentState.notificationId=ie.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:Ce.next=35;break;case 32:throw Ce.prev=32,Ce.t0=Ce.catch(8),Ce.t0;case 35:return Ce.prev=35,this._hasActiveAttempt=!1,Ce.finish(35);case 38:case"end":return Ce.stop()}},me,this,[[8,32,35,38]])}));function oe(){return de.apply(this,arguments)}return oe}()}]),ae}(Oe);function Pt(ve){var ye=yt();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}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 it={min:2e3,max:12e4,randomness:.2},Mt=function(ve){G.default(ae,ve);var ye=Pt(ae);function ae(de,oe,me,Se){var Z;return X.default(this,ae),Z=ye.call(this,de),Y.default(ge.default(Z),"registrationId",null),Z.context=oe,Z.twilsock=me,Z.registrarUrl=Se,Z}return J.default(ae,[{key:"updateRegistration",value:function(){var de=q.default(se.default.mark(function me(Se,Z){var ce=this,H,ie,K,xe,Ce;return se.default.wrap(function(Be){for(;;)switch(Be.prev=Be.next){case 0:if(!Z.has("notificationId")){Be.next=3;break}return Be.next=3,this.removeRegistration();case 3:if(!(!Se.notificationId||!Se.notificationId.length)){Be.next=6;break}throw dt.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return dt.trace("Registering",this.channelType,Se),H={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(Se.messageTypes),data:{registration_id:Se.notificationId}},ie=this.context.productId,K="".concat(this.registrarUrl,"?productId=").concat(ie),xe={"Content-Type":"application/json"},dt.trace("Creating registration for channel ".concat(this.channelType)),Be.prev=12,Be.next=15,new v.AsyncRetrier(it).run(function(){return ce.twilsock.post(K,xe,H,ie)});case 15:Ce=Be.sent,this.registrationId=Ce.body.id,dt.debug("Registration created: ",Ce),Be.next=24;break;case 20:throw Be.prev=20,Be.t0=Be.catch(12),dt.error("Registration failed: ",Be.t0),Be.t0;case 24:return Be.abrupt("return",Se);case 25:case"end":return Be.stop()}},me,this,[[12,20]])}));function oe(me,Se){return de.apply(this,arguments)}return oe}()},{key:"removeRegistration",value:function(){var de=q.default(se.default.mark(function me(){var Se=this,Z,ce,H;return se.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.registrationId){K.next=2;break}return K.abrupt("return");case 2:return Z=this.context.productId,ce="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(Z),H={"Content-Type":"application/json"},dt.trace("Removing registration for ".concat(this.channelType)),K.prev=6,K.next=9,new v.AsyncRetrier(Object.assign(it,{maxAttemptsCount:3})).run(function(){return Se.twilsock.delete(ce,H,{},Z)});case 9:this.registrationId=null,this.currentState.notificationId="",dt.debug("Registration removed for ".concat(this.channelType)),K.next=18;break;case 14:throw K.prev=14,K.t0=K.catch(6),dt.error("Failed to remove registration ",this.channelType,K.t0),K.t0;case 18:case"end":return K.stop()}},me,this,[[6,14]])}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"sendDeviceRemoveRequest",value:function(){var de=q.default(se.default.mark(function me(Se){var Z=this,ce,H,ie,K;return se.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(Se!==""){Ce.next=2;break}throw new Error("Empty registration ID");case 2:return ce=this.context.productId,H="".concat(this.registrarUrl,"?productId=").concat(ce),ie={"Content-Type":"application/json"},K={binding_type:this.channelType,address:Se},Ce.prev=6,dt.trace("Removing old registrations for ".concat(this.channelType)),Ce.next=10,new v.AsyncRetrier(Object.assign(it,{maxAttemptsCount:3})).run(function(){return Z.twilsock.delete(H,ie,K,ce)});case 10:this.registrationId=null,this.currentState.notificationId="",dt.debug("Registration removed for ".concat(this.channelType)),Ce.next=19;break;case 15:throw Ce.prev=15,Ce.t0=Ce.catch(6),dt.error("Failed to remove registration ",this.channelType,Ce.t0),Ce.t0;case 19:case"end":return Ce.stop()}},me,this,[[6,15]])}));function oe(me){return de.apply(this,arguments)}return oe}()}]),ae}(Ct);function It(ve){var ye=sr();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}function sr(){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 Nr=function(ve){G.default(ae,ve);var ye=It(ae);function ae(de,oe,me){var Se;return X.default(this,ae),Se=ye.call(this,"twilsock"),Y.default(ge.default(Se),"contextId",ft.v4()),Se.productId=de,Se.platform=oe,Se.twilsock=me,Se}return J.default(ae,[{key:"updateRegistration",value:function(){var de=q.default(se.default.mark(function me(Se,Z){var ce,H;return se.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(Z.has("messageType")){K.next=2;break}return K.abrupt("return",Se);case 2:return ce=Array.from(Se.messageTypes),H={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:ce},K.prev=4,K.next=7,this.twilsock.setNotificationsContext(this.contextId,H);case 7:K.next=13;break;case 9:throw K.prev=9,K.t0=K.catch(4),dt.error("Failed to update twilsock notification context: ".concat(K.t0)),K.t0;case 13:return K.abrupt("return",Se);case 14:case"end":return K.stop()}},me,this,[[4,9]])}));function oe(me,Se){return de.apply(this,arguments)}return oe}()},{key:"removeRegistration",value:function(){var de=q.default(se.default.mark(function me(){return se.default.wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:return Z.prev=0,Z.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:Z.next=9;break;case 5:throw Z.prev=5,Z.t0=Z.catch(0),dt.error("Failed to remove twilsock notification context: ".concat(Z.t0)),Z.t0;case 9:case"end":return Z.stop()}},me,this,[[0,5]])}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"sendDeviceRemoveRequest",value:function(){var de=q.default(se.default.mark(function me(Se){return se.default.wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:case"end":return ce.stop()}},me)}));function oe(me){return de.apply(this,arguments)}return oe}()}]),ae}(Ct);function tn(ve){var ye=rn();return function(){var de=te.default(ve),oe;if(ye){var me=te.default(this).constructor;oe=Reflect.construct(de,arguments,me)}else oe=de.apply(this,arguments);return L.default(this,oe)}}function rn(){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 Qt,lr=$.literal("apn","fcm","twilsock");e.Notifications=Qt=function(ve){G.default(ae,ve);var ye=tn(ae);function ae(de){var oe,me,Se,Z,ce,H,ie,K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};X.default(this,ae),ie=ye.call(this),K.logLevel=(oe=K.logLevel)!==null&&oe!==void 0?oe:"error",dt.setLevel(K.logLevel);var xe=(me=K.productId)!==null&&me!==void 0?me:"notifications",Ce=!K.twilsockClient,We=K.twilsockClient=(Se=K.twilsockClient)!==null&&Se!==void 0?Se:new c.TwilsockClient(de,xe,K),Be=(Z=K.notifications)!==null&&Z!==void 0?Z:{},Ve=(ce=(H=Be.region)!==null&&H!==void 0?H:K.region)!==null&&ce!==void 0?ce:"us1",Ye="https://ers.".concat(Ve,".twilio.com/v1/registrations"),Qe=Be.ersUrl||Ye;ie.connectors=new Map;var Ke=Qt._detectPlatform();return ie.connectors.set("apn",new Mt("apn",{protocolVersion:4,productId:xe,platform:Ke},We,Qe)),ie.connectors.set("fcm",new Mt("fcm",{protocolVersion:3,productId:xe,platform:Ke},We,Qe)),ie.connectors.set("twilsock",new Nr(xe,Ke,We)),We.on("stateChanged",function(Xe){return ie.emit("transportState",Xe)}),ie._connector("twilsock").on("stateChanged",function(Xe,Ze,at){return ie.emit("stateChanged",Xe,Ze,at)}),ie._connector("apn").on("stateChanged",function(Xe,Ze,at){return ie.emit("stateChanged",Xe,Ze,at)}),ie._connector("fcm").on("stateChanged",function(Xe,Ze,at){return ie.emit("stateChanged",Xe,Ze,at)}),We.on("message",function(Xe,Ze){return ie._routeMessage(Xe,Ze)}),ie.updateToken(de),Ce&&(We.connect(),ie.twilsock=We),ie}return J.default(ae,[{key:"shutdown",value:function(){var de=q.default(se.default.mark(function me(){return se.default.wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(this.connectors.clear(),!this.twilsock){Z.next=4;break}return Z.next=4,this.twilsock.disconnect();case 4:case"end":return Z.stop()}},me,this)}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"setPushRegistrationId",value:function(oe,me){dt.debug("Set ".concat(oe," push registration id '").concat(me,"'")),this._connector(oe).setNotificationId(me)}},{key:"subscribe",value:function(oe,me){dt.debug("Add ".concat(oe," subscriptions for message type ").concat(me)),this._connector(oe).subscribe(me)}},{key:"unsubscribe",value:function(oe,me){dt.debug("Remove ".concat(oe," subscriptions for message type ").concat(me)),this._connector(oe).unsubscribe(me)}},{key:"updateToken",value:function(oe){this.connectors.forEach(function(me){return me.updateToken(oe)})}},{key:"commitChanges",value:function(){var de=q.default(se.default.mark(function me(){var Se;return se.default.wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:return Se=[],this.connectors.forEach(function(H){H.isActive()&&Se.push(H.commitChanges())}),ce.next=4,Promise.all(Se);case 4:case"end":return ce.stop()}},me,this)}));function oe(){return de.apply(this,arguments)}return oe}()},{key:"removeRegistrations",value:function(){var de=q.default(se.default.mark(function me(Se,Z){return se.default.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return H.next=2,this._connector(Se).sendDeviceRemoveRequest(Z);case 2:case"end":return H.stop()}},me,this)}));function oe(me,Se){return de.apply(this,arguments)}return oe}()},{key:"handlePushNotification",value:function(oe){return{messageType:oe.twi_message_type,payload:oe.payload}}},{key:"_routeMessage",value:function(oe,me){dt.debug("Notification message arrived: ",oe,me),this.emit("message",oe,me)}},{key:"_connector",value:function(oe){var me=this.connectors.get(oe);if(!me)throw new Error("Unknown channel type: ".concat(oe));return me}}],[{key:"_detectPlatform",value:function(){var oe="";return typeof navigator<"u"?(oe="unknown",typeof navigator.product<"u"&&(oe=navigator.product),typeof navigator.userAgent<"u"&&(oe=navigator.userAgent)):oe="web",oe.substring(0,128)}}]),ae}(Oe),Pe([$.validateTypes(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),Pe([$.validateTypes(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),Pe([$.validateTypes(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),Pe([$.validateTypes($.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String]),he("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),Pe([$.validateTypesAsync(lr,$.nonEmptyString),he("design:type",Function),he("design:paramtypes",[String,String]),he("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=Qt=Pe([$.validateConstructorTypes($.nonEmptyString,[$.pureObject,"undefined",$.literal(null)]),he("design:paramtypes",[String,Object])],e.Notifications)})(oR);var en={},qr={};/*
184
184
  @license
185
185
  Copyright (c) 2021 Twilio Inc.
186
186
 
@@ -191,11 +191,11 @@ The above copyright notice and this permission notice shall be included in all c
191
191
  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.
192
192
 
193
193
 
194
- */Object.defineProperty(qr,"__esModule",{value:!0});var rH=On,nH=uo,iH=co,aH=gi,sH=vi,oH=mi,uH=Pn;function fs(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var qs=fs(rH),Za=fs(nH),Zd=fs(iH),cH=fs(aH),lH=fs(sH),fH=fs(oH),bw=fs(uH),Ia=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function dH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=pH(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
195
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function pH(e,r){if(e){if(typeof e=="string")return _w(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _w(e,r)}}function _w(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var dR=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ia(function(i){var a=!1,s=[],o=dH(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;if(typeof c=="string"){a=a||qs.default(i)===c,s.push("of type ".concat(c));continue}a=a||i instanceof c,s.push("an instance of ".concat(c.name))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})};function hH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=vH(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
196
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function vH(e,r){if(e){if(typeof e=="string")return ww(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ww(e,r)}}function ww(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var mH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ia(function(i){var a=!1,s=[],o=hH(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;a=a||i===c,s.push(typeof c=="string"?'"'.concat(c,'"'):"".concat(c))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})},gH=Ia(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),yH=Ia(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),bH=Ia(function(e){return[qs.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function _H(e){var r=wH();return function(){var n=bw.default(e),i;if(r){var a=bw.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return fH.default(this,i)}}function wH(){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 tu(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=SH(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
197
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function SH(e,r){if(e){if(typeof e=="string")return Sw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Sw(e,r)}}function Sw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var gf=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=tu(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Za.default(i.value,2),s=a[0],o=a[1],u=Km(r[s],o),c=Za.default(u,4),l=c[0],h=c[1],v=c[2],m=c[3];if(!l){var _=s+1;throw new Error("Argument ".concat(_," is expected to be ").concat(v).concat(m," but got ").concat(h))}}}catch(C){n.e(C)}finally{n.f()}},pR=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(qs.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),qs.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=qs.default(r)),n},CH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Gm(t);return function(a){return function(s){lH.default(u,s);var o=_H(u);function u(){cH.default(this,u);for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return gf(i,l),o.call.apply(o,[this].concat(l))}return u}(a)}},TH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Gm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return gf(i,l),u.apply(this,l)}}},EH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Gm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];try{gf(i,l)}catch(v){return Promise.reject(v)}return u.apply(this,l)}}},Gm=function(r){var t=[],n=tu(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Hm(a))}}catch(s){n.e(s)}finally{n.f()}return t},Hm=function(r){var t=[],n=Array.isArray(r)?r:[r],i=tu(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(dR(s));continue}t.push(s)}}catch(o){i.e(o)}finally{i.f()}return t},Km=function(r,t){var n=[],i,a=!1,s=tu(r),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,c=tu(u.checks),l;try{for(c.s();!(l=c.n()).done;){var h=l.value,v=h(t),m=Za.default(v,3),_=m[0],C=m[1],I=m[2];a=a||_,!i&&I&&(i=I),C&&(n=typeof C=="string"?[].concat(Zd.default(n),[C]):[].concat(Zd.default(n),Zd.default(C)))}}catch(q){c.e(q)}finally{c.f()}}}catch(q){s.e(q)}finally{s.f()}if(a)return[!0];var $=i||pR(t),x=n.length-1,N=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,$,N,x>1?";":","]},kH=function(r,t){return Ia(function(n){if(qs.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=Za.default(a[i],2),o=s[0],u=s[1],c=Km(Hm(u),n[o]),l=Za.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"valid ".concat(r,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(r,' (key "').concat(o,'" is ').concat(v,")")]}return[!0]})};function RH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=$H(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
198
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function $H(e,r){if(e){if(typeof e=="string")return Cw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Cw(e,r)}}function Cw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var IH=function(r,t){return Ia(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=RH(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Za.default(a.value,2),o=s[0],u=s[1],c=Km(Hm(t),u),l=Za.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})};qr.array=IH;qr.custom=Ia;qr.literal=mH;qr.nonEmptyString=gH;qr.nonNegativeInteger=yH;qr.objectSchema=kH;qr.pureObject=bH;qr.runtimeTypeValidation=gf;qr.stringifyReceivedType=pR;qr.type=dR;qr.validateConstructorTypes=CH;qr.validateTypes=TH;qr.validateTypesAsync=EH;var kh={exports:{}},Tw=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(Tw){var Ew=new Uint8Array(16);kh.exports=function(){return Tw(Ew),Ew}}else{var kw=new Array(16);kh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),kw[r]=t>>>((r&3)<<3)&255;return kw}}var hR=kh.exports,vR=[];for(var mc=0;mc<256;++mc)vR[mc]=(mc+256).toString(16).substr(1);function OH(e,r){var t=r||0,n=vR;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var mR=OH,PH=hR,AH=mR,Rw,ep,tp=0,rp=0;function MH(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||Rw,s=e.clockseq!==void 0?e.clockseq:ep;if(a==null||s==null){var o=PH();a==null&&(a=Rw=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=ep=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:rp+1,l=u-tp+(c-rp)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>tp)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");tp=u,rp=c,ep=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||AH(i)}var xH=MH,NH=hR,LH=mR;function DH(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||NH)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||LH(i)}var jH=DH,FH=xH,gR=jH,Jm=gR;Jm.v1=FH;Jm.v4=gR;var UH=Jm;/*
194
+ */Object.defineProperty(qr,"__esModule",{value:!0});var iH=On,aH=uo,sH=co,oH=gi,uH=vi,cH=mi,lH=Pn;function fs(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var qs=fs(iH),Za=fs(aH),Zd=fs(sH),fH=fs(oH),dH=fs(uH),pH=fs(cH),_w=fs(lH),Ia=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return{checks:t}};function hH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=vH(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
195
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function vH(e,r){if(e){if(typeof e=="string")return ww(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ww(e,r)}}function ww(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var pR=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ia(function(i){var a=!1,s=[],o=hH(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;if(typeof c=="string"){a=a||qs.default(i)===c,s.push("of type ".concat(c));continue}a=a||i instanceof c,s.push("an instance of ".concat(c.name))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})};function mH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=gH(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
196
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function gH(e,r){if(e){if(typeof e=="string")return Sw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Sw(e,r)}}function Sw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var yH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return Ia(function(i){var a=!1,s=[],o=mH(t),u;try{for(o.s();!(u=o.n()).done;){var c=u.value;a=a||i===c,s.push(typeof c=="string"?'"'.concat(c,'"'):"".concat(c))}}catch(l){o.e(l)}finally{o.f()}return[a,s]})},bH=Ia(function(e){return[typeof e=="string"&&e.length>0,"a non-empty string"]}),_H=Ia(function(e){return[typeof e=="number"&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),wH=Ia(function(e){return[qs.default(e)==="object"&&e!==null&&!Array.isArray(e),"a pure object (non-null and non-array)"]});function SH(e){var r=CH();return function(){var n=_w.default(e),i;if(r){var a=_w.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return pH.default(this,i)}}function CH(){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 tu(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=TH(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
197
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function TH(e,r){if(e){if(typeof e=="string")return Cw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Cw(e,r)}}function Cw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var gf=function(r,t){if(t.length>r.length)throw new Error("Expected at most ".concat(r.length," argument(s), but got ").concat(t.length));for(;t.length<r.length;)t.push(void 0);var n=tu(t.entries()),i;try{for(n.s();!(i=n.n()).done;){var a=Za.default(i.value,2),s=a[0],o=a[1],u=Km(r[s],o),c=Za.default(u,4),l=c[0],h=c[1],v=c[2],m=c[3];if(!l){var _=s+1;throw new Error("Argument ".concat(_," is expected to be ").concat(v).concat(m," but got ").concat(h))}}}catch(C){n.e(C)}finally{n.f()}},hR=function(r){var t,n,i=["undefined","boolean","number","bigint","string"];if(i.includes(qs.default(r))&&(n=typeof r=="string"?'"'.concat(r,'"'):"".concat(r)),qs.default(r)==="object"&&(r==null||(t=r.constructor)===null||t===void 0?void 0:t.name)!=="Object"){var a;n=r===null?"null":"instance of ".concat(r==null||(a=r.constructor)===null||a===void 0?void 0:a.name)}return n||(n=qs.default(r)),n},EH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Gm(t);return function(a){return function(s){dH.default(u,s);var o=SH(u);function u(){fH.default(this,u);for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return gf(i,l),o.call.apply(o,[this].concat(l))}return u}(a)}},kH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Gm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypes decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return gf(i,l),u.apply(this,l)}}},RH=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];var i=Gm(t);return function(a,s,o){if(typeof o.value!="function")throw new Error("The validateTypesAsync decorator can only be applied to methods");var u=o.value;o.value=function(){for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];try{gf(i,l)}catch(v){return Promise.reject(v)}return u.apply(this,l)}}},Gm=function(r){var t=[],n=tu(r),i;try{for(n.s();!(i=n.n()).done;){var a=i.value;t.push(Hm(a))}}catch(s){n.e(s)}finally{n.f()}return t},Hm=function(r){var t=[],n=Array.isArray(r)?r:[r],i=tu(n),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;if(typeof s=="string"||typeof s=="function"){t.push(pR(s));continue}t.push(s)}}catch(o){i.e(o)}finally{i.f()}return t},Km=function(r,t){var n=[],i,a=!1,s=tu(r),o;try{for(s.s();!(o=s.n()).done;){var u=o.value,c=tu(u.checks),l;try{for(c.s();!(l=c.n()).done;){var h=l.value,v=h(t),m=Za.default(v,3),_=m[0],C=m[1],I=m[2];a=a||_,!i&&I&&(i=I),C&&(n=typeof C=="string"?[].concat(Zd.default(n),[C]):[].concat(Zd.default(n),Zd.default(C)))}}catch(q){c.e(q)}finally{c.f()}}}catch(q){s.e(q)}finally{s.f()}if(a)return[!0];var $=i||hR(t),x=n.length-1,N=x>0?"".concat(n.slice(0,x).join(", ")," or ").concat(n[x]):n.join(", ");return[!1,$,N,x>1?";":","]},$H=function(r,t){return Ia(function(n){if(qs.default(n)!=="object"||n===null||Array.isArray(n))return[!1,"valid ".concat(r," (should be a pure object)")];for(var i=0,a=Object.entries(t);i<a.length;i++){var s=Za.default(a[i],2),o=s[0],u=s[1],c=Km(Hm(u),n[o]),l=Za.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"valid ".concat(r,' (key "').concat(o,'" should be ').concat(m,")"),"malformed ".concat(r,' (key "').concat(o,'" is ').concat(v,")")]}return[!0]})};function IH(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=OH(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
198
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function OH(e,r){if(e){if(typeof e=="string")return Tw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Tw(e,r)}}function Tw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var PH=function(r,t){return Ia(function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(r)];var i=IH(n.entries()),a;try{for(i.s();!(a=i.n()).done;){var s=Za.default(a.value,2),o=s[0],u=s[1],c=Km(Hm(t),u),l=Za.default(c,3),h=l[0],v=l[1],m=l[2];if(!h)return[!1,"a valid array of ".concat(r," (index ").concat(o," should be ").concat(m,")"),"malformed array of ".concat(r," (index ").concat(o," is ").concat(v,")")]}}catch(_){i.e(_)}finally{i.f()}return[!0]})};qr.array=PH;qr.custom=Ia;qr.literal=yH;qr.nonEmptyString=bH;qr.nonNegativeInteger=_H;qr.objectSchema=$H;qr.pureObject=wH;qr.runtimeTypeValidation=gf;qr.stringifyReceivedType=hR;qr.type=pR;qr.validateConstructorTypes=EH;qr.validateTypes=kH;qr.validateTypesAsync=RH;var kh={exports:{}},Ew=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(Ew){var kw=new Uint8Array(16);kh.exports=function(){return Ew(kw),kw}}else{var Rw=new Array(16);kh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),Rw[r]=t>>>((r&3)<<3)&255;return Rw}}var vR=kh.exports,mR=[];for(var mc=0;mc<256;++mc)mR[mc]=(mc+256).toString(16).substr(1);function AH(e,r){var t=r||0,n=mR;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var gR=AH,MH=vR,xH=gR,$w,ep,tp=0,rp=0;function NH(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||$w,s=e.clockseq!==void 0?e.clockseq:ep;if(a==null||s==null){var o=MH();a==null&&(a=$w=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=ep=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:rp+1,l=u-tp+(c-rp)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>tp)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");tp=u,rp=c,ep=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||xH(i)}var LH=NH,DH=vR,jH=gR;function FH(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||DH)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||jH(i)}var UH=FH,BH=LH,yR=UH,Jm=yR;Jm.v1=BH;Jm.v4=yR;var qH=Jm;/*
199
199
  @license
200
200
  The following license applies to all parts of this software except as
201
201
  documented below.
@@ -294,11 +294,11 @@ This software includes Event-to-Promise library under the following license
294
294
  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
295
295
  THIS SOFTWARE.
296
296
 
297
- */Object.defineProperty(en,"__esModule",{value:!0});var BH=yu,qH=gi,zH=Ea,WH=os,VH=vi,GH=mi,HH=Pn,KH=us,JH=Cu,YH=On,Ee=qr,El=cf,XH=mf,QH=gr,ZH=uo,yR=Ji,bR=UH,e9=gm,t9=aR;function hn(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function Ym(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}var Me=hn(BH),Et=hn(qH),At=hn(zH),si=hn(WH),zr=hn(VH),Oa=hn(GH),cr=hn(HH),xt=hn(KH),ee=hn(JH),_R=hn(YH),r9=hn(XH),n9=Ym(QH),wR=hn(ZH),i9=Ym(bR),Iu=hn(e9),gc=Ym(t9);function kt(e,r,t,n){var i=arguments.length,a=i<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,t):n,s;if((typeof Reflect>"u"?"undefined":_R.default(Reflect))==="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,r,t,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(i<3?s(a):i>3?s(r,t,a):s(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a}function Re(e,r){if((typeof Reflect>"u"?"undefined":_R.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,r)}var a9;function ya(){}ya.prototype=Object.create(null);function Lt(){Lt.init.call(this)}Lt.EventEmitter=Lt;Lt.usingDomains=!1;Lt.prototype.domain=void 0;Lt.prototype._events=void 0;Lt.prototype._maxListeners=void 0;Lt.defaultMaxListeners=10;Lt.init=function(){this.domain=null,Lt.usingDomains&&a9.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ya,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Lt.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function SR(e){return e._maxListeners===void 0?Lt.defaultMaxListeners:e._maxListeners}Lt.prototype.getMaxListeners=function(){return SR(this)};function s9(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Ou(e,n),a=0;a<n;++a)i[a].call(t)}function o9(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Ou(e,i),s=0;s<i;++s)a[s].call(t,n)}function u9(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Ou(e,a),o=0;o<a;++o)s[o].call(t,n,i)}function c9(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,o=Ou(e,s),u=0;u<s;++u)o[u].call(t,n,i,a)}function l9(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Ou(e,i),s=0;s<i;++s)a[s].apply(t,n)}Lt.prototype.emit=function(r){var t,n,i,a,s,o,u,c=r==="error";if(o=this._events,o)c=c&&o.error==null;else if(!c)return!1;if(u=this.domain,c){if(t=arguments[1],u)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=u,t.domainThrown=!1,u.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=o[r],!n)return!1;var h=typeof n=="function";switch(i=arguments.length,i){case 1:s9(n,h,this);break;case 2:o9(n,h,this,arguments[1]);break;case 3:u9(n,h,this,arguments[1],arguments[2]);break;case 4:c9(n,h,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];l9(n,h,this,a)}return!0};function CR(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new ya,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=SR(e),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=r,o.count=s.length,f9(o)}return e}function f9(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Lt.prototype.addListener=function(r,t){return CR(this,r,t,!1)};Lt.prototype.on=Lt.prototype.addListener;Lt.prototype.prependListener=function(r,t){return CR(this,r,t,!0)};function TR(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Lt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,TR(this,r,t)),this};Lt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,TR(this,r,t)),this};Lt.prototype.removeListener=function(r,t){var n,i,a,s,o;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new ya:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){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 ya,this;delete i[r]}else d9(n,a);i.removeListener&&this.emit("removeListener",r,o||t)}return this};Lt.prototype.off=function(e,r){return this.removeListener(e,r)};Lt.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ya,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new ya:delete n[r]),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 ya,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};Lt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=p9(t):n=[]):n=[],n};Lt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):ER.call(e,r)};Lt.prototype.listenerCount=ER;function ER(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Lt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function d9(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function Ou(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function p9(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}var Xs=function(){function e(r){Et.default(this,e),this.base=r,this.args=new Array,this.paths=new Array}return At.default(e,[{key:"pathSegment",value:function(t){return this.paths.push(encodeURIComponent(t)),this}},{key:"queryParam",value:function(t,n){return typeof n<"u"&&this.args.push(encodeURIComponent(t)+"="+encodeURIComponent(n)),this}},{key:"build",value:function(){var t=this.base;return this.paths.length&&(t+="/"+this.paths.join("/")),this.args.length&&(t+="?"+this.args.join("&")),t}}]),e}();function kR(e){var r=h9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function h9(){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 Qr=function(e){zr.default(t,e);var r=kR(t);function t(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 Et.default(this,t),i=r.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 t}(r9.default(Error)),v9=function(e){zr.default(t,e);var r=kR(t);function t(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 Et.default(this,t),i=r.call(this,n,a,s),i.body=o,i}return t}(Qr);function Wn(e){return JSON.parse(JSON.stringify(e))}function RR(e){var r=e===void 0||Xm(e);if(!r)throw new Qr("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function m9(e){return!isNaN(parseInt(e))&&isFinite(e)}function Xm(e){return m9(e)&&e>0}var Ss=n9.getLogger("twilio-sync");function Ro(e,r){return["".concat(new Date().toISOString()," Sync ").concat(e,":")].concat(Array.from(r))}var Ot={setLevel:function(r){Ss.setLevel(r)},trace:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.trace.apply(null,Ro("T",t))},debug:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.debug.apply(null,Ro("D",t))},info:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.info.apply(null,Ro("I",t))},warn:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.warn.apply(null,Ro("W",t))},error:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.error.apply(null,Ro("E",t))}},g9="/v4/Subscriptions",y9="/v3/Maps",b9="/v3/Lists",_9="/v3/Documents",w9="/v3/Streams",S9="/v3/Insights";function C9(e,r,t){return e&&typeof e[r]<"u"?e[r]:t}var T9=function(){function e(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Et.default(this,e);var t=r.region||"us1",n="https://cds.".concat(t,".twilio.com"),i=r.cdsUri||n;this.settings={subscriptionsUri:i+g9,documentsUri:i+_9,listsUri:i+b9,mapsUri:i+y9,streamsUri:i+w9,insightsUri:i+S9,sessionStorageEnabled:C9(r.Sync,"enableSessionStorage",!0),productId:r.productId}}return At.default(e,[{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}}]),e}();function $o(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=E9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
298
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function E9(e,r){if(e){if(typeof e=="string")return $w(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return $w(e,r)}}function $w(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var k9=function(){function e(r){Et.default(this,e),this.localObject=r,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return At.default(e,[{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(t,n){this.localObject._update(t,n)}},{key:"updatePending",value:function(t,n){this.pendingAction=t,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(t){this.rejectedWithError=t.error,this.updatePending(null,null),this.localObject.reportFailure(new Qr("Failed to subscribe on service events: ".concat(t.error.message),t.error.status,t.error.code))}},{key:"complete",value:function(t){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(t)}},{key:"setSubscriptionState",value:function(t){this.localObject._setSubscriptionState(t)}}]),e}(),R9=function(){function e(r){var t=this;Et.default(this,e),xt.default(this,"isConnected",!1),xt.default(this,"maxBatchSize",100),xt.default(this,"subscriptionTtlTimer",null),xt.default(this,"pendingPokeReason",null),this.services=r,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=yR.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=t.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?t.applyNewSubscriptionUpdateBatch(a,s):(t.backoff.reset(),Ot.debug("All subscriptions resolved."))})}return At.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function t(a,s,o,u){var c=[],l=$o(a),h;try{for(l.s();!(h=l.n()).done;){var v=wR.default(h.value,2),m=v[0],_=v[1],C=s.get(m);if(!C&&o!==_.pendingAction&&!_.rejectedWithError&&(c.push(_),u&&c.length>=u))break}}catch(I){l.e(I)}finally{l.f()}return c}var n=t(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=t(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 r=Me.default(ee.default.mark(function n(i,a){var s=this,o,u,c,l,h,v,m,_,C,I,$,x,N,q,X,J;return ee.default.wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.isConnected){L.next=4;break}return Ot.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),L.abrupt("return");case 4:a=this.processLocalActions(i,a),o=new Date().getTime(),u=$o(a);try{for(u.s();!(c=u.n()).done;)l=c.value,this.recordActionAttemptOn(l,i,o)}catch(te){u.e(te)}finally{u.f()}return h=this.pendingPokeReason,this.pendingPokeReason=null,L.prev=10,L.next=13,this.request(i,o,h,a);case 13:v=L.sent,m=v.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(_=v.body.ttl_in_s,C=!isNaN(parseFloat(_))&&isFinite(_),I=C&&_>0,I&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},_*1e3))),i==="establish"&&($=v.body.estimated_delivery_in_ms,x=!isNaN(parseFloat($))&&isFinite($),N=x&&$>0,N?setTimeout(function(){return s.verifyPokeDelivery(o,$,a)},$):Ot.error("Invalid timeout: ".concat($)),a.filter(function(te){return te.pendingCorrelationId===o}).forEach(function(te){return te.setSubscriptionState("response_in_flight")})),this.backoff.reset(),L.next=26;break;case 21:L.prev=21,L.t0=L.catch(10),q=$o(a);try{for(q.s();!(X=q.n()).done;)J=X.value,this.recordActionFailureOn(J,i)}catch(te){q.e(te)}finally{q.f()}L.t0 instanceof El.TransportUnavailableError?(Ot.debug("Twilsock connection (required for subscription) not ready (c:".concat(o,"); waiting…")),this.backoff.reset()):(Ot.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(o,"); retrying"),L.t0),this.persist());case 26:case"end":return L.stop()}},n,this,[[10,21]])}));function t(n,i){return r.apply(this,arguments)}return t}()},{key:"verifyPokeDelivery",value:function(t,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(t),o=s?new Date().getTime()-s:n;if(o>=n)i.filter(function(c){return c.pendingCorrelationId===t}).forEach(function(c){c.updatePending(null,null),c.retryCount++,a.persisted.delete(c.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(t);else{var u=n-o;setTimeout(function(){return a.verifyPokeDelivery(t,n,i)},u)}}},{key:"processLocalActions",value:function(t,n){return t==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(t,n,i){if(t.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(t.sid,t),t.updatePending(n,i);else{var a=this.persisted.get(t.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(t,n){t.setSubscriptionState("none"),t.updatePending(null,null),n==="establish"&&this.persisted.delete(t.sid)}},{key:"request",value:function(t,n,i,a){var s=a.map(function(c){return{object_sid:c.sid,object_type:c.type,last_event_id:t==="establish"?c.lastEventId:void 0,index_name:t==="establish"?c.indexName:void 0,query_string:t==="establish"?c.queryString:void 0}}),o=a.filter(function(c){return c.retryCount>0}).length;Ot.debug("Attempting '".concat(t,"' request (c:").concat(n,"):"),s);var u={event_protocol_version:4,action:t,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(t,n){Ot.debug("Establishing intent to subscribe to ".concat(t));var i=this.subscriptions.get(t);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(t),this.subscriptions.set(t,new k9(n)),this.persist())}},{key:"remove",value:function(t){Ot.debug("Establishing intent to unsubscribe from ".concat(t));var n=this.subscriptions.delete(t);n&&this.persist()}},{key:"acceptMessage",value:function(t,n){Ot.trace("Subscriptions received",t);var i=t.event_type,a=typeof t.events<"u"?t.events:[t.event],s=t.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var o=$o(a),u;try{for(o.s();!(u=o.n()).done;){var c=u.value,l=void 0;switch(t.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(c,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(c,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(c,s);break;case(l=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var h=void 0;switch(l[0]){case"map_":h=c.map_sid;break;case"list_":h=c.list_sid;break;case"document_":h=c.document_sid;break;case"stream_":h=c.stream_sid;break;case"live_query_":h=c.query_id,n=!1,t.strictly_ordered===!0&&(n=!0);break;default:h=void 0}this.applyEventToSubscribedEntity(h,c,i,n);break}default:Ot.debug("Dropping unknown message type ".concat(i));break}}}catch(v){o.e(v)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(t,n){var i=t.object_sid,a=this.persisted.get(t.object_sid);a&&a.pendingCorrelationId===n?t.replay_status==="interrupted"?(Ot.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()):t.replay_status==="completed"&&(Ot.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(t.last_event_id),this.persisted.set(t.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):Ot.debug("Late message for ".concat(t.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(t,n){var i=this.persisted.get(t.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(t.object_sid)):Ot.debug("Late message for ".concat(t.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(t,n){var i=t.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(Ot.error("Failed to subscribe on ".concat(s.sid),t.error),s.markAsFailed(t),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(t,n,i,a){var s=this;if(t){a=a||function(){var u=s.persisted.get(t);return u&&u.isEstablished}();var o=this.subscriptions.get(t);o?(n.type=i,o.update(n,a)):Ot.debug("Message dropped for SID '".concat(t,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(t){this.isConnected=t,t&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(t){Ot.debug("Triggering event replay for all subscriptions, reason=".concat(t)),this.pendingPokeReason=t,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=$o(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(l){i.e(l)}finally{i.f()}this.persisted.clear();for(var o=0,u=n;o<u.length;o++){var c=u[o];this.persisted.set(c.sid,c)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}(),$9=4e3,I9=6e4,O9=9e4,P9=.2;function Iw(e){if(e.body&&e.body.message)return e.body.message;switch(e.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function Ow(e){return e.body?e.body.code:0}function Io(e){return e.status===409?new v9(Iw(e),e.status,Ow(e),e.body):e.status?new Qr(Iw(e),e.status,Ow(e)):e instanceof El.TransportUnavailableError?e:new Qr(e.message,0,0)}var A9=function(){function e(r,t,n){Et.default(this,e),this.clientInfo=r,this.config=t,this.transport=n}return At.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+i9.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:$9,max:I9,maxAttemptsTime:O9,randomness:P9},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(t){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 yR.Retrier(n.backoffConfig());u.on("attempt",function(){t().then(function(c){return u.succeeded(c)}).catch(function(c){if(o.includes(c.status)){var l=parseInt(c.headers?c.headers["Retry-After"]:null);u.failed(Io(c),isNaN(l)?null:l*1e3)}else c.message==="Twilsock disconnected"?u.failed(Io(c)):(u.removeAllListeners(),u.cancel(),s(Io(c)))})}),u.on("succeeded",function(c){a(c)}),u.on("cancelled",function(c){return s(Io(c))}),u.on("failed",function(c){return s(Io(c))}),u.start()})}},{key:"get",value:function(t){var n=this,i=this.createHeaders();return Ot.debug("GET",t,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(t,i,n.config.productId)},!0)}},{key:"post",value:function(t,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),Ot.debug("POST",t,"ID:",o["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(t,o,n,a.config.productId)},s)}},{key:"put",value:function(t,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),Ot.debug("PUT",t,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(t,s,n,a.config.productId)},!1)}},{key:"delete",value:function(t){var n=this,i=this.createHeaders();return Ot.debug("DELETE",t,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(t,i,n.config.productId)},!1)}}]),e}(),M9=function(){function e(r,t){Et.default(this,e),this.config=r,this.storageId=null;try{this.storage=t||sessionStorage}catch{}}return At.default(e,[{key:"storageKey",value:function(t,n){return"".concat(this.storageId,"::").concat(t,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(t){this.storageId=t}},{key:"store",value:function(t,n,i){return this.isReady?this._store(this.storageKey(t,n),i):null}},{key:"read",value:function(t,n){return this.isReady?this._read(this.storageKey(t,n)):null}},{key:"remove",value:function(t,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(t,n)),i&&this.storage.removeItem(this.storageKey(t,i))}catch{}}},{key:"update",value:function(t,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(t,n),a),i&&this._apply(this.storageKey(t,i),a)}},{key:"_store",value:function(t,n){try{this.storage.setItem(t,JSON.stringify(n))}catch{}}},{key:"_read",value:function(t){try{var n=this.storage.getItem(t);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(t,n){var i=this._read(t);if(!i)return!1;this._store(t,Object.assign(i,n))}}]),e}();function x9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=N9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
299
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function N9(e,r){if(e){if(typeof e=="string")return Pw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Pw(e,r)}}function Pw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Pu=function(){function e(r,t){Et.default(this,e),this.services=r,this.removalHandler=t,this.subscriptionState="none",this._attachedListeners=new Map}return At.default(e,[{key:"_advanceLastEventId",value:function(t,n){}},{key:"reportFailure",value:function(t){t.status===404?this.onRemoved(!1):this.broadcastEventToListeners("failure",t)}},{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(t){this.subscriptionState=t,this.broadcastEventToListeners("_subscriptionStateChanged",t)}},{key:"close",value:function(){this._unsubscribe(),this.removalHandler!=null&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(t){var n=t.listenerUuid,i=this._attachedListeners.get(n);i||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(n,t))}},{key:"detach",value:function(t){this._attachedListeners.delete(t),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(t,n){var i=x9(this._attachedListeners.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.emit(t,n)}}catch(o){i.e(o)}finally{i.f()}}}]),e}(),$R=function(){function e(r){Et.default(this,e),xt.default(this,"queuedRequests",[]),xt.default(this,"isRequestInFlight",!1),this.inputMergingFunction=r}return At.default(e,[{key:"add",value:function(t,n){var i=this,a=new Promise(function(s,o){return i.queuedRequests.push({input:t,requestFunction:n,resolve:s,reject:o})});return this.wakeupQueue(),a}},{key:"squashAndAdd",value:function(t,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,t)):a=t;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 t=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){t.isRequestInFlight=!1,t.wakeupQueue()})}}}]),e}(),IR=function(){function e(r){Et.default(this,e),xt.default(this,"queueByNamespaceKey",new Map),this.inputReducer=r}return At.default(e,[{key:"add",value:function(){var r=Me.default(ee.default.mark(function n(i,a,s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(c){return c.add(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function t(n,i,a){return r.apply(this,arguments)}return t}()},{key:"squashAndAdd",value:function(){var r=Me.default(ee.default.mark(function n(i,a,s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(c){return c.squashAndAdd(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function t(n,i,a){return r.apply(this,arguments)}return t}()},{key:"invokeQueueMethod",value:function(){var r=Me.default(ee.default.mark(function n(i,a){var s,o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.queueByNamespaceKey.has(i)||this.queueByNamespaceKey.set(i,new $R(this.inputReducer)),s=this.queueByNamespaceKey.get(i),o=a(s),this.queueByNamespaceKey.get(i).isEmpty()&&this.queueByNamespaceKey.delete(i),c.abrupt("return",o);case 5:case"end":return c.stop()}},n,this)}));function t(n,i){return r.apply(this,arguments)}return t}()}]),e}();function L9(e){var r=D9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function D9(){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 Au=function(e){zr.default(t,e);var r=L9(t);function t(){var n;return Et.default(this,t),n=r.call(this),n.closed=!1,n.uuid=bR.v4(),n}return At.default(t,[{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")}}]),t}(Lt);function OR(e){var r=j9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function j9(){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 Rh=function(e){zr.default(t,e);var r=OR(t);function t(n,i,a){var s;Et.default(this,t),s=r.call(this,n,a),xt.default(si.default(s),"isDeleted",!1);var o=function(c,l){return typeof l.ttl=="number"?{ttl:l.ttl}:c};return s.updateMergingQueue=new $R(o),s.descriptor=i,s.descriptor.data=s.descriptor.data||{},s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return At.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:"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){Ot.trace("Document update skipped, current:",this.lastEventId,", remote:",i.id);break}var a=this.descriptor.data!==void 0?Wn(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=Me.default(ee.default.mark(function a(s,o){var u=this,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return c=o||{},h.abrupt("return",this.updateMergingQueue.squashAndAdd(c,function(v){return u._setUnconditionally(s,v.ttl)}));case 2:case"end":return h.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u=this,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return c=o||{},h.abrupt("return",this.updateMergingQueue.add(c,function(v){return u._setWithIfMatch(s,v.ttl)}));case 2:case"end":return h.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(function(l){return Object.assign(l,s)},o));case 1:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this._postUpdateToServer({ttl:s});case 2:o=c.sent,this.descriptor.date_expires=o.date_expires;case 4:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_setUnconditionally",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this._postUpdateToServer({data:s,revision:void 0,ttl:o});case 2:return u=l.sent,this._handleSuccessfulUpdateResult(u),l.abrupt("return",this.descriptor.data);case 5:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_setWithIfMatch",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(u=s(Wn(this.descriptor.data)),!u){v.next=22;break}return c=this.revision,v.prev=3,v.next=6,this._postUpdateToServer({data:u,revision:c,ttl:o});case 6:return l=v.sent,this._handleSuccessfulUpdateResult(l),v.abrupt("return",this.descriptor.data);case 11:if(v.prev=11,v.t0=v.catch(3),v.t0.status!==412){v.next=19;break}return v.next=16,this._softSync();case 16:return v.abrupt("return",this._setWithIfMatch(s));case 19:throw v.t0;case 20:v.next=23;break;case 22:return v.abrupt("return",this.descriptor.data);case 23:case"end":return v.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?Wn(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=Me.default(ee.default.mark(function a(s){var o,u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isDeleted){h.next=17;break}return o={data:s.data},s.ttl!==void 0&&(o.ttl=s.ttl),u=s.revision,h.prev=4,h.next=7,this.services.network.post(this.uri,o,u);case 7:return c=h.sent,h.abrupt("return",{revision:c.body.revision,data:s.data,last_event_id:c.body.last_event_id,date_updated:c.body.date_updated,date_expires:c.body.date_expires});case 11:throw h.prev=11,h.t0=h.catch(4),h.t0.status===404&&this.onRemoved(!1),h.t0;case 15:h.next=18;break;case 17:return h.abrupt("return",Promise.reject(new Qr("The Document has been removed",404,54100)));case 18:case"end":return h.stop()}},a,this,[[4,11]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_softSync",value:function(){var n=Me.default(ee.default.mark(function a(){var s=this;return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.network.get(this.uri).then(function(c){var l={type:"document_updated",id:c.body.last_event_id,document_revision:c.body.revision,document_data:c.body.data,date_created:c.body.date_updated};return s._update(l),s}).catch(function(c){c.status===404?s.onRemoved(!1):Ot.error("Can't get updates for ".concat(s.sid,":"),c)}));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?Wn(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=Me.default(ee.default.mark(function a(){return ee.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 Qr("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"}}]),t}(Pu),kn=function(e){zr.default(t,e);var r=OR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncDocumentImpl=n,i.syncDocumentImpl.attach(si.default(i)),i}return At.default(t,[{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 Rh.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncDocumentImpl.set(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncDocumentImpl.mutate(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncDocumentImpl.update(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Rh.type}}]),t}(Au);xt.default(kn,"removed","removed");xt.default(kn,"updated","updated");kt([Ee.validateTypesAsync(Ee.pureObject,["undefined",Ee.objectSchema("document metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object,Object]),Re("design:returntype",Promise)],kn.prototype,"set",null);kt([Ee.validateTypesAsync("function",["undefined",Ee.objectSchema("document metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Function,Object]),Re("design:returntype",Promise)],kn.prototype,"mutate",null);kt([Ee.validateTypesAsync(Ee.pureObject,["undefined",Ee.objectSchema("document metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object,Object]),Re("design:returntype",Promise)],kn.prototype,"update",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],kn.prototype,"setTtl",null);var $h=function(){function e(r){Et.default(this,e),this.descriptor=r}return At.default(e,[{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(t,n,i,a){return this.descriptor.lastEventId=t,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.dateUpdated=a,this}},{key:"updateDateExpires",value:function(t){this.descriptor.dateExpires=t}}]),e}(),Qm=function(){function e(r,t,n,i){Et.default(this,e),this.prevToken=n,this.nextToken=i,this.items=r,this.source=t}return At.default(e,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:function(){var r=Me.default(ee.default.mark(function n(){return ee.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 t(){return r.apply(this,arguments)}return t}()},{key:"prevPage",value:function(){var r=Me.default(ee.default.mark(function n(){return ee.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 t(){return r.apply(this,arguments)}return t}()}]),e}();function F9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=U9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
300
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function U9(e,r){if(e){if(typeof e=="string")return Aw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Aw(e,r)}}function Aw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var B9=function(){function e(r,t){Et.default(this,e),this.balanceFactor=0,this.key=r,this.value=t,this.parent=null,this.left=null,this.right=null}return At.default(e,[{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(t){this.value=t}},{key:"replace",value:function(t,n){t&&(this.left===n?this.left=n:this.right===n&&(this.right=n))}}]),e}(),q9=function(){function e(r,t){Et.default(this,e),this.isLessThan=r||function(n,i){return n<i},this.isEqual=t||function(n,i){return n===i},this.root=null,this.count=null}return At.default(e,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(t,n){var i=this.getNode(t);i?i.update(n):this.insert(t,n)}},{key:"insert",value:function(t,n){var i=new B9(t,n);if(this.count++,!this.root){this.root=i;return}for(var a=this.root;;)if(this.isLessThan(t,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(t){for(var n=this.root;n;){if(this.isEqual(t,n.key))return n.value;this.isLessThan(t,n.key)?n=n.left:n=n.right}return null}},{key:"delete",value:function(t){var n=this.getNode(t);if(!n||n.key!==t)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 c=u.parent,l=u.left;c.right=l,l&&(l.parent=c),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:c,isLeftChild:!1}}}for(this.count--;n.parent;){var h=n.parent,v=h.balanceFactor;if(n.isLeftChild?h.balanceFactor-=1:h.balanceFactor+=1,Math.abs(h.balanceFactor)>Math.abs(v))if(h.balanceFactor<-1||h.balanceFactor>1)if(this.rebalance(h),h.parent.balanceFactor===0)n=h.parent;else break;else break;else n=h}return null}},{key:"getNode",value:function(t){for(var n=this.root;n;){if(this.isEqual(t,n.key))return n;this.isLessThan(t,n.key)?n=n.left:n=n.right}return null}},{key:"rebalance",value:function(t){t.balanceFactor<0?t.right.balanceFactor>0?(this.rotateRight(t.right),this.rotateLeft(t)):this.rotateLeft(t):t.balanceFactor>0&&(t.left.balanceFactor<0?(this.rotateLeft(t.left),this.rotateRight(t)):this.rotateRight(t))}},{key:"rotateLeft",value:function(t){var n=t.right;t.right=n.left,n.left!==null&&(n.left.parent=t),n.parent=t.parent,n.parent===null?this.root=n:t.isLeftChild?n.parent.left=n:n.parent.right=n,n.left=t,t.parent=n,t.balanceFactor=t.balanceFactor+1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor+1-Math.max(t.balanceFactor,0)}},{key:"rotateRight",value:function(t){var n=t.left;t.left=n.right,n.right!==null&&(n.right.parent=t),n.parent=t.parent,n.parent===null?this.root=n:t.isLeftChild?n.parent.left=n:n.parent.right=n,n.right=t,t.parent=n,t.balanceFactor=t.balanceFactor-1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor-1-Math.max(t.balanceFactor,0)}},{key:Symbol.iterator,value:ee.default.mark(function r(){var t,n,i;return ee.default.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:t=F9(this.getIterator()),s.prev=1,t.s();case 3:if((n=t.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),t.e(s.t0);case 14:return s.prev=14,t.f(),s.finish(14);case 17:case"end":return s.stop()}},r,this,[[1,11,14,17]])})},{key:"getIterator",value:ee.default.mark(function r(){var t,n,i,a=arguments;return ee.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:t=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(t,n.key)||t===null&&!n.left)){o.next=5;break}return o.abrupt("break",8);case 5:this.isLessThan(t,n.key)||t===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()}},r,this)})},{key:"getReverseIterator",value:ee.default.mark(function r(){var t,n,i,a=arguments;return ee.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:t=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(t,n.key)||t===null&&!n.right)){o.next=5;break}return o.abrupt("break",8);case 5:!this.isLessThan(t,n.key)||t===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()}},r,this)})}]),e}();function z9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=W9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
301
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function W9(e,r){if(e){if(typeof e=="string")return Mw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Mw(e,r)}}function Mw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var V9=function(){function e(r,t){Et.default(this,e),this.value=r,this.revision=t||0}return At.default(e,[{key:"isValid",get:function(){return!0}}]),e}(),G9=function(){function e(r){Et.default(this,e),this.revision=r}return At.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),Zm=function(){function e(){Et.default(this,e),this.items=new q9}return At.default(e,[{key:"store",value:function(t,n,i){var a=this.items.get(t);return a&&a.revision>i?a.isValid?a.value:null:(this.items.set(t,new V9(n,i)),n)}},{key:"delete",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=this.items.get(t);(!a||a.revision<n||a&&i===!0)&&this.items.set(t,new G9(n))}},{key:"isKnown",value:function(t,n){var i=this.items.get(t);return i&&i.revision>=n}},{key:"get",value:function(t){var n=this.items.get(t);return n&&n.isValid?n.value:null}},{key:"has",value:function(t){var n=this.items.get(t);return n&&n.isValid}},{key:"forEach",value:function(t){if(this.items){var n=z9(this.items),i;try{for(n.s();!(i=n.n()).done;){var a=wR.default(i.value,2),s=a[0],o=a[1];o.isValid&&t(s,o.value)}}catch(u){n.e(u)}finally{n.f()}}}}]),e}();function PR(e){var r=H9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function H9(){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 Ih=function(e){zr.default(t,e);var r=PR(t);function t(n,i,a){var s;Et.default(this,t),s=r.call(this,n,a);var o=function(c,l){return typeof l.ttl=="number"?{ttl:l.ttl}:c};return s.updateMergingQueue=new IR(o),s.cache=new Zm,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return At.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:"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=Me.default(ee.default.mark(function a(s,o,u,c){var l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return l={data:o},c!==void 0&&(l.ttl=c),m.next=4,this.services.network.post(s,l,u);case 4:return h=m.sent,h.body.data=o,h.body.date_updated=new Date(h.body.date_updated),m.abrupt("return",h.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=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return u=(o||{}).ttl,v.next=3,this._addOrUpdateItemOnServer(this.links.items,s,void 0,u);case 3:return c=v.sent,l=Number(c.index),this._handleItemMutated(l,c.url,c.last_event_id,c.revision,s,c.date_updated,c.date_expires,!0,!1),v.abrupt("return",this.cache.get(l));case 7:case"end":return v.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.squashAndAdd(s,l,function(m){return c._updateItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemUnconditionally",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.get(s);case 2:return c=v.sent,v.next=5,this._addOrUpdateItemOnServer(c.uri,o,void 0,u);case 5:return l=v.sent,this._handleItemMutated(s,l.url,l.last_event_id,l.revision,l.data,l.date_updated,l.date_expires,!1,!1),v.abrupt("return",this.cache.get(s));case 8:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemWithIfMatch",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l,h,v;return ee.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this.get(s);case 2:if(c=_.sent,l=o(Wn(c.data)),!l){_.next=25;break}return h=c.revision,_.prev=6,_.next=9,this._addOrUpdateItemOnServer(c.uri,l,h,u);case 9:return v=_.sent,this._handleItemMutated(s,v.url,v.last_event_id,v.revision,v.data,v.date_updated,v.date_expires,!1,!1),_.abrupt("return",this.cache.get(s));case 14:if(_.prev=14,_.t0=_.catch(6),_.t0.status!==412){_.next=22;break}return _.next=19,this._getItemFromServer(s);case 19:return _.abrupt("return",this._updateItemWithIfMatch(s,o,u));case 22:throw _.t0;case 23:_.next=26;break;case 25:return _.abrupt("return",c);case 26:case"end":return _.stop()}},a,this,[[6,14]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.add(s,l,function(m){return c._updateItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(s,function(h){return Object.assign(h,o)},u));case 1:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){var o,u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.get(s);case 2:return o=h.sent,u=Wn(o.data),h.next=6,this.services.network.delete(o.uri);case 6:c=h.sent,this._handleItemRemoved(s,c.body.last_event_id,u,new Date(c.body.date_updated),!1);case 8:case"end":return h.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(o=this.cache.get(s),!o){c.next=5;break}return c.abrupt("return",o);case 5:return c.abrupt("return",this._getItemFromServer(s));case 6:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.queryItems({index:s});case 2:if(o=c.sent,!(o.items.length<1)){c.next=7;break}throw new Qr("No item with index ".concat(s," found"),404,54151);case 7:return c.abrupt("return",o.items[0]);case 8:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new Xs(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 c=m.sent,l=c.body.items.map(function(_){_.date_updated=new Date(_.date_updated);var C=o.cache.get(_.index);return C?o._handleItemMutated(_.index,_.url,_.last_event_id,_.revision,_.data,_.date_updated,_.date_expires,!1,!0):o.cache.store(Number(_.index),new $h({index:Number(_.index),uri:_.url,revision:_.revision,lastEventId:_.last_event_id,dateUpdated:_.date_updated,dateExpires:_.date_expires,data:_.data}),_.last_event_id),o.cache.get(_.index)}),h=c.body.meta,m.abrupt("return",new Qm(l,function(_){return o.queryItems({pageToken:_})},h.previous_token,h.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},RR(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=Me.default(ee.default.mark(function a(){var s;return ee.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=Me.default(ee.default.mark(function a(s){var o,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,o={ttl:s},l.next=4,this.services.network.post(this.uri,o);case 4:u=l.sent,this.descriptor.date_expires=u.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.get(s);case 2:return u=v.sent,c={ttl:o},v.next=6,this.services.network.post(u.uri,c);case 6:l=v.sent,u.updateDateExpires(l.body.date_expires);case 8:case"end":return v.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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,c,l,h,v){if(this.shouldIgnoreEvent(i,s)){Ot.trace("Item ".concat(i," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(s));return}this._updateRootDateUpdated(c);var m=this.cache.get(i);if(!m){var _=new $h({index:i,uri:a,lastEventId:s,revision:o,data:u,dateUpdated:c,dateExpires:l});this.cache.store(i,_,s),this.emitItemMutationEvent(_,v,h);return}var C=Wn(m.data);m.update(s,o,u,c),this.cache.store(i,m,s),l!==void 0&&m.updateDateExpires(l),this.emitItemMutationEvent(m,v,!1,C)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",c={item:i,isLocal:!a};s||(c.previousItemData=o),this.broadcastEventToListeners(u,c)}},{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):(Ot.trace("Context update skipped, current:",this.lastEventId,", remote:",a),!1)}}],[{key:"type",get:function(){return"list"}}]),t}(Pu),mr=function(e){zr.default(t,e);var r=PR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncListImpl=n,i.syncListImpl.attach(si.default(i)),i}return At.default(t,[{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 Ih.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.push(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.set(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.mutate(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.update(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.setItemTtl(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Ih.type}}]),t}(Au);xt.default(mr,"itemAdded","itemAdded");xt.default(mr,"itemUpdated","itemUpdated");xt.default(mr,"itemRemoved","itemRemoved");xt.default(mr,"removed","removed");kt([Ee.validateTypesAsync(Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object,Object]),Re("design:returntype",Promise)],mr.prototype,"push",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Number,Object,Object]),Re("design:returntype",Promise)],mr.prototype,"set",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,"function",["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Number,Function,Object]),Re("design:returntype",Promise)],mr.prototype,"mutate",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Number,Object,Object]),Re("design:returntype",Promise)],mr.prototype,"update",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],mr.prototype,"remove",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],mr.prototype,"get",null);kt([Ee.validateTypesAsync(["undefined",Ee.objectSchema("query options",{from:[Ee.nonNegativeInteger,"undefined"],pageSize:[Ee.custom(function(e){return[Xm(e),"a positive integer"]}),"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],mr.prototype,"getItems",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],mr.prototype,"setTtl",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number,Number]),Re("design:returntype",Promise)],mr.prototype,"setItemTtl",null);var Lo=function(){function e(r){Et.default(this,e),this.descriptor=r}return At.default(e,[{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(t,n,i,a){return this.descriptor.last_event_id=t,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.date_updated=a,this}},{key:"updateDateExpires",value:function(t){this.descriptor.date_expires=t}}]),e}();function AR(e){var r=K9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function K9(){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 Oh=function(e){zr.default(t,e);var r=AR(t);function t(n,i,a){var s;Et.default(this,t),s=r.call(this,n,a);var o=function(c,l){return typeof l.ttl=="number"?{ttl:l.ttl}:c};return s.updateMergingQueue=new IR(o),s.cache=new Zm,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 Lo(u),u.last_event_id)}),s}return At.default(t,[{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=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.squashAndAdd(s,l,function(m){return c._putItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(s!=null){u.next=2;break}throw new Qr("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=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.queryItems({key:s});case 2:if(o=c.sent,!(o.items.length<1)){c.next=7;break}throw new Qr("The specified Map Item does not exist",404,54201);case 7:return c.abrupt("return",o.items[0]);case 8:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.add(s,l,function(m){return c._putItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(s,function(h){return Object.assign(h,o)},u));case 1:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemUnconditionally",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this._putItemToServer(s,o,void 0,u);case 2:return c=v.sent,l=c.item,this._handleItemMutated(l.key,l.url,l.last_event_id,l.revision,l.data,l.date_updated,l.date_expires,c.added,!1),v.abrupt("return",this.cache.get(l.key));case 6:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemWithIfMatch",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l,h,v,m;return ee.default.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,this.get(s).catch(function(I){if(I.status===404)return new Lo({key:s,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw I});case 2:if(c=C.sent,l=o(Wn(c.data)),!l){C.next=26;break}return h=c.revision,C.prev=6,C.next=9,this._putItemToServer(s,l,h,u);case 9:return v=C.sent,m=v.item,this._handleItemMutated(m.key,m.url,m.last_event_id,m.revision,m.data,m.date_updated,m.date_expires,v.added,!1),C.abrupt("return",this.cache.get(m.key));case 15:if(C.prev=15,C.t0=C.catch(6),C.t0.status!==412){C.next=23;break}return C.next=20,this._getItemFromServer(s);case 20:return C.abrupt("return",this._putItemWithIfMatch(s,o,u));case 23:throw C.t0;case 24:C.next=27;break;case 26:return C.abrupt("return",c);case 27:case"end":return C.stop()}},a,this,[[6,15]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemToServer",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u,c){var l,h,v,m,_;return ee.default.wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return l=new Xs(this.links.items).pathSegment(s).build(),h={data:o},c!==void 0&&(h.ttl=c),I.prev=3,I.next=6,this.services.network.put(l,h,u);case 6:return v=I.sent,m=v.body,m.data=o,m.date_updated=new Date(m.date_updated),_=v.status.code===201,I.abrupt("return",{added:_,item:m});case 14:throw I.prev=14,I.t0=I.catch(3),I.t0.status===404&&this.onRemoved(!1),I.t0;case 18:case"end":return I.stop()}},a,this,[[3,14]])}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){var o,u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.get(s);case 2:return o=h.sent,u=Wn(o.data),h.next=6,this.services.network.delete(o.uri);case 6:c=h.sent,this._handleItemRemoved(s,c.body.last_event_id,u,new Date(c.body.date_updated),!1);case 8:case"end":return h.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new Xs(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 c=m.sent,l=c.body.items.map(function(_){_.date_updated=new Date(_.date_updated);var C=o.cache.get(_.key);return C?o._handleItemMutated(_.key,_.url,_.last_event_id,_.revision,_.data,_.date_updated,_.date_expires,!1,!0):o.cache.store(_.key,new Lo(_),_.last_event_id),o.cache.get(_.key)}),h=c.body.meta,m.abrupt("return",new Qm(l,function(_){return o.queryItems({pageToken:_})},h.previous_token,h.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},RR(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,c,l,h,v){if(this.shouldIgnoreEvent(i,s)){Ot.trace("SyncMapItem ",i," update skipped, current:",this.lastEventId,", remote:",s);return}this._updateRootDateUpdated(c);var m=this.cache.get(i);if(!m){var _=new Lo({key:i,url:a,last_event_id:s,revision:o,data:u,date_updated:c,date_expires:l});this.cache.store(i,_,s),this.emitItemMutationEvent(_,v,h);return}var C=Wn(m.data);m.update(s,o,u,c),this.cache.store(i,m,s),l!==void 0&&m.updateDateExpires(l),this.emitItemMutationEvent(m,v,!1,C)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",c={item:i,isLocal:!a};s||(c.previousItemData=o),this.broadcastEventToListeners(u,c)}},{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=Me.default(ee.default.mark(function a(s){var o,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,o={ttl:s},l.next=4,this.services.network.post(this.uri,o);case 4:u=l.sent,this.descriptor.date_expires=u.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.get(s);case 2:return u=v.sent,c={ttl:o},v.next=6,this.services.network.post(u.uri,c);case 6:l=v.sent,u.updateDateExpires(l.body.date_expires);case 8:case"end":return v.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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"}}]),t}(Pu),_r=function(e){zr.default(t,e);var r=AR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncMapImpl=n,i.syncMapImpl.attach(si.default(i)),i}return At.default(t,[{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 Oh.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=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.set(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.mutate(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.update(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.setItemTtl(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Oh.type}}]),t}(Au);xt.default(_r,"itemAdded","itemAdded");xt.default(_r,"itemUpdated","itemUpdated");xt.default(_r,"itemRemoved","itemRemoved");xt.default(_r,"removed","removed");kt([Ee.validateTypesAsync("string",Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[String,Object,Object]),Re("design:returntype",Promise)],_r.prototype,"set",null);kt([Ee.validateTypesAsync("string"),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],_r.prototype,"get",null);kt([Ee.validateTypesAsync("string","function",["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[String,Function,Object]),Re("design:returntype",Promise)],_r.prototype,"mutate",null);kt([Ee.validateTypesAsync("string",Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[String,Object,Object]),Re("design:returntype",Promise)],_r.prototype,"update",null);kt([Ee.validateTypesAsync("string"),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],_r.prototype,"remove",null);kt([Ee.validateTypesAsync(["undefined",Ee.objectSchema("query options",{from:["string","undefined"],pageSize:[Ee.custom(function(e){return[Xm(e),"a positive integer"]}),"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],_r.prototype,"getItems",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],_r.prototype,"setTtl",null);kt([Ee.validateTypesAsync("string",Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[String,Number]),Re("design:returntype",Promise)],_r.prototype,"setItemTtl",null);function MR(e){var r=J9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function J9(){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 ru=function(e){zr.default(t,e);var r=MR(t);function t(n,i,a){var s;return Et.default(this,t),s=r.call(this,n,a),s.descriptor=i,s}return At.default(t,[{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=Me.default(ee.default.mark(function a(s){var o,u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return o={data:s},v.next=3,this.services.network.post(this.links.messages,o);case 3:return u=v.sent,c=u.body,l=this._handleMessagePublished(c.sid,s,!1),v.abrupt("return",l);case 7:case"end":return v.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Me.default(ee.default.mark(function a(s){var o,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,o={ttl:s},l.next=4,this.services.network.post(this.uri,o);case 4:u=l.sent,this.descriptor.date_expires=u.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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"}}]),t}(Pu);kt([Ee.validateTypesAsync(Ee.pureObject),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],ru.prototype,"publishMessage",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],ru.prototype,"setTtl",null);var ai=function(e){zr.default(t,e);var r=MR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncStreamImpl=n,i.syncStreamImpl.attach(si.default(i)),i}return At.default(t,[{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 ru.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return ru.type}}]),t}(Au);xt.default(ai,"messagePublished","messagePublished");xt.default(ai,"removed","removed");kt([Ee.validateTypesAsync(Ee.pureObject),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],ai.prototype,"publishMessage",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],ai.prototype,"setTtl",null);var Y9=function e(r){Et.default(this,e),this.sdk="js",this.sdkVer=r,this.os=gc.os.family,this.osVer=gc.os.version,this.pl=gc.name,this.plVer=gc.version},X9=function(){function e(){Et.default(this,e),this.names=new Map,this.entities=new Map}return At.default(e,[{key:"store",value:function(t){var n=this.entities.get(t.sid);return n||(this.entities.set(t.sid,t),t.uniqueName&&this.names.set(t.type+"::"+t.uniqueName,t.sid),t)}},{key:"getResolved",value:function(t,n){var i=this.names.get(n+"::"+t);return i?this.entities.get(i):null}},{key:"get",value:function(t,n){return this.entities.get(t)||this.getResolved(t,n)||null}},{key:"remove",value:function(t){var n=this.entities.get(t);n&&(this.entities.delete(t),n.uniqueName&&this.names.delete(n.type+"::"+n.uniqueName))}}]),e}();function eg(e){var r=Q9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function Q9(){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 Z9=function e(){Et.default(this,e)},Ph=function(e){zr.default(t,e);var r=eg(t);function t(n,i,a,s){var o;return Et.default(this,t),o=r.call(this,i,a),o.descriptor=n,o.cache=new Zm,s&&s.forEach(function(u){o.cache.store(u.key,{key:u.key,value:u.data},u.revision)}),o}return At.default(t,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return t.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))Ot.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)?Ot.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,c){var l=s[u];l!=null?a.handleItemMutated(u,l.data,l.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"}}]),t}(Pu);function xR(e){return Ah.apply(this,arguments)}function Ah(){return Ah=Me.default(ee.default.mark(function e(r){var t,n,i,a,s,o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(t=r.network,n=r.queryString,i=r.uri,a=r.type,n!=null){c.next=3;break}throw new Qr("Invalid query",400,54507);case 3:return s={query_string:n},a===xi.type&&(s.type=a),c.next=7,t.post(i,s,void 0,!0);case 7:return o=c.sent,c.abrupt("return",o.body);case 9:case"end":return c.stop()}},e)})),Ah.apply(this,arguments)}var xi=function(e){zr.default(t,e);var r=eg(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.liveQueryImpl=n,i.liveQueryImpl.attach(si.default(i)),i}return At.default(t,[{key:"type",get:function(){return Ph.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){Iu.default(cr.default(t.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 Ph.type}}]),t}(Au);xt.default(xi,"itemUpdated","itemUpdated");xt.default(xi,"itemRemoved","itemRemoved");var Mu=function(e){zr.default(t,e);var r=eg(t);function t(n){var i;return Et.default(this,t),i=r.call(this),xt.default(si.default(i),"queryExpression",null),xt.default(si.default(i),"items",{}),Object.assign(si.default(i),n),i.updateIndexName(n.indexName),i}return At.default(t,[{key:"type",get:function(){return t.type}},{key:"search",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.items={},c.abrupt("return",xR({network:this.network,uri:this.queryUri,queryString:s}).then(function(l){o.queryExpression=s,l.items&&l.items.forEach(function(h){o.items[h.key]=h.data}),o.emit("searchResult",o.getItems())}).catch(function(l){throw Ot.error("Error '".concat(l.message,"' while executing query '").concat(s,"'")),o.queryExpression=null,l}));case 2:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"subscribe",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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 Qr("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 Xs(this.insightsUri).pathSegment(i).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),t}(Lt);xt.default(Mu,"searchResult","searchResult");kt([Ee.validateTypesAsync("string"),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],Mu.prototype,"search",null);kt([Ee.validateTypes(Ee.nonEmptyString),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",void 0)],Mu.prototype,"updateIndexName",null);var e7="3.1.0";function t7(e){var r=r7();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function r7(){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 xw(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),t.push.apply(t,n)}return t}function Nw(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?xw(Object(t),!0).forEach(function(n){xt.default(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):xw(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var n7="data_sync",np=e7;function yc(e){if(e){if(typeof e=="string")return{id:e,mode:"open_or_create"};var r=e.mode||(e.id?"open_or_create":"create_new");return Nw(Nw({},e),{},{mode:r})}else return{mode:"create_new"}}var Lw="com.twilio.rtd.cds.document",Dw="com.twilio.rtd.cds.list",jw="com.twilio.rtd.cds.map",Fw="twilio.sync.event",vn=function(e){zr.default(t,e);var r=t7(t);function t(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Et.default(this,t),i=r.call(this),!n)throw new Error("Sync library needs a valid Twilio token to be passed");a.hasOwnProperty("logLevel")?Ot.setLevel(a.logLevel):Ot.setLevel("silent");var s=a.productId=a.productId||n7;a.clientMetadata=a.clientMetadata||{},a.clientMetadata.hasOwnProperty("type")||(a.clientMetadata.type="sync"),a.clientMetadata.hasOwnProperty("sdk")||(a.clientMetadata.sdk="JS",a.clientMetadata.sdkv=np);var o=!a.twilsockClient;if(!a.initRegistrations){var u=new El.InitRegistration(s);t.populateInitRegistrations(u),a.initRegistrations=[u]}var c=a.twilsockClient=a.twilsockClient||new El.Twilsock(n,s,a);c.on("tokenAboutToExpire",function(m){return i.emit("tokenAboutToExpire",m)}),c.on("tokenExpired",function(){return i.emit("tokenExpired")}),c.on("connectionError",function(m){return i.emit("connectionError",m)}),c.on("stateChanged",function(m){i.emit("connectionStateChanged",m),i.services.subscriptions.onConnectionStateChanged(m==="connected")}),c.on("message",function(m,_){return i._routeMessage(m,_)});var l=new T9(a),h=new A9(new Y9(np),l,c),v=new M9(l);return i.services={config:l,twilsock:c,network:h,storage:v,router:si.default(i),subscriptions:null},i.services.subscriptions=new R9(i.services),i.entities=new X9,o&&c.connect(),i}return At.default(t,[{key:"_routeMessage",value:function(i,a){switch(Ot.trace("Notification type:",i,"content:",a),i){case Lw:case Dw:case jw:this.services.subscriptions.acceptMessage(a,!1);break;case Fw: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=Me.default(ee.default.mark(function a(){var s;return ee.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),Ot.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=Wn(s);(i===mr.type||i===_r.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=Me.default(ee.default.mark(function a(s,o){var u,c,l,h=arguments;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(u=h.length>2&&h[2]!==void 0?h[2]:!1,o){m.next=3;break}throw new Qr("Cannot get entity without id",404);case 3:return c=new Xs(s).pathSegment(o).queryParam("Include",u?"items":void 0).build(),m.next=6,this.services.network.get(c);case 6:return l=m.sent,m.abrupt("return",l.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(kn.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(c){return c.body})}},{key:"_getList",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(mr.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=Me.default(ee.default.mark(function a(s){var o,u=arguments;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return o=u.length>1&&u[1]!==void 0?u[1]:!1,l.abrupt("return",this.readRootFromSessionCache(_r.type,s)||this._get(this.services.config.mapsUri,s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getStream",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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.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=Me.default(ee.default.mark(function a(s,o){var u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return u={unique_name:s},o!==void 0&&(u.ttl=o),h.next=4,this.services.network.post(this.services.config.streamsUri,u);case 4:return c=h.sent,h.abrupt("return",c.body);case 6:case"end":return h.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_getLiveQuery",value:function(i){return this.readRootFromSessionCache(xi.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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=yc(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createDocument(u.id,u.data,u.ttl);case 6:c=m.sent,m.next=39;break;case 9:if(l=this.getCached(u.id,kn.type),!l){m.next=14;break}return m.abrupt("return",new kn(l));case 14:return m.prev=14,m.next=17,this._getDocument(u.id);case 17:c=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:c=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(kn.type,u.id,c),h=new Rh(this.services,c,function(_,C,I){return o.removeFromCacheAndSession(_,C,I)}),h=this.entities.store(h),m.abrupt("return",new kn(h));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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=yc(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createMap(u.id,u.ttl);case 6:c=m.sent,m.next=39;break;case 9:if(l=this.getCached(u.id,_r.type),!l){m.next=14;break}return m.abrupt("return",new _r(l));case 14:return m.prev=14,m.next=17,this._getMap(u.id,u.includeItems);case 17:c=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:c=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(_r.type,u.id,c),h=new Oh(this.services,c,function(_,C,I){return o.removeFromCacheAndSession(_,C,I)}),h=this.entities.store(h),m.abrupt("return",new _r(h));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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=yc(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:c=m.sent,m.next=39;break;case 9:if(l=this.getCached(u.id,mr.type),!l){m.next=14;break}return m.abrupt("return",new mr(l));case 14:return m.prev=14,m.next=17,this._getList(u.id);case 17:c=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:c=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(mr.type,u.id,c),h=new Ih(this.services,c,function(_,C,I){return o.removeFromCacheAndSession(_,C,I)}),h=this.entities.store(h),m.abrupt("return",new mr(h));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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h,v;return ee.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this.ensureReady();case 2:if(u=yc(s),u.mode!=="create_new"){_.next=9;break}return _.next=6,this._createStream(u.id,u.ttl);case 6:c=_.sent,_.next=39;break;case 9:if(l=this.getCached(u.id,ai.type),!l){_.next=14;break}return _.abrupt("return",new ai(l));case 14:return _.prev=14,_.next=17,this._getStream(u.id);case 17:c=_.sent,_.next=39;break;case 20:if(_.prev=20,_.t0=_.catch(14),!(_.t0.status!==404||u.mode==="open_existing")){_.next=26;break}throw _.t0;case 26:return _.prev=26,_.next=29,this._createStream(u.id,u.ttl);case 29:c=_.sent,_.next=39;break;case 32:if(_.prev=32,_.t1=_.catch(26),_.t1.status!==409){_.next=38;break}return _.abrupt("return",this.stream(s));case 38:throw _.t1;case 39:return this.storeRootInSessionCache(ai.type,u.id,c),h=function(I,$,x){return o.removeFromCacheAndSession(I,$,x)},v=new ru(this.services,c,h),v=this.entities.store(v),_.abrupt("return",new ai(v));case 44:case"end":return _.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shutdown",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.twilsock.updateToken(s).catch(function(c){var l,h=c==null||(l=c.reply)===null||l===void 0?void 0:l.status;throw(h==null?void 0:h.code)===401&&(h==null?void 0:h.status)==="UNAUTHORIZED"?new Qr("Updated token was rejected by server",400,51130):c}));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=Me.default(ee.default.mark(function a(s,o){var u=this,c,l,h,v,m;return ee.default.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,this.ensureReady();case 2:return c=new Xs(this.services.config.insightsUri).pathSegment(s).pathSegment("Items").build(),C.next=5,xR({network:this.services.network,uri:c,queryString:o,type:xi.type});case 5:return l=C.sent,h=this.getCached(l.query_id,xi.type),h||(v=this._getLiveQuery(l.query_id),v||(v={indexName:s,queryExpression:o,sid:l.query_id,queryUri:c,last_event_id:l.last_event_id}),m=function($,x,N){return u.removeFromCacheAndSession($,x,N)},h=new Ph(v,this.services,m,l.items)),this.storeRootInSessionCache(xi.type,l.query_id,h.liveQueryDescriptor),h=this.entities.store(h),C.abrupt("return",new xi(h));case 11:case"end":return C.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"instantQuery",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.ensureReady();case 2:return u=function(v,m){return o.liveQuery(v,m)},l.abrupt("return",new Mu({indexName:s,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:u}));case 4:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()}],[{key:"populateInitRegistrations",value:function(i){i.populateInitRegistrations([Fw,Lw,Dw,jw])}},{key:"version",get:function(){return np}}]),t}(Lt);xt.default(vn,"connectionStateChanged","connectionStateChanged");xt.default(vn,"connectionError","connectionError");xt.default(vn,"tokenAboutToExpire","tokenAboutToExpire");xt.default(vn,"tokenExpired","tokenExpired");kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open document options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"document",null);kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open map options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)],includeItems:["boolean","undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"map",null);kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open list options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)],purpose:["string","undefined"],context:[Ee.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"list",null);kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open stream options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"stream",null);kt([Ee.validateTypesAsync(Ee.nonEmptyString),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],vn.prototype,"updateToken",null);kt([Ee.validateTypesAsync(Ee.nonEmptyString,"string"),Re("design:type",Function),Re("design:paramtypes",[String,String]),Re("design:returntype",Promise)],vn.prototype,"liveQuery",null);kt([Ee.validateTypesAsync(Ee.nonEmptyString),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],vn.prototype,"instantQuery",null);en.Client=vn;en.InsightsItem=Z9;en.InstantQuery=Mu;en.LiveQuery=xi;en.Paginator=Qm;en.SyncClient=vn;en.SyncDocument=kn;en.SyncList=mr;en.SyncListItem=$h;en.SyncMap=_r;en.SyncMapItem=Lo;en.SyncStream=ai;var NR={},i7=Jt,a7=li,s7=Bt,o7=s7("match"),u7=function(e){var r;return i7(e)&&((r=e[o7])!==void 0?!!r:a7(e)==="RegExp")},c7=u7,l7=TypeError,LR=function(e){if(c7(e))throw new l7("The method doesn't accept regular expressions");return e},f7=Bt,d7=f7("match"),DR=function(e){var r=/./;try{"/./"[e](r)}catch{try{return r[d7]=!1,"/./"[e](r)}catch{}}return!1},p7=gt,h7=jv,v7=Bi.f,m7=Wi,Uw=wr,g7=LR,y7=Kn,b7=DR,_7=h7("".slice),w7=Math.min,jR=b7("startsWith"),S7=!jR&&!!function(){var e=v7(String.prototype,"startsWith");return e&&!e.writable}();p7({target:"String",proto:!0,forced:!S7&&!jR},{startsWith:function(r){var t=Uw(y7(this));g7(r);var n=m7(w7(arguments.length>1?arguments[1]:void 0,t.length)),i=Uw(r);return _7(t,n,n+i.length)===i}});var C7=lt,T7=Bt,E7=Wt,Bw=U0,k7=T7("iterator"),FR=!C7(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),r=e.searchParams,t=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",r.forEach(function(i,a){r.delete("b"),n+=a+i}),t.delete("a",2),t.delete("b",void 0),Bw&&(!e.toJSON||!t.has("a",1)||t.has("a",2)||!t.has("a",void 0)||t.has("b"))||!r.size&&(Bw||!E7)||!r.sort||e.href!=="https://a/c%20d?a=1&c=3"||r.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!r[k7]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||n!=="a1c3"||new URL("https://x",void 0).host!=="x"}),ds=vt,ip=2147483647,zo=36,UR=1,Mh=26,R7=38,$7=700,I7=72,O7=128,P7="-",A7=/[^\0-\u007E]/,BR=/[.\u3002\uFF0E\uFF61]/g,qw="Overflow: input needs wider integers to process",ap=zo-UR,zw=RangeError,M7=ds(BR.exec),As=Math.floor,sp=String.fromCharCode,Ww=ds("".charCodeAt),qR=ds([].join),fa=ds([].push),x7=ds("".replace),N7=ds("".split),L7=ds("".toLowerCase),D7=function(e){for(var r=[],t=0,n=e.length;t<n;){var i=Ww(e,t++);if(i>=55296&&i<=56319&&t<n){var a=Ww(e,t++);(a&64512)===56320?fa(r,((i&1023)<<10)+(a&1023)+65536):(fa(r,i),t--)}else fa(r,i)}return r},Vw=function(e){return e+22+75*(e<26)},j7=function(e,r,t){var n=0;for(e=t?As(e/$7):e>>1,e+=As(e/r);e>ap*Mh>>1;)e=As(e/ap),n+=zo;return As(n+(ap+1)*e/(e+R7))},F7=function(e){var r=[];e=D7(e);var t=e.length,n=O7,i=0,a=I7,s,o;for(s=0;s<e.length;s++)o=e[s],o<128&&fa(r,sp(o));var u=r.length,c=u;for(u&&fa(r,P7);c<t;){var l=ip;for(s=0;s<e.length;s++)o=e[s],o>=n&&o<l&&(l=o);var h=c+1;if(l-n>As((ip-i)/h))throw new zw(qw);for(i+=(l-n)*h,n=l,s=0;s<e.length;s++){if(o=e[s],o<n&&++i>ip)throw new zw(qw);if(o===n){for(var v=i,m=zo;;){var _=m<=a?UR:m>=a+Mh?Mh:m-a;if(v<_)break;var C=v-_,I=zo-_;fa(r,sp(Vw(_+C%I))),v=As(C/I),m+=zo}fa(r,sp(Vw(v))),a=j7(i,h,c===u),i=0,c++}}i++,n++}return qR(r,"")},U7=function(e){var r=[],t=N7(x7(L7(e),BR,"."),"."),n,i;for(n=0;n<t.length;n++)i=t[n],fa(r,M7(A7,i)?"xn--"+F7(i):i);return qR(r,".")},B7=gt,q7=vt,z7=as,W7=RangeError,Gw=String.fromCharCode,Hw=String.fromCodePoint,V7=q7([].join),G7=!!Hw&&Hw.length!==1;B7({target:"String",stat:!0,arity:1,forced:G7},{fromCodePoint:function(r){for(var t=[],n=arguments.length,i=0,a;n>i;){if(a=+arguments[i++],z7(a,1114111)!==a)throw new W7(a+" is not a valid code point");t[i]=a<65536?Gw(a):Gw(((a-=65536)>>10)+55296,a%1024+56320)}return V7(t,"")}});var xh=gt,zR=_t,tg=aT,H7=$n,bc=Ft,Gn=vt,Wo=Wt,WR=FR,VR=Ur,K7=hi,J7=uf,Y7=di,X7=PT,rg=pn,GR=ka,op=Ut,Q7=tr,Z7=Gi,eK=Vi,tK=ar,HR=Jt,Dr=wr,rK=Ta,Kw=ts,Jw=Hl,nK=wu,_c=Jl,Cs=Gv,iK=Bt,aK=zm,sK=iK("iterator"),fo="URLSearchParams",KR=fo+"Iterator",JR=rg.set,Tn=rg.getterFor(fo),oK=rg.getterFor(KR),Yw=tg("fetch"),kl=tg("Request"),Vo=tg("Headers"),up=kl&&kl.prototype,Xw=Vo&&Vo.prototype,uK=zR.TypeError,cK=zR.encodeURIComponent,lK=String.fromCharCode,fK=H7("String","fromCodePoint"),dK=parseInt,el=Gn("".charAt),Qw=Gn([].join),da=Gn([].push),YR=Gn("".replace),pK=Gn([].shift),Zw=Gn([].splice),eS=Gn("".split),XR=Gn("".slice),hK=Gn(/./.exec),vK=/\+/g,cp="�",mK=/^[0-9a-f]+$/i,tS=function(e,r){var t=XR(e,r,r+2);return hK(mK,t)?dK(t,16):NaN},gK=function(e){for(var r=0,t=128;t>0&&e&t;t>>=1)r++;return r},yK=function(e){var r=null;switch(e.length){case 1:r=e[0];break;case 2:r=(e[0]&31)<<6|e[1]&63;break;case 3:r=(e[0]&15)<<12|(e[1]&63)<<6|e[2]&63;break;case 4:r=(e[0]&7)<<18|(e[1]&63)<<12|(e[2]&63)<<6|e[3]&63;break}return r>1114111?null:r},rS=function(e){e=YR(e,vK," ");for(var r=e.length,t="",n=0;n<r;){var i=el(e,n);if(i==="%"){if(el(e,n+1)==="%"||n+3>r){t+="%",n++;continue}var a=tS(e,n+1);if(a!==a){t+=i,n++;continue}n+=2;var s=gK(a);if(s===0)i=lK(a);else{if(s===1||s>4){t+=cp,n++;continue}for(var o=[a],u=1;u<s&&(n++,!(n+3>r||el(e,n)!=="%"));){var c=tS(e,n+1);if(c!==c){n+=3;break}if(c>191||c<128)break;da(o,c),n+=2,u++}if(o.length!==s){t+=cp;continue}var l=yK(o);l===null?t+=cp:i=fK(l)}}t+=i,n++}return t},bK=/[!'()~]|%20/g,_K={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},wK=function(e){return _K[e]},nS=function(e){return YR(cK(e),bK,wK)},lp=X7(function(r,t){JR(this,{type:KR,target:Tn(r).entries,index:0,kind:t})},fo,function(){var r=oK(this),t=r.target,n=r.index++;if(!t||n>=t.length)return r.target=null,_c(void 0,!0);var i=t[n];switch(r.kind){case"keys":return _c(i.key,!1);case"values":return _c(i.value,!1)}return _c([i.key,i.value],!1)},!0),QR=function(e){this.entries=[],this.url=null,e!==void 0&&(HR(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?el(e,0)==="?"?XR(e,1):e:Dr(e)))};QR.prototype={type:fo,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var r=this.entries,t=nK(e),n,i,a,s,o,u,c;if(t)for(n=Jw(e,t),i=n.next;!(a=bc(i,n)).done;){if(s=Jw(tK(a.value)),o=s.next,(u=bc(o,s)).done||(c=bc(o,s)).done||!bc(o,s).done)throw new uK("Expected sequence with length 2");da(r,{key:Dr(u.value),value:Dr(c.value)})}else for(var l in e)Q7(e,l)&&da(r,{key:l,value:Dr(e[l])})},parseQuery:function(e){if(e)for(var r=this.entries,t=eS(e,"&"),n=0,i,a;n<t.length;)i=t[n++],i.length&&(a=eS(i,"="),da(r,{key:rS(pK(a)),value:rS(Qw(a,"="))}))},serialize:function(){for(var e=this.entries,r=[],t=0,n;t<e.length;)n=e[t++],da(r,nS(n.key)+"="+nS(n.value));return Qw(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var yf=function(){GR(this,Qs);var r=arguments.length>0?arguments[0]:void 0,t=JR(this,new QR(r));Wo||(this.size=t.entries.length)},Qs=yf.prototype;J7(Qs,{append:function(r,t){var n=Tn(this);Cs(arguments.length,2),da(n.entries,{key:Dr(r),value:Dr(t)}),Wo||this.length++,n.updateURL()},delete:function(e){for(var r=Tn(this),t=Cs(arguments.length,1),n=r.entries,i=Dr(e),a=t<2?void 0:arguments[1],s=a===void 0?a:Dr(a),o=0;o<n.length;){var u=n[o];if(u.key===i&&(s===void 0||u.value===s)){if(Zw(n,o,1),s!==void 0)break}else o++}Wo||(this.size=n.length),r.updateURL()},get:function(r){var t=Tn(this).entries;Cs(arguments.length,1);for(var n=Dr(r),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(r){var t=Tn(this).entries;Cs(arguments.length,1);for(var n=Dr(r),i=[],a=0;a<t.length;a++)t[a].key===n&&da(i,t[a].value);return i},has:function(r){for(var t=Tn(this).entries,n=Cs(arguments.length,1),i=Dr(r),a=n<2?void 0:arguments[1],s=a===void 0?a:Dr(a),o=0;o<t.length;){var u=t[o++];if(u.key===i&&(s===void 0||u.value===s))return!0}return!1},set:function(r,t){var n=Tn(this);Cs(arguments.length,1);for(var i=n.entries,a=!1,s=Dr(r),o=Dr(t),u=0,c;u<i.length;u++)c=i[u],c.key===s&&(a?Zw(i,u--,1):(a=!0,c.value=o));a||da(i,{key:s,value:o}),Wo||(this.size=i.length),n.updateURL()},sort:function(){var r=Tn(this);aK(r.entries,function(t,n){return t.key>n.key?1:-1}),r.updateURL()},forEach:function(r){for(var t=Tn(this).entries,n=Z7(r,arguments.length>1?arguments[1]:void 0),i=0,a;i<t.length;)a=t[i++],n(a.value,a.key,this)},keys:function(){return new lp(this,"keys")},values:function(){return new lp(this,"values")},entries:function(){return new lp(this,"entries")}},{enumerable:!0});VR(Qs,sK,Qs.entries,{name:"entries"});VR(Qs,"toString",function(){return Tn(this).serialize()},{enumerable:!0});Wo&&K7(Qs,"size",{get:function(){return Tn(this).entries.length},configurable:!0,enumerable:!0});Y7(yf,fo);xh({global:!0,constructor:!0,forced:!WR},{URLSearchParams:yf});if(!WR&&op(Vo)){var SK=Gn(Xw.has),CK=Gn(Xw.set),iS=function(e){if(HR(e)){var r=e.body,t;if(eK(r)===fo)return t=e.headers?new Vo(e.headers):new Vo,SK(t,"content-type")||CK(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),rK(e,{body:Kw(0,Dr(r)),headers:Kw(0,t)})}return e};if(op(Yw)&&xh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(r){return Yw(r,arguments.length>1?iS(arguments[1]):{})}}),op(kl)){var fp=function(r){return GR(this,up),new kl(r,arguments.length>1?iS(arguments[1]):{})};up.constructor=fp,fp.prototype=up,xh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fp})}}var TK={URLSearchParams:yf,getState:Tn},EK=gt,ng=Wt,kK=FR,ig=_t,aS=Gi,An=vt,Rl=Ur,_n=hi,RK=ka,Nh=tr,ag=oR,Ts=$T,Ln=pi,$K=tm.codeAt,IK=U7,Ri=wr,OK=di,PK=Gv,ZR=TK,e1=pn,AK=e1.set,$l=e1.getterFor("URL"),MK=ZR.URLSearchParams,xK=ZR.getState,Oo=ig.URL,Lh=ig.TypeError,Il=ig.parseInt,NK=Math.floor,sS=Math.pow,En=An("".charAt),qn=An(/./.exec),Do=An([].join),LK=An(1 .toString),DK=An([].pop),$s=An([].push),dp=An("".replace),jK=An([].shift),FK=An("".split),Go=An("".slice),Ol=An("".toLowerCase),UK=An([].unshift),BK="Invalid authority",pp="Invalid scheme",za="Invalid host",oS="Invalid port",t1=/[a-z]/i,qK=/[\d+-.a-z]/i,Dh=/\d/,zK=/^0x/i,WK=/^[0-7]+$/,VK=/^\d+$/,r1=/^[\da-f]+$/i,GK=/[\0\t\n\r #%/:<>?@[\\\]^|]/,HK=/[\0\t\n\r #/:<>?@[\\\]^|]/,KK=/^[\u0000-\u0020]+/,JK=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,YK=/[\t\n\r]/g,wn,XK=function(e){var r=FK(e,"."),t,n,i,a,s,o,u;if(r.length&&r[r.length-1]===""&&r.length--,t=r.length,t>4)return e;for(n=[],i=0;i<t;i++){if(a=r[i],a==="")return e;if(s=10,a.length>1&&En(a,0)==="0"&&(s=qn(zK,a)?16:8,a=Go(a,s===8?1:2)),a==="")o=0;else{if(!qn(s===10?VK:s===8?WK:r1,a))return e;o=Il(a,s)}$s(n,o)}for(i=0;i<t;i++)if(o=n[i],i===t-1){if(o>=sS(256,5-t))return null}else if(o>255)return null;for(u=DK(n),i=0;i<n.length;i++)u+=n[i]*sS(256,3-i);return u},QK=function(e){var r=[0,0,0,0,0,0,0,0],t=0,n=null,i=0,a,s,o,u,c,l,h,v=function(){return En(e,i)};if(v()===":"){if(En(e,1)!==":")return;i+=2,t++,n=t}for(;v();){if(t===8)return;if(v()===":"){if(n!==null)return;i++,t++,n=t;continue}for(a=s=0;s<4&&qn(r1,v());)a=a*16+Il(v(),16),i++,s++;if(v()==="."){if(s===0||(i-=s,t>6))return;for(o=0;v();){if(u=null,o>0)if(v()==="."&&o<4)i++;else return;if(!qn(Dh,v()))return;for(;qn(Dh,v());){if(c=Il(v(),10),u===null)u=c;else{if(u===0)return;u=u*10+c}if(u>255)return;i++}r[t]=r[t]*256+u,o++,(o===2||o===4)&&t++}if(o!==4)return;break}else if(v()===":"){if(i++,!v())return}else if(v())return;r[t++]=a}if(n!==null)for(l=t-n,t=7;t!==0&&l>0;)h=r[t],r[t--]=r[n+l-1],r[n+--l]=h;else if(t!==8)return;return r},ZK=function(e){for(var r=null,t=1,n=null,i=0,a=0;a<8;a++)e[a]!==0?(i>t&&(r=n,t=i),n=null,i=0):(n===null&&(n=a),++i);return i>t?n:r},Po=function(e){var r,t,n,i;if(typeof e=="number"){for(r=[],t=0;t<4;t++)UK(r,e%256),e=NK(e/256);return Do(r,".")}if(typeof e=="object"){for(r="",n=ZK(e),t=0;t<8;t++)i&&e[t]===0||(i&&(i=!1),n===t?(r+=t?":":"::",i=!0):(r+=LK(e[t],16),t<7&&(r+=":")));return"["+r+"]"}return e},tl={},n1=ag({},tl,{" ":1,'"':1,"<":1,">":1,"`":1}),i1=ag({},n1,{"#":1,"?":1,"{":1,"}":1}),hp=ag({},i1,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ua=function(e,r){var t=$K(e,0);return t>32&&t<127&&!Nh(r,e)?e:encodeURIComponent(e)},wc={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jo=function(e,r){var t;return e.length===2&&qn(t1,En(e,0))&&((t=En(e,1))===":"||!r&&t==="|")},uS=function(e){var r;return e.length>1&&jo(Go(e,0,2))&&(e.length===2||(r=En(e,2))==="/"||r==="\\"||r==="?"||r==="#")},eJ=function(e){return e==="."||Ol(e)==="%2e"},tJ=function(e){return e=Ol(e),e===".."||e==="%2e."||e===".%2e"||e==="%2e%2e"},vp={},cS={},mp={},lS={},fS={},gp={},dS={},pS={},Sc={},Cc={},yp={},bp={},_p={},wp={},hS={},Sp={},Es={},ni={},vS={},Wa={},ki={},sg=function(e,r,t){var n=Ri(e),i,a,s;if(r){if(a=this.parse(n),a)throw new Lh(a);this.searchParams=null}else{if(t!==void 0&&(i=new sg(t,!0)),a=this.parse(n,null,i),a)throw new Lh(a);s=xK(new MK),s.bindURL(this),this.searchParams=s}};sg.prototype={type:"URL",parse:function(e,r,t){var n=this,i=r||vp,a=0,s="",o=!1,u=!1,c=!1,l,h,v,m;for(e=Ri(e),r||(n.scheme="",n.username="",n.password="",n.host=null,n.port=null,n.path=[],n.query=null,n.fragment=null,n.cannotBeABaseURL=!1,e=dp(e,KK,""),e=dp(e,JK,"$1")),e=dp(e,YK,""),l=Ts(e);a<=l.length;){switch(h=l[a],i){case vp:if(h&&qn(t1,h))s+=Ol(h),i=cS;else{if(r)return pp;i=mp;continue}break;case cS:if(h&&(qn(qK,h)||h==="+"||h==="-"||h==="."))s+=Ol(h);else if(h===":"){if(r&&(n.isSpecial()!==Nh(wc,s)||s==="file"&&(n.includesCredentials()||n.port!==null)||n.scheme==="file"&&!n.host))return;if(n.scheme=s,r){n.isSpecial()&&wc[n.scheme]===n.port&&(n.port=null);return}s="",n.scheme==="file"?i=wp:n.isSpecial()&&t&&t.scheme===n.scheme?i=lS:n.isSpecial()?i=pS:l[a+1]==="/"?(i=fS,a++):(n.cannotBeABaseURL=!0,$s(n.path,""),i=vS)}else{if(r)return pp;s="",i=mp,a=0;continue}break;case mp:if(!t||t.cannotBeABaseURL&&h!=="#")return pp;if(t.cannotBeABaseURL&&h==="#"){n.scheme=t.scheme,n.path=Ln(t.path),n.query=t.query,n.fragment="",n.cannotBeABaseURL=!0,i=ki;break}i=t.scheme==="file"?wp:gp;continue;case lS:if(h==="/"&&l[a+1]==="/")i=Sc,a++;else{i=gp;continue}break;case fS:if(h==="/"){i=Cc;break}else{i=ni;continue}case gp:if(n.scheme=t.scheme,h===wn)n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.query=t.query;else if(h==="/"||h==="\\"&&n.isSpecial())i=dS;else if(h==="?")n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.query="",i=Wa;else if(h==="#")n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.query=t.query,n.fragment="",i=ki;else{n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.path.length--,i=ni;continue}break;case dS:if(n.isSpecial()&&(h==="/"||h==="\\"))i=Sc;else if(h==="/")i=Cc;else{n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,i=ni;continue}break;case pS:if(i=Sc,h!=="/"||En(s,a+1)!=="/")continue;a++;break;case Sc:if(h!=="/"&&h!=="\\"){i=Cc;continue}break;case Cc:if(h==="@"){o&&(s="%40"+s),o=!0,v=Ts(s);for(var _=0;_<v.length;_++){var C=v[_];if(C===":"&&!c){c=!0;continue}var I=ua(C,hp);c?n.password+=I:n.username+=I}s=""}else if(h===wn||h==="/"||h==="?"||h==="#"||h==="\\"&&n.isSpecial()){if(o&&s==="")return BK;a-=Ts(s).length+1,s="",i=yp}else s+=h;break;case yp:case bp:if(r&&n.scheme==="file"){i=Sp;continue}else if(h===":"&&!u){if(s==="")return za;if(m=n.parseHost(s),m)return m;if(s="",i=_p,r===bp)return}else if(h===wn||h==="/"||h==="?"||h==="#"||h==="\\"&&n.isSpecial()){if(n.isSpecial()&&s==="")return za;if(r&&s===""&&(n.includesCredentials()||n.port!==null))return;if(m=n.parseHost(s),m)return m;if(s="",i=Es,r)return;continue}else h==="["?u=!0:h==="]"&&(u=!1),s+=h;break;case _p:if(qn(Dh,h))s+=h;else if(h===wn||h==="/"||h==="?"||h==="#"||h==="\\"&&n.isSpecial()||r){if(s!==""){var $=Il(s,10);if($>65535)return oS;n.port=n.isSpecial()&&$===wc[n.scheme]?null:$,s=""}if(r)return;i=Es;continue}else return oS;break;case wp:if(n.scheme="file",h==="/"||h==="\\")i=hS;else if(t&&t.scheme==="file")switch(h){case wn:n.host=t.host,n.path=Ln(t.path),n.query=t.query;break;case"?":n.host=t.host,n.path=Ln(t.path),n.query="",i=Wa;break;case"#":n.host=t.host,n.path=Ln(t.path),n.query=t.query,n.fragment="",i=ki;break;default:uS(Do(Ln(l,a),""))||(n.host=t.host,n.path=Ln(t.path),n.shortenPath()),i=ni;continue}else{i=ni;continue}break;case hS:if(h==="/"||h==="\\"){i=Sp;break}t&&t.scheme==="file"&&!uS(Do(Ln(l,a),""))&&(jo(t.path[0],!0)?$s(n.path,t.path[0]):n.host=t.host),i=ni;continue;case Sp:if(h===wn||h==="/"||h==="\\"||h==="?"||h==="#"){if(!r&&jo(s))i=ni;else if(s===""){if(n.host="",r)return;i=Es}else{if(m=n.parseHost(s),m)return m;if(n.host==="localhost"&&(n.host=""),r)return;s="",i=Es}continue}else s+=h;break;case Es:if(n.isSpecial()){if(i=ni,h!=="/"&&h!=="\\")continue}else if(!r&&h==="?")n.query="",i=Wa;else if(!r&&h==="#")n.fragment="",i=ki;else if(h!==wn&&(i=ni,h!=="/"))continue;break;case ni:if(h===wn||h==="/"||h==="\\"&&n.isSpecial()||!r&&(h==="?"||h==="#")){if(tJ(s)?(n.shortenPath(),h!=="/"&&!(h==="\\"&&n.isSpecial())&&$s(n.path,"")):eJ(s)?h!=="/"&&!(h==="\\"&&n.isSpecial())&&$s(n.path,""):(n.scheme==="file"&&!n.path.length&&jo(s)&&(n.host&&(n.host=""),s=En(s,0)+":"),$s(n.path,s)),s="",n.scheme==="file"&&(h===wn||h==="?"||h==="#"))for(;n.path.length>1&&n.path[0]==="";)jK(n.path);h==="?"?(n.query="",i=Wa):h==="#"&&(n.fragment="",i=ki)}else s+=ua(h,i1);break;case vS:h==="?"?(n.query="",i=Wa):h==="#"?(n.fragment="",i=ki):h!==wn&&(n.path[0]+=ua(h,tl));break;case Wa:!r&&h==="#"?(n.fragment="",i=ki):h!==wn&&(h==="'"&&n.isSpecial()?n.query+="%27":h==="#"?n.query+="%23":n.query+=ua(h,tl));break;case ki:h!==wn&&(n.fragment+=ua(h,n1));break}a++}},parseHost:function(e){var r,t,n;if(En(e,0)==="["){if(En(e,e.length-1)!=="]"||(r=QK(Go(e,1,-1)),!r))return za;this.host=r}else if(this.isSpecial()){if(e=IK(e),qn(GK,e)||(r=XK(e),r===null))return za;this.host=r}else{if(qn(HK,e))return za;for(r="",t=Ts(e),n=0;n<t.length;n++)r+=ua(t[n],tl);this.host=r}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme==="file"},includesCredentials:function(){return this.username!==""||this.password!==""},isSpecial:function(){return Nh(wc,this.scheme)},shortenPath:function(){var e=this.path,r=e.length;r&&(this.scheme!=="file"||r!==1||!jo(e[0],!0))&&e.length--},serialize:function(){var e=this,r=e.scheme,t=e.username,n=e.password,i=e.host,a=e.port,s=e.path,o=e.query,u=e.fragment,c=r+":";return i!==null?(c+="//",e.includesCredentials()&&(c+=t+(n?":"+n:"")+"@"),c+=Po(i),a!==null&&(c+=":"+a)):r==="file"&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+Do(s,"/"):"",o!==null&&(c+="?"+o),u!==null&&(c+="#"+u),c},setHref:function(e){var r=this.parse(e);if(r)throw new Lh(r);this.searchParams.update()},getOrigin:function(){var e=this.scheme,r=this.port;if(e==="blob")try{return new Zs(e.path[0]).origin}catch{return"null"}return e==="file"||!this.isSpecial()?"null":e+"://"+Po(this.host)+(r!==null?":"+r:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Ri(e)+":",vp)},getUsername:function(){return this.username},setUsername:function(e){var r=Ts(Ri(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var t=0;t<r.length;t++)this.username+=ua(r[t],hp)}},getPassword:function(){return this.password},setPassword:function(e){var r=Ts(Ri(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var t=0;t<r.length;t++)this.password+=ua(r[t],hp)}},getHost:function(){var e=this.host,r=this.port;return e===null?"":r===null?Po(e):Po(e)+":"+r},setHost:function(e){this.cannotBeABaseURL||this.parse(e,yp)},getHostname:function(){var e=this.host;return e===null?"":Po(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,bp)},getPort:function(){var e=this.port;return e===null?"":Ri(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(e=Ri(e),e===""?this.port=null:this.parse(e,_p))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+Do(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Es))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){e=Ri(e),e===""?this.query=null:(En(e,0)==="?"&&(e=Go(e,1)),this.query="",this.parse(e,Wa)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){if(e=Ri(e),e===""){this.fragment=null;return}En(e,0)==="#"&&(e=Go(e,1)),this.fragment="",this.parse(e,ki)},update:function(){this.query=this.searchParams.serialize()||null}};var Zs=function(r){var t=RK(this,Lr),n=PK(arguments.length,1)>1?arguments[1]:void 0,i=AK(t,new sg(r,!1,n));ng||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},Lr=Zs.prototype,Sn=function(e,r){return{get:function(){return $l(this)[e]()},set:r&&function(t){return $l(this)[r](t)},configurable:!0,enumerable:!0}};ng&&(_n(Lr,"href",Sn("serialize","setHref")),_n(Lr,"origin",Sn("getOrigin")),_n(Lr,"protocol",Sn("getProtocol","setProtocol")),_n(Lr,"username",Sn("getUsername","setUsername")),_n(Lr,"password",Sn("getPassword","setPassword")),_n(Lr,"host",Sn("getHost","setHost")),_n(Lr,"hostname",Sn("getHostname","setHostname")),_n(Lr,"port",Sn("getPort","setPort")),_n(Lr,"pathname",Sn("getPathname","setPathname")),_n(Lr,"search",Sn("getSearch","setSearch")),_n(Lr,"searchParams",Sn("getSearchParams")),_n(Lr,"hash",Sn("getHash","setHash")));Rl(Lr,"toJSON",function(){return $l(this).serialize()},{enumerable:!0});Rl(Lr,"toString",function(){return $l(this).serialize()},{enumerable:!0});if(Oo){var mS=Oo.createObjectURL,gS=Oo.revokeObjectURL;mS&&Rl(Zs,"createObjectURL",aS(mS,Oo)),gS&&Rl(Zs,"revokeObjectURL",aS(gS,Oo))}OK(Zs,"URL");EK({global:!0,constructor:!0,forced:!kK,sham:!ng},{URL:Zs});/*
297
+ */Object.defineProperty(en,"__esModule",{value:!0});var zH=yu,WH=gi,VH=Ea,GH=os,HH=vi,KH=mi,JH=Pn,YH=us,XH=Cu,QH=On,Ee=qr,El=cf,ZH=mf,e9=gr,t9=uo,bR=Ji,_R=qH,r9=gm,n9=sR;function hn(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function Ym(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}var Me=hn(zH),Et=hn(WH),At=hn(VH),si=hn(GH),zr=hn(HH),Oa=hn(KH),cr=hn(JH),xt=hn(YH),ee=hn(XH),wR=hn(QH),i9=hn(ZH),a9=Ym(e9),SR=hn(t9),s9=Ym(_R),Iu=hn(r9),gc=Ym(n9);function kt(e,r,t,n){var i=arguments.length,a=i<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,t):n,s;if((typeof Reflect>"u"?"undefined":wR.default(Reflect))==="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,r,t,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(i<3?s(a):i>3?s(r,t,a):s(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a}function Re(e,r){if((typeof Reflect>"u"?"undefined":wR.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,r)}var o9;function ya(){}ya.prototype=Object.create(null);function Lt(){Lt.init.call(this)}Lt.EventEmitter=Lt;Lt.usingDomains=!1;Lt.prototype.domain=void 0;Lt.prototype._events=void 0;Lt.prototype._maxListeners=void 0;Lt.defaultMaxListeners=10;Lt.init=function(){this.domain=null,Lt.usingDomains&&o9.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ya,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Lt.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||isNaN(r))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=r,this};function CR(e){return e._maxListeners===void 0?Lt.defaultMaxListeners:e._maxListeners}Lt.prototype.getMaxListeners=function(){return CR(this)};function u9(e,r,t){if(r)e.call(t);else for(var n=e.length,i=Ou(e,n),a=0;a<n;++a)i[a].call(t)}function c9(e,r,t,n){if(r)e.call(t,n);else for(var i=e.length,a=Ou(e,i),s=0;s<i;++s)a[s].call(t,n)}function l9(e,r,t,n,i){if(r)e.call(t,n,i);else for(var a=e.length,s=Ou(e,a),o=0;o<a;++o)s[o].call(t,n,i)}function f9(e,r,t,n,i,a){if(r)e.call(t,n,i,a);else for(var s=e.length,o=Ou(e,s),u=0;u<s;++u)o[u].call(t,n,i,a)}function d9(e,r,t,n){if(r)e.apply(t,n);else for(var i=e.length,a=Ou(e,i),s=0;s<i;++s)a[s].apply(t,n)}Lt.prototype.emit=function(r){var t,n,i,a,s,o,u,c=r==="error";if(o=this._events,o)c=c&&o.error==null;else if(!c)return!1;if(u=this.domain,c){if(t=arguments[1],u)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=u,t.domainThrown=!1,u.emit("error",t);else{if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return!1}if(n=o[r],!n)return!1;var h=typeof n=="function";switch(i=arguments.length,i){case 1:u9(n,h,this);break;case 2:c9(n,h,this,arguments[1]);break;case 3:l9(n,h,this,arguments[1],arguments[2]);break;case 4:f9(n,h,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];d9(n,h,this,a)}return!0};function TR(e,r,t,n){var i,a,s;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",r,t.listener?t.listener:t),a=e._events),s=a[r]):(a=e._events=new ya,e._eventsCount=0),!s)s=a[r]=t,++e._eventsCount;else if(typeof s=="function"?s=a[r]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),!s.warned&&(i=CR(e),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=r,o.count=s.length,p9(o)}return e}function p9(e){typeof console.warn=="function"?console.warn(e):console.log(e)}Lt.prototype.addListener=function(r,t){return TR(this,r,t,!1)};Lt.prototype.on=Lt.prototype.addListener;Lt.prototype.prependListener=function(r,t){return TR(this,r,t,!0)};function ER(e,r,t){var n=!1;function i(){e.removeListener(r,i),n||(n=!0,t.apply(e,arguments))}return i.listener=t,i}Lt.prototype.once=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(r,ER(this,r,t)),this};Lt.prototype.prependOnceListener=function(r,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(r,ER(this,r,t)),this};Lt.prototype.removeListener=function(r,t){var n,i,a,s,o;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[r],!n)return this;if(n===t||n.listener&&n.listener===t)--this._eventsCount===0?this._events=new ya:(delete i[r],i.removeListener&&this.emit("removeListener",r,n.listener||t));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){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 ya,this;delete i[r]}else h9(n,a);i.removeListener&&this.emit("removeListener",r,o||t)}return this};Lt.prototype.off=function(e,r){return this.removeListener(e,r)};Lt.prototype.removeAllListeners=function(r){var t,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ya,this._eventsCount=0):n[r]&&(--this._eventsCount===0?this._events=new ya:delete n[r]),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 ya,this._eventsCount=0,this}if(t=n[r],typeof t=="function")this.removeListener(r,t);else if(t)do this.removeListener(r,t[t.length-1]);while(t[0]);return this};Lt.prototype.listeners=function(r){var t,n,i=this._events;return i?(t=i[r],t?typeof t=="function"?n=[t.listener||t]:n=v9(t):n=[]):n=[],n};Lt.listenerCount=function(e,r){return typeof e.listenerCount=="function"?e.listenerCount(r):kR.call(e,r)};Lt.prototype.listenerCount=kR;function kR(e){var r=this._events;if(r){var t=r[e];if(typeof t=="function")return 1;if(t)return t.length}return 0}Lt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function h9(e,r){for(var t=r,n=t+1,i=e.length;n<i;t+=1,n+=1)e[t]=e[n];e.pop()}function Ou(e,r){for(var t=new Array(r);r--;)t[r]=e[r];return t}function v9(e){for(var r=new Array(e.length),t=0;t<r.length;++t)r[t]=e[t].listener||e[t];return r}var Xs=function(){function e(r){Et.default(this,e),this.base=r,this.args=new Array,this.paths=new Array}return At.default(e,[{key:"pathSegment",value:function(t){return this.paths.push(encodeURIComponent(t)),this}},{key:"queryParam",value:function(t,n){return typeof n<"u"&&this.args.push(encodeURIComponent(t)+"="+encodeURIComponent(n)),this}},{key:"build",value:function(){var t=this.base;return this.paths.length&&(t+="/"+this.paths.join("/")),this.args.length&&(t+="?"+this.args.join("&")),t}}]),e}();function RR(e){var r=m9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function m9(){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 Qr=function(e){zr.default(t,e);var r=RR(t);function t(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 Et.default(this,t),i=r.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 t}(i9.default(Error)),g9=function(e){zr.default(t,e);var r=RR(t);function t(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 Et.default(this,t),i=r.call(this,n,a,s),i.body=o,i}return t}(Qr);function Wn(e){return JSON.parse(JSON.stringify(e))}function $R(e){var r=e===void 0||Xm(e);if(!r)throw new Qr("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function y9(e){return!isNaN(parseInt(e))&&isFinite(e)}function Xm(e){return y9(e)&&e>0}var Ss=a9.getLogger("twilio-sync");function Ro(e,r){return["".concat(new Date().toISOString()," Sync ").concat(e,":")].concat(Array.from(r))}var Ot={setLevel:function(r){Ss.setLevel(r)},trace:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.trace.apply(null,Ro("T",t))},debug:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.debug.apply(null,Ro("D",t))},info:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.info.apply(null,Ro("I",t))},warn:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.warn.apply(null,Ro("W",t))},error:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];Ss.error.apply(null,Ro("E",t))}},b9="/v4/Subscriptions",_9="/v3/Maps",w9="/v3/Lists",S9="/v3/Documents",C9="/v3/Streams",T9="/v3/Insights";function E9(e,r,t){return e&&typeof e[r]<"u"?e[r]:t}var k9=function(){function e(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Et.default(this,e);var t=r.region||"us1",n="https://cds.".concat(t,".twilio.com"),i=r.cdsUri||n;this.settings={subscriptionsUri:i+b9,documentsUri:i+S9,listsUri:i+w9,mapsUri:i+_9,streamsUri:i+C9,insightsUri:i+T9,sessionStorageEnabled:E9(r.Sync,"enableSessionStorage",!0),productId:r.productId}}return At.default(e,[{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}}]),e}();function $o(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=R9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
298
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function R9(e,r){if(e){if(typeof e=="string")return Iw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Iw(e,r)}}function Iw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var $9=function(){function e(r){Et.default(this,e),this.localObject=r,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return At.default(e,[{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(t,n){this.localObject._update(t,n)}},{key:"updatePending",value:function(t,n){this.pendingAction=t,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(t){this.rejectedWithError=t.error,this.updatePending(null,null),this.localObject.reportFailure(new Qr("Failed to subscribe on service events: ".concat(t.error.message),t.error.status,t.error.code))}},{key:"complete",value:function(t){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(t)}},{key:"setSubscriptionState",value:function(t){this.localObject._setSubscriptionState(t)}}]),e}(),I9=function(){function e(r){var t=this;Et.default(this,e),xt.default(this,"isConnected",!1),xt.default(this,"maxBatchSize",100),xt.default(this,"subscriptionTtlTimer",null),xt.default(this,"pendingPokeReason",null),this.services=r,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=bR.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=t.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?t.applyNewSubscriptionUpdateBatch(a,s):(t.backoff.reset(),Ot.debug("All subscriptions resolved."))})}return At.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function t(a,s,o,u){var c=[],l=$o(a),h;try{for(l.s();!(h=l.n()).done;){var v=SR.default(h.value,2),m=v[0],_=v[1],C=s.get(m);if(!C&&o!==_.pendingAction&&!_.rejectedWithError&&(c.push(_),u&&c.length>=u))break}}catch(I){l.e(I)}finally{l.f()}return c}var n=t(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=t(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 r=Me.default(ee.default.mark(function n(i,a){var s=this,o,u,c,l,h,v,m,_,C,I,$,x,N,q,X,J;return ee.default.wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.isConnected){L.next=4;break}return Ot.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),L.abrupt("return");case 4:a=this.processLocalActions(i,a),o=new Date().getTime(),u=$o(a);try{for(u.s();!(c=u.n()).done;)l=c.value,this.recordActionAttemptOn(l,i,o)}catch(te){u.e(te)}finally{u.f()}return h=this.pendingPokeReason,this.pendingPokeReason=null,L.prev=10,L.next=13,this.request(i,o,h,a);case 13:v=L.sent,m=v.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(_=v.body.ttl_in_s,C=!isNaN(parseFloat(_))&&isFinite(_),I=C&&_>0,I&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},_*1e3))),i==="establish"&&($=v.body.estimated_delivery_in_ms,x=!isNaN(parseFloat($))&&isFinite($),N=x&&$>0,N?setTimeout(function(){return s.verifyPokeDelivery(o,$,a)},$):Ot.error("Invalid timeout: ".concat($)),a.filter(function(te){return te.pendingCorrelationId===o}).forEach(function(te){return te.setSubscriptionState("response_in_flight")})),this.backoff.reset(),L.next=26;break;case 21:L.prev=21,L.t0=L.catch(10),q=$o(a);try{for(q.s();!(X=q.n()).done;)J=X.value,this.recordActionFailureOn(J,i)}catch(te){q.e(te)}finally{q.f()}L.t0 instanceof El.TransportUnavailableError?(Ot.debug("Twilsock connection (required for subscription) not ready (c:".concat(o,"); waiting…")),this.backoff.reset()):(Ot.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(o,"); retrying"),L.t0),this.persist());case 26:case"end":return L.stop()}},n,this,[[10,21]])}));function t(n,i){return r.apply(this,arguments)}return t}()},{key:"verifyPokeDelivery",value:function(t,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(t),o=s?new Date().getTime()-s:n;if(o>=n)i.filter(function(c){return c.pendingCorrelationId===t}).forEach(function(c){c.updatePending(null,null),c.retryCount++,a.persisted.delete(c.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(t);else{var u=n-o;setTimeout(function(){return a.verifyPokeDelivery(t,n,i)},u)}}},{key:"processLocalActions",value:function(t,n){return t==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(t,n,i){if(t.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(t.sid,t),t.updatePending(n,i);else{var a=this.persisted.get(t.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(t,n){t.setSubscriptionState("none"),t.updatePending(null,null),n==="establish"&&this.persisted.delete(t.sid)}},{key:"request",value:function(t,n,i,a){var s=a.map(function(c){return{object_sid:c.sid,object_type:c.type,last_event_id:t==="establish"?c.lastEventId:void 0,index_name:t==="establish"?c.indexName:void 0,query_string:t==="establish"?c.queryString:void 0}}),o=a.filter(function(c){return c.retryCount>0}).length;Ot.debug("Attempting '".concat(t,"' request (c:").concat(n,"):"),s);var u={event_protocol_version:4,action:t,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(t,n){Ot.debug("Establishing intent to subscribe to ".concat(t));var i=this.subscriptions.get(t);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(t),this.subscriptions.set(t,new $9(n)),this.persist())}},{key:"remove",value:function(t){Ot.debug("Establishing intent to unsubscribe from ".concat(t));var n=this.subscriptions.delete(t);n&&this.persist()}},{key:"acceptMessage",value:function(t,n){Ot.trace("Subscriptions received",t);var i=t.event_type,a=typeof t.events<"u"?t.events:[t.event],s=t.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var o=$o(a),u;try{for(o.s();!(u=o.n()).done;){var c=u.value,l=void 0;switch(t.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(c,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(c,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(c,s);break;case(l=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var h=void 0;switch(l[0]){case"map_":h=c.map_sid;break;case"list_":h=c.list_sid;break;case"document_":h=c.document_sid;break;case"stream_":h=c.stream_sid;break;case"live_query_":h=c.query_id,n=!1,t.strictly_ordered===!0&&(n=!0);break;default:h=void 0}this.applyEventToSubscribedEntity(h,c,i,n);break}default:Ot.debug("Dropping unknown message type ".concat(i));break}}}catch(v){o.e(v)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(t,n){var i=t.object_sid,a=this.persisted.get(t.object_sid);a&&a.pendingCorrelationId===n?t.replay_status==="interrupted"?(Ot.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()):t.replay_status==="completed"&&(Ot.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(t.last_event_id),this.persisted.set(t.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):Ot.debug("Late message for ".concat(t.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(t,n){var i=this.persisted.get(t.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(t.object_sid)):Ot.debug("Late message for ".concat(t.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(t,n){var i=t.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(Ot.error("Failed to subscribe on ".concat(s.sid),t.error),s.markAsFailed(t),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(t,n,i,a){var s=this;if(t){a=a||function(){var u=s.persisted.get(t);return u&&u.isEstablished}();var o=this.subscriptions.get(t);o?(n.type=i,o.update(n,a)):Ot.debug("Message dropped for SID '".concat(t,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(t){this.isConnected=t,t&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(t){Ot.debug("Triggering event replay for all subscriptions, reason=".concat(t)),this.pendingPokeReason=t,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=$o(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(l){i.e(l)}finally{i.f()}this.persisted.clear();for(var o=0,u=n;o<u.length;o++){var c=u[o];this.persisted.set(c.sid,c)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}(),O9=4e3,P9=6e4,A9=9e4,M9=.2;function Ow(e){if(e.body&&e.body.message)return e.body.message;switch(e.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function Pw(e){return e.body?e.body.code:0}function Io(e){return e.status===409?new g9(Ow(e),e.status,Pw(e),e.body):e.status?new Qr(Ow(e),e.status,Pw(e)):e instanceof El.TransportUnavailableError?e:new Qr(e.message,0,0)}var x9=function(){function e(r,t,n){Et.default(this,e),this.clientInfo=r,this.config=t,this.transport=n}return At.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+s9.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:O9,max:P9,maxAttemptsTime:A9,randomness:M9},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(t){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 bR.Retrier(n.backoffConfig());u.on("attempt",function(){t().then(function(c){return u.succeeded(c)}).catch(function(c){if(o.includes(c.status)){var l=parseInt(c.headers?c.headers["Retry-After"]:null);u.failed(Io(c),isNaN(l)?null:l*1e3)}else c.message==="Twilsock disconnected"?u.failed(Io(c)):(u.removeAllListeners(),u.cancel(),s(Io(c)))})}),u.on("succeeded",function(c){a(c)}),u.on("cancelled",function(c){return s(Io(c))}),u.on("failed",function(c){return s(Io(c))}),u.start()})}},{key:"get",value:function(t){var n=this,i=this.createHeaders();return Ot.debug("GET",t,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(t,i,n.config.productId)},!0)}},{key:"post",value:function(t,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),Ot.debug("POST",t,"ID:",o["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(t,o,n,a.config.productId)},s)}},{key:"put",value:function(t,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),Ot.debug("PUT",t,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(t,s,n,a.config.productId)},!1)}},{key:"delete",value:function(t){var n=this,i=this.createHeaders();return Ot.debug("DELETE",t,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(t,i,n.config.productId)},!1)}}]),e}(),N9=function(){function e(r,t){Et.default(this,e),this.config=r,this.storageId=null;try{this.storage=t||sessionStorage}catch{}}return At.default(e,[{key:"storageKey",value:function(t,n){return"".concat(this.storageId,"::").concat(t,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(t){this.storageId=t}},{key:"store",value:function(t,n,i){return this.isReady?this._store(this.storageKey(t,n),i):null}},{key:"read",value:function(t,n){return this.isReady?this._read(this.storageKey(t,n)):null}},{key:"remove",value:function(t,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(t,n)),i&&this.storage.removeItem(this.storageKey(t,i))}catch{}}},{key:"update",value:function(t,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(t,n),a),i&&this._apply(this.storageKey(t,i),a)}},{key:"_store",value:function(t,n){try{this.storage.setItem(t,JSON.stringify(n))}catch{}}},{key:"_read",value:function(t){try{var n=this.storage.getItem(t);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(t,n){var i=this._read(t);if(!i)return!1;this._store(t,Object.assign(i,n))}}]),e}();function L9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=D9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
299
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function D9(e,r){if(e){if(typeof e=="string")return Aw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Aw(e,r)}}function Aw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Pu=function(){function e(r,t){Et.default(this,e),this.services=r,this.removalHandler=t,this.subscriptionState="none",this._attachedListeners=new Map}return At.default(e,[{key:"_advanceLastEventId",value:function(t,n){}},{key:"reportFailure",value:function(t){t.status===404?this.onRemoved(!1):this.broadcastEventToListeners("failure",t)}},{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(t){this.subscriptionState=t,this.broadcastEventToListeners("_subscriptionStateChanged",t)}},{key:"close",value:function(){this._unsubscribe(),this.removalHandler!=null&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(t){var n=t.listenerUuid,i=this._attachedListeners.get(n);i||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(n,t))}},{key:"detach",value:function(t){this._attachedListeners.delete(t),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(t,n){var i=L9(this._attachedListeners.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.emit(t,n)}}catch(o){i.e(o)}finally{i.f()}}}]),e}(),IR=function(){function e(r){Et.default(this,e),xt.default(this,"queuedRequests",[]),xt.default(this,"isRequestInFlight",!1),this.inputMergingFunction=r}return At.default(e,[{key:"add",value:function(t,n){var i=this,a=new Promise(function(s,o){return i.queuedRequests.push({input:t,requestFunction:n,resolve:s,reject:o})});return this.wakeupQueue(),a}},{key:"squashAndAdd",value:function(t,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,t)):a=t;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 t=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){t.isRequestInFlight=!1,t.wakeupQueue()})}}}]),e}(),OR=function(){function e(r){Et.default(this,e),xt.default(this,"queueByNamespaceKey",new Map),this.inputReducer=r}return At.default(e,[{key:"add",value:function(){var r=Me.default(ee.default.mark(function n(i,a,s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(c){return c.add(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function t(n,i,a){return r.apply(this,arguments)}return t}()},{key:"squashAndAdd",value:function(){var r=Me.default(ee.default.mark(function n(i,a,s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(c){return c.squashAndAdd(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function t(n,i,a){return r.apply(this,arguments)}return t}()},{key:"invokeQueueMethod",value:function(){var r=Me.default(ee.default.mark(function n(i,a){var s,o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.queueByNamespaceKey.has(i)||this.queueByNamespaceKey.set(i,new IR(this.inputReducer)),s=this.queueByNamespaceKey.get(i),o=a(s),this.queueByNamespaceKey.get(i).isEmpty()&&this.queueByNamespaceKey.delete(i),c.abrupt("return",o);case 5:case"end":return c.stop()}},n,this)}));function t(n,i){return r.apply(this,arguments)}return t}()}]),e}();function j9(e){var r=F9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function F9(){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 Au=function(e){zr.default(t,e);var r=j9(t);function t(){var n;return Et.default(this,t),n=r.call(this),n.closed=!1,n.uuid=_R.v4(),n}return At.default(t,[{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")}}]),t}(Lt);function PR(e){var r=U9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function U9(){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 Rh=function(e){zr.default(t,e);var r=PR(t);function t(n,i,a){var s;Et.default(this,t),s=r.call(this,n,a),xt.default(si.default(s),"isDeleted",!1);var o=function(c,l){return typeof l.ttl=="number"?{ttl:l.ttl}:c};return s.updateMergingQueue=new IR(o),s.descriptor=i,s.descriptor.data=s.descriptor.data||{},s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return At.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:"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){Ot.trace("Document update skipped, current:",this.lastEventId,", remote:",i.id);break}var a=this.descriptor.data!==void 0?Wn(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=Me.default(ee.default.mark(function a(s,o){var u=this,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return c=o||{},h.abrupt("return",this.updateMergingQueue.squashAndAdd(c,function(v){return u._setUnconditionally(s,v.ttl)}));case 2:case"end":return h.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u=this,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return c=o||{},h.abrupt("return",this.updateMergingQueue.add(c,function(v){return u._setWithIfMatch(s,v.ttl)}));case 2:case"end":return h.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(function(l){return Object.assign(l,s)},o));case 1:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this._postUpdateToServer({ttl:s});case 2:o=c.sent,this.descriptor.date_expires=o.date_expires;case 4:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_setUnconditionally",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this._postUpdateToServer({data:s,revision:void 0,ttl:o});case 2:return u=l.sent,this._handleSuccessfulUpdateResult(u),l.abrupt("return",this.descriptor.data);case 5:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_setWithIfMatch",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(u=s(Wn(this.descriptor.data)),!u){v.next=22;break}return c=this.revision,v.prev=3,v.next=6,this._postUpdateToServer({data:u,revision:c,ttl:o});case 6:return l=v.sent,this._handleSuccessfulUpdateResult(l),v.abrupt("return",this.descriptor.data);case 11:if(v.prev=11,v.t0=v.catch(3),v.t0.status!==412){v.next=19;break}return v.next=16,this._softSync();case 16:return v.abrupt("return",this._setWithIfMatch(s));case 19:throw v.t0;case 20:v.next=23;break;case 22:return v.abrupt("return",this.descriptor.data);case 23:case"end":return v.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?Wn(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=Me.default(ee.default.mark(function a(s){var o,u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isDeleted){h.next=17;break}return o={data:s.data},s.ttl!==void 0&&(o.ttl=s.ttl),u=s.revision,h.prev=4,h.next=7,this.services.network.post(this.uri,o,u);case 7:return c=h.sent,h.abrupt("return",{revision:c.body.revision,data:s.data,last_event_id:c.body.last_event_id,date_updated:c.body.date_updated,date_expires:c.body.date_expires});case 11:throw h.prev=11,h.t0=h.catch(4),h.t0.status===404&&this.onRemoved(!1),h.t0;case 15:h.next=18;break;case 17:return h.abrupt("return",Promise.reject(new Qr("The Document has been removed",404,54100)));case 18:case"end":return h.stop()}},a,this,[[4,11]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_softSync",value:function(){var n=Me.default(ee.default.mark(function a(){var s=this;return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.network.get(this.uri).then(function(c){var l={type:"document_updated",id:c.body.last_event_id,document_revision:c.body.revision,document_data:c.body.data,date_created:c.body.date_updated};return s._update(l),s}).catch(function(c){c.status===404?s.onRemoved(!1):Ot.error("Can't get updates for ".concat(s.sid,":"),c)}));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?Wn(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=Me.default(ee.default.mark(function a(){return ee.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 Qr("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"}}]),t}(Pu),kn=function(e){zr.default(t,e);var r=PR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncDocumentImpl=n,i.syncDocumentImpl.attach(si.default(i)),i}return At.default(t,[{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 Rh.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncDocumentImpl.set(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncDocumentImpl.mutate(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncDocumentImpl.update(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Rh.type}}]),t}(Au);xt.default(kn,"removed","removed");xt.default(kn,"updated","updated");kt([Ee.validateTypesAsync(Ee.pureObject,["undefined",Ee.objectSchema("document metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object,Object]),Re("design:returntype",Promise)],kn.prototype,"set",null);kt([Ee.validateTypesAsync("function",["undefined",Ee.objectSchema("document metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Function,Object]),Re("design:returntype",Promise)],kn.prototype,"mutate",null);kt([Ee.validateTypesAsync(Ee.pureObject,["undefined",Ee.objectSchema("document metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object,Object]),Re("design:returntype",Promise)],kn.prototype,"update",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],kn.prototype,"setTtl",null);var $h=function(){function e(r){Et.default(this,e),this.descriptor=r}return At.default(e,[{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(t,n,i,a){return this.descriptor.lastEventId=t,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.dateUpdated=a,this}},{key:"updateDateExpires",value:function(t){this.descriptor.dateExpires=t}}]),e}(),Qm=function(){function e(r,t,n,i){Et.default(this,e),this.prevToken=n,this.nextToken=i,this.items=r,this.source=t}return At.default(e,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:function(){var r=Me.default(ee.default.mark(function n(){return ee.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 t(){return r.apply(this,arguments)}return t}()},{key:"prevPage",value:function(){var r=Me.default(ee.default.mark(function n(){return ee.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 t(){return r.apply(this,arguments)}return t}()}]),e}();function B9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=q9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
300
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function q9(e,r){if(e){if(typeof e=="string")return Mw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Mw(e,r)}}function Mw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var z9=function(){function e(r,t){Et.default(this,e),this.balanceFactor=0,this.key=r,this.value=t,this.parent=null,this.left=null,this.right=null}return At.default(e,[{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(t){this.value=t}},{key:"replace",value:function(t,n){t&&(this.left===n?this.left=n:this.right===n&&(this.right=n))}}]),e}(),W9=function(){function e(r,t){Et.default(this,e),this.isLessThan=r||function(n,i){return n<i},this.isEqual=t||function(n,i){return n===i},this.root=null,this.count=null}return At.default(e,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(t,n){var i=this.getNode(t);i?i.update(n):this.insert(t,n)}},{key:"insert",value:function(t,n){var i=new z9(t,n);if(this.count++,!this.root){this.root=i;return}for(var a=this.root;;)if(this.isLessThan(t,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(t){for(var n=this.root;n;){if(this.isEqual(t,n.key))return n.value;this.isLessThan(t,n.key)?n=n.left:n=n.right}return null}},{key:"delete",value:function(t){var n=this.getNode(t);if(!n||n.key!==t)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 c=u.parent,l=u.left;c.right=l,l&&(l.parent=c),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:c,isLeftChild:!1}}}for(this.count--;n.parent;){var h=n.parent,v=h.balanceFactor;if(n.isLeftChild?h.balanceFactor-=1:h.balanceFactor+=1,Math.abs(h.balanceFactor)>Math.abs(v))if(h.balanceFactor<-1||h.balanceFactor>1)if(this.rebalance(h),h.parent.balanceFactor===0)n=h.parent;else break;else break;else n=h}return null}},{key:"getNode",value:function(t){for(var n=this.root;n;){if(this.isEqual(t,n.key))return n;this.isLessThan(t,n.key)?n=n.left:n=n.right}return null}},{key:"rebalance",value:function(t){t.balanceFactor<0?t.right.balanceFactor>0?(this.rotateRight(t.right),this.rotateLeft(t)):this.rotateLeft(t):t.balanceFactor>0&&(t.left.balanceFactor<0?(this.rotateLeft(t.left),this.rotateRight(t)):this.rotateRight(t))}},{key:"rotateLeft",value:function(t){var n=t.right;t.right=n.left,n.left!==null&&(n.left.parent=t),n.parent=t.parent,n.parent===null?this.root=n:t.isLeftChild?n.parent.left=n:n.parent.right=n,n.left=t,t.parent=n,t.balanceFactor=t.balanceFactor+1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor+1-Math.max(t.balanceFactor,0)}},{key:"rotateRight",value:function(t){var n=t.left;t.left=n.right,n.right!==null&&(n.right.parent=t),n.parent=t.parent,n.parent===null?this.root=n:t.isLeftChild?n.parent.left=n:n.parent.right=n,n.right=t,t.parent=n,t.balanceFactor=t.balanceFactor-1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor-1-Math.max(t.balanceFactor,0)}},{key:Symbol.iterator,value:ee.default.mark(function r(){var t,n,i;return ee.default.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:t=B9(this.getIterator()),s.prev=1,t.s();case 3:if((n=t.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),t.e(s.t0);case 14:return s.prev=14,t.f(),s.finish(14);case 17:case"end":return s.stop()}},r,this,[[1,11,14,17]])})},{key:"getIterator",value:ee.default.mark(function r(){var t,n,i,a=arguments;return ee.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:t=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(t,n.key)||t===null&&!n.left)){o.next=5;break}return o.abrupt("break",8);case 5:this.isLessThan(t,n.key)||t===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()}},r,this)})},{key:"getReverseIterator",value:ee.default.mark(function r(){var t,n,i,a=arguments;return ee.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:t=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(t,n.key)||t===null&&!n.right)){o.next=5;break}return o.abrupt("break",8);case 5:!this.isLessThan(t,n.key)||t===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()}},r,this)})}]),e}();function V9(e,r){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=G9(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
301
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){t=t.call(e)},n:function(){var c=t.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}}}function G9(e,r){if(e){if(typeof e=="string")return xw(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return xw(e,r)}}function xw(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var H9=function(){function e(r,t){Et.default(this,e),this.value=r,this.revision=t||0}return At.default(e,[{key:"isValid",get:function(){return!0}}]),e}(),K9=function(){function e(r){Et.default(this,e),this.revision=r}return At.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),Zm=function(){function e(){Et.default(this,e),this.items=new W9}return At.default(e,[{key:"store",value:function(t,n,i){var a=this.items.get(t);return a&&a.revision>i?a.isValid?a.value:null:(this.items.set(t,new H9(n,i)),n)}},{key:"delete",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=this.items.get(t);(!a||a.revision<n||a&&i===!0)&&this.items.set(t,new K9(n))}},{key:"isKnown",value:function(t,n){var i=this.items.get(t);return i&&i.revision>=n}},{key:"get",value:function(t){var n=this.items.get(t);return n&&n.isValid?n.value:null}},{key:"has",value:function(t){var n=this.items.get(t);return n&&n.isValid}},{key:"forEach",value:function(t){if(this.items){var n=V9(this.items),i;try{for(n.s();!(i=n.n()).done;){var a=SR.default(i.value,2),s=a[0],o=a[1];o.isValid&&t(s,o.value)}}catch(u){n.e(u)}finally{n.f()}}}}]),e}();function AR(e){var r=J9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function J9(){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 Ih=function(e){zr.default(t,e);var r=AR(t);function t(n,i,a){var s;Et.default(this,t),s=r.call(this,n,a);var o=function(c,l){return typeof l.ttl=="number"?{ttl:l.ttl}:c};return s.updateMergingQueue=new OR(o),s.cache=new Zm,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return At.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:"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=Me.default(ee.default.mark(function a(s,o,u,c){var l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return l={data:o},c!==void 0&&(l.ttl=c),m.next=4,this.services.network.post(s,l,u);case 4:return h=m.sent,h.body.data=o,h.body.date_updated=new Date(h.body.date_updated),m.abrupt("return",h.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=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return u=(o||{}).ttl,v.next=3,this._addOrUpdateItemOnServer(this.links.items,s,void 0,u);case 3:return c=v.sent,l=Number(c.index),this._handleItemMutated(l,c.url,c.last_event_id,c.revision,s,c.date_updated,c.date_expires,!0,!1),v.abrupt("return",this.cache.get(l));case 7:case"end":return v.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.squashAndAdd(s,l,function(m){return c._updateItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemUnconditionally",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.get(s);case 2:return c=v.sent,v.next=5,this._addOrUpdateItemOnServer(c.uri,o,void 0,u);case 5:return l=v.sent,this._handleItemMutated(s,l.url,l.last_event_id,l.revision,l.data,l.date_updated,l.date_expires,!1,!1),v.abrupt("return",this.cache.get(s));case 8:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemWithIfMatch",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l,h,v;return ee.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this.get(s);case 2:if(c=_.sent,l=o(Wn(c.data)),!l){_.next=25;break}return h=c.revision,_.prev=6,_.next=9,this._addOrUpdateItemOnServer(c.uri,l,h,u);case 9:return v=_.sent,this._handleItemMutated(s,v.url,v.last_event_id,v.revision,v.data,v.date_updated,v.date_expires,!1,!1),_.abrupt("return",this.cache.get(s));case 14:if(_.prev=14,_.t0=_.catch(6),_.t0.status!==412){_.next=22;break}return _.next=19,this._getItemFromServer(s);case 19:return _.abrupt("return",this._updateItemWithIfMatch(s,o,u));case 22:throw _.t0;case 23:_.next=26;break;case 25:return _.abrupt("return",c);case 26:case"end":return _.stop()}},a,this,[[6,14]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.add(s,l,function(m){return c._updateItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(s,function(h){return Object.assign(h,o)},u));case 1:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){var o,u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.get(s);case 2:return o=h.sent,u=Wn(o.data),h.next=6,this.services.network.delete(o.uri);case 6:c=h.sent,this._handleItemRemoved(s,c.body.last_event_id,u,new Date(c.body.date_updated),!1);case 8:case"end":return h.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(o=this.cache.get(s),!o){c.next=5;break}return c.abrupt("return",o);case 5:return c.abrupt("return",this._getItemFromServer(s));case 6:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.queryItems({index:s});case 2:if(o=c.sent,!(o.items.length<1)){c.next=7;break}throw new Qr("No item with index ".concat(s," found"),404,54151);case 7:return c.abrupt("return",o.items[0]);case 8:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new Xs(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 c=m.sent,l=c.body.items.map(function(_){_.date_updated=new Date(_.date_updated);var C=o.cache.get(_.index);return C?o._handleItemMutated(_.index,_.url,_.last_event_id,_.revision,_.data,_.date_updated,_.date_expires,!1,!0):o.cache.store(Number(_.index),new $h({index:Number(_.index),uri:_.url,revision:_.revision,lastEventId:_.last_event_id,dateUpdated:_.date_updated,dateExpires:_.date_expires,data:_.data}),_.last_event_id),o.cache.get(_.index)}),h=c.body.meta,m.abrupt("return",new Qm(l,function(_){return o.queryItems({pageToken:_})},h.previous_token,h.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},$R(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=Me.default(ee.default.mark(function a(){var s;return ee.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=Me.default(ee.default.mark(function a(s){var o,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,o={ttl:s},l.next=4,this.services.network.post(this.uri,o);case 4:u=l.sent,this.descriptor.date_expires=u.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.get(s);case 2:return u=v.sent,c={ttl:o},v.next=6,this.services.network.post(u.uri,c);case 6:l=v.sent,u.updateDateExpires(l.body.date_expires);case 8:case"end":return v.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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,c,l,h,v){if(this.shouldIgnoreEvent(i,s)){Ot.trace("Item ".concat(i," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(s));return}this._updateRootDateUpdated(c);var m=this.cache.get(i);if(!m){var _=new $h({index:i,uri:a,lastEventId:s,revision:o,data:u,dateUpdated:c,dateExpires:l});this.cache.store(i,_,s),this.emitItemMutationEvent(_,v,h);return}var C=Wn(m.data);m.update(s,o,u,c),this.cache.store(i,m,s),l!==void 0&&m.updateDateExpires(l),this.emitItemMutationEvent(m,v,!1,C)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",c={item:i,isLocal:!a};s||(c.previousItemData=o),this.broadcastEventToListeners(u,c)}},{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):(Ot.trace("Context update skipped, current:",this.lastEventId,", remote:",a),!1)}}],[{key:"type",get:function(){return"list"}}]),t}(Pu),mr=function(e){zr.default(t,e);var r=AR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncListImpl=n,i.syncListImpl.attach(si.default(i)),i}return At.default(t,[{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 Ih.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.push(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.set(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.mutate(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.update(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.setItemTtl(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Ih.type}}]),t}(Au);xt.default(mr,"itemAdded","itemAdded");xt.default(mr,"itemUpdated","itemUpdated");xt.default(mr,"itemRemoved","itemRemoved");xt.default(mr,"removed","removed");kt([Ee.validateTypesAsync(Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object,Object]),Re("design:returntype",Promise)],mr.prototype,"push",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Number,Object,Object]),Re("design:returntype",Promise)],mr.prototype,"set",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,"function",["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Number,Function,Object]),Re("design:returntype",Promise)],mr.prototype,"mutate",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Number,Object,Object]),Re("design:returntype",Promise)],mr.prototype,"update",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],mr.prototype,"remove",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],mr.prototype,"get",null);kt([Ee.validateTypesAsync(["undefined",Ee.objectSchema("query options",{from:[Ee.nonNegativeInteger,"undefined"],pageSize:[Ee.custom(function(e){return[Xm(e),"a positive integer"]}),"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],mr.prototype,"getItems",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],mr.prototype,"setTtl",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger,Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number,Number]),Re("design:returntype",Promise)],mr.prototype,"setItemTtl",null);var Lo=function(){function e(r){Et.default(this,e),this.descriptor=r}return At.default(e,[{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(t,n,i,a){return this.descriptor.last_event_id=t,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.date_updated=a,this}},{key:"updateDateExpires",value:function(t){this.descriptor.date_expires=t}}]),e}();function MR(e){var r=Y9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function Y9(){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 Oh=function(e){zr.default(t,e);var r=MR(t);function t(n,i,a){var s;Et.default(this,t),s=r.call(this,n,a);var o=function(c,l){return typeof l.ttl=="number"?{ttl:l.ttl}:c};return s.updateMergingQueue=new OR(o),s.cache=new Zm,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 Lo(u),u.last_event_id)}),s}return At.default(t,[{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=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.squashAndAdd(s,l,function(m){return c._putItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(s!=null){u.next=2;break}throw new Qr("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=Me.default(ee.default.mark(function a(s){var o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.queryItems({key:s});case 2:if(o=c.sent,!(o.items.length<1)){c.next=7;break}throw new Qr("The specified Map Item does not exist",404,54201);case 7:return c.abrupt("return",o.items[0]);case 8:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c=this,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return l=u||{},v.abrupt("return",this.updateMergingQueue.add(s,l,function(m){return c._putItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(s,function(h){return Object.assign(h,o)},u));case 1:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemUnconditionally",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this._putItemToServer(s,o,void 0,u);case 2:return c=v.sent,l=c.item,this._handleItemMutated(l.key,l.url,l.last_event_id,l.revision,l.data,l.date_updated,l.date_expires,c.added,!1),v.abrupt("return",this.cache.get(l.key));case 6:case"end":return v.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemWithIfMatch",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){var c,l,h,v,m;return ee.default.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,this.get(s).catch(function(I){if(I.status===404)return new Lo({key:s,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw I});case 2:if(c=C.sent,l=o(Wn(c.data)),!l){C.next=26;break}return h=c.revision,C.prev=6,C.next=9,this._putItemToServer(s,l,h,u);case 9:return v=C.sent,m=v.item,this._handleItemMutated(m.key,m.url,m.last_event_id,m.revision,m.data,m.date_updated,m.date_expires,v.added,!1),C.abrupt("return",this.cache.get(m.key));case 15:if(C.prev=15,C.t0=C.catch(6),C.t0.status!==412){C.next=23;break}return C.next=20,this._getItemFromServer(s);case 20:return C.abrupt("return",this._putItemWithIfMatch(s,o,u));case 23:throw C.t0;case 24:C.next=27;break;case 26:return C.abrupt("return",c);case 27:case"end":return C.stop()}},a,this,[[6,15]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemToServer",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u,c){var l,h,v,m,_;return ee.default.wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return l=new Xs(this.links.items).pathSegment(s).build(),h={data:o},c!==void 0&&(h.ttl=c),I.prev=3,I.next=6,this.services.network.put(l,h,u);case 6:return v=I.sent,m=v.body,m.data=o,m.date_updated=new Date(m.date_updated),_=v.status.code===201,I.abrupt("return",{added:_,item:m});case 14:throw I.prev=14,I.t0=I.catch(3),I.t0.status===404&&this.onRemoved(!1),I.t0;case 18:case"end":return I.stop()}},a,this,[[3,14]])}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){var o,u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.get(s);case 2:return o=h.sent,u=Wn(o.data),h.next=6,this.services.network.delete(o.uri);case 6:c=h.sent,this._handleItemRemoved(s,c.body.last_event_id,u,new Date(c.body.date_updated),!1);case 8:case"end":return h.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new Xs(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 c=m.sent,l=c.body.items.map(function(_){_.date_updated=new Date(_.date_updated);var C=o.cache.get(_.key);return C?o._handleItemMutated(_.key,_.url,_.last_event_id,_.revision,_.data,_.date_updated,_.date_expires,!1,!0):o.cache.store(_.key,new Lo(_),_.last_event_id),o.cache.get(_.key)}),h=c.body.meta,m.abrupt("return",new Qm(l,function(_){return o.queryItems({pageToken:_})},h.previous_token,h.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},$R(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,c,l,h,v){if(this.shouldIgnoreEvent(i,s)){Ot.trace("SyncMapItem ",i," update skipped, current:",this.lastEventId,", remote:",s);return}this._updateRootDateUpdated(c);var m=this.cache.get(i);if(!m){var _=new Lo({key:i,url:a,last_event_id:s,revision:o,data:u,date_updated:c,date_expires:l});this.cache.store(i,_,s),this.emitItemMutationEvent(_,v,h);return}var C=Wn(m.data);m.update(s,o,u,c),this.cache.store(i,m,s),l!==void 0&&m.updateDateExpires(l),this.emitItemMutationEvent(m,v,!1,C)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",c={item:i,isLocal:!a};s||(c.previousItemData=o),this.broadcastEventToListeners(u,c)}},{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=Me.default(ee.default.mark(function a(s){var o,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,o={ttl:s},l.next=4,this.services.network.post(this.uri,o);case 4:u=l.sent,this.descriptor.date_expires=u.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=Me.default(ee.default.mark(function a(s,o){var u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,this.get(s);case 2:return u=v.sent,c={ttl:o},v.next=6,this.services.network.post(u.uri,c);case 6:l=v.sent,u.updateDateExpires(l.body.date_expires);case 8:case"end":return v.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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"}}]),t}(Pu),_r=function(e){zr.default(t,e);var r=MR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncMapImpl=n,i.syncMapImpl.attach(si.default(i)),i}return At.default(t,[{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 Oh.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=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.set(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.mutate(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=Me.default(ee.default.mark(function a(s,o,u){return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.update(s,o,u));case 2:case"end":return l.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s,o){return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.setItemTtl(s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Oh.type}}]),t}(Au);xt.default(_r,"itemAdded","itemAdded");xt.default(_r,"itemUpdated","itemUpdated");xt.default(_r,"itemRemoved","itemRemoved");xt.default(_r,"removed","removed");kt([Ee.validateTypesAsync("string",Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[String,Object,Object]),Re("design:returntype",Promise)],_r.prototype,"set",null);kt([Ee.validateTypesAsync("string"),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],_r.prototype,"get",null);kt([Ee.validateTypesAsync("string","function",["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[String,Function,Object]),Re("design:returntype",Promise)],_r.prototype,"mutate",null);kt([Ee.validateTypesAsync("string",Ee.pureObject,["undefined",Ee.objectSchema("item metadata",{ttl:[Ee.nonNegativeInteger,"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[String,Object,Object]),Re("design:returntype",Promise)],_r.prototype,"update",null);kt([Ee.validateTypesAsync("string"),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],_r.prototype,"remove",null);kt([Ee.validateTypesAsync(["undefined",Ee.objectSchema("query options",{from:["string","undefined"],pageSize:[Ee.custom(function(e){return[Xm(e),"a positive integer"]}),"undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],_r.prototype,"getItems",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],_r.prototype,"setTtl",null);kt([Ee.validateTypesAsync("string",Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[String,Number]),Re("design:returntype",Promise)],_r.prototype,"setItemTtl",null);function xR(e){var r=X9();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function X9(){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 ru=function(e){zr.default(t,e);var r=xR(t);function t(n,i,a){var s;return Et.default(this,t),s=r.call(this,n,a),s.descriptor=i,s}return At.default(t,[{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=Me.default(ee.default.mark(function a(s){var o,u,c,l;return ee.default.wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return o={data:s},v.next=3,this.services.network.post(this.links.messages,o);case 3:return u=v.sent,c=u.body,l=this._handleMessagePublished(c.sid,s,!1),v.abrupt("return",l);case 7:case"end":return v.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=Me.default(ee.default.mark(function a(s){var o,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,o={ttl:s},l.next=4,this.services.network.post(this.uri,o);case 4:u=l.sent,this.descriptor.date_expires=u.body.date_expires,l.next=12;break;case 8:throw l.prev=8,l.t0=l.catch(0),l.t0.status===404&&this.onRemoved(!1),l.t0;case 12:case"end":return l.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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"}}]),t}(Pu);kt([Ee.validateTypesAsync(Ee.pureObject),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],ru.prototype,"publishMessage",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],ru.prototype,"setTtl",null);var ai=function(e){zr.default(t,e);var r=xR(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.syncStreamImpl=n,i.syncStreamImpl.attach(si.default(i)),i}return At.default(t,[{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 ru.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(s){return ee.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=Me.default(ee.default.mark(function a(){return ee.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(){Iu.default(cr.default(t.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return ru.type}}]),t}(Au);xt.default(ai,"messagePublished","messagePublished");xt.default(ai,"removed","removed");kt([Ee.validateTypesAsync(Ee.pureObject),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],ai.prototype,"publishMessage",null);kt([Ee.validateTypesAsync(Ee.nonNegativeInteger),Re("design:type",Function),Re("design:paramtypes",[Number]),Re("design:returntype",Promise)],ai.prototype,"setTtl",null);var Q9=function e(r){Et.default(this,e),this.sdk="js",this.sdkVer=r,this.os=gc.os.family,this.osVer=gc.os.version,this.pl=gc.name,this.plVer=gc.version},Z9=function(){function e(){Et.default(this,e),this.names=new Map,this.entities=new Map}return At.default(e,[{key:"store",value:function(t){var n=this.entities.get(t.sid);return n||(this.entities.set(t.sid,t),t.uniqueName&&this.names.set(t.type+"::"+t.uniqueName,t.sid),t)}},{key:"getResolved",value:function(t,n){var i=this.names.get(n+"::"+t);return i?this.entities.get(i):null}},{key:"get",value:function(t,n){return this.entities.get(t)||this.getResolved(t,n)||null}},{key:"remove",value:function(t){var n=this.entities.get(t);n&&(this.entities.delete(t),n.uniqueName&&this.names.delete(n.type+"::"+n.uniqueName))}}]),e}();function eg(e){var r=e7();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function e7(){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 t7=function e(){Et.default(this,e)},Ph=function(e){zr.default(t,e);var r=eg(t);function t(n,i,a,s){var o;return Et.default(this,t),o=r.call(this,i,a),o.descriptor=n,o.cache=new Zm,s&&s.forEach(function(u){o.cache.store(u.key,{key:u.key,value:u.data},u.revision)}),o}return At.default(t,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return t.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))Ot.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)?Ot.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,c){var l=s[u];l!=null?a.handleItemMutated(u,l.data,l.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"}}]),t}(Pu);function NR(e){return Ah.apply(this,arguments)}function Ah(){return Ah=Me.default(ee.default.mark(function e(r){var t,n,i,a,s,o;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(t=r.network,n=r.queryString,i=r.uri,a=r.type,n!=null){c.next=3;break}throw new Qr("Invalid query",400,54507);case 3:return s={query_string:n},a===xi.type&&(s.type=a),c.next=7,t.post(i,s,void 0,!0);case 7:return o=c.sent,c.abrupt("return",o.body);case 9:case"end":return c.stop()}},e)})),Ah.apply(this,arguments)}var xi=function(e){zr.default(t,e);var r=eg(t);function t(n){var i;return Et.default(this,t),i=r.call(this),i.liveQueryImpl=n,i.liveQueryImpl.attach(si.default(i)),i}return At.default(t,[{key:"type",get:function(){return Ph.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){Iu.default(cr.default(t.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 Ph.type}}]),t}(Au);xt.default(xi,"itemUpdated","itemUpdated");xt.default(xi,"itemRemoved","itemRemoved");var Mu=function(e){zr.default(t,e);var r=eg(t);function t(n){var i;return Et.default(this,t),i=r.call(this),xt.default(si.default(i),"queryExpression",null),xt.default(si.default(i),"items",{}),Object.assign(si.default(i),n),i.updateIndexName(n.indexName),i}return At.default(t,[{key:"type",get:function(){return t.type}},{key:"search",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this;return ee.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.items={},c.abrupt("return",NR({network:this.network,uri:this.queryUri,queryString:s}).then(function(l){o.queryExpression=s,l.items&&l.items.forEach(function(h){o.items[h.key]=h.data}),o.emit("searchResult",o.getItems())}).catch(function(l){throw Ot.error("Error '".concat(l.message,"' while executing query '").concat(s,"'")),o.queryExpression=null,l}));case 2:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"subscribe",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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 Qr("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 Xs(this.insightsUri).pathSegment(i).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),t}(Lt);xt.default(Mu,"searchResult","searchResult");kt([Ee.validateTypesAsync("string"),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],Mu.prototype,"search",null);kt([Ee.validateTypes(Ee.nonEmptyString),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",void 0)],Mu.prototype,"updateIndexName",null);var r7="3.1.0";function n7(e){var r=i7();return function(){var n=cr.default(e),i;if(r){var a=cr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return Oa.default(this,i)}}function i7(){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 Nw(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),t.push.apply(t,n)}return t}function Lw(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Nw(Object(t),!0).forEach(function(n){xt.default(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Nw(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var a7="data_sync",np=r7;function yc(e){if(e){if(typeof e=="string")return{id:e,mode:"open_or_create"};var r=e.mode||(e.id?"open_or_create":"create_new");return Lw(Lw({},e),{},{mode:r})}else return{mode:"create_new"}}var Dw="com.twilio.rtd.cds.document",jw="com.twilio.rtd.cds.list",Fw="com.twilio.rtd.cds.map",Uw="twilio.sync.event",vn=function(e){zr.default(t,e);var r=n7(t);function t(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Et.default(this,t),i=r.call(this),!n)throw new Error("Sync library needs a valid Twilio token to be passed");a.hasOwnProperty("logLevel")?Ot.setLevel(a.logLevel):Ot.setLevel("silent");var s=a.productId=a.productId||a7;a.clientMetadata=a.clientMetadata||{},a.clientMetadata.hasOwnProperty("type")||(a.clientMetadata.type="sync"),a.clientMetadata.hasOwnProperty("sdk")||(a.clientMetadata.sdk="JS",a.clientMetadata.sdkv=np);var o=!a.twilsockClient;if(!a.initRegistrations){var u=new El.InitRegistration(s);t.populateInitRegistrations(u),a.initRegistrations=[u]}var c=a.twilsockClient=a.twilsockClient||new El.Twilsock(n,s,a);c.on("tokenAboutToExpire",function(m){return i.emit("tokenAboutToExpire",m)}),c.on("tokenExpired",function(){return i.emit("tokenExpired")}),c.on("connectionError",function(m){return i.emit("connectionError",m)}),c.on("stateChanged",function(m){i.emit("connectionStateChanged",m),i.services.subscriptions.onConnectionStateChanged(m==="connected")}),c.on("message",function(m,_){return i._routeMessage(m,_)});var l=new k9(a),h=new x9(new Q9(np),l,c),v=new N9(l);return i.services={config:l,twilsock:c,network:h,storage:v,router:si.default(i),subscriptions:null},i.services.subscriptions=new I9(i.services),i.entities=new Z9,o&&c.connect(),i}return At.default(t,[{key:"_routeMessage",value:function(i,a){switch(Ot.trace("Notification type:",i,"content:",a),i){case Dw:case jw:case Fw:this.services.subscriptions.acceptMessage(a,!1);break;case Uw: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=Me.default(ee.default.mark(function a(){var s;return ee.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),Ot.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=Wn(s);(i===mr.type||i===_r.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=Me.default(ee.default.mark(function a(s,o){var u,c,l,h=arguments;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(u=h.length>2&&h[2]!==void 0?h[2]:!1,o){m.next=3;break}throw new Qr("Cannot get entity without id",404);case 3:return c=new Xs(s).pathSegment(o).queryParam("Include",u?"items":void 0).build(),m.next=6,this.services.network.get(c);case 6:return l=m.sent,m.abrupt("return",l.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(kn.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(c){return c.body})}},{key:"_getList",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(mr.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=Me.default(ee.default.mark(function a(s){var o,u=arguments;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return o=u.length>1&&u[1]!==void 0?u[1]:!1,l.abrupt("return",this.readRootFromSessionCache(_r.type,s)||this._get(this.services.config.mapsUri,s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getStream",value:function(){var n=Me.default(ee.default.mark(function a(s){return ee.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.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=Me.default(ee.default.mark(function a(s,o){var u,c;return ee.default.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return u={unique_name:s},o!==void 0&&(u.ttl=o),h.next=4,this.services.network.post(this.services.config.streamsUri,u);case 4:return c=h.sent,h.abrupt("return",c.body);case 6:case"end":return h.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_getLiveQuery",value:function(i){return this.readRootFromSessionCache(xi.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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=yc(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createDocument(u.id,u.data,u.ttl);case 6:c=m.sent,m.next=39;break;case 9:if(l=this.getCached(u.id,kn.type),!l){m.next=14;break}return m.abrupt("return",new kn(l));case 14:return m.prev=14,m.next=17,this._getDocument(u.id);case 17:c=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:c=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(kn.type,u.id,c),h=new Rh(this.services,c,function(_,C,I){return o.removeFromCacheAndSession(_,C,I)}),h=this.entities.store(h),m.abrupt("return",new kn(h));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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=yc(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createMap(u.id,u.ttl);case 6:c=m.sent,m.next=39;break;case 9:if(l=this.getCached(u.id,_r.type),!l){m.next=14;break}return m.abrupt("return",new _r(l));case 14:return m.prev=14,m.next=17,this._getMap(u.id,u.includeItems);case 17:c=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:c=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(_r.type,u.id,c),h=new Oh(this.services,c,function(_,C,I){return o.removeFromCacheAndSession(_,C,I)}),h=this.entities.store(h),m.abrupt("return",new _r(h));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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h;return ee.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=yc(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:c=m.sent,m.next=39;break;case 9:if(l=this.getCached(u.id,mr.type),!l){m.next=14;break}return m.abrupt("return",new mr(l));case 14:return m.prev=14,m.next=17,this._getList(u.id);case 17:c=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:c=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(mr.type,u.id,c),h=new Ih(this.services,c,function(_,C,I){return o.removeFromCacheAndSession(_,C,I)}),h=this.entities.store(h),m.abrupt("return",new mr(h));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=Me.default(ee.default.mark(function a(s){var o=this,u,c,l,h,v;return ee.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this.ensureReady();case 2:if(u=yc(s),u.mode!=="create_new"){_.next=9;break}return _.next=6,this._createStream(u.id,u.ttl);case 6:c=_.sent,_.next=39;break;case 9:if(l=this.getCached(u.id,ai.type),!l){_.next=14;break}return _.abrupt("return",new ai(l));case 14:return _.prev=14,_.next=17,this._getStream(u.id);case 17:c=_.sent,_.next=39;break;case 20:if(_.prev=20,_.t0=_.catch(14),!(_.t0.status!==404||u.mode==="open_existing")){_.next=26;break}throw _.t0;case 26:return _.prev=26,_.next=29,this._createStream(u.id,u.ttl);case 29:c=_.sent,_.next=39;break;case 32:if(_.prev=32,_.t1=_.catch(26),_.t1.status!==409){_.next=38;break}return _.abrupt("return",this.stream(s));case 38:throw _.t1;case 39:return this.storeRootInSessionCache(ai.type,u.id,c),h=function(I,$,x){return o.removeFromCacheAndSession(I,$,x)},v=new ru(this.services,c,h),v=this.entities.store(v),_.abrupt("return",new ai(v));case 44:case"end":return _.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shutdown",value:function(){var n=Me.default(ee.default.mark(function a(){return ee.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=Me.default(ee.default.mark(function a(s){return ee.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.twilsock.updateToken(s).catch(function(c){var l,h=c==null||(l=c.reply)===null||l===void 0?void 0:l.status;throw(h==null?void 0:h.code)===401&&(h==null?void 0:h.status)==="UNAUTHORIZED"?new Qr("Updated token was rejected by server",400,51130):c}));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=Me.default(ee.default.mark(function a(s,o){var u=this,c,l,h,v,m;return ee.default.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,this.ensureReady();case 2:return c=new Xs(this.services.config.insightsUri).pathSegment(s).pathSegment("Items").build(),C.next=5,NR({network:this.services.network,uri:c,queryString:o,type:xi.type});case 5:return l=C.sent,h=this.getCached(l.query_id,xi.type),h||(v=this._getLiveQuery(l.query_id),v||(v={indexName:s,queryExpression:o,sid:l.query_id,queryUri:c,last_event_id:l.last_event_id}),m=function($,x,N){return u.removeFromCacheAndSession($,x,N)},h=new Ph(v,this.services,m,l.items)),this.storeRootInSessionCache(xi.type,l.query_id,h.liveQueryDescriptor),h=this.entities.store(h),C.abrupt("return",new xi(h));case 11:case"end":return C.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"instantQuery",value:function(){var n=Me.default(ee.default.mark(function a(s){var o=this,u;return ee.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.ensureReady();case 2:return u=function(v,m){return o.liveQuery(v,m)},l.abrupt("return",new Mu({indexName:s,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:u}));case 4:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()}],[{key:"populateInitRegistrations",value:function(i){i.populateInitRegistrations([Uw,Dw,jw,Fw])}},{key:"version",get:function(){return np}}]),t}(Lt);xt.default(vn,"connectionStateChanged","connectionStateChanged");xt.default(vn,"connectionError","connectionError");xt.default(vn,"tokenAboutToExpire","tokenAboutToExpire");xt.default(vn,"tokenExpired","tokenExpired");kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open document options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"document",null);kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open map options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)],includeItems:["boolean","undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"map",null);kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open list options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)],purpose:["string","undefined"],context:[Ee.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"list",null);kt([Ee.validateTypesAsync(["undefined","string",Ee.objectSchema("open stream options",{id:["string","undefined"],mode:[Ee.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ee.nonNegativeInteger,"undefined"],data:[Ee.pureObject,"undefined",Ee.literal(null)]})]),Re("design:type",Function),Re("design:paramtypes",[Object]),Re("design:returntype",Promise)],vn.prototype,"stream",null);kt([Ee.validateTypesAsync(Ee.nonEmptyString),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],vn.prototype,"updateToken",null);kt([Ee.validateTypesAsync(Ee.nonEmptyString,"string"),Re("design:type",Function),Re("design:paramtypes",[String,String]),Re("design:returntype",Promise)],vn.prototype,"liveQuery",null);kt([Ee.validateTypesAsync(Ee.nonEmptyString),Re("design:type",Function),Re("design:paramtypes",[String]),Re("design:returntype",Promise)],vn.prototype,"instantQuery",null);en.Client=vn;en.InsightsItem=t7;en.InstantQuery=Mu;en.LiveQuery=xi;en.Paginator=Qm;en.SyncClient=vn;en.SyncDocument=kn;en.SyncList=mr;en.SyncListItem=$h;en.SyncMap=_r;en.SyncMapItem=Lo;en.SyncStream=ai;var LR={},s7=Jt,o7=li,u7=Bt,c7=u7("match"),l7=function(e){var r;return s7(e)&&((r=e[c7])!==void 0?!!r:o7(e)==="RegExp")},f7=l7,d7=TypeError,DR=function(e){if(f7(e))throw new d7("The method doesn't accept regular expressions");return e},p7=Bt,h7=p7("match"),jR=function(e){var r=/./;try{"/./"[e](r)}catch{try{return r[h7]=!1,"/./"[e](r)}catch{}}return!1},v7=gt,m7=jv,g7=Bi.f,y7=Wi,Bw=wr,b7=DR,_7=Kn,w7=jR,S7=m7("".slice),C7=Math.min,FR=w7("startsWith"),T7=!FR&&!!function(){var e=g7(String.prototype,"startsWith");return e&&!e.writable}();v7({target:"String",proto:!0,forced:!T7&&!FR},{startsWith:function(r){var t=Bw(_7(this));b7(r);var n=y7(C7(arguments.length>1?arguments[1]:void 0,t.length)),i=Bw(r);return S7(t,n,n+i.length)===i}});var E7=lt,k7=Bt,R7=Wt,qw=B0,$7=k7("iterator"),UR=!E7(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),r=e.searchParams,t=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",r.forEach(function(i,a){r.delete("b"),n+=a+i}),t.delete("a",2),t.delete("b",void 0),qw&&(!e.toJSON||!t.has("a",1)||t.has("a",2)||!t.has("a",void 0)||t.has("b"))||!r.size&&(qw||!R7)||!r.sort||e.href!=="https://a/c%20d?a=1&c=3"||r.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!r[$7]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||n!=="a1c3"||new URL("https://x",void 0).host!=="x"}),ds=vt,ip=2147483647,zo=36,BR=1,Mh=26,I7=38,O7=700,P7=72,A7=128,M7="-",x7=/[^\0-\u007E]/,qR=/[.\u3002\uFF0E\uFF61]/g,zw="Overflow: input needs wider integers to process",ap=zo-BR,Ww=RangeError,N7=ds(qR.exec),As=Math.floor,sp=String.fromCharCode,Vw=ds("".charCodeAt),zR=ds([].join),fa=ds([].push),L7=ds("".replace),D7=ds("".split),j7=ds("".toLowerCase),F7=function(e){for(var r=[],t=0,n=e.length;t<n;){var i=Vw(e,t++);if(i>=55296&&i<=56319&&t<n){var a=Vw(e,t++);(a&64512)===56320?fa(r,((i&1023)<<10)+(a&1023)+65536):(fa(r,i),t--)}else fa(r,i)}return r},Gw=function(e){return e+22+75*(e<26)},U7=function(e,r,t){var n=0;for(e=t?As(e/O7):e>>1,e+=As(e/r);e>ap*Mh>>1;)e=As(e/ap),n+=zo;return As(n+(ap+1)*e/(e+I7))},B7=function(e){var r=[];e=F7(e);var t=e.length,n=A7,i=0,a=P7,s,o;for(s=0;s<e.length;s++)o=e[s],o<128&&fa(r,sp(o));var u=r.length,c=u;for(u&&fa(r,M7);c<t;){var l=ip;for(s=0;s<e.length;s++)o=e[s],o>=n&&o<l&&(l=o);var h=c+1;if(l-n>As((ip-i)/h))throw new Ww(zw);for(i+=(l-n)*h,n=l,s=0;s<e.length;s++){if(o=e[s],o<n&&++i>ip)throw new Ww(zw);if(o===n){for(var v=i,m=zo;;){var _=m<=a?BR:m>=a+Mh?Mh:m-a;if(v<_)break;var C=v-_,I=zo-_;fa(r,sp(Gw(_+C%I))),v=As(C/I),m+=zo}fa(r,sp(Gw(v))),a=U7(i,h,c===u),i=0,c++}}i++,n++}return zR(r,"")},q7=function(e){var r=[],t=D7(L7(j7(e),qR,"."),"."),n,i;for(n=0;n<t.length;n++)i=t[n],fa(r,N7(x7,i)?"xn--"+B7(i):i);return zR(r,".")},z7=gt,W7=vt,V7=as,G7=RangeError,Hw=String.fromCharCode,Kw=String.fromCodePoint,H7=W7([].join),K7=!!Kw&&Kw.length!==1;z7({target:"String",stat:!0,arity:1,forced:K7},{fromCodePoint:function(r){for(var t=[],n=arguments.length,i=0,a;n>i;){if(a=+arguments[i++],V7(a,1114111)!==a)throw new G7(a+" is not a valid code point");t[i]=a<65536?Hw(a):Hw(((a-=65536)>>10)+55296,a%1024+56320)}return H7(t,"")}});var xh=gt,WR=_t,tg=sT,J7=$n,bc=Ft,Gn=vt,Wo=Wt,VR=UR,GR=Ur,Y7=hi,X7=uf,Q7=di,Z7=AT,rg=pn,HR=ka,op=Ut,eK=tr,tK=Gi,rK=Vi,nK=ar,KR=Jt,Dr=wr,iK=Ta,Jw=ts,Yw=Hl,aK=wu,_c=Jl,Cs=Gv,sK=Bt,oK=zm,uK=sK("iterator"),fo="URLSearchParams",JR=fo+"Iterator",YR=rg.set,Tn=rg.getterFor(fo),cK=rg.getterFor(JR),Xw=tg("fetch"),kl=tg("Request"),Vo=tg("Headers"),up=kl&&kl.prototype,Qw=Vo&&Vo.prototype,lK=WR.TypeError,fK=WR.encodeURIComponent,dK=String.fromCharCode,pK=J7("String","fromCodePoint"),hK=parseInt,el=Gn("".charAt),Zw=Gn([].join),da=Gn([].push),XR=Gn("".replace),vK=Gn([].shift),eS=Gn([].splice),tS=Gn("".split),QR=Gn("".slice),mK=Gn(/./.exec),gK=/\+/g,cp="�",yK=/^[0-9a-f]+$/i,rS=function(e,r){var t=QR(e,r,r+2);return mK(yK,t)?hK(t,16):NaN},bK=function(e){for(var r=0,t=128;t>0&&e&t;t>>=1)r++;return r},_K=function(e){var r=null;switch(e.length){case 1:r=e[0];break;case 2:r=(e[0]&31)<<6|e[1]&63;break;case 3:r=(e[0]&15)<<12|(e[1]&63)<<6|e[2]&63;break;case 4:r=(e[0]&7)<<18|(e[1]&63)<<12|(e[2]&63)<<6|e[3]&63;break}return r>1114111?null:r},nS=function(e){e=XR(e,gK," ");for(var r=e.length,t="",n=0;n<r;){var i=el(e,n);if(i==="%"){if(el(e,n+1)==="%"||n+3>r){t+="%",n++;continue}var a=rS(e,n+1);if(a!==a){t+=i,n++;continue}n+=2;var s=bK(a);if(s===0)i=dK(a);else{if(s===1||s>4){t+=cp,n++;continue}for(var o=[a],u=1;u<s&&(n++,!(n+3>r||el(e,n)!=="%"));){var c=rS(e,n+1);if(c!==c){n+=3;break}if(c>191||c<128)break;da(o,c),n+=2,u++}if(o.length!==s){t+=cp;continue}var l=_K(o);l===null?t+=cp:i=pK(l)}}t+=i,n++}return t},wK=/[!'()~]|%20/g,SK={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},CK=function(e){return SK[e]},iS=function(e){return XR(fK(e),wK,CK)},lp=Z7(function(r,t){YR(this,{type:JR,target:Tn(r).entries,index:0,kind:t})},fo,function(){var r=cK(this),t=r.target,n=r.index++;if(!t||n>=t.length)return r.target=null,_c(void 0,!0);var i=t[n];switch(r.kind){case"keys":return _c(i.key,!1);case"values":return _c(i.value,!1)}return _c([i.key,i.value],!1)},!0),ZR=function(e){this.entries=[],this.url=null,e!==void 0&&(KR(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?el(e,0)==="?"?QR(e,1):e:Dr(e)))};ZR.prototype={type:fo,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var r=this.entries,t=aK(e),n,i,a,s,o,u,c;if(t)for(n=Yw(e,t),i=n.next;!(a=bc(i,n)).done;){if(s=Yw(nK(a.value)),o=s.next,(u=bc(o,s)).done||(c=bc(o,s)).done||!bc(o,s).done)throw new lK("Expected sequence with length 2");da(r,{key:Dr(u.value),value:Dr(c.value)})}else for(var l in e)eK(e,l)&&da(r,{key:l,value:Dr(e[l])})},parseQuery:function(e){if(e)for(var r=this.entries,t=tS(e,"&"),n=0,i,a;n<t.length;)i=t[n++],i.length&&(a=tS(i,"="),da(r,{key:nS(vK(a)),value:nS(Zw(a,"="))}))},serialize:function(){for(var e=this.entries,r=[],t=0,n;t<e.length;)n=e[t++],da(r,iS(n.key)+"="+iS(n.value));return Zw(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var yf=function(){HR(this,Qs);var r=arguments.length>0?arguments[0]:void 0,t=YR(this,new ZR(r));Wo||(this.size=t.entries.length)},Qs=yf.prototype;X7(Qs,{append:function(r,t){var n=Tn(this);Cs(arguments.length,2),da(n.entries,{key:Dr(r),value:Dr(t)}),Wo||this.length++,n.updateURL()},delete:function(e){for(var r=Tn(this),t=Cs(arguments.length,1),n=r.entries,i=Dr(e),a=t<2?void 0:arguments[1],s=a===void 0?a:Dr(a),o=0;o<n.length;){var u=n[o];if(u.key===i&&(s===void 0||u.value===s)){if(eS(n,o,1),s!==void 0)break}else o++}Wo||(this.size=n.length),r.updateURL()},get:function(r){var t=Tn(this).entries;Cs(arguments.length,1);for(var n=Dr(r),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(r){var t=Tn(this).entries;Cs(arguments.length,1);for(var n=Dr(r),i=[],a=0;a<t.length;a++)t[a].key===n&&da(i,t[a].value);return i},has:function(r){for(var t=Tn(this).entries,n=Cs(arguments.length,1),i=Dr(r),a=n<2?void 0:arguments[1],s=a===void 0?a:Dr(a),o=0;o<t.length;){var u=t[o++];if(u.key===i&&(s===void 0||u.value===s))return!0}return!1},set:function(r,t){var n=Tn(this);Cs(arguments.length,1);for(var i=n.entries,a=!1,s=Dr(r),o=Dr(t),u=0,c;u<i.length;u++)c=i[u],c.key===s&&(a?eS(i,u--,1):(a=!0,c.value=o));a||da(i,{key:s,value:o}),Wo||(this.size=i.length),n.updateURL()},sort:function(){var r=Tn(this);oK(r.entries,function(t,n){return t.key>n.key?1:-1}),r.updateURL()},forEach:function(r){for(var t=Tn(this).entries,n=tK(r,arguments.length>1?arguments[1]:void 0),i=0,a;i<t.length;)a=t[i++],n(a.value,a.key,this)},keys:function(){return new lp(this,"keys")},values:function(){return new lp(this,"values")},entries:function(){return new lp(this,"entries")}},{enumerable:!0});GR(Qs,uK,Qs.entries,{name:"entries"});GR(Qs,"toString",function(){return Tn(this).serialize()},{enumerable:!0});Wo&&Y7(Qs,"size",{get:function(){return Tn(this).entries.length},configurable:!0,enumerable:!0});Q7(yf,fo);xh({global:!0,constructor:!0,forced:!VR},{URLSearchParams:yf});if(!VR&&op(Vo)){var TK=Gn(Qw.has),EK=Gn(Qw.set),aS=function(e){if(KR(e)){var r=e.body,t;if(rK(r)===fo)return t=e.headers?new Vo(e.headers):new Vo,TK(t,"content-type")||EK(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),iK(e,{body:Jw(0,Dr(r)),headers:Jw(0,t)})}return e};if(op(Xw)&&xh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(r){return Xw(r,arguments.length>1?aS(arguments[1]):{})}}),op(kl)){var fp=function(r){return HR(this,up),new kl(r,arguments.length>1?aS(arguments[1]):{})};up.constructor=fp,fp.prototype=up,xh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fp})}}var kK={URLSearchParams:yf,getState:Tn},RK=gt,ng=Wt,$K=UR,ig=_t,sS=Gi,An=vt,Rl=Ur,_n=hi,IK=ka,Nh=tr,ag=uR,Ts=IT,Ln=pi,OK=tm.codeAt,PK=q7,Ri=wr,AK=di,MK=Gv,e1=kK,t1=pn,xK=t1.set,$l=t1.getterFor("URL"),NK=e1.URLSearchParams,LK=e1.getState,Oo=ig.URL,Lh=ig.TypeError,Il=ig.parseInt,DK=Math.floor,oS=Math.pow,En=An("".charAt),qn=An(/./.exec),Do=An([].join),jK=An(1 .toString),FK=An([].pop),$s=An([].push),dp=An("".replace),UK=An([].shift),BK=An("".split),Go=An("".slice),Ol=An("".toLowerCase),qK=An([].unshift),zK="Invalid authority",pp="Invalid scheme",za="Invalid host",uS="Invalid port",r1=/[a-z]/i,WK=/[\d+-.a-z]/i,Dh=/\d/,VK=/^0x/i,GK=/^[0-7]+$/,HK=/^\d+$/,n1=/^[\da-f]+$/i,KK=/[\0\t\n\r #%/:<>?@[\\\]^|]/,JK=/[\0\t\n\r #/:<>?@[\\\]^|]/,YK=/^[\u0000-\u0020]+/,XK=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,QK=/[\t\n\r]/g,wn,ZK=function(e){var r=BK(e,"."),t,n,i,a,s,o,u;if(r.length&&r[r.length-1]===""&&r.length--,t=r.length,t>4)return e;for(n=[],i=0;i<t;i++){if(a=r[i],a==="")return e;if(s=10,a.length>1&&En(a,0)==="0"&&(s=qn(VK,a)?16:8,a=Go(a,s===8?1:2)),a==="")o=0;else{if(!qn(s===10?HK:s===8?GK:n1,a))return e;o=Il(a,s)}$s(n,o)}for(i=0;i<t;i++)if(o=n[i],i===t-1){if(o>=oS(256,5-t))return null}else if(o>255)return null;for(u=FK(n),i=0;i<n.length;i++)u+=n[i]*oS(256,3-i);return u},eJ=function(e){var r=[0,0,0,0,0,0,0,0],t=0,n=null,i=0,a,s,o,u,c,l,h,v=function(){return En(e,i)};if(v()===":"){if(En(e,1)!==":")return;i+=2,t++,n=t}for(;v();){if(t===8)return;if(v()===":"){if(n!==null)return;i++,t++,n=t;continue}for(a=s=0;s<4&&qn(n1,v());)a=a*16+Il(v(),16),i++,s++;if(v()==="."){if(s===0||(i-=s,t>6))return;for(o=0;v();){if(u=null,o>0)if(v()==="."&&o<4)i++;else return;if(!qn(Dh,v()))return;for(;qn(Dh,v());){if(c=Il(v(),10),u===null)u=c;else{if(u===0)return;u=u*10+c}if(u>255)return;i++}r[t]=r[t]*256+u,o++,(o===2||o===4)&&t++}if(o!==4)return;break}else if(v()===":"){if(i++,!v())return}else if(v())return;r[t++]=a}if(n!==null)for(l=t-n,t=7;t!==0&&l>0;)h=r[t],r[t--]=r[n+l-1],r[n+--l]=h;else if(t!==8)return;return r},tJ=function(e){for(var r=null,t=1,n=null,i=0,a=0;a<8;a++)e[a]!==0?(i>t&&(r=n,t=i),n=null,i=0):(n===null&&(n=a),++i);return i>t?n:r},Po=function(e){var r,t,n,i;if(typeof e=="number"){for(r=[],t=0;t<4;t++)qK(r,e%256),e=DK(e/256);return Do(r,".")}if(typeof e=="object"){for(r="",n=tJ(e),t=0;t<8;t++)i&&e[t]===0||(i&&(i=!1),n===t?(r+=t?":":"::",i=!0):(r+=jK(e[t],16),t<7&&(r+=":")));return"["+r+"]"}return e},tl={},i1=ag({},tl,{" ":1,'"':1,"<":1,">":1,"`":1}),a1=ag({},i1,{"#":1,"?":1,"{":1,"}":1}),hp=ag({},a1,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ua=function(e,r){var t=OK(e,0);return t>32&&t<127&&!Nh(r,e)?e:encodeURIComponent(e)},wc={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jo=function(e,r){var t;return e.length===2&&qn(r1,En(e,0))&&((t=En(e,1))===":"||!r&&t==="|")},cS=function(e){var r;return e.length>1&&jo(Go(e,0,2))&&(e.length===2||(r=En(e,2))==="/"||r==="\\"||r==="?"||r==="#")},rJ=function(e){return e==="."||Ol(e)==="%2e"},nJ=function(e){return e=Ol(e),e===".."||e==="%2e."||e===".%2e"||e==="%2e%2e"},vp={},lS={},mp={},fS={},dS={},gp={},pS={},hS={},Sc={},Cc={},yp={},bp={},_p={},wp={},vS={},Sp={},Es={},ni={},mS={},Wa={},ki={},sg=function(e,r,t){var n=Ri(e),i,a,s;if(r){if(a=this.parse(n),a)throw new Lh(a);this.searchParams=null}else{if(t!==void 0&&(i=new sg(t,!0)),a=this.parse(n,null,i),a)throw new Lh(a);s=LK(new NK),s.bindURL(this),this.searchParams=s}};sg.prototype={type:"URL",parse:function(e,r,t){var n=this,i=r||vp,a=0,s="",o=!1,u=!1,c=!1,l,h,v,m;for(e=Ri(e),r||(n.scheme="",n.username="",n.password="",n.host=null,n.port=null,n.path=[],n.query=null,n.fragment=null,n.cannotBeABaseURL=!1,e=dp(e,YK,""),e=dp(e,XK,"$1")),e=dp(e,QK,""),l=Ts(e);a<=l.length;){switch(h=l[a],i){case vp:if(h&&qn(r1,h))s+=Ol(h),i=lS;else{if(r)return pp;i=mp;continue}break;case lS:if(h&&(qn(WK,h)||h==="+"||h==="-"||h==="."))s+=Ol(h);else if(h===":"){if(r&&(n.isSpecial()!==Nh(wc,s)||s==="file"&&(n.includesCredentials()||n.port!==null)||n.scheme==="file"&&!n.host))return;if(n.scheme=s,r){n.isSpecial()&&wc[n.scheme]===n.port&&(n.port=null);return}s="",n.scheme==="file"?i=wp:n.isSpecial()&&t&&t.scheme===n.scheme?i=fS:n.isSpecial()?i=hS:l[a+1]==="/"?(i=dS,a++):(n.cannotBeABaseURL=!0,$s(n.path,""),i=mS)}else{if(r)return pp;s="",i=mp,a=0;continue}break;case mp:if(!t||t.cannotBeABaseURL&&h!=="#")return pp;if(t.cannotBeABaseURL&&h==="#"){n.scheme=t.scheme,n.path=Ln(t.path),n.query=t.query,n.fragment="",n.cannotBeABaseURL=!0,i=ki;break}i=t.scheme==="file"?wp:gp;continue;case fS:if(h==="/"&&l[a+1]==="/")i=Sc,a++;else{i=gp;continue}break;case dS:if(h==="/"){i=Cc;break}else{i=ni;continue}case gp:if(n.scheme=t.scheme,h===wn)n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.query=t.query;else if(h==="/"||h==="\\"&&n.isSpecial())i=pS;else if(h==="?")n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.query="",i=Wa;else if(h==="#")n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.query=t.query,n.fragment="",i=ki;else{n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,n.path=Ln(t.path),n.path.length--,i=ni;continue}break;case pS:if(n.isSpecial()&&(h==="/"||h==="\\"))i=Sc;else if(h==="/")i=Cc;else{n.username=t.username,n.password=t.password,n.host=t.host,n.port=t.port,i=ni;continue}break;case hS:if(i=Sc,h!=="/"||En(s,a+1)!=="/")continue;a++;break;case Sc:if(h!=="/"&&h!=="\\"){i=Cc;continue}break;case Cc:if(h==="@"){o&&(s="%40"+s),o=!0,v=Ts(s);for(var _=0;_<v.length;_++){var C=v[_];if(C===":"&&!c){c=!0;continue}var I=ua(C,hp);c?n.password+=I:n.username+=I}s=""}else if(h===wn||h==="/"||h==="?"||h==="#"||h==="\\"&&n.isSpecial()){if(o&&s==="")return zK;a-=Ts(s).length+1,s="",i=yp}else s+=h;break;case yp:case bp:if(r&&n.scheme==="file"){i=Sp;continue}else if(h===":"&&!u){if(s==="")return za;if(m=n.parseHost(s),m)return m;if(s="",i=_p,r===bp)return}else if(h===wn||h==="/"||h==="?"||h==="#"||h==="\\"&&n.isSpecial()){if(n.isSpecial()&&s==="")return za;if(r&&s===""&&(n.includesCredentials()||n.port!==null))return;if(m=n.parseHost(s),m)return m;if(s="",i=Es,r)return;continue}else h==="["?u=!0:h==="]"&&(u=!1),s+=h;break;case _p:if(qn(Dh,h))s+=h;else if(h===wn||h==="/"||h==="?"||h==="#"||h==="\\"&&n.isSpecial()||r){if(s!==""){var $=Il(s,10);if($>65535)return uS;n.port=n.isSpecial()&&$===wc[n.scheme]?null:$,s=""}if(r)return;i=Es;continue}else return uS;break;case wp:if(n.scheme="file",h==="/"||h==="\\")i=vS;else if(t&&t.scheme==="file")switch(h){case wn:n.host=t.host,n.path=Ln(t.path),n.query=t.query;break;case"?":n.host=t.host,n.path=Ln(t.path),n.query="",i=Wa;break;case"#":n.host=t.host,n.path=Ln(t.path),n.query=t.query,n.fragment="",i=ki;break;default:cS(Do(Ln(l,a),""))||(n.host=t.host,n.path=Ln(t.path),n.shortenPath()),i=ni;continue}else{i=ni;continue}break;case vS:if(h==="/"||h==="\\"){i=Sp;break}t&&t.scheme==="file"&&!cS(Do(Ln(l,a),""))&&(jo(t.path[0],!0)?$s(n.path,t.path[0]):n.host=t.host),i=ni;continue;case Sp:if(h===wn||h==="/"||h==="\\"||h==="?"||h==="#"){if(!r&&jo(s))i=ni;else if(s===""){if(n.host="",r)return;i=Es}else{if(m=n.parseHost(s),m)return m;if(n.host==="localhost"&&(n.host=""),r)return;s="",i=Es}continue}else s+=h;break;case Es:if(n.isSpecial()){if(i=ni,h!=="/"&&h!=="\\")continue}else if(!r&&h==="?")n.query="",i=Wa;else if(!r&&h==="#")n.fragment="",i=ki;else if(h!==wn&&(i=ni,h!=="/"))continue;break;case ni:if(h===wn||h==="/"||h==="\\"&&n.isSpecial()||!r&&(h==="?"||h==="#")){if(nJ(s)?(n.shortenPath(),h!=="/"&&!(h==="\\"&&n.isSpecial())&&$s(n.path,"")):rJ(s)?h!=="/"&&!(h==="\\"&&n.isSpecial())&&$s(n.path,""):(n.scheme==="file"&&!n.path.length&&jo(s)&&(n.host&&(n.host=""),s=En(s,0)+":"),$s(n.path,s)),s="",n.scheme==="file"&&(h===wn||h==="?"||h==="#"))for(;n.path.length>1&&n.path[0]==="";)UK(n.path);h==="?"?(n.query="",i=Wa):h==="#"&&(n.fragment="",i=ki)}else s+=ua(h,a1);break;case mS:h==="?"?(n.query="",i=Wa):h==="#"?(n.fragment="",i=ki):h!==wn&&(n.path[0]+=ua(h,tl));break;case Wa:!r&&h==="#"?(n.fragment="",i=ki):h!==wn&&(h==="'"&&n.isSpecial()?n.query+="%27":h==="#"?n.query+="%23":n.query+=ua(h,tl));break;case ki:h!==wn&&(n.fragment+=ua(h,i1));break}a++}},parseHost:function(e){var r,t,n;if(En(e,0)==="["){if(En(e,e.length-1)!=="]"||(r=eJ(Go(e,1,-1)),!r))return za;this.host=r}else if(this.isSpecial()){if(e=PK(e),qn(KK,e)||(r=ZK(e),r===null))return za;this.host=r}else{if(qn(JK,e))return za;for(r="",t=Ts(e),n=0;n<t.length;n++)r+=ua(t[n],tl);this.host=r}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme==="file"},includesCredentials:function(){return this.username!==""||this.password!==""},isSpecial:function(){return Nh(wc,this.scheme)},shortenPath:function(){var e=this.path,r=e.length;r&&(this.scheme!=="file"||r!==1||!jo(e[0],!0))&&e.length--},serialize:function(){var e=this,r=e.scheme,t=e.username,n=e.password,i=e.host,a=e.port,s=e.path,o=e.query,u=e.fragment,c=r+":";return i!==null?(c+="//",e.includesCredentials()&&(c+=t+(n?":"+n:"")+"@"),c+=Po(i),a!==null&&(c+=":"+a)):r==="file"&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+Do(s,"/"):"",o!==null&&(c+="?"+o),u!==null&&(c+="#"+u),c},setHref:function(e){var r=this.parse(e);if(r)throw new Lh(r);this.searchParams.update()},getOrigin:function(){var e=this.scheme,r=this.port;if(e==="blob")try{return new Zs(e.path[0]).origin}catch{return"null"}return e==="file"||!this.isSpecial()?"null":e+"://"+Po(this.host)+(r!==null?":"+r:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Ri(e)+":",vp)},getUsername:function(){return this.username},setUsername:function(e){var r=Ts(Ri(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var t=0;t<r.length;t++)this.username+=ua(r[t],hp)}},getPassword:function(){return this.password},setPassword:function(e){var r=Ts(Ri(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var t=0;t<r.length;t++)this.password+=ua(r[t],hp)}},getHost:function(){var e=this.host,r=this.port;return e===null?"":r===null?Po(e):Po(e)+":"+r},setHost:function(e){this.cannotBeABaseURL||this.parse(e,yp)},getHostname:function(){var e=this.host;return e===null?"":Po(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,bp)},getPort:function(){var e=this.port;return e===null?"":Ri(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(e=Ri(e),e===""?this.port=null:this.parse(e,_p))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+Do(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Es))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){e=Ri(e),e===""?this.query=null:(En(e,0)==="?"&&(e=Go(e,1)),this.query="",this.parse(e,Wa)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){if(e=Ri(e),e===""){this.fragment=null;return}En(e,0)==="#"&&(e=Go(e,1)),this.fragment="",this.parse(e,ki)},update:function(){this.query=this.searchParams.serialize()||null}};var Zs=function(r){var t=IK(this,Lr),n=MK(arguments.length,1)>1?arguments[1]:void 0,i=xK(t,new sg(r,!1,n));ng||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},Lr=Zs.prototype,Sn=function(e,r){return{get:function(){return $l(this)[e]()},set:r&&function(t){return $l(this)[r](t)},configurable:!0,enumerable:!0}};ng&&(_n(Lr,"href",Sn("serialize","setHref")),_n(Lr,"origin",Sn("getOrigin")),_n(Lr,"protocol",Sn("getProtocol","setProtocol")),_n(Lr,"username",Sn("getUsername","setUsername")),_n(Lr,"password",Sn("getPassword","setPassword")),_n(Lr,"host",Sn("getHost","setHost")),_n(Lr,"hostname",Sn("getHostname","setHostname")),_n(Lr,"port",Sn("getPort","setPort")),_n(Lr,"pathname",Sn("getPathname","setPathname")),_n(Lr,"search",Sn("getSearch","setSearch")),_n(Lr,"searchParams",Sn("getSearchParams")),_n(Lr,"hash",Sn("getHash","setHash")));Rl(Lr,"toJSON",function(){return $l(this).serialize()},{enumerable:!0});Rl(Lr,"toString",function(){return $l(this).serialize()},{enumerable:!0});if(Oo){var gS=Oo.createObjectURL,yS=Oo.revokeObjectURL;gS&&Rl(Zs,"createObjectURL",sS(gS,Oo)),yS&&Rl(Zs,"revokeObjectURL",sS(yS,Oo))}AK(Zs,"URL");RK({global:!0,constructor:!0,forced:!$K,sham:!ng},{URL:Zs});/*
302
302
  @license
303
303
  Copyright (c) 2018, Twilio, Inc.
304
304
 
@@ -314,9 +314,9 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
314
314
  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
315
315
  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
316
316
 
317
- */(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=gi,n=Ea,i=vi,a=mi,s=Pn,o=mf,u=us,c=yu,l=Cu,h=On,v=gr,m=Ji,_=kr;function C(Z){return Z&&typeof Z=="object"&&"default"in Z?Z:{default:Z}}function I(Z){if(Z&&Z.__esModule)return Z;var ce=Object.create(null);return Z&&Object.keys(Z).forEach(function(H){if(H!=="default"){var ie=Object.getOwnPropertyDescriptor(Z,H);Object.defineProperty(ce,H,ie.get?ie:{enumerable:!0,get:function(){return Z[H]}})}}),ce.default=Z,Object.freeze(ce)}var $=C(t),x=C(n),N=C(i),q=C(a),X=C(s),J=C(o),G=C(u),L=C(c),te=C(l),se=C(h),ne=I(v),ge={exports:{}},Y=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(Y){var Ue=new Uint8Array(16);ge.exports=function(){return Y(Ue),Ue}}else{var He=new Array(16);ge.exports=function(){for(var ce=0,H;ce<16;ce++)ce&3||(H=Math.random()*4294967296),He[ce]=H>>>((ce&3)<<3)&255;return He}}for(var Rt=[],ft=0;ft<256;++ft)Rt[ft]=(ft+256).toString(16).substr(1);function Pe(Z,ce){var H=ce||0,ie=Rt;return[ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]]].join("")}var he=Pe,pe=ge.exports,M=he,Oe,Je,De=0,we=0;function Q(Z,ce,H){var ie=ce&&H||0,K=ce||[];Z=Z||{};var xe=Z.node||Oe,Ce=Z.clockseq!==void 0?Z.clockseq:Je;if(xe==null||Ce==null){var We=pe();xe==null&&(xe=Oe=[We[0]|1,We[1],We[2],We[3],We[4],We[5]]),Ce==null&&(Ce=Je=(We[6]<<8|We[7])&16383)}var Be=Z.msecs!==void 0?Z.msecs:new Date().getTime(),Ve=Z.nsecs!==void 0?Z.nsecs:we+1,Ye=Be-De+(Ve-we)/1e4;if(Ye<0&&Z.clockseq===void 0&&(Ce=Ce+1&16383),(Ye<0||Be>De)&&Z.nsecs===void 0&&(Ve=0),Ve>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");De=Be,we=Ve,Je=Ce,Be+=122192928e5;var Qe=((Be&268435455)*1e4+Ve)%4294967296;K[ie++]=Qe>>>24&255,K[ie++]=Qe>>>16&255,K[ie++]=Qe>>>8&255,K[ie++]=Qe&255;var Ke=Be/4294967296*1e4&268435455;K[ie++]=Ke>>>8&255,K[ie++]=Ke&255,K[ie++]=Ke>>>24&15|16,K[ie++]=Ke>>>16&255,K[ie++]=Ce>>>8|128,K[ie++]=Ce&255;for(var Xe=0;Xe<6;++Xe)K[ie+Xe]=xe[Xe];return ce||M(K)}var $t=Q,_e=ge.exports,le=he;function St(Z,ce,H){var ie=ce&&H||0;typeof Z=="string"&&(ce=Z==="binary"?new Array(16):null,Z=null),Z=Z||{};var K=Z.random||(Z.rng||_e)();if(K[6]=K[6]&15|64,K[8]=K[8]&63|128,ce)for(var xe=0;xe<16;++xe)ce[ie+xe]=K[xe];return ce||le(K)}var Le=St,Gt=$t,pt=Le,ke=pt;ke.v1=Gt,ke.v4=pt;var ot=ke;function bt(Z){var ce=$e();return function(){var ie=X.default(Z),K;if(ce){var xe=X.default(this).constructor;K=Reflect.construct(ie,arguments,xe)}else K=ie.apply(this,arguments);return q.default(this,K)}}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 Kt=function(Z){N.default(H,Z);var ce=bt(H);function H(ie){var K;$.default(this,H);var xe=ot.v4(),Ce;return K=ce.call(this,function(We,Be){return Ce=Be,ie(function(Ve){H.cancellationMap.delete(xe),We(Ve)},function(Ve){H.cancellationMap.delete(xe),Be(Ve)},function(Ve){H.cancellationMap.set(xe,Ve)})}),K.id=xe,K.rejectPromise=Ce,K}return x.default(H,[{key:"cancel",value:function(){var K=H.cancellationMap.get(this.id);return K==null||K(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),H}(J.default(Promise));G.default(Kt,"cancellationMap",new Map);function dt(Z,ce,H,ie){var K=arguments.length,xe=K<3?ce:ie===null?ie=Object.getOwnPropertyDescriptor(ce,H):ie,Ce;if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")xe=Reflect.decorate(Z,ce,H,ie);else for(var We=Z.length-1;We>=0;We--)(Ce=Z[We])&&(xe=(K<3?Ce(xe):K>3?Ce(ce,H,xe):Ce(ce,H))||xe);return K>3&&xe&&Object.defineProperty(ce,H,xe),xe}function qt(Z,ce){if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Z,ce)}function rr(Z,ce){return["".concat(new Date().toISOString()," MCS Client ").concat(Z,":")].concat(Array.from(ce))}var Fe=function(){function Z(ce){$.default(this,Z),G.default(this,"prefix",""),this.prefix=ce!=null&&ce.length>0?ce+" ":""}return x.default(Z,[{key:"setLevel",value:function(H){ne.setLevel(H)}},{key:"trace",value:function(){if(ne.getLevel()==ne.levels.TRACE){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr(this.prefix+"T",ie))}}},{key:"debug",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr(this.prefix+"D",ie))}},{key:"info",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.info.apply(null,rr(this.prefix+"I",ie))}},{key:"warn",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.warn.apply(null,rr(this.prefix+"W",ie))}},{key:"error",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.error.apply(null,rr(this.prefix+"E",ie))}}],[{key:"scope",value:function(H){return new Z(H)}},{key:"setLevel",value:function(H){ne.setLevel(H)}},{key:"trace",value:function(){if(ne.getLevel()==ne.levels.TRACE){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr("T",ie))}}},{key:"debug",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr("D",ie))}},{key:"info",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.info.apply(null,rr("I",ie))}},{key:"warn",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.warn.apply(null,rr("W",ie))}},{key:"error",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.error.apply(null,rr("E",ie))}}]),Z}(),Ar=1e3,Rr=4e3,Ct=3,Pt=!0,yt=function(ce){return"https://mcs.".concat(ce??"us1",".twilio.com")},it=function(ce){return ce.startsWith("http")},Mt=function(ce,H){return"".concat(it(ce)?"":yt(H)).concat(ce)},It=function(){function Z(ce,H,ie,K){var xe,Ce,We,Be,Ve,Ye;$.default(this,Z);var Qe=(xe=(Ce=K.MCS)!==null&&Ce!==void 0?Ce:K)!==null&&xe!==void 0?xe:{};this.region=(We=(Be=Qe.region)!==null&&Be!==void 0?Be:K.region)!==null&&We!==void 0?We:"us1",this.mediaUrl=Mt(H,this.region),this.mediaSetUrl=ie?Mt(ie):"".concat(this.mediaUrl,"Set"),this.token=ce,this.retryWhenThrottledOverride=(Ve=Qe.retryWhenThrottledOverride)!==null&&Ve!==void 0?Ve:Pt,this.backoffConfigOverride=(Ye=Qe.backoffConfigOverride)!==null&&Ye!==void 0?Ye:Z.backoffConfigDefault}return x.default(Z,[{key:"updateToken",value:function(H){this.token=H}}],[{key:"backoffConfigDefault",get:function(){return{min:Ar,max:Rr,maxAttemptsCount:Ct}}},{key:"retryWhenThrottledDefault",get:function(){return Pt}}]),Z}(),sr=function(){function Z(ce,H,ie){$.default(this,Z),this.config=ce,this.network=H,this._update(ie)}return x.default(Z,[{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 H=this;return new Kt(function(){var ie=L.default(te.default.mark(function K(xe,Ce,We){var Be,Ve;return te.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Be=H.network.get("".concat(H.config.mediaUrl,"/").concat(H.sid)),We(function(){return Be.cancel()}),Qe.prev=2,Qe.next=5,Be;case 5:Ve=Qe.sent,H._update(Ve.body),xe(H.state.contentDirectUrl),Qe.next=13;break;case 10:Qe.prev=10,Qe.t0=Qe.catch(2),Ce(Qe.t0);case 13:case"end":return Qe.stop()}},K,null,[[2,10]])}));return function(K,xe,Ce){return ie.apply(this,arguments)}}())}},{key:"_update",value:function(H){var ie,K,xe,Ce;this.state={sid:H.sid,serviceSid:H.service_sid,channelSid:H.channel_sid,messageSid:H.message_sid,dateCreated:H.date_created?new Date(H.date_created):null,dateUploadUpdated:H.date_upload_updated?new Date(H.date_upload_updated):null,dateUpdated:H.date_updated?new Date(H.date_updated):null,size:H.size,contentType:H.content_type,author:H.author,url:H.url,contentUrl:H.links.content,contentDirectUrl:(ie=H.links.content_direct_temporary)!==null&&ie!==void 0?ie:null,filename:(K=H.filename)!==null&&K!==void 0?K:null,category:(xe=H.category)!==null&&xe!==void 0?xe:"media",isMultipartUpstream:(Ce=H.is_multipart_upstream)!==null&&Ce!==void 0?Ce:!1}}},{key:"_state",value:function(){var H;return{sid:this.state.sid,category:this.state.category,filename:(H=this.state.filename)!==null&&H!==void 0?H:null,contentType:this.state.contentType,size:this.state.size}}}]),Z}();function Nr(Z){var ce=tn();return function(){var ie=X.default(Z),K;if(ce){var xe=X.default(this).constructor;K=Reflect.construct(ie,arguments,xe)}else K=ie.apply(this,arguments);return q.default(this,K)}}function tn(){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(Z){N.default(H,Z);var ce=Nr(H);function H(ie,K,xe,Ce,We){var Be;return $.default(this,H),Be=ce.call(this,ie),Be.code=K,Be.body=xe,Be.status=Ce,Be.headers=We,Be}return x.default(H)}(J.default(Error)),Qt=r.XMLHttpRequest||{};function lr(Z){return Z?Z.split(`\r
317
+ */(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=gi,n=Ea,i=vi,a=mi,s=Pn,o=mf,u=us,c=yu,l=Cu,h=On,v=gr,m=Ji,_=Rr;function C(Z){return Z&&typeof Z=="object"&&"default"in Z?Z:{default:Z}}function I(Z){if(Z&&Z.__esModule)return Z;var ce=Object.create(null);return Z&&Object.keys(Z).forEach(function(H){if(H!=="default"){var ie=Object.getOwnPropertyDescriptor(Z,H);Object.defineProperty(ce,H,ie.get?ie:{enumerable:!0,get:function(){return Z[H]}})}}),ce.default=Z,Object.freeze(ce)}var $=C(t),x=C(n),N=C(i),q=C(a),X=C(s),J=C(o),G=C(u),L=C(c),te=C(l),se=C(h),ne=I(v),ge={exports:{}},Y=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(Y){var Ue=new Uint8Array(16);ge.exports=function(){return Y(Ue),Ue}}else{var He=new Array(16);ge.exports=function(){for(var ce=0,H;ce<16;ce++)ce&3||(H=Math.random()*4294967296),He[ce]=H>>>((ce&3)<<3)&255;return He}}for(var Rt=[],ft=0;ft<256;++ft)Rt[ft]=(ft+256).toString(16).substr(1);function Pe(Z,ce){var H=ce||0,ie=Rt;return[ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],"-",ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]],ie[Z[H++]]].join("")}var he=Pe,pe=ge.exports,M=he,Oe,Je,De=0,we=0;function Q(Z,ce,H){var ie=ce&&H||0,K=ce||[];Z=Z||{};var xe=Z.node||Oe,Ce=Z.clockseq!==void 0?Z.clockseq:Je;if(xe==null||Ce==null){var We=pe();xe==null&&(xe=Oe=[We[0]|1,We[1],We[2],We[3],We[4],We[5]]),Ce==null&&(Ce=Je=(We[6]<<8|We[7])&16383)}var Be=Z.msecs!==void 0?Z.msecs:new Date().getTime(),Ve=Z.nsecs!==void 0?Z.nsecs:we+1,Ye=Be-De+(Ve-we)/1e4;if(Ye<0&&Z.clockseq===void 0&&(Ce=Ce+1&16383),(Ye<0||Be>De)&&Z.nsecs===void 0&&(Ve=0),Ve>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");De=Be,we=Ve,Je=Ce,Be+=122192928e5;var Qe=((Be&268435455)*1e4+Ve)%4294967296;K[ie++]=Qe>>>24&255,K[ie++]=Qe>>>16&255,K[ie++]=Qe>>>8&255,K[ie++]=Qe&255;var Ke=Be/4294967296*1e4&268435455;K[ie++]=Ke>>>8&255,K[ie++]=Ke&255,K[ie++]=Ke>>>24&15|16,K[ie++]=Ke>>>16&255,K[ie++]=Ce>>>8|128,K[ie++]=Ce&255;for(var Xe=0;Xe<6;++Xe)K[ie+Xe]=xe[Xe];return ce||M(K)}var $t=Q,_e=ge.exports,le=he;function St(Z,ce,H){var ie=ce&&H||0;typeof Z=="string"&&(ce=Z==="binary"?new Array(16):null,Z=null),Z=Z||{};var K=Z.random||(Z.rng||_e)();if(K[6]=K[6]&15|64,K[8]=K[8]&63|128,ce)for(var xe=0;xe<16;++xe)ce[ie+xe]=K[xe];return ce||le(K)}var Le=St,Gt=$t,pt=Le,ke=pt;ke.v1=Gt,ke.v4=pt;var ot=ke;function bt(Z){var ce=$e();return function(){var ie=X.default(Z),K;if(ce){var xe=X.default(this).constructor;K=Reflect.construct(ie,arguments,xe)}else K=ie.apply(this,arguments);return q.default(this,K)}}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 Kt=function(Z){N.default(H,Z);var ce=bt(H);function H(ie){var K;$.default(this,H);var xe=ot.v4(),Ce;return K=ce.call(this,function(We,Be){return Ce=Be,ie(function(Ve){H.cancellationMap.delete(xe),We(Ve)},function(Ve){H.cancellationMap.delete(xe),Be(Ve)},function(Ve){H.cancellationMap.set(xe,Ve)})}),K.id=xe,K.rejectPromise=Ce,K}return x.default(H,[{key:"cancel",value:function(){var K=H.cancellationMap.get(this.id);return K==null||K(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),H}(J.default(Promise));G.default(Kt,"cancellationMap",new Map);function dt(Z,ce,H,ie){var K=arguments.length,xe=K<3?ce:ie===null?ie=Object.getOwnPropertyDescriptor(ce,H):ie,Ce;if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")xe=Reflect.decorate(Z,ce,H,ie);else for(var We=Z.length-1;We>=0;We--)(Ce=Z[We])&&(xe=(K<3?Ce(xe):K>3?Ce(ce,H,xe):Ce(ce,H))||xe);return K>3&&xe&&Object.defineProperty(ce,H,xe),xe}function qt(Z,ce){if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Z,ce)}function rr(Z,ce){return["".concat(new Date().toISOString()," MCS Client ").concat(Z,":")].concat(Array.from(ce))}var Fe=function(){function Z(ce){$.default(this,Z),G.default(this,"prefix",""),this.prefix=ce!=null&&ce.length>0?ce+" ":""}return x.default(Z,[{key:"setLevel",value:function(H){ne.setLevel(H)}},{key:"trace",value:function(){if(ne.getLevel()==ne.levels.TRACE){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr(this.prefix+"T",ie))}}},{key:"debug",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr(this.prefix+"D",ie))}},{key:"info",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.info.apply(null,rr(this.prefix+"I",ie))}},{key:"warn",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.warn.apply(null,rr(this.prefix+"W",ie))}},{key:"error",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.error.apply(null,rr(this.prefix+"E",ie))}}],[{key:"scope",value:function(H){return new Z(H)}},{key:"setLevel",value:function(H){ne.setLevel(H)}},{key:"trace",value:function(){if(ne.getLevel()==ne.levels.TRACE){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr("T",ie))}}},{key:"debug",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.debug.apply(null,rr("D",ie))}},{key:"info",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.info.apply(null,rr("I",ie))}},{key:"warn",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.warn.apply(null,rr("W",ie))}},{key:"error",value:function(){for(var H=arguments.length,ie=new Array(H),K=0;K<H;K++)ie[K]=arguments[K];ne.error.apply(null,rr("E",ie))}}]),Z}(),Ar=1e3,$r=4e3,Ct=3,Pt=!0,yt=function(ce){return"https://mcs.".concat(ce??"us1",".twilio.com")},it=function(ce){return ce.startsWith("http")},Mt=function(ce,H){return"".concat(it(ce)?"":yt(H)).concat(ce)},It=function(){function Z(ce,H,ie,K){var xe,Ce,We,Be,Ve,Ye;$.default(this,Z);var Qe=(xe=(Ce=K.MCS)!==null&&Ce!==void 0?Ce:K)!==null&&xe!==void 0?xe:{};this.region=(We=(Be=Qe.region)!==null&&Be!==void 0?Be:K.region)!==null&&We!==void 0?We:"us1",this.mediaUrl=Mt(H,this.region),this.mediaSetUrl=ie?Mt(ie):"".concat(this.mediaUrl,"Set"),this.token=ce,this.retryWhenThrottledOverride=(Ve=Qe.retryWhenThrottledOverride)!==null&&Ve!==void 0?Ve:Pt,this.backoffConfigOverride=(Ye=Qe.backoffConfigOverride)!==null&&Ye!==void 0?Ye:Z.backoffConfigDefault}return x.default(Z,[{key:"updateToken",value:function(H){this.token=H}}],[{key:"backoffConfigDefault",get:function(){return{min:Ar,max:$r,maxAttemptsCount:Ct}}},{key:"retryWhenThrottledDefault",get:function(){return Pt}}]),Z}(),sr=function(){function Z(ce,H,ie){$.default(this,Z),this.config=ce,this.network=H,this._update(ie)}return x.default(Z,[{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 H=this;return new Kt(function(){var ie=L.default(te.default.mark(function K(xe,Ce,We){var Be,Ve;return te.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Be=H.network.get("".concat(H.config.mediaUrl,"/").concat(H.sid)),We(function(){return Be.cancel()}),Qe.prev=2,Qe.next=5,Be;case 5:Ve=Qe.sent,H._update(Ve.body),xe(H.state.contentDirectUrl),Qe.next=13;break;case 10:Qe.prev=10,Qe.t0=Qe.catch(2),Ce(Qe.t0);case 13:case"end":return Qe.stop()}},K,null,[[2,10]])}));return function(K,xe,Ce){return ie.apply(this,arguments)}}())}},{key:"_update",value:function(H){var ie,K,xe,Ce;this.state={sid:H.sid,serviceSid:H.service_sid,channelSid:H.channel_sid,messageSid:H.message_sid,dateCreated:H.date_created?new Date(H.date_created):null,dateUploadUpdated:H.date_upload_updated?new Date(H.date_upload_updated):null,dateUpdated:H.date_updated?new Date(H.date_updated):null,size:H.size,contentType:H.content_type,author:H.author,url:H.url,contentUrl:H.links.content,contentDirectUrl:(ie=H.links.content_direct_temporary)!==null&&ie!==void 0?ie:null,filename:(K=H.filename)!==null&&K!==void 0?K:null,category:(xe=H.category)!==null&&xe!==void 0?xe:"media",isMultipartUpstream:(Ce=H.is_multipart_upstream)!==null&&Ce!==void 0?Ce:!1}}},{key:"_state",value:function(){var H;return{sid:this.state.sid,category:this.state.category,filename:(H=this.state.filename)!==null&&H!==void 0?H:null,contentType:this.state.contentType,size:this.state.size}}}]),Z}();function Nr(Z){var ce=tn();return function(){var ie=X.default(Z),K;if(ce){var xe=X.default(this).constructor;K=Reflect.construct(ie,arguments,xe)}else K=ie.apply(this,arguments);return q.default(this,K)}}function tn(){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(Z){N.default(H,Z);var ce=Nr(H);function H(ie,K,xe,Ce,We){var Be;return $.default(this,H),Be=ce.call(this,ie),Be.code=K,Be.body=xe,Be.status=Ce,Be.headers=We,Be}return x.default(H)}(J.default(Error)),Qt=r.XMLHttpRequest||{};function lr(Z){return Z?Z.split(`\r
318
318
  `).map(function(ce){return ce.split(": ")}).filter(function(ce){return ce.length===2&&ce[1].length>0}).reduce(function(ce,H){return ce[H[0]]=H[1],ce},{}):{}}function ve(Z){var ce=Z.getResponseHeader("Content-Type");if(!ce||ce.indexOf("application/json")!==0||Z.responseText.length===0)return Z.responseText;try{return JSON.parse(Z.responseText)}catch{return Z.responseText}}var ye=function(){function Z(){$.default(this,Z)}return x.default(Z,[{key:"get",value:function(H,ie){return Z.request("GET",H,ie)}},{key:"post",value:function(H,ie,K){return Z.request("POST",H,ie,K)}}],[{key:"request",value:function(H,ie,K,xe){return new Kt(function(Ce,We,Be){var Ve=new Qt,Ye=!1;Be(function(){Ve.abort(),Ye=!0}),Ve.open(H,ie,!0),Ve.onreadystatechange=function(){if(!(Ve.readyState!==4||Ye)){var Xe=lr(Ve.getAllResponseHeaders()),Ze=ve(Ve);if(200<=Ve.status&&Ve.status<300)Ce({status:Ve.status,headers:Xe,body:Ze});else{var at,yr=(at=Ve.statusText)!==null&&at!==void 0?at:"NONE",or;if(typeof Ze=="string")if(Ze&&Ze.split(`
319
- `,2).length===1)or=Ze;else{var st,Wr=(st=Ze.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(bi){return bi.length})[0])===null||st===void 0?void 0:st.split(" ");or=(Wr==null?void 0:Wr.length)>2?Wr==null?void 0:Wr.slice(1).join(" "):""}else or=JSON.stringify(Ze);var mn="".concat(Ve.status,": [").concat(yr,"] ").concat(or);We(new rn(mn,Ve.status,Ze,yr,Xe))}}};for(var Qe in K)Ve.setRequestHeader(Qe,K[Qe]),Qe==="Content-Type"&&K[Qe]==="application/json"&&(xe=JSON.stringify(xe));Ve.send(xe)})}}]),Z}(),ae=Fe.scope("Network"),de=function(){function Z(ce,H){$.default(this,Z),this.config=ce,this.transport=H}return x.default(Z,[{key:"backoffConfig",value:function(){return Object.assign(It.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var H,ie;return(H=(ie=this.config.retryWhenThrottledOverride)!==null&&ie!==void 0?ie:It.retryWhenThrottledDefault)!==null&&H!==void 0?H:!1}},{key:"executeWithRetry",value:function(H,ie){var K=this;return new Kt(function(){var xe=L.default(te.default.mark(function Ce(We,Be,Ve){var Ye,Qe;return te.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:Ye=new m.Retrier(K.backoffConfig()),Qe=[502,503,504],ie&&Qe.push(429),Ve(function(){Ye.cancel(),Ye.removeAllListeners()}),Ye.on("attempt",L.default(te.default.mark(function Ze(){var at,yr;return te.default.wrap(function(st){for(;;)switch(st.prev=st.next){case 0:return st.prev=0,at=H(),Ve(function(){at.cancel(),Ye.cancel(),Ye.removeAllListeners()}),st.next=5,at;case 5:yr=st.sent,Ye.succeeded(yr),st.next=12;break;case 9:st.prev=9,st.t0=st.catch(0),Qe.indexOf(st.t0.status)>-1||st.t0.message==="Twilsock disconnected"?Ye.failed(st.t0):(Ye.removeAllListeners(),Ye.cancel(),Be(st.t0));case 12:case"end":return st.stop()}},Ze,null,[[0,9]])}))),Ye.on("succeeded",function(Ze){We(Ze)}),Ye.on("cancelled",function(Ze){return Be(Ze)}),Ye.on("failed",function(Ze){return Be(Ze)}),Ye.start();case 9:case"end":return Xe.stop()}},Ce)}));return function(Ce,We,Be){return xe.apply(this,arguments)}}())}},{key:"get",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye,Qe;return te.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return Ve={"X-Twilio-Token":ie.config.token},Ye=ie.executeWithRetry(function(){return ie.transport.get(H,Ve)},ie.retryWhenThrottled()),ae.trace("sending GET request to ",H," headers ",Ve),Be(function(){return Ye.cancel()}),Xe.prev=4,Xe.next=7,Ye;case 7:Qe=Xe.sent,ae.trace("response",Qe),Ce(Qe),Xe.next=16;break;case 12:Xe.prev=12,Xe.t0=Xe.catch(4),ae.debug("get() error ".concat(Xe.t0)),We(Xe.t0);case 16:case"end":return Xe.stop()}},xe,null,[[4,12]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}},{key:"post",value:function(H,ie,K,xe,Ce){var We=this,Be={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(K instanceof FormData))&&xe&&Object.assign(Be,{"Content-Type":xe});var Ve=new URL(H);return ie&&Ve.searchParams.append("Category",ie),Ce&&Ve.searchParams.append("Filename",Ce),new Kt(function(){var Ye=L.default(te.default.mark(function Qe(Ke,Xe,Ze){var at,yr;return te.default.wrap(function(st){for(;;)switch(st.prev=st.next){case 0:return at=We.transport.post(Ve.href,Be,K),Ze(function(){return at.cancel()}),ae.trace("sending POST request to ".concat(H," with headers ").concat(Be)),st.prev=3,st.next=6,at;case 6:yr=st.sent,st.next=17;break;case 9:if(st.prev=9,st.t0=st.catch(3),!(r.XMLHttpRequest===void 0&&K instanceof FormData)){st.next=14;break}return Xe(new TypeError("Posting FormData supported only with browser engine's FormData")),st.abrupt("return");case 14:return ae.debug("post() error ".concat(st.t0)),Xe(st.t0),st.abrupt("return");case 17:ae.trace("response",yr),Ke(yr);case 19:case"end":return st.stop()}},Qe,null,[[3,9]])}));return function(Qe,Ke,Xe){return Ye.apply(this,arguments)}}())}}]),Z}(),oe="0.6.8",me,Se=Fe.scope("");e.default=(me=function(){function Z(ce,H,ie){var K,xe,Ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};$.default(this,Z),this.options=Ce,this.options.logLevel=(K=this.options.logLevel)!==null&&K!==void 0?K:"silent",this.config=new It(ce,H,ie,this.options),Se.setLevel(this.options.logLevel),this.options.transport=(xe=this.options.transport)!==null&&xe!==void 0?xe:new ye,this.transport=this.options.transport,this.network=new de(this.config,this.transport)}return x.default(Z,[{key:"updateToken",value:function(H){Se.info("updateToken"),this.config.updateToken(H)}},{key:"get",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye;return te.default.wrap(function(Ke){for(;;)switch(Ke.prev=Ke.next){case 0:return Ve=ie.network.get("".concat(ie.config.mediaUrl,"/").concat(H)),Be(function(){return Ve.cancel()}),Ke.prev=2,Ke.next=5,Ve;case 5:Ye=Ke.sent,Ce(new sr(ie.config,ie.network,Ye.body)),Ke.next=12;break;case 9:Ke.prev=9,Ke.t0=Ke.catch(2),We(Ke.t0);case 12:case"end":return Ke.stop()}},xe,null,[[2,9]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}},{key:"post",value:function(H,ie,K,xe){var Ce=this;return new Kt(function(){var We=L.default(te.default.mark(function Be(Ve,Ye,Qe){var Ke,Xe;return te.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ke=Ce.network.post(Ce.config.mediaUrl,K??"media",ie,H,xe),Qe(function(){return Ke.cancel()}),at.prev=2,at.next=5,Ke;case 5:Xe=at.sent,Ve(new sr(Ce.config,Ce.network,Xe.body)),at.next=12;break;case 9:at.prev=9,at.t0=at.catch(2),Ye(at.t0);case 12:case"end":return at.stop()}},Be,null,[[2,9]])}));return function(Be,Ve,Ye){return We.apply(this,arguments)}}())}},{key:"postFormData",value:function(H,ie){var K=this;return new Kt(function(){var xe=L.default(te.default.mark(function Ce(We,Be,Ve){var Ye,Qe;return te.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return Ye=K.network.post(K.config.mediaUrl,ie??"media",H),Ve(function(){return Ye.cancel()}),Xe.prev=2,Xe.next=5,Ye;case 5:Qe=Xe.sent,We(new sr(K.config,K.network,Qe.body)),Xe.next=12;break;case 9:Xe.prev=9,Xe.t0=Xe.catch(2),Be(Xe.t0);case 12:case"end":return Xe.stop()}},Ce,null,[[2,9]])}));return function(Ce,We,Be){return xe.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye,Qe,Ke;return te.default.wrap(function(Ze){for(;;)switch(Ze.prev=Ze.next){case 0:return Ve={command:"get",list:H.map(function(at){return{media_sid:at}})},Ye=ie.network.post("".concat(ie.config.mediaSetUrl),null,Ve,"application/json"),Be(function(){return Ye.cancel()}),Ze.prev=3,Ze.next=6,Ye;case 6:Qe=Ze.sent,Ke=Qe.body.map(function(at){if(at.code!==200){We("Failed to obtain detailed information about Media items (failed SID ".concat(at.media_record.sid,")"));return}return new sr(ie.config,ie.network,at.media_record)}),Ce(Ke),Ze.next=14;break;case 11:Ze.prev=11,Ze.t0=Ze.catch(3),We(Ze.t0);case 14:case"end":return Ze.stop()}},xe,null,[[3,11]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye,Qe,Ke;return te.default.wrap(function(Ze){for(;;)switch(Ze.prev=Ze.next){case 0:return Ve={command:"get",list:H.map(function(at){return{media_sid:at}})},Ye=ie.network.post("".concat(ie.config.mediaSetUrl),null,Ve,"application/json"),Be(function(){return Ye.cancel()}),Ze.prev=3,Ze.next=6,Ye;case 6:Qe=Ze.sent,Ke=new Map,Qe.body.forEach(function(at){if(at.code!==200){We("Failed to obtain detailed information about Media items (failed SID ".concat(at.media_record.sid,")"));return}Ke.set(at.media_record.sid,at.media_record.links.content_direct_temporary)}),Ce(Ke),Ze.next=15;break;case 12:Ze.prev=12,Ze.t0=Ze.catch(3),We(Ze.t0);case 15:case"end":return Ze.stop()}},xe,null,[[3,12]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}}]),Z}(),G.default(me,"version",oe),me),dt([_.validateTypes(_.nonEmptyString),qt("design:type",Function),qt("design:paramtypes",[String]),qt("design:returntype",void 0)],e.default.prototype,"updateToken",null),dt([_.validateTypesAsync(_.nonEmptyString),qt("design:type",Function),qt("design:paramtypes",[String]),qt("design:returntype",Kt)],e.default.prototype,"get",null),e.default=dt([_.validateConstructorTypes(_.nonEmptyString,_.nonEmptyString,[_.nonEmptyString,_.literal(null)],[_.pureObject,"undefined"]),qt("design:paramtypes",[String,String,Object,Object])],e.default),e.CancellablePromise=Kt,e.Client=e.default,e.McsClient=e.default,e.McsMedia=sr,e.Media=sr})(NR);var a1=Vt,rJ=xr,nJ=fi,iJ=a1.aTypedArray,aJ=a1.exportTypedArrayMethod;aJ("at",function(r){var t=iJ(this),n=rJ(t),i=nJ(r),a=i>=0?i:n+i;return a<0||a>=n?void 0:t[a]});var sJ=gt,oJ=_t,uJ=dk,cJ=Wl,og="ArrayBuffer",yS=uJ[og],lJ=oJ[og];sJ({global:!0,constructor:!0,forced:lJ!==yS},{ArrayBuffer:yS});cJ(og);var fJ=gt,s1=vt,dJ=In,pJ=Mr,bS=xr,hJ=Nm,_S=wr,ug=lt,vJ=zm,mJ=zl,wS=Kk,gJ=Jk,SS=ro,CS=Yk,pa=[],TS=s1(pa.sort),yJ=s1(pa.push),bJ=ug(function(){pa.sort(void 0)}),_J=ug(function(){pa.sort(null)}),wJ=mJ("sort"),o1=!ug(function(){if(SS)return SS<70;if(!(wS&&wS>3)){if(gJ)return!0;if(CS)return CS<603;var e="",r,t,n,i;for(r=65;r<76;r++){switch(t=String.fromCharCode(r),r){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++)pa.push({k:t+i,v:n})}for(pa.sort(function(a,s){return s.v-a.v}),i=0;i<pa.length;i++)t=pa[i].k.charAt(0),e.charAt(e.length-1)!==t&&(e+=t);return e!=="DGBEFHACIJK"}}),SJ=bJ||!_J||!wJ||!o1,CJ=function(e){return function(r,t){return t===void 0?-1:r===void 0?1:e!==void 0?+e(r,t)||0:_S(r)>_S(t)?1:-1}};fJ({target:"Array",proto:!0,forced:SJ},{sort:function(r){r!==void 0&&dJ(r);var t=pJ(this);if(o1)return r===void 0?TS(t):TS(t,r);var n=[],i=bS(t),a,s;for(s=0;s<i;s++)s in t&&yJ(n,t[s]);for(vJ(n,CJ(r)),a=bS(n),s=0;s<a;)t[s]=n[s++];for(;s<i;)hJ(t,s++);return t}});var TJ=gt,EJ=vt,kJ=LR,RJ=Kn,ES=wr,$J=DR,IJ=EJ("".indexOf);TJ({target:"String",proto:!0,forced:!$J("includes")},{includes:function(r){return!!~IJ(ES(RJ(this)),ES(kJ(r)),arguments.length>1?arguments[1]:void 0)}});var OJ=vt,kS=uf,Tc=of.getWeakData,PJ=ka,AJ=ar,MJ=Hn,Cp=Jt,xJ=Su,u1=Zr,RS=tr,c1=pn,NJ=c1.set,LJ=c1.getterFor,DJ=u1.find,jJ=u1.findIndex,FJ=OJ([].splice),UJ=0,Ec=function(e){return e.frozen||(e.frozen=new l1)},l1=function(){this.entries=[]},Tp=function(e,r){return DJ(e.entries,function(t){return t[0]===r})};l1.prototype={get:function(e){var r=Tp(this,e);if(r)return r[1]},has:function(e){return!!Tp(this,e)},set:function(e,r){var t=Tp(this,e);t?t[1]=r:this.entries.push([e,r])},delete:function(e){var r=jJ(this.entries,function(t){return t[0]===e});return~r&&FJ(this.entries,r,1),!!~r}};var BJ={getConstructor:function(e,r,t,n){var i=e(function(u,c){PJ(u,a),NJ(u,{type:r,id:UJ++,frozen:null}),MJ(c)||xJ(c,u[n],{that:u,AS_ENTRIES:t})}),a=i.prototype,s=LJ(r),o=function(u,c,l){var h=s(u),v=Tc(AJ(c),!0);return v===!0?Ec(h).set(c,l):v[h.id]=l,u};return kS(a,{delete:function(u){var c=s(this);if(!Cp(u))return!1;var l=Tc(u);return l===!0?Ec(c).delete(u):l&&RS(l,c.id)&&delete l[c.id]},has:function(c){var l=s(this);if(!Cp(c))return!1;var h=Tc(c);return h===!0?Ec(l).has(c):h&&RS(h,l.id)}}),kS(a,t?{get:function(c){var l=s(this);if(Cp(c)){var h=Tc(c);if(h===!0)return Ec(l).get(c);if(h)return h[l.id]}},set:function(c,l){return o(this,c,l)}}:{add:function(c){return o(this,c,!0)}}),i}},qJ=wm,zJ=BJ;qJ("WeakSet",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},zJ);var bf={},f1={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(Ae,function(){var r=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(C,I){var $=C[I];if(typeof $.bind=="function")return $.bind(C);try{return Function.prototype.bind.call($,C)}catch{return function(){return Function.prototype.apply.apply($,[C,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(C){return C==="debug"&&(C="log"),typeof console===t?!1:C==="trace"&&n?s:console[C]!==void 0?a(console,C):console.log!==void 0?a(console,"log"):r}function u(C,I){for(var $=0;$<i.length;$++){var x=i[$];this[x]=$<C?r:this.methodFactory(x,C,I)}this.log=this.debug}function c(C,I,$){return function(){typeof console!==t&&(u.call(this,I,$),this[C].apply(this,arguments))}}function l(C,I,$){return o(C)||c.apply(this,arguments)}function h(C,I,$){var x=this,N;I=I??"WARN";var q="loglevel";typeof C=="string"?q+=":"+C:typeof C=="symbol"&&(q=void 0);function X(te){var se=(i[te]||"silent").toUpperCase();if(!(typeof window===t||!q)){try{window.localStorage[q]=se;return}catch{}try{window.document.cookie=encodeURIComponent(q)+"="+se+";"}catch{}}}function J(){var te;if(!(typeof window===t||!q)){try{te=window.localStorage[q]}catch{}if(typeof te===t)try{var se=window.document.cookie,ne=se.indexOf(encodeURIComponent(q)+"=");ne!==-1&&(te=/^([^;]+)/.exec(se.slice(ne))[1])}catch{}return x.levels[te]===void 0&&(te=void 0),te}}function G(){if(!(typeof window===t||!q)){try{window.localStorage.removeItem(q);return}catch{}try{window.document.cookie=encodeURIComponent(q)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}x.name=C,x.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},x.methodFactory=$||l,x.getLevel=function(){return N},x.setLevel=function(te,se){if(typeof te=="string"&&x.levels[te.toUpperCase()]!==void 0&&(te=x.levels[te.toUpperCase()]),typeof te=="number"&&te>=0&&te<=x.levels.SILENT){if(N=te,se!==!1&&X(te),u.call(x,te,C),typeof console===t&&te<x.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+te},x.setDefaultLevel=function(te){I=te,J()||x.setLevel(te,!1)},x.resetLevel=function(){x.setLevel(I,!1),G()},x.enableAll=function(te){x.setLevel(x.levels.TRACE,te)},x.disableAll=function(te){x.setLevel(x.levels.SILENT,te)};var L=J();L==null&&(L=I),x.setLevel(L,!1)}var v=new h,m={};v.getLogger=function(I){if(typeof I!="symbol"&&typeof I!="string"||I==="")throw new TypeError("You must supply a name when creating a logger.");var $=m[I];return $||($=m[I]=new h(I,v.getLevel(),v.methodFactory)),$};var _=typeof window!==t?window.log:void 0;return v.noConflict=function(){return typeof window!==t&&window.log===v&&(window.log=_),v},v.getLoggers=function(){return m},v.default=v,v})})(f1);var WJ=f1.exports;/*
319
+ `,2).length===1)or=Ze;else{var st,Wr=(st=Ze.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(bi){return bi.length})[0])===null||st===void 0?void 0:st.split(" ");or=(Wr==null?void 0:Wr.length)>2?Wr==null?void 0:Wr.slice(1).join(" "):""}else or=JSON.stringify(Ze);var mn="".concat(Ve.status,": [").concat(yr,"] ").concat(or);We(new rn(mn,Ve.status,Ze,yr,Xe))}}};for(var Qe in K)Ve.setRequestHeader(Qe,K[Qe]),Qe==="Content-Type"&&K[Qe]==="application/json"&&(xe=JSON.stringify(xe));Ve.send(xe)})}}]),Z}(),ae=Fe.scope("Network"),de=function(){function Z(ce,H){$.default(this,Z),this.config=ce,this.transport=H}return x.default(Z,[{key:"backoffConfig",value:function(){return Object.assign(It.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var H,ie;return(H=(ie=this.config.retryWhenThrottledOverride)!==null&&ie!==void 0?ie:It.retryWhenThrottledDefault)!==null&&H!==void 0?H:!1}},{key:"executeWithRetry",value:function(H,ie){var K=this;return new Kt(function(){var xe=L.default(te.default.mark(function Ce(We,Be,Ve){var Ye,Qe;return te.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:Ye=new m.Retrier(K.backoffConfig()),Qe=[502,503,504],ie&&Qe.push(429),Ve(function(){Ye.cancel(),Ye.removeAllListeners()}),Ye.on("attempt",L.default(te.default.mark(function Ze(){var at,yr;return te.default.wrap(function(st){for(;;)switch(st.prev=st.next){case 0:return st.prev=0,at=H(),Ve(function(){at.cancel(),Ye.cancel(),Ye.removeAllListeners()}),st.next=5,at;case 5:yr=st.sent,Ye.succeeded(yr),st.next=12;break;case 9:st.prev=9,st.t0=st.catch(0),Qe.indexOf(st.t0.status)>-1||st.t0.message==="Twilsock disconnected"?Ye.failed(st.t0):(Ye.removeAllListeners(),Ye.cancel(),Be(st.t0));case 12:case"end":return st.stop()}},Ze,null,[[0,9]])}))),Ye.on("succeeded",function(Ze){We(Ze)}),Ye.on("cancelled",function(Ze){return Be(Ze)}),Ye.on("failed",function(Ze){return Be(Ze)}),Ye.start();case 9:case"end":return Xe.stop()}},Ce)}));return function(Ce,We,Be){return xe.apply(this,arguments)}}())}},{key:"get",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye,Qe;return te.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return Ve={"X-Twilio-Token":ie.config.token},Ye=ie.executeWithRetry(function(){return ie.transport.get(H,Ve)},ie.retryWhenThrottled()),ae.trace("sending GET request to ",H," headers ",Ve),Be(function(){return Ye.cancel()}),Xe.prev=4,Xe.next=7,Ye;case 7:Qe=Xe.sent,ae.trace("response",Qe),Ce(Qe),Xe.next=16;break;case 12:Xe.prev=12,Xe.t0=Xe.catch(4),ae.debug("get() error ".concat(Xe.t0)),We(Xe.t0);case 16:case"end":return Xe.stop()}},xe,null,[[4,12]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}},{key:"post",value:function(H,ie,K,xe,Ce){var We=this,Be={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(K instanceof FormData))&&xe&&Object.assign(Be,{"Content-Type":xe});var Ve=new URL(H);return ie&&Ve.searchParams.append("Category",ie),Ce&&Ve.searchParams.append("Filename",Ce),new Kt(function(){var Ye=L.default(te.default.mark(function Qe(Ke,Xe,Ze){var at,yr;return te.default.wrap(function(st){for(;;)switch(st.prev=st.next){case 0:return at=We.transport.post(Ve.href,Be,K),Ze(function(){return at.cancel()}),ae.trace("sending POST request to ".concat(H," with headers ").concat(Be)),st.prev=3,st.next=6,at;case 6:yr=st.sent,st.next=17;break;case 9:if(st.prev=9,st.t0=st.catch(3),!(r.XMLHttpRequest===void 0&&K instanceof FormData)){st.next=14;break}return Xe(new TypeError("Posting FormData supported only with browser engine's FormData")),st.abrupt("return");case 14:return ae.debug("post() error ".concat(st.t0)),Xe(st.t0),st.abrupt("return");case 17:ae.trace("response",yr),Ke(yr);case 19:case"end":return st.stop()}},Qe,null,[[3,9]])}));return function(Qe,Ke,Xe){return Ye.apply(this,arguments)}}())}}]),Z}(),oe="0.6.8",me,Se=Fe.scope("");e.default=(me=function(){function Z(ce,H,ie){var K,xe,Ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};$.default(this,Z),this.options=Ce,this.options.logLevel=(K=this.options.logLevel)!==null&&K!==void 0?K:"silent",this.config=new It(ce,H,ie,this.options),Se.setLevel(this.options.logLevel),this.options.transport=(xe=this.options.transport)!==null&&xe!==void 0?xe:new ye,this.transport=this.options.transport,this.network=new de(this.config,this.transport)}return x.default(Z,[{key:"updateToken",value:function(H){Se.info("updateToken"),this.config.updateToken(H)}},{key:"get",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye;return te.default.wrap(function(Ke){for(;;)switch(Ke.prev=Ke.next){case 0:return Ve=ie.network.get("".concat(ie.config.mediaUrl,"/").concat(H)),Be(function(){return Ve.cancel()}),Ke.prev=2,Ke.next=5,Ve;case 5:Ye=Ke.sent,Ce(new sr(ie.config,ie.network,Ye.body)),Ke.next=12;break;case 9:Ke.prev=9,Ke.t0=Ke.catch(2),We(Ke.t0);case 12:case"end":return Ke.stop()}},xe,null,[[2,9]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}},{key:"post",value:function(H,ie,K,xe){var Ce=this;return new Kt(function(){var We=L.default(te.default.mark(function Be(Ve,Ye,Qe){var Ke,Xe;return te.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ke=Ce.network.post(Ce.config.mediaUrl,K??"media",ie,H,xe),Qe(function(){return Ke.cancel()}),at.prev=2,at.next=5,Ke;case 5:Xe=at.sent,Ve(new sr(Ce.config,Ce.network,Xe.body)),at.next=12;break;case 9:at.prev=9,at.t0=at.catch(2),Ye(at.t0);case 12:case"end":return at.stop()}},Be,null,[[2,9]])}));return function(Be,Ve,Ye){return We.apply(this,arguments)}}())}},{key:"postFormData",value:function(H,ie){var K=this;return new Kt(function(){var xe=L.default(te.default.mark(function Ce(We,Be,Ve){var Ye,Qe;return te.default.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return Ye=K.network.post(K.config.mediaUrl,ie??"media",H),Ve(function(){return Ye.cancel()}),Xe.prev=2,Xe.next=5,Ye;case 5:Qe=Xe.sent,We(new sr(K.config,K.network,Qe.body)),Xe.next=12;break;case 9:Xe.prev=9,Xe.t0=Xe.catch(2),Be(Xe.t0);case 12:case"end":return Xe.stop()}},Ce,null,[[2,9]])}));return function(Ce,We,Be){return xe.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye,Qe,Ke;return te.default.wrap(function(Ze){for(;;)switch(Ze.prev=Ze.next){case 0:return Ve={command:"get",list:H.map(function(at){return{media_sid:at}})},Ye=ie.network.post("".concat(ie.config.mediaSetUrl),null,Ve,"application/json"),Be(function(){return Ye.cancel()}),Ze.prev=3,Ze.next=6,Ye;case 6:Qe=Ze.sent,Ke=Qe.body.map(function(at){if(at.code!==200){We("Failed to obtain detailed information about Media items (failed SID ".concat(at.media_record.sid,")"));return}return new sr(ie.config,ie.network,at.media_record)}),Ce(Ke),Ze.next=14;break;case 11:Ze.prev=11,Ze.t0=Ze.catch(3),We(Ze.t0);case 14:case"end":return Ze.stop()}},xe,null,[[3,11]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(H){var ie=this;return new Kt(function(){var K=L.default(te.default.mark(function xe(Ce,We,Be){var Ve,Ye,Qe,Ke;return te.default.wrap(function(Ze){for(;;)switch(Ze.prev=Ze.next){case 0:return Ve={command:"get",list:H.map(function(at){return{media_sid:at}})},Ye=ie.network.post("".concat(ie.config.mediaSetUrl),null,Ve,"application/json"),Be(function(){return Ye.cancel()}),Ze.prev=3,Ze.next=6,Ye;case 6:Qe=Ze.sent,Ke=new Map,Qe.body.forEach(function(at){if(at.code!==200){We("Failed to obtain detailed information about Media items (failed SID ".concat(at.media_record.sid,")"));return}Ke.set(at.media_record.sid,at.media_record.links.content_direct_temporary)}),Ce(Ke),Ze.next=15;break;case 12:Ze.prev=12,Ze.t0=Ze.catch(3),We(Ze.t0);case 15:case"end":return Ze.stop()}},xe,null,[[3,12]])}));return function(xe,Ce,We){return K.apply(this,arguments)}}())}}]),Z}(),G.default(me,"version",oe),me),dt([_.validateTypes(_.nonEmptyString),qt("design:type",Function),qt("design:paramtypes",[String]),qt("design:returntype",void 0)],e.default.prototype,"updateToken",null),dt([_.validateTypesAsync(_.nonEmptyString),qt("design:type",Function),qt("design:paramtypes",[String]),qt("design:returntype",Kt)],e.default.prototype,"get",null),e.default=dt([_.validateConstructorTypes(_.nonEmptyString,_.nonEmptyString,[_.nonEmptyString,_.literal(null)],[_.pureObject,"undefined"]),qt("design:paramtypes",[String,String,Object,Object])],e.default),e.CancellablePromise=Kt,e.Client=e.default,e.McsClient=e.default,e.McsMedia=sr,e.Media=sr})(LR);var s1=Vt,iJ=xr,aJ=fi,sJ=s1.aTypedArray,oJ=s1.exportTypedArrayMethod;oJ("at",function(r){var t=sJ(this),n=iJ(t),i=aJ(r),a=i>=0?i:n+i;return a<0||a>=n?void 0:t[a]});var uJ=gt,cJ=_t,lJ=pk,fJ=Wl,og="ArrayBuffer",bS=lJ[og],dJ=cJ[og];uJ({global:!0,constructor:!0,forced:dJ!==bS},{ArrayBuffer:bS});fJ(og);var pJ=gt,o1=vt,hJ=In,vJ=Mr,_S=xr,mJ=Nm,wS=wr,ug=lt,gJ=zm,yJ=zl,SS=Jk,bJ=Yk,CS=ro,TS=Xk,pa=[],ES=o1(pa.sort),_J=o1(pa.push),wJ=ug(function(){pa.sort(void 0)}),SJ=ug(function(){pa.sort(null)}),CJ=yJ("sort"),u1=!ug(function(){if(CS)return CS<70;if(!(SS&&SS>3)){if(bJ)return!0;if(TS)return TS<603;var e="",r,t,n,i;for(r=65;r<76;r++){switch(t=String.fromCharCode(r),r){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++)pa.push({k:t+i,v:n})}for(pa.sort(function(a,s){return s.v-a.v}),i=0;i<pa.length;i++)t=pa[i].k.charAt(0),e.charAt(e.length-1)!==t&&(e+=t);return e!=="DGBEFHACIJK"}}),TJ=wJ||!SJ||!CJ||!u1,EJ=function(e){return function(r,t){return t===void 0?-1:r===void 0?1:e!==void 0?+e(r,t)||0:wS(r)>wS(t)?1:-1}};pJ({target:"Array",proto:!0,forced:TJ},{sort:function(r){r!==void 0&&hJ(r);var t=vJ(this);if(u1)return r===void 0?ES(t):ES(t,r);var n=[],i=_S(t),a,s;for(s=0;s<i;s++)s in t&&_J(n,t[s]);for(gJ(n,EJ(r)),a=_S(n),s=0;s<a;)t[s]=n[s++];for(;s<i;)mJ(t,s++);return t}});var kJ=gt,RJ=vt,$J=DR,IJ=Kn,kS=wr,OJ=jR,PJ=RJ("".indexOf);kJ({target:"String",proto:!0,forced:!OJ("includes")},{includes:function(r){return!!~PJ(kS(IJ(this)),kS($J(r)),arguments.length>1?arguments[1]:void 0)}});var AJ=vt,RS=uf,Tc=of.getWeakData,MJ=ka,xJ=ar,NJ=Hn,Cp=Jt,LJ=Su,c1=Zr,$S=tr,l1=pn,DJ=l1.set,jJ=l1.getterFor,FJ=c1.find,UJ=c1.findIndex,BJ=AJ([].splice),qJ=0,Ec=function(e){return e.frozen||(e.frozen=new f1)},f1=function(){this.entries=[]},Tp=function(e,r){return FJ(e.entries,function(t){return t[0]===r})};f1.prototype={get:function(e){var r=Tp(this,e);if(r)return r[1]},has:function(e){return!!Tp(this,e)},set:function(e,r){var t=Tp(this,e);t?t[1]=r:this.entries.push([e,r])},delete:function(e){var r=UJ(this.entries,function(t){return t[0]===e});return~r&&BJ(this.entries,r,1),!!~r}};var zJ={getConstructor:function(e,r,t,n){var i=e(function(u,c){MJ(u,a),DJ(u,{type:r,id:qJ++,frozen:null}),NJ(c)||LJ(c,u[n],{that:u,AS_ENTRIES:t})}),a=i.prototype,s=jJ(r),o=function(u,c,l){var h=s(u),v=Tc(xJ(c),!0);return v===!0?Ec(h).set(c,l):v[h.id]=l,u};return RS(a,{delete:function(u){var c=s(this);if(!Cp(u))return!1;var l=Tc(u);return l===!0?Ec(c).delete(u):l&&$S(l,c.id)&&delete l[c.id]},has:function(c){var l=s(this);if(!Cp(c))return!1;var h=Tc(c);return h===!0?Ec(l).has(c):h&&$S(h,l.id)}}),RS(a,t?{get:function(c){var l=s(this);if(Cp(c)){var h=Tc(c);if(h===!0)return Ec(l).get(c);if(h)return h[l.id]}},set:function(c,l){return o(this,c,l)}}:{add:function(c){return o(this,c,!0)}}),i}},WJ=wm,VJ=zJ;WJ("WeakSet",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},VJ);var bf={},d1={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.log=t()})(Ae,function(){var r=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(C,I){var $=C[I];if(typeof $.bind=="function")return $.bind(C);try{return Function.prototype.bind.call($,C)}catch{return function(){return Function.prototype.apply.apply($,[C,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(C){return C==="debug"&&(C="log"),typeof console===t?!1:C==="trace"&&n?s:console[C]!==void 0?a(console,C):console.log!==void 0?a(console,"log"):r}function u(C,I){for(var $=0;$<i.length;$++){var x=i[$];this[x]=$<C?r:this.methodFactory(x,C,I)}this.log=this.debug}function c(C,I,$){return function(){typeof console!==t&&(u.call(this,I,$),this[C].apply(this,arguments))}}function l(C,I,$){return o(C)||c.apply(this,arguments)}function h(C,I,$){var x=this,N;I=I??"WARN";var q="loglevel";typeof C=="string"?q+=":"+C:typeof C=="symbol"&&(q=void 0);function X(te){var se=(i[te]||"silent").toUpperCase();if(!(typeof window===t||!q)){try{window.localStorage[q]=se;return}catch{}try{window.document.cookie=encodeURIComponent(q)+"="+se+";"}catch{}}}function J(){var te;if(!(typeof window===t||!q)){try{te=window.localStorage[q]}catch{}if(typeof te===t)try{var se=window.document.cookie,ne=se.indexOf(encodeURIComponent(q)+"=");ne!==-1&&(te=/^([^;]+)/.exec(se.slice(ne))[1])}catch{}return x.levels[te]===void 0&&(te=void 0),te}}function G(){if(!(typeof window===t||!q)){try{window.localStorage.removeItem(q);return}catch{}try{window.document.cookie=encodeURIComponent(q)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}x.name=C,x.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},x.methodFactory=$||l,x.getLevel=function(){return N},x.setLevel=function(te,se){if(typeof te=="string"&&x.levels[te.toUpperCase()]!==void 0&&(te=x.levels[te.toUpperCase()]),typeof te=="number"&&te>=0&&te<=x.levels.SILENT){if(N=te,se!==!1&&X(te),u.call(x,te,C),typeof console===t&&te<x.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+te},x.setDefaultLevel=function(te){I=te,J()||x.setLevel(te,!1)},x.resetLevel=function(){x.setLevel(I,!1),G()},x.enableAll=function(te){x.setLevel(x.levels.TRACE,te)},x.disableAll=function(te){x.setLevel(x.levels.SILENT,te)};var L=J();L==null&&(L=I),x.setLevel(L,!1)}var v=new h,m={};v.getLogger=function(I){if(typeof I!="symbol"&&typeof I!="string"||I==="")throw new TypeError("You must supply a name when creating a logger.");var $=m[I];return $||($=m[I]=new h(I,v.getLevel(),v.methodFactory)),$};var _=typeof window!==t?window.log:void 0;return v.noConflict=function(){return typeof window!==t&&window.log===v&&(window.log=_),v},v.getLoggers=function(){return m},v.default=v,v})})(d1);var GJ=d1.exports;/*
320
320
  @license
321
321
  Copyright (c) 2022 Twilio Inc.
322
322
 
@@ -327,7 +327,7 @@ The above copyright notice and this permission notice shall be included in all c
327
327
  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.
328
328
 
329
329
 
330
- */Object.defineProperty(bf,"__esModule",{value:!0});var VJ=WJ;function GJ(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var kc=GJ(VJ),HJ=function(r,t,n){return function(i,a,s){if(typeof s.value!="function"&&(s==null?void 0:s.get)===void 0)throw new Error("The deprecated decorator can only be applied to methods or getters");if(typeof s.value=="function"){var o=s.value;s.value=function(){jh("The method ".concat(r," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return o.apply(this,l)};return}var u=s.get;s.get=function(){return jh("The getter ".concat(r," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),u==null?void 0:u.apply(this)}}},jh=function(r){var t=kc.default.getLevel();kc.default.setLevel("warn"),kc.default.warn(r),kc.default.setLevel(t)};bf.deprecated=HJ;bf.deprecationWarning=jh;var KJ=gt,JJ=Zr.find,YJ=am,Fh="find",d1=!0;Fh in[]&&Array(1)[Fh](function(){d1=!1});KJ({target:"Array",proto:!0,forced:d1},{find:function(r){return JJ(this,r,arguments.length>1?arguments[1]:void 0)}});YJ(Fh);var Uh={exports:{}},$S=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if($S){var IS=new Uint8Array(16);Uh.exports=function(){return $S(IS),IS}}else{var OS=new Array(16);Uh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),OS[r]=t>>>((r&3)<<3)&255;return OS}}var p1=Uh.exports,h1=[];for(var Rc=0;Rc<256;++Rc)h1[Rc]=(Rc+256).toString(16).substr(1);function XJ(e,r){var t=r||0,n=h1;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var v1=XJ,QJ=p1,ZJ=v1,PS,Ep,kp=0,Rp=0;function eY(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||PS,s=e.clockseq!==void 0?e.clockseq:Ep;if(a==null||s==null){var o=QJ();a==null&&(a=PS=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=Ep=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Rp+1,l=u-kp+(c-Rp)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>kp)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");kp=u,Rp=c,Ep=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||ZJ(i)}var tY=eY,rY=p1,nY=v1;function iY(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||rY)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||nY(i)}var aY=iY,sY=tY,m1=aY,cg=m1;cg.v1=sY;cg.v4=m1;var oY=cg,uY=gt,cY=RE,lY=lt,fY=Jt,dY=of.onFreeze,Bh=Object.freeze,pY=lY(function(){Bh(1)});uY({target:"Object",stat:!0,forced:pY,sham:!cY},{freeze:function(r){return Bh&&fY(r)?Bh(dY(r)):r}});/*
330
+ */Object.defineProperty(bf,"__esModule",{value:!0});var HJ=GJ;function KJ(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var kc=KJ(HJ),JJ=function(r,t,n){return function(i,a,s){if(typeof s.value!="function"&&(s==null?void 0:s.get)===void 0)throw new Error("The deprecated decorator can only be applied to methods or getters");if(typeof s.value=="function"){var o=s.value;s.value=function(){jh("The method ".concat(r," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var c=arguments.length,l=new Array(c),h=0;h<c;h++)l[h]=arguments[h];return o.apply(this,l)};return}var u=s.get;s.get=function(){return jh("The getter ".concat(r," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),u==null?void 0:u.apply(this)}}},jh=function(r){var t=kc.default.getLevel();kc.default.setLevel("warn"),kc.default.warn(r),kc.default.setLevel(t)};bf.deprecated=JJ;bf.deprecationWarning=jh;var YJ=gt,XJ=Zr.find,QJ=am,Fh="find",p1=!0;Fh in[]&&Array(1)[Fh](function(){p1=!1});YJ({target:"Array",proto:!0,forced:p1},{find:function(r){return XJ(this,r,arguments.length>1?arguments[1]:void 0)}});QJ(Fh);var Uh={exports:{}},IS=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(IS){var OS=new Uint8Array(16);Uh.exports=function(){return IS(OS),OS}}else{var PS=new Array(16);Uh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),PS[r]=t>>>((r&3)<<3)&255;return PS}}var h1=Uh.exports,v1=[];for(var Rc=0;Rc<256;++Rc)v1[Rc]=(Rc+256).toString(16).substr(1);function ZJ(e,r){var t=r||0,n=v1;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var m1=ZJ,eY=h1,tY=m1,AS,Ep,kp=0,Rp=0;function rY(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||AS,s=e.clockseq!==void 0?e.clockseq:Ep;if(a==null||s==null){var o=eY();a==null&&(a=AS=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=Ep=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Rp+1,l=u-kp+(c-Rp)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>kp)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");kp=u,Rp=c,Ep=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||tY(i)}var nY=rY,iY=h1,aY=m1;function sY(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||iY)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||aY(i)}var oY=sY,uY=nY,g1=oY,cg=g1;cg.v1=uY;cg.v4=g1;var cY=cg,lY=gt,fY=$E,dY=lt,pY=Jt,hY=of.onFreeze,Bh=Object.freeze,vY=dY(function(){Bh(1)});lY({target:"Object",stat:!0,forced:vY,sham:!fY},{freeze:function(r){return Bh&&pY(r)?Bh(hY(r)):r}});/*
331
331
  @license
332
332
  The following license applies to all parts of this software except as
333
333
  documented below.
@@ -454,13 +454,13 @@ This software includes platform.js under the following license.
454
454
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
455
455
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
456
456
 
457
- */(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=yu,n=os,i=vi,a=mi,s=Pn,o=us,u=Ea,c=gi,l=Cu,h=On,v=gr,m=VF,_=kr,C=co,I=mm,$=uq,x=uo,N=Ji,q=cf,X=sR,J=en,G=NR,L=bf,te=mf,se=oY;function ne(O){return O&&typeof O=="object"&&"default"in O?O:{default:O}}function ge(O){if(O&&O.__esModule)return O;var P=Object.create(null);return O&&Object.keys(O).forEach(function(f){if(f!=="default"){var d=Object.getOwnPropertyDescriptor(O,f);Object.defineProperty(P,f,d.get?d:{enumerable:!0,get:function(){return O[f]}})}}),P.default=O,Object.freeze(P)}var Y=ne(t),Ue=ne(n),He=ne(i),Rt=ne(a),ft=ne(s),Pe=ne(o),he=ne(u),pe=ne(c),M=ne(l),Oe=ne(h),Je=ge(v),De=ne(C),we=ne($),Q=ne(x),$t=ne(te);function _e(O,P,f,d){var p=arguments.length,y=p<3?P:d===null?d=Object.getOwnPropertyDescriptor(P,f):d,g;if((typeof Reflect>"u"?"undefined":Oe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(O,P,f,d);else for(var b=O.length-1;b>=0;b--)(g=O[b])&&(y=(p<3?g(y):p>3?g(P,f,y):g(P,f))||y);return p>3&&y&&Object.defineProperty(P,f,y),y}function le(O,P){if((typeof Reflect>"u"?"undefined":Oe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(O,P)}function St(O,P){return["".concat(new Date().toISOString()," Conversations ").concat(O,":")].concat(Array.from(P))}var Le=Je.getLogger("twilio-conversations"),Gt=function(){function O(P){pe.default(this,O),Pe.default(this,"prefix",""),this.prefix=P!=null&&P.length>0?P+" ":""}return he.default(O,[{key:"setLevel",value:function(f){Le.setLevel(f)}},{key:"trace",value:function(){if(Le.getLevel()==Le.levels.TRACE){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St(this.prefix+"T",d))}}},{key:"debug",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St(this.prefix+"D",d))}},{key:"info",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.info.apply(null,St(this.prefix+"I",d))}},{key:"warn",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.warn.apply(null,St(this.prefix+"W",d))}},{key:"error",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.error.apply(null,St(this.prefix+"E",d))}}],[{key:"scope",value:function(f){return new O(f)}},{key:"setLevel",value:function(f){Le.setLevel(f)}},{key:"trace",value:function(){if(Le.getLevel()==Le.levels.TRACE){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St("T",d))}}},{key:"debug",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St("D",d))}},{key:"info",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.info.apply(null,St("I",d))}},{key:"warn",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.warn.apply(null,St("W",d))}},{key:"error",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.error.apply(null,St("E",d))}}]),O}();function pt(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function ke(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?pt(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):pt(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}var ot=5,bt="PT5S",$e="PT5S",Kt=100,dt=1e3,qt=4e3,rr=3,Fe=!0,Ar=100,Rr=1e3,Ct=he.default(function O(){var P,f,d,p,y,g,b,w,S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=arguments.length>1?arguments[1]:void 0,F=arguments.length>2?arguments[2]:void 0;pe.default(this,O),Pe.default(this,"typingIndicatorTimeoutDefault",ot*1e3);var j=S.Chat||S.IPMessaging||S||{};this.productId=j.productId,this.links={myConversations:T.links.my_conversations,conversations:T.links.conversations,users:T.links.users,currentUser:T.links.current_user,typing:T.links.typing,mediaService:T.links.media_service,mediaSetService:T.links.media_set_service,messagesReceipts:T.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:T.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:T.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:T.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:T.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:T.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=j.typingIndicatorTimeoutOverride,this.backoffConfiguration=ke({min:dt,max:qt,maxAttemptsCount:rr},j.backoffConfigOverride),this.retryWhenThrottled=j.retryWhenThrottledOverride!==void 0?j.retryWhenThrottledOverride:Fe,this.userInfosToSubscribe=(P=(f=j.userInfosToSubscribeOverride)!==null&&f!==void 0?f:T.options.user_infos_to_subscribe)!==null&&P!==void 0?P:Kt,this.reachabilityEnabled=T.options.reachability_enabled,this.userIdentity=T.identity,this.userInfo=T.sync_objects.my_user_info,this.myConversations=T.sync_objects.my_conversations;var V=(d=(p=j.httpCacheIntervalOverride)!==null&&p!==void 0?p:T.options.http_cache_interval)!==null&&d!==void 0?d:bt;try{this.httpCacheInterval=m.toSeconds(m.parse(V))}catch{F.error("Failed to parse http cache interval ".concat(V,", using default value ").concat(bt)),this.httpCacheInterval=m.toSeconds(m.parse(bt))}var W=(y=(g=j.consumptionReportIntervalOverride)!==null&&g!==void 0?g:T.options.consumption_report_interval)!==null&&y!==void 0?y:$e;try{this.consumptionReportInterval=m.toSeconds(m.parse(W))}catch{F.error("Failed to parse consumption report interval ".concat(W,", using default value ").concat($e)),this.consumptionReportInterval=m.toSeconds(m.parse($e))}this.channelMetadataCacheCapacity=(b=S.channelMetadataCacheCapacity)!==null&&b!==void 0?b:Ar,this.messageRecipientsCacheCapacity=(w=S.messageRecipientsCacheCapacity)!==null&&w!==void 0?w:Rr});function Pt(O){return JSON.parse(JSON.stringify(O))}function yt(O){return typeof O<"u"&&!isNaN(Number(O))?Number(O):null}function it(O){try{return new Date(O)}catch{return null}}function Mt(O,P,f){var d={};if(O)try{d=JSON.parse(O)}catch(p){f.warn(P,p)}return d}var It=function(){function O(P){pe.default(this,O),this.base=P.replace(/\/$/,""),this.args=[],this.paths=[]}return he.default(O,[{key:"arg",value:function(f,d){return typeof d<"u"&&this.args.push(encodeURIComponent(f)+"="+encodeURIComponent(d)),this}},{key:"path",value:function(f){return this.paths.push(encodeURIComponent(f)),this}},{key:"build",value:function(){var f=this.base;return this.paths.length&&(f+="/"+this.paths.join("/")),this.args.length&&(f+="?"+this.args.join("&")),f}}]),O}(),sr=_.custom(function(O){return[["string","number","boolean","object"].includes(Oe.default(O)),"a JSON type"]}),Nr=_.custom(function(O){return[["undefined","string","number","boolean","object"].includes(Oe.default(O)),"an optional JSON type"]}),tn=_.objectSchema("send media options",{contentType:[_.literal(null),"string"],filename:["string","undefined"],media:[_.literal("null"),"string"].concat(De.default(typeof Buffer=="function"?[Buffer]:[]),De.default(typeof Blob=="function"?[Blob]:[]))});function rn(O){var P=Qt();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function Qt(){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=Gt.scope("User"),ve=function(O){He.default(f,O);var P=rn(f);function f(d,p,y,g){var b;return pe.default(this,f),b=P.call(this),Pe.default(Ue.default(b),"promiseToFetch",null),Pe.default(Ue.default(b),"updated","updated"),Pe.default(Ue.default(b),"userSubscribed","userSubscribed"),Pe.default(Ue.default(b),"userUnsubscribed","userUnsubscribed"),b.services=g,b.subscribed="initializing",b.setMaxListeners(0),b.state={identity:d,entityName:p,friendlyName:null,attributes:{},online:null,notifiable:null},b._initializationPromise=new Promise(function(w){b._resolveInitializationPromise=w}),y!==null&&b._resolveInitialization(y,d,p,!1),b}return he.default(f,[{key:"identity",get:function(){return this.state.identity},set:function(p){this.state.identity=p}},{key:"entityName",set:function(p){this.state.entityName=p}},{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 d=Y.default(M.default.mark(function y(g,b){var w,S;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return F.next=2,this._initializationPromise;case 2:w=[],lr.debug("User for",this.state.identity,"updated:",g,b),F.t0=g,F.next=F.t0==="friendlyName"?7:F.t0==="attributes"?9:F.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==b.value&&(w.push("friendlyName"),this.state.friendlyName=b.value),F.abrupt("break",16);case 9:return S=Mt(b.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),lr),we.default(this.state.attributes,S)||(this.state.attributes=S,w.push("attributes")),F.abrupt("break",16);case 12:return this.state.online!==b.online&&(this.state.online=b.online,w.push("reachabilityOnline")),this.state.notifiable!==b.notifiable&&(this.state.notifiable=b.notifiable,w.push("reachabilityNotifiable")),F.abrupt("break",16);case 15:return F.abrupt("return");case 16:w.length>0&&this.emit("updated",{user:this,updateReasons:w});case 17:case"end":return F.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"_updateReachabilityInfo",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w=this;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){T.next=4;break}return T.abrupt("return",Promise.resolve());case 4:return T.abrupt("return",g.get("reachability").then(b).catch(function(F){lr.warn("Failed to get reachability info for ",w.state.identity,F)}));case 5:case"end":return T.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"_fetch",value:function(){var d=Y.default(M.default.mark(function y(){var g=this;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._initializationPromise;case 2:if(this.state.entityName){w.next=4;break}return w.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(S){return g.entity=S,S.on("itemUpdated",function(T){return lr.debug(g.state.entityName+" ("+g.state.identity+") itemUpdated: "+T.item.key),g._update(T.item.key,T.item.data)}),S.on("itemAdded",function(T){return lr.debug(g.state.entityName+" ("+g.state.identity+") itemAdded: "+T.item.key),g._update(T.item.key,T.item.data)}),Promise.all([S.get("friendlyName").then(function(T){return g._update(T.key,T.data)}),S.get("attributes").then(function(T){return g._update(T.key,T.data)}),g._updateReachabilityInfo(S,function(T){return g._update(T.key,T.data)})])}).then(function(){return lr.debug("Fetched for",g.identity),g.subscribed="subscribed",g.emit("userSubscribed",g),g}).catch(function(S){throw g.promiseToFetch=null,S}),w.abrupt("return",this.promiseToFetch);case 6:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_ensureFetched",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._initializationPromise;case 2:return b.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"updateAttributes",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){w.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return w.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(g)});case 6:return w.abrupt("return",this);case 7:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"updateFriendlyName",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){w.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return w.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:g});case 6:return w.abrupt("return",this);case 7:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"unsubscribe",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){b.next=9;break}return b.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_resolveInitialization",value:function(p,y,g,b){this.configuration=p,this.identity=y,this.entityName=g,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),b&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),f}(I.ReplayEventEmitter);_e([_.validateTypesAsync(sr),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],ve.prototype,"updateAttributes",null),_e([_.validateTypesAsync(["string"]),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],ve.prototype,"updateFriendlyName",null);function ye(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=ae(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
457
+ */(function(e){var r=typeof r<"u"?r:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(e,"__esModule",{value:!0});var t=yu,n=os,i=vi,a=mi,s=Pn,o=us,u=Ea,c=gi,l=Cu,h=On,v=gr,m=HF,_=Rr,C=co,I=mm,$=lq,x=uo,N=Ji,q=cf,X=oR,J=en,G=LR,L=bf,te=mf,se=cY;function ne(O){return O&&typeof O=="object"&&"default"in O?O:{default:O}}function ge(O){if(O&&O.__esModule)return O;var P=Object.create(null);return O&&Object.keys(O).forEach(function(f){if(f!=="default"){var d=Object.getOwnPropertyDescriptor(O,f);Object.defineProperty(P,f,d.get?d:{enumerable:!0,get:function(){return O[f]}})}}),P.default=O,Object.freeze(P)}var Y=ne(t),Ue=ne(n),He=ne(i),Rt=ne(a),ft=ne(s),Pe=ne(o),he=ne(u),pe=ne(c),M=ne(l),Oe=ne(h),Je=ge(v),De=ne(C),we=ne($),Q=ne(x),$t=ne(te);function _e(O,P,f,d){var p=arguments.length,y=p<3?P:d===null?d=Object.getOwnPropertyDescriptor(P,f):d,g;if((typeof Reflect>"u"?"undefined":Oe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(O,P,f,d);else for(var b=O.length-1;b>=0;b--)(g=O[b])&&(y=(p<3?g(y):p>3?g(P,f,y):g(P,f))||y);return p>3&&y&&Object.defineProperty(P,f,y),y}function le(O,P){if((typeof Reflect>"u"?"undefined":Oe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(O,P)}function St(O,P){return["".concat(new Date().toISOString()," Conversations ").concat(O,":")].concat(Array.from(P))}var Le=Je.getLogger("twilio-conversations"),Gt=function(){function O(P){pe.default(this,O),Pe.default(this,"prefix",""),this.prefix=P!=null&&P.length>0?P+" ":""}return he.default(O,[{key:"setLevel",value:function(f){Le.setLevel(f)}},{key:"trace",value:function(){if(Le.getLevel()==Le.levels.TRACE){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St(this.prefix+"T",d))}}},{key:"debug",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St(this.prefix+"D",d))}},{key:"info",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.info.apply(null,St(this.prefix+"I",d))}},{key:"warn",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.warn.apply(null,St(this.prefix+"W",d))}},{key:"error",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.error.apply(null,St(this.prefix+"E",d))}}],[{key:"scope",value:function(f){return new O(f)}},{key:"setLevel",value:function(f){Le.setLevel(f)}},{key:"trace",value:function(){if(Le.getLevel()==Le.levels.TRACE){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St("T",d))}}},{key:"debug",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.debug.apply(null,St("D",d))}},{key:"info",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.info.apply(null,St("I",d))}},{key:"warn",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.warn.apply(null,St("W",d))}},{key:"error",value:function(){for(var f=arguments.length,d=new Array(f),p=0;p<f;p++)d[p]=arguments[p];Le.error.apply(null,St("E",d))}}]),O}();function pt(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function ke(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?pt(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):pt(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}var ot=5,bt="PT5S",$e="PT5S",Kt=100,dt=1e3,qt=4e3,rr=3,Fe=!0,Ar=100,$r=1e3,Ct=he.default(function O(){var P,f,d,p,y,g,b,w,S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=arguments.length>1?arguments[1]:void 0,F=arguments.length>2?arguments[2]:void 0;pe.default(this,O),Pe.default(this,"typingIndicatorTimeoutDefault",ot*1e3);var j=S.Chat||S.IPMessaging||S||{};this.productId=j.productId,this.links={myConversations:T.links.my_conversations,conversations:T.links.conversations,users:T.links.users,currentUser:T.links.current_user,typing:T.links.typing,mediaService:T.links.media_service,mediaSetService:T.links.media_set_service,messagesReceipts:T.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:T.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:T.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:T.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:T.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:T.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=j.typingIndicatorTimeoutOverride,this.backoffConfiguration=ke({min:dt,max:qt,maxAttemptsCount:rr},j.backoffConfigOverride),this.retryWhenThrottled=j.retryWhenThrottledOverride!==void 0?j.retryWhenThrottledOverride:Fe,this.userInfosToSubscribe=(P=(f=j.userInfosToSubscribeOverride)!==null&&f!==void 0?f:T.options.user_infos_to_subscribe)!==null&&P!==void 0?P:Kt,this.reachabilityEnabled=T.options.reachability_enabled,this.userIdentity=T.identity,this.userInfo=T.sync_objects.my_user_info,this.myConversations=T.sync_objects.my_conversations;var V=(d=(p=j.httpCacheIntervalOverride)!==null&&p!==void 0?p:T.options.http_cache_interval)!==null&&d!==void 0?d:bt;try{this.httpCacheInterval=m.toSeconds(m.parse(V))}catch{F.error("Failed to parse http cache interval ".concat(V,", using default value ").concat(bt)),this.httpCacheInterval=m.toSeconds(m.parse(bt))}var W=(y=(g=j.consumptionReportIntervalOverride)!==null&&g!==void 0?g:T.options.consumption_report_interval)!==null&&y!==void 0?y:$e;try{this.consumptionReportInterval=m.toSeconds(m.parse(W))}catch{F.error("Failed to parse consumption report interval ".concat(W,", using default value ").concat($e)),this.consumptionReportInterval=m.toSeconds(m.parse($e))}this.channelMetadataCacheCapacity=(b=S.channelMetadataCacheCapacity)!==null&&b!==void 0?b:Ar,this.messageRecipientsCacheCapacity=(w=S.messageRecipientsCacheCapacity)!==null&&w!==void 0?w:$r});function Pt(O){return JSON.parse(JSON.stringify(O))}function yt(O){return typeof O<"u"&&!isNaN(Number(O))?Number(O):null}function it(O){try{return new Date(O)}catch{return null}}function Mt(O,P,f){var d={};if(O)try{d=JSON.parse(O)}catch(p){f.warn(P,p)}return d}var It=function(){function O(P){pe.default(this,O),this.base=P.replace(/\/$/,""),this.args=[],this.paths=[]}return he.default(O,[{key:"arg",value:function(f,d){return typeof d<"u"&&this.args.push(encodeURIComponent(f)+"="+encodeURIComponent(d)),this}},{key:"path",value:function(f){return this.paths.push(encodeURIComponent(f)),this}},{key:"build",value:function(){var f=this.base;return this.paths.length&&(f+="/"+this.paths.join("/")),this.args.length&&(f+="?"+this.args.join("&")),f}}]),O}(),sr=_.custom(function(O){return[["string","number","boolean","object"].includes(Oe.default(O)),"a JSON type"]}),Nr=_.custom(function(O){return[["undefined","string","number","boolean","object"].includes(Oe.default(O)),"an optional JSON type"]}),tn=_.objectSchema("send media options",{contentType:[_.literal(null),"string"],filename:["string","undefined"],media:[_.literal("null"),"string"].concat(De.default(typeof Buffer=="function"?[Buffer]:[]),De.default(typeof Blob=="function"?[Blob]:[]))});function rn(O){var P=Qt();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function Qt(){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=Gt.scope("User"),ve=function(O){He.default(f,O);var P=rn(f);function f(d,p,y,g){var b;return pe.default(this,f),b=P.call(this),Pe.default(Ue.default(b),"promiseToFetch",null),Pe.default(Ue.default(b),"updated","updated"),Pe.default(Ue.default(b),"userSubscribed","userSubscribed"),Pe.default(Ue.default(b),"userUnsubscribed","userUnsubscribed"),b.services=g,b.subscribed="initializing",b.setMaxListeners(0),b.state={identity:d,entityName:p,friendlyName:null,attributes:{},online:null,notifiable:null},b._initializationPromise=new Promise(function(w){b._resolveInitializationPromise=w}),y!==null&&b._resolveInitialization(y,d,p,!1),b}return he.default(f,[{key:"identity",get:function(){return this.state.identity},set:function(p){this.state.identity=p}},{key:"entityName",set:function(p){this.state.entityName=p}},{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 d=Y.default(M.default.mark(function y(g,b){var w,S;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return F.next=2,this._initializationPromise;case 2:w=[],lr.debug("User for",this.state.identity,"updated:",g,b),F.t0=g,F.next=F.t0==="friendlyName"?7:F.t0==="attributes"?9:F.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==b.value&&(w.push("friendlyName"),this.state.friendlyName=b.value),F.abrupt("break",16);case 9:return S=Mt(b.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),lr),we.default(this.state.attributes,S)||(this.state.attributes=S,w.push("attributes")),F.abrupt("break",16);case 12:return this.state.online!==b.online&&(this.state.online=b.online,w.push("reachabilityOnline")),this.state.notifiable!==b.notifiable&&(this.state.notifiable=b.notifiable,w.push("reachabilityNotifiable")),F.abrupt("break",16);case 15:return F.abrupt("return");case 16:w.length>0&&this.emit("updated",{user:this,updateReasons:w});case 17:case"end":return F.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"_updateReachabilityInfo",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w=this;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){T.next=4;break}return T.abrupt("return",Promise.resolve());case 4:return T.abrupt("return",g.get("reachability").then(b).catch(function(F){lr.warn("Failed to get reachability info for ",w.state.identity,F)}));case 5:case"end":return T.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"_fetch",value:function(){var d=Y.default(M.default.mark(function y(){var g=this;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._initializationPromise;case 2:if(this.state.entityName){w.next=4;break}return w.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(S){return g.entity=S,S.on("itemUpdated",function(T){return lr.debug(g.state.entityName+" ("+g.state.identity+") itemUpdated: "+T.item.key),g._update(T.item.key,T.item.data)}),S.on("itemAdded",function(T){return lr.debug(g.state.entityName+" ("+g.state.identity+") itemAdded: "+T.item.key),g._update(T.item.key,T.item.data)}),Promise.all([S.get("friendlyName").then(function(T){return g._update(T.key,T.data)}),S.get("attributes").then(function(T){return g._update(T.key,T.data)}),g._updateReachabilityInfo(S,function(T){return g._update(T.key,T.data)})])}).then(function(){return lr.debug("Fetched for",g.identity),g.subscribed="subscribed",g.emit("userSubscribed",g),g}).catch(function(S){throw g.promiseToFetch=null,S}),w.abrupt("return",this.promiseToFetch);case 6:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_ensureFetched",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._initializationPromise;case 2:return b.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"updateAttributes",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){w.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return w.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(g)});case 6:return w.abrupt("return",this);case 7:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"updateFriendlyName",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){w.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return w.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:g});case 6:return w.abrupt("return",this);case 7:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"unsubscribe",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){b.next=9;break}return b.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_resolveInitialization",value:function(p,y,g,b){this.configuration=p,this.identity=y,this.entityName=g,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),b&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),f}(I.ReplayEventEmitter);_e([_.validateTypesAsync(sr),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],ve.prototype,"updateAttributes",null),_e([_.validateTypesAsync(["string"]),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],ve.prototype,"updateFriendlyName",null);function ye(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=ae(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
458
458
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function ae(O,P){if(O){if(typeof O=="string")return de(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return de(O,P)}}function de(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}var oe=function(){function O(P,f){pe.default(this,O),this.configuration=P,this.services=f,this.cache=new Map,this.cacheLifetime=this.configuration.httpCacheInterval*100,this.cleanupCache()}return he.default(O,[{key:"isExpired",value:function(f){return!this.cacheLifetime||Date.now()-f>this.cacheLifetime}},{key:"cleanupCache",value:function(){var f=ye(this.cache),d;try{for(f.s();!(d=f.n()).done;){var p=Q.default(d.value,2),y=p[0],g=p[1];this.isExpired(g.timestamp)&&this.cache.delete(y)}}catch(b){f.e(b)}finally{f.f()}this.cache.size===0&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var f=this;this.timer=this.timer||setInterval(function(){return f.cleanupCache()},this.cacheLifetime*2)}},{key:"executeWithRetry",value:function(f){var d=this,p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return new Promise(function(y,g){var b=[502,503,504];p&&b.push(429);var w=new N.Retrier(d.configuration.backoffConfiguration);w.on("attempt",function(){f().then(function(S){return w.succeeded(S)}).catch(function(S){b.indexOf(S.status)>-1||S.message==="Twilsock disconnected"?w.failed(S):(w.removeAllListeners(),w.cancel(),g(S))})}),w.on("succeeded",function(S){y(S)}),w.on("cancelled",function(S){return g(S)}),w.on("failed",function(S){return g(S)}),w.start()})}},{key:"get",value:function(){var P=Y.default(M.default.mark(function d(p){var y=this,g,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(g=this.cache.get(p),!(g&&!this.isExpired(g.timestamp))){T.next=3;break}return T.abrupt("return",g.response);case 3:return b={},T.next=6,this.executeWithRetry(function(){return y.services.transport.get(p,b,y.configuration.productId)},this.configuration.retryWhenThrottled);case 6:return w=T.sent,this.cache.set(p,{response:w,timestamp:Date.now()}),this.pokeTimer(),T.abrupt("return",w);case 10:case"end":return T.stop()}},d,this)}));function f(d){return P.apply(this,arguments)}return f}()}]),O}(),me=he.default(function O(){pe.default(this,O)});Pe.default(me,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),Pe.default(me,"NEW_MESSAGE","twilio.conversations.new_message"),Pe.default(me,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),Pe.default(me,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),Pe.default(me,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");function Se(O){var P=Z();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function Z(){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 ce=Gt.scope("Participant"),H=function(O){He.default(f,O);var P=Se(f);function f(d,p,y,g,b){var w,S,T;if(pe.default(this,f),T=P.call(this),T.conversation=y,T.links=g,T.services=b,T.state={attributes:Mt(d.attributes,"Retrieved malformed attributes from the server for participant: "+p,ce),dateCreated:d.dateCreated?it(d.dateCreated):null,dateUpdated:d.dateCreated?it(d.dateUpdated):null,sid:p,typingTimeout:null,isTyping:!1,identity:d.identity,roleSid:(w=d.roleSid)!==null&&w!==void 0?w:"",lastReadMessageIndex:Number.isInteger(d.lastConsumedMessageIndex)?d.lastConsumedMessageIndex:null,lastReadTimestamp:d.lastConsumptionTimestamp?it(d.lastConsumptionTimestamp):null,type:d.type||"chat",userInfo:d.userInfo,bindings:(S=d.bindings)!==null&&S!==void 0?S:{}},!d.identity&&!d.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return T}return he.default(f,[{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 p;return(p=this.state.bindings)!==null&&p!==void 0?p:{}}},{key:"_startTyping",value:function(p){var y=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit(f.typingStarted,this),this.conversation.emit(wt.typingStarted,this),this.state.typingTimeout=Number(setTimeout(function(){return y._endTyping()},p)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit(f.typingEnded,this),this.conversation.emit(wt.typingEnded,this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(p){var y=[],g=Mt(p.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,ce);p.attributes&&!we.default(this.state.attributes,g)&&(this.state.attributes=g,y.push("attributes"));var b=it(p.dateUpdated);p.dateUpdated&&(b==null?void 0:b.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=b,y.push("dateUpdated"));var w=it(p.dateCreated);if(p.dateCreated&&(w==null?void 0:w.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=w,y.push("dateCreated")),p.roleSid&&this.state.roleSid!==p.roleSid&&(this.state.roleSid=p.roleSid,y.push("roleSid")),(Number.isInteger(p.lastConsumedMessageIndex)||p.lastConsumedMessageIndex===null)&&this.state.lastReadMessageIndex!==p.lastConsumedMessageIndex&&(this.state.lastReadMessageIndex=p.lastConsumedMessageIndex,y.push("lastReadMessageIndex")),p.lastConsumptionTimestamp){var S=new Date(p.lastConsumptionTimestamp);(!this.state.lastReadTimestamp||this.state.lastReadTimestamp.getTime()!==S.getTime())&&(this.state.lastReadTimestamp=S,y.push("lastReadTimestamp"))}return p.bindings&&!we.default(this.state.bindings,p.bindings)&&(this.state.bindings=p.bindings,y.push("bindings")),y.length>0&&this.emit(f.updated,{participant:this,updateReasons:y}),this}},{key:"getUser",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this.type=="chat"){b.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return b.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"remove",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"updateAttributes",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(g)});case 2:return w.abrupt("return",this);case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()}]),f}(I.ReplayEventEmitter);Pe.default(H,"typingStarted","typingStarted"),Pe.default(H,"typingEnded","typingEnded"),Pe.default(H,"updated","updated"),_e([_.validateTypesAsync(sr),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],H.prototype,"updateAttributes",null);function ie(O){var P=K();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}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 xe=Gt.scope("Participants"),Ce=function(O){He.default(f,O);var P=ie(f);function f(d,p,y,g){var b;return pe.default(this,f),b=P.call(this),Pe.default(Ue.default(b),"rosterEntityPromise",null),b.conversation=d,b.participants=p,b.links=y,b.services=g,b}return he.default(f,[{key:"unsubscribe",value:function(){var d=Y.default(M.default.mark(function y(){var g;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(!this.rosterEntityPromise){w.next=6;break}return w.next=3,this.rosterEntityPromise;case 3:g=w.sent,g.close(),this.rosterEntityPromise=null;case 6:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"subscribe",value:function(p){var y=this,g=typeof p=="string"?this.services.syncClient.map({id:p,mode:"open_existing"}):Promise.resolve(p);return this.rosterEntityPromise=this.rosterEntityPromise||g.then(function(b){b.on(J.SyncMap.itemAdded,function(T){xe.debug(y.conversation.sid+" itemAdded: "+T.item.key),y.upsertParticipant(T.item.key,T.item.data).then(function(F){y.emit(wt.participantJoined,F)})}),b.on(J.SyncMap.itemRemoved,function(T){xe.debug(y.conversation.sid+" itemRemoved: "+T.key);var F=T.key;if(y.participants.has(F)){var j=y.participants.get(F);y.participants.delete(F),j&&y.emit(wt.participantLeft,j)}}),b.on(J.SyncMap.itemUpdated,function(T){xe.debug(y.conversation.sid+" itemUpdated: "+T.item.key),y.upsertParticipant(T.item.key,T.item.data).catch(function(F){return xe.error(F)})});var w=[],S=function T(F){return F.items.forEach(function(j){w.push(y.upsertParticipant(j.key,j.data))}),F.hasNextPage?F.nextPage().then(T):null};return b.getItems().then(S).then(function(){return Promise.all(w)}).then(function(){return b})}).catch(function(b){throw y.rosterEntityPromise=null,y.services.syncClient.connectionState!="disconnected"&&xe.error("Failed to get roster object for conversation",y.conversation.sid,b),xe.debug("ERROR: Failed to get roster object for conversation",y.conversation.sid,b),b})}},{key:"upsertParticipantFromResponse",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T,F,j,V,W;return M.default.wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:return w=g.sid,S=g.attributes,T=g.date_created,F=g.date_updated,j=g.identity,V=g.role_sid,W=g.messaging_binding,ze.next=3,this.upsertParticipant(w,{attributes:S,dateCreated:new Date(T),dateUpdated:new Date(F),identity:j,roleSid:V,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:(b=W==null?void 0:W.type)!==null&&b!==void 0?b:"chat"});case 3:return ze.abrupt("return",ze.sent);case 4:case"end":return ze.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"upsertParticipant",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w=this,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(S=this.participants.get(g),!S){j.next=3;break}return j.abrupt("return",S._update(b));case 3:return T={self:"".concat(this.links.participants,"/").concat(g)},S=new H(b,g,this.conversation,T,this.services),this.participants.set(g,S),S.on(H.updated,function(V){return w.emit(wt.participantUpdated,V)}),j.abrupt("return",S);case 8:case"end":return j.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"getParticipants",value:function(){var d=Y.default(M.default.mark(function y(){var g=this;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var S=[];return g.participants.forEach(function(T){return S.push(T)}),S}):[]);case 1:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getParticipantBySid",value:function(){var d=Y.default(M.default.mark(function y(g){var b=this;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var T=b.participants.get(g);if(!T)throw new Error("Participant with SID "+g+" was not found");return T}):null);case 1:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getParticipantByIdentity",value:function(){var d=Y.default(M.default.mark(function y(g){var b=this,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return w=null,T.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){if(b.participants.forEach(function(F){F.identity===g&&(w=F)}),!w)throw new Error("Participant with identity "+g+" was not found");return w}):null);case 2:case"end":return T.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"add",value:function(){var d=Y.default(M.default.mark(function y(g,b){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:g,attributes:typeof b<"u"?JSON.stringify(b):void 0});case 2:return S.abrupt("return",S.sent);case 3:case"end":return S.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"addNonChatParticipant",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w,S,T,F,j=arguments;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:return T=j.length>2&&j[2]!==void 0?j[2]:{},F=j.length>3&&j[3]!==void 0?j[3]:{},W.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:typeof T<"u"?JSON.stringify(T):void 0,messaging_binding:{address:b,proxy_address:g,name:F==null||(w=F.email)===null||w===void 0?void 0:w.name,level:F==null||(S=F.email)===null||S===void 0?void 0:S.level}});case 4:return W.abrupt("return",W.sent);case 5:case"end":return W.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"remove",value:function(p){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(p)))}}]),f}(I.ReplayEventEmitter),We=function(){function O(P,f){var d;pe.default(this,O),Pe.default(this,"mcsMedia",null),this.services=f,P instanceof G.McsMedia&&(this.mcsMedia=P),this.state={sid:P.sid,category:P.category,filename:(d=P.filename)!==null&&d!==void 0?d:null,contentType:P.contentType,size:P.size}}return he.default(O,[{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 f=this;return new G.CancellablePromise(function(){var d=Y.default(M.default.mark(function p(y,g,b){var w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(S=f.mcsMedia?void 0:f._fetchMcsMedia(),T=(w=f.mcsMedia)===null||w===void 0?void 0:w.getContentUrl(),b(function(){S&&S.cancel(),T&&T.cancel()}),V.prev=3,T){V.next=9;break}return V.next=7,S;case 7:F=V.sent,T=F==null?void 0:F.getContentUrl();case 9:if(V.t0=y,!T){V.next=16;break}return V.next=13,T;case 13:V.t1=V.sent,V.next=17;break;case 16:V.t1=null;case 17:V.t2=V.t1,(0,V.t0)(V.t2),V.next=24;break;case 21:V.prev=21,V.t3=V.catch(3),g(V.t3);case 24:case"end":return V.stop()}},p,null,[[3,21]])}));return function(p,y,g){return d.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var f=this;return new G.CancellablePromise(function(){var d=Y.default(M.default.mark(function p(y,g,b){var w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return f.services.mcsClient===null&&g(new Error("Media Content Service is unavailable")),w=f.services.mcsClient.get(f.state.sid),b(function(){return w.cancel()}),T.prev=3,T.next=6,w;case 6:f.mcsMedia=T.sent,f.state=f.mcsMedia._state(),y(f.mcsMedia),T.next=14;break;case 11:T.prev=11,T.t0=T.catch(3),g(T.t0);case 14:case"end":return T.stop()}},p,null,[[3,11]])}));return function(p,y,g){return d.apply(this,arguments)}}())}},{key:"_state",value:function(){return this.state}}]),O}(),Be=function(){function O(P){pe.default(this,O),this.state=P}return he.default(O,[{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(f){this.state=f}},{key:"_isEquals",value:function(f){var d=this.total===f.total,p=this.sent===f.sent,y=this.delivered===f.delivered,g=this.read===f.read,b=this.undelivered===f.undelivered,w=this.failed===f.failed;return d&&p&&y&&g&&b&&w}}]),O}(),Ve=function(){function O(P,f,d,p){pe.default(this,O),this.state={prevToken:d,nextToken:p,source:f,items:P}}return he.default(O,[{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"))}}]),O}(),Ye=he.default(function O(P){pe.default(this,O),this.sid=P.sid,this.messageSid=P.message_sid,this.conversationSid=P.conversation_sid,this.channelMessageSid=P.channel_message_sid,this.participantSid=P.participant_sid,this.status=P.status||"queued",this.errorCode=P.error_code||0,this.dateCreated=P.date_created,this.dateUpdated=P.date_updated}),Qe=function(P){return P.map(function(f){var d,p,y,g,b=JSON.stringify(f);switch(f.type){case"QUICK_REPLY":return{type:"reply",title:f.title,id:(d=f.id)!==null&&d!==void 0?d:"",index:(p=f.index)!==null&&p!==void 0?p:0,rawData:b};case"PHONE_NUMBER":return{type:"phone",title:f.title,phone:(y=f.phone)!==null&&y!==void 0?y:"",rawData:b};case"URL":return{type:"url",title:f.title,url:(g=f.url)!==null&&g!==void 0?g:"",rawData:b};default:return{type:"other",rawData:b}}})},Ke=function(P,f){var d=JSON.stringify(f);switch(P){case"twilio/text":{var p=f;return{type:"text",body:p.body,rawData:d}}case"twilio/media":{var y=f;return{type:"media",body:y.body,media:y.media,rawData:d}}case"twilio/location":{var g=f;return{type:"location",longitude:g.longitude,latitude:g.latitude,label:g.label,rawData:d}}case"twilio/quick-reply":{var b=f;return{type:"quickReply",body:b.body,replies:b.actions,rawData:d}}case"twilio/call-to-action":{var w=f;return{type:"callToAction",body:w.body,actions:Qe(w.actions),rawData:d}}case"twilio/list-picker":{var S=f;return{type:"listPicker",body:S.body,button:S.button,items:S.items,rawData:d}}case"twilio/card":{var T,F,j=f;return{type:"card",title:j.title,subtitle:j.subtitle,media:(T=j.media)!==null&&T!==void 0?T:[],actions:Qe((F=j.actions)!==null&&F!==void 0?F:[]),rawData:d}}default:return{type:"other",rawData:d}}},Xe=function(P){for(var f=new Map,d=0,p=Object.entries(P);d<p.length;d++){var y=Q.default(p[d],2),g=y[0],b=y[1];f.set(g,Ke(g,b))}return f},Ze=function(){function O(P,f){pe.default(this,O),this.name=P,this.value=f}return he.default(O,[{key:"copyWithValue",value:function(f){return new O(this.name,f)}}]),O}(),at=he.default(function O(P){pe.default(this,O),this.sid=P.sid,this.friendlyName=P.friendly_name,this.variables=Object.entries(JSON.parse(P.variables)).map(function(f){var d=Q.default(f,2),p=d[0],y=d[1];return new Ze(p,y)}),this.variants=Xe(P.variants),this.dateCreated=new Date(P.date_created),this.dateUpdated=new Date(P.date_updated)});function yr(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function or(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?yr(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):yr(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function st(O){var P=Wr();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function Wr(){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 mn(O,P){bi(O,P),P.add(O)}function bi(O,P){if(P.has(O))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Vr(O,P,f){if(!P.has(O))throw new TypeError("attempted to get private field on non-instance");return f}var Xn=Gt.scope("Message"),Gr=r.XMLHttpRequest||{},gn=new WeakSet,_i=new WeakSet,ur=function(O){He.default(f,O);var P=st(f);function f(d,p,y,g,b,w){var S,T,F,j,V,W,Ie,ze;return pe.default(this,f),ze=P.call(this),mn(Ue.default(ze),_i),mn(Ue.default(ze),gn),ze.conversation=y,ze.links=g,ze.configuration=b,ze.services=w,ze.state={sid:p.sid,index:d,author:p.author,subject:p.subject,contentSid:p.contentSid,body:(S=p.text)!==null&&S!==void 0?S:null,timestamp:p.timestamp?new Date(p.timestamp):null,dateUpdated:p.dateUpdated?new Date(p.dateUpdated):null,lastUpdatedBy:(T=p.lastUpdatedBy)!==null&&T!==void 0?T:null,attributes:Mt(p.attributes,"Got malformed attributes for the message ".concat(p.sid),Xn),type:(F=p.type)!==null&&F!==void 0?F:"text",media:null,medias:null,participantSid:(j=p.memberSid)!==null&&j!==void 0?j:null,aggregatedDeliveryReceipt:p.delivery?new Be(p.delivery):null,hasChannelMetadata:(V=p.channelMetadata)!==null&&V!==void 0?V:!1},Vr(Ue.default(ze),_i,Zi).call(Ue.default(ze),(W=p.medias)!==null&&W!==void 0?W:null,(Ie=p.media)!==null&&Ie!==void 0?Ie:null),ze}return he.default(f,[{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(p){return this.getMediaByCategories(p)}},{key:"getMediaByCategories",value:function(p){var y;return((y=this.state.medias)!==null&&y!==void 0?y:[]).filter(function(g){return p.includes(g.category)})}},{key:"getEmailBody",value:function(){var p,y,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(p=(y=this.getMediaByCategories(["body"]))===null||y===void 0?void 0:y.filter(function(b){return b.contentType==g}).shift())!==null&&p!==void 0?p:null}},{key:"getEmailHistory",value:function(){var p,y,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(p=(y=this.getMediaByCategories(["history"]))===null||y===void 0?void 0:y.filter(function(b){return b.contentType==g}).shift())!==null&&p!==void 0?p:null}},{key:"_update",value:function(p){var y,g=this,b,w,S,T=[];(p.text||typeof p.text=="string")&&p.text!==this.state.body&&(this.state.body=p.text,T.push("body")),p.subject&&p.subject!==this.state.subject&&(this.state.subject=p.subject,T.push("subject")),p.lastUpdatedBy&&p.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=p.lastUpdatedBy,T.push("lastUpdatedBy")),p.author&&p.author!==this.state.author&&(this.state.author=p.author,T.push("author")),p.dateUpdated&&new Date(p.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(p.dateUpdated),T.push("dateUpdated")),p.timestamp&&new Date(p.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(p.timestamp),T.push("dateCreated"));var F=Mt(p.attributes,"Got malformed attributes for the message ".concat(this.sid),Xn);we.default(this.state.attributes,F)||(this.state.attributes=F,T.push("attributes"));var j=p.delivery,V=this.state.aggregatedDeliveryReceipt,W=!!j&&!!j.total&&!!j.delivered&&!!j.failed&&!!j.read&&!!j.sent&&!!j.undelivered;W&&(V?V._isEquals(j)||(V._update(j),T.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new Be(j),T.push("deliveryReceipt")));var Ie=((y=p.medias)!==null&&y!==void 0?y:[]).map(function(Tt){var mt;return(mt=Vr(g,gn,xn).call(g,Tt))===null||mt===void 0?void 0:mt._state()}).filter(function(Tt){return Tt!==null}),ze=((b=this.state.medias)!==null&&b!==void 0?b:[]).map(function(Tt){return Tt._state()}).filter(function(Tt){return Tt!==null});if(!we.default(Ie,ze)||!we.default((w=Vr(this,gn,xn).call(this,p.media))===null||w===void 0?void 0:w._state(),(S=this.state.media)===null||S===void 0?void 0:S._state())){var je,qe;Vr(this,_i,Zi).call(this,(je=p.medias)!==null&&je!==void 0?je:null,(qe=p.media)!==null&&qe!==void 0?qe:null),T.push("media")}T.length>0&&this.emit("updated",{message:this,updateReasons:T})}},{key:"getParticipant",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(b=null,!this.state.participantSid){T.next=5;break}return T.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch(function(){return Xn.debug('Participant with sid "'.concat(g.participantSid,'" not found for message ').concat(g.sid)),null});case 4:b=T.sent;case 5:if(!(!b&&this.state.author)){T.next=9;break}return T.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch(function(){return Xn.debug('Participant with identity "'.concat(g.author,'" not found for message ').concat(g.sid)),null});case 8:b=T.sent;case 9:if(!b){T.next=11;break}return T.abrupt("return",b);case 11:throw w="Participant with ",this.state.participantSid&&(w+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(w+="or "),w+="identity '"+this.state.author+"' "),w==="Participant with "&&(w="Participant "),w+="was not found",new Error(w);case 17:case"end":return T.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getDetailedDeliveryReceipts",value:function(){var d=Y.default(M.default.mark(function y(){var g,b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:g=S.sent,b=g.items;case 4:if(!g.hasNextPage){S.next=11;break}return S.next=7,g.nextPage();case 7:g=S.sent,b=[].concat(De.default(b),De.default(g.items)),S.next=4;break;case 11:return S.abrupt("return",b);case 12:case"end":return S.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"remove",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return b.abrupt("return",this);case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"updateBody",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:g});case 2:return w.abrupt("return",this);case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"updateAttributes",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:typeof g<"u"?JSON.stringify(g):void 0});case 2:return w.abrupt("return",this);case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"attachTemporaryUrlsFor",value:function(){var d=Y.default(M.default.mark(function y(g){var b=this,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(w=g==null?void 0:g.map(function(F){return F.sid}),!(this.services.mcsClient&&w)){T.next=7;break}return T.next=4,this.services.mcsClient.mediaSetGet(w);case 4:return T.abrupt("return",T.sent.map(function(F){return new We(F,b.services)}));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return T.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getTemporaryContentUrlsForMedia",value:function(p){var y=p.map(function(g){return g.sid});return this.getTemporaryContentUrlsForMediaSids(y)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(p){var y=this;return new G.CancellablePromise(function(){var g=Y.default(M.default.mark(function b(w,S,T){var F,j;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(F=y.services.mcsClient.mediaSetGetContentUrls(p??[]),!(!y.services.mcsClient||!p)){W.next=4;break}return S(new Error("Media Content Service is unavailable")),W.abrupt("return");case 4:return T(function(){F.cancel()}),W.prev=5,W.next=8,F;case 8:j=W.sent,w(j),W.next=15;break;case 12:W.prev=12,W.t0=W.catch(5),S(W.t0);case 15:case"end":return W.stop()}},b,null,[[5,12]])}));return function(b,w,S){return g.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var p,y=this.attachedMedia,g=(p=y==null?void 0:y.map(function(b){return b.sid}))!==null&&p!==void 0?p:[];return this.getTemporaryContentUrlsForMediaSids(g)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:function(){var d=Y.default(M.default.mark(function y(g){var b=this,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return w=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),S=new It(w).arg("PageToken",g==null?void 0:g.pageToken).arg("PageSize",g==null?void 0:g.pageSize).build(),j.next=4,this.services.network.get(S);case 4:return T=j.sent,j.abrupt("return",new Ve(T.body.delivery_receipts.map(function(V){return new Ye(V)}),function(V,W){return b._getDetailedDeliveryReceiptsPaginator({pageToken:V,pageSize:W})},T.body.meta.previous_token,T.body.meta.next_token));case 6:case"end":return j.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getContentData",value:function(){var p=this;return new G.CancellablePromise(function(){var y=Y.default(M.default.mark(function g(b,w,S){var T,F,j,V,W,Ie,ze,je,qe,Tt;return M.default.wrap(function(nt){for(;;)switch(nt.prev=nt.next){case 0:if(p.state.contentSid!==null){nt.next=3;break}return b(null),nt.abrupt("return");case 3:if(T=p.getMediaByCategories(["body"]),T!==null){nt.next=7;break}return b(null),nt.abrupt("return");case 7:if(F="application/x-vnd.com.twilio.rich.",j=T.filter(function(er){return er.contentType.startsWith(F)}),j.length!==0){nt.next=12;break}return b(null),nt.abrupt("return");case 12:return V=j[0],W=V.getContentTemporaryUrl(),S(function(){W.cancel()}),nt.prev=15,nt.next=18,W;case 18:Ie=nt.sent,nt.next=25;break;case 21:return nt.prev=21,nt.t0=nt.catch(15),w(nt.t0),nt.abrupt("return");case 25:if(Ie!==null){nt.next=28;break}return b(null),nt.abrupt("return");case 28:return ze=new Promise(function(er,ei){var tt,ti=!1,bn=new Gr;bn.open("GET",(tt=Ie)!==null&&tt!==void 0?tt:"",!0),bn.responseType="text",bn.onreadystatechange=function(){bn.readyState!==4||ti||er(bn.responseText)},bn.onerror=function(){ei(bn.statusText)},S(function(){ti=!0,bn.abort(),ei(new Error("XHR has been aborted"))}),bn.send()}),nt.prev=29,nt.next=32,ze;case 32:qe=nt.sent,je=JSON.parse(qe),nt.next=40;break;case 36:return nt.prev=36,nt.t1=nt.catch(29),w(nt.t1),nt.abrupt("return");case 40:Tt=V.contentType.replace(F,"").replace(".","/"),b(Ke(Tt,je.data));case 42:case"end":return nt.stop()}},g,null,[[15,21],[29,36]])}));return function(g,b,w){return y.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this.state.hasChannelMetadata){b.next=2;break}return b.abrupt("return",null);case 2:return b.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return b.abrupt("return",b.sent);case 5:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getMessageRecipients",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid,this.sid);case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()}]),f}(I.ReplayEventEmitter);function xn(O){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return O?P?new We(or(or({},O),{},{category:P}),this.services):new We(O,this.services):null}function Zi(O,P){var f=this;this.state.media=Vr(this,gn,xn).call(this,P),this.state.medias=O?O.map(function(d){return Vr(f,gn,xn).call(f,d)}).filter(function(d){return d!==null}):P&&!O?[Vr(this,gn,xn).call(this,P,"media")].filter(function(d){return d!==null}):null}Pe.default(ur,"updated","updated"),_e([L.deprecated("getMediaByCategory","getMediaByCategories"),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",Array)],ur.prototype,"getMediaByCategory",null),_e([_.validateTypes([_.nonEmptyString,"undefined"]),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",We)],ur.prototype,"getEmailBody",null),_e([_.validateTypes([_.nonEmptyString,"undefined"]),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",We)],ur.prototype,"getEmailHistory",null),_e([_.validateTypesAsync("string"),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],ur.prototype,"updateBody",null),_e([_.validateTypesAsync(sr),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],ur.prototype,"updateAttributes",null),_e([L.deprecated("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",Promise)],ur.prototype,"attachTemporaryUrlsFor",null),_e([_.validateTypesAsync(_.nonEmptyArray("media",We)),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",G.CancellablePromise)],ur.prototype,"getTemporaryContentUrlsForMedia",null),_e([_.validateTypesAsync(_.nonEmptyArray("strings","string")),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",G.CancellablePromise)],ur.prototype,"getTemporaryContentUrlsForMediaSids",null);function nn(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function ea(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?nn(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):nn(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function wi(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=Hr(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
459
459
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function Hr(O,P){if(O){if(typeof O=="string")return ta(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return ta(O,P)}}function ta(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}function Aa(O){var P=Ma();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function Ma(){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 fr=Gt.scope("Messages"),xa=function(O){He.default(f,O);var P=Aa(f);function f(d,p,y){var g;return pe.default(this,f),g=P.call(this),g.conversation=d,g.configuration=p,g.services=y,g.messagesByIndex=new Map,g.messagesListPromise=null,g}return he.default(f,[{key:"subscribe",value:function(){var d=Y.default(M.default.mark(function y(g){var b=this,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(!this.messagesListPromise){T.next=2;break}return T.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise=typeof g=="string"?this.services.syncClient.list({id:g,mode:"open_existing"}):Promise.resolve(g),T.prev=3,T.next=6,this.messagesListPromise;case 6:return w=T.sent,w.on("itemAdded",function(F){fr.debug("".concat(b.conversation.sid," itemAdded: ").concat(F.item.index));var j={self:"".concat(b.conversation._links.messages,"/").concat(F.item.data.sid),conversation:b.conversation._links.self,messages_receipts:"".concat(b.conversation._links.messages,"/").concat(F.item.data.sid,"/Receipts")},V=new ur(F.item.index,F.item.data,b.conversation,j,b.configuration,b.services);if(b.messagesByIndex.has(V.index)){fr.debug("Message arrived, but is already known and ignored",b.conversation.sid,V.index);return}b.messagesByIndex.set(V.index,V),V.on("updated",function(W){return b.emit("messageUpdated",W)}),b.emit("messageAdded",V)}),w.on("itemRemoved",function(F){fr.debug("#{this.conversation.sid} itemRemoved: ".concat(F.index));var j=F.index;if(b.messagesByIndex.has(j)){var V=b.messagesByIndex.get(j);if(!V)return;b.messagesByIndex.delete(V.index),V.removeAllListeners("updated"),b.emit("messageRemoved",V)}}),w.on("itemUpdated",function(F){fr.debug("".concat(b.conversation.sid," itemUpdated: ").concat(F.item.index));var j=b.messagesByIndex.get(F.item.index);j&&j._update(F.item.data)}),T.abrupt("return",w);case 13:throw T.prev=13,T.t0=T.catch(3),this.messagesListPromise=null,this.services.syncClient.connectionState!=="disconnected"&&fr.error("Failed to get messages object for conversation",this.conversation.sid,T.t0),fr.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,T.t0),T.t0;case 19:case"end":return T.stop()}},y,this,[[3,13]])}));function p(y){return d.apply(this,arguments)}return p}()},{key:"unsubscribe",value:function(){var d=Y.default(M.default.mark(function y(){var g;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(this.messagesListPromise){w.next=2;break}return w.abrupt("return");case 2:return w.next=4,this.messagesListPromise;case 4:g=w.sent,g.close(),this.messagesListPromise=null;case 7:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"sendV2",value:function(p){var y=this;return fr.debug("Sending message V2",p.mediaContent,p.attributes,p.emailOptions),new G.CancellablePromise(function(){var g=Y.default(M.default.mark(function b(w,S,T){var F,j,V,W,Ie,ze,je,qe,Tt,mt,nt,er;return M.default.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:j=[],V=[],T(function(){V.forEach(function(ti){return ti.cancel()})}),W=wi(p.mediaContent),tt.prev=4,W.s();case 6:if((Ie=W.n()).done){tt.next=25;break}return ze=Q.default(Ie.value,2),je=ze[0],qe=ze[1],tt.prev=8,fr.debug("Adding media to a message as ".concat(qe instanceof FormData?"FormData":"SendMediaOptions"),qe),nt=qe instanceof FormData?y.services.mcsClient.postFormData(qe,je):y.services.mcsClient.post((Tt=qe.contentType)!==null&&Tt!==void 0?Tt:"",(mt=qe.media)!==null&&mt!==void 0?mt:"",je,qe.filename),V.push(nt),tt.t0=j,tt.next=15,nt;case 15:tt.t1=tt.sent,tt.t0.push.call(tt.t0,tt.t1),tt.next=23;break;case 19:return tt.prev=19,tt.t2=tt.catch(8),S(tt.t2),tt.abrupt("return");case 23:tt.next=6;break;case 25:tt.next=30;break;case 27:tt.prev=27,tt.t3=tt.catch(4),W.e(tt.t3);case 30:return tt.prev=30,W.f(),tt.finish(30);case 33:return er=y.services.commandExecutor.mutateResource("post",y.conversation._links.messages,{body:p.text,subject:(F=p.emailOptions)===null||F===void 0?void 0:F.subject,media_sids:j.map(function(ti){return ti.sid}),attributes:typeof p.attributes<"u"?JSON.stringify(p.attributes):void 0,content_sid:p.contentSid,content_variables:typeof p.contentVariables<"u"?JSON.stringify(p.contentVariables.reduce(function(ti,bn){return ea(ea({},ti),{},Pe.default({},bn.name,bn.value))},{})):void 0}),tt.prev=34,tt.t4=w,tt.next=38,er;case 38:tt.t5=tt.sent,(0,tt.t4)(tt.t5),tt.next=45;break;case 42:tt.prev=42,tt.t6=tt.catch(34),S(tt.t6);case 45:case"end":return tt.stop()}},b,null,[[4,27,30,33],[8,19],[34,42]])}));return function(b,w,S){return g.apply(this,arguments)}}())}},{key:"send",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S=arguments;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return b=S.length>1&&S[1]!==void 0?S[1]:{},w=S.length>2?S[2]:void 0,fr.debug("Sending text message",g,b,w),F.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:g??"",attributes:typeof b<"u"?JSON.stringify(b):void 0,subject:w==null?void 0:w.subject}));case 4:case"end":return F.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"sendMedia",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T,F,j=arguments;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(S=j.length>1&&j[1]!==void 0?j[1]:{},T=j.length>2?j[2]:void 0,fr.debug("Sending media message",g,S,T),fr.debug("Sending media message as ".concat(g instanceof FormData?"FormData":"SendMediaOptions"),g,S),!(g instanceof FormData)){W.next=10;break}return W.next=7,this.services.mcsClient.postFormData(g);case 7:W.t0=W.sent,W.next=13;break;case 10:return W.next=12,this.services.mcsClient.post((b=g.contentType)!==null&&b!==void 0?b:"",(w=g.media)!==null&&w!==void 0?w:"","media",g.filename);case 12:W.t0=W.sent;case 13:return F=W.t0,W.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[F.sid],attributes:typeof S<"u"?JSON.stringify(S):void 0});case 16:return W.abrupt("return",W.sent);case 17:case"end":return W.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getMessages",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w,S=arguments;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return w=S.length>2&&S[2]!==void 0?S[2]:"backwards",F.abrupt("return",this._getMessages(g,b,w));case 2:case"end":return F.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"_wrapPaginator",value:function(p,y,g){var b=this,w=p==="desc",S=function(){return y.nextPage().then(function(j){return b._wrapPaginator(p,j,g)})},T=function(){return y.prevPage().then(function(j){return b._wrapPaginator(p,j,g)})};return g(y.items).then(function(F){return{items:F.sort(function(j,V){return j.index-V.index}),hasPrevPage:w?y.hasNextPage:y.hasPrevPage,hasNextPage:w?y.hasPrevPage:y.hasNextPage,prevPage:w?S:T,nextPage:w?T:S}})}},{key:"_upsertMessage",value:function(p,y){var g=this,b=this.messagesByIndex.get(p);if(b)return b;var w={self:"".concat(this.conversation._links.messages,"/").concat(y.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(y.sid,"/Receipts")},S=new ur(p,y,this.conversation,w,this.configuration,this.services);return this.messagesByIndex.set(S.index,S),S.on("updated",function(T){return g.emit("messageUpdated",T)}),S}},{key:"_getMessages",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b,w,S,T,F,j,V=arguments;return M.default.wrap(function(Ie){for(;;)switch(Ie.prev=Ie.next){case 0:return b=V.length>0&&V[0]!==void 0?V[0]:30,w=V.length>1&&V[1]!==void 0?V[1]:"end",S=V.length>2&&V[2]!==void 0?V[2]:"forward",T=S==="backwards"?"desc":"asc",Ie.next=6,this.messagesListPromise;case 6:return F=Ie.sent,Ie.next=9,F==null?void 0:F.getItems({from:w!=="end"?w:void 0,pageSize:b,order:T,limit:b});case 9:return j=Ie.sent,Ie.next=12,this._wrapPaginator(T,j,function(ze){return Promise.all(ze.map(function(je){return g._upsertMessage(je.index,je.data)}))});case 12:return Ie.abrupt("return",Ie.sent);case 13:case"end":return Ie.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()}]),f}(I.ReplayEventEmitter),Qn=function(){function O(P){pe.default(this,O),Pe.default(this,"attributes",{}),Pe.default(this,"mediaContent",[]),Pe.default(this,"emailOptions",{}),this.messagesEntity=P}return he.default(O,[{key:"send",value:function(){var f=this;return new G.CancellablePromise(function(){var d=Y.default(M.default.mark(function p(y,g,b){var w,S;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return w=f.messagesEntity.sendV2(f),b(function(){return w.cancel()}),F.prev=2,F.next=5,w;case 5:S=F.sent,y(yt(S.index)),F.next=12;break;case 9:F.prev=9,F.t0=F.catch(2),g(F.t0);case 12:case"end":return F.stop()}},p,null,[[2,9]])}));return function(p,y,g){return d.apply(this,arguments)}}())}}]),O}(),Yt=function(){function O(P,f){pe.default(this,O),this.limits=P,this.message=new Qn(f),this.emailBodies=new Map,this.emailHistories=new Map}return he.default(O,[{key:"setBody",value:function(f){return this.message.text=f,this}},{key:"setSubject",value:function(f){return this.message.emailOptions.subject=f,this}},{key:"setAttributes",value:function(f){return this.message.attributes=f,this}},{key:"setEmailBody",value:function(f,d){return this.emailBodies.set(f,d),this}},{key:"setEmailHistory",value:function(f,d){return this.emailHistories.set(f,d),this}},{key:"setContentTemplate",value:function(f){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return this.message.contentSid=f,this.message.contentVariables=d,this}},{key:"addMedia",value:function(f){if(typeof FormData>"u"&&f instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(f instanceof FormData)){var d=f;if(!d.contentType||!d.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",f]),this}},{key:"build",value:function(){var f=this;if(this.emailBodies.forEach(function(d,p){if(!f.limits.emailBodiesAllowedContentTypes.includes(p))throw new Error("Unsupported email body content type ".concat(p))}),this.emailHistories.forEach(function(d,p){if(!f.limits.emailHistoriesAllowedContentTypes.includes(p))throw new Error("Unsupported email history content type ".concat(p))}),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(d){f.message.mediaContent.push(["body",d])}),this.emailHistories.forEach(function(d){f.message.mediaContent.push(["history",d])}),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),O}();_e([_.validateTypes("string"),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Yt)],Yt.prototype,"setBody",null),_e([_.validateTypes("string"),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Yt)],Yt.prototype,"setSubject",null),_e([_.validateTypes(sr),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Yt)],Yt.prototype,"setAttributes",null),_e([_.validateTypes("string",[FormData,tn]),le("design:type",Function),le("design:paramtypes",[String,Object]),le("design:returntype",Yt)],Yt.prototype,"setEmailBody",null),_e([_.validateTypes("string",[FormData,tn]),le("design:type",Function),le("design:paramtypes",[String,Object]),le("design:returntype",Yt)],Yt.prototype,"setEmailHistory",null),_e([_.validateTypes("string",[_.array("content variables",Ze),"undefined"]),le("design:type",Function),le("design:paramtypes",[String,Array]),le("design:returntype",Yt)],Yt.prototype,"setContentTemplate",null),_e([_.validateTypes([FormData,tn]),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Yt)],Yt.prototype,"addMedia",null);function Na(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=an(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
460
460
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function an(O,P){if(O){if(typeof O=="string")return Si(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return Si(O,P)}}function Si(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}function Ci(O){var P=La();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function La(){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 sn={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"},wt=function(O){He.default(f,O);var P=Ci(f);function f(d,p,y,g,b){var w,S,T;pe.default(this,f),T=P.call(this),T.sid=p,T._links=y,T._configuration=g,T._services=b,T._entityName=d.channel,T._internalState={uniqueName:d.uniqueName||null,status:"notParticipating",attributes:(w=d.attributes)!==null&&w!==void 0?w:{},createdBy:d.createdBy,dateCreated:it(d.dateCreated),dateUpdated:it(d.dateUpdated),friendlyName:d.friendlyName||null,lastReadMessageIndex:Number.isInteger(d.lastConsumedMessageIndex)?d.lastConsumedMessageIndex:null,bindings:(S=d.bindings)!==null&&S!==void 0?S:{}},d.notificationLevel&&(T._internalState.notificationLevel=d.notificationLevel);var F={participants:T._links.participants};return T._participants=new Map,T._participantsEntity=new Ce(Ue.default(T),T._participants,F,T._services),T._participantsEntity.on(f.participantJoined,function(j){return T.emit(f.participantJoined,j)}),T._participantsEntity.on(f.participantLeft,function(j){return T.emit(f.participantLeft,j)}),T._participantsEntity.on(f.participantUpdated,function(j){return T.emit(f.participantUpdated,j)}),T._messagesEntity=new xa(Ue.default(T),g,b),T._messagesEntity.on(f.messageAdded,function(j){return T._onMessageAdded(j)}),T._messagesEntity.on(f.messageUpdated,function(j){return T.emit(f.messageUpdated,j)}),T._messagesEntity.on(f.messageRemoved,function(j){return T.emit(f.messageRemoved,j)}),T}return he.default(f,[{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 p;return(p=this._internalState.createdBy)!==null&&p!==void 0?p:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var p;return(p=this._internalState.lastMessage)!==null&&p!==void 0?p:void 0}},{key:"notificationLevel",get:function(){var p;return(p=this._internalState.notificationLevel)!==null&&p!==void 0?p:"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 d=Y.default(M.default.mark(function y(g,b){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.abrupt("return",this._participantsEntity.add(g,b??{}));case 1:case"end":return S.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"addNonChatParticipant",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w,S,T=arguments;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return w=T.length>2&&T[2]!==void 0?T[2]:{},S=T.length>3&&T[3]!==void 0?T[3]:{},j.abrupt("return",this._participantsEntity.addNonChatParticipant(g,b,w??{},S??{}));case 3:case"end":return j.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"advanceLastReadMessageIndex",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._subscribeStreams();case 2:if(!(g<((b=this.lastReadMessageIndex)!==null&&b!==void 0?b:0))){S.next=6;break}return S.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:return S.abrupt("return",S.sent);case 6:return S.next=8,this._setLastReadMessageIndex(g);case 8:return S.abrupt("return",S.sent);case 9:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"delete",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return b.abrupt("return",this);case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getAttributes",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._subscribe();case 2:return b.abrupt("return",this.attributes);case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getMessages",value:function(){var d=Y.default(M.default.mark(function y(g,b,w){return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._subscribeStreams();case 2:return T.abrupt("return",this._messagesEntity.getMessages(g,b,w));case 3:case"end":return T.stop()}},y,this)}));function p(y,g,b){return d.apply(this,arguments)}return p}()},{key:"getParticipants",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._subscribeStreams();case 2:return b.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getParticipantsCount",value:function(){var d=Y.default(M.default.mark(function y(){var g,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return b=new It(this._configuration.links.conversations).path(this.sid).build(),T.next=3,this._services.network.get(b);case 3:return w=T.sent,T.abrupt("return",(g=w.body.participants_count)!==null&&g!==void 0?g:0);case 5:case"end":return T.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getParticipantBySid",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.abrupt("return",this._participantsEntity.getParticipantBySid(g));case 1:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getParticipantByIdentity",value:function(){var d=Y.default(M.default.mark(function y(){var g,b=arguments;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=b.length>0&&b[0]!==void 0?b[0]:"",S.abrupt("return",this._participantsEntity.getParticipantByIdentity(g??""));case 2:case"end":return S.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getMessagesCount",value:function(){var d=Y.default(M.default.mark(function y(){var g,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return b=new It(this._configuration.links.conversations).path(this.sid).build(),T.next=3,this._services.network.get(b);case 3:return w=T.sent,T.abrupt("return",(g=w.body.messages_count)!==null&&g!==void 0?g:0);case 5:case"end":return T.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getUnreadMessagesCount",value:function(){var d=Y.default(M.default.mark(function y(){var g,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return g=new It(this._configuration.links.myConversations).path(this.sid).build(),T.next=3,this._services.network.get(g);case 3:if(b=T.sent,b.body.conversation_sid===this.sid){T.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if(w=b.body.unread_messages_count,typeof w!="number"){T.next=9;break}return T.abrupt("return",w);case 9:return T.abrupt("return",null);case 10:case"end":return T.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"join",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return b.abrupt("return",this);case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"leave",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this._internalState.status!=="joined"){b.next=3;break}return b.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return b.abrupt("return",this);case 4:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"removeParticipant",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._participantsEntity.remove(typeof g=="string"?g:g.sid);case 2:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"sendMessage",value:function(){var d=Y.default(M.default.mark(function y(g,b,w){var S,T,F,j;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(!(typeof g=="string"||g===null)){W.next=5;break}return W.next=3,this._messagesEntity.send(g,b,w);case 3:return F=W.sent,W.abrupt("return",(T=yt(F.index))!==null&&T!==void 0?T:0);case 5:return W.next=7,this._messagesEntity.sendMedia(g,b,w);case 7:return j=W.sent,W.abrupt("return",(S=yt(j.index))!==null&&S!==void 0?S:0);case 9:case"end":return W.stop()}},y,this)}));function p(y,g,b){return d.apply(this,arguments)}return p}()},{key:"prepareMessage",value:function(){return new Yt(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:function(){var d=Y.default(M.default.mark(function y(){var g;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._subscribeStreams();case 2:return w.next=4,this.getMessages(1);case 4:if(g=w.sent,!(g.items.length>0)){w.next=7;break}return w.abrupt("return",this.advanceLastReadMessageIndex(g.items[0].index));case 7:return w.abrupt("return",0);case 8:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"setAllMessagesUnread",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._subscribeStreams();case 2:return b.next=4,this._setLastReadMessageIndex(null);case 4:return b.abrupt("return",b.sent);case 5:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"setUserNotificationLevel",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:g});case 2:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:g!==void 0?JSON.stringify(g):void 0});case 2:return w.abrupt("return",this);case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"updateFriendlyName",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(this._internalState.friendlyName===g){w.next=3;break}return w.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:g});case 3:return w.abrupt("return",this);case 4:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"updateLastReadMessageIndex",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._subscribeStreams();case 2:return w.abrupt("return",this._setLastReadMessageIndex(g));case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"updateUniqueName",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(this._internalState.uniqueName===g){w.next=4;break}return g||(g=""),w.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:g});case 4:return w.abrupt("return",this);case 5:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getMessageRecipients",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,g);case 2:return w.abrupt("return",w.sent);case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"_subscribe",value:function(){var d=Y.default(M.default.mark(function y(){var g=this;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(!this._entityPromise){w.next=2;break}return w.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),w.prev=3,w.next=6,this._entityPromise;case 6:return this._entity=w.sent,this._entity.on(J.SyncDocument.updated,function(S){return g._update(S.data)}),this._entity.on(J.SyncDocument.removed,function(){return g.emit(f.removed,g)}),this._update(this._entity.data),w.abrupt("return",this._entity);case 13:throw w.prev=13,w.t0=w.catch(3),this._entity=null,this._entityPromise=null,this._services.syncClient.connectionState!="disconnected"&&f._logger.error("Failed to get conversation object",w.t0),f._logger.debug("ERROR: Failed to get conversation object",w.t0),w.t0;case 20:case"end":return w.stop()}},y,this,[[3,13]])}));function p(){return d.apply(this,arguments)}return p}()},{key:"_fetchStreams",value:function(){var d=Y.default(M.default.mark(function y(){var g,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._subscribe();case 2:return f._logger.trace("_streamsAvailable, this.entity.data=",(g=this._entity)===null||g===void 0?void 0:g.data),w=(b=this._entity)===null||b===void 0?void 0:b.data,T.next=6,this._services.syncClient.list({id:w.messages,mode:"open_existing"});case 6:return this._messagesList=T.sent,T.next=9,this._services.syncClient.map({id:w.roster,mode:"open_existing"});case 9:this._participantsMap=T.sent;case 10:case"end":return T.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_subscribeStreams",value:function(){var d=Y.default(M.default.mark(function y(){var g,b,w,S,T,F,j;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:return W.prev=0,W.next=3,this._subscribe();case 3:return f._logger.trace("_subscribeStreams, this.entity.data=",(g=this._entity)===null||g===void 0?void 0:g.data),T=(b=this._entity)===null||b===void 0?void 0:b.data,F=T.messages,j=T.roster,W.next=9,Promise.all([this._messagesEntity.subscribe((w=this._messagesList)!==null&&w!==void 0?w:F),this._participantsEntity.subscribe((S=this._participantsMap)!==null&&S!==void 0?S:j)]);case 9:W.next=16;break;case 11:throw W.prev=11,W.t0=W.catch(0),this._services.syncClient.connectionState!=="disconnected"&&f._logger.error("Failed to subscribe on conversation objects",this.sid,W.t0),f._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,W.t0),W.t0;case 16:case"end":return W.stop()}},y,this,[[0,11]])}));function p(){return d.apply(this,arguments)}return p}()},{key:"_unsubscribe",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),b.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_setStatus",value:function(p,y){var g=this;if(this._dataSource=y,this._internalState.status!==p){if(this._internalState.status=p,p==="joined"){this._subscribeStreams().catch(function(b){if(f._logger.debug("ERROR while setting conversation status "+p,b),g._services.syncClient.connectionState!=="disconnected")throw b});return}this._entityPromise&&this._unsubscribe().catch(function(b){if(f._logger.debug("ERROR while setting conversation status "+p,b),g._services.syncClient.connectionState!=="disconnected")throw b})}}},{key:"_update",value:function(p){var y,g,b,w,S;f._logger.trace("_update",p),f.preprocessUpdate(p,this.sid);for(var T=new Set,F=0,j=Object.keys(p);F<j.length;F++){var V=j[F],W=sn[V];if(W)switch(W){case sn.status:if(!p.status||p.status==="unknown"||this._internalState.status===p.status)break;this._internalState.status=p.status,T.add(W);break;case sn.attributes:if(we.default(this._internalState.attributes,p.attributes))break;this._internalState.attributes=p.attributes,T.add(W);break;case sn.lastConsumedMessageIndex:if(p.lastConsumedMessageIndex===void 0||p.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=p.lastConsumedMessageIndex,T.add("lastReadMessageIndex");break;case sn.lastMessage:if(this._internalState.lastMessage&&!p.lastMessage){delete this._internalState.lastMessage,T.add(W);break}this._internalState.lastMessage=this._internalState.lastMessage||{},((y=p.lastMessage)===null||y===void 0?void 0:y.index)!==void 0&&p.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=p.lastMessage.index,T.add(W)),((g=p.lastMessage)===null||g===void 0?void 0:g.timestamp)!==void 0&&((b=this._internalState.lastMessage)===null||b===void 0||(w=b.dateCreated)===null||w===void 0?void 0:w.getTime())!==p.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=p.lastMessage.timestamp,T.add(W)),we.default(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case sn.state:var Ie=p.state||void 0;if(Ie!==void 0&&(Ie.dateUpdated=new Date(Ie.dateUpdated)),we.default(this._internalState.state,Ie))break;this._internalState.state=Ie,T.add(W);break;case sn.bindings:if(we.default(this._internalState.bindings,p.bindings))break;this._internalState.bindings=p.bindings,T.add(W);break;default:var ze=p[V]instanceof Date,je=ze&&((S=this._internalState[W])===null||S===void 0?void 0:S.getTime())===p[V].getTime(),qe=!ze&&this[W]===p[V];if(je||qe)break;this._internalState[W]=p[V],T.add(W)}}T.size>0&&this.emit(f.updated,{conversation:this,updateReasons:De.default(T)})}},{key:"_onMessageAdded",value:function(p){var y=Na(this._participants.values()),g;try{for(y.s();!(g=y.n()).done;){var b=g.value;if(b.identity===p.author){b._endTyping();break}}}catch(w){y.e(w)}finally{y.f()}this.emit(f.messageAdded,p)}},{key:"_setLastReadMessageIndex",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:g});case 2:return b=S.sent,S.abrupt("return",b.unread_messages_count);case 4:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()}],[{key:"preprocessUpdate",value:function(p,y){try{typeof p.attributes=="string"?p.attributes=JSON.parse(p.attributes):p.attributes&&JSON.stringify(p.attributes)}catch{f._logger.warn("Retrieved malformed attributes from the server for conversation: "+y),p.attributes={}}try{p.dateCreated&&(p.dateCreated=new Date(p.dateCreated))}catch{f._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+y),delete p.dateCreated}try{p.dateUpdated&&(p.dateUpdated=new Date(p.dateUpdated))}catch{f._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+y),delete p.dateUpdated}try{p.lastMessage&&p.lastMessage.timestamp&&(p.lastMessage.timestamp=new Date(p.lastMessage.timestamp))}catch{f._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+y),delete p.lastMessage.timestamp}}}]),f}(I.ReplayEventEmitter);Pe.default(wt,"participantJoined","participantJoined"),Pe.default(wt,"participantLeft","participantLeft"),Pe.default(wt,"participantUpdated","participantUpdated"),Pe.default(wt,"messageAdded","messageAdded"),Pe.default(wt,"messageRemoved","messageRemoved"),Pe.default(wt,"messageUpdated","messageUpdated"),Pe.default(wt,"typingEnded","typingEnded"),Pe.default(wt,"typingStarted","typingStarted"),Pe.default(wt,"updated","updated"),Pe.default(wt,"removed","removed"),Pe.default(wt,"_logger",Gt.scope("Conversation")),_e([_.validateTypesAsync(_.nonEmptyString,Nr),le("design:type",Function),le("design:paramtypes",[String,Object]),le("design:returntype",Promise)],wt.prototype,"add",null),_e([_.validateTypesAsync(_.nonEmptyString,_.nonEmptyString,Nr,Nr),le("design:type",Function),le("design:paramtypes",[String,String,Object,Object]),le("design:returntype",Promise)],wt.prototype,"addNonChatParticipant",null),_e([_.validateTypesAsync(_.nonNegativeInteger),le("design:type",Function),le("design:paramtypes",[Number]),le("design:returntype",Promise)],wt.prototype,"advanceLastReadMessageIndex",null),_e([_.validateTypesAsync(["undefined",_.nonNegativeInteger],["undefined",_.nonNegativeInteger],["undefined",_.literal("backwards","forward")]),le("design:type",Function),le("design:paramtypes",[Number,Number,String]),le("design:returntype",Promise)],wt.prototype,"getMessages",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],wt.prototype,"getParticipantBySid",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],wt.prototype,"getParticipantByIdentity",null),_e([_.validateTypesAsync([_.nonEmptyString,H]),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],wt.prototype,"removeParticipant",null),_e([_.validateTypesAsync(["string",FormData,_.literal(null),_.objectSchema("media options",{contentType:_.nonEmptyString,media:_.custom(function(O){var P=typeof O=="string"&&O.length>0||O instanceof Uint8Array||O instanceof ArrayBuffer;return typeof Blob=="function"&&(P=P||O instanceof Blob),[P,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],Nr,["undefined",_.literal(null),_.objectSchema("email attributes",{subject:[_.nonEmptyString,"undefined"]})]),le("design:type",Function),le("design:paramtypes",[Object,Object,Object]),le("design:returntype",Promise)],wt.prototype,"sendMessage",null),_e([_.validateTypesAsync(_.literal("default","muted")),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],wt.prototype,"setUserNotificationLevel",null),_e([_.validateTypesAsync(sr),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],wt.prototype,"updateAttributes",null),_e([_.validateTypesAsync("string"),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],wt.prototype,"updateFriendlyName",null),_e([_.validateTypesAsync([_.literal(null),_.nonNegativeInteger]),le("design:type",Function),le("design:paramtypes",[Number]),le("design:returntype",Promise)],wt.prototype,"updateLastReadMessageIndex",null),_e([_.validateTypesAsync(["string",_.literal(null)]),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],wt.prototype,"updateUniqueName",null);var ra=function(){function O(){var P=this;pe.default(this,O),this._promise=new Promise(function(f,d){P._resolve=f,P._reject=d})}return he.default(O,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(f){this._resolve(f)}},{key:"set",value:function(f){this.current=f,this._resolve(f)}},{key:"fail",value:function(f){this._reject(f)}}]),O}();function na(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=Ti(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
461
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function Ti(O,P){if(O){if(typeof O=="string")return Ei(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return Ei(O,P)}}function Ei(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}function Zn(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function Nn(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?Zn(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):Zn(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function dr(O){var P=ia();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function ia(){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 pr=Gt.scope("Conversations"),$r=function(O){He.default(f,O);var P=dr(f);function f(d,p){var y;return pe.default(this,f),y=P.call(this),Pe.default(Ue.default(y),"conversations",new Map),Pe.default(Ue.default(y),"myConversationsRead",new ra),Pe.default(Ue.default(y),"tombstones",new Set),Pe.default(Ue.default(y),"myConversationsFetched",!1),y.configuration=d,y.services=p,y}return he.default(f,[{key:"addConversation",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T,F,j,V,W,Ie,ze;return M.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:return T=typeof(g==null?void 0:g.attributes)<"u"?g.attributes:{},qe.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:g.friendlyName,unique_name:g.uniqueName,attributes:typeof T<"u"?JSON.stringify(T):void 0});case 3:if(F=qe.sent,j=(b=F.sid)!==null&&b!==void 0?b:null,V=(w=(S=F.sync_objects)===null||S===void 0?void 0:S.conversation)!==null&&w!==void 0?w:null,W=Nn({self:F.url},F.links),Ie=this.conversations.get(j),!Ie){qe.next=12;break}return qe.next=11,Ie._subscribe();case 11:return qe.abrupt("return",Ie);case 12:return ze=new wt({channel:V,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},j,W,this.configuration,this.services),this.conversations.set(ze.sid,ze),this._registerForEvents(ze),qe.next=17,ze._subscribe();case 17:return this.emit("conversationAdded",ze),qe.abrupt("return",ze);case 19:case"end":return qe.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"fetchConversations",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b,w,S,T,F,j,V;return M.default.wrap(function(Ie){for(;;)switch(Ie.prev=Ie.next){case 0:return Ie.prev=0,Ie.next=3,this._getMap();case 3:return b=Ie.sent,b.on(J.SyncMap.itemAdded,function(ze){pr.debug("itemAdded: ".concat(ze.item.key)),g._upsertConversation("sync",ze.item.key,ze.item.data)}),b.on(J.SyncMap.itemRemoved,function(ze){pr.debug("itemRemoved: ".concat(ze.key));var je=ze.key;g.myConversationsFetched||g.tombstones.add(je);var qe=g.conversations.get(je);qe&&(qe.status==="joined"&&(qe._setStatus("notParticipating","sync"),g.emit("conversationLeft",qe)),g.conversations.delete(je),g.emit("conversationRemoved",qe),qe.emit("removed",qe))}),b.on(J.SyncMap.itemUpdated,function(ze){pr.debug("itemUpdated: ".concat(ze.item.key)),g._upsertConversation("sync",ze.item.key,ze.item.data)}),Ie.next=9,this._fetchMyConversations();case 9:w=Ie.sent,S=[],T=na(w);try{for(T.s();!(F=T.n()).done;)j=F.value,S.push(this._upsertConversation("rest",j.channel_sid,j))}catch(ze){T.e(ze)}finally{T.f()}return this.myConversationsRead.set(!0),Ie.next=16,Promise.all(S);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),pr.debug("The conversations list has been successfully fetched"),Ie.abrupt("return",this);case 22:throw Ie.prev=22,Ie.t0=Ie.catch(0),V="Failed to fetch the conversations list",this.services.syncClient.connectionState!=="disconnected"&&pr.error(V,Ie.t0),pr.debug("ERROR: ".concat(V),Ie.t0),Ie.t0;case 28:case"end":return Ie.stop()}},y,this,[[0,22]])}));function p(){return d.apply(this,arguments)}return p}()},{key:"getConversations",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._getMap();case 2:return b=T.sent,T.next=5,b.getItems();case 5:return w=T.sent,T.abrupt("return",this._wrapPaginator(w,function(F){return Promise.all(F.map(function(j){return g._upsertConversation("sync",j.key,j.data)}))}));case 7:case"end":return T.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getConversation",value:function(){var d=Y.default(M.default.mark(function y(g){var b=this,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.next=2,this._getMap();case 2:return w=j.sent,j.next=5,w.getItems({key:g});case 5:return S=j.sent,T=S.items.map(function(V){return b._upsertConversation("sync",V.key,V.data)}),j.abrupt("return",T.length>0?T[0]:null);case 8:case"end":return j.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getConversationByUniqueName",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:return b=new It(this.configuration.links.myConversations).path(g).build(),V.next=3,this.services.network.get(b);case 3:return w=V.sent,S=w.body,T=S.conversation_sid,F={entityName:null,lastConsumedMessageIndex:S.last_read_message_index,status:(S==null?void 0:S.status)||"unknown",friendlyName:S.friendly_name,dateUpdated:S.date_updated,dateCreated:S.date_created,uniqueName:S.unique_name,createdBy:S.created_by,attributes:S.attributes,channel:S.sync_objects.conversation,notificationLevel:S==null?void 0:S.notification_level,sid:T},V.abrupt("return",T?this._upsertConversation("sync",T,F):null);case 8:case"end":return V.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"peekConversation",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return b=new It(this.configuration.links.conversations).path(g).build(),j.next=3,this.services.network.get(b);case 3:return w=j.sent,S=w.body,T={entityName:null,status:(S==null?void 0:S.status)||"unknown",friendlyName:S.friendly_name,dateUpdated:S.date_updated,dateCreated:S.date_created,uniqueName:S.unique_name,createdBy:S.created_by,attributes:S.attributes,channel:"".concat(g,".channel"),sid:g},j.abrupt("return",this._upsertConversation("sync",g,T));case 7:case"end":return j.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"_getMap",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_wrapPaginator",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w=this,S;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return F.next=2,b(g.items);case 2:return S=F.sent,F.abrupt("return",{items:S.filter(function(j){return j!==null}),hasNextPage:g.hasNextPage,hasPrevPage:g.hasPrevPage,nextPage:function(){return g.nextPage().then(function(V){return w._wrapPaginator(V,b)})},prevPage:function(){return g.prevPage().then(function(V){return w._wrapPaginator(V,b)})}});case 4:case"end":return F.stop()}},y)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"_updateConversation",value:function(){var d=Y.default(M.default.mark(function y(g,b,w){var S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(S=b._statusSource!==void 0&&g!==b._statusSource,T=g!=="rest"||b._statusSource==="sync",!(S&&T&&g!=="sync")){V.next=5;break}return pr.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:b.sid,data:w.status,conversation:b.status}),V.abrupt("return");case 5:if(!(w.status==="joined"&&b.status!=="joined")){V.next=15;break}return b._setStatus("joined",g),F={},typeof w.notificationLevel<"u"&&(F.notificationLevel=w.notificationLevel),typeof w.lastConsumedMessageIndex<"u"&&(F.lastConsumedMessageIndex=w.lastConsumedMessageIndex),we.default(F,{})||b._update(F),V.next=13,b._subscribe();case 13:return this.emit("conversationJoined",b),V.abrupt("return");case 15:if(!(w.status==="notParticipating"&&b.status==="joined")){V.next=22;break}return b._setStatus("notParticipating",g),b._update(w),V.next=20,b._subscribe();case 20:return this.emit("conversationLeft",b),V.abrupt("return");case 22:if(w.status!=="notParticipating"){V.next=26;break}return V.next=25,b._subscribe();case 25:return V.abrupt("return");case 26:b._update(w);case 27:case"end":return V.stop()}},y,this)}));function p(y,g,b){return d.apply(this,arguments)}return p}()},{key:"_upsertConversation",value:function(){var d=Y.default(M.default.mark(function y(g,b,w){var S,T,F,j;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(pr.trace("upsertConversation called for ".concat(b),w),S=this.conversations.get(b),!S){W.next=9;break}return pr.trace("upsertConversation: the conversation ".concat(S.sid," is known;")+"its status is known from the source ".concat(S._statusSource," ")+"and the update came from the source ".concat(g),S),W.next=6,this._updateConversation(g,S,w);case 6:return W.next=8,S._subscribe();case 8:return W.abrupt("return",S);case 9:if(!(g==="rest"&&this.tombstones.has(b))){W.next=12;break}return pr.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",b),W.abrupt("return",null);case 12:return pr.trace("upsertConversation: creating a local conversation object with sid "+b,w),T="".concat(this.configuration.links.conversations,"/").concat(b),F={self:T,messages:"".concat(T,"/Messages"),participants:"".concat(T,"/Participants")},j=new wt(w,b,F,this.configuration,this.services),this.conversations.set(b,j),W.prev=17,W.next=20,j._subscribe();case 20:if(w.status!=="joined"){W.next=23;break}return W.next=23,j._fetchStreams();case 23:W.next=32;break;case 25:if(W.prev=25,W.t0=W.catch(17),W.t0.name==="SyncError"){W.next=29;break}throw W.t0;case 29:return pr.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",b,W.t0),this.conversations.delete(b),W.abrupt("return",null);case 32:return this._registerForEvents(j),this.emit("conversationAdded",j),w.status==="joined"&&(j._setStatus("joined",g),this.emit("conversationJoined",j)),W.abrupt("return",j);case 36:case"end":return W.stop()}},y,this,[[17,25]])}));function p(y,g,b){return d.apply(this,arguments)}return p}()},{key:"_fetchMyConversations",value:function(){var d=Y.default(M.default.mark(function y(){var g,b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:g=[],b=null;case 2:return S=new It(this.configuration.links.myConversations),b&&S.arg("PageToken",b),V.next=6,this.services.network.get(S.build());case 6:T=V.sent,F=(w=T.body)===null||w===void 0?void 0:w.conversations.map(function(W){return{descriptor:W,channel_sid:W.conversation_sid,status:W.status,channel:W.sync_objects.conversation,messages:W.sync_objects.messages,roster:"".concat(W.conversation_sid,".roster"),lastConsumedMessageIndex:W.last_read_message_index,notificationLevel:W.notification_level}}),b=T.body.meta.next_token,g=[].concat(De.default(g),De.default(F));case 10:if(b){V.next=2;break}case 11:return V.abrupt("return",g);case 12:case"end":return V.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_onConversationRemoved",value:function(p){var y=this.conversations.get(p);y&&(this.conversations.delete(p),this.emit("conversationRemoved",y))}},{key:"_registerForEvents",value:function(p){var y=this;p.on("removed",function(){return y._onConversationRemoved(p.sid)}),p.on("updated",function(g){return y.emit("conversationUpdated",g)}),p.on("participantJoined",function(g){return y.emit("participantJoined",g)}),p.on("participantLeft",function(g){return y.emit("participantLeft",g)}),p.on("participantUpdated",function(g){return y.emit("participantUpdated",g)}),p.on("messageAdded",function(g){return y.emit("messageAdded",g)}),p.on("messageUpdated",function(g){return y.emit("messageUpdated",g)}),p.on("messageRemoved",function(g){return y.emit("messageRemoved",g)}),p.on("typingStarted",function(g){return y.emit("typingStarted",g)}),p.on("typingEnded",function(g){return y.emit("typingEnded",g)})}}]),f}(I.ReplayEventEmitter);function on(O){var P=aa();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function aa(){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(O){He.default(f,O);var P=on(f);function f(d,p,y){var g;return pe.default(this,f),g=P.call(this),g.configuration=p,g.services=y,g.fifoStack=[],g.myself=d,g.myself.on("updated",function(b){return g.emit("userUpdated",b)}),g.myself.on("userSubscribed",function(){return g.emit("userSubscribed",g.myself)}),g.myself.on("userUnsubscribed",function(){g.emit("userUnsubscribed",g.myself),g.myself._ensureFetched()}),g.subscribedUsers=new Map,g}return he.default(f,[{key:"handleUnsubscribeUser",value:function(p){this.subscribedUsers.has(p.identity)&&this.subscribedUsers.delete(p.identity);var y=0,g=this.fifoStack.find(function(b,w){return b==p.identity?(y=w,!0):!1});g&&this.fifoStack.splice(y,1),this.emit("userUnsubscribed",p)}},{key:"handleSubscribeUser",value:function(p){if(!this.subscribedUsers.has(p.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var y,g,b=this.fifoStack.shift();(y=this.subscribedUsers)===null||y===void 0||(g=y.get(b))===null||g===void 0||g.unsubscribe()}this.fifoStack.push(p.identity),this.subscribedUsers.set(p.identity,p),this.emit("userSubscribed",p)}}},{key:"getUser",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w,S=this,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:return V.next=2,this.myself._ensureFetched();case 2:if(g!=this.myself.identity){V.next=4;break}return V.abrupt("return",this.myself);case 4:if(T=this.subscribedUsers.get(g),!T){V.next=7;break}return V.abrupt("return",T);case 7:if(!((w=b)!==null&&w!==void 0)){V.next=11;break}V.next=14;break;case 11:return V.next=13,this.getSyncUniqueName(g);case 13:b=V.sent;case 14:return F=new ve(g,b,this.configuration,this.services),F.on("updated",function(W){return S.emit("userUpdated",W)}),F.on("userSubscribed",function(){return S.handleSubscribeUser(F)}),F.on("userUnsubscribed",function(){return S.handleUnsubscribeUser(F)}),V.next=20,F._ensureFetched();case 20:return V.abrupt("return",F);case 21:case"end":return V.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"getSubscribedUsers",value:function(){var d=Y.default(M.default.mark(function y(){var g;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this.myself._ensureFetched();case 2:return g=[this.myself],this.subscribedUsers.forEach(function(S){return g.push(S)}),w.abrupt("return",g);case 5:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getSyncUniqueName",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return S=new It(this.configuration.links.users).path(g).build(),j.next=3,this.services.network.get(S);case 3:return T=j.sent,j.abrupt("return",(b=(w=T.body)===null||w===void 0?void 0:w.sync_objects.user_info_map)!==null&&b!==void 0?b:"");case 5:case"end":return j.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()}]),f}(I.ReplayEventEmitter),B=Gt.scope("TypingIndicator"),R=function(){function O(P,f,d){pe.default(this,O),this.configuration=f,this.services=d,this.getConversation=P,this.serviceTypingTimeout=null,this.sentUpdates=new Map}return he.default(O,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var f=this;this.services.notificationClient.on("message",function(){var d=Y.default(M.default.mark(function p(y,g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(y!==me.TYPING_INDICATOR){w.next=3;break}return w.next=3,f._handleRemoteTyping(g);case 3:case"end":return w.stop()}},p)}));return function(p,y){return d.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:function(){var P=Y.default(M.default.mark(function d(p){var y=this;return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:B.trace("Got new typing indicator ",p),this.getConversation(p.channel_sid).then(function(w){w&&w._participants.forEach(function(S){if(S.identity===p.identity){var T=y.configuration.typingIndicatorTimeoutOverride?y.configuration.typingIndicatorTimeoutOverride+1e3:p.typing_timeout*1e3;S._startTyping(T)}})}).catch(function(w){throw B.error(w),w});case 2:case"end":return b.stop()}},d,this)}));function f(d){return P.apply(this,arguments)}return f}()},{key:"send",value:function(f){var d=this.sentUpdates.get(f);return d&&d>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(f,Date.now()),this._send(f))}},{key:"_send",value:function(f){var d=this;B.trace("Sending typing indicator");var p=this.configuration.links.typing,y={"Content-Type":"application/x-www-form-urlencoded"},g="ChannelSid=".concat(f);return this.services.twilsockClient.post(p,y,g,this.configuration.productId).then(function(b){b.body.hasOwnProperty("typing_timeout")&&(d.serviceTypingTimeout=b.body.typing_timeout*1e3)}).catch(function(b){throw B.error("Failed to send typing indicator:",b),b})}}]),O}(),k=he.default(function O(P){pe.default(this,O),this.title=P.title||null,this.body=P.body||null,this.sound=P.sound||null,this.badge=P.badge||null,this.action=P.action||null,this.type=P.type||null,this.data=P.data||{}}),E="2.6.0";function U(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function A(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?U(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):U(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function fe(O){var P=ue();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function ue(){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 Te=function(P){return P.replace(/(^\/+|\/+$)/g,"")},Ne=function(P){return P.status.code===202},et=function(O){He.default(f,O);var P=fe(f);function f(d){return pe.default(this,f),P.call(this,d)}return he.default(f)}($t.default(Error)),hr=function(){function O(P,f,d){pe.default(this,O),this._serviceUrl=P,this._services=f,this._productId=d}return he.default(O,[{key:"_preProcessUrl",value:function(f){var d=Te(f);return/^https?:\/\//.test(f)?d:"".concat(Te(this._serviceUrl),"/").concat(d)}},{key:"_makeRequest",value:function(){var P=Y.default(M.default.mark(function d(p,y,g,b){var w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:w=this._preProcessUrl(y),S=A({"Content-Type":"application/json; charset=utf-8"},b||{}),V.t0=p,V.next=V.t0==="get"?5:V.t0==="post"?11:V.t0==="delete"?15:19;break;case 5:return F=w,g&&(F+="?"+Object.entries(g).map(function(W){return W.map(encodeURIComponent).join("=")}).join("&")),V.next=9,this._services.transport.get(F,S,this._productId);case 9:return T=V.sent,V.abrupt("break",19);case 11:return V.next=13,this._services.transport.post(w,S,JSON.stringify(g),this._productId);case 13:return T=V.sent,V.abrupt("break",19);case 15:return V.next=17,this._services.transport.delete(w,S,{},this._productId);case 17:return T=V.sent,V.abrupt("break",19);case 19:if(!(T.status.code<200||T.status.code>=300)){V.next=21;break}throw new Error("Request responded with a non-success code ".concat(T.status.code));case 21:return V.abrupt("return",T);case 22:case"end":return V.stop()}},d,this)}));function f(d,p,y,g){return P.apply(this,arguments)}return f}()},{key:"fetchResource",value:function(){var P=Y.default(M.default.mark(function d(p,y){var g=this,b,w,S;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return b=6,w=new N.AsyncRetrier({min:50,max:1600,maxAttemptsCount:b}),F.prev=2,F.next=5,w.run(Y.default(M.default.mark(function j(){var V,W,Ie;return M.default.wrap(function(je){for(;;)switch(je.prev=je.next){case 0:return je.prev=0,je.next=3,g._makeRequest("get",p,y);case 3:return V=je.sent,je.abrupt("return",{type:"success",data:V.body});case 7:if(je.prev=7,je.t0=je.catch(0),!((je.t0===null||je.t0===void 0||(W=je.t0.body)===null||W===void 0?void 0:W.status)===404&&(je.t0===null||je.t0===void 0||(Ie=je.t0.body)===null||Ie===void 0?void 0:Ie.code)===50530)){je.next=11;break}return je.abrupt("return",{type:"noMetadata"});case 11:throw je.t0;case 12:case"end":return je.stop()}},j,null,[[0,7]])})));case 5:S=F.sent,F.next=11;break;case 8:throw F.prev=8,F.t0=F.catch(2),new Error('Fetch resource from "'.concat(p,'" failed.'));case 11:if(S.type!=="noMetadata"){F.next=13;break}throw new et("No metadata found.");case 13:return F.abrupt("return",S.data);case 14:case"end":return F.stop()}},d,null,[[2,8]])}));function f(d,p){return P.apply(this,arguments)}return f}()},{key:"mutateResource",value:function(){var P=Y.default(M.default.mark(function d(p,y,g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._makeRequest(p,y,g,{"X-Twilio-Mutation-Id":se.v4()});case 2:if(b=S.sent,!Ne(b)){S.next=7;break}return S.next=6,this.fetchResource(b.body.resource_url);case 6:return S.abrupt("return",S.sent);case 7:return S.abrupt("return",b.body);case 8:case"end":return S.stop()}},d,this)}));function f(d,p,y){return P.apply(this,arguments)}return f}()}]),O}(),Kr=function(){function O(P){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:100,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5e3;pe.default(this,O),Pe.default(this,"_cachedTemplates",null),this._services=P,this._pageSize=f,this._cacheTtlMs=d}return he.default(O,[{key:"getContentTemplates",value:function(){var P=Y.default(M.default.mark(function d(){var p=this,y,g,b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(this._cachedTemplates===null){V.next=2;break}return V.abrupt("return",this._cachedTemplates);case 2:return V.next=4,this._fetchContentTemplates();case 4:y=V.sent,g=Q.default(y,2),b=g[0],w=g[1],S=b;case 9:if(w===null){V.next=19;break}return V.next=12,this._fetchContentTemplates(w);case 12:T=V.sent,F=Q.default(T,2),b=F[0],w=F[1],S=[].concat(De.default(S),De.default(b)),V.next=9;break;case 19:return this._cachedTemplates=Object.freeze(S),setTimeout(function(){p._cachedTemplates=null},this._cacheTtlMs),V.abrupt("return",S);case 22:case"end":return V.stop()}},d,this)}));function f(){return P.apply(this,arguments)}return f}()},{key:"_fetchContentTemplates",value:function(){var P=Y.default(M.default.mark(function d(p){var y,g,b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return y="Client/v2/ContentTemplates",g=new It(y),g.arg("PageSize",this._pageSize),p!==void 0&&g.arg("PageToken",p),S.next=6,this._services.commandExecutor.fetchResource(g.build());case 6:return b=S.sent,S.abrupt("return",[b.templates.map(function(T){return new at(T)}),b.meta.next_token]);case 8:case"end":return S.stop()}},d,this)}));function f(d){return P.apply(this,arguments)}return f}()}]),O}();function nr(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=un(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
461
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function Ti(O,P){if(O){if(typeof O=="string")return Ei(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return Ei(O,P)}}function Ei(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}function Zn(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function Nn(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?Zn(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):Zn(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function dr(O){var P=ia();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function ia(){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 pr=Gt.scope("Conversations"),Ir=function(O){He.default(f,O);var P=dr(f);function f(d,p){var y;return pe.default(this,f),y=P.call(this),Pe.default(Ue.default(y),"conversations",new Map),Pe.default(Ue.default(y),"myConversationsRead",new ra),Pe.default(Ue.default(y),"tombstones",new Set),Pe.default(Ue.default(y),"myConversationsFetched",!1),y.configuration=d,y.services=p,y}return he.default(f,[{key:"addConversation",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T,F,j,V,W,Ie,ze;return M.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:return T=typeof(g==null?void 0:g.attributes)<"u"?g.attributes:{},qe.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:g.friendlyName,unique_name:g.uniqueName,attributes:typeof T<"u"?JSON.stringify(T):void 0});case 3:if(F=qe.sent,j=(b=F.sid)!==null&&b!==void 0?b:null,V=(w=(S=F.sync_objects)===null||S===void 0?void 0:S.conversation)!==null&&w!==void 0?w:null,W=Nn({self:F.url},F.links),Ie=this.conversations.get(j),!Ie){qe.next=12;break}return qe.next=11,Ie._subscribe();case 11:return qe.abrupt("return",Ie);case 12:return ze=new wt({channel:V,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},j,W,this.configuration,this.services),this.conversations.set(ze.sid,ze),this._registerForEvents(ze),qe.next=17,ze._subscribe();case 17:return this.emit("conversationAdded",ze),qe.abrupt("return",ze);case 19:case"end":return qe.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"fetchConversations",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b,w,S,T,F,j,V;return M.default.wrap(function(Ie){for(;;)switch(Ie.prev=Ie.next){case 0:return Ie.prev=0,Ie.next=3,this._getMap();case 3:return b=Ie.sent,b.on(J.SyncMap.itemAdded,function(ze){pr.debug("itemAdded: ".concat(ze.item.key)),g._upsertConversation("sync",ze.item.key,ze.item.data)}),b.on(J.SyncMap.itemRemoved,function(ze){pr.debug("itemRemoved: ".concat(ze.key));var je=ze.key;g.myConversationsFetched||g.tombstones.add(je);var qe=g.conversations.get(je);qe&&(qe.status==="joined"&&(qe._setStatus("notParticipating","sync"),g.emit("conversationLeft",qe)),g.conversations.delete(je),g.emit("conversationRemoved",qe),qe.emit("removed",qe))}),b.on(J.SyncMap.itemUpdated,function(ze){pr.debug("itemUpdated: ".concat(ze.item.key)),g._upsertConversation("sync",ze.item.key,ze.item.data)}),Ie.next=9,this._fetchMyConversations();case 9:w=Ie.sent,S=[],T=na(w);try{for(T.s();!(F=T.n()).done;)j=F.value,S.push(this._upsertConversation("rest",j.channel_sid,j))}catch(ze){T.e(ze)}finally{T.f()}return this.myConversationsRead.set(!0),Ie.next=16,Promise.all(S);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),pr.debug("The conversations list has been successfully fetched"),Ie.abrupt("return",this);case 22:throw Ie.prev=22,Ie.t0=Ie.catch(0),V="Failed to fetch the conversations list",this.services.syncClient.connectionState!=="disconnected"&&pr.error(V,Ie.t0),pr.debug("ERROR: ".concat(V),Ie.t0),Ie.t0;case 28:case"end":return Ie.stop()}},y,this,[[0,22]])}));function p(){return d.apply(this,arguments)}return p}()},{key:"getConversations",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b,w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.next=2,this._getMap();case 2:return b=T.sent,T.next=5,b.getItems();case 5:return w=T.sent,T.abrupt("return",this._wrapPaginator(w,function(F){return Promise.all(F.map(function(j){return g._upsertConversation("sync",j.key,j.data)}))}));case 7:case"end":return T.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getConversation",value:function(){var d=Y.default(M.default.mark(function y(g){var b=this,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.next=2,this._getMap();case 2:return w=j.sent,j.next=5,w.getItems({key:g});case 5:return S=j.sent,T=S.items.map(function(V){return b._upsertConversation("sync",V.key,V.data)}),j.abrupt("return",T.length>0?T[0]:null);case 8:case"end":return j.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getConversationByUniqueName",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:return b=new It(this.configuration.links.myConversations).path(g).build(),V.next=3,this.services.network.get(b);case 3:return w=V.sent,S=w.body,T=S.conversation_sid,F={entityName:null,lastConsumedMessageIndex:S.last_read_message_index,status:(S==null?void 0:S.status)||"unknown",friendlyName:S.friendly_name,dateUpdated:S.date_updated,dateCreated:S.date_created,uniqueName:S.unique_name,createdBy:S.created_by,attributes:S.attributes,channel:S.sync_objects.conversation,notificationLevel:S==null?void 0:S.notification_level,sid:T},V.abrupt("return",T?this._upsertConversation("sync",T,F):null);case 8:case"end":return V.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"peekConversation",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return b=new It(this.configuration.links.conversations).path(g).build(),j.next=3,this.services.network.get(b);case 3:return w=j.sent,S=w.body,T={entityName:null,status:(S==null?void 0:S.status)||"unknown",friendlyName:S.friendly_name,dateUpdated:S.date_updated,dateCreated:S.date_created,uniqueName:S.unique_name,createdBy:S.created_by,attributes:S.attributes,channel:"".concat(g,".channel"),sid:g},j.abrupt("return",this._upsertConversation("sync",g,T));case 7:case"end":return j.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"_getMap",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_wrapPaginator",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w=this,S;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return F.next=2,b(g.items);case 2:return S=F.sent,F.abrupt("return",{items:S.filter(function(j){return j!==null}),hasNextPage:g.hasNextPage,hasPrevPage:g.hasPrevPage,nextPage:function(){return g.nextPage().then(function(V){return w._wrapPaginator(V,b)})},prevPage:function(){return g.prevPage().then(function(V){return w._wrapPaginator(V,b)})}});case 4:case"end":return F.stop()}},y)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"_updateConversation",value:function(){var d=Y.default(M.default.mark(function y(g,b,w){var S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(S=b._statusSource!==void 0&&g!==b._statusSource,T=g!=="rest"||b._statusSource==="sync",!(S&&T&&g!=="sync")){V.next=5;break}return pr.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:b.sid,data:w.status,conversation:b.status}),V.abrupt("return");case 5:if(!(w.status==="joined"&&b.status!=="joined")){V.next=15;break}return b._setStatus("joined",g),F={},typeof w.notificationLevel<"u"&&(F.notificationLevel=w.notificationLevel),typeof w.lastConsumedMessageIndex<"u"&&(F.lastConsumedMessageIndex=w.lastConsumedMessageIndex),we.default(F,{})||b._update(F),V.next=13,b._subscribe();case 13:return this.emit("conversationJoined",b),V.abrupt("return");case 15:if(!(w.status==="notParticipating"&&b.status==="joined")){V.next=22;break}return b._setStatus("notParticipating",g),b._update(w),V.next=20,b._subscribe();case 20:return this.emit("conversationLeft",b),V.abrupt("return");case 22:if(w.status!=="notParticipating"){V.next=26;break}return V.next=25,b._subscribe();case 25:return V.abrupt("return");case 26:b._update(w);case 27:case"end":return V.stop()}},y,this)}));function p(y,g,b){return d.apply(this,arguments)}return p}()},{key:"_upsertConversation",value:function(){var d=Y.default(M.default.mark(function y(g,b,w){var S,T,F,j;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(pr.trace("upsertConversation called for ".concat(b),w),S=this.conversations.get(b),!S){W.next=9;break}return pr.trace("upsertConversation: the conversation ".concat(S.sid," is known;")+"its status is known from the source ".concat(S._statusSource," ")+"and the update came from the source ".concat(g),S),W.next=6,this._updateConversation(g,S,w);case 6:return W.next=8,S._subscribe();case 8:return W.abrupt("return",S);case 9:if(!(g==="rest"&&this.tombstones.has(b))){W.next=12;break}return pr.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",b),W.abrupt("return",null);case 12:return pr.trace("upsertConversation: creating a local conversation object with sid "+b,w),T="".concat(this.configuration.links.conversations,"/").concat(b),F={self:T,messages:"".concat(T,"/Messages"),participants:"".concat(T,"/Participants")},j=new wt(w,b,F,this.configuration,this.services),this.conversations.set(b,j),W.prev=17,W.next=20,j._subscribe();case 20:if(w.status!=="joined"){W.next=23;break}return W.next=23,j._fetchStreams();case 23:W.next=32;break;case 25:if(W.prev=25,W.t0=W.catch(17),W.t0.name==="SyncError"){W.next=29;break}throw W.t0;case 29:return pr.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",b,W.t0),this.conversations.delete(b),W.abrupt("return",null);case 32:return this._registerForEvents(j),this.emit("conversationAdded",j),w.status==="joined"&&(j._setStatus("joined",g),this.emit("conversationJoined",j)),W.abrupt("return",j);case 36:case"end":return W.stop()}},y,this,[[17,25]])}));function p(y,g,b){return d.apply(this,arguments)}return p}()},{key:"_fetchMyConversations",value:function(){var d=Y.default(M.default.mark(function y(){var g,b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:g=[],b=null;case 2:return S=new It(this.configuration.links.myConversations),b&&S.arg("PageToken",b),V.next=6,this.services.network.get(S.build());case 6:T=V.sent,F=(w=T.body)===null||w===void 0?void 0:w.conversations.map(function(W){return{descriptor:W,channel_sid:W.conversation_sid,status:W.status,channel:W.sync_objects.conversation,messages:W.sync_objects.messages,roster:"".concat(W.conversation_sid,".roster"),lastConsumedMessageIndex:W.last_read_message_index,notificationLevel:W.notification_level}}),b=T.body.meta.next_token,g=[].concat(De.default(g),De.default(F));case 10:if(b){V.next=2;break}case 11:return V.abrupt("return",g);case 12:case"end":return V.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_onConversationRemoved",value:function(p){var y=this.conversations.get(p);y&&(this.conversations.delete(p),this.emit("conversationRemoved",y))}},{key:"_registerForEvents",value:function(p){var y=this;p.on("removed",function(){return y._onConversationRemoved(p.sid)}),p.on("updated",function(g){return y.emit("conversationUpdated",g)}),p.on("participantJoined",function(g){return y.emit("participantJoined",g)}),p.on("participantLeft",function(g){return y.emit("participantLeft",g)}),p.on("participantUpdated",function(g){return y.emit("participantUpdated",g)}),p.on("messageAdded",function(g){return y.emit("messageAdded",g)}),p.on("messageUpdated",function(g){return y.emit("messageUpdated",g)}),p.on("messageRemoved",function(g){return y.emit("messageRemoved",g)}),p.on("typingStarted",function(g){return y.emit("typingStarted",g)}),p.on("typingEnded",function(g){return y.emit("typingEnded",g)})}}]),f}(I.ReplayEventEmitter);function on(O){var P=aa();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function aa(){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(O){He.default(f,O);var P=on(f);function f(d,p,y){var g;return pe.default(this,f),g=P.call(this),g.configuration=p,g.services=y,g.fifoStack=[],g.myself=d,g.myself.on("updated",function(b){return g.emit("userUpdated",b)}),g.myself.on("userSubscribed",function(){return g.emit("userSubscribed",g.myself)}),g.myself.on("userUnsubscribed",function(){g.emit("userUnsubscribed",g.myself),g.myself._ensureFetched()}),g.subscribedUsers=new Map,g}return he.default(f,[{key:"handleUnsubscribeUser",value:function(p){this.subscribedUsers.has(p.identity)&&this.subscribedUsers.delete(p.identity);var y=0,g=this.fifoStack.find(function(b,w){return b==p.identity?(y=w,!0):!1});g&&this.fifoStack.splice(y,1),this.emit("userUnsubscribed",p)}},{key:"handleSubscribeUser",value:function(p){if(!this.subscribedUsers.has(p.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var y,g,b=this.fifoStack.shift();(y=this.subscribedUsers)===null||y===void 0||(g=y.get(b))===null||g===void 0||g.unsubscribe()}this.fifoStack.push(p.identity),this.subscribedUsers.set(p.identity,p),this.emit("userSubscribed",p)}}},{key:"getUser",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w,S=this,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:return V.next=2,this.myself._ensureFetched();case 2:if(g!=this.myself.identity){V.next=4;break}return V.abrupt("return",this.myself);case 4:if(T=this.subscribedUsers.get(g),!T){V.next=7;break}return V.abrupt("return",T);case 7:if(!((w=b)!==null&&w!==void 0)){V.next=11;break}V.next=14;break;case 11:return V.next=13,this.getSyncUniqueName(g);case 13:b=V.sent;case 14:return F=new ve(g,b,this.configuration,this.services),F.on("updated",function(W){return S.emit("userUpdated",W)}),F.on("userSubscribed",function(){return S.handleSubscribeUser(F)}),F.on("userUnsubscribed",function(){return S.handleUnsubscribeUser(F)}),V.next=20,F._ensureFetched();case 20:return V.abrupt("return",F);case 21:case"end":return V.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"getSubscribedUsers",value:function(){var d=Y.default(M.default.mark(function y(){var g;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this.myself._ensureFetched();case 2:return g=[this.myself],this.subscribedUsers.forEach(function(S){return g.push(S)}),w.abrupt("return",g);case 5:case"end":return w.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getSyncUniqueName",value:function(){var d=Y.default(M.default.mark(function y(g){var b,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return S=new It(this.configuration.links.users).path(g).build(),j.next=3,this.services.network.get(S);case 3:return T=j.sent,j.abrupt("return",(b=(w=T.body)===null||w===void 0?void 0:w.sync_objects.user_info_map)!==null&&b!==void 0?b:"");case 5:case"end":return j.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()}]),f}(I.ReplayEventEmitter),B=Gt.scope("TypingIndicator"),R=function(){function O(P,f,d){pe.default(this,O),this.configuration=f,this.services=d,this.getConversation=P,this.serviceTypingTimeout=null,this.sentUpdates=new Map}return he.default(O,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var f=this;this.services.notificationClient.on("message",function(){var d=Y.default(M.default.mark(function p(y,g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(y!==me.TYPING_INDICATOR){w.next=3;break}return w.next=3,f._handleRemoteTyping(g);case 3:case"end":return w.stop()}},p)}));return function(p,y){return d.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:function(){var P=Y.default(M.default.mark(function d(p){var y=this;return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:B.trace("Got new typing indicator ",p),this.getConversation(p.channel_sid).then(function(w){w&&w._participants.forEach(function(S){if(S.identity===p.identity){var T=y.configuration.typingIndicatorTimeoutOverride?y.configuration.typingIndicatorTimeoutOverride+1e3:p.typing_timeout*1e3;S._startTyping(T)}})}).catch(function(w){throw B.error(w),w});case 2:case"end":return b.stop()}},d,this)}));function f(d){return P.apply(this,arguments)}return f}()},{key:"send",value:function(f){var d=this.sentUpdates.get(f);return d&&d>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(f,Date.now()),this._send(f))}},{key:"_send",value:function(f){var d=this;B.trace("Sending typing indicator");var p=this.configuration.links.typing,y={"Content-Type":"application/x-www-form-urlencoded"},g="ChannelSid=".concat(f);return this.services.twilsockClient.post(p,y,g,this.configuration.productId).then(function(b){b.body.hasOwnProperty("typing_timeout")&&(d.serviceTypingTimeout=b.body.typing_timeout*1e3)}).catch(function(b){throw B.error("Failed to send typing indicator:",b),b})}}]),O}(),k=he.default(function O(P){pe.default(this,O),this.title=P.title||null,this.body=P.body||null,this.sound=P.sound||null,this.badge=P.badge||null,this.action=P.action||null,this.type=P.type||null,this.data=P.data||{}}),E="2.6.0";function U(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function A(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?U(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):U(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function fe(O){var P=ue();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function ue(){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 Te=function(P){return P.replace(/(^\/+|\/+$)/g,"")},Ne=function(P){return P.status.code===202},et=function(O){He.default(f,O);var P=fe(f);function f(d){return pe.default(this,f),P.call(this,d)}return he.default(f)}($t.default(Error)),hr=function(){function O(P,f,d){pe.default(this,O),this._serviceUrl=P,this._services=f,this._productId=d}return he.default(O,[{key:"_preProcessUrl",value:function(f){var d=Te(f);return/^https?:\/\//.test(f)?d:"".concat(Te(this._serviceUrl),"/").concat(d)}},{key:"_makeRequest",value:function(){var P=Y.default(M.default.mark(function d(p,y,g,b){var w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:w=this._preProcessUrl(y),S=A({"Content-Type":"application/json; charset=utf-8"},b||{}),V.t0=p,V.next=V.t0==="get"?5:V.t0==="post"?11:V.t0==="delete"?15:19;break;case 5:return F=w,g&&(F+="?"+Object.entries(g).map(function(W){return W.map(encodeURIComponent).join("=")}).join("&")),V.next=9,this._services.transport.get(F,S,this._productId);case 9:return T=V.sent,V.abrupt("break",19);case 11:return V.next=13,this._services.transport.post(w,S,JSON.stringify(g),this._productId);case 13:return T=V.sent,V.abrupt("break",19);case 15:return V.next=17,this._services.transport.delete(w,S,{},this._productId);case 17:return T=V.sent,V.abrupt("break",19);case 19:if(!(T.status.code<200||T.status.code>=300)){V.next=21;break}throw new Error("Request responded with a non-success code ".concat(T.status.code));case 21:return V.abrupt("return",T);case 22:case"end":return V.stop()}},d,this)}));function f(d,p,y,g){return P.apply(this,arguments)}return f}()},{key:"fetchResource",value:function(){var P=Y.default(M.default.mark(function d(p,y){var g=this,b,w,S;return M.default.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return b=6,w=new N.AsyncRetrier({min:50,max:1600,maxAttemptsCount:b}),F.prev=2,F.next=5,w.run(Y.default(M.default.mark(function j(){var V,W,Ie;return M.default.wrap(function(je){for(;;)switch(je.prev=je.next){case 0:return je.prev=0,je.next=3,g._makeRequest("get",p,y);case 3:return V=je.sent,je.abrupt("return",{type:"success",data:V.body});case 7:if(je.prev=7,je.t0=je.catch(0),!((je.t0===null||je.t0===void 0||(W=je.t0.body)===null||W===void 0?void 0:W.status)===404&&(je.t0===null||je.t0===void 0||(Ie=je.t0.body)===null||Ie===void 0?void 0:Ie.code)===50530)){je.next=11;break}return je.abrupt("return",{type:"noMetadata"});case 11:throw je.t0;case 12:case"end":return je.stop()}},j,null,[[0,7]])})));case 5:S=F.sent,F.next=11;break;case 8:throw F.prev=8,F.t0=F.catch(2),new Error('Fetch resource from "'.concat(p,'" failed.'));case 11:if(S.type!=="noMetadata"){F.next=13;break}throw new et("No metadata found.");case 13:return F.abrupt("return",S.data);case 14:case"end":return F.stop()}},d,null,[[2,8]])}));function f(d,p){return P.apply(this,arguments)}return f}()},{key:"mutateResource",value:function(){var P=Y.default(M.default.mark(function d(p,y,g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._makeRequest(p,y,g,{"X-Twilio-Mutation-Id":se.v4()});case 2:if(b=S.sent,!Ne(b)){S.next=7;break}return S.next=6,this.fetchResource(b.body.resource_url);case 6:return S.abrupt("return",S.sent);case 7:return S.abrupt("return",b.body);case 8:case"end":return S.stop()}},d,this)}));function f(d,p,y){return P.apply(this,arguments)}return f}()}]),O}(),Kr=function(){function O(P){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:100,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5e3;pe.default(this,O),Pe.default(this,"_cachedTemplates",null),this._services=P,this._pageSize=f,this._cacheTtlMs=d}return he.default(O,[{key:"getContentTemplates",value:function(){var P=Y.default(M.default.mark(function d(){var p=this,y,g,b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(this._cachedTemplates===null){V.next=2;break}return V.abrupt("return",this._cachedTemplates);case 2:return V.next=4,this._fetchContentTemplates();case 4:y=V.sent,g=Q.default(y,2),b=g[0],w=g[1],S=b;case 9:if(w===null){V.next=19;break}return V.next=12,this._fetchContentTemplates(w);case 12:T=V.sent,F=Q.default(T,2),b=F[0],w=F[1],S=[].concat(De.default(S),De.default(b)),V.next=9;break;case 19:return this._cachedTemplates=Object.freeze(S),setTimeout(function(){p._cachedTemplates=null},this._cacheTtlMs),V.abrupt("return",S);case 22:case"end":return V.stop()}},d,this)}));function f(){return P.apply(this,arguments)}return f}()},{key:"_fetchContentTemplates",value:function(){var P=Y.default(M.default.mark(function d(p){var y,g,b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return y="Client/v2/ContentTemplates",g=new It(y),g.arg("PageSize",this._pageSize),p!==void 0&&g.arg("PageToken",p),S.next=6,this._services.commandExecutor.fetchResource(g.build());case 6:return b=S.sent,S.abrupt("return",[b.templates.map(function(T){return new at(T)}),b.meta.next_token]);case 8:case"end":return S.stop()}},d,this)}));function f(d){return P.apply(this,arguments)}return f}()}]),O}();function nr(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=un(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
462
462
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function un(O,P){if(O){if(typeof O=="string")return vs(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return vs(O,P)}}function vs(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}var mo=function(O){function P(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(pe.default(this,P),!(f.maxSize&&f.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=f.maxSize,this.onEviction=f.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}return he.default(P,[{key:"_set",value:function(d,p){if(this.cache.set(d,p),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function"){var y=nr(this.oldCache.entries()),g;try{for(y.s();!(g=y.n()).done;){var b=Q.default(g.value,2),w=b[0],S=b[1];this.onEviction(w,S)}}catch(T){y.e(T)}finally{y.f()}}this.oldCache=this.cache,this.cache=new Map}}},{key:"get",value:function(d){if(this.cache.has(d))return this.cache.get(d);if(this.oldCache.has(d)){var p=this.oldCache.get(d);return this.oldCache.delete(d),this._set(d,p),p}}},{key:"set",value:function(d,p){return this.cache.has(d)?this.cache.set(d,p):this._set(d,p),this}},{key:"has",value:function(d){return this.cache.has(d)||this.oldCache.has(d)}},{key:"peek",value:function(d){if(this.cache.has(d))return this.cache.get(d);if(this.oldCache.has(d))return this.oldCache.get(d)}},{key:"delete",value:function(d){var p=this.cache.delete(d);return p&&this._size--,this.oldCache.delete(d)||p}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"keys",value:M.default.mark(function f(){var d,p,y,g;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:d=nr(this),w.prev=1,d.s();case 3:if((p=d.n()).done){w.next=9;break}return y=Q.default(p.value,1),g=y[0],w.next=7,g;case 7:w.next=3;break;case 9:w.next=14;break;case 11:w.prev=11,w.t0=w.catch(1),d.e(w.t0);case 14:return w.prev=14,d.f(),w.finish(14);case 17:case"end":return w.stop()}},f,this,[[1,11,14,17]])})},{key:"values",value:M.default.mark(function f(){var d,p,y,g;return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:d=nr(this),w.prev=1,d.s();case 3:if((p=d.n()).done){w.next=9;break}return y=Q.default(p.value,2),g=y[1],w.next=7,g;case 7:w.next=3;break;case 9:w.next=14;break;case 11:w.prev=11,w.t0=w.catch(1),d.e(w.t0);case 14:return w.prev=14,d.f(),w.finish(14);case 17:case"end":return w.stop()}},f,this,[[1,11,14,17]])})},{key:O,value:M.default.mark(function f(){var d,p,y,g,b,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:d=nr(this.cache),j.prev=1,d.s();case 3:if((p=d.n()).done){j.next=9;break}return y=p.value,j.next=7,y;case 7:j.next=3;break;case 9:j.next=14;break;case 11:j.prev=11,j.t0=j.catch(1),d.e(j.t0);case 14:return j.prev=14,d.f(),j.finish(14);case 17:g=nr(this.oldCache),j.prev=18,g.s();case 20:if((b=g.n()).done){j.next=28;break}if(w=b.value,S=Q.default(w,1),T=S[0],this.cache.has(T)){j.next=26;break}return j.next=26,w;case 26:j.next=20;break;case 28:j.next=33;break;case 30:j.prev=30,j.t1=j.catch(18),g.e(j.t1);case 33:return j.prev=33,g.f(),j.finish(33);case 36:case"end":return j.stop()}},f,this,[[1,11,14,17],[18,30,33,36]])})},{key:"size",get:function(){var d=0,p=nr(this.oldCache.keys()),y;try{for(p.s();!(y=p.n()).done;){var g=y.value;this.cache.has(g)||d++}}catch(b){p.e(b)}finally{p.f()}return Math.min(this._size+d,this.maxSize)}}]),P}(Symbol.iterator),z=mo,re=he.default(function O(P,f){pe.default(this,O),this.type=P,this.data=f,Object.freeze(f)}),be=function(){function O(P,f){pe.default(this,O),this._services=P,this._configuration=f,this._cache=new z({maxSize:f.channelMetadataCacheCapacity})}return he.default(O,[{key:"getChannelMetadata",value:function(){var P=Y.default(M.default.mark(function d(p,y){var g,b,w,S,T;return M.default.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(g="".concat(p,",").concat(y),b=this._cache.get(g),!b){j.next=4;break}return j.abrupt("return",b.item);case 4:return w="".concat(this._configuration.links.conversations,"/").concat(p,"/Messages/").concat(y,"/ChannelMetadata"),j.prev=5,j.next=8,this._services.commandExecutor.fetchResource(w);case 8:S=j.sent,j.next=17;break;case 11:if(j.prev=11,j.t0=j.catch(5),!(j.t0 instanceof et)){j.next=16;break}return this._cache.set(g,{item:null}),j.abrupt("return",null);case 16:throw new Error(j.t0);case 17:return T=new re(S.type,S.data),this._cache.set(g,{item:T}),j.abrupt("return",T);case 20:case"end":return j.stop()}},d,this,[[5,11]])}));function f(d,p){return P.apply(this,arguments)}return f}()}]),O}();function Ge(O,P){var f=typeof Symbol<"u"&&O[Symbol.iterator]||O["@@iterator"];if(!f){if(Array.isArray(O)||(f=Dt(O))||P){f&&(O=f);var d=0,p=function(){};return{s:p,n:function(){return d>=O.length?{done:!0}:{done:!1,value:O[d++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
463
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function Dt(O,P){if(O){if(typeof O=="string")return ht(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return ht(O,P)}}function ht(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}var jt=he.default(function O(P){pe.default(this,O),Pe.default(this,"type","email"),this.messageSid=P.message_sid,this.level=P.level,this.name=P.name,this.address=P.address}),Xt=he.default(function O(P){pe.default(this,O),this.type=P.type,this.messageSid=P.message_sid,this.rawData=JSON.stringify(P)}),ir=function(){function O(P,f){pe.default(this,O),this._services=P,this._configuration=f,this._cache=new z({maxSize:f.messageRecipientsCacheCapacity})}return he.default(O,[{key:"getRecipientsFromMessage",value:function(){var P=Y.default(M.default.mark(function d(p,y){var g=this,b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(b="".concat(p,",").concat(y),w=this._cache.get(b),!w){V.next=4;break}return V.abrupt("return",w.item);case 4:return S=new It(this._configuration.links.conversations).path(p).path("MessageRecipients").arg("MessageSid",y).build(),V.next=7,this._services.commandExecutor.fetchResource(S);case 7:return T=V.sent,F=T.message_recipients.map(function(W){return g._wrapResponse(W)}),F.length>0&&this._cache.set(b,{item:F}),V.abrupt("return",F);case 11:case"end":return V.stop()}},d,this)}));function f(d,p){return P.apply(this,arguments)}return f}()},{key:"getRecipientsFromConversation",value:function(){var P=Y.default(M.default.mark(function d(p,y){var g,b,w=this,S,T,F,j,V,W,Ie,ze,je,qe;return M.default.wrap(function(mt){for(;;)switch(mt.prev=mt.next){case 0:return S=new It(this._configuration.links.conversations).path(p).path("MessageRecipients").arg("PageToken",(g=y==null?void 0:y.pageToken)!==null&&g!==void 0?g:void 0).arg("PageSize",(b=y==null?void 0:y.pageSize)!==null&&b!==void 0?b:void 0).build(),mt.next=3,this._services.commandExecutor.fetchResource(S);case 3:T=mt.sent,F=T.message_recipients.map(function(nt){return w._wrapResponse(nt)}),j=Ge(F);try{for(j.s();!(V=j.n()).done;)ze=V.value,je="".concat(p,",").concat(ze.messageSid),qe=(W=(Ie=this._cache.get(je))===null||Ie===void 0?void 0:Ie.item)!==null&&W!==void 0?W:[],this._cache.set(je,{item:[].concat(De.default(qe),[ze])})}catch(nt){j.e(nt)}finally{j.f()}return mt.abrupt("return",new Ve(F,function(nt,er){return w.getRecipientsFromConversation(p,{pageToken:nt,pageSize:er})},T.meta.previous_token,T.meta.next_token));case 8:case"end":return mt.stop()}},d,this)}));function f(d,p){return P.apply(this,arguments)}return f}()},{key:"_wrapResponse",value:function(f){switch(f.type){case"email":return new jt(f);default:return new Xt(f)}}}]),O}(),rt;function Sr(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function Cr(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?Sr(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):Sr(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function Zt(O){var P=Tr();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function Tr(){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 ct,yn=he.default(function O(){pe.default(this,O)});e.Client=ct=(rt=function(O){He.default(f,O);var P=Zt(f);function f(d){var p,y,g,b,w,S,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(pe.default(this,f),S=P.call(this),Pe.default(Ue.default(S),"version",E),Pe.default(Ue.default(S),"connectionState","unknown"),Pe.default(Ue.default(S),"parsePushNotification",ct.parsePushNotification),S._fpaToken=d??"",S._options=T??{},!S._options.disableDeepClone){var F=Cr(Cr({},S._options),{},{transport:void 0,twilsockClient:void 0});F=Pt(F),F.transport=S._options.transport,F.twilsockClient=S._options.twilsockClient,S._options=F}S._options.logLevel=(p=S._options.logLevel)!==null&&p!==void 0?p:"silent",ct._logger.setLevel(S._options.logLevel);var j=S._options.productId="ip_messaging";if(S._options.clientMetadata=S._options.clientMetadata||{},S._options.clientMetadata.hasOwnProperty("type")||(S._options.clientMetadata.type="conversations"),S._options.clientMetadata.hasOwnProperty("sdk")||(S._options.clientMetadata.sdk="JS",S._options.clientMetadata.sdkv=E),S._options.Sync=S._options.Sync||{},typeof S._options.Sync.enableSessionStorage>"u"&&(S._options.Sync.enableSessionStorage=!0),S._options.region&&(S._options.Sync.region=S._options.region),!d)throw new Error("A valid Twilio token should be provided");S._services=new yn,S._myself=new ve("","",null,S._services);var V=!S._options.twilsockClient;if(!S._options.initRegistrations){var W=new q.InitRegistration(j);ct.populateInitRegistrations(W),S._options.initRegistrations=[W]}S._services.twilsockClient=S._options.twilsockClient=(y=S._options.twilsockClient)!==null&&y!==void 0?y:new q.TwilsockClient(d,j,S._options),S._services.twilsockClient.on(ct.tokenAboutToExpire,function(){return S.emit(ct.tokenAboutToExpire)}),S._services.twilsockClient.on(ct.tokenExpired,function(){return S.emit(ct.tokenExpired)}),S._services.twilsockClient.on(ct.connectionError,function(mt){return S.emit(ct.connectionError,mt)}),S._services.twilsockClient.on("stateChanged",function(mt){ct._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(mt)),mt!==S.connectionState&&(S.connectionState=mt,S.emit(ct.connectionStateChanged,S.connectionState))}),S._services.transport=S._options.transport=(g=S._options.transport)!==null&&g!==void 0?g:S._options.twilsockClient,S._services.notificationClient=S._options.notificationsClient=(b=S._options.notificationsClient)!==null&&b!==void 0?b:new X.Notifications(d,S._options),S._services.syncClient=S._options.syncClient=(w=S._options.syncClient)!==null&&w!==void 0?w:new J.SyncClient(d,S._options);var Ie=(T==null?void 0:T.Chat)||(T==null?void 0:T.IPMessaging)||T||{},ze=Ie.region||(T==null?void 0:T.region),je=Ie.apiUri||Ie.typingUri||"https://aim.".concat(ze||"us1",".twilio.com");S._services.commandExecutor=new hr(je,{transport:S._options.transport},j),S._services.contentClient=new Kr(S._services);var qe=function(nt){S._rejectEnsureReady(nt),S.emit(ct.stateChanged,"failed"),S.emit(ct.initFailed,{error:nt})},Tt=function(){qe({terminal:!0,message:"Twilsock has disconnected."}),S._initializeEnsureReady((T==null?void 0:T.throwErrorsAlways)||!1)};return S._services.twilsockClient.once("connectionError",qe),S._services.twilsockClient.once("disconnected",Tt),S._services.twilsockClient.once("connected",Y.default(M.default.mark(function mt(){var nt,er;return M.default.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:return ct._logger.debug("ConversationsClient started INITIALIZING"),S._services.twilsockClient.off("connectionError",qe),S._services.twilsockClient.off("disconnected",Tt),tt.prev=3,nt="conversations.client.startup",S._services.twilsockClient.addPartialTelemetryEvent(new q.TelemetryEventDescription(nt,"Conversations client startup",new Date),nt,q.TelemetryPoint.Start),tt.next=8,S._initialize();case 8:S._services.twilsockClient.addPartialTelemetryEvent(new q.TelemetryEventDescription("","",new Date),nt,q.TelemetryPoint.End),tt.next=17;break;case 11:tt.prev=11,tt.t0=tt.catch(3),er={terminal:!0,message:tt.t0.message},S._rejectEnsureReady(er),S.emit(ct.stateChanged,"failed"),S.emit(ct.initFailed,{error:er});case 17:case"end":return tt.stop()}},mt,null,[[3,11]])}))),S._initializeEnsureReady((T==null?void 0:T.throwErrorsAlways)||!1),V&&S._services.twilsockClient.connect(),S}return he.default(f,[{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 d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"updateToken",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:if(ct._logger.info("updateToken"),this._fpaToken!==g){w.next=5;break}return w.abrupt("return",this);case 5:return w.next=7,this._services.twilsockClient.updateToken(g);case 7:return w.next=9,this._services.notificationClient.updateToken(g);case 9:return w.next=11,this._services.mcsClient.updateToken(g);case 11:return this._fpaToken=g,w.abrupt("return",this);case 13:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getConversationBySid",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return S.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return S.next=6,this._conversationsEntity.getConversation(g);case 6:if(b=S.sent,b){S.next=12;break}return S.next=10,this.peekConversationBySid(g);case 10:b=S.sent,b&&L.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(b){S.next=14;break}throw new Error("Conversation with SID ".concat(g," was not found."));case 14:return S.abrupt("return",b);case 15:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"peekConversationBySid",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return S.next=4,this._conversationsEntity.peekConversation(g);case 4:if(b=S.sent,b){S.next=7;break}throw new Error("Conversation with SID ".concat(g," was not found."));case 7:return S.abrupt("return",b);case 8:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getConversationByUniqueName",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return S.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return S.next=6,this._conversationsEntity.getConversationByUniqueName(g);case 6:if(b=S.sent,b){S.next=9;break}throw new Error("Conversation with unique name ".concat(g," was not found."));case 9:return S.abrupt("return",b);case 10:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getSubscribedConversations",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.abrupt("return",this._conversationsPromise.then(function(w){return w.getConversations()}));case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"createConversation",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:return g=g||{},w.abrupt("return",this._conversationsPromise.then(function(S){return S.addConversation(g)}));case 4:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"setPushRegistrationId",value:function(){var d=Y.default(M.default.mark(function y(g,b){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(g),this._services.notificationClient.setPushRegistrationId(g,b),S.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return S.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"unsetPushRegistrationId",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(g),w.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"removePushRegistrations",value:function(){var d=Y.default(M.default.mark(function y(g,b){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._services.notificationClient.removeRegistrations(g,b);case 2:case"end":return S.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"handlePushNotification",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:ct._logger.debug("handlePushNotification, notificationPayload=",g),this.emit("pushNotification",ct.parsePushNotification(g));case 4:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getUser",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:return w.abrupt("return",this._services.users.getUser(g));case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getSubscribedUsers",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(p){var y=this;return new G.CancellablePromise(function(){var g=Y.default(M.default.mark(function b(w,S,T){var F,j;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(!(!y._services.mcsClient||!p)){W.next=3;break}return S(new Error("Media Content Service is unavailable")),W.abrupt("return");case 3:return F=y._services.mcsClient.mediaSetGetContentUrls(p),T(function(){F.cancel()}),W.prev=5,W.next=8,F;case 8:j=W.sent,w(j),W.next=15;break;case 12:W.prev=12,W.t0=W.catch(5),S(W.t0);case 15:case"end":return W.stop()}},b,null,[[5,12]])}));return function(b,w,S){return g.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(p){var y=p.map(function(g){return g.sid});return this.getTemporaryContentUrlsForMediaSids(y)}},{key:"getContentTemplates",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.next=4,this._services.contentClient.getContentTemplates();case 4:return b.abrupt("return",b.sent);case 5:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_initialize",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return b=S.sent,this._configuration=new Ct(this._options,b,ct._logger),this._services.channelMetadataClient=new be(this._services,this._configuration),this._services.messageRecipientsClient=new ir(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new R(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new oe(this._configuration,this._services),this._services.users=new D(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function(T){g.emit("userSubscribed",T)}),this._services.users.on("userUpdated",function(T){return g.emit("userUpdated",T)}),this._services.users.on("userUnsubscribed",function(T){g.emit("userUnsubscribed",T)}),this._conversationsEntity=new $r(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function(T){g.emit("conversationAdded",T)}),this._conversationsEntity.on("conversationRemoved",function(T){g.emit("conversationRemoved",T)}),this._conversationsEntity.on("conversationJoined",function(T){g.emit("conversationJoined",T)}),this._conversationsEntity.on("conversationLeft",function(T){g.emit("conversationLeft",T)}),this._conversationsEntity.on("conversationUpdated",function(T){return g.emit("conversationUpdated",T)}),this._conversationsEntity.on("participantJoined",function(T){g.emit("participantJoined",T)}),this._conversationsEntity.on("participantLeft",function(T){g.emit("participantLeft",T)}),this._conversationsEntity.on("participantUpdated",function(T){return g.emit("participantUpdated",T)}),this._conversationsEntity.on("messageAdded",function(T){return g.emit("messageAdded",T)}),this._conversationsEntity.on("messageUpdated",function(T){return g.emit("messageUpdated",T)}),this._conversationsEntity.on("messageRemoved",function(T){return g.emit("messageRemoved",T)}),this._conversationsEntity.on("typingStarted",function(T){return g.emit("typingStarted",T)}),this._conversationsEntity.on("typingEnded",function(T){return g.emit("typingEnded",T)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return g._conversationsEntity}).catch(function(T){throw T}),S.next=30,this._services.users.myself._ensureFetched();case 30:ct._supportedPushChannels.forEach(function(T){return g._subscribeToPushNotifications(T)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new G.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,Cr(Cr({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(ct.stateChanged,"initialized"),this.emit(ct.initialized);case 36:case"end":return S.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_subscribeToPushNotifications",value:function(p){var y=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(g){y._services.notificationClient.subscribe(p,g)})}},{key:"_unsubscribeFromPushNotifications",value:function(p){var y=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(g){y._services.notificationClient.unsubscribe(p,g)})}},{key:"_initializeEnsureReady",value:function(p){var y=this;this._ensureReady=new Promise(function(g,b){y._resolveEnsureReady=g,y._rejectEnsureReady=b}).catch(function(g){if(p)throw g})}}],[{key:"create",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(!(b!=null&&b.twilsockClient)){T.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 w=new ct(g,b),T.next=5,w._ensureReady;case 5:return T.abrupt("return",w);case 6:case"end":return T.stop()}},y)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"parsePushNotification",value:function(p){if(ct._logger.debug("parsePushNotification, notificationPayload=",p),typeof p.aps<"u"){if(!p.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var y=ct._parsePushNotificationChatData(p),g=p.aps,b,w=null;if(typeof g.alert=="string")b=g.alert||null;else{var S,T;b=((S=g.alert)===null||S===void 0?void 0:S.body)||null,w=((T=g.alert)===null||T===void 0?void 0:T.title)||null}return new k({title:w,body:b,sound:g.sound||null,badge:g.badge||null,action:g.category||null,type:p.twi_message_type,data:y})}if(typeof p.data<"u"){var F=p.data;if(!F.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var j=ct._parsePushNotificationChatData(p.data);return new k({title:F.twi_title||null,body:F.twi_body||null,sound:F.twi_sound||null,badge:null,action:F.twi_action||null,type:F.twi_message_type,data:j})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(p){var y={};for(var g in ct._supportedPushDataFields){var b=p[g];if(!(typeof b>"u"||b===null)){if(g==="message_index"||g==="media_count"){var w=yt(b);w!==null&&(y[ct._supportedPushDataFields[g]]=w);continue}if(g==="media"){if(typeof b=="string")try{y[ct._supportedPushDataFields[g]]=JSON.parse(b)}catch{ct._logger.debug("Media message notification parsing error")}continue}y[ct._supportedPushDataFields[g]]=b}}return y}},{key:"populateInitRegistrations",value:function(p){p.populateInitRegistrations([me.TYPING_INDICATOR]),J.SyncClient.populateInitRegistrations(p)}}]),f}(I.ReplayEventEmitter),Pe.default(rt,"conversationAdded","conversationAdded"),Pe.default(rt,"conversationJoined","conversationJoined"),Pe.default(rt,"conversationLeft","conversationLeft"),Pe.default(rt,"conversationRemoved","conversationRemoved"),Pe.default(rt,"conversationUpdated","conversationUpdated"),Pe.default(rt,"participantJoined","participantJoined"),Pe.default(rt,"participantLeft","participantLeft"),Pe.default(rt,"participantUpdated","participantUpdated"),Pe.default(rt,"messageAdded","messageAdded"),Pe.default(rt,"messageRemoved","messageRemoved"),Pe.default(rt,"messageUpdated","messageUpdated"),Pe.default(rt,"tokenAboutToExpire","tokenAboutToExpire"),Pe.default(rt,"tokenExpired","tokenExpired"),Pe.default(rt,"typingEnded","typingEnded"),Pe.default(rt,"typingStarted","typingStarted"),Pe.default(rt,"pushNotification","pushNotification"),Pe.default(rt,"userSubscribed","userSubscribed"),Pe.default(rt,"userUnsubscribed","userUnsubscribed"),Pe.default(rt,"userUpdated","userUpdated"),Pe.default(rt,"stateChanged","stateChanged"),Pe.default(rt,"initialized","initialized"),Pe.default(rt,"initFailed","initFailed"),Pe.default(rt,"connectionStateChanged","connectionStateChanged"),Pe.default(rt,"connectionError","connectionError"),Pe.default(rt,"version",E),Pe.default(rt,"_logger",Gt.scope("Client")),Pe.default(rt,"_supportedPushChannels",["fcm","apn"]),Pe.default(rt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),rt),_e([L.deprecated("token"),le("design:type",String),le("design:paramtypes",[])],e.Client.prototype,"token",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"updateToken",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),_e([_.validateTypesAsync(["undefined",_.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],e.Client.prototype,"createConversation",null),_e([_.validateTypesAsync(_.literal("fcm","apn"),"string"),le("design:type",Function),le("design:paramtypes",[String,String]),le("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),_e([_.validateTypesAsync(_.literal("fcm","apn")),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),_e([_.validateTypesAsync(_.literal("fcm","apn"),_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String,String]),le("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),_e([_.validateTypesAsync(_.pureObject),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"getUser",null),_e([_.validateTypesAsync(_.nonEmptyArray("strings","string")),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",G.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),_e([_.validateTypesAsync(_.nonEmptyArray("media",We)),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",G.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),_e([L.deprecated("Client.create()","new Client()"),_.validateTypesAsync("string",["undefined",_.pureObject]),le("design:type",Function),le("design:paramtypes",[String,Object]),le("design:returntype",Promise)],e.Client,"create",null),_e([_.validateTypes(_.pureObject),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",k)],e.Client,"parsePushNotification",null),e.Client=ct=_e([_.validateConstructorTypes(_.nonEmptyString,[_.pureObject,"undefined"]),le("design:paramtypes",[String,Object])],e.Client),Object.defineProperty(e,"CancellablePromise",{enumerable:!0,get:function(){return G.CancellablePromise}}),e.AggregatedDeliveryReceipt=Be,e.ChannelMetadata=re,e.ContentTemplate=at,e.ContentTemplateVariable=Ze,e.Conversation=wt,e.DetailedDeliveryReceipt=Ye,e.EmailRecipientDescriptor=jt,e.Media=We,e.Message=ur,e.MessageBuilder=Yt,e.NotificationTypes=me,e.Participant=H,e.PushNotification=k,e.RestPaginator=Ve,e.UnknownRecipientDescriptor=Xt,e.UnsentMessage=Qn,e.User=ve})(P0);const Cn=new Sa("twilio-chat");class g1 extends _v{constructor(){super(...arguments);ut(this,"client");ut(this,"conversation")}async create(){const{token:t,identity:n}=await this.issueChatToken();this.identity=n,Cn.info(`Connecting chat, identity: ${n}, token: ${t}`);const i=new P0.Client(t);i.on("initialized",()=>{Cn.info("client: initialized"),this.events.triggerEvent("initialized")}),i.on("tokenAboutToExpire",()=>{Cn.info("client: tokenAboutToExpire"),this.refreshToken()}),i.on("tokenExpired",()=>{Cn.info("client: tokenExpired"),this.refreshToken()}),this.client=i}async refreshToken(){const{token:t}=await this.issueChatToken();await this.client.updateToken(t)}async join(t){const n=await this.client.getConversationBySid(t);n.status==="joined"?Cn.info("already joined conversation:",t):(await n.join(),Cn.info("success joined conversation:",t)),this.registerEvents(n),this.conversation=n}async preview(t){await(await this.conversation.getParticipantByIdentity(this.identity)).updateAttributes({chat_preview:t,chat_preview_updated_at:new Date().toJSON()})}async destroy(){this.client&&(await this.client.shutdown(),this.client=null,this.conversation=null)}async fetchMessages(t){return(await this.conversation.getMessages()).items.map(i=>{const a=AS(i);return t[a.$index]&&(a.file=t[a.$index]),this.trackInTask(a),a})}async sendMessage(t){try{const n=await this.conversation.sendMessage(JSON.stringify(t));return Cn.info(`Message sent from ${this.conversation.sid}, index: ${n}`),n}catch(n){Cn.warn(`Failed to send a message from ${this.conversation.sid}`,{error:n})}}startTyping(){this.conversation&&this.conversation.typing()}stopTyping(){}registerEvents(t){t.on("messageAdded",n=>{const i=AS(n);Cn.info(`Message added from ${this.conversation.sid}, index: ${i.$index}, sid: ${i.$sid}, timestamp: ${i.$timestamp}, user type: ${i.$userType}`),i.$userType!=="end_user"&&this.ping(),this.trackInTask(i),this.events.triggerEvent("message",i)}),t.on("participantJoined",n=>{Cn.info("conversation: memberJoined",n),this.events.triggerEvent("memberJoined",n.identity)}),t.on("participantLeft",n=>{Cn.info("conversation: memberLeft",n),this.events.triggerEvent("memberLeft",n.identity)}),t.on("typingStarted",n=>{this.events.triggerEvent("typingStarted",n.identity)}),t.on("typingEnded",n=>{this.events.triggerEvent("typingEnded",n.identity)})}}ut(g1,"type","twilio_conversations");wv(g1);function AS(e){const{index:r,sid:t,author:n,dateCreated:i,body:a}=e,[s,o]=n.split("-");let u=0;o&&(u=parseInt(o,10));const c={$index:r,$sid:t,$timestamp:i,$userType:s,$userId:u};try{const l=JSON.parse(a);return l.message&&!l.type?{...c,...l,type:"message"}:{...c,...l}}catch(l){return Cn.warn("Format message failed",{error:l,data:a}),{...c,type:"text",content:a}}}var qh={exports:{}},Pa=Pl;function Pl(){}Pl.mixin=function(e){var r=e.prototype||e;r.isWildEmitter=!0,r.on=function(t,n,i){this.callbacks=this.callbacks||{};var a=arguments.length===3,s=a?arguments[1]:void 0,o=a?arguments[2]:arguments[1];return o._groupName=s,(this.callbacks[t]=this.callbacks[t]||[]).push(o),this},r.once=function(t,n,i){var a=this,s=arguments.length===3,o=s?arguments[1]:void 0,u=s?arguments[2]:arguments[1];function c(){a.off(t,c),u.apply(this,arguments)}return this.on(t,o,c),this},r.releaseGroup=function(t){this.callbacks=this.callbacks||{};var n,i,a,s;for(n in this.callbacks)for(s=this.callbacks[n],i=0,a=s.length;i<a;i++)s[i]._groupName===t&&(s.splice(i,1),i--,a--);return this},r.off=function(t,n){this.callbacks=this.callbacks||{};var i=this.callbacks[t],a;return i?arguments.length===1?(delete this.callbacks[t],this):(a=i.indexOf(n),a!==-1&&(i.splice(a,1),i.length===0&&delete this.callbacks[t]),this):this},r.emit=function(t){this.callbacks=this.callbacks||{};var n=[].slice.call(arguments,1),i=this.callbacks[t],a=this.getWildcardCallbacks(t),s,o,u;if(i)for(u=i.slice(),s=0,o=u.length;s<o&&u[s];++s)u[s].apply(this,n);if(a)for(o=a.length,u=a.slice(),s=0,o=u.length;s<o&&u[s];++s)u[s].apply(this,[t].concat(n));return this},r.getWildcardCallbacks=function(t){this.callbacks=this.callbacks||{};var n,i,a=[];for(n in this.callbacks)i=n.split("*"),(n==="*"||i.length===2&&t.slice(0,i[0].length)===i[0])&&(a=a.concat(this.callbacks[n]));return a}};Pl.mixin(Pl);var y1={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.prefix=t(r)})(Ae,function(r){var t=function(l){for(var h=1,v=arguments.length,m;h<v;h++)for(m in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],m)&&(l[m]=arguments[h][m]);return l},n={template:"[%t] %l:",levelFormatter:function(l){return l.toUpperCase()},nameFormatter:function(l){return l||"root"},timestampFormatter:function(l){return l.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},i,a={},s=function(l){if(!l||!l.getLogger)throw new TypeError("Argument is not a root logger");i=l},o=function(l,h){if(!l||!l.setLevel)throw new TypeError("Argument is not a logger");var v=l.methodFactory,m=l.name||"",_=a[m]||a[""]||n;function C(I,$,x){var N=v(I,$,x),q=a[x]||a[""],X=q.template.indexOf("%t")!==-1,J=q.template.indexOf("%l")!==-1,G=q.template.indexOf("%n")!==-1;return function(){for(var L="",te=arguments.length,se=Array(te),ne=0;ne<te;ne++)se[ne]=arguments[ne];if(m||!a[x]){var ge=q.timestampFormatter(new Date),Y=q.levelFormatter(I),Ue=q.nameFormatter(x);q.format?L+=q.format(Y,Ue,ge):(L+=q.template,X&&(L=L.replace(/%t/,ge)),J&&(L=L.replace(/%l/,Y)),G&&(L=L.replace(/%n/,Ue))),se.length&&typeof se[0]=="string"?se[0]=L+" "+se[0]:se.unshift(L)}N.apply(void 0,se)}}return a[m]||(l.methodFactory=C),h=h||{},h.template&&(h.format=void 0),a[m]=t({},_,h),l.setLevel(l.getLevel()),i||l.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),l},u={reg:s,apply:o},c;return r&&(c=r.prefix,u.noConflict=function(){return r.prefix===u&&(r.prefix=c),u}),u})})(y1);var hY=y1.exports,zh={exports:{}},vY={"error:application:call:params":{type:"error:application:call:params",description:"not a valid String[] of usernames param"},"error:application:callServer:params":{type:"error:application:call:params",description:"not a valid String of phone number"},"error:call:reject":{type:"error:call:reject",description:"failed to reject the call"},"error:getUserMedia:permissions":{type:"error:getUserMedia:permissions",description:"missing getUserMedia permissions"},"error:media:params":{type:"error:media:params",description:"currently supported params media type= {audio:{muted:false, earmuffed:false}}"},"error:media:reenable":{type:"error:media:reenable",description:"missing reconnectRtcId required to reenable media"},"error:self":{type:"error:self",description:"Conversation Object is missing self (me)"},"error:user:relogin":{type:"error:user:relogin",description:"please relogin"},"error:seen:own-message":{type:"error:seen:own-message",description:"attempt to send seen for own message"},"error:already-seen":{type:"error:already-seen",description:"already marked as seen"},"error:delivered:own-message":{type:"error:delivered:own-message",description:"attempt to send delivered for own message"},"error:already-delivered":{type:"error:already-delivered",description:"already marked as delivered"},"error:fetch-image":{type:"error:fetch-image",description:"xhr.status received other than 200"},"error:delete-image":{type:"error:delete-image",description:"xhr.status received other than 204"},"error:missing:params":{type:"error:missing:params",description:"missing parameters"},"error:invite:missing:params":{type:"error:missing:params",description:"This invite cannot be sent to empty username and user_id"},"error:invalid:param:type":{type:"error:invalid:param:type",description:"Invalid Object type, passed in the parameters"},"error:audio:already-connecting":{type:"error:audio:already-connecting",description:"Audio call already in progress"},"error:audio:not-enabled":{type:"error:audio:not-enabled",description:"Audio is not enabled"},"error:media:already-connecting":{type:"error:media:already-connecting",description:"Media is already in progress"},"error:media:unsupported-browser":{type:"error:media:unsupported-browser",description:"This action is not supported on this browser"},"error:media:extension":{type:"error:media:extension",description:"Chrome extension has thrown an error"},"error:media:extension-not-installed":{type:"error:media:extension-not-installed",description:"Chrome extension should be installed"},"error:media:update:streams":{type:"error:media:update:streams",description:"cant update more than one stream"},"error:media:update:invalid":{type:"error:media:update:invalid",description:"state of media is not supported for this update"},"error:media:stream:not-found":{type:"error:media:stream:not-found",description:"A stream with the given index was not found"},"error:audio:dtmf:invalid-digit":{type:"error:audio:dtmf:invalid-digit",description:"not a valid string of dtmf digits (0-9,a-d,A-D,p,P,*,#)"},"error:audio:dtmf:audio-disabled":{type:"error:audio:dtmf:audio-disabled",description:"Audio must be enabled to send DTMF"},"error:invalid-order":{type:"error:invalid-order",description:"params not valid. Order must be asc or desc"},"error:custom-event:invalid":{type:"error:custom-event:invalid",description:"Custom event type not valid"},"error:message-event:invalid":{type:"error:message-event:invalid",description:"message_type is missing or is invalid"},"error:invalid-cursor":{type:"error:invalid-cursor",description:"page does not exist"},"error:client:reconnection_failed":{type:"error:client:reconnection_failed",description:"websocket failed to reconnect"},"error:conversation-service:version":{type:"error:conversation:version",description:'Wrong version of Conversation Service API. It should be one of "v1" or "v3"'},"error:no-media-offer":{type:"error:no-media-offer",description:"Media preload attempt without having an offer available"},"error:input:unsanitized":{type:"error:input:unsanitized",description:"Input is not sanitized"}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.NexmoApiError=r.NexmoClientError=void 0;const t=vY,n=gr;function i(o,u){var c,l;u!=null&&u.code&&(u.type=u.code,delete u.code),Object.assign(o,u),o.message="type: "+o.type+", description: "+((l=(c=o.description)!==null&&c!==void 0?c:o.detail)!==null&&l!==void 0?l:"")}class a{constructor(u){const c=t[u];c?i(this,c):(this.message=u&&u.message?u.message:u,this.stack=u.stack),this.log=n.getLogger(this.constructor.name),this.log.error(this),this.name="NexmoClientError",typeof Ae.NXMbugsnagClient<"u"&&Ae.NXMbugsnagClient.notify(this,{severity:"info"})}}r.NexmoClientError=a;class s{constructor(u){this.log=n.getLogger(this.constructor.name),u?i(this,u):(this.message=u&&u.message?u.message:u,this.stack=u&&u.stack?u.stack:new Error().stack),this.name="NexmoApiError",this.log=n.getLogger(this.constructor.name),this.log.error(this),typeof Ae.NXMbugsnagClient<"u"&&Ae.NXMbugsnagClient.notify(this,{severity:"info"})}}r.NexmoApiError=s,e.exports={NexmoClientError:a,NexmoApiError:s}})(zh,zh.exports);var Mn=zh.exports,Wh={exports:{}},lg={},_f={},Ni={},xu={},oi={},Nu={},Ui={},po={},Lu={},ui={};Object.defineProperty(ui,"__esModule",{value:!0});ui.ERROR_PACKET=ui.PACKET_TYPES_REVERSE=ui.PACKET_TYPES=void 0;const ci=Object.create(null);ui.PACKET_TYPES=ci;ci.open="0";ci.close="1";ci.ping="2";ci.pong="3";ci.message="4";ci.upgrade="5";ci.noop="6";const b1=Object.create(null);ui.PACKET_TYPES_REVERSE=b1;Object.keys(ci).forEach(e=>{b1[ci[e]]=e});const mY={type:"error",data:"parser error"};ui.ERROR_PACKET=mY;Object.defineProperty(Lu,"__esModule",{value:!0});Lu.encodePacket=void 0;Lu.encodePacketToBinary=yY;const gY=ui,_1=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",w1=typeof ArrayBuffer=="function",S1=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,C1=({type:e,data:r},t,n)=>_1&&r instanceof Blob?t?n(r):MS(r,n):w1&&(r instanceof ArrayBuffer||S1(r))?t?n(r):MS(new Blob([r]),n):n(gY.PACKET_TYPES[e]+(r||""));Lu.encodePacket=C1;const MS=(e,r)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];r("b"+(n||""))},t.readAsDataURL(e)};function xS(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let $p;function yY(e,r){if(_1&&e.data instanceof Blob)return e.data.arrayBuffer().then(xS).then(r);if(w1&&(e.data instanceof ArrayBuffer||S1(e.data)))return r(xS(e.data));C1(e,!1,t=>{$p||($p=new TextEncoder),r($p.encode(t))})}var wf={},eo={};Object.defineProperty(eo,"__esModule",{value:!0});eo.decode=eo.encode=void 0;const Ms="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Ms.length;e++)Fo[Ms.charCodeAt(e)]=e;const bY=e=>{let r=new Uint8Array(e),t,n=r.length,i="";for(t=0;t<n;t+=3)i+=Ms[r[t]>>2],i+=Ms[(r[t]&3)<<4|r[t+1]>>4],i+=Ms[(r[t+1]&15)<<2|r[t+2]>>6],i+=Ms[r[t+2]&63];return n%3===2?i=i.substring(0,i.length-1)+"=":n%3===1&&(i=i.substring(0,i.length-2)+"=="),i};eo.encode=bY;const _Y=e=>{let r=e.length*.75,t=e.length,n,i=0,a,s,o,u;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);const c=new ArrayBuffer(r),l=new Uint8Array(c);for(n=0;n<t;n+=4)a=Fo[e.charCodeAt(n)],s=Fo[e.charCodeAt(n+1)],o=Fo[e.charCodeAt(n+2)],u=Fo[e.charCodeAt(n+3)],l[i++]=a<<2|s>>4,l[i++]=(s&15)<<4|o>>2,l[i++]=(o&3)<<6|u&63;return c};eo.decode=_Y;Object.defineProperty(wf,"__esModule",{value:!0});wf.decodePacket=void 0;const $c=ui,wY=eo,SY=typeof ArrayBuffer=="function",CY=(e,r)=>{if(typeof e!="string")return{type:"message",data:T1(e,r)};const t=e.charAt(0);return t==="b"?{type:"message",data:TY(e.substring(1),r)}:$c.PACKET_TYPES_REVERSE[t]?e.length>1?{type:$c.PACKET_TYPES_REVERSE[t],data:e.substring(1)}:{type:$c.PACKET_TYPES_REVERSE[t]}:$c.ERROR_PACKET};wf.decodePacket=CY;const TY=(e,r)=>{if(SY){const t=(0,wY.decode)(e);return T1(t,r)}else return{base64:!0,data:e}},T1=(e,r)=>{switch(r){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodePayload=e.decodePacket=e.encodePayload=e.encodePacket=e.protocol=void 0,e.createPacketEncoderStream=o,e.createPacketDecoderStream=h;const r=Lu;Object.defineProperty(e,"encodePacket",{enumerable:!0,get:function(){return r.encodePacket}});const t=wf;Object.defineProperty(e,"decodePacket",{enumerable:!0,get:function(){return t.decodePacket}});const n=ui,i="",a=(v,m)=>{const _=v.length,C=new Array(_);let I=0;v.forEach(($,x)=>{(0,r.encodePacket)($,!1,N=>{C[x]=N,++I===_&&m(C.join(i))})})};e.encodePayload=a;const s=(v,m)=>{const _=v.split(i),C=[];for(let I=0;I<_.length;I++){const $=(0,t.decodePacket)(_[I],m);if(C.push($),$.type==="error")break}return C};e.decodePayload=s;function o(){return new TransformStream({transform(v,m){(0,r.encodePacketToBinary)(v,_=>{const C=_.length;let I;if(C<126)I=new Uint8Array(1),new DataView(I.buffer).setUint8(0,C);else if(C<65536){I=new Uint8Array(3);const $=new DataView(I.buffer);$.setUint8(0,126),$.setUint16(1,C)}else{I=new Uint8Array(9);const $=new DataView(I.buffer);$.setUint8(0,127),$.setBigUint64(1,BigInt(C))}v.data&&typeof v.data!="string"&&(I[0]|=128),m.enqueue(I),m.enqueue(_)})}})}let u;function c(v){return v.reduce((m,_)=>m+_.length,0)}function l(v,m){if(v[0].length===m)return v.shift();const _=new Uint8Array(m);let C=0;for(let I=0;I<m;I++)_[I]=v[0][C++],C===v[0].length&&(v.shift(),C=0);return v.length&&C<v[0].length&&(v[0]=v[0].slice(C)),_}function h(v,m){u||(u=new TextDecoder);const _=[];let C=0,I=-1,$=!1;return new TransformStream({transform(x,N){for(_.push(x);;){if(C===0){if(c(_)<1)break;const q=l(_,1);$=(q[0]&128)===128,I=q[0]&127,I<126?C=3:I===126?C=1:C=2}else if(C===1){if(c(_)<2)break;const q=l(_,2);I=new DataView(q.buffer,q.byteOffset,q.length).getUint16(0),C=3}else if(C===2){if(c(_)<8)break;const q=l(_,8),X=new DataView(q.buffer,q.byteOffset,q.length),J=X.getUint32(0);if(J>Math.pow(2,21)-1){N.enqueue(n.ERROR_PACKET);break}I=J*Math.pow(2,32)+X.getUint32(4),C=3}else{if(c(_)<I)break;const q=l(_,I);N.enqueue((0,t.decodePacket)($?q:u.decode(q),m)),C=0}if(I===0||I>v){N.enqueue(n.ERROR_PACKET);break}}}})}e.protocol=4})(po);function jr(e){if(e)return EY(e)}function EY(e){for(var r in jr.prototype)e[r]=jr.prototype[r];return e}jr.prototype.on=jr.prototype.addEventListener=function(e,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(r),this};jr.prototype.once=function(e,r){function t(){this.off(e,t),r.apply(this,arguments)}return t.fn=r,this.on(e,t),this};jr.prototype.off=jr.prototype.removeListener=jr.prototype.removeAllListeners=jr.prototype.removeEventListener=function(e,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+e];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,i=0;i<t.length;i++)if(n=t[i],n===r||n.fn===r){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+e],this};jr.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),t=this._callbacks["$"+e],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,i=t.length;n<i;++n)t[n].apply(this,r)}return this};jr.prototype.emitReserved=jr.prototype.emit;jr.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};jr.prototype.hasListeners=function(e){return!!this.listeners(e).length};const kY=Object.freeze(Object.defineProperty({__proto__:null,Emitter:jr},Symbol.toStringTag,{value:"Module"})),ho=O0(kY);var Jn={},Xr={};Object.defineProperty(Xr,"__esModule",{value:!0});Xr.defaultBinaryType=Xr.globalThisShim=Xr.nextTick=void 0;Xr.createCookieJar=RY;Xr.nextTick=typeof Promise=="function"&&typeof Promise.resolve=="function"?r=>Promise.resolve().then(r):(r,t)=>t(r,0);Xr.globalThisShim=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();Xr.defaultBinaryType="arraybuffer";function RY(){}Object.defineProperty(Jn,"__esModule",{value:!0});Jn.pick=$Y;Jn.installTimerFunctions=PY;Jn.byteLength=MY;Jn.randomString=NY;const ca=Xr;function $Y(e,...r){return r.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const IY=ca.globalThisShim.setTimeout,OY=ca.globalThisShim.clearTimeout;function PY(e,r){r.useNativeTimers?(e.setTimeoutFn=IY.bind(ca.globalThisShim),e.clearTimeoutFn=OY.bind(ca.globalThisShim)):(e.setTimeoutFn=ca.globalThisShim.setTimeout.bind(ca.globalThisShim),e.clearTimeoutFn=ca.globalThisShim.clearTimeout.bind(ca.globalThisShim))}const AY=1.33;function MY(e){return typeof e=="string"?xY(e):Math.ceil((e.byteLength||e.size)*AY)}function xY(e){let r=0,t=0;for(let n=0,i=e.length;n<i;n++)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:r<55296||r>=57344?t+=3:(n++,t+=4);return t}function NY(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}var Du={};Object.defineProperty(Du,"__esModule",{value:!0});Du.encode=LY;Du.decode=DY;function LY(e){let r="";for(let t in e)e.hasOwnProperty(t)&&(r.length&&(r+="&"),r+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return r}function DY(e){let r={},t=e.split("&");for(let n=0,i=t.length;n<i;n++){let a=t[n].split("=");r[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return r}var Vh={exports:{}},Ip,NS;function jY(){if(NS)return Ip;NS=1;var e=1e3,r=e*60,t=r*60,n=t*24,i=n*7,a=n*365.25;Ip=function(l,h){h=h||{};var v=typeof l;if(v==="string"&&l.length>0)return s(l);if(v==="number"&&isFinite(l))return h.long?u(l):o(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function s(l){if(l=String(l),!(l.length>100)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(h){var v=parseFloat(h[1]),m=(h[2]||"ms").toLowerCase();switch(m){case"years":case"year":case"yrs":case"yr":case"y":return v*a;case"weeks":case"week":case"w":return v*i;case"days":case"day":case"d":return v*n;case"hours":case"hour":case"hrs":case"hr":case"h":return v*t;case"minutes":case"minute":case"mins":case"min":case"m":return v*r;case"seconds":case"second":case"secs":case"sec":case"s":return v*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return v;default:return}}}}function o(l){var h=Math.abs(l);return h>=n?Math.round(l/n)+"d":h>=t?Math.round(l/t)+"h":h>=r?Math.round(l/r)+"m":h>=e?Math.round(l/e)+"s":l+"ms"}function u(l){var h=Math.abs(l);return h>=n?c(l,h,n,"day"):h>=t?c(l,h,t,"hour"):h>=r?c(l,h,r,"minute"):h>=e?c(l,h,e,"second"):l+" ms"}function c(l,h,v,m){var _=h>=v*1.5;return Math.round(l/v)+" "+m+(_?"s":"")}return Ip}function FY(e){t.debug=t,t.default=t,t.coerce=u,t.disable=a,t.enable=i,t.enabled=s,t.humanize=jY(),t.destroy=c,Object.keys(e).forEach(l=>{t[l]=e[l]}),t.names=[],t.skips=[],t.formatters={};function r(l){let h=0;for(let v=0;v<l.length;v++)h=(h<<5)-h+l.charCodeAt(v),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=r;function t(l){let h,v=null,m,_;function C(...I){if(!C.enabled)return;const $=C,x=Number(new Date),N=x-(h||x);$.diff=N,$.prev=h,$.curr=x,h=x,I[0]=t.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let q=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(J,G)=>{if(J==="%%")return"%";q++;const L=t.formatters[G];if(typeof L=="function"){const te=I[q];J=L.call($,te),I.splice(q,1),q--}return J}),t.formatArgs.call($,I),($.log||t.log).apply($,I)}return C.namespace=l,C.useColors=t.useColors(),C.color=t.selectColor(l),C.extend=n,C.destroy=t.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(m!==t.namespaces&&(m=t.namespaces,_=t.enabled(l)),_),set:I=>{v=I}}),typeof t.init=="function"&&t.init(C),C}function n(l,h){const v=t(this.namespace+(typeof h>"u"?":":h)+l);return v.log=this.log,v}function i(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let h;const v=(typeof l=="string"?l:"").split(/[\s,]+/),m=v.length;for(h=0;h<m;h++)v[h]&&(l=v[h].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function a(){const l=[...t.names.map(o),...t.skips.map(o).map(h=>"-"+h)].join(",");return t.enable(""),l}function s(l){if(l[l.length-1]==="*")return!0;let h,v;for(h=0,v=t.skips.length;h<v;h++)if(t.skips[h].test(l))return!1;for(h=0,v=t.names.length;h<v;h++)if(t.names[h].test(l))return!0;return!1}function o(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}var UY=FY;(function(e,r){r.formatArgs=n,r.save=i,r.load=a,r.useColors=t,r.storage=s(),r.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const c="color: "+this.color;u.splice(1,0,c,"color: inherit");let l=0,h=0;u[0].replace(/%[a-zA-Z%]/g,v=>{v!=="%%"&&(l++,v==="%c"&&(h=l))}),u.splice(h,0,c)}r.log=console.debug||console.log||(()=>{});function i(u){try{u?r.storage.setItem("debug",u):r.storage.removeItem("debug")}catch{}}function a(){let u;try{u=r.storage.getItem("debug")}catch{}return!u&&typeof process<"u"&&"env"in process&&(u=process.env.DEBUG),u}function s(){try{return localStorage}catch{}}e.exports=UY(r);const{formatters:o}=e.exports;o.j=function(u){try{return JSON.stringify(u)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}})(Vh,Vh.exports);var Yn=Vh.exports,BY=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ui,"__esModule",{value:!0});Ui.Transport=Ui.TransportError=void 0;const qY=po,zY=ho,WY=Jn,VY=Du,GY=BY(Yn),HY=(0,GY.default)("engine.io-client:transport");class E1 extends Error{constructor(r,t,n){super(r),this.description=t,this.context=n,this.type="TransportError"}}Ui.TransportError=E1;class KY extends zY.Emitter{constructor(r){super(),this.writable=!1,(0,WY.installTimerFunctions)(this,r),this.opts=r,this.query=r.query,this.socket=r.socket,this.supportsBinary=!r.forceBase64}onError(r,t,n){return super.emitReserved("error",new E1(r,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(r){this.readyState==="open"?this.write(r):HY("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(r){const t=(0,qY.decodePacket)(r,this.socket.binaryType);this.onPacket(t)}onPacket(r){super.emitReserved("packet",r)}onClose(r){this.readyState="closed",super.emitReserved("close",r)}pause(r){}createUri(r,t={}){return r+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const r=this.opts.hostname;return r.indexOf(":")===-1?r:"["+r+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(r){const t=(0,VY.encode)(r);return t.length?"?"+t:""}}Ui.Transport=KY;var JY=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Nu,"__esModule",{value:!0});Nu.Polling=void 0;const YY=Ui,XY=Jn,LS=po,QY=JY(Yn),Dn=(0,QY.default)("engine.io-client:polling");class ZY extends YY.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(r){this.readyState="pausing";const t=()=>{Dn("paused"),this.readyState="paused",r()};if(this._polling||!this.writable){let n=0;this._polling&&(Dn("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){Dn("pre-pause polling complete"),--n||t()})),this.writable||(Dn("we are currently writing - waiting to pause"),n++,this.once("drain",function(){Dn("pre-pause writing complete"),--n||t()}))}else t()}_poll(){Dn("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(r){Dn("polling got data %s",r);const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};(0,LS.decodePayload)(r,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this._poll():Dn('ignoring poll - transport state "%s"',this.readyState))}doClose(){const r=()=>{Dn("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(Dn("transport open - closing"),r()):(Dn("transport not open - deferring close"),this.once("open",r))}write(r){this.writable=!1,(0,LS.encodePayload)(r,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const r=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=(0,XY.randomString)()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(r,t)}}Nu.Polling=ZY;var Sf={};Object.defineProperty(Sf,"__esModule",{value:!0});Sf.hasCORS=void 0;let k1=!1;try{k1=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}Sf.hasCORS=k1;var eX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(oi,"__esModule",{value:!0});oi.XHR=oi.Request=oi.BaseXHR=void 0;const tX=Nu,rX=ho,DS=Jn,R1=Xr,nX=Sf,iX=eX(Yn),Gh=(0,iX.default)("engine.io-client:polling");function aX(){}class $1 extends tX.Polling{constructor(r){if(super(r),typeof location<"u"){const t=location.protocol==="https:";let n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&r.hostname!==location.hostname||n!==r.port}}doWrite(r,t){const n=this.request({method:"POST",data:r});n.on("success",t),n.on("error",(i,a)=>{this.onError("xhr post error",i,a)})}doPoll(){Gh("xhr poll");const r=this.request();r.on("data",this.onData.bind(this)),r.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=r}}oi.BaseXHR=$1;class Vn extends rX.Emitter{constructor(r,t,n){super(),this.createRequest=r,(0,DS.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var r;const t=(0,DS.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{Gh("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&n.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(r=this._opts.cookieJar)===null||r===void 0||r.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var i;n.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},Gh("xhr data %s",this._data),n.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=Vn.requestsCount++,Vn.requests[this._index]=this)}_onError(r){this.emitReserved("error",r,this._xhr),this._cleanup(!0)}_cleanup(r){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=aX,r)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Vn.requests[this._index],this._xhr=null}}_onLoad(){const r=this._xhr.responseText;r!==null&&(this.emitReserved("data",r),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}oi.Request=Vn;Vn.requestsCount=0;Vn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",jS);else if(typeof addEventListener=="function"){const e="onpagehide"in R1.globalThisShim?"pagehide":"unload";addEventListener(e,jS,!1)}}function jS(){for(let e in Vn.requests)Vn.requests.hasOwnProperty(e)&&Vn.requests[e].abort()}const sX=function(){const e=I1({xdomain:!1});return e&&e.responseType!==null}();class oX extends $1{constructor(r){super(r);const t=r&&r.forceBase64;this.supportsBinary=sX&&!t}request(r={}){return Object.assign(r,{xd:this.xd},this.opts),new Vn(I1,this.uri(),r)}}oi.XHR=oX;function I1(e){const r=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!r||nX.hasCORS))return new XMLHttpRequest}catch{}if(!r)try{return new R1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var wa={},uX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wa,"__esModule",{value:!0});wa.WS=wa.BaseWS=void 0;const cX=Ui,FS=Jn,lX=po,Hh=Xr,fX=uX(Yn),dX=(0,fX.default)("engine.io-client:websocket"),O1=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class P1 extends cX.Transport{get name(){return"websocket"}doOpen(){const r=this.uri(),t=this.opts.protocols,n=O1?{}:(0,FS.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(r,t,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=r=>this.onClose({description:"websocket connection closed",context:r}),this.ws.onmessage=r=>this.onData(r.data),this.ws.onerror=r=>this.onError("websocket error",r)}write(r){this.writable=!1;for(let t=0;t<r.length;t++){const n=r[t],i=t===r.length-1;(0,lX.encodePacket)(n,this.supportsBinary,a=>{try{this.doWrite(n,a)}catch{dX("websocket closed before onclose event")}i&&(0,Hh.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const r=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,FS.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(r,t)}}wa.BaseWS=P1;const Op=Hh.globalThisShim.WebSocket||Hh.globalThisShim.MozWebSocket;class pX extends P1{createSocket(r,t,n){return O1?new Op(r,t,n):t?new Op(r,t):new Op(r)}doWrite(r,t){this.ws.send(t)}}wa.WS=pX;var ju={},hX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ju,"__esModule",{value:!0});ju.WT=void 0;const vX=Ui,mX=Xr,US=po,gX=hX(Yn),Ao=(0,gX.default)("engine.io-client:webtransport");class yX extends vX.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(r){return this.emitReserved("error",r)}this._transport.closed.then(()=>{Ao("transport closed gracefully"),this.onClose()}).catch(r=>{Ao("transport closed due to %s",r),this.onError("webtransport error",r)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(r=>{const t=(0,US.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=r.readable.pipeThrough(t).getReader(),i=(0,US.createPacketEncoderStream)();i.readable.pipeTo(r.writable),this._writer=i.writable.getWriter();const a=()=>{n.read().then(({done:o,value:u})=>{if(o){Ao("session is closed");return}Ao("received chunk: %o",u),this.onPacket(u),a()}).catch(o=>{Ao("an error occurred while reading: %s",o)})};a();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(r){this.writable=!1;for(let t=0;t<r.length;t++){const n=r[t],i=t===r.length-1;this._writer.write(n).then(()=>{i&&(0,mX.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var r;(r=this._transport)===null||r===void 0||r.close()}}ju.WT=yX;Object.defineProperty(xu,"__esModule",{value:!0});xu.transports=void 0;const bX=oi,_X=wa,wX=ju;xu.transports={websocket:_X.WS,webtransport:wX.WT,polling:bX.XHR};var Cf={};Object.defineProperty(Cf,"__esModule",{value:!0});Cf.parse=TX;const SX=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,CX=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function TX(e){if(e.length>8e3)throw"URI too long";const r=e,t=e.indexOf("["),n=e.indexOf("]");t!=-1&&n!=-1&&(e=e.substring(0,t)+e.substring(t,n).replace(/:/g,";")+e.substring(n,e.length));let i=SX.exec(e||""),a={},s=14;for(;s--;)a[CX[s]]=i[s]||"";return t!=-1&&n!=-1&&(a.source=r,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=EX(a,a.path),a.queryKey=kX(a,a.query),a}function EX(e,r){const t=/\/{2,9}/g,n=r.replace(t,"/").split("/");return(r.slice(0,1)=="/"||r.length===0)&&n.splice(0,1),r.slice(-1)=="/"&&n.splice(n.length-1,1),n}function kX(e,r){const t={};return r.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,a){i&&(t[i]=a)}),t}var RX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ni,"__esModule",{value:!0});Ni.Socket=Ni.SocketWithUpgrade=Ni.SocketWithoutUpgrade=void 0;const $X=xu,BS=Jn,IX=Du,qS=Cf,OX=ho,A1=po,Pp=Xr,PX=RX(Yn),Ht=(0,PX.default)("engine.io-client:socket"),Kh=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ho=[];Kh&&addEventListener("offline",()=>{Ht("closing %d connection(s) because the network was lost",Ho.length),Ho.forEach(e=>e())},!1);class Li extends OX.Emitter{constructor(r,t){if(super(),this.binaryType=Pp.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,r&&typeof r=="object"&&(t=r,r=null),r){const n=(0,qS.parse)(r);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,qS.parse)(t.host).host);(0,BS.installTimerFunctions)(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{const i=n.prototype.name;this.transports.push(i),this._transportsByName[i]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=(0,IX.decode)(this.opts.query)),Kh&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(Ht("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ho.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,Pp.createCookieJar)()),this._open()}createTransport(r){Ht('creating transport "%s"',r);const t=Object.assign({},this.opts.query);t.EIO=A1.protocol,t.transport=r,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[r]);return Ht("options: %j",n),new this._transportsByName[r](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const r=this.opts.rememberUpgrade&&Li.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(r);t.open(),this.setTransport(t)}setTransport(r){Ht("setting transport %s",r.name),this.transport&&(Ht("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=r,r.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){Ht("socket open"),this.readyState="open",Li.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(Ht('socket receive: type "%s", data "%s"',r.type,r.data),this.emitReserved("packet",r),this.emitReserved("heartbeat"),r.type){case"open":this.onHandshake(JSON.parse(r.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=r.data,this._onError(t);break;case"message":this.emitReserved("data",r.data),this.emitReserved("message",r.data);break}else Ht('packet received with socket readyState "%s"',this.readyState)}onHandshake(r){this.emitReserved("handshake",r),this.id=r.sid,this.transport.query.sid=r.sid,this._pingInterval=r.pingInterval,this._pingTimeout=r.pingTimeout,this._maxPayload=r.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const r=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+r,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},r),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const r=this._getWritablePackets();Ht("flushing %d packets in socket",r.length),this.transport.send(r),this._prevBufferLen=r.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){const i=this.writeBuffer[n].data;if(i&&(t+=(0,BS.byteLength)(i)),n>0&&t>this._maxPayload)return Ht("only send %d out of %d packets",n,this.writeBuffer.length),this.writeBuffer.slice(0,n);t+=2}return Ht("payload size is %d (max: %d)",t,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const r=Date.now()>this._pingTimeoutTime;return r&&(Ht("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,Pp.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),r}write(r,t,n){return this._sendPacket("message",r,t,n),this}send(r,t,n){return this._sendPacket("message",r,t,n),this}_sendPacket(r,t,n,i){if(typeof t=="function"&&(i=t,t=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const a={type:r,data:t,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const r=()=>{this._onClose("forced close"),Ht("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),r()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():r()}):this.upgrading?n():r()),this}_onError(r){if(Ht("socket error %j",r),Li.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return Ht("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",r),this._onClose("transport error",r)}_onClose(r,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(Ht('socket close with reason: "%s"',r),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Kh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=Ho.indexOf(this._offlineEventListener);n!==-1&&(Ht("removing listener for the 'offline' event"),Ho.splice(n,1))}this.readyState="closed",this.id=null,this.emitReserved("close",r,t),this.writeBuffer=[],this._prevBufferLen=0}}}Ni.SocketWithoutUpgrade=Li;Li.protocol=A1.protocol;class M1 extends Li{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade){Ht("starting upgrade probes");for(let r=0;r<this._upgrades.length;r++)this._probe(this._upgrades[r])}}_probe(r){Ht('probing transport "%s"',r);let t=this.createTransport(r),n=!1;Li.priorWebsocketSuccess=!1;const i=()=>{n||(Ht('probe transport "%s" opened',r),t.send([{type:"ping",data:"probe"}]),t.once("packet",h=>{if(!n)if(h.type==="pong"&&h.data==="probe"){if(Ht('probe transport "%s" pong',r),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Li.priorWebsocketSuccess=t.name==="websocket",Ht('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||this.readyState!=="closed"&&(Ht("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{Ht('probe transport "%s" failed',r);const v=new Error("probe error");v.transport=t.name,this.emitReserved("upgradeError",v)}}))};function a(){n||(n=!0,l(),t.close(),t=null)}const s=h=>{const v=new Error("probe error: "+h);v.transport=t.name,a(),Ht('probe transport "%s" failed because of error: %s',r,h),this.emitReserved("upgradeError",v)};function o(){s("transport closed")}function u(){s("socket closed")}function c(h){t&&h.name!==t.name&&(Ht('"%s" works - aborting "%s"',h.name,t.name),a())}const l=()=>{t.removeListener("open",i),t.removeListener("error",s),t.removeListener("close",o),this.off("close",u),this.off("upgrading",c)};t.once("open",i),t.once("error",s),t.once("close",o),this.once("close",u),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&r!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(r){this._upgrades=this._filterUpgrades(r.upgrades),super.onHandshake(r)}_filterUpgrades(r){const t=[];for(let n=0;n<r.length;n++)~this.transports.indexOf(r[n])&&t.push(r[n]);return t}}Ni.SocketWithUpgrade=M1;let AX=class extends M1{constructor(r,t={}){const n=typeof r=="object"?r:t;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(i=>$X.transports[i]).filter(i=>!!i)),super(r,n)}};Ni.Socket=AX;var Tf={};Object.defineProperty(Tf,"__esModule",{value:!0});Tf.Fetch=void 0;const MX=Nu;class xX extends MX.Polling{doPoll(){this._fetch().then(r=>{if(!r.ok)return this.onError("fetch read error",r.status,r);r.text().then(t=>this.onData(t))}).catch(r=>{this.onError("fetch read error",r)})}doWrite(r,t){this._fetch(r).then(n=>{if(!n.ok)return this.onError("fetch write error",n.status,n);t()}).catch(n=>{this.onError("fetch write error",n)})}_fetch(r){var t;const n=r!==void 0,i=new Headers(this.opts.extraHeaders);return n&&i.set("content-type","text/plain;charset=UTF-8"),(t=this.socket._cookieJar)===null||t===void 0||t.appendCookies(i),fetch(this.uri(),{method:n?"POST":"GET",body:n?r:null,headers:i,credentials:this.opts.withCredentials?"include":"omit"}).then(a=>{var s;return(s=this.socket._cookieJar)===null||s===void 0||s.parseCookies(a.headers.getSetCookie()),a})}}Tf.Fetch=xX;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WebTransport=e.WebSocket=e.NodeWebSocket=e.XHR=e.NodeXHR=e.Fetch=e.nextTick=e.parse=e.installTimerFunctions=e.transports=e.TransportError=e.Transport=e.protocol=e.SocketWithUpgrade=e.SocketWithoutUpgrade=e.Socket=void 0;const r=Ni;Object.defineProperty(e,"Socket",{enumerable:!0,get:function(){return r.Socket}});var t=Ni;Object.defineProperty(e,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return t.SocketWithoutUpgrade}}),Object.defineProperty(e,"SocketWithUpgrade",{enumerable:!0,get:function(){return t.SocketWithUpgrade}}),e.protocol=r.Socket.protocol;var n=Ui;Object.defineProperty(e,"Transport",{enumerable:!0,get:function(){return n.Transport}}),Object.defineProperty(e,"TransportError",{enumerable:!0,get:function(){return n.TransportError}});var i=xu;Object.defineProperty(e,"transports",{enumerable:!0,get:function(){return i.transports}});var a=Jn;Object.defineProperty(e,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var s=Cf;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return s.parse}});var o=Xr;Object.defineProperty(e,"nextTick",{enumerable:!0,get:function(){return o.nextTick}});var u=Tf;Object.defineProperty(e,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var c=oi;Object.defineProperty(e,"NodeXHR",{enumerable:!0,get:function(){return c.XHR}});var l=oi;Object.defineProperty(e,"XHR",{enumerable:!0,get:function(){return l.XHR}});var h=wa;Object.defineProperty(e,"NodeWebSocket",{enumerable:!0,get:function(){return h.WS}});var v=wa;Object.defineProperty(e,"WebSocket",{enumerable:!0,get:function(){return v.WS}});var m=ju;Object.defineProperty(e,"WebTransport",{enumerable:!0,get:function(){return m.WT}})})(_f);var NX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lg,"__esModule",{value:!0});lg.url=jX;const LX=_f,DX=NX(Yn),zS=(0,DX.default)("socket.io-client:url");function jX(e,r="",t){let n=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(zS("protocol-less url %s",e),typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),zS("parse %s",e),n=(0,LX.parse)(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const a=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+a+":"+n.port+r,n.href=n.protocol+"://"+a+(t&&t.port===n.port?"":":"+n.port),n}var Ef={},Fu={},kf={},to={},es={};Object.defineProperty(es,"__esModule",{value:!0});es.hasBinary=es.isBinary=void 0;const FX=typeof ArrayBuffer=="function",UX=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,x1=Object.prototype.toString,BX=typeof Blob=="function"||typeof Blob<"u"&&x1.call(Blob)==="[object BlobConstructor]",qX=typeof File=="function"||typeof File<"u"&&x1.call(File)==="[object FileConstructor]";function N1(e){return FX&&(e instanceof ArrayBuffer||UX(e))||BX&&e instanceof Blob||qX&&e instanceof File}es.isBinary=N1;function rl(e,r){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(rl(e[t]))return!0;return!1}if(N1(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return rl(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&rl(e[t]))return!0;return!1}es.hasBinary=rl;Object.defineProperty(to,"__esModule",{value:!0});to.reconstructPacket=to.deconstructPacket=void 0;const zX=es;function WX(e){const r=[],t=e.data,n=e;return n.data=Jh(t,r),n.attachments=r.length,{packet:n,buffers:r}}to.deconstructPacket=WX;function Jh(e,r){if(!e)return e;if((0,zX.isBinary)(e)){const t={_placeholder:!0,num:r.length};return r.push(e),t}else if(Array.isArray(e)){const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=Jh(e[n],r);return t}else if(typeof e=="object"&&!(e instanceof Date)){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=Jh(e[n],r));return t}return e}function VX(e,r){return e.data=Yh(e.data,r),delete e.attachments,e}to.reconstructPacket=VX;function Yh(e,r){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<r.length)return r[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=Yh(e[t],r);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=Yh(e[t],r));return e}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Decoder=e.Encoder=e.PacketType=e.protocol=void 0;const r=ho,t=to,n=es,a=(0,Yn.default)("socket.io-parser"),s=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];e.protocol=5;var o;(function(v){v[v.CONNECT=0]="CONNECT",v[v.DISCONNECT=1]="DISCONNECT",v[v.EVENT=2]="EVENT",v[v.ACK=3]="ACK",v[v.CONNECT_ERROR=4]="CONNECT_ERROR",v[v.BINARY_EVENT=5]="BINARY_EVENT",v[v.BINARY_ACK=6]="BINARY_ACK"})(o=e.PacketType||(e.PacketType={}));class u{constructor(m){this.replacer=m}encode(m){return a("encoding packet %j",m),(m.type===o.EVENT||m.type===o.ACK)&&(0,n.hasBinary)(m)?this.encodeAsBinary({type:m.type===o.EVENT?o.BINARY_EVENT:o.BINARY_ACK,nsp:m.nsp,data:m.data,id:m.id}):[this.encodeAsString(m)]}encodeAsString(m){let _=""+m.type;return(m.type===o.BINARY_EVENT||m.type===o.BINARY_ACK)&&(_+=m.attachments+"-"),m.nsp&&m.nsp!=="/"&&(_+=m.nsp+","),m.id!=null&&(_+=m.id),m.data!=null&&(_+=JSON.stringify(m.data,this.replacer)),a("encoded %j as %s",m,_),_}encodeAsBinary(m){const _=(0,t.deconstructPacket)(m),C=this.encodeAsString(_.packet),I=_.buffers;return I.unshift(C),I}}e.Encoder=u;function c(v){return Object.prototype.toString.call(v)==="[object Object]"}class l extends r.Emitter{constructor(m){super(),this.reviver=m}add(m){let _;if(typeof m=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");_=this.decodeString(m);const C=_.type===o.BINARY_EVENT;C||_.type===o.BINARY_ACK?(_.type=C?o.EVENT:o.ACK,this.reconstructor=new h(_),_.attachments===0&&super.emitReserved("decoded",_)):super.emitReserved("decoded",_)}else if((0,n.isBinary)(m)||m.base64)if(this.reconstructor)_=this.reconstructor.takeBinaryData(m),_&&(this.reconstructor=null,super.emitReserved("decoded",_));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+m)}decodeString(m){let _=0;const C={type:Number(m.charAt(0))};if(o[C.type]===void 0)throw new Error("unknown packet type "+C.type);if(C.type===o.BINARY_EVENT||C.type===o.BINARY_ACK){const $=_+1;for(;m.charAt(++_)!=="-"&&_!=m.length;);const x=m.substring($,_);if(x!=Number(x)||m.charAt(_)!=="-")throw new Error("Illegal attachments");C.attachments=Number(x)}if(m.charAt(_+1)==="/"){const $=_+1;for(;++_&&!(m.charAt(_)===","||_===m.length););C.nsp=m.substring($,_)}else C.nsp="/";const I=m.charAt(_+1);if(I!==""&&Number(I)==I){const $=_+1;for(;++_;){const x=m.charAt(_);if(x==null||Number(x)!=x){--_;break}if(_===m.length)break}C.id=Number(m.substring($,_+1))}if(m.charAt(++_)){const $=this.tryParse(m.substr(_));if(l.isPayloadValid(C.type,$))C.data=$;else throw new Error("invalid payload")}return a("decoded %s as %j",m,C),C}tryParse(m){try{return JSON.parse(m,this.reviver)}catch{return!1}}static isPayloadValid(m,_){switch(m){case o.CONNECT:return c(_);case o.DISCONNECT:return _===void 0;case o.CONNECT_ERROR:return typeof _=="string"||c(_);case o.EVENT:case o.BINARY_EVENT:return Array.isArray(_)&&(typeof _[0]=="number"||typeof _[0]=="string"&&s.indexOf(_[0])===-1);case o.ACK:case o.BINARY_ACK:return Array.isArray(_)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}e.Decoder=l;class h{constructor(m){this.packet=m,this.buffers=[],this.reconPack=m}takeBinaryData(m){if(this.buffers.push(m),this.buffers.length===this.reconPack.attachments){const _=(0,t.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),_}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}})(kf);var Rf={};Object.defineProperty(Rf,"__esModule",{value:!0});Rf.on=GX;function GX(e,r,t){return e.on(r,t),function(){e.off(r,t)}}var HX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Fu,"__esModule",{value:!0});Fu.Socket=void 0;const jn=kf,Ic=Rf,KX=ho,JX=HX(Yn),br=(0,JX.default)("socket.io-client:socket"),YX=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class XX extends KX.Emitter{constructor(r,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=r,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const r=this.io;this.subs=[(0,Ic.on)(r,"open",this.onopen.bind(this)),(0,Ic.on)(r,"packet",this.onpacket.bind(this)),(0,Ic.on)(r,"error",this.onerror.bind(this)),(0,Ic.on)(r,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...r){return r.unshift("message"),this.emit.apply(this,r),this}emit(r,...t){var n,i,a;if(YX.hasOwnProperty(r))throw new Error('"'+r.toString()+'" is a reserved event name');if(t.unshift(r),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const s={type:jn.PacketType.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const l=this.ids++;br("emitting packet with ack id %d",l);const h=t.pop();this._registerAckCallback(l,h),s.id=l}const o=(i=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||i===void 0?void 0:i.writable,u=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!o?br("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s),this.flags={},this}_registerAckCallback(r,t){var n;const i=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(i===void 0){this.acks[r]=t;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[r];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===r&&(br("removing packet with ack id %d from the buffer",r),this.sendBuffer.splice(o,1));br("event with ack id %d has timed out after %d ms",r,i),t.call(this,new Error("operation has timed out"))},i),s=(...o)=>{this.io.clearTimeoutFn(a),t.apply(this,o)};s.withError=!0,this.acks[r]=s}emitWithAck(r,...t){return new Promise((n,i)=>{const a=(s,o)=>s?i(s):n(o);a.withError=!0,t.push(a),this.emit(r,...t)})}_addToQueue(r){let t;typeof r[r.length-1]=="function"&&(t=r.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:r,flags:Object.assign({fromQueue:!0},this.flags)};r.push((i,...a)=>n!==this._queue[0]?void 0:(i!==null?n.tryCount>this._opts.retries&&(br("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(i)):(br("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...a)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(r=!1){if(br("draining queue"),!this.connected||this._queue.length===0)return;const t=this._queue[0];if(t.pending&&!r){br("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,br("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(r){r.nsp=this.nsp,this.io._packet(r)}onopen(){br("transport is open - connecting"),typeof this.auth=="function"?this.auth(r=>{this._sendConnectPacket(r)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(r){this.packet({type:jn.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},r):r})}onerror(r){this.connected||this.emitReserved("connect_error",r)}onclose(r,t){br("close (%s)",r),this.connected=!1,delete this.id,this.emitReserved("disconnect",r,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(r=>{if(!this.sendBuffer.some(n=>String(n.id)===r)){const n=this.acks[r];delete this.acks[r],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(r){if(r.nsp===this.nsp)switch(r.type){case jn.PacketType.CONNECT:r.data&&r.data.sid?this.onconnect(r.data.sid,r.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case jn.PacketType.EVENT:case jn.PacketType.BINARY_EVENT:this.onevent(r);break;case jn.PacketType.ACK:case jn.PacketType.BINARY_ACK:this.onack(r);break;case jn.PacketType.DISCONNECT:this.ondisconnect();break;case jn.PacketType.CONNECT_ERROR:this.destroy();const n=new Error(r.data.message);n.data=r.data.data,this.emitReserved("connect_error",n);break}}onevent(r){const t=r.data||[];br("emitting event %j",t),r.id!=null&&(br("attaching ack callback to event"),t.push(this.ack(r.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(r){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,r)}super.emit.apply(this,r),this._pid&&r.length&&typeof r[r.length-1]=="string"&&(this._lastOffset=r[r.length-1])}ack(r){const t=this;let n=!1;return function(...i){n||(n=!0,br("sending ack %j",i),t.packet({type:jn.PacketType.ACK,id:r,data:i}))}}onack(r){const t=this.acks[r.id];if(typeof t!="function"){br("bad ack %s",r.id);return}delete this.acks[r.id],br("calling ack %s with %j",r.id,r.data),t.withError&&r.data.unshift(null),t.apply(this,r.data)}onconnect(r,t){br("socket connected with id %s",r),this.id=r,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(r=>this.emitEvent(r)),this.receiveBuffer=[],this.sendBuffer.forEach(r=>{this.notifyOutgoingListeners(r),this.packet(r)}),this.sendBuffer=[]}ondisconnect(){br("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(r=>r()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(br("performing disconnect (%s)",this.nsp),this.packet({type:jn.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(r){return this.flags.compress=r,this}get volatile(){return this.flags.volatile=!0,this}timeout(r){return this.flags.timeout=r,this}onAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(r),this}prependAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(r),this}offAny(r){if(!this._anyListeners)return this;if(r){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(r===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(r),this}prependAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(r),this}offAnyOutgoing(r){if(!this._anyOutgoingListeners)return this;if(r){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(r===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(r){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,r.data)}}}Fu.Socket=XX;var fg={};Object.defineProperty(fg,"__esModule",{value:!0});fg.Backoff=vo;function vo(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}vo.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var r=Math.random(),t=Math.floor(r*this.jitter*e);e=Math.floor(r*10)&1?e+t:e-t}return Math.min(e,this.max)|0};vo.prototype.reset=function(){this.attempts=0};vo.prototype.setMin=function(e){this.ms=e};vo.prototype.setMax=function(e){this.max=e};vo.prototype.setJitter=function(e){this.jitter=e};var QX=Ae&&Ae.__createBinding||(Object.create?function(e,r,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(r,t);(!i||("get"in i?!r.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,i)}:function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]}),ZX=Ae&&Ae.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),eQ=Ae&&Ae.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&QX(r,e,t);return ZX(r,e),r},tQ=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ef,"__esModule",{value:!0});Ef.Manager=void 0;const Ap=_f,rQ=Fu,nQ=eQ(kf),Va=Rf,iQ=fg,aQ=ho,sQ=tQ(Yn),Ir=(0,sQ.default)("socket.io-client:manager");class oQ extends aQ.Emitter{constructor(r,t){var n;super(),this.nsps={},this.subs=[],r&&typeof r=="object"&&(t=r,r=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,(0,Ap.installTimerFunctions)(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new iQ.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=r;const i=t.parser||nQ;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(r){return arguments.length?(this._reconnection=!!r,r||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(r){return r===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=r,this)}reconnectionDelay(r){var t;return r===void 0?this._reconnectionDelay:(this._reconnectionDelay=r,(t=this.backoff)===null||t===void 0||t.setMin(r),this)}randomizationFactor(r){var t;return r===void 0?this._randomizationFactor:(this._randomizationFactor=r,(t=this.backoff)===null||t===void 0||t.setJitter(r),this)}reconnectionDelayMax(r){var t;return r===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=r,(t=this.backoff)===null||t===void 0||t.setMax(r),this)}timeout(r){return arguments.length?(this._timeout=r,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(r){if(Ir("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Ir("opening %s",this.uri),this.engine=new Ap.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=(0,Va.on)(t,"open",function(){n.onopen(),r&&r()}),a=o=>{Ir("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",o),r?r(o):this.maybeReconnectOnOpen()},s=(0,Va.on)(t,"error",a);if(this._timeout!==!1){const o=this._timeout;Ir("connect attempt will timeout after %d",o);const u=this.setTimeoutFn(()=>{Ir("connect attempt timed out after %d",o),i(),a(new Error("timeout")),t.close()},o);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(i),this.subs.push(s),this}connect(r){return this.open(r)}onopen(){Ir("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const r=this.engine;this.subs.push((0,Va.on)(r,"ping",this.onping.bind(this)),(0,Va.on)(r,"data",this.ondata.bind(this)),(0,Va.on)(r,"error",this.onerror.bind(this)),(0,Va.on)(r,"close",this.onclose.bind(this)),(0,Va.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(r){try{this.decoder.add(r)}catch(t){this.onclose("parse error",t)}}ondecoded(r){(0,Ap.nextTick)(()=>{this.emitReserved("packet",r)},this.setTimeoutFn)}onerror(r){Ir("error",r),this.emitReserved("error",r)}socket(r,t){let n=this.nsps[r];return n?this._autoConnect&&!n.active&&n.connect():(n=new rQ.Socket(this,r,t),this.nsps[r]=n),n}_destroy(r){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active){Ir("socket %s is still active, skipping close",n);return}this._close()}_packet(r){Ir("writing packet %j",r);const t=this.encoder.encode(r);for(let n=0;n<t.length;n++)this.engine.write(t[n],r.options)}cleanup(){Ir("cleanup"),this.subs.forEach(r=>r()),this.subs.length=0,this.decoder.destroy()}_close(){Ir("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(r,t){var n;Ir("closed due to %s",r),this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",r,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const r=this;if(this.backoff.attempts>=this._reconnectionAttempts)Ir("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();Ir("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn(()=>{r.skipReconnect||(Ir("attempting reconnect"),this.emitReserved("reconnect_attempt",r.backoff.attempts),!r.skipReconnect&&r.open(i=>{i?(Ir("reconnect attempt error"),r._reconnecting=!1,r.reconnect(),this.emitReserved("reconnect_error",i)):(Ir("reconnect success"),r.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const r=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",r)}}Ef.Manager=oQ;(function(e,r){var t=Ae&&Ae.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(r,"__esModule",{value:!0}),r.WebTransport=r.WebSocket=r.NodeWebSocket=r.XHR=r.NodeXHR=r.Fetch=r.Socket=r.Manager=r.protocol=void 0,r.io=c,r.connect=c,r.default=c;const n=lg,i=Ef;Object.defineProperty(r,"Manager",{enumerable:!0,get:function(){return i.Manager}});const a=Fu;Object.defineProperty(r,"Socket",{enumerable:!0,get:function(){return a.Socket}});const o=(0,t(Yn).default)("socket.io-client"),u={};function c(v,m){typeof v=="object"&&(m=v,v=void 0),m=m||{};const _=(0,n.url)(v,m.path||"/socket.io"),C=_.source,I=_.id,$=_.path,x=u[I]&&$ in u[I].nsps,N=m.forceNew||m["force new connection"]||m.multiplex===!1||x;let q;return N?(o("ignoring socket cache for %s",C),q=new i.Manager(C,m)):(u[I]||(o("new io instance for %s",C),u[I]=new i.Manager(C,m)),q=u[I]),_.query&&!m.query&&(m.query=_.queryKey),q.socket(_.path,m)}Object.assign(c,{Manager:i.Manager,Socket:a.Socket,io:c,connect:c});var l=kf;Object.defineProperty(r,"protocol",{enumerable:!0,get:function(){return l.protocol}});var h=_f;Object.defineProperty(r,"Fetch",{enumerable:!0,get:function(){return h.Fetch}}),Object.defineProperty(r,"NodeXHR",{enumerable:!0,get:function(){return h.NodeXHR}}),Object.defineProperty(r,"XHR",{enumerable:!0,get:function(){return h.XHR}}),Object.defineProperty(r,"NodeWebSocket",{enumerable:!0,get:function(){return h.NodeWebSocket}}),Object.defineProperty(r,"WebSocket",{enumerable:!0,get:function(){return h.WebSocket}}),Object.defineProperty(r,"WebTransport",{enumerable:!0,get:function(){return h.WebTransport}}),e.exports=c})(Wh,Wh.exports);var L1=Wh.exports,D1={exports:{}};(function(e,r){(function(t){e.exports=t()})(function(){var t=function(f,d,p){for(var y=p,g=0,b=f.length;g<b;g++)y=d(y,f[g],g,f);return y},n=function(f,d){return t(f,function(p,y,g,b){return d(y,g,b)?p.concat(y):p},[])},i=function(f,d){return t(f,function(p,y,g,b){return p.concat(d(y,g,b))},[])},a=function(f,d){return t(f,function(p,y,g,b){return p===!0||y===d},!1)},s=!{toString:null}.propertyIsEnumerable("toString"),o=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],u=function(f){var d=[],p;for(p in f)Object.prototype.hasOwnProperty.call(f,p)&&d.push(p);if(!s)return d;for(var y=0,g=o.length;y<g;y++)Object.prototype.hasOwnProperty.call(f,o[y])&&d.push(o[y]);return d},c=function(f){return Object.prototype.toString.call(f)==="[object Array]"},l=function(f){return f<10?"0"+f:f},h=function(){var f=new Date;return f.getUTCFullYear()+"-"+l(f.getUTCMonth()+1)+"-"+l(f.getUTCDate())+"T"+l(f.getUTCHours())+":"+l(f.getUTCMinutes())+":"+l(f.getUTCSeconds())+"."+(f.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"},v={map:i,reduce:t,filter:n,includes:a,keys:u,isArray:c,isoDate:h},m={};m.intRange=function(f,d){return f===void 0&&(f=1),d===void 0&&(d=1/0),function(p){return typeof p=="number"&&parseInt(""+p,10)===p&&p>=f&&p<=d}},m.stringWithLength=function(f){return typeof f=="string"&&!!f.length};var _={},C=v.filter,I=v.reduce,$=v.keys,x=v.isArray,N=v.includes,q=m.intRange,X=m.stringWithLength;_.schema={apiKey:{defaultValue:function(){return null},message:"is required",validate:X},appVersion:{defaultValue:function(){return null},message:"should be a string",validate:function(f){return f===null||X(f)}},appType:{defaultValue:function(){return null},message:"should be a string",validate:function(f){return f===null||X(f)}},autoNotify:{defaultValue:function(){return!0},message:"should be true|false",validate:function(f){return f===!0||f===!1}},beforeSend:{defaultValue:function(){return[]},message:"should be a function or array of functions",validate:function(f){return typeof f=="function"||x(f)&&C(f,function(d){return typeof d=="function"}).length===f.length}},endpoints:{defaultValue:function(){return{notify:"https://notify.bugsnag.com",sessions:"https://sessions.bugsnag.com"}},message:"should be an object containing endpoint URLs { notify, sessions }. sessions is optional if autoCaptureSessions=false",validate:function(f,d){return f&&typeof f=="object"&&X(f.notify)&&(d.autoCaptureSessions===!1||X(f.sessions))&&C($(f),function(p){return!N(["notify","sessions"],p)}).length===0}},autoCaptureSessions:{defaultValue:function(f,d){return d.endpoints===void 0||!!d.endpoints&&!!d.endpoints.sessions},message:"should be true|false",validate:function(f){return f===!0||f===!1}},notifyReleaseStages:{defaultValue:function(){return null},message:"should be an array of strings",validate:function(f){return f===null||x(f)&&C(f,function(d){return typeof d=="string"}).length===f.length}},releaseStage:{defaultValue:function(){return"production"},message:"should be a string",validate:function(f){return typeof f=="string"&&f.length}},maxBreadcrumbs:{defaultValue:function(){return 20},message:"should be a number ≤40",validate:function(f){return q(0,40)(f)}},autoBreadcrumbs:{defaultValue:function(){return!0},message:"should be true|false",validate:function(f){return typeof f=="boolean"}},user:{defaultValue:function(){return null},message:"(object) user should be an object",validate:function(f){return typeof f=="object"}},metaData:{defaultValue:function(){return null},message:"should be an object",validate:function(f){return typeof f=="object"}},logger:{defaultValue:function(){},message:"should be null or an object with methods { debug, info, warn, error }",validate:function(f){return!f||f&&I(["debug","info","warn","error"],function(d,p){return d&&typeof f[p]=="function"},!0)}},filters:{defaultValue:function(){return["password"]},message:"should be an array of strings|regexes",validate:function(f){return x(f)&&f.length===C(f,function(d){return typeof d=="string"||d&&typeof d.test=="function"}).length}}},_.mergeDefaults=function(f,d){if(!f||!d)throw new Error("opts and schema objects are required");return I($(d),function(p,y){return p[y]=f[y]!==void 0?f[y]:d[y].defaultValue(f[y],f),p},{})},_.validate=function(f,d){if(!f||!d)throw new Error("opts and schema objects are required");var p=I($(d),function(y,g){return d[g].validate(f[g],f)?y:y.concat({key:g,message:d[g].message,value:f[g]})},[]);return{valid:!p.length,errors:p}};function J(){return J=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},J.apply(this,arguments)}var G=_.schema,L=v.map,te=m.stringWithLength,se={releaseStage:{defaultValue:function(){return/^localhost(:\d+)?$/.test(window.location.host)?"development":"production"},message:"should be set",validate:te},logger:J({},G.logger,{defaultValue:function(){return typeof console<"u"&&typeof console.debug=="function"?ne():void 0}})},ne=function(){var f={},d=console.log;return L(["debug","info","warn","error"],function(p){var y=console[p];f[p]=typeof y=="function"?y.bind(console,"[bugsnag]"):d.bind(console,"[bugsnag]")}),f},ge=v.isoDate,Y=function(){function f(p,y,g,b){p===void 0&&(p="[anonymous]"),y===void 0&&(y={}),g===void 0&&(g="manual"),b===void 0&&(b=ge()),this.type=g,this.name=p,this.metaData=y,this.timestamp=b}var d=f.prototype;return d.toJSON=function(){return{type:this.type,name:this.name,timestamp:this.timestamp,metaData:this.metaData}},f}(),Ue=Y,He=function(f,d,p){var y=f.length,g=0,b=function(){if(g>=y)return p(null,!1);d(f[g],function(w,S){if(w)return p(w,!1);if(S===!0)return p(null,!0);g++,b()})};b()},Rt=function(f){return f.app&&typeof f.app.releaseStage=="string"?f.app.releaseStage:f.config.releaseStage},ft=Pe;function Pe(f){switch(Object.prototype.toString.call(f)){case"[object Error]":return!0;case"[object Exception]":return!0;case"[object DOMException]":return!0;default:return f instanceof Error}}var he=ft,pe=function(f,d){return function(p,y){if(typeof p!="function")return y(null,!1);try{if(p.length!==2){var g=p(f);return g&&typeof g.then=="function"?g.then(function(b){return setTimeout(function(){return y(null,M(f,b))},0)},function(b){setTimeout(function(){return d(b),y(null,!1)})}):y(null,M(f,g))}p(f,function(b,w){if(b)return d(b),y(null,!1);y(null,M(f,w))})}catch(b){d(b),y(null,!1)}}},M=function(f,d){return f.isIgnored()||d===!1},Oe={};(function(f,d){typeof Oe=="object"?Oe=d():f.StackFrame=d()})(this,function(){function f(W){return!isNaN(parseFloat(W))&&isFinite(W)}function d(W){return W.charAt(0).toUpperCase()+W.substring(1)}function p(W){return function(){return this[W]}}var y=["isConstructor","isEval","isNative","isToplevel"],g=["columnNumber","lineNumber"],b=["fileName","functionName","source"],w=["args"],S=y.concat(g,b,w);function T(W){if(W instanceof Object)for(var Ie=0;Ie<S.length;Ie++)W.hasOwnProperty(S[Ie])&&W[S[Ie]]!==void 0&&this["set"+d(S[Ie])](W[S[Ie]])}T.prototype={getArgs:function(){return this.args},setArgs:function(W){if(Object.prototype.toString.call(W)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=W},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(W){if(W instanceof T)this.evalOrigin=W;else if(W instanceof Object)this.evalOrigin=new T(W);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var W=this.getFunctionName()||"{anonymous}",Ie="("+(this.getArgs()||[]).join(",")+")",ze=this.getFileName()?"@"+this.getFileName():"",je=f(this.getLineNumber())?":"+this.getLineNumber():"",qe=f(this.getColumnNumber())?":"+this.getColumnNumber():"";return W+Ie+ze+je+qe}};for(var F=0;F<y.length;F++)T.prototype["get"+d(y[F])]=p(y[F]),T.prototype["set"+d(y[F])]=function(W){return function(Ie){this[W]=!!Ie}}(y[F]);for(var j=0;j<g.length;j++)T.prototype["get"+d(g[j])]=p(g[j]),T.prototype["set"+d(g[j])]=function(W){return function(Ie){if(!f(Ie))throw new TypeError(W+" must be a Number");this[W]=Number(Ie)}}(g[j]);for(var V=0;V<b.length;V++)T.prototype["get"+d(b[V])]=p(b[V]),T.prototype["set"+d(b[V])]=function(W){return function(Ie){this[W]=String(Ie)}}(b[V]);return T});var Je={};(function(f,d){typeof Je=="object"?Je=d(Oe):f.ErrorStackParser=d(f.StackFrame)})(this,function(d){var p=/(^|@)\S+\:\d+/,y=/^\s*at .*(\S+\:\d+|\(native\))/m,g=/^(eval@)?(\[native code\])?$/;return{parse:function(w){if(typeof w.stacktrace<"u"||typeof w["opera#sourceloc"]<"u")return this.parseOpera(w);if(w.stack&&w.stack.match(y))return this.parseV8OrIE(w);if(w.stack)return this.parseFFOrSafari(w);throw new Error("Cannot parse given Error object")},extractLocation:function(w){if(w.indexOf(":")===-1)return[w];var S=/(.+?)(?:\:(\d+))?(?:\:(\d+))?$/,T=S.exec(w.replace(/[\(\)]/g,""));return[T[1],T[2]||void 0,T[3]||void 0]},parseV8OrIE:function(w){var S=w.stack.split(`
463
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=!0,g=!1,b;return{s:function(){f=f.call(O)},n:function(){var S=f.next();return y=S.done,S},e:function(S){g=!0,b=S},f:function(){try{!y&&f.return!=null&&f.return()}finally{if(g)throw b}}}}function Dt(O,P){if(O){if(typeof O=="string")return ht(O,P);var f=Object.prototype.toString.call(O).slice(8,-1);if(f==="Object"&&O.constructor&&(f=O.constructor.name),f==="Map"||f==="Set")return Array.from(O);if(f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f))return ht(O,P)}}function ht(O,P){(P==null||P>O.length)&&(P=O.length);for(var f=0,d=new Array(P);f<P;f++)d[f]=O[f];return d}var jt=he.default(function O(P){pe.default(this,O),Pe.default(this,"type","email"),this.messageSid=P.message_sid,this.level=P.level,this.name=P.name,this.address=P.address}),Xt=he.default(function O(P){pe.default(this,O),this.type=P.type,this.messageSid=P.message_sid,this.rawData=JSON.stringify(P)}),ir=function(){function O(P,f){pe.default(this,O),this._services=P,this._configuration=f,this._cache=new z({maxSize:f.messageRecipientsCacheCapacity})}return he.default(O,[{key:"getRecipientsFromMessage",value:function(){var P=Y.default(M.default.mark(function d(p,y){var g=this,b,w,S,T,F;return M.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(b="".concat(p,",").concat(y),w=this._cache.get(b),!w){V.next=4;break}return V.abrupt("return",w.item);case 4:return S=new It(this._configuration.links.conversations).path(p).path("MessageRecipients").arg("MessageSid",y).build(),V.next=7,this._services.commandExecutor.fetchResource(S);case 7:return T=V.sent,F=T.message_recipients.map(function(W){return g._wrapResponse(W)}),F.length>0&&this._cache.set(b,{item:F}),V.abrupt("return",F);case 11:case"end":return V.stop()}},d,this)}));function f(d,p){return P.apply(this,arguments)}return f}()},{key:"getRecipientsFromConversation",value:function(){var P=Y.default(M.default.mark(function d(p,y){var g,b,w=this,S,T,F,j,V,W,Ie,ze,je,qe;return M.default.wrap(function(mt){for(;;)switch(mt.prev=mt.next){case 0:return S=new It(this._configuration.links.conversations).path(p).path("MessageRecipients").arg("PageToken",(g=y==null?void 0:y.pageToken)!==null&&g!==void 0?g:void 0).arg("PageSize",(b=y==null?void 0:y.pageSize)!==null&&b!==void 0?b:void 0).build(),mt.next=3,this._services.commandExecutor.fetchResource(S);case 3:T=mt.sent,F=T.message_recipients.map(function(nt){return w._wrapResponse(nt)}),j=Ge(F);try{for(j.s();!(V=j.n()).done;)ze=V.value,je="".concat(p,",").concat(ze.messageSid),qe=(W=(Ie=this._cache.get(je))===null||Ie===void 0?void 0:Ie.item)!==null&&W!==void 0?W:[],this._cache.set(je,{item:[].concat(De.default(qe),[ze])})}catch(nt){j.e(nt)}finally{j.f()}return mt.abrupt("return",new Ve(F,function(nt,er){return w.getRecipientsFromConversation(p,{pageToken:nt,pageSize:er})},T.meta.previous_token,T.meta.next_token));case 8:case"end":return mt.stop()}},d,this)}));function f(d,p){return P.apply(this,arguments)}return f}()},{key:"_wrapResponse",value:function(f){switch(f.type){case"email":return new jt(f);default:return new Xt(f)}}}]),O}(),rt;function Sr(O,P){var f=Object.keys(O);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(O);P&&(d=d.filter(function(p){return Object.getOwnPropertyDescriptor(O,p).enumerable})),f.push.apply(f,d)}return f}function Cr(O){for(var P=1;P<arguments.length;P++){var f=arguments[P]!=null?arguments[P]:{};P%2?Sr(Object(f),!0).forEach(function(d){Pe.default(O,d,f[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(f)):Sr(Object(f)).forEach(function(d){Object.defineProperty(O,d,Object.getOwnPropertyDescriptor(f,d))})}return O}function Zt(O){var P=Tr();return function(){var d=ft.default(O),p;if(P){var y=ft.default(this).constructor;p=Reflect.construct(d,arguments,y)}else p=d.apply(this,arguments);return Rt.default(this,p)}}function Tr(){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 ct,yn=he.default(function O(){pe.default(this,O)});e.Client=ct=(rt=function(O){He.default(f,O);var P=Zt(f);function f(d){var p,y,g,b,w,S,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(pe.default(this,f),S=P.call(this),Pe.default(Ue.default(S),"version",E),Pe.default(Ue.default(S),"connectionState","unknown"),Pe.default(Ue.default(S),"parsePushNotification",ct.parsePushNotification),S._fpaToken=d??"",S._options=T??{},!S._options.disableDeepClone){var F=Cr(Cr({},S._options),{},{transport:void 0,twilsockClient:void 0});F=Pt(F),F.transport=S._options.transport,F.twilsockClient=S._options.twilsockClient,S._options=F}S._options.logLevel=(p=S._options.logLevel)!==null&&p!==void 0?p:"silent",ct._logger.setLevel(S._options.logLevel);var j=S._options.productId="ip_messaging";if(S._options.clientMetadata=S._options.clientMetadata||{},S._options.clientMetadata.hasOwnProperty("type")||(S._options.clientMetadata.type="conversations"),S._options.clientMetadata.hasOwnProperty("sdk")||(S._options.clientMetadata.sdk="JS",S._options.clientMetadata.sdkv=E),S._options.Sync=S._options.Sync||{},typeof S._options.Sync.enableSessionStorage>"u"&&(S._options.Sync.enableSessionStorage=!0),S._options.region&&(S._options.Sync.region=S._options.region),!d)throw new Error("A valid Twilio token should be provided");S._services=new yn,S._myself=new ve("","",null,S._services);var V=!S._options.twilsockClient;if(!S._options.initRegistrations){var W=new q.InitRegistration(j);ct.populateInitRegistrations(W),S._options.initRegistrations=[W]}S._services.twilsockClient=S._options.twilsockClient=(y=S._options.twilsockClient)!==null&&y!==void 0?y:new q.TwilsockClient(d,j,S._options),S._services.twilsockClient.on(ct.tokenAboutToExpire,function(){return S.emit(ct.tokenAboutToExpire)}),S._services.twilsockClient.on(ct.tokenExpired,function(){return S.emit(ct.tokenExpired)}),S._services.twilsockClient.on(ct.connectionError,function(mt){return S.emit(ct.connectionError,mt)}),S._services.twilsockClient.on("stateChanged",function(mt){ct._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(mt)),mt!==S.connectionState&&(S.connectionState=mt,S.emit(ct.connectionStateChanged,S.connectionState))}),S._services.transport=S._options.transport=(g=S._options.transport)!==null&&g!==void 0?g:S._options.twilsockClient,S._services.notificationClient=S._options.notificationsClient=(b=S._options.notificationsClient)!==null&&b!==void 0?b:new X.Notifications(d,S._options),S._services.syncClient=S._options.syncClient=(w=S._options.syncClient)!==null&&w!==void 0?w:new J.SyncClient(d,S._options);var Ie=(T==null?void 0:T.Chat)||(T==null?void 0:T.IPMessaging)||T||{},ze=Ie.region||(T==null?void 0:T.region),je=Ie.apiUri||Ie.typingUri||"https://aim.".concat(ze||"us1",".twilio.com");S._services.commandExecutor=new hr(je,{transport:S._options.transport},j),S._services.contentClient=new Kr(S._services);var qe=function(nt){S._rejectEnsureReady(nt),S.emit(ct.stateChanged,"failed"),S.emit(ct.initFailed,{error:nt})},Tt=function(){qe({terminal:!0,message:"Twilsock has disconnected."}),S._initializeEnsureReady((T==null?void 0:T.throwErrorsAlways)||!1)};return S._services.twilsockClient.once("connectionError",qe),S._services.twilsockClient.once("disconnected",Tt),S._services.twilsockClient.once("connected",Y.default(M.default.mark(function mt(){var nt,er;return M.default.wrap(function(tt){for(;;)switch(tt.prev=tt.next){case 0:return ct._logger.debug("ConversationsClient started INITIALIZING"),S._services.twilsockClient.off("connectionError",qe),S._services.twilsockClient.off("disconnected",Tt),tt.prev=3,nt="conversations.client.startup",S._services.twilsockClient.addPartialTelemetryEvent(new q.TelemetryEventDescription(nt,"Conversations client startup",new Date),nt,q.TelemetryPoint.Start),tt.next=8,S._initialize();case 8:S._services.twilsockClient.addPartialTelemetryEvent(new q.TelemetryEventDescription("","",new Date),nt,q.TelemetryPoint.End),tt.next=17;break;case 11:tt.prev=11,tt.t0=tt.catch(3),er={terminal:!0,message:tt.t0.message},S._rejectEnsureReady(er),S.emit(ct.stateChanged,"failed"),S.emit(ct.initFailed,{error:er});case 17:case"end":return tt.stop()}},mt,null,[[3,11]])}))),S._initializeEnsureReady((T==null?void 0:T.throwErrorsAlways)||!1),V&&S._services.twilsockClient.connect(),S}return he.default(f,[{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 d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"updateToken",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:if(ct._logger.info("updateToken"),this._fpaToken!==g){w.next=5;break}return w.abrupt("return",this);case 5:return w.next=7,this._services.twilsockClient.updateToken(g);case 7:return w.next=9,this._services.notificationClient.updateToken(g);case 9:return w.next=11,this._services.mcsClient.updateToken(g);case 11:return this._fpaToken=g,w.abrupt("return",this);case 13:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getConversationBySid",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return S.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return S.next=6,this._conversationsEntity.getConversation(g);case 6:if(b=S.sent,b){S.next=12;break}return S.next=10,this.peekConversationBySid(g);case 10:b=S.sent,b&&L.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(b){S.next=14;break}throw new Error("Conversation with SID ".concat(g," was not found."));case 14:return S.abrupt("return",b);case 15:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"peekConversationBySid",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return S.next=4,this._conversationsEntity.peekConversation(g);case 4:if(b=S.sent,b){S.next=7;break}throw new Error("Conversation with SID ".concat(g," was not found."));case 7:return S.abrupt("return",b);case 8:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getConversationByUniqueName",value:function(){var d=Y.default(M.default.mark(function y(g){var b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return S.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return S.next=6,this._conversationsEntity.getConversationByUniqueName(g);case 6:if(b=S.sent,b){S.next=9;break}throw new Error("Conversation with unique name ".concat(g," was not found."));case 9:return S.abrupt("return",b);case 10:case"end":return S.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getSubscribedConversations",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.abrupt("return",this._conversationsPromise.then(function(w){return w.getConversations()}));case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"createConversation",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:return g=g||{},w.abrupt("return",this._conversationsPromise.then(function(S){return S.addConversation(g)}));case 4:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"setPushRegistrationId",value:function(){var d=Y.default(M.default.mark(function y(g,b){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(g),this._services.notificationClient.setPushRegistrationId(g,b),S.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return S.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"unsetPushRegistrationId",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(g),w.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"removePushRegistrations",value:function(){var d=Y.default(M.default.mark(function y(g,b){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._services.notificationClient.removeRegistrations(g,b);case 2:case"end":return S.stop()}},y,this)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"handlePushNotification",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:ct._logger.debug("handlePushNotification, notificationPayload=",g),this.emit("pushNotification",ct.parsePushNotification(g));case 4:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getUser",value:function(){var d=Y.default(M.default.mark(function y(g){return M.default.wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._ensureReady;case 2:return w.abrupt("return",this._services.users.getUser(g));case 3:case"end":return w.stop()}},y,this)}));function p(y){return d.apply(this,arguments)}return p}()},{key:"getSubscribedUsers",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(p){var y=this;return new G.CancellablePromise(function(){var g=Y.default(M.default.mark(function b(w,S,T){var F,j;return M.default.wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(!(!y._services.mcsClient||!p)){W.next=3;break}return S(new Error("Media Content Service is unavailable")),W.abrupt("return");case 3:return F=y._services.mcsClient.mediaSetGetContentUrls(p),T(function(){F.cancel()}),W.prev=5,W.next=8,F;case 8:j=W.sent,w(j),W.next=15;break;case 12:W.prev=12,W.t0=W.catch(5),S(W.t0);case 15:case"end":return W.stop()}},b,null,[[5,12]])}));return function(b,w,S){return g.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(p){var y=p.map(function(g){return g.sid});return this.getTemporaryContentUrlsForMediaSids(y)}},{key:"getContentTemplates",value:function(){var d=Y.default(M.default.mark(function y(){return M.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this._ensureReady;case 2:return b.next=4,this._services.contentClient.getContentTemplates();case 4:return b.abrupt("return",b.sent);case 5:case"end":return b.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_initialize",value:function(){var d=Y.default(M.default.mark(function y(){var g=this,b;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return b=S.sent,this._configuration=new Ct(this._options,b,ct._logger),this._services.channelMetadataClient=new be(this._services,this._configuration),this._services.messageRecipientsClient=new ir(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new R(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new oe(this._configuration,this._services),this._services.users=new D(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function(T){g.emit("userSubscribed",T)}),this._services.users.on("userUpdated",function(T){return g.emit("userUpdated",T)}),this._services.users.on("userUnsubscribed",function(T){g.emit("userUnsubscribed",T)}),this._conversationsEntity=new Ir(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function(T){g.emit("conversationAdded",T)}),this._conversationsEntity.on("conversationRemoved",function(T){g.emit("conversationRemoved",T)}),this._conversationsEntity.on("conversationJoined",function(T){g.emit("conversationJoined",T)}),this._conversationsEntity.on("conversationLeft",function(T){g.emit("conversationLeft",T)}),this._conversationsEntity.on("conversationUpdated",function(T){return g.emit("conversationUpdated",T)}),this._conversationsEntity.on("participantJoined",function(T){g.emit("participantJoined",T)}),this._conversationsEntity.on("participantLeft",function(T){g.emit("participantLeft",T)}),this._conversationsEntity.on("participantUpdated",function(T){return g.emit("participantUpdated",T)}),this._conversationsEntity.on("messageAdded",function(T){return g.emit("messageAdded",T)}),this._conversationsEntity.on("messageUpdated",function(T){return g.emit("messageUpdated",T)}),this._conversationsEntity.on("messageRemoved",function(T){return g.emit("messageRemoved",T)}),this._conversationsEntity.on("typingStarted",function(T){return g.emit("typingStarted",T)}),this._conversationsEntity.on("typingEnded",function(T){return g.emit("typingEnded",T)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return g._conversationsEntity}).catch(function(T){throw T}),S.next=30,this._services.users.myself._ensureFetched();case 30:ct._supportedPushChannels.forEach(function(T){return g._subscribeToPushNotifications(T)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new G.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,Cr(Cr({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(ct.stateChanged,"initialized"),this.emit(ct.initialized);case 36:case"end":return S.stop()}},y,this)}));function p(){return d.apply(this,arguments)}return p}()},{key:"_subscribeToPushNotifications",value:function(p){var y=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(g){y._services.notificationClient.subscribe(p,g)})}},{key:"_unsubscribeFromPushNotifications",value:function(p){var y=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(g){y._services.notificationClient.unsubscribe(p,g)})}},{key:"_initializeEnsureReady",value:function(p){var y=this;this._ensureReady=new Promise(function(g,b){y._resolveEnsureReady=g,y._rejectEnsureReady=b}).catch(function(g){if(p)throw g})}}],[{key:"create",value:function(){var d=Y.default(M.default.mark(function y(g,b){var w;return M.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(!(b!=null&&b.twilsockClient)){T.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 w=new ct(g,b),T.next=5,w._ensureReady;case 5:return T.abrupt("return",w);case 6:case"end":return T.stop()}},y)}));function p(y,g){return d.apply(this,arguments)}return p}()},{key:"parsePushNotification",value:function(p){if(ct._logger.debug("parsePushNotification, notificationPayload=",p),typeof p.aps<"u"){if(!p.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var y=ct._parsePushNotificationChatData(p),g=p.aps,b,w=null;if(typeof g.alert=="string")b=g.alert||null;else{var S,T;b=((S=g.alert)===null||S===void 0?void 0:S.body)||null,w=((T=g.alert)===null||T===void 0?void 0:T.title)||null}return new k({title:w,body:b,sound:g.sound||null,badge:g.badge||null,action:g.category||null,type:p.twi_message_type,data:y})}if(typeof p.data<"u"){var F=p.data;if(!F.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var j=ct._parsePushNotificationChatData(p.data);return new k({title:F.twi_title||null,body:F.twi_body||null,sound:F.twi_sound||null,badge:null,action:F.twi_action||null,type:F.twi_message_type,data:j})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(p){var y={};for(var g in ct._supportedPushDataFields){var b=p[g];if(!(typeof b>"u"||b===null)){if(g==="message_index"||g==="media_count"){var w=yt(b);w!==null&&(y[ct._supportedPushDataFields[g]]=w);continue}if(g==="media"){if(typeof b=="string")try{y[ct._supportedPushDataFields[g]]=JSON.parse(b)}catch{ct._logger.debug("Media message notification parsing error")}continue}y[ct._supportedPushDataFields[g]]=b}}return y}},{key:"populateInitRegistrations",value:function(p){p.populateInitRegistrations([me.TYPING_INDICATOR]),J.SyncClient.populateInitRegistrations(p)}}]),f}(I.ReplayEventEmitter),Pe.default(rt,"conversationAdded","conversationAdded"),Pe.default(rt,"conversationJoined","conversationJoined"),Pe.default(rt,"conversationLeft","conversationLeft"),Pe.default(rt,"conversationRemoved","conversationRemoved"),Pe.default(rt,"conversationUpdated","conversationUpdated"),Pe.default(rt,"participantJoined","participantJoined"),Pe.default(rt,"participantLeft","participantLeft"),Pe.default(rt,"participantUpdated","participantUpdated"),Pe.default(rt,"messageAdded","messageAdded"),Pe.default(rt,"messageRemoved","messageRemoved"),Pe.default(rt,"messageUpdated","messageUpdated"),Pe.default(rt,"tokenAboutToExpire","tokenAboutToExpire"),Pe.default(rt,"tokenExpired","tokenExpired"),Pe.default(rt,"typingEnded","typingEnded"),Pe.default(rt,"typingStarted","typingStarted"),Pe.default(rt,"pushNotification","pushNotification"),Pe.default(rt,"userSubscribed","userSubscribed"),Pe.default(rt,"userUnsubscribed","userUnsubscribed"),Pe.default(rt,"userUpdated","userUpdated"),Pe.default(rt,"stateChanged","stateChanged"),Pe.default(rt,"initialized","initialized"),Pe.default(rt,"initFailed","initFailed"),Pe.default(rt,"connectionStateChanged","connectionStateChanged"),Pe.default(rt,"connectionError","connectionError"),Pe.default(rt,"version",E),Pe.default(rt,"_logger",Gt.scope("Client")),Pe.default(rt,"_supportedPushChannels",["fcm","apn"]),Pe.default(rt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),rt),_e([L.deprecated("token"),le("design:type",String),le("design:paramtypes",[])],e.Client.prototype,"token",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"updateToken",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),_e([_.validateTypesAsync(["undefined",_.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],e.Client.prototype,"createConversation",null),_e([_.validateTypesAsync(_.literal("fcm","apn"),"string"),le("design:type",Function),le("design:paramtypes",[String,String]),le("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),_e([_.validateTypesAsync(_.literal("fcm","apn")),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),_e([_.validateTypesAsync(_.literal("fcm","apn"),_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String,String]),le("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),_e([_.validateTypesAsync(_.pureObject),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),_e([_.validateTypesAsync(_.nonEmptyString),le("design:type",Function),le("design:paramtypes",[String]),le("design:returntype",Promise)],e.Client.prototype,"getUser",null),_e([_.validateTypesAsync(_.nonEmptyArray("strings","string")),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",G.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),_e([_.validateTypesAsync(_.nonEmptyArray("media",We)),le("design:type",Function),le("design:paramtypes",[Array]),le("design:returntype",G.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),_e([L.deprecated("Client.create()","new Client()"),_.validateTypesAsync("string",["undefined",_.pureObject]),le("design:type",Function),le("design:paramtypes",[String,Object]),le("design:returntype",Promise)],e.Client,"create",null),_e([_.validateTypes(_.pureObject),le("design:type",Function),le("design:paramtypes",[Object]),le("design:returntype",k)],e.Client,"parsePushNotification",null),e.Client=ct=_e([_.validateConstructorTypes(_.nonEmptyString,[_.pureObject,"undefined"]),le("design:paramtypes",[String,Object])],e.Client),Object.defineProperty(e,"CancellablePromise",{enumerable:!0,get:function(){return G.CancellablePromise}}),e.AggregatedDeliveryReceipt=Be,e.ChannelMetadata=re,e.ContentTemplate=at,e.ContentTemplateVariable=Ze,e.Conversation=wt,e.DetailedDeliveryReceipt=Ye,e.EmailRecipientDescriptor=jt,e.Media=We,e.Message=ur,e.MessageBuilder=Yt,e.NotificationTypes=me,e.Participant=H,e.PushNotification=k,e.RestPaginator=Ve,e.UnknownRecipientDescriptor=Xt,e.UnsentMessage=Qn,e.User=ve})(A0);const Cn=new Sa("twilio-chat");class y1 extends _v{constructor(){super(...arguments);ut(this,"client");ut(this,"conversation")}async create(){const{token:t,identity:n}=await this.issueChatToken();this.identity=n,Cn.info(`Connecting chat, identity: ${n}, token: ${t}`);const i=new A0.Client(t);i.on("initialized",()=>{Cn.info("client: initialized"),this.events.triggerEvent("initialized")}),i.on("tokenAboutToExpire",()=>{Cn.info("client: tokenAboutToExpire"),this.refreshToken()}),i.on("tokenExpired",()=>{Cn.info("client: tokenExpired"),this.refreshToken()}),this.client=i}async refreshToken(){const{token:t}=await this.issueChatToken();await this.client.updateToken(t)}async join(t){const n=await this.client.getConversationBySid(t);n.status==="joined"?Cn.info("already joined conversation:",t):(await n.join(),Cn.info("success joined conversation:",t)),this.registerEvents(n),this.conversation=n}async preview(t){await(await this.conversation.getParticipantByIdentity(this.identity)).updateAttributes({chat_preview:t,chat_preview_updated_at:new Date().toJSON()})}async destroy(){this.client&&(await this.client.shutdown(),this.client=null,this.conversation=null)}async fetchMessages(t){return(await this.conversation.getMessages()).items.map(i=>{const a=MS(i);return t[a.$index]&&(a.file=t[a.$index]),this.trackInTask(a),a})}async sendMessage(t){try{const n=await this.conversation.sendMessage(JSON.stringify(t));return Cn.info(`Message sent from ${this.conversation.sid}, index: ${n}`),n}catch(n){Cn.warn(`Failed to send a message from ${this.conversation.sid}`,{error:n})}}startTyping(){this.conversation&&this.conversation.typing()}stopTyping(){}registerEvents(t){t.on("messageAdded",n=>{const i=MS(n);Cn.info(`Message added from ${this.conversation.sid}, index: ${i.$index}, sid: ${i.$sid}, timestamp: ${i.$timestamp}, user type: ${i.$userType}`),i.$userType!=="end_user"&&this.ping(),this.trackInTask(i),this.events.triggerEvent("message",i)}),t.on("participantJoined",n=>{Cn.info("conversation: memberJoined",n),this.events.triggerEvent("memberJoined",n.identity)}),t.on("participantLeft",n=>{Cn.info("conversation: memberLeft",n),this.events.triggerEvent("memberLeft",n.identity)}),t.on("typingStarted",n=>{this.events.triggerEvent("typingStarted",n.identity)}),t.on("typingEnded",n=>{this.events.triggerEvent("typingEnded",n.identity)})}}ut(y1,"type","twilio_conversations");wv(y1);function MS(e){const{index:r,sid:t,author:n,dateCreated:i,body:a}=e,[s,o]=n.split("-");let u=0;o&&(u=parseInt(o,10));const c={$index:r,$sid:t,$timestamp:i,$userType:s,$userId:u};try{const l=JSON.parse(a);return l.message&&!l.type?{...c,...l,type:"message"}:{...c,...l}}catch(l){return Cn.warn("Format message failed",{error:l,data:a}),{...c,type:"text",content:a}}}var qh={exports:{}},Pa=Pl;function Pl(){}Pl.mixin=function(e){var r=e.prototype||e;r.isWildEmitter=!0,r.on=function(t,n,i){this.callbacks=this.callbacks||{};var a=arguments.length===3,s=a?arguments[1]:void 0,o=a?arguments[2]:arguments[1];return o._groupName=s,(this.callbacks[t]=this.callbacks[t]||[]).push(o),this},r.once=function(t,n,i){var a=this,s=arguments.length===3,o=s?arguments[1]:void 0,u=s?arguments[2]:arguments[1];function c(){a.off(t,c),u.apply(this,arguments)}return this.on(t,o,c),this},r.releaseGroup=function(t){this.callbacks=this.callbacks||{};var n,i,a,s;for(n in this.callbacks)for(s=this.callbacks[n],i=0,a=s.length;i<a;i++)s[i]._groupName===t&&(s.splice(i,1),i--,a--);return this},r.off=function(t,n){this.callbacks=this.callbacks||{};var i=this.callbacks[t],a;return i?arguments.length===1?(delete this.callbacks[t],this):(a=i.indexOf(n),a!==-1&&(i.splice(a,1),i.length===0&&delete this.callbacks[t]),this):this},r.emit=function(t){this.callbacks=this.callbacks||{};var n=[].slice.call(arguments,1),i=this.callbacks[t],a=this.getWildcardCallbacks(t),s,o,u;if(i)for(u=i.slice(),s=0,o=u.length;s<o&&u[s];++s)u[s].apply(this,n);if(a)for(o=a.length,u=a.slice(),s=0,o=u.length;s<o&&u[s];++s)u[s].apply(this,[t].concat(n));return this},r.getWildcardCallbacks=function(t){this.callbacks=this.callbacks||{};var n,i,a=[];for(n in this.callbacks)i=n.split("*"),(n==="*"||i.length===2&&t.slice(0,i[0].length)===i[0])&&(a=a.concat(this.callbacks[n]));return a}};Pl.mixin(Pl);var b1={exports:{}};(function(e){(function(r,t){e.exports?e.exports=t():r.prefix=t(r)})(Ae,function(r){var t=function(l){for(var h=1,v=arguments.length,m;h<v;h++)for(m in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],m)&&(l[m]=arguments[h][m]);return l},n={template:"[%t] %l:",levelFormatter:function(l){return l.toUpperCase()},nameFormatter:function(l){return l||"root"},timestampFormatter:function(l){return l.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},i,a={},s=function(l){if(!l||!l.getLogger)throw new TypeError("Argument is not a root logger");i=l},o=function(l,h){if(!l||!l.setLevel)throw new TypeError("Argument is not a logger");var v=l.methodFactory,m=l.name||"",_=a[m]||a[""]||n;function C(I,$,x){var N=v(I,$,x),q=a[x]||a[""],X=q.template.indexOf("%t")!==-1,J=q.template.indexOf("%l")!==-1,G=q.template.indexOf("%n")!==-1;return function(){for(var L="",te=arguments.length,se=Array(te),ne=0;ne<te;ne++)se[ne]=arguments[ne];if(m||!a[x]){var ge=q.timestampFormatter(new Date),Y=q.levelFormatter(I),Ue=q.nameFormatter(x);q.format?L+=q.format(Y,Ue,ge):(L+=q.template,X&&(L=L.replace(/%t/,ge)),J&&(L=L.replace(/%l/,Y)),G&&(L=L.replace(/%n/,Ue))),se.length&&typeof se[0]=="string"?se[0]=L+" "+se[0]:se.unshift(L)}N.apply(void 0,se)}}return a[m]||(l.methodFactory=C),h=h||{},h.template&&(h.format=void 0),a[m]=t({},_,h),l.setLevel(l.getLevel()),i||l.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),l},u={reg:s,apply:o},c;return r&&(c=r.prefix,u.noConflict=function(){return r.prefix===u&&(r.prefix=c),u}),u})})(b1);var mY=b1.exports,zh={exports:{}},gY={"error:application:call:params":{type:"error:application:call:params",description:"not a valid String[] of usernames param"},"error:application:callServer:params":{type:"error:application:call:params",description:"not a valid String of phone number"},"error:call:reject":{type:"error:call:reject",description:"failed to reject the call"},"error:getUserMedia:permissions":{type:"error:getUserMedia:permissions",description:"missing getUserMedia permissions"},"error:media:params":{type:"error:media:params",description:"currently supported params media type= {audio:{muted:false, earmuffed:false}}"},"error:media:reenable":{type:"error:media:reenable",description:"missing reconnectRtcId required to reenable media"},"error:self":{type:"error:self",description:"Conversation Object is missing self (me)"},"error:user:relogin":{type:"error:user:relogin",description:"please relogin"},"error:seen:own-message":{type:"error:seen:own-message",description:"attempt to send seen for own message"},"error:already-seen":{type:"error:already-seen",description:"already marked as seen"},"error:delivered:own-message":{type:"error:delivered:own-message",description:"attempt to send delivered for own message"},"error:already-delivered":{type:"error:already-delivered",description:"already marked as delivered"},"error:fetch-image":{type:"error:fetch-image",description:"xhr.status received other than 200"},"error:delete-image":{type:"error:delete-image",description:"xhr.status received other than 204"},"error:missing:params":{type:"error:missing:params",description:"missing parameters"},"error:invite:missing:params":{type:"error:missing:params",description:"This invite cannot be sent to empty username and user_id"},"error:invalid:param:type":{type:"error:invalid:param:type",description:"Invalid Object type, passed in the parameters"},"error:audio:already-connecting":{type:"error:audio:already-connecting",description:"Audio call already in progress"},"error:audio:not-enabled":{type:"error:audio:not-enabled",description:"Audio is not enabled"},"error:media:already-connecting":{type:"error:media:already-connecting",description:"Media is already in progress"},"error:media:unsupported-browser":{type:"error:media:unsupported-browser",description:"This action is not supported on this browser"},"error:media:extension":{type:"error:media:extension",description:"Chrome extension has thrown an error"},"error:media:extension-not-installed":{type:"error:media:extension-not-installed",description:"Chrome extension should be installed"},"error:media:update:streams":{type:"error:media:update:streams",description:"cant update more than one stream"},"error:media:update:invalid":{type:"error:media:update:invalid",description:"state of media is not supported for this update"},"error:media:stream:not-found":{type:"error:media:stream:not-found",description:"A stream with the given index was not found"},"error:audio:dtmf:invalid-digit":{type:"error:audio:dtmf:invalid-digit",description:"not a valid string of dtmf digits (0-9,a-d,A-D,p,P,*,#)"},"error:audio:dtmf:audio-disabled":{type:"error:audio:dtmf:audio-disabled",description:"Audio must be enabled to send DTMF"},"error:invalid-order":{type:"error:invalid-order",description:"params not valid. Order must be asc or desc"},"error:custom-event:invalid":{type:"error:custom-event:invalid",description:"Custom event type not valid"},"error:message-event:invalid":{type:"error:message-event:invalid",description:"message_type is missing or is invalid"},"error:invalid-cursor":{type:"error:invalid-cursor",description:"page does not exist"},"error:client:reconnection_failed":{type:"error:client:reconnection_failed",description:"websocket failed to reconnect"},"error:conversation-service:version":{type:"error:conversation:version",description:'Wrong version of Conversation Service API. It should be one of "v1" or "v3"'},"error:no-media-offer":{type:"error:no-media-offer",description:"Media preload attempt without having an offer available"},"error:input:unsanitized":{type:"error:input:unsanitized",description:"Input is not sanitized"}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.NexmoApiError=r.NexmoClientError=void 0;const t=gY,n=gr;function i(o,u){var c,l;u!=null&&u.code&&(u.type=u.code,delete u.code),Object.assign(o,u),o.message="type: "+o.type+", description: "+((l=(c=o.description)!==null&&c!==void 0?c:o.detail)!==null&&l!==void 0?l:"")}class a{constructor(u){const c=t[u];c?i(this,c):(this.message=u&&u.message?u.message:u,this.stack=u.stack),this.log=n.getLogger(this.constructor.name),this.log.error(this),this.name="NexmoClientError",typeof Ae.NXMbugsnagClient<"u"&&Ae.NXMbugsnagClient.notify(this,{severity:"info"})}}r.NexmoClientError=a;class s{constructor(u){this.log=n.getLogger(this.constructor.name),u?i(this,u):(this.message=u&&u.message?u.message:u,this.stack=u&&u.stack?u.stack:new Error().stack),this.name="NexmoApiError",this.log=n.getLogger(this.constructor.name),this.log.error(this),typeof Ae.NXMbugsnagClient<"u"&&Ae.NXMbugsnagClient.notify(this,{severity:"info"})}}r.NexmoApiError=s,e.exports={NexmoClientError:a,NexmoApiError:s}})(zh,zh.exports);var Mn=zh.exports,Wh={exports:{}},lg={},_f={},Ni={},xu={},oi={},Nu={},Ui={},po={},Lu={},ui={};Object.defineProperty(ui,"__esModule",{value:!0});ui.ERROR_PACKET=ui.PACKET_TYPES_REVERSE=ui.PACKET_TYPES=void 0;const ci=Object.create(null);ui.PACKET_TYPES=ci;ci.open="0";ci.close="1";ci.ping="2";ci.pong="3";ci.message="4";ci.upgrade="5";ci.noop="6";const _1=Object.create(null);ui.PACKET_TYPES_REVERSE=_1;Object.keys(ci).forEach(e=>{_1[ci[e]]=e});const yY={type:"error",data:"parser error"};ui.ERROR_PACKET=yY;Object.defineProperty(Lu,"__esModule",{value:!0});Lu.encodePacket=void 0;Lu.encodePacketToBinary=_Y;const bY=ui,w1=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",S1=typeof ArrayBuffer=="function",C1=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,T1=({type:e,data:r},t,n)=>w1&&r instanceof Blob?t?n(r):xS(r,n):S1&&(r instanceof ArrayBuffer||C1(r))?t?n(r):xS(new Blob([r]),n):n(bY.PACKET_TYPES[e]+(r||""));Lu.encodePacket=T1;const xS=(e,r)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];r("b"+(n||""))},t.readAsDataURL(e)};function NS(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let $p;function _Y(e,r){if(w1&&e.data instanceof Blob)return e.data.arrayBuffer().then(NS).then(r);if(S1&&(e.data instanceof ArrayBuffer||C1(e.data)))return r(NS(e.data));T1(e,!1,t=>{$p||($p=new TextEncoder),r($p.encode(t))})}var wf={},eo={};Object.defineProperty(eo,"__esModule",{value:!0});eo.decode=eo.encode=void 0;const Ms="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Ms.length;e++)Fo[Ms.charCodeAt(e)]=e;const wY=e=>{let r=new Uint8Array(e),t,n=r.length,i="";for(t=0;t<n;t+=3)i+=Ms[r[t]>>2],i+=Ms[(r[t]&3)<<4|r[t+1]>>4],i+=Ms[(r[t+1]&15)<<2|r[t+2]>>6],i+=Ms[r[t+2]&63];return n%3===2?i=i.substring(0,i.length-1)+"=":n%3===1&&(i=i.substring(0,i.length-2)+"=="),i};eo.encode=wY;const SY=e=>{let r=e.length*.75,t=e.length,n,i=0,a,s,o,u;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);const c=new ArrayBuffer(r),l=new Uint8Array(c);for(n=0;n<t;n+=4)a=Fo[e.charCodeAt(n)],s=Fo[e.charCodeAt(n+1)],o=Fo[e.charCodeAt(n+2)],u=Fo[e.charCodeAt(n+3)],l[i++]=a<<2|s>>4,l[i++]=(s&15)<<4|o>>2,l[i++]=(o&3)<<6|u&63;return c};eo.decode=SY;Object.defineProperty(wf,"__esModule",{value:!0});wf.decodePacket=void 0;const $c=ui,CY=eo,TY=typeof ArrayBuffer=="function",EY=(e,r)=>{if(typeof e!="string")return{type:"message",data:E1(e,r)};const t=e.charAt(0);return t==="b"?{type:"message",data:kY(e.substring(1),r)}:$c.PACKET_TYPES_REVERSE[t]?e.length>1?{type:$c.PACKET_TYPES_REVERSE[t],data:e.substring(1)}:{type:$c.PACKET_TYPES_REVERSE[t]}:$c.ERROR_PACKET};wf.decodePacket=EY;const kY=(e,r)=>{if(TY){const t=(0,CY.decode)(e);return E1(t,r)}else return{base64:!0,data:e}},E1=(e,r)=>{switch(r){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodePayload=e.decodePacket=e.encodePayload=e.encodePacket=e.protocol=void 0,e.createPacketEncoderStream=o,e.createPacketDecoderStream=h;const r=Lu;Object.defineProperty(e,"encodePacket",{enumerable:!0,get:function(){return r.encodePacket}});const t=wf;Object.defineProperty(e,"decodePacket",{enumerable:!0,get:function(){return t.decodePacket}});const n=ui,i="",a=(v,m)=>{const _=v.length,C=new Array(_);let I=0;v.forEach(($,x)=>{(0,r.encodePacket)($,!1,N=>{C[x]=N,++I===_&&m(C.join(i))})})};e.encodePayload=a;const s=(v,m)=>{const _=v.split(i),C=[];for(let I=0;I<_.length;I++){const $=(0,t.decodePacket)(_[I],m);if(C.push($),$.type==="error")break}return C};e.decodePayload=s;function o(){return new TransformStream({transform(v,m){(0,r.encodePacketToBinary)(v,_=>{const C=_.length;let I;if(C<126)I=new Uint8Array(1),new DataView(I.buffer).setUint8(0,C);else if(C<65536){I=new Uint8Array(3);const $=new DataView(I.buffer);$.setUint8(0,126),$.setUint16(1,C)}else{I=new Uint8Array(9);const $=new DataView(I.buffer);$.setUint8(0,127),$.setBigUint64(1,BigInt(C))}v.data&&typeof v.data!="string"&&(I[0]|=128),m.enqueue(I),m.enqueue(_)})}})}let u;function c(v){return v.reduce((m,_)=>m+_.length,0)}function l(v,m){if(v[0].length===m)return v.shift();const _=new Uint8Array(m);let C=0;for(let I=0;I<m;I++)_[I]=v[0][C++],C===v[0].length&&(v.shift(),C=0);return v.length&&C<v[0].length&&(v[0]=v[0].slice(C)),_}function h(v,m){u||(u=new TextDecoder);const _=[];let C=0,I=-1,$=!1;return new TransformStream({transform(x,N){for(_.push(x);;){if(C===0){if(c(_)<1)break;const q=l(_,1);$=(q[0]&128)===128,I=q[0]&127,I<126?C=3:I===126?C=1:C=2}else if(C===1){if(c(_)<2)break;const q=l(_,2);I=new DataView(q.buffer,q.byteOffset,q.length).getUint16(0),C=3}else if(C===2){if(c(_)<8)break;const q=l(_,8),X=new DataView(q.buffer,q.byteOffset,q.length),J=X.getUint32(0);if(J>Math.pow(2,21)-1){N.enqueue(n.ERROR_PACKET);break}I=J*Math.pow(2,32)+X.getUint32(4),C=3}else{if(c(_)<I)break;const q=l(_,I);N.enqueue((0,t.decodePacket)($?q:u.decode(q),m)),C=0}if(I===0||I>v){N.enqueue(n.ERROR_PACKET);break}}}})}e.protocol=4})(po);function jr(e){if(e)return RY(e)}function RY(e){for(var r in jr.prototype)e[r]=jr.prototype[r];return e}jr.prototype.on=jr.prototype.addEventListener=function(e,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(r),this};jr.prototype.once=function(e,r){function t(){this.off(e,t),r.apply(this,arguments)}return t.fn=r,this.on(e,t),this};jr.prototype.off=jr.prototype.removeListener=jr.prototype.removeAllListeners=jr.prototype.removeEventListener=function(e,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+e];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,i=0;i<t.length;i++)if(n=t[i],n===r||n.fn===r){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+e],this};jr.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),t=this._callbacks["$"+e],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,i=t.length;n<i;++n)t[n].apply(this,r)}return this};jr.prototype.emitReserved=jr.prototype.emit;jr.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};jr.prototype.hasListeners=function(e){return!!this.listeners(e).length};const $Y=Object.freeze(Object.defineProperty({__proto__:null,Emitter:jr},Symbol.toStringTag,{value:"Module"})),ho=P0($Y);var Jn={},Xr={};Object.defineProperty(Xr,"__esModule",{value:!0});Xr.defaultBinaryType=Xr.globalThisShim=Xr.nextTick=void 0;Xr.createCookieJar=IY;Xr.nextTick=typeof Promise=="function"&&typeof Promise.resolve=="function"?r=>Promise.resolve().then(r):(r,t)=>t(r,0);Xr.globalThisShim=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();Xr.defaultBinaryType="arraybuffer";function IY(){}Object.defineProperty(Jn,"__esModule",{value:!0});Jn.pick=OY;Jn.installTimerFunctions=MY;Jn.byteLength=NY;Jn.randomString=DY;const ca=Xr;function OY(e,...r){return r.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const PY=ca.globalThisShim.setTimeout,AY=ca.globalThisShim.clearTimeout;function MY(e,r){r.useNativeTimers?(e.setTimeoutFn=PY.bind(ca.globalThisShim),e.clearTimeoutFn=AY.bind(ca.globalThisShim)):(e.setTimeoutFn=ca.globalThisShim.setTimeout.bind(ca.globalThisShim),e.clearTimeoutFn=ca.globalThisShim.clearTimeout.bind(ca.globalThisShim))}const xY=1.33;function NY(e){return typeof e=="string"?LY(e):Math.ceil((e.byteLength||e.size)*xY)}function LY(e){let r=0,t=0;for(let n=0,i=e.length;n<i;n++)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:r<55296||r>=57344?t+=3:(n++,t+=4);return t}function DY(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}var Du={};Object.defineProperty(Du,"__esModule",{value:!0});Du.encode=jY;Du.decode=FY;function jY(e){let r="";for(let t in e)e.hasOwnProperty(t)&&(r.length&&(r+="&"),r+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return r}function FY(e){let r={},t=e.split("&");for(let n=0,i=t.length;n<i;n++){let a=t[n].split("=");r[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return r}var Vh={exports:{}},Ip,LS;function UY(){if(LS)return Ip;LS=1;var e=1e3,r=e*60,t=r*60,n=t*24,i=n*7,a=n*365.25;Ip=function(l,h){h=h||{};var v=typeof l;if(v==="string"&&l.length>0)return s(l);if(v==="number"&&isFinite(l))return h.long?u(l):o(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function s(l){if(l=String(l),!(l.length>100)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(h){var v=parseFloat(h[1]),m=(h[2]||"ms").toLowerCase();switch(m){case"years":case"year":case"yrs":case"yr":case"y":return v*a;case"weeks":case"week":case"w":return v*i;case"days":case"day":case"d":return v*n;case"hours":case"hour":case"hrs":case"hr":case"h":return v*t;case"minutes":case"minute":case"mins":case"min":case"m":return v*r;case"seconds":case"second":case"secs":case"sec":case"s":return v*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return v;default:return}}}}function o(l){var h=Math.abs(l);return h>=n?Math.round(l/n)+"d":h>=t?Math.round(l/t)+"h":h>=r?Math.round(l/r)+"m":h>=e?Math.round(l/e)+"s":l+"ms"}function u(l){var h=Math.abs(l);return h>=n?c(l,h,n,"day"):h>=t?c(l,h,t,"hour"):h>=r?c(l,h,r,"minute"):h>=e?c(l,h,e,"second"):l+" ms"}function c(l,h,v,m){var _=h>=v*1.5;return Math.round(l/v)+" "+m+(_?"s":"")}return Ip}function BY(e){t.debug=t,t.default=t,t.coerce=u,t.disable=a,t.enable=i,t.enabled=s,t.humanize=UY(),t.destroy=c,Object.keys(e).forEach(l=>{t[l]=e[l]}),t.names=[],t.skips=[],t.formatters={};function r(l){let h=0;for(let v=0;v<l.length;v++)h=(h<<5)-h+l.charCodeAt(v),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=r;function t(l){let h,v=null,m,_;function C(...I){if(!C.enabled)return;const $=C,x=Number(new Date),N=x-(h||x);$.diff=N,$.prev=h,$.curr=x,h=x,I[0]=t.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let q=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(J,G)=>{if(J==="%%")return"%";q++;const L=t.formatters[G];if(typeof L=="function"){const te=I[q];J=L.call($,te),I.splice(q,1),q--}return J}),t.formatArgs.call($,I),($.log||t.log).apply($,I)}return C.namespace=l,C.useColors=t.useColors(),C.color=t.selectColor(l),C.extend=n,C.destroy=t.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(m!==t.namespaces&&(m=t.namespaces,_=t.enabled(l)),_),set:I=>{v=I}}),typeof t.init=="function"&&t.init(C),C}function n(l,h){const v=t(this.namespace+(typeof h>"u"?":":h)+l);return v.log=this.log,v}function i(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let h;const v=(typeof l=="string"?l:"").split(/[\s,]+/),m=v.length;for(h=0;h<m;h++)v[h]&&(l=v[h].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function a(){const l=[...t.names.map(o),...t.skips.map(o).map(h=>"-"+h)].join(",");return t.enable(""),l}function s(l){if(l[l.length-1]==="*")return!0;let h,v;for(h=0,v=t.skips.length;h<v;h++)if(t.skips[h].test(l))return!1;for(h=0,v=t.names.length;h<v;h++)if(t.names[h].test(l))return!0;return!1}function o(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}var qY=BY;(function(e,r){r.formatArgs=n,r.save=i,r.load=a,r.useColors=t,r.storage=s(),r.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const c="color: "+this.color;u.splice(1,0,c,"color: inherit");let l=0,h=0;u[0].replace(/%[a-zA-Z%]/g,v=>{v!=="%%"&&(l++,v==="%c"&&(h=l))}),u.splice(h,0,c)}r.log=console.debug||console.log||(()=>{});function i(u){try{u?r.storage.setItem("debug",u):r.storage.removeItem("debug")}catch{}}function a(){let u;try{u=r.storage.getItem("debug")}catch{}return!u&&typeof process<"u"&&"env"in process&&(u=process.env.DEBUG),u}function s(){try{return localStorage}catch{}}e.exports=qY(r);const{formatters:o}=e.exports;o.j=function(u){try{return JSON.stringify(u)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}})(Vh,Vh.exports);var Yn=Vh.exports,zY=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ui,"__esModule",{value:!0});Ui.Transport=Ui.TransportError=void 0;const WY=po,VY=ho,GY=Jn,HY=Du,KY=zY(Yn),JY=(0,KY.default)("engine.io-client:transport");class k1 extends Error{constructor(r,t,n){super(r),this.description=t,this.context=n,this.type="TransportError"}}Ui.TransportError=k1;class YY extends VY.Emitter{constructor(r){super(),this.writable=!1,(0,GY.installTimerFunctions)(this,r),this.opts=r,this.query=r.query,this.socket=r.socket,this.supportsBinary=!r.forceBase64}onError(r,t,n){return super.emitReserved("error",new k1(r,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(r){this.readyState==="open"?this.write(r):JY("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(r){const t=(0,WY.decodePacket)(r,this.socket.binaryType);this.onPacket(t)}onPacket(r){super.emitReserved("packet",r)}onClose(r){this.readyState="closed",super.emitReserved("close",r)}pause(r){}createUri(r,t={}){return r+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const r=this.opts.hostname;return r.indexOf(":")===-1?r:"["+r+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(r){const t=(0,HY.encode)(r);return t.length?"?"+t:""}}Ui.Transport=YY;var XY=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Nu,"__esModule",{value:!0});Nu.Polling=void 0;const QY=Ui,ZY=Jn,DS=po,eX=XY(Yn),Dn=(0,eX.default)("engine.io-client:polling");class tX extends QY.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(r){this.readyState="pausing";const t=()=>{Dn("paused"),this.readyState="paused",r()};if(this._polling||!this.writable){let n=0;this._polling&&(Dn("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){Dn("pre-pause polling complete"),--n||t()})),this.writable||(Dn("we are currently writing - waiting to pause"),n++,this.once("drain",function(){Dn("pre-pause writing complete"),--n||t()}))}else t()}_poll(){Dn("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(r){Dn("polling got data %s",r);const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};(0,DS.decodePayload)(r,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this._poll():Dn('ignoring poll - transport state "%s"',this.readyState))}doClose(){const r=()=>{Dn("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(Dn("transport open - closing"),r()):(Dn("transport not open - deferring close"),this.once("open",r))}write(r){this.writable=!1,(0,DS.encodePayload)(r,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const r=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=(0,ZY.randomString)()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(r,t)}}Nu.Polling=tX;var Sf={};Object.defineProperty(Sf,"__esModule",{value:!0});Sf.hasCORS=void 0;let R1=!1;try{R1=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}Sf.hasCORS=R1;var rX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(oi,"__esModule",{value:!0});oi.XHR=oi.Request=oi.BaseXHR=void 0;const nX=Nu,iX=ho,jS=Jn,$1=Xr,aX=Sf,sX=rX(Yn),Gh=(0,sX.default)("engine.io-client:polling");function oX(){}class I1 extends nX.Polling{constructor(r){if(super(r),typeof location<"u"){const t=location.protocol==="https:";let n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&r.hostname!==location.hostname||n!==r.port}}doWrite(r,t){const n=this.request({method:"POST",data:r});n.on("success",t),n.on("error",(i,a)=>{this.onError("xhr post error",i,a)})}doPoll(){Gh("xhr poll");const r=this.request();r.on("data",this.onData.bind(this)),r.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=r}}oi.BaseXHR=I1;class Vn extends iX.Emitter{constructor(r,t,n){super(),this.createRequest=r,(0,jS.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var r;const t=(0,jS.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{Gh("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&n.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(r=this._opts.cookieJar)===null||r===void 0||r.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var i;n.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},Gh("xhr data %s",this._data),n.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=Vn.requestsCount++,Vn.requests[this._index]=this)}_onError(r){this.emitReserved("error",r,this._xhr),this._cleanup(!0)}_cleanup(r){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=oX,r)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Vn.requests[this._index],this._xhr=null}}_onLoad(){const r=this._xhr.responseText;r!==null&&(this.emitReserved("data",r),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}oi.Request=Vn;Vn.requestsCount=0;Vn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",FS);else if(typeof addEventListener=="function"){const e="onpagehide"in $1.globalThisShim?"pagehide":"unload";addEventListener(e,FS,!1)}}function FS(){for(let e in Vn.requests)Vn.requests.hasOwnProperty(e)&&Vn.requests[e].abort()}const uX=function(){const e=O1({xdomain:!1});return e&&e.responseType!==null}();class cX extends I1{constructor(r){super(r);const t=r&&r.forceBase64;this.supportsBinary=uX&&!t}request(r={}){return Object.assign(r,{xd:this.xd},this.opts),new Vn(O1,this.uri(),r)}}oi.XHR=cX;function O1(e){const r=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!r||aX.hasCORS))return new XMLHttpRequest}catch{}if(!r)try{return new $1.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var wa={},lX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wa,"__esModule",{value:!0});wa.WS=wa.BaseWS=void 0;const fX=Ui,US=Jn,dX=po,Hh=Xr,pX=lX(Yn),hX=(0,pX.default)("engine.io-client:websocket"),P1=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class A1 extends fX.Transport{get name(){return"websocket"}doOpen(){const r=this.uri(),t=this.opts.protocols,n=P1?{}:(0,US.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(r,t,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=r=>this.onClose({description:"websocket connection closed",context:r}),this.ws.onmessage=r=>this.onData(r.data),this.ws.onerror=r=>this.onError("websocket error",r)}write(r){this.writable=!1;for(let t=0;t<r.length;t++){const n=r[t],i=t===r.length-1;(0,dX.encodePacket)(n,this.supportsBinary,a=>{try{this.doWrite(n,a)}catch{hX("websocket closed before onclose event")}i&&(0,Hh.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const r=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,US.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(r,t)}}wa.BaseWS=A1;const Op=Hh.globalThisShim.WebSocket||Hh.globalThisShim.MozWebSocket;class vX extends A1{createSocket(r,t,n){return P1?new Op(r,t,n):t?new Op(r,t):new Op(r)}doWrite(r,t){this.ws.send(t)}}wa.WS=vX;var ju={},mX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ju,"__esModule",{value:!0});ju.WT=void 0;const gX=Ui,yX=Xr,BS=po,bX=mX(Yn),Ao=(0,bX.default)("engine.io-client:webtransport");class _X extends gX.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(r){return this.emitReserved("error",r)}this._transport.closed.then(()=>{Ao("transport closed gracefully"),this.onClose()}).catch(r=>{Ao("transport closed due to %s",r),this.onError("webtransport error",r)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(r=>{const t=(0,BS.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=r.readable.pipeThrough(t).getReader(),i=(0,BS.createPacketEncoderStream)();i.readable.pipeTo(r.writable),this._writer=i.writable.getWriter();const a=()=>{n.read().then(({done:o,value:u})=>{if(o){Ao("session is closed");return}Ao("received chunk: %o",u),this.onPacket(u),a()}).catch(o=>{Ao("an error occurred while reading: %s",o)})};a();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(r){this.writable=!1;for(let t=0;t<r.length;t++){const n=r[t],i=t===r.length-1;this._writer.write(n).then(()=>{i&&(0,yX.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var r;(r=this._transport)===null||r===void 0||r.close()}}ju.WT=_X;Object.defineProperty(xu,"__esModule",{value:!0});xu.transports=void 0;const wX=oi,SX=wa,CX=ju;xu.transports={websocket:SX.WS,webtransport:CX.WT,polling:wX.XHR};var Cf={};Object.defineProperty(Cf,"__esModule",{value:!0});Cf.parse=kX;const TX=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,EX=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function kX(e){if(e.length>8e3)throw"URI too long";const r=e,t=e.indexOf("["),n=e.indexOf("]");t!=-1&&n!=-1&&(e=e.substring(0,t)+e.substring(t,n).replace(/:/g,";")+e.substring(n,e.length));let i=TX.exec(e||""),a={},s=14;for(;s--;)a[EX[s]]=i[s]||"";return t!=-1&&n!=-1&&(a.source=r,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=RX(a,a.path),a.queryKey=$X(a,a.query),a}function RX(e,r){const t=/\/{2,9}/g,n=r.replace(t,"/").split("/");return(r.slice(0,1)=="/"||r.length===0)&&n.splice(0,1),r.slice(-1)=="/"&&n.splice(n.length-1,1),n}function $X(e,r){const t={};return r.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,a){i&&(t[i]=a)}),t}var IX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ni,"__esModule",{value:!0});Ni.Socket=Ni.SocketWithUpgrade=Ni.SocketWithoutUpgrade=void 0;const OX=xu,qS=Jn,PX=Du,zS=Cf,AX=ho,M1=po,Pp=Xr,MX=IX(Yn),Ht=(0,MX.default)("engine.io-client:socket"),Kh=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ho=[];Kh&&addEventListener("offline",()=>{Ht("closing %d connection(s) because the network was lost",Ho.length),Ho.forEach(e=>e())},!1);class Li extends AX.Emitter{constructor(r,t){if(super(),this.binaryType=Pp.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,r&&typeof r=="object"&&(t=r,r=null),r){const n=(0,zS.parse)(r);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,zS.parse)(t.host).host);(0,qS.installTimerFunctions)(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{const i=n.prototype.name;this.transports.push(i),this._transportsByName[i]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=(0,PX.decode)(this.opts.query)),Kh&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(Ht("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ho.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,Pp.createCookieJar)()),this._open()}createTransport(r){Ht('creating transport "%s"',r);const t=Object.assign({},this.opts.query);t.EIO=M1.protocol,t.transport=r,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[r]);return Ht("options: %j",n),new this._transportsByName[r](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const r=this.opts.rememberUpgrade&&Li.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(r);t.open(),this.setTransport(t)}setTransport(r){Ht("setting transport %s",r.name),this.transport&&(Ht("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=r,r.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){Ht("socket open"),this.readyState="open",Li.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(Ht('socket receive: type "%s", data "%s"',r.type,r.data),this.emitReserved("packet",r),this.emitReserved("heartbeat"),r.type){case"open":this.onHandshake(JSON.parse(r.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=r.data,this._onError(t);break;case"message":this.emitReserved("data",r.data),this.emitReserved("message",r.data);break}else Ht('packet received with socket readyState "%s"',this.readyState)}onHandshake(r){this.emitReserved("handshake",r),this.id=r.sid,this.transport.query.sid=r.sid,this._pingInterval=r.pingInterval,this._pingTimeout=r.pingTimeout,this._maxPayload=r.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const r=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+r,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},r),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const r=this._getWritablePackets();Ht("flushing %d packets in socket",r.length),this.transport.send(r),this._prevBufferLen=r.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){const i=this.writeBuffer[n].data;if(i&&(t+=(0,qS.byteLength)(i)),n>0&&t>this._maxPayload)return Ht("only send %d out of %d packets",n,this.writeBuffer.length),this.writeBuffer.slice(0,n);t+=2}return Ht("payload size is %d (max: %d)",t,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const r=Date.now()>this._pingTimeoutTime;return r&&(Ht("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,Pp.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),r}write(r,t,n){return this._sendPacket("message",r,t,n),this}send(r,t,n){return this._sendPacket("message",r,t,n),this}_sendPacket(r,t,n,i){if(typeof t=="function"&&(i=t,t=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const a={type:r,data:t,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const r=()=>{this._onClose("forced close"),Ht("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),r()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():r()}):this.upgrading?n():r()),this}_onError(r){if(Ht("socket error %j",r),Li.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return Ht("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",r),this._onClose("transport error",r)}_onClose(r,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(Ht('socket close with reason: "%s"',r),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Kh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=Ho.indexOf(this._offlineEventListener);n!==-1&&(Ht("removing listener for the 'offline' event"),Ho.splice(n,1))}this.readyState="closed",this.id=null,this.emitReserved("close",r,t),this.writeBuffer=[],this._prevBufferLen=0}}}Ni.SocketWithoutUpgrade=Li;Li.protocol=M1.protocol;class x1 extends Li{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade){Ht("starting upgrade probes");for(let r=0;r<this._upgrades.length;r++)this._probe(this._upgrades[r])}}_probe(r){Ht('probing transport "%s"',r);let t=this.createTransport(r),n=!1;Li.priorWebsocketSuccess=!1;const i=()=>{n||(Ht('probe transport "%s" opened',r),t.send([{type:"ping",data:"probe"}]),t.once("packet",h=>{if(!n)if(h.type==="pong"&&h.data==="probe"){if(Ht('probe transport "%s" pong',r),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Li.priorWebsocketSuccess=t.name==="websocket",Ht('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||this.readyState!=="closed"&&(Ht("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{Ht('probe transport "%s" failed',r);const v=new Error("probe error");v.transport=t.name,this.emitReserved("upgradeError",v)}}))};function a(){n||(n=!0,l(),t.close(),t=null)}const s=h=>{const v=new Error("probe error: "+h);v.transport=t.name,a(),Ht('probe transport "%s" failed because of error: %s',r,h),this.emitReserved("upgradeError",v)};function o(){s("transport closed")}function u(){s("socket closed")}function c(h){t&&h.name!==t.name&&(Ht('"%s" works - aborting "%s"',h.name,t.name),a())}const l=()=>{t.removeListener("open",i),t.removeListener("error",s),t.removeListener("close",o),this.off("close",u),this.off("upgrading",c)};t.once("open",i),t.once("error",s),t.once("close",o),this.once("close",u),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&r!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(r){this._upgrades=this._filterUpgrades(r.upgrades),super.onHandshake(r)}_filterUpgrades(r){const t=[];for(let n=0;n<r.length;n++)~this.transports.indexOf(r[n])&&t.push(r[n]);return t}}Ni.SocketWithUpgrade=x1;let xX=class extends x1{constructor(r,t={}){const n=typeof r=="object"?r:t;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(i=>OX.transports[i]).filter(i=>!!i)),super(r,n)}};Ni.Socket=xX;var Tf={};Object.defineProperty(Tf,"__esModule",{value:!0});Tf.Fetch=void 0;const NX=Nu;class LX extends NX.Polling{doPoll(){this._fetch().then(r=>{if(!r.ok)return this.onError("fetch read error",r.status,r);r.text().then(t=>this.onData(t))}).catch(r=>{this.onError("fetch read error",r)})}doWrite(r,t){this._fetch(r).then(n=>{if(!n.ok)return this.onError("fetch write error",n.status,n);t()}).catch(n=>{this.onError("fetch write error",n)})}_fetch(r){var t;const n=r!==void 0,i=new Headers(this.opts.extraHeaders);return n&&i.set("content-type","text/plain;charset=UTF-8"),(t=this.socket._cookieJar)===null||t===void 0||t.appendCookies(i),fetch(this.uri(),{method:n?"POST":"GET",body:n?r:null,headers:i,credentials:this.opts.withCredentials?"include":"omit"}).then(a=>{var s;return(s=this.socket._cookieJar)===null||s===void 0||s.parseCookies(a.headers.getSetCookie()),a})}}Tf.Fetch=LX;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.WebTransport=e.WebSocket=e.NodeWebSocket=e.XHR=e.NodeXHR=e.Fetch=e.nextTick=e.parse=e.installTimerFunctions=e.transports=e.TransportError=e.Transport=e.protocol=e.SocketWithUpgrade=e.SocketWithoutUpgrade=e.Socket=void 0;const r=Ni;Object.defineProperty(e,"Socket",{enumerable:!0,get:function(){return r.Socket}});var t=Ni;Object.defineProperty(e,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return t.SocketWithoutUpgrade}}),Object.defineProperty(e,"SocketWithUpgrade",{enumerable:!0,get:function(){return t.SocketWithUpgrade}}),e.protocol=r.Socket.protocol;var n=Ui;Object.defineProperty(e,"Transport",{enumerable:!0,get:function(){return n.Transport}}),Object.defineProperty(e,"TransportError",{enumerable:!0,get:function(){return n.TransportError}});var i=xu;Object.defineProperty(e,"transports",{enumerable:!0,get:function(){return i.transports}});var a=Jn;Object.defineProperty(e,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var s=Cf;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return s.parse}});var o=Xr;Object.defineProperty(e,"nextTick",{enumerable:!0,get:function(){return o.nextTick}});var u=Tf;Object.defineProperty(e,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var c=oi;Object.defineProperty(e,"NodeXHR",{enumerable:!0,get:function(){return c.XHR}});var l=oi;Object.defineProperty(e,"XHR",{enumerable:!0,get:function(){return l.XHR}});var h=wa;Object.defineProperty(e,"NodeWebSocket",{enumerable:!0,get:function(){return h.WS}});var v=wa;Object.defineProperty(e,"WebSocket",{enumerable:!0,get:function(){return v.WS}});var m=ju;Object.defineProperty(e,"WebTransport",{enumerable:!0,get:function(){return m.WT}})})(_f);var DX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lg,"__esModule",{value:!0});lg.url=UX;const jX=_f,FX=DX(Yn),WS=(0,FX.default)("socket.io-client:url");function UX(e,r="",t){let n=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(WS("protocol-less url %s",e),typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),WS("parse %s",e),n=(0,jX.parse)(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const a=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+a+":"+n.port+r,n.href=n.protocol+"://"+a+(t&&t.port===n.port?"":":"+n.port),n}var Ef={},Fu={},kf={},to={},es={};Object.defineProperty(es,"__esModule",{value:!0});es.hasBinary=es.isBinary=void 0;const BX=typeof ArrayBuffer=="function",qX=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,N1=Object.prototype.toString,zX=typeof Blob=="function"||typeof Blob<"u"&&N1.call(Blob)==="[object BlobConstructor]",WX=typeof File=="function"||typeof File<"u"&&N1.call(File)==="[object FileConstructor]";function L1(e){return BX&&(e instanceof ArrayBuffer||qX(e))||zX&&e instanceof Blob||WX&&e instanceof File}es.isBinary=L1;function rl(e,r){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(rl(e[t]))return!0;return!1}if(L1(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return rl(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&rl(e[t]))return!0;return!1}es.hasBinary=rl;Object.defineProperty(to,"__esModule",{value:!0});to.reconstructPacket=to.deconstructPacket=void 0;const VX=es;function GX(e){const r=[],t=e.data,n=e;return n.data=Jh(t,r),n.attachments=r.length,{packet:n,buffers:r}}to.deconstructPacket=GX;function Jh(e,r){if(!e)return e;if((0,VX.isBinary)(e)){const t={_placeholder:!0,num:r.length};return r.push(e),t}else if(Array.isArray(e)){const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=Jh(e[n],r);return t}else if(typeof e=="object"&&!(e instanceof Date)){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=Jh(e[n],r));return t}return e}function HX(e,r){return e.data=Yh(e.data,r),delete e.attachments,e}to.reconstructPacket=HX;function Yh(e,r){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<r.length)return r[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=Yh(e[t],r);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=Yh(e[t],r));return e}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Decoder=e.Encoder=e.PacketType=e.protocol=void 0;const r=ho,t=to,n=es,a=(0,Yn.default)("socket.io-parser"),s=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];e.protocol=5;var o;(function(v){v[v.CONNECT=0]="CONNECT",v[v.DISCONNECT=1]="DISCONNECT",v[v.EVENT=2]="EVENT",v[v.ACK=3]="ACK",v[v.CONNECT_ERROR=4]="CONNECT_ERROR",v[v.BINARY_EVENT=5]="BINARY_EVENT",v[v.BINARY_ACK=6]="BINARY_ACK"})(o=e.PacketType||(e.PacketType={}));class u{constructor(m){this.replacer=m}encode(m){return a("encoding packet %j",m),(m.type===o.EVENT||m.type===o.ACK)&&(0,n.hasBinary)(m)?this.encodeAsBinary({type:m.type===o.EVENT?o.BINARY_EVENT:o.BINARY_ACK,nsp:m.nsp,data:m.data,id:m.id}):[this.encodeAsString(m)]}encodeAsString(m){let _=""+m.type;return(m.type===o.BINARY_EVENT||m.type===o.BINARY_ACK)&&(_+=m.attachments+"-"),m.nsp&&m.nsp!=="/"&&(_+=m.nsp+","),m.id!=null&&(_+=m.id),m.data!=null&&(_+=JSON.stringify(m.data,this.replacer)),a("encoded %j as %s",m,_),_}encodeAsBinary(m){const _=(0,t.deconstructPacket)(m),C=this.encodeAsString(_.packet),I=_.buffers;return I.unshift(C),I}}e.Encoder=u;function c(v){return Object.prototype.toString.call(v)==="[object Object]"}class l extends r.Emitter{constructor(m){super(),this.reviver=m}add(m){let _;if(typeof m=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");_=this.decodeString(m);const C=_.type===o.BINARY_EVENT;C||_.type===o.BINARY_ACK?(_.type=C?o.EVENT:o.ACK,this.reconstructor=new h(_),_.attachments===0&&super.emitReserved("decoded",_)):super.emitReserved("decoded",_)}else if((0,n.isBinary)(m)||m.base64)if(this.reconstructor)_=this.reconstructor.takeBinaryData(m),_&&(this.reconstructor=null,super.emitReserved("decoded",_));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+m)}decodeString(m){let _=0;const C={type:Number(m.charAt(0))};if(o[C.type]===void 0)throw new Error("unknown packet type "+C.type);if(C.type===o.BINARY_EVENT||C.type===o.BINARY_ACK){const $=_+1;for(;m.charAt(++_)!=="-"&&_!=m.length;);const x=m.substring($,_);if(x!=Number(x)||m.charAt(_)!=="-")throw new Error("Illegal attachments");C.attachments=Number(x)}if(m.charAt(_+1)==="/"){const $=_+1;for(;++_&&!(m.charAt(_)===","||_===m.length););C.nsp=m.substring($,_)}else C.nsp="/";const I=m.charAt(_+1);if(I!==""&&Number(I)==I){const $=_+1;for(;++_;){const x=m.charAt(_);if(x==null||Number(x)!=x){--_;break}if(_===m.length)break}C.id=Number(m.substring($,_+1))}if(m.charAt(++_)){const $=this.tryParse(m.substr(_));if(l.isPayloadValid(C.type,$))C.data=$;else throw new Error("invalid payload")}return a("decoded %s as %j",m,C),C}tryParse(m){try{return JSON.parse(m,this.reviver)}catch{return!1}}static isPayloadValid(m,_){switch(m){case o.CONNECT:return c(_);case o.DISCONNECT:return _===void 0;case o.CONNECT_ERROR:return typeof _=="string"||c(_);case o.EVENT:case o.BINARY_EVENT:return Array.isArray(_)&&(typeof _[0]=="number"||typeof _[0]=="string"&&s.indexOf(_[0])===-1);case o.ACK:case o.BINARY_ACK:return Array.isArray(_)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}e.Decoder=l;class h{constructor(m){this.packet=m,this.buffers=[],this.reconPack=m}takeBinaryData(m){if(this.buffers.push(m),this.buffers.length===this.reconPack.attachments){const _=(0,t.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),_}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}})(kf);var Rf={};Object.defineProperty(Rf,"__esModule",{value:!0});Rf.on=KX;function KX(e,r,t){return e.on(r,t),function(){e.off(r,t)}}var JX=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Fu,"__esModule",{value:!0});Fu.Socket=void 0;const jn=kf,Ic=Rf,YX=ho,XX=JX(Yn),br=(0,XX.default)("socket.io-client:socket"),QX=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ZX extends YX.Emitter{constructor(r,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=r,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const r=this.io;this.subs=[(0,Ic.on)(r,"open",this.onopen.bind(this)),(0,Ic.on)(r,"packet",this.onpacket.bind(this)),(0,Ic.on)(r,"error",this.onerror.bind(this)),(0,Ic.on)(r,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...r){return r.unshift("message"),this.emit.apply(this,r),this}emit(r,...t){var n,i,a;if(QX.hasOwnProperty(r))throw new Error('"'+r.toString()+'" is a reserved event name');if(t.unshift(r),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const s={type:jn.PacketType.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const l=this.ids++;br("emitting packet with ack id %d",l);const h=t.pop();this._registerAckCallback(l,h),s.id=l}const o=(i=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||i===void 0?void 0:i.writable,u=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!o?br("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s),this.flags={},this}_registerAckCallback(r,t){var n;const i=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(i===void 0){this.acks[r]=t;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[r];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===r&&(br("removing packet with ack id %d from the buffer",r),this.sendBuffer.splice(o,1));br("event with ack id %d has timed out after %d ms",r,i),t.call(this,new Error("operation has timed out"))},i),s=(...o)=>{this.io.clearTimeoutFn(a),t.apply(this,o)};s.withError=!0,this.acks[r]=s}emitWithAck(r,...t){return new Promise((n,i)=>{const a=(s,o)=>s?i(s):n(o);a.withError=!0,t.push(a),this.emit(r,...t)})}_addToQueue(r){let t;typeof r[r.length-1]=="function"&&(t=r.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:r,flags:Object.assign({fromQueue:!0},this.flags)};r.push((i,...a)=>n!==this._queue[0]?void 0:(i!==null?n.tryCount>this._opts.retries&&(br("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(i)):(br("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...a)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(r=!1){if(br("draining queue"),!this.connected||this._queue.length===0)return;const t=this._queue[0];if(t.pending&&!r){br("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,br("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(r){r.nsp=this.nsp,this.io._packet(r)}onopen(){br("transport is open - connecting"),typeof this.auth=="function"?this.auth(r=>{this._sendConnectPacket(r)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(r){this.packet({type:jn.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},r):r})}onerror(r){this.connected||this.emitReserved("connect_error",r)}onclose(r,t){br("close (%s)",r),this.connected=!1,delete this.id,this.emitReserved("disconnect",r,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(r=>{if(!this.sendBuffer.some(n=>String(n.id)===r)){const n=this.acks[r];delete this.acks[r],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(r){if(r.nsp===this.nsp)switch(r.type){case jn.PacketType.CONNECT:r.data&&r.data.sid?this.onconnect(r.data.sid,r.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case jn.PacketType.EVENT:case jn.PacketType.BINARY_EVENT:this.onevent(r);break;case jn.PacketType.ACK:case jn.PacketType.BINARY_ACK:this.onack(r);break;case jn.PacketType.DISCONNECT:this.ondisconnect();break;case jn.PacketType.CONNECT_ERROR:this.destroy();const n=new Error(r.data.message);n.data=r.data.data,this.emitReserved("connect_error",n);break}}onevent(r){const t=r.data||[];br("emitting event %j",t),r.id!=null&&(br("attaching ack callback to event"),t.push(this.ack(r.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(r){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,r)}super.emit.apply(this,r),this._pid&&r.length&&typeof r[r.length-1]=="string"&&(this._lastOffset=r[r.length-1])}ack(r){const t=this;let n=!1;return function(...i){n||(n=!0,br("sending ack %j",i),t.packet({type:jn.PacketType.ACK,id:r,data:i}))}}onack(r){const t=this.acks[r.id];if(typeof t!="function"){br("bad ack %s",r.id);return}delete this.acks[r.id],br("calling ack %s with %j",r.id,r.data),t.withError&&r.data.unshift(null),t.apply(this,r.data)}onconnect(r,t){br("socket connected with id %s",r),this.id=r,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(r=>this.emitEvent(r)),this.receiveBuffer=[],this.sendBuffer.forEach(r=>{this.notifyOutgoingListeners(r),this.packet(r)}),this.sendBuffer=[]}ondisconnect(){br("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(r=>r()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(br("performing disconnect (%s)",this.nsp),this.packet({type:jn.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(r){return this.flags.compress=r,this}get volatile(){return this.flags.volatile=!0,this}timeout(r){return this.flags.timeout=r,this}onAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(r),this}prependAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(r),this}offAny(r){if(!this._anyListeners)return this;if(r){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(r===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(r),this}prependAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(r),this}offAnyOutgoing(r){if(!this._anyOutgoingListeners)return this;if(r){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(r===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(r){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,r.data)}}}Fu.Socket=ZX;var fg={};Object.defineProperty(fg,"__esModule",{value:!0});fg.Backoff=vo;function vo(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}vo.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var r=Math.random(),t=Math.floor(r*this.jitter*e);e=Math.floor(r*10)&1?e+t:e-t}return Math.min(e,this.max)|0};vo.prototype.reset=function(){this.attempts=0};vo.prototype.setMin=function(e){this.ms=e};vo.prototype.setMax=function(e){this.max=e};vo.prototype.setJitter=function(e){this.jitter=e};var eQ=Ae&&Ae.__createBinding||(Object.create?function(e,r,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(r,t);(!i||("get"in i?!r.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,i)}:function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]}),tQ=Ae&&Ae.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),rQ=Ae&&Ae.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&eQ(r,e,t);return tQ(r,e),r},nQ=Ae&&Ae.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ef,"__esModule",{value:!0});Ef.Manager=void 0;const Ap=_f,iQ=Fu,aQ=rQ(kf),Va=Rf,sQ=fg,oQ=ho,uQ=nQ(Yn),Or=(0,uQ.default)("socket.io-client:manager");class cQ extends oQ.Emitter{constructor(r,t){var n;super(),this.nsps={},this.subs=[],r&&typeof r=="object"&&(t=r,r=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,(0,Ap.installTimerFunctions)(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new sQ.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=r;const i=t.parser||aQ;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(r){return arguments.length?(this._reconnection=!!r,r||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(r){return r===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=r,this)}reconnectionDelay(r){var t;return r===void 0?this._reconnectionDelay:(this._reconnectionDelay=r,(t=this.backoff)===null||t===void 0||t.setMin(r),this)}randomizationFactor(r){var t;return r===void 0?this._randomizationFactor:(this._randomizationFactor=r,(t=this.backoff)===null||t===void 0||t.setJitter(r),this)}reconnectionDelayMax(r){var t;return r===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=r,(t=this.backoff)===null||t===void 0||t.setMax(r),this)}timeout(r){return arguments.length?(this._timeout=r,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(r){if(Or("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Or("opening %s",this.uri),this.engine=new Ap.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=(0,Va.on)(t,"open",function(){n.onopen(),r&&r()}),a=o=>{Or("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",o),r?r(o):this.maybeReconnectOnOpen()},s=(0,Va.on)(t,"error",a);if(this._timeout!==!1){const o=this._timeout;Or("connect attempt will timeout after %d",o);const u=this.setTimeoutFn(()=>{Or("connect attempt timed out after %d",o),i(),a(new Error("timeout")),t.close()},o);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(i),this.subs.push(s),this}connect(r){return this.open(r)}onopen(){Or("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const r=this.engine;this.subs.push((0,Va.on)(r,"ping",this.onping.bind(this)),(0,Va.on)(r,"data",this.ondata.bind(this)),(0,Va.on)(r,"error",this.onerror.bind(this)),(0,Va.on)(r,"close",this.onclose.bind(this)),(0,Va.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(r){try{this.decoder.add(r)}catch(t){this.onclose("parse error",t)}}ondecoded(r){(0,Ap.nextTick)(()=>{this.emitReserved("packet",r)},this.setTimeoutFn)}onerror(r){Or("error",r),this.emitReserved("error",r)}socket(r,t){let n=this.nsps[r];return n?this._autoConnect&&!n.active&&n.connect():(n=new iQ.Socket(this,r,t),this.nsps[r]=n),n}_destroy(r){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active){Or("socket %s is still active, skipping close",n);return}this._close()}_packet(r){Or("writing packet %j",r);const t=this.encoder.encode(r);for(let n=0;n<t.length;n++)this.engine.write(t[n],r.options)}cleanup(){Or("cleanup"),this.subs.forEach(r=>r()),this.subs.length=0,this.decoder.destroy()}_close(){Or("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(r,t){var n;Or("closed due to %s",r),this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",r,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const r=this;if(this.backoff.attempts>=this._reconnectionAttempts)Or("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();Or("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn(()=>{r.skipReconnect||(Or("attempting reconnect"),this.emitReserved("reconnect_attempt",r.backoff.attempts),!r.skipReconnect&&r.open(i=>{i?(Or("reconnect attempt error"),r._reconnecting=!1,r.reconnect(),this.emitReserved("reconnect_error",i)):(Or("reconnect success"),r.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const r=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",r)}}Ef.Manager=cQ;(function(e,r){var t=Ae&&Ae.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(r,"__esModule",{value:!0}),r.WebTransport=r.WebSocket=r.NodeWebSocket=r.XHR=r.NodeXHR=r.Fetch=r.Socket=r.Manager=r.protocol=void 0,r.io=c,r.connect=c,r.default=c;const n=lg,i=Ef;Object.defineProperty(r,"Manager",{enumerable:!0,get:function(){return i.Manager}});const a=Fu;Object.defineProperty(r,"Socket",{enumerable:!0,get:function(){return a.Socket}});const o=(0,t(Yn).default)("socket.io-client"),u={};function c(v,m){typeof v=="object"&&(m=v,v=void 0),m=m||{};const _=(0,n.url)(v,m.path||"/socket.io"),C=_.source,I=_.id,$=_.path,x=u[I]&&$ in u[I].nsps,N=m.forceNew||m["force new connection"]||m.multiplex===!1||x;let q;return N?(o("ignoring socket cache for %s",C),q=new i.Manager(C,m)):(u[I]||(o("new io instance for %s",C),u[I]=new i.Manager(C,m)),q=u[I]),_.query&&!m.query&&(m.query=_.queryKey),q.socket(_.path,m)}Object.assign(c,{Manager:i.Manager,Socket:a.Socket,io:c,connect:c});var l=kf;Object.defineProperty(r,"protocol",{enumerable:!0,get:function(){return l.protocol}});var h=_f;Object.defineProperty(r,"Fetch",{enumerable:!0,get:function(){return h.Fetch}}),Object.defineProperty(r,"NodeXHR",{enumerable:!0,get:function(){return h.NodeXHR}}),Object.defineProperty(r,"XHR",{enumerable:!0,get:function(){return h.XHR}}),Object.defineProperty(r,"NodeWebSocket",{enumerable:!0,get:function(){return h.NodeWebSocket}}),Object.defineProperty(r,"WebSocket",{enumerable:!0,get:function(){return h.WebSocket}}),Object.defineProperty(r,"WebTransport",{enumerable:!0,get:function(){return h.WebTransport}}),e.exports=c})(Wh,Wh.exports);var D1=Wh.exports,j1={exports:{}};(function(e,r){(function(t){e.exports=t()})(function(){var t=function(f,d,p){for(var y=p,g=0,b=f.length;g<b;g++)y=d(y,f[g],g,f);return y},n=function(f,d){return t(f,function(p,y,g,b){return d(y,g,b)?p.concat(y):p},[])},i=function(f,d){return t(f,function(p,y,g,b){return p.concat(d(y,g,b))},[])},a=function(f,d){return t(f,function(p,y,g,b){return p===!0||y===d},!1)},s=!{toString:null}.propertyIsEnumerable("toString"),o=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],u=function(f){var d=[],p;for(p in f)Object.prototype.hasOwnProperty.call(f,p)&&d.push(p);if(!s)return d;for(var y=0,g=o.length;y<g;y++)Object.prototype.hasOwnProperty.call(f,o[y])&&d.push(o[y]);return d},c=function(f){return Object.prototype.toString.call(f)==="[object Array]"},l=function(f){return f<10?"0"+f:f},h=function(){var f=new Date;return f.getUTCFullYear()+"-"+l(f.getUTCMonth()+1)+"-"+l(f.getUTCDate())+"T"+l(f.getUTCHours())+":"+l(f.getUTCMinutes())+":"+l(f.getUTCSeconds())+"."+(f.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"},v={map:i,reduce:t,filter:n,includes:a,keys:u,isArray:c,isoDate:h},m={};m.intRange=function(f,d){return f===void 0&&(f=1),d===void 0&&(d=1/0),function(p){return typeof p=="number"&&parseInt(""+p,10)===p&&p>=f&&p<=d}},m.stringWithLength=function(f){return typeof f=="string"&&!!f.length};var _={},C=v.filter,I=v.reduce,$=v.keys,x=v.isArray,N=v.includes,q=m.intRange,X=m.stringWithLength;_.schema={apiKey:{defaultValue:function(){return null},message:"is required",validate:X},appVersion:{defaultValue:function(){return null},message:"should be a string",validate:function(f){return f===null||X(f)}},appType:{defaultValue:function(){return null},message:"should be a string",validate:function(f){return f===null||X(f)}},autoNotify:{defaultValue:function(){return!0},message:"should be true|false",validate:function(f){return f===!0||f===!1}},beforeSend:{defaultValue:function(){return[]},message:"should be a function or array of functions",validate:function(f){return typeof f=="function"||x(f)&&C(f,function(d){return typeof d=="function"}).length===f.length}},endpoints:{defaultValue:function(){return{notify:"https://notify.bugsnag.com",sessions:"https://sessions.bugsnag.com"}},message:"should be an object containing endpoint URLs { notify, sessions }. sessions is optional if autoCaptureSessions=false",validate:function(f,d){return f&&typeof f=="object"&&X(f.notify)&&(d.autoCaptureSessions===!1||X(f.sessions))&&C($(f),function(p){return!N(["notify","sessions"],p)}).length===0}},autoCaptureSessions:{defaultValue:function(f,d){return d.endpoints===void 0||!!d.endpoints&&!!d.endpoints.sessions},message:"should be true|false",validate:function(f){return f===!0||f===!1}},notifyReleaseStages:{defaultValue:function(){return null},message:"should be an array of strings",validate:function(f){return f===null||x(f)&&C(f,function(d){return typeof d=="string"}).length===f.length}},releaseStage:{defaultValue:function(){return"production"},message:"should be a string",validate:function(f){return typeof f=="string"&&f.length}},maxBreadcrumbs:{defaultValue:function(){return 20},message:"should be a number ≤40",validate:function(f){return q(0,40)(f)}},autoBreadcrumbs:{defaultValue:function(){return!0},message:"should be true|false",validate:function(f){return typeof f=="boolean"}},user:{defaultValue:function(){return null},message:"(object) user should be an object",validate:function(f){return typeof f=="object"}},metaData:{defaultValue:function(){return null},message:"should be an object",validate:function(f){return typeof f=="object"}},logger:{defaultValue:function(){},message:"should be null or an object with methods { debug, info, warn, error }",validate:function(f){return!f||f&&I(["debug","info","warn","error"],function(d,p){return d&&typeof f[p]=="function"},!0)}},filters:{defaultValue:function(){return["password"]},message:"should be an array of strings|regexes",validate:function(f){return x(f)&&f.length===C(f,function(d){return typeof d=="string"||d&&typeof d.test=="function"}).length}}},_.mergeDefaults=function(f,d){if(!f||!d)throw new Error("opts and schema objects are required");return I($(d),function(p,y){return p[y]=f[y]!==void 0?f[y]:d[y].defaultValue(f[y],f),p},{})},_.validate=function(f,d){if(!f||!d)throw new Error("opts and schema objects are required");var p=I($(d),function(y,g){return d[g].validate(f[g],f)?y:y.concat({key:g,message:d[g].message,value:f[g]})},[]);return{valid:!p.length,errors:p}};function J(){return J=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},J.apply(this,arguments)}var G=_.schema,L=v.map,te=m.stringWithLength,se={releaseStage:{defaultValue:function(){return/^localhost(:\d+)?$/.test(window.location.host)?"development":"production"},message:"should be set",validate:te},logger:J({},G.logger,{defaultValue:function(){return typeof console<"u"&&typeof console.debug=="function"?ne():void 0}})},ne=function(){var f={},d=console.log;return L(["debug","info","warn","error"],function(p){var y=console[p];f[p]=typeof y=="function"?y.bind(console,"[bugsnag]"):d.bind(console,"[bugsnag]")}),f},ge=v.isoDate,Y=function(){function f(p,y,g,b){p===void 0&&(p="[anonymous]"),y===void 0&&(y={}),g===void 0&&(g="manual"),b===void 0&&(b=ge()),this.type=g,this.name=p,this.metaData=y,this.timestamp=b}var d=f.prototype;return d.toJSON=function(){return{type:this.type,name:this.name,timestamp:this.timestamp,metaData:this.metaData}},f}(),Ue=Y,He=function(f,d,p){var y=f.length,g=0,b=function(){if(g>=y)return p(null,!1);d(f[g],function(w,S){if(w)return p(w,!1);if(S===!0)return p(null,!0);g++,b()})};b()},Rt=function(f){return f.app&&typeof f.app.releaseStage=="string"?f.app.releaseStage:f.config.releaseStage},ft=Pe;function Pe(f){switch(Object.prototype.toString.call(f)){case"[object Error]":return!0;case"[object Exception]":return!0;case"[object DOMException]":return!0;default:return f instanceof Error}}var he=ft,pe=function(f,d){return function(p,y){if(typeof p!="function")return y(null,!1);try{if(p.length!==2){var g=p(f);return g&&typeof g.then=="function"?g.then(function(b){return setTimeout(function(){return y(null,M(f,b))},0)},function(b){setTimeout(function(){return d(b),y(null,!1)})}):y(null,M(f,g))}p(f,function(b,w){if(b)return d(b),y(null,!1);y(null,M(f,w))})}catch(b){d(b),y(null,!1)}}},M=function(f,d){return f.isIgnored()||d===!1},Oe={};(function(f,d){typeof Oe=="object"?Oe=d():f.StackFrame=d()})(this,function(){function f(W){return!isNaN(parseFloat(W))&&isFinite(W)}function d(W){return W.charAt(0).toUpperCase()+W.substring(1)}function p(W){return function(){return this[W]}}var y=["isConstructor","isEval","isNative","isToplevel"],g=["columnNumber","lineNumber"],b=["fileName","functionName","source"],w=["args"],S=y.concat(g,b,w);function T(W){if(W instanceof Object)for(var Ie=0;Ie<S.length;Ie++)W.hasOwnProperty(S[Ie])&&W[S[Ie]]!==void 0&&this["set"+d(S[Ie])](W[S[Ie]])}T.prototype={getArgs:function(){return this.args},setArgs:function(W){if(Object.prototype.toString.call(W)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=W},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(W){if(W instanceof T)this.evalOrigin=W;else if(W instanceof Object)this.evalOrigin=new T(W);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var W=this.getFunctionName()||"{anonymous}",Ie="("+(this.getArgs()||[]).join(",")+")",ze=this.getFileName()?"@"+this.getFileName():"",je=f(this.getLineNumber())?":"+this.getLineNumber():"",qe=f(this.getColumnNumber())?":"+this.getColumnNumber():"";return W+Ie+ze+je+qe}};for(var F=0;F<y.length;F++)T.prototype["get"+d(y[F])]=p(y[F]),T.prototype["set"+d(y[F])]=function(W){return function(Ie){this[W]=!!Ie}}(y[F]);for(var j=0;j<g.length;j++)T.prototype["get"+d(g[j])]=p(g[j]),T.prototype["set"+d(g[j])]=function(W){return function(Ie){if(!f(Ie))throw new TypeError(W+" must be a Number");this[W]=Number(Ie)}}(g[j]);for(var V=0;V<b.length;V++)T.prototype["get"+d(b[V])]=p(b[V]),T.prototype["set"+d(b[V])]=function(W){return function(Ie){this[W]=String(Ie)}}(b[V]);return T});var Je={};(function(f,d){typeof Je=="object"?Je=d(Oe):f.ErrorStackParser=d(f.StackFrame)})(this,function(d){var p=/(^|@)\S+\:\d+/,y=/^\s*at .*(\S+\:\d+|\(native\))/m,g=/^(eval@)?(\[native code\])?$/;return{parse:function(w){if(typeof w.stacktrace<"u"||typeof w["opera#sourceloc"]<"u")return this.parseOpera(w);if(w.stack&&w.stack.match(y))return this.parseV8OrIE(w);if(w.stack)return this.parseFFOrSafari(w);throw new Error("Cannot parse given Error object")},extractLocation:function(w){if(w.indexOf(":")===-1)return[w];var S=/(.+?)(?:\:(\d+))?(?:\:(\d+))?$/,T=S.exec(w.replace(/[\(\)]/g,""));return[T[1],T[2]||void 0,T[3]||void 0]},parseV8OrIE:function(w){var S=w.stack.split(`
464
464
  `).filter(function(T){return!!T.match(y)},this);return S.map(function(T){T.indexOf("(eval ")>-1&&(T=T.replace(/eval code/g,"eval").replace(/(\(eval at [^\()]*)|(\)\,.*$)/g,""));var F=T.replace(/^\s+/,"").replace(/\(eval code/g,"("),j=F.match(/ (\((.+):(\d+):(\d+)\)$)/);F=j?F.replace(j[0],""):F;var V=F.split(/\s+/).slice(1),W=this.extractLocation(j?j[1]:V.pop()),Ie=V.join(" ")||void 0,ze=["eval","<anonymous>"].indexOf(W[0])>-1?void 0:W[0];return new d({functionName:Ie,fileName:ze,lineNumber:W[1],columnNumber:W[2],source:T})},this)},parseFFOrSafari:function(w){var S=w.stack.split(`
465
465
  `).filter(function(T){return!T.match(g)},this);return S.map(function(T){if(T.indexOf(" > eval")>-1&&(T=T.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g,":$1")),T.indexOf("@")===-1&&T.indexOf(":")===-1)return new d({functionName:T});var F=/((.*".+"[^@]*)?[^@]*)(?:@)/,j=T.match(F),V=j&&j[1]?j[1]:void 0,W=this.extractLocation(T.replace(F,""));return new d({functionName:V,fileName:W[0],lineNumber:W[1],columnNumber:W[2],source:T})},this)},parseOpera:function(w){return!w.stacktrace||w.message.indexOf(`
466
466
  `)>-1&&w.message.split(`
@@ -468,14 +468,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
468
468
  `).length?this.parseOpera9(w):w.stack?this.parseOpera11(w):this.parseOpera10(w)},parseOpera9:function(w){for(var S=/Line (\d+).*script (?:in )?(\S+)/i,T=w.message.split(`
469
469
  `),F=[],j=2,V=T.length;j<V;j+=2){var W=S.exec(T[j]);W&&F.push(new d({fileName:W[2],lineNumber:W[1],source:T[j]}))}return F},parseOpera10:function(w){for(var S=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,T=w.stacktrace.split(`
470
470
  `),F=[],j=0,V=T.length;j<V;j+=2){var W=S.exec(T[j]);W&&F.push(new d({functionName:W[3]||void 0,fileName:W[2],lineNumber:W[1],source:T[j]}))}return F},parseOpera11:function(w){var S=w.stack.split(`
471
- `).filter(function(T){return!!T.match(p)&&!T.match(/^Error created at/)},this);return S.map(function(T){var F=T.split("@"),j=this.extractLocation(F.pop()),V=F.shift()||"",W=V.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^\)]*\)/g,"")||void 0,Ie;V.match(/\(([^\)]*)\)/)&&(Ie=V.replace(/^[^\(]+\(([^\)]*)\)$/,"$1"));var ze=Ie===void 0||Ie==="[arguments not available]"?void 0:Ie.split(",");return new d({functionName:W,args:ze,fileName:j[0],lineNumber:j[1],columnNumber:j[2],source:T})},this)}}});var De=Je,we=function(f){return!!f&&(!!f.stack||!!f.stacktrace||!!f["opera#sourceloc"])&&typeof(f.stack||f.stacktrace||f["opera#sourceloc"])=="string"&&f.stack!==f.name+": "+f.message},Q="browserjs",$t={};(function(f,d){typeof $t=="object"?$t=d(Oe):f.StackGenerator=d(f.StackFrame)})(this,function(f){return{backtrace:function(p){var y=[],g=10;typeof p=="object"&&typeof p.maxStackSize=="number"&&(g=p.maxStackSize);for(var b=arguments.callee;b&&y.length<g&&b.arguments;){for(var w=new Array(b.arguments.length),S=0;S<w.length;++S)w[S]=b.arguments[S];/function(?:\s+([\w$]+))+\s*\(/.test(b.toString())?y.push(new f({functionName:RegExp.$1||void 0,args:w})):y.push(new f({args:w}));try{b=b.caller}catch{break}}return y}}});function _e(){return _e=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},_e.apply(this,arguments)}var le=v.reduce,St=v.filter,Le=function(){function f(p,y,g,b,w){g===void 0&&(g=[]),b===void 0&&(b=ke()),this.__isBugsnagReport=!0,this._ignored=!1,this._handledState=b,this.app=void 0,this.apiKey=void 0,this.breadcrumbs=[],this.context=void 0,this.device=void 0,this.errorClass=ot(p,"[no error class]"),this.errorMessage=ot(y,"[no error message]"),this.groupingHash=void 0,this.metaData={},this.request=void 0,this.severity=this._handledState.severity,this.stacktrace=le(g,function(S,T){var F=Gt(T);try{return JSON.stringify(F)==="{}"?S:S.concat(F)}catch{return S}},[]),this.user=void 0,this.session=void 0,this.originalError=w}var d=f.prototype;return d.ignore=function(){this._ignored=!0},d.isIgnored=function(){return this._ignored},d.updateMetaData=function(y){var g;if(!y)return this;var b;return(arguments.length<=1?void 0:arguments[1])===null?this.removeMetaData(y):(arguments.length<=2?void 0:arguments[2])===null?this.removeMetaData(y,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2]):(typeof(arguments.length<=1?void 0:arguments[1])=="object"&&(b=arguments.length<=1?void 0:arguments[1]),typeof(arguments.length<=1?void 0:arguments[1])=="string"&&(b=(g={},g[arguments.length<=1?void 0:arguments[1]]=arguments.length<=2?void 0:arguments[2],g)),b?(this.metaData[y]||(this.metaData[y]={}),this.metaData[y]=_e({},this.metaData[y],b),this):this)},d.removeMetaData=function(y,g){return typeof y!="string"?this:g?this.metaData[y]?(delete this.metaData[y][g],this):this:(delete this.metaData[y],this)},d.toJSON=function(){return{payloadVersion:"4",exceptions:[{errorClass:this.errorClass,message:this.errorMessage,stacktrace:this.stacktrace,type:Q}],severity:this.severity,unhandled:this._handledState.unhandled,severityReason:this._handledState.severityReason,app:this.app,device:this.device,breadcrumbs:this.breadcrumbs,context:this.context,user:this.user,metaData:this.metaData,groupingHash:this.groupingHash,request:this.request,session:this.session}},f}(),Gt=function(f){var d={file:f.fileName,method:pt(f.functionName),lineNumber:f.lineNumber,columnNumber:f.columnNumber,code:void 0,inProject:void 0};return d.lineNumber>-1&&!d.file&&!d.method&&(d.file="global code"),d},pt=function(f){return/^global code$/i.test(f)?"global code":f},ke=function(){return{unhandled:!1,severity:"warning",severityReason:{type:"handledException"}}},ot=function(f,d){return typeof f=="string"&&f?f:d};Le.getStacktrace=function(f,d,p){if(d===void 0&&(d=0),p===void 0&&(p=0),we(f))return De.parse(f).slice(d);try{throw f}catch(y){if(we(y))return De.parse(f).slice(1+p);try{return St($t.backtrace(),function(g){return(g.functionName||"").indexOf("StackGenerator$$")===-1}).slice(1+p)}catch{return[]}}},Le.ensureReport=function(f,d,p){if(d===void 0&&(d=0),p===void 0&&(p=0),f.__isBugsnagReport)return f;try{var y=Le.getStacktrace(f,d,1+p);return new Le(f.name,f.message,y,void 0,f)}catch{return new Le(f.name,f.message,[],void 0,f)}};var bt=Le,$e=function(d,p){var y="000000000"+d;return y.substr(y.length-p)},Kt=typeof window=="object"?window:self,dt=0;for(var qt in Kt)Object.hasOwnProperty.call(Kt,qt)&&dt++;var rr=navigator.mimeTypes?navigator.mimeTypes.length:0,Fe=$e((rr+navigator.userAgent.length).toString(36)+dt.toString(36),4),Ar=function(){return Fe},Rr=0,Ct=4,Pt=36,yt=Math.pow(Pt,Ct);function it(){return $e((Math.random()*yt<<0).toString(Pt),Ct)}function Mt(){return Rr=Rr<yt?Rr:0,Rr++,Rr-1}function It(){var f="c",d=new Date().getTime().toString(Pt),p=$e(Mt().toString(Pt),Ct),y=Ar(),g=it()+it();return f+d+p+y+g}It.fingerprint=Ar;var sr=It,Nr=v.isoDate,tn=function(){function f(){this.id=sr(),this.startedAt=Nr(),this._handled=0,this._unhandled=0}var d=f.prototype;return d.toJSON=function(){return{id:this.id,startedAt:this.startedAt,events:{handled:this._handled,unhandled:this._unhandled}}},d.trackError=function(y){this[y._handledState.unhandled?"_unhandled":"_handled"]+=1},f}(),rn=tn;function Qt(){return Qt=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},Qt.apply(this,arguments)}var lr=v.map,ve=v.includes,ye=v.isArray,ae="Usage error.",de="Bugsnag usage error.",oe=function(){function f(p){if(!p||!p.name||!p.version||!p.url)throw new Error("`notifier` argument is required");this.notifier=p,this._configured=!1,this._opts={},this.config={},this._delivery={sendSession:function(){},sendReport:function(){}},this._logger={debug:function(){},info:function(){},warn:function(){},error:function(){}},this._plugins={},this._session=null,this.breadcrumbs=[],this.app={},this.context=void 0,this.device=void 0,this.metaData=void 0,this.request=void 0,this.user={},this.BugsnagClient=f,this.BugsnagReport=bt,this.BugsnagBreadcrumb=Ue,this.BugsnagSession=rn;var y=this,g=this.notify;this.notify=function(){return g.apply(y,arguments)}}var d=f.prototype;return d.setOptions=function(y){this._opts=Qt({},this._opts,y)},d.configure=function(y){y===void 0&&(y=_.schema);var g=_.mergeDefaults(this._opts,y),b=_.validate(g,y);if(!b.valid)throw new Error(Z(b.errors));return typeof g.beforeSend=="function"&&(g.beforeSend=[g.beforeSend]),g.appVersion&&(this.app.version=g.appVersion),g.appType&&(this.app.type=g.appType),g.metaData&&(this.metaData=g.metaData),g.user&&(this.user=g.user),g.logger&&this.logger(g.logger),this.config=Qt({},this.config,g),this._configured=!0,this},d.use=function(y){if(!this._configured)throw new Error("client not configured");y.configSchema&&this.configure(y.configSchema);for(var g=arguments.length,b=new Array(g>1?g-1:0),w=1;w<g;w++)b[w-1]=arguments[w];var S=y.init.apply(y,[this].concat(b));return y.name&&(this._plugins["~"+y.name+"~"]=S),this},d.getPlugin=function(y){return this._plugins["~"+y+"~"]},d.delivery=function(y){return this._delivery=y(this),this},d.logger=function(y,g){return this._logger=y,this},d.sessionDelegate=function(y){return this._sessionDelegate=y,this},d.startSession=function(){return this._sessionDelegate?this._sessionDelegate.startSession(this):(this._logger.warn("No session implementation is installed"),this)},d.leaveBreadcrumb=function(y,g,b,w){if(!this._configured)throw new Error("client not configured");if(y=y||void 0,b=typeof b=="string"?b:void 0,w=typeof w=="string"?w:void 0,g=typeof g=="object"&&g!==null?g:void 0,!(typeof y!="string"&&!g)){var S=new Ue(y,g,b,w);return this.breadcrumbs.push(S),this.breadcrumbs.length>this.config.maxBreadcrumbs&&(this.breadcrumbs=this.breadcrumbs.slice(this.breadcrumbs.length-this.config.maxBreadcrumbs)),this}},d.notify=function(y,g,b){var w=this;if(g===void 0&&(g={}),b===void 0&&(b=function(){}),!this._configured)throw new Error("client not configured");var S=Rt(this),T=me(y,g,this._logger),F=T.err,j=T.errorFramesToSkip,V=T._opts;V&&(g=V),(typeof g!="object"||g===null)&&(g={});var W=bt.ensureReport(F,j,2);if(W.app=Qt({},{releaseStage:S},W.app,this.app),W.context=W.context||g.context||this.context||void 0,W.device=Qt({},W.device,this.device,g.device),W.request=Qt({},W.request,this.request,g.request),W.user=Qt({},W.user,this.user,g.user),W.metaData=Qt({},W.metaData,this.metaData,g.metaData),W.breadcrumbs=this.breadcrumbs.slice(0),this._session&&(this._session.trackError(W),W.session=this._session),g.severity!==void 0&&(W.severity=g.severity,W._handledState.severityReason={type:"userSpecifiedSeverity"}),ye(this.config.notifyReleaseStages)&&!ve(this.config.notifyReleaseStages,S))return this._logger.warn("Report not sent due to releaseStage/notifyReleaseStages configuration"),b(null,W);var Ie=W.severity,ze=[].concat(g.beforeSend).concat(this.config.beforeSend),je=function(qe){w._logger.error("Error occurred in beforeSend callback, continuing anyway…"),w._logger.error(qe)};He(ze,pe(W,je),function(qe,Tt){if(qe&&je(qe),Tt)return w._logger.debug("Report not sent due to beforeSend callback"),b(null,W);w.config.autoBreadcrumbs&&w.leaveBreadcrumb(W.errorClass,{errorClass:W.errorClass,errorMessage:W.errorMessage,severity:W.severity},"error"),Ie!==W.severity&&(W._handledState.severityReason={type:"userCallbackSetSeverity"}),w._delivery.sendReport({apiKey:W.apiKey||w.config.apiKey,notifier:w.notifier,events:[W]},function(mt){return b(mt,W)})})},f}(),me=function(f,d,p){var y=3,g=function(T){var F=ce(T);return p.warn(ae+" "+F),new Error(de+" "+F)},b,w=0,S;switch(typeof f){case"string":typeof d=="string"?(b=g("string/string"),S={metaData:{notifier:{notifyArgs:[f,d]}}}):(b=new Error(String(f)),w=y);break;case"number":case"boolean":b=new Error(String(f));break;case"function":b=g("function");break;case"object":f!==null&&(he(f)||f.__isBugsnagReport)?b=f:f!==null&&Se(f)?(b=new Error(f.message||f.errorMessage),b.name=f.name||f.errorClass,w=y):b=g(f===null?"null":"unsupported object");break;default:b=g("nothing")}return{err:b,errorFramesToSkip:w,_opts:S}},Se=function(f){return(typeof f.name=="string"||typeof f.errorClass=="string")&&(typeof f.message=="string"||typeof f.errorMessage=="string")},Z=function(f){return`Bugsnag configuration error
471
+ `).filter(function(T){return!!T.match(p)&&!T.match(/^Error created at/)},this);return S.map(function(T){var F=T.split("@"),j=this.extractLocation(F.pop()),V=F.shift()||"",W=V.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^\)]*\)/g,"")||void 0,Ie;V.match(/\(([^\)]*)\)/)&&(Ie=V.replace(/^[^\(]+\(([^\)]*)\)$/,"$1"));var ze=Ie===void 0||Ie==="[arguments not available]"?void 0:Ie.split(",");return new d({functionName:W,args:ze,fileName:j[0],lineNumber:j[1],columnNumber:j[2],source:T})},this)}}});var De=Je,we=function(f){return!!f&&(!!f.stack||!!f.stacktrace||!!f["opera#sourceloc"])&&typeof(f.stack||f.stacktrace||f["opera#sourceloc"])=="string"&&f.stack!==f.name+": "+f.message},Q="browserjs",$t={};(function(f,d){typeof $t=="object"?$t=d(Oe):f.StackGenerator=d(f.StackFrame)})(this,function(f){return{backtrace:function(p){var y=[],g=10;typeof p=="object"&&typeof p.maxStackSize=="number"&&(g=p.maxStackSize);for(var b=arguments.callee;b&&y.length<g&&b.arguments;){for(var w=new Array(b.arguments.length),S=0;S<w.length;++S)w[S]=b.arguments[S];/function(?:\s+([\w$]+))+\s*\(/.test(b.toString())?y.push(new f({functionName:RegExp.$1||void 0,args:w})):y.push(new f({args:w}));try{b=b.caller}catch{break}}return y}}});function _e(){return _e=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},_e.apply(this,arguments)}var le=v.reduce,St=v.filter,Le=function(){function f(p,y,g,b,w){g===void 0&&(g=[]),b===void 0&&(b=ke()),this.__isBugsnagReport=!0,this._ignored=!1,this._handledState=b,this.app=void 0,this.apiKey=void 0,this.breadcrumbs=[],this.context=void 0,this.device=void 0,this.errorClass=ot(p,"[no error class]"),this.errorMessage=ot(y,"[no error message]"),this.groupingHash=void 0,this.metaData={},this.request=void 0,this.severity=this._handledState.severity,this.stacktrace=le(g,function(S,T){var F=Gt(T);try{return JSON.stringify(F)==="{}"?S:S.concat(F)}catch{return S}},[]),this.user=void 0,this.session=void 0,this.originalError=w}var d=f.prototype;return d.ignore=function(){this._ignored=!0},d.isIgnored=function(){return this._ignored},d.updateMetaData=function(y){var g;if(!y)return this;var b;return(arguments.length<=1?void 0:arguments[1])===null?this.removeMetaData(y):(arguments.length<=2?void 0:arguments[2])===null?this.removeMetaData(y,arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2]):(typeof(arguments.length<=1?void 0:arguments[1])=="object"&&(b=arguments.length<=1?void 0:arguments[1]),typeof(arguments.length<=1?void 0:arguments[1])=="string"&&(b=(g={},g[arguments.length<=1?void 0:arguments[1]]=arguments.length<=2?void 0:arguments[2],g)),b?(this.metaData[y]||(this.metaData[y]={}),this.metaData[y]=_e({},this.metaData[y],b),this):this)},d.removeMetaData=function(y,g){return typeof y!="string"?this:g?this.metaData[y]?(delete this.metaData[y][g],this):this:(delete this.metaData[y],this)},d.toJSON=function(){return{payloadVersion:"4",exceptions:[{errorClass:this.errorClass,message:this.errorMessage,stacktrace:this.stacktrace,type:Q}],severity:this.severity,unhandled:this._handledState.unhandled,severityReason:this._handledState.severityReason,app:this.app,device:this.device,breadcrumbs:this.breadcrumbs,context:this.context,user:this.user,metaData:this.metaData,groupingHash:this.groupingHash,request:this.request,session:this.session}},f}(),Gt=function(f){var d={file:f.fileName,method:pt(f.functionName),lineNumber:f.lineNumber,columnNumber:f.columnNumber,code:void 0,inProject:void 0};return d.lineNumber>-1&&!d.file&&!d.method&&(d.file="global code"),d},pt=function(f){return/^global code$/i.test(f)?"global code":f},ke=function(){return{unhandled:!1,severity:"warning",severityReason:{type:"handledException"}}},ot=function(f,d){return typeof f=="string"&&f?f:d};Le.getStacktrace=function(f,d,p){if(d===void 0&&(d=0),p===void 0&&(p=0),we(f))return De.parse(f).slice(d);try{throw f}catch(y){if(we(y))return De.parse(f).slice(1+p);try{return St($t.backtrace(),function(g){return(g.functionName||"").indexOf("StackGenerator$$")===-1}).slice(1+p)}catch{return[]}}},Le.ensureReport=function(f,d,p){if(d===void 0&&(d=0),p===void 0&&(p=0),f.__isBugsnagReport)return f;try{var y=Le.getStacktrace(f,d,1+p);return new Le(f.name,f.message,y,void 0,f)}catch{return new Le(f.name,f.message,[],void 0,f)}};var bt=Le,$e=function(d,p){var y="000000000"+d;return y.substr(y.length-p)},Kt=typeof window=="object"?window:self,dt=0;for(var qt in Kt)Object.hasOwnProperty.call(Kt,qt)&&dt++;var rr=navigator.mimeTypes?navigator.mimeTypes.length:0,Fe=$e((rr+navigator.userAgent.length).toString(36)+dt.toString(36),4),Ar=function(){return Fe},$r=0,Ct=4,Pt=36,yt=Math.pow(Pt,Ct);function it(){return $e((Math.random()*yt<<0).toString(Pt),Ct)}function Mt(){return $r=$r<yt?$r:0,$r++,$r-1}function It(){var f="c",d=new Date().getTime().toString(Pt),p=$e(Mt().toString(Pt),Ct),y=Ar(),g=it()+it();return f+d+p+y+g}It.fingerprint=Ar;var sr=It,Nr=v.isoDate,tn=function(){function f(){this.id=sr(),this.startedAt=Nr(),this._handled=0,this._unhandled=0}var d=f.prototype;return d.toJSON=function(){return{id:this.id,startedAt:this.startedAt,events:{handled:this._handled,unhandled:this._unhandled}}},d.trackError=function(y){this[y._handledState.unhandled?"_unhandled":"_handled"]+=1},f}(),rn=tn;function Qt(){return Qt=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},Qt.apply(this,arguments)}var lr=v.map,ve=v.includes,ye=v.isArray,ae="Usage error.",de="Bugsnag usage error.",oe=function(){function f(p){if(!p||!p.name||!p.version||!p.url)throw new Error("`notifier` argument is required");this.notifier=p,this._configured=!1,this._opts={},this.config={},this._delivery={sendSession:function(){},sendReport:function(){}},this._logger={debug:function(){},info:function(){},warn:function(){},error:function(){}},this._plugins={},this._session=null,this.breadcrumbs=[],this.app={},this.context=void 0,this.device=void 0,this.metaData=void 0,this.request=void 0,this.user={},this.BugsnagClient=f,this.BugsnagReport=bt,this.BugsnagBreadcrumb=Ue,this.BugsnagSession=rn;var y=this,g=this.notify;this.notify=function(){return g.apply(y,arguments)}}var d=f.prototype;return d.setOptions=function(y){this._opts=Qt({},this._opts,y)},d.configure=function(y){y===void 0&&(y=_.schema);var g=_.mergeDefaults(this._opts,y),b=_.validate(g,y);if(!b.valid)throw new Error(Z(b.errors));return typeof g.beforeSend=="function"&&(g.beforeSend=[g.beforeSend]),g.appVersion&&(this.app.version=g.appVersion),g.appType&&(this.app.type=g.appType),g.metaData&&(this.metaData=g.metaData),g.user&&(this.user=g.user),g.logger&&this.logger(g.logger),this.config=Qt({},this.config,g),this._configured=!0,this},d.use=function(y){if(!this._configured)throw new Error("client not configured");y.configSchema&&this.configure(y.configSchema);for(var g=arguments.length,b=new Array(g>1?g-1:0),w=1;w<g;w++)b[w-1]=arguments[w];var S=y.init.apply(y,[this].concat(b));return y.name&&(this._plugins["~"+y.name+"~"]=S),this},d.getPlugin=function(y){return this._plugins["~"+y+"~"]},d.delivery=function(y){return this._delivery=y(this),this},d.logger=function(y,g){return this._logger=y,this},d.sessionDelegate=function(y){return this._sessionDelegate=y,this},d.startSession=function(){return this._sessionDelegate?this._sessionDelegate.startSession(this):(this._logger.warn("No session implementation is installed"),this)},d.leaveBreadcrumb=function(y,g,b,w){if(!this._configured)throw new Error("client not configured");if(y=y||void 0,b=typeof b=="string"?b:void 0,w=typeof w=="string"?w:void 0,g=typeof g=="object"&&g!==null?g:void 0,!(typeof y!="string"&&!g)){var S=new Ue(y,g,b,w);return this.breadcrumbs.push(S),this.breadcrumbs.length>this.config.maxBreadcrumbs&&(this.breadcrumbs=this.breadcrumbs.slice(this.breadcrumbs.length-this.config.maxBreadcrumbs)),this}},d.notify=function(y,g,b){var w=this;if(g===void 0&&(g={}),b===void 0&&(b=function(){}),!this._configured)throw new Error("client not configured");var S=Rt(this),T=me(y,g,this._logger),F=T.err,j=T.errorFramesToSkip,V=T._opts;V&&(g=V),(typeof g!="object"||g===null)&&(g={});var W=bt.ensureReport(F,j,2);if(W.app=Qt({},{releaseStage:S},W.app,this.app),W.context=W.context||g.context||this.context||void 0,W.device=Qt({},W.device,this.device,g.device),W.request=Qt({},W.request,this.request,g.request),W.user=Qt({},W.user,this.user,g.user),W.metaData=Qt({},W.metaData,this.metaData,g.metaData),W.breadcrumbs=this.breadcrumbs.slice(0),this._session&&(this._session.trackError(W),W.session=this._session),g.severity!==void 0&&(W.severity=g.severity,W._handledState.severityReason={type:"userSpecifiedSeverity"}),ye(this.config.notifyReleaseStages)&&!ve(this.config.notifyReleaseStages,S))return this._logger.warn("Report not sent due to releaseStage/notifyReleaseStages configuration"),b(null,W);var Ie=W.severity,ze=[].concat(g.beforeSend).concat(this.config.beforeSend),je=function(qe){w._logger.error("Error occurred in beforeSend callback, continuing anyway…"),w._logger.error(qe)};He(ze,pe(W,je),function(qe,Tt){if(qe&&je(qe),Tt)return w._logger.debug("Report not sent due to beforeSend callback"),b(null,W);w.config.autoBreadcrumbs&&w.leaveBreadcrumb(W.errorClass,{errorClass:W.errorClass,errorMessage:W.errorMessage,severity:W.severity},"error"),Ie!==W.severity&&(W._handledState.severityReason={type:"userCallbackSetSeverity"}),w._delivery.sendReport({apiKey:W.apiKey||w.config.apiKey,notifier:w.notifier,events:[W]},function(mt){return b(mt,W)})})},f}(),me=function(f,d,p){var y=3,g=function(T){var F=ce(T);return p.warn(ae+" "+F),new Error(de+" "+F)},b,w=0,S;switch(typeof f){case"string":typeof d=="string"?(b=g("string/string"),S={metaData:{notifier:{notifyArgs:[f,d]}}}):(b=new Error(String(f)),w=y);break;case"number":case"boolean":b=new Error(String(f));break;case"function":b=g("function");break;case"object":f!==null&&(he(f)||f.__isBugsnagReport)?b=f:f!==null&&Se(f)?(b=new Error(f.message||f.errorMessage),b.name=f.name||f.errorClass,w=y):b=g(f===null?"null":"unsupported object");break;default:b=g("nothing")}return{err:b,errorFramesToSkip:w,_opts:S}},Se=function(f){return(typeof f.name=="string"||typeof f.errorClass=="string")&&(typeof f.message=="string"||typeof f.errorMessage=="string")},Z=function(f){return`Bugsnag configuration error
472
472
  `+lr(f,function(d){return'"'+d.key+'" '+d.message+`
473
473
  got `+H(d.value)}).join(`
474
474
 
475
475
  `)},ce=function(f){return"notify() expected error/opts parameters, got "+f},H=function(f){return typeof f=="object"?JSON.stringify(f):String(f)},ie=oe,K=function(f,d,p,y){var g=y&&y.filterKeys?y.filterKeys:[],b=y&&y.filterPaths?y.filterPaths:[];return JSON.stringify(yr(f,g,b),d,p)},xe=20,Ce=25e3,We=8,Be="...";function Ve(f){return f instanceof Error||/^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(f))}function Ye(f){return"[Throws: "+(f?f.message:"?")+"]"}function Qe(f,d){for(var p=0,y=f.length;p<y;p++)if(f[p]===d)return!0;return!1}function Ke(f,d){for(var p=0,y=f.length;p<y;p++)if(d.indexOf(f[p])===0)return!0;return!1}function Xe(f,d){for(var p=0,y=f.length;p<y;p++)if(typeof f[p]=="string"&&f[p]===d||f[p]&&typeof f[p].test=="function"&&f[p].test(d))return!0;return!1}function Ze(f){return Object.prototype.toString.call(f)==="[object Array]"}function at(f,d){try{return f[d]}catch(p){return Ye(p)}}function yr(f,d,p){var y=[],g=0;function b(w,S){function T(){return S.length>We&&g>Ce}if(g++,S.length>xe||T())return Be;if(w===null||typeof w!="object")return w;if(Qe(y,w))return"[Circular]";if(y.push(w),typeof w.toJSON=="function")try{g--;var F=b(w.toJSON(),S);return y.pop(),F}catch(Tt){return Ye(Tt)}var j=Ve(w);if(j){g--;var V=b({name:w.name,message:w.message},S);return y.pop(),V}if(Ze(w)){for(var W=[],Ie=0,ze=w.length;Ie<ze;Ie++){if(T()){W.push(Be);break}W.push(b(w[Ie],S.concat("[]")))}return y.pop(),W}var je={};try{for(var qe in w)if(Object.prototype.hasOwnProperty.call(w,qe)){if(Ke(p,S.join("."))&&Xe(d,qe)){je[qe]="[Filtered]";continue}if(T()){je[qe]=Be;break}je[qe]=b(at(w,qe),S.concat(qe))}}catch{}return y.pop(),je}return b(f,[])}var or={},st=["events.[].app","events.[].metaData","events.[].user","events.[].breadcrumbs","events.[].request","events.[].device"],Wr=["device","app","user"];or.report=function(f,d){var p=K(f,null,null,{filterPaths:st,filterKeys:d});if(p.length>1e6&&(delete f.events[0].metaData,f.events[0].metaData={notifier:`WARNING!
476
476
  Serialized payload was `+p.length/1e6+`MB (limit = 1MB)
477
477
  metaData was removed`},p=K(f,null,null,{filterPaths:st,filterKeys:d}),p.length>1e6))throw new Error("payload exceeded 1MB limit");return p},or.session=function(f,d){var p=K(f,null,null,{filterPaths:Wr,filterKeys:d});if(p.length>1e6)throw new Error("payload exceeded 1MB limit");return p};var mn={},bi=v.isoDate;mn=function(f,d){return d===void 0&&(d=window),{sendReport:function(p,y){y===void 0&&(y=function(){});var g=Vr(f.config,"notify","4",d),b=new d.XDomainRequest;b.onload=function(){y(null)},b.open("POST",g),setTimeout(function(){try{b.send(or.report(p,f.config.filters))}catch(w){f._logger.error(w),y(w)}},0)},sendSession:function(p,y){y===void 0&&(y=function(){});var g=Vr(f.config,"sessions","1",d),b=new d.XDomainRequest;b.onload=function(){y(null)},b.open("POST",g),setTimeout(function(){try{b.send(or.session(p,f.config.filters))}catch(w){f._logger.error(w),y(w)}},0)}}};var Vr=function(f,d,p,y){return Xn(f.endpoints[d],y.location.protocol)+"?apiKey="+encodeURIComponent(f.apiKey)+"&payloadVersion="+p+"&sentAt="+encodeURIComponent(bi())},Xn=mn._matchPageProtocol=function(f,d){return d==="http:"?f.replace(/^https:/,"http:"):f},Gr=v.isoDate,gn=function(f,d){return d===void 0&&(d=window),{sendReport:function(p,y){y===void 0&&(y=function(){});try{var g=f.config.endpoints.notify,b=new d.XMLHttpRequest;b.onreadystatechange=function(){b.readyState===d.XMLHttpRequest.DONE&&y(null)},b.open("POST",g),b.setRequestHeader("Content-Type","application/json"),b.setRequestHeader("Bugsnag-Api-Key",p.apiKey||f.config.apiKey),b.setRequestHeader("Bugsnag-Payload-Version","4"),b.setRequestHeader("Bugsnag-Sent-At",Gr()),b.send(or.report(p,f.config.filters))}catch(w){f._logger.error(w)}},sendSession:function(p,y){y===void 0&&(y=function(){});try{var g=f.config.endpoints.sessions,b=new d.XMLHttpRequest;b.onreadystatechange=function(){b.readyState===d.XMLHttpRequest.DONE&&y(null)},b.open("POST",g),b.setRequestHeader("Content-Type","application/json"),b.setRequestHeader("Bugsnag-Api-Key",f.config.apiKey),b.setRequestHeader("Bugsnag-Payload-Version","1"),b.setRequestHeader("Bugsnag-Sent-At",Gr()),b.send(or.session(p,f.config.filters))}catch(w){f._logger.error(w)}}}},_i={init:function(f,d){d===void 0&&(d=window),f.config.beforeSend.unshift(function(p){p.context||(p.context=d.location.pathname)})}};function ur(){return ur=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},ur.apply(this,arguments)}var xn=v.isoDate,Zi={init:function(f,d){d===void 0&&(d=navigator);var p={locale:d.browserLanguage||d.systemLanguage||d.userLanguage||d.language,userAgent:d.userAgent};f.device=ur({},p,f.device),f.config.beforeSend.unshift(function(y){y.device=ur({},y.device,{time:xn()})})}};function nn(){return nn=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},nn.apply(this,arguments)}var ea={init:function(f,d){d===void 0&&(d=window),f.config.beforeSend.unshift(function(p){p.request&&p.request.url||(p.request=nn({},p.request,{url:d.location.href}))})}};function wi(){return wi=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},wi.apply(this,arguments)}var Hr=v.isArray,ta=v.includes,Aa={init:function(f){return f.sessionDelegate(Ma)}},Ma={startSession:function(f){var d=f;d._session=new f.BugsnagSession;var p=Rt(d);return Hr(d.config.notifyReleaseStages)&&!ta(d.config.notifyReleaseStages,p)?(d._logger.warn("Session not sent due to releaseStage/notifyReleaseStages configuration"),d):d.config.endpoints.sessions?(d._delivery.sendSession({notifier:d.notifier,device:d.device,app:wi({},{releaseStage:p},d.app),sessions:[{id:d._session.id,startedAt:d._session.startedAt,user:d.user}]}),d):(d._logger.warn("Session not sent due to missing endpoints.sessions configuration"),d)}};function fr(){return fr=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},fr.apply(this,arguments)}var xa={init:function(f){f.config.collectUserIp||f.config.beforeSend.push(function(d){d.user&&typeof d.user.id>"u"&&delete d.user.id,d.user=fr({id:"[NOT COLLECTED]"},d.user),d.request=fr({clientIp:"[NOT COLLECTED]"},d.request)})},configSchema:{collectUserIp:{defaultValue:function(){return!0},message:"should be true|false",validate:function(f){return f===!0||f===!1}}}},Qn={},Yt=v.map,Na=v.reduce,an=v.filter;Qn.init=function(f){var d=/^dev(elopment)?$/.test(f.config.releaseStage),p=f.config.consoleBreadcrumbsEnabled===!1,y=(f.config.autoBreadcrumbs===!1||d)&&f.config.consoleBreadcrumbsEnabled!==!0;p||y||Yt(Si,function(g){var b=console[g];console[g]=function(){for(var w=arguments.length,S=new Array(w),T=0;T<w;T++)S[T]=arguments[T];f.leaveBreadcrumb("Console output",Na(S,function(F,j,V){var W="[Unknown value]";try{W=String(j)}catch{}if(W==="[object Object]")try{W=JSON.stringify(j)}catch{}return F["["+V+"]"]=W,F},{severity:g.indexOf("group")===0?"log":g}),"log"),b.apply(console,S)},console[g]._restore=function(){console[g]=b}})},Qn.configSchema={consoleBreadcrumbsEnabled:{defaultValue:function(){},validate:function(f){return f===!0||f===!1||f===void 0},message:"should be true|false"}};var Si=an(["log","debug","info","warn","error"],function(f){return typeof console<"u"&&typeof console[f]=="function"}),Ci=v.map,La=v.reduce,sn=v.filter,wt=200,ra=5e5,na={init:function(f,d,p){if(d===void 0&&(d=document),p===void 0&&(p=window),!f.config.trackInlineScripts)return;var y=p.location.href,g="",b=!1,w=function(){return d.documentElement.outerHTML};g=w();var S=d.onreadystatechange;d.onreadystatechange=function(){d.readyState==="interactive"&&(g=w(),b=!0);try{S.apply(this,arguments)}catch{}};var T=null,F=function(je){T=je},j=function(){var je=d.currentScript||T;if(!je&&!b){var qe=d.scripts||d.getElementsByTagName("script");je=qe[qe.length-1]}return je},V=function(je){(!b||!g)&&(g=w());var qe=["<!-- DOC START -->"].concat(g.split(`
478
- `)),Tt=je-1,mt=Math.max(Tt-3,0),nt=Math.min(Tt+3,qe.length);return La(qe.slice(mt,nt),function(er,ei,tt){return er[mt+1+tt]=ei.length<=wt?ei:ei.substr(0,wt),er},{})};f.config.beforeSend.unshift(function(je){je.stacktrace=sn(je.stacktrace,function(nt){return!/__trace__$/.test(nt.method)});var qe=je.stacktrace[0];if(!(qe&&qe.file&&qe.file.replace(/#.*$/,"")!==y.replace(/#.*$/,""))){var Tt=j();if(Tt){var mt=Tt.innerHTML;je.updateMetaData("script","content",mt.length<=ra?mt:mt.substr(0,ra))}!qe||!qe.lineNumber||(qe.code=V(qe.lineNumber))}});var W=Ci(["setTimeout","setInterval","setImmediate","requestAnimationFrame"],function(je){return Ti(p,je,function(qe){return ze(qe,function(Tt){return{get:function(){return Tt[0]},replace:function(mt){Tt[0]=mt}}})})}),Ie=W[0];Ci(["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],function(je){!p[je]||!p[je].prototype||!p[je].prototype.hasOwnProperty||!p[je].prototype.hasOwnProperty("addEventListener")||(Ti(p[je].prototype,"addEventListener",function(qe){return ze(qe,Ei)}),Ti(p[je].prototype,"removeEventListener",function(qe){return ze(qe,Ei,!0)}))});function ze(je,qe,Tt){return Tt===void 0&&(Tt=!1),function(){var mt=Array.prototype.slice.call(arguments);try{var nt=qe(mt),er=nt.get();if(Tt&&je.apply(this,mt),typeof er!="function")return je.apply(this,mt);if(er.__trace__)nt.replace(er.__trace__);else{var ei=j();er.__trace__=function(){F(ei),Ie(function(){F(null)},0);var ti=er.apply(this,arguments);return F(null),ti},er.__trace__.__trace__=er.__trace__,nt.replace(er.__trace__)}}catch{}if(je.apply)return je.apply(this,mt);switch(mt.length){case 1:return je(mt[0]);case 2:return je(mt[0],mt[1]);default:return je()}}}},configSchema:{trackInlineScripts:{validate:function(f){return f===!0||f===!1},defaultValue:function(){return!0},message:"should be true|false"}}};function Ti(f,d,p){var y=f[d];if(!y)return y;var g=p(y);return f[d]=g,y}function Ei(f){var d=!!f[1]&&typeof f[1].handleEvent=="function";return{get:function(){return d?f[1].handleEvent:f[1]},replace:function(p){d?f[1].handleEvent=p:f[1]=p}}}var Zn={init:function(f,d){if(d===void 0&&(d=window),"addEventListener"in d){var p=f.config.interactionBreadcrumbsEnabled===!1,y=f.config.autoBreadcrumbs===!1&&f.config.interactionBreadcrumbsEnabled!==!0;p||y||d.addEventListener("click",function(g){var b,w;try{b=Nn(g.target),w=dr(g.target,d)}catch{b="[hidden]",w="[hidden]",f._logger.error("Cross domain error when tracking click event. See docs: https://tinyurl.com/yy3rn63z")}f.leaveBreadcrumb("UI click",{targetText:b,targetSelector:w},"user")},!0)}},configSchema:{interactionBreadcrumbsEnabled:{defaultValue:function(){},validate:function(f){return f===!0||f===!1||f===void 0},message:"should be true|false"}}},Nn=function(f){var d=f.textContent||f.innerText||"";return!d&&(f.type==="submit"||f.type==="button")&&(d=f.value),d=d.replace(/^\s+|\s+$/g,""),ia(d,140)};function dr(f,d){var p=[f.tagName];if(f.id&&p.push("#"+f.id),f.className&&f.className.length&&p.push("."+f.className.split(" ").join(".")),!d.document.querySelectorAll||!Array.prototype.indexOf)return p.join("");try{if(d.document.querySelectorAll(p.join("")).length===1)return p.join("")}catch{return p.join("")}if(f.parentNode.childNodes.length>1){var y=Array.prototype.indexOf.call(f.parentNode.childNodes,f)+1;p.push(":nth-child("+y+")")}return d.document.querySelectorAll(p.join("")).length===1?p.join(""):f.parentNode?dr(f.parentNode,d)+" > "+p.join(""):p.join("")}function ia(f,d){var p="(...)";return f&&f.length<=d?f:f.slice(0,d-p.length)+p}var pr={};pr.init=function(f,d){if(d===void 0&&(d=window),"addEventListener"in d){var p=f.config.navigationBreadcrumbsEnabled===!1,y=f.config.autoBreadcrumbs===!1&&f.config.navigationBreadcrumbsEnabled!==!0;if(!(p||y)){var g=function(b){return function(){return f.leaveBreadcrumb(b,{},"navigation")}};d.addEventListener("pagehide",g("Page hidden"),!0),d.addEventListener("pageshow",g("Page shown"),!0),d.addEventListener("load",g("Page loaded"),!0),d.document.addEventListener("DOMContentLoaded",g("DOMContentLoaded"),!0),d.addEventListener("load",function(){return d.addEventListener("popstate",g("Navigated back"),!0)}),d.addEventListener("hashchange",function(b){var w=b.oldURL?{from:$r(b.oldURL,d),to:$r(b.newURL,d),state:D(d)}:{to:$r(d.location.href,d)};f.leaveBreadcrumb("Hash changed",w,"navigation")},!0),d.history.replaceState&&aa(f,d.history,"replaceState",d),d.history.pushState&&aa(f,d.history,"pushState",d),f.leaveBreadcrumb("Bugsnag loaded",{},"navigation")}}},pr.configSchema={navigationBreadcrumbsEnabled:{defaultValue:function(){},validate:function(f){return f===!0||f===!1||f===void 0},message:"should be true|false"}};var $r=function(f,d){var p=d.document.createElement("A");return p.href=f,""+p.pathname+p.search+p.hash},on=function(f,d,p,y){var g=$r(f.location.href,f);return{title:p,state:d,prevState:D(f),to:y||g,from:g}},aa=function(f,d,p,y){var g=d[p];d[p]=function(b,w,S){f.leaveBreadcrumb("History "+p,on(y,b,w,S),"navigation"),typeof f.refresh=="function"&&f.refresh(),f.config.autoCaptureSessions&&f.startSession(),g.apply(d,[b,w].concat(S!==void 0?S:[]))}},D=function(f){try{return f.history.state}catch{}},B={},R="request",k="BS~~S",E="BS~~U",U="BS~~M",A=v.includes,fe,ue,Te,Ne=function(){return[fe.config.endpoints.notify,fe.config.endpoints.sessions]};B.name="networkBreadcrumbs",B.init=function(f,d,p){d===void 0&&(d=Ne),p===void 0&&(p=window);var y=f.config.networkBreadcrumbsEnabled===!1,g=f.config.autoBreadcrumbs===!1&&f.config.networkBreadcrumbsEnabled!==!0;y||g||(fe=f,ue=p,Te=d,et(),nr())},B.configSchema={networkBreadcrumbsEnabled:{defaultValue:function(){},validate:function(f){return f===!0||f===!1||f===void 0},message:"should be true|false"}};var et=function(){if("addEventListener"in ue.XMLHttpRequest.prototype){var f=ue.XMLHttpRequest.prototype.open;ue.XMLHttpRequest.prototype.open=function(p,y){this[E]=y,this[U]=p,this[k]&&(this.removeEventListener("load",hr),this.removeEventListener("error",Kr)),this.addEventListener("load",hr),this.addEventListener("error",Kr),this[k]=!0,f.apply(this,arguments)}}};function hr(){if(!A(Te(),this[E])){var f={status:this.status,request:this[U]+" "+this[E]};this.status>=400?fe.leaveBreadcrumb("XMLHttpRequest failed",f,R):fe.leaveBreadcrumb("XMLHttpRequest succeeded",f,R)}}function Kr(){A(Te,this[E])||fe.leaveBreadcrumb("XMLHttpRequest error",{request:this[U]+" "+this[E]},R)}var nr=function(){if(!(!("fetch"in ue)||ue.fetch.polyfill)){var f=ue.fetch;ue.fetch=function(){var p=arguments,y=arguments[0],g=arguments[1],b,w=null;return y&&typeof y=="object"?(w=y.url,g&&"method"in g?b=g.method:y&&"method"in y&&(b=y.method)):(w=y,g&&"method"in g&&(b=g.method)),b===void 0&&(b="GET"),new Promise(function(S,T){f.apply(void 0,p).then(function(F){un(F,b,w),S(F)}).catch(function(F){vs(b,w),T(F)})})}}},un=function(f,d,p){var y={status:f.status,request:d+" "+p};f.status>=400?fe.leaveBreadcrumb("fetch() failed",y,R):fe.leaveBreadcrumb("fetch() succeeded",y,R)},vs=function(f,d){fe.leaveBreadcrumb("fetch() error",{request:f+" "+d},R)},mo=m.intRange,z={init:function(f){var d=0;f.config.beforeSend.push(function(p){if(d>=f.config.maxEvents)return p.ignore();d++}),f.refresh=function(){d=0}},configSchema:{maxEvents:{defaultValue:function(){return 10},message:"should be a positive integer ≤100",validate:function(f){return mo(1,100)(f)}}}},re={};function be(){return be=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},be.apply(this,arguments)}var Ge=v.map;re={init:function(f){f.config.beforeSend.push(function(d){d.stacktrace=Ge(d.stacktrace,function(p){return be({},p,{file:Dt(p.file)})})})}};var Dt=re._strip=function(f){return typeof f=="string"?f.replace(/\?.*$/,"").replace(/#.*$/,""):f},ht={init:function(f,d){d===void 0&&(d=window);function p(g,b,w,S,T){if(w===0&&/Script error\.?/.test(g))f._logger.warn("Ignoring cross-domain or eval script error. See docs: https://tinyurl.com/yy3rn63z");else{var F={severity:"error",unhandled:!0,severityReason:{type:"unhandledException"}},j;if(T)T.name&&T.message?j=new f.BugsnagReport(T.name,T.message,jt(f.BugsnagReport.getStacktrace(T),b,w,S),F,T):(j=new f.BugsnagReport("window.onerror",String(T),jt(f.BugsnagReport.getStacktrace(T,1),b,w,S),F,T),j.updateMetaData("window onerror",{error:T}));else if(typeof g=="object"&&g!==null&&(!b||typeof b!="string")&&!w&&!S&&!T){var V=g.type?"Event: "+g.type:"window.onerror",W=g.message||g.detail||"";j=new f.BugsnagReport(V,W,f.BugsnagReport.getStacktrace(new Error,1).slice(1),F,g),j.updateMetaData("window onerror",{event:g,extraParameters:b})}else j=new f.BugsnagReport("window.onerror",String(g),jt(f.BugsnagReport.getStacktrace(T,1),b,w,S),F,g),j.updateMetaData("window onerror",{event:g});f.notify(j)}typeof y=="function"&&y.apply(this,arguments)}var y=d.onerror;d.onerror=p}},jt=function(f,d,p,y){var g=f[0];return g&&(!g.fileName&&typeof d=="string"&&g.setFileName(d),!g.lineNumber&&Xt(p)&&g.setLineNumber(p),g.columnNumber||(Xt(y)?g.setColumnNumber(y):window.event&&Xt(window.event.errorCharacter)&&g.setColumnNumber(window.event.errorCharacter))),f},Xt=function(f){return typeof f=="number"&&String.call(f)!=="NaN"},ir={},rt=v.reduce;ir.init=function(f,d){d===void 0&&(d=window);var p=function(y){var g=y.reason,b=!1;try{y.detail&&y.detail.reason&&(g=y.detail.reason,b=!0)}catch{}var w={severity:"error",unhandled:!0,severityReason:{type:"unhandledPromiseRejection"}},S;if(g&&we(g))S=new f.BugsnagReport(g.name,g.message,De.parse(g),w,g),b&&(S.stacktrace=rt(S.stacktrace,Cr(g),[]));else{var T='Rejection reason was not an Error. See "Promise" tab for more detail.';S=new f.BugsnagReport(g&&g.name?g.name:"UnhandledRejection",g&&g.message?g.message:T,[],w,g),S.updateMetaData("promise","rejection reason",Sr(g))}f.notify(S)};"addEventListener"in d?d.addEventListener("unhandledrejection",p):d.onunhandledrejection=function(y,g){p({detail:{reason:y,promise:g}})}};var Sr=function(f){if(f==null)return"undefined (or null)";if(he(f)){var d;return d={},d[Object.prototype.toString.call(f)]={name:f.name,message:f.message,code:f.code,stack:f.stack},d}else return f},Cr=function(f){return function(d,p){return p.file===f.toString()?d:(p.method&&(p.method=p.method.replace(/^\s+/,"")),d.concat(p))}},Zt={};function Tr(){return Tr=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},Tr.apply(this,arguments)}var ct="Bugsnag JavaScript",yn="6.5.2",O="https://github.com/bugsnag/bugsnag-js",P=Tr({},_.schema,se);return Zt=function(f){typeof f=="string"&&(f={apiKey:f});var d="";f.endpoints&&f.endpoints.notify&&!f.endpoints.sessions&&(d+="notify endpoint is set but sessions endpoint is not. No sessions will be sent.");var p=new ie({name:ct,version:yn,url:O});return p.setOptions(f),p.delivery(window.XDomainRequest?mn:gn),p.configure(P),d&&p._logger.warn(d),p.use(Zi),p.use(_i),p.use(ea),p.use(z),p.use(Aa),p.use(xa),p.use(re),p.config.autoNotify!==!1&&(p.use(ht),p.use(ir)),p.use(pr),p.use(Zn),p.use(B),p.use(Qn),p.use(na),p._logger.debug("Loaded!"),p.config.autoCaptureSessions?p.startSession():p},Zt.Bugsnag={Client:ie,Report:bt,Session:rn,Breadcrumb:Ue},Zt.default=Zt,Zt})})(D1);var uQ=D1.exports,cQ=uQ,Xh={exports:{}};const WS="[a-fA-F\\d:]",ha=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${WS})|(?<=${WS})(?=\\s|$))`:"",Un="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",vr="[a-fA-F\\d]{1,4}",$f=`
478
+ `)),Tt=je-1,mt=Math.max(Tt-3,0),nt=Math.min(Tt+3,qe.length);return La(qe.slice(mt,nt),function(er,ei,tt){return er[mt+1+tt]=ei.length<=wt?ei:ei.substr(0,wt),er},{})};f.config.beforeSend.unshift(function(je){je.stacktrace=sn(je.stacktrace,function(nt){return!/__trace__$/.test(nt.method)});var qe=je.stacktrace[0];if(!(qe&&qe.file&&qe.file.replace(/#.*$/,"")!==y.replace(/#.*$/,""))){var Tt=j();if(Tt){var mt=Tt.innerHTML;je.updateMetaData("script","content",mt.length<=ra?mt:mt.substr(0,ra))}!qe||!qe.lineNumber||(qe.code=V(qe.lineNumber))}});var W=Ci(["setTimeout","setInterval","setImmediate","requestAnimationFrame"],function(je){return Ti(p,je,function(qe){return ze(qe,function(Tt){return{get:function(){return Tt[0]},replace:function(mt){Tt[0]=mt}}})})}),Ie=W[0];Ci(["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],function(je){!p[je]||!p[je].prototype||!p[je].prototype.hasOwnProperty||!p[je].prototype.hasOwnProperty("addEventListener")||(Ti(p[je].prototype,"addEventListener",function(qe){return ze(qe,Ei)}),Ti(p[je].prototype,"removeEventListener",function(qe){return ze(qe,Ei,!0)}))});function ze(je,qe,Tt){return Tt===void 0&&(Tt=!1),function(){var mt=Array.prototype.slice.call(arguments);try{var nt=qe(mt),er=nt.get();if(Tt&&je.apply(this,mt),typeof er!="function")return je.apply(this,mt);if(er.__trace__)nt.replace(er.__trace__);else{var ei=j();er.__trace__=function(){F(ei),Ie(function(){F(null)},0);var ti=er.apply(this,arguments);return F(null),ti},er.__trace__.__trace__=er.__trace__,nt.replace(er.__trace__)}}catch{}if(je.apply)return je.apply(this,mt);switch(mt.length){case 1:return je(mt[0]);case 2:return je(mt[0],mt[1]);default:return je()}}}},configSchema:{trackInlineScripts:{validate:function(f){return f===!0||f===!1},defaultValue:function(){return!0},message:"should be true|false"}}};function Ti(f,d,p){var y=f[d];if(!y)return y;var g=p(y);return f[d]=g,y}function Ei(f){var d=!!f[1]&&typeof f[1].handleEvent=="function";return{get:function(){return d?f[1].handleEvent:f[1]},replace:function(p){d?f[1].handleEvent=p:f[1]=p}}}var Zn={init:function(f,d){if(d===void 0&&(d=window),"addEventListener"in d){var p=f.config.interactionBreadcrumbsEnabled===!1,y=f.config.autoBreadcrumbs===!1&&f.config.interactionBreadcrumbsEnabled!==!0;p||y||d.addEventListener("click",function(g){var b,w;try{b=Nn(g.target),w=dr(g.target,d)}catch{b="[hidden]",w="[hidden]",f._logger.error("Cross domain error when tracking click event. See docs: https://tinyurl.com/yy3rn63z")}f.leaveBreadcrumb("UI click",{targetText:b,targetSelector:w},"user")},!0)}},configSchema:{interactionBreadcrumbsEnabled:{defaultValue:function(){},validate:function(f){return f===!0||f===!1||f===void 0},message:"should be true|false"}}},Nn=function(f){var d=f.textContent||f.innerText||"";return!d&&(f.type==="submit"||f.type==="button")&&(d=f.value),d=d.replace(/^\s+|\s+$/g,""),ia(d,140)};function dr(f,d){var p=[f.tagName];if(f.id&&p.push("#"+f.id),f.className&&f.className.length&&p.push("."+f.className.split(" ").join(".")),!d.document.querySelectorAll||!Array.prototype.indexOf)return p.join("");try{if(d.document.querySelectorAll(p.join("")).length===1)return p.join("")}catch{return p.join("")}if(f.parentNode.childNodes.length>1){var y=Array.prototype.indexOf.call(f.parentNode.childNodes,f)+1;p.push(":nth-child("+y+")")}return d.document.querySelectorAll(p.join("")).length===1?p.join(""):f.parentNode?dr(f.parentNode,d)+" > "+p.join(""):p.join("")}function ia(f,d){var p="(...)";return f&&f.length<=d?f:f.slice(0,d-p.length)+p}var pr={};pr.init=function(f,d){if(d===void 0&&(d=window),"addEventListener"in d){var p=f.config.navigationBreadcrumbsEnabled===!1,y=f.config.autoBreadcrumbs===!1&&f.config.navigationBreadcrumbsEnabled!==!0;if(!(p||y)){var g=function(b){return function(){return f.leaveBreadcrumb(b,{},"navigation")}};d.addEventListener("pagehide",g("Page hidden"),!0),d.addEventListener("pageshow",g("Page shown"),!0),d.addEventListener("load",g("Page loaded"),!0),d.document.addEventListener("DOMContentLoaded",g("DOMContentLoaded"),!0),d.addEventListener("load",function(){return d.addEventListener("popstate",g("Navigated back"),!0)}),d.addEventListener("hashchange",function(b){var w=b.oldURL?{from:Ir(b.oldURL,d),to:Ir(b.newURL,d),state:D(d)}:{to:Ir(d.location.href,d)};f.leaveBreadcrumb("Hash changed",w,"navigation")},!0),d.history.replaceState&&aa(f,d.history,"replaceState",d),d.history.pushState&&aa(f,d.history,"pushState",d),f.leaveBreadcrumb("Bugsnag loaded",{},"navigation")}}},pr.configSchema={navigationBreadcrumbsEnabled:{defaultValue:function(){},validate:function(f){return f===!0||f===!1||f===void 0},message:"should be true|false"}};var Ir=function(f,d){var p=d.document.createElement("A");return p.href=f,""+p.pathname+p.search+p.hash},on=function(f,d,p,y){var g=Ir(f.location.href,f);return{title:p,state:d,prevState:D(f),to:y||g,from:g}},aa=function(f,d,p,y){var g=d[p];d[p]=function(b,w,S){f.leaveBreadcrumb("History "+p,on(y,b,w,S),"navigation"),typeof f.refresh=="function"&&f.refresh(),f.config.autoCaptureSessions&&f.startSession(),g.apply(d,[b,w].concat(S!==void 0?S:[]))}},D=function(f){try{return f.history.state}catch{}},B={},R="request",k="BS~~S",E="BS~~U",U="BS~~M",A=v.includes,fe,ue,Te,Ne=function(){return[fe.config.endpoints.notify,fe.config.endpoints.sessions]};B.name="networkBreadcrumbs",B.init=function(f,d,p){d===void 0&&(d=Ne),p===void 0&&(p=window);var y=f.config.networkBreadcrumbsEnabled===!1,g=f.config.autoBreadcrumbs===!1&&f.config.networkBreadcrumbsEnabled!==!0;y||g||(fe=f,ue=p,Te=d,et(),nr())},B.configSchema={networkBreadcrumbsEnabled:{defaultValue:function(){},validate:function(f){return f===!0||f===!1||f===void 0},message:"should be true|false"}};var et=function(){if("addEventListener"in ue.XMLHttpRequest.prototype){var f=ue.XMLHttpRequest.prototype.open;ue.XMLHttpRequest.prototype.open=function(p,y){this[E]=y,this[U]=p,this[k]&&(this.removeEventListener("load",hr),this.removeEventListener("error",Kr)),this.addEventListener("load",hr),this.addEventListener("error",Kr),this[k]=!0,f.apply(this,arguments)}}};function hr(){if(!A(Te(),this[E])){var f={status:this.status,request:this[U]+" "+this[E]};this.status>=400?fe.leaveBreadcrumb("XMLHttpRequest failed",f,R):fe.leaveBreadcrumb("XMLHttpRequest succeeded",f,R)}}function Kr(){A(Te,this[E])||fe.leaveBreadcrumb("XMLHttpRequest error",{request:this[U]+" "+this[E]},R)}var nr=function(){if(!(!("fetch"in ue)||ue.fetch.polyfill)){var f=ue.fetch;ue.fetch=function(){var p=arguments,y=arguments[0],g=arguments[1],b,w=null;return y&&typeof y=="object"?(w=y.url,g&&"method"in g?b=g.method:y&&"method"in y&&(b=y.method)):(w=y,g&&"method"in g&&(b=g.method)),b===void 0&&(b="GET"),new Promise(function(S,T){f.apply(void 0,p).then(function(F){un(F,b,w),S(F)}).catch(function(F){vs(b,w),T(F)})})}}},un=function(f,d,p){var y={status:f.status,request:d+" "+p};f.status>=400?fe.leaveBreadcrumb("fetch() failed",y,R):fe.leaveBreadcrumb("fetch() succeeded",y,R)},vs=function(f,d){fe.leaveBreadcrumb("fetch() error",{request:f+" "+d},R)},mo=m.intRange,z={init:function(f){var d=0;f.config.beforeSend.push(function(p){if(d>=f.config.maxEvents)return p.ignore();d++}),f.refresh=function(){d=0}},configSchema:{maxEvents:{defaultValue:function(){return 10},message:"should be a positive integer ≤100",validate:function(f){return mo(1,100)(f)}}}},re={};function be(){return be=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},be.apply(this,arguments)}var Ge=v.map;re={init:function(f){f.config.beforeSend.push(function(d){d.stacktrace=Ge(d.stacktrace,function(p){return be({},p,{file:Dt(p.file)})})})}};var Dt=re._strip=function(f){return typeof f=="string"?f.replace(/\?.*$/,"").replace(/#.*$/,""):f},ht={init:function(f,d){d===void 0&&(d=window);function p(g,b,w,S,T){if(w===0&&/Script error\.?/.test(g))f._logger.warn("Ignoring cross-domain or eval script error. See docs: https://tinyurl.com/yy3rn63z");else{var F={severity:"error",unhandled:!0,severityReason:{type:"unhandledException"}},j;if(T)T.name&&T.message?j=new f.BugsnagReport(T.name,T.message,jt(f.BugsnagReport.getStacktrace(T),b,w,S),F,T):(j=new f.BugsnagReport("window.onerror",String(T),jt(f.BugsnagReport.getStacktrace(T,1),b,w,S),F,T),j.updateMetaData("window onerror",{error:T}));else if(typeof g=="object"&&g!==null&&(!b||typeof b!="string")&&!w&&!S&&!T){var V=g.type?"Event: "+g.type:"window.onerror",W=g.message||g.detail||"";j=new f.BugsnagReport(V,W,f.BugsnagReport.getStacktrace(new Error,1).slice(1),F,g),j.updateMetaData("window onerror",{event:g,extraParameters:b})}else j=new f.BugsnagReport("window.onerror",String(g),jt(f.BugsnagReport.getStacktrace(T,1),b,w,S),F,g),j.updateMetaData("window onerror",{event:g});f.notify(j)}typeof y=="function"&&y.apply(this,arguments)}var y=d.onerror;d.onerror=p}},jt=function(f,d,p,y){var g=f[0];return g&&(!g.fileName&&typeof d=="string"&&g.setFileName(d),!g.lineNumber&&Xt(p)&&g.setLineNumber(p),g.columnNumber||(Xt(y)?g.setColumnNumber(y):window.event&&Xt(window.event.errorCharacter)&&g.setColumnNumber(window.event.errorCharacter))),f},Xt=function(f){return typeof f=="number"&&String.call(f)!=="NaN"},ir={},rt=v.reduce;ir.init=function(f,d){d===void 0&&(d=window);var p=function(y){var g=y.reason,b=!1;try{y.detail&&y.detail.reason&&(g=y.detail.reason,b=!0)}catch{}var w={severity:"error",unhandled:!0,severityReason:{type:"unhandledPromiseRejection"}},S;if(g&&we(g))S=new f.BugsnagReport(g.name,g.message,De.parse(g),w,g),b&&(S.stacktrace=rt(S.stacktrace,Cr(g),[]));else{var T='Rejection reason was not an Error. See "Promise" tab for more detail.';S=new f.BugsnagReport(g&&g.name?g.name:"UnhandledRejection",g&&g.message?g.message:T,[],w,g),S.updateMetaData("promise","rejection reason",Sr(g))}f.notify(S)};"addEventListener"in d?d.addEventListener("unhandledrejection",p):d.onunhandledrejection=function(y,g){p({detail:{reason:y,promise:g}})}};var Sr=function(f){if(f==null)return"undefined (or null)";if(he(f)){var d;return d={},d[Object.prototype.toString.call(f)]={name:f.name,message:f.message,code:f.code,stack:f.stack},d}else return f},Cr=function(f){return function(d,p){return p.file===f.toString()?d:(p.method&&(p.method=p.method.replace(/^\s+/,"")),d.concat(p))}},Zt={};function Tr(){return Tr=Object.assign||function(f){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(f[y]=p[y])}return f},Tr.apply(this,arguments)}var ct="Bugsnag JavaScript",yn="6.5.2",O="https://github.com/bugsnag/bugsnag-js",P=Tr({},_.schema,se);return Zt=function(f){typeof f=="string"&&(f={apiKey:f});var d="";f.endpoints&&f.endpoints.notify&&!f.endpoints.sessions&&(d+="notify endpoint is set but sessions endpoint is not. No sessions will be sent.");var p=new ie({name:ct,version:yn,url:O});return p.setOptions(f),p.delivery(window.XDomainRequest?mn:gn),p.configure(P),d&&p._logger.warn(d),p.use(Zi),p.use(_i),p.use(ea),p.use(z),p.use(Aa),p.use(xa),p.use(re),p.config.autoNotify!==!1&&(p.use(ht),p.use(ir)),p.use(pr),p.use(Zn),p.use(B),p.use(Qn),p.use(na),p._logger.debug("Loaded!"),p.config.autoCaptureSessions?p.startSession():p},Zt.Bugsnag={Client:ie,Report:bt,Session:rn,Breadcrumb:Ue},Zt.default=Zt,Zt})})(j1);var lQ=j1.exports,fQ=lQ,Xh={exports:{}};const VS="[a-fA-F\\d:]",ha=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${VS})|(?<=${VS})(?=\\s|$))`:"",Un="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",vr="[a-fA-F\\d]{1,4}",$f=`
479
479
  (?:
480
480
  (?:${vr}:){7}(?:${vr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
481
481
  (?:${vr}:){6}(?:${Un}|:${vr}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
@@ -486,7 +486,7 @@ metaData was removed`},p=K(f,null,null,{filterPaths:st,filterKeys:d}),p.length>1
486
486
  (?:${vr}:){1}(?:(?::${vr}){0,4}:${Un}|(?::${vr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
487
487
  (?::(?:(?::${vr}){0,5}:${Un}|(?::${vr}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
488
488
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
489
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),lQ=new RegExp(`(?:^${Un}$)|(?:^${$f}$)`),fQ=new RegExp(`^${Un}$`),dQ=new RegExp(`^${$f}$`),dg=e=>e&&e.exact?lQ:new RegExp(`(?:${ha(e)}${Un}${ha(e)})|(?:${ha(e)}${$f}${ha(e)})`,"g");dg.v4=e=>e&&e.exact?fQ:new RegExp(`${ha(e)}${Un}${ha(e)}`,"g");dg.v6=e=>e&&e.exact?dQ:new RegExp(`${ha(e)}${$f}${ha(e)}`,"g");var pQ=dg;const pg=pQ,zs=e=>pg({exact:!0}).test(e);zs.v4=e=>pg.v4({exact:!0}).test(e);zs.v6=e=>pg.v6({exact:!0}).test(e);zs.version=e=>zs(e)?zs.v4(e)?4:6:void 0;var hQ=zs;(function(e,r){var t=Ae&&Ae.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(hQ);class i extends Error{constructor(){super("Request was cancelled"),this.name="CancelError"}get isCanceled(){return!0}}const a={timeout:5e3},s={v4:["https://ipv4.icanhazip.com/","https://api.ipify.org/"],v6:["https://ipv6.icanhazip.com/","https://api6.ipify.org/"]},o=(l,h,v)=>{const m=new XMLHttpRequest;return new Promise((C,I)=>{m.addEventListener("error",I,{once:!0}),m.addEventListener("timeout",I,{once:!0}),m.addEventListener("load",()=>{const $=m.responseText.trim();if(!$||v==="v4"?!n.default.v4($):!n.default.v6($)){I();return}C($)},{once:!0}),m.open("GET",l),m.timeout=h.timeout,m.send()})},u=(l,h)=>{let v;return async function(){const _=[].concat.apply(s[l],h.fallbackUrls||[]);for(const C of _)try{return v=o(C,h,l),await v}catch(I){if(I instanceof i)throw I}throw new Error("Couldn't find your IP")}()};class c{}r.default=c,c.v4=l=>u("v4",{...a,...l}),c.v6=l=>u("v6",{...a,...l}),e.exports=c})(Xh,Xh.exports);var vQ=Xh.exports,Oc={exports:{}},Qh={exports:{}},VS=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(VS){var GS=new Uint8Array(16);Qh.exports=function(){return VS(GS),GS}}else{var HS=new Array(16);Qh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),HS[r]=t>>>((r&3)<<3)&255;return HS}}var j1=Qh.exports,F1=[];for(var Pc=0;Pc<256;++Pc)F1[Pc]=(Pc+256).toString(16).substr(1);function mQ(e,r){var t=r||0,n=F1;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var U1=mQ,gQ=j1,yQ=U1,KS,Mp,xp=0,Np=0;function bQ(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||KS,s=e.clockseq!==void 0?e.clockseq:Mp;if(a==null||s==null){var o=gQ();a==null&&(a=KS=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=Mp=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Np+1,l=u-xp+(c-Np)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>xp)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");xp=u,Np=c,Mp=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||yQ(i)}var _Q=bQ,wQ=j1,SQ=U1;function CQ(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||wQ)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||SQ(i)}var TQ=CQ,EQ=_Q,B1=TQ,hg=B1;hg.v1=EQ;hg.v4=B1;var kQ=hg,Ac={exports:{}},Zh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Pa;class n{constructor(a,s){this.application=a,Object.assign(this,s),t.mixin(n)}}r.default=n,e.exports=n})(Zh,Zh.exports);var q1=Zh.exports,Mc={exports:{}},xc={exports:{}},ev={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Pa,n=Mn;class i{constructor(s,o){var u,c,l,h;if(this.conversation=s,o)for(const v in o)switch(v){case"type":o.type.startsWith("custom:")?this.type=o.type.replace("custom:",""):this.type=o.type;break;case"application_id":this.application_id=o.application_id;break;case"cid":this.cid=o.cid;break;case"from":["member:invited","member:joined","member:left"].indexOf(o.type)>-1?!((c=(u=o._embedded)===null||u===void 0?void 0:u.from_member)===null||c===void 0)&&c.id&&(this.from=(h=(l=o._embedded)===null||l===void 0?void 0:l.from_member)===null||h===void 0?void 0:h.id):this.from=o.from;break;case"timestamp":this.timestamp=o.timestamp;break;case"id":this.id=o.id;break;case"state":this.state=o.state;break;case"index":this.index=o.index;break;case"streamIndex":this.streamIndex=o.streamIndex;break;case"body":this.body=o.body,this.body.user&&this.body.user.user_id&&(this.body.user.id=this.body.user.user_id,delete this.body.user.user_id),this.body.digit&&(this.digit=this.body.digit,delete this.body.digit),this.body.digits&&(this.digit=this.body.digits,delete this.body.digits);break}t.mixin(i)}async del(s=this.id){try{await this.conversation.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.conversation.id}/events/${s}?from=${this.conversation.me.id}`,version:"beta2"});return}catch(o){throw new n.NexmoApiError(o)}}async delivered(s=this.id){if(this.type!=="text"&&this.type!=="image"&&this.type!=="message"&&(this.type="event"),this.conversation.me.id===this.from)throw new n.NexmoClientError("error:delivered:own-message");if(this.state&&this.state.delivered_to&&this.state.delivered_to[this.conversation.me.id])throw new n.NexmoClientError("error:already-delivered");try{await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.conversation.id}/events`,data:{type:`${this.type}:delivered`,from:this.conversation.me.id,body:{event_id:s}}});return}catch(o){throw new n.NexmoApiError(o)}}async seen(s=this.id){if(this.type!=="text"&&this.type!=="image"&&this.type!=="message"&&(this.type="event"),this.conversation.me.id===this.from)throw new n.NexmoClientError("error:seen:own-message");if(this.state&&this.state.seen_by&&this.state.seen_by[this.conversation.me.id])throw new n.NexmoClientError("error:already-seen");try{await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.conversation.id}/events`,data:{type:`${this.type}:seen`,from:this.conversation.me.id,body:{event_id:s}}});return}catch(o){throw new n.NexmoApiError(o)}}}r.default=i,e.exports=i})(ev,ev.exports);var Yi=ev.exports,JS;function vg(){return JS||(JS=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=Mn,a=t(Yi),s=t(yi());class o{constructor(c,l){this.conversation=c,this.callStatus=null,this._normalise(l),n.mixin(o)}_normalise(c){if(c){this.user=this.user||{},this.channel=c.channel||{type:"app"};let l;for(l in c)switch(l){case"member_id":this.id=c.member_id;break;case"timestamp":this.timestamp=c.timestamp;break;case"state":this.state=c.state;break;case"from":this.id=c.from;break;case"user_id":this.user.id=c.user_id;break;case"name":this.user.name=c.name;break;case"user":this.user={name:c.user.name,id:c.user.user_id||c.user.id},this.display_name=this.display_name||c.user.display_name;break;case"invited_by":this.invited_by=c.invited_by;break;case"display_name":this.display_name=this.display_name||c.display_name;break;case"_embedded":c._embedded.user&&(this.user={id:c._embedded.user.id||this.user.id,name:c._embedded.user.name||this.user.name},this.display_name=this.display_name||c._embedded.user.display_name);case"conversation":break;default:c.type||(this[l]=c[l])}this.conversation.application.me&&c.user_id===this.conversation.application.me.id&&(this.user.name=this.conversation.application.me.name),delete this.user_id,delete this.name,delete this.user.user_id}}async playStream(c){try{const l=await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"audio:play",to:this.id,body:c}});return new a.default(this.conversation,l)}catch(l){throw new i.NexmoApiError(l)}}async sayText(c){try{const l=await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"audio:say",cid:this.id,from:this.conversation.me.id,to:this.id,body:{text:c.text,voice_name:c.voice_name||"Amy",level:c.level||1,queue:c.queue||!0,loop:c.loop||1,ssml:c.ssml||!1}}});return new a.default(this.conversation,l)}catch(l){throw new i.NexmoApiError(l)}}async kick(c){var l,h;let v=`conversations/${this.conversation.id}/members/${this.id}`,m=new URLSearchParams;!((h=(l=this===null||this===void 0?void 0:this.conversation)===null||l===void 0?void 0:l.me)===null||h===void 0)&&h.id&&m.append("from",this.conversation.me.id),c&&Object.keys(c).forEach(_=>{m.append(_,c[_])}),v+=`?${m.toString()}`;try{return await this.conversation.application.session.sendNetworkRequest({type:"DELETE",path:v})}catch(_){throw new i.NexmoApiError(_)}}mute(c,l=null){return this.conversation.media.mute(c,l)}earmuff(c){return this.conversation.media.earmuff(c)}_handleEvent(c){switch(c.type){case"member:invited":this._normalise(c.body),this.state="INVITED",this.timestamp.invited=c.body.timestamp.invited,!c.body.invited_by&&c.body.user.media&&c.body.user.media.audio_settings&&c.body.user.media.audio_settings.enabled&&this._setCallStatusAndEmit("started");break;case"member:joined":this._normalise(c.body),this.state="JOINED",this.timestamp.joined=c.body.timestamp.joined,c.body.channel&&c.body.channel.knocking_id&&this._setCallStatusAndEmit("started");break;case"member:left":this._normalise(c.body),this.state="LEFT",this.timestamp.left=c.body.timestamp.left,c.body.reason&&c.body.reason.text&&this._setCallStatusAndEmit(c.body.reason.text);break;case"member:media":this.media=c.body.media;break;case"leg:status:update":this.channel.legs=s.default.updateMemberLegs(this.channel.legs,c),this._setCallStatusAndEmit(c.body.status);break;case"audio:ringing:start":(!this.callStatus||this.callStatus==="started")&&this._setCallStatusAndEmit("ringing");break}}_setCallStatusAndEmit(c){this.callStatus!==String(c)&&(this.callStatus=c,this.conversation.emit("member:call:status",this))}}r.default=o,e.exports=o}(xc,xc.exports)),xc.exports}var tv={exports:{}};(function(e,r){var t=Ae&&Ae.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Yi);class i extends n.default{constructor(s,o){super(s,o),this.type="text",this.conversation=s,this.state={seen_by:{},delivered_to:{}},o&&o.body&&o.body.timestamp&&(this.timestamp=o.body.timestamp),Object.assign(this,o)}seen(){return super.seen()}delivered(){return super.delivered()}del(){return super.del()}}r.default=i,e.exports=i})(tv,tv.exports);var mg=tv.exports,Nc={exports:{}},YS;function gg(){return YS||(YS=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=t(yi()),a=t(Yi),s=Mn;class o extends a.default{constructor(c,l){super(c,l),this.log=n.getLogger(this.constructor.name),this.type="message",this.conversation=c,this.state={seen_by:{},delivered_to:{},submitted_to:{},rejected_by:{},undeliverable_to:{}},l&&l.body&&l.body.timestamp&&(this.timestamp=l.body.timestamp),Object.assign(this,l)}seen(){return super.seen()}delivered(){return super.delivered()}del(){return super.del()}async fetchImage(){if(this.body.message_type!=="image")throw new s.NexmoClientError("error:message-event:invalid");try{return i.default._fetchImage(this.body.image.url,this.conversation.application.session.config.token)}catch(c){throw this.log.error(c),c}}}r.default=o,e.exports=o}(Nc,Nc.exports)),Nc.exports}var Lc={exports:{}},Dc={exports:{}};let z1=!0,W1=!0;function nl(e,r,t){const n=e.match(r);return n&&n.length>=t&&parseInt(n[t],10)}function ps(e,r,t){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(s,o){if(s!==r)return i.apply(this,arguments);const u=c=>{const l=t(c);l&&(o.handleEvent?o.handleEvent(l):o(l))};return this._eventMap=this._eventMap||{},this._eventMap[r]||(this._eventMap[r]=new Map),this._eventMap[r].set(o,u),i.apply(this,[s,u])};const a=n.removeEventListener;n.removeEventListener=function(s,o){if(s!==r||!this._eventMap||!this._eventMap[r])return a.apply(this,arguments);if(!this._eventMap[r].has(o))return a.apply(this,arguments);const u=this._eventMap[r].get(o);return this._eventMap[r].delete(o),this._eventMap[r].size===0&&delete this._eventMap[r],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[s,u])},Object.defineProperty(n,"on"+r,{get(){return this["_on"+r]},set(s){this["_on"+r]&&(this.removeEventListener(r,this["_on"+r]),delete this["_on"+r]),s&&this.addEventListener(r,this["_on"+r]=s)},enumerable:!0,configurable:!0})}function RQ(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(z1=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function $Q(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(W1=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function V1(){if(typeof window=="object"){if(z1)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function yg(e,r){W1&&console.warn(e+" is deprecated, please use "+r+" instead.")}function IQ(e){const r={browser:null,version:null};if(typeof e>"u"||!e.navigator||!e.navigator.userAgent)return r.browser="Not a browser.",r;const{navigator:t}=e;if(t.userAgentData&&t.userAgentData.brands){const n=t.userAgentData.brands.find(i=>i.brand==="Chromium");if(n)return{browser:"chrome",version:parseInt(n.version,10)}}if(t.mozGetUserMedia)r.browser="firefox",r.version=nl(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||e.isSecureContext===!1&&e.webkitRTCPeerConnection)r.browser="chrome",r.version=nl(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))r.browser="safari",r.version=nl(t.userAgent,/AppleWebKit\/(\d+)\./,1),r.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype;else return r.browser="Not a supported browser.",r;return r}function XS(e){return Object.prototype.toString.call(e)==="[object Object]"}function G1(e){return XS(e)?Object.keys(e).reduce(function(r,t){const n=XS(e[t]),i=n?G1(e[t]):e[t],a=n&&!Object.keys(i).length;return i===void 0||a?r:Object.assign(r,{[t]:i})},{}):e}function rv(e,r,t){!r||t.has(r.id)||(t.set(r.id,r),Object.keys(r).forEach(n=>{n.endsWith("Id")?rv(e,e.get(r[n]),t):n.endsWith("Ids")&&r[n].forEach(i=>{rv(e,e.get(i),t)})}))}function QS(e,r,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(r===null)return i;const a=[];return e.forEach(s=>{s.type==="track"&&s.trackIdentifier===r.id&&a.push(s)}),a.forEach(s=>{e.forEach(o=>{o.type===n&&o.trackId===s.id&&rv(e,o,i)})}),i}const ZS=V1;function H1(e,r){const t=e&&e.navigator;if(!t.mediaDevices)return;const n=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const u={};return Object.keys(o).forEach(c=>{if(c==="require"||c==="advanced"||c==="mediaSource")return;const l=typeof o[c]=="object"?o[c]:{ideal:o[c]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(v,m){return v?v+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(l.ideal!==void 0){u.optional=u.optional||[];let v={};typeof l.ideal=="number"?(v[h("min",c)]=l.ideal,u.optional.push(v),v={},v[h("max",c)]=l.ideal,u.optional.push(v)):(v[h("",c)]=l.ideal,u.optional.push(v))}l.exact!==void 0&&typeof l.exact!="number"?(u.mandatory=u.mandatory||{},u.mandatory[h("",c)]=l.exact):["min","max"].forEach(v=>{l[v]!==void 0&&(u.mandatory=u.mandatory||{},u.mandatory[h(v,c)]=l[v])})}),o.advanced&&(u.optional=(u.optional||[]).concat(o.advanced)),u},i=function(o,u){if(r.version>=61)return u(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const c=function(l,h,v){h in l&&!(v in l)&&(l[v]=l[h],delete l[h])};o=JSON.parse(JSON.stringify(o)),c(o.audio,"autoGainControl","googAutoGainControl"),c(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=n(o.audio)}if(o&&typeof o.video=="object"){let c=o.video.facingMode;c=c&&(typeof c=="object"?c:{ideal:c});const l=r.version<66;if(c&&(c.exact==="user"||c.exact==="environment"||c.ideal==="user"||c.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!l)){delete o.video.facingMode;let h;if(c.exact==="environment"||c.ideal==="environment"?h=["back","rear"]:(c.exact==="user"||c.ideal==="user")&&(h=["front"]),h)return t.mediaDevices.enumerateDevices().then(v=>{v=v.filter(_=>_.kind==="videoinput");let m=v.find(_=>h.some(C=>_.label.toLowerCase().includes(C)));return!m&&v.length&&h.includes("back")&&(m=v[v.length-1]),m&&(o.video.deviceId=c.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),ZS("chrome: "+JSON.stringify(o)),u(o)})}o.video=n(o.video)}return ZS("chrome: "+JSON.stringify(o)),u(o)},a=function(o){return r.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},s=function(o,u,c){i(o,l=>{t.webkitGetUserMedia(l,u,h=>{c&&c(a(h))})})};if(t.getUserMedia=s.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(u){return i(u,c=>o(c).then(l=>{if(c.audio&&!l.getAudioTracks().length||c.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(a(l))))}}}function K1(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function J1(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",i=>{let a;e.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(o=>o.track&&o.track.id===i.track.id):a={track:i.track};const s=new Event("track");s.track=i.track,s.receiver=a,s.transceiver={receiver:a},s.streams=[n.stream],this.dispatchEvent(s)}),n.stream.getTracks().forEach(i=>{let a;e.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(o=>o.track&&o.track.id===i.id):a={track:i};const s=new Event("track");s.track=i,s.receiver=a,s.transceiver={receiver:a},s.streams=[n.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),r.apply(this,arguments)}}else ps(e,"track",r=>(r.transceiver||Object.defineProperty(r,"transceiver",{value:{receiver:r.receiver}}),r))}function Y1(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const r=function(i,a){return{track:a,get dtmf(){return this._dtmf===void 0&&(a.kind==="audio"?this._dtmf=i.createDTMFSender(a):this._dtmf=null),this._dtmf},_pc:i}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(o,u){let c=i.apply(this,arguments);return c||(c=r(this,o),this._senders.push(c)),c};const a=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(o){a.apply(this,arguments);const u=this._senders.indexOf(o);u!==-1&&this._senders.splice(u,1)}}const t=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(a){this._senders=this._senders||[],t.apply(this,[a]),a.getTracks().forEach(s=>{this._senders.push(r(this,s))})};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(a){this._senders=this._senders||[],n.apply(this,[a]),a.getTracks().forEach(s=>{const o=this._senders.find(u=>u.track===s);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof e=="object"&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const r=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const n=r.apply(this,[]);return n.forEach(i=>i._pc=this),n},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function X1(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const a=t.apply(this,[]);return a.forEach(s=>s._pc=this),a});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const a=n.apply(this,arguments);return a._pc=this,a}),e.RTCRtpSender.prototype.getStats=function(){const a=this;return this._pc.getStats().then(s=>QS(s,a.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(a=>a._pc=this),i}),ps(e,"track",n=>(n.receiver._pc=n.srcElement,n)),e.RTCRtpReceiver.prototype.getStats=function(){const i=this;return this._pc.getStats().then(a=>QS(a,i.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;const r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const n=arguments[0];let i,a,s;return this.getSenders().forEach(o=>{o.track===n&&(i?s=!0:i=o)}),this.getReceivers().forEach(o=>(o.track===n&&(a?s=!0:a=o),o.track===n)),s||i&&a?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():a?a.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return r.apply(this,arguments)}}function Q1(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(s,o){if(!o)return r.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const u=r.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(u)===-1&&this._shimmedLocalStreams[o.id].push(u):this._shimmedLocalStreams[o.id]=[o,u],u};const t=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(c=>{if(this.getSenders().find(h=>h.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const u=this.getSenders().filter(c=>o.indexOf(c)===-1);this._shimmedLocalStreams[s.id]=[s].concat(u)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],n.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const u=this._shimmedLocalStreams[o].indexOf(s);u!==-1&&this._shimmedLocalStreams[o].splice(u,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function Z1(e,r){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&r.version>=65)return Q1(e);const t=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(m=>m.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const h=new e.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}n.apply(this,[l])};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},e.RTCPeerConnection.prototype.addTrack=function(l,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const v=[].slice.call(arguments,1);if(v.length!==1||!v[0].getTracks().find(C=>C===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(C=>C.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const _=this._streams[h.id];if(_)_.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const C=new e.MediaStream([l]);this._streams[h.id]=C,this._reverseStreams[C.id]=h,this.addStream(C)}return this.getSenders().find(C=>C.track===l)};function a(c,l){let h=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(v=>{const m=c._reverseStreams[v],_=c._streams[m.id];h=h.replace(new RegExp(_.id,"g"),m.id)}),new RTCSessionDescription({type:l.type,sdp:h})}function s(c,l){let h=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(v=>{const m=c._reverseStreams[v],_=c._streams[m.id];h=h.replace(new RegExp(m.id,"g"),_.id)}),new RTCSessionDescription({type:l.type,sdp:h})}["createOffer","createAnswer"].forEach(function(c){const l=e.RTCPeerConnection.prototype[c],h={[c](){const v=arguments;return arguments.length&&typeof arguments[0]=="function"?l.apply(this,[_=>{const C=a(this,_);v[0].apply(null,[C])},_=>{v[1]&&v[1].apply(null,_)},arguments[2]]):l.apply(this,arguments).then(_=>a(this,_))}};e.RTCPeerConnection.prototype[c]=h[c]});const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=s(this,arguments[0]),o.apply(this,arguments))};const u=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const c=u.get.apply(this);return c.type===""?c:a(this,c)}}),e.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(l._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let v;Object.keys(this._streams).forEach(m=>{this._streams[m].getTracks().find(C=>l.track===C)&&(v=this._streams[m])}),v&&(v.getTracks().length===1?this.removeStream(this._reverseStreams[v.id]):v.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function nv(e,r){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&r.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]})}function e$(e,r){ps(e,"negotiationneeded",t=>{const n=t.target;if(!((r.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const e0=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:e$,shimAddTrackRemoveTrack:Z1,shimAddTrackRemoveTrackWithNative:Q1,shimGetSendersWithDtmf:Y1,shimGetUserMedia:H1,shimMediaStream:K1,shimOnTrack:J1,shimPeerConnection:nv,shimSenderReceiverGetStats:X1},Symbol.toStringTag,{value:"Module"}));function t$(e,r){const t=e&&e.navigator,n=e&&e.MediaStreamTrack;if(t.getUserMedia=function(i,a,s){yg("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(a,s)},!(r.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(s,o,u){o in s&&!(u in s)&&(s[u]=s[o],delete s[o])},a=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s.audio,"autoGainControl","mozAutoGainControl"),i(s.audio,"noiseSuppression","mozNoiseSuppression")),a(s)},n&&n.prototype.getSettings){const s=n.prototype.getSettings;n.prototype.getSettings=function(){const o=s.apply(this,arguments);return i(o,"mozAutoGainControl","autoGainControl"),i(o,"mozNoiseSuppression","noiseSuppression"),o}}if(n&&n.prototype.applyConstraints){const s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o,"autoGainControl","mozAutoGainControl"),i(o,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[o])}}}}function OQ(e,r){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){const i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return n.video===!0?n.video={mediaSource:r}:n.video.mediaSource=r,e.navigator.mediaDevices.getUserMedia(n)})}function r$(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function iv(e,r){if(typeof e!="object"||!(e.RTCPeerConnection||e.mozRTCPeerConnection))return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),r.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const a=e.RTCPeerConnection.prototype[i],s={[i](){return arguments[0]=new(i==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),a.apply(this,arguments)}};e.RTCPeerConnection.prototype[i]=s[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[a,s,o]=arguments;return n.apply(this,[a||null]).then(u=>{if(r.version<53&&!s)try{u.forEach(c=>{c.type=t[c.type]||c.type})}catch(c){if(c.name!=="TypeError")throw c;u.forEach((l,h)=>{u.set(h,Object.assign({},l,{type:t[l.type]||l.type}))})}return u}).then(s,o)}}function n$(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const r=e.RTCPeerConnection.prototype.getSenders;r&&(e.RTCPeerConnection.prototype.getSenders=function(){const i=r.apply(this,[]);return i.forEach(a=>a._pc=this),i});const t=e.RTCPeerConnection.prototype.addTrack;t&&(e.RTCPeerConnection.prototype.addTrack=function(){const i=t.apply(this,arguments);return i._pc=this,i}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function i$(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){const n=r.apply(this,[]);return n.forEach(i=>i._pc=this),n}),ps(e,"track",t=>(t.receiver._pc=t.srcElement,t)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function a$(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){yg("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function s$(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function o$(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.addTransceiver;r&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let n=arguments[1]&&arguments[1].sendEncodings;n===void 0&&(n=[]),n=[...n];const i=n.length>0;i&&n.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const a=r.apply(this,arguments);if(i){const{sender:s}=a,o=s.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=n,s.sendEncodings=n,this.setParametersPromises.push(s.setParameters(o).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return a})}function u$(e){if(!(typeof e=="object"&&e.RTCRtpSender))return;const r=e.RTCRtpSender.prototype.getParameters;r&&(e.RTCRtpSender.prototype.getParameters=function(){const n=r.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function c$(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}function l$(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}const t0=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:o$,shimCreateAnswer:l$,shimCreateOffer:c$,shimGetDisplayMedia:OQ,shimGetParameters:u$,shimGetUserMedia:t$,shimOnTrack:r$,shimPeerConnection:iv,shimRTCDataChannel:s$,shimReceiverGetStats:i$,shimRemoveStream:a$,shimSenderGetStats:n$},Symbol.toStringTag,{value:"Module"}));function f$(e){if(!(typeof e!="object"||!e.RTCPeerConnection)){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(i=>r.call(this,i,n)),n.getVideoTracks().forEach(i=>r.call(this,i,n))},e.RTCPeerConnection.prototype.addTrack=function(n,...i){return i&&i.forEach(a=>{this._localStreams?this._localStreams.includes(a)||this._localStreams.push(a):this._localStreams=[a]}),r.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);const i=t.getTracks();this.getSenders().forEach(a=>{i.includes(a.track)&&this.removeTrack(a)})})}}function d$(e){if(!(typeof e!="object"||!e.RTCPeerConnection)&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const a=new Event("addstream");a.stream=i,this.dispatchEvent(a)})})}});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(a=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(a)>=0)return;n._remoteStreams.push(a);const s=new Event("addstream");s.stream=a,n.dispatchEvent(s)})}),r.apply(n,arguments)}}}function p$(e){if(typeof e!="object"||!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,t=r.createOffer,n=r.createAnswer,i=r.setLocalDescription,a=r.setRemoteDescription,s=r.addIceCandidate;r.createOffer=function(c,l){const h=arguments.length>=2?arguments[2]:arguments[0],v=t.apply(this,[h]);return l?(v.then(c,l),Promise.resolve()):v},r.createAnswer=function(c,l){const h=arguments.length>=2?arguments[2]:arguments[0],v=n.apply(this,[h]);return l?(v.then(c,l),Promise.resolve()):v};let o=function(u,c,l){const h=i.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h};r.setLocalDescription=o,o=function(u,c,l){const h=a.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h},r.setRemoteDescription=o,o=function(u,c,l){const h=s.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h},r.addIceCandidate=o}function h$(e){const r=e&&e.navigator;if(r.mediaDevices&&r.mediaDevices.getUserMedia){const t=r.mediaDevices,n=t.getUserMedia.bind(t);r.mediaDevices.getUserMedia=i=>n(v$(i))}!r.getUserMedia&&r.mediaDevices&&r.mediaDevices.getUserMedia&&(r.getUserMedia=(function(n,i,a){r.mediaDevices.getUserMedia(n).then(i,a)}).bind(r))}function v$(e){return e&&e.video!==void 0?Object.assign({},e,{video:G1(e.video)}):e}function m$(e){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection;e.RTCPeerConnection=function(n,i){if(n&&n.iceServers){const a=[];for(let s=0;s<n.iceServers.length;s++){let o=n.iceServers[s];o.urls===void 0&&o.url?(yg("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,a.push(o)):a.push(n.iceServers[s])}n.iceServers=a}return new r(n,i)},e.RTCPeerConnection.prototype=r.prototype,"generateCertificate"in r&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get(){return r.generateCertificate}})}function g$(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function y$(e){const r=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const i=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio",{direction:"recvonly"}),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const a=this.getTransceivers().find(s=>s.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&a?a.direction==="sendrecv"?a.setDirection?a.setDirection("sendonly"):a.direction="sendonly":a.direction==="recvonly"&&(a.setDirection?a.setDirection("inactive"):a.direction="inactive"):n.offerToReceiveVideo===!0&&!a&&this.addTransceiver("video",{direction:"recvonly"})}return r.apply(this,arguments)}}function b$(e){typeof e!="object"||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}const r0=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:b$,shimCallbacksAPI:p$,shimConstraints:v$,shimCreateOfferLegacy:y$,shimGetUserMedia:h$,shimLocalStreamsAPI:f$,shimRTCIceServerUrls:m$,shimRemoteStreamsAPI:d$,shimTrackEventTransceiver:g$},Symbol.toStringTag,{value:"Module"}));var _$={exports:{}};(function(e){const r={};r.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},r.localCName=r.generateIdentifier(),r.splitLines=function(t){return t.trim().split(`
489
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),dQ=new RegExp(`(?:^${Un}$)|(?:^${$f}$)`),pQ=new RegExp(`^${Un}$`),hQ=new RegExp(`^${$f}$`),dg=e=>e&&e.exact?dQ:new RegExp(`(?:${ha(e)}${Un}${ha(e)})|(?:${ha(e)}${$f}${ha(e)})`,"g");dg.v4=e=>e&&e.exact?pQ:new RegExp(`${ha(e)}${Un}${ha(e)}`,"g");dg.v6=e=>e&&e.exact?hQ:new RegExp(`${ha(e)}${$f}${ha(e)}`,"g");var vQ=dg;const pg=vQ,zs=e=>pg({exact:!0}).test(e);zs.v4=e=>pg.v4({exact:!0}).test(e);zs.v6=e=>pg.v6({exact:!0}).test(e);zs.version=e=>zs(e)?zs.v4(e)?4:6:void 0;var mQ=zs;(function(e,r){var t=Ae&&Ae.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(mQ);class i extends Error{constructor(){super("Request was cancelled"),this.name="CancelError"}get isCanceled(){return!0}}const a={timeout:5e3},s={v4:["https://ipv4.icanhazip.com/","https://api.ipify.org/"],v6:["https://ipv6.icanhazip.com/","https://api6.ipify.org/"]},o=(l,h,v)=>{const m=new XMLHttpRequest;return new Promise((C,I)=>{m.addEventListener("error",I,{once:!0}),m.addEventListener("timeout",I,{once:!0}),m.addEventListener("load",()=>{const $=m.responseText.trim();if(!$||v==="v4"?!n.default.v4($):!n.default.v6($)){I();return}C($)},{once:!0}),m.open("GET",l),m.timeout=h.timeout,m.send()})},u=(l,h)=>{let v;return async function(){const _=[].concat.apply(s[l],h.fallbackUrls||[]);for(const C of _)try{return v=o(C,h,l),await v}catch(I){if(I instanceof i)throw I}throw new Error("Couldn't find your IP")}()};class c{}r.default=c,c.v4=l=>u("v4",{...a,...l}),c.v6=l=>u("v6",{...a,...l}),e.exports=c})(Xh,Xh.exports);var gQ=Xh.exports,Oc={exports:{}},Qh={exports:{}},GS=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(GS){var HS=new Uint8Array(16);Qh.exports=function(){return GS(HS),HS}}else{var KS=new Array(16);Qh.exports=function(){for(var r=0,t;r<16;r++)r&3||(t=Math.random()*4294967296),KS[r]=t>>>((r&3)<<3)&255;return KS}}var F1=Qh.exports,U1=[];for(var Pc=0;Pc<256;++Pc)U1[Pc]=(Pc+256).toString(16).substr(1);function yQ(e,r){var t=r||0,n=U1;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]]].join("")}var B1=yQ,bQ=F1,_Q=B1,JS,Mp,xp=0,Np=0;function wQ(e,r,t){var n=r&&t||0,i=r||[];e=e||{};var a=e.node||JS,s=e.clockseq!==void 0?e.clockseq:Mp;if(a==null||s==null){var o=bQ();a==null&&(a=JS=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=Mp=(o[6]<<8|o[7])&16383)}var u=e.msecs!==void 0?e.msecs:new Date().getTime(),c=e.nsecs!==void 0?e.nsecs:Np+1,l=u-xp+(c-Np)/1e4;if(l<0&&e.clockseq===void 0&&(s=s+1&16383),(l<0||u>xp)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");xp=u,Np=c,Mp=s,u+=122192928e5;var h=((u&268435455)*1e4+c)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=h&255;var v=u/4294967296*1e4&268435455;i[n++]=v>>>8&255,i[n++]=v&255,i[n++]=v>>>24&15|16,i[n++]=v>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return r||_Q(i)}var SQ=wQ,CQ=F1,TQ=B1;function EQ(e,r,t){var n=r&&t||0;typeof e=="string"&&(r=e==="binary"?new Array(16):null,e=null),e=e||{};var i=e.random||(e.rng||CQ)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,r)for(var a=0;a<16;++a)r[n+a]=i[a];return r||TQ(i)}var kQ=EQ,RQ=SQ,q1=kQ,hg=q1;hg.v1=RQ;hg.v4=q1;var $Q=hg,Ac={exports:{}},Zh={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Pa;class n{constructor(a,s){this.application=a,Object.assign(this,s),t.mixin(n)}}r.default=n,e.exports=n})(Zh,Zh.exports);var z1=Zh.exports,Mc={exports:{}},xc={exports:{}},ev={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Pa,n=Mn;class i{constructor(s,o){var u,c,l,h;if(this.conversation=s,o)for(const v in o)switch(v){case"type":o.type.startsWith("custom:")?this.type=o.type.replace("custom:",""):this.type=o.type;break;case"application_id":this.application_id=o.application_id;break;case"cid":this.cid=o.cid;break;case"from":["member:invited","member:joined","member:left"].indexOf(o.type)>-1?!((c=(u=o._embedded)===null||u===void 0?void 0:u.from_member)===null||c===void 0)&&c.id&&(this.from=(h=(l=o._embedded)===null||l===void 0?void 0:l.from_member)===null||h===void 0?void 0:h.id):this.from=o.from;break;case"timestamp":this.timestamp=o.timestamp;break;case"id":this.id=o.id;break;case"state":this.state=o.state;break;case"index":this.index=o.index;break;case"streamIndex":this.streamIndex=o.streamIndex;break;case"body":this.body=o.body,this.body.user&&this.body.user.user_id&&(this.body.user.id=this.body.user.user_id,delete this.body.user.user_id),this.body.digit&&(this.digit=this.body.digit,delete this.body.digit),this.body.digits&&(this.digit=this.body.digits,delete this.body.digits);break}t.mixin(i)}async del(s=this.id){try{await this.conversation.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.conversation.id}/events/${s}?from=${this.conversation.me.id}`,version:"beta2"});return}catch(o){throw new n.NexmoApiError(o)}}async delivered(s=this.id){if(this.type!=="text"&&this.type!=="image"&&this.type!=="message"&&(this.type="event"),this.conversation.me.id===this.from)throw new n.NexmoClientError("error:delivered:own-message");if(this.state&&this.state.delivered_to&&this.state.delivered_to[this.conversation.me.id])throw new n.NexmoClientError("error:already-delivered");try{await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.conversation.id}/events`,data:{type:`${this.type}:delivered`,from:this.conversation.me.id,body:{event_id:s}}});return}catch(o){throw new n.NexmoApiError(o)}}async seen(s=this.id){if(this.type!=="text"&&this.type!=="image"&&this.type!=="message"&&(this.type="event"),this.conversation.me.id===this.from)throw new n.NexmoClientError("error:seen:own-message");if(this.state&&this.state.seen_by&&this.state.seen_by[this.conversation.me.id])throw new n.NexmoClientError("error:already-seen");try{await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.conversation.id}/events`,data:{type:`${this.type}:seen`,from:this.conversation.me.id,body:{event_id:s}}});return}catch(o){throw new n.NexmoApiError(o)}}}r.default=i,e.exports=i})(ev,ev.exports);var Yi=ev.exports,YS;function vg(){return YS||(YS=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=Mn,a=t(Yi),s=t(yi());class o{constructor(c,l){this.conversation=c,this.callStatus=null,this._normalise(l),n.mixin(o)}_normalise(c){if(c){this.user=this.user||{},this.channel=c.channel||{type:"app"};let l;for(l in c)switch(l){case"member_id":this.id=c.member_id;break;case"timestamp":this.timestamp=c.timestamp;break;case"state":this.state=c.state;break;case"from":this.id=c.from;break;case"user_id":this.user.id=c.user_id;break;case"name":this.user.name=c.name;break;case"user":this.user={name:c.user.name,id:c.user.user_id||c.user.id},this.display_name=this.display_name||c.user.display_name;break;case"invited_by":this.invited_by=c.invited_by;break;case"display_name":this.display_name=this.display_name||c.display_name;break;case"_embedded":c._embedded.user&&(this.user={id:c._embedded.user.id||this.user.id,name:c._embedded.user.name||this.user.name},this.display_name=this.display_name||c._embedded.user.display_name);case"conversation":break;default:c.type||(this[l]=c[l])}this.conversation.application.me&&c.user_id===this.conversation.application.me.id&&(this.user.name=this.conversation.application.me.name),delete this.user_id,delete this.name,delete this.user.user_id}}async playStream(c){try{const l=await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"audio:play",to:this.id,body:c}});return new a.default(this.conversation,l)}catch(l){throw new i.NexmoApiError(l)}}async sayText(c){try{const l=await this.conversation.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"audio:say",cid:this.id,from:this.conversation.me.id,to:this.id,body:{text:c.text,voice_name:c.voice_name||"Amy",level:c.level||1,queue:c.queue||!0,loop:c.loop||1,ssml:c.ssml||!1}}});return new a.default(this.conversation,l)}catch(l){throw new i.NexmoApiError(l)}}async kick(c){var l,h;let v=`conversations/${this.conversation.id}/members/${this.id}`,m=new URLSearchParams;!((h=(l=this===null||this===void 0?void 0:this.conversation)===null||l===void 0?void 0:l.me)===null||h===void 0)&&h.id&&m.append("from",this.conversation.me.id),c&&Object.keys(c).forEach(_=>{m.append(_,c[_])}),v+=`?${m.toString()}`;try{return await this.conversation.application.session.sendNetworkRequest({type:"DELETE",path:v})}catch(_){throw new i.NexmoApiError(_)}}mute(c,l=null){return this.conversation.media.mute(c,l)}earmuff(c){return this.conversation.media.earmuff(c)}_handleEvent(c){switch(c.type){case"member:invited":this._normalise(c.body),this.state="INVITED",this.timestamp.invited=c.body.timestamp.invited,!c.body.invited_by&&c.body.user.media&&c.body.user.media.audio_settings&&c.body.user.media.audio_settings.enabled&&this._setCallStatusAndEmit("started");break;case"member:joined":this._normalise(c.body),this.state="JOINED",this.timestamp.joined=c.body.timestamp.joined,c.body.channel&&c.body.channel.knocking_id&&this._setCallStatusAndEmit("started");break;case"member:left":this._normalise(c.body),this.state="LEFT",this.timestamp.left=c.body.timestamp.left,c.body.reason&&c.body.reason.text&&this._setCallStatusAndEmit(c.body.reason.text);break;case"member:media":this.media=c.body.media;break;case"leg:status:update":this.channel.legs=s.default.updateMemberLegs(this.channel.legs,c),this._setCallStatusAndEmit(c.body.status);break;case"audio:ringing:start":(!this.callStatus||this.callStatus==="started")&&this._setCallStatusAndEmit("ringing");break}}_setCallStatusAndEmit(c){this.callStatus!==String(c)&&(this.callStatus=c,this.conversation.emit("member:call:status",this))}}r.default=o,e.exports=o}(xc,xc.exports)),xc.exports}var tv={exports:{}};(function(e,r){var t=Ae&&Ae.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Yi);class i extends n.default{constructor(s,o){super(s,o),this.type="text",this.conversation=s,this.state={seen_by:{},delivered_to:{}},o&&o.body&&o.body.timestamp&&(this.timestamp=o.body.timestamp),Object.assign(this,o)}seen(){return super.seen()}delivered(){return super.delivered()}del(){return super.del()}}r.default=i,e.exports=i})(tv,tv.exports);var mg=tv.exports,Nc={exports:{}},XS;function gg(){return XS||(XS=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=t(yi()),a=t(Yi),s=Mn;class o extends a.default{constructor(c,l){super(c,l),this.log=n.getLogger(this.constructor.name),this.type="message",this.conversation=c,this.state={seen_by:{},delivered_to:{},submitted_to:{},rejected_by:{},undeliverable_to:{}},l&&l.body&&l.body.timestamp&&(this.timestamp=l.body.timestamp),Object.assign(this,l)}seen(){return super.seen()}delivered(){return super.delivered()}del(){return super.del()}async fetchImage(){if(this.body.message_type!=="image")throw new s.NexmoClientError("error:message-event:invalid");try{return i.default._fetchImage(this.body.image.url,this.conversation.application.session.config.token)}catch(c){throw this.log.error(c),c}}}r.default=o,e.exports=o}(Nc,Nc.exports)),Nc.exports}var Lc={exports:{}},Dc={exports:{}};let W1=!0,V1=!0;function nl(e,r,t){const n=e.match(r);return n&&n.length>=t&&parseInt(n[t],10)}function ps(e,r,t){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(s,o){if(s!==r)return i.apply(this,arguments);const u=c=>{const l=t(c);l&&(o.handleEvent?o.handleEvent(l):o(l))};return this._eventMap=this._eventMap||{},this._eventMap[r]||(this._eventMap[r]=new Map),this._eventMap[r].set(o,u),i.apply(this,[s,u])};const a=n.removeEventListener;n.removeEventListener=function(s,o){if(s!==r||!this._eventMap||!this._eventMap[r])return a.apply(this,arguments);if(!this._eventMap[r].has(o))return a.apply(this,arguments);const u=this._eventMap[r].get(o);return this._eventMap[r].delete(o),this._eventMap[r].size===0&&delete this._eventMap[r],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[s,u])},Object.defineProperty(n,"on"+r,{get(){return this["_on"+r]},set(s){this["_on"+r]&&(this.removeEventListener(r,this["_on"+r]),delete this["_on"+r]),s&&this.addEventListener(r,this["_on"+r]=s)},enumerable:!0,configurable:!0})}function IQ(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(W1=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function OQ(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(V1=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function G1(){if(typeof window=="object"){if(W1)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function yg(e,r){V1&&console.warn(e+" is deprecated, please use "+r+" instead.")}function PQ(e){const r={browser:null,version:null};if(typeof e>"u"||!e.navigator||!e.navigator.userAgent)return r.browser="Not a browser.",r;const{navigator:t}=e;if(t.userAgentData&&t.userAgentData.brands){const n=t.userAgentData.brands.find(i=>i.brand==="Chromium");if(n)return{browser:"chrome",version:parseInt(n.version,10)}}if(t.mozGetUserMedia)r.browser="firefox",r.version=nl(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||e.isSecureContext===!1&&e.webkitRTCPeerConnection)r.browser="chrome",r.version=nl(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))r.browser="safari",r.version=nl(t.userAgent,/AppleWebKit\/(\d+)\./,1),r.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype;else return r.browser="Not a supported browser.",r;return r}function QS(e){return Object.prototype.toString.call(e)==="[object Object]"}function H1(e){return QS(e)?Object.keys(e).reduce(function(r,t){const n=QS(e[t]),i=n?H1(e[t]):e[t],a=n&&!Object.keys(i).length;return i===void 0||a?r:Object.assign(r,{[t]:i})},{}):e}function rv(e,r,t){!r||t.has(r.id)||(t.set(r.id,r),Object.keys(r).forEach(n=>{n.endsWith("Id")?rv(e,e.get(r[n]),t):n.endsWith("Ids")&&r[n].forEach(i=>{rv(e,e.get(i),t)})}))}function ZS(e,r,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(r===null)return i;const a=[];return e.forEach(s=>{s.type==="track"&&s.trackIdentifier===r.id&&a.push(s)}),a.forEach(s=>{e.forEach(o=>{o.type===n&&o.trackId===s.id&&rv(e,o,i)})}),i}const e0=G1;function K1(e,r){const t=e&&e.navigator;if(!t.mediaDevices)return;const n=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const u={};return Object.keys(o).forEach(c=>{if(c==="require"||c==="advanced"||c==="mediaSource")return;const l=typeof o[c]=="object"?o[c]:{ideal:o[c]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const h=function(v,m){return v?v+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(l.ideal!==void 0){u.optional=u.optional||[];let v={};typeof l.ideal=="number"?(v[h("min",c)]=l.ideal,u.optional.push(v),v={},v[h("max",c)]=l.ideal,u.optional.push(v)):(v[h("",c)]=l.ideal,u.optional.push(v))}l.exact!==void 0&&typeof l.exact!="number"?(u.mandatory=u.mandatory||{},u.mandatory[h("",c)]=l.exact):["min","max"].forEach(v=>{l[v]!==void 0&&(u.mandatory=u.mandatory||{},u.mandatory[h(v,c)]=l[v])})}),o.advanced&&(u.optional=(u.optional||[]).concat(o.advanced)),u},i=function(o,u){if(r.version>=61)return u(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const c=function(l,h,v){h in l&&!(v in l)&&(l[v]=l[h],delete l[h])};o=JSON.parse(JSON.stringify(o)),c(o.audio,"autoGainControl","googAutoGainControl"),c(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=n(o.audio)}if(o&&typeof o.video=="object"){let c=o.video.facingMode;c=c&&(typeof c=="object"?c:{ideal:c});const l=r.version<66;if(c&&(c.exact==="user"||c.exact==="environment"||c.ideal==="user"||c.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!l)){delete o.video.facingMode;let h;if(c.exact==="environment"||c.ideal==="environment"?h=["back","rear"]:(c.exact==="user"||c.ideal==="user")&&(h=["front"]),h)return t.mediaDevices.enumerateDevices().then(v=>{v=v.filter(_=>_.kind==="videoinput");let m=v.find(_=>h.some(C=>_.label.toLowerCase().includes(C)));return!m&&v.length&&h.includes("back")&&(m=v[v.length-1]),m&&(o.video.deviceId=c.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),e0("chrome: "+JSON.stringify(o)),u(o)})}o.video=n(o.video)}return e0("chrome: "+JSON.stringify(o)),u(o)},a=function(o){return r.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},s=function(o,u,c){i(o,l=>{t.webkitGetUserMedia(l,u,h=>{c&&c(a(h))})})};if(t.getUserMedia=s.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(u){return i(u,c=>o(c).then(l=>{if(c.audio&&!l.getAudioTracks().length||c.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(a(l))))}}}function J1(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Y1(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",i=>{let a;e.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(o=>o.track&&o.track.id===i.track.id):a={track:i.track};const s=new Event("track");s.track=i.track,s.receiver=a,s.transceiver={receiver:a},s.streams=[n.stream],this.dispatchEvent(s)}),n.stream.getTracks().forEach(i=>{let a;e.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(o=>o.track&&o.track.id===i.id):a={track:i};const s=new Event("track");s.track=i,s.receiver=a,s.transceiver={receiver:a},s.streams=[n.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),r.apply(this,arguments)}}else ps(e,"track",r=>(r.transceiver||Object.defineProperty(r,"transceiver",{value:{receiver:r.receiver}}),r))}function X1(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const r=function(i,a){return{track:a,get dtmf(){return this._dtmf===void 0&&(a.kind==="audio"?this._dtmf=i.createDTMFSender(a):this._dtmf=null),this._dtmf},_pc:i}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(o,u){let c=i.apply(this,arguments);return c||(c=r(this,o),this._senders.push(c)),c};const a=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(o){a.apply(this,arguments);const u=this._senders.indexOf(o);u!==-1&&this._senders.splice(u,1)}}const t=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(a){this._senders=this._senders||[],t.apply(this,[a]),a.getTracks().forEach(s=>{this._senders.push(r(this,s))})};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(a){this._senders=this._senders||[],n.apply(this,[a]),a.getTracks().forEach(s=>{const o=this._senders.find(u=>u.track===s);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof e=="object"&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const r=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const n=r.apply(this,[]);return n.forEach(i=>i._pc=this),n},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Q1(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const a=t.apply(this,[]);return a.forEach(s=>s._pc=this),a});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const a=n.apply(this,arguments);return a._pc=this,a}),e.RTCRtpSender.prototype.getStats=function(){const a=this;return this._pc.getStats().then(s=>ZS(s,a.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(a=>a._pc=this),i}),ps(e,"track",n=>(n.receiver._pc=n.srcElement,n)),e.RTCRtpReceiver.prototype.getStats=function(){const i=this;return this._pc.getStats().then(a=>ZS(a,i.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;const r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const n=arguments[0];let i,a,s;return this.getSenders().forEach(o=>{o.track===n&&(i?s=!0:i=o)}),this.getReceivers().forEach(o=>(o.track===n&&(a?s=!0:a=o),o.track===n)),s||i&&a?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():a?a.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return r.apply(this,arguments)}}function Z1(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(s,o){if(!o)return r.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const u=r.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(u)===-1&&this._shimmedLocalStreams[o.id].push(u):this._shimmedLocalStreams[o.id]=[o,u],u};const t=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(c=>{if(this.getSenders().find(h=>h.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const u=this.getSenders().filter(c=>o.indexOf(c)===-1);this._shimmedLocalStreams[s.id]=[s].concat(u)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],n.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const u=this._shimmedLocalStreams[o].indexOf(s);u!==-1&&this._shimmedLocalStreams[o].splice(u,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function e$(e,r){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&r.version>=65)return Z1(e);const t=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(h=>this._reverseStreams[h.id])};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(h=>{if(this.getSenders().find(m=>m.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const h=new e.MediaStream(l.getTracks());this._streams[l.id]=h,this._reverseStreams[h.id]=l,l=h}n.apply(this,[l])};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},e.RTCPeerConnection.prototype.addTrack=function(l,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const v=[].slice.call(arguments,1);if(v.length!==1||!v[0].getTracks().find(C=>C===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(C=>C.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const _=this._streams[h.id];if(_)_.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const C=new e.MediaStream([l]);this._streams[h.id]=C,this._reverseStreams[C.id]=h,this.addStream(C)}return this.getSenders().find(C=>C.track===l)};function a(c,l){let h=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(v=>{const m=c._reverseStreams[v],_=c._streams[m.id];h=h.replace(new RegExp(_.id,"g"),m.id)}),new RTCSessionDescription({type:l.type,sdp:h})}function s(c,l){let h=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(v=>{const m=c._reverseStreams[v],_=c._streams[m.id];h=h.replace(new RegExp(m.id,"g"),_.id)}),new RTCSessionDescription({type:l.type,sdp:h})}["createOffer","createAnswer"].forEach(function(c){const l=e.RTCPeerConnection.prototype[c],h={[c](){const v=arguments;return arguments.length&&typeof arguments[0]=="function"?l.apply(this,[_=>{const C=a(this,_);v[0].apply(null,[C])},_=>{v[1]&&v[1].apply(null,_)},arguments[2]]):l.apply(this,arguments).then(_=>a(this,_))}};e.RTCPeerConnection.prototype[c]=h[c]});const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=s(this,arguments[0]),o.apply(this,arguments))};const u=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const c=u.get.apply(this);return c.type===""?c:a(this,c)}}),e.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(l._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let v;Object.keys(this._streams).forEach(m=>{this._streams[m].getTracks().find(C=>l.track===C)&&(v=this._streams[m])}),v&&(v.getTracks().length===1?this.removeStream(this._reverseStreams[v.id]):v.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function nv(e,r){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&r.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]})}function t$(e,r){ps(e,"negotiationneeded",t=>{const n=t.target;if(!((r.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const t0=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:t$,shimAddTrackRemoveTrack:e$,shimAddTrackRemoveTrackWithNative:Z1,shimGetSendersWithDtmf:X1,shimGetUserMedia:K1,shimMediaStream:J1,shimOnTrack:Y1,shimPeerConnection:nv,shimSenderReceiverGetStats:Q1},Symbol.toStringTag,{value:"Module"}));function r$(e,r){const t=e&&e.navigator,n=e&&e.MediaStreamTrack;if(t.getUserMedia=function(i,a,s){yg("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(a,s)},!(r.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(s,o,u){o in s&&!(u in s)&&(s[u]=s[o],delete s[o])},a=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(s){return typeof s=="object"&&typeof s.audio=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s.audio,"autoGainControl","mozAutoGainControl"),i(s.audio,"noiseSuppression","mozNoiseSuppression")),a(s)},n&&n.prototype.getSettings){const s=n.prototype.getSettings;n.prototype.getSettings=function(){const o=s.apply(this,arguments);return i(o,"mozAutoGainControl","autoGainControl"),i(o,"mozNoiseSuppression","noiseSuppression"),o}}if(n&&n.prototype.applyConstraints){const s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o,"autoGainControl","mozAutoGainControl"),i(o,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[o])}}}}function AQ(e,r){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){const i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return n.video===!0?n.video={mediaSource:r}:n.video.mediaSource=r,e.navigator.mediaDevices.getUserMedia(n)})}function n$(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function iv(e,r){if(typeof e!="object"||!(e.RTCPeerConnection||e.mozRTCPeerConnection))return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),r.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const a=e.RTCPeerConnection.prototype[i],s={[i](){return arguments[0]=new(i==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),a.apply(this,arguments)}};e.RTCPeerConnection.prototype[i]=s[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[a,s,o]=arguments;return n.apply(this,[a||null]).then(u=>{if(r.version<53&&!s)try{u.forEach(c=>{c.type=t[c.type]||c.type})}catch(c){if(c.name!=="TypeError")throw c;u.forEach((l,h)=>{u.set(h,Object.assign({},l,{type:t[l.type]||l.type}))})}return u}).then(s,o)}}function i$(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const r=e.RTCPeerConnection.prototype.getSenders;r&&(e.RTCPeerConnection.prototype.getSenders=function(){const i=r.apply(this,[]);return i.forEach(a=>a._pc=this),i});const t=e.RTCPeerConnection.prototype.addTrack;t&&(e.RTCPeerConnection.prototype.addTrack=function(){const i=t.apply(this,arguments);return i._pc=this,i}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function a$(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){const n=r.apply(this,[]);return n.forEach(i=>i._pc=this),n}),ps(e,"track",t=>(t.receiver._pc=t.srcElement,t)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function s$(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){yg("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function o$(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function u$(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.addTransceiver;r&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let n=arguments[1]&&arguments[1].sendEncodings;n===void 0&&(n=[]),n=[...n];const i=n.length>0;i&&n.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const a=r.apply(this,arguments);if(i){const{sender:s}=a,o=s.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=n,s.sendEncodings=n,this.setParametersPromises.push(s.setParameters(o).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return a})}function c$(e){if(!(typeof e=="object"&&e.RTCRtpSender))return;const r=e.RTCRtpSender.prototype.getParameters;r&&(e.RTCRtpSender.prototype.getParameters=function(){const n=r.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function l$(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}function f$(e){if(!(typeof e=="object"&&e.RTCPeerConnection))return;const r=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}const r0=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:u$,shimCreateAnswer:f$,shimCreateOffer:l$,shimGetDisplayMedia:AQ,shimGetParameters:c$,shimGetUserMedia:r$,shimOnTrack:n$,shimPeerConnection:iv,shimRTCDataChannel:o$,shimReceiverGetStats:a$,shimRemoveStream:s$,shimSenderGetStats:i$},Symbol.toStringTag,{value:"Module"}));function d$(e){if(!(typeof e!="object"||!e.RTCPeerConnection)){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(i=>r.call(this,i,n)),n.getVideoTracks().forEach(i=>r.call(this,i,n))},e.RTCPeerConnection.prototype.addTrack=function(n,...i){return i&&i.forEach(a=>{this._localStreams?this._localStreams.includes(a)||this._localStreams.push(a):this._localStreams=[a]}),r.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);const i=t.getTracks();this.getSenders().forEach(a=>{i.includes(a.track)&&this.removeTrack(a)})})}}function p$(e){if(!(typeof e!="object"||!e.RTCPeerConnection)&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const a=new Event("addstream");a.stream=i,this.dispatchEvent(a)})})}});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(i){i.streams.forEach(a=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(a)>=0)return;n._remoteStreams.push(a);const s=new Event("addstream");s.stream=a,n.dispatchEvent(s)})}),r.apply(n,arguments)}}}function h$(e){if(typeof e!="object"||!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,t=r.createOffer,n=r.createAnswer,i=r.setLocalDescription,a=r.setRemoteDescription,s=r.addIceCandidate;r.createOffer=function(c,l){const h=arguments.length>=2?arguments[2]:arguments[0],v=t.apply(this,[h]);return l?(v.then(c,l),Promise.resolve()):v},r.createAnswer=function(c,l){const h=arguments.length>=2?arguments[2]:arguments[0],v=n.apply(this,[h]);return l?(v.then(c,l),Promise.resolve()):v};let o=function(u,c,l){const h=i.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h};r.setLocalDescription=o,o=function(u,c,l){const h=a.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h},r.setRemoteDescription=o,o=function(u,c,l){const h=s.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h},r.addIceCandidate=o}function v$(e){const r=e&&e.navigator;if(r.mediaDevices&&r.mediaDevices.getUserMedia){const t=r.mediaDevices,n=t.getUserMedia.bind(t);r.mediaDevices.getUserMedia=i=>n(m$(i))}!r.getUserMedia&&r.mediaDevices&&r.mediaDevices.getUserMedia&&(r.getUserMedia=(function(n,i,a){r.mediaDevices.getUserMedia(n).then(i,a)}).bind(r))}function m$(e){return e&&e.video!==void 0?Object.assign({},e,{video:H1(e.video)}):e}function g$(e){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection;e.RTCPeerConnection=function(n,i){if(n&&n.iceServers){const a=[];for(let s=0;s<n.iceServers.length;s++){let o=n.iceServers[s];o.urls===void 0&&o.url?(yg("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,a.push(o)):a.push(n.iceServers[s])}n.iceServers=a}return new r(n,i)},e.RTCPeerConnection.prototype=r.prototype,"generateCertificate"in r&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get(){return r.generateCertificate}})}function y$(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function b$(e){const r=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const i=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveAudio===!0&&!i&&this.addTransceiver("audio",{direction:"recvonly"}),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const a=this.getTransceivers().find(s=>s.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&a?a.direction==="sendrecv"?a.setDirection?a.setDirection("sendonly"):a.direction="sendonly":a.direction==="recvonly"&&(a.setDirection?a.setDirection("inactive"):a.direction="inactive"):n.offerToReceiveVideo===!0&&!a&&this.addTransceiver("video",{direction:"recvonly"})}return r.apply(this,arguments)}}function _$(e){typeof e!="object"||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}const n0=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:_$,shimCallbacksAPI:h$,shimConstraints:m$,shimCreateOfferLegacy:b$,shimGetUserMedia:v$,shimLocalStreamsAPI:d$,shimRTCIceServerUrls:g$,shimRemoteStreamsAPI:p$,shimTrackEventTransceiver:y$},Symbol.toStringTag,{value:"Module"}));var w$={exports:{}};(function(e){const r={};r.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},r.localCName=r.generateIdentifier(),r.splitLines=function(t){return t.trim().split(`
490
490
  `).map(n=>n.trim())},r.splitSections=function(t){return t.split(`
491
491
  m=`).map((i,a)=>(a>0?"m="+i:i).trim()+`\r
492
492
  `)},r.getDescription=function(t){const n=r.splitSections(t);return n&&n[0]},r.getMediaSections=function(t){const n=r.splitSections(t);return n.shift(),n},r.matchPrefix=function(t,n){return r.splitLines(t).filter(i=>i.indexOf(n)===0)},r.parseCandidate=function(t){let n;t.indexOf("a=candidate:")===0?n=t.substring(12).split(" "):n=t.substring(10).split(" ");const i={foundation:n[0],component:{1:"rtp",2:"rtcp"}[n[1]]||n[1],protocol:n[2].toLowerCase(),priority:parseInt(n[3],10),ip:n[4],address:n[4],port:parseInt(n[5],10),type:n[7]};for(let a=8;a<n.length;a+=2)switch(n[a]){case"raddr":i.relatedAddress=n[a+1];break;case"rport":i.relatedPort=parseInt(n[a+1],10);break;case"tcptype":i.tcpType=n[a+1];break;case"ufrag":i.ufrag=n[a+1],i.usernameFragment=n[a+1];break;default:i[n[a]]===void 0&&(i[n[a]]=n[a+1]);break}return i},r.writeCandidate=function(t){const n=[];n.push(t.foundation);const i=t.component;i==="rtp"?n.push(1):i==="rtcp"?n.push(2):n.push(i),n.push(t.protocol.toUpperCase()),n.push(t.priority),n.push(t.address||t.ip),n.push(t.port);const a=t.type;return n.push("typ"),n.push(a),a!=="host"&&t.relatedAddress&&t.relatedPort&&(n.push("raddr"),n.push(t.relatedAddress),n.push("rport"),n.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(n.push("tcptype"),n.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(n.push("ufrag"),n.push(t.usernameFragment||t.ufrag)),"candidate:"+n.join(" ")},r.parseIceOptions=function(t){return t.substring(14).split(" ")},r.parseRtpMap=function(t){let n=t.substring(9).split(" ");const i={payloadType:parseInt(n.shift(),10)};return n=n[0].split("/"),i.name=n[0],i.clockRate=parseInt(n[1],10),i.channels=n.length===3?parseInt(n[2],10):1,i.numChannels=i.channels,i},r.writeRtpMap=function(t){let n=t.payloadType;t.preferredPayloadType!==void 0&&(n=t.preferredPayloadType);const i=t.channels||t.numChannels||1;return"a=rtpmap:"+n+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
@@ -517,9 +517,9 @@ a=ice-pwd:`+t.password+`\r
517
517
  o=`+(i||"thisisadapterortc")+" "+a+" "+s+` IN IP4 127.0.0.1\r
518
518
  s=-\r
519
519
  t=0 0\r
520
- `},r.getDirection=function(t,n){const i=r.splitLines(t);for(let a=0;a<i.length;a++)switch(i[a]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[a].substring(2)}return n?r.getDirection(n):"sendrecv"},r.getKind=function(t){return r.splitLines(t)[0].split(" ")[0].substring(2)},r.isRejected=function(t){return t.split(" ",2)[1]==="0"},r.parseMLine=function(t){const i=r.splitLines(t)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},r.parseOLine=function(t){const i=r.matchPrefix(t,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},r.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;const n=r.splitLines(t);for(let i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},e.exports=r})(_$);var w$=_$.exports;const Ws=I0(w$),PQ=F$({__proto__:null,default:Ws},[w$]);function il(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const r=e.RTCIceCandidate;e.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&(n=JSON.parse(JSON.stringify(n)),n.candidate=n.candidate.substring(2)),n.candidate&&n.candidate.length){const i=new r(n),a=Ws.parseCandidate(n.candidate);for(const s in a)s in i||Object.defineProperty(i,s,{value:a[s]});return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new r(n)},e.RTCIceCandidate.prototype=r.prototype,ps(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function av(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||ps(e,"icecandidate",r=>{if(r.candidate){const t=Ws.parseCandidate(r.candidate.candidate);t.type==="relay"&&(r.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return r})}function al(e,r){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(o){if(!o||!o.sdp)return!1;const u=Ws.splitSections(o.sdp);return u.shift(),u.some(c=>{const l=Ws.parseMLine(c);return l&&l.kind==="application"&&l.protocol.indexOf("SCTP")!==-1})},n=function(o){const u=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(u===null||u.length<2)return-1;const c=parseInt(u[1],10);return c!==c?-1:c},i=function(o){let u=65536;return r.browser==="firefox"&&(r.version<57?o===-1?u=16384:u=2147483637:r.version<60?u=r.version===57?65535:65536:u=2147483637),u},a=function(o,u){let c=65536;r.browser==="firefox"&&r.version===57&&(c=65535);const l=Ws.matchPrefix(o.sdp,"a=max-message-size:");return l.length>0?c=parseInt(l[0].substring(19),10):r.browser==="firefox"&&u!==-1&&(c=2147483637),c},s=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,r.browser==="chrome"&&r.version>=76){const{sdpSemantics:u}=this.getConfiguration();u==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const u=n(arguments[0]),c=i(u),l=a(arguments[0],u);let h;c===0&&l===0?h=Number.POSITIVE_INFINITY:c===0||l===0?h=Math.max(c,l):h=Math.min(c,l);const v={};Object.defineProperty(v,"maxMessageSize",{get(){return h}}),this._sctp=v}return s.apply(this,arguments)}}function sl(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function r(n,i){const a=n.send;n.send=function(){const o=arguments[0],u=o.length||o.size||o.byteLength;if(n.readyState==="open"&&i.sctp&&u>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return a.apply(n,arguments)}}const t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const i=t.apply(this,arguments);return r(i,this),i},ps(e,"datachannel",n=>(r(n.channel,n.target),n))}function sv(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype;Object.defineProperty(r,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(r,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=r[t];r[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const a=i.target;if(a._lastConnectionState!==a.connectionState){a._lastConnectionState=a.connectionState;const s=new Event("connectionstatechange",i);a.dispatchEvent(s)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function ov(e,r){if(!e.RTCPeerConnection||r.browser==="chrome"&&r.version>=71||r.browser==="safari"&&r.version>=605)return;const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
520
+ `},r.getDirection=function(t,n){const i=r.splitLines(t);for(let a=0;a<i.length;a++)switch(i[a]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[a].substring(2)}return n?r.getDirection(n):"sendrecv"},r.getKind=function(t){return r.splitLines(t)[0].split(" ")[0].substring(2)},r.isRejected=function(t){return t.split(" ",2)[1]==="0"},r.parseMLine=function(t){const i=r.splitLines(t)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},r.parseOLine=function(t){const i=r.matchPrefix(t,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},r.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;const n=r.splitLines(t);for(let i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},e.exports=r})(w$);var S$=w$.exports;const Ws=O0(S$),MQ=U$({__proto__:null,default:Ws},[S$]);function il(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const r=e.RTCIceCandidate;e.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&(n=JSON.parse(JSON.stringify(n)),n.candidate=n.candidate.substring(2)),n.candidate&&n.candidate.length){const i=new r(n),a=Ws.parseCandidate(n.candidate);for(const s in a)s in i||Object.defineProperty(i,s,{value:a[s]});return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new r(n)},e.RTCIceCandidate.prototype=r.prototype,ps(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function av(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||ps(e,"icecandidate",r=>{if(r.candidate){const t=Ws.parseCandidate(r.candidate.candidate);t.type==="relay"&&(r.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return r})}function al(e,r){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(o){if(!o||!o.sdp)return!1;const u=Ws.splitSections(o.sdp);return u.shift(),u.some(c=>{const l=Ws.parseMLine(c);return l&&l.kind==="application"&&l.protocol.indexOf("SCTP")!==-1})},n=function(o){const u=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(u===null||u.length<2)return-1;const c=parseInt(u[1],10);return c!==c?-1:c},i=function(o){let u=65536;return r.browser==="firefox"&&(r.version<57?o===-1?u=16384:u=2147483637:r.version<60?u=r.version===57?65535:65536:u=2147483637),u},a=function(o,u){let c=65536;r.browser==="firefox"&&r.version===57&&(c=65535);const l=Ws.matchPrefix(o.sdp,"a=max-message-size:");return l.length>0?c=parseInt(l[0].substring(19),10):r.browser==="firefox"&&u!==-1&&(c=2147483637),c},s=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,r.browser==="chrome"&&r.version>=76){const{sdpSemantics:u}=this.getConfiguration();u==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const u=n(arguments[0]),c=i(u),l=a(arguments[0],u);let h;c===0&&l===0?h=Number.POSITIVE_INFINITY:c===0||l===0?h=Math.max(c,l):h=Math.min(c,l);const v={};Object.defineProperty(v,"maxMessageSize",{get(){return h}}),this._sctp=v}return s.apply(this,arguments)}}function sl(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function r(n,i){const a=n.send;n.send=function(){const o=arguments[0],u=o.length||o.size||o.byteLength;if(n.readyState==="open"&&i.sctp&&u>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return a.apply(n,arguments)}}const t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const i=t.apply(this,arguments);return r(i,this),i},ps(e,"datachannel",n=>(r(n.channel,n.target),n))}function sv(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype;Object.defineProperty(r,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(r,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=r[t];r[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const a=i.target;if(a._lastConnectionState!==a.connectionState){a._lastConnectionState=a.connectionState;const s=new Event("connectionstatechange",i);a.dispatchEvent(s)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function ov(e,r){if(!e.RTCPeerConnection||r.browser==="chrome"&&r.version>=71||r.browser==="safari"&&r.version>=605)return;const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(i){if(i&&i.sdp&&i.sdp.indexOf(`
521
521
  a=extmap-allow-mixed`)!==-1){const a=i.sdp.split(`
522
522
  `).filter(s=>s.trim()!=="a=extmap-allow-mixed").join(`
523
- `);e.RTCSessionDescription&&i instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:i.type,sdp:a}):i.sdp=a}return t.apply(this,arguments)}}function ol(e,r){if(!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype))return;const t=e.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(r.browser==="chrome"&&r.version<78||r.browser==="firefox"&&r.version<68||r.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function ul(e,r){if(!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype))return;const t=e.RTCPeerConnection.prototype.setLocalDescription;!t||t.length===0||(e.RTCPeerConnection.prototype.setLocalDescription=function(){let i=arguments[0]||{};if(typeof i!="object"||i.type&&i.sdp)return t.apply(this,arguments);if(i={type:i.type,sdp:i.sdp},!i.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":i.type="offer";break;default:i.type="answer";break}return i.sdp||i.type!=="offer"&&i.type!=="answer"?t.apply(this,[i]):(i.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(s=>t.apply(this,[s]))})}const AQ=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:ov,shimAddIceCandidateNullOrEmpty:ol,shimConnectionState:sv,shimMaxMessageSize:al,shimParameterlessSetLocalDescription:ul,shimRTCIceCandidate:il,shimRTCIceCandidateRelayProtocol:av,shimSendThrowTypeError:sl},Symbol.toStringTag,{value:"Module"}));function MQ({window:e}={},r={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const t=V1,n=IQ(e),i={browserDetails:n,commonShim:AQ,extractVersion:nl,disableLog:RQ,disableWarnings:$Q,sdp:PQ};switch(n.browser){case"chrome":if(!e0||!nv||!r.shimChrome)return t("Chrome shim is not included in this adapter release."),i;if(n.version===null)return t("Chrome shim can not determine version, not shimming."),i;t("adapter.js shimming chrome."),i.browserShim=e0,ol(e,n),ul(e),H1(e,n),K1(e),nv(e,n),J1(e),Z1(e,n),Y1(e),X1(e),e$(e,n),il(e),av(e),sv(e),al(e,n),sl(e),ov(e,n);break;case"firefox":if(!t0||!iv||!r.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=t0,ol(e,n),ul(e),t$(e,n),iv(e,n),r$(e),a$(e),n$(e),i$(e),s$(e),o$(e),u$(e),c$(e),l$(e),il(e),sv(e),al(e,n),sl(e);break;case"safari":if(!r0||!r.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=r0,ol(e,n),ul(e),m$(e),y$(e),p$(e),f$(e),d$(e),g$(e),h$(e),b$(e),il(e),av(e),al(e,n),sl(e),ov(e,n);break;default:t("Unsupported browser!");break}return i}MQ({window:typeof window>"u"?void 0:window});var Xi={},S$={},C$={exports:{}},n0=C$.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var r="candidate:%s %d %s %d %s %d typ %s";return r+=e.raddr!=null?" raddr %s rport %d":"%v%v",r+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(r+=" generation %d"),r+=e["network-id"]!=null?" network-id %d":"%v",r+=e["network-cost"]!=null?" network-cost %d":"%v",r}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var r="ssrc:%d";return e.attribute!=null&&(r+=" %s",e.value!=null&&(r+=":%s")),r}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var r="mediaclk:";return r+=e.id!=null?"id=%s %s":"%v%s",r+=e.mediaClockValue!=null?"=%s":"",r+=e.rateNumerator!=null?" rate=%s":"",r+=e.rateDenominator!=null?"/%s":"",r}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(n0).forEach(function(e){var r=n0[e];r.forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})});var T$=C$.exports;(function(e){var r=function(o){return String(Number(o))===o?Number(o):o},t=function(o,u,c,l){if(l&&!c)u[l]=r(o[1]);else for(var h=0;h<c.length;h+=1)o[h+1]!=null&&(u[c[h]]=r(o[h+1]))},n=function(o,u,c){var l=o.name&&o.names;o.push&&!u[o.push]?u[o.push]=[]:l&&!u[o.name]&&(u[o.name]={});var h=o.push?{}:l?u[o.name]:u;t(c.match(o.reg),h,o.names,o.name),o.push&&u[o.push].push(h)},i=T$,a=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(o){var u={},c=[],l=u;return o.split(/(\r\n|\r|\n)/).filter(a).forEach(function(h){var v=h[0],m=h.slice(2);v==="m"&&(c.push({rtp:[],fmtp:[]}),l=c[c.length-1]);for(var _=0;_<(i[v]||[]).length;_+=1){var C=i[v][_];if(C.reg.test(m))return n(C,l,m)}}),u.media=c,u};var s=function(o,u){var c=u.split(/=(.+)/,2);return c.length===2?o[c[0]]=r(c[1]):c.length===1&&u.length>1&&(o[c[0]]=void 0),o};e.parseParams=function(o){return o.split(/;\s?/).reduce(s,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(o){return o.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(o){for(var u=[],c=o.split(" ").map(r),l=0;l<c.length;l+=3)u.push({component:c[l],ip:c[l+1],port:c[l+2]});return u},e.parseImageAttributes=function(o){return o.split(" ").map(function(u){return u.substring(1,u.length-1).split(",").reduce(s,{})})},e.parseSimulcastStreamList=function(o){return o.split(";").map(function(u){return u.split(",").map(function(c){var l,h=!1;return c[0]!=="~"?l=r(c):(l=r(c.substring(1,c.length)),h=!0),{scid:l,paused:h}})})}})(S$);var Lp=T$,xQ=/%[sdv%]/g,NQ=function(e){var r=1,t=arguments,n=t.length;return e.replace(xQ,function(i){if(r>=n)return i;var a=t[r];switch(r+=1,i){case"%%":return"%";case"%s":return String(a);case"%d":return Number(a);case"%v":return""}})},Mo=function(e,r,t){var n=r.format instanceof Function?r.format(r.push?t:t[r.name]):r.format,i=[e+"="+n];if(r.names)for(var a=0;a<r.names.length;a+=1){var s=r.names[a];r.name?i.push(t[r.name][s]):i.push(t[r.names[a]])}else i.push(t[r.name]);return NQ.apply(null,i)},LQ=["v","o","s","i","u","e","p","c","b","t","r","z","a"],DQ=["i","c","b","a"],jQ=function(e,r){r=r||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(a){a.payloads==null&&(a.payloads="")});var t=r.outerOrder||LQ,n=r.innerOrder||DQ,i=[];return t.forEach(function(a){Lp[a].forEach(function(s){s.name in e&&e[s.name]!=null?i.push(Mo(a,s,e)):s.push in e&&e[s.push]!=null&&e[s.push].forEach(function(o){i.push(Mo(a,s,o))})})}),e.media.forEach(function(a){i.push(Mo("m",Lp.m[0],a)),n.forEach(function(s){Lp[s].forEach(function(o){o.name in a&&a[o.name]!=null?i.push(Mo(s,o,a)):o.push in a&&a[o.push]!=null&&a[o.push].forEach(function(u){i.push(Mo(s,o,u))})})})}),i.join(`\r
523
+ `);e.RTCSessionDescription&&i instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:i.type,sdp:a}):i.sdp=a}return t.apply(this,arguments)}}function ol(e,r){if(!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype))return;const t=e.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(r.browser==="chrome"&&r.version<78||r.browser==="firefox"&&r.version<68||r.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function ul(e,r){if(!(e.RTCPeerConnection&&e.RTCPeerConnection.prototype))return;const t=e.RTCPeerConnection.prototype.setLocalDescription;!t||t.length===0||(e.RTCPeerConnection.prototype.setLocalDescription=function(){let i=arguments[0]||{};if(typeof i!="object"||i.type&&i.sdp)return t.apply(this,arguments);if(i={type:i.type,sdp:i.sdp},!i.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":i.type="offer";break;default:i.type="answer";break}return i.sdp||i.type!=="offer"&&i.type!=="answer"?t.apply(this,[i]):(i.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(s=>t.apply(this,[s]))})}const xQ=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:ov,shimAddIceCandidateNullOrEmpty:ol,shimConnectionState:sv,shimMaxMessageSize:al,shimParameterlessSetLocalDescription:ul,shimRTCIceCandidate:il,shimRTCIceCandidateRelayProtocol:av,shimSendThrowTypeError:sl},Symbol.toStringTag,{value:"Module"}));function NQ({window:e}={},r={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const t=G1,n=PQ(e),i={browserDetails:n,commonShim:xQ,extractVersion:nl,disableLog:IQ,disableWarnings:OQ,sdp:MQ};switch(n.browser){case"chrome":if(!t0||!nv||!r.shimChrome)return t("Chrome shim is not included in this adapter release."),i;if(n.version===null)return t("Chrome shim can not determine version, not shimming."),i;t("adapter.js shimming chrome."),i.browserShim=t0,ol(e,n),ul(e),K1(e,n),J1(e),nv(e,n),Y1(e),e$(e,n),X1(e),Q1(e),t$(e,n),il(e),av(e),sv(e),al(e,n),sl(e),ov(e,n);break;case"firefox":if(!r0||!iv||!r.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=r0,ol(e,n),ul(e),r$(e,n),iv(e,n),n$(e),s$(e),i$(e),a$(e),o$(e),u$(e),c$(e),l$(e),f$(e),il(e),sv(e),al(e,n),sl(e);break;case"safari":if(!n0||!r.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=n0,ol(e,n),ul(e),g$(e),b$(e),h$(e),d$(e),p$(e),y$(e),v$(e),_$(e),il(e),av(e),al(e,n),sl(e),ov(e,n);break;default:t("Unsupported browser!");break}return i}NQ({window:typeof window>"u"?void 0:window});var Xi={},C$={},T$={exports:{}},i0=T$.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var r="candidate:%s %d %s %d %s %d typ %s";return r+=e.raddr!=null?" raddr %s rport %d":"%v%v",r+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(r+=" generation %d"),r+=e["network-id"]!=null?" network-id %d":"%v",r+=e["network-cost"]!=null?" network-cost %d":"%v",r}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var r="ssrc:%d";return e.attribute!=null&&(r+=" %s",e.value!=null&&(r+=":%s")),r}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var r="mediaclk:";return r+=e.id!=null?"id=%s %s":"%v%s",r+=e.mediaClockValue!=null?"=%s":"",r+=e.rateNumerator!=null?" rate=%s":"",r+=e.rateDenominator!=null?"/%s":"",r}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(i0).forEach(function(e){var r=i0[e];r.forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})});var E$=T$.exports;(function(e){var r=function(o){return String(Number(o))===o?Number(o):o},t=function(o,u,c,l){if(l&&!c)u[l]=r(o[1]);else for(var h=0;h<c.length;h+=1)o[h+1]!=null&&(u[c[h]]=r(o[h+1]))},n=function(o,u,c){var l=o.name&&o.names;o.push&&!u[o.push]?u[o.push]=[]:l&&!u[o.name]&&(u[o.name]={});var h=o.push?{}:l?u[o.name]:u;t(c.match(o.reg),h,o.names,o.name),o.push&&u[o.push].push(h)},i=E$,a=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(o){var u={},c=[],l=u;return o.split(/(\r\n|\r|\n)/).filter(a).forEach(function(h){var v=h[0],m=h.slice(2);v==="m"&&(c.push({rtp:[],fmtp:[]}),l=c[c.length-1]);for(var _=0;_<(i[v]||[]).length;_+=1){var C=i[v][_];if(C.reg.test(m))return n(C,l,m)}}),u.media=c,u};var s=function(o,u){var c=u.split(/=(.+)/,2);return c.length===2?o[c[0]]=r(c[1]):c.length===1&&u.length>1&&(o[c[0]]=void 0),o};e.parseParams=function(o){return o.split(/;\s?/).reduce(s,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(o){return o.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(o){for(var u=[],c=o.split(" ").map(r),l=0;l<c.length;l+=3)u.push({component:c[l],ip:c[l+1],port:c[l+2]});return u},e.parseImageAttributes=function(o){return o.split(" ").map(function(u){return u.substring(1,u.length-1).split(",").reduce(s,{})})},e.parseSimulcastStreamList=function(o){return o.split(";").map(function(u){return u.split(",").map(function(c){var l,h=!1;return c[0]!=="~"?l=r(c):(l=r(c.substring(1,c.length)),h=!0),{scid:l,paused:h}})})}})(C$);var Lp=E$,LQ=/%[sdv%]/g,DQ=function(e){var r=1,t=arguments,n=t.length;return e.replace(LQ,function(i){if(r>=n)return i;var a=t[r];switch(r+=1,i){case"%%":return"%";case"%s":return String(a);case"%d":return Number(a);case"%v":return""}})},Mo=function(e,r,t){var n=r.format instanceof Function?r.format(r.push?t:t[r.name]):r.format,i=[e+"="+n];if(r.names)for(var a=0;a<r.names.length;a+=1){var s=r.names[a];r.name?i.push(t[r.name][s]):i.push(t[r.names[a]])}else i.push(t[r.name]);return DQ.apply(null,i)},jQ=["v","o","s","i","u","e","p","c","b","t","r","z","a"],FQ=["i","c","b","a"],UQ=function(e,r){r=r||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(a){a.payloads==null&&(a.payloads="")});var t=r.outerOrder||jQ,n=r.innerOrder||FQ,i=[];return t.forEach(function(a){Lp[a].forEach(function(s){s.name in e&&e[s.name]!=null?i.push(Mo(a,s,e)):s.push in e&&e[s.push]!=null&&e[s.push].forEach(function(o){i.push(Mo(a,s,o))})})}),e.media.forEach(function(a){i.push(Mo("m",Lp.m[0],a)),n.forEach(function(s){Lp[s].forEach(function(o){o.name in a&&a[o.name]!=null?i.push(Mo(s,o,a)):o.push in a&&a[o.push]!=null&&a[o.push].forEach(function(u){i.push(Mo(s,o,u))})})})}),i.join(`\r
524
524
  `)+`\r
525
- `},hs=S$,FQ=jQ;Xi.write=FQ;Xi.parse=hs.parse;Xi.parseParams=hs.parseParams;Xi.parseFmtpConfig=hs.parseFmtpConfig;Xi.parsePayloads=hs.parsePayloads;Xi.parseRemoteCandidates=hs.parseRemoteCandidates;Xi.parseImageAttributes=hs.parseImageAttributes;Xi.parseSimulcastStreamList=hs.parseSimulcastStreamList;var Qi={},UQ=Ae&&Ae.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;for(var n=Array(e),i=0,r=0;r<t;r++)for(var a=arguments[r],s=0,o=a.length;s<o;s++,i++)n[i]=a[s];return n};Object.defineProperty(Qi,"__esModule",{value:!0});var E$=function(){function e(r,t,n){this.name=r,this.version=t,this.os=n}return e}();Qi.BrowserInfo=E$;var k$=function(){function e(r){this.version=r,this.name="node",this.os=process.platform}return e}();Qi.NodeInfo=k$;var R$=function(){function e(){this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}();Qi.BotInfo=R$;var BQ=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,qQ=/(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves\/Teoma)|(ia_archiver)/,i0=3,zQ=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["vivaldi",/Vivaldi\/([0-9\.]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/Edg\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",BQ]],a0=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/],["Search Bot",qQ]];function WQ(e){return e?uv(e):typeof navigator<"u"?uv(navigator.userAgent):I$()}Qi.detect=WQ;function uv(e){var r=e!==""&&zQ.reduce(function(a,s){var o=s[0],u=s[1];if(a)return a;var c=u.exec(e);return!!c&&[o,c]},!1);if(!r)return null;var t=r[0],n=r[1];if(t==="searchbot")return new R$;var i=n[1]&&n[1].split(/[._]/).slice(0,3);return i?i.length<i0&&(i=UQ(i,VQ(i0-i.length))):i=[],new E$(t,i.join("."),$$(e))}Qi.parseUserAgent=uv;function $$(e){for(var r=0,t=a0.length;r<t;r++){var n=a0[r],i=n[0],a=n[1],s=a.test(e);if(s)return i}return null}Qi.detectOS=$$;function I$(){var e=typeof process<"u"&&process.version;return e?new k$(process.version.slice(1)):null}Qi.getNodeVersion=I$;function VQ(e){for(var r=[],t=0;t<e;t++)r.push("0");return r}var jc={exports:{}};function GQ(e,r){if(typeof e[Symbol.iterator]=="function")for(const t of e){const n=Array.isArray(t)?t[1]:t;r(n)}else for(const t in e)if(e.hasOwnProperty(t)){const n=e[t];r(n)}}var O$={iterateReports:GQ};const HQ={"outbound-rtp":{packetsSent:"audioSentPackets",bytesSent:"audioSentBytes"},"inbound-rtp":{packetsReceived:"audioRecvPackets",packetsLost:"audioRecvPacketsLost",bytesReceived:"audioRecvBytes",jitter:"audioRecvJitter"},"remote-inbound-rtp":{packetsLost:"audioSentPacketsLost",roundTripTime:"audioRtt",jitter:"audioSentJitter"}},KQ={"remote-candidate":function(e){return Fc(e)},"inbound-rtp":function(e){return Fc(e)},"outbound-rtp":function(e){return Fc(e)},"remote-inbound-rtp":function(e){return Fc(e)}},Fc=e=>{const{type:r}=e,t=HQ[r],n={};for(let i in t)if(i in e){let a;typeof t[i]=="function"?a=t[i](e):a=t[i],n[a]=e[i]}else n[t[i]]=null;return n};var JQ={parsers:KQ};const{iterateReports:YQ}=O$;function XQ(e){let r=0,t=0,n=0,i=100,a=0,s,o,u;return YQ(e,c=>{c.type==="inbound-rtp"&&(r=c.jitter,n=c.packetsLost,t=c.packetsReceived)}),t+n>0&&(a=100*(n/(t+n))),s=i+r*2+10,s<160?o=93.2-s/40:o=93.2-(s-120)/10,o=o-a*2.5,o<1&&(o=1),u=1+.035*o+7e-6*o*(o-60)*(100-o),parseFloat(u).toFixed(6)}var P$=XQ;const{iterateReports:QQ}=O$,{parsers:s0}=JQ,ZQ=P$;function eZ(e){const r={};return QQ(e,t=>{if(t.type in s0){const n=s0[t.type](t);Object.assign(r,n)}}),r.networkMos=parseFloat(ZQ(e)),r}var tZ=eZ,o0;function rZ(){return o0||(o0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0});const n=tZ,i=P$,a=t(yi());class s{constructor(u){this.mos_report={min:5,max:0},this._reportsCount=0,this._mosSum=0,this.intervals=[],this._deprecationWarningSent=!1,!(!u||!u.application||!u.rtc_id||!u.pc)&&(this.conversation=null,this.application_id=null,this.attachHandlers(u),this.startSendingStats(u),this.startEmittingStats(u))}attachHandlers(u){const{pc:c}=u;c.addEventListener("connectionstatechange",()=>{switch(c.connectionState){case"disconnected":case"failed":case"closed":this.removeIntervals(),this.emitLastReport(u)}}),u.conversation?u.conversation.on("member:media",(h,v)=>{!this.application_id&&(u==null?void 0:u.rtc_id)===v.body.channel.id&&(this.application_id=v.application_id)}):u.application.on("member:joined",(h,v)=>{(!this.conversation||!this.application_id)&&(u==null?void 0:u.rtc_id)===v.body.channel.id&&(this.conversation=h.conversation,this.application_id=v.application_id)})}emitLastReport(u){const{application:c,conversation:l=null,rtc_id:h,config:{emit_events:v,emit_rtc_analytics:m}}=u,_=this.getMOSReport(),C=_.last;C&&(m&&c.emit("rtcstats:analytics",{type:"mos_report",mos:C,rtc_id:h,mos_report:_,api_key:c.session.apiKey,...this.application_id&&{application_id:this.application_id},...l&&{conversation_id:l.id,conversation_name:l.name}}),v&&(this._deprecationWarningSent||(this._deprecationWarningSent=!0,console.warn('"rtcstats:report" event is deprecated. Use "rtcstats:analytics" instead')),c.emit("rtcstats:report",C,null,l,_)))}startSendingStats(u){const{application:c,conversation:l=null,pc:h,rtc_id:v,config:{remote_collection:m,remote_collection_url:_,remote_collection_interval:C}}=u;if(!m)return;const I=setInterval(()=>{h.getStats(null).then($=>{var x;const N=(x=l??this.conversation)!==null&&x!==void 0?x:null;a.default.networkRequest({url:_,type:"POST",data:{...n($),legId:v,apiKey:c.session.apiKey,...this.application_id&&{applicationId:this.application_id},...N&&{conversationId:N.id,conversationName:N.name}}}).catch(()=>{})}).catch(()=>{}),(h.connectionState==="closed"||h.signalingState==="closed")&&this.removeIntervals()},C);this.intervals.push(I)}startEmittingStats(u){const{application:c,conversation:l=null,pc:h,rtc_id:v,config:{emit_events:m,emit_rtc_analytics:_,emit_interval:C}}=u;if(!m&&!_)return;const I=setInterval(()=>{var $;h.getStats(null).then(x=>{var N;const q=this.getMos(x);if(!q)return;const X=(N=l??this.conversation)!==null&&N!==void 0?N:null;_&&c.emit("rtcstats:analytics",{type:"mos",mos:q,report:x,rtc_id:v,api_key:c.session.apiKey,...this.application_id&&{application_id:this.application_id},...X&&{conversation_id:X.id,conversation_name:X.name}}),m&&(this._deprecationWarningSent||(this._deprecationWarningSent=!0,console.warn('"rtcstats:report" event is deprecated. Use "rtcstats:analytics" instead')),c.emit("rtcstats:report",q,x,l))}).catch(()=>{}),(h.connectionState==="closed"||h.signalingState==="closed")&&(this.removeIntervals(),this.emitLastReport({...u,conversation:($=l??this.conversation)!==null&&$!==void 0?$:null}))},C);this.intervals.push(I)}removeIntervals(){this.intervals.forEach(u=>clearInterval(u)),this.intervals=[]}getMos(u){const c=i(u);return this.updateMOSReport(parseInt(c)),c}updateMOSReport(u){this._reportsCount++,this._mosSum+=u,this.mos_report.last=u,this.mos_report.min=u<this.mos_report.min?u:this.mos_report.min,this.mos_report.max=u>this.mos_report.max?u:this.mos_report.max,this.mos_report.average=this._mosSum/this._reportsCount}getMOSReport(){return this.mos_report.min=s.normaliseFloat(this.mos_report.min),this.mos_report.max=s.normaliseFloat(this.mos_report.max),this.mos_report.last=s.normaliseFloat(this.mos_report.last),this.mos_report.average=s.normaliseFloat(this.mos_report.average),this.mos_report}static normaliseFloat(u){return parseFloat(u).toFixed(6)}}r.default=s,e.exports=s}(jc,jc.exports)),jc.exports}var u0;function If(){return u0||(u0=1,function(e,r){var t=Ae&&Ae.__createBinding||(Object.create?function(m,_,C,I){I===void 0&&(I=C),Object.defineProperty(m,I,{enumerable:!0,get:function(){return _[C]}})}:function(m,_,C,I){I===void 0&&(I=C),m[I]=_[C]}),n=Ae&&Ae.__setModuleDefault||(Object.create?function(m,_){Object.defineProperty(m,"default",{enumerable:!0,value:_})}:function(m,_){m.default=_}),i=Ae&&Ae.__importStar||function(m){if(m&&m.__esModule)return m;var _={};if(m!=null)for(var C in m)C!=="default"&&Object.hasOwnProperty.call(m,C)&&t(_,m,C);return n(_,m),_},a=Ae&&Ae.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(r,"__esModule",{value:!0});const s=Xi,o=gr,u=i(Qi),c=Mn,l=a(rZ()),h=2e4;class v{constructor(){this.log=o.getLogger(this.constructor.name)}static getUserAudio(_=!0){let C={video:!1,audio:_};return navigator.mediaDevices.getUserMedia(C)}createRTCPeerConnection(_){const C=new RTCPeerConnection(_);return C.trace=()=>{},C}_getWindowLocationProtocol(){return window.location.protocol}static _getBrowserName(){return u.detect().name}static isNode(){return this._getBrowserName()==="node"}checkValidKeys(_,C){let I=!0;return Object.keys(_).forEach($=>{C.hasOwnProperty($)||(I=!1)}),I}static cleanCallMediaIfFailed(_){setTimeout(()=>{_.conversation||(this.cleanMediaProperties(_),_.status=_.CALL_STATUS.FAILED,_.application.emit("call:status:changed",_))},5e3)}static callDisconnectHandler(_,C){const I=[_.CALL_STATUS.ANSWERED,_.CALL_STATUS.STARTED,_.CALL_STATUS.RINGING];if(!(C.connectionState!=="disconnected"||!_||!_.conversation))return setTimeout(()=>{C.connectionState==="connected"||I.indexOf(_.status)==-1||(this.cleanMediaProperties(_),_.status=_.CALL_STATUS.COMPLETED,_.application.emit("call:status:changed",_))},h)}static cleanMediaProperties(_){if(_.rtcObjects)for(const C in _.rtcObjects)_.rtcObjects[C].pc.close(),delete _.rtcObjects[C].pc,v.closeStream(_.rtcObjects[C].stream);_.application.activeStreams=[],_.rtcObjects={},_.conversation&&_.conversation.media&&(_.conversation.media.rtcStats=null)}static cleanConversationMediaProperties(_,C){C&&v.closeStream(C),_&&_.close()}static playAudioStream(_){const C=new Audio;return C.srcObject=_,C.autoplay=!0,C}static createDummyCandidateSDP(_){const C={foundation:1176891032,component:1,transport:"udp",priority:2122260223,ip:"0.0.0.0",port:9,type:"host",generation:0,"network-id":1,"network-cost":50},I=s.parse(_.localDescription.sdp);return I.media[0].candidates=[C],s.write(I)}static createRTCPeerConnectionConfig(_){return{iceTransportPolicy:"all",bundlePolicy:"balanced",rtcpMuxPolicy:"require",iceCandidatePoolSize:"0",..._.session.config&&_.session.config.iceServers&&{iceServers:_.session.config.iceServers}}}static setupPeerConnectionApplicationListeners(_,C){C.addEventListener("icecandidateerror",I=>_.emit("rtc:icecandidateerror",I)),C.addEventListener("icegatheringstatechange",()=>_.emit("rtc:icegatheringstatechange",C.iceGatheringState)),C.addEventListener("signalingstatechange",()=>_.emit("rtc:signalingstatechange",C.signalingState)),C.addEventListener("iceconnectionstatechange",()=>_.emit("rtc:iceconnectionstatechange",C.iceConnectionState)),C.addEventListener("connectionstatechange",()=>_.emit("rtc:peerconnectionstatechange",C.connectionState))}static createPeerConnection(_){const C=this.createRTCPeerConnectionConfig(_),I=new RTCPeerConnection(C);return this.setupPeerConnectionApplicationListeners(_,I),I}static sendOffer(_,C,I,$){const N={sdp:this.createDummyCandidateSDP(C)};let q={from:I.me.id,body:{offer:N}},X=`conversations/${I.id}/rtc`;return $&&(X+=`/${$}/offer`),_.session.sendNetworkRequest({type:"POST",path:X,data:q})}static sendAnswer(_,C,I,$){const x=this.createDummyCandidateSDP(C);let N={from:I.me.id,body:{answer:x}},q=`conversations/${I.id}/rtc/${$}/answer`;return _.session.sendNetworkRequest({type:"POST",path:q,data:N})}static createLeg(_,C){const $={sdp:this.createDummyCandidateSDP(C),type:"offer"};return _.session.sendNetworkRequest({type:"POST",path:"legs",version:"beta",data:{body:{offer:$}}})}static closeStream(_){_.getTracks().forEach(C=>{C.stop()})}static emitMediaStream(_,C,I){_.emit("media:stream:on",{pc:C,stream:I,type:"audio",streamIndex:0})}static _initStatsEvents(_){var C,I,$;if(!v.isNode()&&!(($=(I=(C=_==null?void 0:_.application)===null||C===void 0?void 0:C.session)===null||I===void 0?void 0:I.config)===null||$===void 0)&&$.rtcstats){const x=_.application.session.config.rtcstats,{emit_events:N,remote_collection:q,emit_rtc_analytics:X}=x;if(N||q||X){const J={..._,config:{...x}};return new l.default(J)}}}static attachConversationEventHandlers(_){const{conversation:C,pc:I,log:$}=_;C.once("rtc:answer",x=>{if(!I){$.warn("RTC: received an answer too late");return}I.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:x.body.answer}))})}static doAnswer(_,C,I){const{application:$,conversation:x,pc:N,reject:q,localStream:X}=_;this.addPeerConnectionListeners(_,()=>v.sendAnswer($,N,x,I).then(()=>({rtc_id:I}))),N.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:C})).then(()=>N.createAnswer()).then(J=>N.setLocalDescription(J)).catch(J=>{v.cleanConversationMediaProperties(N,X),q(J)})}static attachPeerConnectionEventHandlers(_){const{application:C,conversation:I,pc:$,reconnectRtcId:x}=_;this.addPeerConnectionListeners(_,()=>v.sendOffer(C,$,I,x))}static addPeerConnectionListeners(_,C){const{application:I,conversation:$,pc:x,streamIndex:N,localStream:q,log:X,rtcObjects:J,resolve:G,reject:L}=_;let te,se=!1,ne;$.id&&(ne=I.calls.get($.id)),x.ontrack=ge=>{te=ge.streams[0],I.activeStreams.push(te),v.emitMediaStream($.me,x,te)},x.addEventListener("connectionstatechange",ge=>this.onconnectionstatechangeHandler(x,X,ne,()=>G(te),()=>{v.cleanConversationMediaProperties(x,q),L()})),x.addEventListener("negotiationneeded",()=>this.onnegotiationneededHandler(x,ge=>{v.cleanConversationMediaProperties(x,q),L(ge)})),x.addEventListener("iceconnectionstatechange",ge=>this.oniceconnectionstatechange(ge,x,X,Y=>{v.cleanConversationMediaProperties(x,q),L(Y)})),x.addEventListener("icecandidate",async ge=>{if(ge.candidate&&!se&&x){se=!0;try{const{rtc_id:Y}=await C();v._initStatsEvents({application:I,rtc_id:Y,pc:x,conversation:$}),x.trace&&x.trace("rtc_id",Y),J[Y]={rtc_id:Y,pc:x,stream:q,type:"audio",streamIndex:N}}catch(Y){v.cleanConversationMediaProperties(x,q),L(new c.NexmoClientError(Y))}}}),q.getTracks().forEach(ge=>x.addTrack(ge))}static prewarmLeg(_){const C=_.application;return new Promise(async(I,$)=>{let x=!1,N,q,X={},J,G;const L=o.getLogger(this.constructor.name);try{G=await this.getUserAudio(),J=this.createPeerConnection(C),J.ontrack=te=>{N=te.streams[0],C.activeStreams.push(N)},J.addEventListener("connectionstatechange",te=>this.onconnectionstatechangeHandler(J,L,_,()=>I({stream:N,legId:q,rtcObjects:X}),()=>{v.cleanConversationMediaProperties(J,G),$()})),J.addEventListener("negotiationneeded",()=>this.onnegotiationneededHandler(J,te=>{v.cleanConversationMediaProperties(J,G),$(te)})),J.addEventListener("iceconnectionstatechange",te=>this.oniceconnectionstatechange(te,J,L,se=>{v.cleanConversationMediaProperties(J,G),$(se)})),J.addEventListener("icecandidate",async te=>{if(te.candidate&&!x&&J){x=!0;const{rtc_id:se,sdp:ne}=await this.createLeg(C,J);return v._initStatsEvents({application:C,rtc_id:se,pc:J}),q=se,X[q]={rtc_id:se,pc:J,stream:G,type:"audio",streamIndex:1},J.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:ne}))}}),G.getTracks().forEach(te=>J.addTrack(te))}catch(te){v.cleanConversationMediaProperties(J,G),$(new c.NexmoClientError(te))}})}}r.default=v,v.onconnectionstatechangeHandler=(m,_,C,I,$)=>{switch(m.connectionState){case"connected":_.info("The connection has become fully connected"),I();break;case"disconnected":if(!C)break;C.call_disconnect_timeout&&clearTimeout(C.call_disconnect_timeout),C.call_disconnect_timeout=v.callDisconnectHandler(C,m);break;case"failed":$(),_.info("One or more transports has terminated unexpectedly or in an error");break;case"closed":_.info("The connection has been closed");break}},v.oniceconnectionstatechange=(m,_,C,I)=>{switch(_.iceConnectionState){case"disconnected":C.warn("One or more transports is disconnected",_.iceConnectionState);break;case"failed":I(new c.NexmoClientError(m)),C.warn("One or more transports has terminated unexpectedly or in an error",m);break;default:C.info("The ice connection status changed",_.iceConnectionState)}},v.onnegotiationneededHandler=async(m,_)=>{try{const C=await m.createOffer();return m.setLocalDescription(C)}catch(C){_(new c.NexmoClientError(C))}},e.exports=v}(Dc,Dc.exports)),Dc.exports}var c0;function nZ(){return c0||(c0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=Mn,a=t(If()),s=t(yi()),o=t(Yi),u=t(x$()),c=t(Pf());class l{constructor(v){var m,_,C;const I=v instanceof u.default?v:null,$=v instanceof c.default?v:null;this.log=n.getLogger(this.constructor.name),I?(this.rtcHelper=new a.default,this.application=I.application,this.application.activeStreams=this.application.activeStreams||[],this.parentConversation=I,this.rtcObjects={},this.streamIndex=0,this.rtcstats_conf=((C=(_=(m=this.application)===null||m===void 0?void 0:m.session)===null||_===void 0?void 0:_.config)===null||C===void 0?void 0:C.rtcStats)||{},this.rtcStats=null):$?(this.rtcHelper=new a.default,this.application=$):this.log.warn("No conversation object in Media")}_attachEndingEventHandlers(){this.parentConversation&&(this.log.debug("attaching leave listeners in media for "+this.parentConversation.id),this.parentConversation.on("rtc:hangup",async v=>{let m;if(this.parentConversation.members.has(v.from))m=this.parentConversation.members.get(v.from);else try{m=await this.parentConversation.getMember(v.from)}catch(_){this.log.warn(`There is an error getting the member ${_}`)}m.user.id===this.application.me.id&&this.application.activeStreams.length&&this._cleanMediaProperties(),m.user.id===this.application.me.id&&m.transferred_from&&m.transferred_from.media._cleanMediaProperties(),m.user.id===this.application.me.id&&this.parentConversation.off("rtc:hangup")}))}_enableStatsEvents(){this.rtcstats_conf.emit_rtc_analytics=!0,this.rtcstats_conf.remote_collection=!0;const v=this._findRtcObjectByType("audio");!this.rtcStats&&v&&(this.log.debug(`enabling stats events for ${v.rtc_id}`),this.rtcStats=a.default._initStatsEvents({application:this.application,rtc_id:v.rtc_id,pc:this.pc,conversation:this.parentConversation}))}_disableStatsEvents(){this.rtcstats_conf.emit_events=!1,this.rtcstats_conf.emit_rtc_analytics=!1,this.rtcstats_conf.remote_collection=!1,this.rtcStats.removeIntervals(),delete this.rtcStats}_audioInitHandler(v={},m){return new Promise(async(_,C)=>{const I=this.streamIndex;this.streamIndex++;const{audioConstraints:$}=v;try{const x=await a.default.getUserAudio($),N=a.default.createPeerConnection(this.application);this.pc=N;const{application:q,log:X,parentConversation:J,rtcObjects:G}=this,L={pc:N,streamIndex:I,localStream:x,application:q,conversation:J,log:X,rtcObjects:G};m({...L,resolve:_,reject:C}),a.default.attachConversationEventHandlers(L),this._attachEndingEventHandlers()}catch(x){C(new i.NexmoClientError(x))}})}_execAnswer(v={}){const{offer:{sdp:m,leg_id:_}}=v;return this._audioInitHandler(v,C=>a.default.doAnswer(C,m,_))}_handleAudio(v={}){const{reconnectRtcId:m}=v;return this._audioInitHandler(v,_=>a.default.attachPeerConnectionEventHandlers({..._,reconnectRtcId:m}))}_findRtcObjectByType(v){return Object.values(this.rtcObjects).find(m=>m.type===v)}async _cleanConversationProperties(){this.pc&&this.pc.close(),delete this.pc,this.rtcStats=null,this.application.activeStreams=[],this.listeningToRtcEvent=!1,await Promise.resolve()}_cleanMediaProperties(){if(this.pc&&this.pc.close(),this.rtcObjects)for(const v in this.rtcObjects)a.default.closeStream(this.rtcObjects[v].stream);delete this.pc,this.rtcStats=null,this.application.activeStreams=[],this.rtcObjects={},this.listeningToRtcEvent=!1}async _disableLeg(v){const m=new Promise(async(C,I)=>{try{await this.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.parentConversation.id}/rtc/${v}?from=${this.parentConversation.me.id}&originating_session=${this.application.session.session_id}`,version:"beta2"}),C("rtc:terminate:success")}catch($){I(new i.NexmoApiError($))}}),_=new Promise(C=>{this.rtcObjects[v].pc&&this.rtcObjects[v].pc.close(),this.rtcObjects[v].stream&&a.default.closeStream(this.rtcObjects[v].stream),C()});try{return await Promise.all([m,_]),this.parentConversation.me.emit("media:stream:off",this.rtcObjects[v].streamIndex),delete this.rtcObjects[v],"rtc:terminate:success"}catch(C){throw C}}_enableMediaTracks(v,m){v.forEach(_=>{_.enabled=m})}async _setMediaTracksAndMute(v,m,_,C){this._enableMediaTracks(m,!_);try{return await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:C,to:this.parentConversation.me.id,from:this.parentConversation.me.id,body:{rtc_id:v}}})}catch(I){throw this._enableMediaTracks(m,_),new i.NexmoApiError(I)}}async updateAudioConstraints(v={}){let m=this._findRtcObjectByType("audio");if(m&&m.pc)try{const _=await a.default.getUserAudio(v);return _.getTracks().forEach(C=>{const I=m.pc.getSenders().find($=>$.track.kind===C.kind);I&&(C.enabled=I.track.enabled,I.replaceTrack(C))}),a.default.closeStream(m.stream),m.stream=_,_}catch(_){return _}else throw new i.NexmoApiError("error:media:stream:not-found")}mute(v=!1,m=null){const C="audio:mute:"+(v?"on":"off");let I=[],$={};if(m!==null){if($[0]=Object.values(this.rtcObjects).find(x=>x.streamIndex===m),!$[0])throw new i.NexmoClientError("error:media:stream:not-found")}else $=this.rtcObjects;return Object.values($).forEach(x=>{const N=x.stream.getAudioTracks(),q=this._setMediaTracksAndMute(x.rtc_id,N,v,C);I.push(q)}),Promise.all(I)}async earmuff(v){try{if(this.me===null)throw new i.NexmoClientError("error:self");{let m="audio:earmuff:off";v&&(m="audio:earmuff:on");const{response:_}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:m,to:this.parentConversation.me.id}});return _}}catch(m){throw new i.NexmoApiError(m)}}async enable(v){try{if(this.parentConversation.me===null)throw new i.NexmoClientError("error:self");{const{offer:m}=v??{};let _=await(m!==void 0?this._execAnswer(v):this._handleAudio(v)),C=v&&(v.autoPlayAudio||v.autoPlayAudio===void 0);return(!v||C)&&a.default.playAudioStream(_),_}}catch(m){throw m}}disable(){let v=[];v.push(this._cleanConversationProperties());for(const m in this.rtcObjects)v.push(this._disableLeg(m));return Promise.all(v)}async sayText(v){try{const m=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:say",cid:this.parentConversation.id,from:this.parentConversation.me.id,body:{text:v.text,voice_name:v.voice_name||"Amy",level:v.level||1,queue:v.queue||!0,loop:v.loop||1,ssml:v.ssml||!1}}});return new o.default(this.parentConversation,m)}catch(m){throw new i.NexmoApiError(m)}}async sendDTMF(v){try{if(!s.default.validateDTMF(v))throw new i.NexmoClientError("error:audio:dtmf:invalid-digit");if(!(this._findRtcObjectByType("audio")||{}).rtc_id)throw new i.NexmoClientError("error:audio:dtmf:audio-disabled");const{id:_,timestamp:C}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:dtmf",from:this.parentConversation.me.id,body:{digit:v,channel:{type:"app",id:this._findRtcObjectByType("audio").rtc_id}}}}),I={body:{digit:v,dtmf_id:""},cid:this.parentConversation.id,from:this.parentConversation.me.id,id:_,timestamp:C,type:"audio:dtmf"},$=new o.default(this.parentConversation,I);return this.parentConversation.events.set(I.id,$),$}catch(m){throw new i.NexmoApiError(m)}}async playStream(v){try{const m=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:play",body:v}});return new o.default(this.parentConversation,m)}catch(m){throw new i.NexmoApiError(m)}}async startRinging(){try{const v=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:ringing:start",from:this.parentConversation.me.id,body:{}}});return new o.default(this.parentConversation,v)}catch(v){throw new i.NexmoApiError(v)}}async stopRinging(){try{const v=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:ringing:stop",from:this.parentConversation.me.id,body:{}}});return new o.default(this.parentConversation,v)}catch(v){throw new i.NexmoApiError(v)}}}r.default=l,e.exports=l}(Lc,Lc.exports)),Lc.exports}var Uc={exports:{}},Bc={exports:{}},l0;function A$(){return l0||(l0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(yi()),i=gr,a=t(Yi);class s extends a.default{constructor(u,c){super(u,c),this.log=i.getLogger(this.constructor.name),this.type="image",this.conversation=u,this.state={seen_by:{},delivered_to:{}},c&&c.body&&c.body.timestamp&&(this.timestamp=c.body.timestamp),Object.assign(this,c)}seen(){return super.seen()}delivered(){return super.delivered()}async del(){return await n.default.networkRequest({type:"DELETE",url:this.body.representations.original.url,token:this.conversation.application.session.config.token}),super.del()}async fetchImage(u="thumbnail",c=this.body.representations){try{return n.default._fetchImage(c[u].url,this.conversation.application.session.config.token)}catch(l){throw this.log.error(l),l}}}r.default=s,e.exports=s}(Bc,Bc.exports)),Bc.exports}var f0;function iZ(){return f0||(f0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=t(Yi),a=t(mg),s=t(A$()),o=t(gg());class u{constructor(l,h){this.log=n.getLogger(this.constructor.name),this.application=l,this.conversation=h,this.constructed_event=null,this._handleEventMap={"event:delete":this._processDelete,image:this._processImage,"image:delivered":this._processDelivered,"image:seen":this._processSeen,"member:invited":this._processMember,"member:joined":this._processMember,"member:left":this._processMember,"audio:ringing:start":this._processMember,"leg:status:update":this._processLegStatus,"member:media":this._processMedia,text:this._processText,"text:delivered":this._processDelivered,"text:seen":this._processSeen,"audio:mute:on":this._processMuteForMedia,"audio:mute:off":this._processMuteForMedia,message:this._processMessage,"message:delivered":this._processDelivered,"message:seen":this._processSeen,"message:submitted":this._processSubmitted,"message:rejected":this._processRejected,"message:undeliverable":this._processUndeliverable}}handleEvent(l){return this._handleEventMap.hasOwnProperty(l.type)?this._handleEventMap[l.type].call(this,l)||new i.default(this.conversation,l):new i.default(this.conversation,l)}_processDelivered(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.delivered_to=h.state.delivered_to||{},h.state.delivered_to[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processDelete(l){var h;let v=this.conversation.events.get((h=l==null?void 0:l.body)===null||h===void 0?void 0:h.event_id);return v?(v.body.text&&(v.body.text=""),v.body.representations&&(v.body.representations=""),v.body.timestamp={deleted:l.timestamp},v):(this.log.warn("NXMEvent not found"),null)}_processImage(l){var h;const v=new s.default(this.conversation,l);return((h=this.conversation.me)===null||h===void 0?void 0:h.id)!==v.from&&v.delivered(),v}_processMember(l){return this.application.calls.has(this.conversation.id)&&this.application.calls.get(this.conversation.id)._handleStatusChange(l),this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),new i.default(this.conversation,l)}_processLegStatus(l){return this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),new i.default(this.conversation,l)}_processMedia(l){return this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),null}_processMuteForMedia(l){return this.conversation.media.rtcObjects[l.body.rtc_id]?l.streamIndex=this.conversation.media.rtcObjects[l.body.rtc_id].streamIndex:this.log.warn("No audio stream was found"),null}_processSeen(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.seen_by=h.state.seen_by||{},h.state.seen_by[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processText(l){var h,v;const m=new a.default(this.conversation,l);return((v=(h=this.conversation)===null||h===void 0?void 0:h.me)===null||v===void 0?void 0:v.id)!==m.from&&m.delivered(),m}_processMessage(l){var h,v;const m=new o.default(this.conversation,l);return((v=(h=this.conversation)===null||h===void 0?void 0:h.me)===null||v===void 0?void 0:v.id)!==m.from&&m.delivered(),m}_processSubmitted(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.submitted_to=h.state.submitted_to||{},h.state.submitted_to[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processRejected(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.rejected_by=h.state.rejected_by||{},h.state.rejected_by[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processUndeliverable(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.undeliverable_to=h.state.undeliverable_to||{},h.state.undeliverable_to[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}}r.default=u,e.exports=u}(Uc,Uc.exports)),Uc.exports}var cv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});class t{constructor(i={}){this.page_size=i.page_size||10,this.order=i.order||"asc",this.cursor=i.cursor||"",this.state=i.state||"",i.event_type&&(this.event_type=i.event_type)}}r.default=t,e.exports=t})(cv,cv.exports);var M$=cv.exports,qc={exports:{}},lv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Mn;class n{constructor(a={}){this.page_size=a.page_size,this.order=a.order,this.cursor=a.cursor,this.application=a.application,a.event_type&&a.event_type.length>0&&(this.event_type=a.event_type)}hasPrev(){return this.cursor.prev?this.cursor.prev.length>0:!1}hasNext(){return this.cursor.next?this.cursor.next.length>0:!1}_getConfig(a){return{page_size:this.page_size,order:this.order,cursor:a,...this.event_type&&{event_type:this.event_type}}}_getError(){return Promise.reject(new t.NexmoClientError("error:invalid-cursor"))}}r.default=n,e.exports=n})(lv,lv.exports);var Of=lv.exports,d0;function aZ(){return d0||(d0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of),i=t(Yi),a=t(mg),s=t(A$()),o=t(gg());class u extends n.default{constructor(l){super(l),this.items=new Map,this.conversation=l.conversation,l.items.forEach(h=>{switch(h.type){case"text":this.items.set(h.id,new a.default(this.conversation,h));break;case"image":this.items.set(h.id,new s.default(this.conversation,h));break;case"message":this.items.set(h.id,new o.default(this.conversation,h));break;default:this.items.set(h.id,new i.default(this.conversation,h));break}}),this.conversation.events=new Map([...this.conversation.events,...this.items])}getPrev(){return this.hasPrev()?this.conversation.getEvents(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.conversation.getEvents(this._getConfig(this.cursor.next)):this._getError()}}r.default=u,e.exports=u}(qc,qc.exports)),qc.exports}var zc={exports:{}},p0;function sZ(){return p0||(p0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of),i=t(vg());class a extends n.default{constructor(o){super(o),this.conversation=o.conversation,this.items=new Map,o.items.forEach(u=>{this.items.set(u.id,new i.default(this.conversation,u))})}getPrev(){return this.hasPrev()?this.conversation.getMembers(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.conversation.getMembers(this._getConfig(this.cursor.next)):this._getError()}}r.default=a,e.exports=a}(zc,zc.exports)),zc.exports}var h0;function x$(){return h0||(h0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=gr,a=Mn,s=t(vg()),o=t(Yi),u=t(mg),c=t(gg()),l=t(nZ()),h=t(iZ()),v=t(yi()),m=t(M$),_=t(aZ()),C=t(sZ()),I=t(Pf());class ${constructor(N,q){this.log=i.getLogger(this.constructor.name),this.application=N,this.id=null,this.name=null,this.display_name=null,this.timestamp=null,this.members=new Map,this.events=new Map,this.sequence_number=0,this.pageConfig=new m.default(((this.application.session||{}).config||{}).events_page_config),this.events_page_last=null,this.members_page_last=null,this.conversationEventHandler=new h.default(N,this),this.media=new l.default(this),this.me=null,this._updateObjectInstance(q),n.mixin($)}_updateObjectInstance(N){for(let q in N)switch(q){case"id":this.id=N.id;break;case"name":this.name=N.name;break;case"display_name":this.display_name=N.display_name;break;case"members":N.members.forEach(J=>{if(this.members.has(J.member_id))this.members.get(J.member_id)._normalise(J),J.user_id===this.application.me.id&&J.state!=="LEFT"&&(this.me=this.members.get(J.member_id),this.members.set(this.me.id,this.me));else{const G=new s.default(this,J);J.user_id===this.application.me.id&&J.state!=="LEFT"&&(this.me=G),this.members.set(G.id,G)}});break;case"timestamp":this.timestamp=N.timestamp;break;case"sequence_number":this.sequence_number=N.sequence_number;break;case"member_id":const X={id:N.member_id,state:N.state,user:this.application.me};if(this.members.has(N.member_id)){const J=this.members.get(N.member_id);Object.assign(J,X)}else{const J=new s.default(this,X);this.me=J,this.members.set(J.id,J)}break}}async join(N){var q,X;try{let J={state:"joined",channel:{type:"app"},user:{...!N&&{name:this.application.me.name,id:this.application.me.id},...N&&N.user_name&&{name:N.user_name},...N&&N.user_id&&{id:N.user_id}}};!((q=this===null||this===void 0?void 0:this.me)===null||q===void 0)&&q.id&&((X=this===null||this===void 0?void 0:this.me)===null||X===void 0?void 0:X.state)!=="LEFT"&&(J.from=this.me.id);const G=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/members`,version:"v0.3",data:J}),L=new s.default(this,G);return G._embedded.user.id===this.application.me.id&&(this.me=L,this.members.set(L.id,L)),this.application.getConversation(this.id,I.default.CONVERSATION_API_VERSION.v3),L}catch(J){throw new a.NexmoApiError(J)}}async del(){try{const N=await this.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.id}`});return this.application.conversations.delete(this.id),N}catch(N){throw new a.NexmoApiError(N)}}deleteEvent(N){return N.del()}async invite(N){var q,X;if(!N||!N.id&&!N.user_name)throw new a.NexmoClientError("error:invite:missing:params");const J={state:"invited",user:{...N.id&&{id:N.id},...N.user_name&&{name:N.user_name}},media:N.media,channel:{from:{type:"app"},to:{type:"app"},type:"app"}};!((q=this===null||this===void 0?void 0:this.me)===null||q===void 0)&&q.id&&((X=this===null||this===void 0?void 0:this.me)===null||X===void 0?void 0:X.state)!=="LEFT"&&(J.from=this.me.id);try{const G=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/members`,version:"v0.3",data:J});return new s.default(this,G)}catch(G){throw new a.NexmoApiError(G)}}inviteWithAudio(N){return!N||!N.id&&!N.user_name?Promise.reject(new a.NexmoClientError("error:invite:missing:params")):(N.media={audio_settings:{enabled:!0,muted:!1,earmuffed:!1}},this.invite(N))}leave(N){return this.me.kick(N)}async sendText(N){try{if(this.me===null)throw new a.NexmoClientError("error:self");const q={type:"text",cid:this.id,from:this.me.id,body:{text:N}},{id:X,timestamp:J}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q});return q.id=X,q.body.timestamp=J,new u.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}async sendCustomEvent({type:N,body:q}){try{if(this.me===null)throw new a.NexmoClientError("error:self");if(!N||typeof N!="string"||N.length<1)throw new a.NexmoClientError("error:custom-event:invalid");const X={type:`custom:${N}`,cid:this.id,from:this.me.id,body:q},{id:J,timestamp:G}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:X});return X.id=J,X.timestamp=G,new o.default(this,X)}catch(X){throw new a.NexmoApiError(X)}}async sendEphemeralEvent(N){try{if(this.me===null)throw new a.NexmoClientError("error:self");const q={type:"ephemeral",cid:this.id,from:this.me.id,body:N},{id:X,timestamp:J}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q});return q.timestamp=J,new o.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}async uploadImage(N,q={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const X=new FormData;X.append("file",N),X.append("quality_ratio",q.quality_ratio),X.append("medium_size_ratio",q.medium_size_ratio),X.append("thumbnail_size_ratio",q.thumbnail_size_ratio);const J=await v.default.networkRequest({type:"POST",url:this.application.session.config.ips_url,data:X,token:this.application.session.config.token});return J.upload.addEventListener("progress",G=>{G.lengthComputable&&this.log.debug("uploading image "+G.loaded+"/"+G.total)},!1),J.onreadystatechange=()=>{J.status!==200&&this.log.error(J)},J}async sendImage(N,q={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const X=await this.uploadImage(N,q);return X.onreadystatechange=()=>{if(X.readyState===4&&X.status===200)try{this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"image",from:this.me.id,body:{representations:JSON.parse(X.responseText)}}}),this.log.info(X)}catch(J){this.log.error(new a.NexmoApiError(J))}},X}abortSendImage(N){return N instanceof XMLHttpRequest?N.abort():new a.NexmoClientError("error:invalid:param:type")}async sendMessage(N){if(this.me===null)throw new a.NexmoClientError("error:self");if(!(N!=null&&N.message_type))throw new a.NexmoClientError("error:message-event:invalid");try{const q={type:"message",cid:this.id,from:this.me.id,body:{...N}},{id:X,timestamp:J}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q});return q.id=X,q.body.timestamp=J,new c.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}async _typing(N){const q={cid:this.id,from:this.me.id};try{return await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q}),`text:typing:${N}:success`}catch(X){throw new a.NexmoApiError(X)}}startTyping(){return this._typing("on")}stopTyping(){return this._typing("off")}async getEvents(N={}){const q=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.id}/events`;let X=Object.keys(N).length===0?this.pageConfig:new m.default(N);try{const J=await v.default.paginationRequest(q,X,this.application.session.config.token);J.application=this.application,J.conversation=this;const G=new _.default(J);return this.events_page_last=G,G}catch(J){throw new a.NexmoApiError(J)}}async getMembers(N={}){const q=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.id}/members`;let X=Object.keys(N).length===0?this.pageConfig:new m.default(N);try{const J=await v.default.paginationRequest(q,X,this.application.session.config.token);J.application=this.application,J.conversation=this;const G=new C.default(J);return this.members_page_last=G,G}catch(J){throw new a.NexmoApiError(J)}}async getMyMember(){try{const N=await this.application.session.sendNetworkRequest({type:"GET",path:`conversations/${this.id}/members/me`,version:"v0.3"});return new s.default(this,N)}catch(N){throw new a.NexmoApiError(N)}}async getMember(N){try{const q=await this.application.session.sendNetworkRequest({type:"GET",path:`conversations/${this.id}/members/${N}`,version:"v0.3"});return new s.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}_handleEvent(N){var q,X;if(N.type.startsWith("rtc"))return this.emit(N.type,N),Promise.resolve(N);this.sequence_number++,N.body&&N.body.event_id&&typeof N.body.event_id=="string"&&(N.body.event_id=parseInt(N.body.event_id));let J={memberId:N.from};if(!((q=N==null?void 0:N.body)===null||q===void 0)&&q.user){const{id:L,name:te,display_name:se,image_url:ne,custom_data:ge}=N.body.user;J={...J,...L&&{userId:L},...te&&{userName:te},...se&&{displayName:se},...ne&&{imageUrl:ne},...ge&&{customData:ge}}}else if(!((X=N==null?void 0:N._embedded)===null||X===void 0)&&X.from_user){const{id:L,name:te,display_name:se,image_url:ne,custom_data:ge}=N._embedded.from_user;J={...J,...L&&{userId:L},...te&&{userName:te},...se&&{displayName:se},...ne&&{imageUrl:ne},...ge&&{customData:ge}}}let G=this.conversationEventHandler.handleEvent(N);return["text:typing:on","text:typing:off","ephemeral"].includes(N.type)||this.events.set(G.id,G),N.type.startsWith("custom:")?(this.emit(G.type,J,G),Promise.resolve(N)):(this.emit(N.type,J,G),Promise.resolve(N))}}r.default=$,e.exports=$}(Mc,Mc.exports)),Mc.exports}var Wc={exports:{}},v0;function N$(){return v0||(v0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=gr,a=Mn,s=t(If());class o{constructor(c,l,h){this.application=c,this.log=i.getLogger(this.constructor.name),this.from=h,this.conversation=null,this.rtcObjects={},this.CALL_STATUS={STARTED:"started",RINGING:"ringing",ANSWERED:"answered",COMPLETED:"completed",BUSY:"busy",TIMEOUT:"timeout",UNANSWERED:"unanswered",REJECTED:"rejected",FAILED:"failed"},this.CALL_DIRECTION={INBOUND:"inbound",OUTBOUND:"outbound"},Object.freeze(this.CALL_DIRECTION),this.STATUS_PERMITTED_FLOW=new Map([["STARTED",new Set([this.CALL_STATUS.RINGING,this.CALL_STATUS.ANSWERED,this.CALL_STATUS.FAILED,this.CALL_STATUS.TIMEOUT,this.CALL_STATUS.UNANSWERED,this.CALL_STATUS.REJECTED,this.CALL_STATUS.BUSY])],["RINGING",new Set([this.CALL_STATUS.ANSWERED,this.CALL_STATUS.FAILED,this.CALL_STATUS.TIMEOUT,this.CALL_STATUS.UNANSWERED,this.CALL_STATUS.REJECTED,this.CALL_STATUS.BUSY])],["ANSWERED",new Set([this.CALL_STATUS.COMPLETED,this.CALL_STATUS.FAILED])]]),Object.freeze(this.STATUS_PERMITTED_FLOW),this.status=null,this.call_disconnect_timeout=null,this.direction=this.CALL_DIRECTION.INBOUND,this._setupConversationObject(l),n.mixin(o)}_enableStatsEvents(){this.conversation.media._enableStatsEvents()}_attachCallListeners(){this.log.debug("_attachCallListeners : ",{nxmCall:this});try{this.conversation.releaseGroup("call_module"),this.conversation.on("member:media","call_module",(c,l)=>{this.application.calls&&this.application.calls.has(this.conversation.id)&&this.application.calls.get(this.conversation.id)._handleStatusChange(l)})}catch(c){this.log.error("_attachCallListeners_error: ",{e:c})}}_isValidStatusTransition(c){if(!c)throw new a.NexmoClientError(`Provide the status to validate the transition from '${this.status}'`);if(!this.status)return!0;const l=this.status.toUpperCase();return!this.STATUS_PERMITTED_FLOW.has(l)||this.status===c?!1:this.STATUS_PERMITTED_FLOW.get(l).has(c)}hangUpIfAllLeft(){if(this.log.debug("hangUpIfAllLeft: ",{nxmCall:this}),!this.conversation.me||this.conversation.me.state==="LEFT"||this.conversation.members.size<=1)return Promise.resolve();for(let c of this.conversation.members.values())if(c.state!=="LEFT"&&this.conversation.me.user.id!==c.user.id)return Promise.resolve();return this.hangUp()}_setupConversationObject(c,l){c&&(this.conversation=c,c.me?(this.to=new Map(c.members),this.from&&this.to.delete(this.from.id)):this.log.warn("missing own member object"),this._attachCallListeners())}_setFrom(c){this.from=c}_setOffer(c){this.offer=c}_handleStatusChange(c){var l;const h=this.conversation?((l=this.conversation.me)===null||l===void 0?void 0:l.id)===c.from:!0,v=this.direction===this.CALL_DIRECTION.OUTBOUND;this.log.debug("_handleStatusChange: ",{event:c},`_isEventFromMe: ${h} _isOutbound: ${v}`);let m=new Map;if(m.set("member:joined",async()=>{if(c.body.channel&&c.body.channel.id)try{this._setStatusAndEmit(this.CALL_STATUS.STARTED);return}catch(_){throw this._setStatusAndEmit(this.CALL_STATUS.FAILED),this.log.error(_),_}return Promise.resolve()}),m.set("member:invited",()=>(c.body.invited_by===null&&c.body.user.media&&c.body.user.media.audio_settings&&this._setStatusAndEmit(this.CALL_STATUS.STARTED),Promise.resolve())),m.set("rtc:hangup",()=>this.status===this.CALL_STATUS.ANSWERED?(this._setStatusAndEmit(this.CALL_STATUS.COMPLETED),Promise.resolve()):h&&v||!h&&!v?(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve()):(this._setStatusAndEmit(this.CALL_STATUS.REJECTED),Promise.resolve())),m.set("member:left",()=>{if(!c.body.timestamp.hasOwnProperty("joined")&&this.status!==this.CALL_STATUS.ANSWERED)return h&&v||!h&&!v?(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve()):(this._setStatusAndEmit(this.CALL_STATUS.REJECTED),Promise.resolve())}),m.set("member:media",()=>(this.status!==this.CALL_STATUS.ANSWERED&&c.body.audio&&(h&&c.body.channel&&(this.id=c.body.channel.id),(!h||!v)&&this.id&&this._setStatusAndEmit(this.CALL_STATUS.ANSWERED)),Promise.resolve())),m.set("sip:ringing",()=>(this.status!==this.CALL_STATUS.RINGING&&this._setStatusAndEmit(this.CALL_STATUS.RINGING),Promise.resolve())),m.set("sip:hangup",()=>{switch(c.body.reason.sip_code){case 486:this._setStatusAndEmit(this.CALL_STATUS.BUSY);break;case 487:this._setStatusAndEmit(this.CALL_STATUS.TIMEOUT);break;case 403:this._setStatusAndEmit(this.CALL_STATUS.FAILED);break}return Promise.resolve()}),m.set("knocking:delete:success",()=>(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve())),m.has(c.type))return m.get(c.type).call(this)}_setStatusAndEmit(c){this._isValidStatusTransition(c)&&(this.status=c,this.log.debug(`_setStatusAndEmit: ${c}`,{nxmCall:this}),this.application.emit("call:status:changed",this))}async answer(c=!0){if(this.log.debug(`answer: { autoPlayAudio: ${c}`),this.conversation)try{await this.conversation.join();const l=await this.conversation.media.enable({autoPlayAudio:c,offer:this.offer});return this.offer=void 0,l}catch(l){throw this._setStatusAndEmit(this.CALL_STATUS.FAILED),this.log.error(l),l}else throw new a.NexmoClientError("error:call:answer")}async createCall(c,l=!0){if(this.log.debug(`createCall: { usernames: ${c}, autoPlayAudio: ${l} }`),!c||!Array.isArray(c)||c.length===0)return Promise.reject(new a.NexmoClientError("error:application:call:params"));try{const h=await this.application.newConversationAndJoin({display_name:"CALL_"+this.application.me.name+"_"+c.join("_").replace(" ","")});h.members.set(h.me.id,h.me),this.from=h.me,this.successful_invited_members=new Map;const v=c.map(async _=>{try{const C=await h.inviteWithAudio({user_name:_});return h.members.set(C.id,C),this.successful_invited_members.set(C.id,C),C}catch(C){return this.log.error(C),C}}),m=async()=>{if(this.successful_invited_members.size>0)return await h.media.enable({audio:{muted:!1,earmuffed:!1},autoPlayAudio:l}),this.application.calls.set(h.id,this),v;throw v};return await Promise.all(v),this._setupConversationObject(h),await m()}catch(h){throw this.log.error(h),this._setStatusAndEmit(this.CALL_STATUS.FAILED),h}}async createServerCall(c,l,h){this.log.debug(`createServerCall: { user: ${c}, type: ${l}, custom_data: `,{custom_data:h});const v={type:l};l==="phone"?v.number=c:v.user=c;try{const{stream:m,legId:_,rtcObjects:C}=await s.default.prewarmLeg(this);this.log.debug("createServerCall: ",{stream:m},{legId:_},{rtcObjects:C}),this.rtcObjects=C,this.stream=m,this.id=_,this.application._call_draft_list.set(_,this),s.default.playAudioStream(m);const I={type:"POST",path:"knocking",data:{channel:{type:"app",from:{type:"app"},to:v,id:_||null},...h&&Object.keys(h).length&&{properties:{custom_data:h}}}};try{const $=await this.application.session.sendNetworkRequest(I);this.knocking_id=$.id}catch($){throw new a.NexmoApiError($)}return s.default.cleanCallMediaIfFailed(this),m}catch(m){throw s.default.cleanMediaProperties(this),m}}async hangUp(c){if(this.log.debug(`hangUp: { reason: ${c} }`),this.conversation&&await this.conversation.media.disable(),!this.knocking_id&&this.conversation)return this.conversation.leave(c).catch(l=>{if(l.type!=="conversation:error:invalid-member-state")return Promise.reject(l)});{let l=`knocking/${this.knocking_id}`;if(c){let h=new URLSearchParams;Object.keys(c).forEach(v=>{h.append(v,c[v])}),l+=`?${h.toString()}`}try{const h=await this.application.session.sendNetworkRequest({type:"DELETE",path:l});return this.application._call_draft_list.get(this.client_ref)._handleStatusChange(h),this.application._call_draft_list.delete(this.client_ref),h}catch(h){if(this.conversation)return this.log.error(new a.NexmoApiError(h)),this.conversation.leave(c).catch(v=>{if(v.type!=="conversation:error:invalid-member-state")return Promise.reject(v)});this.log.debug("hangup: Problem cancelling the call. Knocking cancel failed and Conversation. Leave not available",h);return}}}reject(c){return this.log.debug(`reject: { reason: ${c} }`),this.conversation?this.conversation.leave(c):Promise.reject(new a.NexmoClientError("error:call:reject"))}}r.default=o,e.exports=o}(Wc,Wc.exports)),Wc.exports}var fv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=gr;class n{constructor(a){this.log=t.getLogger(this.constructor.name),this.application=a,this._handleSipCallEventMap={"sip:hangup":this._processSipHangup,"sip:ringing":this._processSipRinging}}_handleSipCallEvent(a){if(this.log.debug("_handleSipCallEvent: ",{event:a}),!this.application.calls.has(a.cid)){this.log.warn("There is no call object for this Conversation id.");return}const s=this.application.calls.get(a.cid);if(this._handleSipCallEventMap.hasOwnProperty(a.type))return this._handleSipCallEventMap[a.type].call(this,s,a)}_processSipHangup(a,s){this.log.debug("_processSipHangup: ",s),a._handleStatusChange(s)}_processSipRinging(a,s){this.log.debug("_processSipRinging: ",s),a._handleStatusChange(s)}}r.default=n,e.exports=n})(fv,fv.exports);var oZ=fv.exports,dv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=gr;class n{constructor(a){this.log=t.getLogger(this.constructor.name),this.application=a,this._handleRtcEventMap={"rtc:transfer":this._processRtcTransfer,"rtc:answer":this._processRtcAnswer,"rtc:hangup":this._processRtcHangup}}_handleRtcEvent(a){if(this._handleRtcEventMap.hasOwnProperty(a.type))return this._handleRtcEventMap[a.type].call(this,a)}_processRtcTransfer(a){this.log.debug("_processRtcTransfer: ",{event:a});const s=this.application.conversations.get(a.body.transferred_from),o=this.application.conversations.get(a.cid),u=this.application.calls.get(a.body.transferred_from);if(!u){this.log.warn("NXMCall transfer for unknown nxmCall");return}u.conversation.members.get(a.body.was_member).transferred_to=o,u._setupConversationObject(o),u.transferred=!0,this.application.calls.set(a.cid,u),this.application.calls.delete(a.body.transferred_from),s&&(o.members.get(a.from).transferred_from=s,o.media._attachEndingEventHandlers(),Object.entries(o.media.rtcObjects).length===0&&Object.entries(s.media.rtcObjects).length!==0&&Object.assign(o.media.rtcObjects,s.media.rtcObjects),!o.media.pc&&s.media.pc&&Object.assign(o.media.pc=s.media.pc),o.application.activeStreams.length===0&&s.application.activeStreams.length>0&&(o.application.activeStreams=s.application.activeStreams))}_processRtcAnswer(a){this.log.debug("_processRtcAnswer: ",{event:a}),this.application.calls.has(a.cid)&&(this.application.calls.get(a.cid).id=a.body.rtc_id)}_processRtcHangup(a){this.log.debug("_processRtcHangup: ",{event:a}),this.application.calls.has(a.cid)&&this.application.calls.get(a.cid)._handleStatusChange(a)}}r.default=n,e.exports=n})(dv,dv.exports);var uZ=dv.exports,Vc={exports:{}},m0;function cZ(){return m0||(m0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=t(Yi),a=t(N$()),s=t(yi()),o=t(If());class u{constructor(l){this.log=n.getLogger(this.constructor.name),this.application=l,this._handleApplicationEventMap={"member:joined":this._processMemberJoined,"member:invited":this._processMemberInvited}}handleEvent(l){const h=this.application.conversations.get(l.cid),v=Object.assign({},l);return this._handleApplicationEventMap.hasOwnProperty(l.type)?this._handleApplicationEventMap[l.type].call(this,h,new i.default(h,v),l):new i.default(h,v)}_processMemberJoined(l,h,v){try{if(h.body.channel&&this.application._call_draft_list.has(h.body.channel.id)){this.log.debug("_processMemberJoined: outbound serverCall from sdk",{event:h});const m=this.application._call_draft_list.get(h.body.channel.id);let _=((m.rtcObjects||{})[h.body.channel.id]||{}).pc;if(m._setFrom(l.me),m._setupConversationObject(l,h.body.channel.id),l.media._attachEndingEventHandlers(),Object.entries(l.media.rtcObjects).length===0&&Object.entries(m.rtcObjects).length!==0&&Object.assign(l.media.rtcObjects,m.rtcObjects),!l.media.pc&&_&&Object.assign(l.media.pc=_),l.application.activeStreams.length===0&&m.application.activeStreams.length>0&&(l.application.activeStreams=m.application.activeStreams),delete m.client_ref,delete m.knocking_id,m.rtcStats&&(l.media.rtcStats=m.rtcStats),this.application._call_draft_list.delete(h.body.channel.id),this.application.calls.set(l.id,m),m._handleStatusChange(h),this.log.debug("_processMemberJoined: processedCall ",{nxmCall:m}),l.members&&h.body.member_id){const C=l.members.get(h.body.member_id);C&&this.application.emit("member:call",C,m)}setTimeout(()=>{l!=null&&l.me&&o.default.emitMediaStream(l.me,_,m.stream)},200)}return this.log.debug("_processMemberJoined: default member joined: ",{event:h}),h}catch(m){this.log.error("_processMemberJoined: ",{e:m})}}_processMemberInvited(l,h){var v,m,_,C,I,$;try{if(!l)return this.log.warn(`no conversation object for ${h.type}`),h;if(((v=l.me)===null||v===void 0?void 0:v.user.id)===h.body.invited_by||!(!((_=(m=h.body.user.media)===null||m===void 0?void 0:m.audio_settings)===null||_===void 0)&&_.enabled))return h;const x=s.default.getMemberNumberFromEventOrNull(h.body.channel)||s.default.getMemberFromNameOrNull(l,h.body.invited_by)||"unknown",N=new a.default(this.application,l,x);return this.application.calls.set(l.id,N),!((C=h.body)===null||C===void 0)&&C.sdp&&this.application.session.config.enableInboundOffer&&N._setOffer({sdp:h.body.sdp,leg_id:h.body.channel.id}),!((I=l.display_name)===null||I===void 0)&&I.startsWith("CALL_")||N._handleStatusChange(h),this.application.emit("member:call",this.application.conversations.get(h.cid).members.get(($=h.body)===null||$===void 0?void 0:$.member_id),N),h}catch(x){this.log.error("_processMemberInvited: ",{e:x})}}}r.default=u,e.exports=u}(Vc,Vc.exports)),Vc.exports}var pv={exports:{}};(function(e,r){var t=Ae&&Ae.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of);class i extends n.default{constructor(s){super(s),this.items=new Map,s.items.forEach(o=>{const u=this.application.updateOrCreateConversation(o);this.items.set(u.id,u)})}getPrev(){return this.hasPrev()?this.application.getConversations(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.application.getConversations(this._getConfig(this.cursor.next)):this._getError()}}r.default=i,e.exports=i})(pv,pv.exports);var lZ=pv.exports,hv={exports:{}},vv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Pa;class n{constructor(a,s){var o,u;this.application=a,this.id=(o=s==null?void 0:s.id)!==null&&o!==void 0?o:null,this._embedded=(u=s==null?void 0:s._embedded)!==null&&u!==void 0?u:null,t.mixin(n)}}r.default=n,e.exports=n})(vv,vv.exports);var fZ=vv.exports;(function(e,r){var t=Ae&&Ae.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of),i=t(fZ);class a extends n.default{constructor(o){super(o),this.items=new Map,o.items.forEach(u=>{this.items.set(u.id,new i.default(this.application,u))})}getPrev(){return this.hasPrev()?this.application.getUserSessions(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.application.getUserSessions(this._getConfig(this.cursor.next)):this._getError()}}r.default=a,e.exports=a})(hv,hv.exports);var dZ=hv.exports,Gc={exports:{}},g0;function pZ(){return g0||(g0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0}),r.ConversationEventsProcessor=r.EventsQueue=void 0;const n=Mn,i=t(yi()),a=gr;class s{constructor(c){this.callback=c,this.cidMap=new Map,this.log=a.getLogger(this.constructor.name)}async enqueue(c,l){var h,v,m,_,C,I,$,x;const{cid:N,id:q}=c,X=Number(q);if(!N||isNaN(X))return this.callback(c);if(((v=(h=l.conversations.get(N))===null||h===void 0?void 0:h.me)===null||v===void 0?void 0:v.state)==="LEFT")return this.callback(c);if(!this.cidMap.get(N)){this.log.debug(`enqueue: create new ConversationEventsProcessor for ${N}`);const G=new o(N,X-1,l);if(this.cidMap.set(N,G),c.type=="member:media"&&(!((_=(m=c.body)===null||m===void 0?void 0:m.media)===null||_===void 0)&&_.audio)||c.type=="member:joined"&&(!((I=(C=c.body)===null||C===void 0?void 0:C.channel)===null||I===void 0)&&I.id)&&((x=($=c.body)===null||$===void 0?void 0:$.channel)===null||x===void 0?void 0:x.knocking_id)===void 0){G.processing=!0,G.lastEventIdProcessed=0;try{await new Promise(ne=>setTimeout(ne,G.eventRequestWaitTime));const L=ne=>{var ge;return(ge=ne.find(Y=>(Y==null?void 0:Y.type)==="rtc:transfer"&&(Y==null?void 0:Y.from)===c.from))===null||ge===void 0?void 0:ge.id};let te=[Array.from(Array(5).keys()).map(ne=>X+1+ne),Array.from(Array(5).keys()).map(ne=>X-1-ne)].flatMap(ne=>ne).map(ne=>G.eventsMap.get(ne)).filter(ne=>ne),se;if((se=L(te))===void 0){const ne=Math.max(X-20,1);te=await G.fetchConversationEvents(ne,20)}(se=L(te))!==void 0&&(se=Number(se),G.lastEventIdProcessed=Math.max(se-1,0),te.slice(se).forEach(ne=>G.enqueue(Number(ne.id),ne)))}finally{G.processing=!1}}}const J=this.cidMap.get(N);J.enqueue(X,c),J.processing||(J.processing=!0,await J.processEvents())}}r.EventsQueue=s;class o{constructor(c,l,h){this.cid=c,this.eventsMap=new Map,this.callback=v=>h._handleEvent(v),this.lastEventIdProcessed=l,this.largestEventIdInQueue=l,this.processing=!1,this.application=h,this.eventsFetchRange=9,this.eventRequestWaitTime=h.session.config.eventQueueWaitTime,this.log=a.getLogger(this.constructor.name)}enqueue(c,l){return c>this.largestEventIdInQueue&&(this.largestEventIdInQueue=c),c>this.lastEventIdProcessed&&this.eventsMap.set(c,l),l}dequeue(c){const l=this.eventsMap.get(c);return this.eventsMap.delete(c),l}async processEvents(){const c=()=>(this.eventsMap.clear(),this.log.debug("processEvents: Done Processing"),this.processing=!1);if(this.eventsMap.size<1)return c();const l=this.lastEventIdProcessed+1,h=await this.processNextEvent(l,1);return h?(this.lastEventIdProcessed=Number(h.id),this.processEvents()):c()}async processNextEvent(c,l){this.log.debug(`processNextEvent: processing event number ${c}`);const h=this.dequeue(c);try{if(h)return await this.callback(h),h;if(l>0)return await new Promise(v=>setTimeout(v,this.eventRequestWaitTime)),this.processNextEvent(c,l-1);if(this.largestEventIdInQueue>c){this.log.debug(`processNextEvent: largestEventIdInQueue-${this.largestEventIdInQueue} > eventId-${c}`);const v=await this.fetchEventsAndProcess(c);return v?(this.log.debug("processNextEvent: foundEvent ",{foundEvent:v}),await this.callback(v),v):(this.log.debug(`processNextEvent: not found process next ${c+1}`),this.processNextEvent(c+1,l))}return}catch{return}}async fetchEventsAndProcess(c){try{const l=await this.fetchConversationEvents(c,this.eventsFetchRange);this.log.debug("fetchEventsAndProcess: fetched events list ",{eventsList:l});let h;return l.forEach(v=>{v.cid=this.cid;const m=Number(v.id);isNaN(m)||m<c||(m>c?(this.log.debug(`fetchEventsAndProcess: event > missingEvent ${m} `,{missingEvent:c}),this.enqueue(m,v)):(this.log.debug("fetchEventsAndProcess: foundEvent ",{event:v}),h=v))}),h}catch(l){this.log.debug("fetchEventsAndProcess: error ",{e:l});return}}async fetchConversationEvents(c,l){this.log.debug("fetchConversationEvents: ",this.cid,c);const h=this.largestEventIdInQueue>c?this.largestEventIdInQueue+l:c+l,v=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.cid}/events`;try{return(await i.default.paginationRequest(v,{start_id:c,end_id:h},this.application.session.config.token)).items}catch(m){throw new n.NexmoApiError(m)}}}r.ConversationEventsProcessor=o,e.exports={EventsQueue:s,ConversationEventsProcessor:o}}(Gc,Gc.exports)),Gc.exports}var y0;function Pf(){return y0||(y0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(J){return J&&J.__esModule?J:{default:J}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=gr,a=Mn,s=t(q1),o=t(x$()),u=t(N$()),c=t(oZ),l=t(uZ),h=t(cZ()),v=t(yi()),m=t(M$),_=t(lZ),C=t(dZ),I=pZ(),$=t(vg());let x=null,N=null,q=null;class X{constructor(G,L){this.log=i.getLogger(this.constructor.name),this.session=G,this.conversations=new Map,this.synced_conversations_count=0,this.start_sync_time=0,this.stop_sync_time=0,this.calls=new Map,this._call_draft_list=new Map,this.pageConfig=new m.default((G.config||{}).conversations_page_config),this.conversations_page_last=null,this.activeStreams=[],x=new c.default(this),N=new l.default(this),q=new h.default(this),this.me=null,Object.assign(this,L),n.mixin(X)}updateOrCreateConversation(G){const L=this.conversations.get(G.id);return L?(L._updateObjectInstance(G),this.conversations.set(G.id,L)):this.conversations.set(G.id,new o.default(this,G)),this.conversations.get(G.id)}async _enqueueEvent(G){this.session.config.enableEventsQueue?(this.eventsQueue||(this.eventsQueue=new I.EventsQueue(L=>this._handleEvent(L))),this.eventsQueue.enqueue(G,this)):this._handleEvent(G)}async _handleEvent(G){var L,te,se,ne,ge,Y,Ue;const He=!((L=G._embedded)===null||L===void 0)&&L.from_user?((se=(te=G._embedded)===null||te===void 0?void 0:te.from_user)===null||se===void 0?void 0:se.id)===((ne=this.me)===null||ne===void 0?void 0:ne.id):((Y=(ge=G.body)===null||ge===void 0?void 0:ge.user)===null||Y===void 0?void 0:Y.user_id)===((Ue=this.me)===null||Ue===void 0?void 0:Ue.id),Rt=v.default._checkIfUserIsReInvited(this.conversations,G);if(G.type.startsWith("sip"))return x._handleSipCallEvent(G),G;if(this.conversations.has(G.cid)&&G.type!=="rtc:transfer"&&!Rt)return G.type.startsWith("rtc")&&N._handleRtcEvent(G),this.conversations.get(G.cid)._handleEvent(G),(G.type==="member:joined"||G.type==="member:invited")&&He&&this._handleApplicationEvent(G),G;if(G.cid)try{Rt&&this.conversations.delete(G.cid);let ft;return v.default._isCallEvent(G)?ft=await this.getConversation(G.cid,X.CONVERSATION_API_VERSION.v1):ft=await this.getConversation(G.cid,X.CONVERSATION_API_VERSION.v3),this.conversations.set(G.cid,ft),await ft._handleEvent(G),await this._handleApplicationEvent(G),G.type.startsWith("rtc")&&N._handleRtcEvent(G),Promise.resolve(G)}catch(ft){return this.log.error(ft),Promise.reject(ft)}}async updateToken(G){if(this.session.connection&&this.session.connection.disconnected)return this.session.config.token=G,this.session.connection.io.opts.query.token=G,Promise.resolve();const L={url:`${this.session.config.nexmo_api_url}/v0.2/sessions/${this.session.session_id}`,type:"PUT",token:G};try{await v.default.networkRequest(L),this.me&&(this.session.config.token=G,this.session.connection.io.opts.query.token=G)}catch(te){throw new a.NexmoApiError(te)}}async _handleApplicationEvent(G){try{this.log.debug("_handleApplicationEvent: ",{event:G});const L=q.handleEvent(G),te=this.conversations.get(G.cid);let se;if(te.members.has((L||{}).from))se=te.members.get(L.from);else if(G.type==="member:joined"||G.type==="member:invited"){const ne={...G.body,...G.from&&{member_id:G.from}};se=new $.default(te,ne)}else try{se=await te.getMember(L.from)}catch(ne){this.log.warn(`There is an error getting the member ${ne}`)}return this.emit(L.type,se,L),G}catch(L){throw this.log.error("_handleApplicationEvent: ",L),L}}async inAppCall(G){if(!G||!Array.isArray(G)||G.length===0)return Promise.reject(new a.NexmoClientError("error:application:call:params"));try{const L=new u.default(this);return await L.createCall(G),L.direction=L.CALL_DIRECTION.OUTBOUND,L}catch(L){throw L}}async callServer(G,L="phone",te={}){try{const se=new u.default(this);return se.direction=se.CALL_DIRECTION.OUTBOUND,await se.createServerCall(G,L,te),se}catch(se){throw se}}async reconnectCall(G,L,te={}){try{if(!G||!L)throw new a.NexmoClientError("error:missing:params");const se=await this.getConversation(G,X.CONVERSATION_API_VERSION.v1);await se.media.enable({...te,reconnectRtcId:L});const ne=new u.default(this,se),ge=Array.from(se.events.values()).map(Y=>Y.type);return ge.includes("sip:answered")?ne.status=ne.CALL_STATUS.ANSWERED:ge.includes("sip:ringing")?ne.status=ne.CALL_STATUS.RINGING:ne.status=ne.CALL_STATUS.STARTED,ne.rtcObjects=se.media.rtcObjects,this.calls.set(se.id,ne),ne}catch(se){throw se}}async newConversation(G={}){try{const L=await this.session.sendNetworkRequest({type:"POST",path:"conversations",data:G}),te=new o.default(this,L);return this.conversations.set(te.id,te),this.getConversation(te.id,X.CONVERSATION_API_VERSION.v1)}catch(L){throw new a.NexmoApiError(L)}}async newConversationAndJoin(G){const L=await this.newConversation(G);return await L.join(),L}async getConversation(G,L=X.CONVERSATION_API_VERSION.v3){if(L!==X.CONVERSATION_API_VERSION.v1&&L!==X.CONVERSATION_API_VERSION.v3)throw new a.NexmoClientError("error:conversation-service:version");let te;if(L===X.CONVERSATION_API_VERSION.v1)try{te=await this.session.sendNetworkRequest({type:"GET",path:`conversations/${G}`}),te.id=te.uuid,delete te.uuid}catch(ne){throw new a.NexmoApiError(ne)}else try{te=await this.session.sendNetworkRequest({type:"GET",path:`conversations/${G}`,version:"v0.3"})}catch(ne){throw new a.NexmoApiError(ne)}const se=this.updateOrCreateConversation(te);if(L===X.CONVERSATION_API_VERSION.v3&&!se.me)try{const ne=await se.getMyMember();se.me=ne,se.members.set(ne.id,ne)}catch{try{const ge=await se.getMyMember();se.me=ge,se.members.set(ge.id,ge)}catch{this.log.warn(`You don't have any membership in ${se.id}`)}}if(this.session.config.sync==="full"){const{items:ne}=await se.getEvents();return se.events=ne,se}else return se}async getConversations(G={}){const L=`${this.session.config.nexmo_api_url}/beta2/users/${this.me.id}/conversations`;let te=Object.keys(G).length===0?this.pageConfig:new m.default(G);try{const se=await v.default.paginationRequest(L,te,this.session.config.token);se.application=this;const ne=new _.default(se);return this.conversations_page_last=ne,ne}catch(se){throw new a.NexmoApiError(se)}}syncConversations(G){const L=Array.from(G.values()),te=L.length,se=new Date;this.start_sync_time=typeof window<"u"&&window.performance?window.performance.now():se.getTime();const ne=async()=>{this.synced_conversations_percentage=Number((this.synced_conversations_count/te*100).toFixed(2));const ge={sync_progress:this.synced_conversations_percentage};if(this.emit("sync:progress",ge),this.log.info("Loading sync progress: "+this.synced_conversations_count+"/"+te+" - "+this.synced_conversations_percentage+"%"),this.synced_conversations_percentage>=100){const Y=new Date;this.stop_sync_time=typeof window<"u"&&window.performance?window.performance.now():Y.getTime(),this.log.info("Loaded conversations in "+(this.stop_sync_time-this.start_sync_time)+"ms")}this.synced_conversations_count<te&&(await this.getConversation(L[this.synced_conversations_count].id),ne(),this.synced_conversations_count++,this.sync_progress_buffer++)};ne()}async getUser(G=this.me.id){try{const L=await this.session.sendNetworkRequest({type:"GET",path:`users/${G}`});return new s.default(this,L)}catch(L){throw new a.NexmoApiError(L)}}async getUserSessions(G={}){var L;const te=((L=G)===null||L===void 0?void 0:L.user_id)||this.me.id,se=`${this.session.config.nexmo_api_url}/v0.3/users/${te}/sessions`;let ne=Object.keys(G).length===0?this.pageConfig:new m.default(G);try{const ge=await v.default.paginationRequest(se,ne,this.session.config.token,X.CONVERSATION_API_VERSION.v3);ge.application=this;const Y=new C.default(ge);return this.user_sessions_page_last=Y,Y}catch(ge){throw new a.NexmoApiError(ge)}}}r.default=X,X.CONVERSATION_API_VERSION={v1:"v0.1",v3:"v0.3"},e.exports=X}(Ac,Ac.exports)),Ac.exports}var b0;function yi(){return b0||(b0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(kQ),i=t(L1),a=t(Pf()),s=4e4,o=2e4,u=new RegExp(`"|'|<|>|&|\\|/`),c=new RegExp(`"|'|<|>|\\|javascript:`);class l{static getMemberFromNameOrNull(v,m){if(!v||!m)return null;for(let _ of v.members.values())if(_.user.name===m)return _;return null}static getMemberNumberFromEventOrNull(v){const m=v&&v.from;return m&&(m.number||m.uri)?m.number||m.uri:null}static isSanitizedInput(v){return!u.test(v)}static isSanitizedUrlInput(v){return!c.test(v)}static checkIsSanitized([v,m]){if(m==null)return!0;switch(typeof m){case"string":return v.includes("url")||v.includes("uri")?l.isSanitizedUrlInput(m):l.isSanitizedInput(m);case"object":return Array.isArray(m)?m.every(_=>l.checkIsSanitized(["dummy",_])):Object.entries(m).every(l.checkIsSanitized);default:return!0}}static networkRequest(v){return new Promise((m,_)=>{!v.token&&!v.url.includes("logging")&&!v.url.includes("ping")&&_({response:{type:"error:user:token",description:"network error on request. Please create a new session."}});const C=new XMLHttpRequest;let I;C.open(v.type,v.url,!0),v.token&&C.setRequestHeader("Authorization","Bearer "+v.token),v&&v.url.includes("image")?(C.responseType="",I=v.data,C.onloadstart=()=>{m(C)}):(C.responseType=v.responseType||"json",I=v.data?JSON.stringify(v.data):null,C.setRequestHeader("Content-type","application/json; charset=utf-8")),C.onload=()=>{C.status===200||C.status===201||C.status===204?m(C):_(C)},C.onerror=$=>{_($)},C.send(I)})}static async paginationRequest(v,m,_,C=a.default.CONVERSATION_API_VERSION.v1){try{const I=await l.networkRequest({type:"GET",url:l.addUrlSearchParams(v,m),token:_}),{page_size:$,_embedded:x,_links:N}=I.response,q=v.split("/").pop().trim();return{items:C===a.default.CONVERSATION_API_VERSION.v1?x.data[q]:x[q],cursor:{prev:N.prev?new URLSearchParams(N.prev.href).get("cursor"):"",next:N.next?new URLSearchParams(N.next.href).get("cursor"):"",self:N.self?new URLSearchParams(N.self.href).get("cursor"):""},page_size:$,order:m.order||"asc",event_type:m.event_type||null}}catch({response:I}){const $=I||{type:"error:network:get-request",description:"network error on nexmo get request"};throw $.validation&&($.description=$.validation[Object.keys($.validation)[0]]),$}}static addUrlSearchParams(v,m={}){let _=new URL(v);return Object.keys(m).forEach(C=>{m[C]&&!(typeof m[C]=="string"&&m[C].length<1)&&m[C]!==null&&_.searchParams.set(C,m[C])}),_.href}static deepMergeObj(v,m){const _=JSON.parse(JSON.stringify(v));for(let C in m)Object.prototype.toString.call(m[C])==="[object Object]"?_[C]=l.deepMergeObj(_[C],m[C]):_[C]=m[C];return _}static injectScript(v,m){if(typeof document<"u"){let _=document.getElementsByTagName("head")[0],C=document.createElement("script");C.async=!0,C.src=v,C.onload=C.onreadystatechange=()=>{(!C.readyState||/loaded|complete/.test(C.readyState))&&(C.onload=C.onreadystatechange=null,C=null,m&&m())},_.insertBefore(C,_.firstChild)}}static allocateUUID(){return n.default.v4()}static validateDTMF(v){return typeof v=="string"?/^[\da-dA-D#*pP]{1,45}$$/.test(v):!1}static _getBugsnagKey(){return"76498fc1ca8d9b0a173a44e2b873d7ed"}static updateMemberLegs(v,m){if(v){const _=v.find(C=>C.leg_id===m.body.leg_id);if(!_)v.push({leg_id:m.body.leg_id,status:m.body.status});else if(_.status!==m.body.status){let C=v.indexOf(_);v.fill(_.status=m.body.status,C,C++)}}else v=[{leg_id:m.body.leg_id,status:m.body.status}];return v}static _isCallEvent(v){const{channel:m,media:_}=v.body;return!!(v.type==="rtc:transfer"||m&&(_&&_.audio_settings&&_.audio_settings.enabled||_&&_.audio&&_.audio.enabled||m.knocking_id))}static async _fetchImage(v,m){const{response:_}=await l.networkRequest({type:"GET",url:v,responseType:"arraybuffer",token:m}),C=new Uint8Array(_);let I="";const $=8*1024;let x;for(x=0;x<C.length/$;x++)I+=String.fromCharCode.apply(null,C.subarray(x*$,(x+1)*$));return I+=String.fromCharCode.apply(null,C.subarray(x*$)),"data:image/jpeg;base64,"+btoa(I)}static async _checkHttpConnectivity(v){const m=Date.now();try{await l.networkRequest({type:"GET",url:v});const _=Date.now()-m;return{url:v,canConnect:!0,connectionTime:_}}catch(_){return{url:v,canConnect:!1,error:_}}}static _checkWsConnectivity(v,m,_){return new Promise((C,I)=>{const $=Object.assign({path:m},_),x=Date.now(),N=i.default.connect(v,$),q=setTimeout(()=>C({url:v,canConnect:!1}),o);N.on("connect",()=>{const X=Date.now()-x;N.disconnect(),clearTimeout(q),C({url:v,canConnect:!0,connectionTime:X})}),N.on("error",X=>{N.disconnect(),clearTimeout(q),C({url:v,canConnect:!1,error:X})})})}static async _checkMediaServers(v,m,_){try{const{response:C}=await l.networkRequest({type:"GET",url:`${m}/v0.3/discovery/media/${_}`,token:v}),I=C.map($=>l._checkMediaConnectivity($.ip,$.port));return await Promise.all(I)}catch{return[]}}static async _checkMediaConnectivity(v,m){return new Promise(async(_,C)=>{const I={iceServers:[{urls:`stun:${v}:${m}`}]},$=new RTCPeerConnection(I),x=Date.now(),N=await $.createOffer({offerToReceiveAudio:!0});$.setLocalDescription(N);const q=setTimeout(()=>{$.close(),_({ip:v,canConnect:!1})},s);$.addEventListener("icecandidate",X=>{var J;if(((J=X==null?void 0:X.candidate)===null||J===void 0?void 0:J.type)==="srflx"){const G=Date.now()-x;clearTimeout(q),$.close(),_({ip:v,canConnect:!0,connectionTime:G})}}),$.addEventListener("icecandidateerror",X=>{X.errorCode&&($.close(),clearTimeout(q),_({ip:v,canConnect:!1,error:X}))})})}static _checkIfUserIsReInvited(v,m){var _;if(!v.has(m.cid)||!(m.type==="member:invited"||m.type==="member:joined"))return!1;const C=(_=v.get(m.cid))===null||_===void 0?void 0:_.me;return C?C.user.name===m.body.user.name&&C.state==="LEFT":!1}}r.default=l,e.exports=l}(Oc,Oc.exports)),Oc.exports}var mv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=gr,n=Mn;class i{constructor(s){if(this.log=t.getLogger(this.constructor.name),!s)throw new n.NexmoClientError("no emitter object passed for the Error Emitter");this.emitter=s,this.LISTENER_GROUP="NXM-errors"}emitResponseIfError(s){if(this._isTypeError(s.type))return this.emitter.emit(s.type,this.LISTENER_GROUP,s)}cleanup(){return this.emitter.releaseGroup(this.LISTENER_GROUP)}_isTypeError(s){return s.indexOf("error")!==-1}}r.default=i,e.exports=i})(mv,mv.exports);var hZ=mv.exports;(function(e,r){var t=Ae&&Ae.__importDefault||function(I){return I&&I.__esModule?I:{default:I}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=t(hY),a=t(gr),s=Mn,o=t(L1),u=t(cQ),c=t(vQ),l=t(yi()),h=t(Pf()),v=t(hZ),m=t(q1),_=t(If());i.default.reg(a.default),i.default.apply(a.default,{template:"[%t] %l (NXM-%n):",timestampFormatter:I=>I.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),levelFormatter:I=>I.toUpperCase(),nameFormatter:I=>I||"SDK"});class C{constructor($={}){const x=$;if(this.config={debug:"silent",log_reporter:{enabled:!1,bugsnag_key:null},environment:"production",ips_url:"https://api-us.vonage.com/v1/image",nexmo_api_url:"https://api-us.vonage.com",path:"/v2/rtc",repository:"https://github.com/Nexmo/conversation-js-sdk",SDK_version:"9.6.1",socket_io:{reconnection:!0,reconnectionAttempts:5,reconnectionDelay:2e3,randomizationFactor:.75,reconnectionDelayMax:15e3,forceNew:!0,autoConnect:!0,transports:["websocket"]},sync:"none",url:"https://ws-us.vonage.com",iceServers:[],rtcstats:{remote_collection:!0,remote_collection_url:"https://hlg.tokbox.com/prod/logging/nexmo_client_js_stats",remote_collection_interval:5e3,emit_events:!1,emit_rtc_analytics:!1,emit_interval:1e3},conversations_page_config:{page_size:10,order:"asc",cursor:""},events_page_config:{page_size:10,order:"asc",event_type:""},enableEventsQueue:!0,eventQueueWaitTime:50,enableInboundOffer:!1,acknowledgeEvents:!0,token:null},this.config.socket_io.query={token:"",SDK_version:this.config.SDK_version,session_version:$.enableInboundOffer?"0.0.3":"0.0.1",acknowledge_events:this.config.acknowledgeEvents,OS_family:"js",OS_revision:typeof navigator<"u"?navigator.userAgent:typeof window<"u"?window.navigator.userAgent:"Generic JS navigator"},this.sessionReady=!1,this.disconnectTimestamp=null,this.session_id=null,this.apiKey=null,this.requests={},this.application=null,["debug","info","warn","error"].includes(x.debug)?a.default.setLevel(x.debug):x.debug===!0?a.default.setLevel("debug"):a.default.setLevel("silent"),this.log=a.default.noConflict(),this.config=l.default.deepMergeObj(this.config,this._sanitizeConfig(x)),this.config.log_reporter.enabled){const N={apiKey:this.config.log_reporter.bugsnag_key||l.default._getBugsnagKey(),appVersion:this.config.socket_io.query.SDK_version,releaseStage:this.config.environment};Ae.NXMbugsnagClient=u.default(N)}n.mixin(C)}_createAndSetConnection(){let $,x=Object.assign({path:this.config.path},this.config.socket_io);return $=o.default.connect(this.config.url,x),this.connection=$,$.on("connect",()=>{this.emit("ready"),this.sessionReady=!0,this.log.info("websocket ready")}),$.on("disconnect",(N,q)=>{this.emit("disconnect",N==="io client disconnect"?C.DISCONNECT_REASON.ClientDisconnected:N==="io server disconnect"&&this.session_id?C.DISCONNECT_REASON.TokenExpired:C.DISCONNECT_REASON.ConnectionError),this.disconnectTimestamp=Date.now(),this.log.info("websocket disconnected",N,q)}),$.io.on("reconnect",N=>{this.emit("reconnect",N),this.log.info("websocket reconnect",N),l.default.networkRequest({url:`${this.config.url.replace("wss://","https://")}/v2/rtc/metrics`,type:"POST",token:this.config.token,data:{sessionId:this.session_id,metrics:[{name:"TIME_TO_RECONNECT_SUCCESS",time:this.disconnectTimestamp?Date.now()-this.disconnectTimestamp:void 0,attempt:N}]}}).catch(q=>{this.log.warn("Failed to publish socket reconnection metrics",q)})}),$.io.on("reconnect_attempt",N=>{this.emit("reconnecting",N),this.log.info("websocket reconnecting",N)}),$.on("connect_error",N=>{this.emit("error",new s.NexmoClientError(N)),this.log.error("Socket.io reported a generic error",N)}),$.io.on("reconnect_failed",()=>{this.emit("error",new s.NexmoClientError("error:client:reconnection_failed")),this.log.error("websocket reconnection error")}),$.io.on("packet",N=>{if(N.type!==2||N.data[0]==="echo")return;const q=N.data[2];q&&typeof q=="function"&&q();const X=N.data[1];if(X.type=N.data[0],this.log.debug("<--",X.type,X),this.requests["session:login"]){const J=this.requests["session:login"].callback;delete this.requests["session:login"],J(X)}else if(X.rid in this.requests){const J=this.requests[X.rid].callback;delete this.requests[X.rid],delete X.delay,this.errorsEmitter&&this.errorsEmitter.emitResponseIfError(X),J(X)}else this.errorsEmitter&&X.type.startsWith("system:error:")?this.errorsEmitter.emitResponseIfError(X):X.type.startsWith("session:")?this.updateSession(X):this.application&&this.application._enqueueEvent(X)}),$}_sanitizeConfig($){let x=$;return $.sync&&["none","lite","full"].indexOf($.sync)===-1&&(this.log.warn(`invalid param '${$.sync}' for sync, reverting to ${this.config.sync}`),x.sync=this.config.sync),x}sendRequest($,x){$.tid=l.default.allocateUUID();const N=$.type;delete $.type,this.log.debug("-->",N,$),this.log.info("-->",N,$.tid),this.connection.emit(N,$),this.requests[$.tid]={type:N,request:$,callback:x}}async sendNetworkRequest($){const x=$.version||"beta",N=`${this.config.nexmo_api_url}/${x}/${$.path}`;if(!($.type==="GET"||$.type==="DELETE")&&($.data={...$.data,originating_session:this.session_id},!l.default.checkIsSanitized(["data",$.data])))throw new s.NexmoClientError("error:input:unsanitized");try{const q={type:$.type,url:N,data:$.data?$.data:null,token:($.data||{}).token?$.data.token:this.config.token||null};this.log.debug("sendNetworkRequest: ",{request:q});const{response:X}=await l.default.networkRequest(q);return X}catch({response:q}){throw q}}createSession($){return this.config.socket_io.query.token=$,this._createAndSetConnection(),new Promise((x,N)=>{this.log.info(`Client-SDK Version: ${this.config.SDK_version}`),this.config.token=null,this.requests["session:login"]={type:"session:login",callback:async q=>{if(q.type==="session:success")if(this.session_id=q.body.id,this.apiKey=q.body.api_key,this.config.token=$,this.connection.io.opts.query={session_id:this.session_id,token:this.config.token},(!this.application||this.application.me&&this.application.me.id!==q.body.user_id)&&(this.application=new h.default(this,{})),this.application.me||(this.application.me=new m.default(this.application,{id:q.body.user_id,name:q.body.name})),this.errorsEmitter||(this.errorsEmitter=new v.default(this.application)),this.config.log_reporter.enabled&&(Ae.NXMbugsnagClient.user={id:this.application.me.id,name:this.application.me.name,session_id:q.body.id}),this.config.sync!=="none")try{await this.application.getConversations(),x(this.application)}catch(X){N(X)}else x(this.application);else N(new s.NexmoApiError(q))}}})}deleteSession(){return new Promise(async($,x)=>{const N=()=>this.sendRequest({type:"session:logout",body:{}},q=>{q.type==="session:logged-out"||q.type==="session:terminated"?(this.disconnect(),delete this.errorsEmitter,delete this.application,delete this.connection,this.requests={},this.sessionReady=!1,$(q)):x(q)});if(this.application){let q=[];if(this.application.conversations.size)for(let X of this.application.conversations.values())q.push(X.media.disable());try{await Promise.all(q)}catch(X){this.log.error("deleteSession: ",X)}return N()}else return N()})}updateSession($){$.type==="session:success"&&(this.session_id=$.body.id,this.connection.io.opts.query.session_id=$.body.id,this.application&&$.body.pending_events&&$.body.pending_events.forEach(x=>this.application._enqueueEvent(x)))}disconnect(){return this.connection.disconnect()}connect(){return this.connection.connect()}async connectivityReport($,x){const q={machineInfo:{ip:_.default.isNode()?void 0:await c.default.v4()},connectivityReport:[]};try{const{response:X}=await l.default.networkRequest({type:"GET",url:`${this.config.nexmo_api_url}/v0.3/discovery/api`,token:$});let J=X;x!=null&&x.dcListCallback&&(J=x.dcListCallback(J));for(const G in J){const L=J[G].endpoint,te=J[G].https,se=J[G].ws;try{const ne=await l.default._checkHttpConnectivity(te),ge=await l.default._checkWsConnectivity(se,this.config.path,this.config.socket_io),Y=await l.default._checkMediaServers($,L,G),Ue={name:G,signalConnectionReport:{https:ne,ws:ge},mediaConnectionReport:Y};q.connectivityReport.push(Ue)}catch(ne){this.log.error(`Error generating report for ${G}`,ne)}}}catch(X){this.log.error("Error fetching nexmo servers information",X)}return q}async checkMediaServers($,x,N){return await l.default._checkMediaServers($,x,N)}async checkMediaConnectivity($,x){return await l.default._checkMediaConnectivity($,x)}}r.default=C,C.DISCONNECT_REASON={ClientDisconnected:"ClientDisconnected",TokenExpired:"TokenExpired",ConnectionError:"ConnectionError"},e.exports=C})(qh,qh.exports);var vZ=qh.exports;const mZ=I0(vZ),$i=new Sa("nexmo-chat"),gZ=["us-3","us-4","eu-3","eu-4","ap-3","ap-4"];class L$ extends _v{constructor(){super(...arguments);ut(this,"rtc");ut(this,"application");ut(this,"conversation")}get _client(){if(this.rtc)return this.rtc;const t=yZ(this.region);return this.rtc=new mZ({nexmo_api_url:`https://api-${this.region}.${t}`,url:`wss://ws-${this.region}.${t}`}),this.rtc}async create(){const{identity:t,token:n}=await this.issueChatToken();$i.info(`Connecting chat, identity: ${t}, token: ${n}`),this.identity=t,this.application=await this._client.createSession(n)}async destroy(){this.rtc&&(await this.rtc.deleteSession(),this.rtc=null,this.application=null,this.conversation=null)}async join(t){const n=await this.application.getConversation(t);n.me.state==="JOINED"?$i.info("already joined conversation:",t):(await n.join(),$i.info("success joined conversation:",t)),this.registerEvents(n),this.conversation=n}async preview(t){await this.conversation.sendCustomEvent({type:"ujet_preview",body:{chat_preview:t,chat_preview_updated_at:new Date().toJSON()}})}async fetchMessages(t){const n=await this.conversation.getEvents({event_type:"message",order:"desc",page_size:100}),i=[];return n.items.forEach(a=>{const s=a._embedded.from_user.name,o=_0(a,s);t[o.$index]&&(o.file=t[o.$index]),this.trackInTask(o),i.push(o)}),i.reverse()}async sendMessage(t){try{const n=await this.conversation.sendMessage({message_type:"text",text:JSON.stringify(t)});return $i.info(`Message sent from ${this.conversation.id}, id: ${n.id}`),parseInt(n.id,10)}catch(n){$i.warn(`Failed to send a message from ${this.conversation.id}`,{error:n})}}startTyping(){this.conversation&&this.conversation.startTyping()}stopTyping(){this.conversation&&this.conversation.stopTyping()}registerEvents(t){t.on("message",(n,i)=>{const a=_0(i,n.userName);$i.info(`Message added from ${this.conversation.id}, index: ${a.$index}, sid: ${a.$sid}, timestamp: ${a.$timestamp}, user type: ${a.$userType}`),a.$userType!=="end_user"&&this.ping(),this.trackInTask(a),this.events.triggerEvent("message",a)}),t.on("member:joined",n=>{$i.info("conversation: memberJoined",n),this.events.triggerEvent("memberJoined",n.userName)}),t.on("member:left",n=>{$i.info("conversation: memberLeft",n),this.events.triggerEvent("memberLeft",n.userName)}),t.on("text:typing:on",n=>{/^end_user/.test(n.userName)||this.events.triggerEvent("typingStarted",n.userName)}),t.on("text:typing:off",n=>{/^end_user/.test(n.userName)||this.events.triggerEvent("typingEnded",n.userName)})}}ut(L$,"type","nexmo_conversations");wv(L$);function yZ(e){return gZ.indexOf(e)>-1?"vonage.com":"nexmo.com"}function _0(e,r){const{id:t,timestamp:n,body:i}=e,[a,s]=r.split("-");let o=0;s&&(o=parseInt(s,10));const u={$index:parseInt(t,10),$sid:t,$timestamp:new Date(Date.parse(n)),$userType:a,$userId:o};try{const c=JSON.parse(i.text);return c.message&&!c.type?{...u,...c,type:"message"}:{...u,...c}}catch(c){return $i.warn("Format message failed",{error:c,data:i.text}),{...u,type:"text",content:i.text}}}exports.Client=aO;exports.ENVIRONMENT=U$;exports.EventManager=bv;exports.Logger=Sa;exports.MediaStore=S0;exports.OPTIONS=Pr;exports.PostSessionStatus=Vs;exports.VERSION=gv;exports.addProviderType=wv;exports.consoleLoggerHandler=G$;
525
+ `},hs=C$,BQ=UQ;Xi.write=BQ;Xi.parse=hs.parse;Xi.parseParams=hs.parseParams;Xi.parseFmtpConfig=hs.parseFmtpConfig;Xi.parsePayloads=hs.parsePayloads;Xi.parseRemoteCandidates=hs.parseRemoteCandidates;Xi.parseImageAttributes=hs.parseImageAttributes;Xi.parseSimulcastStreamList=hs.parseSimulcastStreamList;var Qi={},qQ=Ae&&Ae.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;for(var n=Array(e),i=0,r=0;r<t;r++)for(var a=arguments[r],s=0,o=a.length;s<o;s++,i++)n[i]=a[s];return n};Object.defineProperty(Qi,"__esModule",{value:!0});var k$=function(){function e(r,t,n){this.name=r,this.version=t,this.os=n}return e}();Qi.BrowserInfo=k$;var R$=function(){function e(r){this.version=r,this.name="node",this.os=process.platform}return e}();Qi.NodeInfo=R$;var $$=function(){function e(){this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}();Qi.BotInfo=$$;var zQ=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,WQ=/(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves\/Teoma)|(ia_archiver)/,a0=3,VQ=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["vivaldi",/Vivaldi\/([0-9\.]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/Edg\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",zQ]],s0=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/],["Search Bot",WQ]];function GQ(e){return e?uv(e):typeof navigator<"u"?uv(navigator.userAgent):O$()}Qi.detect=GQ;function uv(e){var r=e!==""&&VQ.reduce(function(a,s){var o=s[0],u=s[1];if(a)return a;var c=u.exec(e);return!!c&&[o,c]},!1);if(!r)return null;var t=r[0],n=r[1];if(t==="searchbot")return new $$;var i=n[1]&&n[1].split(/[._]/).slice(0,3);return i?i.length<a0&&(i=qQ(i,HQ(a0-i.length))):i=[],new k$(t,i.join("."),I$(e))}Qi.parseUserAgent=uv;function I$(e){for(var r=0,t=s0.length;r<t;r++){var n=s0[r],i=n[0],a=n[1],s=a.test(e);if(s)return i}return null}Qi.detectOS=I$;function O$(){var e=typeof process<"u"&&process.version;return e?new R$(process.version.slice(1)):null}Qi.getNodeVersion=O$;function HQ(e){for(var r=[],t=0;t<e;t++)r.push("0");return r}var jc={exports:{}};function KQ(e,r){if(typeof e[Symbol.iterator]=="function")for(const t of e){const n=Array.isArray(t)?t[1]:t;r(n)}else for(const t in e)if(e.hasOwnProperty(t)){const n=e[t];r(n)}}var P$={iterateReports:KQ};const JQ={"outbound-rtp":{packetsSent:"audioSentPackets",bytesSent:"audioSentBytes"},"inbound-rtp":{packetsReceived:"audioRecvPackets",packetsLost:"audioRecvPacketsLost",bytesReceived:"audioRecvBytes",jitter:"audioRecvJitter"},"remote-inbound-rtp":{packetsLost:"audioSentPacketsLost",roundTripTime:"audioRtt",jitter:"audioSentJitter"}},YQ={"remote-candidate":function(e){return Fc(e)},"inbound-rtp":function(e){return Fc(e)},"outbound-rtp":function(e){return Fc(e)},"remote-inbound-rtp":function(e){return Fc(e)}},Fc=e=>{const{type:r}=e,t=JQ[r],n={};for(let i in t)if(i in e){let a;typeof t[i]=="function"?a=t[i](e):a=t[i],n[a]=e[i]}else n[t[i]]=null;return n};var XQ={parsers:YQ};const{iterateReports:QQ}=P$;function ZQ(e){let r=0,t=0,n=0,i=100,a=0,s,o,u;return QQ(e,c=>{c.type==="inbound-rtp"&&(r=c.jitter,n=c.packetsLost,t=c.packetsReceived)}),t+n>0&&(a=100*(n/(t+n))),s=i+r*2+10,s<160?o=93.2-s/40:o=93.2-(s-120)/10,o=o-a*2.5,o<1&&(o=1),u=1+.035*o+7e-6*o*(o-60)*(100-o),parseFloat(u).toFixed(6)}var A$=ZQ;const{iterateReports:eZ}=P$,{parsers:o0}=XQ,tZ=A$;function rZ(e){const r={};return eZ(e,t=>{if(t.type in o0){const n=o0[t.type](t);Object.assign(r,n)}}),r.networkMos=parseFloat(tZ(e)),r}var nZ=rZ,u0;function iZ(){return u0||(u0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0});const n=nZ,i=A$,a=t(yi());class s{constructor(u){this.mos_report={min:5,max:0},this._reportsCount=0,this._mosSum=0,this.intervals=[],this._deprecationWarningSent=!1,!(!u||!u.application||!u.rtc_id||!u.pc)&&(this.conversation=null,this.application_id=null,this.attachHandlers(u),this.startSendingStats(u),this.startEmittingStats(u))}attachHandlers(u){const{pc:c}=u;c.addEventListener("connectionstatechange",()=>{switch(c.connectionState){case"disconnected":case"failed":case"closed":this.removeIntervals(),this.emitLastReport(u)}}),u.conversation?u.conversation.on("member:media",(h,v)=>{!this.application_id&&(u==null?void 0:u.rtc_id)===v.body.channel.id&&(this.application_id=v.application_id)}):u.application.on("member:joined",(h,v)=>{(!this.conversation||!this.application_id)&&(u==null?void 0:u.rtc_id)===v.body.channel.id&&(this.conversation=h.conversation,this.application_id=v.application_id)})}emitLastReport(u){const{application:c,conversation:l=null,rtc_id:h,config:{emit_events:v,emit_rtc_analytics:m}}=u,_=this.getMOSReport(),C=_.last;C&&(m&&c.emit("rtcstats:analytics",{type:"mos_report",mos:C,rtc_id:h,mos_report:_,api_key:c.session.apiKey,...this.application_id&&{application_id:this.application_id},...l&&{conversation_id:l.id,conversation_name:l.name}}),v&&(this._deprecationWarningSent||(this._deprecationWarningSent=!0,console.warn('"rtcstats:report" event is deprecated. Use "rtcstats:analytics" instead')),c.emit("rtcstats:report",C,null,l,_)))}startSendingStats(u){const{application:c,conversation:l=null,pc:h,rtc_id:v,config:{remote_collection:m,remote_collection_url:_,remote_collection_interval:C}}=u;if(!m)return;const I=setInterval(()=>{h.getStats(null).then($=>{var x;const N=(x=l??this.conversation)!==null&&x!==void 0?x:null;a.default.networkRequest({url:_,type:"POST",data:{...n($),legId:v,apiKey:c.session.apiKey,...this.application_id&&{applicationId:this.application_id},...N&&{conversationId:N.id,conversationName:N.name}}}).catch(()=>{})}).catch(()=>{}),(h.connectionState==="closed"||h.signalingState==="closed")&&this.removeIntervals()},C);this.intervals.push(I)}startEmittingStats(u){const{application:c,conversation:l=null,pc:h,rtc_id:v,config:{emit_events:m,emit_rtc_analytics:_,emit_interval:C}}=u;if(!m&&!_)return;const I=setInterval(()=>{var $;h.getStats(null).then(x=>{var N;const q=this.getMos(x);if(!q)return;const X=(N=l??this.conversation)!==null&&N!==void 0?N:null;_&&c.emit("rtcstats:analytics",{type:"mos",mos:q,report:x,rtc_id:v,api_key:c.session.apiKey,...this.application_id&&{application_id:this.application_id},...X&&{conversation_id:X.id,conversation_name:X.name}}),m&&(this._deprecationWarningSent||(this._deprecationWarningSent=!0,console.warn('"rtcstats:report" event is deprecated. Use "rtcstats:analytics" instead')),c.emit("rtcstats:report",q,x,l))}).catch(()=>{}),(h.connectionState==="closed"||h.signalingState==="closed")&&(this.removeIntervals(),this.emitLastReport({...u,conversation:($=l??this.conversation)!==null&&$!==void 0?$:null}))},C);this.intervals.push(I)}removeIntervals(){this.intervals.forEach(u=>clearInterval(u)),this.intervals=[]}getMos(u){const c=i(u);return this.updateMOSReport(parseInt(c)),c}updateMOSReport(u){this._reportsCount++,this._mosSum+=u,this.mos_report.last=u,this.mos_report.min=u<this.mos_report.min?u:this.mos_report.min,this.mos_report.max=u>this.mos_report.max?u:this.mos_report.max,this.mos_report.average=this._mosSum/this._reportsCount}getMOSReport(){return this.mos_report.min=s.normaliseFloat(this.mos_report.min),this.mos_report.max=s.normaliseFloat(this.mos_report.max),this.mos_report.last=s.normaliseFloat(this.mos_report.last),this.mos_report.average=s.normaliseFloat(this.mos_report.average),this.mos_report}static normaliseFloat(u){return parseFloat(u).toFixed(6)}}r.default=s,e.exports=s}(jc,jc.exports)),jc.exports}var c0;function If(){return c0||(c0=1,function(e,r){var t=Ae&&Ae.__createBinding||(Object.create?function(m,_,C,I){I===void 0&&(I=C),Object.defineProperty(m,I,{enumerable:!0,get:function(){return _[C]}})}:function(m,_,C,I){I===void 0&&(I=C),m[I]=_[C]}),n=Ae&&Ae.__setModuleDefault||(Object.create?function(m,_){Object.defineProperty(m,"default",{enumerable:!0,value:_})}:function(m,_){m.default=_}),i=Ae&&Ae.__importStar||function(m){if(m&&m.__esModule)return m;var _={};if(m!=null)for(var C in m)C!=="default"&&Object.hasOwnProperty.call(m,C)&&t(_,m,C);return n(_,m),_},a=Ae&&Ae.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(r,"__esModule",{value:!0});const s=Xi,o=gr,u=i(Qi),c=Mn,l=a(iZ()),h=2e4;class v{constructor(){this.log=o.getLogger(this.constructor.name)}static getUserAudio(_=!0){let C={video:!1,audio:_};return navigator.mediaDevices.getUserMedia(C)}createRTCPeerConnection(_){const C=new RTCPeerConnection(_);return C.trace=()=>{},C}_getWindowLocationProtocol(){return window.location.protocol}static _getBrowserName(){return u.detect().name}static isNode(){return this._getBrowserName()==="node"}checkValidKeys(_,C){let I=!0;return Object.keys(_).forEach($=>{C.hasOwnProperty($)||(I=!1)}),I}static cleanCallMediaIfFailed(_){setTimeout(()=>{_.conversation||(this.cleanMediaProperties(_),_.status=_.CALL_STATUS.FAILED,_.application.emit("call:status:changed",_))},5e3)}static callDisconnectHandler(_,C){const I=[_.CALL_STATUS.ANSWERED,_.CALL_STATUS.STARTED,_.CALL_STATUS.RINGING];if(!(C.connectionState!=="disconnected"||!_||!_.conversation))return setTimeout(()=>{C.connectionState==="connected"||I.indexOf(_.status)==-1||(this.cleanMediaProperties(_),_.status=_.CALL_STATUS.COMPLETED,_.application.emit("call:status:changed",_))},h)}static cleanMediaProperties(_){if(_.rtcObjects)for(const C in _.rtcObjects)_.rtcObjects[C].pc.close(),delete _.rtcObjects[C].pc,v.closeStream(_.rtcObjects[C].stream);_.application.activeStreams=[],_.rtcObjects={},_.conversation&&_.conversation.media&&(_.conversation.media.rtcStats=null)}static cleanConversationMediaProperties(_,C){C&&v.closeStream(C),_&&_.close()}static playAudioStream(_){const C=new Audio;return C.srcObject=_,C.autoplay=!0,C}static createDummyCandidateSDP(_){const C={foundation:1176891032,component:1,transport:"udp",priority:2122260223,ip:"0.0.0.0",port:9,type:"host",generation:0,"network-id":1,"network-cost":50},I=s.parse(_.localDescription.sdp);return I.media[0].candidates=[C],s.write(I)}static createRTCPeerConnectionConfig(_){return{iceTransportPolicy:"all",bundlePolicy:"balanced",rtcpMuxPolicy:"require",iceCandidatePoolSize:"0",..._.session.config&&_.session.config.iceServers&&{iceServers:_.session.config.iceServers}}}static setupPeerConnectionApplicationListeners(_,C){C.addEventListener("icecandidateerror",I=>_.emit("rtc:icecandidateerror",I)),C.addEventListener("icegatheringstatechange",()=>_.emit("rtc:icegatheringstatechange",C.iceGatheringState)),C.addEventListener("signalingstatechange",()=>_.emit("rtc:signalingstatechange",C.signalingState)),C.addEventListener("iceconnectionstatechange",()=>_.emit("rtc:iceconnectionstatechange",C.iceConnectionState)),C.addEventListener("connectionstatechange",()=>_.emit("rtc:peerconnectionstatechange",C.connectionState))}static createPeerConnection(_){const C=this.createRTCPeerConnectionConfig(_),I=new RTCPeerConnection(C);return this.setupPeerConnectionApplicationListeners(_,I),I}static sendOffer(_,C,I,$){const N={sdp:this.createDummyCandidateSDP(C)};let q={from:I.me.id,body:{offer:N}},X=`conversations/${I.id}/rtc`;return $&&(X+=`/${$}/offer`),_.session.sendNetworkRequest({type:"POST",path:X,data:q})}static sendAnswer(_,C,I,$){const x=this.createDummyCandidateSDP(C);let N={from:I.me.id,body:{answer:x}},q=`conversations/${I.id}/rtc/${$}/answer`;return _.session.sendNetworkRequest({type:"POST",path:q,data:N})}static createLeg(_,C){const $={sdp:this.createDummyCandidateSDP(C),type:"offer"};return _.session.sendNetworkRequest({type:"POST",path:"legs",version:"beta",data:{body:{offer:$}}})}static closeStream(_){_.getTracks().forEach(C=>{C.stop()})}static emitMediaStream(_,C,I){_.emit("media:stream:on",{pc:C,stream:I,type:"audio",streamIndex:0})}static _initStatsEvents(_){var C,I,$;if(!v.isNode()&&!(($=(I=(C=_==null?void 0:_.application)===null||C===void 0?void 0:C.session)===null||I===void 0?void 0:I.config)===null||$===void 0)&&$.rtcstats){const x=_.application.session.config.rtcstats,{emit_events:N,remote_collection:q,emit_rtc_analytics:X}=x;if(N||q||X){const J={..._,config:{...x}};return new l.default(J)}}}static attachConversationEventHandlers(_){const{conversation:C,pc:I,log:$}=_;C.once("rtc:answer",x=>{if(!I){$.warn("RTC: received an answer too late");return}I.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:x.body.answer}))})}static doAnswer(_,C,I){const{application:$,conversation:x,pc:N,reject:q,localStream:X}=_;this.addPeerConnectionListeners(_,()=>v.sendAnswer($,N,x,I).then(()=>({rtc_id:I}))),N.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:C})).then(()=>N.createAnswer()).then(J=>N.setLocalDescription(J)).catch(J=>{v.cleanConversationMediaProperties(N,X),q(J)})}static attachPeerConnectionEventHandlers(_){const{application:C,conversation:I,pc:$,reconnectRtcId:x}=_;this.addPeerConnectionListeners(_,()=>v.sendOffer(C,$,I,x))}static addPeerConnectionListeners(_,C){const{application:I,conversation:$,pc:x,streamIndex:N,localStream:q,log:X,rtcObjects:J,resolve:G,reject:L}=_;let te,se=!1,ne;$.id&&(ne=I.calls.get($.id)),x.ontrack=ge=>{te=ge.streams[0],I.activeStreams.push(te),v.emitMediaStream($.me,x,te)},x.addEventListener("connectionstatechange",ge=>this.onconnectionstatechangeHandler(x,X,ne,()=>G(te),()=>{v.cleanConversationMediaProperties(x,q),L()})),x.addEventListener("negotiationneeded",()=>this.onnegotiationneededHandler(x,ge=>{v.cleanConversationMediaProperties(x,q),L(ge)})),x.addEventListener("iceconnectionstatechange",ge=>this.oniceconnectionstatechange(ge,x,X,Y=>{v.cleanConversationMediaProperties(x,q),L(Y)})),x.addEventListener("icecandidate",async ge=>{if(ge.candidate&&!se&&x){se=!0;try{const{rtc_id:Y}=await C();v._initStatsEvents({application:I,rtc_id:Y,pc:x,conversation:$}),x.trace&&x.trace("rtc_id",Y),J[Y]={rtc_id:Y,pc:x,stream:q,type:"audio",streamIndex:N}}catch(Y){v.cleanConversationMediaProperties(x,q),L(new c.NexmoClientError(Y))}}}),q.getTracks().forEach(ge=>x.addTrack(ge))}static prewarmLeg(_){const C=_.application;return new Promise(async(I,$)=>{let x=!1,N,q,X={},J,G;const L=o.getLogger(this.constructor.name);try{G=await this.getUserAudio(),J=this.createPeerConnection(C),J.ontrack=te=>{N=te.streams[0],C.activeStreams.push(N)},J.addEventListener("connectionstatechange",te=>this.onconnectionstatechangeHandler(J,L,_,()=>I({stream:N,legId:q,rtcObjects:X}),()=>{v.cleanConversationMediaProperties(J,G),$()})),J.addEventListener("negotiationneeded",()=>this.onnegotiationneededHandler(J,te=>{v.cleanConversationMediaProperties(J,G),$(te)})),J.addEventListener("iceconnectionstatechange",te=>this.oniceconnectionstatechange(te,J,L,se=>{v.cleanConversationMediaProperties(J,G),$(se)})),J.addEventListener("icecandidate",async te=>{if(te.candidate&&!x&&J){x=!0;const{rtc_id:se,sdp:ne}=await this.createLeg(C,J);return v._initStatsEvents({application:C,rtc_id:se,pc:J}),q=se,X[q]={rtc_id:se,pc:J,stream:G,type:"audio",streamIndex:1},J.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:ne}))}}),G.getTracks().forEach(te=>J.addTrack(te))}catch(te){v.cleanConversationMediaProperties(J,G),$(new c.NexmoClientError(te))}})}}r.default=v,v.onconnectionstatechangeHandler=(m,_,C,I,$)=>{switch(m.connectionState){case"connected":_.info("The connection has become fully connected"),I();break;case"disconnected":if(!C)break;C.call_disconnect_timeout&&clearTimeout(C.call_disconnect_timeout),C.call_disconnect_timeout=v.callDisconnectHandler(C,m);break;case"failed":$(),_.info("One or more transports has terminated unexpectedly or in an error");break;case"closed":_.info("The connection has been closed");break}},v.oniceconnectionstatechange=(m,_,C,I)=>{switch(_.iceConnectionState){case"disconnected":C.warn("One or more transports is disconnected",_.iceConnectionState);break;case"failed":I(new c.NexmoClientError(m)),C.warn("One or more transports has terminated unexpectedly or in an error",m);break;default:C.info("The ice connection status changed",_.iceConnectionState)}},v.onnegotiationneededHandler=async(m,_)=>{try{const C=await m.createOffer();return m.setLocalDescription(C)}catch(C){_(new c.NexmoClientError(C))}},e.exports=v}(Dc,Dc.exports)),Dc.exports}var l0;function aZ(){return l0||(l0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=Mn,a=t(If()),s=t(yi()),o=t(Yi),u=t(N$()),c=t(Pf());class l{constructor(v){var m,_,C;const I=v instanceof u.default?v:null,$=v instanceof c.default?v:null;this.log=n.getLogger(this.constructor.name),I?(this.rtcHelper=new a.default,this.application=I.application,this.application.activeStreams=this.application.activeStreams||[],this.parentConversation=I,this.rtcObjects={},this.streamIndex=0,this.rtcstats_conf=((C=(_=(m=this.application)===null||m===void 0?void 0:m.session)===null||_===void 0?void 0:_.config)===null||C===void 0?void 0:C.rtcStats)||{},this.rtcStats=null):$?(this.rtcHelper=new a.default,this.application=$):this.log.warn("No conversation object in Media")}_attachEndingEventHandlers(){this.parentConversation&&(this.log.debug("attaching leave listeners in media for "+this.parentConversation.id),this.parentConversation.on("rtc:hangup",async v=>{let m;if(this.parentConversation.members.has(v.from))m=this.parentConversation.members.get(v.from);else try{m=await this.parentConversation.getMember(v.from)}catch(_){this.log.warn(`There is an error getting the member ${_}`)}m.user.id===this.application.me.id&&this.application.activeStreams.length&&this._cleanMediaProperties(),m.user.id===this.application.me.id&&m.transferred_from&&m.transferred_from.media._cleanMediaProperties(),m.user.id===this.application.me.id&&this.parentConversation.off("rtc:hangup")}))}_enableStatsEvents(){this.rtcstats_conf.emit_rtc_analytics=!0,this.rtcstats_conf.remote_collection=!0;const v=this._findRtcObjectByType("audio");!this.rtcStats&&v&&(this.log.debug(`enabling stats events for ${v.rtc_id}`),this.rtcStats=a.default._initStatsEvents({application:this.application,rtc_id:v.rtc_id,pc:this.pc,conversation:this.parentConversation}))}_disableStatsEvents(){this.rtcstats_conf.emit_events=!1,this.rtcstats_conf.emit_rtc_analytics=!1,this.rtcstats_conf.remote_collection=!1,this.rtcStats.removeIntervals(),delete this.rtcStats}_audioInitHandler(v={},m){return new Promise(async(_,C)=>{const I=this.streamIndex;this.streamIndex++;const{audioConstraints:$}=v;try{const x=await a.default.getUserAudio($),N=a.default.createPeerConnection(this.application);this.pc=N;const{application:q,log:X,parentConversation:J,rtcObjects:G}=this,L={pc:N,streamIndex:I,localStream:x,application:q,conversation:J,log:X,rtcObjects:G};m({...L,resolve:_,reject:C}),a.default.attachConversationEventHandlers(L),this._attachEndingEventHandlers()}catch(x){C(new i.NexmoClientError(x))}})}_execAnswer(v={}){const{offer:{sdp:m,leg_id:_}}=v;return this._audioInitHandler(v,C=>a.default.doAnswer(C,m,_))}_handleAudio(v={}){const{reconnectRtcId:m}=v;return this._audioInitHandler(v,_=>a.default.attachPeerConnectionEventHandlers({..._,reconnectRtcId:m}))}_findRtcObjectByType(v){return Object.values(this.rtcObjects).find(m=>m.type===v)}async _cleanConversationProperties(){this.pc&&this.pc.close(),delete this.pc,this.rtcStats=null,this.application.activeStreams=[],this.listeningToRtcEvent=!1,await Promise.resolve()}_cleanMediaProperties(){if(this.pc&&this.pc.close(),this.rtcObjects)for(const v in this.rtcObjects)a.default.closeStream(this.rtcObjects[v].stream);delete this.pc,this.rtcStats=null,this.application.activeStreams=[],this.rtcObjects={},this.listeningToRtcEvent=!1}async _disableLeg(v){const m=new Promise(async(C,I)=>{try{await this.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.parentConversation.id}/rtc/${v}?from=${this.parentConversation.me.id}&originating_session=${this.application.session.session_id}`,version:"beta2"}),C("rtc:terminate:success")}catch($){I(new i.NexmoApiError($))}}),_=new Promise(C=>{this.rtcObjects[v].pc&&this.rtcObjects[v].pc.close(),this.rtcObjects[v].stream&&a.default.closeStream(this.rtcObjects[v].stream),C()});try{return await Promise.all([m,_]),this.parentConversation.me.emit("media:stream:off",this.rtcObjects[v].streamIndex),delete this.rtcObjects[v],"rtc:terminate:success"}catch(C){throw C}}_enableMediaTracks(v,m){v.forEach(_=>{_.enabled=m})}async _setMediaTracksAndMute(v,m,_,C){this._enableMediaTracks(m,!_);try{return await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:C,to:this.parentConversation.me.id,from:this.parentConversation.me.id,body:{rtc_id:v}}})}catch(I){throw this._enableMediaTracks(m,_),new i.NexmoApiError(I)}}async updateAudioConstraints(v={}){let m=this._findRtcObjectByType("audio");if(m&&m.pc)try{const _=await a.default.getUserAudio(v);return _.getTracks().forEach(C=>{const I=m.pc.getSenders().find($=>$.track.kind===C.kind);I&&(C.enabled=I.track.enabled,I.replaceTrack(C))}),a.default.closeStream(m.stream),m.stream=_,_}catch(_){return _}else throw new i.NexmoApiError("error:media:stream:not-found")}mute(v=!1,m=null){const C="audio:mute:"+(v?"on":"off");let I=[],$={};if(m!==null){if($[0]=Object.values(this.rtcObjects).find(x=>x.streamIndex===m),!$[0])throw new i.NexmoClientError("error:media:stream:not-found")}else $=this.rtcObjects;return Object.values($).forEach(x=>{const N=x.stream.getAudioTracks(),q=this._setMediaTracksAndMute(x.rtc_id,N,v,C);I.push(q)}),Promise.all(I)}async earmuff(v){try{if(this.me===null)throw new i.NexmoClientError("error:self");{let m="audio:earmuff:off";v&&(m="audio:earmuff:on");const{response:_}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:m,to:this.parentConversation.me.id}});return _}}catch(m){throw new i.NexmoApiError(m)}}async enable(v){try{if(this.parentConversation.me===null)throw new i.NexmoClientError("error:self");{const{offer:m}=v??{};let _=await(m!==void 0?this._execAnswer(v):this._handleAudio(v)),C=v&&(v.autoPlayAudio||v.autoPlayAudio===void 0);return(!v||C)&&a.default.playAudioStream(_),_}}catch(m){throw m}}disable(){let v=[];v.push(this._cleanConversationProperties());for(const m in this.rtcObjects)v.push(this._disableLeg(m));return Promise.all(v)}async sayText(v){try{const m=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:say",cid:this.parentConversation.id,from:this.parentConversation.me.id,body:{text:v.text,voice_name:v.voice_name||"Amy",level:v.level||1,queue:v.queue||!0,loop:v.loop||1,ssml:v.ssml||!1}}});return new o.default(this.parentConversation,m)}catch(m){throw new i.NexmoApiError(m)}}async sendDTMF(v){try{if(!s.default.validateDTMF(v))throw new i.NexmoClientError("error:audio:dtmf:invalid-digit");if(!(this._findRtcObjectByType("audio")||{}).rtc_id)throw new i.NexmoClientError("error:audio:dtmf:audio-disabled");const{id:_,timestamp:C}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:dtmf",from:this.parentConversation.me.id,body:{digit:v,channel:{type:"app",id:this._findRtcObjectByType("audio").rtc_id}}}}),I={body:{digit:v,dtmf_id:""},cid:this.parentConversation.id,from:this.parentConversation.me.id,id:_,timestamp:C,type:"audio:dtmf"},$=new o.default(this.parentConversation,I);return this.parentConversation.events.set(I.id,$),$}catch(m){throw new i.NexmoApiError(m)}}async playStream(v){try{const m=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:play",body:v}});return new o.default(this.parentConversation,m)}catch(m){throw new i.NexmoApiError(m)}}async startRinging(){try{const v=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:ringing:start",from:this.parentConversation.me.id,body:{}}});return new o.default(this.parentConversation,v)}catch(v){throw new i.NexmoApiError(v)}}async stopRinging(){try{const v=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.parentConversation.id}/events`,data:{type:"audio:ringing:stop",from:this.parentConversation.me.id,body:{}}});return new o.default(this.parentConversation,v)}catch(v){throw new i.NexmoApiError(v)}}}r.default=l,e.exports=l}(Lc,Lc.exports)),Lc.exports}var Uc={exports:{}},Bc={exports:{}},f0;function M$(){return f0||(f0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(yi()),i=gr,a=t(Yi);class s extends a.default{constructor(u,c){super(u,c),this.log=i.getLogger(this.constructor.name),this.type="image",this.conversation=u,this.state={seen_by:{},delivered_to:{}},c&&c.body&&c.body.timestamp&&(this.timestamp=c.body.timestamp),Object.assign(this,c)}seen(){return super.seen()}delivered(){return super.delivered()}async del(){return await n.default.networkRequest({type:"DELETE",url:this.body.representations.original.url,token:this.conversation.application.session.config.token}),super.del()}async fetchImage(u="thumbnail",c=this.body.representations){try{return n.default._fetchImage(c[u].url,this.conversation.application.session.config.token)}catch(l){throw this.log.error(l),l}}}r.default=s,e.exports=s}(Bc,Bc.exports)),Bc.exports}var d0;function sZ(){return d0||(d0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=t(Yi),a=t(mg),s=t(M$()),o=t(gg());class u{constructor(l,h){this.log=n.getLogger(this.constructor.name),this.application=l,this.conversation=h,this.constructed_event=null,this._handleEventMap={"event:delete":this._processDelete,image:this._processImage,"image:delivered":this._processDelivered,"image:seen":this._processSeen,"member:invited":this._processMember,"member:joined":this._processMember,"member:left":this._processMember,"audio:ringing:start":this._processMember,"leg:status:update":this._processLegStatus,"member:media":this._processMedia,text:this._processText,"text:delivered":this._processDelivered,"text:seen":this._processSeen,"audio:mute:on":this._processMuteForMedia,"audio:mute:off":this._processMuteForMedia,message:this._processMessage,"message:delivered":this._processDelivered,"message:seen":this._processSeen,"message:submitted":this._processSubmitted,"message:rejected":this._processRejected,"message:undeliverable":this._processUndeliverable}}handleEvent(l){return this._handleEventMap.hasOwnProperty(l.type)?this._handleEventMap[l.type].call(this,l)||new i.default(this.conversation,l):new i.default(this.conversation,l)}_processDelivered(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.delivered_to=h.state.delivered_to||{},h.state.delivered_to[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processDelete(l){var h;let v=this.conversation.events.get((h=l==null?void 0:l.body)===null||h===void 0?void 0:h.event_id);return v?(v.body.text&&(v.body.text=""),v.body.representations&&(v.body.representations=""),v.body.timestamp={deleted:l.timestamp},v):(this.log.warn("NXMEvent not found"),null)}_processImage(l){var h;const v=new s.default(this.conversation,l);return((h=this.conversation.me)===null||h===void 0?void 0:h.id)!==v.from&&v.delivered(),v}_processMember(l){return this.application.calls.has(this.conversation.id)&&this.application.calls.get(this.conversation.id)._handleStatusChange(l),this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),new i.default(this.conversation,l)}_processLegStatus(l){return this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),new i.default(this.conversation,l)}_processMedia(l){return this.conversation.members.has(l.from)&&this.conversation.members.get(l.from)._handleEvent(l),null}_processMuteForMedia(l){return this.conversation.media.rtcObjects[l.body.rtc_id]?l.streamIndex=this.conversation.media.rtcObjects[l.body.rtc_id].streamIndex:this.log.warn("No audio stream was found"),null}_processSeen(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.seen_by=h.state.seen_by||{},h.state.seen_by[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processText(l){var h,v;const m=new a.default(this.conversation,l);return((v=(h=this.conversation)===null||h===void 0?void 0:h.me)===null||v===void 0?void 0:v.id)!==m.from&&m.delivered(),m}_processMessage(l){var h,v;const m=new o.default(this.conversation,l);return((v=(h=this.conversation)===null||h===void 0?void 0:h.me)===null||v===void 0?void 0:v.id)!==m.from&&m.delivered(),m}_processSubmitted(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.submitted_to=h.state.submitted_to||{},h.state.submitted_to[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processRejected(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.rejected_by=h.state.rejected_by||{},h.state.rejected_by[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}_processUndeliverable(l){let h=this.conversation.events.get(l.body.event_id);return h?(h.state=h.state||{},h.state.undeliverable_to=h.state.undeliverable_to||{},h.state.undeliverable_to[l.from]=l.timestamp,h):(this.log.warn("NXMEvent not found"),null)}}r.default=u,e.exports=u}(Uc,Uc.exports)),Uc.exports}var cv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});class t{constructor(i={}){this.page_size=i.page_size||10,this.order=i.order||"asc",this.cursor=i.cursor||"",this.state=i.state||"",i.event_type&&(this.event_type=i.event_type)}}r.default=t,e.exports=t})(cv,cv.exports);var x$=cv.exports,qc={exports:{}},lv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Mn;class n{constructor(a={}){this.page_size=a.page_size,this.order=a.order,this.cursor=a.cursor,this.application=a.application,a.event_type&&a.event_type.length>0&&(this.event_type=a.event_type)}hasPrev(){return this.cursor.prev?this.cursor.prev.length>0:!1}hasNext(){return this.cursor.next?this.cursor.next.length>0:!1}_getConfig(a){return{page_size:this.page_size,order:this.order,cursor:a,...this.event_type&&{event_type:this.event_type}}}_getError(){return Promise.reject(new t.NexmoClientError("error:invalid-cursor"))}}r.default=n,e.exports=n})(lv,lv.exports);var Of=lv.exports,p0;function oZ(){return p0||(p0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of),i=t(Yi),a=t(mg),s=t(M$()),o=t(gg());class u extends n.default{constructor(l){super(l),this.items=new Map,this.conversation=l.conversation,l.items.forEach(h=>{switch(h.type){case"text":this.items.set(h.id,new a.default(this.conversation,h));break;case"image":this.items.set(h.id,new s.default(this.conversation,h));break;case"message":this.items.set(h.id,new o.default(this.conversation,h));break;default:this.items.set(h.id,new i.default(this.conversation,h));break}}),this.conversation.events=new Map([...this.conversation.events,...this.items])}getPrev(){return this.hasPrev()?this.conversation.getEvents(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.conversation.getEvents(this._getConfig(this.cursor.next)):this._getError()}}r.default=u,e.exports=u}(qc,qc.exports)),qc.exports}var zc={exports:{}},h0;function uZ(){return h0||(h0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of),i=t(vg());class a extends n.default{constructor(o){super(o),this.conversation=o.conversation,this.items=new Map,o.items.forEach(u=>{this.items.set(u.id,new i.default(this.conversation,u))})}getPrev(){return this.hasPrev()?this.conversation.getMembers(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.conversation.getMembers(this._getConfig(this.cursor.next)):this._getError()}}r.default=a,e.exports=a}(zc,zc.exports)),zc.exports}var v0;function N$(){return v0||(v0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=gr,a=Mn,s=t(vg()),o=t(Yi),u=t(mg),c=t(gg()),l=t(aZ()),h=t(sZ()),v=t(yi()),m=t(x$),_=t(oZ()),C=t(uZ()),I=t(Pf());class ${constructor(N,q){this.log=i.getLogger(this.constructor.name),this.application=N,this.id=null,this.name=null,this.display_name=null,this.timestamp=null,this.members=new Map,this.events=new Map,this.sequence_number=0,this.pageConfig=new m.default(((this.application.session||{}).config||{}).events_page_config),this.events_page_last=null,this.members_page_last=null,this.conversationEventHandler=new h.default(N,this),this.media=new l.default(this),this.me=null,this._updateObjectInstance(q),n.mixin($)}_updateObjectInstance(N){for(let q in N)switch(q){case"id":this.id=N.id;break;case"name":this.name=N.name;break;case"display_name":this.display_name=N.display_name;break;case"members":N.members.forEach(J=>{if(this.members.has(J.member_id))this.members.get(J.member_id)._normalise(J),J.user_id===this.application.me.id&&J.state!=="LEFT"&&(this.me=this.members.get(J.member_id),this.members.set(this.me.id,this.me));else{const G=new s.default(this,J);J.user_id===this.application.me.id&&J.state!=="LEFT"&&(this.me=G),this.members.set(G.id,G)}});break;case"timestamp":this.timestamp=N.timestamp;break;case"sequence_number":this.sequence_number=N.sequence_number;break;case"member_id":const X={id:N.member_id,state:N.state,user:this.application.me};if(this.members.has(N.member_id)){const J=this.members.get(N.member_id);Object.assign(J,X)}else{const J=new s.default(this,X);this.me=J,this.members.set(J.id,J)}break}}async join(N){var q,X;try{let J={state:"joined",channel:{type:"app"},user:{...!N&&{name:this.application.me.name,id:this.application.me.id},...N&&N.user_name&&{name:N.user_name},...N&&N.user_id&&{id:N.user_id}}};!((q=this===null||this===void 0?void 0:this.me)===null||q===void 0)&&q.id&&((X=this===null||this===void 0?void 0:this.me)===null||X===void 0?void 0:X.state)!=="LEFT"&&(J.from=this.me.id);const G=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/members`,version:"v0.3",data:J}),L=new s.default(this,G);return G._embedded.user.id===this.application.me.id&&(this.me=L,this.members.set(L.id,L)),this.application.getConversation(this.id,I.default.CONVERSATION_API_VERSION.v3),L}catch(J){throw new a.NexmoApiError(J)}}async del(){try{const N=await this.application.session.sendNetworkRequest({type:"DELETE",path:`conversations/${this.id}`});return this.application.conversations.delete(this.id),N}catch(N){throw new a.NexmoApiError(N)}}deleteEvent(N){return N.del()}async invite(N){var q,X;if(!N||!N.id&&!N.user_name)throw new a.NexmoClientError("error:invite:missing:params");const J={state:"invited",user:{...N.id&&{id:N.id},...N.user_name&&{name:N.user_name}},media:N.media,channel:{from:{type:"app"},to:{type:"app"},type:"app"}};!((q=this===null||this===void 0?void 0:this.me)===null||q===void 0)&&q.id&&((X=this===null||this===void 0?void 0:this.me)===null||X===void 0?void 0:X.state)!=="LEFT"&&(J.from=this.me.id);try{const G=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/members`,version:"v0.3",data:J});return new s.default(this,G)}catch(G){throw new a.NexmoApiError(G)}}inviteWithAudio(N){return!N||!N.id&&!N.user_name?Promise.reject(new a.NexmoClientError("error:invite:missing:params")):(N.media={audio_settings:{enabled:!0,muted:!1,earmuffed:!1}},this.invite(N))}leave(N){return this.me.kick(N)}async sendText(N){try{if(this.me===null)throw new a.NexmoClientError("error:self");const q={type:"text",cid:this.id,from:this.me.id,body:{text:N}},{id:X,timestamp:J}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q});return q.id=X,q.body.timestamp=J,new u.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}async sendCustomEvent({type:N,body:q}){try{if(this.me===null)throw new a.NexmoClientError("error:self");if(!N||typeof N!="string"||N.length<1)throw new a.NexmoClientError("error:custom-event:invalid");const X={type:`custom:${N}`,cid:this.id,from:this.me.id,body:q},{id:J,timestamp:G}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:X});return X.id=J,X.timestamp=G,new o.default(this,X)}catch(X){throw new a.NexmoApiError(X)}}async sendEphemeralEvent(N){try{if(this.me===null)throw new a.NexmoClientError("error:self");const q={type:"ephemeral",cid:this.id,from:this.me.id,body:N},{id:X,timestamp:J}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q});return q.timestamp=J,new o.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}async uploadImage(N,q={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const X=new FormData;X.append("file",N),X.append("quality_ratio",q.quality_ratio),X.append("medium_size_ratio",q.medium_size_ratio),X.append("thumbnail_size_ratio",q.thumbnail_size_ratio);const J=await v.default.networkRequest({type:"POST",url:this.application.session.config.ips_url,data:X,token:this.application.session.config.token});return J.upload.addEventListener("progress",G=>{G.lengthComputable&&this.log.debug("uploading image "+G.loaded+"/"+G.total)},!1),J.onreadystatechange=()=>{J.status!==200&&this.log.error(J)},J}async sendImage(N,q={quality_ratio:"100",medium_size_ratio:"50",thumbnail_size_ratio:"30"}){const X=await this.uploadImage(N,q);return X.onreadystatechange=()=>{if(X.readyState===4&&X.status===200)try{this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:{type:"image",from:this.me.id,body:{representations:JSON.parse(X.responseText)}}}),this.log.info(X)}catch(J){this.log.error(new a.NexmoApiError(J))}},X}abortSendImage(N){return N instanceof XMLHttpRequest?N.abort():new a.NexmoClientError("error:invalid:param:type")}async sendMessage(N){if(this.me===null)throw new a.NexmoClientError("error:self");if(!(N!=null&&N.message_type))throw new a.NexmoClientError("error:message-event:invalid");try{const q={type:"message",cid:this.id,from:this.me.id,body:{...N}},{id:X,timestamp:J}=await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q});return q.id=X,q.body.timestamp=J,new c.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}async _typing(N){const q={cid:this.id,from:this.me.id};try{return await this.application.session.sendNetworkRequest({type:"POST",path:`conversations/${this.id}/events`,data:q}),`text:typing:${N}:success`}catch(X){throw new a.NexmoApiError(X)}}startTyping(){return this._typing("on")}stopTyping(){return this._typing("off")}async getEvents(N={}){const q=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.id}/events`;let X=Object.keys(N).length===0?this.pageConfig:new m.default(N);try{const J=await v.default.paginationRequest(q,X,this.application.session.config.token);J.application=this.application,J.conversation=this;const G=new _.default(J);return this.events_page_last=G,G}catch(J){throw new a.NexmoApiError(J)}}async getMembers(N={}){const q=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.id}/members`;let X=Object.keys(N).length===0?this.pageConfig:new m.default(N);try{const J=await v.default.paginationRequest(q,X,this.application.session.config.token);J.application=this.application,J.conversation=this;const G=new C.default(J);return this.members_page_last=G,G}catch(J){throw new a.NexmoApiError(J)}}async getMyMember(){try{const N=await this.application.session.sendNetworkRequest({type:"GET",path:`conversations/${this.id}/members/me`,version:"v0.3"});return new s.default(this,N)}catch(N){throw new a.NexmoApiError(N)}}async getMember(N){try{const q=await this.application.session.sendNetworkRequest({type:"GET",path:`conversations/${this.id}/members/${N}`,version:"v0.3"});return new s.default(this,q)}catch(q){throw new a.NexmoApiError(q)}}_handleEvent(N){var q,X;if(N.type.startsWith("rtc"))return this.emit(N.type,N),Promise.resolve(N);this.sequence_number++,N.body&&N.body.event_id&&typeof N.body.event_id=="string"&&(N.body.event_id=parseInt(N.body.event_id));let J={memberId:N.from};if(!((q=N==null?void 0:N.body)===null||q===void 0)&&q.user){const{id:L,name:te,display_name:se,image_url:ne,custom_data:ge}=N.body.user;J={...J,...L&&{userId:L},...te&&{userName:te},...se&&{displayName:se},...ne&&{imageUrl:ne},...ge&&{customData:ge}}}else if(!((X=N==null?void 0:N._embedded)===null||X===void 0)&&X.from_user){const{id:L,name:te,display_name:se,image_url:ne,custom_data:ge}=N._embedded.from_user;J={...J,...L&&{userId:L},...te&&{userName:te},...se&&{displayName:se},...ne&&{imageUrl:ne},...ge&&{customData:ge}}}let G=this.conversationEventHandler.handleEvent(N);return["text:typing:on","text:typing:off","ephemeral"].includes(N.type)||this.events.set(G.id,G),N.type.startsWith("custom:")?(this.emit(G.type,J,G),Promise.resolve(N)):(this.emit(N.type,J,G),Promise.resolve(N))}}r.default=$,e.exports=$}(Mc,Mc.exports)),Mc.exports}var Wc={exports:{}},m0;function L$(){return m0||(m0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=gr,a=Mn,s=t(If());class o{constructor(c,l,h){this.application=c,this.log=i.getLogger(this.constructor.name),this.from=h,this.conversation=null,this.rtcObjects={},this.CALL_STATUS={STARTED:"started",RINGING:"ringing",ANSWERED:"answered",COMPLETED:"completed",BUSY:"busy",TIMEOUT:"timeout",UNANSWERED:"unanswered",REJECTED:"rejected",FAILED:"failed"},this.CALL_DIRECTION={INBOUND:"inbound",OUTBOUND:"outbound"},Object.freeze(this.CALL_DIRECTION),this.STATUS_PERMITTED_FLOW=new Map([["STARTED",new Set([this.CALL_STATUS.RINGING,this.CALL_STATUS.ANSWERED,this.CALL_STATUS.FAILED,this.CALL_STATUS.TIMEOUT,this.CALL_STATUS.UNANSWERED,this.CALL_STATUS.REJECTED,this.CALL_STATUS.BUSY])],["RINGING",new Set([this.CALL_STATUS.ANSWERED,this.CALL_STATUS.FAILED,this.CALL_STATUS.TIMEOUT,this.CALL_STATUS.UNANSWERED,this.CALL_STATUS.REJECTED,this.CALL_STATUS.BUSY])],["ANSWERED",new Set([this.CALL_STATUS.COMPLETED,this.CALL_STATUS.FAILED])]]),Object.freeze(this.STATUS_PERMITTED_FLOW),this.status=null,this.call_disconnect_timeout=null,this.direction=this.CALL_DIRECTION.INBOUND,this._setupConversationObject(l),n.mixin(o)}_enableStatsEvents(){this.conversation.media._enableStatsEvents()}_attachCallListeners(){this.log.debug("_attachCallListeners : ",{nxmCall:this});try{this.conversation.releaseGroup("call_module"),this.conversation.on("member:media","call_module",(c,l)=>{this.application.calls&&this.application.calls.has(this.conversation.id)&&this.application.calls.get(this.conversation.id)._handleStatusChange(l)})}catch(c){this.log.error("_attachCallListeners_error: ",{e:c})}}_isValidStatusTransition(c){if(!c)throw new a.NexmoClientError(`Provide the status to validate the transition from '${this.status}'`);if(!this.status)return!0;const l=this.status.toUpperCase();return!this.STATUS_PERMITTED_FLOW.has(l)||this.status===c?!1:this.STATUS_PERMITTED_FLOW.get(l).has(c)}hangUpIfAllLeft(){if(this.log.debug("hangUpIfAllLeft: ",{nxmCall:this}),!this.conversation.me||this.conversation.me.state==="LEFT"||this.conversation.members.size<=1)return Promise.resolve();for(let c of this.conversation.members.values())if(c.state!=="LEFT"&&this.conversation.me.user.id!==c.user.id)return Promise.resolve();return this.hangUp()}_setupConversationObject(c,l){c&&(this.conversation=c,c.me?(this.to=new Map(c.members),this.from&&this.to.delete(this.from.id)):this.log.warn("missing own member object"),this._attachCallListeners())}_setFrom(c){this.from=c}_setOffer(c){this.offer=c}_handleStatusChange(c){var l;const h=this.conversation?((l=this.conversation.me)===null||l===void 0?void 0:l.id)===c.from:!0,v=this.direction===this.CALL_DIRECTION.OUTBOUND;this.log.debug("_handleStatusChange: ",{event:c},`_isEventFromMe: ${h} _isOutbound: ${v}`);let m=new Map;if(m.set("member:joined",async()=>{if(c.body.channel&&c.body.channel.id)try{this._setStatusAndEmit(this.CALL_STATUS.STARTED);return}catch(_){throw this._setStatusAndEmit(this.CALL_STATUS.FAILED),this.log.error(_),_}return Promise.resolve()}),m.set("member:invited",()=>(c.body.invited_by===null&&c.body.user.media&&c.body.user.media.audio_settings&&this._setStatusAndEmit(this.CALL_STATUS.STARTED),Promise.resolve())),m.set("rtc:hangup",()=>this.status===this.CALL_STATUS.ANSWERED?(this._setStatusAndEmit(this.CALL_STATUS.COMPLETED),Promise.resolve()):h&&v||!h&&!v?(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve()):(this._setStatusAndEmit(this.CALL_STATUS.REJECTED),Promise.resolve())),m.set("member:left",()=>{if(!c.body.timestamp.hasOwnProperty("joined")&&this.status!==this.CALL_STATUS.ANSWERED)return h&&v||!h&&!v?(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve()):(this._setStatusAndEmit(this.CALL_STATUS.REJECTED),Promise.resolve())}),m.set("member:media",()=>(this.status!==this.CALL_STATUS.ANSWERED&&c.body.audio&&(h&&c.body.channel&&(this.id=c.body.channel.id),(!h||!v)&&this.id&&this._setStatusAndEmit(this.CALL_STATUS.ANSWERED)),Promise.resolve())),m.set("sip:ringing",()=>(this.status!==this.CALL_STATUS.RINGING&&this._setStatusAndEmit(this.CALL_STATUS.RINGING),Promise.resolve())),m.set("sip:hangup",()=>{switch(c.body.reason.sip_code){case 486:this._setStatusAndEmit(this.CALL_STATUS.BUSY);break;case 487:this._setStatusAndEmit(this.CALL_STATUS.TIMEOUT);break;case 403:this._setStatusAndEmit(this.CALL_STATUS.FAILED);break}return Promise.resolve()}),m.set("knocking:delete:success",()=>(this._setStatusAndEmit(this.CALL_STATUS.UNANSWERED),Promise.resolve())),m.has(c.type))return m.get(c.type).call(this)}_setStatusAndEmit(c){this._isValidStatusTransition(c)&&(this.status=c,this.log.debug(`_setStatusAndEmit: ${c}`,{nxmCall:this}),this.application.emit("call:status:changed",this))}async answer(c=!0){if(this.log.debug(`answer: { autoPlayAudio: ${c}`),this.conversation)try{await this.conversation.join();const l=await this.conversation.media.enable({autoPlayAudio:c,offer:this.offer});return this.offer=void 0,l}catch(l){throw this._setStatusAndEmit(this.CALL_STATUS.FAILED),this.log.error(l),l}else throw new a.NexmoClientError("error:call:answer")}async createCall(c,l=!0){if(this.log.debug(`createCall: { usernames: ${c}, autoPlayAudio: ${l} }`),!c||!Array.isArray(c)||c.length===0)return Promise.reject(new a.NexmoClientError("error:application:call:params"));try{const h=await this.application.newConversationAndJoin({display_name:"CALL_"+this.application.me.name+"_"+c.join("_").replace(" ","")});h.members.set(h.me.id,h.me),this.from=h.me,this.successful_invited_members=new Map;const v=c.map(async _=>{try{const C=await h.inviteWithAudio({user_name:_});return h.members.set(C.id,C),this.successful_invited_members.set(C.id,C),C}catch(C){return this.log.error(C),C}}),m=async()=>{if(this.successful_invited_members.size>0)return await h.media.enable({audio:{muted:!1,earmuffed:!1},autoPlayAudio:l}),this.application.calls.set(h.id,this),v;throw v};return await Promise.all(v),this._setupConversationObject(h),await m()}catch(h){throw this.log.error(h),this._setStatusAndEmit(this.CALL_STATUS.FAILED),h}}async createServerCall(c,l,h){this.log.debug(`createServerCall: { user: ${c}, type: ${l}, custom_data: `,{custom_data:h});const v={type:l};l==="phone"?v.number=c:v.user=c;try{const{stream:m,legId:_,rtcObjects:C}=await s.default.prewarmLeg(this);this.log.debug("createServerCall: ",{stream:m},{legId:_},{rtcObjects:C}),this.rtcObjects=C,this.stream=m,this.id=_,this.application._call_draft_list.set(_,this),s.default.playAudioStream(m);const I={type:"POST",path:"knocking",data:{channel:{type:"app",from:{type:"app"},to:v,id:_||null},...h&&Object.keys(h).length&&{properties:{custom_data:h}}}};try{const $=await this.application.session.sendNetworkRequest(I);this.knocking_id=$.id}catch($){throw new a.NexmoApiError($)}return s.default.cleanCallMediaIfFailed(this),m}catch(m){throw s.default.cleanMediaProperties(this),m}}async hangUp(c){if(this.log.debug(`hangUp: { reason: ${c} }`),this.conversation&&await this.conversation.media.disable(),!this.knocking_id&&this.conversation)return this.conversation.leave(c).catch(l=>{if(l.type!=="conversation:error:invalid-member-state")return Promise.reject(l)});{let l=`knocking/${this.knocking_id}`;if(c){let h=new URLSearchParams;Object.keys(c).forEach(v=>{h.append(v,c[v])}),l+=`?${h.toString()}`}try{const h=await this.application.session.sendNetworkRequest({type:"DELETE",path:l});return this.application._call_draft_list.get(this.client_ref)._handleStatusChange(h),this.application._call_draft_list.delete(this.client_ref),h}catch(h){if(this.conversation)return this.log.error(new a.NexmoApiError(h)),this.conversation.leave(c).catch(v=>{if(v.type!=="conversation:error:invalid-member-state")return Promise.reject(v)});this.log.debug("hangup: Problem cancelling the call. Knocking cancel failed and Conversation. Leave not available",h);return}}}reject(c){return this.log.debug(`reject: { reason: ${c} }`),this.conversation?this.conversation.leave(c):Promise.reject(new a.NexmoClientError("error:call:reject"))}}r.default=o,e.exports=o}(Wc,Wc.exports)),Wc.exports}var fv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=gr;class n{constructor(a){this.log=t.getLogger(this.constructor.name),this.application=a,this._handleSipCallEventMap={"sip:hangup":this._processSipHangup,"sip:ringing":this._processSipRinging}}_handleSipCallEvent(a){if(this.log.debug("_handleSipCallEvent: ",{event:a}),!this.application.calls.has(a.cid)){this.log.warn("There is no call object for this Conversation id.");return}const s=this.application.calls.get(a.cid);if(this._handleSipCallEventMap.hasOwnProperty(a.type))return this._handleSipCallEventMap[a.type].call(this,s,a)}_processSipHangup(a,s){this.log.debug("_processSipHangup: ",s),a._handleStatusChange(s)}_processSipRinging(a,s){this.log.debug("_processSipRinging: ",s),a._handleStatusChange(s)}}r.default=n,e.exports=n})(fv,fv.exports);var cZ=fv.exports,dv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=gr;class n{constructor(a){this.log=t.getLogger(this.constructor.name),this.application=a,this._handleRtcEventMap={"rtc:transfer":this._processRtcTransfer,"rtc:answer":this._processRtcAnswer,"rtc:hangup":this._processRtcHangup}}_handleRtcEvent(a){if(this._handleRtcEventMap.hasOwnProperty(a.type))return this._handleRtcEventMap[a.type].call(this,a)}_processRtcTransfer(a){this.log.debug("_processRtcTransfer: ",{event:a});const s=this.application.conversations.get(a.body.transferred_from),o=this.application.conversations.get(a.cid),u=this.application.calls.get(a.body.transferred_from);if(!u){this.log.warn("NXMCall transfer for unknown nxmCall");return}u.conversation.members.get(a.body.was_member).transferred_to=o,u._setupConversationObject(o),u.transferred=!0,this.application.calls.set(a.cid,u),this.application.calls.delete(a.body.transferred_from),s&&(o.members.get(a.from).transferred_from=s,o.media._attachEndingEventHandlers(),Object.entries(o.media.rtcObjects).length===0&&Object.entries(s.media.rtcObjects).length!==0&&Object.assign(o.media.rtcObjects,s.media.rtcObjects),!o.media.pc&&s.media.pc&&Object.assign(o.media.pc=s.media.pc),o.application.activeStreams.length===0&&s.application.activeStreams.length>0&&(o.application.activeStreams=s.application.activeStreams))}_processRtcAnswer(a){this.log.debug("_processRtcAnswer: ",{event:a}),this.application.calls.has(a.cid)&&(this.application.calls.get(a.cid).id=a.body.rtc_id)}_processRtcHangup(a){this.log.debug("_processRtcHangup: ",{event:a}),this.application.calls.has(a.cid)&&this.application.calls.get(a.cid)._handleStatusChange(a)}}r.default=n,e.exports=n})(dv,dv.exports);var lZ=dv.exports,Vc={exports:{}},g0;function fZ(){return g0||(g0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(r,"__esModule",{value:!0});const n=gr,i=t(Yi),a=t(L$()),s=t(yi()),o=t(If());class u{constructor(l){this.log=n.getLogger(this.constructor.name),this.application=l,this._handleApplicationEventMap={"member:joined":this._processMemberJoined,"member:invited":this._processMemberInvited}}handleEvent(l){const h=this.application.conversations.get(l.cid),v=Object.assign({},l);return this._handleApplicationEventMap.hasOwnProperty(l.type)?this._handleApplicationEventMap[l.type].call(this,h,new i.default(h,v),l):new i.default(h,v)}_processMemberJoined(l,h,v){try{if(h.body.channel&&this.application._call_draft_list.has(h.body.channel.id)){this.log.debug("_processMemberJoined: outbound serverCall from sdk",{event:h});const m=this.application._call_draft_list.get(h.body.channel.id);let _=((m.rtcObjects||{})[h.body.channel.id]||{}).pc;if(m._setFrom(l.me),m._setupConversationObject(l,h.body.channel.id),l.media._attachEndingEventHandlers(),Object.entries(l.media.rtcObjects).length===0&&Object.entries(m.rtcObjects).length!==0&&Object.assign(l.media.rtcObjects,m.rtcObjects),!l.media.pc&&_&&Object.assign(l.media.pc=_),l.application.activeStreams.length===0&&m.application.activeStreams.length>0&&(l.application.activeStreams=m.application.activeStreams),delete m.client_ref,delete m.knocking_id,m.rtcStats&&(l.media.rtcStats=m.rtcStats),this.application._call_draft_list.delete(h.body.channel.id),this.application.calls.set(l.id,m),m._handleStatusChange(h),this.log.debug("_processMemberJoined: processedCall ",{nxmCall:m}),l.members&&h.body.member_id){const C=l.members.get(h.body.member_id);C&&this.application.emit("member:call",C,m)}setTimeout(()=>{l!=null&&l.me&&o.default.emitMediaStream(l.me,_,m.stream)},200)}return this.log.debug("_processMemberJoined: default member joined: ",{event:h}),h}catch(m){this.log.error("_processMemberJoined: ",{e:m})}}_processMemberInvited(l,h){var v,m,_,C,I,$;try{if(!l)return this.log.warn(`no conversation object for ${h.type}`),h;if(((v=l.me)===null||v===void 0?void 0:v.user.id)===h.body.invited_by||!(!((_=(m=h.body.user.media)===null||m===void 0?void 0:m.audio_settings)===null||_===void 0)&&_.enabled))return h;const x=s.default.getMemberNumberFromEventOrNull(h.body.channel)||s.default.getMemberFromNameOrNull(l,h.body.invited_by)||"unknown",N=new a.default(this.application,l,x);return this.application.calls.set(l.id,N),!((C=h.body)===null||C===void 0)&&C.sdp&&this.application.session.config.enableInboundOffer&&N._setOffer({sdp:h.body.sdp,leg_id:h.body.channel.id}),!((I=l.display_name)===null||I===void 0)&&I.startsWith("CALL_")||N._handleStatusChange(h),this.application.emit("member:call",this.application.conversations.get(h.cid).members.get(($=h.body)===null||$===void 0?void 0:$.member_id),N),h}catch(x){this.log.error("_processMemberInvited: ",{e:x})}}}r.default=u,e.exports=u}(Vc,Vc.exports)),Vc.exports}var pv={exports:{}};(function(e,r){var t=Ae&&Ae.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of);class i extends n.default{constructor(s){super(s),this.items=new Map,s.items.forEach(o=>{const u=this.application.updateOrCreateConversation(o);this.items.set(u.id,u)})}getPrev(){return this.hasPrev()?this.application.getConversations(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.application.getConversations(this._getConfig(this.cursor.next)):this._getError()}}r.default=i,e.exports=i})(pv,pv.exports);var dZ=pv.exports,hv={exports:{}},vv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=Pa;class n{constructor(a,s){var o,u;this.application=a,this.id=(o=s==null?void 0:s.id)!==null&&o!==void 0?o:null,this._embedded=(u=s==null?void 0:s._embedded)!==null&&u!==void 0?u:null,t.mixin(n)}}r.default=n,e.exports=n})(vv,vv.exports);var pZ=vv.exports;(function(e,r){var t=Ae&&Ae.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(r,"__esModule",{value:!0});const n=t(Of),i=t(pZ);class a extends n.default{constructor(o){super(o),this.items=new Map,o.items.forEach(u=>{this.items.set(u.id,new i.default(this.application,u))})}getPrev(){return this.hasPrev()?this.application.getUserSessions(this._getConfig(this.cursor.prev)):this._getError()}getNext(){return this.hasNext()?this.application.getUserSessions(this._getConfig(this.cursor.next)):this._getError()}}r.default=a,e.exports=a})(hv,hv.exports);var hZ=hv.exports,Gc={exports:{}},y0;function vZ(){return y0||(y0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0}),r.ConversationEventsProcessor=r.EventsQueue=void 0;const n=Mn,i=t(yi()),a=gr;class s{constructor(c){this.callback=c,this.cidMap=new Map,this.log=a.getLogger(this.constructor.name)}async enqueue(c,l){var h,v,m,_,C,I,$,x;const{cid:N,id:q}=c,X=Number(q);if(!N||isNaN(X))return this.callback(c);if(((v=(h=l.conversations.get(N))===null||h===void 0?void 0:h.me)===null||v===void 0?void 0:v.state)==="LEFT")return this.callback(c);if(!this.cidMap.get(N)){this.log.debug(`enqueue: create new ConversationEventsProcessor for ${N}`);const G=new o(N,X-1,l);if(this.cidMap.set(N,G),c.type=="member:media"&&(!((_=(m=c.body)===null||m===void 0?void 0:m.media)===null||_===void 0)&&_.audio)||c.type=="member:joined"&&(!((I=(C=c.body)===null||C===void 0?void 0:C.channel)===null||I===void 0)&&I.id)&&((x=($=c.body)===null||$===void 0?void 0:$.channel)===null||x===void 0?void 0:x.knocking_id)===void 0){G.processing=!0,G.lastEventIdProcessed=0;try{await new Promise(ne=>setTimeout(ne,G.eventRequestWaitTime));const L=ne=>{var ge;return(ge=ne.find(Y=>(Y==null?void 0:Y.type)==="rtc:transfer"&&(Y==null?void 0:Y.from)===c.from))===null||ge===void 0?void 0:ge.id};let te=[Array.from(Array(5).keys()).map(ne=>X+1+ne),Array.from(Array(5).keys()).map(ne=>X-1-ne)].flatMap(ne=>ne).map(ne=>G.eventsMap.get(ne)).filter(ne=>ne),se;if((se=L(te))===void 0){const ne=Math.max(X-20,1);te=await G.fetchConversationEvents(ne,20)}(se=L(te))!==void 0&&(se=Number(se),G.lastEventIdProcessed=Math.max(se-1,0),te.slice(se).forEach(ne=>G.enqueue(Number(ne.id),ne)))}finally{G.processing=!1}}}const J=this.cidMap.get(N);J.enqueue(X,c),J.processing||(J.processing=!0,await J.processEvents())}}r.EventsQueue=s;class o{constructor(c,l,h){this.cid=c,this.eventsMap=new Map,this.callback=v=>h._handleEvent(v),this.lastEventIdProcessed=l,this.largestEventIdInQueue=l,this.processing=!1,this.application=h,this.eventsFetchRange=9,this.eventRequestWaitTime=h.session.config.eventQueueWaitTime,this.log=a.getLogger(this.constructor.name)}enqueue(c,l){return c>this.largestEventIdInQueue&&(this.largestEventIdInQueue=c),c>this.lastEventIdProcessed&&this.eventsMap.set(c,l),l}dequeue(c){const l=this.eventsMap.get(c);return this.eventsMap.delete(c),l}async processEvents(){const c=()=>(this.eventsMap.clear(),this.log.debug("processEvents: Done Processing"),this.processing=!1);if(this.eventsMap.size<1)return c();const l=this.lastEventIdProcessed+1,h=await this.processNextEvent(l,1);return h?(this.lastEventIdProcessed=Number(h.id),this.processEvents()):c()}async processNextEvent(c,l){this.log.debug(`processNextEvent: processing event number ${c}`);const h=this.dequeue(c);try{if(h)return await this.callback(h),h;if(l>0)return await new Promise(v=>setTimeout(v,this.eventRequestWaitTime)),this.processNextEvent(c,l-1);if(this.largestEventIdInQueue>c){this.log.debug(`processNextEvent: largestEventIdInQueue-${this.largestEventIdInQueue} > eventId-${c}`);const v=await this.fetchEventsAndProcess(c);return v?(this.log.debug("processNextEvent: foundEvent ",{foundEvent:v}),await this.callback(v),v):(this.log.debug(`processNextEvent: not found process next ${c+1}`),this.processNextEvent(c+1,l))}return}catch{return}}async fetchEventsAndProcess(c){try{const l=await this.fetchConversationEvents(c,this.eventsFetchRange);this.log.debug("fetchEventsAndProcess: fetched events list ",{eventsList:l});let h;return l.forEach(v=>{v.cid=this.cid;const m=Number(v.id);isNaN(m)||m<c||(m>c?(this.log.debug(`fetchEventsAndProcess: event > missingEvent ${m} `,{missingEvent:c}),this.enqueue(m,v)):(this.log.debug("fetchEventsAndProcess: foundEvent ",{event:v}),h=v))}),h}catch(l){this.log.debug("fetchEventsAndProcess: error ",{e:l});return}}async fetchConversationEvents(c,l){this.log.debug("fetchConversationEvents: ",this.cid,c);const h=this.largestEventIdInQueue>c?this.largestEventIdInQueue+l:c+l,v=`${this.application.session.config.nexmo_api_url}/beta2/conversations/${this.cid}/events`;try{return(await i.default.paginationRequest(v,{start_id:c,end_id:h},this.application.session.config.token)).items}catch(m){throw new n.NexmoApiError(m)}}}r.ConversationEventsProcessor=o,e.exports={EventsQueue:s,ConversationEventsProcessor:o}}(Gc,Gc.exports)),Gc.exports}var b0;function Pf(){return b0||(b0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(J){return J&&J.__esModule?J:{default:J}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=gr,a=Mn,s=t(z1),o=t(N$()),u=t(L$()),c=t(cZ),l=t(lZ),h=t(fZ()),v=t(yi()),m=t(x$),_=t(dZ),C=t(hZ),I=vZ(),$=t(vg());let x=null,N=null,q=null;class X{constructor(G,L){this.log=i.getLogger(this.constructor.name),this.session=G,this.conversations=new Map,this.synced_conversations_count=0,this.start_sync_time=0,this.stop_sync_time=0,this.calls=new Map,this._call_draft_list=new Map,this.pageConfig=new m.default((G.config||{}).conversations_page_config),this.conversations_page_last=null,this.activeStreams=[],x=new c.default(this),N=new l.default(this),q=new h.default(this),this.me=null,Object.assign(this,L),n.mixin(X)}updateOrCreateConversation(G){const L=this.conversations.get(G.id);return L?(L._updateObjectInstance(G),this.conversations.set(G.id,L)):this.conversations.set(G.id,new o.default(this,G)),this.conversations.get(G.id)}async _enqueueEvent(G){this.session.config.enableEventsQueue?(this.eventsQueue||(this.eventsQueue=new I.EventsQueue(L=>this._handleEvent(L))),this.eventsQueue.enqueue(G,this)):this._handleEvent(G)}async _handleEvent(G){var L,te,se,ne,ge,Y,Ue;const He=!((L=G._embedded)===null||L===void 0)&&L.from_user?((se=(te=G._embedded)===null||te===void 0?void 0:te.from_user)===null||se===void 0?void 0:se.id)===((ne=this.me)===null||ne===void 0?void 0:ne.id):((Y=(ge=G.body)===null||ge===void 0?void 0:ge.user)===null||Y===void 0?void 0:Y.user_id)===((Ue=this.me)===null||Ue===void 0?void 0:Ue.id),Rt=v.default._checkIfUserIsReInvited(this.conversations,G);if(G.type.startsWith("sip"))return x._handleSipCallEvent(G),G;if(this.conversations.has(G.cid)&&G.type!=="rtc:transfer"&&!Rt)return G.type.startsWith("rtc")&&N._handleRtcEvent(G),this.conversations.get(G.cid)._handleEvent(G),(G.type==="member:joined"||G.type==="member:invited")&&He&&this._handleApplicationEvent(G),G;if(G.cid)try{Rt&&this.conversations.delete(G.cid);let ft;return v.default._isCallEvent(G)?ft=await this.getConversation(G.cid,X.CONVERSATION_API_VERSION.v1):ft=await this.getConversation(G.cid,X.CONVERSATION_API_VERSION.v3),this.conversations.set(G.cid,ft),await ft._handleEvent(G),await this._handleApplicationEvent(G),G.type.startsWith("rtc")&&N._handleRtcEvent(G),Promise.resolve(G)}catch(ft){return this.log.error(ft),Promise.reject(ft)}}async updateToken(G){if(this.session.connection&&this.session.connection.disconnected)return this.session.config.token=G,this.session.connection.io.opts.query.token=G,Promise.resolve();const L={url:`${this.session.config.nexmo_api_url}/v0.2/sessions/${this.session.session_id}`,type:"PUT",token:G};try{await v.default.networkRequest(L),this.me&&(this.session.config.token=G,this.session.connection.io.opts.query.token=G)}catch(te){throw new a.NexmoApiError(te)}}async _handleApplicationEvent(G){try{this.log.debug("_handleApplicationEvent: ",{event:G});const L=q.handleEvent(G),te=this.conversations.get(G.cid);let se;if(te.members.has((L||{}).from))se=te.members.get(L.from);else if(G.type==="member:joined"||G.type==="member:invited"){const ne={...G.body,...G.from&&{member_id:G.from}};se=new $.default(te,ne)}else try{se=await te.getMember(L.from)}catch(ne){this.log.warn(`There is an error getting the member ${ne}`)}return this.emit(L.type,se,L),G}catch(L){throw this.log.error("_handleApplicationEvent: ",L),L}}async inAppCall(G){if(!G||!Array.isArray(G)||G.length===0)return Promise.reject(new a.NexmoClientError("error:application:call:params"));try{const L=new u.default(this);return await L.createCall(G),L.direction=L.CALL_DIRECTION.OUTBOUND,L}catch(L){throw L}}async callServer(G,L="phone",te={}){try{const se=new u.default(this);return se.direction=se.CALL_DIRECTION.OUTBOUND,await se.createServerCall(G,L,te),se}catch(se){throw se}}async reconnectCall(G,L,te={}){try{if(!G||!L)throw new a.NexmoClientError("error:missing:params");const se=await this.getConversation(G,X.CONVERSATION_API_VERSION.v1);await se.media.enable({...te,reconnectRtcId:L});const ne=new u.default(this,se),ge=Array.from(se.events.values()).map(Y=>Y.type);return ge.includes("sip:answered")?ne.status=ne.CALL_STATUS.ANSWERED:ge.includes("sip:ringing")?ne.status=ne.CALL_STATUS.RINGING:ne.status=ne.CALL_STATUS.STARTED,ne.rtcObjects=se.media.rtcObjects,this.calls.set(se.id,ne),ne}catch(se){throw se}}async newConversation(G={}){try{const L=await this.session.sendNetworkRequest({type:"POST",path:"conversations",data:G}),te=new o.default(this,L);return this.conversations.set(te.id,te),this.getConversation(te.id,X.CONVERSATION_API_VERSION.v1)}catch(L){throw new a.NexmoApiError(L)}}async newConversationAndJoin(G){const L=await this.newConversation(G);return await L.join(),L}async getConversation(G,L=X.CONVERSATION_API_VERSION.v3){if(L!==X.CONVERSATION_API_VERSION.v1&&L!==X.CONVERSATION_API_VERSION.v3)throw new a.NexmoClientError("error:conversation-service:version");let te;if(L===X.CONVERSATION_API_VERSION.v1)try{te=await this.session.sendNetworkRequest({type:"GET",path:`conversations/${G}`}),te.id=te.uuid,delete te.uuid}catch(ne){throw new a.NexmoApiError(ne)}else try{te=await this.session.sendNetworkRequest({type:"GET",path:`conversations/${G}`,version:"v0.3"})}catch(ne){throw new a.NexmoApiError(ne)}const se=this.updateOrCreateConversation(te);if(L===X.CONVERSATION_API_VERSION.v3&&!se.me)try{const ne=await se.getMyMember();se.me=ne,se.members.set(ne.id,ne)}catch{try{const ge=await se.getMyMember();se.me=ge,se.members.set(ge.id,ge)}catch{this.log.warn(`You don't have any membership in ${se.id}`)}}if(this.session.config.sync==="full"){const{items:ne}=await se.getEvents();return se.events=ne,se}else return se}async getConversations(G={}){const L=`${this.session.config.nexmo_api_url}/beta2/users/${this.me.id}/conversations`;let te=Object.keys(G).length===0?this.pageConfig:new m.default(G);try{const se=await v.default.paginationRequest(L,te,this.session.config.token);se.application=this;const ne=new _.default(se);return this.conversations_page_last=ne,ne}catch(se){throw new a.NexmoApiError(se)}}syncConversations(G){const L=Array.from(G.values()),te=L.length,se=new Date;this.start_sync_time=typeof window<"u"&&window.performance?window.performance.now():se.getTime();const ne=async()=>{this.synced_conversations_percentage=Number((this.synced_conversations_count/te*100).toFixed(2));const ge={sync_progress:this.synced_conversations_percentage};if(this.emit("sync:progress",ge),this.log.info("Loading sync progress: "+this.synced_conversations_count+"/"+te+" - "+this.synced_conversations_percentage+"%"),this.synced_conversations_percentage>=100){const Y=new Date;this.stop_sync_time=typeof window<"u"&&window.performance?window.performance.now():Y.getTime(),this.log.info("Loaded conversations in "+(this.stop_sync_time-this.start_sync_time)+"ms")}this.synced_conversations_count<te&&(await this.getConversation(L[this.synced_conversations_count].id),ne(),this.synced_conversations_count++,this.sync_progress_buffer++)};ne()}async getUser(G=this.me.id){try{const L=await this.session.sendNetworkRequest({type:"GET",path:`users/${G}`});return new s.default(this,L)}catch(L){throw new a.NexmoApiError(L)}}async getUserSessions(G={}){var L;const te=((L=G)===null||L===void 0?void 0:L.user_id)||this.me.id,se=`${this.session.config.nexmo_api_url}/v0.3/users/${te}/sessions`;let ne=Object.keys(G).length===0?this.pageConfig:new m.default(G);try{const ge=await v.default.paginationRequest(se,ne,this.session.config.token,X.CONVERSATION_API_VERSION.v3);ge.application=this;const Y=new C.default(ge);return this.user_sessions_page_last=Y,Y}catch(ge){throw new a.NexmoApiError(ge)}}}r.default=X,X.CONVERSATION_API_VERSION={v1:"v0.1",v3:"v0.3"},e.exports=X}(Ac,Ac.exports)),Ac.exports}var _0;function yi(){return _0||(_0=1,function(e,r){var t=Ae&&Ae.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(r,"__esModule",{value:!0});const n=t($Q),i=t(D1),a=t(Pf()),s=4e4,o=2e4,u=new RegExp(`"|'|<|>|&|\\|/`),c=new RegExp(`"|'|<|>|\\|javascript:`);class l{static getMemberFromNameOrNull(v,m){if(!v||!m)return null;for(let _ of v.members.values())if(_.user.name===m)return _;return null}static getMemberNumberFromEventOrNull(v){const m=v&&v.from;return m&&(m.number||m.uri)?m.number||m.uri:null}static isSanitizedInput(v){return!u.test(v)}static isSanitizedUrlInput(v){return!c.test(v)}static checkIsSanitized([v,m]){if(m==null)return!0;switch(typeof m){case"string":return v.includes("url")||v.includes("uri")?l.isSanitizedUrlInput(m):l.isSanitizedInput(m);case"object":return Array.isArray(m)?m.every(_=>l.checkIsSanitized(["dummy",_])):Object.entries(m).every(l.checkIsSanitized);default:return!0}}static networkRequest(v){return new Promise((m,_)=>{!v.token&&!v.url.includes("logging")&&!v.url.includes("ping")&&_({response:{type:"error:user:token",description:"network error on request. Please create a new session."}});const C=new XMLHttpRequest;let I;C.open(v.type,v.url,!0),v.token&&C.setRequestHeader("Authorization","Bearer "+v.token),v&&v.url.includes("image")?(C.responseType="",I=v.data,C.onloadstart=()=>{m(C)}):(C.responseType=v.responseType||"json",I=v.data?JSON.stringify(v.data):null,C.setRequestHeader("Content-type","application/json; charset=utf-8")),C.onload=()=>{C.status===200||C.status===201||C.status===204?m(C):_(C)},C.onerror=$=>{_($)},C.send(I)})}static async paginationRequest(v,m,_,C=a.default.CONVERSATION_API_VERSION.v1){try{const I=await l.networkRequest({type:"GET",url:l.addUrlSearchParams(v,m),token:_}),{page_size:$,_embedded:x,_links:N}=I.response,q=v.split("/").pop().trim();return{items:C===a.default.CONVERSATION_API_VERSION.v1?x.data[q]:x[q],cursor:{prev:N.prev?new URLSearchParams(N.prev.href).get("cursor"):"",next:N.next?new URLSearchParams(N.next.href).get("cursor"):"",self:N.self?new URLSearchParams(N.self.href).get("cursor"):""},page_size:$,order:m.order||"asc",event_type:m.event_type||null}}catch({response:I}){const $=I||{type:"error:network:get-request",description:"network error on nexmo get request"};throw $.validation&&($.description=$.validation[Object.keys($.validation)[0]]),$}}static addUrlSearchParams(v,m={}){let _=new URL(v);return Object.keys(m).forEach(C=>{m[C]&&!(typeof m[C]=="string"&&m[C].length<1)&&m[C]!==null&&_.searchParams.set(C,m[C])}),_.href}static deepMergeObj(v,m){const _=JSON.parse(JSON.stringify(v));for(let C in m)Object.prototype.toString.call(m[C])==="[object Object]"?_[C]=l.deepMergeObj(_[C],m[C]):_[C]=m[C];return _}static injectScript(v,m){if(typeof document<"u"){let _=document.getElementsByTagName("head")[0],C=document.createElement("script");C.async=!0,C.src=v,C.onload=C.onreadystatechange=()=>{(!C.readyState||/loaded|complete/.test(C.readyState))&&(C.onload=C.onreadystatechange=null,C=null,m&&m())},_.insertBefore(C,_.firstChild)}}static allocateUUID(){return n.default.v4()}static validateDTMF(v){return typeof v=="string"?/^[\da-dA-D#*pP]{1,45}$$/.test(v):!1}static _getBugsnagKey(){return"76498fc1ca8d9b0a173a44e2b873d7ed"}static updateMemberLegs(v,m){if(v){const _=v.find(C=>C.leg_id===m.body.leg_id);if(!_)v.push({leg_id:m.body.leg_id,status:m.body.status});else if(_.status!==m.body.status){let C=v.indexOf(_);v.fill(_.status=m.body.status,C,C++)}}else v=[{leg_id:m.body.leg_id,status:m.body.status}];return v}static _isCallEvent(v){const{channel:m,media:_}=v.body;return!!(v.type==="rtc:transfer"||m&&(_&&_.audio_settings&&_.audio_settings.enabled||_&&_.audio&&_.audio.enabled||m.knocking_id))}static async _fetchImage(v,m){const{response:_}=await l.networkRequest({type:"GET",url:v,responseType:"arraybuffer",token:m}),C=new Uint8Array(_);let I="";const $=8*1024;let x;for(x=0;x<C.length/$;x++)I+=String.fromCharCode.apply(null,C.subarray(x*$,(x+1)*$));return I+=String.fromCharCode.apply(null,C.subarray(x*$)),"data:image/jpeg;base64,"+btoa(I)}static async _checkHttpConnectivity(v){const m=Date.now();try{await l.networkRequest({type:"GET",url:v});const _=Date.now()-m;return{url:v,canConnect:!0,connectionTime:_}}catch(_){return{url:v,canConnect:!1,error:_}}}static _checkWsConnectivity(v,m,_){return new Promise((C,I)=>{const $=Object.assign({path:m},_),x=Date.now(),N=i.default.connect(v,$),q=setTimeout(()=>C({url:v,canConnect:!1}),o);N.on("connect",()=>{const X=Date.now()-x;N.disconnect(),clearTimeout(q),C({url:v,canConnect:!0,connectionTime:X})}),N.on("error",X=>{N.disconnect(),clearTimeout(q),C({url:v,canConnect:!1,error:X})})})}static async _checkMediaServers(v,m,_){try{const{response:C}=await l.networkRequest({type:"GET",url:`${m}/v0.3/discovery/media/${_}`,token:v}),I=C.map($=>l._checkMediaConnectivity($.ip,$.port));return await Promise.all(I)}catch{return[]}}static async _checkMediaConnectivity(v,m){return new Promise(async(_,C)=>{const I={iceServers:[{urls:`stun:${v}:${m}`}]},$=new RTCPeerConnection(I),x=Date.now(),N=await $.createOffer({offerToReceiveAudio:!0});$.setLocalDescription(N);const q=setTimeout(()=>{$.close(),_({ip:v,canConnect:!1})},s);$.addEventListener("icecandidate",X=>{var J;if(((J=X==null?void 0:X.candidate)===null||J===void 0?void 0:J.type)==="srflx"){const G=Date.now()-x;clearTimeout(q),$.close(),_({ip:v,canConnect:!0,connectionTime:G})}}),$.addEventListener("icecandidateerror",X=>{X.errorCode&&($.close(),clearTimeout(q),_({ip:v,canConnect:!1,error:X}))})})}static _checkIfUserIsReInvited(v,m){var _;if(!v.has(m.cid)||!(m.type==="member:invited"||m.type==="member:joined"))return!1;const C=(_=v.get(m.cid))===null||_===void 0?void 0:_.me;return C?C.user.name===m.body.user.name&&C.state==="LEFT":!1}}r.default=l,e.exports=l}(Oc,Oc.exports)),Oc.exports}var mv={exports:{}};(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});const t=gr,n=Mn;class i{constructor(s){if(this.log=t.getLogger(this.constructor.name),!s)throw new n.NexmoClientError("no emitter object passed for the Error Emitter");this.emitter=s,this.LISTENER_GROUP="NXM-errors"}emitResponseIfError(s){if(this._isTypeError(s.type))return this.emitter.emit(s.type,this.LISTENER_GROUP,s)}cleanup(){return this.emitter.releaseGroup(this.LISTENER_GROUP)}_isTypeError(s){return s.indexOf("error")!==-1}}r.default=i,e.exports=i})(mv,mv.exports);var mZ=mv.exports;(function(e,r){var t=Ae&&Ae.__importDefault||function(I){return I&&I.__esModule?I:{default:I}};Object.defineProperty(r,"__esModule",{value:!0});const n=Pa,i=t(mY),a=t(gr),s=Mn,o=t(D1),u=t(fQ),c=t(gQ),l=t(yi()),h=t(Pf()),v=t(mZ),m=t(z1),_=t(If());i.default.reg(a.default),i.default.apply(a.default,{template:"[%t] %l (NXM-%n):",timestampFormatter:I=>I.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),levelFormatter:I=>I.toUpperCase(),nameFormatter:I=>I||"SDK"});class C{constructor($={}){const x=$;if(this.config={debug:"silent",log_reporter:{enabled:!1,bugsnag_key:null},environment:"production",ips_url:"https://api-us.vonage.com/v1/image",nexmo_api_url:"https://api-us.vonage.com",path:"/v2/rtc",repository:"https://github.com/Nexmo/conversation-js-sdk",SDK_version:"9.6.1",socket_io:{reconnection:!0,reconnectionAttempts:5,reconnectionDelay:2e3,randomizationFactor:.75,reconnectionDelayMax:15e3,forceNew:!0,autoConnect:!0,transports:["websocket"]},sync:"none",url:"https://ws-us.vonage.com",iceServers:[],rtcstats:{remote_collection:!0,remote_collection_url:"https://hlg.tokbox.com/prod/logging/nexmo_client_js_stats",remote_collection_interval:5e3,emit_events:!1,emit_rtc_analytics:!1,emit_interval:1e3},conversations_page_config:{page_size:10,order:"asc",cursor:""},events_page_config:{page_size:10,order:"asc",event_type:""},enableEventsQueue:!0,eventQueueWaitTime:50,enableInboundOffer:!1,acknowledgeEvents:!0,token:null},this.config.socket_io.query={token:"",SDK_version:this.config.SDK_version,session_version:$.enableInboundOffer?"0.0.3":"0.0.1",acknowledge_events:this.config.acknowledgeEvents,OS_family:"js",OS_revision:typeof navigator<"u"?navigator.userAgent:typeof window<"u"?window.navigator.userAgent:"Generic JS navigator"},this.sessionReady=!1,this.disconnectTimestamp=null,this.session_id=null,this.apiKey=null,this.requests={},this.application=null,["debug","info","warn","error"].includes(x.debug)?a.default.setLevel(x.debug):x.debug===!0?a.default.setLevel("debug"):a.default.setLevel("silent"),this.log=a.default.noConflict(),this.config=l.default.deepMergeObj(this.config,this._sanitizeConfig(x)),this.config.log_reporter.enabled){const N={apiKey:this.config.log_reporter.bugsnag_key||l.default._getBugsnagKey(),appVersion:this.config.socket_io.query.SDK_version,releaseStage:this.config.environment};Ae.NXMbugsnagClient=u.default(N)}n.mixin(C)}_createAndSetConnection(){let $,x=Object.assign({path:this.config.path},this.config.socket_io);return $=o.default.connect(this.config.url,x),this.connection=$,$.on("connect",()=>{this.emit("ready"),this.sessionReady=!0,this.log.info("websocket ready")}),$.on("disconnect",(N,q)=>{this.emit("disconnect",N==="io client disconnect"?C.DISCONNECT_REASON.ClientDisconnected:N==="io server disconnect"&&this.session_id?C.DISCONNECT_REASON.TokenExpired:C.DISCONNECT_REASON.ConnectionError),this.disconnectTimestamp=Date.now(),this.log.info("websocket disconnected",N,q)}),$.io.on("reconnect",N=>{this.emit("reconnect",N),this.log.info("websocket reconnect",N),l.default.networkRequest({url:`${this.config.url.replace("wss://","https://")}/v2/rtc/metrics`,type:"POST",token:this.config.token,data:{sessionId:this.session_id,metrics:[{name:"TIME_TO_RECONNECT_SUCCESS",time:this.disconnectTimestamp?Date.now()-this.disconnectTimestamp:void 0,attempt:N}]}}).catch(q=>{this.log.warn("Failed to publish socket reconnection metrics",q)})}),$.io.on("reconnect_attempt",N=>{this.emit("reconnecting",N),this.log.info("websocket reconnecting",N)}),$.on("connect_error",N=>{this.emit("error",new s.NexmoClientError(N)),this.log.error("Socket.io reported a generic error",N)}),$.io.on("reconnect_failed",()=>{this.emit("error",new s.NexmoClientError("error:client:reconnection_failed")),this.log.error("websocket reconnection error")}),$.io.on("packet",N=>{if(N.type!==2||N.data[0]==="echo")return;const q=N.data[2];q&&typeof q=="function"&&q();const X=N.data[1];if(X.type=N.data[0],this.log.debug("<--",X.type,X),this.requests["session:login"]){const J=this.requests["session:login"].callback;delete this.requests["session:login"],J(X)}else if(X.rid in this.requests){const J=this.requests[X.rid].callback;delete this.requests[X.rid],delete X.delay,this.errorsEmitter&&this.errorsEmitter.emitResponseIfError(X),J(X)}else this.errorsEmitter&&X.type.startsWith("system:error:")?this.errorsEmitter.emitResponseIfError(X):X.type.startsWith("session:")?this.updateSession(X):this.application&&this.application._enqueueEvent(X)}),$}_sanitizeConfig($){let x=$;return $.sync&&["none","lite","full"].indexOf($.sync)===-1&&(this.log.warn(`invalid param '${$.sync}' for sync, reverting to ${this.config.sync}`),x.sync=this.config.sync),x}sendRequest($,x){$.tid=l.default.allocateUUID();const N=$.type;delete $.type,this.log.debug("-->",N,$),this.log.info("-->",N,$.tid),this.connection.emit(N,$),this.requests[$.tid]={type:N,request:$,callback:x}}async sendNetworkRequest($){const x=$.version||"beta",N=`${this.config.nexmo_api_url}/${x}/${$.path}`;if(!($.type==="GET"||$.type==="DELETE")&&($.data={...$.data,originating_session:this.session_id},!l.default.checkIsSanitized(["data",$.data])))throw new s.NexmoClientError("error:input:unsanitized");try{const q={type:$.type,url:N,data:$.data?$.data:null,token:($.data||{}).token?$.data.token:this.config.token||null};this.log.debug("sendNetworkRequest: ",{request:q});const{response:X}=await l.default.networkRequest(q);return X}catch({response:q}){throw q}}createSession($){return this.config.socket_io.query.token=$,this._createAndSetConnection(),new Promise((x,N)=>{this.log.info(`Client-SDK Version: ${this.config.SDK_version}`),this.config.token=null,this.requests["session:login"]={type:"session:login",callback:async q=>{if(q.type==="session:success")if(this.session_id=q.body.id,this.apiKey=q.body.api_key,this.config.token=$,this.connection.io.opts.query={session_id:this.session_id,token:this.config.token},(!this.application||this.application.me&&this.application.me.id!==q.body.user_id)&&(this.application=new h.default(this,{})),this.application.me||(this.application.me=new m.default(this.application,{id:q.body.user_id,name:q.body.name})),this.errorsEmitter||(this.errorsEmitter=new v.default(this.application)),this.config.log_reporter.enabled&&(Ae.NXMbugsnagClient.user={id:this.application.me.id,name:this.application.me.name,session_id:q.body.id}),this.config.sync!=="none")try{await this.application.getConversations(),x(this.application)}catch(X){N(X)}else x(this.application);else N(new s.NexmoApiError(q))}}})}deleteSession(){return new Promise(async($,x)=>{const N=()=>this.sendRequest({type:"session:logout",body:{}},q=>{q.type==="session:logged-out"||q.type==="session:terminated"?(this.disconnect(),delete this.errorsEmitter,delete this.application,delete this.connection,this.requests={},this.sessionReady=!1,$(q)):x(q)});if(this.application){let q=[];if(this.application.conversations.size)for(let X of this.application.conversations.values())q.push(X.media.disable());try{await Promise.all(q)}catch(X){this.log.error("deleteSession: ",X)}return N()}else return N()})}updateSession($){$.type==="session:success"&&(this.session_id=$.body.id,this.connection.io.opts.query.session_id=$.body.id,this.application&&$.body.pending_events&&$.body.pending_events.forEach(x=>this.application._enqueueEvent(x)))}disconnect(){return this.connection.disconnect()}connect(){return this.connection.connect()}async connectivityReport($,x){const q={machineInfo:{ip:_.default.isNode()?void 0:await c.default.v4()},connectivityReport:[]};try{const{response:X}=await l.default.networkRequest({type:"GET",url:`${this.config.nexmo_api_url}/v0.3/discovery/api`,token:$});let J=X;x!=null&&x.dcListCallback&&(J=x.dcListCallback(J));for(const G in J){const L=J[G].endpoint,te=J[G].https,se=J[G].ws;try{const ne=await l.default._checkHttpConnectivity(te),ge=await l.default._checkWsConnectivity(se,this.config.path,this.config.socket_io),Y=await l.default._checkMediaServers($,L,G),Ue={name:G,signalConnectionReport:{https:ne,ws:ge},mediaConnectionReport:Y};q.connectivityReport.push(Ue)}catch(ne){this.log.error(`Error generating report for ${G}`,ne)}}}catch(X){this.log.error("Error fetching nexmo servers information",X)}return q}async checkMediaServers($,x,N){return await l.default._checkMediaServers($,x,N)}async checkMediaConnectivity($,x){return await l.default._checkMediaConnectivity($,x)}}r.default=C,C.DISCONNECT_REASON={ClientDisconnected:"ClientDisconnected",TokenExpired:"TokenExpired",ConnectionError:"ConnectionError"},e.exports=C})(qh,qh.exports);var gZ=qh.exports;const yZ=O0(gZ),$i=new Sa("nexmo-chat"),bZ=["us-3","us-4","eu-3","eu-4","ap-3","ap-4"];class D$ extends _v{constructor(){super(...arguments);ut(this,"rtc");ut(this,"application");ut(this,"conversation")}get _client(){if(this.rtc)return this.rtc;const t=_Z(this.region);return this.rtc=new yZ({nexmo_api_url:`https://api-${this.region}.${t}`,url:`wss://ws-${this.region}.${t}`}),this.rtc}async create(){const{identity:t,token:n}=await this.issueChatToken();$i.info(`Connecting chat, identity: ${t}, token: ${n}`),this.identity=t,this.application=await this._client.createSession(n)}async destroy(){this.rtc&&(await this.rtc.deleteSession(),this.rtc=null,this.application=null,this.conversation=null)}async join(t){const n=await this.application.getConversation(t);n.me.state==="JOINED"?$i.info("already joined conversation:",t):(await n.join(),$i.info("success joined conversation:",t)),this.registerEvents(n),this.conversation=n}async preview(t){await this.conversation.sendCustomEvent({type:"ujet_preview",body:{chat_preview:t,chat_preview_updated_at:new Date().toJSON()}})}async fetchMessages(t){const n=await this.conversation.getEvents({event_type:"message",order:"desc",page_size:100}),i=[];return n.items.forEach(a=>{const s=a._embedded.from_user.name,o=w0(a,s);t[o.$index]&&(o.file=t[o.$index]),this.trackInTask(o),i.push(o)}),i.reverse()}async sendMessage(t){try{const n=await this.conversation.sendMessage({message_type:"text",text:JSON.stringify(t)});return $i.info(`Message sent from ${this.conversation.id}, id: ${n.id}`),parseInt(n.id,10)}catch(n){$i.warn(`Failed to send a message from ${this.conversation.id}`,{error:n})}}startTyping(){this.conversation&&this.conversation.startTyping()}stopTyping(){this.conversation&&this.conversation.stopTyping()}registerEvents(t){t.on("message",(n,i)=>{const a=w0(i,n.userName);$i.info(`Message added from ${this.conversation.id}, index: ${a.$index}, sid: ${a.$sid}, timestamp: ${a.$timestamp}, user type: ${a.$userType}`),a.$userType!=="end_user"&&this.ping(),this.trackInTask(a),this.events.triggerEvent("message",a)}),t.on("member:joined",n=>{$i.info("conversation: memberJoined",n),this.events.triggerEvent("memberJoined",n.userName)}),t.on("member:left",n=>{$i.info("conversation: memberLeft",n),this.events.triggerEvent("memberLeft",n.userName)}),t.on("text:typing:on",n=>{/^end_user/.test(n.userName)||this.events.triggerEvent("typingStarted",n.userName)}),t.on("text:typing:off",n=>{/^end_user/.test(n.userName)||this.events.triggerEvent("typingEnded",n.userName)})}}ut(D$,"type","nexmo_conversations");wv(D$);function _Z(e){return bZ.indexOf(e)>-1?"vonage.com":"nexmo.com"}function w0(e,r){const{id:t,timestamp:n,body:i}=e,[a,s]=r.split("-");let o=0;s&&(o=parseInt(s,10));const u={$index:parseInt(t,10),$sid:t,$timestamp:new Date(Date.parse(n)),$userType:a,$userId:o};try{const c=JSON.parse(i.text);return c.message&&!c.type?{...u,...c,type:"message"}:{...u,...c}}catch(c){return $i.warn("Format message failed",{error:c,data:i.text}),{...u,type:"text",content:i.text}}}exports.Client=oO;exports.ENVIRONMENT=B$;exports.EventManager=bv;exports.Logger=Sa;exports.MediaStore=C0;exports.OPTIONS=Er;exports.PostSessionStatus=Vs;exports.VERSION=gv;exports.addProviderType=wv;exports.consoleLoggerHandler=K$;