(()=>{"use strict";window.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".newsletter-container--root.front").forEach(e=>{e.querySelector(".newsletter-container-form--btn").addEventListener("click",t=>{!async function(e){const t=e.querySelector(".newsletter-container-form--email");if(!t)throw new Error("Email input not present");const r=[t,e.querySelector(".newsletter-container-form--name"),e.querySelector(".newsletter-container-form--phone"),e.querySelector(".newsletter-container-form--message")];for(const e of r)if(e&&"true"===e.dataset.required&&!e.value.trim())return void alert(e.dataset.notice);if(!function(e){return!!e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim())}(t.value))return alert("Invalid Email");let n=e.querySelector(".newsletter-container-form--message");n&&(n=n.value);let o=e.querySelector(".newsletter-container-form--name");o&&(o=o.value);let a=e.querySelector(".newsletter-container-form--phone");a&&(a=a.value);let l=t.value;e.setAttribute("data-loading","yes");try{await jQuery.ajax({type:"post",url:UCS_LOCAL.ajax_url,data:{action:"ultimate_coming_soon_newsletter_submit",email:l,message:n,name:o,phone:a,nonce:UCS_LOCAL.nonce}}),e.setAttribute("data-show_after_email_send_message","true")}catch(e){console.log(e),alert(e.responseJSON.message)}finally{e.removeAttribute("data-loading")}}(e)})})})})();