pixel-react 1.14.87 → 1.14.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +75 -75
  2. package/lib/_virtual/index10.js +2 -2
  3. package/lib/_virtual/index11.js +2 -2
  4. package/lib/_virtual/index12.js +2 -2
  5. package/lib/_virtual/index9.js +2 -2
  6. package/lib/assets/icons/dataset_list.svg.js +1 -1
  7. package/lib/assets/icons/dataset_list.svg.js.map +1 -1
  8. package/lib/assets/icons/spinner.svg.js +1 -1
  9. package/lib/assets/icons/spinner.svg.js.map +1 -1
  10. package/lib/components/Chip/Chip.js +1 -1
  11. package/lib/components/Chip/Chip.js.map +1 -1
  12. package/lib/components/NLPInput/components/NlpDropDown/NlpDropdown.js +9 -0
  13. package/lib/components/NLPInput/components/NlpDropDown/NlpDropdown.js.map +1 -1
  14. package/lib/components/Select/Select.js +3 -2
  15. package/lib/components/Select/Select.js.map +1 -1
  16. package/lib/index.cjs +1362 -6766
  17. package/lib/index.cjs.map +1 -1
  18. package/lib/index.d.ts +1 -1
  19. package/lib/node_modules/js-beautify/js/src/css/beautifier.js +1 -1
  20. package/lib/node_modules/js-beautify/js/src/css/index.js +1 -1
  21. package/lib/node_modules/js-beautify/js/src/css/options.js +1 -1
  22. package/lib/node_modules/js-beautify/js/src/html/beautifier.js +1 -1
  23. package/lib/node_modules/js-beautify/js/src/html/index.js +1 -1
  24. package/lib/node_modules/js-beautify/js/src/html/options.js +1 -1
  25. package/lib/node_modules/js-beautify/js/src/html/tokenizer.js +1 -1
  26. package/lib/node_modules/js-beautify/js/src/javascript/index.js +1 -1
  27. package/lib/node_modules/js-beautify/js/src/javascript/tokenizer.js +1 -1
  28. package/lib/node_modules/libphonenumber-js/es6/AsYouType.js +6 -8
  29. package/lib/node_modules/libphonenumber-js/es6/AsYouType.js.map +1 -1
  30. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.complete.js +4 -4
  31. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.complete.js.map +1 -1
  32. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.js +4 -4
  33. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.js.map +1 -1
  34. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeParser.js +41 -28
  35. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeParser.js.map +1 -1
  36. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeState.js +21 -17
  37. package/lib/node_modules/libphonenumber-js/es6/AsYouTypeState.js.map +1 -1
  38. package/lib/node_modules/libphonenumber-js/es6/PhoneNumber.js +1 -1
  39. package/lib/node_modules/libphonenumber-js/es6/PhoneNumber.js.map +1 -1
  40. package/lib/node_modules/libphonenumber-js/es6/format.js +50 -91
  41. package/lib/node_modules/libphonenumber-js/es6/format.js.map +1 -1
  42. package/lib/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +39 -6
  43. package/lib/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js.map +1 -1
  44. package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +13 -10
  45. package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js.map +1 -1
  46. package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +10 -8
  47. package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -1
  48. package/lib/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +15 -5
  49. package/lib/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js.map +1 -1
  50. package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +2 -2
  51. package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js.map +1 -1
  52. package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +30 -8
  53. package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js.map +1 -1
  54. package/lib/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +4 -4
  55. package/lib/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js.map +1 -1
  56. package/lib/node_modules/libphonenumber-js/es6/isPossible.js +4 -4
  57. package/lib/node_modules/libphonenumber-js/es6/isPossible.js.map +1 -1
  58. package/lib/node_modules/libphonenumber-js/es6/metadata.js +1 -1
  59. package/lib/node_modules/libphonenumber-js/es6/metadata.js.map +1 -1
  60. package/lib/node_modules/libphonenumber-js/es6/parse.js +9 -7
  61. package/lib/node_modules/libphonenumber-js/es6/parse.js.map +1 -1
  62. package/lib/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +7 -7
  63. package/lib/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js.map +1 -1
  64. package/lib/node_modules/libphonenumber-js/metadata.min.json.js +11 -11
  65. package/lib/node_modules/libphonenumber-js/metadata.min.json.js.map +1 -1
  66. package/lib/node_modules/prop-types/index.js +1 -1
  67. package/lib/node_modules/react-day-picker/dist/esm/DayPicker.js +33 -21
  68. package/lib/node_modules/react-day-picker/dist/esm/DayPicker.js.map +1 -1
  69. package/lib/node_modules/react-day-picker/dist/esm/classes/DateLib.js +41 -0
  70. package/lib/node_modules/react-day-picker/dist/esm/classes/DateLib.js.map +1 -1
  71. package/lib/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js +3 -2
  72. package/lib/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js.map +1 -1
  73. package/lib/node_modules/react-day-picker/dist/esm/labels/labelGrid.js +3 -2
  74. package/lib/node_modules/react-day-picker/dist/esm/labels/labelGrid.js.map +1 -1
  75. package/lib/node_modules/react-hook-form/dist/index.esm.js +60 -38
  76. package/lib/node_modules/react-hook-form/dist/index.esm.js.map +1 -1
  77. package/lib/node_modules/react-virtuoso/dist/index.js +397 -397
  78. package/lib/node_modules/react-virtuoso/dist/index.js.map +1 -1
  79. package/lib/node_modules/ua-parser-js/src/ua-parser.js +85 -71
  80. package/lib/node_modules/ua-parser-js/src/ua-parser.js.map +1 -1
  81. package/lib/styles.css +1 -1
  82. package/lib/styles.css.map +1 -1
  83. package/lib/utils/getEncryptedData/getEncryptedData.d.ts +1 -1
  84. package/lib/utils/getEncryptedData/getEncryptedData.js +17 -8
  85. package/lib/utils/getEncryptedData/getEncryptedData.js.map +1 -1
  86. package/package.json +106 -107
  87. package/lib/node_modules/jsencrypt/lib/JSEncrypt.js +0 -246
  88. package/lib/node_modules/jsencrypt/lib/JSEncrypt.js.map +0 -1
  89. package/lib/node_modules/jsencrypt/lib/JSEncryptRSAKey.js +0 -325
  90. package/lib/node_modules/jsencrypt/lib/JSEncryptRSAKey.js.map +0 -1
  91. package/lib/node_modules/jsencrypt/lib/index.js +0 -6
  92. package/lib/node_modules/jsencrypt/lib/index.js.map +0 -1
  93. package/lib/node_modules/jsencrypt/lib/lib/asn1js/asn1.js +0 -570
  94. package/lib/node_modules/jsencrypt/lib/lib/asn1js/asn1.js.map +0 -1
  95. package/lib/node_modules/jsencrypt/lib/lib/asn1js/base64.js +0 -88
  96. package/lib/node_modules/jsencrypt/lib/lib/asn1js/base64.js.map +0 -1
  97. package/lib/node_modules/jsencrypt/lib/lib/asn1js/hex.js +0 -66
  98. package/lib/node_modules/jsencrypt/lib/lib/asn1js/hex.js.map +0 -1
  99. package/lib/node_modules/jsencrypt/lib/lib/asn1js/int10.js +0 -87
  100. package/lib/node_modules/jsencrypt/lib/lib/asn1js/int10.js.map +0 -1
  101. package/lib/node_modules/jsencrypt/lib/lib/jsbn/base64.js +0 -65
  102. package/lib/node_modules/jsencrypt/lib/lib/jsbn/base64.js.map +0 -1
  103. package/lib/node_modules/jsencrypt/lib/lib/jsbn/jsbn.js +0 -1700
  104. package/lib/node_modules/jsencrypt/lib/lib/jsbn/jsbn.js.map +0 -1
  105. package/lib/node_modules/jsencrypt/lib/lib/jsbn/prng4.js +0 -48
  106. package/lib/node_modules/jsencrypt/lib/lib/jsbn/prng4.js.map +0 -1
  107. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rng.js +0 -77
  108. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rng.js.map +0 -1
  109. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rsa.js +0 -415
  110. package/lib/node_modules/jsencrypt/lib/lib/jsbn/rsa.js.map +0 -1
  111. package/lib/node_modules/jsencrypt/lib/lib/jsbn/sha256.js +0 -307
  112. package/lib/node_modules/jsencrypt/lib/lib/jsbn/sha256.js.map +0 -1
  113. package/lib/node_modules/jsencrypt/lib/lib/jsbn/util.js +0 -61
  114. package/lib/node_modules/jsencrypt/lib/lib/jsbn/util.js.map +0 -1
  115. package/lib/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js +0 -1559
  116. package/lib/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js.map +0 -1
@@ -37,21 +37,25 @@ function _toPrimitive(t, r) {
37
37
  }
38
38
  // This "state" object simply holds the state of the "AsYouType" parser:
39
39
  //
40
- // * `country?: string`
41
- // * `callingCode?: string`
42
- // * `digits: string`
43
- // * `international: boolean`
44
- // * `missingPlus: boolean`
45
- // * `IDDPrefix?: string`
46
- // * `carrierCode?: string`
47
- // * `nationalPrefix?: string`
48
- // * `nationalSignificantNumber?: string`
49
- // * `nationalSignificantNumberMatchesInput: boolean`
50
- // * `complexPrefixBeforeNationalSignificantNumber?: string`
51
- //
52
- // `state.country` and `state.callingCode` aren't required to be in sync.
53
- // For example, `state.country` could be `"AR"` and `state.callingCode` could be `undefined`.
54
- // So `state.country` and `state.callingCode` are totally independent.
40
+ // * `country?: string` — The exact country of the phone number, if it could be determined.
41
+ // When inputting a phone number in "international" format, it will derive the `country` from "country calling code" and the phone number digits.
42
+ // When inputting a phone number in "national" format, it will derive the `country` from `defaultCountry` that was specified when creating the `AsYouType` formatter.
43
+ // Sidenote: If `USE_NON_GEOGRAPHIC_COUNTRY_CODE` flag was `true`, then for "non-geographic phone numbers" `state.country` would've been "001".
44
+ // * `callingCode?: string` — "Country calling code" that has been extracted from the input phone number.
45
+ // When inputting a phone number in "international" format, it will extract the "country calling code" from the digits that follow the "+" character.
46
+ // When inputting a phone number in "national" format, `callingCode` will be `undefined`.
47
+ // Sidenote: `state.callingCode` is therefore independent from `state.country` and there could be situations when `state.country` is defined by `state.callingCode` is not — that would be when inputting a phone number not in "international" format.
48
+ // * `digits: string` — Phone number digits that have been input so far, including the "+" character, if present. In case of inputting non-arabic digits, those will be converted to arabic ones.
49
+ // * `international: boolean` — Whether the phone number is being input in "international" format, i.e. with a "+" character.
50
+ // * `missingPlus: boolean` — Whether it's a phone number in "international" format that is missing the leading "+" character for some reason — apparently, Google thinks that it's a common mistake when inputting a phone number.
51
+ // * `IDDPrefix?: string` — An "IDD prefix", when the phone number is being input in an "out-of-country dialing" format. https://wikitravel.org/en/International_dialling_prefix
52
+ // * `carrierCode?: string` A "carrier code", if the phone number contains it. Normally, those can only be present in Colombia or Brazil, and only when calling from mobile phones to fixed-line numbers.
53
+ // * `nationalPrefix?: string` "National prefix", if present in the phone number input.
54
+ // * `nationalSignificantNumber?: string` National (significant) number digits that have been input so far.
55
+ // * `nationalSignificantNumberIsModified: boolean` — Tells if the parsed national (significant) number is present as-is in the input string. For example, when inputting "0343515551212999" Argentinian mobile number, the parsed national (significant) number is "93435551212999". There, one can see how it stripped "0" national prefix and prepended a "9", because that's how it is instructed to do in Argentina's metadata. So in the described example, the parsed national (significant) number is not present as-is in the input string. Instead, it's "modified" in the input string. https://gitlab.com/caamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
56
+ // * `prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix?: string` — In some countries, a phone number could have a prefix that is not a "national prefix" but rather some other type of "utility" prefix.
57
+ // For example, when calling within Australia, one could prepend `1831` prefix to hide caller's phone number.
58
+ // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
55
59
  //
56
60
  var AsYouTypeState = /*#__PURE__*/function () {
57
61
  function AsYouTypeState(_ref) {
@@ -78,10 +82,10 @@ var AsYouTypeState = /*#__PURE__*/function () {
78
82
  key: "resetNationalSignificantNumber",
79
83
  value: function resetNationalSignificantNumber() {
80
84
  this.nationalSignificantNumber = this.getNationalDigits();
81
- this.nationalSignificantNumberMatchesInput = true;
85
+ this.nationalSignificantNumberIsModified = false;
82
86
  this.nationalPrefix = undefined;
83
87
  this.carrierCode = undefined;
84
- this.complexPrefixBeforeNationalSignificantNumber = undefined;
88
+ this.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix = undefined;
85
89
  }
86
90
  }, {
87
91
  key: "update",
@@ -1 +1 @@
1
- {"version":3,"file":"AsYouTypeState.js","sources":["../../../../node_modules/libphonenumber-js/es6/AsYouTypeState.js"],"sourcesContent":["function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n// This \"state\" object simply holds the state of the \"AsYouType\" parser:\n//\n// * `country?: string`\n// * `callingCode?: string`\n// * `digits: string`\n// * `international: boolean`\n// * `missingPlus: boolean`\n// * `IDDPrefix?: string`\n// * `carrierCode?: string`\n// * `nationalPrefix?: string`\n// * `nationalSignificantNumber?: string`\n// * `nationalSignificantNumberMatchesInput: boolean`\n// * `complexPrefixBeforeNationalSignificantNumber?: string`\n//\n// `state.country` and `state.callingCode` aren't required to be in sync.\n// For example, `state.country` could be `\"AR\"` and `state.callingCode` could be `undefined`.\n// So `state.country` and `state.callingCode` are totally independent.\n//\nvar AsYouTypeState = /*#__PURE__*/function () {\n function AsYouTypeState(_ref) {\n var onCountryChange = _ref.onCountryChange,\n onCallingCodeChange = _ref.onCallingCodeChange;\n _classCallCheck(this, AsYouTypeState);\n this.onCountryChange = onCountryChange;\n this.onCallingCodeChange = onCallingCodeChange;\n }\n return _createClass(AsYouTypeState, [{\n key: \"reset\",\n value: function reset(_ref2) {\n var country = _ref2.country,\n callingCode = _ref2.callingCode;\n this.international = false;\n this.missingPlus = false;\n this.IDDPrefix = undefined;\n this.callingCode = undefined;\n this.digits = '';\n this.resetNationalSignificantNumber();\n this.initCountryAndCallingCode(country, callingCode);\n }\n }, {\n key: \"resetNationalSignificantNumber\",\n value: function resetNationalSignificantNumber() {\n this.nationalSignificantNumber = this.getNationalDigits();\n this.nationalSignificantNumberMatchesInput = true;\n this.nationalPrefix = undefined;\n this.carrierCode = undefined;\n this.complexPrefixBeforeNationalSignificantNumber = undefined;\n }\n }, {\n key: \"update\",\n value: function update(properties) {\n for (var _i = 0, _Object$keys = Object.keys(properties); _i < _Object$keys.length; _i++) {\n var key = _Object$keys[_i];\n this[key] = properties[key];\n }\n }\n }, {\n key: \"initCountryAndCallingCode\",\n value: function initCountryAndCallingCode(country, callingCode) {\n this.setCountry(country);\n this.setCallingCode(callingCode);\n }\n }, {\n key: \"setCountry\",\n value: function setCountry(country) {\n this.country = country;\n this.onCountryChange(country);\n }\n }, {\n key: \"setCallingCode\",\n value: function setCallingCode(callingCode) {\n this.callingCode = callingCode;\n this.onCallingCodeChange(callingCode, this.country);\n }\n }, {\n key: \"startInternationalNumber\",\n value: function startInternationalNumber(country, callingCode) {\n // Prepend the `+` to parsed input.\n this.international = true;\n // If a default country was set then reset it\n // because an explicitly international phone\n // number is being entered.\n this.initCountryAndCallingCode(country, callingCode);\n }\n }, {\n key: \"appendDigits\",\n value: function appendDigits(nextDigits) {\n this.digits += nextDigits;\n }\n }, {\n key: \"appendNationalSignificantNumberDigits\",\n value: function appendNationalSignificantNumberDigits(nextDigits) {\n this.nationalSignificantNumber += nextDigits;\n }\n\n /**\r\n * Returns the part of `this.digits` that corresponds to the national number.\r\n * Basically, all digits that have been input by the user, except for the\r\n * international prefix and the country calling code part\r\n * (if the number is an international one).\r\n * @return {string}\r\n */\n }, {\n key: \"getNationalDigits\",\n value: function getNationalDigits() {\n if (this.international) {\n return this.digits.slice((this.IDDPrefix ? this.IDDPrefix.length : 0) + (this.callingCode ? this.callingCode.length : 0));\n }\n return this.digits;\n }\n }, {\n key: \"getDigitsWithoutInternationalPrefix\",\n value: function getDigitsWithoutInternationalPrefix() {\n if (this.international) {\n if (this.IDDPrefix) {\n return this.digits.slice(this.IDDPrefix.length);\n }\n }\n return this.digits;\n }\n }]);\n}();\nexport { AsYouTypeState as default };\n//# sourceMappingURL=AsYouTypeState.js.map"],"names":["AsYouTypeState","_ref","onCountryChange","onCallingCodeChange","_classCallCheck","_createClass","key","value","reset","_ref2","country","callingCode","international","missingPlus","IDDPrefix","undefined","digits","resetNationalSignificantNumber","initCountryAndCallingCode","nationalSignificantNumber","getNationalDigits","nationalSignificantNumberMatchesInput","nationalPrefix","carrierCode","complexPrefixBeforeNationalSignificantNumber","update","properties","_i","_Object$keys","Object","keys","length","setCountry","setCallingCode","startInternationalNumber","appendDigits","nextDigits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QAAA;AACD,MAAA;MACA,OAAO,IAAI,CAACf,MAAM;AACnB,IAAA;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"AsYouTypeState.js","sources":["../../../../node_modules/libphonenumber-js/es6/AsYouTypeState.js"],"sourcesContent":["function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n// This \"state\" object simply holds the state of the \"AsYouType\" parser:\n//\n// * `country?: string` — The exact country of the phone number, if it could be determined.\n// When inputting a phone number in \"international\" format, it will derive the `country` from \"country calling code\" and the phone number digits.\n// When inputting a phone number in \"national\" format, it will derive the `country` from `defaultCountry` that was specified when creating the `AsYouType` formatter.\n// Sidenote: If `USE_NON_GEOGRAPHIC_COUNTRY_CODE` flag was `true`, then for \"non-geographic phone numbers\" `state.country` would've been \"001\".\n// * `callingCode?: string` — \"Country calling code\" that has been extracted from the input phone number.\n// When inputting a phone number in \"international\" format, it will extract the \"country calling code\" from the digits that follow the \"+\" character.\n// When inputting a phone number in \"national\" format, `callingCode` will be `undefined`.\n// Sidenote: `state.callingCode` is therefore independent from `state.country` and there could be situations when `state.country` is defined by `state.callingCode` is not — that would be when inputting a phone number not in \"international\" format.\n// * `digits: string` — Phone number digits that have been input so far, including the \"+\" character, if present. In case of inputting non-arabic digits, those will be converted to arabic ones.\n// * `international: boolean` — Whether the phone number is being input in \"international\" format, i.e. with a \"+\" character.\n// * `missingPlus: boolean` — Whether it's a phone number in \"international\" format that is missing the leading \"+\" character for some reason — apparently, Google thinks that it's a common mistake when inputting a phone number.\n// * `IDDPrefix?: string` — An \"IDD prefix\", when the phone number is being input in an \"out-of-country dialing\" format. https://wikitravel.org/en/International_dialling_prefix\n// * `carrierCode?: string` — A \"carrier code\", if the phone number contains it. Normally, those can only be present in Colombia or Brazil, and only when calling from mobile phones to fixed-line numbers.\n// * `nationalPrefix?: string` — \"National prefix\", if present in the phone number input.\n// * `nationalSignificantNumber?: string` — National (significant) number digits that have been input so far.\n// * `nationalSignificantNumberIsModified: boolean` — Tells if the parsed national (significant) number is present as-is in the input string. For example, when inputting \"0343515551212999\" Argentinian mobile number, the parsed national (significant) number is \"93435551212999\". There, one can see how it stripped \"0\" national prefix and prepended a \"9\", because that's how it is instructed to do in Argentina's metadata. So in the described example, the parsed national (significant) number is not present as-is in the input string. Instead, it's \"modified\" in the input string. https://gitlab.com/caamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule\n// * `prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix?: string` — In some countries, a phone number could have a prefix that is not a \"national prefix\" but rather some other type of \"utility\" prefix.\n// For example, when calling within Australia, one could prepend `1831` prefix to hide caller's phone number.\n// https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule\n//\nvar AsYouTypeState = /*#__PURE__*/function () {\n function AsYouTypeState(_ref) {\n var onCountryChange = _ref.onCountryChange,\n onCallingCodeChange = _ref.onCallingCodeChange;\n _classCallCheck(this, AsYouTypeState);\n this.onCountryChange = onCountryChange;\n this.onCallingCodeChange = onCallingCodeChange;\n }\n return _createClass(AsYouTypeState, [{\n key: \"reset\",\n value: function reset(_ref2) {\n var country = _ref2.country,\n callingCode = _ref2.callingCode;\n this.international = false;\n this.missingPlus = false;\n this.IDDPrefix = undefined;\n this.callingCode = undefined;\n this.digits = '';\n this.resetNationalSignificantNumber();\n this.initCountryAndCallingCode(country, callingCode);\n }\n }, {\n key: \"resetNationalSignificantNumber\",\n value: function resetNationalSignificantNumber() {\n this.nationalSignificantNumber = this.getNationalDigits();\n this.nationalSignificantNumberIsModified = false;\n this.nationalPrefix = undefined;\n this.carrierCode = undefined;\n this.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix = undefined;\n }\n }, {\n key: \"update\",\n value: function update(properties) {\n for (var _i = 0, _Object$keys = Object.keys(properties); _i < _Object$keys.length; _i++) {\n var key = _Object$keys[_i];\n this[key] = properties[key];\n }\n }\n }, {\n key: \"initCountryAndCallingCode\",\n value: function initCountryAndCallingCode(country, callingCode) {\n this.setCountry(country);\n this.setCallingCode(callingCode);\n }\n }, {\n key: \"setCountry\",\n value: function setCountry(country) {\n this.country = country;\n this.onCountryChange(country);\n }\n }, {\n key: \"setCallingCode\",\n value: function setCallingCode(callingCode) {\n this.callingCode = callingCode;\n this.onCallingCodeChange(callingCode, this.country);\n }\n }, {\n key: \"startInternationalNumber\",\n value: function startInternationalNumber(country, callingCode) {\n // Prepend the `+` to parsed input.\n this.international = true;\n // If a default country was set then reset it\n // because an explicitly international phone\n // number is being entered.\n this.initCountryAndCallingCode(country, callingCode);\n }\n }, {\n key: \"appendDigits\",\n value: function appendDigits(nextDigits) {\n this.digits += nextDigits;\n }\n }, {\n key: \"appendNationalSignificantNumberDigits\",\n value: function appendNationalSignificantNumberDigits(nextDigits) {\n this.nationalSignificantNumber += nextDigits;\n }\n\n /**\r\n * Returns the part of `this.digits` that corresponds to the national number.\r\n * Basically, all digits that have been input by the user, except for the\r\n * international prefix and the country calling code part\r\n * (if the number is an international one).\r\n * @return {string}\r\n */\n }, {\n key: \"getNationalDigits\",\n value: function getNationalDigits() {\n if (this.international) {\n return this.digits.slice((this.IDDPrefix ? this.IDDPrefix.length : 0) + (this.callingCode ? this.callingCode.length : 0));\n }\n return this.digits;\n }\n }, {\n key: \"getDigitsWithoutInternationalPrefix\",\n value: function getDigitsWithoutInternationalPrefix() {\n if (this.international) {\n if (this.IDDPrefix) {\n return this.digits.slice(this.IDDPrefix.length);\n }\n }\n return this.digits;\n }\n }]);\n}();\nexport { AsYouTypeState as default };\n//# sourceMappingURL=AsYouTypeState.js.map"],"names":["AsYouTypeState","_ref","onCountryChange","onCallingCodeChange","_classCallCheck","_createClass","key","value","reset","_ref2","country","callingCode","international","missingPlus","IDDPrefix","undefined","digits","resetNationalSignificantNumber","initCountryAndCallingCode","nationalSignificantNumber","getNationalDigits","nationalSignificantNumberIsModified","nationalPrefix","carrierCode","prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix","update","properties","_i","_Object$keys","Object","keys","length","setCountry","setCallingCode","startInternationalNumber","appendDigits","nextDigits","appendNationalSignificantNumberDigits","slice","getDigitsWithoutInternationalPrefix"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,IACqBA,cAAc,gBAAA,YAAA;EAClC,SAAAA,cAAAA,CAAAC,IAAA,EAAsD;AAAA,IAAA,IAAxCC,eAAe,GAAAD,IAAA,CAAfC,eAAe;MAAEC,mBAAmB,GAAAF,IAAA,CAAnBE,mBAAmB;AAAAC,IAAAA,eAAA,OAAAJ,cAAA,CAAA;IACjD,I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AAA,uCAAA;AAAAC,IAAAA,KAAA,EAED,SAAA8B,qCAAqCA,CAACD,UAAU,EAAE;MACjD,IAAI,CAACjB,yBAAyB,IAAIiB,UAAU;AAC7C,IAAA;;AAEA;AACD;AACA;AACA;AACA;AACA;AACA;AANC,GAAA,EAAA;IAAA9B,GAAA,EAAA,mBAAA;AAAAC,IAAAA,KAAA,EAOA,SAAAa,iBAAiBA,GAAG;MACnB,IAAI,IAAI,CAACR,aAAa,EAAE;AACvB,QAAA,OAAO,IAAI,CAACI,MAAM,CAACsB,KAAK,CACvB,CAAC,IAAI,CAACxB,SAAS,GAAG,IAAI,CAACA,SAAS,CAACiB,MAAM,GAAG,CAAC,KAC1C,IAAI,CAACpB,WAAW,GAAG,IAAI,CAACA,WAAW,CAACoB,MAAM,GAAG,CAAC,CAChD,CAAC;AACF,MAAA;MACA,OAAO,IAAI,CAACf,MAAM;AACnB,IAAA;AAAC,GAAA,EAAA;IAAAV,GAAA,EAAA,qCAAA;AAAAC,IAAAA,KAAA,EAED,SAAAgC,mCAAmCA,GAAG;MACrC,IAAI,IAAI,CAAC3B,aAAa,EAAE;QACvB,IAAI,IAAI,CAACE,SAAS,EAAE;UACnB,OAAO,IAAI,CAACE,MAAM,CAACsB,KAAK,CAAC,IAAI,CAACxB,SAAS,CAACiB,MAAM,CAAC;AAChD,QAAA;AACD,MAAA;MACA,OAAO,IAAI,CAACf,MAAM;AACnB,IAAA;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA;;;;","x_google_ignoreList":[0]}
@@ -102,7 +102,7 @@ var PhoneNumber = /*#__PURE__*/function () {
102
102
  if (!E164_NUMBER_REGEXP.test(e164Number)) {
103
103
  throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');
104
104
  }
105
- var _extractCountryCallin = extractCountryCallingCode(e164Number, undefined, undefined, metadata),
105
+ var _extractCountryCallin = extractCountryCallingCode(e164Number, undefined, undefined, undefined, metadata),
106
106
  _countryCallingCode = _extractCountryCallin.countryCallingCode,
107
107
  number = _extractCountryCallin.number;
108
108
  nationalNumber = number;
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumber.js","sources":["../../../../node_modules/libphonenumber-js/es6/PhoneNumber.js"],"sourcesContent":["function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport Metadata, { validateMetadata } from './metadata.js';\nimport isPossibleNumber from './isPossible.js';\nimport isValidNumber from './isValid.js';\n// import checkNumberLength from './helpers/checkNumberLength.js'\nimport getNumberType from './helpers/getNumberType.js';\nimport getPossibleCountriesForNumber from './helpers/getPossibleCountriesForNumber.js';\nimport extractCountryCallingCode from './helpers/extractCountryCallingCode.js';\nimport isObject from './helpers/isObject.js';\nimport formatNumber from './format.js';\nvar USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;\nvar PhoneNumber = /*#__PURE__*/function () {\n /**\r\n * @param {string} countryOrCountryCallingCode\r\n * @param {string} nationalNumber\r\n * @param {object} metadata — Metadata JSON\r\n * @return {PhoneNumber}\r\n */\n function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {\n _classCallCheck(this, PhoneNumber);\n // Validate `countryOrCountryCallingCode` argument.\n if (!countryOrCountryCallingCode) {\n throw new TypeError('First argument is required');\n }\n if (typeof countryOrCountryCallingCode !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n // In case of public API use: `constructor(number, metadata)`.\n // Transform the arguments from `constructor(number, metadata)` to\n // `constructor(countryOrCountryCallingCode, nationalNumber, metadata)`.\n if (countryOrCountryCallingCode[0] === '+' && !nationalNumber) {\n throw new TypeError('`metadata` argument not passed');\n }\n if (isObject(nationalNumber) && isObject(nationalNumber.countries)) {\n metadata = nationalNumber;\n var e164Number = countryOrCountryCallingCode;\n if (!E164_NUMBER_REGEXP.test(e164Number)) {\n throw new Error('Invalid `number` argument passed: must consist of a \"+\" followed by digits');\n }\n var _extractCountryCallin = extractCountryCallingCode(e164Number, undefined, undefined, metadata),\n _countryCallingCode = _extractCountryCallin.countryCallingCode,\n number = _extractCountryCallin.number;\n nationalNumber = number;\n countryOrCountryCallingCode = _countryCallingCode;\n if (!nationalNumber) {\n throw new Error('Invalid `number` argument passed: too short');\n }\n }\n\n // Validate `nationalNumber` argument.\n if (!nationalNumber) {\n throw new TypeError('`nationalNumber` argument is required');\n }\n if (typeof nationalNumber !== 'string') {\n throw new TypeError('`nationalNumber` argument must be a string');\n }\n\n // Validate `metadata` argument.\n validateMetadata(metadata);\n\n // Initialize properties.\n var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),\n country = _getCountryAndCountry.country,\n countryCallingCode = _getCountryAndCountry.countryCallingCode;\n this.country = country;\n this.countryCallingCode = countryCallingCode;\n this.nationalNumber = nationalNumber;\n this.number = '+' + this.countryCallingCode + this.nationalNumber;\n // Exclude `metadata` property output from `PhoneNumber.toString()`\n // so that it doesn't clutter the console output of Node.js.\n // Previously, when Node.js did `console.log(new PhoneNumber(...))`,\n // it would output the whole internal structure of the `metadata` object.\n this.getMetadata = function () {\n return metadata;\n };\n }\n return _createClass(PhoneNumber, [{\n key: \"setExt\",\n value: function setExt(ext) {\n this.ext = ext;\n }\n }, {\n key: \"getPossibleCountries\",\n value: function getPossibleCountries() {\n if (this.country) {\n return [this.country];\n }\n return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.getMetadata());\n }\n }, {\n key: \"isPossible\",\n value: function isPossible() {\n return isPossibleNumber(this, {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"isValid\",\n value: function isValid() {\n return isValidNumber(this, {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"isNonGeographic\",\n value: function isNonGeographic() {\n var metadata = new Metadata(this.getMetadata());\n return metadata.isNonGeographicCallingCode(this.countryCallingCode);\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(phoneNumber) {\n return this.number === phoneNumber.number && this.ext === phoneNumber.ext;\n }\n\n // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,\n // but later it was found out that it doesn't include the possible `TOO_SHORT` result\n // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,\n // so eventually I simply commented out this method from the `PhoneNumber` class\n // and just left the `validatePhoneNumberLength()` function, even though that one would require\n // and additional step to also validate the actual country / calling code of the phone number.\n // validateLength() {\n // \tconst metadata = new Metadata(this.getMetadata())\n // \tmetadata.selectNumberingPlan(this.countryCallingCode)\n // \tconst result = checkNumberLength(this.nationalNumber, metadata)\n // \tif (result !== 'IS_POSSIBLE') {\n // \t\treturn result\n // \t}\n // }\n }, {\n key: \"getType\",\n value: function getType() {\n return getNumberType(this, {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"format\",\n value: function format(_format, options) {\n return formatNumber(this, _format, options ? _objectSpread(_objectSpread({}, options), {}, {\n v2: true\n }) : {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"formatNational\",\n value: function formatNational(options) {\n return this.format('NATIONAL', options);\n }\n }, {\n key: \"formatInternational\",\n value: function formatInternational(options) {\n return this.format('INTERNATIONAL', options);\n }\n }, {\n key: \"getURI\",\n value: function getURI(options) {\n return this.format('RFC3966', options);\n }\n }]);\n}();\nexport { PhoneNumber as default };\nvar isCountryCode = function isCountryCode(value) {\n return /^[A-Z]{2}$/.test(value);\n};\nfunction getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {\n var country;\n var countryCallingCode;\n var metadata = new Metadata(metadataJson);\n // If country code is passed then derive `countryCallingCode` from it.\n // Also store the country code as `.country`.\n if (isCountryCode(countryOrCountryCallingCode)) {\n country = countryOrCountryCallingCode;\n metadata.selectNumberingPlan(country);\n countryCallingCode = metadata.countryCallingCode();\n } else {\n countryCallingCode = countryOrCountryCallingCode;\n /* istanbul ignore if */\n if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\n if (metadata.isNonGeographicCallingCode(countryCallingCode)) {\n country = '001';\n }\n }\n }\n return {\n country: country,\n countryCallingCode: countryCallingCode\n };\n}\nvar E164_NUMBER_REGEXP = /^\\+\\d+$/;\n//# sourceMappingURL=PhoneNumber.js.map"],"names":["PhoneNumber","countryOrCountryCallingCode","nationalNumber","metadata","_classCallCheck","TypeError","isObject","countries","e164Number","E164_NUMBER_REGEXP","test","Error","_extractCountryCallin","extractCountryCallingCode","undefined","_countryCallingCode","countryCallingCode","number","validateMetadata","_getCountryAndCountry","getCountryAndCountryCallingCode","country","getMetadata","_createClass","key","value","setExt","ext","getPossibleCountries","getPossibleCountriesForNumber","isPossible","isPossibleNumber","v2","isValid","isValidNumber","isNonGeographic","Metadata","isNonGeographicCallingCode","isEqual","phoneNumber","getType","getNumberType","format","_format","options","formatNumber","_objectSpread","formatNational","formatInternational","getURI","isCountryCode","metadataJson","selectNumberingPlan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU6C,IAExBA,WAAW,gBAAA,YAAA;AAC/B;AACD;AACA;AACA;AACA;AACA;AACC,EAAA,SAAAA,YAAYC,2BAA2B,EAAEC,cAAc,EAAEC,QAAQ,EAAE;AAAAC,IAAAA,eAAA,OAAAJ,WAAA,CAAA;AAClE;IACA,IAAI,CAACC,2BAA2B,EAAE;AACjC,MAAA,MAAM,IAAII,SAAS,CAAC,4BAA4B,CAAC;AAClD,IAAA;AACA,IAAA,IAAI,OAAOJ,2BAA2B,KAAK,QAAQ,EAAE;AACpD,MAAA,MAAM,IAAII,SAAS,CAAC,iCAAiC,CAAC;AACvD,IAAA;;AAEA;AACA;AACA;IACA,IAAIJ,2BAA2B,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAACC,cAAc,EAAE;AAC9D,MAAA,MAAM,IAAIG,SAAS,CAAC,gCAAgC,CAAC;AACtD,IAAA;IACA,IAAIC,QAAQ,CAACJ,cAAc,CAAC,IAAII,QAAQ,CAACJ,cAAc,CAACK,SAAS,CAAC,EAAE;AACnEJ,MAAAA,QAAQ,GAAGD,cAAc;MACzB,IAAMM,UAAU,GAAGP,2BAA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IAAA;AAAC,GAAA,EAAA;IAAApB,GAAA,EAAA,QAAA;AAAAC,IAAAA,KAAA,EAED,SAAAwB,MAAMA,CAACL,OAAO,EAAE;AACf,MAAA,OAAO,IAAI,CAACF,MAAM,CAAC,SAAS,EAAEE,OAAO,CAAC;AACvC,IAAA;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA;AAGF,IAAMM,aAAa,GAAG,SAAhBA,aAAaA,CAAIzB,KAAK,EAAA;AAAA,EAAA,OAAK,YAAY,CAACf,IAAI,CAACe,KAAK,CAAC;AAAA,CAAA;AAEzD,SAASL,+BAA+BA,CAACnB,2BAA2B,EAAEkD,YAAY,EAAE;AACnF,EAAA,IAAI9B,OAAO;AACX,EAAA,IAAIL,kBAAkB;AAEtB,EAAA,IAAMb,QAAQ,GAAG,IAAIiC,QAAQ,CAACe,YAAY,CAAC;AAC3C;AACA;AACA,EAAA,IAAID,aAAa,CAACjD,2BAA2B,CAAC,EAAE;AAC/CoB,IAAAA,OAAO,GAAGpB,2BAA2B;AACrCE,IAAAA,QAAQ,CAACiD,mBAAmB,CAAC/B,OAAO,CAAC;AACrCL,IAAAA,kBAAkB,GAAGb,QAAQ,CAACa,kBAAkB,EAAE;AACnD,EAAA,CAAC,MAAM;AACNA,IAAAA,kBAAkB,GAAGf,2BAA2B;AAOjD,EAAA;EAEA,OAAO;AACNoB,IAAAA,OAAO,EAAPA,OAAO;AACPL,IAAAA,kBAAkB,EAAlBA;GACA;AACF;AAEA,IAAMP,kBAAkB,GAAG,SAAS;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"PhoneNumber.js","sources":["../../../../node_modules/libphonenumber-js/es6/PhoneNumber.js"],"sourcesContent":["function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport Metadata, { validateMetadata } from './metadata.js';\nimport isPossibleNumber from './isPossible.js';\nimport isValidNumber from './isValid.js';\nimport getNumberType from './helpers/getNumberType.js';\nimport getPossibleCountriesForNumber from './helpers/getPossibleCountriesForNumber.js';\nimport extractCountryCallingCode from './helpers/extractCountryCallingCode.js';\nimport isObject from './helpers/isObject.js';\nimport formatNumber from './format.js';\nvar USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;\nvar PhoneNumber = /*#__PURE__*/function () {\n /**\r\n * @param {string} countryOrCountryCallingCode\r\n * @param {string} nationalNumber\r\n * @param {object} metadata — Metadata JSON\r\n * @return {PhoneNumber}\r\n */\n function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {\n _classCallCheck(this, PhoneNumber);\n // Validate `countryOrCountryCallingCode` argument.\n if (!countryOrCountryCallingCode) {\n throw new TypeError('First argument is required');\n }\n if (typeof countryOrCountryCallingCode !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n // In case of public API use: `constructor(number, metadata)`.\n // Transform the arguments from `constructor(number, metadata)` to\n // `constructor(countryOrCountryCallingCode, nationalNumber, metadata)`.\n if (countryOrCountryCallingCode[0] === '+' && !nationalNumber) {\n throw new TypeError('`metadata` argument not passed');\n }\n if (isObject(nationalNumber) && isObject(nationalNumber.countries)) {\n metadata = nationalNumber;\n var e164Number = countryOrCountryCallingCode;\n if (!E164_NUMBER_REGEXP.test(e164Number)) {\n throw new Error('Invalid `number` argument passed: must consist of a \"+\" followed by digits');\n }\n var _extractCountryCallin = extractCountryCallingCode(e164Number, undefined, undefined, undefined, metadata),\n _countryCallingCode = _extractCountryCallin.countryCallingCode,\n number = _extractCountryCallin.number;\n nationalNumber = number;\n countryOrCountryCallingCode = _countryCallingCode;\n if (!nationalNumber) {\n throw new Error('Invalid `number` argument passed: too short');\n }\n }\n\n // Validate `nationalNumber` argument.\n if (!nationalNumber) {\n throw new TypeError('`nationalNumber` argument is required');\n }\n if (typeof nationalNumber !== 'string') {\n throw new TypeError('`nationalNumber` argument must be a string');\n }\n\n // Validate `metadata` argument.\n validateMetadata(metadata);\n\n // Initialize properties.\n var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),\n country = _getCountryAndCountry.country,\n countryCallingCode = _getCountryAndCountry.countryCallingCode;\n this.country = country;\n this.countryCallingCode = countryCallingCode;\n this.nationalNumber = nationalNumber;\n this.number = '+' + this.countryCallingCode + this.nationalNumber;\n // Exclude `metadata` property output from `PhoneNumber.toString()`\n // so that it doesn't clutter the console output of Node.js.\n // Previously, when Node.js did `console.log(new PhoneNumber(...))`,\n // it would output the whole internal structure of the `metadata` object.\n this.getMetadata = function () {\n return metadata;\n };\n }\n return _createClass(PhoneNumber, [{\n key: \"setExt\",\n value: function setExt(ext) {\n this.ext = ext;\n }\n }, {\n key: \"getPossibleCountries\",\n value: function getPossibleCountries() {\n if (this.country) {\n return [this.country];\n }\n return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.getMetadata());\n }\n }, {\n key: \"isPossible\",\n value: function isPossible() {\n return isPossibleNumber(this, {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"isValid\",\n value: function isValid() {\n return isValidNumber(this, {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"isNonGeographic\",\n value: function isNonGeographic() {\n var metadata = new Metadata(this.getMetadata());\n return metadata.isNonGeographicCallingCode(this.countryCallingCode);\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(phoneNumber) {\n return this.number === phoneNumber.number && this.ext === phoneNumber.ext;\n }\n\n // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,\n // but later it was found out that it doesn't include the possible `TOO_SHORT` result\n // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,\n // so eventually I simply commented out this method from the `PhoneNumber` class\n // and just left the `validatePhoneNumberLength()` function, even though that one would require\n // and additional step to also validate the actual country / calling code of the phone number.\n // validateLength() {\n // \tconst metadata = new Metadata(this.getMetadata())\n // \tmetadata.selectNumberingPlan(this.countryCallingCode)\n // \tconst result = checkNumberLength(this.nationalNumber, metadata)\n // \tif (result !== 'IS_POSSIBLE') {\n // \t\treturn result\n // \t}\n // }\n }, {\n key: \"getType\",\n value: function getType() {\n return getNumberType(this, {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"format\",\n value: function format(_format, options) {\n return formatNumber(this, _format, options ? _objectSpread(_objectSpread({}, options), {}, {\n v2: true\n }) : {\n v2: true\n }, this.getMetadata());\n }\n }, {\n key: \"formatNational\",\n value: function formatNational(options) {\n return this.format('NATIONAL', options);\n }\n }, {\n key: \"formatInternational\",\n value: function formatInternational(options) {\n return this.format('INTERNATIONAL', options);\n }\n }, {\n key: \"getURI\",\n value: function getURI(options) {\n return this.format('RFC3966', options);\n }\n }]);\n}();\nexport { PhoneNumber as default };\nvar isCountryCode = function isCountryCode(value) {\n return /^[A-Z]{2}$/.test(value);\n};\nfunction getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {\n var country;\n var countryCallingCode;\n var metadata = new Metadata(metadataJson);\n // If country code is passed then derive `countryCallingCode` from it.\n // Also store the country code as `.country`.\n if (isCountryCode(countryOrCountryCallingCode)) {\n country = countryOrCountryCallingCode;\n metadata.selectNumberingPlan(country);\n countryCallingCode = metadata.countryCallingCode();\n } else {\n countryCallingCode = countryOrCountryCallingCode;\n /* istanbul ignore if */\n if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\n if (metadata.isNonGeographicCallingCode(countryCallingCode)) {\n country = '001';\n }\n }\n }\n return {\n country: country,\n countryCallingCode: countryCallingCode\n };\n}\nvar E164_NUMBER_REGEXP = /^\\+\\d+$/;\n//# sourceMappingURL=PhoneNumber.js.map"],"names":["PhoneNumber","countryOrCountryCallingCode","nationalNumber","metadata","_classCallCheck","TypeError","isObject","countries","e164Number","E164_NUMBER_REGEXP","test","Error","_extractCountryCallin","extractCountryCallingCode","undefined","_countryCallingCode","countryCallingCode","number","validateMetadata","_getCountryAndCountry","getCountryAndCountryCallingCode","country","getMetadata","_createClass","key","value","setExt","ext","getPossibleCountries","getPossibleCountriesForNumber","isPossible","isPossibleNumber","v2","isValid","isValidNumber","isNonGeographic","Metadata","isNonGeographicCallingCode","isEqual","phoneNumber","getType","getNumberType","format","_format","options","formatNumber","_objectSpread","formatNational","formatInternational","getURI","isCountryCode","metadataJson","selectNumberingPlan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAS6C,IAExBA,WAAW,gBAAA,YAAA;AAC/B;AACD;AACA;AACA;AACA;AACA;AACC,EAAA,SAAAA,YAAYC,2BAA2B,EAAEC,cAAc,EAAEC,QAAQ,EAAE;AAAAC,IAAAA,eAAA,OAAAJ,WAAA,CAAA;AAClE;IACA,IAAI,CAACC,2BAA2B,EAAE;AACjC,MAAA,MAAM,IAAII,SAAS,CAAC,4BAA4B,CAAC;AAClD,IAAA;AACA,IAAA,IAAI,OAAOJ,2BAA2B,KAAK,QAAQ,EAAE;AACpD,MAAA,MAAM,IAAII,SAAS,CAAC,iCAAiC,CAAC;AACvD,IAAA;;AAEA;AACA;AACA;IACA,IAAIJ,2BAA2B,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAACC,cAAc,EAAE;AAC9D,MAAA,MAAM,IAAIG,SAAS,CAAC,gCAAgC,CAAC;AACtD,IAAA;IACA,IAAIC,QAAQ,CAACJ,cAAc,CAAC,IAAII,QAAQ,CAACJ,cAAc,CAACK,SAAS,CAAC,EAAE;AACnEJ,MAAAA,QAAQ,GAAGD,cAAc;MACzB,IAAMM,UAAU,GAAGP,2BAA2B;AAC9C,MAAA,IAAI,CAACQ,kBAAkB,CAACC,IAAI,CAACF,UAAU,CAAC,EAAE;AACzC,QAAA,MAAM,IAAIG,KAAK,CAAC,4EAA4E,CAAC;AAC9F,MAAA;AACA,MAAA,IAAAC,qBAAA,GAAuCC,yBAAyB,CAACL,UAAU,EAAEM,SAAS,EAAEA,SAAS,EAAEA,SAAS,EAAEX,QAAQ,CAAC;QAA/GY,mBAAkB,GAAAH,qBAAA,CAAlBI,kBAAkB;QAAEC,MAAM,GAAAL,qBAAA,CAANK,MAAM;AAClCf,MAA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CAAC;AAAA,CAAA;AAEzD,SAASL,+BAA+BA,CAACnB,2BAA2B,EAAEkD,YAAY,EAAE;AACnF,EAAA,IAAI9B,OAAO;AACX,EAAA,IAAIL,kBAAkB;AAEtB,EAAA,IAAMb,QAAQ,GAAG,IAAIiC,QAAQ,CAACe,YAAY,CAAC;AAC3C;AACA;AACA,EAAA,IAAID,aAAa,CAACjD,2BAA2B,CAAC,EAAE;AAC/CoB,IAAAA,OAAO,GAAGpB,2BAA2B;AACrCE,IAAAA,QAAQ,CAACiD,mBAAmB,CAAC/B,OAAO,CAAC;AACrCL,IAAAA,kBAAkB,GAAGb,QAAQ,CAACa,kBAAkB,EAAE;AACnD,EAAA,CAAC,MAAM;AACNA,IAAAA,kBAAkB,GAAGf,2BAA2B;AAOjD,EAAA;EAEA,OAAO;AACNoB,IAAAA,OAAO,EAAPA,OAAO;AACPL,IAAAA,kBAAkB,EAAlBA;GACA;AACF;AAEA,IAAMP,kBAAkB,GAAG,SAAS;;;;","x_google_ignoreList":[0]}
@@ -4,87 +4,11 @@ import Metadata, { getCountryCallingCode } from './metadata.js';
4
4
  import getIddPrefix from './helpers/getIddPrefix.js';
5
5
  import { formatRFC3966 } from './helpers/RFC3966.js';
6
6
 
7
- function _typeof(o) {
8
- "@babel/helpers - typeof";
7
+ // This is a port of Google Android `libphonenumber`'s
8
+ // `phonenumberutil.js` of December 31th, 2018.
9
+ //
10
+ // https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
9
11
 
10
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
11
- return typeof o;
12
- } : function (o) {
13
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
14
- }, _typeof(o);
15
- }
16
- function _createForOfIteratorHelperLoose(r, e) {
17
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
18
- if (t) return (t = t.call(r)).next.bind(t);
19
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
20
- t && (r = t);
21
- var o = 0;
22
- return function () {
23
- return o >= r.length ? {
24
- done: true
25
- } : {
26
- done: false,
27
- value: r[o++]
28
- };
29
- };
30
- }
31
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
32
- }
33
- function _unsupportedIterableToArray(r, a) {
34
- if (r) {
35
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
36
- var t = {}.toString.call(r).slice(8, -1);
37
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
38
- }
39
- }
40
- function _arrayLikeToArray(r, a) {
41
- (null == a || a > r.length) && (a = r.length);
42
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
43
- return n;
44
- }
45
- function ownKeys(e, r) {
46
- var t = Object.keys(e);
47
- if (Object.getOwnPropertySymbols) {
48
- var o = Object.getOwnPropertySymbols(e);
49
- r && (o = o.filter(function (r) {
50
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
51
- })), t.push.apply(t, o);
52
- }
53
- return t;
54
- }
55
- function _objectSpread(e) {
56
- for (var r = 1; r < arguments.length; r++) {
57
- var t = null != arguments[r] ? arguments[r] : {};
58
- r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
59
- _defineProperty(e, r, t[r]);
60
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
61
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
62
- });
63
- }
64
- return e;
65
- }
66
- function _defineProperty(e, r, t) {
67
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
68
- value: t,
69
- enumerable: true,
70
- configurable: true,
71
- writable: true
72
- }) : e[r] = t, e;
73
- }
74
- function _toPropertyKey(t) {
75
- var i = _toPrimitive(t, "string");
76
- return "symbol" == _typeof(i) ? i : i + "";
77
- }
78
- function _toPrimitive(t, r) {
79
- if ("object" != _typeof(t) || !t) return t;
80
- var e = t[Symbol.toPrimitive];
81
- if (void 0 !== e) {
82
- var i = e.call(t, r);
83
- if ("object" != _typeof(i)) return i;
84
- throw new TypeError("@@toPrimitive must return a primitive value.");
85
- }
86
- return ("string" === r ? String : Number)(t);
87
- }
88
12
  var DEFAULT_OPTIONS = {
89
13
  formatExtension: function formatExtension(formattedNumber, extension, metadata) {
90
14
  return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
@@ -109,7 +33,14 @@ var DEFAULT_OPTIONS = {
109
33
  function formatNumber(input, format, options, metadata) {
110
34
  // Apply default options.
111
35
  if (options) {
112
- options = _objectSpread(_objectSpread({}, DEFAULT_OPTIONS), options);
36
+ // Using ES6 "rest spread" syntax here didn't work with `babel`/`istanbul`
37
+ // for some weird reason: this line of code would cause the code coverage
38
+ // to show as not 100%. That's because `babel`/`istanbul`, for some weird reason,
39
+ // apparently doesn't know how to properly exclude Babel polyfills from code coverage.
40
+ //
41
+ // options = { ...DEFAULT_OPTIONS, ...options }
42
+ //
43
+ options = merge({}, DEFAULT_OPTIONS, options);
113
44
  } else {
114
45
  options = DEFAULT_OPTIONS;
115
46
  }
@@ -119,7 +50,7 @@ function formatNumber(input, format, options, metadata) {
119
50
  if (!metadata.hasCountry(input.country)) {
120
51
  throw new Error("Unknown country: ".concat(input.country));
121
52
  }
122
- metadata.country(input.country);
53
+ metadata.selectNumberingPlan(input.country);
123
54
  } else if (input.countryCallingCode) {
124
55
  metadata.selectNumberingPlan(input.countryCallingCode);
125
56
  } else return input.phone || '';
@@ -183,9 +114,15 @@ function formatNationalNumber(number, carrierCode, formatAs, metadata, options)
183
114
  metadata: metadata
184
115
  });
185
116
  }
186
- function chooseFormatForNumber(availableFormats, nationalNnumber) {
187
- for (var _iterator = _createForOfIteratorHelperLoose(availableFormats), _step; !(_step = _iterator()).done;) {
188
- var format = _step.value;
117
+ function chooseFormatForNumber(availableFormats, nationalNumber) {
118
+ // Using a `for ... of` loop here didn't work with `babel`/`istanbul`:
119
+ // for some weird reason, it showed code coverage less than 100%.
120
+ // That's because `babel`/`istanbul`, for some weird reason,
121
+ // apparently doesn't know how to properly exclude Babel polyfills from code coverage.
122
+ //
123
+ // for (const format of availableFormats) { ... }
124
+ //
125
+ return pickFirstMatchingElement(availableFormats, function (format) {
189
126
  // Validate leading digits.
190
127
  // The test case for "else path" could be found by searching for
191
128
  // "format.leadingDigitsPatterns().length === 0".
@@ -193,15 +130,13 @@ function chooseFormatForNumber(availableFormats, nationalNnumber) {
193
130
  // The last leading_digits_pattern is used here, as it is the most detailed
194
131
  var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1];
195
132
  // If leading digits don't match then move on to the next phone number format
196
- if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {
197
- continue;
133
+ if (nationalNumber.search(lastLeadingDigitsPattern) !== 0) {
134
+ return false;
198
135
  }
199
136
  }
200
137
  // Check that the national number matches the phone number format regular expression
201
- if (matchesEntirely(nationalNnumber, format.pattern())) {
202
- return format;
203
- }
204
- }
138
+ return matchesEntirely(nationalNumber, format.pattern());
139
+ });
205
140
  }
206
141
  function addExtension(formattedNumber, ext, metadata, formatExtension) {
207
142
  return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;
@@ -232,6 +167,30 @@ function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry,
232
167
  return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
233
168
  }
234
169
  }
170
+ function merge() {
171
+ var i = 1;
172
+ for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
173
+ objects[_key] = arguments[_key];
174
+ }
175
+ while (i < objects.length) {
176
+ if (objects[i]) {
177
+ for (var key in objects[i]) {
178
+ objects[0][key] = objects[i][key];
179
+ }
180
+ }
181
+ i++;
182
+ }
183
+ return objects[0];
184
+ }
185
+ function pickFirstMatchingElement(elements, testFunction) {
186
+ var i = 0;
187
+ while (i < elements.length) {
188
+ if (testFunction(elements[i])) {
189
+ return elements[i];
190
+ }
191
+ i++;
192
+ }
193
+ }
235
194
 
236
195
  export { chooseFormatForNumber, formatNumber as default };
237
196
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sources":["../../../../node_modules/libphonenumber-js/es6/format.js"],"sourcesContent":["function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelperLoose(r, e) { var t = \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && \"number\" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n// This is a port of Google Android `libphonenumber`'s\n// `phonenumberutil.js` of December 31th, 2018.\n//\n// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js\n\nimport matchesEntirely from './helpers/matchesEntirely.js';\nimport formatNationalNumberUsingFormat from './helpers/formatNationalNumberUsingFormat.js';\nimport Metadata, { getCountryCallingCode } from './metadata.js';\nimport getIddPrefix from './helpers/getIddPrefix.js';\nimport { formatRFC3966 } from './helpers/RFC3966.js';\nvar DEFAULT_OPTIONS = {\n formatExtension: function formatExtension(formattedNumber, extension, metadata) {\n return \"\".concat(formattedNumber).concat(metadata.ext()).concat(extension);\n }\n};\n\n/**\r\n * Formats a phone number.\r\n *\r\n * format(phoneNumberInstance, 'INTERNATIONAL', { ..., v2: true }, metadata)\r\n * format(phoneNumberInstance, 'NATIONAL', { ..., v2: true }, metadata)\r\n *\r\n * format({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', { ... }, metadata)\r\n * format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', undefined, metadata)\r\n *\r\n * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.\r\n * @param {string} format\r\n * @param {object} [options]\r\n * @param {object} metadata\r\n * @return {string}\r\n */\nexport default function formatNumber(input, format, options, metadata) {\n // Apply default options.\n if (options) {\n options = _objectSpread(_objectSpread({}, DEFAULT_OPTIONS), options);\n } else {\n options = DEFAULT_OPTIONS;\n }\n metadata = new Metadata(metadata);\n if (input.country && input.country !== '001') {\n // Validate `input.country`.\n if (!metadata.hasCountry(input.country)) {\n throw new Error(\"Unknown country: \".concat(input.country));\n }\n metadata.country(input.country);\n } else if (input.countryCallingCode) {\n metadata.selectNumberingPlan(input.countryCallingCode);\n } else return input.phone || '';\n var countryCallingCode = metadata.countryCallingCode();\n var nationalNumber = options.v2 ? input.nationalNumber : input.phone;\n\n // This variable should have been declared inside `case`s\n // but Babel has a bug and it says \"duplicate variable declaration\".\n var number;\n switch (format) {\n case 'NATIONAL':\n // Legacy argument support.\n // (`{ country: ..., phone: '' }`)\n if (!nationalNumber) {\n return '';\n }\n number = formatNationalNumber(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);\n return addExtension(number, input.ext, metadata, options.formatExtension);\n case 'INTERNATIONAL':\n // Legacy argument support.\n // (`{ country: ..., phone: '' }`)\n if (!nationalNumber) {\n return \"+\".concat(countryCallingCode);\n }\n number = formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata, options);\n number = \"+\".concat(countryCallingCode, \" \").concat(number);\n return addExtension(number, input.ext, metadata, options.formatExtension);\n case 'E.164':\n // `E.164` doesn't define \"phone number extensions\".\n return \"+\".concat(countryCallingCode).concat(nationalNumber);\n case 'RFC3966':\n return formatRFC3966({\n number: \"+\".concat(countryCallingCode).concat(nationalNumber),\n ext: input.ext\n });\n\n // For reference, here's Google's IDD formatter:\n // https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546\n // Not saying that this IDD formatter replicates it 1:1, but it seems to work.\n // Who would even need to format phone numbers in IDD format anyway?\n case 'IDD':\n if (!options.fromCountry) {\n return;\n // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')\n }\n var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);\n return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);\n default:\n throw new Error(\"Unknown \\\"format\\\" argument passed to \\\"formatNumber()\\\": \\\"\".concat(format, \"\\\"\"));\n }\n}\nfunction formatNationalNumber(number, carrierCode, formatAs, metadata, options) {\n var format = chooseFormatForNumber(metadata.formats(), number);\n if (!format) {\n return number;\n }\n return formatNationalNumberUsingFormat(number, format, {\n useInternationalFormat: formatAs === 'INTERNATIONAL',\n withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,\n carrierCode: carrierCode,\n metadata: metadata\n });\n}\nexport function chooseFormatForNumber(availableFormats, nationalNnumber) {\n for (var _iterator = _createForOfIteratorHelperLoose(availableFormats), _step; !(_step = _iterator()).done;) {\n var format = _step.value;\n // Validate leading digits.\n // The test case for \"else path\" could be found by searching for\n // \"format.leadingDigitsPatterns().length === 0\".\n if (format.leadingDigitsPatterns().length > 0) {\n // The last leading_digits_pattern is used here, as it is the most detailed\n var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1];\n // If leading digits don't match then move on to the next phone number format\n if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {\n continue;\n }\n }\n // Check that the national number matches the phone number format regular expression\n if (matchesEntirely(nationalNnumber, format.pattern())) {\n return format;\n }\n }\n}\nfunction addExtension(formattedNumber, ext, metadata, formatExtension) {\n return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;\n}\nfunction formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {\n var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata);\n // When calling within the same country calling code.\n if (fromCountryCallingCode === countryCallingCode) {\n var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, 'NATIONAL', metadata);\n // For NANPA regions, return the national format for these regions\n // but prefix it with the country calling code.\n if (countryCallingCode === '1') {\n return countryCallingCode + ' ' + formattedNumber;\n }\n // If regions share a country calling code, the country calling code need\n // not be dialled. This also applies when dialling within a region, so this\n // if clause covers both these cases. Technically this is the case for\n // dialling from La Reunion to other overseas departments of France (French\n // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover\n // this edge case for now and for those cases return the version including\n // country calling code. Details here:\n // http://www.petitfute.com/voyage/225-info-pratiques-reunion\n //\n return formattedNumber;\n }\n var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);\n if (iddPrefix) {\n return \"\".concat(iddPrefix, \" \").concat(countryCallingCode, \" \").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));\n }\n}\n//# sourceMappingURL=format.js.map"],"names":["DEFAULT_OPTIONS","formatExtension","formattedNumber","extension","metadata","concat","ext","formatNumber","input","format","options","_objectSpread","Metadata","country","hasCountry","Error","countryCallingCode","selectNumberingPlan","phone","nationalNumber","v2","number","formatNationalNumber","carrierCode","addExtension","formatRFC3966","fromCountry","formatIDD","formatAs","chooseFormatForNumber","formats","formatNationalNumberUsingFormat","useInternationalFormat","withNationalPrefix","nationalPrefixIsOptionalWhenFormattingInNationalFormat","nationalPrefix","availableFormats","nationalNnumber","_iterator","_createForOfIteratorHelperLoose","_step","done","value","leadingDigitsPatterns","length","lastLeadingDigitsPattern","search","matchesEntirely","pattern","fromCountryCallingCode","getCount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B,KAAK,GAAG,EAAE;AAC/B,MAAA,OAAOA,kBAAkB,GAAG,GAAG,GAAGd,eAAe;AAClD,IAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,OAAOA,eAAe;AACvB,EAAA;EACA,IAAMiD,SAAS,GAAGC,YAAY,CAAC1B,WAAW,EAAE2B,SAAS,EAAEjD,QAAQ,CAACA,QAAQ,CAAC;AACzE,EAAA,IAAI+C,SAAS,EAAE;AACd,IAAA,OAAA,EAAA,CAAA9C,MAAA,CAAU8C,SAAS,OAAA9C,MAAA,CAAIW,kBAAkB,EAAA,GAAA,CAAA,CAAAX,MAAA,CAAIiB,oBAAoB,CAACH,cAAc,EAAE,IAAI,EAAE,eAAe,EAAEf,QAAQ,CAAC,CAAA;AACnH,EAAA;AACD;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"format.js","sources":["../../../../node_modules/libphonenumber-js/es6/format.js"],"sourcesContent":["// This is a port of Google Android `libphonenumber`'s\n// `phonenumberutil.js` of December 31th, 2018.\n//\n// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js\n\nimport matchesEntirely from './helpers/matchesEntirely.js';\nimport formatNationalNumberUsingFormat from './helpers/formatNationalNumberUsingFormat.js';\nimport Metadata, { getCountryCallingCode } from './metadata.js';\nimport getIddPrefix from './helpers/getIddPrefix.js';\nimport { formatRFC3966 } from './helpers/RFC3966.js';\nvar DEFAULT_OPTIONS = {\n formatExtension: function formatExtension(formattedNumber, extension, metadata) {\n return \"\".concat(formattedNumber).concat(metadata.ext()).concat(extension);\n }\n};\n\n/**\r\n * Formats a phone number.\r\n *\r\n * format(phoneNumberInstance, 'INTERNATIONAL', { ..., v2: true }, metadata)\r\n * format(phoneNumberInstance, 'NATIONAL', { ..., v2: true }, metadata)\r\n *\r\n * format({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', { ... }, metadata)\r\n * format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', undefined, metadata)\r\n *\r\n * @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.\r\n * @param {string} format\r\n * @param {object} [options]\r\n * @param {object} metadata\r\n * @return {string}\r\n */\nexport default function formatNumber(input, format, options, metadata) {\n // Apply default options.\n if (options) {\n // Using ES6 \"rest spread\" syntax here didn't work with `babel`/`istanbul`\n // for some weird reason: this line of code would cause the code coverage\n // to show as not 100%. That's because `babel`/`istanbul`, for some weird reason,\n // apparently doesn't know how to properly exclude Babel polyfills from code coverage.\n //\n // options = { ...DEFAULT_OPTIONS, ...options }\n //\n options = merge({}, DEFAULT_OPTIONS, options);\n } else {\n options = DEFAULT_OPTIONS;\n }\n metadata = new Metadata(metadata);\n if (input.country && input.country !== '001') {\n // Validate `input.country`.\n if (!metadata.hasCountry(input.country)) {\n throw new Error(\"Unknown country: \".concat(input.country));\n }\n metadata.selectNumberingPlan(input.country);\n } else if (input.countryCallingCode) {\n metadata.selectNumberingPlan(input.countryCallingCode);\n } else return input.phone || '';\n var countryCallingCode = metadata.countryCallingCode();\n var nationalNumber = options.v2 ? input.nationalNumber : input.phone;\n\n // This variable should have been declared inside `case`s\n // but Babel has a bug and it says \"duplicate variable declaration\".\n var number;\n switch (format) {\n case 'NATIONAL':\n // Legacy argument support.\n // (`{ country: ..., phone: '' }`)\n if (!nationalNumber) {\n return '';\n }\n number = formatNationalNumber(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);\n return addExtension(number, input.ext, metadata, options.formatExtension);\n case 'INTERNATIONAL':\n // Legacy argument support.\n // (`{ country: ..., phone: '' }`)\n if (!nationalNumber) {\n return \"+\".concat(countryCallingCode);\n }\n number = formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata, options);\n number = \"+\".concat(countryCallingCode, \" \").concat(number);\n return addExtension(number, input.ext, metadata, options.formatExtension);\n case 'E.164':\n // `E.164` doesn't define \"phone number extensions\".\n return \"+\".concat(countryCallingCode).concat(nationalNumber);\n case 'RFC3966':\n return formatRFC3966({\n number: \"+\".concat(countryCallingCode).concat(nationalNumber),\n ext: input.ext\n });\n\n // For reference, here's Google's IDD formatter:\n // https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546\n // Not saying that this IDD formatter replicates it 1:1, but it seems to work.\n // Who would even need to format phone numbers in IDD format anyway?\n case 'IDD':\n if (!options.fromCountry) {\n return;\n // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')\n }\n var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);\n return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);\n default:\n throw new Error(\"Unknown \\\"format\\\" argument passed to \\\"formatNumber()\\\": \\\"\".concat(format, \"\\\"\"));\n }\n}\nfunction formatNationalNumber(number, carrierCode, formatAs, metadata, options) {\n var format = chooseFormatForNumber(metadata.formats(), number);\n if (!format) {\n return number;\n }\n return formatNationalNumberUsingFormat(number, format, {\n useInternationalFormat: formatAs === 'INTERNATIONAL',\n withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,\n carrierCode: carrierCode,\n metadata: metadata\n });\n}\nexport function chooseFormatForNumber(availableFormats, nationalNumber) {\n // Using a `for ... of` loop here didn't work with `babel`/`istanbul`:\n // for some weird reason, it showed code coverage less than 100%.\n // That's because `babel`/`istanbul`, for some weird reason,\n // apparently doesn't know how to properly exclude Babel polyfills from code coverage.\n //\n // for (const format of availableFormats) { ... }\n //\n return pickFirstMatchingElement(availableFormats, function (format) {\n // Validate leading digits.\n // The test case for \"else path\" could be found by searching for\n // \"format.leadingDigitsPatterns().length === 0\".\n if (format.leadingDigitsPatterns().length > 0) {\n // The last leading_digits_pattern is used here, as it is the most detailed\n var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1];\n // If leading digits don't match then move on to the next phone number format\n if (nationalNumber.search(lastLeadingDigitsPattern) !== 0) {\n return false;\n }\n }\n // Check that the national number matches the phone number format regular expression\n return matchesEntirely(nationalNumber, format.pattern());\n });\n}\nfunction addExtension(formattedNumber, ext, metadata, formatExtension) {\n return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;\n}\nfunction formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {\n var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata);\n // When calling within the same country calling code.\n if (fromCountryCallingCode === countryCallingCode) {\n var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, 'NATIONAL', metadata);\n // For NANPA regions, return the national format for these regions\n // but prefix it with the country calling code.\n if (countryCallingCode === '1') {\n return countryCallingCode + ' ' + formattedNumber;\n }\n // If regions share a country calling code, the country calling code need\n // not be dialled. This also applies when dialling within a region, so this\n // if clause covers both these cases. Technically this is the case for\n // dialling from La Reunion to other overseas departments of France (French\n // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover\n // this edge case for now and for those cases return the version including\n // country calling code. Details here:\n // http://www.petitfute.com/voyage/225-info-pratiques-reunion\n //\n return formattedNumber;\n }\n var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);\n if (iddPrefix) {\n return \"\".concat(iddPrefix, \" \").concat(countryCallingCode, \" \").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));\n }\n}\nfunction merge() {\n var i = 1;\n for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {\n objects[_key] = arguments[_key];\n }\n while (i < objects.length) {\n if (objects[i]) {\n for (var key in objects[i]) {\n objects[0][key] = objects[i][key];\n }\n }\n i++;\n }\n return objects[0];\n}\nfunction pickFirstMatchingElement(elements, testFunction) {\n var i = 0;\n while (i < elements.length) {\n if (testFunction(elements[i])) {\n return elements[i];\n }\n i++;\n }\n}\n//# sourceMappingURL=format.js.map"],"names":["DEFAULT_OPTIONS","formatExtension","formattedNumber","extension","metadata","concat","ext","formatNumber","input","format","options","merge","Metadata","country","hasCountry","Error","selectNumberingPlan","countryCallingCode","phone","nationalNumber","v2","number","formatNationalNumber","carrierCode","addExtension","formatRFC3966","fromCountry","formatIDD","formatAs","chooseFormatForNumber","formats","formatNationalNumberUsingFormat","useInternationalFormat","withNationalPrefix","nationalPrefixIsOptionalWhenFormattingInNationalFormat","nationalPrefix","availableFormats","pickFirstMatchingElement","leadingDigitsPatterns","length","lastLeadingDigitsPattern","search","matchesEntirely","pattern","fromCountryCallingCode","getCountryCallingCode","iddPrefix","getIddPrefix","undefined","i","_len","arguments","objects","Array","_key","key","elements","testFunction"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAQA,IAAMA,eAAe,GAAG;EACvBC,eAAe,EAAE,SAAjBA,eAAeA,CAAGC,eAAe,EAAEC,SAAS,EAAEC,QAAQ,EAAA;AAAA,IAAA,OAAA,EAAA,CAAAC,MAAA,CAAQH,eAAe,CAAA,CAAAG,MAAA,CAAGD,QAAQ,CAACE,GAAG,EAAE,CAAA,CAAAD,MAAA,CAAGF,SAAS,CAAA;AAAA,EAAA;AAC3G,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASI,YAAYA,CAACC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEN,QAAQ,EAAE;AACtE;AACA,EAAA,IAAIM,OAAO,EAAE;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;IACAA,OAAO,GAAGC,KAAK,CAAC,EAAE,EAAEX,eAAe,EAAEU,OAAO,CAAC;AAC9C,EAAA,CAAC,MAAM;AACNA,IAAAA,OAAO,GAAGV,eAAe;AAC1B,EAAA;AAEAI,EAAAA,QAAQ,GAAG,IAAIQ,QAAQ,CAACR,QAAQ,CAAC;EAEjC,IAAII,KAAK,CAACK,OAAO,IAAIL,KAAK,CAACK,OAAO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OAAO,CAACH,CAAC,CAAC,EAAE;AAC7BG,QAAAA,OAAO,CAAC,CAAC,CAAC,CAACG,GAAG,CAAC,GAAGH,OAAO,CAACH,CAAC,CAAC,CAACM,GAAG,CAAC;AAClC,MAAA;AACD,IAAA;AACAN,IAAAA,CAAC,EAAE;AACJ,EAAA;EACA,OAAOG,OAAO,CAAC,CAAC,CAAC;AAClB;AAEA,SAASf,wBAAwBA,CAACmB,QAAQ,EAAEC,YAAY,EAAE;EACzD,IAAIR,CAAC,GAAG,CAAC;AACT,EAAA,OAAOA,CAAC,GAAGO,QAAQ,CAACjB,MAAM,EAAE;AAC3B,IAAA,IAAIkB,YAAY,CAACD,QAAQ,CAACP,CAAC,CAAC,CAAC,EAAE;MAC9B,OAAOO,QAAQ,CAACP,CAAC,CAAC;AACnB,IAAA;AACAA,IAAAA,CAAC,EAAE;AACJ,EAAA;AACD;;;;","x_google_ignoreList":[0]}
@@ -1,10 +1,43 @@
1
- function checkNumberLength(nationalNumber, metadata) {
2
- return checkNumberLengthForType(nationalNumber, undefined, metadata);
1
+ import Metadata from '../metadata.js';
2
+
3
+ function checkNumberLength(nationalNumber, country, metadata) {
4
+ return checkNumberLengthForType(nationalNumber, country, undefined, metadata);
3
5
  }
4
6
 
5
- // Checks whether a number is possible for the country based on its length.
6
- // Should only be called for the "new" metadata which has "possible lengths".
7
- function checkNumberLengthForType(nationalNumber, type, metadata) {
7
+ // Checks whether a number is possible for a certain `country` based on the number length.
8
+ //
9
+ // This function is not supported by metadata generated with ancient versions of
10
+ // `libphonenumber-js` (before version `1.0.18`) which didn't include "possible lengths".
11
+ //
12
+ // There was also a known issue with `checkNumberLength()` function:
13
+ // if a number is possible only in a certain `country` among several `countries`
14
+ // that share the same "country calling code", that function would check
15
+ // the possibility of the phone number only in the "main" `country` for the "country calling code"
16
+ // and would not check if it's actually be possible in the speciifc `country`.
17
+ //
18
+ // For example, "+1310xxxx" numbers are valid in Canada.
19
+ // However, they are not possible in the US due to being too short.
20
+ // Since Canada and the US share the same country calling code — "+1" —
21
+ // `checkNumberLength()` function used to return not "IS_POSSIBLE" for "+1310xxxx" numbers.
22
+ //
23
+ // In such cases, when using "/max" metadata, `isValid()` could output `true`
24
+ // but at the same time `isPossible()` could output `false`, which was contradictory.
25
+ //
26
+ // See https://issuetracker.google.com/issues/335892662 for the discusson in Google's issues.
27
+ //
28
+ // The solution suggested by Google was implemented: an optional `country` argument
29
+ // was added to `checkNumberLength()` function. If present, that `country` will be used
30
+ // to check phone number length for that specific `country` rather than the "main" country
31
+ // for the shared "country calling code".
32
+ //
33
+ function checkNumberLengthForType(nationalNumber, country, type, metadata) {
34
+ // If the exact `country` is specified, it's no necessarily already selected in `metadata`.
35
+ // Most likely, in cases when there're multiple countries corresponding to the same
36
+ // "country calling code", the "main" country for that "country calling code" will be selected.
37
+ if (country) {
38
+ metadata = new Metadata(metadata.metadata);
39
+ metadata.selectNumberingPlan(country);
40
+ }
8
41
  var type_info = metadata.type(type);
9
42
 
10
43
  // There should always be "<possiblePengths/>" set for every type element.
@@ -15,7 +48,7 @@ function checkNumberLengthForType(nationalNumber, type, metadata) {
15
48
  // exist at all, there is one possible length (-1) which is guaranteed
16
49
  // not to match the length of any real phone number.
17
50
  var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths();
18
- // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
51
+ // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
19
52
 
20
53
  // Metadata before version `1.0.18` didn't contain `possible_lengths`.
21
54
  if (!possible_lengths) {
@@ -1 +1 @@
1
- {"version":3,"file":"checkNumberLength.js","sources":["../../../../../node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js"],"sourcesContent":["import mergeArrays from './mergeArrays.js';\nexport default function checkNumberLength(nationalNumber, metadata) {\n return checkNumberLengthForType(nationalNumber, undefined, metadata);\n}\n\n// Checks whether a number is possible for the country based on its length.\n// Should only be called for the \"new\" metadata which has \"possible lengths\".\nexport function checkNumberLengthForType(nationalNumber, type, metadata) {\n var type_info = metadata.type(type);\n\n // There should always be \"<possiblePengths/>\" set for every type element.\n // This is declared in the XML schema.\n // For size efficiency, where a sub-description (e.g. fixed-line)\n // has the same \"<possiblePengths/>\" as the \"general description\", this is missing,\n // so we fall back to the \"general description\". Where no numbers of the type\n // exist at all, there is one possible length (-1) which is guaranteed\n // not to match the length of any real phone number.\n var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths();\n // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()\n\n // Metadata before version `1.0.18` didn't contain `possible_lengths`.\n if (!possible_lengths) {\n return 'IS_POSSIBLE';\n }\n if (type === 'FIXED_LINE_OR_MOBILE') {\n // No such country in metadata.\n /* istanbul ignore next */\n if (!metadata.type('FIXED_LINE')) {\n // The rare case has been encountered where no fixedLine data is available\n // (true for some non-geographic entities), so we just check mobile.\n return checkNumberLengthForType(nationalNumber, 'MOBILE', metadata);\n }\n var mobile_type = metadata.type('MOBILE');\n if (mobile_type) {\n // Merge the mobile data in if there was any. \"Concat\" creates a new\n // array, it doesn't edit possible_lengths in place, so we don't need a copy.\n // Note that when adding the possible lengths from mobile, we have\n // to again check they aren't empty since if they are this indicates\n // they are the same as the general desc and should be obtained from there.\n possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths());\n // The current list is sorted; we need to merge in the new list and\n // re-sort (duplicates are okay). Sorting isn't so expensive because\n // the lists are very small.\n\n // if (local_lengths) {\n // \tlocal_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())\n // } else {\n // \tlocal_lengths = mobile_type.possibleLengthsLocal()\n // }\n }\n }\n // If the type doesn't exist then return 'INVALID_LENGTH'.\n else if (type && !type_info) {\n return 'INVALID_LENGTH';\n }\n var actual_length = nationalNumber.length;\n\n // In `libphonenumber-js` all \"local-only\" formats are dropped for simplicity.\n // // This is safe because there is never an overlap beween the possible lengths\n // // and the local-only lengths; this is checked at build time.\n // if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)\n // {\n // \treturn 'IS_POSSIBLE_LOCAL_ONLY'\n // }\n\n var minimum_length = possible_lengths[0];\n if (minimum_length === actual_length) {\n return 'IS_POSSIBLE';\n }\n if (minimum_length > actual_length) {\n return 'TOO_SHORT';\n }\n if (possible_lengths[possible_lengths.length - 1] < actual_length) {\n return 'TOO_LONG';\n }\n\n // We skip the first element since we've already checked it.\n return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';\n}\n//# sourceMappingURL=checkNumberLength.js.map"],"names":["checkNumberLength","nationalNumber","metadata","checkNumberLengthForType","undefined","type","type_info","possible_lengths","possibleLengths","actual_length","length","minimum_length","indexOf"],"mappings":"AAEe,SAASA,iBAAiBA,CAACC,cAAc,EAAEC,QAAQ,EAAE;AACnE,EAAA,OAAOC,wBAAwB,CAACF,cAAc,EAAEG,SAAS,EAAEF,QAAQ,CAAC;AACrE;;AAEA;AACA;AACO,SAASC,wBAAwBA,CAACF,cAAc,EAAEI,IAAI,EAAEH,QAAQ,EAAE;AACxE,EAAA,IAAMI,SAAS,GAAGJ,QAAQ,CAACG,IAAI,CAACA,IAAI,CAAC;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA,IAAIE,gBAAgB,GAAGD,SAAS,IAAIA,SAAS,CAACE,eAAe,EAAE,IAAIN,QAAQ,CAACM,eAAe,EAAE;AAC7F;;AAEA;EACA,IAAI,CAACD,gBAAgB,EAAE;AACtB,IAAA,OAAO,aAAa;AACrB,EAAA;AAmCA,EAAA,IAAME,aAAa,GAAGR,cAAc,CAACS,MAAM;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,EAAA,IAAMC,cAAc,GAAGJ,gBAAgB,CAAC,CAAC,CAAC;EAE1C,IAAII,cAAc,KAAKF,aAAa,EAAE;AACrC,IAAA,OAAO,aAAa;AACrB,EAAA;EAEA,IAAIE,cAAc,GAAGF,aAAa,EAAE;AACnC,IAAA,OAAO,WAAW;AACnB,EAAA;EAEA,IAAIF,gBAAgB,CAACA,gBAAgB,CAACG,MAAM,GAAG,CAAC,CAAC,GAAGD,aAAa,EAAE;AAClE,IAAA,OAAO,UAAU;AAClB,EAAA;;AAEA;AACA,EAAA,OAAOF,gBAAgB,CAACK,OAAO,CAACH,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,aAAa,GAAG,gBAAgB;AAC1F;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"checkNumberLength.js","sources":["../../../../../node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js"],"sourcesContent":["import Metadata from '../metadata.js';\nimport mergeArrays from './mergeArrays.js';\nexport default function checkNumberLength(nationalNumber, country, metadata) {\n return checkNumberLengthForType(nationalNumber, country, undefined, metadata);\n}\n\n// Checks whether a number is possible for a certain `country` based on the number length.\n//\n// This function is not supported by metadata generated with ancient versions of\n// `libphonenumber-js` (before version `1.0.18`) which didn't include \"possible lengths\".\n//\n// There was also a known issue with `checkNumberLength()` function:\n// if a number is possible only in a certain `country` among several `countries`\n// that share the same \"country calling code\", that function would check\n// the possibility of the phone number only in the \"main\" `country` for the \"country calling code\"\n// and would not check if it's actually be possible in the speciifc `country`.\n//\n// For example, \"+1310xxxx\" numbers are valid in Canada.\n// However, they are not possible in the US due to being too short.\n// Since Canada and the US share the same country calling code — \"+1\" —\n// `checkNumberLength()` function used to return not \"IS_POSSIBLE\" for \"+1310xxxx\" numbers.\n//\n// In such cases, when using \"/max\" metadata, `isValid()` could output `true`\n// but at the same time `isPossible()` could output `false`, which was contradictory.\n//\n// See https://issuetracker.google.com/issues/335892662 for the discusson in Google's issues.\n//\n// The solution suggested by Google was implemented: an optional `country` argument\n// was added to `checkNumberLength()` function. If present, that `country` will be used\n// to check phone number length for that specific `country` rather than the \"main\" country\n// for the shared \"country calling code\".\n//\nexport function checkNumberLengthForType(nationalNumber, country, type, metadata) {\n // If the exact `country` is specified, it's no necessarily already selected in `metadata`.\n // Most likely, in cases when there're multiple countries corresponding to the same\n // \"country calling code\", the \"main\" country for that \"country calling code\" will be selected.\n if (country) {\n metadata = new Metadata(metadata.metadata);\n metadata.selectNumberingPlan(country);\n }\n var type_info = metadata.type(type);\n\n // There should always be \"<possiblePengths/>\" set for every type element.\n // This is declared in the XML schema.\n // For size efficiency, where a sub-description (e.g. fixed-line)\n // has the same \"<possiblePengths/>\" as the \"general description\", this is missing,\n // so we fall back to the \"general description\". Where no numbers of the type\n // exist at all, there is one possible length (-1) which is guaranteed\n // not to match the length of any real phone number.\n var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths();\n // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()\n\n // Metadata before version `1.0.18` didn't contain `possible_lengths`.\n if (!possible_lengths) {\n return 'IS_POSSIBLE';\n }\n if (type === 'FIXED_LINE_OR_MOBILE') {\n // No such country in metadata.\n /* istanbul ignore next */\n if (!metadata.type('FIXED_LINE')) {\n // The rare case has been encountered where no fixedLine data is available\n // (true for some non-geographic entities), so we just check mobile.\n return checkNumberLengthForType(nationalNumber, country, 'MOBILE', metadata);\n }\n var mobile_type = metadata.type('MOBILE');\n if (mobile_type) {\n // Merge the mobile data in if there was any. \"Concat\" creates a new\n // array, it doesn't edit possible_lengths in place, so we don't need a copy.\n // Note that when adding the possible lengths from mobile, we have\n // to again check they aren't empty since if they are this indicates\n // they are the same as the general desc and should be obtained from there.\n possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths());\n // The current list is sorted; we need to merge in the new list and\n // re-sort (duplicates are okay). Sorting isn't so expensive because\n // the lists are very small.\n\n // if (local_lengths) {\n // \tlocal_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())\n // } else {\n // \tlocal_lengths = mobile_type.possibleLengthsLocal()\n // }\n }\n }\n // If the type doesn't exist then return 'INVALID_LENGTH'.\n else if (type && !type_info) {\n return 'INVALID_LENGTH';\n }\n var actual_length = nationalNumber.length;\n\n // In `libphonenumber-js` all \"local-only\" formats are dropped for simplicity.\n // // This is safe because there is never an overlap beween the possible lengths\n // // and the local-only lengths; this is checked at build time.\n // if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)\n // {\n // \treturn 'IS_POSSIBLE_LOCAL_ONLY'\n // }\n\n var minimum_length = possible_lengths[0];\n if (minimum_length === actual_length) {\n return 'IS_POSSIBLE';\n }\n if (minimum_length > actual_length) {\n return 'TOO_SHORT';\n }\n if (possible_lengths[possible_lengths.length - 1] < actual_length) {\n return 'TOO_LONG';\n }\n\n // We skip the first element since we've already checked it.\n return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';\n}\n//# sourceMappingURL=checkNumberLength.js.map"],"names":["checkNumberLength","nationalNumber","country","metadata","checkNumberLengthForType","undefined","type","Metadata","selectNumberingPlan","type_info","possible_lengths","possibleLengths","actual_length","length","minimum_length","indexOf"],"mappings":";;AAGe,SAASA,iBAAiBA,CAACC,cAAc,EAAEC,OAAO,EAAEC,QAAQ,EAAE;EAC5E,OAAOC,wBAAwB,CAACH,cAAc,EAAEC,OAAO,EAAEG,SAAS,EAAEF,QAAQ,CAAC;AAC9E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CAACH,cAAc,EAAEC,OAAO,EAAEI,IAAI,EAAEH,QAAQ,EAAE;AACjF;AACA;AACA;AACA,EAAA,IAAID,OAAO,EAAE;AACZC,IAAAA,QAAQ,GAAG,IAAII,QAAQ,CAACJ,QAAQ,CAACA,QAAQ,CAAC;AAC1CA,IAAAA,QAAQ,CAACK,mBAAmB,CAACN,OAAO,CAAC;AACtC,EAAA;AAEA,EAAA,IAAMO,SAAS,GAAGN,QAAQ,CAACG,IAAI,CAACA,IAAI,CAAC;;AAErC;AACA;AAC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