{"version":3,"file":"WithFormValidation.DbRSym8P.mjs","names":[],"sources":["https:/framerusercontent.com/modules/ibedcp6rP2hpHwAex8bo/4GZYhahT9ZQwseSgfZd2/WithFormValidation.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";const personalEmailDomains=[\"gmail.com\",\"yahoo.com\",\"hotmail.com\",\"outlook.com\",\"live.com\",\"aol.com\",\"icloud.com\",\"mailinator.com\",\"addy.io\",\"maildrop.cc\",\"temporary-mail.net\",\"relay.firefox.com\",\"guerrillamail.com\",\"yopmail.com\",\"simplelogin.io\",\"spamgourmet.com\",\"cloaked.app\",\"erine.email\",\"dispostable.com\",\"10minutemail.com\"];export function withFormValidation(Component){return function FormValidationHOC(props){useEffect(()=>{function snakeToCamel(str){return str.replace(/_([a-z])/g,(match,letter)=>letter.toUpperCase());}if(typeof window!==\"undefined\"&&props.className){const params=new URLSearchParams(window.location.search);const form=document.querySelector(`form.${props.className}`);if(form){console.log(\"Has utms\");params.forEach((value,key)=>{if(key.startsWith(\"utm\")){const input=document.createElement(\"input\");input.type=\"hidden\";input.name=snakeToCamel(key);input.value=value;form.appendChild(input);}});}}},[props.className]);useEffect(()=>{if(!props.className)return;const form=document.querySelector(`form.${props.className}`);const emailInput=form?.querySelector(\"input[name='email']\");const formId=form?.id||\"default_form\";if(!form||!emailInput)return;// Email validation function\nconst validateEmail=()=>{const value=emailInput.value;const emailDomain=value.split(\"@\")[1]?.toLowerCase();if(value===\"\"){emailInput.setCustomValidity(\"Email is required.\");}else{emailInput.setCustomValidity(\"\")// Valid email\n;window.posthog.portfolio.identify(value,{email:value,form_id:formId});}};// const handleSubmit = (event: Event) => {\n//     validateEmail()\n//     if (!form.checkValidity()) {\n//         return\n//     }\n//     event.preventDefault()\n//     const email = emailInput.value\n//     const loginHint = encodeURIComponent(email)\n//     const redirectUrl = `http://app.genway.ai/sign-up?login_hint=${loginHint}`\n//     window.location.href = redirectUrl\n// }\nemailInput.addEventListener(\"blur\",validateEmail);// form.addEventListener(\"submit\", handleSubmit)\nreturn()=>{emailInput.removeEventListener(\"blur\",validateEmail);// form.removeEventListener(\"submit\", handleSubmit)\n};},[props.className]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withFormValidation\":{\"type\":\"reactHoc\",\"name\":\"withFormValidation\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithFormValidation.map"],"mappings":"6FAAmZ,SAAgB,EAAmB,EAAU,CAAC,OAAO,SAA2B,EAAM,CAeld,OAfmd,MAAc,CAAC,SAAS,EAAa,EAAI,CAAC,OAAO,EAAI,QAAQ,aAAa,EAAM,IAAS,EAAO,cAAgB,IAAU,IAAS,QAAa,EAAM,UAAU,CAAC,IAAM,EAAO,IAAI,gBAAgB,EAAO,SAAS,QAAc,EAAK,SAAS,cAAc,QAAQ,EAAM,aAAgB,IAAM,QAAQ,IAAI,YAAY,EAAO,SAAS,EAAM,IAAM,CAAC,GAAG,EAAI,WAAW,OAAO,CAAC,IAAM,EAAM,SAAS,cAAc,SAAS,EAAM,KAAK,SAAS,EAAM,KAAK,EAAa,GAAK,EAAM,MAAM,EAAM,EAAK,YAAY,EAAQ,CAAC,GAAI,CAAC,EAAC,CAAC,EAAM,UAAU,EAAE,MAAc,CAAC,GAAG,CAAC,EAAM,UAAU,OAAO,IAAM,EAAK,SAAS,cAAc,QAAQ,EAAM,aAAmB,EAAW,GAAM,cAAc,uBAA6B,EAAO,GAAM,IAAI,eAAe,GAAG,CAAC,GAAM,CAAC,EAAW,OAC1tC,IAAM,MAAkB,CAAC,IAAM,EAAM,EAAW,MAAwB,EAAM,MAAM,KAAK,IAAI,cAAiB,IAAQ,GAAI,EAAW,kBAAkB,uBAA4B,EAAW,kBAAkB,IAC/M,EAAO,QAAQ,UAAU,SAAS,EAAM,CAAC,MAAM,EAAM,QAAQ,EAAO,EAAI,EAYzE,OADA,EAAW,iBAAiB,OAAO,OACzB,CAAC,EAAW,oBAAoB,OAAO,EAChD,CAAE,EAAC,CAAC,EAAM,UAAU,EAAsB,EAAK,EAAU,CAAC,GAAG,EAAM,CAAG,CAAE"}