/*! For license information please see main.ade5ba54.js.LICENSE.txt */ !function(){var e={228:function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},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 a,c=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){s=!0,a=e},f:function(){try{c||null==n.return||n.return()}finally{if(s)throw a}}}},e.exports.__esModule=!0,e.exports.default=e.exports},379:function(e,t,n){var r=n(228);e.exports=function(e,t){if(e){if("string"===typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},757:function(e,t,n){e.exports=n(727)},927:function(e,t,n){var r=n(269).default;!function(){var e={821:function(){!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),r=new connect.IFrameConduit(t,window,n),o=[connect.AgentEvents.UPDATE,connect.ContactEvents.VIEW,connect.EventType.ACKNOWLEDGE,connect.EventType.TERMINATED,connect.TaskEvents.CREATED];n.addEventListener("load",(function(e){o.forEach((function(e){connect.core.getUpstream().onUpstream(e,(function(t){r.sendUpstream(e,t)}))}))}))};var n=function(e){var t=e.indexOf("ccp-v2");return e.slice(0,t-1)};connect.agentApp.initApp=function(e,r,o,i){i=i||{};var a=o.endsWith("/")?o:o+"/",c=i.onLoad?i.onLoad:null,s={endpoint:a,style:i.style,onLoad:c};connect.agentApp.AppRegistry.register(e,s,document.getElementById(r)),connect.agentApp.AppRegistry.start(e,(function(r){var o=r.endpoint,a=r.containerDOM;return{init:function(){return e===t?function(e,t,r){var o={ccpUrl:e,ccpLoadTimeout:1e4,loginPopup:!0,loginUrl:n(e)+"/login",softphone:{allowFramedSoftphone:!0,disableRingtone:!1}},i=connect.merge(o,r.ccpParams);connect.core.initCCP(t,i)}(o,a,i):connect.agentApp.initAppCommunication(e,o)},destroy:function(){return e===t?function(e){var t=n(e)+"/logout";return connect.fetch(t,{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=t,!1}))}(o):null}}}))},connect.agentApp.stopApp=function(e){return connect.agentApp.AppRegistry.stop(e)}}()},500:function(){!function(){var e=this;connect=e.connect||{},e.connect=connect;var t="ccp";e.connect.agentApp.AppRegistry=function(){var e={};return{register:function(t,n,r){e[t]={containerDOM:r,endpoint:n.endpoint,style:n.style,instance:void 0,onLoad:n.onLoad}},start:function(n,r){if(e[n]){var o=e[n].containerDOM,i=e[n].endpoint,a=e[n].style,c=e[n].onLoad;if(n!==t){var s=function(e,t,n,r){var o=document.createElement("iframe");return o.src=t,o.style=n||"width: 100%; height:100%;",o.id=e,o["aria-label"]=e,o.onload=r,o.setAttribute("sandbox","allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"),o}(n,i,a,c);o.appendChild(s)}return e[n].instance=r(e[n]),e[n].instance.init()}},stop:function(t){if(e[t]){var n,r=e[t],o=r.containerDOM.querySelector("iframe");return r.containerDOM.removeChild(o),r.instance&&(n=r.instance.destroy(),delete r.instance),n}}}}()}()},965:function(){!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect,connect.AgentStateType=connect.makeEnum(["init","routable","not_routable","offline"]),connect.AgentStatusType=connect.AgentStateType,connect.AgentAvailStates=connect.makeEnum(["Init","Busy","AfterCallWork","CallingCustomer","Dialing","Joining","PendingAvailable","PendingBusy"]),connect.AgentErrorStates=connect.makeEnum(["Error","AgentHungUp","BadAddressAgent","BadAddressCustomer","Default","FailedConnectAgent","FailedConnectCustomer","InvalidLocale","LineEngagedAgent","LineEngagedCustomer","MissedCallAgent","MissedCallCustomer","MultipleCcpWindows","RealtimeCommunicationError"]),connect.EndpointType=connect.makeEnum(["phone_number","agent","queue"]),connect.AddressType=connect.EndpointType,connect.ConnectionType=connect.makeEnum(["agent","inbound","outbound","monitoring"]),connect.ConnectionStateType=connect.makeEnum(["init","connecting","connected","hold","disconnected"]),connect.ConnectionStatusType=connect.ConnectionStateType,connect.CONNECTION_ACTIVE_STATES=connect.set([connect.ConnectionStateType.CONNECTING,connect.ConnectionStateType.CONNECTED,connect.ConnectionStateType.HOLD]),connect.ContactStateType=connect.makeEnum(["init","incoming","pending","connecting","connected","missed","error","ended"]),connect.ContactStatusType=connect.ContactStateType,connect.CONTACT_ACTIVE_STATES=connect.makeEnum(["incoming","pending","connecting","connected"]),connect.ContactType=connect.makeEnum(["voice","queue_callback","chat","task"]),connect.ContactInitiationMethod=connect.makeEnum(["inbound","outbound","transfer","queue_transfer","callback","api","disconnect"]),connect.ChannelType=connect.makeEnum(["VOICE","CHAT","TASK"]),connect.MediaType=connect.makeEnum(["softphone","chat","task"]),connect.SoftphoneCallType=connect.makeEnum(["audio_video","video_only","audio_only","none"]),connect.SoftphoneErrorTypes=connect.makeEnum(["unsupported_browser","microphone_not_shared","signalling_handshake_failure","signalling_connection_failure","ice_collection_timeout","user_busy_error","webrtc_error","realtime_communication_error","other"]),connect.VoiceIdErrorTypes=connect.makeEnum(["no_speaker_id_found","speaker_id_not_enrolled","get_speaker_id_failed","get_speaker_status_failed","opt_out_speaker_failed","opt_out_speaker_in_lcms_failed","delete_speaker_failed","start_session_failed","evaluate_speaker_failed","session_not_exists","describe_session_failed","enroll_speaker_failed","update_speaker_id_failed","update_speaker_id_in_lcms_failed","not_supported_on_conference_calls","enroll_speaker_timeout","evaluate_speaker_timeout","get_domain_id_failed","no_domain_id_found"]),connect.CTIExceptions=connect.makeEnum(["AccessDeniedException","InvalidStateException","BadEndpointException","InvalidAgentARNException","InvalidConfigurationException","InvalidContactTypeException","PaginationException","RefreshTokenExpiredException","SendDataFailedException","UnauthorizedException","QuotaExceededException"]),connect.VoiceIdStreamingStatus=connect.makeEnum(["ONGOING","ENDED","PENDING_CONFIGURATION"]),connect.VoiceIdAuthenticationDecision=connect.makeEnum(["ACCEPT","REJECT","NOT_ENOUGH_SPEECH","SPEAKER_NOT_ENROLLED","SPEAKER_OPTED_OUT","SPEAKER_ID_NOT_PROVIDED","SPEAKER_EXPIRED"]),connect.VoiceIdFraudDetectionDecision=connect.makeEnum(["NOT_ENOUGH_SPEECH","HIGH_RISK","LOW_RISK"]),connect.ContactFlowAuthenticationDecision=connect.makeEnum(["Authenticated","NotAuthenticated","Inconclusive","NotEnrolled","OptedOut","NotEnabled","Error"]),connect.ContactFlowFraudDetectionDecision=connect.makeEnum(["HighRisk","LowRisk","Inconclusive","NotEnabled","Error"]),connect.VoiceIdEnrollmentRequestStatus=connect.makeEnum(["NOT_ENOUGH_SPEECH","IN_PROGRESS","COMPLETED","FAILED"]),connect.VoiceIdSpeakerStatus=connect.makeEnum(["OPTED_OUT","ENROLLED","PENDING"]),connect.VoiceIdConstants={EVALUATE_SESSION_DELAY:1e4,EVALUATION_MAX_POLL_TIMES:24,EVALUATION_POLLING_INTERVAL:5e3,ENROLLMENT_MAX_POLL_TIMES:120,ENROLLMENT_POLLING_INTERVAL:5e3,START_SESSION_DELAY:8e3},connect.AgentPermissions={OUTBOUND_CALL:"outboundCall",VOICE_ID:"voiceId"};var t=function(){if(!connect.agent.initialized)throw new connect.StateError("The agent is not yet initialized!")};t.prototype._getData=function(){return connect.core.getAgentDataProvider().getAgentData()},t.prototype._createContactAPI=function(e){return new connect.Contact(e.contactId)},t.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.REFRESH,e)},t.prototype.onRoutable=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ROUTABLE,e)},t.prototype.onNotRoutable=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.NOT_ROUTABLE,e)},t.prototype.onOffline=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.OFFLINE,e)},t.prototype.onError=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ERROR,e)},t.prototype.onSoftphoneError=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.SOFTPHONE_ERROR,e)},t.prototype.onWebSocketConnectionLost=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e)},t.prototype.onWebSocketConnectionGained=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED,e)},t.prototype.onAfterCallWork=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ACW,e)},t.prototype.onStateChange=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.STATE_CHANGE,e)},t.prototype.onMuteToggle=function(e){connect.core.getUpstream().onUpstream(connect.AgentEvents.MUTE_TOGGLE,e)},t.prototype.onLocalMediaStreamCreated=function(e){connect.core.getUpstream().onUpstream(connect.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,e)},t.prototype.onSpeakerDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,e)},t.prototype.onMicrophoneDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,e)},t.prototype.onRingerDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.RINGER_DEVICE_CHANGED,e)},t.prototype.mute=function(){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.MUTE,data:{mute:!0}})},t.prototype.unmute=function(){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.MUTE,data:{mute:!1}})},t.prototype.setSpeakerDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_SPEAKER_DEVICE,data:{deviceId:e}})},t.prototype.setMicrophoneDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_MICROPHONE_DEVICE,data:{deviceId:e}})},t.prototype.setRingerDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_RINGER_DEVICE,data:{deviceId:e}})},t.prototype.getState=function(){return this._getData().snapshot.state},t.prototype.getNextState=function(){return this._getData().snapshot.nextState},t.prototype.getAvailabilityState=function(){return this._getData().snapshot.agentAvailabilityState},t.prototype.getStatus=t.prototype.getState,t.prototype.getStateDuration=function(){return connect.now()-this._getData().snapshot.state.startTimestamp.getTime()+connect.core.getSkew()},t.prototype.getStatusDuration=t.prototype.getStateDuration,t.prototype.getPermissions=function(){return this.getConfiguration().permissions},t.prototype.getContacts=function(e){var t=this;return this._getData().snapshot.contacts.map((function(e){return t._createContactAPI(e)})).filter((function(t){return!e||t.getType()===e}))},t.prototype.getConfiguration=function(){return this._getData().configuration},t.prototype.getAgentStates=function(){return this.getConfiguration().agentStates},t.prototype.getRoutingProfile=function(){return this.getConfiguration().routingProfile},t.prototype.getChannelConcurrency=function(e){var t=this.getRoutingProfile().channelConcurrencyMap;return t||(t=Object.keys(connect.ChannelType).reduce((function(e,t){return"TASK"!==t&&(e[connect.ChannelType[t]]=1),e}),{})),e?t[e]||0:t},t.prototype.getName=function(){return this.getConfiguration().name},t.prototype.getExtension=function(){return this.getConfiguration().extension},t.prototype.getDialableCountries=function(){return this.getConfiguration().dialableCountries},t.prototype.isSoftphoneEnabled=function(){return this.getConfiguration().softphoneEnabled},t.prototype.setConfiguration=function(e,t){var n=connect.core.getClient();e&&e.agentPreferences&&!connect.isValidLocale(e.agentPreferences.locale)?t&&t.failure&&t.failure(connect.AgentErrorStates.INVALID_LOCALE):n.call(connect.ClientMethods.UPDATE_AGENT_CONFIGURATION,{configuration:connect.assertNotNull(e,"configuration")},{success:function(e){connect.core.getUpstream().sendUpstream(connect.EventType.RELOAD_AGENT_CONFIGURATION),t.success&&t.success(e)},failure:t&&t.failure})},t.prototype.setState=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.PUT_AGENT_STATE,{state:connect.assertNotNull(e,"state"),enqueueNextState:n&&!!n.enqueueNextState},t)},t.prototype.onEnqueuedNextState=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ENQUEUED_NEXT_STATE,e)},t.prototype.setStatus=t.prototype.setState,t.prototype.connect=function(e,t){var n=connect.core.getClient(),r=new connect.Endpoint(e);delete r.endpointId,n.call(connect.ClientMethods.CREATE_OUTBOUND_CONTACT,{endpoint:connect.assertNotNull(r,"endpoint"),queueARN:t&&(t.queueARN||t.queueId)||this.getRoutingProfile().defaultOutboundQueue.queueARN},t&&{success:t.success,failure:t.failure})},t.prototype.getAllQueueARNs=function(){return this.getConfiguration().routingProfile.queues.map((function(e){return e.queueARN}))},t.prototype.getEndpoints=function(e,t,n){var r=this,o=connect.core.getClient();connect.assertNotNull(t,"callbacks"),connect.assertNotNull(t.success,"callbacks.success");var i=n||{};i.endpoints=i.endpoints||[],i.maxResults=i.maxResults||connect.DEFAULT_BATCH_SIZE,connect.isArray(e)||(e=[e]),o.call(connect.ClientMethods.GET_ENDPOINTS,{queueARNs:e,nextToken:i.nextToken||null,maxResults:i.maxResults},{success:function(n){if(n.nextToken)r.getEndpoints(e,t,{nextToken:n.nextToken,maxResults:i.maxResults,endpoints:i.endpoints.concat(n.endpoints)});else{i.endpoints=i.endpoints.concat(n.endpoints);var o=i.endpoints.map((function(e){return new connect.Endpoint(e)}));t.success({endpoints:o,addresses:o})}},failure:t.failure})},t.prototype.getAddresses=t.prototype.getEndpoints,t.prototype._getResourceId=function(){queueArns=this.getAllQueueARNs();var e,t=r(queueArns);try{for(t.s();!(e=t.n()).done;){var n=e.value.match(/\/agent\/([^/]+)/);if(n)return n[1]}}catch(o){t.e(o)}finally{t.f()}return new Error("Agent.prototype._getResourceId: queueArns did not contain agentResourceId: ",queueArns)},t.prototype.toSnapshot=function(){return new connect.AgentSnapshot(this._getData())};var n=function(e){connect.Agent.call(this),this.agentData=e};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype._getData=function(){return this.agentData},n.prototype._createContactAPI=function(e){return new connect.ContactSnapshot(e)};var o=function(e){this.contactId=e};o.prototype._getData=function(){return connect.core.getAgentDataProvider().getContactData(this.getContactId())},o.prototype._createConnectionAPI=function(e){return this.getType()===connect.ContactType.CHAT?new connect.ChatConnection(this.contactId,e.connectionId):this.getType()===connect.ContactType.TASK?new connect.TaskConnection(this.contactId,e.connectionId):new connect.VoiceConnection(this.contactId,e.connectionId)},o.prototype.getEventName=function(e){return connect.core.getContactEventName(e,this.getContactId())},o.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.REFRESH),e)},o.prototype.onIncoming=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.INCOMING),e)},o.prototype.onConnecting=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTING),e)},o.prototype.onPending=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.PENDING),e)},o.prototype.onAccepted=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACCEPTED),e)},o.prototype.onMissed=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.MISSED),e)},o.prototype.onEnded=function(e){var t=connect.core.getEventBus();t.subscribe(this.getEventName(connect.ContactEvents.ENDED),e),t.subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},o.prototype.onDestroy=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},o.prototype.onACW=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACW),e)},o.prototype.onConnected=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTED),e)},o.prototype.onError=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ERROR),e)},o.prototype.getContactId=function(){return this.contactId},o.prototype.getOriginalContactId=function(){return this._getData().initialContactId},o.prototype.getInitialContactId=o.prototype.getOriginalContactId,o.prototype.getType=function(){return this._getData().type},o.prototype.getContactDuration=function(){return this._getData().contactDuration},o.prototype.getState=function(){return this._getData().state},o.prototype.getStatus=o.prototype.getState,o.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},o.prototype.getStatusDuration=o.prototype.getStateDuration,o.prototype.getQueue=function(){return this._getData().queue},o.prototype.getQueueTimestamp=function(){return this._getData().queueTimestamp},o.prototype.getConnections=function(){var e=this;return this._getData().connections.map((function(t){return e.getType()===connect.ContactType.CHAT?new connect.ChatConnection(e.contactId,t.connectionId):e.getType()===connect.ContactType.TASK?new connect.TaskConnection(e.contactId,t.connectionId):new connect.VoiceConnection(e.contactId,t.connectionId)}))},o.prototype.getInitialConnection=function(){return connect.find(this.getConnections(),(function(e){return e.isInitialConnection()}))||null},o.prototype.getActiveInitialConnection=function(){var e=this.getInitialConnection();return null!=e&&e.isActive()?e:null},o.prototype.getThirdPartyConnections=function(){return this.getConnections().filter((function(e){return!e.isInitialConnection()&&e.getType()!==connect.ConnectionType.AGENT}))},o.prototype.getSingleActiveThirdPartyConnection=function(){return this.getThirdPartyConnections().filter((function(e){return e.isActive()}))[0]||null},o.prototype.getAgentConnection=function(){return connect.find(this.getConnections(),(function(e){var t=e.getType();return t===connect.ConnectionType.AGENT||t===connect.ConnectionType.MONITORING}))},o.prototype.getName=function(){return this._getData().name},o.prototype.getContactMetadata=function(){return this._getData().contactMetadata},o.prototype.getDescription=function(){return this._getData().description},o.prototype.getReferences=function(){return this._getData().references},o.prototype.getAttributes=function(){return this._getData().attributes},o.prototype.getContactFeatures=function(){return this._getData().contactFeatures},o.prototype.isSoftphoneCall=function(){return null!=connect.find(this.getConnections(),(function(e){return null!=e.getSoftphoneMediaInfo()}))},o.prototype._isInbound=function(){return this._getData().initiationMethod!==connect.ContactInitiationMethod.OUTBOUND},o.prototype.isInbound=function(){var e=this.getInitialConnection();return e.getMediaType()===connect.MediaType.TASK?this._isInbound():!!e&&e.getType()===connect.ConnectionType.INBOUND},o.prototype.isConnected=function(){return this.getStatus().type===connect.ContactStateType.CONNECTED},o.prototype.accept=function(e){var t=connect.core.getClient(),n=this,r=this.getContactId();t.call(connect.ClientMethods.ACCEPT_CONTACT,{contactId:r},{success:function(t){var o=connect.core.getUpstream();o.sendUpstream(connect.EventType.BROADCAST,{event:connect.ContactEvents.ACCEPTED,data:new connect.Contact(r)}),o.sendUpstream(connect.EventType.BROADCAST,{event:connect.core.getContactEventName(connect.ContactEvents.ACCEPTED,n.getContactId()),data:new connect.Contact(r)});var i=new connect.Contact(r);connect.isFirefoxBrowser()&&i.isSoftphoneCall()&&connect.core.triggerReadyToStartSessionEvent(),e&&e.success&&e.success(t)},failure:e?e.failure:null})},o.prototype.destroy=function(){connect.getLog().warn("contact.destroy() has been deprecated.")},o.prototype.reject=function(e){connect.core.getClient().call(connect.ClientMethods.REJECT_CONTACT,{contactId:this.getContactId()},e)},o.prototype.complete=function(e){connect.core.getClient().call(connect.ClientMethods.COMPLETE_CONTACT,{contactId:this.getContactId()},e)},o.prototype.clear=function(e){connect.core.getClient().call(connect.ClientMethods.CLEAR_CONTACT,{contactId:this.getContactId()},e)},o.prototype.notifyIssue=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.NOTIFY_CONTACT_ISSUE,{contactId:this.getContactId(),issueCode:e,description:t},n)},o.prototype.addConnection=function(e,t){var n=connect.core.getClient(),r=new connect.Endpoint(e);delete r.endpointId,n.call(connect.ClientMethods.CREATE_ADDITIONAL_CONNECTION,{contactId:this.getContactId(),endpoint:r},t)},o.prototype.toggleActiveConnections=function(e){var t=connect.core.getClient(),n=null,r=connect.find(this.getConnections(),(function(e){return e.getStatus().type===connect.ConnectionStateType.HOLD}));if(null!=r)n=r.getConnectionId();else{var o=this.getConnections().filter((function(e){return e.isActive()}));o.length>0&&(n=o[0].getConnectionId())}t.call(connect.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:n},e)},o.prototype.sendSoftphoneMetrics=function(t,n){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:e.ccpVersion,softphoneStreamStatistics:t},n),connect.publishSoftphoneStats({contactId:this.getContactId(),ccpVersion:e.ccpVersion,stats:t})},o.prototype.sendSoftphoneReport=function(t,n){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:e.ccpVersion,report:t},n),connect.publishSoftphoneReport({contactId:this.getContactId(),ccpVersion:e.ccpVersion,report:t})},o.prototype.conferenceConnections=function(e){connect.core.getClient().call(connect.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},o.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(o.prototype)).constructor=i,i.prototype._getData=function(){return this.contactData},i.prototype._createConnectionAPI=function(e){return new connect.ConnectionSnapshot(e)};var a=function(e,t){this.contactId=e,this.connectionId=t,this._initMediaController()};a.prototype._getData=function(){return connect.core.getAgentDataProvider().getConnectionData(this.getContactId(),this.getConnectionId())},a.prototype.getContactId=function(){return this.contactId},a.prototype.getConnectionId=function(){return this.connectionId},a.prototype.getEndpoint=function(){return new connect.Endpoint(this._getData().endpoint)},a.prototype.getAddress=a.prototype.getEndpoint,a.prototype.getState=function(){return this._getData().state},a.prototype.getStatus=a.prototype.getState,a.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},a.prototype.getStatusDuration=a.prototype.getStateDuration,a.prototype.getType=function(){return this._getData().type},a.prototype.isInitialConnection=function(){return this._getData().initial},a.prototype.isActive=function(){return connect.contains(connect.CONNECTION_ACTIVE_STATES,this.getStatus().type)},a.prototype.isConnected=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTED},a.prototype.isConnecting=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTING},a.prototype.isOnHold=function(){return this.getStatus().type===connect.ConnectionStateType.HOLD},a.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},a.prototype.getMonitorInfo=function(){return this._getData().monitoringInfo},a.prototype.destroy=function(e){connect.core.getClient().call(connect.ClientMethods.DESTROY_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},a.prototype.sendDigits=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_DIGITS,{contactId:this.getContactId(),connectionId:this.getConnectionId(),digits:e},t)},a.prototype.hold=function(e){connect.core.getClient().call(connect.ClientMethods.HOLD_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},a.prototype.resume=function(e){connect.core.getClient().call(connect.ClientMethods.RESUME_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},a.prototype.toSnapshot=function(){return new connect.ConnectionSnapshot(this._getData())},a.prototype._initMediaController=function(){this.getMediaInfo()&&connect.core.mediaFactory.get(this).catch((function(){}))},a.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING},a.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,r){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 o=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_SPEAKER_ID_FOUND,"No speakerId assotiated with this call");r(o)}},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);r(t)}})}))},c.prototype.getSpeakerStatus=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,r){e.getSpeakerId().then((function(o){e.getDomainId().then((function(e){t.call(connect.AgentAppClientMethods.DESCRIBE_SPEAKER,{SpeakerId:connect.assertNotNull(o.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 o=t;o.type=o.type?o.type:connect.VoiceIdErrorTypes.SPEAKER_ID_NOT_ENROLLED,connect.getLog().info("Speaker is not enrolled.").sendInternalLogToServer(),n(o);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);r(i)}}})})).catch((function(e){r(e)}))})).catch((function(e){r(e)}))}))},c.prototype._optOutSpeakerInLcms=function(e){var t=this,n=connect.core.getClient();return new Promise((function(r,o){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(),r(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);o(t)}})}))},c.prototype.optOutSpeaker=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,r){e.getSpeakerId().then((function(o){e.getDomainId().then((function(i){var a=o.speakerId;t.call(connect.AgentAppClientMethods.OPT_OUT_SPEAKER,{SpeakerId:connect.assertNotNull(a,"speakerId"),DomainId:i},{success:function(t){e._optOutSpeakerInLcms(a).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);r(t)}})})).catch((function(e){r(e)}))})).catch((function(e){r(e)}))}))},c.prototype.deleteSpeaker=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,r){e.getSpeakerId().then((function(o){e.getDomainId().then((function(e){t.call(connect.AgentAppClientMethods.DELETE_SPEAKER,{SpeakerId:connect.assertNotNull(o.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);r(t)}})})).catch((function(e){r(e)}))})).catch((function(e){r(e)}))}))},c.prototype.startSession=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise((function(n,r){e.getDomainId().then((function(o){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:o},{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");r(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);r(t)}})})).catch((function(e){r(e)}))}))},c.prototype.evaluateSpeaker=function(e){var t=this;t.checkConferenceCall();var n=connect.core.getClient(),r=connect.core.getAgentDataProvider().getContactData(this.contactId),o=0;return new Promise((function(i,a){function c(){t.getDomainId().then((function(e){n.call(connect.AgentAppClientMethods.EVALUATE_SESSION,{SessionNameOrId:r.initialContactId||this.contactId,DomainId:e},{success:function(e){if(++o=1)r=n.IntegrationAssociationSummaryList[0].IntegrationArn.replace(/^.*domain\//i,"");if(!r){connect.getLog().info("getDomainId: no domainId found").sendInternalLogToServer();var o=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_DOMAIN_ID_FOUND);return void t(o)}connect.getLog().info("getDomainId succeeded").withObject(n).sendInternalLogToServer(),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.VoiceIdEvents.UPDATE_DOMAIN_ID,data:{domainId:r}}),e(r)}catch(i){connect.getLog().error("getDomainId failed").withObject({err:i}).sendInternalLogToServer();o=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_DOMAIN_ID_FAILED,"getDomainId failed",i);t(o)}},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)}})}else 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 s=function(e,t){this._speakerAuthenticator=new c(e),a.call(this,e,t)};(s.prototype=Object.create(a.prototype)).constructor=s,s.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMediaType=function(){return connect.MediaType.SOFTPHONE},s.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)},s.prototype.getVoiceIdSpeakerId=function(){return this._speakerAuthenticator.getSpeakerId()},s.prototype.getVoiceIdSpeakerStatus=function(){return this._speakerAuthenticator.getSpeakerStatus()},s.prototype.optOutVoiceIdSpeaker=function(){return this._speakerAuthenticator.optOutSpeaker()},s.prototype.deleteVoiceIdSpeaker=function(){return this._speakerAuthenticator.deleteSpeaker()},s.prototype.evaluateSpeakerWithVoiceId=function(e){return this._speakerAuthenticator.evaluateSpeaker(e)},s.prototype.enrollSpeakerInVoiceId=function(){return this._speakerAuthenticator.enrollSpeaker()},s.prototype.updateVoiceIdSpeakerId=function(e){return this._speakerAuthenticator.updateSpeakerIdInVoiceId(e)},s.prototype.getQuickConnectName=function(){return this._getData().quickConnectName},s.prototype.isMute=function(){return this._getData().mute},s.prototype.muteParticipant=function(e){connect.core.getClient().call(connect.ClientMethods.MUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},s.prototype.unmuteParticipant=function(e){connect.core.getClient().call(connect.ClientMethods.UNMUTE_PARTICIPANT,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)};var u=function(e,t){a.call(this,e,t)};(u.prototype=Object.create(a.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(r){connect.getLog().error(connect.LogComponent.CHAT,"Connection data is invalid").withObject(e).withException(r).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){a.call(this,e,t)};(l.prototype=Object.create(a.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(a.prototype)).constructor=p,p.prototype._getData=function(){return this.connectionData},p.prototype._initMediaController=function(){};var f=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};f.prototype.stripPhoneNumber=function(){return this.phoneNumber?this.phoneNumber.replace(/sip:([^@]*)@.*/,"$1"):""},f.byPhoneNumber=function(e,t){return new f({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,r){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:r},{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=t,connect.AgentSnapshot=n,connect.Contact=o,connect.ContactSnapshot=i,connect.Connection=s,connect.BaseConnection=a,connect.VoiceConnection=s,connect.ChatConnection=u,connect.TaskConnection=l,connect.ConnectionSnapshot=p,connect.Endpoint=f,connect.Address=f,connect.SoftphoneError=d,connect.VoiceId=c}()},827:function(e,t,n){var r;!function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};t[a][0].call(u.exports,(function(e){return o(t[a][1][e]||e)}),u,u.exports,e,t,n,r)}return n[a].exports}for(var i=void 0,a=0;a-1});var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]","[object DataView]"];t.exports={isEmptyData:function(e){return"string"===typeof e?0===e.length:0===e.byteLength},convertToBuffer:function(e){return"string"===typeof e&&(e=new r(e,"utf8")),ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}}},{"buffer/":81}],12:[function(e,t,n){var r=e("./browserHashUtils");function o(e,t){this.hash=new e,this.outer=new e;var n=function(e,t){var n=r.convertToBuffer(t);if(n.byteLength>e.BLOCK_SIZE){var o=new e;o.update(n),n=o.digest()}var i=new Uint8Array(e.BLOCK_SIZE);return i.set(n),i}(e,t),o=new Uint8Array(e.BLOCK_SIZE);o.set(n);for(var i=0;i>>32-o)+n&4294967295}function s(e,t,n,r,o,i,a){return c(t&n|~t&r,e,t,o,i,a)}function u(e,t,n,r,o,i,a){return c(t&r|n&~r,e,t,o,i,a)}function l(e,t,n,r,o,i,a){return c(t^n^r,e,t,o,i,a)}function p(e,t,n,r,o,i,a){return c(n^(t|~r),e,t,o,i,a)}t.exports=a,a.BLOCK_SIZE=i,a.prototype.update=function(e){if(r.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=r.convertToBuffer(e),n=0,o=t.byteLength;for(this.bytesHashed+=o;o>0;)this.buffer.setUint8(this.bufferLength++,t[n++]),o--,this.bufferLength===i&&(this.hashBuffer(),this.bufferLength=0);return this},a.prototype.digest=function(e){if(!this.finished){var t=this,n=t.buffer,r=t.bufferLength,a=8*t.bytesHashed;if(n.setUint8(this.bufferLength++,128),r%i>=56){for(var c=this.bufferLength;c>>0,!0),n.setUint32(60,Math.floor(a/4294967296),!0),this.hashBuffer(),this.finished=!0}var s=new DataView(new ArrayBuffer(16));for(c=0;c<4;c++)s.setUint32(4*c,this.state[c],!0);var u=new o(s.buffer,s.byteOffset,s.byteLength);return e?u.toString(e):u},a.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=t[0],r=t[1],o=t[2],i=t[3];n=s(n,r,o,i,e.getUint32(0,!0),7,3614090360),i=s(i,n,r,o,e.getUint32(4,!0),12,3905402710),o=s(o,i,n,r,e.getUint32(8,!0),17,606105819),r=s(r,o,i,n,e.getUint32(12,!0),22,3250441966),n=s(n,r,o,i,e.getUint32(16,!0),7,4118548399),i=s(i,n,r,o,e.getUint32(20,!0),12,1200080426),o=s(o,i,n,r,e.getUint32(24,!0),17,2821735955),r=s(r,o,i,n,e.getUint32(28,!0),22,4249261313),n=s(n,r,o,i,e.getUint32(32,!0),7,1770035416),i=s(i,n,r,o,e.getUint32(36,!0),12,2336552879),o=s(o,i,n,r,e.getUint32(40,!0),17,4294925233),r=s(r,o,i,n,e.getUint32(44,!0),22,2304563134),n=s(n,r,o,i,e.getUint32(48,!0),7,1804603682),i=s(i,n,r,o,e.getUint32(52,!0),12,4254626195),o=s(o,i,n,r,e.getUint32(56,!0),17,2792965006),n=u(n,r=s(r,o,i,n,e.getUint32(60,!0),22,1236535329),o,i,e.getUint32(4,!0),5,4129170786),i=u(i,n,r,o,e.getUint32(24,!0),9,3225465664),o=u(o,i,n,r,e.getUint32(44,!0),14,643717713),r=u(r,o,i,n,e.getUint32(0,!0),20,3921069994),n=u(n,r,o,i,e.getUint32(20,!0),5,3593408605),i=u(i,n,r,o,e.getUint32(40,!0),9,38016083),o=u(o,i,n,r,e.getUint32(60,!0),14,3634488961),r=u(r,o,i,n,e.getUint32(16,!0),20,3889429448),n=u(n,r,o,i,e.getUint32(36,!0),5,568446438),i=u(i,n,r,o,e.getUint32(56,!0),9,3275163606),o=u(o,i,n,r,e.getUint32(12,!0),14,4107603335),r=u(r,o,i,n,e.getUint32(32,!0),20,1163531501),n=u(n,r,o,i,e.getUint32(52,!0),5,2850285829),i=u(i,n,r,o,e.getUint32(8,!0),9,4243563512),o=u(o,i,n,r,e.getUint32(28,!0),14,1735328473),n=l(n,r=u(r,o,i,n,e.getUint32(48,!0),20,2368359562),o,i,e.getUint32(20,!0),4,4294588738),i=l(i,n,r,o,e.getUint32(32,!0),11,2272392833),o=l(o,i,n,r,e.getUint32(44,!0),16,1839030562),r=l(r,o,i,n,e.getUint32(56,!0),23,4259657740),n=l(n,r,o,i,e.getUint32(4,!0),4,2763975236),i=l(i,n,r,o,e.getUint32(16,!0),11,1272893353),o=l(o,i,n,r,e.getUint32(28,!0),16,4139469664),r=l(r,o,i,n,e.getUint32(40,!0),23,3200236656),n=l(n,r,o,i,e.getUint32(52,!0),4,681279174),i=l(i,n,r,o,e.getUint32(0,!0),11,3936430074),o=l(o,i,n,r,e.getUint32(12,!0),16,3572445317),r=l(r,o,i,n,e.getUint32(24,!0),23,76029189),n=l(n,r,o,i,e.getUint32(36,!0),4,3654602809),i=l(i,n,r,o,e.getUint32(48,!0),11,3873151461),o=l(o,i,n,r,e.getUint32(60,!0),16,530742520),n=p(n,r=l(r,o,i,n,e.getUint32(8,!0),23,3299628645),o,i,e.getUint32(0,!0),6,4096336452),i=p(i,n,r,o,e.getUint32(28,!0),10,1126891415),o=p(o,i,n,r,e.getUint32(56,!0),15,2878612391),r=p(r,o,i,n,e.getUint32(20,!0),21,4237533241),n=p(n,r,o,i,e.getUint32(48,!0),6,1700485571),i=p(i,n,r,o,e.getUint32(12,!0),10,2399980690),o=p(o,i,n,r,e.getUint32(40,!0),15,4293915773),r=p(r,o,i,n,e.getUint32(4,!0),21,2240044497),n=p(n,r,o,i,e.getUint32(32,!0),6,1873313359),i=p(i,n,r,o,e.getUint32(60,!0),10,4264355552),o=p(o,i,n,r,e.getUint32(24,!0),15,2734768916),r=p(r,o,i,n,e.getUint32(52,!0),21,1309151649),n=p(n,r,o,i,e.getUint32(16,!0),6,4149444226),i=p(i,n,r,o,e.getUint32(44,!0),10,3174756917),o=p(o,i,n,r,e.getUint32(8,!0),15,718787259),r=p(r,o,i,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=r+t[1]&4294967295,t[2]=o+t[2]&4294967295,t[3]=i+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":81}],14:[function(e,t,n){var r=e("buffer/").Buffer,o=e("./browserHashUtils");new Uint32Array([1518500249,1859775393,-1894007588,-899497514]),Math.pow(2,53);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}t.exports=i,i.BLOCK_SIZE=64,i.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=(e=o.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n14||14===this.offset&&this.shift<24)&&this.processBlock(),this.offset=14,this.shift=24,this.write(0),this.write(0),this.write(this.totalLength>0xffffffffff?this.totalLength/1099511627776:0),this.write(this.totalLength>4294967295?this.totalLength/4294967296:0);for(var t=24;t>=0;t-=8)this.write(this.totalLength>>t);var n=new r(20),o=new DataView(n.buffer);return o.setUint32(0,this.h0,!1),o.setUint32(4,this.h1,!1),o.setUint32(8,this.h2,!1),o.setUint32(12,this.h3,!1),o.setUint32(16,this.h4,!1),e?n.toString(e):n},i.prototype.processBlock=function(){for(var e=16;e<80;e++){var t=this.block[e-3]^this.block[e-8]^this.block[e-14]^this.block[e-16];this.block[e]=t<<1|t>>>31}var n,r,o=this.h0,i=this.h1,a=this.h2,c=this.h3,s=this.h4;for(e=0;e<80;e++){e<20?(n=c^i&(a^c),r=1518500249):e<40?(n=i^a^c,r=1859775393):e<60?(n=i&a|c&(i|a),r=2400959708):(n=i^a^c,r=3395469782);var u=(o<<5|o>>>27)+n+s+r+(0|this.block[e]);s=c,c=a,a=i<<30|i>>>2,i=o,o=u}for(this.h0=this.h0+o|0,this.h1=this.h1+i|0,this.h2=this.h2+a|0,this.h3=this.h3+c|0,this.h4=this.h4+s|0,this.offset=0,e=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":81}],15:[function(e,t,n){var r=e("buffer/").Buffer,o=e("./browserHashUtils"),i=64,a=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 s(){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=s,s.BLOCK_SIZE=i,s.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(o.isEmptyData(e))return this;var t=0,n=(e=o.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>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},s.prototype.digest=function(e){if(!this.finished){var t=8*this.bytesHashed,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),o=this.bufferLength;if(n.setUint8(this.bufferLength++,128),o%i>=56){for(var a=this.bufferLength;a>>24&255,c[4*a+1]=this.state[a]>>>16&255,c[4*a+2]=this.state[a]>>>8&255,c[4*a+3]=this.state[a]>>>0&255;return e?c.toString(e):c},s.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],r=t[1],o=t[2],c=t[3],s=t[4],u=t[5],l=t[6],p=t[7],f=0;f>>17|d<<15)^(d>>>19|d<<13)^d>>>10,g=((d=this.temp[f-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3;this.temp[f]=(h+this.temp[f-7]|0)+(g+this.temp[f-16]|0)}var m=(((s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7))+(s&u^~s&l)|0)+(p+(a[f]+this.temp[f]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&r^n&o^r&o)|0;p=l,l=u,u=s,s=c+m|0,c=o,o=r,r=n,n=m+v|0}t[0]+=n,t[1]+=r,t[2]+=o,t[3]+=c,t[4]+=s,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 r=e("./core");if(t.exports=r,e("./credentials"),e("./credentials/credential_provider_chain"),e("./credentials/temporary_credentials"),e("./credentials/chainable_temporary_credentials"),e("./credentials/web_identity_credentials"),e("./credentials/cognito_identity_credentials"),e("./credentials/saml_credentials"),r.XML.Parser=e("./xml/browser_parser"),e("./http/xhr"),"undefined"===typeof o)var o={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 r,o=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),o.Config=o.util.inherit({constructor:function(e){void 0===e&&(e={}),e=this.extractCredentials(e),o.util.each.call(this,this.keys,(function(t,n){this.set(t,e[t],n)}))},getCredentials:function(e){var t=this;function n(n){e(n,n?null:t.credentials)}function r(e,t){return new o.util.error(t||new Error,{code:"CredentialsError",message:e,name:"CredentialsError"})}t.credentials?"function"===typeof t.credentials.get?t.credentials.get((function(e){e&&(e=r("Could not load credentials from "+t.credentials.constructor.name,e)),n(e)})):function(){var e=null;t.credentials.accessKeyId&&t.credentials.secretAccessKey||(e=r("Missing credentials")),n(e)}():t.credentialProvider?t.credentialProvider.resolve((function(e,o){e&&(e=r("Could not load credentials from any providers",e)),t.credentials=o,n(e)})):n(r("No credentials to load"))},update:function(e,t){t=t||!1,e=this.extractCredentials(e),o.util.each.call(this,e,(function(e,n){(t||Object.prototype.hasOwnProperty.call(this.keys,e)||o.Service.hasService(e))&&this.set(e,n)}))},loadFromPath:function(e){this.clear();var t=JSON.parse(o.util.readFileSync(e)),n=new o.FileSystemCredentials(e),r=new o.CredentialProviderChain;return r.providers.unshift(n),r.resolve((function(e,n){if(e)throw e;t.credentials=n})),this.constructor(t),this},clear:function(){o.util.each.call(this,this.keys,(function(e){delete this[e]})),this.set("credentials",void 0),this.set("credentialProvider",void 0)},set:function(e,t,n){void 0===t?(void 0===n&&(n=this.keys[e]),this[e]="function"===typeof n?n.call(this):n):"httpOptions"===e&&this[e]?this[e]=o.util.merge(this[e],t):this[e]=t},keys:{credentials:null,credentialProvider:null,region:null,logger:null,apiVersions:{},apiVersion:null,endpoint:void 0,httpOptions:{timeout:12e4},maxRetries:void 0,maxRedirects:10,paramValidation:!0,sslEnabled:!0,s3ForcePathStyle:!1,s3BucketEndpoint:!1,s3DisableBodySigning:!0,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=o.util.copy(e)).credentials=new o.Credentials(e)),e},setPromisesDependency:function(e){r=e,null===e&&"function"===typeof Promise&&(r=Promise);var t=[o.Request,o.Credentials,o.CredentialProviderChain];o.S3&&(t.push(o.S3),o.S3.ManagedUpload&&t.push(o.S3.ManagedUpload)),o.util.addPromises(t,r)},getPromisesDependency:function(){return r}}),o.config=new o.Config},{"./core":18,"./credentials":19,"./credentials/credential_provider_chain":22}],18:[function(e,t,n){var r={util:e("./util")};({}).toString(),t.exports=r,r.util.update(r,{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"),r.events=new r.SequentialExecutor,r.util.memoizedProperty(r,"endpointCache",(function(){return new r.EndpointCache(r.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 r=e("./core");r.Credentials=r.util.inherit({constructor:function(){if(r.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"===typeof arguments[0]){var e=arguments[0].credentials||arguments[0];this.accessKeyId=e.accessKeyId,this.secretAccessKey=e.secretAccessKey,this.sessionToken=e.sessionToken}else this.accessKeyId=arguments[0],this.secretAccessKey=arguments[1],this.sessionToken=arguments[2]},expiryWindow:15,needsRefresh:function(){var e=r.util.date.getDate().getTime(),t=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&t>this.expireTime)||(this.expired||!this.accessKeyId||!this.secretAccessKey)},get:function(e){var t=this;this.needsRefresh()?this.refresh((function(n){n||(t.expired=!1),e&&e(n)})):e&&e()},refresh:function(e){this.expired=!1,e()},coalesceRefresh:function(e,t){var n=this;1===n.refreshCallbacks.push(e)&&n.load((function(e){r.util.arrayEach(n.refreshCallbacks,(function(n){t?n(e):r.util.defer((function(){n(e)}))})),n.refreshCallbacks.length=0}))},load:function(e){e()}}),r.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=r.util.promisifyMethod("get",e),this.prototype.refreshPromise=r.util.promisifyMethod("refresh",e)},r.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},r.util.addPromises(r.Credentials)},{"./core":18}],20:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.ChainableTemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=r.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!==typeof e.tokenCodeFn)throw new r.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=r.util.merge({params:t,credentials:e.masterCredentials||r.config.credentials},e.stsConfig||{});this.service=new o(n)},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this,n=t.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode((function(r,o){var i={};r?e(r):(o&&(i.TokenCode=o),t.service[n](i,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)})))}))},getTokenCode:function(e){var t=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,(function(n,o){if(n){var i=n;return n instanceof Error&&(i=n.message),void e(r.util.error(new Error("Error fetching MFA token: "+i),{code:t.errorCode}))}e(null,o)})):e(null)}})},{"../../clients/sts":8,"../core":18}],21:[function(e,t,n){var r=e("../core"),o=e("../../clients/cognitoidentity"),i=e("../../clients/sts");r.CognitoIdentityCredentials=r.util.inherit(r.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=r.util.copy(t||{}),this.loadCachedId();var n=this;Object.defineProperty(this,"identityId",{get:function(){return n.loadCachedId(),n._identityId||n.params.IdentityId},set:function(e){n._identityId=e}})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.data=null,t._identityId=null,t.getId((function(n){n?(t.clearIdOnNotAuthorized(n),e(n)):t.params.RoleArn?t.getCredentialsFromSTS(e):t.getCredentialsForIdentity(e)}))},clearCachedId:function(){this._identityId=null,delete this.params.IdentityId;var e=this.params.IdentityPoolId,t=this.params.LoginId||"";delete this.storage[this.localStorageKey.id+e+t],delete this.storage[this.localStorageKey.providers+e+t]},clearIdOnNotAuthorized:function(e){"NotAuthorizedException"==e.code&&this.clearCachedId()},getId:function(e){var t=this;if("string"===typeof t.params.IdentityId)return e(null,t.params.IdentityId);t.cognito.getId((function(n,r){!n&&r.IdentityId?(t.params.IdentityId=r.IdentityId,e(null,r.IdentityId)):e(n)}))},loadCredentials:function(e,t){e&&t&&(t.expired=!1,t.accessKeyId=e.Credentials.AccessKeyId,t.secretAccessKey=e.Credentials.SecretKey,t.sessionToken=e.Credentials.SessionToken,t.expireTime=e.Credentials.Expiration)},getCredentialsForIdentity:function(e){var t=this;t.cognito.getCredentialsForIdentity((function(n,r){n?t.clearIdOnNotAuthorized(n):(t.cacheId(r),t.data=r,t.loadCredentials(t.data,t)),e(n)}))},getCredentialsFromSTS:function(e){var t=this;t.cognito.getOpenIdToken((function(n,r){n?(t.clearIdOnNotAuthorized(n),e(n)):(t.cacheId(r),t.params.WebIdentityToken=r.Token,t.webIdentityCredentials.refresh((function(n){n||(t.data=t.webIdentityCredentials.data,t.sts.credentialsFrom(t.data,t)),e(n)})))}))},loadCachedId:function(){var e=this;if(r.util.isBrowser()&&!e.params.IdentityId){var t=e.getStorage("id");if(t&&e.params.Logins){var n=Object.keys(e.params.Logins);0!==(e.getStorage("providers")||"").split(",").filter((function(e){return-1!==n.indexOf(e)})).length&&(e.params.IdentityId=t)}else t&&(e.params.IdentityId=t)}},createClients:function(){var e=this._clientConfig;if(this.webIdentityCredentials=this.webIdentityCredentials||new r.WebIdentityCredentials(this.params,e),!this.cognito){var t=r.util.merge({},e);t.params=this.params,this.cognito=new o(t)}this.sts=this.sts||new i(e)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,r.util.isBrowser()&&(this.setStorage("id",e.IdentityId),this.params.Logins&&this.setStorage("providers",Object.keys(this.params.Logins).join(",")))},getStorage:function(e){return this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]},setStorage:function(e,t){try{this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]=t}catch(n){}},storage:function(){try{var e=r.util.isBrowser()&&null!==window.localStorage&&"object"===typeof window.localStorage?window.localStorage:{};return e["aws.test-storage"]="foobar",delete e["aws.test-storage"],e}catch(t){return{}}}()})},{"../../clients/cognitoidentity":7,"../../clients/sts":8,"../core":18}],22:[function(e,t,n){var r=e("../core");r.CredentialProviderChain=r.util.inherit(r.Credentials,{constructor:function(e){this.providers=e||r.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var t=this;if(0===t.providers.length)return e(new Error("No providers")),t;if(1===t.resolveCallbacks.push(e)){var n=0,o=t.providers.slice(0);!function e(i,a){if(!i&&a||n===o.length)return r.util.arrayEach(t.resolveCallbacks,(function(e){e(i,a)})),void(t.resolveCallbacks.length=0);var c=o[n++];(a="function"===typeof c?c.call():c).get?a.get((function(t){e(t,t?null:a)})):e(null,a)}()}return t}}),r.CredentialProviderChain.defaultProviders=[],r.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=r.util.promisifyMethod("resolve",e)},r.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},r.util.addPromises(r.CredentialProviderChain)},{"../core":18}],23:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.SAMLCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithSAML((function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":18}],24:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.TemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.loadMasterCredentials(t),this.expired=!0,this.params=e||{},this.params.RoleArn&&(this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials")},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.masterCredentials.get((function(){t.service.config.credentials=t.masterCredentials,(t.params.RoleArn?t.service.assumeRole:t.service.getSessionToken).call(t.service,(function(n,r){n||t.service.credentialsFrom(r,t),e(n)}))}))},loadMasterCredentials:function(e){for(this.masterCredentials=e||r.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!==typeof this.masterCredentials.get&&(this.masterCredentials=new r.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":18}],25:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.WebIdentityCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=r.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(e){var t=this;t.createClients(),t.service.assumeRoleWithWebIdentity((function(n,r){t.data=null,n||(t.data=r,t.service.credentialsFrom(r,t)),e(n)}))},createClients:function(){if(!this.service){var e=r.util.merge({},this._clientConfig);e.params=this.params,this.service=new o(e)}}})},{"../../clients/sts":8,"../core":18}],26:[function(e,t,n){(function(n){(function(){var r=e("./core"),o=e("./util"),i=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function a(e){var t=e.service,n=t.api||{},r=(n.operations,{});return t.config.region&&(r.region=t.config.region),n.serviceId&&(r.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(r.accessKeyId=t.config.credentials.accessKeyId),r}function c(e,t,n){n&&void 0!==t&&null!==t&&"structure"===n.type&&n.required&&n.required.length>0&&o.arrayEach(n.required,(function(r){var o=n.members[r];if(!0===o.endpointDiscoveryId){var i=o.isLocationName?o.name:r;e[i]=String(t[r])}else c(e,t[r],o)}))}function s(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=s(e,i?i.input:void 0),u=a(e);Object.keys(c).length>0&&(u=o.update(u,c),i&&(u.operation=i.name));var l=r.endpointCache.get(u);if(!l||1!==l.length||""!==l[0].Address)if(l&&l.length>0)e.httpRequest.updateEndpoint(l[0].Address);else{var p=t.makeRequest(n.endpointOperation,{Operation:i.name,Identifiers:c});f(p),p.removeListener("validate",r.EventListeners.Core.VALIDATE_PARAMETERS),p.removeListener("retry",r.EventListeners.Core.RETRY_CHECK),r.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}]),p.send((function(e,t){t&&t.Endpoints?r.endpointCache.put(u,t.Endpoints):e&&r.endpointCache.put(u,[{Address:"",CachePeriodInMinutes:1}])}))}}var l={};function p(e,t){var n=e.service,i=n.api,c=i.operations?i.operations[e.operation]:void 0,u=c?c.input:void 0,p=s(e,u),d=a(e);Object.keys(p).length>0&&(d=o.update(d,p),c&&(d.operation=c.name));var h=r.EndpointCache.getKeyString(d),g=r.endpointCache.get(h);if(g&&1===g.length&&""===g[0].Address)return l[h]||(l[h]=[]),void l[h].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",r.EventListeners.Core.VALIDATE_PARAMETERS),f(m),r.endpointCache.put(h,[{Address:"",CachePeriodInMinutes:60}]),m.send((function(n,i){if(n){var a={code:"EndpointDiscoveryException",message:"Request cannot be fulfilled without specifying an endpoint",retryable:!1};if(e.response.error=o.error(n,a),r.endpointCache.remove(d),l[h]){var c=l[h];o.arrayEach(c,(function(e){e.request.response.error=o.error(n,a),e.callback()})),delete l[h]}}else if(i&&(r.endpointCache.put(h,i.Endpoints),e.httpRequest.updateEndpoint(i.Endpoints[0].Address),l[h])){c=l[h];o.arrayEach(c,(function(e){e.request.httpRequest.updateEndpoint(i.Endpoints[0].Address),e.callback()})),delete l[h]}t()}))}}function f(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=s(i,c[i.operation]?c[i.operation].input:void 0),l=a(i);Object.keys(u).length>0&&(l=o.update(l,u),c[i.operation]&&(l.operation=c[i.operation].name)),r.endpointCache.remove(l)}}function h(e){return["false","0"].indexOf(e)>=0}t.exports={discoverEndpoint:function(e,t){var a=e.service||{};if(function(e){if(e._originalConfig&&e._originalConfig.endpoint&&!0===e._originalConfig.endpointDiscoveryEnabled)throw o.error(new Error,{code:"ConfigurationException",message:"Custom endpoint is supplied; endpointDiscoveryEnabled must not be true."});var t=r.config[e.serviceIdentifier]||{};return Boolean(r.config.endpoint||t.endpoint||e._originalConfig&&e._originalConfig.endpoint)}(a)||e.isPresigned())return t();if(!function(e){if(!0===(e.service||{}).config.endpointDiscoveryEnabled)return!0;if(o.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,r=Math.abs(Math.round(e));n>-1&&r>0;n--,r/=256)t[n]=r;return e<0&&a(t),new i(t)},i.prototype.valueOf=function(){var e=this.bytes.slice(0),t=128&e[0];return t&&a(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 r=e("./parse-message").parseMessage;t.exports={parseEvent:function(e,t,n){var o=r(t),i=o.headers[":message-type"];if(i){if("error"===i.value)throw function(e){var t=e.headers[":error-code"],n=e.headers[":error-message"],r=new Error(n.value||n);return r.code=r.name=t.value||t,r}(o);if("event"!==i.value)return}var a=o.headers[":event-type"],c=n.members[a.value];if(c){var s={},u=c.eventPayloadMemberName;if(u){var l=c.members[u];"binary"===l.type?s[u]=o.body:s[u]=e.parse(o.body.toString(),l)}for(var p=c.eventHeaderMemberNames,f=0;f=0)return e.httpRequest.headers["X-Amz-Content-Sha256"]="UNSIGNED-PAYLOAD",t();r.util.computeSha256(i,(function(n,r){n?t(n):(e.httpRequest.headers["X-Amz-Content-Sha256"]=r,t())}))}else t()}})),e("SET_CONTENT_LENGTH","afterBuild",(function(e){var t=function(e){if(!e.service.api.operations)return"";var t=e.service.api.operations[e.operation];return t?t.authtype:""}(e),n=r.util.getRequestPayloadShape(e);if(void 0===e.httpRequest.headers["Content-Length"])try{var o=r.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=o}catch(i){if(n&&n.isStreaming){if(n.requiresLength)throw i;if(t.indexOf("unsigned-body")>=0)return void(e.httpRequest.headers["Transfer-Encoding"]="chunked");throw i}throw i}})),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 r.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,o){n.httpResponse.statusCode=e,n.httpResponse.statusMessage=o,n.httpResponse.headers=t,n.httpResponse.body=r.util.buffer.toBuffer(""),n.httpResponse.buffers=[],n.httpResponse.numBytes=0;var i=t.date||t.Date,a=n.request.service;if(i){var c=Date.parse(i);a.config.correctClockSkew&&a.isClockSkewed(c)&&a.applyClockOffset(c)}})),e("HTTP_DATA","httpData",(function(e,t){if(e){if(r.util.isNode()){t.httpResponse.numBytes+=e.length;var n=t.httpResponse.headers["content-length"],o={loaded:t.httpResponse.numBytes,total:n};t.request.emit("httpDownloadProgress",[o,t])}t.httpResponse.buffers.push(r.util.buffer.toBuffer(e))}})),e("HTTP_DONE","httpDone",(function(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var t=r.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 r.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&&!p&&(s.statusCode=l.status,s.headers=a.parseHeaders(l.getAllResponseHeaders()),s.emit("headers",s.statusCode,s.headers,l.statusText),p=!0),this.readyState===this.DONE&&a.finishRequest(l,s)}),!1),l.upload.addEventListener("progress",(function(e){s.emit("sendProgress",e)})),l.addEventListener("progress",(function(e){s.emit("receiveProgress",e)}),!1),l.addEventListener("timeout",(function(){i(r.util.error(new Error("Timeout"),{code:"TimeoutError"}))}),!1),l.addEventListener("error",(function(){i(r.util.error(new Error("Network Failure"),{code:"NetworkingError"}))}),!1),l.addEventListener("abort",(function(){i(r.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))}),!1),n(s),l.open(e.method,u,!1!==t.xhrAsync),r.util.each(e.headers,(function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&l.setRequestHeader(e,t)})),t.timeout&&!1!==t.xhrAsync&&(l.timeout=t.timeout),t.xhrWithCredentials&&(l.withCredentials=!0);try{l.responseType="arraybuffer"}catch(f){}try{e.body?l.send(e.body):l.send()}catch(d){if(!e.body||"object"!==typeof e.body.buffer)throw d;l.send(e.body.buffer)}return s},parseHeaders:function(e){var t={};return r.util.arrayEach(e.split(/\r?\n/),(function(e){var n=e.split(":",1)[0],r=e.substring(n.length+2);n.length>0&&(t[n.toLowerCase()]=r)})),t},finishRequest:function(e,t){var n;if("arraybuffer"===e.responseType&&e.response){var o=e.response;n=new r.util.Buffer(o.byteLength);for(var i=new Uint8Array(o),a=0;a-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 d(){c.apply(this,arguments),this.toType=function(e){var t=o.base64.decode(e);if(this.isSensitive&&o.isNode()&&"function"===typeof o.Buffer.alloc){var n=o.Buffer.alloc(t.length,t);t.fill(0),t=n}return t},this.toWireFormat=o.base64.encode}function h(){d.apply(this,arguments)}function g(){c.apply(this,arguments),this.toType=function(e){return"boolean"===typeof e?e:null===e||void 0===e?null:"true"===e}}c.normalizedTypes={character:"string",double:"float",long:"integer",short:"integer",biginteger:"integer",bigdecimal:"float",blob:"binary"},c.types={structure:u,list:l,map:p,boolean:g,timestamp:function(e){var t=this;if(c.apply(this,arguments),e.timestampFormat)i(this,"timestampFormat",e.timestampFormat);else if(t.isTimestampFormatSet&&this.timestampFormat)i(this,"timestampFormat",this.timestampFormat);else if("header"===this.location)i(this,"timestampFormat","rfc822");else if("querystring"===this.location)i(this,"timestampFormat","iso8601");else if(this.api)switch(this.api.protocol){case"json":case"rest-json":i(this,"timestampFormat","unixTimestamp");break;case"rest-xml":case"query":case"ec2":i(this,"timestampFormat","iso8601")}this.toType=function(e){return null===e||void 0===e?null:"function"===typeof e.toUTCString?e:"string"===typeof e||"number"===typeof e?o.date.parseTimestamp(e):null},this.toWireFormat=function(e){return o.date.format(e,t.timestampFormat)}},float:function(){c.apply(this,arguments),this.toType=function(e){return null===e||void 0===e?null:parseFloat(e)},this.toWireFormat=this.toType},integer:function(){c.apply(this,arguments),this.toType=function(e){return null===e||void 0===e?null:parseInt(e,10)},this.toWireFormat=this.toType},string:f,base64:h,binary:d},c.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},c.create=function(e,t,n){if(e.isShape)return e;var r=c.resolve(e,t);if(r){var o=Object.keys(e);t.documentation||(o=o.filter((function(e){return!e.match(/documentation/)})));var i=function(){r.constructor.call(this,e,t,n)};return i.prototype=r,new i}e.type||(e.members?e.type="structure":e.member?e.type="list":e.key?e.type="map":e.type="string");var a=e.type;if(c.normalizedTypes[e.type]&&(e.type=c.normalizedTypes[e.type]),c.types[e.type])return new c.types[e.type](e,t,n);throw new Error("Unrecognized shape type: "+a)},c.shapes={StructureShape:u,ListShape:l,MapShape:p,StringShape:f,BooleanShape:g,Base64Shape:h},t.exports=c},{"../util":71,"./collection":39}],44:[function(e,t,n){var r=e("./core");r.ParamValidator=r.util.inherit({constructor:function(e){!0!==e&&void 0!==e||(e={min:!0}),this.validation=e},validate:function(e,t,n){if(this.errors=[],this.validateMember(e,t||{},n||"params"),this.errors.length>1){var o=this.errors.join("\n* ");throw o="There were "+this.errors.length+" validation errors:\n* "+o,r.util.error(new Error(o),{code:"MultipleValidationErrors",errors:this.errors})}if(1===this.errors.length)throw this.errors[0];return!0},fail:function(e,t){this.errors.push(r.util.error(new Error(t),{code:e}))},validateStructure:function(e,t,n){var r;this.validateType(t,n,["object"],"structure");for(var o=0;e.required&&o= 1, but found "'+t+'" for '+n)},validatePattern:function(e,t,n){this.validation.pattern&&void 0!==e.pattern&&(new RegExp(e.pattern).test(t)||this.fail("PatternMatchError",'Provided value "'+t+'" does not match regex pattern /'+e.pattern+"/ for "+n))},validateRange:function(e,t,n,r){this.validation.min&&void 0!==e.min&&t= "+e.min+", but found "+t+" for "+n),this.validation.max&&void 0!==e.max&&t>e.max&&this.fail("MaxRangeError","Expected "+r+" <= "+e.max+", but found "+t+" for "+n)},validateEnum:function(e,t,n){this.validation.enum&&void 0!==e.enum&&-1===e.enum.indexOf(t)&&this.fail("EnumError","Found string value of "+t+", but expected "+e.enum.join("|")+" for "+n)},validateType:function(e,t,n,o){if(null===e||void 0===e)return!1;for(var i=!1,a=0;a63)throw r.error(new Error,{code:"ValidationError",message:"Hostname label length should be between 1 to 63 characters, inclusive."});if(!n.test(e))throw o.util.error(new Error,{code:"ValidationError",message:e+" is not hostname compatible."})}))}(e.httpRequest.endpoint.hostname)}return e}}},{"../core":18,"../util":71}],46:[function(e,t,n){var r=e("../util"),o=e("../json/builder"),i=e("../json/parser"),a=e("./helpers").populateHostPrefix;t.exports={buildRequest:function(e){var t=e.httpRequest,n=e.service.api,r=n.targetPrefix+"."+n.operations[e.operation].name,i=n.jsonVersion||"1.0",c=n.operations[e.operation].input,s=new o;1===i&&(i="1.0"),t.body=s.build(e.params||{},c),t.headers["Content-Type"]="application/x-amz-json-"+i,t.headers["X-Amz-Target"]=r,a(e)},extractError:function(e){var t={},n=e.httpResponse;if(t.code=n.headers["x-amzn-errortype"]||"UnknownError","string"===typeof t.code&&(t.code=t.code.split(":")[0]),n.body.length>0)try{var o=JSON.parse(n.body.toString());(o.__type||o.code)&&(t.code=(o.__type||o.code).split("#").pop()),"RequestEntityTooLarge"===t.code?t.message="Request body must be less than 1 MB":t.message=o.message||o.Message||null}catch(o){t.statusCode=n.statusCode,t.message=n.statusMessage}else t.statusCode=n.statusCode,t.message=n.statusCode.toString();e.error=r.error(new Error,t)},extractData:function(e){var t=e.httpResponse.body.toString()||"{}";if(!1===e.request.service.config.convertResponseTypes)e.data=JSON.parse(t);else{var n=e.request.service.api.operations[e.request.operation].output||{},r=new i;e.data=r.parse(t,n)}}}},{"../json/builder":36,"../json/parser":37,"../util":71,"./helpers":45}],47:[function(e,t,n){var r=e("../core"),o=e("../util"),i=e("../query/query_param_serializer"),a=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=o.queryParamsToString(n.params),c(e)},extractError:function(e){var t,n=e.httpResponse.body.toString();if(n.match("=0?"&":"?";var s=[];r.arrayEach(Object.keys(a).sort(),(function(e){Array.isArray(a[e])||(a[e]=[a[e]]);for(var t=0;t0){var p=(t=new r.XML.Parser).parse(a.toString(),s);o.update(e.data,p)}}}},{"../core":18,"../util":71,"./rest":48}],51:[function(e,t,n){var r=e("../util");function o(){}function i(e){return e.isQueryName||"ec2"!==e.api.protocol?e.name:e.name[0].toUpperCase()+e.name.substr(1)}function a(e,t,n,o){r.each(n.members,(function(n,r){var a=t[n];if(null!==a&&void 0!==a){var s=i(r);c(s=e?e+"."+s:s,a,r,o)}}))}function c(e,t,n,o){null!==t&&void 0!==t&&("structure"===n.type?a(e,t,n,o):"list"===n.type?function(e,t,n,o){var a=n.member||{};0!==t.length?r.arrayEach(t,(function(t,r){var s="."+(r+1);if("ec2"===n.api.protocol)s+="";else if(n.flattened){if(a.name){var u=e.split(".");u.pop(),u.push(i(a)),e=u.join(".")}}else s="."+(a.name?a.name:"member")+s;c(e+s,t,a,o)})):o.call(this,e,null)}(e,t,n,o):"map"===n.type?function(e,t,n,o){var i=1;r.each(t,(function(t,r){var a=(n.flattened?".":".entry.")+i+++".",s=a+(n.key.name||"key"),u=a+(n.value.name||"value");c(e+s,t,n.key,o),c(e+u,r,n.value,o)}))}(e,t,n,o):o(e,n.toWireFormat(t).toString()))}o.prototype.serialize=function(e,t,n){a("",e,t,n)},t.exports=o},{"../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 r=e("./util"),o=e("./region_config_data.json");function i(e,t){r.each(t,(function(t,n){"globalEndpoint"!==t&&(void 0!==e.config[t]&&null!==e.config[t]||(e.config[t]=n))}))}t.exports=function(e){for(var t=function(e){var t=e.config.region,n=function(e){if(!e)return null;var t=e.split("-");return t.length<3?null:t.slice(0,t.length-2).join("-")+"-*"}(t),r=e.api.endpointPrefix;return[[t,r],[n,r],[t,"*"],[n,"*"],["*",r],["*","*"]].map((function(e){return e[0]&&e[1]?e.join("/"):null}))}(e),n=0;n=0){s=!0;var u=0}var l=function(){s&&u!==c?o.emit("error",n.util.error(new Error("Stream content length mismatch. Received "+u+" of "+c+" bytes."),{code:"StreamContentLengthMismatch"})):2===n.HttpClient.streamsApiVersion?o.end():o.emit("end")},p=a.httpResponse.createUnbufferedStream();if(2===n.HttpClient.streamsApiVersion)if(s){var f=new e.PassThrough;f._write=function(t){return t&&t.length&&(u+=t.length),e.PassThrough.prototype._write.apply(this,arguments)},f.on("end",l),o.on("error",(function(e){s=!1,p.unpipe(f),f.emit("end"),f.end()})),p.pipe(f).pipe(o,{end:!1})}else p.pipe(o);else s&&p.on("data",(function(e){e&&e.length&&(u+=e.length)})),p.on("data",(function(e){o.emit("data",e)})),p.on("end",l);p.on("error",(function(e){s=!1,o.emit("error",e)}))}})),o},emitEvent:function(e,t,r){"function"===typeof t&&(r=t,t=null),r||(r=function(){}),t||(t=this.eventParameters(e,this.response)),n.SequentialExecutor.prototype.emit.call(this,e,t,(function(e){e&&(this.response.error=e),r.call(this,e)}))},eventParameters:function(e){switch(e){case"restart":case"validate":case"sign":case"build":case"afterValidate":case"afterBuild":return[this];case"error":return[this.response.error,this.response];default:return[this.response]}},presign:function(e,t){return t||"function"!==typeof e||(t=e,e=null),(new n.Signers.Presign).sign(this.toGet(),e,t)},isPresigned:function(){return Object.prototype.hasOwnProperty.call(this.httpRequest.headers,"presigned-expires")},toUnauthenticated:function(){return this._unAuthenticated=!0,this.removeListener("validate",n.EventListeners.Core.VALIDATE_CREDENTIALS),this.removeListener("sign",n.EventListeners.Core.SIGN),this},toGet:function(){return"query"!==this.service.api.protocol&&"ec2"!==this.service.api.protocol||(this.removeListener("build",this.buildAsGet),this.addListener("build",this.buildAsGet)),this},buildAsGet:function(e){e.httpRequest.method="GET",e.httpRequest.path=e.service.endpoint.path+"?"+e.httpRequest.body,e.httpRequest.body="",delete e.httpRequest.headers["Content-Length"],delete e.httpRequest.headers["Content-Type"]},haltHandlersOnError:function(){this._haltHandlersOnError=!0}}),n.Request.addPromisesToClass=function(e){this.prototype.promise=function(){var t=this;return this.httpRequest.appendToUserAgent("promise"),new e((function(e,n){t.on("complete",(function(t){t.error?n(t.error):e(Object.defineProperty(t.data||{},"$response",{value:t}))})),t.runTo()}))}},n.Request.deletePromisesFromClass=function(){delete this.prototype.promise},n.util.addPromises(n.Request),n.util.mixin(n.Request,n.SequentialExecutor)}).call(this)}).call(this,e("_process"))},{"./core":18,"./state_machine":70,_process:86,jmespath:85}],56:[function(e,t,n){var r=e("./core"),o=r.util.inherit,i=e("jmespath");function a(e){var t=e.request._waiter,n=t.config.acceptors,r=!1,o="retry";n.forEach((function(n){if(!r){var i=t.matchers[n.matcher];i&&i(e,n.expected,n.argument)&&(r=!0,o=n.state)}})),!r&&e.error&&(o="failure"),"success"===o?t.setSuccess(e):t.setError(e,"retry"===o)}r.ResourceWaiter=o({constructor:function(e,t){this.service=e,this.state=t,this.loadWaiterConfig(this.state)},service:null,state:null,config:null,matchers:{path:function(e,t,n){try{var r=i.search(e.data,n)}catch(o){return!1}return i.strictDeepEqual(r,t)},pathAll:function(e,t,n){try{var r=i.search(e.data,n)}catch(c){return!1}Array.isArray(r)||(r=[r]);var o=r.length;if(!o)return!1;for(var a=0;a-1&&n.splice(o,1)}return this},removeAllListeners:function(e){return e?delete this._events[e]:this._events={},this},emit:function(e,t,n){n||(n=function(){});var r=this.listeners(e),o=r.length;return this.callListeners(r,t,n),o>0},callListeners:function(e,t,n,o){var i=this,a=o||null;function c(o){if(o&&(a=r.util.error(a||new Error,o),i._haltHandlersOnError))return n.call(i,a);i.callListeners(e,t,n,a)}for(;e.length>0;){var s=e.shift();if(s._isAsync)return void s.apply(i,t.concat([c]));try{s.apply(i,t)}catch(u){a=r.util.error(a||new Error,u)}if(a&&i._haltHandlersOnError)return void n.call(i,a)}n.call(i,a)},addListeners:function(e){var t=this;return e._events&&(e=e._events),r.util.each(e,(function(e,n){"function"===typeof n&&(n=[n]),r.util.arrayEach(n,(function(n){t.on(e,n)}))})),t},addNamedListener:function(e,t,n,r){return this[e]=n,this.addListener(t,n,r),this},addNamedAsyncListener:function(e,t,n,r){return n._isAsync=!0,this.addNamedListener(e,t,n,r)},addNamedListeners:function(e){var t=this;return e((function(){t.addNamedListener.apply(t,arguments)}),(function(){t.addNamedAsyncListener.apply(t,arguments)})),this}}),r.SequentialExecutor.prototype.addListener=r.SequentialExecutor.prototype.on,t.exports=r.SequentialExecutor},{"./core":18}],59:[function(e,t,n){(function(n){(function(){var r=e("./core"),o=e("./model/api"),i=e("./region_config"),a=r.util.inherit,c=0;r.Service=a({constructor:function(e){if(!this.loadServiceClass)throw r.util.error(new Error,"Service must be constructed with `new' operator");var t=this.loadServiceClass(e||{});if(t){var n=r.util.copy(e),o=new t(e);return Object.defineProperty(o,"_originalConfig",{get:function(){return n},enumerable:!1,configurable:!0}),o._clientId=++c,o}this.initialize(e)},initialize:function(e){var t=r.config[this.serviceIdentifier];if(this.config=new r.Config(r.config),t&&this.config.update(t,!0),e&&this.config.update(e,!0),this.validateService(),this.config.endpoint||i(this),this.config.endpoint=this.endpointFromTemplate(this.config.endpoint),this.setEndpoint(this.config.endpoint),r.SequentialExecutor.call(this),r.Service.addDefaultMonitoringListeners(this),(this.config.clientSideMonitoring||r.Service._clientSideMonitoring)&&this.publisher){var o=this.publisher;this.addNamedListener("PUBLISH_API_CALL","apiCall",(function(e){n.nextTick((function(){o.eventHandler(e)}))})),this.addNamedListener("PUBLISH_API_ATTEMPT","apiCallAttempt",(function(e){n.nextTick((function(){o.eventHandler(e)}))}))}},validateService:function(){},loadServiceClass:function(e){var t=e;if(r.util.isEmpty(this.api)){if(t.apiConfig)return r.Service.defineServiceApi(this.constructor,t.apiConfig);if(this.constructor.services){(t=new r.Config(r.config)).update(e,!0);var n=t.apiVersions[this.constructor.serviceIdentifier];return n=n||t.apiVersion,this.getLatestServiceClass(n)}return null}return null},getLatestServiceClass:function(e){return e=this.getLatestServiceVersion(e),null===this.constructor.services[e]&&r.Service.defineServiceApi(this.constructor,e),this.constructor.services[e]},getLatestServiceVersion:function(e){if(!this.constructor.services||0===this.constructor.services.length)throw new Error("No services defined on "+this.constructor.serviceIdentifier);if(e?r.util.isType(e,Date)&&(e=r.util.date.iso8601(e).split("T")[0]):e="latest",Object.hasOwnProperty(this.constructor.services,e))return e;for(var t=Object.keys(this.constructor.services).sort(),n=null,o=t.length-1;o>=0;o--)if("*"!==t[o][t[o].length-1]&&(n=t[o]),t[o].substr(0,10)<=e)return n;throw new Error("Could not find "+this.constructor.serviceIdentifier+" API to satisfy version constraint `"+e+"'")},api:{},defaultRetryCount:3,customizeRequests:function(e){if(e){if("function"!==typeof e)throw new Error("Invalid callback type '"+typeof e+"' provided in customizeRequests");this.customRequestHandler=e}else this.customRequestHandler=null},makeRequest:function(e,t,n){if("function"===typeof t&&(n=t,t=null),t=t||{},this.config.params){var o=this.api.operations[e];o&&(t=r.util.copy(t),r.util.each(this.config.params,(function(e,n){o.input.members[e]&&(void 0!==t[e]&&null!==t[e]||(t[e]=n))})))}var i=new r.Request(this,e,t);return this.addAllRequestListeners(i),this.attachMonitoringEmitter(i),n&&i.send(n),i},makeUnauthenticatedRequest:function(e,t,n){"function"===typeof t&&(n=t,t={});var r=this.makeRequest(e,t).toUnauthenticated();return n?r.send(n):r},waitFor:function(e,t,n){return new r.ResourceWaiter(this,e).wait(t,n)},addAllRequestListeners:function(e){for(var t=[r.events,r.EventListeners.Core,this.serviceInterface(),r.EventListeners.CorePost],n=0;n299?(o.code&&(n.FinalAwsException=o.code),o.message&&(n.FinalAwsExceptionMessage=o.message)):((o.code||o.name)&&(n.FinalSdkException=o.code||o.name),o.message&&(n.FinalSdkExceptionMessage=o.message))}return n},apiAttemptEvent:function(e){var t=e.service.api.operations[e.operation],n={Type:"ApiCallAttempt",Api:t?t.name:e.operation,Version:1,Service:e.service.api.serviceId||e.service.api.endpointPrefix,Fqdn:e.httpRequest.endpoint.hostname,UserAgent:e.httpRequest.getUserAgent()},r=e.response;return r.httpResponse.statusCode&&(n.HttpStatusCode=r.httpResponse.statusCode),!e._unAuthenticated&&e.service.config.credentials&&e.service.config.credentials.accessKeyId&&(n.AccessKey=e.service.config.credentials.accessKeyId),r.httpResponse.headers?(e.httpRequest.headers["x-amz-security-token"]&&(n.SessionToken=e.httpRequest.headers["x-amz-security-token"]),r.httpResponse.headers["x-amzn-requestid"]&&(n.XAmznRequestId=r.httpResponse.headers["x-amzn-requestid"]),r.httpResponse.headers["x-amz-request-id"]&&(n.XAmzRequestId=r.httpResponse.headers["x-amz-request-id"]),r.httpResponse.headers["x-amz-id-2"]&&(n.XAmzId2=r.httpResponse.headers["x-amz-id-2"]),n):n},attemptFailEvent:function(e){var t=this.apiAttemptEvent(e),n=e.response,r=n.error;return n.httpResponse.statusCode>299?(r.code&&(t.AwsException=r.code),r.message&&(t.AwsExceptionMessage=r.message)):((r.code||r.name)&&(t.SdkException=r.code||r.name),r.message&&(t.SdkExceptionMessage=r.message)),t},attachMonitoringEmitter:function(e){var t,n,o,i,a,c,s=0,u=this;e.on("validate",(function(){i=r.util.realClock.now(),c=Date.now()}),true),e.on("sign",(function(){n=r.util.realClock.now(),t=Date.now(),a=e.httpRequest.region,s++}),true),e.on("validateResponse",(function(){o=Math.round(r.util.realClock.now()-n)})),e.addNamedListener("API_CALL_ATTEMPT","success",(function(){var n=u.apiAttemptEvent(e);n.Timestamp=t,n.AttemptLatency=o>=0?o:0,n.Region=a,u.emit("apiCallAttempt",[n])})),e.addNamedListener("API_CALL_ATTEMPT_RETRY","retry",(function(){var i=u.attemptFailEvent(e);i.Timestamp=t,o=o||Math.round(r.util.realClock.now()-n),i.AttemptLatency=o>=0?o:0,i.Region=a,u.emit("apiCallAttempt",[i])})),e.addNamedListener("API_CALL","complete",(function(){var t=u.apiCallEvent(e);if(t.AttemptCount=s,!(t.AttemptCount<=0)){t.Timestamp=c;var n=Math.round(r.util.realClock.now()-i);t.Latency=n>=0?n:0;var o=e.response;"number"===typeof o.retryCount&&"number"===typeof o.maxRetries&&o.retryCount>=o.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t])}}))},setupRequestListeners:function(e){},getSignerClass:function(e){var t,n=null,o="";e&&(o=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:"");return t=this.config.signatureVersion?this.config.signatureVersion:"v4"===o||"v4-unsigned-body"===o?"v4":this.api.signatureVersion,r.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return r.EventListeners.Query;case"json":return r.EventListeners.Json;case"rest-json":return r.EventListeners.RestJson;case"rest-xml":return r.EventListeners.RestXml}if(this.api.protocol)throw new Error("Invalid service `protocol' "+this.api.protocol+" in API config")},successfulResponse:function(e){return e.httpResponse.statusCode<300},numRetries:function(){return void 0!==this.config.maxRetries?this.config.maxRetries:this.defaultRetryCount},retryDelays:function(e){return r.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 r.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(!n){if(t){var o=new Error;throw r.util.error(o,"No pagination configuration for "+e)}return null}return n}}),r.util.update(r.Service,{defineMethods:function(e){r.util.each(e.prototype.api.operations,(function(t){e.prototype[t]||("none"===e.prototype.api.operations[t].authtype?e.prototype[t]=function(e,n){return this.makeUnauthenticatedRequest(t,e,n)}:e.prototype[t]=function(e,n){return this.makeRequest(t,e,n)})}))},defineService:function(e,t,n){r.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var o=a(r.Service,n||{});if("string"===typeof e){r.Service.addVersions(o,t);var i=o.serviceIdentifier||e;o.serviceIdentifier=i}else o.prototype.api=e,r.Service.defineMethods(o);if(r.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&r.util.clientSideMonitoring){var c=r.util.clientSideMonitoring.Publisher,s=(0,r.util.clientSideMonitoring.configProvider)();this.prototype.publisher=new c(s),s.enabled&&(r.Service._clientSideMonitoring=!0)}return r.SequentialExecutor.call(o.prototype),r.Service.addDefaultMonitoringListeners(o.prototype),o},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;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,o)){var r=t.env.AWS_STS_REGIONAL_ENDPOINTS;this.validateRegionalEndpointsFlagValue(r,{code:"InvalidEnvironmentalVariable",message:'invalid AWS_STS_REGIONAL_ENDPOINTS environmental variable. Expect "legacy" or "regional". Got "'+t.env.AWS_STS_REGIONAL_ENDPOINTS+'".'})}var a={};try{a=n.util.getProfilesFromSharedConfig(n.util.iniLoader)[t.env.AWS_PROFILE||n.util.defaultProfile]}catch(s){}if(a&&Object.prototype.hasOwnProperty.call(a,i)){var c=a.sts_regional_endpoints;this.validateRegionalEndpointsFlagValue(c,{code:"InvalidConfiguration",message:'invalid sts_regional_endpoints profile config. Expect "legacy" or "regional". Got "'+a.sts_regional_endpoints+'".'})}}},optInRegionalEndpoint:function(){this.validateRegionalEndpointsFlag();var e=this.config;if("regional"===e.stsRegionalEndpoints){if(r(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 r=e("../core"),o=r.util.inherit,i="presigned-expires";function a(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===r.Signers.V4){if(t>604800){throw r.util.error(new Error,{code:"InvalidExpiryTime",message:"Presigning does not support expiry time greater than a week with SigV4 signing.",retryable:!1})}e.httpRequest.headers[i]=t}else{if(n!==r.Signers.S3)throw r.util.error(new Error,{message:"Presigning only supports S3 or SigV4 signing.",code:"UnsupportedSigner",retryable:!1});var o=e.service?e.service.getSkewCorrectedDate():r.util.date.getDate();e.httpRequest.headers[i]=parseInt(r.util.date.unixTimestamp(o)+t,10).toString()}}function c(e){var t=e.httpRequest.endpoint,n=r.util.urlParse(e.httpRequest.path),o={};n.search&&(o=r.util.queryStringParse(n.search.substr(1)));var a=e.httpRequest.headers.Authorization.split(" ");if("AWS"===a[0])a=a[1].split(":"),o.AWSAccessKeyId=a[0],o.Signature=a[1],r.util.each(e.httpRequest.headers,(function(e,t){e===i&&(e="Expires"),0===e.indexOf("x-amz-meta-")&&(delete o[e],e=e.toLowerCase()),o[e]=t})),delete e.httpRequest.headers[i],delete o.Authorization,delete o.Host;else if("AWS4-HMAC-SHA256"===a[0]){a.shift();var c=a.join(" ").match(/Signature=(.*?)(?:,|\s|\r?\n|$)/)[1];o["X-Amz-Signature"]=c,delete o.Expires}t.pathname=n.pathname,t.search=r.util.queryParamsToString(o)}r.Signers.Presign=o({sign:function(e,t,n){if(e.httpRequest.headers[i]=t||3600,e.on("build",a),e.on("sign",c),e.removeListener("afterBuild",r.EventListeners.Core.SET_CONTENT_LENGTH),e.removeListener("afterBuild",r.EventListeners.Core.COMPUTE_SHA256),e.emit("beforePresign",[e]),!n){if(e.build(),e.response.error)throw e.response.error;return r.util.urlFormat(e.httpRequest.endpoint)}e.build((function(){this.response.error?n(this.response.error):n(null,r.util.urlFormat(e.httpRequest.endpoint))}))}}),t.exports=r.Signers.Presign},{"../core":18}],63:[function(e,t,n){var r=e("../core"),o=r.util.inherit;r.Signers.RequestSigner=o({constructor:function(e){this.request=e},setServiceClientId:function(e){this.serviceClientId=e},getServiceClientId:function(){return this.serviceClientId}}),r.Signers.RequestSigner.getVersion=function(e){switch(e){case"v2":return r.Signers.V2;case"v3":return r.Signers.V3;case"s3v4":case"v4":return r.Signers.V4;case"s3":return r.Signers.S3;case"v3https":return r.Signers.V3Https}throw new Error("Unknown signing version "+e)},e("./v2"),e("./v3"),e("./v3https"),e("./v4"),e("./s3"),e("./presign")},{"../core":18,"./presign":62,"./s3":64,"./v2":65,"./v3":66,"./v3https":67,"./v4":68}],64:[function(e,t,n){var r=e("../core"),o=r.util.inherit;r.Signers.S3=o(r.Signers.RequestSigner,{subResources:{acl:1,accelerate:1,analytics:1,cors:1,lifecycle:1,delete:1,inventory:1,location:1,logging:1,metrics:1,notification:1,partNumber:1,policy:1,requestPayment:1,replication:1,restore:1,tagging:1,torrent:1,uploadId:1,uploads:1,versionId:1,versioning:1,versions:1,website:1},responseHeaders:{"response-content-type":1,"response-content-language":1,"response-expires":1,"response-cache-control":1,"response-content-disposition":1,"response-content-encoding":1},addAuthorization:function(e,t){this.request.headers["presigned-expires"]||(this.request.headers["X-Amz-Date"]=r.util.date.rfc822(t)),e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken);var n=this.sign(e.secretAccessKey,this.stringToSign()),o="AWS "+e.accessKeyId+":"+n;this.request.headers.Authorization=o},stringToSign:function(){var e=this.request,t=[];t.push(e.method),t.push(e.headers["Content-MD5"]||""),t.push(e.headers["Content-Type"]||""),t.push(e.headers["presigned-expires"]||"");var n=this.canonicalizedAmzHeaders();return n&&t.push(n),t.push(this.canonicalizedResource()),t.join("\n")},canonicalizedAmzHeaders:function(){var e=[];r.util.each(this.request.headers,(function(t){t.match(/^x-amz-/i)&&e.push(t)})),e.sort((function(e,t){return e.toLowerCase()=0?"&":"?";this.request.path+=i+r.util.queryParamsToString(o)},authorization:function(e,t){var n=[],r=this.credentialString(t);return n.push(this.algorithm+" Credential="+e.accessKeyId+"/"+r),n.push("SignedHeaders="+this.signedHeaders()),n.push("Signature="+this.signature(e,t)),n.join(", ")},signature:function(e,t){var n=o.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return r.util.crypto.hmac(n,this.stringToSign(t),"hex")},stringToSign:function(e){var t=[];return t.push("AWS4-HMAC-SHA256"),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")},canonicalString:function(){var e=[],t=this.request.pathname();return"s3"!==this.serviceName&&"s3v4"!==this.signatureVersion&&(t=r.util.uriEscapePath(t)),e.push(this.request.method),e.push(t),e.push(this.request.search()),e.push(this.canonicalHeaders()+"\n"),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")},canonicalHeaders:function(){var e=[];r.util.each.call(this,this.request.headers,(function(t,n){e.push([t,n])})),e.sort((function(e,t){return e[0].toLowerCase()50&&delete o[i.shift()]),d},emptyCache:function(){o={},i=[]}}},{"../core":18}],70:[function(e,t,n){function r(e,t){this.currentState=t||null,this.states=e||{}}r.prototype.runTo=function(e,t,n,r){"function"===typeof e&&(r=n,n=t,t=e,e=null);var o=this,i=o.states[o.currentState];i.fn.call(n||o,r,(function(r){if(r){if(!i.fail)return t?t.call(n,r):null;o.currentState=i.fail}else{if(!i.accept)return t?t.call(n):null;o.currentState=i.accept}if(o.currentState===e)return t?t.call(n,r):null;o.runTo(e,t,n,r)}))},r.prototype.addState=function(e,t,n,r){return"function"===typeof t?(r=t,t=null,n=null):"function"===typeof n&&(r=n,n=null),this.currentState||(this.currentState=e),this.states[e]={accept:t,fail:n,fn:r},this},t.exports=r},{}],71:[function(e,t,n){(function(n,r){(function(){var o,i={environment:"nodejs",engine:function(){if(i.isBrowser()&&"undefined"!==typeof navigator)return navigator.userAgent;var e=n.platform+"/"+n.version;return n.env.AWS_EXECUTION_ENV&&(e+=" exec-env/"+n.env.AWS_EXECUTION_ENV),e},userAgent:function(){var t=i.environment,n="aws-sdk-"+t+"/"+e("./core").VERSION;return"nodejs"===t&&(n+=" "+i.engine()),n},uriEscape:function(e){var t=encodeURIComponent(e);return t=(t=t.replace(/[^A-Za-z0-9_.~\-%]+/g,escape)).replace(/[*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))},uriEscapePath:function(e){var t=[];return i.arrayEach(e.split("/"),(function(e){t.push(i.uriEscape(e))})),t.join("/")},urlParse:function(e){return i.url.parse(e)},urlFormat:function(e){return i.url.format(e)},queryStringParse:function(e){return i.querystring.parse(e)},queryParamsToString:function(e){var t=[],n=i.uriEscape,r=Object.keys(e).sort();return i.arrayEach(r,(function(r){var o=e[r],a=n(r),c=a+"=";if(Array.isArray(o)){var s=[];i.arrayEach(o,(function(e){s.push(n(e))})),c=a+"="+s.sort().join("&"+a+"=")}else void 0!==o&&null!==o&&(c=a+"="+n(o));t.push(c)})),t.join("&")},readFileSync:function(t){return i.isBrowser()?null:e("fs").readFileSync(t,"utf-8")},base64:{encode:function(e){if("number"===typeof e)throw i.error(new Error("Cannot base64 encode number "+e));return null===e||"undefined"===typeof e?e:i.buffer.toBuffer(e).toString("base64")},decode:function(e){if("number"===typeof e)throw i.error(new Error("Cannot base64 decode number "+e));return null===e||"undefined"===typeof e?e:i.buffer.toBuffer(e,"base64")}},buffer:{toBuffer:function(e,t){return"function"===typeof i.Buffer.from&&i.Buffer.from!==Uint8Array.from?i.Buffer.from(e,t):new i.Buffer(e,t)},alloc:function(e,t,n){if("number"!==typeof e)throw new Error("size passed to alloc must be a number.");if("function"===typeof i.Buffer.alloc)return i.Buffer.alloc(e,t,n);var r=new i.Buffer(e);return void 0!==t&&"function"===typeof r.fill&&r.fill(t,void 0,void 0,n),r},toStream:function(e){i.Buffer.isBuffer(e)||(e=i.buffer.toBuffer(e));var t=new i.stream.Readable,n=0;return t._read=function(r){if(n>=e.length)return t.push(null);var o=n+r;o>e.length&&(o=e.length),t.push(e.slice(n,o)),n=o},t},concat:function(e){var t,n,r=0,o=0;for(n=0;n>>8^t[255&(n^e.readUInt8(r))]}return(-1^n)>>>0},hmac:function(e,t,n,r){return n||(n="binary"),"buffer"===n&&(n=void 0),r||(r="sha256"),"string"===typeof t&&(t=i.buffer.toBuffer(t)),i.crypto.lib.createHmac(r,e).update(t).digest(n)},md5:function(e,t,n){return i.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return i.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,r){var o=i.crypto.createHash(e);n||(n="binary"),"buffer"===n&&(n=void 0),"string"===typeof t&&(t=i.buffer.toBuffer(t));var a=i.arraySliceFn(t),c=i.Buffer.isBuffer(t);if(i.isBrowser()&&"undefined"!==typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(c=!0),r&&"object"===typeof t&&"function"===typeof t.on&&!c)t.on("data",(function(e){o.update(e)})),t.on("error",(function(e){r(e)})),t.on("end",(function(){r(null,o.digest(n))}));else{if(!r||!a||c||"undefined"===typeof FileReader){i.isBrowser()&&"object"===typeof t&&!c&&(t=new i.Buffer(new Uint8Array(t)));var s=o.update(t).digest(n);return r&&r(null,s),s}var u=0,l=new FileReader;l.onerror=function(){r(new Error("Failed to read data."))},l.onload=function(){var e=new i.Buffer(new Uint8Array(l.result));o.update(e),u+=e.length,l._continueReading()},l._continueReading=function(){if(u>=t.size)r(null,o.digest(n));else{var e=u+524288;e>t.size&&(e=t.size),l.readAsArrayBuffer(a.call(t,u,e))}},l._continueReading()}},toHex:function(e){for(var t=[],n=0;n=3e5,!1),o.config.isClockSkewed},applyClockOffset:function(e){e&&(o.config.systemClockOffset=e-(new Date).getTime())},extractRequestId:function(e){var t=e.httpResponse.headers["x-amz-request-id"]||e.httpResponse.headers["x-amzn-requestid"];!t&&e.data&&e.data.ResponseMetadata&&(t=e.data.ResponseMetadata.RequestId),t&&(e.requestId=t),e.error&&(e.error.requestId=t)},addPromises:function(e,t){var n=!1;void 0===t&&o&&o.config&&(t=o.config.getPromisesDependency()),void 0===t&&"undefined"!==typeof Promise&&(t=Promise),"function"!==typeof t&&(n=!0),Array.isArray(e)||(e=[e]);for(var r=0;r=500||429===r});o&&a.retryable&&(a.retryAfter=o),s(a)}}))}),s)};o.util.defer(u)},uuid:{v4:function(){return e("uuid").v4()}},convertPayloadToString:function(e){var t=e.request,n=t.operation,r=t.service.api.operations[n].output||{};r.payload&&e.data[r.payload]&&(e.data[r.payload]=e.data[r.payload].toString())},defer:function(e){"object"===typeof n&&"function"===typeof n.nextTick?n.nextTick(e):"function"===typeof r?r(e):setTimeout(e,0)},getRequestPayloadShape:function(e){var t=e.service.api.operations;if(t){var n=(t||{})[e.operation];if(n&&n.input&&n.input.payload)return n.input.members[n.input.payload]}},getProfilesFromSharedConfig:function(e,t){var r={},o={};if(n.env[i.configOptInEnv])o=e.loadFrom({isConfig:!0,filename:n.env[i.sharedConfigFileEnv]});for(var a=e.loadFrom({filename:t||n.env[i.configOptInEnv]&&n.env[i.sharedCredentialsFileEnv]}),c=0,s=Object.keys(o);c0||r?i.toString():""},t.exports=a},{"../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 r=e("./escape-attribute").escapeAttribute;function o(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}o.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},o.prototype.addChildNode=function(e){return this.children.push(e),this},o.prototype.removeAttribute=function(e){return delete this.attributes[e],this},o.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,o=0,i=Object.keys(n);o"+this.children.map((function(e){return e.toString()})).join("")+"":"/>")},t.exports={XmlNode:o}},{"./escape-attribute":74}],77:[function(e,t,n){var r=e("./escape-element").escapeElement;function o(e){this.value=e}o.prototype.toString=function(){return r(""+this.value)},t.exports={XmlText:o}},{"./escape-element":75}],78:[function(e,t,n){"use strict";n.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=u(e),a=r[0],c=r[1],s=new i(function(e,t,n){return 3*(t+n)/4-n}(0,a,c)),l=0,p=c>0?a-4:a;for(n=0;n>16&255,s[l++]=t>>8&255,s[l++]=255&t;2===c&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,s[l++]=255&t);1===c&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,s[l++]=t>>8&255,s[l++]=255&t);return s},n.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],a=16383,c=0,s=n-o;cs?s:c+a));1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!==typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,s=a.length;c0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var o,i,a=[],c=t;c>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],79:[function(e,t,n){},{}],80:[function(e,t,o){(function(e){(function(){!function(i){"object"==typeof o&&o&&o.nodeType,"object"==typeof t&&t&&t.nodeType;var a="object"==typeof e&&e;a.global!==a&&a.window!==a&&a.self;var c,s=2147483647,u=36,l=/^xn--/,p=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=Math.floor,g=String.fromCharCode;function m(e){throw RangeError(d[e])}function v(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function y(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+v((e=e.replace(f,".")).split("."),t).join(".")}function b(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(t+=g((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=g(e)})).join("")}function S(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function C(e,t,n){var r=0;for(e=n?h(e/700):e>>1,e+=h(e/t);e>455;r+=u)e=h(e/35);return h(r+36*e/(e+38))}function w(e){var t,n,r,o,i,a,c,l,p,f,d,g=[],v=e.length,y=0,b=128,S=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r=128&&m("not-basic"),g.push(e.charCodeAt(r));for(o=n>0?n+1:0;o=v&&m("invalid-input"),((l=(d=e.charCodeAt(o++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:u)>=u||l>h((s-y)/a))&&m("overflow"),y+=l*a,!(l<(p=c<=S?1:c>=S+26?26:c-S));c+=u)a>h(s/(f=u-p))&&m("overflow"),a*=f;S=C(y-i,t=g.length+1,0==i),h(y/t)>s-b&&m("overflow"),b+=h(y/t),y%=t,g.splice(y++,0,b)}return E(g)}function T(e){var t,n,r,o,i,a,c,l,p,f,d,v,y,E,w,T=[];for(v=(e=b(e)).length,t=128,n=0,i=72,a=0;a=t&&dh((s-n)/(y=r+1))&&m("overflow"),n+=(c-t)*y,t=c,a=0;as&&m("overflow"),d==t){for(l=n,p=u;!(l<(f=p<=i?1:p>=i+26?26:p-i));p+=u)w=l-f,E=u-f,T.push(g(S(f+w%E,0))),l=h(w/E);T.push(g(S(l,0))),i=C(n,y,r==o),n=0,++r}++n,++t}return T.join("")}c={version:"1.3.2",ucs2:{decode:b,encode:E},decode:w,encode:T,toASCII:function(e){return y(e,(function(e){return p.test(e)?"xn--"+T(e):e}))},toUnicode:function(e){return y(e,(function(e){return l.test(e)?w(e.slice(4).toLowerCase()):e}))}},void 0===(r=function(){return c}.call(o,n,o,t))||(t.exports=r)}()}).call(this)}).call(this,"undefined"!==typeof n.g?n.g:"undefined"!==typeof self?self:"undefined"!==typeof window?window:{})},{}],81:[function(e,t,r){(function(t,n){(function(){"use strict";var n=e("base64-js"),o=e("ieee754"),i=e("isarray");function a(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function c(e,t){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function h(e,t){if(s.isBuffer(e))return e.length;if("undefined"!==typeof ArrayBuffer&&"function"===typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!==typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(e).length;default:if(r)return B(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,n);case"utf8":case"utf-8":return _(this,t,n);case"ascii":return A(this,t,n);case"latin1":case"binary":return R(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function m(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,o){if(0===e.length)return-1;if("string"===typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"===typeof t&&(t=s.from(t,r)),s.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,o);if("number"===typeof t)return t&=255,s.TYPED_ARRAY_SUPPORT&&"function"===typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,o){var i,a=1,c=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,c/=2,s/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var l=-1;for(i=n;ic&&(n=c-s),i=n;i>=0;i--){for(var p=!0,f=0;fo&&(r=o):r=o;var i=t.length;if(i%2!==0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function I(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function _(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o239?4:u>223?3:u>191?2:1;if(o+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128===(192&(i=e[o+1]))&&(s=(31&u)<<6|63&i)>127&&(l=s);break;case 3:i=e[o+1],a=e[o+2],128===(192&i)&&128===(192&a)&&(s=(15&u)<<12|(63&i)<<6|63&a)>2047&&(s<55296||s>57343)&&(l=s);break;case 4:i=e[o+1],a=e[o+2],c=e[o+3],128===(192&i)&&128===(192&a)&&128===(192&c)&&(s=(15&u)<<18|(63&i)<<12|(63&a)<<6|63&c)>65535&&s<1114112&&(l=s)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=p}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,n,r,o){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),c=Math.min(i,a),u=this.slice(r,o),l=e.slice(t,n),p=0;po)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return E(this,e,t,n);case"ascii":return S(this,e,t,n);case"latin1":case"binary":return C(this,e,t,n);case"base64":return w(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function A(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;or)&&(n=r);for(var o="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function L(e,t,n,r,o,i){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function P(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function D(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function M(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,r,i){return i||M(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,i){return i||M(e,0,n,8),o.write(e,t,n,r,52,8),n+8}s.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)r+=this[e+--t]*o;return r},s.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var r=this[e],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*t)),r},s.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),o.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),o.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),o.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),o.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+n},s.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);L(this,e,t,n,o-1,-o)}var i=0,a=1,c=0;for(this[t]=255&e;++i>0)-c&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);L(this,e,t,n,o-1,-o)}var i=n-1,a=1,c=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===c&&0!==this[t+i+1]&&(c=1),this[t+i]=(e/a>>0)-c&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},s.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"===typeof e)for(i=t;i55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function z(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(j,"")).length<2)return"";for(;e.length%4!==0;)e+="=";return e}(e))}function V(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this)}).call(this,"undefined"!==typeof 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 r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"===typeof e}function i(e){return"object"===typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!==typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,c,s,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(a(n=this._events[e]))return!1;if(o(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:c=Array.prototype.slice.call(arguments,1),n.apply(this,c)}else if(i(n))for(c=Array.prototype.slice.call(arguments,1),r=(u=n.slice()).length,s=0;s0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"===typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!o(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,a,c;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(n=this._events[e]).length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(c=a;c-- >0;)if(n[c]===t||n[c].listener&&n[c].listener===t){r=c;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(o(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],83:[function(e,t,n){n.read=function(e,t,n,r,o){var i,a,c=8*o-r-1,s=(1<>1,l=-7,p=n?o-1:0,f=n?-1:1,d=e[t+p];for(p+=f,i=d&(1<<-l)-1,d>>=-l,l+=c;l>0;i=256*i+e[t+p],p+=f,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=r;l>0;a=256*a+e[t+p],p+=f,l-=8);if(0===i)i=1-u;else{if(i===s)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),i-=u}return(d?-1:1)*a*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var a,c,s,u=8*i-o-1,l=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,h=r?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,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-a))<1&&(a--,s*=2),(t+=a+p>=1?f/s:f*Math.pow(2,1-p))*s>=2&&(a++,s/=2),a+p>=l?(c=0,a=l):a+p>=1?(c=(t*s-1)*Math.pow(2,o),a+=p):(c=t*Math.pow(2,p-1)*Math.pow(2,o),a=0));o>=8;e[n+d]=255&c,d+=h,c/=256,o-=8);for(a=a<0;e[n+d]=255&a,d+=h,a/=256,u-=8);e[n+d-h]|=128*g}},{}],84:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.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 r(e,o){if(e===o)return!0;if(Object.prototype.toString.call(e)!==Object.prototype.toString.call(o))return!1;if(!0===t(e)){if(e.length!==o.length)return!1;for(var i=0;i":!0,"=":!0,"!":!0},j={" ":!0,"\t":!0,"\n":!0};function q(e){return e>="0"&&e<="9"||"-"===e}function B(){}B.prototype={tokenize:function(e){var t,n,r,o,i=[];for(this._current=0;this._current="a"&&o<="z"||o>="A"&&o<="Z"||"_"===o)t=this._current,n=this._consumeUnquotedIdentifier(e),i.push({type:u,value:n,start:t});else if(void 0!==U[e[this._current]])i.push({type:U[e[this._current]],value:e[this._current],start:this._current}),this._current++;else if(q(e[this._current]))r=this._consumeNumber(e),i.push(r);else if("["===e[this._current])r=this._consumeLBracket(e),i.push(r);else if('"'===e[this._current])t=this._current,n=this._consumeQuotedIdentifier(e),i.push({type:l,value:n,start:t});else if("'"===e[this._current])t=this._current,n=this._consumeRawStringLiteral(e),i.push({type:M,value:n,start:t});else if("`"===e[this._current]){t=this._current;var a=this._consumeLiteral(e);i.push({type:M,value:a,start:t})}else if(void 0!==F[e[this._current]])i.push(this._consumeOperator(e));else if(void 0!==j[e[this._current]])this._current++;else if("&"===e[this._current])t=this._current,this._current++,"&"===e[this._current]?(this._current++,i.push({type:S,value:"&&",start:t})):i.push({type:y,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:E,value:"||",start:t})):i.push({type:b,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:I,value:">=",start:t}):{type:w,value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:C,value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t,n=this._current,r=e.length;"`"!==e[this._current]&&this._current=0)return!0;if(["true","false","null"].indexOf(e)>=0)return!0;if(!("-0123456789".indexOf(e[0])>=0))return!1;try{return JSON.parse(e),!0}catch(t){return!1}}};var z={};function V(){}function W(e){this.runtime=e}function H(e){this._interpreter=e,this.functionTable={abs:{_func:this._functionAbs,_signature:[{types:[a]}]},avg:{_func:this._functionAvg,_signature:[{types:[8]}]},ceil:{_func:this._functionCeil,_signature:[{types:[a]}]},contains:{_func:this._functionContains,_signature:[{types:[c,3]},{types:[1]}]},ends_with:{_func:this._functionEndsWith,_signature:[{types:[c]},{types:[c]}]},floor:{_func:this._functionFloor,_signature:[{types:[a]}]},length:{_func:this._functionLength,_signature:[{types:[c,3,4]}]},map:{_func:this._functionMap,_signature:[{types:[6]},{types:[3]}]},max:{_func:this._functionMax,_signature:[{types:[8,9]}]},merge:{_func:this._functionMerge,_signature:[{types:[4],variadic:!0}]},max_by:{_func:this._functionMaxBy,_signature:[{types:[3]},{types:[6]}]},sum:{_func:this._functionSum,_signature:[{types:[8]}]},starts_with:{_func:this._functionStartsWith,_signature:[{types:[c]},{types:[c]}]},min:{_func:this._functionMin,_signature:[{types:[8,9]}]},min_by:{_func:this._functionMinBy,_signature:[{types:[3]},{types:[6]}]},type:{_func:this._functionType,_signature:[{types:[1]}]},keys:{_func:this._functionKeys,_signature:[{types:[4]}]},values:{_func:this._functionValues,_signature:[{types:[4]}]},sort:{_func:this._functionSort,_signature:[{types:[9,8]}]},sort_by:{_func:this._functionSortBy,_signature:[{types:[3]},{types:[6]}]},join:{_func:this._functionJoin,_signature:[{types:[c]},{types:[9]}]},reverse:{_func:this._functionReverse,_signature:[{types:[c,3]}]},to_array:{_func:this._functionToArray,_signature:[{types:[1]}]},to_string:{_func:this._functionToString,_signature:[{types:[1]}]},to_number:{_func:this._functionToNumber,_signature:[{types:[1]}]},not_null:{_func:this._functionNotNull,_signature:[{types:[1],variadic:!0}]}}}z.EOF=0,z.UnquotedIdentifier=0,z.QuotedIdentifier=0,z.Rbracket=0,z.Rparen=0,z.Comma=0,z.Rbrace=0,z.Number=0,z.Current=0,z.Expref=0,z.Pipe=1,z.Or=2,z.And=3,z.EQ=5,z.GT=5,z.LT=5,z.GTE=5,z.LTE=5,z.NE=5,z.Flatten=9,z.Star=20,z.Filter=21,z.Dot=40,z.Not=45,z.Lbrace=50,z.Lbracket=55,z.Lparen=60,V.prototype={parse:function(e){this._loadTokens(e),this.index=0;var t=this.expression(0);if(this._lookahead(0)!==s){var n=this._lookaheadToken(0),r=new Error("Unexpected token type: "+n.type+", value: "+n.value);throw r.name="ParserError",r}return t},_loadTokens:function(e){var t=(new B).tokenize(e);t.push({type:s,value:"",start:e.length}),this.tokens=t},expression:function(e){var t=this._lookaheadToken(0);this._advance();for(var n=this.nud(t),r=this._lookahead(0);e=0?this.expression(e):t===P?(this._match(P),this._parseMultiselectList()):t===L?(this._match(L),this._parseMultiselectHash()):void 0},_parseProjectionRHS:function(e){var t;if(z[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===P)t=this.expression(e);else if(this._lookahead(0)===N)t=this.expression(e);else{if(this._lookahead(0)!==x){var n=this._lookaheadToken(0),r=new Error("Sytanx error, unexpected token: "+n.value+"("+n.type+")");throw r.name="ParserError",r}this._match(x),t=this._parseDotRHS(e)}return t},_parseMultiselectList:function(){for(var e=[];this._lookahead(0)!==p;){var t=this.expression(0);if(e.push(t),this._lookahead(0)===d&&(this._match(d),this._lookahead(0)===p))throw new Error("Unexpected token Rbracket")}return this._match(p),{type:"MultiSelectList",children:e}},_parseMultiselectHash:function(){for(var e,t,n,r=[],o=[u,l];;){if(e=this._lookaheadToken(0),o.indexOf(e.type)<0)throw new Error("Expecting an identifier token, got: "+e.type);if(t=e.value,this._advance(),this._match(h),n={type:"KeyValuePair",name:t,value:this.expression(0)},r.push(n),this._lookahead(0)===d)this._match(d);else if(this._lookahead(0)===g){this._match(g);break}}return{type:"MultiSelectHash",children:r}}},W.prototype={search:function(e,t){return this.visit(e,t)},visit:function(e,i){var a,c,s,u,l,p,f,d,h;switch(e.type){case"Field":return null===i?null:n(i)?void 0===(p=i[e.name])?null:p:null;case"Subexpression":for(s=this.visit(e.children[0],i),h=1;h0)for(h=S;hR;h+=N)s.push(i[h]);return s;case"Projection":var x=this.visit(e.children[0],i);if(!t(x))return null;for(d=[],h=0;hl;break;case I:s=u>=l;break;case T:s=u=e&&(t=n<0?e-1:e),t}},H.prototype={callFunction:function(e,t){var n=this.functionTable[e];if(void 0===n)throw new Error("Unknown function: "+e+"()");return this._validateArgs(e,t,n._signature),n._func.call(this,t)},_validateArgs:function(e,t,n){var r,o,i,a;if(n[n.length-1].variadic){if(t.length=0;r--)n+=t[r];return n}var o=e[0].slice(0);return o.reverse(),o},_functionAbs:function(e){return Math.abs(e[0])},_functionCeil:function(e){return Math.ceil(e[0])},_functionAvg:function(e){for(var t=0,n=e[0],r=0;r=0},_functionFloor:function(e){return Math.floor(e[0])},_functionLength:function(e){return n(e[0])?Object.keys(e[0]).length:e[0].length},_functionMap:function(e){for(var t=[],n=this._interpreter,r=e[0],o=e[1],i=0;i0){if(this._getTypeName(e[0][0])===a)return Math.max.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;r0){if(this._getTypeName(e[0][0])===a)return Math.min.apply(Math,e[0]);for(var t=e[0],n=t[0],r=1;rc?1:as&&(s=n,t=o[u]);return t},_functionMinBy:function(e){for(var t,n,r=e[1],o=e[0],i=this.createKeyFunction(r,[a,c]),s=1/0,u=0;u1)for(var n=1;n0&&u>s&&(u=s);for(var l=0;l=0?(p=g.substr(0,m),f=g.substr(m+1)):(p=g,f=""),d=decodeURIComponent(p),h=decodeURIComponent(f),r(a,d)?o(a[d])?a[d].push(h):a[d]=[a[d],h]:a[d]=h}return a};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],88:[function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,c){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"===typeof e?i(a(e),(function(a){var c=encodeURIComponent(r(a))+n;return o(e[a])?i(e[a],(function(e){return c+encodeURIComponent(r(e))})).join(t):c+encodeURIComponent(r(e[a]))})).join(t):c?encodeURIComponent(r(c))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r0&&s>c&&(s=c);for(var u=0;u=0?(l=h.substr(0,g),p=h.substr(g+1)):(l=h,p=""),f=decodeURIComponent(l),d=decodeURIComponent(p),r(i,f)?Array.isArray(i[f])?i[f].push(d):i[f]=[i[f],d]:i[f]=d}return i}},{}],91:[function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,o){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"===typeof e?Object.keys(e).map((function(o){var i=encodeURIComponent(r(o))+n;return Array.isArray(e[o])?e[o].map((function(e){return i+encodeURIComponent(r(e))})).join(t):i+encodeURIComponent(r(e[o]))})).join(t):o?encodeURIComponent(r(o))+n+encodeURIComponent(r(e)):""}},{}],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,r){(function(){var o=e("process/browser.js").nextTick,i=Function.prototype.apply,a=Array.prototype.slice,c={},s=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=s++,r=!(arguments.length<2)&&a.call(arguments,1);return c[t]=!0,o((function(){c[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"===typeof r?r: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 r=e("punycode");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}n.parse=v,n.resolve=function(e,t){return v(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?v(e,!1,!0).resolveObject(t):t},n.format=function(e){y(e)&&(e=v(e));return e instanceof o?e.format():o.prototype.format.call(e)},n.Url=o;var i=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),s=["'"].concat(c),u=["%","/","?",";","#"].concat(s),l=["/","?","#"],p=/^[a-z0-9A-Z_-]{0,63}$/,f=/^([a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},h={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=e("querystring");function v(e,t,n){if(e&&b(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}function y(e){return"string"===typeof e}function b(e){return"object"===typeof e&&null!==e}function E(e){return null===e}o.prototype.parse=function(e,t,n){if(!y(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e;o=o.trim();var a=i.exec(o);if(a){var c=(a=a[0]).toLowerCase();this.protocol=c,o=o.substr(a.length)}if(n||a||o.match(/^\/\/[^@\/]+@[^@\/]+/)){var v="//"===o.substr(0,2);!v||a&&h[a]||(o=o.substr(2),this.slashes=!0)}if(!h[a]&&(v||a&&!g[a])){for(var b,E,S=-1,C=0;C127?A+="x":A+=k[R];if(!A.match(p)){var x=I.slice(0,C),O=I.slice(C+1),L=k.match(f);L&&(x.push(L[1]),O.unshift(L[2])),O.length&&(o="/"+O.join(".")+o),this.hostname=x.join(".");break}}}if(this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),!T){var P=this.hostname.split("."),D=[];for(C=0;C0)&&n.host.split("@"))&&(n.auth=S.shift(),n.host=n.hostname=S.shift());return n.search=e.search,n.query=e.query,E(n.pathname)&&E(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],m=(n.host||e.host)&&("."===d||".."===d)||""===d,v=0,b=p.length;b>=0;b--)"."==(d=p[b])?p.splice(b,1):".."===d?(p.splice(b,1),v++):v&&(p.splice(b,1),v--);if(!u&&!l)for(;v--;v)p.unshift("..");!u||""===p[0]||p[0]&&"/"===p[0].charAt(0)||p.unshift(""),m&&"/"!==p.join("/").substr(-1)&&p.push("");var S,C=""===p[0]||p[0]&&"/"===p[0].charAt(0);f&&(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()));return(u=u||n.host&&p.length)&&!C&&p.unshift(""),p.length?n.pathname=p.join("/"):(n.pathname=null,n.path=null),E(n.pathname)&&E(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=a.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"===typeof e&&"function"===typeof e.copy&&"function"===typeof e.fill&&"function"===typeof e.readUInt8}},{}],97:[function(e,t,r){(function(t,n){(function(){var o=/%[sdj%]/g;r.format=function(e){if(!v(e)){for(var t=[],n=0;n=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}})),s=r[n];n=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),h(t)?n.showHidden=t:t&&r._extend(n,t),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=s),l(n,e,n.depth)}function s(e,t){var n=c.styles[t];return n?"\x1b["+c.colors[n][0]+"m"+e+"\x1b["+c.colors[n][1]+"m":e}function u(e,t){return e}function l(e,t,n){if(e.customInspect&&t&&w(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(n,e);return v(o)||(o=l(e,o,n)),o}var i=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(m(t))return e.stylize(""+t,"number");if(h(t))return e.stylize(""+t,"boolean");if(g(t))return e.stylize("null","null")}(e,t);if(i)return i;var a=Object.keys(t),c=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),C(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(t);if(0===a.length){if(w(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(b(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(S(t))return e.stylize(Date.prototype.toString.call(t),"date");if(C(t))return p(t)}var u,E="",T=!1,I=["{","}"];(d(t)&&(T=!0,I=["[","]"]),w(t))&&(E=" [Function"+(t.name?": "+t.name:"")+"]");return b(t)&&(E=" "+RegExp.prototype.toString.call(t)),S(t)&&(E=" "+Date.prototype.toUTCString.call(t)),C(t)&&(E=" "+p(t)),0!==a.length||T&&0!=t.length?n<0?b(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=T?function(e,t,n,r,o){for(var i=[],a=0,c=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(u,E,I)):I[0]+E+I[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,o,i){var a,c,s;if((s=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?c=s.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):s.set&&(c=e.stylize("[Setter]","special")),A(r,o)||(a="["+o+"]"),c||(e.seen.indexOf(s.value)<0?(c=g(n)?l(e,s.value,null):l(e,s.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")),y(a)){if(i&&o.match(/^\d+$/))return c;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+c}function d(e){return Array.isArray(e)}function h(e){return"boolean"===typeof e}function g(e){return null===e}function m(e){return"number"===typeof e}function v(e){return"string"===typeof e}function y(e){return void 0===e}function b(e){return E(e)&&"[object RegExp]"===T(e)}function E(e){return"object"===typeof e&&null!==e}function S(e){return E(e)&&"[object Date]"===T(e)}function C(e){return E(e)&&("[object Error]"===T(e)||e instanceof Error)}function w(e){return"function"===typeof e}function T(e){return Object.prototype.toString.call(e)}function I(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(y(i)&&(i=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var n=t.pid;a[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else a[e]=function(){};return a[e]},r.inspect=c,c.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]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=h,r.isNull=g,r.isNullOrUndefined=function(e){return null==e},r.isNumber=m,r.isString=v,r.isSymbol=function(e){return"symbol"===typeof e},r.isUndefined=y,r.isRegExp=b,r.isObject=E,r.isDate=S,r.isError=C,r.isFunction=w,r.isPrimitive=function(e){return null===e||"boolean"===typeof e||"number"===typeof e||"string"===typeof e||"symbol"===typeof e||"undefined"===typeof e},r.isBuffer=e("./support/isBuffer");var _=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(){var e=new Date,t=[I(e.getHours()),I(e.getMinutes()),I(e.getSeconds())].join(":");return[e.getDate(),_[e.getMonth()],t].join(" ")}function A(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){console.log("%s - %s",k(),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!E(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this)}).call(this,e("_process"),"undefined"!==typeof 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 r=e("./v1"),o=e("./v4"),i=o;i.v1=r,i.v4=o,t.exports=i},{"./v1":101,"./v4":102}],99:[function(e,t,n){for(var r=[],o=0;o<256;++o)r[o]=(o+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,o=r;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")}},{}],100:[function(e,t,n){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var o=new Uint8Array(16);t.exports=function(){return r(o),o}}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 r,o,i=e("./lib/rng"),a=e("./lib/bytesToUuid"),c=0,s=0;t.exports=function(e,t,n){var u=t&&n||0,l=t||[],p=(e=e||{}).node||r,f=void 0!==e.clockseq?e.clockseq:o;if(null==p||null==f){var d=i();null==p&&(p=r=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==f&&(f=o=16383&(d[6]<<8|d[7]))}var h=void 0!==e.msecs?e.msecs:(new Date).getTime(),g=void 0!==e.nsecs?e.nsecs:s+1,m=h-c+(g-s)/1e4;if(m<0&&void 0===e.clockseq&&(f=f+1&16383),(m<0||h>c)&&void 0===e.nsecs&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=h,s=g,o=f;var v=(1e4*(268435455&(h+=122192928e5))+g)%4294967296;l[u++]=v>>>24&255,l[u++]=v>>>16&255,l[u++]=v>>>8&255,l[u++]=255&v;var y=h/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++]=f>>>8|128,l[u++]=255&f;for(var b=0;b<6;++b)l[u+b]=p[b];return t||a(l)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],102:[function(e,t,n){var r=e("./lib/rng"),o=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 a=(e=e||{}).random||(e.rng||r)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var c=0;c<16;++c)t[i+c]=a[c];return t||o(a)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],103:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./utils/LRU"),o=function(){function e(e){void 0===e&&(e=1e3),this.maxSize=e,this.cache=new r.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 r="string"!==typeof t?e.getKeyString(t):t,o=this.populateValue(n);this.cache.put(r,o)},e.prototype.get=function(t){var n="string"!==typeof t?e.getKeyString(t):t,r=Date.now(),o=this.cache.get(n);if(o)for(var i=0;i0},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"!==s(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},l=new RegExp("^(wss://)\\w*");u.validWSUrl=function(e){return l.test(e)},u.getSubscriptionResponse=function(e,t,n){return{topic:e,content:{status:t?"success":"failure",topics:n}}},u.assertIsObject=function(e,t){if(!u.isObject(e))throw new Error(t+" is not an object!")},u.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)},u.isNetworkOnline=function(){return navigator.onLine},u.isNetworkFailure=function(e){return!(!e._debug||!e._debug.type)&&"NetworkingError"===e._debug.type};var p=u;function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(e,t){for(var n=0;n=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){var t=e.prefix||"";return this._logsDestination===o?this.consoleLoggerWrapper:new C(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||b.DEBUG,this._clientLogger=t.logger||null,this._logsDestination="NULL",t.debug&&(this._logsDestination=o),t.logger&&(this._logsDestination="CLIENT_LOGGER")}}]),e}(),S=function(){function e(){g(this,e)}return v(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),e}(),C=function(e){function t(e){var n;return g(this,t),(n=function(e,t){return!t||"object"!==f(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,d(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&&h(e,t)}(t,S),v(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}}])&&I(t.prototype,n),e}();n.d(t,"a",(function(){return A}));var k=function(){var e=T.getLogger({}),t=p.isNetworkOnline(),n={primary:null,secondary:null},r={reconnectWebSocket:!0,websocketInitFailed:!1,exponentialBackOffTime:1e3,exponentialTimeoutHandle:null,lifeTimeTimeoutHandle:null,webSocketInitCheckerTimeoutId:null,connState:null},o={connectWebSocketRetryCount:0,connectionAttemptStartTime:null,noOpenConnectionsTimestamp:null},s={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},f={subscribed:new Set,pending:new Set,subscriptionHistory:new Set},d={responseCheckIntervalId:null,requestCompleted:!0,reSubscribeIntervalId:null,consecutiveFailedSubscribeAttempts:0,consecutiveNoResponseRequest:0},h=new _((function(){B()})),g=new Set([i,"aws/unsubscribe",a]),m=setInterval((function(){if(t!==p.isNetworkOnline()){if(!(t=p.isNetworkOnline()))return void W(e.info("Network offline"));var n=w();t&&(!n||E(n,WebSocket.CLOSING)||E(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"}},b=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)))},E=function(e,t){return e&&e.readyState===t},S=function(e){return E(e,WebSocket.OPEN)},C=function(e){return null===e||void 0===e.readyState||E(e,WebSocket.CLOSED)},w=function(){return null!==n.secondary?n.secondary:n.primary},I=function(){return S(w())},k=function(){if(s.pendingResponse)return W(e.warn("Heartbeat response not received")),clearInterval(s.intervalHandle),s.pendingResponse=!1,void B();I()?(W(e.debug("Sending heartbeat")),w().send(j(a)),s.pendingResponse=!0):(W(e.warn("Failed to send heartbeat since WebSocket is not open")),b("sendHeartBeat"),B())},A=function(){r.exponentialBackOffTime=1e3,s.pendingResponse=!1,r.reconnectWebSocket=!0,clearTimeout(r.lifeTimeTimeoutHandle),clearInterval(s.intervalHandle),clearTimeout(r.exponentialTimeoutHandle),clearTimeout(r.webSocketInitCheckerTimeoutId)},R=function(){d.consecutiveFailedSubscribeAttempts=0,d.consecutiveNoResponseRequest=0,clearInterval(d.responseCheckIntervalId),clearInterval(d.reSubscribeIntervalId)},N=function(){o.connectWebSocketRetryCount=0,o.connectionAttemptStartTime=null,o.noOpenConnectionsTimestamp=null},x=function(){try{W(e.info("WebSocket connection established!")),b("webSocketOnOpen"),null!==r.connState&&r.connState!==c||v(u.connectionGain),r.connState="connected";var t=Date.now();v(u.connectionOpen,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,noOpenConnectionsTimestamp:o.noOpenConnectionsTimestamp,connectionEstablishedTime:t,timeToConnect:t-o.connectionAttemptStartTime,timeWithoutConnection:o.noOpenConnectionsTimestamp?t-o.noOpenConnectionsTimestamp:null}),N(),A(),w().openTimestamp=Date.now(),0===f.subscribed.size&&S(n.secondary)&&D(n.primary,"[Primary WebSocket] Closing WebSocket"),(f.subscribed.size>0||f.pending.size>0)&&(S(n.secondary)&&W(e.info("Subscribing secondary websocket to topics of primary websocket")),f.subscribed.forEach((function(e){f.subscriptionHistory.add(e),f.pending.add(e)})),f.subscribed.clear(),P()),k(),s.intervalHandle=setInterval(k,1e4);var i=1e3*l.connConfig.webSocketTransport.transportLifeTimeInSeconds;W(e.debug("Scheduling WebSocket manager reconnection, after delay "+i+" ms")),r.lifeTimeTimeoutHandle=setTimeout((function(){W(e.debug("Starting scheduled WebSocket manager reconnection")),B()}),i)}catch(t){W(e.error("Error after establishing WebSocket connection",t))}},O=function(t){b("webSocketOnError"),W(e.error("WebSocketManager Error, error_event: ",JSON.stringify(t))),B()},L=function(t){var r=JSON.parse(t.data);switch(r.topic){case i:if(W(e.debug("Subscription Message received from webSocket server",t.data)),d.requestCompleted=!0,d.consecutiveNoResponseRequest=0,"success"===r.content.status)d.consecutiveFailedSubscribeAttempts=0,r.content.topics.forEach((function(e){f.subscriptionHistory.delete(e),f.pending.delete(e),f.subscribed.add(e)})),0===f.subscriptionHistory.size?S(n.secondary)&&(W(e.info("Successfully subscribed secondary websocket to all topics of primary websocket")),D(n.primary,"[Primary WebSocket] Closing WebSocket")):P(),v(u.subscriptionUpdate,r);else{if(clearInterval(d.reSubscribeIntervalId),++d.consecutiveFailedSubscribeAttempts,5===d.consecutiveFailedSubscribeAttempts)return v(u.subscriptionFailure,r),void(d.consecutiveFailedSubscribeAttempts=0);d.reSubscribeIntervalId=setInterval((function(){P()}),500)}break;case a:W(e.debug("Heartbeat response received")),s.pendingResponse=!1;break;default:if(r.topic){if(W(e.debug("Message received for topic "+r.topic)),S(n.primary)&&S(n.secondary)&&0===f.subscriptionHistory.size&&this===n.primary)return void W(e.warn("Ignoring Message for Topic "+r.topic+", to avoid duplicates"));if(0===u.allMessage.size&&0===u.topic.size)return void W(e.warn("No registered callback listener for Topic",r.topic));v(u.allMessage,r),u.topic.has(r.topic)&&v(u.topic.get(r.topic),r)}else r.message?W(e.warn("WebSocketManager Message Error",r)):W(e.warn("Invalid incoming message",r))}},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,p.getSubscriptionResponse(i,!1,Array.from(f.pending)));I()?(clearInterval(d.responseCheckIntervalId),w().send(j(i,{topics:Array.from(f.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"))},D=function(t,n){E(t,WebSocket.CONNECTING)||E(t,WebSocket.OPEN)?t.close(1e3,n):W(e.warn("Ignoring WebSocket Close request, WebSocket State: "+y(t)))},M=function(e){D(n.primary,"[Primary] WebSocket "+e),D(n.secondary,"[Secondary] WebSocket "+e)},U=function(){o.connectWebSocketRetryCount++;var t=p.addJitter(r.exponentialBackOffTime,.3);Date.now()+t<=l.connConfig.urlConnValidTime?(W(e.debug("Scheduling WebSocket reinitialization, after delay "+t+" ms")),r.exponentialTimeoutHandle=setTimeout((function(){return z()}),t),r.exponentialBackOffTime*=2):(W(e.warn("WebSocket URL cannot be used to establish connection")),B())},F=function(t){A(),R(),W(e.error("WebSocket Initialization failed")),r.websocketInitFailed=!0,M("Terminating WebSocket Manager"),clearInterval(m),v(u.initFailure,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,reason:t}),N()},j=function(e,t){return JSON.stringify({topic:e,content:t})},q=function(t){return!!(p.isObject(t)&&p.isObject(t.webSocketTransport)&&p.isNonEmptyString(t.webSocketTransport.url)&&p.validWSUrl(t.webSocketTransport.url)&&1e3*t.webSocketTransport.transportLifeTimeInSeconds>=3e5)||(W(e.error("Invalid WebSocket Connection Configuration",t)),!1)},B=function(){if(p.isNetworkOnline())if(r.websocketInitFailed)W(e.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request"));else{if(l.promiseCompleted)return A(),W(e.info("Fetching new WebSocket connection configuration")),o.connectionAttemptStartTime=o.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)),q(t)?(l.connConfig=t,l.connConfig.urlConnValidTime=Date.now()+85e3,h.connected(),z()):(F("Invalid WebSocket connection configuration: "+t),{webSocketConnectionFailed:!0})}),(function(t){return l.promiseCompleted=!0,W(e.error("Failed to fetch webSocket connection configuration",t)),p.isNetworkFailure(t)?(W(e.info("Retrying fetching new WebSocket connection configuration")),h.retry()):F("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"))},z=function(){if(r.websocketInitFailed)return W(e.info("web-socket initializing had failed, aborting re-init")),{webSocketConnectionFailed:!0};if(!p.isNetworkOnline())return W(e.warn("System is offline aborting web-socket init")),{webSocketConnectionFailed:!0};W(e.info("Initializing Websocket Manager")),b("initWebSocket");try{if(q(l.connConfig)){var t=null;return S(n.primary)?(W(e.debug("Primary Socket connection is already open")),E(n.secondary,WebSocket.CONNECTING)||(W(e.debug("Establishing a secondary web-socket connection")),n.secondary=V()),t=n.secondary):(E(n.primary,WebSocket.CONNECTING)||(W(e.debug("Establishing a primary web-socket connection")),n.primary=V()),t=n.primary),r.webSocketInitCheckerTimeoutId=setTimeout((function(){S(t)||U()}),1e3),{webSocketConnectionFailed:!1}}}catch(t){return W(e.error("Error Initializing web-socket-manager",t)),F("Failed to initialize new WebSocket: "+t.message),{webSocketConnectionFailed:!0}}},V=function(){var t=new WebSocket(l.connConfig.webSocketTransport.url);return t.addEventListener("open",x),t.addEventListener("message",L),t.addEventListener("error",O),t.addEventListener("close",(function(i){return function(t,i){W(e.info("Socket connection is closed",t)),b("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),r.reconnectWebSocket&&(S(n.primary)||S(n.secondary)?C(n.primary)&&S(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")),r.connState===c?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}),o.noOpenConnectionsTimestamp=Date.now()),r.connState=c,B()),b("webSocketOnClose after-cleanup"))}(i,t)})),t},W=function(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e};this.init=function(t){if(p.assertTrue(p.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 p.assertTrue(p.isFunction(e),"cb must be a function"),u.initFailure.add(e),r.websocketInitFailed&&e(),function(){return u.initFailure.delete(e)}},this.onConnectionOpen=function(e){return p.assertTrue(p.isFunction(e),"cb must be a function"),u.connectionOpen.add(e),function(){return u.connectionOpen.delete(e)}},this.onConnectionClose=function(e){return p.assertTrue(p.isFunction(e),"cb must be a function"),u.connectionClose.add(e),function(){return u.connectionClose.delete(e)}},this.onConnectionGain=function(e){return p.assertTrue(p.isFunction(e),"cb must be a function"),u.connectionGain.add(e),I()&&e(),function(){return u.connectionGain.delete(e)}},this.onConnectionLost=function(e){return p.assertTrue(p.isFunction(e),"cb must be a function"),u.connectionLost.add(e),r.connState===c&&e(),function(){return u.connectionLost.delete(e)}},this.onSubscriptionUpdate=function(e){return p.assertTrue(p.isFunction(e),"cb must be a function"),u.subscriptionUpdate.add(e),function(){return u.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(e){return p.assertTrue(p.isFunction(e),"cb must be a function"),u.subscriptionFailure.add(e),function(){return u.subscriptionFailure.delete(e)}},this.onMessage=function(e,t){return p.assertNotNull(e,"topicName"),p.assertTrue(p.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 p.assertTrue(p.isFunction(e),"cb must be a function"),u.allMessage.add(e),function(){return u.allMessage.delete(e)}},this.subscribeTopics=function(e){p.assertNotNull(e,"topics"),p.assertIsList(e),e.forEach((function(e){f.subscribed.has(e)||f.pending.add(e)})),d.consecutiveNoResponseRequest=0,P()},this.sendMessage=function(t){if(p.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()?w().send(t):W(e.warn("Cannot send message, web socket connection is not open"))}},this.closeWebSocket=function(){A(),R(),r.reconnectWebSocket=!1,clearInterval(m),M("User request to close WebSocket")},this.terminateWebSocketManager=F},A={create:function(){return new k},setGlobalConfig:function(e){var t=e.loggerConfig;T.updateLoggerConfig(t)},LogLevel:b,Logger:y}},function(e,t,n){var r;!function(){"use strict";var o={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function i(e){return function(e,t){var n,r,a,c,s,u,l,p,f,d=1,h=e.length,g="";for(r=0;r=0),c.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,c.width?parseInt(c.width):0);break;case"e":n=c.precision?parseFloat(n).toExponential(c.precision):parseFloat(n).toExponential();break;case"f":n=c.precision?parseFloat(n).toFixed(c.precision):parseFloat(n);break;case"g":n=c.precision?String(Number(n.toPrecision(c.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=c.precision?n.substring(0,c.precision):n;break;case"t":n=String(!!n),n=c.precision?n.substring(0,c.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=c.precision?n.substring(0,c.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=c.precision?n.substring(0,c.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}o.json.test(c.type)?g+=n:(!o.number.test(c.type)||p&&!c.sign?f="":(f=p?"+":"-",n=n.toString().replace(o.sign,"")),u=c.pad_char?"0"===c.pad_char?"0":c.pad_char.charAt(1):" ",l=c.width-(f+n).length,s=c.width&&l>0?u.repeat(l):"",g+=c.align?f+n+s:"0"===u?f+s+n:s+f+n)}return g}(function(e){if(c[e])return c[e];for(var t,n=e,r=[],i=0;n;){if(null!==(t=o.text.exec(n)))r.push(t[0]);else if(null!==(t=o.modulo.exec(n)))r.push("%");else{if(null===(t=o.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){i|=1;var a=[],s=t[2],u=[];if(null===(u=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a.push(u[1]);""!==(s=s.substring(u[0].length));)if(null!==(u=o.key_access.exec(s)))a.push(u[1]);else{if(null===(u=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a.push(u[1])}t[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return c[e]=r}(e),arguments)}function a(e,t){return i.apply(null,[e].concat(t||[]))}var c=Object.create(null);t.sprintf=i,t.vsprintf=a,"undefined"!=typeof window&&(window.sprintf=i,window.vsprintf=a,void 0===(r=function(){return{sprintf:i,vsprintf:a}}.call(t,n,t,e))||(e.exports=r))}()},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"WebSocketManager",(function(){return o}));var r=n(0);e.connect=e.connect||{},connect.WebSocketManager=r.a;var o=r.a}.call(this,n(3))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n}])},151:function(){!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect;var t={TEST:"TEST",TRACE:"TRACE",DEBUG:"DEBUG",INFO:"INFO",LOG:"LOG",WARN:"WARN",ERROR:"ERROR",CRITICAL:"CRITICAL"},n={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},o={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)}},i=function(e){var t,r,o=Array.prototype.slice.call(e,0),i=o.shift();return!function(e){return-1!==Object.values(n).indexOf(e)}(i)?(t=i,r=n.CCP):(r=i,t=o.shift()),{format:t,component:r,args:o}},a=function(e,t,n,r){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(o){console.log("Issue finding agentResourceId: ",o)}this.loggerId=r};a.fromObject=function(e){var t=new a(n.CCP,e.level,e.text,e.loggerId);return"[object Date]"===Object.prototype.toString.call(e.time)?t.time=new Date(e.time.getTime()):"number"===typeof e.time?t.time=new Date(e.time):"string"===typeof e.time?t.time=Date.parse(e.time):t.time=new Date,t.exception=e.exception,t.objects=e.objects,t};var c=function e(t){var n=/AuthToken.*\=/g;t&&"object"===typeof t&&Object.keys(t).forEach((function(r){"object"===typeof t[r]?e(t[r]):"string"===typeof t[r]&&("url"===r||"text"===r?t[r]=t[r].replace(n,"[redacted]"):"quickConnectName"===r&&(t[r]="[redacted]"))}))},s=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"):[]};a.prototype.toString=function(){return connect.sprintf("[%s] [%s] [%s]: %s",this.getTime()&&this.getTime().toISOString?this.getTime().toISOString():"???",this.getLevel(),this.getAgentResourceId(),this.getText())},a.prototype.getTime=function(){return this.time},a.prototype.getAgentResourceId=function(){return this.agentResourceId},a.prototype.getLevel=function(){return this.level},a.prototype.getText=function(){return this.text},a.prototype.getComponent=function(){return this.component},a.prototype.withException=function(e){return this.exception=new s(e),this},a.prototype.withObject=function(e){var t=connect.deepcopy(e);return c(t),this.objects.push(t),this},a.prototype.withCrossOriginEventObject=function(e){var t=connect.deepcopyCrossOriginEvent(e);return c(t),this.objects.push(t),this},a.prototype.sendInternalLogToServer=function(){return connect.getLog()._serverBoundInternalLogs.push(this),this};var u=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};u.prototype.setLogRollInterval=function(t){var n=this;this._logRollTimer&&t===this._logRollInterval?this.warn("Logger is already set to the given interval: %d",this._logRollInterval):(this._logRollTimer&&e.clearInterval(this._logRollTimer),this._logRollInterval=t,this._logRollTimer=e.setInterval((function(){this._rolledLogs=this._logs,this._logs=[],this._startLogIndexToPush=0,n.info("Log roll interval occurred.")}),this._logRollInterval))},u.prototype.setLogLevel=function(e){if(!(e in r))throw new Error("Unknown logging level: "+e);this._logLevel=r[e]},u.prototype.setEchoLevel=function(e){if(!(e in r))throw new Error("Unknown logging level: "+e);this._echoLevel=r[e]},u.prototype.write=function(e,t,n){var r=new a(e,t,n,this.getLoggerId());return c(r),this.addLogEntry(r),r},u.prototype.addLogEntry=function(e){c(e),this._logs.push(e),n.SOFTPHONE===e.component&&this._logsToPush.push(e),e.level in r&&r[e.level]>=this._logLevel&&(r[e.level]>=this._echoLevel&&o[e.getLevel()](e.toString()),e.line=this._lineCount++)},u.prototype.sendInternalLogEntryToServer=function(e){this._serverBoundInternalLogs.push(e),e.level in r&&r[e.level]>=this._logLevel&&(r[e.level]>=this._echoLevel&&o[e.getLevel()](e.toString()),e.line=this._lineCount++)},u.prototype.clearObjects=function(){for(var e=0;e=i._logLevel})));var c=new e.Blob([JSON.stringify(a,void 0,4)],["text/plain"]),s=document.createElement("a");n=n||"agent-log";s.href=e.URL.createObjectURL(c),s.download=n+".txt",document.body.appendChild(s),s.click(),document.body.removeChild(s)},u.prototype.scheduleUpstreamLogPush=function(t){connect.upstreamLogPushScheduled||(connect.upstreamLogPushScheduled=!0,e.setInterval(connect.hitch(this,this.reportMasterLogsUpStream,t),5e3))},u.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)}))},u.prototype.scheduleUpstreamOuterContextCCPserverBoundLogsPush=function(t){e.setInterval(connect.hitch(this,this.pushOuterContextCCPserverBoundLogsUpstream,t),1e3)},u.prototype.scheduleUpstreamOuterContextCCPLogsPush=function(t){e.setInterval(connect.hitch(this,this.pushOuterContextCCPLogsUpstream,t),1e3)},u.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 l=function t(n){u.call(this),this.conduit=n,e.setInterval(connect.hitch(this,this._pushLogsDownstream),t.LOG_PUSH_INTERVAL),e.clearInterval(this._logRollTimer),this._logRollTimer=null};l.LOG_PUSH_INTERVAL=1e3,(l.prototype=Object.create(u.prototype)).constructor=l,l.prototype.pushLogsDownstream=function(e){var t=this;e.forEach((function(e){t.conduit.sendDownstream(connect.EventType.LOG,e)}))},l.prototype._pushLogsDownstream=function(){var e=this;this._logs.forEach((function(t){e.conduit.sendDownstream(connect.EventType.LOG,t)})),this._logs=[];for(var t=0;t43&&navigator.permissions.query({name:"microphone"}).then((function(e){e.onchange=function(){l.info("Microphone Permission: "+e.state),x("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:e.state}),"denied"===e.state&&R(p.MICROPHONE_NOT_SHARED,"Your microphone is not enabled in your browser. ","")}}))}catch(e){l.error("Failed in detecting microphone permission status: "+e)}},S=function(){window.setInterval((function(){if(!t&&f)try{t=!0,connect.checkMediaEndpointConnection(f).then((function(e){x("ConnectivityCheckResult",null,Object.assign({},e,{connectivityCheckType:"MediaEndpointCheck",status:e.success})),t=!1}))}catch(e){l.error("Failed in checking media endpoint connection: "+e)}}),3e4)},C=function(e){delete d[e],connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.MUTE_TOGGLE,data:{muted:!1}})},w=function(e){var t;if(0!==connect.keys(d).length){for(var n in e&&void 0!==e.mute&&(t=e.mute),d)if(d.hasOwnProperty(n)){var r=d[n].stream;if(r){var o=r.getAudioTracks()[0];void 0!==t?(o.enabled=!t,d[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=d[n].muted||!1}}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.MUTE_TOGGLE,data:{muted:t}})}},T=function(e){if(0!==connect.keys(d).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(r){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}})}},I=function(e){if(0!==connect.keys(d).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 r in d)if(d.hasOwnProperty(r)){d[r].stream;n.getSession(r)._pc.getSenders()[0].replaceTrack(t).then((function(){n.replaceLocalMediaTrack(r,t)}))}}))}catch(r){l.error("Failed to set microphone device "+t)}connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,data:{deviceId:t}})}},_=function(e,t){if(t===connect.RTCErrors.ICE_COLLECTION_TIMEOUT){for(var n="\n",r=0;r0?t.success(e):t.failure(p.MICROPHONE_NOT_SHARED)}),(function(e){t.failure(p.MICROPHONE_NOT_SHARED)})),r}t.failure(p.UNSUPPORTED_BROWSER)},R=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)})},N=function(e,t){x("Softphone Session Failed",e,{failedReason:t})},x=function(e,t,n){connect.publishMetric({name:e,contactId:t,data:n})},O=function(e,t,n){x(e,t,[{name:"AgentConnectionId",value:n}]),l.info("Publish multiple session error metrics",e,"contactId "+t,"agent connectionId "+n).sendInternalLogToServer()},L=function(){return!!(connect.isOperaBrowser()&&connect.getOperaBrowserVersion()>17)||(!!(connect.isChromeBrowser()&&connect.getChromeBrowserVersion()>22)||!!(connect.isFirefoxBrowser()&&connect.getFirefoxBrowserVersion()>21))},P=function(e){var t=i.slice();i=[],t.length>0&&e.sendSoftphoneMetrics(t,{success:function(){l.info("sendSoftphoneMetrics success"+JSON.stringify(t)).sendInternalLogToServer()},failure:function(e){l.error("sendSoftphoneMetrics failed.").withObject(e).sendInternalLogToServer()}})},D=function(e){s=window.setInterval((function(){e.getUserAudioStats().then((function(e){var t=a;a=e,i.push(F(a,t,r))}),(function(e){l.debug("Failed to get user audio stats.",e).sendInternalLogToServer()})),e.getRemoteAudioStats().then((function(e){var t=c;c=e,i.push(F(c,t,o))}),(function(e){l.debug("Failed to get remote audio stats.",e).sendInternalLogToServer()}))}),1e3)},M=function(e){u=window.setInterval((function(){P(e)}),3e4)},U=function(){a=null,c=null,i=[],s=null,u=null},F=function(e,t,n){if(t&&e){var r=e.packetsLost>t.packetsLost?e.packetsLost-t.packetsLost:0,o=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new B(e.timestamp,r,o,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new B(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},j=function(e){return null!==e&&window.clearInterval(e),null},q=function(e,t){s=j(s),u=j(u),function(e,t,n,i){t.streamStats=[z(n,r),z(i,o)];var a={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(a,{success:function(){l.info("sendSoftphoneReport success"+JSON.stringify(a)).sendInternalLogToServer()},failure:function(e){l.error("sendSoftphoneReport failed.").withObject(e).sendInternalLogToServer()}})}(e,t,z(a,r),z(c,o)),P(e)},B=function(e,t,n,r,o,i,a){this.softphoneStreamType=r,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=o,this.jitterBufferMillis=i,this.roundTripTimeMillis=a},z=function(e,t){return new B((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},V=function(e){this._originalLogger=e;var t=this;this._tee=function(e,n){return function(){var e=Array.prototype.slice.call(arguments[0]),r="";return e.forEach((function(){r+=" %s"})),n.apply(t._originalLogger,[connect.LogComponent.SOFTPHONE,r].concat(e))}}};V.prototype.debug=function(){return this._tee(1,this._originalLogger.debug)(arguments)},V.prototype.info=function(){return this._tee(2,this._originalLogger.info)(arguments)},V.prototype.log=function(){return this._tee(3,this._originalLogger.log)(arguments)},V.prototype.warn=function(){return this._tee(4,this._originalLogger.warn)(arguments)},V.prototype.error=function(){return this._tee(5,this._originalLogger.error)(arguments)},connect.SoftphoneManager=function(e){var n,r=this;(l=new V(connect.getLog())).info("[Softphone Manager] softphone manager initialization has begun").sendInternalLogToServer(),connect.RtcPeerConnectionFactory&&(n=new connect.RtcPeerConnectionFactory(l,connect.core.getWebSocketManager(),h,connect.hitch(r,g,{transportType:"softphone",softphoneClientId:h}),connect.hitch(r,R))),L()||R(p.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ","");A({success:function(e){connect.core.setSoftphoneUserMediaStream(e),x("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:"granted"})},failure:function(e){R(e,"Your microphone is not enabled in your browser. ",""),x("ConnectivityCheckResult",null,{connectivityCheckType:"MicrophonePermission",status:"denied"})}});v(),y(),b(),E(),S(),this.ringtoneEngine=null;var o={},i={};this.onInitContactSub={},this.onInitContactSub.unsubscribe=function(){};var a=!1,c=null,s=null,u=function(){a=!1,c=null,s=null};this.getSession=function(e){return o[e]},this.replaceLocalMediaTrack=function(e,t){var n=d[e].stream;if(n){var r=n.getAudioTracks()[0];t.enabled=r.enabled,r.enabled=!1,n.removeTrack(r),n.addTrack(t)}};var f=function(e){if(o.hasOwnProperty(e)){var t=o[e];new Promise((function(n,r){delete o[e],delete i[e],t.hangup()})).catch((function(t){lily.getLog().warn("Clean up the session locally "+e,t.message).sendInternalLogToServer()}))}};this.startSession=function(e,r){var p=a?c:e,h=a?s:r;if(p&&h){u(),i[h]=!0,l.info("Softphone call detected:","contactId "+p.getContactId(),"agent connectionId "+h).sendInternalLogToServer(),function(e){if(Object.keys(e).length>0){for(var t in e)e.hasOwnProperty(t)&&(O("MultiSessionHangUp",e[t].callId,t),f(t));throw new Error("duplicate session detected, refusing to setup new connection")}}(o),p.getStatus().type===connect.ContactStatusType.CONNECTING&&x("Softphone Connecting",p.getContactId()),U();var g,v=p.getAgentConnection().getSoftphoneMediaInfo(),y=k(v.callConfigJson);y.useWebSocketProvider&&(g=connect.core.getWebSocketManager());var b=new connect.RTCSession(y.signalingEndpoint,y.iceServers,v.callContextToken,l,p.getContactId(),h,g);o[h]=b,connect.core.getSoftphoneUserMediaStream()&&(b.mediaStream=connect.core.getSoftphoneUserMediaStream()),connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConnectionEvents.SESSION_INIT,data:{connectionId:h}}),b.onSessionFailed=function(e,n){delete o[h],delete i[h],_(e,n),N(p.getContactId(),n),q(p,e.sessionReport),t=!1},b.onSessionConnected=function(e){x("Softphone Session Connected",p.getContactId()),connect.becomeMaster(connect.MasterTopics.SEND_LOGS),D(e),M(p),m(p),t=!0},b.onSessionCompleted=function(e){x("Softphone Session Completed",p.getContactId()),delete o[h],delete i[h],q(p,e.sessionReport),C(h),t=!1},b.onLocalStreamAdded=function(e,t){d[h]={stream:t},connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,data:{connectionId:h}})},b.remoteAudioElement=document.getElementById("remote-audio"),n?b.connect(n.get(y.iceServers)):b.connect()}};var w=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)&&(f(t),u()),!e.isSoftphoneCall()||i[t]||e.getStatus().type!==connect.ContactStatusType.CONNECTING&&e.getStatus().type!==connect.ContactStatusType.INCOMING||(connect.isFirefoxBrowser()&&connect.hasOtherConnectedCCPs()?function(e,t){a=!0,c=e,s=t}(e,t):r.startSession(e,t))},T=function(e){var t=e.getAgentConnection().connectionId;l.info("Contact detected:","contactId "+e.getContactId(),"agent connectionId "+t).sendInternalLogToServer(),i[t]||e.onRefresh((function(){w(e,t)}))};r.onInitContactSub=connect.contact(T),(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(),T(e),w(e,t)}))}}()},944:function(){!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)};e.format=function(r,o){var i,a,c,s,u,l,p,f=1,d=r.length,h="",g=[];for(a=0;a>>=0;break;case"x":i=i.toString(16);break;case"X":i=i.toString(16).toUpperCase()}i=/[def]/.test(s[8])&&s[3]&&i>=0?"+"+i:i,l=s[4]?"0"==s[4]?"0":s[4].charAt(1):" ",p=s[6]-String(i).length,u=s[6]?n(l,p):"",g.push(s[5]?i+u:u+i)}return g.join("")},e.cache={},e.parse=function(e){for(var t=e,n=[],r=[],o=0;t;){if(null!==(n=/^[^\x25]+/.exec(t)))r.push(n[0]);else if(null!==(n=/^\x25{2}/.exec(t)))r.push("%");else{if(null===(n=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t)))throw"[sprintf] huh?";if(n[2]){o|=1;var i=[],a=n[2],c=[];if(null===(c=/^([a-z_][a-z_\d]*)/i.exec(a)))throw"[sprintf] huh?";for(i.push(c[1]);""!==(a=a.substring(c[0].length));)if(null!==(c=/^\.([a-z_][a-z_\d]*)/i.exec(a)))i.push(c[1]);else{if(null===(c=/^\[(\d+)\]/.exec(a)))throw"[sprintf] huh?";i.push(c[1])}n[2]=i}else o|=2;if(3===o)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";r.push(n)}t=t.substring(n[0].length)}return r};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("")}this.sprintf=e,this.vsprintf=function(t,n,r){return(r=n.slice(0)).splice(0,0,t),e.apply(null,r)}}()},82:function(){!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 r=function(e,n){t.call(this),this.window=e,this.domain=n||"*"};(r.prototype=Object.create(t.prototype)).constructor=r,r.prototype.send=function(e){this.window.postMessage(e,this.domain)},r.prototype.onMessage=function(e){this.window.addEventListener("message",e)};var o=function(e,n,r){t.call(this),this.input=e,this.output=n,this.domain=r||"*"};(o.prototype=Object.create(t.prototype)).constructor=o,o.prototype.send=function(e){this.output.postMessage(e,this.domain)},o.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 a=function(e){t.call(this),this.streamMap=e?connect.index(e,(function(e){return e.getId()})):{},this.messageListeners=[]};(a.prototype=Object.create(t.prototype)).constructor=a,a.prototype.send=function(e){this.getStreams().forEach((function(t){try{t.send(e)}catch(n){}}))},a.prototype.onMessage=function(e){this.messageListeners.push(e),this.getStreams().forEach((function(t){t.onMessage(e)}))},a.prototype.addStream=function(e){this.streamMap[e.getId()]=e,this.messageListeners.forEach((function(t){e.onMessage(t)}))},a.prototype.removeStream=function(e){delete this.streamMap[e.getId()]},a.prototype.getStreams=function(e){return connect.values(this.streamMap)},a.prototype.getStreamForPort=function(e){return connect.find(this.getStreams(),(function(t){return t.port===e}))};var c=function(e,t,r){this.name=e,this.upstream=t||new n,this.downstream=r||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 s=function(e,t,n,r){c.call(this,e,new o(t,n.contentWindow,r||"*"),null)};(s.prototype=Object.create(c.prototype)).constructor=s,connect.Stream=t,connect.NullStream=n,connect.WindowStream=r,connect.WindowIOStream=o,connect.PortStream=i,connect.StreamMultiplexer=a,connect.Conduit=c,connect.IFrameConduit=s}()},833:function(){!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,r){connect.assertNotNull(e,"fromState"),connect.assertNotNull(n,"toState"),connect.assertNotNull(r,"associations"),t.call(this,e,n),this.associations=r};(n.prototype=Object.create(t.prototype)).constructor=n,n.prototype.getAssociations=function(e){return this.associations};var r=function(e,n,r){connect.assertNotNull(e,"fromState"),connect.assertNotNull(n,"toState"),connect.assertNotNull(r,"closure"),connect.assertTrue(connect.isFunction(r),"closure must be a function"),t.call(this,e,n),this.closure=r};(r.prototype=Object.create(t.prototype)).constructor=r,r.prototype.getAssociations=function(e){return this.closure(e,this.getFromState(),this.getToState())};var o=function(){this.fromMap={}};o.ANY="<>",o.prototype.assoc=function(e,t,o){var i=this;if(!e)throw new Error("fromStateObj is not defined.");if(!t)throw new Error("toStateObj is not defined.");if(!o)throw new Error("assocObj is not defined.");return e instanceof Array?e.forEach((function(e){i.assoc(e,t,o)})):t instanceof Array?t.forEach((function(t){i.assoc(e,t,o)})):"function"===typeof o?this._addAssociation(new r(e,t,o)):o instanceof Array?this._addAssociation(new n(e,t,o)):this._addAssociation(new n(e,t,[o])),this},o.prototype.getAssociations=function(e,t,n){connect.assertNotNull(t,"fromState"),connect.assertNotNull(n,"toState");var r=[],i=this.fromMap[o.ANY]||{},a=this.fromMap[t]||{};return r=(r=r.concat(this._getAssociationsFromMap(i,e,t,n))).concat(this._getAssociationsFromMap(a,e,t,n))},o.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)},o.prototype._getAssociationsFromMap=function(e,t,n,r){return(e[o.ANY]||[]).concat(e[r]||[]).reduce((function(e,n){return e.concat(n.getAssociations(t))}),[])},connect.EventGraph=o}()},891:function(){!function(){var e=this;connect=e.connect||{},e.connect=connect,e.lily=connect;var t=navigator.userAgent,n=["bubbles","cancelBubble","cancelable","composed","data","defaultPrevented","eventPhase","isTrusted","lastEventId","origin","returnValue","timeStamp","type"];connect.sprintf=e.sprintf,connect.vsprintf=e.vsprintf,delete e.sprintf,delete e.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 r=Array.prototype.slice.call(arguments);return n.apply(t,e.concat(r))}},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,r){return r=r||5,n=n||1e3,t=t||{},new Promise((function(o,i){!function r(a){fetch(e,t).then((function(e){e.status===connect.HTTP_STATUS_CODES.SUCCESS?e.json().then((function(e){return o(e)})).catch((function(){return o({})})):1!==a&&(e.status>=connect.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===connect.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout((function(){r(--a)}),n):i(e)})).catch((function(e){i(e)}))}(r)}))},connect.backoff=function(t,n,r,o){connect.assertTrue(connect.isFunction(t),"func must be a Function");var i=this;t({success:function(e){o&&o.success&&o.success(e)},failure:function(a,c){if(r>0){var s=2*n*Math.random();e.setTimeout((function(){i.backoff(t,2*s,--r,o)}),s)}else o&&o.failure&&o.failure(a,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 r=this._getLastOpenedTimestamp(t),o=(new Date).getTime(),i=null;if(o-r>864e5){if(n){var a=n.height||578,c=n.width||433,s=n.top||0,u=n.left||0;(i=window.open("",t,"width="+c+", height="+a+", top="+s+", left="+u)).location!==e&&(i=window.open(e,t,"width="+c+", height="+a+", top="+s+", left="+u))}else(i=window.open("",t)).location!==e&&(i=window.open(e,t));this._setLastOpenedTimestamp(t,o)}return i},connect.PopupManager.prototype.clear=function(t){var n=this._getLocalStorageKey(t);e.localStorage.removeItem(n)},connect.PopupManager.prototype._getLastOpenedTimestamp=function(t){var n=this._getLocalStorageKey(t),r=e.localStorage.getItem(n);return r?parseInt(r,10):0},connect.PopupManager.prototype._setLastOpenedTimestamp=function(t,n){var r=this._getLocalStorageKey(t);e.localStorage.setItem(r,""+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 t=this;"Notification"in e?e.Notification.permission===r.DENIED?(connect.getLog().warn("The user has requested to not receive notifications.").sendInternalLogToServer(),this.permission=r.DENIED):this.permission!==r.GRANTED&&e.Notification.requestPermission().then((function(e){t.permission=e,e===r.GRANTED?t._showQueued():t.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(t){var n=new e.Notification(t.title,t.options);return t.options.clicked&&(n.onclick=function(){t.options.clicked.call(n)}),n},connect.BaseError=function(t,n){e.Error.call(this,connect.vsprintf(t,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 r={};return r.type=e,r.message=t,r.stack=Error(t).stack,r.err=n,r},connect.isCCP=function(){return"ConnectSharedWorkerConduit"===connect.core.getUpstream().name}}()},736:function(){!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 r=this,o=(new Date).getTime();connect.containsValue(connect.AgentAppClientMethods,e)?connect.core.getAgentAppClient()._callImpl(e,t,{success:function(t){r._recordAPILatency(e,o),n.success(t)},failure:function(t){r._recordAPILatency(e,o,t),n.failure(t)}}):connect.core.getClient()._callImpl(e,t,{success:function(t){r._recordAPILatency(e,o),n.success(t)},failure:function(t,i){r._recordAPILatency(e,o,t),n.failure(t,i)},authFailure:function(){r._recordAPILatency(e,o),n.authFailure()},accessDenied:function(){n.accessDenied&&n.accessDenied()}})},n.prototype._recordAPILatency=function(e,t,n){var r=(new Date).getTime()-t;this._sendAPIMetrics(e,r,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 r=function(){var r=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 o=null;connect.rootLogger=new connect.DownstreamConduitLogger(this.conduit),this.conduit.onDownstream(connect.EventType.SEND_LOGS,(function(e){connect.getLog().pushLogsDownstream(e),r.logsBuffer=r.logsBuffer.concat(e),r.logsBuffer.length>400&&r.handleSendLogsRequest(r.logsBuffer)})),this.conduit.onDownstream(connect.EventType.CONFIGURE,(function(t){t.authToken&&t.authToken!==r.initData.authToken&&(r.initData=t,connect.core.init(t),o?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()}}),(o=connect.WebSocketManager.create()).onInitFailure((function(){r.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE)})),o.onConnectionOpen((function(e){r.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_OPEN,e)})),o.onConnectionClose((function(e){r.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_CLOSE,e)})),o.onConnectionGain((function(){r.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED),r.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_GAIN)})),o.onConnectionLost((function(e){r.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e),r.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_LOST,e)})),o.onSubscriptionUpdate((function(e){r.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_UPDATE,e)})),o.onSubscriptionFailure((function(e){r.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_FAILURE,e)})),o.onAllMessage((function(e){r.conduit.sendDownstream(connect.WebSocketEvents.ALL_MESSAGE,e)})),r.conduit.onDownstream(connect.WebSocketEvents.SEND,(function(e){o.sendMessage(e)})),r.conduit.onDownstream(connect.WebSocketEvents.SUBSCRIBE,(function(e){o.subscribeTopics(e)})),o.init(connect.hitch(r,r.getWebSocketUrl)).then((function(t){try{if(t&&!t.webSocketConnectionFailed)connect.getLog().info("Kicking off agent polling").sendInternalLogToServer(),r.pollForAgent(),connect.getLog().info("Kicking off config polling").sendInternalLogToServer(),r.pollForAgentConfiguration({repeatForever:!0}),connect.getLog().info("Kicking off auth token polling").sendInternalLogToServer(),e.setInterval(connect.hitch(r,r.checkAuthToken),3e5);else if(!connect.webSocketInitFailed){var n=connect.WebSocketEvents.INIT_FAILURE;throw r.conduit.sendDownstream(n),connect.webSocketInitFailed=!0,new Error(n)}}catch(o){connect.getLog().error("WebSocket failed to initialize").withException(o).sendInternalLogToServer()}}))))})),this.conduit.onDownstream(connect.EventType.TERMINATE,(function(){r.handleSendLogsRequest(r.logsBuffer),connect.core.terminate(),r.conduit.sendDownstream(connect.EventType.TERMINATED)})),this.conduit.onDownstream(connect.EventType.SYNCHRONIZE,(function(){r.conduit.sendDownstream(connect.EventType.ACKNOWLEDGE)})),this.conduit.onDownstream(connect.EventType.BROADCAST,(function(e){r.conduit.sendDownstream(e.event,e.data)})),e.onconnect=function(e){var t=e.ports[0],n=new connect.PortStream(t);r.multiplexer.addStream(n),t.start();var o=new connect.Conduit(n.getId(),null,n);o.sendDownstream(connect.EventType.ACKNOWLEDGE,{id:n.getId()}),r.portConduitMap[n.getId()]=o,r.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(r.portConduitMap).length}),null!==r.agent&&r.updateAgent(),o.onDownstream(connect.EventType.API_REQUEST,connect.hitch(r,r.handleAPIRequest,o)),o.onDownstream(connect.EventType.MASTER_REQUEST,connect.hitch(r,r.handleMasterRequest,o,n.getId())),o.onDownstream(connect.EventType.RELOAD_AGENT_CONFIGURATION,connect.hitch(r,r.pollForAgentConfiguration)),o.onDownstream(connect.EventType.CLOSE,(function(){r.multiplexer.removeStream(n),delete r.portConduitMap[n.getId()],r.masterCoord.removeMaster(n.getId()),r.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(r.portConduitMap).length})}))}};r.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(r){connect.getLog().error("Long poll failed to update agent.").withObject(n).withException(r).sendInternalLogToServer()}finally{e.setTimeout(connect.hitch(t,t.pollForAgent),100)}},failure:function(n,r){try{connect.getLog().error("Failed to get agent data.").sendInternalLogToServer().withObject({err:n,data:r})}finally{e.setTimeout(connect.hitch(t,t.pollForAgent),5e3)}},authFailure:function(){n()},accessDenied:connect.hitch(t,t.handleAccessDenied)})},r.prototype.pollForAgentConfiguration=function(t){var n=this,r=t||{},o=connect.hitch(n,n.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_CONFIGURATION,{},{success:function(t){var o=t.configuration;n.pollForAgentPermissions(o),n.pollForAgentStates(o),n.pollForDialableCountryCodes(o),n.pollForRoutingProfileQueues(o),r.repeatForever&&e.setTimeout(connect.hitch(n,n.pollForAgentConfiguration,r),3e4)},failure:function(t,o){try{connect.getLog().error("Failed to fetch agent configuration data.").sendInternalLogToServer().withObject({err:t,data:o})}finally{r.repeatForever&&e.setTimeout(connect.hitch(n,n.pollForAgentConfiguration),3e4,r)}},authFailure:function(){o()},accessDenied:connect.hitch(n,n.handleAccessDenied)})},r.prototype.pollForAgentStates=function(e,t){var n=this,r=t||{};r.maxResults=r.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_STATES,{nextToken:r.nextToken||null,maxResults:r.maxResults},{success:function(t){t.nextToken?n.pollForAgentStates(e,{states:(r.states||[]).concat(t.states),nextToken:t.nextToken,maxResults:r.maxResults}):(e.agentStates=(r.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)})},r.prototype.pollForAgentPermissions=function(e,t){var n=this,r=t||{};r.maxResults=r.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_PERMISSIONS,{nextToken:r.nextToken||null,maxResults:r.maxResults},{success:function(t){t.nextToken?n.pollForAgentPermissions(e,{permissions:(r.permissions||[]).concat(t.permissions),nextToken:t.nextToken,maxResults:r.maxResults}):(e.permissions=(r.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)})},r.prototype.pollForDialableCountryCodes=function(e,t){var n=this,r=t||{};r.maxResults=r.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_DIALABLE_COUNTRY_CODES,{nextToken:r.nextToken||null,maxResults:r.maxResults},{success:function(t){t.nextToken?n.pollForDialableCountryCodes(e,{countryCodes:(r.countryCodes||[]).concat(t.countryCodes),nextToken:t.nextToken,maxResults:r.maxResults}):(e.dialableCountries=(r.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)})},r.prototype.pollForRoutingProfileQueues=function(e,t){var n=this,r=t||{};r.maxResults=r.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_ROUTING_PROFILE_QUEUES,{routingProfileARN:e.routingProfile.routingProfileARN,nextToken:r.nextToken||null,maxResults:r.maxResults},{success:function(t){t.nextToken?n.pollForRoutingProfileQueues(e,{countryCodes:(r.queues||[]).concat(t.queues),nextToken:t.nextToken,maxResults:r.maxResults}):(e.routingProfile.queues=(r.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)})},r.prototype.handleAPIRequest=function(e,t){var n=this;this.client.call(t.method,t.params,{success:function(n){var r=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,t,n);e.sendDownstream(r.event,r)},failure:function(r,o){var i=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,t,o,JSON.stringify(r));e.sendDownstream(i.event,i),connect.getLog().error("'%s' API request failed",t.method).withObject({request:n.filterAuthToken(t),response:i}).withException(r).sendInternalLogToServer()},authFailure:connect.hitch(n,n.handleAuthFail)})},r.prototype.handleMasterRequest=function(e,t,n){var r=this.conduit,o=null;switch(n.method){case connect.MasterMethods.BECOME_MASTER:var i=this.masterCoord.getMaster(n.params.topic),a=Boolean(i)&&i!==t;this.masterCoord.setMaster(n.params.topic,t),o=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:t,takeOver:a,topic:n.params.topic}),a&&r.sendDownstream(o.event,o);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),o=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(o.event,o)},r.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()},r.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()},r.prototype.getWebSocketUrl=function(){var e=this,t=connect.core.getClient(),n=connect.hitch(e,e.handleAuthFail),r=connect.hitch(e,e.handleAccessDenied);return new Promise((function(e,o){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}),o({reason:"getWebSocketUrl failed",_debug:e})},authFailure:function(){connect.getLog().error("getWebSocketUrl Auth Failure").sendInternalLogToServer(),o(Error("Authentication failed while getting getWebSocketUrl")),n()},accessDenied:function(){connect.getLog().error("getWebSocketUrl Access Denied Failure").sendInternalLogToServer(),o(Error("Access Denied Failure while getting getWebSocketUrl")),r()}})}))},r.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)})},r.prototype.handleAuthFail=function(){this.conduit.sendDownstream(connect.EventType.AUTH_FAIL)},r.prototype.handleAccessDenied=function(){this.conduit.sendDownstream(connect.EventType.ACCESS_DENIED)},r.prototype.checkAuthToken=function(){var e=this,t=new Date(e.initData.authTokenExpiration),n=(new Date).getTime();t.getTime()