(()=>{"use strict";const e=window.wp.i18n,t={unclear_how_to_use:["ea11y_text_field_unclear","ea11y_unclear_details"],switched_solution:["ea11y_text_field_switched","ea11y_switched_details"],other:["ea11y_text_field_other","ea11y_other_details"]};class i{constructor(){this.deactivationLink=document.getElementById("deactivate-pojo-accessibility"),this.deactivationLink&&(this.originalDeactivationLink=this.deactivationLink.getAttribute("href"),this.init())}modal(e,t,i){window.tb_show?.(e,t),setTimeout(()=>document.getElementById("TB_window")?.classList.add(i),5)}resetModal(){this.hideFields(),document.querySelectorAll('input[name="ea11y_deactivation_reason"]').forEach(e=>{e.checked=!1})}hideFields(){document.querySelectorAll(".ea11y-feedback-text-field").forEach(e=>e.style.display="none")}toggleField(e){this.hideFields();const i=t[e]?.[0];i&&(document.getElementById(i).style.display="block")}handleOptionClick(e){const t=e.target.closest(".ea11y-feedback-option");if(!t||e.target.closest(".ea11y-feedback-text-field"))return;const i=t.querySelector('input[type="radio"][name="ea11y_deactivation_reason"]');i&&(i.checked=!0,this.toggleField(i.value))}sendRequest(e,t){fetch(window?.ea11yDeactivationFeedback?.ajaxurl||"",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(e)}).finally(t)}handleSubmit(){const e=document.querySelector('input[name="ea11y_deactivation_reason"]:checked')?.value,i=t[e]?.[1],a=i&&document.getElementById(i)?.value||"";e?this.sendRequest({action:"ea11y_deactivation_feedback",reason:e,additional_data:a,nonce:window?.ea11yDeactivationFeedback?.nonce||""},()=>this.deactivate()):this.deactivate()}deactivate(){window.tb_remove?.(),window.location.href=this.originalDeactivationLink}init(){this.deactivationLink.addEventListener("click",t=>{t.preventDefault(),this.resetModal(),this.modal((0,e.__)("Quick feedback","pojo-accessibility"),"#TB_inline?width=600&height=auto&inlineId=ea11y-deactivation-modal","ea11y-feedback-thickbox")}),document.addEventListener("change",e=>{"ea11y_deactivation_reason"===e.target?.name&&this.toggleField(e.target.value)}),document.addEventListener("click",e=>"ea11y-submit-deactivate"===e.target?.id?(e.preventDefault(),void this.handleSubmit()):"ea11y-skip-deactivate"===e.target?.id?(e.preventDefault(),void this.deactivate()):void this.handleOptionClick(e))}}document.addEventListener("DOMContentLoaded",()=>new i)})();