{"version":3,"file":"PhoneNumberValidator.Dyo3xIAt.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/yT4SDLd9JqEGiuvdEr5Q/dd9nQE1lmvdwSI4FJI57/PhoneNumberValidator.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const useStore=createStore({isValid:true});export function setParent(Component){return props=>{const[store]=useStore();return /*#__PURE__*/_jsx(Component,{...props,variant:store.isValid?\"Default\":\"Error\"});};}export function withValidation(Component){return props=>{const[value,setValue]=useState(\"\");const[isFocused,setIsFocused]=useState(false);const[store,setStore]=useStore();const phoneRegex=/^\\+\\d{1,3}[-\\s]?(\\(\\d{3}\\)|\\d{3})[-\\s]?\\d{3}[-\\s]?\\d{4}$/;const getIsValid=async()=>{try{const isValid=phoneRegex.test(value);await setStore({isValid});}catch(error){console.error(\"Validation error:\",error);}};useEffect(()=>{if(!isFocused||value.length<=1)return;const handler=setTimeout(()=>{getIsValid();},800);return()=>{clearTimeout(handler);};},[value,isFocused]);return /*#__PURE__*/_jsx(Component,{...props,onChange:e=>setValue(e.target.value),onFocus:()=>setIsFocused(true),onBlur:getIsValid});};}\nexport const __FramerMetadata__ = {\"exports\":{\"setParent\":{\"type\":\"reactHoc\",\"name\":\"setParent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withValidation\":{\"type\":\"reactHoc\",\"name\":\"withValidation\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PhoneNumberValidator.map"],"mappings":"sPAAuW,SAAgB,EAAe,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAM,GAAU,GAAU,CAAO,EAAW,2DAAiE,EAAW,SAAS,CAAC,GAAG,CAAC,IAAM,EAAQ,EAAW,KAAK,EAAM,CAAC,MAAM,EAAS,CAAC,UAAQ,CAAC,OAAQ,EAAM,CAAC,QAAQ,MAAM,oBAAoB,EAAM,GAAmK,OAA/J,MAAc,CAAC,GAAG,CAAC,GAAW,EAAM,QAAQ,EAAE,OAAO,IAAM,EAAQ,eAAe,CAAC,GAAY,EAAG,IAAI,CAAC,UAAU,CAAC,aAAa,EAAQ,GAAK,CAAC,EAAM,EAAU,CAAC,CAAqB,EAAK,EAAU,CAAC,GAAG,EAAM,SAAS,GAAG,EAAS,EAAE,OAAO,MAAM,CAAC,YAAY,EAAa,GAAK,CAAC,OAAO,EAAW,CAAC,qBAA9+B,IAAsC,IAAqE,CAAM,EAAS,EAAY,CAAC,QAAQ,GAAK,CAAC"}