{"version":3,"file":"Form_Filter.CUP6rmRI.mjs","names":[],"sources":["https:/framerusercontent.com/modules/oJkSHVLXPUD8qV6S3EO1/Ezt563Oqm4N2MnfA7rSk/Form_Filter.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";// ─── Config ───────────────────────────────────────────────────────────────────\nconst BLOCKED_DOMAINS=[\"gmail.com\",\"yahoo.com\"];const MAX_DOTS_BEFORE_AT=2;// Fields to run gibberish detection on (matched against name/placeholder/id)\nconst TEXT_FIELD_KEYWORDS=[\"name\",\"company\",\"position\",\"title\",\"organisation\",\"organization\"];// ─── Email Validation ─────────────────────────────────────────────────────────\nfunction validateEmail(email){const trimmed=email.trim().toLowerCase();const atIndex=trimmed.lastIndexOf(\"@\");if(atIndex===-1)return{valid:false,reason:\"Invalid email address.\"};const localPart=trimmed.substring(0,atIndex);const domain=trimmed.substring(atIndex+1);if(BLOCKED_DOMAINS.includes(domain)){return{valid:false,reason:`Email addresses from @${domain} are not accepted. Please use your business email.`};}const dotCount=(localPart.match(/\\./g)||[]).length;if(dotCount>MAX_DOTS_BEFORE_AT){return{valid:false,reason:\"The part before the @ contains too many dots. Please use a valid business email.\"};}return{valid:true};}// ─── Gibberish Detection (Consonant Clusters only) ────────────────────────────\n/**\n * Detects gibberish by measuring the ratio of characters inside long consonant\n * clusters (3+ consonants in a row) against the total non-whitespace length.\n * Real words rarely exceed a ratio of ~0.40; random strings often hit 0.55+.\n */function isGibberish(value){const cleaned=value.trim();if(cleaned.length<5)return false;const consonantClusters=cleaned.match(/[^aeiou\\s\\d\\W]{3,}/gi)||[];const clusterChars=consonantClusters.reduce((n,c)=>n+c.length,0);const total=cleaned.replace(/\\s/g,\"\").length;return total>0&&clusterChars/total>.5;}// ─── Honeypot ─────────────────────────────────────────────────────────────────\nconst HONEYPOT_NAME=\"website_url\";function injectHoneypot(form){if(form.querySelector(`[name=\"${HONEYPOT_NAME}\"]`))return;const honeypot=document.createElement(\"input\");honeypot.type=\"text\";honeypot.name=HONEYPOT_NAME;honeypot.tabIndex=-1;honeypot.autocomplete=\"off\";honeypot.setAttribute(\"style\",\"opacity:0;position:absolute;top:0;left:0;height:0;width:0;z-index:-1;pointer-events:none;\");form.appendChild(honeypot);}function honeypotTriggered(form){const hp=form.querySelector(`[name=\"${HONEYPOT_NAME}\"]`);return!!hp&&hp.value.length>0;}// ─── Field helpers ────────────────────────────────────────────────────────────\nfunction isTextField(input){const haystack=`${input.name} ${input.id} ${input.placeholder}`.toLowerCase();return TEXT_FIELD_KEYWORDS.some(kw=>haystack.includes(kw));}// ─── Error UI ─────────────────────────────────────────────────────────────────\nconst ERROR_ID_PREFIX=\"spam-guard-error-\";const ERROR_STYLE=\"color:#e53e3e;font-size:13px;margin-top:4px;display:block;font-family:inherit;\";function showError(input,message){input.style.outline=\"2px solid #e53e3e\";input.style.outlineOffset=\"2px\";const errorId=ERROR_ID_PREFIX+(input.name||input.id||\"field\");let el=document.getElementById(errorId);if(!el){el=document.createElement(\"span\");el.id=errorId;el.setAttribute(\"role\",\"alert\");el.setAttribute(\"style\",ERROR_STYLE);input.parentNode?.insertBefore(el,input.nextSibling);}el.textContent=message;input.addEventListener(\"input\",()=>clearError(input),{once:true});}function clearError(input){input.style.outline=\"\";input.style.outlineOffset=\"\";document.getElementById(ERROR_ID_PREFIX+(input.name||input.id||\"field\"))?.remove();}// ─── Core validation runner ───────────────────────────────────────────────────\nfunction runValidation(form,event){// 1. Honeypot – silent block (no error, bots shouldn't know why they failed)\nif(honeypotTriggered(form)){event.preventDefault();event.stopPropagation();return false;}let blocked=false;// 2. Email validation\nconst emailInputs=form.querySelectorAll('input[type=\"email\"], input[name*=\"email\"], input[placeholder*=\"email\" i]');emailInputs.forEach(input=>{if(!input.value)return;const result=validateEmail(input.value);if(!result.valid){event.preventDefault();event.stopPropagation();blocked=true;showError(input,result.reason);}else{clearError(input);}});// 3. Gibberish detection on name/company/position fields\nconst textInputs=form.querySelectorAll(\"input[type='text'], input:not([type])\");textInputs.forEach(input=>{if(!isTextField(input)||!input.value)return;if(isGibberish(input.value)){event.preventDefault();event.stopPropagation();blocked=true;showError(input,\"This doesn't look like a valid entry. Please enter your real details.\");}else{clearError(input);}});return!blocked;}// ─── Override ─────────────────────────────────────────────────────────────────\nexport function withEmailSpamGuard(Component){return function SpamGuardedForm(props){// Inject honeypot as soon as the DOM node is available\nconst refCallback=el=>{if(!el)return;const form=el.querySelector(\"form\")||el.closest(\"form\");if(form)injectHoneypot(form);};const handleSubmit=event=>{const form=event.target instanceof HTMLFormElement?event.target:event.currentTarget?.closest(\"form\");if(form)runValidation(form,event);};const handleClick=e=>{const target=e.target;const isSubmit=target.tagName===\"BUTTON\"||!!target.closest('button[type=\"submit\"]')||!!target.closest('[data-framer-name*=\"submit\" i]');if(isSubmit){const form=target.closest(\"form\");if(form)runValidation(form,e);}props.onClick?.(e);};return /*#__PURE__*/_jsx(\"div\",{ref:refCallback,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props,onSubmit:handleSubmit,onClick:handleClick})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withEmailSpamGuard\":{\"type\":\"reactHoc\",\"name\":\"withEmailSpamGuard\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Form_Filter.map"],"mappings":"oGAGA,SAAS,EAAc,EAAM,CAAC,IAAM,EAAQ,EAAM,MAAM,CAAC,aAAa,CAAO,EAAQ,EAAQ,YAAY,IAAI,CAAC,GAAG,IAAU,GAAG,MAAM,CAAC,MAAM,GAAM,OAAO,yBAAyB,CAAC,IAAM,EAAU,EAAQ,UAAU,EAAE,EAAQ,CAAO,EAAO,EAAQ,UAAU,EAAQ,EAAE,CAAwV,OAApV,EAAgB,SAAS,EAAO,CAAQ,CAAC,MAAM,GAAM,OAAO,yBAAyB,EAAO,oDAAoD,EAAkB,EAAU,MAAM,MAAM,EAAE,EAAE,EAAE,OAAmB,EAA0B,CAAC,MAAM,G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