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,qBAGX,CAKAI,YAAAA,GACEpC,KAAKuB,WAAWc,oBAAoB,QAASrC,KAAK8B,eAE1B,MAApB9B,KAAK2B,aAAuB3B,KAAKwB,QACnCxB,KAAKK,cAAciC,eAAetC,KAAKgC,oBAE3C,CAKAO,OAAAA,GACEvC,KAAKoC,cACP,CAKAJ,oBAAsBA,KACpBhC,KAAKM,oBAAoBkC,KAAK,cAAexC,KAAKD,QAAQ,EAQ5D+B,cAAiBW,IACfzC,KAAK0C,mBAAmB,EAS1BA,iBAAAA,GACE1C,KAAKD,QAAQsB,UAAUC,OAAOjC,EAAYsD,QAAQ/C,QAE1B,MAApBI,KAAK2B,cACPiB,EAAAA,EAAAA,IAAU5C,KAAKyB,WAAY,KAGxBzB,KAAKD,QAAQsB,UAAUwB,SAASxD,EAAYsD,QAAQ/C,UACnDI,KAAKwB,QACPxB,KAAKgC,sBAEPhC,KAAK8C,cAAc9C,KAAKD,QAAS,UAErC,CASAU,WAAAA,GACMT,KAAKD,UACiB,MAApBC,KAAK2B,aACP3B,KAAKD,QAAQsB,UAAU0B,IAAI1D,EAAYsD,QAAQ/C,QAC/CI,KAAKgD,eAAehD,KAAKD,QAAS,UAE9BC,KAAKwB,QACPxB,KAAKgC,uBAGPhC,KAAK8C,cAAc9C,KAAKD,QAAS,UAGvC,CASAiD,cAAAA,CAAeC,EAAOC,GACN,WAAVA,IACFD,EAAME,aAAa,gBAAiB,QACpCF,EAAME,aAAa,cAAe,SAEtC,CAUAL,aAAAA,CAAcG,EAAOC,GACL,WAAVA,IACFD,EAAME,aAAa,gBAAiB,SACpCF,EAAME,aAAa,cAAe,QAEtC,E","sources":["webpack://@hero-digital/masonite/./src/components/modules/AlertBanner/AlertBanner.js"],"sourcesContent":["import { setCookie, getCookie } from '../../../js/utilities/utilities'\nimport Services from '../../../js/services'\n\n// Alert Banner Module:\n// displays important information above the global header\nexport default class AlertBanner {\n static SELECTORS = {\n COMPONENT: '[data-cmp-is=\"alert-banner\"]',\n BTN_CLOSE: '[data-cmp-alert-banner=\"button-close-alert\"]',\n HEADER: '[data-cmp-is=\"header\"]',\n HEADER_STICKY_CONTAINER: '.module-header__sticky',\n PAGE_ALERT_BANNER: '[data-page-alert-banner=\"true\"]'\n }\n\n static CLASSES = {\n ACTIVE: 'mod-alert-banner--active'\n }\n\n static VALUES = {\n COOKIE_NAME: 'msnt_alertBanner'\n }\n\n constructor (element) {\n this.element = element // ref to component element\n this.id = element?.id || '' // ref to component id\n this.services = Services.getInstance()\n\n this.ResizeService = this.services.ResizeService\n this.EventEmitterService = this.services.EventEmitterService\n\n this.cacheDom()\n this.attachEvents()\n this.cookieState()\n this.moveAlert()\n }\n\n /**\n * Move Alert in the dom to be in header\n */\n\n moveAlert () {\n // if page specific alert exists move it to be with the other alert in the header.\n if (this.element.getAttribute('data-page-alert-banner') === 'true') {\n const parent = document.querySelector(AlertBanner.SELECTORS.HEADER_STICKY_CONTAINER)\n const globalBanner = document.querySelector('[data-page-alert-banner=\"false\"]')\n\n // if the global alert is also showing\n if (globalBanner) {\n globalBanner.parentNode.insertBefore(this.element, globalBanner.nextSibling)\n } else {\n parent.prepend(this.element)\n }\n this.element.classList.remove('hidden')\n }\n }\n\n /**\n * Cache the dom refs needed for the component\n */\n cacheDom () {\n this.alertClose = this.element.querySelector(\n AlertBanner.SELECTORS.BTN_CLOSE\n )\n\n if (document.querySelector(AlertBanner.SELECTORS.HEADER)) {\n this.header = document.querySelector(AlertBanner.SELECTORS.HEADER)\n }\n\n this.cookieName = AlertBanner.VALUES.COOKIE_NAME + this.id;\n this.alertCookie = getCookie(this.cookieName)\n }\n\n /**\n * Attach component event listeners\n */\n attachEvents () {\n this.alertClose.addEventListener('click', this.toggleHandler)\n\n if (this.alertCookie == null && this.header) {\n // set up listener for header height\n this.ResizeService.addCallback(this.dispatchAlertUpdate)\n this.EventEmitterService.on(\n Services.EVENTS.MODULES_LOADED,\n this.dispatchAlertUpdate\n )\n }\n }\n\n /**\n * Detach component event listeners\n */\n detachEvents () {\n this.alertClose.removeEventListener('click', this.toggleHandler)\n\n if (this.alertCookie == null && this.header) {\n this.ResizeService.removeCallback(this.dispatchAlertUpdate)\n }\n }\n\n /**\n * Destroy the component and clean up event listeners\n */\n destroy () {\n this.detachEvents()\n }\n\n /**\n * Dispatches an event that the banner has been updated\n */\n dispatchAlertUpdate = () => {\n this.EventEmitterService.emit('alert event', this.element)\n }\n\n /**\n * Handler for 'click' and 'keydown' events.\n *\n * @param {Event} event A Javascript event.\n */\n toggleHandler = (event) => {\n this.toggleAlertBanner()\n }\n\n /**\n * toggleAlertBanner method: remove Alert Banner's existing active class\n * if there's no cookie set, set the cookie\n * and set aria attributes to hidden\n *\n */\n toggleAlertBanner () {\n this.element.classList.remove(AlertBanner.CLASSES.ACTIVE)\n\n if (this.alertCookie == null) {\n setCookie(this.cookieName, 'a')\n }\n\n if (!this.element.classList.contains(AlertBanner.CLASSES.ACTIVE)) {\n if (this.header) {\n this.dispatchAlertUpdate()\n }\n this.setAriaHidden(this.element, 'banner')\n }\n }\n\n /**\n * cookieState method: if the Alert Banner exists,\n * if there's no cookie set: set the cookie, if there's no cookie set,\n * add the active class to the alert banner, set aria visibility\n * else: set aria attributes to hidden\n *\n */\n cookieState () {\n if (this.element) {\n if (this.alertCookie == null) {\n this.element.classList.add(AlertBanner.CLASSES.ACTIVE)\n this.setAriaVisible(this.element, 'banner')\n\n if (this.header) {\n this.dispatchAlertUpdate()\n }\n } else {\n this.setAriaHidden(this.element, 'banner')\n }\n }\n }\n\n /**\n * setAriaVisible method: set aria visible\n * on close btn and alert banner\n *\n * @param {HTMLElement} $this target The DOM object that the event is triggered on.\n * @param {String} $type A string key to identify if it's the 'banner' else 'btn'.\n */\n setAriaVisible($this, $type) {\n if ($type === 'banner') {\n $this.setAttribute('aria-expanded', 'true')\n $this.setAttribute('aria-hidden', 'false')\n }\n }\n\n /**\n * setAriaHidden method: set aria hidden\n * on close btn and alert banner\n *\n * @param {HTMLElement} $this target The DOM object that the event is triggered on.\n * @param {String} $type A string key to identify if it's the 'banner' else 'btn'.\n *\n */\n setAriaHidden($this, $type) {\n if ($type === 'banner') {\n $this.setAttribute('aria-expanded', 'false')\n $this.setAttribute('aria-hidden', 'true')\n }\n }\n}\n"],"names":["AlertBanner","static","COMPONENT","BTN_CLOSE","HEADER","HEADER_STICKY_CONTAINER","PAGE_ALERT_BANNER","ACTIVE","COOKIE_NAME","constructor","element","this","id","services","Services","getInstance","ResizeService","EventEmitterService","cacheDom","attachEvents","cookieState","moveAlert","getAttribute","parent","document","querySelector","SELECTORS","globalBanner","parentNode","insertBefore","nextSibling","prepend","classList","remove","alertClose","header","cookieName","VALUES","alertCookie","getCookie","addEventListener","toggleHandler","addCallback","dispatchAlertUpdate","on","EVENTS","MODULES_LOADED","detachEvents","removeEventListener","removeCallback","destroy","emit","event","toggleAlertBanner","CLASSES","setCookie","contains","setAriaHidden","add","setAriaVisible","$this","$type","setAttribute"],"sourceRoot":""}