{"version":3,"file":"RecaptchaInput_2.69yZVdDM.mjs","names":["useRef","useState","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/WUHeNEuQn81UN0w5MBoy/4ly7iKIOcAwVuNLuQxOw/RecaptchaInput_2.js"],"sourcesContent":["// Create a reusable Framer code component for Google reCAPTCHA integration named RecaptchaFormGuard that can be dropped into any existing form, intercept submit in capture phase, block submit until verification, handle verification/expiration/error state, avoid duplicate scripts across instances, and expose siteKey + errorMessage controls.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useCallback,useEffect,useMemo,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function ensureRecaptchaScript(){if(typeof window===\"undefined\"||typeof document===\"undefined\"){return Promise.reject(new Error(\"reCAPTCHA is not available during SSR\"));}if(window.grecaptcha?.render){return Promise.resolve(window.grecaptcha);}if(window.__recaptchaScriptReadyPromise){return window.__recaptchaScriptReadyPromise;}window.__recaptchaOnLoadCbs=window.__recaptchaOnLoadCbs||[];window.__recaptchaOnloadHandler=()=>{const callbacks=window.__recaptchaOnLoadCbs||[];callbacks.forEach(callback=>callback());window.__recaptchaOnLoadCbs=[];};window.__recaptchaScriptReadyPromise=new Promise((resolve,reject)=>{const existingScript=document.querySelector(\"#google-recaptcha-script\");if(existingScript){window.__recaptchaOnLoadCbs?.push(()=>{if(window.grecaptcha?.render){resolve(window.grecaptcha);}else{reject(new Error(\"reCAPTCHA loaded but grecaptcha missing\"));}});let attempts=0;const maxAttempts=120;const interval=window.setInterval(()=>{attempts+=1;if(window.grecaptcha?.render){window.clearInterval(interval);const grecaptcha=window.grecaptcha;const callbacks=window.__recaptchaOnLoadCbs||[];callbacks.forEach(callback=>callback());window.__recaptchaOnLoadCbs=[];resolve(grecaptcha);}else if(attempts>=maxAttempts){window.clearInterval(interval);reject(new Error(\"Timed out waiting for reCAPTCHA\"));}},100);return;}window.__recaptchaOnLoadCbs?.push(()=>{if(window.grecaptcha?.render){resolve(window.grecaptcha);}else{reject(new Error(\"reCAPTCHA loaded but grecaptcha missing\"));}});const script=document.createElement(\"script\");script.id=\"google-recaptcha-script\";script.src=\"https://www.google.com/recaptcha/api.js?onload=__recaptchaOnloadHandler&render=explicit\";script.async=true;script.defer=true;script.onerror=()=>reject(new Error(\"Failed to load reCAPTCHA\"));document.head.appendChild(script);});return window.__recaptchaScriptReadyPromise;}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function RecaptchaFormGuard(props){const{siteKey,errorMessage,style}=props;const rootRef=useRef(null);const widgetContainerRef=useRef(null);const widgetIdRef=useRef(null);const[verified,setVerified]=useState(false);const[visibleError,setVisibleError]=useState(\"\");const isConfigured=useMemo(()=>siteKey.trim().length>0,[siteKey]);const focusAndScrollIntoView=useCallback(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const element=rootRef.current;if(!element)return;element.scrollIntoView({behavior:\"smooth\",block:\"center\"});if(typeof element.focus===\"function\"){element.focus();}},[]);useEffect(()=>{if(!isConfigured){startTransition(()=>{setVerified(false);});return;}if(typeof window===\"undefined\"||typeof document===\"undefined\")return;let mounted=true;const container=widgetContainerRef.current;if(!container)return;container.innerHTML=\"\";widgetIdRef.current=null;ensureRecaptchaScript().then(grecaptcha=>{if(!mounted||!widgetContainerRef.current)return;try{widgetIdRef.current=grecaptcha.render(widgetContainerRef.current,{sitekey:siteKey.trim(),callback:token=>{startTransition(()=>{const success=Boolean(token);setVerified(success);if(success)setVisibleError(\"\");});},\"expired-callback\":()=>{startTransition(()=>{setVerified(false);});},\"error-callback\":()=>{startTransition(()=>{setVerified(false);});}});}catch(error){startTransition(()=>{setVerified(false);});}}).catch(()=>{if(!mounted)return;startTransition(()=>{setVerified(false);});});return()=>{mounted=false;if(window.grecaptcha?.reset&&widgetIdRef.current!==null){try{window.grecaptcha.reset(widgetIdRef.current);}catch(error){// no-op\n}}widgetIdRef.current=null;};},[isConfigured,siteKey]);useEffect(()=>{const root=rootRef.current;if(!root)return;const parentForm=root.closest(\"form\");if(!parentForm)return;const onSubmitCapture=event=>{const shouldBlock=!isConfigured||!verified;if(!shouldBlock)return;event.preventDefault();event.stopPropagation();if(typeof event.stopImmediatePropagation===\"function\"){event.stopImmediatePropagation();}startTransition(()=>{setVisibleError(errorMessage);});focusAndScrollIntoView();};parentForm.addEventListener(\"submit\",onSubmitCapture,true);return()=>{parentForm.removeEventListener(\"submit\",onSubmitCapture,true);};},[isConfigured,verified,errorMessage,focusAndScrollIntoView]);return /*#__PURE__*/_jsxs(\"div\",{ref:rootRef,tabIndex:-1,style:{position:\"relative\",width:\"100%\",display:\"flex\",flexDirection:\"column\",alignItems:\"flex-start\",background:\"transparent\",outline:\"none\",...style},children:[isConfigured?/*#__PURE__*/_jsx(\"div\",{ref:widgetContainerRef,style:{width:\"100%\",minHeight:78},\"aria-label\":\"reCAPTCHA verification\"}):/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",minHeight:44,fontSize:12,lineHeight:1.4,color:\"#000000\",background:\"#F5F5F5\",border:\"1px dashed #EEEEEE\",borderRadius:8,padding:\"10px 12px\",boxSizing:\"border-box\"},children:\"Add your Google reCAPTCHA Site Key in the Site Key property to activate verification.\"}),visibleError?/*#__PURE__*/_jsx(\"div\",{role:\"alert\",style:{marginTop:6,color:\"#c62828\",fontSize:12,lineHeight:1.35},children:visibleError}):null]});}addPropertyControls(RecaptchaFormGuard,{siteKey:{type:ControlType.String,title:\"Site Key\",defaultValue:\"\",placeholder:\"Paste reCAPTCHA site key\"},errorMessage:{type:ControlType.String,title:\"Error\",defaultValue:\"Please complete the reCAPTCHA before submitting.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RecaptchaFormGuard\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}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