document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(".hts-contacts form").forEach(function(e){const t=e.querySelector(".contact-email"),a=e.querySelector(".privacy-policy-checkbox"),n=e.querySelector(".validate-message"),o=e.querySelector('input[type="submit"]');t&&t.addEventListener("input",()=>{var e;e=t.value,/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(e)?t.classList.remove("not-valid"):t.classList.add("not-valid")}),e.addEventListener("submit",function(c){if(c.preventDefault(),o.disabled)return;const s=e.querySelector(".contact-name").value,r=t?t.value:"",l=e.querySelector(".contact-message").value;let d=!1;a&&a.checked&&(d="on"),n&&(n.textContent=""),o.disabled=!0,o.classList.add("loading");const i=new FormData;i.append("action","submit_contactform"),i.append("name",s),i.append("email",r),i.append("message",l),i.append("privacy_policy",d),i.append("nonce",e.querySelector('input[name="contactform_nonce"]').value),fetch(hostinger_contact_form.ajax_url,{method:"POST",body:i}).then(e=>e.json()).then(t=>{o.disabled=!1,o.classList.remove("loading"),t.success?(n&&(n.textContent=t.data.message,n.style.color="#00b341"),e.reset()):n&&(n.textContent=t.data.message,n.style.color="#ff0000")}).catch(e=>{o.disabled=!1,o.classList.remove("loading"),n&&(n.textContent=hostinger_contact_form.error,n.style.color="#ff0000")})})})});