import{aa as v,j as i,T as b,f as y,r as l,g as S,X as T,W as C}from"./main-TIUJvpaR.js";function N({className:e}){const{label:o}=v();return i.jsxs("div",{className:e,children:[i.jsx("div",{className:o,children:i.jsx(b,{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,f,w,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"?(f=n.captcha)==null?void 0:f.g_site_key:(w=n.captcha)==null?void 0:w.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 j=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:j}}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};
