Browse Source

Add check for `phone-context`. (#2875)

* Add check for `phone-context`.

Add a check to PhoneNumberUtil that the value of the `phone-context` parameter of the tel URI follows the correct syntax as defined in [RFC3966](https://www.rfc-editor.org/rfc/rfc3966#section-3).

* Add check for `phone-context`.

Add a check to PhoneNumberUtil that the value of the `phone-context` parameter of the tel URI follows the correct syntax as defined in [RFC3966](https://www.rfc-editor.org/rfc/rfc3966#section-3).

* Add check for `phone-context`.

Add a check to PhoneNumberUtil that the value of the `phone-context` parameter of the tel URI follows the correct syntax as defined in [RFC3966](https://www.rfc-editor.org/rfc/rfc3966#section-3).
pull/2903/head
Fabrice Berchtold 3 years ago
committed by GitHub
parent
commit
d5cb0121b9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 700 additions and 189 deletions
  1. +98
    -16
      cpp/src/phonenumbers/phonenumberutil.cc
  2. +8
    -2
      cpp/src/phonenumbers/phonenumberutil.h
  3. +99
    -8
      cpp/test/phonenumbers/phonenumberutil_test.cc
  4. +4
    -3
      java/libphonenumber/src/com/google/i18n/phonenumbers/NumberParseException.java
  5. +80
    -15
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  6. +66
    -7
      java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
  7. +67
    -67
      javascript/i18n/phonenumbers/demo-compiled.js
  8. +208
    -60
      javascript/i18n/phonenumbers/phonenumberutil.js
  9. +66
    -10
      javascript/i18n/phonenumbers/phonenumberutil_test.js
  10. +4
    -1
      pending_code_changes.txt

+ 98
- 16
cpp/src/phonenumbers/phonenumberutil.cc View File

@ -97,11 +97,13 @@ const char kRfc3966ExtnPrefix[] = ";ext=";
const char kRfc3966Prefix[] = "tel:";
const char kRfc3966PhoneContext[] = ";phone-context=";
const char kRfc3966IsdnSubaddress[] = ";isub=";
const char kRfc3966VisualSeparator[] = "[\\-\\.\\(\\)]?";
const char kDigits[] = "\\p{Nd}";
// We accept alpha characters in phone numbers, ASCII only. We store lower-case
// here only since our regular expressions are case-insensitive.
const char kValidAlpha[] = "a-z";
const char kValidAlphaInclUppercase[] = "A-Za-z";
// Default extension prefix to use when formatting. This will be put in front of
// any extension component of the number, after the main national number is
@ -654,6 +656,13 @@ class PhoneNumberRegExpsAndMappings {
// indicators. When matching, these are hardly ever used to indicate this.
const string extn_patterns_for_parsing_;
// Regular expressions of different parts of the phone-context parameter,
// following the syntax defined in RFC3966.
const std::string rfc3966_phone_digit_;
const std::string alphanum_;
const std::string rfc3966_domainlabel_;
const std::string rfc3966_toplabel_;
public:
scoped_ptr<const AbstractRegExpFactory> regexp_factory_;
scoped_ptr<RegExpCache> regexp_cache_;
@ -756,6 +765,14 @@ class PhoneNumberRegExpsAndMappings {
scoped_ptr<const RegExp> plus_chars_pattern_;
// Regular expression of valid global-number-digits for the phone-context
// parameter, following the syntax defined in RFC3966.
std::unique_ptr<const RegExp> rfc3966_global_number_digits_pattern_;
// Regular expression of valid domainname for the phone-context parameter,
// following the syntax defined in RFC3966.
std::unique_ptr<const RegExp> rfc3966_domainname_pattern_;
PhoneNumberRegExpsAndMappings()
: valid_phone_number_(
StrCat(kDigits, "{", PhoneNumberUtil::kMinLengthForNsn, "}|[",
@ -764,6 +781,13 @@ class PhoneNumberRegExpsAndMappings {
kDigits, "){3,}[", PhoneNumberUtil::kValidPunctuation,
kStarSign, kValidAlpha, kDigits, "]*")),
extn_patterns_for_parsing_(CreateExtnPattern(/* for_parsing= */ true)),
rfc3966_phone_digit_(
StrCat("(", kDigits, "|", kRfc3966VisualSeparator, ")")),
alphanum_(StrCat(kValidAlphaInclUppercase, kDigits)),
rfc3966_domainlabel_(
StrCat("[", alphanum_, "]+((\\-)*[", alphanum_, "])*")),
rfc3966_toplabel_(StrCat("[", kValidAlphaInclUppercase,
"]+((\\-)*[", alphanum_, "])*")),
regexp_factory_(new RegExpFactory()),
regexp_cache_(new RegExpCache(*regexp_factory_.get(), 128)),
diallable_char_mappings_(),
@ -809,7 +833,12 @@ class PhoneNumberRegExpsAndMappings {
regexp_factory_->CreateRegExp("(\\$\\d)")),
carrier_code_pattern_(regexp_factory_->CreateRegExp("\\$CC")),
plus_chars_pattern_(regexp_factory_->CreateRegExp(
StrCat("[", PhoneNumberUtil::kPlusChars, "]+"))) {
StrCat("[", PhoneNumberUtil::kPlusChars, "]+"))),
rfc3966_global_number_digits_pattern_(regexp_factory_->CreateRegExp(
StrCat("^\\", kPlusSign, rfc3966_phone_digit_, "*", kDigits,
rfc3966_phone_digit_, "*$"))),
rfc3966_domainname_pattern_(regexp_factory_->CreateRegExp(StrCat(
"^(", rfc3966_domainlabel_, "\\.)*", rfc3966_toplabel_, "\\.?$"))) {
InitializeMapsAndSets();
}
@ -2118,30 +2147,78 @@ bool PhoneNumberUtil::CheckRegionForParsing(
return true;
}
// Extracts the value of the phone-context parameter of number_to_extract_from
// where the index of ";phone-context=" is parameter index_of_phone_context,
// following the syntax defined in RFC3966.
// Returns the extracted string_view (possibly empty), or a nullopt if no
// phone-context parameter is found.
absl::optional<string> PhoneNumberUtil::ExtractPhoneContext(
const string& number_to_extract_from,
const size_t index_of_phone_context) const {
// If no phone-context parameter is present
if (index_of_phone_context == std::string::npos) {
return absl::nullopt;
}
size_t phone_context_start =
index_of_phone_context + strlen(kRfc3966PhoneContext);
// If phone-context parameter is empty
if (phone_context_start >= number_to_extract_from.length()) {
return "";
}
size_t phone_context_end =
number_to_extract_from.find(';', phone_context_start);
// If phone-context is not the last parameter
if (phone_context_end != std::string::npos) {
return number_to_extract_from.substr(
phone_context_start, phone_context_end - phone_context_start);
} else {
return number_to_extract_from.substr(phone_context_start);
}
}
// Returns whether the value of phoneContext follows the syntax defined in
// RFC3966.
bool PhoneNumberUtil::IsPhoneContextValid(
const absl::optional<string> phone_context) const {
if (!phone_context.has_value()) {
return true;
}
if (phone_context.value().empty()) {
return false;
}
// Does phone-context value match pattern of global-number-digits or
// domainname
return reg_exps_->rfc3966_global_number_digits_pattern_->FullMatch(
std::string{phone_context.value()}) ||
reg_exps_->rfc3966_domainname_pattern_->FullMatch(
std::string{phone_context.value()});
}
// Converts number_to_parse to a form that we can parse and write it to
// national_number if it is written in RFC3966; otherwise extract a possible
// number out of it and write to national_number.
void PhoneNumberUtil::BuildNationalNumberForParsing(
PhoneNumberUtil::ErrorType PhoneNumberUtil::BuildNationalNumberForParsing(
const string& number_to_parse, string* national_number) const {
size_t index_of_phone_context = number_to_parse.find(kRfc3966PhoneContext);
if (index_of_phone_context != string::npos) {
size_t phone_context_start =
index_of_phone_context + strlen(kRfc3966PhoneContext);
absl::optional<string> phone_context =
ExtractPhoneContext(number_to_parse, index_of_phone_context);
if (!IsPhoneContextValid(phone_context)) {
VLOG(2) << "The phone-context value is invalid.";
return NOT_A_NUMBER;
}
if (phone_context.has_value()) {
// If the phone context contains a phone number prefix, we need to capture
// it, whereas domains will be ignored.
if (phone_context_start < (number_to_parse.length() - 1) &&
number_to_parse.at(phone_context_start) == kPlusSign[0]) {
if (phone_context.value().at(0) == kPlusSign[0]) {
// Additional parameters might follow the phone context. If so, we will
// remove them here because the parameters after phone context are not
// important for parsing the phone number.
size_t phone_context_end = number_to_parse.find(';', phone_context_start);
if (phone_context_end != string::npos) {
StrAppend(
national_number, number_to_parse.substr(
phone_context_start, phone_context_end - phone_context_start));
} else {
StrAppend(national_number, number_to_parse.substr(phone_context_start));
}
StrAppend(national_number, phone_context.value());
}
// Now append everything between the "tel:" prefix and the phone-context.
@ -2175,6 +2252,7 @@ void PhoneNumberUtil::BuildNationalNumberForParsing(
// we are concerned about deleting content from a potential number string
// when there is no strong evidence that the number is actually written in
// RFC3966.
return NO_PARSING_ERROR;
}
// Note if any new field is added to this method that should always be filled
@ -2189,7 +2267,11 @@ PhoneNumberUtil::ErrorType PhoneNumberUtil::ParseHelper(
DCHECK(phone_number);
string national_number;
BuildNationalNumberForParsing(number_to_parse, &national_number);
PhoneNumberUtil::ErrorType build_national_number_for_parsing_return =
BuildNationalNumberForParsing(number_to_parse, &national_number);
if (build_national_number_for_parsing_return != NO_PARSING_ERROR) {
return build_national_number_for_parsing_return;
}
if (!IsViablePhoneNumber(national_number)) {
VLOG(2) << "The string supplied did not seem to be a phone number.";


+ 8
- 2
cpp/src/phonenumbers/phonenumberutil.h View File

@ -958,8 +958,14 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
bool check_region,
PhoneNumber* phone_number) const;
void BuildNationalNumberForParsing(const string& number_to_parse,
string* national_number) const;
absl::optional<string> ExtractPhoneContext(
const string& number_to_extract_from,
size_t index_of_phone_context) const;
bool IsPhoneContextValid(absl::optional<string> phone_context) const;
ErrorType BuildNationalNumberForParsing(const string& number_to_parse,
string* national_number) const;
bool IsShorterThanPossibleNormalNumber(const PhoneMetadata* country_metadata,
const string& number) const;


+ 99
- 8
cpp/test/phonenumbers/phonenumberutil_test.cc View File

@ -111,6 +111,13 @@ class PhoneNumberUtilTest : public testing::Test {
return phone_util_.ContainsOnlyValidDigits(s);
}
void AssertThrowsForInvalidPhoneContext(const string number_to_parse) {
PhoneNumber actual_number;
EXPECT_EQ(
PhoneNumberUtil::NOT_A_NUMBER,
phone_util_.Parse(number_to_parse, RegionCode::ZZ(), &actual_number));
}
const PhoneNumberUtil& phone_util_;
private:
@ -3653,13 +3660,6 @@ TEST_F(PhoneNumberUtilTest, ParseNationalNumber) {
"tel:253-0000;isub=12345;phone-context=www.google.com",
RegionCode::US(), &test_number));
EXPECT_EQ(us_local_number, test_number);
// This is invalid because no "+" sign is present as part of phone-context.
// The phone context is simply ignored in this case just as if it contains a
// domain.
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:2530000;isub=12345;phone-context=1-650",
RegionCode::US(), &test_number));
EXPECT_EQ(us_local_number, test_number);
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:2530000;isub=12345;phone-context=1234.com",
RegionCode::US(), &test_number));
@ -4085,7 +4085,7 @@ TEST_F(PhoneNumberUtilTest, FailedParseOnInvalidNumbers) {
EXPECT_EQ(PhoneNumber::default_instance(), test_number);
// This is invalid because no "+" sign is present as part of phone-context.
// This should not succeed in being parsed.
EXPECT_EQ(PhoneNumberUtil::INVALID_COUNTRY_CODE_ERROR,
EXPECT_EQ(PhoneNumberUtil::NOT_A_NUMBER,
phone_util_.Parse("tel:555-1234;phone-context=1-331",
RegionCode::ZZ(), &test_number));
EXPECT_EQ(PhoneNumber::default_instance(), test_number);
@ -4703,6 +4703,97 @@ TEST_F(PhoneNumberUtilTest, ParseItalianLeadingZeros) {
EXPECT_EQ(zeros_number, test_number);
}
TEST_F(PhoneNumberUtilTest, ParseWithPhoneContext) {
PhoneNumber expected_number;
expected_number.set_country_code(64);
expected_number.set_national_number(33316005L);
PhoneNumber actual_number;
// context = ";phone-context=" descriptor
// descriptor = domainname / global-number-digits
// Valid global-phone-digits
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=+64",
RegionCode::ZZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=+64;{this isn't "
"part of phone-context anymore!}",
RegionCode::ZZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
expected_number.set_national_number(3033316005L);
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=+64-3",
RegionCode::ZZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
expected_number.set_country_code(55);
expected_number.set_national_number(5033316005L);
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=+(555)",
RegionCode::ZZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
expected_number.set_country_code(1);
expected_number.set_national_number(23033316005L);
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=+-1-2.3()",
RegionCode::ZZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
// Valid domainname
expected_number.set_country_code(64);
expected_number.set_national_number(33316005L);
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=abc.nz",
RegionCode::NZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
EXPECT_EQ(
PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=www.PHONE-numb3r.com",
RegionCode::NZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=a", RegionCode::NZ(),
&actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=3phone.J.",
RegionCode::NZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
actual_number.Clear();
EXPECT_EQ(PhoneNumberUtil::NO_PARSING_ERROR,
phone_util_.Parse("tel:033316005;phone-context=a--z",
RegionCode::NZ(), &actual_number));
EXPECT_EQ(expected_number, actual_number);
// Invalid descriptor
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=+");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=64");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=++64");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=+abc");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=.");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=3phone");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=a-.nz");
AssertThrowsForInvalidPhoneContext("tel:033316005;phone-context=a{b}c");
}
TEST_F(PhoneNumberUtilTest, CanBeInternationallyDialled) {
PhoneNumber test_number;
test_number.set_country_code(1);


+ 4
- 3
java/libphonenumber/src/com/google/i18n/phonenumbers/NumberParseException.java View File

@ -31,9 +31,10 @@ public class NumberParseException extends Exception {
*/
INVALID_COUNTRY_CODE,
/**
* This generally indicates the string passed in had less than 3 digits in it. More
* specifically, the number failed to match the regular expression VALID_PHONE_NUMBER in
* PhoneNumberUtil.java.
* This indicates the string passed is not a valid number. Either the string had less than 3
* digits in it or had an invalid phone-context parameter. More specifically, the number failed
* to match the regular expression VALID_PHONE_NUMBER, RFC3966_GLOBAL_NUMBER_DIGITS, or
* RFC3966_DOMAINNAME in PhoneNumberUtil.java.
*/
NOT_A_NUMBER,
/**


+ 80
- 15
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -306,6 +306,27 @@ public class PhoneNumberUtil {
private static final String EXTN_PATTERNS_FOR_PARSING = createExtnPattern(true);
static final String EXTN_PATTERNS_FOR_MATCHING = createExtnPattern(false);
// Regular expression of valid global-number-digits for the phone-context parameter, following the
// syntax defined in RFC3966.
private static final String RFC3966_VISUAL_SEPARATOR = "[\\-\\.\\(\\)]?";
private static final String RFC3966_PHONE_DIGIT =
"(" + DIGITS + "|" + RFC3966_VISUAL_SEPARATOR + ")";
private static final String RFC3966_GLOBAL_NUMBER_DIGITS =
"^\\" + PLUS_SIGN + RFC3966_PHONE_DIGIT + "*" + DIGITS + RFC3966_PHONE_DIGIT + "*$";
static final Pattern RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN =
Pattern.compile(RFC3966_GLOBAL_NUMBER_DIGITS);
// Regular expression of valid domainname for the phone-context parameter, following the syntax
// defined in RFC3966.
private static final String ALPHANUM = VALID_ALPHA + DIGITS;
private static final String RFC3966_DOMAINLABEL =
"[" + ALPHANUM + "]+((\\-)*[" + ALPHANUM + "])*";
private static final String RFC3966_TOPLABEL =
"[" + VALID_ALPHA + "]+((\\-)*[" + ALPHANUM + "])*";
private static final String RFC3966_DOMAINNAME =
"^(" + RFC3966_DOMAINLABEL + "\\.)*" + RFC3966_TOPLABEL + "\\.?$";
static final Pattern RFC3966_DOMAINNAME_PATTERN = Pattern.compile(RFC3966_DOMAINNAME);
/**
* Helper method for constructing regular expressions for parsing. Creates an expression that
* captures up to maxLength digits.
@ -3338,27 +3359,71 @@ public class PhoneNumberUtil {
phoneNumber.setNationalNumber(Long.parseLong(normalizedNationalNumber.toString()));
}
/**
* Extracts the value of the phone-context parameter of numberToExtractFrom where the index of
* ";phone-context=" is the parameter indexOfPhoneContext, following the syntax defined in
* RFC3966.
*
* @return the extracted string (possibly empty), or null if no phone-context parameter is found.
*/
private String extractPhoneContext(String numberToExtractFrom, int indexOfPhoneContext) {
// If no phone-context parameter is present
if (indexOfPhoneContext == -1) {
return null;
}
int phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT.length();
// If phone-context parameter is empty
if (phoneContextStart >= numberToExtractFrom.length()) {
return "";
}
int phoneContextEnd = numberToExtractFrom.indexOf(';', phoneContextStart);
// If phone-context is not the last parameter
if (phoneContextEnd != -1) {
return numberToExtractFrom.substring(phoneContextStart, phoneContextEnd);
} else {
return numberToExtractFrom.substring(phoneContextStart);
}
}
/**
* Returns whether the value of phoneContext follows the syntax defined in RFC3966.
*/
private boolean isPhoneContextValid(String phoneContext) {
if (phoneContext == null) {
return true;
}
if (phoneContext.length() == 0) {
return false;
}
// Does phone-context value match pattern of global-number-digits or domainname
return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN.matcher(phoneContext).matches()
|| RFC3966_DOMAINNAME_PATTERN.matcher(phoneContext).matches();
}
/**
* Converts numberToParse to a form that we can parse and write it to nationalNumber if it is
* written in RFC3966; otherwise extract a possible number out of it and write to nationalNumber.
*/
private void buildNationalNumberForParsing(String numberToParse, StringBuilder nationalNumber) {
private void buildNationalNumberForParsing(String numberToParse, StringBuilder nationalNumber)
throws NumberParseException {
int indexOfPhoneContext = numberToParse.indexOf(RFC3966_PHONE_CONTEXT);
if (indexOfPhoneContext >= 0) {
int phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT.length();
String phoneContext = extractPhoneContext(numberToParse, indexOfPhoneContext);
if (!isPhoneContextValid(phoneContext)) {
throw new NumberParseException(NumberParseException.ErrorType.NOT_A_NUMBER,
"The phone-context value is invalid.");
}
if (phoneContext != null) {
// If the phone context contains a phone number prefix, we need to capture it, whereas domains
// will be ignored.
if (phoneContextStart < (numberToParse.length() - 1)
&& numberToParse.charAt(phoneContextStart) == PLUS_SIGN) {
if (phoneContext.charAt(0) == PLUS_SIGN) {
// Additional parameters might follow the phone context. If so, we will remove them here
// because the parameters after phone context are not important for parsing the
// phone number.
int phoneContextEnd = numberToParse.indexOf(';', phoneContextStart);
if (phoneContextEnd > 0) {
nationalNumber.append(numberToParse.substring(phoneContextStart, phoneContextEnd));
} else {
nationalNumber.append(numberToParse.substring(phoneContextStart));
}
// because the parameters after phone context are not important for parsing the phone
// number.
nationalNumber.append(phoneContext);
}
// Now append everything between the "tel:" prefix and the phone-context. This should include
@ -3366,8 +3431,8 @@ public class PhoneNumberUtil {
// handle the case when "tel:" is missing, as we have seen in some of the phone number inputs.
// In that case, we append everything from the beginning.
int indexOfRfc3966Prefix = numberToParse.indexOf(RFC3966_PREFIX);
int indexOfNationalNumber = (indexOfRfc3966Prefix >= 0)
? indexOfRfc3966Prefix + RFC3966_PREFIX.length() : 0;
int indexOfNationalNumber =
(indexOfRfc3966Prefix >= 0) ? indexOfRfc3966Prefix + RFC3966_PREFIX.length() : 0;
nationalNumber.append(numberToParse.substring(indexOfNationalNumber, indexOfPhoneContext));
} else {
// Extract a possible number from the string passed in (this strips leading characters that


+ 66
- 7
java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java View File

@ -2122,10 +2122,6 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase {
phoneUtil.parse("tel:253-0000;phone-context=www.google.com", RegionCode.US));
assertEquals(US_LOCAL_NUMBER,
phoneUtil.parse("tel:253-0000;isub=12345;phone-context=www.google.com", RegionCode.US));
// This is invalid because no "+" sign is present as part of phone-context. The phone context
// is simply ignored in this case just as if it contains a domain.
assertEquals(US_LOCAL_NUMBER,
phoneUtil.parse("tel:2530000;isub=12345;phone-context=1-650", RegionCode.US));
assertEquals(US_LOCAL_NUMBER,
phoneUtil.parse("tel:2530000;isub=12345;phone-context=1234.com", RegionCode.US));
@ -2539,18 +2535,18 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase {
// succeed in being parsed.
String invalidRfcPhoneContext = "tel:555-1234;phone-context=1-331";
phoneUtil.parse(invalidRfcPhoneContext, RegionCode.ZZ);
fail("'Unknown' region code not allowed: should fail.");
fail("phone-context is missing '+' sign: should fail.");
} catch (NumberParseException e) {
// Expected this exception.
assertEquals("Wrong error type stored in exception.",
NumberParseException.ErrorType.INVALID_COUNTRY_CODE,
NumberParseException.ErrorType.NOT_A_NUMBER,
e.getErrorType());
}
try {
// Only the phone-context symbol is present, but no data.
String invalidRfcPhoneContext = ";phone-context=";
phoneUtil.parse(invalidRfcPhoneContext, RegionCode.ZZ);
fail("No number is present: should fail.");
fail("phone-context can't be empty: should fail.");
} catch (NumberParseException e) {
// Expected this exception.
assertEquals("Wrong error type stored in exception.",
@ -2895,6 +2891,69 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase {
assertEquals(threeZeros, phoneUtil.parse("0000", RegionCode.AU));
}
public void testParseWithPhoneContext() throws Exception {
// context = ";phone-context=" descriptor
// descriptor = domainname / global-number-digits
// Valid global-phone-digits
assertEquals(NZ_NUMBER, phoneUtil.parse("tel:033316005;phone-context=+64", RegionCode.ZZ));
assertEquals(
NZ_NUMBER,
phoneUtil.parse(
"tel:033316005;phone-context=+64;{this isn't part of phone-context anymore!}",
RegionCode.ZZ));
PhoneNumber nzFromPhoneContext = new PhoneNumber();
nzFromPhoneContext.setCountryCode(64).setNationalNumber(3033316005L);
assertEquals(
nzFromPhoneContext,
phoneUtil.parse("tel:033316005;phone-context=+64-3", RegionCode.ZZ));
PhoneNumber brFromPhoneContext = new PhoneNumber();
brFromPhoneContext.setCountryCode(55).setNationalNumber(5033316005L);
assertEquals(
brFromPhoneContext,
phoneUtil.parse("tel:033316005;phone-context=+(555)", RegionCode.ZZ));
PhoneNumber usFromPhoneContext = new PhoneNumber();
usFromPhoneContext.setCountryCode(1).setNationalNumber(23033316005L);
assertEquals(
usFromPhoneContext,
phoneUtil.parse("tel:033316005;phone-context=+-1-2.3()", RegionCode.ZZ));
// Valid domainname
assertEquals(NZ_NUMBER, phoneUtil.parse("tel:033316005;phone-context=abc.nz", RegionCode.NZ));
assertEquals(
NZ_NUMBER,
phoneUtil.parse("tel:033316005;phone-context=www.PHONE-numb3r.com", RegionCode.NZ));
assertEquals(NZ_NUMBER, phoneUtil.parse("tel:033316005;phone-context=a", RegionCode.NZ));
assertEquals(
NZ_NUMBER, phoneUtil.parse("tel:033316005;phone-context=3phone.J.", RegionCode.NZ));
assertEquals(NZ_NUMBER, phoneUtil.parse("tel:033316005;phone-context=a--z", RegionCode.NZ));
// Invalid descriptor
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=+");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=64");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=++64");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=+abc");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=.");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=3phone");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=a-.nz");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=a{b}c");
}
private void assertThrowsForInvalidPhoneContext(String numberToParse) {
final String numberToParseFinal = numberToParse;
assertEquals(
NumberParseException.ErrorType.NOT_A_NUMBER,
assertThrows(
NumberParseException.class, new ThrowingRunnable() {
@Override
public void run() throws Throwable {
phoneUtil.parse(numberToParseFinal, RegionCode.ZZ);
}
})
.getErrorType());
}
public void testCountryWithNoNumberDesc() {
// Andorra is a country where we don't have PhoneNumberDesc info in the metadata.
PhoneNumber adNumber = new PhoneNumber();


+ 67
- 67
javascript/i18n/phonenumbers/demo-compiled.js View File

@ -3,16 +3,16 @@
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var ca=ba(this);
function da(a,b){if(b)a:{var c=ca;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))break a;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&aa(c,a,{configurable:!0,writable:!0,value:b})}}da("Object.is",function(a){return a?a:function(b,c){return b===c?0!==b||1/b===1/c:b!==b&&c!==c}});
da("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c<e;c++){var f=d[c];if(f===b||Object.is(f,b))return!0}return!1}});
da("String.prototype.includes",function(a){return a?a:function(b,c){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(b,c||0)}});var ea=this||self;function fa(a){a.fa=void 0;a.ea=function(){return a.fa?a.fa:a.fa=new a}}
function h(a,b){function c(){}c.prototype=b.prototype;a.ga=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.qa=function(d,e,f){for(var g=Array(arguments.length-2),k=2;k<arguments.length;k++)g[k-2]=arguments[k];return b.prototype[e].apply(d,g)}};function l(a){if(Error.captureStackTrace)Error.captureStackTrace(this,l);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))}h(l,Error);l.prototype.name="CustomError";function ha(a,b){a=a.split("%s");for(var c="",d=a.length-1,e=0;e<d;e++)c+=a[e]+(e<b.length?b[e]:"%s");l.call(this,c+a[d])}h(ha,l);ha.prototype.name="AssertionError";function ia(a,b){throw new ha("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};function ja(a,b){a.sort(b||ka)}function ka(a,b){return a>b?1:a<b?-1:0};function la(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function ma(a,b){a:{for(var c in a)if(b.call(void 0,a[c],c,a)){b=c;break a}b=void 0}return b&&a[b]};function na(a){return String(a).replace(/\-([a-z])/g,function(b,c){return c.toUpperCase()})};function n(a){var b=document;return"string"===typeof a?b.getElementById(a):a};function oa(a,b){this.a=a;this.j=b.name;this.f=!!b.v;this.b=b.c;this.l=b.type;this.i=!1;switch(this.b){case pa:case qa:case ra:case sa:case ta:case ua:case va:this.i=!0}this.g=b.defaultValue}var va=1,ua=2,pa=3,qa=4,ra=6,sa=16,ta=18;function wa(a,b){this.b=a;this.a={};for(a=0;a<b.length;a++){var c=b[a];this.a[c.a]=c}}function xa(a){a=la(a.a);ja(a,function(b,c){return b.a-c.a});return a}function ya(a,b){return ma(a.a,function(c){return c.j==b})||null};function p(){this.b={};this.f=this.h().a;this.a=this.g=null}function za(a,b){for(var c in a.b){var d=Number(c);a.f[d]||b.call(a,d,a.b[c])}}p.prototype.has=function(a){return q(this,a.a)};p.prototype.get=function(a,b){return r(this,a.a,b)};p.prototype.set=function(a,b){u(this,a.a,b)};p.prototype.add=function(a,b){Aa(this,a.a,b)};
function Ba(a,b){for(var c=xa(a.h()),d=0;d<c.length;d++){var e=c[d],f=e.a;if(q(b,f)){a.a&&delete a.a[e.a];var g=11==e.b||10==e.b;if(e.f){e=v(b,f);for(var k=0;k<e.length;k++)Aa(a,f,g?e[k].clone():e[k])}else e=Ca(b,f),g?(g=Ca(a,f))?Ba(g,e):u(a,f,e.clone()):u(a,f,e)}}}p.prototype.clone=function(){var a=new this.constructor;a!=this&&(a.b={},a.a&&(a.a={}),Ba(a,this));return a};function q(a,b){return null!=a.b[b]}
function Ca(a,b){var c=a.b[b];if(null==c)return null;if(a.g){if(!(b in a.a)){var d=a.g,e=a.f[b];if(null!=c)if(e.f){for(var f=[],g=0;g<c.length;g++)f[g]=d.a(e,c[g]);c=f}else c=d.a(e,c);return a.a[b]=c}return a.a[b]}return c}function r(a,b,c){var d=Ca(a,b);return a.f[b].f?d[c||0]:d}function w(a,b){if(q(a,b))a=r(a,b,void 0);else a:{a=a.f[b];if(void 0===a.g)if(b=a.l,b===Boolean)a.g=!1;else if(b===Number)a.g=0;else if(b===String)a.g=a.i?"0":"";else{a=new b;break a}a=a.g}return a}
function v(a,b){return Ca(a,b)||[]}function x(a,b){return a.f[b].f?q(a,b)?a.b[b].length:0:q(a,b)?1:0}function u(a,b,c){a.b[b]=c;a.a&&(a.a[b]=c)}function Aa(a,b,c){a.b[b]||(a.b[b]=[]);a.b[b].push(c);a.a&&delete a.a[b]}function Da(a,b){delete a.b[b];a.a&&delete a.a[b]}function Ea(a,b){var c=[],d;for(d in b)0!=d&&c.push(new oa(d,b[d]));return new wa(a,c)};function y(){}y.prototype.b=function(a,b){return 11==a.b||10==a.b?this.g(b):"number"!==typeof b||isFinite(b)?b:b.toString()};y.prototype.f=function(a,b){a=new a.b;this.i(a,b);return a};
y.prototype.a=function(a,b){if(11==a.b||10==a.b)return b instanceof p?b:this.f(a.l.prototype.h(),b);if(14==a.b)return"string"===typeof b&&Fa.test(b)&&(a=Number(b),0<a)?a:b;if(!a.i)return b;a=a.l;if(a===String){if("number"===typeof b)return String(b)}else if(a===Number&&"string"===typeof b&&("Infinity"===b||"-Infinity"===b||"NaN"===b||Fa.test(b)))return Number(b);return b};var Fa=/^-?[0-9]+$/;function z(a,b,c){this.j=a;this.m=b;this.l=c}h(z,y);z.prototype.g=function(a){for(var b=xa(a.h()),c={},d=0;d<b.length;d++){var e=b[d],f=e.a;switch(this.j){case 1:f=e.j;break;case 2:f=na(e.j.replace(/_/g,"-"))}if(a.has(e))if(e.f){var g=[];c[f]=g;for(f=0;f<x(a,e.a);f++)g.push(this.b(e,a.get(e,f)))}else c[f]=this.b(e,a.get(e))}za(a,function(k,m){c[k]=m});return c};z.prototype.b=function(a,b){return this.m&&8==a.b&&"boolean"===typeof b?b?1:0:z.ga.b.call(this,a,b)};
z.prototype.a=function(a,b){return 8==a.b&&"number"===typeof b?!!b:z.ga.a.call(this,a,b)};z.prototype.i=function(a,b){var c=a.h(),d;for(d in b){var e=b[d],f=!/[^0-9]/.test(d);if(f)var g=c.a[parseInt(d,10)]||null;else 2==this.j&&(d=String(d).replace(/([A-Z])/g,"-$1").toLowerCase().replace(/\-/g,"_")),g=ya(c,d);if(g)if(g.f)for(f=0;f<e.length;f++)a.add(g,this.a(g,e[f]));else a.set(g,this.a(g,e));else f?(g=a,f=Number(d),g.b[f]=e,g.a&&delete g.a[f]):this.l||ia("Failed to find field: "+d)}};function A(a,b){null!=a&&this.a.apply(this,arguments)}A.prototype.b="";A.prototype.set=function(a){this.b=""+a};A.prototype.a=function(a,b,c){this.b+=String(a);if(null!=b)for(var d=1;d<arguments.length;d++)this.b+=arguments[d];return this};function B(a){a.b=""}A.prototype.toString=function(){return this.b};/*
var ba="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};function ca(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var da=ca(this);
function ea(a,b){if(b)a:{var c=da;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&ba(c,a,{configurable:!0,writable:!0,value:b})}}ea("Object.is",function(a){return a?a:function(b,c){return b===c?0!==b||1/b===1/c:b!==b&&c!==c}});
ea("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var f=d.length;c=c||0;for(0>c&&(c=Math.max(c+f,0));c<f;c++){var e=d[c];if(e===b||Object.is(e,b))return!0}return!1}});
ea("String.prototype.includes",function(a){return a?a:function(b,c){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(b,c||0)}});var fa=this||self;function na(a){a.ka=void 0;a.ja=function(){return a.ka?a.ka:a.ka=new a}}
function k(a,b){function c(){}c.prototype=b.prototype;a.la=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.ua=function(d,f,e){for(var g=Array(arguments.length-2),h=2;h<arguments.length;h++)g[h-2]=arguments[h];return b.prototype[f].apply(d,g)}};function oa(a){if(Error.captureStackTrace)Error.captureStackTrace(this,oa);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))}k(oa,Error);oa.prototype.name="CustomError";function pa(a,b){a=a.split("%s");for(var c="",d=a.length-1,f=0;f<d;f++)c+=a[f]+(f<b.length?b[f]:"%s");oa.call(this,c+a[d])}k(pa,oa);pa.prototype.name="AssertionError";function qa(a,b){throw new pa("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};function ra(a,b){a.sort(b||sa)}function sa(a,b){return a>b?1:a<b?-1:0};function ta(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function ua(a,b){a:{for(var c in a)if(b.call(void 0,a[c],c,a)){b=c;break a}b=void 0}return b&&a[b]};function va(a){return String(a).replace(/\-([a-z])/g,function(b,c){return c.toUpperCase()})};function wa(a){var b=document;return"string"===typeof a?b.getElementById(a):a};function xa(a,b){this.g=a;this.o=b.name;this.j=!!b.aa;this.h=b.i;this.u=b.type;this.s=!1;switch(this.h){case ya:case za:case Ea:case Fa:case Ga:case Ha:case Ia:this.s=!0}this.l=b.defaultValue}var Ia=1,Ha=2,ya=3,za=4,Ea=6,Fa=16,Ga=18;function Ja(a,b){this.h=a;this.g={};for(a=0;a<b.length;a++){var c=b[a];this.g[c.g]=c}}function Ka(a){a=ta(a.g);ra(a,function(b,c){return b.g-c.g});return a}function La(a,b){return ua(a.g,function(c){return c.o==b})||null};function l(){this.h={};this.j=this.m().g;this.g=this.l=null}function Ma(a,b){for(var c in a.h){var d=Number(c);a.j[d]||b.call(a,d,a.h[c])}}l.prototype.has=function(a){return n(this,a.g)};l.prototype.get=function(a,b){return q(this,a.g,b)};l.prototype.set=function(a,b){t(this,a.g,b)};l.prototype.add=function(a,b){Na(this,a.g,b)};
function Oa(a,b){for(var c=Ka(a.m()),d=0;d<c.length;d++){var f=c[d],e=f.g;if(n(b,e)){a.g&&delete a.g[f.g];var g=11==f.h||10==f.h;if(f.j){f=u(b,e);for(var h=0;h<f.length;h++)Na(a,e,g?f[h].clone():f[h])}else f=Pa(b,e),g?(g=Pa(a,e))?Oa(g,f):t(a,e,f.clone()):t(a,e,f)}}}l.prototype.clone=function(){var a=new this.constructor;a!=this&&(a.h={},a.g&&(a.g={}),Oa(a,this));return a};function n(a,b){return null!=a.h[b]}
function Pa(a,b){var c=a.h[b];if(null==c)return null;if(a.l){if(!(b in a.g)){var d=a.l,f=a.j[b];if(null!=c)if(f.j){for(var e=[],g=0;g<c.length;g++)e[g]=d.g(f,c[g]);c=e}else c=d.g(f,c);return a.g[b]=c}return a.g[b]}return c}function q(a,b,c){var d=Pa(a,b);return a.j[b].j?d[c||0]:d}function v(a,b){if(n(a,b))a=q(a,b,void 0);else a:{a=a.j[b];if(void 0===a.l)if(b=a.u,b===Boolean)a.l=!1;else if(b===Number)a.l=0;else if(b===String)a.l=a.s?"0":"";else{a=new b;break a}a=a.l}return a}
function u(a,b){return Pa(a,b)||[]}function w(a,b){return a.j[b].j?n(a,b)?a.h[b].length:0:n(a,b)?1:0}function t(a,b,c){a.h[b]=c;a.g&&(a.g[b]=c)}function Na(a,b,c){a.h[b]||(a.h[b]=[]);a.h[b].push(c);a.g&&delete a.g[b]}function Qa(a,b){delete a.h[b];a.g&&delete a.g[b]}function Ra(a,b){var c=[],d;for(d in b)0!=d&&c.push(new xa(d,b[d]));return new Ja(a,c)};function x(){}x.prototype.h=function(a,b){return 11==a.h||10==a.h?this.l(b):"number"!==typeof b||isFinite(b)?b:b.toString()};x.prototype.j=function(a,b){a=new a.h;this.o(a,b);return a};
x.prototype.g=function(a,b){if(11==a.h||10==a.h)return b instanceof l?b:this.j(a.u.prototype.m(),b);if(14==a.h)return"string"===typeof b&&$a.test(b)&&(a=Number(b),0<a)?a:b;if(!a.s)return b;a=a.u;if(a===String){if("number"===typeof b)return String(b)}else if(a===Number&&"string"===typeof b&&("Infinity"===b||"-Infinity"===b||"NaN"===b||$a.test(b)))return Number(b);return b};var $a=/^-?[0-9]+$/;function y(a,b,c){this.s=a;this.v=b;this.u=c}k(y,x);y.prototype.l=function(a){for(var b=Ka(a.m()),c={},d=0;d<b.length;d++){var f=b[d],e=f.g;switch(this.s){case 1:e=f.o;break;case 2:e=va(f.o.replace(/_/g,"-"))}if(a.has(f))if(f.j){var g=[];c[e]=g;for(e=0;e<w(a,f.g);e++)g.push(this.h(f,a.get(f,e)))}else c[e]=this.h(f,a.get(f))}Ma(a,function(h,m){c[h]=m});return c};y.prototype.h=function(a,b){return this.v&&8==a.h&&"boolean"===typeof b?b?1:0:y.la.h.call(this,a,b)};
y.prototype.g=function(a,b){return 8==a.h&&"number"===typeof b?!!b:y.la.g.call(this,a,b)};y.prototype.o=function(a,b){var c=a.m(),d;for(d in b){var f=b[d],e=!/[^0-9]/.test(d);if(e)var g=c.g[parseInt(d,10)]||null;else 2==this.s&&(d=String(d).replace(/([A-Z])/g,"-$1").toLowerCase().replace(/\-/g,"_")),g=La(c,d);if(g)if(g.j)for(e=0;e<f.length;e++)a.add(g,this.g(g,f[e]));else a.set(g,this.g(g,f));else e?(g=a,e=Number(d),g.h[e]=f,g.g&&delete g.g[e]):this.u||qa("Failed to find field: "+d)}};function z(a,b){null!=a&&this.g.apply(this,arguments)}z.prototype.h="";z.prototype.set=function(a){this.h=""+a};z.prototype.g=function(a,b,c){this.h+=String(a);if(null!=b)for(var d=1;d<arguments.length;d++)this.h+=arguments[d];return this};function A(a){a.h=""}z.prototype.toString=function(){return this.h};/*
Protocol Buffer 2 Copyright 2008 Google Inc.
All other code copyright its respective owners.
@ -30,14 +30,14 @@ z.prototype.a=function(a,b){return 8==a.b&&"number"===typeof b?!!b:z.ga.a.call(t
See the License for the specific language governing permissions and
limitations under the License.
*/
function C(){p.call(this)}h(C,p);var Ga=null;function D(){p.call(this)}h(D,p);var Ha=null;function E(){p.call(this)}h(E,p);var Ia=null;
C.prototype.h=function(){var a=Ga;a||(Ga=a=Ea(C,{0:{name:"NumberFormat",da:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",v:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}}));return a};C.h=C.prototype.h;
D.prototype.h=function(){var a=Ha;a||(Ha=a=Ea(D,{0:{name:"PhoneNumberDesc",da:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},9:{name:"possible_length",v:!0,c:5,type:Number},10:{name:"possible_length_local_only",v:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String}}));return a};D.h=D.prototype.h;
E.prototype.h=function(){var a=Ia;a||(Ia=a=Ea(E,{0:{name:"PhoneMetadata",da:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:D},2:{name:"fixed_line",c:11,type:D},3:{name:"mobile",c:11,type:D},4:{name:"toll_free",c:11,type:D},5:{name:"premium_rate",c:11,type:D},6:{name:"shared_cost",c:11,type:D},7:{name:"personal_number",c:11,type:D},8:{name:"voip",c:11,type:D},21:{name:"pager",c:11,type:D},25:{name:"uan",c:11,type:D},27:{name:"emergency",c:11,type:D},28:{name:"voicemail",c:11,type:D},
29:{name:"short_code",c:11,type:D},30:{name:"standard_rate",c:11,type:D},31:{name:"carrier_specific",c:11,type:D},33:{name:"sms_services",c:11,type:D},24:{name:"no_international_dialling",c:11,type:D},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",
c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,type:Boolean},19:{name:"number_format",v:!0,c:11,type:C},20:{name:"intl_number_format",v:!0,c:11,type:C},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String}}));return a};E.h=E.prototype.h;function Ja(){}h(Ja,y);Ja.prototype.f=function(a,b){a=new a.b;a.g=this;a.b=b;a.a={};return a};Ja.prototype.i=function(){throw Error("Unimplemented");};function F(){}h(F,Ja);F.prototype.g=function(a){for(var b=xa(a.h()),c=[],d=0;d<b.length;d++){var e=b[d];if(a.has(e)){var f=e.a;if(e.f){c[f]=[];for(var g=0;g<x(a,e.a);g++)c[f][g]=this.b(e,a.get(e,g))}else c[f]=this.b(e,a.get(e))}}za(a,function(k,m){c[k]=m});return c};F.prototype.b=function(a,b){return 8==a.b?b?1:0:y.prototype.b.apply(this,arguments)};F.prototype.a=function(a,b){return 8==a.b?!!b:y.prototype.a.apply(this,arguments)};F.prototype.f=function(a,b){return F.ga.f.call(this,a,b)};function G(){p.call(this)}h(G,p);var Ka=null,La={pa:0,oa:1,na:5,ma:10,la:20};
G.prototype.h=function(){var a=Ka;a||(Ka=a=Ea(G,{0:{name:"PhoneNumber",da:"i18n.phonenumbers.PhoneNumber"},1:{name:"country_code",required:!0,c:5,type:Number},2:{name:"national_number",required:!0,c:4,type:Number},3:{name:"extension",c:9,type:String},4:{name:"italian_leading_zero",c:8,type:Boolean},8:{name:"number_of_leading_zeros",c:5,defaultValue:1,type:Number},5:{name:"raw_input",c:9,type:String},6:{name:"country_code_source",c:14,defaultValue:0,type:La},7:{name:"preferred_domestic_carrier_code",
c:9,type:String}}));return a};G.ctor=G;G.ctor.h=G.prototype.h;/*
function D(){l.call(this)}k(D,l);var ab=null;function E(){l.call(this)}k(E,l);var bb=null;function F(){l.call(this)}k(F,l);var cb=null;
D.prototype.m=function(){var a=ab;a||(ab=a=Ra(D,{0:{name:"NumberFormat",ia:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,i:9,type:String},2:{name:"format",required:!0,i:9,type:String},3:{name:"leading_digits_pattern",aa:!0,i:9,type:String},4:{name:"national_prefix_formatting_rule",i:9,type:String},6:{name:"national_prefix_optional_when_formatting",i:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",i:9,type:String}}));return a};D.m=D.prototype.m;
E.prototype.m=function(){var a=bb;a||(bb=a=Ra(E,{0:{name:"PhoneNumberDesc",ia:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",i:9,type:String},9:{name:"possible_length",aa:!0,i:5,type:Number},10:{name:"possible_length_local_only",aa:!0,i:5,type:Number},6:{name:"example_number",i:9,type:String}}));return a};E.m=E.prototype.m;
F.prototype.m=function(){var a=cb;a||(cb=a=Ra(F,{0:{name:"PhoneMetadata",ia:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",i:11,type:E},2:{name:"fixed_line",i:11,type:E},3:{name:"mobile",i:11,type:E},4:{name:"toll_free",i:11,type:E},5:{name:"premium_rate",i:11,type:E},6:{name:"shared_cost",i:11,type:E},7:{name:"personal_number",i:11,type:E},8:{name:"voip",i:11,type:E},21:{name:"pager",i:11,type:E},25:{name:"uan",i:11,type:E},27:{name:"emergency",i:11,type:E},28:{name:"voicemail",i:11,type:E},
29:{name:"short_code",i:11,type:E},30:{name:"standard_rate",i:11,type:E},31:{name:"carrier_specific",i:11,type:E},33:{name:"sms_services",i:11,type:E},24:{name:"no_international_dialling",i:11,type:E},9:{name:"id",required:!0,i:9,type:String},10:{name:"country_code",i:5,type:Number},11:{name:"international_prefix",i:9,type:String},17:{name:"preferred_international_prefix",i:9,type:String},12:{name:"national_prefix",i:9,type:String},13:{name:"preferred_extn_prefix",i:9,type:String},15:{name:"national_prefix_for_parsing",
i:9,type:String},16:{name:"national_prefix_transform_rule",i:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",i:8,defaultValue:!1,type:Boolean},19:{name:"number_format",aa:!0,i:11,type:D},20:{name:"intl_number_format",aa:!0,i:11,type:D},22:{name:"main_country_for_code",i:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",i:9,type:String}}));return a};F.m=F.prototype.m;function db(){}k(db,x);db.prototype.j=function(a,b){a=new a.h;a.l=this;a.h=b;a.g={};return a};db.prototype.o=function(){throw Error("Unimplemented");};function G(){}k(G,db);G.prototype.l=function(a){for(var b=Ka(a.m()),c=[],d=0;d<b.length;d++){var f=b[d];if(a.has(f)){var e=f.g;if(f.j){c[e]=[];for(var g=0;g<w(a,f.g);g++)c[e][g]=this.h(f,a.get(f,g))}else c[e]=this.h(f,a.get(f))}}Ma(a,function(h,m){c[h]=m});return c};G.prototype.h=function(a,b){return 8==a.h?b?1:0:x.prototype.h.apply(this,arguments)};G.prototype.g=function(a,b){return 8==a.h?!!b:x.prototype.g.apply(this,arguments)};G.prototype.j=function(a,b){return G.la.j.call(this,a,b)};function H(){l.call(this)}k(H,l);var eb=null,fb={ta:0,sa:1,ra:5,qa:10,pa:20};
H.prototype.m=function(){var a=eb;a||(eb=a=Ra(H,{0:{name:"PhoneNumber",ia:"i18n.phonenumbers.PhoneNumber"},1:{name:"country_code",required:!0,i:5,type:Number},2:{name:"national_number",required:!0,i:4,type:Number},3:{name:"extension",i:9,type:String},4:{name:"italian_leading_zero",i:8,type:Boolean},8:{name:"number_of_leading_zeros",i:5,defaultValue:1,type:Number},5:{name:"raw_input",i:9,type:String},6:{name:"country_code_source",i:14,defaultValue:0,type:fb},7:{name:"preferred_domestic_carrier_code",
i:9,type:String}}));return a};H.ctor=H;H.ctor.m=H.prototype.m;/*
Copyright (C) 2010 The Libphonenumber Authors
@ -53,11 +53,11 @@ c:9,type:String}}));return a};G.ctor=G;G.ctor.h=G.prototype.h;/*
See the License for the specific language governing permissions and
limitations under the License.
*/
var H={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" "),7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],
var I={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" "),7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],
86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],
253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],
386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],
691:["FM"],692:["MH"],800:["001"],808:["001"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],870:["001"],878:["001"],880:["BD"],881:["001"],882:["001"],883:["001"],886:["TW"],888:["001"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],979:["001"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},Ma={AC:[,[,,"(?:[01589]\\d|[46])\\d{4}",
691:["FM"],692:["MH"],800:["001"],808:["001"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],870:["001"],878:["001"],880:["BD"],881:["001"],882:["001"],883:["001"],886:["TW"],888:["001"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],979:["001"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},gb={AC:[,[,,"(?:[01589]\\d|[46])\\d{4}",
,,,,,,[5,6]],[,,"6[2-467]\\d{3}",,,,"62889",,,[5]],[,,"4\\d{4}",,,,"40123",,,[5]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AC",247,"00",,,,,,,,,,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"(?:0[1-9]|[1589]\\d)\\d{4}",,,,"542011",,,[6]],,,[,,,,,,,,,[-1]]],AD:[,[,,"(?:1|6\\d)\\d{7}|[135-9]\\d{5}",,,,,,,[6,8,9]],[,,"[78]\\d{5}",,,,"712345",,,[6]],[,,"690\\d{6}|[356]\\d{5}",,,,"312345",,,[6,9]],[,,"180[02]\\d{4}",,,,"18001234",,,[8]],[,,"[19]\\d{5}",,,,"912345",,,[6]],
[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AD",376,"00",,,,,,,,[[,"(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],[,"(\\d{4})(\\d{4})","$1 $2",["1"]],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],,[,,,,,,,,,[-1]],,,[,,"1800\\d{4}",,,,,,,[8]],[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]]],AE:[,[,,"(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",,,,,,,[5,6,7,8,9,10,11,12]],[,,"[2-4679][2-8]\\d{6}",,,,"22345678",,,[8],[7]],[,,"5[024-68]\\d{7}",,,,"501234567",,,[9]],[,,"400\\d{6}|800\\d{2,9}",,,,"800123456"],
[,,"900[02]\\d{5}",,,,"900234567",,,[9]],[,,"700[05]\\d{5}",,,,"700012345",,,[9]],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],"AE",971,"00","0",,,"0",,,,[[,"(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],[,"(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],[,"(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],,[,,,,,,,,,[-1]],,,[,,,,,,,,,[-1]],[,,"600[25]\\d{5}",,,,"600212345",,,[9]],,,[,,,,,,,,,[-1]]],AF:[,[,,"[2-7]\\d{8}",,,,,,,[9],[7]],[,,"(?:[25][0-8]|[34][0-4]|6[0-5])[2-9]\\d{6}",
@ -483,45 +483,41 @@ SJ:[,[,,"0\\d{4}|(?:[489]\\d|[57]9)\\d{6}",,,,,,,[5,8]],[,,"79\\d{6}",,,,"791234
See the License for the specific language governing permissions and
limitations under the License.
*/
function Na(){this.a={}}fa(Na);
var I={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9"},Oa={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",
7:"7",8:"8",9:"9","+":"+","*":"*","#":"#"},Pa={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9",A:"2",
B:"2",C:"2",D:"3",E:"3",F:"3",G:"4",H:"4",I:"4",J:"5",K:"5",L:"5",M:"6",N:"6",O:"6",P:"7",Q:"7",R:"7",S:"7",T:"8",U:"8",V:"8",W:"9",X:"9",Y:"9",Z:"9"},Qa=/[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?/,Ra=/[+\uff0b]+/,J=/^[+\uff0b]+/,Sa=/([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9])/,Ta=/[+\uff0b0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]/,Ua=/[\\\/] *x/,Va=/[^0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9A-Za-z#]+$/,Wa=/(?:.*?[A-Za-z]){3}.*/;
function K(a){return"([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,"+a+"})"}
function Xa(){return";ext="+K("20")+"|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|\u0434\u043e\u0431|anexo)[:\\.\uff0e]?[ \u00a0\\t,-]*"+(K("20")+"#?|[ \u00a0\\t,]*(?:[x\uff58#\uff03~\uff5e]|int|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*")+(K("9")+"#?|[- ]+")+(K("6")+"#|[ \u00a0\\t]*(?:,{2}|;)[:\\.\uff0e]?[ \u00a0\\t,-]*")+(K("15")+"#?|[ \u00a0\\t]*(?:,)+[:\\.\uff0e]?[ \u00a0\\t,-]*")+(K("9")+"#?")}
var Ya=new RegExp("(?:"+Xa()+")$","i"),Za=new RegExp("^[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{2}$|^[+\uff0b]*(?:[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*]*[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]){3,}[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]*(?:"+Xa()+")?$","i"),$a=/(\$\d)/,
ab=/\$NP/,bb=/\$FG/,cb=/\$CC/,db=/^\(?\$1\)?$/;function eb(a){var b=a.search(Ta);0<=b?(a=a.substring(b),a=a.replace(Va,""),b=a.search(Ua),0<=b&&(a=a.substring(0,b))):a="";return a}function fb(a){return 2>a.length?!1:L(Za,a)}function gb(a){return L(Wa,a)?M(a,Pa):M(a,I)}function hb(a){var b=gb(a.toString());B(a);a.a(b)}function ib(a){return null!=a&&(1!=x(a,9)||-1!=v(a,9)[0])}
function M(a,b){for(var c=new A,d,e=a.length,f=0;f<e;++f)d=a.charAt(f),d=b[d.toUpperCase()],null!=d&&c.a(d);return c.toString()}function jb(a){return 0==a.length||db.test(a)}function kb(a){return null!=a&&isNaN(a)&&a.toUpperCase()in Ma}function N(a,b,c){if(0==r(b,2)&&q(b,5)){var d=w(b,5);if(0<d.length)return d}d=w(b,1);var e=P(b);if(0==c)return Q(d,0,e,"");if(!(d in H))return e;a=R(a,d,S(d));b=lb(b,a,c);e=mb(e,a,c);return Q(d,c,e,b)}
function nb(a,b,c){var d=w(b,1),e=P(b);if(!(d in H))return e;a=R(a,d,S(d));b=lb(b,a,2);c=mb(e,a,2,c);return Q(d,2,c,b)}function R(a,b,c){return"001"==c?T(a,""+b):T(a,c)}function ob(a,b){return nb(a,b,0<w(b,7).length?w(b,7):"")}
function pb(a){var b=U,c=w(a,1);if(!(c in H))return q(a,5)?w(a,5):"";var d="";a=a.clone();Da(a,3);var e=S(c),f=qb(b,a),g=-1!=f;if("US"==e)if(d=0==f||1==f||2==f,"BR"==e&&d)d=0<w(a,7).length?ob(b,a):"";else if(1==c){c=T(b,"US");if(d=rb(b,a))d=P(a),d=2!=V(b,d,c,-1);d=d?N(b,a,1):N(b,a,2)}else d=("001"==e||("MX"==e||"CL"==e||"UZ"==e)&&d)&&rb(b,a)?N(b,a,1):N(b,a,2);else if(g&&rb(b,a))return N(b,a,1);return d}
function sb(a,b,c){if(!kb(c))return N(a,b,1);var d=w(b,1),e=P(b);if(!(d in H))return e;if(1==d){if(null!=c&&H[1].includes(c.toUpperCase()))return d+" "+N(a,b,2)}else if(d==ub(a,c))return N(a,b,2);var f=T(a,c),g=w(f,11);c="";q(f,17)?c=w(f,17):L(Qa,g)&&(c=g);a=R(a,d,S(d));e=mb(e,a,1);b=lb(b,a,1);return 0<c.length?c+" "+d+" "+e+b:Q(d,1,e,b)}
function vb(a,b){var c=U,d;if(d=q(a,5)){d=w(a,1);d=R(c,d,S(d));if(null==d)d=!1;else{var e=P(a);d=null!=wb(v(d,19),e)}d=!d}if(d)return w(a,5);if(!q(a,6))return N(c,a,2);switch(r(a,6)){case 1:c=N(c,a,1);break;case 5:c=sb(c,a,b);break;case 10:c=N(c,a,1).substring(1);break;default:d=S(w(a,1));b=T(c,d);if(null==b)var f=null;else b=w(b,12),f=0==b.length?null:b=b.replace("~","");b=N(c,a,2);if(null==f||0==f.length)c=b;else{a:{e=w(a,5);e=M(e,I);if(0==e.lastIndexOf(f,0))try{var g=xb(c,yb(c,e.substring(f.length),
d,!1));break a}catch(k){}g=!1}g?c=b:(g=T(c,d),d=P(a),g=wb(v(g,19),d),null==g?c=b:(d=w(g,4),e=d.indexOf("$1"),0>=e?c=b:(d=d.substring(0,e),d=M(d,I),0==d.length?c=b:(g=g.clone(),Da(g,4),d=[g],g=w(a,1),b=P(a),g in H?(c=R(c,g,S(g)),e=wb(d,b),null!=e&&(d=e.clone(),e=w(e,4),0<e.length&&(f=w(c,12),0<f.length?(e=e.replace(ab,f).replace(bb,"$1"),u(d,4,e)):Da(d,4)),b=zb(b,d,2)),c=lb(a,c,2),c=Q(g,2,b,c)):c=b))))}}a=w(a,5);null!=c&&0<a.length&&(g=M(c,Oa),b=M(a,Oa),g!=b&&(c=a));return c}
function P(a){if(!q(a,2))return"";var b=""+r(a,2);return q(a,4)&&r(a,4)&&0<w(a,8)?Array(w(a,8)+1).join("0")+b:b}function Q(a,b,c,d){switch(b){case 0:return"+"+a+c+d;case 1:return"+"+a+" "+c+d;case 3:return"tel:+"+a+"-"+c+d;default:return c+d}}function mb(a,b,c,d){b=0==v(b,20).length||2==c?v(b,19):v(b,20);b=wb(b,a);return null==b?a:zb(a,b,c,d)}
function wb(a,b){for(var c,d=a.length,e=0;e<d;++e){c=a[e];var f=x(c,3);if(0==f||0==b.search(r(c,3,f-1)))if(f=new RegExp(r(c,1)),L(f,b))return c}return null}
function zb(a,b,c,d){var e=w(b,2),f=new RegExp(r(b,1)),g=w(b,5);2==c&&null!=d&&0<d.length&&0<g.length?(b=g.replace(cb,d),e=e.replace($a,b),a=a.replace(f,e)):(b=w(b,4),a=2==c&&null!=b&&0<b.length?a.replace(f,e.replace($a,b)):a.replace(f,e));3==c&&(a=a.replace(/^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]+/,""),a=a.replace(/[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]+/g,
"-"));return a}function lb(a,b,c){return q(a,3)&&0!=r(a,3).length?3==c?";ext="+r(a,3):q(b,13)?r(b,13)+w(a,3):" ext. "+w(a,3):""}function Ab(a,b){switch(b){case 4:return r(a,5);case 3:return r(a,4);case 1:return r(a,3);case 0:case 2:return r(a,2);case 5:return r(a,6);case 6:return r(a,8);case 7:return r(a,7);case 8:return r(a,21);case 9:return r(a,25);case 10:return r(a,28);default:return r(a,1)}}function qb(a,b){var c=Bb(a,b);a=R(a,w(b,1),c);if(null==a)return-1;b=P(b);return Cb(b,a)}
function Cb(a,b){return W(a,r(b,1))?W(a,r(b,5))?4:W(a,r(b,4))?3:W(a,r(b,6))?5:W(a,r(b,8))?6:W(a,r(b,7))?7:W(a,r(b,21))?8:W(a,r(b,25))?9:W(a,r(b,28))?10:W(a,r(b,2))?r(b,18)||W(a,r(b,3))?2:0:!r(b,18)&&W(a,r(b,3))?1:-1:-1}function T(a,b){if(null==b)return null;b=b.toUpperCase();var c=a.a[b];if(null==c){c=Ma[b];if(null==c)return null;c=(new F).f(E.h(),c);a.a[b]=c}return c}function W(a,b){var c=a.length;return 0<x(b,9)&&-1==v(b,9).indexOf(c)?!1:L(w(b,2),a)}
function xb(a,b){var c=Bb(a,b);return Db(a,b,c)}function Db(a,b,c){var d=w(b,1),e=R(a,d,c);if(null==e||"001"!=c&&d!=ub(a,c))return!1;a=P(b);return-1!=Cb(a,e)}function Bb(a,b){if(null==b)return null;var c=w(b,1);c=H[c];if(null==c)a=null;else if(1==c.length)a=c[0];else a:{b=P(b);for(var d,e=c.length,f=0;f<e;f++){d=c[f];var g=T(a,d);if(q(g,23)){if(0==b.search(r(g,23))){a=d;break a}}else if(-1!=Cb(b,g)){a=d;break a}}a=null}return a}function S(a){a=H[a];return null==a?"ZZ":a[0]}
function ub(a,b){a=T(a,b);if(null==a)throw Error("Invalid region code: "+b);return w(a,10)}function V(a,b,c,d){var e=Ab(c,d),f=0==x(e,9)?v(r(c,1),9):v(e,9);e=v(e,10);if(2==d)if(ib(Ab(c,0)))a=Ab(c,1),ib(a)&&(f=f.concat(0==x(a,9)?v(r(c,1),9):v(a,9)),f.sort(),0==e.length?e=v(a,10):(e=e.concat(v(a,10)),e.sort()));else return V(a,b,c,1);if(-1==f[0])return 5;b=b.length;if(-1<e.indexOf(b))return 4;c=f[0];return c==b?0:c>b?2:f[f.length-1]<b?3:-1<f.indexOf(b,1)?0:5}
function Eb(a){var b=U,c=P(a);a=w(a,1);if(!(a in H))return 1;a=R(b,a,S(a));return V(b,c,a,-1)}function Fb(a,b){a=a.toString();if(0==a.length||"0"==a.charAt(0))return 0;for(var c,d=a.length,e=1;3>=e&&e<=d;++e)if(c=parseInt(a.substring(0,e),10),c in H)return b.a(a.substring(e)),c;return 0}
function Gb(a,b,c,d,e,f){if(0==b.length)return 0;b=new A(b);var g;null!=c&&(g=r(c,11));null==g&&(g="NonMatch");var k=b.toString();if(0==k.length)g=20;else if(J.test(k))k=k.replace(J,""),B(b),b.a(gb(k)),g=1;else{k=new RegExp(g);hb(b);g=b.toString();if(0==g.search(k)){k=g.match(k)[0].length;var m=g.substring(k).match(Sa);m&&null!=m[1]&&0<m[1].length&&"0"==M(m[1],I)?g=!1:(B(b),b.a(g.substring(k)),g=!0)}else g=!1;g=g?5:20}e&&u(f,6,g);if(20!=g){if(2>=b.b.length)throw Error("Phone number too short after IDD");
a=Fb(b,d);if(0!=a)return u(f,1,a),a;throw Error("Invalid country calling code");}if(null!=c&&(g=w(c,10),k=""+g,m=b.toString(),0==m.lastIndexOf(k,0)&&(k=new A(m.substring(k.length)),m=r(c,1),m=new RegExp(w(m,2)),Hb(k,c,null),k=k.toString(),!L(m,b.toString())&&L(m,k)||3==V(a,b.toString(),c,-1))))return d.a(k),e&&u(f,6,10),u(f,1,g),g;u(f,1,0);return 0}
function Hb(a,b,c){var d=a.toString(),e=d.length,f=r(b,15);if(0!=e&&null!=f&&0!=f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){f=new RegExp(w(r(b,1),2));var k=L(f,d),m=e.length-1;b=r(b,16);if(null==b||0==b.length||null==e[m]||0==e[m].length){if(!k||L(f,d.substring(e[0].length)))null!=c&&0<m&&null!=e[m]&&c.a(e[1]),a.set(d.substring(e[0].length))}else if(d=d.replace(g,b),!k||L(f,d))null!=c&&0<m&&c.a(e[1]),a.set(d)}}}
function yb(a,b,c,d){if(null==b)throw Error("The string supplied did not seem to be a phone number");if(250<b.length)throw Error("The string supplied is too long to be a phone number");var e=new A,f=b.indexOf(";phone-context=");if(0<=f){var g=f+15;if("+"==b.charAt(g)){var k=b.indexOf(";",g);0<k?e.a(b.substring(g,k)):e.a(b.substring(g))}g=b.indexOf("tel:");e.a(b.substring(0<=g?g+4:0,f))}else e.a(eb(b));f=e.toString();g=f.indexOf(";isub=");0<g&&(B(e),e.a(f.substring(0,g)));if(!fb(e.toString()))throw Error("The string supplied did not seem to be a phone number");
f=e.toString();if(!(kb(c)||null!=f&&0<f.length&&J.test(f)))throw Error("Invalid country calling code");f=new G;d&&u(f,5,b);a:{b=e.toString();g=b.search(Ya);if(0<=g&&fb(b.substring(0,g))){k=b.match(Ya);for(var m=k.length,t=1;t<m;++t)if(null!=k[t]&&0<k[t].length){B(e);e.a(b.substring(0,g));b=k[t];break a}}b=""}0<b.length&&u(f,3,b);g=T(a,c);b=new A;k=0;m=e.toString();try{k=Gb(a,m,g,b,d,f)}catch(O){if("Invalid country calling code"==O.message&&J.test(m)){if(m=m.replace(J,""),k=Gb(a,m,g,b,d,f),0==k)throw O;
}else throw O;}0!=k?(e=S(k),e!=c&&(g=R(a,k,e))):(hb(e),b.a(e.toString()),null!=c?(k=w(g,10),u(f,1,k)):d&&Da(f,6));if(2>b.b.length)throw Error("The string supplied is too short to be a phone number");null!=g&&(c=new A,e=new A(b.toString()),Hb(e,g,c),a=V(a,e.toString(),g,-1),2!=a&&4!=a&&5!=a&&(b=e,d&&0<c.toString().length&&u(f,7,c.toString())));d=b.toString();a=d.length;if(2>a)throw Error("The string supplied is too short to be a phone number");if(17<a)throw Error("The string supplied is too long to be a phone number");
if(1<d.length&&"0"==d.charAt(0)){u(f,4,!0);for(a=1;a<d.length-1&&"0"==d.charAt(a);)a++;1!=a&&u(f,8,a)}u(f,2,parseInt(d,10));return f}function rb(a,b){a=T(a,Bb(a,b));if(null==a)return!0;b=P(b);return!W(b,r(a,24))}function L(a,b){return(a="string"==typeof a?b.match("^(?:"+a+")$"):b.match(a))&&a[0].length==b.length?!0:!1};function Ib(a){this.ha=/\u2008/;this.ia="";this.m=new A;this.$="";this.j=new A;this.o=new A;this.l=!0;this.aa=this.s=this.ka=!1;this.ba=Na.ea();this.u=0;this.b=new A;this.ca=!1;this.i="";this.a=new A;this.f=[];this.ja=a;this.g=Jb(this,this.ja)}var Kb=new E;u(Kb,11,"NA");
var Lb=/^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]*\$1[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]*(\$\d[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]*)*$/,Mb=/[- ]/;function Jb(a,b){var c=a.ba;b=kb(b)?ub(c,b):0;a=T(a.ba,S(b));return null!=a?a:Kb}
function Nb(a){for(var b=a.f.length,c=0;c<b;++c){var d=a.f[c],e=w(d,1);if(a.$==e)return!1;var f=a;var g=d,k=w(g,1);B(f.m);var m=f;g=w(g,2);var t="999999999999999".match(k)[0];t.length<m.a.b.length?m="":(m=t.replace(new RegExp(k,"g"),g),m=m.replace(/9/g,"\u2008"));0<m.length?(f.m.a(m),f=!0):f=!1;if(f)return a.$=e,a.ca=Mb.test(r(d,4)),a.u=0,!0}return a.l=!1}
function Ob(a,b){for(var c=[],d=b.length-3,e=a.f.length,f=0;f<e;++f){var g=a.f[f];0==x(g,3)?c.push(a.f[f]):(g=r(g,3,Math.min(d,x(g,3)-1)),0==b.search(g)&&c.push(a.f[f]))}a.f=c}function Pb(a,b){a.ia=Qb(a,b);return a.ia}
function Qb(a,b){a.j.a(b);var c=b;Sa.test(c)||1==a.j.b.length&&Ra.test(c)?("+"==b?(c=b,a.o.a(b)):(c=I[b],a.o.a(c),a.a.a(c)),b=c):(a.l=!1,a.ka=!0);if(!a.l){if(!a.ka)if(Rb(a)){if(Sb(a))return Tb(a)}else if(0<a.i.length&&(b=a.a.toString(),B(a.a),a.a.a(a.i),a.a.a(b),b=a.b.toString(),c=b.lastIndexOf(a.i),B(a.b),a.b.a(b.substring(0,c))),a.i!=Ub(a))return a.b.a(" "),Tb(a);return a.j.toString()}switch(a.o.b.length){case 0:case 1:case 2:return a.j.toString();case 3:if(Rb(a))a.aa=!0;else return a.i=Ub(a),Vb(a);
default:if(a.aa)return Sb(a)&&(a.aa=!1),a.b.toString()+a.a.toString();if(0<a.f.length){b=Wb(a,b);c=Xb(a);if(0<c.length)return c;Ob(a,a.a.toString());return Nb(a)?Yb(a):a.l?Zb(a,b):a.j.toString()}return Vb(a)}}function Tb(a){a.l=!0;a.aa=!1;a.f=[];a.u=0;B(a.m);a.$="";return Vb(a)}
function Xb(a){for(var b=a.a.toString(),c=a.f.length,d=0;d<c;++d){var e=a.f[d],f=w(e,1);if((new RegExp("^(?:"+f+")$")).test(b)&&(a.ca=Mb.test(r(e,4)),e=b.replace(new RegExp(f,"g"),r(e,2)),e=Zb(a,e),M(e,Oa)==a.o))return e}return""}function Zb(a,b){var c=a.b.b.length;return a.ca&&0<c&&" "!=a.b.toString().charAt(c-1)?a.b+" "+b:a.b+b}
function Vb(a){var b=a.a.toString();if(3<=b.length){for(var c=a.s&&0==a.i.length&&0<x(a.g,20)?v(a.g,20):v(a.g,19),d=c.length,e=0;e<d;++e){var f=c[e];0<a.i.length&&jb(w(f,4))&&!r(f,6)&&!q(f,5)||(0!=a.i.length||a.s||jb(w(f,4))||r(f,6))&&Lb.test(w(f,2))&&a.f.push(f)}Ob(a,b);b=Xb(a);return 0<b.length?b:Nb(a)?Yb(a):a.j.toString()}return Zb(a,b)}function Yb(a){var b=a.a.toString(),c=b.length;if(0<c){for(var d="",e=0;e<c;e++)d=Wb(a,b.charAt(e));return a.l?Zb(a,d):a.j.toString()}return a.b.toString()}
function Ub(a){var b=a.a.toString(),c=0;if(1!=r(a.g,10))var d=!1;else d=a.a.toString(),d="1"==d.charAt(0)&&"0"!=d.charAt(1)&&"1"!=d.charAt(1);d?(c=1,a.b.a("1").a(" "),a.s=!0):q(a.g,15)&&(d=new RegExp("^(?:"+r(a.g,15)+")"),d=b.match(d),null!=d&&null!=d[0]&&0<d[0].length&&(a.s=!0,c=d[0].length,a.b.a(b.substring(0,c))));B(a.a);a.a.a(b.substring(c));return b.substring(0,c)}
function Rb(a){var b=a.o.toString(),c=new RegExp("^(?:\\+|"+r(a.g,11)+")");c=b.match(c);return null!=c&&null!=c[0]&&0<c[0].length?(a.s=!0,c=c[0].length,B(a.a),a.a.a(b.substring(c)),B(a.b),a.b.a(b.substring(0,c)),"+"!=b.charAt(0)&&a.b.a(" "),!0):!1}function Sb(a){if(0==a.a.b.length)return!1;var b=new A,c=Fb(a.a,b);if(0==c)return!1;B(a.a);a.a.a(b.toString());b=S(c);"001"==b?a.g=T(a.ba,""+c):b!=a.ja&&(a.g=Jb(a,b));a.b.a(""+c).a(" ");a.i="";return!0}
function Wb(a,b){var c=a.m.toString();if(0<=c.substring(a.u).search(a.ha)){var d=c.search(a.ha);b=c.replace(a.ha,b);B(a.m);a.m.a(b);a.u=d;return b.substring(0,a.u+1)}1==a.f.length&&(a.l=!1);a.$="";return a.j.toString()};var $b={AC:[,[,,"9\\d\\d",,,,,,,[3]],,,[,,"9(?:11|99)",,,,"911"],[,,,,,,,,,[-1]],,,,"AC",,,,,,,,,,,,,,,,,,[,,"9(?:11|99)",,,,"911"],,[,,"9(?:11|99)",,,,"911"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,[,,,,,,,,,[-1]]],AD:[,[,,"1\\d\\d",,,,,,,[3]],,,[,,"11[0268]",,,,"110"],[,,,,,,,,,[-1]],,,,"AD",,,,,,,,,,,,,,,,,,[,,"11[0268]",,,,"110"],,[,,"11[0268]",,,,"110"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,[,,,,,,,,,[-1]]],AE:[,[,,"[149]\\d{2,3}",,,,,,,[3,4]],,,[,,"112|99[7-9]",,,,"112",,,[3]],[,,,,,,,,,[-1]],,,,"AE",,
function hb(){this.g={}}na(hb);
var ib={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9"},jb={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",
7:"7",8:"8",9:"9","+":"+","*":"*","#":"#"},kb={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9",A:"2",
B:"2",C:"2",D:"3",E:"3",F:"3",G:"4",H:"4",I:"4",J:"5",K:"5",L:"5",M:"6",N:"6",O:"6",P:"7",Q:"7",R:"7",S:"7",T:"8",U:"8",V:"8",W:"9",X:"9",Y:"9",Z:"9"},lb=/[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?/,mb=/[+\uff0b]+/,nb=/^[+\uff0b]+/,ob=/([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9])/,pb=/[+\uff0b0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]/,qb=/[\\\/] *x/,rb=/[^0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9A-Za-z#]+$/,sb=/(?:.*?[A-Za-z]){3}.*/,tb=/^\+([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]|[\-\.\(\)]?)*[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]|[\-\.\(\)]?)*$/,
ub=/^([A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]+((\-)*[A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9])*\.)*[A-Za-z]+((\-)*[A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9])*\.?$/;function J(a){return"([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,"+a+"})"}
function vb(){return";ext="+J("20")+"|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|\u0434\u043e\u0431|anexo)[:\\.\uff0e]?[ \u00a0\\t,-]*"+(J("20")+"#?|[ \u00a0\\t,]*(?:[x\uff58#\uff03~\uff5e]|int|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*")+(J("9")+"#?|[- ]+")+(J("6")+"#|[ \u00a0\\t]*(?:,{2}|;)[:\\.\uff0e]?[ \u00a0\\t,-]*")+(J("15")+"#?|[ \u00a0\\t]*(?:,)+[:\\.\uff0e]?[ \u00a0\\t,-]*")+(J("9")+"#?")}
var wb=new RegExp("(?:"+vb()+")$","i"),xb=new RegExp("^[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{2}$|^[+\uff0b]*(?:[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*]*[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]){3,}[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]*(?:"+vb()+")?$","i"),yb=/(\$\d)/,
zb=/\$NP/,Ab=/\$FG/,Bb=/\$CC/,Cb=/^\(?\$1\)?$/;function Db(a){return 2>a.length?!1:K(xb,a)}function Eb(a){return K(sb,a)?L(a,kb):L(a,ib)}function Fb(a){var b=Eb(a.toString());A(a);a.g(b)}function Gb(a){return null!=a&&(1!=w(a,9)||-1!=u(a,9)[0])}function L(a,b){for(var c=new z,d,f=a.length,e=0;e<f;++e)d=a.charAt(e),d=b[d.toUpperCase()],null!=d&&c.g(d);return c.toString()}function Hb(a){return 0==a.length||Cb.test(a)}function Ib(a){return null!=a&&isNaN(a)&&a.toUpperCase()in gb}
function M(a,b,c){if(0==q(b,2)&&n(b,5)){var d=v(b,5);if(0<d.length)return d}d=v(b,1);var f=N(b);if(0==c)return Jb(d,0,f,"");if(!(d in I))return f;a=O(a,d,P(d));b=Kb(b,a,c);f=Lb(f,a,c);return Jb(d,c,f,b)}function Mb(a,b,c){var d=v(b,1),f=N(b);if(!(d in I))return f;a=O(a,d,P(d));b=Kb(b,a,2);c=Lb(f,a,2,c);return Jb(d,2,c,b)}function O(a,b,c){return"001"==c?Q(a,""+b):Q(a,c)}function Nb(a,b){return Mb(a,b,0<v(b,7).length?v(b,7):"")}
function Ob(a,b,c){if(!Ib(c))return M(a,b,1);var d=v(b,1),f=N(b);if(!(d in I))return f;if(1==d){if(null!=c&&I[1].includes(c.toUpperCase()))return d+" "+M(a,b,2)}else if(d==Pb(a,c))return M(a,b,2);var e=Q(a,c),g=v(e,11);c="";n(e,17)?c=v(e,17):K(lb,g)&&(c=g);a=O(a,d,P(d));f=Lb(f,a,1);b=Kb(b,a,1);return 0<c.length?c+" "+d+" "+f+b:Jb(d,1,f,b)}function N(a){if(!n(a,2))return"";var b=""+q(a,2);return n(a,4)&&q(a,4)&&0<v(a,8)?Array(v(a,8)+1).join("0")+b:b}
function Jb(a,b,c,d){switch(b){case 0:return"+"+a+c+d;case 1:return"+"+a+" "+c+d;case 3:return"tel:+"+a+"-"+c+d;default:return c+d}}function Lb(a,b,c,d){b=0==u(b,20).length||2==c?u(b,19):u(b,20);b=Qb(b,a);return null==b?a:Rb(a,b,c,d)}function Qb(a,b){for(var c,d=a.length,f=0;f<d;++f){c=a[f];var e=w(c,3);if(0==e||0==b.search(q(c,3,e-1)))if(e=new RegExp(q(c,1)),K(e,b))return c}return null}
function Rb(a,b,c,d){var f=v(b,2),e=new RegExp(q(b,1)),g=v(b,5);2==c&&null!=d&&0<d.length&&0<g.length?(b=g.replace(Bb,d),f=f.replace(yb,b),a=a.replace(e,f)):(b=v(b,4),a=2==c&&null!=b&&0<b.length?a.replace(e,f.replace(yb,b)):a.replace(e,f));3==c&&(a=a.replace(/^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]+/,""),a=a.replace(/[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]+/g,
"-"));return a}function Kb(a,b,c){return n(a,3)&&0!=q(a,3).length?3==c?";ext="+q(a,3):n(b,13)?q(b,13)+v(a,3):" ext. "+v(a,3):""}function Sb(a,b){switch(b){case 4:return q(a,5);case 3:return q(a,4);case 1:return q(a,3);case 0:case 2:return q(a,2);case 5:return q(a,6);case 6:return q(a,8);case 7:return q(a,7);case 8:return q(a,21);case 9:return q(a,25);case 10:return q(a,28);default:return q(a,1)}}function lc(a,b){var c=mc(a,b);a=O(a,v(b,1),c);if(null==a)return-1;b=N(b);return nc(b,a)}
function nc(a,b){return R(a,q(b,1))?R(a,q(b,5))?4:R(a,q(b,4))?3:R(a,q(b,6))?5:R(a,q(b,8))?6:R(a,q(b,7))?7:R(a,q(b,21))?8:R(a,q(b,25))?9:R(a,q(b,28))?10:R(a,q(b,2))?q(b,18)||R(a,q(b,3))?2:0:!q(b,18)&&R(a,q(b,3))?1:-1:-1}function Q(a,b){if(null==b)return null;b=b.toUpperCase();var c=a.g[b];if(null==c){c=gb[b];if(null==c)return null;c=(new G).j(F.m(),c);a.g[b]=c}return c}function R(a,b){var c=a.length;return 0<w(b,9)&&-1==u(b,9).indexOf(c)?!1:K(v(b,2),a)}
function oc(a,b){var c=mc(a,b);return pc(a,b,c)}function pc(a,b,c){var d=v(b,1),f=O(a,d,c);if(null==f||"001"!=c&&d!=Pb(a,c))return!1;a=N(b);return-1!=nc(a,f)}function mc(a,b){if(null==b)return null;var c=v(b,1);c=I[c];if(null==c)a=null;else if(1==c.length)a=c[0];else a:{b=N(b);for(var d,f=c.length,e=0;e<f;e++){d=c[e];var g=Q(a,d);if(n(g,23)){if(0==b.search(q(g,23))){a=d;break a}}else if(-1!=nc(b,g)){a=d;break a}}a=null}return a}function P(a){a=I[a];return null==a?"ZZ":a[0]}
function Pb(a,b){a=Q(a,b);if(null==a)throw Error("Invalid region code: "+b);return v(a,10)}function qc(a,b,c,d){var f=Sb(c,d),e=0==w(f,9)?u(q(c,1),9):u(f,9);f=u(f,10);if(2==d)if(Gb(Sb(c,0)))a=Sb(c,1),Gb(a)&&(e=e.concat(0==w(a,9)?u(q(c,1),9):u(a,9)),e.sort(),0==f.length?f=u(a,10):(f=f.concat(u(a,10)),f.sort()));else return qc(a,b,c,1);if(-1==e[0])return 5;b=b.length;if(-1<f.indexOf(b))return 4;c=e[0];return c==b?0:c>b?2:e[e.length-1]<b?3:-1<e.indexOf(b,1)?0:5}
function rc(a){var b=S,c=N(a);a=v(a,1);if(!(a in I))return 1;a=O(b,a,P(a));return qc(b,c,a,-1)}function sc(a,b){a=a.toString();if(0==a.length||"0"==a.charAt(0))return 0;for(var c,d=a.length,f=1;3>=f&&f<=d;++f)if(c=parseInt(a.substring(0,f),10),c in I)return b.g(a.substring(f)),c;return 0}
function tc(a,b,c,d,f,e){if(0==b.length)return 0;b=new z(b);var g;null!=c&&(g=q(c,11));null==g&&(g="NonMatch");var h=b.toString();if(0==h.length)g=20;else if(nb.test(h))h=h.replace(nb,""),A(b),b.g(Eb(h)),g=1;else{h=new RegExp(g);Fb(b);g=b.toString();if(0==g.search(h)){h=g.match(h)[0].length;var m=g.substring(h).match(ob);m&&null!=m[1]&&0<m[1].length&&"0"==L(m[1],ib)?g=!1:(A(b),b.g(g.substring(h)),g=!0)}else g=!1;g=g?5:20}f&&t(e,6,g);if(20!=g){if(2>=b.h.length)throw Error("Phone number too short after IDD");
a=sc(b,d);if(0!=a)return t(e,1,a),a;throw Error("Invalid country calling code");}if(null!=c&&(g=v(c,10),h=""+g,m=b.toString(),0==m.lastIndexOf(h,0)&&(h=new z(m.substring(h.length)),m=q(c,1),m=new RegExp(v(m,2)),uc(h,c,null),h=h.toString(),!K(m,b.toString())&&K(m,h)||3==qc(a,b.toString(),c,-1))))return d.g(h),f&&t(e,6,10),t(e,1,g),g;t(e,1,0);return 0}
function uc(a,b,c){var d=a.toString(),f=d.length,e=q(b,15);if(0!=f&&null!=e&&0!=e.length){var g=new RegExp("^(?:"+e+")");if(f=g.exec(d)){e=new RegExp(v(q(b,1),2));var h=K(e,d),m=f.length-1;b=q(b,16);if(null==b||0==b.length||null==f[m]||0==f[m].length){if(!h||K(e,d.substring(f[0].length)))null!=c&&0<m&&null!=f[m]&&c.g(f[1]),a.set(d.substring(f[0].length))}else if(d=d.replace(g,b),!h||K(e,d))null!=c&&0<m&&c.g(f[1]),a.set(d)}}}
function vc(a,b,c,d){if(null==b)throw Error("The string supplied did not seem to be a phone number");if(250<b.length)throw Error("The string supplied is too long to be a phone number");var f=new z;var e=b.indexOf(";phone-context=");if(-1===e)e=null;else if(e+=15,e>=b.length)e="";else{var g=b.indexOf(";",e);e=-1!==g?b.substring(e,g):b.substring(e)}var h=e;null==h?g=!0:0===h.length?g=!1:(g=tb.exec(h),h=ub.exec(h),g=null!==g||null!==h);if(!g)throw Error("The string supplied did not seem to be a phone number");
null!=e?("+"===e.charAt(0)&&f.g(e),e=b.indexOf("tel:"),f.g(b.substring(0<=e?e+4:0,b.indexOf(";phone-context=")))):(e=f.g,g=null!=b?b:"",h=g.search(pb),0<=h?(g=g.substring(h),g=g.replace(rb,""),h=g.search(qb),0<=h&&(g=g.substring(0,h))):g="",e.call(f,g));e=f.toString();g=e.indexOf(";isub=");0<g&&(A(f),f.g(e.substring(0,g)));if(!Db(f.toString()))throw Error("The string supplied did not seem to be a phone number");e=f.toString();if(!(Ib(c)||null!=e&&0<e.length&&nb.test(e)))throw Error("Invalid country calling code");
e=new H;d&&t(e,5,b);a:{b=f.toString();g=b.search(wb);if(0<=g&&Db(b.substring(0,g))){h=b.match(wb);for(var m=h.length,p=1;p<m;++p)if(null!=h[p]&&0<h[p].length){A(f);f.g(b.substring(0,g));b=h[p];break a}}b=""}0<b.length&&t(e,3,b);g=Q(a,c);b=new z;h=0;m=f.toString();try{h=tc(a,m,g,b,d,e)}catch(r){if("Invalid country calling code"==r.message&&nb.test(m)){if(m=m.replace(nb,""),h=tc(a,m,g,b,d,e),0==h)throw r;}else throw r;}0!=h?(f=P(h),f!=c&&(g=O(a,h,f))):(Fb(f),b.g(f.toString()),null!=c?(h=v(g,10),t(e,
1,h)):d&&Qa(e,6));if(2>b.h.length)throw Error("The string supplied is too short to be a phone number");null!=g&&(c=new z,f=new z(b.toString()),uc(f,g,c),a=qc(a,f.toString(),g,-1),2!=a&&4!=a&&5!=a&&(b=f,d&&0<c.toString().length&&t(e,7,c.toString())));d=b.toString();a=d.length;if(2>a)throw Error("The string supplied is too short to be a phone number");if(17<a)throw Error("The string supplied is too long to be a phone number");if(1<d.length&&"0"==d.charAt(0)){t(e,4,!0);for(a=1;a<d.length-1&&"0"==d.charAt(a);)a++;
1!=a&&t(e,8,a)}t(e,2,parseInt(d,10));return e}function wc(a,b){a=Q(a,mc(a,b));if(null==a)return!0;b=N(b);return!R(b,q(a,24))}function K(a,b){return(a="string"==typeof a?b.match("^(?:"+a+")$"):b.match(a))&&a[0].length==b.length?!0:!1};function xc(a){this.fa=/\u2008/;this.ma="";this.v=new z;this.da="";this.s=new z;this.ba=new z;this.u=!0;this.ea=this.ca=this.oa=!1;this.ga=hb.ja();this.$=0;this.h=new z;this.ha=!1;this.o="";this.g=new z;this.j=[];this.na=a;this.l=yc(this,this.na)}var zc=new F;t(zc,11,"NA");
var Ac=/^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]*\$1[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]*(\$\d[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\[\]/~\u2053\u223c\uff5e]*)*$/,Bc=/[- ]/;function yc(a,b){var c=a.ga;b=Ib(b)?Pb(c,b):0;a=Q(a.ga,P(b));return null!=a?a:zc}
function Cc(a){for(var b=a.j.length,c=0;c<b;++c){var d=a.j[c],f=v(d,1);if(a.da==f)return!1;var e=a;var g=d,h=v(g,1);A(e.v);var m=e;g=v(g,2);var p="999999999999999".match(h)[0];p.length<m.g.h.length?m="":(m=p.replace(new RegExp(h,"g"),g),m=m.replace(/9/g,"\u2008"));0<m.length?(e.v.g(m),e=!0):e=!1;if(e)return a.da=f,a.ha=Bc.test(q(d,4)),a.$=0,!0}return a.u=!1}
function Dc(a,b){for(var c=[],d=b.length-3,f=a.j.length,e=0;e<f;++e){var g=a.j[e];0==w(g,3)?c.push(a.j[e]):(g=q(g,3,Math.min(d,w(g,3)-1)),0==b.search(g)&&c.push(a.j[e]))}a.j=c}
function Ec(a,b){a.s.g(b);var c=b;ob.test(c)||1==a.s.h.length&&mb.test(c)?("+"==b?(c=b,a.ba.g(b)):(c=ib[b],a.ba.g(c),a.g.g(c)),b=c):(a.u=!1,a.oa=!0);if(!a.u){if(!a.oa)if(Fc(a)){if(Gc(a))return Hc(a)}else if(0<a.o.length&&(b=a.g.toString(),A(a.g),a.g.g(a.o),a.g.g(b),b=a.h.toString(),c=b.lastIndexOf(a.o),A(a.h),a.h.g(b.substring(0,c))),a.o!=Ic(a))return a.h.g(" "),Hc(a);return a.s.toString()}switch(a.ba.h.length){case 0:case 1:case 2:return a.s.toString();case 3:if(Fc(a))a.ea=!0;else return a.o=Ic(a),
Jc(a);default:if(a.ea)return Gc(a)&&(a.ea=!1),a.h.toString()+a.g.toString();if(0<a.j.length){b=Kc(a,b);c=Lc(a);if(0<c.length)return c;Dc(a,a.g.toString());return Cc(a)?Mc(a):a.u?Nc(a,b):a.s.toString()}return Jc(a)}}function Hc(a){a.u=!0;a.ea=!1;a.j=[];a.$=0;A(a.v);a.da="";return Jc(a)}
function Lc(a){for(var b=a.g.toString(),c=a.j.length,d=0;d<c;++d){var f=a.j[d],e=v(f,1);if((new RegExp("^(?:"+e+")$")).test(b)&&(a.ha=Bc.test(q(f,4)),f=b.replace(new RegExp(e,"g"),q(f,2)),f=Nc(a,f),L(f,jb)==a.ba))return f}return""}function Nc(a,b){var c=a.h.h.length;return a.ha&&0<c&&" "!=a.h.toString().charAt(c-1)?a.h+" "+b:a.h+b}
function Jc(a){var b=a.g.toString();if(3<=b.length){for(var c=a.ca&&0==a.o.length&&0<w(a.l,20)?u(a.l,20):u(a.l,19),d=c.length,f=0;f<d;++f){var e=c[f];0<a.o.length&&Hb(v(e,4))&&!q(e,6)&&!n(e,5)||(0!=a.o.length||a.ca||Hb(v(e,4))||q(e,6))&&Ac.test(v(e,2))&&a.j.push(e)}Dc(a,b);b=Lc(a);return 0<b.length?b:Cc(a)?Mc(a):a.s.toString()}return Nc(a,b)}function Mc(a){var b=a.g.toString(),c=b.length;if(0<c){for(var d="",f=0;f<c;f++)d=Kc(a,b.charAt(f));return a.u?Nc(a,d):a.s.toString()}return a.h.toString()}
function Ic(a){var b=a.g.toString(),c=0;if(1!=q(a.l,10))var d=!1;else d=a.g.toString(),d="1"==d.charAt(0)&&"0"!=d.charAt(1)&&"1"!=d.charAt(1);d?(c=1,a.h.g("1").g(" "),a.ca=!0):n(a.l,15)&&(d=new RegExp("^(?:"+q(a.l,15)+")"),d=b.match(d),null!=d&&null!=d[0]&&0<d[0].length&&(a.ca=!0,c=d[0].length,a.h.g(b.substring(0,c))));A(a.g);a.g.g(b.substring(c));return b.substring(0,c)}
function Fc(a){var b=a.ba.toString(),c=new RegExp("^(?:\\+|"+q(a.l,11)+")");c=b.match(c);return null!=c&&null!=c[0]&&0<c[0].length?(a.ca=!0,c=c[0].length,A(a.g),a.g.g(b.substring(c)),A(a.h),a.h.g(b.substring(0,c)),"+"!=b.charAt(0)&&a.h.g(" "),!0):!1}function Gc(a){if(0==a.g.h.length)return!1;var b=new z,c=sc(a.g,b);if(0==c)return!1;A(a.g);a.g.g(b.toString());b=P(c);"001"==b?a.l=Q(a.ga,""+c):b!=a.na&&(a.l=yc(a,b));a.h.g(""+c).g(" ");a.o="";return!0}
function Kc(a,b){var c=a.v.toString();if(0<=c.substring(a.$).search(a.fa)){var d=c.search(a.fa);b=c.replace(a.fa,b);A(a.v);a.v.g(b);a.$=d;return b.substring(0,a.$+1)}1==a.j.length&&(a.u=!1);a.da="";return a.s.toString()};var Oc={AC:[,[,,"9\\d\\d",,,,,,,[3]],,,[,,"9(?:11|99)",,,,"911"],[,,,,,,,,,[-1]],,,,"AC",,,,,,,,,,,,,,,,,,[,,"9(?:11|99)",,,,"911"],,[,,"9(?:11|99)",,,,"911"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,[,,,,,,,,,[-1]]],AD:[,[,,"1\\d\\d",,,,,,,[3]],,,[,,"11[0268]",,,,"110"],[,,,,,,,,,[-1]],,,,"AD",,,,,,,,,,,,,,,,,,[,,"11[0268]",,,,"110"],,[,,"11[0268]",,,,"110"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,[,,,,,,,,,[-1]]],AE:[,[,,"[149]\\d{2,3}",,,,,,,[3,4]],,,[,,"112|99[7-9]",,,,"112",,,[3]],[,,,,,,,,,[-1]],,,,"AE",,
,,,,,,,,,,,,,,,,[,,"112|99[7-9]",,,,"112",,,[3]],,[,,"112|445[16]|99[7-9]",,,,"112"],[,,,,,,,,,[-1]],[,,,,,,,,,[-1]],,[,,"445\\d",,,,"4450",,,[4]]],AF:[,[,,"[14]\\d\\d(?:\\d{2})?",,,,,,,[3,5]],,,[,,"1(?:0[02]|19)",,,,"100",,,[3]],[,,,,,,,,,[-1]],,,,"AF",,,,,,,,,,,,,,,,,,[,,"1(?:0[02]|19)",,,,"100",,,[3]],,[,,"1(?:0[02]|19)|40404",,,,"100"],[,,,,,,,,,[-1]],[,,"404\\d\\d",,,,"40400",,,[5]],,[,,"404\\d\\d",,,,"40400",,,[5]]],AG:[,[,,"[19]\\d\\d",,,,,,,[3]],,,[,,"9(?:11|88|99)",,,,"911"],[,,,,,,,,,[-1]],
,,,"AG",,,,,,,,,,,,,,,,,,[,,"9(?:11|99)",,,,"911"],,[,,"176|9(?:11|88|99)",,,,"176"],[,,,,,,,,,[-1]],[,,"176",,,,"176"],,[,,"176",,,,"176"]],AI:[,[,,"[19]\\d\\d",,,,,,,[3]],,,[,,"9(?:11|88)",,,,"911"],[,,,,,,,,,[-1]],,,,"AI",,,,,,,,,,,,,,,,,,[,,"911",,,,"911"],,[,,"176|9(?:11|88)",,,,"176"],[,,,,,,,,,[-1]],[,,"176",,,,"176"],,[,,"176",,,,"176"]],AL:[,[,,"[15]\\d{2,5}",,,,,,,[3,4,5,6]],,,[,,"1(?:1(?:2|6[01]\\d\\d)|2[7-9]|3[15]|41)",,,,"112",,,[3,6]],[,,"5\\d{4}",,,,"50000",,,[5]],,,,"AL",,,,,,,,,,
,,,,,,,,[,,"1(?:12|2[7-9])",,,,"112",,,[3]],,[,,"1(?:1(?:6(?:000|1(?:06|11|23))|8\\d\\d)|65\\d|89[12])|5\\d{4}|1(?:[1349]\\d|2[2-9])",,,,"110"],[,,,,,,,,,[-1]],[,,"123",,,,"123",,,[3]],,[,,"131|5\\d{4}",,,,"131",,,[3,5]]],AM:[,[,,"[148]\\d{2,4}",,,,,,,[3,4,5]],,,[,,"10[1-3]",,,,"101",,,[3]],[,,,,,,,,,[-1]],,,,"AM",,,,,,,,,,,,,,,,,,[,,"10[1-3]",,,,"101",,,[3]],,[,,"(?:1|8[1-7])\\d\\d|40404",,,,"100"],[,,,,,,,,,[-1]],[,,"404\\d\\d",,,,"40400",,,[5]],,[,,"404\\d\\d",,,,"40400",,,[5]]],AO:[,[,,"1\\d\\d",
@ -672,11 +668,15 @@ MO:[,[,,"9\\d\\d",,,,,,,[3]],,,[,,"999",,,,"999"],[,,,,,,,,,[-1]],,,,"MO",,,,,,,
See the License for the specific language governing permissions and
limitations under the License.
*/
function ac(){this.a={}}fa(ac);function bc(a){return(a=H[a])?a:[]}function cc(a,b){a=bc(w(a,1));return null!=b&&a.includes(b)}function dc(a,b,c){if(!cc(b,c))return!1;a=ec(a,c);if(!a)return!1;b=fc(b).length;return v(r(a,1),9).includes(b)}function gc(a,b){var c=bc(w(b,1));b=fc(b).length;for(var d=0;d<c.length;d++){var e=ec(a,c[d]);if(e&&v(r(e,1),9).includes(b))return!0}return!1}
function hc(a,b,c){if(!cc(b,c))return!1;a=ec(a,c);if(!a)return!1;b=fc(b);c=r(a,1);if(!ic(b,c))return!1;a=r(a,29);return ic(b,a)}function jc(a,b){var c=bc(w(b,1));a:if(0===c.length)var d=null;else if(1===c.length)d=c[0];else{d=fc(b);for(var e=0;e<c.length;e++){var f=c[e],g=ec(a,f);if(g&&ic(d,r(g,29))){d=f;break a}}d=null}return 1<c.length&&null!=d?!0:hc(a,b,d)}
function ec(a,b){if(!b)return null;b=b.toUpperCase();var c=a.a[b];if(null==c){c=$b[b];if(null==c)return null;c=(new F).f(E.h(),c);a.a[b]=c}return c}function fc(a){if(!q(a,2))return"";var b=""+r(a,2);return q(a,4)&&r(a,4)&&0<w(a,8)?Array(w(a,8)+1).join("0")+b:b}function ic(a,b){return 0<v(b,9).length&&!v(b,9).includes(a.length)?!1:L(w(b,2),a.toString())};var U=Na.ea();function kc(a){switch(qb(U,a)){case 0:return"FIXED_LINE";case 1:return"MOBILE";case 2:return"FIXED_LINE_OR_MOBILE";case 3:return"TOLL_FREE";case 4:return"PREMIUM_RATE";case 5:return"SHARED_COST";case 6:return"VOIP";case 7:return"PERSONAL_NUMBER";case 8:return"PAGER";case 9:return"UAN";case -1:return"UNKNOWN"}}
function lc(){var a=n("phoneNumber").value,b=n("defaultCountry").value.toUpperCase(),c=n("carrierCode").value,d=new A;try{var e=U;if(!kb(b)&&0<a.length&&"+"!=a.charAt(0))throw Error("Invalid country calling code");var f=yb(e,a,b,!0);d.a("****Parsing Result:****\n");d.a(JSON.stringify((new z(1)).g(f)));d.a("\n\n****Validation Results:****");var g=Eb(f);var k=0==g||4==g;d.a("\nResult from isPossibleNumber(): ");d.a(k);var m=Eb(f);e=b&&"ZZ"!=b;if(k)if(4==m)d.a("\nResult from isPossibleNumberWithReason(): "),
d.a("IS_POSSIBLE_LOCAL_ONLY"),d.a("\nNumber is considered invalid as it is not a possible national number.");else{var t=xb(U,f);d.a("\nResult from isValidNumber(): ");d.a(t);t&&e&&(d.a("\nResult from isValidNumberForRegion(): "),d.a(Db(U,f,b)));d.a("\nPhone Number region: ");d.a(Bb(U,f));d.a("\nResult from getNumberType(): ");d.a(kc(f))}else{d.a("\nResult from isPossibleNumberWithReason(): ");switch(m){case 1:d.a("INVALID_COUNTRY_CODE");break;case 2:d.a("TOO_SHORT");break;case 3:d.a("TOO_LONG");break;
case 5:d.a("INVALID_LENGTH")}d.a("\nNote: Numbers that are not possible have type UNKNOWN, an unknown region, and are considered invalid.")}if(!t){var O=ac.ea();d.a("\n\n****ShortNumberInfo Results:****");d.a("\nResult from isPossibleShortNumber: ");d.a(gc(O,f));d.a("\nResult from isValidShortNumber: ");d.a(jc(O,f));e&&(d.a("\nResult from isPossibleShortNumberForRegion: "),d.a(dc(O,f,b)),d.a("\nResult from isValidShortNumberForRegion: "),d.a(hc(O,f,b)))}d.a("\n\n****Formatting Results:**** ");d.a("\nE164 format: ");
d.a(t?N(U,f,0):"invalid");d.a("\nOriginal format: ");d.a(vb(f,b));d.a("\nNational format: ");d.a(N(U,f,2));d.a("\nInternational format: ");d.a(t?N(U,f,1):"invalid");d.a("\nOut-of-country format from US: ");d.a(t?sb(U,f,"US"):"invalid");d.a("\nOut-of-country format from Switzerland: ");d.a(t?sb(U,f,"CH"):"invalid");0<c.length&&(d.a("\nNational format with carrier code: "),d.a(nb(U,f,c)));d.a("\nFormat for mobile dialing (calling from US): ");d.a(t?pb(f):"invalid");d.a("\nFormat for national dialing with preferred carrier code and empty fallback carrier code: ");
d.a(t?ob(U,f):"invalid");d.a("\n\n****AsYouTypeFormatter Results****");var mc=new Ib(b),nc=a.length;for(b=0;b<nc;++b){var tb=a.charAt(b);d.a("\nChar entered: ");d.a(tb);d.a(" Output: ");d.a(Pb(mc,tb))}}catch(oc){d.a("\n"+oc.toString())}n("output").value=d.toString();return!1}var X=["phoneNumberParser"],Y=ea;X[0]in Y||"undefined"==typeof Y.execScript||Y.execScript("var "+X[0]);for(var Z;X.length&&(Z=X.shift());)X.length||void 0===lc?Y[Z]&&Y[Z]!==Object.prototype[Z]?Y=Y[Z]:Y=Y[Z]={}:Y[Z]=lc;})();
function Pc(){this.g={}}na(Pc);function Qc(a){return(a=I[a])?a:[]}function Rc(a,b){a=Qc(v(a,1));return null!=b&&a.includes(b)}function Sc(a,b,c){if(!Rc(b,c))return!1;a=Tc(a,c);if(!a)return!1;b=Uc(b);c=q(a,1);if(!Vc(b,c))return!1;a=q(a,29);return Vc(b,a)}function Tc(a,b){if(!b)return null;b=b.toUpperCase();var c=a.g[b];if(null==c){c=Oc[b];if(null==c)return null;c=(new G).j(F.m(),c);a.g[b]=c}return c}
function Uc(a){if(!n(a,2))return"";var b=""+q(a,2);return n(a,4)&&q(a,4)&&0<v(a,8)?Array(v(a,8)+1).join("0")+b:b}function Vc(a,b){return 0<u(b,9).length&&!u(b,9).includes(a.length)?!1:K(v(b,2),a.toString())};var S=hb.ja();function Wc(a){switch(lc(S,a)){case 0:return"FIXED_LINE";case 1:return"MOBILE";case 2:return"FIXED_LINE_OR_MOBILE";case 3:return"TOLL_FREE";case 4:return"PREMIUM_RATE";case 5:return"SHARED_COST";case 6:return"VOIP";case 7:return"PERSONAL_NUMBER";case 8:return"PAGER";case 9:return"UAN";case -1:return"UNKNOWN"}}
function Xc(){var a=wa("phoneNumber").value,b=wa("defaultCountry").value.toUpperCase(),c=wa("carrierCode").value,d=new z;try{var f=S;if(!Ib(b)&&0<a.length&&"+"!=a.charAt(0))throw Error("Invalid country calling code");var e=vc(f,a,b,!0);d.g("****Parsing Result:****\n");d.g(JSON.stringify((new y(1)).l(e)));d.g("\n\n****Validation Results:****");var g=rc(e);var h=0==g||4==g;d.g("\nResult from isPossibleNumber(): ");d.g(h);var m=rc(e);f=b&&"ZZ"!=b;if(h)if(4==m)d.g("\nResult from isPossibleNumberWithReason(): "),
d.g("IS_POSSIBLE_LOCAL_ONLY"),d.g("\nNumber is considered invalid as it is not a possible national number.");else{var p=oc(S,e);d.g("\nResult from isValidNumber(): ");d.g(p);p&&f&&(d.g("\nResult from isValidNumberForRegion(): "),d.g(pc(S,e,b)));d.g("\nPhone Number region: ");d.g(mc(S,e));d.g("\nResult from getNumberType(): ");d.g(Wc(e))}else{d.g("\nResult from isPossibleNumberWithReason(): ");switch(m){case 1:d.g("INVALID_COUNTRY_CODE");break;case 2:d.g("TOO_SHORT");break;case 3:d.g("TOO_LONG");break;
case 5:d.g("INVALID_LENGTH")}d.g("\nNote: Numbers that are not possible have type UNKNOWN, an unknown region, and are considered invalid.")}if(!p){var r=Pc.ja();d.g("\n\n****ShortNumberInfo Results:****");d.g("\nResult from isPossibleShortNumber: ");var ha=d.g;a:{var Tb=Qc(v(e,1)),Zc=Uc(e).length;for(h=0;h<Tb.length;h++){var Ub=Tc(r,Tb[h]);if(Ub&&u(q(Ub,1),9).includes(Zc)){var Vb=!0;break a}}Vb=!1}ha.call(d,Vb);d.g("\nResult from isValidShortNumber: ");var $c=d.g,W=Qc(v(e,1));a:if(0===W.length)var ia=
null;else if(1===W.length)ia=W[0];else{var ad=Uc(e);for(ha=0;ha<W.length;ha++){var Wb=W[ha],Xb=Tc(r,Wb);if(Xb&&Vc(ad,q(Xb,29))){ia=Wb;break a}}ia=null}var bd=1<W.length&&null!=ia?!0:Sc(r,e,ia);$c.call(d,bd);if(f){d.g("\nResult from isPossibleShortNumberForRegion: ");var cd=d.g;if(Rc(e,b)){var Yb=Tc(r,b);if(Yb){var dd=Uc(e).length;var Sa=u(q(Yb,1),9).includes(dd)}else Sa=!1}else Sa=!1;cd.call(d,Sa);d.g("\nResult from isValidShortNumberForRegion: ");d.g(Sc(r,e,b))}}d.g("\n\n****Formatting Results:**** ");
d.g("\nE164 format: ");d.g(p?M(S,e,0):"invalid");d.g("\nOriginal format: ");var X=d.g;r=S;var Y;if(Y=n(e,5)){var Zb=v(e,1),$b=O(r,Zb,P(Zb));if(null==$b)var ac=!1;else{var ed=N(e);ac=null!=Qb(u($b,19),ed)}Y=!ac}if(Y)var ja=v(e,5);else if(n(e,6)){switch(q(e,6)){case 1:var B=M(r,e,1);break;case 5:B=Ob(r,e,b);break;case 10:B=M(r,e,1).substring(1);break;default:var ka=P(v(e,1));var bc=Q(r,ka);if(null==bc)var la=null;else{var Ta=v(bc,12);la=0==Ta.length?null:Ta=Ta.replace("~","")}var ma=M(r,e,2);if(null==
la||0==la.length)B=ma;else{b:{var fd=v(e,5);Y=la;var cc=L(fd,ib);if(0==cc.lastIndexOf(Y,0))try{var dc=oc(r,vc(r,cc.substring(Y.length),ka,!1));break b}catch(ec){}dc=!1}if(dc)B=ma;else{var gd=Q(r,ka),hd=N(e),Ua=Qb(u(gd,19),hd);if(null==Ua)B=ma;else{var Z=v(Ua,4),fc=Z.indexOf("$1");if(0>=fc)B=ma;else if(Z=Z.substring(0,fc),Z=L(Z,ib),0==Z.length)B=ma;else{var gc=Ua.clone();Qa(gc,4);ka=[gc];var Aa=v(e,1),Ba=N(e);if(Aa in I){var hc=O(r,Aa,P(Aa)),Va=Qb(ka,Ba);if(null==Va)var ic=Ba;else{var Wa=Va.clone(),
Ca=v(Va,4);if(0<Ca.length){var jc=v(hc,12);0<jc.length?(Ca=Ca.replace(zb,jc).replace(Ab,"$1"),t(Wa,4,Ca)):Qa(Wa,4)}ic=Rb(Ba,Wa,2)}var id=Kb(e,hc,2);B=Jb(Aa,2,ic,id)}else B=Ba}}}}}var Xa=v(e,5);if(null!=B&&0<Xa.length){var jd=L(B,jb),kd=L(Xa,jb);jd!=kd&&(B=Xa)}ja=B}else ja=M(r,e,2);X.call(d,ja);d.g("\nNational format: ");d.g(M(S,e,2));d.g("\nInternational format: ");d.g(p?M(S,e,1):"invalid");d.g("\nOut-of-country format from US: ");d.g(p?Ob(S,e,"US"):"invalid");d.g("\nOut-of-country format from Switzerland: ");
d.g(p?Ob(S,e,"CH"):"invalid");0<c.length&&(d.g("\nNational format with carrier code: "),d.g(Mb(S,e,c)));d.g("\nFormat for mobile dialing (calling from US): ");var ld=d.g;if(p)a:{c=S;var Ya=v(e,1);if(Ya in I){X="";var C=e.clone();Qa(C,3);var aa=P(Ya),T=lc(c,C);ja=-1!=T;if("US"==aa)if(T=0==T||1==T||2==T,"BR"==aa&&T)X=0<v(C,7).length?Nb(c,C):"";else if(1==Ya){var md=Q(c,"US"),Za;if(Za=wc(c,C)){var nd=N(C);Za=2!=qc(c,nd,md,-1)}X=Za?M(c,C,1):M(c,C,2)}else X=("001"==aa||("MX"==aa||"CL"==aa||"UZ"==aa)&&
T)&&wc(c,C)?M(c,C,1):M(c,C,2);else if(ja&&wc(c,C)){var Da=M(c,C,1);break a}Da=X}else Da=n(e,5)?v(e,5):""}else Da="invalid";ld.call(d,Da);d.g("\nFormat for national dialing with preferred carrier code and empty fallback carrier code: ");d.g(p?Nb(S,e):"invalid");d.g("\n\n****AsYouTypeFormatter Results****");var od=new xc(b),pd=a.length;for(b=0;b<pd;++b){var kc=a.charAt(b);d.g("\nChar entered: ");d.g(kc);d.g(" Output: ");e=d;var qd=e.g;p=od;p.ma=Ec(p,kc);qd.call(e,p.ma)}}catch(ec){d.g("\n"+ec.toString())}wa("output").value=
d.toString();return!1}var Yc=["phoneNumberParser"],U=fa;Yc[0]in U||"undefined"==typeof U.execScript||U.execScript("var "+Yc[0]);for(var V;Yc.length&&(V=Yc.shift());)Yc.length||void 0===Xc?U[V]&&U[V]!==Object.prototype[V]?U=U[V]:U=U[V]={}:U[V]=Xc;})();

+ 208
- 60
javascript/i18n/phonenumbers/phonenumberutil.js View File

@ -67,9 +67,10 @@ goog.addSingletonGetter(i18n.phonenumbers.PhoneNumberUtil);
*/
i18n.phonenumbers.Error = {
INVALID_COUNTRY_CODE: 'Invalid country calling code',
// This generally indicates the string passed in had less than 3 digits in it.
// This indicates the string passed is not a valid number. Either the string
// had less than 3 digits in it or had an invalid phone-context parameter.
// More specifically, the number failed to match the regular expression
// VALID_PHONE_NUMBER.
// VALID_PHONE_NUMBER, RFC3966_GLOBAL_NUMBER_DIGITS, or RFC3966_DOMAINNAME.
NOT_A_NUMBER: 'The string supplied did not seem to be a phone number',
// This indicates the string started with an international dialing prefix, but
// after this was stripped from the number, had less digits than any valid
@ -730,6 +731,90 @@ i18n.phonenumbers.PhoneNumberUtil.VALID_PHONE_NUMBER_ =
*/
i18n.phonenumbers.PhoneNumberUtil.DEFAULT_EXTN_PREFIX_ = ' ext. ';
/**
* @const
* @type {string}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_VISUAL_SEPARATOR_ = '[\\-\\.\\(\\)]?';
/**
* @const
* @type {string}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_DIGIT_ = '(['
+ i18n.phonenumbers.PhoneNumberUtil.VALID_DIGITS_ + ']|'
+ i18n.phonenumbers.PhoneNumberUtil.RFC3966_VISUAL_SEPARATOR_ + ')';
/**
* @const
* @type {string}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_GLOBAL_NUMBER_DIGITS_ = '^\\'
+ i18n.phonenumbers.PhoneNumberUtil.PLUS_SIGN
+ i18n.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_DIGIT_ + '*['
+ i18n.phonenumbers.PhoneNumberUtil.VALID_DIGITS_ + ']'
+ i18n.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_DIGIT_ + '*$';
/**
* Regular expression of valid global-number-digits for the phone-context
* parameter, following the syntax defined in RFC3966.
*
* @const
* @type {RegExp}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_ =
new RegExp(i18n.phonenumbers.PhoneNumberUtil.RFC3966_GLOBAL_NUMBER_DIGITS_);
/**
* @const
* @type {string}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.ALPHANUM_ =
i18n.phonenumbers.PhoneNumberUtil.VALID_ALPHA_
+ i18n.phonenumbers.PhoneNumberUtil.VALID_DIGITS_;
/**
* @const
* @type {string}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_DOMAINLABEL_ = '['
+ i18n.phonenumbers.PhoneNumberUtil.ALPHANUM_ + ']+((\\-)*['
+ i18n.phonenumbers.PhoneNumberUtil.ALPHANUM_ + '])*';
/**
* @const
* @type {string}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_TOPLABEL_ = '['
+ i18n.phonenumbers.PhoneNumberUtil.VALID_ALPHA_ + ']+((\\-)*['
+ i18n.phonenumbers.PhoneNumberUtil.ALPHANUM_ + '])*';
/**
* @const
* @type {string}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_DOMAINNAME_ = '^('
+ i18n.phonenumbers.PhoneNumberUtil.RFC3966_DOMAINLABEL_ + '\\.)*'
+ i18n.phonenumbers.PhoneNumberUtil.RFC3966_TOPLABEL_ + '\\.?$';
/**
* Regular expression of valid domainname for the phone-context parameter,
* following the syntax defined in RFC3966.
*
* @const
* @type {RegExp}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.RFC3966_DOMAINNAME_PATTERN_ =
new RegExp(i18n.phonenumbers.PhoneNumberUtil.RFC3966_DOMAINNAME_);
/**
* Helper method for constructing regular expressions for parsing. Creates
@ -4298,6 +4383,74 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.parseHelper_ =
};
/**
* Extracts the value of the phone-context parameter of numberToExtractFrom,
* following the syntax defined in RFC3966.
* @param numberToExtractFrom
* @return {string|null} the extracted string (possibly empty), or null if no
* phone-context parameter is found.
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.prototype.extractPhoneContext_ =
function (numberToExtractFrom) {
/** @type {number} */
var indexOfPhoneContext = numberToExtractFrom.indexOf(i18n
.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_CONTEXT_);
// If no phone-context parameter is present
if (indexOfPhoneContext === -1) {
return null;
}
/** @type {number} */
var phoneContextStart = indexOfPhoneContext + i18n
.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_CONTEXT_.length;
// If phone-context parameter is empty
if (phoneContextStart >= numberToExtractFrom.length) {
return "";
}
/** @type {number} */
var phoneContextEnd = numberToExtractFrom.indexOf(';', phoneContextStart);
// If phone-context is not the last parameter
if (phoneContextEnd !== -1) {
return numberToExtractFrom.substring(phoneContextStart,
phoneContextEnd);
} else {
return numberToExtractFrom.substring(phoneContextStart);
}
}
/**
* Returns whether the value of phoneContext follows the syntax defined in
* RFC3966.
*
* @param {string|null} phoneContext
* @return {boolean}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.prototype.isPhoneContextValid_ =
function (phoneContext) {
if (phoneContext == null) {
return true;
}
if (phoneContext.length === 0) {
return false;
}
var globalNumberDigitsMatcher =
i18n.phonenumbers.PhoneNumberUtil.RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.exec(
phoneContext);
var domainnameMatcher =
i18n.phonenumbers.PhoneNumberUtil.RFC3966_DOMAINNAME_PATTERN_.exec(
phoneContext);
// Does phone-context value match pattern of global-number-digits or
// domainname
return globalNumberDigitsMatcher !== null || domainnameMatcher !== null;
}
/**
* Converts numberToParse to a form that we can parse and write it to
* nationalNumber if it is written in RFC3966; otherwise extract a possible
@ -4308,71 +4461,66 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.parseHelper_ =
* extension.
* @param {!goog.string.StringBuffer} nationalNumber a string buffer for storing
* the national significant number.
* @throws {Error}
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.prototype.buildNationalNumberForParsing_ =
function(numberToParse, nationalNumber) {
function (numberToParse, nationalNumber) {
var phoneContext =
i18n.phonenumbers.PhoneNumberUtil.prototype.extractPhoneContext_(
numberToParse);
if (!i18n.phonenumbers.PhoneNumberUtil.prototype.isPhoneContextValid_(
phoneContext)) {
throw new Error(i18n.phonenumbers.Error.NOT_A_NUMBER);
}
if (phoneContext != null) {
// If the phone context contains a phone number prefix, we need to capture
// it, whereas domains will be ignored.
if (phoneContext.charAt(0) ===
i18n.phonenumbers.PhoneNumberUtil.PLUS_SIGN) {
nationalNumber.append(phoneContext);
}
/** @type {number} */
var indexOfPhoneContext = numberToParse.indexOf(
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_CONTEXT_);
if (indexOfPhoneContext >= 0) {
var phoneContextStart = indexOfPhoneContext +
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_CONTEXT_.length;
// If the phone context contains a phone number prefix, we need to capture
// it, whereas domains will be ignored.
// No length check is necessary, as per C++ or Java, since out-of-bounds
// requests to charAt return an empty string.
if (numberToParse.charAt(phoneContextStart) ==
i18n.phonenumbers.PhoneNumberUtil.PLUS_SIGN) {
// Additional parameters might follow the phone context. If so, we will
// remove them here because the parameters after phone context are not
// important for parsing the phone number.
var phoneContextEnd = numberToParse.indexOf(';', phoneContextStart);
if (phoneContextEnd > 0) {
nationalNumber.append(numberToParse.substring(phoneContextStart,
phoneContextEnd));
// Now append everything between the "tel:" prefix and the phone-context.
// This should include the national number, an optional extension or
// isdn-subaddress component. Note we also handle the case when "tel:" is
// missing, as we have seen in some of the phone number inputs.
// In that case, we append everything from the beginning.
var indexOfRfc3966Prefix = numberToParse.indexOf(
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PREFIX_);
var indexOfNationalNumber = (indexOfRfc3966Prefix >= 0) ?
indexOfRfc3966Prefix +
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PREFIX_.length : 0;
var indexOfPhoneContext = numberToParse.indexOf(
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PHONE_CONTEXT_);
nationalNumber.append(numberToParse.substring(indexOfNationalNumber,
indexOfPhoneContext));
} else {
nationalNumber.append(numberToParse.substring(phoneContextStart));
// Extract a possible number from the string passed in (this strips leading
// characters that could not be the start of a phone number.)
nationalNumber.append(
i18n.phonenumbers.PhoneNumberUtil.extractPossibleNumber(
numberToParse ?? ""));
}
}
// Now append everything between the "tel:" prefix and the phone-context.
// This should include the national number, an optional extension or
// isdn-subaddress component. Note we also handle the case when "tel:" is
// missing, as we have seen in some of the phone number inputs.
// In that case, we append everything from the beginning.
var indexOfRfc3966Prefix = numberToParse.indexOf(
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PREFIX_);
var indexOfNationalNumber = (indexOfRfc3966Prefix >= 0) ?
indexOfRfc3966Prefix +
i18n.phonenumbers.PhoneNumberUtil.RFC3966_PREFIX_.length : 0;
nationalNumber.append(numberToParse.substring(indexOfNationalNumber,
indexOfPhoneContext));
} else {
// Extract a possible number from the string passed in (this strips leading
// characters that could not be the start of a phone number.)
nationalNumber.append(
i18n.phonenumbers.PhoneNumberUtil.extractPossibleNumber(numberToParse));
}
// Delete the isdn-subaddress and everything after it if it is present.
// Note extension won't appear at the same time with isdn-subaddress
// according to paragraph 5.3 of the RFC3966 spec,
/** @type {string} */
var nationalNumberStr = nationalNumber.toString();
var indexOfIsdn = nationalNumberStr.indexOf(
i18n.phonenumbers.PhoneNumberUtil.RFC3966_ISDN_SUBADDRESS_);
if (indexOfIsdn > 0) {
nationalNumber.clear();
nationalNumber.append(nationalNumberStr.substring(0, indexOfIsdn));
}
// If both phone context and isdn-subaddress are absent but other
// parameters are present, the parameters are left in nationalNumber. This
// is because we are concerned about deleting content from a potential
// number string when there is no strong evidence that the number is
// actually written in RFC3966.
};
// Delete the isdn-subaddress and everything after it if it is present.
// Note extension won't appear at the same time with isdn-subaddress
// according to paragraph 5.3 of the RFC3966 spec,
/** @type {string} */
var nationalNumberStr = nationalNumber.toString();
var indexOfIsdn = nationalNumberStr.indexOf(
i18n.phonenumbers.PhoneNumberUtil.RFC3966_ISDN_SUBADDRESS_);
if (indexOfIsdn > 0) {
nationalNumber.clear();
nationalNumber.append(nationalNumberStr.substring(0, indexOfIsdn));
}
// If both phone context and isdn-subaddress are absent but other
// parameters are present, the parameters are left in nationalNumber. This
// is because we are concerned about deleting content from a potential
// number string when there is no strong evidence that the number is
// actually written in RFC3966.
};
/**


+ 66
- 10
javascript/i18n/phonenumbers/phonenumberutil_test.js View File

@ -896,7 +896,7 @@ function testFormatOutOfCountryWithPreferredIntlPrefix() {
assertEquals(
'0011 39 02 3661 8300',
phoneUtil.formatOutOfCountryCallingNumber(IT_NUMBER, RegionCode.AU));
// Testing preferred international prefixes with ~ are supported (designates
// waiting).
assertEquals(
@ -2818,11 +2818,6 @@ function testParseNationalNumber() {
'tel:253-0000;phone-context=www.google.com', RegionCode.US)));
assertTrue(US_LOCAL_NUMBER.equals(phoneUtil.parse(
'tel:253-0000;isub=12345;phone-context=www.google.com', RegionCode.US)));
// This is invalid because no "+" sign is present as part of phone-context.
// The phone context is simply ignored in this case just as if it contains a
// domain.
assertTrue(US_LOCAL_NUMBER.equals(phoneUtil.parse(
'tel:2530000;isub=12345;phone-context=1-650', RegionCode.US)));
assertTrue(US_LOCAL_NUMBER.equals(phoneUtil.parse(
'tel:2530000;isub=12345;phone-context=1234.com', RegionCode.US)));
@ -3330,20 +3325,19 @@ function testFailedParseOnInvalidNumbers() {
/** @type {string} */
var invalidRfcPhoneContext = 'tel:555-1234;phone-context=1-331';
phoneUtil.parse(invalidRfcPhoneContext, RegionCode.ZZ);
fail('"Unknown" region code not allowed: should fail.');
fail('phone-context is missing "+" sign: should fail.');
} catch (e) {
// Expected this exception.
assertEquals(
'Wrong error type stored in exception.',
i18n.phonenumbers.Error.INVALID_COUNTRY_CODE, e.message);
i18n.phonenumbers.Error.NOT_A_NUMBER, e.message);
}
try {
// Only the phone-context symbol is present, but no data.
invalidRfcPhoneContext = ';phone-context=';
phoneUtil.parse(invalidRfcPhoneContext, RegionCode.ZZ);
fail(
'Should have thrown an exception, no valid country calling code ' +
'present.');
'phone-context can\'t be empty: should fail.');
} catch (e) {
// Expected.
assertEquals(
@ -3792,6 +3786,68 @@ function testParseItalianLeadingZeros() {
assertTrue(threeZeros.equals(phoneUtil.parse('0000', RegionCode.AU)));
}
function testParseWithPhoneContext() {
// context = ";phone-context=" descriptor
// descriptor = domainname / global-number-digits
// Valid global-phone-digits
assertTrue(NZ_NUMBER.equals(
phoneUtil.parse("tel:033316005;phone-context=+64", RegionCode.ZZ)));
assertTrue(NZ_NUMBER.equals(phoneUtil.parse(
"tel:033316005;phone-context=+64;{this isn't part of phone-context anymore!}",
RegionCode.ZZ)));
/** @type {!i18n.phonenumbers.PhoneNumber} */
var nzFromPhoneContext = new i18n.phonenumbers.PhoneNumber();
nzFromPhoneContext.setCountryCode(64);
nzFromPhoneContext.setNationalNumber(3033316005);
assertTrue(nzFromPhoneContext.equals(
phoneUtil.parse("tel:033316005;phone-context=+64-3", RegionCode.ZZ)));
/** @type {!i18n.phonenumbers.PhoneNumber} */
var brFromPhoneContext = new i18n.phonenumbers.PhoneNumber();
brFromPhoneContext.setCountryCode(55);
brFromPhoneContext.setNationalNumber(5033316005);
assertTrue(brFromPhoneContext.equals(
phoneUtil.parse("tel:033316005;phone-context=+(555)", RegionCode.ZZ)));
/** @type {!i18n.phonenumbers.PhoneNumber} */
var usFromPhoneContext = new i18n.phonenumbers.PhoneNumber();
usFromPhoneContext.setCountryCode(1);
usFromPhoneContext.setNationalNumber(23033316005);
assertTrue(usFromPhoneContext.equals(
phoneUtil.parse("tel:033316005;phone-context=+-1-2.3()", RegionCode.ZZ)));
// Valid domainname
assertTrue(NZ_NUMBER.equals(
phoneUtil.parse("tel:033316005;phone-context=abc.nz", RegionCode.NZ)));
assertTrue(NZ_NUMBER.equals(
phoneUtil.parse("tel:033316005;phone-context=www.PHONE-numb3r.com",
RegionCode.NZ)));
assertTrue(NZ_NUMBER.equals(
phoneUtil.parse("tel:033316005;phone-context=a", RegionCode.NZ)));
assertTrue(NZ_NUMBER.equals(
phoneUtil.parse("tel:033316005;phone-context=3phone.J.", RegionCode.NZ)));
assertTrue(NZ_NUMBER.equals(
phoneUtil.parse("tel:033316005;phone-context=a--z", RegionCode.NZ)));
// Invalid descriptor
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=+");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=64");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=++64");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=+abc");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=.");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=3phone");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=a-.nz");
assertThrowsForInvalidPhoneContext("tel:033316005;phone-context=a{b}c");
}
function assertThrowsForInvalidPhoneContext(numberToParse) {
try {
phoneUtil.parse(numberToParse, RegionCode.ZZ);
} catch (e) {
assertEquals(i18n.phonenumbers.Error.NOT_A_NUMBER, e.message);
}
}
function testCountryWithNoNumberDesc() {
var PNF = i18n.phonenumbers.PhoneNumberFormat;
var PNT = i18n.phonenumbers.PhoneNumberType;


+ 4
- 1
pending_code_changes.txt View File

@ -1 +1,4 @@
Code changes:
- Added a check to PhoneNumberUtil that the value of the `phone-context`
parameter of the tel URI follows the correct syntax as defined in
[RFC3966](https://www.rfc-editor.org/rfc/rfc3966#section-3).

Loading…
Cancel
Save