{"version":3,"file":"cart-notifications.443a78382ba1d92b8dff.js?ssi=0","mappings":"4LAMA,MAAMA,EAAwBA,EAC7BC,uBACAC,gBAKA,MAAMC,kBAAEA,IAAsBC,EAAAA,EAAAA,GAAqBH,GAEnD,OAAiC,IAA7BE,EAAkBE,OACd,KAIPC,EAAAA,cAAA,OAAKJ,UAAWA,GACdC,EAAkBI,IAAIC,GACtBF,EAAAA,cAACG,EAAAA,GAA0B,CAC1BC,IAAKF,EAAaG,GAClBH,aAAcA,EACdI,SAAUA,KAAMC,EAAAA,EAAAA,IAAmBL,EAAaG,0CAOhBG,IACpCR,EAAAA,cAACS,EAAAA,EAAa,KACbT,EAAAA,cAACN,EAAqB,CAACC,qBAAsBe,EAAAA,EAAyBC,SAAUf,UAAU,qCAIlEgB,IACzBZ,EAAAA,cAACS,EAAAA,EAAa,KACbT,EAAAA,cAACN,EAAqB,CAACC,qBAAsBe,EAAAA,EAAyBG,+DCnC5BC,KAC3CC,EAAAA,EAAAA,IACCC,OACAF,EAAiBJ,EAAAA,EAAyBG,KAAOH,EAAAA,EAAyBC,iBAIvChB,IACpC,MAAMsB,oBAAEA,IAAwBC,EAAAA,EAAAA,MAMhC,MAAO,CAAErB,kBAJRoB,EAA2C,MAAGE,OAC7CjB,GAAgBA,EAAakB,OAAOC,WAAa1B,IAC7C","sources":["webpack://@logos/commerceweb-frontend/./Scripts/site/components/cart/notifications/index.tsx","webpack://@logos/commerceweb-frontend/./Scripts/site/components/cart/notifications/use-cart-notifications.tsx"],"sourcesContent":["import React from 'react';\nimport { AnimatedClientNotification, removeNotification } from '../../notifications/client-notifications';\nimport ErrorBoundary from '../../error-boundary';\nimport { CartNotificationLocation } from './types';\nimport { useCartNotifications } from './use-cart-notifications';\n\nconst CartNotificationsCore = ({\n\tnotificationLocation,\n\tclassName,\n}: {\n\tnotificationLocation: CartNotificationLocation;\n\tclassName?: string;\n}) => {\n\tconst { cartNotifications } = useCartNotifications(notificationLocation);\n\n\tif (cartNotifications.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className={className}>\n\t\t\t{cartNotifications.map(notification => (\n\t\t\t\t<AnimatedClientNotification\n\t\t\t\t\tkey={notification.id}\n\t\t\t\t\tnotification={notification}\n\t\t\t\t\tonRemove={() => removeNotification(notification.id)}\n\t\t\t\t/>\n\t\t\t))}\n\t\t</div>\n\t);\n};\n\nexport const MiniCartNotifications = () => (\n\t<ErrorBoundary>\n\t\t<CartNotificationsCore notificationLocation={CartNotificationLocation.MiniCart} className=\"pointer-events-auto\" />\n\t</ErrorBoundary>\n);\n\nconst CartNotifications = () => (\n\t<ErrorBoundary>\n\t\t<CartNotificationsCore notificationLocation={CartNotificationLocation.Page} />\n\t</ErrorBoundary>\n);\n\nexport default CartNotifications;\n","import { removeScopedNotifications, useClientNotifications } from '../../notifications/client-notifications';\nimport { CART_NOTIFICATION_SCOPE, CartNotificationLocation } from './types';\n\n// Clears notifications from the location that is no longer visible after a minicart toggle:\n// when the minicart opens, page-scoped notifications are stale; when it closes, minicart-scoped ones are.\nexport const clearStaleCartNotifications = (isMiniCartOpen: boolean) => {\n\tremoveScopedNotifications(\n\t\tCART_NOTIFICATION_SCOPE,\n\t\tisMiniCartOpen ? CartNotificationLocation.Page : CartNotificationLocation.MiniCart\n\t);\n};\n\nexport const useCartNotifications = (notificationLocation: CartNotificationLocation) => {\n\tconst { scopedNotifications } = useClientNotifications();\n\tconst cartNotifications =\n\t\tscopedNotifications[CART_NOTIFICATION_SCOPE]?.filter(\n\t\t\tnotification => notification.scope?.location === notificationLocation\n\t\t) ?? [];\n\n\treturn { cartNotifications };\n};\n"],"names":["CartNotificationsCore","notificationLocation","className","cartNotifications","useCartNotifications","length","React","map","notification","AnimatedClientNotification","key","id","onRemove","removeNotification","MiniCartNotifications","ErrorBoundary","CartNotificationLocation","MiniCart","CartNotifications","Page","isMiniCartOpen","removeScopedNotifications","CART_NOTIFICATION_SCOPE","scopedNotifications","useClientNotifications","filter","scope","location"],"sourceRoot":""}