{"version":3,"file":"RecaptchaInput_2.D_AmMrwW.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/vo2YtLo90RqATHszaJEq/OOJO2iXvBwj7xhSJLh6O/RecaptchaInput_2.js"],"sourcesContent":["// RecaptchaInput: Framer reCAPTCHA input that is required by Framer Form. Supports both visible checkbox and invisible modes.\n//The error you’re seeing on the reCAPTCHA component onframer project canvas is normal — it won’t appear on the published domain.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * RecaptchaInput\n *\n * Framer reCAPTCHA input that is required by Framer Form. Hidden input is not readOnly so required validation works.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight fixed\n */export default function RecaptchaInput(props){const{siteKey,mode,size,badge,errorMessage,style}=props;const containerRef=useRef(null);const inputRef=useRef(null);const[verified,setVerified]=useState(false);const[error,setError]=useState(\"\");const widgetIdRef=useRef(null);const formRef=useRef(null);const isInitializedRef=useRef(false);const pendingSubmitRef=useRef(false);const handleSubmitRef=useRef(null);// Load reCAPTCHA script\nuseEffect(()=>{if(typeof window===\"undefined\"||!siteKey)return;const existingScript=document.querySelector(\"#google-recaptcha-script\");if(!existingScript){const script=document.createElement(\"script\");script.id=\"google-recaptcha-script\";script.src=`https://www.google.com/recaptcha/api.js?onload=onRecaptchaLoad&render=explicit`;script.async=true;script.defer=true;document.body.appendChild(script);}const initRecaptcha=()=>{if(!window.grecaptcha?.render||!containerRef.current||isInitializedRef.current)return;try{// Reset widget if it exists\nif(widgetIdRef.current!==null){try{window.grecaptcha.reset(widgetIdRef.current);}catch(e){// Widget doesn't exist, continue\n}}const widgetId=window.grecaptcha.render(containerRef.current,{sitekey:siteKey.trim(),size:mode===\"invisible\"?\"invisible\":size,badge:mode===\"invisible\"?badge:undefined,callback:token=>{console.log(\"✅ reCAPTCHA verification successful\",{token:token.substring(0,20)+\"...\"});startTransition(()=>{const valid=!!token;setVerified(valid);setError(valid?\"\":errorMessage);});// Auto-submit form after verification in invisible mode\nif(mode===\"invisible\"&&pendingSubmitRef.current&&formRef.current){console.log(\"🚀 Auto-submitting form after reCAPTCHA verification\");pendingSubmitRef.current=false;const form=formRef.current;const handler=handleSubmitRef.current;// Remove listener to prevent interception\nif(handler){form.removeEventListener(\"submit\",handler,true);}// Submit the form natively\nsetTimeout(()=>{if(form.requestSubmit){form.requestSubmit();}else{form.submit();}console.log(\"📤 Form submitted successfully\");// Re-attach listener after submission\nif(handler){setTimeout(()=>{form.addEventListener(\"submit\",handler,true);},100);}},50);}},\"expired-callback\":()=>{console.warn(\"⏰ reCAPTCHA token expired - user needs to verify again\");startTransition(()=>{setVerified(false);setError(errorMessage);});},\"error-callback\":()=>{console.error(\"❌ reCAPTCHA error - Invalid site key or configuration\");startTransition(()=>{setVerified(false);setError(\"Invalid site key or configuration.\");});}});widgetIdRef.current=widgetId;isInitializedRef.current=true;console.log(\"🔧 reCAPTCHA initialized\",{widgetId,mode,siteKey:siteKey.substring(0,10)+\"...\"});}catch(err){console.error(\"reCAPTCHA render error:\",err);startTransition(()=>setError(\"Failed to render reCAPTCHA.\"));}};window.onRecaptchaLoad=initRecaptcha;// If grecaptcha is already loaded, initialize immediately\nif(window.grecaptcha?.render){initRecaptcha();}return()=>{isInitializedRef.current=false;};},[siteKey,mode,size,badge,errorMessage]);// Trigger input + change events for Framer Form validation\nuseEffect(()=>{if(!inputRef.current)return;const input=inputRef.current;const event=new Event(\"input\",{bubbles:true});const change=new Event(\"change\",{bubbles:true});input.value=verified?\"1\":\"\";input.dispatchEvent(event);input.dispatchEvent(change);},[verified]);// Auto-trigger reCAPTCHA on form submit\nuseEffect(()=>{if(typeof window===\"undefined\"||mode!==\"invisible\")return;// Find parent form\nconst findForm=()=>{let element=containerRef.current?.parentElement;while(element){if(element.tagName===\"FORM\"){return element;}element=element.parentElement;}return null;};const form=findForm();if(!form)return;formRef.current=form;const handleSubmit=e=>{// If not verified, prevent submission and trigger reCAPTCHA\nif(!verified){console.log(\"🛑 Form submit intercepted - triggering reCAPTCHA verification\");e.preventDefault();e.stopPropagation();pendingSubmitRef.current=true;if(window.grecaptcha&&widgetIdRef.current!==null){try{console.log(\"🚀 Executing invisible reCAPTCHA...\");window.grecaptcha.execute(widgetIdRef.current);}catch(err){console.error(\"reCAPTCHA execute error:\",err);startTransition(()=>setError(\"Failed to execute reCAPTCHA.\"));pendingSubmitRef.current=false;}}}else{console.log(\"✅ reCAPTCHA already verified - allowing form submission\");}};handleSubmitRef.current=handleSubmit;form.addEventListener(\"submit\",handleSubmit,true);return()=>{form.removeEventListener(\"submit\",handleSubmit,true);};},[verified,mode]);if(RenderTarget.current()===RenderTarget.thumbnail)return null;return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",display:\"flex\",flexDirection:\"column\",alignItems:\"flex-start\",...style},children:[/*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{display:mode===\"invisible\"?\"none\":\"block\",minHeight:mode===\"invisible\"?0:size===\"compact\"?60:80,width:mode===\"invisible\"?0:size===\"compact\"?180:304}}),/*#__PURE__*/_jsx(\"input\",{ref:inputRef,type:\"text\",name:\"recaptcha\",value:verified?\"1\":\"\",style:{opacity:0,height:0,width:0,position:\"absolute\"},tabIndex:-1,\"aria-hidden\":\"true\",autoComplete:\"off\"})]});}addPropertyControls(RecaptchaInput,{siteKey:{type:ControlType.String,title:\"Site Key\",placeholder:\"Paste reCAPTCHA site key\"},mode:{type:ControlType.Enum,title:\"Mode\",options:[\"visible\",\"invisible\"],optionTitles:[\"Visible Checkbox\",\"Invisible\"],defaultValue:\"visible\",displaySegmentedControl:true},size:{type:ControlType.Enum,title:\"Size\",options:[\"normal\",\"compact\"],optionTitles:[\"Normal\",\"Compact\"],defaultValue:\"normal\",displaySegmentedControl:true,hidden:({mode})=>mode===\"invisible\"},badge:{type:ControlType.Enum,title:\"Badge Position\",options:[\"bottomright\",\"bottomleft\",\"inline\"],optionTitles:[\"Bottom Right\",\"Bottom Left\",\"Inline\"],defaultValue:\"bottomright\",hidden:({mode})=>mode===\"visible\"},errorMessage:{type:ControlType.String,title:\"Error Message\",defaultValue:\"Please verify you are not a robot.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RecaptchaInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RecaptchaInput_2.map"],"mappings":"4NASG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,UAAQ,OAAK,OAAK,QAAM,eAAa,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CAAM,CAAC,EAAS,GAAaC,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAO,EAAYD,EAAO,KAAK,CAAO,EAAQA,EAAO,KAAK,CAAO,EAAiBA,EAAO,GAAM,CAAO,EAAiBA,EAAO,GAAM,CAAO,EAAgBA,EAAO,KAAK,CAYmX,OAX7wB,MAAc,CAAC,GAAU,IAAS,QAAa,CAAC,EAAQ,OAA+E,GAAG,CAAtD,SAAS,cAAc,2BAA2B,CAAoB,CAAC,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,GAAG,0BAA0B,EAAO,IAAI,iFAAiF,EAAO,MAAM,GAAK,EAAO,MAAM,GAAK,SAAS,KAAK,YAAY,EAAO,CAAE,IAAM,MAAkB,CAAI,MAAC,EAAO,YAAY,QAAQ,CAAC,EAAa,SAAS,EAAiB,SAAe,GAAG,CAClgB,GAAG,EAAY,UAAU,KAAM,GAAG,CAAC,EAAO,WAAW,MAAM,EAAY,QAAQ,MAAU,EACvF,IAAM,EAAS,EAAO,WAAW,OAAO,EAAa,QAAQ,CAAC,QAAQ,EAAQ,M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