{"version":3,"file":"AntiBotProtection.CQjZ3jW7.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Kmtu708ed61C7ZPPaW7T/VhEZroyQ4YEB5ftpWZ1k/AntiBotProtection.js"],"sourcesContent":["// antiBotProtection.tsx\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";// ============================================================\n// CONFIGURATION\n// ============================================================\n// Minimum time (in seconds) a real human would take to fill the form.\n// If the form is submitted faster than this → it's a bot.\n// Example: 3 seconds is reasonable for a simple contact form.\nconst MIN_TIME_SECONDS=3;// Name for the honeypot field. Use something attractive that bots\n// would want to fill (like \"website\", \"url\", \"company_website\").\n// A real user will NEVER see this field, so the name doesn't matter\n// for UX — it only matters for tricking bots.\nconst HONEYPOT_FIELD_NAME=\"company_website\";// ============================================================\n// OVERRIDE — Apply this to the FRAME that wraps your form\n// ============================================================\nexport function withAntiBot(Component){return props=>{// Reference to the wrapper div so we can find the <form> inside\nconst formRef=useRef(null);// Store the timestamp when the page loaded\nconst loadTime=useRef(Date.now());useEffect(()=>{// Safety check: if the ref isn't attached yet, do nothing\nif(!formRef.current)return;// Find the actual <form> element inside the Framer component\nconst form=formRef.current.querySelector(\"form\");if(!form)return;// Record the exact moment the form becomes visible\n// We'll compare this against the submit time later\nloadTime.current=Date.now();// --------------------------------------------------------\n// HONEYPOT SETUP\n// --------------------------------------------------------\n// Create a fake input field that is:\n//   - Invisible to humans (via CSS)\n//   - Visible to bots (because bots read raw HTML)\n//\n// Important: We do NOT use \"display: none\" because smart\n// bots can detect that and skip it. Instead we make it\n// zero-sized and positioned off-screen.\n// --------------------------------------------------------\nconst honeypot=document.createElement(\"input\");honeypot.setAttribute(\"type\",\"text\");honeypot.setAttribute(\"name\",HONEYPOT_FIELD_NAME);honeypot.setAttribute(\"tabindex\",\"-1\")// Can't be reached with Tab key\n;honeypot.setAttribute(\"autocomplete\",\"off\")// Prevent browser autofill\n;honeypot.setAttribute(\"aria-hidden\",\"true\")// Hidden from screen readers\n;honeypot.style.cssText=`\n                opacity: 0;\n                position: absolute;\n                top: 0;\n                left: 0;\n                height: 0;\n                width: 0;\n                z-index: -1;\n                overflow: hidden;\n                pointer-events: none;\n            `;// Insert the honeypot as the first child of the form\nform.insertBefore(honeypot,form.firstChild);// --------------------------------------------------------\n// SUBMIT HANDLER\n// --------------------------------------------------------\n// This function runs BEFORE the form is actually submitted.\n// We use \"capture: true\" (the third parameter) so our handler\n// runs FIRST, before Framer's own submit handler.\n//\n// If we detect a bot → we block the submission entirely,\n// so the webhook never gets triggered.\n// --------------------------------------------------------\nconst handleSubmit=e=>{let isBot=false;let reason=\"\";// --- CHECK 1: Honeypot ---\n// If this field has any value, a bot filled it.\n// A real user can't see or interact with it.\nif(honeypot.value.trim()!==\"\"){isBot=true;reason=\"Honeypot field was filled\";}// --- CHECK 2: Time ---\n// Calculate how many seconds passed since the form loaded.\n// Example: if loadTime was 1000 and now is 1500,\n//          elapsed = (1500 - 1000) / 1000 = 0.5 seconds → too fast!\nconst elapsedSeconds=(Date.now()-loadTime.current)/1e3;if(elapsedSeconds<MIN_TIME_SECONDS){isBot=true;reason=`Form submitted too fast (${elapsedSeconds.toFixed(1)}s)`;}// --- DECISION ---\nif(isBot){// Block the form submission completely\ne.preventDefault()// Stop the default form behavior\n;e.stopPropagation()// Stop the event from bubbling up\n;e.stopImmediatePropagation()// Stop any other listeners on this element\n;// Log to console for debugging (only you can see this in DevTools)\n// console.log(`🤖 Bot blocked: ${reason}`)\nreturn false;}// If we reach here, the submission is legit — let it through!\n// console.log(\"✅ Legitimate submission — allowing\")\n};// Attach our handler to the form's submit event\n// The \"true\" makes it run in the CAPTURE phase (before everything else)\nform.addEventListener(\"submit\",handleSubmit,true);// --------------------------------------------------------\n// CLEANUP\n// --------------------------------------------------------\n// When the component unmounts (e.g., user navigates away),\n// remove the event listener and the honeypot field to avoid\n// memory leaks.\n// --------------------------------------------------------\nreturn()=>{form.removeEventListener(\"submit\",handleSubmit,true);honeypot.remove();};},[]);// Wrap the original Framer component in a div so we can\n// use the ref to find the <form> inside it\nreturn /*#__PURE__*/_jsx(\"div\",{ref:formRef,children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withAntiBot\":{\"type\":\"reactHoc\",\"name\":\"withAntiBot\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AntiBotProtection.map"],"mappings":"yHAcA,SAAgB,EAAY,EAAU,CAAC,MAAO,IAAO,CACrD,IAAM,EAAQA,EAAO,KAAK,CACpB,EAASA,EAAO,KAAK,KAAK,CAAC,CAkEjC,OAlEkC,MAAc,CAChD,GAAG,CAAC,EAAQ,QAAQ,OACpB,IAAM,EAAK,EAAQ,QAAQ,cAAc,OAAO,CAAC,GAAG,CAAC,EAAK,OAE1D,EAAS,QAAQ,KAAK,KAAK,CAW3B,IAAM,EAAS,SAAS,cAAc,QAAQ,CAAC,EAAS,aAAa,OAAO,OAAO,CAAC,EAAS,aAAa,OAAO,EAAoB,CAAC,EAAS,aAAa,WAAW,KAAK,CAC3K,EAAS,aAAa,eAAe,MAAM,CAC3C,EAAS,aAAa,cAAc,OAAO,CAC3C,EAAS,MAAM,QAAQ;;;;;;;;;;cAWxB,EAAK,aAAa,EAAS,EAAK,WAAW,CAU3C,IAAM,EAAa,GAAG,CAAC,IAAI,EAAM,GAG9B,EAAS,MAAM,MAAM,GAAG,KAAI,EAAM,IAIrC,IAAM,GAAgB,KAAK,KAAK,CAAC,EAAS,SAAS,IACnD,GAD0D,EAAe,IAAkB,EAAM,GAAY,GAA4B,EAAe,QAAQ,EAAE,IAC/J,EAMH,OALA,EAAE,gBAAgB,CACjB,EAAE,iBAAiB,CACnB,EAAE,0BAA0B,CAGtB,IAWP,OAPA,EAAK,iBAAiB,SAAS,EAAa,GAAK,KAOvC,CAAC,EAAK,oBAAoB,SAAS,EAAa,GAAK,CAAC,EAAS,QAAQ,GAAK,EAAE,CAAC,CAErE,EAAK,MAAM,CAAC,IAAI,EAAQ,SAAsB,EAAK,EAAU,CAAC,GAAG,EAAM,CAAC,CAAC,CAAC,uBAjFnD,IAAoC,CAMzE,EAAiB,EAIjB,EAAoB"}