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iCACjC6B,EAASvC,KAAKD,GAAGW,cAAc,+BACrC4B,EAASxB,iBAAiB,QAASd,KAAKmB,aAAaqB,KAAKxC,OACtDuC,GACAA,EAAOzB,iBAAiB,QAASd,KAAKiB,gBAAgBuB,KAAKxC,MAEnE,EAEAyC,KAAI,YAEKzC,KAAKC,GAAGsB,UAAUvB,KAAK0B,kBACxB1B,KAAKwB,oCAELxB,KAAKqC,4BACLrC,KAAKI,oBAEb,GAGJ,IAAMsC,EAA0B,SAAAC,GAC5B,OAAIA,EAAIC,OAAS,EACSC,MAAMC,KAAKH,GAAKI,MAAK,SAACC,EAAGC,GAC3C,OACmC,OAA9BA,EAAErB,QAAQsB,kBACoB,OAA9BF,EAAEpB,QAAQsB,gBAEnB,IACqB,GAElB,IACX,EAEe,SAASC,EAAYR,GAC5BD,EAAwBC,IACJ,IAAI7C,EAAsB4C,EAAwBC,IAC1DF,MAEpB,C","sources":["webpack:///./html/wp-content/themes/ls/src/js/main/components/alertBanner/alertBanner.js"],"sourcesContent":["import { isMobile } from 'root/utils/isMobile';\nimport { gtm } from 'root/utils/tracking/googleTagManagerDeprecated';\nimport { CookieMonster } from 'root/utils/cookies/cookieMonster';\n\nfunction AlertBannerController(el) {\n this.el = el;\n this.cm = new CookieMonster();\n}\n\nAlertBannerController.prototype = {\n postInsertActions() {\n this.el.classList.add('js-alert-banner-show');\n this.el.classList.remove('js-alert-banner-null');\n this.titleElement = document.querySelector('[data-alert-banner=title]');\n gtm.alertBanner(this.titleElement).sendEvent('shown');\n },\n\n postClosedActions() {\n this.el.classList.remove('js-alert-banner-show');\n this.el.classList.add('js-alert-banner-hide');\n this.el.addEventListener('animationend', e => {\n e.currentTarget.classList.add('js-alert-banner-null');\n });\n\n gtm.alertBanner(this.titleElement).sendEvent('exit');\n },\n\n ctaClickHandler() {\n this.setAlertBannerCookie();\n gtm.alertBanner(this.titleElement).sendEvent('click');\n },\n\n closeHandler(e) {\n e.preventDefault();\n this.setAlertBannerCookie();\n // hide the banner after the close button is clicked\n this.postClosedActions();\n },\n\n /**\n * @param cookieName\n * @returns {boolean}\n */\n hasCookie(cookieName) {\n return cookieName && this.cm.getCookie(cookieName) === 1;\n },\n\n /**\n * On desktop: always return true\n * On mobile: return true if the Cookie Notification banner cookie has been set (ie: closed)\n * On mobile it is the case, so that we don't show 2 banners at a time, due to the small size of the mobile screen\n * @returns {boolean}\n */\n isCookieNotificationSetOnMobile() {\n if (isMobile.hasMobileDeviceSize()) {\n return this.hasCookie('_ls-cookie_notification');\n }\n return true;\n },\n\n /**\n * @returns {string}\n */\n getCookieName() {\n return `_ls-alert-banner-${this.el.dataset.alertBannerCookie}`;\n },\n\n setAlertBannerCookie() {\n window.registerCookieComplianceCallback({\n callback: () =>\n !('alertBannerShowEvenIfDismissed' in this.el.dataset) &&\n this.cm.setCookie(this.getCookieName(), 1, 90),\n category: 'functional',\n isCallOptanonWrapper: true,\n });\n },\n\n addEventListenerToElement() {\n const closeBtn = this.el.querySelector(`[data-alert-banner=close-btn]`);\n const ctaBtn = this.el.querySelector(`[data-alert-banner=cta-btn]`);\n closeBtn.addEventListener('click', this.closeHandler.bind(this));\n if (ctaBtn) {\n ctaBtn.addEventListener('click', this.ctaClickHandler.bind(this));\n }\n },\n\n init() {\n if (\n !this.cm.getCookie(this.getCookieName()) &&\n this.isCookieNotificationSetOnMobile() // on mobile we'll show the banner only if the cookie notificaiton has been closed.\n ) {\n this.addEventListenerToElement();\n this.postInsertActions();\n }\n },\n};\n\nconst getBannerBasedOnRanking = els => {\n if (els.length > 0) {\n const sortedBanners = Array.from(els).sort((a, b) => {\n return (\n (b.dataset.alertBannerRank === 'on') -\n (a.dataset.alertBannerRank === 'on')\n );\n });\n return sortedBanners[0];\n }\n return null;\n};\n\nexport default function AlertBanner(els) {\n if (getBannerBasedOnRanking(els)) {\n const alertBanner = new AlertBannerController(getBannerBasedOnRanking(els));\n alertBanner.init();\n }\n}\n"],"names":["AlertBannerController","el","this","cm","CookieMonster","prototype","postInsertActions","classList","add","remove","titleElement","document","querySelector","gtm","sendEvent","postClosedActions","addEventListener","e","currentTarget","ctaClickHandler","setAlertBannerCookie","closeHandler","preventDefault","hasCookie","cookieName","getCookie","isCookieNotificationSetOnMobile","isMobile","getCookieName","concat","dataset","alertBannerCookie","_this","window","registerCookieComplianceCallback","callback","setCookie","category","isCallOptanonWrapper","addEventListenerToElement","closeBtn","ctaBtn","bind","init","getBannerBasedOnRanking","els","length","Array","from","sort","a","b","alertBannerRank","AlertBanner"],"sourceRoot":""}