(()=>{const e=document.querySelectorAll(".wp-block-nexa-form");e&&e.length>0&&e.forEach((e=>{const t=e.querySelector(".nexa-form"),s=t.getAttribute("id");var a=new Pristine(t);t&&t.addEventListener("submit",(n=>{if(n.preventDefault(),!a.validate())return;const o=new FormData;o.append("action","nexa_form_submit"),o.append("formId",s),o.append("nonce",nexaGLocalize?.nonce),t.querySelectorAll("[name]").forEach((e=>{const t=e?.getAttribute("name"),s=e?.value,a=e?.getAttribute("data-label")||t;o.append(`data[${t}][label]`,a),o.append(`data[${t}][value]`,s)}));const r=new XMLHttpRequest;r.open("POST",nexaGLocalize.ajax_url,!0),r.responseType="json",r.onload=()=>{if(200===r.status)if(r.response.success){const s=e.querySelector(".nx-success-message");s&&s.classList.add("show"),t.reset()}else{const t=e.querySelector(".nx-error-message");t&&t.classList.add("show")}else console.error("Error:",r.status,r.response)},r.send(o)}))}))})();