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,CACZC,qBAAmB,EACnBC,SAAUC,EAAAA,GAAkB/F,UAE5BT,EAAAA,EAAAA,KAAC2F,EAAG,UAKd,C","sources":["webpack://oricheckoutshoppingnotifications/../../src/constants-generated.ts","webpack://oricheckoutshoppingnotifications/../../src/logger.ts","webpack://oricheckoutshoppingnotifications/../../../src/types/TestId.ts","webpack://oricheckoutshoppingnotifications/../../../src/components/Notification.tsx","webpack://oricheckoutshoppingnotifications/../../../src/utils/getAlertSeverity.ts","webpack://oricheckoutshoppingnotifications/../../../src/components/NotificationHolder.tsx","webpack://oricheckoutshoppingnotifications/../../../src/utils/dispatchAcceptNotificationEvent.ts","webpack://oricheckoutshoppingnotifications/../../src/NotificationsController.tsx","webpack://oricheckoutshoppingnotifications/../../../src/types/NotificationAppearance.ts","webpack://oricheckoutshoppingnotifications/./src/utils/getFilteredNotifications.ts","webpack://oricheckoutshoppingnotifications/./src/hooks/useNotifications.ts","webpack://oricheckoutshoppingnotifications/./src/logger.ts","webpack://oricheckoutshoppingnotifications/./src/components/Notifications.tsx","webpack://oricheckoutshoppingnotifications/./src/App.tsx","webpack://oricheckoutshoppingnotifications/./src/appRender.tsx"],"sourcesContent":["/* istanbul ignore file */\n//\n// DO NOT EDIT!\n// This file was autogenerated by Eddie.\n// Changes may cause incorrect behavior and will be lost when the file is regenerated.\n//\n// Run `npx eddie update workspace` to regenerate.\n//\n\nexport const LIBRARY_NAME = 'checkout-notifications';\nexport const PACKAGE_NAME = '@ori/checkout-notifications';\nexport const TEAM_NAME = 'Checkout';\n\nexport const EMOTION_CACHE_KEY = `${LIBRARY_NAME}-emotion-cache-key`;\n","import { getDebugLogger } from '@ori/checkout-utils';\nimport { Logger } from '@ori/logger';\n\nimport { LIBRARY_NAME, PACKAGE_NAME, TEAM_NAME } from './constants';\n\nexport const mainLogger = new Logger(PACKAGE_NAME, { teamName: TEAM_NAME });\n\nexport const logDebug = getDebugLogger(LIBRARY_NAME);\n","export enum TestId {\n // Close notification button\n CloseNotificationButton = 'close-notification-button',\n // Alert wrapper for notification message\n NotificationMessage = 'notification-message',\n // Link inside notification message alert\n NotificationMessageLink = 'notification-message-link',\n}\n","import { IconButton } from '@ori-ui/components';\nimport { Clear } from '@ori-ui/icons';\nimport { Alert, Link, styled } from '@ori-ui/mui';\nimport useTestId from '@ori/testid-generator';\nimport { useCallback, useMemo, type FC } from 'react';\n\nimport type { NotificationMessage } from '../types';\nimport { TestId } from '../types';\nimport { getAlertSeverity } from '../utils';\n\nconst Root = styled(Alert)(({ theme }) => ({\n marginBottom: theme.spacing(2),\n}));\n\nexport interface NotificationProps {\n closeCallback: (id: string) => void;\n notificationMessage: NotificationMessage;\n}\n\nexport const Notification: FC = (props: NotificationProps) => {\n const { getTestIdProps } = useTestId();\n const { closeCallback, notificationMessage } = props;\n const { closeEnabled, closeLabel, id, linkText, linkUrl, type, text } = notificationMessage;\n const severity = getAlertSeverity(type);\n\n const handleCloseNotification = useCallback(() => {\n closeCallback(id);\n }, [closeCallback, id]);\n\n const closeButton = useMemo(() => {\n if (closeEnabled) {\n return (\n \n \n \n );\n }\n\n return null;\n }, [closeEnabled, closeLabel, getTestIdProps, handleCloseNotification]);\n\n return (\n \n {text}{' '}\n {linkText && linkUrl ? (\n \n {linkText}\n \n ) : null}\n \n );\n};\n","import { ShoppingNotificationType } from '@ori-events/basket-updated';\n\nexport const getAlertSeverity = (type: ShoppingNotificationType) => {\n switch (type) {\n case ShoppingNotificationType.Error:\n return 'error';\n case ShoppingNotificationType.Info:\n return 'info';\n case ShoppingNotificationType.Success:\n return 'success';\n case ShoppingNotificationType.Warning:\n case ShoppingNotificationType.Reminding:\n return 'warning';\n default:\n return 'info';\n }\n};\n","import { styled } from '@ori-ui/mui';\nimport { useCallback, type FC } from 'react';\n\nimport { logDebug } from '../logger';\nimport type { NotificationMessage } from '../types';\nimport { dispatchAcceptNotificationEvent } from '../utils';\nimport { Notification } from './Notification';\n\nconst Root = styled('div')(({ theme }) => ({\n paddingBottom: theme.spacing(2),\n [theme.breakpoints.down('sm')]: {\n paddingLeft: theme.spacing(3),\n paddingRight: theme.spacing(3),\n },\n}));\n\nexport interface NotificationHolderProps {\n readonly notificationMessages?: NotificationMessage[];\n}\n\nexport const NotificationHolder: FC = ({ notificationMessages }) => {\n logDebug(`NotificationHolder: `, notificationMessages);\n\n const dispatchAcceptNotification = useCallback((id: string) => {\n const reasonId = Number(id);\n if (reasonId) {\n logDebug(`Message ${id} triggered @ori-events/accept-notification.`);\n dispatchAcceptNotificationEvent(reasonId);\n }\n }, []);\n\n // if there are no records we should not render anything but that should be already caught on previous step\n if (typeof notificationMessages === 'undefined' || notificationMessages.length === 0) {\n logDebug('No more messages to display. Exiting ...');\n\n return null;\n }\n\n return (\n \n {notificationMessages.map((message) => (\n \n ))}\n \n );\n};\n","import type { Data } from '@ori-events/accept-notification';\nimport { Name } from '@ori-events/accept-notification';\n\nexport const dispatchAcceptNotificationEvent = (reasonId: number) => {\n const acceptNotificationEvent = new CustomEvent(Name, {\n detail: { reasonId },\n });\n window.dispatchEvent(acceptNotificationEvent);\n};\n","import { ErrorBoundary, LoggerProvider } from '@ori/logger';\nimport { Team, TestIdProvider } from '@ori/testid-generator';\nimport { StrictMode, Suspense, type FC } from 'react';\n\nimport { NotificationHolder } from './components';\nimport { LIBRARY_NAME } from './constants';\nimport { logDebug, mainLogger } from './logger';\nimport type { NotificationMessage } from './types';\n\nexport interface NotificationsProps {\n readonly notificationMessages?: NotificationMessage[];\n}\n\nexport const NotificationsController: FC = ({ notificationMessages }) => {\n logDebug(`Rendering NotificationsController ...`, '\\n\\tnotificationMessages: ', notificationMessages);\n\n // If there are no records we should not render anything\n if (notificationMessages === undefined || notificationMessages.length === 0) {\n logDebug('No notification messages to display. Exiting ...');\n\n return null;\n }\n\n return (\n \n \n \n \n \n \n \n \n \n \n \n );\n};\n","export enum NotificationAppearance {\n ShopppingBag = 1,\n Information = 2,\n Offers = 4,\n Delivery = 8,\n Payments = 16,\n Beauty = 32,\n Review = 64,\n Subscriptions = 128,\n All = 255,\n}\n","import { CheckoutStep } from '@ori-events/checkout-step-changed';\nimport type { NotificationMessage } from '@ori/checkout-notifications';\nimport { NotificationAppearance } from '@ori/checkout-notifications';\n\nexport const shoppingStepToNotificaitonAppearancesMap = new Map([\n [CheckoutStep.Basket, [NotificationAppearance.ShopppingBag, NotificationAppearance.All]],\n [CheckoutStep.Delivery, [NotificationAppearance.Delivery, NotificationAppearance.All]],\n [CheckoutStep.Offers, [NotificationAppearance.Offers, NotificationAppearance.All]],\n [CheckoutStep.Payment, [NotificationAppearance.Payments, NotificationAppearance.All]],\n [CheckoutStep.Review, [NotificationAppearance.Review, NotificationAppearance.All]],\n]);\n\nexport const getFilteredNotifications = (activeCheckoutStep: CheckoutStep, notifications: NotificationMessage[]) => {\n if (!notifications.length) {\n return [];\n }\n const notificationAppearances = shoppingStepToNotificaitonAppearancesMap.get(activeCheckoutStep);\n if (!notificationAppearances) {\n return [];\n }\n\n return notifications.filter((notification) => notificationAppearances.includes(notification.notificationAppearance));\n};\n","import { CheckoutStep, CheckoutStepChangedEvent, type Data } from '@ori-events/checkout-step-changed';\nimport { useWindowEvent } from '@ori/checkout-utils';\nimport { useShoppingContext } from '@ori/shopping-context';\nimport { useCallback, useState } from 'react';\n\nimport { getFilteredNotifications } from '../utils';\n\nexport const useNotifications = () => {\n const [activeCheckoutStep, setActiveCheckoutStep] = useState(CheckoutStep.Basket);\n\n const activeStepChangedHandler = useCallback(\n (event: CustomEvent) => setActiveCheckoutStep(event.detail.pageId),\n [],\n ) as EventListener;\n\n useWindowEvent(CheckoutStepChangedEvent, activeStepChangedHandler);\n\n const { isLoading, shoppingContext: { notifications: allNotifications = [] } = {} } = useShoppingContext();\n const notifications = getFilteredNotifications(activeCheckoutStep, allNotifications);\n const notificationMessages = isLoading ? undefined : notifications;\n\n return { activeCheckoutStep, isLoading, notificationMessages, notifications };\n};\n","import { getDebugLogger } from '@ori/checkout-utils';\nimport { Logger } from '@ori/logger';\n\nimport { APP_NAME, PACKAGE_NAME, TEAM_NAME } from './constants';\n\nexport const mainLogger = new Logger(PACKAGE_NAME, { teamName: TEAM_NAME });\n\nexport const logDebug = getDebugLogger(APP_NAME);\n","import { styled } from '@ori-ui/mui';\nimport { NotificationsController } from '@ori/checkout-notifications';\nimport { type FC } from 'react';\n\nimport { useNotifications } from '../hooks';\nimport { logDebug } from '../logger';\n\nconst NotificationWrapper = styled('div')({\n margin: '0 auto',\n maxWidth: 980,\n});\n\nexport const Notifications: FC = () => {\n const { activeCheckoutStep, notificationMessages } = useNotifications();\n\n logDebug('activeCheckoutStep', activeCheckoutStep);\n logDebug('Notifications', notificationMessages);\n\n if (typeof notificationMessages === 'undefined' || notificationMessages.length === 0) {\n logDebug('No notifications. Skipping rendering.');\n\n return null;\n }\n\n return (\n \n \n \n );\n};\n","import { ShoppingContextProvider } from '@ori/shopping-context';\nimport { Team, TestIdProvider } from '@ori/testid-generator';\nimport { type FC } from 'react';\n\nimport { Notifications } from './components';\nimport { APP_NAME } from './constants';\n\nexport const App: FC = () => (\n \n \n \n \n \n);\n","import { ThemeProvider } from '@ori-ui/mui';\nimport { ApplicationInsights, ErrorBoundary, getClientApplicationInsightsConfig, LoggerProvider } from '@ori/logger';\nimport { createRoot } from 'react-dom/client';\n\nimport { App } from './App';\nimport { APP_NAME, EMOTION_CACHE_KEY } from './constants';\nimport { logDebug, mainLogger } from './logger';\n\n/**\n * React app renderer that is used when app is used as a standalone app\n */\nexport async function render(rootElement: HTMLElement) {\n if (process.env.NODE_ENV !== 'production' && process.env.REACT_APP_USE_REQUESTLY === '1') {\n logDebug('USING REQUESTLY');\n }\n\n // Initialize Application Insights in production\n if (process.env.NODE_ENV === 'production') {\n ApplicationInsights.initialize(getClientApplicationInsightsConfig());\n }\n\n createRoot(rootElement).render(\n \n \n \n \n \n \n ,\n );\n}\n"],"names":["LIBRARY_NAME","mainLogger","Logger","teamName","logDebug","getDebugLogger","TestId","Root","styled","Alert","theme","marginBottom","spacing","Notification","props","getTestIdProps","useTestId","closeCallback","notificationMessage","closeEnabled","closeLabel","id","linkText","linkUrl","type","text","severity","ShoppingNotificationType","Error","Info","Success","Warning","Reminding","getAlertSeverity","handleCloseNotification","useCallback","closeButton","useMemo","_jsx","IconButton","variant","color","size","tabIndex","title","onClick","CloseNotificationButton","children","Clear","_jsxs","action","NotificationMessage","Link","href","NotificationMessageLink","paddingBottom","breakpoints","down","paddingLeft","paddingRight","NotificationHolder","notificationMessages","dispatchAcceptNotification","reasonId","Number","acceptNotificationEvent","CustomEvent","Name","detail","window","dispatchEvent","dispatchAcceptNotificationEvent","length","map","message","NotificationsController","undefined","StrictMode","LoggerProvider","logger","ErrorBoundary","areaName","Suspense","fallback","TestIdProvider","team","Team","Checkout","project","NotificationAppearance","shoppingStepToNotificaitonAppearancesMap","Map","CheckoutStep","Basket","ShopppingBag","All","Delivery","Offers","Payment","Payments","Review","useNotifications","activeCheckoutStep","setActiveCheckoutStep","useState","activeStepChangedHandler","event","pageId","useWindowEvent","CheckoutStepChangedEvent","isLoading","shoppingContext","notifications","allNotifications","useShoppingContext","getFilteredNotifications","notificationAppearances","get","filter","notification","includes","notificationAppearance","PACKAGE_NAME","TEAM_NAME","APP_NAME","NotificationWrapper","margin","maxWidth","Notifications","App","ShoppingContextProvider","parentComponentName","async","render","rootElement","ApplicationInsights","initialize","getClientApplicationInsightsConfig","createRoot","ThemeProvider","enableCacheProvider","cacheKey","EMOTION_CACHE_KEY"],"sourceRoot":""}