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,WACZ,OAAOoS,CACX,EAKA7T,KAAK6N,QAAU,SAAUmG,GACrBH,EAAM9N,KAAKiO,EACf,EAKAhU,KAAK8N,QAAU,WAEX,GAAoB,GAAhB+F,EAAM5P,OAAa,OAGvB,MAAM+P,EAAOH,EAAMC,GASnB,OANe,IAATA,GAAcD,EAAM5P,SACtB4P,EAAQA,EAAMxH,MAAMyH,GACpBA,EAAS,GAINE,CACX,EAKAhU,KAAKiU,KAAO,WACR,OAAOJ,EAAM5P,OAAS,EAAI4P,EAAMC,QAAUhK,CAC9C,CACJ,C","sources":["webpack://apexchatwidgets/./widgets/core/hooks/UserIds.js","webpack://apexchatwidgets/./widgets/core/hooks/canBrowserDoLive.js","webpack://apexchatwidgets/./widgets/core/LiveChatRoom.js","webpack://apexchatwidgets/./widgets/core/hooks/Queue.js"],"sourcesContent":["const UserIds = {\r\n simulated: 2147483647\r\n};\r\nexport default UserIds;\r\n","const canBrowserDoLive = function () {\r\n const me = this;\r\n const hasActiveX = function () {\r\n let hasActiveX = 'ActiveX' in window;\r\n if (hasActiveX &&\r\n typeof window.external.msActiveXFilteringEnabled !== 'undefined' &&\r\n window.external.msActiveXFilteringEnabled()) {\r\n hasActiveX = false;\r\n }\r\n return hasActiveX;\r\n };\r\n return (\r\n !!(\r\n navigator.getUserMedia ||\r\n navigator.webkitGetUserMedia ||\r\n navigator.mozGetUserMedia ||\r\n navigator.msGetUserMedia\r\n ) || hasActiveX()\r\n );\r\n};\r\nexport default canBrowserDoLive;\r\n","/* \r\n* A Chatroom should not: \r\n. render a chat widget's look n feel \r\n. define how & when chat widget UI should behave in a certain manner\r\n. be responsible to render & handle any other widget type like Visitor Form and Video Chat\r\n \r\n* A Chatroom should:\r\n. handle visitor response\r\n. handle chat streaming events\r\n. maintain list of chat log/history\r\n \r\n*/\r\nimport BaseClass from './BaseClass';\r\nimport WidgetTypes from './enums/WidgetTypes';\r\nimport TempCache from './enums/TempCache';\r\nimport ParticipantIds from './enums/ParticipantIds';\r\nimport GlobalVariables from './GlobalVariables';\r\nimport UserIds from './hooks/UserIds';\r\nimport ChatMode from './hooks/ChatMode';\r\nimport PipedMessageHandler from './hooks/PipedMessageHandler';\r\nimport Queue from './hooks/Queue';\r\nimport { ScriptsQuestionType, SystemMessageType } from './enums/Enum';\r\nimport sendChatAndLeadAnalytics from './hooks/sendChatAndLeadAnalytics';\r\nimport canBrowserDoLive from './hooks/canBrowserDoLive';\r\nimport RunAsSoonAs from './hooks/RunAsSoonAs';\r\nimport ChatStates from './hooks/ChatStates';\r\nimport Cookies from './hooks/Cookies';\r\nimport ChatEvents from './hooks/ChatEvents';\r\nimport WidgetStates from './hooks/WidgetStates';\r\nimport getCookieValue from './hooks/getCookieValue';\r\nimport getStorageAPIValue from './hooks/getStorageAPIValue';\r\nimport fromQueryString from './hooks/fromQueryString';\r\nimport storageAPIExists from './hooks/storageAPIExists';\r\nimport logIt from '../../logIt';\r\n\r\nexport default class LiveChatRoom extends BaseClass {\r\n constructor(options) {\r\n\r\n const objectType = WidgetTypes.ChatRoom;\r\n const thisOptions = Object.assign(options, {\r\n widget: objectType,\r\n $: options.$\r\n });\r\n super(thisOptions);\r\n this.widget = objectType;\r\n const me = this;\r\n me.isNewChat = typeof ApexChatStartData !== 'undefined';\r\n me.chatId = options.chatId;\r\n me.suppressHistory = options.isFromInvitation;\r\n // messageSequence keeps track of the sequence # of message from visitor - this is a Lumin request\r\n this.messageSequence = 0;\r\n this.subscribe(ChatStates.MessageArrived, (m) => {\r\n logIt(`after::LiveChatRoom::${ChatStates.MessageArrived}:${m.text}`);\r\n if (!m.isFromHistory) {\r\n // this guy only deals in History fetching scenarios\r\n return;\r\n }\r\n logIt(\r\n `after::LiveChatRoom::${ChatStates.MessageArrived}: loading history items:${m.text}`\r\n );\r\n\r\n if (me.Queue && me.Queue.getLength() > 0) {\r\n // logIt('after::reload::' + ChatStates.MessageArrived + ' m done:' + m.text + '\\n' + JSON.stringify(m));\r\n // before rendering Last message need to publish that chat is rendered and take decision on disabling TextArea for Disabling.\r\n if (me.Queue.getLength() === 1) {\r\n me.postMessage({ event: ChatEvents.OnHistoryLoadedCompletely });\r\n }\r\n const msg = me.dequeueMessage();\r\n logIt(\r\n `${me.Queue.getLength()} remaining::after::reload:: dequeueing msgs:${msg.text}`\r\n );\r\n logIt(`after::${JSON.stringify(me.Queue.getItems())}`);\r\n me.onMessageArrived(msg, true, msg.index);\r\n }\r\n });\r\n }\r\n\r\n end() { }\r\n\r\n setWebSyncClient() {\r\n if (!ApexChat.webSyncClient) {\r\n ApexChat.webSyncClient = new fm.websync.client(`${GlobalVariables.LiveChatServiceUrl}request.ashx`);\r\n fm.util.ready();\r\n ApexChat.webSyncClient.connect({\r\n requestUrl: `${GlobalVariables.LiveChatServiceUrl}request.ashx`,\r\n stream: {\r\n requestUrl: `${GlobalVariables.LiveChatServiceUrl || GlobalVariables.LiveChatServiceUrl}request.ashx`\r\n },\r\n // never auto-disconnect; this gives the visitor a moment to refresh the browser, lose a network connection, etc\r\n autoDisconnect: false,\r\n // ignore if we're already initialized\r\n quiet: true,\r\n stayConnected: true,\r\n onSuccess(args) { },\r\n onFailure(args) {\r\n args.reconnect = true;\r\n },\r\n onStreamFailure(args) {\r\n // stream is dead...we're going to retry, so for now we'll just leave this\r\n }\r\n });\r\n }\r\n\r\n this.webSyncClient = ApexChat.webSyncClient;\r\n }\r\n\r\n getMeta(chatId, companyId, token) {\r\n return {\r\n chatId,\r\n companyId,\r\n token\r\n };\r\n }\r\n\r\n /**\r\n * Its subscribing to Chat channel, so, this minimal connection, especially, in case of Refresh when no DOM & no websync.\r\n * @param {id} id is basically ChatID\r\n */\r\n subscribeToChatChannel(id) {\r\n const me = this;\r\n me.options.chatId = id;\r\n const onSuccess = (args) => {\r\n let meta = args.getMeta();\r\n const isPreChatMaximized =\r\n me.state.getStateValue(WidgetTypes.PreChat) === WidgetStates.ShownMaximized;\r\n me.options.participantId = meta.participantId;\r\n // Only need to send Last Message of History not all.\r\n if (isPreChatMaximized && meta.history) {\r\n // check prechat is not maximize\r\n const indexOfLastMessage = meta.history.length - 1;\r\n meta.history[indexOfLastMessage] &&\r\n me.onMessageArrived(meta.history[indexOfLastMessage], true, indexOfLastMessage);\r\n }\r\n };\r\n const channels = [\r\n `/chatroom/${id}`,\r\n `/chatroom/${id}/typing`,\r\n `/chatroom/${id}/participants`,\r\n `/chat/${id}/transferRequested`,\r\n `/chatroom/${id}/messagereceipt/`\r\n ];\r\n try {\r\n if (fm) {\r\n me.setWebSyncClient();\r\n }\r\n const meta = me.getMeta(id, me.options.companyId, me.options.token);\r\n me.webSyncClient.subscribe({\r\n retries: 3,\r\n meta,\r\n channels,\r\n onSuccess,\r\n onReceive(args) {\r\n const data = args.getData();\r\n /* return if message coming from predefined */\r\n if (data.userId === 0 || data.participantId === ParticipantIds.predefined) {\r\n return;\r\n }\r\n me.onMessageArrived(data);\r\n },\r\n onFailure(args) {\r\n me.onChatJoinFailure(args);\r\n }\r\n });\r\n } catch (error) {\r\n console.log(\"fm not defined::\", error);\r\n }\r\n }\r\n\r\n processHistoryItems(meta, isChatActive, cb) {\r\n const me = this;\r\n ApexChat.allHistoryMessages = ApexChat.allHistoryMessages || []; // store all messages\r\n for (var i = 0; i < meta.history.length; i++) {\r\n let match = false; // check for history messages already appeared.\r\n // CHAT-7391 this scenario is for when we moved our application to background and return to application\r\n // check if message already appeared on dom we should not run it again to avoid duplication\r\n match = ApexChat.allHistoryMessages.some(\r\n (msg) => meta.history[i].id === msg.id // if msg id from meta history matches with our allhistorymessages id it should not append to DOM.\r\n );\r\n if (!match) {\r\n // If chat is being loaded from history, we need to set message sequece separately for chat handlers as well as visitors\r\n const setMessageSequenceFromHistory = function (log, currentSequence) {\r\n // System message\r\n if (!log.messageSequence) {\r\n return currentSequence;\r\n }\r\n // is agent or operator?\r\n const isAgentOrOperator =\r\n ApexChat.Settings && ApexChat.Settings.CurrentUserId > 0;\r\n // we maintain 2 separate sequences, on for agent and one for visitor\r\n // bail out if not relevant\r\n if (\r\n isAgentOrOperator &&\r\n (log.userId <= 0 || log.userId !== ApexChat.Settings.CurrentUserId)\r\n ) {\r\n return currentSequence;\r\n }\r\n if (\r\n (!isAgentOrOperator &&\r\n log.messageSequence &&\r\n log.userId == 0 &&\r\n log.participantId > 0) ||\r\n isAgentOrOperator\r\n ) {\r\n // extract last 2 characters as they reperesent message sequence\r\n const messageSequence = Number(log.messageSequence.substring(8, 10));\r\n // we need the current sequence regardless of the order of messages from the server\r\n if (currentSequence < messageSequence) {\r\n currentSequence = messageSequence;\r\n }\r\n }\r\n return currentSequence;\r\n };\r\n // we dont need to run history messages again if its already appeared on DOM.\r\n // when loading history, we filter out only those messages which the visitor sends\r\n me.messageSequence = setMessageSequenceFromHistory(\r\n meta.history[i],\r\n me.messageSequence\r\n );\r\n // Bug_7343 - Visitor's responses against FullText not appearing\r\n // no matter what questionType message is belongs to the function itself will handle, won't work for QTs except FullText\r\n meta.history[i].options = me.handleFullTextVisitorResponse(meta.history[i]);\r\n meta.history[i].options = me.handleVisitorResponsesRenderAsText(meta.history[i]);\r\n meta.history[i].index = i;\r\n logIt('Adding history messages');\r\n // logIt(JSON.stringify(meta.history[i]));\r\n me.queueMessage(meta.history[i]); // just cache history items, we will handle them manually below\r\n ApexChat.allHistoryMessages.push(meta.history[i]);\r\n }\r\n }\r\n // we process 1st history item in refresh scenario ourself\r\n if (me.Queue && me.Queue.getLength() > 0 && !me.isChatEnded) {\r\n logIt('Queue messages');\r\n logIt(JSON.stringify(me.Queue.getItems()));\r\n const msg = me.dequeueMessage();\r\n me.onMessageArrived(msg, isChatActive, msg.index);\r\n }\r\n if (cb && typeof cb === 'function') {\r\n cb();\r\n }\r\n }\r\n\r\n setChatId(id, token) {\r\n const me = this;\r\n me.options.chatId = id;\r\n me.options.token = token;\r\n let onSuccess = function (args) {\r\n let meta = args.getMeta();\r\n me.options.participantId = meta.participantId;\r\n if (me.isPageRefreshed()) {\r\n me.postMessage({ event: ChatEvents.OnHistoryStartLoading });\r\n }\r\n me.isConnectionEstablished = true;\r\n // If chat is new our initial message's inital load should be false, if chatmode is windowed we need to get chat status from querystring.\r\n const isChatActive =\r\n me.isChatActive() ||\r\n (me.options.chatMode === ChatMode.Windowed &&\r\n ApexChat.TryParse(fromQueryString('isChatActive')));\r\n me.processHistoryItems(meta, isChatActive, () => {\r\n me.onChatJoined(args);\r\n ApexChat.storageAPI.Store(TempCache.CHAT_ID_COOKIE, id);\r\n });\r\n };\r\n if (me.suppressHistory) {\r\n onSuccess = function (args) {\r\n me.updateBubbleMsgCount(args);\r\n logIt('bypassing displaying history...');\r\n logIt(args);\r\n };\r\n }\r\n const channels = [\r\n `/chatroom/${id}`,\r\n `/chatroom/${id}/typing`,\r\n `/chatroom/${id}/participants`,\r\n `/chat/${id}/transferRequested`,\r\n `/chatroom/${id}/messagereceipt/`\r\n ];\r\n if (fm) {\r\n me.setWebSyncClient();\r\n }\r\n let meta = me.getMeta(id, me.options.companyId, me.options.token);\r\n me.webSyncClient.subscribe({\r\n retries: 3,\r\n meta,\r\n channels,\r\n onSuccess: onSuccess,\r\n onReceive(args) {\r\n const data = args.getData();\r\n switch (args.getChannel()) {\r\n case channels[0]:\r\n // no need to take action if message is coming from visitor\r\n if (data.userId == 0) {\r\n return;\r\n }\r\n // return if message coming from predefined\r\n if (\r\n data.participantId == ParticipantIds.predefined ||\r\n data.isPredefinedPokeMessage\r\n ) {\r\n return;\r\n }\r\n // Simple null check for allHistoryMessages before Pushing.\r\n ApexChat.allHistoryMessages = ApexChat.allHistoryMessages || [];\r\n var lastDOMState = me.state.getStateValue(WidgetTypes.DOM); // get last state of widget\r\n // we need only run this maximize case; not the RD/DOM is minimized\r\n if (!(lastDOMState == WidgetStates.ShownMinimized)) {\r\n ApexChat.allHistoryMessages.push(data);\r\n }\r\n if (\r\n me.state.getStateValue(WidgetTypes.PreChat) ===\r\n WidgetStates.ShownMaximized\r\n ) {\r\n ApexChat.allHistoryMessages.push(data);\r\n }\r\n if (\r\n me.isWindowedStarted() ||\r\n (me.options.chatMode &&\r\n me.options.chatMode == ChatMode.Windowed)\r\n ) {\r\n ApexChat.allHistoryMessages.push(data);\r\n }\r\n if (data.systemMessageType == SystemMessageType.WebToSMSTransferCompleted) {\r\n me.onMessageArrived(data);\r\n me.postMessage({ event: WidgetTypes.ChatRoom + ChatEvents.ChatIdleOut });\r\n me.$('#apexchat .switchto-text-chat', me.options.context).remove();\r\n me.$('#apexchat #menuItemPopout', me.options.context).remove();\r\n }\r\n // handle SMS transfer system messages for RD and non-RD\r\n else if (\r\n data.systemMessageType ==\r\n SystemMessageType.SMSTransferInProgress ||\r\n data.systemMessageType == SystemMessageType.SMSTransferred\r\n ) {\r\n me.OnSMSTransfer(data);\r\n\r\n } else {\r\n me.onMessageArrived(data);\r\n }\r\n break;\r\n case channels[1]:\r\n if (me.options.participantId === data.participantId) {\r\n return;\r\n }\r\n me.onTypingArrived(data);\r\n break;\r\n case channels[2]:\r\n me.onParticipantsChanged(data);\r\n break;\r\n case channels[3]:\r\n // me.OnTransferRequested(data);\r\n break;\r\n case channels[6]: // templated questions\r\n break;\r\n case channels[8]: // realtime-text\r\n break;\r\n default:\r\n }\r\n },\r\n onFailure(args) {\r\n meta = args.getMeta();\r\n if (meta && meta.history) {\r\n logIt('OnFailure-Messages');\r\n // logIt(JSON.stringify(meta.history));\r\n // for (var i = 0; i < meta.history.length; i++) {\r\n // me.onMessageArrived(meta.history[i], true, i);\r\n // }\r\n const isChatActive =\r\n me.isChatActive() ||\r\n (me.options.chatMode === ChatMode.Windowed &&\r\n ApexChat.TryParse(fromQueryString('isChatActive')));\r\n me.processHistoryItems(meta, isChatActive);\r\n }\r\n me.onChatJoinFailure(args);\r\n },\r\n onComplete(args) { }\r\n });\r\n }\r\n\r\n updateBubbleMsgCount(args) {\r\n let counterMessage = 0;\r\n let lastMessageId = 0;\r\n let msgCountUpdated = false;\r\n const me = this;\r\n if (storageAPIExists('livechat_new_msg_count')) {\r\n counterMessage = parseInt(getStorageAPIValue('livechat_new_msg_count'));\r\n }\r\n if (storageAPIExists('livechat_msg_count_updated')) {\r\n msgCountUpdated = getStorageAPIValue('livechat_msg_count_updated');\r\n }\r\n if (storageAPIExists('livechat_last_msg_id')) {\r\n lastMessageId = parseInt(getStorageAPIValue('livechat_last_msg_id'));\r\n }\r\n const agentMsgsCount =\r\n args.getMeta().history != null\r\n ? args.getMeta().history.filter((m) => m.userId > 0 && m.id > lastMessageId)\r\n : [];\r\n if (msgCountUpdated === 'true') {\r\n const noOfNewAgentMsgs = agentMsgsCount.length + counterMessage;\r\n ApexChat.storageAPI.StoreTemp('livechat_new_msg_count', noOfNewAgentMsgs);\r\n ApexChat.storageAPI.StoreTemp('livechat_msg_count_updated', false);\r\n }\r\n me.postMessage({ event: ChatEvents.OnHistoryLoadedCompletely });\r\n }\r\n\r\n setNewChat(isNewChat) {\r\n this.options.isNewChat = isNewChat;\r\n }\r\n\r\n initChatRoom() {\r\n this.state.changeState({ toState: ChatStates.Requested });\r\n const me = this;\r\n if (typeof fm !== 'undefined') {\r\n me.setWebSyncClient();\r\n } else {\r\n console.log('WebSync is not loaded');\r\n }\r\n }\r\n\r\n sendVisitorRealtimeTyping(text, clear) {\r\n const me = this;\r\n me.webSyncClient.publish({\r\n channel: `/chatroom/${me.options.chatId}/realtime/text`,\r\n data: {\r\n text,\r\n clear\r\n },\r\n onSuccess(args) {\r\n // me.onVisitorRealtimeTypingArrived(args.data);\r\n },\r\n onFailure(args) { }\r\n });\r\n }\r\n\r\n onChatJoined(args) {\r\n const me = this;\r\n me.isLead = false;\r\n // Extracting value of visitor client Id from query string.\r\n const visitorsGoogleClientId = Cookies.get('ga_client_id');\r\n if (me.isNewChat) {\r\n // Sending data over to analytics for chats\r\n sendChatAndLeadAnalytics(ApexChatStartData, true, visitorsGoogleClientId);\r\n } else {\r\n // clean out the real time response area (Refresh scenario)\r\n me.sendVisitorRealtimeTyping('', true);\r\n }\r\n // subscribing the channel which informs that chat becomes lead; now sending leads data to analytics if any analytics is available\r\n me.webSyncClient.subscribe({\r\n retries: 3,\r\n channel: `/chatroom/${me.options.chatId}/meta`,\r\n onSuccess() { },\r\n onReceive(args) {\r\n const data = args.getData();\r\n if (me.isLead) {\r\n return;\r\n }\r\n if (data.isLead) {\r\n me.isLead = true;\r\n sendChatAndLeadAnalytics(ApexChatStartData, false, visitorsGoogleClientId);\r\n }\r\n },\r\n onFailure() { }\r\n });\r\n const data = {\r\n messageIds:\r\n getCookieValue(TempCache.APEXCHAT_PRECHAT_MESSAGE_IDS_COOKIE) ||\r\n fromQueryString('prechatids'),\r\n agentName: me.options.agentName\r\n };\r\n if (args.participantDisplayName) {\r\n data.participantDisplayName = args.participantDisplayName;\r\n }\r\n if (me.options.chatId == 0 || me.options.chatId == undefined) {\r\n me.options.chatId = me.chatId;\r\n }\r\n const publishData = { data, meta: me.getMeta(), chatId: me.options.chatId };\r\n // CHAT-8201 Windowed chat not initiated on beta when start from prechat\r\n // check if prechat messages ids not exists and query string has prechatIds so defined cookie on windowed mode\r\n // previously it was not creating a cookie due to different domain on beta, so we need to create it from querystring\r\n if (\r\n !storageAPIExists(TempCache.APEXCHAT_PRECHAT_MESSAGE_IDS_COOKIE) &&\r\n me.options.chatMode === ChatMode.Windowed\r\n ) {\r\n const prechatIds = fromQueryString('prechatids');\r\n if (prechatIds) {\r\n ApexChat.storageAPI.Store(\r\n TempCache.APEXCHAT_PRECHAT_MESSAGE_IDS_COOKIE,\r\n prechatIds\r\n );\r\n }\r\n }\r\n /* CHAT-6280-Handle PreChat chat joined hits\r\n * invoked event here so specfic widget(prechat or other widget) can publish whenever required\r\n *\r\n For Windowed Chat, had to move publishPreChatMessages From PreChat Class to ChatRoom Class\r\n Added Strong conditions to make sure that IF PreChat Messages has sent already than no need to send it again (CHAT-6643 FIX) */\r\n if (\r\n (storageAPIExists(TempCache.APEXCHAT_PRECHAT_MESSAGE_IDS_COOKIE) || fromQueryString('prechatids')) &&\r\n !storageAPIExists(TempCache.APEXCHAT_PRECHAT_MESSAGE_SENT_COOKIE)\r\n ) {\r\n console.log('publishPreChatMessages')\r\n me.publishPreChatMessages(publishData);\r\n } else {\r\n console.log('publishPreChatMessages not called');\r\n }\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnChatJoined,\r\n value: publishData\r\n });\r\n }\r\n\r\n onChatJoinFailure(args) {\r\n const me = this;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnChatJoinFailure,\r\n value: args\r\n });\r\n }\r\n\r\n sendLive() {\r\n const me = this;\r\n if (this.options.isLiveAvailable && this.firstMessageArrived) {\r\n this.webSyncClient.publish({\r\n retries: 3,\r\n channel: `/chatroom/${me.chatId}/meta`,\r\n data: {\r\n live: canBrowserDoLive()\r\n }\r\n });\r\n this.sendLive = function () { }; // do it once and only once\r\n }\r\n }\r\n\r\n startBatch() {\r\n this.webSyncClient.startBatch();\r\n }\r\n\r\n endBatch() {\r\n this.webSyncClient.endBatch();\r\n }\r\n\r\n sendMessage(args) {\r\n const me = this;\r\n if (me.isChatTransferredToSMS) {\r\n me.isChatTransferredToSMS = false;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnSendMessageFailure,\r\n value: {}\r\n });\r\n }\r\n if (window.ApexChatStartData) {\r\n Object.assign(me.options, ApexChatStartData);\r\n }\r\n // avoid sending blank text\r\n // CHAT-7539 - ChatId before sending responses.\r\n if (!me.options.chatId || !args.chatMsg || args?.chatMsg?.replace(/\\s/g, '') == '') {\r\n // CHAT-8877 - DarkOverlay was not appearing If Chat Started and page get refreshed and session gets ended\r\n // because ChatId we are making null and it was returning and WebSync OnFailure was not executing\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnSendMessageFailure,\r\n value: null\r\n });\r\n return;\r\n }\r\n me.webSyncClient.publish({\r\n retries: 3,\r\n channel: `/chatroom/${me.options.chatId}/meta`,\r\n data: {\r\n live: canBrowserDoLive()\r\n }\r\n });\r\n const data = {};\r\n data.text = args.chatMsg;\r\n data.isForAIBot = args.isForAIBot;\r\n data.questionTypeChatLogIdToBeUpdated = args.questionTypeChatLogIdToBeUpdated;\r\n data.participantId = args.agentParticipantId || me.options.participantId;\r\n data.isPredefinedResponse = args.isPredefinedResponse;\r\n data.timeCalendarOrText = args.timeCalendarOrText;\r\n if (args.isGreeting) {\r\n data.isGreeting = args.isGreeting;\r\n }\r\n if (args.contactInfo) {\r\n // Contact info json\r\n data.contactInfo = args.contactInfo;\r\n }\r\n // If this script text has associated agent script answer details\r\n if (args.answerScript) {\r\n // Set these properties here, to pass these details in ChatLog table\r\n data.scriptAnswerId = args.answerScript.agentScriptAnswerId;\r\n data.questionType = args.answerScript.questionType;\r\n data.options = args.answerScript.options;\r\n // If message is predefind poke message\r\n if (\r\n args.agentParticipantId === ParticipantIds.predefined &&\r\n args.answerScript.agentParticipantId === ParticipantIds.pokeMessage\r\n ) {\r\n data.participantId = args.answerScript.agentParticipantId;\r\n data.isPredefinedPokeMessage = true;\r\n }\r\n }\r\n\r\n // Send QT response flag with the data\r\n data.isQTResponseSent = args.questionType > 0;\r\n\r\n if (args.participantDisplayName) {\r\n data.participantDisplayName = args.participantDisplayName;\r\n }\r\n if (args.userId) {\r\n // sending userId as a data in webSyncClient publish so it can update on db according to message type(agent,predefined or visitor)\r\n data.userId = args.userId;\r\n }\r\n const argsContext = args;\r\n // We are assigning message sequence for each new message here\r\n const formatMessageSequence = (number) => {\r\n // is agent or operator?\r\n var isAgentOrOperator = ApexChat.Settings && ApexChat.Settings.CurrentUserId > 0;\r\n // the format of message sequence is userId (8 digits) + sequence number of message\r\n // for visitor UserId is always 0\r\n var prefix = '00000000';\r\n // we maintain two separate sequences for agents/operators and visitors\r\n if (isAgentOrOperator) {\r\n var userIdLen = ApexChat.Settings.CurrentUserId.toString().length;\r\n // add as many 0s as needed to make it 8 digits long\r\n prefix = prefix.slice(0, prefix.length - userIdLen) + ApexChat.Settings.CurrentUserId;\r\n }\r\n // limit to two digits (edge case), just in case its a long chat- which has never happned\r\n if (number > 99) {\r\n number = number % 100;\r\n }\r\n var messageSequenceFormatted = number;\r\n // if number is less than 10, add a leading 0, to make it a double digit string\r\n if (number < 10) {\r\n messageSequenceFormatted = '0' + number;\r\n }\r\n return prefix + messageSequenceFormatted;\r\n };\r\n if (data.participantId > 0) {\r\n this.messageSequence++;\r\n data.messageSequence = formatMessageSequence(this.messageSequence);\r\n }\r\n if (args.agentParticipantId == ParticipantIds.predefined) {\r\n data.delayTime = args.delayTime;\r\n }\r\n data.isUnread = true;\r\n me.webSyncClient.publish({\r\n retries: 0,\r\n meta: me.getMeta(me.options.chatId, me.options.companyId, me.options.token),\r\n channel: `/chatroom/${me.options.chatId}`,\r\n data,\r\n onSuccess(args) {\r\n /* server sending invalid text of predefined msg with nested html code and tag, replacing server's predefined msg with clients chat msg */\r\n const getData = args.getData();\r\n getData.userId = getData.userId || ParticipantIds.visitor;\r\n getData.text = argsContext.chatMsg;\r\n Cookies.set('livechat_chat_lastmessage', JSON.stringify(getData)); // CHAT-7300 set last message on cookies\r\n if (argsContext.shouldRenderResponseAsText) {\r\n // in case of a full text response, we forcefully clear it from being tagged: QuestionTypeAnswer so that we can show the full text response on chat messages\r\n getData.options = null;\r\n }\r\n if (getData.userId == ParticipantIds.visitor) {\r\n // message send by visitor should also be part of allHistoryMessages.\r\n ApexChat.allHistoryMessages.push(getData);\r\n }\r\n if (argsContext.onSuccess) {\r\n argsContext.onSuccess(getData);\r\n }\r\n if (argsContext.agentParticipantId != ParticipantIds.predefined) {\r\n // predefined messages should not be shown after publish predefined messages, since they are already shown before\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnSendMessageSuccess,\r\n value: args.getData ? getData : args\r\n });\r\n }\r\n },\r\n onFailure(args) {\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnSendMessageFailure,\r\n value: args\r\n }); // passing error object as value is more informative than passing just an error message\r\n }\r\n });\r\n\r\n if (args.callback) {\r\n args.callback();\r\n }\r\n }\r\n\r\n sendTyping(indicator, text) {\r\n const operatorName =\r\n ApexChat && ApexChat.Settings ? ApexChat.Settings.CurrentUserDisplayName : '';\r\n const me = this;\r\n if (!text) {\r\n text = '';\r\n }\r\n me.webSyncClient.publish({\r\n channel: `/chatroom/${me.options.chatId}/typing`,\r\n data: {\r\n participantId: me.options.participantId,\r\n // Visitor Name (available on Visitor End) || Agent/Operator Aliase Name || Operator Name if aliase not selected\r\n participantDisplayName:\r\n me.options.participantDisplayName ||\r\n me.agentAlias ||\r\n operatorName ||\r\n 'Chat Representative',\r\n indicator,\r\n text\r\n },\r\n onSuccess(args) {\r\n me.onTypingArrived(args.getData(), true);\r\n },\r\n onFailure(args) {\r\n if (window.console) {\r\n window.console.log(args.error);\r\n }\r\n }\r\n });\r\n }\r\n\r\n onMessageTyping(e) {\r\n const me = this;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnMessageTyping,\r\n value: e\r\n });\r\n }\r\n\r\n updateChatOnHoldStatus(chatId) {\r\n fm.network.xhr({\r\n retries: 0,\r\n method: 'POST',\r\n url: `/Services/ApexChatService.svc/updatechatonholdstatus/${chatId}/false`,\r\n data: {},\r\n onSuccess() {\r\n try {\r\n $('#videoChatStatus').hide();\r\n $('.apexchat-live-status-title').remove('');\r\n // ApexChat.Invitation.showInvitation();\r\n } catch (e) { }\r\n },\r\n onFailure(args) { }\r\n });\r\n }\r\n\r\n queueMessage(m) {\r\n const me = this;\r\n me.Queue = me.Queue || new Queue();\r\n me.Queue.enqueue(m);\r\n }\r\n\r\n dequeueMessage() {\r\n const me = this;\r\n if (me.Queue.getLength() == 0) {\r\n return null;\r\n }\r\n const popped = me.Queue.dequeue();\r\n return popped;\r\n }\r\n\r\n onMessageArrived(m, initialLoad, index) {\r\n const me = this;\r\n m.isFromHistory = initialLoad;\r\n const delayPromise = me.delayOnMessageArrived(m);\r\n Promise.all([delayPromise]).then(() => {\r\n const args = { m, initialLoad, index };\r\n if (m.isTranslating) {\r\n return;\r\n }\r\n const isNotSystemMessage = m.participantId > ParticipantIds.visitor &&\r\n m.questionType != ScriptsQuestionType.MultipleChoiceConsent &&\r\n m.questionType != ScriptsQuestionType.WebToSMSNotification;\r\n // persist input hidden on every message except agent message from dashboard\r\n if (isNotSystemMessage) {\r\n const chatContentWrap = me.options.context.querySelector('.apexchat_hide_msg_input');\r\n if (chatContentWrap) {\r\n chatContentWrap.classList.remove('apexchat_hide_msg_input');\r\n }\r\n }\r\n logIt(`chatroom-v3::onMessageArrived:${args.m.text}`);\r\n\r\n logIt(`validating if msg is piped:${JSON.stringify(args.m)}`);\r\n if (m.isChatEnded) {\r\n const PipedMessageHandlerSingleton = new PipedMessageHandler();\r\n // is it chat ended system msg? hold on in case a piped msg is being processed\r\n me.isChatEnded = true;\r\n RunAsSoonAs(\r\n () => {\r\n logIt('safely end chat:');\r\n me.postMessage({\r\n event: WidgetTypes.PokeMessagesOverLay + WidgetStates.Hidden\r\n });\r\n me.postMessage({\r\n event: WidgetTypes.ChatRoom + ChatEvents.ChatIdleOut\r\n });\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnMessageArrived,\r\n value: args\r\n });\r\n },\r\n () => PipedMessageHandlerSingleton.isProcessing() == false\r\n );\r\n } else {\r\n const isFromHistory = initialLoad;\r\n // There are few scenarios in which we need to manipulate the typing indication time.\r\n // 1. In case of Refresh the history message should show without typing & with no time delay.\r\n // 2. If the message has been shown on PreChat so after moving to DOM the there should be no extra delay added.\r\n const messageInterval = isFromHistory ? 2 : me.options.questionTypeDelay * 1000; // set default interval\r\n // process a piped msg or a normal/non-piped msg\r\n if (isFromHistory) {\r\n if (args.m.questionType == ScriptsQuestionType.AppointmentScheduler) {\r\n // Set the options for appointment scheduler\r\n if (!args.m.questionTypeSettings && args.m.options) {\r\n args.m.questionTypeSettings = args.m.options;\r\n }\r\n }\r\n }\r\n const PipedMessageHandlerSingleton = new PipedMessageHandler();\r\n if (PipedMessageHandlerSingleton.isValidPipedMessage(args)) {\r\n logIt(`QUEUED:processing piped${args.m.text}`);\r\n\r\n PipedMessageHandlerSingleton.startPolling({\r\n init() {\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnTypingArrived,\r\n value: { indicator: true }\r\n });\r\n },\r\n async startPollingCallback(m) {\r\n logIt(`QUEUED:startPollingCallback:${m.text}`);\r\n\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnMessageArrived,\r\n value: { m, initialLoad, index }\r\n });\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnTypingArrived,\r\n value: { indicator: true }\r\n });\r\n },\r\n lastPollingCallback(args) {\r\n logIt(`QUEUED:lastPollingCallback:${args.m.text}`);\r\n\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnTypingArrived,\r\n value: { indicator: false }\r\n });\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnMessageArrived,\r\n value: args\r\n });\r\n },\r\n messageDisplayDuration: messageInterval,\r\n isFromHistory\r\n });\r\n } else {\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnMessageArrived,\r\n value: args\r\n });\r\n }\r\n ApexChat.addDelayToMappedQuestion = m.isNextQuestionMapped;\r\n }\r\n Cookies.set('livechat_chat_lastmessage', JSON.stringify(m)); // CHAT-7300 set last message on cookies\r\n if (m.userId > 0) {\r\n // message from the agent - stop waiting timer\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnStopWaiting,\r\n value: args\r\n });\r\n }\r\n });\r\n }\r\n\r\n /** add delay to question type as per text length\r\n * If the length is greater than 100 the default timeout apply\r\n * other than that it will calculate the time by multiplying text length with 150\r\n */\r\n delayOnMessageArrived(message) {\r\n const me = this;\r\n return new Promise((resolve) => {\r\n let timeout = 0;\r\n ApexChat.options = me.options || '';\r\n const PipedMessageHandlerSingleton = new PipedMessageHandler();\r\n if (\r\n message.text &&\r\n message.questionType > ScriptsQuestionType.None &&\r\n !PipedMessageHandlerSingleton.isValidPipedMessage({ m: message }) &&\r\n !message.isFromHistory\r\n ) {\r\n const messageText = message.text.replace(/<[^>]*>?/gm, '');\r\n if (ApexChat.addDelayToMappedQuestion && ApexChat.VisitorResponse) {\r\n function estimator(number) {\r\n if (number <= 30) {\r\n return 2000;\r\n }\r\n if (number <= 50) {\r\n return 2500;\r\n }\r\n if (number <= 75) {\r\n return 3000;\r\n }\r\n if (number <= 100) {\r\n return 3500;\r\n }\r\n return 4000;\r\n }\r\n timeout = estimator(messageText.trim().length);\r\n } else {\r\n timeout = 0;\r\n }\r\n }\r\n // show typing indication\r\n if (timeout) {\r\n me.postMessage({\r\n event: ChatEvents.OnTypingArrived,\r\n value: { indicator: true }\r\n });\r\n }\r\n setTimeout(() => {\r\n // hide typing indication\r\n me.postMessage({\r\n event: ChatEvents.OnTypingArrived,\r\n value: { indicator: false }\r\n });\r\n resolve(true);\r\n }, timeout);\r\n });\r\n }\r\n\r\n isLinkSameAsHost(link) {\r\n try {\r\n let hrefURL;\r\n let pageURL;\r\n hrefURL = new URL(link);\r\n pageURL = new URL(window.location);\r\n if (!(link.startsWith('/') || hrefURL.host === pageURL.host)) {\r\n return false;\r\n }\r\n return true;\r\n } catch (e) {\r\n return false;\r\n }\r\n }\r\n\r\n openLinkIfExists(data) {\r\n let linkMatch = data.answers.match && data.answers.match(\"href='(.*)'\");\r\n if (!linkMatch && data.answers && data.answers[0].option && data.answers[0].option.match) {\r\n linkMatch = data.answers[0].option.match(\"href='(.*)'\")\r\n }\r\n if (linkMatch && linkMatch[1]) {\r\n if (linkMatch[1] && this.isLinkSameAsHost(linkMatch[1])) {\r\n window.open(linkMatch[1], '_self');\r\n } else {\r\n window.open(linkMatch[1], '_blank');\r\n }\r\n }\r\n }\r\n\r\n publishQuestionTypeResponse(data, cb) {\r\n const me = this;\r\n logIt('publishQuestionTypeResponse:');\r\n logIt(data);\r\n data.chatId = me.options.chatId || data.chatId;\r\n /// /Send QT response flag with the data\r\n data.isQTResponseSent = data.questionType > 0;\r\n me.webSyncClient.publish({\r\n retries: 1,\r\n meta: me.getMeta(me.options.chatId, me.options.companyId, me.options.token),\r\n channel: `/chatroom/${data.chatId}/templatedquestions/answer`,\r\n data,\r\n onSuccess() {\r\n if (cb && typeof cb === 'function') {\r\n logIt('FT:: FT/QT processed... do anything in a callback');\r\n cb();\r\n }\r\n me.openLinkIfExists(data);\r\n }\r\n });\r\n }\r\n\r\n OnSMSTransfer(args) {\r\n const me = this;\r\n me.isChatTransferredToSMS = true;\r\n if (args.systemMessageType == SystemMessageType.SMSTransferInProgress) {\r\n // if chat transferred to sms unsubscribe chat channels and remove cookies to disabled chat.\r\n me.postMessage({\r\n event: WidgetTypes.ChatRoom + ChatEvents.OnSMSChatTransferring,\r\n data: args\r\n });\r\n }\r\n // uncomment and implement SMSTransferred status when required\r\n // else if (args.systemMessageType == SystemMessageType.SMSTransferred) {\r\n // me.postMessage({\r\n // event: WidgetTypes.ChatRoom + ChatEvents.OnSMSChatTransferred,\r\n // data: args\r\n // });\r\n // me.postMessage({\r\n // event: WidgetTypes.ChatRoom + ChatEvents.ChatIdleOut\r\n // });\r\n // }\r\n }\r\n\r\n onParticipantsChanged(participants) {\r\n const me = this;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnParticipantsChanged,\r\n value: participants\r\n });\r\n }\r\n\r\n hideWaitingIndicator(participants) {\r\n const me = this;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnHideWaitingIndicator,\r\n value: participants\r\n });\r\n }\r\n\r\n onTypingArrived(args, self) {\r\n if (self) {\r\n return;\r\n }\r\n const me = this;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnTypingArrived,\r\n value: args\r\n });\r\n }\r\n\r\n onCallStatusArrived(args) {\r\n const me = this;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnCallStatusArrived,\r\n value: args\r\n });\r\n }\r\n\r\n onChatEnded(args) {\r\n const me = this;\r\n me.state.changeState({\r\n origin: me.objectType,\r\n toState: ChatEvents.OnChatEnded,\r\n value: args\r\n });\r\n }\r\n\r\n leaveChat() {\r\n const id = this.options.chatId || this.getChatId();\r\n const me = this;\r\n me.webSyncClient.unsubscribe({\r\n channels: [\r\n `/chatroom/${id}`,\r\n `/chatroom/${id}/typing`,\r\n `/chatroom/${id}/participants`,\r\n `/chatroom/${id}/meta`,\r\n `/chatroom/${id}/messagereceipt`\r\n ],\r\n onFailure(args) {\r\n alert(args.getErrorMessage());\r\n }\r\n });\r\n }\r\n\r\n publishPreChatMessages(args) {\r\n ApexChat.webSyncClient.publish({\r\n retries: 0,\r\n meta: args.meta,\r\n channel: `/chatroom/${args.chatId}/prechatmessages`,\r\n data: args.data,\r\n onSuccess() {\r\n ApexChat.storageAPI.StoreTemp(TempCache.APEXCHAT_PRECHAT_MESSAGE_SENT_COOKIE, true);\r\n setTimeout(() => {\r\n ApexChat.storageAPI.Remove(TempCache.APEXCHAT_PRECHAT_MESSAGE_IDS_COOKIE);\r\n }, 6000);\r\n }\r\n });\r\n }\r\n\r\n handleFullTextVisitorResponse(m) {\r\n ApexChat.chatArray = ApexChat.chatArray || [];\r\n const chatLogLength = ApexChat.chatArray.length;\r\n // Bug_7343 - Visitor's responses against FullText not appearing\r\n // summary: in case of a full text response, we forcefully clear it from being tagged: QuestionTypeAnswer so that we can show the full text response on chat messages\r\n if (chatLogLength > 0) {\r\n const previousMsg = ApexChat.chatArray[chatLogLength - 1];\r\n // We need to make previous message options null only when we have got answer in current message\r\n if (\r\n previousMsg &&\r\n m.options == 'QuestionTypeAnswer' &&\r\n previousMsg.questionType === ScriptsQuestionType.FullText\r\n ) {\r\n m.options = null;\r\n }\r\n }\r\n if (m.participantId != ParticipantIds.pokeMessage) {\r\n // don't need to be push poke messages in chatArray\r\n ApexChat.chatArray.push(m);\r\n }\r\n return m.options;\r\n }\r\n\r\n handleVisitorResponsesRenderAsText(m) {\r\n const me = this;\r\n ApexChat.chatArray = ApexChat.chatArray || [];\r\n const chatLogLength = ApexChat.chatArray.length;\r\n\r\n // summary: in case of a MCBottomSheet List response, we forcefully clear it from being tagged: QuestionTypeAnswer so that we can show the full text response on chat messages\r\n if (chatLogLength > 0) {\r\n const previousMsg = ApexChat.chatArray[chatLogLength - 2];\r\n // We need to make previous message options null only when we have got answer in current message\r\n if (previousMsg && m.options == 'QuestionTypeAnswer') {\r\n const isATA = previousMsg.questionType == ScriptsQuestionType.AllThatApply;\r\n const isMC =\r\n previousMsg.questionType == ScriptsQuestionType.MultipleChoice;\r\n const isTF = previousMsg.questionType == ScriptsQuestionType.TrueOrFalse;\r\n const isSMSOptIn =\r\n previousMsg.questionType == ScriptsQuestionType.MultipleChoiceConsent;\r\n\r\n const isText = previousMsg.questionType == ScriptsQuestionType.Text;\r\n const isDateTimeQT =\r\n previousMsg.questionType == ScriptsQuestionType.Time ||\r\n previousMsg.questionType == ScriptsQuestionType.TimeCalendar ||\r\n previousMsg.questionType == ScriptsQuestionType.CalendarDate;\r\n const isWebToSMS = previousMsg.questionType == ScriptsQuestionType.WebToSMSNotification;\r\n // BottomSheet & ATA-List Responses\r\n if (\r\n (isATA || isMC) &&\r\n previousMsg.questionTypeDisplayListForVisitor &&\r\n (me.options.widgetType.indexOf(WidgetTypes.DOM) !== -1 ||\r\n me.options.widgetType.indexOf(WidgetTypes.Windowed) !== -1)\r\n ) {\r\n m.options = null;\r\n }\r\n // ATA - Non List Responses\r\n if (isATA && !previousMsg.questionTypeDisplayListForVisitor) {\r\n m.options = null;\r\n }\r\n // MC - Non List Responses\r\n if (isMC && !previousMsg.questionTypeDisplayListForVisitor) {\r\n m.options = null;\r\n }\r\n // TF - Responses\r\n if (isTF || isDateTimeQT || isText || isSMSOptIn || isWebToSMS) {\r\n m.options = null;\r\n }\r\n // EP - QT Responses\r\n if (\r\n previousMsg.participantId == ParticipantIds.predefined &&\r\n m.options == 'QuestionTypeAnswer' &&\r\n previousMsg.userId == UserIds.simulated\r\n ) {\r\n m.options = null;\r\n }\r\n }\r\n }\r\n return m.options;\r\n }\r\n}\r\n","/**\r\n Creates a new queue. A queue is a first-in-first-out (FIFO) data structure -\r\n items are added to the end of the queue and removed from the front.\r\n*/\r\nconst Queue = function () {\r\n // initialise the queue and offset\r\n let queue = [];\r\n let offset = 0;\r\n\r\n // Returns the length of the queue.\r\n this.getLength = function () {\r\n return queue.length - offset;\r\n };\r\n\r\n // Returns true if the queue is empty, and false otherwise.\r\n this.isEmpty = function () {\r\n return queue.length == 0;\r\n };\r\n this.getItems = function () {\r\n return queue;\r\n };\r\n /* Enqueues the specified item. The parameter is:\r\n *\r\n * item - the item to enqueue\r\n */\r\n this.enqueue = function (item) {\r\n queue.push(item);\r\n };\r\n\r\n /* Dequeues an item and returns it. If the queue is empty, the value\r\n * 'undefined' is returned.\r\n */\r\n this.dequeue = function () {\r\n // if the queue is empty, return immediately\r\n if (queue.length == 0) return undefined;\r\n\r\n // store the item at the front of the queue\r\n const item = queue[offset];\r\n\r\n // increment the offset and remove the free space if necessary\r\n if (++offset * 2 >= queue.length) {\r\n queue = queue.slice(offset);\r\n offset = 0;\r\n }\r\n\r\n // return the dequeued item\r\n return item;\r\n };\r\n\r\n /* Returns the item at the front of the queue (without dequeuing it). If the\r\n * queue is empty then undefined is returned.\r\n */\r\n this.peek = function () {\r\n return queue.length > 0 ? queue[offset] : undefined;\r\n };\r\n};\r\nexport default Queue;\r\n"],"names":["simulated","navigator","getUserMedia","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","hasActiveX","window","external","msActiveXFilteringEnabled","LiveChatRoom","BaseClass","constructor","options","objectType","WidgetTypes","ChatRoom","super","Object","assign","widget","$","this","me","isNewChat","ApexChatStartData","chatId","suppressHistory","isFromInvitation","messageSequence","subscribe","ChatStates","MessageArrived","m","logIt","text","isFromHistory","Queue","getLength","postMessage","event","ChatEvents","OnHistoryLoadedCompletely","msg","dequeueMessage","JSON","stringify","getItems","onMessageArrived","index","end","setWebSyncClient","ApexChat","webSyncClient","fm","websync","client","GlobalVariables","LiveChatServiceUrl","util","ready","connect","requestUrl","stream","autoDisconnect","quiet","stayConnected","onSuccess","args","onFailure","reconnect","onStreamFailure","getMeta","companyId","token","subscribeToChatChannel","id","meta","isPreChatMaximized","state","getStateValue","PreChat","WidgetStates","ShownMaximized","participantId","history","indexOfLastMessage","length","channels","retries","onReceive","data","getData","userId","ParticipantIds","predefined","onChatJoinFailure","error","console","log","processHistoryItems","isChatActive","cb","allHistoryMessages","i","match","some","setMessageSequenceFromHistory","currentSequence","isAgentOrOperator","Settings","CurrentUserId","Number","substring","handleFullTextVisitorResponse","handleVisitorResponsesRenderAsText","queueMessage","push","isChatEnded","setChatId","isPageRefreshed","OnHistoryStartLoading","isConnectionEstablished","chatMode","ChatMode","Windowed","TryParse","fromQueryString","onChatJoined","storageAPI","Store","TempCache","CHAT_ID_COOKIE","updateBubbleMsgCount","getChannel","isPredefinedPokeMessage","DOM","ShownMinimized","isWindowedStarted","systemMessageType","SystemMessageType","WebToSMSTransferCompleted","ChatIdleOut","context","remove","SMSTransferInProgress","SMSTransferred","OnSMSTransfer","onTypingArrived","onParticipantsChanged","onComplete","counterMessage","lastMessageId","msgCountUpdated","storageAPIExists","parseInt","getStorageAPIValue","agentMsgsCount","filter","noOfNewAgentMsgs","StoreTemp","setNewChat","initChatRoom","changeState","toState","Requested","sendVisitorRealtimeTyping","clear","publish","channel","isLead","visitorsGoogleClientId","Cookies","get","sendChatAndLeadAnalytics","messageIds","getCookieValue","APEXCHAT_PRECHAT_MESSAGE_IDS_COOKIE","agentName","participantDisplayName","undefined","publishData","prechatIds","APEXCHAT_PRECHAT_MESSAGE_SENT_COOKIE","publishPreChatMessages","origin","OnChatJoined","value","OnChatJoinFailure","sendLive","isLiveAvailable","firstMessageArrived","live","canBrowserDoLive","startBatch","endBatch","sendMessage","isChatTransferredToSMS","OnSendMessageFailure","chatMsg","replace","isForAIBot","questionTypeChatLogIdToBeUpdated","agentParticipantId","isPredefinedResponse","timeCalendarOrText","isGreeting","contactInfo","answerScript","scriptAnswerId","agentScriptAnswerId","questionType","pokeMessage","isQTResponseSent","argsContext","number","prefix","userIdLen","toString","slice","messageSequenceFormatted","formatMessageSequence","delayTime","isUnread","visitor","set","shouldRenderResponseAsText","OnSendMessageSuccess","callback","sendTyping","indicator","operatorName","CurrentUserDisplayName","agentAlias","onMessageTyping","e","OnMessageTyping","updateChatOnHoldStatus","network","xhr","method","url","hide","enqueue","dequeue","initialLoad","delayPromise","delayOnMessageArrived","Promise","all","then","isTranslating","ScriptsQuestionType","MultipleChoiceConsent","WebToSMSNotification","chatContentWrap","querySelector","classList","PipedMessageHandlerSingleton","PipedMessageHandler","RunAsSoonAs","PokeMessagesOverLay","Hidden","OnMessageArrived","isProcessing","messageInterval","questionTypeDelay","AppointmentScheduler","questionTypeSettings","isValidPipedMessage","startPolling","init","OnTypingArrived","startPollingCallback","lastPollingCallback","messageDisplayDuration","addDelayToMappedQuestion","isNextQuestionMapped","OnStopWaiting","message","resolve","timeout","None","messageText","VisitorResponse","trim","setTimeout","isLinkSameAsHost","link","hrefURL","pageURL","URL","location","startsWith","host","openLinkIfExists","linkMatch","answers","option","open","publishQuestionTypeResponse","OnSMSChatTransferring","participants","OnParticipantsChanged","hideWaitingIndicator","OnHideWaitingIndicator","self","onCallStatusArrived","OnCallStatusArrived","onChatEnded","OnChatEnded","leaveChat","getChatId","unsubscribe","alert","getErrorMessage","Remove","chatArray","chatLogLength","previousMsg","FullText","isATA","AllThatApply","isMC","MultipleChoice","isTF","TrueOrFalse","isSMSOptIn","isText","Text","isDateTimeQT","Time","TimeCalendar","CalendarDate","isWebToSMS","questionTypeDisplayListForVisitor","widgetType","indexOf","UserIds","queue","offset","isEmpty","item","peek"],"sourceRoot":""}