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AAStB,GAASsB,EAAStB,GAAOqB,OAAO,CAACY,EAAIC,IAAOA,IAAOH,GAC7D,CACD,EACAI,QAAS,SAAUnC,EAAO4B,GACzB,GAAsB,oBAAXjB,OACV,MAAM,IAAIyB,MAAM,uFAMjB,GAJKZ,EAAQxB,KACZwB,EAAQxB,GAAS,IAElBwB,EAAQxB,GAAOqC,KAAKT,GACfN,EAAStB,GAAd,CAGA,IAAK,MAAM0B,KAAWJ,EAAStB,GAC9B,IACC0B,EAAQ,CAAEG,KAAM7B,GAAS4B,EAC1B,CAAE,MAAOU,GACRC,QAAQC,MAAM,+BAA+BxC,cAAmBsC,EACjE,CAEIf,IACJA,EAAQkB,WAAW,KAElBlB,OAAQmB,EACRlB,EAAU,CAAC,GACT,GAbJ,CAeD,GAGImB,WAAOlB,kBACXkB,WAAOlB,gBAAkBA,GAE1B/B,EAAOC,QAAUgD,WAAOlB,kBCvExB,MAAAmB,EAAA,IAGA,SAAAC,EAAAC,GAEA,MAAAC,EAAAH,EAAAE,GACA,QAAAJ,IAAAK,EACA,OAAAA,EAAApD,QAGA,MAAAD,EAAAkD,EAAAE,GAAA,CAGAnD,QAAA,IAOA,OAHAqD,EAAAF,GAAApD,EAAAA,EAAAC,QAAAkD,GAGAnD,EAAAC,OACA,ECtBgCF,CAAQ,OAEhBG","sources":["webpack://@logos/commerceweb-frontend/./Scripts/site/cart/utility/cartnotificationutility.js","webpack://@logos/commerceweb-frontend/./Scripts/site/cart/utility/eventaggregator.js","webpack://@logos/commerceweb-frontend/webpack/bootstrap","webpack://@logos/commerceweb-frontend/./Scripts/site/cart/entries/shoppingcart.js"],"sourcesContent":["'use strict';\n\nconst events = require('./eventaggregator.js');\n\nmodule.exports = {\n\tinit: function () {\n\t\tlet alreadyDisplayedNotification = false;\n\t\tlet previousNumberOfPayments = null;\n\n\t\tevents.on('cart:updated', (event, newCartData) => {\n\t\t\tconst notifications = newCartData.order.notifications ?? [];\n\t\t\tconst immediatePaymentPreventsBalanceDueFromSurpassingLimitNotification = notifications.find(\n\t\t\t\tn => n.code === 'ImmediatePaymentPreventsBalanceDueFromSurpassingLimit'\n\t\t\t);\n\t\t\tconst notificationBannerNotifications = document.querySelectorAll(\n\t\t\t\t'.js-cart-notification[js-notification-code=\"ImmediatePaymentPreventsBalanceDueFromSurpassingLimit\"]'\n\t\t\t);\n\n\t\t\tif (immediatePaymentPreventsBalanceDueFromSurpassingLimitNotification) {\n\t\t\t\t// Note that this creates a different style of notification than the _Notifications.cshtml notification that may be present on page load.\n\t\t\t\t// We could unify these styles, but the static notification (from _Notifications.cshtml) feels better-suited to a notification display for a page load,\n\t\t\t\t// and the dynamic sweep-in/sweep-out notification from window.NotificationUtility.notify feels better-suited to a notification display for an update after page load.\n\t\t\t\tif (\n\t\t\t\t\twindow.NotificationUtility &&\n\t\t\t\t\tnotificationBannerNotifications.length === 0 &&\n\t\t\t\t\t(!alreadyDisplayedNotification || newCartData.order.numberOfPayments !== previousNumberOfPayments)\n\t\t\t\t) {\n\t\t\t\t\twindow.NotificationUtility.notify(\n\t\t\t\t\t\timmediatePaymentPreventsBalanceDueFromSurpassingLimitNotification.message,\n\t\t\t\t\t\timmediatePaymentPreventsBalanceDueFromSurpassingLimitNotification.kind\n\t\t\t\t\t);\n\t\t\t\t\talreadyDisplayedNotification = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\talreadyDisplayedNotification = false;\n\n\t\t\t\tif (notificationBannerNotifications.length > 0) {\n\t\t\t\t\tnotificationBannerNotifications.forEach(notification => notification.remove());\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpreviousNumberOfPayments = newCartData.order.numberOfPayments;\n\n\t\t\tconst otherNotifications = notifications.filter(\n\t\t\t\tn => n.code !== 'ImmediatePaymentPreventsBalanceDueFromSurpassingLimit'\n\t\t\t);\n\n\t\t\totherNotifications.forEach(notification =>\n\t\t\t\twindow.NotificationUtility.notify(notification.message, notification.kind)\n\t\t\t);\n\t\t});\n\t},\n};\n","'use strict';\n\nconst handlers = {};\n// pending events allow a lot of subscribers to all come online during the same tick\nlet pending = {};\n// the timeout id to clear pending events at the end of a tick after an event has been triggered\nlet clear = undefined;\nconst eventAggregator = {\n\ton: function (events, handler) {\n\t\t// events can be one event (\"cart:updated\") or multiple separated by spaces (\"cart:validated cart:invalidated\")\n\t\t// this preserves the behavior of jQuery.on()\n\t\tfor (const event of events.split(' ')) {\n\t\t\tif (!handlers[event]) {\n\t\t\t\thandlers[event] = [];\n\t\t\t}\n\t\t\t// don't modify the handlers array or it'll cause iterator issues\n\t\t\thandlers[event] = [...handlers[event], handler];\n\t\t\t// pending events were fired on the same tick, but before you registered your handler\n\t\t\tif (!pending[event]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const data of pending[event]) {\n\t\t\t\thandler({ type: event }, data);\n\t\t\t}\n\t\t}\n\t},\n\toff: function (events, handler) {\n\t\t// events can be one event (\"cart:updated\") or multiple separated by spaces (\"cart:validated cart:invalidated\")\n\t\t// this preserves the behavior of jQuery.off()\n\t\tfor (const event of events.split(' ')) {\n\t\t\tif (!handlers[event]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst index = handlers[event].indexOf(handler);\n\t\t\tif (index === -1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// don't modify the handlers array or it'll cause iterator issues\n\t\t\thandlers[event] = handlers[event].filter((it, ix) => ix !== index);\n\t\t}\n\t},\n\ttrigger: function (event, data) {\n\t\tif (typeof window === 'undefined') {\n\t\t\tthrow new Error('Events cannot be triggered server-side. Wrap them in an event handler or useEffect.');\n\t\t}\n\t\tif (!pending[event]) {\n\t\t\tpending[event] = [];\n\t\t}\n\t\tpending[event].push(data);\n\t\tif (!handlers[event]) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const handler of handlers[event]) {\n\t\t\ttry {\n\t\t\t\thandler({ type: event }, data);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(`[eventAggregator] Error in \"${event}\" handler:`, e);\n\t\t\t}\n\t\t}\n\t\tif (!clear) {\n\t\t\tclear = setTimeout(() => {\n\t\t\t\t// on the next tick, clear the pending queue and allow us to restart the pending queue\n\t\t\t\tclear = undefined;\n\t\t\t\tpending = {};\n\t\t\t}, 0);\n\t\t}\n\t},\n};\n\nif (!global.eventAggregator) {\n\tglobal.eventAggregator = eventAggregator;\n}\nmodule.exports = global.eventAggregator;\n","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","const cartNotificationUtility = require('../utility/cartnotificationutility.js');\n\ncartNotificationUtility.init();\n"],"names":["events","require","module","exports","init","alreadyDisplayedNotification","previousNumberOfPayments","on","event","newCartData","notifications","order","immediatePaymentPreventsBalanceDueFromSurpassingLimitNotification","find","n","code","notificationBannerNotifications","document","querySelectorAll","window","NotificationUtility","length","numberOfPayments","notify","message","kind","forEach","notification","remove","filter","handlers","clear","pending","eventAggregator","handler","split","data","type","off","index","indexOf","it","ix","trigger","Error","push","e","console","error","setTimeout","undefined","global","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}