{"version":3,"file":"WorkEmailOnly.CVYPUIa_.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/7qYZ2XZ6bMJyomKQCEdH/D20wJX6eYrkJTyOXo3Mf/WorkEmailOnly.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";const MESSAGE=\"Please use your work email address.\";// Consumer providers, matched together with their country variants, so\n// \"yahoo\" also covers yahoo.co.uk and \"gmx\" also covers gmx.de. The short\n// TLD pattern keeps company domains like mail.acme.com out of the match.\nconst CONSUMER_FAMILIES=/^(?:gmail|googlemail|yahoo|ymail|rocketmail|hotmail|outlook|live|msn|aol|icloud|proton|protonmail|gmx|yandex|mail)\\.[a-z]{2,3}(?:\\.[a-z]{2,3})?$/;const CONSUMER_DOMAINS=new Set([\"me.com\",\"mac.com\",\"pm.me\",\"hey.com\",\"fastmail.com\",\"zoho.com\",\"qq.com\",\"163.com\",\"126.com\",\"naver.com\"]);function isConsumerEmail(value){const domain=value.trim().toLowerCase().split(\"@\")[1];if(!domain)return false;return CONSUMER_DOMAINS.has(domain)||CONSUMER_FAMILIES.test(domain);}export function withWorkEmailOnly(Component){return props=>{const ref=useRef(null);useEffect(()=>{const input=ref.current?.querySelector(\"input\");if(!input)return;const validate=()=>{input.setCustomValidity(isConsumerEmail(input.value)?MESSAGE:\"\");};// The submit button validates natively, so marking the field\n// invalid is enough to stop submission. The click listener\n// re-checks first, in case the value arrived via autofill\n// without firing an input event.\nconst form=input.closest(\"form\");input.addEventListener(\"input\",validate);input.addEventListener(\"blur\",validate);form?.addEventListener(\"click\",validate,true);return()=>{input.removeEventListener(\"input\",validate);input.removeEventListener(\"blur\",validate);form?.removeEventListener(\"click\",validate,true);};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withWorkEmailOnly\":{\"type\":\"reactHoc\",\"name\":\"withWorkEmailOnly\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WorkEmailOnly.map"],"mappings":"yHAGqT,SAAS,EAAgB,EAAM,CAAC,IAAM,EAAO,EAAM,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAA2B,OAApB,EAA2B,EAAiB,IAAI,CAAM,GAAG,EAAkB,KAAK,CAAM,EAAxE,EAA0E,CAAC,SAAgB,EAAkB,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,IAAI,EAI9P,OAJgQ,MAAc,CAAC,IAAM,EAAM,EAAI,SAAS,cAAc,OAAO,EAAE,GAAG,CAAC,EAAM,OAAO,IAAM,MAAa,CAAC,EAAM,kBAAkB,EAAgB,EAAM,KAAK,EAAE,EAAQ,EAAE,CAAE,EAI1tB,EAAK,EAAM,QAAQ,MAAM,EAAiI,OAA/H,EAAM,iBAAiB,QAAQ,CAAQ,EAAE,EAAM,iBAAiB,OAAO,CAAQ,EAAE,GAAM,iBAAiB,QAAQ,EAAS,EAAI,MAAY,CAAC,EAAM,oBAAoB,QAAQ,CAAQ,EAAE,EAAM,oBAAoB,OAAO,CAAQ,EAAE,GAAM,oBAAoB,QAAQ,EAAS,EAAI,CAAE,CAAE,EAAE,CAAC,CAAC,EAAsB,EAAK,MAAM,CAAK,MAAI,MAAM,CAAC,QAAQ,UAAU,EAAE,SAAsB,EAAK,EAAU,CAAC,GAAG,CAAK,CAAC,CAAC,CAAC,CAAE,CAAE,uBAPzY,IAAoC,EAAO,EAAQ,sCAGvF,EAAkB,mJAAyJ,EAAiB,IAAI,IAAI,CAAC,SAAS,UAAU,QAAQ,UAAU,eAAe,WAAW,SAAS,UAAU,UAAU,WAAW,CAAC"}