({init(t){"use strict";t&&document.addEventListener("DOMContentLoaded",(function(){document.addEventListener("click",(function(t){const e=t.target;if(!e.matches(".instawp-activate-now"))return;const n=e.getAttribute("data-slug");e.textContent="Activating plugin ...",t.preventDefault();const s={action:"install_activate_plugin",plugin:n,nonce:instawp_activate.nonce},a=new XMLHttpRequest;a.open("POST",ajaxurl,!0),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.onreadystatechange=function(){if(4===a.readyState)if(200===a.status){const t=JSON.parse(a.responseText);if(t.success)e.textContent=t.data.anchor_text,e.setAttribute("onclick","window.open('"+t.data.href+"', '_blank');"),e.setAttribute("data-originaltext",t.data.anchor_text),e.setAttribute("aria-label",t.data.anchor_text),e.setAttribute("target","_blank"),e.classList.remove("instawp-activate-now"),e.classList.add("string-locator-instawp-button","disabled");else{const e=t.data,n=document.createElement("div");n.className="notice notice-error is-dismissible",n.innerHTML="<p>Error installing and activating the plugin: "+e+'</p><button type="button" class="notice-dismiss" onclick="this.parentNode.remove();"></button>',document.querySelector(".wrap").insertAdjacentElement("afterbegin",n)}}else{const t=document.createElement("div");t.className="notice notice-error is-dismissible",t.innerHTML="<p>Error installing and activating the plugin: "+a.statusText+'</p><button type="button" class="notice-dismiss" onclick="this.parentNode.remove();"></button>',document.querySelector(".wrap").insertAdjacentElement("afterbegin",t)}};const i=Object.keys(s).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(s[t])})).join("&");a.send(i)})),document.addEventListener("click",(function(e){const n=e.target;n.matches(".sl-instawp-install-now")&&(n.classList.contains("instawp-activate-now")||n.classList.contains("updating-message")||n.classList.contains("button-disabled")||(e.preventDefault(),t.updates.shouldRequestFilesystemCredentials&&!t.updates.ajaxLocked&&(t.updates.requestFilesystemCredentials(e),document.addEventListener("credential-modal-cancel",(function(){const e=document.querySelector(".sl-instawp-install-now.updating-message");e.classList.remove("updating-message"),e.textContent=t.updates.l10n.installNow,t.a11y.speak(t.updates.l10n.updateCancel,"polite")}))),setTimeout((function(){n.textContent="Installing plugin..."}),200),t.updates.installPlugin({slug:n.getAttribute("data-slug"),success(){n.textContent="Activating plugin ...";const t={action:"install_activate_plugin",nonce:instawp_activate.nonce},e=new XMLHttpRequest;e.open("POST",ajaxurl,!0),e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status){const t=JSON.parse(e.responseText);if(t.success)n.textContent="Plugin installed",setTimeout((function(){n.textContent=t.data.anchor_text,n.setAttribute("onclick","window.open('"+t.data.href+"', '_blank');"),n.setAttribute("data-originaltext",t.data.anchor_text),n.setAttribute("aria-label",t.data.anchor_text),n.setAttribute("target","_blank"),n.classList.remove("sl-instawp-install-now","install-now","install-instawp-connect","updating-message"),n.classList.add("string-locator-instawp-button","disabled");const e=document.querySelector(".update-nag");e&&e.remove()}),3e3);else{const e=t.data,n=document.createElement("div");n.className="notice notice-error is-dismissible",n.innerHTML="<p>Error installing and activating the plugin: "+e+'</p><button type="button" class="notice-dismiss" onclick="this.parentNode.remove();"></button>',document.querySelector(".wrap").insertAdjacentElement("afterbegin",n)}}else{const t=document.createElement("div");t.className="notice notice-error is-dismissible",t.innerHTML="<p>Error installing the plugin: "+e.statusText+'</p><button type="button" class="notice-dismiss" onclick="this.parentNode.remove();"></button>',document.querySelector(".wrap").insertAdjacentElement("afterbegin",t)}};const s=Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&");e.send(s)},error(t){const e=document.createElement("div");e.className="notice notice-error is-dismissible",e.innerHTML="<p>Error installing the plugin: "+t+'</p><button type="button" class="notice-dismiss" onclick="this.parentNode.remove();"></button>',document.querySelector(".wrap").insertAdjacentElement("afterbegin",e)}})))}))}))}}).init(window.wp);