{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/yizwceTvg0HE8uCw3Xgj/TOAPG8DhHbMYannuhKNS/PhoneMaskController.js"],
  "sourcesContent": ["/**\n * v2.0\n * Name and Phone Mask Validation for Framer\n * You may use this asset for personal and commercial use.\n * Created by Sergei Chyrkov (x.com/sergeichyrkov) at sergeichyrkov.com\n *\n * Redistribution of this work is NOT permitted, re-sharing or altering it\n * in a way that misrepresents authorship is not allowed. Proper attribution is required.\n *\n * Hope you enjoy using it!\n *\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 1\n * @framerIntrinsicHeight 1\n */export default function PhoneMaskController(props){const{phoneMask}=props;const countryCodeMatch=phoneMask.match(/^\\+(\\d+)/);const countryCode=countryCodeMatch?countryCodeMatch[1]:\"\";const countryCodeLength=countryCode.length;useEffect(()=>{const applyPhoneMask=event=>{const matrix=phoneMask;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;const digitsOnly=currentValue.replace(/\\D/g,\"\");if(digitsOnly.length<=countryCodeLength){event.target.value=\"\";const customEvent=new Event(\"change\");event.target.dispatchEvent(customEvent);}};const restrictNameInput=event=>{const regex=/^[a-zA-Z\\u0400-\\u04FF\\s]*$/;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);});return()=>{phoneFields.forEach(phoneField=>{phoneField.removeEventListener(\"input\",applyPhoneMask);phoneField.removeEventListener(\"blur\",handleBlur);});nameFields.forEach(nameField=>{nameField.removeEventListener(\"input\",restrictNameInput);});};},[phoneMask,countryCodeLength]);return /*#__PURE__*/_jsx(\"div\",{style:{width:0,height:0,position:\"absolute\",opacity:0,pointerEvents:\"none\"}});}addPropertyControls(PhoneMaskController,{phoneMask:{type:ControlType.String,title:\"Phone Mask\",defaultValue:\"+1 (___) ___-__-__\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PhoneMaskController\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"1\",\"framerDisableUnlink\":\"*\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PhoneMaskController.map"],
  "mappings": "gGAgBkB,SAARA,EAAqCC,EAAM,CAAC,GAAK,CAAC,UAAAC,CAAS,EAAED,EAAYE,EAAiBD,EAAU,MAAM,UAAU,EAAkEE,GAA9CD,EAAiBA,EAAiB,CAAC,EAAE,IAAuC,OAAO,OAAAE,EAAU,IAAI,CAAC,IAAMC,EAAeC,GAAO,CAAC,IAAMC,EAAON,EAAcO,EAAE,EAAQC,EAAIF,EAAO,QAAQ,MAAM,EAAE,EAAMG,EAAaJ,EAAM,OAAO,MAAM,QAAQ,MAAM,EAAE,EAAKG,EAAI,QAAQC,EAAa,SAAQA,EAAaD,GAAK,IAAME,EAASJ,EAAO,QAAQ,KAAK,SAASK,EAAE,CAAC,MAAM,QAAQ,KAAKA,CAAC,GAAGJ,EAAEE,EAAa,OAAOA,EAAa,OAAOF,GAAG,EAAEA,GAAGE,EAAa,OAAO,GAAGE,CAAE,CAAC,EAAEN,EAAM,OAAO,MAAMK,CAAS,EAAQE,EAAWP,GAAO,CAAuF,GAAnEA,EAAM,OAAO,MAAoC,QAAQ,MAAM,EAAE,EAAgB,QAAQH,EAAkB,CAACG,EAAM,OAAO,MAAM,GAAG,IAAMQ,EAAY,IAAI,MAAM,QAAQ,EAAER,EAAM,OAAO,cAAcQ,CAAW,CAAE,CAAC,EAAQC,EAAkBT,GAAO,CAAa,6BAAuC,KAAKA,EAAM,OAAO,KAAK,IAAGA,EAAM,OAAO,MAAMA,EAAM,OAAO,MAAM,QAAQ,4BAA4B,EAAE,EAAG,EAAQU,EAAY,SAAS,iBAAiB,mBAAmB,EAAQC,EAAW,SAAS,iBAAiB,oBAAoB,EAAE,OAAAD,EAAY,QAAQE,GAAY,CAACA,EAAW,iBAAiB,QAAQb,CAAc,EAAEa,EAAW,iBAAiB,OAAOL,CAAU,CAAE,CAAC,EAAEI,EAAW,QAAQE,GAAW,CAACA,EAAU,iBAAiB,QAAQJ,CAAiB,CAAE,CAAC,EAAQ,IAAI,CAACC,EAAY,QAAQE,GAAY,CAACA,EAAW,oBAAoB,QAAQb,CAAc,EAAEa,EAAW,oBAAoB,OAAOL,CAAU,CAAE,CAAC,EAAEI,EAAW,QAAQE,GAAW,CAACA,EAAU,oBAAoB,QAAQJ,CAAiB,CAAE,CAAC,CAAE,CAAE,EAAE,CAACd,EAAUE,CAAiB,CAAC,EAAsBiB,EAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,WAAW,QAAQ,EAAE,cAAc,MAAM,CAAC,CAAC,CAAE,CAACC,EAAoBtB,EAAoB,CAAC,UAAU,CAAC,KAAKuB,EAAY,OAAO,MAAM,aAAa,aAAa,oBAAoB,CAAC,CAAC",
  "names": ["PhoneMaskController", "props", "phoneMask", "countryCodeMatch", "countryCodeLength", "ue", "applyPhoneMask", "event", "matrix", "i", "def", "currentValue", "newValue", "a", "handleBlur", "customEvent", "restrictNameInput", "phoneFields", "nameFields", "phoneField", "nameField", "p", "addPropertyControls", "ControlType"]
}
