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C,EAAiBgD,SAAeR,EAAAA,EAAAA,KAAAF,EAAAA,SAAA,IAEpD,kBAA7BtC,EAAiB0B,SACvBc,EAAAA,EAAAA,KAAA,OACEC,UAAU,cACVG,wBAAyB,CAAEC,OAAQC,EAAAA,EAAcC,aAAa/C,EAAiB0B,SAAS,OAG1Fc,EAAAA,EAAAA,KAAAF,EAAAA,SAAA,CAAAC,SAAGvC,EAAiB0B,qBAUhCc,EAAAA,EAAAA,KAAAF,EAAAA,SAAA,GACD,C","sources":["components/ui/Notifications/NotificationsPanel/NotificationsPanel.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { Subscription } from 'rxjs';\nimport GeneralHelper from '../../../Helpers/GeneralHelper';\nimport './NotificationsPanel.scss';\nimport { NotificationsPanelMessage, useNotificationsPanelContext } from './NotificationsPanelContext';\n\nconst messageTimeout = 4_000;\nconst messageTimeout_Long = 6_000;\nconst messageTimeout_Tag = 1_000;\n\nconst NotificationPanel: React.FC = () => {\n const [displayedMessage, setDisplayedMessage] = useState(null);\n // A ref that mirrors the value of the state variable above, so we can use it in code to sync things up\n // without the BS of React and stale variables\n const displayedMessageRef = useRef(null);\n\n const [isHidingMessage, setIsHidingMessage] = useState(false);\n\n const { nextMessageToShow$, dismissCurrentMessage$, dismissCurrentMessage } = useNotificationsPanelContext();\n\n const queuedMessages = useRef([]);\n\n const hideMessagePromise = useRef(null);\n const onMessageHiddenPromise = useRef(null);\n\n useEffect(() => {\n const allSubscriptions = new Subscription();\n\n // NOTE: We have to define all of our functions that we use in the observable callback functions\n // inside this useEffect or else things become spaghetti real quick with React dependencies.\n const hideCurrentMessage = () => {\n setIsHidingMessage(true);\n\n if (hideMessagePromise.current) {\n clearTimeout(hideMessagePromise.current);\n }\n\n if (onMessageHiddenPromise.current) {\n clearTimeout(onMessageHiddenPromise.current);\n }\n\n onMessageHiddenPromise.current = setTimeout(() => {\n setDisplayedMessage(null);\n displayedMessageRef.current = null;\n\n setIsHidingMessage(false);\n\n displayNextMessage();\n }, 500);\n };\n\n const displayNextMessage = () => {\n if (!queuedMessages.current.length || displayedMessageRef.current) {\n return;\n }\n\n const nextMessageToDisplay = queuedMessages.current.shift();\n\n if (!nextMessageToDisplay) {\n return;\n }\n\n setDisplayedMessage(nextMessageToDisplay);\n displayedMessageRef.current = nextMessageToDisplay;\n\n if (hideMessagePromise.current) {\n clearTimeout(hideMessagePromise.current);\n }\n\n if (onMessageHiddenPromise.current) {\n clearTimeout(onMessageHiddenPromise.current);\n }\n\n let timeoutToUse =\n typeof nextMessageToDisplay.message === 'string'\n ? nextMessageToDisplay.message.length < 60\n ? messageTimeout\n : messageTimeout_Long\n : messageTimeout;\n\n if (nextMessageToDisplay.type === 'success-tag') {\n timeoutToUse = messageTimeout_Tag;\n }\n\n hideMessagePromise.current = setTimeout(() => {\n hideCurrentMessage();\n }, timeoutToUse);\n };\n\n // If a new message comes in\n allSubscriptions.add(\n nextMessageToShow$.subscribe((newMessage) => {\n queuedMessages.current.push(newMessage);\n\n if (!displayedMessageRef.current) {\n displayNextMessage();\n }\n })\n );\n\n // If a request to dismiss the current message early comes in\n allSubscriptions.add(\n dismissCurrentMessage$.subscribe(() => {\n if (hideMessagePromise.current) {\n clearTimeout(hideMessagePromise.current);\n }\n\n if (onMessageHiddenPromise.current) {\n clearTimeout(onMessageHiddenPromise.current);\n }\n\n hideMessagePromise.current = setTimeout(() => {\n hideCurrentMessage();\n });\n })\n );\n\n return () => {\n allSubscriptions.unsubscribe();\n };\n }, [dismissCurrentMessage$, displayedMessage, isHidingMessage, nextMessageToShow$]);\n\n const getCSSClassesForDisplayedMessage = (): string => {\n const returnValue: string[] = [];\n\n if (isHidingMessage) {\n returnValue.push('isHiding');\n }\n\n if (displayedMessage?.type) {\n returnValue.push(displayedMessage.type);\n }\n\n return returnValue.join(' ');\n };\n\n const isTagNotification = () => {\n if (!displayedMessage) {\n return false;\n }\n\n switch (displayedMessage.type) {\n case 'success-tag':\n return true;\n\n default:\n return false;\n }\n };\n\n return displayedMessage ? (\n <>\n {isTagNotification() ? (\n
\n
\n {typeof displayedMessage.message === 'string' ? (\n
\n ) : (\n <>{displayedMessage.message}\n )}\n
\n \n ) : (\n <>\n )}\n\n {!isTagNotification() ? (\n
\n
\n
\n {displayedMessage.title ?
{displayedMessage.title}
: <>}\n\n {typeof displayedMessage.message === 'string' ? (\n
\n ) : (\n <>{displayedMessage.message}\n )}\n
\n
\n \n ) : (\n <>\n )}\n \n ) : (\n <>\n );\n};\n\nexport default NotificationPanel;\n"],"names":["NotificationPanel","displayedMessage","setDisplayedMessage","useState","displayedMessageRef","useRef","isHidingMessage","setIsHidingMessage","nextMessageToShow$","dismissCurrentMessage$","dismissCurrentMessage","useNotificationsPanelContext","queuedMessages","hideMessagePromise","onMessageHiddenPromise","useEffect","allSubscriptions","Subscription","hideCurrentMessage","current","clearTimeout","setTimeout","displayNextMessage","length","nextMessageToDisplay","shift","timeoutToUse","message","type","add","subscribe","newMessage","push","unsubscribe","getCSSClassesForDisplayedMessage","returnValue","join","isTagNotification","_jsxs","_Fragment","children","_jsx","className","concat","onClick","dangerouslySetInnerHTML","__html","GeneralHelper","sanitizeHtml","title"],"sourceRoot":""}