{"version":3,"sources":["../source/parseIncompletePhoneNumber.js"],"names":["parseDigit","parseIncompletePhoneNumber","string","result","split","character","parsePhoneNumberCharacter","value"],"mappings":"AAAA,SAASA,UAAT,QAA2B,eAA3B;AAEA;;;;;;;;;;;;;;;;AAeA,eAAe,SAASC,0BAAT,CAAoCC,MAApC,EAA4C;AAC1D,MAAIC,MAAM,GAAG,EAAb,CAD0D,CAE1D;AACA;AACA;AACA;AACA;AACA;;AACA,uBAAwBD,MAAM,CAACE,KAAP,CAAa,EAAb,CAAxB,kHAA0C;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA,QAA/BC,SAA+B;AACzCF,IAAAA,MAAM,IAAIG,yBAAyB,CAACD,SAAD,EAAYF,MAAZ,CAAzB,IAAgD,EAA1D;AACA;;AACD,SAAOA,MAAP;AACA;AAED;;;;;;;;;AAQA,OAAO,SAASG,yBAAT,CAAmCD,SAAnC,EAA8CE,KAA9C,EAAqD;AAC3D;AACA,MAAIF,SAAS,KAAK,GAAlB,EAAuB;AACtB;AACA;AACA,QAAIE,KAAJ,EAAW;AACV;AACA;;AACD,WAAO,GAAP;AACA,GAT0D,CAU3D;;;AACA,SAAOP,UAAU,CAACK,SAAD,CAAjB;AACA","sourcesContent":["import { parseDigit } from './parseDigits'\r\n\r\n/**\r\n * Parses phone number characters from a string.\r\n * Drops all punctuation leaving only digits and the leading `+` sign (if any).\r\n * Also converts wide-ascii and arabic-indic numerals to conventional numerals.\r\n * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.\r\n * @param {string} string\r\n * @return {string}\r\n * @example\r\n * ```js\r\n * // Outputs '8800555'.\r\n * parseIncompletePhoneNumber('8 (800) 555')\r\n * // Outputs '+7800555'.\r\n * parseIncompletePhoneNumber('+7 800 555')\r\n * ```\r\n */\r\nexport default function parseIncompletePhoneNumber(string) {\r\n\tlet result = ''\r\n\t// Using `.split('')` here instead of normal `for ... of`\r\n\t// because the importing application doesn't neccessarily include an ES6 polyfill.\r\n\t// The `.split('')` approach discards \"exotic\" UTF-8 characters\r\n\t// (the ones consisting of four bytes) but digits\r\n\t// (including non-European ones) don't fall into that range\r\n\t// so such \"exotic\" characters would be discarded anyway.\r\n\tfor (const character of string.split('')) {\r\n\t\tresult += parsePhoneNumberCharacter(character, result) || ''\r\n\t}\r\n\treturn result\r\n}\r\n\r\n/**\r\n * `input-format` `parse()` function.\r\n * https://gitlab.com/catamphetamine/input-format\r\n * @param {string} character - Yet another character from raw input string.\r\n * @param {string} value - The value parsed so far.\r\n * @param {object} meta - Optional custom use-case-specific metadata.\r\n * @return {string?} The parsed character.\r\n */\r\nexport function parsePhoneNumberCharacter(character, value) {\r\n\t// Only allow a leading `+`.\r\n\tif (character === '+') {\r\n\t\t// If this `+` is not the first parsed character\r\n\t\t// then discard it.\r\n\t\tif (value) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn '+'\r\n\t}\r\n\t// Allow digits.\r\n\treturn parseDigit(character)\r\n}"],"file":"parseIncompletePhoneNumber.js"}