import{j as t}from"./jsx-runtime-Byf2O5Qf.js";import{r as o,f as H,e as K}from"./chunk-HA7DTUK3-Cv5eIhAv.js";import{R as g}from"./r_error_alert-xF7JHxlP.js";import{R as _}from"./r_form-DETEbxVx.js";import{b as k}from"./rc_hidden-BV74MAa6.js";const j="6LdDCakUAAAAAEFI0Kyx_gg9t-G4r1mOWrIwFLd0",z=()=>(o.useEffect(()=>{const e=document.createElement("script");return e.src=`https://www.google.com/recaptcha/api.js?render=${j}`,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]),t.jsx("article",{children:t.jsxs("p",{className:"prose prose-sm text-left text-xs text-neutral-500 prose-a:underline prose-a:hover:text-azure-500",children:["This site is protected by reCAPTCHA and the Google"," ",t.jsx("a",{href:"https://policies.google.com/privacy",children:"Privacy Policy"})," and"," ",t.jsx("a",{href:"https://policies.google.com/terms",children:"Terms of Service"})," apply."]})})),R=()=>typeof window<"u"&&typeof window.grecaptcha<"u"&&typeof window.grecaptcha.execute<"u",$=e=>{const[r,a]=o.useState(R());o.useEffect(()=>{if(r)return;const s=setInterval(()=>{R()&&(a(!0),clearInterval(s))},1e3);return()=>clearInterval(s)},[r]);const c=o.useCallback(async s=>{if(r)return window.grecaptcha.execute(e,{action:s})},[e,r]);return{ready:r,execute:c}};function M({config:e,recaptchaAction:r,navigate:a,className:c,method:s,multipart:w,children:C,action:u,preventScrollReset:d,replace:p,reloadDocument:v,fetcherKey:E,hideToast:b=!1,errorPlacement:m="top"}){const{errors:l}=e,A=E??e.id,{execute:S}=$(j),T=H(),i=o.useRef(!1),I=K().some(n=>n.id.startsWith("routes/_store+")),P=b||I,f=k(e),F=r?async n=>{if(n.preventDefault(),!i.current){i.current=!0;try{const h=n.currentTarget,x=await S(r),y=h.querySelector('input[name="g-recaptcha-response"]');x&&y&&(y.value=x),T(h,{method:"POST",action:u,replace:p??!1,preventScrollReset:d})}finally{i.current=!1}}}:f.onSubmit;return t.jsxs(_,{className:c,method:s,multipart:w,navigate:a,action:u,preventScrollReset:d,replace:p,reloadDocument:v,fetcherKey:A,hideToast:P,...f,onSubmit:F,children:[r&&t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"hidden",name:"g-recaptcha-response"}),t.jsx("input",{type:"hidden",name:"reload-root-route",value:"true"})]}),m==="top"&&t.jsx(g,{errors:l,id:`${e.id}-error`}),C,m==="bottom"&&t.jsx(g,{errors:l,id:`${e.id}-error`})]})}export{M as R,z as a};