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KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAE,EAC1D,YAAY,GAAG,CAAC,MAAM,CAAC,KAAK,CAAE,IAAI,CAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,IAAI,CAAE,CAAC;YAE9D,IAAI,IAAI,CAAC,SAAS,CAAE,KAAK,CAAE,CAAC,CAAE,CAAE,IAAI,IAAI,CAAC,SAAS,CAAE,WAAW,CAAE,IAAI,YAAY,EAAG;gBACnF,OAAO,CAAC,IAAI,CAAE,IAAI,UAAU,CAAE;oBAC7B,UAAU,EAAE,UAAU;oBACtB,WAAW,EAAE,WAAW;oBACxB,MAAM,EAAE,KAAK,CAAC,KAAK;oBACnB,MAAM,EAAE,WAAW;oBACnB,QAAQ,EAAE,QAAQ;iBAClB,CAAE,CAAE,CAAC;aACN;SACD;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;IAGS,gCAAS,GAAnB,UAAqB,IAAY;QAChC,OAAO,UAAU,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAChC,CAAC;IAEF,mBAAC;AAAD,CA3DA,AA2DC,CA3DiC,OAAO,GA2DxC","file":"phone-matcher.js","sourcesContent":["import { Matcher } from \"./matcher\";\nimport { PhoneMatch } from \"../match/phone-match\";\nimport { Match } from \"../match/match\";\nimport { nonDigitRe } from '../regex-lib';\n\n// RegExp objects which are shared by all instances of PhoneMatcher. These are\n// here to avoid re-instantiating the RegExp objects if `Autolinker.link()` is\n// called multiple times, thus instantiating PhoneMatcher and its RegExp \n// objects each time (which is very expensive - see https://github.com/gregjacobs/Autolinker.js/issues/314). \n// See descriptions of the properties where they are used for details about them\nconst phoneMatcherRegex = /(?:(?:(?:(\\+)?\\d{1,3}[-\\040.]?)?\\(?\\d{3}\\)?[-\\040.]?\\d{3}[-\\040.]?\\d{4})|(?:(\\+)(?:9[976]\\d|8[987530]\\d|6[987]\\d|5[90]\\d|42\\d|3[875]\\d|2[98654321]\\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)[-\\040.]?(?:\\d[-\\040.]?){6,12}\\d+))([,;]+[0-9]+#?)*/g;\n\n/**\n * @class Autolinker.matcher.Phone\n * @extends Autolinker.matcher.Matcher\n *\n * Matcher to find Phone number matches in an input string.\n *\n * See this class's superclass ({@link Autolinker.matcher.Matcher}) for more\n * details.\n */\nexport class PhoneMatcher extends Matcher {\n\n\t/**\n\t * The regular expression to match Phone numbers. Example matches:\n\t *\n\t * (123) 456-7890\n\t * 123 456 7890\n\t * 123-456-7890\n\t * +18004441234,,;,10226420346#\n\t * +1 (800) 444 1234\n\t * 10226420346#\n\t * 1-800-444-1234,1022,64,20346#\n\t *\n\t * This regular expression has the following capturing groups:\n\t *\n\t * 1 or 2. The prefixed '+' sign, if there is one.\n\t *\n\t * @protected\n\t * @property {RegExp} matcherRegex\n\t */\n\tprotected matcherRegex = phoneMatcherRegex;\n\n\t/**\n\t * @inheritdoc\n\t */\n\tparseMatches( text: string ) {\n\t\tlet matcherRegex = this.matcherRegex,\n\t\t\ttagBuilder = this.tagBuilder,\n\t\t\tmatches: Match[] = [],\n\t\t\tmatch: RegExpExecArray | null;\n\n\t\twhile( ( match = matcherRegex.exec( text ) ) !== null ) {\n\t\t\t// Remove non-numeric values from phone number string\n\t\t\tvar matchedText = match[ 0 ],\n\t\t\t\tcleanNumber = matchedText.replace( /[^0-9,;#]/g, '' ), // strip out non-digit characters exclude comma semicolon and #\n\t\t\t\tplusSign = !!( match[ 1 ] || match[ 2 ] ), // match[ 1 ] or match[ 2 ] is the prefixed plus sign, if there is one\n\t\t\t\tbefore = match.index == 0 ? '' : text.substr( match.index - 1, 1 ),\n\t\t\t\tafter = text.substr( match.index + matchedText.length, 1 ),\n\t\t\t\tcontextClear = !before.match( /\\d/ ) && !after.match( /\\d/ );\n\n\t\t\tif( this.testMatch( match[ 3 ] ) && this.testMatch( matchedText ) && contextClear ) {\n\t\t\t\tmatches.push( new PhoneMatch( {\n\t\t\t\t\ttagBuilder: tagBuilder,\n\t\t\t\t\tmatchedText: matchedText,\n\t\t\t\t\toffset: match.index,\n\t\t\t\t\tnumber: cleanNumber,\n\t\t\t\t\tplusSign: plusSign\n\t\t\t\t} ) );\n\t\t\t}\n\t\t}\n\n\t\treturn matches;\n\t}\n\n\n\tprotected testMatch( text: string ) {\n\t\treturn nonDigitRe.test( text );\n\t}\n\n}\n"]}