text: /*
   * Copyright (c) 2021, salesforce.com, inc.
   * All rights reserved.
   * SPDX-License-Identifier: BSD-3-Clause
   * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
   */
  
  !function(t){var e={};function a(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=t,a.c=e,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)a.d(n,r,function(e){return t[e]}.bind(null,r));return n},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="/assets/",a(a.s=16)}([function(t,e,a){"use strict";a.d(e,"f",(function(){return v})),a.d(e,"q",(function(){return g})),a.d(e,"s",(function(){return b})),a.d(e,"r",(function(){return G})),a.d(e,"a",(function(){return i})),a.d(e,"d",(function(){return s})),a.d(e,"p",(function(){return c})),a.d(e,"l",(function(){return o})),a.d(e,"m",(function(){return l})),a.d(e,"e",(function(){return E})),a.d(e,"o",(function(){return T})),a.d(e,"c",(function(){return u})),a.d(e,"i",(function(){return A})),a.d(e,"j",(function(){return _})),a.d(e,"h",(function(){return N})),a.d(e,"k",(function(){return r})),a.d(e,"b",(function(){return C})),a.d(e,"n",(function(){return d})),a.d(e,"g",(function(){return O}));var n={MESSAGE_TYPE:{SETUP_CONNECTOR:"SETUP_CONNECTOR",CONNECTOR_READY:"CONNECTOR_READY",TELEPHONY_EVENT_DISPATCHED:"TELEPHONY_EVENT_DISPATCHED",ACCEPT_CALL:"ACCEPT_CALL",DECLINE_CALL:"DECLINE_CALL",END_CALL:"END_CALL",MUTE:"MUTE",UNMUTE:"UNMUTE",HOLD:"HOLD",RESUME:"RESUME",SET_AGENT_STATUS:"SET_AGENT_STATUS",DIAL:"DIAL",SEND_DIGITS:"SEND_DIGITS",GET_PHONE_CONTACTS:"GET_PHONE_CONTACTS",SWAP_PARTICIPANTS:"SWAP_PARTICIPANTS",ADD_PARTICIPANT:"ADD_PARTICIPANT",CONFERENCE:"CONFERENCE",PAUSE_RECORDING:"PAUSE_RECORDING",RESUME_RECORDING:"RESUME_RECORDING",LOGOUT:"LOGOUT",MESSAGE:"MESSAGE",WRAP_UP_CALL:"WRAP_UP_CALL",AGENT_AVAILABLE:"AGENT_AVAILABLE"},EVENT_TYPE:{QUEUED_CALL_STARTED:"QUEUED_CALL_STARTED",CALL_STARTED:"CALL_STARTED",CALL_CONNECTED:"CALL_CONNECTED",CALL_FAILED:"CALL_FAILED",MUTE_TOGGLE:"MUTE_TOGGLE",HOLD_TOGGLE:"HOLD_TOGGLE",HANGUP:"HANGUP",ERROR:"ERROR",PHONE_CONTACTS:"PHONE_CONTACTS",PARTICIPANT_ADDED:"PARTICIPANT_ADDED",PARTICIPANT_CONNECTED:"PARTICIPANT_CONNECTED",PARTICIPANT_REMOVED:"PARTICIPANT_REMOVED",LOGIN_STARTED:"LOGIN_STARTED",LOGIN_RESULT:"LOGIN_RESULT",LOGOUT_RESULT:"LOGOUT_RESULT",RECORDING_TOGGLE:"RECORDING_TOGGLE",SHOW_LOGIN:"SHOW_LOGIN",SET_AGENT_STATUS_RESULT:"SET_AGENT_STATUS_RESULT",WRAP_UP_ENDED:"WRAP_UP_ENDED",MESSAGE:"MESSAGE",AFTER_CALL_WORK_STARTED:"AFTER_CALL_WORK_STARTED"},ERROR_TYPE:{GENERIC_ERROR:"GENERIC_ERROR",AGENT_ERROR:"AGENT_ERROR",MICROPHONE_NOT_SHARED:"MICROPHONE_NOT_SHARED",UNSUPPORTED_BROWSER:"UNSUPPORTED_BROWSER",AUTHENTICATION_ERROR:"AUTHENTICATION_ERROR",INVALID_AGENT_STATUS:"INVALID_AGENT_STATUS",CAN_NOT_SET_AGENT_STATUS:"CAN_NOT_SET_AGENT_STATUS",LOGIN_REQUIRED:"LOGIN_REQUIRED",CAN_NOT_ACCEPT_THE_CALL:"CAN_NOT_ACCEPT_THE_CALL",CAN_NOT_DECLINE_THE_CALL:"CAN_NOT_DECLINE_THE_CALL",CAN_NOT_END_THE_CALL:"CAN_NOT_END_THE_CALL",CAN_NOT_HOLD_CALL:"CAN_NOT_HOLD_CALL",CAN_NOT_RESUME_CALL:"CAN_NOT_RESUME_CALL",CAN_NOT_MUTE_CALL:"CAN_NOT_MUTE_CALL",CAN_NOT_UNMUTE_CALL:"CAN_NOT_UNMUTE_CALL",INVALID_PARTICIPANT:"INVALID_PARTICIPANT",CAN_NOT_LOG_IN:"CAN_NOT_LOG_IN",CAN_NOT_LOG_OUT:"CAN_NOT_LOG_OUT",INVALID_PARAMS:"INVALID_PARAMS",CAN_NOT_GET_PHONE_CONTACTS:"CAN_NOT_GET_PHONE_CONTACTS",CAN_NOT_SWAP_PARTICIPANTS:"CAN_NOT_SWAP_PARTICIPANTS",CAN_NOT_CONFERENCE:"CAN_NOT_CONFERENCE",INVALID_DESTINATION:"INVALID_DESTINATION",INVALID_PHONE_NUMBER:"INVALID_PHONE_NUMBER",CAN_NOT_HANGUP_PARTICIPANT:"CAN_NOT_HANGUP_PARTICIPANT",CAN_NOT_ADD_PARTICIPANT:"CAN_NOT_ADD_PARTICIPANT",CAN_NOT_CONNECT_PARTICIPANT:"CAN_NOT_CONNECT_PARTICIPANT",CAN_NOT_START_THE_CALL:"CAN_NOT_START_THE_CALL",CAN_NOT_PAUSE_RECORDING:"CAN_NOT_PAUSE_RECORDING",CAN_NOT_RESUME_RECORDING:"CAN_NOT_RESUME_RECORDING"},AGENT_STATUS:{ONLINE:"Online",OFFLINE:"Offline",ACW:"AfterCallWork"},PARTICIPANT_TYPE:{AGENT:"Agent",INITIAL_CALLER:"Initial_Caller",THIRD_PARTY:"Third_Party"},CALL_TYPE:{INBOUND:"Inbound",OUTBOUND:"Outbound",ADD_PARTICIPANT:"AddParticipant"},CONTACT_TYPE:{PHONEBOOK:"PhoneBook",QUEUE:"Queue",PHONENUMBER:"PhoneNumber"},CAPABILITY_TYPE:{SHOW_AGENT_SETTINGS:"SHOW_AGENT_SETTINGS",MUTE:"MUTE",RECORD:"RECORD",MERGE:"MERGE",SWAP:"SWAP"},CALL_STATE:{RINGING:"ringing",CONNECTED:"connected",TRANSFERRING:"transferring",TRANSFERRED:"transferred",ENDED:"ended"}};class r{constructor({isMuted:t}){this.isMuted=t}}class i{constructor({activeCalls:t=[]}){t.length>0&&t.forEach(t=>{h.validateClassObject(t,d)}),this.activeCalls=t}}class s{constructor({hasMute:t=!0,hasRecord:e=!0,hasMerge:a=!0,hasSwap:n=!0}){this.hasMute=t,this.hasRecord=e,this.hasMerge=a,this.hasSwap=n}}class c{constructor({isRecordingPaused:t,contactId:e=null,initialContactId:a=null,instanceId:n=null,region:r=null}){this.isRecordingPaused=t,this.contactId=e,this.initialContactId=a,this.instanceId=n,this.region=r}}class o{constructor({reason:t="",participantType:e}){this.reason=t,this.participantType=e}}class l{constructor({initialCallHasEnded:t,callInfo:e,phoneNumber:a,callId:n}){h.validateClassObject(e,C),this.initialCallHasEnded=t,this.callInfo=e,this.phoneNumber=a,this.callId=n}}class E{constructor({isThirdPartyOnHold:t,isCustomerOnHold:e}){this.isThirdPartyOnHold=t,this.isCustomerOnHold=e}}class T{constructor({contacts:t=[]}){t.length>0&&t.forEach(t=>{h.validateClassObject(t,O)}),this.contacts=t}}class u{constructor({call:t}){h.validateClassObject(t,d),this.call=t}}class A{constructor({isThirdPartyOnHold:t,isCustomerOnHold:e,calls:a}){Object.values(a).forEach(t=>{h.validateClassObject(t,d)}),this.isThirdPartyOnHold=t,this.isCustomerOnHold=e,this.calls=a}}class _{constructor({showLogin:t=!1,loginFrameHeight:e=350}){this.showLogin=t,this.loginFrameHeight=e}}class N{constructor({success:t}){this.success=t}}class C{constructor({callStateTimestamp:t=null,isOnHold:e}){t&&h.validateDate(t),this.callStateTimestamp=t,this.isOnHold=e}}class O{constructor({phoneNumber:t,id:e,type:a,name:r,prefix:i,extension:s}){t&&h.validateString(t),a&&h.validateEnum(a,Object.values(n.CONTACT_TYPE)),e&&h.validateString(e),r&&h.validateString(r),i&&h.validateString(i),s&&h.validateString(s),this.phoneNumber=t,this.id=e,this.type=a,this.name=r,this.prefix=i,this.extension=s}}class d{constructor({callId:t,callType:e,contact:a,state:r,callAttributes:i,phoneNumber:s,callInfo:c}){h.validateString(t).validateEnum(e?e.charAt(0).toUpperCase()+e.slice(1):e,Object.values(n.CALL_TYPE)).validateString(r).validateObject(i),s?(h.validateString(s),a&&h.validateClassObject(a,O)):h.validateClassObject(a,O),this.callId=t,this.callType=e,this.contact=a,this.state=r,this.callAttributes=i,this.phoneNumber=s,this.callInfo=c}}class h{static validateString(t){if("string"!=typeof t)throw new Error("Invalid argument. Expecting a string but got "+typeof t);return this}static validateBoolean(t){if("boolean"!=typeof t)throw new Error("Invalid argument. Expecting a boolean but got "+typeof t);return this}static validateObject(t){if("object"!=typeof t)throw new Error("Invalid argument. Expecting an object but got "+typeof t);return this}static validateEnum(t,e){if(!e.includes(t))throw new Error(`Invalid argument. Expecting a value from ${JSON.stringify(e)} but got ${t}`);return this}static validateDate(t){if(!(t instanceof Date))throw new Error("Invalid argument. Expecting a Date object but got "+typeof t);return this}static validateClassObject(t,e){if(!(t instanceof e))throw new Error("Invalid className. Expecting object of class "+e);return this}}let P,f,p;function R(t,e){console.error("SCV dispatched error "+t,e),I(n.EVENT_TYPE.ERROR,{message:n.ERROR_TYPE[t]})}function I(t,e){P.postMessage({type:n.MESSAGE_TYPE.TELEPHONY_EVENT_DISPATCHED,payload:{telephonyEventType:t,telephonyEventPayload:e}})}async function L(){const t=await f.getCapabilities();h.validateClassObject(t,s),P.postMessage({type:n.MESSAGE_TYPE.CONNECTOR_READY,payload:{capabilities:{[n.CAPABILITY_TYPE.MUTE]:t.hasMute,[n.CAPABILITY_TYPE.RECORD]:t.hasRecord,[n.CAPABILITY_TYPE.MERGE]:t.hasMerge,[n.CAPABILITY_TYPE.SWAP]:t.hasSwap}}})}async function S(t){switch(t.data.type){case n.MESSAGE_TYPE.ACCEPT_CALL:try{if(t.data.call&&t.data.call.callType&&t.data.call.callType.toLowerCase()===n.CALL_TYPE.OUTBOUND.toLowerCase())return;const e=await f.acceptCall(t.data.call);h.validateClassObject(e,u);const{call:a}=e;I(n.EVENT_TYPE.CALL_CONNECTED,a)}catch(t){R(n.ERROR_TYPE.CAN_NOT_ACCEPT_THE_CALL,t)}break;case n.MESSAGE_TYPE.DECLINE_CALL:try{const e=await f.declineCall(t.data.call);h.validateClassObject(e,u);const{call:a}=e;I(n.EVENT_TYPE.HANGUP,a)}catch(t){R(n.ERROR_TYPE.CAN_NOT_DECLINE_THE_CALL,t)}break;case n.MESSAGE_TYPE.END_CALL:try{const e=await f.endCall(t.data.call,t.data.agentStatus);h.validateClassObject(e,u);const a=await f.getActiveCalls();h.validateClassObject(a,i);const r=a.activeCalls,{call:s}=e;0===r.length&&I(n.EVENT_TYPE.HANGUP,s)}catch(t){R(n.ERROR_TYPE.CAN_NOT_END_THE_CALL,t)}break;case n.MESSAGE_TYPE.MUTE:try{const t=await f.mute();h.validateClassObject(t,r),I(n.EVENT_TYPE.MUTE_TOGGLE,{isMuted:t.isMuted})}catch(t){R(n.ERROR_TYPE.CAN_NOT_MUTE_CALL,t)}break;case n.MESSAGE_TYPE.UNMUTE:try{const t=await f.unmute();h.validateClassObject(t,r),I(n.EVENT_TYPE.MUTE_TOGGLE,{isMuted:t.isMuted})}catch(t){R(n.ERROR_TYPE.CAN_NOT_UNMUTE_CALL,t)}break;case n.MESSAGE_TYPE.HOLD:try{const e=await f.hold(t.data.call);h.validateClassObject(e,A);const{isThirdPartyOnHold:a,isCustomerOnHold:r,calls:i}=e;I(n.EVENT_TYPE.HOLD_TOGGLE,{isThirdPartyOnHold:a,isCustomerOnHold:r,calls:i})}catch(t){R(n.ERROR_TYPE.CAN_NOT_HOLD_CALL,t)}break;case n.MESSAGE_TYPE.RESUME:try{const e=await f.resume(t.data.call);h.validateClassObject(e,A);const{isThirdPartyOnHold:a,isCustomerOnHold:r,calls:i}=e;I(n.EVENT_TYPE.HOLD_TOGGLE,{isThirdPartyOnHold:a,isCustomerOnHold:r,calls:i})}catch(t){R(n.ERROR_TYPE.CAN_NOT_RESUME_CALL,t)}break;case n.MESSAGE_TYPE.SET_AGENT_STATUS:try{const e=await f.setAgentStatus(t.data.agentStatus);h.validateClassObject(e,N);const{success:a}=e;I(n.EVENT_TYPE.SET_AGENT_STATUS_RESULT,{success:a})}catch(t){R(n.ERROR_TYPE.CAN_NOT_SET_AGENT_STATUS,t)}break;case n.MESSAGE_TYPE.DIAL:try{const e=await f.dial(new O(t.data.contact));h.validateClassObject(e,u);const{call:a}=e;I(n.EVENT_TYPE.CALL_STARTED,a)}catch(t){I(n.EVENT_TYPE.CALL_FAILED),R(n.ERROR_TYPE.CAN_NOT_START_THE_CALL,t)}break;case n.MESSAGE_TYPE.SEND_DIGITS:await f.sendDigits(t.data.digits);break;case n.MESSAGE_TYPE.GET_PHONE_CONTACTS:try{const e=await f.getPhoneContacts(t.data.filter);h.validateClassObject(e,T);const a=e.contacts.map(t=>({id:t.id,endpointARN:t.endpointARN,phoneNumber:t.phoneNumber,name:t.name,type:t.type}));I(n.EVENT_TYPE.PHONE_CONTACTS,{contacts:a})}catch(t){R(n.ERROR_TYPE.CAN_NOT_GET_PHONE_CONTACTS,t)}break;case n.MESSAGE_TYPE.SWAP_PARTICIPANTS:try{const e=await f.swap(t.data.callToHold,t.data.callToResume);h.validateClassObject(e,A);const{isThirdPartyOnHold:a,isCustomerOnHold:r,calls:i}=e;I(n.EVENT_TYPE.HOLD_TOGGLE,{isThirdPartyOnHold:a,isCustomerOnHold:r,calls:i})}catch(t){R(n.ERROR_TYPE.CAN_NOT_SWAP_PARTICIPANTS,t)}break;case n.MESSAGE_TYPE.CONFERENCE:try{const e=await f.conference(t.data.calls);h.validateClassObject(e,E);const{isThirdPartyOnHold:a,isCustomerOnHold:r}=e;I(n.EVENT_TYPE.HOLD_TOGGLE,{isThirdPartyOnHold:a,isCustomerOnHold:r})}catch(t){R(n.ERROR_TYPE.CAN_NOT_CONFERENCE,t)}break;case n.MESSAGE_TYPE.ADD_PARTICIPANT:try{const e=await f.addParticipant(new O(t.data.contact),t.data.call);h.validateClassObject(e,l);const{initialCallHasEnded:a,callInfo:r,phoneNumber:i,callId:s}=e;I(n.EVENT_TYPE.PARTICIPANT_ADDED,{initialCallHasEnded:a,callInfo:r,phoneNumber:i,callId:s})}catch(t){R(n.ERROR_TYPE.CAN_NOT_ADD_PARTICIPANT,t)}break;case n.MESSAGE_TYPE.PAUSE_RECORDING:try{const e=await f.pauseRecording(t.data.call);h.validateClassObject(e,c);const{isRecordingPaused:a,contactId:r,initialContactId:i,instanceId:s,region:o}=e;I(n.EVENT_TYPE.RECORDING_TOGGLE,{isRecordingPaused:a,contactId:r,initialContactId:i,instanceId:s,region:o})}catch(t){R(n.ERROR_TYPE.CAN_NOT_PAUSE_RECORDING,t)}break;case n.MESSAGE_TYPE.RESUME_RECORDING:try{const e=await f.resumeRecording(t.data.call);h.validateClassObject(e,c);const{isRecordingPaused:a,contactId:r,initialContactId:i,instanceId:s,region:o}=e;I(n.EVENT_TYPE.RECORDING_TOGGLE,{isRecordingPaused:a,contactId:r,initialContactId:i,instanceId:s,region:o})}catch(t){R(n.ERROR_TYPE.CAN_NOT_RESUME_RECORDING,t)}break;case n.MESSAGE_TYPE.LOGOUT:try{const t=await f.logout();h.validateClassObject(t,N);const{success:e}=t;I(n.EVENT_TYPE.LOGOUT_RESULT,{success:e})}catch(t){R(n.ERROR_TYPE.CAN_NOT_LOG_OUT,t)}break;case n.MESSAGE_TYPE.MESSAGE:f.handleMessage(t.data.message);break;case n.MESSAGE_TYPE.WRAP_UP_CALL:f.wrapUpCall(t.data.call);break;case n.MESSAGE_TYPE.AGENT_AVAILABLE:if(p=t.data.isAvailable,p){const t=await f.getActiveCalls();h.validateClassObject(t,i);const e=t.activeCalls;for(const t in e){const a=e[t];switch(a.isReplayedCall=!0,a.state){case n.CALL_STATE.CONNECTED:I(n.EVENT_TYPE.CALL_CONNECTED,a);break;case n.CALL_STATE.RINGING:I(n.EVENT_TYPE.CALL_STARTED,a);break;case n.CALL_STATE.TRANSFERRING:I(n.EVENT_TYPE.PARTICIPANT_ADDED,{phoneNumber:a.contact.phoneNumber,callInfo:a.callInfo,initialCallHasEnded:a.callAttributes.initialCallHasEnded,callId:a.callId});break;case n.CALL_STATE.TRANSFERRED:I(n.EVENT_TYPE.PARTICIPANT_CONNECTED,{phoneNumber:a.contact.phoneNumber,callInfo:a.callInfo,initialCallHasEnded:a.callAttributes.initialCallHasEnded,callId:a.callId})}}}}}async function y(t){switch(t.data.type){case n.MESSAGE_TYPE.SETUP_CONNECTOR:P=t.ports[0],P.onmessage=S;try{const e=await f.init(t.data.connectorConfig);h.validateClassObject(e,_),e.showLogin?I(n.EVENT_TYPE.SHOW_LOGIN,{loginFrameHeight:e.loginFrameHeight}):await L()}catch(t){R(n.ERROR_TYPE.CAN_NOT_LOG_IN,t)}window.removeEventListener("message",y)}}const v={EVENT_TYPE:{LOGIN_RESULT:n.EVENT_TYPE.LOGIN_RESULT,LOGOUT_RESULT:n.EVENT_TYPE.LOGOUT_RESULT,CALL_STARTED:n.EVENT_TYPE.CALL_STARTED,CALL_CONNECTED:n.EVENT_TYPE.CALL_CONNECTED,HANGUP:n.EVENT_TYPE.HANGUP,PARTICIPANT_CONNECTED:n.EVENT_TYPE.PARTICIPANT_CONNECTED,PARTICIPANT_REMOVED:n.EVENT_TYPE.PARTICIPANT_REMOVED,MESSAGE:n.EVENT_TYPE.MESSAGE,REMOTE_CONTROLLER:"REMOTE_CONTROLLER"},AGENT_STATUS:{...n.AGENT_STATUS},PARTICIPANT_TYPE:{...n.PARTICIPANT_TYPE},CALL_TYPE:{...n.CALL_TYPE},CONTACT_TYPE:{...n.CONTACT_TYPE},CALL_STATE:{...n.CALL_STATE}};function g(t){f=t,window.addEventListener("message",y)}async function b({eventType:t,payload:e}){switch(t){case v.EVENT_TYPE.LOGIN_RESULT:try{h.validateClassObject(e,N);const{success:t}=e;I(n.EVENT_TYPE.LOGIN_RESULT,{success:t}),t&&await L()}catch(t){R(n.ERROR_TYPE.CAN_NOT_LOG_IN,t)}break;case v.EVENT_TYPE.LOGOUT_RESULT:try{h.validateClassObject(e,N),I(n.EVENT_TYPE.LOGOUT_RESULT,{success:e.success})}catch(t){R(n.ERROR_TYPE.CAN_NOT_LOG_OUT,t)}break;case v.EVENT_TYPE.CALL_STARTED:try{h.validateClassObject(e,u),I(n.EVENT_TYPE.CALL_STARTED,e.call)}catch(t){R(n.ERROR_TYPE.CAN_NOT_START_THE_CALL,t)}break;case v.EVENT_TYPE.CALL_CONNECTED:try{h.validateClassObject(e,u),I(n.EVENT_TYPE.CALL_CONNECTED,e.call)}catch(t){R(n.ERROR_TYPE.CAN_NOT_START_THE_CALL,t)}break;case v.EVENT_TYPE.HANGUP:try{h.validateClassObject(e,u),I(n.EVENT_TYPE.HANGUP,e.call)}catch(t){R(n.ERROR_TYPE.CAN_NOT_END_THE_CALL,t)}break;case v.EVENT_TYPE.PARTICIPANT_CONNECTED:try{h.validateClassObject(e,l);const{initialCallHasEnded:t,callInfo:a,phoneNumber:r,callId:i}=e;I(n.EVENT_TYPE.PARTICIPANT_CONNECTED,{initialCallHasEnded:t,callInfo:a,phoneNumber:r,callId:i})}catch(t){R(n.ERROR_TYPE.CAN_NOT_CONNECT_PARTICIPANT,t)}break;case v.EVENT_TYPE.PARTICIPANT_REMOVED:try{h.validateClassObject(e,o);const{reason:t,participantType:a}=e,r=await f.getActiveCalls();h.validateClassObject(r,i);const s=r.activeCalls;if(0===s.length)I(n.EVENT_TYPE.HANGUP);else if(a===n.PARTICIPANT_TYPE.INITIAL_CALLER){const t=Object.values(s).filter(t=>t.callType===n.CALL_TYPE.ADD_PARTICIPANT).pop();I(t.state===n.CALL_STATE.TRANSFERRING?n.EVENT_TYPE.PARTICIPANT_ADDED:n.EVENT_TYPE.PARTICIPANT_CONNECTED,{initialCallHasEnded:!0})}else I(n.EVENT_TYPE.PARTICIPANT_REMOVED,{reason:t})}catch(t){R(n.ERROR_TYPE.CAN_NOT_HANGUP_PARTICIPANT,t)}break;case v.EVENT_TYPE.MESSAGE:I(n.EVENT_TYPE.MESSAGE,e);break;case v.EVENT_TYPE.REMOTE_CONTROLLER:S(e)}}function G(){return p}},function(t,e,a){"use strict";var n=a(2),r=a.n(n),i=a(0);function s(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,n)}return a}e.a={LOGIN_SUBMIT:"LOGIN_SUBMIT",SHOW_LOGIN_PAGE:"SHOW_LOGIN_PAGE",GET_SHOW_LOGIN_PAGE:"GET_SHOW_LOGIN_PAGE",SET_SHOW_LOGIN_PAGE:"SET_SHOW_LOGIN_PAGE",CAPABILITIES:"CAPABILITIES",GET_CAPABILITIES:"GET_CAPABILITIES",SET_CAPABILITIES:"SET_CAPABILITIES",START_INBOUND_CALL:"START_INBOUND_CALL",CONNECT_PARTICIPANT:"CONNECT_PARTICIPANT",REMOVE_PARTICIPANT:"REMOVE_PARTICIPANT",CONNECT_CALL:"CONNECT_CALL",HANGUP:"HANGUP",GET_PHONE_CONTACTS:"GET_PHONE_CONTACTS",SOFTPHONE_LOGOUT:"SOFTPHONE_LOGOUT",CREATE_TRANSCRIPTION:"SEND_TRANSCRIPTION",INBOUND_CALL_TYPE:"inbound",MESSAGE_FROM_CONNECTOR:"MESSAGE_FROM_CONNECTOR",MESSAGE_TO_CONNECTOR:"MESSAGE_TO_CONNECTOR",SENDER_TYPE:{END_USER:"END_USER",HUMAN_AGENT:"HUMAN_AGENT",VIRTUAL_AGENT:"VIRTUAL_AGENT"},PARTICIPANT_TYPE:function(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?s(Object(a),!0).forEach((function(e){r()(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):s(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}({},i.f.PARTICIPANT_TYPE),SEND_RECORDING:"SEND_RECORDING",LOGIN_RESULT:"LOGIN_RESULT",LOGOUT_RESULT:"LOGOUT_RESULT",CALL_CONNECTED:"CALL_CONNECTED",THROW_ERROR:"THROW_ERROR",PARTICIPANT_CONNECTED:"PARTICIPANT_CONNECTED",PARTICIPANT_REMOVED:"PARTICIPANT_REMOVED",MESSAGE:"MESSAGE",REMOTE_CONTROLLER:"REMOTE_CONTROLLER",MESSAGE_TYPE:{ACCEPT_CALL:"ACCEPT_CALL",DECLINE_CALL:"DECLINE_CALL",END_CALL:"END_CALL",MUTE:"MUTE",UNMUTE:"UNMUTE",HOLD:"HOLD",RESUME:"RESUME",SET_AGENT_STATUS:"SET_AGENT_STATUS",DIAL:"DIAL",SEND_DIGITS:"SEND_DIGITS",GET_PHONE_CONTACTS:"GET_PHONE_CONTACTS",SWAP_PARTICIPANTS:"SWAP_PARTICIPANTS",ADD_PARTICIPANT:"ADD_PARTICIPANT",CONFERENCE:"CONFERENCE",PAUSE_RECORDING:"PAUSE_RECORDING",RESUME_RECORDING:"RESUME_RECORDING",LOGOUT:"LOGOUT",MESSAGE:"MESSAGE"}}},function(t,e){t.exports=function(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function a(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&a(t.prototype,e),n&&a(t,n),t}},function(t,e){function a(e){return t.exports=a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},a(e)}t.exports=a},function(t,e,a){t.exports=a(13)},function(t,e,a){var n=a(10);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}},function(t,e,a){var n=a(11),r=a(12);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?r(t):e}},function(t,e){function a(t,e,a,n,r,i,s){try{var c=t[i](s),o=c.value}catch(t){return void a(t)}c.done?e(o):Promise.resolve(o).then(n,r)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var s=t.apply(e,n);function c(t){a(s,r,i,c,o,"next",t)}function o(t){a(s,r,i,c,o,"throw",t)}c(void 0)}))}}},function(t,e){function a(e,n){return t.exports=a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},a(e,n)}t.exports=a},function(t,e){function a(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=a=function(t){return typeof t}:t.exports=a=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(e)}t.exports=a},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e,a){var n=function(t){"use strict";var e=Object.prototype,a=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function c(t,e,a,n){var r=e&&e.prototype instanceof E?e:E,i=Object.create(r.prototype),s=new p(n||[]);return i._invoke=function(t,e,a){var n="suspendedStart";return function(r,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===r)throw i;return I()}for(a.method=r,a.arg=i;;){var s=a.delegate;if(s){var c=h(s,a);if(c){if(c===l)continue;return c}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===n)throw n="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n="executing";var E=o(t,e,a);if("normal"===E.type){if(n=a.done?"completed":"suspendedYield",E.arg===l)continue;return{value:E.arg,done:a.done}}"throw"===E.type&&(n="completed",a.method="throw",a.arg=E.arg)}}}(t,a,s),i}function o(t,e,a){try{return{type:"normal",arg:t.call(e,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function E(){}function T(){}function u(){}var A={};A[r]=function(){return this};var _=Object.getPrototypeOf,N=_&&_(_(R([])));N&&N!==e&&a.call(N,r)&&(A=N);var C=u.prototype=E.prototype=Object.create(A);function O(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function d(t,e){var n;this._invoke=function(r,i){function s(){return new e((function(n,s){!function n(r,i,s,c){var l=o(t[r],t,i);if("throw"!==l.type){var E=l.arg,T=E.value;return T&&"object"==typeof T&&a.call(T,"__await")?e.resolve(T.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):e.resolve(T).then((function(t){E.value=t,s(E)}),(function(t){return n("throw",t,s,c)}))}c(l.arg)}(r,i,n,s)}))}return n=n?n.then(s,s):s()}}function h(t,e){var a=t.iterator[e.method];if(void 0===a){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,h(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=o(a,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var r=n.arg;return r?r.done?(e[t.resultName]=r.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):r:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function f(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function p(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function R(t){if(t){var e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(a.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return T.prototype=C.constructor=u,u.constructor=T,u[s]=T.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===T||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(C),t},t.awrap=function(t){return{__await:t}},O(d.prototype),d.prototype[i]=function(){return this},t.AsyncIterator=d,t.async=function(e,a,n,r,i){void 0===i&&(i=Promise);var s=new d(c(e,a,n,r),i);return t.isGeneratorFunction(a)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},O(C),C[s]="Generator",C[r]=function(){return this},C.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var a in t)e.push(a);return e.reverse(),function a(){for(;e.length;){var n=e.pop();if(n in t)return a.value=n,a.done=!1,a}return a.done=!0,a}},t.values=R,p.prototype={constructor:p,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(f),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(a,n){return s.type="throw",s.arg=t,e.next=a,n&&(e.method="next",e.arg=void 0),!!n}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),o=a.call(i,"finallyLoc");if(c&&o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!o)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),f(a),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.tryLoc===t){var n=a.completion;if("throw"===n.type){var r=n.arg;f(a)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,a){return this.delegate={iterator:R(t),resultName:e,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},,,function(t,e,a){"use strict";a.r(e);var n=a(0),r=a(3),i=a.n(r),s=a(4),c=a.n(s),o=a(2),l=a.n(o),E=a(7),T=a.n(E),u=a(8),A=a.n(u),_=a(5),N=a.n(_);function C(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,n)}return a}function O(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?C(Object(a),!0).forEach((function(e){l()(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):C(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function d(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,n=N()(t);if(e){var r=N()(this).constructor;a=Reflect.construct(n,arguments,r)}else a=n.apply(this,arguments);return A()(this,a)}}var h=function(t){T()(a,t);var e=d(a);function a(t,r,s,c){i()(this,a);var o=n.f.CALL_STATE.RINGING,l={voiceCallId:c,state:o,participantType:s,initialCallHasEnded:!1,isOnHold:!1},E=Math.random().toString(36).substring(2,15);return e.call(this,{callId:E,callType:t,contact:r,state:o,callAttributes:l,phoneNumber:r.phoneNumber})}return c()(a,[{key:"parentId",set:function(t){this.callAttributes.parentId=t}}]),a}(n.n),P=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{isLoginRequired:!0,capabilities:JSON.parse(localStorage.getItem("capabilities"))||{hasMerge:!0,hasMute:!0,hasRecord:!0,hasSwap:!0},activeCalls:this.getActiveCallsObj(),destroyedCalls:[],agentStatus:"Available",phoneContacts:[new n.g({id:"id1",phoneNumber:"555-555-4441",type:n.f.CONTACT_TYPE.PHONENUMBER,name:"AgentU"}),new n.g({id:"id2",type:n.f.CONTACT_TYPE.PHONEBOOK,phoneNumber:"555-555-4442",name:"AgentV"}),new n.g({id:"id3",type:n.f.CONTACT_TYPE.PHONENUMBER,name:"AgentW",phoneNumber:"555-555-4443"}),new n.g({id:"id4",type:n.f.CONTACT_TYPE.PHONENUMBER,name:"AgentX",phoneNumber:"555-555-4444"}),new n.g({id:"id5",type:n.f.CONTACT_TYPE.PHONEBOOK,name:"AgentY",phoneNumber:"555-555-4445"})]};i()(this,t),this.state=O(O({},e),{},{showLoginPage:!!JSON.parse(localStorage.getItem("showLoginPage")),throwError:!!JSON.parse(localStorage.getItem("throwError"))})}return c()(t,[{key:"getCall",value:function(t){return t&&this.hasActiveCalls()?"HANGUP"===t.type?Object.values(this.state.activeCalls).filter((function(t){return t.callAttributes.participantType===n.f.PARTICIPANT_TYPE.INITIAL_CALLER})).pop():t.callAttributes&&t.callAttributes.participantType?Object.values(this.state.activeCalls).filter((function(e){return e.callAttributes.participantType===t.callAttributes.participantType})).pop():t.callId?this.state.activeCalls[t.callId]:null:null}},{key:"addCall",value:function(t){this.state.activeCalls[t.callId]=t,localStorage.setItem("activeCalls",JSON.stringify(this.state.activeCalls))}},{key:"showLoginPage",value:function(t){localStorage.setItem("showLoginPage",t),this.state.showLoginPage=t}},{key:"setCapabilities",value:function(t){localStorage.setItem("capabilities",JSON.stringify(t)),this.state.capabilities=t}},{key:"throwError",value:function(t){localStorage.setItem("throwError",t),this.state.throwError=t}},{key:"subsystemLoginResult",value:function(t){Object(n.s)({eventType:n.f.EVENT_TYPE.LOGIN_RESULT,payload:new n.h({success:this.state.showLoginPage&&t})})}},{key:"log",value:function(){Array.prototype.unshift.call(arguments,"[sdk]"),Function.apply.call(console.log,console,Array.from(arguments))}},{key:"filterContacts",value:function(t,e){if(!e)return t;var a=t;return e.contains&&(a=a.filter((function(t){return Object.keys(t).some((function(a){return t[a].includes(e.contains)}))}))),e.type&&(a=a.filter((function(t){return Object.keys(t).some((function(a){return"type"===a&&t[a]===e.type}))}))),a}},{key:"destroyCall",value:function(t,e){if(this.state.throwError)return this.executeAsync("destroyCall",null);var a=this.getCall(t);return a.state=a.callAttributes.state=n.f.CALL_STATE.ENDED,a.reason=e,this.state.destroyedCalls.push(a),delete this.state.activeCalls[a.callId],localStorage.setItem("activeCalls",JSON.stringify(this.state.activeCalls)),this.executeAsync("destroyCall",new n.c({call:a}))}},{key:"failCall",value:function(t,e){this.log("failCall",t,e),this.destroyCall(t,"CallFailed")}},{key:"init",value:function(t){return this.executeAsync("ssoLogin",this.state.showLoginPage?new n.j({showLogin:!0,loginFrameHeight:350}):new n.j({}))}},{key:"subsystemLogout",value:function(){Object(n.s)({eventType:n.f.EVENT_TYPE.LOGOUT_RESULT,payload:new n.h({success:!this.state.throwError})})}},{key:"omniLogout",value:function(){return this.executeAsync("SubsystemLogout",new n.h({success:!0}))}},{key:"executeAsync",value:function(t,e){return this.log("Executing action - ".concat(t),e),this.state.throwError?Promise.reject(new Error("demo error")):Promise.resolve(e)}},{key:"dial",value:function(t){var e=new h(n.f.CALL_TYPE.OUTBOUND,t,n.f.PARTICIPANT_TYPE.INITIAL_CALLER);return this.addCall(e),this.executeAsync("dial",new n.c({call:e}))}},{key:"startInboundCall",value:function(t,e,a){var r=this;if(!Object(n.r)()){var i="Agent is not available for a inbound call from phoneNumber - ".concat(t);return this.log(i),Promise.reject(new Error(i))}var s=new n.g({phoneNumber:t});return fetch("/api/createVoiceCall?caller="+t+"&type="+n.f.CALL_TYPE.INBOUND).then((function(t){return t.json()})).then((function(t){return a=t.voiceCallId,function(){var t=new h(n.f.CALL_TYPE.INBOUND,s,e,a);r.addCall(t);var i=new n.c({call:t});return Object(n.s)({eventType:n.f.EVENT_TYPE.CALL_STARTED,payload:i}),r.executeAsync("startInboundCall",i)}()})).catch((function(t){return Promise.reject(t)}))}},{key:"getActiveCallsObj",value:function(){try{var t=JSON.parse(localStorage.getItem("activeCalls"));return Object.keys(t).forEach((function(e){if(t[e].contact){var a=new n.g(t[e].contact);t[e].contact=a}t[e]=new n.n(t[e])})),t||{}}catch(t){return{}}}},{key:"hasActiveCalls",value:function(){return this.state.activeCalls&&Object.keys(this.state.activeCalls).length>0}},{key:"getCapabilities",value:function(){return this.executeAsync("getCapabilities",new n.d({hasMute:this.state.capabilities.hasMute,hasMerge:this.state.capabilities.hasMerge,hasRecord:this.state.capabilities.hasRecord,hasSwap:this.state.capabilities.hasSwap}))}},{key:"getActiveCalls",value:function(){var t=this.getActiveCallsObj(),e=Object.values(t);return this.executeAsync("getActiveCalls",new n.a({activeCalls:e}))}},{key:"acceptCall",value:function(t){var e=this.getCall(t);return this.log("acceptCall",e),e?(e.state=n.f.CALL_STATE.CONNECTED,e.callAttributes.state=n.f.CALL_STATE.CONNECTED,this.addCall(e),this.executeAsync("acceptCall",new n.c({call:e}))):Promise.reject("Call not found")}},{key:"declineCall",value:function(t){return this.log("declineCall",t),this.destroyCall(t,"declined")}},{key:"endCall",value:function(t,e){if(this.log("endCall",t,e),t.callAttributes&&t.callAttributes.participantType===n.f.PARTICIPANT_TYPE.AGENT){var a=this.getCall({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.INITIAL_CALLER}}),r=this.getCall({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.THIRD_PARTY}});return a&&this.destroyCall(a,"AgentHangup"),r&&this.destroyCall(r,"AgentHangup"),this.executeAsync("destroyCall",new n.c({call:a||r}))}return this.destroyCall(t,"AgentHangup")}},{key:"mute",value:function(){return this.executeAsync("mute",new n.k({isMuted:!0}))}},{key:"unmute",value:function(){return this.executeAsync("unmute",new n.k({isMuted:!1}))}},{key:"hold",value:function(t){return this.updateHoldState(t,!0),this.executeAsync("hold",new n.i({isThirdPartyOnHold:this.isOnHold({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.THIRD_PARTY}}),isCustomerOnHold:this.isOnHold({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.INITIAL_CALLER}}),calls:this.state.activeCalls}))}},{key:"resume",value:function(t){return this.updateHoldState(t,!1),this.executeAsync("resume",new n.i({isThirdPartyOnHold:this.isOnHold({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.THIRD_PARTY}}),isCustomerOnHold:this.isOnHold({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.INITIAL_CALLER}}),calls:this.state.activeCalls}))}},{key:"pauseRecording",value:function(t){return this.executeAsync("pauseRecording",new n.p({isRecordingPaused:!0}))}},{key:"resumeRecording",value:function(t){return this.executeAsync("resumeRecording",new n.p({isRecordingPaused:!1}))}},{key:"isOnHold",value:function(t){var e=this.getCall(t);if(e)return this.log("isOnHold",t,e.callAttributes.isOnHold),e.callAttributes.isOnHold}},{key:"updateHoldState",value:function(t,e){var a=this.getCall(t);a.callAttributes.isOnHold=e,a.callInfo=new n.b({isOnHold:e}),this.addCall(a)}},{key:"swapCalls",value:function(t,e){return this.updateHoldState(t,!this.getCall(t).callAttributes.isOnHold),this.updateHoldState(e,!this.getCall(e).callAttributes.isOnHold),this.executeAsync("swapCalls",new n.i({isThirdPartyOnHold:this.isOnHold(t),isCustomerOnHold:this.isOnHold(e),calls:this.state.activeCalls}))}},{key:"conference",value:function(t){var e=this;return t.forEach((function(t){e.updateHoldState(t,!1)})),this.executeAsync("Conference",new n.e({isThirdPartyOnHold:!1,isCustomerOnHold:!1}))}},{key:"setAgentStatus",value:function(t){return this.agentStatus=t,this.executeAsync("setAgentStatus",new n.h({success:!0}))}},{key:"sendDigits",value:function(t){return this.executeAsync("sendDigits")}},{key:"getPhoneContacts",value:function(t){var e=this.filterContacts(this.state.phoneContacts,t);return this.executeAsync("getPhoneContacts",new n.o({contacts:e}))}},{key:"addParticipant",value:function(t,e){var a=this.getCall(e);a.callAttributes.isOnHold=!0,a.callInfo=new n.b({isOnHold:!0});var r=a.callAttributes.voiceCallId,i=new h(n.f.CALL_TYPE.ADD_PARTICIPANT,t,n.f.PARTICIPANT_TYPE.THIRD_PARTY,r);return i.parentId=a.callId,i.callAttributes.isOnHold=!1,i.callInfo=new n.b({isOnHold:!1}),i.state=n.f.CALL_STATE.TRANSFERRING,this.log("addParticipant to parent voiceCall "+r,i),this.addCall(a),this.addCall(i),this.executeAsync("addParticipant",new n.m({phoneNumber:t.phoneNumber,callInfo:new n.b({isOnHold:!1}),initialCallHasEnded:a.callAttributes&&a.callAttributes.initialCallHasEnded,callId:i.callId}))}},{key:"connectParticipant",value:function(){var t=this.getCall({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.THIRD_PARTY}});t.state=n.f.CALL_STATE.TRANSFERRED,this.log("connectParticipant",t),this.addCall(t),Object(n.s)({eventType:n.f.EVENT_TYPE.PARTICIPANT_CONNECTED,payload:new n.m({phoneNumber:t.contact.phoneNumber,callInfo:new n.b(t.callInfo),initialCallHasEnded:t.callAttributes&&t.callAttributes.initialCallHasEnded,callId:t.callId})})}},{key:"removeParticipant",value:function(t){var e=this.getCall({callAttributes:{participantType:t}});this.destroyCall(e,"participant hangup"),this.log("removeParticipant",e),Object(n.s)({eventType:n.f.EVENT_TYPE.PARTICIPANT_REMOVED,payload:new n.l({participantType:t})})}},{key:"connectCall",value:function(){var t=this.getCall({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.INITIAL_CALLER}});t.state=n.f.CALL_STATE.CONNECTED,t.callAttributes.state=n.f.CALL_STATE.CONNECTED,this.addCall(t),this.log("connectCall",t),Object(n.s)({eventType:n.f.EVENT_TYPE.CALL_CONNECTED,payload:new n.c({call:t})})}},{key:"hangup",value:function(){var t=this.getCall({callAttributes:{participantType:n.f.PARTICIPANT_TYPE.INITIAL_CALLER}});this.log("hangUp",t),this.destroyCall(t,"CallerHangup"),Object(n.s)({eventType:n.f.EVENT_TYPE.HANGUP,payload:new n.c({call:t})})}},{key:"publishMessage",value:function(t){this.log("publishMessage",t),Object(n.s)({eventType:n.f.EVENT_TYPE.MESSAGE,payload:t})}},{key:"handleMessage",value:function(t){this.log("handleMessage",t)}}]),t}(),f=function(){function t(e){i()(this,t),this.sdk=new P(e)}return c()(t,[{key:"init",value:function(t){return this.sdk.init(t)}},{key:"getActiveCalls",value:function(){return this.sdk.getActiveCalls()}},{key:"acceptCall",value:function(t){return this.sdk.acceptCall(t)}},{key:"declineCall",value:function(t){return this.sdk.declineCall(t||{callAttributes:{participantType:n.f.PARTICIPANT_TYPE.INITIAL_CALLER}})}},{key:"endCall",value:function(t,e){return this.sdk.endCall(t,e)}},{key:"mute",value:function(){return this.sdk.mute()}},{key:"unmute",value:function(){return this.sdk.unmute()}},{key:"hold",value:function(t){return this.sdk.hold(t)}},{key:"resume",value:function(t){return this.sdk.resume(t)}},{key:"pauseRecording",value:function(t){return this.sdk.pauseRecording(t)}},{key:"resumeRecording",value:function(t){return this.sdk.resumeRecording(t)}},{key:"swap",value:function(t,e){return this.sdk.swapCalls(t,e)}},{key:"conference",value:function(t){return this.sdk.conference(t)}},{key:"setAgentStatus",value:function(t){return this.sdk.setAgentStatus(t)}},{key:"dial",value:function(t){return this.sdk.dial(t)}},{key:"sendDigits",value:function(t){return this.sdk.sendDigits(t)}},{key:"getPhoneContacts",value:function(t){return this.sdk.getPhoneContacts(t)}},{key:"addParticipant",value:function(t,e){return this.sdk.addParticipant(t,e)}},{key:"logout",value:function(){return this.sdk.omniLogout()}},{key:"dispatchEventToRemote",value:function(t,e){new BroadcastChannel("rc-request").postMessage({type:t,payload:e})}},{key:"getCapabilities",value:function(){return this.sdk.getCapabilities()}},{key:"handleMessage",value:function(t){this.sdk.handleMessage(t),this.dispatchEventToRemote(n.f.EVENT_TYPE.MESSAGE,t)}}]),t}(),p=a(6),R=a.n(p),I=a(9),L=a.n(I),S=a(1);var y=new f;window.addEventListener("load",(function(){var t,e;Object(n.q)(y),t=y,(e=new BroadcastChannel("rc-request")).addEventListener("message",function(){var a=L()(R.a.mark((function a(n){var r,i;return R.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!n||!n.data){a.next=35;break}a.t0=n.data.type,a.next=a.t0===S.a.LOGIN_SUBMIT?4:a.t0===S.a.GET_SHOW_LOGIN_PAGE?6:a.t0===S.a.GET_CAPABILITIES?9:a.t0===S.a.THROW_ERROR?12:a.t0===S.a.SET_SHOW_LOGIN_PAGE?14:a.t0===S.a.SET_CAPABILITIES?16:a.t0===S.a.START_INBOUND_CALL?18:a.t0===S.a.CONNECT_PARTICIPANT?20:a.t0===S.a.REMOVE_PARTICIPANT?22:a.t0===S.a.CONNECT_CALL?24:a.t0===S.a.SOFTPHONE_LOGOUT?26:a.t0===S.a.CREATE_TRANSCRIPTION?29:a.t0===S.a.SEND_RECORDING?31:a.t0===S.a.MESSAGE_FROM_CONNECTOR?33:35;break;case 4:return t.sdk.subsystemLoginResult(n.data.success),a.abrupt("break",35);case 6:return r=t.sdk.state.showLoginPage,e.postMessage({type:S.a.SHOW_LOGIN_PAGE,value:r}),a.abrupt("break",35);case 9:return i=t.sdk.state.capabilities,e.postMessage({type:S.a.CAPABILITIES,value:i}),a.abrupt("break",35);case 12:return t.sdk.throwError(n.data.value),a.abrupt("break",35);case 14:return t.sdk.showLoginPage(n.data.value),a.abrupt("break",35);case 16:return t.sdk.setCapabilities({hasMute:n.data.value.hasMute,hasRecord:n.data.value.hasRecord,hasSwap:n.data.value.hasSwap,hasMerge:n.data.value.hasMerge}),a.abrupt("break",35);case 18:return t.sdk.startInboundCall(n.data.phoneNumber,n.data.participantType,n.data.voiceCallId),a.abrupt("break",35);case 20:return t.sdk.connectParticipant(),a.abrupt("break",35);case 22:return t.sdk.removeParticipant(n.data.participantType),a.abrupt("break",35);case 24:return t.sdk.connectCall(),a.abrupt("break",35);case 26:return a.next=28,t.sdk.subsystemLogout();case 28:return a.abrupt("break",35);case 29:return fetch("/api/createTranscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n.data)}).then((function(e){t.sdk.log("Create transcript returned with ".concat(e.success))})).catch((function(e){t.sdk.log("Create transcript failed - ".concat(e))})),a.abrupt("break",35);case 31:return fetch("/api/updateVoiceCall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n.data.recordingInfo)}).then((function(e){t.sdk.log("Store recording link returned with ".concat(e.success))})).catch((function(e){t.sdk.log("Store recording link failed - ".concat(e))})),a.abrupt("break",35);case 33:return a.next=35,t.sdk.publishMessage(n.data.message);case 35:case"end":return a.stop()}}),a)})));return function(t){return a.apply(this,arguments)}}())}))}]);
  //# sourceMappingURL=main.bundle.js.map