(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.jQuery;var n=e.n(t);function s(e,t,s,a=!1){const c=n()(`<div class="notice notice-${t} is-dismissible" />`);c.html('<div class="py-3">'+e+"</div>"),s.after(c),a&&setTimeout(()=>{c.fadeOut(500,()=>{c.remove()})},3e3),n()(document).trigger("wp-notice-added")}n()(()=>{n()(document).on("click","#dismiss-welcome i",function(){n().ajax(window.ajaxurl,{method:"POST",data:{action:"advads_dismiss_welcome"},success(){n()("#welcome").remove()}})}),document.querySelectorAll(".advads-multiple-subscribe_button").forEach(e=>{e.addEventListener("click",function(){const t=e.closest(".advads-multiple-subscribe"),n=Array.from(t.querySelectorAll('input[name="advads-multiple-subscribe"]:checked')).map(function(e){return e.value});if(0===n.length)return;const s=document.createElement("span");s.className="spinner advads-spinner",e.insertAdjacentElement("afterend",s);const a=new FormData;a.append("action","advads-multiple-subscribe"),a.append("groups",JSON.stringify(n)),a.append("nonce",advadsglobal.ajax_nonce),fetch(ajaxurl,{method:"POST",body:a}).then(e=>e.json()).then(n=>{e.style.display="none";const s=document.createElement("p");s.innerHTML=n.data.message,t.innerHTML="",t.appendChild(s),t.classList.add("notice-success","notice")}).catch(e=>{const n=document.createElement("p");n.innerHTML=e.responseJSON?.data?.message||"An error occurred",t.innerHTML="",t.appendChild(n),t.classList.add("notice-error","notice")})})}),n()("#advads-overview").on("click",".notice-dismiss",function(e){e.preventDefault();const t=n()(this).parent();t.fadeOut(500,function(){t.remove()})}),function(){const e=document.getElementById("advads_overview_addons");e&&e.addEventListener("click",e=>{const t=e.target;if("a"===t.tagName.toLowerCase()&&t.classList.contains("disabled"))e.preventDefault();else if(t.classList.contains("button")&&t.classList.contains("subscribe")&&(e.preventDefault(),t.disabled=!0,t.classList.add("disabled"),wp.ajax.post("advads_newsletter",{nonce:t.dataset.nonce}).done(function(e){e&&(t.closest(".item-details").querySelector(".description").innerHTML=`<p style="font-weight: 600;">${e}</p>`)}).fail(function(e){try{t.closest(".item-details").querySelector(".description").innerHTML=`<p style="font-weight: 600;">${e.responseJSON.data.message}</p>`}catch(e){}})),t.classList.contains("button")&&t.classList.contains("installed")){const n="#activate-aaplugin_",s=t.href?t.href:"";if(-1!==s.indexOf(n)){e.preventDefault();const n=s.split("_");((e,t,n,s)=>{s.classList.add("disabled");const a=e.substring(e.indexOf("/")+1,e.indexOf("."));wp.ajax.post("advads_activate_addon",{_ajax_nonce:n,plugin:e,slug:a,name:t}).done(function(){s.className="button active disabled",s.innerText=window.advadstxt.active;const e=document.createElement("i");e.className="dashicons",e.style.cssText='content:"\\f147"',s.insertBefore(e,s.firstChild)}).fail(function(e){void 0!==e.errorMessage&&(s.closest(".cta").parentNode.querySelector(".description").innerText=e.errorMessage)})})(n[2],decodeURIComponent(n[3]),n[1],t)}}})}(),n()(document).on("click",".js-btn-backup-adstxt",function(){const e=n()(this),t=e.closest(".notice");e.prop("disabled",!0),e.html(e.data("loading")),n().ajax({url:advancedAds.endpoints.ajaxUrl,method:"POST",data:{action:"pubguru_backup_ads_txt",security:e.data("security")}}).always(()=>{e.prop("disabled",!1),e.html(e.data("text"))}).done(e=>{e.success?(s(e.data,"success",t,!0),t.remove()):(s(e.data,"error",t),t.remove())})})})})();