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GAAGiC,UAAUrC,KAAKsC,gBAAiB,EAAG,KAC3CL,EAAAA,EAAAA,mBAAuB,IAAIC,UAAU,UACrClC,KAAKuC,mBACT,GAAC,CAAA9B,IAAA,oBAAAC,MAED,WACIV,KAAKL,GAAG0B,UAAUE,OAAOvB,KAAKG,WAC9BH,KAAKL,GAAG0B,UAAUC,IAAItB,KAAKC,WAC3BgC,EAAAA,EAAAA,mBAAuB,IAAIC,UAAU,OACzC,GAAC,CAAAzB,IAAA,gBAAAC,MAED,WAEI,OAAoB,IADFV,KAAKI,GAAGe,UAAUnB,KAAKsC,gBAK7C,GAAC,CAAA7B,IAAA,gBAAAC,MAED,WACI,MAAO,OAASV,KAAKM,IACzB,IAAC,CA3E6B,E","sources":["webpack:///./html/wp-content/themes/ls/src/js/main/components/alertBanner/cookieNotificationController.js"],"sourcesContent":["import { gtm } from 'root/utils/tracking/googleTagManagerDeprecated';\nimport { CookieMonster } from 'root/utils/cookies/cookieMonster';\nimport { GeoMonster } from 'root/utils/cookies/geoMonster';\n\nexport default function CookieNotificationControllerInit(els) {\n els.forEach(el => {\n if (el) {\n const cn = new CookieNotificationController(el);\n return cn.load();\n }\n });\n}\n\nclass CookieNotificationController {\n constructor(el) {\n this.el = el;\n this.hideClass = 'js-cookie-notification-null';\n this.globalHideClass = 'gb-hide';\n this.showClass = 'js-cookie-notification-display';\n this.cm = new CookieMonster();\n this.name = 'cookie-notification';\n this.gm = new GeoMonster();\n }\n\n // if the OptanonActiveGroups.split(',').filter(el => el !== '') is equal to 4 that means all 4 categories are granted.\n // that means that the user is browsing from a location where OT is not enabled\n // that means we can show the LS cookie banner\n // except from California where the OT banner is optin by default\n\n // however there could be a possibility that the user has granted all 4 categories and has reloaded the page\n // in that case we should check for the OptanonAlertBoxClosed cookie if it is set.\n // If it is set then we know that we should not show the LS cookie banner\n\n displayLogicCallbackBasedOnConsent() {\n const isCalifornia =\n this.gm.getField('country_code') === 'US' &&\n this.gm.getField('state_code' === 'CA');\n const isAllCategoriesGranted =\n window.OptanonActiveGroups.split(',').filter(el => el !== '').length === 4;\n\n const isOTDisabled =\n isAllCategoriesGranted &&\n !isCalifornia &&\n !this.cm.getCookie('OptanonAlertBoxClosed');\n if (!this.hasBeenClosed() && isOTDisabled) {\n this.el.classList.add(this.showClass);\n this.el.classList.remove(this.hideClass);\n this.el.classList.remove(this.globalHideClass);\n this.eventListener();\n }\n }\n\n load() {\n this.el.classList.add(this.hideClass);\n window.registerCookieComplianceCallback({\n callback: this.displayLogicCallbackBasedOnConsent.bind(this),\n });\n }\n\n eventListener() {\n let button = document.querySelector('[data-alert=\"accept-cookie_notification\"]');\n button.addEventListener('click', this.closeHandler.bind(this));\n gtm.cookieNotification('').sendEvent('shown');\n }\n\n closeHandler(e) {\n e.preventDefault();\n this.cm.setCookie(this.getCookieName(), 1, 365);\n gtm.cookieNotification('').sendEvent('accept');\n this.postClosedActions();\n }\n\n postClosedActions() {\n this.el.classList.remove(this.showClass);\n this.el.classList.add(this.hideClass);\n gtm.cookieNotification('').sendEvent('exit');\n }\n\n hasBeenClosed() {\n let cookieValue = this.cm.getCookie(this.getCookieName());\n if (cookieValue === 1) {\n return true;\n }\n return false;\n }\n\n getCookieName() {\n return '_ls-' + this.name;\n }\n}\n"],"names":["CookieNotificationControllerInit","els","forEach","el","CookieNotificationController","load","_createClass","_classCallCheck","this","hideClass","globalHideClass","showClass","cm","CookieMonster","name","gm","GeoMonster","key","value","isCalifornia","getField","isOTDisabled","window","OptanonActiveGroups","split","filter","length","getCookie","hasBeenClosed","classList","add","remove","eventListener","registerCookieComplianceCallback","callback","displayLogicCallbackBasedOnConsent","bind","document","querySelector","addEventListener","closeHandler","gtm","sendEvent","e","preventDefault","setCookie","getCookieName","postClosedActions"],"sourceRoot":""}