@webex/cc-store 1.28.0-ccwidgets.49 → 1.28.0-ccwidgets.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3688,7 +3688,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
3688
3688
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3689
3689
 
3690
3690
  "use strict";
3691
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../../../node_modules/events/events.js\"));\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _constants2 = __webpack_require__(/*! ./services/constants */ \"../../../node_modules/@webex/plugin-cc/dist/services/constants.js\");\nvar _services = _interopRequireDefault(__webpack_require__(/*! ./services */ \"../../../node_modules/@webex/plugin-cc/dist/services/index.js\"));\nvar _WebexRequest = _interopRequireDefault(__webpack_require__(/*! ./services/core/WebexRequest */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/WebexRequest.js\"));\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ./logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _Utils = __webpack_require__(/*! ./services/core/Utils */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/Utils.js\");\nvar _types2 = __webpack_require__(/*! ./services/config/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/types.js\");\nvar _constants3 = __webpack_require__(/*! ./services/config/constants */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/constants.js\");\nvar _TaskManager = _interopRequireDefault(__webpack_require__(/*! ./services/task/TaskManager */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/TaskManager.js\"));\nvar _WebCallingService = _interopRequireDefault(__webpack_require__(/*! ./services/WebCallingService */ \"../../../node_modules/@webex/plugin-cc/dist/services/WebCallingService.js\"));\nvar _types3 = __webpack_require__(/*! ./services/task/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/types.js\");\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ./metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nvar _constants4 = __webpack_require__(/*! ./metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass ContactCenter extends _webexCore.WebexPlugin {\n namespace = 'cc';\n LoggerProxy = _loggerProxy.default;\n constructor(...args) {\n super(...args);\n this.eventEmitter = new _events.default();\n // @ts-ignore\n this.$webex = this.webex;\n this.$webex.once(_constants.READY, () => {\n // @ts-ignore\n this.$config = this.config;\n\n /**\n * This is used for handling the async requests by sending webex.request and wait for corresponding websocket event.\n */\n this.webexRequest = _WebexRequest.default.getInstance({\n webex: this.$webex\n });\n this.services = _services.default.getInstance({\n webex: this.$webex,\n connectionConfig: this.getConnectionConfig()\n });\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n this.services.webSocketManager.on('message', this.handleWebSocketMessage);\n this.webCallingService = new _WebCallingService.default(this.$webex);\n this.metricsManager = _MetricsManager.default.getInstance({\n webex: this.$webex\n });\n this.taskManager = _TaskManager.default.getTaskManager(this.services.contact, this.webCallingService, this.services.webSocketManager);\n this.incomingTaskListener();\n _loggerProxy.default.initialize(this.$webex.logger);\n });\n }\n handleIncomingTask = task => {\n // @ts-ignore\n this.trigger(_types3.TASK_EVENTS.TASK_INCOMING, task);\n };\n handleTaskHydrate = task => {\n // @ts-ignore\n this.trigger(_types3.TASK_EVENTS.TASK_HYDRATE, task);\n };\n\n /**\n * An Incoming Call listener.\n */\n incomingTaskListener() {\n this.taskManager.on(_types3.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n this.taskManager.on(_types3.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n }\n\n /**\n * This is used for making the CC SDK ready by setting up the cc mercury connection.\n */\n async register() {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_SUCCESS, _constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED]);\n this.setupEventListeners();\n const resp = await this.connectWebsocket();\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n deviceType: resp.deviceType || _constants.EMPTY_STRING\n }, ['operational']);\n return resp;\n } catch (error) {\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED, {\n orgId: error.orgId\n }, ['operational']);\n _loggerProxy.default.error(`Error during register: ${error}`, {\n module: _constants.CC_FILE,\n method: this.register.name\n });\n throw error;\n }\n }\n\n /**\n * Returns the list of buddy agents in the given state and media according to agent profile settings\n *\n * @param {BuddyAgents} data - The data required to fetch buddy agents, including additional agent profile information.\n * @returns {Promise<BuddyAgentsResponse>} A promise that resolves to the response containing buddy agents information.\n * @throws Error\n * @example getBuddyAgents({state: 'Available', mediaType: 'telephony'})\n */\n async getBuddyAgents(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_SUCCESS, _constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_FAILED]);\n const resp = await this.services.agent.buddyAgents({\n data: {\n agentProfileId: this.agentConfig.agentProfileID,\n ...data\n }\n });\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n mediaType: data.mediaType,\n buddyAgentState: data.state,\n buddyAgentCount: resp.data.agentList.length\n }, ['operational']);\n return resp;\n } catch (error) {\n const failureResp = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failureResp),\n mediaType: data.mediaType,\n buddyAgentState: data.state\n }, ['operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'getBuddyAgents', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /**\n * This is used for connecting the websocket and fetching the agent profile.\n * @returns Promise<Profile>\n * @throws Error\n * @private\n */\n async connectWebsocket() {\n try {\n return this.services.webSocketManager.initWebSocket({\n body: this.getConnectionConfig()\n }).then(async data => {\n const agentId = data.agentId;\n const orgId = this.$webex.credentials.getOrgId();\n this.agentConfig = await this.services.config.getAgentConfig(orgId, agentId);\n _loggerProxy.default.log(`Agent config is fetched successfully`, {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n if (this.agentConfig.webRtcEnabled && this.agentConfig.loginVoiceOptions.includes(_types.LoginOption.BROWSER)) {\n this.$webex.internal.mercury.connect().then(() => {\n _loggerProxy.default.info('Authentication: webex.internal.mercury.connect successful', {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n }).catch(error => {\n _loggerProxy.default.error(`Error occurred during mercury.connect() ${error}`, {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n });\n }\n if (this.$config && this.$config.allowAutomatedRelogin) {\n await this.silentRelogin();\n }\n return this.agentConfig;\n }).catch(error => {\n throw error;\n });\n } catch (error) {\n _loggerProxy.default.error(`Error during register: ${error}`, {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n throw error;\n }\n }\n\n /**\n * This is used for agent login.\n * @param data\n * @returns Promise<StationLoginResponse>\n * @throws Error\n */\n async stationLogin(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_LOGIN_FAILED]);\n const loginResponse = this.services.agent.stationLogin({\n data: {\n dialNumber: data.loginOption === _types.LoginOption.BROWSER ? this.agentConfig.agentId : data.dialNumber,\n teamId: data.teamId,\n deviceType: data.loginOption,\n isExtension: data.loginOption === _types.LoginOption.EXTENSION,\n deviceId: this.getDeviceId(data.loginOption, data.dialNumber),\n roles: [_constants2.AGENT],\n // TODO: The public API should not have the following properties so filling them with empty values for now. If needed, we can add them in the future.\n teamName: _constants.EMPTY_STRING,\n siteId: _constants.EMPTY_STRING,\n usesOtherDN: false,\n auxCodeId: _constants.EMPTY_STRING\n }\n });\n if (this.agentConfig.webRtcEnabled && data.loginOption === _types.LoginOption.BROWSER) {\n await this.webCallingService.registerWebCallingLine();\n }\n const resp = await loginResponse;\n const {\n channelsMap,\n ...loginData\n } = resp.data;\n const response = {\n ...loginData,\n mmProfile: {\n chat: channelsMap.chat?.length,\n email: channelsMap.email?.length,\n social: channelsMap.social?.length,\n telephony: channelsMap.telephony?.length\n },\n notifsTrackingId: resp.trackingId\n };\n this.webCallingService.setLoginOption(data.loginOption);\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n loginType: data.loginOption,\n status: resp.data.status,\n // 'LoggedIn'\n type: resp.data.type,\n // 'AgentStationLoginSuccess'\n roles: resp.data.roles?.join(',') || _constants.EMPTY_STRING\n }, ['behavioral', 'business', 'operational']);\n\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n // this.services.webSocketManager.on('message', this.handleWebSocketMessage);\n // this.incomingTaskListener();\n\n return response;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n loginType: data.loginOption\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'stationLogin', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /** This is used for agent logout.\n * @param data\n * @returns Promise<StationLogoutResponse>\n * @throws Error\n */\n async stationLogout(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_FAILED]);\n const logoutResponse = this.services.agent.logout({\n data\n });\n const resp = await logoutResponse;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n logoutReason: data.logoutReason\n }, ['behavioral', 'business', 'operational']);\n if (this.webCallingService) {\n this.webCallingService.deregisterWebCallingLine();\n }\n\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n // this.services.webSocketManager.off('message', this.handleWebSocketMessage);\n // this.taskManager.unregisterIncomingCallEvent();\n // this.taskManager.off(TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n // this.taskManager.off(TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n\n return resp;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n logoutReason: data.logoutReason\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'stationLogout', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /* This is used for agent relogin.\n * @returns Promise<StationReLoginResponse>\n * @throws Error\n */\n async stationReLogin() {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_FAILED]);\n const reLoginResponse = await this.services.agent.reload();\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(reLoginResponse)\n }, ['behavioral', 'business', 'operational']);\n return reLoginResponse;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure)\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'stationReLogin', _constants.CC_FILE);\n throw detailedError;\n }\n }\n getDeviceId(loginOption, dialNumber) {\n if (loginOption === _types.LoginOption.EXTENSION || loginOption === _types.LoginOption.AGENT_DN) {\n return dialNumber;\n }\n return _constants2.WEB_RTC_PREFIX + this.agentConfig.agentId;\n }\n\n /**\n * This is used for setting agent state.\n * @param options\n * @returns Promise<SetStateResponse>\n * @throws Error\n */\n\n async setAgentState(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, _constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_FAILED]);\n const agentStatusResponse = await this.services.agent.stateChange({\n data: {\n ...data,\n agentId: data.agentId || this.agentConfig.agentId\n }\n });\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(agentStatusResponse),\n requestedState: data.state,\n teamId: this.agentConfig?.teams[0]?.teamId ?? _constants.EMPTY_STRING,\n status: agentStatusResponse.data?.status,\n subStatus: agentStatusResponse.data?.subStatus,\n auxCodeId: data.auxCodeId,\n lastStateChangeReason: data.lastStateChangeReason || _constants.EMPTY_STRING\n }, ['behavioral', 'business', 'operational']);\n _loggerProxy.default.log(`SET AGENT STATUS API SUCCESS`, {\n module: _constants.CC_FILE,\n method: this.setAgentState.name\n });\n return agentStatusResponse;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n state: data.state,\n auxCodeId: data.auxCodeId,\n lastStateChangeReason: data.lastStateChangeReason || _constants.EMPTY_STRING\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'setAgentState', _constants.CC_FILE);\n throw detailedError;\n }\n }\n handleWebSocketMessage = event => {\n const eventData = JSON.parse(event);\n // Re-emit the events related to agent\n if (Object.values(_types2.CC_AGENT_EVENTS).includes(eventData.data?.type)) {\n // @ts-ignore\n this.emit(eventData.data.type, eventData.data);\n }\n if (eventData.type === _types2.CC_EVENTS.AGENT_STATE_CHANGE) {\n // @ts-ignore\n this.emit(_constants.AGENT_STATE_CHANGE, eventData.data);\n }\n if (eventData.type === _types2.CC_EVENTS.AGENT_MULTI_LOGIN) {\n // @ts-ignore\n this.emit(_constants.AGENT_MULTI_LOGIN, eventData.data);\n }\n };\n\n /**\n * For setting up the Event Emitter listeners and handlers\n */\n setupEventListeners() {\n this.services.connectionService.on('connectionLost', this.handleConnectionLost.bind(this));\n }\n\n /**\n * This method returns the connection configuration.\n */\n getConnectionConfig() {\n return {\n force: this.$config?.force ?? true,\n isKeepAliveEnabled: this.$config?.isKeepAliveEnabled ?? false,\n clientType: this.$config?.clientType ?? 'WebexCCSDK',\n allowMultiLogin: this.$config?.allowMultiLogin ?? true\n };\n }\n\n /**\n * Called when the reconnection has been completed\n */\n async handleConnectionLost(msg) {\n if (msg.isConnectionLost) {\n // TODO: Emit an event saying connection is lost\n _loggerProxy.default.info('event=handleConnectionLost | Connection lost', {\n module: _constants.CC_FILE,\n method: this.handleConnectionLost.name\n });\n } else if (msg.isSocketReconnected) {\n // TODO: Emit an event saying connection is re-estabilished\n _loggerProxy.default.info('event=handleConnectionReconnect | Connection reconnected attempting to request silent relogin', {\n module: _constants.CC_FILE,\n method: this.handleConnectionLost.name\n });\n if (this.$config && this.$config.allowAutomatedRelogin) {\n await this.silentRelogin();\n }\n }\n }\n\n /**\n * Called when we finish registration to silently handle the errors\n */\n async silentRelogin() {\n try {\n const reLoginResponse = await this.services.agent.reload();\n const {\n agentId,\n lastStateChangeReason,\n deviceType,\n dn,\n lastStateChangeTimestamp,\n lastIdleCodeChangeTimestamp\n } = reLoginResponse.data;\n let {\n auxCodeId\n } = reLoginResponse.data;\n this.agentConfig.lastStateChangeTimestamp = lastStateChangeTimestamp;\n this.agentConfig.lastIdleCodeChangeTimestamp = lastIdleCodeChangeTimestamp;\n await this.handleDeviceType(deviceType, dn);\n\n // To handle re-registration of event listeners on silent relogin\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n // this.incomingTaskListener();\n\n if (lastStateChangeReason === 'agent-wss-disconnect') {\n _loggerProxy.default.info('event=requestAutoStateChange | Requesting state change to available on socket reconnect', {\n module: _constants.CC_FILE,\n method: this.silentRelogin.name\n });\n auxCodeId = _constants3.AGENT_STATE_AVAILABLE_ID;\n const stateChangeData = {\n state: _constants3.AGENT_STATE_AVAILABLE,\n auxCodeId,\n lastStateChangeReason,\n agentId\n };\n try {\n const agentStatusResponse = await this.setAgentState(stateChangeData);\n this.agentConfig.lastStateChangeTimestamp = agentStatusResponse.data.lastStateChangeTimestamp;\n this.agentConfig.lastIdleCodeChangeTimestamp = agentStatusResponse.data.lastIdleCodeChangeTimestamp;\n } catch (error) {\n _loggerProxy.default.error(`event=requestAutoStateChange | Error requesting state change to available on socket reconnect: ${error}`, {\n module: _constants.CC_FILE,\n method: this.silentRelogin.name\n });\n }\n }\n this.agentConfig.lastStateAuxCodeId = auxCodeId;\n this.agentConfig.isAgentLoggedIn = true;\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n this.services.webSocketManager.on('message', this.handleWebSocketMessage);\n } catch (error) {\n const {\n reason,\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'silentReLogin', _constants.CC_FILE);\n if (reason === 'AGENT_NOT_FOUND') {\n _loggerProxy.default.log('Agent not found during re-login, handling silently', {\n module: _constants.CC_FILE,\n method: 'silentRelogin'\n });\n return;\n }\n throw detailedError;\n }\n }\n\n /**\n * Handles the device type specific logic\n */\n async handleDeviceType(deviceType, dn) {\n this.webCallingService.setLoginOption(deviceType);\n this.agentConfig.deviceType = deviceType;\n switch (deviceType) {\n case _types.LoginOption.BROWSER:\n await this.webCallingService.registerWebCallingLine();\n break;\n case _types.LoginOption.AGENT_DN:\n case _types.LoginOption.EXTENSION:\n this.agentConfig.defaultDn = dn;\n break;\n default:\n _loggerProxy.default.error(`Unsupported device type: ${deviceType}`, {\n module: _constants.CC_FILE,\n method: this.handleDeviceType.name\n });\n throw new Error(`Unsupported device type: ${deviceType}`);\n }\n }\n\n /**\n * This is used for making the outdial call.\n * @param destination\n * @returns Promise<TaskResponse>\n * @throws Error\n * @example\n * ```typescript\n * const destination = '1234567890';\n * const result = await webex.cc.startOutdial(destination).then(()=>{}).catch(()=>{});\n * ```\n */\n\n async startOutdial(destination) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_SUCCESS, _constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_FAILED]);\n\n // Construct the outdial payload.\n const outDialPayload = {\n destination,\n entryPointId: this.agentConfig.outDialEp,\n direction: _constants.OUTDIAL_DIRECTION,\n attributes: _constants.ATTRIBUTES,\n mediaType: _constants.OUTDIAL_MEDIA_TYPE,\n outboundType: _constants.OUTBOUND_TYPE\n };\n const result = await this.services.dialer.startOutdial({\n data: outDialPayload\n });\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result),\n destination,\n mediaType: _constants.OUTDIAL_MEDIA_TYPE\n }, ['behavioral', 'business', 'operational']);\n return result;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n destination,\n mediaType: _constants.OUTDIAL_MEDIA_TYPE\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'startOutdial', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /**\n * This is used for getting the list of queues.\n * @param search - optional\n * @param filter - optional\n * @param page - default is 0\n * @param pageSize - default is 100\n * @returns Promise<ContactServiceQueue[]>\n * @throws Error\n *\n * @example\n * ```typescript\n * const search = 'queue';\n * const filter = 'id == \"e23ad456-1ebd-1b43-b9d0-34f39c7dcb5e\"';\n * const page = 0;\n * const pageSize = 100;\n * const result = await webex.cc.getQueues(search, filter, page, pageSize);\n * ```\n */\n async getQueues(search, filter, page = _constants3.DEFAULT_PAGE, pageSize = _constants3.DEFAULT_PAGE_SIZE) {\n const orgId = this.$webex.credentials.getOrgId();\n if (!orgId) {\n _loggerProxy.default.error('Org ID not found.', {\n module: _constants.CC_FILE,\n method: this.getQueues.name\n });\n throw new Error('Org ID not found.');\n }\n return this.services.config.getQueues(orgId, page, pageSize, search, filter);\n }\n\n /**\n * Uploads logs to help troubleshoot SDK issues.\n *\n * This method collects the current SDK logs including network requests, WebSocket\n * messages, and client-side events, then securely submits them to Webex's diagnostics\n * service. The returned tracking ID, feedbackID can be provided to Webex support for faster\n * issue resolution.\n * @returns Promise<SubmitLogsResponse>\n * @throws Error\n */\n async uploadLogs() {\n return this.webexRequest.uploadLogs();\n }\n}\nexports[\"default\"] = ContactCenter;\n//# sourceMappingURL=cc.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/cc.js?");
3691
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _webexCore = __webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\");\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../../../node_modules/events/events.js\"));\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _constants2 = __webpack_require__(/*! ./services/constants */ \"../../../node_modules/@webex/plugin-cc/dist/services/constants.js\");\nvar _services = _interopRequireDefault(__webpack_require__(/*! ./services */ \"../../../node_modules/@webex/plugin-cc/dist/services/index.js\"));\nvar _WebexRequest = _interopRequireDefault(__webpack_require__(/*! ./services/core/WebexRequest */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/WebexRequest.js\"));\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ./logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _Utils = __webpack_require__(/*! ./services/core/Utils */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/Utils.js\");\nvar _types2 = __webpack_require__(/*! ./services/config/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/types.js\");\nvar _constants3 = __webpack_require__(/*! ./services/config/constants */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/constants.js\");\nvar _TaskManager = _interopRequireDefault(__webpack_require__(/*! ./services/task/TaskManager */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/TaskManager.js\"));\nvar _WebCallingService = _interopRequireDefault(__webpack_require__(/*! ./services/WebCallingService */ \"../../../node_modules/@webex/plugin-cc/dist/services/WebCallingService.js\"));\nvar _types3 = __webpack_require__(/*! ./services/task/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/types.js\");\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ./metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nvar _constants4 = __webpack_require__(/*! ./metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass ContactCenter extends _webexCore.WebexPlugin {\n namespace = 'cc';\n LoggerProxy = _loggerProxy.default;\n constructor(...args) {\n super(...args);\n this.eventEmitter = new _events.default();\n // @ts-ignore\n this.$webex = this.webex;\n this.$webex.once(_constants.READY, () => {\n // @ts-ignore\n this.$config = this.config;\n\n /**\n * This is used for handling the async requests by sending webex.request and wait for corresponding websocket event.\n */\n this.webexRequest = _WebexRequest.default.getInstance({\n webex: this.$webex\n });\n this.services = _services.default.getInstance({\n webex: this.$webex,\n connectionConfig: this.getConnectionConfig()\n });\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n this.services.webSocketManager.on('message', this.handleWebSocketMessage);\n this.webCallingService = new _WebCallingService.default(this.$webex);\n this.metricsManager = _MetricsManager.default.getInstance({\n webex: this.$webex\n });\n this.taskManager = _TaskManager.default.getTaskManager(this.services.contact, this.webCallingService, this.services.webSocketManager);\n this.incomingTaskListener();\n _loggerProxy.default.initialize(this.$webex.logger);\n });\n }\n handleIncomingTask = task => {\n // @ts-ignore\n this.trigger(_types3.TASK_EVENTS.TASK_INCOMING, task);\n };\n handleTaskHydrate = task => {\n // @ts-ignore\n this.trigger(_types3.TASK_EVENTS.TASK_HYDRATE, task);\n };\n\n /**\n * An Incoming Call listener.\n */\n incomingTaskListener() {\n this.taskManager.on(_types3.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n this.taskManager.on(_types3.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n }\n\n /**\n * This is used for making the CC SDK ready by setting up the cc mercury connection.\n */\n async register() {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_SUCCESS, _constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED]);\n this.setupEventListeners();\n const resp = await this.connectWebsocket();\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n deviceType: resp.deviceType || _constants.EMPTY_STRING\n }, ['operational']);\n return resp;\n } catch (error) {\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED, {\n orgId: error.orgId\n }, ['operational']);\n _loggerProxy.default.error(`Error during register: ${error}`, {\n module: _constants.CC_FILE,\n method: this.register.name\n });\n this.webexRequest.uploadLogs({\n correlationId: error?.trackingId\n });\n throw error;\n }\n }\n\n /**\n * Returns the list of buddy agents in the given state and media according to agent profile settings\n *\n * @param {BuddyAgents} data - The data required to fetch buddy agents, including additional agent profile information.\n * @returns {Promise<BuddyAgentsResponse>} A promise that resolves to the response containing buddy agents information.\n * @throws Error\n * @example getBuddyAgents({state: 'Available', mediaType: 'telephony'})\n */\n async getBuddyAgents(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_SUCCESS, _constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_FAILED]);\n const resp = await this.services.agent.buddyAgents({\n data: {\n agentProfileId: this.agentConfig.agentProfileID,\n ...data\n }\n });\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n mediaType: data.mediaType,\n buddyAgentState: data.state,\n buddyAgentCount: resp.data.agentList.length\n }, ['operational']);\n return resp;\n } catch (error) {\n const failureResp = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failureResp),\n mediaType: data.mediaType,\n buddyAgentState: data.state\n }, ['operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'getBuddyAgents', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /**\n * This is used for connecting the websocket and fetching the agent profile.\n * @returns Promise<Profile>\n * @throws Error\n * @private\n */\n async connectWebsocket() {\n try {\n return this.services.webSocketManager.initWebSocket({\n body: this.getConnectionConfig()\n }).then(async data => {\n const agentId = data.agentId;\n const orgId = this.$webex.credentials.getOrgId();\n this.agentConfig = await this.services.config.getAgentConfig(orgId, agentId);\n _loggerProxy.default.log(`Agent config is fetched successfully`, {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n if (this.agentConfig.webRtcEnabled && this.agentConfig.loginVoiceOptions.includes(_types.LoginOption.BROWSER)) {\n this.$webex.internal.mercury.connect().then(() => {\n _loggerProxy.default.info('Authentication: webex.internal.mercury.connect successful', {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n }).catch(error => {\n _loggerProxy.default.error(`Error occurred during mercury.connect() ${error}`, {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n });\n }\n if (this.$config && this.$config.allowAutomatedRelogin) {\n await this.silentRelogin();\n }\n return this.agentConfig;\n }).catch(error => {\n throw error;\n });\n } catch (error) {\n _loggerProxy.default.error(`Error during register: ${error}`, {\n module: _constants.CC_FILE,\n method: this.connectWebsocket.name\n });\n throw error;\n }\n }\n\n /**\n * This is used for agent login.\n * @param data\n * @returns Promise<StationLoginResponse>\n * @throws Error\n */\n async stationLogin(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_LOGIN_FAILED]);\n const loginResponse = this.services.agent.stationLogin({\n data: {\n dialNumber: data.loginOption === _types.LoginOption.BROWSER ? this.agentConfig.agentId : data.dialNumber,\n teamId: data.teamId,\n deviceType: data.loginOption,\n isExtension: data.loginOption === _types.LoginOption.EXTENSION,\n deviceId: this.getDeviceId(data.loginOption, data.dialNumber),\n roles: [_constants2.AGENT],\n // TODO: The public API should not have the following properties so filling them with empty values for now. If needed, we can add them in the future.\n teamName: _constants.EMPTY_STRING,\n siteId: _constants.EMPTY_STRING,\n usesOtherDN: false,\n auxCodeId: _constants.EMPTY_STRING\n }\n });\n if (this.agentConfig.webRtcEnabled && data.loginOption === _types.LoginOption.BROWSER) {\n await this.webCallingService.registerWebCallingLine();\n }\n const resp = await loginResponse;\n const {\n channelsMap,\n ...loginData\n } = resp.data;\n const response = {\n ...loginData,\n mmProfile: {\n chat: channelsMap.chat?.length,\n email: channelsMap.email?.length,\n social: channelsMap.social?.length,\n telephony: channelsMap.telephony?.length\n },\n notifsTrackingId: resp.trackingId\n };\n this.webCallingService.setLoginOption(data.loginOption);\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n loginType: data.loginOption,\n status: resp.data.status,\n // 'LoggedIn'\n type: resp.data.type,\n // 'AgentStationLoginSuccess'\n roles: resp.data.roles?.join(',') || _constants.EMPTY_STRING\n }, ['behavioral', 'business', 'operational']);\n\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n // this.services.webSocketManager.on('message', this.handleWebSocketMessage);\n // this.incomingTaskListener();\n\n return response;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n loginType: data.loginOption\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'stationLogin', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /** This is used for agent logout.\n * @param data\n * @returns Promise<StationLogoutResponse>\n * @throws Error\n */\n async stationLogout(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_FAILED]);\n const logoutResponse = this.services.agent.logout({\n data\n });\n const resp = await logoutResponse;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),\n logoutReason: data.logoutReason\n }, ['behavioral', 'business', 'operational']);\n if (this.webCallingService) {\n this.webCallingService.deregisterWebCallingLine();\n }\n\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n // this.services.webSocketManager.off('message', this.handleWebSocketMessage);\n // this.taskManager.unregisterIncomingCallEvent();\n // this.taskManager.off(TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n // this.taskManager.off(TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n\n return resp;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGOUT_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n logoutReason: data.logoutReason\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'stationLogout', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /* This is used for agent relogin.\n * @returns Promise<StationReLoginResponse>\n * @throws Error\n */\n async stationReLogin() {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_SUCCESS, _constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_FAILED]);\n const reLoginResponse = await this.services.agent.reload();\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(reLoginResponse)\n }, ['behavioral', 'business', 'operational']);\n return reLoginResponse;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_RELOGIN_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure)\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'stationReLogin', _constants.CC_FILE);\n throw detailedError;\n }\n }\n getDeviceId(loginOption, dialNumber) {\n if (loginOption === _types.LoginOption.EXTENSION || loginOption === _types.LoginOption.AGENT_DN) {\n return dialNumber;\n }\n return _constants2.WEB_RTC_PREFIX + this.agentConfig.agentId;\n }\n\n /**\n * This is used for setting agent state.\n * @param options\n * @returns Promise<SetStateResponse>\n * @throws Error\n */\n\n async setAgentState(data) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, _constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_FAILED]);\n const agentStatusResponse = await this.services.agent.stateChange({\n data: {\n ...data,\n agentId: data.agentId || this.agentConfig.agentId\n }\n });\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(agentStatusResponse),\n requestedState: data.state,\n teamId: this.agentConfig?.teams[0]?.teamId ?? _constants.EMPTY_STRING,\n status: agentStatusResponse.data?.status,\n subStatus: agentStatusResponse.data?.subStatus,\n auxCodeId: data.auxCodeId,\n lastStateChangeReason: data.lastStateChangeReason || _constants.EMPTY_STRING\n }, ['behavioral', 'business', 'operational']);\n _loggerProxy.default.log(`SET AGENT STATUS API SUCCESS`, {\n module: _constants.CC_FILE,\n method: this.setAgentState.name\n });\n return agentStatusResponse;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n state: data.state,\n auxCodeId: data.auxCodeId,\n lastStateChangeReason: data.lastStateChangeReason || _constants.EMPTY_STRING\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'setAgentState', _constants.CC_FILE);\n throw detailedError;\n }\n }\n handleWebSocketMessage = event => {\n const eventData = JSON.parse(event);\n // Re-emit the events related to agent\n if (Object.values(_types2.CC_AGENT_EVENTS).includes(eventData.data?.type)) {\n // @ts-ignore\n this.emit(eventData.data.type, eventData.data);\n }\n if (eventData.type === _types2.CC_EVENTS.AGENT_STATE_CHANGE) {\n // @ts-ignore\n this.emit(_constants.AGENT_STATE_CHANGE, eventData.data);\n }\n if (eventData.type === _types2.CC_EVENTS.AGENT_MULTI_LOGIN) {\n // @ts-ignore\n this.emit(_constants.AGENT_MULTI_LOGIN, eventData.data);\n }\n };\n\n /**\n * For setting up the Event Emitter listeners and handlers\n */\n setupEventListeners() {\n this.services.connectionService.on('connectionLost', this.handleConnectionLost.bind(this));\n }\n\n /**\n * This method returns the connection configuration.\n */\n getConnectionConfig() {\n return {\n force: this.$config?.force ?? true,\n isKeepAliveEnabled: this.$config?.isKeepAliveEnabled ?? false,\n clientType: this.$config?.clientType ?? 'WebexCCSDK',\n allowMultiLogin: this.$config?.allowMultiLogin ?? true\n };\n }\n\n /**\n * Called when the reconnection has been completed\n */\n async handleConnectionLost(msg) {\n if (msg.isConnectionLost) {\n // TODO: Emit an event saying connection is lost\n _loggerProxy.default.info('event=handleConnectionLost | Connection lost', {\n module: _constants.CC_FILE,\n method: this.handleConnectionLost.name\n });\n } else if (msg.isSocketReconnected) {\n // TODO: Emit an event saying connection is re-estabilished\n _loggerProxy.default.info('event=handleConnectionReconnect | Connection reconnected attempting to request silent relogin', {\n module: _constants.CC_FILE,\n method: this.handleConnectionLost.name\n });\n if (this.$config && this.$config.allowAutomatedRelogin) {\n await this.silentRelogin();\n }\n }\n }\n\n /**\n * Called when we finish registration to silently handle the errors\n */\n async silentRelogin() {\n try {\n const reLoginResponse = await this.services.agent.reload();\n const {\n agentId,\n lastStateChangeReason,\n deviceType,\n dn,\n lastStateChangeTimestamp,\n lastIdleCodeChangeTimestamp\n } = reLoginResponse.data;\n let {\n auxCodeId\n } = reLoginResponse.data;\n this.agentConfig.lastStateChangeTimestamp = lastStateChangeTimestamp;\n this.agentConfig.lastIdleCodeChangeTimestamp = lastIdleCodeChangeTimestamp;\n await this.handleDeviceType(deviceType, dn);\n\n // To handle re-registration of event listeners on silent relogin\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n // this.incomingTaskListener();\n\n if (lastStateChangeReason === 'agent-wss-disconnect') {\n _loggerProxy.default.info('event=requestAutoStateChange | Requesting state change to available on socket reconnect', {\n module: _constants.CC_FILE,\n method: this.silentRelogin.name\n });\n auxCodeId = _constants3.AGENT_STATE_AVAILABLE_ID;\n const stateChangeData = {\n state: _constants3.AGENT_STATE_AVAILABLE,\n auxCodeId,\n lastStateChangeReason,\n agentId\n };\n try {\n const agentStatusResponse = await this.setAgentState(stateChangeData);\n this.agentConfig.lastStateChangeTimestamp = agentStatusResponse.data.lastStateChangeTimestamp;\n this.agentConfig.lastIdleCodeChangeTimestamp = agentStatusResponse.data.lastIdleCodeChangeTimestamp;\n } catch (error) {\n _loggerProxy.default.error(`event=requestAutoStateChange | Error requesting state change to available on socket reconnect: ${error}`, {\n module: _constants.CC_FILE,\n method: this.silentRelogin.name\n });\n }\n }\n this.agentConfig.lastStateAuxCodeId = auxCodeId;\n this.agentConfig.isAgentLoggedIn = true;\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n this.services.webSocketManager.on('message', this.handleWebSocketMessage);\n } catch (error) {\n const {\n reason,\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'silentReLogin', _constants.CC_FILE);\n if (reason === 'AGENT_NOT_FOUND') {\n _loggerProxy.default.log('Agent not found during re-login, handling silently', {\n module: _constants.CC_FILE,\n method: 'silentRelogin'\n });\n return;\n }\n throw detailedError;\n }\n }\n\n /**\n * Handles the device type specific logic\n */\n async handleDeviceType(deviceType, dn) {\n this.webCallingService.setLoginOption(deviceType);\n this.agentConfig.deviceType = deviceType;\n switch (deviceType) {\n case _types.LoginOption.BROWSER:\n await this.webCallingService.registerWebCallingLine();\n break;\n case _types.LoginOption.AGENT_DN:\n case _types.LoginOption.EXTENSION:\n this.agentConfig.defaultDn = dn;\n break;\n default:\n _loggerProxy.default.error(`Unsupported device type: ${deviceType}`, {\n module: _constants.CC_FILE,\n method: this.handleDeviceType.name\n });\n throw new Error(`Unsupported device type: ${deviceType}`);\n }\n }\n\n /**\n * This is used for making the outdial call.\n * @param destination\n * @returns Promise<TaskResponse>\n * @throws Error\n * @example\n * ```typescript\n * const destination = '1234567890';\n * const result = await webex.cc.startOutdial(destination).then(()=>{}).catch(()=>{});\n * ```\n */\n\n async startOutdial(destination) {\n try {\n this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_SUCCESS, _constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_FAILED]);\n\n // Construct the outdial payload.\n const outDialPayload = {\n destination,\n entryPointId: this.agentConfig.outDialEp,\n direction: _constants.OUTDIAL_DIRECTION,\n attributes: _constants.ATTRIBUTES,\n mediaType: _constants.OUTDIAL_MEDIA_TYPE,\n outboundType: _constants.OUTBOUND_TYPE\n };\n const result = await this.services.dialer.startOutdial({\n data: outDialPayload\n });\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_SUCCESS, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result),\n destination,\n mediaType: _constants.OUTDIAL_MEDIA_TYPE\n }, ['behavioral', 'business', 'operational']);\n return result;\n } catch (error) {\n const failure = error.details;\n this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.TASK_OUTDIAL_FAILED, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),\n destination,\n mediaType: _constants.OUTDIAL_MEDIA_TYPE\n }, ['behavioral', 'business', 'operational']);\n const {\n error: detailedError\n } = (0, _Utils.getErrorDetails)(error, 'startOutdial', _constants.CC_FILE);\n throw detailedError;\n }\n }\n\n /**\n * This is used for getting the list of queues.\n * @param search - optional\n * @param filter - optional\n * @param page - default is 0\n * @param pageSize - default is 100\n * @returns Promise<ContactServiceQueue[]>\n * @throws Error\n *\n * @example\n * ```typescript\n * const search = 'queue';\n * const filter = 'id == \"e23ad456-1ebd-1b43-b9d0-34f39c7dcb5e\"';\n * const page = 0;\n * const pageSize = 100;\n * const result = await webex.cc.getQueues(search, filter, page, pageSize);\n * ```\n */\n async getQueues(search, filter, page = _constants3.DEFAULT_PAGE, pageSize = _constants3.DEFAULT_PAGE_SIZE) {\n const orgId = this.$webex.credentials.getOrgId();\n if (!orgId) {\n _loggerProxy.default.error('Org ID not found.', {\n module: _constants.CC_FILE,\n method: this.getQueues.name\n });\n throw new Error('Org ID not found.');\n }\n return this.services.config.getQueues(orgId, page, pageSize, search, filter);\n }\n\n /**\n * Uploads logs to help troubleshoot SDK issues.\n *\n * This method collects the current SDK logs including network requests, WebSocket\n * messages, and client-side events, then securely submits them to Webex's diagnostics\n * service. The returned tracking ID, feedbackID can be provided to Webex support for faster\n * issue resolution.\n * @returns Promise<SubmitLogsResponse>\n * @throws Error\n */\n async uploadLogs() {\n return this.webexRequest.uploadLogs();\n }\n}\nexports[\"default\"] = ContactCenter;\n//# sourceMappingURL=cc.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/cc.js?");
3692
3692
 
3693
3693
  /***/ }),
3694
3694
 
@@ -3864,7 +3864,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
3864
3864
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3865
3865
 
3866
3866
  "use strict";
3867
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.getErrorDetails = exports.createErrDetailsObject = void 0;\nvar Err = _interopRequireWildcard(__webpack_require__(/*! ./Err */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/Err.js\"));\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != typeof e && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nconst getCommonErrorDetails = errObj => {\n return {\n trackingId: errObj?.headers?.trackingid || errObj?.headers?.TrackingID,\n msg: errObj?.body\n };\n};\nconst getErrorDetails = (error, methodName, moduleName) => {\n const failure = error.details;\n const reason = failure?.data?.reason ?? `Error while performing ${methodName}`;\n if (!(reason === 'AGENT_NOT_FOUND' && methodName === 'silentReLogin')) {\n _loggerProxy.default.error(`${methodName} failed with trackingId: ${failure?.trackingId}`, {\n module: moduleName,\n method: methodName\n });\n }\n return {\n error: new Error(reason ?? `Error while performing ${methodName}`),\n reason\n };\n};\nexports.getErrorDetails = getErrorDetails;\nconst createErrDetailsObject = errObj => {\n const details = getCommonErrorDetails(errObj);\n return new Err.Details('Service.reqs.generic.failure', details);\n};\nexports.createErrDetailsObject = createErrDetailsObject;\n//# sourceMappingURL=Utils.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/core/Utils.js?");
3867
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.getErrorDetails = exports.createErrDetailsObject = void 0;\nvar Err = _interopRequireWildcard(__webpack_require__(/*! ./Err */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/Err.js\"));\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _WebexRequest = _interopRequireDefault(__webpack_require__(/*! ./WebexRequest */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/WebexRequest.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != typeof e && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nconst getCommonErrorDetails = errObj => {\n return {\n trackingId: errObj?.headers?.trackingid || errObj?.headers?.TrackingID,\n msg: errObj?.body\n };\n};\nconst getErrorDetails = (error, methodName, moduleName) => {\n const failure = error.details;\n const reason = failure?.data?.reason ?? `Error while performing ${methodName}`;\n if (!(reason === 'AGENT_NOT_FOUND' && methodName === 'silentReLogin')) {\n _loggerProxy.default.error(`${methodName} failed with trackingId: ${failure?.trackingId}`, {\n module: moduleName,\n method: methodName\n });\n // we can add more conditions here if not needed for specific cases eg: silentReLogin\n _WebexRequest.default.getInstance().uploadLogs({\n correlationId: failure?.trackingId\n });\n }\n return {\n error: new Error(reason ?? `Error while performing ${methodName}`),\n reason\n };\n};\nexports.getErrorDetails = getErrorDetails;\nconst createErrDetailsObject = errObj => {\n const details = getCommonErrorDetails(errObj);\n return new Err.Details('Service.reqs.generic.failure', details);\n};\nexports.createErrDetailsObject = createErrDetailsObject;\n//# sourceMappingURL=Utils.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/core/Utils.js?");
3868
3868
 
3869
3869
  /***/ }),
3870
3870
 
@@ -3875,7 +3875,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
3875
3875
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3876
3876
 
3877
3877
  "use strict";
3878
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _constants = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _constants2 = __webpack_require__(/*! ../../metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ../../metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass WebexRequest {\n static getInstance(options) {\n if (!WebexRequest.instance && options && options.webex) {\n WebexRequest.instance = new WebexRequest(options);\n }\n return WebexRequest.instance;\n }\n constructor(options) {\n const {\n webex\n } = options;\n this.webex = webex;\n }\n async request(options) {\n const {\n service,\n resource,\n method,\n body\n } = options;\n return this.webex.request({\n service,\n resource,\n method,\n body\n });\n }\n\n /**\n * This is used for uploading the logs to backend/mats.\n *\n * @param metaData - meta data to be uploaded.\n */\n async uploadLogs(metaData = {}) {\n const feedbackId = crypto.randomUUID();\n try {\n const response = await this.webex.internal.support.submitLogs({\n ...metaData,\n feedbackId\n });\n _loggerProxy.default.info(`Logs uploaded successfully`, {\n module: _constants.WEBEX_REQUEST_FILE,\n method: this.uploadLogs.name\n });\n _MetricsManager.default.getInstance().trackEvent(_constants2.METRIC_EVENT_NAMES.UPLOAD_LOGS_SUCCESS, {\n trackingId: response?.trackingid,\n feedbackId\n }, ['behavioral']);\n return {\n trackingid: response.trackingid,\n ...(response.url ? {\n url: response.url\n } : {}),\n ...(response.userId ? {\n userId: response.userId\n } : {}),\n feedbackId\n };\n } catch (error) {\n _loggerProxy.default.error(`Error uploading logs: ${error}`, {\n module: _constants.WEBEX_REQUEST_FILE,\n method: this.uploadLogs.name\n });\n _MetricsManager.default.getInstance().trackEvent(_constants2.METRIC_EVENT_NAMES.UPLOAD_LOGS_FAILED, {\n stack: error?.stack,\n feedbackId\n }, ['behavioral']);\n throw error;\n }\n }\n}\nvar _default = exports[\"default\"] = WebexRequest;\n//# sourceMappingURL=WebexRequest.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/core/WebexRequest.js?");
3878
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _constants = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _constants2 = __webpack_require__(/*! ../../metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ../../metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass WebexRequest {\n static getInstance(options) {\n if (!WebexRequest.instance && options && options.webex) {\n WebexRequest.instance = new WebexRequest(options);\n }\n return WebexRequest.instance;\n }\n constructor(options) {\n const {\n webex\n } = options;\n this.webex = webex;\n }\n async request(options) {\n const {\n service,\n resource,\n method,\n body\n } = options;\n return this.webex.request({\n service,\n resource,\n method,\n body\n });\n }\n\n /**\n * This is used for uploading the logs to backend/mats.\n *\n * @param metaData - meta data to be uploaded.\n */\n async uploadLogs(metaData = {}) {\n const feedbackId = crypto.randomUUID();\n try {\n const response = await this.webex.internal.support.submitLogs({\n ...metaData,\n feedbackId\n }, undefined,\n // we dont send logs but take from webex logger\n {\n type: 'diff'\n } // this is to take the diff logs from previous upload\n );\n\n _loggerProxy.default.info(`Logs uploaded successfully with feedbackId: ${feedbackId}`, {\n module: _constants.WEBEX_REQUEST_FILE,\n method: 'uploadLogs'\n });\n _MetricsManager.default.getInstance().trackEvent(_constants2.METRIC_EVENT_NAMES.UPLOAD_LOGS_SUCCESS, {\n trackingId: response?.trackingid,\n feedbackId,\n correlationId: metaData?.correlationId\n }, ['behavioral']);\n return {\n trackingid: response.trackingid,\n ...(response.url ? {\n url: response.url\n } : {}),\n ...(response.userId ? {\n userId: response.userId\n } : {}),\n ...(response.correlationId ? {\n correlationId: response.correlationId\n } : {}),\n feedbackId\n };\n } catch (error) {\n _loggerProxy.default.error(`Error uploading logs: ${error}`, {\n module: _constants.WEBEX_REQUEST_FILE,\n method: 'uploadLogs'\n });\n _MetricsManager.default.getInstance().trackEvent(_constants2.METRIC_EVENT_NAMES.UPLOAD_LOGS_FAILED, {\n stack: error?.stack,\n feedbackId,\n correlationId: metaData?.correlationId\n }, ['behavioral']);\n throw error;\n }\n }\n}\nvar _default = exports[\"default\"] = WebexRequest;\n//# sourceMappingURL=WebexRequest.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/core/WebexRequest.js?");
3879
3879
 
3880
3880
  /***/ }),
3881
3881
 
@@ -3886,7 +3886,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
3886
3886
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3887
3887
 
3888
3888
  "use strict";
3889
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar Err = _interopRequireWildcard(__webpack_require__(/*! ./Err */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/Err.js\"));\nvar _types = __webpack_require__(/*! ../../types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/constants.js\");\nvar _constants2 = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _WebexRequest = _interopRequireDefault(__webpack_require__(/*! ./WebexRequest */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/WebexRequest.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != typeof e && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nclass AqmReqs {\n pendingRequests = {};\n pendingNotifCancelrequest = {};\n constructor(webSocketManager) {\n this.webexRequest = _WebexRequest.default.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n req(c) {\n return (p, cbRes) => this.makeAPIRequest(c(p), cbRes);\n }\n reqEmpty(c) {\n return cbRes => this.makeAPIRequest(c(), cbRes);\n }\n async makeAPIRequest(c, cbRes) {\n return this.createPromise(c, cbRes);\n }\n createPromise(c, cbRes) {\n return new Promise((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.'\n }));\n return;\n }\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n this.pendingRequests[keySuccess] = {\n check: msg => this.bindCheck(c.notifSuccess.bind, msg),\n handle: msg => {\n clear();\n resolve(msg);\n }\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: msg => this.bindCheck(c.notifCancel?.bind, msg),\n handle: msg => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess\n };\n }\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: msg => this.bindCheck(c.notifFail.bind, msg),\n handle: msg => {\n clear();\n const notifFail = c.notifFail;\n if ('errId' in notifFail) {\n _loggerProxy.default.log(`Routing request failed: ${msg}`, {\n module: _constants2.AQM_REQS_FILE,\n method: 'createPromise'\n });\n const eerr = new Err.Details(notifFail.errId, msg);\n _loggerProxy.default.log(`Routing request failed: ${eerr}`, {\n module: _constants2.AQM_REQS_FILE,\n method: 'createPromise'\n });\n reject(eerr);\n } else {\n reject(notifFail.err(msg));\n }\n }\n };\n }\n let response = null;\n this.webexRequest.request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? _types.HTTP_METHODS.POST : _types.HTTP_METHODS.GET,\n body: c.data\n }).then(res => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n }).catch(error => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n if (c.timeout !== 'disabled') {\n window.setTimeout(() => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n _loggerProxy.default.error(`Routing request timeout${keySuccess}${response}${c.url}`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.createPromise.name\n });\n reject(new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response\n }));\n }, c.timeout && c.timeout > 0 ? c.timeout : _constants.TIMEOUT_REQ);\n }\n });\n }\n bindPrint(bind) {\n let result = '';\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n result += `${k}=[${bind[k].join(',')}],`;\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n result += `${k}=(${this.bindPrint(bind[k])}),`;\n } else {\n result += `${k}=${bind[k]},`;\n }\n }\n return result ? result.slice(0, -1) : result;\n }\n bindCheck(bind, msg) {\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n // Check if the message value matches any of the values in the array\n if (!bind[k].includes(msg[k])) {\n return false;\n }\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n if (typeof msg[k] === 'object' && msg[k] !== null) {\n if (!this.bindCheck(bind[k], msg[k])) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msg[k] || msg[k] !== bind[k]) {\n return false;\n }\n }\n return true;\n }\n\n // must be lambda\n onMessage = msg => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n _loggerProxy.default.info(`Welcome message from Notifs Websocket`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n return;\n }\n if (event.keepalive === 'true') {\n _loggerProxy.default.info(`Keepalive from web socket`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n return;\n }\n if (event.type === 'AgentReloginFailed') {\n _loggerProxy.default.info('Silently handling the agent relogin fail', {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n }\n let isHandled = false;\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n _loggerProxy.default.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n }\n };\n}\nexports[\"default\"] = AqmReqs;\n//# sourceMappingURL=aqm-reqs.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/core/aqm-reqs.js?");
3889
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar Err = _interopRequireWildcard(__webpack_require__(/*! ./Err */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/Err.js\"));\nvar _types = __webpack_require__(/*! ../../types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _constants = __webpack_require__(/*! ./constants */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/constants.js\");\nvar _constants2 = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _WebexRequest = _interopRequireDefault(__webpack_require__(/*! ./WebexRequest */ \"../../../node_modules/@webex/plugin-cc/dist/services/core/WebexRequest.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _getRequireWildcardCache(e) { if (\"function\" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }\nfunction _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || \"object\" != typeof e && \"function\" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if (\"default\" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }\nclass AqmReqs {\n pendingRequests = {};\n pendingNotifCancelrequest = {};\n constructor(webSocketManager) {\n this.webexRequest = _WebexRequest.default.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n req(c) {\n return (p, cbRes) => this.makeAPIRequest(c(p), cbRes);\n }\n reqEmpty(c) {\n return cbRes => this.makeAPIRequest(c(), cbRes);\n }\n async makeAPIRequest(c, cbRes) {\n return this.createPromise(c, cbRes);\n }\n createPromise(c, cbRes) {\n return new Promise((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.'\n }));\n return;\n }\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n this.pendingRequests[keySuccess] = {\n check: msg => this.bindCheck(c.notifSuccess.bind, msg),\n handle: msg => {\n clear();\n resolve(msg);\n }\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: msg => this.bindCheck(c.notifCancel?.bind, msg),\n handle: msg => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess\n };\n }\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: msg => this.bindCheck(c.notifFail.bind, msg),\n handle: msg => {\n clear();\n const notifFail = c.notifFail;\n if ('errId' in notifFail) {\n _loggerProxy.default.log(`Routing request failed: ${JSON.stringify(msg)}`, {\n module: _constants2.AQM_REQS_FILE,\n method: 'createPromise'\n });\n const eerr = new Err.Details(notifFail.errId, msg);\n _loggerProxy.default.log(`Routing request failed: ${eerr}`, {\n module: _constants2.AQM_REQS_FILE,\n method: 'createPromise'\n });\n reject(eerr);\n } else {\n reject(notifFail.err(msg));\n }\n }\n };\n }\n let response = null;\n this.webexRequest.request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? _types.HTTP_METHODS.POST : _types.HTTP_METHODS.GET,\n body: c.data\n }).then(res => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n }).catch(error => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n if (c.timeout !== 'disabled') {\n window.setTimeout(() => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n _loggerProxy.default.error(`Routing request timeout${keySuccess}${response}${c.url}`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.createPromise.name\n });\n reject(new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response\n }));\n }, c.timeout && c.timeout > 0 ? c.timeout : _constants.TIMEOUT_REQ);\n }\n });\n }\n bindPrint(bind) {\n let result = '';\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n result += `${k}=[${bind[k].join(',')}],`;\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n result += `${k}=(${this.bindPrint(bind[k])}),`;\n } else {\n result += `${k}=${bind[k]},`;\n }\n }\n return result ? result.slice(0, -1) : result;\n }\n bindCheck(bind, msg) {\n // eslint-disable-next-line no-restricted-syntax\n for (const k in bind) {\n if (Array.isArray(bind[k])) {\n // Check if the message value matches any of the values in the array\n if (!bind[k].includes(msg[k])) {\n return false;\n }\n } else if (typeof bind[k] === 'object' && bind[k] !== null) {\n if (typeof msg[k] === 'object' && msg[k] !== null) {\n if (!this.bindCheck(bind[k], msg[k])) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msg[k] || msg[k] !== bind[k]) {\n return false;\n }\n }\n return true;\n }\n\n // must be lambda\n onMessage = msg => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n _loggerProxy.default.info(`Welcome message from Notifs Websocket`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n return;\n }\n if (event.keepalive === 'true') {\n _loggerProxy.default.info(`Keepalive from web socket`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n return;\n }\n if (event.type === 'AgentReloginFailed') {\n _loggerProxy.default.info('Silently handling the agent relogin fail', {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n }\n let isHandled = false;\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n _loggerProxy.default.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: _constants2.AQM_REQS_FILE,\n method: this.onMessage.name\n });\n }\n };\n}\nexports[\"default\"] = AqmReqs;\n//# sourceMappingURL=aqm-reqs.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/core/aqm-reqs.js?");
3890
3890
 
3891
3891
  /***/ }),
3892
3892
 
@@ -3952,7 +3952,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
3952
3952
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3953
3953
 
3954
3954
  "use strict";
3955
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../../../node_modules/events/events.js\"));\nvar _calling = __webpack_require__(/*! @webex/calling */ \"../../../node_modules/@webex/calling/dist/module/index.js\");\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/types.js\");\nvar _constants = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _types2 = __webpack_require__(/*! ../config/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/types.js\");\nvar _types3 = __webpack_require__(/*! ../../types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _ = _interopRequireDefault(__webpack_require__(/*! . */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/index.js\"));\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ../../metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nvar _constants2 = __webpack_require__(/*! ../../metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass TaskManager extends _events.default {\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n constructor(contact, webCallingService, webSocketManager) {\n super();\n this.contact = contact;\n this.taskCollection = {};\n this.webCallingService = webCallingService;\n this.webSocketManager = webSocketManager;\n this.metricsManager = _MetricsManager.default.getInstance();\n this.registerTaskListeners();\n this.registerIncomingCallEvent();\n }\n handleIncomingWebCall = call => {\n const currentTask = Object.values(this.taskCollection).find(task => task.data.interaction.mediaType === 'telephony');\n if (currentTask) {\n this.webCallingService.mapCallToTask(call.getCallId(), currentTask.data.interactionId);\n _loggerProxy.default.log('Call mapped to task', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'handleIncomingWebCall'\n });\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, currentTask);\n }\n this.call = call;\n };\n registerIncomingCallEvent() {\n this.webCallingService.on(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n unregisterIncomingCallEvent() {\n this.webCallingService.off(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n registerTaskListeners() {\n this.webSocketManager.on('message', event => {\n const payload = JSON.parse(event);\n // Re-emit the task events to the task object\n let task;\n if (payload.data?.type) {\n if (Object.values(_types2.CC_TASK_EVENTS).includes(payload.data.type)) {\n task = this.taskCollection[payload.data.interactionId];\n if (task) {\n task.emit(payload.data.type, payload.data);\n }\n }\n switch (payload.data.type) {\n case _types2.CC_EVENTS.AGENT_CONTACT:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction?.participants?.[payload.data.agentId]?.isWrapUp || false\n });\n this.taskCollection[payload.data.interactionId] = task;\n this.emit(_types.TASK_EVENTS.TASK_HYDRATE, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_RESERVED:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n isConsulted: false\n }); // Ensure isConsulted prop exists\n this.taskCollection[payload.data.interactionId] = task;\n if (this.webCallingService.loginOption !== _types3.LoginOption.BROWSER || task.data.interaction.mediaType !== _types.MEDIA_CHANNEL.TELEPHONY // for digital channels\n ) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n } else if (this.call) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONTACT:\n // We don't have to emit any event here since this will be result of promise.\n task = this.updateTaskData(task, payload.data);\n _loggerProxy.default.log('Agent offer contact', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_OUTBOUND_FAILED:\n // We don't have to emit any event here since this will be result of promise.\n if (task.data) {\n this.removeTaskFromCollection(task);\n }\n _loggerProxy.default.log('Agent outbound failed', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_ASSIGNED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_ASSIGNED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNASSIGNED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_OFFER_RONA:\n task = this.updateTaskData(task, payload.data);\n this.metricsManager.trackEvent(_constants2.METRIC_EVENT_NAMES.AGENT_RONA, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(payload.data),\n taskId: payload.data.interactionId,\n reason: payload.data.reason\n }, ['behavioral', 'operational']);\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_REJECT, payload.data.reason);\n break;\n case _types2.CC_EVENTS.CONTACT_ENDED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction.state !== 'new'\n });\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_HELD:\n // As soon as the main interaction is held, we need to emit TASK_HOLD\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_HOLD, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNHELD:\n // As soon as the main interaction is unheld, we need to emit TASK_RESUME\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_RESUME, task);\n break;\n case _types2.CC_EVENTS.AGENT_VTEAM_TRANSFERRED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCEL_FAILED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_FAILED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_CREATED:\n // Received when self agent initiates a consult\n task = this.updateTaskData(task, payload.data);\n // Do not emit anything since this be received only as a result of an API invocation(handled by a promise)\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONSULT:\n // Received when other agent sends us a consult offer\n task = this.updateTaskData(task, {\n ...payload.data,\n isConsulted: true // This ensures that the task is marked as us being requested for a consult\n });\n\n break;\n case _types2.CC_EVENTS.AGENT_CONSULTING:\n // Received when agent is in an active consult state\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // Fire only if you are the agent who received the consult request\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_ACCEPTED, task);\n } else {\n // Fire only if you are the agent who initiated the consult\n task.emit(_types.TASK_EVENTS.TASK_CONSULTING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_FAILED:\n // This can only be received by the agent who initiated the consult.\n // We need not emit any event here since this will be result of promise\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_ENDED:\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // This will be the end state of the task as soon as we end the consult in case of\n // us being offered a consult\n this.removeTaskFromCollection(task);\n }\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCELLED:\n // This event is received when the consult using queue is cancelled using API\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, task);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPUP:\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPPEDUP:\n this.removeTaskFromCollection(task);\n break;\n default:\n break;\n }\n }\n });\n }\n updateTaskData(task, taskData) {\n const currentTask = task.updateTaskData(taskData);\n this.taskCollection[taskData.interactionId] = currentTask;\n return currentTask;\n }\n removeTaskFromCollection(task) {\n if (task?.data?.interactionId) {\n delete this.taskCollection[task.data.interactionId];\n _loggerProxy.default.info(`Task removed from collection: ${task.data.interactionId}`, {\n module: _constants.TASK_MANAGER_FILE,\n method: 'removeTaskFromCollection'\n });\n }\n }\n handleTaskCleanup(task) {\n if (this.webCallingService.loginOption === _types3.LoginOption.BROWSER && task.data.interaction.mediaType === 'telephony') {\n task.unregisterWebCallListeners();\n this.webCallingService.cleanUpCall();\n }\n if (task.data.interaction.state === 'new') {\n // Only remove tasks in 'new' state immediately. For other states,\n // retain tasks until they complete wrap-up, unless the task disconnected before being answered.\n this.removeTaskFromCollection(task);\n }\n }\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getTask = taskId => {\n return this.taskCollection[taskId];\n };\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getAllTasks = () => {\n return this.taskCollection;\n };\n\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n static getTaskManager = (contact, webCallingService, webSocketManager) => {\n if (!this.taskManager) {\n this.taskManager = new TaskManager(contact, webCallingService, webSocketManager);\n }\n return this.taskManager;\n };\n}\nexports[\"default\"] = TaskManager;\n//# sourceMappingURL=TaskManager.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/task/TaskManager.js?");
3955
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _events = _interopRequireDefault(__webpack_require__(/*! events */ \"../../../node_modules/events/events.js\"));\nvar _calling = __webpack_require__(/*! @webex/calling */ \"../../../node_modules/@webex/calling/dist/module/index.js\");\nvar _types = __webpack_require__(/*! ./types */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/types.js\");\nvar _constants = __webpack_require__(/*! ../../constants */ \"../../../node_modules/@webex/plugin-cc/dist/constants.js\");\nvar _types2 = __webpack_require__(/*! ../config/types */ \"../../../node_modules/@webex/plugin-cc/dist/services/config/types.js\");\nvar _types3 = __webpack_require__(/*! ../../types */ \"../../../node_modules/@webex/plugin-cc/dist/types.js\");\nvar _loggerProxy = _interopRequireDefault(__webpack_require__(/*! ../../logger-proxy */ \"../../../node_modules/@webex/plugin-cc/dist/logger-proxy.js\"));\nvar _ = _interopRequireDefault(__webpack_require__(/*! . */ \"../../../node_modules/@webex/plugin-cc/dist/services/task/index.js\"));\nvar _MetricsManager = _interopRequireDefault(__webpack_require__(/*! ../../metrics/MetricsManager */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/MetricsManager.js\"));\nvar _constants2 = __webpack_require__(/*! ../../metrics/constants */ \"../../../node_modules/@webex/plugin-cc/dist/metrics/constants.js\");\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nclass TaskManager extends _events.default {\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n constructor(contact, webCallingService, webSocketManager) {\n super();\n this.contact = contact;\n this.taskCollection = {};\n this.webCallingService = webCallingService;\n this.webSocketManager = webSocketManager;\n this.metricsManager = _MetricsManager.default.getInstance();\n this.registerTaskListeners();\n this.registerIncomingCallEvent();\n }\n handleIncomingWebCall = call => {\n const currentTask = Object.values(this.taskCollection).find(task => task.data.interaction.mediaType === 'telephony');\n if (currentTask) {\n this.webCallingService.mapCallToTask(call.getCallId(), currentTask.data.interactionId);\n _loggerProxy.default.log('Call mapped to task', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'handleIncomingWebCall'\n });\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, currentTask);\n }\n this.call = call;\n };\n registerIncomingCallEvent() {\n this.webCallingService.on(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n unregisterIncomingCallEvent() {\n this.webCallingService.off(_calling.LINE_EVENTS.INCOMING_CALL, this.handleIncomingWebCall);\n }\n registerTaskListeners() {\n this.webSocketManager.on('message', event => {\n const payload = JSON.parse(event);\n // Re-emit the task events to the task object\n let task;\n if (payload.data?.type) {\n if (Object.values(_types2.CC_TASK_EVENTS).includes(payload.data.type)) {\n task = this.taskCollection[payload.data.interactionId];\n if (task) {\n task.emit(payload.data.type, payload.data);\n }\n }\n switch (payload.data.type) {\n case _types2.CC_EVENTS.AGENT_CONTACT:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction?.participants?.[payload.data.agentId]?.isWrapUp || false\n });\n this.taskCollection[payload.data.interactionId] = task;\n this.emit(_types.TASK_EVENTS.TASK_HYDRATE, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_RESERVED:\n task = new _.default(this.contact, this.webCallingService, {\n ...payload.data,\n isConsulted: false\n }); // Ensure isConsulted prop exists\n this.taskCollection[payload.data.interactionId] = task;\n if (this.webCallingService.loginOption !== _types3.LoginOption.BROWSER || task.data.interaction.mediaType !== _types.MEDIA_CHANNEL.TELEPHONY // for digital channels\n ) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n } else if (this.call) {\n this.emit(_types.TASK_EVENTS.TASK_INCOMING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONTACT:\n // We don't have to emit any event here since this will be result of promise.\n task = this.updateTaskData(task, payload.data);\n _loggerProxy.default.log('Agent offer contact', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_OUTBOUND_FAILED:\n // We don't have to emit any event here since this will be result of promise.\n if (task.data) {\n this.removeTaskFromCollection(task);\n }\n _loggerProxy.default.log('Agent outbound failed', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'registerTaskListeners'\n });\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_ASSIGNED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_ASSIGNED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNASSIGNED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_OFFER_RONA:\n task = this.updateTaskData(task, payload.data);\n this.metricsManager.trackEvent(_constants2.METRIC_EVENT_NAMES.AGENT_RONA, {\n ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(payload.data),\n taskId: payload.data.interactionId,\n reason: payload.data.reason\n }, ['behavioral', 'operational']);\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_REJECT, payload.data.reason);\n break;\n case _types2.CC_EVENTS.CONTACT_ENDED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: payload.data.interaction.state !== 'new'\n });\n this.handleTaskCleanup(task);\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_HELD:\n // As soon as the main interaction is held, we need to emit TASK_HOLD\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_HOLD, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONTACT_UNHELD:\n // As soon as the main interaction is unheld, we need to emit TASK_RESUME\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_RESUME, task);\n break;\n case _types2.CC_EVENTS.AGENT_VTEAM_TRANSFERRED:\n task = this.updateTaskData(task, {\n ...payload.data,\n wrapUpRequired: true\n });\n task.emit(_types.TASK_EVENTS.TASK_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCEL_FAILED:\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_FAILED, task);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_CREATED:\n // Received when self agent initiates a consult\n task = this.updateTaskData(task, {\n ...payload.data,\n isConsulted: false // This ensures that the task consult status is always reset\n });\n // Do not emit anything since this be received only as a result of an API invocation(handled by a promise)\n break;\n case _types2.CC_EVENTS.AGENT_OFFER_CONSULT:\n // Received when other agent sends us a consult offer\n task = this.updateTaskData(task, {\n ...payload.data,\n isConsulted: true // This ensures that the task is marked as us being requested for a consult\n });\n\n break;\n case _types2.CC_EVENTS.AGENT_CONSULTING:\n // Received when agent is in an active consult state\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // Fire only if you are the agent who received the consult request\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_ACCEPTED, task);\n } else {\n // Fire only if you are the agent who initiated the consult\n task.emit(_types.TASK_EVENTS.TASK_CONSULTING, task);\n }\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_FAILED:\n // This can only be received by the agent who initiated the consult.\n // We need not emit any event here since this will be result of promise\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_CONSULT_ENDED:\n task = this.updateTaskData(task, payload.data);\n if (task.data.isConsulted) {\n // This will be the end state of the task as soon as we end the consult in case of\n // us being offered a consult\n this.removeTaskFromCollection(task);\n }\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_END, task);\n break;\n case _types2.CC_EVENTS.AGENT_CTQ_CANCELLED:\n // This event is received when the consult using queue is cancelled using API\n task = this.updateTaskData(task, payload.data);\n task.emit(_types.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, task);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPUP:\n task = this.updateTaskData(task, payload.data);\n break;\n case _types2.CC_EVENTS.AGENT_WRAPPEDUP:\n this.removeTaskFromCollection(task);\n break;\n default:\n break;\n }\n }\n });\n }\n updateTaskData(task, taskData) {\n if (!task) {\n return undefined;\n }\n if (!taskData?.interactionId) {\n _loggerProxy.default.warn('Received task update with missing interactionId', {\n module: _constants.TASK_MANAGER_FILE,\n method: 'updateTaskData'\n });\n }\n try {\n const currentTask = task.updateTaskData(taskData);\n this.taskCollection[taskData.interactionId] = currentTask;\n return currentTask;\n } catch (error) {\n _loggerProxy.default.error(`Failed to update task ${taskData.interactionId}`, {\n module: _constants.TASK_MANAGER_FILE,\n method: 'updateTaskData'\n });\n return task;\n }\n }\n removeTaskFromCollection(task) {\n if (task?.data?.interactionId) {\n delete this.taskCollection[task.data.interactionId];\n _loggerProxy.default.info(`Task removed from collection: ${task.data.interactionId}`, {\n module: _constants.TASK_MANAGER_FILE,\n method: 'removeTaskFromCollection'\n });\n }\n }\n handleTaskCleanup(task) {\n if (this.webCallingService.loginOption === _types3.LoginOption.BROWSER && task.data.interaction.mediaType === 'telephony') {\n task.unregisterWebCallListeners();\n this.webCallingService.cleanUpCall();\n }\n if (task.data.interaction.state === 'new') {\n // Only remove tasks in 'new' state immediately. For other states,\n // retain tasks until they complete wrap-up, unless the task disconnected before being answered.\n this.removeTaskFromCollection(task);\n }\n }\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getTask = taskId => {\n return this.taskCollection[taskId];\n };\n\n /**\n * @param taskId - Unique identifier for each task\n */\n getAllTasks = () => {\n return this.taskCollection;\n };\n\n /**\n * @param contact - Routing Contact layer. Talks to AQMReq layer to convert events to promises\n * @param webCallingService - Webrtc Service Layer\n * @param webSocketManager - Websocket Manager to maintain websocket connection and keepalives\n */\n static getTaskManager = (contact, webCallingService, webSocketManager) => {\n if (!this.taskManager) {\n this.taskManager = new TaskManager(contact, webCallingService, webSocketManager);\n }\n return this.taskManager;\n };\n}\nexports[\"default\"] = TaskManager;\n//# sourceMappingURL=TaskManager.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/../../../node_modules/@webex/plugin-cc/dist/services/task/TaskManager.js?");
3956
3956
 
3957
3957
  /***/ }),
3958
3958
 
@@ -12368,7 +12368,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
12368
12368
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
12369
12369
 
12370
12370
  "use strict";
12371
- eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst store_types_1 = __webpack_require__(/*! ./store.types */ \"./src/store.types.ts\");\nconst store_1 = __importDefault(__webpack_require__(/*! ./store */ \"./src/store.ts\"));\nconst mobx_1 = __webpack_require__(/*! mobx */ \"../../../node_modules/mobx/dist/mobx.esm.js\");\nclass StoreWrapper {\n constructor() {\n this.setCurrentTheme = (theme) => {\n this.store.currentTheme = theme;\n };\n this.setShowMultipleLoginAlert = (value) => {\n this.store.showMultipleLoginAlert = value;\n };\n this.setDeviceType = (option) => {\n this.store.deviceType = option;\n };\n this.setDialNumber = (input) => {\n this.store.dialNumber = input;\n };\n this.setCurrentState = (state) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentState = state;\n this.store.customState = null;\n });\n };\n this.setLastStateChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastStateChangeTimestamp = timestamp;\n });\n };\n this.setLastIdleCodeChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastIdleCodeChangeTimestamp = timestamp;\n });\n };\n this.setIsAgentLoggedIn = (value) => {\n this.store.isAgentLoggedIn = value;\n };\n this.setWrapupRequired = (value) => {\n this.store.wrapupRequired = value;\n };\n this.setCurrentTask = (task) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentTask = task;\n });\n };\n this.setIncomingTask = (task) => {\n this.store.incomingTask = task;\n };\n this.setTaskList = (taskList) => {\n this.store.taskList = taskList;\n };\n this.setWrapupCodes = (wrapupCodes) => {\n this.store.wrapupCodes = wrapupCodes;\n };\n this.setConsultCompleted = (value) => {\n this.store.consultCompleted = value;\n };\n this.setConsultInitiated = (value) => {\n this.store.consultInitiated = value;\n };\n this.setConsultAccepted = (value) => {\n this.store.consultAccepted = value;\n };\n this.setConsultOfferReceived = (value) => {\n this.store.consultOfferReceived = value;\n };\n this.setConsultStartTimeStamp = (timestamp) => {\n this.store.consultStartTimeStamp = timestamp;\n };\n this.setCallControlAudio = (audio) => {\n this.store.callControlAudio = audio;\n };\n this.setIsQueueConsultInProgress = (value) => {\n (0, mobx_1.runInAction)(() => {\n this.store.isQueueConsultInProgress = value;\n });\n };\n this.setCurrentConsultQueueId = (queueId) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentConsultQueueId = queueId;\n });\n };\n this.setState = (state) => {\n if ('reset' in state) {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = null;\n });\n return;\n }\n if ('id' in state) {\n (0, mobx_1.runInAction)(() => {\n this.setCurrentState(state.id);\n this.store.customState = null;\n });\n }\n else {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = state;\n });\n }\n };\n this.setTaskRejected = (callback) => {\n this.onTaskRejected = callback;\n };\n this.setCCCallback = (event, callback) => {\n if (!callback)\n return;\n this.store.cc.on(event, callback);\n };\n this.setTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (!task)\n return;\n task.on(event, callback);\n };\n this.removeCCCallback = (event) => {\n this.store.cc.off(event);\n };\n this.removeTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (!task)\n return;\n task.off(event, callback);\n };\n this.registerCC = (webex) => {\n return this.store.registerCC(webex);\n };\n this.handleTaskRemove = (event) => {\n const taskId = event;\n // Remove the task from the taskList\n const taskToRemove = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (taskToRemove) {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_END, ({ wrapupRequired }) => this.handleTaskEnd(taskToRemove, wrapupRequired));\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(taskToRemove.interactionId, reason));\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n taskToRemove.off(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n this.setCallControlAudio(null);\n }\n }\n const updateTaskList = this.store.taskList.filter((task) => task.data.interactionId !== taskId);\n (0, mobx_1.runInAction)(() => {\n var _a, _b;\n this.setTaskList(updateTaskList);\n this.setWrapupRequired(false);\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n // Remove the task from currentTask or incomingTask if it is the same task\n if (((_a = this.store.currentTask) === null || _a === void 0 ? void 0 : _a.data.interactionId) === taskId) {\n this.setCurrentTask(null);\n }\n if (((_b = this.store.incomingTask) === null || _b === void 0 ? void 0 : _b.data.interactionId) === taskId) {\n this.setIncomingTask(null);\n }\n // reset the custom state\n this.setState({\n reset: true,\n });\n });\n };\n this.handleTaskEnd = (event, wrapupRequired) => {\n // If the call is ended by agent we get the task object in event.data\n // If the call is ended by customer we get the task object directly\n const task = event.data ? event.data : event;\n if (wrapupRequired) {\n this.setWrapupRequired(true);\n }\n else {\n this.handleTaskRemove(task.interactionId);\n }\n };\n this.handleTaskAssigned = (event) => {\n const task = event;\n (0, mobx_1.runInAction)(() => {\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n }\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n });\n };\n this.handleTaskWrapUp = (event) => {\n const task = event;\n this.setWrapupRequired(false);\n this.handleTaskRemove(task.interactionId);\n };\n this.handleTaskMedia = (track) => {\n this.setCallControlAudio(new MediaStream([track]));\n };\n // Case to handle multi session\n this.handleConsultCreated = () => {\n this.setConsultInitiated(true);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsulting = (event) => {\n this.setConsultCompleted(true);\n this.setCurrentTask(event);\n this.handleIncomingTask(event);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsultEnd = (event) => {\n const task = event;\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n else if (this.consultOfferReceived) {\n this.setConsultOfferReceived(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n this.setConsultCompleted(false);\n this.setConsultStartTimeStamp(null);\n };\n this.handleConsultOffer = () => {\n this.setConsultOfferReceived(true);\n };\n this.handleConsultAccepted = (event) => {\n const task = event;\n (0, mobx_1.runInAction)(() => {\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setConsultAccepted(true);\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n });\n };\n this.handleConsultQueueCancelled = () => {\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n this.setConsultStartTimeStamp(null);\n };\n this.handleIncomingTask = (event) => {\n const task = event;\n if (this.store.taskList.some((t) => t.data.interactionId === task.data.interactionId)) {\n // Task already present in the taskList\n return;\n }\n // Attach event listeners to the task\n task.on(store_types_1.TASK_EVENTS.TASK_END, ({ wrapupRequired }) => this.handleTaskEnd(task, wrapupRequired));\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task.data.interactionId, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n this.setIncomingTask(task);\n this.setTaskList([...this.store.taskList, task]);\n };\n this.handleStateChange = (data) => {\n var _a;\n if (data && typeof data === 'object' && data.type === 'AgentStateChangeSuccess') {\n const DEFAULT_CODE = '0'; // Default code when no aux code is present\n this.setCurrentState(((_a = data.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? data.auxCodeId : DEFAULT_CODE);\n this.setLastStateChangeTimestamp(data.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(data.lastIdleCodeChangeTimestamp);\n }\n };\n this.handleMultiLoginCloseSession = (data) => {\n if (data && typeof data === 'object' && data.type === 'AgentMultiLoginCloseSession') {\n this.setShowMultipleLoginAlert(true);\n }\n };\n this.handleTaskHydrate = (event) => {\n const task = event;\n task.on(store_types_1.TASK_EVENTS.TASK_END, ({ wrapupRequired }) => this.handleTaskEnd(task, wrapupRequired));\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task.data.interactionId, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n if (!this.store.taskList.some((t) => t.data.interactionId === task.data.interactionId)) {\n this.setTaskList([...this.store.taskList, task]);\n }\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n if (task.data.interaction.state === 'consulting') {\n if (task.data.isConsulted) {\n this.setConsultAccepted(true);\n }\n else {\n this.setConsultInitiated(true);\n }\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n }\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n const { interaction, agentId } = task.data;\n const { state, isTerminated, participants } = interaction;\n // Update call control states\n if (isTerminated) {\n // wrapup\n const wrapupRequired = state === 'wrapUp' && !participants[agentId].isWrappedUp;\n this.setWrapupRequired(wrapupRequired);\n if (!wrapupRequired) {\n this.setState({\n reset: true,\n });\n }\n return;\n }\n };\n this.handleTaskReject = (taskId, reason) => {\n if (this.onTaskRejected) {\n this.onTaskRejected(reason || 'No reason provided');\n }\n this.handleTaskRemove(taskId);\n };\n this.getBuddyAgents = () => __awaiter(this, void 0, void 0, function* () {\n try {\n const response = yield this.store.cc.getBuddyAgents({\n mediaType: 'telephony',\n state: 'Available',\n });\n return response.data.agentList;\n }\n catch (error) {\n return Promise.reject(error);\n }\n });\n this.getQueues = () => __awaiter(this, void 0, void 0, function* () {\n try {\n let queueList = yield this.store.cc.getQueues();\n queueList = queueList.filter((queue) => queue.channelType === 'TELEPHONY');\n return queueList;\n }\n catch (error) {\n console.error('Error fetching queues:', error);\n return Promise.reject(error);\n }\n });\n this.cleanUpStore = () => {\n (0, mobx_1.runInAction)(() => {\n this.setIsAgentLoggedIn(false);\n this.setDeviceType('AGENT_DN');\n this.setDialNumber('');\n this.setIncomingTask(null);\n this.setCurrentTask(null);\n this.setTaskList([]);\n this.setWrapupRequired(false);\n this.setLastStateChangeTimestamp(undefined);\n this.setLastIdleCodeChangeTimestamp(undefined);\n this.setShowMultipleLoginAlert(false);\n this.setConsultStartTimeStamp(undefined);\n });\n };\n this.setupIncomingTaskHandler = (ccSDK) => {\n let listenersAdded = false;\n const handleLogOut = () => {\n this.cleanUpStore();\n removeEventListeners();\n listenersAdded = false;\n };\n const addEventListeners = () => {\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n const removeEventListeners = () => {\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n const handleLogin = (payload) => {\n (0, mobx_1.runInAction)(() => {\n var _a;\n this.setIsAgentLoggedIn(true);\n this.setDeviceType(payload.deviceType);\n this.setDialNumber(payload.dn);\n this.setCurrentState(((_a = payload.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? payload.auxCodeId : '0');\n this.setLastStateChangeTimestamp(payload.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(payload.lastIdleCodeChangeTimestamp);\n });\n };\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATION_LOGIN_SUCCESS, handleLogin);\n [store_types_1.CC_EVENTS.AGENT_DN_REGISTERED, store_types_1.CC_EVENTS.AGENT_RELOGIN_SUCCESS].forEach((event) => {\n ccSDK.on(`${event}`, () => {\n if (!listenersAdded) {\n addEventListeners();\n listenersAdded = true;\n }\n });\n });\n };\n this.store = store_1.default.getInstance();\n }\n // Proxy all methods and properties of the original store\n get teams() {\n return this.store.teams;\n }\n get loginOptions() {\n return this.store.loginOptions;\n }\n get cc() {\n return this.store.cc;\n }\n get logger() {\n return this.store.logger;\n }\n get idleCodes() {\n return this.store.idleCodes.filter((code) => {\n return code.name === 'RONA' || !code.isSystem;\n });\n }\n get agentId() {\n return this.store.agentId;\n }\n get deviceType() {\n return this.store.deviceType;\n }\n get dialNumber() {\n return this.store.dialNumber;\n }\n get wrapupCodes() {\n return this.store.wrapupCodes;\n }\n get currentTask() {\n return this.store.currentTask;\n }\n get isAgentLoggedIn() {\n return this.store.isAgentLoggedIn;\n }\n get taskList() {\n return this.store.taskList;\n }\n get incomingTask() {\n return this.store.incomingTask;\n }\n get wrapupRequired() {\n return this.store.wrapupRequired;\n }\n get currentState() {\n return this.store.currentState;\n }\n get lastStateChangeTimestamp() {\n return this.store.lastStateChangeTimestamp;\n }\n get lastIdleCodeChangeTimestamp() {\n return this.store.lastIdleCodeChangeTimestamp;\n }\n get showMultipleLoginAlert() {\n return this.store.showMultipleLoginAlert;\n }\n get currentTheme() {\n return this.store.currentTheme;\n }\n get customState() {\n return this.store.customState;\n }\n get consultCompleted() {\n return this.store.consultCompleted;\n }\n get consultInitiated() {\n return this.store.consultInitiated;\n }\n get consultAccepted() {\n return this.store.consultAccepted;\n }\n get consultStartTimeStamp() {\n return this.store.consultStartTimeStamp;\n }\n get callControlAudio() {\n return this.store.callControlAudio;\n }\n get consultOfferReceived() {\n return this.store.consultOfferReceived;\n }\n get isQueueConsultInProgress() {\n return this.store.isQueueConsultInProgress;\n }\n get currentConsultQueueId() {\n return this.store.currentConsultQueueId;\n }\n get isEndConsultEnabled() {\n return this.store.isEndConsultEnabled;\n }\n get allowConsultToQueue() {\n return this.store.allowConsultToQueue;\n }\n init(options) {\n return this.store.init(options, this.setupIncomingTaskHandler);\n }\n}\n// Create and export a single instance of the wrapper\nconst storeWrapper = new StoreWrapper();\nexports[\"default\"] = storeWrapper;\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/storeEventsWrapper.ts?");
12371
+ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst store_types_1 = __webpack_require__(/*! ./store.types */ \"./src/store.types.ts\");\nconst store_1 = __importDefault(__webpack_require__(/*! ./store */ \"./src/store.ts\"));\nconst mobx_1 = __webpack_require__(/*! mobx */ \"../../../node_modules/mobx/dist/mobx.esm.js\");\nclass StoreWrapper {\n constructor() {\n this.setCurrentTheme = (theme) => {\n this.store.currentTheme = theme;\n };\n this.setShowMultipleLoginAlert = (value) => {\n this.store.showMultipleLoginAlert = value;\n };\n this.setDeviceType = (option) => {\n this.store.deviceType = option;\n };\n this.setDialNumber = (input) => {\n this.store.dialNumber = input;\n };\n this.setCurrentState = (state) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentState = state;\n this.store.customState = null;\n });\n };\n this.setLastStateChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastStateChangeTimestamp = timestamp;\n });\n };\n this.setLastIdleCodeChangeTimestamp = (timestamp) => {\n (0, mobx_1.runInAction)(() => {\n this.store.lastIdleCodeChangeTimestamp = timestamp;\n });\n };\n this.setIsAgentLoggedIn = (value) => {\n this.store.isAgentLoggedIn = value;\n };\n this.setWrapupRequired = (value) => {\n this.store.wrapupRequired = value;\n };\n this.setCurrentTask = (task) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentTask = task;\n });\n };\n this.setIncomingTask = (task) => {\n this.store.incomingTask = task;\n };\n this.setTaskList = (taskList) => {\n this.store.taskList = taskList;\n };\n this.setWrapupCodes = (wrapupCodes) => {\n this.store.wrapupCodes = wrapupCodes;\n };\n this.setConsultCompleted = (value) => {\n this.store.consultCompleted = value;\n };\n this.setConsultInitiated = (value) => {\n this.store.consultInitiated = value;\n };\n this.setConsultAccepted = (value) => {\n this.store.consultAccepted = value;\n };\n this.setConsultOfferReceived = (value) => {\n this.store.consultOfferReceived = value;\n };\n this.setConsultStartTimeStamp = (timestamp) => {\n this.store.consultStartTimeStamp = timestamp;\n };\n this.setCallControlAudio = (audio) => {\n this.store.callControlAudio = audio;\n };\n this.setIsQueueConsultInProgress = (value) => {\n (0, mobx_1.runInAction)(() => {\n this.store.isQueueConsultInProgress = value;\n });\n };\n this.setCurrentConsultQueueId = (queueId) => {\n (0, mobx_1.runInAction)(() => {\n this.store.currentConsultQueueId = queueId;\n });\n };\n this.setState = (state) => {\n if ('reset' in state) {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = null;\n });\n return;\n }\n if ('id' in state) {\n (0, mobx_1.runInAction)(() => {\n this.setCurrentState(state.id);\n this.store.customState = null;\n });\n }\n else {\n (0, mobx_1.runInAction)(() => {\n this.store.customState = state;\n });\n }\n };\n this.setTaskRejected = (callback) => {\n this.onTaskRejected = callback;\n };\n this.setCCCallback = (event, callback) => {\n if (!callback)\n return;\n this.store.cc.on(event, callback);\n };\n this.setTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (!task)\n return;\n task.on(event, callback);\n };\n this.removeCCCallback = (event) => {\n this.store.cc.off(event);\n };\n this.removeTaskCallback = (event, callback, taskId) => {\n if (!callback)\n return;\n const task = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (!task)\n return;\n task.off(event, callback);\n };\n this.registerCC = (webex) => {\n return this.store.registerCC(webex);\n };\n this.handleTaskRemove = (event) => {\n const taskId = event;\n // Remove the task from the taskList\n const taskToRemove = this.store.taskList.find((task) => task.data.interactionId === taskId);\n if (taskToRemove) {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_END, this.handleTaskEnd);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(taskToRemove.interactionId, reason));\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n taskToRemove.off(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n taskToRemove.off(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n taskToRemove.off(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n this.setCallControlAudio(null);\n }\n }\n const updateTaskList = this.store.taskList.filter((task) => task.data.interactionId !== taskId);\n (0, mobx_1.runInAction)(() => {\n var _a, _b;\n this.setTaskList(updateTaskList);\n this.setWrapupRequired(false);\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n // Remove the task from currentTask or incomingTask if it is the same task\n if (((_a = this.store.currentTask) === null || _a === void 0 ? void 0 : _a.data.interactionId) === taskId) {\n this.setCurrentTask(null);\n }\n if (((_b = this.store.incomingTask) === null || _b === void 0 ? void 0 : _b.data.interactionId) === taskId) {\n this.setIncomingTask(null);\n }\n // reset the custom state\n this.setState({\n reset: true,\n });\n });\n };\n this.handleTaskEnd = (event) => {\n // If the call is ended by agent we get the task object in event.data\n // If the call is ended by customer we get the task object directly\n const task = event.data ? event.data : event;\n if (task.wrapUpRequired) {\n this.setWrapupRequired(true);\n }\n else {\n this.handleTaskRemove(task.interactionId);\n }\n };\n this.handleTaskAssigned = (event) => {\n const task = event;\n (0, mobx_1.runInAction)(() => {\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.setConsultInitiated(false);\n this.setConsultCompleted(false);\n this.setConsultOfferReceived(false);\n }\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n });\n };\n this.handleTaskWrapUp = (event) => {\n const task = event;\n this.setWrapupRequired(false);\n this.handleTaskRemove(task.interactionId);\n };\n this.handleTaskMedia = (track) => {\n this.setCallControlAudio(new MediaStream([track]));\n };\n // Case to handle multi session\n this.handleConsultCreated = () => {\n this.setConsultInitiated(true);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsulting = (event) => {\n this.setConsultCompleted(true);\n this.setCurrentTask(event);\n this.handleIncomingTask(event);\n this.setConsultStartTimeStamp(Date.now());\n };\n this.handleConsultEnd = (event) => {\n const task = event;\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n if (this.consultAccepted) {\n this.setConsultAccepted(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n else if (this.consultOfferReceived) {\n this.setConsultOfferReceived(false);\n this.handleTaskRemove(task.data.interactionId);\n }\n this.setConsultCompleted(false);\n this.setConsultStartTimeStamp(null);\n };\n this.handleConsultOffer = () => {\n this.setConsultOfferReceived(true);\n };\n this.handleConsultAccepted = (event) => {\n const task = event;\n (0, mobx_1.runInAction)(() => {\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n this.setConsultAccepted(true);\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n });\n };\n this.handleConsultQueueCancelled = () => {\n this.setConsultInitiated(false);\n this.setIsQueueConsultInProgress(false);\n this.setCurrentConsultQueueId(null);\n this.setConsultStartTimeStamp(null);\n };\n this.handleIncomingTask = (event) => {\n const task = event;\n if (this.store.taskList.some((t) => t.data.interactionId === task.data.interactionId)) {\n // Task already present in the taskList\n return;\n }\n // Attach event listeners to the task\n task.on(store_types_1.TASK_EVENTS.TASK_END, () => this.handleTaskEnd(task));\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task.data.interactionId, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n this.setIncomingTask(task);\n this.setTaskList([...this.store.taskList, task]);\n };\n this.handleStateChange = (data) => {\n var _a;\n if (data && typeof data === 'object' && data.type === 'AgentStateChangeSuccess') {\n const DEFAULT_CODE = '0'; // Default code when no aux code is present\n this.setCurrentState(((_a = data.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? data.auxCodeId : DEFAULT_CODE);\n this.setLastStateChangeTimestamp(data.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(data.lastIdleCodeChangeTimestamp);\n }\n };\n this.handleMultiLoginCloseSession = (data) => {\n if (data && typeof data === 'object' && data.type === 'AgentMultiLoginCloseSession') {\n this.setShowMultipleLoginAlert(true);\n }\n };\n this.handleTaskHydrate = (event) => {\n const task = event;\n task.on(store_types_1.TASK_EVENTS.TASK_END, () => this.handleTaskEnd(task));\n // When we receive TASK_ASSIGNED the task was accepted by the agent and we need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_ASSIGNED, this.handleTaskAssigned);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_ACCEPTED, this.handleConsultAccepted);\n task.on(store_types_1.TASK_EVENTS.AGENT_CONSULT_CREATED, this.handleConsultCreated);\n // When we receive TASK_REJECT sdk changes the agent status\n // When we receive TASK_REJECT that means the task was not accepted by the agent and we wont need wrap up\n task.on(store_types_1.TASK_EVENTS.TASK_REJECT, (reason) => this.handleTaskReject(task.data.interactionId, reason));\n task.on(store_types_1.TASK_EVENTS.AGENT_WRAPPEDUP, this.handleTaskWrapUp);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULTING, this.handleConsulting);\n task.on(store_types_1.CC_EVENTS.AGENT_OFFER_CONSULT, this.handleConsultOffer);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_END, this.handleConsultEnd);\n task.on(store_types_1.TASK_EVENTS.TASK_CONSULT_QUEUE_CANCELLED, this.handleConsultQueueCancelled);\n if (this.deviceType === 'BROWSER') {\n task.on(store_types_1.TASK_EVENTS.TASK_MEDIA, this.handleTaskMedia);\n }\n if (!this.store.taskList.some((t) => t.data.interactionId === task.data.interactionId)) {\n this.setTaskList([...this.store.taskList, task]);\n }\n this.setCurrentTask(task);\n this.setIncomingTask(null);\n if (task.data.interaction.state === 'consulting') {\n if (task.data.isConsulted) {\n this.setConsultAccepted(true);\n }\n else {\n this.setConsultInitiated(true);\n }\n this.setConsultStartTimeStamp(Date.now());\n this.setConsultCompleted(true);\n }\n this.setState({\n developerName: store_types_1.ENGAGED_LABEL,\n name: store_types_1.ENGAGED_USERNAME,\n });\n const { interaction } = task.data;\n const { isTerminated } = interaction;\n // Update call control states\n if (isTerminated) {\n // wrapup\n this.setWrapupRequired(task.data.wrapUpRequired);\n if (!task.data.wrapUpRequired) {\n this.setState({\n reset: true,\n });\n }\n return;\n }\n };\n this.handleTaskReject = (taskId, reason) => {\n if (this.onTaskRejected) {\n this.onTaskRejected(reason || 'No reason provided');\n }\n this.handleTaskRemove(taskId);\n };\n this.getBuddyAgents = () => __awaiter(this, void 0, void 0, function* () {\n try {\n const response = yield this.store.cc.getBuddyAgents({\n mediaType: 'telephony',\n state: 'Available',\n });\n return response.data.agentList;\n }\n catch (error) {\n return Promise.reject(error);\n }\n });\n this.getQueues = () => __awaiter(this, void 0, void 0, function* () {\n try {\n let queueList = yield this.store.cc.getQueues();\n queueList = queueList.filter((queue) => queue.channelType === 'TELEPHONY');\n return queueList;\n }\n catch (error) {\n console.error('Error fetching queues:', error);\n return Promise.reject(error);\n }\n });\n this.cleanUpStore = () => {\n (0, mobx_1.runInAction)(() => {\n this.setIsAgentLoggedIn(false);\n this.setDeviceType('AGENT_DN');\n this.setDialNumber('');\n this.setIncomingTask(null);\n this.setCurrentTask(null);\n this.setTaskList([]);\n this.setWrapupRequired(false);\n this.setLastStateChangeTimestamp(undefined);\n this.setLastIdleCodeChangeTimestamp(undefined);\n this.setShowMultipleLoginAlert(false);\n this.setConsultStartTimeStamp(undefined);\n });\n };\n this.setupIncomingTaskHandler = (ccSDK) => {\n let listenersAdded = false;\n const handleLogOut = () => {\n this.cleanUpStore();\n removeEventListeners();\n listenersAdded = false;\n };\n const addEventListeners = () => {\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.on(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n const removeEventListeners = () => {\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_STATE_CHANGE, this.handleStateChange);\n ccSDK.off(store_types_1.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_MULTI_LOGIN, this.handleMultiLoginCloseSession);\n ccSDK.off(store_types_1.CC_EVENTS.AGENT_LOGOUT_SUCCESS, handleLogOut);\n };\n // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there\n const handleLogin = (payload) => {\n (0, mobx_1.runInAction)(() => {\n var _a;\n this.setIsAgentLoggedIn(true);\n this.setDeviceType(payload.deviceType);\n this.setDialNumber(payload.dn);\n this.setCurrentState(((_a = payload.auxCodeId) === null || _a === void 0 ? void 0 : _a.trim()) !== '' ? payload.auxCodeId : '0');\n this.setLastStateChangeTimestamp(payload.lastStateChangeTimestamp);\n this.setLastIdleCodeChangeTimestamp(payload.lastIdleCodeChangeTimestamp);\n });\n };\n ccSDK.on(store_types_1.CC_EVENTS.AGENT_STATION_LOGIN_SUCCESS, handleLogin);\n [store_types_1.CC_EVENTS.AGENT_DN_REGISTERED, store_types_1.CC_EVENTS.AGENT_RELOGIN_SUCCESS].forEach((event) => {\n ccSDK.on(`${event}`, () => {\n if (!listenersAdded) {\n addEventListeners();\n listenersAdded = true;\n }\n });\n });\n };\n this.store = store_1.default.getInstance();\n }\n // Proxy all methods and properties of the original store\n get teams() {\n return this.store.teams;\n }\n get loginOptions() {\n return this.store.loginOptions;\n }\n get cc() {\n return this.store.cc;\n }\n get logger() {\n return this.store.logger;\n }\n get idleCodes() {\n return this.store.idleCodes.filter((code) => {\n return code.name === 'RONA' || !code.isSystem;\n });\n }\n get agentId() {\n return this.store.agentId;\n }\n get deviceType() {\n return this.store.deviceType;\n }\n get dialNumber() {\n return this.store.dialNumber;\n }\n get wrapupCodes() {\n return this.store.wrapupCodes;\n }\n get currentTask() {\n return this.store.currentTask;\n }\n get isAgentLoggedIn() {\n return this.store.isAgentLoggedIn;\n }\n get taskList() {\n return this.store.taskList;\n }\n get incomingTask() {\n return this.store.incomingTask;\n }\n get wrapupRequired() {\n return this.store.wrapupRequired;\n }\n get currentState() {\n return this.store.currentState;\n }\n get lastStateChangeTimestamp() {\n return this.store.lastStateChangeTimestamp;\n }\n get lastIdleCodeChangeTimestamp() {\n return this.store.lastIdleCodeChangeTimestamp;\n }\n get showMultipleLoginAlert() {\n return this.store.showMultipleLoginAlert;\n }\n get currentTheme() {\n return this.store.currentTheme;\n }\n get customState() {\n return this.store.customState;\n }\n get consultCompleted() {\n return this.store.consultCompleted;\n }\n get consultInitiated() {\n return this.store.consultInitiated;\n }\n get consultAccepted() {\n return this.store.consultAccepted;\n }\n get consultStartTimeStamp() {\n return this.store.consultStartTimeStamp;\n }\n get callControlAudio() {\n return this.store.callControlAudio;\n }\n get consultOfferReceived() {\n return this.store.consultOfferReceived;\n }\n get isQueueConsultInProgress() {\n return this.store.isQueueConsultInProgress;\n }\n get currentConsultQueueId() {\n return this.store.currentConsultQueueId;\n }\n get isEndConsultEnabled() {\n return this.store.isEndConsultEnabled;\n }\n get allowConsultToQueue() {\n return this.store.allowConsultToQueue;\n }\n init(options) {\n return this.store.init(options, this.setupIncomingTaskHandler);\n }\n}\n// Create and export a single instance of the wrapper\nconst storeWrapper = new StoreWrapper();\nexports[\"default\"] = storeWrapper;\n\n\n//# sourceURL=webpack://@webex/cc-store/./src/storeEventsWrapper.ts?");
12372
12372
 
12373
12373
  /***/ }),
12374
12374
 
@@ -12401,7 +12401,7 @@ eval("/* provided dependency */ var process = __webpack_require__(/*! process/br
12401
12401
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
12402
12402
 
12403
12403
  "use strict";
12404
- eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _merge = _interopRequireDefault(__webpack_require__(/*! lodash/merge */ \"../../../node_modules/lodash/merge.js\"));\nvar _webexCore = _interopRequireDefault(__webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\"));\n__webpack_require__(/*! @webex/plugin-authorization */ \"./node_modules/@webex/plugin-authorization/dist/index.browser.js\");\n__webpack_require__(/*! @webex/plugin-cc */ \"../../../node_modules/@webex/plugin-cc/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-mercury */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/index.js\");\n__webpack_require__(/*! @webex/plugin-logger */ \"./node_modules/@webex/plugin-logger/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-support */ \"./node_modules/@webex/internal-plugin-support/dist/index.js\");\nvar config = __webpack_require__(/*! ./config */ \"./node_modules/webex/dist/config.js\");\nvar Webex = _webexCore.default.extend({\n webex: true,\n version: \"3.8.0-next.51\"\n});\nWebex.init = function init() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n attrs.config = (0, _merge.default)({}, config, attrs.config); // eslint-disable-line no-param-reassign\n\n return new Webex(attrs);\n};\nvar _default = exports[\"default\"] = Webex;\n//# sourceMappingURL=contact-center.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/webex/dist/contact-center.js?");
12404
+ eval("\n\nvar _Object$defineProperty = __webpack_require__(/*! @babel/runtime-corejs2/core-js/object/define-property */ \"../../../node_modules/@babel/runtime-corejs2/core-js/object/define-property.js\");\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime-corejs2/helpers/interopRequireDefault */ \"../../../node_modules/@babel/runtime-corejs2/helpers/interopRequireDefault.js\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports[\"default\"] = void 0;\nvar _merge = _interopRequireDefault(__webpack_require__(/*! lodash/merge */ \"../../../node_modules/lodash/merge.js\"));\nvar _webexCore = _interopRequireDefault(__webpack_require__(/*! @webex/webex-core */ \"../../../node_modules/@webex/webex-core/dist/index.js\"));\n__webpack_require__(/*! @webex/plugin-authorization */ \"./node_modules/@webex/plugin-authorization/dist/index.browser.js\");\n__webpack_require__(/*! @webex/plugin-cc */ \"../../../node_modules/@webex/plugin-cc/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-mercury */ \"../../../node_modules/@webex/internal-plugin-mercury/dist/index.js\");\n__webpack_require__(/*! @webex/plugin-logger */ \"./node_modules/@webex/plugin-logger/dist/index.js\");\n__webpack_require__(/*! @webex/internal-plugin-support */ \"./node_modules/@webex/internal-plugin-support/dist/index.js\");\nvar config = __webpack_require__(/*! ./config */ \"./node_modules/webex/dist/config.js\");\nvar Webex = _webexCore.default.extend({\n webex: true,\n version: \"3.8.0-next.56\"\n});\nWebex.init = function init() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n attrs.config = (0, _merge.default)({}, config, attrs.config); // eslint-disable-line no-param-reassign\n\n return new Webex(attrs);\n};\nvar _default = exports[\"default\"] = Webex;\n//# sourceMappingURL=contact-center.js.map\n\n\n//# sourceURL=webpack://@webex/cc-store/./node_modules/webex/dist/contact-center.js?");
12405
12405
 
12406
12406
  /***/ }),
12407
12407
 
@@ -63,7 +63,7 @@ declare class StoreWrapper implements IStoreWrapper {
63
63
  init(options: InitParams): Promise<void>;
64
64
  registerCC: (webex?: WithWebex["webex"]) => Promise<void>;
65
65
  handleTaskRemove: (event: any) => void;
66
- handleTaskEnd: (event: any, wrapupRequired: any) => void;
66
+ handleTaskEnd: (event: any) => void;
67
67
  handleTaskAssigned: (event: any) => void;
68
68
  handleTaskWrapUp: (event: any) => void;
69
69
  handleTaskMedia: (track: any) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webex/cc-store",
3
3
  "description": "Webex Contact Center Widgets: Widgets Store",
4
- "version": "1.28.0-ccwidgets.49",
4
+ "version": "1.28.0-ccwidgets.50",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "mobx": "6.13.5",
25
25
  "typescript": "5.6.3",
26
- "webex": "3.8.0-next.51"
26
+ "webex": "3.8.0-next.56"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/core": "7.25.2",