{"version":3,"file":"cart-notifications.ef25967414092783302f.js?ssi=0","mappings":"gLAMA,MAAMA,EAAwBC,IAMxB,IALLC,EAAoBD,EAApBC,qBACAC,EAASF,EAATE,UAKA,MAAQC,GAAsBC,EAAAA,EAAAA,GAAqBH,GAA3CE,kBAER,OAAiC,IAA7BA,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,cAACP,EAAqB,CAACE,qBAAsBe,EAAAA,EAAyBC,SAAUf,UAAU,qCAIlEgB,IACzBZ,EAAAA,cAACS,EAAAA,EAAa,KACbT,EAAAA,cAACP,EAAqB,CAACE,qBAAsBe,EAAAA,EAAyBG,+DCnC5BC,KAC3CC,EAAAA,EAAAA,IACCC,OACAF,EAAiBJ,EAAAA,EAAyBG,KAAOH,EAAAA,EAAyBC,iBAIvChB,IAAmD,IAAAsB,EAAAC,EAOvF,MAAO,CAAErB,kBAFP,QAHqBoB,EACsB,QADtBC,GADSC,EAAAA,EAAAA,MAAxBC,oBAEoC,YAAC,IAAAF,OAAA,EAA5CA,EAA8CG,OAC7CnB,IAAY,IAAAoB,EAAA,OAAsB,QAAlBA,EAAApB,EAAaqB,aAAK,IAAAD,OAAA,EAAlBA,EAAoBE,YAAa7B,WACjD,IAAAsB,EAAAA,EAAI","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","_ref","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$","_scopedNotifications$2","useClientNotifications","scopedNotifications","filter","_notification$scope","scope","location"],"sourceRoot":""}