{"version":3,"file":"PhoneNumberValidator.DGR-RVTi.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/WiOGrSvXyRuMUKmOj01g/nRUKFiILe1yD89Kfo9NN/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=/^(\\+91[\\-\\s]?)?[0]?(91)?[789]\\d{9}$/;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\":{\"withValidation\":{\"type\":\"reactHoc\",\"name\":\"withValidation\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"setParent\":{\"type\":\"reactHoc\",\"name\":\"setParent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PhoneNumberValidator.map"],"mappings":"wLAAiM,SAAgB,EAAU,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,GAAO,GAAU,CAAC,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAM,QAAQ,EAAM,QAAQ,UAAU,QAAQ,CAAC,EAAI,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,sCAA4C,EAAW,SAAS,CAAC,GAAG,CAAsC,MAAM,EAAS,CAAC,QAAvC,EAAW,KAAK,EAAM,CAAyB,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,qBAAz9B,IAAsC,IAAqE,CAAM,EAAS,EAAY,CAAC,QAAQ,GAAK,CAAC"}