{"version":3,"file":"RequiredMessage.Cd9HP3Ll.mjs","names":["useState","useRef","__esmMin","ce","J","init_jsx_runtime","init_npm_react_18_3_1","c","de","_e","check","el","raw","v","SPACE_MESSAGE","PLAIN_ONLY","SAFE_CHARS","VALID_EMAIL","INCOMPLETE_MESSAGE","CHAR_MESSAGE","ACCENT_MESSAGE","REQUIRED_MESSAGE","onInvalid","isEmailField","onEdit","onFocus","withRequiredMessage","Component","props","withFormRetry","k","setK","saved","node","root","form","data","n","proto","setter","onClick","btn","e","ERROR_TEXT","x","setRef","ref","init_RequiredMessage","t"],"sources":["https:/framerusercontent.com/modules/z5l34y2LDaBQSU9TArxc/xV4WWnPMQdiqixPnKt6R/RequiredMessage.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef,useState}from\"react\";// Validation for the Email field on the contact, referral and whitepaper forms.\n// The field is checked here so the visitor gets a clear message:\n// - Empty, or only spaces: REQUIRED_MESSAGE\n// - Contains a space: SPACE_MESSAGE\n// - Accented / non-English characters: ACCENT_MESSAGE\n//   (Framer's form service silently rejects these, so catch them first)\n// - Any symbol other than letters, digits and . _ + - : CHAR_MESSAGE\n//   Tested 10 Nov 2026: Framer accepts an address with an apostrophe\n//   (o'brien@...) and shows success, but never sends the email, so the\n//   enquiry is silently lost. Other rare symbols are blocked for safety.\n// - Not a proper name@domain.ending (double dot, dot at the start or end,\n//   hyphen at the start or end of a domain part, numeric ending):\n//   INCOMPLETE_MESSAGE\nconst REQUIRED_MESSAGE=\"Please fill in the required field\";const SPACE_MESSAGE=\"Please remove the space from your email address\";const ACCENT_MESSAGE=\"Please use an email address without accented characters (e.g. juergen instead of j\\xfcrgen)\";const CHAR_MESSAGE=\"Sorry, our form can't accept that character in an email address. Please use a different address, or email us at team@encevia.com\";const INCOMPLETE_MESSAGE=\"Please enter a full email address, e.g. name@company.com\";// Plain (ASCII) characters only\nconst PLAIN_ONLY=/^[\\x21-\\x7E]+$/;// Only characters Framer delivers reliably: letters, digits, . _ + - and @\nconst SAFE_CHARS=/^[A-Za-z0-9._+@-]+$/;// Name part: no dot at either end, no double dots.\n// Domain: parts of letters/digits/hyphens (hyphen not at either end),\n// ending in 2+ letters.\nconst VALID_EMAIL=/^[A-Za-z0-9_+-]+(\\.[A-Za-z0-9_+-]+)*@([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?\\.)+[A-Za-z]{2,}$/;const isEmailField=t=>t instanceof HTMLInputElement&&t.name===\"Email\";function check(el){el.setCustomValidity(\"\");const raw=el.value;const v=raw.trim();if(!v){// Only spaces: the browser doesn't count that as empty, so we do\nif(raw.length>0)el.setCustomValidity(REQUIRED_MESSAGE);return;}if(/\\s/.test(v))el.setCustomValidity(SPACE_MESSAGE);else if(!PLAIN_ONLY.test(v))el.setCustomValidity(ACCENT_MESSAGE);else if((v.match(/@/g)||[]).length!==1)el.setCustomValidity(INCOMPLETE_MESSAGE);else if(!SAFE_CHARS.test(v))el.setCustomValidity(CHAR_MESSAGE);else if(!VALID_EMAIL.test(v))el.setCustomValidity(INCOMPLETE_MESSAGE);}// Page-level listeners (capture phase), so it doesn't matter when the field renders\nfunction onInvalid(e){if(!isEmailField(e.target))return;if(e.target.validity.valueMissing)e.target.setCustomValidity(REQUIRED_MESSAGE);}function onEdit(e){if(isEmailField(e.target))check(e.target);}function onFocus(e){if(!isEmailField(e.target))return;// Email keyboard on phones, browser autofill, no autocorrect\ne.target.inputMode=\"email\";e.target.autocomplete=\"email\";e.target.spellcheck=false;e.target.setAttribute(\"autocapitalize\",\"off\");}export function withRequiredMessage(Component){return /*#__PURE__*/forwardRef((props,ref)=>{useEffect(()=>{if(typeof document===\"undefined\")return;document.addEventListener(\"invalid\",onInvalid,true);document.addEventListener(\"input\",onEdit,true);document.addEventListener(\"change\",onEdit,true);document.addEventListener(\"focusin\",onFocus,true);return()=>{document.removeEventListener(\"invalid\",onInvalid,true);document.removeEventListener(\"input\",onEdit,true);document.removeEventListener(\"change\",onEdit,true);document.removeEventListener(\"focusin\",onFocus,true);};},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}// Retry after a failed send. Framer leaves the form stuck in its Error state\n// (clicking again does nothing), so clicking the error button remounts the\n// form, puts back what the person typed, and submits again.\n// Apply to the layer that contains the form (e.g. the \"Contact Form\" stack).\n// NOTE: this matches the button's Error text. If that text is ever changed,\n// update ERROR_TEXT to match, or the retry silently stops working.\nconst ERROR_TEXT=/Not sent|went wrong/i;export function withFormRetry(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[k,setK]=useState(0);const saved=useRef(null);const node=useRef(null);useEffect(()=>{const root=node.current;if(!root)return;if(saved.current){const form=root.querySelector(\"form\");const data=saved.current;saved.current=null;if(form){Object.keys(data).forEach(n=>{const el=form.querySelector('[name=\"'+n+'\"]');if(!el||el.type===\"hidden\")return;const proto=el instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype;const setter=Object.getOwnPropertyDescriptor(proto,\"value\");if(setter&&setter.set)setter.set.call(el,data[n]);el.dispatchEvent(new Event(\"input\",{bubbles:true}));});setTimeout(()=>form.requestSubmit(),50);}}const onClick=e=>{const btn=e.target.closest(\"button[type=submit]\");if(!btn||!root.contains(btn))return;if(!ERROR_TEXT.test(btn.textContent||\"\"))return;e.preventDefault();e.stopPropagation();const form=btn.closest(\"form\");const data={};if(form){form.querySelectorAll(\"input[name], textarea[name]\").forEach(el=>{data[el.name]=el.value;});}saved.current=data;setK(x=>x+1);};root.addEventListener(\"click\",onClick,true);return()=>root.removeEventListener(\"click\",onClick,true);},[k]);const setRef=el=>{node.current=el;if(typeof ref===\"function\")ref(el);else if(ref)ref.current=el;};return /*#__PURE__*/_jsx(Component,{...props,ref:setRef},k);});}\nexport const __FramerMetadata__ = {\"exports\":{\"withRequiredMessage\":{\"type\":\"reactHoc\",\"name\":\"withRequiredMessage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormRetry\":{\"type\":\"reactHoc\",\"name\":\"withF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