@ticketmaster/tm-global-address 0.3.0 → 0.5.0

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 (70) hide show
  1. package/dist/components/AddressForm/AddressForm.js +174 -192
  2. package/dist/data/countries.d.ts +18 -0
  3. package/dist/data/countries.js +261 -0
  4. package/dist/data/countryConfig.d.ts +9 -0
  5. package/dist/data/countryConfig.js +87 -0
  6. package/dist/data/countryData.d.ts +7 -9
  7. package/dist/data/countryData.js +25 -542
  8. package/dist/data/index.d.ts +22 -0
  9. package/dist/data/postalPatterns.d.ts +22 -0
  10. package/dist/data/postalPatterns.js +183 -0
  11. package/dist/data/states.d.ts +15 -0
  12. package/dist/data/states.js +1405 -0
  13. package/dist/index.d.ts +12 -1
  14. package/dist/index.js +38 -15
  15. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/ParseError.js +89 -0
  16. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/PhoneNumber.js +188 -0
  17. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/constants.js +10 -0
  18. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/format.js +92 -0
  19. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/RFC3966.js +11 -0
  20. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +7 -0
  21. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +16 -0
  22. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +11 -0
  23. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js +18 -0
  24. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +47 -0
  25. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +22 -0
  26. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +23 -0
  27. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +39 -0
  28. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +31 -0
  29. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js +23 -0
  30. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +25 -0
  31. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +12 -0
  32. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +45 -0
  33. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js +12 -0
  34. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/getNumberType.js +51 -0
  35. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +14 -0
  36. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/isObject.js +7 -0
  37. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +20 -0
  38. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +6 -0
  39. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/parseDigits.js +79 -0
  40. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js +19 -0
  41. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/isPossible.js +38 -0
  42. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/isValid.js +12 -0
  43. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/metadata.js +473 -0
  44. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/normalizeArguments.js +108 -0
  45. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/parse.js +119 -0
  46. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +40 -0
  47. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/parsePhoneNumber.js +9 -0
  48. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js +55 -0
  49. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js +62 -0
  50. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/es6/tools/semver-compare.js +14 -0
  51. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/max/exports/parsePhoneNumber.js +8 -0
  52. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/max/exports/withMetadataArgument.js +8 -0
  53. package/dist/node_modules/.pnpm/libphonenumber-js@1.12.41/node_modules/libphonenumber-js/metadata.max.json.js +4 -0
  54. package/dist/validation/constants.d.ts +2 -0
  55. package/dist/validation/constants.js +152 -0
  56. package/dist/validation/index.d.ts +15 -0
  57. package/dist/validation/sanitize.d.ts +13 -0
  58. package/dist/validation/sanitize.js +6 -0
  59. package/dist/validation/types.d.ts +46 -0
  60. package/dist/validation/validateForm.d.ts +7 -0
  61. package/dist/validation/validateForm.js +22 -0
  62. package/dist/validation/validatePhoneNumber.d.ts +3 -0
  63. package/dist/validation/validatePhoneNumber.js +17 -0
  64. package/dist/validation/validatePostalCode.d.ts +3 -0
  65. package/dist/validation/validatePostalCode.js +22 -0
  66. package/dist/validation/validateState.d.ts +3 -0
  67. package/dist/validation/validateState.js +23 -0
  68. package/dist/validation/validateTextField.d.ts +2 -0
  69. package/dist/validation/validateTextField.js +36 -0
  70. package/package.json +4 -1
package/dist/index.d.ts CHANGED
@@ -10,6 +10,17 @@ export type { AddressListProps } from './components/AddressList/AddressList';
10
10
  export type { AddressData, SaveAddressPayload, ActionResult, ActionSuccess, ActionFailure, ActionError, FieldError, } from './types/AddressData';
11
11
  export type { CountryValidationConfig, CountryOption, SubdivisionOption, } from './types/CountryConfig';
12
12
  export type { GlobalAddressProps } from './types/GlobalAddressProps';
13
- export { COUNTRY_OPTIONS, SUBDIVISIONS, COUNTRY_CONFIGS, getCountryConfig, getSubdivisions, getCountryName, } from './data/countryData';
13
+ export type { CountryRecord } from './data/countries';
14
+ export { COUNTRIES, getCountryByCode } from './data/countries';
15
+ export type { SubdivisionRecord } from './data/states';
16
+ export { SUBDIVISIONS, getSubdivisions } from './data/states';
17
+ export type { PostalPattern } from './data/postalPatterns';
18
+ export { POSTAL_PATTERNS, getPostalPattern } from './data/postalPatterns';
19
+ export { STATE_REQUIRED_CODES } from './data/countryConfig';
20
+ export { COUNTRY_OPTIONS, COUNTRY_CONFIGS, getCountryConfig, getCountryName, } from './data/countryData';
21
+ export type { ValidationErrorCode, ValidationError, FieldValidationResult, FormValidationResult, CharacterPattern, FieldConstraint, } from './validation/types';
22
+ export { FIELD_CONSTRAINTS } from './validation/constants';
23
+ export { sanitize, validateTextField, validatePostalCode, validateState, validatePhoneNumber, validateForm, } from './validation/index';
24
+ export type { ValidateFormOptions } from './validation/index';
14
25
  export { HelloWorld } from './components/HelloWorld/HelloWorld';
15
26
  export type { HelloWorldProps } from './components/HelloWorld/HelloWorld';
package/dist/index.js CHANGED
@@ -1,22 +1,45 @@
1
1
  import { GlobalAddress as e } from "./components/GlobalAddress/GlobalAddress.js";
2
- import { AddressForm as s } from "./components/AddressForm/AddressForm.js";
3
- import { AddressCard as t, formatAddressSummary as f } from "./components/AddressCard/AddressCard.js";
2
+ import { AddressForm as m } from "./components/AddressForm/AddressForm.js";
3
+ import { AddressCard as a, formatAddressSummary as f } from "./components/AddressCard/AddressCard.js";
4
4
  import { AddressSummary as p } from "./components/AddressSummary/AddressSummary.js";
5
- import { AddressList as C } from "./components/AddressList/AddressList.js";
6
- import { COUNTRY_CONFIGS as A, COUNTRY_OPTIONS as N, SUBDIVISIONS as O, getCountryConfig as i, getCountryName as l, getSubdivisions as u } from "./data/countryData.js";
7
- import { HelloWorld as g } from "./components/HelloWorld/HelloWorld.js";
5
+ import { AddressList as S } from "./components/AddressList/AddressList.js";
6
+ import { COUNTRIES as l, getCountryByCode as C } from "./data/countries.js";
7
+ import { SUBDIVISIONS as N, getSubdivisions as A } from "./data/states.js";
8
+ import { POSTAL_PATTERNS as I, getPostalPattern as n } from "./data/postalPatterns.js";
9
+ import { STATE_REQUIRED_CODES as E } from "./data/countryConfig.js";
10
+ import { COUNTRY_CONFIGS as R, COUNTRY_OPTIONS as g, getCountryConfig as v, getCountryName as y } from "./data/countryData.js";
11
+ import { FIELD_CONSTRAINTS as F } from "./validation/constants.js";
12
+ import { HelloWorld as D } from "./components/HelloWorld/HelloWorld.js";
13
+ import { sanitize as L } from "./validation/sanitize.js";
14
+ import { validateForm as G } from "./validation/validateForm.js";
15
+ import { validatePhoneNumber as h } from "./validation/validatePhoneNumber.js";
16
+ import { validatePostalCode as H } from "./validation/validatePostalCode.js";
17
+ import { validateState as V } from "./validation/validateState.js";
18
+ import { validateTextField as c } from "./validation/validateTextField.js";
8
19
  export {
9
- t as AddressCard,
10
- s as AddressForm,
11
- C as AddressList,
20
+ a as AddressCard,
21
+ m as AddressForm,
22
+ S as AddressList,
12
23
  p as AddressSummary,
13
- A as COUNTRY_CONFIGS,
14
- N as COUNTRY_OPTIONS,
24
+ l as COUNTRIES,
25
+ R as COUNTRY_CONFIGS,
26
+ g as COUNTRY_OPTIONS,
27
+ F as FIELD_CONSTRAINTS,
15
28
  e as GlobalAddress,
16
- g as HelloWorld,
17
- O as SUBDIVISIONS,
29
+ D as HelloWorld,
30
+ I as POSTAL_PATTERNS,
31
+ E as STATE_REQUIRED_CODES,
32
+ N as SUBDIVISIONS,
18
33
  f as formatAddressSummary,
19
- i as getCountryConfig,
20
- l as getCountryName,
21
- u as getSubdivisions
34
+ C as getCountryByCode,
35
+ v as getCountryConfig,
36
+ y as getCountryName,
37
+ n as getPostalPattern,
38
+ A as getSubdivisions,
39
+ L as sanitize,
40
+ G as validateForm,
41
+ h as validatePhoneNumber,
42
+ H as validatePostalCode,
43
+ V as validateState,
44
+ c as validateTextField
22
45
  };
@@ -0,0 +1,89 @@
1
+ function i(r) {
2
+ "@babel/helpers - typeof";
3
+ return i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
4
+ return typeof t;
5
+ } : function(t) {
6
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
7
+ }, i(r);
8
+ }
9
+ function a(r, t, n) {
10
+ return Object.defineProperty(r, "prototype", { writable: !1 }), r;
11
+ }
12
+ function s(r, t) {
13
+ if (!(r instanceof t)) throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ function l(r, t, n) {
16
+ return t = c(t), y(r, p() ? Reflect.construct(t, n || [], c(r).constructor) : t.apply(r, n));
17
+ }
18
+ function y(r, t) {
19
+ if (t && (i(t) == "object" || typeof t == "function")) return t;
20
+ if (t !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
21
+ return b(r);
22
+ }
23
+ function b(r) {
24
+ if (r === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
25
+ return r;
26
+ }
27
+ function _(r, t) {
28
+ if (typeof t != "function" && t !== null) throw new TypeError("Super expression must either be null or a function");
29
+ r.prototype = Object.create(t && t.prototype, { constructor: { value: r, writable: !0, configurable: !0 } }), Object.defineProperty(r, "prototype", { writable: !1 }), t && u(r, t);
30
+ }
31
+ function f(r) {
32
+ var t = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
33
+ return f = function(e) {
34
+ if (e === null || !v(e)) return e;
35
+ if (typeof e != "function") throw new TypeError("Super expression must either be null or a function");
36
+ if (t !== void 0) {
37
+ if (t.has(e)) return t.get(e);
38
+ t.set(e, o);
39
+ }
40
+ function o() {
41
+ return h(e, arguments, c(this).constructor);
42
+ }
43
+ return o.prototype = Object.create(e.prototype, { constructor: { value: o, enumerable: !1, writable: !0, configurable: !0 } }), u(o, e);
44
+ }, f(r);
45
+ }
46
+ function h(r, t, n) {
47
+ if (p()) return Reflect.construct.apply(null, arguments);
48
+ var e = [null];
49
+ e.push.apply(e, t);
50
+ var o = new (r.bind.apply(r, e))();
51
+ return n && u(o, n.prototype), o;
52
+ }
53
+ function p() {
54
+ try {
55
+ var r = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
56
+ }));
57
+ } catch {
58
+ }
59
+ return (p = function() {
60
+ return !!r;
61
+ })();
62
+ }
63
+ function v(r) {
64
+ try {
65
+ return Function.toString.call(r).indexOf("[native code]") !== -1;
66
+ } catch {
67
+ return typeof r == "function";
68
+ }
69
+ }
70
+ function u(r, t) {
71
+ return u = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, e) {
72
+ return n.__proto__ = e, n;
73
+ }, u(r, t);
74
+ }
75
+ function c(r) {
76
+ return c = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
77
+ return t.__proto__ || Object.getPrototypeOf(t);
78
+ }, c(r);
79
+ }
80
+ var O = /* @__PURE__ */ function(r) {
81
+ function t(n) {
82
+ var e;
83
+ return s(this, t), e = l(this, t, [n]), Object.setPrototypeOf(e, t.prototype), e.name = e.constructor.name, e;
84
+ }
85
+ return _(t, r), a(t);
86
+ }(/* @__PURE__ */ f(Error));
87
+ export {
88
+ O as default
89
+ };
@@ -0,0 +1,188 @@
1
+ import l, { validateMetadata as h } from "./metadata.js";
2
+ import d from "./isPossible.js";
3
+ import v from "./isValid.js";
4
+ import w from "./helpers/getNumberType.js";
5
+ import P from "./helpers/getPossibleCountriesForNumber.js";
6
+ import C from "./helpers/extractCountryCallingCode.js";
7
+ import s from "./helpers/isObject.js";
8
+ import E from "./format.js";
9
+ function o(r) {
10
+ "@babel/helpers - typeof";
11
+ return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
12
+ return typeof t;
13
+ } : function(t) {
14
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
15
+ }, o(r);
16
+ }
17
+ function f(r, t) {
18
+ var e = Object.keys(r);
19
+ if (Object.getOwnPropertySymbols) {
20
+ var n = Object.getOwnPropertySymbols(r);
21
+ t && (n = n.filter(function(i) {
22
+ return Object.getOwnPropertyDescriptor(r, i).enumerable;
23
+ })), e.push.apply(e, n);
24
+ }
25
+ return e;
26
+ }
27
+ function c(r) {
28
+ for (var t = 1; t < arguments.length; t++) {
29
+ var e = arguments[t] != null ? arguments[t] : {};
30
+ t % 2 ? f(Object(e), !0).forEach(function(n) {
31
+ j(r, n, e[n]);
32
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : f(Object(e)).forEach(function(n) {
33
+ Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
34
+ });
35
+ }
36
+ return r;
37
+ }
38
+ function j(r, t, e) {
39
+ return (t = y(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
40
+ }
41
+ function O(r, t) {
42
+ if (!(r instanceof t)) throw new TypeError("Cannot call a class as a function");
43
+ }
44
+ function k(r, t) {
45
+ for (var e = 0; e < t.length; e++) {
46
+ var n = t[e];
47
+ n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(r, y(n.key), n);
48
+ }
49
+ }
50
+ function N(r, t, e) {
51
+ return t && k(r.prototype, t), Object.defineProperty(r, "prototype", { writable: !1 }), r;
52
+ }
53
+ function y(r) {
54
+ var t = T(r, "string");
55
+ return o(t) == "symbol" ? t : t + "";
56
+ }
57
+ function T(r, t) {
58
+ if (o(r) != "object" || !r) return r;
59
+ var e = r[Symbol.toPrimitive];
60
+ if (e !== void 0) {
61
+ var n = e.call(r, t);
62
+ if (o(n) != "object") return n;
63
+ throw new TypeError("@@toPrimitive must return a primitive value.");
64
+ }
65
+ return String(r);
66
+ }
67
+ var U = /* @__PURE__ */ function() {
68
+ function r(t, e, n) {
69
+ if (O(this, r), !t)
70
+ throw new TypeError("First argument is required");
71
+ if (typeof t != "string")
72
+ throw new TypeError("First argument must be a string");
73
+ if (t[0] === "+" && !e)
74
+ throw new TypeError("`metadata` argument not passed");
75
+ if (s(e) && s(e.countries)) {
76
+ n = e;
77
+ var i = t;
78
+ if (!_.test(i))
79
+ throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');
80
+ var u = C(i, void 0, void 0, void 0, n), m = u.countryCallingCode, p = u.number;
81
+ if (e = p, t = m, !e)
82
+ throw new Error("Invalid `number` argument passed: too short");
83
+ }
84
+ if (!e)
85
+ throw new TypeError("`nationalNumber` argument is required");
86
+ if (typeof e != "string")
87
+ throw new TypeError("`nationalNumber` argument must be a string");
88
+ h(n);
89
+ var a = S(t, n), b = a.country, g = a.countryCallingCode;
90
+ this.country = b, this.countryCallingCode = g, this.nationalNumber = e, this.number = "+" + this.countryCallingCode + this.nationalNumber, this.getMetadata = function() {
91
+ return n;
92
+ };
93
+ }
94
+ return N(r, [{
95
+ key: "setExt",
96
+ value: function(e) {
97
+ this.ext = e;
98
+ }
99
+ }, {
100
+ key: "getPossibleCountries",
101
+ value: function() {
102
+ return this.country ? [this.country] : P(this.countryCallingCode, this.nationalNumber, this.getMetadata());
103
+ }
104
+ }, {
105
+ key: "isPossible",
106
+ value: function() {
107
+ return d(this, {
108
+ v2: !0
109
+ }, this.getMetadata());
110
+ }
111
+ }, {
112
+ key: "isValid",
113
+ value: function() {
114
+ return v(this, {
115
+ v2: !0
116
+ }, this.getMetadata());
117
+ }
118
+ }, {
119
+ key: "isNonGeographic",
120
+ value: function() {
121
+ var e = new l(this.getMetadata());
122
+ return e.isNonGeographicCallingCode(this.countryCallingCode);
123
+ }
124
+ }, {
125
+ key: "isEqual",
126
+ value: function(e) {
127
+ return this.number === e.number && this.ext === e.ext;
128
+ }
129
+ // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
130
+ // but later it was found out that it doesn't include the possible `TOO_SHORT` result
131
+ // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
132
+ // so eventually I simply commented out this method from the `PhoneNumber` class
133
+ // and just left the `validatePhoneNumberLength()` function, even though that one would require
134
+ // and additional step to also validate the actual country / calling code of the phone number.
135
+ // validateLength() {
136
+ // const metadata = new Metadata(this.getMetadata())
137
+ // metadata.selectNumberingPlan(this.countryCallingCode)
138
+ // const result = checkNumberLength(this.nationalNumber, metadata)
139
+ // if (result !== 'IS_POSSIBLE') {
140
+ // return result
141
+ // }
142
+ // }
143
+ }, {
144
+ key: "getType",
145
+ value: function() {
146
+ return w(this, {
147
+ v2: !0
148
+ }, this.getMetadata());
149
+ }
150
+ }, {
151
+ key: "format",
152
+ value: function(e, n) {
153
+ return E(this, e, n ? c(c({}, n), {}, {
154
+ v2: !0
155
+ }) : {
156
+ v2: !0
157
+ }, this.getMetadata());
158
+ }
159
+ }, {
160
+ key: "formatNational",
161
+ value: function(e) {
162
+ return this.format("NATIONAL", e);
163
+ }
164
+ }, {
165
+ key: "formatInternational",
166
+ value: function(e) {
167
+ return this.format("INTERNATIONAL", e);
168
+ }
169
+ }, {
170
+ key: "getURI",
171
+ value: function(e) {
172
+ return this.format("RFC3966", e);
173
+ }
174
+ }]);
175
+ }(), M = function(t) {
176
+ return /^[A-Z]{2}$/.test(t);
177
+ };
178
+ function S(r, t) {
179
+ var e, n, i = new l(t);
180
+ return M(r) ? (e = r, i.selectNumberingPlan(e), n = i.countryCallingCode()) : n = r, {
181
+ country: e,
182
+ countryCallingCode: n
183
+ };
184
+ }
185
+ var _ = /^\+\d+$/;
186
+ export {
187
+ U as default
188
+ };
@@ -0,0 +1,10 @@
1
+ var v = 2, A = 17, E = 3, _ = "0-90-9٠-٩۰-۹", F = "-‐-―−ー-", u = "//", a = "..", S = "  ­​⁠ ", r = "()()[]\\[\\]", c = "~⁓∼~", N = "".concat(F).concat(u).concat(a).concat(S).concat(r).concat(c), T = "++";
2
+ export {
3
+ E as MAX_LENGTH_COUNTRY_CODE,
4
+ A as MAX_LENGTH_FOR_NSN,
5
+ v as MIN_LENGTH_FOR_NSN,
6
+ T as PLUS_CHARS,
7
+ _ as VALID_DIGITS,
8
+ N as VALID_PUNCTUATION,
9
+ S as WHITESPACE
10
+ };
@@ -0,0 +1,92 @@
1
+ import N from "./helpers/matchesEntirely.js";
2
+ import g from "./helpers/formatNationalNumberUsingFormat.js";
3
+ import m, { getCountryCallingCode as s } from "./metadata.js";
4
+ import h from "./helpers/getIddPrefix.js";
5
+ import { formatRFC3966 as I } from "./helpers/RFC3966.js";
6
+ var l = {
7
+ formatExtension: function(t, r, e) {
8
+ return "".concat(t).concat(e.ext()).concat(r);
9
+ }
10
+ };
11
+ function O(n, t, r, e) {
12
+ if (r ? r = E({}, l, r) : r = l, e = new m(e), n.country && n.country !== "001") {
13
+ if (!e.hasCountry(n.country))
14
+ throw new Error("Unknown country: ".concat(n.country));
15
+ e.selectNumberingPlan(n.country);
16
+ } else if (n.countryCallingCode)
17
+ e.selectNumberingPlan(n.countryCallingCode);
18
+ else return n.phone || "";
19
+ var o = e.countryCallingCode(), a = r.v2 ? n.nationalNumber : n.phone, c;
20
+ switch (t) {
21
+ case "NATIONAL":
22
+ return a ? (c = f(a, n.carrierCode, "NATIONAL", e, r), u(c, n.ext, e, r.formatExtension)) : "";
23
+ case "INTERNATIONAL":
24
+ return a ? (c = f(a, null, "INTERNATIONAL", e, r), c = "+".concat(o, " ").concat(c), u(c, n.ext, e, r.formatExtension)) : "+".concat(o);
25
+ case "E.164":
26
+ return "+".concat(o).concat(a);
27
+ case "RFC3966":
28
+ return I({
29
+ number: "+".concat(o).concat(a),
30
+ ext: n.ext
31
+ });
32
+ case "IDD":
33
+ if (!r.fromCountry)
34
+ return;
35
+ var i = A(a, n.carrierCode, o, r.fromCountry, e);
36
+ return i ? u(i, n.ext, e, r.formatExtension) : void 0;
37
+ default:
38
+ throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t, '"'));
39
+ }
40
+ }
41
+ function f(n, t, r, e, o) {
42
+ var a = x(e.formats(), n);
43
+ return a ? g(n, a, {
44
+ useInternationalFormat: r === "INTERNATIONAL",
45
+ withNationalPrefix: !(a.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && o && o.nationalPrefix === !1)
46
+ }) : n;
47
+ }
48
+ function x(n, t) {
49
+ return v(n, function(r) {
50
+ if (r.leadingDigitsPatterns().length > 0) {
51
+ var e = r.leadingDigitsPatterns()[r.leadingDigitsPatterns().length - 1];
52
+ if (t.search(e) !== 0)
53
+ return !1;
54
+ }
55
+ return N(t, r.pattern());
56
+ });
57
+ }
58
+ function u(n, t, r, e) {
59
+ return t ? e(n, t, r) : n;
60
+ }
61
+ function A(n, t, r, e, o) {
62
+ var a = s(e, o.metadata);
63
+ if (a === r) {
64
+ var c = f(n, t, "NATIONAL", o);
65
+ return r === "1" ? r + " " + c : c;
66
+ }
67
+ var i = h(e, void 0, o.metadata);
68
+ if (i)
69
+ return "".concat(i, " ").concat(r, " ").concat(f(n, null, "INTERNATIONAL", o));
70
+ }
71
+ function E() {
72
+ for (var n = 1, t = arguments.length, r = new Array(t), e = 0; e < t; e++)
73
+ r[e] = arguments[e];
74
+ for (; n < r.length; ) {
75
+ if (r[n])
76
+ for (var o in r[n])
77
+ r[0][o] = r[n][o];
78
+ n++;
79
+ }
80
+ return r[0];
81
+ }
82
+ function v(n, t) {
83
+ for (var r = 0; r < n.length; ) {
84
+ if (t(n[r]))
85
+ return n[r];
86
+ r++;
87
+ }
88
+ }
89
+ export {
90
+ x as chooseFormatForNumber,
91
+ O as default
92
+ };
@@ -0,0 +1,11 @@
1
+ function n(r) {
2
+ var t = r.number, e = r.ext;
3
+ if (!t)
4
+ return "";
5
+ if (t[0] !== "+")
6
+ throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');
7
+ return "tel:".concat(t).concat(e ? ";ext=" + e : "");
8
+ }
9
+ export {
10
+ n as formatRFC3966
11
+ };
@@ -0,0 +1,7 @@
1
+ import { VALID_PUNCTUATION as e } from "../constants.js";
2
+ function a(t) {
3
+ return t.replace(new RegExp("[".concat(e, "]+"), "g"), " ").trim();
4
+ }
5
+ export {
6
+ a as default
7
+ };
@@ -0,0 +1,16 @@
1
+ import h from "../metadata.js";
2
+ function L(i, r, u) {
3
+ return s(i, r, void 0, u);
4
+ }
5
+ function s(i, r, u, e) {
6
+ r && (e = new h(e.metadata), e.selectNumberingPlan(r));
7
+ var f = e.type(u), n = f && f.possibleLengths() || e.possibleLengths();
8
+ if (!n)
9
+ return "IS_POSSIBLE";
10
+ var t = i.length, l = n[0];
11
+ return l === t ? "IS_POSSIBLE" : l > t ? "TOO_SHORT" : n[n.length - 1] < t ? "TOO_LONG" : n.indexOf(t, 1) >= 0 ? "IS_POSSIBLE" : "INVALID_LENGTH";
12
+ }
13
+ export {
14
+ s as checkNumberLengthForType,
15
+ L as default
16
+ };
@@ -0,0 +1,11 @@
1
+ import { VALID_DIGITS as A } from "../../constants.js";
2
+ var g = ";ext=", t = function(a) {
3
+ return "([".concat(A, "]{1,").concat(a, "})");
4
+ };
5
+ function D(x) {
6
+ var a = "20", o = "15", i = "9", F = "6", n = "[  \\t,]*", e = "[:\\..]?[  \\t,-]*", r = "#?", s = "(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)", E = "(?:[xx##~~]|int|int)", l = "[- ]+", u = "[  \\t]*", v = "(?:,{2}|;)", b = g + t(a), m = n + s + e + t(a) + r, p = n + E + e + t(i) + r, L = l + t(F) + "#", f = u + v + e + t(o) + r, c = u + "(?:,)+" + e + t(i) + r;
7
+ return b + "|" + m + "|" + p + "|" + L + "|" + f + "|" + c;
8
+ }
9
+ export {
10
+ D as default
11
+ };
@@ -0,0 +1,18 @@
1
+ import o from "./createExtensionPattern.js";
2
+ var n = new RegExp("(?:" + o() + ")$", "i");
3
+ function c(e) {
4
+ var a = e.search(n);
5
+ if (a < 0)
6
+ return {};
7
+ for (var i = e.slice(0, a), r = e.match(n), t = 1; t < r.length; ) {
8
+ if (r[t])
9
+ return {
10
+ number: i,
11
+ ext: r[t]
12
+ };
13
+ t++;
14
+ }
15
+ }
16
+ export {
17
+ c as default
18
+ };
@@ -0,0 +1,47 @@
1
+ import M from "./stripIddPrefix.js";
2
+ import I from "./extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js";
3
+ import R from "../metadata.js";
4
+ import { MAX_LENGTH_COUNTRY_CODE as S } from "../constants.js";
5
+ function O(r, s, e, f, i) {
6
+ if (!r)
7
+ return {};
8
+ var l;
9
+ if (r[0] !== "+") {
10
+ var n = M(r, e, f, i);
11
+ if (n && n !== r)
12
+ l = !0, r = "+" + n;
13
+ else {
14
+ if (e || f) {
15
+ var N = I(r, s, e, f, i), c = N.countryCallingCode, t = N.number;
16
+ if (c)
17
+ return {
18
+ countryCallingCodeSource: "FROM_NUMBER_WITHOUT_PLUS_SIGN",
19
+ countryCallingCode: c,
20
+ number: t
21
+ };
22
+ }
23
+ return {
24
+ // No need to set it to `UNSPECIFIED`. It can be just `undefined`.
25
+ // countryCallingCodeSource: 'UNSPECIFIED',
26
+ number: r
27
+ };
28
+ }
29
+ }
30
+ if (r[1] === "0")
31
+ return {};
32
+ i = new R(i);
33
+ for (var o = 2; o - 1 <= S && o <= r.length; ) {
34
+ var _ = r.slice(1, o);
35
+ if (i.hasCallingCode(_))
36
+ return i.selectNumberingPlan(_), {
37
+ countryCallingCodeSource: l ? "FROM_NUMBER_WITH_IDD" : "FROM_NUMBER_WITH_PLUS_SIGN",
38
+ countryCallingCode: _,
39
+ number: r.slice(o)
40
+ };
41
+ o++;
42
+ }
43
+ return {};
44
+ }
45
+ export {
46
+ O as default
47
+ };
@@ -0,0 +1,22 @@
1
+ import m, { getCountryCallingCode as b } from "../metadata.js";
2
+ import g from "./matchesEntirely.js";
3
+ import u from "./extractNationalNumber.js";
4
+ import h from "./checkNumberLength.js";
5
+ function P(r, o, e, c, n) {
6
+ var i = e ? b(e, n) : c;
7
+ if (r.indexOf(i) === 0) {
8
+ n = new m(n), n.selectNumberingPlan(e, i);
9
+ var l = r.slice(i.length), C = u(l, o, n), N = C.nationalNumber, f = u(r, o, n), t = f.nationalNumber;
10
+ if (!g(t, n.nationalNumberPattern()) && g(N, n.nationalNumberPattern()) || h(t, o, n) === "TOO_LONG")
11
+ return {
12
+ countryCallingCode: i,
13
+ number: l
14
+ };
15
+ }
16
+ return {
17
+ number: r
18
+ };
19
+ }
20
+ export {
21
+ P as default
22
+ };
@@ -0,0 +1,23 @@
1
+ import s, { isPhoneContextValid as x, PLUS_SIGN as F, RFC3966_PREFIX_ as a, RFC3966_PHONE_CONTEXT_ as d, RFC3966_ISDN_SUBADDRESS_ as m } from "./extractPhoneContext.js";
2
+ import v from "../ParseError.js";
3
+ function S(r, _) {
4
+ var f = _.extractFormattedPhoneNumber, e = s(r);
5
+ if (!x(e))
6
+ throw new v("NOT_A_NUMBER");
7
+ var t;
8
+ if (e === null)
9
+ t = f(r) || "";
10
+ else {
11
+ t = "", e.charAt(0) === F && (t += e);
12
+ var n = r.indexOf(a), o;
13
+ n >= 0 ? o = n + a.length : o = 0;
14
+ var h = r.indexOf(d);
15
+ t += r.substring(o, h);
16
+ }
17
+ var i = t.indexOf(m);
18
+ if (i > 0 && (t = t.substring(0, i)), t !== "")
19
+ return t;
20
+ }
21
+ export {
22
+ S as default
23
+ };
@@ -0,0 +1,39 @@
1
+ import l from "./extractNationalNumberFromPossiblyIncompleteNumber.js";
2
+ import o from "./matchesEntirely.js";
3
+ import u from "./checkNumberLength.js";
4
+ import N from "./getCountryByCallingCode.js";
5
+ function g(e, n, r) {
6
+ var i = l(e, r), a = i.carrierCode, t = i.nationalNumber;
7
+ if (t !== e) {
8
+ if (!m(e, t, r))
9
+ return {
10
+ nationalNumber: e
11
+ };
12
+ if (r.numberingPlan.possibleLengths() && (n || (n = N(r.numberingPlan.callingCode(), {
13
+ nationalNumber: t,
14
+ metadata: r
15
+ })), !f(t, n, r)))
16
+ return {
17
+ nationalNumber: e
18
+ };
19
+ }
20
+ return {
21
+ nationalNumber: t,
22
+ carrierCode: a
23
+ };
24
+ }
25
+ function m(e, n, r) {
26
+ return !(o(e, r.nationalNumberPattern()) && !o(n, r.nationalNumberPattern()));
27
+ }
28
+ function f(e, n, r) {
29
+ switch (u(e, n, r)) {
30
+ case "TOO_SHORT":
31
+ case "INVALID_LENGTH":
32
+ return !1;
33
+ default:
34
+ return !0;
35
+ }
36
+ }
37
+ export {
38
+ g as default
39
+ };