{"version":3,"file":"Form_validation.C1Voiplv.mjs","names":[],"sources":["https:/framerusercontent.com/modules/mPESs27SSuJJEjE3YM01/XtAJMGyZjBs0qpFLexIB/Form_validation.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";/**\n@framerDisableUnlink\n@framerIntrinsicWidth 100\n@framerIntrinsicHeight 100\n*/export function withPhoneMaskAndNameValidation(Component){return props=>{useEffect(()=>{const applyPhoneMask=event=>{const matrix=\"+7 (___) ___-__-__\"// Adjust phone matrix as needed\n;let i=0;const def=matrix.replace(/\\D/g,\"\");let currentValue=event.target.value.replace(/\\D/g,\"\");if(def.length>=currentValue.length){currentValue=def;}const newValue=matrix.replace(/./g,function(a){return/[_\\d]/.test(a)&&i<currentValue.length?currentValue.charAt(i++):i>=currentValue.length?\"\":a;});event.target.value=newValue;};const handleBlur=event=>{const currentValue=event.target.value;// Adjust 2 to 3 for country codes with two digits (e.g., +38)\nif(currentValue.length<=2){event.target.value=\"\";const customEvent=new Event(\"change\");event.target.dispatchEvent(customEvent);}};const restrictNameInput=event=>{const regex=/^[a-zA-Z\\u0400-\\u04FF\\s]*$///Latic, Cyrillic, and spaces\n;if(!regex.test(event.target.value)){event.target.value=event.target.value.replace(/[^a-zA-Z\\u0400-\\u04FF\\s]/g,\"\");}};const phoneFields=document.querySelectorAll('input[type=\"tel\"]');const nameFields=document.querySelectorAll('input[name=\"name\"]');phoneFields.forEach(phoneField=>{phoneField.addEventListener(\"input\",applyPhoneMask);phoneField.addEventListener(\"blur\",handleBlur);});nameFields.forEach(nameField=>{nameField.addEventListener(\"input\",restrictNameInput);});// Cleanup on unmount\nreturn()=>{phoneFields.forEach(phoneFields=>{phoneFields.removeEventListener(\"input\",applyPhoneMask);phoneFields.removeEventListener(\"blur\",handleBlur);});};},[]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withPhoneMaskAndNameValidation\":{\"type\":\"reactHoc\",\"name\":\"withPhoneMaskAndNameValidation\",\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"@framerIntrinsicWidth 100\",\"framerIntrinsicHeight\":\"100\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Form_validation.map"],"mappings":"2JAIE,SAAgB,EAA+B,EAAU,CAAC,MAAO,CAAA,IAAQ,EAAU,IAAI,CAAC,IAAM,EAAe,GAAO,CAAC,IAAM,EAAO,qBAC/H,EAAE,EAAQ,EAAI,EAAO,QAAQ,MAAM,GAAG,CAAK,EAAa,EAAM,OAAO,MAAM,QAAQ,MAAM,GAAG,CAAC,AAAG,EAAI,QAAQ,EAAa,SAAQ,EAAa,GAAK,IAAM,EAAS,EAAO,QAAQ,KAAK,SAAS,EAAE,CAAC,MAAM,QAAQ,KAAK,EAAE,EAAE,EAAE,EAAa,OAAO,EAAa,OAAO,IAAI,CAAC,GAAG,EAAa,OAAO,GAAG,CAAG,EAAC,CAAC,EAAM,OAAO,MAAM,CAAU,EAAO,EAAW,GAAO,CAAC,IAAM,EAAa,EAAM,OAAO,MACnY,GAAG,EAAa,QAAQ,EAAE,CAAC,EAAM,OAAO,MAAM,GAAG,IAAM,EAAY,IAAI,MAAM,UAAU,EAAM,OAAO,cAAc,EAAY,AAAE,CAAC,EAAO,EAAkB,GAAO,CAAC,IAAM,EAAM,6BAC7K,AAAI,EAAM,KAAK,EAAM,OAAO,MAAM,GAAE,EAAM,OAAO,MAAM,EAAM,OAAO,MAAM,QAAQ,4BAA4B,GAAG,CAAG,EAAO,EAAY,SAAS,iBAAiB,oBAAoB,CAAO,EAAW,SAAS,iBAAiB,qBAAqB,CACvP,MADwP,GAAY,QAAQ,GAAY,CAAqD,AAApD,EAAW,iBAAiB,QAAQ,EAAe,CAAC,EAAW,iBAAiB,OAAO,EAAW,AAAE,EAAC,CAAC,EAAW,QAAQ,GAAW,CAAC,EAAU,iBAAiB,QAAQ,EAAkB,AAAE,EAAC,CAChd,IAAI,CAAC,EAAY,QAAQ,GAAa,CAAyD,AAAxD,EAAY,oBAAoB,QAAQ,EAAe,CAAC,EAAY,oBAAoB,OAAO,EAAW,AAAE,EAAC,AAAE,CAAE,EAAC,CAAE,EAAC,CAAqB,EAAK,EAAU,CAAC,GAAG,CAAM,EAAC,CAAI,cARrN,GAA2C,IAA6B"}