(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=function(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift():null},o=function(e,t,o){let i=`${e}=${t}; path=/`;if(o){const e=new Date;e.setTime(e.getTime()+60*o*60*1e3),i+=`; expires=${e.toUTCString()}`}document.cookie=i},i=window.wp.hooks,n=(e,t)=>{let i=e.getAttribute("id");i=i.replace("popup-builder-","");const{entrAnimation:n,exitAnimation:r,animationDuration:p,type:s}=t||{},u=e.querySelector(".popup-builder-container");u.classList.remove(`${n}`),u.classList.add(`${r}`),u.classList.add("reverse"),setTimeout(()=>{["popup","full-screen"].includes(s)&&t?.preventScroll&&(document.body.style.overflow=""),e.classList.remove("popup-builder-modal--open"),u.classList.remove(`${r}`),u.classList.remove("reverse"),o(`pbb_closed_${i}`,"true",8760),e.remove()},1e3*p)},r=window.wp.apiFetch;var p=e.n(r);const s=()=>window.parent.location.search.includes("preview=true")||window.parent.location.search.includes("subpage=templates"),u=async(e,i)=>{let r=e.getAttribute("id");r=r.replace("popup-builder-","");const u=e.querySelector(".popup-builder-container"),c=e.querySelector(".popup-builder-close"),l=window.getComputedStyle(e),{left:d,right:a,top:b,bottom:_}=l||{},{outsideClose:v,entrAnimation:m,animationDuration:w,type:y}=i||{};let f="display:flex;border:none;";e.style=f+"height:100%;width:100%;top:0;left:0;",e.classList.add("popup-builder-modal--open");const g=e=>"0px"===e?0:void 0;if(["popup","full-screen"].includes(y)?i?.preventScroll&&(document.body.style.overflow="hidden"):e.style=f+`bottom:${g(_)};left:${g(d)};right:${g(a)};top:${g(b)};`,m&&(u.classList.add(`${m}`),u.style.setProperty("--pbb-popup-animate-duration",`${w}s`),setTimeout(()=>{u.classList.remove(`${m}`)},1e3*w)),c&&c.addEventListener("click",()=>n(e,i)),v&&e.addEventListener("click",t=>{const o=e.querySelector(".popup-builder-content");o&&o.contains(t.target)||n(e,i)}),(c||v)&&document.addEventListener("keydown",function(t){"Escape"===t.key&&n(e,i)}),!s()){let e=parseInt(t(`pbb_viewed_${r}_count`));e=isNaN(e)?0:e,o(`pbb_viewed_${r}_count`,e+1,8760),p()({path:"/pbb/v1/popup/logs",method:"POST",data:{postId:Number(r)}}).then(e=>{if("success"===e.status){const{logId:t,userDetails:i,location:n}=e.data;o("pbb_user_info",JSON.stringify(i),8760),sessionStorage.setItem("pbb_logs",t),o("pbb_location",JSON.stringify(n),8760)}})}},c=e=>{const{popupID:r,popupAttributes:p}=(e=>{const t=JSON.parse(e.getAttribute("data-settings"));return{popupID:e.getAttribute("id").replace("popup-builder-",""),popupAttributes:t}})(e),{openTrigger:s,pageLoadDelay:c,scheduleDateTime:l,displayVisitor:d,adblockDetection:a}=p||{},b=()=>{"once-a-day"===d?.frequency?"true"!==t(`pbb_viewed_${r}`)&&(o(`pbb_viewed_${r}`,"true",24),u(e,p)):(0,i.doAction)("popup-builder.checkFrequency",e,r,p,t,o,u)},_=()=>{d?.convertionOff&&"true"===t(`pbb_conversion_${r}`)||("new"===d?.visitor?"true"!==t("pbb_new_visitor")&&"true"!==t("pbb_old_visitor")&&(o("pbb_new_visitor","true",24*d?.newDayCount),o("pbb_old_visitor","true",24*d?.returnDayCount),u(e,p)):"return"===d?.visitor?"true"!==t("pbb_old_visitor")?o("pbb_old_visitor","true",24*d?.returnDayCount):b():(b(),"true"!==t("pbb_old_visitor")&&o("pbb_old_visitor","true",24*d?.returnDayCount)))},v=()=>{"page-load"===s?setTimeout(()=>{_()},1e3*c):"click-count"===s?(()=>{let e=0;const t=()=>{e++,e>=p.clickCount&&(_(),document.removeEventListener("click",t))};document.addEventListener("click",t)})():(0,i.doAction)("popup-builder.checkOpenTrigger",e,p,u,_)},m=()=>{l?(0,i.doAction)("popup-builder.checkTimeAndShowPopup",e,p,v,n):v()};a&&"function"==typeof window.parent.adblockDetect?window.parent.adblockDetect(function(e){e&&m()}):m()};var l;l="popup-builder",window.addEventListener("load",()=>{window[`__POPUPKIT_${l.toUpperCase()}_INIT`]||(window[`__POPUPKIT_${l.toUpperCase()}_INIT`]=!0,(()=>{const e=document.querySelectorAll(".popup-builder-modal");if(e.length>0)for(const t of e)s()||c(t)})())})})();