!function(){"use strict";var e;e=()=>{const e=document.querySelectorAll(".wp-block-themeisle-blocks-popup");e.length&&e.forEach((e=>new class{canLock=!1;constructor(e){this.element=e,this.happened=!1,this.storageKey="otter-popup-dismiss";const{dismiss:t,anchor:n}=e.dataset;this.isItemDismissed()&&t&&!n&&!Boolean(window.themeisleGutenberg?.isPreview)||(this.canLock=Boolean(this.element.dataset.lockScrolling),this.isDisabled()||this.init())}init(){this.bindOpen(),this.bindClose()}isDisabled(){const{disableOn:e}=this.element.dataset;return"mobile"===e&&window.matchMedia("(max-width: 600px)").matches}openModal(){this.element.classList.add("active"),this.happened=!0,this.lockScrolling()}closeModal(){this.element.classList.remove("active"),this.dismissModal(),this.unlockScrolling()}dismissModal(){var e;const{dismiss:t,anchor:n}=this.element.dataset,{id:s}=this.element;if(!t||!s||n)return!1;const o=new Date,i=JSON.parse(null!==(e=localStorage.getItem(this.storageKey))&&void 0!==e?e:"[]")||[];if(i.some((e=>e.modalID===s)))return!1;const l=864e5*parseInt(t),a={expiry:o.getTime()+l,modalID:s};localStorage.setItem(this.storageKey,JSON.stringify([...i,a]))}isItemDismissed(){var e;const{id:t}=this.element,n=JSON.parse(null!==(e=localStorage.getItem(this.storageKey))&&void 0!==e?e:"[]")||[],s=n.filter((e=>e.modalID===t));if(0===s.length)return!1;const o=s[0],i=new Date;if(o.expiry>i.getTime())return!0;const l=n.filter((e=>e!==s[0]));return localStorage.setItem(this.storageKey,JSON.stringify(l)),!1}bindOpen(){const{open:e}=this.element.dataset;switch(e){case"onClick":this.bindAnchors();break;case"onScroll":this.bindOpenAfterScroll();break;case"onExit":this.bindExitIntent();break;default:this.bindOnLoad()}}bindAnchors(){const{anchor:e}=this.element.dataset;if(!e)return!1;document.querySelectorAll(`a[href='#${e}'], #${e}`).forEach((t=>{t.addEventListener("click",(t=>{t.target?.href===`#${e}`&&t.preventDefault(),this.openModal()}))}))}bindOpenAfterScroll(){window.document.addEventListener("scroll",(()=>{if(this.happened)return!1;const{offset:e}=this.element.dataset;if(parseInt(null!=e?e:"0")>=this.getScrolledPercent())return!1;this.openModal()}))}bindOnLoad(){const{time:e}=this.element.dataset;setTimeout((()=>{this.openModal()}),1e3*parseInt(null!=e?e:"0"))}bindExitIntent(){document.body.addEventListener("mouseleave",(e=>{if(this.happened)return!1;0>e.clientY&&this.openModal()}))}getScrolledPercent(){const e=document.documentElement,{body:t}=document,n="scrollTop",s="scrollHeight";return(e[n]||t[n])/((e[s]||t[s])-e.clientHeight)*100}bindClose(){this.bindCloseButtons(),this.bindAnchorClose(),this.bindOverlayClosing()}bindAnchorClose(){const{anchorclose:e}=this.element.dataset;if(!e)return!1;document.querySelectorAll(`a[href='#${e}'], #${e}`).forEach((t=>{t.addEventListener("click",(t=>{t.target?.href===`#${e}`&&t.preventDefault(),this.closeModal()}))}))}bindCloseButtons(){this.element.querySelectorAll(".otter-popup__modal_header .components-button").forEach((e=>{e.addEventListener("click",(()=>{this.closeModal()}))}))}bindOverlayClosing(){const{outside:e}=this.element.dataset;if(!e)return!1;const t=this.element.querySelector(".otter-popup__modal_wrap_overlay");t?.addEventListener("click",(()=>{this.closeModal()}))}lockScrolling(){this.canLock&&document.body.classList.add("o-lock-body")}unlockScrolling(){this.canLock&&document.body.classList.remove("o-lock-body")}}(e)))},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}();