diff --git a/CHANGELOG.md b/CHANGELOG.md index f47ad0a0..c903751c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,16 @@ # CHANGELOG.md + +## 2.4.2 +- Fix an issue in Streams’ Voice ID APIs that may have led to incorrect values being set against the generatedSpeakerID field in the VoiceIdResult segment of Connect Contact Trace Records (CTRs). + +## 2.4.1 +- This version brings in updates that will provide enhanced monitoring experience to agents and supervisors, allowing to silently monitor multiparty calls, and if needed to barge in the call and take over control, mute agents, or drop them from the call. New APIs introduced with this feature are `isSilentMonitor`, `isBarge`, `isSilentMonitorEnabled`, `isBargeEnabled`, `isUnderSupervision`, `updateMonitorParticipantState`, `getMonitorCapabilities`, `getMonitorStatus`, `isForcedMute`. + ## 2.4.0 - Introduce Amazon Connect Step-by-step guides embedding support via `connect.agentApp.initApp`. ## 2.3.0 -- Fix an issue in Streams’ Voice ID APIs that may have led to incorrect values being set against the generatedSpeakerID field in the VoiceIdResult segment of Connect Contact Trace Records (CTRs). - Make StreamsJS compatible with strict mode - Fix an issue that connect.ValueError and connect.StateError don't print error message properly diff --git a/Documentation.md b/Documentation.md index d052704a..3f965caf 100644 --- a/Documentation.md +++ b/Documentation.md @@ -15,10 +15,12 @@ In version 1.x, we also support `make` for legacy builds. This option was remove 1. December 2022 - In addition to the CCP, customers can now embed the Step-by-step guides application using the connect.agentApp. See the [updated documentation](https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md#initialization-for-ccp-customer-profiles-and-wisdom) for details on usage. * ### About Amazon Connect Step-by-step guides + With Amazon Connect you can now create guides that walk agents through tailored views that focus on what must be seen or done by the agent at a given moment during an interaction. You can design workflows for various types of customer interactions and present agents with different step-by-step guides based on context, such as call queue, customer information, and interactive voice response (IVR). This feature is available in the Connect agent workspace as well as an embeddable application that can be embedded into another website via the Streams API. For more information, visit the AWS website: https://aws.amazon.com/connect/agent-workspace/ +1. December 2022 - 2.4.2 + * This patch fixes an issue in Streams’ Voice ID APIs that may have led to incorrect values being set against the generatedSpeakerID field in the VoiceIdResult segment of Connect Contact Trace Records (CTRs). This occurred in some scenarios where you call either enrollSpeakerInVoiceId(), evaluateSpeakerWithVoiceId(), or updateVoiceIdSpeakerId() in your custom CCP integration code. If you are using Voice ID and consuming Voice ID CTRs, or updating speaker ID in your agent workflow, please upgrade to this version. 1. December 2022 - 2.4.1 * This version brings in updates that will provide enhanced monitoring experience to agents and supervisors, allowing to silently monitor multiparty calls, and if needed to barge in the call and take over control, mute agents, or drop them from the call. New APIs introduced with this feature are `isSilentMonitor`, `isBarge`, `isSilentMonitorEnabled`, `isBargeEnabled`, `isUnderSupervision`, `updateMonitorParticipantState`, `getMonitorCapabilities`, `getMonitorStatus`, `isForcedMute`. 1. August 2022 - 2.3.0 - * This patch fixes an issue in Streams’ Voice ID APIs that may have led to incorrect values being set against the generatedSpeakerID field in the VoiceIdResult segment of Connect Contact Trace Records (CTRs). This occurred in some scenarios where you call either enrollSpeakerInVoiceId(), evaluateSpeakerWithVoiceId(), or updateVoiceIdSpeakerId() in your custom CCP integration code. If you are using Voice ID and consuming Voice ID CTRs, please upgrade to this version. + * [Update on 12/13/2022] Please see 2.4.2 for final resolution of the Voice ID CTR fix. 1. Jan 2022 - 2.0.0 * Multiple calls to `initCCP` will no longer append multiple embedded CCPs to the window, and only the first call to `initCCP` will succeed. Please note that the use-case of initializing multiple CCPs has never been supported by Streams, and this change has been added to prevent unpredictable behavior arising from such cases. * `agent.onContactPending` has been removed. Please use `contact.onPending` instead. `connect.onError` now triggers. Previously, this api did not work at all. Please be aware that, if you have application logic within this function, its behavior has changed. See its entry in documentation.md for more details. @@ -1429,7 +1431,12 @@ conn.muteParticipant({ failure: function(err) { /* ... */ } }); ``` -Mute the connection server side. +Mute the connection server side. +#### Multiparty call +Any agent participant can mute another agent participant. + +#### Supervisor barges into the call +Agents can mute themselves, but cannot mute other agents or supervisor. Optional success and failure callbacks can be provided to determine if the operation was successful. @@ -1440,7 +1447,12 @@ conn.unmuteParticipant({ failure: function(err) { /* ... */ } }); ``` -Unmute the connection server side. +Unmute the connection server side. +#### Multiparty call +Any agent can only unmute themselves. + +#### Supervisor barges into the call +Agents can only unmute themselves up until the point they have been muted by the supervisor (isForcedMute API can help checking that). Once they have been muted by the supervisor, agent cannot unmute themselves until supervisor unmutes agent (at which point agent will regain ability to mute and unmute themselves). If supervisor has muted but not unmuted agent then drops from call, agent will be able to unmute themselves once supervisor has dropped. Optional success and failure callbacks can be provided to determine if the operation was successful. @@ -1989,3 +2001,113 @@ voiceConnection.deleteVoiceIdSpeaker() console.error(err); }); ``` + +## Enhanced Monitoring APIs +Enhanced monitoring providing real-time silent monitoring and barge capability to help managers and supervisors to listen in the agents' conversations and barge into the call if needed to take over the control and provide better customer experience. Supervisors in barge mode will be able to force mute agents and prevent them from unmuting themselves, will be able to hold, drop any connection, or directly speak with the customer. If the supervisor has muted an agent and then drops from the call, the agent will be able to unmute themselves once supervisor has dropped. Monitoring APIs are expected to be used against agent's(or supervisor's) connection. To start enhanced monitoring supervisor/manager will need to click an eye icon on the Real Time Metrics page. + +Streams Enhanced Monitoring APIs can be tested after all these prerequisites are met: +1. Enable Multi-Party Calls and Enhanced Monitoring in Telephony section of the Amazon Connect Console. +1. Enable Real-time contact monitoring and Real-time contact barge-in in Security Profiles + +### `voiceConnection.isSilentMonitor()` +```js +if (conn.isSilentMonitor()) { /* ... */ } +``` +Returns true if monitorStatus is `MonitoringMode.SILENT_MONITOR`. This means the supervisor connection is in silent monitoring state. Regular agent will not see supervisor's connection in the snapshot while it is in silent monitor state. + +### `voiceConnection.isBarge()` +```js +if (conn.isBarge()) { /* ... */ } +``` +Returns true if monitorStatus is `MonitoringMode.BARGE`. This means the connection is in barge-in state. Regular agent will see the supervisor's connection in the list of connections in the snapshot. + +### `voiceConnection.isSilentMonitorEnabled()` +```js +if (conn.isSilentMonitorEnabled()) { /* ... */ } +``` +Returns true if agent's monitoringCapabilities contain `MonitoringMode.SILENT_MONITOR` type. + +### `voiceConnection.isBargeEnabled()` +```js +if (conn.isBargeEnabled()) { /* ... */ } +``` +Returns true if agent's monitoringCapabilities contain `MonitoringMode.BARGE` state type. + +### `voiceConnection.getMonitorCapabilities()` +```js +var allowedMonitorStates = conn.getMonitorCapabilities(); +``` +Returns the array of enabled monitor states of this connection. The array will consist of `MonitoringMode` enum values. + +### `voiceConnection.getMonitorStatus()` +```js +var monitorState = conn.getMonitorStatus(); +``` +Returns the current monitoring state of this connection. The value can be on of `MonitoringMode` enum values if the agent is supervisor, or the monitorStatus will not be present for the agent. + +### `voiceConnection.isForcedMute()` +```js +if (conn.isForcedMute()) { /* ... */ } +``` +Determine whether the connection was forced muted by the manager. + +### `contact.updateMonitorParticipantState()` +```js +contact.updateMonitorParticipantState(targetState, { + success: function() { /* ... */ }, + failure: function(err) { /* ... */ } +}); +``` +Updates the monitor participant state to switch between different monitoring modes. The targetState value is a `MonitoringMode` enum member. + +### `contact.isUnderSupervision()` +```js +if (contact.isUnderSupervision()) { /* ... */ } +``` +Determines if the contact is under manager's supervision + +#### Usage examples + +Check that barge is enabled before switching to the barge mode - first we need to make sure that barge is enabled for the supervisor connection, and after that initiate monitor status change on the contact. +```js +if(voiceConnection.isBargeEnabled()) { + contact.updateMonitorParticipantState(connect.MonitoringMode.BARGE, { + success: function() { + console.log("Successfully changed the monitoring status to barge, now you can control the conversation") + }, + failure: function(err) { + console.log("Somenting went wrong, here is the error ", err) + } + }); +} +``` + +Check that silent monitor is enabled before switching to the silent monitor mode - first we need to make sure that silent monitor is enabled for the supervisor connection, and after that initiate monitor status change on the contact. +```js +if(voiceConnection.isSilentMonitorEnabled()) { + contact.updateMonitorParticipantState(connect.MonitoringMode.SILENT_MONITOR, { + success: function() { + console.log("Successfully changed the monitoring status to silent monitor") + }, + failure: function(err) { + console.log("Somenting went wrong, here is the error ", err) + } + }); +} +``` + +After supervisor mutes the agent - force mute field is automatically updated on the agent side. You may want to display a banner or somehow indicate to the agent that he cannot unmute himself back anymore. + +```js +if(voiceConnection.isForcedMute()) { + /* Some logic here to indicate forced mute to the agent */ +} +``` + +After supervisor barges the call - agent doesn't have control anymore. Agent can only mute or unmute himself until he was forced muted, or leave the call. It will be good to indicate that to ahent as well by hiding or disabling buttons. + +```js +if(voiceConnection.isUnderSupervision()) { + /* Some logic here to indicate disabled call controls to the agent */ +} +``` diff --git a/README.md b/README.md index ec2d9204..2cda2908 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,12 @@ In version 1.x, we also support `make` for legacy builds. This option was remove 1. December 2022 - In addition to the CCP, customers can now embed the Step-by-step guides application using the connect.agentApp. See the [updated documentation](https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md#initialization-for-ccp-customer-profiles-and-wisdom) for details on usage. * ### About Amazon Connect Step-by-step guides + With Amazon Connect you can now create guides that walk agents through tailored views that focus on what must be seen or done by the agent at a given moment during an interaction. You can design workflows for various types of customer interactions and present agents with different step-by-step guides based on context, such as call queue, customer information, and interactive voice response (IVR). This feature is available in the Connect agent workspace as well as an embeddable application that can be embedded into another website via the Streams API. For more information, visit the AWS website: https://aws.amazon.com/connect/agent-workspace/ +1. December 2022 - 2.4.2 + * This patch fixes an issue in Streams’ Voice ID APIs that may have led to incorrect values being set against the generatedSpeakerID field in the VoiceIdResult segment of Connect Contact Trace Records (CTRs). This occurred in some scenarios where you call either enrollSpeakerInVoiceId(), evaluateSpeakerWithVoiceId(), or updateVoiceIdSpeakerId() in your custom CCP integration code. If you are using Voice ID and consuming Voice ID CTRs, or updating speaker ID in your agent workflow, please upgrade to this version. +1. December 2022 - 2.4.1 + * This version brings in updates that will provide enhanced monitoring experience to agents and supervisors, allowing to silently monitor multiparty calls, and if needed to barge in the call and take over control, mute agents, or drop them from the call. New APIs introduced with this feature are `isSilentMonitor`, `isBarge`, `isSilentMonitorEnabled`, `isBargeEnabled`, `isUnderSupervision`, `updateMonitorParticipantState`, `getMonitorCapabilities`, `getMonitorStatus`, `isForcedMute`. 1. August 2022 - 2.3.0 - * This patch fixes an issue in Streams’ Voice ID APIs that may have led to incorrect values being set against the generatedSpeakerID field in the VoiceIdResult segment of Connect Contact Trace Records (CTRs). This occurred in some scenarios where you call either enrollSpeakerInVoiceId(), evaluateSpeakerWithVoiceId(), or updateVoiceIdSpeakerId() in your custom CCP integration code. If you are using Voice ID and consuming Voice ID CTRs, please upgrade to this version. + * [Update on 12/13/2022] Please see 2.4.2 for final resolution of the Voice ID CTR fix. 1. Jan 2022 - 2.0.0 * Multiple calls to `initCCP` will no longer append multiple embedded CCPs to the window, and only the first call to `initCCP` will succeed. Please note that the use-case of initializing multiple CCPs with `initCCP` has never been supported by Streams, and this change has been added to prevent unpredictable behavior arising from such cases. * `agent.onContactPending` has been removed. Please use `contact.onPending` instead. `connect.onError` now triggers. Previously, this api did not work at all. Please be aware that, if you have application logic within this function, its behavior has changed. See its entry in documentation.md for more details. diff --git a/package-lock.json b/package-lock.json index 176328d9..09328f94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "amazon-connect-streams", - "version": "2.4.1", + "version": "2.4.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "amazon-connect-streams", - "version": "2.4.1", + "version": "2.4.2", "license": "Apache-2.0", "dependencies": { "lodash.clonedeep": "^4.5.0" diff --git a/package.json b/package.json index d0f4db1d..6132c667 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amazon-connect-streams", - "version": "2.4.1", + "version": "2.4.2", "description": "Amazon Connect Streams Library", "engines": { "node": ">=12.0.0" diff --git a/release/connect-streams-min.js b/release/connect-streams-min.js index 21c8f1b7..b11f9e03 100644 --- a/release/connect-streams-min.js +++ b/release/connect-streams-min.js @@ -1 +1 @@ -(()=>{var e={465:(e,t,n)=>{e=n.nmd(e);var r="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",l="[object Map]",p="[object Number]",d="[object Object]",h="[object Promise]",f="[object RegExp]",g="[object Set]",m="[object String]",v="[object Symbol]",y="[object WeakMap]",E="[object ArrayBuffer]",S="[object DataView]",b="[object Float32Array]",T="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",_="[object Int32Array]",A="[object Uint8Array]",w="[object Uint8ClampedArray]",R="[object Uint16Array]",k="[object Uint32Array]",N=/\w*$/,O=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,D={};D[i]=D["[object Array]"]=D[E]=D[S]=D[s]=D[a]=D[b]=D[T]=D[C]=D[I]=D[_]=D[l]=D[p]=D[d]=D[f]=D[g]=D[m]=D[v]=D[A]=D[w]=D[R]=D[k]=!0,D["[object Error]"]=D[c]=D[y]=!1;var P="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,x="object"==typeof self&&self&&self.Object===Object&&self,M=P||x||Function("return this")(),U=t&&!t.nodeType&&t,F=U&&e&&!e.nodeType&&e,q=F&&F.exports===U;function j(e,t){return e.set(t[0],t[1]),e}function B(e,t){return e.add(t),e}function V(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o-1},we.prototype.set=function(e,t){var n=this.__data__,r=Le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Re.prototype.clear=function(){this.__data__={hash:new Ae,map:new(fe||we),string:new Ae}},Re.prototype.delete=function(e){return Ue(this,e).delete(e)},Re.prototype.get=function(e){return Ue(this,e).get(e)},Re.prototype.has=function(e){return Ue(this,e).has(e)},Re.prototype.set=function(e,t){return Ue(this,e).set(e,t),this},ke.prototype.clear=function(){this.__data__=new we},ke.prototype.delete=function(e){return this.__data__.delete(e)},ke.prototype.get=function(e){return this.__data__.get(e)},ke.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.set=function(e,t){var n=this.__data__;if(n instanceof we){var r=n.__data__;if(!fe||r.length<199)return r.push([e,t]),this;n=this.__data__=new Re(r)}return n.set(e,t),this};var qe=le?z(le,Object):function(){return[]},je=function(e){return te.call(e)};function Be(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||L.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=o}(e.length)&&!Xe(e)}var Ke=pe||function(){return!1};function Xe(e){var t=Ye(e)?te.call(e):"";return t==c||t==u}function Ye(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Je(e){return Ge(e)?Ne(e):function(e){if(!Ve(e))return de(e);var t=[];for(var n in Object(e))ee.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return De(e,!0,!0)}},821:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.agentApp={};var n="ccp";t.agentApp.initCCP=t.core.initCCP,t.agentApp.isInitialized=function(e){},t.agentApp.initAppCommunication=function(e,n){var r=document.getElementById(e),o=new t.IFrameConduit(n,window,r),i=[t.AgentEvents.UPDATE,t.ContactEvents.VIEW,t.EventType.ACKNOWLEDGE,t.EventType.TERMINATED,t.TaskEvents.CREATED];r.addEventListener("load",(function(e){i.forEach((function(e){t.core.getUpstream().onUpstream(e,(function(t){o.sendUpstream(e,t)}))}))}))};var r=function(e){var t=e.indexOf("ccp-v2");return e.slice(0,t-1)};t.agentApp.initApp=function(e,o,i,s){s=s||{};var a=i.endsWith("/")?i:i+"/",c=s.onLoad?s.onLoad:null,u={endpoint:a,style:s.style,onLoad:c};t.agentApp.AppRegistry.register(e,u,document.getElementById(o)),t.agentApp.AppRegistry.start(e,(function(o){var i=o.endpoint,a=o.containerDOM;return{init:function(){return e===n?(s.ccpParams=s.ccpParams?s.ccpParams:{},s.style&&(s.ccpParams.style=s.style),function(e,n,o){var i={ccpUrl:e,ccpLoadTimeout:1e4,loginPopup:!0,loginUrl:r(e)+"/login",softphone:{allowFramedSoftphone:!0,disableRingtone:!1}},s=t.merge(i,o.ccpParams);t.core.initCCP(n,s)}(i,a,s)):t.agentApp.initAppCommunication(e,i)},destroy:function(){return e===n?(o=r(i)+"/logout",t.fetch(o,{credentials:"include"}).then((function(){return t.core.getEventBus().trigger(t.EventType.TERMINATE),!0})).catch((function(e){return t.getLog().error("An error occured on logout."+e).withException(e),window.location.href=o,!1}))):null;var o}}}))},t.agentApp.stopApp=function(e){return t.agentApp.AppRegistry.stop(e)}}()},500:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t;var n,r="ccp";e.connect.agentApp.AppRegistry=(n={},{register:function(e,t,r){n[e]={containerDOM:r,endpoint:t.endpoint,style:t.style,instance:void 0,onLoad:t.onLoad}},start:function(e,t){if(n[e]){var o=n[e].containerDOM,i=n[e].endpoint,s=n[e].style,a=n[e].onLoad;if(e!==r){var c=function(e,t,n,r){var o=document.createElement("iframe");return o.src=t,o.style=n||"width: 100%; height:100%;",o.id=e,o["aria-label"]=e,o.onload=r,o.setAttribute("sandbox","allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"),o}(e,i,s,a);o.appendChild(c)}return n[e].instance=t(n[e]),n[e].instance.init()}},stop:function(e){if(n[e]){var t,r=n[e],o=r.containerDOM.querySelector("iframe");return r.containerDOM.removeChild(o),r.instance&&(t=r.instance.destroy(),delete r.instance),t}}})}()},965:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.AgentStateType=t.makeEnum(["init","routable","not_routable","offline"]),t.AgentStatusType=t.AgentStateType,t.AgentAvailStates=t.makeEnum(["Init","Busy","AfterCallWork","CallingCustomer","Dialing","Joining","PendingAvailable","PendingBusy"]),t.AgentErrorStates=t.makeEnum(["Error","AgentHungUp","BadAddressAgent","BadAddressCustomer","Default","FailedConnectAgent","FailedConnectCustomer","InvalidLocale","LineEngagedAgent","LineEngagedCustomer","MissedCallAgent","MissedCallCustomer","MultipleCcpWindows","RealtimeCommunicationError"]),t.EndpointType=t.makeEnum(["phone_number","agent","queue"]),t.AddressType=t.EndpointType,t.ConnectionType=t.makeEnum(["agent","inbound","outbound","monitoring"]),t.ConnectionStateType=t.makeEnum(["init","connecting","connected","hold","disconnected","silent_monitor","barge"]),t.ConnectionStatusType=t.ConnectionStateType,t.CONNECTION_ACTIVE_STATES=t.set([t.ConnectionStateType.CONNECTING,t.ConnectionStateType.CONNECTED,t.ConnectionStateType.HOLD,t.ConnectionStateType.SILENT_MONITOR,t.ConnectionStateType.BARGE]),t.CONNECTION_CONNECTED_STATES=t.set([t.ConnectionStateType.CONNECTED,t.ConnectionStateType.SILENT_MONITOR,t.ConnectionStateType.BARGE]),t.ContactStateType=t.makeEnum(["init","incoming","pending","connecting","connected","missed","error","ended"]),t.ContactStatusType=t.ContactStateType,t.CONTACT_ACTIVE_STATES=t.makeEnum(["incoming","pending","connecting","connected"]),t.ContactType=t.makeEnum(["voice","queue_callback","chat","task"]),t.ContactInitiationMethod=t.makeEnum(["inbound","outbound","transfer","queue_transfer","callback","api","disconnect"]),t.MonitoringMode=t.makeEnum(["SILENT_MONITOR","BARGE"]),t.MonitoringErrorTypes=t.makeEnum(["invalid_target_state"]),t.ChannelType=t.makeEnum(["VOICE","CHAT","TASK"]),t.MediaType=t.makeEnum(["softphone","chat","task"]),t.SoftphoneCallType=t.makeEnum(["audio_video","video_only","audio_only","none"]),t.SoftphoneErrorTypes=t.makeEnum(["unsupported_browser","microphone_not_shared","signalling_handshake_failure","signalling_connection_failure","ice_collection_timeout","user_busy_error","webrtc_error","realtime_communication_error","other"]),t.ClickType=t.makeEnum(["Accept","Reject","Hangup"]),t.VoiceIdErrorTypes=t.makeEnum(["no_speaker_id_found","speaker_id_not_enrolled","get_speaker_id_failed","get_speaker_status_failed","opt_out_speaker_failed","opt_out_speaker_in_lcms_failed","delete_speaker_failed","start_session_failed","evaluate_speaker_failed","session_not_exists","describe_session_failed","enroll_speaker_failed","update_speaker_id_failed","update_speaker_id_in_lcms_failed","not_supported_on_conference_calls","enroll_speaker_timeout","evaluate_speaker_timeout","get_domain_id_failed","no_domain_id_found"]),t.CTIExceptions=t.makeEnum(["AccessDeniedException","InvalidStateException","BadEndpointException","InvalidAgentARNException","InvalidConfigurationException","InvalidContactTypeException","PaginationException","RefreshTokenExpiredException","SendDataFailedException","UnauthorizedException","QuotaExceededException"]),t.VoiceIdStreamingStatus=t.makeEnum(["ONGOING","ENDED","PENDING_CONFIGURATION"]),t.VoiceIdAuthenticationDecision=t.makeEnum(["ACCEPT","REJECT","NOT_ENOUGH_SPEECH","SPEAKER_NOT_ENROLLED","SPEAKER_OPTED_OUT","SPEAKER_ID_NOT_PROVIDED","SPEAKER_EXPIRED"]),t.VoiceIdFraudDetectionDecision=t.makeEnum(["NOT_ENOUGH_SPEECH","HIGH_RISK","LOW_RISK"]),t.ContactFlowAuthenticationDecision=t.makeEnum(["Authenticated","NotAuthenticated","Inconclusive","NotEnrolled","OptedOut","NotEnabled","Error"]),t.ContactFlowFraudDetectionDecision=t.makeEnum(["HighRisk","LowRisk","Inconclusive","NotEnabled","Error"]),t.VoiceIdEnrollmentRequestStatus=t.makeEnum(["NOT_ENOUGH_SPEECH","IN_PROGRESS","COMPLETED","FAILED"]),t.VoiceIdSpeakerStatus=t.makeEnum(["OPTED_OUT","ENROLLED","PENDING"]),t.VoiceIdConstants={EVALUATE_SESSION_DELAY:1e4,EVALUATION_MAX_POLL_TIMES:24,EVALUATION_POLLING_INTERVAL:5e3,ENROLLMENT_MAX_POLL_TIMES:120,ENROLLMENT_POLLING_INTERVAL:5e3,START_SESSION_DELAY:8e3},t.AgentPermissions={OUTBOUND_CALL:"outboundCall",VOICE_ID:"voiceId"};var n=function(){if(!t.agent.initialized)throw new t.StateError("The agent is not yet initialized!")};n.prototype._getData=function(){return t.core.getAgentDataProvider().getAgentData()},n.prototype._createContactAPI=function(e){return new t.Contact(e.contactId)},n.prototype.onRefresh=function(e){t.core.getEventBus().subscribe(t.AgentEvents.REFRESH,e)},n.prototype.onRoutable=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ROUTABLE,e)},n.prototype.onNotRoutable=function(e){t.core.getEventBus().subscribe(t.AgentEvents.NOT_ROUTABLE,e)},n.prototype.onOffline=function(e){t.core.getEventBus().subscribe(t.AgentEvents.OFFLINE,e)},n.prototype.onError=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ERROR,e)},n.prototype.onSoftphoneError=function(e){t.core.getEventBus().subscribe(t.AgentEvents.SOFTPHONE_ERROR,e)},n.prototype.onWebSocketConnectionLost=function(e){t.core.getEventBus().subscribe(t.AgentEvents.WEBSOCKET_CONNECTION_LOST,e)},n.prototype.onWebSocketConnectionGained=function(e){t.core.getEventBus().subscribe(t.AgentEvents.WEBSOCKET_CONNECTION_GAINED,e)},n.prototype.onAfterCallWork=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ACW,e)},n.prototype.onStateChange=function(e){t.core.getEventBus().subscribe(t.AgentEvents.STATE_CHANGE,e)},n.prototype.onMuteToggle=function(e){t.core.getUpstream().onUpstream(t.AgentEvents.MUTE_TOGGLE,e)},n.prototype.onLocalMediaStreamCreated=function(e){t.core.getUpstream().onUpstream(t.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,e)},n.prototype.onSpeakerDeviceChanged=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,e)},n.prototype.onMicrophoneDeviceChanged=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,e)},n.prototype.onRingerDeviceChanged=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.RINGER_DEVICE_CHANGED,e)},n.prototype.mute=function(){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.MUTE,data:{mute:!0}})},n.prototype.unmute=function(){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.MUTE,data:{mute:!1}})},n.prototype.setSpeakerDevice=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SET_SPEAKER_DEVICE,data:{deviceId:e}})},n.prototype.setMicrophoneDevice=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SET_MICROPHONE_DEVICE,data:{deviceId:e}})},n.prototype.setRingerDevice=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SET_RINGER_DEVICE,data:{deviceId:e}})},n.prototype.getState=function(){return this._getData().snapshot.state},n.prototype.getNextState=function(){return this._getData().snapshot.nextState},n.prototype.getAvailabilityState=function(){return this._getData().snapshot.agentAvailabilityState},n.prototype.getStatus=n.prototype.getState,n.prototype.getStateDuration=function(){return t.now()-this._getData().snapshot.state.startTimestamp.getTime()+t.core.getSkew()},n.prototype.getStatusDuration=n.prototype.getStateDuration,n.prototype.getPermissions=function(){return this.getConfiguration().permissions},n.prototype.getContacts=function(e){var t=this;return this._getData().snapshot.contacts.map((function(e){return t._createContactAPI(e)})).filter((function(t){return!e||t.getType()===e}))},n.prototype.getConfiguration=function(){return this._getData().configuration},n.prototype.getAgentStates=function(){return this.getConfiguration().agentStates},n.prototype.getRoutingProfile=function(){return this.getConfiguration().routingProfile},n.prototype.getChannelConcurrency=function(e){var n=this.getRoutingProfile().channelConcurrencyMap;return n||(n=Object.keys(t.ChannelType).reduce((function(e,n){return"TASK"!==n&&(e[t.ChannelType[n]]=1),e}),{})),e?n[e]||0:n},n.prototype.getName=function(){return this.getConfiguration().name},n.prototype.getExtension=function(){return this.getConfiguration().extension},n.prototype.getDialableCountries=function(){return this.getConfiguration().dialableCountries},n.prototype.isSoftphoneEnabled=function(){return this.getConfiguration().softphoneEnabled},n.prototype.setConfiguration=function(e,n){var r=t.core.getClient();e&&e.agentPreferences&&e.agentPreferences.LANGUAGE&&!e.agentPreferences.locale&&(e.agentPreferences.locale=e.agentPreferences.LANGUAGE),e&&e.agentPreferences&&!t.isValidLocale(e.agentPreferences.locale)?n&&n.failure&&n.failure(t.AgentErrorStates.INVALID_LOCALE):r.call(t.ClientMethods.UPDATE_AGENT_CONFIGURATION,{configuration:t.assertNotNull(e,"configuration")},{success:function(e){t.core.getUpstream().sendUpstream(t.EventType.RELOAD_AGENT_CONFIGURATION),n.success&&n.success(e)},failure:n&&n.failure})},n.prototype.setState=function(e,n,r){t.core.getClient().call(t.ClientMethods.PUT_AGENT_STATE,{state:t.assertNotNull(e,"state"),enqueueNextState:r&&!!r.enqueueNextState},n)},n.prototype.onEnqueuedNextState=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ENQUEUED_NEXT_STATE,e)},n.prototype.setStatus=n.prototype.setState,n.prototype.connect=function(e,n){var r=t.core.getClient(),o=new t.Endpoint(e);delete o.endpointId,r.call(t.ClientMethods.CREATE_OUTBOUND_CONTACT,{endpoint:t.assertNotNull(o,"endpoint"),queueARN:n&&(n.queueARN||n.queueId)||this.getRoutingProfile().defaultOutboundQueue.queueARN},n&&{success:n.success,failure:n.failure})},n.prototype.getAllQueueARNs=function(){return this.getConfiguration().routingProfile.queues.map((function(e){return e.queueARN}))},n.prototype.getEndpoints=function(e,n,r){var o=this,i=t.core.getClient();t.assertNotNull(n,"callbacks"),t.assertNotNull(n.success,"callbacks.success");var s=r||{};s.endpoints=s.endpoints||[],s.maxResults=s.maxResults||t.DEFAULT_BATCH_SIZE,t.isArray(e)||(e=[e]),i.call(t.ClientMethods.GET_ENDPOINTS,{queueARNs:e,nextToken:s.nextToken||null,maxResults:s.maxResults},{success:function(r){if(r.nextToken)o.getEndpoints(e,n,{nextToken:r.nextToken,maxResults:s.maxResults,endpoints:s.endpoints.concat(r.endpoints)});else{s.endpoints=s.endpoints.concat(r.endpoints);var i=s.endpoints.map((function(e){return new t.Endpoint(e)}));n.success({endpoints:i,addresses:i})}},failure:n.failure})},n.prototype.getAddresses=n.prototype.getEndpoints,n.prototype._getResourceId=function(){var e=this.getAllQueueARNs();for(let t of e){const e=t.match(/\/agent\/([^/]+)/);if(e)return e[1]}return new Error("Agent.prototype._getResourceId: queueArns did not contain agentResourceId: ",e)},n.prototype.toSnapshot=function(){return new t.AgentSnapshot(this._getData())};var r=function(e){t.Agent.call(this),this.agentData=e};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype._getData=function(){return this.agentData},r.prototype._createContactAPI=function(e){return new t.ContactSnapshot(e)};var o=function(e){this.contactId=e};o.prototype._getData=function(){return t.core.getAgentDataProvider().getContactData(this.getContactId())},o.prototype._createConnectionAPI=function(e){return this.getType()===t.ContactType.CHAT?new t.ChatConnection(this.contactId,e.connectionId):this.getType()===t.ContactType.TASK?new t.TaskConnection(this.contactId,e.connectionId):new t.VoiceConnection(this.contactId,e.connectionId)},o.prototype.getEventName=function(e){return t.core.getContactEventName(e,this.getContactId())},o.prototype.onRefresh=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.REFRESH),e)},o.prototype.onIncoming=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.INCOMING),e)},o.prototype.onConnecting=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.CONNECTING),e)},o.prototype.onPending=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.PENDING),e)},o.prototype.onAccepted=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.ACCEPTED),e)},o.prototype.onMissed=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.MISSED),e)},o.prototype.onEnded=function(e){var n=t.core.getEventBus();n.subscribe(this.getEventName(t.ContactEvents.ENDED),e),n.subscribe(this.getEventName(t.ContactEvents.DESTROYED),e)},o.prototype.onDestroy=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.DESTROYED),e)},o.prototype.onACW=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.ACW),e)},o.prototype.onConnected=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.CONNECTED),e)},o.prototype.onError=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.ERROR),e)},o.prototype.getContactId=function(){return this.contactId},o.prototype.getOriginalContactId=function(){return this._getData().initialContactId},o.prototype.getInitialContactId=o.prototype.getOriginalContactId,o.prototype.getType=function(){return this._getData().type},o.prototype.getContactDuration=function(){return this._getData().contactDuration},o.prototype.getState=function(){return this._getData().state},o.prototype.getStatus=o.prototype.getState,o.prototype.getStateDuration=function(){return t.now()-this._getData().state.timestamp.getTime()+t.core.getSkew()},o.prototype.getStatusDuration=o.prototype.getStateDuration,o.prototype.getQueue=function(){return this._getData().queue},o.prototype.getQueueTimestamp=function(){return this._getData().queueTimestamp},o.prototype.getConnections=function(){var e=this;return this._getData().connections.map((function(n){return e.getType()===t.ContactType.CHAT?new t.ChatConnection(e.contactId,n.connectionId):e.getType()===t.ContactType.TASK?new t.TaskConnection(e.contactId,n.connectionId):new t.VoiceConnection(e.contactId,n.connectionId)}))},o.prototype.getInitialConnection=function(){return t.find(this.getConnections(),(function(e){return e.isInitialConnection()}))||null},o.prototype.getActiveInitialConnection=function(){var e=this.getInitialConnection();return null!=e&&e.isActive()?e:null},o.prototype.getThirdPartyConnections=function(){return this.getConnections().filter((function(e){return!e.isInitialConnection()&&e.getType()!==t.ConnectionType.AGENT}))},o.prototype.getSingleActiveThirdPartyConnection=function(){return this.getThirdPartyConnections().filter((function(e){return e.isActive()}))[0]||null},o.prototype.getAgentConnection=function(){return t.find(this.getConnections(),(function(e){var n=e.getType();return n===t.ConnectionType.AGENT||n===t.ConnectionType.MONITORING}))},o.prototype.getName=function(){return this._getData().name},o.prototype.getContactMetadata=function(){return this._getData().contactMetadata},o.prototype.getDescription=function(){return this._getData().description},o.prototype.getReferences=function(){return this._getData().references},o.prototype.getAttributes=function(){return this._getData().attributes},o.prototype.getContactFeatures=function(){return this._getData().contactFeatures},o.prototype.getChannelContext=function(){return this._getData().channelContext},o.prototype.isSoftphoneCall=function(){return null!=t.find(this.getConnections(),(function(e){return null!=e.getSoftphoneMediaInfo()}))},o.prototype._isInbound=function(){return this._getData().initiationMethod!==t.ContactInitiationMethod.OUTBOUND},o.prototype.isInbound=function(){var e=this.getInitialConnection();return e.getMediaType()===t.MediaType.TASK?this._isInbound():!!e&&e.getType()===t.ConnectionType.INBOUND},o.prototype.isConnected=function(){return this.getStatus().type===t.ContactStateType.CONNECTED},o.prototype.accept=function(e){var n=t.core.getClient(),r=this,o=this.getContactId();t.publishClickStreamData({contactId:this.getContactId(),clickType:t.ClickType.ACCEPT,clickTime:(new Date).toISOString()}),n.call(t.ClientMethods.ACCEPT_CONTACT,{contactId:o},{success:function(n){var i=t.core.getUpstream();i.sendUpstream(t.EventType.BROADCAST,{event:t.ContactEvents.ACCEPTED,data:new t.Contact(o)}),i.sendUpstream(t.EventType.BROADCAST,{event:t.core.getContactEventName(t.ContactEvents.ACCEPTED,r.getContactId()),data:new t.Contact(o)});var s=new t.Contact(o);t.isFirefoxBrowser()&&s.isSoftphoneCall()&&t.core.triggerReadyToStartSessionEvent(),e&&e.success&&e.success(n)},failure:e?e.failure:null})},o.prototype.destroy=function(){t.getLog().warn("contact.destroy() has been deprecated.")},o.prototype.reject=function(e){var n=t.core.getClient();t.publishClickStreamData({contactId:this.getContactId(),clickType:t.ClickType.REJECT,clickTime:(new Date).toISOString()}),n.call(t.ClientMethods.REJECT_CONTACT,{contactId:this.getContactId()},e)},o.prototype.complete=function(e){t.core.getClient().call(t.ClientMethods.COMPLETE_CONTACT,{contactId:this.getContactId()},e)},o.prototype.clear=function(e){t.core.getClient().call(t.ClientMethods.CLEAR_CONTACT,{contactId:this.getContactId()},e)},o.prototype.notifyIssue=function(e,n,r){t.core.getClient().call(t.ClientMethods.NOTIFY_CONTACT_ISSUE,{contactId:this.getContactId(),issueCode:e,description:n},r)},o.prototype.addConnection=function(e,n){var r=t.core.getClient(),o=new t.Endpoint(e);delete o.endpointId,r.call(t.ClientMethods.CREATE_ADDITIONAL_CONNECTION,{contactId:this.getContactId(),endpoint:o},n)},o.prototype.toggleActiveConnections=function(e){var n=t.core.getClient(),r=null,o=t.find(this.getConnections(),(function(e){return e.getStatus().type===t.ConnectionStateType.HOLD}));if(null!=o)r=o.getConnectionId();else{var i=this.getConnections().filter((function(e){return e.isActive()}));i.length>0&&(r=i[0].getConnectionId())}n.call(t.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:r},e)},o.prototype.sendSoftphoneMetrics=function(n,r){t.core.getClient().call(t.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:e.ccpVersion,softphoneStreamStatistics:n},r),t.publishSoftphoneStats({contactId:this.getContactId(),ccpVersion:e.ccpVersion,stats:n})},o.prototype.sendSoftphoneReport=function(n,r){t.core.getClient().call(t.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:e.ccpVersion,report:n},r),t.publishSoftphoneReport({contactId:this.getContactId(),ccpVersion:e.ccpVersion,report:n})},o.prototype.conferenceConnections=function(e){t.core.getClient().call(t.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},o.prototype.toSnapshot=function(){return new t.ContactSnapshot(this._getData())},o.prototype.isMultiPartyConferenceEnabled=function(){var e=this.getContactFeatures();return!(!e||!e.multiPartyConferenceEnabled)},o.prototype.updateMonitorParticipantState=function(e,n){e&&Object.values(t.MonitoringMode).includes(e.toUpperCase())?t.core.getClient().call(t.ClientMethods.UPDATE_MONITOR_PARTICIPANT_STATE,{contactId:this.getContactId(),targetMonitorMode:e.toUpperCase()},n):(t.getLog().error(`Invalid target state was provided: ${e}`).sendInternalLogToServer(),n&&n.failure&&n.failure(t.MonitoringErrorTypes.INVALID_TARGET_STATE))},o.prototype.isUnderSupervision=function(){var e=this.getConnections().filter((e=>e.getType()!==t.ConnectionType.AGENT));return void 0!==(e&&e.find((e=>e.isBarge()&&e.isActive())))};var i=function(e){t.Contact.call(this,e.contactId),this.contactData=e};(i.prototype=Object.create(o.prototype)).constructor=i,i.prototype._getData=function(){return this.contactData},i.prototype._createConnectionAPI=function(e){return new t.ConnectionSnapshot(e)};var s=function(e,t){this.contactId=e,this.connectionId=t,this._initMediaController()};s.prototype._getData=function(){return t.core.getAgentDataProvider().getConnectionData(this.getContactId(),this.getConnectionId())},s.prototype.getContactId=function(){return this.contactId},s.prototype.getConnectionId=function(){return this.connectionId},s.prototype.getEndpoint=function(){return new t.Endpoint(this._getData().endpoint)},s.prototype.getAddress=s.prototype.getEndpoint,s.prototype.getState=function(){return this._getData().state},s.prototype.getStatus=s.prototype.getState,s.prototype.getStateDuration=function(){return t.now()-this._getData().state.timestamp.getTime()+t.core.getSkew()},s.prototype.getStatusDuration=s.prototype.getStateDuration,s.prototype.getType=function(){return this._getData().type},s.prototype.isInitialConnection=function(){return this._getData().initial},s.prototype.isActive=function(){return t.contains(t.CONNECTION_ACTIVE_STATES,this.getStatus().type)},s.prototype.isConnected=function(){return t.contains(t.CONNECTION_CONNECTED_STATES,this.getStatus().type)},s.prototype.isConnecting=function(){return this.getStatus().type===t.ConnectionStateType.CONNECTING},s.prototype.isOnHold=function(){return this.getStatus().type===t.ConnectionStateType.HOLD},s.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMonitorInfo=function(){return this._getData().monitoringInfo},s.prototype.destroy=function(e){t.publishClickStreamData({contactId:this.getContactId(),clickType:t.ClickType.HANGUP,clickTime:(new Date).toISOString()}),t.core.getClient().call(t.ClientMethods.DESTROY_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.sendDigits=function(e,n){t.core.getClient().call(t.ClientMethods.SEND_DIGITS,{contactId:this.getContactId(),connectionId:this.getConnectionId(),digits:e},n)},s.prototype.hold=function(e){t.core.getClient().call(t.ClientMethods.HOLD_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.resume=function(e){t.core.getClient().call(t.ClientMethods.RESUME_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.toSnapshot=function(){return new t.ConnectionSnapshot(this._getData())},s.prototype._initMediaController=function(){this.getMediaInfo()&&t.core.mediaFactory.get(this).catch((function(){}))},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===t.ConnectionType.AGENT||e===t.ConnectionType.MONITORING},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===t.ConnectionType.AGENT||e===t.ConnectionType.MONITORING};var a=function(e){this.contactId=e};a.prototype.getSpeakerId=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){const i={contactId:e.contactId,instanceId:t.core.getAgentDataProvider().getInstanceId(),awsAccountId:t.core.getAgentDataProvider().getAWSAccountId()};t.getLog().info("getSpeakerId called").withObject(i).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.GET_CONTACT,i,{success:function(e){if(e.contactData.customerId){var n={speakerId:e.contactData.customerId};t.getLog().info("getSpeakerId succeeded").withObject(e).sendInternalLogToServer(),r(n)}else{var i=t.VoiceIdError(t.VoiceIdErrorTypes.NO_SPEAKER_ID_FOUND,"No speakerId assotiated with this call");o(i)}},failure:function(e){t.getLog().error("Get SpeakerId failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.GET_SPEAKER_ID_FAILED,"Get SpeakerId failed",e);o(n)}})}))},a.prototype.getSpeakerStatus=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getSpeakerId().then((function(i){e.getDomainId().then((function(e){const s={SpeakerId:t.assertNotNull(i.speakerId,"speakerId"),DomainId:e};t.getLog().info("getSpeakerStatus called").withObject(s).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.DESCRIBE_SPEAKER,s,{success:function(e){t.getLog().info("getSpeakerStatus succeeded").withObject(e).sendInternalLogToServer(),r(e)},failure:function(e){var n=JSON.parse(e);switch(n.status){case 400:case 404:var i=n;i.type=i.type?i.type:t.VoiceIdErrorTypes.SPEAKER_ID_NOT_ENROLLED,t.getLog().info("Speaker is not enrolled.").sendInternalLogToServer(),r(i);break;default:t.getLog().error("getSpeakerStatus failed").withObject({err:e}).sendInternalLogToServer();var s=t.VoiceIdError(t.VoiceIdErrorTypes.GET_SPEAKER_STATUS_FAILED,"Get SpeakerStatus failed",e);o(s)}}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},a.prototype._optOutSpeakerInLcms=function(e,n){var r=this,o=t.core.getClient();return new Promise((function(i,s){const a={ContactId:r.contactId,InstanceId:t.core.getAgentDataProvider().getInstanceId(),AWSAccountId:t.core.getAgentDataProvider().getAWSAccountId(),CustomerId:t.assertNotNull(e,"speakerId"),VoiceIdResult:{SpeakerOptedOut:!0,generatedSpeakerId:n}};t.getLog().info("_optOutSpeakerInLcms called").withObject(a).sendInternalLogToServer(),o.call(t.AgentAppClientMethods.UPDATE_VOICE_ID_DATA,a,{success:function(e){t.getLog().info("optOutSpeakerInLcms succeeded").withObject(e).sendInternalLogToServer(),i(e)},failure:function(e){t.getLog().error("optOutSpeakerInLcms failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.OPT_OUT_SPEAKER_IN_LCMS_FAILED,"optOutSpeakerInLcms failed",e);s(n)}})}))},a.prototype.optOutSpeaker=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getSpeakerId().then((function(i){e.getDomainId().then((function(s){var a=i.speakerId;const c={SpeakerId:t.assertNotNull(a,"speakerId"),DomainId:s};t.getLog().info("optOutSpeaker called").withObject(c).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.OPT_OUT_SPEAKER,c,{success:function(n){e._optOutSpeakerInLcms(a,n.generatedSpeakerId).catch((function(){})),t.getLog().info("optOutSpeaker succeeded").withObject(n).sendInternalLogToServer(),r(n)},failure:function(e){t.getLog().error("optOutSpeaker failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.OPT_OUT_SPEAKER_FAILED,"optOutSpeaker failed.",e);o(n)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},a.prototype.deleteSpeaker=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getSpeakerId().then((function(i){e.getDomainId().then((function(e){const s={SpeakerId:t.assertNotNull(i.speakerId,"speakerId"),DomainId:e};t.getLog().info("deleteSpeaker called").withObject(s).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.DELETE_SPEAKER,s,{success:function(e){t.getLog().info("deleteSpeaker succeeded").withObject(e).sendInternalLogToServer(),r(e)},failure:function(e){t.getLog().error("deleteSpeaker failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.DELETE_SPEAKER_FAILED,"deleteSpeaker failed.",e);o(n)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},a.prototype.startSession=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getDomainId().then((function(i){const s={contactId:e.contactId,instanceId:t.core.getAgentDataProvider().getInstanceId(),customerAccountId:t.core.getAgentDataProvider().getAWSAccountId(),clientToken:AWS.util.uuid.v4(),domainId:i};t.getLog().info("startSession called").withObject(s).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.START_VOICE_ID_SESSION,s,{success:function(e){if(e.sessionId)r(e);else{t.getLog().error("startVoiceIdSession failed, no session id returned").withObject({data:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.START_SESSION_FAILED,"No session id returned from start session api");o(n)}},failure:function(e){t.getLog().error("startVoiceIdSession failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.START_SESSION_FAILED,"startVoiceIdSession failed",e);o(n)}})})).catch((function(e){o(e)}))}))},a.prototype.evaluateSpeaker=function(e){var n=this;n.checkConferenceCall();var r=t.core.getClient(),o=t.core.getAgentDataProvider().getContactData(this.contactId),i=0;return new Promise((function(s,a){function c(){n.getDomainId().then((function(e){const u={SessionNameOrId:o.initialContactId||this.contactId,DomainId:e};t.getLog().info("evaluateSpeaker called").withObject(u).sendInternalLogToServer(),r.call(t.AgentAppClientMethods.EVALUATE_SESSION,u,{success:function(e){if(++i=1&&(o=r.IntegrationAssociationSummaryList[0].IntegrationArn.replace(/^.*domain\//i,"")),!o){t.getLog().info("getDomainId: no domainId found").sendInternalLogToServer();var i=t.VoiceIdError(t.VoiceIdErrorTypes.NO_DOMAIN_ID_FOUND);return void n(i)}t.getLog().info("getDomainId succeeded").withObject(r).sendInternalLogToServer(),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.VoiceIdEvents.UPDATE_DOMAIN_ID,data:{domainId:o}}),e(o)}catch(e){t.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer(),i=t.VoiceIdError(t.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e),n(i)}},failure:function(e){t.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer();var r=t.VoiceIdError(t.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e);n(r)}})}else n(new Error("Agent doesn't have the permission for Voice ID"))}))},a.prototype.checkConferenceCall=function(){if(t.core.getAgentDataProvider().getContactData(this.contactId).connections.filter((function(e){return t.contains(t.CONNECTION_ACTIVE_STATES,e.state.type)})).length>2)throw new t.NotImplementedError("VoiceId is not supported for conference calls")},a.prototype.isAuthEnabled=function(e){return e!==t.ContactFlowAuthenticationDecision.NOT_ENABLED},a.prototype.isAuthResultNotEnoughSpeech=function(e){return e===t.VoiceIdAuthenticationDecision.NOT_ENOUGH_SPEECH},a.prototype.isAuthResultInconclusive=function(e){return e===t.ContactFlowAuthenticationDecision.INCONCLUSIVE},a.prototype.isFraudEnabled=function(e){return e!==t.ContactFlowFraudDetectionDecision.NOT_ENABLED},a.prototype.isFraudResultNotEnoughSpeech=function(e){return e===t.VoiceIdFraudDetectionDecision.NOT_ENOUGH_SPEECH},a.prototype.isFraudResultInconclusive=function(e){return e===t.ContactFlowFraudDetectionDecision.INCONCLUSIVE};var c=function(e,t){this._speakerAuthenticator=new a(e),s.call(this,e,t)};(c.prototype=Object.create(s.prototype)).constructor=c,c.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},c.prototype.getMediaInfo=function(){return this._getData().softphoneMediaInfo},c.prototype.getMediaType=function(){return t.MediaType.SOFTPHONE},c.prototype.getMediaController=function(){return t.core.mediaFactory.get(this)},c.prototype.getVoiceIdSpeakerId=function(){return this._speakerAuthenticator.getSpeakerId()},c.prototype.getVoiceIdSpeakerStatus=function(){return this._speakerAuthenticator.getSpeakerStatus()},c.prototype.optOutVoiceIdSpeaker=function(){return this._speakerAuthenticator.optOutSpeaker()},c.prototype.deleteVoiceIdSpeaker=function(){return this._speakerAuthenticator.deleteSpeaker()},c.prototype.evaluateSpeakerWithVoiceId=function(e){return this._speakerAuthenticator.evaluateSpeaker(e)},c.prototype.enrollSpeakerInVoiceId=function(e){return this._speakerAuthenticator.enrollSpeaker(e)},c.prototype.updateVoiceIdSpeakerId=function(e){return this._speakerAuthenticator.updateSpeakerIdInVoiceId(e)},c.prototype.getQuickConnectName=function(){return this._getData().quickConnectName},c.prototype.isSilentMonitor=function(){return this.getMonitorStatus()===t.MonitoringMode.SILENT_MONITOR},c.prototype.isBarge=function(){return this.getMonitorStatus()===t.MonitoringMode.BARGE},c.prototype.isBargeEnabled=function(){var e=this.getMonitorCapabilities();return e&&e.includes(t.MonitoringMode.BARGE)},c.prototype.isSilentMonitorEnabled=function(){var e=this.getMonitorCapabilities();return e&&e.includes(t.MonitoringMode.SILENT_MONITOR)},c.prototype.getMonitorCapabilities=function(){return this._getData().monitorCapabilities},c.prototype.getMonitorStatus=function(){return this._getData().monitorStatus},c.prototype.isMute=function(){return this._getData().mute},c.prototype.isForcedMute=function(){return this._getData().forcedMute},c.prototype.muteParticipant=function(e){t.core.getClient().call(t.ClientMethods.MUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},c.prototype.unmuteParticipant=function(e){t.core.getClient().call(t.ClientMethods.UNMUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)};var u=function(e,t){s.call(this,e,t)};(u.prototype=Object.create(s.prototype)).constructor=u,u.prototype.getMediaInfo=function(){var e=this._getData().chatMediaInfo;if(e){var n=t.core.getAgentDataProvider().getContactData(this.contactId),r={contactId:this.contactId,initialContactId:n.initialContactId||this.contactId,participantId:this.connectionId,getConnectionToken:t.hitch(this,this.getConnectionToken)};if(e.connectionData)try{r.participantToken=JSON.parse(e.connectionData).ConnectionAuthenticationToken}catch(n){t.getLog().error(t.LogComponent.CHAT,"Connection data is invalid").withObject(e).withException(n).sendInternalLogToServer(),r.participantToken=null}return r.participantToken=r.participantToken||null,r.originalInfo=this._getData().chatMediaInfo,r}return null},u.prototype.getConnectionToken=function(){var e=t.core.getClient(),n=t.core.getAgentDataProvider().getContactData(this.contactId),r={transportType:t.TRANSPORT_TYPES.CHAT_TOKEN,participantId:this.connectionId,contactId:n.initialContactId||this.contactId};return new Promise((function(n,o){e.call(t.ClientMethods.CREATE_TRANSPORT,r,{success:function(e){t.getLog().info("getConnectionToken succeeded").sendInternalLogToServer(),n(e)},failure:function(e,n){t.getLog().error("getConnectionToken failed").sendInternalLogToServer().withObject({err:e,data:n}),o(Error("getConnectionToken failed"))}})}))},u.prototype.getMediaType=function(){return t.MediaType.CHAT},u.prototype.getMediaController=function(){return t.core.mediaFactory.get(this)},u.prototype._initMediaController=function(){this._isAgentConnectionType()&&t.core.mediaFactory.get(this).catch((function(){}))};var l=function(e,t){s.call(this,e,t)};(l.prototype=Object.create(s.prototype)).constructor=l,l.prototype.getMediaType=function(){return t.MediaType.TASK},l.prototype.getMediaInfo=function(){var e=t.core.getAgentDataProvider().getContactData(this.contactId);return{contactId:this.contactId,initialContactId:e.initialContactId||this.contactId}},l.prototype.getMediaController=function(){return t.core.mediaFactory.get(this)};var p=function(e){t.Connection.call(this,e.contactId,e.connectionId),this.connectionData=e};(p.prototype=Object.create(s.prototype)).constructor=p,p.prototype._getData=function(){return this.connectionData},p.prototype._initMediaController=function(){};var d=function(e){var t=e||{};this.endpointARN=t.endpointId||t.endpointARN||null,this.endpointId=this.endpointARN,this.type=t.type||null,this.name=t.name||null,this.phoneNumber=t.phoneNumber||null,this.agentLogin=t.agentLogin||null,this.queue=t.queue||null};d.prototype.stripPhoneNumber=function(){return this.phoneNumber?this.phoneNumber.replace(/sip:([^@]*)@.*/,"$1"):""},d.byPhoneNumber=function(e,n){return new d({type:t.EndpointType.PHONE_NUMBER,phoneNumber:e,name:n||null})};var h=function(e,t,n){this.errorType=e,this.errorMessage=t,this.endPointUrl=n};h.prototype.getErrorType=function(){return this.errorType},h.prototype.getErrorMessage=function(){return this.errorMessage},h.prototype.getEndPointUrl=function(){return this.endPointUrl},t.agent=function(e){var n=t.core.getEventBus().subscribe(t.AgentEvents.INIT,e);return t.agent.initialized&&e(new t.Agent),n},t.agent.initialized=!1,t.contact=function(e){return t.core.getEventBus().subscribe(t.ContactEvents.INIT,e)},t.onWebsocketInitFailure=function(e){var n=t.core.getEventBus().subscribe(t.WebSocketEvents.INIT_FAILURE,e);return t.webSocketInitFailed&&e(),n},t.ifMaster=function(e,n,r,o){if(t.assertNotNull(e,"A topic must be provided."),t.assertNotNull(n,"A true callback must be provided."),!t.core.masterClient)return t.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e).sendInternalLogToServer(),void(r&&r());t.core.getMasterClient().call(t.MasterMethods.CHECK_MASTER,{topic:e,shouldNotBecomeMasterIfNone:o},{success:function(e){e.isMaster?n():r&&r()}})},t.becomeMaster=function(e,n,r){t.assertNotNull(e,"A topic must be provided."),t.core.masterClient?t.core.getMasterClient().call(t.MasterMethods.BECOME_MASTER,{topic:e},{success:function(){n&&n()}}):(t.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e),r&&r())},t.Agent=n,t.AgentSnapshot=r,t.Contact=o,t.ContactSnapshot=i,t.Connection=c,t.BaseConnection=s,t.VoiceConnection=c,t.ChatConnection=u,t.TaskConnection=l,t.ConnectionSnapshot=p,t.Endpoint=d,t.Address=d,t.SoftphoneError=h,t.VoiceId=a}()},827:(e,t,n)=>{var r;!function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return o(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var i=void 0,s=0;s-1});var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]","[object DataView]"];t.exports={isEmptyData:function(e){return"string"==typeof e?0===e.length:0===e.byteLength},convertToBuffer:function(e){return"string"==typeof e&&(e=new r(e,"utf8")),ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}}},{"buffer/":85}],12:[function(e,t,n){var r=e("./browserHashUtils");function o(e,t){this.hash=new e,this.outer=new e;var n=function(e,t){var n=r.convertToBuffer(t);if(n.byteLength>e.BLOCK_SIZE){var o=new e;o.update(n),n=o.digest()}var i=new Uint8Array(e.BLOCK_SIZE);return i.set(n),i}(e,t),o=new Uint8Array(e.BLOCK_SIZE);o.set(n);for(var i=0;i>>32-o)+n&4294967295}function c(e,t,n,r,o,i,s){return a(t&n|~t&r,e,t,o,i,s)}function u(e,t,n,r,o,i,s){return a(t&r|n&~r,e,t,o,i,s)}function l(e,t,n,r,o,i,s){return a(t^n^r,e,t,o,i,s)}function p(e,t,n,r,o,i,s){return a(n^(t|~r),e,t,o,i,s)}t.exports=s,s.BLOCK_SIZE=i,s.prototype.update=function(e){if(r.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=r.convertToBuffer(e),n=0,o=t.byteLength;for(this.bytesHashed+=o;o>0;)this.buffer.setUint8(this.bufferLength++,t[n++]),o--,this.bufferLength===i&&(this.hashBuffer(),this.bufferLength=0);return this},s.prototype.digest=function(e){if(!this.finished){var t=this,n=t.buffer,r=t.bufferLength,s=8*t.bytesHashed;if(n.setUint8(this.bufferLength++,128),r%i>=56){for(var a=this.bufferLength;a>>0,!0),n.setUint32(60,Math.floor(s/4294967296),!0),this.hashBuffer(),this.finished=!0}var c=new DataView(new ArrayBuffer(16));for(a=0;a<4;a++)c.setUint32(4*a,this.state[a],!0);var u=new o(c.buffer,c.byteOffset,c.byteLength);return e?u.toString(e):u},s.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=t[0],r=t[1],o=t[2],i=t[3];n=c(n,r,o,i,e.getUint32(0,!0),7,3614090360),i=c(i,n,r,o,e.getUint32(4,!0),12,3905402710),o=c(o,i,n,r,e.getUint32(8,!0),17,606105819),r=c(r,o,i,n,e.getUint32(12,!0),22,3250441966),n=c(n,r,o,i,e.getUint32(16,!0),7,4118548399),i=c(i,n,r,o,e.getUint32(20,!0),12,1200080426),o=c(o,i,n,r,e.getUint32(24,!0),17,2821735955),r=c(r,o,i,n,e.getUint32(28,!0),22,4249261313),n=c(n,r,o,i,e.getUint32(32,!0),7,1770035416),i=c(i,n,r,o,e.getUint32(36,!0),12,2336552879),o=c(o,i,n,r,e.getUint32(40,!0),17,4294925233),r=c(r,o,i,n,e.getUint32(44,!0),22,2304563134),n=c(n,r,o,i,e.getUint32(48,!0),7,1804603682),i=c(i,n,r,o,e.getUint32(52,!0),12,4254626195),o=c(o,i,n,r,e.getUint32(56,!0),17,2792965006),n=u(n,r=c(r,o,i,n,e.getUint32(60,!0),22,1236535329),o,i,e.getUint32(4,!0),5,4129170786),i=u(i,n,r,o,e.getUint32(24,!0),9,3225465664),o=u(o,i,n,r,e.getUint32(44,!0),14,643717713),r=u(r,o,i,n,e.getUint32(0,!0),20,3921069994),n=u(n,r,o,i,e.getUint32(20,!0),5,3593408605),i=u(i,n,r,o,e.getUint32(40,!0),9,38016083),o=u(o,i,n,r,e.getUint32(60,!0),14,3634488961),r=u(r,o,i,n,e.getUint32(16,!0),20,3889429448),n=u(n,r,o,i,e.getUint32(36,!0),5,568446438),i=u(i,n,r,o,e.getUint32(56,!0),9,3275163606),o=u(o,i,n,r,e.getUint32(12,!0),14,4107603335),r=u(r,o,i,n,e.getUint32(32,!0),20,1163531501),n=u(n,r,o,i,e.getUint32(52,!0),5,2850285829),i=u(i,n,r,o,e.getUint32(8,!0),9,4243563512),o=u(o,i,n,r,e.getUint32(28,!0),14,1735328473),n=l(n,r=u(r,o,i,n,e.getUint32(48,!0),20,2368359562),o,i,e.getUint32(20,!0),4,4294588738),i=l(i,n,r,o,e.getUint32(32,!0),11,2272392833),o=l(o,i,n,r,e.getUint32(44,!0),16,1839030562),r=l(r,o,i,n,e.getUint32(56,!0),23,4259657740),n=l(n,r,o,i,e.getUint32(4,!0),4,2763975236),i=l(i,n,r,o,e.getUint32(16,!0),11,1272893353),o=l(o,i,n,r,e.getUint32(28,!0),16,4139469664),r=l(r,o,i,n,e.getUint32(40,!0),23,3200236656),n=l(n,r,o,i,e.getUint32(52,!0),4,681279174),i=l(i,n,r,o,e.getUint32(0,!0),11,3936430074),o=l(o,i,n,r,e.getUint32(12,!0),16,3572445317),r=l(r,o,i,n,e.getUint32(24,!0),23,76029189),n=l(n,r,o,i,e.getUint32(36,!0),4,3654602809),i=l(i,n,r,o,e.getUint32(48,!0),11,3873151461),o=l(o,i,n,r,e.getUint32(60,!0),16,530742520),n=p(n,r=l(r,o,i,n,e.getUint32(8,!0),23,3299628645),o,i,e.getUint32(0,!0),6,4096336452),i=p(i,n,r,o,e.getUint32(28,!0),10,1126891415),o=p(o,i,n,r,e.getUint32(56,!0),15,2878612391),r=p(r,o,i,n,e.getUint32(20,!0),21,4237533241),n=p(n,r,o,i,e.getUint32(48,!0),6,1700485571),i=p(i,n,r,o,e.getUint32(12,!0),10,2399980690),o=p(o,i,n,r,e.getUint32(40,!0),15,4293915773),r=p(r,o,i,n,e.getUint32(4,!0),21,2240044497),n=p(n,r,o,i,e.getUint32(32,!0),6,1873313359),i=p(i,n,r,o,e.getUint32(60,!0),10,4264355552),o=p(o,i,n,r,e.getUint32(24,!0),15,2734768916),r=p(r,o,i,n,e.getUint32(52,!0),21,1309151649),n=p(n,r,o,i,e.getUint32(16,!0),6,4149444226),i=p(i,n,r,o,e.getUint32(44,!0),10,3174756917),o=p(o,i,n,r,e.getUint32(8,!0),15,718787259),r=p(r,o,i,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=r+t[1]&4294967295,t[2]=o+t[2]&4294967295,t[3]=i+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":85}],14:[function(e,t,n){var r=e("buffer/").Buffer,o=e("./browserHashUtils");function i(){this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=new Uint32Array(80),this.offset=0,this.shift=24,this.totalLength=0}new Uint32Array([1518500249,1859775393,-1894007588,-899497514]),Math.pow(2,53),t.exports=i,i.BLOCK_SIZE=64,i.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=(e=o.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n14||14===this.offset&&this.shift<24)&&this.processBlock(),this.offset=14,this.shift=24,this.write(0),this.write(0),this.write(this.totalLength>0xffffffffff?this.totalLength/1099511627776:0),this.write(this.totalLength>4294967295?this.totalLength/4294967296:0);for(var t=24;t>=0;t-=8)this.write(this.totalLength>>t);var n=new r(20),o=new DataView(n.buffer);return o.setUint32(0,this.h0,!1),o.setUint32(4,this.h1,!1),o.setUint32(8,this.h2,!1),o.setUint32(12,this.h3,!1),o.setUint32(16,this.h4,!1),e?n.toString(e):n},i.prototype.processBlock=function(){for(var e=16;e<80;e++){var t=this.block[e-3]^this.block[e-8]^this.block[e-14]^this.block[e-16];this.block[e]=t<<1|t>>>31}var n,r,o=this.h0,i=this.h1,s=this.h2,a=this.h3,c=this.h4;for(e=0;e<80;e++){e<20?(n=a^i&(s^a),r=1518500249):e<40?(n=i^s^a,r=1859775393):e<60?(n=i&s|a&(i|s),r=2400959708):(n=i^s^a,r=3395469782);var u=(o<<5|o>>>27)+n+c+r+(0|this.block[e]);c=a,a=s,s=i<<30|i>>>2,i=o,o=u}for(this.h0=this.h0+o|0,this.h1=this.h1+i|0,this.h2=this.h2+s|0,this.h3=this.h3+a|0,this.h4=this.h4+c|0,this.offset=0,e=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":85}],15:[function(e,t,n){var r=e("buffer/").Buffer,o=e("./browserHashUtils"),i=64,s=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=Math.pow(2,53)-1;function c(){this.state=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}t.exports=c,c.BLOCK_SIZE=i,c.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=0,n=(e=o.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>a)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;n>0;)this.buffer[this.bufferLength++]=e[t++],n--,this.bufferLength===i&&(this.hashBuffer(),this.bufferLength=0);return this},c.prototype.digest=function(e){if(!this.finished){var t=8*this.bytesHashed,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),o=this.bufferLength;if(n.setUint8(this.bufferLength++,128),o%i>=56){for(var s=this.bufferLength;s>>24&255,a[4*s+1]=this.state[s]>>>16&255,a[4*s+2]=this.state[s]>>>8&255,a[4*s+3]=this.state[s]>>>0&255;return e?a.toString(e):a},c.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],r=t[1],o=t[2],a=t[3],c=t[4],u=t[5],l=t[6],p=t[7],d=0;d>>17|h<<15)^(h>>>19|h<<13)^h>>>10,g=((h=this.temp[d-15])>>>7|h<<25)^(h>>>18|h<<14)^h>>>3;this.temp[d]=(f+this.temp[d-7]|0)+(g+this.temp[d-16]|0)}var m=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&u^~c&l)|0)+(p+(s[d]+this.temp[d]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&r^n&o^r&o)|0;p=l,l=u,u=c,c=a+m|0,a=o,o=r,r=n,n=m+v|0}t[0]+=n,t[1]+=r,t[2]+=o,t[3]+=a,t[4]+=c,t[5]+=u,t[6]+=l,t[7]+=p}},{"./browserHashUtils":11,"buffer/":85}],16:[function(e,t,n){(function(n){(function(){var n=e("./util");n.crypto.lib=e("./browserCryptoLib"),n.Buffer=e("buffer/").Buffer,n.url=e("url/"),n.querystring=e("querystring/"),n.realClock=e("./realclock/browserClock"),n.environment="js",n.createEventStream=e("./event-stream/buffered-create-event-stream").createEventStream,n.isBrowser=function(){return!0},n.isNode=function(){return!1};var r=e("./core");if(t.exports=r,e("./credentials"),e("./credentials/credential_provider_chain"),e("./credentials/temporary_credentials"),e("./credentials/chainable_temporary_credentials"),e("./credentials/web_identity_credentials"),e("./credentials/cognito_identity_credentials"),e("./credentials/saml_credentials"),r.XML.Parser=e("./xml/browser_parser"),e("./http/xhr"),void 0===o)var o={browser:!0}}).call(this)}).call(this,e("_process"))},{"./browserCryptoLib":10,"./core":19,"./credentials":20,"./credentials/chainable_temporary_credentials":21,"./credentials/cognito_identity_credentials":22,"./credentials/credential_provider_chain":23,"./credentials/saml_credentials":24,"./credentials/temporary_credentials":25,"./credentials/web_identity_credentials":26,"./event-stream/buffered-create-event-stream":28,"./http/xhr":36,"./realclock/browserClock":53,"./util":72,"./xml/browser_parser":73,_process:90,"buffer/":85,"querystring/":96,"url/":98}],17:[function(e,t,n){var r,o=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),o.Config=o.util.inherit({constructor:function(e){void 0===e&&(e={}),e=this.extractCredentials(e),o.util.each.call(this,this.keys,(function(t,n){this.set(t,e[t],n)}))},getCredentials:function(e){var t,n=this;function r(t){e(t,t?null:n.credentials)}function i(e,t){return new o.util.error(t||new Error,{code:"CredentialsError",message:e,name:"CredentialsError"})}n.credentials?"function"==typeof n.credentials.get?n.credentials.get((function(e){e&&(e=i("Could not load credentials from "+n.credentials.constructor.name,e)),r(e)})):(t=null,n.credentials.accessKeyId&&n.credentials.secretAccessKey||(t=i("Missing credentials")),r(t)):n.credentialProvider?n.credentialProvider.resolve((function(e,t){e&&(e=i("Could not load credentials from any providers",e)),n.credentials=t,r(e)})):r(i("No credentials to load"))},update:function(e,t){t=t||!1,e=this.extractCredentials(e),o.util.each.call(this,e,(function(e,n){(t||Object.prototype.hasOwnProperty.call(this.keys,e)||o.Service.hasService(e))&&this.set(e,n)}))},loadFromPath:function(e){this.clear();var t=JSON.parse(o.util.readFileSync(e)),n=new o.FileSystemCredentials(e),r=new o.CredentialProviderChain;return r.providers.unshift(n),r.resolve((function(e,n){if(e)throw e;t.credentials=n})),this.constructor(t),this},clear:function(){o.util.each.call(this,this.keys,(function(e){delete this[e]})),this.set("credentials",void 0),this.set("credentialProvider",void 0)},set:function(e,t,n){void 0===t?(void 0===n&&(n=this.keys[e]),this[e]="function"==typeof n?n.call(this):n):"httpOptions"===e&&this[e]?this[e]=o.util.merge(this[e],t):this[e]=t},keys:{credentials:null,credentialProvider:null,region:null,logger:null,apiVersions:{},apiVersion:null,endpoint:void 0,httpOptions:{timeout:12e4},maxRetries:void 0,maxRedirects:10,paramValidation:!0,sslEnabled:!0,s3ForcePathStyle:!1,s3BucketEndpoint:!1,s3DisableBodySigning:!0,s3UsEast1RegionalEndpoint:"legacy",s3UseArnRegion:void 0,computeChecksums:!0,convertResponseTypes:!0,correctClockSkew:!1,customUserAgent:null,dynamoDbCrc32:!0,systemClockOffset:0,signatureVersion:null,signatureCache:!0,retryDelayOptions:{},useAccelerateEndpoint:!1,clientSideMonitoring:!1,endpointDiscoveryEnabled:void 0,endpointCacheSize:1e3,hostPrefixEnabled:!0,stsRegionalEndpoints:"legacy",useFipsEndpoint:!1,useDualstackEndpoint:!1},extractCredentials:function(e){return e.accessKeyId&&e.secretAccessKey&&((e=o.util.copy(e)).credentials=new o.Credentials(e)),e},setPromisesDependency:function(e){r=e,null===e&&"function"==typeof Promise&&(r=Promise);var t=[o.Request,o.Credentials,o.CredentialProviderChain];o.S3&&(t.push(o.S3),o.S3.ManagedUpload&&t.push(o.S3.ManagedUpload)),o.util.addPromises(t,r)},getPromisesDependency:function(){return r}}),o.config=new o.Config},{"./core":19,"./credentials":20,"./credentials/credential_provider_chain":23}],18:[function(e,t,n){(function(n){(function(){var r=e("./core");function o(e,t){if("string"==typeof e){if(["legacy","regional"].indexOf(e.toLowerCase())>=0)return e.toLowerCase();throw r.util.error(new Error,t)}}t.exports=function(e,t){var i;if((e=e||{})[t.clientConfig]&&(i=o(e[t.clientConfig],{code:"InvalidConfiguration",message:'invalid "'+t.clientConfig+'" configuration. Expect "legacy" or "regional". Got "'+e[t.clientConfig]+'".'})))return i;if(!r.util.isNode())return i;if(Object.prototype.hasOwnProperty.call(n.env,t.env)&&(i=o(n.env[t.env],{code:"InvalidEnvironmentalVariable",message:"invalid "+t.env+' environmental variable. Expect "legacy" or "regional". Got "'+n.env[t.env]+'".'})))return i;var s={};try{s=r.util.getProfilesFromSharedConfig(r.util.iniLoader)[n.env.AWS_PROFILE||r.util.defaultProfile]}catch(e){}return s&&Object.prototype.hasOwnProperty.call(s,t.sharedConfig)&&(i=o(s[t.sharedConfig],{code:"InvalidConfiguration",message:"invalid "+t.sharedConfig+' profile config. Expect "legacy" or "regional". Got "'+s[t.sharedConfig]+'".'})),i}}).call(this)}).call(this,e("_process"))},{"./core":19,_process:90}],19:[function(e,t,n){var r={util:e("./util")};({}).toString(),t.exports=r,r.util.update(r,{VERSION:"2.1200.0",Signers:{},Protocol:{Json:e("./protocol/json"),Query:e("./protocol/query"),Rest:e("./protocol/rest"),RestJson:e("./protocol/rest_json"),RestXml:e("./protocol/rest_xml")},XML:{Builder:e("./xml/builder"),Parser:null},JSON:{Builder:e("./json/builder"),Parser:e("./json/parser")},Model:{Api:e("./model/api"),Operation:e("./model/operation"),Shape:e("./model/shape"),Paginator:e("./model/paginator"),ResourceWaiter:e("./model/resource_waiter")},apiLoader:e("./api_loader"),EndpointCache:e("../vendor/endpoint-cache").EndpointCache}),e("./sequential_executor"),e("./service"),e("./config"),e("./http"),e("./event_listeners"),e("./request"),e("./response"),e("./resource_waiter"),e("./signers/request_signer"),e("./param_validator"),r.events=new r.SequentialExecutor,r.util.memoizedProperty(r,"endpointCache",(function(){return new r.EndpointCache(r.config.endpointCacheSize)}),!0)},{"../vendor/endpoint-cache":109,"./api_loader":9,"./config":17,"./event_listeners":34,"./http":35,"./json/builder":37,"./json/parser":38,"./model/api":39,"./model/operation":41,"./model/paginator":42,"./model/resource_waiter":43,"./model/shape":44,"./param_validator":45,"./protocol/json":47,"./protocol/query":48,"./protocol/rest":49,"./protocol/rest_json":50,"./protocol/rest_xml":51,"./request":57,"./resource_waiter":58,"./response":59,"./sequential_executor":60,"./service":61,"./signers/request_signer":64,"./util":72,"./xml/builder":74}],20:[function(e,t,n){var r=e("./core");r.Credentials=r.util.inherit({constructor:function(){if(r.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"==typeof arguments[0]){var e=arguments[0].credentials||arguments[0];this.accessKeyId=e.accessKeyId,this.secretAccessKey=e.secretAccessKey,this.sessionToken=e.sessionToken}else this.accessKeyId=arguments[0],this.secretAccessKey=arguments[1],this.sessionToken=arguments[2]},expiryWindow:15,needsRefresh:function(){var e=r.util.date.getDate().getTime(),t=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&t>this.expireTime)||this.expired||!this.accessKeyId||!this.secretAccessKey},get:function(e){var t=this;this.needsRefresh()?this.refresh((function(n){n||(t.expired=!1),e&&e(n)})):e&&e()},refresh:function(e){this.expired=!1,e()},coalesceRefresh:function(e,t){var n=this;1===n.refreshCallbacks.push(e)&&n.load((function(e){r.util.arrayEach(n.refreshCallbacks,(function(n){t?n(e):r.util.defer((function(){n(e)}))})),n.refreshCallbacks.length=0}))},load:function(e){e()}}),r.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=r.util.promisifyMethod("get",e),this.prototype.refreshPromise=r.util.promisifyMethod("refresh",e)},r.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},r.util.addPromises(r.Credentials)},{"./core":19}],21:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.ChainableTemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=r.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!=typeof e.tokenCodeFn)throw new r.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=r.util.merge({params:t,credentials:e.masterCredentials||r.config.credentials},e.stsConfig||{});this.service=new o(n)},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this,n=t.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode((function(r,o){var i={};r?e(r):(o&&(i.TokenCode=o),t.service[n](i,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)})))}))},getTokenCode:function(e){var t=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,(function(n,o){if(n){var i=n;return n instanceof Error&&(i=n.message),void e(r.util.error(new Error("Error fetching MFA token: "+i),{code:t.errorCode}))}e(null,o)})):e(null)}})},{"../../clients/sts":8,"../core":19}],22:[function(e,t,n){var r=e("../core"),o=e("../../clients/cognitoidentity"),i=e("../../clients/sts");r.CognitoIdentityCredentials=r.util.inherit(r.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=r.util.copy(t||{}),this.loadCachedId();var n=this;Object.defineProperty(this,"identityId",{get:function(){return n.loadCachedId(),n._identityId||n.params.IdentityId},set:function(e){n._identityId=e}})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.data=null,t._identityId=null,t.getId((function(n){n?(t.clearIdOnNotAuthorized(n),e(n)):t.params.RoleArn?t.getCredentialsFromSTS(e):t.getCredentialsForIdentity(e)}))},clearCachedId:function(){this._identityId=null,delete this.params.IdentityId;var e=this.params.IdentityPoolId,t=this.params.LoginId||"";delete this.storage[this.localStorageKey.id+e+t],delete this.storage[this.localStorageKey.providers+e+t]},clearIdOnNotAuthorized:function(e){"NotAuthorizedException"==e.code&&this.clearCachedId()},getId:function(e){var t=this;if("string"==typeof t.params.IdentityId)return e(null,t.params.IdentityId);t.cognito.getId((function(n,r){!n&&r.IdentityId?(t.params.IdentityId=r.IdentityId,e(null,r.IdentityId)):e(n)}))},loadCredentials:function(e,t){e&&t&&(t.expired=!1,t.accessKeyId=e.Credentials.AccessKeyId,t.secretAccessKey=e.Credentials.SecretKey,t.sessionToken=e.Credentials.SessionToken,t.expireTime=e.Credentials.Expiration)},getCredentialsForIdentity:function(e){var t=this;t.cognito.getCredentialsForIdentity((function(n,r){n?t.clearIdOnNotAuthorized(n):(t.cacheId(r),t.data=r,t.loadCredentials(t.data,t)),e(n)}))},getCredentialsFromSTS:function(e){var t=this;t.cognito.getOpenIdToken((function(n,r){n?(t.clearIdOnNotAuthorized(n),e(n)):(t.cacheId(r),t.params.WebIdentityToken=r.Token,t.webIdentityCredentials.refresh((function(n){n||(t.data=t.webIdentityCredentials.data,t.sts.credentialsFrom(t.data,t)),e(n)})))}))},loadCachedId:function(){var e=this;if(r.util.isBrowser()&&!e.params.IdentityId){var t=e.getStorage("id");if(t&&e.params.Logins){var n=Object.keys(e.params.Logins);0!==(e.getStorage("providers")||"").split(",").filter((function(e){return-1!==n.indexOf(e)})).length&&(e.params.IdentityId=t)}else t&&(e.params.IdentityId=t)}},createClients:function(){var e=this._clientConfig;if(this.webIdentityCredentials=this.webIdentityCredentials||new r.WebIdentityCredentials(this.params,e),!this.cognito){var t=r.util.merge({},e);t.params=this.params,this.cognito=new o(t)}this.sts=this.sts||new i(e)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,r.util.isBrowser()&&(this.setStorage("id",e.IdentityId),this.params.Logins&&this.setStorage("providers",Object.keys(this.params.Logins).join(",")))},getStorage:function(e){return this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]},setStorage:function(e,t){try{this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]=t}catch(e){}},storage:function(){try{var e=r.util.isBrowser()&&null!==window.localStorage&&"object"==typeof window.localStorage?window.localStorage:{};return e["aws.test-storage"]="foobar",delete e["aws.test-storage"],e}catch(e){return{}}}()})},{"../../clients/cognitoidentity":7,"../../clients/sts":8,"../core":19}],23:[function(e,t,n){var r=e("../core");r.CredentialProviderChain=r.util.inherit(r.Credentials,{constructor:function(e){this.providers=e||r.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var t=this;if(0===t.providers.length)return e(new Error("No providers")),t;if(1===t.resolveCallbacks.push(e)){var n=0,o=t.providers.slice(0);!function e(i,s){if(!i&&s||n===o.length)return r.util.arrayEach(t.resolveCallbacks,(function(e){e(i,s)})),void(t.resolveCallbacks.length=0);var a=o[n++];(s="function"==typeof a?a.call():a).get?s.get((function(t){e(t,t?null:s)})):e(null,s)}()}return t}}),r.CredentialProviderChain.defaultProviders=[],r.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=r.util.promisifyMethod("resolve",e)},r.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},r.util.addPromises(r.CredentialProviderChain)},{"../core":19}],24:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.SAMLCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithSAML((function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":19}],25:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.TemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.loadMasterCredentials(t),this.expired=!0,this.params=e||{},this.params.RoleArn&&(this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials")},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.masterCredentials.get((function(){t.service.config.credentials=t.masterCredentials,(t.params.RoleArn?t.service.assumeRole:t.service.getSessionToken).call(t.service,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))}))},loadMasterCredentials:function(e){for(this.masterCredentials=e||r.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new r.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":19}],26:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.WebIdentityCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=r.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithWebIdentity((function(n,r){t.data=null,n||(t.data=r,t.service.credentialsFrom(r,t)),e(n)}))},createClients:function(){if(!this.service){var e=r.util.merge({},this._clientConfig);e.params=this.params,this.service=new o(e)}}})},{"../../clients/sts":8,"../core":19}],27:[function(e,t,n){(function(n){(function(){var r=e("./core"),o=e("./util"),i=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function s(e){var t=e.service,n=t.api||{},r=(n.operations,{});return t.config.region&&(r.region=t.config.region),n.serviceId&&(r.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(r.accessKeyId=t.config.credentials.accessKeyId),r}function a(e,t,n){n&&null!=t&&"structure"===n.type&&n.required&&n.required.length>0&&o.arrayEach(n.required,(function(r){var o=n.members[r];if(!0===o.endpointDiscoveryId){var i=o.isLocationName?o.name:r;e[i]=String(t[r])}else a(e,t[r],o)}))}function c(e,t){var n={};return a(n,e.params,t),n}function u(e){var t=e.service,n=t.api,i=n.operations?n.operations[e.operation]:void 0,a=c(e,i?i.input:void 0),u=s(e);Object.keys(a).length>0&&(u=o.update(u,a),i&&(u.operation=i.name));var l=r.endpointCache.get(u);if(!l||1!==l.length||""!==l[0].Address)if(l&&l.length>0)e.httpRequest.updateEndpoint(l[0].Address);else{var p=t.makeRequest(n.endpointOperation,{Operation:i.name,Identifiers:a});d(p),p.removeListener("validate",r.EventListeners.Core.VALIDATE_PARAMETERS),p.removeListener("retry",r.EventListeners.Core.RETRY_CHECK),r.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}]),p.send((function(e,t){t&&t.Endpoints?r.endpointCache.put(u,t.Endpoints):e&&r.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}])}))}}var l={};function p(e,t){var n=e.service,i=n.api,a=i.operations?i.operations[e.operation]:void 0,u=a?a.input:void 0,p=c(e,u),h=s(e);Object.keys(p).length>0&&(h=o.update(h,p),a&&(h.operation=a.name));var f=r.EndpointCache.getKeyString(h),g=r.endpointCache.get(f);if(g&&1===g.length&&""===g[0].Address)return l[f]||(l[f]=[]),void l[f].push({request:e,callback:t});if(g&&g.length>0)e.httpRequest.updateEndpoint(g[0].Address),t();else{var m=n.makeRequest(i.endpointOperation,{Operation:a.name,Identifiers:p});m.removeListener("validate",r.EventListeners.Core.VALIDATE_PARAMETERS),d(m),r.endpointCache.put(f,[{Address:"",CachePeriodInMinutes:60}]),m.send((function(n,i){if(n){if(e.response.error=o.error(n,{retryable:!1}),r.endpointCache.remove(h),l[f]){var s=l[f];o.arrayEach(s,(function(e){e.request.response.error=o.error(n,{retryable:!1}),e.callback()})),delete l[f]}}else i&&(r.endpointCache.put(f,i.Endpoints),e.httpRequest.updateEndpoint(i.Endpoints[0].Address),l[f])&&(s=l[f],o.arrayEach(s,(function(e){e.request.httpRequest.updateEndpoint(i.Endpoints[0].Address),e.callback()})),delete l[f]);t()}))}}function d(e){var t=e.service.api.apiVersion;t&&!e.httpRequest.headers["x-amz-api-version"]&&(e.httpRequest.headers["x-amz-api-version"]=t)}function h(e){var t=e.error,n=e.httpResponse;if(t&&("InvalidEndpointException"===t.code||421===n.statusCode)){var i=e.request,a=i.service.api.operations||{},u=c(i,a[i.operation]?a[i.operation].input:void 0),l=s(i);Object.keys(u).length>0&&(l=o.update(l,u),a[i.operation]&&(l.operation=a[i.operation].name)),r.endpointCache.remove(l)}}function f(e){return["false","0"].indexOf(e)>=0}t.exports={discoverEndpoint:function(e,t){var s=e.service||{};if(function(e){if(e._originalConfig&&e._originalConfig.endpoint&&!0===e._originalConfig.endpointDiscoveryEnabled)throw o.error(new Error,{code:"ConfigurationException",message:"Custom endpoint is supplied; endpointDiscoveryEnabled must not be true."});var t=r.config[e.serviceIdentifier]||{};return Boolean(r.config.endpoint||t.endpoint||e._originalConfig&&e._originalConfig.endpoint)}(s)||e.isPresigned())return t();var a=(s.api.operations||{})[e.operation],c=a?a.endpointDiscoveryRequired:"NULL",l=function(e){var t=e.service||{};if(void 0!==t.config.endpointDiscoveryEnabled)return t.config.endpointDiscoveryEnabled;if(!o.isBrowser()){for(var s=0;s-1&&(e[t]++,0===e[t]);t--);}i.fromNumber=function(e){if(e>0x8000000000000000||e<-0x8000000000000000)throw new Error(e+" is too large (or, if negative, too small) to represent as an Int64");for(var t=new Uint8Array(8),n=7,r=Math.abs(Math.round(e));n>-1&&r>0;n--,r/=256)t[n]=r;return e<0&&s(t),new i(t)},i.prototype.valueOf=function(){var e=this.bytes.slice(0),t=128&e[0];return t&&s(e),parseInt(e.toString("hex"),16)*(t?-1:1)},i.prototype.toString=function(){return String(this.valueOf())},t.exports={Int64:i}},{"../core":19}],31:[function(e,t,n){var r=e("./parse-message").parseMessage;t.exports={parseEvent:function(e,t,n){var o=r(t),i=o.headers[":message-type"];if(i){if("error"===i.value)throw function(e){var t=e.headers[":error-code"],n=e.headers[":error-message"],r=new Error(n.value||n);return r.code=r.name=t.value||t,r}(o);if("event"!==i.value)return}var s=o.headers[":event-type"],a=n.members[s.value];if(a){var c={},u=a.eventPayloadMemberName;if(u){var l=a.members[u];"binary"===l.type?c[u]=o.body:c[u]=e.parse(o.body.toString(),l)}for(var p=a.eventHeaderMemberNames,d=0;d=0)return e.httpRequest.headers["X-Amz-Content-Sha256"]="UNSIGNED-PAYLOAD",t();n.util.computeSha256(i,(function(n,r){n?t(n):(e.httpRequest.headers["X-Amz-Content-Sha256"]=r,t())}))}else t()}})),e("SET_CONTENT_LENGTH","afterBuild",(function(e){var t=function(e){if(!e.service.api.operations)return"";var t=e.service.api.operations[e.operation];return t?t.authtype:""}(e),r=n.util.getRequestPayloadShape(e);if(void 0===e.httpRequest.headers["Content-Length"])try{var o=n.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=o}catch(n){if(r&&r.isStreaming){if(r.requiresLength)throw n;if(t.indexOf("unsigned-body")>=0)return void(e.httpRequest.headers["Transfer-Encoding"]="chunked");throw n}throw n}})),e("SET_HTTP_HOST","afterBuild",(function(e){e.httpRequest.headers.Host=e.httpRequest.endpoint.host})),e("SET_TRACE_ID","afterBuild",(function(e){var r="X-Amzn-Trace-Id";if(n.util.isNode()&&!Object.hasOwnProperty.call(e.httpRequest.headers,r)){var o=t.env.AWS_LAMBDA_FUNCTION_NAME,i=t.env._X_AMZN_TRACE_ID;"string"==typeof o&&o.length>0&&"string"==typeof i&&i.length>0&&(e.httpRequest.headers[r]=i)}})),e("RESTART","restart",(function(){var e=this.response.error;e&&e.retryable&&(this.httpRequest=new n.HttpRequest(this.service.endpoint,this.service.region),this.response.retryCount=600?this.emit("sign",[this],(function(e){e?t(e):i()})):i()})),e("HTTP_HEADERS","httpHeaders",(function(e,t,r,o){r.httpResponse.statusCode=e,r.httpResponse.statusMessage=o,r.httpResponse.headers=t,r.httpResponse.body=n.util.buffer.toBuffer(""),r.httpResponse.buffers=[],r.httpResponse.numBytes=0;var i=t.date||t.Date,s=r.request.service;if(i){var a=Date.parse(i);s.config.correctClockSkew&&s.isClockSkewed(a)&&s.applyClockOffset(a)}})),e("HTTP_DATA","httpData",(function(e,t){if(e){if(n.util.isNode()){t.httpResponse.numBytes+=e.length;var r=t.httpResponse.headers["content-length"],o={loaded:t.httpResponse.numBytes,total:r};t.request.emit("httpDownloadProgress",[o,t])}t.httpResponse.buffers.push(n.util.buffer.toBuffer(e))}})),e("HTTP_DONE","httpDone",(function(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var t=n.util.buffer.concat(e.httpResponse.buffers);e.httpResponse.body=t}delete e.httpResponse.numBytes,delete e.httpResponse.buffers})),e("FINALIZE_ERROR","retry",(function(e){e.httpResponse.statusCode&&(e.error.statusCode=e.httpResponse.statusCode,void 0===e.error.retryable&&(e.error.retryable=this.service.retryableError(e.error,this)))})),e("INVALIDATE_CREDENTIALS","retry",(function(e){if(e.error)switch(e.error.code){case"RequestExpired":case"ExpiredTokenException":case"ExpiredToken":e.error.retryable=!0,e.request.service.config.credentials.expired=!0}})),e("EXPIRED_SIGNATURE","retry",(function(e){var t=e.error;t&&"string"==typeof t.code&&"string"==typeof t.message&&t.code.match(/Signature/)&&t.message.match(/expired/)&&(e.error.retryable=!0)})),e("CLOCK_SKEWED","retry",(function(e){e.error&&this.service.clockSkewError(e.error)&&this.service.config.correctClockSkew&&(e.error.retryable=!0)})),e("REDIRECT","retry",(function(e){e.error&&e.error.statusCode>=300&&e.error.statusCode<400&&e.httpResponse.headers.location&&(this.httpRequest.endpoint=new n.Endpoint(e.httpResponse.headers.location),this.httpRequest.headers.Host=this.httpRequest.endpoint.host,e.error.redirect=!0,e.error.retryable=!0)})),e("RETRY_CHECK","retry",(function(e){e.error&&(e.error.redirect&&e.redirectCount=0?(e.error=null,setTimeout(t,n)):t()}))})),CorePost:(new r).addNamedListeners((function(e){e("EXTRACT_REQUEST_ID","extractData",n.util.extractRequestId),e("EXTRACT_REQUEST_ID","extractError",n.util.extractRequestId),e("ENOTFOUND_ERROR","httpError",(function(e){if("NetworkingError"===e.code&&function(e){return"ENOTFOUND"===e.errno||"number"==typeof e.errno&&"function"==typeof n.util.getSystemErrorName&&["EAI_NONAME","EAI_NODATA"].indexOf(n.util.getSystemErrorName(e.errno)>=0)}(e)){var t="Inaccessible host: `"+e.hostname+"' at port `"+e.port+"'. This service may not be available in the `"+e.region+"' region.";this.response.error=n.util.error(new Error(t),{code:"UnknownEndpoint",region:e.region,hostname:e.hostname,retryable:!0,originalError:e})}}))})),Logger:(new r).addNamedListeners((function(t){t("LOG_REQUEST","complete",(function(t){var r=t.request,o=r.service.config.logger;if(o){var i=function(){var i=(t.request.service.getSkewCorrectedDate().getTime()-r.startTime.getTime())/1e3,a=!!o.isTTY,c=t.httpResponse.statusCode,u=r.params;r.service.api.operations&&r.service.api.operations[r.operation]&&r.service.api.operations[r.operation].input&&(u=s(r.service.api.operations[r.operation].input,r.params));var l=e("util").inspect(u,!0,null),p="";return a&&(p+=""),p+="[AWS "+r.service.serviceIdentifier+" "+c,p+=" "+i.toString()+"s "+t.retryCount+" retries]",a&&(p+=""),p+=" "+n.util.string.lowerFirst(r.operation),p+="("+l+")",a&&(p+=""),p}();"function"==typeof o.log?o.log(i):"function"==typeof o.write&&o.write(i+"\n")}function s(e,t){if(!t)return t;if(e.isSensitive)return"***SensitiveInformation***";switch(e.type){case"structure":var r={};return n.util.each(t,(function(t,n){Object.prototype.hasOwnProperty.call(e.members,t)?r[t]=s(e.members[t],n):r[t]=n})),r;case"list":var o=[];return n.util.arrayEach(t,(function(t,n){o.push(s(e.member,t))})),o;case"map":var i={};return n.util.each(t,(function(t,n){i[t]=s(e.value,n)})),i;default:return t}}}))})),Json:(new r).addNamedListeners((function(t){var n=e("./protocol/json");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),Rest:(new r).addNamedListeners((function(t){var n=e("./protocol/rest");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),RestJson:(new r).addNamedListeners((function(t){var n=e("./protocol/rest_json");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),RestXml:(new r).addNamedListeners((function(t){var n=e("./protocol/rest_xml");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),Query:(new r).addNamedListeners((function(t){var n=e("./protocol/query");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)}))}}).call(this)}).call(this,e("_process"))},{"./core":19,"./discover_endpoint":27,"./protocol/json":47,"./protocol/query":48,"./protocol/rest":49,"./protocol/rest_json":50,"./protocol/rest_xml":51,"./sequential_executor":60,_process:90,util:84}],35:[function(e,t,n){var r=e("./core"),o=r.util.inherit;r.Endpoint=o({constructor:function(e,t){if(r.util.hideProperties(this,["slashes","auth","hash","search","query"]),null==e)throw new Error("Invalid endpoint: "+e);if("string"!=typeof e)return r.util.copy(e);e.match(/^http/)||(e=((t&&void 0!==t.sslEnabled?t.sslEnabled:r.config.sslEnabled)?"https":"http")+"://"+e),r.util.update(this,r.util.urlParse(e)),this.port?this.port=parseInt(this.port,10):this.port="https:"===this.protocol?443:80}}),r.HttpRequest=o({constructor:function(e,t){e=new r.Endpoint(e),this.method="POST",this.path=e.path||"/",this.headers={},this.body="",this.endpoint=e,this.region=t,this._userAgent="",this.setUserAgent()},setUserAgent:function(){this._userAgent=this.headers[this.getUserAgentHeaderName()]=r.util.userAgent()},getUserAgentHeaderName:function(){return(r.util.isBrowser()?"X-Amz-":"")+"User-Agent"},appendToUserAgent:function(e){"string"==typeof e&&e&&(this._userAgent+=" "+e),this.headers[this.getUserAgentHeaderName()]=this._userAgent},getUserAgent:function(){return this._userAgent},pathname:function(){return this.path.split("?",1)[0]},search:function(){var e=this.path.split("?",2)[1];return e?(e=r.util.queryStringParse(e),r.util.queryParamsToString(e)):""},updateEndpoint:function(e){var t=new r.Endpoint(e);this.endpoint=t,this.path=t.path||"/",this.headers.Host&&(this.headers.Host=t.host)}}),r.HttpResponse=o({constructor:function(){this.statusCode=void 0,this.headers={},this.body=void 0,this.streaming=!1,this.stream=null},createUnbufferedStream:function(){return this.streaming=!0,this.stream}}),r.HttpClient=o({}),r.HttpClient.getInstance=function(){return void 0===this.singleton&&(this.singleton=new this),this.singleton}},{"./core":19}],36:[function(e,t,n){var r=e("../core"),o=e("events").EventEmitter;e("../http"),r.XHRClient=r.util.inherit({handleRequest:function(e,t,n,i){var s=this,a=e.endpoint,c=new o,u=a.protocol+"//"+a.hostname;80!==a.port&&443!==a.port&&(u+=":"+a.port),u+=e.path;var l=new XMLHttpRequest,p=!1;e.stream=l,l.addEventListener("readystatechange",(function(){try{if(0===l.status)return}catch(e){return}this.readyState>=this.HEADERS_RECEIVED&&!p&&(c.statusCode=l.status,c.headers=s.parseHeaders(l.getAllResponseHeaders()),c.emit("headers",c.statusCode,c.headers,l.statusText),p=!0),this.readyState===this.DONE&&s.finishRequest(l,c)}),!1),l.upload.addEventListener("progress",(function(e){c.emit("sendProgress",e)})),l.addEventListener("progress",(function(e){c.emit("receiveProgress",e)}),!1),l.addEventListener("timeout",(function(){i(r.util.error(new Error("Timeout"),{code:"TimeoutError"}))}),!1),l.addEventListener("error",(function(){i(r.util.error(new Error("Network Failure"),{code:"NetworkingError"}))}),!1),l.addEventListener("abort",(function(){i(r.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))}),!1),n(c),l.open(e.method,u,!1!==t.xhrAsync),r.util.each(e.headers,(function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&l.setRequestHeader(e,t)})),t.timeout&&!1!==t.xhrAsync&&(l.timeout=t.timeout),t.xhrWithCredentials&&(l.withCredentials=!0);try{l.responseType="arraybuffer"}catch(e){}try{e.body?l.send(e.body):l.send()}catch(t){if(!e.body||"object"!=typeof e.body.buffer)throw t;l.send(e.body.buffer)}return c},parseHeaders:function(e){var t={};return r.util.arrayEach(e.split(/\r?\n/),(function(e){var n=e.split(":",1)[0],r=e.substring(n.length+2);n.length>0&&(t[n.toLowerCase()]=r)})),t},finishRequest:function(e,t){var n;if("arraybuffer"===e.responseType&&e.response){var o=e.response;n=new r.util.Buffer(o.byteLength);for(var i=new Uint8Array(o),s=0;s-1?t||"":t,this.isJsonValue?JSON.parse(t):t&&"function"==typeof t.toString?t.toString():t},this.toWireFormat=function(e){return this.isJsonValue?JSON.stringify(e):e}}function h(){a.apply(this,arguments),this.toType=function(e){var t=o.base64.decode(e);if(this.isSensitive&&o.isNode()&&"function"==typeof o.Buffer.alloc){var n=o.Buffer.alloc(t.length,t);t.fill(0),t=n}return t},this.toWireFormat=o.base64.encode}function f(){h.apply(this,arguments)}function g(){a.apply(this,arguments),this.toType=function(e){return"boolean"==typeof e?e:null==e?null:"true"===e}}a.normalizedTypes={character:"string",double:"float",long:"integer",short:"integer",biginteger:"integer",bigdecimal:"float",blob:"binary"},a.types={structure:u,list:l,map:p,boolean:g,timestamp:function(e){var t=this;if(a.apply(this,arguments),e.timestampFormat)i(this,"timestampFormat",e.timestampFormat);else if(t.isTimestampFormatSet&&this.timestampFormat)i(this,"timestampFormat",this.timestampFormat);else if("header"===this.location)i(this,"timestampFormat","rfc822");else if("querystring"===this.location)i(this,"timestampFormat","iso8601");else if(this.api)switch(this.api.protocol){case"json":case"rest-json":i(this,"timestampFormat","unixTimestamp");break;case"rest-xml":case"query":case"ec2":i(this,"timestampFormat","iso8601")}this.toType=function(e){return null==e?null:"function"==typeof e.toUTCString?e:"string"==typeof e||"number"==typeof e?o.date.parseTimestamp(e):null},this.toWireFormat=function(e){return o.date.format(e,t.timestampFormat)}},float:function(){a.apply(this,arguments),this.toType=function(e){return null==e?null:parseFloat(e)},this.toWireFormat=this.toType},integer:function(){a.apply(this,arguments),this.toType=function(e){return null==e?null:parseInt(e,10)},this.toWireFormat=this.toType},string:d,base64:f,binary:h},a.resolve=function(e,t){if(e.shape){var n=t.api.shapes[e.shape];if(!n)throw new Error("Cannot find shape reference: "+e.shape);return n}return null},a.create=function(e,t,n){if(e.isShape)return e;var r=a.resolve(e,t);if(r){var o=Object.keys(e);t.documentation||(o=o.filter((function(e){return!e.match(/documentation/)})));var i=function(){r.constructor.call(this,e,t,n)};return i.prototype=r,new i}e.type||(e.members?e.type="structure":e.member?e.type="list":e.key?e.type="map":e.type="string");var s=e.type;if(a.normalizedTypes[e.type]&&(e.type=a.normalizedTypes[e.type]),a.types[e.type])return new a.types[e.type](e,t,n);throw new Error("Unrecognized shape type: "+s)},a.shapes={StructureShape:u,ListShape:l,MapShape:p,StringShape:d,BooleanShape:g,Base64Shape:f},t.exports=a},{"../util":72,"./collection":40}],45:[function(e,t,n){var r=e("./core");r.ParamValidator=r.util.inherit({constructor:function(e){!0!==e&&void 0!==e||(e={min:!0}),this.validation=e},validate:function(e,t,n){if(this.errors=[],this.validateMember(e,t||{},n||"params"),this.errors.length>1){var o=this.errors.join("\n* ");throw o="There were "+this.errors.length+" validation errors:\n* "+o,r.util.error(new Error(o),{code:"MultipleValidationErrors",errors:this.errors})}if(1===this.errors.length)throw this.errors[0];return!0},fail:function(e,t){this.errors.push(r.util.error(new Error(t),{code:e}))},validateStructure:function(e,t,n){if(e.isDocument)return!0;var r;this.validateType(t,n,["object"],"structure");for(var o=0;e.required&&o= 1, but found "'+t+'" for '+n)},validatePattern:function(e,t,n){this.validation.pattern&&void 0!==e.pattern&&(new RegExp(e.pattern).test(t)||this.fail("PatternMatchError",'Provided value "'+t+'" does not match regex pattern /'+e.pattern+"/ for "+n))},validateRange:function(e,t,n,r){this.validation.min&&void 0!==e.min&&t= "+e.min+", but found "+t+" for "+n),this.validation.max&&void 0!==e.max&&t>e.max&&this.fail("MaxRangeError","Expected "+r+" <= "+e.max+", but found "+t+" for "+n)},validateEnum:function(e,t,n){this.validation.enum&&void 0!==e.enum&&-1===e.enum.indexOf(t)&&this.fail("EnumError","Found string value of "+t+", but expected "+e.enum.join("|")+" for "+n)},validateType:function(e,t,n,o){if(null==e)return!1;for(var i=!1,s=0;s63)throw r.error(new Error,{code:"ValidationError",message:"Hostname label length should be between 1 to 63 characters, inclusive."});if(!i.test(e))throw o.util.error(new Error,{code:"ValidationError",message:e+" is not hostname compatible."})}))}return e}}},{"../core":19,"../util":72}],47:[function(e,t,n){var r=e("../util"),o=e("../json/builder"),i=e("../json/parser"),s=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.httpRequest,n=e.service.api,r=n.targetPrefix+"."+n.operations[e.operation].name,i=n.jsonVersion||"1.0",a=n.operations[e.operation].input,c=new o;1===i&&(i="1.0"),t.body=c.build(e.params||{},a),t.headers["Content-Type"]="application/x-amz-json-"+i,t.headers["X-Amz-Target"]=r,s(e)},extractError:function(e){var t={},n=e.httpResponse;if(t.code=n.headers["x-amzn-errortype"]||"UnknownError","string"==typeof t.code&&(t.code=t.code.split(":")[0]),n.body.length>0)try{var o=JSON.parse(n.body.toString()),i=o.__type||o.code||o.Code;i&&(t.code=i.split("#").pop()),"RequestEntityTooLarge"===t.code?t.message="Request body must be less than 1 MB":t.message=o.message||o.Message||null}catch(o){t.statusCode=n.statusCode,t.message=n.statusMessage}else t.statusCode=n.statusCode,t.message=n.statusCode.toString();e.error=r.error(new Error,t)},extractData:function(e){var t=e.httpResponse.body.toString()||"{}";if(!1===e.request.service.config.convertResponseTypes)e.data=JSON.parse(t);else{var n=e.request.service.api.operations[e.request.operation].output||{},r=new i;e.data=r.parse(t,n)}}}},{"../json/builder":37,"../json/parser":38,"../util":72,"./helpers":46}],48:[function(e,t,n){var r=e("../core"),o=e("../util"),i=e("../query/query_param_serializer"),s=e("../model/shape"),a=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.service.api.operations[e.operation],n=e.httpRequest;n.headers["Content-Type"]="application/x-www-form-urlencoded; charset=utf-8",n.params={Version:e.service.api.apiVersion,Action:t.name},(new i).serialize(e.params,t.input,(function(e,t){n.params[e]=t})),n.body=o.queryParamsToString(n.params),a(e)},extractError:function(e){var t,n=e.httpResponse.body.toString();if(n.match("=0?"&":"?";var c=[];r.arrayEach(Object.keys(s).sort(),(function(e){Array.isArray(s[e])||(s[e]=[s[e]]);for(var t=0;t0){var p=(t=new r.XML.Parser).parse(s.toString(),c);o.update(e.data,p)}}}},{"../core":19,"../util":72,"./rest":49}],52:[function(e,t,n){var r=e("../util");function o(){}function i(e){return e.isQueryName||"ec2"!==e.api.protocol?e.name:e.name[0].toUpperCase()+e.name.substr(1)}function s(e,t,n,o){r.each(n.members,(function(n,r){var s=t[n];if(null!=s){var c=i(r);a(c=e?e+"."+c:c,s,r,o)}}))}function a(e,t,n,o){null!=t&&("structure"===n.type?s(e,t,n,o):"list"===n.type?function(e,t,n,o){var s=n.member||{};0!==t.length?r.arrayEach(t,(function(t,r){var c="."+(r+1);if("ec2"===n.api.protocol)c+="";else if(n.flattened){if(s.name){var u=e.split(".");u.pop(),u.push(i(s)),e=u.join(".")}}else c="."+(s.name?s.name:"member")+c;a(e+c,t,s,o)})):o.call(this,e,null)}(e,t,n,o):"map"===n.type?function(e,t,n,o){var i=1;r.each(t,(function(t,r){var s=(n.flattened?".":".entry.")+i+++".",c=s+(n.key.name||"key"),u=s+(n.value.name||"value");a(e+c,t,n.key,o),a(e+u,r,n.value,o)}))}(e,t,n,o):o(e,n.toWireFormat(t).toString()))}o.prototype.serialize=function(e,t,n){s("",e,t,n)},t.exports=o},{"../util":72}],53:[function(e,t,n){t.exports={now:function(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}}},{}],54:[function(e,t,n){t.exports={isFipsRegion:function(e){return"string"==typeof e&&(e.startsWith("fips-")||e.endsWith("-fips"))},isGlobalRegion:function(e){return"string"==typeof e&&["aws-global","aws-us-gov-global"].includes(e)},getRealRegion:function(e){return["fips-aws-global","aws-fips","aws-global"].includes(e)?"us-east-1":["fips-aws-us-gov-global","aws-us-gov-global"].includes(e)?"us-gov-west-1":e.replace(/fips-(dkr-|prod-)?|-fips/,"")}}},{}],55:[function(e,t,n){var r=e("./util"),o=e("./region_config_data.json");function i(e,t){r.each(t,(function(t,n){"globalEndpoint"!==t&&(void 0!==e.config[t]&&null!==e.config[t]||(e.config[t]=n))}))}t.exports={configureEndpoint:function(e){for(var t=function(e){var t=e.config.region,n=function(e){if(!e)return null;var t=e.split("-");return t.length<3?null:t.slice(0,t.length-2).join("-")+"-*"}(t),r=e.api.endpointPrefix;return[[t,r],[n,r],[t,"*"],[n,"*"],["*",r],["*","*"]].map((function(e){return e[0]&&e[1]?e.join("/"):null}))}(e),n=e.config.useFipsEndpoint,r=e.config.useDualstackEndpoint,s=0;s=0){c=!0;var u=0}var l=function(){c&&u!==a?o.emit("error",n.util.error(new Error("Stream content length mismatch. Received "+u+" of "+a+" bytes."),{code:"StreamContentLengthMismatch"})):2===n.HttpClient.streamsApiVersion?o.end():o.emit("end")},p=s.httpResponse.createUnbufferedStream();if(2===n.HttpClient.streamsApiVersion)if(c){var d=new e.PassThrough;d._write=function(t){return t&&t.length&&(u+=t.length),e.PassThrough.prototype._write.apply(this,arguments)},d.on("end",l),o.on("error",(function(e){c=!1,p.unpipe(d),d.emit("end"),d.end()})),p.pipe(d).pipe(o,{end:!1})}else p.pipe(o);else c&&p.on("data",(function(e){e&&e.length&&(u+=e.length)})),p.on("data",(function(e){o.emit("data",e)})),p.on("end",l);p.on("error",(function(e){c=!1,o.emit("error",e)}))}})),o},emitEvent:function(e,t,r){"function"==typeof t&&(r=t,t=null),r||(r=function(){}),t||(t=this.eventParameters(e,this.response)),n.SequentialExecutor.prototype.emit.call(this,e,t,(function(e){e&&(this.response.error=e),r.call(this,e)}))},eventParameters:function(e){switch(e){case"restart":case"validate":case"sign":case"build":case"afterValidate":case"afterBuild":return[this];case"error":return[this.response.error,this.response];default:return[this.response]}},presign:function(e,t){return t||"function"!=typeof e||(t=e,e=null),(new n.Signers.Presign).sign(this.toGet(),e,t)},isPresigned:function(){return Object.prototype.hasOwnProperty.call(this.httpRequest.headers,"presigned-expires")},toUnauthenticated:function(){return this._unAuthenticated=!0,this.removeListener("validate",n.EventListeners.Core.VALIDATE_CREDENTIALS),this.removeListener("sign",n.EventListeners.Core.SIGN),this},toGet:function(){return"query"!==this.service.api.protocol&&"ec2"!==this.service.api.protocol||(this.removeListener("build",this.buildAsGet),this.addListener("build",this.buildAsGet)),this},buildAsGet:function(e){e.httpRequest.method="GET",e.httpRequest.path=e.service.endpoint.path+"?"+e.httpRequest.body,e.httpRequest.body="",delete e.httpRequest.headers["Content-Length"],delete e.httpRequest.headers["Content-Type"]},haltHandlersOnError:function(){this._haltHandlersOnError=!0}}),n.Request.addPromisesToClass=function(e){this.prototype.promise=function(){var t=this;return this.httpRequest.appendToUserAgent("promise"),new e((function(e,n){t.on("complete",(function(t){t.error?n(t.error):e(Object.defineProperty(t.data||{},"$response",{value:t}))})),t.runTo()}))}},n.Request.deletePromisesFromClass=function(){delete this.prototype.promise},n.util.addPromises(n.Request),n.util.mixin(n.Request,n.SequentialExecutor)}).call(this)}).call(this,e("_process"))},{"./core":19,"./state_machine":71,_process:90,jmespath:89}],58:[function(e,t,n){var r=e("./core"),o=r.util.inherit,i=e("jmespath");function s(e){var t=e.request._waiter,n=t.config.acceptors,r=!1,o="retry";n.forEach((function(n){if(!r){var i=t.matchers[n.matcher];i&&i(e,n.expected,n.argument)&&(r=!0,o=n.state)}})),!r&&e.error&&(o="failure"),"success"===o?t.setSuccess(e):t.setError(e,"retry"===o)}r.ResourceWaiter=o({constructor:function(e,t){this.service=e,this.state=t,this.loadWaiterConfig(this.state)},service:null,state:null,config:null,matchers:{path:function(e,t,n){try{var r=i.search(e.data,n)}catch(e){return!1}return i.strictDeepEqual(r,t)},pathAll:function(e,t,n){try{var r=i.search(e.data,n)}catch(e){return!1}Array.isArray(r)||(r=[r]);var o=r.length;if(!o)return!1;for(var s=0;s-1&&n.splice(o,1)}return this},removeAllListeners:function(e){return e?delete this._events[e]:this._events={},this},emit:function(e,t,n){n||(n=function(){});var r=this.listeners(e),o=r.length;return this.callListeners(r,t,n),o>0},callListeners:function(e,t,n,o){var i=this,s=o||null;function a(o){if(o&&(s=r.util.error(s||new Error,o),i._haltHandlersOnError))return n.call(i,s);i.callListeners(e,t,n,s)}for(;e.length>0;){var c=e.shift();if(c._isAsync)return void c.apply(i,t.concat([a]));try{c.apply(i,t)}catch(e){s=r.util.error(s||new Error,e)}if(s&&i._haltHandlersOnError)return void n.call(i,s)}n.call(i,s)},addListeners:function(e){var t=this;return e._events&&(e=e._events),r.util.each(e,(function(e,n){"function"==typeof n&&(n=[n]),r.util.arrayEach(n,(function(n){t.on(e,n)}))})),t},addNamedListener:function(e,t,n,r){return this[e]=n,this.addListener(t,n,r),this},addNamedAsyncListener:function(e,t,n,r){return n._isAsync=!0,this.addNamedListener(e,t,n,r)},addNamedListeners:function(e){var t=this;return e((function(){t.addNamedListener.apply(t,arguments)}),(function(){t.addNamedAsyncListener.apply(t,arguments)})),this}}),r.SequentialExecutor.prototype.addListener=r.SequentialExecutor.prototype.on,t.exports=r.SequentialExecutor},{"./core":19}],61:[function(e,t,n){(function(n){(function(){var r=e("./core"),o=e("./model/api"),i=e("./region_config"),s=r.util.inherit,a=0,c=e("./region/utils");r.Service=s({constructor:function(e){if(!this.loadServiceClass)throw r.util.error(new Error,"Service must be constructed with `new' operator");if(e){if(e.region){var t=e.region;c.isFipsRegion(t)&&(e.region=c.getRealRegion(t),e.useFipsEndpoint=!0),c.isGlobalRegion(t)&&(e.region=c.getRealRegion(t))}"boolean"==typeof e.useDualstack&&"boolean"!=typeof e.useDualstackEndpoint&&(e.useDualstackEndpoint=e.useDualstack)}var n=this.loadServiceClass(e||{});if(n){var o=r.util.copy(e),i=new n(e);return Object.defineProperty(i,"_originalConfig",{get:function(){return o},enumerable:!1,configurable:!0}),i._clientId=++a,i}this.initialize(e)},initialize:function(e){var t=r.config[this.serviceIdentifier];if(this.config=new r.Config(r.config),t&&this.config.update(t,!0),e&&this.config.update(e,!0),this.validateService(),this.config.endpoint||i.configureEndpoint(this),this.config.endpoint=this.endpointFromTemplate(this.config.endpoint),this.setEndpoint(this.config.endpoint),r.SequentialExecutor.call(this),r.Service.addDefaultMonitoringListeners(this),(this.config.clientSideMonitoring||r.Service._clientSideMonitoring)&&this.publisher){var o=this.publisher;this.addNamedListener("PUBLISH_API_CALL","apiCall",(function(e){n.nextTick((function(){o.eventHandler(e)}))})),this.addNamedListener("PUBLISH_API_ATTEMPT","apiCallAttempt",(function(e){n.nextTick((function(){o.eventHandler(e)}))}))}},validateService:function(){},loadServiceClass:function(e){var t=e;if(r.util.isEmpty(this.api)){if(t.apiConfig)return r.Service.defineServiceApi(this.constructor,t.apiConfig);if(this.constructor.services){(t=new r.Config(r.config)).update(e,!0);var n=t.apiVersions[this.constructor.serviceIdentifier];return n=n||t.apiVersion,this.getLatestServiceClass(n)}return null}return null},getLatestServiceClass:function(e){return e=this.getLatestServiceVersion(e),null===this.constructor.services[e]&&r.Service.defineServiceApi(this.constructor,e),this.constructor.services[e]},getLatestServiceVersion:function(e){if(!this.constructor.services||0===this.constructor.services.length)throw new Error("No services defined on "+this.constructor.serviceIdentifier);if(e?r.util.isType(e,Date)&&(e=r.util.date.iso8601(e).split("T")[0]):e="latest",Object.hasOwnProperty(this.constructor.services,e))return e;for(var t=Object.keys(this.constructor.services).sort(),n=null,o=t.length-1;o>=0;o--)if("*"!==t[o][t[o].length-1]&&(n=t[o]),t[o].substr(0,10)<=e)return n;throw new Error("Could not find "+this.constructor.serviceIdentifier+" API to satisfy version constraint `"+e+"'")},api:{},defaultRetryCount:3,customizeRequests:function(e){if(e){if("function"!=typeof e)throw new Error("Invalid callback type '"+typeof e+"' provided in customizeRequests");this.customRequestHandler=e}else this.customRequestHandler=null},makeRequest:function(e,t,n){if("function"==typeof t&&(n=t,t=null),t=t||{},this.config.params){var o=this.api.operations[e];o&&(t=r.util.copy(t),r.util.each(this.config.params,(function(e,n){o.input.members[e]&&(void 0!==t[e]&&null!==t[e]||(t[e]=n))})))}var i=new r.Request(this,e,t);return this.addAllRequestListeners(i),this.attachMonitoringEmitter(i),n&&i.send(n),i},makeUnauthenticatedRequest:function(e,t,n){"function"==typeof t&&(n=t,t={});var r=this.makeRequest(e,t).toUnauthenticated();return n?r.send(n):r},waitFor:function(e,t,n){return new r.ResourceWaiter(this,e).wait(t,n)},addAllRequestListeners:function(e){for(var t=[r.events,r.EventListeners.Core,this.serviceInterface(),r.EventListeners.CorePost],n=0;n299?(o.code&&(n.FinalAwsException=o.code),o.message&&(n.FinalAwsExceptionMessage=o.message)):((o.code||o.name)&&(n.FinalSdkException=o.code||o.name),o.message&&(n.FinalSdkExceptionMessage=o.message))}return n},apiAttemptEvent:function(e){var t=e.service.api.operations[e.operation],n={Type:"ApiCallAttempt",Api:t?t.name:e.operation,Version:1,Service:e.service.api.serviceId||e.service.api.endpointPrefix,Fqdn:e.httpRequest.endpoint.hostname,UserAgent:e.httpRequest.getUserAgent()},r=e.response;return r.httpResponse.statusCode&&(n.HttpStatusCode=r.httpResponse.statusCode),!e._unAuthenticated&&e.service.config.credentials&&e.service.config.credentials.accessKeyId&&(n.AccessKey=e.service.config.credentials.accessKeyId),r.httpResponse.headers?(e.httpRequest.headers["x-amz-security-token"]&&(n.SessionToken=e.httpRequest.headers["x-amz-security-token"]),r.httpResponse.headers["x-amzn-requestid"]&&(n.XAmznRequestId=r.httpResponse.headers["x-amzn-requestid"]),r.httpResponse.headers["x-amz-request-id"]&&(n.XAmzRequestId=r.httpResponse.headers["x-amz-request-id"]),r.httpResponse.headers["x-amz-id-2"]&&(n.XAmzId2=r.httpResponse.headers["x-amz-id-2"]),n):n},attemptFailEvent:function(e){var t=this.apiAttemptEvent(e),n=e.response,r=n.error;return n.httpResponse.statusCode>299?(r.code&&(t.AwsException=r.code),r.message&&(t.AwsExceptionMessage=r.message)):((r.code||r.name)&&(t.SdkException=r.code||r.name),r.message&&(t.SdkExceptionMessage=r.message)),t},attachMonitoringEmitter:function(e){var t,n,o,i,s,a,c=0,u=this;e.on("validate",(function(){i=r.util.realClock.now(),a=Date.now()}),!0),e.on("sign",(function(){n=r.util.realClock.now(),t=Date.now(),s=e.httpRequest.region,c++}),!0),e.on("validateResponse",(function(){o=Math.round(r.util.realClock.now()-n)})),e.addNamedListener("API_CALL_ATTEMPT","success",(function(){var n=u.apiAttemptEvent(e);n.Timestamp=t,n.AttemptLatency=o>=0?o:0,n.Region=s,u.emit("apiCallAttempt",[n])})),e.addNamedListener("API_CALL_ATTEMPT_RETRY","retry",(function(){var i=u.attemptFailEvent(e);i.Timestamp=t,o=o||Math.round(r.util.realClock.now()-n),i.AttemptLatency=o>=0?o:0,i.Region=s,u.emit("apiCallAttempt",[i])})),e.addNamedListener("API_CALL","complete",(function(){var t=u.apiCallEvent(e);if(t.AttemptCount=c,!(t.AttemptCount<=0)){t.Timestamp=a;var n=Math.round(r.util.realClock.now()-i);t.Latency=n>=0?n:0;var o=e.response;o.error&&o.error.retryable&&"number"==typeof o.retryCount&&"number"==typeof o.maxRetries&&o.retryCount>=o.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t])}}))},setupRequestListeners:function(e){},getSigningName:function(){return this.api.signingName||this.api.endpointPrefix},getSignerClass:function(e){var t,n=null,o="";return e&&(o=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:""),t=this.config.signatureVersion?this.config.signatureVersion:"v4"===o||"v4-unsigned-body"===o?"v4":this.api.signatureVersion,r.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return r.EventListeners.Query;case"json":return r.EventListeners.Json;case"rest-json":return r.EventListeners.RestJson;case"rest-xml":return r.EventListeners.RestXml}if(this.api.protocol)throw new Error("Invalid service `protocol' "+this.api.protocol+" in API config")},successfulResponse:function(e){return e.httpResponse.statusCode<300},numRetries:function(){return void 0!==this.config.maxRetries?this.config.maxRetries:this.defaultRetryCount},retryDelays:function(e,t){return r.util.calculateRetryDelay(e,this.config.retryDelayOptions,t)},retryableError:function(e){return!!this.timeoutError(e)||!!this.networkingError(e)||!!this.expiredCredentialsError(e)||!!this.throttledError(e)||e.statusCode>=500},networkingError:function(e){return"NetworkingError"===e.code},timeoutError:function(e){return"TimeoutError"===e.code},expiredCredentialsError:function(e){return"ExpiredTokenException"===e.code},clockSkewError:function(e){switch(e.code){case"RequestTimeTooSkewed":case"RequestExpired":case"InvalidSignatureException":case"SignatureDoesNotMatch":case"AuthFailure":case"RequestInTheFuture":return!0;default:return!1}},getSkewCorrectedDate:function(){return new Date(Date.now()+this.config.systemClockOffset)},applyClockOffset:function(e){e&&(this.config.systemClockOffset=e-Date.now())},isClockSkewed:function(e){if(e)return Math.abs(this.getSkewCorrectedDate().getTime()-e)>=3e5},throttledError:function(e){if(429===e.statusCode)return!0;switch(e.code){case"ProvisionedThroughputExceededException":case"Throttling":case"ThrottlingException":case"RequestLimitExceeded":case"RequestThrottled":case"RequestThrottledException":case"TooManyRequestsException":case"TransactionInProgressException":case"EC2ThrottledException":return!0;default:return!1}},endpointFromTemplate:function(e){if("string"!=typeof e)return e;var t=e;return t=(t=(t=t.replace(/\{service\}/g,this.api.endpointPrefix)).replace(/\{region\}/g,this.config.region)).replace(/\{scheme\}/g,this.config.sslEnabled?"https":"http")},setEndpoint:function(e){this.endpoint=new r.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(!n){if(t){var o=new Error;throw r.util.error(o,"No pagination configuration for "+e)}return null}return n}}),r.util.update(r.Service,{defineMethods:function(e){r.util.each(e.prototype.api.operations,(function(t){e.prototype[t]||("none"===e.prototype.api.operations[t].authtype?e.prototype[t]=function(e,n){return this.makeUnauthenticatedRequest(t,e,n)}:e.prototype[t]=function(e,n){return this.makeRequest(t,e,n)})}))},defineService:function(e,t,n){r.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var o=s(r.Service,n||{});if("string"==typeof e){r.Service.addVersions(o,t);var i=o.serviceIdentifier||e;o.serviceIdentifier=i}else o.prototype.api=e,r.Service.defineMethods(o);if(r.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&r.util.clientSideMonitoring){var a=r.util.clientSideMonitoring.Publisher,c=(0,r.util.clientSideMonitoring.configProvider)();this.prototype.publisher=new a(c),c.enabled&&(r.Service._clientSideMonitoring=!0)}return r.SequentialExecutor.call(o.prototype),r.Service.addDefaultMonitoringListeners(o.prototype),o},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n604800)throw r.util.error(new Error,{code:"InvalidExpiryTime",message:"Presigning does not support expiry time greater than a week with SigV4 signing.",retryable:!1});e.httpRequest.headers[i]=t}else{if(n!==r.Signers.S3)throw r.util.error(new Error,{message:"Presigning only supports S3 or SigV4 signing.",code:"UnsupportedSigner",retryable:!1});var o=e.service?e.service.getSkewCorrectedDate():r.util.date.getDate();e.httpRequest.headers[i]=parseInt(r.util.date.unixTimestamp(o)+t,10).toString()}}function a(e){var t=e.httpRequest.endpoint,n=r.util.urlParse(e.httpRequest.path),o={};n.search&&(o=r.util.queryStringParse(n.search.substr(1)));var s=e.httpRequest.headers.Authorization.split(" ");if("AWS"===s[0])s=s[1].split(":"),o.Signature=s.pop(),o.AWSAccessKeyId=s.join(":"),r.util.each(e.httpRequest.headers,(function(e,t){e===i&&(e="Expires"),0===e.indexOf("x-amz-meta-")&&(delete o[e],e=e.toLowerCase()),o[e]=t})),delete e.httpRequest.headers[i],delete o.Authorization,delete o.Host;else if("AWS4-HMAC-SHA256"===s[0]){s.shift();var a=s.join(" ").match(/Signature=(.*?)(?:,|\s|\r?\n|$)/)[1];o["X-Amz-Signature"]=a,delete o.Expires}t.pathname=n.pathname,t.search=r.util.queryParamsToString(o)}r.Signers.Presign=o({sign:function(e,t,n){if(e.httpRequest.headers[i]=t||3600,e.on("build",s),e.on("sign",a),e.removeListener("afterBuild",r.EventListeners.Core.SET_CONTENT_LENGTH),e.removeListener("afterBuild",r.EventListeners.Core.COMPUTE_SHA256),e.emit("beforePresign",[e]),!n){if(e.build(),e.response.error)throw e.response.error;return r.util.urlFormat(e.httpRequest.endpoint)}e.build((function(){this.response.error?n(this.response.error):n(null,r.util.urlFormat(e.httpRequest.endpoint))}))}}),t.exports=r.Signers.Presign},{"../core":19}],64:[function(e,t,n){var r=e("../core"),o=r.util.inherit;r.Signers.RequestSigner=o({constructor:function(e){this.request=e},setServiceClientId:function(e){this.serviceClientId=e},getServiceClientId:function(){return this.serviceClientId}}),r.Signers.RequestSigner.getVersion=function(e){switch(e){case"v2":return r.Signers.V2;case"v3":return r.Signers.V3;case"s3v4":case"v4":return r.Signers.V4;case"s3":return r.Signers.S3;case"v3https":return r.Signers.V3Https}throw new Error("Unknown signing version "+e)},e("./v2"),e("./v3"),e("./v3https"),e("./v4"),e("./s3"),e("./presign")},{"../core":19,"./presign":63,"./s3":65,"./v2":66,"./v3":67,"./v3https":68,"./v4":69}],65:[function(e,t,n){var r=e("../core"),o=r.util.inherit;r.Signers.S3=o(r.Signers.RequestSigner,{subResources:{acl:1,accelerate:1,analytics:1,cors:1,lifecycle:1,delete:1,inventory:1,location:1,logging:1,metrics:1,notification:1,partNumber:1,policy:1,requestPayment:1,replication:1,restore:1,tagging:1,torrent:1,uploadId:1,uploads:1,versionId:1,versioning:1,versions:1,website:1},responseHeaders:{"response-content-type":1,"response-content-language":1,"response-expires":1,"response-cache-control":1,"response-content-disposition":1,"response-content-encoding":1},addAuthorization:function(e,t){this.request.headers["presigned-expires"]||(this.request.headers["X-Amz-Date"]=r.util.date.rfc822(t)),e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken);var n=this.sign(e.secretAccessKey,this.stringToSign()),o="AWS "+e.accessKeyId+":"+n;this.request.headers.Authorization=o},stringToSign:function(){var e=this.request,t=[];t.push(e.method),t.push(e.headers["Content-MD5"]||""),t.push(e.headers["Content-Type"]||""),t.push(e.headers["presigned-expires"]||"");var n=this.canonicalizedAmzHeaders();return n&&t.push(n),t.push(this.canonicalizedResource()),t.join("\n")},canonicalizedAmzHeaders:function(){var e=[];r.util.each(this.request.headers,(function(t){t.match(/^x-amz-/i)&&e.push(t)})),e.sort((function(e,t){return e.toLowerCase()=0?"&":"?";this.request.path+=i+r.util.queryParamsToString(o)},authorization:function(e,t){var n=[],r=this.credentialString(t);return n.push(this.algorithm+" Credential="+e.accessKeyId+"/"+r),n.push("SignedHeaders="+this.signedHeaders()),n.push("Signature="+this.signature(e,t)),n.join(", ")},signature:function(e,t){var n=o.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return r.util.crypto.hmac(n,this.stringToSign(t),"hex")},stringToSign:function(e){var t=[];return t.push("AWS4-HMAC-SHA256"),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")},canonicalString:function(){var e=[],t=this.request.pathname();return"s3"!==this.serviceName&&"s3v4"!==this.signatureVersion&&(t=r.util.uriEscapePath(t)),e.push(this.request.method),e.push(t),e.push(this.request.search()),e.push(this.canonicalHeaders()+"\n"),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")},canonicalHeaders:function(){var e=[];r.util.each.call(this,this.request.headers,(function(t,n){e.push([t,n])})),e.sort((function(e,t){return e[0].toLowerCase()-1&&!e.body?"UNSIGNED-PAYLOAD":e.headers["X-Amz-Content-Sha256"]?e.headers["X-Amz-Content-Sha256"]:this.hexEncodedHash(this.request.body||"")},unsignableHeaders:["authorization","content-type","content-length","user-agent",s,"expect","x-amzn-trace-id"],isSignableHeader:function(e){return 0===e.toLowerCase().indexOf("x-amz-")||this.unsignableHeaders.indexOf(e)<0},isPresigned:function(){return!!this.request.headers[s]}}),t.exports=r.Signers.V4},{"../core":19,"./v4_credentials":70}],70:[function(e,t,n){var r=e("../core"),o={},i=[],s="aws4_request";t.exports={createScope:function(e,t,n){return[e.substr(0,8),t,n,s].join("/")},getSigningKey:function(e,t,n,a,c){var u=[r.util.crypto.hmac(e.secretAccessKey,e.accessKeyId,"base64"),t,n,a].join("_");if((c=!1!==c)&&u in o)return o[u];var l=r.util.crypto.hmac("AWS4"+e.secretAccessKey,t,"buffer"),p=r.util.crypto.hmac(l,n,"buffer"),d=r.util.crypto.hmac(p,a,"buffer"),h=r.util.crypto.hmac(d,s,"buffer");return c&&(o[u]=h,i.push(u),i.length>50&&delete o[i.shift()]),h},emptyCache:function(){o={},i=[]}}},{"../core":19}],71:[function(e,t,n){function r(e,t){this.currentState=t||null,this.states=e||{}}r.prototype.runTo=function(e,t,n,r){"function"==typeof e&&(r=n,n=t,t=e,e=null);var o=this,i=o.states[o.currentState];i.fn.call(n||o,r,(function(r){if(r){if(!i.fail)return t?t.call(n,r):null;o.currentState=i.fail}else{if(!i.accept)return t?t.call(n):null;o.currentState=i.accept}if(o.currentState===e)return t?t.call(n,r):null;o.runTo(e,t,n,r)}))},r.prototype.addState=function(e,t,n,r){return"function"==typeof t?(r=t,t=null,n=null):"function"==typeof n&&(r=n,n=null),this.currentState||(this.currentState=e),this.states[e]={accept:t,fail:n,fn:r},this},t.exports=r},{}],72:[function(e,t,n){(function(n,r){(function(){var o,i={environment:"nodejs",engine:function(){if(i.isBrowser()&&"undefined"!=typeof navigator)return navigator.userAgent;var e=n.platform+"/"+n.version;return n.env.AWS_EXECUTION_ENV&&(e+=" exec-env/"+n.env.AWS_EXECUTION_ENV),e},userAgent:function(){var t=i.environment,n="aws-sdk-"+t+"/"+e("./core").VERSION;return"nodejs"===t&&(n+=" "+i.engine()),n},uriEscape:function(e){var t=encodeURIComponent(e);return t=(t=t.replace(/[^A-Za-z0-9_.~\-%]+/g,escape)).replace(/[*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))},uriEscapePath:function(e){var t=[];return i.arrayEach(e.split("/"),(function(e){t.push(i.uriEscape(e))})),t.join("/")},urlParse:function(e){return i.url.parse(e)},urlFormat:function(e){return i.url.format(e)},queryStringParse:function(e){return i.querystring.parse(e)},queryParamsToString:function(e){var t=[],n=i.uriEscape,r=Object.keys(e).sort();return i.arrayEach(r,(function(r){var o=e[r],s=n(r),a=s+"=";if(Array.isArray(o)){var c=[];i.arrayEach(o,(function(e){c.push(n(e))})),a=s+"="+c.sort().join("&"+s+"=")}else null!=o&&(a=s+"="+n(o));t.push(a)})),t.join("&")},readFileSync:function(t){return i.isBrowser()?null:e("fs").readFileSync(t,"utf-8")},base64:{encode:function(e){if("number"==typeof e)throw i.error(new Error("Cannot base64 encode number "+e));return null==e?e:i.buffer.toBuffer(e).toString("base64")},decode:function(e){if("number"==typeof e)throw i.error(new Error("Cannot base64 decode number "+e));return null==e?e:i.buffer.toBuffer(e,"base64")}},buffer:{toBuffer:function(e,t){return"function"==typeof i.Buffer.from&&i.Buffer.from!==Uint8Array.from?i.Buffer.from(e,t):new i.Buffer(e,t)},alloc:function(e,t,n){if("number"!=typeof e)throw new Error("size passed to alloc must be a number.");if("function"==typeof i.Buffer.alloc)return i.Buffer.alloc(e,t,n);var r=new i.Buffer(e);return void 0!==t&&"function"==typeof r.fill&&r.fill(t,void 0,void 0,n),r},toStream:function(e){i.Buffer.isBuffer(e)||(e=i.buffer.toBuffer(e));var t=new i.stream.Readable,n=0;return t._read=function(r){if(n>=e.length)return t.push(null);var o=n+r;o>e.length&&(o=e.length),t.push(e.slice(n,o)),n=o},t},concat:function(e){var t,n,r=0,o=0;for(n=0;n>>8^t[255&(n^e.readUInt8(r))];return(-1^n)>>>0},hmac:function(e,t,n,r){return n||(n="binary"),"buffer"===n&&(n=void 0),r||(r="sha256"),"string"==typeof t&&(t=i.buffer.toBuffer(t)),i.crypto.lib.createHmac(r,e).update(t).digest(n)},md5:function(e,t,n){return i.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return i.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,r){var o=i.crypto.createHash(e);n||(n="binary"),"buffer"===n&&(n=void 0),"string"==typeof t&&(t=i.buffer.toBuffer(t));var s=i.arraySliceFn(t),a=i.Buffer.isBuffer(t);if(i.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(a=!0),r&&"object"==typeof t&&"function"==typeof t.on&&!a)t.on("data",(function(e){o.update(e)})),t.on("error",(function(e){r(e)})),t.on("end",(function(){r(null,o.digest(n))}));else{if(!r||!s||a||"undefined"==typeof FileReader){i.isBrowser()&&"object"==typeof t&&!a&&(t=new i.Buffer(new Uint8Array(t)));var c=o.update(t).digest(n);return r&&r(null,c),c}var u=0,l=new FileReader;l.onerror=function(){r(new Error("Failed to read data."))},l.onload=function(){var e=new i.Buffer(new Uint8Array(l.result));o.update(e),u+=e.length,l._continueReading()},l._continueReading=function(){if(u>=t.size)r(null,o.digest(n));else{var e=u+524288;e>t.size&&(e=t.size),l.readAsArrayBuffer(s.call(t,u,e))}},l._continueReading()}},toHex:function(e){for(var t=[],n=0;n=3e5,!1),o.config.isClockSkewed},applyClockOffset:function(e){e&&(o.config.systemClockOffset=e-(new Date).getTime())},extractRequestId:function(e){var t=e.httpResponse.headers["x-amz-request-id"]||e.httpResponse.headers["x-amzn-requestid"];!t&&e.data&&e.data.ResponseMetadata&&(t=e.data.ResponseMetadata.RequestId),t&&(e.requestId=t),e.error&&(e.error.requestId=t)},addPromises:function(e,t){var n=!1;void 0===t&&o&&o.config&&(t=o.config.getPromisesDependency()),void 0===t&&"undefined"!=typeof Promise&&(t=Promise),"function"!=typeof t&&(n=!0),Array.isArray(e)||(e=[e]);for(var r=0;r=0)return a++,void setTimeout(u,o+(e.retryAfter||0))}n(e)},u=function(){var t="";r.handleRequest(e,s,(function(e){e.on("data",(function(e){t+=e.toString()})),e.on("end",(function(){var r=e.statusCode;if(r<300)n(null,t);else{var o=1e3*parseInt(e.headers["retry-after"],10)||0,s=i.error(new Error,{statusCode:r,retryable:r>=500||429===r});o&&s.retryable&&(s.retryAfter=o),c(s)}}))}),c)};o.util.defer(u)},uuid:{v4:function(){return e("uuid").v4()}},convertPayloadToString:function(e){var t=e.request,n=t.operation,r=t.service.api.operations[n].output||{};r.payload&&e.data[r.payload]&&(e.data[r.payload]=e.data[r.payload].toString())},defer:function(e){"object"==typeof n&&"function"==typeof n.nextTick?n.nextTick(e):"function"==typeof r?r(e):setTimeout(e,0)},getRequestPayloadShape:function(e){var t=e.service.api.operations;if(t){var n=(t||{})[e.operation];if(n&&n.input&&n.input.payload)return n.input.members[n.input.payload]}},getProfilesFromSharedConfig:function(e,t){var r={},o={};n.env[i.configOptInEnv]&&(o=e.loadFrom({isConfig:!0,filename:n.env[i.sharedConfigFileEnv]}));var s={};try{s=e.loadFrom({filename:t||n.env[i.configOptInEnv]&&n.env[i.sharedCredentialsFileEnv]})}catch(e){if(!n.env[i.configOptInEnv])throw e}for(var a=0,c=Object.keys(o);a=6},parse:function(e){var t=e.split(":");return{partition:t[1],service:t[2],region:t[3],accountId:t[4],resource:t.slice(5).join(":")}},build:function(e){if(void 0===e.service||void 0===e.region||void 0===e.accountId||void 0===e.resource)throw i.error(new Error("Input ARN object is invalid"));return"arn:"+(e.partition||"aws")+":"+e.service+":"+e.region+":"+e.accountId+":"+e.resource}},defaultProfile:"default",configOptInEnv:"AWS_SDK_LOAD_CONFIG",sharedCredentialsFileEnv:"AWS_SHARED_CREDENTIALS_FILE",sharedConfigFileEnv:"AWS_CONFIG_FILE",imdsDisabledEnv:"AWS_EC2_METADATA_DISABLED"};t.exports=i}).call(this)}).call(this,e("_process"),e("timers").setImmediate)},{"../apis/metadata.json":4,"./core":19,_process:90,fs:80,timers:97,uuid:100}],73:[function(e,t,n){var r=e("../util"),o=e("../model/shape");function i(){}function s(e,t){for(var n=e.getElementsByTagName(t),r=0,o=n.length;r0||r?i.toString():""},t.exports=s},{"../util":72,"./xml-node":77,"./xml-text":78}],75:[function(e,t,n){t.exports={escapeAttribute:function(e){return e.replace(/&/g,"&").replace(/'/g,"'").replace(//g,">").replace(/"/g,""")}}},{}],76:[function(e,t,n){t.exports={escapeElement:function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/\r/g," ").replace(/\n/g," ").replace(/\u0085/g,"…").replace(/\u2028/,"
")}}},{}],77:[function(e,t,n){var r=e("./escape-attribute").escapeAttribute;function o(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}o.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},o.prototype.addChildNode=function(e){return this.children.push(e),this},o.prototype.removeAttribute=function(e){return delete this.attributes[e],this},o.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,o=0,i=Object.keys(n);o"+this.children.map((function(e){return e.toString()})).join("")+"":"/>")},t.exports={XmlNode:o}},{"./escape-attribute":75}],78:[function(e,t,n){var r=e("./escape-element").escapeElement;function o(e){this.value=e}o.prototype.toString=function(){return r(""+this.value)},t.exports={XmlText:o}},{"./escape-element":76}],79:[function(e,t,n){"use strict";n.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=u(e),s=r[0],a=r[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),l=0,p=a>0?s-4:s;for(n=0;n>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},n.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,c=n-o;ac?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var o,i,s=[],a=t;a>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],80:[function(e,t,n){},{}],81:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],82:[function(e,t,o){(function(e){(function(){!function(i){"object"==typeof o&&o&&o.nodeType,"object"==typeof t&&t&&t.nodeType;var s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self;var a,c=2147483647,u=36,l=/^xn--/,p=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=Math.floor,g=String.fromCharCode;function m(e){throw RangeError(h[e])}function v(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function y(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+v((e=e.replace(d,".")).split("."),t).join(".")}function E(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(t+=g((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=g(e)})).join("")}function b(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function T(e,t,n){var r=0;for(e=n?f(e/700):e>>1,e+=f(e/t);e>455;r+=u)e=f(e/35);return f(r+36*e/(e+38))}function C(e){var t,n,r,o,i,s,a,l,p,d,h,g=[],v=e.length,y=0,E=128,b=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r=128&&m("not-basic"),g.push(e.charCodeAt(r));for(o=n>0?n+1:0;o=v&&m("invalid-input"),((l=(h=e.charCodeAt(o++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:u)>=u||l>f((c-y)/s))&&m("overflow"),y+=l*s,!(l<(p=a<=b?1:a>=b+26?26:a-b));a+=u)s>f(c/(d=u-p))&&m("overflow"),s*=d;b=T(y-i,t=g.length+1,0==i),f(y/t)>c-E&&m("overflow"),E+=f(y/t),y%=t,g.splice(y++,0,E)}return S(g)}function I(e){var t,n,r,o,i,s,a,l,p,d,h,v,y,S,C,I=[];for(v=(e=E(e)).length,t=128,n=0,i=72,s=0;s=t&&hf((c-n)/(y=r+1))&&m("overflow"),n+=(a-t)*y,t=a,s=0;sc&&m("overflow"),h==t){for(l=n,p=u;!(l<(d=p<=i?1:p>=i+26?26:p-i));p+=u)C=l-d,S=u-d,I.push(g(b(d+C%S,0))),l=f(C/S);I.push(g(b(l,0))),i=T(n,y,r==o),n=0,++r}++n,++t}return I.join("")}a={version:"1.3.2",ucs2:{decode:E,encode:S},decode:C,encode:I,toASCII:function(e){return y(e,(function(e){return p.test(e)?"xn--"+I(e):e}))},toUnicode:function(e){return y(e,(function(e){return l.test(e)?C(e.slice(4).toLowerCase()):e}))}},void 0===(r=function(){return a}.call(o,n,o,t))||(t.exports=r)}()}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],83:[function(e,t,n){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],84:[function(e,t,r){(function(t,n){(function(){var o=/%[sdj%]/g;r.format=function(e){if(!v(e)){for(var t=[],n=0;n=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),c=r[n];n=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),f(t)?n.showHidden=t:t&&r._extend(n,t),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),l(n,e,n.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function u(e,t){return e}function l(e,t,n){if(e.customInspect&&t&&C(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(n,e);return v(o)||(o=l(e,o,n)),o}var i=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):f(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var s=Object.keys(t),a=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),T(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return p(t);if(0===s.length){if(C(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(E(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(b(t))return e.stylize(Date.prototype.toString.call(t),"date");if(T(t))return p(t)}var u,S="",I=!1,_=["{","}"];return h(t)&&(I=!0,_=["[","]"]),C(t)&&(S=" [Function"+(t.name?": "+t.name:"")+"]"),E(t)&&(S=" "+RegExp.prototype.toString.call(t)),b(t)&&(S=" "+Date.prototype.toUTCString.call(t)),T(t)&&(S=" "+p(t)),0!==s.length||I&&0!=t.length?n<0?E(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=I?function(e,t,n,r,o){for(var i=[],s=0,a=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(u,S,_)):_[0]+S+_[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,r,o,i){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),R(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=g(n)?l(e,c.value,null):l(e,c.value,n-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),y(s)){if(i&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function h(e){return Array.isArray(e)}function f(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function v(e){return"string"==typeof e}function y(e){return void 0===e}function E(e){return S(e)&&"[object RegExp]"===I(e)}function S(e){return"object"==typeof e&&null!==e}function b(e){return S(e)&&"[object Date]"===I(e)}function T(e){return S(e)&&("[object Error]"===I(e)||e instanceof Error)}function C(e){return"function"==typeof e}function I(e){return Object.prototype.toString.call(e)}function _(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(y(i)&&(i=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var n=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else s[e]=function(){};return s[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=h,r.isBoolean=f,r.isNull=g,r.isNullOrUndefined=function(e){return null==e},r.isNumber=m,r.isString=v,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=y,r.isRegExp=E,r.isObject=S,r.isDate=b,r.isError=T,r.isFunction=C,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function w(){var e=new Date,t=[_(e.getHours()),_(e.getMinutes()),_(e.getSeconds())].join(":");return[e.getDate(),A[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){console.log("%s - %s",w(),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this)}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":83,_process:90,inherits:81}],85:[function(e,t,r){(function(t,n){(function(){"use strict";var n=e("base64-js"),o=e("ieee754"),i=e("isarray");function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return B(e).length;default:if(r)return j(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return R(this,t,n);case"latin1":case"binary":return k(this,t,n);case"base64":return _(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function m(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,o);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=n;ia&&(n=a-c),i=n;i>=0;i--){for(var p=!0,d=0;do&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function _(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o239?4:u>223?3:u>191?2:1;if(o+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=p}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);for(var n="",r=0;r0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},c.prototype.compare=function(e,t,n,r,o){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(r,o),l=e.slice(t,n),p=0;po)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return b(this,e,t,n);case"latin1":case"binary":return T(this,e,t,n);case"base64":return C(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function R(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;oo)&&(n=o);for(var i="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,n,r,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function P(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function x(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function M(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,r,i){return i||M(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,i){return i||M(e,0,n,8),o.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)r+=this[e+--t]*o;return r},c.prototype.readUInt8=function(e,t){return t||L(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||L(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||L(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||L(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var r=this[e],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||L(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||L(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||L(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||L(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||L(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||L(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||L(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||D(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function B(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"base64-js":79,buffer:85,ieee754:87,isarray:88}],86:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function i(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,a,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(s(n=this._events[e]))return!1;if(o(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(i(n))for(a=Array.prototype.slice.call(arguments,1),r=(u=n.slice()).length,c=0;c0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!o(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(n=this._events[e]).length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(o(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],87:[function(e,t,n){n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<>1,l=-7,p=n?o-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,u=8*i-o-1,l=(1<>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(a=0,s=l):s+p>=1?(a=(t*c-1)*Math.pow(2,o),s+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,o),s=0));o>=8;e[n+h]=255&a,h+=f,a/=256,o-=8);for(s=s<0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*g}},{}],88:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],89:[function(e,t,n){!function(e){"use strict";function t(e){return null!==e&&"[object Array]"===Object.prototype.toString.call(e)}function n(e){return null!==e&&"[object Object]"===Object.prototype.toString.call(e)}function r(e,o){if(e===o)return!0;if(Object.prototype.toString.call(e)!==Object.prototype.toString.call(o))return!1;if(!0===t(e)){if(e.length!==o.length)return!1;for(var i=0;i",9:"Array"},u="EOF",l="UnquotedIdentifier",p="QuotedIdentifier",d="Rbracket",h="Rparen",f="Comma",g="Colon",m="Rbrace",v="Number",y="Current",E="Expref",S="Pipe",b="Or",T="And",C="EQ",I="GT",_="LT",A="GTE",w="LTE",R="NE",k="Flatten",N="Star",O="Filter",L="Dot",D="Not",P="Lbrace",x="Lbracket",M="Lparen",U="Literal",F={".":L,"*":N,",":f,":":g,"{":P,"}":m,"]":d,"(":M,")":h,"@":y},q={"<":!0,">":!0,"=":!0,"!":!0},j={" ":!0,"\t":!0,"\n":!0};function B(e){return e>="0"&&e<="9"||"-"===e}function V(){}V.prototype={tokenize:function(e){var t,n,r,o,i=[];for(this._current=0;this._current="a"&&o<="z"||o>="A"&&o<="Z"||"_"===o)t=this._current,n=this._consumeUnquotedIdentifier(e),i.push({type:l,value:n,start:t});else if(void 0!==F[e[this._current]])i.push({type:F[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(B(e[this._current]))r=this._consumeNumber(e),i.push(r);else if("["===e[this._current])r=this._consumeLBracket(e),i.push(r);else if('"'===e[this._current])t=this._current,n=this._consumeQuotedIdentifier(e),i.push({type:p,value:n,start:t});else if("'"===e[this._current])t=this._current,n=this._consumeRawStringLiteral(e),i.push({type:U,value:n,start:t});else if("`"===e[this._current]){t=this._current;var s=this._consumeLiteral(e);i.push({type:U,value:s,start:t})}else if(void 0!==q[e[this._current]])i.push(this._consumeOperator(e));else if(void 0!==j[e[this._current]])this._current++;else if("&"===e[this._current])t=this._current,this._current++,"&"===e[this._current]?(this._current++,i.push({type:T,value:"&&",start:t})):i.push({type:E,value:"&",start:t});else{if("|"!==e[this._current]){var a=new Error("Unknown character:"+e[this._current]);throw a.name="LexerError",a}t=this._current,this._current++,"|"===e[this._current]?(this._current++,i.push({type:b,value:"||",start:t})):i.push({type:S,value:"|",start:t})}return i},_consumeUnquotedIdentifier:function(e){var t,n=this._current;for(this._current++;this._current="a"&&t<="z"||t>="A"&&t<="Z"||t>="0"&&t<="9"||"_"===t);)this._current++;return e.slice(n,this._current)},_consumeQuotedIdentifier:function(e){var t=this._current;this._current++;for(var n=e.length;'"'!==e[this._current]&&this._current"===n?"="===e[this._current]?(this._current++,{type:A,value:">=",start:t}):{type:I,value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:C,value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t,n=this._current,r=e.length;"`"!==e[this._current]&&this._current=0)return!0;if(["true","false","null"].indexOf(e)>=0)return!0;if(!("-0123456789".indexOf(e[0])>=0))return!1;try{return JSON.parse(e),!0}catch(e){return!1}}};var W={};function H(){}function z(e){this.runtime=e}function G(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[s]}]},avg:{_func:this._functionAvg,_signature:[{types:[8]}]},ceil:{_func:this._functionCeil,_signature:[{types:[s]}]},contains:{_func:this._functionContains,_signature:[{types:[a,3]},{types:[1]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[a]},{types:[a]}]},floor:{_func:this._functionFloor,_signature:[{types:[s]}]},length:{_func:this._functionLength,_signature:[{types:[a,3,4]}]},map:{_func:this._functionMap,_signature:[{types:[6]},{types:[3]}]},max:{_func:this._functionMax,_signature:[{types:[8,9]}]},merge:{_func:this._functionMerge,_signature:[{types:[4],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[3]},{types:[6]}]},sum:{_func:this._functionSum,_signature:[{types:[8]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[a]},{types:[a]}]},min:{_func:this._functionMin,_signature:[{types:[8,9]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[3]},{types:[6]}]},type:{_func:this._functionType,_signature:[{types:[1]}]},keys:{_func:this._functionKeys,_signature:[{types:[4]}]},values:{_func:this._functionValues,_signature:[{types:[4]}]},sort:{_func:this._functionSort,_signature:[{types:[9,8]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[3]},{types:[6]}]},join:{_func:this._functionJoin,_signature:[{types:[a]},{types:[9]}]},reverse:{_func:this._functionReverse,_signature:[{types:[a,3]}]},to_array:{_func:this._functionToArray,_signature:[{types:[1]}]},to_string:{_func:this._functionToString,_signature:[{types:[1]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[1]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[1],variadic:!0}]}}}W.EOF=0,W.UnquotedIdentifier=0,W.QuotedIdentifier=0,W.Rbracket=0,W.Rparen=0,W.Comma=0,W.Rbrace=0,W.Number=0,W.Current=0,W.Expref=0,W.Pipe=1,W.Or=2,W.And=3,W.EQ=5,W.GT=5,W.LT=5,W.GTE=5,W.LTE=5,W.NE=5,W.Flatten=9,W.Star=20,W.Filter=21,W.Dot=40,W.Not=45,W.Lbrace=50,W.Lbracket=55,W.Lparen=60,H.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if(this._lookahead(0)!==u){var n=this._lookaheadToken(0),r=new Error("Unexpected token type: "+n.type+", value: "+n.value);throw r.name="ParserError",r}return t},_loadTokens:function(e){var t=(new V).tokenize(e);t.push({type:u,value:"",start:e.length}),this.tokens=t},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var n=this.nud(t),r=this._lookahead(0);e=0?this.expression(e):t===x?(this._match(x),this._parseMultiselectList()):t===P?(this._match(P),this._parseMultiselectHash()):void 0},_parseProjectionRHS:function(e){var t;if(W[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===x)t=this.expression(e);else if(this._lookahead(0)===O)t=this.expression(e);else{if(this._lookahead(0)!==L){var n=this._lookaheadToken(0),r=new Error("Sytanx error, unexpected token: "+n.value+"("+n.type+")");throw r.name="ParserError",r}this._match(L),t=this._parseDotRHS(e)}return t},_parseMultiselectList:function(){for(var e=[];this._lookahead(0)!==d;){var t=this.expression(0);if(e.push(t),this._lookahead(0)===f&&(this._match(f),this._lookahead(0)===d))throw new Error("Unexpected token Rbracket")}return this._match(d),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e,t,n,r=[],o=[l,p];;){if(e=this._lookaheadToken(0),o.indexOf(e.type)<0)throw new Error("Expecting an identifier token, got: "+e.type);if(t=e.value,this._advance(),this._match(g),n={type:"KeyValuePair",name:t,value:this.expression(0)},r.push(n),this._lookahead(0)===f)this._match(f);else if(this._lookahead(0)===m){this._match(m);break}}return{type:"MultiSelectHash",children:r}}},z.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,i){var s,a,c,u,l,p,d,h,f;switch(e.type){case"Field":return null!==i&&n(i)?void 0===(p=i[e.name])?null:p:null;case"Subexpression":for(c=this.visit(e.children[0],i),f=1;f0)for(f=b;fT;f+=N)c.push(i[f]);return c;case"Projection":var O=this.visit(e.children[0],i);if(!t(O))return null;for(h=[],f=0;fl;break;case A:c=u>=l;break;case _:c=u=e&&(t=n<0?e-1:e),t}},G.prototype={callFunction:function(e,t){var n=this.functionTable[e];if(void 0===n)throw new Error("Unknown function: "+e+"()");return this._validateArgs(e,t,n._signature),n._func.call(this,t)},_validateArgs:function(e,t,n){var r,o,i,s;if(n[n.length-1].variadic){if(t.length=0;r--)n+=t[r];return n}var o=e[0].slice(0);return o.reverse(),o},_functionAbs:function(e){return Math.abs(e[0])},_functionCeil:function(e){return Math.ceil(e[0])},_functionAvg:function(e){for(var t=0,n=e[0],r=0;r=0},_functionFloor:function(e){return Math.floor(e[0])},_functionLength:function(e){return n(e[0])?Object.keys(e[0]).length:e[0].length},_functionMap:function(e){for(var t=[],n=this._interpreter,r=e[0],o=e[1],i=0;i0){if(this._getTypeName(e[0][0])===s)return Math.max.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;r0){if(this._getTypeName(e[0][0])===s)return Math.min.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;ra?1:sc&&(c=n,t=o[u]);return t},_functionMinBy:function(e){for(var t,n,r=e[1],o=e[0],i=this.createKeyFunction(r,[s,a]),c=1/0,u=0;u1)for(var n=1;n0&&u>c&&(u=c);for(var l=0;l=0?(p=g.substr(0,m),d=g.substr(m+1)):(p=g,d=""),h=decodeURIComponent(p),f=decodeURIComponent(d),r(s,h)?o(s[h])?s[h].push(f):s[h]=[s[h],f]:s[h]=f}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],92:[function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r0&&c>a&&(c=a);for(var u=0;u=0?(l=f.substr(0,g),p=f.substr(g+1)):(l=f,p=""),d=decodeURIComponent(l),h=decodeURIComponent(p),r(i,d)?Array.isArray(i[d])?i[d].push(h):i[d]=[i[d],h]:i[d]=h}return i}},{}],95:[function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,o){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(o){var i=encodeURIComponent(r(o))+n;return Array.isArray(e[o])?e[o].map((function(e){return i+encodeURIComponent(r(e))})).join(t):i+encodeURIComponent(r(e[o]))})).join(t):o?encodeURIComponent(r(o))+n+encodeURIComponent(r(e)):""}},{}],96:[function(e,t,n){arguments[4][93][0].apply(n,arguments)},{"./decode":94,"./encode":95,dup:93}],97:[function(e,t,n){(function(t,r){(function(){var o=e("process/browser.js").nextTick,i=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function u(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new u(i.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new u(i.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n.setImmediate="function"==typeof t?t:function(e){var t=c++,r=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,o((function(){a[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"==typeof r?r:function(e){delete a[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":90,timers:97}],98:[function(e,t,n){var r=e("punycode");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}n.parse=v,n.resolve=function(e,t){return v(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?v(e,!1,!0).resolveObject(t):t},n.format=function(e){return y(e)&&(e=v(e)),e instanceof o?e.format():o.prototype.format.call(e)},n.Url=o;var i=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(a),u=["%","/","?",";","#"].concat(c),l=["/","?","#"],p=/^[a-z0-9A-Z_-]{0,63}$/,d=/^([a-z0-9A-Z_-]{0,63})(.*)$/,h={javascript:!0,"javascript:":!0},f={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=e("querystring");function v(e,t,n){if(e&&E(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}function y(e){return"string"==typeof e}function E(e){return"object"==typeof e&&null!==e}function S(e){return null===e}o.prototype.parse=function(e,t,n){if(!y(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e;o=o.trim();var s=i.exec(o);if(s){var a=(s=s[0]).toLowerCase();this.protocol=a,o=o.substr(s.length)}if(n||s||o.match(/^\/\/[^@\/]+@[^@\/]+/)){var v="//"===o.substr(0,2);!v||s&&f[s]||(o=o.substr(2),this.slashes=!0)}if(!f[s]&&(v||s&&!g[s])){for(var E,S,b=-1,T=0;T127?R+="x":R+=w[k];if(!R.match(p)){var O=_.slice(0,T),L=_.slice(T+1),D=w.match(d);D&&(O.push(D[1]),L.unshift(D[2])),L.length&&(o="/"+L.join(".")+o),this.hostname=O.join(".");break}}}if(this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),!I){var P=this.hostname.split("."),x=[];for(T=0;T0)&&n.host.split("@"))&&(n.auth=b.shift(),n.host=n.hostname=b.shift())),n.search=e.search,n.query=e.query,S(n.pathname)&&S(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!p.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var h=p.slice(-1)[0],m=(n.host||e.host)&&("."===h||".."===h)||""===h,v=0,E=p.length;E>=0;E--)"."==(h=p[E])?p.splice(E,1):".."===h?(p.splice(E,1),v++):v&&(p.splice(E,1),v--);if(!u&&!l)for(;v--;v)p.unshift("..");!u||""===p[0]||p[0]&&"/"===p[0].charAt(0)||p.unshift(""),m&&"/"!==p.join("/").substr(-1)&&p.push("");var b,T=""===p[0]||p[0]&&"/"===p[0].charAt(0);return d&&(n.hostname=n.host=T?"":p.length?p.shift():"",(b=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=b.shift(),n.host=n.hostname=b.shift())),(u=u||n.host&&p.length)&&!T&&p.unshift(""),p.length?n.pathname=p.join("/"):(n.pathname=null,n.path=null),S(n.pathname)&&S(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{punycode:82,querystring:93}],99:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;for(var r=[],o=0;o<256;++o)r[o]=(o+256).toString(16).substr(1);var i=function(e,t){var n=t||0,o=r;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")};n.default=i},{}],100:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"v1",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(n,"v3",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(n,"v4",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(n,"v5",{enumerable:!0,get:function(){return s.default}});var r=a(e("./v1.js")),o=a(e("./v3.js")),i=a(e("./v4.js")),s=a(e("./v5.js"));function a(e){return e&&e.__esModule?e:{default:e}}},{"./v1.js":104,"./v3.js":105,"./v4.js":107,"./v5.js":108}],101:[function(e,t,n){"use strict";function r(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function o(e,t,n,o,i,s){return r((a=r(r(t,e),r(o,s)))<<(c=i)|a>>>32-c,n);var a,c}function i(e,t,n,r,i,s,a){return o(t&n|~t&r,e,t,i,s,a)}function s(e,t,n,r,i,s,a){return o(t&r|n&~r,e,t,i,s,a)}function a(e,t,n,r,i,s,a){return o(t^n^r,e,t,i,s,a)}function c(e,t,n,r,i,s,a){return o(n^(t|~r),e,t,i,s,a)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var u=function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Array(t.length);for(var n=0;n>5]>>>t%32&255,r=parseInt(s.charAt(n>>>4&15)+s.charAt(15&n),16),o.push(r);return o}(function(e,t){var n,o,u,l,p;e[t>>5]|=128<>>9<<4)]=t;var d=1732584193,h=-271733879,f=-1732584194,g=271733878;for(n=0;n>2)-1]=void 0,t=0;t>5]|=(255&e[t/8])<>>32-t}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var i=function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=new Array(i.length);for(var s=0;s>>0;v=m,m=g,g=o(f,30)>>>0,f=h,h=E}n[0]=n[0]+h>>>0,n[1]=n[1]+f>>>0,n[2]=n[2]+g>>>0,n[3]=n[3]+m>>>0,n[4]=n[4]+v>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]};n.default=i},{}],104:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r,o,i=a(e("./rng.js")),s=a(e("./bytesToUuid.js"));function a(e){return e&&e.__esModule?e:{default:e}}var c=0,u=0,l=function(e,t,n){var a=t&&n||0,l=t||[],p=(e=e||{}).node||r,d=void 0!==e.clockseq?e.clockseq:o;if(null==p||null==d){var h=e.random||(e.rng||i.default)();null==p&&(p=r=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==d&&(d=o=16383&(h[6]<<8|h[7]))}var f=void 0!==e.msecs?e.msecs:(new Date).getTime(),g=void 0!==e.nsecs?e.nsecs:u+1,m=f-c+(g-u)/1e4;if(m<0&&void 0===e.clockseq&&(d=d+1&16383),(m<0||f>c)&&void 0===e.nsecs&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=f,u=g,o=d;var v=(1e4*(268435455&(f+=122192928e5))+g)%4294967296;l[a++]=v>>>24&255,l[a++]=v>>>16&255,l[a++]=v>>>8&255,l[a++]=255&v;var y=f/4294967296*1e4&268435455;l[a++]=y>>>8&255,l[a++]=255&y,l[a++]=y>>>24&15|16,l[a++]=y>>>16&255,l[a++]=d>>>8|128,l[a++]=255&d;for(var E=0;E<6;++E)l[a+E]=p[E];return t||(0,s.default)(l)};n.default=l},{"./bytesToUuid.js":99,"./rng.js":102}],105:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=i(e("./v35.js")),o=i(e("./md5.js"));function i(e){return e&&e.__esModule?e:{default:e}}var s=(0,r.default)("v3",48,o.default);n.default=s},{"./md5.js":101,"./v35.js":106}],106:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){var r=function(e,r,i,s){var a=i&&s||0;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=new Array(e.length),n=0;n=0;i--)o[i].Expire{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.ClientMethods=t.makeEnum(["getAgentSnapshot","putAgentState","getAgentStates","getDialableCountryCodes","getRoutingProfileQueues","getAgentPermissions","getAgentConfiguration","updateAgentConfiguration","acceptContact","createOutboundContact","createTaskContact","clearContact","completeContact","destroyContact","rejectContact","notifyContactIssue","updateContactAttributes","createAdditionalConnection","destroyConnection","holdConnection","resumeConnection","toggleActiveConnections","conferenceConnections","sendClientLogs","sendDigits","sendSoftphoneCallReport","sendSoftphoneCallMetrics","getEndpoints","getNewAuthToken","createTransport","muteParticipant","unmuteParticipant","updateMonitorParticipantState"]),t.AgentAppClientMethods={GET_CONTACT:"AgentAppService.Lcms.getContact",DELETE_SPEAKER:"AgentAppService.VoiceId.deleteSpeaker",ENROLL_BY_SESSION:"AgentAppService.VoiceId.enrollBySession",EVALUATE_SESSION:"AgentAppService.VoiceId.evaluateSession",DESCRIBE_SPEAKER:"AgentAppService.VoiceId.describeSpeaker",OPT_OUT_SPEAKER:"AgentAppService.VoiceId.optOutSpeaker",UPDATE_VOICE_ID_DATA:"AgentAppService.Lcms.updateVoiceIdData",DESCRIBE_SESSION:"AgentAppService.VoiceId.describeSession",UPDATE_SESSION:"AgentAppService.VoiceId.updateSession",START_VOICE_ID_SESSION:"AgentAppService.Nasa.startVoiceIdSession",LIST_INTEGRATION_ASSOCIATIONS:"AgentAppService.Acs.listIntegrationAssociations"},t.MasterMethods=t.makeEnum(["becomeMaster","checkMaster"]),t.TaskTemplatesClientMethods=t.makeEnum(["listTaskTemplates","getTaskTemplate","createTemplatedTask","updateContact"]);var n=function(){};n.EMPTY_CALLBACKS={success:function(){},failure:function(){}},n.prototype.call=function(e,r,o){t.assertNotNull(e,"method");var i=r||{},s=o||n.EMPTY_CALLBACKS;this._callImpl(e,i,s)},n.prototype._callImpl=function(e,n,r){throw new t.NotImplementedError};var r=function(){n.call(this)};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype._callImpl=function(e,n,r){if(r&&r.failure){var o=t.sprintf("No such method exists on NULL client: %s",e);r.failure(new t.ValueError(o),{message:o})}};var o=function(e,r,o){n.call(this),this.conduit=e,this.requestEvent=r,this.responseEvent=o,this._requestIdCallbacksMap={},this.conduit.onUpstream(o,t.hitch(this,this._handleResponse))};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype._callImpl=function(e,n,r){var o=t.EventFactory.createRequest(this.requestEvent,e,n);this._requestIdCallbacksMap[o.requestId]=r,this.conduit.sendUpstream(o.event,o)},o.prototype._getCallbacksForRequest=function(e){var t=this._requestIdCallbacksMap[e]||null;return null!=t&&delete this._requestIdCallbacksMap[e],t},o.prototype._handleResponse=function(e){var t=this._getCallbacksForRequest(e.requestId);null!=t&&(e.err&&t.failure?t.failure(e.err,e.data):t.success&&t.success(e.data))};var i=function(e){o.call(this,e,t.EventType.API_REQUEST,t.EventType.API_RESPONSE)};(i.prototype=Object.create(o.prototype)).constructor=i;var s=function(e){o.call(this,e,t.EventType.MASTER_REQUEST,t.EventType.MASTER_RESPONSE)};(s.prototype=Object.create(o.prototype)).constructor=s;var a=function(e,r,o){t.assertNotNull(e,"authCookieName"),t.assertNotNull(r,"authToken"),t.assertNotNull(o,"endpoint"),n.call(this),this.endpointUrl=t.getUrlWithProtocol(o),this.authToken=r,this.authCookieName=e};(a.prototype=Object.create(n.prototype)).constructor=a,a.prototype._callImpl=function(e,n,r){var o=this,i={};i[o.authCookieName]=o.authToken;var s={method:"post",body:JSON.stringify(n||{}),headers:{Accept:"application/json","Content-Type":"application/json","X-Amz-target":e,"X-Amz-Bearer":JSON.stringify(i)}};t.fetch(o.endpointUrl,s).then((function(e){r.success(e)})).catch((function(e){const t=e.body.getReader();let n="";const o=new TextDecoder;t.read().then((function i({done:s,value:a}){if(s){var c=JSON.parse(n);return c.status=e.status,void r.failure(c)}return n+=o.decode(a),t.read().then(i)}))}))};var c=function(e,r,o){t.assertNotNull(e,"authToken"),t.assertNotNull(r,"region"),n.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=r,this.authToken=e;var i=t.getBaseUrl(),s=o||(i.includes(".awsapps.com")?i+"/connect/api":i+"/api"),a=new AWS.Endpoint(s);this.client=new AWS.Connect({endpoint:a})};(c.prototype=Object.create(n.prototype)).constructor=c,c.prototype._callImpl=function(e,n,r){var o=this,i=t.getLog();if(t.contains(this.client,e))n=this._translateParams(e,n),i.trace("AWSClient: --\x3e Calling operation '%s'",e).sendInternalLogToServer(),this.client[e](n).on("build",(function(e){e.httpRequest.headers["X-Amz-Bearer"]=o.authToken})).send((function(n,o){try{if(n){if(n.code===t.CTIExceptions.UNAUTHORIZED_EXCEPTION)r.authFailure();else if(!r.accessDenied||n.code!==t.CTIExceptions.ACCESS_DENIED_EXCEPTION&&403!==n.statusCode){var s={};if(s.type=n.code,s.message=n.message,s.stack=[],n.stack)try{Array.isArray(n.stack)?s.stack=n.stack:"object"==typeof n.stack?s.stack=[JSON.stringify(n.stack)]:"string"==typeof n.stack&&(s.stack=n.stack.split("\n"))}catch{}r.failure(s,o)}else r.accessDenied();i.trace("AWSClient: <-- Operation '%s' failed: %s",e,JSON.stringify(n)).sendInternalLogToServer()}else i.trace("AWSClient: <-- Operation '%s' succeeded.",e).withObject(o).sendInternalLogToServer(),r.success(o)}catch(n){t.getLog().error("Failed to handle AWS API request for method %s",e).withException(n).sendInternalLogToServer()}}));else{var s=t.sprintf("No such method exists on AWS client: %s",e);r.failure(new t.ValueError(s),{message:s})}},c.prototype._requiresAuthenticationParam=function(e){return e!==t.ClientMethods.COMPLETE_CONTACT&&e!==t.ClientMethods.CLEAR_CONTACT&&e!==t.ClientMethods.REJECT_CONTACT&&e!==t.ClientMethods.CREATE_TASK_CONTACT&&e!==t.ClientMethods.UPDATE_MONITOR_PARTICIPANT_STATE},c.prototype._translateParams=function(e,n){switch(e){case t.ClientMethods.UPDATE_AGENT_CONFIGURATION:n.configuration=this._translateAgentConfiguration(n.configuration);break;case t.ClientMethods.SEND_SOFTPHONE_CALL_METRICS:n.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(n.softphoneStreamStatistics);break;case t.ClientMethods.SEND_SOFTPHONE_CALL_REPORT:n.report=this._translateSoftphoneCallReport(n.report)}return this._requiresAuthenticationParam(e)&&(n.authentication={authToken:this.authToken}),n},c.prototype._translateAgentConfiguration=function(e){return{name:e.name,softphoneEnabled:e.softphoneEnabled,softphoneAutoAccept:e.softphoneAutoAccept,extension:e.extension,routingProfile:this._translateRoutingProfile(e.routingProfile),agentPreferences:e.agentPreferences}},c.prototype._translateRoutingProfile=function(e){return{name:e.name,routingProfileARN:e.routingProfileARN,defaultOutboundQueue:this._translateQueue(e.defaultOutboundQueue)}},c.prototype._translateQueue=function(e){return{queueARN:e.queueARN,name:e.name}},c.prototype._translateSoftphoneStreamStatistics=function(e){return e.forEach((function(e){"packetsCount"in e&&(e.packetCount=e.packetsCount,delete e.packetsCount)})),e},c.prototype._translateSoftphoneCallReport=function(e){return"handshakingTimeMillis"in e&&(e.handshakeTimeMillis=e.handshakingTimeMillis,delete e.handshakingTimeMillis),"preTalkingTimeMillis"in e&&(e.preTalkTimeMillis=e.preTalkingTimeMillis,delete e.preTalkingTimeMillis),"handshakingFailure"in e&&(e.handshakeFailure=e.handshakingFailure,delete e.handshakingFailure),"talkingTimeMillis"in e&&(e.talkTimeMillis=e.talkingTimeMillis,delete e.talkingTimeMillis),e.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(e.softphoneStreamStatistics),e};var u=function(e){if(t.assertNotNull(e,"endpoint"),n.call(this),e.includes("/task-templates"))this.endpointUrl=t.getUrlWithProtocol(e);else{var r=new AWS.Endpoint(e),o=e.includes(".awsapps.com")?"/connect":"";this.endpointUrl=t.getUrlWithProtocol(`${r.host}${o}/task-templates/api/ccp`)}};(u.prototype=Object.create(n.prototype)).constructor=u,u.prototype._callImpl=function(e,n,r){t.assertNotNull(e,"method"),t.assertNotNull(n,"params");var o={credentials:"include",method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","x-csrf-token":"csrf"}},i=n.instanceId,s=this.endpointUrl,a=t.TaskTemplatesClientMethods;switch(e){case a.LIST_TASK_TEMPLATES:if(s+=`/proxy/instance/${i}/task/template`,n.queryParams){const e=new URLSearchParams(n.queryParams).toString();e&&(s+=`?${e}`)}break;case a.GET_TASK_TEMPLATE:t.assertNotNull(n.templateParams,"params.templateParams");const r=t.assertNotNull(n.templateParams.id,"params.templateParams.id"),c=n.templateParams.version;s+=`/proxy/instance/${i}/task/template/${r}`,c&&(s+=`?snapshotVersion=${c}`);break;case a.CREATE_TEMPLATED_TASK:s+=`/${e}`,o.body=JSON.stringify(n),o.method="PUT";break;case a.UPDATE_CONTACT:s+=`/${e}`,o.body=JSON.stringify(n),o.method="POST"}t.fetch(s,o).then((function(e){r.success(e)})).catch((function(e){const t=e.body.getReader();let n="";const o=new TextDecoder;t.read().then((function i({done:s,value:a}){if(s){var c=JSON.parse(n);return c.status=e.status,void r.failure(c)}return n+=o.decode(a),t.read().then(i)}))}))},t.ClientBase=n,t.NullClient=r,t.UpstreamConduitClient=i,t.UpstreamConduitMasterClient=s,t.AWSClient=c,t.AgentAppClient=a,t.TaskTemplatesClient=u}()},895:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.core={},t.core.initialized=!1,t.version="2.4.1",t.DEFAULT_BATCH_SIZE=500;var n="Amazon Connect CCP",r="https://{alias}.awsapps.com/auth/?client_id={client_id}&redirect_uri={redirect}",o="06919f4fd8ed324e",i="/auth/authorize",s="/connect/auth/authorize",a="IframeRefreshAttempts",c="IframeInitializationSuccess";t.numberOfConnectedCCPs=0,t.numberOfConnectedCCPsInThisTab=0,t.core.MAX_AUTHORIZE_RETRY_COUNT_FOR_SESSION=3,t.core.MAX_CTI_AUTH_RETRY_COUNT=10,t.core.ctiAuthRetryCount=0,t.core.authorizeTimeoutId=null,t.core.ctiTimeoutId=null,t.SessionStorageKeys=t.makeEnum(["tab_id","authorize_retry_count"]);var u=function(){let n=`SoftphoneParamsStorage::${e.location.origin}`;return{set:function(r){try{r&&e.localStorage.setItem(n,JSON.stringify(r))}catch(e){t.getLog().error("SoftphoneParamsStorage:: Failed to set softphone params to local storage!").withException(e).sendInternalLogToServer()}},get:function(){try{let t=e.localStorage.getItem(n);return t&&JSON.parse(t)}catch(e){t.getLog().error("SoftphoneParamsStorage:: Failed to get softphone params from local storage!").withException(e).sendInternalLogToServer()}return null},clean:function(){e.localStorage.removeItem(n)}}}();function l(e){var t=e.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/gi);return t.length?t[0]:""}t.core.checkNotInitialized=function(){t.core.initialized&&t.getLog().warn("Connect core already initialized, only needs to be initialized once.").sendInternalLogToServer()},t.core.init=function(e){t.core.eventBus=new t.EventBus,t.core.agentDataProvider=new g(t.core.getEventBus()),t.core.initClient(e),t.core.initAgentAppClient(e),t.core.initTaskTemplatesClient(e),t.core.initialized=!0},t.core.initClient=function(e){t.assertNotNull(e,"params");var n=t.assertNotNull(e.authToken,"params.authToken"),r=t.assertNotNull(e.region,"params.region"),o=e.endpoint||null;t.core.client=new t.AWSClient(n,r,o)},t.core.initAgentAppClient=function(e){t.assertNotNull(e,"params");var n=t.assertNotNull(e.authToken,"params.authToken"),r=t.assertNotNull(e.authCookieName,"params.authCookieName"),o=t.assertNotNull(e.agentAppEndpoint,"params.agentAppEndpoint");t.core.agentAppClient=new t.AgentAppClient(r,n,o)},t.core.initTaskTemplatesClient=function(e){t.assertNotNull(e,"params");var n=e.taskTemplatesEndpoint||e.endpoint;t.assertNotNull(n,"taskTemplatesEndpoint"),t.core.taskTemplatesClient=new t.TaskTemplatesClient(n)},t.core.terminate=function(){t.core.client=new t.NullClient,t.core.agentAppClient=new t.NullClient,t.core.taskTemplatesClient=new t.NullClient,t.core.masterClient=new t.NullClient;var e=t.core.getEventBus();e&&e.unsubscribeAll(),t.core.bus=new t.EventBus,t.core.agentDataProvider=null,t.core.softphoneManager=null,t.core.upstream=null,t.core.keepaliveManager=null,t.agent.initialized=!1,t.core.initialized=!1},t.core.softphoneUserMediaStream=null,t.core.getSoftphoneUserMediaStream=function(){return t.core.softphoneUserMediaStream},t.core.setSoftphoneUserMediaStream=function(e){t.core.softphoneUserMediaStream=e},t.core.initRingtoneEngines=function(e){t.assertNotNull(e,"params");var n=function(e){t.assertNotNull(e,"ringtoneSettings"),t.assertNotNull(e.voice,"ringtoneSettings.voice"),t.assertTrue(e.voice.ringtoneUrl||e.voice.disabled,"ringtoneSettings.voice.ringtoneUrl must be provided or ringtoneSettings.voice.disabled must be true"),t.assertNotNull(e.queue_callback,"ringtoneSettings.queue_callback"),t.assertTrue(e.queue_callback.ringtoneUrl||e.queue_callback.disabled,"ringtoneSettings.voice.ringtoneUrl must be provided or ringtoneSettings.queue_callback.disabled must be true"),t.core.ringtoneEngines={},t.agent((function(n){n.onRefresh((function(){t.ifMaster(t.MasterTopics.RINGTONE,(function(){e.voice.disabled||t.core.ringtoneEngines.voice||(t.core.ringtoneEngines.voice=new t.VoiceRingtoneEngine(e.voice),t.getLog().info("VoiceRingtoneEngine initialized.").sendInternalLogToServer()),e.chat.disabled||t.core.ringtoneEngines.chat||(t.core.ringtoneEngines.chat=new t.ChatRingtoneEngine(e.chat),t.getLog().info("ChatRingtoneEngine initialized.").sendInternalLogToServer()),e.task.disabled||t.core.ringtoneEngines.task||(t.core.ringtoneEngines.task=new t.TaskRingtoneEngine(e.task),t.getLog().info("TaskRingtoneEngine initialized.").sendInternalLogToServer()),e.queue_callback.disabled||t.core.ringtoneEngines.queue_callback||(t.core.ringtoneEngines.queue_callback=new t.QueueCallbackRingtoneEngine(e.queue_callback),t.getLog().info("QueueCallbackRingtoneEngine initialized.").sendInternalLogToServer())}))}))})),p()},r=function(e,n){e.ringtone=e.ringtone||{},e.ringtone.voice=e.ringtone.voice||{},e.ringtone.queue_callback=e.ringtone.queue_callback||{},e.ringtone.chat=e.ringtone.chat||{disabled:!0},e.ringtone.task=e.ringtone.task||{disabled:!0},n.softphone&&(n.softphone.disableRingtone&&(e.ringtone.voice.disabled=!0,e.ringtone.queue_callback.disabled=!0),n.softphone.ringtoneUrl&&(e.ringtone.voice.ringtoneUrl=n.softphone.ringtoneUrl,e.ringtone.queue_callback.ringtoneUrl=n.softphone.ringtoneUrl)),n.chat&&(n.chat.disableRingtone&&(e.ringtone.chat.disabled=!0),n.chat.ringtoneUrl&&(e.ringtone.chat.ringtoneUrl=n.chat.ringtoneUrl)),n.ringtone&&(e.ringtone.voice=t.merge(e.ringtone.voice,n.ringtone.voice||{}),e.ringtone.queue_callback=t.merge(e.ringtone.queue_callback,n.ringtone.voice||{}),e.ringtone.chat=t.merge(e.ringtone.chat,n.ringtone.chat||{}))};r(e,e),t.isFramed()?t.core.getEventBus().subscribe(t.EventType.CONFIGURE,(function(t){this.unsubscribe(),r(e,t),n(e.ringtone)})):n(e.ringtone)};var p=function(){t.core.getEventBus().subscribe(t.ConfigurationEvents.SET_RINGER_DEVICE,d)},d=function(e){if(0!==t.keys(t.core.ringtoneEngines).length&&e&&e.deviceId){var n=e.deviceId;for(var r in t.core.ringtoneEngines)t.core.ringtoneEngines[r].setOutputDevice(n);t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.RINGER_DEVICE_CHANGED,data:{deviceId:n}})}};t.core.initSoftphoneManager=function(n){var r=n||{};t.getLog().info("[Softphone Manager] initSoftphoneManager started").sendInternalLogToServer();var o=function(e){var n=t.merge(r.softphone||{},e);t.getLog().info("[Softphone Manager] competeForMasterOnAgentUpdate executed").sendInternalLogToServer(),t.agent((function(e){e.getChannelConcurrency(t.ChannelType.VOICE)&&e.onRefresh((function(){var r=this;t.getLog().info("[Softphone Manager] agent refresh handler executed").sendInternalLogToServer(),t.ifMaster(t.MasterTopics.SOFTPHONE,(function(){t.getLog().info("[Softphone Manager] confirmed as softphone master topic").sendInternalLogToServer(),!t.core.softphoneManager&&e.isSoftphoneEnabled()&&(t.becomeMaster(t.MasterTopics.SEND_LOGS),t.core.softphoneManager=new t.SoftphoneManager(n),r.unsubscribe())}))}))}))};if(t.isFramed()&&t.isCCP()){let n;t.core.getEventBus().subscribe(t.EventType.CONFIGURE,(function(r){e.clearTimeout(n),t.getLog().info("[Softphone Manager] Configure event handler executed").sendInternalLogToServer(),u.set(r.softphone),r.softphone&&r.softphone.allowFramedSoftphone&&(this.unsubscribe(),o(r.softphone)),i(r.softphone)}));let r=u.get();r&&t.core.getUpstream().onUpstream(t.EventType.ACKNOWLEDGE,(function(s){s&&s.id&&(t.getLog().info("[Softphone Manager] Embedded CCP is refreshed successfully and waiting for configure Message handler to execute").sendInternalLogToServer(),this.unsubscribe(),n=e.setTimeout((()=>{t.getLog().info("[Softphone Manager] Embedded CCP is refreshed without configure message handler execution").sendInternalLogToServer(),t.publishMetric({name:"EmbeddedCCPRefreshedWithoutInitCCP",data:{count:1}}),i(r),r.allowFramedSoftphone&&(t.getLog().info("[Softphone Manager] Embedded CCP is refreshed & Initializing competeForMasterOnAgentUpdate (Softphone manager) from localStorage softphone params").sendInternalLogToServer(),o(r))}),100))}))}else o(r),i(r);function i(e){var n=t.merge(r.softphone||{},e);t.core.softphoneParams=n,t.isFirefoxBrowser()&&(t.core.getUpstream().onUpstream(t.EventType.MASTER_RESPONSE,(function(e){if(e.data&&e.data.topic===t.MasterTopics.SOFTPHONE&&e.data.takeOver&&e.data.masterId!==t.core.portStreamId){t.core.softphoneManager&&(t.core.softphoneManager.onInitContactSub.unsubscribe(),delete t.core.softphoneManager);var n=t.core.getSoftphoneUserMediaStream();n&&(n.getTracks().forEach((function(e){e.stop()})),t.core.setSoftphoneUserMediaStream(null))}})),t.core.getEventBus().subscribe(t.ConnectionEvents.READY_TO_START_SESSION,(function(){t.ifMaster(t.MasterTopics.SOFTPHONE,(function(){t.core.softphoneManager&&t.core.softphoneManager.startSession()}),(function(){t.becomeMaster(t.MasterTopics.SOFTPHONE,(function(){t.agent((function(e){!t.core.softphoneManager&&e.isSoftphoneEnabled()&&(t.becomeMaster(t.MasterTopics.SEND_LOGS),t.core.softphoneManager=new t.SoftphoneManager(n),t.core.softphoneManager.startSession())}))}))}))})),t.contact((function(e){t.agent((function(n){e.onRefresh((function(e){if(t.hasOtherConnectedCCPs()&&"visible"===document.visibilityState&&(e.getStatus().type===t.ContactStatusType.CONNECTING||e.getStatus().type===t.ContactStatusType.INCOMING)){var r=e.isSoftphoneCall()&&!e.isInbound(),o=e.isSoftphoneCall()&&n.getConfiguration().softphoneAutoAccept,i=e.getType()===t.ContactType.QUEUE_CALLBACK;(r||o||i)&&t.core.triggerReadyToStartSessionEvent()}}))}))})))}t.agent((function(e){e.isSoftphoneEnabled()&&e.getChannelConcurrency(t.ChannelType.VOICE)&&t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.MUTE})}))},t.core.triggerReadyToStartSessionEvent=function(){var e=t.core.softphoneParams&&t.core.softphoneParams.allowFramedSoftphone;t.isCCP()?e?t.core.getEventBus().trigger(t.ConnectionEvents.READY_TO_START_SESSION):t.isFramed()?t.core.getUpstream().sendDownstream(t.ConnectionEvents.READY_TO_START_SESSION):t.core.getEventBus().trigger(t.ConnectionEvents.READY_TO_START_SESSION):e?t.core.getUpstream().sendUpstream(t.ConnectionEvents.READY_TO_START_SESSION):t.core.getEventBus().trigger(t.ConnectionEvents.READY_TO_START_SESSION)},t.core.initPageOptions=function(e){if(t.assertNotNull(e,"params"),t.isFramed()){var n=t.core.getEventBus();n.subscribe(t.EventType.CONFIGURE,(function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.CONFIGURE,data:e})})),n.subscribe(t.EventType.MEDIA_DEVICE_REQUEST,(function(){function e(e){t.core.getUpstream().sendDownstream(t.EventType.MEDIA_DEVICE_RESPONSE,e)}navigator&&navigator.mediaDevices?navigator.mediaDevices.enumerateDevices().then((function(t){devices=t||[],devices=devices.map((function(e){return e.toJSON()})),e(devices)})).catch((function(t){e({error:t.message})})):e({error:"No navigator or navigator.mediaDevices object found"})}))}},t.core.getFrameMediaDevices=function(e){var n=null,r=e||1e3,o=new Promise((function(e,t){setTimeout((function(){t(new Error("Timeout exceeded"))}),r)})),i=new Promise((function(e,r){if(t.isFramed()||t.isCCP())navigator&&navigator.mediaDevices?navigator.mediaDevices.enumerateDevices().then((function(t){devices=t||[],devices=devices.map((function(e){return e.toJSON()})),e(devices)})):r(new Error("No navigator or navigator.mediaDevices object found"));else{var o=t.core.getEventBus();n=o.subscribe(t.EventType.MEDIA_DEVICE_RESPONSE,(function(t){t.error?r(new Error(t.error)):e(t)})),t.core.getUpstream().sendUpstream(t.EventType.MEDIA_DEVICE_REQUEST)}}));return Promise.race([i,o]).finally((function(){n&&n.unsubscribe()}))},t.core.authorize=function(e){var n=e;return n||(n=t.core.isLegacyDomain()?s:i),t.fetch(n,{credentials:"include"},2e3,5)},t.core.verifyDomainAccess=function(e,n){if(t.getLog().warn("This API will be deprecated in the next major version release"),!t.isFramed())return Promise.resolve();var r={headers:{"X-Amz-Bearer":e}},o=null;return o=n||(t.core.isLegacyDomain()?"/connect/whitelisted-origins":"/whitelisted-origins"),t.fetch(o,r,2e3,5).then((function(e){var t=l(window.document.referrer);return e.whitelistedOrigins.some((function(e){return t===l(e)}))?Promise.resolve():Promise.reject()}))},t.core.isLegacyDomain=function(e){return(e=e||window.location.href).includes(".awsapps.com")},t.core.initSharedWorker=function(n){if(t.core.checkNotInitialized(),!t.core.initialized){t.assertNotNull(n,"params");var r=t.assertNotNull(n.sharedWorkerUrl,"params.sharedWorkerUrl"),o=t.assertNotNull(n.authToken,"params.authToken"),a=t.assertNotNull(n.refreshToken,"params.refreshToken"),c=t.assertNotNull(n.authTokenExpiration,"params.authTokenExpiration"),u=t.assertNotNull(n.region,"params.region"),l=n.endpoint||null,p=n.authorizeEndpoint;p||(p=t.core.isLegacyDomain()?s:i);var d=n.agentAppEndpoint||null,h=n.taskTemplatesEndpoint||null,m=n.authCookieName||null;try{t.core.eventBus=new t.EventBus({logEvents:!0}),t.core.agentDataProvider=new g(t.core.getEventBus()),t.core.mediaFactory=new t.MediaFactory(n);var v=new SharedWorker(r,"ConnectSharedWorker"),y=new t.Conduit("ConnectSharedWorkerConduit",new t.PortStream(v.port),new t.WindowIOStream(window,parent));t.core.upstream=y,t.core.webSocketProvider=new f,e.onunload=function(){y.sendUpstream(t.EventType.CLOSE),v.port.close()},t.getLog().scheduleUpstreamLogPush(y),t.getLog().scheduleDownstreamClientSideLogsPush(),y.onAllUpstream(t.core.getEventBus().bridge()),y.onAllUpstream(y.passDownstream()),t.isFramed()&&(y.onAllDownstream(t.core.getEventBus().bridge()),y.onAllDownstream(y.passUpstream())),y.sendUpstream(t.EventType.CONFIGURE,{authToken:o,authTokenExpiration:c,endpoint:l,refreshToken:a,region:u,authorizeEndpoint:p,agentAppEndpoint:d,taskTemplatesEndpoint:h,authCookieName:m,longPollingOptions:n.longPollingOptions||void 0}),y.onUpstream(t.EventType.ACKNOWLEDGE,(function(e){t.getLog().info("Acknowledged by the ConnectSharedWorker!").sendInternalLogToServer(),t.core.initialized=!0,t.core._setTabId(),t.core.portStreamId=e.id,this.unsubscribe()})),y.onUpstream(t.EventType.LOG,(function(e){e.loggerId!==t.getLog().getLoggerId()&&t.getLog().addLogEntry(t.LogEntry.fromObject(e))})),y.onUpstream(t.EventType.SERVER_BOUND_INTERNAL_LOG,(function(e){t.getLog().sendInternalLogEntryToServer(t.LogEntry.fromObject(e))})),y.onDownstream(t.EventType.SERVER_BOUND_INTERNAL_LOG,(function(e){t.isFramed()&&Array.isArray(e)&&e.forEach((function(e){t.getLog().sendInternalLogEntryToServer(t.LogEntry.fromObject(e))}))})),y.onDownstream(t.EventType.LOG,(function(e){t.isFramed()&&e.loggerId!==t.getLog().getLoggerId()&&t.getLog().addLogEntry(t.LogEntry.fromObject(e))})),t.core.onAuthFail(t.hitch(t.core,t.core._handleAuthFail,n.loginEndpoint||null,p)),t.core.onAuthorizeSuccess(t.hitch(t.core,t.core._handleAuthorizeSuccess)),t.getLog().info("User Agent: "+navigator.userAgent).sendInternalLogToServer(),t.getLog().info("isCCPv2: "+!0).sendInternalLogToServer(),t.getLog().info("isFramed: "+t.isFramed()).sendInternalLogToServer(),t.core.upstream.onDownstream(t.EventType.OUTER_CONTEXT_INFO,(function(e){var n=e.streamsVersion;t.getLog().info("StreamsJS Version: "+n).sendInternalLogToServer()})),y.onUpstream(t.EventType.UPDATE_CONNECTED_CCPS,(function(e){t.getLog().info("Number of connected CCPs updated: "+e.length).sendInternalLogToServer(),t.numberOfConnectedCCPs=e.length,e[t.core.tabId]&&!isNaN(e[t.core.tabId].length)&&t.numberOfConnectedCCPsInThisTab!==e[t.core.tabId].length&&(t.numberOfConnectedCCPsInThisTab=e[t.core.tabId].length,t.numberOfConnectedCCPsInThisTab>1&&t.getLog().warn("There are "+t.numberOfConnectedCCPsInThisTab+" connected CCPs in this tab. Please adjust your implementation to avoid complications. If you are embedding CCP, please do so exclusively with initCCP. InitCCP will not let you embed more than one CCP.").sendInternalLogToServer(),t.publishMetric({name:"ConnectedCCPSingleTabCount",data:{count:t.numberOfConnectedCCPsInThisTab}})),e.tabId&&e.streamsTabsAcrossBrowser&&t.ifMaster(t.MasterTopics.METRICS,(()=>t.agent((()=>t.publishMetric({name:"CCPTabsAcrossBrowserCount",data:{tabId:e.tabId,count:e.streamsTabsAcrossBrowser}})))))})),t.core.client=new t.UpstreamConduitClient(y),t.core.masterClient=new t.UpstreamConduitMasterClient(y),t.core.getEventBus().subscribe(t.EventType.TERMINATE,y.passUpstream()),t.core.getEventBus().subscribe(t.EventType.TERMINATED,(function(){window.location.reload(!0)})),v.port.start(),y.onUpstream(t.VoiceIdEvents.UPDATE_DOMAIN_ID,(function(e){e&&e.domainId&&(t.core.voiceIdDomainId=e.domainId)})),t.agent((function(){(new t.VoiceId).getDomainId().then((function(e){t.getLog().info("voiceId domainId successfully fetched at agent initialization: "+e).sendInternalLogToServer()})).catch((function(e){t.getLog().info("voiceId domainId not fetched at agent initialization").withObject({err:e}).sendInternalLogToServer()}))})),t.core.getNotificationManager().requestPermission()}catch(e){t.getLog().error("Failed to initialize the API shared worker, we're dead!").withException(e).sendInternalLogToServer()}}},t.core._setTabId=function(){try{t.core.tabId=window.sessionStorage.getItem(t.SessionStorageKeys.TAB_ID),t.core.tabId||(t.core.tabId=t.randomId(),window.sessionStorage.setItem(t.SessionStorageKeys.TAB_ID,t.core.tabId)),t.core.upstream.sendUpstream(t.EventType.TAB_ID,{tabId:t.core.tabId})}catch(e){t.getLog().error("[Tab Id] There was an issue setting the tab Id").withException(e).sendInternalLogToServer()}},t.core.initCCP=function(n,i){if(t.core.checkNotInitialized(),!t.core.initialized){t.getLog().info("Iframe initialization started").sendInternalLogToServer();var s=Date.now();try{if(t.core._getCCPIframe())return void t.getLog().error("Attempted to call initCCP when an iframe generated by initCCP already exists").sendInternalLogToServer()}catch(e){t.getLog().error("Error while checking if initCCP has already been called").withException(e).sendInternalLogToServer()}var l={};"string"==typeof i?l.ccpUrl=i:l=i,t.assertNotNull(n,"containerDiv"),t.assertNotNull(l.ccpUrl,"params.ccpUrl"),u.clean();var p=t.core._createCCPIframe(n,l);t.core.eventBus=new t.EventBus({logEvents:!1}),t.core.agentDataProvider=new g(t.core.getEventBus()),t.core.mediaFactory=new t.MediaFactory(l);var d=new t.IFrameConduit(l.ccpUrl,window,p);t.core._sendIframeStyleDataUpstreamAfterReasonableWaitTime(p,d),t.core.upstream=d,t.core.webSocketProvider=new f,d.onAllUpstream(t.core.getEventBus().bridge()),t.core.keepaliveManager=new h(d,t.core.getEventBus(),l.ccpSynTimeout||1e3,l.ccpAckTimeout||3e3),t.core.iframeRefreshTimeout=null,t.core.ccpLoadTimeoutInstance=e.setTimeout((function(){t.core.ccpLoadTimeoutInstance=null,t.core.getEventBus().trigger(t.EventType.ACK_TIMEOUT),t.getLog().info("CCP LoadTimeout triggered").sendInternalLogToServer()}),l.ccpLoadTimeout||5e3),t.getLog().scheduleUpstreamOuterContextCCPLogsPush(d),t.getLog().scheduleUpstreamOuterContextCCPserverBoundLogsPush(d),d.onUpstream(t.EventType.ACKNOWLEDGE,(function(n){if(t.getLog().info("Acknowledged by the CCP!").sendInternalLogToServer(),t.core.client=new t.UpstreamConduitClient(d),t.core.masterClient=new t.UpstreamConduitMasterClient(d),t.core.portStreamId=n.id,(l.softphone||l.chat||l.pageOptions||l.shouldAddNamespaceToLogs)&&d.sendUpstream(t.EventType.CONFIGURE,{softphone:l.softphone,chat:l.chat,pageOptions:l.pageOptions,shouldAddNamespaceToLogs:l.shouldAddNamespaceToLogs}),t.core.ccpLoadTimeoutInstance&&(e.clearTimeout(t.core.ccpLoadTimeoutInstance),t.core.ccpLoadTimeoutInstance=null),d.sendUpstream(t.EventType.OUTER_CONTEXT_INFO,{streamsVersion:t.version}),t.core.keepaliveManager.start(),this.unsubscribe(),t.core.initialized=!0,t.core.getEventBus().trigger(t.EventType.INIT),s){var r=Date.now()-s,o=t.core.iframeRefreshAttempt||0;t.getLog().info("Iframe initialization succeeded").sendInternalLogToServer(),t.getLog().info(`Iframe initialization time ${r}`).sendInternalLogToServer(),t.getLog().info(`Iframe refresh attempts ${o}`).sendInternalLogToServer(),setTimeout((()=>{t.publishMetric({name:a,data:{count:o}}),t.publishMetric({name:c,data:{count:1}}),t.publishMetric({name:"IframeInitializationTime",data:{count:r}}),s=null}),1e3)}})),d.onUpstream(t.EventType.LOG,(function(e){e.loggerId!==t.getLog().getLoggerId()&&t.getLog().addLogEntry(t.LogEntry.fromObject(e))})),t.core.getEventBus().subscribe(t.EventType.ACK_TIMEOUT,(function(){if(!1!==l.loginPopup)try{var i=function(n){var i="https://lily.us-east-1.amazonaws.com/taw/auth/code";return t.assertNotNull(i),n.loginUrl?n.loginUrl:n.alias?(log.warn("The `alias` param is deprecated and should not be expected to function properly. Please use `ccpUrl` or `loginUrl`. See https://github.com/amazon-connect/amazon-connect-streams/blob/master/README.md#connectcoreinitccp for valid parameters."),r.replace("{alias}",n.alias).replace("{client_id}",o).replace("{redirect}",e.encodeURIComponent(i))):n.ccpUrl}(l);t.getLog().warn("ACK_TIMEOUT occurred, attempting to pop the login page if not already open.").sendInternalLogToServer(),l.loginUrl&&t.core.getPopupManager().clear(t.MasterTopics.LOGIN_POPUP),t.core.loginWindow=t.core.getPopupManager().open(i,t.MasterTopics.LOGIN_POPUP,l.loginOptions)}catch(e){t.getLog().error("ACK_TIMEOUT occurred but we are unable to open the login popup.").withException(e).sendInternalLogToServer()}if(null==t.core.iframeRefreshTimeout)try{d.onUpstream(t.EventType.ACKNOWLEDGE,(function(){this.unsubscribe(),e.clearTimeout(t.core.iframeRefreshTimeout),t.core.iframeRefreshTimeout=null,t.core.getPopupManager().clear(t.MasterTopics.LOGIN_POPUP),(l.loginPopupAutoClose||l.loginOptions&&l.loginOptions.autoClose)&&t.core.loginWindow&&(t.core.loginWindow.close(),t.core.loginWindow=null)})),t.core._refreshIframeOnTimeout(l,n)}catch(e){t.getLog().error("Error occurred while refreshing iframe").withException(e).sendInternalLogToServer()}})),l.onViewContact&&t.core.onViewContact(l.onViewContact),d.onUpstream(t.EventType.UPDATE_CONNECTED_CCPS,(function(e){t.numberOfConnectedCCPs=e.length})),d.onUpstream(t.VoiceIdEvents.UPDATE_DOMAIN_ID,(function(e){e&&e.domainId&&(t.core.voiceIdDomainId=e.domainId)})),t.core.getEventBus().subscribe(t.EventType.IFRAME_RETRIES_EXHAUSTED,(function(){if(s){var e=t.core.iframeRefreshAttempt-1;t.getLog().info("Iframe initialization failed").sendInternalLogToServer(),t.getLog().info("Time after iframe initialization started "+(Date.now()-s)).sendInternalLogToServer(),t.getLog().info(`Iframe refresh attempts ${e}`).sendInternalLogToServer(),t.publishMetric({name:a,data:{count:e}}),t.publishMetric({name:c,data:{count:0}}),s=null}})),t.core.softphoneParams=l.softphone}},t.core.onIframeRetriesExhausted=function(e){t.core.getEventBus().subscribe(t.EventType.IFRAME_RETRIES_EXHAUSTED,e)},t.core._refreshIframeOnTimeout=function(n,r){t.assertNotNull(n,"initCCPParams"),t.assertNotNull(r,"containerDiv");var o=((n.disasterRecoveryOn?1e4:5e3)+AWS.util.calculateRetryDelay(t.core.iframeRefreshAttempt-1||0,{base:2e3}))*Math.ceil((t.core.iframeRefreshAttempt||0)/6);e.clearTimeout(t.core.iframeRefreshTimeout),t.core.iframeRefreshTimeout=e.setTimeout((function(){if(t.core.iframeRefreshAttempt=(t.core.iframeRefreshAttempt||0)+1,t.core.iframeRefreshAttempt<=6){try{var o=t.core._getCCPIframe();o&&o.parentNode.removeChild(o);var i=t.core._createCCPIframe(r,n);t.core.upstream.upstream.output=i.contentWindow,t.core._sendIframeStyleDataUpstreamAfterReasonableWaitTime(i,t.core.upstream)}catch(e){t.getLog().error("Error while checking for, and recreating, the CCP IFrame").withException(e).sendInternalLogToServer()}t.core._refreshIframeOnTimeout(n,r)}else t.core.getEventBus().trigger(t.EventType.IFRAME_RETRIES_EXHAUSTED),e.clearTimeout(t.core.iframeRefreshTimeout)}),o)},t.core._getCCPIframe=function(){for(var e of window.document.getElementsByTagName("iframe"))if(e.name===n)return e;return null},t.core._createCCPIframe=function(e,r){t.assertNotNull(r,"initCCPParams"),t.assertNotNull(e,"containerDiv");var o=document.createElement("iframe");return o.src=r.ccpUrl,o.allow="microphone; autoplay; clipboard-write",o.style=r.style||"width: 100%; height: 100%",o.title=r.iframeTitle||n,o.name=n,e.appendChild(o),o},t.core._sendIframeStyleDataUpstreamAfterReasonableWaitTime=function(e,n){t.assertNotNull(e,"iframe"),t.assertNotNull(n,"conduit"),setTimeout((function(){var r={display:window.getComputedStyle(e,null).display,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,clientRectsLength:e.getClientRects().length};n.sendUpstream(t.EventType.IFRAME_STYLE,r)}),1e4)};var h=function(e,t,n,r){this.conduit=e,this.eventBus=t,this.synTimeout=n,this.ackTimeout=r,this.ackTimer=null,this.synTimer=null,this.ackSub=null};h.prototype.start=function(){var n=this;this.conduit.sendUpstream(t.EventType.SYNCHRONIZE),this.ackSub=this.conduit.onUpstream(t.EventType.ACKNOWLEDGE,(function(){this.unsubscribe(),e.clearTimeout(n.ackTimer),n._deferStart()})),this.ackTimer=e.setTimeout((function(){n.ackSub.unsubscribe(),n.eventBus.trigger(t.EventType.ACK_TIMEOUT),n._deferStart()}),this.ackTimeout)},h.prototype._deferStart=function(){this.synTimer=e.setTimeout(t.hitch(this,this.start),this.synTimeout)},h.prototype.deferStart=function(){null==this.synTimer&&(this.synTimer=e.setTimeout(t.hitch(this,this.start),this.synTimeout))};var f=function(){var e={initFailure:new Set,subscriptionUpdate:new Set,subscriptionFailure:new Set,topic:new Map,allMessage:new Set,connectionGain:new Set,connectionLost:new Set,connectionOpen:new Set,connectionClose:new Set},n=function(e,t){e.forEach((function(e){e(t)}))};t.core.getUpstream().onUpstream(t.WebSocketEvents.INIT_FAILURE,(function(){n(e.initFailure)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_OPEN,(function(t){n(e.connectionOpen,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_CLOSE,(function(t){n(e.connectionClose,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_GAIN,(function(){n(e.connectionGain)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_LOST,(function(t){n(e.connectionLost,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.SUBSCRIPTION_UPDATE,(function(t){n(e.subscriptionUpdate,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.SUBSCRIPTION_FAILURE,(function(t){n(e.subscriptionFailure,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.ALL_MESSAGE,(function(t){n(e.allMessage,t),e.topic.has(t.topic)&&n(e.topic.get(t.topic),t)})),this.sendMessage=function(e){t.core.getUpstream().sendUpstream(t.WebSocketEvents.SEND,e)},this.onInitFailure=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.initFailure.add(n),function(){return e.initFailure.delete(n)}},this.onConnectionOpen=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionOpen.add(n),function(){return e.connectionOpen.delete(n)}},this.onConnectionClose=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionClose.add(n),function(){return e.connectionClose.delete(n)}},this.onConnectionGain=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionGain.add(n),function(){return e.connectionGain.delete(n)}},this.onConnectionLost=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionLost.add(n),function(){return e.connectionLost.delete(n)}},this.onSubscriptionUpdate=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.subscriptionUpdate.add(n),function(){return e.subscriptionUpdate.delete(n)}},this.onSubscriptionFailure=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.subscriptionFailure.add(n),function(){return e.subscriptionFailure.delete(n)}},this.subscribeTopics=function(e){t.assertNotNull(e,"topics"),t.assertTrue(t.isArray(e),"topics must be a array"),t.core.getUpstream().sendUpstream(t.WebSocketEvents.SUBSCRIBE,e)},this.onMessage=function(n,r){return t.assertNotNull(n,"topicName"),t.assertTrue(t.isFunction(r),"method must be a function"),e.topic.has(n)?e.topic.get(n).add(r):e.topic.set(n,new Set([r])),function(){return e.topic.get(n).delete(r)}},this.onAllMessage=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.allMessage.add(n),function(){return e.allMessage.delete(n)}}},g=function(e){this.bus=e,this.bus.subscribe(t.AgentEvents.UPDATE,t.hitch(this,this.updateAgentData))};g.prototype.updateAgentData=function(e){var n=this.agentData;this.agentData=e,null==n&&(t.agent.initialized=!0,this.bus.trigger(t.AgentEvents.INIT,new t.Agent)),this.bus.trigger(t.AgentEvents.REFRESH,new t.Agent),this._fireAgentUpdateEvents(n)},g.prototype.getAgentData=function(){if(null==this.agentData)throw new t.StateError("No agent data is available yet!");return t.deepcopy(this.agentData)},g.prototype.getContactData=function(e){var n=this.getAgentData(),r=t.find(n.snapshot.contacts,(function(t){return t.contactId===e}));if(null==r)throw new t.StateError("Contact %s no longer exists.",e);return r},g.prototype.getConnectionData=function(e,n){var r=this.getContactData(e),o=t.find(r.connections,(function(e){return e.connectionId===n}));if(null==o)throw new t.StateError("Connection %s for contact %s no longer exists.",n,e);return o},g.prototype.getInstanceId=function(){return this.getAgentData().configuration.routingProfile.routingProfileId.match(/instance\/([0-9a-fA-F|-]+)\//)[1]},g.prototype.getAWSAccountId=function(){return this.getAgentData().configuration.routingProfile.routingProfileId.match(/:([0-9]+):instance/)[1]},g.prototype._diffContacts=function(e){var n={added:{},removed:{},common:{},oldMap:t.index(null==e?[]:e.snapshot.contacts,(function(e){return e.contactId})),newMap:t.index(this.agentData.snapshot.contacts,(function(e){return e.contactId}))};return t.keys(n.oldMap).forEach((function(e){t.contains(n.newMap,e)?n.common[e]=n.newMap[e]:n.removed[e]=n.oldMap[e]})),t.keys(n.newMap).forEach((function(e){t.contains(n.oldMap,e)||(n.added[e]=n.newMap[e])})),n},g.prototype._fireAgentUpdateEvents=function(e){var n=this,r=null,o=null==e?t.AgentAvailStates.INIT:e.snapshot.state.name,i=this.agentData.snapshot.state.name,s=null==e?t.AgentStateType.INIT:e.snapshot.state.type,a=this.agentData.snapshot.state.type;s!==a&&t.core.getAgentRoutingEventGraph().getAssociations(this,s,a).forEach((function(e){n.bus.trigger(e,new t.Agent)})),o!==i&&(this.bus.trigger(t.AgentEvents.STATE_CHANGE,{agent:new t.Agent,oldState:o,newState:i}),t.core.getAgentStateEventGraph().getAssociations(this,o,i).forEach((function(e){n.bus.trigger(e,new t.Agent)})));var c=e&&e.snapshot.nextState?e.snapshot.nextState.name:null,u=this.agentData.snapshot.nextState?this.agentData.snapshot.nextState.name:null;c!==u&&u&&n.bus.trigger(t.AgentEvents.ENQUEUED_NEXT_STATE,new t.Agent),r=null!==e?this._diffContacts(e):{added:t.index(this.agentData.snapshot.contacts,(function(e){return e.contactId})),removed:{},common:{},oldMap:{},newMap:t.index(this.agentData.snapshot.contacts,(function(e){return e.contactId}))},t.values(r.added).forEach((function(e){n.bus.trigger(t.ContactEvents.INIT,new t.Contact(e.contactId)),n._fireContactUpdateEvents(e.contactId,t.ContactStateType.INIT,e.state.type)})),t.values(r.removed).forEach((function(e){n.bus.trigger(t.ContactEvents.DESTROYED,new t.ContactSnapshot(e)),n.bus.trigger(t.core.getContactEventName(t.ContactEvents.DESTROYED,e.contactId),new t.ContactSnapshot(e)),n._unsubAllContactEventsForContact(e.contactId)})),t.keys(r.common).forEach((function(e){n._fireContactUpdateEvents(e,r.oldMap[e].state.type,r.newMap[e].state.type)}))},g.prototype._fireContactUpdateEvents=function(e,n,r){var o=this;n!==r&&t.core.getContactEventGraph().getAssociations(this,n,r).forEach((function(n){o.bus.trigger(n,new t.Contact(e)),o.bus.trigger(t.core.getContactEventName(n,e),new t.Contact(e))})),o.bus.trigger(t.ContactEvents.REFRESH,new t.Contact(e)),o.bus.trigger(t.core.getContactEventName(t.ContactEvents.REFRESH,e),new t.Contact(e))},g.prototype._unsubAllContactEventsForContact=function(e){var n=this;t.values(t.ContactEvents).forEach((function(r){n.bus.getSubscriptions(t.core.getContactEventName(r,e)).map((function(e){e.unsubscribe()}))}))},t.core.onViewContact=function(e){t.core.getUpstream().onUpstream(t.ContactEvents.VIEW,e)},t.core.viewContact=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ContactEvents.VIEW,data:{contactId:e}})},t.core.onActivateChannelWithViewType=function(e){t.core.getUpstream().onUpstream(t.ChannelViewEvents.ACTIVATE_CHANNEL_WITH_VIEW_TYPE,e)},t.core.activateChannelWithViewType=function(e,n,r,o){const i={viewType:e,mediaType:n};r&&(i.source=r),o&&(i.caseId=o),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ChannelViewEvents.ACTIVATE_CHANNEL_WITH_VIEW_TYPE,data:i})},t.core.triggerTaskCreated=function(e){t.core.getUpstream().upstreamBus.trigger(t.TaskEvents.CREATED,e)},t.core.onAccessDenied=function(e){t.core.getUpstream().onUpstream(t.EventType.ACCESS_DENIED,e)},t.core.onAuthFail=function(e){t.core.getUpstream().onUpstream(t.EventType.AUTH_FAIL,e)},t.core.onAuthorizeSuccess=function(e){t.core.getUpstream().onUpstream(t.EventType.AUTHORIZE_SUCCESS,e)},t.core._handleAuthorizeSuccess=function(){window.sessionStorage.setItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT,0)},t.core._handleAuthFail=function(e,n,r){r&&r.authorize?t.core._handleAuthorizeFail(e):t.core._handleCTIAuthFail(n)},t.core._handleAuthorizeFail=function(e){let n=t.core._getAuthRetryCount();if(!t.core.authorizeTimeoutId)if(n{t.core._redirectToLogin(e)}),r)}else t.getLog().warn("We have exhausted our authorization retries due to 401s from the authorize api. No more retries will be attempted in this session until the authorize api returns 200.").sendInternalLogToServer(),t.core.getEventBus().trigger(t.EventType.AUTHORIZE_RETRIES_EXHAUSTED)},t.core._redirectToLogin=function(e){"string"==typeof e?location.assign(e):location.reload()},t.core._handleCTIAuthFail=function(e){if(!t.core.ctiTimeoutId)if(t.core.ctiAuthRetryCount{t.core.authorize(e).then(t.core._triggerAuthorizeSuccess.bind(t.core)).catch(t.core._triggerAuthFail.bind(t.core,{authorize:!0})),t.core.ctiTimeoutId=null}),n)}else t.getLog().warn("We have exhausted our authorization retries due to 401s from the CTI service. No more retries will be attempted until the page is refreshed.").sendInternalLogToServer(),t.core.getEventBus().trigger(t.EventType.CTI_AUTHORIZE_RETRIES_EXHAUSTED)},t.core._triggerAuthorizeSuccess=function(){t.core.getUpstream().upstreamBus.trigger(t.EventType.AUTHORIZE_SUCCESS)},t.core._triggerAuthFail=function(e){t.core.getUpstream().upstreamBus.trigger(t.EventType.AUTH_FAIL,e)},t.core._getAuthRetryCount=function(){let e=window.sessionStorage.getItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT);if(null!==e){if(isNaN(parseInt(e)))throw new t.StateError("The session storage value for auth retry count was NaN");return parseInt(e)}return window.sessionStorage.setItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT,0),0},t.core._incrementAuthRetryCount=function(){window.sessionStorage.setItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT,(t.core._getAuthRetryCount()+1).toString())},t.core.onAuthorizeRetriesExhausted=function(e){t.core.getEventBus().subscribe(t.EventType.AUTHORIZE_RETRIES_EXHAUSTED,e)},t.core.onCTIAuthorizeRetriesExhausted=function(e){t.core.getEventBus().subscribe(t.EventType.CTI_AUTHORIZE_RETRIES_EXHAUSTED,e)},t.core.onSoftphoneSessionInit=function(e){t.core.getUpstream().onUpstream(t.ConnectionEvents.SESSION_INIT,e)},t.core.onConfigure=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.CONFIGURE,e)},t.core.onInitialized=function(e){t.core.getEventBus().subscribe(t.EventType.INIT,e)},t.core.getContactEventName=function(e,n){if(t.assertNotNull(e,"eventName"),t.assertNotNull(n,"contactId"),!t.contains(t.values(t.ContactEvents),e))throw new t.ValueError("%s is not a valid contact event.",e);return t.sprintf("%s::%s",e,n)},t.core.getEventBus=function(){return t.core.eventBus},t.core.getWebSocketManager=function(){return t.core.webSocketProvider},t.core.getAgentDataProvider=function(){return t.core.agentDataProvider},t.core.getLocalTimestamp=function(){return t.core.getAgentDataProvider().getAgentData().snapshot.localTimestamp},t.core.getSkew=function(){return t.core.getAgentDataProvider().getAgentData().snapshot.skew},t.core.getAgentRoutingEventGraph=function(){return t.core.agentRoutingEventGraph},t.core.agentRoutingEventGraph=(new t.EventGraph).assoc(t.EventGraph.ANY,t.AgentStateType.ROUTABLE,t.AgentEvents.ROUTABLE).assoc(t.EventGraph.ANY,t.AgentStateType.NOT_ROUTABLE,t.AgentEvents.NOT_ROUTABLE).assoc(t.EventGraph.ANY,t.AgentStateType.OFFLINE,t.AgentEvents.OFFLINE),t.core.getAgentStateEventGraph=function(){return t.core.agentStateEventGraph},t.core.agentStateEventGraph=(new t.EventGraph).assoc(t.EventGraph.ANY,t.values(t.AgentErrorStates),t.AgentEvents.ERROR).assoc(t.EventGraph.ANY,t.AgentAvailStates.AFTER_CALL_WORK,t.AgentEvents.ACW),t.core.getContactEventGraph=function(){return t.core.contactEventGraph},t.core.contactEventGraph=(new t.EventGraph).assoc(t.EventGraph.ANY,t.ContactStateType.INCOMING,t.ContactEvents.INCOMING).assoc(t.EventGraph.ANY,t.ContactStateType.PENDING,t.ContactEvents.PENDING).assoc(t.EventGraph.ANY,t.ContactStateType.CONNECTING,t.ContactEvents.CONNECTING).assoc(t.EventGraph.ANY,t.ContactStateType.CONNECTED,t.ContactEvents.CONNECTED).assoc(t.ContactStateType.CONNECTING,t.ContactStateType.ERROR,t.ContactEvents.MISSED).assoc(t.ContactStateType.INCOMING,t.ContactStateType.ERROR,t.ContactEvents.MISSED).assoc(t.EventGraph.ANY,t.ContactStateType.ENDED,t.ContactEvents.ACW).assoc(t.values(t.CONTACT_ACTIVE_STATES),t.values(t.relativeComplement(t.CONTACT_ACTIVE_STATES,t.ContactStateType)),t.ContactEvents.ENDED).assoc(t.EventGraph.ANY,t.ContactStateType.ERROR,t.ContactEvents.ERROR).assoc(t.ContactStateType.CONNECTING,t.ContactStateType.MISSED,t.ContactEvents.MISSED),t.core.getClient=function(){if(!t.core.client)throw new t.StateError("The connect core has not been initialized!");return t.core.client},t.core.client=null,t.core.getAgentAppClient=function(){if(!t.core.agentAppClient)throw new t.StateError("The connect AgentApp Client has not been initialized!");return t.core.agentAppClient},t.core.agentAppClient=null,t.core.getTaskTemplatesClient=function(){if(!t.core.taskTemplatesClient)throw new t.StateError("The connect TaskTemplates Client has not been initialized!");return t.core.taskTemplatesClient},t.core.taskTemplatesClient=null,t.core.getMasterClient=function(){if(!t.core.masterClient)throw new t.StateError("The connect master client has not been initialized!");return t.core.masterClient},t.core.masterClient=null,t.core.getSoftphoneManager=function(){return t.core.softphoneManager},t.core.softphoneManager=null,t.core.getNotificationManager=function(){return t.core.notificationManager||(t.core.notificationManager=new t.NotificationManager),t.core.notificationManager},t.core.notificationManager=null,t.core.getPopupManager=function(){return t.core.popupManager},t.core.popupManager=new t.PopupManager,t.core.getUpstream=function(){if(!t.core.upstream)throw new t.StateError("There is no upstream conduit!");return t.core.upstream},t.core.upstream=null,t.core.AgentDataProvider=g}()},592:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t;var n="<>",r=t.makeEnum(["acknowledge","ack_timeout","init","api_request","api_response","auth_fail","access_denied","close","configure","log","master_request","master_response","synchronize","terminate","terminated","send_logs","reload_agent_configuration","broadcast","api_metric","client_metric","softphone_stats","softphone_report","client_side_logs","server_bound_internal_log","mute","iframe_style","iframe_retries_exhausted","update_connected_ccps","outer_context_info","media_device_request","media_device_response","tab_id","authorize_success","authorize_retries_exhausted","cti_authorize_retries_exhausted","click_stream_data"]),o=t.makeNamespacedEnum("connect",["loginPopup","sendLogs","softphone","ringtone","metrics"]),i=t.makeNamespacedEnum("agent",["init","update","refresh","routable","not_routable","pending","contact_pending","offline","error","softphone_error","websocket_connection_lost","websocket_connection_gained","state_change","acw","mute_toggle","local_media_stream_created","enqueued_next_state"]),s=t.makeNamespacedEnum("webSocket",["init_failure","connection_open","connection_close","connection_error","connection_gain","connection_lost","subscription_update","subscription_failure","all_message","send","subscribe"]),a=t.makeNamespacedEnum("contact",["init","refresh","destroyed","incoming","pending","connecting","connected","missed","acw","view","ended","error","accepted"]),c=t.makeNamespacedEnum("taskList",["activate_channel_with_view_type"]),u=t.makeNamespacedEnum("task",["created"]),l=t.makeNamespacedEnum("connection",["session_init","ready_to_start_session"]),p=t.makeNamespacedEnum("configuration",["configure","set_speaker_device","set_microphone_device","set_ringer_device","speaker_device_changed","microphone_device_changed","ringer_device_changed"]),d=t.makeNamespacedEnum("voiceId",["update_domain_id"]),h=function(){};h.createRequest=function(e,n,r){return{event:e,requestId:t.randomId(),method:n,params:r}},h.createResponse=function(e,t,n,r){return{event:e,requestId:t.requestId,data:n,err:r||null}};var f=function(e,n,r){this.subMap=e,this.id=t.randomId(),this.eventName=n,this.f=r};f.prototype.unsubscribe=function(){this.subMap.unsubscribe(this.eventName,this.id)};var g=function(){this.subIdMap={},this.subEventNameMap={}};g.prototype.subscribe=function(e,t){var n=new f(this,e,t);this.subIdMap[n.id]=n;var r=this.subEventNameMap[e]||[];return r.push(n),this.subEventNameMap[e]=r,n},g.prototype.unsubscribe=function(e,n){t.contains(this.subEventNameMap,e)&&(this.subEventNameMap[e]=this.subEventNameMap[e].filter((function(e){return e.id!==n})),this.subEventNameMap[e].length<1&&delete this.subEventNameMap[e]),t.contains(this.subIdMap,n)&&delete this.subIdMap[n]},g.prototype.getAllSubscriptions=function(){return t.values(this.subEventNameMap).reduce((function(e,t){return e.concat(t)}),[])},g.prototype.getSubscriptions=function(e){return this.subEventNameMap[e]||[]};var m=function(e){var t=e||{};this.subMap=new g,this.logEvents=t.logEvents||!1};m.prototype.subscribe=function(e,n){return t.assertNotNull(e,"eventName"),t.assertNotNull(n,"f"),t.assertTrue(t.isFunction(n),"f must be a function"),this.subMap.subscribe(e,n)},m.prototype.subscribeAll=function(e){return t.assertNotNull(e,"f"),t.assertTrue(t.isFunction(e),"f must be a function"),this.subMap.subscribe(n,e)},m.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},m.prototype.trigger=function(e,r){t.assertNotNull(e,"eventName");var o=this,i=this.subMap.getSubscriptions(n),s=this.subMap.getSubscriptions(e);this.logEvents&&e!==t.EventType.LOG&&e!==t.EventType.MASTER_RESPONSE&&e!==t.EventType.API_METRIC&&e!==t.EventType.SERVER_BOUND_INTERNAL_LOG&&t.getLog().trace("Publishing event: %s",e).sendInternalLogToServer(),e.startsWith(t.ContactEvents.ACCEPTED)&&r&&r.contactId&&!(r instanceof t.Contact)&&(r=new t.Contact(r.contactId)),i.concat(s).forEach((function(n){try{n.f(r||null,e,o)}catch(n){t.getLog().error("'%s' event handler failed.",e).withException(n).sendInternalLogToServer()}}))},m.prototype.bridge=function(){var e=this;return function(t,n){e.trigger(n,t)}},m.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach((function(e){e.unsubscribe()}))},t.EventBus=m,t.EventFactory=h,t.EventType=r,t.AgentEvents=i,t.ConfigurationEvents=p,t.ConnectionEvents=l,t.ConnnectionEvents=l,t.ContactEvents=a,t.ChannelViewEvents=c,t.TaskEvents=u,t.VoiceIdEvents=d,t.WebSocketEvents=s,t.MasterTopics=o}()},286:()=>{!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";var r=n(1),o="DEBUG",i="AMZ_WEB_SOCKET_MANAGER:",s="Network offline",a="Network online, connecting to WebSocket server",c="Network offline, ignoring this getWebSocketConnConfig request",u="Heartbeat response not received",l="Failed to send heartbeat since WebSocket is not open",p="WebSocket connection established!",d="WebSocket connection is closed",h="WebSocketManager Error, error_event: ",f="Scheduling WebSocket reinitialization, after delay ",g="WebSocket URL cannot be used to establish connection",m="WebSocket Initialization failed - Terminating and cleaning subscriptions",v="Fetching new WebSocket connection configuration",y="Successfully fetched webSocket connection configuration",E="Failed to fetch webSocket connection configuration",S="Retrying fetching new WebSocket connection configuration",b="Initializing Websocket Manager",T="WebSocketManager Message Error",C="Message received for topic ",I="Invalid incoming message",_="aws/subscribe",A="aws/heartbeat",w="disconnected";function R(e){return(R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var k={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return k.assertTrue(null!==e&&void 0!==R(e),Object(r.sprintf)("%s must be provided",t||"A value")),e},isNonEmptyString:function(e){return"string"==typeof e&&e.length>0},assertIsList:function(e,t){if(!Array.isArray(e))throw new Error(t+" is not an array")},isFunction:function(e){return!!(e&&e.constructor&&e.call&&e.apply)},isObject:function(e){return!("object"!==R(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},N=new RegExp("^(wss://)\\w*");k.validWSUrl=function(e){return N.test(e)},k.getSubscriptionResponse=function(e,t,n){return{topic:e,content:{status:t?"success":"failure",topics:n}}},k.assertIsObject=function(e,t){if(!k.isObject(e))throw new Error(t+" is not an object!")},k.addJitter=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;t=Math.min(t,1);var n=Math.random()>.5?1:-1;return Math.floor(e+n*e*Math.random()*t)},k.isNetworkOnline=function(){return navigator.onLine},k.isNetworkFailure=function(e){return!(!e._debug||!e._debug.type)&&"NetworkingError"===e._debug.type};var O=k;function L(e){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function M(e,t){for(var n=0;n=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){var t=e.prefix||q;return this._logsDestination===o?this.consoleLoggerWrapper:new W(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||j.INFO,this._advancedLogWriter="warn",t.advancedLogWriter&&(this._advancedLogWriter=t.advancedLogWriter),t.customizedLogger&&"object"===P(t.customizedLogger)&&(this.useClientLogger=!0),this._clientLogger=t.logger||this.selectLogger(t),this._logsDestination="NULL",t.debug&&(this._logsDestination=o),t.logger&&(this._logsDestination="CLIENT_LOGGER")}},{key:"selectLogger",value:function(e){return e.customizedLogger&&"object"===P(e.customizedLogger)?e.customizedLogger:e.useDefaultLogger?(this.consoleLoggerWrapper=H(),this.consoleLoggerWrapper):null}}]),e}(),V=function(){function e(){x(this,e)}return U(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}},{key:"advancedLog",value:function(){}}]),e}(),W=function(e){function t(e){var n;return x(this,t),(n=function(e,t){return!t||"object"!==P(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}(this,L(t).call(this))).prefix=e||q,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&D(e,t)}(t,V),U(t,[{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1&&void 0!==arguments[1]?arguments[1]:2e3;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.numAttempts=0,this.executor=t,this.hasActiveReconnection=!1,this.defaultRetry=n}var t,n;return t=e,(n=[{key:"retry",value:function(){var e=this;this.hasActiveReconnection||(this.hasActiveReconnection=!0,setTimeout((function(){e._execute()}),this._getDelay()))}},{key:"_execute",value:function(){this.hasActiveReconnection=!1,this.executor(),this.numAttempts++}},{key:"connected",value:function(){this.numAttempts=0}},{key:"_getDelay",value:function(){var e=Math.pow(2,this.numAttempts)*this.defaultRetry;return e<=3e4?e:3e4}},{key:"getIsConnected",value:function(){return!this.numAttempts}}])&&G(t.prototype,n),e}();n.d(t,"a",(function(){return Y}));var X=function(){var e=z.getLogger({prefix:i}),t=O.isNetworkOnline(),n={primary:null,secondary:null},r={reconnectWebSocket:!0,websocketInitFailed:!1,exponentialBackOffTime:1e3,exponentialTimeoutHandle:null,lifeTimeTimeoutHandle:null,webSocketInitCheckerTimeoutId:null,connState:null},o={connectWebSocketRetryCount:0,connectionAttemptStartTime:null,noOpenConnectionsTimestamp:null},R={pendingResponse:!1,intervalHandle:null},k={initFailure:new Set,getWebSocketTransport:null,subscriptionUpdate:new Set,subscriptionFailure:new Set,topic:new Map,allMessage:new Set,connectionGain:new Set,connectionLost:new Set,connectionOpen:new Set,connectionClose:new Set},N={connConfig:null,promiseHandle:null,promiseCompleted:!0},L={subscribed:new Set,pending:new Set,subscriptionHistory:new Set},D={responseCheckIntervalId:null,requestCompleted:!0,reSubscribeIntervalId:null,consecutiveFailedSubscribeAttempts:0,consecutiveNoResponseRequest:0},P=new K((function(){se()})),x=new Set([_,"aws/unsubscribe",A]),M=setInterval((function(){if(t!==O.isNetworkOnline()){if(!(t=O.isNetworkOnline()))return e.advancedLog(s),void ue(e.info(s));var n=W();t&&(!n||j(n,WebSocket.CLOSING)||j(n,WebSocket.CLOSED))&&(e.advancedLog(a),ue(e.info(a)),se())}}),250),U=function(t,n){t.forEach((function(t){try{t(n)}catch(t){ue(e.error("Error executing callback",t))}}))},F=function(e){if(null===e)return"NULL";switch(e.readyState){case WebSocket.CONNECTING:return"CONNECTING";case WebSocket.OPEN:return"OPEN";case WebSocket.CLOSING:return"CLOSING";case WebSocket.CLOSED:return"CLOSED";default:return"UNDEFINED"}},q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";ue(e.debug("["+t+"] Primary WebSocket: "+F(n.primary)+" | Secondary WebSocket: "+F(n.secondary)))},j=function(e,t){return e&&e.readyState===t},B=function(e){return j(e,WebSocket.OPEN)},V=function(e){return null===e||void 0===e.readyState||j(e,WebSocket.CLOSED)},W=function(){return null!==n.secondary?n.secondary:n.primary},H=function(){return B(W())},G=function(){if(R.pendingResponse)return e.advancedLog(u),ue(e.warn(u)),clearInterval(R.intervalHandle),R.pendingResponse=!1,void se();H()?(ue(e.debug("Sending heartbeat")),W().send(oe(A)),R.pendingResponse=!0):(e.advancedLog(l),ue(e.warn(l)),q("sendHeartBeat"),se())},X=function(){e.advancedLog("Reset Websocket state"),r.exponentialBackOffTime=1e3,R.pendingResponse=!1,r.reconnectWebSocket=!0,clearTimeout(r.lifeTimeTimeoutHandle),clearInterval(R.intervalHandle),clearTimeout(r.exponentialTimeoutHandle),clearTimeout(r.webSocketInitCheckerTimeoutId)},Y=function(){D.consecutiveFailedSubscribeAttempts=0,D.consecutiveNoResponseRequest=0,clearInterval(D.responseCheckIntervalId),clearInterval(D.reSubscribeIntervalId)},J=function(){o.connectWebSocketRetryCount=0,o.connectionAttemptStartTime=null,o.noOpenConnectionsTimestamp=null},Q=function(){P.connected();try{e.advancedLog(p),ue(e.info(p)),q("webSocketOnOpen"),null!==r.connState&&r.connState!==w||U(k.connectionGain),r.connState="connected";var t=Date.now();U(k.connectionOpen,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,noOpenConnectionsTimestamp:o.noOpenConnectionsTimestamp,connectionEstablishedTime:t,timeToConnect:t-o.connectionAttemptStartTime,timeWithoutConnection:o.noOpenConnectionsTimestamp?t-o.noOpenConnectionsTimestamp:null}),J(),X(),W().openTimestamp=Date.now(),0===L.subscribed.size&&B(n.secondary)&&te(n.primary,"[Primary WebSocket] Closing WebSocket"),(L.subscribed.size>0||L.pending.size>0)&&(B(n.secondary)&&ue(e.info("Subscribing secondary websocket to topics of primary websocket")),L.subscribed.forEach((function(e){L.subscriptionHistory.add(e),L.pending.add(e)})),L.subscribed.clear(),ee()),G(),R.intervalHandle=setInterval(G,1e4);var i=1e3*N.connConfig.webSocketTransport.transportLifeTimeInSeconds;ue(e.debug("Scheduling WebSocket manager reconnection, after delay "+i+" ms")),r.lifeTimeTimeoutHandle=setTimeout((function(){ue(e.debug("Starting scheduled WebSocket manager reconnection")),se()}),i)}catch(t){ue(e.error("Error after establishing WebSocket connection",t))}},$=function(t){q("webSocketOnError"),e.advancedLog(h,JSON.stringify(t)),ue(e.error(h,JSON.stringify(t))),P.getIsConnected()?se():P.retry()},Z=function(t){var r=JSON.parse(t.data);switch(r.topic){case _:if(ue(e.debug("Subscription Message received from webSocket server",t.data)),D.requestCompleted=!0,D.consecutiveNoResponseRequest=0,"success"===r.content.status)D.consecutiveFailedSubscribeAttempts=0,r.content.topics.forEach((function(e){L.subscriptionHistory.delete(e),L.pending.delete(e),L.subscribed.add(e)})),0===L.subscriptionHistory.size?B(n.secondary)&&(ue(e.info("Successfully subscribed secondary websocket to all topics of primary websocket")),te(n.primary,"[Primary WebSocket] Closing WebSocket")):ee(),U(k.subscriptionUpdate,r);else{if(clearInterval(D.reSubscribeIntervalId),++D.consecutiveFailedSubscribeAttempts,5===D.consecutiveFailedSubscribeAttempts)return U(k.subscriptionFailure,r),void(D.consecutiveFailedSubscribeAttempts=0);D.reSubscribeIntervalId=setInterval((function(){ee()}),500)}break;case A:ue(e.debug("Heartbeat response received")),R.pendingResponse=!1;break;default:if(r.topic){if(e.advancedLog(C,r.topic),ue(e.debug(C+r.topic)),B(n.primary)&&B(n.secondary)&&0===L.subscriptionHistory.size&&this===n.primary)return void ue(e.warn("Ignoring Message for Topic "+r.topic+", to avoid duplicates"));if(0===k.allMessage.size&&0===k.topic.size)return void ue(e.warn("No registered callback listener for Topic",r.topic));e.advancedLog("WebsocketManager invoke callbacks for topic success ",r.topic),U(k.allMessage,r),k.topic.has(r.topic)&&U(k.topic.get(r.topic),r)}else r.message?(e.advancedLog(T,r),ue(e.warn(T,r))):(e.advancedLog(I,r),ue(e.warn(I,r)))}},ee=function t(){if(D.consecutiveNoResponseRequest>3)return ue(e.warn("Ignoring subscribePendingTopics since we have exhausted max subscription retries with no response")),void U(k.subscriptionFailure,O.getSubscriptionResponse(_,!1,Array.from(L.pending)));H()?0!==Array.from(L.pending).length&&(clearInterval(D.responseCheckIntervalId),W().send(oe(_,{topics:Array.from(L.pending)})),D.requestCompleted=!1,D.responseCheckIntervalId=setInterval((function(){D.requestCompleted||(++D.consecutiveNoResponseRequest,t())}),1e3)):ue(e.warn("Ignoring subscribePendingTopics call since Default WebSocket is not open"))},te=function(t,n){j(t,WebSocket.CONNECTING)||j(t,WebSocket.OPEN)?t.close(1e3,n):ue(e.warn("Ignoring WebSocket Close request, WebSocket State: "+F(t)))},ne=function(e){te(n.primary,"[Primary] WebSocket "+e),te(n.secondary,"[Secondary] WebSocket "+e)},re=function(t){X(),Y(),e.advancedLog(m,t),ue(e.error(m)),r.websocketInitFailed=!0,ne("Terminating WebSocket Manager"),clearInterval(M),U(k.initFailure,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,reason:t}),J()},oe=function(e,t){return JSON.stringify({topic:e,content:t})},ie=function(t){return!!(O.isObject(t)&&O.isObject(t.webSocketTransport)&&O.isNonEmptyString(t.webSocketTransport.url)&&O.validWSUrl(t.webSocketTransport.url)&&1e3*t.webSocketTransport.transportLifeTimeInSeconds>=3e5)||(ue(e.error("Invalid WebSocket Connection Configuration",t)),!1)},se=function(){if(!O.isNetworkOnline())return e.advancedLog(c),void ue(e.info(c));if(r.websocketInitFailed)ue(e.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request"));else{if(N.promiseCompleted)return X(),e.advancedLog(v),ue(e.info(v)),o.connectionAttemptStartTime=o.connectionAttemptStartTime||Date.now(),N.promiseCompleted=!1,N.promiseHandle=k.getWebSocketTransport(),N.promiseHandle.then((function(t){return N.promiseCompleted=!0,e.advancedLog(y),ue(e.debug(y,t)),ie(t)?(N.connConfig=t,N.connConfig.urlConnValidTime=Date.now()+85e3,ae()):(re("Invalid WebSocket connection configuration: "+t),{webSocketConnectionFailed:!0})}),(function(t){return N.promiseCompleted=!0,e.advancedLog(E),ue(e.error(E,t)),O.isNetworkFailure(t)?(e.advancedLog(S+JSON.stringify(t)),ue(e.info(S+JSON.stringify(t))),P.retry()):re("Failed to fetch webSocket connection configuration: "+JSON.stringify(t)),{webSocketConnectionFailed:!0}}));ue(e.debug("There is an ongoing getWebSocketConnConfig request, this request will be ignored"))}},ae=function(){if(r.websocketInitFailed)return ue(e.info("web-socket initializing had failed, aborting re-init")),{webSocketConnectionFailed:!0};if(!O.isNetworkOnline())return ue(e.warn("System is offline aborting web-socket init")),{webSocketConnectionFailed:!0};e.advancedLog(b),ue(e.info(b)),q("initWebSocket");try{if(ie(N.connConfig)){var t=null;return B(n.primary)?(ue(e.debug("Primary Socket connection is already open")),j(n.secondary,WebSocket.CONNECTING)||(ue(e.debug("Establishing a secondary web-socket connection")),P.numAttempts=0,n.secondary=ce()),t=n.secondary):(j(n.primary,WebSocket.CONNECTING)||(ue(e.debug("Establishing a primary web-socket connection")),n.primary=ce()),t=n.primary),r.webSocketInitCheckerTimeoutId=setTimeout((function(){B(t)||function(){o.connectWebSocketRetryCount++;var t=O.addJitter(r.exponentialBackOffTime,.3);Date.now()+t<=N.connConfig.urlConnValidTime?(e.advancedLog(f),ue(e.debug(f+t+" ms")),r.exponentialTimeoutHandle=setTimeout((function(){return ae()}),t),r.exponentialBackOffTime*=2):(e.advancedLog(g),ue(e.warn(g)),se())}()}),1e3),{webSocketConnectionFailed:!1}}}catch(t){return ue(e.error("Error Initializing web-socket-manager",t)),re("Failed to initialize new WebSocket: "+t.message),{webSocketConnectionFailed:!0}}},ce=function(){var t=new WebSocket(N.connConfig.webSocketTransport.url);return t.addEventListener("open",Q),t.addEventListener("message",Z),t.addEventListener("error",$),t.addEventListener("close",(function(i){return function(t,i){e.advancedLog(d,JSON.stringify(t)),ue(e.info(d,JSON.stringify(t))),q("webSocketOnClose before-cleanup"),U(k.connectionClose,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),V(n.primary)&&(n.primary=null),V(n.secondary)&&(n.secondary=null),r.reconnectWebSocket&&(B(n.primary)||B(n.secondary)?V(n.primary)&&B(n.secondary)&&(ue(e.info("[Primary] WebSocket Cleanly Closed")),n.primary=n.secondary,n.secondary=null):(ue(e.warn("Neither primary websocket and nor secondary websocket have open connections, attempting to re-establish connection")),r.connState===w?ue(e.info("Ignoring connectionLost callback invocation")):(U(k.connectionLost,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),o.noOpenConnectionsTimestamp=Date.now()),r.connState=w,se()),q("webSocketOnClose after-cleanup"))}(i,t)})),t},ue=function(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e};this.init=function(t){if(O.assertTrue(O.isFunction(t),"transportHandle must be a function"),null===k.getWebSocketTransport)return k.getWebSocketTransport=t,se();ue(e.warn("Web Socket Manager was already initialized"))},this.onInitFailure=function(t){return e.advancedLog("Initializing Websocket Manager Failed!"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.initFailure.add(t),r.websocketInitFailed&&t(),function(){return k.initFailure.delete(t)}},this.onConnectionOpen=function(t){return e.advancedLog("Websocket connection open"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionOpen.add(t),function(){return k.connectionOpen.delete(t)}},this.onConnectionClose=function(t){return e.advancedLog("Websocket connection close"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionClose.add(t),function(){return k.connectionClose.delete(t)}},this.onConnectionGain=function(t){return e.advancedLog("Websocket connection gain"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionGain.add(t),H()&&t(),function(){return k.connectionGain.delete(t)}},this.onConnectionLost=function(t){return e.advancedLog("Websocket connection lost"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionLost.add(t),r.connState===w&&t(),function(){return k.connectionLost.delete(t)}},this.onSubscriptionUpdate=function(e){return O.assertTrue(O.isFunction(e),"cb must be a function"),k.subscriptionUpdate.add(e),function(){return k.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(t){return e.advancedLog("Websocket subscription failure"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.subscriptionFailure.add(t),function(){return k.subscriptionFailure.delete(t)}},this.onMessage=function(e,t){return O.assertNotNull(e,"topicName"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.topic.has(e)?k.topic.get(e).add(t):k.topic.set(e,new Set([t])),function(){return k.topic.get(e).delete(t)}},this.onAllMessage=function(e){return O.assertTrue(O.isFunction(e),"cb must be a function"),k.allMessage.add(e),function(){return k.allMessage.delete(e)}},this.subscribeTopics=function(e){O.assertNotNull(e,"topics"),O.assertIsList(e),e.forEach((function(e){L.subscribed.has(e)||L.pending.add(e)})),D.consecutiveNoResponseRequest=0,ee()},this.sendMessage=function(t){if(O.assertIsObject(t,"payload"),void 0===t.topic||x.has(t.topic))ue(e.warn("Cannot send message, Invalid topic",t));else{try{t=JSON.stringify(t)}catch(n){return void ue(e.warn("Error stringify message",t))}H()?W().send(t):ue(e.warn("Cannot send message, web socket connection is not open"))}},this.closeWebSocket=function(){X(),Y(),r.reconnectWebSocket=!1,clearInterval(M),ne("User request to close WebSocket")},this.terminateWebSocketManager=re},Y={create:function(){return new X},setGlobalConfig:function(e){var t=e&&e.loggerConfig;z.updateLoggerConfig(t)},LogLevel:j,Logger:F}},function(e,t,n){var r;!function(){"use strict";var o={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function i(e){return function(e,t){var n,r,s,a,c,u,l,p,d,h=1,f=e.length,g="";for(r=0;r=0),a.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,a.width?parseInt(a.width):0);break;case"e":n=a.precision?parseFloat(n).toExponential(a.precision):parseFloat(n).toExponential();break;case"f":n=a.precision?parseFloat(n).toFixed(a.precision):parseFloat(n);break;case"g":n=a.precision?String(Number(n.toPrecision(a.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=a.precision?n.substring(0,a.precision):n;break;case"t":n=String(!!n),n=a.precision?n.substring(0,a.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=a.precision?n.substring(0,a.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=a.precision?n.substring(0,a.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}o.json.test(a.type)?g+=n:(!o.number.test(a.type)||p&&!a.sign?d="":(d=p?"+":"-",n=n.toString().replace(o.sign,"")),u=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",l=a.width-(d+n).length,c=a.width&&l>0?u.repeat(l):"",g+=a.align?d+n+c:"0"===u?d+c+n:c+d+n)}return g}(function(e){if(a[e])return a[e];for(var t,n=e,r=[],i=0;n;){if(null!==(t=o.text.exec(n)))r.push(t[0]);else if(null!==(t=o.modulo.exec(n)))r.push("%");else{if(null===(t=o.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){i|=1;var s=[],c=t[2],u=[];if(null===(u=o.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(c=c.substring(u[0].length));)if(null!==(u=o.key_access.exec(c)))s.push(u[1]);else{if(null===(u=o.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}t[2]=s}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return a[e]=r}(e),arguments)}function s(e,t){return i.apply(null,[e].concat(t||[]))}var a=Object.create(null);t.sprintf=i,t.vsprintf=s,"undefined"!=typeof window&&(window.sprintf=i,window.vsprintf=s,void 0===(r=function(){return{sprintf:i,vsprintf:s}}.call(t,n,t,e))||(e.exports=r))}()},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"WebSocketManager",(function(){return o}));var r=n(0);e.connect=e.connect||{},connect.WebSocketManager=r.a;var o=r.a}.call(this,n(3))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n}])},151:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n={TEST:"TEST",TRACE:"TRACE",DEBUG:"DEBUG",INFO:"INFO",LOG:"LOG",WARN:"WARN",ERROR:"ERROR",CRITICAL:"CRITICAL"},r={CCP:"ccp",SOFTPHONE:"softphone",CHAT:"chat",TASK:"task"},o={TEST:0,TRACE:10,DEBUG:20,INFO:30,LOG:40,WARN:50,ERROR:100,CRITICAL:200},i={TRACE:function(e){console.info(e)},DEBUG:function(e){console.info(e)},INFO:function(e){console.info(e)},LOG:function(e){console.log(e)},TEST:function(e){console.log(e)},WARN:function(e){console.warn(e)},ERROR:function(e){console.error(e)},CRITICAL:function(e){console.error(e)}},s=function(e){var t,n,o=Array.prototype.slice.call(e,0),i=o.shift();return function(e){return-1!==Object.values(r).indexOf(e)}(i)?(n=i,t=o.shift()):(t=i,n=r.CCP),{format:t,component:n,args:o}},a=function(e,n,r,o){this.component=e,this.level=n,this.text=r,this.time=new Date,this.exception=null,this.objects=[],this.line=0,this.agentResourceId=null;try{t.agent.initialized&&(this.agentResourceId=(new t.Agent)._getResourceId())}catch(e){console.log("Issue finding agentResourceId: ",e)}this.loggerId=o};a.fromObject=function(e){var t=new a(r.CCP,e.level,e.text,e.loggerId);return"[object Date]"===Object.prototype.toString.call(e.time)?t.time=new Date(e.time.getTime()):"number"==typeof e.time?t.time=new Date(e.time):"string"==typeof e.time?t.time=Date.parse(e.time):t.time=new Date,t.exception=e.exception,t.objects=e.objects,t};var c=function(e){var t=/AuthToken.*\=/g;e&&"object"==typeof e&&Object.keys(e).forEach((function(n){"object"==typeof e[n]?c(e[n]):"string"==typeof e[n]&&("url"===n||"text"===n?e[n]=e[n].replace(t,"[redacted]"):["quickConnectName"].includes(n)?e[n]="[redacted]":["customerId","CustomerId","SpeakerId","CustomerSpeakerId"].includes(n)&&(e[n]=md5(e[n])))}))},u=function(e){if(this.type=e instanceof Error?e.name:e.code||Object.prototype.toString.call(e),this.message=e.message,this.stack=[],e.stack)try{Array.isArray(e.stack)?this.stack=e.stack:"object"==typeof e.stack?this.stack=[JSON.stringify(e.stack)]:"string"==typeof e.stack&&(this.stack=e.stack.split("\n"))}catch{}};a.prototype.toString=function(){return t.sprintf("[%s] [%s] [%s]: %s",this.getTime()&&this.getTime().toISOString?this.getTime().toISOString():"???",this.getLevel(),this.getAgentResourceId(),this.getText())},a.prototype.getTime=function(){return this.time},a.prototype.getAgentResourceId=function(){return this.agentResourceId},a.prototype.getLevel=function(){return this.level},a.prototype.getText=function(){return this.text},a.prototype.getComponent=function(){return this.component},a.prototype.withException=function(e){return this.exception=new u(e),this},a.prototype.withObject=function(e){var n=t.deepcopy(e);return c(n),this.objects.push(n),this},a.prototype.withCrossOriginEventObject=function(e){var n=t.deepcopyCrossOriginEvent(e);return c(n),this.objects.push(n),this},a.prototype.sendInternalLogToServer=function(){return t.getLog()._serverBoundInternalLogs.push(this),this};var l=function(){this._logs=[],this._rolledLogs=[],this._logsToPush=[],this._serverBoundInternalLogs=[],this._echoLevel=o.INFO,this._logLevel=o.INFO,this._lineCount=0,this._logRollInterval=0,this._logRollTimer=null,this._loggerId=(new Date).getTime()+"-"+Math.random().toString(36).slice(2),this.setLogRollInterval(18e5),this._startLogIndexToPush=0};l.prototype.setLogRollInterval=function(t){var n=this;this._logRollTimer&&t===this._logRollInterval?this.warn("Logger is already set to the given interval: %d",this._logRollInterval):(this._logRollTimer&&e.clearInterval(this._logRollTimer),this._logRollInterval=t,this._logRollTimer=e.setInterval((function(){n._rolledLogs=n._logs,n._logs=[],n._startLogIndexToPush=0,n.info("Log roll interval occurred.")}),this._logRollInterval))},l.prototype.setLogLevel=function(e){if(!(e in o))throw new Error("Unknown logging level: "+e);this._logLevel=o[e]},l.prototype.setEchoLevel=function(e){if(!(e in o))throw new Error("Unknown logging level: "+e);this._echoLevel=o[e]},l.prototype.write=function(e,t,n){var r=new a(e,t,n,this.getLoggerId());return c(r),this.addLogEntry(r),r},l.prototype.addLogEntry=function(e){c(e),this._logs.push(e),r.SOFTPHONE===e.component&&this._logsToPush.push(e),e.level in o&&o[e.level]>=this._logLevel&&(o[e.level]>=this._echoLevel&&i[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.sendInternalLogEntryToServer=function(e){this._serverBoundInternalLogs.push(e),e.level in o&&o[e.level]>=this._logLevel&&(o[e.level]>=this._echoLevel&&i[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.clearObjects=function(){for(var e=0;e=i._logLevel})));var a=new e.Blob([JSON.stringify(s,void 0,4)],["text/plain"]),c=document.createElement("a");n=n||"agent-log",c.href=e.URL.createObjectURL(a),c.download=n+".txt",document.body.appendChild(c),c.click(),document.body.removeChild(c)},l.prototype.scheduleUpstreamLogPush=function(n){t.upstreamLogPushScheduled||(t.upstreamLogPushScheduled=!0,e.setInterval(t.hitch(this,this.reportMasterLogsUpStream,n),5e3))},l.prototype.reportMasterLogsUpStream=function(e){var n=this._logsToPush.slice();this._logsToPush=[],t.ifMaster(t.MasterTopics.SEND_LOGS,(function(){n.length>0&&e.sendUpstream(t.EventType.SEND_LOGS,n)}))},l.prototype.scheduleUpstreamOuterContextCCPserverBoundLogsPush=function(n){e.setInterval(t.hitch(this,this.pushOuterContextCCPserverBoundLogsUpstream,n),1e3)},l.prototype.scheduleUpstreamOuterContextCCPLogsPush=function(n){e.setInterval(t.hitch(this,this.pushOuterContextCCPLogsUpstream,n),1e3)},l.prototype.pushOuterContextCCPserverBoundLogsUpstream=function(e){if(this._serverBoundInternalLogs.length>0){for(var n=0;n500?e=this._serverBoundInternalLogs.splice(0,500):(e=this._serverBoundInternalLogs,this._serverBoundInternalLogs=[]),t.publishClientSideLogs(e))};var p=function(n){l.call(this),this.conduit=n,e.setInterval(t.hitch(this,this._pushLogsDownstream),p.LOG_PUSH_INTERVAL),e.clearInterval(this._logRollTimer),this._logRollTimer=null};p.LOG_PUSH_INTERVAL=1e3,p.prototype=Object.create(l.prototype),p.prototype.constructor=p,p.prototype.pushLogsDownstream=function(e){var n=this;e.forEach((function(e){n.conduit.sendDownstream(t.EventType.LOG,e)}))},p.prototype._pushLogsDownstream=function(){var e=this;this._logs.forEach((function(n){e.conduit.sendDownstream(t.EventType.LOG,n)})),this._logs=[];for(var n=0;n>16)+(t>>16)+(n>>16)<<16|65535&n}function n(e,n,r,o,i,s){return t((a=t(t(n,e),t(o,s)))<<(c=i)|a>>>32-c,r);var a,c}function r(e,t,r,o,i,s,a){return n(t&r|~t&o,e,t,i,s,a)}function o(e,t,r,o,i,s,a){return n(t&o|r&~o,e,t,i,s,a)}function i(e,t,r,o,i,s,a){return n(t^r^o,e,t,i,s,a)}function s(e,t,r,o,i,s,a){return n(r^(t|~o),e,t,i,s,a)}function a(e,n){var a,c,u,l,p;e[n>>5]|=128<>>9<<4)]=n;var d=1732584193,h=-271733879,f=-1732584194,g=271733878;for(a=0;a>5]>>>t%32&255);return n}function u(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function p(e){return unescape(encodeURIComponent(e))}function d(e){return function(e){return c(a(u(e),8*e.length))}(p(e))}function h(e,t){return function(e,t){var n,r,o=u(e),i=[],s=[];for(i[15]=s[15]=void 0,o.length>16&&(o=a(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],s[n]=1549556828^o[n];return r=a(i.concat(u(t)),512+8*t.length),c(a(s.concat(r),640))}(p(e),p(t))}(this||globalThis).md5=function(e,t,n){return t?n?h(t,e):l(h(t,e)):n?d(e):l(d(e))}}()},439:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.ChatMediaController=function(e,n){var r=t.getLog(),o=t.LogComponent.CHAT,i=function(n,r){t.publishMetric({name:n,contactId:e.contactId,data:r||e})},s=function(e){e.onConnectionBroken((function(e){r.error(o,"Chat Session connection broken").withException(e).sendInternalLogToServer(),i("Chat Session connection broken",e)})),e.onConnectionEstablished((function(e){r.info(o,"Chat Session connection established").withObject(e).sendInternalLogToServer(),i("Chat Session connection established",e)}))};return{get:function(){return function(){i("Chat media controller init",e.contactId),r.info(o,"Chat media controller init").withObject(e).sendInternalLogToServer(),t.ChatSession.setGlobalConfig({loggerConfig:{logger:r},region:n.region});var a=t.ChatSession.create({chatDetails:e,type:"AGENT",websocketManager:t.core.getWebSocketManager()});return s(a),a.connect().then((function(t){return r.info(o,"Chat Session Successfully established for contactId %s",e.contactId).sendInternalLogToServer(),i("Chat Session Successfully established",e.contactId),a})).catch((function(t){throw r.error(o,"Chat Session establishement failed for contact %s",e.contactId).withException(t).sendInternalLogToServer(),i("Chat Session establishement failed",e.contactId,t),t}))}()}}}}()},279:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.MediaFactory=function(e){var n={},r=new Set,o=t.getLog(),i=t.LogComponent.CHAT,s=t.merge({},e)||{};s.region=s.region||"us-west-2";var a=function(e){n[e]&&!r.has(e)&&(o.info(i,"Destroying mediaController for %s",e),r.add(e),n[e].then((function(){"function"==typeof controller.cleanUp&&controller.cleanUp(),delete n[e],r.delete(e)})).catch((function(){delete n[e],r.delete(e)})))};return{get:function(e){return function(e){return e.isActive()}(e)?function(e){var r=e.getConnectionId();if(!e.getMediaInfo())return o.error(i,"Media info does not exist for a media type %s",e.getMediaType()).withObject(e).sendInternalLogToServer(),Promise.reject("Media info does not exist for this connection");if(n[r])return n[r];switch(o.info(i,"media controller of type %s init",e.getMediaType()).withObject(e).sendInternalLogToServer(),e.getMediaType()){case t.MediaType.CHAT:return n[r]=new t.ChatMediaController(e.getMediaInfo(),s).get();case t.MediaType.SOFTPHONE:return n[r]=new t.SoftphoneMediaController(e.getMediaInfo()).get();case t.MediaType.TASK:return n[r]=new t.TaskMediaController(e.getMediaInfo()).get();default:return o.error(i,"Unrecognized media type %s ",e.getMediaType()).sendInternalLogToServer(),Promise.reject()}}(e):(a(e.getConnectionId()),Promise.reject("Media Controller is no longer available for this connection"))},destroy:a}}}()},418:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.SoftphoneMediaController=function(e){return{get:function(){return Promise.resolve(e)}}}}()},187:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.TaskMediaController=function(e){var n=t.getLog(),r=t.LogComponent.TASK,o=function(n,r){t.publishMetric({name:n,contactId:e.contactId,data:r||e})},i=function(e){e.onConnectionBroken((function(e){n.error(r,"Task Session connection broken").withException(e),o("Task Session connection broken",e)})),e.onConnectionEstablished((function(e){n.info(r,"Task Session connection established").withObject(e),o("Task Session connection established",e)}))};return{get:function(){return function(){o("Task media controller init",e.contactId),n.info(r,"Task media controller init").withObject(e);var s=t.TaskSession.create({contactId:e.contactId,initialContactId:e.initialContactId,websocketManager:t.core.getWebSocketManager()});return i(s),s.connect().then((function(){return n.info(r,"Task Session Successfully established for contactId %s",e.contactId),o("Task Session Successfully established",e.contactId),s})).catch((function(t){throw n.error(r,"Task Session establishement failed for contact %s",e.contactId).withException(t),o("Chat Session establishement failed",e.contactId,t),t}))}()}}}}()},743:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=function(n){var r=this;if(this._prevContactId=null,t.assertNotNull(n,"ringtoneConfig"),!n.ringtoneUrl)throw new Error("ringtoneUrl is required!");e.Audio&&void 0!==e.Promise?this._playableAudioPromise=new Promise((function(e,o){r._audio=new Audio(n.ringtoneUrl),r._audio.loop=!0,r._audio.addEventListener("canplay",(function(){t.getLog().info("Ringtone is ready to play: ",+n.ringtoneUrl).sendInternalLogToServer(),r._audioPlayable=!0,e(r._audio)}))})):(this._audio=null,t.getLog().error("Unable to provide a ringtone.").sendInternalLogToServer()),r._driveRingtone()};n.prototype._driveRingtone=function(){throw new Error("Not implemented.")},n.prototype._startRingtone=function(e){var n=this;this._audio&&(this._audio.play().catch((function(r){n._publishTelemetryEvent("Ringtone Playback Failure",e),t.getLog().error("Ringtone Playback Failure").withException(r).withObject({currentSrc:n._audio.currentSrc,sinkId:n._audio.sinkId,volume:n._audio.volume}).sendInternalLogToServer()})),n._publishTelemetryEvent("Ringtone Start",e),t.getLog().info("Ringtone Start").sendInternalLogToServer())},n.prototype._stopRingtone=function(e){this._audio&&(this._audio.pause(),this._audio.currentTime=0,this._publishTelemetryEvent("Ringtone Stop",e),t.getLog().info("Ringtone Stop").sendInternalLogToServer())},n.prototype.stopRingtone=function(){this._stopRingtone()},n.prototype._ringtoneSetup=function(e){var n=this;t.ifMaster(t.MasterTopics.RINGTONE,(function(){n._startRingtone(e),n._prevContactId=e.getContactId(),e.onConnected(lily.hitch(n,n._stopRingtone)),e.onAccepted(lily.hitch(n,n._stopRingtone)),e.onEnded(lily.hitch(n,n._stopRingtone)),e.onRefresh((function(e){e.getStatus().type!==t.ContactStatusType.CONNECTING&&e.getStatus().type!==t.ContactStatusType.INCOMING&&n._stopRingtone()}))}))},n.prototype._publishTelemetryEvent=function(e,n){n&&n.getContactId()&&t.publishMetric({name:e,contactId:n.getContactId()})},n.prototype.setOutputDevice=function(t){return this._playableAudioPromise?Promise.race([this._playableAudioPromise,new Promise((function(t,n){e.setTimeout((function(){n("Timed out waiting for playable audio")}),3e3)}))]).then((function(e){return e?e.setSinkId?Promise.resolve(e.setSinkId(t)):Promise.reject("Not supported"):Promise.reject("No audio found")})):e.Promise?Promise.reject("Not eligible ringtone owner"):void 0};var r=function(e){n.call(this,e)};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype._driveRingtone=function(){var e=this,n=function(n){n.getType()===lily.ContactType.VOICE&&n.isSoftphoneCall()&&n.isInbound()&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Ringtone Connecting",n),t.getLog().info("Ringtone Connecting").sendInternalLogToServer())};t.contact((function(e){e.onConnecting(n)})),(new t.Agent).getContacts().forEach((function(e){e.getStatus().type===t.ContactStatusType.CONNECTING&&n(e)}))};var o=function(e){n.call(this,e)};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype._driveRingtone=function(){var e=this,n=function(n){n.getType()===lily.ContactType.CHAT&&n.isInbound()&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Chat Ringtone Connecting",n),t.getLog().info("Chat Ringtone Connecting").sendInternalLogToServer())};t.contact((function(e){e.onConnecting(n)}))};var i=function(e){n.call(this,e)};(i.prototype=Object.create(n.prototype)).constructor=i,i.prototype._driveRingtone=function(){var e=this,n=function(n){n.getType()===lily.ContactType.TASK&&n.isInbound()&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Task Ringtone Connecting",n),t.getLog().info("Task Ringtone Connecting").sendInternalLogToServer())};t.contact((function(e){e.onConnecting(n)}))};var s=function(e){n.call(this,e)};(s.prototype=Object.create(n.prototype)).constructor=s,s.prototype._driveRingtone=function(){var e=this;t.contact((function(n){n.onIncoming((function(){n.getType()===lily.ContactType.QUEUE_CALLBACK&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Callback Ringtone Connecting",n),t.getLog().info("Callback Ringtone Connecting").sendInternalLogToServer())}))}))},t.VoiceRingtoneEngine=r,t.ChatRingtoneEngine=o,t.TaskRingtoneEngine=i,t.QueueCallbackRingtoneEngine=s}()},642:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,e.ccpVersion="V2";var n={};n[t.SoftphoneCallType.AUDIO_ONLY]="Audio",n[t.SoftphoneCallType.VIDEO_ONLY]="Video",n[t.SoftphoneCallType.AUDIO_VIDEO]="AudioVideo",n[t.SoftphoneCallType.NONE]="None";var r="audio_input",o="audio_output";({})[t.ContactType.VOICE]="Voice";var i=[],s={},a={},c=null,u=null,l=null,p=t.SoftphoneErrorTypes,d={},h=t.randomId(),f=function(e){return new Promise((function(n,r){t.core.getClient().call(t.ClientMethods.CREATE_TRANSPORT,e,{success:function(e){n(e.softphoneTransport.softphoneMediaConnections)},failure:function(e){e.message&&e.message.includes("SoftphoneConnectionLimitBreachedException")&&w("multiple_softphone_active_sessions","Number of active sessions are more then allowed limit.",""),r(Error("requestIceAccess failed"))},authFailure:function(){r(Error("Authentication failed while requestIceAccess"))},accessDenied:function(){r(Error("Access Denied while requestIceAccess"))}})}))},g=function(e){var n=t.core.getUpstream(),r=e.getAgentConnection();if(r){var o=r.getSoftphoneMediaInfo();o?!0===o.autoAccept?(l.info("Auto-accept is enabled, sending out Accepted event to stop ringtone..").sendInternalLogToServer(),n.sendUpstream(t.EventType.BROADCAST,{event:t.ContactEvents.ACCEPTED,data:new t.Contact(e.contactId)}),n.sendUpstream(t.EventType.BROADCAST,{event:t.core.getContactEventName(t.ContactEvents.ACCEPTED,e.contactId),data:new t.Contact(e.contactId)})):l.info("Auto-accept is disabled, ringtone will be stopped by user action.").sendInternalLogToServer():l.info("Not able to retrieve the auto-accept setting from null SoftphoneMediaInfo, ignoring event publish..").sendInternalLogToServer()}else l.info("Not able to retrieve the auto-accept setting from null AgentConnection, ignoring event publish..").sendInternalLogToServer()},m=function(){t.core.getEventBus().subscribe(t.EventType.MUTE,b)},v=function(){t.core.getEventBus().subscribe(t.ConfigurationEvents.SET_SPEAKER_DEVICE,T)},y=function(){t.core.getEventBus().subscribe(t.ConfigurationEvents.SET_MICROPHONE_DEVICE,C)},E=function(){try{t.isChromeBrowser()&&t.getChromeBrowserVersion()>43&&navigator.permissions.query({name:"microphone"}).then((function(e){e.onchange=function(){l.info("Microphone Permission: "+e.state),k("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:e.state}),"denied"===e.state&&w(p.MICROPHONE_NOT_SHARED,"Your microphone is not enabled in your browser. ","")}}))}catch(e){l.error("Failed in detecting microphone permission status: "+e)}},S=function(e){delete d[e],t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.MUTE_TOGGLE,data:{muted:!1}})},b=function(e){var n;if(0!==t.keys(d).length){for(var r in e&&void 0!==e.mute&&(n=e.mute),d)if(d.hasOwnProperty(r)){var o=d[r].stream;if(o){var i=o.getAudioTracks()[0];void 0!==n?(i.enabled=!n,d[r].muted=n,n?l.info("Agent has muted the contact, connectionId - "+r).sendInternalLogToServer():l.info("Agent has unmuted the contact, connectionId - "+r).sendInternalLogToServer()):n=d[r].muted||!1}}t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.MUTE_TOGGLE,data:{muted:n}})}},T=function(e){if(0!==t.keys(d).length&&e&&e.deviceId){var n=e.deviceId,r=document.getElementById("remote-audio");try{l.info("Trying to set speaker to device "+n),r&&"function"==typeof r.setSinkId&&r.setSinkId(n)}catch(e){l.error("Failed to set speaker to device "+n)}t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,data:{deviceId:n}})}},C=function(e){if(0!==t.keys(d).length&&e&&e.deviceId){var n=e.deviceId,r=t.core.getSoftphoneManager();try{navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:n}}}).then((function(e){var t=e.getAudioTracks()[0];for(var n in d)d.hasOwnProperty(n)&&(d[n].stream,r.getSession(n)._pc.getSenders()[0].replaceTrack(t).then((function(){r.replaceLocalMediaTrack(n,t)})))}))}catch(e){l.error("Failed to set microphone device "+n)}t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,data:{deviceId:n}})}},I=function(e,n){if(n===t.RTCErrors.ICE_COLLECTION_TIMEOUT){for(var r="\n",o=0;o0?t.success(e):t.failure(p.MICROPHONE_NOT_SHARED)}),(function(e){t.failure(p.MICROPHONE_NOT_SHARED)})),r}t.failure(p.UNSUPPORTED_BROWSER)},w=function(e,n,r){l.error("Softphone error occurred : ",e,n||"").sendInternalLogToServer(),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.SOFTPHONE_ERROR,data:new t.SoftphoneError(e,n,r)})},R=function(e,t){k("Softphone Session Failed",e,{failedReason:t})},k=function(e,n,r){t.publishMetric({name:e,contactId:n,data:r})},N=function(e,t,n){k(e,t,[{name:"AgentConnectionId",value:n}]),l.info("Publish multiple session error metrics",e,"contactId "+t,"agent connectionId "+n).sendInternalLogToServer()},O=function(){return!!(t.isOperaBrowser()&&t.getOperaBrowserVersion()>17)||!!(t.isChromeBrowser()&&t.getChromeBrowserVersion()>22)||!!(t.isFirefoxBrowser()&&t.getFirefoxBrowserVersion()>21)},L=function(e){var t=i.slice();i=[],t.length>0&&e.sendSoftphoneMetrics(t,{success:function(){l.info("sendSoftphoneMetrics success"+JSON.stringify(t)).sendInternalLogToServer()},failure:function(e){l.error("sendSoftphoneMetrics failed.").withObject(e).sendInternalLogToServer()}})},D=function(e){c=window.setInterval((function(){e.getUserAudioStats().then((function(e){var t=s;s=e,i.push(M(s,t,r))}),(function(e){l.debug("Failed to get user audio stats.",e).sendInternalLogToServer()})),e.getRemoteAudioStats().then((function(e){var t=a;a=e,i.push(M(a,t,o))}),(function(e){l.debug("Failed to get remote audio stats.",e).sendInternalLogToServer()}))}),1e3)},P=function(e){u=window.setInterval((function(){L(e)}),3e4)},x=function(){s=null,a=null,i=[],c=null,u=null},M=function(e,t,n){if(t&&e){var r=e.packetsLost>t.packetsLost?e.packetsLost-t.packetsLost:0,o=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new q(e.timestamp,r,o,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new q(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},U=function(e){return null!==e&&window.clearInterval(e),null},F=function(e,t){c=U(c),u=U(u),function(e,t,n,i){t.streamStats=[j(n,r),j(i,o)];var s={callStartTime:t.sessionStartTime,callEndTime:t.sessionEndTime,gumTimeMillis:t.gumTimeMillis,initializationTimeMillis:t.initializationTimeMillis,iceCollectionTimeMillis:t.iceCollectionTimeMillis,signallingConnectTimeMillis:t.signallingConnectTimeMillis,handshakingTimeMillis:t.handshakingTimeMillis,preTalkingTimeMillis:t.preTalkingTimeMillis,talkingTimeMillis:t.talkingTimeMillis,cleanupTimeMillis:t.cleanupTimeMillis,iceCollectionFailure:t.iceCollectionFailure,signallingConnectionFailure:t.signallingConnectionFailure,handshakingFailure:t.handshakingFailure,gumOtherFailure:t.gumOtherFailure,gumTimeoutFailure:t.gumTimeoutFailure,createOfferFailure:t.createOfferFailure,setLocalDescriptionFailure:t.setLocalDescriptionFailure,userBusyFailure:t.userBusyFailure,invalidRemoteSDPFailure:t.invalidRemoteSDPFailure,noRemoteIceCandidateFailure:t.noRemoteIceCandidateFailure,setRemoteDescriptionFailure:t.setRemoteDescriptionFailure,softphoneStreamStatistics:t.streamStats};e.sendSoftphoneReport(s,{success:function(){l.info("sendSoftphoneReport success"+JSON.stringify(s)).sendInternalLogToServer()},failure:function(e){l.error("sendSoftphoneReport failed.").withObject(e).sendInternalLogToServer()}})}(e,t,j(s,r),j(a,o)),L(e)},q=function(e,t,n,r,o,i,s){this.softphoneStreamType=r,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=o,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},j=function(e,t){return new q((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},B=function(e){this._originalLogger=e;var n=this;this._tee=function(e,r){return function(){var e=Array.prototype.slice.call(arguments[0]),o="";return e.forEach((function(){o+=" %s"})),r.apply(n._originalLogger,[t.LogComponent.SOFTPHONE,o].concat(e))}}};B.prototype.debug=function(){return this._tee(1,this._originalLogger.debug)(arguments)},B.prototype.info=function(){return this._tee(2,this._originalLogger.info)(arguments)},B.prototype.log=function(){return this._tee(3,this._originalLogger.log)(arguments)},B.prototype.warn=function(){return this._tee(4,this._originalLogger.warn)(arguments)},B.prototype.error=function(){return this._tee(5,this._originalLogger.error)(arguments)},t.SoftphoneManager=function(e){var n,r=this;(l=new B(t.getLog())).info("[Softphone Manager] softphone manager initialization has begun").sendInternalLogToServer(),t.RtcPeerConnectionFactory&&(n=new t.RtcPeerConnectionFactory(l,t.core.getWebSocketManager(),h,t.hitch(r,f,{transportType:"softphone",softphoneClientId:h}),t.hitch(r,w))),O()||w(p.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ",""),A({success:function(e){k("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:"granted"})},failure:function(e){w(e,"Your microphone is not enabled in your browser. ",""),k("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:"denied"})}}),m(),v(),y(),E(),this.ringtoneEngine=null;var o={},i={};this.onInitContactSub={},this.onInitContactSub.unsubscribe=function(){};var s=!1,a=null,c=null,u=function(){s=!1,a=null,c=null};this.getSession=function(e){return o[e]},this.replaceLocalMediaTrack=function(e,t){var n=d[e].stream;if(n){var r=n.getAudioTracks()[0];t.enabled=r.enabled,r.enabled=!1,n.removeTrack(r),n.addTrack(t)}};var b=function(e){if(o.hasOwnProperty(e)){var t=o[e];new Promise((function(n,r){delete o[e],delete i[e],t.hangup()})).catch((function(t){lily.getLog().warn("Clean up the session locally "+e,t.message).sendInternalLogToServer()}))}};this.startSession=function(e,r){var p=s?a:e,h=s?c:r;if(p&&h){u(),i[h]=!0,l.info("Softphone call detected:","contactId "+p.getContactId(),"agent connectionId "+h).sendInternalLogToServer(),function(e){if(Object.keys(e).length>0){for(var t in e)e.hasOwnProperty(t)&&(N("MultiSessionHangUp",e[t].callId,t),b(t));throw new Error("duplicate session detected, refusing to setup new connection")}}(o),p.getStatus().type===t.ContactStatusType.CONNECTING&&k("Softphone Connecting",p.getContactId()),x();var f,m=p.getAgentConnection().getSoftphoneMediaInfo(),v=_(m.callConfigJson);v.useWebSocketProvider&&(f=t.core.getWebSocketManager());var y=new t.RTCSession(v.signalingEndpoint,v.iceServers,m.callContextToken,l,p.getContactId(),h,f);o[h]=y,t.core.getSoftphoneUserMediaStream()&&(y.mediaStream=t.core.getSoftphoneUserMediaStream()),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConnectionEvents.SESSION_INIT,data:{connectionId:h}}),y.onSessionFailed=function(e,t){delete o[h],delete i[h],I(e,t),R(p.getContactId(),t),F(p,e.sessionReport)},y.onSessionConnected=function(e){k("Softphone Session Connected",p.getContactId()),t.becomeMaster(t.MasterTopics.SEND_LOGS),D(e),P(p),g(p)},y.onSessionCompleted=function(e){k("Softphone Session Completed",p.getContactId()),delete o[h],delete i[h],F(p,e.sessionReport),S(h)},y.onLocalStreamAdded=function(e,n){d[h]={stream:n},t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,data:{connectionId:h}})},y.remoteAudioElement=document.getElementById("remote-audio"),n?y.connect(n.get(v.iceServers)):y.connect()}};var T=function(e,n){o[n]&&function(e){return e.getStatus().type===t.ContactStatusType.ENDED||e.getStatus().type===t.ContactStatusType.ERROR||e.getStatus().type===t.ContactStatusType.MISSED}(e)&&(b(n),u()),!e.isSoftphoneCall()||i[n]||e.getStatus().type!==t.ContactStatusType.CONNECTING&&e.getStatus().type!==t.ContactStatusType.INCOMING||(t.isFirefoxBrowser()&&t.hasOtherConnectedCCPs()?function(e,t){s=!0,a=e,c=t}(e,n):r.startSession(e,n))},C=function(e){var t=e.getAgentConnection().connectionId;l.info("Contact detected:","contactId "+e.getContactId(),"agent connectionId "+t).sendInternalLogToServer(),i[t]||e.onRefresh((function(){T(e,t)}))};r.onInitContactSub=t.contact(C),(new t.Agent).getContacts().forEach((function(e){var t=e.getAgentConnection().connectionId;l.info("Contact exist in the snapshot. Reinitiate the Contact and RTC session creation for contactId"+e.getContactId(),"agent connectionId "+t).sendInternalLogToServer(),C(e),T(e,t)}))}}()},944:()=>{!function(){var e=this||globalThis,t=function(){return t.cache.hasOwnProperty(arguments[0])||(t.cache[arguments[0]]=t.parse(arguments[0])),t.format.call(null,t.cache[arguments[0]],arguments)};function n(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function r(e,t){for(var n=[];t>0;n[--t]=e);return n.join("")}t.format=function(e,o){var i,s,a,c,u,l,p,d=1,h=e.length,f="",g=[];for(s=0;s>>=0;break;case"x":i=i.toString(16);break;case"X":i=i.toString(16).toUpperCase()}i=/[def]/.test(c[8])&&c[3]&&i>=0?"+"+i:i,l=c[4]?"0"==c[4]?"0":c[4].charAt(1):" ",p=c[6]-String(i).length,u=c[6]?r(l,p):"",g.push(c[5]?i+u:u+i)}return g.join("")},t.cache={},t.parse=function(e){for(var t=e,n=[],r=[],o=0;t;){if(null!==(n=/^[^\x25]+/.exec(t)))r.push(n[0]);else if(null!==(n=/^\x25{2}/.exec(t)))r.push("%");else{if(null===(n=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t)))throw"[sprintf] huh?";if(n[2]){o|=1;var i=[],s=n[2],a=[];if(null===(a=/^([a-z_][a-z_\d]*)/i.exec(s)))throw"[sprintf] huh?";for(i.push(a[1]);""!==(s=s.substring(a[0].length));)if(null!==(a=/^\.([a-z_][a-z_\d]*)/i.exec(s)))i.push(a[1]);else{if(null===(a=/^\[(\d+)\]/.exec(s)))throw"[sprintf] huh?";i.push(a[1])}n[2]=i}else o|=2;if(3===o)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";r.push(n)}t=t.substring(n[0].length)}return r},e.sprintf=t,e.vsprintf=function(e,n,r){return(r=n.slice(0)).splice(0,0,e),t.apply(null,r)}}()},82:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=function(){};n.prototype.send=function(e){throw new t.NotImplementedError},n.prototype.onMessage=function(e){throw new t.NotImplementedError};var r=function(){n.call(this)};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype.onMessage=function(e){},r.prototype.send=function(e){};var o=function(e,t){n.call(this),this.window=e,this.domain=t||"*"};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype.send=function(e){this.window.postMessage(e,this.domain)},o.prototype.onMessage=function(e){this.window.addEventListener("message",e)};var i=function(e,t,r){n.call(this),this.input=e,this.output=t,this.domain=r||"*"};(i.prototype=Object.create(n.prototype)).constructor=i,i.prototype.send=function(e){this.output.postMessage(e,this.domain)},i.prototype.onMessage=function(e){this.input.addEventListener("message",(t=>{t.source===this.output&&e(t)}))};var s=function(e){n.call(this),this.port=e,this.id=t.randomId()};(s.prototype=Object.create(n.prototype)).constructor=s,s.prototype.send=function(e){this.port.postMessage(e)},s.prototype.onMessage=function(e){this.port.addEventListener("message",e)},s.prototype.getId=function(){return this.id};var a=function(e){n.call(this),this.streamMap=e?t.index(e,(function(e){return e.getId()})):{},this.messageListeners=[]};(a.prototype=Object.create(n.prototype)).constructor=a,a.prototype.send=function(e){this.getStreams().forEach((function(t){try{t.send(e)}catch(e){}}))},a.prototype.onMessage=function(e){this.messageListeners.push(e),this.getStreams().forEach((function(t){t.onMessage(e)}))},a.prototype.addStream=function(e){this.streamMap[e.getId()]=e,this.messageListeners.forEach((function(t){e.onMessage(t)}))},a.prototype.removeStream=function(e){delete this.streamMap[e.getId()]},a.prototype.getStreams=function(e){return t.values(this.streamMap)},a.prototype.getStreamForPort=function(e){return t.find(this.getStreams(),(function(t){return t.port===e}))};var c=function(e,n,o){this.name=e,this.upstream=n||new r,this.downstream=o||new r,this.downstreamBus=new t.EventBus,this.upstreamBus=new t.EventBus,this.upstream.onMessage(t.hitch(this,this._dispatchEvent,this.upstreamBus)),this.downstream.onMessage(t.hitch(this,this._dispatchEvent,this.downstreamBus))};c.prototype.onUpstream=function(e,n){return t.assertNotNull(e,"eventName"),t.assertNotNull(n,"f"),t.assertTrue(t.isFunction(n),"f must be a function"),this.upstreamBus.subscribe(e,n)},c.prototype.onAllUpstream=function(e){return t.assertNotNull(e,"f"),t.assertTrue(t.isFunction(e),"f must be a function"),this.upstreamBus.subscribeAll(e)},c.prototype.onDownstream=function(e,n){return t.assertNotNull(e,"eventName"),t.assertNotNull(n,"f"),t.assertTrue(t.isFunction(n),"f must be a function"),this.downstreamBus.subscribe(e,n)},c.prototype.onAllDownstream=function(e){return t.assertNotNull(e,"f"),t.assertTrue(t.isFunction(e),"f must be a function"),this.downstreamBus.subscribeAll(e)},c.prototype.sendUpstream=function(e,n){t.assertNotNull(e,"eventName"),this.upstream.send({event:e,data:n})},c.prototype.sendDownstream=function(e,n){t.assertNotNull(e,"eventName"),this.downstream.send({event:e,data:n})},c.prototype._dispatchEvent=function(e,t){var n=t.data;n.event&&e.trigger(n.event,n.data)},c.prototype.passUpstream=function(){var e=this;return function(t,n){e.upstream.send({event:n,data:t})}},c.prototype.passDownstream=function(){var e=this;return function(t,n){e.downstream.send({event:n,data:t})}},c.prototype.shutdown=function(){this.upstreamBus.unsubscribeAll(),this.downstreamBus.unsubscribeAll()};var u=function(e,t,n,r){c.call(this,e,new i(t,n.contentWindow,r||"*"),null)};(u.prototype=Object.create(c.prototype)).constructor=u,t.Stream=n,t.NullStream=r,t.WindowStream=o,t.WindowIOStream=i,t.PortStream=s,t.StreamMultiplexer=a,t.Conduit=c,t.IFrameConduit=u}()},833:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=function(e,n){t.assertNotNull(e,"fromState"),t.assertNotNull(n,"toState"),this.fromState=e,this.toState=n};n.prototype.getAssociations=function(e){throw t.NotImplementedError()},n.prototype.getFromState=function(){return this.fromState},n.prototype.getToState=function(){return this.toState};var r=function(e,r,o){t.assertNotNull(e,"fromState"),t.assertNotNull(r,"toState"),t.assertNotNull(o,"associations"),n.call(this,e,r),this.associations=o};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype.getAssociations=function(e){return this.associations};var o=function(e,r,o){t.assertNotNull(e,"fromState"),t.assertNotNull(r,"toState"),t.assertNotNull(o,"closure"),t.assertTrue(t.isFunction(o),"closure must be a function"),n.call(this,e,r),this.closure=o};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype.getAssociations=function(e){return this.closure(e,this.getFromState(),this.getToState())};var i=function(){this.fromMap={}};i.ANY="<>",i.prototype.assoc=function(e,t,n){var i=this;if(!e)throw new Error("fromStateObj is not defined.");if(!t)throw new Error("toStateObj is not defined.");if(!n)throw new Error("assocObj is not defined.");return e instanceof Array?e.forEach((function(e){i.assoc(e,t,n)})):t instanceof Array?t.forEach((function(t){i.assoc(e,t,n)})):"function"==typeof n?this._addAssociation(new o(e,t,n)):n instanceof Array?this._addAssociation(new r(e,t,n)):this._addAssociation(new r(e,t,[n])),this},i.prototype.getAssociations=function(e,n,r){t.assertNotNull(n,"fromState"),t.assertNotNull(r,"toState");var o=[],s=this.fromMap[i.ANY]||{},a=this.fromMap[n]||{};return o=(o=o.concat(this._getAssociationsFromMap(s,e,n,r))).concat(this._getAssociationsFromMap(a,e,n,r))},i.prototype._addAssociation=function(e){var t=this.fromMap[e.getFromState()];t||(t=this.fromMap[e.getFromState()]={});var n=t[e.getToState()];n||(n=t[e.getToState()]=[]),n.push(e)},i.prototype._getAssociationsFromMap=function(e,t,n,r){return(e[i.ANY]||[]).concat(e[r]||[]).reduce((function(e,n){return e.concat(n.getAssociations(t))}),[])},t.EventGraph=i}()},891:(e,t,n)=>{var r=n(465);!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=navigator.userAgent,o=["bubbles","cancelBubble","cancelable","composed","data","defaultPrevented","eventPhase","isTrusted","lastEventId","origin","returnValue","timeStamp","type"];t.sprintf=e.sprintf,t.vsprintf=e.vsprintf,delete e.sprintf,delete e.vsprintf,t.HTTP_STATUS_CODES={SUCCESS:200,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500},t.TRANSPORT_TYPES={CHAT_TOKEN:"chat_token",WEB_SOCKET:"web_socket"},t.hitch=function(){var e=Array.prototype.slice.call(arguments),n=e.shift(),r=e.shift();return t.assertNotNull(n,"scope"),t.assertNotNull(r,"method"),t.assertTrue(t.isFunction(r),"method must be a function"),function(){var t=Array.prototype.slice.call(arguments);return r.apply(n,e.concat(t))}},t.isFunction=function(e){return!!(e&&e.constructor&&e.call&&e.apply)},t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.keys=function(e){var n=[];for(var r in t.assertNotNull(e,"map"),e)n.push(r);return n},t.values=function(e){var n=[];for(var r in t.assertNotNull(e,"map"),e)n.push(e[r]);return n},t.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},t.merge=function(){var e=Array.prototype.slice.call(arguments,0),n={};return e.forEach((function(e){t.entries(e).forEach((function(e){n[e.key]=e.value}))})),n},t.now=function(){return(new Date).getTime()},t.find=function(e,t){for(var n=0;n{try{void 0!==e[r]&&(n[r]=e[r])}catch(e){t.getLog().info("deepcopyCrossOriginEvent failed on key: ",r).sendInternalLogToServer()}})),t.deepcopy(n)},t.getBaseUrl=function(){var n=e.location;return t.sprintf("%s//%s:%s",n.protocol,n.hostname,n.port)},t.getUrlWithProtocol=function(n){var r=e.location.protocol;return n.substr(0,r.length)!==r?t.sprintf("%s//%s",r,n):n},t.isFramed=function(){try{return window.self!==window.top}catch(e){return!0}},t.hasOtherConnectedCCPs=function(){return t.numberOfConnectedCCPs>1},t.fetch=function(e,n,r,o){return o=o||5,r=r||1e3,n=n||{},new Promise((function(i,s){!function o(a){fetch(e,n).then((function(e){e.status===t.HTTP_STATUS_CODES.SUCCESS?e.json().then((e=>i(e))).catch((()=>i({}))):1!==a&&(e.status>=t.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===t.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout((function(){o(--a)}),r):s(e)})).catch((function(e){s(e)}))}(o)}))},t.backoff=function(n,r,o,i){t.assertTrue(t.isFunction(n),"func must be a Function");var s=this;n({success:function(e){i&&i.success&&i.success(e)},failure:function(t,a){if(o>0){var c=2*r*Math.random();e.setTimeout((function(){s.backoff(n,2*c,--o,i)}),c)}else i&&i.failure&&i.failure(t,a)}})},t.publishMetric=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.CLIENT_METRIC,data:e})},t.publishSoftphoneStats=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.SOFTPHONE_STATS,data:e})},t.publishSoftphoneReport=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.SOFTPHONE_REPORT,data:e})},t.publishClickStreamData=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.CLICK_STREAM_DATA,data:e})},t.publishClientSideLogs=function(e){t.core.getEventBus().trigger(t.EventType.CLIENT_SIDE_LOGS,e)},t.addNamespaceToLogs=function(e){["log","error","warn","info","debug"].forEach((t=>{const n=window.console[t];window.console[t]=function(){const t=Array.from(arguments);t.unshift(`[${e}]`),n.apply(window.console,t)}}))},t.PopupManager=function(){},t.PopupManager.prototype.open=function(e,t,n){var r=this._getLastOpenedTimestamp(t),o=(new Date).getTime(),i=null;if(o-r>864e5){if(n){var s=n.height||578,a=n.width||433,c=n.top||0,u=n.left||0;(i=window.open("",t,"width="+a+", height="+s+", top="+c+", left="+u)).location!==e&&(i=window.open(e,t,"width="+a+", height="+s+", top="+c+", left="+u))}else(i=window.open("",t)).location!==e&&(i=window.open(e,t));this._setLastOpenedTimestamp(t,o)}return i},t.PopupManager.prototype.clear=function(t){var n=this._getLocalStorageKey(t);e.localStorage.removeItem(n)},t.PopupManager.prototype._getLastOpenedTimestamp=function(t){var n=this._getLocalStorageKey(t),r=e.localStorage.getItem(n);return r?parseInt(r,10):0},t.PopupManager.prototype._setLastOpenedTimestamp=function(t,n){var r=this._getLocalStorageKey(t);e.localStorage.setItem(r,""+n)},t.PopupManager.prototype._getLocalStorageKey=function(e){return"connectPopupManager::"+e};var i=t.makeEnum(["granted","denied","default"]);t.NotificationManager=function(){this.queue=[],this.permission=i.DEFAULT},t.NotificationManager.prototype.requestPermission=function(){var n=this;"Notification"in e?e.Notification.permission===i.DENIED?(t.getLog().warn("The user has requested to not receive notifications.").sendInternalLogToServer(),this.permission=i.DENIED):this.permission!==i.GRANTED&&e.Notification.requestPermission().then((function(e){n.permission=e,e===i.GRANTED?n._showQueued():n.queue=[]})):(t.getLog().warn("This browser doesn't support notifications.").sendInternalLogToServer(),this.permission=i.DENIED)},t.NotificationManager.prototype.show=function(e,n){if(this.permission===i.GRANTED)return this._showImpl({title:e,options:n});if(this.permission===i.DENIED)t.getLog().warn("Unable to show notification.").sendInternalLogToServer().withObject({title:e,options:n});else{var r={title:e,options:n};t.getLog().warn("Deferring notification until user decides to allow or deny.").withObject(r).sendInternalLogToServer(),this.queue.push(r)}},t.NotificationManager.prototype._showQueued=function(){var e=this,t=this.queue.map((function(t){return e._showImpl(t)}));return this.queue=[],t},t.NotificationManager.prototype._showImpl=function(t){var n=new e.Notification(t.title,t.options);return t.options.clicked&&(n.onclick=function(){t.options.clicked.call(n)}),n},t.ValueError=function(){var e=Array.prototype.slice.call(arguments,0),n=e.shift(),r=new Error(t.vsprintf(n,e));return Object.setPrototypeOf(r,t.ValueError.prototype),r},Object.setPrototypeOf(t.ValueError.prototype,Error.prototype),Object.setPrototypeOf(t.ValueError,Error),t.ValueError.prototype.name="ValueError",t.NotImplementedError=function(){var e=Array.prototype.slice.call(arguments,0),n=e.shift(),r=new Error(t.vsprintf(n,e));return Object.setPrototypeOf(r,t.NotImplementedError.prototype),r},Object.setPrototypeOf(t.NotImplementedError.prototype,Error.prototype),Object.setPrototypeOf(t.NotImplementedError,Error),t.NotImplementedError.prototype.name="NotImplementedError",t.StateError=function(){var e=Array.prototype.slice.call(arguments,0),n=e.shift(),r=new Error(t.vsprintf(n,e));return Object.setPrototypeOf(r,t.StateError.prototype),r},Object.setPrototypeOf(t.StateError.prototype,Error.prototype),Object.setPrototypeOf(t.StateError,Error),t.StateError.prototype.name="StateError",t.VoiceIdError=function(e,t,n){var r={};return r.type=e,r.message=t,r.stack=Error(t).stack,r.err=n,r},t.isCCP=function(){return"ConnectSharedWorkerConduit"===t.core.getUpstream().name}}()},736:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.worker={};var n=function(){this.topicMasterMap={}};n.prototype.getMaster=function(e){return t.assertNotNull(e,"topic"),this.topicMasterMap[e]||null},n.prototype.setMaster=function(e,n){t.assertNotNull(e,"topic"),t.assertNotNull(n,"id"),this.topicMasterMap[e]=n},n.prototype.removeMaster=function(e){t.assertNotNull(e,"id");var n=this;t.entries(this.topicMasterMap).filter((function(t){return t.value===e})).forEach((function(e){delete n.topicMasterMap[e.key]}))};var r=function(e){t.ClientBase.call(this),this.conduit=e};(r.prototype=Object.create(t.ClientBase.prototype)).constructor=r,r.prototype._callImpl=function(e,n,r){var o=this,i=(new Date).getTime();t.containsValue(t.AgentAppClientMethods,e)?t.core.getAgentAppClient()._callImpl(e,n,{success:function(t){o._recordAPILatency(e,i),r.success(t)},failure:function(t){o._recordAPILatency(e,i,t),r.failure(t)}}):t.containsValue(t.TaskTemplatesClientMethods,e)?t.core.getTaskTemplatesClient()._callImpl(e,n,{success:function(t){o._recordAPILatency(e,i),r.success(t)},failure:function(t){o._recordAPILatency(e,i,t),r.failure(t)}}):t.core.getClient()._callImpl(e,n,{success:function(t){o._recordAPILatency(e,i),r.success(t)},failure:function(t,n){o._recordAPILatency(e,i,t),r.failure(t,n)},authFailure:function(){o._recordAPILatency(e,i),r.authFailure()},accessDenied:function(){r.accessDenied&&r.accessDenied()}})},r.prototype._recordAPILatency=function(e,t,n){var r=(new Date).getTime()-t;this._sendAPIMetrics(e,r,n)},r.prototype._sendAPIMetrics=function(e,n,r){this.conduit.sendDownstream(t.EventType.API_METRIC,{name:e,time:n,dimensions:[{name:"Category",value:"API"}],error:r})};var o=function(){var o=this;this.multiplexer=new t.StreamMultiplexer,this.conduit=new t.Conduit("AmazonConnectSharedWorker",null,this.multiplexer),this.client=new r(this.conduit),this.timeout=null,this.agent=null,this.nextToken=null,this.initData={},this.portConduitMap={},this.streamMapByTabId={},this.masterCoord=new n,this.logsBuffer=[],this.suppress=!1,this.forceOffline=!1,this.longPollingOptions={allowLongPollingShadowMode:!1,allowLongPollingWebsocketOnlyMode:!1};var i=null;t.rootLogger=new t.DownstreamConduitLogger(this.conduit),this.conduit.onDownstream(t.EventType.SEND_LOGS,(function(e){t.getLog().pushLogsDownstream(e),o.logsBuffer=o.logsBuffer.concat(e),o.logsBuffer.length>400&&o.handleSendLogsRequest(o.logsBuffer)})),this.conduit.onDownstream(t.EventType.CONFIGURE,(function(n){console.log("@@@ configure event handler",n);try{n.authToken&&n.authToken!==o.initData.authToken&&(o.initData=n,t.core.init(n),n.longPollingOptions&&("boolean"==typeof n.longPollingOptions.allowLongPollingShadowMode&&(o.longPollingOptions.allowLongPollingShadowMode=n.longPollingOptions.allowLongPollingShadowMode),"boolean"==typeof n.longPollingOptions.allowLongPollingWebsocketOnlyMode&&(o.longPollingOptions.allowLongPollingWebsocketOnlyMode=n.longPollingOptions.allowLongPollingWebsocketOnlyMode)),i?t.getLog().info("Not Initializing a new WebsocketManager instance, since one already exists").sendInternalLogToServer():(t.getLog().info("Creating a new Websocket connection for CCP").sendInternalLogToServer(),t.WebSocketManager.setGlobalConfig({loggerConfig:{logger:t.getLog()}}),(i=t.WebSocketManager.create()).onInitFailure((function(){o.conduit.sendDownstream(t.WebSocketEvents.INIT_FAILURE)})),i.onConnectionOpen((function(e){o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_OPEN,e)})),i.onConnectionClose((function(e){o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_CLOSE,e)})),i.onConnectionGain((function(){o.conduit.sendDownstream(t.AgentEvents.WEBSOCKET_CONNECTION_GAINED),o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_GAIN)})),i.onConnectionLost((function(e){o.conduit.sendDownstream(t.AgentEvents.WEBSOCKET_CONNECTION_LOST,e),o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_LOST,e)})),i.onSubscriptionUpdate((function(e){o.conduit.sendDownstream(t.WebSocketEvents.SUBSCRIPTION_UPDATE,e)})),i.onSubscriptionFailure((function(e){o.conduit.sendDownstream(t.WebSocketEvents.SUBSCRIPTION_FAILURE,e)})),i.onAllMessage((function(e){o.conduit.sendDownstream(t.WebSocketEvents.ALL_MESSAGE,e)})),o.conduit.onDownstream(t.WebSocketEvents.SEND,(function(e){i.sendMessage(e)})),o.conduit.onDownstream(t.WebSocketEvents.SUBSCRIBE,(function(e){i.subscribeTopics(e)})),i.init(t.hitch(o,o.getWebSocketUrl)).then((function(n){try{if(n&&!n.webSocketConnectionFailed)t.getLog().info("Kicking off agent polling").sendInternalLogToServer(),o.pollForAgent(),t.getLog().info("Kicking off config polling").sendInternalLogToServer(),o.pollForAgentConfiguration({repeatForever:!0}),t.getLog().info("Kicking off auth token polling").sendInternalLogToServer(),e.setInterval(t.hitch(o,o.checkAuthToken),3e5);else if(!t.webSocketInitFailed){const e=t.WebSocketEvents.INIT_FAILURE;throw o.conduit.sendDownstream(e),t.webSocketInitFailed=!0,new Error(e)}}catch(e){t.getLog().error("WebSocket failed to initialize").withException(e).sendInternalLogToServer()}}))))}catch(e){console.error("@@@ error",e)}})),this.conduit.onDownstream(t.EventType.TERMINATE,(function(){o.handleSendLogsRequest(o.logsBuffer),t.core.terminate(),o.conduit.sendDownstream(t.EventType.TERMINATED)})),this.conduit.onDownstream(t.EventType.SYNCHRONIZE,(function(){o.conduit.sendDownstream(t.EventType.ACKNOWLEDGE)})),this.conduit.onDownstream(t.EventType.BROADCAST,(function(e){o.conduit.sendDownstream(e.event,e.data)})),e.onconnect=function(e){var n=e.ports[0],r=new t.PortStream(n);o.multiplexer.addStream(r),n.start();var i=new t.Conduit(r.getId(),null,r);i.sendDownstream(t.EventType.ACKNOWLEDGE,{id:r.getId()}),o.portConduitMap[r.getId()]=i,o.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(o.portConduitMap).length}),null!==o.agent&&o.updateAgent(),i.onDownstream(t.EventType.API_REQUEST,t.hitch(o,o.handleAPIRequest,i)),i.onDownstream(t.EventType.MASTER_REQUEST,t.hitch(o,o.handleMasterRequest,i,r.getId())),i.onDownstream(t.EventType.RELOAD_AGENT_CONFIGURATION,t.hitch(o,o.pollForAgentConfiguration)),i.onDownstream(t.EventType.TAB_ID,t.hitch(o,o.handleTabIdEvent,r)),i.onDownstream(t.EventType.CLOSE,t.hitch(o,o.handleCloseEvent,r))}};o.prototype.pollForAgent=function(){var n=this,r=t.hitch(n,n.handleAuthFail);this.client.call(t.ClientMethods.GET_AGENT_SNAPSHOT,{nextToken:n.nextToken,timeout:3e4},{success:function(r){try{n.agent=n.agent||{},n.agent.snapshot=r.snapshot,n.agent.snapshot.localTimestamp=t.now(),n.agent.snapshot.skew=n.agent.snapshot.snapshotTimestamp-n.agent.snapshot.localTimestamp,n.nextToken=r.nextToken,t.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(r).sendInternalLogToServer(),n.updateAgent()}catch(e){t.getLog().error("Long poll failed to update agent.").withObject(r).withException(e).sendInternalLogToServer()}finally{e.setTimeout(t.hitch(n,n.pollForAgent),100)}},failure:function(r,o){try{t.getLog().error("Failed to get agent data.").sendInternalLogToServer().withObject({err:r,data:o})}finally{e.setTimeout(t.hitch(n,n.pollForAgent),5e3)}},authFailure:function(){r()},accessDenied:t.hitch(n,n.handleAccessDenied)})},o.prototype.pollForAgentConfiguration=function(n){var r=this,o=n||{},i=t.hitch(r,r.handleAuthFail);this.client.call(t.ClientMethods.GET_AGENT_CONFIGURATION,{},{success:function(n){var i=n.configuration;r.pollForAgentPermissions(i),r.pollForAgentStates(i),r.pollForDialableCountryCodes(i),r.pollForRoutingProfileQueues(i),o.repeatForever&&e.setTimeout(t.hitch(r,r.pollForAgentConfiguration,o),3e4)},failure:function(n,i){try{t.getLog().error("Failed to fetch agent configuration data.").sendInternalLogToServer().withObject({err:n,data:i})}finally{o.repeatForever&&e.setTimeout(t.hitch(r,r.pollForAgentConfiguration),3e4,o)}},authFailure:function(){i()},accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForAgentStates=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_AGENT_STATES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForAgentStates(e,{states:(o.states||[]).concat(t.states),nextToken:t.nextToken,maxResults:o.maxResults}):(e.agentStates=(o.states||[]).concat(t.states),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch agent states list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForAgentPermissions=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_AGENT_PERMISSIONS,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForAgentPermissions(e,{permissions:(o.permissions||[]).concat(t.permissions),nextToken:t.nextToken,maxResults:o.maxResults}):(e.permissions=(o.permissions||[]).concat(t.permissions),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch agent permissions list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForDialableCountryCodes=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_DIALABLE_COUNTRY_CODES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForDialableCountryCodes(e,{countryCodes:(o.countryCodes||[]).concat(t.countryCodes),nextToken:t.nextToken,maxResults:o.maxResults}):(e.dialableCountries=(o.countryCodes||[]).concat(t.countryCodes),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch dialable country codes list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForRoutingProfileQueues=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_ROUTING_PROFILE_QUEUES,{routingProfileARN:e.routingProfile.routingProfileARN,nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForRoutingProfileQueues(e,{countryCodes:(o.queues||[]).concat(t.queues),nextToken:t.nextToken,maxResults:o.maxResults}):(e.routingProfile.queues=(o.queues||[]).concat(t.queues),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch routing profile queues list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.handleAPIRequest=function(e,n){var r=this;this.client.call(n.method,n.params,{success:function(r){var o=t.EventFactory.createResponse(t.EventType.API_RESPONSE,n,r);e.sendDownstream(o.event,o)},failure:function(o,i){var s=t.EventFactory.createResponse(t.EventType.API_RESPONSE,n,i,JSON.stringify(o));e.sendDownstream(s.event,s),t.getLog().error("'%s' API request failed",n.method).withObject({request:r.filterAuthToken(n),response:s}).withException(o).sendInternalLogToServer()},authFailure:t.hitch(r,r.handleAuthFail,{authorize:!0})})},o.prototype.handleMasterRequest=function(e,n,r){var o=this.conduit,i=null;switch(r.method){case t.MasterMethods.BECOME_MASTER:var s=this.masterCoord.getMaster(r.params.topic),a=Boolean(s)&&s!==n;this.masterCoord.setMaster(r.params.topic,n),i=t.EventFactory.createResponse(t.EventType.MASTER_RESPONSE,r,{masterId:n,takeOver:a,topic:r.params.topic}),a&&o.sendDownstream(i.event,i);break;case t.MasterMethods.CHECK_MASTER:(s=this.masterCoord.getMaster(r.params.topic))||r.params.shouldNotBecomeMasterIfNone||(this.masterCoord.setMaster(r.params.topic,n),s=n),i=t.EventFactory.createResponse(t.EventType.MASTER_RESPONSE,r,{masterId:s,isMaster:n===s,topic:r.params.topic});break;default:throw new Error("Unknown master method: "+r.method)}e.sendDownstream(i.event,i)},o.prototype.handleTabIdEvent=function(e,n){var r=this;try{let o=n.tabId,i=r.streamMapByTabId[o],s=e.getId(),a=Object.keys(r.streamMapByTabId).filter((e=>r.streamMapByTabId[e].length>0)).length;if(i&&i.length>0){if(!i.includes(s)){r.streamMapByTabId[o].push(s);let e={length:Object.keys(r.portConduitMap).length,tabId:o,streamsTabsAcrossBrowser:a};e[o]={length:i.length},r.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,e)}}else{r.streamMapByTabId[o]=[e.getId()];let n={length:Object.keys(r.portConduitMap).length,tabId:o,streamsTabsAcrossBrowser:a+1};n[o]={length:r.streamMapByTabId[o].length},r.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,n)}}catch(e){t.getLog().error("[Tab Ids] Issue updating connected CCPs within the same tab").withException(e).sendInternalLogToServer()}},o.prototype.handleCloseEvent=function(e){var n=this;n.multiplexer.removeStream(e),delete n.portConduitMap[e.getId()],n.masterCoord.removeMaster(e.getId());let r={length:Object.keys(n.portConduitMap).length},o=Object.keys(n.streamMapByTabId);try{let t=o.find((t=>n.streamMapByTabId[t].includes(e.getId())));if(t){let o=n.streamMapByTabId[t].findIndex((t=>e.getId()===t));n.streamMapByTabId[t].splice(o,1);let i=n.streamMapByTabId[t]?n.streamMapByTabId[t].length:0;r[t]={length:i},r.tabId=t}let i=o.filter((e=>n.streamMapByTabId[e].length>0)).length;r.streamsTabsAcrossBrowser=i}catch(e){t.getLog().error("[Tab Ids] Issue updating tabId-specific stream data").withException(e).sendInternalLogToServer()}n.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,r)},o.prototype.updateAgentConfiguration=function(e){e.permissions&&e.dialableCountries&&e.agentStates&&e.routingProfile.queues?(this.agent=this.agent||{},this.agent.configuration=e,this.updateAgent()):t.getLog().trace("Waiting to update agent configuration until all config data has been fetched.").sendInternalLogToServer()},o.prototype.updateAgent=function(){this.agent?this.agent.snapshot?this.agent.configuration?(this.agent.snapshot.status=this.agent.state,this.agent.snapshot.contacts&&this.agent.snapshot.contacts.length>1&&this.agent.snapshot.contacts.sort((function(e,t){return e.state.timestamp.getTime()-t.state.timestamp.getTime()})),this.agent.snapshot.contacts.forEach((function(e){e.status=e.state,e.connections.forEach((function(e){e.address=e.endpoint}))})),this.agent.configuration.routingProfile.defaultOutboundQueue.queueId=this.agent.configuration.routingProfile.defaultOutboundQueue.queueARN,this.agent.configuration.routingProfile.queues.forEach((function(e){e.queueId=e.queueARN})),this.agent.snapshot.contacts.forEach((function(e){void 0!==e.queue&&(e.queue.queueId=e.queue.queueARN)})),this.agent.configuration.routingProfile.routingProfileId=this.agent.configuration.routingProfile.routingProfileARN,this.conduit.sendDownstream(t.AgentEvents.UPDATE,this.agent)):t.getLog().trace("Waiting to update agent until the agent configuration is available.").sendInternalLogToServer():t.getLog().trace("Waiting to update agent until the agent snapshot is available.").sendInternalLogToServer():t.getLog().trace("Waiting to update agent until the agent has been fully constructed.").sendInternalLogToServer()},o.prototype.getWebSocketUrl=function(){var e=this,n=t.core.getClient(),r=t.hitch(e,e.handleAuthFail),o=t.hitch(e,e.handleAccessDenied);return new Promise((function(e,i){n.call(t.ClientMethods.CREATE_TRANSPORT,{transportType:t.TRANSPORT_TYPES.WEB_SOCKET},{success:function(n){t.getLog().info("getWebSocketUrl succeeded").sendInternalLogToServer(),e(n)},failure:function(e,n){t.getLog().error("getWebSocketUrl failed").sendInternalLogToServer().withObject({err:e,data:n}),i({reason:"getWebSocketUrl failed",_debug:e})},authFailure:function(){t.getLog().error("getWebSocketUrl Auth Failure").sendInternalLogToServer(),i(Error("Authentication failed while getting getWebSocketUrl")),r()},accessDenied:function(){t.getLog().error("getWebSocketUrl Access Denied Failure").sendInternalLogToServer(),i(Error("Access Denied Failure while getting getWebSocketUrl")),o()}})}))},o.prototype.handleSendLogsRequest=function(){var e=this,n=[],r=e.logsBuffer.slice();e.logsBuffer=[],r.forEach((function(e){n.push({timestamp:e.time,component:e.component,message:e.text})})),this.client.call(t.ClientMethods.SEND_CLIENT_LOGS,{logEvents:n},{success:function(e){t.getLog().info("SendLogs request succeeded.").sendInternalLogToServer()},failure:function(e,n){t.getLog().error("SendLogs request failed.").withObject(n).withException(e).sendInternalLogToServer()},authFailure:t.hitch(e,e.handleAuthFail)})},o.prototype.handleAuthFail=function(e){e?this.conduit.sendDownstream(t.EventType.AUTH_FAIL,e):this.conduit.sendDownstream(t.EventType.AUTH_FAIL)},o.prototype.handleAccessDenied=function(){this.conduit.sendDownstream(t.EventType.ACCESS_DENIED)},o.prototype.checkAuthToken=function(){var e=this,n=new Date(e.initData.authTokenExpiration),r=(new Date).getTime();n.getTime()(e.paths=[],e.children||(e.children=[]),e),n(827),n(163),n(944),n(151),n(891),n(592),n(82),n(754),n(833),n(965),n(286),n(895),n(743),n(642),n(736),n(439),n(279),n(418),n(187),n(821),n(500)})(); \ No newline at end of file +(()=>{var e={465:(e,t,n)=>{e=n.nmd(e);var r="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",l="[object Map]",p="[object Number]",d="[object Object]",h="[object Promise]",f="[object RegExp]",g="[object Set]",m="[object String]",v="[object Symbol]",y="[object WeakMap]",E="[object ArrayBuffer]",S="[object DataView]",b="[object Float32Array]",T="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",_="[object Int32Array]",A="[object Uint8Array]",w="[object Uint8ClampedArray]",R="[object Uint16Array]",k="[object Uint32Array]",N=/\w*$/,O=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,D={};D[i]=D["[object Array]"]=D[E]=D[S]=D[s]=D[a]=D[b]=D[T]=D[C]=D[I]=D[_]=D[l]=D[p]=D[d]=D[f]=D[g]=D[m]=D[v]=D[A]=D[w]=D[R]=D[k]=!0,D["[object Error]"]=D[c]=D[y]=!1;var P="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,x="object"==typeof self&&self&&self.Object===Object&&self,M=P||x||Function("return this")(),U=t&&!t.nodeType&&t,F=U&&e&&!e.nodeType&&e,q=F&&F.exports===U;function j(e,t){return e.set(t[0],t[1]),e}function B(e,t){return e.add(t),e}function V(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o-1},we.prototype.set=function(e,t){var n=this.__data__,r=Le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Re.prototype.clear=function(){this.__data__={hash:new Ae,map:new(fe||we),string:new Ae}},Re.prototype.delete=function(e){return Ue(this,e).delete(e)},Re.prototype.get=function(e){return Ue(this,e).get(e)},Re.prototype.has=function(e){return Ue(this,e).has(e)},Re.prototype.set=function(e,t){return Ue(this,e).set(e,t),this},ke.prototype.clear=function(){this.__data__=new we},ke.prototype.delete=function(e){return this.__data__.delete(e)},ke.prototype.get=function(e){return this.__data__.get(e)},ke.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.set=function(e,t){var n=this.__data__;if(n instanceof we){var r=n.__data__;if(!fe||r.length<199)return r.push([e,t]),this;n=this.__data__=new Re(r)}return n.set(e,t),this};var qe=le?z(le,Object):function(){return[]},je=function(e){return te.call(e)};function Be(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||L.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=o}(e.length)&&!Xe(e)}var Ke=pe||function(){return!1};function Xe(e){var t=Ye(e)?te.call(e):"";return t==c||t==u}function Ye(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Je(e){return Ge(e)?Ne(e):function(e){if(!Ve(e))return de(e);var t=[];for(var n in Object(e))ee.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return De(e,!0,!0)}},821:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.agentApp={};var n="ccp";t.agentApp.initCCP=t.core.initCCP,t.agentApp.isInitialized=function(e){},t.agentApp.initAppCommunication=function(e,n){var r=document.getElementById(e),o=new t.IFrameConduit(n,window,r),i=[t.AgentEvents.UPDATE,t.ContactEvents.VIEW,t.EventType.ACKNOWLEDGE,t.EventType.TERMINATED,t.TaskEvents.CREATED];r.addEventListener("load",(function(e){i.forEach((function(e){t.core.getUpstream().onUpstream(e,(function(t){o.sendUpstream(e,t)}))}))}))};var r=function(e){var t=e.indexOf("ccp-v2");return e.slice(0,t-1)};t.agentApp.initApp=function(e,o,i,s){s=s||{};var a=i.endsWith("/")?i:i+"/",c=s.onLoad?s.onLoad:null,u={endpoint:a,style:s.style,onLoad:c};t.agentApp.AppRegistry.register(e,u,document.getElementById(o)),t.agentApp.AppRegistry.start(e,(function(o){var i=o.endpoint,a=o.containerDOM;return{init:function(){return e===n?(s.ccpParams=s.ccpParams?s.ccpParams:{},s.style&&(s.ccpParams.style=s.style),function(e,n,o){var i={ccpUrl:e,ccpLoadTimeout:1e4,loginPopup:!0,loginUrl:r(e)+"/login",softphone:{allowFramedSoftphone:!0,disableRingtone:!1}},s=t.merge(i,o.ccpParams);t.core.initCCP(n,s)}(i,a,s)):t.agentApp.initAppCommunication(e,i)},destroy:function(){return e===n?(o=r(i)+"/logout",t.fetch(o,{credentials:"include"}).then((function(){return t.core.getEventBus().trigger(t.EventType.TERMINATE),!0})).catch((function(e){return t.getLog().error("An error occured on logout."+e).withException(e),window.location.href=o,!1}))):null;var o}}}))},t.agentApp.stopApp=function(e){return t.agentApp.AppRegistry.stop(e)}}()},500:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t;var n,r="ccp";e.connect.agentApp.AppRegistry=(n={},{register:function(e,t,r){n[e]={containerDOM:r,endpoint:t.endpoint,style:t.style,instance:void 0,onLoad:t.onLoad}},start:function(e,t){if(n[e]){var o=n[e].containerDOM,i=n[e].endpoint,s=n[e].style,a=n[e].onLoad;if(e!==r){var c=function(e,t,n,r){var o=document.createElement("iframe");return o.src=t,o.style=n||"width: 100%; height:100%;",o.id=e,o["aria-label"]=e,o.onload=r,o.setAttribute("sandbox","allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"),o}(e,i,s,a);o.appendChild(c)}return n[e].instance=t(n[e]),n[e].instance.init()}},stop:function(e){if(n[e]){var t,r=n[e],o=r.containerDOM.querySelector("iframe");return r.containerDOM.removeChild(o),r.instance&&(t=r.instance.destroy(),delete r.instance),t}}})}()},965:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.AgentStateType=t.makeEnum(["init","routable","not_routable","offline"]),t.AgentStatusType=t.AgentStateType,t.AgentAvailStates=t.makeEnum(["Init","Busy","AfterCallWork","CallingCustomer","Dialing","Joining","PendingAvailable","PendingBusy"]),t.AgentErrorStates=t.makeEnum(["Error","AgentHungUp","BadAddressAgent","BadAddressCustomer","Default","FailedConnectAgent","FailedConnectCustomer","InvalidLocale","LineEngagedAgent","LineEngagedCustomer","MissedCallAgent","MissedCallCustomer","MultipleCcpWindows","RealtimeCommunicationError"]),t.EndpointType=t.makeEnum(["phone_number","agent","queue"]),t.AddressType=t.EndpointType,t.ConnectionType=t.makeEnum(["agent","inbound","outbound","monitoring"]),t.ConnectionStateType=t.makeEnum(["init","connecting","connected","hold","disconnected","silent_monitor","barge"]),t.ConnectionStatusType=t.ConnectionStateType,t.CONNECTION_ACTIVE_STATES=t.set([t.ConnectionStateType.CONNECTING,t.ConnectionStateType.CONNECTED,t.ConnectionStateType.HOLD,t.ConnectionStateType.SILENT_MONITOR,t.ConnectionStateType.BARGE]),t.CONNECTION_CONNECTED_STATES=t.set([t.ConnectionStateType.CONNECTED,t.ConnectionStateType.SILENT_MONITOR,t.ConnectionStateType.BARGE]),t.ContactStateType=t.makeEnum(["init","incoming","pending","connecting","connected","missed","error","ended"]),t.ContactStatusType=t.ContactStateType,t.CONTACT_ACTIVE_STATES=t.makeEnum(["incoming","pending","connecting","connected"]),t.ContactType=t.makeEnum(["voice","queue_callback","chat","task"]),t.ContactInitiationMethod=t.makeEnum(["inbound","outbound","transfer","queue_transfer","callback","api","disconnect"]),t.MonitoringMode=t.makeEnum(["SILENT_MONITOR","BARGE"]),t.MonitoringErrorTypes=t.makeEnum(["invalid_target_state"]),t.ChannelType=t.makeEnum(["VOICE","CHAT","TASK"]),t.MediaType=t.makeEnum(["softphone","chat","task"]),t.SoftphoneCallType=t.makeEnum(["audio_video","video_only","audio_only","none"]),t.SoftphoneErrorTypes=t.makeEnum(["unsupported_browser","microphone_not_shared","signalling_handshake_failure","signalling_connection_failure","ice_collection_timeout","user_busy_error","webrtc_error","realtime_communication_error","other"]),t.ClickType=t.makeEnum(["Accept","Reject","Hangup"]),t.VoiceIdErrorTypes=t.makeEnum(["no_speaker_id_found","speaker_id_not_enrolled","get_speaker_id_failed","get_speaker_status_failed","opt_out_speaker_failed","opt_out_speaker_in_lcms_failed","delete_speaker_failed","start_session_failed","evaluate_speaker_failed","session_not_exists","describe_session_failed","enroll_speaker_failed","update_speaker_id_failed","update_speaker_id_in_lcms_failed","not_supported_on_conference_calls","enroll_speaker_timeout","evaluate_speaker_timeout","get_domain_id_failed","no_domain_id_found"]),t.CTIExceptions=t.makeEnum(["AccessDeniedException","InvalidStateException","BadEndpointException","InvalidAgentARNException","InvalidConfigurationException","InvalidContactTypeException","PaginationException","RefreshTokenExpiredException","SendDataFailedException","UnauthorizedException","QuotaExceededException"]),t.VoiceIdStreamingStatus=t.makeEnum(["ONGOING","ENDED","PENDING_CONFIGURATION"]),t.VoiceIdAuthenticationDecision=t.makeEnum(["ACCEPT","REJECT","NOT_ENOUGH_SPEECH","SPEAKER_NOT_ENROLLED","SPEAKER_OPTED_OUT","SPEAKER_ID_NOT_PROVIDED","SPEAKER_EXPIRED"]),t.VoiceIdFraudDetectionDecision=t.makeEnum(["NOT_ENOUGH_SPEECH","HIGH_RISK","LOW_RISK"]),t.ContactFlowAuthenticationDecision=t.makeEnum(["Authenticated","NotAuthenticated","Inconclusive","NotEnrolled","OptedOut","NotEnabled","Error"]),t.ContactFlowFraudDetectionDecision=t.makeEnum(["HighRisk","LowRisk","Inconclusive","NotEnabled","Error"]),t.VoiceIdEnrollmentRequestStatus=t.makeEnum(["NOT_ENOUGH_SPEECH","IN_PROGRESS","COMPLETED","FAILED"]),t.VoiceIdSpeakerStatus=t.makeEnum(["OPTED_OUT","ENROLLED","PENDING"]),t.VoiceIdConstants={EVALUATE_SESSION_DELAY:1e4,EVALUATION_MAX_POLL_TIMES:24,EVALUATION_POLLING_INTERVAL:5e3,ENROLLMENT_MAX_POLL_TIMES:120,ENROLLMENT_POLLING_INTERVAL:5e3,START_SESSION_DELAY:8e3},t.AgentPermissions={OUTBOUND_CALL:"outboundCall",VOICE_ID:"voiceId"};var n=function(){if(!t.agent.initialized)throw new t.StateError("The agent is not yet initialized!")};n.prototype._getData=function(){return t.core.getAgentDataProvider().getAgentData()},n.prototype._createContactAPI=function(e){return new t.Contact(e.contactId)},n.prototype.onRefresh=function(e){t.core.getEventBus().subscribe(t.AgentEvents.REFRESH,e)},n.prototype.onRoutable=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ROUTABLE,e)},n.prototype.onNotRoutable=function(e){t.core.getEventBus().subscribe(t.AgentEvents.NOT_ROUTABLE,e)},n.prototype.onOffline=function(e){t.core.getEventBus().subscribe(t.AgentEvents.OFFLINE,e)},n.prototype.onError=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ERROR,e)},n.prototype.onSoftphoneError=function(e){t.core.getEventBus().subscribe(t.AgentEvents.SOFTPHONE_ERROR,e)},n.prototype.onWebSocketConnectionLost=function(e){t.core.getEventBus().subscribe(t.AgentEvents.WEBSOCKET_CONNECTION_LOST,e)},n.prototype.onWebSocketConnectionGained=function(e){t.core.getEventBus().subscribe(t.AgentEvents.WEBSOCKET_CONNECTION_GAINED,e)},n.prototype.onAfterCallWork=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ACW,e)},n.prototype.onStateChange=function(e){t.core.getEventBus().subscribe(t.AgentEvents.STATE_CHANGE,e)},n.prototype.onMuteToggle=function(e){t.core.getUpstream().onUpstream(t.AgentEvents.MUTE_TOGGLE,e)},n.prototype.onLocalMediaStreamCreated=function(e){t.core.getUpstream().onUpstream(t.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,e)},n.prototype.onSpeakerDeviceChanged=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,e)},n.prototype.onMicrophoneDeviceChanged=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,e)},n.prototype.onRingerDeviceChanged=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.RINGER_DEVICE_CHANGED,e)},n.prototype.mute=function(){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.MUTE,data:{mute:!0}})},n.prototype.unmute=function(){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.MUTE,data:{mute:!1}})},n.prototype.setSpeakerDevice=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SET_SPEAKER_DEVICE,data:{deviceId:e}})},n.prototype.setMicrophoneDevice=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SET_MICROPHONE_DEVICE,data:{deviceId:e}})},n.prototype.setRingerDevice=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SET_RINGER_DEVICE,data:{deviceId:e}})},n.prototype.getState=function(){return this._getData().snapshot.state},n.prototype.getNextState=function(){return this._getData().snapshot.nextState},n.prototype.getAvailabilityState=function(){return this._getData().snapshot.agentAvailabilityState},n.prototype.getStatus=n.prototype.getState,n.prototype.getStateDuration=function(){return t.now()-this._getData().snapshot.state.startTimestamp.getTime()+t.core.getSkew()},n.prototype.getStatusDuration=n.prototype.getStateDuration,n.prototype.getPermissions=function(){return this.getConfiguration().permissions},n.prototype.getContacts=function(e){var t=this;return this._getData().snapshot.contacts.map((function(e){return t._createContactAPI(e)})).filter((function(t){return!e||t.getType()===e}))},n.prototype.getConfiguration=function(){return this._getData().configuration},n.prototype.getAgentStates=function(){return this.getConfiguration().agentStates},n.prototype.getRoutingProfile=function(){return this.getConfiguration().routingProfile},n.prototype.getChannelConcurrency=function(e){var n=this.getRoutingProfile().channelConcurrencyMap;return n||(n=Object.keys(t.ChannelType).reduce((function(e,n){return"TASK"!==n&&(e[t.ChannelType[n]]=1),e}),{})),e?n[e]||0:n},n.prototype.getName=function(){return this.getConfiguration().name},n.prototype.getExtension=function(){return this.getConfiguration().extension},n.prototype.getDialableCountries=function(){return this.getConfiguration().dialableCountries},n.prototype.isSoftphoneEnabled=function(){return this.getConfiguration().softphoneEnabled},n.prototype.setConfiguration=function(e,n){var r=t.core.getClient();e&&e.agentPreferences&&e.agentPreferences.LANGUAGE&&!e.agentPreferences.locale&&(e.agentPreferences.locale=e.agentPreferences.LANGUAGE),e&&e.agentPreferences&&!t.isValidLocale(e.agentPreferences.locale)?n&&n.failure&&n.failure(t.AgentErrorStates.INVALID_LOCALE):r.call(t.ClientMethods.UPDATE_AGENT_CONFIGURATION,{configuration:t.assertNotNull(e,"configuration")},{success:function(e){t.core.getUpstream().sendUpstream(t.EventType.RELOAD_AGENT_CONFIGURATION),n.success&&n.success(e)},failure:n&&n.failure})},n.prototype.setState=function(e,n,r){t.core.getClient().call(t.ClientMethods.PUT_AGENT_STATE,{state:t.assertNotNull(e,"state"),enqueueNextState:r&&!!r.enqueueNextState},n)},n.prototype.onEnqueuedNextState=function(e){t.core.getEventBus().subscribe(t.AgentEvents.ENQUEUED_NEXT_STATE,e)},n.prototype.setStatus=n.prototype.setState,n.prototype.connect=function(e,n){var r=t.core.getClient(),o=new t.Endpoint(e);delete o.endpointId,r.call(t.ClientMethods.CREATE_OUTBOUND_CONTACT,{endpoint:t.assertNotNull(o,"endpoint"),queueARN:n&&(n.queueARN||n.queueId)||this.getRoutingProfile().defaultOutboundQueue.queueARN},n&&{success:n.success,failure:n.failure})},n.prototype.getAllQueueARNs=function(){return this.getConfiguration().routingProfile.queues.map((function(e){return e.queueARN}))},n.prototype.getEndpoints=function(e,n,r){var o=this,i=t.core.getClient();t.assertNotNull(n,"callbacks"),t.assertNotNull(n.success,"callbacks.success");var s=r||{};s.endpoints=s.endpoints||[],s.maxResults=s.maxResults||t.DEFAULT_BATCH_SIZE,t.isArray(e)||(e=[e]),i.call(t.ClientMethods.GET_ENDPOINTS,{queueARNs:e,nextToken:s.nextToken||null,maxResults:s.maxResults},{success:function(r){if(r.nextToken)o.getEndpoints(e,n,{nextToken:r.nextToken,maxResults:s.maxResults,endpoints:s.endpoints.concat(r.endpoints)});else{s.endpoints=s.endpoints.concat(r.endpoints);var i=s.endpoints.map((function(e){return new t.Endpoint(e)}));n.success({endpoints:i,addresses:i})}},failure:n.failure})},n.prototype.getAddresses=n.prototype.getEndpoints,n.prototype._getResourceId=function(){var e=this.getAllQueueARNs();for(let t of e){const e=t.match(/\/agent\/([^/]+)/);if(e)return e[1]}return new Error("Agent.prototype._getResourceId: queueArns did not contain agentResourceId: ",e)},n.prototype.toSnapshot=function(){return new t.AgentSnapshot(this._getData())};var r=function(e){t.Agent.call(this),this.agentData=e};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype._getData=function(){return this.agentData},r.prototype._createContactAPI=function(e){return new t.ContactSnapshot(e)};var o=function(e){this.contactId=e};o.prototype._getData=function(){return t.core.getAgentDataProvider().getContactData(this.getContactId())},o.prototype._createConnectionAPI=function(e){return this.getType()===t.ContactType.CHAT?new t.ChatConnection(this.contactId,e.connectionId):this.getType()===t.ContactType.TASK?new t.TaskConnection(this.contactId,e.connectionId):new t.VoiceConnection(this.contactId,e.connectionId)},o.prototype.getEventName=function(e){return t.core.getContactEventName(e,this.getContactId())},o.prototype.onRefresh=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.REFRESH),e)},o.prototype.onIncoming=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.INCOMING),e)},o.prototype.onConnecting=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.CONNECTING),e)},o.prototype.onPending=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.PENDING),e)},o.prototype.onAccepted=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.ACCEPTED),e)},o.prototype.onMissed=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.MISSED),e)},o.prototype.onEnded=function(e){var n=t.core.getEventBus();n.subscribe(this.getEventName(t.ContactEvents.ENDED),e),n.subscribe(this.getEventName(t.ContactEvents.DESTROYED),e)},o.prototype.onDestroy=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.DESTROYED),e)},o.prototype.onACW=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.ACW),e)},o.prototype.onConnected=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.CONNECTED),e)},o.prototype.onError=function(e){t.core.getEventBus().subscribe(this.getEventName(t.ContactEvents.ERROR),e)},o.prototype.getContactId=function(){return this.contactId},o.prototype.getOriginalContactId=function(){return this._getData().initialContactId},o.prototype.getInitialContactId=o.prototype.getOriginalContactId,o.prototype.getType=function(){return this._getData().type},o.prototype.getContactDuration=function(){return this._getData().contactDuration},o.prototype.getState=function(){return this._getData().state},o.prototype.getStatus=o.prototype.getState,o.prototype.getStateDuration=function(){return t.now()-this._getData().state.timestamp.getTime()+t.core.getSkew()},o.prototype.getStatusDuration=o.prototype.getStateDuration,o.prototype.getQueue=function(){return this._getData().queue},o.prototype.getQueueTimestamp=function(){return this._getData().queueTimestamp},o.prototype.getConnections=function(){var e=this;return this._getData().connections.map((function(n){return e.getType()===t.ContactType.CHAT?new t.ChatConnection(e.contactId,n.connectionId):e.getType()===t.ContactType.TASK?new t.TaskConnection(e.contactId,n.connectionId):new t.VoiceConnection(e.contactId,n.connectionId)}))},o.prototype.getInitialConnection=function(){return t.find(this.getConnections(),(function(e){return e.isInitialConnection()}))||null},o.prototype.getActiveInitialConnection=function(){var e=this.getInitialConnection();return null!=e&&e.isActive()?e:null},o.prototype.getThirdPartyConnections=function(){return this.getConnections().filter((function(e){return!e.isInitialConnection()&&e.getType()!==t.ConnectionType.AGENT}))},o.prototype.getSingleActiveThirdPartyConnection=function(){return this.getThirdPartyConnections().filter((function(e){return e.isActive()}))[0]||null},o.prototype.getAgentConnection=function(){return t.find(this.getConnections(),(function(e){var n=e.getType();return n===t.ConnectionType.AGENT||n===t.ConnectionType.MONITORING}))},o.prototype.getName=function(){return this._getData().name},o.prototype.getContactMetadata=function(){return this._getData().contactMetadata},o.prototype.getDescription=function(){return this._getData().description},o.prototype.getReferences=function(){return this._getData().references},o.prototype.getAttributes=function(){return this._getData().attributes},o.prototype.getContactFeatures=function(){return this._getData().contactFeatures},o.prototype.getChannelContext=function(){return this._getData().channelContext},o.prototype.isSoftphoneCall=function(){return null!=t.find(this.getConnections(),(function(e){return null!=e.getSoftphoneMediaInfo()}))},o.prototype._isInbound=function(){return this._getData().initiationMethod!==t.ContactInitiationMethod.OUTBOUND},o.prototype.isInbound=function(){var e=this.getInitialConnection();return e.getMediaType()===t.MediaType.TASK?this._isInbound():!!e&&e.getType()===t.ConnectionType.INBOUND},o.prototype.isConnected=function(){return this.getStatus().type===t.ContactStateType.CONNECTED},o.prototype.accept=function(e){var n=t.core.getClient(),r=this,o=this.getContactId();t.publishClickStreamData({contactId:this.getContactId(),clickType:t.ClickType.ACCEPT,clickTime:(new Date).toISOString()}),n.call(t.ClientMethods.ACCEPT_CONTACT,{contactId:o},{success:function(n){var i=t.core.getUpstream();i.sendUpstream(t.EventType.BROADCAST,{event:t.ContactEvents.ACCEPTED,data:new t.Contact(o)}),i.sendUpstream(t.EventType.BROADCAST,{event:t.core.getContactEventName(t.ContactEvents.ACCEPTED,r.getContactId()),data:new t.Contact(o)});var s=new t.Contact(o);t.isFirefoxBrowser()&&s.isSoftphoneCall()&&t.core.triggerReadyToStartSessionEvent(),e&&e.success&&e.success(n)},failure:e?e.failure:null})},o.prototype.destroy=function(){t.getLog().warn("contact.destroy() has been deprecated.")},o.prototype.reject=function(e){var n=t.core.getClient();t.publishClickStreamData({contactId:this.getContactId(),clickType:t.ClickType.REJECT,clickTime:(new Date).toISOString()}),n.call(t.ClientMethods.REJECT_CONTACT,{contactId:this.getContactId()},e)},o.prototype.complete=function(e){t.core.getClient().call(t.ClientMethods.COMPLETE_CONTACT,{contactId:this.getContactId()},e)},o.prototype.clear=function(e){t.core.getClient().call(t.ClientMethods.CLEAR_CONTACT,{contactId:this.getContactId()},e)},o.prototype.notifyIssue=function(e,n,r){t.core.getClient().call(t.ClientMethods.NOTIFY_CONTACT_ISSUE,{contactId:this.getContactId(),issueCode:e,description:n},r)},o.prototype.addConnection=function(e,n){var r=t.core.getClient(),o=new t.Endpoint(e);delete o.endpointId,r.call(t.ClientMethods.CREATE_ADDITIONAL_CONNECTION,{contactId:this.getContactId(),endpoint:o},n)},o.prototype.toggleActiveConnections=function(e){var n=t.core.getClient(),r=null,o=t.find(this.getConnections(),(function(e){return e.getStatus().type===t.ConnectionStateType.HOLD}));if(null!=o)r=o.getConnectionId();else{var i=this.getConnections().filter((function(e){return e.isActive()}));i.length>0&&(r=i[0].getConnectionId())}n.call(t.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:r},e)},o.prototype.sendSoftphoneMetrics=function(n,r){t.core.getClient().call(t.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:e.ccpVersion,softphoneStreamStatistics:n},r),t.publishSoftphoneStats({contactId:this.getContactId(),ccpVersion:e.ccpVersion,stats:n})},o.prototype.sendSoftphoneReport=function(n,r){t.core.getClient().call(t.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:e.ccpVersion,report:n},r),t.publishSoftphoneReport({contactId:this.getContactId(),ccpVersion:e.ccpVersion,report:n})},o.prototype.conferenceConnections=function(e){t.core.getClient().call(t.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},o.prototype.toSnapshot=function(){return new t.ContactSnapshot(this._getData())},o.prototype.isMultiPartyConferenceEnabled=function(){var e=this.getContactFeatures();return!(!e||!e.multiPartyConferenceEnabled)},o.prototype.updateMonitorParticipantState=function(e,n){e&&Object.values(t.MonitoringMode).includes(e.toUpperCase())?t.core.getClient().call(t.ClientMethods.UPDATE_MONITOR_PARTICIPANT_STATE,{contactId:this.getContactId(),targetMonitorMode:e.toUpperCase()},n):(t.getLog().error(`Invalid target state was provided: ${e}`).sendInternalLogToServer(),n&&n.failure&&n.failure(t.MonitoringErrorTypes.INVALID_TARGET_STATE))},o.prototype.isUnderSupervision=function(){var e=this.getConnections().filter((e=>e.getType()!==t.ConnectionType.AGENT));return void 0!==(e&&e.find((e=>e.isBarge()&&e.isActive())))};var i=function(e){t.Contact.call(this,e.contactId),this.contactData=e};(i.prototype=Object.create(o.prototype)).constructor=i,i.prototype._getData=function(){return this.contactData},i.prototype._createConnectionAPI=function(e){return new t.ConnectionSnapshot(e)};var s=function(e,t){this.contactId=e,this.connectionId=t,this._initMediaController()};s.prototype._getData=function(){return t.core.getAgentDataProvider().getConnectionData(this.getContactId(),this.getConnectionId())},s.prototype.getContactId=function(){return this.contactId},s.prototype.getConnectionId=function(){return this.connectionId},s.prototype.getEndpoint=function(){return new t.Endpoint(this._getData().endpoint)},s.prototype.getAddress=s.prototype.getEndpoint,s.prototype.getState=function(){return this._getData().state},s.prototype.getStatus=s.prototype.getState,s.prototype.getStateDuration=function(){return t.now()-this._getData().state.timestamp.getTime()+t.core.getSkew()},s.prototype.getStatusDuration=s.prototype.getStateDuration,s.prototype.getType=function(){return this._getData().type},s.prototype.isInitialConnection=function(){return this._getData().initial},s.prototype.isActive=function(){return t.contains(t.CONNECTION_ACTIVE_STATES,this.getStatus().type)},s.prototype.isConnected=function(){return t.contains(t.CONNECTION_CONNECTED_STATES,this.getStatus().type)},s.prototype.isConnecting=function(){return this.getStatus().type===t.ConnectionStateType.CONNECTING},s.prototype.isOnHold=function(){return this.getStatus().type===t.ConnectionStateType.HOLD},s.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMonitorInfo=function(){return this._getData().monitoringInfo},s.prototype.destroy=function(e){t.publishClickStreamData({contactId:this.getContactId(),clickType:t.ClickType.HANGUP,clickTime:(new Date).toISOString()}),t.core.getClient().call(t.ClientMethods.DESTROY_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.sendDigits=function(e,n){t.core.getClient().call(t.ClientMethods.SEND_DIGITS,{contactId:this.getContactId(),connectionId:this.getConnectionId(),digits:e},n)},s.prototype.hold=function(e){t.core.getClient().call(t.ClientMethods.HOLD_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.resume=function(e){t.core.getClient().call(t.ClientMethods.RESUME_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.toSnapshot=function(){return new t.ConnectionSnapshot(this._getData())},s.prototype._initMediaController=function(){this.getMediaInfo()&&t.core.mediaFactory.get(this).catch((function(){}))},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===t.ConnectionType.AGENT||e===t.ConnectionType.MONITORING},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===t.ConnectionType.AGENT||e===t.ConnectionType.MONITORING};var a=function(e){this.contactId=e};a.prototype.getSpeakerId=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){const i={contactId:e.contactId,instanceId:t.core.getAgentDataProvider().getInstanceId(),awsAccountId:t.core.getAgentDataProvider().getAWSAccountId()};t.getLog().info("getSpeakerId called").withObject(i).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.GET_CONTACT,i,{success:function(e){if(e.contactData.customerId){var n={speakerId:e.contactData.customerId};t.getLog().info("getSpeakerId succeeded").withObject(e).sendInternalLogToServer(),r(n)}else{var i=t.VoiceIdError(t.VoiceIdErrorTypes.NO_SPEAKER_ID_FOUND,"No speakerId assotiated with this call");o(i)}},failure:function(e){t.getLog().error("Get SpeakerId failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.GET_SPEAKER_ID_FAILED,"Get SpeakerId failed",e);o(n)}})}))},a.prototype.getSpeakerStatus=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getSpeakerId().then((function(i){e.getDomainId().then((function(e){const s={SpeakerId:t.assertNotNull(i.speakerId,"speakerId"),DomainId:e};t.getLog().info("getSpeakerStatus called").withObject(s).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.DESCRIBE_SPEAKER,s,{success:function(e){t.getLog().info("getSpeakerStatus succeeded").withObject(e).sendInternalLogToServer(),r(e)},failure:function(e){var n=JSON.parse(e);switch(n.status){case 400:case 404:var i=n;i.type=i.type?i.type:t.VoiceIdErrorTypes.SPEAKER_ID_NOT_ENROLLED,t.getLog().info("Speaker is not enrolled.").sendInternalLogToServer(),r(i);break;default:t.getLog().error("getSpeakerStatus failed").withObject({err:e}).sendInternalLogToServer();var s=t.VoiceIdError(t.VoiceIdErrorTypes.GET_SPEAKER_STATUS_FAILED,"Get SpeakerStatus failed",e);o(s)}}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},a.prototype._optOutSpeakerInLcms=function(e,n){var r=this,o=t.core.getClient();return new Promise((function(i,s){const a={ContactId:r.contactId,InstanceId:t.core.getAgentDataProvider().getInstanceId(),AWSAccountId:t.core.getAgentDataProvider().getAWSAccountId(),CustomerId:t.assertNotNull(e,"speakerId"),VoiceIdResult:{SpeakerOptedOut:!0,generatedSpeakerId:n}};t.getLog().info("_optOutSpeakerInLcms called").withObject(a).sendInternalLogToServer(),o.call(t.AgentAppClientMethods.UPDATE_VOICE_ID_DATA,a,{success:function(e){t.getLog().info("optOutSpeakerInLcms succeeded").withObject(e).sendInternalLogToServer(),i(e)},failure:function(e){t.getLog().error("optOutSpeakerInLcms failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.OPT_OUT_SPEAKER_IN_LCMS_FAILED,"optOutSpeakerInLcms failed",e);s(n)}})}))},a.prototype.optOutSpeaker=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getSpeakerId().then((function(i){e.getDomainId().then((function(s){var a=i.speakerId;const c={SpeakerId:t.assertNotNull(a,"speakerId"),DomainId:s};t.getLog().info("optOutSpeaker called").withObject(c).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.OPT_OUT_SPEAKER,c,{success:function(n){e._optOutSpeakerInLcms(a,n.generatedSpeakerId).catch((function(){})),t.getLog().info("optOutSpeaker succeeded").withObject(n).sendInternalLogToServer(),r(n)},failure:function(e){t.getLog().error("optOutSpeaker failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.OPT_OUT_SPEAKER_FAILED,"optOutSpeaker failed.",e);o(n)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},a.prototype.deleteSpeaker=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getSpeakerId().then((function(i){e.getDomainId().then((function(e){const s={SpeakerId:t.assertNotNull(i.speakerId,"speakerId"),DomainId:e};t.getLog().info("deleteSpeaker called").withObject(s).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.DELETE_SPEAKER,s,{success:function(e){t.getLog().info("deleteSpeaker succeeded").withObject(e).sendInternalLogToServer(),r(e)},failure:function(e){t.getLog().error("deleteSpeaker failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.DELETE_SPEAKER_FAILED,"deleteSpeaker failed.",e);o(n)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},a.prototype.startSession=function(){var e=this;e.checkConferenceCall();var n=t.core.getClient();return new Promise((function(r,o){e.getDomainId().then((function(i){const s={contactId:e.contactId,instanceId:t.core.getAgentDataProvider().getInstanceId(),customerAccountId:t.core.getAgentDataProvider().getAWSAccountId(),clientToken:AWS.util.uuid.v4(),domainId:i};t.getLog().info("startSession called").withObject(s).sendInternalLogToServer(),n.call(t.AgentAppClientMethods.START_VOICE_ID_SESSION,s,{success:function(e){if(e.sessionId)r(e);else{t.getLog().error("startVoiceIdSession failed, no session id returned").withObject({data:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.START_SESSION_FAILED,"No session id returned from start session api");o(n)}},failure:function(e){t.getLog().error("startVoiceIdSession failed").withObject({err:e}).sendInternalLogToServer();var n=t.VoiceIdError(t.VoiceIdErrorTypes.START_SESSION_FAILED,"startVoiceIdSession failed",e);o(n)}})})).catch((function(e){o(e)}))}))},a.prototype.evaluateSpeaker=function(e){var n=this;n.checkConferenceCall();var r=t.core.getClient(),o=t.core.getAgentDataProvider().getContactData(this.contactId),i=0;return new Promise((function(s,a){function c(){n.getDomainId().then((function(e){const u={SessionNameOrId:o.initialContactId||this.contactId,DomainId:e};t.getLog().info("evaluateSpeaker called").withObject(u).sendInternalLogToServer(),r.call(t.AgentAppClientMethods.EVALUATE_SESSION,u,{success:function(e){if(++i=1&&(o=r.IntegrationAssociationSummaryList[0].IntegrationArn.replace(/^.*domain\//i,"")),!o){t.getLog().info("getDomainId: no domainId found").sendInternalLogToServer();var i=t.VoiceIdError(t.VoiceIdErrorTypes.NO_DOMAIN_ID_FOUND);return void n(i)}t.getLog().info("getDomainId succeeded").withObject(r).sendInternalLogToServer(),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.VoiceIdEvents.UPDATE_DOMAIN_ID,data:{domainId:o}}),e(o)}catch(e){t.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer(),i=t.VoiceIdError(t.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e),n(i)}},failure:function(e){t.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer();var r=t.VoiceIdError(t.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e);n(r)}})}else n(new Error("Agent doesn't have the permission for Voice ID"))}))},a.prototype.checkConferenceCall=function(){if(t.core.getAgentDataProvider().getContactData(this.contactId).connections.filter((function(e){return t.contains(t.CONNECTION_ACTIVE_STATES,e.state.type)})).length>2)throw new t.NotImplementedError("VoiceId is not supported for conference calls")},a.prototype.isAuthEnabled=function(e){return e!==t.ContactFlowAuthenticationDecision.NOT_ENABLED},a.prototype.isAuthResultNotEnoughSpeech=function(e){return e===t.VoiceIdAuthenticationDecision.NOT_ENOUGH_SPEECH},a.prototype.isAuthResultInconclusive=function(e){return e===t.ContactFlowAuthenticationDecision.INCONCLUSIVE},a.prototype.isFraudEnabled=function(e){return e!==t.ContactFlowFraudDetectionDecision.NOT_ENABLED},a.prototype.isFraudResultNotEnoughSpeech=function(e){return e===t.VoiceIdFraudDetectionDecision.NOT_ENOUGH_SPEECH},a.prototype.isFraudResultInconclusive=function(e){return e===t.ContactFlowFraudDetectionDecision.INCONCLUSIVE};var c=function(e,t){this._speakerAuthenticator=new a(e),s.call(this,e,t)};(c.prototype=Object.create(s.prototype)).constructor=c,c.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},c.prototype.getMediaInfo=function(){return this._getData().softphoneMediaInfo},c.prototype.getMediaType=function(){return t.MediaType.SOFTPHONE},c.prototype.getMediaController=function(){return t.core.mediaFactory.get(this)},c.prototype.getVoiceIdSpeakerId=function(){return this._speakerAuthenticator.getSpeakerId()},c.prototype.getVoiceIdSpeakerStatus=function(){return this._speakerAuthenticator.getSpeakerStatus()},c.prototype.optOutVoiceIdSpeaker=function(){return this._speakerAuthenticator.optOutSpeaker()},c.prototype.deleteVoiceIdSpeaker=function(){return this._speakerAuthenticator.deleteSpeaker()},c.prototype.evaluateSpeakerWithVoiceId=function(e){return this._speakerAuthenticator.evaluateSpeaker(e)},c.prototype.enrollSpeakerInVoiceId=function(e){return this._speakerAuthenticator.enrollSpeaker(e)},c.prototype.updateVoiceIdSpeakerId=function(e){return this._speakerAuthenticator.updateSpeakerIdInVoiceId(e)},c.prototype.getQuickConnectName=function(){return this._getData().quickConnectName},c.prototype.isSilentMonitor=function(){return this.getMonitorStatus()===t.MonitoringMode.SILENT_MONITOR},c.prototype.isBarge=function(){return this.getMonitorStatus()===t.MonitoringMode.BARGE},c.prototype.isBargeEnabled=function(){var e=this.getMonitorCapabilities();return e&&e.includes(t.MonitoringMode.BARGE)},c.prototype.isSilentMonitorEnabled=function(){var e=this.getMonitorCapabilities();return e&&e.includes(t.MonitoringMode.SILENT_MONITOR)},c.prototype.getMonitorCapabilities=function(){return this._getData().monitorCapabilities},c.prototype.getMonitorStatus=function(){return this._getData().monitorStatus},c.prototype.isMute=function(){return this._getData().mute},c.prototype.isForcedMute=function(){return this._getData().forcedMute},c.prototype.muteParticipant=function(e){t.core.getClient().call(t.ClientMethods.MUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},c.prototype.unmuteParticipant=function(e){t.core.getClient().call(t.ClientMethods.UNMUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)};var u=function(e,t){s.call(this,e,t)};(u.prototype=Object.create(s.prototype)).constructor=u,u.prototype.getMediaInfo=function(){var e=this._getData().chatMediaInfo;if(e){var n=t.core.getAgentDataProvider().getContactData(this.contactId),r={contactId:this.contactId,initialContactId:n.initialContactId||this.contactId,participantId:this.connectionId,getConnectionToken:t.hitch(this,this.getConnectionToken)};if(e.connectionData)try{r.participantToken=JSON.parse(e.connectionData).ConnectionAuthenticationToken}catch(n){t.getLog().error(t.LogComponent.CHAT,"Connection data is invalid").withObject(e).withException(n).sendInternalLogToServer(),r.participantToken=null}return r.participantToken=r.participantToken||null,r.originalInfo=this._getData().chatMediaInfo,r}return null},u.prototype.getConnectionToken=function(){var e=t.core.getClient(),n=t.core.getAgentDataProvider().getContactData(this.contactId),r={transportType:t.TRANSPORT_TYPES.CHAT_TOKEN,participantId:this.connectionId,contactId:n.initialContactId||this.contactId};return new Promise((function(n,o){e.call(t.ClientMethods.CREATE_TRANSPORT,r,{success:function(e){t.getLog().info("getConnectionToken succeeded").sendInternalLogToServer(),n(e)},failure:function(e,n){t.getLog().error("getConnectionToken failed").sendInternalLogToServer().withObject({err:e,data:n}),o(Error("getConnectionToken failed"))}})}))},u.prototype.getMediaType=function(){return t.MediaType.CHAT},u.prototype.getMediaController=function(){return t.core.mediaFactory.get(this)},u.prototype._initMediaController=function(){this._isAgentConnectionType()&&t.core.mediaFactory.get(this).catch((function(){}))};var l=function(e,t){s.call(this,e,t)};(l.prototype=Object.create(s.prototype)).constructor=l,l.prototype.getMediaType=function(){return t.MediaType.TASK},l.prototype.getMediaInfo=function(){var e=t.core.getAgentDataProvider().getContactData(this.contactId);return{contactId:this.contactId,initialContactId:e.initialContactId||this.contactId}},l.prototype.getMediaController=function(){return t.core.mediaFactory.get(this)};var p=function(e){t.Connection.call(this,e.contactId,e.connectionId),this.connectionData=e};(p.prototype=Object.create(s.prototype)).constructor=p,p.prototype._getData=function(){return this.connectionData},p.prototype._initMediaController=function(){};var d=function(e){var t=e||{};this.endpointARN=t.endpointId||t.endpointARN||null,this.endpointId=this.endpointARN,this.type=t.type||null,this.name=t.name||null,this.phoneNumber=t.phoneNumber||null,this.agentLogin=t.agentLogin||null,this.queue=t.queue||null};d.prototype.stripPhoneNumber=function(){return this.phoneNumber?this.phoneNumber.replace(/sip:([^@]*)@.*/,"$1"):""},d.byPhoneNumber=function(e,n){return new d({type:t.EndpointType.PHONE_NUMBER,phoneNumber:e,name:n||null})};var h=function(e,t,n){this.errorType=e,this.errorMessage=t,this.endPointUrl=n};h.prototype.getErrorType=function(){return this.errorType},h.prototype.getErrorMessage=function(){return this.errorMessage},h.prototype.getEndPointUrl=function(){return this.endPointUrl},t.agent=function(e){var n=t.core.getEventBus().subscribe(t.AgentEvents.INIT,e);return t.agent.initialized&&e(new t.Agent),n},t.agent.initialized=!1,t.contact=function(e){return t.core.getEventBus().subscribe(t.ContactEvents.INIT,e)},t.onWebsocketInitFailure=function(e){var n=t.core.getEventBus().subscribe(t.WebSocketEvents.INIT_FAILURE,e);return t.webSocketInitFailed&&e(),n},t.ifMaster=function(e,n,r,o){if(t.assertNotNull(e,"A topic must be provided."),t.assertNotNull(n,"A true callback must be provided."),!t.core.masterClient)return t.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e).sendInternalLogToServer(),void(r&&r());t.core.getMasterClient().call(t.MasterMethods.CHECK_MASTER,{topic:e,shouldNotBecomeMasterIfNone:o},{success:function(e){e.isMaster?n():r&&r()}})},t.becomeMaster=function(e,n,r){t.assertNotNull(e,"A topic must be provided."),t.core.masterClient?t.core.getMasterClient().call(t.MasterMethods.BECOME_MASTER,{topic:e},{success:function(){n&&n()}}):(t.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e),r&&r())},t.Agent=n,t.AgentSnapshot=r,t.Contact=o,t.ContactSnapshot=i,t.Connection=c,t.BaseConnection=s,t.VoiceConnection=c,t.ChatConnection=u,t.TaskConnection=l,t.ConnectionSnapshot=p,t.Endpoint=d,t.Address=d,t.SoftphoneError=h,t.VoiceId=a}()},827:(e,t,n)=>{var r;!function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return o(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var i=void 0,s=0;s-1});var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]","[object DataView]"];t.exports={isEmptyData:function(e){return"string"==typeof e?0===e.length:0===e.byteLength},convertToBuffer:function(e){return"string"==typeof e&&(e=new r(e,"utf8")),ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}}},{"buffer/":85}],12:[function(e,t,n){var r=e("./browserHashUtils");function o(e,t){this.hash=new e,this.outer=new e;var n=function(e,t){var n=r.convertToBuffer(t);if(n.byteLength>e.BLOCK_SIZE){var o=new e;o.update(n),n=o.digest()}var i=new Uint8Array(e.BLOCK_SIZE);return i.set(n),i}(e,t),o=new Uint8Array(e.BLOCK_SIZE);o.set(n);for(var i=0;i>>32-o)+n&4294967295}function c(e,t,n,r,o,i,s){return a(t&n|~t&r,e,t,o,i,s)}function u(e,t,n,r,o,i,s){return a(t&r|n&~r,e,t,o,i,s)}function l(e,t,n,r,o,i,s){return a(t^n^r,e,t,o,i,s)}function p(e,t,n,r,o,i,s){return a(n^(t|~r),e,t,o,i,s)}t.exports=s,s.BLOCK_SIZE=i,s.prototype.update=function(e){if(r.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=r.convertToBuffer(e),n=0,o=t.byteLength;for(this.bytesHashed+=o;o>0;)this.buffer.setUint8(this.bufferLength++,t[n++]),o--,this.bufferLength===i&&(this.hashBuffer(),this.bufferLength=0);return this},s.prototype.digest=function(e){if(!this.finished){var t=this,n=t.buffer,r=t.bufferLength,s=8*t.bytesHashed;if(n.setUint8(this.bufferLength++,128),r%i>=56){for(var a=this.bufferLength;a>>0,!0),n.setUint32(60,Math.floor(s/4294967296),!0),this.hashBuffer(),this.finished=!0}var c=new DataView(new ArrayBuffer(16));for(a=0;a<4;a++)c.setUint32(4*a,this.state[a],!0);var u=new o(c.buffer,c.byteOffset,c.byteLength);return e?u.toString(e):u},s.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=t[0],r=t[1],o=t[2],i=t[3];n=c(n,r,o,i,e.getUint32(0,!0),7,3614090360),i=c(i,n,r,o,e.getUint32(4,!0),12,3905402710),o=c(o,i,n,r,e.getUint32(8,!0),17,606105819),r=c(r,o,i,n,e.getUint32(12,!0),22,3250441966),n=c(n,r,o,i,e.getUint32(16,!0),7,4118548399),i=c(i,n,r,o,e.getUint32(20,!0),12,1200080426),o=c(o,i,n,r,e.getUint32(24,!0),17,2821735955),r=c(r,o,i,n,e.getUint32(28,!0),22,4249261313),n=c(n,r,o,i,e.getUint32(32,!0),7,1770035416),i=c(i,n,r,o,e.getUint32(36,!0),12,2336552879),o=c(o,i,n,r,e.getUint32(40,!0),17,4294925233),r=c(r,o,i,n,e.getUint32(44,!0),22,2304563134),n=c(n,r,o,i,e.getUint32(48,!0),7,1804603682),i=c(i,n,r,o,e.getUint32(52,!0),12,4254626195),o=c(o,i,n,r,e.getUint32(56,!0),17,2792965006),n=u(n,r=c(r,o,i,n,e.getUint32(60,!0),22,1236535329),o,i,e.getUint32(4,!0),5,4129170786),i=u(i,n,r,o,e.getUint32(24,!0),9,3225465664),o=u(o,i,n,r,e.getUint32(44,!0),14,643717713),r=u(r,o,i,n,e.getUint32(0,!0),20,3921069994),n=u(n,r,o,i,e.getUint32(20,!0),5,3593408605),i=u(i,n,r,o,e.getUint32(40,!0),9,38016083),o=u(o,i,n,r,e.getUint32(60,!0),14,3634488961),r=u(r,o,i,n,e.getUint32(16,!0),20,3889429448),n=u(n,r,o,i,e.getUint32(36,!0),5,568446438),i=u(i,n,r,o,e.getUint32(56,!0),9,3275163606),o=u(o,i,n,r,e.getUint32(12,!0),14,4107603335),r=u(r,o,i,n,e.getUint32(32,!0),20,1163531501),n=u(n,r,o,i,e.getUint32(52,!0),5,2850285829),i=u(i,n,r,o,e.getUint32(8,!0),9,4243563512),o=u(o,i,n,r,e.getUint32(28,!0),14,1735328473),n=l(n,r=u(r,o,i,n,e.getUint32(48,!0),20,2368359562),o,i,e.getUint32(20,!0),4,4294588738),i=l(i,n,r,o,e.getUint32(32,!0),11,2272392833),o=l(o,i,n,r,e.getUint32(44,!0),16,1839030562),r=l(r,o,i,n,e.getUint32(56,!0),23,4259657740),n=l(n,r,o,i,e.getUint32(4,!0),4,2763975236),i=l(i,n,r,o,e.getUint32(16,!0),11,1272893353),o=l(o,i,n,r,e.getUint32(28,!0),16,4139469664),r=l(r,o,i,n,e.getUint32(40,!0),23,3200236656),n=l(n,r,o,i,e.getUint32(52,!0),4,681279174),i=l(i,n,r,o,e.getUint32(0,!0),11,3936430074),o=l(o,i,n,r,e.getUint32(12,!0),16,3572445317),r=l(r,o,i,n,e.getUint32(24,!0),23,76029189),n=l(n,r,o,i,e.getUint32(36,!0),4,3654602809),i=l(i,n,r,o,e.getUint32(48,!0),11,3873151461),o=l(o,i,n,r,e.getUint32(60,!0),16,530742520),n=p(n,r=l(r,o,i,n,e.getUint32(8,!0),23,3299628645),o,i,e.getUint32(0,!0),6,4096336452),i=p(i,n,r,o,e.getUint32(28,!0),10,1126891415),o=p(o,i,n,r,e.getUint32(56,!0),15,2878612391),r=p(r,o,i,n,e.getUint32(20,!0),21,4237533241),n=p(n,r,o,i,e.getUint32(48,!0),6,1700485571),i=p(i,n,r,o,e.getUint32(12,!0),10,2399980690),o=p(o,i,n,r,e.getUint32(40,!0),15,4293915773),r=p(r,o,i,n,e.getUint32(4,!0),21,2240044497),n=p(n,r,o,i,e.getUint32(32,!0),6,1873313359),i=p(i,n,r,o,e.getUint32(60,!0),10,4264355552),o=p(o,i,n,r,e.getUint32(24,!0),15,2734768916),r=p(r,o,i,n,e.getUint32(52,!0),21,1309151649),n=p(n,r,o,i,e.getUint32(16,!0),6,4149444226),i=p(i,n,r,o,e.getUint32(44,!0),10,3174756917),o=p(o,i,n,r,e.getUint32(8,!0),15,718787259),r=p(r,o,i,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=r+t[1]&4294967295,t[2]=o+t[2]&4294967295,t[3]=i+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":85}],14:[function(e,t,n){var r=e("buffer/").Buffer,o=e("./browserHashUtils");function i(){this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=new Uint32Array(80),this.offset=0,this.shift=24,this.totalLength=0}new Uint32Array([1518500249,1859775393,-1894007588,-899497514]),Math.pow(2,53),t.exports=i,i.BLOCK_SIZE=64,i.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=(e=o.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n14||14===this.offset&&this.shift<24)&&this.processBlock(),this.offset=14,this.shift=24,this.write(0),this.write(0),this.write(this.totalLength>0xffffffffff?this.totalLength/1099511627776:0),this.write(this.totalLength>4294967295?this.totalLength/4294967296:0);for(var t=24;t>=0;t-=8)this.write(this.totalLength>>t);var n=new r(20),o=new DataView(n.buffer);return o.setUint32(0,this.h0,!1),o.setUint32(4,this.h1,!1),o.setUint32(8,this.h2,!1),o.setUint32(12,this.h3,!1),o.setUint32(16,this.h4,!1),e?n.toString(e):n},i.prototype.processBlock=function(){for(var e=16;e<80;e++){var t=this.block[e-3]^this.block[e-8]^this.block[e-14]^this.block[e-16];this.block[e]=t<<1|t>>>31}var n,r,o=this.h0,i=this.h1,s=this.h2,a=this.h3,c=this.h4;for(e=0;e<80;e++){e<20?(n=a^i&(s^a),r=1518500249):e<40?(n=i^s^a,r=1859775393):e<60?(n=i&s|a&(i|s),r=2400959708):(n=i^s^a,r=3395469782);var u=(o<<5|o>>>27)+n+c+r+(0|this.block[e]);c=a,a=s,s=i<<30|i>>>2,i=o,o=u}for(this.h0=this.h0+o|0,this.h1=this.h1+i|0,this.h2=this.h2+s|0,this.h3=this.h3+a|0,this.h4=this.h4+c|0,this.offset=0,e=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":85}],15:[function(e,t,n){var r=e("buffer/").Buffer,o=e("./browserHashUtils"),i=64,s=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=Math.pow(2,53)-1;function c(){this.state=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}t.exports=c,c.BLOCK_SIZE=i,c.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=0,n=(e=o.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>a)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;n>0;)this.buffer[this.bufferLength++]=e[t++],n--,this.bufferLength===i&&(this.hashBuffer(),this.bufferLength=0);return this},c.prototype.digest=function(e){if(!this.finished){var t=8*this.bytesHashed,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),o=this.bufferLength;if(n.setUint8(this.bufferLength++,128),o%i>=56){for(var s=this.bufferLength;s>>24&255,a[4*s+1]=this.state[s]>>>16&255,a[4*s+2]=this.state[s]>>>8&255,a[4*s+3]=this.state[s]>>>0&255;return e?a.toString(e):a},c.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],r=t[1],o=t[2],a=t[3],c=t[4],u=t[5],l=t[6],p=t[7],d=0;d>>17|h<<15)^(h>>>19|h<<13)^h>>>10,g=((h=this.temp[d-15])>>>7|h<<25)^(h>>>18|h<<14)^h>>>3;this.temp[d]=(f+this.temp[d-7]|0)+(g+this.temp[d-16]|0)}var m=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&u^~c&l)|0)+(p+(s[d]+this.temp[d]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&r^n&o^r&o)|0;p=l,l=u,u=c,c=a+m|0,a=o,o=r,r=n,n=m+v|0}t[0]+=n,t[1]+=r,t[2]+=o,t[3]+=a,t[4]+=c,t[5]+=u,t[6]+=l,t[7]+=p}},{"./browserHashUtils":11,"buffer/":85}],16:[function(e,t,n){(function(n){(function(){var n=e("./util");n.crypto.lib=e("./browserCryptoLib"),n.Buffer=e("buffer/").Buffer,n.url=e("url/"),n.querystring=e("querystring/"),n.realClock=e("./realclock/browserClock"),n.environment="js",n.createEventStream=e("./event-stream/buffered-create-event-stream").createEventStream,n.isBrowser=function(){return!0},n.isNode=function(){return!1};var r=e("./core");if(t.exports=r,e("./credentials"),e("./credentials/credential_provider_chain"),e("./credentials/temporary_credentials"),e("./credentials/chainable_temporary_credentials"),e("./credentials/web_identity_credentials"),e("./credentials/cognito_identity_credentials"),e("./credentials/saml_credentials"),r.XML.Parser=e("./xml/browser_parser"),e("./http/xhr"),void 0===o)var o={browser:!0}}).call(this)}).call(this,e("_process"))},{"./browserCryptoLib":10,"./core":19,"./credentials":20,"./credentials/chainable_temporary_credentials":21,"./credentials/cognito_identity_credentials":22,"./credentials/credential_provider_chain":23,"./credentials/saml_credentials":24,"./credentials/temporary_credentials":25,"./credentials/web_identity_credentials":26,"./event-stream/buffered-create-event-stream":28,"./http/xhr":36,"./realclock/browserClock":53,"./util":72,"./xml/browser_parser":73,_process:90,"buffer/":85,"querystring/":96,"url/":98}],17:[function(e,t,n){var r,o=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),o.Config=o.util.inherit({constructor:function(e){void 0===e&&(e={}),e=this.extractCredentials(e),o.util.each.call(this,this.keys,(function(t,n){this.set(t,e[t],n)}))},getCredentials:function(e){var t,n=this;function r(t){e(t,t?null:n.credentials)}function i(e,t){return new o.util.error(t||new Error,{code:"CredentialsError",message:e,name:"CredentialsError"})}n.credentials?"function"==typeof n.credentials.get?n.credentials.get((function(e){e&&(e=i("Could not load credentials from "+n.credentials.constructor.name,e)),r(e)})):(t=null,n.credentials.accessKeyId&&n.credentials.secretAccessKey||(t=i("Missing credentials")),r(t)):n.credentialProvider?n.credentialProvider.resolve((function(e,t){e&&(e=i("Could not load credentials from any providers",e)),n.credentials=t,r(e)})):r(i("No credentials to load"))},update:function(e,t){t=t||!1,e=this.extractCredentials(e),o.util.each.call(this,e,(function(e,n){(t||Object.prototype.hasOwnProperty.call(this.keys,e)||o.Service.hasService(e))&&this.set(e,n)}))},loadFromPath:function(e){this.clear();var t=JSON.parse(o.util.readFileSync(e)),n=new o.FileSystemCredentials(e),r=new o.CredentialProviderChain;return r.providers.unshift(n),r.resolve((function(e,n){if(e)throw e;t.credentials=n})),this.constructor(t),this},clear:function(){o.util.each.call(this,this.keys,(function(e){delete this[e]})),this.set("credentials",void 0),this.set("credentialProvider",void 0)},set:function(e,t,n){void 0===t?(void 0===n&&(n=this.keys[e]),this[e]="function"==typeof n?n.call(this):n):"httpOptions"===e&&this[e]?this[e]=o.util.merge(this[e],t):this[e]=t},keys:{credentials:null,credentialProvider:null,region:null,logger:null,apiVersions:{},apiVersion:null,endpoint:void 0,httpOptions:{timeout:12e4},maxRetries:void 0,maxRedirects:10,paramValidation:!0,sslEnabled:!0,s3ForcePathStyle:!1,s3BucketEndpoint:!1,s3DisableBodySigning:!0,s3UsEast1RegionalEndpoint:"legacy",s3UseArnRegion:void 0,computeChecksums:!0,convertResponseTypes:!0,correctClockSkew:!1,customUserAgent:null,dynamoDbCrc32:!0,systemClockOffset:0,signatureVersion:null,signatureCache:!0,retryDelayOptions:{},useAccelerateEndpoint:!1,clientSideMonitoring:!1,endpointDiscoveryEnabled:void 0,endpointCacheSize:1e3,hostPrefixEnabled:!0,stsRegionalEndpoints:"legacy",useFipsEndpoint:!1,useDualstackEndpoint:!1},extractCredentials:function(e){return e.accessKeyId&&e.secretAccessKey&&((e=o.util.copy(e)).credentials=new o.Credentials(e)),e},setPromisesDependency:function(e){r=e,null===e&&"function"==typeof Promise&&(r=Promise);var t=[o.Request,o.Credentials,o.CredentialProviderChain];o.S3&&(t.push(o.S3),o.S3.ManagedUpload&&t.push(o.S3.ManagedUpload)),o.util.addPromises(t,r)},getPromisesDependency:function(){return r}}),o.config=new o.Config},{"./core":19,"./credentials":20,"./credentials/credential_provider_chain":23}],18:[function(e,t,n){(function(n){(function(){var r=e("./core");function o(e,t){if("string"==typeof e){if(["legacy","regional"].indexOf(e.toLowerCase())>=0)return e.toLowerCase();throw r.util.error(new Error,t)}}t.exports=function(e,t){var i;if((e=e||{})[t.clientConfig]&&(i=o(e[t.clientConfig],{code:"InvalidConfiguration",message:'invalid "'+t.clientConfig+'" configuration. Expect "legacy" or "regional". Got "'+e[t.clientConfig]+'".'})))return i;if(!r.util.isNode())return i;if(Object.prototype.hasOwnProperty.call(n.env,t.env)&&(i=o(n.env[t.env],{code:"InvalidEnvironmentalVariable",message:"invalid "+t.env+' environmental variable. Expect "legacy" or "regional". Got "'+n.env[t.env]+'".'})))return i;var s={};try{s=r.util.getProfilesFromSharedConfig(r.util.iniLoader)[n.env.AWS_PROFILE||r.util.defaultProfile]}catch(e){}return s&&Object.prototype.hasOwnProperty.call(s,t.sharedConfig)&&(i=o(s[t.sharedConfig],{code:"InvalidConfiguration",message:"invalid "+t.sharedConfig+' profile config. Expect "legacy" or "regional". Got "'+s[t.sharedConfig]+'".'})),i}}).call(this)}).call(this,e("_process"))},{"./core":19,_process:90}],19:[function(e,t,n){var r={util:e("./util")};({}).toString(),t.exports=r,r.util.update(r,{VERSION:"2.1200.0",Signers:{},Protocol:{Json:e("./protocol/json"),Query:e("./protocol/query"),Rest:e("./protocol/rest"),RestJson:e("./protocol/rest_json"),RestXml:e("./protocol/rest_xml")},XML:{Builder:e("./xml/builder"),Parser:null},JSON:{Builder:e("./json/builder"),Parser:e("./json/parser")},Model:{Api:e("./model/api"),Operation:e("./model/operation"),Shape:e("./model/shape"),Paginator:e("./model/paginator"),ResourceWaiter:e("./model/resource_waiter")},apiLoader:e("./api_loader"),EndpointCache:e("../vendor/endpoint-cache").EndpointCache}),e("./sequential_executor"),e("./service"),e("./config"),e("./http"),e("./event_listeners"),e("./request"),e("./response"),e("./resource_waiter"),e("./signers/request_signer"),e("./param_validator"),r.events=new r.SequentialExecutor,r.util.memoizedProperty(r,"endpointCache",(function(){return new r.EndpointCache(r.config.endpointCacheSize)}),!0)},{"../vendor/endpoint-cache":109,"./api_loader":9,"./config":17,"./event_listeners":34,"./http":35,"./json/builder":37,"./json/parser":38,"./model/api":39,"./model/operation":41,"./model/paginator":42,"./model/resource_waiter":43,"./model/shape":44,"./param_validator":45,"./protocol/json":47,"./protocol/query":48,"./protocol/rest":49,"./protocol/rest_json":50,"./protocol/rest_xml":51,"./request":57,"./resource_waiter":58,"./response":59,"./sequential_executor":60,"./service":61,"./signers/request_signer":64,"./util":72,"./xml/builder":74}],20:[function(e,t,n){var r=e("./core");r.Credentials=r.util.inherit({constructor:function(){if(r.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"==typeof arguments[0]){var e=arguments[0].credentials||arguments[0];this.accessKeyId=e.accessKeyId,this.secretAccessKey=e.secretAccessKey,this.sessionToken=e.sessionToken}else this.accessKeyId=arguments[0],this.secretAccessKey=arguments[1],this.sessionToken=arguments[2]},expiryWindow:15,needsRefresh:function(){var e=r.util.date.getDate().getTime(),t=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&t>this.expireTime)||this.expired||!this.accessKeyId||!this.secretAccessKey},get:function(e){var t=this;this.needsRefresh()?this.refresh((function(n){n||(t.expired=!1),e&&e(n)})):e&&e()},refresh:function(e){this.expired=!1,e()},coalesceRefresh:function(e,t){var n=this;1===n.refreshCallbacks.push(e)&&n.load((function(e){r.util.arrayEach(n.refreshCallbacks,(function(n){t?n(e):r.util.defer((function(){n(e)}))})),n.refreshCallbacks.length=0}))},load:function(e){e()}}),r.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=r.util.promisifyMethod("get",e),this.prototype.refreshPromise=r.util.promisifyMethod("refresh",e)},r.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},r.util.addPromises(r.Credentials)},{"./core":19}],21:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.ChainableTemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=r.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!=typeof e.tokenCodeFn)throw new r.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=r.util.merge({params:t,credentials:e.masterCredentials||r.config.credentials},e.stsConfig||{});this.service=new o(n)},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this,n=t.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode((function(r,o){var i={};r?e(r):(o&&(i.TokenCode=o),t.service[n](i,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)})))}))},getTokenCode:function(e){var t=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,(function(n,o){if(n){var i=n;return n instanceof Error&&(i=n.message),void e(r.util.error(new Error("Error fetching MFA token: "+i),{code:t.errorCode}))}e(null,o)})):e(null)}})},{"../../clients/sts":8,"../core":19}],22:[function(e,t,n){var r=e("../core"),o=e("../../clients/cognitoidentity"),i=e("../../clients/sts");r.CognitoIdentityCredentials=r.util.inherit(r.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=r.util.copy(t||{}),this.loadCachedId();var n=this;Object.defineProperty(this,"identityId",{get:function(){return n.loadCachedId(),n._identityId||n.params.IdentityId},set:function(e){n._identityId=e}})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.data=null,t._identityId=null,t.getId((function(n){n?(t.clearIdOnNotAuthorized(n),e(n)):t.params.RoleArn?t.getCredentialsFromSTS(e):t.getCredentialsForIdentity(e)}))},clearCachedId:function(){this._identityId=null,delete this.params.IdentityId;var e=this.params.IdentityPoolId,t=this.params.LoginId||"";delete this.storage[this.localStorageKey.id+e+t],delete this.storage[this.localStorageKey.providers+e+t]},clearIdOnNotAuthorized:function(e){"NotAuthorizedException"==e.code&&this.clearCachedId()},getId:function(e){var t=this;if("string"==typeof t.params.IdentityId)return e(null,t.params.IdentityId);t.cognito.getId((function(n,r){!n&&r.IdentityId?(t.params.IdentityId=r.IdentityId,e(null,r.IdentityId)):e(n)}))},loadCredentials:function(e,t){e&&t&&(t.expired=!1,t.accessKeyId=e.Credentials.AccessKeyId,t.secretAccessKey=e.Credentials.SecretKey,t.sessionToken=e.Credentials.SessionToken,t.expireTime=e.Credentials.Expiration)},getCredentialsForIdentity:function(e){var t=this;t.cognito.getCredentialsForIdentity((function(n,r){n?t.clearIdOnNotAuthorized(n):(t.cacheId(r),t.data=r,t.loadCredentials(t.data,t)),e(n)}))},getCredentialsFromSTS:function(e){var t=this;t.cognito.getOpenIdToken((function(n,r){n?(t.clearIdOnNotAuthorized(n),e(n)):(t.cacheId(r),t.params.WebIdentityToken=r.Token,t.webIdentityCredentials.refresh((function(n){n||(t.data=t.webIdentityCredentials.data,t.sts.credentialsFrom(t.data,t)),e(n)})))}))},loadCachedId:function(){var e=this;if(r.util.isBrowser()&&!e.params.IdentityId){var t=e.getStorage("id");if(t&&e.params.Logins){var n=Object.keys(e.params.Logins);0!==(e.getStorage("providers")||"").split(",").filter((function(e){return-1!==n.indexOf(e)})).length&&(e.params.IdentityId=t)}else t&&(e.params.IdentityId=t)}},createClients:function(){var e=this._clientConfig;if(this.webIdentityCredentials=this.webIdentityCredentials||new r.WebIdentityCredentials(this.params,e),!this.cognito){var t=r.util.merge({},e);t.params=this.params,this.cognito=new o(t)}this.sts=this.sts||new i(e)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,r.util.isBrowser()&&(this.setStorage("id",e.IdentityId),this.params.Logins&&this.setStorage("providers",Object.keys(this.params.Logins).join(",")))},getStorage:function(e){return this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]},setStorage:function(e,t){try{this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]=t}catch(e){}},storage:function(){try{var e=r.util.isBrowser()&&null!==window.localStorage&&"object"==typeof window.localStorage?window.localStorage:{};return e["aws.test-storage"]="foobar",delete e["aws.test-storage"],e}catch(e){return{}}}()})},{"../../clients/cognitoidentity":7,"../../clients/sts":8,"../core":19}],23:[function(e,t,n){var r=e("../core");r.CredentialProviderChain=r.util.inherit(r.Credentials,{constructor:function(e){this.providers=e||r.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var t=this;if(0===t.providers.length)return e(new Error("No providers")),t;if(1===t.resolveCallbacks.push(e)){var n=0,o=t.providers.slice(0);!function e(i,s){if(!i&&s||n===o.length)return r.util.arrayEach(t.resolveCallbacks,(function(e){e(i,s)})),void(t.resolveCallbacks.length=0);var a=o[n++];(s="function"==typeof a?a.call():a).get?s.get((function(t){e(t,t?null:s)})):e(null,s)}()}return t}}),r.CredentialProviderChain.defaultProviders=[],r.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=r.util.promisifyMethod("resolve",e)},r.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},r.util.addPromises(r.CredentialProviderChain)},{"../core":19}],24:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.SAMLCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithSAML((function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":19}],25:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.TemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.loadMasterCredentials(t),this.expired=!0,this.params=e||{},this.params.RoleArn&&(this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials")},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.masterCredentials.get((function(){t.service.config.credentials=t.masterCredentials,(t.params.RoleArn?t.service.assumeRole:t.service.getSessionToken).call(t.service,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))}))},loadMasterCredentials:function(e){for(this.masterCredentials=e||r.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new r.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":19}],26:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.WebIdentityCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=r.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithWebIdentity((function(n,r){t.data=null,n||(t.data=r,t.service.credentialsFrom(r,t)),e(n)}))},createClients:function(){if(!this.service){var e=r.util.merge({},this._clientConfig);e.params=this.params,this.service=new o(e)}}})},{"../../clients/sts":8,"../core":19}],27:[function(e,t,n){(function(n){(function(){var r=e("./core"),o=e("./util"),i=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function s(e){var t=e.service,n=t.api||{},r=(n.operations,{});return t.config.region&&(r.region=t.config.region),n.serviceId&&(r.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(r.accessKeyId=t.config.credentials.accessKeyId),r}function a(e,t,n){n&&null!=t&&"structure"===n.type&&n.required&&n.required.length>0&&o.arrayEach(n.required,(function(r){var o=n.members[r];if(!0===o.endpointDiscoveryId){var i=o.isLocationName?o.name:r;e[i]=String(t[r])}else a(e,t[r],o)}))}function c(e,t){var n={};return a(n,e.params,t),n}function u(e){var t=e.service,n=t.api,i=n.operations?n.operations[e.operation]:void 0,a=c(e,i?i.input:void 0),u=s(e);Object.keys(a).length>0&&(u=o.update(u,a),i&&(u.operation=i.name));var l=r.endpointCache.get(u);if(!l||1!==l.length||""!==l[0].Address)if(l&&l.length>0)e.httpRequest.updateEndpoint(l[0].Address);else{var p=t.makeRequest(n.endpointOperation,{Operation:i.name,Identifiers:a});d(p),p.removeListener("validate",r.EventListeners.Core.VALIDATE_PARAMETERS),p.removeListener("retry",r.EventListeners.Core.RETRY_CHECK),r.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}]),p.send((function(e,t){t&&t.Endpoints?r.endpointCache.put(u,t.Endpoints):e&&r.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}])}))}}var l={};function p(e,t){var n=e.service,i=n.api,a=i.operations?i.operations[e.operation]:void 0,u=a?a.input:void 0,p=c(e,u),h=s(e);Object.keys(p).length>0&&(h=o.update(h,p),a&&(h.operation=a.name));var f=r.EndpointCache.getKeyString(h),g=r.endpointCache.get(f);if(g&&1===g.length&&""===g[0].Address)return l[f]||(l[f]=[]),void l[f].push({request:e,callback:t});if(g&&g.length>0)e.httpRequest.updateEndpoint(g[0].Address),t();else{var m=n.makeRequest(i.endpointOperation,{Operation:a.name,Identifiers:p});m.removeListener("validate",r.EventListeners.Core.VALIDATE_PARAMETERS),d(m),r.endpointCache.put(f,[{Address:"",CachePeriodInMinutes:60}]),m.send((function(n,i){if(n){if(e.response.error=o.error(n,{retryable:!1}),r.endpointCache.remove(h),l[f]){var s=l[f];o.arrayEach(s,(function(e){e.request.response.error=o.error(n,{retryable:!1}),e.callback()})),delete l[f]}}else i&&(r.endpointCache.put(f,i.Endpoints),e.httpRequest.updateEndpoint(i.Endpoints[0].Address),l[f])&&(s=l[f],o.arrayEach(s,(function(e){e.request.httpRequest.updateEndpoint(i.Endpoints[0].Address),e.callback()})),delete l[f]);t()}))}}function d(e){var t=e.service.api.apiVersion;t&&!e.httpRequest.headers["x-amz-api-version"]&&(e.httpRequest.headers["x-amz-api-version"]=t)}function h(e){var t=e.error,n=e.httpResponse;if(t&&("InvalidEndpointException"===t.code||421===n.statusCode)){var i=e.request,a=i.service.api.operations||{},u=c(i,a[i.operation]?a[i.operation].input:void 0),l=s(i);Object.keys(u).length>0&&(l=o.update(l,u),a[i.operation]&&(l.operation=a[i.operation].name)),r.endpointCache.remove(l)}}function f(e){return["false","0"].indexOf(e)>=0}t.exports={discoverEndpoint:function(e,t){var s=e.service||{};if(function(e){if(e._originalConfig&&e._originalConfig.endpoint&&!0===e._originalConfig.endpointDiscoveryEnabled)throw o.error(new Error,{code:"ConfigurationException",message:"Custom endpoint is supplied; endpointDiscoveryEnabled must not be true."});var t=r.config[e.serviceIdentifier]||{};return Boolean(r.config.endpoint||t.endpoint||e._originalConfig&&e._originalConfig.endpoint)}(s)||e.isPresigned())return t();var a=(s.api.operations||{})[e.operation],c=a?a.endpointDiscoveryRequired:"NULL",l=function(e){var t=e.service||{};if(void 0!==t.config.endpointDiscoveryEnabled)return t.config.endpointDiscoveryEnabled;if(!o.isBrowser()){for(var s=0;s-1&&(e[t]++,0===e[t]);t--);}i.fromNumber=function(e){if(e>0x8000000000000000||e<-0x8000000000000000)throw new Error(e+" is too large (or, if negative, too small) to represent as an Int64");for(var t=new Uint8Array(8),n=7,r=Math.abs(Math.round(e));n>-1&&r>0;n--,r/=256)t[n]=r;return e<0&&s(t),new i(t)},i.prototype.valueOf=function(){var e=this.bytes.slice(0),t=128&e[0];return t&&s(e),parseInt(e.toString("hex"),16)*(t?-1:1)},i.prototype.toString=function(){return String(this.valueOf())},t.exports={Int64:i}},{"../core":19}],31:[function(e,t,n){var r=e("./parse-message").parseMessage;t.exports={parseEvent:function(e,t,n){var o=r(t),i=o.headers[":message-type"];if(i){if("error"===i.value)throw function(e){var t=e.headers[":error-code"],n=e.headers[":error-message"],r=new Error(n.value||n);return r.code=r.name=t.value||t,r}(o);if("event"!==i.value)return}var s=o.headers[":event-type"],a=n.members[s.value];if(a){var c={},u=a.eventPayloadMemberName;if(u){var l=a.members[u];"binary"===l.type?c[u]=o.body:c[u]=e.parse(o.body.toString(),l)}for(var p=a.eventHeaderMemberNames,d=0;d=0)return e.httpRequest.headers["X-Amz-Content-Sha256"]="UNSIGNED-PAYLOAD",t();n.util.computeSha256(i,(function(n,r){n?t(n):(e.httpRequest.headers["X-Amz-Content-Sha256"]=r,t())}))}else t()}})),e("SET_CONTENT_LENGTH","afterBuild",(function(e){var t=function(e){if(!e.service.api.operations)return"";var t=e.service.api.operations[e.operation];return t?t.authtype:""}(e),r=n.util.getRequestPayloadShape(e);if(void 0===e.httpRequest.headers["Content-Length"])try{var o=n.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=o}catch(n){if(r&&r.isStreaming){if(r.requiresLength)throw n;if(t.indexOf("unsigned-body")>=0)return void(e.httpRequest.headers["Transfer-Encoding"]="chunked");throw n}throw n}})),e("SET_HTTP_HOST","afterBuild",(function(e){e.httpRequest.headers.Host=e.httpRequest.endpoint.host})),e("SET_TRACE_ID","afterBuild",(function(e){var r="X-Amzn-Trace-Id";if(n.util.isNode()&&!Object.hasOwnProperty.call(e.httpRequest.headers,r)){var o=t.env.AWS_LAMBDA_FUNCTION_NAME,i=t.env._X_AMZN_TRACE_ID;"string"==typeof o&&o.length>0&&"string"==typeof i&&i.length>0&&(e.httpRequest.headers[r]=i)}})),e("RESTART","restart",(function(){var e=this.response.error;e&&e.retryable&&(this.httpRequest=new n.HttpRequest(this.service.endpoint,this.service.region),this.response.retryCount=600?this.emit("sign",[this],(function(e){e?t(e):i()})):i()})),e("HTTP_HEADERS","httpHeaders",(function(e,t,r,o){r.httpResponse.statusCode=e,r.httpResponse.statusMessage=o,r.httpResponse.headers=t,r.httpResponse.body=n.util.buffer.toBuffer(""),r.httpResponse.buffers=[],r.httpResponse.numBytes=0;var i=t.date||t.Date,s=r.request.service;if(i){var a=Date.parse(i);s.config.correctClockSkew&&s.isClockSkewed(a)&&s.applyClockOffset(a)}})),e("HTTP_DATA","httpData",(function(e,t){if(e){if(n.util.isNode()){t.httpResponse.numBytes+=e.length;var r=t.httpResponse.headers["content-length"],o={loaded:t.httpResponse.numBytes,total:r};t.request.emit("httpDownloadProgress",[o,t])}t.httpResponse.buffers.push(n.util.buffer.toBuffer(e))}})),e("HTTP_DONE","httpDone",(function(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var t=n.util.buffer.concat(e.httpResponse.buffers);e.httpResponse.body=t}delete e.httpResponse.numBytes,delete e.httpResponse.buffers})),e("FINALIZE_ERROR","retry",(function(e){e.httpResponse.statusCode&&(e.error.statusCode=e.httpResponse.statusCode,void 0===e.error.retryable&&(e.error.retryable=this.service.retryableError(e.error,this)))})),e("INVALIDATE_CREDENTIALS","retry",(function(e){if(e.error)switch(e.error.code){case"RequestExpired":case"ExpiredTokenException":case"ExpiredToken":e.error.retryable=!0,e.request.service.config.credentials.expired=!0}})),e("EXPIRED_SIGNATURE","retry",(function(e){var t=e.error;t&&"string"==typeof t.code&&"string"==typeof t.message&&t.code.match(/Signature/)&&t.message.match(/expired/)&&(e.error.retryable=!0)})),e("CLOCK_SKEWED","retry",(function(e){e.error&&this.service.clockSkewError(e.error)&&this.service.config.correctClockSkew&&(e.error.retryable=!0)})),e("REDIRECT","retry",(function(e){e.error&&e.error.statusCode>=300&&e.error.statusCode<400&&e.httpResponse.headers.location&&(this.httpRequest.endpoint=new n.Endpoint(e.httpResponse.headers.location),this.httpRequest.headers.Host=this.httpRequest.endpoint.host,e.error.redirect=!0,e.error.retryable=!0)})),e("RETRY_CHECK","retry",(function(e){e.error&&(e.error.redirect&&e.redirectCount=0?(e.error=null,setTimeout(t,n)):t()}))})),CorePost:(new r).addNamedListeners((function(e){e("EXTRACT_REQUEST_ID","extractData",n.util.extractRequestId),e("EXTRACT_REQUEST_ID","extractError",n.util.extractRequestId),e("ENOTFOUND_ERROR","httpError",(function(e){if("NetworkingError"===e.code&&function(e){return"ENOTFOUND"===e.errno||"number"==typeof e.errno&&"function"==typeof n.util.getSystemErrorName&&["EAI_NONAME","EAI_NODATA"].indexOf(n.util.getSystemErrorName(e.errno)>=0)}(e)){var t="Inaccessible host: `"+e.hostname+"' at port `"+e.port+"'. This service may not be available in the `"+e.region+"' region.";this.response.error=n.util.error(new Error(t),{code:"UnknownEndpoint",region:e.region,hostname:e.hostname,retryable:!0,originalError:e})}}))})),Logger:(new r).addNamedListeners((function(t){t("LOG_REQUEST","complete",(function(t){var r=t.request,o=r.service.config.logger;if(o){var i=function(){var i=(t.request.service.getSkewCorrectedDate().getTime()-r.startTime.getTime())/1e3,a=!!o.isTTY,c=t.httpResponse.statusCode,u=r.params;r.service.api.operations&&r.service.api.operations[r.operation]&&r.service.api.operations[r.operation].input&&(u=s(r.service.api.operations[r.operation].input,r.params));var l=e("util").inspect(u,!0,null),p="";return a&&(p+=""),p+="[AWS "+r.service.serviceIdentifier+" "+c,p+=" "+i.toString()+"s "+t.retryCount+" retries]",a&&(p+=""),p+=" "+n.util.string.lowerFirst(r.operation),p+="("+l+")",a&&(p+=""),p}();"function"==typeof o.log?o.log(i):"function"==typeof o.write&&o.write(i+"\n")}function s(e,t){if(!t)return t;if(e.isSensitive)return"***SensitiveInformation***";switch(e.type){case"structure":var r={};return n.util.each(t,(function(t,n){Object.prototype.hasOwnProperty.call(e.members,t)?r[t]=s(e.members[t],n):r[t]=n})),r;case"list":var o=[];return n.util.arrayEach(t,(function(t,n){o.push(s(e.member,t))})),o;case"map":var i={};return n.util.each(t,(function(t,n){i[t]=s(e.value,n)})),i;default:return t}}}))})),Json:(new r).addNamedListeners((function(t){var n=e("./protocol/json");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),Rest:(new r).addNamedListeners((function(t){var n=e("./protocol/rest");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),RestJson:(new r).addNamedListeners((function(t){var n=e("./protocol/rest_json");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),RestXml:(new r).addNamedListeners((function(t){var n=e("./protocol/rest_xml");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)})),Query:(new r).addNamedListeners((function(t){var n=e("./protocol/query");t("BUILD","build",n.buildRequest),t("EXTRACT_DATA","extractData",n.extractData),t("EXTRACT_ERROR","extractError",n.extractError)}))}}).call(this)}).call(this,e("_process"))},{"./core":19,"./discover_endpoint":27,"./protocol/json":47,"./protocol/query":48,"./protocol/rest":49,"./protocol/rest_json":50,"./protocol/rest_xml":51,"./sequential_executor":60,_process:90,util:84}],35:[function(e,t,n){var r=e("./core"),o=r.util.inherit;r.Endpoint=o({constructor:function(e,t){if(r.util.hideProperties(this,["slashes","auth","hash","search","query"]),null==e)throw new Error("Invalid endpoint: "+e);if("string"!=typeof e)return r.util.copy(e);e.match(/^http/)||(e=((t&&void 0!==t.sslEnabled?t.sslEnabled:r.config.sslEnabled)?"https":"http")+"://"+e),r.util.update(this,r.util.urlParse(e)),this.port?this.port=parseInt(this.port,10):this.port="https:"===this.protocol?443:80}}),r.HttpRequest=o({constructor:function(e,t){e=new r.Endpoint(e),this.method="POST",this.path=e.path||"/",this.headers={},this.body="",this.endpoint=e,this.region=t,this._userAgent="",this.setUserAgent()},setUserAgent:function(){this._userAgent=this.headers[this.getUserAgentHeaderName()]=r.util.userAgent()},getUserAgentHeaderName:function(){return(r.util.isBrowser()?"X-Amz-":"")+"User-Agent"},appendToUserAgent:function(e){"string"==typeof e&&e&&(this._userAgent+=" "+e),this.headers[this.getUserAgentHeaderName()]=this._userAgent},getUserAgent:function(){return this._userAgent},pathname:function(){return this.path.split("?",1)[0]},search:function(){var e=this.path.split("?",2)[1];return e?(e=r.util.queryStringParse(e),r.util.queryParamsToString(e)):""},updateEndpoint:function(e){var t=new r.Endpoint(e);this.endpoint=t,this.path=t.path||"/",this.headers.Host&&(this.headers.Host=t.host)}}),r.HttpResponse=o({constructor:function(){this.statusCode=void 0,this.headers={},this.body=void 0,this.streaming=!1,this.stream=null},createUnbufferedStream:function(){return this.streaming=!0,this.stream}}),r.HttpClient=o({}),r.HttpClient.getInstance=function(){return void 0===this.singleton&&(this.singleton=new this),this.singleton}},{"./core":19}],36:[function(e,t,n){var r=e("../core"),o=e("events").EventEmitter;e("../http"),r.XHRClient=r.util.inherit({handleRequest:function(e,t,n,i){var s=this,a=e.endpoint,c=new o,u=a.protocol+"//"+a.hostname;80!==a.port&&443!==a.port&&(u+=":"+a.port),u+=e.path;var l=new XMLHttpRequest,p=!1;e.stream=l,l.addEventListener("readystatechange",(function(){try{if(0===l.status)return}catch(e){return}this.readyState>=this.HEADERS_RECEIVED&&!p&&(c.statusCode=l.status,c.headers=s.parseHeaders(l.getAllResponseHeaders()),c.emit("headers",c.statusCode,c.headers,l.statusText),p=!0),this.readyState===this.DONE&&s.finishRequest(l,c)}),!1),l.upload.addEventListener("progress",(function(e){c.emit("sendProgress",e)})),l.addEventListener("progress",(function(e){c.emit("receiveProgress",e)}),!1),l.addEventListener("timeout",(function(){i(r.util.error(new Error("Timeout"),{code:"TimeoutError"}))}),!1),l.addEventListener("error",(function(){i(r.util.error(new Error("Network Failure"),{code:"NetworkingError"}))}),!1),l.addEventListener("abort",(function(){i(r.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))}),!1),n(c),l.open(e.method,u,!1!==t.xhrAsync),r.util.each(e.headers,(function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&l.setRequestHeader(e,t)})),t.timeout&&!1!==t.xhrAsync&&(l.timeout=t.timeout),t.xhrWithCredentials&&(l.withCredentials=!0);try{l.responseType="arraybuffer"}catch(e){}try{e.body?l.send(e.body):l.send()}catch(t){if(!e.body||"object"!=typeof e.body.buffer)throw t;l.send(e.body.buffer)}return c},parseHeaders:function(e){var t={};return r.util.arrayEach(e.split(/\r?\n/),(function(e){var n=e.split(":",1)[0],r=e.substring(n.length+2);n.length>0&&(t[n.toLowerCase()]=r)})),t},finishRequest:function(e,t){var n;if("arraybuffer"===e.responseType&&e.response){var o=e.response;n=new r.util.Buffer(o.byteLength);for(var i=new Uint8Array(o),s=0;s-1?t||"":t,this.isJsonValue?JSON.parse(t):t&&"function"==typeof t.toString?t.toString():t},this.toWireFormat=function(e){return this.isJsonValue?JSON.stringify(e):e}}function h(){a.apply(this,arguments),this.toType=function(e){var t=o.base64.decode(e);if(this.isSensitive&&o.isNode()&&"function"==typeof o.Buffer.alloc){var n=o.Buffer.alloc(t.length,t);t.fill(0),t=n}return t},this.toWireFormat=o.base64.encode}function f(){h.apply(this,arguments)}function g(){a.apply(this,arguments),this.toType=function(e){return"boolean"==typeof e?e:null==e?null:"true"===e}}a.normalizedTypes={character:"string",double:"float",long:"integer",short:"integer",biginteger:"integer",bigdecimal:"float",blob:"binary"},a.types={structure:u,list:l,map:p,boolean:g,timestamp:function(e){var t=this;if(a.apply(this,arguments),e.timestampFormat)i(this,"timestampFormat",e.timestampFormat);else if(t.isTimestampFormatSet&&this.timestampFormat)i(this,"timestampFormat",this.timestampFormat);else if("header"===this.location)i(this,"timestampFormat","rfc822");else if("querystring"===this.location)i(this,"timestampFormat","iso8601");else if(this.api)switch(this.api.protocol){case"json":case"rest-json":i(this,"timestampFormat","unixTimestamp");break;case"rest-xml":case"query":case"ec2":i(this,"timestampFormat","iso8601")}this.toType=function(e){return null==e?null:"function"==typeof e.toUTCString?e:"string"==typeof e||"number"==typeof e?o.date.parseTimestamp(e):null},this.toWireFormat=function(e){return o.date.format(e,t.timestampFormat)}},float:function(){a.apply(this,arguments),this.toType=function(e){return null==e?null:parseFloat(e)},this.toWireFormat=this.toType},integer:function(){a.apply(this,arguments),this.toType=function(e){return null==e?null:parseInt(e,10)},this.toWireFormat=this.toType},string:d,base64:f,binary:h},a.resolve=function(e,t){if(e.shape){var n=t.api.shapes[e.shape];if(!n)throw new Error("Cannot find shape reference: "+e.shape);return n}return null},a.create=function(e,t,n){if(e.isShape)return e;var r=a.resolve(e,t);if(r){var o=Object.keys(e);t.documentation||(o=o.filter((function(e){return!e.match(/documentation/)})));var i=function(){r.constructor.call(this,e,t,n)};return i.prototype=r,new i}e.type||(e.members?e.type="structure":e.member?e.type="list":e.key?e.type="map":e.type="string");var s=e.type;if(a.normalizedTypes[e.type]&&(e.type=a.normalizedTypes[e.type]),a.types[e.type])return new a.types[e.type](e,t,n);throw new Error("Unrecognized shape type: "+s)},a.shapes={StructureShape:u,ListShape:l,MapShape:p,StringShape:d,BooleanShape:g,Base64Shape:f},t.exports=a},{"../util":72,"./collection":40}],45:[function(e,t,n){var r=e("./core");r.ParamValidator=r.util.inherit({constructor:function(e){!0!==e&&void 0!==e||(e={min:!0}),this.validation=e},validate:function(e,t,n){if(this.errors=[],this.validateMember(e,t||{},n||"params"),this.errors.length>1){var o=this.errors.join("\n* ");throw o="There were "+this.errors.length+" validation errors:\n* "+o,r.util.error(new Error(o),{code:"MultipleValidationErrors",errors:this.errors})}if(1===this.errors.length)throw this.errors[0];return!0},fail:function(e,t){this.errors.push(r.util.error(new Error(t),{code:e}))},validateStructure:function(e,t,n){if(e.isDocument)return!0;var r;this.validateType(t,n,["object"],"structure");for(var o=0;e.required&&o= 1, but found "'+t+'" for '+n)},validatePattern:function(e,t,n){this.validation.pattern&&void 0!==e.pattern&&(new RegExp(e.pattern).test(t)||this.fail("PatternMatchError",'Provided value "'+t+'" does not match regex pattern /'+e.pattern+"/ for "+n))},validateRange:function(e,t,n,r){this.validation.min&&void 0!==e.min&&t= "+e.min+", but found "+t+" for "+n),this.validation.max&&void 0!==e.max&&t>e.max&&this.fail("MaxRangeError","Expected "+r+" <= "+e.max+", but found "+t+" for "+n)},validateEnum:function(e,t,n){this.validation.enum&&void 0!==e.enum&&-1===e.enum.indexOf(t)&&this.fail("EnumError","Found string value of "+t+", but expected "+e.enum.join("|")+" for "+n)},validateType:function(e,t,n,o){if(null==e)return!1;for(var i=!1,s=0;s63)throw r.error(new Error,{code:"ValidationError",message:"Hostname label length should be between 1 to 63 characters, inclusive."});if(!i.test(e))throw o.util.error(new Error,{code:"ValidationError",message:e+" is not hostname compatible."})}))}return e}}},{"../core":19,"../util":72}],47:[function(e,t,n){var r=e("../util"),o=e("../json/builder"),i=e("../json/parser"),s=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.httpRequest,n=e.service.api,r=n.targetPrefix+"."+n.operations[e.operation].name,i=n.jsonVersion||"1.0",a=n.operations[e.operation].input,c=new o;1===i&&(i="1.0"),t.body=c.build(e.params||{},a),t.headers["Content-Type"]="application/x-amz-json-"+i,t.headers["X-Amz-Target"]=r,s(e)},extractError:function(e){var t={},n=e.httpResponse;if(t.code=n.headers["x-amzn-errortype"]||"UnknownError","string"==typeof t.code&&(t.code=t.code.split(":")[0]),n.body.length>0)try{var o=JSON.parse(n.body.toString()),i=o.__type||o.code||o.Code;i&&(t.code=i.split("#").pop()),"RequestEntityTooLarge"===t.code?t.message="Request body must be less than 1 MB":t.message=o.message||o.Message||null}catch(o){t.statusCode=n.statusCode,t.message=n.statusMessage}else t.statusCode=n.statusCode,t.message=n.statusCode.toString();e.error=r.error(new Error,t)},extractData:function(e){var t=e.httpResponse.body.toString()||"{}";if(!1===e.request.service.config.convertResponseTypes)e.data=JSON.parse(t);else{var n=e.request.service.api.operations[e.request.operation].output||{},r=new i;e.data=r.parse(t,n)}}}},{"../json/builder":37,"../json/parser":38,"../util":72,"./helpers":46}],48:[function(e,t,n){var r=e("../core"),o=e("../util"),i=e("../query/query_param_serializer"),s=e("../model/shape"),a=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.service.api.operations[e.operation],n=e.httpRequest;n.headers["Content-Type"]="application/x-www-form-urlencoded; charset=utf-8",n.params={Version:e.service.api.apiVersion,Action:t.name},(new i).serialize(e.params,t.input,(function(e,t){n.params[e]=t})),n.body=o.queryParamsToString(n.params),a(e)},extractError:function(e){var t,n=e.httpResponse.body.toString();if(n.match("=0?"&":"?";var c=[];r.arrayEach(Object.keys(s).sort(),(function(e){Array.isArray(s[e])||(s[e]=[s[e]]);for(var t=0;t0){var p=(t=new r.XML.Parser).parse(s.toString(),c);o.update(e.data,p)}}}},{"../core":19,"../util":72,"./rest":49}],52:[function(e,t,n){var r=e("../util");function o(){}function i(e){return e.isQueryName||"ec2"!==e.api.protocol?e.name:e.name[0].toUpperCase()+e.name.substr(1)}function s(e,t,n,o){r.each(n.members,(function(n,r){var s=t[n];if(null!=s){var c=i(r);a(c=e?e+"."+c:c,s,r,o)}}))}function a(e,t,n,o){null!=t&&("structure"===n.type?s(e,t,n,o):"list"===n.type?function(e,t,n,o){var s=n.member||{};0!==t.length?r.arrayEach(t,(function(t,r){var c="."+(r+1);if("ec2"===n.api.protocol)c+="";else if(n.flattened){if(s.name){var u=e.split(".");u.pop(),u.push(i(s)),e=u.join(".")}}else c="."+(s.name?s.name:"member")+c;a(e+c,t,s,o)})):o.call(this,e,null)}(e,t,n,o):"map"===n.type?function(e,t,n,o){var i=1;r.each(t,(function(t,r){var s=(n.flattened?".":".entry.")+i+++".",c=s+(n.key.name||"key"),u=s+(n.value.name||"value");a(e+c,t,n.key,o),a(e+u,r,n.value,o)}))}(e,t,n,o):o(e,n.toWireFormat(t).toString()))}o.prototype.serialize=function(e,t,n){s("",e,t,n)},t.exports=o},{"../util":72}],53:[function(e,t,n){t.exports={now:function(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}}},{}],54:[function(e,t,n){t.exports={isFipsRegion:function(e){return"string"==typeof e&&(e.startsWith("fips-")||e.endsWith("-fips"))},isGlobalRegion:function(e){return"string"==typeof e&&["aws-global","aws-us-gov-global"].includes(e)},getRealRegion:function(e){return["fips-aws-global","aws-fips","aws-global"].includes(e)?"us-east-1":["fips-aws-us-gov-global","aws-us-gov-global"].includes(e)?"us-gov-west-1":e.replace(/fips-(dkr-|prod-)?|-fips/,"")}}},{}],55:[function(e,t,n){var r=e("./util"),o=e("./region_config_data.json");function i(e,t){r.each(t,(function(t,n){"globalEndpoint"!==t&&(void 0!==e.config[t]&&null!==e.config[t]||(e.config[t]=n))}))}t.exports={configureEndpoint:function(e){for(var t=function(e){var t=e.config.region,n=function(e){if(!e)return null;var t=e.split("-");return t.length<3?null:t.slice(0,t.length-2).join("-")+"-*"}(t),r=e.api.endpointPrefix;return[[t,r],[n,r],[t,"*"],[n,"*"],["*",r],["*","*"]].map((function(e){return e[0]&&e[1]?e.join("/"):null}))}(e),n=e.config.useFipsEndpoint,r=e.config.useDualstackEndpoint,s=0;s=0){c=!0;var u=0}var l=function(){c&&u!==a?o.emit("error",n.util.error(new Error("Stream content length mismatch. Received "+u+" of "+a+" bytes."),{code:"StreamContentLengthMismatch"})):2===n.HttpClient.streamsApiVersion?o.end():o.emit("end")},p=s.httpResponse.createUnbufferedStream();if(2===n.HttpClient.streamsApiVersion)if(c){var d=new e.PassThrough;d._write=function(t){return t&&t.length&&(u+=t.length),e.PassThrough.prototype._write.apply(this,arguments)},d.on("end",l),o.on("error",(function(e){c=!1,p.unpipe(d),d.emit("end"),d.end()})),p.pipe(d).pipe(o,{end:!1})}else p.pipe(o);else c&&p.on("data",(function(e){e&&e.length&&(u+=e.length)})),p.on("data",(function(e){o.emit("data",e)})),p.on("end",l);p.on("error",(function(e){c=!1,o.emit("error",e)}))}})),o},emitEvent:function(e,t,r){"function"==typeof t&&(r=t,t=null),r||(r=function(){}),t||(t=this.eventParameters(e,this.response)),n.SequentialExecutor.prototype.emit.call(this,e,t,(function(e){e&&(this.response.error=e),r.call(this,e)}))},eventParameters:function(e){switch(e){case"restart":case"validate":case"sign":case"build":case"afterValidate":case"afterBuild":return[this];case"error":return[this.response.error,this.response];default:return[this.response]}},presign:function(e,t){return t||"function"!=typeof e||(t=e,e=null),(new n.Signers.Presign).sign(this.toGet(),e,t)},isPresigned:function(){return Object.prototype.hasOwnProperty.call(this.httpRequest.headers,"presigned-expires")},toUnauthenticated:function(){return this._unAuthenticated=!0,this.removeListener("validate",n.EventListeners.Core.VALIDATE_CREDENTIALS),this.removeListener("sign",n.EventListeners.Core.SIGN),this},toGet:function(){return"query"!==this.service.api.protocol&&"ec2"!==this.service.api.protocol||(this.removeListener("build",this.buildAsGet),this.addListener("build",this.buildAsGet)),this},buildAsGet:function(e){e.httpRequest.method="GET",e.httpRequest.path=e.service.endpoint.path+"?"+e.httpRequest.body,e.httpRequest.body="",delete e.httpRequest.headers["Content-Length"],delete e.httpRequest.headers["Content-Type"]},haltHandlersOnError:function(){this._haltHandlersOnError=!0}}),n.Request.addPromisesToClass=function(e){this.prototype.promise=function(){var t=this;return this.httpRequest.appendToUserAgent("promise"),new e((function(e,n){t.on("complete",(function(t){t.error?n(t.error):e(Object.defineProperty(t.data||{},"$response",{value:t}))})),t.runTo()}))}},n.Request.deletePromisesFromClass=function(){delete this.prototype.promise},n.util.addPromises(n.Request),n.util.mixin(n.Request,n.SequentialExecutor)}).call(this)}).call(this,e("_process"))},{"./core":19,"./state_machine":71,_process:90,jmespath:89}],58:[function(e,t,n){var r=e("./core"),o=r.util.inherit,i=e("jmespath");function s(e){var t=e.request._waiter,n=t.config.acceptors,r=!1,o="retry";n.forEach((function(n){if(!r){var i=t.matchers[n.matcher];i&&i(e,n.expected,n.argument)&&(r=!0,o=n.state)}})),!r&&e.error&&(o="failure"),"success"===o?t.setSuccess(e):t.setError(e,"retry"===o)}r.ResourceWaiter=o({constructor:function(e,t){this.service=e,this.state=t,this.loadWaiterConfig(this.state)},service:null,state:null,config:null,matchers:{path:function(e,t,n){try{var r=i.search(e.data,n)}catch(e){return!1}return i.strictDeepEqual(r,t)},pathAll:function(e,t,n){try{var r=i.search(e.data,n)}catch(e){return!1}Array.isArray(r)||(r=[r]);var o=r.length;if(!o)return!1;for(var s=0;s-1&&n.splice(o,1)}return this},removeAllListeners:function(e){return e?delete this._events[e]:this._events={},this},emit:function(e,t,n){n||(n=function(){});var r=this.listeners(e),o=r.length;return this.callListeners(r,t,n),o>0},callListeners:function(e,t,n,o){var i=this,s=o||null;function a(o){if(o&&(s=r.util.error(s||new Error,o),i._haltHandlersOnError))return n.call(i,s);i.callListeners(e,t,n,s)}for(;e.length>0;){var c=e.shift();if(c._isAsync)return void c.apply(i,t.concat([a]));try{c.apply(i,t)}catch(e){s=r.util.error(s||new Error,e)}if(s&&i._haltHandlersOnError)return void n.call(i,s)}n.call(i,s)},addListeners:function(e){var t=this;return e._events&&(e=e._events),r.util.each(e,(function(e,n){"function"==typeof n&&(n=[n]),r.util.arrayEach(n,(function(n){t.on(e,n)}))})),t},addNamedListener:function(e,t,n,r){return this[e]=n,this.addListener(t,n,r),this},addNamedAsyncListener:function(e,t,n,r){return n._isAsync=!0,this.addNamedListener(e,t,n,r)},addNamedListeners:function(e){var t=this;return e((function(){t.addNamedListener.apply(t,arguments)}),(function(){t.addNamedAsyncListener.apply(t,arguments)})),this}}),r.SequentialExecutor.prototype.addListener=r.SequentialExecutor.prototype.on,t.exports=r.SequentialExecutor},{"./core":19}],61:[function(e,t,n){(function(n){(function(){var r=e("./core"),o=e("./model/api"),i=e("./region_config"),s=r.util.inherit,a=0,c=e("./region/utils");r.Service=s({constructor:function(e){if(!this.loadServiceClass)throw r.util.error(new Error,"Service must be constructed with `new' operator");if(e){if(e.region){var t=e.region;c.isFipsRegion(t)&&(e.region=c.getRealRegion(t),e.useFipsEndpoint=!0),c.isGlobalRegion(t)&&(e.region=c.getRealRegion(t))}"boolean"==typeof e.useDualstack&&"boolean"!=typeof e.useDualstackEndpoint&&(e.useDualstackEndpoint=e.useDualstack)}var n=this.loadServiceClass(e||{});if(n){var o=r.util.copy(e),i=new n(e);return Object.defineProperty(i,"_originalConfig",{get:function(){return o},enumerable:!1,configurable:!0}),i._clientId=++a,i}this.initialize(e)},initialize:function(e){var t=r.config[this.serviceIdentifier];if(this.config=new r.Config(r.config),t&&this.config.update(t,!0),e&&this.config.update(e,!0),this.validateService(),this.config.endpoint||i.configureEndpoint(this),this.config.endpoint=this.endpointFromTemplate(this.config.endpoint),this.setEndpoint(this.config.endpoint),r.SequentialExecutor.call(this),r.Service.addDefaultMonitoringListeners(this),(this.config.clientSideMonitoring||r.Service._clientSideMonitoring)&&this.publisher){var o=this.publisher;this.addNamedListener("PUBLISH_API_CALL","apiCall",(function(e){n.nextTick((function(){o.eventHandler(e)}))})),this.addNamedListener("PUBLISH_API_ATTEMPT","apiCallAttempt",(function(e){n.nextTick((function(){o.eventHandler(e)}))}))}},validateService:function(){},loadServiceClass:function(e){var t=e;if(r.util.isEmpty(this.api)){if(t.apiConfig)return r.Service.defineServiceApi(this.constructor,t.apiConfig);if(this.constructor.services){(t=new r.Config(r.config)).update(e,!0);var n=t.apiVersions[this.constructor.serviceIdentifier];return n=n||t.apiVersion,this.getLatestServiceClass(n)}return null}return null},getLatestServiceClass:function(e){return e=this.getLatestServiceVersion(e),null===this.constructor.services[e]&&r.Service.defineServiceApi(this.constructor,e),this.constructor.services[e]},getLatestServiceVersion:function(e){if(!this.constructor.services||0===this.constructor.services.length)throw new Error("No services defined on "+this.constructor.serviceIdentifier);if(e?r.util.isType(e,Date)&&(e=r.util.date.iso8601(e).split("T")[0]):e="latest",Object.hasOwnProperty(this.constructor.services,e))return e;for(var t=Object.keys(this.constructor.services).sort(),n=null,o=t.length-1;o>=0;o--)if("*"!==t[o][t[o].length-1]&&(n=t[o]),t[o].substr(0,10)<=e)return n;throw new Error("Could not find "+this.constructor.serviceIdentifier+" API to satisfy version constraint `"+e+"'")},api:{},defaultRetryCount:3,customizeRequests:function(e){if(e){if("function"!=typeof e)throw new Error("Invalid callback type '"+typeof e+"' provided in customizeRequests");this.customRequestHandler=e}else this.customRequestHandler=null},makeRequest:function(e,t,n){if("function"==typeof t&&(n=t,t=null),t=t||{},this.config.params){var o=this.api.operations[e];o&&(t=r.util.copy(t),r.util.each(this.config.params,(function(e,n){o.input.members[e]&&(void 0!==t[e]&&null!==t[e]||(t[e]=n))})))}var i=new r.Request(this,e,t);return this.addAllRequestListeners(i),this.attachMonitoringEmitter(i),n&&i.send(n),i},makeUnauthenticatedRequest:function(e,t,n){"function"==typeof t&&(n=t,t={});var r=this.makeRequest(e,t).toUnauthenticated();return n?r.send(n):r},waitFor:function(e,t,n){return new r.ResourceWaiter(this,e).wait(t,n)},addAllRequestListeners:function(e){for(var t=[r.events,r.EventListeners.Core,this.serviceInterface(),r.EventListeners.CorePost],n=0;n299?(o.code&&(n.FinalAwsException=o.code),o.message&&(n.FinalAwsExceptionMessage=o.message)):((o.code||o.name)&&(n.FinalSdkException=o.code||o.name),o.message&&(n.FinalSdkExceptionMessage=o.message))}return n},apiAttemptEvent:function(e){var t=e.service.api.operations[e.operation],n={Type:"ApiCallAttempt",Api:t?t.name:e.operation,Version:1,Service:e.service.api.serviceId||e.service.api.endpointPrefix,Fqdn:e.httpRequest.endpoint.hostname,UserAgent:e.httpRequest.getUserAgent()},r=e.response;return r.httpResponse.statusCode&&(n.HttpStatusCode=r.httpResponse.statusCode),!e._unAuthenticated&&e.service.config.credentials&&e.service.config.credentials.accessKeyId&&(n.AccessKey=e.service.config.credentials.accessKeyId),r.httpResponse.headers?(e.httpRequest.headers["x-amz-security-token"]&&(n.SessionToken=e.httpRequest.headers["x-amz-security-token"]),r.httpResponse.headers["x-amzn-requestid"]&&(n.XAmznRequestId=r.httpResponse.headers["x-amzn-requestid"]),r.httpResponse.headers["x-amz-request-id"]&&(n.XAmzRequestId=r.httpResponse.headers["x-amz-request-id"]),r.httpResponse.headers["x-amz-id-2"]&&(n.XAmzId2=r.httpResponse.headers["x-amz-id-2"]),n):n},attemptFailEvent:function(e){var t=this.apiAttemptEvent(e),n=e.response,r=n.error;return n.httpResponse.statusCode>299?(r.code&&(t.AwsException=r.code),r.message&&(t.AwsExceptionMessage=r.message)):((r.code||r.name)&&(t.SdkException=r.code||r.name),r.message&&(t.SdkExceptionMessage=r.message)),t},attachMonitoringEmitter:function(e){var t,n,o,i,s,a,c=0,u=this;e.on("validate",(function(){i=r.util.realClock.now(),a=Date.now()}),!0),e.on("sign",(function(){n=r.util.realClock.now(),t=Date.now(),s=e.httpRequest.region,c++}),!0),e.on("validateResponse",(function(){o=Math.round(r.util.realClock.now()-n)})),e.addNamedListener("API_CALL_ATTEMPT","success",(function(){var n=u.apiAttemptEvent(e);n.Timestamp=t,n.AttemptLatency=o>=0?o:0,n.Region=s,u.emit("apiCallAttempt",[n])})),e.addNamedListener("API_CALL_ATTEMPT_RETRY","retry",(function(){var i=u.attemptFailEvent(e);i.Timestamp=t,o=o||Math.round(r.util.realClock.now()-n),i.AttemptLatency=o>=0?o:0,i.Region=s,u.emit("apiCallAttempt",[i])})),e.addNamedListener("API_CALL","complete",(function(){var t=u.apiCallEvent(e);if(t.AttemptCount=c,!(t.AttemptCount<=0)){t.Timestamp=a;var n=Math.round(r.util.realClock.now()-i);t.Latency=n>=0?n:0;var o=e.response;o.error&&o.error.retryable&&"number"==typeof o.retryCount&&"number"==typeof o.maxRetries&&o.retryCount>=o.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t])}}))},setupRequestListeners:function(e){},getSigningName:function(){return this.api.signingName||this.api.endpointPrefix},getSignerClass:function(e){var t,n=null,o="";return e&&(o=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:""),t=this.config.signatureVersion?this.config.signatureVersion:"v4"===o||"v4-unsigned-body"===o?"v4":this.api.signatureVersion,r.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return r.EventListeners.Query;case"json":return r.EventListeners.Json;case"rest-json":return r.EventListeners.RestJson;case"rest-xml":return r.EventListeners.RestXml}if(this.api.protocol)throw new Error("Invalid service `protocol' "+this.api.protocol+" in API config")},successfulResponse:function(e){return e.httpResponse.statusCode<300},numRetries:function(){return void 0!==this.config.maxRetries?this.config.maxRetries:this.defaultRetryCount},retryDelays:function(e,t){return r.util.calculateRetryDelay(e,this.config.retryDelayOptions,t)},retryableError:function(e){return!!this.timeoutError(e)||!!this.networkingError(e)||!!this.expiredCredentialsError(e)||!!this.throttledError(e)||e.statusCode>=500},networkingError:function(e){return"NetworkingError"===e.code},timeoutError:function(e){return"TimeoutError"===e.code},expiredCredentialsError:function(e){return"ExpiredTokenException"===e.code},clockSkewError:function(e){switch(e.code){case"RequestTimeTooSkewed":case"RequestExpired":case"InvalidSignatureException":case"SignatureDoesNotMatch":case"AuthFailure":case"RequestInTheFuture":return!0;default:return!1}},getSkewCorrectedDate:function(){return new Date(Date.now()+this.config.systemClockOffset)},applyClockOffset:function(e){e&&(this.config.systemClockOffset=e-Date.now())},isClockSkewed:function(e){if(e)return Math.abs(this.getSkewCorrectedDate().getTime()-e)>=3e5},throttledError:function(e){if(429===e.statusCode)return!0;switch(e.code){case"ProvisionedThroughputExceededException":case"Throttling":case"ThrottlingException":case"RequestLimitExceeded":case"RequestThrottled":case"RequestThrottledException":case"TooManyRequestsException":case"TransactionInProgressException":case"EC2ThrottledException":return!0;default:return!1}},endpointFromTemplate:function(e){if("string"!=typeof e)return e;var t=e;return t=(t=(t=t.replace(/\{service\}/g,this.api.endpointPrefix)).replace(/\{region\}/g,this.config.region)).replace(/\{scheme\}/g,this.config.sslEnabled?"https":"http")},setEndpoint:function(e){this.endpoint=new r.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(!n){if(t){var o=new Error;throw r.util.error(o,"No pagination configuration for "+e)}return null}return n}}),r.util.update(r.Service,{defineMethods:function(e){r.util.each(e.prototype.api.operations,(function(t){e.prototype[t]||("none"===e.prototype.api.operations[t].authtype?e.prototype[t]=function(e,n){return this.makeUnauthenticatedRequest(t,e,n)}:e.prototype[t]=function(e,n){return this.makeRequest(t,e,n)})}))},defineService:function(e,t,n){r.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var o=s(r.Service,n||{});if("string"==typeof e){r.Service.addVersions(o,t);var i=o.serviceIdentifier||e;o.serviceIdentifier=i}else o.prototype.api=e,r.Service.defineMethods(o);if(r.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&r.util.clientSideMonitoring){var a=r.util.clientSideMonitoring.Publisher,c=(0,r.util.clientSideMonitoring.configProvider)();this.prototype.publisher=new a(c),c.enabled&&(r.Service._clientSideMonitoring=!0)}return r.SequentialExecutor.call(o.prototype),r.Service.addDefaultMonitoringListeners(o.prototype),o},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n604800)throw r.util.error(new Error,{code:"InvalidExpiryTime",message:"Presigning does not support expiry time greater than a week with SigV4 signing.",retryable:!1});e.httpRequest.headers[i]=t}else{if(n!==r.Signers.S3)throw r.util.error(new Error,{message:"Presigning only supports S3 or SigV4 signing.",code:"UnsupportedSigner",retryable:!1});var o=e.service?e.service.getSkewCorrectedDate():r.util.date.getDate();e.httpRequest.headers[i]=parseInt(r.util.date.unixTimestamp(o)+t,10).toString()}}function a(e){var t=e.httpRequest.endpoint,n=r.util.urlParse(e.httpRequest.path),o={};n.search&&(o=r.util.queryStringParse(n.search.substr(1)));var s=e.httpRequest.headers.Authorization.split(" ");if("AWS"===s[0])s=s[1].split(":"),o.Signature=s.pop(),o.AWSAccessKeyId=s.join(":"),r.util.each(e.httpRequest.headers,(function(e,t){e===i&&(e="Expires"),0===e.indexOf("x-amz-meta-")&&(delete o[e],e=e.toLowerCase()),o[e]=t})),delete e.httpRequest.headers[i],delete o.Authorization,delete o.Host;else if("AWS4-HMAC-SHA256"===s[0]){s.shift();var a=s.join(" ").match(/Signature=(.*?)(?:,|\s|\r?\n|$)/)[1];o["X-Amz-Signature"]=a,delete o.Expires}t.pathname=n.pathname,t.search=r.util.queryParamsToString(o)}r.Signers.Presign=o({sign:function(e,t,n){if(e.httpRequest.headers[i]=t||3600,e.on("build",s),e.on("sign",a),e.removeListener("afterBuild",r.EventListeners.Core.SET_CONTENT_LENGTH),e.removeListener("afterBuild",r.EventListeners.Core.COMPUTE_SHA256),e.emit("beforePresign",[e]),!n){if(e.build(),e.response.error)throw e.response.error;return r.util.urlFormat(e.httpRequest.endpoint)}e.build((function(){this.response.error?n(this.response.error):n(null,r.util.urlFormat(e.httpRequest.endpoint))}))}}),t.exports=r.Signers.Presign},{"../core":19}],64:[function(e,t,n){var r=e("../core"),o=r.util.inherit;r.Signers.RequestSigner=o({constructor:function(e){this.request=e},setServiceClientId:function(e){this.serviceClientId=e},getServiceClientId:function(){return this.serviceClientId}}),r.Signers.RequestSigner.getVersion=function(e){switch(e){case"v2":return r.Signers.V2;case"v3":return r.Signers.V3;case"s3v4":case"v4":return r.Signers.V4;case"s3":return r.Signers.S3;case"v3https":return r.Signers.V3Https}throw new Error("Unknown signing version "+e)},e("./v2"),e("./v3"),e("./v3https"),e("./v4"),e("./s3"),e("./presign")},{"../core":19,"./presign":63,"./s3":65,"./v2":66,"./v3":67,"./v3https":68,"./v4":69}],65:[function(e,t,n){var r=e("../core"),o=r.util.inherit;r.Signers.S3=o(r.Signers.RequestSigner,{subResources:{acl:1,accelerate:1,analytics:1,cors:1,lifecycle:1,delete:1,inventory:1,location:1,logging:1,metrics:1,notification:1,partNumber:1,policy:1,requestPayment:1,replication:1,restore:1,tagging:1,torrent:1,uploadId:1,uploads:1,versionId:1,versioning:1,versions:1,website:1},responseHeaders:{"response-content-type":1,"response-content-language":1,"response-expires":1,"response-cache-control":1,"response-content-disposition":1,"response-content-encoding":1},addAuthorization:function(e,t){this.request.headers["presigned-expires"]||(this.request.headers["X-Amz-Date"]=r.util.date.rfc822(t)),e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken);var n=this.sign(e.secretAccessKey,this.stringToSign()),o="AWS "+e.accessKeyId+":"+n;this.request.headers.Authorization=o},stringToSign:function(){var e=this.request,t=[];t.push(e.method),t.push(e.headers["Content-MD5"]||""),t.push(e.headers["Content-Type"]||""),t.push(e.headers["presigned-expires"]||"");var n=this.canonicalizedAmzHeaders();return n&&t.push(n),t.push(this.canonicalizedResource()),t.join("\n")},canonicalizedAmzHeaders:function(){var e=[];r.util.each(this.request.headers,(function(t){t.match(/^x-amz-/i)&&e.push(t)})),e.sort((function(e,t){return e.toLowerCase()=0?"&":"?";this.request.path+=i+r.util.queryParamsToString(o)},authorization:function(e,t){var n=[],r=this.credentialString(t);return n.push(this.algorithm+" Credential="+e.accessKeyId+"/"+r),n.push("SignedHeaders="+this.signedHeaders()),n.push("Signature="+this.signature(e,t)),n.join(", ")},signature:function(e,t){var n=o.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return r.util.crypto.hmac(n,this.stringToSign(t),"hex")},stringToSign:function(e){var t=[];return t.push("AWS4-HMAC-SHA256"),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")},canonicalString:function(){var e=[],t=this.request.pathname();return"s3"!==this.serviceName&&"s3v4"!==this.signatureVersion&&(t=r.util.uriEscapePath(t)),e.push(this.request.method),e.push(t),e.push(this.request.search()),e.push(this.canonicalHeaders()+"\n"),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")},canonicalHeaders:function(){var e=[];r.util.each.call(this,this.request.headers,(function(t,n){e.push([t,n])})),e.sort((function(e,t){return e[0].toLowerCase()-1&&!e.body?"UNSIGNED-PAYLOAD":e.headers["X-Amz-Content-Sha256"]?e.headers["X-Amz-Content-Sha256"]:this.hexEncodedHash(this.request.body||"")},unsignableHeaders:["authorization","content-type","content-length","user-agent",s,"expect","x-amzn-trace-id"],isSignableHeader:function(e){return 0===e.toLowerCase().indexOf("x-amz-")||this.unsignableHeaders.indexOf(e)<0},isPresigned:function(){return!!this.request.headers[s]}}),t.exports=r.Signers.V4},{"../core":19,"./v4_credentials":70}],70:[function(e,t,n){var r=e("../core"),o={},i=[],s="aws4_request";t.exports={createScope:function(e,t,n){return[e.substr(0,8),t,n,s].join("/")},getSigningKey:function(e,t,n,a,c){var u=[r.util.crypto.hmac(e.secretAccessKey,e.accessKeyId,"base64"),t,n,a].join("_");if((c=!1!==c)&&u in o)return o[u];var l=r.util.crypto.hmac("AWS4"+e.secretAccessKey,t,"buffer"),p=r.util.crypto.hmac(l,n,"buffer"),d=r.util.crypto.hmac(p,a,"buffer"),h=r.util.crypto.hmac(d,s,"buffer");return c&&(o[u]=h,i.push(u),i.length>50&&delete o[i.shift()]),h},emptyCache:function(){o={},i=[]}}},{"../core":19}],71:[function(e,t,n){function r(e,t){this.currentState=t||null,this.states=e||{}}r.prototype.runTo=function(e,t,n,r){"function"==typeof e&&(r=n,n=t,t=e,e=null);var o=this,i=o.states[o.currentState];i.fn.call(n||o,r,(function(r){if(r){if(!i.fail)return t?t.call(n,r):null;o.currentState=i.fail}else{if(!i.accept)return t?t.call(n):null;o.currentState=i.accept}if(o.currentState===e)return t?t.call(n,r):null;o.runTo(e,t,n,r)}))},r.prototype.addState=function(e,t,n,r){return"function"==typeof t?(r=t,t=null,n=null):"function"==typeof n&&(r=n,n=null),this.currentState||(this.currentState=e),this.states[e]={accept:t,fail:n,fn:r},this},t.exports=r},{}],72:[function(e,t,n){(function(n,r){(function(){var o,i={environment:"nodejs",engine:function(){if(i.isBrowser()&&"undefined"!=typeof navigator)return navigator.userAgent;var e=n.platform+"/"+n.version;return n.env.AWS_EXECUTION_ENV&&(e+=" exec-env/"+n.env.AWS_EXECUTION_ENV),e},userAgent:function(){var t=i.environment,n="aws-sdk-"+t+"/"+e("./core").VERSION;return"nodejs"===t&&(n+=" "+i.engine()),n},uriEscape:function(e){var t=encodeURIComponent(e);return t=(t=t.replace(/[^A-Za-z0-9_.~\-%]+/g,escape)).replace(/[*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))},uriEscapePath:function(e){var t=[];return i.arrayEach(e.split("/"),(function(e){t.push(i.uriEscape(e))})),t.join("/")},urlParse:function(e){return i.url.parse(e)},urlFormat:function(e){return i.url.format(e)},queryStringParse:function(e){return i.querystring.parse(e)},queryParamsToString:function(e){var t=[],n=i.uriEscape,r=Object.keys(e).sort();return i.arrayEach(r,(function(r){var o=e[r],s=n(r),a=s+"=";if(Array.isArray(o)){var c=[];i.arrayEach(o,(function(e){c.push(n(e))})),a=s+"="+c.sort().join("&"+s+"=")}else null!=o&&(a=s+"="+n(o));t.push(a)})),t.join("&")},readFileSync:function(t){return i.isBrowser()?null:e("fs").readFileSync(t,"utf-8")},base64:{encode:function(e){if("number"==typeof e)throw i.error(new Error("Cannot base64 encode number "+e));return null==e?e:i.buffer.toBuffer(e).toString("base64")},decode:function(e){if("number"==typeof e)throw i.error(new Error("Cannot base64 decode number "+e));return null==e?e:i.buffer.toBuffer(e,"base64")}},buffer:{toBuffer:function(e,t){return"function"==typeof i.Buffer.from&&i.Buffer.from!==Uint8Array.from?i.Buffer.from(e,t):new i.Buffer(e,t)},alloc:function(e,t,n){if("number"!=typeof e)throw new Error("size passed to alloc must be a number.");if("function"==typeof i.Buffer.alloc)return i.Buffer.alloc(e,t,n);var r=new i.Buffer(e);return void 0!==t&&"function"==typeof r.fill&&r.fill(t,void 0,void 0,n),r},toStream:function(e){i.Buffer.isBuffer(e)||(e=i.buffer.toBuffer(e));var t=new i.stream.Readable,n=0;return t._read=function(r){if(n>=e.length)return t.push(null);var o=n+r;o>e.length&&(o=e.length),t.push(e.slice(n,o)),n=o},t},concat:function(e){var t,n,r=0,o=0;for(n=0;n>>8^t[255&(n^e.readUInt8(r))];return(-1^n)>>>0},hmac:function(e,t,n,r){return n||(n="binary"),"buffer"===n&&(n=void 0),r||(r="sha256"),"string"==typeof t&&(t=i.buffer.toBuffer(t)),i.crypto.lib.createHmac(r,e).update(t).digest(n)},md5:function(e,t,n){return i.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return i.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,r){var o=i.crypto.createHash(e);n||(n="binary"),"buffer"===n&&(n=void 0),"string"==typeof t&&(t=i.buffer.toBuffer(t));var s=i.arraySliceFn(t),a=i.Buffer.isBuffer(t);if(i.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(a=!0),r&&"object"==typeof t&&"function"==typeof t.on&&!a)t.on("data",(function(e){o.update(e)})),t.on("error",(function(e){r(e)})),t.on("end",(function(){r(null,o.digest(n))}));else{if(!r||!s||a||"undefined"==typeof FileReader){i.isBrowser()&&"object"==typeof t&&!a&&(t=new i.Buffer(new Uint8Array(t)));var c=o.update(t).digest(n);return r&&r(null,c),c}var u=0,l=new FileReader;l.onerror=function(){r(new Error("Failed to read data."))},l.onload=function(){var e=new i.Buffer(new Uint8Array(l.result));o.update(e),u+=e.length,l._continueReading()},l._continueReading=function(){if(u>=t.size)r(null,o.digest(n));else{var e=u+524288;e>t.size&&(e=t.size),l.readAsArrayBuffer(s.call(t,u,e))}},l._continueReading()}},toHex:function(e){for(var t=[],n=0;n=3e5,!1),o.config.isClockSkewed},applyClockOffset:function(e){e&&(o.config.systemClockOffset=e-(new Date).getTime())},extractRequestId:function(e){var t=e.httpResponse.headers["x-amz-request-id"]||e.httpResponse.headers["x-amzn-requestid"];!t&&e.data&&e.data.ResponseMetadata&&(t=e.data.ResponseMetadata.RequestId),t&&(e.requestId=t),e.error&&(e.error.requestId=t)},addPromises:function(e,t){var n=!1;void 0===t&&o&&o.config&&(t=o.config.getPromisesDependency()),void 0===t&&"undefined"!=typeof Promise&&(t=Promise),"function"!=typeof t&&(n=!0),Array.isArray(e)||(e=[e]);for(var r=0;r=0)return a++,void setTimeout(u,o+(e.retryAfter||0))}n(e)},u=function(){var t="";r.handleRequest(e,s,(function(e){e.on("data",(function(e){t+=e.toString()})),e.on("end",(function(){var r=e.statusCode;if(r<300)n(null,t);else{var o=1e3*parseInt(e.headers["retry-after"],10)||0,s=i.error(new Error,{statusCode:r,retryable:r>=500||429===r});o&&s.retryable&&(s.retryAfter=o),c(s)}}))}),c)};o.util.defer(u)},uuid:{v4:function(){return e("uuid").v4()}},convertPayloadToString:function(e){var t=e.request,n=t.operation,r=t.service.api.operations[n].output||{};r.payload&&e.data[r.payload]&&(e.data[r.payload]=e.data[r.payload].toString())},defer:function(e){"object"==typeof n&&"function"==typeof n.nextTick?n.nextTick(e):"function"==typeof r?r(e):setTimeout(e,0)},getRequestPayloadShape:function(e){var t=e.service.api.operations;if(t){var n=(t||{})[e.operation];if(n&&n.input&&n.input.payload)return n.input.members[n.input.payload]}},getProfilesFromSharedConfig:function(e,t){var r={},o={};n.env[i.configOptInEnv]&&(o=e.loadFrom({isConfig:!0,filename:n.env[i.sharedConfigFileEnv]}));var s={};try{s=e.loadFrom({filename:t||n.env[i.configOptInEnv]&&n.env[i.sharedCredentialsFileEnv]})}catch(e){if(!n.env[i.configOptInEnv])throw e}for(var a=0,c=Object.keys(o);a=6},parse:function(e){var t=e.split(":");return{partition:t[1],service:t[2],region:t[3],accountId:t[4],resource:t.slice(5).join(":")}},build:function(e){if(void 0===e.service||void 0===e.region||void 0===e.accountId||void 0===e.resource)throw i.error(new Error("Input ARN object is invalid"));return"arn:"+(e.partition||"aws")+":"+e.service+":"+e.region+":"+e.accountId+":"+e.resource}},defaultProfile:"default",configOptInEnv:"AWS_SDK_LOAD_CONFIG",sharedCredentialsFileEnv:"AWS_SHARED_CREDENTIALS_FILE",sharedConfigFileEnv:"AWS_CONFIG_FILE",imdsDisabledEnv:"AWS_EC2_METADATA_DISABLED"};t.exports=i}).call(this)}).call(this,e("_process"),e("timers").setImmediate)},{"../apis/metadata.json":4,"./core":19,_process:90,fs:80,timers:97,uuid:100}],73:[function(e,t,n){var r=e("../util"),o=e("../model/shape");function i(){}function s(e,t){for(var n=e.getElementsByTagName(t),r=0,o=n.length;r0||r?i.toString():""},t.exports=s},{"../util":72,"./xml-node":77,"./xml-text":78}],75:[function(e,t,n){t.exports={escapeAttribute:function(e){return e.replace(/&/g,"&").replace(/'/g,"'").replace(//g,">").replace(/"/g,""")}}},{}],76:[function(e,t,n){t.exports={escapeElement:function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/\r/g," ").replace(/\n/g," ").replace(/\u0085/g,"…").replace(/\u2028/,"
")}}},{}],77:[function(e,t,n){var r=e("./escape-attribute").escapeAttribute;function o(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}o.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},o.prototype.addChildNode=function(e){return this.children.push(e),this},o.prototype.removeAttribute=function(e){return delete this.attributes[e],this},o.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,o=0,i=Object.keys(n);o"+this.children.map((function(e){return e.toString()})).join("")+"":"/>")},t.exports={XmlNode:o}},{"./escape-attribute":75}],78:[function(e,t,n){var r=e("./escape-element").escapeElement;function o(e){this.value=e}o.prototype.toString=function(){return r(""+this.value)},t.exports={XmlText:o}},{"./escape-element":76}],79:[function(e,t,n){"use strict";n.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=u(e),s=r[0],a=r[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),l=0,p=a>0?s-4:s;for(n=0;n>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},n.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,c=n-o;ac?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var o,i,s=[],a=t;a>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],80:[function(e,t,n){},{}],81:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],82:[function(e,t,o){(function(e){(function(){!function(i){"object"==typeof o&&o&&o.nodeType,"object"==typeof t&&t&&t.nodeType;var s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self;var a,c=2147483647,u=36,l=/^xn--/,p=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=Math.floor,g=String.fromCharCode;function m(e){throw RangeError(h[e])}function v(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function y(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+v((e=e.replace(d,".")).split("."),t).join(".")}function E(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(t+=g((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=g(e)})).join("")}function b(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function T(e,t,n){var r=0;for(e=n?f(e/700):e>>1,e+=f(e/t);e>455;r+=u)e=f(e/35);return f(r+36*e/(e+38))}function C(e){var t,n,r,o,i,s,a,l,p,d,h,g=[],v=e.length,y=0,E=128,b=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r=128&&m("not-basic"),g.push(e.charCodeAt(r));for(o=n>0?n+1:0;o=v&&m("invalid-input"),((l=(h=e.charCodeAt(o++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:u)>=u||l>f((c-y)/s))&&m("overflow"),y+=l*s,!(l<(p=a<=b?1:a>=b+26?26:a-b));a+=u)s>f(c/(d=u-p))&&m("overflow"),s*=d;b=T(y-i,t=g.length+1,0==i),f(y/t)>c-E&&m("overflow"),E+=f(y/t),y%=t,g.splice(y++,0,E)}return S(g)}function I(e){var t,n,r,o,i,s,a,l,p,d,h,v,y,S,C,I=[];for(v=(e=E(e)).length,t=128,n=0,i=72,s=0;s=t&&hf((c-n)/(y=r+1))&&m("overflow"),n+=(a-t)*y,t=a,s=0;sc&&m("overflow"),h==t){for(l=n,p=u;!(l<(d=p<=i?1:p>=i+26?26:p-i));p+=u)C=l-d,S=u-d,I.push(g(b(d+C%S,0))),l=f(C/S);I.push(g(b(l,0))),i=T(n,y,r==o),n=0,++r}++n,++t}return I.join("")}a={version:"1.3.2",ucs2:{decode:E,encode:S},decode:C,encode:I,toASCII:function(e){return y(e,(function(e){return p.test(e)?"xn--"+I(e):e}))},toUnicode:function(e){return y(e,(function(e){return l.test(e)?C(e.slice(4).toLowerCase()):e}))}},void 0===(r=function(){return a}.call(o,n,o,t))||(t.exports=r)}()}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],83:[function(e,t,n){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],84:[function(e,t,r){(function(t,n){(function(){var o=/%[sdj%]/g;r.format=function(e){if(!v(e)){for(var t=[],n=0;n=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),c=r[n];n=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),f(t)?n.showHidden=t:t&&r._extend(n,t),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),l(n,e,n.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function u(e,t){return e}function l(e,t,n){if(e.customInspect&&t&&C(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(n,e);return v(o)||(o=l(e,o,n)),o}var i=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):f(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var s=Object.keys(t),a=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),T(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return p(t);if(0===s.length){if(C(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(E(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(b(t))return e.stylize(Date.prototype.toString.call(t),"date");if(T(t))return p(t)}var u,S="",I=!1,_=["{","}"];return h(t)&&(I=!0,_=["[","]"]),C(t)&&(S=" [Function"+(t.name?": "+t.name:"")+"]"),E(t)&&(S=" "+RegExp.prototype.toString.call(t)),b(t)&&(S=" "+Date.prototype.toUTCString.call(t)),T(t)&&(S=" "+p(t)),0!==s.length||I&&0!=t.length?n<0?E(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=I?function(e,t,n,r,o){for(var i=[],s=0,a=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(u,S,_)):_[0]+S+_[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,r,o,i){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),R(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=g(n)?l(e,c.value,null):l(e,c.value,n-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),y(s)){if(i&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function h(e){return Array.isArray(e)}function f(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function v(e){return"string"==typeof e}function y(e){return void 0===e}function E(e){return S(e)&&"[object RegExp]"===I(e)}function S(e){return"object"==typeof e&&null!==e}function b(e){return S(e)&&"[object Date]"===I(e)}function T(e){return S(e)&&("[object Error]"===I(e)||e instanceof Error)}function C(e){return"function"==typeof e}function I(e){return Object.prototype.toString.call(e)}function _(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(y(i)&&(i=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var n=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else s[e]=function(){};return s[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=h,r.isBoolean=f,r.isNull=g,r.isNullOrUndefined=function(e){return null==e},r.isNumber=m,r.isString=v,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=y,r.isRegExp=E,r.isObject=S,r.isDate=b,r.isError=T,r.isFunction=C,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function w(){var e=new Date,t=[_(e.getHours()),_(e.getMinutes()),_(e.getSeconds())].join(":");return[e.getDate(),A[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){console.log("%s - %s",w(),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this)}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":83,_process:90,inherits:81}],85:[function(e,t,r){(function(t,n){(function(){"use strict";var n=e("base64-js"),o=e("ieee754"),i=e("isarray");function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return B(e).length;default:if(r)return j(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return R(this,t,n);case"latin1":case"binary":return k(this,t,n);case"base64":return _(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function m(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,o);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=n;ia&&(n=a-c),i=n;i>=0;i--){for(var p=!0,d=0;do&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function _(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o239?4:u>223?3:u>191?2:1;if(o+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=p}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);for(var n="",r=0;r0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},c.prototype.compare=function(e,t,n,r,o){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(r,o),l=e.slice(t,n),p=0;po)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return b(this,e,t,n);case"latin1":case"binary":return T(this,e,t,n);case"base64":return C(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function R(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;oo)&&(n=o);for(var i="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,n,r,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function P(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function x(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function M(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,r,i){return i||M(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,i){return i||M(e,0,n,8),o.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)r+=this[e+--t]*o;return r},c.prototype.readUInt8=function(e,t){return t||L(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||L(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||L(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||L(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var r=this[e],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||L(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||L(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||L(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||L(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||L(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||L(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||L(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||D(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function B(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"base64-js":79,buffer:85,ieee754:87,isarray:88}],86:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function i(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,a,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(s(n=this._events[e]))return!1;if(o(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(i(n))for(a=Array.prototype.slice.call(arguments,1),r=(u=n.slice()).length,c=0;c0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!o(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(n=this._events[e]).length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(o(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],87:[function(e,t,n){n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<>1,l=-7,p=n?o-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,u=8*i-o-1,l=(1<>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(a=0,s=l):s+p>=1?(a=(t*c-1)*Math.pow(2,o),s+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,o),s=0));o>=8;e[n+h]=255&a,h+=f,a/=256,o-=8);for(s=s<0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*g}},{}],88:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],89:[function(e,t,n){!function(e){"use strict";function t(e){return null!==e&&"[object Array]"===Object.prototype.toString.call(e)}function n(e){return null!==e&&"[object Object]"===Object.prototype.toString.call(e)}function r(e,o){if(e===o)return!0;if(Object.prototype.toString.call(e)!==Object.prototype.toString.call(o))return!1;if(!0===t(e)){if(e.length!==o.length)return!1;for(var i=0;i",9:"Array"},u="EOF",l="UnquotedIdentifier",p="QuotedIdentifier",d="Rbracket",h="Rparen",f="Comma",g="Colon",m="Rbrace",v="Number",y="Current",E="Expref",S="Pipe",b="Or",T="And",C="EQ",I="GT",_="LT",A="GTE",w="LTE",R="NE",k="Flatten",N="Star",O="Filter",L="Dot",D="Not",P="Lbrace",x="Lbracket",M="Lparen",U="Literal",F={".":L,"*":N,",":f,":":g,"{":P,"}":m,"]":d,"(":M,")":h,"@":y},q={"<":!0,">":!0,"=":!0,"!":!0},j={" ":!0,"\t":!0,"\n":!0};function B(e){return e>="0"&&e<="9"||"-"===e}function V(){}V.prototype={tokenize:function(e){var t,n,r,o,i=[];for(this._current=0;this._current="a"&&o<="z"||o>="A"&&o<="Z"||"_"===o)t=this._current,n=this._consumeUnquotedIdentifier(e),i.push({type:l,value:n,start:t});else if(void 0!==F[e[this._current]])i.push({type:F[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(B(e[this._current]))r=this._consumeNumber(e),i.push(r);else if("["===e[this._current])r=this._consumeLBracket(e),i.push(r);else if('"'===e[this._current])t=this._current,n=this._consumeQuotedIdentifier(e),i.push({type:p,value:n,start:t});else if("'"===e[this._current])t=this._current,n=this._consumeRawStringLiteral(e),i.push({type:U,value:n,start:t});else if("`"===e[this._current]){t=this._current;var s=this._consumeLiteral(e);i.push({type:U,value:s,start:t})}else if(void 0!==q[e[this._current]])i.push(this._consumeOperator(e));else if(void 0!==j[e[this._current]])this._current++;else if("&"===e[this._current])t=this._current,this._current++,"&"===e[this._current]?(this._current++,i.push({type:T,value:"&&",start:t})):i.push({type:E,value:"&",start:t});else{if("|"!==e[this._current]){var a=new Error("Unknown character:"+e[this._current]);throw a.name="LexerError",a}t=this._current,this._current++,"|"===e[this._current]?(this._current++,i.push({type:b,value:"||",start:t})):i.push({type:S,value:"|",start:t})}return i},_consumeUnquotedIdentifier:function(e){var t,n=this._current;for(this._current++;this._current="a"&&t<="z"||t>="A"&&t<="Z"||t>="0"&&t<="9"||"_"===t);)this._current++;return e.slice(n,this._current)},_consumeQuotedIdentifier:function(e){var t=this._current;this._current++;for(var n=e.length;'"'!==e[this._current]&&this._current"===n?"="===e[this._current]?(this._current++,{type:A,value:">=",start:t}):{type:I,value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:C,value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t,n=this._current,r=e.length;"`"!==e[this._current]&&this._current=0)return!0;if(["true","false","null"].indexOf(e)>=0)return!0;if(!("-0123456789".indexOf(e[0])>=0))return!1;try{return JSON.parse(e),!0}catch(e){return!1}}};var W={};function H(){}function z(e){this.runtime=e}function G(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[s]}]},avg:{_func:this._functionAvg,_signature:[{types:[8]}]},ceil:{_func:this._functionCeil,_signature:[{types:[s]}]},contains:{_func:this._functionContains,_signature:[{types:[a,3]},{types:[1]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[a]},{types:[a]}]},floor:{_func:this._functionFloor,_signature:[{types:[s]}]},length:{_func:this._functionLength,_signature:[{types:[a,3,4]}]},map:{_func:this._functionMap,_signature:[{types:[6]},{types:[3]}]},max:{_func:this._functionMax,_signature:[{types:[8,9]}]},merge:{_func:this._functionMerge,_signature:[{types:[4],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[3]},{types:[6]}]},sum:{_func:this._functionSum,_signature:[{types:[8]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[a]},{types:[a]}]},min:{_func:this._functionMin,_signature:[{types:[8,9]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[3]},{types:[6]}]},type:{_func:this._functionType,_signature:[{types:[1]}]},keys:{_func:this._functionKeys,_signature:[{types:[4]}]},values:{_func:this._functionValues,_signature:[{types:[4]}]},sort:{_func:this._functionSort,_signature:[{types:[9,8]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[3]},{types:[6]}]},join:{_func:this._functionJoin,_signature:[{types:[a]},{types:[9]}]},reverse:{_func:this._functionReverse,_signature:[{types:[a,3]}]},to_array:{_func:this._functionToArray,_signature:[{types:[1]}]},to_string:{_func:this._functionToString,_signature:[{types:[1]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[1]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[1],variadic:!0}]}}}W.EOF=0,W.UnquotedIdentifier=0,W.QuotedIdentifier=0,W.Rbracket=0,W.Rparen=0,W.Comma=0,W.Rbrace=0,W.Number=0,W.Current=0,W.Expref=0,W.Pipe=1,W.Or=2,W.And=3,W.EQ=5,W.GT=5,W.LT=5,W.GTE=5,W.LTE=5,W.NE=5,W.Flatten=9,W.Star=20,W.Filter=21,W.Dot=40,W.Not=45,W.Lbrace=50,W.Lbracket=55,W.Lparen=60,H.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if(this._lookahead(0)!==u){var n=this._lookaheadToken(0),r=new Error("Unexpected token type: "+n.type+", value: "+n.value);throw r.name="ParserError",r}return t},_loadTokens:function(e){var t=(new V).tokenize(e);t.push({type:u,value:"",start:e.length}),this.tokens=t},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var n=this.nud(t),r=this._lookahead(0);e=0?this.expression(e):t===x?(this._match(x),this._parseMultiselectList()):t===P?(this._match(P),this._parseMultiselectHash()):void 0},_parseProjectionRHS:function(e){var t;if(W[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===x)t=this.expression(e);else if(this._lookahead(0)===O)t=this.expression(e);else{if(this._lookahead(0)!==L){var n=this._lookaheadToken(0),r=new Error("Sytanx error, unexpected token: "+n.value+"("+n.type+")");throw r.name="ParserError",r}this._match(L),t=this._parseDotRHS(e)}return t},_parseMultiselectList:function(){for(var e=[];this._lookahead(0)!==d;){var t=this.expression(0);if(e.push(t),this._lookahead(0)===f&&(this._match(f),this._lookahead(0)===d))throw new Error("Unexpected token Rbracket")}return this._match(d),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e,t,n,r=[],o=[l,p];;){if(e=this._lookaheadToken(0),o.indexOf(e.type)<0)throw new Error("Expecting an identifier token, got: "+e.type);if(t=e.value,this._advance(),this._match(g),n={type:"KeyValuePair",name:t,value:this.expression(0)},r.push(n),this._lookahead(0)===f)this._match(f);else if(this._lookahead(0)===m){this._match(m);break}}return{type:"MultiSelectHash",children:r}}},z.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,i){var s,a,c,u,l,p,d,h,f;switch(e.type){case"Field":return null!==i&&n(i)?void 0===(p=i[e.name])?null:p:null;case"Subexpression":for(c=this.visit(e.children[0],i),f=1;f0)for(f=b;fT;f+=N)c.push(i[f]);return c;case"Projection":var O=this.visit(e.children[0],i);if(!t(O))return null;for(h=[],f=0;fl;break;case A:c=u>=l;break;case _:c=u=e&&(t=n<0?e-1:e),t}},G.prototype={callFunction:function(e,t){var n=this.functionTable[e];if(void 0===n)throw new Error("Unknown function: "+e+"()");return this._validateArgs(e,t,n._signature),n._func.call(this,t)},_validateArgs:function(e,t,n){var r,o,i,s;if(n[n.length-1].variadic){if(t.length=0;r--)n+=t[r];return n}var o=e[0].slice(0);return o.reverse(),o},_functionAbs:function(e){return Math.abs(e[0])},_functionCeil:function(e){return Math.ceil(e[0])},_functionAvg:function(e){for(var t=0,n=e[0],r=0;r=0},_functionFloor:function(e){return Math.floor(e[0])},_functionLength:function(e){return n(e[0])?Object.keys(e[0]).length:e[0].length},_functionMap:function(e){for(var t=[],n=this._interpreter,r=e[0],o=e[1],i=0;i0){if(this._getTypeName(e[0][0])===s)return Math.max.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;r0){if(this._getTypeName(e[0][0])===s)return Math.min.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;ra?1:sc&&(c=n,t=o[u]);return t},_functionMinBy:function(e){for(var t,n,r=e[1],o=e[0],i=this.createKeyFunction(r,[s,a]),c=1/0,u=0;u1)for(var n=1;n0&&u>c&&(u=c);for(var l=0;l=0?(p=g.substr(0,m),d=g.substr(m+1)):(p=g,d=""),h=decodeURIComponent(p),f=decodeURIComponent(d),r(s,h)?o(s[h])?s[h].push(f):s[h]=[s[h],f]:s[h]=f}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],92:[function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r0&&c>a&&(c=a);for(var u=0;u=0?(l=f.substr(0,g),p=f.substr(g+1)):(l=f,p=""),d=decodeURIComponent(l),h=decodeURIComponent(p),r(i,d)?Array.isArray(i[d])?i[d].push(h):i[d]=[i[d],h]:i[d]=h}return i}},{}],95:[function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,o){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(o){var i=encodeURIComponent(r(o))+n;return Array.isArray(e[o])?e[o].map((function(e){return i+encodeURIComponent(r(e))})).join(t):i+encodeURIComponent(r(e[o]))})).join(t):o?encodeURIComponent(r(o))+n+encodeURIComponent(r(e)):""}},{}],96:[function(e,t,n){arguments[4][93][0].apply(n,arguments)},{"./decode":94,"./encode":95,dup:93}],97:[function(e,t,n){(function(t,r){(function(){var o=e("process/browser.js").nextTick,i=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function u(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new u(i.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new u(i.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n.setImmediate="function"==typeof t?t:function(e){var t=c++,r=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,o((function(){a[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"==typeof r?r:function(e){delete a[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":90,timers:97}],98:[function(e,t,n){var r=e("punycode");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}n.parse=v,n.resolve=function(e,t){return v(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?v(e,!1,!0).resolveObject(t):t},n.format=function(e){return y(e)&&(e=v(e)),e instanceof o?e.format():o.prototype.format.call(e)},n.Url=o;var i=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(a),u=["%","/","?",";","#"].concat(c),l=["/","?","#"],p=/^[a-z0-9A-Z_-]{0,63}$/,d=/^([a-z0-9A-Z_-]{0,63})(.*)$/,h={javascript:!0,"javascript:":!0},f={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=e("querystring");function v(e,t,n){if(e&&E(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}function y(e){return"string"==typeof e}function E(e){return"object"==typeof e&&null!==e}function S(e){return null===e}o.prototype.parse=function(e,t,n){if(!y(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e;o=o.trim();var s=i.exec(o);if(s){var a=(s=s[0]).toLowerCase();this.protocol=a,o=o.substr(s.length)}if(n||s||o.match(/^\/\/[^@\/]+@[^@\/]+/)){var v="//"===o.substr(0,2);!v||s&&f[s]||(o=o.substr(2),this.slashes=!0)}if(!f[s]&&(v||s&&!g[s])){for(var E,S,b=-1,T=0;T127?R+="x":R+=w[k];if(!R.match(p)){var O=_.slice(0,T),L=_.slice(T+1),D=w.match(d);D&&(O.push(D[1]),L.unshift(D[2])),L.length&&(o="/"+L.join(".")+o),this.hostname=O.join(".");break}}}if(this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),!I){var P=this.hostname.split("."),x=[];for(T=0;T0)&&n.host.split("@"))&&(n.auth=b.shift(),n.host=n.hostname=b.shift())),n.search=e.search,n.query=e.query,S(n.pathname)&&S(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!p.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var h=p.slice(-1)[0],m=(n.host||e.host)&&("."===h||".."===h)||""===h,v=0,E=p.length;E>=0;E--)"."==(h=p[E])?p.splice(E,1):".."===h?(p.splice(E,1),v++):v&&(p.splice(E,1),v--);if(!u&&!l)for(;v--;v)p.unshift("..");!u||""===p[0]||p[0]&&"/"===p[0].charAt(0)||p.unshift(""),m&&"/"!==p.join("/").substr(-1)&&p.push("");var b,T=""===p[0]||p[0]&&"/"===p[0].charAt(0);return d&&(n.hostname=n.host=T?"":p.length?p.shift():"",(b=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=b.shift(),n.host=n.hostname=b.shift())),(u=u||n.host&&p.length)&&!T&&p.unshift(""),p.length?n.pathname=p.join("/"):(n.pathname=null,n.path=null),S(n.pathname)&&S(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{punycode:82,querystring:93}],99:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;for(var r=[],o=0;o<256;++o)r[o]=(o+256).toString(16).substr(1);var i=function(e,t){var n=t||0,o=r;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")};n.default=i},{}],100:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"v1",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(n,"v3",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(n,"v4",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(n,"v5",{enumerable:!0,get:function(){return s.default}});var r=a(e("./v1.js")),o=a(e("./v3.js")),i=a(e("./v4.js")),s=a(e("./v5.js"));function a(e){return e&&e.__esModule?e:{default:e}}},{"./v1.js":104,"./v3.js":105,"./v4.js":107,"./v5.js":108}],101:[function(e,t,n){"use strict";function r(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function o(e,t,n,o,i,s){return r((a=r(r(t,e),r(o,s)))<<(c=i)|a>>>32-c,n);var a,c}function i(e,t,n,r,i,s,a){return o(t&n|~t&r,e,t,i,s,a)}function s(e,t,n,r,i,s,a){return o(t&r|n&~r,e,t,i,s,a)}function a(e,t,n,r,i,s,a){return o(t^n^r,e,t,i,s,a)}function c(e,t,n,r,i,s,a){return o(n^(t|~r),e,t,i,s,a)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var u=function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Array(t.length);for(var n=0;n>5]>>>t%32&255,r=parseInt(s.charAt(n>>>4&15)+s.charAt(15&n),16),o.push(r);return o}(function(e,t){var n,o,u,l,p;e[t>>5]|=128<>>9<<4)]=t;var d=1732584193,h=-271733879,f=-1732584194,g=271733878;for(n=0;n>2)-1]=void 0,t=0;t>5]|=(255&e[t/8])<>>32-t}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var i=function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=new Array(i.length);for(var s=0;s>>0;v=m,m=g,g=o(f,30)>>>0,f=h,h=E}n[0]=n[0]+h>>>0,n[1]=n[1]+f>>>0,n[2]=n[2]+g>>>0,n[3]=n[3]+m>>>0,n[4]=n[4]+v>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]};n.default=i},{}],104:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r,o,i=a(e("./rng.js")),s=a(e("./bytesToUuid.js"));function a(e){return e&&e.__esModule?e:{default:e}}var c=0,u=0,l=function(e,t,n){var a=t&&n||0,l=t||[],p=(e=e||{}).node||r,d=void 0!==e.clockseq?e.clockseq:o;if(null==p||null==d){var h=e.random||(e.rng||i.default)();null==p&&(p=r=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==d&&(d=o=16383&(h[6]<<8|h[7]))}var f=void 0!==e.msecs?e.msecs:(new Date).getTime(),g=void 0!==e.nsecs?e.nsecs:u+1,m=f-c+(g-u)/1e4;if(m<0&&void 0===e.clockseq&&(d=d+1&16383),(m<0||f>c)&&void 0===e.nsecs&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=f,u=g,o=d;var v=(1e4*(268435455&(f+=122192928e5))+g)%4294967296;l[a++]=v>>>24&255,l[a++]=v>>>16&255,l[a++]=v>>>8&255,l[a++]=255&v;var y=f/4294967296*1e4&268435455;l[a++]=y>>>8&255,l[a++]=255&y,l[a++]=y>>>24&15|16,l[a++]=y>>>16&255,l[a++]=d>>>8|128,l[a++]=255&d;for(var E=0;E<6;++E)l[a+E]=p[E];return t||(0,s.default)(l)};n.default=l},{"./bytesToUuid.js":99,"./rng.js":102}],105:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=i(e("./v35.js")),o=i(e("./md5.js"));function i(e){return e&&e.__esModule?e:{default:e}}var s=(0,r.default)("v3",48,o.default);n.default=s},{"./md5.js":101,"./v35.js":106}],106:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){var r=function(e,r,i,s){var a=i&&s||0;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=new Array(e.length),n=0;n=0;i--)o[i].Expire{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.ClientMethods=t.makeEnum(["getAgentSnapshot","putAgentState","getAgentStates","getDialableCountryCodes","getRoutingProfileQueues","getAgentPermissions","getAgentConfiguration","updateAgentConfiguration","acceptContact","createOutboundContact","createTaskContact","clearContact","completeContact","destroyContact","rejectContact","notifyContactIssue","updateContactAttributes","createAdditionalConnection","destroyConnection","holdConnection","resumeConnection","toggleActiveConnections","conferenceConnections","sendClientLogs","sendDigits","sendSoftphoneCallReport","sendSoftphoneCallMetrics","getEndpoints","getNewAuthToken","createTransport","muteParticipant","unmuteParticipant","updateMonitorParticipantState"]),t.AgentAppClientMethods={GET_CONTACT:"AgentAppService.Lcms.getContact",DELETE_SPEAKER:"AgentAppService.VoiceId.deleteSpeaker",ENROLL_BY_SESSION:"AgentAppService.VoiceId.enrollBySession",EVALUATE_SESSION:"AgentAppService.VoiceId.evaluateSession",DESCRIBE_SPEAKER:"AgentAppService.VoiceId.describeSpeaker",OPT_OUT_SPEAKER:"AgentAppService.VoiceId.optOutSpeaker",UPDATE_VOICE_ID_DATA:"AgentAppService.Lcms.updateVoiceIdData",DESCRIBE_SESSION:"AgentAppService.VoiceId.describeSession",UPDATE_SESSION:"AgentAppService.VoiceId.updateSession",START_VOICE_ID_SESSION:"AgentAppService.Nasa.startVoiceIdSession",LIST_INTEGRATION_ASSOCIATIONS:"AgentAppService.Acs.listIntegrationAssociations"},t.MasterMethods=t.makeEnum(["becomeMaster","checkMaster"]),t.TaskTemplatesClientMethods=t.makeEnum(["listTaskTemplates","getTaskTemplate","createTemplatedTask","updateContact"]);var n=function(){};n.EMPTY_CALLBACKS={success:function(){},failure:function(){}},n.prototype.call=function(e,r,o){t.assertNotNull(e,"method");var i=r||{},s=o||n.EMPTY_CALLBACKS;this._callImpl(e,i,s)},n.prototype._callImpl=function(e,n,r){throw new t.NotImplementedError};var r=function(){n.call(this)};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype._callImpl=function(e,n,r){if(r&&r.failure){var o=t.sprintf("No such method exists on NULL client: %s",e);r.failure(new t.ValueError(o),{message:o})}};var o=function(e,r,o){n.call(this),this.conduit=e,this.requestEvent=r,this.responseEvent=o,this._requestIdCallbacksMap={},this.conduit.onUpstream(o,t.hitch(this,this._handleResponse))};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype._callImpl=function(e,n,r){var o=t.EventFactory.createRequest(this.requestEvent,e,n);this._requestIdCallbacksMap[o.requestId]=r,this.conduit.sendUpstream(o.event,o)},o.prototype._getCallbacksForRequest=function(e){var t=this._requestIdCallbacksMap[e]||null;return null!=t&&delete this._requestIdCallbacksMap[e],t},o.prototype._handleResponse=function(e){var t=this._getCallbacksForRequest(e.requestId);null!=t&&(e.err&&t.failure?t.failure(e.err,e.data):t.success&&t.success(e.data))};var i=function(e){o.call(this,e,t.EventType.API_REQUEST,t.EventType.API_RESPONSE)};(i.prototype=Object.create(o.prototype)).constructor=i;var s=function(e){o.call(this,e,t.EventType.MASTER_REQUEST,t.EventType.MASTER_RESPONSE)};(s.prototype=Object.create(o.prototype)).constructor=s;var a=function(e,r,o){t.assertNotNull(e,"authCookieName"),t.assertNotNull(r,"authToken"),t.assertNotNull(o,"endpoint"),n.call(this),this.endpointUrl=t.getUrlWithProtocol(o),this.authToken=r,this.authCookieName=e};(a.prototype=Object.create(n.prototype)).constructor=a,a.prototype._callImpl=function(e,n,r){var o=this,i={};i[o.authCookieName]=o.authToken;var s={method:"post",body:JSON.stringify(n||{}),headers:{Accept:"application/json","Content-Type":"application/json","X-Amz-target":e,"X-Amz-Bearer":JSON.stringify(i)}};t.fetch(o.endpointUrl,s).then((function(e){r.success(e)})).catch((function(e){const t=e.body.getReader();let n="";const o=new TextDecoder;t.read().then((function i({done:s,value:a}){if(s){var c=JSON.parse(n);return c.status=e.status,void r.failure(c)}return n+=o.decode(a),t.read().then(i)}))}))};var c=function(e,r,o){t.assertNotNull(e,"authToken"),t.assertNotNull(r,"region"),n.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=r,this.authToken=e;var i=t.getBaseUrl(),s=o||(i.includes(".awsapps.com")?i+"/connect/api":i+"/api"),a=new AWS.Endpoint(s);this.client=new AWS.Connect({endpoint:a})};(c.prototype=Object.create(n.prototype)).constructor=c,c.prototype._callImpl=function(e,n,r){var o=this,i=t.getLog();if(t.contains(this.client,e))n=this._translateParams(e,n),i.trace("AWSClient: --\x3e Calling operation '%s'",e).sendInternalLogToServer(),this.client[e](n).on("build",(function(e){e.httpRequest.headers["X-Amz-Bearer"]=o.authToken})).send((function(n,o){try{if(n){if(n.code===t.CTIExceptions.UNAUTHORIZED_EXCEPTION)r.authFailure();else if(!r.accessDenied||n.code!==t.CTIExceptions.ACCESS_DENIED_EXCEPTION&&403!==n.statusCode){var s={};if(s.type=n.code,s.message=n.message,s.stack=[],n.stack)try{Array.isArray(n.stack)?s.stack=n.stack:"object"==typeof n.stack?s.stack=[JSON.stringify(n.stack)]:"string"==typeof n.stack&&(s.stack=n.stack.split("\n"))}catch{}r.failure(s,o)}else r.accessDenied();i.trace("AWSClient: <-- Operation '%s' failed: %s",e,JSON.stringify(n)).sendInternalLogToServer()}else i.trace("AWSClient: <-- Operation '%s' succeeded.",e).withObject(o).sendInternalLogToServer(),r.success(o)}catch(n){t.getLog().error("Failed to handle AWS API request for method %s",e).withException(n).sendInternalLogToServer()}}));else{var s=t.sprintf("No such method exists on AWS client: %s",e);r.failure(new t.ValueError(s),{message:s})}},c.prototype._requiresAuthenticationParam=function(e){return e!==t.ClientMethods.COMPLETE_CONTACT&&e!==t.ClientMethods.CLEAR_CONTACT&&e!==t.ClientMethods.REJECT_CONTACT&&e!==t.ClientMethods.CREATE_TASK_CONTACT&&e!==t.ClientMethods.UPDATE_MONITOR_PARTICIPANT_STATE},c.prototype._translateParams=function(e,n){switch(e){case t.ClientMethods.UPDATE_AGENT_CONFIGURATION:n.configuration=this._translateAgentConfiguration(n.configuration);break;case t.ClientMethods.SEND_SOFTPHONE_CALL_METRICS:n.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(n.softphoneStreamStatistics);break;case t.ClientMethods.SEND_SOFTPHONE_CALL_REPORT:n.report=this._translateSoftphoneCallReport(n.report)}return this._requiresAuthenticationParam(e)&&(n.authentication={authToken:this.authToken}),n},c.prototype._translateAgentConfiguration=function(e){return{name:e.name,softphoneEnabled:e.softphoneEnabled,softphoneAutoAccept:e.softphoneAutoAccept,extension:e.extension,routingProfile:this._translateRoutingProfile(e.routingProfile),agentPreferences:e.agentPreferences}},c.prototype._translateRoutingProfile=function(e){return{name:e.name,routingProfileARN:e.routingProfileARN,defaultOutboundQueue:this._translateQueue(e.defaultOutboundQueue)}},c.prototype._translateQueue=function(e){return{queueARN:e.queueARN,name:e.name}},c.prototype._translateSoftphoneStreamStatistics=function(e){return e.forEach((function(e){"packetsCount"in e&&(e.packetCount=e.packetsCount,delete e.packetsCount)})),e},c.prototype._translateSoftphoneCallReport=function(e){return"handshakingTimeMillis"in e&&(e.handshakeTimeMillis=e.handshakingTimeMillis,delete e.handshakingTimeMillis),"preTalkingTimeMillis"in e&&(e.preTalkTimeMillis=e.preTalkingTimeMillis,delete e.preTalkingTimeMillis),"handshakingFailure"in e&&(e.handshakeFailure=e.handshakingFailure,delete e.handshakingFailure),"talkingTimeMillis"in e&&(e.talkTimeMillis=e.talkingTimeMillis,delete e.talkingTimeMillis),e.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(e.softphoneStreamStatistics),e};var u=function(e){if(t.assertNotNull(e,"endpoint"),n.call(this),e.includes("/task-templates"))this.endpointUrl=t.getUrlWithProtocol(e);else{var r=new AWS.Endpoint(e),o=e.includes(".awsapps.com")?"/connect":"";this.endpointUrl=t.getUrlWithProtocol(`${r.host}${o}/task-templates/api/ccp`)}};(u.prototype=Object.create(n.prototype)).constructor=u,u.prototype._callImpl=function(e,n,r){t.assertNotNull(e,"method"),t.assertNotNull(n,"params");var o={credentials:"include",method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","x-csrf-token":"csrf"}},i=n.instanceId,s=this.endpointUrl,a=t.TaskTemplatesClientMethods;switch(e){case a.LIST_TASK_TEMPLATES:if(s+=`/proxy/instance/${i}/task/template`,n.queryParams){const e=new URLSearchParams(n.queryParams).toString();e&&(s+=`?${e}`)}break;case a.GET_TASK_TEMPLATE:t.assertNotNull(n.templateParams,"params.templateParams");const r=t.assertNotNull(n.templateParams.id,"params.templateParams.id"),c=n.templateParams.version;s+=`/proxy/instance/${i}/task/template/${r}`,c&&(s+=`?snapshotVersion=${c}`);break;case a.CREATE_TEMPLATED_TASK:s+=`/${e}`,o.body=JSON.stringify(n),o.method="PUT";break;case a.UPDATE_CONTACT:s+=`/${e}`,o.body=JSON.stringify(n),o.method="POST"}t.fetch(s,o).then((function(e){r.success(e)})).catch((function(e){const t=e.body.getReader();let n="";const o=new TextDecoder;t.read().then((function i({done:s,value:a}){if(s){var c=JSON.parse(n);return c.status=e.status,void r.failure(c)}return n+=o.decode(a),t.read().then(i)}))}))},t.ClientBase=n,t.NullClient=r,t.UpstreamConduitClient=i,t.UpstreamConduitMasterClient=s,t.AWSClient=c,t.AgentAppClient=a,t.TaskTemplatesClient=u}()},895:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.core={},t.core.initialized=!1,t.version="2.4.2",t.DEFAULT_BATCH_SIZE=500;var n="Amazon Connect CCP",r="https://{alias}.awsapps.com/auth/?client_id={client_id}&redirect_uri={redirect}",o="06919f4fd8ed324e",i="/auth/authorize",s="/connect/auth/authorize",a="IframeRefreshAttempts",c="IframeInitializationSuccess";t.numberOfConnectedCCPs=0,t.numberOfConnectedCCPsInThisTab=0,t.core.MAX_AUTHORIZE_RETRY_COUNT_FOR_SESSION=3,t.core.MAX_CTI_AUTH_RETRY_COUNT=10,t.core.ctiAuthRetryCount=0,t.core.authorizeTimeoutId=null,t.core.ctiTimeoutId=null,t.SessionStorageKeys=t.makeEnum(["tab_id","authorize_retry_count"]);var u=function(){let n=`SoftphoneParamsStorage::${e.location.origin}`;return{set:function(r){try{r&&e.localStorage.setItem(n,JSON.stringify(r))}catch(e){t.getLog().error("SoftphoneParamsStorage:: Failed to set softphone params to local storage!").withException(e).sendInternalLogToServer()}},get:function(){try{let t=e.localStorage.getItem(n);return t&&JSON.parse(t)}catch(e){t.getLog().error("SoftphoneParamsStorage:: Failed to get softphone params from local storage!").withException(e).sendInternalLogToServer()}return null},clean:function(){e.localStorage.removeItem(n)}}}();function l(e){var t=e.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/gi);return t.length?t[0]:""}t.core.checkNotInitialized=function(){t.core.initialized&&t.getLog().warn("Connect core already initialized, only needs to be initialized once.").sendInternalLogToServer()},t.core.init=function(e){t.core.eventBus=new t.EventBus,t.core.agentDataProvider=new g(t.core.getEventBus()),t.core.initClient(e),t.core.initAgentAppClient(e),t.core.initTaskTemplatesClient(e),t.core.initialized=!0},t.core.initClient=function(e){t.assertNotNull(e,"params");var n=t.assertNotNull(e.authToken,"params.authToken"),r=t.assertNotNull(e.region,"params.region"),o=e.endpoint||null;t.core.client=new t.AWSClient(n,r,o)},t.core.initAgentAppClient=function(e){t.assertNotNull(e,"params");var n=t.assertNotNull(e.authToken,"params.authToken"),r=t.assertNotNull(e.authCookieName,"params.authCookieName"),o=t.assertNotNull(e.agentAppEndpoint,"params.agentAppEndpoint");t.core.agentAppClient=new t.AgentAppClient(r,n,o)},t.core.initTaskTemplatesClient=function(e){t.assertNotNull(e,"params");var n=e.taskTemplatesEndpoint||e.endpoint;t.assertNotNull(n,"taskTemplatesEndpoint"),t.core.taskTemplatesClient=new t.TaskTemplatesClient(n)},t.core.terminate=function(){t.core.client=new t.NullClient,t.core.agentAppClient=new t.NullClient,t.core.taskTemplatesClient=new t.NullClient,t.core.masterClient=new t.NullClient;var e=t.core.getEventBus();e&&e.unsubscribeAll(),t.core.bus=new t.EventBus,t.core.agentDataProvider=null,t.core.softphoneManager=null,t.core.upstream=null,t.core.keepaliveManager=null,t.agent.initialized=!1,t.core.initialized=!1},t.core.softphoneUserMediaStream=null,t.core.getSoftphoneUserMediaStream=function(){return t.core.softphoneUserMediaStream},t.core.setSoftphoneUserMediaStream=function(e){t.core.softphoneUserMediaStream=e},t.core.initRingtoneEngines=function(e){t.assertNotNull(e,"params");var n=function(e){t.assertNotNull(e,"ringtoneSettings"),t.assertNotNull(e.voice,"ringtoneSettings.voice"),t.assertTrue(e.voice.ringtoneUrl||e.voice.disabled,"ringtoneSettings.voice.ringtoneUrl must be provided or ringtoneSettings.voice.disabled must be true"),t.assertNotNull(e.queue_callback,"ringtoneSettings.queue_callback"),t.assertTrue(e.queue_callback.ringtoneUrl||e.queue_callback.disabled,"ringtoneSettings.voice.ringtoneUrl must be provided or ringtoneSettings.queue_callback.disabled must be true"),t.core.ringtoneEngines={},t.agent((function(n){n.onRefresh((function(){t.ifMaster(t.MasterTopics.RINGTONE,(function(){e.voice.disabled||t.core.ringtoneEngines.voice||(t.core.ringtoneEngines.voice=new t.VoiceRingtoneEngine(e.voice),t.getLog().info("VoiceRingtoneEngine initialized.").sendInternalLogToServer()),e.chat.disabled||t.core.ringtoneEngines.chat||(t.core.ringtoneEngines.chat=new t.ChatRingtoneEngine(e.chat),t.getLog().info("ChatRingtoneEngine initialized.").sendInternalLogToServer()),e.task.disabled||t.core.ringtoneEngines.task||(t.core.ringtoneEngines.task=new t.TaskRingtoneEngine(e.task),t.getLog().info("TaskRingtoneEngine initialized.").sendInternalLogToServer()),e.queue_callback.disabled||t.core.ringtoneEngines.queue_callback||(t.core.ringtoneEngines.queue_callback=new t.QueueCallbackRingtoneEngine(e.queue_callback),t.getLog().info("QueueCallbackRingtoneEngine initialized.").sendInternalLogToServer())}))}))})),p()},r=function(e,n){e.ringtone=e.ringtone||{},e.ringtone.voice=e.ringtone.voice||{},e.ringtone.queue_callback=e.ringtone.queue_callback||{},e.ringtone.chat=e.ringtone.chat||{disabled:!0},e.ringtone.task=e.ringtone.task||{disabled:!0},n.softphone&&(n.softphone.disableRingtone&&(e.ringtone.voice.disabled=!0,e.ringtone.queue_callback.disabled=!0),n.softphone.ringtoneUrl&&(e.ringtone.voice.ringtoneUrl=n.softphone.ringtoneUrl,e.ringtone.queue_callback.ringtoneUrl=n.softphone.ringtoneUrl)),n.chat&&(n.chat.disableRingtone&&(e.ringtone.chat.disabled=!0),n.chat.ringtoneUrl&&(e.ringtone.chat.ringtoneUrl=n.chat.ringtoneUrl)),n.ringtone&&(e.ringtone.voice=t.merge(e.ringtone.voice,n.ringtone.voice||{}),e.ringtone.queue_callback=t.merge(e.ringtone.queue_callback,n.ringtone.voice||{}),e.ringtone.chat=t.merge(e.ringtone.chat,n.ringtone.chat||{}))};r(e,e),t.isFramed()?t.core.getEventBus().subscribe(t.EventType.CONFIGURE,(function(t){this.unsubscribe(),r(e,t),n(e.ringtone)})):n(e.ringtone)};var p=function(){t.core.getEventBus().subscribe(t.ConfigurationEvents.SET_RINGER_DEVICE,d)},d=function(e){if(0!==t.keys(t.core.ringtoneEngines).length&&e&&e.deviceId){var n=e.deviceId;for(var r in t.core.ringtoneEngines)t.core.ringtoneEngines[r].setOutputDevice(n);t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.RINGER_DEVICE_CHANGED,data:{deviceId:n}})}};t.core.initSoftphoneManager=function(n){var r=n||{};t.getLog().info("[Softphone Manager] initSoftphoneManager started").sendInternalLogToServer();var o=function(e){var n=t.merge(r.softphone||{},e);t.getLog().info("[Softphone Manager] competeForMasterOnAgentUpdate executed").sendInternalLogToServer(),t.agent((function(e){e.getChannelConcurrency(t.ChannelType.VOICE)&&e.onRefresh((function(){var r=this;t.getLog().info("[Softphone Manager] agent refresh handler executed").sendInternalLogToServer(),t.ifMaster(t.MasterTopics.SOFTPHONE,(function(){t.getLog().info("[Softphone Manager] confirmed as softphone master topic").sendInternalLogToServer(),!t.core.softphoneManager&&e.isSoftphoneEnabled()&&(t.becomeMaster(t.MasterTopics.SEND_LOGS),t.core.softphoneManager=new t.SoftphoneManager(n),r.unsubscribe())}))}))}))};if(t.isFramed()&&t.isCCP()){let n;t.core.getEventBus().subscribe(t.EventType.CONFIGURE,(function(r){e.clearTimeout(n),t.getLog().info("[Softphone Manager] Configure event handler executed").sendInternalLogToServer(),u.set(r.softphone),r.softphone&&r.softphone.allowFramedSoftphone&&(this.unsubscribe(),o(r.softphone)),i(r.softphone)}));let r=u.get();r&&t.core.getUpstream().onUpstream(t.EventType.ACKNOWLEDGE,(function(s){s&&s.id&&(t.getLog().info("[Softphone Manager] Embedded CCP is refreshed successfully and waiting for configure Message handler to execute").sendInternalLogToServer(),this.unsubscribe(),n=e.setTimeout((()=>{t.getLog().info("[Softphone Manager] Embedded CCP is refreshed without configure message handler execution").sendInternalLogToServer(),t.publishMetric({name:"EmbeddedCCPRefreshedWithoutInitCCP",data:{count:1}}),i(r),r.allowFramedSoftphone&&(t.getLog().info("[Softphone Manager] Embedded CCP is refreshed & Initializing competeForMasterOnAgentUpdate (Softphone manager) from localStorage softphone params").sendInternalLogToServer(),o(r))}),100))}))}else o(r),i(r);function i(e){var n=t.merge(r.softphone||{},e);t.core.softphoneParams=n,t.isFirefoxBrowser()&&(t.core.getUpstream().onUpstream(t.EventType.MASTER_RESPONSE,(function(e){if(e.data&&e.data.topic===t.MasterTopics.SOFTPHONE&&e.data.takeOver&&e.data.masterId!==t.core.portStreamId){t.core.softphoneManager&&(t.core.softphoneManager.onInitContactSub.unsubscribe(),delete t.core.softphoneManager);var n=t.core.getSoftphoneUserMediaStream();n&&(n.getTracks().forEach((function(e){e.stop()})),t.core.setSoftphoneUserMediaStream(null))}})),t.core.getEventBus().subscribe(t.ConnectionEvents.READY_TO_START_SESSION,(function(){t.ifMaster(t.MasterTopics.SOFTPHONE,(function(){t.core.softphoneManager&&t.core.softphoneManager.startSession()}),(function(){t.becomeMaster(t.MasterTopics.SOFTPHONE,(function(){t.agent((function(e){!t.core.softphoneManager&&e.isSoftphoneEnabled()&&(t.becomeMaster(t.MasterTopics.SEND_LOGS),t.core.softphoneManager=new t.SoftphoneManager(n),t.core.softphoneManager.startSession())}))}))}))})),t.contact((function(e){t.agent((function(n){e.onRefresh((function(e){if(t.hasOtherConnectedCCPs()&&"visible"===document.visibilityState&&(e.getStatus().type===t.ContactStatusType.CONNECTING||e.getStatus().type===t.ContactStatusType.INCOMING)){var r=e.isSoftphoneCall()&&!e.isInbound(),o=e.isSoftphoneCall()&&n.getConfiguration().softphoneAutoAccept,i=e.getType()===t.ContactType.QUEUE_CALLBACK;(r||o||i)&&t.core.triggerReadyToStartSessionEvent()}}))}))})))}t.agent((function(e){e.isSoftphoneEnabled()&&e.getChannelConcurrency(t.ChannelType.VOICE)&&t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.MUTE})}))},t.core.triggerReadyToStartSessionEvent=function(){var e=t.core.softphoneParams&&t.core.softphoneParams.allowFramedSoftphone;t.isCCP()?e?t.core.getEventBus().trigger(t.ConnectionEvents.READY_TO_START_SESSION):t.isFramed()?t.core.getUpstream().sendDownstream(t.ConnectionEvents.READY_TO_START_SESSION):t.core.getEventBus().trigger(t.ConnectionEvents.READY_TO_START_SESSION):e?t.core.getUpstream().sendUpstream(t.ConnectionEvents.READY_TO_START_SESSION):t.core.getEventBus().trigger(t.ConnectionEvents.READY_TO_START_SESSION)},t.core.initPageOptions=function(e){if(t.assertNotNull(e,"params"),t.isFramed()){var n=t.core.getEventBus();n.subscribe(t.EventType.CONFIGURE,(function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.CONFIGURE,data:e})})),n.subscribe(t.EventType.MEDIA_DEVICE_REQUEST,(function(){function e(e){t.core.getUpstream().sendDownstream(t.EventType.MEDIA_DEVICE_RESPONSE,e)}navigator&&navigator.mediaDevices?navigator.mediaDevices.enumerateDevices().then((function(t){devices=t||[],devices=devices.map((function(e){return e.toJSON()})),e(devices)})).catch((function(t){e({error:t.message})})):e({error:"No navigator or navigator.mediaDevices object found"})}))}},t.core.getFrameMediaDevices=function(e){var n=null,r=e||1e3,o=new Promise((function(e,t){setTimeout((function(){t(new Error("Timeout exceeded"))}),r)})),i=new Promise((function(e,r){if(t.isFramed()||t.isCCP())navigator&&navigator.mediaDevices?navigator.mediaDevices.enumerateDevices().then((function(t){devices=t||[],devices=devices.map((function(e){return e.toJSON()})),e(devices)})):r(new Error("No navigator or navigator.mediaDevices object found"));else{var o=t.core.getEventBus();n=o.subscribe(t.EventType.MEDIA_DEVICE_RESPONSE,(function(t){t.error?r(new Error(t.error)):e(t)})),t.core.getUpstream().sendUpstream(t.EventType.MEDIA_DEVICE_REQUEST)}}));return Promise.race([i,o]).finally((function(){n&&n.unsubscribe()}))},t.core.authorize=function(e){var n=e;return n||(n=t.core.isLegacyDomain()?s:i),t.fetch(n,{credentials:"include"},2e3,5)},t.core.verifyDomainAccess=function(e,n){if(t.getLog().warn("This API will be deprecated in the next major version release"),!t.isFramed())return Promise.resolve();var r={headers:{"X-Amz-Bearer":e}},o=null;return o=n||(t.core.isLegacyDomain()?"/connect/whitelisted-origins":"/whitelisted-origins"),t.fetch(o,r,2e3,5).then((function(e){var t=l(window.document.referrer);return e.whitelistedOrigins.some((function(e){return t===l(e)}))?Promise.resolve():Promise.reject()}))},t.core.isLegacyDomain=function(e){return(e=e||window.location.href).includes(".awsapps.com")},t.core.initSharedWorker=function(n){if(t.core.checkNotInitialized(),!t.core.initialized){t.assertNotNull(n,"params");var r=t.assertNotNull(n.sharedWorkerUrl,"params.sharedWorkerUrl"),o=t.assertNotNull(n.authToken,"params.authToken"),a=t.assertNotNull(n.refreshToken,"params.refreshToken"),c=t.assertNotNull(n.authTokenExpiration,"params.authTokenExpiration"),u=t.assertNotNull(n.region,"params.region"),l=n.endpoint||null,p=n.authorizeEndpoint;p||(p=t.core.isLegacyDomain()?s:i);var d=n.agentAppEndpoint||null,h=n.taskTemplatesEndpoint||null,m=n.authCookieName||null;try{t.core.eventBus=new t.EventBus({logEvents:!0}),t.core.agentDataProvider=new g(t.core.getEventBus()),t.core.mediaFactory=new t.MediaFactory(n);var v=new SharedWorker(r,"ConnectSharedWorker"),y=new t.Conduit("ConnectSharedWorkerConduit",new t.PortStream(v.port),new t.WindowIOStream(window,parent));t.core.upstream=y,t.core.webSocketProvider=new f,e.onunload=function(){y.sendUpstream(t.EventType.CLOSE),v.port.close()},t.getLog().scheduleUpstreamLogPush(y),t.getLog().scheduleDownstreamClientSideLogsPush(),y.onAllUpstream(t.core.getEventBus().bridge()),y.onAllUpstream(y.passDownstream()),t.isFramed()&&(y.onAllDownstream(t.core.getEventBus().bridge()),y.onAllDownstream(y.passUpstream())),y.sendUpstream(t.EventType.CONFIGURE,{authToken:o,authTokenExpiration:c,endpoint:l,refreshToken:a,region:u,authorizeEndpoint:p,agentAppEndpoint:d,taskTemplatesEndpoint:h,authCookieName:m,longPollingOptions:n.longPollingOptions||void 0}),y.onUpstream(t.EventType.ACKNOWLEDGE,(function(e){t.getLog().info("Acknowledged by the ConnectSharedWorker!").sendInternalLogToServer(),t.core.initialized=!0,t.core._setTabId(),t.core.portStreamId=e.id,this.unsubscribe()})),y.onUpstream(t.EventType.LOG,(function(e){e.loggerId!==t.getLog().getLoggerId()&&t.getLog().addLogEntry(t.LogEntry.fromObject(e))})),y.onUpstream(t.EventType.SERVER_BOUND_INTERNAL_LOG,(function(e){t.getLog().sendInternalLogEntryToServer(t.LogEntry.fromObject(e))})),y.onDownstream(t.EventType.SERVER_BOUND_INTERNAL_LOG,(function(e){t.isFramed()&&Array.isArray(e)&&e.forEach((function(e){t.getLog().sendInternalLogEntryToServer(t.LogEntry.fromObject(e))}))})),y.onDownstream(t.EventType.LOG,(function(e){t.isFramed()&&e.loggerId!==t.getLog().getLoggerId()&&t.getLog().addLogEntry(t.LogEntry.fromObject(e))})),t.core.onAuthFail(t.hitch(t.core,t.core._handleAuthFail,n.loginEndpoint||null,p)),t.core.onAuthorizeSuccess(t.hitch(t.core,t.core._handleAuthorizeSuccess)),t.getLog().info("User Agent: "+navigator.userAgent).sendInternalLogToServer(),t.getLog().info("isCCPv2: "+!0).sendInternalLogToServer(),t.getLog().info("isFramed: "+t.isFramed()).sendInternalLogToServer(),t.core.upstream.onDownstream(t.EventType.OUTER_CONTEXT_INFO,(function(e){var n=e.streamsVersion;t.getLog().info("StreamsJS Version: "+n).sendInternalLogToServer()})),y.onUpstream(t.EventType.UPDATE_CONNECTED_CCPS,(function(e){t.getLog().info("Number of connected CCPs updated: "+e.length).sendInternalLogToServer(),t.numberOfConnectedCCPs=e.length,e[t.core.tabId]&&!isNaN(e[t.core.tabId].length)&&t.numberOfConnectedCCPsInThisTab!==e[t.core.tabId].length&&(t.numberOfConnectedCCPsInThisTab=e[t.core.tabId].length,t.numberOfConnectedCCPsInThisTab>1&&t.getLog().warn("There are "+t.numberOfConnectedCCPsInThisTab+" connected CCPs in this tab. Please adjust your implementation to avoid complications. If you are embedding CCP, please do so exclusively with initCCP. InitCCP will not let you embed more than one CCP.").sendInternalLogToServer(),t.publishMetric({name:"ConnectedCCPSingleTabCount",data:{count:t.numberOfConnectedCCPsInThisTab}})),e.tabId&&e.streamsTabsAcrossBrowser&&t.ifMaster(t.MasterTopics.METRICS,(()=>t.agent((()=>t.publishMetric({name:"CCPTabsAcrossBrowserCount",data:{tabId:e.tabId,count:e.streamsTabsAcrossBrowser}})))))})),t.core.client=new t.UpstreamConduitClient(y),t.core.masterClient=new t.UpstreamConduitMasterClient(y),t.core.getEventBus().subscribe(t.EventType.TERMINATE,y.passUpstream()),t.core.getEventBus().subscribe(t.EventType.TERMINATED,(function(){window.location.reload(!0)})),v.port.start(),y.onUpstream(t.VoiceIdEvents.UPDATE_DOMAIN_ID,(function(e){e&&e.domainId&&(t.core.voiceIdDomainId=e.domainId)})),t.agent((function(){(new t.VoiceId).getDomainId().then((function(e){t.getLog().info("voiceId domainId successfully fetched at agent initialization: "+e).sendInternalLogToServer()})).catch((function(e){t.getLog().info("voiceId domainId not fetched at agent initialization").withObject({err:e}).sendInternalLogToServer()}))})),t.core.getNotificationManager().requestPermission()}catch(e){t.getLog().error("Failed to initialize the API shared worker, we're dead!").withException(e).sendInternalLogToServer()}}},t.core._setTabId=function(){try{t.core.tabId=window.sessionStorage.getItem(t.SessionStorageKeys.TAB_ID),t.core.tabId||(t.core.tabId=t.randomId(),window.sessionStorage.setItem(t.SessionStorageKeys.TAB_ID,t.core.tabId)),t.core.upstream.sendUpstream(t.EventType.TAB_ID,{tabId:t.core.tabId})}catch(e){t.getLog().error("[Tab Id] There was an issue setting the tab Id").withException(e).sendInternalLogToServer()}},t.core.initCCP=function(n,i){if(t.core.checkNotInitialized(),!t.core.initialized){t.getLog().info("Iframe initialization started").sendInternalLogToServer();var s=Date.now();try{if(t.core._getCCPIframe())return void t.getLog().error("Attempted to call initCCP when an iframe generated by initCCP already exists").sendInternalLogToServer()}catch(e){t.getLog().error("Error while checking if initCCP has already been called").withException(e).sendInternalLogToServer()}var l={};"string"==typeof i?l.ccpUrl=i:l=i,t.assertNotNull(n,"containerDiv"),t.assertNotNull(l.ccpUrl,"params.ccpUrl"),u.clean();var p=t.core._createCCPIframe(n,l);t.core.eventBus=new t.EventBus({logEvents:!1}),t.core.agentDataProvider=new g(t.core.getEventBus()),t.core.mediaFactory=new t.MediaFactory(l);var d=new t.IFrameConduit(l.ccpUrl,window,p);t.core._sendIframeStyleDataUpstreamAfterReasonableWaitTime(p,d),t.core.upstream=d,t.core.webSocketProvider=new f,d.onAllUpstream(t.core.getEventBus().bridge()),t.core.keepaliveManager=new h(d,t.core.getEventBus(),l.ccpSynTimeout||1e3,l.ccpAckTimeout||3e3),t.core.iframeRefreshTimeout=null,t.core.ccpLoadTimeoutInstance=e.setTimeout((function(){t.core.ccpLoadTimeoutInstance=null,t.core.getEventBus().trigger(t.EventType.ACK_TIMEOUT),t.getLog().info("CCP LoadTimeout triggered").sendInternalLogToServer()}),l.ccpLoadTimeout||5e3),t.getLog().scheduleUpstreamOuterContextCCPLogsPush(d),t.getLog().scheduleUpstreamOuterContextCCPserverBoundLogsPush(d),d.onUpstream(t.EventType.ACKNOWLEDGE,(function(n){if(t.getLog().info("Acknowledged by the CCP!").sendInternalLogToServer(),t.core.client=new t.UpstreamConduitClient(d),t.core.masterClient=new t.UpstreamConduitMasterClient(d),t.core.portStreamId=n.id,(l.softphone||l.chat||l.pageOptions||l.shouldAddNamespaceToLogs)&&d.sendUpstream(t.EventType.CONFIGURE,{softphone:l.softphone,chat:l.chat,pageOptions:l.pageOptions,shouldAddNamespaceToLogs:l.shouldAddNamespaceToLogs}),t.core.ccpLoadTimeoutInstance&&(e.clearTimeout(t.core.ccpLoadTimeoutInstance),t.core.ccpLoadTimeoutInstance=null),d.sendUpstream(t.EventType.OUTER_CONTEXT_INFO,{streamsVersion:t.version}),t.core.keepaliveManager.start(),this.unsubscribe(),t.core.initialized=!0,t.core.getEventBus().trigger(t.EventType.INIT),s){var r=Date.now()-s,o=t.core.iframeRefreshAttempt||0;t.getLog().info("Iframe initialization succeeded").sendInternalLogToServer(),t.getLog().info(`Iframe initialization time ${r}`).sendInternalLogToServer(),t.getLog().info(`Iframe refresh attempts ${o}`).sendInternalLogToServer(),setTimeout((()=>{t.publishMetric({name:a,data:{count:o}}),t.publishMetric({name:c,data:{count:1}}),t.publishMetric({name:"IframeInitializationTime",data:{count:r}}),s=null}),1e3)}})),d.onUpstream(t.EventType.LOG,(function(e){e.loggerId!==t.getLog().getLoggerId()&&t.getLog().addLogEntry(t.LogEntry.fromObject(e))})),t.core.getEventBus().subscribe(t.EventType.ACK_TIMEOUT,(function(){if(!1!==l.loginPopup)try{var i=function(n){var i="https://lily.us-east-1.amazonaws.com/taw/auth/code";return t.assertNotNull(i),n.loginUrl?n.loginUrl:n.alias?(log.warn("The `alias` param is deprecated and should not be expected to function properly. Please use `ccpUrl` or `loginUrl`. See https://github.com/amazon-connect/amazon-connect-streams/blob/master/README.md#connectcoreinitccp for valid parameters."),r.replace("{alias}",n.alias).replace("{client_id}",o).replace("{redirect}",e.encodeURIComponent(i))):n.ccpUrl}(l);t.getLog().warn("ACK_TIMEOUT occurred, attempting to pop the login page if not already open.").sendInternalLogToServer(),l.loginUrl&&t.core.getPopupManager().clear(t.MasterTopics.LOGIN_POPUP),t.core.loginWindow=t.core.getPopupManager().open(i,t.MasterTopics.LOGIN_POPUP,l.loginOptions)}catch(e){t.getLog().error("ACK_TIMEOUT occurred but we are unable to open the login popup.").withException(e).sendInternalLogToServer()}if(null==t.core.iframeRefreshTimeout)try{d.onUpstream(t.EventType.ACKNOWLEDGE,(function(){this.unsubscribe(),e.clearTimeout(t.core.iframeRefreshTimeout),t.core.iframeRefreshTimeout=null,t.core.getPopupManager().clear(t.MasterTopics.LOGIN_POPUP),(l.loginPopupAutoClose||l.loginOptions&&l.loginOptions.autoClose)&&t.core.loginWindow&&(t.core.loginWindow.close(),t.core.loginWindow=null)})),t.core._refreshIframeOnTimeout(l,n)}catch(e){t.getLog().error("Error occurred while refreshing iframe").withException(e).sendInternalLogToServer()}})),l.onViewContact&&t.core.onViewContact(l.onViewContact),d.onUpstream(t.EventType.UPDATE_CONNECTED_CCPS,(function(e){t.numberOfConnectedCCPs=e.length})),d.onUpstream(t.VoiceIdEvents.UPDATE_DOMAIN_ID,(function(e){e&&e.domainId&&(t.core.voiceIdDomainId=e.domainId)})),t.core.getEventBus().subscribe(t.EventType.IFRAME_RETRIES_EXHAUSTED,(function(){if(s){var e=t.core.iframeRefreshAttempt-1;t.getLog().info("Iframe initialization failed").sendInternalLogToServer(),t.getLog().info("Time after iframe initialization started "+(Date.now()-s)).sendInternalLogToServer(),t.getLog().info(`Iframe refresh attempts ${e}`).sendInternalLogToServer(),t.publishMetric({name:a,data:{count:e}}),t.publishMetric({name:c,data:{count:0}}),s=null}})),t.core.softphoneParams=l.softphone}},t.core.onIframeRetriesExhausted=function(e){t.core.getEventBus().subscribe(t.EventType.IFRAME_RETRIES_EXHAUSTED,e)},t.core._refreshIframeOnTimeout=function(n,r){t.assertNotNull(n,"initCCPParams"),t.assertNotNull(r,"containerDiv");var o=((n.disasterRecoveryOn?1e4:5e3)+AWS.util.calculateRetryDelay(t.core.iframeRefreshAttempt-1||0,{base:2e3}))*Math.ceil((t.core.iframeRefreshAttempt||0)/6);e.clearTimeout(t.core.iframeRefreshTimeout),t.core.iframeRefreshTimeout=e.setTimeout((function(){if(t.core.iframeRefreshAttempt=(t.core.iframeRefreshAttempt||0)+1,t.core.iframeRefreshAttempt<=6){try{var o=t.core._getCCPIframe();o&&o.parentNode.removeChild(o);var i=t.core._createCCPIframe(r,n);t.core.upstream.upstream.output=i.contentWindow,t.core._sendIframeStyleDataUpstreamAfterReasonableWaitTime(i,t.core.upstream)}catch(e){t.getLog().error("Error while checking for, and recreating, the CCP IFrame").withException(e).sendInternalLogToServer()}t.core._refreshIframeOnTimeout(n,r)}else t.core.getEventBus().trigger(t.EventType.IFRAME_RETRIES_EXHAUSTED),e.clearTimeout(t.core.iframeRefreshTimeout)}),o)},t.core._getCCPIframe=function(){for(var e of window.document.getElementsByTagName("iframe"))if(e.name===n)return e;return null},t.core._createCCPIframe=function(e,r){t.assertNotNull(r,"initCCPParams"),t.assertNotNull(e,"containerDiv");var o=document.createElement("iframe");return o.src=r.ccpUrl,o.allow="microphone; autoplay; clipboard-write",o.style=r.style||"width: 100%; height: 100%",o.title=r.iframeTitle||n,o.name=n,e.appendChild(o),o},t.core._sendIframeStyleDataUpstreamAfterReasonableWaitTime=function(e,n){t.assertNotNull(e,"iframe"),t.assertNotNull(n,"conduit"),setTimeout((function(){var r={display:window.getComputedStyle(e,null).display,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,clientRectsLength:e.getClientRects().length};n.sendUpstream(t.EventType.IFRAME_STYLE,r)}),1e4)};var h=function(e,t,n,r){this.conduit=e,this.eventBus=t,this.synTimeout=n,this.ackTimeout=r,this.ackTimer=null,this.synTimer=null,this.ackSub=null};h.prototype.start=function(){var n=this;this.conduit.sendUpstream(t.EventType.SYNCHRONIZE),this.ackSub=this.conduit.onUpstream(t.EventType.ACKNOWLEDGE,(function(){this.unsubscribe(),e.clearTimeout(n.ackTimer),n._deferStart()})),this.ackTimer=e.setTimeout((function(){n.ackSub.unsubscribe(),n.eventBus.trigger(t.EventType.ACK_TIMEOUT),n._deferStart()}),this.ackTimeout)},h.prototype._deferStart=function(){this.synTimer=e.setTimeout(t.hitch(this,this.start),this.synTimeout)},h.prototype.deferStart=function(){null==this.synTimer&&(this.synTimer=e.setTimeout(t.hitch(this,this.start),this.synTimeout))};var f=function(){var e={initFailure:new Set,subscriptionUpdate:new Set,subscriptionFailure:new Set,topic:new Map,allMessage:new Set,connectionGain:new Set,connectionLost:new Set,connectionOpen:new Set,connectionClose:new Set},n=function(e,t){e.forEach((function(e){e(t)}))};t.core.getUpstream().onUpstream(t.WebSocketEvents.INIT_FAILURE,(function(){n(e.initFailure)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_OPEN,(function(t){n(e.connectionOpen,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_CLOSE,(function(t){n(e.connectionClose,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_GAIN,(function(){n(e.connectionGain)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.CONNECTION_LOST,(function(t){n(e.connectionLost,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.SUBSCRIPTION_UPDATE,(function(t){n(e.subscriptionUpdate,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.SUBSCRIPTION_FAILURE,(function(t){n(e.subscriptionFailure,t)})),t.core.getUpstream().onUpstream(t.WebSocketEvents.ALL_MESSAGE,(function(t){n(e.allMessage,t),e.topic.has(t.topic)&&n(e.topic.get(t.topic),t)})),this.sendMessage=function(e){t.core.getUpstream().sendUpstream(t.WebSocketEvents.SEND,e)},this.onInitFailure=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.initFailure.add(n),function(){return e.initFailure.delete(n)}},this.onConnectionOpen=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionOpen.add(n),function(){return e.connectionOpen.delete(n)}},this.onConnectionClose=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionClose.add(n),function(){return e.connectionClose.delete(n)}},this.onConnectionGain=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionGain.add(n),function(){return e.connectionGain.delete(n)}},this.onConnectionLost=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.connectionLost.add(n),function(){return e.connectionLost.delete(n)}},this.onSubscriptionUpdate=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.subscriptionUpdate.add(n),function(){return e.subscriptionUpdate.delete(n)}},this.onSubscriptionFailure=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.subscriptionFailure.add(n),function(){return e.subscriptionFailure.delete(n)}},this.subscribeTopics=function(e){t.assertNotNull(e,"topics"),t.assertTrue(t.isArray(e),"topics must be a array"),t.core.getUpstream().sendUpstream(t.WebSocketEvents.SUBSCRIBE,e)},this.onMessage=function(n,r){return t.assertNotNull(n,"topicName"),t.assertTrue(t.isFunction(r),"method must be a function"),e.topic.has(n)?e.topic.get(n).add(r):e.topic.set(n,new Set([r])),function(){return e.topic.get(n).delete(r)}},this.onAllMessage=function(n){return t.assertTrue(t.isFunction(n),"method must be a function"),e.allMessage.add(n),function(){return e.allMessage.delete(n)}}},g=function(e){this.bus=e,this.bus.subscribe(t.AgentEvents.UPDATE,t.hitch(this,this.updateAgentData))};g.prototype.updateAgentData=function(e){var n=this.agentData;this.agentData=e,null==n&&(t.agent.initialized=!0,this.bus.trigger(t.AgentEvents.INIT,new t.Agent)),this.bus.trigger(t.AgentEvents.REFRESH,new t.Agent),this._fireAgentUpdateEvents(n)},g.prototype.getAgentData=function(){if(null==this.agentData)throw new t.StateError("No agent data is available yet!");return t.deepcopy(this.agentData)},g.prototype.getContactData=function(e){var n=this.getAgentData(),r=t.find(n.snapshot.contacts,(function(t){return t.contactId===e}));if(null==r)throw new t.StateError("Contact %s no longer exists.",e);return r},g.prototype.getConnectionData=function(e,n){var r=this.getContactData(e),o=t.find(r.connections,(function(e){return e.connectionId===n}));if(null==o)throw new t.StateError("Connection %s for contact %s no longer exists.",n,e);return o},g.prototype.getInstanceId=function(){return this.getAgentData().configuration.routingProfile.routingProfileId.match(/instance\/([0-9a-fA-F|-]+)\//)[1]},g.prototype.getAWSAccountId=function(){return this.getAgentData().configuration.routingProfile.routingProfileId.match(/:([0-9]+):instance/)[1]},g.prototype._diffContacts=function(e){var n={added:{},removed:{},common:{},oldMap:t.index(null==e?[]:e.snapshot.contacts,(function(e){return e.contactId})),newMap:t.index(this.agentData.snapshot.contacts,(function(e){return e.contactId}))};return t.keys(n.oldMap).forEach((function(e){t.contains(n.newMap,e)?n.common[e]=n.newMap[e]:n.removed[e]=n.oldMap[e]})),t.keys(n.newMap).forEach((function(e){t.contains(n.oldMap,e)||(n.added[e]=n.newMap[e])})),n},g.prototype._fireAgentUpdateEvents=function(e){var n=this,r=null,o=null==e?t.AgentAvailStates.INIT:e.snapshot.state.name,i=this.agentData.snapshot.state.name,s=null==e?t.AgentStateType.INIT:e.snapshot.state.type,a=this.agentData.snapshot.state.type;s!==a&&t.core.getAgentRoutingEventGraph().getAssociations(this,s,a).forEach((function(e){n.bus.trigger(e,new t.Agent)})),o!==i&&(this.bus.trigger(t.AgentEvents.STATE_CHANGE,{agent:new t.Agent,oldState:o,newState:i}),t.core.getAgentStateEventGraph().getAssociations(this,o,i).forEach((function(e){n.bus.trigger(e,new t.Agent)})));var c=e&&e.snapshot.nextState?e.snapshot.nextState.name:null,u=this.agentData.snapshot.nextState?this.agentData.snapshot.nextState.name:null;c!==u&&u&&n.bus.trigger(t.AgentEvents.ENQUEUED_NEXT_STATE,new t.Agent),r=null!==e?this._diffContacts(e):{added:t.index(this.agentData.snapshot.contacts,(function(e){return e.contactId})),removed:{},common:{},oldMap:{},newMap:t.index(this.agentData.snapshot.contacts,(function(e){return e.contactId}))},t.values(r.added).forEach((function(e){n.bus.trigger(t.ContactEvents.INIT,new t.Contact(e.contactId)),n._fireContactUpdateEvents(e.contactId,t.ContactStateType.INIT,e.state.type)})),t.values(r.removed).forEach((function(e){n.bus.trigger(t.ContactEvents.DESTROYED,new t.ContactSnapshot(e)),n.bus.trigger(t.core.getContactEventName(t.ContactEvents.DESTROYED,e.contactId),new t.ContactSnapshot(e)),n._unsubAllContactEventsForContact(e.contactId)})),t.keys(r.common).forEach((function(e){n._fireContactUpdateEvents(e,r.oldMap[e].state.type,r.newMap[e].state.type)}))},g.prototype._fireContactUpdateEvents=function(e,n,r){var o=this;n!==r&&t.core.getContactEventGraph().getAssociations(this,n,r).forEach((function(n){o.bus.trigger(n,new t.Contact(e)),o.bus.trigger(t.core.getContactEventName(n,e),new t.Contact(e))})),o.bus.trigger(t.ContactEvents.REFRESH,new t.Contact(e)),o.bus.trigger(t.core.getContactEventName(t.ContactEvents.REFRESH,e),new t.Contact(e))},g.prototype._unsubAllContactEventsForContact=function(e){var n=this;t.values(t.ContactEvents).forEach((function(r){n.bus.getSubscriptions(t.core.getContactEventName(r,e)).map((function(e){e.unsubscribe()}))}))},t.core.onViewContact=function(e){t.core.getUpstream().onUpstream(t.ContactEvents.VIEW,e)},t.core.viewContact=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ContactEvents.VIEW,data:{contactId:e}})},t.core.onActivateChannelWithViewType=function(e){t.core.getUpstream().onUpstream(t.ChannelViewEvents.ACTIVATE_CHANNEL_WITH_VIEW_TYPE,e)},t.core.activateChannelWithViewType=function(e,n,r,o){const i={viewType:e,mediaType:n};r&&(i.source=r),o&&(i.caseId=o),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ChannelViewEvents.ACTIVATE_CHANNEL_WITH_VIEW_TYPE,data:i})},t.core.triggerTaskCreated=function(e){t.core.getUpstream().upstreamBus.trigger(t.TaskEvents.CREATED,e)},t.core.onAccessDenied=function(e){t.core.getUpstream().onUpstream(t.EventType.ACCESS_DENIED,e)},t.core.onAuthFail=function(e){t.core.getUpstream().onUpstream(t.EventType.AUTH_FAIL,e)},t.core.onAuthorizeSuccess=function(e){t.core.getUpstream().onUpstream(t.EventType.AUTHORIZE_SUCCESS,e)},t.core._handleAuthorizeSuccess=function(){window.sessionStorage.setItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT,0)},t.core._handleAuthFail=function(e,n,r){r&&r.authorize?t.core._handleAuthorizeFail(e):t.core._handleCTIAuthFail(n)},t.core._handleAuthorizeFail=function(e){let n=t.core._getAuthRetryCount();if(!t.core.authorizeTimeoutId)if(n{t.core._redirectToLogin(e)}),r)}else t.getLog().warn("We have exhausted our authorization retries due to 401s from the authorize api. No more retries will be attempted in this session until the authorize api returns 200.").sendInternalLogToServer(),t.core.getEventBus().trigger(t.EventType.AUTHORIZE_RETRIES_EXHAUSTED)},t.core._redirectToLogin=function(e){"string"==typeof e?location.assign(e):location.reload()},t.core._handleCTIAuthFail=function(e){if(!t.core.ctiTimeoutId)if(t.core.ctiAuthRetryCount{t.core.authorize(e).then(t.core._triggerAuthorizeSuccess.bind(t.core)).catch(t.core._triggerAuthFail.bind(t.core,{authorize:!0})),t.core.ctiTimeoutId=null}),n)}else t.getLog().warn("We have exhausted our authorization retries due to 401s from the CTI service. No more retries will be attempted until the page is refreshed.").sendInternalLogToServer(),t.core.getEventBus().trigger(t.EventType.CTI_AUTHORIZE_RETRIES_EXHAUSTED)},t.core._triggerAuthorizeSuccess=function(){t.core.getUpstream().upstreamBus.trigger(t.EventType.AUTHORIZE_SUCCESS)},t.core._triggerAuthFail=function(e){t.core.getUpstream().upstreamBus.trigger(t.EventType.AUTH_FAIL,e)},t.core._getAuthRetryCount=function(){let e=window.sessionStorage.getItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT);if(null!==e){if(isNaN(parseInt(e)))throw new t.StateError("The session storage value for auth retry count was NaN");return parseInt(e)}return window.sessionStorage.setItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT,0),0},t.core._incrementAuthRetryCount=function(){window.sessionStorage.setItem(t.SessionStorageKeys.AUTHORIZE_RETRY_COUNT,(t.core._getAuthRetryCount()+1).toString())},t.core.onAuthorizeRetriesExhausted=function(e){t.core.getEventBus().subscribe(t.EventType.AUTHORIZE_RETRIES_EXHAUSTED,e)},t.core.onCTIAuthorizeRetriesExhausted=function(e){t.core.getEventBus().subscribe(t.EventType.CTI_AUTHORIZE_RETRIES_EXHAUSTED,e)},t.core.onSoftphoneSessionInit=function(e){t.core.getUpstream().onUpstream(t.ConnectionEvents.SESSION_INIT,e)},t.core.onConfigure=function(e){t.core.getUpstream().onUpstream(t.ConfigurationEvents.CONFIGURE,e)},t.core.onInitialized=function(e){t.core.getEventBus().subscribe(t.EventType.INIT,e)},t.core.getContactEventName=function(e,n){if(t.assertNotNull(e,"eventName"),t.assertNotNull(n,"contactId"),!t.contains(t.values(t.ContactEvents),e))throw new t.ValueError("%s is not a valid contact event.",e);return t.sprintf("%s::%s",e,n)},t.core.getEventBus=function(){return t.core.eventBus},t.core.getWebSocketManager=function(){return t.core.webSocketProvider},t.core.getAgentDataProvider=function(){return t.core.agentDataProvider},t.core.getLocalTimestamp=function(){return t.core.getAgentDataProvider().getAgentData().snapshot.localTimestamp},t.core.getSkew=function(){return t.core.getAgentDataProvider().getAgentData().snapshot.skew},t.core.getAgentRoutingEventGraph=function(){return t.core.agentRoutingEventGraph},t.core.agentRoutingEventGraph=(new t.EventGraph).assoc(t.EventGraph.ANY,t.AgentStateType.ROUTABLE,t.AgentEvents.ROUTABLE).assoc(t.EventGraph.ANY,t.AgentStateType.NOT_ROUTABLE,t.AgentEvents.NOT_ROUTABLE).assoc(t.EventGraph.ANY,t.AgentStateType.OFFLINE,t.AgentEvents.OFFLINE),t.core.getAgentStateEventGraph=function(){return t.core.agentStateEventGraph},t.core.agentStateEventGraph=(new t.EventGraph).assoc(t.EventGraph.ANY,t.values(t.AgentErrorStates),t.AgentEvents.ERROR).assoc(t.EventGraph.ANY,t.AgentAvailStates.AFTER_CALL_WORK,t.AgentEvents.ACW),t.core.getContactEventGraph=function(){return t.core.contactEventGraph},t.core.contactEventGraph=(new t.EventGraph).assoc(t.EventGraph.ANY,t.ContactStateType.INCOMING,t.ContactEvents.INCOMING).assoc(t.EventGraph.ANY,t.ContactStateType.PENDING,t.ContactEvents.PENDING).assoc(t.EventGraph.ANY,t.ContactStateType.CONNECTING,t.ContactEvents.CONNECTING).assoc(t.EventGraph.ANY,t.ContactStateType.CONNECTED,t.ContactEvents.CONNECTED).assoc(t.ContactStateType.CONNECTING,t.ContactStateType.ERROR,t.ContactEvents.MISSED).assoc(t.ContactStateType.INCOMING,t.ContactStateType.ERROR,t.ContactEvents.MISSED).assoc(t.EventGraph.ANY,t.ContactStateType.ENDED,t.ContactEvents.ACW).assoc(t.values(t.CONTACT_ACTIVE_STATES),t.values(t.relativeComplement(t.CONTACT_ACTIVE_STATES,t.ContactStateType)),t.ContactEvents.ENDED).assoc(t.EventGraph.ANY,t.ContactStateType.ERROR,t.ContactEvents.ERROR).assoc(t.ContactStateType.CONNECTING,t.ContactStateType.MISSED,t.ContactEvents.MISSED),t.core.getClient=function(){if(!t.core.client)throw new t.StateError("The connect core has not been initialized!");return t.core.client},t.core.client=null,t.core.getAgentAppClient=function(){if(!t.core.agentAppClient)throw new t.StateError("The connect AgentApp Client has not been initialized!");return t.core.agentAppClient},t.core.agentAppClient=null,t.core.getTaskTemplatesClient=function(){if(!t.core.taskTemplatesClient)throw new t.StateError("The connect TaskTemplates Client has not been initialized!");return t.core.taskTemplatesClient},t.core.taskTemplatesClient=null,t.core.getMasterClient=function(){if(!t.core.masterClient)throw new t.StateError("The connect master client has not been initialized!");return t.core.masterClient},t.core.masterClient=null,t.core.getSoftphoneManager=function(){return t.core.softphoneManager},t.core.softphoneManager=null,t.core.getNotificationManager=function(){return t.core.notificationManager||(t.core.notificationManager=new t.NotificationManager),t.core.notificationManager},t.core.notificationManager=null,t.core.getPopupManager=function(){return t.core.popupManager},t.core.popupManager=new t.PopupManager,t.core.getUpstream=function(){if(!t.core.upstream)throw new t.StateError("There is no upstream conduit!");return t.core.upstream},t.core.upstream=null,t.core.AgentDataProvider=g}()},592:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t;var n="<>",r=t.makeEnum(["acknowledge","ack_timeout","init","api_request","api_response","auth_fail","access_denied","close","configure","log","master_request","master_response","synchronize","terminate","terminated","send_logs","reload_agent_configuration","broadcast","api_metric","client_metric","softphone_stats","softphone_report","client_side_logs","server_bound_internal_log","mute","iframe_style","iframe_retries_exhausted","update_connected_ccps","outer_context_info","media_device_request","media_device_response","tab_id","authorize_success","authorize_retries_exhausted","cti_authorize_retries_exhausted","click_stream_data"]),o=t.makeNamespacedEnum("connect",["loginPopup","sendLogs","softphone","ringtone","metrics"]),i=t.makeNamespacedEnum("agent",["init","update","refresh","routable","not_routable","pending","contact_pending","offline","error","softphone_error","websocket_connection_lost","websocket_connection_gained","state_change","acw","mute_toggle","local_media_stream_created","enqueued_next_state"]),s=t.makeNamespacedEnum("webSocket",["init_failure","connection_open","connection_close","connection_error","connection_gain","connection_lost","subscription_update","subscription_failure","all_message","send","subscribe"]),a=t.makeNamespacedEnum("contact",["init","refresh","destroyed","incoming","pending","connecting","connected","missed","acw","view","ended","error","accepted"]),c=t.makeNamespacedEnum("taskList",["activate_channel_with_view_type"]),u=t.makeNamespacedEnum("task",["created"]),l=t.makeNamespacedEnum("connection",["session_init","ready_to_start_session"]),p=t.makeNamespacedEnum("configuration",["configure","set_speaker_device","set_microphone_device","set_ringer_device","speaker_device_changed","microphone_device_changed","ringer_device_changed"]),d=t.makeNamespacedEnum("voiceId",["update_domain_id"]),h=function(){};h.createRequest=function(e,n,r){return{event:e,requestId:t.randomId(),method:n,params:r}},h.createResponse=function(e,t,n,r){return{event:e,requestId:t.requestId,data:n,err:r||null}};var f=function(e,n,r){this.subMap=e,this.id=t.randomId(),this.eventName=n,this.f=r};f.prototype.unsubscribe=function(){this.subMap.unsubscribe(this.eventName,this.id)};var g=function(){this.subIdMap={},this.subEventNameMap={}};g.prototype.subscribe=function(e,t){var n=new f(this,e,t);this.subIdMap[n.id]=n;var r=this.subEventNameMap[e]||[];return r.push(n),this.subEventNameMap[e]=r,n},g.prototype.unsubscribe=function(e,n){t.contains(this.subEventNameMap,e)&&(this.subEventNameMap[e]=this.subEventNameMap[e].filter((function(e){return e.id!==n})),this.subEventNameMap[e].length<1&&delete this.subEventNameMap[e]),t.contains(this.subIdMap,n)&&delete this.subIdMap[n]},g.prototype.getAllSubscriptions=function(){return t.values(this.subEventNameMap).reduce((function(e,t){return e.concat(t)}),[])},g.prototype.getSubscriptions=function(e){return this.subEventNameMap[e]||[]};var m=function(e){var t=e||{};this.subMap=new g,this.logEvents=t.logEvents||!1};m.prototype.subscribe=function(e,n){return t.assertNotNull(e,"eventName"),t.assertNotNull(n,"f"),t.assertTrue(t.isFunction(n),"f must be a function"),this.subMap.subscribe(e,n)},m.prototype.subscribeAll=function(e){return t.assertNotNull(e,"f"),t.assertTrue(t.isFunction(e),"f must be a function"),this.subMap.subscribe(n,e)},m.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},m.prototype.trigger=function(e,r){t.assertNotNull(e,"eventName");var o=this,i=this.subMap.getSubscriptions(n),s=this.subMap.getSubscriptions(e);this.logEvents&&e!==t.EventType.LOG&&e!==t.EventType.MASTER_RESPONSE&&e!==t.EventType.API_METRIC&&e!==t.EventType.SERVER_BOUND_INTERNAL_LOG&&t.getLog().trace("Publishing event: %s",e).sendInternalLogToServer(),e.startsWith(t.ContactEvents.ACCEPTED)&&r&&r.contactId&&!(r instanceof t.Contact)&&(r=new t.Contact(r.contactId)),i.concat(s).forEach((function(n){try{n.f(r||null,e,o)}catch(n){t.getLog().error("'%s' event handler failed.",e).withException(n).sendInternalLogToServer()}}))},m.prototype.bridge=function(){var e=this;return function(t,n){e.trigger(n,t)}},m.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach((function(e){e.unsubscribe()}))},t.EventBus=m,t.EventFactory=h,t.EventType=r,t.AgentEvents=i,t.ConfigurationEvents=p,t.ConnectionEvents=l,t.ConnnectionEvents=l,t.ContactEvents=a,t.ChannelViewEvents=c,t.TaskEvents=u,t.VoiceIdEvents=d,t.WebSocketEvents=s,t.MasterTopics=o}()},286:()=>{!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";var r=n(1),o="DEBUG",i="AMZ_WEB_SOCKET_MANAGER:",s="Network offline",a="Network online, connecting to WebSocket server",c="Network offline, ignoring this getWebSocketConnConfig request",u="Heartbeat response not received",l="Failed to send heartbeat since WebSocket is not open",p="WebSocket connection established!",d="WebSocket connection is closed",h="WebSocketManager Error, error_event: ",f="Scheduling WebSocket reinitialization, after delay ",g="WebSocket URL cannot be used to establish connection",m="WebSocket Initialization failed - Terminating and cleaning subscriptions",v="Fetching new WebSocket connection configuration",y="Successfully fetched webSocket connection configuration",E="Failed to fetch webSocket connection configuration",S="Retrying fetching new WebSocket connection configuration",b="Initializing Websocket Manager",T="WebSocketManager Message Error",C="Message received for topic ",I="Invalid incoming message",_="aws/subscribe",A="aws/heartbeat",w="disconnected";function R(e){return(R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var k={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return k.assertTrue(null!==e&&void 0!==R(e),Object(r.sprintf)("%s must be provided",t||"A value")),e},isNonEmptyString:function(e){return"string"==typeof e&&e.length>0},assertIsList:function(e,t){if(!Array.isArray(e))throw new Error(t+" is not an array")},isFunction:function(e){return!!(e&&e.constructor&&e.call&&e.apply)},isObject:function(e){return!("object"!==R(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},N=new RegExp("^(wss://)\\w*");k.validWSUrl=function(e){return N.test(e)},k.getSubscriptionResponse=function(e,t,n){return{topic:e,content:{status:t?"success":"failure",topics:n}}},k.assertIsObject=function(e,t){if(!k.isObject(e))throw new Error(t+" is not an object!")},k.addJitter=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;t=Math.min(t,1);var n=Math.random()>.5?1:-1;return Math.floor(e+n*e*Math.random()*t)},k.isNetworkOnline=function(){return navigator.onLine},k.isNetworkFailure=function(e){return!(!e._debug||!e._debug.type)&&"NetworkingError"===e._debug.type};var O=k;function L(e){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function M(e,t){for(var n=0;n=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){var t=e.prefix||q;return this._logsDestination===o?this.consoleLoggerWrapper:new W(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||j.INFO,this._advancedLogWriter="warn",t.advancedLogWriter&&(this._advancedLogWriter=t.advancedLogWriter),t.customizedLogger&&"object"===P(t.customizedLogger)&&(this.useClientLogger=!0),this._clientLogger=t.logger||this.selectLogger(t),this._logsDestination="NULL",t.debug&&(this._logsDestination=o),t.logger&&(this._logsDestination="CLIENT_LOGGER")}},{key:"selectLogger",value:function(e){return e.customizedLogger&&"object"===P(e.customizedLogger)?e.customizedLogger:e.useDefaultLogger?(this.consoleLoggerWrapper=H(),this.consoleLoggerWrapper):null}}]),e}(),V=function(){function e(){x(this,e)}return U(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}},{key:"advancedLog",value:function(){}}]),e}(),W=function(e){function t(e){var n;return x(this,t),(n=function(e,t){return!t||"object"!==P(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}(this,L(t).call(this))).prefix=e||q,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&D(e,t)}(t,V),U(t,[{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1&&void 0!==arguments[1]?arguments[1]:2e3;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.numAttempts=0,this.executor=t,this.hasActiveReconnection=!1,this.defaultRetry=n}var t,n;return t=e,(n=[{key:"retry",value:function(){var e=this;this.hasActiveReconnection||(this.hasActiveReconnection=!0,setTimeout((function(){e._execute()}),this._getDelay()))}},{key:"_execute",value:function(){this.hasActiveReconnection=!1,this.executor(),this.numAttempts++}},{key:"connected",value:function(){this.numAttempts=0}},{key:"_getDelay",value:function(){var e=Math.pow(2,this.numAttempts)*this.defaultRetry;return e<=3e4?e:3e4}},{key:"getIsConnected",value:function(){return!this.numAttempts}}])&&G(t.prototype,n),e}();n.d(t,"a",(function(){return Y}));var X=function(){var e=z.getLogger({prefix:i}),t=O.isNetworkOnline(),n={primary:null,secondary:null},r={reconnectWebSocket:!0,websocketInitFailed:!1,exponentialBackOffTime:1e3,exponentialTimeoutHandle:null,lifeTimeTimeoutHandle:null,webSocketInitCheckerTimeoutId:null,connState:null},o={connectWebSocketRetryCount:0,connectionAttemptStartTime:null,noOpenConnectionsTimestamp:null},R={pendingResponse:!1,intervalHandle:null},k={initFailure:new Set,getWebSocketTransport:null,subscriptionUpdate:new Set,subscriptionFailure:new Set,topic:new Map,allMessage:new Set,connectionGain:new Set,connectionLost:new Set,connectionOpen:new Set,connectionClose:new Set},N={connConfig:null,promiseHandle:null,promiseCompleted:!0},L={subscribed:new Set,pending:new Set,subscriptionHistory:new Set},D={responseCheckIntervalId:null,requestCompleted:!0,reSubscribeIntervalId:null,consecutiveFailedSubscribeAttempts:0,consecutiveNoResponseRequest:0},P=new K((function(){se()})),x=new Set([_,"aws/unsubscribe",A]),M=setInterval((function(){if(t!==O.isNetworkOnline()){if(!(t=O.isNetworkOnline()))return e.advancedLog(s),void ue(e.info(s));var n=W();t&&(!n||j(n,WebSocket.CLOSING)||j(n,WebSocket.CLOSED))&&(e.advancedLog(a),ue(e.info(a)),se())}}),250),U=function(t,n){t.forEach((function(t){try{t(n)}catch(t){ue(e.error("Error executing callback",t))}}))},F=function(e){if(null===e)return"NULL";switch(e.readyState){case WebSocket.CONNECTING:return"CONNECTING";case WebSocket.OPEN:return"OPEN";case WebSocket.CLOSING:return"CLOSING";case WebSocket.CLOSED:return"CLOSED";default:return"UNDEFINED"}},q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";ue(e.debug("["+t+"] Primary WebSocket: "+F(n.primary)+" | Secondary WebSocket: "+F(n.secondary)))},j=function(e,t){return e&&e.readyState===t},B=function(e){return j(e,WebSocket.OPEN)},V=function(e){return null===e||void 0===e.readyState||j(e,WebSocket.CLOSED)},W=function(){return null!==n.secondary?n.secondary:n.primary},H=function(){return B(W())},G=function(){if(R.pendingResponse)return e.advancedLog(u),ue(e.warn(u)),clearInterval(R.intervalHandle),R.pendingResponse=!1,void se();H()?(ue(e.debug("Sending heartbeat")),W().send(oe(A)),R.pendingResponse=!0):(e.advancedLog(l),ue(e.warn(l)),q("sendHeartBeat"),se())},X=function(){e.advancedLog("Reset Websocket state"),r.exponentialBackOffTime=1e3,R.pendingResponse=!1,r.reconnectWebSocket=!0,clearTimeout(r.lifeTimeTimeoutHandle),clearInterval(R.intervalHandle),clearTimeout(r.exponentialTimeoutHandle),clearTimeout(r.webSocketInitCheckerTimeoutId)},Y=function(){D.consecutiveFailedSubscribeAttempts=0,D.consecutiveNoResponseRequest=0,clearInterval(D.responseCheckIntervalId),clearInterval(D.reSubscribeIntervalId)},J=function(){o.connectWebSocketRetryCount=0,o.connectionAttemptStartTime=null,o.noOpenConnectionsTimestamp=null},Q=function(){P.connected();try{e.advancedLog(p),ue(e.info(p)),q("webSocketOnOpen"),null!==r.connState&&r.connState!==w||U(k.connectionGain),r.connState="connected";var t=Date.now();U(k.connectionOpen,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,noOpenConnectionsTimestamp:o.noOpenConnectionsTimestamp,connectionEstablishedTime:t,timeToConnect:t-o.connectionAttemptStartTime,timeWithoutConnection:o.noOpenConnectionsTimestamp?t-o.noOpenConnectionsTimestamp:null}),J(),X(),W().openTimestamp=Date.now(),0===L.subscribed.size&&B(n.secondary)&&te(n.primary,"[Primary WebSocket] Closing WebSocket"),(L.subscribed.size>0||L.pending.size>0)&&(B(n.secondary)&&ue(e.info("Subscribing secondary websocket to topics of primary websocket")),L.subscribed.forEach((function(e){L.subscriptionHistory.add(e),L.pending.add(e)})),L.subscribed.clear(),ee()),G(),R.intervalHandle=setInterval(G,1e4);var i=1e3*N.connConfig.webSocketTransport.transportLifeTimeInSeconds;ue(e.debug("Scheduling WebSocket manager reconnection, after delay "+i+" ms")),r.lifeTimeTimeoutHandle=setTimeout((function(){ue(e.debug("Starting scheduled WebSocket manager reconnection")),se()}),i)}catch(t){ue(e.error("Error after establishing WebSocket connection",t))}},$=function(t){q("webSocketOnError"),e.advancedLog(h,JSON.stringify(t)),ue(e.error(h,JSON.stringify(t))),P.getIsConnected()?se():P.retry()},Z=function(t){var r=JSON.parse(t.data);switch(r.topic){case _:if(ue(e.debug("Subscription Message received from webSocket server",t.data)),D.requestCompleted=!0,D.consecutiveNoResponseRequest=0,"success"===r.content.status)D.consecutiveFailedSubscribeAttempts=0,r.content.topics.forEach((function(e){L.subscriptionHistory.delete(e),L.pending.delete(e),L.subscribed.add(e)})),0===L.subscriptionHistory.size?B(n.secondary)&&(ue(e.info("Successfully subscribed secondary websocket to all topics of primary websocket")),te(n.primary,"[Primary WebSocket] Closing WebSocket")):ee(),U(k.subscriptionUpdate,r);else{if(clearInterval(D.reSubscribeIntervalId),++D.consecutiveFailedSubscribeAttempts,5===D.consecutiveFailedSubscribeAttempts)return U(k.subscriptionFailure,r),void(D.consecutiveFailedSubscribeAttempts=0);D.reSubscribeIntervalId=setInterval((function(){ee()}),500)}break;case A:ue(e.debug("Heartbeat response received")),R.pendingResponse=!1;break;default:if(r.topic){if(e.advancedLog(C,r.topic),ue(e.debug(C+r.topic)),B(n.primary)&&B(n.secondary)&&0===L.subscriptionHistory.size&&this===n.primary)return void ue(e.warn("Ignoring Message for Topic "+r.topic+", to avoid duplicates"));if(0===k.allMessage.size&&0===k.topic.size)return void ue(e.warn("No registered callback listener for Topic",r.topic));e.advancedLog("WebsocketManager invoke callbacks for topic success ",r.topic),U(k.allMessage,r),k.topic.has(r.topic)&&U(k.topic.get(r.topic),r)}else r.message?(e.advancedLog(T,r),ue(e.warn(T,r))):(e.advancedLog(I,r),ue(e.warn(I,r)))}},ee=function t(){if(D.consecutiveNoResponseRequest>3)return ue(e.warn("Ignoring subscribePendingTopics since we have exhausted max subscription retries with no response")),void U(k.subscriptionFailure,O.getSubscriptionResponse(_,!1,Array.from(L.pending)));H()?0!==Array.from(L.pending).length&&(clearInterval(D.responseCheckIntervalId),W().send(oe(_,{topics:Array.from(L.pending)})),D.requestCompleted=!1,D.responseCheckIntervalId=setInterval((function(){D.requestCompleted||(++D.consecutiveNoResponseRequest,t())}),1e3)):ue(e.warn("Ignoring subscribePendingTopics call since Default WebSocket is not open"))},te=function(t,n){j(t,WebSocket.CONNECTING)||j(t,WebSocket.OPEN)?t.close(1e3,n):ue(e.warn("Ignoring WebSocket Close request, WebSocket State: "+F(t)))},ne=function(e){te(n.primary,"[Primary] WebSocket "+e),te(n.secondary,"[Secondary] WebSocket "+e)},re=function(t){X(),Y(),e.advancedLog(m,t),ue(e.error(m)),r.websocketInitFailed=!0,ne("Terminating WebSocket Manager"),clearInterval(M),U(k.initFailure,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,reason:t}),J()},oe=function(e,t){return JSON.stringify({topic:e,content:t})},ie=function(t){return!!(O.isObject(t)&&O.isObject(t.webSocketTransport)&&O.isNonEmptyString(t.webSocketTransport.url)&&O.validWSUrl(t.webSocketTransport.url)&&1e3*t.webSocketTransport.transportLifeTimeInSeconds>=3e5)||(ue(e.error("Invalid WebSocket Connection Configuration",t)),!1)},se=function(){if(!O.isNetworkOnline())return e.advancedLog(c),void ue(e.info(c));if(r.websocketInitFailed)ue(e.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request"));else{if(N.promiseCompleted)return X(),e.advancedLog(v),ue(e.info(v)),o.connectionAttemptStartTime=o.connectionAttemptStartTime||Date.now(),N.promiseCompleted=!1,N.promiseHandle=k.getWebSocketTransport(),N.promiseHandle.then((function(t){return N.promiseCompleted=!0,e.advancedLog(y),ue(e.debug(y,t)),ie(t)?(N.connConfig=t,N.connConfig.urlConnValidTime=Date.now()+85e3,ae()):(re("Invalid WebSocket connection configuration: "+t),{webSocketConnectionFailed:!0})}),(function(t){return N.promiseCompleted=!0,e.advancedLog(E),ue(e.error(E,t)),O.isNetworkFailure(t)?(e.advancedLog(S+JSON.stringify(t)),ue(e.info(S+JSON.stringify(t))),P.retry()):re("Failed to fetch webSocket connection configuration: "+JSON.stringify(t)),{webSocketConnectionFailed:!0}}));ue(e.debug("There is an ongoing getWebSocketConnConfig request, this request will be ignored"))}},ae=function(){if(r.websocketInitFailed)return ue(e.info("web-socket initializing had failed, aborting re-init")),{webSocketConnectionFailed:!0};if(!O.isNetworkOnline())return ue(e.warn("System is offline aborting web-socket init")),{webSocketConnectionFailed:!0};e.advancedLog(b),ue(e.info(b)),q("initWebSocket");try{if(ie(N.connConfig)){var t=null;return B(n.primary)?(ue(e.debug("Primary Socket connection is already open")),j(n.secondary,WebSocket.CONNECTING)||(ue(e.debug("Establishing a secondary web-socket connection")),P.numAttempts=0,n.secondary=ce()),t=n.secondary):(j(n.primary,WebSocket.CONNECTING)||(ue(e.debug("Establishing a primary web-socket connection")),n.primary=ce()),t=n.primary),r.webSocketInitCheckerTimeoutId=setTimeout((function(){B(t)||function(){o.connectWebSocketRetryCount++;var t=O.addJitter(r.exponentialBackOffTime,.3);Date.now()+t<=N.connConfig.urlConnValidTime?(e.advancedLog(f),ue(e.debug(f+t+" ms")),r.exponentialTimeoutHandle=setTimeout((function(){return ae()}),t),r.exponentialBackOffTime*=2):(e.advancedLog(g),ue(e.warn(g)),se())}()}),1e3),{webSocketConnectionFailed:!1}}}catch(t){return ue(e.error("Error Initializing web-socket-manager",t)),re("Failed to initialize new WebSocket: "+t.message),{webSocketConnectionFailed:!0}}},ce=function(){var t=new WebSocket(N.connConfig.webSocketTransport.url);return t.addEventListener("open",Q),t.addEventListener("message",Z),t.addEventListener("error",$),t.addEventListener("close",(function(i){return function(t,i){e.advancedLog(d,JSON.stringify(t)),ue(e.info(d,JSON.stringify(t))),q("webSocketOnClose before-cleanup"),U(k.connectionClose,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),V(n.primary)&&(n.primary=null),V(n.secondary)&&(n.secondary=null),r.reconnectWebSocket&&(B(n.primary)||B(n.secondary)?V(n.primary)&&B(n.secondary)&&(ue(e.info("[Primary] WebSocket Cleanly Closed")),n.primary=n.secondary,n.secondary=null):(ue(e.warn("Neither primary websocket and nor secondary websocket have open connections, attempting to re-establish connection")),r.connState===w?ue(e.info("Ignoring connectionLost callback invocation")):(U(k.connectionLost,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),o.noOpenConnectionsTimestamp=Date.now()),r.connState=w,se()),q("webSocketOnClose after-cleanup"))}(i,t)})),t},ue=function(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e};this.init=function(t){if(O.assertTrue(O.isFunction(t),"transportHandle must be a function"),null===k.getWebSocketTransport)return k.getWebSocketTransport=t,se();ue(e.warn("Web Socket Manager was already initialized"))},this.onInitFailure=function(t){return e.advancedLog("Initializing Websocket Manager Failed!"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.initFailure.add(t),r.websocketInitFailed&&t(),function(){return k.initFailure.delete(t)}},this.onConnectionOpen=function(t){return e.advancedLog("Websocket connection open"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionOpen.add(t),function(){return k.connectionOpen.delete(t)}},this.onConnectionClose=function(t){return e.advancedLog("Websocket connection close"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionClose.add(t),function(){return k.connectionClose.delete(t)}},this.onConnectionGain=function(t){return e.advancedLog("Websocket connection gain"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionGain.add(t),H()&&t(),function(){return k.connectionGain.delete(t)}},this.onConnectionLost=function(t){return e.advancedLog("Websocket connection lost"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.connectionLost.add(t),r.connState===w&&t(),function(){return k.connectionLost.delete(t)}},this.onSubscriptionUpdate=function(e){return O.assertTrue(O.isFunction(e),"cb must be a function"),k.subscriptionUpdate.add(e),function(){return k.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(t){return e.advancedLog("Websocket subscription failure"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.subscriptionFailure.add(t),function(){return k.subscriptionFailure.delete(t)}},this.onMessage=function(e,t){return O.assertNotNull(e,"topicName"),O.assertTrue(O.isFunction(t),"cb must be a function"),k.topic.has(e)?k.topic.get(e).add(t):k.topic.set(e,new Set([t])),function(){return k.topic.get(e).delete(t)}},this.onAllMessage=function(e){return O.assertTrue(O.isFunction(e),"cb must be a function"),k.allMessage.add(e),function(){return k.allMessage.delete(e)}},this.subscribeTopics=function(e){O.assertNotNull(e,"topics"),O.assertIsList(e),e.forEach((function(e){L.subscribed.has(e)||L.pending.add(e)})),D.consecutiveNoResponseRequest=0,ee()},this.sendMessage=function(t){if(O.assertIsObject(t,"payload"),void 0===t.topic||x.has(t.topic))ue(e.warn("Cannot send message, Invalid topic",t));else{try{t=JSON.stringify(t)}catch(n){return void ue(e.warn("Error stringify message",t))}H()?W().send(t):ue(e.warn("Cannot send message, web socket connection is not open"))}},this.closeWebSocket=function(){X(),Y(),r.reconnectWebSocket=!1,clearInterval(M),ne("User request to close WebSocket")},this.terminateWebSocketManager=re},Y={create:function(){return new X},setGlobalConfig:function(e){var t=e&&e.loggerConfig;z.updateLoggerConfig(t)},LogLevel:j,Logger:F}},function(e,t,n){var r;!function(){"use strict";var o={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function i(e){return function(e,t){var n,r,s,a,c,u,l,p,d,h=1,f=e.length,g="";for(r=0;r=0),a.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,a.width?parseInt(a.width):0);break;case"e":n=a.precision?parseFloat(n).toExponential(a.precision):parseFloat(n).toExponential();break;case"f":n=a.precision?parseFloat(n).toFixed(a.precision):parseFloat(n);break;case"g":n=a.precision?String(Number(n.toPrecision(a.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=a.precision?n.substring(0,a.precision):n;break;case"t":n=String(!!n),n=a.precision?n.substring(0,a.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=a.precision?n.substring(0,a.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=a.precision?n.substring(0,a.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}o.json.test(a.type)?g+=n:(!o.number.test(a.type)||p&&!a.sign?d="":(d=p?"+":"-",n=n.toString().replace(o.sign,"")),u=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",l=a.width-(d+n).length,c=a.width&&l>0?u.repeat(l):"",g+=a.align?d+n+c:"0"===u?d+c+n:c+d+n)}return g}(function(e){if(a[e])return a[e];for(var t,n=e,r=[],i=0;n;){if(null!==(t=o.text.exec(n)))r.push(t[0]);else if(null!==(t=o.modulo.exec(n)))r.push("%");else{if(null===(t=o.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){i|=1;var s=[],c=t[2],u=[];if(null===(u=o.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(c=c.substring(u[0].length));)if(null!==(u=o.key_access.exec(c)))s.push(u[1]);else{if(null===(u=o.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}t[2]=s}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return a[e]=r}(e),arguments)}function s(e,t){return i.apply(null,[e].concat(t||[]))}var a=Object.create(null);t.sprintf=i,t.vsprintf=s,"undefined"!=typeof window&&(window.sprintf=i,window.vsprintf=s,void 0===(r=function(){return{sprintf:i,vsprintf:s}}.call(t,n,t,e))||(e.exports=r))}()},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"WebSocketManager",(function(){return o}));var r=n(0);e.connect=e.connect||{},connect.WebSocketManager=r.a;var o=r.a}.call(this,n(3))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n}])},151:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n={TEST:"TEST",TRACE:"TRACE",DEBUG:"DEBUG",INFO:"INFO",LOG:"LOG",WARN:"WARN",ERROR:"ERROR",CRITICAL:"CRITICAL"},r={CCP:"ccp",SOFTPHONE:"softphone",CHAT:"chat",TASK:"task"},o={TEST:0,TRACE:10,DEBUG:20,INFO:30,LOG:40,WARN:50,ERROR:100,CRITICAL:200},i={TRACE:function(e){console.info(e)},DEBUG:function(e){console.info(e)},INFO:function(e){console.info(e)},LOG:function(e){console.log(e)},TEST:function(e){console.log(e)},WARN:function(e){console.warn(e)},ERROR:function(e){console.error(e)},CRITICAL:function(e){console.error(e)}},s=function(e){var t,n,o=Array.prototype.slice.call(e,0),i=o.shift();return function(e){return-1!==Object.values(r).indexOf(e)}(i)?(n=i,t=o.shift()):(t=i,n=r.CCP),{format:t,component:n,args:o}},a=function(e,n,r,o){this.component=e,this.level=n,this.text=r,this.time=new Date,this.exception=null,this.objects=[],this.line=0,this.agentResourceId=null;try{t.agent.initialized&&(this.agentResourceId=(new t.Agent)._getResourceId())}catch(e){console.log("Issue finding agentResourceId: ",e)}this.loggerId=o};a.fromObject=function(e){var t=new a(r.CCP,e.level,e.text,e.loggerId);return"[object Date]"===Object.prototype.toString.call(e.time)?t.time=new Date(e.time.getTime()):"number"==typeof e.time?t.time=new Date(e.time):"string"==typeof e.time?t.time=Date.parse(e.time):t.time=new Date,t.exception=e.exception,t.objects=e.objects,t};var c=function(e){var t=/AuthToken.*\=/g;e&&"object"==typeof e&&Object.keys(e).forEach((function(n){"object"==typeof e[n]?c(e[n]):"string"==typeof e[n]&&("url"===n||"text"===n?e[n]=e[n].replace(t,"[redacted]"):["quickConnectName"].includes(n)?e[n]="[redacted]":["customerId","CustomerId","SpeakerId","CustomerSpeakerId"].includes(n)&&(e[n]=md5(e[n])))}))},u=function(e){if(this.type=e instanceof Error?e.name:e.code||Object.prototype.toString.call(e),this.message=e.message,this.stack=[],e.stack)try{Array.isArray(e.stack)?this.stack=e.stack:"object"==typeof e.stack?this.stack=[JSON.stringify(e.stack)]:"string"==typeof e.stack&&(this.stack=e.stack.split("\n"))}catch{}};a.prototype.toString=function(){return t.sprintf("[%s] [%s] [%s]: %s",this.getTime()&&this.getTime().toISOString?this.getTime().toISOString():"???",this.getLevel(),this.getAgentResourceId(),this.getText())},a.prototype.getTime=function(){return this.time},a.prototype.getAgentResourceId=function(){return this.agentResourceId},a.prototype.getLevel=function(){return this.level},a.prototype.getText=function(){return this.text},a.prototype.getComponent=function(){return this.component},a.prototype.withException=function(e){return this.exception=new u(e),this},a.prototype.withObject=function(e){var n=t.deepcopy(e);return c(n),this.objects.push(n),this},a.prototype.withCrossOriginEventObject=function(e){var n=t.deepcopyCrossOriginEvent(e);return c(n),this.objects.push(n),this},a.prototype.sendInternalLogToServer=function(){return t.getLog()._serverBoundInternalLogs.push(this),this};var l=function(){this._logs=[],this._rolledLogs=[],this._logsToPush=[],this._serverBoundInternalLogs=[],this._echoLevel=o.INFO,this._logLevel=o.INFO,this._lineCount=0,this._logRollInterval=0,this._logRollTimer=null,this._loggerId=(new Date).getTime()+"-"+Math.random().toString(36).slice(2),this.setLogRollInterval(18e5),this._startLogIndexToPush=0};l.prototype.setLogRollInterval=function(t){var n=this;this._logRollTimer&&t===this._logRollInterval?this.warn("Logger is already set to the given interval: %d",this._logRollInterval):(this._logRollTimer&&e.clearInterval(this._logRollTimer),this._logRollInterval=t,this._logRollTimer=e.setInterval((function(){n._rolledLogs=n._logs,n._logs=[],n._startLogIndexToPush=0,n.info("Log roll interval occurred.")}),this._logRollInterval))},l.prototype.setLogLevel=function(e){if(!(e in o))throw new Error("Unknown logging level: "+e);this._logLevel=o[e]},l.prototype.setEchoLevel=function(e){if(!(e in o))throw new Error("Unknown logging level: "+e);this._echoLevel=o[e]},l.prototype.write=function(e,t,n){var r=new a(e,t,n,this.getLoggerId());return c(r),this.addLogEntry(r),r},l.prototype.addLogEntry=function(e){c(e),this._logs.push(e),r.SOFTPHONE===e.component&&this._logsToPush.push(e),e.level in o&&o[e.level]>=this._logLevel&&(o[e.level]>=this._echoLevel&&i[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.sendInternalLogEntryToServer=function(e){this._serverBoundInternalLogs.push(e),e.level in o&&o[e.level]>=this._logLevel&&(o[e.level]>=this._echoLevel&&i[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.clearObjects=function(){for(var e=0;e=i._logLevel})));var a=new e.Blob([JSON.stringify(s,void 0,4)],["text/plain"]),c=document.createElement("a");n=n||"agent-log",c.href=e.URL.createObjectURL(a),c.download=n+".txt",document.body.appendChild(c),c.click(),document.body.removeChild(c)},l.prototype.scheduleUpstreamLogPush=function(n){t.upstreamLogPushScheduled||(t.upstreamLogPushScheduled=!0,e.setInterval(t.hitch(this,this.reportMasterLogsUpStream,n),5e3))},l.prototype.reportMasterLogsUpStream=function(e){var n=this._logsToPush.slice();this._logsToPush=[],t.ifMaster(t.MasterTopics.SEND_LOGS,(function(){n.length>0&&e.sendUpstream(t.EventType.SEND_LOGS,n)}))},l.prototype.scheduleUpstreamOuterContextCCPserverBoundLogsPush=function(n){e.setInterval(t.hitch(this,this.pushOuterContextCCPserverBoundLogsUpstream,n),1e3)},l.prototype.scheduleUpstreamOuterContextCCPLogsPush=function(n){e.setInterval(t.hitch(this,this.pushOuterContextCCPLogsUpstream,n),1e3)},l.prototype.pushOuterContextCCPserverBoundLogsUpstream=function(e){if(this._serverBoundInternalLogs.length>0){for(var n=0;n500?e=this._serverBoundInternalLogs.splice(0,500):(e=this._serverBoundInternalLogs,this._serverBoundInternalLogs=[]),t.publishClientSideLogs(e))};var p=function(n){l.call(this),this.conduit=n,e.setInterval(t.hitch(this,this._pushLogsDownstream),p.LOG_PUSH_INTERVAL),e.clearInterval(this._logRollTimer),this._logRollTimer=null};p.LOG_PUSH_INTERVAL=1e3,p.prototype=Object.create(l.prototype),p.prototype.constructor=p,p.prototype.pushLogsDownstream=function(e){var n=this;e.forEach((function(e){n.conduit.sendDownstream(t.EventType.LOG,e)}))},p.prototype._pushLogsDownstream=function(){var e=this;this._logs.forEach((function(n){e.conduit.sendDownstream(t.EventType.LOG,n)})),this._logs=[];for(var n=0;n>16)+(t>>16)+(n>>16)<<16|65535&n}function n(e,n,r,o,i,s){return t((a=t(t(n,e),t(o,s)))<<(c=i)|a>>>32-c,r);var a,c}function r(e,t,r,o,i,s,a){return n(t&r|~t&o,e,t,i,s,a)}function o(e,t,r,o,i,s,a){return n(t&o|r&~o,e,t,i,s,a)}function i(e,t,r,o,i,s,a){return n(t^r^o,e,t,i,s,a)}function s(e,t,r,o,i,s,a){return n(r^(t|~o),e,t,i,s,a)}function a(e,n){var a,c,u,l,p;e[n>>5]|=128<>>9<<4)]=n;var d=1732584193,h=-271733879,f=-1732584194,g=271733878;for(a=0;a>5]>>>t%32&255);return n}function u(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function p(e){return unescape(encodeURIComponent(e))}function d(e){return function(e){return c(a(u(e),8*e.length))}(p(e))}function h(e,t){return function(e,t){var n,r,o=u(e),i=[],s=[];for(i[15]=s[15]=void 0,o.length>16&&(o=a(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],s[n]=1549556828^o[n];return r=a(i.concat(u(t)),512+8*t.length),c(a(s.concat(r),640))}(p(e),p(t))}(this||globalThis).md5=function(e,t,n){return t?n?h(t,e):l(h(t,e)):n?d(e):l(d(e))}}()},439:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.ChatMediaController=function(e,n){var r=t.getLog(),o=t.LogComponent.CHAT,i=function(n,r){t.publishMetric({name:n,contactId:e.contactId,data:r||e})},s=function(e){e.onConnectionBroken((function(e){r.error(o,"Chat Session connection broken").withException(e).sendInternalLogToServer(),i("Chat Session connection broken",e)})),e.onConnectionEstablished((function(e){r.info(o,"Chat Session connection established").withObject(e).sendInternalLogToServer(),i("Chat Session connection established",e)}))};return{get:function(){return function(){i("Chat media controller init",e.contactId),r.info(o,"Chat media controller init").withObject(e).sendInternalLogToServer(),t.ChatSession.setGlobalConfig({loggerConfig:{logger:r},region:n.region});var a=t.ChatSession.create({chatDetails:e,type:"AGENT",websocketManager:t.core.getWebSocketManager()});return s(a),a.connect().then((function(t){return r.info(o,"Chat Session Successfully established for contactId %s",e.contactId).sendInternalLogToServer(),i("Chat Session Successfully established",e.contactId),a})).catch((function(t){throw r.error(o,"Chat Session establishement failed for contact %s",e.contactId).withException(t).sendInternalLogToServer(),i("Chat Session establishement failed",e.contactId,t),t}))}()}}}}()},279:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.MediaFactory=function(e){var n={},r=new Set,o=t.getLog(),i=t.LogComponent.CHAT,s=t.merge({},e)||{};s.region=s.region||"us-west-2";var a=function(e){n[e]&&!r.has(e)&&(o.info(i,"Destroying mediaController for %s",e),r.add(e),n[e].then((function(){"function"==typeof controller.cleanUp&&controller.cleanUp(),delete n[e],r.delete(e)})).catch((function(){delete n[e],r.delete(e)})))};return{get:function(e){return function(e){return e.isActive()}(e)?function(e){var r=e.getConnectionId();if(!e.getMediaInfo())return o.error(i,"Media info does not exist for a media type %s",e.getMediaType()).withObject(e).sendInternalLogToServer(),Promise.reject("Media info does not exist for this connection");if(n[r])return n[r];switch(o.info(i,"media controller of type %s init",e.getMediaType()).withObject(e).sendInternalLogToServer(),e.getMediaType()){case t.MediaType.CHAT:return n[r]=new t.ChatMediaController(e.getMediaInfo(),s).get();case t.MediaType.SOFTPHONE:return n[r]=new t.SoftphoneMediaController(e.getMediaInfo()).get();case t.MediaType.TASK:return n[r]=new t.TaskMediaController(e.getMediaInfo()).get();default:return o.error(i,"Unrecognized media type %s ",e.getMediaType()).sendInternalLogToServer(),Promise.reject()}}(e):(a(e.getConnectionId()),Promise.reject("Media Controller is no longer available for this connection"))},destroy:a}}}()},418:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.SoftphoneMediaController=function(e){return{get:function(){return Promise.resolve(e)}}}}()},187:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.TaskMediaController=function(e){var n=t.getLog(),r=t.LogComponent.TASK,o=function(n,r){t.publishMetric({name:n,contactId:e.contactId,data:r||e})},i=function(e){e.onConnectionBroken((function(e){n.error(r,"Task Session connection broken").withException(e),o("Task Session connection broken",e)})),e.onConnectionEstablished((function(e){n.info(r,"Task Session connection established").withObject(e),o("Task Session connection established",e)}))};return{get:function(){return function(){o("Task media controller init",e.contactId),n.info(r,"Task media controller init").withObject(e);var s=t.TaskSession.create({contactId:e.contactId,initialContactId:e.initialContactId,websocketManager:t.core.getWebSocketManager()});return i(s),s.connect().then((function(){return n.info(r,"Task Session Successfully established for contactId %s",e.contactId),o("Task Session Successfully established",e.contactId),s})).catch((function(t){throw n.error(r,"Task Session establishement failed for contact %s",e.contactId).withException(t),o("Chat Session establishement failed",e.contactId,t),t}))}()}}}}()},743:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=function(n){var r=this;if(this._prevContactId=null,t.assertNotNull(n,"ringtoneConfig"),!n.ringtoneUrl)throw new Error("ringtoneUrl is required!");e.Audio&&void 0!==e.Promise?this._playableAudioPromise=new Promise((function(e,o){r._audio=new Audio(n.ringtoneUrl),r._audio.loop=!0,r._audio.addEventListener("canplay",(function(){t.getLog().info("Ringtone is ready to play: ",+n.ringtoneUrl).sendInternalLogToServer(),r._audioPlayable=!0,e(r._audio)}))})):(this._audio=null,t.getLog().error("Unable to provide a ringtone.").sendInternalLogToServer()),r._driveRingtone()};n.prototype._driveRingtone=function(){throw new Error("Not implemented.")},n.prototype._startRingtone=function(e){var n=this;this._audio&&(this._audio.play().catch((function(r){n._publishTelemetryEvent("Ringtone Playback Failure",e),t.getLog().error("Ringtone Playback Failure").withException(r).withObject({currentSrc:n._audio.currentSrc,sinkId:n._audio.sinkId,volume:n._audio.volume}).sendInternalLogToServer()})),n._publishTelemetryEvent("Ringtone Start",e),t.getLog().info("Ringtone Start").sendInternalLogToServer())},n.prototype._stopRingtone=function(e){this._audio&&(this._audio.pause(),this._audio.currentTime=0,this._publishTelemetryEvent("Ringtone Stop",e),t.getLog().info("Ringtone Stop").sendInternalLogToServer())},n.prototype.stopRingtone=function(){this._stopRingtone()},n.prototype._ringtoneSetup=function(e){var n=this;t.ifMaster(t.MasterTopics.RINGTONE,(function(){n._startRingtone(e),n._prevContactId=e.getContactId(),e.onConnected(lily.hitch(n,n._stopRingtone)),e.onAccepted(lily.hitch(n,n._stopRingtone)),e.onEnded(lily.hitch(n,n._stopRingtone)),e.onRefresh((function(e){e.getStatus().type!==t.ContactStatusType.CONNECTING&&e.getStatus().type!==t.ContactStatusType.INCOMING&&n._stopRingtone()}))}))},n.prototype._publishTelemetryEvent=function(e,n){n&&n.getContactId()&&t.publishMetric({name:e,contactId:n.getContactId()})},n.prototype.setOutputDevice=function(t){return this._playableAudioPromise?Promise.race([this._playableAudioPromise,new Promise((function(t,n){e.setTimeout((function(){n("Timed out waiting for playable audio")}),3e3)}))]).then((function(e){return e?e.setSinkId?Promise.resolve(e.setSinkId(t)):Promise.reject("Not supported"):Promise.reject("No audio found")})):e.Promise?Promise.reject("Not eligible ringtone owner"):void 0};var r=function(e){n.call(this,e)};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype._driveRingtone=function(){var e=this,n=function(n){n.getType()===lily.ContactType.VOICE&&n.isSoftphoneCall()&&n.isInbound()&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Ringtone Connecting",n),t.getLog().info("Ringtone Connecting").sendInternalLogToServer())};t.contact((function(e){e.onConnecting(n)})),(new t.Agent).getContacts().forEach((function(e){e.getStatus().type===t.ContactStatusType.CONNECTING&&n(e)}))};var o=function(e){n.call(this,e)};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype._driveRingtone=function(){var e=this,n=function(n){n.getType()===lily.ContactType.CHAT&&n.isInbound()&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Chat Ringtone Connecting",n),t.getLog().info("Chat Ringtone Connecting").sendInternalLogToServer())};t.contact((function(e){e.onConnecting(n)}))};var i=function(e){n.call(this,e)};(i.prototype=Object.create(n.prototype)).constructor=i,i.prototype._driveRingtone=function(){var e=this,n=function(n){n.getType()===lily.ContactType.TASK&&n.isInbound()&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Task Ringtone Connecting",n),t.getLog().info("Task Ringtone Connecting").sendInternalLogToServer())};t.contact((function(e){e.onConnecting(n)}))};var s=function(e){n.call(this,e)};(s.prototype=Object.create(n.prototype)).constructor=s,s.prototype._driveRingtone=function(){var e=this;t.contact((function(n){n.onIncoming((function(){n.getType()===lily.ContactType.QUEUE_CALLBACK&&(e._ringtoneSetup(n),e._publishTelemetryEvent("Callback Ringtone Connecting",n),t.getLog().info("Callback Ringtone Connecting").sendInternalLogToServer())}))}))},t.VoiceRingtoneEngine=r,t.ChatRingtoneEngine=o,t.TaskRingtoneEngine=i,t.QueueCallbackRingtoneEngine=s}()},642:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,e.ccpVersion="V2";var n={};n[t.SoftphoneCallType.AUDIO_ONLY]="Audio",n[t.SoftphoneCallType.VIDEO_ONLY]="Video",n[t.SoftphoneCallType.AUDIO_VIDEO]="AudioVideo",n[t.SoftphoneCallType.NONE]="None";var r="audio_input",o="audio_output";({})[t.ContactType.VOICE]="Voice";var i=[],s={},a={},c=null,u=null,l=null,p=t.SoftphoneErrorTypes,d={},h=t.randomId(),f=function(e){return new Promise((function(n,r){t.core.getClient().call(t.ClientMethods.CREATE_TRANSPORT,e,{success:function(e){n(e.softphoneTransport.softphoneMediaConnections)},failure:function(e){e.message&&e.message.includes("SoftphoneConnectionLimitBreachedException")&&w("multiple_softphone_active_sessions","Number of active sessions are more then allowed limit.",""),r(Error("requestIceAccess failed"))},authFailure:function(){r(Error("Authentication failed while requestIceAccess"))},accessDenied:function(){r(Error("Access Denied while requestIceAccess"))}})}))},g=function(e){var n=t.core.getUpstream(),r=e.getAgentConnection();if(r){var o=r.getSoftphoneMediaInfo();o?!0===o.autoAccept?(l.info("Auto-accept is enabled, sending out Accepted event to stop ringtone..").sendInternalLogToServer(),n.sendUpstream(t.EventType.BROADCAST,{event:t.ContactEvents.ACCEPTED,data:new t.Contact(e.contactId)}),n.sendUpstream(t.EventType.BROADCAST,{event:t.core.getContactEventName(t.ContactEvents.ACCEPTED,e.contactId),data:new t.Contact(e.contactId)})):l.info("Auto-accept is disabled, ringtone will be stopped by user action.").sendInternalLogToServer():l.info("Not able to retrieve the auto-accept setting from null SoftphoneMediaInfo, ignoring event publish..").sendInternalLogToServer()}else l.info("Not able to retrieve the auto-accept setting from null AgentConnection, ignoring event publish..").sendInternalLogToServer()},m=function(){t.core.getEventBus().subscribe(t.EventType.MUTE,b)},v=function(){t.core.getEventBus().subscribe(t.ConfigurationEvents.SET_SPEAKER_DEVICE,T)},y=function(){t.core.getEventBus().subscribe(t.ConfigurationEvents.SET_MICROPHONE_DEVICE,C)},E=function(){try{t.isChromeBrowser()&&t.getChromeBrowserVersion()>43&&navigator.permissions.query({name:"microphone"}).then((function(e){e.onchange=function(){l.info("Microphone Permission: "+e.state),k("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:e.state}),"denied"===e.state&&w(p.MICROPHONE_NOT_SHARED,"Your microphone is not enabled in your browser. ","")}}))}catch(e){l.error("Failed in detecting microphone permission status: "+e)}},S=function(e){delete d[e],t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.MUTE_TOGGLE,data:{muted:!1}})},b=function(e){var n;if(0!==t.keys(d).length){for(var r in e&&void 0!==e.mute&&(n=e.mute),d)if(d.hasOwnProperty(r)){var o=d[r].stream;if(o){var i=o.getAudioTracks()[0];void 0!==n?(i.enabled=!n,d[r].muted=n,n?l.info("Agent has muted the contact, connectionId - "+r).sendInternalLogToServer():l.info("Agent has unmuted the contact, connectionId - "+r).sendInternalLogToServer()):n=d[r].muted||!1}}t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.MUTE_TOGGLE,data:{muted:n}})}},T=function(e){if(0!==t.keys(d).length&&e&&e.deviceId){var n=e.deviceId,r=document.getElementById("remote-audio");try{l.info("Trying to set speaker to device "+n),r&&"function"==typeof r.setSinkId&&r.setSinkId(n)}catch(e){l.error("Failed to set speaker to device "+n)}t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,data:{deviceId:n}})}},C=function(e){if(0!==t.keys(d).length&&e&&e.deviceId){var n=e.deviceId,r=t.core.getSoftphoneManager();try{navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:n}}}).then((function(e){var t=e.getAudioTracks()[0];for(var n in d)d.hasOwnProperty(n)&&(d[n].stream,r.getSession(n)._pc.getSenders()[0].replaceTrack(t).then((function(){r.replaceLocalMediaTrack(n,t)})))}))}catch(e){l.error("Failed to set microphone device "+n)}t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,data:{deviceId:n}})}},I=function(e,n){if(n===t.RTCErrors.ICE_COLLECTION_TIMEOUT){for(var r="\n",o=0;o0?t.success(e):t.failure(p.MICROPHONE_NOT_SHARED)}),(function(e){t.failure(p.MICROPHONE_NOT_SHARED)})),r}t.failure(p.UNSUPPORTED_BROWSER)},w=function(e,n,r){l.error("Softphone error occurred : ",e,n||"").sendInternalLogToServer(),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.SOFTPHONE_ERROR,data:new t.SoftphoneError(e,n,r)})},R=function(e,t){k("Softphone Session Failed",e,{failedReason:t})},k=function(e,n,r){t.publishMetric({name:e,contactId:n,data:r})},N=function(e,t,n){k(e,t,[{name:"AgentConnectionId",value:n}]),l.info("Publish multiple session error metrics",e,"contactId "+t,"agent connectionId "+n).sendInternalLogToServer()},O=function(){return!!(t.isOperaBrowser()&&t.getOperaBrowserVersion()>17)||!!(t.isChromeBrowser()&&t.getChromeBrowserVersion()>22)||!!(t.isFirefoxBrowser()&&t.getFirefoxBrowserVersion()>21)},L=function(e){var t=i.slice();i=[],t.length>0&&e.sendSoftphoneMetrics(t,{success:function(){l.info("sendSoftphoneMetrics success"+JSON.stringify(t)).sendInternalLogToServer()},failure:function(e){l.error("sendSoftphoneMetrics failed.").withObject(e).sendInternalLogToServer()}})},D=function(e){c=window.setInterval((function(){e.getUserAudioStats().then((function(e){var t=s;s=e,i.push(M(s,t,r))}),(function(e){l.debug("Failed to get user audio stats.",e).sendInternalLogToServer()})),e.getRemoteAudioStats().then((function(e){var t=a;a=e,i.push(M(a,t,o))}),(function(e){l.debug("Failed to get remote audio stats.",e).sendInternalLogToServer()}))}),1e3)},P=function(e){u=window.setInterval((function(){L(e)}),3e4)},x=function(){s=null,a=null,i=[],c=null,u=null},M=function(e,t,n){if(t&&e){var r=e.packetsLost>t.packetsLost?e.packetsLost-t.packetsLost:0,o=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new q(e.timestamp,r,o,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new q(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},U=function(e){return null!==e&&window.clearInterval(e),null},F=function(e,t){c=U(c),u=U(u),function(e,t,n,i){t.streamStats=[j(n,r),j(i,o)];var s={callStartTime:t.sessionStartTime,callEndTime:t.sessionEndTime,gumTimeMillis:t.gumTimeMillis,initializationTimeMillis:t.initializationTimeMillis,iceCollectionTimeMillis:t.iceCollectionTimeMillis,signallingConnectTimeMillis:t.signallingConnectTimeMillis,handshakingTimeMillis:t.handshakingTimeMillis,preTalkingTimeMillis:t.preTalkingTimeMillis,talkingTimeMillis:t.talkingTimeMillis,cleanupTimeMillis:t.cleanupTimeMillis,iceCollectionFailure:t.iceCollectionFailure,signallingConnectionFailure:t.signallingConnectionFailure,handshakingFailure:t.handshakingFailure,gumOtherFailure:t.gumOtherFailure,gumTimeoutFailure:t.gumTimeoutFailure,createOfferFailure:t.createOfferFailure,setLocalDescriptionFailure:t.setLocalDescriptionFailure,userBusyFailure:t.userBusyFailure,invalidRemoteSDPFailure:t.invalidRemoteSDPFailure,noRemoteIceCandidateFailure:t.noRemoteIceCandidateFailure,setRemoteDescriptionFailure:t.setRemoteDescriptionFailure,softphoneStreamStatistics:t.streamStats};e.sendSoftphoneReport(s,{success:function(){l.info("sendSoftphoneReport success"+JSON.stringify(s)).sendInternalLogToServer()},failure:function(e){l.error("sendSoftphoneReport failed.").withObject(e).sendInternalLogToServer()}})}(e,t,j(s,r),j(a,o)),L(e)},q=function(e,t,n,r,o,i,s){this.softphoneStreamType=r,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=o,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},j=function(e,t){return new q((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},B=function(e){this._originalLogger=e;var n=this;this._tee=function(e,r){return function(){var e=Array.prototype.slice.call(arguments[0]),o="";return e.forEach((function(){o+=" %s"})),r.apply(n._originalLogger,[t.LogComponent.SOFTPHONE,o].concat(e))}}};B.prototype.debug=function(){return this._tee(1,this._originalLogger.debug)(arguments)},B.prototype.info=function(){return this._tee(2,this._originalLogger.info)(arguments)},B.prototype.log=function(){return this._tee(3,this._originalLogger.log)(arguments)},B.prototype.warn=function(){return this._tee(4,this._originalLogger.warn)(arguments)},B.prototype.error=function(){return this._tee(5,this._originalLogger.error)(arguments)},t.SoftphoneManager=function(e){var n,r=this;(l=new B(t.getLog())).info("[Softphone Manager] softphone manager initialization has begun").sendInternalLogToServer(),t.RtcPeerConnectionFactory&&(n=new t.RtcPeerConnectionFactory(l,t.core.getWebSocketManager(),h,t.hitch(r,f,{transportType:"softphone",softphoneClientId:h}),t.hitch(r,w))),O()||w(p.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ",""),A({success:function(e){k("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:"granted"})},failure:function(e){w(e,"Your microphone is not enabled in your browser. ",""),k("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:"denied"})}}),m(),v(),y(),E(),this.ringtoneEngine=null;var o={},i={};this.onInitContactSub={},this.onInitContactSub.unsubscribe=function(){};var s=!1,a=null,c=null,u=function(){s=!1,a=null,c=null};this.getSession=function(e){return o[e]},this.replaceLocalMediaTrack=function(e,t){var n=d[e].stream;if(n){var r=n.getAudioTracks()[0];t.enabled=r.enabled,r.enabled=!1,n.removeTrack(r),n.addTrack(t)}};var b=function(e){if(o.hasOwnProperty(e)){var t=o[e];new Promise((function(n,r){delete o[e],delete i[e],t.hangup()})).catch((function(t){lily.getLog().warn("Clean up the session locally "+e,t.message).sendInternalLogToServer()}))}};this.startSession=function(e,r){var p=s?a:e,h=s?c:r;if(p&&h){u(),i[h]=!0,l.info("Softphone call detected:","contactId "+p.getContactId(),"agent connectionId "+h).sendInternalLogToServer(),function(e){if(Object.keys(e).length>0){for(var t in e)e.hasOwnProperty(t)&&(N("MultiSessionHangUp",e[t].callId,t),b(t));throw new Error("duplicate session detected, refusing to setup new connection")}}(o),p.getStatus().type===t.ContactStatusType.CONNECTING&&k("Softphone Connecting",p.getContactId()),x();var f,m=p.getAgentConnection().getSoftphoneMediaInfo(),v=_(m.callConfigJson);v.useWebSocketProvider&&(f=t.core.getWebSocketManager());var y=new t.RTCSession(v.signalingEndpoint,v.iceServers,m.callContextToken,l,p.getContactId(),h,f);o[h]=y,t.core.getSoftphoneUserMediaStream()&&(y.mediaStream=t.core.getSoftphoneUserMediaStream()),t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.ConnectionEvents.SESSION_INIT,data:{connectionId:h}}),y.onSessionFailed=function(e,t){delete o[h],delete i[h],I(e,t),R(p.getContactId(),t),F(p,e.sessionReport)},y.onSessionConnected=function(e){k("Softphone Session Connected",p.getContactId()),t.becomeMaster(t.MasterTopics.SEND_LOGS),D(e),P(p),g(p)},y.onSessionCompleted=function(e){k("Softphone Session Completed",p.getContactId()),delete o[h],delete i[h],F(p,e.sessionReport),S(h)},y.onLocalStreamAdded=function(e,n){d[h]={stream:n},t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,data:{connectionId:h}})},y.remoteAudioElement=document.getElementById("remote-audio"),n?y.connect(n.get(v.iceServers)):y.connect()}};var T=function(e,n){o[n]&&function(e){return e.getStatus().type===t.ContactStatusType.ENDED||e.getStatus().type===t.ContactStatusType.ERROR||e.getStatus().type===t.ContactStatusType.MISSED}(e)&&(b(n),u()),!e.isSoftphoneCall()||i[n]||e.getStatus().type!==t.ContactStatusType.CONNECTING&&e.getStatus().type!==t.ContactStatusType.INCOMING||(t.isFirefoxBrowser()&&t.hasOtherConnectedCCPs()?function(e,t){s=!0,a=e,c=t}(e,n):r.startSession(e,n))},C=function(e){var t=e.getAgentConnection().connectionId;l.info("Contact detected:","contactId "+e.getContactId(),"agent connectionId "+t).sendInternalLogToServer(),i[t]||e.onRefresh((function(){T(e,t)}))};r.onInitContactSub=t.contact(C),(new t.Agent).getContacts().forEach((function(e){var t=e.getAgentConnection().connectionId;l.info("Contact exist in the snapshot. Reinitiate the Contact and RTC session creation for contactId"+e.getContactId(),"agent connectionId "+t).sendInternalLogToServer(),C(e),T(e,t)}))}}()},944:()=>{!function(){var e=this||globalThis,t=function(){return t.cache.hasOwnProperty(arguments[0])||(t.cache[arguments[0]]=t.parse(arguments[0])),t.format.call(null,t.cache[arguments[0]],arguments)};function n(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function r(e,t){for(var n=[];t>0;n[--t]=e);return n.join("")}t.format=function(e,o){var i,s,a,c,u,l,p,d=1,h=e.length,f="",g=[];for(s=0;s>>=0;break;case"x":i=i.toString(16);break;case"X":i=i.toString(16).toUpperCase()}i=/[def]/.test(c[8])&&c[3]&&i>=0?"+"+i:i,l=c[4]?"0"==c[4]?"0":c[4].charAt(1):" ",p=c[6]-String(i).length,u=c[6]?r(l,p):"",g.push(c[5]?i+u:u+i)}return g.join("")},t.cache={},t.parse=function(e){for(var t=e,n=[],r=[],o=0;t;){if(null!==(n=/^[^\x25]+/.exec(t)))r.push(n[0]);else if(null!==(n=/^\x25{2}/.exec(t)))r.push("%");else{if(null===(n=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t)))throw"[sprintf] huh?";if(n[2]){o|=1;var i=[],s=n[2],a=[];if(null===(a=/^([a-z_][a-z_\d]*)/i.exec(s)))throw"[sprintf] huh?";for(i.push(a[1]);""!==(s=s.substring(a[0].length));)if(null!==(a=/^\.([a-z_][a-z_\d]*)/i.exec(s)))i.push(a[1]);else{if(null===(a=/^\[(\d+)\]/.exec(s)))throw"[sprintf] huh?";i.push(a[1])}n[2]=i}else o|=2;if(3===o)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";r.push(n)}t=t.substring(n[0].length)}return r},e.sprintf=t,e.vsprintf=function(e,n,r){return(r=n.slice(0)).splice(0,0,e),t.apply(null,r)}}()},82:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=function(){};n.prototype.send=function(e){throw new t.NotImplementedError},n.prototype.onMessage=function(e){throw new t.NotImplementedError};var r=function(){n.call(this)};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype.onMessage=function(e){},r.prototype.send=function(e){};var o=function(e,t){n.call(this),this.window=e,this.domain=t||"*"};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype.send=function(e){this.window.postMessage(e,this.domain)},o.prototype.onMessage=function(e){this.window.addEventListener("message",e)};var i=function(e,t,r){n.call(this),this.input=e,this.output=t,this.domain=r||"*"};(i.prototype=Object.create(n.prototype)).constructor=i,i.prototype.send=function(e){this.output.postMessage(e,this.domain)},i.prototype.onMessage=function(e){this.input.addEventListener("message",(t=>{t.source===this.output&&e(t)}))};var s=function(e){n.call(this),this.port=e,this.id=t.randomId()};(s.prototype=Object.create(n.prototype)).constructor=s,s.prototype.send=function(e){this.port.postMessage(e)},s.prototype.onMessage=function(e){this.port.addEventListener("message",e)},s.prototype.getId=function(){return this.id};var a=function(e){n.call(this),this.streamMap=e?t.index(e,(function(e){return e.getId()})):{},this.messageListeners=[]};(a.prototype=Object.create(n.prototype)).constructor=a,a.prototype.send=function(e){this.getStreams().forEach((function(t){try{t.send(e)}catch(e){}}))},a.prototype.onMessage=function(e){this.messageListeners.push(e),this.getStreams().forEach((function(t){t.onMessage(e)}))},a.prototype.addStream=function(e){this.streamMap[e.getId()]=e,this.messageListeners.forEach((function(t){e.onMessage(t)}))},a.prototype.removeStream=function(e){delete this.streamMap[e.getId()]},a.prototype.getStreams=function(e){return t.values(this.streamMap)},a.prototype.getStreamForPort=function(e){return t.find(this.getStreams(),(function(t){return t.port===e}))};var c=function(e,n,o){this.name=e,this.upstream=n||new r,this.downstream=o||new r,this.downstreamBus=new t.EventBus,this.upstreamBus=new t.EventBus,this.upstream.onMessage(t.hitch(this,this._dispatchEvent,this.upstreamBus)),this.downstream.onMessage(t.hitch(this,this._dispatchEvent,this.downstreamBus))};c.prototype.onUpstream=function(e,n){return t.assertNotNull(e,"eventName"),t.assertNotNull(n,"f"),t.assertTrue(t.isFunction(n),"f must be a function"),this.upstreamBus.subscribe(e,n)},c.prototype.onAllUpstream=function(e){return t.assertNotNull(e,"f"),t.assertTrue(t.isFunction(e),"f must be a function"),this.upstreamBus.subscribeAll(e)},c.prototype.onDownstream=function(e,n){return t.assertNotNull(e,"eventName"),t.assertNotNull(n,"f"),t.assertTrue(t.isFunction(n),"f must be a function"),this.downstreamBus.subscribe(e,n)},c.prototype.onAllDownstream=function(e){return t.assertNotNull(e,"f"),t.assertTrue(t.isFunction(e),"f must be a function"),this.downstreamBus.subscribeAll(e)},c.prototype.sendUpstream=function(e,n){t.assertNotNull(e,"eventName"),this.upstream.send({event:e,data:n})},c.prototype.sendDownstream=function(e,n){t.assertNotNull(e,"eventName"),this.downstream.send({event:e,data:n})},c.prototype._dispatchEvent=function(e,t){var n=t.data;n.event&&e.trigger(n.event,n.data)},c.prototype.passUpstream=function(){var e=this;return function(t,n){e.upstream.send({event:n,data:t})}},c.prototype.passDownstream=function(){var e=this;return function(t,n){e.downstream.send({event:n,data:t})}},c.prototype.shutdown=function(){this.upstreamBus.unsubscribeAll(),this.downstreamBus.unsubscribeAll()};var u=function(e,t,n,r){c.call(this,e,new i(t,n.contentWindow,r||"*"),null)};(u.prototype=Object.create(c.prototype)).constructor=u,t.Stream=n,t.NullStream=r,t.WindowStream=o,t.WindowIOStream=i,t.PortStream=s,t.StreamMultiplexer=a,t.Conduit=c,t.IFrameConduit=u}()},833:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=function(e,n){t.assertNotNull(e,"fromState"),t.assertNotNull(n,"toState"),this.fromState=e,this.toState=n};n.prototype.getAssociations=function(e){throw t.NotImplementedError()},n.prototype.getFromState=function(){return this.fromState},n.prototype.getToState=function(){return this.toState};var r=function(e,r,o){t.assertNotNull(e,"fromState"),t.assertNotNull(r,"toState"),t.assertNotNull(o,"associations"),n.call(this,e,r),this.associations=o};(r.prototype=Object.create(n.prototype)).constructor=r,r.prototype.getAssociations=function(e){return this.associations};var o=function(e,r,o){t.assertNotNull(e,"fromState"),t.assertNotNull(r,"toState"),t.assertNotNull(o,"closure"),t.assertTrue(t.isFunction(o),"closure must be a function"),n.call(this,e,r),this.closure=o};(o.prototype=Object.create(n.prototype)).constructor=o,o.prototype.getAssociations=function(e){return this.closure(e,this.getFromState(),this.getToState())};var i=function(){this.fromMap={}};i.ANY="<>",i.prototype.assoc=function(e,t,n){var i=this;if(!e)throw new Error("fromStateObj is not defined.");if(!t)throw new Error("toStateObj is not defined.");if(!n)throw new Error("assocObj is not defined.");return e instanceof Array?e.forEach((function(e){i.assoc(e,t,n)})):t instanceof Array?t.forEach((function(t){i.assoc(e,t,n)})):"function"==typeof n?this._addAssociation(new o(e,t,n)):n instanceof Array?this._addAssociation(new r(e,t,n)):this._addAssociation(new r(e,t,[n])),this},i.prototype.getAssociations=function(e,n,r){t.assertNotNull(n,"fromState"),t.assertNotNull(r,"toState");var o=[],s=this.fromMap[i.ANY]||{},a=this.fromMap[n]||{};return o=(o=o.concat(this._getAssociationsFromMap(s,e,n,r))).concat(this._getAssociationsFromMap(a,e,n,r))},i.prototype._addAssociation=function(e){var t=this.fromMap[e.getFromState()];t||(t=this.fromMap[e.getFromState()]={});var n=t[e.getToState()];n||(n=t[e.getToState()]=[]),n.push(e)},i.prototype._getAssociationsFromMap=function(e,t,n,r){return(e[i.ANY]||[]).concat(e[r]||[]).reduce((function(e,n){return e.concat(n.getAssociations(t))}),[])},t.EventGraph=i}()},891:(e,t,n)=>{var r=n(465);!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t;var n=navigator.userAgent,o=["bubbles","cancelBubble","cancelable","composed","data","defaultPrevented","eventPhase","isTrusted","lastEventId","origin","returnValue","timeStamp","type"];t.sprintf=e.sprintf,t.vsprintf=e.vsprintf,delete e.sprintf,delete e.vsprintf,t.HTTP_STATUS_CODES={SUCCESS:200,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500},t.TRANSPORT_TYPES={CHAT_TOKEN:"chat_token",WEB_SOCKET:"web_socket"},t.hitch=function(){var e=Array.prototype.slice.call(arguments),n=e.shift(),r=e.shift();return t.assertNotNull(n,"scope"),t.assertNotNull(r,"method"),t.assertTrue(t.isFunction(r),"method must be a function"),function(){var t=Array.prototype.slice.call(arguments);return r.apply(n,e.concat(t))}},t.isFunction=function(e){return!!(e&&e.constructor&&e.call&&e.apply)},t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.keys=function(e){var n=[];for(var r in t.assertNotNull(e,"map"),e)n.push(r);return n},t.values=function(e){var n=[];for(var r in t.assertNotNull(e,"map"),e)n.push(e[r]);return n},t.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},t.merge=function(){var e=Array.prototype.slice.call(arguments,0),n={};return e.forEach((function(e){t.entries(e).forEach((function(e){n[e.key]=e.value}))})),n},t.now=function(){return(new Date).getTime()},t.find=function(e,t){for(var n=0;n{try{void 0!==e[r]&&(n[r]=e[r])}catch(e){t.getLog().info("deepcopyCrossOriginEvent failed on key: ",r).sendInternalLogToServer()}})),t.deepcopy(n)},t.getBaseUrl=function(){var n=e.location;return t.sprintf("%s//%s:%s",n.protocol,n.hostname,n.port)},t.getUrlWithProtocol=function(n){var r=e.location.protocol;return n.substr(0,r.length)!==r?t.sprintf("%s//%s",r,n):n},t.isFramed=function(){try{return window.self!==window.top}catch(e){return!0}},t.hasOtherConnectedCCPs=function(){return t.numberOfConnectedCCPs>1},t.fetch=function(e,n,r,o){return o=o||5,r=r||1e3,n=n||{},new Promise((function(i,s){!function o(a){fetch(e,n).then((function(e){e.status===t.HTTP_STATUS_CODES.SUCCESS?e.json().then((e=>i(e))).catch((()=>i({}))):1!==a&&(e.status>=t.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===t.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout((function(){o(--a)}),r):s(e)})).catch((function(e){s(e)}))}(o)}))},t.backoff=function(n,r,o,i){t.assertTrue(t.isFunction(n),"func must be a Function");var s=this;n({success:function(e){i&&i.success&&i.success(e)},failure:function(t,a){if(o>0){var c=2*r*Math.random();e.setTimeout((function(){s.backoff(n,2*c,--o,i)}),c)}else i&&i.failure&&i.failure(t,a)}})},t.publishMetric=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.CLIENT_METRIC,data:e})},t.publishSoftphoneStats=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.SOFTPHONE_STATS,data:e})},t.publishSoftphoneReport=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.SOFTPHONE_REPORT,data:e})},t.publishClickStreamData=function(e){t.core.getUpstream().sendUpstream(t.EventType.BROADCAST,{event:t.EventType.CLICK_STREAM_DATA,data:e})},t.publishClientSideLogs=function(e){t.core.getEventBus().trigger(t.EventType.CLIENT_SIDE_LOGS,e)},t.addNamespaceToLogs=function(e){["log","error","warn","info","debug"].forEach((t=>{const n=window.console[t];window.console[t]=function(){const t=Array.from(arguments);t.unshift(`[${e}]`),n.apply(window.console,t)}}))},t.PopupManager=function(){},t.PopupManager.prototype.open=function(e,t,n){var r=this._getLastOpenedTimestamp(t),o=(new Date).getTime(),i=null;if(o-r>864e5){if(n){var s=n.height||578,a=n.width||433,c=n.top||0,u=n.left||0;(i=window.open("",t,"width="+a+", height="+s+", top="+c+", left="+u)).location!==e&&(i=window.open(e,t,"width="+a+", height="+s+", top="+c+", left="+u))}else(i=window.open("",t)).location!==e&&(i=window.open(e,t));this._setLastOpenedTimestamp(t,o)}return i},t.PopupManager.prototype.clear=function(t){var n=this._getLocalStorageKey(t);e.localStorage.removeItem(n)},t.PopupManager.prototype._getLastOpenedTimestamp=function(t){var n=this._getLocalStorageKey(t),r=e.localStorage.getItem(n);return r?parseInt(r,10):0},t.PopupManager.prototype._setLastOpenedTimestamp=function(t,n){var r=this._getLocalStorageKey(t);e.localStorage.setItem(r,""+n)},t.PopupManager.prototype._getLocalStorageKey=function(e){return"connectPopupManager::"+e};var i=t.makeEnum(["granted","denied","default"]);t.NotificationManager=function(){this.queue=[],this.permission=i.DEFAULT},t.NotificationManager.prototype.requestPermission=function(){var n=this;"Notification"in e?e.Notification.permission===i.DENIED?(t.getLog().warn("The user has requested to not receive notifications.").sendInternalLogToServer(),this.permission=i.DENIED):this.permission!==i.GRANTED&&e.Notification.requestPermission().then((function(e){n.permission=e,e===i.GRANTED?n._showQueued():n.queue=[]})):(t.getLog().warn("This browser doesn't support notifications.").sendInternalLogToServer(),this.permission=i.DENIED)},t.NotificationManager.prototype.show=function(e,n){if(this.permission===i.GRANTED)return this._showImpl({title:e,options:n});if(this.permission===i.DENIED)t.getLog().warn("Unable to show notification.").sendInternalLogToServer().withObject({title:e,options:n});else{var r={title:e,options:n};t.getLog().warn("Deferring notification until user decides to allow or deny.").withObject(r).sendInternalLogToServer(),this.queue.push(r)}},t.NotificationManager.prototype._showQueued=function(){var e=this,t=this.queue.map((function(t){return e._showImpl(t)}));return this.queue=[],t},t.NotificationManager.prototype._showImpl=function(t){var n=new e.Notification(t.title,t.options);return t.options.clicked&&(n.onclick=function(){t.options.clicked.call(n)}),n},t.ValueError=function(){var e=Array.prototype.slice.call(arguments,0),n=e.shift(),r=new Error(t.vsprintf(n,e));return Object.setPrototypeOf(r,t.ValueError.prototype),r},Object.setPrototypeOf(t.ValueError.prototype,Error.prototype),Object.setPrototypeOf(t.ValueError,Error),t.ValueError.prototype.name="ValueError",t.NotImplementedError=function(){var e=Array.prototype.slice.call(arguments,0),n=e.shift(),r=new Error(t.vsprintf(n,e));return Object.setPrototypeOf(r,t.NotImplementedError.prototype),r},Object.setPrototypeOf(t.NotImplementedError.prototype,Error.prototype),Object.setPrototypeOf(t.NotImplementedError,Error),t.NotImplementedError.prototype.name="NotImplementedError",t.StateError=function(){var e=Array.prototype.slice.call(arguments,0),n=e.shift(),r=new Error(t.vsprintf(n,e));return Object.setPrototypeOf(r,t.StateError.prototype),r},Object.setPrototypeOf(t.StateError.prototype,Error.prototype),Object.setPrototypeOf(t.StateError,Error),t.StateError.prototype.name="StateError",t.VoiceIdError=function(e,t,n){var r={};return r.type=e,r.message=t,r.stack=Error(t).stack,r.err=n,r},t.isCCP=function(){return"ConnectSharedWorkerConduit"===t.core.getUpstream().name}}()},736:()=>{!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,e.lily=t,t.worker={};var n=function(){this.topicMasterMap={}};n.prototype.getMaster=function(e){return t.assertNotNull(e,"topic"),this.topicMasterMap[e]||null},n.prototype.setMaster=function(e,n){t.assertNotNull(e,"topic"),t.assertNotNull(n,"id"),this.topicMasterMap[e]=n},n.prototype.removeMaster=function(e){t.assertNotNull(e,"id");var n=this;t.entries(this.topicMasterMap).filter((function(t){return t.value===e})).forEach((function(e){delete n.topicMasterMap[e.key]}))};var r=function(e){t.ClientBase.call(this),this.conduit=e};(r.prototype=Object.create(t.ClientBase.prototype)).constructor=r,r.prototype._callImpl=function(e,n,r){var o=this,i=(new Date).getTime();t.containsValue(t.AgentAppClientMethods,e)?t.core.getAgentAppClient()._callImpl(e,n,{success:function(t){o._recordAPILatency(e,i),r.success(t)},failure:function(t){o._recordAPILatency(e,i,t),r.failure(t)}}):t.containsValue(t.TaskTemplatesClientMethods,e)?t.core.getTaskTemplatesClient()._callImpl(e,n,{success:function(t){o._recordAPILatency(e,i),r.success(t)},failure:function(t){o._recordAPILatency(e,i,t),r.failure(t)}}):t.core.getClient()._callImpl(e,n,{success:function(t){o._recordAPILatency(e,i),r.success(t)},failure:function(t,n){o._recordAPILatency(e,i,t),r.failure(t,n)},authFailure:function(){o._recordAPILatency(e,i),r.authFailure()},accessDenied:function(){r.accessDenied&&r.accessDenied()}})},r.prototype._recordAPILatency=function(e,t,n){var r=(new Date).getTime()-t;this._sendAPIMetrics(e,r,n)},r.prototype._sendAPIMetrics=function(e,n,r){this.conduit.sendDownstream(t.EventType.API_METRIC,{name:e,time:n,dimensions:[{name:"Category",value:"API"}],error:r})};var o=function(){var o=this;this.multiplexer=new t.StreamMultiplexer,this.conduit=new t.Conduit("AmazonConnectSharedWorker",null,this.multiplexer),this.client=new r(this.conduit),this.timeout=null,this.agent=null,this.nextToken=null,this.initData={},this.portConduitMap={},this.streamMapByTabId={},this.masterCoord=new n,this.logsBuffer=[],this.suppress=!1,this.forceOffline=!1,this.longPollingOptions={allowLongPollingShadowMode:!1,allowLongPollingWebsocketOnlyMode:!1};var i=null;t.rootLogger=new t.DownstreamConduitLogger(this.conduit),this.conduit.onDownstream(t.EventType.SEND_LOGS,(function(e){t.getLog().pushLogsDownstream(e),o.logsBuffer=o.logsBuffer.concat(e),o.logsBuffer.length>400&&o.handleSendLogsRequest(o.logsBuffer)})),this.conduit.onDownstream(t.EventType.CONFIGURE,(function(n){console.log("@@@ configure event handler",n);try{n.authToken&&n.authToken!==o.initData.authToken&&(o.initData=n,t.core.init(n),n.longPollingOptions&&("boolean"==typeof n.longPollingOptions.allowLongPollingShadowMode&&(o.longPollingOptions.allowLongPollingShadowMode=n.longPollingOptions.allowLongPollingShadowMode),"boolean"==typeof n.longPollingOptions.allowLongPollingWebsocketOnlyMode&&(o.longPollingOptions.allowLongPollingWebsocketOnlyMode=n.longPollingOptions.allowLongPollingWebsocketOnlyMode)),i?t.getLog().info("Not Initializing a new WebsocketManager instance, since one already exists").sendInternalLogToServer():(t.getLog().info("Creating a new Websocket connection for CCP").sendInternalLogToServer(),t.WebSocketManager.setGlobalConfig({loggerConfig:{logger:t.getLog()}}),(i=t.WebSocketManager.create()).onInitFailure((function(){o.conduit.sendDownstream(t.WebSocketEvents.INIT_FAILURE)})),i.onConnectionOpen((function(e){o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_OPEN,e)})),i.onConnectionClose((function(e){o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_CLOSE,e)})),i.onConnectionGain((function(){o.conduit.sendDownstream(t.AgentEvents.WEBSOCKET_CONNECTION_GAINED),o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_GAIN)})),i.onConnectionLost((function(e){o.conduit.sendDownstream(t.AgentEvents.WEBSOCKET_CONNECTION_LOST,e),o.conduit.sendDownstream(t.WebSocketEvents.CONNECTION_LOST,e)})),i.onSubscriptionUpdate((function(e){o.conduit.sendDownstream(t.WebSocketEvents.SUBSCRIPTION_UPDATE,e)})),i.onSubscriptionFailure((function(e){o.conduit.sendDownstream(t.WebSocketEvents.SUBSCRIPTION_FAILURE,e)})),i.onAllMessage((function(e){o.conduit.sendDownstream(t.WebSocketEvents.ALL_MESSAGE,e)})),o.conduit.onDownstream(t.WebSocketEvents.SEND,(function(e){i.sendMessage(e)})),o.conduit.onDownstream(t.WebSocketEvents.SUBSCRIBE,(function(e){i.subscribeTopics(e)})),i.init(t.hitch(o,o.getWebSocketUrl)).then((function(n){try{if(n&&!n.webSocketConnectionFailed)t.getLog().info("Kicking off agent polling").sendInternalLogToServer(),o.pollForAgent(),t.getLog().info("Kicking off config polling").sendInternalLogToServer(),o.pollForAgentConfiguration({repeatForever:!0}),t.getLog().info("Kicking off auth token polling").sendInternalLogToServer(),e.setInterval(t.hitch(o,o.checkAuthToken),3e5);else if(!t.webSocketInitFailed){const e=t.WebSocketEvents.INIT_FAILURE;throw o.conduit.sendDownstream(e),t.webSocketInitFailed=!0,new Error(e)}}catch(e){t.getLog().error("WebSocket failed to initialize").withException(e).sendInternalLogToServer()}}))))}catch(e){console.error("@@@ error",e)}})),this.conduit.onDownstream(t.EventType.TERMINATE,(function(){o.handleSendLogsRequest(o.logsBuffer),t.core.terminate(),o.conduit.sendDownstream(t.EventType.TERMINATED)})),this.conduit.onDownstream(t.EventType.SYNCHRONIZE,(function(){o.conduit.sendDownstream(t.EventType.ACKNOWLEDGE)})),this.conduit.onDownstream(t.EventType.BROADCAST,(function(e){o.conduit.sendDownstream(e.event,e.data)})),e.onconnect=function(e){var n=e.ports[0],r=new t.PortStream(n);o.multiplexer.addStream(r),n.start();var i=new t.Conduit(r.getId(),null,r);i.sendDownstream(t.EventType.ACKNOWLEDGE,{id:r.getId()}),o.portConduitMap[r.getId()]=i,o.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(o.portConduitMap).length}),null!==o.agent&&o.updateAgent(),i.onDownstream(t.EventType.API_REQUEST,t.hitch(o,o.handleAPIRequest,i)),i.onDownstream(t.EventType.MASTER_REQUEST,t.hitch(o,o.handleMasterRequest,i,r.getId())),i.onDownstream(t.EventType.RELOAD_AGENT_CONFIGURATION,t.hitch(o,o.pollForAgentConfiguration)),i.onDownstream(t.EventType.TAB_ID,t.hitch(o,o.handleTabIdEvent,r)),i.onDownstream(t.EventType.CLOSE,t.hitch(o,o.handleCloseEvent,r))}};o.prototype.pollForAgent=function(){var n=this,r=t.hitch(n,n.handleAuthFail);this.client.call(t.ClientMethods.GET_AGENT_SNAPSHOT,{nextToken:n.nextToken,timeout:3e4},{success:function(r){try{n.agent=n.agent||{},n.agent.snapshot=r.snapshot,n.agent.snapshot.localTimestamp=t.now(),n.agent.snapshot.skew=n.agent.snapshot.snapshotTimestamp-n.agent.snapshot.localTimestamp,n.nextToken=r.nextToken,t.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(r).sendInternalLogToServer(),n.updateAgent()}catch(e){t.getLog().error("Long poll failed to update agent.").withObject(r).withException(e).sendInternalLogToServer()}finally{e.setTimeout(t.hitch(n,n.pollForAgent),100)}},failure:function(r,o){try{t.getLog().error("Failed to get agent data.").sendInternalLogToServer().withObject({err:r,data:o})}finally{e.setTimeout(t.hitch(n,n.pollForAgent),5e3)}},authFailure:function(){r()},accessDenied:t.hitch(n,n.handleAccessDenied)})},o.prototype.pollForAgentConfiguration=function(n){var r=this,o=n||{},i=t.hitch(r,r.handleAuthFail);this.client.call(t.ClientMethods.GET_AGENT_CONFIGURATION,{},{success:function(n){var i=n.configuration;r.pollForAgentPermissions(i),r.pollForAgentStates(i),r.pollForDialableCountryCodes(i),r.pollForRoutingProfileQueues(i),o.repeatForever&&e.setTimeout(t.hitch(r,r.pollForAgentConfiguration,o),3e4)},failure:function(n,i){try{t.getLog().error("Failed to fetch agent configuration data.").sendInternalLogToServer().withObject({err:n,data:i})}finally{o.repeatForever&&e.setTimeout(t.hitch(r,r.pollForAgentConfiguration),3e4,o)}},authFailure:function(){i()},accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForAgentStates=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_AGENT_STATES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForAgentStates(e,{states:(o.states||[]).concat(t.states),nextToken:t.nextToken,maxResults:o.maxResults}):(e.agentStates=(o.states||[]).concat(t.states),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch agent states list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForAgentPermissions=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_AGENT_PERMISSIONS,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForAgentPermissions(e,{permissions:(o.permissions||[]).concat(t.permissions),nextToken:t.nextToken,maxResults:o.maxResults}):(e.permissions=(o.permissions||[]).concat(t.permissions),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch agent permissions list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForDialableCountryCodes=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_DIALABLE_COUNTRY_CODES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForDialableCountryCodes(e,{countryCodes:(o.countryCodes||[]).concat(t.countryCodes),nextToken:t.nextToken,maxResults:o.maxResults}):(e.dialableCountries=(o.countryCodes||[]).concat(t.countryCodes),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch dialable country codes list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.pollForRoutingProfileQueues=function(e,n){var r=this,o=n||{};o.maxResults=o.maxResults||t.DEFAULT_BATCH_SIZE,this.client.call(t.ClientMethods.GET_ROUTING_PROFILE_QUEUES,{routingProfileARN:e.routingProfile.routingProfileARN,nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?r.pollForRoutingProfileQueues(e,{countryCodes:(o.queues||[]).concat(t.queues),nextToken:t.nextToken,maxResults:o.maxResults}):(e.routingProfile.queues=(o.queues||[]).concat(t.queues),r.updateAgentConfiguration(e))},failure:function(e,n){t.getLog().error("Failed to fetch routing profile queues list.").sendInternalLogToServer().withObject({err:e,data:n})},authFailure:t.hitch(r,r.handleAuthFail),accessDenied:t.hitch(r,r.handleAccessDenied)})},o.prototype.handleAPIRequest=function(e,n){var r=this;this.client.call(n.method,n.params,{success:function(r){var o=t.EventFactory.createResponse(t.EventType.API_RESPONSE,n,r);e.sendDownstream(o.event,o)},failure:function(o,i){var s=t.EventFactory.createResponse(t.EventType.API_RESPONSE,n,i,JSON.stringify(o));e.sendDownstream(s.event,s),t.getLog().error("'%s' API request failed",n.method).withObject({request:r.filterAuthToken(n),response:s}).withException(o).sendInternalLogToServer()},authFailure:t.hitch(r,r.handleAuthFail,{authorize:!0})})},o.prototype.handleMasterRequest=function(e,n,r){var o=this.conduit,i=null;switch(r.method){case t.MasterMethods.BECOME_MASTER:var s=this.masterCoord.getMaster(r.params.topic),a=Boolean(s)&&s!==n;this.masterCoord.setMaster(r.params.topic,n),i=t.EventFactory.createResponse(t.EventType.MASTER_RESPONSE,r,{masterId:n,takeOver:a,topic:r.params.topic}),a&&o.sendDownstream(i.event,i);break;case t.MasterMethods.CHECK_MASTER:(s=this.masterCoord.getMaster(r.params.topic))||r.params.shouldNotBecomeMasterIfNone||(this.masterCoord.setMaster(r.params.topic,n),s=n),i=t.EventFactory.createResponse(t.EventType.MASTER_RESPONSE,r,{masterId:s,isMaster:n===s,topic:r.params.topic});break;default:throw new Error("Unknown master method: "+r.method)}e.sendDownstream(i.event,i)},o.prototype.handleTabIdEvent=function(e,n){var r=this;try{let o=n.tabId,i=r.streamMapByTabId[o],s=e.getId(),a=Object.keys(r.streamMapByTabId).filter((e=>r.streamMapByTabId[e].length>0)).length;if(i&&i.length>0){if(!i.includes(s)){r.streamMapByTabId[o].push(s);let e={length:Object.keys(r.portConduitMap).length,tabId:o,streamsTabsAcrossBrowser:a};e[o]={length:i.length},r.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,e)}}else{r.streamMapByTabId[o]=[e.getId()];let n={length:Object.keys(r.portConduitMap).length,tabId:o,streamsTabsAcrossBrowser:a+1};n[o]={length:r.streamMapByTabId[o].length},r.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,n)}}catch(e){t.getLog().error("[Tab Ids] Issue updating connected CCPs within the same tab").withException(e).sendInternalLogToServer()}},o.prototype.handleCloseEvent=function(e){var n=this;n.multiplexer.removeStream(e),delete n.portConduitMap[e.getId()],n.masterCoord.removeMaster(e.getId());let r={length:Object.keys(n.portConduitMap).length},o=Object.keys(n.streamMapByTabId);try{let t=o.find((t=>n.streamMapByTabId[t].includes(e.getId())));if(t){let o=n.streamMapByTabId[t].findIndex((t=>e.getId()===t));n.streamMapByTabId[t].splice(o,1);let i=n.streamMapByTabId[t]?n.streamMapByTabId[t].length:0;r[t]={length:i},r.tabId=t}let i=o.filter((e=>n.streamMapByTabId[e].length>0)).length;r.streamsTabsAcrossBrowser=i}catch(e){t.getLog().error("[Tab Ids] Issue updating tabId-specific stream data").withException(e).sendInternalLogToServer()}n.conduit.sendDownstream(t.EventType.UPDATE_CONNECTED_CCPS,r)},o.prototype.updateAgentConfiguration=function(e){e.permissions&&e.dialableCountries&&e.agentStates&&e.routingProfile.queues?(this.agent=this.agent||{},this.agent.configuration=e,this.updateAgent()):t.getLog().trace("Waiting to update agent configuration until all config data has been fetched.").sendInternalLogToServer()},o.prototype.updateAgent=function(){this.agent?this.agent.snapshot?this.agent.configuration?(this.agent.snapshot.status=this.agent.state,this.agent.snapshot.contacts&&this.agent.snapshot.contacts.length>1&&this.agent.snapshot.contacts.sort((function(e,t){return e.state.timestamp.getTime()-t.state.timestamp.getTime()})),this.agent.snapshot.contacts.forEach((function(e){e.status=e.state,e.connections.forEach((function(e){e.address=e.endpoint}))})),this.agent.configuration.routingProfile.defaultOutboundQueue.queueId=this.agent.configuration.routingProfile.defaultOutboundQueue.queueARN,this.agent.configuration.routingProfile.queues.forEach((function(e){e.queueId=e.queueARN})),this.agent.snapshot.contacts.forEach((function(e){void 0!==e.queue&&(e.queue.queueId=e.queue.queueARN)})),this.agent.configuration.routingProfile.routingProfileId=this.agent.configuration.routingProfile.routingProfileARN,this.conduit.sendDownstream(t.AgentEvents.UPDATE,this.agent)):t.getLog().trace("Waiting to update agent until the agent configuration is available.").sendInternalLogToServer():t.getLog().trace("Waiting to update agent until the agent snapshot is available.").sendInternalLogToServer():t.getLog().trace("Waiting to update agent until the agent has been fully constructed.").sendInternalLogToServer()},o.prototype.getWebSocketUrl=function(){var e=this,n=t.core.getClient(),r=t.hitch(e,e.handleAuthFail),o=t.hitch(e,e.handleAccessDenied);return new Promise((function(e,i){n.call(t.ClientMethods.CREATE_TRANSPORT,{transportType:t.TRANSPORT_TYPES.WEB_SOCKET},{success:function(n){t.getLog().info("getWebSocketUrl succeeded").sendInternalLogToServer(),e(n)},failure:function(e,n){t.getLog().error("getWebSocketUrl failed").sendInternalLogToServer().withObject({err:e,data:n}),i({reason:"getWebSocketUrl failed",_debug:e})},authFailure:function(){t.getLog().error("getWebSocketUrl Auth Failure").sendInternalLogToServer(),i(Error("Authentication failed while getting getWebSocketUrl")),r()},accessDenied:function(){t.getLog().error("getWebSocketUrl Access Denied Failure").sendInternalLogToServer(),i(Error("Access Denied Failure while getting getWebSocketUrl")),o()}})}))},o.prototype.handleSendLogsRequest=function(){var e=this,n=[],r=e.logsBuffer.slice();e.logsBuffer=[],r.forEach((function(e){n.push({timestamp:e.time,component:e.component,message:e.text})})),this.client.call(t.ClientMethods.SEND_CLIENT_LOGS,{logEvents:n},{success:function(e){t.getLog().info("SendLogs request succeeded.").sendInternalLogToServer()},failure:function(e,n){t.getLog().error("SendLogs request failed.").withObject(n).withException(e).sendInternalLogToServer()},authFailure:t.hitch(e,e.handleAuthFail)})},o.prototype.handleAuthFail=function(e){e?this.conduit.sendDownstream(t.EventType.AUTH_FAIL,e):this.conduit.sendDownstream(t.EventType.AUTH_FAIL)},o.prototype.handleAccessDenied=function(){this.conduit.sendDownstream(t.EventType.ACCESS_DENIED)},o.prototype.checkAuthToken=function(){var e=this,n=new Date(e.initData.authTokenExpiration),r=(new Date).getTime();n.getTime()(e.paths=[],e.children||(e.children=[]),e),n(827),n(163),n(944),n(151),n(891),n(592),n(82),n(754),n(833),n(965),n(286),n(895),n(743),n(642),n(736),n(439),n(279),n(418),n(187),n(821),n(500)})(); \ No newline at end of file diff --git a/release/connect-streams.js b/release/connect-streams.js index 7d309d9c..0dcad0f9 100644 --- a/release/connect-streams.js +++ b/release/connect-streams.js @@ -3795,7 +3795,8 @@ module.exports = cloneDeep; client.call(connect.AgentAppClientMethods.UPDATE_SESSION, params, { success: function (data) { connect.getLog().info("updateSpeakerIdInVoiceId succeeded").withObject(data).sendInternalLogToServer(); - self._updateSpeakerIdInLcms(speakerId, data.generatedSpeakerId) + var generatedSpeakerId = data && data.Session && data.Session.GeneratedSpeakerId; + self._updateSpeakerIdInLcms(speakerId, generatedSpeakerId) .then(function() { resolve(data); }) @@ -27482,7 +27483,7 @@ AWS.apiLoader.services['connect']['2017-02-15'] = require('../apis/connect-2017- connect.core = {}; connect.core.initialized = false; - connect.version = "2.4.1"; + connect.version = "2.4.2"; connect.DEFAULT_BATCH_SIZE = 500; var CCP_SYN_TIMEOUT = 1000; // 1 sec diff --git a/src/api.js b/src/api.js index 9df088fa..3a1e90b6 100644 --- a/src/api.js +++ b/src/api.js @@ -1846,7 +1846,8 @@ client.call(connect.AgentAppClientMethods.UPDATE_SESSION, params, { success: function (data) { connect.getLog().info("updateSpeakerIdInVoiceId succeeded").withObject(data).sendInternalLogToServer(); - self._updateSpeakerIdInLcms(speakerId, data.generatedSpeakerId) + var generatedSpeakerId = data && data.Session && data.Session.GeneratedSpeakerId; + self._updateSpeakerIdInLcms(speakerId, generatedSpeakerId) .then(function() { resolve(data); }) diff --git a/test/unit/voiceid.spec.js b/test/unit/voiceid.spec.js index a880b185..5b2f9d6c 100644 --- a/test/unit/voiceid.spec.js +++ b/test/unit/voiceid.spec.js @@ -1161,7 +1161,11 @@ describe('VoiceId', () => { describe('updateSpeakerIdInVoiceId', () => { it('should get resolved with data', async () => { - const response = 'fakeData'; + const response = { + Session: { + GeneratedSpeakerId: 'dummy-generated-speaker-id' + } + }; sinon.stub(connect.core, 'getClient').callsFake(() => ({ call: (endpoint, params, callbacks) => { callbacks.success(response); @@ -1175,7 +1179,7 @@ describe('VoiceId', () => { expect(obj).to.equal(response); sinon.assert.calledOnce(voiceId.checkConferenceCall); sinon.assert.calledOnce(voiceId.getDomainId); - sinon.assert.calledOnce(voiceId._updateSpeakerIdInLcms); + sinon.assert.calledWith(voiceId._updateSpeakerIdInLcms, speakerId, 'dummy-generated-speaker-id'); connect.core.getClient.restore(); });