libphonenumber-js 1.13.3 → 1.13.5
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.
- package/.gitlab-ci.yml +24 -9
- package/CHANGELOG.md +20 -15
- package/README.md +27 -10
- package/build/AsYouType.js +100 -27
- package/build/AsYouType.js.map +1 -1
- package/build/AsYouType.test.js.map +1 -1
- package/build/AsYouTypeFormatter.complete.js +2 -2
- package/build/AsYouTypeFormatter.complete.js.map +1 -1
- package/build/AsYouTypeFormatter.js +1 -1
- package/build/AsYouTypeFormatter.js.map +1 -1
- package/build/AsYouTypeState.js +15 -1
- package/build/AsYouTypeState.js.map +1 -1
- package/build/PhoneNumber.js +26 -39
- package/build/PhoneNumber.js.map +1 -1
- package/build/format.js +3 -3
- package/build/format.js.map +1 -1
- package/build/formatPhoneNumberForMobileDialing.js +4 -3
- package/build/formatPhoneNumberForMobileDialing.js.map +1 -1
- package/build/helpers/checkNumberLength.js +21 -6
- package/build/helpers/checkNumberLength.js.map +1 -1
- package/build/helpers/checkNumberLength.test.js.map +1 -1
- package/build/helpers/extractCountryCallingCode.js +16 -11
- package/build/helpers/extractCountryCallingCode.js.map +1 -1
- package/build/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +21 -10
- package/build/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -1
- package/build/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.test.js.map +1 -0
- package/build/helpers/extractNationalNumber.js +12 -3
- package/build/helpers/extractNationalNumber.js.map +1 -1
- package/build/helpers/extractNationalNumber.test.js.map +1 -1
- package/build/helpers/getCountryAndCallingCodeFromOneOfThem.js +35 -0
- package/build/helpers/getCountryAndCallingCodeFromOneOfThem.js.map +1 -0
- package/build/helpers/getCountryByCallingCode.js +10 -7
- package/build/helpers/getCountryByCallingCode.js.map +1 -1
- package/build/helpers/getCountryByNationalNumber.js +13 -9
- package/build/helpers/getCountryByNationalNumber.js.map +1 -1
- package/build/helpers/getIddPrefix.js +1 -1
- package/build/helpers/getIddPrefix.js.map +1 -1
- package/build/helpers/getNumberType.js +3 -3
- package/build/helpers/getNumberType.js.map +1 -1
- package/build/helpers/getPossibleCountriesForNumber.js +4 -7
- package/build/helpers/getPossibleCountriesForNumber.js.map +1 -1
- package/build/helpers/isCallingCode.js +11 -0
- package/build/helpers/isCallingCode.js.map +1 -0
- package/build/helpers/isCallingCode.test.js.map +1 -0
- package/build/helpers/isCountryCode.js +11 -0
- package/build/helpers/isCountryCode.js.map +1 -0
- package/build/helpers/isCountryCode.test.js.map +1 -0
- package/build/helpers/stripIddPrefix.js +9 -4
- package/build/helpers/stripIddPrefix.js.map +1 -1
- package/build/isPossible.js +14 -8
- package/build/isPossible.js.map +1 -1
- package/build/isValid.js +3 -3
- package/build/isValid.js.map +1 -1
- package/build/metadata.js +80 -31
- package/build/metadata.js.map +1 -1
- package/build/metadata.test.js.map +1 -1
- package/build/parse.js +36 -12
- package/build/parse.js.map +1 -1
- package/build/validatePhoneNumberLength.js +3 -3
- package/build/validatePhoneNumberLength.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/core/index.d.cts +1 -0
- package/core/index.d.ts +1 -0
- package/custom.d.ts +3 -1
- package/es6/AsYouType.js +100 -27
- package/es6/AsYouType.js.map +1 -1
- package/es6/AsYouType.test.js.map +1 -1
- package/es6/AsYouTypeFormatter.complete.js +2 -2
- package/es6/AsYouTypeFormatter.complete.js.map +1 -1
- package/es6/AsYouTypeFormatter.js +1 -1
- package/es6/AsYouTypeFormatter.js.map +1 -1
- package/es6/AsYouTypeState.js +15 -1
- package/es6/AsYouTypeState.js.map +1 -1
- package/es6/PhoneNumber.js +26 -39
- package/es6/PhoneNumber.js.map +1 -1
- package/es6/format.js +3 -3
- package/es6/format.js.map +1 -1
- package/es6/formatPhoneNumberForMobileDialing.js +4 -3
- package/es6/formatPhoneNumberForMobileDialing.js.map +1 -1
- package/es6/helpers/checkNumberLength.js +22 -6
- package/es6/helpers/checkNumberLength.js.map +1 -1
- package/es6/helpers/checkNumberLength.test.js.map +1 -1
- package/es6/helpers/extractCountryCallingCode.js +16 -11
- package/es6/helpers/extractCountryCallingCode.js.map +1 -1
- package/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +21 -10
- package/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -1
- package/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.test.js.map +1 -0
- package/es6/helpers/extractNationalNumber.js +12 -3
- package/es6/helpers/extractNationalNumber.js.map +1 -1
- package/es6/helpers/extractNationalNumber.test.js.map +1 -1
- package/es6/helpers/getCountryAndCallingCodeFromOneOfThem.js +28 -0
- package/es6/helpers/getCountryAndCallingCodeFromOneOfThem.js.map +1 -0
- package/es6/helpers/getCountryByCallingCode.js +10 -7
- package/es6/helpers/getCountryByCallingCode.js.map +1 -1
- package/es6/helpers/getCountryByNationalNumber.js +13 -9
- package/es6/helpers/getCountryByNationalNumber.js.map +1 -1
- package/es6/helpers/getIddPrefix.js +1 -1
- package/es6/helpers/getIddPrefix.js.map +1 -1
- package/es6/helpers/getNumberType.js +3 -3
- package/es6/helpers/getNumberType.js.map +1 -1
- package/es6/helpers/getPossibleCountriesForNumber.js +4 -7
- package/es6/helpers/getPossibleCountriesForNumber.js.map +1 -1
- package/es6/helpers/isCallingCode.js +5 -0
- package/es6/helpers/isCallingCode.js.map +1 -0
- package/es6/helpers/isCallingCode.test.js.map +1 -0
- package/es6/helpers/isCountryCode.js +5 -0
- package/es6/helpers/isCountryCode.js.map +1 -0
- package/es6/helpers/isCountryCode.test.js.map +1 -0
- package/es6/helpers/stripIddPrefix.js +9 -4
- package/es6/helpers/stripIddPrefix.js.map +1 -1
- package/es6/isPossible.js +14 -8
- package/es6/isPossible.js.map +1 -1
- package/es6/isValid.js +3 -3
- package/es6/isValid.js.map +1 -1
- package/es6/metadata.js +80 -31
- package/es6/metadata.js.map +1 -1
- package/es6/metadata.test.js.map +1 -1
- package/es6/parse.js +36 -12
- package/es6/parse.js.map +1 -1
- package/es6/validatePhoneNumberLength.js +3 -3
- package/es6/validatePhoneNumberLength.js.map +1 -1
- package/es6-modern/AsYouType.js +100 -26
- package/es6-modern/AsYouType.js.map +1 -1
- package/es6-modern/AsYouType.test.js.map +1 -1
- package/es6-modern/AsYouTypeFormatter.complete.js +2 -2
- package/es6-modern/AsYouTypeFormatter.complete.js.map +1 -1
- package/es6-modern/AsYouTypeFormatter.js +1 -1
- package/es6-modern/AsYouTypeFormatter.js.map +1 -1
- package/es6-modern/AsYouTypeState.js +15 -1
- package/es6-modern/AsYouTypeState.js.map +1 -1
- package/es6-modern/PhoneNumber.js +25 -36
- package/es6-modern/PhoneNumber.js.map +1 -1
- package/es6-modern/format.js +3 -3
- package/es6-modern/format.js.map +1 -1
- package/es6-modern/formatPhoneNumberForMobileDialing.js +4 -3
- package/es6-modern/formatPhoneNumberForMobileDialing.js.map +1 -1
- package/es6-modern/helpers/checkNumberLength.js +22 -6
- package/es6-modern/helpers/checkNumberLength.js.map +1 -1
- package/es6-modern/helpers/checkNumberLength.test.js.map +1 -1
- package/es6-modern/helpers/extractCountryCallingCode.js +16 -11
- package/es6-modern/helpers/extractCountryCallingCode.js.map +1 -1
- package/es6-modern/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +21 -10
- package/es6-modern/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -1
- package/es6-modern/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.test.js.map +1 -0
- package/es6-modern/helpers/extractNationalNumber.js +12 -3
- package/es6-modern/helpers/extractNationalNumber.js.map +1 -1
- package/es6-modern/helpers/extractNationalNumber.test.js.map +1 -1
- package/es6-modern/helpers/getCountryAndCallingCodeFromOneOfThem.js +28 -0
- package/es6-modern/helpers/getCountryAndCallingCodeFromOneOfThem.js.map +1 -0
- package/es6-modern/helpers/getCountryByCallingCode.js +10 -7
- package/es6-modern/helpers/getCountryByCallingCode.js.map +1 -1
- package/es6-modern/helpers/getCountryByNationalNumber.js +13 -10
- package/es6-modern/helpers/getCountryByNationalNumber.js.map +1 -1
- package/es6-modern/helpers/getIddPrefix.js +1 -1
- package/es6-modern/helpers/getIddPrefix.js.map +1 -1
- package/es6-modern/helpers/getNumberType.js +3 -3
- package/es6-modern/helpers/getNumberType.js.map +1 -1
- package/es6-modern/helpers/getPossibleCountriesForNumber.js +4 -7
- package/es6-modern/helpers/getPossibleCountriesForNumber.js.map +1 -1
- package/es6-modern/helpers/isCallingCode.js +5 -0
- package/es6-modern/helpers/isCallingCode.js.map +1 -0
- package/es6-modern/helpers/isCallingCode.test.js.map +1 -0
- package/es6-modern/helpers/isCountryCode.js +5 -0
- package/es6-modern/helpers/isCountryCode.js.map +1 -0
- package/es6-modern/helpers/isCountryCode.test.js.map +1 -0
- package/es6-modern/helpers/stripIddPrefix.js +9 -4
- package/es6-modern/helpers/stripIddPrefix.js.map +1 -1
- package/es6-modern/isPossible.js +14 -8
- package/es6-modern/isPossible.js.map +1 -1
- package/es6-modern/isValid.js +3 -3
- package/es6-modern/isValid.js.map +1 -1
- package/es6-modern/metadata.js +78 -31
- package/es6-modern/metadata.js.map +1 -1
- package/es6-modern/metadata.test.js.map +1 -1
- package/es6-modern/parse.js +41 -12
- package/es6-modern/parse.js.map +1 -1
- package/es6-modern/validatePhoneNumberLength.js +3 -3
- package/es6-modern/validatePhoneNumberLength.js.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/max/index.d.cts +1 -0
- package/max/index.d.ts +1 -0
- package/min/index.d.cts +1 -0
- package/min/index.d.ts +1 -0
- package/mobile/index.d.cts +1 -0
- package/mobile/index.d.ts +1 -0
- package/package.json +1 -1
- package/source/AsYouType.js +108 -27
- package/source/AsYouTypeFormatter.complete.js +2 -2
- package/source/AsYouTypeFormatter.js +1 -1
- package/source/AsYouTypeState.js +15 -1
- package/source/PhoneNumber.js +24 -39
- package/source/format.js +3 -3
- package/source/formatPhoneNumberForMobileDialing.js +4 -3
- package/source/helpers/checkNumberLength.js +21 -6
- package/source/helpers/extractCountryCallingCode.js +16 -11
- package/source/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +20 -10
- package/source/helpers/extractNationalNumber.js +11 -3
- package/source/helpers/getCountryAndCallingCodeFromOneOfThem.js +31 -0
- package/source/helpers/getCountryByCallingCode.js +10 -7
- package/source/helpers/getCountryByNationalNumber.js +14 -11
- package/source/helpers/getIddPrefix.js +1 -1
- package/source/helpers/getNumberType.js +3 -3
- package/source/helpers/getPossibleCountriesForNumber.js +4 -7
- package/source/helpers/isCallingCode.js +5 -0
- package/source/helpers/isCountryCode.js +5 -0
- package/source/helpers/stripIddPrefix.js +10 -4
- package/source/isPossible.js +13 -7
- package/source/isValid.js +3 -3
- package/source/metadata.js +77 -33
- package/source/parse.js +41 -11
- package/source/validatePhoneNumberLength.js +3 -3
- package/types.d.cts +5 -34
- package/types.d.ts +5 -34
package/core/index.d.cts
CHANGED
package/core/index.d.ts
CHANGED
package/custom.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
PhoneNumberType,
|
|
17
17
|
NumberType,
|
|
18
18
|
NumberFormat,
|
|
19
|
-
NumberingPlan
|
|
19
|
+
NumberingPlan,
|
|
20
|
+
ValidatePhoneNumberLengthResult
|
|
20
21
|
} from './types.d.js';
|
|
21
22
|
|
|
22
23
|
import {
|
|
@@ -128,6 +129,7 @@ export class AsYouType {
|
|
|
128
129
|
isInternational(): boolean;
|
|
129
130
|
isPossible(): boolean;
|
|
130
131
|
isValid(): boolean;
|
|
132
|
+
validateLength(): ValidatePhoneNumberLengthResult;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
export class Metadata {
|
package/es6/AsYouType.js
CHANGED
|
@@ -12,6 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
12
12
|
function _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); }
|
|
13
13
|
import Metadata from './metadata.js';
|
|
14
14
|
import PhoneNumber from './PhoneNumber.js';
|
|
15
|
+
import checkNumberLength from './helpers/checkNumberLength.js';
|
|
15
16
|
import AsYouTypeState from './AsYouTypeState.js';
|
|
16
17
|
import AsYouTypeFormatter, { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.js';
|
|
17
18
|
import AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser.js';
|
|
@@ -26,6 +27,9 @@ var AsYouType = /*#__PURE__*/function () {
|
|
|
26
27
|
*/
|
|
27
28
|
function AsYouType(optionsOrDefaultCountry, metadata) {
|
|
28
29
|
_classCallCheck(this, AsYouType);
|
|
30
|
+
// Metadata instance is created once and stays constant.
|
|
31
|
+
// This is required because other utility classes such as `AsYouTypeFormatter`
|
|
32
|
+
// will use this metadata instance "reference" and will assume that it stays constant.
|
|
29
33
|
this.metadata = new Metadata(metadata);
|
|
30
34
|
var _this$getCountryAndCa = this.getCountryAndCallingCode(optionsOrDefaultCountry),
|
|
31
35
|
_this$getCountryAndCa2 = _slicedToArray(_this$getCountryAndCa, 2),
|
|
@@ -119,7 +123,7 @@ var AsYouType = /*#__PURE__*/function () {
|
|
|
119
123
|
_this.country = country;
|
|
120
124
|
},
|
|
121
125
|
onCallingCodeChange: function onCallingCodeChange(callingCode, country) {
|
|
122
|
-
_this.metadata.selectNumberingPlan(country
|
|
126
|
+
_this.metadata.selectNumberingPlan(country || callingCode);
|
|
123
127
|
_this.formatter.reset(_this.metadata.numberingPlan, _this.state);
|
|
124
128
|
_this.parser.reset(_this.metadata.numberingPlan);
|
|
125
129
|
}
|
|
@@ -309,10 +313,32 @@ var AsYouType = /*#__PURE__*/function () {
|
|
|
309
313
|
}, {
|
|
310
314
|
key: "determineTheCountry",
|
|
311
315
|
value: function determineTheCountry() {
|
|
312
|
-
|
|
316
|
+
// Get a more precise country code for this national number.
|
|
317
|
+
// It is possible that the precise country couldn't be determined
|
|
318
|
+
// in cases when there're multiple countries sharing the same calling code.
|
|
319
|
+
// In that case, `country` will be `undefined`.
|
|
320
|
+
var country = getCountryByCallingCode(this.isInternational() ? this.state.callingCode : this.defaultCallingCode, {
|
|
313
321
|
nationalNumber: this.state.nationalSignificantNumber,
|
|
314
322
|
metadata: this.metadata
|
|
315
|
-
})
|
|
323
|
+
});
|
|
324
|
+
// If the derived country is indeed more precise,
|
|
325
|
+
// or if no country could be derived for the updated phone number.
|
|
326
|
+
if (country !== this.state.country) {
|
|
327
|
+
// Set (or reset) the more precise country.
|
|
328
|
+
this.state.setCountry(country);
|
|
329
|
+
// If a more precise country could be derived.
|
|
330
|
+
if (country) {
|
|
331
|
+
// Select a more precise telephone numbering plan.
|
|
332
|
+
// For example, consider that `AsYouType` instance was created with `defaultCountry: "US"` argument.
|
|
333
|
+
// In that case, the metadata instance will be using "US" metadata.
|
|
334
|
+
// But then the user could input a Canadian phone number, in which case
|
|
335
|
+
// the metadata instance should be switched to Canadian telephone numbering plan.
|
|
336
|
+
// It is required to do that because later `canFormatCompleteNumber()` function will be called,
|
|
337
|
+
// and that function relies on the precise country being pre-selected in the metadata instance.
|
|
338
|
+
// Or, for example, `checkNumberLength()` function also relies on same thing.
|
|
339
|
+
this.metadata.selectNumberingPlan(country);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
316
342
|
}
|
|
317
343
|
|
|
318
344
|
/**
|
|
@@ -373,18 +399,19 @@ var AsYouType = /*#__PURE__*/function () {
|
|
|
373
399
|
nationalSignificantNumber = _this$state3.nationalSignificantNumber,
|
|
374
400
|
carrierCode = _this$state3.carrierCode,
|
|
375
401
|
callingCode = _this$state3.callingCode;
|
|
402
|
+
if (!nationalSignificantNumber) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
376
405
|
|
|
377
406
|
// `this._getCountry()` is basically same as `this.state.country`
|
|
378
|
-
// with the only change that it
|
|
407
|
+
// with the only change that it returns `undefined` in case of a
|
|
379
408
|
// "non-geographic" numbering plan instead of `"001"` "internal use" value.
|
|
380
409
|
var country = this._getCountry();
|
|
381
|
-
if (!nationalSignificantNumber) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
410
|
|
|
385
|
-
//
|
|
386
|
-
//
|
|
387
|
-
//
|
|
411
|
+
// Sidenote:
|
|
412
|
+
// `state.callingCode` and `state.country` are somewhat independent from one another
|
|
413
|
+
// and there could be situations when one is defined but the other is not.
|
|
414
|
+
// See the comment in `AsYouTypeState.js` for more info on when that is possible.
|
|
388
415
|
|
|
389
416
|
if (!country && !callingCode) {
|
|
390
417
|
return;
|
|
@@ -400,26 +427,32 @@ var AsYouType = /*#__PURE__*/function () {
|
|
|
400
427
|
//
|
|
401
428
|
// Because `AsYouType.getNumber()` method is supposed to be a 1:1
|
|
402
429
|
// equivalent for `parsePhoneNumber(AsYouType.getNumberValue())`,
|
|
403
|
-
//
|
|
430
|
+
// it means that it should also behave accordingly in such cases of `country` ambiguity.
|
|
404
431
|
// That's how users of this library would expect it to behave anyway.
|
|
405
432
|
//
|
|
433
|
+
// So here it checks if `state.country` is same as the `defaultCountry`,
|
|
434
|
+
// and if it is, it attempts to get rid of any potential ambiguity.
|
|
435
|
+
//
|
|
406
436
|
if (country) {
|
|
407
437
|
if (country === this.defaultCountry) {
|
|
408
|
-
//
|
|
409
|
-
//
|
|
410
|
-
//
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
438
|
+
// // Create a `Metadata` instance just to get the calling code of the `country`.
|
|
439
|
+
// const metadata = new Metadata(this.metadata.metadata)
|
|
440
|
+
// // `state.callingCode` and `state.country` are somewhat independent from one another
|
|
441
|
+
// // and there could be situations when one is defined but the other is not.
|
|
442
|
+
// // See the comment in `AsYouTypeState.js` for more info on when that is possible.
|
|
443
|
+
// // Here, it only passes `state.country` because there's no need to pass `state.callingCode`
|
|
444
|
+
// // because `state.country` is known to be defined.
|
|
445
|
+
// metadata.selectNumberingPlan(country)
|
|
446
|
+
// const countryCallingCode = metadata.numberingPlan.callingCode()
|
|
447
|
+
|
|
448
|
+
// Instead of getting `countryCallingCode` value above,
|
|
449
|
+
// it could simply read it from the existing metadata instance.
|
|
450
|
+
var countryCallingCode = this.metadata.numberingPlan.callingCode();
|
|
451
|
+
|
|
452
|
+
// Attempt to rule out any potential country code ambiguity, if present.
|
|
453
|
+
var exactCountry = getExactCountryForMultiCountryCallingCode(countryCallingCode, nationalSignificantNumber, this.metadata);
|
|
454
|
+
if (exactCountry) {
|
|
455
|
+
country = exactCountry;
|
|
423
456
|
}
|
|
424
457
|
}
|
|
425
458
|
}
|
|
@@ -461,6 +494,39 @@ var AsYouType = /*#__PURE__*/function () {
|
|
|
461
494
|
return phoneNumber.isValid();
|
|
462
495
|
}
|
|
463
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Checks if the phone number length is valid.
|
|
499
|
+
* If it is, nothing is returned.
|
|
500
|
+
* Otherwise, a rejection reason is returned.
|
|
501
|
+
* @return {string?}
|
|
502
|
+
*/
|
|
503
|
+
}, {
|
|
504
|
+
key: "validateLength",
|
|
505
|
+
value: function validateLength() {
|
|
506
|
+
var _this$state4 = this.state,
|
|
507
|
+
digits = _this$state4.digits,
|
|
508
|
+
nationalSignificantNumber = _this$state4.nationalSignificantNumber;
|
|
509
|
+
if (!digits) {
|
|
510
|
+
return 'NOT_A_NUMBER';
|
|
511
|
+
}
|
|
512
|
+
if (!this.metadata.numberingPlan) {
|
|
513
|
+
return 'INVALID_COUNTRY';
|
|
514
|
+
}
|
|
515
|
+
if (!nationalSignificantNumber) {
|
|
516
|
+
return 'TOO_SHORT';
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// `state.callingCode` and `state.country` are somewhat independent from one another
|
|
520
|
+
// and there could be situations when one is defined but the other is not.
|
|
521
|
+
// See the comment in `AsYouTypeState.js` for more info on when that is possible.
|
|
522
|
+
// Here, it uses both: if `country` is defined then it will use that,
|
|
523
|
+
// otherwise it will use `callingCode`.
|
|
524
|
+
var result = checkNumberLength(nationalSignificantNumber, undefined, this.metadata);
|
|
525
|
+
if (result !== 'IS_POSSIBLE') {
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
464
530
|
/**
|
|
465
531
|
* @deprecated
|
|
466
532
|
* This method is used in `react-phone-number-input/source/input-control.js`
|
|
@@ -492,6 +558,13 @@ var AsYouType = /*#__PURE__*/function () {
|
|
|
492
558
|
return this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || '';
|
|
493
559
|
}
|
|
494
560
|
}]);
|
|
495
|
-
}();
|
|
561
|
+
}(); // In situations when multiple countries use the same calling code,
|
|
562
|
+
// this function tells what exact country does a given national (significant) number belong to.
|
|
496
563
|
export { AsYouType as default };
|
|
564
|
+
function getExactCountryForMultiCountryCallingCode(callingCode, nationalSignificantNumber, metadata) {
|
|
565
|
+
var ambiguousCountries = metadata.getCountryCodesForCallingCode(callingCode);
|
|
566
|
+
if (ambiguousCountries.length > 1) {
|
|
567
|
+
return getCountryByNationalNumber(nationalSignificantNumber, ambiguousCountries, metadata.metadata);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
497
570
|
//# sourceMappingURL=AsYouType.js.map
|
package/es6/AsYouType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsYouType.js","names":["Metadata","PhoneNumber","AsYouTypeState","AsYouTypeFormatter","DIGIT_PLACEHOLDER","AsYouTypeParser","extractFormattedDigitsAndPlus","getCountryByCallingCode","getCountryByNationalNumber","isObject","USE_NON_GEOGRAPHIC_COUNTRY_CODE","AsYouType","optionsOrDefaultCountry","metadata","_classCallCheck","_this$getCountryAndCa","getCountryAndCallingCode","_this$getCountryAndCa2","_slicedToArray","defaultCountry","defaultCallingCode","reset","_createClass","key","value","hasCountry","undefined","isNonGeographicCallingCode","input","text","_this$parser$input","parser","state","digits","justLeadingPlus","formattedOutput","determineTheCountryIfNeeded","nationalSignificantNumber","formatter","narrowDownMatchingFormats","formattedNationalNumber","hasSelectedNumberingPlan","format","reExtractNationalSignificantNumber","nationalDigits","getNationalDigits","getFullNumber","getNonFormattedNumber","_this","onCountryChange","country","onCallingCodeChange","callingCode","selectNumberingPlan","numberingPlan","onNationalSignificantNumberChange","isInternational","international","getCallingCode","getCountryCallingCode","getCountry","_getCountry","isCountryCallingCodeAmbiguous","determineTheCountry","_this2","prefix","getInternationalPrefixBeforeCountryCallingCode","spacing","concat","getDigitsWithoutInternationalPrefix","getNonFormattedNationalNumberWithPrefix","_this$state","prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix","nationalPrefix","number","nationalSignificantNumberIsModified","getNonFormattedTemplate","replace","countryCodes","getCountryCodesForCallingCode","length","setCountry","nationalNumber","getNumberValue","_this$state2","callingCode_","countryCallingCode","getNumber","_this$state3","carrierCode","ambiguousCountries","exactCountry","countries","phoneNumber","isPossible","isValid","getNationalNumber","getChars","getTemplate","default"],"sources":["../source/AsYouType.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport PhoneNumber from './PhoneNumber.js'\r\nimport AsYouTypeState from './AsYouTypeState.js'\r\nimport AsYouTypeFormatter, { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.js'\r\nimport AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser.js'\r\nimport getCountryByCallingCode from './helpers/getCountryByCallingCode.js'\r\nimport getCountryByNationalNumber from './helpers/getCountryByNationalNumber.js'\r\nimport isObject from './helpers/isObject.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class AsYouType {\r\n\t/**\r\n\t * @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.\r\n\t * @param {Object} metadata\r\n\t */\r\n\tconstructor(optionsOrDefaultCountry, metadata) {\r\n\t\tthis.metadata = new Metadata(metadata)\r\n\t\tconst [defaultCountry, defaultCallingCode] = this.getCountryAndCallingCode(optionsOrDefaultCountry)\r\n\t\t// `this.defaultCountry` and `this.defaultCallingCode` aren't required to be in sync.\r\n\t\t// For example, `this.defaultCountry` could be `\"AR\"` and `this.defaultCallingCode` could be `undefined`.\r\n\t\t// So `this.defaultCountry` and `this.defaultCallingCode` are totally independent.\r\n\t\tthis.defaultCountry = defaultCountry\r\n\t\tthis.defaultCallingCode = defaultCallingCode\r\n\t\tthis.reset()\r\n\t}\r\n\r\n\tgetCountryAndCallingCode(optionsOrDefaultCountry) {\r\n\t\t// Set `defaultCountry` and `defaultCallingCode` options.\r\n\t\tlet defaultCountry\r\n\t\tlet defaultCallingCode\r\n\t\t// Turns out `null` also has type \"object\". Weird.\r\n\t\tif (optionsOrDefaultCountry) {\r\n\t\t\tif (isObject(optionsOrDefaultCountry)) {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry.defaultCountry\r\n\t\t\t\tdefaultCallingCode = optionsOrDefaultCountry.defaultCallingCode\r\n\t\t\t} else {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (defaultCountry && !this.metadata.hasCountry(defaultCountry)) {\r\n\t\t\tdefaultCountry = undefined\r\n\t\t}\r\n\t\tif (defaultCallingCode) {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (this.metadata.isNonGeographicCallingCode(defaultCallingCode)) {\r\n\t\t\t\t\tdefaultCountry = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn [defaultCountry, defaultCallingCode]\r\n\t}\r\n\r\n\t/**\r\n\t * Inputs \"next\" phone number characters.\r\n\t * @param {string} text\r\n\t * @return {string} Formatted phone number characters that have been input so far.\r\n\t */\r\n\tinput(text) {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tjustLeadingPlus\r\n\t\t} = this.parser.input(text, this.state)\r\n\t\tif (justLeadingPlus) {\r\n\t\t\tthis.formattedOutput = '+'\r\n\t\t} else if (digits) {\r\n\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t// Match the available formats by the currently available leading digits.\r\n\t\t\tif (this.state.nationalSignificantNumber) {\r\n\t\t\t\tthis.formatter.narrowDownMatchingFormats(this.state)\r\n\t\t\t}\r\n\t\t\tlet formattedNationalNumber\r\n\t\t\tif (this.metadata.hasSelectedNumberingPlan()) {\r\n\t\t\t\tformattedNationalNumber = this.formatter.format(digits, this.state)\r\n\t\t\t}\r\n\t\t\tif (formattedNationalNumber === undefined) {\r\n\t\t\t\t// See if another national (significant) number could be re-extracted.\r\n\t\t\t\tif (this.parser.reExtractNationalSignificantNumber(this.state)) {\r\n\t\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\t\t// If it could, then re-try formatting the new national (significant) number.\r\n\t\t\t\t\tconst nationalDigits = this.state.getNationalDigits()\r\n\t\t\t\t\tif (nationalDigits) {\r\n\t\t\t\t\t\tformattedNationalNumber = this.formatter.format(nationalDigits, this.state)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.formattedOutput = formattedNationalNumber\r\n\t\t\t\t? this.getFullNumber(formattedNationalNumber)\r\n\t\t\t\t: this.getNonFormattedNumber()\r\n\t\t}\r\n\t\treturn this.formattedOutput\r\n\t}\r\n\r\n\treset() {\r\n\t\tthis.state = new AsYouTypeState({\r\n\t\t\tonCountryChange: (country) => {\r\n\t\t\t\t// Before version `1.6.0`, the official `AsYouType` formatter API\r\n\t\t\t\t// included a `.country` property on an `AsYouType` instance.\r\n\t\t\t\t// Since that property (along with the others) have been moved to\r\n\t\t\t\t// `this.state`, `this.country` property is emulated for compatibility\r\n\t\t\t\t// with the old versions.\r\n\t\t\t\tthis.country = country\r\n\t\t\t},\r\n\t\t\tonCallingCodeChange: (callingCode, country) => {\r\n\t\t\t\tthis.metadata.selectNumberingPlan(country, callingCode)\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t\tthis.parser.reset(this.metadata.numberingPlan)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.formatter = new AsYouTypeFormatter({\r\n\t\t\tstate: this.state,\r\n\t\t\tmetadata: this.metadata\r\n\t\t})\r\n\t\tthis.parser = new AsYouTypeParser({\r\n\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\tdefaultCallingCode: this.defaultCallingCode,\r\n\t\t\tmetadata: this.metadata,\r\n\t\t\tstate: this.state,\r\n\t\t\tonNationalSignificantNumberChange: () => {\r\n\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.state.reset({\r\n\t\t\tcountry: this.defaultCountry,\r\n\t\t\tcallingCode: this.defaultCallingCode\r\n\t\t})\r\n\t\tthis.formattedOutput = ''\r\n\t\treturn this\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is being input in international format.\r\n\t * In other words, returns `true` if and only if the parsed phone number starts with a `\"+\"`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisInternational() {\r\n\t\treturn this.state.international\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the \"calling code\" part of the phone number when it's being input\r\n\t * in an international format.\r\n\t * If no valid calling code has been entered so far, returns `undefined`.\r\n\t * @return {string} [callingCode]\r\n\t */\r\n\tgetCallingCode() {\r\n\t\t // If the number is being input in national format and some \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then `this.state.callingCode`\r\n\t\t // is equal to that \"default calling code\".\r\n\t\t //\r\n\t\t // If the number is being input in national format and no \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then returns `undefined`,\r\n\t\t // even if a \"default country\" has been passed to `AsYouType` constructor.\r\n\t\t //\r\n\t\tif (this.isInternational()) {\r\n\t\t\treturn this.state.callingCode\r\n\t\t}\r\n\t}\r\n\r\n\t// A legacy alias.\r\n\tgetCountryCallingCode() {\r\n\t\treturn this.getCallingCode()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * Returns `undefined` if no phone number has been input yet.\r\n\t * @return {string} [country]\r\n\t */\r\n\tgetCountry() {\r\n\t\tconst { digits } = this.state\r\n\t\t// Return `undefined` if no digits have been input yet.\r\n\t\tif (digits) {\r\n\t\t\treturn this._getCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * @return {string} [country]\r\n\t */\r\n\t_getCountry() {\r\n\t\tconst { country } = this.state\r\n\t\t/* istanbul ignore if */\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t// `AsYouType.getCountry()` returns `undefined`\r\n\t\t\t// for \"non-geographic\" phone numbering plans.\r\n\t\t\tif (country === '001') {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn country\r\n\t}\r\n\r\n\tdetermineTheCountryIfNeeded() {\r\n\t\t// Suppose a user enters a phone number in international format,\r\n\t\t// and there're several countries corresponding to that country calling code,\r\n\t\t// and a country has been derived from the number, and then\r\n\t\t// a user enters one more digit and the number is no longer\r\n\t\t// valid for the derived country, so the country should be re-derived\r\n\t\t// on every new digit in those cases.\r\n\t\t//\r\n\t\t// If the phone number is being input in national format,\r\n\t\t// then it could be a case when `defaultCountry` wasn't specified\r\n\t\t// when creating `AsYouType` instance, and just `defaultCallingCode` was specified,\r\n\t\t// and that \"calling code\" could correspond to a \"non-geographic entity\",\r\n\t\t// or there could be several countries corresponding to that country calling code.\r\n\t\t// In those cases, `this.country` is `undefined` and should be derived\r\n\t\t// from the number. Again, if country calling code is ambiguous, then\r\n\t\t// `this.country` should be re-derived with each new digit.\r\n\t\t//\r\n\t\tif (!this.state.country || this.isCountryCallingCodeAmbiguous()) {\r\n\t\t\tthis.determineTheCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t// Prepends `+CountryCode ` in case of an international phone number\r\n\tgetFullNumber(formattedNationalNumber) {\r\n\t\tif (this.isInternational()) {\r\n\t\t\tconst prefix = (text) => this.formatter.getInternationalPrefixBeforeCountryCallingCode(this.state, {\r\n\t\t\t\tspacing: text ? true : false\r\n\t\t\t}) + text\r\n\t\t\tconst { callingCode } = this.state\r\n\t\t\tif (!callingCode) {\r\n\t\t\t\treturn prefix(`${this.state.getDigitsWithoutInternationalPrefix()}`)\r\n\t\t\t}\r\n\t\t\tif (!formattedNationalNumber) {\r\n\t\t\t\treturn prefix(callingCode)\r\n\t\t\t}\r\n\t\t\treturn prefix(`${callingCode} ${formattedNationalNumber}`)\r\n\t\t}\r\n\t\treturn formattedNationalNumber\r\n\t}\r\n\r\n\tgetNonFormattedNationalNumberWithPrefix() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tprefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,\r\n\t\t\tnationalPrefix\r\n\t\t} = this.state\r\n\t\tlet number = nationalSignificantNumber\r\n\t\tconst prefix = prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix || nationalPrefix\r\n\t\tif (prefix) {\r\n\t\t\tnumber = prefix + number\r\n\t\t}\r\n\t\treturn number\r\n\t}\r\n\r\n\tgetNonFormattedNumber() {\r\n\t\tconst { nationalSignificantNumberIsModified } = this.state\r\n\t\treturn this.getFullNumber(\r\n\t\t\tnationalSignificantNumberIsModified\r\n\t\t\t\t? this.state.getNationalDigits()\r\n\t\t\t\t: this.getNonFormattedNationalNumberWithPrefix()\r\n\t\t)\r\n\t}\r\n\r\n\tgetNonFormattedTemplate() {\r\n\t\tconst number = this.getNonFormattedNumber()\r\n\t\tif (number) {\r\n\t\t\treturn number.replace(/[\\+\\d]/g, DIGIT_PLACEHOLDER)\r\n\t\t}\r\n\t}\r\n\r\n\tisCountryCallingCodeAmbiguous() {\r\n\t\tconst { callingCode } = this.state\r\n\t\tconst countryCodes = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\treturn countryCodes && countryCodes.length > 1\r\n\t}\r\n\r\n\t// Determines the exact country of the phone number\r\n\t// entered so far based on the country phone code\r\n\t// and the national phone number.\r\n\tdetermineTheCountry() {\r\n\t\tthis.state.setCountry(getCountryByCallingCode(\r\n\t\t\tthis.isInternational() ? this.state.callingCode : this.defaultCallingCode,\r\n\t\t\t{\r\n\t\t\t\tnationalNumber: this.state.nationalSignificantNumber,\r\n\t\t\t\tmetadata: this.metadata\r\n\t\t\t}\r\n\t\t))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a E.164 phone number value for the user's input.\r\n\t *\r\n\t * For example, for country `\"US\"` and input `\"(222) 333-4444\"`\r\n\t * it will return `\"+12223334444\"`.\r\n\t *\r\n\t * For international phone number input, it will also auto-correct\r\n\t * some minor errors such as using a national prefix when writing\r\n\t * an international phone number. For example, if the user inputs\r\n\t * `\"+44 0 7400 000000\"` then it will return an auto-corrected\r\n\t * `\"+447400000000\"` phone number value.\r\n\t *\r\n\t * Will return `undefined` if no digits have been input,\r\n\t * or when inputting a phone number in national format and no\r\n\t * default country or default \"country calling code\" have been set.\r\n\t *\r\n\t * @return {string} [value]\r\n\t */\r\n\tgetNumberValue() {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tcallingCode,\r\n\t\t\tcountry,\r\n\t\t\tnationalSignificantNumber\r\n\t\t} = this.state\r\n\r\n\t \t// Will return `undefined` if no digits have been input.\r\n\t\tif (!digits) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (this.isInternational()) {\r\n\t\t\tif (callingCode) {\r\n\t\t\t\treturn '+' + callingCode + nationalSignificantNumber\r\n\t\t\t} else {\r\n\t\t\t\treturn '+' + digits\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (country || callingCode) {\r\n\t\t\t\tconst callingCode_ = country ? this.metadata.countryCallingCode() : callingCode\r\n\t\t\t\treturn '+' + callingCode_ + nationalSignificantNumber\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an instance of `PhoneNumber` class.\r\n\t * Will return `undefined` if no national (significant) number\r\n\t * digits have been entered so far, or if no `defaultCountry` has been\r\n\t * set and the user enters a phone number not in international format.\r\n\t */\r\n\tgetNumber() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tcarrierCode,\r\n\t\t\tcallingCode\r\n\t\t} = this.state\r\n\r\n\t\t// `this._getCountry()` is basically same as `this.state.country`\r\n\t\t// with the only change that it return `undefined` in case of a\r\n\t\t// \"non-geographic\" numbering plan instead of `\"001\"` \"internal use\" value.\r\n\t\tlet country = this._getCountry()\r\n\r\n\t\tif (!nationalSignificantNumber) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t// For example, `country` could be `\"AR\"` and `callingCode` could be `undefined`.\r\n\t\t// So `country` and `callingCode` are totally independent.\r\n\r\n\t\tif (!country && !callingCode) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// By default, if `defaultCountry` parameter was passed when\r\n\t\t// creating `AsYouType` instance, `state.country` is gonna be\r\n\t\t// that `defaultCountry`, which doesn't entirely conform with\r\n\t\t// `parsePhoneNumber()`'s behavior where it attempts to determine\r\n\t\t// the country more precisely in cases when multiple countries\r\n\t\t// could correspond to the same `countryCallingCode`.\r\n\t\t// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/103#note_1417192969\r\n\t\t//\r\n\t\t// Because `AsYouType.getNumber()` method is supposed to be a 1:1\r\n\t\t// equivalent for `parsePhoneNumber(AsYouType.getNumberValue())`,\r\n\t\t// then it should also behave accordingly in cases of `country` ambiguity.\r\n\t\t// That's how users of this library would expect it to behave anyway.\r\n\t\t//\r\n\t\tif (country) {\r\n\t\t\tif (country === this.defaultCountry) {\r\n\t\t\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t\t\t// For example, `state.country` could be `\"AR\"` and `state.callingCode` could be `undefined`.\r\n\t\t\t\t// So `state.country` and `state.callingCode` are totally independent.\r\n\t\t\t\tconst metadata = new Metadata(this.metadata.metadata)\r\n\t\t\t\tmetadata.selectNumberingPlan(country)\r\n\t\t\t\tconst callingCode = metadata.numberingPlan.callingCode()\r\n\t\t\t\tconst ambiguousCountries = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\t\t\tif (ambiguousCountries.length > 1) {\r\n\t\t\t\t\tconst exactCountry = getCountryByNationalNumber(nationalSignificantNumber, {\r\n\t\t\t\t\t\tcountries: ambiguousCountries,\r\n\t\t\t\t\t\tmetadata: this.metadata.metadata\r\n\t\t\t\t\t})\r\n\t\t\t\t\tif (exactCountry) {\r\n\t\t\t\t\t\tcountry = exactCountry\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst phoneNumber = new PhoneNumber(\r\n\t\t\tcountry || callingCode,\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tthis.metadata.metadata\r\n\t\t)\r\n\t\tif (carrierCode) {\r\n\t\t\tphoneNumber.carrierCode = carrierCode\r\n\t\t}\r\n\t\t// Phone number extensions are not supported by \"As You Type\" formatter.\r\n\t\treturn phoneNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"possible\".\r\n\t * Is just a shortcut for `PhoneNumber.isPossible()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisPossible() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isPossible()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"valid\".\r\n\t * Is just a shortcut for `PhoneNumber.isValid()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisValid() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isValid()\r\n\t}\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * This method is used in `react-phone-number-input/source/input-control.js`\r\n\t * in versions before `3.0.16`.\r\n\t */\r\n\tgetNationalNumber() {\r\n\t\treturn this.state.nationalSignificantNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the phone number characters entered by the user.\r\n\t * @return {string}\r\n\t */\r\n\tgetChars() {\r\n\t\treturn (this.state.international ? '+' : '') + this.state.digits\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the template for the formatted phone number.\r\n\t * @return {string}\r\n\t */\r\n\tgetTemplate() {\r\n\t\treturn this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || ''\r\n\t}\r\n}"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,QAAQ,MAAM,eAAe;AACpC,OAAOC,WAAW,MAAM,kBAAkB;AAC1C,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,kBAAkB,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC/E,OAAOC,eAAe,IAAIC,6BAA6B,QAAQ,sBAAsB;AACrF,OAAOC,uBAAuB,MAAM,sCAAsC;AAC1E,OAAOC,0BAA0B,MAAM,yCAAyC;AAChF,OAAOC,QAAQ,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ength","AsYouTypeState","AsYouTypeFormatter","DIGIT_PLACEHOLDER","AsYouTypeParser","extractFormattedDigitsAndPlus","getCountryByCallingCode","getCountryByNationalNumber","isObject","USE_NON_GEOGRAPHIC_COUNTRY_CODE","AsYouType","optionsOrDefaultCountry","metadata","_classCallCheck","_this$getCountryAndCa","getCountryAndCallingCode","_this$getCountryAndCa2","_slicedToArray","defaultCountry","defaultCallingCode","reset","_createClass","key","value","hasCountry","undefined","isNonGeographicCallingCode","input","text","_this$parser$input","parser","state","digits","justLeadingPlus","formattedOutput","determineTheCountryIfNeeded","nationalSignificantNumber","formatter","narrowDownMatchingFormats","formattedNationalNumber","hasSelectedNumberingPlan","format","reExtractNationalSignificantNumber","nationalDigits","getNationalDigits","getFullNumber","getNonFormattedNumber","_this","onCountryChange","country","onCallingCodeChange","callingCode","selectNumberingPlan","numberingPlan","onNationalSignificantNumberChange","isInternational","international","getCallingCode","getCountryCallingCode","getCountry","_getCountry","isCountryCallingCodeAmbiguous","determineTheCountry","_this2","prefix","getInternationalPrefixBeforeCountryCallingCode","spacing","concat","getDigitsWithoutInternationalPrefix","getNonFormattedNationalNumberWithPrefix","_this$state","prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix","nationalPrefix","number","nationalSignificantNumberIsModified","getNonFormattedTemplate","replace","countryCodes","getCountryCodesForCallingCode","length","nationalNumber","setCountry","getNumberValue","_this$state2","callingCode_","countryCallingCode","getNumber","_this$state3","carrierCode","exactCountry","getExactCountryForMultiCountryCallingCode","phoneNumber","isPossible","isValid","validateLength","_this$state4","result","getNationalNumber","getChars","getTemplate","default","ambiguousCountries"],"sources":["../source/AsYouType.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport PhoneNumber from './PhoneNumber.js'\r\nimport checkNumberLength from './helpers/checkNumberLength.js'\r\nimport AsYouTypeState from './AsYouTypeState.js'\r\nimport AsYouTypeFormatter, { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.js'\r\nimport AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser.js'\r\nimport getCountryByCallingCode from './helpers/getCountryByCallingCode.js'\r\nimport getCountryByNationalNumber from './helpers/getCountryByNationalNumber.js'\r\nimport isObject from './helpers/isObject.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class AsYouType {\r\n\t/**\r\n\t * @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.\r\n\t * @param {Object} metadata\r\n\t */\r\n\tconstructor(optionsOrDefaultCountry, metadata) {\r\n\t\t// Metadata instance is created once and stays constant.\r\n\t\t// This is required because other utility classes such as `AsYouTypeFormatter`\r\n\t\t// will use this metadata instance \"reference\" and will assume that it stays constant.\r\n\t\tthis.metadata = new Metadata(metadata)\r\n\t\tconst [defaultCountry, defaultCallingCode] = this.getCountryAndCallingCode(optionsOrDefaultCountry)\r\n\t\t// `this.defaultCountry` and `this.defaultCallingCode` aren't required to be in sync.\r\n\t\t// For example, `this.defaultCountry` could be `\"AR\"` and `this.defaultCallingCode` could be `undefined`.\r\n\t\t// So `this.defaultCountry` and `this.defaultCallingCode` are totally independent.\r\n\t\tthis.defaultCountry = defaultCountry\r\n\t\tthis.defaultCallingCode = defaultCallingCode\r\n\t\tthis.reset()\r\n\t}\r\n\r\n\tgetCountryAndCallingCode(optionsOrDefaultCountry) {\r\n\t\t// Set `defaultCountry` and `defaultCallingCode` options.\r\n\t\tlet defaultCountry\r\n\t\tlet defaultCallingCode\r\n\t\t// Turns out `null` also has type \"object\". Weird.\r\n\t\tif (optionsOrDefaultCountry) {\r\n\t\t\tif (isObject(optionsOrDefaultCountry)) {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry.defaultCountry\r\n\t\t\t\tdefaultCallingCode = optionsOrDefaultCountry.defaultCallingCode\r\n\t\t\t} else {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (defaultCountry && !this.metadata.hasCountry(defaultCountry)) {\r\n\t\t\tdefaultCountry = undefined\r\n\t\t}\r\n\t\tif (defaultCallingCode) {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (this.metadata.isNonGeographicCallingCode(defaultCallingCode)) {\r\n\t\t\t\t\tdefaultCountry = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn [defaultCountry, defaultCallingCode]\r\n\t}\r\n\r\n\t/**\r\n\t * Inputs \"next\" phone number characters.\r\n\t * @param {string} text\r\n\t * @return {string} Formatted phone number characters that have been input so far.\r\n\t */\r\n\tinput(text) {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tjustLeadingPlus\r\n\t\t} = this.parser.input(text, this.state)\r\n\t\tif (justLeadingPlus) {\r\n\t\t\tthis.formattedOutput = '+'\r\n\t\t} else if (digits) {\r\n\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t// Match the available formats by the currently available leading digits.\r\n\t\t\tif (this.state.nationalSignificantNumber) {\r\n\t\t\t\tthis.formatter.narrowDownMatchingFormats(this.state)\r\n\t\t\t}\r\n\t\t\tlet formattedNationalNumber\r\n\t\t\tif (this.metadata.hasSelectedNumberingPlan()) {\r\n\t\t\t\tformattedNationalNumber = this.formatter.format(digits, this.state)\r\n\t\t\t}\r\n\t\t\tif (formattedNationalNumber === undefined) {\r\n\t\t\t\t// See if another national (significant) number could be re-extracted.\r\n\t\t\t\tif (this.parser.reExtractNationalSignificantNumber(this.state)) {\r\n\t\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\t\t// If it could, then re-try formatting the new national (significant) number.\r\n\t\t\t\t\tconst nationalDigits = this.state.getNationalDigits()\r\n\t\t\t\t\tif (nationalDigits) {\r\n\t\t\t\t\t\tformattedNationalNumber = this.formatter.format(nationalDigits, this.state)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.formattedOutput = formattedNationalNumber\r\n\t\t\t\t? this.getFullNumber(formattedNationalNumber)\r\n\t\t\t\t: this.getNonFormattedNumber()\r\n\t\t}\r\n\t\treturn this.formattedOutput\r\n\t}\r\n\r\n\treset() {\r\n\t\tthis.state = new AsYouTypeState({\r\n\t\t\tonCountryChange: (country) => {\r\n\t\t\t\t// Before version `1.6.0`, the official `AsYouType` formatter API\r\n\t\t\t\t// included a `.country` property on an `AsYouType` instance.\r\n\t\t\t\t// Since that property (along with the others) have been moved to\r\n\t\t\t\t// `this.state`, `this.country` property is emulated for compatibility\r\n\t\t\t\t// with the old versions.\r\n\t\t\t\tthis.country = country\r\n\t\t\t},\r\n\t\t\tonCallingCodeChange: (callingCode, country) => {\r\n\t\t\t\tthis.metadata.selectNumberingPlan(country || callingCode)\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t\tthis.parser.reset(this.metadata.numberingPlan)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.formatter = new AsYouTypeFormatter({\r\n\t\t\tstate: this.state,\r\n\t\t\tmetadata: this.metadata\r\n\t\t})\r\n\t\tthis.parser = new AsYouTypeParser({\r\n\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\tdefaultCallingCode: this.defaultCallingCode,\r\n\t\t\tmetadata: this.metadata,\r\n\t\t\tstate: this.state,\r\n\t\t\tonNationalSignificantNumberChange: () => {\r\n\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.state.reset({\r\n\t\t\tcountry: this.defaultCountry,\r\n\t\t\tcallingCode: this.defaultCallingCode\r\n\t\t})\r\n\t\tthis.formattedOutput = ''\r\n\t\treturn this\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is being input in international format.\r\n\t * In other words, returns `true` if and only if the parsed phone number starts with a `\"+\"`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisInternational() {\r\n\t\treturn this.state.international\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the \"calling code\" part of the phone number when it's being input\r\n\t * in an international format.\r\n\t * If no valid calling code has been entered so far, returns `undefined`.\r\n\t * @return {string} [callingCode]\r\n\t */\r\n\tgetCallingCode() {\r\n\t\t // If the number is being input in national format and some \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then `this.state.callingCode`\r\n\t\t // is equal to that \"default calling code\".\r\n\t\t //\r\n\t\t // If the number is being input in national format and no \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then returns `undefined`,\r\n\t\t // even if a \"default country\" has been passed to `AsYouType` constructor.\r\n\t\t //\r\n\t\tif (this.isInternational()) {\r\n\t\t\treturn this.state.callingCode\r\n\t\t}\r\n\t}\r\n\r\n\t// A legacy alias.\r\n\tgetCountryCallingCode() {\r\n\t\treturn this.getCallingCode()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * Returns `undefined` if no phone number has been input yet.\r\n\t * @return {string} [country]\r\n\t */\r\n\tgetCountry() {\r\n\t\tconst { digits } = this.state\r\n\t\t// Return `undefined` if no digits have been input yet.\r\n\t\tif (digits) {\r\n\t\t\treturn this._getCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * @return {string} [country]\r\n\t */\r\n\t_getCountry() {\r\n\t\tconst { country } = this.state\r\n\t\t/* istanbul ignore if */\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t// `AsYouType.getCountry()` returns `undefined`\r\n\t\t\t// for \"non-geographic\" phone numbering plans.\r\n\t\t\tif (country === '001') {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn country\r\n\t}\r\n\r\n\tdetermineTheCountryIfNeeded() {\r\n\t\t// Suppose a user enters a phone number in international format,\r\n\t\t// and there're several countries corresponding to that country calling code,\r\n\t\t// and a country has been derived from the number, and then\r\n\t\t// a user enters one more digit and the number is no longer\r\n\t\t// valid for the derived country, so the country should be re-derived\r\n\t\t// on every new digit in those cases.\r\n\t\t//\r\n\t\t// If the phone number is being input in national format,\r\n\t\t// then it could be a case when `defaultCountry` wasn't specified\r\n\t\t// when creating `AsYouType` instance, and just `defaultCallingCode` was specified,\r\n\t\t// and that \"calling code\" could correspond to a \"non-geographic entity\",\r\n\t\t// or there could be several countries corresponding to that country calling code.\r\n\t\t// In those cases, `this.country` is `undefined` and should be derived\r\n\t\t// from the number. Again, if country calling code is ambiguous, then\r\n\t\t// `this.country` should be re-derived with each new digit.\r\n\t\t//\r\n\t\tif (!this.state.country || this.isCountryCallingCodeAmbiguous()) {\r\n\t\t\tthis.determineTheCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t// Prepends `+CountryCode ` in case of an international phone number\r\n\tgetFullNumber(formattedNationalNumber) {\r\n\t\tif (this.isInternational()) {\r\n\t\t\tconst prefix = (text) => this.formatter.getInternationalPrefixBeforeCountryCallingCode(this.state, {\r\n\t\t\t\tspacing: text ? true : false\r\n\t\t\t}) + text\r\n\t\t\tconst { callingCode } = this.state\r\n\t\t\tif (!callingCode) {\r\n\t\t\t\treturn prefix(`${this.state.getDigitsWithoutInternationalPrefix()}`)\r\n\t\t\t}\r\n\t\t\tif (!formattedNationalNumber) {\r\n\t\t\t\treturn prefix(callingCode)\r\n\t\t\t}\r\n\t\t\treturn prefix(`${callingCode} ${formattedNationalNumber}`)\r\n\t\t}\r\n\t\treturn formattedNationalNumber\r\n\t}\r\n\r\n\tgetNonFormattedNationalNumberWithPrefix() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tprefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,\r\n\t\t\tnationalPrefix\r\n\t\t} = this.state\r\n\t\tlet number = nationalSignificantNumber\r\n\t\tconst prefix = prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix || nationalPrefix\r\n\t\tif (prefix) {\r\n\t\t\tnumber = prefix + number\r\n\t\t}\r\n\t\treturn number\r\n\t}\r\n\r\n\tgetNonFormattedNumber() {\r\n\t\tconst { nationalSignificantNumberIsModified } = this.state\r\n\t\treturn this.getFullNumber(\r\n\t\t\tnationalSignificantNumberIsModified\r\n\t\t\t\t? this.state.getNationalDigits()\r\n\t\t\t\t: this.getNonFormattedNationalNumberWithPrefix()\r\n\t\t)\r\n\t}\r\n\r\n\tgetNonFormattedTemplate() {\r\n\t\tconst number = this.getNonFormattedNumber()\r\n\t\tif (number) {\r\n\t\t\treturn number.replace(/[\\+\\d]/g, DIGIT_PLACEHOLDER)\r\n\t\t}\r\n\t}\r\n\r\n\tisCountryCallingCodeAmbiguous() {\r\n\t\tconst { callingCode } = this.state\r\n\t\tconst countryCodes = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\treturn countryCodes && countryCodes.length > 1\r\n\t}\r\n\r\n\t// Determines the exact country of the phone number\r\n\t// entered so far based on the country phone code\r\n\t// and the national phone number.\r\n\tdetermineTheCountry() {\r\n\t\t// Get a more precise country code for this national number.\r\n\t\t// It is possible that the precise country couldn't be determined\r\n\t\t// in cases when there're multiple countries sharing the same calling code.\r\n\t\t// In that case, `country` will be `undefined`.\r\n\t\tconst country = getCountryByCallingCode(\r\n\t\t\tthis.isInternational() ? this.state.callingCode : this.defaultCallingCode,\r\n\t\t\t{\r\n\t\t\t\tnationalNumber: this.state.nationalSignificantNumber,\r\n\t\t\t\tmetadata: this.metadata\r\n\t\t\t}\r\n\t\t)\r\n\t\t// If the derived country is indeed more precise,\r\n\t\t// or if no country could be derived for the updated phone number.\r\n\t\tif (country !== this.state.country) {\r\n\t\t\t// Set (or reset) the more precise country.\r\n\t\t\tthis.state.setCountry(country)\r\n\t\t\t// If a more precise country could be derived.\r\n\t\t\tif (country) {\r\n\t\t\t\t// Select a more precise telephone numbering plan.\r\n\t\t\t\t// For example, consider that `AsYouType` instance was created with `defaultCountry: \"US\"` argument.\r\n\t\t\t\t// In that case, the metadata instance will be using \"US\" metadata.\r\n\t\t\t\t// But then the user could input a Canadian phone number, in which case\r\n\t\t\t\t// the metadata instance should be switched to Canadian telephone numbering plan.\r\n\t\t\t\t// It is required to do that because later `canFormatCompleteNumber()` function will be called,\r\n\t\t\t\t// and that function relies on the precise country being pre-selected in the metadata instance.\r\n\t\t\t\t// Or, for example, `checkNumberLength()` function also relies on same thing.\r\n\t\t\t\tthis.metadata.selectNumberingPlan(country)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a E.164 phone number value for the user's input.\r\n\t *\r\n\t * For example, for country `\"US\"` and input `\"(222) 333-4444\"`\r\n\t * it will return `\"+12223334444\"`.\r\n\t *\r\n\t * For international phone number input, it will also auto-correct\r\n\t * some minor errors such as using a national prefix when writing\r\n\t * an international phone number. For example, if the user inputs\r\n\t * `\"+44 0 7400 000000\"` then it will return an auto-corrected\r\n\t * `\"+447400000000\"` phone number value.\r\n\t *\r\n\t * Will return `undefined` if no digits have been input,\r\n\t * or when inputting a phone number in national format and no\r\n\t * default country or default \"country calling code\" have been set.\r\n\t *\r\n\t * @return {string} [value]\r\n\t */\r\n\tgetNumberValue() {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tcallingCode,\r\n\t\t\tcountry,\r\n\t\t\tnationalSignificantNumber\r\n\t\t} = this.state\r\n\r\n\t \t// Will return `undefined` if no digits have been input.\r\n\t\tif (!digits) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (this.isInternational()) {\r\n\t\t\tif (callingCode) {\r\n\t\t\t\treturn '+' + callingCode + nationalSignificantNumber\r\n\t\t\t} else {\r\n\t\t\t\treturn '+' + digits\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (country || callingCode) {\r\n\t\t\t\tconst callingCode_ = country ? this.metadata.countryCallingCode() : callingCode\r\n\t\t\t\treturn '+' + callingCode_ + nationalSignificantNumber\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an instance of `PhoneNumber` class.\r\n\t * Will return `undefined` if no national (significant) number\r\n\t * digits have been entered so far, or if no `defaultCountry` has been\r\n\t * set and the user enters a phone number not in international format.\r\n\t */\r\n\tgetNumber() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tcarrierCode,\r\n\t\t\tcallingCode\r\n\t\t} = this.state\r\n\r\n\t\tif (!nationalSignificantNumber) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// `this._getCountry()` is basically same as `this.state.country`\r\n\t\t// with the only change that it returns `undefined` in case of a\r\n\t\t// \"non-geographic\" numbering plan instead of `\"001\"` \"internal use\" value.\r\n\t\tlet country = this._getCountry()\r\n\r\n\t\t// Sidenote:\r\n\t\t// `state.callingCode` and `state.country` are somewhat independent from one another\r\n\t\t// and there could be situations when one is defined but the other is not.\r\n\t\t// See the comment in `AsYouTypeState.js` for more info on when that is possible.\r\n\r\n\t\tif (!country && !callingCode) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// By default, if `defaultCountry` parameter was passed when\r\n\t\t// creating `AsYouType` instance, `state.country` is gonna be\r\n\t\t// that `defaultCountry`, which doesn't entirely conform with\r\n\t\t// `parsePhoneNumber()`'s behavior where it attempts to determine\r\n\t\t// the country more precisely in cases when multiple countries\r\n\t\t// could correspond to the same `countryCallingCode`.\r\n\t\t// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/103#note_1417192969\r\n\t\t//\r\n\t\t// Because `AsYouType.getNumber()` method is supposed to be a 1:1\r\n\t\t// equivalent for `parsePhoneNumber(AsYouType.getNumberValue())`,\r\n\t\t// it means that it should also behave accordingly in such cases of `country` ambiguity.\r\n\t\t// That's how users of this library would expect it to behave anyway.\r\n\t\t//\r\n\t\t// So here it checks if `state.country` is same as the `defaultCountry`,\r\n\t\t// and if it is, it attempts to get rid of any potential ambiguity.\r\n\t\t//\r\n\t\tif (country) {\r\n\t\t\tif (country === this.defaultCountry) {\r\n\t\t\t\t// // Create a `Metadata` instance just to get the calling code of the `country`.\r\n\t\t\t\t// const metadata = new Metadata(this.metadata.metadata)\r\n\t\t\t\t// // `state.callingCode` and `state.country` are somewhat independent from one another\r\n\t\t\t\t// // and there could be situations when one is defined but the other is not.\r\n\t\t\t\t// // See the comment in `AsYouTypeState.js` for more info on when that is possible.\r\n\t\t\t\t// // Here, it only passes `state.country` because there's no need to pass `state.callingCode`\r\n\t\t\t\t// // because `state.country` is known to be defined.\r\n\t\t\t\t// metadata.selectNumberingPlan(country)\r\n\t\t\t\t// const countryCallingCode = metadata.numberingPlan.callingCode()\r\n\r\n\t\t\t\t// Instead of getting `countryCallingCode` value above,\r\n\t\t\t\t// it could simply read it from the existing metadata instance.\r\n\t\t\t\tconst countryCallingCode = this.metadata.numberingPlan.callingCode()\r\n\r\n\t\t\t\t// Attempt to rule out any potential country code ambiguity, if present.\r\n\t\t\t\tconst exactCountry = getExactCountryForMultiCountryCallingCode(\r\n\t\t\t\t\tcountryCallingCode,\r\n\t\t\t\t\tnationalSignificantNumber,\r\n\t\t\t\t\tthis.metadata\r\n\t\t\t\t)\r\n\t\t\t\tif (exactCountry) {\r\n\t\t\t\t\tcountry = exactCountry\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst phoneNumber = new PhoneNumber(\r\n\t\t\tcountry || callingCode,\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tthis.metadata.metadata\r\n\t\t)\r\n\t\tif (carrierCode) {\r\n\t\t\tphoneNumber.carrierCode = carrierCode\r\n\t\t}\r\n\t\t// Phone number extensions are not supported by \"As You Type\" formatter.\r\n\t\treturn phoneNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"possible\".\r\n\t * Is just a shortcut for `PhoneNumber.isPossible()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisPossible() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isPossible()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"valid\".\r\n\t * Is just a shortcut for `PhoneNumber.isValid()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisValid() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isValid()\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the phone number length is valid.\r\n\t * If it is, nothing is returned.\r\n\t * Otherwise, a rejection reason is returned.\r\n\t * @return {string?}\r\n\t */\r\n\tvalidateLength() {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tnationalSignificantNumber\r\n\t\t} = this.state\r\n\r\n\t\tif (!digits) {\r\n\t\t\treturn 'NOT_A_NUMBER'\r\n\t\t}\r\n\r\n\t\tif (!this.metadata.numberingPlan) {\r\n\t\t\treturn 'INVALID_COUNTRY'\r\n\t\t}\r\n\r\n\t\tif (!nationalSignificantNumber) {\r\n\t\t\t return 'TOO_SHORT'\r\n\t\t}\r\n\r\n\t\t// `state.callingCode` and `state.country` are somewhat independent from one another\r\n\t\t// and there could be situations when one is defined but the other is not.\r\n\t\t// See the comment in `AsYouTypeState.js` for more info on when that is possible.\r\n\t\t// Here, it uses both: if `country` is defined then it will use that,\r\n\t\t// otherwise it will use `callingCode`.\r\n\t\tconst result = checkNumberLength(nationalSignificantNumber, undefined, this.metadata)\r\n\t\tif (result !== 'IS_POSSIBLE') {\r\n\t\t\treturn result\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * This method is used in `react-phone-number-input/source/input-control.js`\r\n\t * in versions before `3.0.16`.\r\n\t */\r\n\tgetNationalNumber() {\r\n\t\treturn this.state.nationalSignificantNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the phone number characters entered by the user.\r\n\t * @return {string}\r\n\t */\r\n\tgetChars() {\r\n\t\treturn (this.state.international ? '+' : '') + this.state.digits\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the template for the formatted phone number.\r\n\t * @return {string}\r\n\t */\r\n\tgetTemplate() {\r\n\t\treturn this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || ''\r\n\t}\r\n}\r\n\r\n// In situations when multiple countries use the same calling code,\r\n// this function tells what exact country does a given national (significant) number belong to.\r\nfunction getExactCountryForMultiCountryCallingCode(callingCode, nationalSignificantNumber, metadata) {\r\n\tconst ambiguousCountries = metadata.getCountryCodesForCallingCode(callingCode)\r\n\tif (ambiguousCountries.length > 1) {\r\n\t\treturn getCountryByNationalNumber(nationalSignificantNumber, ambiguousCountries, metadata.metadata)\r\n\t}\r\n}"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,QAAQ,MAAM,eAAe;AACpC,OAAOC,WAAW,MAAM,kBAAkB;AAC1C,OAAOC,iBAAiB,MAAM,gCAAgC;AAC9D,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,kBAAkB,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC/E,OAAOC,eAAe,IAAIC,6BAA6B,QAAQ,sBAAsB;AACrF,OAAOC,uBAAuB,MAAM,sCAAsC;AAC1E,OAAOC,0BAA0B,MAAM,yCAAyC;AAChF,OAAOC,QAAQ,MAAM,uBAAuB;AAE5C,IAAMC,+BAA+B,GAAG,KAAK;AAAA,IAExBC,SAAS;EAC7B;AACD;AACA;AACA;EACC,SAAAA,UAAYC,uBAAuB,EAAEC,QAAQ,EAAE;IAAAC,eAAA,OAAAH,SAAA;IAC9C;IACA;IACA;IACA,IAAI,CAACE,QAAQ,GAAG,IAAId,QAAQ,CAACc,QAAQ,CAAC;IACtC,IAAAE,qBAAA,GAA6C,IAAI,CAACC,wBAAwB,CAACJ,uBAAuB,CAAC;MAAAK,sBAA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