import{b9 as j,j as i,T as v,cw as y,r as l,u as S,W as T,aD as C}from"./main-D6SjkSWq.js";function N({className:e}){const{label:o}=j();return i.jsxs("div",{className:e,children:[i.jsx("div",{className:o,children:i.jsx(v,{message:"Let us know you're human"})}),i.jsx("div",{id:"captcha-container",className:"h-[65px] w-[300px]"})]})}function O(e,o=!1){var h,w,f,g,k;const{isInsideSettingsPreview:m}=y(),p=l.useRef(!1),n=S(),r=((h=n.captcha)==null?void 0:h.provider)==="turnstile"?"turnstile":"recaptcha",a=r==="recaptcha"?(w=n.captcha)==null?void 0:w.g_site_key:(f=n.captcha)==null?void 0:f.t_site_key,s=!!(!m&&a&&((k=(g=n.captcha)==null?void 0:g.enable)!=null&&k[e])&&!o),[x,d]=l.useState(null);l.useEffect(()=>{let c=!1;if(s&&!c&&!p.current){if(c||p.current)return;const t=()=>{r==="recaptcha"?window.grecaptcha.render("captcha-container",{sitekey:a,action:e,callback:function(u){d(u)}}):turnstile.render("#captcha-container",{sitekey:a,action:e,callback:function(u){d(u)}})};window.turnstile||window.grecaptcha?setTimeout(()=>t()):window.captchaOnloadCallback=function(){t()},E(),p.current=!0}return()=>{var t;c=!0,window.turnstile&&((t=window.turnstile)==null||t.remove("#captcha-container"))}},[s,a]);const b=l.useCallback(()=>{var c,t;!a||!s||(r==="turnstile"?(c=window.turnstile)==null||c.reset("#captcha-container"):(t=window.grecaptcha)==null||t.reset())},[a,s,r]);return{captchaToken:x,captchaEnabled:s,resetCaptcha:b}}function E(){var e;return((e=T().settings.captcha)==null?void 0:e.provider)==="turnstile"?C.loadAsset("https://challenges.cloudflare.com/turnstile/v0/api.js?onload=captchaOnloadCallback&render=explicit",{id:"turnstile-js"}):C.loadAsset("https://www.google.com/recaptcha/api.js?onload=captchaOnloadCallback&render=explicit",{id:"recaptcha-js"})}export{N as C,O as u};
