{"version":3,"file":"BetaConsentAutoSubmit.BcsSD9op.mjs","names":["React.useRef"],"sources":["https:/framerusercontent.com/modules/wwPwFT7cOqlNK5oJSL9Z/AY8cbTBbugY4MNQ84IGv/BetaConsentAutoSubmit.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Module-level guard (survives remounts)\nlet __consentFiredModule=false;function uuid4(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16));}export default function BetaConsentAutoSubmit({webhookUrl=\"\"}){const firedRef=React.useRef(false);React.useEffect(()=>{const sp=new URLSearchParams(window.location.search);const email=(sp.get(\"email\")||\"\").trim();if(!webhookUrl||!email){console.warn(\"[Consent] Missing webhookUrl or ?email=\");return;}const key=`consent_submitted_${email}`;if(sessionStorage.getItem(key)===\"1\"){console.log(\"[Consent] Skipping (sessionStorage guard)\");return;}if(window.__consentFiredGlobal){console.log(\"[Consent] Skipping (window global guard)\");return;}const nonce=uuid4();const submit=async reason=>{if(firedRef.current||__consentFiredModule||window.__consentFiredGlobal){console.log(\"[Consent] Already fired, skip:\",{reason});return;}firedRef.current=true;__consentFiredModule=true;window.__consentFiredGlobal=true;sessionStorage.setItem(key,\"1\");try{// Send in BOTH query string and form body (no-cors, simple request)\nconst url=new URL(webhookUrl);url.searchParams.set(\"email\",email);url.searchParams.set(\"nonce\",nonce);url.searchParams.set(\"source\",\"loops_email_click\");url.searchParams.set(\"submitted_at\",new Date().toISOString());const body=new URLSearchParams({email,nonce,agree:\"true\",source:\"loops_email_click\",submitted_at:new Date().toISOString(),ua:navigator.userAgent}).toString();console.log(\"[Consent] POST →\",url.toString(),\"reason:\",reason);await fetch(url.toString(),{method:\"POST\",mode:\"no-cors\",headers:{\"Content-Type\":\"application/x-www-form-urlencoded;charset=UTF-8\"},body});// Optional: remove email from URL to avoid accidental re-fires on refresh/back\ntry{const clean=new URL(window.location.href);clean.searchParams.delete(\"email\");window.history.replaceState({},\"\",clean.toString());}catch{}}catch(e){console.error(\"[Consent] POST failed:\",e);// If you want to allow retry on failure only, uncomment:\n// sessionStorage.removeItem(key);\n}};// Path 1: real user click survives handoff (best case)\nif(navigator.userActivation?.isActive){submit(\"userActivation\");return;}// Path 2: safe fallback — visible + focused for ~400ms\nlet visTimer=null;const tryVisibleFocused=()=>{const ok=document.visibilityState===\"visible\"&&document.hasFocus();if(!ok)return;// slight dwell to avoid previews\nif(visTimer)return;visTimer=setTimeout(()=>submit(\"visible+focused_dwell\"),400);};// Run checks right after paint and on state changes\nconst t=setTimeout(tryVisibleFocused,150);const onFocus=()=>tryVisibleFocused();const onVis=()=>tryVisibleFocused();window.addEventListener(\"focus\",onFocus);document.addEventListener(\"visibilitychange\",onVis);return()=>{clearTimeout(t);if(visTimer)clearTimeout(visTimer);window.removeEventListener(\"focus\",onFocus);document.removeEventListener(\"visibilitychange\",onVis);};},[webhookUrl]);// Tiny invisible box so Framer can place it\nreturn /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1,opacity:0,pointerEvents:\"none\"}});}addPropertyControls(BetaConsentAutoSubmit,{webhookUrl:{type:ControlType.String,title:\"Webhook URL\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BetaConsentAutoSubmit\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BetaConsentAutoSubmit.map"],"mappings":"uMAC+B,SAAS,GAAO,CAAC,MAAO,uCAA4B,QAAQ,SAAS,IAAI,EAAE,OAAO,gBAAgB,IAAI,WAAW,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,GAAG,CAAC,CAAE,SAAwB,EAAsB,CAAC,aAAW,IAAI,CAAC,IAAM,EAASA,EAAa,GAAM,CAShR,OATiR,MAAoB,CAAsD,IAAM,GA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