!function(){"use strict";const e=()=>{const e=e=>{e.classList.add("show-spinner")},t=e=>{e.classList.remove("show-spinner")};document.addEventListener("click",(n=>{(n=>{let a=n.target.closest("button.wpmastertoolkit-single-optimization-btn"),o=n.target.closest("button.wpmastertoolkit-undo-single-optimization-btn"),i=n.target.closest("button.wpmastertoolkit-single-migrate-btn");a?((n,a)=>{n.preventDefault(),e(a);let o=new FormData;o.append("action","wpmtk_media_encoder_start_single"),o.append("nonce",WPMastertoolkit_media_encoder_wpmedia.nonce),o.append("attachment_id",n.target.dataset.attachmentId);let i={method:"POST",body:o,redirect:"follow"};fetch(WPMastertoolkit_media_encoder_wpmedia.ajaxUrl,i).then((e=>e.json())).then((e=>{if(t(a),e.success){let t=a.closest("td");t.innerHTML="",t.innerHTML=e.data}else{let t=a.nextElementSibling;t.innerHTML=e.data,t.classList.add("show")}})).catch((e=>{console.log("ERROR: ",e),t(a)}))})(n,a):o?((n,a)=>{n.preventDefault(),e(a);let o=a.nextElementSibling;o.innerHTML="";let i=new FormData;i.append("action","wpmtk_media_encoder_undo_single"),i.append("nonce",WPMastertoolkit_media_encoder_wpmedia.nonce),i.append("attachment_id",n.target.dataset.attachmentId);let d={method:"POST",body:i,redirect:"follow"};fetch(WPMastertoolkit_media_encoder_wpmedia.ajaxUrl,d).then((e=>e.json())).then((e=>{if(t(a),e.success){let t=a.closest("td");t.innerHTML="",t.innerHTML=e.data}else o.innerHTML=e.data,o.classList.add("show")})).catch((e=>{console.log("ERROR: ",e),t(a)}))})(n,o):i&&((n,a)=>{n.preventDefault(),e(a),a.nextElementSibling.innerHTML="";let o=new FormData;o.append("action","wpmtk_media_encoder_start_single_migration"),o.append("nonce",WPMastertoolkit_media_encoder_wpmedia.nonce),o.append("attachment_id",n.target.dataset.attachmentId);let i={method:"POST",body:o,redirect:"follow"};fetch(WPMastertoolkit_media_encoder_wpmedia.ajaxUrl,i).then((e=>e.json())).then((e=>{if(t(a),e.success){let t=a.closest("td");t.innerHTML="",t.innerHTML=e.data}else{let t=a.nextElementSibling;t.innerHTML=e.data,t.classList.add("show")}})).catch((e=>{console.log("ERROR: ",e),t(a)}))})(n,i)})(n)}))};document.addEventListener("DOMContentLoaded",(()=>e()))}();