(($,t,e,c)=>{"use strict";const s=s=>{const a=t.createElement("div",{class:"tf_loader tf_abs_c"}),o=s.tfClass("themify_captcha_field")[0];if(o)if(o.classList.contains("h-captcha"))e.hcaptcha===c&&t.loadJs("https://js.hcaptcha.com/1/api.js?recaptchacompat=off",null,!1);else if(o.classList.contains("turnstile"))e.turnstile===c&&t.loadJs("https://challenges.cloudflare.com/turnstile/v0/api.js",null,!1).then((()=>{turnstile.render(o,{sitekey:o.dataset.sitekey})}));else if(e.grecaptcha===c){let e="https://www.google.com/recaptcha/api.js";"v3"===o.dataset.ver&&(e+="?render="+o.dataset.sitekey),t.loadJs(e,null,!1)}(s=>{t.is_builder_active||s.tfOn("submit",(async o=>{o.preventDefault();const i=o.currentTarget,n=i.parentElement;if(!i.classList.contains("processing")){n.appendChild(a),n.tfClass("tb_optin_error_message")[0].style.display="none",i.className+=" processing";const r=s.tfClass("themify_captcha_field")[0];try{if("v3"===r?.dataset.ver&&e.grecaptcha!==c){const t=await new Promise(((t,c)=>{e.grecaptcha.ready((()=>{e.grecaptcha.execute(r.dataset.sitekey,{action:"captcha"}).then(t).catch(c)}))})),c=document.createElement("input");c.type="hidden",c.name="g-recaptcha-response",c.value=t,i.prepend(c)}await(async c=>{const s=new FormData(c),o=c.querySelector('[name="g-recaptcha-response"]');null!==o&&s.set("contact-recaptcha",o.value);const i=await t.fetch(s);if(a.remove(),!i.success)throw c.parentElement.tfClass("tb_optin_error_message")[0].style.display="block",i.data.error;"s1"===c.dataset.success?e.location.href=i.data.redirect:$(c).fadeOut().closest(".module").find(".tb_optin_success_message").fadeIn()})(i)}catch(o){console.error(o)}i.classList.remove("processing"),"v2"===r?.dataset.ver&&e.grecaptcha?.reset()}}))})(s)};t.on("builder_load_module_partial",((e,c)=>{if(!0===c&&!e.classList.contains("module-optin"))return;const a=t.selectWithParent("tb_optin_form",e)[0];a&&t.requestIdleCallback((()=>{s(a)}),300)}))})(jQuery,Themify,window,void 0);