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CACrBlC,cAA0B,OAAZA,QAAY,IAAZA,OAAY,EAAZA,EAAcsC,MAAO,MAE3C,OAGR,SAAC,EAAAsF,SAAQ,CAACC,UAAU,oBAAS,SACxBhI,IACG,SAACT,EAAqB,CAClB6I,QAAS,WACDpI,GACAE,IAEAQ,GACAE,IAEJhB,GAAW,GACXoB,GACJ,WASpC,C","sources":["app/TabNotifications.jsx","app/App.jsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport { useIntl } from \"react-intl\";\n\nfunction TabNotification({ newMessage, onResetMessage }) {\n const intl = useIntl();\n const { current: originalTitle } = useRef(document.title);\n\n useEffect(() => {\n let interval;\n clearInterval(interval);\n\n if (document.hidden && !!newMessage) {\n const messageNotification = intl.formatMessage({\n id: \"WEBMESSENGER.TAB_NOTIFICATION.NEW_MESSAGE\",\n description: \"Notification : Nouveau message\",\n defaultMessage: \"Nouveau message\",\n });\n\n interval = setInterval(() => {\n if (document.title === messageNotification) {\n document.title = originalTitle;\n } else {\n document.title = messageNotification;\n }\n }, 1000);\n\n return () => clearInterval(interval);\n }\n\n onResetMessage();\n document.title = originalTitle;\n\n return () => {};\n }, [newMessage, document.hidden]);\n return null;\n}\n\nTabNotification.propTypes = {\n newMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n onResetMessage: PropTypes.func,\n};\nexport default TabNotification;\n","import React, { Suspense, useEffect, useState } from \"react\";\n\nimport * as API from \"@ekonsilio/api-livechat\";\nimport { decode } from \"html-entities\";\nimport omit from \"lodash/omit\";\nimport { deviceType } from \"react-device-detect\";\nimport { useIntl } from \"react-intl\";\nimport { useQuery } from \"react-query\";\n\nimport TabNotification from \"./TabNotifications\";\n\nimport { useBehaviors } from \"../utils/behaviors\";\nimport { useConversationMessagesQuery } from \"../utils/queries/conversations\";\nimport { useSDK } from \"../utils/sdk\";\nimport { useWebmessenger } from \"../utils/webmessenger\";\nimport { useWebSocket } from \"../utils/websocket\";\n\nconst Button = React.lazy(() => import(\"./Button\"));\nconst Window = React.lazy(() => import(\"./window\"));\nconst NotificationComponent = React.lazy(() => import(\"./Notification\"));\n\nconst webmessengerApi = new API.Messaging.Webmessenger();\n\nfunction App() {\n const {\n maximized,\n openWindow,\n closeWindow,\n hidden,\n hide,\n show,\n notification,\n createNotification,\n closeNotification,\n conversation,\n setConversation,\n setOperator,\n operator,\n integration,\n online,\n setOnline,\n unreadMessagesCount,\n incrementUnreadMessagesCount,\n resetUnreadMessagesCount,\n } = useWebmessenger();\n\n const intl = useIntl();\n\n const {\n disable,\n hideChat,\n triggerOpenWindowBehaviors,\n isInit: behaviorsIsInit,\n } = useBehaviors();\n const { websocket, connected } = useWebSocket();\n\n const [newMessage, setNewMessage] = useState(\"\");\n const [allowSendNotification, setAllowSendNotification] = useState(true);\n const [conversationNotification, setConversationNotification] =\n useState(true);\n const [soundNotification, setSoundNotification] = useState(false);\n\n const getSessionStorage = () => {\n const sessionData = sessionStorage.getItem(\"eK-behaviors\");\n return sessionData ? JSON.parse(sessionData) : null;\n };\n\n const storage = getSessionStorage();\n\n const { emit } = useSDK();\n\n const { isSuccess: operatorStatusIsSuccess } = useQuery(\n [\"operator\", \"status\"],\n async () =>\n await webmessengerApi.getOperator(\n integration,\n operator?._id,\n operator?.avatar\n ),\n {\n onSuccess: async (data) => {\n if (process.env.REACT_APP_ANALYTICS) {\n try {\n if (!hideChat) {\n const body = {\n fingerprint: window.eK.fingerprint,\n integration: window.eK.integration,\n entity: window.eK.entity,\n url: window.location.href,\n online: !data.offline,\n root_cause: data.rootCause,\n };\n\n await fetch(\n `${process.env.REACT_APP_ANALYTICS}/status`,\n {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(body),\n }\n );\n }\n } catch (err) {\n console.error(err);\n }\n }\n\n if (data.offline) {\n if (!conversation) {\n disable();\n setOnline(false);\n hide();\n } else {\n show();\n }\n } else if (!hideChat) {\n setOnline(true);\n if (hidden) show();\n }\n },\n enabled: integration !== null,\n refetchOnWindowFocus: true,\n staleTime: 10000,\n }\n );\n\n useEffect(() => {\n if (storage && \"notificationConversation\" in storage.triggered) {\n if (!storage.triggered.notificationConversation) {\n setConversationNotification(false);\n } else {\n setConversationNotification(true);\n }\n }\n }, [storage]);\n\n useConversationMessagesQuery(conversation?._id, true, {\n onSuccess: ({ data }) => {\n const messages = data.filter((m) => m.author?.type === \"operator\");\n\n if (messages.length > 0 && conversationNotification) {\n createNotification({\n title: intl.formatMessage({\n id: \"WEBMESSENGER.NOTIFICATION.NEW_MESSAGE\",\n defaultMessage: \"Nouveau message\",\n }),\n text: messages[messages.length - 1].content,\n });\n incrementUnreadMessagesCount(messages.length);\n\n for (const message of messages) {\n webmessengerApi\n .markMessageAsReceived(conversation._id, message._id)\n .catch((err) => err);\n }\n }\n },\n enabled:\n conversation !== null &&\n conversation.status !== \"closed\" &&\n !maximized &&\n connected,\n refetchOnWindowFocus: false,\n staleTime: 0,\n });\n\n useEffect(() => {\n if (websocket && connected) {\n const onNewMessage = (message) => {\n if (message.author?.type === \"visitor\") {\n setAllowSendNotification(true);\n }\n\n if (\n (message.author?.type === \"operator\" ||\n message.type === \"system\") &&\n conversation &&\n conversation._id === message.conversation\n ) {\n if (\n soundNotification &&\n deviceType === \"browser\" &&\n message.type !== \"system\"\n ) {\n document.getElementById(\"eK-sound\").play();\n }\n if (document.hidden) {\n setNewMessage(message.content);\n if (allowSendNotification) {\n const newNotification = () =>\n new Notification(\n intl.formatMessage({\n id: \"WEBMESSENGER.NOTIFICATION.CONVERSATION_TRANSFERRED.TITLE\",\n defaultMessage: \"Nouveau message\",\n }),\n {\n body:\n message.content?.type === \"transfer\"\n ? intl.formatMessage({\n id: \"WEBMESSENGER.NOTIFICATION.CONVERSATION_TRANSFERRED.TEXT\",\n defaultMessage:\n \"La conversation a été transférée à un autre conseiller\",\n })\n : decode(message.content),\n icon: `${window.location.origin}/favicon.ico`,\n badge: \"faviconNotification.png\",\n }\n );\n newNotification();\n setAllowSendNotification(false);\n setTimeout(\n () => setAllowSendNotification(true),\n 20000\n );\n }\n }\n\n if (!maximized && message.type !== \"system\") {\n createNotification({\n title: intl.formatMessage({\n id: \"WEBMESSENGER.NOTIFICATION.NEW_MESSAGE\",\n defaultMessage: \"Nouveau message\",\n }),\n text: message.content,\n });\n setNewMessage(message.content);\n incrementUnreadMessagesCount();\n webmessengerApi\n .markMessageAsReceived(\n conversation._id,\n message._id\n )\n .catch((err) => err);\n\n storage.triggered = {\n ...storage.triggered,\n notificationConversation: true,\n };\n\n sessionStorage.setItem(\n \"eK-behaviors\",\n JSON.stringify(storage)\n );\n }\n }\n };\n\n websocket.on(\"message:new\", onNewMessage);\n\n const onConversationClosed = ({ _id, events }) => {\n /**\n * Only set the status if there is a conversation\n */\n if (conversation && conversation._id === _id) {\n setConversation((previousState) => ({\n ...previousState,\n status: \"closed\",\n events,\n }));\n }\n };\n\n websocket.on(\"conversation:closed\", onConversationClosed);\n\n const onConversationTransfer = ({\n conversation: conversationTransfer,\n to,\n }) => {\n setOperator({\n ...omit(\n conversationTransfer.participants.operators.find(\n ({ _id, current }) => _id === to && current\n ),\n [\"current\", \"startedAt\", \"endedAt\"]\n ),\n });\n };\n\n websocket.on(\"conversation:transfer\", onConversationTransfer);\n\n return () => {\n websocket.removeListener(\"message:new\", onNewMessage);\n websocket.removeListener(\n \"conversation:closed\",\n onConversationClosed\n );\n websocket.removeListener(\n \"conversation:transfer\",\n onConversationTransfer\n );\n };\n }\n return () => {};\n }, [\n websocket,\n connected,\n maximized,\n createNotification,\n incrementUnreadMessagesCount,\n resetUnreadMessagesCount,\n conversation,\n closeWindow,\n setConversation,\n setOperator,\n allowSendNotification,\n intl,\n soundNotification,\n ]);\n\n useEffect(() => {\n emit(\"service:status\", {\n online,\n operator:\n online && operator?.name && operator?.title && operator?.face\n ? {\n name: operator.name,\n title: operator.title,\n picture: `${process.env.REACT_APP_FILE}/files/avatars/${operator.face}`,\n }\n : null,\n });\n }, [online, operator]);\n\n // Send ChatView event when hidden is false\n useEffect(() => {\n let timeout = null;\n\n if (process.env.REACT_APP_ANALYTICS) {\n timeout = setTimeout(() => {\n if (!hidden && behaviorsIsInit && operatorStatusIsSuccess) {\n const body = {\n fingerprint: window.eK.fingerprint,\n integration: window.eK.integration,\n entity: window.eK.entity,\n url: window.location.href,\n deviceType,\n };\n\n fetch(`${process.env.REACT_APP_ANALYTICS}/chatView`, {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(body),\n });\n }\n }, 1000);\n }\n\n return () => {\n if (timeout !== null) clearTimeout(timeout);\n };\n }, [hidden, operatorStatusIsSuccess, behaviorsIsInit]);\n\n useEffect(() => {\n const sessionValue = sessionStorage.getItem(\"eK-sound-notification\");\n let isSoundNotificationEnabled = false;\n\n if (sessionValue === null) {\n const initialSound = window.eK.sound !== \"none\";\n isSoundNotificationEnabled = initialSound;\n } else {\n isSoundNotificationEnabled = sessionValue === \"true\";\n }\n\n setSoundNotification(isSoundNotificationEnabled);\n\n if (\n isSoundNotificationEnabled &&\n !document.getElementById(\"eK-sound\")\n ) {\n const audioElement = document.createElement(\"audio\");\n\n audioElement.id = \"eK-sound\";\n audioElement.src = `${process.env.PUBLIC_URL}/sounds/${window.eK.sound}.wav`;\n audioElement.autoplay = true;\n audioElement.preload = \"auto\";\n\n document.body.appendChild(audioElement);\n\n const trackElement = document.createElement(\"track\");\n trackElement.kind = \"captions\";\n\n audioElement.appendChild(trackElement);\n audioElement.load();\n audioElement.play();\n audioElement.pause();\n }\n }, []);\n\n const onToggleSoundNotification = (toggleSound) => {\n sessionStorage.setItem(\"eK-sound-notification\", toggleSound);\n setSoundNotification(toggleSound);\n };\n\n return (\n <>\n setNewMessage(\"\")}\n />\n {maximized ? (\n }>\n \n onToggleSoundNotification(!soundNotification)\n }\n />\n \n ) : (\n !hidden && (\n <>\n }>\n {\n if (notification) {\n closeNotification();\n }\n if (unreadMessagesCount) {\n resetUnreadMessagesCount();\n }\n openWindow(true);\n triggerOpenWindowBehaviors();\n\n emit(\"window:maximized\", {\n conversation: conversation?._id || null,\n });\n }}\n />\n \n }>\n {notification && (\n {\n if (notification) {\n closeNotification();\n }\n if (unreadMessagesCount) {\n resetUnreadMessagesCount();\n }\n openWindow(true);\n triggerOpenWindowBehaviors();\n }}\n />\n )}\n \n \n )\n )}\n \n );\n}\n\nexport default App;\n"],"names":["TabNotification","newMessage","onResetMessage","intl","useIntl","originalTitle","useRef","document","title","current","useEffect","interval","clearInterval","hidden","messageNotification","formatMessage","id","description","defaultMessage","setInterval","propTypes","PropTypes","Button","React","Window","NotificationComponent","webmessengerApi","API","useWebmessenger","maximized","openWindow","closeWindow","hide","show","notification","createNotification","closeNotification","conversation","setConversation","setOperator","operator","integration","online","setOnline","unreadMessagesCount","incrementUnreadMessagesCount","resetUnreadMessagesCount","useBehaviors","disable","hideChat","triggerOpenWindowBehaviors","behaviorsIsInit","isInit","useWebSocket","websocket","connected","useState","setNewMessage","allowSendNotification","setAllowSendNotification","conversationNotification","setConversationNotification","soundNotification","setSoundNotification","storage","sessionData","sessionStorage","getItem","JSON","parse","getSessionStorage","emit","useSDK","useQuery","getOperator","_id","avatar","onSuccess","data","body","fingerprint","window","eK","entity","url","location","href","offline","root_cause","rootCause","fetch","process","method","headers","Accept","stringify","console","error","enabled","refetchOnWindowFocus","staleTime","operatorStatusIsSuccess","isSuccess","triggered","notificationConversation","useConversationMessagesQuery","messages","filter","m","author","type","length","text","content","message","markMessageAsReceived","catch","err","status","onNewMessage","deviceType","getElementById","play","Notification","decode","icon","origin","badge","newNotification","setTimeout","setItem","on","onConversationClosed","events","previousState","onConversationTransfer","conversationTransfer","to","omit","participants","operators","find","removeListener","name","face","picture","timeout","clearTimeout","sessionValue","isSoundNotificationEnabled","sound","audioElement","createElement","src","autoplay","preload","appendChild","trackElement","kind","load","pause","Suspense","fallback","onMinimze","onToggleSoundNotification","toggleSound","onClick"],"sourceRoot":""}