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UAAU,EACVC,MAAO,KACPC,UAAW,KAEb,CAEA,+BAAOG,CAAyBJ,GAE/B,MAAO,CAAED,UAAU,EACpB,CAEAM,iBAAAA,CAAkBL,EAAOC,GAExBJ,KAAKC,SAAS,CACbE,QACAC,cAIGJ,KAAKH,MAAMY,SACdT,KAAKH,MAAMY,QAAQN,EAAOC,GAI3BM,QAAQP,MAAM,iCAAkCA,EAAOC,EACxD,CAeAO,MAAAA,GACC,GAAIX,KAAKM,MAAMJ,SAAU,CAExB,GAAIF,KAAKH,MAAMe,SACd,MAAmC,mBAAxBZ,KAAKH,MAAMe,SACdZ,KAAKY,SAINZ,KAAKH,MAAMe,SAAS,CAC1BT,MAAOH,KAAKM,MAAMH,MAClBC,UAAWJ,KAAKM,MAAMF,UACtBS,mBAAoBb,KAAKa,qBAK3B,GAAIb,KAAKH,MAAMiB,kBAAmB,CACjC,MAAMC,EAAoBf,KAAKH,MAAMiB,kBACrC,OACC5C,EAAAA,cAAC6C,EAAiB,CACjBZ,MAAOH,KAAKM,MAAMH,MAClBC,UAAWJ,KAAKM,MAAMF,UACtBS,mBAAoBb,KAAKa,oBAG5B,CAEA,OAAO,IACR,CAEA,OAAOb,KAAKH,MAAMmB,QACnB,EAGDrC,EAAcsC,UAAY,CACzBD,SAAUE,IAAAA,KAAeC,WACzBP,SAAUM,IAAAA,KACVJ,kBAAmBI,IAAAA,YACnBT,QAASS,IAAAA,KACTb,QAASa,IAAAA,KACTE,UAAWF,IAAAA,MAGZvC,EAAc0C,aAAe,CAC5BD,WAAW,GAGZ,MAAAE,EAAA","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","webpack://@logos/commerceweb-frontend/./Scripts/site/components/error-boundary/index.jsx"],"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","import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\n\nclass ErrorBoundary extends Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\thasError: false,\n\t\t\terror: null,\n\t\t\terrorInfo: null,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError(error) {\n\t\t// Update state so the next render will show the fallback UI\n\t\treturn { hasError: true };\n\t}\n\n\tcomponentDidCatch(error, errorInfo) {\n\t\t// Store error details in state\n\t\tthis.setState({\n\t\t\terror,\n\t\t\terrorInfo,\n\t\t});\n\n\t\t// Notify parent component about the error\n\t\tif (this.props.onError) {\n\t\t\tthis.props.onError(error, errorInfo);\n\t\t}\n\n\t\t// Log error to console or external service\n\t\tconsole.error('ErrorBoundary caught an error:', error, errorInfo);\n\t}\n\n\tresetErrorBoundary = () => {\n\t\tthis.setState({\n\t\t\thasError: false,\n\t\t\terror: null,\n\t\t\terrorInfo: null,\n\t\t});\n\n\t\t// Notify parent that error was reset\n\t\tif (this.props.onReset) {\n\t\t\tthis.props.onReset();\n\t\t}\n\t};\n\n\trender() {\n\t\tif (this.state.hasError) {\n\t\t\t// If custom error template is provided, use it\n\t\t\tif (this.props.fallback) {\n\t\t\t\tif (typeof this.props.fallback !== 'function') {\n\t\t\t\t\treturn this.fallback;\n\t\t\t\t}\n\n\t\t\t\t// Pass error details and reset function to custom template\n\t\t\t\treturn this.props.fallback({\n\t\t\t\t\terror: this.state.error,\n\t\t\t\t\terrorInfo: this.state.errorInfo,\n\t\t\t\t\tresetErrorBoundary: this.resetErrorBoundary,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// If fallbackComponent is provided as a React component\n\t\t\tif (this.props.fallbackComponent) {\n\t\t\t\tconst FallbackComponent = this.props.fallbackComponent;\n\t\t\t\treturn (\n\t\t\t\t\t<FallbackComponent\n\t\t\t\t\t\terror={this.state.error}\n\t\t\t\t\t\terrorInfo={this.state.errorInfo}\n\t\t\t\t\t\tresetErrorBoundary={this.resetErrorBoundary}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.props.children;\n\t}\n}\n\nErrorBoundary.propTypes = {\n\tchildren: PropTypes.node.isRequired,\n\tfallback: PropTypes.func,\n\tfallbackComponent: PropTypes.elementType,\n\tonError: PropTypes.func,\n\tonReset: PropTypes.func,\n\tshowError: PropTypes.bool,\n};\n\nErrorBoundary.defaultProps = {\n\tshowError: false,\n};\n\nexport default ErrorBoundary;\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","Component","constructor","props","super","_defineProperty","this","setState","hasError","error","errorInfo","onReset","state","getDerivedStateFromError","componentDidCatch","onError","console","render","fallback","resetErrorBoundary","fallbackComponent","FallbackComponent","children","propTypes","PropTypes","isRequired","showError","defaultProps","__WEBPACK_DEFAULT_EXPORT__"],"sourceRoot":""}