@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
@@ -0,0 +1,473 @@
1
+ import f from "./tools/semver-compare.js";
2
+ import l from "./helpers/isObject.js";
3
+ function a(n) {
4
+ "@babel/helpers - typeof";
5
+ return a = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
6
+ return typeof t;
7
+ } : function(t) {
8
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
9
+ }, a(n);
10
+ }
11
+ function o(n, t) {
12
+ if (!(n instanceof t)) throw new TypeError("Cannot call a class as a function");
13
+ }
14
+ function y(n, t) {
15
+ for (var e = 0; e < t.length; e++) {
16
+ var i = t[e];
17
+ i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(n, v(i.key), i);
18
+ }
19
+ }
20
+ function u(n, t, e) {
21
+ return t && y(n.prototype, t), Object.defineProperty(n, "prototype", { writable: !1 }), n;
22
+ }
23
+ function v(n) {
24
+ var t = P(n, "string");
25
+ return a(t) == "symbol" ? t : t + "";
26
+ }
27
+ function P(n, t) {
28
+ if (a(n) != "object" || !n) return n;
29
+ var e = n[Symbol.toPrimitive];
30
+ if (e !== void 0) {
31
+ var i = e.call(n, t);
32
+ if (a(i) != "object") return i;
33
+ throw new TypeError("@@toPrimitive must return a primitive value.");
34
+ }
35
+ return String(n);
36
+ }
37
+ var d = "1.2.0", p = "1.7.35", h = " ext. ", C = /^\d+$/, b = /* @__PURE__ */ function() {
38
+ function n(t) {
39
+ o(this, n), _(t), this.metadata = t, m.call(this, t);
40
+ }
41
+ return u(n, [{
42
+ key: "getCountries",
43
+ value: function() {
44
+ return Object.keys(this.metadata.countries).filter(function(e) {
45
+ return e !== "001";
46
+ });
47
+ }
48
+ }, {
49
+ key: "getCountryMetadata",
50
+ value: function(e) {
51
+ return this.metadata.countries[e];
52
+ }
53
+ }, {
54
+ key: "nonGeographic",
55
+ value: function() {
56
+ if (!(this.v1 || this.v2 || this.v3))
57
+ return this.metadata.nonGeographic || this.metadata.nonGeographical;
58
+ }
59
+ }, {
60
+ key: "hasCountry",
61
+ value: function(e) {
62
+ return this.getCountryMetadata(e) !== void 0;
63
+ }
64
+ }, {
65
+ key: "hasCallingCode",
66
+ value: function(e) {
67
+ if (this.getCountryCodesForCallingCode(e))
68
+ return !0;
69
+ if (this.nonGeographic()) {
70
+ if (this.nonGeographic()[e])
71
+ return !0;
72
+ } else {
73
+ var i = this.countryCallingCodes()[e];
74
+ if (i && i.length === 1 && i[0] === "001")
75
+ return !0;
76
+ }
77
+ }
78
+ }, {
79
+ key: "isNonGeographicCallingCode",
80
+ value: function(e) {
81
+ return this.nonGeographic() ? !!this.nonGeographic()[e] : !this.getCountryCodesForCallingCode(e);
82
+ }
83
+ // Deprecated.
84
+ }, {
85
+ key: "country",
86
+ value: function(e) {
87
+ return this.selectNumberingPlan(e);
88
+ }
89
+ }, {
90
+ key: "selectNumberingPlan",
91
+ value: function(e, i) {
92
+ if (e && C.test(e) && (i = e, e = null), e && e !== "001") {
93
+ if (!this.hasCountry(e))
94
+ throw new Error("Unknown country: ".concat(e));
95
+ this.numberingPlan = new g(this.getCountryMetadata(e), this);
96
+ } else if (i) {
97
+ if (!this.hasCallingCode(i))
98
+ throw new Error("Unknown calling code: ".concat(i));
99
+ this.numberingPlan = new g(this.getNumberingPlanMetadata(i), this);
100
+ } else
101
+ this.numberingPlan = void 0;
102
+ return this;
103
+ }
104
+ }, {
105
+ key: "getCountryCodesForCallingCode",
106
+ value: function(e) {
107
+ var i = this.countryCallingCodes()[e];
108
+ if (i)
109
+ return i.length === 1 && i[0].length === 3 ? void 0 : i;
110
+ }
111
+ }, {
112
+ key: "getCountryCodeForCallingCode",
113
+ value: function(e) {
114
+ var i = this.getCountryCodesForCallingCode(e);
115
+ if (i)
116
+ return i[0];
117
+ }
118
+ }, {
119
+ key: "getNumberingPlanMetadata",
120
+ value: function(e) {
121
+ var i = this.getCountryCodeForCallingCode(e);
122
+ if (i)
123
+ return this.getCountryMetadata(i);
124
+ if (this.nonGeographic()) {
125
+ var r = this.nonGeographic()[e];
126
+ if (r)
127
+ return r;
128
+ } else {
129
+ var s = this.countryCallingCodes()[e];
130
+ if (s && s.length === 1 && s[0] === "001")
131
+ return this.metadata.countries["001"];
132
+ }
133
+ }
134
+ // Deprecated.
135
+ }, {
136
+ key: "countryCallingCode",
137
+ value: function() {
138
+ return this.numberingPlan.callingCode();
139
+ }
140
+ // Deprecated.
141
+ }, {
142
+ key: "IDDPrefix",
143
+ value: function() {
144
+ return this.numberingPlan.IDDPrefix();
145
+ }
146
+ // Deprecated.
147
+ }, {
148
+ key: "defaultIDDPrefix",
149
+ value: function() {
150
+ return this.numberingPlan.defaultIDDPrefix();
151
+ }
152
+ // Deprecated.
153
+ }, {
154
+ key: "nationalNumberPattern",
155
+ value: function() {
156
+ return this.numberingPlan.nationalNumberPattern();
157
+ }
158
+ // Deprecated.
159
+ }, {
160
+ key: "possibleLengths",
161
+ value: function() {
162
+ return this.numberingPlan.possibleLengths();
163
+ }
164
+ // Deprecated.
165
+ }, {
166
+ key: "formats",
167
+ value: function() {
168
+ return this.numberingPlan.formats();
169
+ }
170
+ // Deprecated.
171
+ }, {
172
+ key: "nationalPrefixForParsing",
173
+ value: function() {
174
+ return this.numberingPlan.nationalPrefixForParsing();
175
+ }
176
+ // Deprecated.
177
+ }, {
178
+ key: "nationalPrefixTransformRule",
179
+ value: function() {
180
+ return this.numberingPlan.nationalPrefixTransformRule();
181
+ }
182
+ // Deprecated.
183
+ }, {
184
+ key: "leadingDigits",
185
+ value: function() {
186
+ return this.numberingPlan.leadingDigits();
187
+ }
188
+ // Deprecated.
189
+ }, {
190
+ key: "hasTypes",
191
+ value: function() {
192
+ return this.numberingPlan.hasTypes();
193
+ }
194
+ // Deprecated.
195
+ }, {
196
+ key: "type",
197
+ value: function(e) {
198
+ return this.numberingPlan.type(e);
199
+ }
200
+ // Deprecated.
201
+ }, {
202
+ key: "ext",
203
+ value: function() {
204
+ return this.numberingPlan.ext();
205
+ }
206
+ }, {
207
+ key: "countryCallingCodes",
208
+ value: function() {
209
+ return this.v1 ? this.metadata.country_phone_code_to_countries : this.metadata.country_calling_codes;
210
+ }
211
+ // Deprecated.
212
+ }, {
213
+ key: "chooseCountryByCountryCallingCode",
214
+ value: function(e) {
215
+ return this.selectNumberingPlan(e);
216
+ }
217
+ }, {
218
+ key: "hasSelectedNumberingPlan",
219
+ value: function() {
220
+ return this.numberingPlan !== void 0;
221
+ }
222
+ }]);
223
+ }(), g = /* @__PURE__ */ function() {
224
+ function n(t, e) {
225
+ o(this, n), this.globalMetadataObject = e, this.metadata = t, m.call(this, e.metadata);
226
+ }
227
+ return u(n, [{
228
+ key: "callingCode",
229
+ value: function() {
230
+ return this.metadata[0];
231
+ }
232
+ // Formatting information for regions which share
233
+ // a country calling code is contained by only one region
234
+ // for performance reasons. For example, for NANPA region
235
+ // ("North American Numbering Plan Administration",
236
+ // which includes USA, Canada, Cayman Islands, Bahamas, etc)
237
+ // it will be contained in the metadata for `US`.
238
+ }, {
239
+ key: "getDefaultCountryMetadataForRegion",
240
+ value: function() {
241
+ return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
242
+ }
243
+ // Is always present.
244
+ }, {
245
+ key: "IDDPrefix",
246
+ value: function() {
247
+ if (!(this.v1 || this.v2))
248
+ return this.metadata[1];
249
+ }
250
+ // Is only present when a country supports multiple IDD prefixes.
251
+ }, {
252
+ key: "defaultIDDPrefix",
253
+ value: function() {
254
+ if (!(this.v1 || this.v2))
255
+ return this.metadata[12];
256
+ }
257
+ }, {
258
+ key: "nationalNumberPattern",
259
+ value: function() {
260
+ return this.v1 || this.v2 ? this.metadata[1] : this.metadata[2];
261
+ }
262
+ // "possible length" data is always present in Google's metadata.
263
+ }, {
264
+ key: "possibleLengths",
265
+ value: function() {
266
+ if (!this.v1)
267
+ return this.metadata[this.v2 ? 2 : 3];
268
+ }
269
+ }, {
270
+ key: "_getFormats",
271
+ value: function(e) {
272
+ return e[this.v1 ? 2 : this.v2 ? 3 : 4];
273
+ }
274
+ // For countries of the same region (e.g. NANPA)
275
+ // formats are all stored in the "main" country for that region.
276
+ // E.g. "RU" and "KZ", "US" and "CA".
277
+ }, {
278
+ key: "formats",
279
+ value: function() {
280
+ var e = this, i = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
281
+ return i.map(function(r) {
282
+ return new F(r, e);
283
+ });
284
+ }
285
+ }, {
286
+ key: "nationalPrefix",
287
+ value: function() {
288
+ return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
289
+ }
290
+ }, {
291
+ key: "_getNationalPrefixFormattingRule",
292
+ value: function(e) {
293
+ return e[this.v1 ? 4 : this.v2 ? 5 : 6];
294
+ }
295
+ // For countries of the same region (e.g. NANPA)
296
+ // national prefix formatting rule is stored in the "main" country for that region.
297
+ // E.g. "RU" and "KZ", "US" and "CA".
298
+ }, {
299
+ key: "nationalPrefixFormattingRule",
300
+ value: function() {
301
+ return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion());
302
+ }
303
+ }, {
304
+ key: "_nationalPrefixForParsing",
305
+ value: function() {
306
+ return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
307
+ }
308
+ }, {
309
+ key: "nationalPrefixForParsing",
310
+ value: function() {
311
+ return this._nationalPrefixForParsing() || this.nationalPrefix();
312
+ }
313
+ }, {
314
+ key: "nationalPrefixTransformRule",
315
+ value: function() {
316
+ return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
317
+ }
318
+ }, {
319
+ key: "_getNationalPrefixIsOptionalWhenFormatting",
320
+ value: function() {
321
+ return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
322
+ }
323
+ // For countries of the same region (e.g. NANPA)
324
+ // "national prefix is optional when formatting" flag is
325
+ // stored in the "main" country for that region.
326
+ // E.g. "RU" and "KZ", "US" and "CA".
327
+ }, {
328
+ key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
329
+ value: function() {
330
+ return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion());
331
+ }
332
+ }, {
333
+ key: "leadingDigits",
334
+ value: function() {
335
+ return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
336
+ }
337
+ }, {
338
+ key: "types",
339
+ value: function() {
340
+ return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
341
+ }
342
+ }, {
343
+ key: "hasTypes",
344
+ value: function() {
345
+ return this.types() && this.types().length === 0 ? !1 : !!this.types();
346
+ }
347
+ }, {
348
+ key: "type",
349
+ value: function(e) {
350
+ if (this.hasTypes() && c(this.types(), e))
351
+ return new x(c(this.types(), e), this);
352
+ }
353
+ }, {
354
+ key: "ext",
355
+ value: function() {
356
+ return this.v1 || this.v2 ? h : this.metadata[13] || h;
357
+ }
358
+ }]);
359
+ }(), F = /* @__PURE__ */ function() {
360
+ function n(t, e) {
361
+ o(this, n), this._format = t, this.metadata = e;
362
+ }
363
+ return u(n, [{
364
+ key: "pattern",
365
+ value: function() {
366
+ return this._format[0];
367
+ }
368
+ }, {
369
+ key: "format",
370
+ value: function() {
371
+ return this._format[1];
372
+ }
373
+ }, {
374
+ key: "leadingDigitsPatterns",
375
+ value: function() {
376
+ return this._format[2] || [];
377
+ }
378
+ }, {
379
+ key: "nationalPrefixFormattingRule",
380
+ value: function() {
381
+ return this._format[3] || this.metadata.nationalPrefixFormattingRule();
382
+ }
383
+ }, {
384
+ key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
385
+ value: function() {
386
+ return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
387
+ }
388
+ }, {
389
+ key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
390
+ value: function() {
391
+ return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
392
+ }
393
+ // Checks whether national prefix formatting rule contains national prefix.
394
+ }, {
395
+ key: "usesNationalPrefix",
396
+ value: function() {
397
+ return !!(this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
398
+ !k.test(this.nationalPrefixFormattingRule()));
399
+ }
400
+ }, {
401
+ key: "internationalFormat",
402
+ value: function() {
403
+ return this._format[5] || this.format();
404
+ }
405
+ }]);
406
+ }(), k = /^\(?\$1\)?$/, x = /* @__PURE__ */ function() {
407
+ function n(t, e) {
408
+ o(this, n), this.type = t, this.metadata = e;
409
+ }
410
+ return u(n, [{
411
+ key: "pattern",
412
+ value: function() {
413
+ return this.metadata.v1 ? this.type : this.type[0];
414
+ }
415
+ }, {
416
+ key: "possibleLengths",
417
+ value: function() {
418
+ if (!this.metadata.v1)
419
+ return this.type[1] || this.metadata.possibleLengths();
420
+ }
421
+ }]);
422
+ }();
423
+ function c(n, t) {
424
+ switch (t) {
425
+ case "FIXED_LINE":
426
+ return n[0];
427
+ case "MOBILE":
428
+ return n[1];
429
+ case "TOLL_FREE":
430
+ return n[2];
431
+ case "PREMIUM_RATE":
432
+ return n[3];
433
+ case "PERSONAL_NUMBER":
434
+ return n[4];
435
+ case "VOICEMAIL":
436
+ return n[5];
437
+ case "UAN":
438
+ return n[6];
439
+ case "PAGER":
440
+ return n[7];
441
+ case "VOIP":
442
+ return n[8];
443
+ case "SHARED_COST":
444
+ return n[9];
445
+ }
446
+ }
447
+ function _(n) {
448
+ if (!n)
449
+ throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");
450
+ if (!l(n) || !l(n.countries))
451
+ throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(l(n) ? "an object of shape: { " + Object.keys(n).join(", ") + " }" : "a " + N(n) + ": " + n, "."));
452
+ }
453
+ var N = function(t) {
454
+ return a(t);
455
+ };
456
+ function R(n, t) {
457
+ if (t = new b(t), t.hasCountry(n))
458
+ return t.selectNumberingPlan(n).countryCallingCode();
459
+ throw new Error("Unknown country: ".concat(n));
460
+ }
461
+ function O(n, t) {
462
+ return t.countries.hasOwnProperty(n);
463
+ }
464
+ function m(n) {
465
+ var t = n.version;
466
+ typeof t == "number" ? (this.v1 = t === 1, this.v2 = t === 2, this.v3 = t === 3, this.v4 = t === 4) : t ? f(t, d) === -1 ? this.v2 = !0 : f(t, p) === -1 ? this.v3 = !0 : this.v4 = !0 : this.v1 = !0;
467
+ }
468
+ export {
469
+ b as default,
470
+ R as getCountryCallingCode,
471
+ O as isSupportedCountry,
472
+ _ as validateMetadata
473
+ };
@@ -0,0 +1,108 @@
1
+ import b from "./helpers/isObject.js";
2
+ function f(r) {
3
+ "@babel/helpers - typeof";
4
+ return f = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
5
+ return typeof t;
6
+ } : function(t) {
7
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
8
+ }, f(r);
9
+ }
10
+ function y(r, t) {
11
+ var e = Object.keys(r);
12
+ if (Object.getOwnPropertySymbols) {
13
+ var n = Object.getOwnPropertySymbols(r);
14
+ t && (n = n.filter(function(o) {
15
+ return Object.getOwnPropertyDescriptor(r, o).enumerable;
16
+ })), e.push.apply(e, n);
17
+ }
18
+ return e;
19
+ }
20
+ function m(r) {
21
+ for (var t = 1; t < arguments.length; t++) {
22
+ var e = arguments[t] != null ? arguments[t] : {};
23
+ t % 2 ? y(Object(e), !0).forEach(function(n) {
24
+ g(r, n, e[n]);
25
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : y(Object(e)).forEach(function(n) {
26
+ Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
27
+ });
28
+ }
29
+ return r;
30
+ }
31
+ function g(r, t, e) {
32
+ return (t = v(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
33
+ }
34
+ function v(r) {
35
+ var t = d(r, "string");
36
+ return f(t) == "symbol" ? t : t + "";
37
+ }
38
+ function d(r, t) {
39
+ if (f(r) != "object" || !r) return r;
40
+ var e = r[Symbol.toPrimitive];
41
+ if (e !== void 0) {
42
+ var n = e.call(r, t);
43
+ if (f(n) != "object") return n;
44
+ throw new TypeError("@@toPrimitive must return a primitive value.");
45
+ }
46
+ return (t === "string" ? String : Number)(r);
47
+ }
48
+ function O(r, t) {
49
+ return _(r) || w(r, t) || h(r, t) || j();
50
+ }
51
+ function j() {
52
+ throw new TypeError(`Invalid attempt to destructure non-iterable instance.
53
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
54
+ }
55
+ function h(r, t) {
56
+ if (r) {
57
+ if (typeof r == "string") return s(r, t);
58
+ var e = {}.toString.call(r).slice(8, -1);
59
+ return e === "Object" && r.constructor && (e = r.constructor.name), e === "Map" || e === "Set" ? Array.from(r) : e === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e) ? s(r, t) : void 0;
60
+ }
61
+ }
62
+ function s(r, t) {
63
+ (t == null || t > r.length) && (t = r.length);
64
+ for (var e = 0, n = Array(t); e < t; e++) n[e] = r[e];
65
+ return n;
66
+ }
67
+ function w(r, t) {
68
+ var e = r == null ? null : typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"];
69
+ if (e != null) {
70
+ var n, o, u, l, c = [], i = !0, a = !1;
71
+ try {
72
+ if (u = (e = e.call(r)).next, t !== 0) for (; !(i = (n = u.call(e)).done) && (c.push(n.value), c.length !== t); i = !0) ;
73
+ } catch (p) {
74
+ a = !0, o = p;
75
+ } finally {
76
+ try {
77
+ if (!i && e.return != null && (l = e.return(), Object(l) !== l)) return;
78
+ } finally {
79
+ if (a) throw o;
80
+ }
81
+ }
82
+ return c;
83
+ }
84
+ }
85
+ function _(r) {
86
+ if (Array.isArray(r)) return r;
87
+ }
88
+ function S(r) {
89
+ var t = Array.prototype.slice.call(r), e = O(t, 4), n = e[0], o = e[1], u = e[2], l = e[3], c, i, a;
90
+ if (typeof n == "string")
91
+ c = n;
92
+ else throw new TypeError("A text for parsing must be a string.");
93
+ if (!o || typeof o == "string")
94
+ l ? (i = u, a = l) : (i = void 0, a = u), o && (i = m({
95
+ defaultCountry: o
96
+ }, i));
97
+ else if (b(o))
98
+ u ? (i = o, a = u) : a = o;
99
+ else throw new Error("Invalid second argument: ".concat(o));
100
+ return {
101
+ text: c,
102
+ options: i,
103
+ metadata: a
104
+ };
105
+ }
106
+ export {
107
+ S as default
108
+ };
@@ -0,0 +1,119 @@
1
+ import { MIN_LENGTH_FOR_NSN as g, MAX_LENGTH_FOR_NSN as h, PLUS_CHARS as P, VALID_DIGITS as d } from "./constants.js";
2
+ import m from "./ParseError.js";
3
+ import T, { getCountryCallingCode as O } from "./metadata.js";
4
+ import s, { isViablePhoneNumberStart as v } from "./helpers/isViablePhoneNumber.js";
5
+ import w from "./helpers/extension/extractExtension.js";
6
+ import y from "./parseIncompletePhoneNumber.js";
7
+ import { isPossibleNumber as S } from "./isPossible.js";
8
+ import x from "./PhoneNumber.js";
9
+ import R from "./helpers/matchesEntirely.js";
10
+ import E from "./helpers/extractCountryCallingCode.js";
11
+ import I from "./helpers/extractNationalNumber.js";
12
+ import A from "./helpers/getCountryByCallingCode.js";
13
+ import p from "./helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js";
14
+ var H = 250, L = new RegExp("[" + P + d + "]"), U = new RegExp("[^" + d + "#]+$");
15
+ function Z(t, r, n) {
16
+ if (r = r || {}, n = new T(n), r.defaultCountry && !n.hasCountry(r.defaultCountry))
17
+ throw r.v2 ? new m("INVALID_COUNTRY") : new Error("Unknown country: ".concat(r.defaultCountry));
18
+ var e = G(t, r.v2, r.extract), l = e.number, c = e.ext, i = e.error;
19
+ if (!l) {
20
+ if (r.v2)
21
+ throw i === "TOO_SHORT" ? new m("TOO_SHORT") : new m("NOT_A_NUMBER");
22
+ return {};
23
+ }
24
+ var a = D(l, r.defaultCountry, r.defaultCallingCode, n), o = a.country, u = a.nationalNumber, N = a.countryCallingCode, _ = a.countryCallingCodeSource, f = a.carrierCode;
25
+ if (!n.hasSelectedNumberingPlan()) {
26
+ if (r.v2)
27
+ throw new m("INVALID_COUNTRY");
28
+ return {};
29
+ }
30
+ if (!u || u.length < g) {
31
+ if (r.v2)
32
+ throw new m("TOO_SHORT");
33
+ return {};
34
+ }
35
+ if (u.length > h) {
36
+ if (r.v2)
37
+ throw new m("TOO_LONG");
38
+ return {};
39
+ }
40
+ if (r.v2) {
41
+ var C = new x(N, u, n.metadata);
42
+ return o && (C.country = o), f && (C.carrierCode = f), c && (C.ext = c), C.__countryCallingCodeSource = _, C;
43
+ }
44
+ var b = (r.extended ? n.hasSelectedNumberingPlan() : o) ? R(u, n.nationalNumberPattern()) : !1;
45
+ return r.extended ? {
46
+ country: o,
47
+ countryCallingCode: N,
48
+ carrierCode: f,
49
+ valid: b,
50
+ possible: b ? !0 : !!(r.extended === !0 && n.possibleLengths() && S(u, o, n)),
51
+ phone: u,
52
+ ext: c
53
+ } : b ? M(o, u, c) : {};
54
+ }
55
+ function F(t, r, n) {
56
+ if (t) {
57
+ if (t.length > H) {
58
+ if (n)
59
+ throw new m("TOO_LONG");
60
+ return;
61
+ }
62
+ if (r === !1)
63
+ return t;
64
+ var e = t.search(L);
65
+ if (!(e < 0))
66
+ return t.slice(e).replace(U, "");
67
+ }
68
+ }
69
+ function G(t, r, n) {
70
+ var e = p(t, {
71
+ extractFormattedPhoneNumber: function(i) {
72
+ return F(i, n, r);
73
+ }
74
+ });
75
+ if (!e)
76
+ return {};
77
+ if (!s(e))
78
+ return v(e) ? {
79
+ error: "TOO_SHORT"
80
+ } : {};
81
+ var l = w(e);
82
+ return l.ext ? l : {
83
+ number: e
84
+ };
85
+ }
86
+ function M(t, r, n) {
87
+ var e = {
88
+ country: t,
89
+ phone: r
90
+ };
91
+ return n && (e.ext = n), e;
92
+ }
93
+ function D(t, r, n, e) {
94
+ var l = E(y(t), void 0, r, n, e.metadata), c = l.countryCallingCodeSource, i = l.countryCallingCode, a = l.number, o;
95
+ if (i)
96
+ e.selectNumberingPlan(i);
97
+ else if (a && (r || n))
98
+ e.selectNumberingPlan(r, n), r && (o = r), i = n || O(r, e.metadata);
99
+ else return {};
100
+ if (!a)
101
+ return {
102
+ countryCallingCodeSource: c,
103
+ countryCallingCode: i
104
+ };
105
+ var u = I(y(a), o, e), N = u.nationalNumber, _ = u.carrierCode, f = A(i, {
106
+ nationalNumber: N,
107
+ metadata: e
108
+ });
109
+ return f && (o = f, f === "001" || e.selectNumberingPlan(o)), {
110
+ country: o,
111
+ countryCallingCode: i,
112
+ countryCallingCodeSource: c,
113
+ nationalNumber: N,
114
+ carrierCode: _
115
+ };
116
+ }
117
+ export {
118
+ Z as default
119
+ };