diff --git a/package-lock.json b/package-lock.json index fc78a0a..96ee5eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "amazon-connect-streams", - "version": "1.8.2", + "version": "1.8.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "amazon-connect-streams", - "version": "1.8.2", + "version": "1.8.3", "license": "Apache-2.0", "devDependencies": { "@babel/preset-env": "^7.21.4", diff --git a/package.json b/package.json index df7d91a..c72f252 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amazon-connect-streams", - "version": "1.8.2", + "version": "1.8.3", "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 741f844..b07ed15 100644 --- a/release/connect-streams-min.js +++ b/release/connect-streams-min.js @@ -1 +1 @@ -(()=>{var e={340:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect,connect.agentApp={};var t="ccp";connect.agentApp.initCCP=connect.core.initCCP,connect.agentApp.isInitialized=function(e){},connect.agentApp.initAppCommunication=function(e,t){var n=document.getElementById(e),o=new connect.IFrameConduit(t,window,n),r=[connect.AgentEvents.UPDATE,connect.ContactEvents.VIEW,connect.EventType.ACKNOWLEDGE,connect.EventType.TERMINATED,connect.TaskEvents.CREATED];n.addEventListener("load",(function(e){r.forEach((function(e){connect.core.getUpstream().onUpstream(e,(function(t){o.sendUpstream(e,t)}))}))}))};var n=function(e){var t=e.indexOf("ccp-v2");return e.slice(0,t-1)};connect.agentApp.initApp=function(e,o,r,i){i=i||{};var s=r.endsWith("/")?r:r+"/",c=i.onLoad?i.onLoad:null,a={endpoint:s,style:i.style,onLoad:c};connect.agentApp.AppRegistry.register(e,a,document.getElementById(o)),connect.agentApp.AppRegistry.start(e,(function(o){var r=o.endpoint,s=o.containerDOM;return{init:function(){return e===t?function(e,t,o){var r={ccpUrl:e,ccpLoadTimeout:1e4,loginPopup:!0,loginUrl:n(e)+"/login",softphone:{allowFramedSoftphone:!0,disableRingtone:!1}},i=connect.merge(r,o.ccpParams);connect.core.initCCP(t,i)}(r,s,i):connect.agentApp.initAppCommunication(e,r)},destroy:function(){return e===t?(o=n(r)+"/logout",connect.fetch(o,{credentials:"include"}).then((function(){return connect.core.getEventBus().trigger(connect.EventType.TERMINATE),!0})).catch((function(e){return connect.getLog().error("An error occured on logout."+e).withException(e),window.location.href=o,!1}))):null;var o}}}))},connect.agentApp.stopApp=function(e){return connect.agentApp.AppRegistry.stop(e)}}()},228:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect;var t,n="ccp";e.connect.agentApp.AppRegistry=(t={},{register:function(e,n,o){t[e]={containerDOM:o,endpoint:n.endpoint,style:n.style,instance:void 0,onLoad:n.onLoad}},start:function(e,o){if(t[e]){var r=t[e].containerDOM,i=t[e].endpoint,s=t[e].style,c=t[e].onLoad;if(e!==n){var a=function(e,t,n,o){var r=document.createElement("iframe");return r.src=t,r.style=n||"width: 100%; height:100%;",r.id=e,r["aria-label"]=e,r.onload=o,r.setAttribute("sandbox","allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"),r}(e,i,s,c);r.appendChild(a)}return t[e].instance=o(t[e]),t[e].instance.init()}},stop:function(e){if(t[e]){var n,o=t[e],r=o.containerDOM.querySelector("iframe");return o.containerDOM.removeChild(r),o.instance&&(n=o.instance.destroy(),delete o.instance),n}}})}()},35:()=>{function e(e,n){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,n){if(e){if("string"==typeof e)return t(e,n);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){o&&(e=o);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,c=!0,a=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return c=e.done,e},e:function(e){a=!0,s=e},f:function(){try{c||null==o.return||o.return()}finally{if(a)throw s}}}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&(n=r[0].getConnectionId())}t.call(connect.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:n},e)},r.prototype.sendSoftphoneMetrics=function(e,n){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:t.ccpVersion,softphoneStreamStatistics:e},n),connect.publishSoftphoneStats({contactId:this.getContactId(),ccpVersion:t.ccpVersion,stats:e})},r.prototype.sendSoftphoneReport=function(e,n){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:t.ccpVersion,report:e},n),connect.publishSoftphoneReport({contactId:this.getContactId(),ccpVersion:t.ccpVersion,report:e})},r.prototype.conferenceConnections=function(e){connect.core.getClient().call(connect.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},r.prototype.toSnapshot=function(){return new connect.ContactSnapshot(this._getData())};var i=function(e){connect.Contact.call(this,e.contactId),this.contactData=e};(i.prototype=Object.create(r.prototype)).constructor=i,i.prototype._getData=function(){return this.contactData},i.prototype._createConnectionAPI=function(e){return new connect.ConnectionSnapshot(e)};var s=function(e,t){this.contactId=e,this.connectionId=t,this._initMediaController()};s.prototype._getData=function(){return connect.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 connect.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 connect.now()-this._getData().state.timestamp.getTime()+connect.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 connect.contains(connect.CONNECTION_ACTIVE_STATES,this.getStatus().type)},s.prototype.isConnected=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTED},s.prototype.isConnecting=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTING},s.prototype.isOnHold=function(){return this.getStatus().type===connect.ConnectionStateType.HOLD},s.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMonitorInfo=function(){return this._getData().monitoringInfo},s.prototype.destroy=function(e){connect.core.getClient().call(connect.ClientMethods.DESTROY_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.sendDigits=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_DIGITS,{contactId:this.getContactId(),connectionId:this.getConnectionId(),digits:e},t)},s.prototype.hold=function(e){connect.core.getClient().call(connect.ClientMethods.HOLD_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.resume=function(e){connect.core.getClient().call(connect.ClientMethods.RESUME_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.toSnapshot=function(){return new connect.ConnectionSnapshot(this._getData())},s.prototype._initMediaController=function(){this.getMediaInfo()&&connect.core.mediaFactory.get(this).catch((function(){}))},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING};var c=function(e){this.contactId=e};c.prototype.getSpeakerId=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){t.call(connect.AgentAppClientMethods.GET_CONTACT,{contactId:e.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),awsAccountId:connect.core.getAgentDataProvider().getAWSAccountId()},{success:function(e){if(e.contactData.customerId){var t={speakerId:e.contactData.customerId};connect.getLog().info("getSpeakerId succeeded").withObject(e).sendInternalLogToServer(),n(t)}else{var r=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_SPEAKER_ID_FOUND,"No speakerId assotiated with this call");o(r)}},failure:function(e){connect.getLog().error("Get SpeakerId failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_ID_FAILED,"Get SpeakerId failed",e);o(t)}})}))},c.prototype.getSpeakerStatus=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getSpeakerId().then((function(r){e.getDomainId().then((function(e){t.call(connect.AgentAppClientMethods.DESCRIBE_SPEAKER,{SpeakerId:connect.assertNotNull(r.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("getSpeakerStatus succeeded").withObject(e).sendInternalLogToServer(),n(e)},failure:function(e){var t=JSON.parse(e);switch(t.status){case 400:case 404:var r=t;r.type=r.type?r.type:connect.VoiceIdErrorTypes.SPEAKER_ID_NOT_ENROLLED,connect.getLog().info("Speaker is not enrolled.").sendInternalLogToServer(),n(r);break;default:connect.getLog().error("getSpeakerStatus failed").withObject({err:e}).sendInternalLogToServer();var i=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_STATUS_FAILED,"Get SpeakerStatus failed",e);o(i)}}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},c.prototype._optOutSpeakerInLcms=function(e){var t=this,n=connect.core.getClient();return new Promise((function(o,r){n.call(connect.AgentAppClientMethods.UPDATE_VOICE_ID_DATA,{ContactId:t.contactId,InstanceId:connect.core.getAgentDataProvider().getInstanceId(),AWSAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),CustomerId:connect.assertNotNull(e,"speakerId"),VoiceIdResult:{SpeakerOptedOut:!0}},{success:function(e){connect.getLog().info("optOutSpeakerInLcms succeeded").withObject(e).sendInternalLogToServer(),o(e)},failure:function(e){connect.getLog().error("optOutSpeakerInLcms failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_IN_LCMS_FAILED,"optOutSpeakerInLcms failed",e);r(t)}})}))},c.prototype.optOutSpeaker=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getSpeakerId().then((function(r){e.getDomainId().then((function(i){var s=r.speakerId;t.call(connect.AgentAppClientMethods.OPT_OUT_SPEAKER,{SpeakerId:connect.assertNotNull(s,"speakerId"),DomainId:i},{success:function(t){e._optOutSpeakerInLcms(s).catch((function(){})),connect.getLog().info("optOutSpeaker succeeded").withObject(t).sendInternalLogToServer(),n(t)},failure:function(e){connect.getLog().error("optOutSpeaker failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_FAILED,"optOutSpeaker failed.",e);o(t)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},c.prototype.deleteSpeaker=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getSpeakerId().then((function(r){e.getDomainId().then((function(e){t.call(connect.AgentAppClientMethods.DELETE_SPEAKER,{SpeakerId:connect.assertNotNull(r.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("deleteSpeaker succeeded").withObject(e).sendInternalLogToServer(),n(e)},failure:function(e){connect.getLog().error("deleteSpeaker failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.DELETE_SPEAKER_FAILED,"deleteSpeaker failed.",e);o(t)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},c.prototype.startSession=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getDomainId().then((function(r){t.call(connect.AgentAppClientMethods.START_VOICE_ID_SESSION,{contactId:e.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),customerAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),clientToken:AWS.util.uuid.v4(),domainId:r},{success:function(e){if(e.sessionId)n(e);else{connect.getLog().error("startVoiceIdSession failed, no session id returned").withObject({data:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"No session id returned from start session api");o(t)}},failure:function(e){connect.getLog().error("startVoiceIdSession failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"startVoiceIdSession failed",e);o(t)}})})).catch((function(e){o(e)}))}))},c.prototype.evaluateSpeaker=function(e){var t=this;t.checkConferenceCall();var n=connect.core.getClient(),o=connect.core.getAgentDataProvider().getContactData(this.contactId),r=0;return new Promise((function(i,s){function c(){t.getDomainId().then((function(e){n.call(connect.AgentAppClientMethods.EVALUATE_SESSION,{SessionNameOrId:o.initialContactId||this.contactId,DomainId:e},{success:function(e){if(++r=1&&(o=n.IntegrationAssociationSummaryList[0].IntegrationArn.replace(/^.*domain\//i,"")),!o){connect.getLog().info("getDomainId: no domainId found").sendInternalLogToServer();var r=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_DOMAIN_ID_FOUND);return void t(r)}connect.getLog().info("getDomainId succeeded").withObject(n).sendInternalLogToServer(),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.VoiceIdEvents.UPDATE_DOMAIN_ID,data:{domainId:o}}),e(o)}catch(e){connect.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer(),r=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e),t(r)}},failure:function(e){connect.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer();var n=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e);t(n)}}):t(new Error("Agent doesn't have the permission for Voice ID"))}))},c.prototype.checkConferenceCall=function(){if(connect.core.getAgentDataProvider().getContactData(this.contactId).connections.filter((function(e){return connect.contains(connect.CONNECTION_ACTIVE_STATES,e.state.type)})).length>2)throw new connect.NotImplementedError("VoiceId is not supported for conference calls")},c.prototype.isAuthEnabled=function(e){return e!==connect.ContactFlowAuthenticationDecision.NOT_ENABLED},c.prototype.isAuthResultNotEnoughSpeech=function(e){return e===connect.VoiceIdAuthenticationDecision.NOT_ENOUGH_SPEECH},c.prototype.isAuthResultInconclusive=function(e){return e===connect.ContactFlowAuthenticationDecision.INCONCLUSIVE},c.prototype.isFraudEnabled=function(e){return e!==connect.ContactFlowFraudDetectionDecision.NOT_ENABLED},c.prototype.isFraudResultNotEnoughSpeech=function(e){return e===connect.VoiceIdFraudDetectionDecision.NOT_ENOUGH_SPEECH},c.prototype.isFraudResultInconclusive=function(e){return e===connect.ContactFlowFraudDetectionDecision.INCONCLUSIVE};var a=function(e,t){this._speakerAuthenticator=new c(e),s.call(this,e,t)};(a.prototype=Object.create(s.prototype)).constructor=a,a.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},a.prototype.getMediaInfo=function(){return this._getData().softphoneMediaInfo},a.prototype.getMediaType=function(){return connect.MediaType.SOFTPHONE},a.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)},a.prototype.getVoiceIdSpeakerId=function(){return this._speakerAuthenticator.getSpeakerId()},a.prototype.getVoiceIdSpeakerStatus=function(){return this._speakerAuthenticator.getSpeakerStatus()},a.prototype.optOutVoiceIdSpeaker=function(){return this._speakerAuthenticator.optOutSpeaker()},a.prototype.deleteVoiceIdSpeaker=function(){return this._speakerAuthenticator.deleteSpeaker()},a.prototype.evaluateSpeakerWithVoiceId=function(e){return this._speakerAuthenticator.evaluateSpeaker(e)},a.prototype.enrollSpeakerInVoiceId=function(){return this._speakerAuthenticator.enrollSpeaker()},a.prototype.updateVoiceIdSpeakerId=function(e){return this._speakerAuthenticator.updateSpeakerIdInVoiceId(e)},a.prototype.getQuickConnectName=function(){return this._getData().quickConnectName},a.prototype.isMute=function(){return this._getData().mute},a.prototype.muteParticipant=function(e){connect.core.getClient().call(connect.ClientMethods.MUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},a.prototype.unmuteParticipant=function(e){connect.core.getClient().call(connect.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 t=connect.core.getAgentDataProvider().getContactData(this.contactId),n={contactId:this.contactId,initialContactId:t.initialContactId||this.contactId,participantId:this.connectionId,getConnectionToken:connect.hitch(this,this.getConnectionToken)};if(e.connectionData)try{n.participantToken=JSON.parse(e.connectionData).ConnectionAuthenticationToken}catch(t){connect.getLog().error(connect.LogComponent.CHAT,"Connection data is invalid").withObject(e).withException(t).sendInternalLogToServer(),n.participantToken=null}return n.participantToken=n.participantToken||null,n.originalInfo=this._getData().chatMediaInfo,n}return null},u.prototype.getConnectionToken=function(){client=connect.core.getClient();var e=connect.core.getAgentDataProvider().getContactData(this.contactId),t={transportType:connect.TRANSPORT_TYPES.CHAT_TOKEN,participantId:this.connectionId,contactId:e.initialContactId||this.contactId};return new Promise((function(e,n){client.call(connect.ClientMethods.CREATE_TRANSPORT,t,{success:function(t){connect.getLog().info("getConnectionToken succeeded").sendInternalLogToServer(),e(t)},failure:function(e,t){connect.getLog().error("getConnectionToken failed").sendInternalLogToServer().withObject({err:e,data:t}),n(Error("getConnectionToken failed"))}})}))},u.prototype.getMediaType=function(){return connect.MediaType.CHAT},u.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)},u.prototype._initMediaController=function(){this._isAgentConnectionType()&&connect.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 connect.MediaType.TASK},l.prototype.getMediaInfo=function(){var e=connect.core.getAgentDataProvider().getContactData(this.contactId);return{contactId:this.contactId,initialContactId:e.initialContactId||this.contactId}},l.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)};var p=function(e){connect.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 h=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};h.prototype.stripPhoneNumber=function(){return this.phoneNumber?this.phoneNumber.replace(/sip:([^@]*)@.*/,"$1"):""},h.byPhoneNumber=function(e,t){return new h({type:connect.EndpointType.PHONE_NUMBER,phoneNumber:e,name:t||null})};var d=function(e,t,n){this.errorType=e,this.errorMessage=t,this.endPointUrl=n};d.prototype.getErrorType=function(){return this.errorType},d.prototype.getErrorMessage=function(){return this.errorMessage},d.prototype.getEndPointUrl=function(){return this.endPointUrl},connect.agent=function(e){var t=connect.core.getEventBus().subscribe(connect.AgentEvents.INIT,e);return connect.agent.initialized&&e(new connect.Agent),t},connect.agent.initialized=!1,connect.contact=function(e){return connect.core.getEventBus().subscribe(connect.ContactEvents.INIT,e)},connect.onWebsocketInitFailure=function(e){var t=connect.core.getEventBus().subscribe(connect.WebSocketEvents.INIT_FAILURE,e);return connect.webSocketInitFailed&&e(),t},connect.ifMaster=function(e,t,n,o){if(connect.assertNotNull(e,"A topic must be provided."),connect.assertNotNull(t,"A true callback must be provided."),!connect.core.masterClient)return connect.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e).sendInternalLogToServer(),void(n&&n());connect.core.getMasterClient().call(connect.MasterMethods.CHECK_MASTER,{topic:e,shouldNotBecomeMasterIfNone:o},{success:function(e){e.isMaster?t():n&&n()}})},connect.becomeMaster=function(e,t,n){connect.assertNotNull(e,"A topic must be provided."),connect.core.masterClient?connect.core.getMasterClient().call(connect.MasterMethods.BECOME_MASTER,{topic:e},{success:function(){t&&t()}}):(connect.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e),n&&n())},connect.Agent=n,connect.AgentSnapshot=o,connect.Contact=r,connect.ContactSnapshot=i,connect.Connection=a,connect.BaseConnection=s,connect.VoiceConnection=a,connect.ChatConnection=u,connect.TaskConnection=l,connect.ConnectionSnapshot=p,connect.Endpoint=h,connect.Address=h,connect.SoftphoneError=d,connect.VoiceId=c}()},538:(e,t,n)=>{var o;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},r(e)}!function e(t,n,o){function r(s,c){if(!n[s]){if(!t[s]){if(i)return i(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,n,o)}return n[s].exports}for(var i=void 0,s=0;s-1});var r=["[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 o(e,"utf8")),ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}}},{"buffer/":81}],12:[function(e,t,n){var o=e("./browserHashUtils");function r(e,t){this.hash=new e,this.outer=new e;var n=function(e,t){var n=o.convertToBuffer(t);if(n.byteLength>e.BLOCK_SIZE){var r=new e;r.update(n),n=r.digest()}var i=new Uint8Array(e.BLOCK_SIZE);return i.set(n),i}(e,t),r=new Uint8Array(e.BLOCK_SIZE);r.set(n);for(var i=0;i>>32-r)+n&4294967295}function a(e,t,n,o,r,i,s){return c(t&n|~t&o,e,t,r,i,s)}function u(e,t,n,o,r,i,s){return c(t&o|n&~o,e,t,r,i,s)}function l(e,t,n,o,r,i,s){return c(t^n^o,e,t,r,i,s)}function p(e,t,n,o,r,i,s){return c(n^(t|~o),e,t,r,i,s)}t.exports=s,s.BLOCK_SIZE=i,s.prototype.update=function(e){if(o.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=o.convertToBuffer(e),n=0,r=t.byteLength;for(this.bytesHashed+=r;r>0;)this.buffer.setUint8(this.bufferLength++,t[n++]),r--,this.bufferLength===i&&(this.hashBuffer(),this.bufferLength=0);return this},s.prototype.digest=function(e){if(!this.finished){var t=this,n=t.buffer,o=t.bufferLength,s=8*t.bytesHashed;if(n.setUint8(this.bufferLength++,128),o%i>=56){for(var c=this.bufferLength;c>>0,!0),n.setUint32(60,Math.floor(s/4294967296),!0),this.hashBuffer(),this.finished=!0}var a=new DataView(new ArrayBuffer(16));for(c=0;c<4;c++)a.setUint32(4*c,this.state[c],!0);var u=new r(a.buffer,a.byteOffset,a.byteLength);return e?u.toString(e):u},s.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=t[0],o=t[1],r=t[2],i=t[3];n=a(n,o,r,i,e.getUint32(0,!0),7,3614090360),i=a(i,n,o,r,e.getUint32(4,!0),12,3905402710),r=a(r,i,n,o,e.getUint32(8,!0),17,606105819),o=a(o,r,i,n,e.getUint32(12,!0),22,3250441966),n=a(n,o,r,i,e.getUint32(16,!0),7,4118548399),i=a(i,n,o,r,e.getUint32(20,!0),12,1200080426),r=a(r,i,n,o,e.getUint32(24,!0),17,2821735955),o=a(o,r,i,n,e.getUint32(28,!0),22,4249261313),n=a(n,o,r,i,e.getUint32(32,!0),7,1770035416),i=a(i,n,o,r,e.getUint32(36,!0),12,2336552879),r=a(r,i,n,o,e.getUint32(40,!0),17,4294925233),o=a(o,r,i,n,e.getUint32(44,!0),22,2304563134),n=a(n,o,r,i,e.getUint32(48,!0),7,1804603682),i=a(i,n,o,r,e.getUint32(52,!0),12,4254626195),r=a(r,i,n,o,e.getUint32(56,!0),17,2792965006),n=u(n,o=a(o,r,i,n,e.getUint32(60,!0),22,1236535329),r,i,e.getUint32(4,!0),5,4129170786),i=u(i,n,o,r,e.getUint32(24,!0),9,3225465664),r=u(r,i,n,o,e.getUint32(44,!0),14,643717713),o=u(o,r,i,n,e.getUint32(0,!0),20,3921069994),n=u(n,o,r,i,e.getUint32(20,!0),5,3593408605),i=u(i,n,o,r,e.getUint32(40,!0),9,38016083),r=u(r,i,n,o,e.getUint32(60,!0),14,3634488961),o=u(o,r,i,n,e.getUint32(16,!0),20,3889429448),n=u(n,o,r,i,e.getUint32(36,!0),5,568446438),i=u(i,n,o,r,e.getUint32(56,!0),9,3275163606),r=u(r,i,n,o,e.getUint32(12,!0),14,4107603335),o=u(o,r,i,n,e.getUint32(32,!0),20,1163531501),n=u(n,o,r,i,e.getUint32(52,!0),5,2850285829),i=u(i,n,o,r,e.getUint32(8,!0),9,4243563512),r=u(r,i,n,o,e.getUint32(28,!0),14,1735328473),n=l(n,o=u(o,r,i,n,e.getUint32(48,!0),20,2368359562),r,i,e.getUint32(20,!0),4,4294588738),i=l(i,n,o,r,e.getUint32(32,!0),11,2272392833),r=l(r,i,n,o,e.getUint32(44,!0),16,1839030562),o=l(o,r,i,n,e.getUint32(56,!0),23,4259657740),n=l(n,o,r,i,e.getUint32(4,!0),4,2763975236),i=l(i,n,o,r,e.getUint32(16,!0),11,1272893353),r=l(r,i,n,o,e.getUint32(28,!0),16,4139469664),o=l(o,r,i,n,e.getUint32(40,!0),23,3200236656),n=l(n,o,r,i,e.getUint32(52,!0),4,681279174),i=l(i,n,o,r,e.getUint32(0,!0),11,3936430074),r=l(r,i,n,o,e.getUint32(12,!0),16,3572445317),o=l(o,r,i,n,e.getUint32(24,!0),23,76029189),n=l(n,o,r,i,e.getUint32(36,!0),4,3654602809),i=l(i,n,o,r,e.getUint32(48,!0),11,3873151461),r=l(r,i,n,o,e.getUint32(60,!0),16,530742520),n=p(n,o=l(o,r,i,n,e.getUint32(8,!0),23,3299628645),r,i,e.getUint32(0,!0),6,4096336452),i=p(i,n,o,r,e.getUint32(28,!0),10,1126891415),r=p(r,i,n,o,e.getUint32(56,!0),15,2878612391),o=p(o,r,i,n,e.getUint32(20,!0),21,4237533241),n=p(n,o,r,i,e.getUint32(48,!0),6,1700485571),i=p(i,n,o,r,e.getUint32(12,!0),10,2399980690),r=p(r,i,n,o,e.getUint32(40,!0),15,4293915773),o=p(o,r,i,n,e.getUint32(4,!0),21,2240044497),n=p(n,o,r,i,e.getUint32(32,!0),6,1873313359),i=p(i,n,o,r,e.getUint32(60,!0),10,4264355552),r=p(r,i,n,o,e.getUint32(24,!0),15,2734768916),o=p(o,r,i,n,e.getUint32(52,!0),21,1309151649),n=p(n,o,r,i,e.getUint32(16,!0),6,4149444226),i=p(i,n,o,r,e.getUint32(44,!0),10,3174756917),r=p(r,i,n,o,e.getUint32(8,!0),15,718787259),o=p(o,r,i,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=o+t[1]&4294967295,t[2]=r+t[2]&4294967295,t[3]=i+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":81}],14:[function(e,t,n){var o=e("buffer/").Buffer,r=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(r.isEmptyData(e))return this;var t=(e=r.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 o(20),r=new DataView(n.buffer);return r.setUint32(0,this.h0,!1),r.setUint32(4,this.h1,!1),r.setUint32(8,this.h2,!1),r.setUint32(12,this.h3,!1),r.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,o,r=this.h0,i=this.h1,s=this.h2,c=this.h3,a=this.h4;for(e=0;e<80;e++){e<20?(n=c^i&(s^c),o=1518500249):e<40?(n=i^s^c,o=1859775393):e<60?(n=i&s|c&(i|s),o=2400959708):(n=i^s^c,o=3395469782);var u=(r<<5|r>>>27)+n+a+o+(0|this.block[e]);a=c,c=s,s=i<<30|i>>>2,i=r,r=u}for(this.h0=this.h0+r|0,this.h1=this.h1+i|0,this.h2=this.h2+s|0,this.h3=this.h3+c|0,this.h4=this.h4+a|0,this.offset=0,e=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":81}],15:[function(e,t,n){var o=e("buffer/").Buffer,r=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]),c=Math.pow(2,53)-1;function a(){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=a,a.BLOCK_SIZE=i,a.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(r.isEmptyData(e))return this;var t=0,n=(e=r.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>c)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},a.prototype.digest=function(e){if(!this.finished){var t=8*this.bytesHashed,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),r=this.bufferLength;if(n.setUint8(this.bufferLength++,128),r%i>=56){for(var s=this.bufferLength;s>>24&255,c[4*s+1]=this.state[s]>>>16&255,c[4*s+2]=this.state[s]>>>8&255,c[4*s+3]=this.state[s]>>>0&255;return e?c.toString(e):c},a.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],o=t[1],r=t[2],c=t[3],a=t[4],u=t[5],l=t[6],p=t[7],h=0;h>>17|d<<15)^(d>>>19|d<<13)^d>>>10,g=((d=this.temp[h-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3;this.temp[h]=(f+this.temp[h-7]|0)+(g+this.temp[h-16]|0)}var m=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&u^~a&l)|0)+(p+(s[h]+this.temp[h]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&o^n&r^o&r)|0;p=l,l=u,u=a,a=c+m|0,c=r,r=o,o=n,n=m+v|0}t[0]+=n,t[1]+=o,t[2]+=r,t[3]+=c,t[4]+=a,t[5]+=u,t[6]+=l,t[7]+=p}},{"./browserHashUtils":11,"buffer/":81}],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 o=e("./core");if(t.exports=o,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"),o.XML.Parser=e("./xml/browser_parser"),e("./http/xhr"),void 0===r)var r={browser:!0}}).call(this)}).call(this,e("_process"))},{"./browserCryptoLib":10,"./core":18,"./credentials":19,"./credentials/chainable_temporary_credentials":20,"./credentials/cognito_identity_credentials":21,"./credentials/credential_provider_chain":22,"./credentials/saml_credentials":23,"./credentials/temporary_credentials":24,"./credentials/web_identity_credentials":25,"./event-stream/buffered-create-event-stream":27,"./http/xhr":35,"./realclock/browserClock":52,"./util":71,"./xml/browser_parser":72,_process:86,"buffer/":81,"querystring/":92,"url/":94}],17:[function(e,t,n){var o,r=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),r.Config=r.util.inherit({constructor:function(e){void 0===e&&(e={}),e=this.extractCredentials(e),r.util.each.call(this,this.keys,(function(t,n){this.set(t,e[t],n)}))},getCredentials:function(e){var t,n=this;function o(t){e(t,t?null:n.credentials)}function i(e,t){return new r.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)),o(e)})):(t=null,n.credentials.accessKeyId&&n.credentials.secretAccessKey||(t=i("Missing credentials")),o(t)):n.credentialProvider?n.credentialProvider.resolve((function(e,t){e&&(e=i("Could not load credentials from any providers",e)),n.credentials=t,o(e)})):o(i("No credentials to load"))},update:function(e,t){t=t||!1,e=this.extractCredentials(e),r.util.each.call(this,e,(function(e,n){(t||Object.prototype.hasOwnProperty.call(this.keys,e)||r.Service.hasService(e))&&this.set(e,n)}))},loadFromPath:function(e){this.clear();var t=JSON.parse(r.util.readFileSync(e)),n=new r.FileSystemCredentials(e),o=new r.CredentialProviderChain;return o.providers.unshift(n),o.resolve((function(e,n){if(e)throw e;t.credentials=n})),this.constructor(t),this},clear:function(){r.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]=r.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,computeChecksums:!0,convertResponseTypes:!0,correctClockSkew:!1,customUserAgent:null,dynamoDbCrc32:!0,systemClockOffset:0,signatureVersion:null,signatureCache:!0,retryDelayOptions:{},useAccelerateEndpoint:!1,clientSideMonitoring:!1,endpointDiscoveryEnabled:!1,endpointCacheSize:1e3,hostPrefixEnabled:!0,stsRegionalEndpoints:null},extractCredentials:function(e){return e.accessKeyId&&e.secretAccessKey&&((e=r.util.copy(e)).credentials=new r.Credentials(e)),e},setPromisesDependency:function(e){o=e,null===e&&"function"==typeof Promise&&(o=Promise);var t=[r.Request,r.Credentials,r.CredentialProviderChain];r.S3&&(t.push(r.S3),r.S3.ManagedUpload&&t.push(r.S3.ManagedUpload)),r.util.addPromises(t,o)},getPromisesDependency:function(){return o}}),r.config=new r.Config},{"./core":18,"./credentials":19,"./credentials/credential_provider_chain":22}],18:[function(e,t,n){var o={util:e("./util")};({}).toString(),t.exports=o,o.util.update(o,{VERSION:"2.553.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"),o.events=new o.SequentialExecutor,o.util.memoizedProperty(o,"endpointCache",(function(){return new o.EndpointCache(o.config.endpointCacheSize)}),!0)},{"../vendor/endpoint-cache":103,"./api_loader":9,"./config":17,"./event_listeners":33,"./http":34,"./json/builder":36,"./json/parser":37,"./model/api":38,"./model/operation":40,"./model/paginator":41,"./model/resource_waiter":42,"./model/shape":43,"./param_validator":44,"./protocol/json":46,"./protocol/query":47,"./protocol/rest":48,"./protocol/rest_json":49,"./protocol/rest_xml":50,"./request":55,"./resource_waiter":56,"./response":57,"./sequential_executor":58,"./service":59,"./signers/request_signer":63,"./util":71,"./xml/builder":73}],19:[function(e,t,n){var o=e("./core");o.Credentials=o.util.inherit({constructor:function(){if(o.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"===r(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=o.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){o.util.arrayEach(n.refreshCallbacks,(function(n){t?n(e):o.util.defer((function(){n(e)}))})),n.refreshCallbacks.length=0}))},load:function(e){e()}}),o.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=o.util.promisifyMethod("get",e),this.prototype.refreshPromise=o.util.promisifyMethod("refresh",e)},o.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},o.util.addPromises(o.Credentials)},{"./core":18}],20:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.ChainableTemporaryCredentials=o.util.inherit(o.Credentials,{constructor:function(e){o.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=o.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!=typeof e.tokenCodeFn)throw new o.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=o.util.merge({params:t,credentials:e.masterCredentials||o.config.credentials},e.stsConfig||{});this.service=new r(n)},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(e){var t=this,n=t.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode((function(o,r){var i={};o?e(o):(r&&(i.TokenCode=r),t.service[n](i,(function(n,o){n||t.service.credentialsFrom(o,t),e(n)})))}))},getTokenCode:function(e){var t=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,(function(n,r){if(n){var i=n;return n instanceof Error&&(i=n.message),void e(o.util.error(new Error("Error fetching MFA token: "+i),{code:t.errorCode}))}e(null,r)})):e(null)}})},{"../../clients/sts":8,"../core":18}],21:[function(e,t,n){var o=e("../core"),i=e("../../clients/cognitoidentity"),s=e("../../clients/sts");o.CognitoIdentityCredentials=o.util.inherit(o.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=o.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||o.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,o){!n&&o.IdentityId?(t.params.IdentityId=o.IdentityId,e(null,o.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,o){n?t.clearIdOnNotAuthorized(n):(t.cacheId(o),t.data=o,t.loadCredentials(t.data,t)),e(n)}))},getCredentialsFromSTS:function(e){var t=this;t.cognito.getOpenIdToken((function(n,o){n?(t.clearIdOnNotAuthorized(n),e(n)):(t.cacheId(o),t.params.WebIdentityToken=o.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(o.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 o.WebIdentityCredentials(this.params,e),!this.cognito){var t=o.util.merge({},e);t.params=this.params,this.cognito=new i(t)}this.sts=this.sts||new s(e)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,o.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=o.util.isBrowser()&&null!==window.localStorage&&"object"===r(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":18}],22:[function(e,t,n){var o=e("../core");o.CredentialProviderChain=o.util.inherit(o.Credentials,{constructor:function(e){this.providers=e||o.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,r=t.providers.slice(0);!function e(i,s){if(!i&&s||n===r.length)return o.util.arrayEach(t.resolveCallbacks,(function(e){e(i,s)})),void(t.resolveCallbacks.length=0);var c=r[n++];(s="function"==typeof c?c.call():c).get?s.get((function(t){e(t,t?null:s)})):e(null,s)}()}return t}}),o.CredentialProviderChain.defaultProviders=[],o.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=o.util.promisifyMethod("resolve",e)},o.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},o.util.addPromises(o.CredentialProviderChain)},{"../core":18}],23:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.SAMLCredentials=o.util.inherit(o.Credentials,{constructor:function(e){o.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithSAML((function(n,o){n||t.service.credentialsFrom(o,t),e(n)}))},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],24:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.TemporaryCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.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||o.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,o){n||t.service.credentialsFrom(o,t),e(n)}))}))},loadMasterCredentials:function(e){for(this.masterCredentials=e||o.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new o.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],25:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.WebIdentityCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=o.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithWebIdentity((function(n,o){t.data=null,n||(t.data=o,t.service.credentialsFrom(o,t)),e(n)}))},createClients:function(){if(!this.service){var e=o.util.merge({},this._clientConfig);e.params=this.params,this.service=new r(e)}}})},{"../../clients/sts":8,"../core":18}],26:[function(e,t,n){(function(n){(function(){var o=e("./core"),r=e("./util"),i=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function s(e){var t=e.service,n=t.api||{},o=(n.operations,{});return t.config.region&&(o.region=t.config.region),n.serviceId&&(o.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(o.accessKeyId=t.config.credentials.accessKeyId),o}function c(e,t,n){n&&null!=t&&"structure"===n.type&&n.required&&n.required.length>0&&r.arrayEach(n.required,(function(o){var r=n.members[o];if(!0===r.endpointDiscoveryId){var i=r.isLocationName?r.name:o;e[i]=String(t[o])}else c(e,t[o],r)}))}function a(e,t){var n={};return c(n,e.params,t),n}function u(e){var t=e.service,n=t.api,i=n.operations?n.operations[e.operation]:void 0,c=a(e,i?i.input:void 0),u=s(e);Object.keys(c).length>0&&(u=r.update(u,c),i&&(u.operation=i.name));var l=o.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:c});h(p),p.removeListener("validate",o.EventListeners.Core.VALIDATE_PARAMETERS),p.removeListener("retry",o.EventListeners.Core.RETRY_CHECK),o.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}]),p.send((function(e,t){t&&t.Endpoints?o.endpointCache.put(u,t.Endpoints):e&&o.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}])}))}}var l={};function p(e,t){var n=e.service,i=n.api,c=i.operations?i.operations[e.operation]:void 0,u=c?c.input:void 0,p=a(e,u),d=s(e);Object.keys(p).length>0&&(d=r.update(d,p),c&&(d.operation=c.name));var f=o.EndpointCache.getKeyString(d),g=o.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:c.name,Identifiers:p});m.removeListener("validate",o.EventListeners.Core.VALIDATE_PARAMETERS),h(m),o.endpointCache.put(f,[{Address:"",CachePeriodInMinutes:60}]),m.send((function(n,i){if(n){var s={code:"EndpointDiscoveryException",message:"Request cannot be fulfilled without specifying an endpoint",retryable:!1};if(e.response.error=r.error(n,s),o.endpointCache.remove(d),l[f]){var c=l[f];r.arrayEach(c,(function(e){e.request.response.error=r.error(n,s),e.callback()})),delete l[f]}}else i&&(o.endpointCache.put(f,i.Endpoints),e.httpRequest.updateEndpoint(i.Endpoints[0].Address),l[f])&&(c=l[f],r.arrayEach(c,(function(e){e.request.httpRequest.updateEndpoint(i.Endpoints[0].Address),e.callback()})),delete l[f]);t()}))}}function h(e){var t=e.service.api.apiVersion;t&&!e.httpRequest.headers["x-amz-api-version"]&&(e.httpRequest.headers["x-amz-api-version"]=t)}function d(e){var t=e.error,n=e.httpResponse;if(t&&("InvalidEndpointException"===t.code||421===n.statusCode)){var i=e.request,c=i.service.api.operations||{},u=a(i,c[i.operation]?c[i.operation].input:void 0),l=s(i);Object.keys(u).length>0&&(l=r.update(l,u),c[i.operation]&&(l.operation=c[i.operation].name)),o.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 r.error(new Error,{code:"ConfigurationException",message:"Custom endpoint is supplied; endpointDiscoveryEnabled must not be true."});var t=o.config[e.serviceIdentifier]||{};return Boolean(o.config.endpoint||t.endpoint||e._originalConfig&&e._originalConfig.endpoint)}(s)||e.isPresigned())return t();if(!function(e){if(!0===(e.service||{}).config.endpointDiscoveryEnabled)return!0;if(r.isBrowser())return!1;for(var t=0;t-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,o=Math.abs(Math.round(e));n>-1&&o>0;n--,o/=256)t[n]=o;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":18}],30:[function(e,t,n){var o=e("./parse-message").parseMessage;t.exports={parseEvent:function(e,t,n){var r=o(t),i=r.headers[":message-type"];if(i){if("error"===i.value)throw function(e){var t=e.headers[":error-code"],n=e.headers[":error-message"],o=new Error(n.value||n);return o.code=o.name=t.value||t,o}(r);if("event"!==i.value)return}var s=r.headers[":event-type"],c=n.members[s.value];if(c){var a={},u=c.eventPayloadMemberName;if(u){var l=c.members[u];"binary"===l.type?a[u]=r.body:a[u]=e.parse(r.body.toString(),l)}for(var p=c.eventHeaderMemberNames,h=0;h=0)return e.httpRequest.headers["X-Amz-Content-Sha256"]="UNSIGNED-PAYLOAD",t();o.util.computeSha256(i,(function(n,o){n?t(n):(e.httpRequest.headers["X-Amz-Content-Sha256"]=o,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),n=o.util.getRequestPayloadShape(e);if(void 0===e.httpRequest.headers["Content-Length"])try{var r=o.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=r}catch(o){if(n&&n.isStreaming){if(n.requiresLength)throw o;if(t.indexOf("unsigned-body")>=0)return void(e.httpRequest.headers["Transfer-Encoding"]="chunked");throw o}throw o}})),e("SET_HTTP_HOST","afterBuild",(function(e){e.httpRequest.headers.Host=e.httpRequest.endpoint.host})),e("RESTART","restart",(function(){var e=this.response.error;e&&e.retryable&&(this.httpRequest=new o.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,n,r){n.httpResponse.statusCode=e,n.httpResponse.statusMessage=r,n.httpResponse.headers=t,n.httpResponse.body=o.util.buffer.toBuffer(""),n.httpResponse.buffers=[],n.httpResponse.numBytes=0;var i=t.date||t.Date,s=n.request.service;if(i){var c=Date.parse(i);s.config.correctClockSkew&&s.isClockSkewed(c)&&s.applyClockOffset(c)}})),e("HTTP_DATA","httpData",(function(e,t){if(e){if(o.util.isNode()){t.httpResponse.numBytes+=e.length;var n=t.httpResponse.headers["content-length"],r={loaded:t.httpResponse.numBytes,total:n};t.request.emit("httpDownloadProgress",[r,t])}t.httpResponse.buffers.push(o.util.buffer.toBuffer(e))}})),e("HTTP_DONE","httpDone",(function(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var t=o.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 o.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=this.HEADERS_RECEIVED&&!h&&(u.statusCode=p.status,u.headers=c.parseHeaders(p.getAllResponseHeaders()),u.emit("headers",u.statusCode,u.headers,p.statusText),h=!0),this.readyState===this.DONE&&c.finishRequest(p,u)}),!1),p.upload.addEventListener("progress",(function(e){u.emit("sendProgress",e)})),p.addEventListener("progress",(function(e){u.emit("receiveProgress",e)}),!1),p.addEventListener("timeout",(function(){s(o.util.error(new Error("Timeout"),{code:"TimeoutError"}))}),!1),p.addEventListener("error",(function(){s(o.util.error(new Error("Network Failure"),{code:"NetworkingError"}))}),!1),p.addEventListener("abort",(function(){s(o.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))}),!1),n(u),p.open(e.method,l,!1!==t.xhrAsync),o.util.each(e.headers,(function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&p.setRequestHeader(e,t)})),t.timeout&&!1!==t.xhrAsync&&(p.timeout=t.timeout),t.xhrWithCredentials&&(p.withCredentials=!0);try{p.responseType="arraybuffer"}catch(e){}try{e.body?p.send(e.body):p.send()}catch(t){if(!e.body||"object"!==r(e.body.buffer))throw t;p.send(e.body.buffer)}return u},parseHeaders:function(e){var t={};return o.util.arrayEach(e.split(/\r?\n/),(function(e){var n=e.split(":",1)[0],o=e.substring(n.length+2);n.length>0&&(t[n.toLowerCase()]=o)})),t},finishRequest:function(e,t){var n;if("arraybuffer"===e.responseType&&e.response){var r=e.response;n=new o.util.Buffer(r.byteLength);for(var i=new Uint8Array(r),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 f(){a.apply(this,arguments),this.toType=function(e){var t=i.base64.decode(e);if(this.isSensitive&&i.isNode()&&"function"==typeof i.Buffer.alloc){var n=i.Buffer.alloc(t.length,t);t.fill(0),t=n}return t},this.toWireFormat=i.base64.encode}function g(){f.apply(this,arguments)}function m(){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:l,list:p,map:h,boolean:m,timestamp:function(e){var t=this;if(a.apply(this,arguments),e.timestampFormat)s(this,"timestampFormat",e.timestampFormat);else if(t.isTimestampFormatSet&&this.timestampFormat)s(this,"timestampFormat",this.timestampFormat);else if("header"===this.location)s(this,"timestampFormat","rfc822");else if("querystring"===this.location)s(this,"timestampFormat","iso8601");else if(this.api)switch(this.api.protocol){case"json":case"rest-json":s(this,"timestampFormat","unixTimestamp");break;case"rest-xml":case"query":case"ec2":s(this,"timestampFormat","iso8601")}this.toType=function(e){return null==e?null:"function"==typeof e.toUTCString?e:"string"==typeof e||"number"==typeof e?i.date.parseTimestamp(e):null},this.toWireFormat=function(e){return i.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:g,binary:f},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 o=a.resolve(e,t);if(o){var r=Object.keys(e);t.documentation||(r=r.filter((function(e){return!e.match(/documentation/)})));var i=function(){o.constructor.call(this,e,t,n)};return i.prototype=o,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:l,ListShape:p,MapShape:h,StringShape:d,BooleanShape:m,Base64Shape:g},t.exports=a},{"../util":71,"./collection":39}],44:[function(e,t,n){var o=e("./core");o.ParamValidator=o.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 r=this.errors.join("\n* ");throw r="There were "+this.errors.length+" validation errors:\n* "+r,o.util.error(new Error(r),{code:"MultipleValidationErrors",errors:this.errors})}if(1===this.errors.length)throw this.errors[0];return!0},fail:function(e,t){this.errors.push(o.util.error(new Error(t),{code:e}))},validateStructure:function(e,t,n){var o;this.validateType(t,n,["object"],"structure");for(var r=0;e.required&&r= 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,o){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 "+o+" <= "+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,i){if(null==e)return!1;for(var s=!1,c=0;c63)throw o.error(new Error,{code:"ValidationError",message:"Hostname label length should be between 1 to 63 characters, inclusive."});if(!i.test(e))throw r.util.error(new Error,{code:"ValidationError",message:e+" is not hostname compatible."})}))}return e}}},{"../core":18,"../util":71}],46:[function(e,t,n){var o=e("../util"),r=e("../json/builder"),i=e("../json/parser"),s=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.httpRequest,n=e.service.api,o=n.targetPrefix+"."+n.operations[e.operation].name,i=n.jsonVersion||"1.0",c=n.operations[e.operation].input,a=new r;1===i&&(i="1.0"),t.body=a.build(e.params||{},c),t.headers["Content-Type"]="application/x-amz-json-"+i,t.headers["X-Amz-Target"]=o,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 r=JSON.parse(n.body.toString());(r.__type||r.code)&&(t.code=(r.__type||r.code).split("#").pop()),"RequestEntityTooLarge"===t.code?t.message="Request body must be less than 1 MB":t.message=r.message||r.Message||null}catch(r){t.statusCode=n.statusCode,t.message=n.statusMessage}else t.statusCode=n.statusCode,t.message=n.statusCode.toString();e.error=o.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||{},o=new i;e.data=o.parse(t,n)}}}},{"../json/builder":36,"../json/parser":37,"../util":71,"./helpers":45}],47:[function(e,t,n){var o=e("../core"),r=e("../util"),i=e("../query/query_param_serializer"),s=e("../model/shape"),c=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=r.queryParamsToString(n.params),c(e)},extractError:function(e){var t,n=e.httpResponse.body.toString();if(n.match("=0?"&":"?";var a=[];o.arrayEach(Object.keys(s).sort(),(function(e){Array.isArray(s[e])||(s[e]=[s[e]]);for(var t=0;t0){var p=(t=new o.XML.Parser).parse(s.toString(),a);r.update(e.data,p)}}}},{"../core":18,"../util":71,"./rest":48}],51:[function(e,t,n){var o=e("../util");function r(){}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,r){o.each(n.members,(function(n,o){var s=t[n];if(null!=s){var a=i(o);c(a=e?e+"."+a:a,s,o,r)}}))}function c(e,t,n,r){null!=t&&("structure"===n.type?s(e,t,n,r):"list"===n.type?function(e,t,n,r){var s=n.member||{};0!==t.length?o.arrayEach(t,(function(t,o){var a="."+(o+1);if("ec2"===n.api.protocol)a+="";else if(n.flattened){if(s.name){var u=e.split(".");u.pop(),u.push(i(s)),e=u.join(".")}}else a="."+(s.name?s.name:"member")+a;c(e+a,t,s,r)})):r.call(this,e,null)}(e,t,n,r):"map"===n.type?function(e,t,n,r){var i=1;o.each(t,(function(t,o){var s=(n.flattened?".":".entry.")+i+++".",a=s+(n.key.name||"key"),u=s+(n.value.name||"value");c(e+a,t,n.key,r),c(e+u,o,n.value,r)}))}(e,t,n,r):r(e,n.toWireFormat(t).toString()))}r.prototype.serialize=function(e,t,n){s("",e,t,n)},t.exports=r},{"../util":71}],52:[function(e,t,n){t.exports={now:function(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}}},{}],53:[function(e,t,n){var o=e("./util"),r=e("./region_config_data.json");function i(e,t){o.each(t,(function(t,n){"globalEndpoint"!==t&&(void 0!==e.config[t]&&null!==e.config[t]||(e.config[t]=n))}))}t.exports=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),o=e.api.endpointPrefix;return[[t,o],[n,o],[t,"*"],[n,"*"],["*",o],["*","*"]].map((function(e){return e[0]&&e[1]?e.join("/"):null}))}(e),n=0;n=0){a=!0;var u=0}var l=function(){a&&u!==c?r.emit("error",n.util.error(new Error("Stream content length mismatch. Received "+u+" of "+c+" bytes."),{code:"StreamContentLengthMismatch"})):2===n.HttpClient.streamsApiVersion?r.end():r.emit("end")},p=s.httpResponse.createUnbufferedStream();if(2===n.HttpClient.streamsApiVersion)if(a){var h=new e.PassThrough;h._write=function(t){return t&&t.length&&(u+=t.length),e.PassThrough.prototype._write.apply(this,arguments)},h.on("end",l),r.on("error",(function(e){a=!1,p.unpipe(h),h.emit("end"),h.end()})),p.pipe(h).pipe(r,{end:!1})}else p.pipe(r);else a&&p.on("data",(function(e){e&&e.length&&(u+=e.length)})),p.on("data",(function(e){r.emit("data",e)})),p.on("end",l);p.on("error",(function(e){a=!1,r.emit("error",e)}))}})),r},emitEvent:function(e,t,o){"function"==typeof t&&(o=t,t=null),o||(o=function(){}),t||(t=this.eventParameters(e,this.response)),n.SequentialExecutor.prototype.emit.call(this,e,t,(function(e){e&&(this.response.error=e),o.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":18,"./state_machine":70,_process:86,jmespath:85}],56:[function(e,t,n){var o=e("./core"),r=o.util.inherit,i=e("jmespath");function s(e){var t=e.request._waiter,n=t.config.acceptors,o=!1,r="retry";n.forEach((function(n){if(!o){var i=t.matchers[n.matcher];i&&i(e,n.expected,n.argument)&&(o=!0,r=n.state)}})),!o&&e.error&&(r="failure"),"success"===r?t.setSuccess(e):t.setError(e,"retry"===r)}o.ResourceWaiter=r({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 o=i.search(e.data,n)}catch(e){return!1}return i.strictDeepEqual(o,t)},pathAll:function(e,t,n){try{var o=i.search(e.data,n)}catch(e){return!1}Array.isArray(o)||(o=[o]);var r=o.length;if(!r)return!1;for(var s=0;s-1&&n.splice(r,1)}return this},removeAllListeners:function(e){return e?delete this._events[e]:this._events={},this},emit:function(e,t,n){n||(n=function(){});var o=this.listeners(e),r=o.length;return this.callListeners(o,t,n),r>0},callListeners:function(e,t,n,r){var i=this,s=r||null;function c(r){if(r&&(s=o.util.error(s||new Error,r),i._haltHandlersOnError))return n.call(i,s);i.callListeners(e,t,n,s)}for(;e.length>0;){var a=e.shift();if(a._isAsync)return void a.apply(i,t.concat([c]));try{a.apply(i,t)}catch(e){s=o.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),o.util.each(e,(function(e,n){"function"==typeof n&&(n=[n]),o.util.arrayEach(n,(function(n){t.on(e,n)}))})),t},addNamedListener:function(e,t,n,o){return this[e]=n,this.addListener(t,n,o),this},addNamedAsyncListener:function(e,t,n,o){return n._isAsync=!0,this.addNamedListener(e,t,n,o)},addNamedListeners:function(e){var t=this;return e((function(){t.addNamedListener.apply(t,arguments)}),(function(){t.addNamedAsyncListener.apply(t,arguments)})),this}}),o.SequentialExecutor.prototype.addListener=o.SequentialExecutor.prototype.on,t.exports=o.SequentialExecutor},{"./core":18}],59:[function(e,t,n){(function(n){(function(){var o=e("./core"),i=e("./model/api"),s=e("./region_config"),c=o.util.inherit,a=0;o.Service=c({constructor:function(e){if(!this.loadServiceClass)throw o.util.error(new Error,"Service must be constructed with `new' operator");var t=this.loadServiceClass(e||{});if(t){var n=o.util.copy(e),r=new t(e);return Object.defineProperty(r,"_originalConfig",{get:function(){return n},enumerable:!1,configurable:!0}),r._clientId=++a,r}this.initialize(e)},initialize:function(e){var t=o.config[this.serviceIdentifier];if(this.config=new o.Config(o.config),t&&this.config.update(t,!0),e&&this.config.update(e,!0),this.validateService(),this.config.endpoint||s(this),this.config.endpoint=this.endpointFromTemplate(this.config.endpoint),this.setEndpoint(this.config.endpoint),o.SequentialExecutor.call(this),o.Service.addDefaultMonitoringListeners(this),(this.config.clientSideMonitoring||o.Service._clientSideMonitoring)&&this.publisher){var r=this.publisher;this.addNamedListener("PUBLISH_API_CALL","apiCall",(function(e){n.nextTick((function(){r.eventHandler(e)}))})),this.addNamedListener("PUBLISH_API_ATTEMPT","apiCallAttempt",(function(e){n.nextTick((function(){r.eventHandler(e)}))}))}},validateService:function(){},loadServiceClass:function(e){var t=e;if(o.util.isEmpty(this.api)){if(t.apiConfig)return o.Service.defineServiceApi(this.constructor,t.apiConfig);if(this.constructor.services){(t=new o.Config(o.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]&&o.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?o.util.isType(e,Date)&&(e=o.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,r=t.length-1;r>=0;r--)if("*"!==t[r][t[r].length-1]&&(n=t[r]),t[r].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 '"+r(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 r=this.api.operations[e];r&&(t=o.util.copy(t),o.util.each(this.config.params,(function(e,n){r.input.members[e]&&(void 0!==t[e]&&null!==t[e]||(t[e]=n))})))}var i=new o.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 o=this.makeRequest(e,t).toUnauthenticated();return n?o.send(n):o},waitFor:function(e,t,n){return new o.ResourceWaiter(this,e).wait(t,n)},addAllRequestListeners:function(e){for(var t=[o.events,o.EventListeners.Core,this.serviceInterface(),o.EventListeners.CorePost],n=0;n299?(r.code&&(n.FinalAwsException=r.code),r.message&&(n.FinalAwsExceptionMessage=r.message)):((r.code||r.name)&&(n.FinalSdkException=r.code||r.name),r.message&&(n.FinalSdkExceptionMessage=r.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()},o=e.response;return o.httpResponse.statusCode&&(n.HttpStatusCode=o.httpResponse.statusCode),!e._unAuthenticated&&e.service.config.credentials&&e.service.config.credentials.accessKeyId&&(n.AccessKey=e.service.config.credentials.accessKeyId),o.httpResponse.headers?(e.httpRequest.headers["x-amz-security-token"]&&(n.SessionToken=e.httpRequest.headers["x-amz-security-token"]),o.httpResponse.headers["x-amzn-requestid"]&&(n.XAmznRequestId=o.httpResponse.headers["x-amzn-requestid"]),o.httpResponse.headers["x-amz-request-id"]&&(n.XAmzRequestId=o.httpResponse.headers["x-amz-request-id"]),o.httpResponse.headers["x-amz-id-2"]&&(n.XAmzId2=o.httpResponse.headers["x-amz-id-2"]),n):n},attemptFailEvent:function(e){var t=this.apiAttemptEvent(e),n=e.response,o=n.error;return n.httpResponse.statusCode>299?(o.code&&(t.AwsException=o.code),o.message&&(t.AwsExceptionMessage=o.message)):((o.code||o.name)&&(t.SdkException=o.code||o.name),o.message&&(t.SdkExceptionMessage=o.message)),t},attachMonitoringEmitter:function(e){var t,n,r,i,s,c,a=0,u=this;e.on("validate",(function(){i=o.util.realClock.now(),c=Date.now()}),!0),e.on("sign",(function(){n=o.util.realClock.now(),t=Date.now(),s=e.httpRequest.region,a++}),!0),e.on("validateResponse",(function(){r=Math.round(o.util.realClock.now()-n)})),e.addNamedListener("API_CALL_ATTEMPT","success",(function(){var n=u.apiAttemptEvent(e);n.Timestamp=t,n.AttemptLatency=r>=0?r:0,n.Region=s,u.emit("apiCallAttempt",[n])})),e.addNamedListener("API_CALL_ATTEMPT_RETRY","retry",(function(){var i=u.attemptFailEvent(e);i.Timestamp=t,r=r||Math.round(o.util.realClock.now()-n),i.AttemptLatency=r>=0?r:0,i.Region=s,u.emit("apiCallAttempt",[i])})),e.addNamedListener("API_CALL","complete",(function(){var t=u.apiCallEvent(e);if(t.AttemptCount=a,!(t.AttemptCount<=0)){t.Timestamp=c;var n=Math.round(o.util.realClock.now()-i);t.Latency=n>=0?n:0;var r=e.response;"number"==typeof r.retryCount&&"number"==typeof r.maxRetries&&r.retryCount>=r.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t])}}))},setupRequestListeners:function(e){},getSignerClass:function(e){var t,n=null,r="";return e&&(r=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:""),t=this.config.signatureVersion?this.config.signatureVersion:"v4"===r||"v4-unsigned-body"===r?"v4":this.api.signatureVersion,o.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return o.EventListeners.Query;case"json":return o.EventListeners.Json;case"rest-json":return o.EventListeners.RestJson;case"rest-xml":return o.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){return o.util.calculateRetryDelay(e,this.config.retryDelayOptions)},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)>=3e4},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":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 o.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(!n){if(t){var r=new Error;throw o.util.error(r,"No pagination configuration for "+e)}return null}return n}}),o.util.update(o.Service,{defineMethods:function(e){o.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){o.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var r=c(o.Service,n||{});if("string"==typeof e){o.Service.addVersions(r,t);var i=r.serviceIdentifier||e;r.serviceIdentifier=i}else r.prototype.api=e,o.Service.defineMethods(r);if(o.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&o.util.clientSideMonitoring){var s=o.util.clientSideMonitoring.Publisher,a=(0,o.util.clientSideMonitoring.configProvider)();this.prototype.publisher=new s(a),a.enabled&&(o.Service._clientSideMonitoring=!0)}return o.SequentialExecutor.call(r.prototype),o.Service.addDefaultMonitoringListeners(r.prototype),r},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n=0))throw n.util.error(new Error,t);this.config.stsRegionalEndpoints=e.toLowerCase()},validateRegionalEndpointsFlag:function(){var e=this.config;if(e.stsRegionalEndpoints&&this.validateRegionalEndpointsFlagValue(e.stsRegionalEndpoints,{code:"InvalidConfiguration",message:'invalid "stsRegionalEndpoints" configuration. Expect "legacy" or "regional". Got "'+e.stsRegionalEndpoints+'".'}),n.util.isNode()){if(Object.prototype.hasOwnProperty.call(t.env,r)){var o=t.env[r];this.validateRegionalEndpointsFlagValue(o,{code:"InvalidEnvironmentalVariable",message:"invalid "+r+' environmental variable. Expect "legacy" or "regional". Got "'+t.env[r]+'".'})}var s={};try{s=n.util.getProfilesFromSharedConfig(n.util.iniLoader)[t.env.AWS_PROFILE||n.util.defaultProfile]}catch(e){}if(s&&Object.prototype.hasOwnProperty.call(s,i)){var c=s[i];this.validateRegionalEndpointsFlagValue(c,{code:"InvalidConfiguration",message:"invalid "+i+' profile config. Expect "legacy" or "regional". Got "'+s[i]+'".'})}}},optInRegionalEndpoint:function(){this.validateRegionalEndpointsFlag();var e=this.config;if("regional"===e.stsRegionalEndpoints){if(o(this),!this.isGlobalEndpoint)return;if(this.isGlobalEndpoint=!1,!e.region)throw n.util.error(new Error,{code:"ConfigError",message:"Missing region in config"});var t=e.endpoint.indexOf(".amazonaws.com");e.endpoint=e.endpoint.substring(0,t)+"."+e.region+e.endpoint.substring(t)}},validateService:function(){this.optInRegionalEndpoint()}})}).call(this)}).call(this,e("_process"))},{"../core":18,"../region_config":53,_process:86}],62:[function(e,t,n){var o=e("../core"),r=o.util.inherit,i="presigned-expires";function s(e){var t=e.httpRequest.headers[i],n=e.service.getSignerClass(e);if(delete e.httpRequest.headers["User-Agent"],delete e.httpRequest.headers["X-Amz-User-Agent"],n===o.Signers.V4){if(t>604800)throw o.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!==o.Signers.S3)throw o.util.error(new Error,{message:"Presigning only supports S3 or SigV4 signing.",code:"UnsupportedSigner",retryable:!1});var r=e.service?e.service.getSkewCorrectedDate():o.util.date.getDate();e.httpRequest.headers[i]=parseInt(o.util.date.unixTimestamp(r)+t,10).toString()}}function c(e){var t=e.httpRequest.endpoint,n=o.util.urlParse(e.httpRequest.path),r={};n.search&&(r=o.util.queryStringParse(n.search.substr(1)));var s=e.httpRequest.headers.Authorization.split(" ");if("AWS"===s[0])s=s[1].split(":"),r.AWSAccessKeyId=s[0],r.Signature=s[1],o.util.each(e.httpRequest.headers,(function(e,t){e===i&&(e="Expires"),0===e.indexOf("x-amz-meta-")&&(delete r[e],e=e.toLowerCase()),r[e]=t})),delete e.httpRequest.headers[i],delete r.Authorization,delete r.Host;else if("AWS4-HMAC-SHA256"===s[0]){s.shift();var c=s.join(" ").match(/Signature=(.*?)(?:,|\s|\r?\n|$)/)[1];r["X-Amz-Signature"]=c,delete r.Expires}t.pathname=n.pathname,t.search=o.util.queryParamsToString(r)}o.Signers.Presign=r({sign:function(e,t,n){if(e.httpRequest.headers[i]=t||3600,e.on("build",s),e.on("sign",c),e.removeListener("afterBuild",o.EventListeners.Core.SET_CONTENT_LENGTH),e.removeListener("afterBuild",o.EventListeners.Core.COMPUTE_SHA256),e.emit("beforePresign",[e]),!n){if(e.build(),e.response.error)throw e.response.error;return o.util.urlFormat(e.httpRequest.endpoint)}e.build((function(){this.response.error?n(this.response.error):n(null,o.util.urlFormat(e.httpRequest.endpoint))}))}}),t.exports=o.Signers.Presign},{"../core":18}],63:[function(e,t,n){var o=e("../core"),r=o.util.inherit;o.Signers.RequestSigner=r({constructor:function(e){this.request=e},setServiceClientId:function(e){this.serviceClientId=e},getServiceClientId:function(){return this.serviceClientId}}),o.Signers.RequestSigner.getVersion=function(e){switch(e){case"v2":return o.Signers.V2;case"v3":return o.Signers.V3;case"s3v4":case"v4":return o.Signers.V4;case"s3":return o.Signers.S3;case"v3https":return o.Signers.V3Https}throw new Error("Unknown signing version "+e)},e("./v2"),e("./v3"),e("./v3https"),e("./v4"),e("./s3"),e("./presign")},{"../core":18,"./presign":62,"./s3":64,"./v2":65,"./v3":66,"./v3https":67,"./v4":68}],64:[function(e,t,n){var o=e("../core"),r=o.util.inherit;o.Signers.S3=r(o.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"]=o.util.date.rfc822(t)),e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken);var n=this.sign(e.secretAccessKey,this.stringToSign()),r="AWS "+e.accessKeyId+":"+n;this.request.headers.Authorization=r},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=[];o.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+o.util.queryParamsToString(r)},authorization:function(e,t){var n=[],o=this.credentialString(t);return n.push(this.algorithm+" Credential="+e.accessKeyId+"/"+o),n.push("SignedHeaders="+this.signedHeaders()),n.push("Signature="+this.signature(e,t)),n.join(", ")},signature:function(e,t){var n=r.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return o.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=o.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=[];o.util.each.call(this,this.request.headers,(function(t,n){e.push([t,n])})),e.sort((function(e,t){return e[0].toLowerCase()50&&delete r[i.shift()]),d},emptyCache:function(){r={},i=[]}}},{"../core":18}],70:[function(e,t,n){function o(e,t){this.currentState=t||null,this.states=e||{}}o.prototype.runTo=function(e,t,n,o){"function"==typeof e&&(o=n,n=t,t=e,e=null);var r=this,i=r.states[r.currentState];i.fn.call(n||r,o,(function(o){if(o){if(!i.fail)return t?t.call(n,o):null;r.currentState=i.fail}else{if(!i.accept)return t?t.call(n):null;r.currentState=i.accept}if(r.currentState===e)return t?t.call(n,o):null;r.runTo(e,t,n,o)}))},o.prototype.addState=function(e,t,n,o){return"function"==typeof t?(o=t,t=null,n=null):"function"==typeof n&&(o=n,n=null),this.currentState||(this.currentState=e),this.states[e]={accept:t,fail:n,fn:o},this},t.exports=o},{}],71:[function(e,t,n){(function(n,o){(function(){var i,s={environment:"nodejs",engine:function(){if(s.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=s.environment,n="aws-sdk-"+t+"/"+e("./core").VERSION;return"nodejs"===t&&(n+=" "+s.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 s.arrayEach(e.split("/"),(function(e){t.push(s.uriEscape(e))})),t.join("/")},urlParse:function(e){return s.url.parse(e)},urlFormat:function(e){return s.url.format(e)},queryStringParse:function(e){return s.querystring.parse(e)},queryParamsToString:function(e){var t=[],n=s.uriEscape,o=Object.keys(e).sort();return s.arrayEach(o,(function(o){var r=e[o],i=n(o),c=i+"=";if(Array.isArray(r)){var a=[];s.arrayEach(r,(function(e){a.push(n(e))})),c=i+"="+a.sort().join("&"+i+"=")}else null!=r&&(c=i+"="+n(r));t.push(c)})),t.join("&")},readFileSync:function(t){return s.isBrowser()?null:e("fs").readFileSync(t,"utf-8")},base64:{encode:function(e){if("number"==typeof e)throw s.error(new Error("Cannot base64 encode number "+e));return null==e?e:s.buffer.toBuffer(e).toString("base64")},decode:function(e){if("number"==typeof e)throw s.error(new Error("Cannot base64 decode number "+e));return null==e?e:s.buffer.toBuffer(e,"base64")}},buffer:{toBuffer:function(e,t){return"function"==typeof s.Buffer.from&&s.Buffer.from!==Uint8Array.from?s.Buffer.from(e,t):new s.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 s.Buffer.alloc)return s.Buffer.alloc(e,t,n);var o=new s.Buffer(e);return void 0!==t&&"function"==typeof o.fill&&o.fill(t,void 0,void 0,n),o},toStream:function(e){s.Buffer.isBuffer(e)||(e=s.buffer.toBuffer(e));var t=new s.stream.Readable,n=0;return t._read=function(o){if(n>=e.length)return t.push(null);var r=n+o;r>e.length&&(r=e.length),t.push(e.slice(n,r)),n=r},t},concat:function(e){var t,n,o=0,r=0;for(n=0;n>>8^t[255&(n^e.readUInt8(o))];return(-1^n)>>>0},hmac:function(e,t,n,o){return n||(n="binary"),"buffer"===n&&(n=void 0),o||(o="sha256"),"string"==typeof t&&(t=s.buffer.toBuffer(t)),s.crypto.lib.createHmac(o,e).update(t).digest(n)},md5:function(e,t,n){return s.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return s.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,o){var i=s.crypto.createHash(e);n||(n="binary"),"buffer"===n&&(n=void 0),"string"==typeof t&&(t=s.buffer.toBuffer(t));var c=s.arraySliceFn(t),a=s.Buffer.isBuffer(t);if(s.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(a=!0),o&&"object"===r(t)&&"function"==typeof t.on&&!a)t.on("data",(function(e){i.update(e)})),t.on("error",(function(e){o(e)})),t.on("end",(function(){o(null,i.digest(n))}));else{if(!o||!c||a||"undefined"==typeof FileReader){s.isBrowser()&&"object"===r(t)&&!a&&(t=new s.Buffer(new Uint8Array(t)));var u=i.update(t).digest(n);return o&&o(null,u),u}var l=0,p=new FileReader;p.onerror=function(){o(new Error("Failed to read data."))},p.onload=function(){var e=new s.Buffer(new Uint8Array(p.result));i.update(e),l+=e.length,p._continueReading()},p._continueReading=function(){if(l>=t.size)o(null,i.digest(n));else{var e=l+524288;e>t.size&&(e=t.size),p.readAsArrayBuffer(c.call(t,l,e))}},p._continueReading()}},toHex:function(e){for(var t=[],n=0;n=3e5,!1),i.config.isClockSkewed},applyClockOffset:function(e){e&&(i.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&&i&&i.config&&(t=i.config.getPromisesDependency()),void 0===t&&"undefined"!=typeof Promise&&(t=Promise),"function"!=typeof t&&(n=!0),Array.isArray(e)||(e=[e]);for(var o=0;o=500||429===o});r&&i.retryable&&(i.retryAfter=r),a(i)}}))}),a)};i.util.defer(u)},uuid:{v4:function(){return e("uuid").v4()}},convertPayloadToString:function(e){var t=e.request,n=t.operation,o=t.service.api.operations[n].output||{};o.payload&&e.data[o.payload]&&(e.data[o.payload]=e.data[o.payload].toString())},defer:function(e){"object"===r(n)&&"function"==typeof n.nextTick?n.nextTick(e):"function"==typeof o?o(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 o={},r={};n.env[s.configOptInEnv]&&(r=e.loadFrom({isConfig:!0,filename:n.env[s.sharedConfigFileEnv]}));for(var i=e.loadFrom({filename:t||n.env[s.configOptInEnv]&&n.env[s.sharedCredentialsFileEnv]}),c=0,a=Object.keys(r);c0||o?i.toString():""},t.exports=s},{"../util":71,"./xml-node":76,"./xml-text":77}],74:[function(e,t,n){t.exports={escapeAttribute:function(e){return e.replace(/&/g,"&").replace(/'/g,"'").replace(//g,">").replace(/"/g,""")}}},{}],75:[function(e,t,n){t.exports={escapeElement:function(e){return e.replace(/&/g,"&").replace(//g,">")}}},{}],76:[function(e,t,n){var o=e("./escape-attribute").escapeAttribute;function r(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}r.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},r.prototype.addChildNode=function(e){return this.children.push(e),this},r.prototype.removeAttribute=function(e){return delete this.attributes[e],this},r.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,r=0,i=Object.keys(n);r"+this.children.map((function(e){return e.toString()})).join("")+"":"/>")},t.exports={XmlNode:r}},{"./escape-attribute":74}],77:[function(e,t,n){var o=e("./escape-element").escapeElement;function r(e){this.value=e}r.prototype.toString=function(){return o(""+this.value)},t.exports={XmlText:r}},{"./escape-element":75}],78:[function(e,t,n){"use strict";n.byteLength=function(e){var t=a(e),n=t[0],o=t[1];return 3*(n+o)/4-o},n.toByteArray=function(e){var t,n,o=a(e),s=o[0],c=o[1],u=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,c)),l=0,p=c>0?s-4:s;for(n=0;n>16&255,u[l++]=t>>8&255,u[l++]=255&t;return 2===c&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[l++]=255&t),1===c&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t),u},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,i=[],s=16383,c=0,a=n-r;ca?a:c+s));return 1===r?(t=e[n-1],i.push(o[t>>2]+o[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],i.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"=")),i.join("")};for(var o=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0;c<64;++c)o[c]=s[c],r[s.charCodeAt(c)]=c;function a(e){var t=e.length;if(t%4>0)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 u(e,t,n){for(var r,i,s=[],c=t;c>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},{}],79:[function(e,t,n){},{}],80:[function(e,t,i){(function(e){(function(){!function(s){var c="object"==r(i)&&i&&!i.nodeType&&i,a="object"==r(t)&&t&&!t.nodeType&&t,u="object"==r(e)&&e;u.global!==u&&u.window!==u&&u.self!==u||(s=u);var l,p,h=2147483647,d=36,f=1,g=26,m=38,v=700,y=72,E=128,S="-",b=/^xn--/,C=/[^\x20-\x7E]/,T=/[\x2E\u3002\uFF0E\uFF61]/g,I={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=d-f,_=Math.floor,w=String.fromCharCode;function R(e){throw RangeError(I[e])}function N(e,t){for(var n=e.length,o=[];n--;)o[n]=t(e[n]);return o}function k(e,t){var n=e.split("@"),o="";return n.length>1&&(o=n[0]+"@",e=n[1]),o+N((e=e.replace(T,".")).split("."),t).join(".")}function O(e){for(var t,n,o=[],r=0,i=e.length;r=55296&&t<=56319&&r65535&&(t+=w((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=w(e)})).join("")}function D(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,n){var o=0;for(e=n?_(e/v):e>>1,e+=_(e/t);e>A*g>>1;o+=d)e=_(e/A);return _(o+(A+1)*e/(e+m))}function x(e){var t,n,o,r,i,s,c,a,u,l,p,m=[],v=e.length,b=0,C=E,T=y;for((n=e.lastIndexOf(S))<0&&(n=0),o=0;o=128&&R("not-basic"),m.push(e.charCodeAt(o));for(r=n>0?n+1:0;r=v&&R("invalid-input"),((a=(p=e.charCodeAt(r++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:d)>=d||a>_((h-b)/s))&&R("overflow"),b+=a*s,!(a<(u=c<=T?f:c>=T+g?g:c-T));c+=d)s>_(h/(l=d-u))&&R("overflow"),s*=l;T=P(b-i,t=m.length+1,0==i),_(b/t)>h-C&&R("overflow"),C+=_(b/t),b%=t,m.splice(b++,0,C)}return L(m)}function M(e){var t,n,o,r,i,s,c,a,u,l,p,m,v,b,C,T=[];for(m=(e=O(e)).length,t=E,n=0,i=y,s=0;s=t&&p_((h-n)/(v=o+1))&&R("overflow"),n+=(c-t)*v,t=c,s=0;sh&&R("overflow"),p==t){for(a=n,u=d;!(a<(l=u<=i?f:u>=i+g?g:u-i));u+=d)C=a-l,b=d-l,T.push(w(D(l+C%b,0))),a=_(C/b);T.push(w(D(a,0))),i=P(n,v,o==r),n=0,++o}++n,++t}return T.join("")}if(l={version:"1.3.2",ucs2:{decode:O,encode:L},decode:x,encode:M,toASCII:function(e){return k(e,(function(e){return C.test(e)?"xn--"+M(e):e}))},toUnicode:function(e){return k(e,(function(e){return b.test(e)?x(e.slice(4).toLowerCase()):e}))}},"object"==r(n.amdO)&&n.amdO)void 0===(o=function(){return l}.call(i,n,i,t))||(t.exports=o);else if(c&&a)if(t.exports==c)a.exports=l;else for(p in l)l.hasOwnProperty(p)&&(c[p]=l[p]);else s.punycode=l}(this)}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],81:[function(e,t,o){(function(t,n){(function(){"use strict";var n=e("base64-js"),r=e("ieee754"),i=e("isarray");function s(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function c(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(a.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 o=!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(o)return j(e).length;t=(""+t).toLowerCase(),o=!0}}function g(e,t,n){var o=!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 k(this,t,n);case"utf8":case"utf-8":return _(this,t,n);case"ascii":return R(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return A(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function m(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function v(e,t,n,o,r){if(0===e.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=a.from(t,o)),a.isBuffer(t))return 0===t.length?-1:y(e,t,n,o,r);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,o,r){var i,s=1,c=e.length,a=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s=2,c/=2,a/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(r){var l=-1;for(i=n;ic&&(n=c-a),i=n;i>=0;i--){for(var p=!0,h=0;hr&&(o=r):o=r;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");o>i/2&&(o=i/2);for(var s=0;s>8,r=n%256,i.push(r),i.push(o);return i}(t,e.length-n),e,n,o)}function A(e,t,o){return 0===t&&o===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,o))}function _(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r239?4:u>223?3:u>191?2:1;if(r+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[r+1]))&&(a=(31&u)<<6|63&i)>127&&(l=a);break;case 3:i=e[r+1],s=e[r+2],128==(192&i)&&128==(192&s)&&(a=(15&u)<<12|(63&i)<<6|63&s)>2047&&(a<55296||a>57343)&&(l=a);break;case 4:i=e[r+1],s=e[r+2],c=e[r+3],128==(192&i)&&128==(192&s)&&128==(192&c)&&(a=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&c)>65535&&a<1114112&&(l=a)}null===l?(l=65533,p=1):l>65535&&(l-=65536,o.push(l>>>10&1023|55296),l=56320|1023&l),o.push(l),r+=p}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);for(var n="",o=0;o0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},a.prototype.compare=function(e,t,n,o,r){if(!a.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===o&&(o=0),void 0===r&&(r=this.length),t<0||n>e.length||o<0||r>this.length)throw new RangeError("out of range index");if(o>=r&&t>=n)return 0;if(o>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(r>>>=0)-(o>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),u=this.slice(o,r),l=e.slice(t,n),p=0;pr)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var i=!1;;)switch(o){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 C(this,e,t,n);case"base64":return T(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: "+o);o=(""+o).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function R(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;rr)&&(n=r);for(var i="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,n,o,r,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function P(e,t,n,o){t<0&&(t=65535+t+1);for(var r=0,i=Math.min(e.length-n,2);r>>8*(o?r:1-r)}function x(e,t,n,o){t<0&&(t=4294967295+t+1);for(var r=0,i=Math.min(e.length-n,4);r>>8*(o?r:3-r)&255}function M(e,t,n,o,r,i){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,o,i){return i||M(e,0,n,4),r.write(e,t,n,o,23,4),n+4}function q(e,t,n,o,i){return i||M(e,0,n,8),r.write(e,t,n,o,52,8),n+8}a.prototype.slice=function(e,t){var n,o=this.length;if((e=~~e)<0?(e+=o)<0&&(e=0):e>o&&(e=o),(t=void 0===t?o:~~t)<0?(t+=o)<0&&(t=0):t>o&&(t=o),t0&&(r*=256);)o+=this[e+--t]*r;return o},a.prototype.readUInt8=function(e,t){return t||L(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||L(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||L(e,2,this.length),this[e]<<8|this[e+1]},a.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]},a.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])},a.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var o=this[e],r=1,i=0;++i=(r*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var o=t,r=1,i=this[e+--o];o>0&&(r*=256);)i+=this[e+--o]*r;return i>=(r*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return t||L(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.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},a.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},a.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},a.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]},a.prototype.readFloatLE=function(e,t){return t||L(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||L(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||L(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||L(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,o){e=+e,t|=0,n|=0,o||D(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+r]=e/i&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),a.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},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),a.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},a.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);D(this,e,t,n,r-1,-r)}var i=0,s=1,c=0;for(this[t]=255&e;++i>0)-c&255;return t+n},a.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);D(this,e,t,n,r-1,-r)}var i=n-1,s=1,c=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===c&&0!==this[t+i+1]&&(c=1),this[t+i]=(e/s>>0)-c&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,2147483647,-2147483648),a.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},a.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),a.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},a.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,o){if(n||(n=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t=0;--r)e[r+t]=this[r+n];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(t-=3)>-1&&i.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&i.push(239,191,189);if(r=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(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,o){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"base64-js":78,buffer:81,ieee754:83,isarray:84}],82:[function(e,t,n){function o(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function s(e){return"object"===r(e)&&null!==e}function c(e){return void 0===e}t.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0,o.defaultMaxListeners=10,o.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},o.prototype.emit=function(e){var t,n,o,r,a,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(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(c(n=this._events[e]))return!1;if(i(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:r=Array.prototype.slice.call(arguments,1),n.apply(this,r)}else if(s(n))for(r=Array.prototype.slice.call(arguments,1),o=(u=n.slice()).length,a=0;a0&&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},o.prototype.on=o.prototype.addListener,o.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=!1;function o(){this.removeListener(e,o),n||(n=!0,t.apply(this,arguments))}return o.listener=t,this.on(e,o),this},o.prototype.removeListener=function(e,t){var n,o,r,c;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=(n=this._events[e]).length,o=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(c=r;c-- >0;)if(n[c]===t||n[c].listener&&n[c].listener===t){o=c;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},o.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(i(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},o.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},o.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},o.listenerCount=function(e,t){return e.listenerCount(t)}},{}],83:[function(e,t,n){n.read=function(e,t,n,o,r){var i,s,c=8*r-o-1,a=(1<>1,l=-7,p=n?r-1:0,h=n?-1:1,d=e[t+p];for(p+=h,i=d&(1<<-l)-1,d>>=-l,l+=c;l>0;i=256*i+e[t+p],p+=h,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=o;l>0;s=256*s+e[t+p],p+=h,l-=8);if(0===i)i=1-u;else{if(i===a)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,o),i-=u}return(d?-1:1)*s*Math.pow(2,i-o)},n.write=function(e,t,n,o,r,i){var s,c,a,u=8*i-r-1,l=(1<>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=o?0:i-1,f=o?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+p>=1?h/a:h*Math.pow(2,1-p))*a>=2&&(s++,a/=2),s+p>=l?(c=0,s=l):s+p>=1?(c=(t*a-1)*Math.pow(2,r),s+=p):(c=t*Math.pow(2,p-1)*Math.pow(2,r),s=0));r>=8;e[n+d]=255&c,d+=f,c/=256,r-=8);for(s=s<0;e[n+d]=255&s,d+=f,s/=256,u-=8);e[n+d-f]|=128*g}},{}],84:[function(e,t,n){var o={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==o.call(e)}},{}],85:[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 o(e,r){if(e===r)return!0;if(Object.prototype.toString.call(e)!==Object.prototype.toString.call(r))return!1;if(!0===t(e)){if(e.length!==r.length)return!1;for(var i=0;i":!0,"=":!0,"!":!0},G={" ":!0,"\t":!0,"\n":!0};function z(e){return e>="0"&&e<="9"||"-"===e}function K(){}K.prototype={tokenize:function(e){var t,n,o,r,i=[];for(this._current=0;this._current="a"&&r<="z"||r>="A"&&r<="Z"||"_"===r)t=this._current,n=this._consumeUnquotedIdentifier(e),i.push({type:g,value:n,start:t});else if(void 0!==H[e[this._current]])i.push({type:H[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(z(e[this._current]))o=this._consumeNumber(e),i.push(o);else if("["===e[this._current])o=this._consumeLBracket(e),i.push(o);else if('"'===e[this._current])t=this._current,n=this._consumeQuotedIdentifier(e),i.push({type:m,value:n,start:t});else if("'"===e[this._current])t=this._current,n=this._consumeRawStringLiteral(e),i.push({type:V,value:n,start:t});else if("`"===e[this._current]){t=this._current;var s=this._consumeLiteral(e);i.push({type:V,value:s,start:t})}else if(void 0!==W[e[this._current]])i.push(this._consumeOperator(e));else if(void 0!==G[e[this._current]])this._current++;else if("&"===e[this._current])t=this._current,this._current++,"&"===e[this._current]?(this._current++,i.push({type:w,value:"&&",start:t})):i.push({type:I,value:"&",start:t});else{if("|"!==e[this._current]){var c=new Error("Unknown character:"+e[this._current]);throw c.name="LexerError",c}t=this._current,this._current++,"|"===e[this._current]?(this._current++,i.push({type:_,value:"||",start:t})):i.push({type:A,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:O,value:">=",start:t}):{type:N,value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:R,value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t,n=this._current,o=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 Y={};function X(){}function J(e){this.runtime=e}function Q(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[s]}]},avg:{_func:this._functionAvg,_signature:[{types:[h]}]},ceil:{_func:this._functionCeil,_signature:[{types:[s]}]},contains:{_func:this._functionContains,_signature:[{types:[a,u]},{types:[c]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[a]},{types:[a]}]},floor:{_func:this._functionFloor,_signature:[{types:[s]}]},length:{_func:this._functionLength,_signature:[{types:[a,u,l]}]},map:{_func:this._functionMap,_signature:[{types:[p]},{types:[u]}]},max:{_func:this._functionMax,_signature:[{types:[h,d]}]},merge:{_func:this._functionMerge,_signature:[{types:[l],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[u]},{types:[p]}]},sum:{_func:this._functionSum,_signature:[{types:[h]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[a]},{types:[a]}]},min:{_func:this._functionMin,_signature:[{types:[h,d]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[u]},{types:[p]}]},type:{_func:this._functionType,_signature:[{types:[c]}]},keys:{_func:this._functionKeys,_signature:[{types:[l]}]},values:{_func:this._functionValues,_signature:[{types:[l]}]},sort:{_func:this._functionSort,_signature:[{types:[d,h]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[u]},{types:[p]}]},join:{_func:this._functionJoin,_signature:[{types:[a]},{types:[d]}]},reverse:{_func:this._functionReverse,_signature:[{types:[a,u]}]},to_array:{_func:this._functionToArray,_signature:[{types:[c]}]},to_string:{_func:this._functionToString,_signature:[{types:[c]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[c]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[c],variadic:!0}]}}}Y[f]=0,Y[g]=0,Y[m]=0,Y[v]=0,Y[y]=0,Y[E]=0,Y[b]=0,Y[C]=0,Y[T]=0,Y[I]=0,Y[A]=1,Y[_]=2,Y[w]=3,Y[R]=5,Y[N]=5,Y[k]=5,Y[O]=5,Y[L]=5,Y[D]=5,Y[P]=9,Y[x]=20,Y[M]=21,Y[U]=40,Y[q]=45,Y[F]=50,Y[j]=55,Y[B]=60,X.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if(this._lookahead(0)!==f){var n=this._lookaheadToken(0),o=new Error("Unexpected token type: "+n.type+", value: "+n.value);throw o.name="ParserError",o}return t},_loadTokens:function(e){var t=(new K).tokenize(e);t.push({type:f,value:"",start:e.length}),this.tokens=t},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var n=this.nud(t),o=this._lookahead(0);e=0?this.expression(e):t===j?(this._match(j),this._parseMultiselectList()):t===F?(this._match(F),this._parseMultiselectHash()):void 0},_parseProjectionRHS:function(e){var t;if(Y[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===j)t=this.expression(e);else if(this._lookahead(0)===M)t=this.expression(e);else{if(this._lookahead(0)!==U){var n=this._lookaheadToken(0),o=new Error("Sytanx error, unexpected token: "+n.value+"("+n.type+")");throw o.name="ParserError",o}this._match(U),t=this._parseDotRHS(e)}return t},_parseMultiselectList:function(){for(var e=[];this._lookahead(0)!==v;){var t=this.expression(0);if(e.push(t),this._lookahead(0)===E&&(this._match(E),this._lookahead(0)===v))throw new Error("Unexpected token Rbracket")}return this._match(v),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e,t,n,o=[],r=[g,m];;){if(e=this._lookaheadToken(0),r.indexOf(e.type)<0)throw new Error("Expecting an identifier token, got: "+e.type);if(t=e.value,this._advance(),this._match(S),n={type:"KeyValuePair",name:t,value:this.expression(0)},o.push(n),this._lookahead(0)===E)this._match(E);else if(this._lookahead(0)===b){this._match(b);break}}return{type:"MultiSelectHash",children:o}}},J.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,i){var s,c,a,u,l,p,h,d,f;switch(e.type){case"Field":return null===i?null:n(i)?void 0===(p=i[e.name])?null:p:null;case"Subexpression":for(a=this.visit(e.children[0],i),f=1;f0)for(f=y;fE;f+=S)a.push(i[f]);return a;case"Projection":var b=this.visit(e.children[0],i);if(!t(b))return null;for(d=[],f=0;fl;break;case O:a=u>=l;break;case k:a=u=e&&(t=n<0?e-1:e),t}},Q.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 o,r,i,s;if(n[n.length-1].variadic){if(t.length=0;o--)n+=t[o];return n}var r=e[0].slice(0);return r.reverse(),r},_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],o=0;o=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,o=e[0],r=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],o=1;o0){if(this._getTypeName(e[0][0])===s)return Math.min.apply(Math,e[0]);for(var t=e[0],n=t[0],o=1;oc?1:sc&&(c=n,t=r[u]);return t},_functionMinBy:function(e){for(var t,n,o=e[1],r=e[0],i=this.createKeyFunction(o,[s,a]),c=1/0,u=0;u1)for(var n=1;n0&&u>a&&(u=a);for(var l=0;l=0?(p=g.substr(0,m),h=g.substr(m+1)):(p=g,h=""),d=decodeURIComponent(p),f=decodeURIComponent(h),o(s,d)?r(s[d])?s[d].push(f):s[d]=[s[d],f]:s[d]=f}return s};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],88:[function(e,t,n){"use strict";var o=function(e){switch(r(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"===r(e)?s(c(e),(function(r){var c=encodeURIComponent(o(r))+n;return i(e[r])?s(e[r],(function(e){return c+encodeURIComponent(o(e))})).join(t):c+encodeURIComponent(o(e[r]))})).join(t):a?encodeURIComponent(o(a))+n+encodeURIComponent(o(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function s(e,t){if(e.map)return e.map(t);for(var n=[],o=0;o0&&a>c&&(a=c);for(var u=0;u=0?(l=f.substr(0,g),p=f.substr(g+1)):(l=f,p=""),h=decodeURIComponent(l),d=decodeURIComponent(p),o(i,h)?Array.isArray(i[h])?i[h].push(d):i[h]=[i[h],d]:i[h]=d}return i}},{}],91:[function(e,t,n){"use strict";var o=function(e){switch(r(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,i){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"===r(e)?Object.keys(e).map((function(r){var i=encodeURIComponent(o(r))+n;return Array.isArray(e[r])?e[r].map((function(e){return i+encodeURIComponent(o(e))})).join(t):i+encodeURIComponent(o(e[r]))})).join(t):i?encodeURIComponent(o(i))+n+encodeURIComponent(o(e)):""}},{}],92:[function(e,t,n){arguments[4][89][0].apply(n,arguments)},{"./decode":90,"./encode":91,dup:89}],93:[function(e,t,n){(function(t,o){(function(){var r=e("process/browser.js").nextTick,i=Function.prototype.apply,s=Array.prototype.slice,c={},a=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=a++,o=!(arguments.length<2)&&s.call(arguments,1);return c[t]=!0,r((function(){c[t]&&(o?e.apply(null,o):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"==typeof o?o:function(e){delete c[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":86,timers:93}],94:[function(e,t,n){var o=e("punycode");function i(){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=y,n.resolve=function(e,t){return y(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?y(e,!1,!0).resolveObject(t):t},n.format=function(e){return E(e)&&(e=y(e)),e instanceof i?e.format():i.prototype.format.call(e)},n.Url=i;var s=/^([a-z0-9.+-]+:)/i,c=/:[0-9]*$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(a),l=["%","/","?",";","#"].concat(u),p=["/","?","#"],h=/^[a-z0-9A-Z_-]{0,63}$/,d=/^([a-z0-9A-Z_-]{0,63})(.*)$/,f={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function y(e,t,n){if(e&&S(e)&&e instanceof i)return e;var o=new i;return o.parse(e,t,n),o}function E(e){return"string"==typeof e}function S(e){return"object"===r(e)&&null!==e}function b(e){return null===e}i.prototype.parse=function(e,t,n){if(!E(e))throw new TypeError("Parameter 'url' must be a string, not "+r(e));var i=e;i=i.trim();var c=s.exec(i);if(c){var a=(c=c[0]).toLowerCase();this.protocol=a,i=i.substr(c.length)}if(n||c||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var y="//"===i.substr(0,2);!y||c&&g[c]||(i=i.substr(2),this.slashes=!0)}if(!g[c]&&(y||c&&!m[c])){for(var S,b,C=-1,T=0;T127?N+="x":N+=R[k];if(!N.match(h)){var L=_.slice(0,T),D=_.slice(T+1),P=R.match(d);P&&(L.push(P[1]),D.unshift(P[2])),D.length&&(i="/"+D.join(".")+i),this.hostname=L.join(".");break}}}if(this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),!A){var x=this.hostname.split("."),M=[];for(T=0;T0)&&n.host.split("@"))&&(n.auth=S.shift(),n.host=n.hostname=S.shift())),n.search=e.search,n.query=e.query,b(n.pathname)&&b(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 d=p.slice(-1)[0],f=(n.host||e.host)&&("."===d||".."===d)||""===d,v=0,y=p.length;y>=0;y--)"."==(d=p[y])?p.splice(y,1):".."===d?(p.splice(y,1),v++):v&&(p.splice(y,1),v--);if(!u&&!l)for(;v--;v)p.unshift("..");!u||""===p[0]||p[0]&&"/"===p[0].charAt(0)||p.unshift(""),f&&"/"!==p.join("/").substr(-1)&&p.push("");var S,C=""===p[0]||p[0]&&"/"===p[0].charAt(0);return h&&(n.hostname=n.host=C?"":p.length?p.shift():"",(S=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=S.shift(),n.host=n.hostname=S.shift())),(u=u||n.host&&p.length)&&!C&&p.unshift(""),p.length?n.pathname=p.join("/"):(n.pathname=null,n.path=null),b(n.pathname)&&b(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},i.prototype.parseHost=function(){var e=this.host,t=c.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{punycode:80,querystring:89}],95:[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}},{}],96:[function(e,t,n){t.exports=function(e){return e&&"object"===r(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],97:[function(e,t,o){(function(t,n){(function(){var i=/%[sdj%]/g;o.format=function(e){if(!y(e)){for(var t=[],n=0;n=r)return e;switch(e){case"%s":return String(o[n++]);case"%d":return Number(o[n++]);case"%j":try{return JSON.stringify(o[n++])}catch(e){return"[Circular]"}default:return e}})),c=o[n];n=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(t)?n.showHidden=t:t&&o._extend(n,t),E(n.showHidden)&&(n.showHidden=!1),E(n.depth)&&(n.depth=2),E(n.colors)&&(n.colors=!1),E(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),p(n,e,n.depth)}function u(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function l(e,t){return e}function p(e,t,n){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==o.inspect&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return y(r)||(r=p(e,r,n)),r}var i=function(e,t){if(E(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var s=Object.keys(t),c=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 h(t);if(0===s.length){if(I(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(S(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(C(t))return e.stylize(Date.prototype.toString.call(t),"date");if(T(t))return h(t)}var u,l="",b=!1,A=["{","}"];return f(t)&&(b=!0,A=["[","]"]),I(t)&&(l=" [Function"+(t.name?": "+t.name:"")+"]"),S(t)&&(l=" "+RegExp.prototype.toString.call(t)),C(t)&&(l=" "+Date.prototype.toUTCString.call(t)),T(t)&&(l=" "+h(t)),0!==s.length||b&&0!=t.length?n<0?S(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=b?function(e,t,n,o,r){for(var i=[],s=0,c=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(u,l,A)):A[0]+l+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,o,r,i){var s,c,a;if((a=Object.getOwnPropertyDescriptor(t,r)||{value:t[r]}).get?c=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(c=e.stylize("[Setter]","special")),R(o,r)||(s="["+r+"]"),c||(e.seen.indexOf(a.value)<0?(c=m(n)?p(e,a.value,null):p(e,a.value,n-1)).indexOf("\n")>-1&&(c=i?c.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+c.split("\n").map((function(e){return" "+e})).join("\n")):c=e.stylize("[Circular]","special")),E(s)){if(i&&r.match(/^\d+$/))return c;(s=JSON.stringify(""+r)).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+": "+c}function f(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function v(e){return"number"==typeof e}function y(e){return"string"==typeof e}function E(e){return void 0===e}function S(e){return b(e)&&"[object RegExp]"===A(e)}function b(e){return"object"===r(e)&&null!==e}function C(e){return b(e)&&"[object Date]"===A(e)}function T(e){return b(e)&&("[object Error]"===A(e)||e instanceof Error)}function I(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function _(e){return e<10?"0"+e.toString(10):e.toString(10)}o.debuglog=function(e){if(E(s)&&(s=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!c[e])if(new RegExp("\\b"+e+"\\b","i").test(s)){var n=t.pid;c[e]=function(){var t=o.format.apply(o,arguments);console.error("%s %d: %s",e,n,t)}}else c[e]=function(){};return c[e]},o.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"},o.isArray=f,o.isBoolean=g,o.isNull=m,o.isNullOrUndefined=function(e){return null==e},o.isNumber=v,o.isString=y,o.isSymbol=function(e){return"symbol"===r(e)},o.isUndefined=E,o.isRegExp=S,o.isObject=b,o.isDate=C,o.isError=T,o.isFunction=I,o.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===r(e)||void 0===e},o.isBuffer=e("./support/isBuffer");var w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}o.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[_(e.getHours()),_(e.getMinutes()),_(e.getSeconds())].join(":"),[e.getDate(),w[e.getMonth()],t].join(" ")),o.format.apply(o,arguments))},o.inherits=e("inherits"),o._extend=function(e,t){if(!t||!b(t))return e;for(var n=Object.keys(t),o=n.length;o--;)e[n[o]]=t[n[o]];return e}}).call(this)}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":96,_process:86,inherits:95}],98:[function(e,t,n){var o=e("./v1"),r=e("./v4"),i=r;i.v1=o,i.v4=r,t.exports=i},{"./v1":101,"./v4":102}],99:[function(e,t,n){for(var o=[],r=0;r<256;++r)o[r]=(r+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,r=o;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}},{}],100:[function(e,t,n){var o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(o){var r=new Uint8Array(16);t.exports=function(){return o(r),r}}else{var i=new Array(16);t.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},{}],101:[function(e,t,n){var o,r,i=e("./lib/rng"),s=e("./lib/bytesToUuid"),c=0,a=0;t.exports=function(e,t,n){var u=t&&n||0,l=t||[],p=(e=e||{}).node||o,h=void 0!==e.clockseq?e.clockseq:r;if(null==p||null==h){var d=i();null==p&&(p=o=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==h&&(h=r=16383&(d[6]<<8|d[7]))}var f=void 0!==e.msecs?e.msecs:(new Date).getTime(),g=void 0!==e.nsecs?e.nsecs:a+1,m=f-c+(g-a)/1e4;if(m<0&&void 0===e.clockseq&&(h=h+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,a=g,r=h;var v=(1e4*(268435455&(f+=122192928e5))+g)%4294967296;l[u++]=v>>>24&255,l[u++]=v>>>16&255,l[u++]=v>>>8&255,l[u++]=255&v;var y=f/4294967296*1e4&268435455;l[u++]=y>>>8&255,l[u++]=255&y,l[u++]=y>>>24&15|16,l[u++]=y>>>16&255,l[u++]=h>>>8|128,l[u++]=255&h;for(var E=0;E<6;++E)l[u+E]=p[E];return t||s(l)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],102:[function(e,t,n){var o=e("./lib/rng"),r=e("./lib/bytesToUuid");t.exports=function(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||o)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var c=0;c<16;++c)t[i+c]=s[c];return t||r(s)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],103:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e("./utils/LRU"),r=function(){function e(e){void 0===e&&(e=1e3),this.maxSize=e,this.cache=new o.LRUCache(e)}return Object.defineProperty(e.prototype,"size",{get:function(){return this.cache.length},enumerable:!0,configurable:!0}),e.prototype.put=function(t,n){var o="string"!=typeof t?e.getKeyString(t):t,r=this.populateValue(n);this.cache.put(o,r)},e.prototype.get=function(t){var n="string"!=typeof t?e.getKeyString(t):t,o=Date.now(),r=this.cache.get(n);if(r)for(var i=0;i{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect,connect.ClientMethods=connect.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"]),connect.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"},connect.MasterMethods=connect.makeEnum(["becomeMaster","checkMaster"]);var t=function(){};t.EMPTY_CALLBACKS={success:function(){},failure:function(){}},t.prototype.call=function(e,n,o){connect.assertNotNull(e,"method");var r=n||{},i=o||t.EMPTY_CALLBACKS;this._callImpl(e,r,i)},t.prototype._callImpl=function(e,t,n){throw new connect.NotImplementedError};var n=function(){t.call(this)};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype._callImpl=function(e,t,n){if(n&&n.failure){var o=connect.sprintf("No such method exists on NULL client: %s",e);n.failure(new connect.ValueError(o),{message:o})}};var o=function(e,n,o){t.call(this),this.conduit=e,this.requestEvent=n,this.responseEvent=o,this._requestIdCallbacksMap={},this.conduit.onUpstream(o,connect.hitch(this,this._handleResponse))};(o.prototype=Object.create(t.prototype)).constructor=o,o.prototype._callImpl=function(e,t,n){var o=connect.EventFactory.createRequest(this.requestEvent,e,t);this._requestIdCallbacksMap[o.requestId]=n,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 r=function(e){o.call(this,e,connect.EventType.API_REQUEST,connect.EventType.API_RESPONSE)};(r.prototype=Object.create(o.prototype)).constructor=r;var i=function(e){o.call(this,e,connect.EventType.MASTER_REQUEST,connect.EventType.MASTER_RESPONSE)};(i.prototype=Object.create(o.prototype)).constructor=i;var s=function(e,n,o){connect.assertNotNull(e,"authCookieName"),connect.assertNotNull(n,"authToken"),connect.assertNotNull(o,"endpoint"),t.call(this),this.endpointUrl=connect.getUrlWithProtocol(o),this.authToken=n,this.authCookieName=e};(s.prototype=Object.create(t.prototype)).constructor=s,s.prototype._callImpl=function(e,t,n){var o=this,r={};r[o.authCookieName]=o.authToken;var i={method:"post",body:JSON.stringify(t||{}),headers:{Accept:"application/json","Content-Type":"application/json","X-Amz-target":e,"X-Amz-Bearer":JSON.stringify(r)}};connect.fetch(o.endpointUrl,i).then((function(e){n.success(e)})).catch((function(e){var t=e.body.getReader(),o="",r=new TextDecoder;t.read().then((function i(s){var c=s.done,a=s.value;if(c){var u=JSON.parse(o);return u.status=e.status,void n.failure(u)}return o+=r.decode(a),t.read().then(i)}))}))};var c=function(e,n,o){connect.assertNotNull(e,"authToken"),connect.assertNotNull(n,"region"),t.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=n,this.authToken=e;var r=connect.getBaseUrl(),i=o||(r.includes(".awsapps.com")?r+"/connect/api":r+"/api"),s=new AWS.Endpoint(i);this.client=new AWS.Connect({endpoint:s})};(c.prototype=Object.create(t.prototype)).constructor=c,c.prototype._callImpl=function(e,t,n){var o=this,r=connect.getLog();if(connect.contains(this.client,e))t=this._translateParams(e,t),r.trace("AWSClient: --\x3e Calling operation '%s'",e).sendInternalLogToServer(),this.client[e](t).on("build",(function(e){e.httpRequest.headers["X-Amz-Bearer"]=o.authToken})).send((function(t,o){try{if(t){if(t.code===connect.CTIExceptions.UNAUTHORIZED_EXCEPTION)n.authFailure();else if(!n.accessDenied||t.code!==connect.CTIExceptions.ACCESS_DENIED_EXCEPTION&&403!==t.statusCode){var i={};i.type=t.code,i.message=t.message,i.stack=t.stack?t.stack.split("\n"):[],n.failure(i,o)}else n.accessDenied();r.trace("AWSClient: <-- Operation '%s' failed: %s",e,JSON.stringify(t)).sendInternalLogToServer()}else r.trace("AWSClient: <-- Operation '%s' succeeded.",e).withObject(o).sendInternalLogToServer(),n.success(o)}catch(t){connect.getLog().error("Failed to handle AWS API request for method %s",e).withException(t).sendInternalLogToServer()}}));else{var i=connect.sprintf("No such method exists on AWS client: %s",e);n.failure(new connect.ValueError(i),{message:i})}},c.prototype._requiresAuthenticationParam=function(e){return e!==connect.ClientMethods.COMPLETE_CONTACT&&e!==connect.ClientMethods.CLEAR_CONTACT&&e!==connect.ClientMethods.REJECT_CONTACT&&e!==connect.ClientMethods.CREATE_TASK_CONTACT},c.prototype._translateParams=function(e,t){switch(e){case connect.ClientMethods.UPDATE_AGENT_CONFIGURATION:t.configuration=this._translateAgentConfiguration(t.configuration);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS:t.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(t.softphoneStreamStatistics);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT:t.report=this._translateSoftphoneCallReport(t.report)}return this._requiresAuthenticationParam(e)&&(t.authentication={authToken:this.authToken}),t},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},connect.ClientBase=t,connect.NullClient=n,connect.UpstreamConduitClient=r,connect.UpstreamConduitMasterClient=i,connect.AWSClient=c,connect.AgentAppClient=s}()},531:()=>{function e(e,n){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,n){if(e){if("string"==typeof e)return t(e,n);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){o&&(e=o);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,c=!0,a=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return c=e.done,e},e:function(e){a=!0,s=e},f:function(){try{c||null==o.return||o.return()}finally{if(a)throw s}}}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n{!function(){connect=this.connect||{},this.connect=connect;var e="<>",t=connect.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","update_connected_ccps","outer_context_info","media_device_request","media_device_response"]),n=connect.makeNamespacedEnum("connect",["loginPopup","sendLogs","softphone","ringtone","metrics"]),o=connect.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"]),r=connect.makeNamespacedEnum("webSocket",["init_failure","connection_open","connection_close","connection_error","connection_gain","connection_lost","subscription_update","subscription_failure","all_message","send","subscribe"]),i=connect.makeNamespacedEnum("contact",["init","refresh","destroyed","incoming","pending","connecting","connected","missed","acw","view","ended","error","accepted"]),s=connect.makeNamespacedEnum("taskList",["activate_channel_with_view_type"]),c=connect.makeNamespacedEnum("task",["created"]),a=connect.makeNamespacedEnum("connection",["session_init","ready_to_start_session"]),u=connect.makeNamespacedEnum("configuration",["configure","set_speaker_device","set_microphone_device","set_ringer_device","speaker_device_changed","microphone_device_changed","ringer_device_changed"]),l=connect.makeNamespacedEnum("voiceId",["update_domain_id"]),p=function(){};p.createRequest=function(e,t,n){return{event:e,requestId:connect.randomId(),method:t,params:n}},p.createResponse=function(e,t,n,o){return{event:e,requestId:t.requestId,data:n,err:o||null}};var h=function(e,t,n){this.subMap=e,this.id=connect.randomId(),this.eventName=t,this.f=n};h.prototype.unsubscribe=function(){this.subMap.unsubscribe(this.eventName,this.id)};var d=function(){this.subIdMap={},this.subEventNameMap={}};d.prototype.subscribe=function(e,t){var n=new h(this,e,t);this.subIdMap[n.id]=n;var o=this.subEventNameMap[e]||[];return o.push(n),this.subEventNameMap[e]=o,n},d.prototype.unsubscribe=function(e,t){connect.contains(this.subEventNameMap,e)&&(this.subEventNameMap[e]=this.subEventNameMap[e].filter((function(e){return e.id!==t})),this.subEventNameMap[e].length<1&&delete this.subEventNameMap[e]),connect.contains(this.subIdMap,t)&&delete this.subIdMap[t]},d.prototype.getAllSubscriptions=function(){return connect.values(this.subEventNameMap).reduce((function(e,t){return e.concat(t)}),[])},d.prototype.getSubscriptions=function(e){return this.subEventNameMap[e]||[]};var f=function(e){var t=e||{};this.subMap=new d,this.logEvents=t.logEvents||!1};f.prototype.subscribe=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.subMap.subscribe(e,t)},f.prototype.subscribeAll=function(t){return connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.subMap.subscribe(e,t)},f.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},f.prototype.trigger=function(t,n){connect.assertNotNull(t,"eventName");var o=this,r=this.subMap.getSubscriptions(e),i=this.subMap.getSubscriptions(t);this.logEvents&&t!==connect.EventType.LOG&&t!==connect.EventType.MASTER_RESPONSE&&t!==connect.EventType.API_METRIC&&t!==connect.EventType.SERVER_BOUND_INTERNAL_LOG&&connect.getLog().trace("Publishing event: %s",t).sendInternalLogToServer(),t.startsWith(connect.ContactEvents.ACCEPTED)&&n&&n.contactId&&!(n instanceof connect.Contact)&&(n=new connect.Contact(n.contactId)),r.concat(i).forEach((function(e){try{e.f(n||null,t,o)}catch(e){connect.getLog().error("'%s' event handler failed.",t).withException(e).sendInternalLogToServer()}}))},f.prototype.bridge=function(){var e=this;return function(t,n){e.trigger(n,t)}},f.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach((function(e){e.unsubscribe()}))},connect.EventBus=f,connect.EventFactory=p,connect.EventType=t,connect.AgentEvents=o,connect.ConfigurationEvents=u,connect.ConnectionEvents=a,connect.ConnnectionEvents=a,connect.ContactEvents=i,connect.ChannelViewEvents=s,connect.TaskEvents=c,connect.VoiceIdEvents=l,connect.WebSocketEvents=r,connect.MasterTopics=n}()},42:()=>{function e(t){return e="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(t)}!function(t){var n={};function o(e){if(n[e])return n[e].exports;var r=n[e]={i:e,l:!1,exports:{}};return t[e].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=t,o.c=n,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,n){if(1&n&&(t=o(t)),8&n)return t;if(4&n&&"object"==e(t)&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)o.d(r,i,function(e){return t[e]}.bind(null,i));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=2)}([function(t,n,o){"use strict";var r=o(1),i="DEBUG",s="aws/subscribe",c="aws/heartbeat",a="disconnected";function u(t){return(u="function"==typeof Symbol&&"symbol"==e(Symbol.iterator)?function(t){return e(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)})(t)}var l={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return l.assertTrue(null!==e&&void 0!==u(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"!==u(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},p=new RegExp("^(wss://)\\w*");l.validWSUrl=function(e){return p.test(e)},l.getSubscriptionResponse=function(e,t,n){return{topic:e,content:{status:t?"success":"failure",topics:n}}},l.assertIsObject=function(e,t){if(!l.isObject(e))throw new Error(t+" is not an object!")},l.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)},l.isNetworkOnline=function(){return navigator.onLine},l.isNetworkFailure=function(e){return!(!e._debug||!e._debug.type)&&"NetworkingError"===e._debug.type};var h=l;function d(t){return(d="function"==typeof Symbol&&"symbol"==e(Symbol.iterator)?function(t){return e(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)})(t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(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||"";return this._logsDestination===i?this.consoleLoggerWrapper:new T(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||S.DEBUG,this._clientLogger=t.logger||null,this._logsDestination="NULL",t.debug&&(this._logsDestination=i),t.logger&&(this._logsDestination="CLIENT_LOGGER")}}]),e}(),C=function(){function e(){m(this,e)}return y(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),e}(),T=function(e){function t(e){var n;return m(this,t),(n=function(e,t){return!t||"object"!==d(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,f(t).call(this))).prefix=e||"",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&&g(e,t)}(t,C),y(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}}])&&_(t.prototype,n),e}();o.d(n,"a",(function(){return N}));var R=function(){var e=A.getLogger({}),t=h.isNetworkOnline(),n={primary:null,secondary:null},o={reconnectWebSocket:!0,websocketInitFailed:!1,exponentialBackOffTime:1e3,exponentialTimeoutHandle:null,lifeTimeTimeoutHandle:null,webSocketInitCheckerTimeoutId:null,connState:null},r={connectWebSocketRetryCount:0,connectionAttemptStartTime:null,noOpenConnectionsTimestamp:null},i={pendingResponse:!1,intervalHandle:null},u={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},l={connConfig:null,promiseHandle:null,promiseCompleted:!0},p={subscribed:new Set,pending:new Set,subscriptionHistory:new Set},d={responseCheckIntervalId:null,requestCompleted:!0,reSubscribeIntervalId:null,consecutiveFailedSubscribeAttempts:0,consecutiveNoResponseRequest:0},f=new w((function(){B()})),g=new Set([s,"aws/unsubscribe",c]),m=setInterval((function(){if(t!==h.isNetworkOnline()){if(!(t=h.isNetworkOnline()))return void W(e.info("Network offline"));var n=T();t&&(!n||S(n,WebSocket.CLOSING)||S(n,WebSocket.CLOSED))&&(W(e.info("Network online, connecting to WebSocket server")),B())}}),250),v=function(t,n){t.forEach((function(t){try{t(n)}catch(t){W(e.error("Error executing callback",t))}}))},y=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"}},E=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";W(e.debug("["+t+"] Primary WebSocket: "+y(n.primary)+" | Secondary WebSocket: "+y(n.secondary)))},S=function(e,t){return e&&e.readyState===t},b=function(e){return S(e,WebSocket.OPEN)},C=function(e){return null===e||void 0===e.readyState||S(e,WebSocket.CLOSED)},T=function(){return null!==n.secondary?n.secondary:n.primary},I=function(){return b(T())},_=function(){if(i.pendingResponse)return W(e.warn("Heartbeat response not received")),clearInterval(i.intervalHandle),i.pendingResponse=!1,void B();I()?(W(e.debug("Sending heartbeat")),T().send(F(c)),i.pendingResponse=!0):(W(e.warn("Failed to send heartbeat since WebSocket is not open")),E("sendHeartBeat"),B())},R=function(){o.exponentialBackOffTime=1e3,i.pendingResponse=!1,o.reconnectWebSocket=!0,clearTimeout(o.lifeTimeTimeoutHandle),clearInterval(i.intervalHandle),clearTimeout(o.exponentialTimeoutHandle),clearTimeout(o.webSocketInitCheckerTimeoutId)},N=function(){d.consecutiveFailedSubscribeAttempts=0,d.consecutiveNoResponseRequest=0,clearInterval(d.responseCheckIntervalId),clearInterval(d.reSubscribeIntervalId)},k=function(){r.connectWebSocketRetryCount=0,r.connectionAttemptStartTime=null,r.noOpenConnectionsTimestamp=null},O=function(){try{W(e.info("WebSocket connection established!")),E("webSocketOnOpen"),null!==o.connState&&o.connState!==a||v(u.connectionGain),o.connState="connected";var t=Date.now();v(u.connectionOpen,{connectWebSocketRetryCount:r.connectWebSocketRetryCount,connectionAttemptStartTime:r.connectionAttemptStartTime,noOpenConnectionsTimestamp:r.noOpenConnectionsTimestamp,connectionEstablishedTime:t,timeToConnect:t-r.connectionAttemptStartTime,timeWithoutConnection:r.noOpenConnectionsTimestamp?t-r.noOpenConnectionsTimestamp:null}),k(),R(),T().openTimestamp=Date.now(),0===p.subscribed.size&&b(n.secondary)&&x(n.primary,"[Primary WebSocket] Closing WebSocket"),(p.subscribed.size>0||p.pending.size>0)&&(b(n.secondary)&&W(e.info("Subscribing secondary websocket to topics of primary websocket")),p.subscribed.forEach((function(e){p.subscriptionHistory.add(e),p.pending.add(e)})),p.subscribed.clear(),P()),_(),i.intervalHandle=setInterval(_,1e4);var s=1e3*l.connConfig.webSocketTransport.transportLifeTimeInSeconds;W(e.debug("Scheduling WebSocket manager reconnection, after delay "+s+" ms")),o.lifeTimeTimeoutHandle=setTimeout((function(){W(e.debug("Starting scheduled WebSocket manager reconnection")),B()}),s)}catch(t){W(e.error("Error after establishing WebSocket connection",t))}},L=function(t){E("webSocketOnError"),W(e.error("WebSocketManager Error, error_event: ",JSON.stringify(t))),B()},D=function(t){var o=JSON.parse(t.data);switch(o.topic){case s:if(W(e.debug("Subscription Message received from webSocket server",t.data)),d.requestCompleted=!0,d.consecutiveNoResponseRequest=0,"success"===o.content.status)d.consecutiveFailedSubscribeAttempts=0,o.content.topics.forEach((function(e){p.subscriptionHistory.delete(e),p.pending.delete(e),p.subscribed.add(e)})),0===p.subscriptionHistory.size?b(n.secondary)&&(W(e.info("Successfully subscribed secondary websocket to all topics of primary websocket")),x(n.primary,"[Primary WebSocket] Closing WebSocket")):P(),v(u.subscriptionUpdate,o);else{if(clearInterval(d.reSubscribeIntervalId),++d.consecutiveFailedSubscribeAttempts,5===d.consecutiveFailedSubscribeAttempts)return v(u.subscriptionFailure,o),void(d.consecutiveFailedSubscribeAttempts=0);d.reSubscribeIntervalId=setInterval((function(){P()}),500)}break;case c:W(e.debug("Heartbeat response received")),i.pendingResponse=!1;break;default:if(o.topic){if(W(e.debug("Message received for topic "+o.topic)),b(n.primary)&&b(n.secondary)&&0===p.subscriptionHistory.size&&this===n.primary)return void W(e.warn("Ignoring Message for Topic "+o.topic+", to avoid duplicates"));if(0===u.allMessage.size&&0===u.topic.size)return void W(e.warn("No registered callback listener for Topic",o.topic));v(u.allMessage,o),u.topic.has(o.topic)&&v(u.topic.get(o.topic),o)}else o.message?W(e.warn("WebSocketManager Message Error",o)):W(e.warn("Invalid incoming message",o))}},P=function t(){if(d.consecutiveNoResponseRequest>3)return W(e.warn("Ignoring subscribePendingTopics since we have exhausted max subscription retries with no response")),void v(u.subscriptionFailure,h.getSubscriptionResponse(s,!1,Array.from(p.pending)));I()?(clearInterval(d.responseCheckIntervalId),T().send(F(s,{topics:Array.from(p.pending)})),d.requestCompleted=!1,d.responseCheckIntervalId=setInterval((function(){d.requestCompleted||(++d.consecutiveNoResponseRequest,t())}),1e3)):W(e.warn("Ignoring subscribePendingTopics call since Default WebSocket is not open"))},x=function(t,n){S(t,WebSocket.CONNECTING)||S(t,WebSocket.OPEN)?t.close(1e3,n):W(e.warn("Ignoring WebSocket Close request, WebSocket State: "+y(t)))},M=function(e){x(n.primary,"[Primary] WebSocket "+e),x(n.secondary,"[Secondary] WebSocket "+e)},U=function(){r.connectWebSocketRetryCount++;var t=h.addJitter(o.exponentialBackOffTime,.3);Date.now()+t<=l.connConfig.urlConnValidTime?(W(e.debug("Scheduling WebSocket reinitialization, after delay "+t+" ms")),o.exponentialTimeoutHandle=setTimeout((function(){return V()}),t),o.exponentialBackOffTime*=2):(W(e.warn("WebSocket URL cannot be used to establish connection")),B())},q=function(t){R(),N(),W(e.error("WebSocket Initialization failed")),o.websocketInitFailed=!0,M("Terminating WebSocket Manager"),clearInterval(m),v(u.initFailure,{connectWebSocketRetryCount:r.connectWebSocketRetryCount,connectionAttemptStartTime:r.connectionAttemptStartTime,reason:t}),k()},F=function(e,t){return JSON.stringify({topic:e,content:t})},j=function(t){return!!(h.isObject(t)&&h.isObject(t.webSocketTransport)&&h.isNonEmptyString(t.webSocketTransport.url)&&h.validWSUrl(t.webSocketTransport.url)&&1e3*t.webSocketTransport.transportLifeTimeInSeconds>=3e5)||(W(e.error("Invalid WebSocket Connection Configuration",t)),!1)},B=function(){if(h.isNetworkOnline())if(o.websocketInitFailed)W(e.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request"));else{if(l.promiseCompleted)return R(),W(e.info("Fetching new WebSocket connection configuration")),r.connectionAttemptStartTime=r.connectionAttemptStartTime||Date.now(),l.promiseCompleted=!1,l.promiseHandle=u.getWebSocketTransport(),l.promiseHandle.then((function(t){return l.promiseCompleted=!0,W(e.debug("Successfully fetched webSocket connection configuration",t)),j(t)?(l.connConfig=t,l.connConfig.urlConnValidTime=Date.now()+85e3,f.connected(),V()):(q("Invalid WebSocket connection configuration: "+t),{webSocketConnectionFailed:!0})}),(function(t){return l.promiseCompleted=!0,W(e.error("Failed to fetch webSocket connection configuration",t)),h.isNetworkFailure(t)?(W(e.info("Retrying fetching new WebSocket connection configuration")),f.retry()):q("Failed to fetch webSocket connection configuration: "+JSON.stringify(t)),{webSocketConnectionFailed:!0}}));W(e.debug("There is an ongoing getWebSocketConnConfig request, this request will be ignored"))}else W(e.info("Network offline, ignoring this getWebSocketConnConfig request"))},V=function(){if(o.websocketInitFailed)return W(e.info("web-socket initializing had failed, aborting re-init")),{webSocketConnectionFailed:!0};if(!h.isNetworkOnline())return W(e.warn("System is offline aborting web-socket init")),{webSocketConnectionFailed:!0};W(e.info("Initializing Websocket Manager")),E("initWebSocket");try{if(j(l.connConfig)){var t=null;return b(n.primary)?(W(e.debug("Primary Socket connection is already open")),S(n.secondary,WebSocket.CONNECTING)||(W(e.debug("Establishing a secondary web-socket connection")),n.secondary=H()),t=n.secondary):(S(n.primary,WebSocket.CONNECTING)||(W(e.debug("Establishing a primary web-socket connection")),n.primary=H()),t=n.primary),o.webSocketInitCheckerTimeoutId=setTimeout((function(){b(t)||U()}),1e3),{webSocketConnectionFailed:!1}}}catch(t){return W(e.error("Error Initializing web-socket-manager",t)),q("Failed to initialize new WebSocket: "+t.message),{webSocketConnectionFailed:!0}}},H=function(){var t=new WebSocket(l.connConfig.webSocketTransport.url);return t.addEventListener("open",O),t.addEventListener("message",D),t.addEventListener("error",L),t.addEventListener("close",(function(i){return function(t,i){W(e.info("Socket connection is closed",t)),E("webSocketOnClose before-cleanup"),v(u.connectionClose,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),C(n.primary)&&(n.primary=null),C(n.secondary)&&(n.secondary=null),o.reconnectWebSocket&&(b(n.primary)||b(n.secondary)?C(n.primary)&&b(n.secondary)&&(W(e.info("[Primary] WebSocket Cleanly Closed")),n.primary=n.secondary,n.secondary=null):(W(e.warn("Neither primary websocket and nor secondary websocket have open connections, attempting to re-establish connection")),o.connState===a?W(e.info("Ignoring connectionLost callback invocation")):(v(u.connectionLost,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),r.noOpenConnectionsTimestamp=Date.now()),o.connState=a,B()),E("webSocketOnClose after-cleanup"))}(i,t)})),t},W=function(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e};this.init=function(t){if(h.assertTrue(h.isFunction(t),"transportHandle must be a function"),null===u.getWebSocketTransport)return u.getWebSocketTransport=t,B();W(e.warn("Web Socket Manager was already initialized"))},this.onInitFailure=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.initFailure.add(e),o.websocketInitFailed&&e(),function(){return u.initFailure.delete(e)}},this.onConnectionOpen=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionOpen.add(e),function(){return u.connectionOpen.delete(e)}},this.onConnectionClose=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionClose.add(e),function(){return u.connectionClose.delete(e)}},this.onConnectionGain=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionGain.add(e),I()&&e(),function(){return u.connectionGain.delete(e)}},this.onConnectionLost=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionLost.add(e),o.connState===a&&e(),function(){return u.connectionLost.delete(e)}},this.onSubscriptionUpdate=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.subscriptionUpdate.add(e),function(){return u.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.subscriptionFailure.add(e),function(){return u.subscriptionFailure.delete(e)}},this.onMessage=function(e,t){return h.assertNotNull(e,"topicName"),h.assertTrue(h.isFunction(t),"cb must be a function"),u.topic.has(e)?u.topic.get(e).add(t):u.topic.set(e,new Set([t])),function(){return u.topic.get(e).delete(t)}},this.onAllMessage=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.allMessage.add(e),function(){return u.allMessage.delete(e)}},this.subscribeTopics=function(e){h.assertNotNull(e,"topics"),h.assertIsList(e),e.forEach((function(e){p.subscribed.has(e)||p.pending.add(e)})),d.consecutiveNoResponseRequest=0,P()},this.sendMessage=function(t){if(h.assertIsObject(t,"payload"),void 0===t.topic||g.has(t.topic))W(e.warn("Cannot send message, Invalid topic",t));else{try{t=JSON.stringify(t)}catch(n){return void W(e.warn("Error stringify message",t))}I()?T().send(t):W(e.warn("Cannot send message, web socket connection is not open"))}},this.closeWebSocket=function(){R(),N(),o.reconnectWebSocket=!1,clearInterval(m),M("User request to close WebSocket")},this.terminateWebSocketManager=q},N={create:function(){return new R},setGlobalConfig:function(e){var t=e.loggerConfig;A.updateLoggerConfig(t)},LogLevel:S,Logger:E}},function(t,n,o){var r;!function(){"use strict";var i={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 s(t){return function(t,n){var o,r,c,a,u,l,p,h,d,f=1,g=t.length,m="";for(r=0;r=0),a.type){case"b":o=parseInt(o,10).toString(2);break;case"c":o=String.fromCharCode(parseInt(o,10));break;case"d":case"i":o=parseInt(o,10);break;case"j":o=JSON.stringify(o,null,a.width?parseInt(a.width):0);break;case"e":o=a.precision?parseFloat(o).toExponential(a.precision):parseFloat(o).toExponential();break;case"f":o=a.precision?parseFloat(o).toFixed(a.precision):parseFloat(o);break;case"g":o=a.precision?String(Number(o.toPrecision(a.precision))):parseFloat(o);break;case"o":o=(parseInt(o,10)>>>0).toString(8);break;case"s":o=String(o),o=a.precision?o.substring(0,a.precision):o;break;case"t":o=String(!!o),o=a.precision?o.substring(0,a.precision):o;break;case"T":o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=a.precision?o.substring(0,a.precision):o;break;case"u":o=parseInt(o,10)>>>0;break;case"v":o=o.valueOf(),o=a.precision?o.substring(0,a.precision):o;break;case"x":o=(parseInt(o,10)>>>0).toString(16);break;case"X":o=(parseInt(o,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?m+=o:(!i.number.test(a.type)||h&&!a.sign?d="":(d=h?"+":"-",o=o.toString().replace(i.sign,"")),l=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",p=a.width-(d+o).length,u=a.width&&p>0?l.repeat(p):"",m+=a.align?d+o+u:"0"===l?d+u+o:u+d+o)}return m}(function(e){if(a[e])return a[e];for(var t,n=e,o=[],r=0;n;){if(null!==(t=i.text.exec(n)))o.push(t[0]);else if(null!==(t=i.modulo.exec(n)))o.push("%");else{if(null===(t=i.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){r|=1;var s=[],c=t[2],u=[];if(null===(u=i.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=i.key_access.exec(c)))s.push(u[1]);else{if(null===(u=i.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}t[2]=s}else r|=2;if(3===r)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");o.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]=o}(t),arguments)}function c(e,t){return s.apply(null,[e].concat(t||[]))}var a=Object.create(null);n.sprintf=s,n.vsprintf=c,"undefined"!=typeof window&&(window.sprintf=s,window.vsprintf=c,void 0===(r=function(){return{sprintf:s,vsprintf:c}}.call(n,o,n,t))||(t.exports=r))}()},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"WebSocketManager",(function(){return r}));var o=n(0);e.connect=e.connect||{},connect.WebSocketManager=o.a;var r=o.a}.call(this,n(3))},function(t,n){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch(t){"object"==("undefined"==typeof window?"undefined":e(window))&&(o=window)}t.exports=o}])},312:()=>{function e(t){return e="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(t)}!function(){var t=this;connect=t.connect||{},t.connect=connect,t.lily=connect;var n={TEST:"TEST",TRACE:"TRACE",DEBUG:"DEBUG",INFO:"INFO",LOG:"LOG",WARN:"WARN",ERROR:"ERROR",CRITICAL:"CRITICAL"},o={CCP:"ccp",SOFTPHONE:"softphone",CHAT:"chat",TASK:"task"},r={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,r=Array.prototype.slice.call(e,0),i=r.shift();return function(e){return-1!==Object.values(o).indexOf(e)}(i)?(n=i,t=r.shift()):(t=i,n=o.CCP),{format:t,component:n,args:r}},c=function(e,t,n,o){this.component=e,this.level=t,this.text=n,this.time=new Date,this.exception=null,this.objects=[],this.line=0,this.agentResourceId=null;try{connect.agent.initialized&&(this.agentResourceId=(new connect.Agent)._getResourceId())}catch(e){console.log("Issue finding agentResourceId: ",e)}this.loggerId=o};c.fromObject=function(e){var t=new c(o.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 a=function t(n){var o=/AuthToken.*\=/g;n&&"object"===e(n)&&Object.keys(n).forEach((function(r){"object"===e(n[r])?t(n[r]):"string"==typeof n[r]&&("url"===r||"text"===r?n[r]=n[r].replace(o,"[redacted]"):"quickConnectName"===r&&(n[r]="[redacted]"))}))},u=function(e){this.type=e instanceof Error?e.name:e.code||Object.prototype.toString.call(e),this.message=e.message,this.stack=e.stack?e.stack.split("\n"):[]};c.prototype.toString=function(){return connect.sprintf("[%s] [%s] [%s]: %s",this.getTime()&&this.getTime().toISOString?this.getTime().toISOString():"???",this.getLevel(),this.getAgentResourceId(),this.getText())},c.prototype.getTime=function(){return this.time},c.prototype.getAgentResourceId=function(){return this.agentResourceId},c.prototype.getLevel=function(){return this.level},c.prototype.getText=function(){return this.text},c.prototype.getComponent=function(){return this.component},c.prototype.withException=function(e){return this.exception=new u(e),this},c.prototype.withObject=function(e){var t=connect.deepcopy(e);return a(t),this.objects.push(t),this},c.prototype.withCrossOriginEventObject=function(e){var t=connect.deepcopyCrossOriginEvent(e);return a(t),this.objects.push(t),this},c.prototype.sendInternalLogToServer=function(){return connect.getLog()._serverBoundInternalLogs.push(this),this};var l=function(){this._logs=[],this._rolledLogs=[],this._logsToPush=[],this._serverBoundInternalLogs=[],this._echoLevel=r.INFO,this._logLevel=r.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(e){var n=this;this._logRollTimer&&e===this._logRollInterval?this.warn("Logger is already set to the given interval: %d",this._logRollInterval):(this._logRollTimer&&t.clearInterval(this._logRollTimer),this._logRollInterval=e,this._logRollTimer=t.setInterval((function(){this._rolledLogs=this._logs,this._logs=[],this._startLogIndexToPush=0,n.info("Log roll interval occurred.")}),this._logRollInterval))},l.prototype.setLogLevel=function(e){if(!(e in r))throw new Error("Unknown logging level: "+e);this._logLevel=r[e]},l.prototype.setEchoLevel=function(e){if(!(e in r))throw new Error("Unknown logging level: "+e);this._echoLevel=r[e]},l.prototype.write=function(e,t,n){var o=new c(e,t,n,this.getLoggerId());return a(o),this.addLogEntry(o),o},l.prototype.addLogEntry=function(e){a(e),this._logs.push(e),o.SOFTPHONE===e.component&&this._logsToPush.push(e),e.level in r&&r[e.level]>=this._logLevel&&(r[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 r&&r[e.level]>=this._logLevel&&(r[e.level]>=this._echoLevel&&i[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.clearObjects=function(){for(var e=0;e=s._logLevel})));var a=new t.Blob([JSON.stringify(c,void 0,4)],["text/plain"]),u=document.createElement("a");o=o||"agent-log",u.href=t.URL.createObjectURL(a),u.download=o+".txt",document.body.appendChild(u),u.click(),document.body.removeChild(u)},l.prototype.scheduleUpstreamLogPush=function(e){connect.upstreamLogPushScheduled||(connect.upstreamLogPushScheduled=!0,t.setInterval(connect.hitch(this,this.reportMasterLogsUpStream,e),5e3))},l.prototype.reportMasterLogsUpStream=function(e){var t=this._logsToPush.slice();this._logsToPush=[],connect.ifMaster(connect.MasterTopics.SEND_LOGS,(function(){t.length>0&&e.sendUpstream(connect.EventType.SEND_LOGS,t)}))},l.prototype.scheduleUpstreamOuterContextCCPserverBoundLogsPush=function(e){t.setInterval(connect.hitch(this,this.pushOuterContextCCPserverBoundLogsUpstream,e),1e3)},l.prototype.scheduleUpstreamOuterContextCCPLogsPush=function(e){t.setInterval(connect.hitch(this,this.pushOuterContextCCPLogsUpstream,e),1e3)},l.prototype.pushOuterContextCCPserverBoundLogsUpstream=function(e){if(this._serverBoundInternalLogs.length>0){for(var t=0;t500?e=this._serverBoundInternalLogs.splice(0,500):(e=this._serverBoundInternalLogs,this._serverBoundInternalLogs=[]),connect.publishClientSideLogs(e))};var p=function e(n){l.call(this),this.conduit=n,t.setInterval(connect.hitch(this,this._pushLogsDownstream),e.LOG_PUSH_INTERVAL),t.clearInterval(this._logRollTimer),this._logRollTimer=null};p.LOG_PUSH_INTERVAL=1e3,(p.prototype=Object.create(l.prototype)).constructor=p,p.prototype.pushLogsDownstream=function(e){var t=this;e.forEach((function(e){t.conduit.sendDownstream(connect.EventType.LOG,e)}))},p.prototype._pushLogsDownstream=function(){var e=this;this._logs.forEach((function(t){e.conduit.sendDownstream(connect.EventType.LOG,t)})),this._logs=[];for(var t=0;t{!function(){connect=this.connect||{},this.connect=connect,connect.ChatMediaController=function(e,t){var n=connect.getLog(),o=connect.LogComponent.CHAT,r=function(t,n){connect.publishMetric({name:t,contactId:e.contactId,data:n||e})},i=function(e){e.onConnectionBroken((function(e){n.error(o,"Chat Session connection broken").withException(e).sendInternalLogToServer(),r("Chat Session connection broken",e)})),e.onConnectionEstablished((function(e){n.info(o,"Chat Session connection established").withObject(e).sendInternalLogToServer(),r("Chat Session connection established",e)}))};return{get:function(){return function(){r("Chat media controller init",e.contactId),n.info(o,"Chat media controller init").withObject(e).sendInternalLogToServer(),connect.ChatSession.setGlobalConfig({loggerConfig:{logger:n},region:t.region});var s=connect.ChatSession.create({chatDetails:e,type:"AGENT",websocketManager:connect.core.getWebSocketManager()});return i(s),s.connect().then((function(t){return n.info(o,"Chat Session Successfully established for contactId %s",e.contactId).sendInternalLogToServer(),r("Chat Session Successfully established",e.contactId),s})).catch((function(t){throw n.error(o,"Chat Session establishement failed for contact %s",e.contactId).withException(t).sendInternalLogToServer(),r("Chat Session establishement failed",e.contactId,t),t}))}()}}}}()},7:()=>{!function(){connect=this.connect||{},this.connect=connect,connect.MediaFactory=function(e){var t={},n=new Set,o=connect.getLog(),r=connect.LogComponent.CHAT,i=connect.merge({},e)||{};i.region=i.region||"us-west-2";var s=function(e){t[e]&&!n.has(e)&&(o.info(r,"Destroying mediaController for %s",e),n.add(e),t[e].then((function(){"function"==typeof controller.cleanUp&&controller.cleanUp(),delete t[e],n.delete(e)})).catch((function(){delete t[e],n.delete(e)})))};return{get:function(e){return function(e){return e.isActive()}(e)?function(e){var n=e.getConnectionId();if(!e.getMediaInfo())return o.error(r,"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(t[n])return t[n];switch(o.info(r,"media controller of type %s init",e.getMediaType()).withObject(e).sendInternalLogToServer(),e.getMediaType()){case connect.MediaType.CHAT:return t[n]=new connect.ChatMediaController(e.getMediaInfo(),i).get();case connect.MediaType.SOFTPHONE:return t[n]=new connect.SoftphoneMediaController(e.getMediaInfo()).get();case connect.MediaType.TASK:return t[n]=new connect.TaskMediaController(e.getMediaInfo()).get();default:return o.error(r,"Unrecognized media type %s ",e.getMediaType()).sendInternalLogToServer(),Promise.reject()}}(e):(s(e.getConnectionId()),Promise.reject("Media Controller is no longer available for this connection"))},destroy:s}}}()},6:()=>{!function(){connect=this.connect||{},this.connect=connect,connect.SoftphoneMediaController=function(e){return{get:function(){return Promise.resolve(e)}}}}()},487:()=>{!function(){connect=this.connect||{},this.connect=connect,connect.TaskMediaController=function(e){var t=connect.getLog(),n=connect.LogComponent.TASK,o=function(t,n){connect.publishMetric({name:t,contactId:e.contactId,data:n||e})},r=function(e){e.onConnectionBroken((function(e){t.error(n,"Task Session connection broken").withException(e),o("Task Session connection broken",e)})),e.onConnectionEstablished((function(e){t.info(n,"Task Session connection established").withObject(e),o("Task Session connection established",e)}))};return{get:function(){return function(){o("Task media controller init",e.contactId),t.info(n,"Task media controller init").withObject(e);var i=connect.TaskSession.create({contactId:e.contactId,initialContactId:e.initialContactId,websocketManager:connect.core.getWebSocketManager()});return r(i),i.connect().then((function(){return t.info(n,"Task Session Successfully established for contactId %s",e.contactId),o("Task Session Successfully established",e.contactId),i})).catch((function(r){throw t.error(n,"Task Session establishement failed for contact %s",e.contactId).withException(r),o("Chat Session establishement failed",e.contactId,r),r}))}()}}}}()},743:()=>{function e(t){return e="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(t)}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function n(e){for(var n=1;n2&&void 0!==arguments[2]?arguments[2]:{};t.assertNotNull(e,"ccpUrl"),t.assertNotNull(o,"container"),a=o,c=e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.custom=e.custom||{},(s=n(n(n({},i),e),{},{custom:n(n({},i.custom),e.custom)})).canRequest=!("false"===s.canRequest||!1===s.canRequest)}(r),t.getLog().info("[StorageAccess][init] Request Storage Acccess init called with ccpUrl - ".concat(e," - ").concat(s.canRequest?"Proceeding with requesting storage access":"user has opted out, skipping request storage access")).withObject(s)},setupRequestHandlers:function(e){var n=e.onGrant;o&&o.unsubscribe(),o=v({onInit:function(e){console.log("%c[StorageAccess][INIT]","background:yellow; color:black; font-size:large"),t.getLog().info("[StorageAccess][onInit] callback executed").withObject(null==e?void 0:e.data),null!=e&&e.data.hasAccess||!h()||p().show()},onDeny:function(){console.log("%c[StorageAccess][DENIED]","background:red; color:black; font-size:large"),t.getLog().info("[StorageAccess][onDeny] callback executed"),h()&&p().show()},onGrant:function(){var e;console.log("%c[StorageAccess][GRANTED]","background:lime; color:black; font-size:large"),t.getLog().info("[StorageAccess][onGrant] callback executed"),h()&&(null===(e=s)||void 0===e||null===(e=e.custom)||void 0===e?void 0:e.hideCCP)&&p().hide(),u||(n(),u=!0)}})},getRequestStorageAccessUrl:function(){if(!c)throw new Error("[StorageAccess] [getRequestStorageAccessUrl] Invoke connect.storageAccess.init first");if(d(c))return f(c);if(g(c))return t.getLog().info("[StorageAccess] [CCP] Local testing"),"".concat(c).concat(r);if(s.instanceUrl&&d(s.instanceUrl))return t.getLog().info("[StorageAccess] [getRequestStorageAccessUrl] Customer has provided storageParams.instanceUrl ".concat(s.instanceUrl)),f(s.instanceUrl);if(s.instanceUrl&&g(s.instanceUrl))return t.getLog().info("[StorageAccess] [getRequestStorageAccessUrl] Local testing"),"".concat(s.instanceUrl).concat(r);throw t.getLog().error("[StorageAccess] [getRequestStorageAccessUrl] Invalid Connect instance/CCP URL provided, please pass the correct ccpUrl or storageAccess.instanceUrl parameters"),new Error("[StorageAccess] [getRequestStorageAccessUrl] Invalid Connect instance/CCP URL provided, please pass the valid Connect CCP URL or in case CCP URL is configured to be the SSO URL then use storageAccess.instanceUrl and pass the Connect CCP URL")},storageAccessEvents:l,resetStorageAccessState:function(){s={},c="",a=null},getStorageAccessParams:function(){return s},onRequest:v,request:function(){t.core._getCCPIframe().contentWindow.postMessage({event:l.REQUEST,data:n(n({},s),{},{landat:m()})},"*")}})}()},555:()=>{!function(){var e=this,t=e.connect||{};e.connect=t,e.lily=t;var n=function(n){var o=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,t){o._audio=new Audio(n.ringtoneUrl),o._audio.loop=!0,o._audio.addEventListener("canplay",(function(){o._audioPlayable=!0,e(o._audio)}))})):(this._audio=null,t.getLog().error("Unable to provide a ringtone.").sendInternalLogToServer()),o._driveRingtone()};n.prototype._driveRingtone=function(){throw new Error("Not implemented.")},n.prototype._startRingtone=function(e){this._audio&&(this._audio.play().catch((function(n){this._publishTelemetryEvent("Ringtone Playback Failure",e),t.getLog().error("Ringtone Playback Failure").sendInternalLogToServer()})),this._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 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.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 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.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=o,t.ChatRingtoneEngine=r,t.TaskRingtoneEngine=i,t.QueueCallbackRingtoneEngine=s}()},960:()=>{function e(t){return e="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(t)}!function(){var t=this;connect=t.connect||{},t.connect=connect,t.lily=connect,t.ccpVersion="V2";var n={};n[connect.SoftphoneCallType.AUDIO_ONLY]="Audio",n[connect.SoftphoneCallType.VIDEO_ONLY]="Video",n[connect.SoftphoneCallType.AUDIO_VIDEO]="AudioVideo",n[connect.SoftphoneCallType.NONE]="None";var o="audio_input",r="audio_output";({})[connect.ContactType.VOICE]="Voice";var i=[],s={},c={},a=null,u=null,l=null,p=connect.SoftphoneErrorTypes,h={},d=connect.randomId(),f=function(e){return new Promise((function(t,n){connect.core.getClient().call(connect.ClientMethods.CREATE_TRANSPORT,e,{success:function(e){t(e.softphoneTransport.softphoneMediaConnections)},failure:function(e){e.message&&e.message.includes("SoftphoneConnectionLimitBreachedException")&&_("multiple_softphone_active_sessions","Number of active sessions are more then allowed limit.",""),n(Error("requestIceAccess failed"))},authFailure:function(){n(Error("Authentication failed while requestIceAccess"))},accessDenied:function(){n(Error("Access Denied while requestIceAccess"))}})}))},g=function(e){var t=connect.core.getUpstream(),n=e.getAgentConnection();if(n){var o=n.getSoftphoneMediaInfo();o?!0===o.autoAccept?(l.info("Auto-accept is enabled, sending out Accepted event to stop ringtone..").sendInternalLogToServer(),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.ContactEvents.ACCEPTED,data:new connect.Contact(e.contactId)}),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.core.getContactEventName(connect.ContactEvents.ACCEPTED,e.contactId),data:new connect.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(){connect.core.getEventBus().subscribe(connect.EventType.MUTE,S)},v=function(){connect.core.getEventBus().subscribe(connect.ConfigurationEvents.SET_SPEAKER_DEVICE,b)},y=function(){connect.core.getEventBus().subscribe(connect.ConfigurationEvents.SET_MICROPHONE_DEVICE,C)},E=function(e){delete h[e],connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.MUTE_TOGGLE,data:{muted:!1}})},S=function(e){var t;if(0!==connect.keys(h).length){for(var n in e&&void 0!==e.mute&&(t=e.mute),h)if(h.hasOwnProperty(n)){var o=h[n].stream;if(o){var r=o.getAudioTracks()[0];void 0!==t?(r.enabled=!t,h[n].muted=t,t?l.info("Agent has muted the contact, connectionId - "+n).sendInternalLogToServer():l.info("Agent has unmuted the contact, connectionId - "+n).sendInternalLogToServer()):t=h[n].muted||!1}}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.MUTE_TOGGLE,data:{muted:t}})}},b=function(e){if(0!==connect.keys(h).length&&e&&e.deviceId){var t=e.deviceId,n=document.getElementById("remote-audio");try{l.info("Trying to set speaker to device "+t),n&&"function"==typeof n.setSinkId&&n.setSinkId(t)}catch(e){l.error("Failed to set speaker to device "+t)}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,data:{deviceId:t}})}},C=function(e){if(0!==connect.keys(h).length&&e&&e.deviceId){var t=e.deviceId,n=connect.core.getSoftphoneManager();try{navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:t}}}).then((function(e){var t=e.getAudioTracks()[0];for(var o in h)h.hasOwnProperty(o)&&(h[o].stream,n.getSession(o)._pc.getSenders()[0].replaceTrack(t).then((function(){n.replaceLocalMediaTrack(o,t)})))}))}catch(e){l.error("Failed to set microphone device "+t)}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,data:{deviceId:t}})}},T=function(e,t){if(t===connect.RTCErrors.ICE_COLLECTION_TIMEOUT){for(var n="\n",o=0;o0?n.success(e):n.failure(p.MICROPHONE_NOT_SHARED)}),(function(e){n.failure(p.MICROPHONE_NOT_SHARED)})),r}n.failure(p.UNSUPPORTED_BROWSER)},_=function(e,t,n){l.error("Softphone error occurred : ",e,t||"").sendInternalLogToServer(),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.SOFTPHONE_ERROR,data:new connect.SoftphoneError(e,t,n)})},w=function(e,t){R("Softphone Session Failed",e,{failedReason:t})},R=function(e,t,n){t&&connect.publishMetric({name:e,contactId:t,data:n})},N=function(e,t,n){R(e,t,[{name:"AgentConnectionId",value:n}]),l.info("Publish multiple session error metrics",e,"contactId "+t,"agent connectionId "+n).sendInternalLogToServer()},k=function(){return!!(connect.isOperaBrowser()&&connect.getOperaBrowserVersion()>17)||!!(connect.isChromeBrowser()&&connect.getChromeBrowserVersion()>22)||!!(connect.isFirefoxBrowser()&&connect.getFirefoxBrowserVersion()>21)},O=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()}})},L=function(e){a=window.setInterval((function(){e.getUserAudioStats().then((function(e){var t=s;s=e,i.push(x(s,t,o))}),(function(e){l.debug("Failed to get user audio stats.",e).sendInternalLogToServer()})),e.getRemoteAudioStats().then((function(e){var t=c;c=e,i.push(x(c,t,r))}),(function(e){l.debug("Failed to get remote audio stats.",e).sendInternalLogToServer()}))}),1e3)},D=function(e){u=window.setInterval((function(){O(e)}),3e4)},P=function(){s=null,c=null,i=[],a=null,u=null},x=function(e,t,n){if(t&&e){var o=e.packetsLost>t.packetsLost?e.packetsLost-t.packetsLost:0,r=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new q(e.timestamp,o,r,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new q(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},M=function(e){return null!==e&&window.clearInterval(e),null},U=function(e,t){a=M(a),u=M(u),function(e,t,n,i){t.streamStats=[F(n,o),F(i,r)];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,F(s,o),F(c,r)),O(e)},q=function(e,t,n,o,r,i,s){this.softphoneStreamType=o,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=r,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},F=function(e,t){return new q((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},j=function(e){this._originalLogger=e;var t=this;this._tee=function(e,n){return function(){var e=Array.prototype.slice.call(arguments[0]),o="";return e.forEach((function(){o+=" %s"})),n.apply(t._originalLogger,[connect.LogComponent.SOFTPHONE,o].concat(e))}}};j.prototype.debug=function(){return this._tee(1,this._originalLogger.debug)(arguments)},j.prototype.info=function(){return this._tee(2,this._originalLogger.info)(arguments)},j.prototype.log=function(){return this._tee(3,this._originalLogger.log)(arguments)},j.prototype.warn=function(){return this._tee(4,this._originalLogger.warn)(arguments)},j.prototype.error=function(){return this._tee(5,this._originalLogger.error)(arguments)},connect.SoftphoneManager=function(e){var t,n=this;(l=new j(connect.getLog())).info("[Softphone Manager] softphone manager initialization has begun").sendInternalLogToServer(),connect.RtcPeerConnectionFactory&&(t=new connect.RtcPeerConnectionFactory(l,connect.core.getWebSocketManager(),d,connect.hitch(n,f,{transportType:"softphone",softphoneClientId:d}),connect.hitch(n,_))),k()||_(p.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ",""),A({success:function(e){connect.core.setSoftphoneUserMediaStream(e)},failure:function(e){_(e,"Your microphone is not enabled in your browser. ","")}}),m(),v(),y(),this.ringtoneEngine=null;var o={},r={};this.onInitContactSub={},this.onInitContactSub.unsubscribe=function(){};var i=!1,s=null,c=null,a=function(){i=!1,s=null,c=null};this.getSession=function(e){return o[e]},this.replaceLocalMediaTrack=function(e,t){var n=h[e].stream;if(n){var o=n.getAudioTracks()[0];t.enabled=o.enabled,o.enabled=!1,n.removeTrack(o),n.addTrack(t)}};var u=function(e){if(o.hasOwnProperty(e)){var t=o[e];new Promise((function(n,i){delete o[e],delete r[e],t.hangup()})).catch((function(t){lily.getLog().warn("Clean up the session locally "+e,t.message).sendInternalLogToServer()}))}};this.startSession=function(e,n){var p=i?s:e,d=i?c:n;if(p&&d){a(),r[d]=!0,l.info("Softphone call detected:","contactId "+p.getContactId(),"agent connectionId "+d).sendInternalLogToServer(),function(e){if(Object.keys(e).length>0){for(var t in e)e.hasOwnProperty(t)&&(N("MultiSessionHangUp",e[t].callId,t),u(t));throw new Error("duplicate session detected, refusing to setup new connection")}}(o),p.getStatus().type===connect.ContactStatusType.CONNECTING&&R("Softphone Connecting",p.getContactId()),P();var f,m=p.getAgentConnection().getSoftphoneMediaInfo(),v=I(m.callConfigJson);v.useWebSocketProvider&&(f=connect.core.getWebSocketManager());var y=new connect.RTCSession(v.signalingEndpoint,v.iceServers,m.callContextToken,l,p.getContactId(),d,f);o[d]=y,connect.core.getSoftphoneUserMediaStream()&&(y.mediaStream=connect.core.getSoftphoneUserMediaStream()),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConnectionEvents.SESSION_INIT,data:{connectionId:d}}),y.onSessionFailed=function(e,t){delete o[d],delete r[d],T(e,t),w(p.getContactId(),t),U(p,e.sessionReport)},y.onSessionConnected=function(e){R("Softphone Session Connected",p.getContactId()),connect.becomeMaster(connect.MasterTopics.SEND_LOGS),L(e),D(p),g(p)},y.onSessionCompleted=function(e){R("Softphone Session Completed",p.getContactId()),delete o[d],delete r[d],U(p,e.sessionReport),E(d)},y.onLocalStreamAdded=function(e,t){h[d]={stream:t},connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,data:{connectionId:d}})},y.remoteAudioElement=document.getElementById("remote-audio"),t?y.connect(t.get(v.iceServers)):y.connect()}};var S=function(e,t){o[t]&&function(e){return e.getStatus().type===connect.ContactStatusType.ENDED||e.getStatus().type===connect.ContactStatusType.ERROR||e.getStatus().type===connect.ContactStatusType.MISSED}(e)&&(u(t),a()),!e.isSoftphoneCall()||r[t]||e.getStatus().type!==connect.ContactStatusType.CONNECTING&&e.getStatus().type!==connect.ContactStatusType.INCOMING||(connect.isFirefoxBrowser()&&connect.hasOtherConnectedCCPs()?function(e,t){i=!0,s=e,c=t}(e,t):n.startSession(e,t))},b=function(e){var t=e.getAgentConnection().connectionId;l.info("Contact detected:","contactId "+e.getContactId(),"agent connectionId "+t).sendInternalLogToServer(),r[t]||e.onRefresh((function(){S(e,t)}))};n.onInitContactSub=connect.contact(b),(new connect.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(),b(e),S(e,t)}))}}()},778:()=>{!function(){var e=function e(){return e.cache.hasOwnProperty(arguments[0])||(e.cache[arguments[0]]=e.parse(arguments[0])),e.format.call(null,e.cache[arguments[0]],arguments)};function t(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function n(e,t){for(var n=[];t>0;n[--t]=e);return n.join("")}e.format=function(o,r){var i,s,c,a,u,l,p,h=1,d=o.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(a[8])&&a[3]&&i>=0?"+"+i:i,l=a[4]?"0"==a[4]?"0":a[4].charAt(1):" ",p=a[6]-String(i).length,u=a[6]?n(l,p):"",g.push(a[5]?i+u:u+i)}return g.join("")},e.cache={},e.parse=function(e){for(var t=e,n=[],o=[],r=0;t;){if(null!==(n=/^[^\x25]+/.exec(t)))o.push(n[0]);else if(null!==(n=/^\x25{2}/.exec(t)))o.push("%");else{if(null===(n=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t)))throw"[sprintf] huh?";if(n[2]){r|=1;var i=[],s=n[2],c=[];if(null===(c=/^([a-z_][a-z_\d]*)/i.exec(s)))throw"[sprintf] huh?";for(i.push(c[1]);""!==(s=s.substring(c[0].length));)if(null!==(c=/^\.([a-z_][a-z_\d]*)/i.exec(s)))i.push(c[1]);else{if(null===(c=/^\[(\d+)\]/.exec(s)))throw"[sprintf] huh?";i.push(c[1])}n[2]=i}else r|=2;if(3===r)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";o.push(n)}t=t.substring(n[0].length)}return o},this.sprintf=e,this.vsprintf=function(t,n,o){return(o=n.slice(0)).splice(0,0,t),e.apply(null,o)}}()},768:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect;var t=function(){};t.prototype.send=function(e){throw new connect.NotImplementedError},t.prototype.onMessage=function(e){throw new connect.NotImplementedError};var n=function(){t.call(this)};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype.onMessage=function(e){},n.prototype.send=function(e){};var o=function(e,n){t.call(this),this.window=e,this.domain=n||"*"};(o.prototype=Object.create(t.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 r=function(e,n,o){t.call(this),this.input=e,this.output=n,this.domain=o||"*"};(r.prototype=Object.create(t.prototype)).constructor=r,r.prototype.send=function(e){this.output.postMessage(e,this.domain)},r.prototype.onMessage=function(e){var t=this;this.input.addEventListener("message",(function(n){n.source===t.output&&e(n)}))};var i=function(e){t.call(this),this.port=e,this.id=connect.randomId()};(i.prototype=Object.create(t.prototype)).constructor=i,i.prototype.send=function(e){this.port.postMessage(e)},i.prototype.onMessage=function(e){this.port.addEventListener("message",e)},i.prototype.getId=function(){return this.id};var s=function(e){t.call(this),this.streamMap=e?connect.index(e,(function(e){return e.getId()})):{},this.messageListeners=[]};(s.prototype=Object.create(t.prototype)).constructor=s,s.prototype.send=function(e){this.getStreams().forEach((function(t){try{t.send(e)}catch(e){}}))},s.prototype.onMessage=function(e){this.messageListeners.push(e),this.getStreams().forEach((function(t){t.onMessage(e)}))},s.prototype.addStream=function(e){this.streamMap[e.getId()]=e,this.messageListeners.forEach((function(t){e.onMessage(t)}))},s.prototype.removeStream=function(e){delete this.streamMap[e.getId()]},s.prototype.getStreams=function(e){return connect.values(this.streamMap)},s.prototype.getStreamForPort=function(e){return connect.find(this.getStreams(),(function(t){return t.port===e}))};var c=function(e,t,o){this.name=e,this.upstream=t||new n,this.downstream=o||new n,this.downstreamBus=new connect.EventBus,this.upstreamBus=new connect.EventBus,this.upstream.onMessage(connect.hitch(this,this._dispatchEvent,this.upstreamBus)),this.downstream.onMessage(connect.hitch(this,this._dispatchEvent,this.downstreamBus))};c.prototype.onUpstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.upstreamBus.subscribe(e,t)},c.prototype.onAllUpstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.upstreamBus.subscribeAll(e)},c.prototype.onDownstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.downstreamBus.subscribe(e,t)},c.prototype.onAllDownstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.downstreamBus.subscribeAll(e)},c.prototype.sendUpstream=function(e,t){connect.assertNotNull(e,"eventName"),this.upstream.send({event:e,data:t})},c.prototype.sendDownstream=function(e,t){connect.assertNotNull(e,"eventName"),this.downstream.send({event:e,data:t})},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 a=function(e,t,n,o){c.call(this,e,new r(t,n.contentWindow,o||"*"),null)};(a.prototype=Object.create(c.prototype)).constructor=a,connect.Stream=t,connect.NullStream=n,connect.WindowStream=o,connect.WindowIOStream=r,connect.PortStream=i,connect.StreamMultiplexer=s,connect.Conduit=c,connect.IFrameConduit=a}()},738:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect;var t=function(e,t){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),this.fromState=e,this.toState=t};t.prototype.getAssociations=function(e){throw connect.NotImplementedError()},t.prototype.getFromState=function(){return this.fromState},t.prototype.getToState=function(){return this.toState};var n=function(e,n,o){connect.assertNotNull(e,"fromState"),connect.assertNotNull(n,"toState"),connect.assertNotNull(o,"associations"),t.call(this,e,n),this.associations=o};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype.getAssociations=function(e){return this.associations};var o=function(e,n,o){connect.assertNotNull(e,"fromState"),connect.assertNotNull(n,"toState"),connect.assertNotNull(o,"closure"),connect.assertTrue(connect.isFunction(o),"closure must be a function"),t.call(this,e,n),this.closure=o};(o.prototype=Object.create(t.prototype)).constructor=o,o.prototype.getAssociations=function(e){return this.closure(e,this.getFromState(),this.getToState())};var r=function(){this.fromMap={}};r.ANY="<>",r.prototype.assoc=function(e,t,r){var i=this;if(!e)throw new Error("fromStateObj is not defined.");if(!t)throw new Error("toStateObj is not defined.");if(!r)throw new Error("assocObj is not defined.");return e instanceof Array?e.forEach((function(e){i.assoc(e,t,r)})):t instanceof Array?t.forEach((function(t){i.assoc(e,t,r)})):"function"==typeof r?this._addAssociation(new o(e,t,r)):r instanceof Array?this._addAssociation(new n(e,t,r)):this._addAssociation(new n(e,t,[r])),this},r.prototype.getAssociations=function(e,t,n){connect.assertNotNull(t,"fromState"),connect.assertNotNull(n,"toState");var o=[],i=this.fromMap[r.ANY]||{},s=this.fromMap[t]||{};return o=(o=o.concat(this._getAssociationsFromMap(i,e,t,n))).concat(this._getAssociationsFromMap(s,e,t,n))},r.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)},r.prototype._getAssociationsFromMap=function(e,t,n,o){return(e[r.ANY]||[]).concat(e[o]||[]).reduce((function(e,n){return e.concat(n.getAssociations(t))}),[])},connect.EventGraph=r}()},420:()=>{function e(t){return e="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(t)}!function(){var t=this;connect=t.connect||{},t.connect=connect,t.lily=connect;var n=navigator.userAgent,o=["bubbles","cancelBubble","cancelable","composed","data","defaultPrevented","eventPhase","isTrusted","lastEventId","origin","returnValue","timeStamp","type"];connect.sprintf=t.sprintf,connect.vsprintf=t.vsprintf,delete t.sprintf,delete t.vsprintf,connect.HTTP_STATUS_CODES={SUCCESS:200,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500},connect.TRANSPORT_TYPES={CHAT_TOKEN:"chat_token",WEB_SOCKET:"web_socket"},connect.hitch=function(){var e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift();return connect.assertNotNull(t,"scope"),connect.assertNotNull(n,"method"),connect.assertTrue(connect.isFunction(n),"method must be a function"),function(){var o=Array.prototype.slice.call(arguments);return n.apply(t,e.concat(o))}},connect.isFunction=function(e){return!!(e&&e.constructor&&e.call&&e.apply)},connect.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},connect.keys=function(e){var t=[];for(var n in connect.assertNotNull(e,"map"),e)t.push(n);return t},connect.values=function(e){var t=[];for(var n in connect.assertNotNull(e,"map"),e)t.push(e[n]);return t},connect.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},connect.merge=function(){var e=Array.prototype.slice.call(arguments,0),t={};return e.forEach((function(e){connect.entries(e).forEach((function(e){t[e.key]=e.value}))})),t},connect.now=function(){return(new Date).getTime()},connect.find=function(e,t){for(var n=0;n1},connect.fetch=function(e,t,n,o){return o=o||5,n=n||1e3,t=t||{},new Promise((function(r,i){!function o(s){fetch(e,t).then((function(e){e.status===connect.HTTP_STATUS_CODES.SUCCESS?e.json().then((function(e){return r(e)})).catch((function(){return r({})})):1!==s&&(e.status>=connect.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===connect.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout((function(){o(--s)}),n):i(e)})).catch((function(e){i(e)}))}(o)}))},connect.backoff=function(e,n,o,r){connect.assertTrue(connect.isFunction(e),"func must be a Function");var i=this;e({success:function(e){r&&r.success&&r.success(e)},failure:function(s,c){if(o>0){var a=2*n*Math.random();t.setTimeout((function(){i.backoff(e,2*a,--o,r)}),a)}else r&&r.failure&&r.failure(s,c)}})},connect.publishMetric=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.CLIENT_METRIC,data:e})},connect.publishSoftphoneStats=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.SOFTPHONE_STATS,data:e})},connect.publishSoftphoneReport=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.SOFTPHONE_REPORT,data:e})},connect.publishClientSideLogs=function(e){connect.core.getEventBus().trigger(connect.EventType.CLIENT_SIDE_LOGS,e)},connect.PopupManager=function(){},connect.PopupManager.prototype.open=function(e,t,n){var o=this._getLastOpenedTimestamp(t),r=(new Date).getTime(),i=null;if(r-o>864e5){if(n){var s=n.height||578,c=n.width||433,a=n.top||0,u=n.left||0;(i=window.open("",t,"width="+c+", height="+s+", top="+a+", left="+u)).location!==e&&(i=window.open(e,t,"width="+c+", height="+s+", top="+a+", left="+u))}else(i=window.open("",t)).location!==e&&(i=window.open(e,t));this._setLastOpenedTimestamp(t,r)}return i},connect.PopupManager.prototype.clear=function(e){var n=this._getLocalStorageKey(e);t.localStorage.removeItem(n)},connect.PopupManager.prototype._getLastOpenedTimestamp=function(e){var n=this._getLocalStorageKey(e),o=t.localStorage.getItem(n);return o?parseInt(o,10):0},connect.PopupManager.prototype._setLastOpenedTimestamp=function(e,n){var o=this._getLocalStorageKey(e);t.localStorage.setItem(o,""+n)},connect.PopupManager.prototype._getLocalStorageKey=function(e){return"connectPopupManager::"+e};var r=connect.makeEnum(["granted","denied","default"]);connect.NotificationManager=function(){this.queue=[],this.permission=r.DEFAULT},connect.NotificationManager.prototype.requestPermission=function(){var e=this;"Notification"in t?t.Notification.permission===r.DENIED?(connect.getLog().warn("The user has requested to not receive notifications.").sendInternalLogToServer(),this.permission=r.DENIED):this.permission!==r.GRANTED&&t.Notification.requestPermission().then((function(t){e.permission=t,t===r.GRANTED?e._showQueued():e.queue=[]})):(connect.getLog().warn("This browser doesn't support notifications.").sendInternalLogToServer(),this.permission=r.DENIED)},connect.NotificationManager.prototype.show=function(e,t){if(this.permission===r.GRANTED)return this._showImpl({title:e,options:t});if(this.permission===r.DENIED)connect.getLog().warn("Unable to show notification.").sendInternalLogToServer().withObject({title:e,options:t});else{var n={title:e,options:t};connect.getLog().warn("Deferring notification until user decides to allow or deny.").withObject(n).sendInternalLogToServer(),this.queue.push(n)}},connect.NotificationManager.prototype._showQueued=function(){var e=this,t=this.queue.map((function(t){return e._showImpl(t)}));return this.queue=[],t},connect.NotificationManager.prototype._showImpl=function(e){var n=new t.Notification(e.title,e.options);return e.options.clicked&&(n.onclick=function(){e.options.clicked.call(n)}),n},connect.BaseError=function(e,n){t.Error.call(this,connect.vsprintf(e,n))},connect.BaseError.prototype=Object.create(Error.prototype),connect.BaseError.prototype.constructor=connect.BaseError,connect.ValueError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift();connect.BaseError.call(this,t,e)},connect.ValueError.prototype=Object.create(connect.BaseError.prototype),connect.ValueError.prototype.constructor=connect.ValueError,connect.NotImplementedError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift();connect.BaseError.call(this,t,e)},connect.NotImplementedError.prototype=Object.create(connect.BaseError.prototype),connect.NotImplementedError.prototype.constructor=connect.NotImplementedError,connect.StateError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift();connect.BaseError.call(this,t,e)},connect.StateError.prototype=Object.create(connect.BaseError.prototype),connect.StateError.prototype.constructor=connect.StateError,connect.VoiceIdError=function(e,t,n){var o={};return o.type=e,o.message=t,o.stack=Error(t).stack,o.err=n,o},connect.isCCP=function(){return"ConnectSharedWorkerConduit"===connect.core.getUpstream().name}}()},744:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect,connect.worker={};var t=function(){this.topicMasterMap={}};t.prototype.getMaster=function(e){return connect.assertNotNull(e,"topic"),this.topicMasterMap[e]||null},t.prototype.setMaster=function(e,t){connect.assertNotNull(e,"topic"),connect.assertNotNull(t,"id"),this.topicMasterMap[e]=t},t.prototype.removeMaster=function(e){connect.assertNotNull(e,"id");var t=this;connect.entries(this.topicMasterMap).filter((function(t){return t.value===e})).forEach((function(e){delete t.topicMasterMap[e.key]}))};var n=function(e){connect.ClientBase.call(this),this.conduit=e};(n.prototype=Object.create(connect.ClientBase.prototype)).constructor=n,n.prototype._callImpl=function(e,t,n){var o=this,r=(new Date).getTime();connect.containsValue(connect.AgentAppClientMethods,e)?connect.core.getAgentAppClient()._callImpl(e,t,{success:function(t){o._recordAPILatency(e,r),n.success(t)},failure:function(t){o._recordAPILatency(e,r,t),n.failure(t)}}):connect.core.getClient()._callImpl(e,t,{success:function(t){o._recordAPILatency(e,r),n.success(t)},failure:function(t,i){o._recordAPILatency(e,r,t),n.failure(t,i)},authFailure:function(){o._recordAPILatency(e,r),n.authFailure()},accessDenied:function(){n.accessDenied&&n.accessDenied()}})},n.prototype._recordAPILatency=function(e,t,n){var o=(new Date).getTime()-t;this._sendAPIMetrics(e,o,n)},n.prototype._sendAPIMetrics=function(e,t,n){this.conduit.sendDownstream(connect.EventType.API_METRIC,{name:e,time:t,dimensions:[{name:"Category",value:"API"}],error:n})};var o=function(){var o=this;this.multiplexer=new connect.StreamMultiplexer,this.conduit=new connect.Conduit("AmazonConnectSharedWorker",null,this.multiplexer),this.client=new n(this.conduit),this.timeout=null,this.agent=null,this.nextToken=null,this.initData={},this.portConduitMap={},this.masterCoord=new t,this.logsBuffer=[],this.suppress=!1,this.forceOffline=!1;var r=null;connect.rootLogger=new connect.DownstreamConduitLogger(this.conduit),this.conduit.onDownstream(connect.EventType.SEND_LOGS,(function(e){connect.getLog().pushLogsDownstream(e),o.logsBuffer=o.logsBuffer.concat(e),o.logsBuffer.length>400&&o.handleSendLogsRequest(o.logsBuffer)})),this.conduit.onDownstream(connect.EventType.CONFIGURE,(function(t){t.authToken&&t.authToken!==o.initData.authToken&&(o.initData=t,connect.core.init(t),r?connect.getLog().info("Not Initializing a new WebsocketManager instance, since one already exists").sendInternalLogToServer():(connect.getLog().info("Creating a new Websocket connection for CCP").sendInternalLogToServer(),connect.WebSocketManager.setGlobalConfig({loggerConfig:{logger:connect.getLog()}}),(r=connect.WebSocketManager.create()).onInitFailure((function(){o.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE)})),r.onConnectionOpen((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_OPEN,e)})),r.onConnectionClose((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_CLOSE,e)})),r.onConnectionGain((function(){o.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED),o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_GAIN)})),r.onConnectionLost((function(e){o.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e),o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_LOST,e)})),r.onSubscriptionUpdate((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_UPDATE,e)})),r.onSubscriptionFailure((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_FAILURE,e)})),r.onAllMessage((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.ALL_MESSAGE,e)})),o.conduit.onDownstream(connect.WebSocketEvents.SEND,(function(e){r.sendMessage(e)})),o.conduit.onDownstream(connect.WebSocketEvents.SUBSCRIBE,(function(e){r.subscribeTopics(e)})),r.init(connect.hitch(o,o.getWebSocketUrl)).then((function(t){t&&!t.webSocketConnectionFailed?(connect.getLog().info("Kicking off agent polling").sendInternalLogToServer(),o.pollForAgent(),connect.getLog().info("Kicking off config polling").sendInternalLogToServer(),o.pollForAgentConfiguration({repeatForever:!0}),connect.getLog().info("Kicking off auth token polling").sendInternalLogToServer(),e.setInterval(connect.hitch(o,o.checkAuthToken),3e5)):connect.webSocketInitFailed||(o.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE),connect.webSocketInitFailed=!0)}))))})),this.conduit.onDownstream(connect.EventType.TERMINATE,(function(){o.handleSendLogsRequest(o.logsBuffer),connect.core.terminate(),o.conduit.sendDownstream(connect.EventType.TERMINATED)})),this.conduit.onDownstream(connect.EventType.SYNCHRONIZE,(function(){o.conduit.sendDownstream(connect.EventType.ACKNOWLEDGE)})),this.conduit.onDownstream(connect.EventType.BROADCAST,(function(e){o.conduit.sendDownstream(e.event,e.data)})),e.onconnect=function(e){var t=e.ports[0],n=new connect.PortStream(t);o.multiplexer.addStream(n),t.start();var r=new connect.Conduit(n.getId(),null,n);r.sendDownstream(connect.EventType.ACKNOWLEDGE,{id:n.getId()}),o.portConduitMap[n.getId()]=r,o.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(o.portConduitMap).length}),null!==o.agent&&o.updateAgent(),r.onDownstream(connect.EventType.API_REQUEST,connect.hitch(o,o.handleAPIRequest,r)),r.onDownstream(connect.EventType.MASTER_REQUEST,connect.hitch(o,o.handleMasterRequest,r,n.getId())),r.onDownstream(connect.EventType.RELOAD_AGENT_CONFIGURATION,connect.hitch(o,o.pollForAgentConfiguration)),r.onDownstream(connect.EventType.CLOSE,(function(){o.multiplexer.removeStream(n),delete o.portConduitMap[n.getId()],o.masterCoord.removeMaster(n.getId()),o.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(o.portConduitMap).length})}))}};o.prototype.pollForAgent=function(){var t=this,n=connect.hitch(t,t.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_SNAPSHOT,{nextToken:t.nextToken,timeout:3e4},{success:function(n){try{t.agent=t.agent||{},t.agent.snapshot=n.snapshot,t.agent.snapshot.localTimestamp=connect.now(),t.agent.snapshot.skew=t.agent.snapshot.snapshotTimestamp-t.agent.snapshot.localTimestamp,t.nextToken=n.nextToken,connect.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(n).sendInternalLogToServer(),t.updateAgent()}catch(e){connect.getLog().error("Long poll failed to update agent.").withObject(n).withException(e).sendInternalLogToServer()}finally{e.setTimeout(connect.hitch(t,t.pollForAgent),100)}},failure:function(n,o){try{connect.getLog().error("Failed to get agent data.").sendInternalLogToServer().withObject({err:n,data:o})}finally{e.setTimeout(connect.hitch(t,t.pollForAgent),5e3)}},authFailure:function(){n()},accessDenied:connect.hitch(t,t.handleAccessDenied)})},o.prototype.pollForAgentConfiguration=function(t){var n=this,o=t||{},r=connect.hitch(n,n.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_CONFIGURATION,{},{success:function(t){var r=t.configuration;n.pollForAgentPermissions(r),n.pollForAgentStates(r),n.pollForDialableCountryCodes(r),n.pollForRoutingProfileQueues(r),o.repeatForever&&e.setTimeout(connect.hitch(n,n.pollForAgentConfiguration,o),3e4)},failure:function(t,r){try{connect.getLog().error("Failed to fetch agent configuration data.").sendInternalLogToServer().withObject({err:t,data:r})}finally{o.repeatForever&&e.setTimeout(connect.hitch(n,n.pollForAgentConfiguration),3e4,o)}},authFailure:function(){r()},accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForAgentStates=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_STATES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForAgentStates(e,{states:(o.states||[]).concat(t.states),nextToken:t.nextToken,maxResults:o.maxResults}):(e.agentStates=(o.states||[]).concat(t.states),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch agent states list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForAgentPermissions=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_PERMISSIONS,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForAgentPermissions(e,{permissions:(o.permissions||[]).concat(t.permissions),nextToken:t.nextToken,maxResults:o.maxResults}):(e.permissions=(o.permissions||[]).concat(t.permissions),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch agent permissions list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForDialableCountryCodes=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_DIALABLE_COUNTRY_CODES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForDialableCountryCodes(e,{countryCodes:(o.countryCodes||[]).concat(t.countryCodes),nextToken:t.nextToken,maxResults:o.maxResults}):(e.dialableCountries=(o.countryCodes||[]).concat(t.countryCodes),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch dialable country codes list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForRoutingProfileQueues=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_ROUTING_PROFILE_QUEUES,{routingProfileARN:e.routingProfile.routingProfileARN,nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForRoutingProfileQueues(e,{countryCodes:(o.queues||[]).concat(t.queues),nextToken:t.nextToken,maxResults:o.maxResults}):(e.routingProfile.queues=(o.queues||[]).concat(t.queues),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch routing profile queues list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.handleAPIRequest=function(e,t){var n=this;this.client.call(t.method,t.params,{success:function(n){var o=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,t,n);e.sendDownstream(o.event,o)},failure:function(o,r){var i=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,t,r,JSON.stringify(o));e.sendDownstream(i.event,i),connect.getLog().error("'%s' API request failed",t.method).withObject({request:n.filterAuthToken(t),response:i}).withException(o).sendInternalLogToServer()},authFailure:connect.hitch(n,n.handleAuthFail)})},o.prototype.handleMasterRequest=function(e,t,n){var o=this.conduit,r=null;switch(n.method){case connect.MasterMethods.BECOME_MASTER:var i=this.masterCoord.getMaster(n.params.topic),s=Boolean(i)&&i!==t;this.masterCoord.setMaster(n.params.topic,t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:t,takeOver:s,topic:n.params.topic}),s&&o.sendDownstream(r.event,r);break;case connect.MasterMethods.CHECK_MASTER:(i=this.masterCoord.getMaster(n.params.topic))||n.params.shouldNotBecomeMasterIfNone||(this.masterCoord.setMaster(n.params.topic,t),i=t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:i,isMaster:t===i,topic:n.params.topic});break;default:throw new Error("Unknown master method: "+n.method)}e.sendDownstream(r.event,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()):connect.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(connect.AgentEvents.UPDATE,this.agent)):connect.getLog().trace("Waiting to update agent until the agent configuration is available.").sendInternalLogToServer():connect.getLog().trace("Waiting to update agent until the agent snapshot is available.").sendInternalLogToServer():connect.getLog().trace("Waiting to update agent until the agent has been fully constructed.").sendInternalLogToServer()},o.prototype.getWebSocketUrl=function(){var e=this,t=connect.core.getClient(),n=connect.hitch(e,e.handleAuthFail),o=connect.hitch(e,e.handleAccessDenied);return new Promise((function(e,r){t.call(connect.ClientMethods.CREATE_TRANSPORT,{transportType:connect.TRANSPORT_TYPES.WEB_SOCKET},{success:function(t){connect.getLog().info("getWebSocketUrl succeeded").sendInternalLogToServer(),e(t)},failure:function(e,t){connect.getLog().error("getWebSocketUrl failed").sendInternalLogToServer().withObject({err:e,data:t}),r({reason:"getWebSocketUrl failed",_debug:e})},authFailure:function(){connect.getLog().error("getWebSocketUrl Auth Failure").sendInternalLogToServer(),r(Error("Authentication failed while getting getWebSocketUrl")),n()},accessDenied:function(){connect.getLog().error("getWebSocketUrl Access Denied Failure").sendInternalLogToServer(),r(Error("Access Denied Failure while getting getWebSocketUrl")),o()}})}))},o.prototype.handleSendLogsRequest=function(){var e=this,t=[],n=e.logsBuffer.slice();e.logsBuffer=[],n.forEach((function(e){t.push({timestamp:e.time,component:e.component,message:e.text})})),this.client.call(connect.ClientMethods.SEND_CLIENT_LOGS,{logEvents:t},{success:function(e){connect.getLog().info("SendLogs request succeeded.").sendInternalLogToServer()},failure:function(e,t){connect.getLog().error("SendLogs request failed.").withObject(t).withException(e).sendInternalLogToServer()},authFailure:connect.hitch(e,e.handleAuthFail)})},o.prototype.handleAuthFail=function(){this.conduit.sendDownstream(connect.EventType.AUTH_FAIL)},o.prototype.handleAccessDenied=function(){this.conduit.sendDownstream(connect.EventType.ACCESS_DENIED)},o.prototype.checkAuthToken=function(){var e=this,t=new Date(e.initData.authTokenExpiration),n=(new Date).getTime();t.getTime(){var e={340:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect,connect.agentApp={};var t="ccp";connect.agentApp.initCCP=connect.core.initCCP,connect.agentApp.isInitialized=function(e){},connect.agentApp.initAppCommunication=function(e,t){var n=document.getElementById(e),o=new connect.IFrameConduit(t,window,n),r=[connect.AgentEvents.UPDATE,connect.ContactEvents.VIEW,connect.EventType.ACKNOWLEDGE,connect.EventType.TERMINATED,connect.TaskEvents.CREATED];n.addEventListener("load",(function(e){r.forEach((function(e){connect.core.getUpstream().onUpstream(e,(function(t){o.sendUpstream(e,t)}))}))}))};var n=function(e){var t=e.indexOf("ccp-v2");return e.slice(0,t-1)};connect.agentApp.initApp=function(e,o,r,i){i=i||{};var s=r.endsWith("/")?r:r+"/",c=i.onLoad?i.onLoad:null,a={endpoint:s,style:i.style,onLoad:c};connect.agentApp.AppRegistry.register(e,a,document.getElementById(o)),connect.agentApp.AppRegistry.start(e,(function(o){var r=o.endpoint,s=o.containerDOM;return{init:function(){return e===t?function(e,t,o){var r={ccpUrl:e,ccpLoadTimeout:1e4,loginPopup:!0,loginUrl:n(e)+"/login",softphone:{allowFramedSoftphone:!0,disableRingtone:!1}},i=connect.merge(r,o.ccpParams);connect.core.initCCP(t,i)}(r,s,i):connect.agentApp.initAppCommunication(e,r)},destroy:function(){return e===t?(o=n(r)+"/logout",connect.fetch(o,{credentials:"include"}).then((function(){return connect.core.getEventBus().trigger(connect.EventType.TERMINATE),!0})).catch((function(e){return connect.getLog().error("An error occured on logout."+e).withException(e),window.location.href=o,!1}))):null;var o}}}))},connect.agentApp.stopApp=function(e){return connect.agentApp.AppRegistry.stop(e)}}()},228:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect;var t,n="ccp";e.connect.agentApp.AppRegistry=(t={},{register:function(e,n,o){t[e]={containerDOM:o,endpoint:n.endpoint,style:n.style,instance:void 0,onLoad:n.onLoad}},start:function(e,o){if(t[e]){var r=t[e].containerDOM,i=t[e].endpoint,s=t[e].style,c=t[e].onLoad;if(e!==n){var a=function(e,t,n,o){var r=document.createElement("iframe");return r.src=t,r.style=n||"width: 100%; height:100%;",r.id=e,r["aria-label"]=e,r.onload=o,r.setAttribute("sandbox","allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"),r}(e,i,s,c);r.appendChild(a)}return t[e].instance=o(t[e]),t[e].instance.init()}},stop:function(e){if(t[e]){var n,o=t[e],r=o.containerDOM.querySelector("iframe");return o.containerDOM.removeChild(r),o.instance&&(n=o.instance.destroy(),delete o.instance),n}}})}()},35:()=>{function e(e,n){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,n){if(e){if("string"==typeof e)return t(e,n);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){o&&(e=o);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,c=!0,a=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return c=e.done,e},e:function(e){a=!0,s=e},f:function(){try{c||null==o.return||o.return()}finally{if(a)throw s}}}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0&&(n=r[0].getConnectionId())}t.call(connect.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:n},e)},r.prototype.sendSoftphoneMetrics=function(e,n){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:t.ccpVersion,softphoneStreamStatistics:e},n),connect.publishSoftphoneStats({contactId:this.getContactId(),ccpVersion:t.ccpVersion,stats:e})},r.prototype.sendSoftphoneReport=function(e,n){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:t.ccpVersion,report:e},n),connect.publishSoftphoneReport({contactId:this.getContactId(),ccpVersion:t.ccpVersion,report:e})},r.prototype.conferenceConnections=function(e){connect.core.getClient().call(connect.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},r.prototype.toSnapshot=function(){return new connect.ContactSnapshot(this._getData())};var i=function(e){connect.Contact.call(this,e.contactId),this.contactData=e};(i.prototype=Object.create(r.prototype)).constructor=i,i.prototype._getData=function(){return this.contactData},i.prototype._createConnectionAPI=function(e){return new connect.ConnectionSnapshot(e)};var s=function(e,t){this.contactId=e,this.connectionId=t,this._initMediaController()};s.prototype._getData=function(){return connect.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 connect.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 connect.now()-this._getData().state.timestamp.getTime()+connect.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 connect.contains(connect.CONNECTION_ACTIVE_STATES,this.getStatus().type)},s.prototype.isConnected=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTED},s.prototype.isConnecting=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTING},s.prototype.isOnHold=function(){return this.getStatus().type===connect.ConnectionStateType.HOLD},s.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMonitorInfo=function(){return this._getData().monitoringInfo},s.prototype.destroy=function(e){connect.core.getClient().call(connect.ClientMethods.DESTROY_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.sendDigits=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_DIGITS,{contactId:this.getContactId(),connectionId:this.getConnectionId(),digits:e},t)},s.prototype.hold=function(e){connect.core.getClient().call(connect.ClientMethods.HOLD_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.resume=function(e){connect.core.getClient().call(connect.ClientMethods.RESUME_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.toSnapshot=function(){return new connect.ConnectionSnapshot(this._getData())},s.prototype._initMediaController=function(){this.getMediaInfo()&&connect.core.mediaFactory.get(this).catch((function(){}))},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING},s.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING};var c=function(e){this.contactId=e};c.prototype.getSpeakerId=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){t.call(connect.AgentAppClientMethods.GET_CONTACT,{contactId:e.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),awsAccountId:connect.core.getAgentDataProvider().getAWSAccountId()},{success:function(e){if(e.contactData.customerId){var t={speakerId:e.contactData.customerId};connect.getLog().info("getSpeakerId succeeded").withObject(e).sendInternalLogToServer(),n(t)}else{var r=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_SPEAKER_ID_FOUND,"No speakerId assotiated with this call");o(r)}},failure:function(e){connect.getLog().error("Get SpeakerId failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_ID_FAILED,"Get SpeakerId failed",e);o(t)}})}))},c.prototype.getSpeakerStatus=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getSpeakerId().then((function(r){e.getDomainId().then((function(e){t.call(connect.AgentAppClientMethods.DESCRIBE_SPEAKER,{SpeakerId:connect.assertNotNull(r.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("getSpeakerStatus succeeded").withObject(e).sendInternalLogToServer(),n(e)},failure:function(e){var t=JSON.parse(e);switch(t.status){case 400:case 404:var r=t;r.type=r.type?r.type:connect.VoiceIdErrorTypes.SPEAKER_ID_NOT_ENROLLED,connect.getLog().info("Speaker is not enrolled.").sendInternalLogToServer(),n(r);break;default:connect.getLog().error("getSpeakerStatus failed").withObject({err:e}).sendInternalLogToServer();var i=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_STATUS_FAILED,"Get SpeakerStatus failed",e);o(i)}}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},c.prototype._optOutSpeakerInLcms=function(e){var t=this,n=connect.core.getClient();return new Promise((function(o,r){n.call(connect.AgentAppClientMethods.UPDATE_VOICE_ID_DATA,{ContactId:t.contactId,InstanceId:connect.core.getAgentDataProvider().getInstanceId(),AWSAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),CustomerId:connect.assertNotNull(e,"speakerId"),VoiceIdResult:{SpeakerOptedOut:!0}},{success:function(e){connect.getLog().info("optOutSpeakerInLcms succeeded").withObject(e).sendInternalLogToServer(),o(e)},failure:function(e){connect.getLog().error("optOutSpeakerInLcms failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_IN_LCMS_FAILED,"optOutSpeakerInLcms failed",e);r(t)}})}))},c.prototype.optOutSpeaker=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getSpeakerId().then((function(r){e.getDomainId().then((function(i){var s=r.speakerId;t.call(connect.AgentAppClientMethods.OPT_OUT_SPEAKER,{SpeakerId:connect.assertNotNull(s,"speakerId"),DomainId:i},{success:function(t){e._optOutSpeakerInLcms(s).catch((function(){})),connect.getLog().info("optOutSpeaker succeeded").withObject(t).sendInternalLogToServer(),n(t)},failure:function(e){connect.getLog().error("optOutSpeaker failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_FAILED,"optOutSpeaker failed.",e);o(t)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},c.prototype.deleteSpeaker=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getSpeakerId().then((function(r){e.getDomainId().then((function(e){t.call(connect.AgentAppClientMethods.DELETE_SPEAKER,{SpeakerId:connect.assertNotNull(r.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("deleteSpeaker succeeded").withObject(e).sendInternalLogToServer(),n(e)},failure:function(e){connect.getLog().error("deleteSpeaker failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.DELETE_SPEAKER_FAILED,"deleteSpeaker failed.",e);o(t)}})})).catch((function(e){o(e)}))})).catch((function(e){o(e)}))}))},c.prototype.startSession=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,o){e.getDomainId().then((function(r){t.call(connect.AgentAppClientMethods.START_VOICE_ID_SESSION,{contactId:e.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),customerAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),clientToken:AWS.util.uuid.v4(),domainId:r},{success:function(e){if(e.sessionId)n(e);else{connect.getLog().error("startVoiceIdSession failed, no session id returned").withObject({data:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"No session id returned from start session api");o(t)}},failure:function(e){connect.getLog().error("startVoiceIdSession failed").withObject({err:e}).sendInternalLogToServer();var t=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"startVoiceIdSession failed",e);o(t)}})})).catch((function(e){o(e)}))}))},c.prototype.evaluateSpeaker=function(e){var t=this;t.checkConferenceCall();var n=connect.core.getClient(),o=connect.core.getAgentDataProvider().getContactData(this.contactId),r=0;return new Promise((function(i,s){function c(){t.getDomainId().then((function(e){n.call(connect.AgentAppClientMethods.EVALUATE_SESSION,{SessionNameOrId:o.initialContactId||this.contactId,DomainId:e},{success:function(e){if(++r=1&&(o=n.IntegrationAssociationSummaryList[0].IntegrationArn.replace(/^.*domain\//i,"")),!o){connect.getLog().info("getDomainId: no domainId found").sendInternalLogToServer();var r=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_DOMAIN_ID_FOUND);return void t(r)}connect.getLog().info("getDomainId succeeded").withObject(n).sendInternalLogToServer(),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.VoiceIdEvents.UPDATE_DOMAIN_ID,data:{domainId:o}}),e(o)}catch(e){connect.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer(),r=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e),t(r)}},failure:function(e){connect.getLog().error("getDomainId failed").withObject({err:e}).sendInternalLogToServer();var n=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",e);t(n)}}):t(new Error("Agent doesn't have the permission for Voice ID"))}))},c.prototype.checkConferenceCall=function(){if(connect.core.getAgentDataProvider().getContactData(this.contactId).connections.filter((function(e){return connect.contains(connect.CONNECTION_ACTIVE_STATES,e.state.type)})).length>2)throw new connect.NotImplementedError("VoiceId is not supported for conference calls")},c.prototype.isAuthEnabled=function(e){return e!==connect.ContactFlowAuthenticationDecision.NOT_ENABLED},c.prototype.isAuthResultNotEnoughSpeech=function(e){return e===connect.VoiceIdAuthenticationDecision.NOT_ENOUGH_SPEECH},c.prototype.isAuthResultInconclusive=function(e){return e===connect.ContactFlowAuthenticationDecision.INCONCLUSIVE},c.prototype.isFraudEnabled=function(e){return e!==connect.ContactFlowFraudDetectionDecision.NOT_ENABLED},c.prototype.isFraudResultNotEnoughSpeech=function(e){return e===connect.VoiceIdFraudDetectionDecision.NOT_ENOUGH_SPEECH},c.prototype.isFraudResultInconclusive=function(e){return e===connect.ContactFlowFraudDetectionDecision.INCONCLUSIVE};var a=function(e,t){this._speakerAuthenticator=new c(e),s.call(this,e,t)};(a.prototype=Object.create(s.prototype)).constructor=a,a.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},a.prototype.getMediaInfo=function(){return this._getData().softphoneMediaInfo},a.prototype.getMediaType=function(){return connect.MediaType.SOFTPHONE},a.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)},a.prototype.getVoiceIdSpeakerId=function(){return this._speakerAuthenticator.getSpeakerId()},a.prototype.getVoiceIdSpeakerStatus=function(){return this._speakerAuthenticator.getSpeakerStatus()},a.prototype.optOutVoiceIdSpeaker=function(){return this._speakerAuthenticator.optOutSpeaker()},a.prototype.deleteVoiceIdSpeaker=function(){return this._speakerAuthenticator.deleteSpeaker()},a.prototype.evaluateSpeakerWithVoiceId=function(e){return this._speakerAuthenticator.evaluateSpeaker(e)},a.prototype.enrollSpeakerInVoiceId=function(){return this._speakerAuthenticator.enrollSpeaker()},a.prototype.updateVoiceIdSpeakerId=function(e){return this._speakerAuthenticator.updateSpeakerIdInVoiceId(e)},a.prototype.getQuickConnectName=function(){return this._getData().quickConnectName},a.prototype.isMute=function(){return this._getData().mute},a.prototype.muteParticipant=function(e){connect.core.getClient().call(connect.ClientMethods.MUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},a.prototype.unmuteParticipant=function(e){connect.core.getClient().call(connect.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 t=connect.core.getAgentDataProvider().getContactData(this.contactId),n={contactId:this.contactId,initialContactId:t.initialContactId||this.contactId,participantId:this.connectionId,getConnectionToken:connect.hitch(this,this.getConnectionToken)};if(e.connectionData)try{n.participantToken=JSON.parse(e.connectionData).ConnectionAuthenticationToken}catch(t){connect.getLog().error(connect.LogComponent.CHAT,"Connection data is invalid").withObject(e).withException(t).sendInternalLogToServer(),n.participantToken=null}return n.participantToken=n.participantToken||null,n.originalInfo=this._getData().chatMediaInfo,n}return null},u.prototype.getConnectionToken=function(){client=connect.core.getClient();var e=connect.core.getAgentDataProvider().getContactData(this.contactId),t={transportType:connect.TRANSPORT_TYPES.CHAT_TOKEN,participantId:this.connectionId,contactId:e.initialContactId||this.contactId};return new Promise((function(e,n){client.call(connect.ClientMethods.CREATE_TRANSPORT,t,{success:function(t){connect.getLog().info("getConnectionToken succeeded").sendInternalLogToServer(),e(t)},failure:function(e,t){connect.getLog().error("getConnectionToken failed").sendInternalLogToServer().withObject({err:e,data:t}),n(Error("getConnectionToken failed"))}})}))},u.prototype.getMediaType=function(){return connect.MediaType.CHAT},u.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)},u.prototype._initMediaController=function(){this._isAgentConnectionType()&&connect.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 connect.MediaType.TASK},l.prototype.getMediaInfo=function(){var e=connect.core.getAgentDataProvider().getContactData(this.contactId);return{contactId:this.contactId,initialContactId:e.initialContactId||this.contactId}},l.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)};var p=function(e){connect.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 h=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};h.prototype.stripPhoneNumber=function(){return this.phoneNumber?this.phoneNumber.replace(/sip:([^@]*)@.*/,"$1"):""},h.byPhoneNumber=function(e,t){return new h({type:connect.EndpointType.PHONE_NUMBER,phoneNumber:e,name:t||null})};var d=function(e,t,n){this.errorType=e,this.errorMessage=t,this.endPointUrl=n};d.prototype.getErrorType=function(){return this.errorType},d.prototype.getErrorMessage=function(){return this.errorMessage},d.prototype.getEndPointUrl=function(){return this.endPointUrl},connect.agent=function(e){var t=connect.core.getEventBus().subscribe(connect.AgentEvents.INIT,e);return connect.agent.initialized&&e(new connect.Agent),t},connect.agent.initialized=!1,connect.contact=function(e){return connect.core.getEventBus().subscribe(connect.ContactEvents.INIT,e)},connect.onWebsocketInitFailure=function(e){var t=connect.core.getEventBus().subscribe(connect.WebSocketEvents.INIT_FAILURE,e);return connect.webSocketInitFailed&&e(),t},connect.ifMaster=function(e,t,n,o){if(connect.assertNotNull(e,"A topic must be provided."),connect.assertNotNull(t,"A true callback must be provided."),!connect.core.masterClient)return connect.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e).sendInternalLogToServer(),void(n&&n());connect.core.getMasterClient().call(connect.MasterMethods.CHECK_MASTER,{topic:e,shouldNotBecomeMasterIfNone:o},{success:function(e){e.isMaster?t():n&&n()}})},connect.becomeMaster=function(e,t,n){connect.assertNotNull(e,"A topic must be provided."),connect.core.masterClient?connect.core.getMasterClient().call(connect.MasterMethods.BECOME_MASTER,{topic:e},{success:function(){t&&t()}}):(connect.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e),n&&n())},connect.Agent=n,connect.AgentSnapshot=o,connect.Contact=r,connect.ContactSnapshot=i,connect.Connection=a,connect.BaseConnection=s,connect.VoiceConnection=a,connect.ChatConnection=u,connect.TaskConnection=l,connect.ConnectionSnapshot=p,connect.Endpoint=h,connect.Address=h,connect.SoftphoneError=d,connect.VoiceId=c}()},538:(e,t,n)=>{var o;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},r(e)}!function e(t,n,o){function r(s,c){if(!n[s]){if(!t[s]){if(i)return i(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,n,o)}return n[s].exports}for(var i=void 0,s=0;s-1});var r=["[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 o(e,"utf8")),ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}}},{"buffer/":81}],12:[function(e,t,n){var o=e("./browserHashUtils");function r(e,t){this.hash=new e,this.outer=new e;var n=function(e,t){var n=o.convertToBuffer(t);if(n.byteLength>e.BLOCK_SIZE){var r=new e;r.update(n),n=r.digest()}var i=new Uint8Array(e.BLOCK_SIZE);return i.set(n),i}(e,t),r=new Uint8Array(e.BLOCK_SIZE);r.set(n);for(var i=0;i>>32-r)+n&4294967295}function a(e,t,n,o,r,i,s){return c(t&n|~t&o,e,t,r,i,s)}function u(e,t,n,o,r,i,s){return c(t&o|n&~o,e,t,r,i,s)}function l(e,t,n,o,r,i,s){return c(t^n^o,e,t,r,i,s)}function p(e,t,n,o,r,i,s){return c(n^(t|~o),e,t,r,i,s)}t.exports=s,s.BLOCK_SIZE=i,s.prototype.update=function(e){if(o.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=o.convertToBuffer(e),n=0,r=t.byteLength;for(this.bytesHashed+=r;r>0;)this.buffer.setUint8(this.bufferLength++,t[n++]),r--,this.bufferLength===i&&(this.hashBuffer(),this.bufferLength=0);return this},s.prototype.digest=function(e){if(!this.finished){var t=this,n=t.buffer,o=t.bufferLength,s=8*t.bytesHashed;if(n.setUint8(this.bufferLength++,128),o%i>=56){for(var c=this.bufferLength;c>>0,!0),n.setUint32(60,Math.floor(s/4294967296),!0),this.hashBuffer(),this.finished=!0}var a=new DataView(new ArrayBuffer(16));for(c=0;c<4;c++)a.setUint32(4*c,this.state[c],!0);var u=new r(a.buffer,a.byteOffset,a.byteLength);return e?u.toString(e):u},s.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=t[0],o=t[1],r=t[2],i=t[3];n=a(n,o,r,i,e.getUint32(0,!0),7,3614090360),i=a(i,n,o,r,e.getUint32(4,!0),12,3905402710),r=a(r,i,n,o,e.getUint32(8,!0),17,606105819),o=a(o,r,i,n,e.getUint32(12,!0),22,3250441966),n=a(n,o,r,i,e.getUint32(16,!0),7,4118548399),i=a(i,n,o,r,e.getUint32(20,!0),12,1200080426),r=a(r,i,n,o,e.getUint32(24,!0),17,2821735955),o=a(o,r,i,n,e.getUint32(28,!0),22,4249261313),n=a(n,o,r,i,e.getUint32(32,!0),7,1770035416),i=a(i,n,o,r,e.getUint32(36,!0),12,2336552879),r=a(r,i,n,o,e.getUint32(40,!0),17,4294925233),o=a(o,r,i,n,e.getUint32(44,!0),22,2304563134),n=a(n,o,r,i,e.getUint32(48,!0),7,1804603682),i=a(i,n,o,r,e.getUint32(52,!0),12,4254626195),r=a(r,i,n,o,e.getUint32(56,!0),17,2792965006),n=u(n,o=a(o,r,i,n,e.getUint32(60,!0),22,1236535329),r,i,e.getUint32(4,!0),5,4129170786),i=u(i,n,o,r,e.getUint32(24,!0),9,3225465664),r=u(r,i,n,o,e.getUint32(44,!0),14,643717713),o=u(o,r,i,n,e.getUint32(0,!0),20,3921069994),n=u(n,o,r,i,e.getUint32(20,!0),5,3593408605),i=u(i,n,o,r,e.getUint32(40,!0),9,38016083),r=u(r,i,n,o,e.getUint32(60,!0),14,3634488961),o=u(o,r,i,n,e.getUint32(16,!0),20,3889429448),n=u(n,o,r,i,e.getUint32(36,!0),5,568446438),i=u(i,n,o,r,e.getUint32(56,!0),9,3275163606),r=u(r,i,n,o,e.getUint32(12,!0),14,4107603335),o=u(o,r,i,n,e.getUint32(32,!0),20,1163531501),n=u(n,o,r,i,e.getUint32(52,!0),5,2850285829),i=u(i,n,o,r,e.getUint32(8,!0),9,4243563512),r=u(r,i,n,o,e.getUint32(28,!0),14,1735328473),n=l(n,o=u(o,r,i,n,e.getUint32(48,!0),20,2368359562),r,i,e.getUint32(20,!0),4,4294588738),i=l(i,n,o,r,e.getUint32(32,!0),11,2272392833),r=l(r,i,n,o,e.getUint32(44,!0),16,1839030562),o=l(o,r,i,n,e.getUint32(56,!0),23,4259657740),n=l(n,o,r,i,e.getUint32(4,!0),4,2763975236),i=l(i,n,o,r,e.getUint32(16,!0),11,1272893353),r=l(r,i,n,o,e.getUint32(28,!0),16,4139469664),o=l(o,r,i,n,e.getUint32(40,!0),23,3200236656),n=l(n,o,r,i,e.getUint32(52,!0),4,681279174),i=l(i,n,o,r,e.getUint32(0,!0),11,3936430074),r=l(r,i,n,o,e.getUint32(12,!0),16,3572445317),o=l(o,r,i,n,e.getUint32(24,!0),23,76029189),n=l(n,o,r,i,e.getUint32(36,!0),4,3654602809),i=l(i,n,o,r,e.getUint32(48,!0),11,3873151461),r=l(r,i,n,o,e.getUint32(60,!0),16,530742520),n=p(n,o=l(o,r,i,n,e.getUint32(8,!0),23,3299628645),r,i,e.getUint32(0,!0),6,4096336452),i=p(i,n,o,r,e.getUint32(28,!0),10,1126891415),r=p(r,i,n,o,e.getUint32(56,!0),15,2878612391),o=p(o,r,i,n,e.getUint32(20,!0),21,4237533241),n=p(n,o,r,i,e.getUint32(48,!0),6,1700485571),i=p(i,n,o,r,e.getUint32(12,!0),10,2399980690),r=p(r,i,n,o,e.getUint32(40,!0),15,4293915773),o=p(o,r,i,n,e.getUint32(4,!0),21,2240044497),n=p(n,o,r,i,e.getUint32(32,!0),6,1873313359),i=p(i,n,o,r,e.getUint32(60,!0),10,4264355552),r=p(r,i,n,o,e.getUint32(24,!0),15,2734768916),o=p(o,r,i,n,e.getUint32(52,!0),21,1309151649),n=p(n,o,r,i,e.getUint32(16,!0),6,4149444226),i=p(i,n,o,r,e.getUint32(44,!0),10,3174756917),r=p(r,i,n,o,e.getUint32(8,!0),15,718787259),o=p(o,r,i,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=o+t[1]&4294967295,t[2]=r+t[2]&4294967295,t[3]=i+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":81}],14:[function(e,t,n){var o=e("buffer/").Buffer,r=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(r.isEmptyData(e))return this;var t=(e=r.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 o(20),r=new DataView(n.buffer);return r.setUint32(0,this.h0,!1),r.setUint32(4,this.h1,!1),r.setUint32(8,this.h2,!1),r.setUint32(12,this.h3,!1),r.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,o,r=this.h0,i=this.h1,s=this.h2,c=this.h3,a=this.h4;for(e=0;e<80;e++){e<20?(n=c^i&(s^c),o=1518500249):e<40?(n=i^s^c,o=1859775393):e<60?(n=i&s|c&(i|s),o=2400959708):(n=i^s^c,o=3395469782);var u=(r<<5|r>>>27)+n+a+o+(0|this.block[e]);a=c,c=s,s=i<<30|i>>>2,i=r,r=u}for(this.h0=this.h0+r|0,this.h1=this.h1+i|0,this.h2=this.h2+s|0,this.h3=this.h3+c|0,this.h4=this.h4+a|0,this.offset=0,e=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":81}],15:[function(e,t,n){var o=e("buffer/").Buffer,r=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]),c=Math.pow(2,53)-1;function a(){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=a,a.BLOCK_SIZE=i,a.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(r.isEmptyData(e))return this;var t=0,n=(e=r.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>c)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},a.prototype.digest=function(e){if(!this.finished){var t=8*this.bytesHashed,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),r=this.bufferLength;if(n.setUint8(this.bufferLength++,128),r%i>=56){for(var s=this.bufferLength;s>>24&255,c[4*s+1]=this.state[s]>>>16&255,c[4*s+2]=this.state[s]>>>8&255,c[4*s+3]=this.state[s]>>>0&255;return e?c.toString(e):c},a.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],o=t[1],r=t[2],c=t[3],a=t[4],u=t[5],l=t[6],p=t[7],h=0;h>>17|d<<15)^(d>>>19|d<<13)^d>>>10,g=((d=this.temp[h-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3;this.temp[h]=(f+this.temp[h-7]|0)+(g+this.temp[h-16]|0)}var m=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&u^~a&l)|0)+(p+(s[h]+this.temp[h]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&o^n&r^o&r)|0;p=l,l=u,u=a,a=c+m|0,c=r,r=o,o=n,n=m+v|0}t[0]+=n,t[1]+=o,t[2]+=r,t[3]+=c,t[4]+=a,t[5]+=u,t[6]+=l,t[7]+=p}},{"./browserHashUtils":11,"buffer/":81}],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 o=e("./core");if(t.exports=o,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"),o.XML.Parser=e("./xml/browser_parser"),e("./http/xhr"),void 0===r)var r={browser:!0}}).call(this)}).call(this,e("_process"))},{"./browserCryptoLib":10,"./core":18,"./credentials":19,"./credentials/chainable_temporary_credentials":20,"./credentials/cognito_identity_credentials":21,"./credentials/credential_provider_chain":22,"./credentials/saml_credentials":23,"./credentials/temporary_credentials":24,"./credentials/web_identity_credentials":25,"./event-stream/buffered-create-event-stream":27,"./http/xhr":35,"./realclock/browserClock":52,"./util":71,"./xml/browser_parser":72,_process:86,"buffer/":81,"querystring/":92,"url/":94}],17:[function(e,t,n){var o,r=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),r.Config=r.util.inherit({constructor:function(e){void 0===e&&(e={}),e=this.extractCredentials(e),r.util.each.call(this,this.keys,(function(t,n){this.set(t,e[t],n)}))},getCredentials:function(e){var t,n=this;function o(t){e(t,t?null:n.credentials)}function i(e,t){return new r.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)),o(e)})):(t=null,n.credentials.accessKeyId&&n.credentials.secretAccessKey||(t=i("Missing credentials")),o(t)):n.credentialProvider?n.credentialProvider.resolve((function(e,t){e&&(e=i("Could not load credentials from any providers",e)),n.credentials=t,o(e)})):o(i("No credentials to load"))},update:function(e,t){t=t||!1,e=this.extractCredentials(e),r.util.each.call(this,e,(function(e,n){(t||Object.prototype.hasOwnProperty.call(this.keys,e)||r.Service.hasService(e))&&this.set(e,n)}))},loadFromPath:function(e){this.clear();var t=JSON.parse(r.util.readFileSync(e)),n=new r.FileSystemCredentials(e),o=new r.CredentialProviderChain;return o.providers.unshift(n),o.resolve((function(e,n){if(e)throw e;t.credentials=n})),this.constructor(t),this},clear:function(){r.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]=r.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,computeChecksums:!0,convertResponseTypes:!0,correctClockSkew:!1,customUserAgent:null,dynamoDbCrc32:!0,systemClockOffset:0,signatureVersion:null,signatureCache:!0,retryDelayOptions:{},useAccelerateEndpoint:!1,clientSideMonitoring:!1,endpointDiscoveryEnabled:!1,endpointCacheSize:1e3,hostPrefixEnabled:!0,stsRegionalEndpoints:null},extractCredentials:function(e){return e.accessKeyId&&e.secretAccessKey&&((e=r.util.copy(e)).credentials=new r.Credentials(e)),e},setPromisesDependency:function(e){o=e,null===e&&"function"==typeof Promise&&(o=Promise);var t=[r.Request,r.Credentials,r.CredentialProviderChain];r.S3&&(t.push(r.S3),r.S3.ManagedUpload&&t.push(r.S3.ManagedUpload)),r.util.addPromises(t,o)},getPromisesDependency:function(){return o}}),r.config=new r.Config},{"./core":18,"./credentials":19,"./credentials/credential_provider_chain":22}],18:[function(e,t,n){var o={util:e("./util")};({}).toString(),t.exports=o,o.util.update(o,{VERSION:"2.553.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"),o.events=new o.SequentialExecutor,o.util.memoizedProperty(o,"endpointCache",(function(){return new o.EndpointCache(o.config.endpointCacheSize)}),!0)},{"../vendor/endpoint-cache":103,"./api_loader":9,"./config":17,"./event_listeners":33,"./http":34,"./json/builder":36,"./json/parser":37,"./model/api":38,"./model/operation":40,"./model/paginator":41,"./model/resource_waiter":42,"./model/shape":43,"./param_validator":44,"./protocol/json":46,"./protocol/query":47,"./protocol/rest":48,"./protocol/rest_json":49,"./protocol/rest_xml":50,"./request":55,"./resource_waiter":56,"./response":57,"./sequential_executor":58,"./service":59,"./signers/request_signer":63,"./util":71,"./xml/builder":73}],19:[function(e,t,n){var o=e("./core");o.Credentials=o.util.inherit({constructor:function(){if(o.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"===r(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=o.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){o.util.arrayEach(n.refreshCallbacks,(function(n){t?n(e):o.util.defer((function(){n(e)}))})),n.refreshCallbacks.length=0}))},load:function(e){e()}}),o.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=o.util.promisifyMethod("get",e),this.prototype.refreshPromise=o.util.promisifyMethod("refresh",e)},o.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},o.util.addPromises(o.Credentials)},{"./core":18}],20:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.ChainableTemporaryCredentials=o.util.inherit(o.Credentials,{constructor:function(e){o.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=o.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!=typeof e.tokenCodeFn)throw new o.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=o.util.merge({params:t,credentials:e.masterCredentials||o.config.credentials},e.stsConfig||{});this.service=new r(n)},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(e){var t=this,n=t.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode((function(o,r){var i={};o?e(o):(r&&(i.TokenCode=r),t.service[n](i,(function(n,o){n||t.service.credentialsFrom(o,t),e(n)})))}))},getTokenCode:function(e){var t=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,(function(n,r){if(n){var i=n;return n instanceof Error&&(i=n.message),void e(o.util.error(new Error("Error fetching MFA token: "+i),{code:t.errorCode}))}e(null,r)})):e(null)}})},{"../../clients/sts":8,"../core":18}],21:[function(e,t,n){var o=e("../core"),i=e("../../clients/cognitoidentity"),s=e("../../clients/sts");o.CognitoIdentityCredentials=o.util.inherit(o.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=o.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||o.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,o){!n&&o.IdentityId?(t.params.IdentityId=o.IdentityId,e(null,o.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,o){n?t.clearIdOnNotAuthorized(n):(t.cacheId(o),t.data=o,t.loadCredentials(t.data,t)),e(n)}))},getCredentialsFromSTS:function(e){var t=this;t.cognito.getOpenIdToken((function(n,o){n?(t.clearIdOnNotAuthorized(n),e(n)):(t.cacheId(o),t.params.WebIdentityToken=o.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(o.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 o.WebIdentityCredentials(this.params,e),!this.cognito){var t=o.util.merge({},e);t.params=this.params,this.cognito=new i(t)}this.sts=this.sts||new s(e)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,o.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=o.util.isBrowser()&&null!==window.localStorage&&"object"===r(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":18}],22:[function(e,t,n){var o=e("../core");o.CredentialProviderChain=o.util.inherit(o.Credentials,{constructor:function(e){this.providers=e||o.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,r=t.providers.slice(0);!function e(i,s){if(!i&&s||n===r.length)return o.util.arrayEach(t.resolveCallbacks,(function(e){e(i,s)})),void(t.resolveCallbacks.length=0);var c=r[n++];(s="function"==typeof c?c.call():c).get?s.get((function(t){e(t,t?null:s)})):e(null,s)}()}return t}}),o.CredentialProviderChain.defaultProviders=[],o.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=o.util.promisifyMethod("resolve",e)},o.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},o.util.addPromises(o.CredentialProviderChain)},{"../core":18}],23:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.SAMLCredentials=o.util.inherit(o.Credentials,{constructor:function(e){o.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithSAML((function(n,o){n||t.service.credentialsFrom(o,t),e(n)}))},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],24:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.TemporaryCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.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||o.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,o){n||t.service.credentialsFrom(o,t),e(n)}))}))},loadMasterCredentials:function(e){for(this.masterCredentials=e||o.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new o.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],25:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.WebIdentityCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=o.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithWebIdentity((function(n,o){t.data=null,n||(t.data=o,t.service.credentialsFrom(o,t)),e(n)}))},createClients:function(){if(!this.service){var e=o.util.merge({},this._clientConfig);e.params=this.params,this.service=new r(e)}}})},{"../../clients/sts":8,"../core":18}],26:[function(e,t,n){(function(n){(function(){var o=e("./core"),r=e("./util"),i=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function s(e){var t=e.service,n=t.api||{},o=(n.operations,{});return t.config.region&&(o.region=t.config.region),n.serviceId&&(o.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(o.accessKeyId=t.config.credentials.accessKeyId),o}function c(e,t,n){n&&null!=t&&"structure"===n.type&&n.required&&n.required.length>0&&r.arrayEach(n.required,(function(o){var r=n.members[o];if(!0===r.endpointDiscoveryId){var i=r.isLocationName?r.name:o;e[i]=String(t[o])}else c(e,t[o],r)}))}function a(e,t){var n={};return c(n,e.params,t),n}function u(e){var t=e.service,n=t.api,i=n.operations?n.operations[e.operation]:void 0,c=a(e,i?i.input:void 0),u=s(e);Object.keys(c).length>0&&(u=r.update(u,c),i&&(u.operation=i.name));var l=o.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:c});h(p),p.removeListener("validate",o.EventListeners.Core.VALIDATE_PARAMETERS),p.removeListener("retry",o.EventListeners.Core.RETRY_CHECK),o.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}]),p.send((function(e,t){t&&t.Endpoints?o.endpointCache.put(u,t.Endpoints):e&&o.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}])}))}}var l={};function p(e,t){var n=e.service,i=n.api,c=i.operations?i.operations[e.operation]:void 0,u=c?c.input:void 0,p=a(e,u),d=s(e);Object.keys(p).length>0&&(d=r.update(d,p),c&&(d.operation=c.name));var f=o.EndpointCache.getKeyString(d),g=o.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:c.name,Identifiers:p});m.removeListener("validate",o.EventListeners.Core.VALIDATE_PARAMETERS),h(m),o.endpointCache.put(f,[{Address:"",CachePeriodInMinutes:60}]),m.send((function(n,i){if(n){var s={code:"EndpointDiscoveryException",message:"Request cannot be fulfilled without specifying an endpoint",retryable:!1};if(e.response.error=r.error(n,s),o.endpointCache.remove(d),l[f]){var c=l[f];r.arrayEach(c,(function(e){e.request.response.error=r.error(n,s),e.callback()})),delete l[f]}}else i&&(o.endpointCache.put(f,i.Endpoints),e.httpRequest.updateEndpoint(i.Endpoints[0].Address),l[f])&&(c=l[f],r.arrayEach(c,(function(e){e.request.httpRequest.updateEndpoint(i.Endpoints[0].Address),e.callback()})),delete l[f]);t()}))}}function h(e){var t=e.service.api.apiVersion;t&&!e.httpRequest.headers["x-amz-api-version"]&&(e.httpRequest.headers["x-amz-api-version"]=t)}function d(e){var t=e.error,n=e.httpResponse;if(t&&("InvalidEndpointException"===t.code||421===n.statusCode)){var i=e.request,c=i.service.api.operations||{},u=a(i,c[i.operation]?c[i.operation].input:void 0),l=s(i);Object.keys(u).length>0&&(l=r.update(l,u),c[i.operation]&&(l.operation=c[i.operation].name)),o.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 r.error(new Error,{code:"ConfigurationException",message:"Custom endpoint is supplied; endpointDiscoveryEnabled must not be true."});var t=o.config[e.serviceIdentifier]||{};return Boolean(o.config.endpoint||t.endpoint||e._originalConfig&&e._originalConfig.endpoint)}(s)||e.isPresigned())return t();if(!function(e){if(!0===(e.service||{}).config.endpointDiscoveryEnabled)return!0;if(r.isBrowser())return!1;for(var t=0;t-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,o=Math.abs(Math.round(e));n>-1&&o>0;n--,o/=256)t[n]=o;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":18}],30:[function(e,t,n){var o=e("./parse-message").parseMessage;t.exports={parseEvent:function(e,t,n){var r=o(t),i=r.headers[":message-type"];if(i){if("error"===i.value)throw function(e){var t=e.headers[":error-code"],n=e.headers[":error-message"],o=new Error(n.value||n);return o.code=o.name=t.value||t,o}(r);if("event"!==i.value)return}var s=r.headers[":event-type"],c=n.members[s.value];if(c){var a={},u=c.eventPayloadMemberName;if(u){var l=c.members[u];"binary"===l.type?a[u]=r.body:a[u]=e.parse(r.body.toString(),l)}for(var p=c.eventHeaderMemberNames,h=0;h=0)return e.httpRequest.headers["X-Amz-Content-Sha256"]="UNSIGNED-PAYLOAD",t();o.util.computeSha256(i,(function(n,o){n?t(n):(e.httpRequest.headers["X-Amz-Content-Sha256"]=o,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),n=o.util.getRequestPayloadShape(e);if(void 0===e.httpRequest.headers["Content-Length"])try{var r=o.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=r}catch(o){if(n&&n.isStreaming){if(n.requiresLength)throw o;if(t.indexOf("unsigned-body")>=0)return void(e.httpRequest.headers["Transfer-Encoding"]="chunked");throw o}throw o}})),e("SET_HTTP_HOST","afterBuild",(function(e){e.httpRequest.headers.Host=e.httpRequest.endpoint.host})),e("RESTART","restart",(function(){var e=this.response.error;e&&e.retryable&&(this.httpRequest=new o.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,n,r){n.httpResponse.statusCode=e,n.httpResponse.statusMessage=r,n.httpResponse.headers=t,n.httpResponse.body=o.util.buffer.toBuffer(""),n.httpResponse.buffers=[],n.httpResponse.numBytes=0;var i=t.date||t.Date,s=n.request.service;if(i){var c=Date.parse(i);s.config.correctClockSkew&&s.isClockSkewed(c)&&s.applyClockOffset(c)}})),e("HTTP_DATA","httpData",(function(e,t){if(e){if(o.util.isNode()){t.httpResponse.numBytes+=e.length;var n=t.httpResponse.headers["content-length"],r={loaded:t.httpResponse.numBytes,total:n};t.request.emit("httpDownloadProgress",[r,t])}t.httpResponse.buffers.push(o.util.buffer.toBuffer(e))}})),e("HTTP_DONE","httpDone",(function(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var t=o.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 o.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=this.HEADERS_RECEIVED&&!h&&(u.statusCode=p.status,u.headers=c.parseHeaders(p.getAllResponseHeaders()),u.emit("headers",u.statusCode,u.headers,p.statusText),h=!0),this.readyState===this.DONE&&c.finishRequest(p,u)}),!1),p.upload.addEventListener("progress",(function(e){u.emit("sendProgress",e)})),p.addEventListener("progress",(function(e){u.emit("receiveProgress",e)}),!1),p.addEventListener("timeout",(function(){s(o.util.error(new Error("Timeout"),{code:"TimeoutError"}))}),!1),p.addEventListener("error",(function(){s(o.util.error(new Error("Network Failure"),{code:"NetworkingError"}))}),!1),p.addEventListener("abort",(function(){s(o.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))}),!1),n(u),p.open(e.method,l,!1!==t.xhrAsync),o.util.each(e.headers,(function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&p.setRequestHeader(e,t)})),t.timeout&&!1!==t.xhrAsync&&(p.timeout=t.timeout),t.xhrWithCredentials&&(p.withCredentials=!0);try{p.responseType="arraybuffer"}catch(e){}try{e.body?p.send(e.body):p.send()}catch(t){if(!e.body||"object"!==r(e.body.buffer))throw t;p.send(e.body.buffer)}return u},parseHeaders:function(e){var t={};return o.util.arrayEach(e.split(/\r?\n/),(function(e){var n=e.split(":",1)[0],o=e.substring(n.length+2);n.length>0&&(t[n.toLowerCase()]=o)})),t},finishRequest:function(e,t){var n;if("arraybuffer"===e.responseType&&e.response){var r=e.response;n=new o.util.Buffer(r.byteLength);for(var i=new Uint8Array(r),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 f(){a.apply(this,arguments),this.toType=function(e){var t=i.base64.decode(e);if(this.isSensitive&&i.isNode()&&"function"==typeof i.Buffer.alloc){var n=i.Buffer.alloc(t.length,t);t.fill(0),t=n}return t},this.toWireFormat=i.base64.encode}function g(){f.apply(this,arguments)}function m(){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:l,list:p,map:h,boolean:m,timestamp:function(e){var t=this;if(a.apply(this,arguments),e.timestampFormat)s(this,"timestampFormat",e.timestampFormat);else if(t.isTimestampFormatSet&&this.timestampFormat)s(this,"timestampFormat",this.timestampFormat);else if("header"===this.location)s(this,"timestampFormat","rfc822");else if("querystring"===this.location)s(this,"timestampFormat","iso8601");else if(this.api)switch(this.api.protocol){case"json":case"rest-json":s(this,"timestampFormat","unixTimestamp");break;case"rest-xml":case"query":case"ec2":s(this,"timestampFormat","iso8601")}this.toType=function(e){return null==e?null:"function"==typeof e.toUTCString?e:"string"==typeof e||"number"==typeof e?i.date.parseTimestamp(e):null},this.toWireFormat=function(e){return i.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:g,binary:f},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 o=a.resolve(e,t);if(o){var r=Object.keys(e);t.documentation||(r=r.filter((function(e){return!e.match(/documentation/)})));var i=function(){o.constructor.call(this,e,t,n)};return i.prototype=o,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:l,ListShape:p,MapShape:h,StringShape:d,BooleanShape:m,Base64Shape:g},t.exports=a},{"../util":71,"./collection":39}],44:[function(e,t,n){var o=e("./core");o.ParamValidator=o.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 r=this.errors.join("\n* ");throw r="There were "+this.errors.length+" validation errors:\n* "+r,o.util.error(new Error(r),{code:"MultipleValidationErrors",errors:this.errors})}if(1===this.errors.length)throw this.errors[0];return!0},fail:function(e,t){this.errors.push(o.util.error(new Error(t),{code:e}))},validateStructure:function(e,t,n){var o;this.validateType(t,n,["object"],"structure");for(var r=0;e.required&&r= 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,o){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 "+o+" <= "+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,i){if(null==e)return!1;for(var s=!1,c=0;c63)throw o.error(new Error,{code:"ValidationError",message:"Hostname label length should be between 1 to 63 characters, inclusive."});if(!i.test(e))throw r.util.error(new Error,{code:"ValidationError",message:e+" is not hostname compatible."})}))}return e}}},{"../core":18,"../util":71}],46:[function(e,t,n){var o=e("../util"),r=e("../json/builder"),i=e("../json/parser"),s=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.httpRequest,n=e.service.api,o=n.targetPrefix+"."+n.operations[e.operation].name,i=n.jsonVersion||"1.0",c=n.operations[e.operation].input,a=new r;1===i&&(i="1.0"),t.body=a.build(e.params||{},c),t.headers["Content-Type"]="application/x-amz-json-"+i,t.headers["X-Amz-Target"]=o,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 r=JSON.parse(n.body.toString());(r.__type||r.code)&&(t.code=(r.__type||r.code).split("#").pop()),"RequestEntityTooLarge"===t.code?t.message="Request body must be less than 1 MB":t.message=r.message||r.Message||null}catch(r){t.statusCode=n.statusCode,t.message=n.statusMessage}else t.statusCode=n.statusCode,t.message=n.statusCode.toString();e.error=o.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||{},o=new i;e.data=o.parse(t,n)}}}},{"../json/builder":36,"../json/parser":37,"../util":71,"./helpers":45}],47:[function(e,t,n){var o=e("../core"),r=e("../util"),i=e("../query/query_param_serializer"),s=e("../model/shape"),c=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=r.queryParamsToString(n.params),c(e)},extractError:function(e){var t,n=e.httpResponse.body.toString();if(n.match("=0?"&":"?";var a=[];o.arrayEach(Object.keys(s).sort(),(function(e){Array.isArray(s[e])||(s[e]=[s[e]]);for(var t=0;t0){var p=(t=new o.XML.Parser).parse(s.toString(),a);r.update(e.data,p)}}}},{"../core":18,"../util":71,"./rest":48}],51:[function(e,t,n){var o=e("../util");function r(){}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,r){o.each(n.members,(function(n,o){var s=t[n];if(null!=s){var a=i(o);c(a=e?e+"."+a:a,s,o,r)}}))}function c(e,t,n,r){null!=t&&("structure"===n.type?s(e,t,n,r):"list"===n.type?function(e,t,n,r){var s=n.member||{};0!==t.length?o.arrayEach(t,(function(t,o){var a="."+(o+1);if("ec2"===n.api.protocol)a+="";else if(n.flattened){if(s.name){var u=e.split(".");u.pop(),u.push(i(s)),e=u.join(".")}}else a="."+(s.name?s.name:"member")+a;c(e+a,t,s,r)})):r.call(this,e,null)}(e,t,n,r):"map"===n.type?function(e,t,n,r){var i=1;o.each(t,(function(t,o){var s=(n.flattened?".":".entry.")+i+++".",a=s+(n.key.name||"key"),u=s+(n.value.name||"value");c(e+a,t,n.key,r),c(e+u,o,n.value,r)}))}(e,t,n,r):r(e,n.toWireFormat(t).toString()))}r.prototype.serialize=function(e,t,n){s("",e,t,n)},t.exports=r},{"../util":71}],52:[function(e,t,n){t.exports={now:function(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}}},{}],53:[function(e,t,n){var o=e("./util"),r=e("./region_config_data.json");function i(e,t){o.each(t,(function(t,n){"globalEndpoint"!==t&&(void 0!==e.config[t]&&null!==e.config[t]||(e.config[t]=n))}))}t.exports=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),o=e.api.endpointPrefix;return[[t,o],[n,o],[t,"*"],[n,"*"],["*",o],["*","*"]].map((function(e){return e[0]&&e[1]?e.join("/"):null}))}(e),n=0;n=0){a=!0;var u=0}var l=function(){a&&u!==c?r.emit("error",n.util.error(new Error("Stream content length mismatch. Received "+u+" of "+c+" bytes."),{code:"StreamContentLengthMismatch"})):2===n.HttpClient.streamsApiVersion?r.end():r.emit("end")},p=s.httpResponse.createUnbufferedStream();if(2===n.HttpClient.streamsApiVersion)if(a){var h=new e.PassThrough;h._write=function(t){return t&&t.length&&(u+=t.length),e.PassThrough.prototype._write.apply(this,arguments)},h.on("end",l),r.on("error",(function(e){a=!1,p.unpipe(h),h.emit("end"),h.end()})),p.pipe(h).pipe(r,{end:!1})}else p.pipe(r);else a&&p.on("data",(function(e){e&&e.length&&(u+=e.length)})),p.on("data",(function(e){r.emit("data",e)})),p.on("end",l);p.on("error",(function(e){a=!1,r.emit("error",e)}))}})),r},emitEvent:function(e,t,o){"function"==typeof t&&(o=t,t=null),o||(o=function(){}),t||(t=this.eventParameters(e,this.response)),n.SequentialExecutor.prototype.emit.call(this,e,t,(function(e){e&&(this.response.error=e),o.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":18,"./state_machine":70,_process:86,jmespath:85}],56:[function(e,t,n){var o=e("./core"),r=o.util.inherit,i=e("jmespath");function s(e){var t=e.request._waiter,n=t.config.acceptors,o=!1,r="retry";n.forEach((function(n){if(!o){var i=t.matchers[n.matcher];i&&i(e,n.expected,n.argument)&&(o=!0,r=n.state)}})),!o&&e.error&&(r="failure"),"success"===r?t.setSuccess(e):t.setError(e,"retry"===r)}o.ResourceWaiter=r({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 o=i.search(e.data,n)}catch(e){return!1}return i.strictDeepEqual(o,t)},pathAll:function(e,t,n){try{var o=i.search(e.data,n)}catch(e){return!1}Array.isArray(o)||(o=[o]);var r=o.length;if(!r)return!1;for(var s=0;s-1&&n.splice(r,1)}return this},removeAllListeners:function(e){return e?delete this._events[e]:this._events={},this},emit:function(e,t,n){n||(n=function(){});var o=this.listeners(e),r=o.length;return this.callListeners(o,t,n),r>0},callListeners:function(e,t,n,r){var i=this,s=r||null;function c(r){if(r&&(s=o.util.error(s||new Error,r),i._haltHandlersOnError))return n.call(i,s);i.callListeners(e,t,n,s)}for(;e.length>0;){var a=e.shift();if(a._isAsync)return void a.apply(i,t.concat([c]));try{a.apply(i,t)}catch(e){s=o.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),o.util.each(e,(function(e,n){"function"==typeof n&&(n=[n]),o.util.arrayEach(n,(function(n){t.on(e,n)}))})),t},addNamedListener:function(e,t,n,o){return this[e]=n,this.addListener(t,n,o),this},addNamedAsyncListener:function(e,t,n,o){return n._isAsync=!0,this.addNamedListener(e,t,n,o)},addNamedListeners:function(e){var t=this;return e((function(){t.addNamedListener.apply(t,arguments)}),(function(){t.addNamedAsyncListener.apply(t,arguments)})),this}}),o.SequentialExecutor.prototype.addListener=o.SequentialExecutor.prototype.on,t.exports=o.SequentialExecutor},{"./core":18}],59:[function(e,t,n){(function(n){(function(){var o=e("./core"),i=e("./model/api"),s=e("./region_config"),c=o.util.inherit,a=0;o.Service=c({constructor:function(e){if(!this.loadServiceClass)throw o.util.error(new Error,"Service must be constructed with `new' operator");var t=this.loadServiceClass(e||{});if(t){var n=o.util.copy(e),r=new t(e);return Object.defineProperty(r,"_originalConfig",{get:function(){return n},enumerable:!1,configurable:!0}),r._clientId=++a,r}this.initialize(e)},initialize:function(e){var t=o.config[this.serviceIdentifier];if(this.config=new o.Config(o.config),t&&this.config.update(t,!0),e&&this.config.update(e,!0),this.validateService(),this.config.endpoint||s(this),this.config.endpoint=this.endpointFromTemplate(this.config.endpoint),this.setEndpoint(this.config.endpoint),o.SequentialExecutor.call(this),o.Service.addDefaultMonitoringListeners(this),(this.config.clientSideMonitoring||o.Service._clientSideMonitoring)&&this.publisher){var r=this.publisher;this.addNamedListener("PUBLISH_API_CALL","apiCall",(function(e){n.nextTick((function(){r.eventHandler(e)}))})),this.addNamedListener("PUBLISH_API_ATTEMPT","apiCallAttempt",(function(e){n.nextTick((function(){r.eventHandler(e)}))}))}},validateService:function(){},loadServiceClass:function(e){var t=e;if(o.util.isEmpty(this.api)){if(t.apiConfig)return o.Service.defineServiceApi(this.constructor,t.apiConfig);if(this.constructor.services){(t=new o.Config(o.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]&&o.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?o.util.isType(e,Date)&&(e=o.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,r=t.length-1;r>=0;r--)if("*"!==t[r][t[r].length-1]&&(n=t[r]),t[r].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 '"+r(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 r=this.api.operations[e];r&&(t=o.util.copy(t),o.util.each(this.config.params,(function(e,n){r.input.members[e]&&(void 0!==t[e]&&null!==t[e]||(t[e]=n))})))}var i=new o.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 o=this.makeRequest(e,t).toUnauthenticated();return n?o.send(n):o},waitFor:function(e,t,n){return new o.ResourceWaiter(this,e).wait(t,n)},addAllRequestListeners:function(e){for(var t=[o.events,o.EventListeners.Core,this.serviceInterface(),o.EventListeners.CorePost],n=0;n299?(r.code&&(n.FinalAwsException=r.code),r.message&&(n.FinalAwsExceptionMessage=r.message)):((r.code||r.name)&&(n.FinalSdkException=r.code||r.name),r.message&&(n.FinalSdkExceptionMessage=r.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()},o=e.response;return o.httpResponse.statusCode&&(n.HttpStatusCode=o.httpResponse.statusCode),!e._unAuthenticated&&e.service.config.credentials&&e.service.config.credentials.accessKeyId&&(n.AccessKey=e.service.config.credentials.accessKeyId),o.httpResponse.headers?(e.httpRequest.headers["x-amz-security-token"]&&(n.SessionToken=e.httpRequest.headers["x-amz-security-token"]),o.httpResponse.headers["x-amzn-requestid"]&&(n.XAmznRequestId=o.httpResponse.headers["x-amzn-requestid"]),o.httpResponse.headers["x-amz-request-id"]&&(n.XAmzRequestId=o.httpResponse.headers["x-amz-request-id"]),o.httpResponse.headers["x-amz-id-2"]&&(n.XAmzId2=o.httpResponse.headers["x-amz-id-2"]),n):n},attemptFailEvent:function(e){var t=this.apiAttemptEvent(e),n=e.response,o=n.error;return n.httpResponse.statusCode>299?(o.code&&(t.AwsException=o.code),o.message&&(t.AwsExceptionMessage=o.message)):((o.code||o.name)&&(t.SdkException=o.code||o.name),o.message&&(t.SdkExceptionMessage=o.message)),t},attachMonitoringEmitter:function(e){var t,n,r,i,s,c,a=0,u=this;e.on("validate",(function(){i=o.util.realClock.now(),c=Date.now()}),!0),e.on("sign",(function(){n=o.util.realClock.now(),t=Date.now(),s=e.httpRequest.region,a++}),!0),e.on("validateResponse",(function(){r=Math.round(o.util.realClock.now()-n)})),e.addNamedListener("API_CALL_ATTEMPT","success",(function(){var n=u.apiAttemptEvent(e);n.Timestamp=t,n.AttemptLatency=r>=0?r:0,n.Region=s,u.emit("apiCallAttempt",[n])})),e.addNamedListener("API_CALL_ATTEMPT_RETRY","retry",(function(){var i=u.attemptFailEvent(e);i.Timestamp=t,r=r||Math.round(o.util.realClock.now()-n),i.AttemptLatency=r>=0?r:0,i.Region=s,u.emit("apiCallAttempt",[i])})),e.addNamedListener("API_CALL","complete",(function(){var t=u.apiCallEvent(e);if(t.AttemptCount=a,!(t.AttemptCount<=0)){t.Timestamp=c;var n=Math.round(o.util.realClock.now()-i);t.Latency=n>=0?n:0;var r=e.response;"number"==typeof r.retryCount&&"number"==typeof r.maxRetries&&r.retryCount>=r.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t])}}))},setupRequestListeners:function(e){},getSignerClass:function(e){var t,n=null,r="";return e&&(r=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:""),t=this.config.signatureVersion?this.config.signatureVersion:"v4"===r||"v4-unsigned-body"===r?"v4":this.api.signatureVersion,o.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return o.EventListeners.Query;case"json":return o.EventListeners.Json;case"rest-json":return o.EventListeners.RestJson;case"rest-xml":return o.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){return o.util.calculateRetryDelay(e,this.config.retryDelayOptions)},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)>=3e4},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":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 o.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(!n){if(t){var r=new Error;throw o.util.error(r,"No pagination configuration for "+e)}return null}return n}}),o.util.update(o.Service,{defineMethods:function(e){o.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){o.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var r=c(o.Service,n||{});if("string"==typeof e){o.Service.addVersions(r,t);var i=r.serviceIdentifier||e;r.serviceIdentifier=i}else r.prototype.api=e,o.Service.defineMethods(r);if(o.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&o.util.clientSideMonitoring){var s=o.util.clientSideMonitoring.Publisher,a=(0,o.util.clientSideMonitoring.configProvider)();this.prototype.publisher=new s(a),a.enabled&&(o.Service._clientSideMonitoring=!0)}return o.SequentialExecutor.call(r.prototype),o.Service.addDefaultMonitoringListeners(r.prototype),r},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n=0))throw n.util.error(new Error,t);this.config.stsRegionalEndpoints=e.toLowerCase()},validateRegionalEndpointsFlag:function(){var e=this.config;if(e.stsRegionalEndpoints&&this.validateRegionalEndpointsFlagValue(e.stsRegionalEndpoints,{code:"InvalidConfiguration",message:'invalid "stsRegionalEndpoints" configuration. Expect "legacy" or "regional". Got "'+e.stsRegionalEndpoints+'".'}),n.util.isNode()){if(Object.prototype.hasOwnProperty.call(t.env,r)){var o=t.env[r];this.validateRegionalEndpointsFlagValue(o,{code:"InvalidEnvironmentalVariable",message:"invalid "+r+' environmental variable. Expect "legacy" or "regional". Got "'+t.env[r]+'".'})}var s={};try{s=n.util.getProfilesFromSharedConfig(n.util.iniLoader)[t.env.AWS_PROFILE||n.util.defaultProfile]}catch(e){}if(s&&Object.prototype.hasOwnProperty.call(s,i)){var c=s[i];this.validateRegionalEndpointsFlagValue(c,{code:"InvalidConfiguration",message:"invalid "+i+' profile config. Expect "legacy" or "regional". Got "'+s[i]+'".'})}}},optInRegionalEndpoint:function(){this.validateRegionalEndpointsFlag();var e=this.config;if("regional"===e.stsRegionalEndpoints){if(o(this),!this.isGlobalEndpoint)return;if(this.isGlobalEndpoint=!1,!e.region)throw n.util.error(new Error,{code:"ConfigError",message:"Missing region in config"});var t=e.endpoint.indexOf(".amazonaws.com");e.endpoint=e.endpoint.substring(0,t)+"."+e.region+e.endpoint.substring(t)}},validateService:function(){this.optInRegionalEndpoint()}})}).call(this)}).call(this,e("_process"))},{"../core":18,"../region_config":53,_process:86}],62:[function(e,t,n){var o=e("../core"),r=o.util.inherit,i="presigned-expires";function s(e){var t=e.httpRequest.headers[i],n=e.service.getSignerClass(e);if(delete e.httpRequest.headers["User-Agent"],delete e.httpRequest.headers["X-Amz-User-Agent"],n===o.Signers.V4){if(t>604800)throw o.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!==o.Signers.S3)throw o.util.error(new Error,{message:"Presigning only supports S3 or SigV4 signing.",code:"UnsupportedSigner",retryable:!1});var r=e.service?e.service.getSkewCorrectedDate():o.util.date.getDate();e.httpRequest.headers[i]=parseInt(o.util.date.unixTimestamp(r)+t,10).toString()}}function c(e){var t=e.httpRequest.endpoint,n=o.util.urlParse(e.httpRequest.path),r={};n.search&&(r=o.util.queryStringParse(n.search.substr(1)));var s=e.httpRequest.headers.Authorization.split(" ");if("AWS"===s[0])s=s[1].split(":"),r.AWSAccessKeyId=s[0],r.Signature=s[1],o.util.each(e.httpRequest.headers,(function(e,t){e===i&&(e="Expires"),0===e.indexOf("x-amz-meta-")&&(delete r[e],e=e.toLowerCase()),r[e]=t})),delete e.httpRequest.headers[i],delete r.Authorization,delete r.Host;else if("AWS4-HMAC-SHA256"===s[0]){s.shift();var c=s.join(" ").match(/Signature=(.*?)(?:,|\s|\r?\n|$)/)[1];r["X-Amz-Signature"]=c,delete r.Expires}t.pathname=n.pathname,t.search=o.util.queryParamsToString(r)}o.Signers.Presign=r({sign:function(e,t,n){if(e.httpRequest.headers[i]=t||3600,e.on("build",s),e.on("sign",c),e.removeListener("afterBuild",o.EventListeners.Core.SET_CONTENT_LENGTH),e.removeListener("afterBuild",o.EventListeners.Core.COMPUTE_SHA256),e.emit("beforePresign",[e]),!n){if(e.build(),e.response.error)throw e.response.error;return o.util.urlFormat(e.httpRequest.endpoint)}e.build((function(){this.response.error?n(this.response.error):n(null,o.util.urlFormat(e.httpRequest.endpoint))}))}}),t.exports=o.Signers.Presign},{"../core":18}],63:[function(e,t,n){var o=e("../core"),r=o.util.inherit;o.Signers.RequestSigner=r({constructor:function(e){this.request=e},setServiceClientId:function(e){this.serviceClientId=e},getServiceClientId:function(){return this.serviceClientId}}),o.Signers.RequestSigner.getVersion=function(e){switch(e){case"v2":return o.Signers.V2;case"v3":return o.Signers.V3;case"s3v4":case"v4":return o.Signers.V4;case"s3":return o.Signers.S3;case"v3https":return o.Signers.V3Https}throw new Error("Unknown signing version "+e)},e("./v2"),e("./v3"),e("./v3https"),e("./v4"),e("./s3"),e("./presign")},{"../core":18,"./presign":62,"./s3":64,"./v2":65,"./v3":66,"./v3https":67,"./v4":68}],64:[function(e,t,n){var o=e("../core"),r=o.util.inherit;o.Signers.S3=r(o.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"]=o.util.date.rfc822(t)),e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken);var n=this.sign(e.secretAccessKey,this.stringToSign()),r="AWS "+e.accessKeyId+":"+n;this.request.headers.Authorization=r},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=[];o.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+o.util.queryParamsToString(r)},authorization:function(e,t){var n=[],o=this.credentialString(t);return n.push(this.algorithm+" Credential="+e.accessKeyId+"/"+o),n.push("SignedHeaders="+this.signedHeaders()),n.push("Signature="+this.signature(e,t)),n.join(", ")},signature:function(e,t){var n=r.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return o.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=o.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=[];o.util.each.call(this,this.request.headers,(function(t,n){e.push([t,n])})),e.sort((function(e,t){return e[0].toLowerCase()50&&delete r[i.shift()]),d},emptyCache:function(){r={},i=[]}}},{"../core":18}],70:[function(e,t,n){function o(e,t){this.currentState=t||null,this.states=e||{}}o.prototype.runTo=function(e,t,n,o){"function"==typeof e&&(o=n,n=t,t=e,e=null);var r=this,i=r.states[r.currentState];i.fn.call(n||r,o,(function(o){if(o){if(!i.fail)return t?t.call(n,o):null;r.currentState=i.fail}else{if(!i.accept)return t?t.call(n):null;r.currentState=i.accept}if(r.currentState===e)return t?t.call(n,o):null;r.runTo(e,t,n,o)}))},o.prototype.addState=function(e,t,n,o){return"function"==typeof t?(o=t,t=null,n=null):"function"==typeof n&&(o=n,n=null),this.currentState||(this.currentState=e),this.states[e]={accept:t,fail:n,fn:o},this},t.exports=o},{}],71:[function(e,t,n){(function(n,o){(function(){var i,s={environment:"nodejs",engine:function(){if(s.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=s.environment,n="aws-sdk-"+t+"/"+e("./core").VERSION;return"nodejs"===t&&(n+=" "+s.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 s.arrayEach(e.split("/"),(function(e){t.push(s.uriEscape(e))})),t.join("/")},urlParse:function(e){return s.url.parse(e)},urlFormat:function(e){return s.url.format(e)},queryStringParse:function(e){return s.querystring.parse(e)},queryParamsToString:function(e){var t=[],n=s.uriEscape,o=Object.keys(e).sort();return s.arrayEach(o,(function(o){var r=e[o],i=n(o),c=i+"=";if(Array.isArray(r)){var a=[];s.arrayEach(r,(function(e){a.push(n(e))})),c=i+"="+a.sort().join("&"+i+"=")}else null!=r&&(c=i+"="+n(r));t.push(c)})),t.join("&")},readFileSync:function(t){return s.isBrowser()?null:e("fs").readFileSync(t,"utf-8")},base64:{encode:function(e){if("number"==typeof e)throw s.error(new Error("Cannot base64 encode number "+e));return null==e?e:s.buffer.toBuffer(e).toString("base64")},decode:function(e){if("number"==typeof e)throw s.error(new Error("Cannot base64 decode number "+e));return null==e?e:s.buffer.toBuffer(e,"base64")}},buffer:{toBuffer:function(e,t){return"function"==typeof s.Buffer.from&&s.Buffer.from!==Uint8Array.from?s.Buffer.from(e,t):new s.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 s.Buffer.alloc)return s.Buffer.alloc(e,t,n);var o=new s.Buffer(e);return void 0!==t&&"function"==typeof o.fill&&o.fill(t,void 0,void 0,n),o},toStream:function(e){s.Buffer.isBuffer(e)||(e=s.buffer.toBuffer(e));var t=new s.stream.Readable,n=0;return t._read=function(o){if(n>=e.length)return t.push(null);var r=n+o;r>e.length&&(r=e.length),t.push(e.slice(n,r)),n=r},t},concat:function(e){var t,n,o=0,r=0;for(n=0;n>>8^t[255&(n^e.readUInt8(o))];return(-1^n)>>>0},hmac:function(e,t,n,o){return n||(n="binary"),"buffer"===n&&(n=void 0),o||(o="sha256"),"string"==typeof t&&(t=s.buffer.toBuffer(t)),s.crypto.lib.createHmac(o,e).update(t).digest(n)},md5:function(e,t,n){return s.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return s.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,o){var i=s.crypto.createHash(e);n||(n="binary"),"buffer"===n&&(n=void 0),"string"==typeof t&&(t=s.buffer.toBuffer(t));var c=s.arraySliceFn(t),a=s.Buffer.isBuffer(t);if(s.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(a=!0),o&&"object"===r(t)&&"function"==typeof t.on&&!a)t.on("data",(function(e){i.update(e)})),t.on("error",(function(e){o(e)})),t.on("end",(function(){o(null,i.digest(n))}));else{if(!o||!c||a||"undefined"==typeof FileReader){s.isBrowser()&&"object"===r(t)&&!a&&(t=new s.Buffer(new Uint8Array(t)));var u=i.update(t).digest(n);return o&&o(null,u),u}var l=0,p=new FileReader;p.onerror=function(){o(new Error("Failed to read data."))},p.onload=function(){var e=new s.Buffer(new Uint8Array(p.result));i.update(e),l+=e.length,p._continueReading()},p._continueReading=function(){if(l>=t.size)o(null,i.digest(n));else{var e=l+524288;e>t.size&&(e=t.size),p.readAsArrayBuffer(c.call(t,l,e))}},p._continueReading()}},toHex:function(e){for(var t=[],n=0;n=3e5,!1),i.config.isClockSkewed},applyClockOffset:function(e){e&&(i.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&&i&&i.config&&(t=i.config.getPromisesDependency()),void 0===t&&"undefined"!=typeof Promise&&(t=Promise),"function"!=typeof t&&(n=!0),Array.isArray(e)||(e=[e]);for(var o=0;o=500||429===o});r&&i.retryable&&(i.retryAfter=r),a(i)}}))}),a)};i.util.defer(u)},uuid:{v4:function(){return e("uuid").v4()}},convertPayloadToString:function(e){var t=e.request,n=t.operation,o=t.service.api.operations[n].output||{};o.payload&&e.data[o.payload]&&(e.data[o.payload]=e.data[o.payload].toString())},defer:function(e){"object"===r(n)&&"function"==typeof n.nextTick?n.nextTick(e):"function"==typeof o?o(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 o={},r={};n.env[s.configOptInEnv]&&(r=e.loadFrom({isConfig:!0,filename:n.env[s.sharedConfigFileEnv]}));for(var i=e.loadFrom({filename:t||n.env[s.configOptInEnv]&&n.env[s.sharedCredentialsFileEnv]}),c=0,a=Object.keys(r);c0||o?i.toString():""},t.exports=s},{"../util":71,"./xml-node":76,"./xml-text":77}],74:[function(e,t,n){t.exports={escapeAttribute:function(e){return e.replace(/&/g,"&").replace(/'/g,"'").replace(//g,">").replace(/"/g,""")}}},{}],75:[function(e,t,n){t.exports={escapeElement:function(e){return e.replace(/&/g,"&").replace(//g,">")}}},{}],76:[function(e,t,n){var o=e("./escape-attribute").escapeAttribute;function r(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}r.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},r.prototype.addChildNode=function(e){return this.children.push(e),this},r.prototype.removeAttribute=function(e){return delete this.attributes[e],this},r.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,r=0,i=Object.keys(n);r"+this.children.map((function(e){return e.toString()})).join("")+"":"/>")},t.exports={XmlNode:r}},{"./escape-attribute":74}],77:[function(e,t,n){var o=e("./escape-element").escapeElement;function r(e){this.value=e}r.prototype.toString=function(){return o(""+this.value)},t.exports={XmlText:r}},{"./escape-element":75}],78:[function(e,t,n){"use strict";n.byteLength=function(e){var t=a(e),n=t[0],o=t[1];return 3*(n+o)/4-o},n.toByteArray=function(e){var t,n,o=a(e),s=o[0],c=o[1],u=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,c)),l=0,p=c>0?s-4:s;for(n=0;n>16&255,u[l++]=t>>8&255,u[l++]=255&t;return 2===c&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[l++]=255&t),1===c&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t),u},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,i=[],s=16383,c=0,a=n-r;ca?a:c+s));return 1===r?(t=e[n-1],i.push(o[t>>2]+o[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],i.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"=")),i.join("")};for(var o=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0;c<64;++c)o[c]=s[c],r[s.charCodeAt(c)]=c;function a(e){var t=e.length;if(t%4>0)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 u(e,t,n){for(var r,i,s=[],c=t;c>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},{}],79:[function(e,t,n){},{}],80:[function(e,t,i){(function(e){(function(){!function(s){var c="object"==r(i)&&i&&!i.nodeType&&i,a="object"==r(t)&&t&&!t.nodeType&&t,u="object"==r(e)&&e;u.global!==u&&u.window!==u&&u.self!==u||(s=u);var l,p,h=2147483647,d=36,f=1,g=26,m=38,v=700,y=72,E=128,S="-",b=/^xn--/,C=/[^\x20-\x7E]/,T=/[\x2E\u3002\uFF0E\uFF61]/g,I={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},A=d-f,_=Math.floor,w=String.fromCharCode;function R(e){throw RangeError(I[e])}function N(e,t){for(var n=e.length,o=[];n--;)o[n]=t(e[n]);return o}function k(e,t){var n=e.split("@"),o="";return n.length>1&&(o=n[0]+"@",e=n[1]),o+N((e=e.replace(T,".")).split("."),t).join(".")}function O(e){for(var t,n,o=[],r=0,i=e.length;r=55296&&t<=56319&&r65535&&(t+=w((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=w(e)})).join("")}function D(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,n){var o=0;for(e=n?_(e/v):e>>1,e+=_(e/t);e>A*g>>1;o+=d)e=_(e/A);return _(o+(A+1)*e/(e+m))}function x(e){var t,n,o,r,i,s,c,a,u,l,p,m=[],v=e.length,b=0,C=E,T=y;for((n=e.lastIndexOf(S))<0&&(n=0),o=0;o=128&&R("not-basic"),m.push(e.charCodeAt(o));for(r=n>0?n+1:0;r=v&&R("invalid-input"),((a=(p=e.charCodeAt(r++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:d)>=d||a>_((h-b)/s))&&R("overflow"),b+=a*s,!(a<(u=c<=T?f:c>=T+g?g:c-T));c+=d)s>_(h/(l=d-u))&&R("overflow"),s*=l;T=P(b-i,t=m.length+1,0==i),_(b/t)>h-C&&R("overflow"),C+=_(b/t),b%=t,m.splice(b++,0,C)}return L(m)}function M(e){var t,n,o,r,i,s,c,a,u,l,p,m,v,b,C,T=[];for(m=(e=O(e)).length,t=E,n=0,i=y,s=0;s=t&&p_((h-n)/(v=o+1))&&R("overflow"),n+=(c-t)*v,t=c,s=0;sh&&R("overflow"),p==t){for(a=n,u=d;!(a<(l=u<=i?f:u>=i+g?g:u-i));u+=d)C=a-l,b=d-l,T.push(w(D(l+C%b,0))),a=_(C/b);T.push(w(D(a,0))),i=P(n,v,o==r),n=0,++o}++n,++t}return T.join("")}if(l={version:"1.3.2",ucs2:{decode:O,encode:L},decode:x,encode:M,toASCII:function(e){return k(e,(function(e){return C.test(e)?"xn--"+M(e):e}))},toUnicode:function(e){return k(e,(function(e){return b.test(e)?x(e.slice(4).toLowerCase()):e}))}},"object"==r(n.amdO)&&n.amdO)void 0===(o=function(){return l}.call(i,n,i,t))||(t.exports=o);else if(c&&a)if(t.exports==c)a.exports=l;else for(p in l)l.hasOwnProperty(p)&&(c[p]=l[p]);else s.punycode=l}(this)}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],81:[function(e,t,o){(function(t,n){(function(){"use strict";var n=e("base64-js"),r=e("ieee754"),i=e("isarray");function s(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function c(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(a.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 o=!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(o)return j(e).length;t=(""+t).toLowerCase(),o=!0}}function g(e,t,n){var o=!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 k(this,t,n);case"utf8":case"utf-8":return _(this,t,n);case"ascii":return R(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return A(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function m(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function v(e,t,n,o,r){if(0===e.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=a.from(t,o)),a.isBuffer(t))return 0===t.length?-1:y(e,t,n,o,r);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,o,r){var i,s=1,c=e.length,a=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s=2,c/=2,a/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(r){var l=-1;for(i=n;ic&&(n=c-a),i=n;i>=0;i--){for(var p=!0,h=0;hr&&(o=r):o=r;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");o>i/2&&(o=i/2);for(var s=0;s>8,r=n%256,i.push(r),i.push(o);return i}(t,e.length-n),e,n,o)}function A(e,t,o){return 0===t&&o===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,o))}function _(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r239?4:u>223?3:u>191?2:1;if(r+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[r+1]))&&(a=(31&u)<<6|63&i)>127&&(l=a);break;case 3:i=e[r+1],s=e[r+2],128==(192&i)&&128==(192&s)&&(a=(15&u)<<12|(63&i)<<6|63&s)>2047&&(a<55296||a>57343)&&(l=a);break;case 4:i=e[r+1],s=e[r+2],c=e[r+3],128==(192&i)&&128==(192&s)&&128==(192&c)&&(a=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&c)>65535&&a<1114112&&(l=a)}null===l?(l=65533,p=1):l>65535&&(l-=65536,o.push(l>>>10&1023|55296),l=56320|1023&l),o.push(l),r+=p}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);for(var n="",o=0;o0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},a.prototype.compare=function(e,t,n,o,r){if(!a.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===o&&(o=0),void 0===r&&(r=this.length),t<0||n>e.length||o<0||r>this.length)throw new RangeError("out of range index");if(o>=r&&t>=n)return 0;if(o>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(r>>>=0)-(o>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),u=this.slice(o,r),l=e.slice(t,n),p=0;pr)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var i=!1;;)switch(o){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 C(this,e,t,n);case"base64":return T(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: "+o);o=(""+o).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function R(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;rr)&&(n=r);for(var i="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,n,o,r,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function P(e,t,n,o){t<0&&(t=65535+t+1);for(var r=0,i=Math.min(e.length-n,2);r>>8*(o?r:1-r)}function x(e,t,n,o){t<0&&(t=4294967295+t+1);for(var r=0,i=Math.min(e.length-n,4);r>>8*(o?r:3-r)&255}function M(e,t,n,o,r,i){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,o,i){return i||M(e,0,n,4),r.write(e,t,n,o,23,4),n+4}function q(e,t,n,o,i){return i||M(e,0,n,8),r.write(e,t,n,o,52,8),n+8}a.prototype.slice=function(e,t){var n,o=this.length;if((e=~~e)<0?(e+=o)<0&&(e=0):e>o&&(e=o),(t=void 0===t?o:~~t)<0?(t+=o)<0&&(t=0):t>o&&(t=o),t0&&(r*=256);)o+=this[e+--t]*r;return o},a.prototype.readUInt8=function(e,t){return t||L(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||L(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||L(e,2,this.length),this[e]<<8|this[e+1]},a.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]},a.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])},a.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var o=this[e],r=1,i=0;++i=(r*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||L(e,t,this.length);for(var o=t,r=1,i=this[e+--o];o>0&&(r*=256);)i+=this[e+--o]*r;return i>=(r*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return t||L(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.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},a.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},a.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},a.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]},a.prototype.readFloatLE=function(e,t){return t||L(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||L(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||L(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||L(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,o){e=+e,t|=0,n|=0,o||D(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+r]=e/i&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),a.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},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,4294967295,0),a.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},a.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);D(this,e,t,n,r-1,-r)}var i=0,s=1,c=0;for(this[t]=255&e;++i>0)-c&255;return t+n},a.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);D(this,e,t,n,r-1,-r)}var i=n-1,s=1,c=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===c&&0!==this[t+i+1]&&(c=1),this[t+i]=(e/s>>0)-c&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||D(this,e,t,4,2147483647,-2147483648),a.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},a.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),a.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},a.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,o){if(n||(n=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t=0;--r)e[r+t]=this[r+n];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(t-=3)>-1&&i.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&i.push(239,191,189);if(r=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(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,o){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}).call(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"base64-js":78,buffer:81,ieee754:83,isarray:84}],82:[function(e,t,n){function o(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function s(e){return"object"===r(e)&&null!==e}function c(e){return void 0===e}t.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0,o.defaultMaxListeners=10,o.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},o.prototype.emit=function(e){var t,n,o,r,a,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(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(c(n=this._events[e]))return!1;if(i(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:r=Array.prototype.slice.call(arguments,1),n.apply(this,r)}else if(s(n))for(r=Array.prototype.slice.call(arguments,1),o=(u=n.slice()).length,a=0;a0&&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},o.prototype.on=o.prototype.addListener,o.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=!1;function o(){this.removeListener(e,o),n||(n=!0,t.apply(this,arguments))}return o.listener=t,this.on(e,o),this},o.prototype.removeListener=function(e,t){var n,o,r,c;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=(n=this._events[e]).length,o=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(c=r;c-- >0;)if(n[c]===t||n[c].listener&&n[c].listener===t){o=c;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},o.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(i(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},o.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},o.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},o.listenerCount=function(e,t){return e.listenerCount(t)}},{}],83:[function(e,t,n){n.read=function(e,t,n,o,r){var i,s,c=8*r-o-1,a=(1<>1,l=-7,p=n?r-1:0,h=n?-1:1,d=e[t+p];for(p+=h,i=d&(1<<-l)-1,d>>=-l,l+=c;l>0;i=256*i+e[t+p],p+=h,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=o;l>0;s=256*s+e[t+p],p+=h,l-=8);if(0===i)i=1-u;else{if(i===a)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,o),i-=u}return(d?-1:1)*s*Math.pow(2,i-o)},n.write=function(e,t,n,o,r,i){var s,c,a,u=8*i-r-1,l=(1<>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=o?0:i-1,f=o?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+p>=1?h/a:h*Math.pow(2,1-p))*a>=2&&(s++,a/=2),s+p>=l?(c=0,s=l):s+p>=1?(c=(t*a-1)*Math.pow(2,r),s+=p):(c=t*Math.pow(2,p-1)*Math.pow(2,r),s=0));r>=8;e[n+d]=255&c,d+=f,c/=256,r-=8);for(s=s<0;e[n+d]=255&s,d+=f,s/=256,u-=8);e[n+d-f]|=128*g}},{}],84:[function(e,t,n){var o={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==o.call(e)}},{}],85:[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 o(e,r){if(e===r)return!0;if(Object.prototype.toString.call(e)!==Object.prototype.toString.call(r))return!1;if(!0===t(e)){if(e.length!==r.length)return!1;for(var i=0;i":!0,"=":!0,"!":!0},G={" ":!0,"\t":!0,"\n":!0};function z(e){return e>="0"&&e<="9"||"-"===e}function K(){}K.prototype={tokenize:function(e){var t,n,o,r,i=[];for(this._current=0;this._current="a"&&r<="z"||r>="A"&&r<="Z"||"_"===r)t=this._current,n=this._consumeUnquotedIdentifier(e),i.push({type:g,value:n,start:t});else if(void 0!==H[e[this._current]])i.push({type:H[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(z(e[this._current]))o=this._consumeNumber(e),i.push(o);else if("["===e[this._current])o=this._consumeLBracket(e),i.push(o);else if('"'===e[this._current])t=this._current,n=this._consumeQuotedIdentifier(e),i.push({type:m,value:n,start:t});else if("'"===e[this._current])t=this._current,n=this._consumeRawStringLiteral(e),i.push({type:V,value:n,start:t});else if("`"===e[this._current]){t=this._current;var s=this._consumeLiteral(e);i.push({type:V,value:s,start:t})}else if(void 0!==W[e[this._current]])i.push(this._consumeOperator(e));else if(void 0!==G[e[this._current]])this._current++;else if("&"===e[this._current])t=this._current,this._current++,"&"===e[this._current]?(this._current++,i.push({type:w,value:"&&",start:t})):i.push({type:I,value:"&",start:t});else{if("|"!==e[this._current]){var c=new Error("Unknown character:"+e[this._current]);throw c.name="LexerError",c}t=this._current,this._current++,"|"===e[this._current]?(this._current++,i.push({type:_,value:"||",start:t})):i.push({type:A,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:O,value:">=",start:t}):{type:N,value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:R,value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t,n=this._current,o=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 Y={};function X(){}function J(e){this.runtime=e}function Q(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[s]}]},avg:{_func:this._functionAvg,_signature:[{types:[h]}]},ceil:{_func:this._functionCeil,_signature:[{types:[s]}]},contains:{_func:this._functionContains,_signature:[{types:[a,u]},{types:[c]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[a]},{types:[a]}]},floor:{_func:this._functionFloor,_signature:[{types:[s]}]},length:{_func:this._functionLength,_signature:[{types:[a,u,l]}]},map:{_func:this._functionMap,_signature:[{types:[p]},{types:[u]}]},max:{_func:this._functionMax,_signature:[{types:[h,d]}]},merge:{_func:this._functionMerge,_signature:[{types:[l],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[u]},{types:[p]}]},sum:{_func:this._functionSum,_signature:[{types:[h]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[a]},{types:[a]}]},min:{_func:this._functionMin,_signature:[{types:[h,d]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[u]},{types:[p]}]},type:{_func:this._functionType,_signature:[{types:[c]}]},keys:{_func:this._functionKeys,_signature:[{types:[l]}]},values:{_func:this._functionValues,_signature:[{types:[l]}]},sort:{_func:this._functionSort,_signature:[{types:[d,h]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[u]},{types:[p]}]},join:{_func:this._functionJoin,_signature:[{types:[a]},{types:[d]}]},reverse:{_func:this._functionReverse,_signature:[{types:[a,u]}]},to_array:{_func:this._functionToArray,_signature:[{types:[c]}]},to_string:{_func:this._functionToString,_signature:[{types:[c]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[c]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[c],variadic:!0}]}}}Y[f]=0,Y[g]=0,Y[m]=0,Y[v]=0,Y[y]=0,Y[E]=0,Y[b]=0,Y[C]=0,Y[T]=0,Y[I]=0,Y[A]=1,Y[_]=2,Y[w]=3,Y[R]=5,Y[N]=5,Y[k]=5,Y[O]=5,Y[L]=5,Y[D]=5,Y[P]=9,Y[x]=20,Y[M]=21,Y[U]=40,Y[q]=45,Y[F]=50,Y[j]=55,Y[B]=60,X.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if(this._lookahead(0)!==f){var n=this._lookaheadToken(0),o=new Error("Unexpected token type: "+n.type+", value: "+n.value);throw o.name="ParserError",o}return t},_loadTokens:function(e){var t=(new K).tokenize(e);t.push({type:f,value:"",start:e.length}),this.tokens=t},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var n=this.nud(t),o=this._lookahead(0);e=0?this.expression(e):t===j?(this._match(j),this._parseMultiselectList()):t===F?(this._match(F),this._parseMultiselectHash()):void 0},_parseProjectionRHS:function(e){var t;if(Y[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===j)t=this.expression(e);else if(this._lookahead(0)===M)t=this.expression(e);else{if(this._lookahead(0)!==U){var n=this._lookaheadToken(0),o=new Error("Sytanx error, unexpected token: "+n.value+"("+n.type+")");throw o.name="ParserError",o}this._match(U),t=this._parseDotRHS(e)}return t},_parseMultiselectList:function(){for(var e=[];this._lookahead(0)!==v;){var t=this.expression(0);if(e.push(t),this._lookahead(0)===E&&(this._match(E),this._lookahead(0)===v))throw new Error("Unexpected token Rbracket")}return this._match(v),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e,t,n,o=[],r=[g,m];;){if(e=this._lookaheadToken(0),r.indexOf(e.type)<0)throw new Error("Expecting an identifier token, got: "+e.type);if(t=e.value,this._advance(),this._match(S),n={type:"KeyValuePair",name:t,value:this.expression(0)},o.push(n),this._lookahead(0)===E)this._match(E);else if(this._lookahead(0)===b){this._match(b);break}}return{type:"MultiSelectHash",children:o}}},J.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,i){var s,c,a,u,l,p,h,d,f;switch(e.type){case"Field":return null===i?null:n(i)?void 0===(p=i[e.name])?null:p:null;case"Subexpression":for(a=this.visit(e.children[0],i),f=1;f0)for(f=y;fE;f+=S)a.push(i[f]);return a;case"Projection":var b=this.visit(e.children[0],i);if(!t(b))return null;for(d=[],f=0;fl;break;case O:a=u>=l;break;case k:a=u=e&&(t=n<0?e-1:e),t}},Q.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 o,r,i,s;if(n[n.length-1].variadic){if(t.length=0;o--)n+=t[o];return n}var r=e[0].slice(0);return r.reverse(),r},_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],o=0;o=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,o=e[0],r=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],o=1;o0){if(this._getTypeName(e[0][0])===s)return Math.min.apply(Math,e[0]);for(var t=e[0],n=t[0],o=1;oc?1:sc&&(c=n,t=r[u]);return t},_functionMinBy:function(e){for(var t,n,o=e[1],r=e[0],i=this.createKeyFunction(o,[s,a]),c=1/0,u=0;u1)for(var n=1;n0&&u>a&&(u=a);for(var l=0;l=0?(p=g.substr(0,m),h=g.substr(m+1)):(p=g,h=""),d=decodeURIComponent(p),f=decodeURIComponent(h),o(s,d)?r(s[d])?s[d].push(f):s[d]=[s[d],f]:s[d]=f}return s};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],88:[function(e,t,n){"use strict";var o=function(e){switch(r(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"===r(e)?s(c(e),(function(r){var c=encodeURIComponent(o(r))+n;return i(e[r])?s(e[r],(function(e){return c+encodeURIComponent(o(e))})).join(t):c+encodeURIComponent(o(e[r]))})).join(t):a?encodeURIComponent(o(a))+n+encodeURIComponent(o(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function s(e,t){if(e.map)return e.map(t);for(var n=[],o=0;o0&&a>c&&(a=c);for(var u=0;u=0?(l=f.substr(0,g),p=f.substr(g+1)):(l=f,p=""),h=decodeURIComponent(l),d=decodeURIComponent(p),o(i,h)?Array.isArray(i[h])?i[h].push(d):i[h]=[i[h],d]:i[h]=d}return i}},{}],91:[function(e,t,n){"use strict";var o=function(e){switch(r(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,i){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"===r(e)?Object.keys(e).map((function(r){var i=encodeURIComponent(o(r))+n;return Array.isArray(e[r])?e[r].map((function(e){return i+encodeURIComponent(o(e))})).join(t):i+encodeURIComponent(o(e[r]))})).join(t):i?encodeURIComponent(o(i))+n+encodeURIComponent(o(e)):""}},{}],92:[function(e,t,n){arguments[4][89][0].apply(n,arguments)},{"./decode":90,"./encode":91,dup:89}],93:[function(e,t,n){(function(t,o){(function(){var r=e("process/browser.js").nextTick,i=Function.prototype.apply,s=Array.prototype.slice,c={},a=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=a++,o=!(arguments.length<2)&&s.call(arguments,1);return c[t]=!0,r((function(){c[t]&&(o?e.apply(null,o):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"==typeof o?o:function(e){delete c[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":86,timers:93}],94:[function(e,t,n){var o=e("punycode");function i(){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=y,n.resolve=function(e,t){return y(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?y(e,!1,!0).resolveObject(t):t},n.format=function(e){return E(e)&&(e=y(e)),e instanceof i?e.format():i.prototype.format.call(e)},n.Url=i;var s=/^([a-z0-9.+-]+:)/i,c=/:[0-9]*$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(a),l=["%","/","?",";","#"].concat(u),p=["/","?","#"],h=/^[a-z0-9A-Z_-]{0,63}$/,d=/^([a-z0-9A-Z_-]{0,63})(.*)$/,f={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function y(e,t,n){if(e&&S(e)&&e instanceof i)return e;var o=new i;return o.parse(e,t,n),o}function E(e){return"string"==typeof e}function S(e){return"object"===r(e)&&null!==e}function b(e){return null===e}i.prototype.parse=function(e,t,n){if(!E(e))throw new TypeError("Parameter 'url' must be a string, not "+r(e));var i=e;i=i.trim();var c=s.exec(i);if(c){var a=(c=c[0]).toLowerCase();this.protocol=a,i=i.substr(c.length)}if(n||c||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var y="//"===i.substr(0,2);!y||c&&g[c]||(i=i.substr(2),this.slashes=!0)}if(!g[c]&&(y||c&&!m[c])){for(var S,b,C=-1,T=0;T127?N+="x":N+=R[k];if(!N.match(h)){var L=_.slice(0,T),D=_.slice(T+1),P=R.match(d);P&&(L.push(P[1]),D.unshift(P[2])),D.length&&(i="/"+D.join(".")+i),this.hostname=L.join(".");break}}}if(this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),!A){var x=this.hostname.split("."),M=[];for(T=0;T0)&&n.host.split("@"))&&(n.auth=S.shift(),n.host=n.hostname=S.shift())),n.search=e.search,n.query=e.query,b(n.pathname)&&b(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 d=p.slice(-1)[0],f=(n.host||e.host)&&("."===d||".."===d)||""===d,v=0,y=p.length;y>=0;y--)"."==(d=p[y])?p.splice(y,1):".."===d?(p.splice(y,1),v++):v&&(p.splice(y,1),v--);if(!u&&!l)for(;v--;v)p.unshift("..");!u||""===p[0]||p[0]&&"/"===p[0].charAt(0)||p.unshift(""),f&&"/"!==p.join("/").substr(-1)&&p.push("");var S,C=""===p[0]||p[0]&&"/"===p[0].charAt(0);return h&&(n.hostname=n.host=C?"":p.length?p.shift():"",(S=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=S.shift(),n.host=n.hostname=S.shift())),(u=u||n.host&&p.length)&&!C&&p.unshift(""),p.length?n.pathname=p.join("/"):(n.pathname=null,n.path=null),b(n.pathname)&&b(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},i.prototype.parseHost=function(){var e=this.host,t=c.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{punycode:80,querystring:89}],95:[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}},{}],96:[function(e,t,n){t.exports=function(e){return e&&"object"===r(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],97:[function(e,t,o){(function(t,n){(function(){var i=/%[sdj%]/g;o.format=function(e){if(!y(e)){for(var t=[],n=0;n=r)return e;switch(e){case"%s":return String(o[n++]);case"%d":return Number(o[n++]);case"%j":try{return JSON.stringify(o[n++])}catch(e){return"[Circular]"}default:return e}})),c=o[n];n=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(t)?n.showHidden=t:t&&o._extend(n,t),E(n.showHidden)&&(n.showHidden=!1),E(n.depth)&&(n.depth=2),E(n.colors)&&(n.colors=!1),E(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),p(n,e,n.depth)}function u(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function l(e,t){return e}function p(e,t,n){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==o.inspect&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return y(r)||(r=p(e,r,n)),r}var i=function(e,t){if(E(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var s=Object.keys(t),c=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 h(t);if(0===s.length){if(I(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(S(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(C(t))return e.stylize(Date.prototype.toString.call(t),"date");if(T(t))return h(t)}var u,l="",b=!1,A=["{","}"];return f(t)&&(b=!0,A=["[","]"]),I(t)&&(l=" [Function"+(t.name?": "+t.name:"")+"]"),S(t)&&(l=" "+RegExp.prototype.toString.call(t)),C(t)&&(l=" "+Date.prototype.toUTCString.call(t)),T(t)&&(l=" "+h(t)),0!==s.length||b&&0!=t.length?n<0?S(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=b?function(e,t,n,o,r){for(var i=[],s=0,c=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(u,l,A)):A[0]+l+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,o,r,i){var s,c,a;if((a=Object.getOwnPropertyDescriptor(t,r)||{value:t[r]}).get?c=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(c=e.stylize("[Setter]","special")),R(o,r)||(s="["+r+"]"),c||(e.seen.indexOf(a.value)<0?(c=m(n)?p(e,a.value,null):p(e,a.value,n-1)).indexOf("\n")>-1&&(c=i?c.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+c.split("\n").map((function(e){return" "+e})).join("\n")):c=e.stylize("[Circular]","special")),E(s)){if(i&&r.match(/^\d+$/))return c;(s=JSON.stringify(""+r)).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+": "+c}function f(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function v(e){return"number"==typeof e}function y(e){return"string"==typeof e}function E(e){return void 0===e}function S(e){return b(e)&&"[object RegExp]"===A(e)}function b(e){return"object"===r(e)&&null!==e}function C(e){return b(e)&&"[object Date]"===A(e)}function T(e){return b(e)&&("[object Error]"===A(e)||e instanceof Error)}function I(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function _(e){return e<10?"0"+e.toString(10):e.toString(10)}o.debuglog=function(e){if(E(s)&&(s=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!c[e])if(new RegExp("\\b"+e+"\\b","i").test(s)){var n=t.pid;c[e]=function(){var t=o.format.apply(o,arguments);console.error("%s %d: %s",e,n,t)}}else c[e]=function(){};return c[e]},o.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"},o.isArray=f,o.isBoolean=g,o.isNull=m,o.isNullOrUndefined=function(e){return null==e},o.isNumber=v,o.isString=y,o.isSymbol=function(e){return"symbol"===r(e)},o.isUndefined=E,o.isRegExp=S,o.isObject=b,o.isDate=C,o.isError=T,o.isFunction=I,o.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===r(e)||void 0===e},o.isBuffer=e("./support/isBuffer");var w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}o.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[_(e.getHours()),_(e.getMinutes()),_(e.getSeconds())].join(":"),[e.getDate(),w[e.getMonth()],t].join(" ")),o.format.apply(o,arguments))},o.inherits=e("inherits"),o._extend=function(e,t){if(!t||!b(t))return e;for(var n=Object.keys(t),o=n.length;o--;)e[n[o]]=t[n[o]];return e}}).call(this)}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":96,_process:86,inherits:95}],98:[function(e,t,n){var o=e("./v1"),r=e("./v4"),i=r;i.v1=o,i.v4=r,t.exports=i},{"./v1":101,"./v4":102}],99:[function(e,t,n){for(var o=[],r=0;r<256;++r)o[r]=(r+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,r=o;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}},{}],100:[function(e,t,n){var o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(o){var r=new Uint8Array(16);t.exports=function(){return o(r),r}}else{var i=new Array(16);t.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},{}],101:[function(e,t,n){var o,r,i=e("./lib/rng"),s=e("./lib/bytesToUuid"),c=0,a=0;t.exports=function(e,t,n){var u=t&&n||0,l=t||[],p=(e=e||{}).node||o,h=void 0!==e.clockseq?e.clockseq:r;if(null==p||null==h){var d=i();null==p&&(p=o=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==h&&(h=r=16383&(d[6]<<8|d[7]))}var f=void 0!==e.msecs?e.msecs:(new Date).getTime(),g=void 0!==e.nsecs?e.nsecs:a+1,m=f-c+(g-a)/1e4;if(m<0&&void 0===e.clockseq&&(h=h+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,a=g,r=h;var v=(1e4*(268435455&(f+=122192928e5))+g)%4294967296;l[u++]=v>>>24&255,l[u++]=v>>>16&255,l[u++]=v>>>8&255,l[u++]=255&v;var y=f/4294967296*1e4&268435455;l[u++]=y>>>8&255,l[u++]=255&y,l[u++]=y>>>24&15|16,l[u++]=y>>>16&255,l[u++]=h>>>8|128,l[u++]=255&h;for(var E=0;E<6;++E)l[u+E]=p[E];return t||s(l)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],102:[function(e,t,n){var o=e("./lib/rng"),r=e("./lib/bytesToUuid");t.exports=function(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||o)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var c=0;c<16;++c)t[i+c]=s[c];return t||r(s)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],103:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e("./utils/LRU"),r=function(){function e(e){void 0===e&&(e=1e3),this.maxSize=e,this.cache=new o.LRUCache(e)}return Object.defineProperty(e.prototype,"size",{get:function(){return this.cache.length},enumerable:!0,configurable:!0}),e.prototype.put=function(t,n){var o="string"!=typeof t?e.getKeyString(t):t,r=this.populateValue(n);this.cache.put(o,r)},e.prototype.get=function(t){var n="string"!=typeof t?e.getKeyString(t):t,o=Date.now(),r=this.cache.get(n);if(r)for(var i=0;i{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect,connect.ClientMethods=connect.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"]),connect.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"},connect.MasterMethods=connect.makeEnum(["becomeMaster","checkMaster"]);var t=function(){};t.EMPTY_CALLBACKS={success:function(){},failure:function(){}},t.prototype.call=function(e,n,o){connect.assertNotNull(e,"method");var r=n||{},i=o||t.EMPTY_CALLBACKS;this._callImpl(e,r,i)},t.prototype._callImpl=function(e,t,n){throw new connect.NotImplementedError};var n=function(){t.call(this)};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype._callImpl=function(e,t,n){if(n&&n.failure){var o=connect.sprintf("No such method exists on NULL client: %s",e);n.failure(new connect.ValueError(o),{message:o})}};var o=function(e,n,o){t.call(this),this.conduit=e,this.requestEvent=n,this.responseEvent=o,this._requestIdCallbacksMap={},this.conduit.onUpstream(o,connect.hitch(this,this._handleResponse))};(o.prototype=Object.create(t.prototype)).constructor=o,o.prototype._callImpl=function(e,t,n){var o=connect.EventFactory.createRequest(this.requestEvent,e,t);this._requestIdCallbacksMap[o.requestId]=n,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 r=function(e){o.call(this,e,connect.EventType.API_REQUEST,connect.EventType.API_RESPONSE)};(r.prototype=Object.create(o.prototype)).constructor=r;var i=function(e){o.call(this,e,connect.EventType.MASTER_REQUEST,connect.EventType.MASTER_RESPONSE)};(i.prototype=Object.create(o.prototype)).constructor=i;var s=function(e,n,o){connect.assertNotNull(e,"authCookieName"),connect.assertNotNull(n,"authToken"),connect.assertNotNull(o,"endpoint"),t.call(this),this.endpointUrl=connect.getUrlWithProtocol(o),this.authToken=n,this.authCookieName=e};(s.prototype=Object.create(t.prototype)).constructor=s,s.prototype._callImpl=function(e,t,n){var o=this,r={};r[o.authCookieName]=o.authToken;var i={method:"post",body:JSON.stringify(t||{}),headers:{Accept:"application/json","Content-Type":"application/json","X-Amz-target":e,"X-Amz-Bearer":JSON.stringify(r)}};connect.fetch(o.endpointUrl,i).then((function(e){n.success(e)})).catch((function(e){var t=e.body.getReader(),o="",r=new TextDecoder;t.read().then((function i(s){var c=s.done,a=s.value;if(c){var u=JSON.parse(o);return u.status=e.status,void n.failure(u)}return o+=r.decode(a),t.read().then(i)}))}))};var c=function(e,n,o){connect.assertNotNull(e,"authToken"),connect.assertNotNull(n,"region"),t.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=n,this.authToken=e;var r=connect.getBaseUrl(),i=o||(r.includes(".awsapps.com")?r+"/connect/api":r+"/api"),s=new AWS.Endpoint(i);this.client=new AWS.Connect({endpoint:s})};(c.prototype=Object.create(t.prototype)).constructor=c,c.prototype._callImpl=function(e,t,n){var o=this,r=connect.getLog();if(connect.contains(this.client,e))t=this._translateParams(e,t),r.trace("AWSClient: --\x3e Calling operation '%s'",e).sendInternalLogToServer(),this.client[e](t).on("build",(function(e){e.httpRequest.headers["X-Amz-Bearer"]=o.authToken})).send((function(t,o){try{if(t){if(t.code===connect.CTIExceptions.UNAUTHORIZED_EXCEPTION)n.authFailure();else if(!n.accessDenied||t.code!==connect.CTIExceptions.ACCESS_DENIED_EXCEPTION&&403!==t.statusCode){var i={};i.type=t.code,i.message=t.message,i.stack=t.stack?t.stack.split("\n"):[],n.failure(i,o)}else n.accessDenied();r.trace("AWSClient: <-- Operation '%s' failed: %s",e,JSON.stringify(t)).sendInternalLogToServer()}else r.trace("AWSClient: <-- Operation '%s' succeeded.",e).withObject(o).sendInternalLogToServer(),n.success(o)}catch(t){connect.getLog().error("Failed to handle AWS API request for method %s",e).withException(t).sendInternalLogToServer()}}));else{var i=connect.sprintf("No such method exists on AWS client: %s",e);n.failure(new connect.ValueError(i),{message:i})}},c.prototype._requiresAuthenticationParam=function(e){return e!==connect.ClientMethods.COMPLETE_CONTACT&&e!==connect.ClientMethods.CLEAR_CONTACT&&e!==connect.ClientMethods.REJECT_CONTACT&&e!==connect.ClientMethods.CREATE_TASK_CONTACT},c.prototype._translateParams=function(e,t){switch(e){case connect.ClientMethods.UPDATE_AGENT_CONFIGURATION:t.configuration=this._translateAgentConfiguration(t.configuration);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS:t.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(t.softphoneStreamStatistics);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT:t.report=this._translateSoftphoneCallReport(t.report)}return this._requiresAuthenticationParam(e)&&(t.authentication={authToken:this.authToken}),t},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},connect.ClientBase=t,connect.NullClient=n,connect.UpstreamConduitClient=r,connect.UpstreamConduitMasterClient=i,connect.AWSClient=c,connect.AgentAppClient=s}()},531:()=>{function e(e,n){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,n){if(e){if("string"==typeof e)return t(e,n);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){o&&(e=o);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,c=!0,a=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return c=e.done,e},e:function(e){a=!0,s=e},f:function(){try{c||null==o.return||o.return()}finally{if(a)throw s}}}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n{!function(){connect=this.connect||{},this.connect=connect;var e="<>",t=connect.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","update_connected_ccps","outer_context_info","media_device_request","media_device_response"]),n=connect.makeNamespacedEnum("connect",["loginPopup","sendLogs","softphone","ringtone","metrics"]),o=connect.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"]),r=connect.makeNamespacedEnum("webSocket",["init_failure","connection_open","connection_close","connection_error","connection_gain","connection_lost","subscription_update","subscription_failure","all_message","send","subscribe"]),i=connect.makeNamespacedEnum("contact",["init","refresh","destroyed","incoming","pending","connecting","connected","missed","acw","view","ended","error","accepted"]),s=connect.makeNamespacedEnum("taskList",["activate_channel_with_view_type"]),c=connect.makeNamespacedEnum("task",["created"]),a=connect.makeNamespacedEnum("connection",["session_init","ready_to_start_session"]),u=connect.makeNamespacedEnum("configuration",["configure","set_speaker_device","set_microphone_device","set_ringer_device","speaker_device_changed","microphone_device_changed","ringer_device_changed"]),l=connect.makeNamespacedEnum("voiceId",["update_domain_id"]),p=function(){};p.createRequest=function(e,t,n){return{event:e,requestId:connect.randomId(),method:t,params:n}},p.createResponse=function(e,t,n,o){return{event:e,requestId:t.requestId,data:n,err:o||null}};var h=function(e,t,n){this.subMap=e,this.id=connect.randomId(),this.eventName=t,this.f=n};h.prototype.unsubscribe=function(){this.subMap.unsubscribe(this.eventName,this.id)};var d=function(){this.subIdMap={},this.subEventNameMap={}};d.prototype.subscribe=function(e,t){var n=new h(this,e,t);this.subIdMap[n.id]=n;var o=this.subEventNameMap[e]||[];return o.push(n),this.subEventNameMap[e]=o,n},d.prototype.unsubscribe=function(e,t){connect.contains(this.subEventNameMap,e)&&(this.subEventNameMap[e]=this.subEventNameMap[e].filter((function(e){return e.id!==t})),this.subEventNameMap[e].length<1&&delete this.subEventNameMap[e]),connect.contains(this.subIdMap,t)&&delete this.subIdMap[t]},d.prototype.getAllSubscriptions=function(){return connect.values(this.subEventNameMap).reduce((function(e,t){return e.concat(t)}),[])},d.prototype.getSubscriptions=function(e){return this.subEventNameMap[e]||[]};var f=function(e){var t=e||{};this.subMap=new d,this.logEvents=t.logEvents||!1};f.prototype.subscribe=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.subMap.subscribe(e,t)},f.prototype.subscribeAll=function(t){return connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.subMap.subscribe(e,t)},f.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},f.prototype.trigger=function(t,n){connect.assertNotNull(t,"eventName");var o=this,r=this.subMap.getSubscriptions(e),i=this.subMap.getSubscriptions(t);this.logEvents&&t!==connect.EventType.LOG&&t!==connect.EventType.MASTER_RESPONSE&&t!==connect.EventType.API_METRIC&&t!==connect.EventType.SERVER_BOUND_INTERNAL_LOG&&connect.getLog().trace("Publishing event: %s",t).sendInternalLogToServer(),t.startsWith(connect.ContactEvents.ACCEPTED)&&n&&n.contactId&&!(n instanceof connect.Contact)&&(n=new connect.Contact(n.contactId)),r.concat(i).forEach((function(e){try{e.f(n||null,t,o)}catch(e){connect.getLog().error("'%s' event handler failed.",t).withException(e).sendInternalLogToServer()}}))},f.prototype.bridge=function(){var e=this;return function(t,n){e.trigger(n,t)}},f.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach((function(e){e.unsubscribe()}))},connect.EventBus=f,connect.EventFactory=p,connect.EventType=t,connect.AgentEvents=o,connect.ConfigurationEvents=u,connect.ConnectionEvents=a,connect.ConnnectionEvents=a,connect.ContactEvents=i,connect.ChannelViewEvents=s,connect.TaskEvents=c,connect.VoiceIdEvents=l,connect.WebSocketEvents=r,connect.MasterTopics=n}()},42:()=>{function e(t){return e="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(t)}!function(t){var n={};function o(e){if(n[e])return n[e].exports;var r=n[e]={i:e,l:!1,exports:{}};return t[e].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=t,o.c=n,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,n){if(1&n&&(t=o(t)),8&n)return t;if(4&n&&"object"==e(t)&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)o.d(r,i,function(e){return t[e]}.bind(null,i));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=2)}([function(t,n,o){"use strict";var r=o(1),i="DEBUG",s="aws/subscribe",c="aws/heartbeat",a="disconnected";function u(t){return(u="function"==typeof Symbol&&"symbol"==e(Symbol.iterator)?function(t){return e(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)})(t)}var l={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return l.assertTrue(null!==e&&void 0!==u(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"!==u(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},p=new RegExp("^(wss://)\\w*");l.validWSUrl=function(e){return p.test(e)},l.getSubscriptionResponse=function(e,t,n){return{topic:e,content:{status:t?"success":"failure",topics:n}}},l.assertIsObject=function(e,t){if(!l.isObject(e))throw new Error(t+" is not an object!")},l.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)},l.isNetworkOnline=function(){return navigator.onLine},l.isNetworkFailure=function(e){return!(!e._debug||!e._debug.type)&&"NetworkingError"===e._debug.type};var h=l;function d(t){return(d="function"==typeof Symbol&&"symbol"==e(Symbol.iterator)?function(t){return e(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)})(t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(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||"";return this._logsDestination===i?this.consoleLoggerWrapper:new T(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||S.DEBUG,this._clientLogger=t.logger||null,this._logsDestination="NULL",t.debug&&(this._logsDestination=i),t.logger&&(this._logsDestination="CLIENT_LOGGER")}}]),e}(),C=function(){function e(){m(this,e)}return y(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),e}(),T=function(e){function t(e){var n;return m(this,t),(n=function(e,t){return!t||"object"!==d(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,f(t).call(this))).prefix=e||"",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&&g(e,t)}(t,C),y(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}}])&&_(t.prototype,n),e}();o.d(n,"a",(function(){return N}));var R=function(){var e=A.getLogger({}),t=h.isNetworkOnline(),n={primary:null,secondary:null},o={reconnectWebSocket:!0,websocketInitFailed:!1,exponentialBackOffTime:1e3,exponentialTimeoutHandle:null,lifeTimeTimeoutHandle:null,webSocketInitCheckerTimeoutId:null,connState:null},r={connectWebSocketRetryCount:0,connectionAttemptStartTime:null,noOpenConnectionsTimestamp:null},i={pendingResponse:!1,intervalHandle:null},u={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},l={connConfig:null,promiseHandle:null,promiseCompleted:!0},p={subscribed:new Set,pending:new Set,subscriptionHistory:new Set},d={responseCheckIntervalId:null,requestCompleted:!0,reSubscribeIntervalId:null,consecutiveFailedSubscribeAttempts:0,consecutiveNoResponseRequest:0},f=new w((function(){B()})),g=new Set([s,"aws/unsubscribe",c]),m=setInterval((function(){if(t!==h.isNetworkOnline()){if(!(t=h.isNetworkOnline()))return void W(e.info("Network offline"));var n=T();t&&(!n||S(n,WebSocket.CLOSING)||S(n,WebSocket.CLOSED))&&(W(e.info("Network online, connecting to WebSocket server")),B())}}),250),v=function(t,n){t.forEach((function(t){try{t(n)}catch(t){W(e.error("Error executing callback",t))}}))},y=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"}},E=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";W(e.debug("["+t+"] Primary WebSocket: "+y(n.primary)+" | Secondary WebSocket: "+y(n.secondary)))},S=function(e,t){return e&&e.readyState===t},b=function(e){return S(e,WebSocket.OPEN)},C=function(e){return null===e||void 0===e.readyState||S(e,WebSocket.CLOSED)},T=function(){return null!==n.secondary?n.secondary:n.primary},I=function(){return b(T())},_=function(){if(i.pendingResponse)return W(e.warn("Heartbeat response not received")),clearInterval(i.intervalHandle),i.pendingResponse=!1,void B();I()?(W(e.debug("Sending heartbeat")),T().send(F(c)),i.pendingResponse=!0):(W(e.warn("Failed to send heartbeat since WebSocket is not open")),E("sendHeartBeat"),B())},R=function(){o.exponentialBackOffTime=1e3,i.pendingResponse=!1,o.reconnectWebSocket=!0,clearTimeout(o.lifeTimeTimeoutHandle),clearInterval(i.intervalHandle),clearTimeout(o.exponentialTimeoutHandle),clearTimeout(o.webSocketInitCheckerTimeoutId)},N=function(){d.consecutiveFailedSubscribeAttempts=0,d.consecutiveNoResponseRequest=0,clearInterval(d.responseCheckIntervalId),clearInterval(d.reSubscribeIntervalId)},k=function(){r.connectWebSocketRetryCount=0,r.connectionAttemptStartTime=null,r.noOpenConnectionsTimestamp=null},O=function(){try{W(e.info("WebSocket connection established!")),E("webSocketOnOpen"),null!==o.connState&&o.connState!==a||v(u.connectionGain),o.connState="connected";var t=Date.now();v(u.connectionOpen,{connectWebSocketRetryCount:r.connectWebSocketRetryCount,connectionAttemptStartTime:r.connectionAttemptStartTime,noOpenConnectionsTimestamp:r.noOpenConnectionsTimestamp,connectionEstablishedTime:t,timeToConnect:t-r.connectionAttemptStartTime,timeWithoutConnection:r.noOpenConnectionsTimestamp?t-r.noOpenConnectionsTimestamp:null}),k(),R(),T().openTimestamp=Date.now(),0===p.subscribed.size&&b(n.secondary)&&x(n.primary,"[Primary WebSocket] Closing WebSocket"),(p.subscribed.size>0||p.pending.size>0)&&(b(n.secondary)&&W(e.info("Subscribing secondary websocket to topics of primary websocket")),p.subscribed.forEach((function(e){p.subscriptionHistory.add(e),p.pending.add(e)})),p.subscribed.clear(),P()),_(),i.intervalHandle=setInterval(_,1e4);var s=1e3*l.connConfig.webSocketTransport.transportLifeTimeInSeconds;W(e.debug("Scheduling WebSocket manager reconnection, after delay "+s+" ms")),o.lifeTimeTimeoutHandle=setTimeout((function(){W(e.debug("Starting scheduled WebSocket manager reconnection")),B()}),s)}catch(t){W(e.error("Error after establishing WebSocket connection",t))}},L=function(t){E("webSocketOnError"),W(e.error("WebSocketManager Error, error_event: ",JSON.stringify(t))),B()},D=function(t){var o=JSON.parse(t.data);switch(o.topic){case s:if(W(e.debug("Subscription Message received from webSocket server",t.data)),d.requestCompleted=!0,d.consecutiveNoResponseRequest=0,"success"===o.content.status)d.consecutiveFailedSubscribeAttempts=0,o.content.topics.forEach((function(e){p.subscriptionHistory.delete(e),p.pending.delete(e),p.subscribed.add(e)})),0===p.subscriptionHistory.size?b(n.secondary)&&(W(e.info("Successfully subscribed secondary websocket to all topics of primary websocket")),x(n.primary,"[Primary WebSocket] Closing WebSocket")):P(),v(u.subscriptionUpdate,o);else{if(clearInterval(d.reSubscribeIntervalId),++d.consecutiveFailedSubscribeAttempts,5===d.consecutiveFailedSubscribeAttempts)return v(u.subscriptionFailure,o),void(d.consecutiveFailedSubscribeAttempts=0);d.reSubscribeIntervalId=setInterval((function(){P()}),500)}break;case c:W(e.debug("Heartbeat response received")),i.pendingResponse=!1;break;default:if(o.topic){if(W(e.debug("Message received for topic "+o.topic)),b(n.primary)&&b(n.secondary)&&0===p.subscriptionHistory.size&&this===n.primary)return void W(e.warn("Ignoring Message for Topic "+o.topic+", to avoid duplicates"));if(0===u.allMessage.size&&0===u.topic.size)return void W(e.warn("No registered callback listener for Topic",o.topic));v(u.allMessage,o),u.topic.has(o.topic)&&v(u.topic.get(o.topic),o)}else o.message?W(e.warn("WebSocketManager Message Error",o)):W(e.warn("Invalid incoming message",o))}},P=function t(){if(d.consecutiveNoResponseRequest>3)return W(e.warn("Ignoring subscribePendingTopics since we have exhausted max subscription retries with no response")),void v(u.subscriptionFailure,h.getSubscriptionResponse(s,!1,Array.from(p.pending)));I()?(clearInterval(d.responseCheckIntervalId),T().send(F(s,{topics:Array.from(p.pending)})),d.requestCompleted=!1,d.responseCheckIntervalId=setInterval((function(){d.requestCompleted||(++d.consecutiveNoResponseRequest,t())}),1e3)):W(e.warn("Ignoring subscribePendingTopics call since Default WebSocket is not open"))},x=function(t,n){S(t,WebSocket.CONNECTING)||S(t,WebSocket.OPEN)?t.close(1e3,n):W(e.warn("Ignoring WebSocket Close request, WebSocket State: "+y(t)))},M=function(e){x(n.primary,"[Primary] WebSocket "+e),x(n.secondary,"[Secondary] WebSocket "+e)},U=function(){r.connectWebSocketRetryCount++;var t=h.addJitter(o.exponentialBackOffTime,.3);Date.now()+t<=l.connConfig.urlConnValidTime?(W(e.debug("Scheduling WebSocket reinitialization, after delay "+t+" ms")),o.exponentialTimeoutHandle=setTimeout((function(){return V()}),t),o.exponentialBackOffTime*=2):(W(e.warn("WebSocket URL cannot be used to establish connection")),B())},q=function(t){R(),N(),W(e.error("WebSocket Initialization failed")),o.websocketInitFailed=!0,M("Terminating WebSocket Manager"),clearInterval(m),v(u.initFailure,{connectWebSocketRetryCount:r.connectWebSocketRetryCount,connectionAttemptStartTime:r.connectionAttemptStartTime,reason:t}),k()},F=function(e,t){return JSON.stringify({topic:e,content:t})},j=function(t){return!!(h.isObject(t)&&h.isObject(t.webSocketTransport)&&h.isNonEmptyString(t.webSocketTransport.url)&&h.validWSUrl(t.webSocketTransport.url)&&1e3*t.webSocketTransport.transportLifeTimeInSeconds>=3e5)||(W(e.error("Invalid WebSocket Connection Configuration",t)),!1)},B=function(){if(h.isNetworkOnline())if(o.websocketInitFailed)W(e.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request"));else{if(l.promiseCompleted)return R(),W(e.info("Fetching new WebSocket connection configuration")),r.connectionAttemptStartTime=r.connectionAttemptStartTime||Date.now(),l.promiseCompleted=!1,l.promiseHandle=u.getWebSocketTransport(),l.promiseHandle.then((function(t){return l.promiseCompleted=!0,W(e.debug("Successfully fetched webSocket connection configuration",t)),j(t)?(l.connConfig=t,l.connConfig.urlConnValidTime=Date.now()+85e3,f.connected(),V()):(q("Invalid WebSocket connection configuration: "+t),{webSocketConnectionFailed:!0})}),(function(t){return l.promiseCompleted=!0,W(e.error("Failed to fetch webSocket connection configuration",t)),h.isNetworkFailure(t)?(W(e.info("Retrying fetching new WebSocket connection configuration")),f.retry()):q("Failed to fetch webSocket connection configuration: "+JSON.stringify(t)),{webSocketConnectionFailed:!0}}));W(e.debug("There is an ongoing getWebSocketConnConfig request, this request will be ignored"))}else W(e.info("Network offline, ignoring this getWebSocketConnConfig request"))},V=function(){if(o.websocketInitFailed)return W(e.info("web-socket initializing had failed, aborting re-init")),{webSocketConnectionFailed:!0};if(!h.isNetworkOnline())return W(e.warn("System is offline aborting web-socket init")),{webSocketConnectionFailed:!0};W(e.info("Initializing Websocket Manager")),E("initWebSocket");try{if(j(l.connConfig)){var t=null;return b(n.primary)?(W(e.debug("Primary Socket connection is already open")),S(n.secondary,WebSocket.CONNECTING)||(W(e.debug("Establishing a secondary web-socket connection")),n.secondary=H()),t=n.secondary):(S(n.primary,WebSocket.CONNECTING)||(W(e.debug("Establishing a primary web-socket connection")),n.primary=H()),t=n.primary),o.webSocketInitCheckerTimeoutId=setTimeout((function(){b(t)||U()}),1e3),{webSocketConnectionFailed:!1}}}catch(t){return W(e.error("Error Initializing web-socket-manager",t)),q("Failed to initialize new WebSocket: "+t.message),{webSocketConnectionFailed:!0}}},H=function(){var t=new WebSocket(l.connConfig.webSocketTransport.url);return t.addEventListener("open",O),t.addEventListener("message",D),t.addEventListener("error",L),t.addEventListener("close",(function(i){return function(t,i){W(e.info("Socket connection is closed",t)),E("webSocketOnClose before-cleanup"),v(u.connectionClose,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),C(n.primary)&&(n.primary=null),C(n.secondary)&&(n.secondary=null),o.reconnectWebSocket&&(b(n.primary)||b(n.secondary)?C(n.primary)&&b(n.secondary)&&(W(e.info("[Primary] WebSocket Cleanly Closed")),n.primary=n.secondary,n.secondary=null):(W(e.warn("Neither primary websocket and nor secondary websocket have open connections, attempting to re-establish connection")),o.connState===a?W(e.info("Ignoring connectionLost callback invocation")):(v(u.connectionLost,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),r.noOpenConnectionsTimestamp=Date.now()),o.connState=a,B()),E("webSocketOnClose after-cleanup"))}(i,t)})),t},W=function(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e};this.init=function(t){if(h.assertTrue(h.isFunction(t),"transportHandle must be a function"),null===u.getWebSocketTransport)return u.getWebSocketTransport=t,B();W(e.warn("Web Socket Manager was already initialized"))},this.onInitFailure=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.initFailure.add(e),o.websocketInitFailed&&e(),function(){return u.initFailure.delete(e)}},this.onConnectionOpen=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionOpen.add(e),function(){return u.connectionOpen.delete(e)}},this.onConnectionClose=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionClose.add(e),function(){return u.connectionClose.delete(e)}},this.onConnectionGain=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionGain.add(e),I()&&e(),function(){return u.connectionGain.delete(e)}},this.onConnectionLost=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.connectionLost.add(e),o.connState===a&&e(),function(){return u.connectionLost.delete(e)}},this.onSubscriptionUpdate=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.subscriptionUpdate.add(e),function(){return u.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.subscriptionFailure.add(e),function(){return u.subscriptionFailure.delete(e)}},this.onMessage=function(e,t){return h.assertNotNull(e,"topicName"),h.assertTrue(h.isFunction(t),"cb must be a function"),u.topic.has(e)?u.topic.get(e).add(t):u.topic.set(e,new Set([t])),function(){return u.topic.get(e).delete(t)}},this.onAllMessage=function(e){return h.assertTrue(h.isFunction(e),"cb must be a function"),u.allMessage.add(e),function(){return u.allMessage.delete(e)}},this.subscribeTopics=function(e){h.assertNotNull(e,"topics"),h.assertIsList(e),e.forEach((function(e){p.subscribed.has(e)||p.pending.add(e)})),d.consecutiveNoResponseRequest=0,P()},this.sendMessage=function(t){if(h.assertIsObject(t,"payload"),void 0===t.topic||g.has(t.topic))W(e.warn("Cannot send message, Invalid topic",t));else{try{t=JSON.stringify(t)}catch(n){return void W(e.warn("Error stringify message",t))}I()?T().send(t):W(e.warn("Cannot send message, web socket connection is not open"))}},this.closeWebSocket=function(){R(),N(),o.reconnectWebSocket=!1,clearInterval(m),M("User request to close WebSocket")},this.terminateWebSocketManager=q},N={create:function(){return new R},setGlobalConfig:function(e){var t=e.loggerConfig;A.updateLoggerConfig(t)},LogLevel:S,Logger:E}},function(t,n,o){var r;!function(){"use strict";var i={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 s(t){return function(t,n){var o,r,c,a,u,l,p,h,d,f=1,g=t.length,m="";for(r=0;r=0),a.type){case"b":o=parseInt(o,10).toString(2);break;case"c":o=String.fromCharCode(parseInt(o,10));break;case"d":case"i":o=parseInt(o,10);break;case"j":o=JSON.stringify(o,null,a.width?parseInt(a.width):0);break;case"e":o=a.precision?parseFloat(o).toExponential(a.precision):parseFloat(o).toExponential();break;case"f":o=a.precision?parseFloat(o).toFixed(a.precision):parseFloat(o);break;case"g":o=a.precision?String(Number(o.toPrecision(a.precision))):parseFloat(o);break;case"o":o=(parseInt(o,10)>>>0).toString(8);break;case"s":o=String(o),o=a.precision?o.substring(0,a.precision):o;break;case"t":o=String(!!o),o=a.precision?o.substring(0,a.precision):o;break;case"T":o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=a.precision?o.substring(0,a.precision):o;break;case"u":o=parseInt(o,10)>>>0;break;case"v":o=o.valueOf(),o=a.precision?o.substring(0,a.precision):o;break;case"x":o=(parseInt(o,10)>>>0).toString(16);break;case"X":o=(parseInt(o,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?m+=o:(!i.number.test(a.type)||h&&!a.sign?d="":(d=h?"+":"-",o=o.toString().replace(i.sign,"")),l=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",p=a.width-(d+o).length,u=a.width&&p>0?l.repeat(p):"",m+=a.align?d+o+u:"0"===l?d+u+o:u+d+o)}return m}(function(e){if(a[e])return a[e];for(var t,n=e,o=[],r=0;n;){if(null!==(t=i.text.exec(n)))o.push(t[0]);else if(null!==(t=i.modulo.exec(n)))o.push("%");else{if(null===(t=i.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){r|=1;var s=[],c=t[2],u=[];if(null===(u=i.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=i.key_access.exec(c)))s.push(u[1]);else{if(null===(u=i.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}t[2]=s}else r|=2;if(3===r)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");o.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]=o}(t),arguments)}function c(e,t){return s.apply(null,[e].concat(t||[]))}var a=Object.create(null);n.sprintf=s,n.vsprintf=c,"undefined"!=typeof window&&(window.sprintf=s,window.vsprintf=c,void 0===(r=function(){return{sprintf:s,vsprintf:c}}.call(n,o,n,t))||(t.exports=r))}()},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"WebSocketManager",(function(){return r}));var o=n(0);e.connect=e.connect||{},connect.WebSocketManager=o.a;var r=o.a}.call(this,n(3))},function(t,n){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch(t){"object"==("undefined"==typeof window?"undefined":e(window))&&(o=window)}t.exports=o}])},312:()=>{function e(t){return e="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(t)}!function(){var t=this;connect=t.connect||{},t.connect=connect,t.lily=connect;var n={TEST:"TEST",TRACE:"TRACE",DEBUG:"DEBUG",INFO:"INFO",LOG:"LOG",WARN:"WARN",ERROR:"ERROR",CRITICAL:"CRITICAL"},o={CCP:"ccp",SOFTPHONE:"softphone",CHAT:"chat",TASK:"task"},r={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,r=Array.prototype.slice.call(e,0),i=r.shift();return function(e){return-1!==Object.values(o).indexOf(e)}(i)?(n=i,t=r.shift()):(t=i,n=o.CCP),{format:t,component:n,args:r}},c=function(e,t,n,o){this.component=e,this.level=t,this.text=n,this.time=new Date,this.exception=null,this.objects=[],this.line=0,this.agentResourceId=null;try{connect.agent.initialized&&(this.agentResourceId=(new connect.Agent)._getResourceId())}catch(e){console.log("Issue finding agentResourceId: ",e)}this.loggerId=o};c.fromObject=function(e){var t=new c(o.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 a=function t(n){var o=/AuthToken.*\=/g;n&&"object"===e(n)&&Object.keys(n).forEach((function(r){"object"===e(n[r])?t(n[r]):"string"==typeof n[r]&&("url"===r||"text"===r?n[r]=n[r].replace(o,"[redacted]"):"quickConnectName"===r&&(n[r]="[redacted]"))}))},u=function(e){this.type=e instanceof Error?e.name:e.code||Object.prototype.toString.call(e),this.message=e.message,this.stack=e.stack?e.stack.split("\n"):[]};c.prototype.toString=function(){return connect.sprintf("[%s] [%s] [%s]: %s",this.getTime()&&this.getTime().toISOString?this.getTime().toISOString():"???",this.getLevel(),this.getAgentResourceId(),this.getText())},c.prototype.getTime=function(){return this.time},c.prototype.getAgentResourceId=function(){return this.agentResourceId},c.prototype.getLevel=function(){return this.level},c.prototype.getText=function(){return this.text},c.prototype.getComponent=function(){return this.component},c.prototype.withException=function(e){return this.exception=new u(e),this},c.prototype.withObject=function(e){var t=connect.deepcopy(e);return a(t),this.objects.push(t),this},c.prototype.withCrossOriginEventObject=function(e){var t=connect.deepcopyCrossOriginEvent(e);return a(t),this.objects.push(t),this},c.prototype.sendInternalLogToServer=function(){return connect.getLog()._serverBoundInternalLogs.push(this),this};var l=function(){this._logs=[],this._rolledLogs=[],this._logsToPush=[],this._serverBoundInternalLogs=[],this._echoLevel=r.INFO,this._logLevel=r.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(e){var n=this;this._logRollTimer&&e===this._logRollInterval?this.warn("Logger is already set to the given interval: %d",this._logRollInterval):(this._logRollTimer&&t.clearInterval(this._logRollTimer),this._logRollInterval=e,this._logRollTimer=t.setInterval((function(){this._rolledLogs=this._logs,this._logs=[],this._startLogIndexToPush=0,n.info("Log roll interval occurred.")}),this._logRollInterval))},l.prototype.setLogLevel=function(e){if(!(e in r))throw new Error("Unknown logging level: "+e);this._logLevel=r[e]},l.prototype.setEchoLevel=function(e){if(!(e in r))throw new Error("Unknown logging level: "+e);this._echoLevel=r[e]},l.prototype.write=function(e,t,n){var o=new c(e,t,n,this.getLoggerId());return a(o),this.addLogEntry(o),o},l.prototype.addLogEntry=function(e){a(e),this._logs.push(e),o.SOFTPHONE===e.component&&this._logsToPush.push(e),e.level in r&&r[e.level]>=this._logLevel&&(r[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 r&&r[e.level]>=this._logLevel&&(r[e.level]>=this._echoLevel&&i[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.clearObjects=function(){for(var e=0;e=s._logLevel})));var a=new t.Blob([JSON.stringify(c,void 0,4)],["text/plain"]),u=document.createElement("a");o=o||"agent-log",u.href=t.URL.createObjectURL(a),u.download=o+".txt",document.body.appendChild(u),u.click(),document.body.removeChild(u)},l.prototype.scheduleUpstreamLogPush=function(e){connect.upstreamLogPushScheduled||(connect.upstreamLogPushScheduled=!0,t.setInterval(connect.hitch(this,this.reportMasterLogsUpStream,e),5e3))},l.prototype.reportMasterLogsUpStream=function(e){var t=this._logsToPush.slice();this._logsToPush=[],connect.ifMaster(connect.MasterTopics.SEND_LOGS,(function(){t.length>0&&e.sendUpstream(connect.EventType.SEND_LOGS,t)}))},l.prototype.scheduleUpstreamOuterContextCCPserverBoundLogsPush=function(e){t.setInterval(connect.hitch(this,this.pushOuterContextCCPserverBoundLogsUpstream,e),1e3)},l.prototype.scheduleUpstreamOuterContextCCPLogsPush=function(e){t.setInterval(connect.hitch(this,this.pushOuterContextCCPLogsUpstream,e),1e3)},l.prototype.pushOuterContextCCPserverBoundLogsUpstream=function(e){if(this._serverBoundInternalLogs.length>0){for(var t=0;t500?e=this._serverBoundInternalLogs.splice(0,500):(e=this._serverBoundInternalLogs,this._serverBoundInternalLogs=[]),connect.publishClientSideLogs(e))};var p=function e(n){l.call(this),this.conduit=n,t.setInterval(connect.hitch(this,this._pushLogsDownstream),e.LOG_PUSH_INTERVAL),t.clearInterval(this._logRollTimer),this._logRollTimer=null};p.LOG_PUSH_INTERVAL=1e3,(p.prototype=Object.create(l.prototype)).constructor=p,p.prototype.pushLogsDownstream=function(e){var t=this;e.forEach((function(e){t.conduit.sendDownstream(connect.EventType.LOG,e)}))},p.prototype._pushLogsDownstream=function(){var e=this;this._logs.forEach((function(t){e.conduit.sendDownstream(connect.EventType.LOG,t)})),this._logs=[];for(var t=0;t{!function(){connect=this.connect||{},this.connect=connect,connect.ChatMediaController=function(e,t){var n=connect.getLog(),o=connect.LogComponent.CHAT,r=function(t,n){connect.publishMetric({name:t,contactId:e.contactId,data:n||e})},i=function(e){e.onConnectionBroken((function(e){n.error(o,"Chat Session connection broken").withException(e).sendInternalLogToServer(),r("Chat Session connection broken",e)})),e.onConnectionEstablished((function(e){n.info(o,"Chat Session connection established").withObject(e).sendInternalLogToServer(),r("Chat Session connection established",e)}))};return{get:function(){return function(){r("Chat media controller init",e.contactId),n.info(o,"Chat media controller init").withObject(e).sendInternalLogToServer(),connect.ChatSession.setGlobalConfig({loggerConfig:{logger:n},region:t.region});var s=connect.ChatSession.create({chatDetails:e,type:"AGENT",websocketManager:connect.core.getWebSocketManager()});return i(s),s.connect().then((function(t){return n.info(o,"Chat Session Successfully established for contactId %s",e.contactId).sendInternalLogToServer(),r("Chat Session Successfully established",e.contactId),s})).catch((function(t){throw n.error(o,"Chat Session establishement failed for contact %s",e.contactId).withException(t).sendInternalLogToServer(),r("Chat Session establishement failed",e.contactId,t),t}))}()}}}}()},7:()=>{!function(){connect=this.connect||{},this.connect=connect,connect.MediaFactory=function(e){var t={},n=new Set,o=connect.getLog(),r=connect.LogComponent.CHAT,i=connect.merge({},e)||{};i.region=i.region||"us-west-2";var s=function(e){t[e]&&!n.has(e)&&(o.info(r,"Destroying mediaController for %s",e),n.add(e),t[e].then((function(){"function"==typeof controller.cleanUp&&controller.cleanUp(),delete t[e],n.delete(e)})).catch((function(){delete t[e],n.delete(e)})))};return{get:function(e){return function(e){return e.isActive()}(e)?function(e){var n=e.getConnectionId();if(!e.getMediaInfo())return o.error(r,"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(t[n])return t[n];switch(o.info(r,"media controller of type %s init",e.getMediaType()).withObject(e).sendInternalLogToServer(),e.getMediaType()){case connect.MediaType.CHAT:return t[n]=new connect.ChatMediaController(e.getMediaInfo(),i).get();case connect.MediaType.SOFTPHONE:return t[n]=new connect.SoftphoneMediaController(e.getMediaInfo()).get();case connect.MediaType.TASK:return t[n]=new connect.TaskMediaController(e.getMediaInfo()).get();default:return o.error(r,"Unrecognized media type %s ",e.getMediaType()).sendInternalLogToServer(),Promise.reject()}}(e):(s(e.getConnectionId()),Promise.reject("Media Controller is no longer available for this connection"))},destroy:s}}}()},6:()=>{!function(){connect=this.connect||{},this.connect=connect,connect.SoftphoneMediaController=function(e){return{get:function(){return Promise.resolve(e)}}}}()},487:()=>{!function(){connect=this.connect||{},this.connect=connect,connect.TaskMediaController=function(e){var t=connect.getLog(),n=connect.LogComponent.TASK,o=function(t,n){connect.publishMetric({name:t,contactId:e.contactId,data:n||e})},r=function(e){e.onConnectionBroken((function(e){t.error(n,"Task Session connection broken").withException(e),o("Task Session connection broken",e)})),e.onConnectionEstablished((function(e){t.info(n,"Task Session connection established").withObject(e),o("Task Session connection established",e)}))};return{get:function(){return function(){o("Task media controller init",e.contactId),t.info(n,"Task media controller init").withObject(e);var i=connect.TaskSession.create({contactId:e.contactId,initialContactId:e.initialContactId,websocketManager:connect.core.getWebSocketManager()});return r(i),i.connect().then((function(){return t.info(n,"Task Session Successfully established for contactId %s",e.contactId),o("Task Session Successfully established",e.contactId),i})).catch((function(r){throw t.error(n,"Task Session establishement failed for contact %s",e.contactId).withException(r),o("Chat Session establishement failed",e.contactId,r),r}))}()}}}}()},743:()=>{function e(t){return e="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(t)}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function n(e){for(var n=1;n2&&void 0!==arguments[2]?arguments[2]:{};t.assertNotNull(e,"ccpUrl"),t.assertNotNull(o,"container"),a=o,c=e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.custom=e.custom||{},(s=n(n(n({},i),e),{},{custom:n(n({},i.custom),e.custom)})).canRequest=!("false"===s.canRequest||!1===s.canRequest)}(r),t.getLog().info("[StorageAccess][init] Request Storage Acccess init called with ccpUrl - ".concat(e," - ").concat(s.canRequest?"Proceeding with requesting storage access":"user has opted out, skipping request storage access")).withObject(s)},setupRequestHandlers:function(e){var n=e.onGrant;o&&o.unsubscribe(),o=v({onInit:function(e){console.log("%c[StorageAccess][INIT]","background:yellow; color:black; font-size:large"),t.getLog().info("[StorageAccess][onInit] callback executed").withObject(null==e?void 0:e.data),null!=e&&e.data.hasAccess||!h()||p().show()},onDeny:function(){console.log("%c[StorageAccess][DENIED]","background:red; color:black; font-size:large"),t.getLog().info("[StorageAccess][onDeny] callback executed"),h()&&p().show()},onGrant:function(){var e;console.log("%c[StorageAccess][GRANTED]","background:lime; color:black; font-size:large"),t.getLog().info("[StorageAccess][onGrant] callback executed"),h()&&(null===(e=s)||void 0===e||null===(e=e.custom)||void 0===e?void 0:e.hideCCP)&&p().hide(),u||(n(),u=!0)}})},getRequestStorageAccessUrl:function(){if(!c)throw new Error("[StorageAccess] [getRequestStorageAccessUrl] Invoke connect.storageAccess.init first");if(d(c))return f(c);if(g(c))return t.getLog().info("[StorageAccess] [CCP] Local testing"),"".concat(c).concat(r);if(s.instanceUrl&&d(s.instanceUrl))return t.getLog().info("[StorageAccess] [getRequestStorageAccessUrl] Customer has provided storageParams.instanceUrl ".concat(s.instanceUrl)),f(s.instanceUrl);if(s.instanceUrl&&g(s.instanceUrl))return t.getLog().info("[StorageAccess] [getRequestStorageAccessUrl] Local testing"),"".concat(s.instanceUrl).concat(r);throw t.getLog().error("[StorageAccess] [getRequestStorageAccessUrl] Invalid Connect instance/CCP URL provided, please pass the correct ccpUrl or storageAccess.instanceUrl parameters"),new Error("[StorageAccess] [getRequestStorageAccessUrl] Invalid Connect instance/CCP URL provided, please pass the valid Connect CCP URL or in case CCP URL is configured to be the SSO URL then use storageAccess.instanceUrl and pass the Connect CCP URL")},storageAccessEvents:l,resetStorageAccessState:function(){s={},c="",a=null,u=!1},getOnGrantCallbackInvoked:function(){return u},getStorageAccessParams:function(){return s},onRequest:v,request:function(){t.core._getCCPIframe().contentWindow.postMessage({event:l.REQUEST,data:n(n({},s),{},{landat:m()})},"*")}})}()},555:()=>{!function(){var e=this,t=e.connect||{};e.connect=t,e.lily=t;var n=function(n){var o=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,t){o._audio=new Audio(n.ringtoneUrl),o._audio.loop=!0,o._audio.addEventListener("canplay",(function(){o._audioPlayable=!0,e(o._audio)}))})):(this._audio=null,t.getLog().error("Unable to provide a ringtone.").sendInternalLogToServer()),o._driveRingtone()};n.prototype._driveRingtone=function(){throw new Error("Not implemented.")},n.prototype._startRingtone=function(e){this._audio&&(this._audio.play().catch((function(n){this._publishTelemetryEvent("Ringtone Playback Failure",e),t.getLog().error("Ringtone Playback Failure").sendInternalLogToServer()})),this._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 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.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 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.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=o,t.ChatRingtoneEngine=r,t.TaskRingtoneEngine=i,t.QueueCallbackRingtoneEngine=s}()},960:()=>{function e(t){return e="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(t)}!function(){var t=this;connect=t.connect||{},t.connect=connect,t.lily=connect,t.ccpVersion="V2";var n={};n[connect.SoftphoneCallType.AUDIO_ONLY]="Audio",n[connect.SoftphoneCallType.VIDEO_ONLY]="Video",n[connect.SoftphoneCallType.AUDIO_VIDEO]="AudioVideo",n[connect.SoftphoneCallType.NONE]="None";var o="audio_input",r="audio_output";({})[connect.ContactType.VOICE]="Voice";var i=[],s={},c={},a=null,u=null,l=null,p=connect.SoftphoneErrorTypes,h={},d=connect.randomId(),f=function(e){return new Promise((function(t,n){connect.core.getClient().call(connect.ClientMethods.CREATE_TRANSPORT,e,{success:function(e){t(e.softphoneTransport.softphoneMediaConnections)},failure:function(e){e.message&&e.message.includes("SoftphoneConnectionLimitBreachedException")&&_("multiple_softphone_active_sessions","Number of active sessions are more then allowed limit.",""),n(Error("requestIceAccess failed"))},authFailure:function(){n(Error("Authentication failed while requestIceAccess"))},accessDenied:function(){n(Error("Access Denied while requestIceAccess"))}})}))},g=function(e){var t=connect.core.getUpstream(),n=e.getAgentConnection();if(n){var o=n.getSoftphoneMediaInfo();o?!0===o.autoAccept?(l.info("Auto-accept is enabled, sending out Accepted event to stop ringtone..").sendInternalLogToServer(),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.ContactEvents.ACCEPTED,data:new connect.Contact(e.contactId)}),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.core.getContactEventName(connect.ContactEvents.ACCEPTED,e.contactId),data:new connect.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(){connect.core.getEventBus().subscribe(connect.EventType.MUTE,S)},v=function(){connect.core.getEventBus().subscribe(connect.ConfigurationEvents.SET_SPEAKER_DEVICE,b)},y=function(){connect.core.getEventBus().subscribe(connect.ConfigurationEvents.SET_MICROPHONE_DEVICE,C)},E=function(e){delete h[e],connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.MUTE_TOGGLE,data:{muted:!1}})},S=function(e){var t;if(0!==connect.keys(h).length){for(var n in e&&void 0!==e.mute&&(t=e.mute),h)if(h.hasOwnProperty(n)){var o=h[n].stream;if(o){var r=o.getAudioTracks()[0];void 0!==t?(r.enabled=!t,h[n].muted=t,t?l.info("Agent has muted the contact, connectionId - "+n).sendInternalLogToServer():l.info("Agent has unmuted the contact, connectionId - "+n).sendInternalLogToServer()):t=h[n].muted||!1}}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.MUTE_TOGGLE,data:{muted:t}})}},b=function(e){if(0!==connect.keys(h).length&&e&&e.deviceId){var t=e.deviceId,n=document.getElementById("remote-audio");try{l.info("Trying to set speaker to device "+t),n&&"function"==typeof n.setSinkId&&n.setSinkId(t)}catch(e){l.error("Failed to set speaker to device "+t)}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,data:{deviceId:t}})}},C=function(e){if(0!==connect.keys(h).length&&e&&e.deviceId){var t=e.deviceId,n=connect.core.getSoftphoneManager();try{navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:t}}}).then((function(e){var t=e.getAudioTracks()[0];for(var o in h)h.hasOwnProperty(o)&&(h[o].stream,n.getSession(o)._pc.getSenders()[0].replaceTrack(t).then((function(){n.replaceLocalMediaTrack(o,t)})))}))}catch(e){l.error("Failed to set microphone device "+t)}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,data:{deviceId:t}})}},T=function(e,t){if(t===connect.RTCErrors.ICE_COLLECTION_TIMEOUT){for(var n="\n",o=0;o0?n.success(e):n.failure(p.MICROPHONE_NOT_SHARED)}),(function(e){n.failure(p.MICROPHONE_NOT_SHARED)})),r}n.failure(p.UNSUPPORTED_BROWSER)},_=function(e,t,n){l.error("Softphone error occurred : ",e,t||"").sendInternalLogToServer(),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.SOFTPHONE_ERROR,data:new connect.SoftphoneError(e,t,n)})},w=function(e,t){R("Softphone Session Failed",e,{failedReason:t})},R=function(e,t,n){t&&connect.publishMetric({name:e,contactId:t,data:n})},N=function(e,t,n){R(e,t,[{name:"AgentConnectionId",value:n}]),l.info("Publish multiple session error metrics",e,"contactId "+t,"agent connectionId "+n).sendInternalLogToServer()},k=function(){return!!(connect.isOperaBrowser()&&connect.getOperaBrowserVersion()>17)||!!(connect.isChromeBrowser()&&connect.getChromeBrowserVersion()>22)||!!(connect.isFirefoxBrowser()&&connect.getFirefoxBrowserVersion()>21)},O=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()}})},L=function(e){a=window.setInterval((function(){e.getUserAudioStats().then((function(e){var t=s;s=e,i.push(x(s,t,o))}),(function(e){l.debug("Failed to get user audio stats.",e).sendInternalLogToServer()})),e.getRemoteAudioStats().then((function(e){var t=c;c=e,i.push(x(c,t,r))}),(function(e){l.debug("Failed to get remote audio stats.",e).sendInternalLogToServer()}))}),1e3)},D=function(e){u=window.setInterval((function(){O(e)}),3e4)},P=function(){s=null,c=null,i=[],a=null,u=null},x=function(e,t,n){if(t&&e){var o=e.packetsLost>t.packetsLost?e.packetsLost-t.packetsLost:0,r=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new q(e.timestamp,o,r,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new q(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},M=function(e){return null!==e&&window.clearInterval(e),null},U=function(e,t){a=M(a),u=M(u),function(e,t,n,i){t.streamStats=[F(n,o),F(i,r)];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,F(s,o),F(c,r)),O(e)},q=function(e,t,n,o,r,i,s){this.softphoneStreamType=o,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=r,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},F=function(e,t){return new q((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},j=function(e){this._originalLogger=e;var t=this;this._tee=function(e,n){return function(){var e=Array.prototype.slice.call(arguments[0]),o="";return e.forEach((function(){o+=" %s"})),n.apply(t._originalLogger,[connect.LogComponent.SOFTPHONE,o].concat(e))}}};j.prototype.debug=function(){return this._tee(1,this._originalLogger.debug)(arguments)},j.prototype.info=function(){return this._tee(2,this._originalLogger.info)(arguments)},j.prototype.log=function(){return this._tee(3,this._originalLogger.log)(arguments)},j.prototype.warn=function(){return this._tee(4,this._originalLogger.warn)(arguments)},j.prototype.error=function(){return this._tee(5,this._originalLogger.error)(arguments)},connect.SoftphoneManager=function(e){var t,n=this;(l=new j(connect.getLog())).info("[Softphone Manager] softphone manager initialization has begun").sendInternalLogToServer(),connect.RtcPeerConnectionFactory&&(t=new connect.RtcPeerConnectionFactory(l,connect.core.getWebSocketManager(),d,connect.hitch(n,f,{transportType:"softphone",softphoneClientId:d}),connect.hitch(n,_))),k()||_(p.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ",""),A({success:function(e){connect.core.setSoftphoneUserMediaStream(e)},failure:function(e){_(e,"Your microphone is not enabled in your browser. ","")}}),m(),v(),y(),this.ringtoneEngine=null;var o={},r={};this.onInitContactSub={},this.onInitContactSub.unsubscribe=function(){};var i=!1,s=null,c=null,a=function(){i=!1,s=null,c=null};this.getSession=function(e){return o[e]},this.replaceLocalMediaTrack=function(e,t){var n=h[e].stream;if(n){var o=n.getAudioTracks()[0];t.enabled=o.enabled,o.enabled=!1,n.removeTrack(o),n.addTrack(t)}};var u=function(e){if(o.hasOwnProperty(e)){var t=o[e];new Promise((function(n,i){delete o[e],delete r[e],t.hangup()})).catch((function(t){lily.getLog().warn("Clean up the session locally "+e,t.message).sendInternalLogToServer()}))}};this.startSession=function(e,n){var p=i?s:e,d=i?c:n;if(p&&d){a(),r[d]=!0,l.info("Softphone call detected:","contactId "+p.getContactId(),"agent connectionId "+d).sendInternalLogToServer(),function(e){if(Object.keys(e).length>0){for(var t in e)e.hasOwnProperty(t)&&(N("MultiSessionHangUp",e[t].callId,t),u(t));throw new Error("duplicate session detected, refusing to setup new connection")}}(o),p.getStatus().type===connect.ContactStatusType.CONNECTING&&R("Softphone Connecting",p.getContactId()),P();var f,m=p.getAgentConnection().getSoftphoneMediaInfo(),v=I(m.callConfigJson);v.useWebSocketProvider&&(f=connect.core.getWebSocketManager());var y=new connect.RTCSession(v.signalingEndpoint,v.iceServers,m.callContextToken,l,p.getContactId(),d,f);o[d]=y,connect.core.getSoftphoneUserMediaStream()&&(y.mediaStream=connect.core.getSoftphoneUserMediaStream()),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConnectionEvents.SESSION_INIT,data:{connectionId:d}}),y.onSessionFailed=function(e,t){delete o[d],delete r[d],T(e,t),w(p.getContactId(),t),U(p,e.sessionReport)},y.onSessionConnected=function(e){R("Softphone Session Connected",p.getContactId()),connect.becomeMaster(connect.MasterTopics.SEND_LOGS),L(e),D(p),g(p)},y.onSessionCompleted=function(e){R("Softphone Session Completed",p.getContactId()),delete o[d],delete r[d],U(p,e.sessionReport),E(d)},y.onLocalStreamAdded=function(e,t){h[d]={stream:t},connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,data:{connectionId:d}})},y.remoteAudioElement=document.getElementById("remote-audio"),t?y.connect(t.get(v.iceServers)):y.connect()}};var S=function(e,t){o[t]&&function(e){return e.getStatus().type===connect.ContactStatusType.ENDED||e.getStatus().type===connect.ContactStatusType.ERROR||e.getStatus().type===connect.ContactStatusType.MISSED}(e)&&(u(t),a()),!e.isSoftphoneCall()||r[t]||e.getStatus().type!==connect.ContactStatusType.CONNECTING&&e.getStatus().type!==connect.ContactStatusType.INCOMING||(connect.isFirefoxBrowser()&&connect.hasOtherConnectedCCPs()?function(e,t){i=!0,s=e,c=t}(e,t):n.startSession(e,t))},b=function(e){var t=e.getAgentConnection().connectionId;l.info("Contact detected:","contactId "+e.getContactId(),"agent connectionId "+t).sendInternalLogToServer(),r[t]||e.onRefresh((function(){S(e,t)}))};n.onInitContactSub=connect.contact(b),(new connect.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(),b(e),S(e,t)}))}}()},778:()=>{!function(){var e=function e(){return e.cache.hasOwnProperty(arguments[0])||(e.cache[arguments[0]]=e.parse(arguments[0])),e.format.call(null,e.cache[arguments[0]],arguments)};function t(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function n(e,t){for(var n=[];t>0;n[--t]=e);return n.join("")}e.format=function(o,r){var i,s,c,a,u,l,p,h=1,d=o.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(a[8])&&a[3]&&i>=0?"+"+i:i,l=a[4]?"0"==a[4]?"0":a[4].charAt(1):" ",p=a[6]-String(i).length,u=a[6]?n(l,p):"",g.push(a[5]?i+u:u+i)}return g.join("")},e.cache={},e.parse=function(e){for(var t=e,n=[],o=[],r=0;t;){if(null!==(n=/^[^\x25]+/.exec(t)))o.push(n[0]);else if(null!==(n=/^\x25{2}/.exec(t)))o.push("%");else{if(null===(n=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t)))throw"[sprintf] huh?";if(n[2]){r|=1;var i=[],s=n[2],c=[];if(null===(c=/^([a-z_][a-z_\d]*)/i.exec(s)))throw"[sprintf] huh?";for(i.push(c[1]);""!==(s=s.substring(c[0].length));)if(null!==(c=/^\.([a-z_][a-z_\d]*)/i.exec(s)))i.push(c[1]);else{if(null===(c=/^\[(\d+)\]/.exec(s)))throw"[sprintf] huh?";i.push(c[1])}n[2]=i}else r|=2;if(3===r)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";o.push(n)}t=t.substring(n[0].length)}return o},this.sprintf=e,this.vsprintf=function(t,n,o){return(o=n.slice(0)).splice(0,0,t),e.apply(null,o)}}()},768:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect;var t=function(){};t.prototype.send=function(e){throw new connect.NotImplementedError},t.prototype.onMessage=function(e){throw new connect.NotImplementedError};var n=function(){t.call(this)};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype.onMessage=function(e){},n.prototype.send=function(e){};var o=function(e,n){t.call(this),this.window=e,this.domain=n||"*"};(o.prototype=Object.create(t.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 r=function(e,n,o){t.call(this),this.input=e,this.output=n,this.domain=o||"*"};(r.prototype=Object.create(t.prototype)).constructor=r,r.prototype.send=function(e){this.output.postMessage(e,this.domain)},r.prototype.onMessage=function(e){var t=this;this.input.addEventListener("message",(function(n){n.source===t.output&&e(n)}))};var i=function(e){t.call(this),this.port=e,this.id=connect.randomId()};(i.prototype=Object.create(t.prototype)).constructor=i,i.prototype.send=function(e){this.port.postMessage(e)},i.prototype.onMessage=function(e){this.port.addEventListener("message",e)},i.prototype.getId=function(){return this.id};var s=function(e){t.call(this),this.streamMap=e?connect.index(e,(function(e){return e.getId()})):{},this.messageListeners=[]};(s.prototype=Object.create(t.prototype)).constructor=s,s.prototype.send=function(e){this.getStreams().forEach((function(t){try{t.send(e)}catch(e){}}))},s.prototype.onMessage=function(e){this.messageListeners.push(e),this.getStreams().forEach((function(t){t.onMessage(e)}))},s.prototype.addStream=function(e){this.streamMap[e.getId()]=e,this.messageListeners.forEach((function(t){e.onMessage(t)}))},s.prototype.removeStream=function(e){delete this.streamMap[e.getId()]},s.prototype.getStreams=function(e){return connect.values(this.streamMap)},s.prototype.getStreamForPort=function(e){return connect.find(this.getStreams(),(function(t){return t.port===e}))};var c=function(e,t,o){this.name=e,this.upstream=t||new n,this.downstream=o||new n,this.downstreamBus=new connect.EventBus,this.upstreamBus=new connect.EventBus,this.upstream.onMessage(connect.hitch(this,this._dispatchEvent,this.upstreamBus)),this.downstream.onMessage(connect.hitch(this,this._dispatchEvent,this.downstreamBus))};c.prototype.onUpstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.upstreamBus.subscribe(e,t)},c.prototype.onAllUpstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.upstreamBus.subscribeAll(e)},c.prototype.onDownstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.downstreamBus.subscribe(e,t)},c.prototype.onAllDownstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.downstreamBus.subscribeAll(e)},c.prototype.sendUpstream=function(e,t){connect.assertNotNull(e,"eventName"),this.upstream.send({event:e,data:t})},c.prototype.sendDownstream=function(e,t){connect.assertNotNull(e,"eventName"),this.downstream.send({event:e,data:t})},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 a=function(e,t,n,o){c.call(this,e,new r(t,n.contentWindow,o||"*"),null)};(a.prototype=Object.create(c.prototype)).constructor=a,connect.Stream=t,connect.NullStream=n,connect.WindowStream=o,connect.WindowIOStream=r,connect.PortStream=i,connect.StreamMultiplexer=s,connect.Conduit=c,connect.IFrameConduit=a}()},738:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect;var t=function(e,t){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),this.fromState=e,this.toState=t};t.prototype.getAssociations=function(e){throw connect.NotImplementedError()},t.prototype.getFromState=function(){return this.fromState},t.prototype.getToState=function(){return this.toState};var n=function(e,n,o){connect.assertNotNull(e,"fromState"),connect.assertNotNull(n,"toState"),connect.assertNotNull(o,"associations"),t.call(this,e,n),this.associations=o};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype.getAssociations=function(e){return this.associations};var o=function(e,n,o){connect.assertNotNull(e,"fromState"),connect.assertNotNull(n,"toState"),connect.assertNotNull(o,"closure"),connect.assertTrue(connect.isFunction(o),"closure must be a function"),t.call(this,e,n),this.closure=o};(o.prototype=Object.create(t.prototype)).constructor=o,o.prototype.getAssociations=function(e){return this.closure(e,this.getFromState(),this.getToState())};var r=function(){this.fromMap={}};r.ANY="<>",r.prototype.assoc=function(e,t,r){var i=this;if(!e)throw new Error("fromStateObj is not defined.");if(!t)throw new Error("toStateObj is not defined.");if(!r)throw new Error("assocObj is not defined.");return e instanceof Array?e.forEach((function(e){i.assoc(e,t,r)})):t instanceof Array?t.forEach((function(t){i.assoc(e,t,r)})):"function"==typeof r?this._addAssociation(new o(e,t,r)):r instanceof Array?this._addAssociation(new n(e,t,r)):this._addAssociation(new n(e,t,[r])),this},r.prototype.getAssociations=function(e,t,n){connect.assertNotNull(t,"fromState"),connect.assertNotNull(n,"toState");var o=[],i=this.fromMap[r.ANY]||{},s=this.fromMap[t]||{};return o=(o=o.concat(this._getAssociationsFromMap(i,e,t,n))).concat(this._getAssociationsFromMap(s,e,t,n))},r.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)},r.prototype._getAssociationsFromMap=function(e,t,n,o){return(e[r.ANY]||[]).concat(e[o]||[]).reduce((function(e,n){return e.concat(n.getAssociations(t))}),[])},connect.EventGraph=r}()},420:()=>{function e(t){return e="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(t)}!function(){var t=this;connect=t.connect||{},t.connect=connect,t.lily=connect;var n=navigator.userAgent,o=["bubbles","cancelBubble","cancelable","composed","data","defaultPrevented","eventPhase","isTrusted","lastEventId","origin","returnValue","timeStamp","type"];connect.sprintf=t.sprintf,connect.vsprintf=t.vsprintf,delete t.sprintf,delete t.vsprintf,connect.HTTP_STATUS_CODES={SUCCESS:200,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500},connect.TRANSPORT_TYPES={CHAT_TOKEN:"chat_token",WEB_SOCKET:"web_socket"},connect.hitch=function(){var e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift();return connect.assertNotNull(t,"scope"),connect.assertNotNull(n,"method"),connect.assertTrue(connect.isFunction(n),"method must be a function"),function(){var o=Array.prototype.slice.call(arguments);return n.apply(t,e.concat(o))}},connect.isFunction=function(e){return!!(e&&e.constructor&&e.call&&e.apply)},connect.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},connect.keys=function(e){var t=[];for(var n in connect.assertNotNull(e,"map"),e)t.push(n);return t},connect.values=function(e){var t=[];for(var n in connect.assertNotNull(e,"map"),e)t.push(e[n]);return t},connect.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},connect.merge=function(){var e=Array.prototype.slice.call(arguments,0),t={};return e.forEach((function(e){connect.entries(e).forEach((function(e){t[e.key]=e.value}))})),t},connect.now=function(){return(new Date).getTime()},connect.find=function(e,t){for(var n=0;n1},connect.fetch=function(e,t,n,o){return o=o||5,n=n||1e3,t=t||{},new Promise((function(r,i){!function o(s){fetch(e,t).then((function(e){e.status===connect.HTTP_STATUS_CODES.SUCCESS?e.json().then((function(e){return r(e)})).catch((function(){return r({})})):1!==s&&(e.status>=connect.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===connect.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout((function(){o(--s)}),n):i(e)})).catch((function(e){i(e)}))}(o)}))},connect.backoff=function(e,n,o,r){connect.assertTrue(connect.isFunction(e),"func must be a Function");var i=this;e({success:function(e){r&&r.success&&r.success(e)},failure:function(s,c){if(o>0){var a=2*n*Math.random();t.setTimeout((function(){i.backoff(e,2*a,--o,r)}),a)}else r&&r.failure&&r.failure(s,c)}})},connect.publishMetric=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.CLIENT_METRIC,data:e})},connect.publishSoftphoneStats=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.SOFTPHONE_STATS,data:e})},connect.publishSoftphoneReport=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.SOFTPHONE_REPORT,data:e})},connect.publishClientSideLogs=function(e){connect.core.getEventBus().trigger(connect.EventType.CLIENT_SIDE_LOGS,e)},connect.PopupManager=function(){},connect.PopupManager.prototype.open=function(e,t,n){var o=this._getLastOpenedTimestamp(t),r=(new Date).getTime(),i=null;if(r-o>864e5){if(n){var s=n.height||578,c=n.width||433,a=n.top||0,u=n.left||0;(i=window.open("",t,"width="+c+", height="+s+", top="+a+", left="+u)).location!==e&&(i=window.open(e,t,"width="+c+", height="+s+", top="+a+", left="+u))}else(i=window.open("",t)).location!==e&&(i=window.open(e,t));this._setLastOpenedTimestamp(t,r)}return i},connect.PopupManager.prototype.clear=function(e){var n=this._getLocalStorageKey(e);t.localStorage.removeItem(n)},connect.PopupManager.prototype._getLastOpenedTimestamp=function(e){var n=this._getLocalStorageKey(e),o=t.localStorage.getItem(n);return o?parseInt(o,10):0},connect.PopupManager.prototype._setLastOpenedTimestamp=function(e,n){var o=this._getLocalStorageKey(e);t.localStorage.setItem(o,""+n)},connect.PopupManager.prototype._getLocalStorageKey=function(e){return"connectPopupManager::"+e};var r=connect.makeEnum(["granted","denied","default"]);connect.NotificationManager=function(){this.queue=[],this.permission=r.DEFAULT},connect.NotificationManager.prototype.requestPermission=function(){var e=this;"Notification"in t?t.Notification.permission===r.DENIED?(connect.getLog().warn("The user has requested to not receive notifications.").sendInternalLogToServer(),this.permission=r.DENIED):this.permission!==r.GRANTED&&t.Notification.requestPermission().then((function(t){e.permission=t,t===r.GRANTED?e._showQueued():e.queue=[]})):(connect.getLog().warn("This browser doesn't support notifications.").sendInternalLogToServer(),this.permission=r.DENIED)},connect.NotificationManager.prototype.show=function(e,t){if(this.permission===r.GRANTED)return this._showImpl({title:e,options:t});if(this.permission===r.DENIED)connect.getLog().warn("Unable to show notification.").sendInternalLogToServer().withObject({title:e,options:t});else{var n={title:e,options:t};connect.getLog().warn("Deferring notification until user decides to allow or deny.").withObject(n).sendInternalLogToServer(),this.queue.push(n)}},connect.NotificationManager.prototype._showQueued=function(){var e=this,t=this.queue.map((function(t){return e._showImpl(t)}));return this.queue=[],t},connect.NotificationManager.prototype._showImpl=function(e){var n=new t.Notification(e.title,e.options);return e.options.clicked&&(n.onclick=function(){e.options.clicked.call(n)}),n},connect.BaseError=function(e,n){t.Error.call(this,connect.vsprintf(e,n))},connect.BaseError.prototype=Object.create(Error.prototype),connect.BaseError.prototype.constructor=connect.BaseError,connect.ValueError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift();connect.BaseError.call(this,t,e)},connect.ValueError.prototype=Object.create(connect.BaseError.prototype),connect.ValueError.prototype.constructor=connect.ValueError,connect.NotImplementedError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift();connect.BaseError.call(this,t,e)},connect.NotImplementedError.prototype=Object.create(connect.BaseError.prototype),connect.NotImplementedError.prototype.constructor=connect.NotImplementedError,connect.StateError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift();connect.BaseError.call(this,t,e)},connect.StateError.prototype=Object.create(connect.BaseError.prototype),connect.StateError.prototype.constructor=connect.StateError,connect.VoiceIdError=function(e,t,n){var o={};return o.type=e,o.message=t,o.stack=Error(t).stack,o.err=n,o},connect.isCCP=function(){return"ConnectSharedWorkerConduit"===connect.core.getUpstream().name}}()},744:()=>{!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect,connect.worker={};var t=function(){this.topicMasterMap={}};t.prototype.getMaster=function(e){return connect.assertNotNull(e,"topic"),this.topicMasterMap[e]||null},t.prototype.setMaster=function(e,t){connect.assertNotNull(e,"topic"),connect.assertNotNull(t,"id"),this.topicMasterMap[e]=t},t.prototype.removeMaster=function(e){connect.assertNotNull(e,"id");var t=this;connect.entries(this.topicMasterMap).filter((function(t){return t.value===e})).forEach((function(e){delete t.topicMasterMap[e.key]}))};var n=function(e){connect.ClientBase.call(this),this.conduit=e};(n.prototype=Object.create(connect.ClientBase.prototype)).constructor=n,n.prototype._callImpl=function(e,t,n){var o=this,r=(new Date).getTime();connect.containsValue(connect.AgentAppClientMethods,e)?connect.core.getAgentAppClient()._callImpl(e,t,{success:function(t){o._recordAPILatency(e,r),n.success(t)},failure:function(t){o._recordAPILatency(e,r,t),n.failure(t)}}):connect.core.getClient()._callImpl(e,t,{success:function(t){o._recordAPILatency(e,r),n.success(t)},failure:function(t,i){o._recordAPILatency(e,r,t),n.failure(t,i)},authFailure:function(){o._recordAPILatency(e,r),n.authFailure()},accessDenied:function(){n.accessDenied&&n.accessDenied()}})},n.prototype._recordAPILatency=function(e,t,n){var o=(new Date).getTime()-t;this._sendAPIMetrics(e,o,n)},n.prototype._sendAPIMetrics=function(e,t,n){this.conduit.sendDownstream(connect.EventType.API_METRIC,{name:e,time:t,dimensions:[{name:"Category",value:"API"}],error:n})};var o=function(){var o=this;this.multiplexer=new connect.StreamMultiplexer,this.conduit=new connect.Conduit("AmazonConnectSharedWorker",null,this.multiplexer),this.client=new n(this.conduit),this.timeout=null,this.agent=null,this.nextToken=null,this.initData={},this.portConduitMap={},this.masterCoord=new t,this.logsBuffer=[],this.suppress=!1,this.forceOffline=!1;var r=null;connect.rootLogger=new connect.DownstreamConduitLogger(this.conduit),this.conduit.onDownstream(connect.EventType.SEND_LOGS,(function(e){connect.getLog().pushLogsDownstream(e),o.logsBuffer=o.logsBuffer.concat(e),o.logsBuffer.length>400&&o.handleSendLogsRequest(o.logsBuffer)})),this.conduit.onDownstream(connect.EventType.CONFIGURE,(function(t){t.authToken&&t.authToken!==o.initData.authToken&&(o.initData=t,connect.core.init(t),r?connect.getLog().info("Not Initializing a new WebsocketManager instance, since one already exists").sendInternalLogToServer():(connect.getLog().info("Creating a new Websocket connection for CCP").sendInternalLogToServer(),connect.WebSocketManager.setGlobalConfig({loggerConfig:{logger:connect.getLog()}}),(r=connect.WebSocketManager.create()).onInitFailure((function(){o.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE)})),r.onConnectionOpen((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_OPEN,e)})),r.onConnectionClose((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_CLOSE,e)})),r.onConnectionGain((function(){o.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED),o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_GAIN)})),r.onConnectionLost((function(e){o.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e),o.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_LOST,e)})),r.onSubscriptionUpdate((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_UPDATE,e)})),r.onSubscriptionFailure((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_FAILURE,e)})),r.onAllMessage((function(e){o.conduit.sendDownstream(connect.WebSocketEvents.ALL_MESSAGE,e)})),o.conduit.onDownstream(connect.WebSocketEvents.SEND,(function(e){r.sendMessage(e)})),o.conduit.onDownstream(connect.WebSocketEvents.SUBSCRIBE,(function(e){r.subscribeTopics(e)})),r.init(connect.hitch(o,o.getWebSocketUrl)).then((function(t){t&&!t.webSocketConnectionFailed?(connect.getLog().info("Kicking off agent polling").sendInternalLogToServer(),o.pollForAgent(),connect.getLog().info("Kicking off config polling").sendInternalLogToServer(),o.pollForAgentConfiguration({repeatForever:!0}),connect.getLog().info("Kicking off auth token polling").sendInternalLogToServer(),e.setInterval(connect.hitch(o,o.checkAuthToken),3e5)):connect.webSocketInitFailed||(o.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE),connect.webSocketInitFailed=!0)}))))})),this.conduit.onDownstream(connect.EventType.TERMINATE,(function(){o.handleSendLogsRequest(o.logsBuffer),connect.core.terminate(),o.conduit.sendDownstream(connect.EventType.TERMINATED)})),this.conduit.onDownstream(connect.EventType.SYNCHRONIZE,(function(){o.conduit.sendDownstream(connect.EventType.ACKNOWLEDGE)})),this.conduit.onDownstream(connect.EventType.BROADCAST,(function(e){o.conduit.sendDownstream(e.event,e.data)})),e.onconnect=function(e){var t=e.ports[0],n=new connect.PortStream(t);o.multiplexer.addStream(n),t.start();var r=new connect.Conduit(n.getId(),null,n);r.sendDownstream(connect.EventType.ACKNOWLEDGE,{id:n.getId()}),o.portConduitMap[n.getId()]=r,o.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(o.portConduitMap).length}),null!==o.agent&&o.updateAgent(),r.onDownstream(connect.EventType.API_REQUEST,connect.hitch(o,o.handleAPIRequest,r)),r.onDownstream(connect.EventType.MASTER_REQUEST,connect.hitch(o,o.handleMasterRequest,r,n.getId())),r.onDownstream(connect.EventType.RELOAD_AGENT_CONFIGURATION,connect.hitch(o,o.pollForAgentConfiguration)),r.onDownstream(connect.EventType.CLOSE,(function(){o.multiplexer.removeStream(n),delete o.portConduitMap[n.getId()],o.masterCoord.removeMaster(n.getId()),o.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(o.portConduitMap).length})}))}};o.prototype.pollForAgent=function(){var t=this,n=connect.hitch(t,t.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_SNAPSHOT,{nextToken:t.nextToken,timeout:3e4},{success:function(n){try{t.agent=t.agent||{},t.agent.snapshot=n.snapshot,t.agent.snapshot.localTimestamp=connect.now(),t.agent.snapshot.skew=t.agent.snapshot.snapshotTimestamp-t.agent.snapshot.localTimestamp,t.nextToken=n.nextToken,connect.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(n).sendInternalLogToServer(),t.updateAgent()}catch(e){connect.getLog().error("Long poll failed to update agent.").withObject(n).withException(e).sendInternalLogToServer()}finally{e.setTimeout(connect.hitch(t,t.pollForAgent),100)}},failure:function(n,o){try{connect.getLog().error("Failed to get agent data.").sendInternalLogToServer().withObject({err:n,data:o})}finally{e.setTimeout(connect.hitch(t,t.pollForAgent),5e3)}},authFailure:function(){n()},accessDenied:connect.hitch(t,t.handleAccessDenied)})},o.prototype.pollForAgentConfiguration=function(t){var n=this,o=t||{},r=connect.hitch(n,n.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_CONFIGURATION,{},{success:function(t){var r=t.configuration;n.pollForAgentPermissions(r),n.pollForAgentStates(r),n.pollForDialableCountryCodes(r),n.pollForRoutingProfileQueues(r),o.repeatForever&&e.setTimeout(connect.hitch(n,n.pollForAgentConfiguration,o),3e4)},failure:function(t,r){try{connect.getLog().error("Failed to fetch agent configuration data.").sendInternalLogToServer().withObject({err:t,data:r})}finally{o.repeatForever&&e.setTimeout(connect.hitch(n,n.pollForAgentConfiguration),3e4,o)}},authFailure:function(){r()},accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForAgentStates=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_STATES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForAgentStates(e,{states:(o.states||[]).concat(t.states),nextToken:t.nextToken,maxResults:o.maxResults}):(e.agentStates=(o.states||[]).concat(t.states),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch agent states list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForAgentPermissions=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_PERMISSIONS,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForAgentPermissions(e,{permissions:(o.permissions||[]).concat(t.permissions),nextToken:t.nextToken,maxResults:o.maxResults}):(e.permissions=(o.permissions||[]).concat(t.permissions),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch agent permissions list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForDialableCountryCodes=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_DIALABLE_COUNTRY_CODES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForDialableCountryCodes(e,{countryCodes:(o.countryCodes||[]).concat(t.countryCodes),nextToken:t.nextToken,maxResults:o.maxResults}):(e.dialableCountries=(o.countryCodes||[]).concat(t.countryCodes),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch dialable country codes list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.pollForRoutingProfileQueues=function(e,t){var n=this,o=t||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_ROUTING_PROFILE_QUEUES,{routingProfileARN:e.routingProfile.routingProfileARN,nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(t){t.nextToken?n.pollForRoutingProfileQueues(e,{countryCodes:(o.queues||[]).concat(t.queues),nextToken:t.nextToken,maxResults:o.maxResults}):(e.routingProfile.queues=(o.queues||[]).concat(t.queues),n.updateAgentConfiguration(e))},failure:function(e,t){connect.getLog().error("Failed to fetch routing profile queues list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},o.prototype.handleAPIRequest=function(e,t){var n=this;this.client.call(t.method,t.params,{success:function(n){var o=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,t,n);e.sendDownstream(o.event,o)},failure:function(o,r){var i=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,t,r,JSON.stringify(o));e.sendDownstream(i.event,i),connect.getLog().error("'%s' API request failed",t.method).withObject({request:n.filterAuthToken(t),response:i}).withException(o).sendInternalLogToServer()},authFailure:connect.hitch(n,n.handleAuthFail)})},o.prototype.handleMasterRequest=function(e,t,n){var o=this.conduit,r=null;switch(n.method){case connect.MasterMethods.BECOME_MASTER:var i=this.masterCoord.getMaster(n.params.topic),s=Boolean(i)&&i!==t;this.masterCoord.setMaster(n.params.topic,t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:t,takeOver:s,topic:n.params.topic}),s&&o.sendDownstream(r.event,r);break;case connect.MasterMethods.CHECK_MASTER:(i=this.masterCoord.getMaster(n.params.topic))||n.params.shouldNotBecomeMasterIfNone||(this.masterCoord.setMaster(n.params.topic,t),i=t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:i,isMaster:t===i,topic:n.params.topic});break;default:throw new Error("Unknown master method: "+n.method)}e.sendDownstream(r.event,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()):connect.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(connect.AgentEvents.UPDATE,this.agent)):connect.getLog().trace("Waiting to update agent until the agent configuration is available.").sendInternalLogToServer():connect.getLog().trace("Waiting to update agent until the agent snapshot is available.").sendInternalLogToServer():connect.getLog().trace("Waiting to update agent until the agent has been fully constructed.").sendInternalLogToServer()},o.prototype.getWebSocketUrl=function(){var e=this,t=connect.core.getClient(),n=connect.hitch(e,e.handleAuthFail),o=connect.hitch(e,e.handleAccessDenied);return new Promise((function(e,r){t.call(connect.ClientMethods.CREATE_TRANSPORT,{transportType:connect.TRANSPORT_TYPES.WEB_SOCKET},{success:function(t){connect.getLog().info("getWebSocketUrl succeeded").sendInternalLogToServer(),e(t)},failure:function(e,t){connect.getLog().error("getWebSocketUrl failed").sendInternalLogToServer().withObject({err:e,data:t}),r({reason:"getWebSocketUrl failed",_debug:e})},authFailure:function(){connect.getLog().error("getWebSocketUrl Auth Failure").sendInternalLogToServer(),r(Error("Authentication failed while getting getWebSocketUrl")),n()},accessDenied:function(){connect.getLog().error("getWebSocketUrl Access Denied Failure").sendInternalLogToServer(),r(Error("Access Denied Failure while getting getWebSocketUrl")),o()}})}))},o.prototype.handleSendLogsRequest=function(){var e=this,t=[],n=e.logsBuffer.slice();e.logsBuffer=[],n.forEach((function(e){t.push({timestamp:e.time,component:e.component,message:e.text})})),this.client.call(connect.ClientMethods.SEND_CLIENT_LOGS,{logEvents:t},{success:function(e){connect.getLog().info("SendLogs request succeeded.").sendInternalLogToServer()},failure:function(e,t){connect.getLog().error("SendLogs request failed.").withObject(t).withException(e).sendInternalLogToServer()},authFailure:connect.hitch(e,e.handleAuthFail)})},o.prototype.handleAuthFail=function(){this.conduit.sendDownstream(connect.EventType.AUTH_FAIL)},o.prototype.handleAccessDenied=function(){this.conduit.sendDownstream(connect.EventType.ACCESS_DENIED)},o.prototype.checkAuthToken=function(){var e=this,t=new Date(e.initData.authTokenExpiration),n=(new Date).getTime();t.getTime() arr.length) len global.lily = connect; connect.core = {}; connect.core.initialized = false; - connect.version = "1.8.2"; + connect.version = "1.8.3"; connect.DEFAULT_BATCH_SIZE = 500; var CCP_SYN_TIMEOUT = 1000; // 1 sec var CCP_ACK_TIMEOUT = 3000; // 3 sec @@ -6118,6 +6118,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len connect.core.softphoneManager = null; connect.core.upstream = null; connect.core.keepaliveManager = null; + connect.storageAccess.resetStorageAccessState(); connect.agent.initialized = false; connect.core.initialized = false; }; @@ -9502,6 +9503,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == storageParams = {}; originalCCPUrl = ""; rsaContainer = null; + onGrantCallbackInvoked = false; }; /** @@ -9753,6 +9755,9 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input == getRequestStorageAccessUrl: getRequestStorageAccessUrl, storageAccessEvents: storageAccessEvents, resetStorageAccessState: resetStorageAccessState, + getOnGrantCallbackInvoked: function getOnGrantCallbackInvoked() { + return onGrantCallbackInvoked; + }, getStorageAccessParams: function getStorageAccessParams() { return storageParams; }, diff --git a/src/core.js b/src/core.js index 9e5a0d5..5ac80b9 100644 --- a/src/core.js +++ b/src/core.js @@ -156,6 +156,7 @@ connect.core.softphoneManager = null; connect.core.upstream = null; connect.core.keepaliveManager = null; + connect.storageAccess.resetStorageAccessState(); connect.agent.initialized = false; connect.core.initialized = false; }; diff --git a/src/request-storage-access.js b/src/request-storage-access.js index 396769e..f3b55f2 100644 --- a/src/request-storage-access.js +++ b/src/request-storage-access.js @@ -84,6 +84,7 @@ storageParams = {}; originalCCPUrl = ""; rsaContainer = null; + onGrantCallbackInvoked = false; }; /** @@ -373,6 +374,7 @@ getRequestStorageAccessUrl, storageAccessEvents, resetStorageAccessState, + getOnGrantCallbackInvoked: () => onGrantCallbackInvoked, getStorageAccessParams: () => storageParams, onRequest: onRequestHandler, request: () => { diff --git a/test/unit/core.spec.js b/test/unit/core.spec.js index e385e0b..0a70705 100644 --- a/test/unit/core.spec.js +++ b/test/unit/core.spec.js @@ -341,7 +341,37 @@ describe('Core', function () { describe('#connect.core.initCCP()', function () { jsdom({ url: "http://localhost" }); - var clock + var clock; + function isCCPInitialized(containerDiv, params) { + try { + expect(params.ccpUrl).not.to.be.a("null"); + expect(containerDiv).not.to.be.a("null"); + assert.isTrue(document.createElement.calledOnce); + assert.isTrue(containerDiv.appendChild.calledOnce); + return true; + } catch(e) { + console.log("InitCCP initialization failed: ",e); + return false; + } + } + function isCCPTerminated() { + try { + assert.isEmpty(connect.core.client); + assert.isEmpty(connect.core.agentAppClient); + assert.isEmpty(connect.core.masterClient); + assert.isNull(connect.core.agentDataProvider); + assert.isNull(connect.core.softphoneManager); + assert.isNull(connect.core.upstream); + assert.isNull(connect.core.keepaliveManager); + assert.isFalse(connect.agent.initialized); + assert.isFalse(connect.core.initialized); + assert.isFalse(connect.core.eventBus.logEvents); + return true; + } catch(e) { + console.log("InitCCP Terminated failed: ",e); + return false; + } + } before(function () { clock = sinon.useFakeTimers(); @@ -366,46 +396,28 @@ describe('Core', function () { sandbox.stub(connect, "ChatRingtoneEngine"); sandbox.spy(document, "createElement"); connect.numberOfConnectedCCPs = 0; - connect.core.initCCP(this.containerDiv, this.params); }); - + after(function () { sandbox.restore(); clock.restore(); }); - + + afterEach(() => { + sandbox.resetHistory(); + }) + it("CCP initialization", function () { + connect.core.initCCP(this.containerDiv, this.params); expect(this.params.ccpUrl).not.to.be.a("null"); expect(this.containerDiv).not.to.be.a("null"); assert.isTrue(connect.core.checkNotInitialized.called); assert.isTrue(document.createElement.calledOnce); assert.isTrue(this.containerDiv.appendChild.calledOnce); }); - - it("Replicates logs received upstream while ignoring duplicates", function () { - var logger = connect.getLog(); - var loggerId = logger.getLoggerId(); - var originalLoggerLength = logger._logs.length; - var newLogs = [ - new connect.LogEntry("test", connect.LogLevel.LOG, "some log", "some-logger-id"), - new connect.LogEntry("test", connect.LogLevel.LOG, "some log with no logger id", null), - new connect.LogEntry("test", connect.LogLevel.INFO, "some log info", "some-logger-id"), - new connect.LogEntry("test", connect.LogLevel.ERROR, "some log error", "some-logger-id") - ]; - var dupLogs = [ - new connect.LogEntry("test", connect.LogLevel.LOG, "some dup log", loggerId), - new connect.LogEntry("test", connect.LogLevel.INFO, "some dup log info", loggerId), - new connect.LogEntry("test", connect.LogLevel.ERROR, "some dup log error", loggerId) - ] - var allLogs = newLogs.concat(dupLogs); - for (var i = 0; i < allLogs.length; i++) { - connect.core.getUpstream().upstreamBus.trigger(connect.EventType.LOG, allLogs[i]); - } - clock.tick(2000); - assert.lengthOf(logger._logs, originalLoggerLength + newLogs.length); - }); - + it("sends initCCP ringtone params on ACK", function () { + connect.core.initCCP(this.containerDiv, this.params); const spy = sinon.spy(connect.core.getUpstream(), "sendUpstream"); connect.core.getUpstream().upstreamBus.trigger(connect.EventType.ACKNOWLEDGE, { id: 'portId' }); assert.isTrue(connect.core.getUpstream().sendUpstream.calledWith(connect.EventType.CONFIGURE, { @@ -415,8 +427,9 @@ describe('Core', function () { })); spy.restore(); }); - + it("sets up ringtone engines on CONFIGURE with initCCP params", function () { + connect.core.initCCP(this.containerDiv, this.params); connect.core.initRingtoneEngines({ ringtone: this.extraRingtone }); connect.core.getEventBus().trigger(connect.EventType.CONFIGURE, { softphone: this.params.softphone, @@ -426,28 +439,75 @@ describe('Core', function () { connect.core.getEventBus().trigger(connect.AgentEvents.INIT, new connect.Agent()); connect.core.getEventBus().trigger(connect.AgentEvents.REFRESH, new connect.Agent()); connect.ifMaster.callArg(1); - + assert.isTrue(connect.VoiceRingtoneEngine.calledWithNew(this.params.softphone)); assert.isTrue(connect.QueueCallbackRingtoneEngine.calledWithNew(this.params.softphone)); assert.isTrue(connect.ChatRingtoneEngine.calledWithNew(this.params.chat)); }); - + it("should update the number of connected CCPs on UPDATE_CONNECTED_CCPS event", function () { + connect.core.initCCP(this.containerDiv, this.params); expect(connect.numberOfConnectedCCPs).to.equal(0); connect.core.getUpstream().upstreamBus.trigger(connect.EventType.UPDATE_CONNECTED_CCPS, { length: 1 }); expect(connect.numberOfConnectedCCPs).to.equal(1); }); - + + it("Replicates logs received upstream while ignoring duplicates", function () { + connect.core.initCCP(this.containerDiv, this.params); + var logger = connect.getLog(); + var loggerId = logger.getLoggerId(); + var originalLoggerLength = logger._logs.length; + var newLogs = [ + new connect.LogEntry("test", connect.LogLevel.LOG, "some log", "some-logger-id"), + new connect.LogEntry("test", connect.LogLevel.LOG, "some log with no logger id", null), + new connect.LogEntry("test", connect.LogLevel.INFO, "some log info", "some-logger-id"), + new connect.LogEntry("test", connect.LogLevel.ERROR, "some log error", "some-logger-id") + ]; + var dupLogs = [ + new connect.LogEntry("test", connect.LogLevel.LOG, "some dup log", loggerId), + new connect.LogEntry("test", connect.LogLevel.INFO, "some dup log info", loggerId), + new connect.LogEntry("test", connect.LogLevel.ERROR, "some dup log error", loggerId) + ] + var allLogs = newLogs.concat(dupLogs); + for (var i = 0; i < allLogs.length; i++) { + connect.core.getUpstream().upstreamBus.trigger(connect.EventType.LOG, allLogs[i]); + } + clock.tick(2000); + assert.lengthOf(logger._logs, originalLoggerLength + newLogs.length); + }); + + it("Check if CCP is initialized after calling terminate function and re-calling initCCP", function () { + const storageAccessOriginal = connect.storageAccess; + connect.storageAccess = { ...connect.storageAccess, resetStorageAccessState: sinon.fake()}; + + expect(this.params.ccpUrl).not.to.be.a("null"); + expect(this.containerDiv).not.to.be.a("null"); + connect.core.initCCP(this.containerDiv, this.params); + expect(isCCPInitialized(this.containerDiv, this.params)).to.be.true; + + connect.core.terminate(); + expect(connect.storageAccess.resetStorageAccessState.calledOnce).to.be.true; + + connect.core.terminate(); + expect(connect.storageAccess.resetStorageAccessState.calledTwice).to.be.true; + + expect(isCCPTerminated()).to.be.true; + sandbox.resetHistory(); + connect.core.initCCP(this.containerDiv, this.params); + expect(isCCPInitialized(this.containerDiv, this.params)).to.be.true; + connect.storageAccess = storageAccessOriginal; + }); + describe("on ACK", function () { let fakeOnInitHandler; - + before(function () { fakeOnInitHandler = sinon.fake(); connect.core.onInitialized(fakeOnInitHandler); sandbox.stub(connect.WindowIOStream.prototype, 'send').returns(null); connect.core.getUpstream().upstreamBus.trigger(connect.EventType.ACKNOWLEDGE, { id: 'portId' }); }); - + it("should set portStreamId on ACK", function () { connect.core.getUpstream().upstreamBus.trigger(connect.EventType.ACKNOWLEDGE, { id: 'portId' }); expect(connect.core.portStreamId).to.equal('portId'); diff --git a/test/unit/request-storage-access.spec.js b/test/unit/request-storage-access.spec.js index 93d9931..32406d7 100644 --- a/test/unit/request-storage-access.spec.js +++ b/test/unit/request-storage-access.spec.js @@ -218,6 +218,7 @@ describe("Request Storage Access module", () => { }); connect.storageAccess.init(ccpUrl, container); + expect(connect.storageAccess.getOnGrantCallbackInvoked()).to.be.false; connect.storageAccess.setupRequestHandlers({ onGrant: onGrantSpy }); connect.storageAccess.request(); @@ -232,10 +233,14 @@ describe("Request Storage Access module", () => { ); expect(onGrantSpy.called).to.be.true; + expect(connect.storageAccess.getOnGrantCallbackInvoked()).to.be.true; connect.storageAccess.request(); /** Should be called only once */ expect(onGrantSpy.calledTwice).not.to.be.true; + + connect.storageAccess.resetStorageAccessState(); + expect(connect.storageAccess.getOnGrantCallbackInvoked()).to.be.false; }); it('Should hide container if mode is custom after granting access', () => {