(()=>{"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 s in o)e.o(o,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:o[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=function(e,t,o){let s=`${e}=${t}; path=/`;if(o){const e=new Date;e.setTime(e.getTime()+60*o*60*1e3),s+=`; expires=${e.toUTCString()}`}document.cookie=s},o=(e,o)=>{let s=e.getAttribute("id");s=s.replace("popup-builder-","");const{entrAnimation:n,exitAnimation:r,animationDuration:i,type:p,preventScroll:c}=o||{},a=e.querySelector(".popup-builder-container");"inline"!==p&&r&&(a.classList.remove(`${n}`),a.classList.add(`${r}`),a.classList.add("reverse")),setTimeout(()=>{["popup","full-screen"].includes(p)&&c&&(document.body.style.overflow=""),a.classList.remove(`${r}`),a.classList.remove("reverse"),t(`pbb_closed_${s}`,"true",8760),e.remove()},1e3*("inline"!==p?i:0))},s=window.wp.apiFetch;var n=e.n(s);const r=async(e,o)=>{if(e&&!function(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift():null}(`pbb_conversion_${o}`)&&!window.parent.location.search.includes("preview=true")&&!window.parent.location.search.includes("subpage=templates")&&"https://wpmet.com/plugin/popupkit/templates/"!==window.parent.location.href){const e=Number(sessionStorage.getItem("pbb_logs"));await n()({path:"/pbb/v1/popup/logs",method:"PUT",data:{id:e,converted:!0,refferer:window.parent.document.referrer}}).then(e=>{"success"===e.status?t(`pbb_conversion_${o}`,"true",8760):console.error("Error updating conversion count:",e.message)})}},i=window.wp.hooks,p=e=>{const t=JSON.parse(e.getAttribute("data-settings"));return{popupID:e.getAttribute("id").replace("popup-builder-",""),popupAttributes:t}};var c;c="button",window.addEventListener("load",()=>{window[`__POPUPKIT_${c.toUpperCase()}_INIT`]||(window[`__POPUPKIT_${c.toUpperCase()}_INIT`]=!0,(()=>{const e=document.querySelectorAll(".pbb-btn");if(e.length)for(const s of e){const e=JSON.parse(s.getAttribute("data-settings")),{istrackConversion:n,clickEvent:c,closeCampaign:a,step:l,cookies:u}=e||{};(["closeCampaign","openUrl","step","cookieConsent"].includes(c)||n)&&s.addEventListener("click",d=>{d.preventDefault();const b=s.closest(".popup-builder-modal"),{popupID:m,popupAttributes:f}=p(b);if(r(n,m),"closeCampaign"===c&&a)o(b,f);else if("openUrl"===c){const e=s.getAttribute("href"),t=s.getAttribute("target");e&&window.top.open(e,t||"_self")}else if("step"===c&&l){let t=(0,i.applyFilters)("popupkit.steps.button","");t=t[m]||[];const o=b.querySelectorAll(".wp-block-popup-builder-block-step");for(const e of o)e.classList.contains("active")&&e.classList.remove("active");const s=t[parseInt(l)];s.classList.add("active"),b.querySelector(".popupkit-steps-inner").insertBefore(s,o[parseInt(e.step)])}else if("cookieConsent"===c&&u){const e=JSON.parse(u);for(const o of e){const{name:e,value:s,expires:n}=o;e&&s&&t(e,s,24*n)}o(b,f)}})}})())})})();