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BrD,KAAKK,cAAciD,UACrCC,EAAeC,aAAY,WACzB,EAAKtD,YACPuD,cAAcF,GAEhB,IAAIG,EAAMpD,KAAKoD,MACXC,EAAWN,EAAgBK,EAC3BC,EAAW,IACbA,EAAW,EACXF,cAAcF,IAEhB,IAAIxC,EAAO6C,KAAKC,MAAMF,EAAW,OAC7BxC,EAAQyC,KAAKC,MAAOF,EAAW,MAAZ,MACnBpC,EAAUqC,KAAKC,MAAOF,EAAW,KAAZ,KACrBhC,EAAUiC,KAAKC,MAAOF,EAAW,IAAe,KAEhDG,EAAgB/C,EAAO,EAAI,EAAKgD,SAAShD,EAAM,OAAS,GAE5D+C,GAAiB,EAAKC,SAAS5C,EAAO,QAAU,EAAK4C,SAASxC,EAAS,UAAY,EAAKwC,SAASpC,EAAS,UAC1GwB,EAAcjB,UAAY4B,IAEzB,O,sBAGL,SAASE,EAAQC,GACf,IAAIC,EAAsB,GAAVF,EAAcC,EAAOA,EAAO,IAC5C,MAAO,iDAAP,OACwBD,EAAOG,WAAWC,OAAS,EAAI,IAAM,IAD7D,OACkEJ,EADlE,wDAEmChE,KAAKY,OAAOsD,GAF/C,wB,0BAMF,WACE,IAAIG,EAAoC,gBAAdrE,KAAKG,OAA2BH,KAAKsE,gBAC3DC,GAAkBvE,KAAKW,kBAAmBX,KAAKK,cAAciD,UAAYhD,KAAKoD,MAClF,OAAOW,GAAuBE,I,2BAGhC,WACE,IAAIC,EAAcC,EAAAA,EAAAA,UAAkBzE,KAAKQ,WACzC,MAAwB,gBAApBR,KAAKU,YACA8D,GAAexE,KAAKS,YAEtB+D,GAAexE,KAAKS,iB,sEAjGzBZ","sources":["webpack:///./resources/js/components/generic/reminder-popup.ts"],"sourcesContent":["import storage from \"../../utils/storage\";\n\nclass ReminderPopup {\n constructor(domRoot, params) {\n this.domRoot = domRoot;\n this.containerElement = domRoot;\n this.params = params;\n this.hasStopped = false;\n this.logic = params.logic;\n this.behavior = params.behavior;\n this.countdownDate = new Date(this.params.countdownClock);\n this.cookieKey = params.cookieKey;\n this.cookieValue = params.cookieValue;\n this.cookieEquiv = params.cookieEquiv;\n this.includeCountdown = params.includeCountdown == \"yes\";\n this.labels = {\n day: params.labelDay,\n days: params.labelDays,\n hour: params.labelHour,\n hours: params.labelHours,\n minute: params.labelMinute,\n minutes: params.labelMinutes,\n second: params.labelSecond,\n seconds: params.labelSeconds\n }\n this.init();\n }\n\n init() {\n if (this.shouldReveal()) {\n if (this.behavior == \"modal\" || this.behavior == \"toaster\") {\n let modalContainer = document.createElement('div');\n modalContainer.innerHTML = this.domRoot.innerHTML;\n document.body.appendChild(modalContainer);\n this.containerElement = modalContainer;\n setTimeout(() => {\n this.containerElement.firstElementChild.style.bottom = 0;\n }, 100);\n } else {\n this.domRoot.classList.remove('hide-all');\n }\n }\n let clickCloses = Array.from(this.containerElement.querySelectorAll('.close-reminder-modal'));\n clickCloses.forEach(closer => {\n closer.addEventListener('click', () => {\n this.containerElement.classList.add('hide-all');\n this.hasStopped = true;\n })\n })\n if (this.includeCountdown) {\n this.runClock();\n }\n }\n\n runClock() {\n const countdownArea = this.containerElement.querySelector('.countdown-area');\n const countDownTime = this.countdownDate.getTime();\n let timeInterval = setInterval(() => {\n if (this.hasStopped) {\n clearInterval(timeInterval);\n }\n let now = Date.now();\n let timeLeft = countDownTime - now;\n if (timeLeft < 1) {\n timeLeft = 0;\n clearInterval(timeInterval);\n }\n let days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));\n let hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));\n let minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));\n let seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);\n\n let countdownHTML = days > 0 ? this.timeUnit(days, 'day') : '';\n\n countdownHTML += this.timeUnit(hours, \"hour\") + this.timeUnit(minutes, \"minute\") + this.timeUnit(seconds, \"second\");\n countdownArea.innerHTML = countdownHTML;\n \n }, 1000);\n }\n\n timeUnit(amount, type) {\n let finalType = amount == 1 ? type : type + \"s\";\n return `
\n
${amount.toString().length < 2 ? '0' : ''}${amount}
\n
${this.labels[finalType]}
\n
`;\n }\n\n shouldReveal() {\n var isInTheCorrectGroup = this.logic == \"allaudiences\" || this.inCookieGroup();\n var shouldCountDown = this.includeCountdown ? this.countdownDate.getTime() > Date.now() : true;\n return isInTheCorrectGroup && shouldCountDown;\n }\n\n inCookieGroup() {\n let savedCookie = storage.getCookie(this.cookieKey);\n if (this.cookieEquiv == \"doesnotequal\") {\n return savedCookie != this.cookieValue;\n }\n return savedCookie == this.cookieValue;\n }\n}\n\nexport default ReminderPopup;"],"names":["ReminderPopup","domRoot","params","this","containerElement","hasStopped","logic","behavior","countdownDate","Date","countdownClock","cookieKey","cookieValue","cookieEquiv","includeCountdown","labels","day","labelDay","days","labelDays","hour","labelHour","hours","labelHours","minute","labelMinute","minutes","labelMinutes","second","labelSecond","seconds","labelSeconds","init","shouldReveal","modalContainer","document","createElement","innerHTML","body","appendChild","setTimeout","firstElementChild","style","bottom","classList","remove","Array","from","querySelectorAll","forEach","closer","addEventListener","add","runClock","countdownArea","querySelector","countDownTime","getTime","timeInterval","setInterval","clearInterval","now","timeLeft","Math","floor","countdownHTML","timeUnit","amount","type","finalType","toString","length","isInTheCorrectGroup","inCookieGroup","shouldCountDown","savedCookie","storage"],"sourceRoot":""}