@jay-framework/wix-bookings 0.26.1 → 0.26.4
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/dist/index.client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { makeJayInit, makeJayStackComponent } from "@jay-framework/fullstack-component";
|
|
2
2
|
import { createJayContext, useGlobalContext, registerGlobalContext } from "@jay-framework/runtime";
|
|
3
3
|
import { wixFetch, WixApiError, WIX_CLIENT_CONTEXT, ensureSessionFresh } from "@jay-framework/wix-server-client/client";
|
|
4
|
-
import {
|
|
4
|
+
import { registerReactiveGlobalContext, createSignal, useReactive } from "@jay-framework/component";
|
|
5
5
|
import { createActionCaller } from "@jay-framework/stack-client-runtime";
|
|
6
6
|
const MAX_SLOTS_PER_QUERY = 200;
|
|
7
7
|
const SERVICES_PAGE_SIZE = 100;
|
|
@@ -10,7 +10,7 @@ async function queryBookingServices(client, bookingAppId) {
|
|
|
10
10
|
let offset = 0;
|
|
11
11
|
let hasMorePages = true;
|
|
12
12
|
while (hasMorePages) {
|
|
13
|
-
const
|
|
13
|
+
const result2 = await wixFetch(
|
|
14
14
|
client,
|
|
15
15
|
"/bookings/v2/services/query",
|
|
16
16
|
{
|
|
@@ -24,7 +24,7 @@ async function queryBookingServices(client, bookingAppId) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
);
|
|
27
|
-
const batch =
|
|
27
|
+
const batch = result2.services ?? [];
|
|
28
28
|
allServices.push(...batch);
|
|
29
29
|
hasMorePages = batch.length >= SERVICES_PAGE_SIZE;
|
|
30
30
|
if (hasMorePages) {
|
|
@@ -34,7 +34,7 @@ async function queryBookingServices(client, bookingAppId) {
|
|
|
34
34
|
return allServices;
|
|
35
35
|
}
|
|
36
36
|
async function getBookingServiceById(client, serviceId) {
|
|
37
|
-
const
|
|
37
|
+
const result2 = await wixFetch(client, "/bookings/v2/services/query", {
|
|
38
38
|
method: "POST",
|
|
39
39
|
body: {
|
|
40
40
|
query: {
|
|
@@ -43,7 +43,7 @@ async function getBookingServiceById(client, serviceId) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
return
|
|
46
|
+
return result2.services?.[0];
|
|
47
47
|
}
|
|
48
48
|
const DEFAULT_FORM_ID = "00000000-0000-0000-0000-000000000000";
|
|
49
49
|
function participantFormId(form) {
|
|
@@ -192,7 +192,7 @@ async function listAvailabilityTimeSlots(client, input, options) {
|
|
|
192
192
|
let cursor;
|
|
193
193
|
let hasMorePages = true;
|
|
194
194
|
while (hasMorePages) {
|
|
195
|
-
const
|
|
195
|
+
const result2 = await wixFetch(
|
|
196
196
|
client,
|
|
197
197
|
"/_api/service-availability/v2/time-slots",
|
|
198
198
|
{
|
|
@@ -207,12 +207,12 @@ async function listAvailabilityTimeSlots(client, input, options) {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
);
|
|
210
|
-
allSlots.push(...
|
|
210
|
+
allSlots.push(...result2.timeSlots ?? []);
|
|
211
211
|
if (allSlots.length >= maxSlots) {
|
|
212
212
|
return allSlots.slice(0, maxSlots);
|
|
213
213
|
}
|
|
214
|
-
cursor =
|
|
215
|
-
hasMorePages = !!cursor &&
|
|
214
|
+
cursor = result2.pagingMetadata?.cursors?.next;
|
|
215
|
+
hasMorePages = !!cursor && result2.pagingMetadata?.hasNext !== false;
|
|
216
216
|
}
|
|
217
217
|
return allSlots;
|
|
218
218
|
}
|
|
@@ -223,7 +223,7 @@ async function listEventTimeSlots(client, input, options) {
|
|
|
223
223
|
let cursor;
|
|
224
224
|
let hasMorePages = true;
|
|
225
225
|
while (hasMorePages) {
|
|
226
|
-
const
|
|
226
|
+
const result2 = await wixFetch(
|
|
227
227
|
client,
|
|
228
228
|
"/_api/service-availability/v2/time-slots/event",
|
|
229
229
|
{
|
|
@@ -238,12 +238,12 @@ async function listEventTimeSlots(client, input, options) {
|
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
);
|
|
241
|
-
allSlots.push(...
|
|
241
|
+
allSlots.push(...result2.timeSlots ?? []);
|
|
242
242
|
if (allSlots.length >= maxSlots) {
|
|
243
243
|
return allSlots.slice(0, maxSlots);
|
|
244
244
|
}
|
|
245
|
-
cursor =
|
|
246
|
-
hasMorePages = !!cursor &&
|
|
245
|
+
cursor = result2.pagingMetadata?.cursors?.next;
|
|
246
|
+
hasMorePages = !!cursor && result2.pagingMetadata?.hasNext !== false;
|
|
247
247
|
}
|
|
248
248
|
return allSlots;
|
|
249
249
|
}
|
|
@@ -508,11 +508,2295 @@ var BookingFailure = /* @__PURE__ */ ((BookingFailure2) => {
|
|
|
508
508
|
const listServices = createActionCaller("wixBookings.listServices", "GET");
|
|
509
509
|
const listSlots = createActionCaller("wixBookings.listSlots", "GET");
|
|
510
510
|
const createBooking = createActionCaller("wixBookings.createBooking", "POST");
|
|
511
|
+
const GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
512
|
+
function canonicalFormId(raw) {
|
|
513
|
+
if (typeof raw !== "string") return void 0;
|
|
514
|
+
const trimmed = raw.trim();
|
|
515
|
+
return GUID.test(trimmed) ? trimmed.toLowerCase() : void 0;
|
|
516
|
+
}
|
|
517
|
+
const WIX_FORMS_CONTEXT = createJayContext("wix:forms");
|
|
518
|
+
const REGISTERED_CHECKS = Symbol("wix-forms.registeredFieldChecks");
|
|
519
|
+
const EMIT_SUBMIT_OUTCOME = Symbol("wix-forms.emitSubmitOutcome");
|
|
520
|
+
const EMIT_SUBMIT_START = Symbol("wix-forms.emitSubmitStart");
|
|
521
|
+
function provideWixFormsContext() {
|
|
522
|
+
return registerReactiveGlobalContext(WIX_FORMS_CONTEXT, createWixFormsContextState);
|
|
523
|
+
}
|
|
524
|
+
function registeredFieldChecks(context, formId) {
|
|
525
|
+
const canonical = canonicalFormId(formId);
|
|
526
|
+
return canonical ? context[REGISTERED_CHECKS](canonical) : [];
|
|
527
|
+
}
|
|
528
|
+
function emitSubmitOutcome(context, event) {
|
|
529
|
+
context[EMIT_SUBMIT_OUTCOME](event);
|
|
530
|
+
}
|
|
531
|
+
function emitSubmitStart(context, event) {
|
|
532
|
+
context[EMIT_SUBMIT_START](event);
|
|
533
|
+
}
|
|
534
|
+
function createWixFormsContextState() {
|
|
535
|
+
const registrationsByFormId = /* @__PURE__ */ new Map();
|
|
536
|
+
const keysWarnedAbout = /* @__PURE__ */ new Set();
|
|
537
|
+
function registerFieldChecks(formId, checks) {
|
|
538
|
+
const canonical = canonicalFormId(formId);
|
|
539
|
+
if (!canonical) {
|
|
540
|
+
warnAboutNonFormIdKey(formId);
|
|
541
|
+
return () => {
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
registrationsByFormId.set(canonical, [...registrationsFor(canonical), checks]);
|
|
545
|
+
return () => {
|
|
546
|
+
registrationsByFormId.set(
|
|
547
|
+
canonical,
|
|
548
|
+
registrationsFor(canonical).filter((registered) => registered !== checks)
|
|
549
|
+
);
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
function registrationsFor(canonical) {
|
|
553
|
+
return registrationsByFormId.get(canonical) ?? [];
|
|
554
|
+
}
|
|
555
|
+
function warnAboutNonFormIdKey(key) {
|
|
556
|
+
if (keysWarnedAbout.has(key)) return;
|
|
557
|
+
keysWarnedAbout.add(key);
|
|
558
|
+
console.warn(
|
|
559
|
+
`[wix-forms] field checks key "${key}" is not a form id and never matches; key checks by the form's id`
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
const submitOutcomeHandlers = /* @__PURE__ */ new Set();
|
|
563
|
+
function onSubmitOutcome(handler) {
|
|
564
|
+
submitOutcomeHandlers.add(handler);
|
|
565
|
+
return () => submitOutcomeHandlers.delete(handler);
|
|
566
|
+
}
|
|
567
|
+
const submitStartHandlers = /* @__PURE__ */ new Set();
|
|
568
|
+
function onSubmitStart(handler) {
|
|
569
|
+
submitStartHandlers.add(handler);
|
|
570
|
+
return () => submitStartHandlers.delete(handler);
|
|
571
|
+
}
|
|
572
|
+
return {
|
|
573
|
+
registerFieldChecks,
|
|
574
|
+
onSubmitOutcome,
|
|
575
|
+
onSubmitStart,
|
|
576
|
+
[REGISTERED_CHECKS]: registrationsFor,
|
|
577
|
+
[EMIT_SUBMIT_OUTCOME]: (event) => callEachHandler(submitOutcomeHandlers, event, "onSubmitOutcome"),
|
|
578
|
+
[EMIT_SUBMIT_START]: (event) => callEachHandler(submitStartHandlers, event, "onSubmitStart")
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function callEachHandler(handlers, event, eventName) {
|
|
582
|
+
for (const handler of [...handlers]) {
|
|
583
|
+
try {
|
|
584
|
+
handler({ event });
|
|
585
|
+
} catch (error) {
|
|
586
|
+
console.error(`[wix-forms] an ${eventName} handler threw`, {
|
|
587
|
+
formId: event.formId,
|
|
588
|
+
error: error instanceof Error ? `${error.name}: ${error.message}` : String(error)
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
511
593
|
makeJayInit().withClient(async () => {
|
|
594
|
+
provideWixFormsContext();
|
|
512
595
|
console.log("[wix-forms] Client ready");
|
|
513
596
|
});
|
|
514
597
|
const getFormSummary = createActionCaller("wixForms.getFormSummary", "GET");
|
|
515
598
|
const submitForm = createActionCaller("wixForms.submitForm", "POST");
|
|
599
|
+
var FieldRule = /* @__PURE__ */ ((FieldRule2) => {
|
|
600
|
+
FieldRule2[FieldRule2["NONE"] = 0] = "NONE";
|
|
601
|
+
FieldRule2[FieldRule2["REQUIRED"] = 1] = "REQUIRED";
|
|
602
|
+
FieldRule2[FieldRule2["MIN_LENGTH"] = 2] = "MIN_LENGTH";
|
|
603
|
+
FieldRule2[FieldRule2["MAX_LENGTH"] = 3] = "MAX_LENGTH";
|
|
604
|
+
FieldRule2[FieldRule2["EMAIL"] = 4] = "EMAIL";
|
|
605
|
+
FieldRule2[FieldRule2["PHONE"] = 5] = "PHONE";
|
|
606
|
+
FieldRule2[FieldRule2["URL"] = 6] = "URL";
|
|
607
|
+
FieldRule2[FieldRule2["PATTERN"] = 7] = "PATTERN";
|
|
608
|
+
FieldRule2[FieldRule2["CUSTOM"] = 8] = "CUSTOM";
|
|
609
|
+
FieldRule2[FieldRule2["SERVER"] = 9] = "SERVER";
|
|
610
|
+
FieldRule2[FieldRule2["PHONE_COUNTRY"] = 10] = "PHONE_COUNTRY";
|
|
611
|
+
FieldRule2[FieldRule2["HOOK"] = 11] = "HOOK";
|
|
612
|
+
return FieldRule2;
|
|
613
|
+
})(FieldRule || {});
|
|
614
|
+
const metadata = { "version": 4, "country_calling_codes": { "1": ["US", "AG", "AI", "AS", "BB", "BM", "BS", "CA", "DM", "DO", "GD", "GU", "JM", "KN", "KY", "LC", "MP", "MS", "PR", "SX", "TC", "TT", "VC", "VG", "VI"], "7": ["RU", "KZ"], "20": ["EG"], "27": ["ZA"], "30": ["GR"], "31": ["NL"], "32": ["BE"], "33": ["FR"], "34": ["ES"], "36": ["HU"], "39": ["IT", "VA"], "40": ["RO"], "41": ["CH"], "43": ["AT"], "44": ["GB", "GG", "IM", "JE"], "45": ["DK"], "46": ["SE"], "47": ["NO", "SJ"], "48": ["PL"], "49": ["DE"], "51": ["PE"], "52": ["MX"], "53": ["CU"], "54": ["AR"], "55": ["BR"], "56": ["CL"], "57": ["CO"], "58": ["VE"], "60": ["MY"], "61": ["AU", "CC", "CX"], "62": ["ID"], "63": ["PH"], "64": ["NZ"], "65": ["SG"], "66": ["TH"], "81": ["JP"], "82": ["KR"], "84": ["VN"], "86": ["CN"], "90": ["TR"], "91": ["IN"], "92": ["PK"], "93": ["AF"], "94": ["LK"], "95": ["MM"], "98": ["IR"], "211": ["SS"], "212": ["MA", "EH"], "213": ["DZ"], "216": ["TN"], "218": ["LY"], "220": ["GM"], "221": ["SN"], "222": ["MR"], "223": ["ML"], "224": ["GN"], "225": ["CI"], "226": ["BF"], "227": ["NE"], "228": ["TG"], "229": ["BJ"], "230": ["MU"], "231": ["LR"], "232": ["SL"], "233": ["GH"], "234": ["NG"], "235": ["TD"], "236": ["CF"], "237": ["CM"], "238": ["CV"], "239": ["ST"], "240": ["GQ"], "241": ["GA"], "242": ["CG"], "243": ["CD"], "244": ["AO"], "245": ["GW"], "246": ["IO"], "247": ["AC"], "248": ["SC"], "249": ["SD"], "250": ["RW"], "251": ["ET"], "252": ["SO"], "253": ["DJ"], "254": ["KE"], "255": ["TZ"], "256": ["UG"], "257": ["BI"], "258": ["MZ"], "260": ["ZM"], "261": ["MG"], "262": ["RE", "YT"], "263": ["ZW"], "264": ["NA"], "265": ["MW"], "266": ["LS"], "267": ["BW"], "268": ["SZ"], "269": ["KM"], "290": ["SH", "TA"], "291": ["ER"], "297": ["AW"], "298": ["FO"], "299": ["GL"], "350": ["GI"], "351": ["PT"], "352": ["LU"], "353": ["IE"], "354": ["IS"], "355": ["AL"], "356": ["MT"], "357": ["CY"], "358": ["FI", "AX"], "359": ["BG"], "370": ["LT"], "371": ["LV"], "372": ["EE"], "373": ["MD"], "374": ["AM"], "375": ["BY"], "376": ["AD"], "377": ["MC"], "378": ["SM"], "380": ["UA"], "381": ["RS"], "382": ["ME"], "383": ["XK"], "385": ["HR"], "386": ["SI"], "387": ["BA"], "389": ["MK"], "420": ["CZ"], "421": ["SK"], "423": ["LI"], "500": ["FK"], "501": ["BZ"], "502": ["GT"], "503": ["SV"], "504": ["HN"], "505": ["NI"], "506": ["CR"], "507": ["PA"], "508": ["PM"], "509": ["HT"], "590": ["GP", "BL", "MF"], "591": ["BO"], "592": ["GY"], "593": ["EC"], "594": ["GF"], "595": ["PY"], "596": ["MQ"], "597": ["SR"], "598": ["UY"], "599": ["CW", "BQ"], "670": ["TL"], "672": ["NF"], "673": ["BN"], "674": ["NR"], "675": ["PG"], "676": ["TO"], "677": ["SB"], "678": ["VU"], "679": ["FJ"], "680": ["PW"], "681": ["WF"], "682": ["CK"], "683": ["NU"], "685": ["WS"], "686": ["KI"], "687": ["NC"], "688": ["TV"], "689": ["PF"], "690": ["TK"], "691": ["FM"], "692": ["MH"], "850": ["KP"], "852": ["HK"], "853": ["MO"], "855": ["KH"], "856": ["LA"], "880": ["BD"], "886": ["TW"], "960": ["MV"], "961": ["LB"], "962": ["JO"], "963": ["SY"], "964": ["IQ"], "965": ["KW"], "966": ["SA"], "967": ["YE"], "968": ["OM"], "970": ["PS"], "971": ["AE"], "972": ["IL"], "973": ["BH"], "974": ["QA"], "975": ["BT"], "976": ["MN"], "977": ["NP"], "992": ["TJ"], "993": ["TM"], "994": ["AZ"], "995": ["GE"], "996": ["KG"], "998": ["UZ"] }, "countries": { "AC": ["247", "00", "(?:[01589]\\d|[2-467])\\d{4}", [5, 6]], "AD": ["376", "00", "(?:1|6\\d)\\d{7}|[135-9]\\d{5}", [6, 8, 9], [["(\\d{3})(\\d{3})", "$1 $2", ["[135-9]"]], ["(\\d{4})(\\d{4})", "$1 $2", ["1"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["6"]]]], "AE": ["971", "00", "(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}", [5, 6, 7, 8, 9, 10, 11, 12], [["(\\d{3})(\\d{2,9})", "$1 $2", ["60|8"]], ["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["[236]|[479][2-8]"], "0$1"], ["(\\d{3})(\\d)(\\d{5})", "$1 $2 $3", ["[479]"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["5"], "0$1"]], "0"], "AF": ["93", "00", "[2-7]\\d{8}", [9], [["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[2-7]"], "0$1"]], "0"], "AG": ["1", "011", "(?:268|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([457]\\d{6})$|1", "268$1", 0, "268"], "AI": ["1", "011", "(?:264|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2457]\\d{6})$|1", "264$1", 0, "264"], "AL": ["355", "00", "(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}", [6, 7, 8, 9], [["(\\d{3})(\\d{3,4})", "$1 $2", ["80|9"], "0$1"], ["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["4[2-6]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[2358][2-5]|4"], "0$1"], ["(\\d{3})(\\d{5})", "$1 $2", ["[23578]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["6"], "0$1"]], "0"], "AM": ["374", "00", "(?:[1-489]\\d|55|60|77)\\d{6}", [8], [["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["[89]0"], "0 $1"], ["(\\d{3})(\\d{5})", "$1 $2", ["2|3[12]"], "(0$1)"], ["(\\d{2})(\\d{6})", "$1 $2", ["1|47"], "(0$1)"], ["(\\d{2})(\\d{6})", "$1 $2", ["[3-9]"], "0$1"]], "0"], "AO": ["244", "00", "[29]\\d{8}", [9], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[29]"]]]], "AR": ["54", "00", "(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}", [10, 11], [["(\\d{4})(\\d{2})(\\d{4})", "$1 $2-$3", ["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])", "2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)", "2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]", "2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"], "0$1", 1], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2-$3", ["1"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{4})", "$1-$2-$3", ["[68]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2-$3", ["[23]"], "0$1", 1], ["(\\d)(\\d{4})(\\d{2})(\\d{4})", "$2 15-$3-$4", ["9(?:2[2-469]|3[3-578])", "9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))", "9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)", "9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]", "9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"], "0$1", 0, "$1 $2 $3-$4"], ["(\\d)(\\d{2})(\\d{4})(\\d{4})", "$2 15-$3-$4", ["91"], "0$1", 0, "$1 $2 $3-$4"], ["(\\d{3})(\\d{3})(\\d{5})", "$1-$2-$3", ["8"], "0$1"], ["(\\d)(\\d{3})(\\d{3})(\\d{4})", "$2 15-$3-$4", ["9"], "0$1", 0, "$1 $2 $3-$4"]], "0", 0, "0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?", "9$1"], "AS": ["1", "011", "(?:[58]\\d\\d|684|900)\\d{7}", [10], 0, "1", 0, "([267]\\d{6})$|1", "684$1", 0, "684"], "AT": ["43", "00", "1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [["(\\d)(\\d{3,12})", "$1 $2", ["1(?:11|[2-9])"], "0$1"], ["(\\d{3})(\\d{2})", "$1 $2", ["517"], "0$1"], ["(\\d{2})(\\d{3,5})", "$1 $2", ["5[079]"], "0$1"], ["(\\d{3})(\\d{3,10})", "$1 $2", ["(?:31|4)6|51|6(?:48|5[0-3579]|[6-9])|7(?:20|32|8)|[89]", "(?:31|4)6|51|6(?:485|5[0-3579]|[6-9])|7(?:20|32|8)|[89]"], "0$1"], ["(\\d{4})(\\d{3,9})", "$1 $2", ["[2-467]|5[2-6]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["5"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4,7})", "$1 $2 $3", ["5"], "0$1"]], "0"], "AU": ["61", "001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011", "1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}", [5, 6, 7, 8, 9, 10, 12], [["(\\d{2})(\\d{3,4})", "$1 $2", ["16"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2,4})", "$1 $2 $3", ["16"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["14|4"], "0$1"], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["[2378]"], "(0$1)"], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["1(?:30|[89])"]]], "0", 0, "(183[12])|0", 0, 0, 0, [["(?:(?:241|349)0\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|[34]\\d\\d)|91(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79]))))\\d{3}|(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\\d|2[0-8])|8(?:55|6[0-8]|[78]\\d|9[02-9]))\\d{6}", [9]], ["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}", [9]], ["180(?:0\\d{3}|2)\\d{3}", [7, 10]], ["190[0-26]\\d{6}", [10]], 0, 0, 0, ["163\\d{2,6}", [5, 6, 7, 8, 9]], ["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}", [9]], ["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}", [6, 8, 10, 12]]], "0011"], "AW": ["297", "00", "(?:[25-79]\\d\\d|800)\\d{4}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[25-9]"]]]], "AX": ["358", "00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))", "2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}", [5, 6, 7, 8, 9, 10, 11, 12], 0, "0", 0, 0, 0, 0, "18", 0, "00"], "AZ": ["994", "00", "365\\d{6}|(?:[124579]\\d|60|88)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["90"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["1[28]|2|365|46", "1[28]|2|365[45]|46", "1[28]|2|365(?:4|5[02])|46"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[13-9]"], "0$1"]], "0"], "BA": ["387", "00", "6\\d{8}|(?:[35689]\\d|49|70)\\d{6}", [8, 9], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["6[1-3]|[7-9]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2-$3", ["[3-5]|6[56]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3 $4", ["6"], "0$1"]], "0"], "BB": ["1", "011", "(?:246|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "246$1", 0, "246"], "BD": ["880", "00", "[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}", [6, 7, 8, 9, 10], [["(\\d{2})(\\d{4,6})", "$1-$2", ["31[5-8]|[459]1"], "0$1"], ["(\\d{3})(\\d{3,7})", "$1-$2", ["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28)|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"], "0$1"], ["(\\d{4})(\\d{3,6})", "$1-$2", ["[13-9]|2[23]"], "0$1"], ["(\\d)(\\d{7,8})", "$1-$2", ["2"], "0$1"]], "0"], "BE": ["32", "00", "4\\d{8}|[1-9]\\d{7}", [8, 9], [["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["(?:80|9)0"], "0$1"], ["(\\d)(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[239]|4[23]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[15-8]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["4"], "0$1"]], "0"], "BF": ["226", "00", "[024-7]\\d{7}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[024-7]"]]]], "BG": ["359", "00", "00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}", [6, 7, 8, 9, 12], [["(\\d)(\\d)(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["2"], "0$1"], ["(\\d{3})(\\d{4})", "$1 $2", ["43[1-6]|70[1-9]"], "0$1"], ["(\\d)(\\d{3})(\\d{3,4})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2,3})", "$1 $2 $3", ["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["(?:70|8)0"], "0$1"], ["(\\d{3})(\\d{3})(\\d{2})", "$1 $2 $3", ["43[1-7]|7"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[48]|9[08]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["9"], "0$1"]], "0"], "BH": ["973", "00", "[136-9]\\d{7}", [8], [["(\\d{4})(\\d{4})", "$1 $2", ["[13679]|8[02-4679]"]]]], "BI": ["257", "00", "(?:[267]\\d|31)\\d{6}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2367]"]]]], "BJ": ["229", "00", "(?:01\\d|8)\\d{7}", [8, 10], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["0"]]]], "BL": ["590", "00", "7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}", [9], 0, "0", 0, 0, 0, 0, 0, [["(?:59(?:0(?:2[7-9]|3[3-7]|5[12]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"], ["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"], ["80[0-5]\\d{6}"], ["8[129]\\d{7}"], 0, 0, 0, 0, ["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]], "BM": ["1", "011", "(?:441|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "441$1", 0, "441"], "BN": ["673", "00", "[2-578]\\d{6}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[2-578]"]]]], "BO": ["591", "00(?:1\\d)?", "(?:[2-7]\\d\\d|8001)\\d{5}", [8, 9], [["(\\d)(\\d{7})", "$1 $2", ["[23]|4[46]|50"]], ["(\\d{8})", "$1", ["[5-7]"]], ["(\\d{3})(\\d{2})(\\d{4})", "$1 $2 $3", ["8"]]], "0", 0, "0(1\\d)?"], "BQ": ["599", "00", "(?:[34]1|7\\d)\\d{5}", [7], 0, 0, 0, 0, 0, 0, "[347]"], "BR": ["55", "00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)", "[1-467]\\d{9,10}|55[0-46-9]\\d{8}|[34]\\d{7}|55\\d{7,8}|(?:5[0-46-9]|[89]\\d)\\d{7,9}", [8, 9, 10, 11], [["(\\d{4})(\\d{4})", "$1-$2", ["300|4(?:0[02]|37|86)", "300|4(?:0(?:0|20)|370|864)"]], ["(\\d{3})(\\d{2,3})(\\d{4})", "$1 $2 $3", ["(?:[358]|90)0"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2-$3", ["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"], "($1)"], ["(\\d{2})(\\d{5})(\\d{4})", "$1 $2-$3", ["[16][1-9]|[2-57-9]"], "($1)"]], "0", 0, "(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?", "$2"], "BS": ["1", "011", "(?:242|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([3-8]\\d{6})$|1", "242$1", 0, "242"], "BT": ["975", "00", "[178]\\d{7}|[2-8]\\d{6}", [7, 8], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["[2-6]|7[246]|8[2-4]"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["1[67]|[78]"]]]], "BW": ["267", "00", "(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}", [7, 8, 10], [["(\\d{2})(\\d{5})", "$1 $2", ["90"]], ["(\\d{3})(\\d{4})", "$1 $2", ["[24-6]|3[15-9]"]], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[37]"]], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["0"]], ["(\\d{3})(\\d{4})(\\d{3})", "$1 $2 $3", ["8"]]]], "BY": ["375", "810", "(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}", [6, 7, 8, 9, 10, 11], [["(\\d{3})(\\d{3})", "$1 $2", ["800"], "8 $1"], ["(\\d{3})(\\d{2})(\\d{2,4})", "$1 $2 $3", ["800"], "8 $1"], ["(\\d{4})(\\d{2})(\\d{3})", "$1 $2-$3", ["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])", "1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"], "8 0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2-$3-$4", ["1(?:[56]|7[467])|2[1-3]"], "8 0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2-$3-$4", ["[1-4]"], "8 0$1"], ["(\\d{3})(\\d{3,4})(\\d{4})", "$1 $2 $3", ["[89]"], "8 $1"]], "8", 0, "0|80?", 0, 0, 0, 0, "8~10"], "BZ": ["501", "00", "(?:0800\\d|[2-8])\\d{6}", [7, 11], [["(\\d{3})(\\d{4})", "$1-$2", ["[2-8]"]], ["(\\d)(\\d{3})(\\d{4})(\\d{3})", "$1-$2-$3-$4", ["0"]]]], "CA": ["1", "011", "[2-9]\\d{9}|3\\d{6}", [7, 10], 0, "1", 0, 0, 0, 0, 0, [["(?:2(?:04|[23]6|[48]9|5[07]|[67]3)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}", [10]], ["", [10]], ["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}", [10]], ["900[2-9]\\d{6}", [10]], ["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|3[23]|44|66|77|88)|6(?:22|33))[2-9]\\d{6}", [10]], 0, ["310\\d{4}", [7]], 0, ["600[2-9]\\d{6}", [10]]]], "CC": ["61", "001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011", "1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}", [6, 7, 8, 9, 10, 12], 0, "0", 0, "([59]\\d{7})$|0", "8$1", 0, 0, [["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}", [9]], ["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}", [9]], ["180(?:0\\d{3}|2)\\d{3}", [7, 10]], ["190[0-26]\\d{6}", [10]], 0, 0, 0, 0, ["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}", [9]], ["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}", [6, 8, 10, 12]]], "0011"], "CD": ["243", "00", "(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}", [7, 8, 9, 10], [["(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3", ["88"], "0$1"], ["(\\d{2})(\\d{5})", "$1 $2", ["[1-6]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[89]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["5"], "0$1"]], "0"], "CF": ["236", "00", "8776\\d{4}|(?:[27]\\d|61)\\d{6}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[26-8]"]]]], "CG": ["242", "00", "222\\d{6}|(?:0\\d|80)\\d{7}", [9], [["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["8"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[02]"]]]], "CH": ["41", "00", "8\\d{11}|[2-9]\\d{8}", [9, 12], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["8[047]|90"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2-79]|81"], "0$1"], ["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["8"], "0$1"]], "0"], "CI": ["225", "00", "[02]\\d{9}", [10], [["(\\d{2})(\\d{2})(\\d)(\\d{5})", "$1 $2 $3 $4", ["2"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3 $4", ["0"]]]], "CK": ["682", "00", "[2-578]\\d{4}", [5], [["(\\d{2})(\\d{3})", "$1 $2", ["[2-578]"]]]], "CL": ["56", "(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0", "12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}", [9, 10, 11], [["(\\d{5})(\\d{4})", "$1 $2", ["219", "2196"], "($1)"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["60|809"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["44"]], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["2[1-36]"], "($1)"], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["9(?:10|[2-9])"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-8]|[1-9])"], "($1)"], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["60|8"]], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"]], ["(\\d{3})(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3 $4", ["60"]]]], "CM": ["237", "00", "[26]\\d{8}|88\\d{6,7}", [8, 9], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["88"]], ["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["[26]|88"]]]], "CN": ["86", "00|1(?:[12]\\d|79)\\d\\d00", "(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}", [7, 8, 9, 10, 11, 12], [["(\\d{2})(\\d{5,6})", "$1 $2", ["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]", "(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1", "10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12", "10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123", "10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"], "0$1"], ["(\\d{3})(\\d{5,6})", "$1 $2", ["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]", "(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]", "85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])", "85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["(?:4|80)0"]], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["10|2(?:[02-57-9]|1[1-9])", "10|2(?:[02-57-9]|1[1-9])", "10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"], "0$1", 1], ["(\\d{3})(\\d{7,8})", "$1 $2", ["9"]], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["80"], "0$1", 1], ["(\\d{3})(\\d{4})(\\d{4})", "$1 $2 $3", ["[3-578]"], "0$1", 1], ["(\\d{3})(\\d{4})(\\d{4})", "$1 $2 $3", ["1[3-9]"]], ["(\\d{2})(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3 $4", ["[12]"], "0$1", 1]], "0", 0, "(1(?:[12]\\d|79)\\d\\d)|0", 0, 0, 0, 0, "00"], "CO": ["57", "00(?:4(?:[14]4|56)|[579])", "(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}", [8, 10, 11], [["(\\d{4})(\\d{4})", "$1 $2", ["46"]], ["(\\d{3})(\\d{7})", "$1 $2", ["6|90"], "($1)"], ["(\\d{3})(\\d{7})", "$1 $2", ["3[0-357]|9[14]"]], ["(\\d)(\\d{3})(\\d{7})", "$1-$2-$3", ["1"], "0$1", 0, "$1 $2 $3"]], "0", 0, "0([3579]|4(?:[14]4|56))?"], "CR": ["506", "00", "(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}", [8, 10], [["(\\d{4})(\\d{4})", "$1 $2", ["[2-7]|8[3-9]"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1-$2-$3", ["[89]"]]], 0, 0, "(19(?:0[0-2468]|1[09]|20|66|77|99))"], "CU": ["53", "119", "(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}", [6, 7, 8, 10], [["(\\d{2})(\\d{4,6})", "$1 $2", ["2[1-4]|[34]"], "(0$1)"], ["(\\d)(\\d{6,7})", "$1 $2", ["7"], "(0$1)"], ["(\\d)(\\d{7})", "$1 $2", ["[56]"], "0$1"], ["(\\d{3})(\\d{7})", "$1 $2", ["8"], "0$1"]], "0"], "CV": ["238", "0", "(?:[2-59]\\d\\d|800)\\d{4}", [7], [["(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3", ["[2-589]"]]]], "CW": ["599", "00", "(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}", [7, 8], [["(\\d{3})(\\d{4})", "$1 $2", ["[3467]"]], ["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["9[4-8]"]]], 0, 0, 0, 0, 0, "[69]"], "CX": ["61", "001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011", "1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}", [6, 7, 8, 9, 10, 12], 0, "0", 0, "([59]\\d{7})$|0", "8$1", 0, 0, [["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}", [9]], ["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}", [9]], ["180(?:0\\d{3}|2)\\d{3}", [7, 10]], ["190[0-26]\\d{6}", [10]], 0, 0, 0, 0, ["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}", [9]], ["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}", [6, 8, 10, 12]]], "0011"], "CY": ["357", "00", "(?:[279]\\d|[58]0)\\d{6}", [8], [["(\\d{2})(\\d{6})", "$1 $2", ["[257-9]"]]]], "CZ": ["420", "00", "(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}", [9, 10, 11, 12], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[2-8]|9[015-7]"]], ["(\\d{2})(\\d{3})(\\d{3})(\\d{2})", "$1 $2 $3 $4", ["96"]], ["(\\d{2})(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["9"]], ["(\\d{3})(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["9"]]]], "DE": ["49", "00", "[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [["(\\d{2})(\\d{3,13})", "$1 $2", ["3[02]|40|[68]9"], "0$1"], ["(\\d{3})(\\d{3,12})", "$1 $2", ["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1", "2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"], "0$1"], ["(\\d{4})(\\d{2,11})", "$1 $2", ["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]", "[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"], "0$1"], ["(\\d{3})(\\d{4})", "$1 $2", ["138"], "0$1"], ["(\\d{5})(\\d{2,10})", "$1 $2", ["3"], "0$1"], ["(\\d{3})(\\d{5,11})", "$1 $2", ["181"], "0$1"], ["(\\d{3})(\\d)(\\d{4,10})", "$1 $2 $3", ["1(?:3|80)|9"], "0$1"], ["(\\d{3})(\\d{7,8})", "$1 $2", ["1[67]"], "0$1"], ["(\\d{3})(\\d{7,12})", "$1 $2", ["8"], "0$1"], ["(\\d{5})(\\d{6})", "$1 $2", ["185", "1850", "18500"], "0$1"], ["(\\d{3})(\\d{4})(\\d{4})", "$1 $2 $3", ["7"], "0$1"], ["(\\d{4})(\\d{7})", "$1 $2", ["18[68]"], "0$1"], ["(\\d{4})(\\d{7})", "$1 $2", ["15[1279]"], "0$1"], ["(\\d{5})(\\d{6})", "$1 $2", ["15[03568]", "15(?:[0568]|3[13])"], "0$1"], ["(\\d{3})(\\d{8})", "$1 $2", ["18"], "0$1"], ["(\\d{3})(\\d{2})(\\d{7,8})", "$1 $2 $3", ["1(?:6[023]|7)"], "0$1"], ["(\\d{4})(\\d{2})(\\d{7})", "$1 $2 $3", ["15[279]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{8})", "$1 $2 $3", ["15"], "0$1"]], "0"], "DJ": ["253", "00", "(?:2\\d|77)\\d{6}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[27]"]]]], "DK": ["45", "00", "[2-9]\\d{7}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2-9]"]]]], "DM": ["1", "011", "(?:[58]\\d\\d|767|900)\\d{7}", [10], 0, "1", 0, "([2-7]\\d{6})$|1", "767$1", 0, "767"], "DO": ["1", "011", "(?:[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, 0, 0, 0, "8001|8[024]9"], "DZ": ["213", "00", "(?:[1-4]|[5-79]\\d|80)\\d{7}", [8, 9], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[1-4]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["9"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[5-8]"], "0$1"]], "0"], "EC": ["593", "00", "1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}", [8, 9, 10, 11], [["(\\d)(\\d{3})(\\d{4})", "$1 $2-$3", ["[2-7]"], "(0$1)", 0, "$1-$2-$3"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["9"], "0$1"], ["(\\d{4})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["1"]]], "0"], "EE": ["372", "00", "8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}", [7, 8, 10], [["(\\d{3})(\\d{4})", "$1 $2", ["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88", "[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]], ["(\\d{4})(\\d{3,4})", "$1 $2", ["[45]|8(?:00|[1-49])", "[45]|8(?:00[1-9]|[1-49])"]], ["(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3", ["7"]], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["8"]]]], "EG": ["20", "00", "[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}", [8, 9, 10], [["(\\d)(\\d{7,8})", "$1 $2", ["[23]"], "0$1"], ["(\\d{2})(\\d{6,7})", "$1 $2", ["1[35]|[4-6]|8[2468]|9[235-7]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["[89]"], "0$1"], ["(\\d{2})(\\d{8})", "$1 $2", ["1"], "0$1"]], "0"], "EH": ["212", "00", "[5-8]\\d{8}", [9], 0, "0", 0, 0, 0, 0, 0, [["528[89]\\d{5}"], ["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[016-8]\\d|2[0-8]|3[01]|5[0-5]))\\d{6}"], ["80[0-7]\\d{6}"], ["89\\d{7}"], 0, 0, 0, 0, ["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]], "ER": ["291", "00", "[178]\\d{6}", [7], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["[178]"], "0$1"]], "0"], "ES": ["34", "00", "(?:400|[5-9]\\d\\d)\\d{6}", [9], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[89]00"]], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[4-9]"]]]], "ET": ["251", "00", "(?:11|[2-57-9]\\d)\\d{7}", [9], [["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[1-57-9]"], "0$1"]], "0"], "FI": ["358", "00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))", "[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}", [5, 6, 7, 8, 9, 10, 11, 12], [["(\\d{5})", "$1", ["20[2-59]"], "0$1"], ["(\\d{3})(\\d{3,7})", "$1 $2", ["(?:[1-3]0|[68])0|70[07-9]"], "0$1"], ["(\\d{2})(\\d{4,8})", "$1 $2", ["[14]|2[09]|50|7[135]"], "0$1"], ["(\\d{2})(\\d{6,10})", "$1 $2", ["7"], "0$1"], ["(\\d)(\\d{4,9})", "$1 $2", ["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"], "0$1"]], "0", 0, 0, 0, 0, "1[03-79]|[2-9]", 0, "00"], "FJ": ["679", "0(?:0|52)", "45\\d{5}|(?:0800\\d|[235-9])\\d{6}", [7, 11], [["(\\d{3})(\\d{4})", "$1 $2", ["[235-9]|45"]], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["0"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "FK": ["500", "00", "[2-7]\\d{4}", [5]], "FM": ["691", "00", "(?:[39]\\d\\d|820)\\d{4}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[389]"]]]], "FO": ["298", "00", "[2-9]\\d{5}", [6], [["(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3", ["[2-9]"]]], 0, 0, "(10(?:01|[12]0|88))"], "FR": ["33", "00", "[1-9]\\d{8}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"], "0 $1"], ["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["[1-79]"], "0$1"]], "0"], "GA": ["241", "00", "(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}", [7, 8], [["(\\d)(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2-7]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["0"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["11|[67]"], "0$1"]], 0, 0, "0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})", "$1"], "GB": ["44", "00", "[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}", [7, 9, 10], [["(\\d{3})(\\d{4})", "$1 $2", ["800", "8001", "80011", "800111", "8001111"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3", ["845", "8454", "84546", "845464"], "0$1"], ["(\\d{3})(\\d{6})", "$1 $2", ["800"], "0$1"], ["(\\d{5})(\\d{4,5})", "$1 $2", ["1(?:38|5[23]|69|76|94)", "1(?:(?:38|69)7|5(?:24|39)|768|946)", "1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"], "0$1"], ["(\\d{4})(\\d{5,6})", "$1 $2", ["1(?:[2-69][02-9]|[78])"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["[25]|7(?:0|6[02-9])", "[25]|7(?:0|6(?:[03-9]|2[356]))"], "0$1"], ["(\\d{4})(\\d{6})", "$1 $2", ["7"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["[1389]"], "0$1"]], "0", 0, "0|180020", 0, 0, 0, [["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-5])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|5[01]))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}", [9, 10]], ["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}", [10]], ["80[08]\\d{7}|800\\d{6}|8001111"], ["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d", [7, 10]], ["70\\d{8}", [10]], 0, ["(?:3[0347]|55)\\d{8}", [10]], ["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}", [10]], ["56\\d{8}", [10]]], 0, " x"], "GD": ["1", "011", "(?:473|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "473$1", 0, "473"], "GE": ["995", "00", "(?:[3-57]\\d\\d|800)\\d{6}", [9], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["70"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["32"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[57]"]], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[348]"], "0$1"]], "0"], "GF": ["594", "00", "(?:694\\d|7093)\\d{5}|(?:59|[89]\\d)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[5-7]|80[6-9]|9[47]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[89]"], "0$1"]], "0"], "GG": ["44", "00", "(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?", [7, 9, 10], 0, "0", 0, "([25-9]\\d{5})$|0|180020", "1481$1", 0, 0, [["1481[25-9]\\d{5}", [10]], ["7(?:(?:781|839)\\d|911[17])\\d{5}", [10]], ["80[08]\\d{7}|800\\d{6}|8001111"], ["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d", [7, 10]], ["70\\d{8}", [10]], 0, ["(?:3[0347]|55)\\d{8}", [10]], ["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}", [10]], ["56\\d{8}", [10]]]], "GH": ["233", "00", "[235]\\d{8}|800\\d{5,6}", [8, 9], [["(\\d{3})(\\d{5})", "$1 $2", ["8"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[2358]"], "0$1"]], "0"], "GI": ["350", "00", "(?:[25]\\d|60)\\d{6}", [8], [["(\\d{3})(\\d{5})", "$1 $2", ["2"]]]], "GL": ["299", "00", "(?:19|[2-689]\\d|70)\\d{4}", [6], [["(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3", ["19|[2-9]"]]]], "GM": ["220", "00", "[48]\\d{8}|[2-9]\\d{6}", [7, 9], [["(\\d{3})(\\d{4})", "$1 $2", ["[235-9]|4(?:[0-35]|4[16-9])"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[48]"]]]], "GN": ["224", "00", "722\\d{6}|(?:3|6\\d)\\d{7}", [8, 9], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["3"]], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[67]"]]]], "GP": ["590", "00", "7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[5-79]|80[6-9]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"], "0$1"]], "0", 0, 0, 0, 0, 0, [["(?:59(?:0(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)|87\\d)|80[6-9]\\d\\d)\\d{4}"], ["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"], ["80[0-5]\\d{6}"], ["8[129]\\d{7}"], 0, 0, 0, 0, ["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]], "GQ": ["240", "00", "222\\d{6}|(?:3\\d|55|[89]0)\\d{7}", [9], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[235]"]], ["(\\d{3})(\\d{6})", "$1 $2", ["[89]"]]]], "GR": ["30", "00", "5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}", [10, 11, 12], [["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["21|7"]], ["(\\d{4})(\\d{6})", "$1 $2", ["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["[2689]"]], ["(\\d{3})(\\d{3,4})(\\d{5})", "$1 $2 $3", ["8"]]]], "GT": ["502", "00", "80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}", [8, 11], [["(\\d{4})(\\d{4})", "$1 $2", ["[2-8]"]], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"]]]], "GU": ["1", "011", "(?:[58]\\d\\d|671|900)\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "671$1", 0, "671"], "GW": ["245", "00", "[49]\\d{8}|4\\d{6}", [7, 9], [["(\\d{3})(\\d{4})", "$1 $2", ["40"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[49]"]]]], "GY": ["592", "001", "(?:[2-8]\\d{3}|9008)\\d{3}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[2-9]"]]]], "HK": ["852", "00(?:30|5[09]|[126-9]?)", "8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}", [5, 6, 7, 8, 9, 11], [["(\\d{3})(\\d{2,5})", "$1 $2", ["900", "9003"]], ["(\\d{4})(\\d{4})", "$1 $2", ["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["8"]], ["(\\d{3})(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["9"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "HN": ["504", "00", "8\\d{10}|[237-9]\\d{7}", [8, 11], [["(\\d{4})(\\d{4})", "$1-$2", ["[237-9]"]]]], "HR": ["385", "00", "[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}", [7, 8, 9], [["(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3", ["6[01]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2,3})", "$1 $2 $3", ["8"], "0$1"], ["(\\d)(\\d{4})(\\d{3})", "$1 $2 $3", ["1"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["6|7[245]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["9"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[2-57]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["8"], "0$1"]], "0"], "HT": ["509", "00", "[2-589]\\d{7}", [8], [["(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3", ["[2-589]"]]]], "HU": ["36", "00", "[235-7]\\d{8}|[1-9]\\d{7}", [8, 9], [["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["1"], "(06 $1)"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"], "(06 $1)"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[2-9]"], "06 $1"]], "06"], "ID": ["62", "00[89]", "00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}", [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["15"]], ["(\\d{2})(\\d{5,9})", "$1 $2", ["2[124]|[36]1"], "(0$1)"], ["(\\d{3})(\\d{5,7})", "$1 $2", ["800"], "0$1"], ["(\\d{3})(\\d{5,8})", "$1 $2", ["[2-79]"], "(0$1)"], ["(\\d{3})(\\d{3,4})(\\d{3})", "$1-$2-$3", ["8[1-35-9]"], "0$1"], ["(\\d{3})(\\d{6,8})", "$1 $2", ["1"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["804"], "0$1"], ["(\\d{3})(\\d)(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["80"], "0$1"], ["(\\d{3})(\\d{4})(\\d{4,5})", "$1-$2-$3", ["8"], "0$1"]], "0"], "IE": ["353", "00", "(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}", [7, 8, 9, 10], [["(\\d{2})(\\d{5})", "$1 $2", ["2[24-9]|47|58|6[237-9]|9[35-9]"], "(0$1)"], ["(\\d{3})(\\d{5})", "$1 $2", ["[45]0"], "(0$1)"], ["(\\d)(\\d{3,4})(\\d{4})", "$1 $2 $3", ["1"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[2569]|4[1-69]|7[14]"], "(0$1)"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["70"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["81"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[78]"], "0$1"], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["1"]], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["4"], "(0$1)"], ["(\\d{2})(\\d)(\\d{3})(\\d{4})", "$1 $2 $3 $4", ["8"], "0$1"]], "0"], "IL": ["972", "0(?:0|1(?:05|[2-9]))", "1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}", [7, 8, 9, 10, 11, 12], [["(\\d{4})(\\d{3})", "$1-$2", ["125"]], ["(\\d{4})(\\d{2})(\\d{2})", "$1-$2-$3", ["121"]], ["(\\d)(\\d{3})(\\d{4})", "$1-$2-$3", ["[2-489]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1-$2-$3", ["[57]"], "0$1"], ["(\\d{4})(\\d{3})(\\d{3})", "$1-$2-$3", ["12"]], ["(\\d{4})(\\d{6})", "$1-$2", ["159"]], ["(\\d)(\\d{3})(\\d{3})(\\d{3})", "$1-$2-$3-$4", ["1[7-9]"]], ["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})", "$1-$2 $3-$4", ["15"]]], "0"], "IM": ["44", "00", "1624\\d{6}|(?:[3578]\\d|90)\\d{8}", [10], 0, "0", 0, "([25-8]\\d{5})$|0|180020", "1624$1", 0, "74576|(?:16|7[56])24"], "IN": ["91", "00", "(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}", [8, 9, 10, 11, 12, 13], [["(\\d{8})", "$1", ["5(?:0|2[23]|3[03]|[67]1|88)", "5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)", "5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"], 0, 1], ["(\\d{4})(\\d{4,5})", "$1 $2", ["180", "1800"], 0, 1], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["140"], 0, 1], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["11|2[02]|33|4[04]|79[1-6]|80[2-46]", "11|2[02]|33|4[04]|79[1-6]|80(?:[2-4]|6[0-589])", "11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9]))|80(?:[2-4]|6[0-589])"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67)[14]", "1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31)|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]", "1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:3171|5[15][2-6]|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|8(?:16|2[014]|3[126]|6[136]|7[78]|83)(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"], "0$1", 1], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|3[129]|5[29]|6[02-5]|70)|807", "1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7(?:[23569]|8[0-57-9])|8[1-6])|7(?:1(?:[013-8]|9[6-9])|3(?:17|2[0-49]|9[2-57])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]", "1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|8(?:28[235-7]|3))|73179|807(?:1|9[1-3])|(?:1552|6(?:(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578])\\d|7(?:[23569]\\d|8[0-57-9])|8(?:[14-6]\\d|2[0-79]))|7(?:1(?:[013-8]\\d|9[6-9])|3(?:2[0-49]|9[2-57])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"], "0$1", 1], ["(\\d{5})(\\d{5})", "$1 $2", ["16|[6-9]"], "0$1", 1], ["(\\d{4})(\\d{2,4})(\\d{4})", "$1 $2 $3", ["18[06]", "18[06]0"], 0, 1], ["(\\d{4})(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["18"], 0, 1]], "0"], "IO": ["246", "00", "3\\d{6}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["3"]]]], "IQ": ["964", "00", "(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}", [8, 9, 10], [["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["1"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[2-6]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["7"], "0$1"]], "0"], "IR": ["98", "00", "[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}", [4, 5, 6, 7, 10], [["(\\d{4,5})", "$1", ["96"], "0$1"], ["(\\d{2})(\\d{4,5})", "$1 $2", ["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["9"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["[1-8]"], "0$1"]], "0"], "IS": ["354", "00|1(?:0(?:01|[12]0)|100)", "(?:38\\d|[4-9])\\d{6}", [7, 9], [["(\\d{3})(\\d{4})", "$1 $2", ["[4-9]"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["3"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "IT": ["39", "00", "0\\d{5,11}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?", [6, 7, 8, 9, 10, 11, 12], [["(\\d{2})(\\d{4,6})", "$1 $2", ["0[26]"]], ["(\\d{3})(\\d{3,6})", "$1 $2", ["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])", "0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]], ["(\\d{4})(\\d{2,6})", "$1 $2", ["0(?:[13-579][2-46-8]|8[236-8])"]], ["(\\d{4})(\\d{4})", "$1 $2", ["894"]], ["(\\d{2})(\\d{3,4})(\\d{4})", "$1 $2 $3", ["0[26]|5"]], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["1(?:44|[679])|[378]|43"]], ["(\\d{3})(\\d{3,4})(\\d{4})", "$1 $2 $3", ["0[13-57-9][0159]|14"]], ["(\\d{2})(\\d{4})(\\d{5})", "$1 $2 $3", ["0[26]"]], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["0"]], ["(\\d{3})(\\d{4})(\\d{4,5})", "$1 $2 $3", ["[03]"]]], 0, 0, 0, 0, 0, 0, [["0(?:669[0-79]\\d{1,6}|831\\d{2,8})|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[2356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}"], ["3[2-9]\\d{7,8}|(?:31|43)\\d{8}", [9, 10]], ["80(?:0\\d{3}|3)\\d{3}", [6, 9]], ["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}", [6, 8, 9, 10]], ["1(?:78\\d|99)\\d{6}", [9, 10]], ["3[2-8]\\d{9,10}", [11, 12]], 0, 0, ["55\\d{8}", [10]], ["84(?:[08]\\d{3}|[17])\\d{3}", [6, 9]]]], "JE": ["44", "00", "1534\\d{6}|(?:[3578]\\d|90)\\d{8}", [10], 0, "0", 0, "([0-24-8]\\d{5})$|0|180020", "1534$1", 0, 0, [["1534[0-24-8]\\d{5}"], ["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"], ["80(?:07(?:35|81)|8901)\\d{4}"], ["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"], ["701511\\d{4}"], 0, ["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"], ["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"], ["56\\d{8}"]]], "JM": ["1", "011", "(?:[58]\\d\\d|658|900)\\d{7}", [10], 0, "1", 0, 0, 0, 0, "658|876"], "JO": ["962", "00", "(?:(?:[2689]|7\\d)\\d|32|427|53)\\d{6}", [8, 9], [["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["[2356]|87"], "(0$1)"], ["(\\d{3})(\\d{5,6})", "$1 $2", ["[89]"], "0$1"], ["(\\d{2})(\\d{7})", "$1 $2", ["70"], "0$1"], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["[47]"], "0$1"]], "0"], "JP": ["81", "010", "00[1-9]\\d{6,14}|[25-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}", [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [["(\\d{3})(\\d{3})(\\d{3})", "$1-$2-$3", ["(?:12|57|99)0"], "0$1"], ["(\\d{4})(\\d)(\\d{4})", "$1-$2-$3", ["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])", "1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]", "1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1-$2-$3", ["60"], "0$1"], ["(\\d)(\\d{4})(\\d{4})", "$1-$2-$3", ["3|4(?:2[09]|7[01])|6[1-9]", "3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1-$2-$3", ["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])", "1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]", "1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{4})", "$1-$2-$3", ["[14]|[289][2-9]|5[3-9]|7[2-4679]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1-$2-$3", ["800"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4})", "$1-$2-$3", ["[25-9]"], "0$1"]], "0", 0, "(000[2569]\\d{4,6})$|(?:(?:003768)0?)|0", "$1"], "KE": ["254", "000", "(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}", [7, 8, 9, 10], [["(\\d{2})(\\d{5,7})", "$1 $2", ["[24-6]"], "0$1"], ["(\\d{3})(\\d{6})", "$1 $2", ["[17]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[89]"], "0$1"]], "0"], "KG": ["996", "00", "8\\d{9}|[235-9]\\d{8}", [9, 10], [["(\\d{4})(\\d{5})", "$1 $2", ["3(?:1[346]|[24-79])"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[235-79]|88"], "0$1"], ["(\\d{3})(\\d{3})(\\d)(\\d{2,3})", "$1 $2 $3 $4", ["8"], "0$1"]], "0"], "KH": ["855", "00[14-9]", "1\\d{9}|[1-9]\\d{7,8}", [8, 9, 10], [["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[1-9]"], "0$1"], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["1"]]], "0"], "KI": ["686", "00", "(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}", [5, 8], 0, "0"], "KM": ["269", "00", "[3478]\\d{6}", [7], [["(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3", ["[3478]"]]]], "KN": ["1", "011", "(?:[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-7]\\d{6})$|1", "869$1", 0, "869"], "KP": ["850", "00|99", "85\\d{6}|(?:19\\d|[2-7])\\d{7}", [8, 10], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["8"], "0$1"], ["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["[2-7]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"], "0$1"]], "0"], "KR": ["82", "00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))", "00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}", [5, 6, 8, 9, 10, 11, 12, 13, 14], [["(\\d{2})(\\d{3,4})", "$1-$2", ["(?:3[1-3]|[46][1-4]|5[1-5])1"], "0$1"], ["(\\d{4})(\\d{4})", "$1-$2", ["1"]], ["(\\d)(\\d{3,4})(\\d{4})", "$1-$2-$3", ["2"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1-$2-$3", ["[36]0|8"], "0$1"], ["(\\d{2})(\\d{3,4})(\\d{4})", "$1-$2-$3", ["[1346]|5[1-5]"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4})", "$1-$2-$3", ["[57]"], "0$1"], ["(\\d{2})(\\d{5})(\\d{4})", "$1-$2-$3", ["5"], "0$1"]], "0", 0, "0(8(?:[1-46-8]|5\\d\\d))?"], "KW": ["965", "00", "18\\d{5}|(?:[2569]\\d|41)\\d{6}", [7, 8], [["(\\d{4})(\\d{3,4})", "$1 $2", ["[169]|2(?:[235]|4[1-35-9])|52"]], ["(\\d{3})(\\d{5})", "$1 $2", ["[245]"]]]], "KY": ["1", "011", "(?:345|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "345$1", 0, "345"], "KZ": ["7", "810", "8\\d{13}|[78]\\d{9}", [10, 14], 0, "8", 0, 0, 0, 0, "7", 0, "8~10"], "LA": ["856", "00", "[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}", [8, 9, 10], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["2[13]|3[14]|[4-8]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3 $4", ["3"], "0$1"], ["(\\d{2})(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["[23]"], "0$1"]], "0"], "LB": ["961", "00", "[27-9]\\d{7}|[13-9]\\d{6}", [7, 8], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["[13-69]|7(?:[2-57]|62|8[0-6]|9[04-9])|8[02-9]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[27-9]"]]], "0"], "LC": ["1", "011", "(?:[58]\\d\\d|758|900)\\d{7}", [10], 0, "1", 0, "([2-8]\\d{6})$|1", "758$1", 0, "758"], "LI": ["423", "00", "[68]\\d{8}|(?:[2378]\\d|90)\\d{5}", [7, 9], [["(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3", ["[2379]|8(?:0[09]|7)", "[2379]|8(?:0(?:02|9)|7)"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["8"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["69"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["6"]]], "0", 0, "(1001)|0"], "LK": ["94", "00", "[1-9]\\d{8}", [9], [["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["7"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[1-689]"], "0$1"]], "0"], "LR": ["231", "00", "(?:[2457]\\d|33|88)\\d{7}|(?:2\\d|[4-6])\\d{6}", [7, 8, 9], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["4[67]|[56]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[2-578]"], "0$1"]], "0"], "LS": ["266", "00", "(?:[256]\\d\\d|800)\\d{5}", [8], [["(\\d{4})(\\d{4})", "$1 $2", ["[2568]"]]]], "LT": ["370", "00", "(?:[3469]\\d|52|[78]0)\\d{6}", [8], [["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["52[0-7]"], "(0-$1)", 1], ["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["[7-9]"], "0 $1", 1], ["(\\d{2})(\\d{6})", "$1 $2", ["37|4(?:[15]|6[1-8])"], "(0-$1)", 1], ["(\\d{3})(\\d{5})", "$1 $2", ["[3-6]"], "(0-$1)", 1]], "0", 0, "[08]"], "LU": ["352", "00", "35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}", [4, 5, 6, 7, 8, 9, 10, 11], [["(\\d{2})(\\d{3})", "$1 $2", ["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]], ["(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3", ["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]], ["(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3", ["20[2-689]"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})", "$1 $2 $3 $4", ["20"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})", "$1 $2 $3 $4", ["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]], ["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["80[01]|90[015]"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3 $4", ["20"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["6"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})", "$1 $2 $3 $4 $5", ["20"]]], 0, 0, "(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"], "LV": ["371", "00", "(?:[268]\\d|78|90)\\d{6}", [8], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[2679]|8[01]"]]]], "LY": ["218", "00", "[2-9]\\d{8}", [9], [["(\\d{2})(\\d{7})", "$1-$2", ["[2-9]"], "0$1"]], "0"], "MA": ["212", "00", "[5-8]\\d{8}", [9], [["(\\d{4})(\\d{5})", "$1-$2", ["892"], "0$1"], ["(\\d{2})(\\d{7})", "$1-$2", ["8(?:0[0-7]|9)"], "0$1"], ["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["[5-8]"], "0$1"]], "0", 0, 0, 0, 0, "[5-8]"], "MC": ["377", "00", "(?:[3489]|[67]\\d)\\d{7}", [8, 9], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["4"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[389]"]], ["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["[67]"], "0$1"]], "0"], "MD": ["373", "00", "(?:[235-7]\\d|[89]0)\\d{6}", [8], [["(\\d{3})(\\d{5})", "$1 $2", ["[89]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["22|3"], "0$1"], ["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["[25-7]"], "0$1"]], "0"], "ME": ["382", "00", "(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}", [8, 9], [["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[2-9]"], "0$1"]], "0"], "MF": ["590", "00", "7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}", [9], 0, "0", 0, 0, 0, 0, 0, [["(?:59(?:0(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"], ["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"], ["80[0-5]\\d{6}"], ["8[129]\\d{7}"], 0, 0, 0, 0, ["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]], "MG": ["261", "00", "[23]\\d{8}", [9], [["(\\d{2})(\\d{2})(\\d{3})(\\d{2})", "$1 $2 $3 $4", ["[23]"], "0$1"]], "0", 0, "([24-9]\\d{6})$|0", "20$1"], "MH": ["692", "011", "329\\d{4}|(?:[256]\\d|45)\\d{5}", [7], [["(\\d{3})(\\d{4})", "$1-$2", ["[2-6]"]]], "1"], "MK": ["389", "00", "[2-578]\\d{7}", [8], [["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["2|34[47]|4(?:[37]7|5[47]|64)"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[347]"], "0$1"], ["(\\d{3})(\\d)(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[58]"], "0$1"]], "0"], "ML": ["223", "00", "[24-9]\\d{7}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[24-9]"]]]], "MM": ["95", "00", "1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}", [6, 7, 8, 9, 10], [["(\\d)(\\d{2})(\\d{3})", "$1 $2 $3", ["16|2"], "0$1"], ["(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3", ["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"], "0$1"], ["(\\d)(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[12]|452|678|86", "[12]|452|6788|86"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[4-7]|8[1-35]"], "0$1"], ["(\\d)(\\d{3})(\\d{4,6})", "$1 $2 $3", ["9(?:2[0-4]|[35-9]|4[137-9])"], "0$1"], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["8"], "0$1"], ["(\\d)(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["92"], "0$1"], ["(\\d)(\\d{5})(\\d{4})", "$1 $2 $3", ["9"], "0$1"]], "0"], "MN": ["976", "001", "[12]\\d{7,9}|[5-9]\\d{7}", [8, 9, 10], [["(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3", ["11|2[16]"], "0$1"], ["(\\d{4})(\\d{4})", "$1 $2", ["[5-9]"]], ["(\\d{3})(\\d{5,6})", "$1 $2", ["[12]2[1-3]"], "0$1"], ["(\\d{4})(\\d{5,6})", "$1 $2", ["[12](?:27|3[2-8]|4[2-68]|5[1-4689])", "[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"], "0$1"], ["(\\d{5})(\\d{4,5})", "$1 $2", ["[12]"], "0$1"]], "0"], "MO": ["853", "00", "0800\\d{3}|(?:28|[68]\\d)\\d{6}", [7, 8], [["(\\d{4})(\\d{3})", "$1 $2", ["0"]], ["(\\d{4})(\\d{4})", "$1 $2", ["[268]"]]]], "MP": ["1", "011", "[58]\\d{9}|(?:67|90)0\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "670$1", 0, "670"], "MQ": ["596", "00", "7091\\d{5}|(?:[56]9|[89]\\d)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[5-79]|8(?:0[6-9]|[36])"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"], "0$1"]], "0"], "MR": ["222", "00", "(?:[2-4]\\d\\d|800)\\d{5}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2-48]"]]]], "MS": ["1", "011", "(?:[58]\\d\\d|664|900)\\d{7}", [10], 0, "1", 0, "([34]\\d{6})$|1", "664$1", 0, "664"], "MT": ["356", "00", "3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}", [8], [["(\\d{4})(\\d{4})", "$1 $2", ["[2357-9]"]]]], "MU": ["230", "0(?:0|[24-7]0|3[03])", "(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}", [7, 8, 10], [["(\\d{3})(\\d{4})", "$1 $2", ["[2-46]|8[013]"]], ["(\\d{4})(\\d{4})", "$1 $2", ["[57]"]], ["(\\d{5})(\\d{5})", "$1 $2", ["8"]]], 0, 0, 0, 0, 0, 0, 0, "020"], "MV": ["960", "0(?:0|19)", "(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}", [7, 10], [["(\\d{3})(\\d{4})", "$1-$2", ["[34679]"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["[89]"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "MW": ["265", "00", "(?:[1289]\\d|31|77)\\d{7}|1\\d{6}", [7, 9], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["1[2-9]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[1-37-9]"], "0$1"]], "0"], "MX": ["52", "0[09]", "[2-9]\\d{9}", [10], [["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["33|5[56]|81"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["[2-9]"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "MY": ["60", "00", "1\\d{8,9}|(?:3\\d|[4-9])\\d{7}", [8, 9, 10], [["(\\d)(\\d{3})(\\d{4})", "$1-$2 $3", ["[4-79]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1-$2 $3", ["1(?:[02469]|[378][1-9]|53)|8", "1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"], "0$1"], ["(\\d)(\\d{4})(\\d{4})", "$1-$2 $3", ["3"], "0$1"], ["(\\d)(\\d{3})(\\d{2})(\\d{4})", "$1-$2-$3-$4", ["1(?:[367]|80)"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1-$2 $3", ["15"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4})", "$1-$2 $3", ["1"], "0$1"]], "0"], "MZ": ["258", "00", "(?:2|8\\d)\\d{7}", [8, 9], [["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["2|8[2-9]"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["8"]]]], "NA": ["264", "00", "[68]\\d{7,8}", [8, 9], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["88"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["6"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["87"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["8"], "0$1"]], "0"], "NC": ["687", "00", "(?:050|[2-57-9]\\d\\d)\\d{3}", [6], [["(\\d{2})(\\d{2})(\\d{2})", "$1.$2.$3", ["[02-57-9]"]]]], "NE": ["227", "00", "[027-9]\\d{7}", [8], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["08"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[089]|2[013]|7[0467]"]]]], "NF": ["672", "00", "[13]\\d{5}", [6], [["(\\d{2})(\\d{4})", "$1 $2", ["1[0-3]"]], ["(\\d)(\\d{5})", "$1 $2", ["[13]"]]], 0, 0, "([0-258]\\d{4})$", "3$1"], "NG": ["234", "009", "(?:20|9\\d)\\d{8}|[78]\\d{9,13}", [10, 11, 12, 13, 14], [["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[7-9]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["20[129]"], "0$1"], ["(\\d{4})(\\d{2})(\\d{4})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{3})(\\d{4})(\\d{4,5})", "$1 $2 $3", ["[78]"], "0$1"], ["(\\d{3})(\\d{5})(\\d{5,6})", "$1 $2 $3", ["[78]"], "0$1"]], "0"], "NI": ["505", "00", "(?:1800|[25-8]\\d{3})\\d{4}", [8], [["(\\d{4})(\\d{4})", "$1 $2", ["[125-8]"]]]], "NL": ["31", "00", "(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}", [5, 6, 7, 8, 9, 10, 11], [["(\\d{3})(\\d{4,7})", "$1 $2", ["[89]0"], "0$1"], ["(\\d{2})(\\d{7})", "$1 $2", ["66"], "0$1"], ["(\\d)(\\d{8})", "$1 $2", ["6"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[1-578]|91"], "0$1"], ["(\\d{3})(\\d{3})(\\d{5})", "$1 $2 $3", ["9"], "0$1"]], "0"], "NO": ["47", "00", "(?:0|[2-9]\\d{3})\\d{4}", [5, 8], [["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["8"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2-79]"]]], 0, 0, 0, 0, 0, "[02-689]|7[0-8]"], "NP": ["977", "00", "(?:1\\d|9)\\d{9}|[1-9]\\d{7}", [8, 10, 11], [["(\\d)(\\d{7})", "$1-$2", ["1[2-6]"], "0$1"], ["(\\d{2})(\\d{6})", "$1-$2", ["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"], "0$1"], ["(\\d{3})(\\d{7})", "$1-$2", ["9"]]], "0"], "NR": ["674", "00", "(?:222|444|(?:55|8\\d)\\d|666|777|999)\\d{4}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[24-9]"]]]], "NU": ["683", "00", "(?:[4-7]|888\\d)\\d{3}", [4, 7], [["(\\d{3})(\\d{4})", "$1 $2", ["8"]]]], "NZ": ["64", "0(?:0|161)", "[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}", [5, 6, 7, 8, 9, 10], [["(\\d{2})(\\d{3,8})", "$1 $2", ["8[1-79]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2,3})", "$1 $2 $3", ["50[036-8]|8|90", "50(?:[0367]|88)|8|90"], "0$1"], ["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["24|[346]|7[2-57-9]|9[2-9]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["2(?:10|74)|[589]"], "0$1"], ["(\\d{2})(\\d{3,4})(\\d{4})", "$1 $2 $3", ["1|2[028]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,5})", "$1 $2 $3", ["2(?:[169]|7[0-35-9])|7"], "0$1"]], "0", 0, 0, 0, 0, 0, 0, "00"], "OM": ["968", "00", "(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}", [7, 8, 9], [["(\\d{3})(\\d{4,6})", "$1 $2", ["[58]"]], ["(\\d{2})(\\d{6})", "$1 $2", ["2"]], ["(\\d{4})(\\d{4})", "$1 $2", ["[179]"]]]], "PA": ["507", "00", "(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}", [7, 8, 10, 11], [["(\\d{3})(\\d{4})", "$1-$2", ["[1-57-9]"]], ["(\\d{4})(\\d{4})", "$1-$2", ["[68]"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["8"]]]], "PE": ["51", "00|19(?:1[124]|77|90)00", "(?:[14-8]|9\\d)\\d{7}", [8, 9], [["(\\d{3})(\\d{5})", "$1 $2", ["80"], "(0$1)"], ["(\\d)(\\d{7})", "$1 $2", ["1"], "(0$1)"], ["(\\d{2})(\\d{6})", "$1 $2", ["[4-8]"], "(0$1)"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["9"]]], "0", 0, 0, 0, 0, 0, 0, "00", " Anexo "], "PF": ["689", "00", "4\\d{5}(?:\\d{2})?|8\\d{7,8}", [6, 8, 9], [["(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3", ["44"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["4|8[7-9]"]], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"]]]], "PG": ["675", "00|140[1-3]", "(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}", [7, 8], [["(\\d{3})(\\d{4})", "$1 $2", ["18|[2-69]|85[02-46-9]"]], ["(\\d{4})(\\d{4})", "$1 $2", ["[78]"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "PH": ["63", "00", "(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}", [6, 8, 9, 10, 11, 12, 13], [["(\\d)(\\d{5})", "$1 $2", ["2"], "(0$1)"], ["(\\d{4})(\\d{4,6})", "$1 $2", ["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2", "3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"], "(0$1)"], ["(\\d{5})(\\d{4})", "$1 $2", ["346|4(?:27|9[35])|883", "3469|4(?:279|9(?:30|56))|8834"], "(0$1)"], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["2"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[3-7]|8[2-8]"], "(0$1)"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["[89]"], "0$1"], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"]], ["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})", "$1 $2 $3 $4", ["1"]]], "0"], "PK": ["92", "00", "122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}", [8, 9, 10, 11, 12], [["(\\d{3})(\\d{3})(\\d{2,7})", "$1 $2 $3", ["[89]0"], "0$1"], ["(\\d{4})(\\d{5})", "$1 $2", ["1"]], ["(\\d{3})(\\d{6,7})", "$1 $2", ["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])", "9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"], "(0$1)"], ["(\\d{2})(\\d{7,8})", "$1 $2", ["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"], "(0$1)"], ["(\\d{5})(\\d{5})", "$1 $2", ["58"], "(0$1)"], ["(\\d{3})(\\d{7})", "$1 $2", ["3"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"], "(0$1)"], ["(\\d{3})(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["[24-9]"], "(0$1)"]], "0"], "PL": ["48", "00", "(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}", [6, 7, 8, 9, 10], [["(\\d{5})", "$1", ["19"]], ["(\\d{3})(\\d{3})", "$1 $2", ["11|20|64"]], ["(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3", ["30|(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1", "30|(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]], ["(\\d{3})(\\d{2})(\\d{2,3})", "$1 $2 $3", ["64"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["1[2-8]|[2-7]|8[1-79]|9[145]"]], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["8"]]]], "PM": ["508", "00", "[78]\\d{8}|[2-9]\\d{5}", [6, 9], [["(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3", ["[2-9]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["7"]], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"], "0$1"]], "0"], "PR": ["1", "011", "(?:[589]\\d\\d|787)\\d{7}", [10], 0, "1", 0, 0, 0, 0, "787|939"], "PS": ["970", "00", "[2489]2\\d{6}|(?:1\\d|5)\\d{8}", [8, 9, 10], [["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["[2489]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["5"], "0$1"], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["1"]]], "0"], "PT": ["351", "00", "1693\\d{5}|(?:[26-9]\\d|30)\\d{7}", [9], [["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["2[12]"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["16|[236-9]"]]]], "PW": ["680", "01[12]", "(?:[24-8]\\d\\d|345|900)\\d{4}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[2-9]"]]]], "PY": ["595", "00", "[36-8]\\d{5,8}|4\\d{6,8}|59\\d{6}|9\\d{5,10}|(?:2\\d|5[0-8])\\d{6,7}", [6, 7, 8, 9, 10, 11], [["(\\d{3})(\\d{3,6})", "$1 $2", ["[2-9]0"], "0$1"], ["(\\d{2})(\\d{5})", "$1 $2", ["3[289]|4[246-8]|61|7[1-3]|8[1-36]"], "(0$1)"], ["(\\d{3})(\\d{4,5})", "$1 $2", ["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["87"]], ["(\\d{3})(\\d{6})", "$1 $2", ["9(?:[5-79]|8[1-7])"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[2-8]"], "0$1"], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["9"]]], "0"], "QA": ["974", "00", "800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}", [7, 8, 9, 11], [["(\\d{3})(\\d{4})", "$1 $2", ["2[136]|8"]], ["(\\d{4})(\\d{4})", "$1 $2", ["[3-7]"]]]], "RE": ["262", "00", "709\\d{6}|(?:26|[689]\\d)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[26-9]"], "0$1"]], "0", 0, 0, 0, 0, 0, [["2631[0-6]\\d{4}|26(?:2\\d|30|88)\\d{5}"], ["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[0-3]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"], ["80\\d{7}"], ["89[1-37-9]\\d{6}"], 0, 0, 0, 0, ["9(?:399[0-3]|479[0-6]|76(?:2[278]|3[0-37]))\\d{4}"], ["8(?:1[019]|2[0156]|84|90)\\d{6}"]]], "RO": ["40", "00", "(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}", [6, 9], [["(\\d{3})(\\d{3})", "$1 $2", ["2[3-6]", "2[3-6]\\d9"], "0$1"], ["(\\d{2})(\\d{4})", "$1 $2", ["219|31"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[23]1"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[236-9]"], "0$1"]], "0", 0, 0, 0, 0, 0, 0, 0, " int "], "RS": ["381", "00", "38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}", [6, 7, 8, 9, 10, 11, 12], [["(\\d{3})(\\d{3,9})", "$1 $2", ["(?:2[389]|39)0|[7-9]"], "0$1"], ["(\\d{2})(\\d{5,10})", "$1 $2", ["[1-36]"], "0$1"]], "0"], "RU": ["7", "810", "8\\d{13}|[347-9]\\d{9}", [10, 14], [["(\\d{4})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["7(?:1[0-8]|2[1-9])", "7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))", "7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"], "8 ($1)", 1], ["(\\d{5})(\\d)(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["7(?:1[0-68]|2[1-9])", "7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))", "7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"], "8 ($1)", 1], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["7"], "8 ($1)", 1], ["(\\d{3})(\\d{3})(\\d{2})(\\d{2})", "$1 $2-$3-$4", ["[349]|8(?:[02-7]|1[1-8])"], "8 ($1)", 1], ["(\\d{4})(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["8"], "8 ($1)"]], "8", 0, 0, 0, 0, "[3489]", 0, "8~10"], "RW": ["250", "00", "(?:06|[27]\\d\\d|[89]00)\\d{6}", [8, 9], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["0"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["2"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[7-9]"], "0$1"]], "0"], "SA": ["966", "00", "(?:[15]\\d|800|92)\\d{7}", [9, 10], [["(\\d{4})(\\d{5})", "$1 $2", ["9"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["5"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["8"]]], "0"], "SB": ["677", "0[01]", "[6-9]\\d{6}|[1-6]\\d{4}", [5, 7], [["(\\d{2})(\\d{5})", "$1 $2", ["6[89]|7|8[4-9]|9(?:[0-8]|9[0-8])"]]]], "SC": ["248", "010|0[0-2]", "(?:[2489]\\d|64)\\d{5}", [7], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["[246]|9[57]"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "SD": ["249", "00", "[19]\\d{8}", [9], [["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[19]"], "0$1"]], "0"], "SE": ["46", "00", "(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}", [6, 7, 8, 9, 10, 12], [["(\\d{2})(\\d{2,3})(\\d{2})", "$1-$2 $3", ["20"], "0$1", 0, "$1 $2 $3"], ["(\\d{3})(\\d{4})", "$1-$2", ["9(?:00|39|44|9)"], "0$1", 0, "$1 $2"], ["(\\d{2})(\\d{3})(\\d{2})", "$1-$2 $3", ["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"], "0$1", 0, "$1 $2 $3"], ["(\\d)(\\d{2,3})(\\d{2})(\\d{2})", "$1-$2 $3 $4", ["8"], "0$1", 0, "$1 $2 $3 $4"], ["(\\d{3})(\\d{2,3})(\\d{2})", "$1-$2 $3", ["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"], "0$1", 0, "$1 $2 $3"], ["(\\d{3})(\\d{2,3})(\\d{3})", "$1-$2 $3", ["9(?:00|39|44)"], "0$1", 0, "$1 $2 $3"], ["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})", "$1-$2 $3 $4", ["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"], "0$1", 0, "$1 $2 $3 $4"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1-$2 $3 $4", ["10|7"], "0$1", 0, "$1 $2 $3 $4"], ["(\\d)(\\d{3})(\\d{3})(\\d{2})", "$1-$2 $3 $4", ["8"], "0$1", 0, "$1 $2 $3 $4"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1-$2 $3 $4", ["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"], "0$1", 0, "$1 $2 $3 $4"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{3})", "$1-$2 $3 $4", ["9"], "0$1", 0, "$1 $2 $3 $4"], ["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1-$2 $3 $4 $5", ["[26]"], "0$1", 0, "$1 $2 $3 $4 $5"]], "0"], "SG": ["65", "0[0-3]\\d", "(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}", [8, 10, 11], [["(\\d{4})(\\d{4})", "$1 $2", ["[369]|8(?:0[1-9]|[1-9])"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["8"]], ["(\\d{4})(\\d{4})(\\d{3})", "$1 $2 $3", ["7"]], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"]]]], "SH": ["290", "00", "(?:[256]\\d|8)\\d{3}", [4, 5], 0, 0, 0, 0, 0, 0, "[256]"], "SI": ["386", "00|10(?:22|66|88|99)", "[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}", [5, 6, 7, 8], [["(\\d{2})(\\d{3,6})", "$1 $2", ["8[09]|9"], "0$1"], ["(\\d{3})(\\d{5})", "$1 $2", ["59|8"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[37][01]|4[013]|51|6"], "0$1"], ["(\\d)(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[1-57]"], "(0$1)"]], "0", 0, 0, 0, 0, 0, 0, "00"], "SJ": ["47", "00", "0\\d{4}|(?:[489]\\d|79)\\d{6}", [5, 8], 0, 0, 0, 0, 0, 0, "79"], "SK": ["421", "00", "[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}", [6, 7, 9], [["(\\d)(\\d{2})(\\d{3,4})", "$1 $2 $3", ["21"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2,3})", "$1 $2 $3", ["[3-5][1-8]1", "[3-5][1-8]1[67]"], "0$1"], ["(\\d)(\\d{3})(\\d{3})(\\d{2})", "$1 $2 $3 $4", ["2"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[689]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[3-5]"], "0$1"]], "0"], "SL": ["232", "00", "(?:[237-9]\\d|66)\\d{6}", [8], [["(\\d{2})(\\d{6})", "$1 $2", ["[236-9]"], "(0$1)"]], "0"], "SM": ["378", "00", "(?:0549|[5-7]\\d)\\d{6}", [8, 10], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[5-7]"]], ["(\\d{4})(\\d{6})", "$1 $2", ["0"]]], 0, 0, "([89]\\d{5})$", "0549$1"], "SN": ["221", "00", "(?:[378]\\d|93)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"]], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[379]"]]]], "SO": ["252", "00", "[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}", [6, 7, 8, 9], [["(\\d{2})(\\d{4})", "$1 $2", ["8[125]"]], ["(\\d{6})", "$1", ["[134]"]], ["(\\d)(\\d{6})", "$1 $2", ["[15]|2[0-79]|3[0-46-8]|4[0-7]"]], ["(\\d{2})(\\d{5,7})", "$1 $2", ["1|28|9[2-9]"]], ["(\\d)(\\d{7})", "$1 $2", ["[267]|904"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[346-9]"]]], "0"], "SR": ["597", "00", "(?:[2-5]|[6-9]\\d)\\d{5}", [6, 7], [["(\\d{2})(\\d{2})(\\d{2})", "$1-$2-$3", ["56"]], ["(\\d{3})(\\d{3})", "$1-$2", ["[2-5]"]], ["(\\d{3})(\\d{4})", "$1-$2", ["[6-9]"]]]], "SS": ["211", "00", "[19]\\d{8}", [9], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[19]"], "0$1"]], "0"], "ST": ["239", "00", "(?:22|9\\d)\\d{5}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[29]"]]]], "SV": ["503", "00", "[25-7]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?", [7, 8, 11], [["(\\d{3})(\\d{4})", "$1 $2", ["[89]"]], ["(\\d{4})(\\d{4})", "$1 $2", ["[25-7]"]], ["(\\d{3})(\\d{4})(\\d{4})", "$1 $2 $3", ["[89]"]]]], "SX": ["1", "011", "7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "(5\\d{6})$|1", "721$1", 0, "721"], "SY": ["963", "00", "[1-359]\\d{8}|[1-5]\\d{7}", [8, 9], [["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[1-4]|5[1-3]"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[59]"], "0$1", 1]], "0"], "SZ": ["268", "00", "0800\\d{4}|(?:[237]\\d|900)\\d{6}", [8, 9], [["(\\d{4})(\\d{4})", "$1 $2", ["[0237]"]], ["(\\d{5})(\\d{4})", "$1 $2", ["9"]]]], "TA": ["290", "00", "8\\d{3}", [4], 0, 0, 0, 0, 0, 0, "8"], "TC": ["1", "011", "(?:[58]\\d\\d|649|900)\\d{7}", [10], 0, "1", 0, "([2-479]\\d{6})$|1", "649$1", 0, "649"], "TD": ["235", "00|16", "(?:22|[3689]\\d|77)\\d{6}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[236-9]"]]], 0, 0, 0, 0, 0, 0, 0, "00"], "TG": ["228", "00", "[279]\\d{7}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[279]"]]]], "TH": ["66", "00[1-9]", "(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}", [8, 9, 10, 13], [["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[13-9]"], "0$1"], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["1"]]], "0"], "TJ": ["992", "810", "(?:[0-57-9]\\d|66)\\d{7}", [9], [["(\\d{6})(\\d)(\\d{2})", "$1 $2 $3", ["331", "3317"]], ["(\\d{3})(\\d{2})(\\d{4})", "$1 $2 $3", ["44[02-479]|[34]7"]], ["(\\d{4})(\\d)(\\d{4})", "$1 $2 $3", ["3(?:[1245]|3[12])"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["\\d"]]], 0, 0, 0, 0, 0, 0, 0, "8~10"], "TK": ["690", "00", "[2-47]\\d{3,6}", [4, 5, 6, 7]], "TL": ["670", "00", "7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}", [7, 8], [["(\\d{3})(\\d{4})", "$1 $2", ["[2-489]|70"]], ["(\\d{4})(\\d{4})", "$1 $2", ["7"]]]], "TM": ["993", "810", "[1-7]\\d{7}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2-$3-$4", ["12"], "(8 $1)"], ["(\\d{3})(\\d)(\\d{2})(\\d{2})", "$1 $2-$3-$4", ["[1-5]"], "(8 $1)"], ["(\\d{2})(\\d{6})", "$1 $2", ["[67]"], "8 $1"]], "8", 0, 0, 0, 0, 0, 0, "8~10"], "TN": ["216", "00", "[2-57-9]\\d{7}", [8], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[2-57-9]"]]]], "TO": ["676", "00", "(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}", [5, 7], [["(\\d{2})(\\d{3})", "$1-$2", ["[2-4]|50|6[09]|7[0-24-69]|8[05]"]], ["(\\d{4})(\\d{3})", "$1 $2", ["0"]], ["(\\d{3})(\\d{4})", "$1 $2", ["[5-9]"]]]], "TR": ["90", "00", "4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}", [7, 10, 12, 13], [["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["512|8[01589]|90"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["5"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[24][1-8]|3[1-9]"], "(0$1)", 1], ["(\\d{3})(\\d{3})(\\d{6,7})", "$1 $2 $3", ["80"], "0$1", 1]], "0"], "TT": ["1", "011", "(?:[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-46-8]\\d{6})$|1", "868$1", 0, "868"], "TV": ["688", "00", "(?:2|7\\d\\d|90)\\d{4}", [5, 6, 7], [["(\\d{2})(\\d{3})", "$1 $2", ["2"]], ["(\\d{2})(\\d{4})", "$1 $2", ["90"]], ["(\\d{2})(\\d{5})", "$1 $2", ["7"]]]], "TW": ["886", "0(?:0[25-79]|19)", "[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}", [7, 8, 9, 10, 11], [["(\\d{2})(\\d)(\\d{4})", "$1 $2 $3", ["202"], "0$1"], ["(\\d{3})(\\d{5})", "$1 $2", ["826"], "0$1"], ["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["83"], "0$1"], ["(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3", ["82"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[25]0|37|49|8[09]"], "0$1"], ["(\\d)(\\d{3,4})(\\d{4})", "$1 $2 $3", ["[23568]|4(?:0[02-48]|[1-478])|7[1-9]", "[23568]|4(?:0[2-48]|[1-478])|(?:400|7)[1-9]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[49]"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4,5})", "$1 $2 $3", ["7"], "0$1"]], "0", 0, 0, 0, 0, 0, 0, 0, "#"], "TZ": ["255", "00[056]", "(?:[25-8]\\d|41|90)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{4})", "$1 $2 $3", ["[89]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[24]"], "0$1"], ["(\\d{2})(\\d{7})", "$1 $2", ["5"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[67]"], "0$1"]], "0"], "UA": ["380", "00", "[89]\\d{9}|[3-9]\\d{8}", [9, 10], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]", "6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"], "0$1"], ["(\\d{4})(\\d{5})", "$1 $2", ["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])", "3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[3-7]|89|9[1-9]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[89]"], "0$1"]], "0", 0, 0, 0, 0, 0, 0, "0~0"], "UG": ["256", "00[057]", "800\\d{6}|(?:[29]0|[347]\\d)\\d{7}", [9], [["(\\d{4})(\\d{5})", "$1 $2", ["202", "2024", "20240"], "0$1"], ["(\\d{3})(\\d{6})", "$1 $2", ["20[0-35-7]|4(?:6[45]|[7-9])|[7-9]", "20(?:[0135-7]|2[5-9])|4(?:6[45]|[7-9])|[7-9]"], "0$1"], ["(\\d{2})(\\d{7})", "$1 $2", ["[2-4]"], "0$1"]], "0"], "US": ["1", "011", "[2-9]\\d{9}|3\\d{6}", [10], [["(\\d{3})(\\d{4})", "$1-$2", ["310"], 0, 1], ["(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3", ["[2-9]"], 0, 1, "$1-$2-$3"]], "1", 0, 0, 0, 0, 0, [["983[2-57-9]\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[02469]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013-79]|3[0-24679]|4[167]|5[0-3]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[02589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-2478]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}"], [""], ["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"], ["900[2-9]\\d{6}"], ["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|3[23]|44|66|77|88)[2-9]\\d{6}"]]], "UY": ["598", "0(?:0|1[3-9]\\d)", "0004\\d{2,9}|[1249]\\d{7}|2\\d{3,4}|(?:[49]\\d|80)\\d{5}", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [["(\\d{4,5})", "$1", ["21"]], ["(\\d{3})(\\d{3,4})", "$1 $2", ["0"]], ["(\\d{3})(\\d{4})", "$1 $2", ["[49]0|8"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["9"], "0$1"], ["(\\d{4})(\\d{4})", "$1 $2", ["[124]"]], ["(\\d{3})(\\d{3})(\\d{2,4})", "$1 $2 $3", ["0"]], ["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})", "$1 $2 $3 $4", ["0"]]], "0", 0, 0, 0, 0, 0, 0, "00", " int. "], "UZ": ["998", "00", "(?:20|33|[5-9]\\d)\\d{7}", [9], [["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[235-9]"]]]], "VA": ["39", "00", "0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}", [6, 7, 8, 9, 10, 11, 12], 0, 0, 0, 0, 0, 0, "06698"], "VC": ["1", "011", "(?:[58]\\d\\d|784|900)\\d{7}", [10], 0, "1", 0, "([2-7]\\d{6})$|1", "784$1", 0, "784"], "VE": ["58", "00", "[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}", [10], [["(\\d{3})(\\d{7})", "$1-$2", ["[24-689]"], "0$1"]], "0"], "VG": ["1", "011", "(?:284|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-578]\\d{6})$|1", "284$1", 0, "284"], "VI": ["1", "011", "[58]\\d{9}|(?:34|90)0\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "340$1", 0, "340"], "VN": ["84", "00", "[12]\\d{9}|[135-9]\\d{8}|[16]\\d{6,7}|7\\d{6}", [7, 8, 9, 10], [["(\\d{4})(\\d{4,6})", "$1 $2", ["1(?:2[02]|[89])"], 0, 1], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["1[26]|6"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[1357-9]"], "0$1", 1], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["2[48]"], "0$1", 1], ["(\\d{3})(\\d{4})(\\d{3})", "$1 $2 $3", ["2"], "0$1", 1]], "0"], "VU": ["678", "00", "[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}", [5, 7], [["(\\d{3})(\\d{4})", "$1 $2", ["[57-9]"]]]], "WF": ["681", "00", "(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}", [6, 9], [["(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3", ["[47-9]"]], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["8"]]]], "WS": ["685", "0", "(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}", [5, 6, 7, 10], [["(\\d{5})", "$1", ["[2-5]|6[1-9]"]], ["(\\d{3})(\\d{3,7})", "$1 $2", ["[68]"]], ["(\\d{2})(\\d{5})", "$1 $2", ["7"]]]], "XK": ["383", "00", "2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}", [8, 9, 10, 11, 12], [["(\\d{3})(\\d{5})", "$1 $2", ["[89]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[2-4]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["2|39"], "0$1"], ["(\\d{2})(\\d{7,10})", "$1 $2", ["3"], "0$1"]], "0"], "YE": ["967", "00", "(?:1|7\\d)\\d{7}|[1-7]\\d{6}", [7, 8, 9], [["(\\d)(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[1-6]|7(?:[24-6]|8[0-7])"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["7"], "0$1"]], "0"], "YT": ["262", "00", "(?:639\\d|7093)\\d{5}|(?:26|80|9\\d)\\d{7}", [9], 0, "0", 0, 0, 0, 0, 0, [["26(?:89\\d|9(?:0[0-467]|15|5[0-4]|6\\d|[78]0))\\d{4}"], ["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"], ["80\\d{7}"], 0, 0, 0, 0, 0, ["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]], "ZA": ["27", "00", "[1-79]\\d{8}|8\\d{4,9}", [5, 6, 7, 8, 9, 10], [["(\\d{2})(\\d{3,4})", "$1 $2", ["8[1-4]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2,3})", "$1 $2 $3", ["8[1-4]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["860"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[1-9]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["8"], "0$1"]], "0"], "ZM": ["260", "00", "800\\d{6}|(?:21|[579]\\d|63)\\d{7}", [9], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[28]"], "0$1"], ["(\\d{2})(\\d{7})", "$1 $2", ["[579]"], "0$1"]], "0"], "ZW": ["263", "00", "(?:13|8\\d{4})\\d{5}|[235-8]\\d{8}|[23568]\\d{6}", [7, 9, 10], [["(\\d{2})(\\d{3,5})", "$1 $2", ["1|2(?:0[0-36-9]|29|58)|67[0-46-9]|(?:55|68)[0-69]"], "0$1"], ["(\\d{3})(\\d{3,5})", "$1 $2", ["2(?:0[45]|[27]|48)|37|675|(?:55|68)[78]"], "0$1"], ["(\\d{3})(\\d{4})", "$1 $2", ["80"], "0$1"], ["(\\d{4})(\\d{3,5})", "$1 $2", ["548"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["29[013-9]"], "0$1"], ["(\\d{2})(\\d{7})", "$1 $2", ["[256]|39|8[13-59]"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["7"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["3"], "0$1"], ["(\\d{4})(\\d{6})", "$1 $2", ["8"], "0$1"]], "0"] }, "nonGeographic": { "800": ["800", 0, "(?:00|[1-9]\\d)\\d{6}", [8], [["(\\d{4})(\\d{4})", "$1 $2", ["\\d"]]], 0, 0, 0, 0, 0, 0, [0, 0, ["(?:00|[1-9]\\d)\\d{6}"]]], "808": ["808", 0, "[1-9]\\d{7}", [8], [["(\\d{4})(\\d{4})", "$1 $2", ["[1-9]"]]], 0, 0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0, 0, 0, 0, ["[1-9]\\d{7}"]]], "870": ["870", 0, "7\\d{11}|[235-7]\\d{8}", [9, 12], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[235-7]"]]], 0, 0, 0, 0, 0, 0, [0, ["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"], 0, 0, 0, 0, 0, 0, ["2\\d{8}", [9]]]], "878": ["878", 0, "10\\d{10}", [12], [["(\\d{2})(\\d{5})(\\d{5})", "$1 $2 $3", ["1"]]], 0, 0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0, 0, 0, ["10\\d{10}"]]], "881": ["881", 0, "6\\d{9}|[0-36-9]\\d{8}", [9, 10], [["(\\d)(\\d{3})(\\d{5})", "$1 $2 $3", ["[0-37-9]"]], ["(\\d)(\\d{3})(\\d{5,6})", "$1 $2 $3", ["6"]]], 0, 0, 0, 0, 0, 0, [0, ["6\\d{9}|[0-36-9]\\d{8}"]]], "882": ["882", 0, "[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?", [7, 8, 9, 10, 11, 12], [["(\\d{2})(\\d{5})", "$1 $2", ["16|342"]], ["(\\d{2})(\\d{6})", "$1 $2", ["49"]], ["(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3", ["1[36]|9"]], ["(\\d{2})(\\d{4})(\\d{3})", "$1 $2 $3", ["3[23]"]], ["(\\d{2})(\\d{3,4})(\\d{4})", "$1 $2 $3", ["16"]], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2 $3", ["10|23|3(?:[15]|4[57])|4|5[12]"]], ["(\\d{3})(\\d{4})(\\d{4})", "$1 $2 $3", ["34"]], ["(\\d{2})(\\d{4,5})(\\d{5})", "$1 $2 $3", ["[1-35]"]]], 0, 0, 0, 0, 0, 0, [0, ["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|5(?:0\\d{3}|2[0-2]))\\d{7}", [7, 8, 9, 10, 12]], 0, 0, 0, ["348[57]\\d{7}", [11]], 0, 0, ["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]], "883": ["883", 0, "(?:[1-4]\\d|51)\\d{6,10}", [8, 9, 10, 11, 12], [["(\\d{3})(\\d{3})(\\d{2,8})", "$1 $2 $3", ["[14]|2[24-689]|3[02-689]|51[24-9]"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["510"]], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2 $3", ["21"]], ["(\\d{4})(\\d{4})(\\d{4})", "$1 $2 $3", ["51[13]"]], ["(\\d{3})(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["[235]"]]], 0, 0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0, 0, 0, ["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]], "888": ["888", 0, "\\d{11}", [11], [["(\\d{3})(\\d{3})(\\d{5})", "$1 $2 $3"]], 0, 0, 0, 0, 0, 0, [0, 0, 0, 0, 0, 0, ["\\d{11}"]]], "979": ["979", 0, "[1359]\\d{8}", [9], [["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["[1359]"]]], 0, 0, 0, 0, 0, 0, [0, 0, 0, ["[1359]\\d{8}"]]] } };
|
|
615
|
+
function withMetadataArgument(func, _arguments) {
|
|
616
|
+
var args = Array.prototype.slice.call(_arguments);
|
|
617
|
+
args.push(metadata);
|
|
618
|
+
return func.apply(this, args);
|
|
619
|
+
}
|
|
620
|
+
function compare(a, b) {
|
|
621
|
+
a = a.split("-");
|
|
622
|
+
b = b.split("-");
|
|
623
|
+
var pa = a[0].split(".");
|
|
624
|
+
var pb = b[0].split(".");
|
|
625
|
+
for (var i = 0; i < 3; i++) {
|
|
626
|
+
var na = Number(pa[i]);
|
|
627
|
+
var nb = Number(pb[i]);
|
|
628
|
+
if (na > nb) return 1;
|
|
629
|
+
if (nb > na) return -1;
|
|
630
|
+
if (!isNaN(na) && isNaN(nb)) return 1;
|
|
631
|
+
if (isNaN(na) && !isNaN(nb)) return -1;
|
|
632
|
+
}
|
|
633
|
+
if (a[1] && b[1]) {
|
|
634
|
+
return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
|
|
635
|
+
}
|
|
636
|
+
return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
|
|
637
|
+
}
|
|
638
|
+
var objectConstructor = {}.constructor;
|
|
639
|
+
function isObject(object) {
|
|
640
|
+
return object !== void 0 && object !== null && object.constructor === objectConstructor;
|
|
641
|
+
}
|
|
642
|
+
var CALLING_CODE_REG_EXP = /^\d+$/;
|
|
643
|
+
function isCallingCode(string) {
|
|
644
|
+
return CALLING_CODE_REG_EXP.test(string);
|
|
645
|
+
}
|
|
646
|
+
function _typeof$5(o) {
|
|
647
|
+
"@babel/helpers - typeof";
|
|
648
|
+
return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
649
|
+
return typeof o2;
|
|
650
|
+
} : function(o2) {
|
|
651
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
652
|
+
}, _typeof$5(o);
|
|
653
|
+
}
|
|
654
|
+
function _classCallCheck$2(a, n) {
|
|
655
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
656
|
+
}
|
|
657
|
+
function _defineProperties$1(e, r) {
|
|
658
|
+
for (var t = 0; t < r.length; t++) {
|
|
659
|
+
var o = r[t];
|
|
660
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$4(o.key), o);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function _createClass$2(e, r, t) {
|
|
664
|
+
return r && _defineProperties$1(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
|
|
665
|
+
}
|
|
666
|
+
function _toPropertyKey$4(t) {
|
|
667
|
+
var i = _toPrimitive$4(t, "string");
|
|
668
|
+
return "symbol" == _typeof$5(i) ? i : i + "";
|
|
669
|
+
}
|
|
670
|
+
function _toPrimitive$4(t, r) {
|
|
671
|
+
if ("object" != _typeof$5(t) || !t) return t;
|
|
672
|
+
var e = t[Symbol.toPrimitive];
|
|
673
|
+
if (void 0 !== e) {
|
|
674
|
+
var i = e.call(t, r);
|
|
675
|
+
if ("object" != _typeof$5(i)) return i;
|
|
676
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
677
|
+
}
|
|
678
|
+
return String(t);
|
|
679
|
+
}
|
|
680
|
+
var V3 = "1.2.0";
|
|
681
|
+
var V4 = "1.7.35";
|
|
682
|
+
var DEFAULT_EXT_PREFIX = " ext. ";
|
|
683
|
+
var Metadata = /* @__PURE__ */ (function() {
|
|
684
|
+
function Metadata2(metadata2) {
|
|
685
|
+
_classCallCheck$2(this, Metadata2);
|
|
686
|
+
validateMetadata(metadata2);
|
|
687
|
+
this.metadata = metadata2;
|
|
688
|
+
setVersion.call(this, metadata2);
|
|
689
|
+
}
|
|
690
|
+
return _createClass$2(Metadata2, [{
|
|
691
|
+
key: "getCountries",
|
|
692
|
+
value: function getCountries() {
|
|
693
|
+
return Object.keys(this.metadata.countries).filter(function(_) {
|
|
694
|
+
return _ !== "001";
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
}, {
|
|
698
|
+
key: "getCountryMetadata",
|
|
699
|
+
value: function getCountryMetadata(countryCode) {
|
|
700
|
+
return this.metadata.countries[countryCode];
|
|
701
|
+
}
|
|
702
|
+
}, {
|
|
703
|
+
key: "nonGeographic",
|
|
704
|
+
value: function nonGeographic() {
|
|
705
|
+
if (this.v1 || this.v2 || this.v3) return;
|
|
706
|
+
return this.metadata.nonGeographic || this.metadata.nonGeographical;
|
|
707
|
+
}
|
|
708
|
+
}, {
|
|
709
|
+
key: "hasCountry",
|
|
710
|
+
value: function hasCountry(country) {
|
|
711
|
+
return this.getCountryMetadata(country) !== void 0;
|
|
712
|
+
}
|
|
713
|
+
}, {
|
|
714
|
+
key: "hasCallingCode",
|
|
715
|
+
value: function hasCallingCode(callingCode) {
|
|
716
|
+
if (this.getCountryCodesForCallingCode(callingCode)) {
|
|
717
|
+
return true;
|
|
718
|
+
}
|
|
719
|
+
if (this.nonGeographic()) {
|
|
720
|
+
if (this.nonGeographic()[callingCode]) {
|
|
721
|
+
return true;
|
|
722
|
+
}
|
|
723
|
+
} else {
|
|
724
|
+
var countryCodes = this.countryCallingCodes()[callingCode];
|
|
725
|
+
if (countryCodes && countryCodes.length === 1 && countryCodes[0] === "001") {
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}, {
|
|
731
|
+
key: "isNonGeographicCallingCode",
|
|
732
|
+
value: function isNonGeographicCallingCode(callingCode) {
|
|
733
|
+
if (this.nonGeographic()) {
|
|
734
|
+
return this.nonGeographic()[callingCode] ? true : false;
|
|
735
|
+
} else {
|
|
736
|
+
return this.getCountryCodesForCallingCode(callingCode) ? false : true;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
// Deprecated.
|
|
740
|
+
}, {
|
|
741
|
+
key: "country",
|
|
742
|
+
value: function country(countryCode) {
|
|
743
|
+
return this.selectNumberingPlan(countryCode);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Selects a telephone numbering plan based on either a country code or a calling code.
|
|
747
|
+
* @param {string} argument — Country code or calling code.
|
|
748
|
+
* @param {string} legacyArgumentCallingCode — Legacy argument: calling code, if the first argument is not passed.
|
|
749
|
+
*/
|
|
750
|
+
}, {
|
|
751
|
+
key: "selectNumberingPlan",
|
|
752
|
+
value: function selectNumberingPlan(argument, legacyArgumentCallingCode) {
|
|
753
|
+
var countryCode;
|
|
754
|
+
var callingCode;
|
|
755
|
+
if (argument) {
|
|
756
|
+
if (isCallingCode(argument)) {
|
|
757
|
+
callingCode = argument;
|
|
758
|
+
} else {
|
|
759
|
+
countryCode = argument;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (legacyArgumentCallingCode) {
|
|
763
|
+
callingCode = legacyArgumentCallingCode;
|
|
764
|
+
}
|
|
765
|
+
if (countryCode && countryCode !== "001") {
|
|
766
|
+
var countryMetadata = this.getCountryMetadata(countryCode);
|
|
767
|
+
if (!countryMetadata) {
|
|
768
|
+
throw new Error("Unknown country: ".concat(countryCode));
|
|
769
|
+
}
|
|
770
|
+
this.numberingPlan = new NumberingPlan(countryMetadata, this);
|
|
771
|
+
} else if (callingCode) {
|
|
772
|
+
if (!this.hasCallingCode(callingCode)) {
|
|
773
|
+
throw new Error("Unknown calling code: ".concat(callingCode));
|
|
774
|
+
}
|
|
775
|
+
this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
|
|
776
|
+
} else {
|
|
777
|
+
this.numberingPlan = void 0;
|
|
778
|
+
}
|
|
779
|
+
return this;
|
|
780
|
+
}
|
|
781
|
+
}, {
|
|
782
|
+
key: "getCountryCodesForCallingCode",
|
|
783
|
+
value: function getCountryCodesForCallingCode(callingCode) {
|
|
784
|
+
var countryCodes = this.countryCallingCodes()[callingCode];
|
|
785
|
+
if (countryCodes) {
|
|
786
|
+
if (countryCodes.length === 1 && countryCodes[0].length === 3) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
return countryCodes;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}, {
|
|
793
|
+
key: "getCountryCodeForCallingCode",
|
|
794
|
+
value: function getCountryCodeForCallingCode(callingCode) {
|
|
795
|
+
var countryCodes = this.getCountryCodesForCallingCode(callingCode);
|
|
796
|
+
if (countryCodes) {
|
|
797
|
+
return countryCodes[0];
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}, {
|
|
801
|
+
key: "getNumberingPlanMetadata",
|
|
802
|
+
value: function getNumberingPlanMetadata(callingCode) {
|
|
803
|
+
var countryCode = this.getCountryCodeForCallingCode(callingCode);
|
|
804
|
+
if (countryCode) {
|
|
805
|
+
return this.getCountryMetadata(countryCode);
|
|
806
|
+
}
|
|
807
|
+
if (this.nonGeographic()) {
|
|
808
|
+
var metadata2 = this.nonGeographic()[callingCode];
|
|
809
|
+
if (metadata2) {
|
|
810
|
+
return metadata2;
|
|
811
|
+
}
|
|
812
|
+
} else {
|
|
813
|
+
var countryCodes = this.countryCallingCodes()[callingCode];
|
|
814
|
+
if (countryCodes && countryCodes.length === 1 && countryCodes[0] === "001") {
|
|
815
|
+
return this.metadata.countries["001"];
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
// Deprecated.
|
|
820
|
+
}, {
|
|
821
|
+
key: "countryCallingCode",
|
|
822
|
+
value: function countryCallingCode() {
|
|
823
|
+
return this.numberingPlan.callingCode();
|
|
824
|
+
}
|
|
825
|
+
// Deprecated.
|
|
826
|
+
}, {
|
|
827
|
+
key: "IDDPrefix",
|
|
828
|
+
value: function IDDPrefix() {
|
|
829
|
+
return this.numberingPlan.IDDPrefix();
|
|
830
|
+
}
|
|
831
|
+
// Deprecated.
|
|
832
|
+
}, {
|
|
833
|
+
key: "defaultIDDPrefix",
|
|
834
|
+
value: function defaultIDDPrefix() {
|
|
835
|
+
return this.numberingPlan.defaultIDDPrefix();
|
|
836
|
+
}
|
|
837
|
+
// Deprecated.
|
|
838
|
+
}, {
|
|
839
|
+
key: "nationalNumberPattern",
|
|
840
|
+
value: function nationalNumberPattern() {
|
|
841
|
+
return this.numberingPlan.nationalNumberPattern();
|
|
842
|
+
}
|
|
843
|
+
// Deprecated.
|
|
844
|
+
}, {
|
|
845
|
+
key: "possibleLengths",
|
|
846
|
+
value: function possibleLengths() {
|
|
847
|
+
return this.numberingPlan.possibleLengths();
|
|
848
|
+
}
|
|
849
|
+
// Deprecated.
|
|
850
|
+
}, {
|
|
851
|
+
key: "formats",
|
|
852
|
+
value: function formats() {
|
|
853
|
+
return this.numberingPlan.formats();
|
|
854
|
+
}
|
|
855
|
+
// Deprecated.
|
|
856
|
+
}, {
|
|
857
|
+
key: "nationalPrefixForParsing",
|
|
858
|
+
value: function nationalPrefixForParsing() {
|
|
859
|
+
return this.numberingPlan.nationalPrefixForParsing();
|
|
860
|
+
}
|
|
861
|
+
// Deprecated.
|
|
862
|
+
}, {
|
|
863
|
+
key: "nationalPrefixTransformRule",
|
|
864
|
+
value: function nationalPrefixTransformRule() {
|
|
865
|
+
return this.numberingPlan.nationalPrefixTransformRule();
|
|
866
|
+
}
|
|
867
|
+
// Deprecated.
|
|
868
|
+
}, {
|
|
869
|
+
key: "leadingDigits",
|
|
870
|
+
value: function leadingDigits() {
|
|
871
|
+
return this.numberingPlan.leadingDigits();
|
|
872
|
+
}
|
|
873
|
+
// Deprecated.
|
|
874
|
+
}, {
|
|
875
|
+
key: "hasTypes",
|
|
876
|
+
value: function hasTypes() {
|
|
877
|
+
return this.numberingPlan.hasTypes();
|
|
878
|
+
}
|
|
879
|
+
// Deprecated.
|
|
880
|
+
}, {
|
|
881
|
+
key: "type",
|
|
882
|
+
value: function type(_type) {
|
|
883
|
+
return this.numberingPlan.type(_type);
|
|
884
|
+
}
|
|
885
|
+
// Deprecated.
|
|
886
|
+
}, {
|
|
887
|
+
key: "ext",
|
|
888
|
+
value: function ext() {
|
|
889
|
+
return this.numberingPlan.ext();
|
|
890
|
+
}
|
|
891
|
+
}, {
|
|
892
|
+
key: "countryCallingCodes",
|
|
893
|
+
value: function countryCallingCodes() {
|
|
894
|
+
if (this.v1) return this.metadata.country_phone_code_to_countries;
|
|
895
|
+
return this.metadata.country_calling_codes;
|
|
896
|
+
}
|
|
897
|
+
// Deprecated.
|
|
898
|
+
}, {
|
|
899
|
+
key: "chooseCountryByCountryCallingCode",
|
|
900
|
+
value: function chooseCountryByCountryCallingCode(callingCode) {
|
|
901
|
+
return this.selectNumberingPlan(callingCode);
|
|
902
|
+
}
|
|
903
|
+
}, {
|
|
904
|
+
key: "hasSelectedNumberingPlan",
|
|
905
|
+
value: function hasSelectedNumberingPlan() {
|
|
906
|
+
return this.numberingPlan !== void 0;
|
|
907
|
+
}
|
|
908
|
+
}]);
|
|
909
|
+
})();
|
|
910
|
+
var NumberingPlan = /* @__PURE__ */ (function() {
|
|
911
|
+
function NumberingPlan2(metadata2, globalMetadataObject) {
|
|
912
|
+
_classCallCheck$2(this, NumberingPlan2);
|
|
913
|
+
this.globalMetadataObject = globalMetadataObject;
|
|
914
|
+
this.metadata = metadata2;
|
|
915
|
+
setVersion.call(this, globalMetadataObject.metadata);
|
|
916
|
+
}
|
|
917
|
+
return _createClass$2(NumberingPlan2, [{
|
|
918
|
+
key: "callingCode",
|
|
919
|
+
value: function callingCode() {
|
|
920
|
+
return this.metadata[0];
|
|
921
|
+
}
|
|
922
|
+
// When multiple countries share the same calling code,
|
|
923
|
+
// all phone number formatting rules are included in the metadata
|
|
924
|
+
// of the "default" country for that calling code.
|
|
925
|
+
// Any other countries' metdata doesn't include any formatting rules.
|
|
926
|
+
// Google developers said that such storage architecture was chosen for performance reasons.
|
|
927
|
+
//
|
|
928
|
+
// For example, for NANPA region ("North American Numbering Plan Administration",
|
|
929
|
+
// which includes USA, Canada, Cayman Islands, Bahamas, etc) all formatting rules
|
|
930
|
+
// are contained in the metadata of `US` country.
|
|
931
|
+
//
|
|
932
|
+
// This is not public API.
|
|
933
|
+
//
|
|
934
|
+
}, {
|
|
935
|
+
key: "_getDefaultCountryMetadataForThisCallingCode",
|
|
936
|
+
value: function _getDefaultCountryMetadataForThisCallingCode() {
|
|
937
|
+
return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
|
|
938
|
+
}
|
|
939
|
+
// Deprecated.
|
|
940
|
+
}, {
|
|
941
|
+
key: "getDefaultCountryMetadataForRegion",
|
|
942
|
+
value: function getDefaultCountryMetadataForRegion() {
|
|
943
|
+
return this._getDefaultCountryMetadataForThisCallingCode();
|
|
944
|
+
}
|
|
945
|
+
// Is always present.
|
|
946
|
+
}, {
|
|
947
|
+
key: "IDDPrefix",
|
|
948
|
+
value: function IDDPrefix() {
|
|
949
|
+
if (this.v1 || this.v2) return;
|
|
950
|
+
return this.metadata[1];
|
|
951
|
+
}
|
|
952
|
+
// Is only present when a country supports multiple IDD prefixes.
|
|
953
|
+
}, {
|
|
954
|
+
key: "defaultIDDPrefix",
|
|
955
|
+
value: function defaultIDDPrefix() {
|
|
956
|
+
if (this.v1 || this.v2) return;
|
|
957
|
+
return this.metadata[12];
|
|
958
|
+
}
|
|
959
|
+
}, {
|
|
960
|
+
key: "nationalNumberPattern",
|
|
961
|
+
value: function nationalNumberPattern() {
|
|
962
|
+
if (this.v1 || this.v2) return this.metadata[1];
|
|
963
|
+
return this.metadata[2];
|
|
964
|
+
}
|
|
965
|
+
// "possible length" data is always present in Google's metadata.
|
|
966
|
+
}, {
|
|
967
|
+
key: "possibleLengths",
|
|
968
|
+
value: function possibleLengths() {
|
|
969
|
+
if (this.v1) return;
|
|
970
|
+
return this.metadata[this.v2 ? 2 : 3];
|
|
971
|
+
}
|
|
972
|
+
}, {
|
|
973
|
+
key: "_getFormats",
|
|
974
|
+
value: function _getFormats(metadata2) {
|
|
975
|
+
return metadata2[this.v1 ? 2 : this.v2 ? 3 : 4];
|
|
976
|
+
}
|
|
977
|
+
// For countries of the same region (e.g. NANPA)
|
|
978
|
+
// formats are all stored in the "main" country for that region.
|
|
979
|
+
// E.g. "RU" and "KZ", "US" and "CA".
|
|
980
|
+
}, {
|
|
981
|
+
key: "formats",
|
|
982
|
+
value: function formats() {
|
|
983
|
+
var _this = this;
|
|
984
|
+
var formats2 = this._getFormats(this.metadata) || this._getFormats(this._getDefaultCountryMetadataForThisCallingCode()) || [];
|
|
985
|
+
return formats2.map(function(_) {
|
|
986
|
+
return new Format(_, _this);
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
}, {
|
|
990
|
+
key: "nationalPrefix",
|
|
991
|
+
value: function nationalPrefix() {
|
|
992
|
+
return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
|
|
993
|
+
}
|
|
994
|
+
}, {
|
|
995
|
+
key: "_getNationalPrefixFormattingRule",
|
|
996
|
+
value: function _getNationalPrefixFormattingRule(metadata2) {
|
|
997
|
+
return metadata2[this.v1 ? 4 : this.v2 ? 5 : 6];
|
|
998
|
+
}
|
|
999
|
+
// For countries of the same region (e.g. NANPA)
|
|
1000
|
+
// national prefix formatting rule is stored in the "main" country for that region.
|
|
1001
|
+
// E.g. "RU" and "KZ", "US" and "CA".
|
|
1002
|
+
}, {
|
|
1003
|
+
key: "nationalPrefixFormattingRule",
|
|
1004
|
+
value: function nationalPrefixFormattingRule() {
|
|
1005
|
+
return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this._getDefaultCountryMetadataForThisCallingCode());
|
|
1006
|
+
}
|
|
1007
|
+
}, {
|
|
1008
|
+
key: "_nationalPrefixForParsing",
|
|
1009
|
+
value: function _nationalPrefixForParsing() {
|
|
1010
|
+
return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
|
|
1011
|
+
}
|
|
1012
|
+
}, {
|
|
1013
|
+
key: "nationalPrefixForParsing",
|
|
1014
|
+
value: function nationalPrefixForParsing() {
|
|
1015
|
+
return this._nationalPrefixForParsing() || this.nationalPrefix();
|
|
1016
|
+
}
|
|
1017
|
+
}, {
|
|
1018
|
+
key: "nationalPrefixTransformRule",
|
|
1019
|
+
value: function nationalPrefixTransformRule() {
|
|
1020
|
+
return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
|
|
1021
|
+
}
|
|
1022
|
+
}, {
|
|
1023
|
+
key: "_getNationalPrefixIsOptionalWhenFormatting",
|
|
1024
|
+
value: function _getNationalPrefixIsOptionalWhenFormatting() {
|
|
1025
|
+
return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
|
|
1026
|
+
}
|
|
1027
|
+
// For countries of the same region (e.g. NANPA)
|
|
1028
|
+
// "national prefix is optional when formatting" flag is
|
|
1029
|
+
// stored in the "main" country for that region.
|
|
1030
|
+
// E.g. "RU" and "KZ", "US" and "CA".
|
|
1031
|
+
}, {
|
|
1032
|
+
key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
|
|
1033
|
+
value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
|
|
1034
|
+
return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this._getDefaultCountryMetadataForThisCallingCode());
|
|
1035
|
+
}
|
|
1036
|
+
}, {
|
|
1037
|
+
key: "leadingDigits",
|
|
1038
|
+
value: function leadingDigits() {
|
|
1039
|
+
return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
|
|
1040
|
+
}
|
|
1041
|
+
}, {
|
|
1042
|
+
key: "types",
|
|
1043
|
+
value: function types() {
|
|
1044
|
+
return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
|
|
1045
|
+
}
|
|
1046
|
+
}, {
|
|
1047
|
+
key: "hasTypes",
|
|
1048
|
+
value: function hasTypes() {
|
|
1049
|
+
if (this.types() && this.types().length === 0) {
|
|
1050
|
+
return false;
|
|
1051
|
+
}
|
|
1052
|
+
return !!this.types();
|
|
1053
|
+
}
|
|
1054
|
+
}, {
|
|
1055
|
+
key: "type",
|
|
1056
|
+
value: function type(_type2) {
|
|
1057
|
+
if (this.hasTypes() && getType(this.types(), _type2)) {
|
|
1058
|
+
return new Type(getType(this.types(), _type2), this);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}, {
|
|
1062
|
+
key: "ext",
|
|
1063
|
+
value: function ext() {
|
|
1064
|
+
if (this.v1 || this.v2) return DEFAULT_EXT_PREFIX;
|
|
1065
|
+
return this.metadata[13] || DEFAULT_EXT_PREFIX;
|
|
1066
|
+
}
|
|
1067
|
+
}]);
|
|
1068
|
+
})();
|
|
1069
|
+
var Format = /* @__PURE__ */ (function() {
|
|
1070
|
+
function Format2(format, metadata2) {
|
|
1071
|
+
_classCallCheck$2(this, Format2);
|
|
1072
|
+
this._format = format;
|
|
1073
|
+
this.metadata = metadata2;
|
|
1074
|
+
}
|
|
1075
|
+
return _createClass$2(Format2, [{
|
|
1076
|
+
key: "pattern",
|
|
1077
|
+
value: function pattern() {
|
|
1078
|
+
return this._format[0];
|
|
1079
|
+
}
|
|
1080
|
+
}, {
|
|
1081
|
+
key: "format",
|
|
1082
|
+
value: function format() {
|
|
1083
|
+
return this._format[1];
|
|
1084
|
+
}
|
|
1085
|
+
}, {
|
|
1086
|
+
key: "leadingDigitsPatterns",
|
|
1087
|
+
value: function leadingDigitsPatterns() {
|
|
1088
|
+
return this._format[2] || [];
|
|
1089
|
+
}
|
|
1090
|
+
}, {
|
|
1091
|
+
key: "nationalPrefixFormattingRule",
|
|
1092
|
+
value: function nationalPrefixFormattingRule() {
|
|
1093
|
+
return this._format[3] || this.metadata.nationalPrefixFormattingRule();
|
|
1094
|
+
}
|
|
1095
|
+
}, {
|
|
1096
|
+
key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
|
|
1097
|
+
value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
|
|
1098
|
+
return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
|
|
1099
|
+
}
|
|
1100
|
+
}, {
|
|
1101
|
+
key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
|
|
1102
|
+
value: function nationalPrefixIsMandatoryWhenFormattingInNationalFormat() {
|
|
1103
|
+
return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
|
|
1104
|
+
}
|
|
1105
|
+
// Checks whether national prefix formatting rule contains national prefix.
|
|
1106
|
+
}, {
|
|
1107
|
+
key: "usesNationalPrefix",
|
|
1108
|
+
value: function usesNationalPrefix() {
|
|
1109
|
+
return this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
|
|
1110
|
+
!FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule()) ? true : false;
|
|
1111
|
+
}
|
|
1112
|
+
}, {
|
|
1113
|
+
key: "internationalFormat",
|
|
1114
|
+
value: function internationalFormat() {
|
|
1115
|
+
return this._format[5] || this.format();
|
|
1116
|
+
}
|
|
1117
|
+
}]);
|
|
1118
|
+
})();
|
|
1119
|
+
var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
|
|
1120
|
+
var Type = /* @__PURE__ */ (function() {
|
|
1121
|
+
function Type2(type, metadata2) {
|
|
1122
|
+
_classCallCheck$2(this, Type2);
|
|
1123
|
+
this.type = type;
|
|
1124
|
+
this.metadata = metadata2;
|
|
1125
|
+
}
|
|
1126
|
+
return _createClass$2(Type2, [{
|
|
1127
|
+
key: "pattern",
|
|
1128
|
+
value: function pattern() {
|
|
1129
|
+
if (this.metadata.v1) return this.type;
|
|
1130
|
+
return this.type[0];
|
|
1131
|
+
}
|
|
1132
|
+
}, {
|
|
1133
|
+
key: "possibleLengths",
|
|
1134
|
+
value: function possibleLengths() {
|
|
1135
|
+
if (this.metadata.v1) return;
|
|
1136
|
+
return this.type[1] || this.metadata.possibleLengths();
|
|
1137
|
+
}
|
|
1138
|
+
}]);
|
|
1139
|
+
})();
|
|
1140
|
+
function getType(types, type) {
|
|
1141
|
+
switch (type) {
|
|
1142
|
+
case "FIXED_LINE":
|
|
1143
|
+
return types[0];
|
|
1144
|
+
case "MOBILE":
|
|
1145
|
+
return types[1];
|
|
1146
|
+
case "TOLL_FREE":
|
|
1147
|
+
return types[2];
|
|
1148
|
+
case "PREMIUM_RATE":
|
|
1149
|
+
return types[3];
|
|
1150
|
+
case "PERSONAL_NUMBER":
|
|
1151
|
+
return types[4];
|
|
1152
|
+
case "VOICEMAIL":
|
|
1153
|
+
return types[5];
|
|
1154
|
+
case "UAN":
|
|
1155
|
+
return types[6];
|
|
1156
|
+
case "PAGER":
|
|
1157
|
+
return types[7];
|
|
1158
|
+
case "VOIP":
|
|
1159
|
+
return types[8];
|
|
1160
|
+
case "SHARED_COST":
|
|
1161
|
+
return types[9];
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
function validateMetadata(metadata2) {
|
|
1165
|
+
if (!metadata2) {
|
|
1166
|
+
throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");
|
|
1167
|
+
}
|
|
1168
|
+
if (!isObject(metadata2) || !isObject(metadata2.countries)) {
|
|
1169
|
+
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(isObject(metadata2) ? "an object of shape: { " + Object.keys(metadata2).join(", ") + " }" : "a " + typeOf(metadata2) + ": " + metadata2, "."));
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
var typeOf = function typeOf2(_) {
|
|
1173
|
+
return _typeof$5(_);
|
|
1174
|
+
};
|
|
1175
|
+
function getCountryCallingCode$1(country, metadataJson) {
|
|
1176
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1177
|
+
if (metadata2.hasCountry(country)) {
|
|
1178
|
+
return metadata2.selectNumberingPlan(country).countryCallingCode();
|
|
1179
|
+
}
|
|
1180
|
+
throw new Error("Unknown country: ".concat(country));
|
|
1181
|
+
}
|
|
1182
|
+
function isSupportedCountry(country, metadataJson) {
|
|
1183
|
+
return metadataJson.countries.hasOwnProperty(country);
|
|
1184
|
+
}
|
|
1185
|
+
function setVersion(metadata2) {
|
|
1186
|
+
var version = metadata2.version;
|
|
1187
|
+
if (typeof version === "number") {
|
|
1188
|
+
this.v1 = version === 1;
|
|
1189
|
+
this.v2 = version === 2;
|
|
1190
|
+
this.v3 = version === 3;
|
|
1191
|
+
this.v4 = version === 4;
|
|
1192
|
+
} else {
|
|
1193
|
+
if (!version) {
|
|
1194
|
+
this.v1 = true;
|
|
1195
|
+
} else if (compare(version, V3) === -1) {
|
|
1196
|
+
this.v2 = true;
|
|
1197
|
+
} else if (compare(version, V4) === -1) {
|
|
1198
|
+
this.v3 = true;
|
|
1199
|
+
} else {
|
|
1200
|
+
this.v4 = true;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
function checkNumberLength(nationalNumber, country, metadata2) {
|
|
1205
|
+
return checkNumberLengthForType(nationalNumber, void 0, country, metadata2);
|
|
1206
|
+
}
|
|
1207
|
+
function checkNumberLengthForType(nationalNumber, type, country, metadata2) {
|
|
1208
|
+
if (country) {
|
|
1209
|
+
metadata2 = new Metadata(metadata2.metadata);
|
|
1210
|
+
metadata2.selectNumberingPlan(country);
|
|
1211
|
+
}
|
|
1212
|
+
var type_info = metadata2.type(type);
|
|
1213
|
+
var possible_lengths = type_info && type_info.possibleLengths() || metadata2.possibleLengths();
|
|
1214
|
+
if (!possible_lengths) {
|
|
1215
|
+
return "IS_POSSIBLE";
|
|
1216
|
+
}
|
|
1217
|
+
var actual_length = nationalNumber.length;
|
|
1218
|
+
var minimum_length = possible_lengths[0];
|
|
1219
|
+
if (minimum_length === actual_length) {
|
|
1220
|
+
return "IS_POSSIBLE";
|
|
1221
|
+
}
|
|
1222
|
+
if (minimum_length > actual_length) {
|
|
1223
|
+
return "TOO_SHORT";
|
|
1224
|
+
}
|
|
1225
|
+
if (possible_lengths[possible_lengths.length - 1] < actual_length) {
|
|
1226
|
+
return "TOO_LONG";
|
|
1227
|
+
}
|
|
1228
|
+
return possible_lengths.indexOf(actual_length, 1) >= 0 ? "IS_POSSIBLE" : "INVALID_LENGTH";
|
|
1229
|
+
}
|
|
1230
|
+
function isPossiblePhoneNumber(input, options, metadataJson) {
|
|
1231
|
+
if (options === void 0) {
|
|
1232
|
+
options = {};
|
|
1233
|
+
}
|
|
1234
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1235
|
+
if (options.v2) {
|
|
1236
|
+
if (!input.countryCallingCode) {
|
|
1237
|
+
throw new Error("Invalid phone number object passed");
|
|
1238
|
+
}
|
|
1239
|
+
metadata2.selectNumberingPlan(input.country || input.countryCallingCode);
|
|
1240
|
+
} else {
|
|
1241
|
+
if (!input.phone) {
|
|
1242
|
+
return false;
|
|
1243
|
+
}
|
|
1244
|
+
if (input.country) {
|
|
1245
|
+
if (!metadata2.hasCountry(input.country)) {
|
|
1246
|
+
throw new Error("Unknown country: ".concat(input.country));
|
|
1247
|
+
}
|
|
1248
|
+
metadata2.selectNumberingPlan(input.country);
|
|
1249
|
+
} else {
|
|
1250
|
+
if (!input.countryCallingCode) {
|
|
1251
|
+
throw new Error("Invalid phone number object passed");
|
|
1252
|
+
}
|
|
1253
|
+
metadata2.selectNumberingPlan(input.countryCallingCode);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
if (metadata2.possibleLengths()) {
|
|
1257
|
+
return isPossibleNumber(input.phone || input.nationalNumber, metadata2);
|
|
1258
|
+
}
|
|
1259
|
+
if (input.countryCallingCode && metadata2.isNonGeographicCallingCode(input.countryCallingCode)) {
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
|
|
1263
|
+
}
|
|
1264
|
+
function isPossibleNumber(nationalNumber, metadata2) {
|
|
1265
|
+
switch (checkNumberLength(nationalNumber, void 0, metadata2)) {
|
|
1266
|
+
case "IS_POSSIBLE":
|
|
1267
|
+
return true;
|
|
1268
|
+
// This library ignores "local-only" phone numbers (for simplicity).
|
|
1269
|
+
// See the readme for more info on what are "local-only" phone numbers.
|
|
1270
|
+
// case 'IS_POSSIBLE_LOCAL_ONLY':
|
|
1271
|
+
// return !isInternational
|
|
1272
|
+
default:
|
|
1273
|
+
return false;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
function matchesEntirely(text, regularExpressionText) {
|
|
1277
|
+
text = text || "";
|
|
1278
|
+
return new RegExp("^(?:" + regularExpressionText + ")$").test(text);
|
|
1279
|
+
}
|
|
1280
|
+
function _createForOfIteratorHelperLoose$2(r, e) {
|
|
1281
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
1282
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
1283
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e) {
|
|
1284
|
+
t && (r = t);
|
|
1285
|
+
var o = 0;
|
|
1286
|
+
return function() {
|
|
1287
|
+
return o >= r.length ? { done: true } : { done: false, value: r[o++] };
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1291
|
+
}
|
|
1292
|
+
function _unsupportedIterableToArray$3(r, a) {
|
|
1293
|
+
if (r) {
|
|
1294
|
+
if ("string" == typeof r) return _arrayLikeToArray$3(r, a);
|
|
1295
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
1296
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
function _arrayLikeToArray$3(r, a) {
|
|
1300
|
+
(null == a || a > r.length) && (a = r.length);
|
|
1301
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
1302
|
+
return n;
|
|
1303
|
+
}
|
|
1304
|
+
var NON_FIXED_LINE_PHONE_TYPES = ["MOBILE", "PREMIUM_RATE", "TOLL_FREE", "SHARED_COST", "VOIP", "PERSONAL_NUMBER", "PAGER", "UAN", "VOICEMAIL"];
|
|
1305
|
+
function getNumberType(input, options, metadataJson) {
|
|
1306
|
+
options = options || {};
|
|
1307
|
+
if (!input.country && !input.countryCallingCode) {
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1311
|
+
metadata2.selectNumberingPlan(input.country || input.countryCallingCode);
|
|
1312
|
+
var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
|
|
1313
|
+
if (!matchesEntirely(nationalNumber, metadata2.nationalNumberPattern())) {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
if (isNumberTypeEqualTo(nationalNumber, "FIXED_LINE", metadata2)) {
|
|
1317
|
+
if (metadata2.type("MOBILE") && metadata2.type("MOBILE").pattern() === "") {
|
|
1318
|
+
return "FIXED_LINE_OR_MOBILE";
|
|
1319
|
+
}
|
|
1320
|
+
if (!metadata2.type("MOBILE")) {
|
|
1321
|
+
return "FIXED_LINE_OR_MOBILE";
|
|
1322
|
+
}
|
|
1323
|
+
if (isNumberTypeEqualTo(nationalNumber, "MOBILE", metadata2)) {
|
|
1324
|
+
return "FIXED_LINE_OR_MOBILE";
|
|
1325
|
+
}
|
|
1326
|
+
return "FIXED_LINE";
|
|
1327
|
+
}
|
|
1328
|
+
for (var _iterator = _createForOfIteratorHelperLoose$2(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done; ) {
|
|
1329
|
+
var type = _step.value;
|
|
1330
|
+
if (isNumberTypeEqualTo(nationalNumber, type, metadata2)) {
|
|
1331
|
+
return type;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function isNumberTypeEqualTo(nationalNumber, type, metadata2) {
|
|
1336
|
+
var typeDefinition = metadata2.type(type);
|
|
1337
|
+
if (!typeDefinition || !typeDefinition.pattern()) {
|
|
1338
|
+
return false;
|
|
1339
|
+
}
|
|
1340
|
+
if (typeDefinition.possibleLengths() && typeDefinition.possibleLengths().indexOf(nationalNumber.length) < 0) {
|
|
1341
|
+
return false;
|
|
1342
|
+
}
|
|
1343
|
+
return matchesEntirely(nationalNumber, typeDefinition.pattern());
|
|
1344
|
+
}
|
|
1345
|
+
function isValidNumber(input, options, metadataJson) {
|
|
1346
|
+
options = options || {};
|
|
1347
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1348
|
+
metadata2.selectNumberingPlan(input.country || input.countryCallingCode);
|
|
1349
|
+
if (metadata2.hasTypes()) {
|
|
1350
|
+
return getNumberType(input, options, metadata2.metadata) !== void 0;
|
|
1351
|
+
}
|
|
1352
|
+
var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
|
|
1353
|
+
return matchesEntirely(nationalNumber, metadata2.nationalNumberPattern());
|
|
1354
|
+
}
|
|
1355
|
+
var COUNTRY_CODE_REG_EXP = /^[A-Z]{2}$/;
|
|
1356
|
+
function isCountryCode(string) {
|
|
1357
|
+
return COUNTRY_CODE_REG_EXP.test(string);
|
|
1358
|
+
}
|
|
1359
|
+
function getCountryAndCallingCodeFromOneOfThem(countryOrCallingCode, metadataJson) {
|
|
1360
|
+
var country;
|
|
1361
|
+
var callingCode;
|
|
1362
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1363
|
+
if (isCountryCode(countryOrCallingCode)) {
|
|
1364
|
+
country = countryOrCallingCode;
|
|
1365
|
+
metadata2.selectNumberingPlan(country);
|
|
1366
|
+
callingCode = metadata2.countryCallingCode();
|
|
1367
|
+
} else {
|
|
1368
|
+
callingCode = countryOrCallingCode;
|
|
1369
|
+
}
|
|
1370
|
+
return {
|
|
1371
|
+
country,
|
|
1372
|
+
callingCode
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
function getPossibleCountriesForNumber(callingCode, nationalNumber, metadata2) {
|
|
1376
|
+
var _metadata = new Metadata(metadata2);
|
|
1377
|
+
var possibleCountries = _metadata.getCountryCodesForCallingCode(callingCode);
|
|
1378
|
+
if (!possibleCountries) {
|
|
1379
|
+
return [];
|
|
1380
|
+
}
|
|
1381
|
+
return possibleCountries.filter(function(country) {
|
|
1382
|
+
return couldNationalNumberBelongToCountry(nationalNumber, country, metadata2);
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
function couldNationalNumberBelongToCountry(nationalNumber, country, metadataJson) {
|
|
1386
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1387
|
+
metadata2.selectNumberingPlan(country);
|
|
1388
|
+
return metadata2.numberingPlan.possibleLengths().indexOf(nationalNumber.length) >= 0;
|
|
1389
|
+
}
|
|
1390
|
+
var MIN_LENGTH_FOR_NSN = 2;
|
|
1391
|
+
var MAX_LENGTH_FOR_NSN = 17;
|
|
1392
|
+
var MAX_LENGTH_COUNTRY_CODE = 3;
|
|
1393
|
+
var VALID_DIGITS = "0-90-9٠-٩۰-۹";
|
|
1394
|
+
var DASHES = "-‐-―−ー-";
|
|
1395
|
+
var SLASHES = "//";
|
|
1396
|
+
var DOTS = "..";
|
|
1397
|
+
var WHITESPACE = " ";
|
|
1398
|
+
var BRACKETS = "()()[]\\[\\]";
|
|
1399
|
+
var TILDES = "~⁓∼~";
|
|
1400
|
+
var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);
|
|
1401
|
+
var PLUS_CHARS = "++";
|
|
1402
|
+
var CAPTURING_DIGIT_PATTERN = new RegExp("([" + VALID_DIGITS + "])");
|
|
1403
|
+
function stripIddPrefix(number, country, callingCode, metadataJson) {
|
|
1404
|
+
if (!country) {
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1408
|
+
metadata2.selectNumberingPlan(country || callingCode);
|
|
1409
|
+
var IDDPrefixPattern = new RegExp(metadata2.IDDPrefix());
|
|
1410
|
+
if (number.search(IDDPrefixPattern) !== 0) {
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
number = number.slice(number.match(IDDPrefixPattern)[0].length);
|
|
1414
|
+
var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
|
|
1415
|
+
if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
|
|
1416
|
+
if (matchedGroups[1] === "0") {
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
return number;
|
|
1421
|
+
}
|
|
1422
|
+
function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata2) {
|
|
1423
|
+
if (number && metadata2.numberingPlan.nationalPrefixForParsing()) {
|
|
1424
|
+
var prefixPattern = new RegExp("^(?:" + metadata2.numberingPlan.nationalPrefixForParsing() + ")");
|
|
1425
|
+
var prefixMatch = prefixPattern.exec(number);
|
|
1426
|
+
if (prefixMatch) {
|
|
1427
|
+
var nationalNumber;
|
|
1428
|
+
var carrierCode;
|
|
1429
|
+
var capturedGroupsCount = prefixMatch.length - 1;
|
|
1430
|
+
var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
|
|
1431
|
+
if (metadata2.nationalPrefixTransformRule() && hasCapturedGroups) {
|
|
1432
|
+
nationalNumber = number.replace(prefixPattern, metadata2.nationalPrefixTransformRule());
|
|
1433
|
+
if (capturedGroupsCount > 1) {
|
|
1434
|
+
carrierCode = prefixMatch[1];
|
|
1435
|
+
}
|
|
1436
|
+
} else {
|
|
1437
|
+
var prefixBeforeNationalNumber = prefixMatch[0];
|
|
1438
|
+
nationalNumber = number.slice(prefixBeforeNationalNumber.length);
|
|
1439
|
+
if (hasCapturedGroups) {
|
|
1440
|
+
carrierCode = prefixMatch[1];
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
var nationalPrefix;
|
|
1444
|
+
if (hasCapturedGroups) {
|
|
1445
|
+
var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
|
|
1446
|
+
var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup);
|
|
1447
|
+
if (possibleNationalPrefix === metadata2.numberingPlan.nationalPrefix()) {
|
|
1448
|
+
nationalPrefix = metadata2.numberingPlan.nationalPrefix();
|
|
1449
|
+
}
|
|
1450
|
+
} else {
|
|
1451
|
+
nationalPrefix = prefixMatch[0];
|
|
1452
|
+
}
|
|
1453
|
+
return {
|
|
1454
|
+
nationalNumber,
|
|
1455
|
+
nationalPrefix,
|
|
1456
|
+
carrierCode
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
return {
|
|
1461
|
+
nationalNumber: number
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
function _createForOfIteratorHelperLoose$1(r, e) {
|
|
1465
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
1466
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
1467
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e) {
|
|
1468
|
+
t && (r = t);
|
|
1469
|
+
var o = 0;
|
|
1470
|
+
return function() {
|
|
1471
|
+
return o >= r.length ? { done: true } : { done: false, value: r[o++] };
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1475
|
+
}
|
|
1476
|
+
function _unsupportedIterableToArray$2(r, a) {
|
|
1477
|
+
if (r) {
|
|
1478
|
+
if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
|
|
1479
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
1480
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0;
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
function _arrayLikeToArray$2(r, a) {
|
|
1484
|
+
(null == a || a > r.length) && (a = r.length);
|
|
1485
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
1486
|
+
return n;
|
|
1487
|
+
}
|
|
1488
|
+
function getCountryByNationalNumber(nationalNumber, countries, metadataJson) {
|
|
1489
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1490
|
+
for (var _iterator = _createForOfIteratorHelperLoose$1(countries), _step; !(_step = _iterator()).done; ) {
|
|
1491
|
+
var country = _step.value;
|
|
1492
|
+
metadata2.selectNumberingPlan(country);
|
|
1493
|
+
if (metadata2.leadingDigits()) {
|
|
1494
|
+
if (nationalNumber && nationalNumber.search(metadata2.leadingDigits()) === 0) {
|
|
1495
|
+
return country;
|
|
1496
|
+
}
|
|
1497
|
+
} else if (getNumberType({
|
|
1498
|
+
phone: nationalNumber,
|
|
1499
|
+
country
|
|
1500
|
+
}, void 0, metadata2.metadata)) {
|
|
1501
|
+
return country;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function getCountryByCallingCode(callingCode, _ref) {
|
|
1506
|
+
var nationalNumber = _ref.nationalNumber, metadata2 = _ref.metadata;
|
|
1507
|
+
var possibleCountries = metadata2.getCountryCodesForCallingCode(callingCode);
|
|
1508
|
+
if (!possibleCountries) {
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
if (possibleCountries.length === 1) {
|
|
1512
|
+
return possibleCountries[0];
|
|
1513
|
+
}
|
|
1514
|
+
return getCountryByNationalNumber(nationalNumber, possibleCountries, metadata2.metadata);
|
|
1515
|
+
}
|
|
1516
|
+
function extractNationalNumber(number, country, metadata2) {
|
|
1517
|
+
var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata2), carrierCode = _extractNationalNumbe.carrierCode, nationalNumber = _extractNationalNumbe.nationalNumber;
|
|
1518
|
+
if (nationalNumber !== number) {
|
|
1519
|
+
if (!shouldHaveExtractedNationalPrefix(number, nationalNumber, metadata2)) {
|
|
1520
|
+
return {
|
|
1521
|
+
nationalNumber: number
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
if (metadata2.numberingPlan.possibleLengths()) {
|
|
1525
|
+
if (!country) {
|
|
1526
|
+
country = getCountryByCallingCode(metadata2.numberingPlan.callingCode(), {
|
|
1527
|
+
nationalNumber,
|
|
1528
|
+
metadata: metadata2
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
if (!isPossibleIncompleteNationalNumber(nationalNumber, country, metadata2)) {
|
|
1532
|
+
return {
|
|
1533
|
+
nationalNumber: number
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
return {
|
|
1539
|
+
nationalNumber,
|
|
1540
|
+
carrierCode
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
function shouldHaveExtractedNationalPrefix(nationalNumberBefore, nationalNumberAfter, metadata2) {
|
|
1544
|
+
if (matchesEntirely(nationalNumberBefore, metadata2.nationalNumberPattern()) && !matchesEntirely(nationalNumberAfter, metadata2.nationalNumberPattern())) {
|
|
1545
|
+
return false;
|
|
1546
|
+
}
|
|
1547
|
+
return true;
|
|
1548
|
+
}
|
|
1549
|
+
function isPossibleIncompleteNationalNumber(nationalNumber, country, metadata2) {
|
|
1550
|
+
switch (checkNumberLength(nationalNumber, country, metadata2)) {
|
|
1551
|
+
case "TOO_SHORT":
|
|
1552
|
+
case "INVALID_LENGTH":
|
|
1553
|
+
return false;
|
|
1554
|
+
default:
|
|
1555
|
+
return true;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, defaultCountry, defaultCallingCode, metadataJson) {
|
|
1559
|
+
if (!(defaultCountry || defaultCallingCode)) {
|
|
1560
|
+
return {
|
|
1561
|
+
number
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
var countryCallingCode = defaultCountry ? getCountryCallingCode$1(defaultCountry, metadataJson) : defaultCallingCode;
|
|
1565
|
+
if (number.indexOf(countryCallingCode) === 0) {
|
|
1566
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1567
|
+
metadata2.selectNumberingPlan(defaultCountry || defaultCallingCode);
|
|
1568
|
+
var possibleShorterNumber = number.slice(countryCallingCode.length);
|
|
1569
|
+
var _extractNationalNumbe = extractNationalNumber(possibleShorterNumber, void 0, metadata2), possibleShorterNationalNumber = _extractNationalNumbe.nationalNumber;
|
|
1570
|
+
var _extractNationalNumbe2 = extractNationalNumber(number, void 0, metadata2), nationalNumber = _extractNationalNumbe2.nationalNumber;
|
|
1571
|
+
if (!matchesEntirely(nationalNumber, metadata2.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata2.nationalNumberPattern()) || checkNumberLength(nationalNumber, void 0, metadata2) === "TOO_LONG") {
|
|
1572
|
+
return {
|
|
1573
|
+
countryCallingCode,
|
|
1574
|
+
number: possibleShorterNumber
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
return {
|
|
1579
|
+
number
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
function extractCountryCallingCode(number, country, defaultCountry, defaultCallingCode, metadataJson) {
|
|
1583
|
+
if (!number) {
|
|
1584
|
+
return {};
|
|
1585
|
+
}
|
|
1586
|
+
var isNumberWithIddPrefix;
|
|
1587
|
+
if (number[0] !== "+") {
|
|
1588
|
+
var numberWithoutIDD = stripIddPrefix(number, defaultCountry, defaultCallingCode, metadataJson);
|
|
1589
|
+
if (numberWithoutIDD && numberWithoutIDD !== number) {
|
|
1590
|
+
isNumberWithIddPrefix = true;
|
|
1591
|
+
number = "+" + numberWithoutIDD;
|
|
1592
|
+
} else {
|
|
1593
|
+
if (defaultCountry || defaultCallingCode) {
|
|
1594
|
+
var _extractCountryCallin = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, defaultCountry, defaultCallingCode, metadataJson), countryCallingCode = _extractCountryCallin.countryCallingCode, shorterNumber = _extractCountryCallin.number;
|
|
1595
|
+
if (countryCallingCode) {
|
|
1596
|
+
return {
|
|
1597
|
+
countryCallingCodeSource: "FROM_NUMBER_WITHOUT_PLUS_SIGN",
|
|
1598
|
+
countryCallingCode,
|
|
1599
|
+
number: shorterNumber
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
return {
|
|
1604
|
+
// No need to set it to `UNSPECIFIED`. It can be just `undefined`.
|
|
1605
|
+
// countryCallingCodeSource: 'UNSPECIFIED',
|
|
1606
|
+
number
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
if (number[1] === "0") {
|
|
1611
|
+
return {};
|
|
1612
|
+
}
|
|
1613
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1614
|
+
var i = 2;
|
|
1615
|
+
while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
|
|
1616
|
+
var _countryCallingCode = number.slice(1, i);
|
|
1617
|
+
if (metadata2.hasCallingCode(_countryCallingCode)) {
|
|
1618
|
+
metadata2.selectNumberingPlan(_countryCallingCode);
|
|
1619
|
+
return {
|
|
1620
|
+
countryCallingCodeSource: isNumberWithIddPrefix ? "FROM_NUMBER_WITH_IDD" : "FROM_NUMBER_WITH_PLUS_SIGN",
|
|
1621
|
+
countryCallingCode: _countryCallingCode,
|
|
1622
|
+
number: number.slice(i)
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
i++;
|
|
1626
|
+
}
|
|
1627
|
+
return {};
|
|
1628
|
+
}
|
|
1629
|
+
function applyInternationalSeparatorStyle(formattedNumber) {
|
|
1630
|
+
return formattedNumber.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), "g"), " ").trim();
|
|
1631
|
+
}
|
|
1632
|
+
var FIRST_GROUP_PATTERN = /(\$\d)/;
|
|
1633
|
+
function formatNationalNumberUsingFormat(number, format, _ref) {
|
|
1634
|
+
var useInternationalFormat = _ref.useInternationalFormat, withNationalPrefix = _ref.withNationalPrefix;
|
|
1635
|
+
var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : (
|
|
1636
|
+
// This library doesn't use `domestic_carrier_code_formatting_rule`,
|
|
1637
|
+
// because that one is only used when formatting phone numbers
|
|
1638
|
+
// for dialing from a mobile phone, and this is not a dialing library.
|
|
1639
|
+
// carrierCode && format.domesticCarrierCodeFormattingRule()
|
|
1640
|
+
// // First, replace the $CC in the formatting rule with the desired carrier code.
|
|
1641
|
+
// // Then, replace the $FG in the formatting rule with the first group
|
|
1642
|
+
// // and the carrier code combined in the appropriate way.
|
|
1643
|
+
// ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
|
|
1644
|
+
// : (
|
|
1645
|
+
// withNationalPrefix && format.nationalPrefixFormattingRule()
|
|
1646
|
+
// ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
|
|
1647
|
+
// : format.format()
|
|
1648
|
+
// )
|
|
1649
|
+
withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format()
|
|
1650
|
+
));
|
|
1651
|
+
if (useInternationalFormat) {
|
|
1652
|
+
return applyInternationalSeparatorStyle(formattedNumber);
|
|
1653
|
+
}
|
|
1654
|
+
return formattedNumber;
|
|
1655
|
+
}
|
|
1656
|
+
var SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;
|
|
1657
|
+
function getIddPrefix(country, callingCode, metadata2) {
|
|
1658
|
+
var countryMetadata = new Metadata(metadata2);
|
|
1659
|
+
countryMetadata.selectNumberingPlan(country || callingCode);
|
|
1660
|
+
if (countryMetadata.defaultIDDPrefix()) {
|
|
1661
|
+
return countryMetadata.defaultIDDPrefix();
|
|
1662
|
+
}
|
|
1663
|
+
if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
|
|
1664
|
+
return countryMetadata.IDDPrefix();
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
var RFC3966_EXTN_PREFIX = ";ext=";
|
|
1668
|
+
var getExtensionDigitsPattern = function getExtensionDigitsPattern2(maxLength) {
|
|
1669
|
+
return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
|
|
1670
|
+
};
|
|
1671
|
+
function createExtensionPattern(purpose) {
|
|
1672
|
+
var extLimitAfterExplicitLabel = "20";
|
|
1673
|
+
var extLimitAfterLikelyLabel = "15";
|
|
1674
|
+
var extLimitAfterAmbiguousChar = "9";
|
|
1675
|
+
var extLimitWhenNotSure = "6";
|
|
1676
|
+
var possibleSeparatorsBetweenNumberAndExtLabel = "[ \\t,]*";
|
|
1677
|
+
var possibleCharsAfterExtLabel = "[:\\..]?[ \\t,-]*";
|
|
1678
|
+
var optionalExtnSuffix = "#?";
|
|
1679
|
+
var explicitExtLabels = "(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)";
|
|
1680
|
+
var ambiguousExtLabels = "(?:[xx##~~]|int|int)";
|
|
1681
|
+
var ambiguousSeparator = "[- ]+";
|
|
1682
|
+
var possibleSeparatorsNumberExtLabelNoComma = "[ \\t]*";
|
|
1683
|
+
var autoDiallingAndExtLabelsFound = "(?:,{2}|;)";
|
|
1684
|
+
var rfcExtn = RFC3966_EXTN_PREFIX + getExtensionDigitsPattern(extLimitAfterExplicitLabel);
|
|
1685
|
+
var explicitExtn = possibleSeparatorsBetweenNumberAndExtLabel + explicitExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterExplicitLabel) + optionalExtnSuffix;
|
|
1686
|
+
var ambiguousExtn = possibleSeparatorsBetweenNumberAndExtLabel + ambiguousExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
|
|
1687
|
+
var americanStyleExtnWithSuffix = ambiguousSeparator + getExtensionDigitsPattern(extLimitWhenNotSure) + "#";
|
|
1688
|
+
var autoDiallingExtn = possibleSeparatorsNumberExtLabelNoComma + autoDiallingAndExtLabelsFound + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterLikelyLabel) + optionalExtnSuffix;
|
|
1689
|
+
var onlyCommasExtn = possibleSeparatorsNumberExtLabelNoComma + "(?:,)+" + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
|
|
1690
|
+
return rfcExtn + "|" + explicitExtn + "|" + ambiguousExtn + "|" + americanStyleExtnWithSuffix + "|" + autoDiallingExtn + "|" + onlyCommasExtn;
|
|
1691
|
+
}
|
|
1692
|
+
var MIN_LENGTH_PHONE_NUMBER_PATTERN = "[" + VALID_DIGITS + "]{" + MIN_LENGTH_FOR_NSN + "}";
|
|
1693
|
+
var VALID_PHONE_NUMBER = "[" + PLUS_CHARS + "]{0,1}(?:[" + VALID_PUNCTUATION + "]*[" + VALID_DIGITS + "]){3,}[" + VALID_PUNCTUATION + VALID_DIGITS + "]*";
|
|
1694
|
+
var VALID_PHONE_NUMBER_START_REG_EXP = new RegExp("^[" + PLUS_CHARS + "]{0,1}(?:[" + VALID_PUNCTUATION + "]*[" + VALID_DIGITS + "]){1,2}$", "i");
|
|
1695
|
+
var VALID_PHONE_NUMBER_WITH_EXTENSION = VALID_PHONE_NUMBER + // Phone number extensions
|
|
1696
|
+
"(?:" + createExtensionPattern() + ")?";
|
|
1697
|
+
var VALID_PHONE_NUMBER_PATTERN = new RegExp(
|
|
1698
|
+
// Either a short two-digit-only phone number
|
|
1699
|
+
"^" + MIN_LENGTH_PHONE_NUMBER_PATTERN + "$|^" + VALID_PHONE_NUMBER_WITH_EXTENSION + "$",
|
|
1700
|
+
"i"
|
|
1701
|
+
);
|
|
1702
|
+
function isViablePhoneNumber(number) {
|
|
1703
|
+
return number.length >= MIN_LENGTH_FOR_NSN && VALID_PHONE_NUMBER_PATTERN.test(number);
|
|
1704
|
+
}
|
|
1705
|
+
function isViablePhoneNumberStart(number) {
|
|
1706
|
+
return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
|
|
1707
|
+
}
|
|
1708
|
+
function formatRFC3966(_ref) {
|
|
1709
|
+
var number = _ref.number, ext = _ref.ext;
|
|
1710
|
+
if (!number) {
|
|
1711
|
+
return "";
|
|
1712
|
+
}
|
|
1713
|
+
if (number[0] !== "+") {
|
|
1714
|
+
throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');
|
|
1715
|
+
}
|
|
1716
|
+
return "tel:".concat(number).concat(ext ? ";ext=" + ext : "");
|
|
1717
|
+
}
|
|
1718
|
+
var DEFAULT_OPTIONS = {
|
|
1719
|
+
formatExtension: function formatExtension(formattedNumber, extension, metadata2) {
|
|
1720
|
+
return "".concat(formattedNumber).concat(metadata2.ext()).concat(extension);
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
function formatNumber(input, format, options, metadataJson) {
|
|
1724
|
+
if (options) {
|
|
1725
|
+
options = merge({}, DEFAULT_OPTIONS, options);
|
|
1726
|
+
} else {
|
|
1727
|
+
options = DEFAULT_OPTIONS;
|
|
1728
|
+
}
|
|
1729
|
+
var metadata2 = new Metadata(metadataJson);
|
|
1730
|
+
if (input.country && input.country !== "001") {
|
|
1731
|
+
if (!metadata2.hasCountry(input.country)) {
|
|
1732
|
+
throw new Error("Unknown country: ".concat(input.country));
|
|
1733
|
+
}
|
|
1734
|
+
metadata2.selectNumberingPlan(input.country);
|
|
1735
|
+
} else if (input.countryCallingCode) {
|
|
1736
|
+
metadata2.selectNumberingPlan(input.countryCallingCode);
|
|
1737
|
+
} else return input.phone || "";
|
|
1738
|
+
var countryCallingCode = metadata2.countryCallingCode();
|
|
1739
|
+
var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
|
|
1740
|
+
var number;
|
|
1741
|
+
switch (format) {
|
|
1742
|
+
case "NATIONAL":
|
|
1743
|
+
if (!nationalNumber) {
|
|
1744
|
+
return "";
|
|
1745
|
+
}
|
|
1746
|
+
number = formatNationalNumber(nationalNumber, input.carrierCode, "NATIONAL", metadata2, options);
|
|
1747
|
+
return addExtension(number, input.ext, metadata2, options.formatExtension);
|
|
1748
|
+
case "INTERNATIONAL":
|
|
1749
|
+
if (!nationalNumber) {
|
|
1750
|
+
return "+".concat(countryCallingCode);
|
|
1751
|
+
}
|
|
1752
|
+
number = formatNationalNumber(nationalNumber, null, "INTERNATIONAL", metadata2, options);
|
|
1753
|
+
number = "+".concat(countryCallingCode, " ").concat(number);
|
|
1754
|
+
return addExtension(number, input.ext, metadata2, options.formatExtension);
|
|
1755
|
+
case "E.164":
|
|
1756
|
+
return "+".concat(countryCallingCode).concat(nationalNumber);
|
|
1757
|
+
case "RFC3966":
|
|
1758
|
+
return formatRFC3966({
|
|
1759
|
+
number: "+".concat(countryCallingCode).concat(nationalNumber),
|
|
1760
|
+
ext: input.ext
|
|
1761
|
+
});
|
|
1762
|
+
// For reference, here's Google's IDD formatter:
|
|
1763
|
+
// https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546
|
|
1764
|
+
// Not saying that this IDD formatter replicates it 1:1, but it seems to work.
|
|
1765
|
+
// Who would even need to format phone numbers in IDD format anyway?
|
|
1766
|
+
case "IDD":
|
|
1767
|
+
if (!options.fromCountry) {
|
|
1768
|
+
return;
|
|
1769
|
+
}
|
|
1770
|
+
var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata2);
|
|
1771
|
+
if (!formattedNumber) {
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
return addExtension(formattedNumber, input.ext, metadata2, options.formatExtension);
|
|
1775
|
+
default:
|
|
1776
|
+
throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(format, '"'));
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
function formatNationalNumber(number, carrierCode, formatAs, metadata2, options) {
|
|
1780
|
+
var format = chooseFormatForNumber(metadata2.formats(), number);
|
|
1781
|
+
if (!format) {
|
|
1782
|
+
return number;
|
|
1783
|
+
}
|
|
1784
|
+
return formatNationalNumberUsingFormat(number, format, {
|
|
1785
|
+
useInternationalFormat: formatAs === "INTERNATIONAL",
|
|
1786
|
+
withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
function chooseFormatForNumber(availableFormats, nationalNumber) {
|
|
1790
|
+
return pickFirstMatchingElement(availableFormats, function(format) {
|
|
1791
|
+
if (format.leadingDigitsPatterns().length > 0) {
|
|
1792
|
+
var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1];
|
|
1793
|
+
if (nationalNumber.search(lastLeadingDigitsPattern) !== 0) {
|
|
1794
|
+
return false;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
return matchesEntirely(nationalNumber, format.pattern());
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
function addExtension(formattedNumber, ext, metadata2, formatExtension2) {
|
|
1801
|
+
return ext ? formatExtension2(formattedNumber, ext, metadata2) : formattedNumber;
|
|
1802
|
+
}
|
|
1803
|
+
function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata2) {
|
|
1804
|
+
var fromCountryCallingCode = getCountryCallingCode$1(fromCountry, metadata2.metadata);
|
|
1805
|
+
if (fromCountryCallingCode === countryCallingCode) {
|
|
1806
|
+
var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, "NATIONAL", metadata2);
|
|
1807
|
+
if (countryCallingCode === "1") {
|
|
1808
|
+
return countryCallingCode + " " + formattedNumber;
|
|
1809
|
+
}
|
|
1810
|
+
return formattedNumber;
|
|
1811
|
+
}
|
|
1812
|
+
var iddPrefix = getIddPrefix(fromCountry, void 0, metadata2.metadata);
|
|
1813
|
+
if (iddPrefix) {
|
|
1814
|
+
return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, "INTERNATIONAL", metadata2));
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
function merge() {
|
|
1818
|
+
var i = 1;
|
|
1819
|
+
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1820
|
+
objects[_key] = arguments[_key];
|
|
1821
|
+
}
|
|
1822
|
+
while (i < objects.length) {
|
|
1823
|
+
if (objects[i]) {
|
|
1824
|
+
for (var key in objects[i]) {
|
|
1825
|
+
objects[0][key] = objects[i][key];
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
i++;
|
|
1829
|
+
}
|
|
1830
|
+
return objects[0];
|
|
1831
|
+
}
|
|
1832
|
+
function pickFirstMatchingElement(elements, testFunction) {
|
|
1833
|
+
var i = 0;
|
|
1834
|
+
while (i < elements.length) {
|
|
1835
|
+
if (testFunction(elements[i])) {
|
|
1836
|
+
return elements[i];
|
|
1837
|
+
}
|
|
1838
|
+
i++;
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
function _typeof$4(o) {
|
|
1842
|
+
"@babel/helpers - typeof";
|
|
1843
|
+
return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
1844
|
+
return typeof o2;
|
|
1845
|
+
} : function(o2) {
|
|
1846
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
1847
|
+
}, _typeof$4(o);
|
|
1848
|
+
}
|
|
1849
|
+
function ownKeys$3(e, r) {
|
|
1850
|
+
var t = Object.keys(e);
|
|
1851
|
+
if (Object.getOwnPropertySymbols) {
|
|
1852
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
1853
|
+
r && (o = o.filter(function(r2) {
|
|
1854
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
1855
|
+
})), t.push.apply(t, o);
|
|
1856
|
+
}
|
|
1857
|
+
return t;
|
|
1858
|
+
}
|
|
1859
|
+
function _objectSpread$3(e) {
|
|
1860
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
1861
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
1862
|
+
r % 2 ? ownKeys$3(Object(t), true).forEach(function(r2) {
|
|
1863
|
+
_defineProperty$3(e, r2, t[r2]);
|
|
1864
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r2) {
|
|
1865
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
return e;
|
|
1869
|
+
}
|
|
1870
|
+
function _defineProperty$3(e, r, t) {
|
|
1871
|
+
return (r = _toPropertyKey$3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
1872
|
+
}
|
|
1873
|
+
function _classCallCheck$1(a, n) {
|
|
1874
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
1875
|
+
}
|
|
1876
|
+
function _defineProperties(e, r) {
|
|
1877
|
+
for (var t = 0; t < r.length; t++) {
|
|
1878
|
+
var o = r[t];
|
|
1879
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$3(o.key), o);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
function _createClass$1(e, r, t) {
|
|
1883
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
|
|
1884
|
+
}
|
|
1885
|
+
function _toPropertyKey$3(t) {
|
|
1886
|
+
var i = _toPrimitive$3(t, "string");
|
|
1887
|
+
return "symbol" == _typeof$4(i) ? i : i + "";
|
|
1888
|
+
}
|
|
1889
|
+
function _toPrimitive$3(t, r) {
|
|
1890
|
+
if ("object" != _typeof$4(t) || !t) return t;
|
|
1891
|
+
var e = t[Symbol.toPrimitive];
|
|
1892
|
+
if (void 0 !== e) {
|
|
1893
|
+
var i = e.call(t, r);
|
|
1894
|
+
if ("object" != _typeof$4(i)) return i;
|
|
1895
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1896
|
+
}
|
|
1897
|
+
return String(t);
|
|
1898
|
+
}
|
|
1899
|
+
var PhoneNumber = /* @__PURE__ */ (function() {
|
|
1900
|
+
function PhoneNumber2(countryOrCountryCallingCode, nationalNumber, metadata2) {
|
|
1901
|
+
_classCallCheck$1(this, PhoneNumber2);
|
|
1902
|
+
if (!countryOrCountryCallingCode) {
|
|
1903
|
+
throw new TypeError("First argument is required");
|
|
1904
|
+
}
|
|
1905
|
+
if (typeof countryOrCountryCallingCode !== "string") {
|
|
1906
|
+
throw new TypeError("First argument must be a string");
|
|
1907
|
+
}
|
|
1908
|
+
if (countryOrCountryCallingCode[0] === "+" && !nationalNumber) {
|
|
1909
|
+
throw new TypeError("`metadata` argument not passed");
|
|
1910
|
+
}
|
|
1911
|
+
if (isObject(nationalNumber) && isObject(nationalNumber.countries)) {
|
|
1912
|
+
metadata2 = nationalNumber;
|
|
1913
|
+
var e164Number = countryOrCountryCallingCode;
|
|
1914
|
+
if (!E164_NUMBER_REGEXP.test(e164Number)) {
|
|
1915
|
+
throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');
|
|
1916
|
+
}
|
|
1917
|
+
var _extractCountryCallin = extractCountryCallingCode(e164Number, void 0, void 0, void 0, metadata2), _countryCallingCode = _extractCountryCallin.countryCallingCode, number = _extractCountryCallin.number;
|
|
1918
|
+
nationalNumber = number;
|
|
1919
|
+
countryOrCountryCallingCode = _countryCallingCode;
|
|
1920
|
+
if (!nationalNumber) {
|
|
1921
|
+
throw new Error("Invalid `number` argument passed: too short");
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
if (!nationalNumber) {
|
|
1925
|
+
throw new TypeError("`nationalNumber` argument is required");
|
|
1926
|
+
}
|
|
1927
|
+
if (typeof nationalNumber !== "string") {
|
|
1928
|
+
throw new TypeError("`nationalNumber` argument must be a string");
|
|
1929
|
+
}
|
|
1930
|
+
validateMetadata(metadata2);
|
|
1931
|
+
var _getCountryAndCalling = getCountryAndCallingCodeFromOneOfThem(countryOrCountryCallingCode, metadata2), country = _getCountryAndCalling.country, countryCallingCode = _getCountryAndCalling.callingCode;
|
|
1932
|
+
this.country = country;
|
|
1933
|
+
this.countryCallingCode = countryCallingCode;
|
|
1934
|
+
this.nationalNumber = nationalNumber;
|
|
1935
|
+
this.number = "+" + this.countryCallingCode + this.nationalNumber;
|
|
1936
|
+
this.getMetadata = function() {
|
|
1937
|
+
return metadata2;
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
return _createClass$1(PhoneNumber2, [{
|
|
1941
|
+
key: "setExt",
|
|
1942
|
+
value: function setExt(ext) {
|
|
1943
|
+
this.ext = ext;
|
|
1944
|
+
}
|
|
1945
|
+
}, {
|
|
1946
|
+
key: "getPossibleCountries",
|
|
1947
|
+
value: function getPossibleCountries() {
|
|
1948
|
+
if (this.country) {
|
|
1949
|
+
return [this.country];
|
|
1950
|
+
}
|
|
1951
|
+
return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.getMetadata());
|
|
1952
|
+
}
|
|
1953
|
+
}, {
|
|
1954
|
+
key: "isPossible",
|
|
1955
|
+
value: function isPossible() {
|
|
1956
|
+
return isPossiblePhoneNumber(this, {
|
|
1957
|
+
v2: true
|
|
1958
|
+
}, this.getMetadata());
|
|
1959
|
+
}
|
|
1960
|
+
}, {
|
|
1961
|
+
key: "isValid",
|
|
1962
|
+
value: function isValid() {
|
|
1963
|
+
return isValidNumber(this, {
|
|
1964
|
+
v2: true
|
|
1965
|
+
}, this.getMetadata());
|
|
1966
|
+
}
|
|
1967
|
+
}, {
|
|
1968
|
+
key: "isNonGeographic",
|
|
1969
|
+
value: function isNonGeographic() {
|
|
1970
|
+
var metadata2 = new Metadata(this.getMetadata());
|
|
1971
|
+
return metadata2.isNonGeographicCallingCode(this.countryCallingCode);
|
|
1972
|
+
}
|
|
1973
|
+
}, {
|
|
1974
|
+
key: "isEqual",
|
|
1975
|
+
value: function isEqual(phoneNumber) {
|
|
1976
|
+
return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
|
|
1977
|
+
}
|
|
1978
|
+
// `validateLength()` method was originally meant to be an equivalent for `validatePhoneNumberLength()`.
|
|
1979
|
+
//
|
|
1980
|
+
// Later, it became apparent that it's not really a true equivalent.
|
|
1981
|
+
// The reason is that a `PhoneNumber` instance is not created
|
|
1982
|
+
// when the phone number string is too short for it to be considered a valid phone number:
|
|
1983
|
+
// * When there must be at least 2 national (significant) number digits: `"1"`.
|
|
1984
|
+
// * When the country calling code part of an international number is incomplete: `"+12"`.
|
|
1985
|
+
//
|
|
1986
|
+
// So leaving this `validateLength()` method here would suggest a hidden anti-pattern
|
|
1987
|
+
// of using it instead of `validatePhoneNumberLength()` while ignoring
|
|
1988
|
+
// the "too short to be even possible" case from phone number length validation.
|
|
1989
|
+
// And ignoring that case wouldn't make any sense in a real-world application
|
|
1990
|
+
// because it would still be a valid case that should be handled.
|
|
1991
|
+
//
|
|
1992
|
+
// Because of that, this method was eventually commented out in order to not introduce
|
|
1993
|
+
// that kind of an anti-pattern.
|
|
1994
|
+
//
|
|
1995
|
+
// validateLength() {
|
|
1996
|
+
// const result = checkNumberLength(
|
|
1997
|
+
// this.nationalNumber,
|
|
1998
|
+
// undefined,
|
|
1999
|
+
// this.getMetadata()
|
|
2000
|
+
// )
|
|
2001
|
+
// if (result !== 'IS_POSSIBLE') {
|
|
2002
|
+
// return result
|
|
2003
|
+
// }
|
|
2004
|
+
// }
|
|
2005
|
+
}, {
|
|
2006
|
+
key: "getType",
|
|
2007
|
+
value: function getType2() {
|
|
2008
|
+
return getNumberType(this, {
|
|
2009
|
+
v2: true
|
|
2010
|
+
}, this.getMetadata());
|
|
2011
|
+
}
|
|
2012
|
+
}, {
|
|
2013
|
+
key: "format",
|
|
2014
|
+
value: function format(_format, options) {
|
|
2015
|
+
return formatNumber(this, _format, options ? _objectSpread$3(_objectSpread$3({}, options), {}, {
|
|
2016
|
+
v2: true
|
|
2017
|
+
}) : {
|
|
2018
|
+
v2: true
|
|
2019
|
+
}, this.getMetadata());
|
|
2020
|
+
}
|
|
2021
|
+
}, {
|
|
2022
|
+
key: "formatNational",
|
|
2023
|
+
value: function formatNational(options) {
|
|
2024
|
+
return this.format("NATIONAL", options);
|
|
2025
|
+
}
|
|
2026
|
+
}, {
|
|
2027
|
+
key: "formatInternational",
|
|
2028
|
+
value: function formatInternational(options) {
|
|
2029
|
+
return this.format("INTERNATIONAL", options);
|
|
2030
|
+
}
|
|
2031
|
+
}, {
|
|
2032
|
+
key: "getURI",
|
|
2033
|
+
value: function getURI(options) {
|
|
2034
|
+
return this.format("RFC3966", options);
|
|
2035
|
+
}
|
|
2036
|
+
}]);
|
|
2037
|
+
})();
|
|
2038
|
+
var E164_NUMBER_REGEXP = /^\+\d+$/;
|
|
2039
|
+
function _typeof$3(o) {
|
|
2040
|
+
"@babel/helpers - typeof";
|
|
2041
|
+
return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2042
|
+
return typeof o2;
|
|
2043
|
+
} : function(o2) {
|
|
2044
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2045
|
+
}, _typeof$3(o);
|
|
2046
|
+
}
|
|
2047
|
+
function _createClass(e, r, t) {
|
|
2048
|
+
return Object.defineProperty(e, "prototype", { writable: false }), e;
|
|
2049
|
+
}
|
|
2050
|
+
function _classCallCheck(a, n) {
|
|
2051
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
2052
|
+
}
|
|
2053
|
+
function _callSuper(t, o, e) {
|
|
2054
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
2055
|
+
}
|
|
2056
|
+
function _possibleConstructorReturn(t, e) {
|
|
2057
|
+
if (e && ("object" == _typeof$3(e) || "function" == typeof e)) return e;
|
|
2058
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
2059
|
+
return _assertThisInitialized(t);
|
|
2060
|
+
}
|
|
2061
|
+
function _assertThisInitialized(e) {
|
|
2062
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2063
|
+
return e;
|
|
2064
|
+
}
|
|
2065
|
+
function _inherits(t, e) {
|
|
2066
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
2067
|
+
t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: true, configurable: true } }), Object.defineProperty(t, "prototype", { writable: false }), e && _setPrototypeOf(t, e);
|
|
2068
|
+
}
|
|
2069
|
+
function _wrapNativeSuper(t) {
|
|
2070
|
+
var r = "function" == typeof Map ? /* @__PURE__ */ new Map() : void 0;
|
|
2071
|
+
return _wrapNativeSuper = function _wrapNativeSuper2(t2) {
|
|
2072
|
+
if (null === t2 || !_isNativeFunction(t2)) return t2;
|
|
2073
|
+
if ("function" != typeof t2) throw new TypeError("Super expression must either be null or a function");
|
|
2074
|
+
if (void 0 !== r) {
|
|
2075
|
+
if (r.has(t2)) return r.get(t2);
|
|
2076
|
+
r.set(t2, Wrapper);
|
|
2077
|
+
}
|
|
2078
|
+
function Wrapper() {
|
|
2079
|
+
return _construct(t2, arguments, _getPrototypeOf(this).constructor);
|
|
2080
|
+
}
|
|
2081
|
+
return Wrapper.prototype = Object.create(t2.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }), _setPrototypeOf(Wrapper, t2);
|
|
2082
|
+
}, _wrapNativeSuper(t);
|
|
2083
|
+
}
|
|
2084
|
+
function _construct(t, e, r) {
|
|
2085
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
2086
|
+
var o = [null];
|
|
2087
|
+
o.push.apply(o, e);
|
|
2088
|
+
var p = new (t.bind.apply(t, o))();
|
|
2089
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
2090
|
+
}
|
|
2091
|
+
function _isNativeReflectConstruct() {
|
|
2092
|
+
try {
|
|
2093
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
2094
|
+
}));
|
|
2095
|
+
} catch (t2) {
|
|
2096
|
+
}
|
|
2097
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct2() {
|
|
2098
|
+
return !!t;
|
|
2099
|
+
})();
|
|
2100
|
+
}
|
|
2101
|
+
function _isNativeFunction(t) {
|
|
2102
|
+
try {
|
|
2103
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
2104
|
+
} catch (n) {
|
|
2105
|
+
return "function" == typeof t;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
function _setPrototypeOf(t, e) {
|
|
2109
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) {
|
|
2110
|
+
return t2.__proto__ = e2, t2;
|
|
2111
|
+
}, _setPrototypeOf(t, e);
|
|
2112
|
+
}
|
|
2113
|
+
function _getPrototypeOf(t) {
|
|
2114
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t2) {
|
|
2115
|
+
return t2.__proto__ || Object.getPrototypeOf(t2);
|
|
2116
|
+
}, _getPrototypeOf(t);
|
|
2117
|
+
}
|
|
2118
|
+
var ParseError = /* @__PURE__ */ (function(_Error) {
|
|
2119
|
+
function ParseError2(code) {
|
|
2120
|
+
var _this;
|
|
2121
|
+
_classCallCheck(this, ParseError2);
|
|
2122
|
+
_this = _callSuper(this, ParseError2, [code]);
|
|
2123
|
+
Object.setPrototypeOf(_this, ParseError2.prototype);
|
|
2124
|
+
_this.name = _this.constructor.name;
|
|
2125
|
+
return _this;
|
|
2126
|
+
}
|
|
2127
|
+
_inherits(ParseError2, _Error);
|
|
2128
|
+
return _createClass(ParseError2);
|
|
2129
|
+
})(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
2130
|
+
var EXTN_PATTERN = new RegExp("(?:" + createExtensionPattern() + ")$", "i");
|
|
2131
|
+
function extractExtension(number) {
|
|
2132
|
+
var start = number.search(EXTN_PATTERN);
|
|
2133
|
+
if (start < 0) {
|
|
2134
|
+
return {};
|
|
2135
|
+
}
|
|
2136
|
+
var numberWithoutExtension = number.slice(0, start);
|
|
2137
|
+
var matches = number.match(EXTN_PATTERN);
|
|
2138
|
+
var i = 1;
|
|
2139
|
+
while (i < matches.length) {
|
|
2140
|
+
if (matches[i]) {
|
|
2141
|
+
return {
|
|
2142
|
+
number: numberWithoutExtension,
|
|
2143
|
+
ext: matches[i]
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
i++;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
var DIGITS = {
|
|
2150
|
+
"0": "0",
|
|
2151
|
+
"1": "1",
|
|
2152
|
+
"2": "2",
|
|
2153
|
+
"3": "3",
|
|
2154
|
+
"4": "4",
|
|
2155
|
+
"5": "5",
|
|
2156
|
+
"6": "6",
|
|
2157
|
+
"7": "7",
|
|
2158
|
+
"8": "8",
|
|
2159
|
+
"9": "9",
|
|
2160
|
+
"0": "0",
|
|
2161
|
+
// Fullwidth digit 0
|
|
2162
|
+
"1": "1",
|
|
2163
|
+
// Fullwidth digit 1
|
|
2164
|
+
"2": "2",
|
|
2165
|
+
// Fullwidth digit 2
|
|
2166
|
+
"3": "3",
|
|
2167
|
+
// Fullwidth digit 3
|
|
2168
|
+
"4": "4",
|
|
2169
|
+
// Fullwidth digit 4
|
|
2170
|
+
"5": "5",
|
|
2171
|
+
// Fullwidth digit 5
|
|
2172
|
+
"6": "6",
|
|
2173
|
+
// Fullwidth digit 6
|
|
2174
|
+
"7": "7",
|
|
2175
|
+
// Fullwidth digit 7
|
|
2176
|
+
"8": "8",
|
|
2177
|
+
// Fullwidth digit 8
|
|
2178
|
+
"9": "9",
|
|
2179
|
+
// Fullwidth digit 9
|
|
2180
|
+
"٠": "0",
|
|
2181
|
+
// Arabic-indic digit 0
|
|
2182
|
+
"١": "1",
|
|
2183
|
+
// Arabic-indic digit 1
|
|
2184
|
+
"٢": "2",
|
|
2185
|
+
// Arabic-indic digit 2
|
|
2186
|
+
"٣": "3",
|
|
2187
|
+
// Arabic-indic digit 3
|
|
2188
|
+
"٤": "4",
|
|
2189
|
+
// Arabic-indic digit 4
|
|
2190
|
+
"٥": "5",
|
|
2191
|
+
// Arabic-indic digit 5
|
|
2192
|
+
"٦": "6",
|
|
2193
|
+
// Arabic-indic digit 6
|
|
2194
|
+
"٧": "7",
|
|
2195
|
+
// Arabic-indic digit 7
|
|
2196
|
+
"٨": "8",
|
|
2197
|
+
// Arabic-indic digit 8
|
|
2198
|
+
"٩": "9",
|
|
2199
|
+
// Arabic-indic digit 9
|
|
2200
|
+
"۰": "0",
|
|
2201
|
+
// Eastern-Arabic digit 0
|
|
2202
|
+
"۱": "1",
|
|
2203
|
+
// Eastern-Arabic digit 1
|
|
2204
|
+
"۲": "2",
|
|
2205
|
+
// Eastern-Arabic digit 2
|
|
2206
|
+
"۳": "3",
|
|
2207
|
+
// Eastern-Arabic digit 3
|
|
2208
|
+
"۴": "4",
|
|
2209
|
+
// Eastern-Arabic digit 4
|
|
2210
|
+
"۵": "5",
|
|
2211
|
+
// Eastern-Arabic digit 5
|
|
2212
|
+
"۶": "6",
|
|
2213
|
+
// Eastern-Arabic digit 6
|
|
2214
|
+
"۷": "7",
|
|
2215
|
+
// Eastern-Arabic digit 7
|
|
2216
|
+
"۸": "8",
|
|
2217
|
+
// Eastern-Arabic digit 8
|
|
2218
|
+
"۹": "9"
|
|
2219
|
+
// Eastern-Arabic digit 9
|
|
2220
|
+
};
|
|
2221
|
+
function parseDigit(character) {
|
|
2222
|
+
return DIGITS[character];
|
|
2223
|
+
}
|
|
2224
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
2225
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
2226
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
2227
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) {
|
|
2228
|
+
t && (r = t);
|
|
2229
|
+
var o = 0;
|
|
2230
|
+
return function() {
|
|
2231
|
+
return o >= r.length ? { done: true } : { done: false, value: r[o++] };
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2235
|
+
}
|
|
2236
|
+
function _unsupportedIterableToArray$1(r, a) {
|
|
2237
|
+
if (r) {
|
|
2238
|
+
if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
|
|
2239
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
2240
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
function _arrayLikeToArray$1(r, a) {
|
|
2244
|
+
(null == a || a > r.length) && (a = r.length);
|
|
2245
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
2246
|
+
return n;
|
|
2247
|
+
}
|
|
2248
|
+
function parseIncompletePhoneNumber(string) {
|
|
2249
|
+
var result2 = "";
|
|
2250
|
+
for (var _iterator = _createForOfIteratorHelperLoose(string.split("")), _step; !(_step = _iterator()).done; ) {
|
|
2251
|
+
var character = _step.value;
|
|
2252
|
+
result2 += parsePhoneNumberCharacter(character, result2) || "";
|
|
2253
|
+
}
|
|
2254
|
+
return result2;
|
|
2255
|
+
}
|
|
2256
|
+
function parsePhoneNumberCharacter(character, prevParsedCharacters, eventListener) {
|
|
2257
|
+
if (character === "+") {
|
|
2258
|
+
if (prevParsedCharacters) {
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
return "+";
|
|
2262
|
+
}
|
|
2263
|
+
return parseDigit(character);
|
|
2264
|
+
}
|
|
2265
|
+
var PLUS_SIGN = "+";
|
|
2266
|
+
var RFC3966_VISUAL_SEPARATOR_ = "[\\-\\.\\(\\)]?";
|
|
2267
|
+
var RFC3966_PHONE_DIGIT_ = "([" + VALID_DIGITS + "]|" + RFC3966_VISUAL_SEPARATOR_ + ")";
|
|
2268
|
+
var RFC3966_GLOBAL_NUMBER_DIGITS_ = "^\\" + PLUS_SIGN + RFC3966_PHONE_DIGIT_ + "*[" + VALID_DIGITS + "]" + RFC3966_PHONE_DIGIT_ + "*$";
|
|
2269
|
+
var RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_ = new RegExp(RFC3966_GLOBAL_NUMBER_DIGITS_, "g");
|
|
2270
|
+
var ALPHANUM_ = VALID_DIGITS;
|
|
2271
|
+
var RFC3966_DOMAINLABEL_ = "[" + ALPHANUM_ + "]+((\\-)*[" + ALPHANUM_ + "])*";
|
|
2272
|
+
var VALID_ALPHA_ = "a-zA-Z";
|
|
2273
|
+
var RFC3966_TOPLABEL_ = "[" + VALID_ALPHA_ + "]+((\\-)*[" + ALPHANUM_ + "])*";
|
|
2274
|
+
var RFC3966_DOMAINNAME_ = "^(" + RFC3966_DOMAINLABEL_ + "\\.)*" + RFC3966_TOPLABEL_ + "\\.?$";
|
|
2275
|
+
var RFC3966_DOMAINNAME_PATTERN_ = new RegExp(RFC3966_DOMAINNAME_, "g");
|
|
2276
|
+
var RFC3966_PREFIX_ = "tel:";
|
|
2277
|
+
var RFC3966_PHONE_CONTEXT_ = ";phone-context=";
|
|
2278
|
+
var RFC3966_ISDN_SUBADDRESS_ = ";isub=";
|
|
2279
|
+
function extractPhoneContext(numberToExtractFrom) {
|
|
2280
|
+
var indexOfPhoneContext = numberToExtractFrom.indexOf(RFC3966_PHONE_CONTEXT_);
|
|
2281
|
+
if (indexOfPhoneContext < 0) {
|
|
2282
|
+
return null;
|
|
2283
|
+
}
|
|
2284
|
+
var phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT_.length;
|
|
2285
|
+
if (phoneContextStart >= numberToExtractFrom.length) {
|
|
2286
|
+
return "";
|
|
2287
|
+
}
|
|
2288
|
+
var phoneContextEnd = numberToExtractFrom.indexOf(";", phoneContextStart);
|
|
2289
|
+
if (phoneContextEnd >= 0) {
|
|
2290
|
+
return numberToExtractFrom.substring(phoneContextStart, phoneContextEnd);
|
|
2291
|
+
} else {
|
|
2292
|
+
return numberToExtractFrom.substring(phoneContextStart);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
function isPhoneContextValid(phoneContext) {
|
|
2296
|
+
if (phoneContext === null) {
|
|
2297
|
+
return true;
|
|
2298
|
+
}
|
|
2299
|
+
if (phoneContext.length === 0) {
|
|
2300
|
+
return false;
|
|
2301
|
+
}
|
|
2302
|
+
return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.test(phoneContext) || RFC3966_DOMAINNAME_PATTERN_.test(phoneContext);
|
|
2303
|
+
}
|
|
2304
|
+
function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(numberToParse, _ref) {
|
|
2305
|
+
var extractFormattedPhoneNumber = _ref.extractFormattedPhoneNumber;
|
|
2306
|
+
var phoneContext = extractPhoneContext(numberToParse);
|
|
2307
|
+
if (!isPhoneContextValid(phoneContext)) {
|
|
2308
|
+
throw new ParseError("NOT_A_NUMBER");
|
|
2309
|
+
}
|
|
2310
|
+
var phoneNumberString;
|
|
2311
|
+
if (phoneContext === null) {
|
|
2312
|
+
phoneNumberString = extractFormattedPhoneNumber(numberToParse) || "";
|
|
2313
|
+
} else {
|
|
2314
|
+
phoneNumberString = "";
|
|
2315
|
+
if (phoneContext.charAt(0) === PLUS_SIGN) {
|
|
2316
|
+
phoneNumberString += phoneContext;
|
|
2317
|
+
}
|
|
2318
|
+
var indexOfRfc3966Prefix = numberToParse.indexOf(RFC3966_PREFIX_);
|
|
2319
|
+
var indexOfNationalNumber;
|
|
2320
|
+
if (indexOfRfc3966Prefix >= 0) {
|
|
2321
|
+
indexOfNationalNumber = indexOfRfc3966Prefix + RFC3966_PREFIX_.length;
|
|
2322
|
+
} else {
|
|
2323
|
+
indexOfNationalNumber = 0;
|
|
2324
|
+
}
|
|
2325
|
+
var indexOfPhoneContext = numberToParse.indexOf(RFC3966_PHONE_CONTEXT_);
|
|
2326
|
+
phoneNumberString += numberToParse.substring(indexOfNationalNumber, indexOfPhoneContext);
|
|
2327
|
+
}
|
|
2328
|
+
var indexOfIsdn = phoneNumberString.indexOf(RFC3966_ISDN_SUBADDRESS_);
|
|
2329
|
+
if (indexOfIsdn > 0) {
|
|
2330
|
+
phoneNumberString = phoneNumberString.substring(0, indexOfIsdn);
|
|
2331
|
+
}
|
|
2332
|
+
if (phoneNumberString !== "") {
|
|
2333
|
+
return phoneNumberString;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
var MAX_INPUT_STRING_LENGTH = 250;
|
|
2337
|
+
var PHONE_NUMBER_START_PATTERN = new RegExp("[" + PLUS_CHARS + VALID_DIGITS + "]");
|
|
2338
|
+
var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp("[^" + VALID_DIGITS + "#]+$");
|
|
2339
|
+
function parse(text, options, metadataJson) {
|
|
2340
|
+
options = options || {};
|
|
2341
|
+
var metadata2 = new Metadata(metadataJson);
|
|
2342
|
+
if (options.defaultCountry && !metadata2.hasCountry(options.defaultCountry)) {
|
|
2343
|
+
if (options.v2) {
|
|
2344
|
+
throw new ParseError("INVALID_COUNTRY");
|
|
2345
|
+
}
|
|
2346
|
+
throw new Error("Unknown country: ".concat(options.defaultCountry));
|
|
2347
|
+
}
|
|
2348
|
+
var _parseInput = parseInput(text, options.v2, options.extract), formattedPhoneNumber = _parseInput.number, ext = _parseInput.ext, error = _parseInput.error;
|
|
2349
|
+
if (!formattedPhoneNumber) {
|
|
2350
|
+
if (options.v2) {
|
|
2351
|
+
if (error === "TOO_SHORT") {
|
|
2352
|
+
throw new ParseError("TOO_SHORT");
|
|
2353
|
+
}
|
|
2354
|
+
throw new ParseError("NOT_A_NUMBER");
|
|
2355
|
+
}
|
|
2356
|
+
return {};
|
|
2357
|
+
}
|
|
2358
|
+
var _parsePhoneNumber = parsePhoneNumber$3(
|
|
2359
|
+
formattedPhoneNumber,
|
|
2360
|
+
options.defaultCountry,
|
|
2361
|
+
options.defaultCallingCode,
|
|
2362
|
+
// If `country` is returned, its numbering plan will also be selected in `metadata`.
|
|
2363
|
+
// Otherwise, if `countryCallingCode` is returned, its numbering plan will also be selected in `metadata`.
|
|
2364
|
+
// Otherwise, if neither `country` nor `countryCallingCode` are returned, no numbering plan will be selected in `metadata`.
|
|
2365
|
+
metadata2
|
|
2366
|
+
), country = _parsePhoneNumber.country, nationalNumber = _parsePhoneNumber.nationalNumber, countryCallingCode = _parsePhoneNumber.countryCallingCode, countryCallingCodeSource = _parsePhoneNumber.countryCallingCodeSource, carrierCode = _parsePhoneNumber.carrierCode;
|
|
2367
|
+
if (!metadata2.hasSelectedNumberingPlan()) {
|
|
2368
|
+
if (options.v2) {
|
|
2369
|
+
throw new ParseError("INVALID_COUNTRY");
|
|
2370
|
+
}
|
|
2371
|
+
return {};
|
|
2372
|
+
}
|
|
2373
|
+
if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
|
|
2374
|
+
if (options.v2) {
|
|
2375
|
+
throw new ParseError("TOO_SHORT");
|
|
2376
|
+
}
|
|
2377
|
+
return {};
|
|
2378
|
+
}
|
|
2379
|
+
if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
|
|
2380
|
+
if (options.v2) {
|
|
2381
|
+
throw new ParseError("TOO_LONG");
|
|
2382
|
+
}
|
|
2383
|
+
return {};
|
|
2384
|
+
}
|
|
2385
|
+
if (options.v2) {
|
|
2386
|
+
var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata2.metadata);
|
|
2387
|
+
if (country) {
|
|
2388
|
+
phoneNumber.country = country;
|
|
2389
|
+
}
|
|
2390
|
+
if (carrierCode) {
|
|
2391
|
+
phoneNumber.carrierCode = carrierCode;
|
|
2392
|
+
}
|
|
2393
|
+
if (ext) {
|
|
2394
|
+
phoneNumber.ext = ext;
|
|
2395
|
+
}
|
|
2396
|
+
phoneNumber.__countryCallingCodeSource = countryCallingCodeSource;
|
|
2397
|
+
return phoneNumber;
|
|
2398
|
+
}
|
|
2399
|
+
var valid = (options.extended ? metadata2.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata2.nationalNumberPattern()) : false;
|
|
2400
|
+
if (!options.extended) {
|
|
2401
|
+
return valid ? result(country, nationalNumber, ext) : {};
|
|
2402
|
+
}
|
|
2403
|
+
return {
|
|
2404
|
+
country,
|
|
2405
|
+
countryCallingCode,
|
|
2406
|
+
carrierCode,
|
|
2407
|
+
valid,
|
|
2408
|
+
possible: valid ? true : options.extended === true && metadata2.possibleLengths() && isPossibleNumber(nationalNumber, metadata2) ? true : false,
|
|
2409
|
+
phone: nationalNumber,
|
|
2410
|
+
ext
|
|
2411
|
+
};
|
|
2412
|
+
}
|
|
2413
|
+
function _extractFormattedPhoneNumber(text, extract, throwOnError) {
|
|
2414
|
+
if (!text) {
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
if (text.length > MAX_INPUT_STRING_LENGTH) {
|
|
2418
|
+
if (throwOnError) {
|
|
2419
|
+
throw new ParseError("TOO_LONG");
|
|
2420
|
+
}
|
|
2421
|
+
return;
|
|
2422
|
+
}
|
|
2423
|
+
if (extract === false) {
|
|
2424
|
+
return text;
|
|
2425
|
+
}
|
|
2426
|
+
var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
|
|
2427
|
+
if (startsAt < 0) {
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2430
|
+
return text.slice(startsAt).replace(AFTER_PHONE_NUMBER_END_PATTERN, "");
|
|
2431
|
+
}
|
|
2432
|
+
function parseInput(text, v2, extract) {
|
|
2433
|
+
var number = extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(text, {
|
|
2434
|
+
extractFormattedPhoneNumber: function extractFormattedPhoneNumber(text2) {
|
|
2435
|
+
return _extractFormattedPhoneNumber(text2, extract, v2);
|
|
2436
|
+
}
|
|
2437
|
+
});
|
|
2438
|
+
if (!number) {
|
|
2439
|
+
return {};
|
|
2440
|
+
}
|
|
2441
|
+
if (!isViablePhoneNumber(number)) {
|
|
2442
|
+
if (isViablePhoneNumberStart(number)) {
|
|
2443
|
+
return {
|
|
2444
|
+
error: "TOO_SHORT"
|
|
2445
|
+
};
|
|
2446
|
+
}
|
|
2447
|
+
return {};
|
|
2448
|
+
}
|
|
2449
|
+
var withExtensionStripped = extractExtension(number);
|
|
2450
|
+
if (withExtensionStripped.ext) {
|
|
2451
|
+
return withExtensionStripped;
|
|
2452
|
+
}
|
|
2453
|
+
return {
|
|
2454
|
+
number
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function result(country, nationalNumber, ext) {
|
|
2458
|
+
var result2 = {
|
|
2459
|
+
country,
|
|
2460
|
+
phone: nationalNumber
|
|
2461
|
+
};
|
|
2462
|
+
if (ext) {
|
|
2463
|
+
result2.ext = ext;
|
|
2464
|
+
}
|
|
2465
|
+
return result2;
|
|
2466
|
+
}
|
|
2467
|
+
function parsePhoneNumber$3(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata2) {
|
|
2468
|
+
var _extractCountryCallin = extractCountryCallingCode(
|
|
2469
|
+
parseIncompletePhoneNumber(formattedPhoneNumber),
|
|
2470
|
+
void 0,
|
|
2471
|
+
// `defaultCountry` and `defaultCallingCode` are only used to detect
|
|
2472
|
+
// if it's an "international" phone number or not. They won't be used
|
|
2473
|
+
// to derive the resulting `countryCallingCode` from them, or anything like that.
|
|
2474
|
+
defaultCountry,
|
|
2475
|
+
defaultCallingCode,
|
|
2476
|
+
metadata2.metadata
|
|
2477
|
+
), countryCallingCodeSource = _extractCountryCallin.countryCallingCodeSource, countryCallingCode = _extractCountryCallin.countryCallingCode, number = _extractCountryCallin.number;
|
|
2478
|
+
var country;
|
|
2479
|
+
if (countryCallingCode) {
|
|
2480
|
+
metadata2.selectNumberingPlan(countryCallingCode);
|
|
2481
|
+
} else if (number && (defaultCountry || defaultCallingCode)) {
|
|
2482
|
+
if (defaultCountry) {
|
|
2483
|
+
country = defaultCountry;
|
|
2484
|
+
metadata2.selectNumberingPlan(defaultCountry);
|
|
2485
|
+
countryCallingCode = metadata2.numberingPlan.callingCode();
|
|
2486
|
+
} else {
|
|
2487
|
+
metadata2.selectNumberingPlan(defaultCallingCode);
|
|
2488
|
+
countryCallingCode = defaultCallingCode;
|
|
2489
|
+
}
|
|
2490
|
+
} else return {};
|
|
2491
|
+
if (!number) {
|
|
2492
|
+
return {
|
|
2493
|
+
countryCallingCodeSource,
|
|
2494
|
+
countryCallingCode
|
|
2495
|
+
};
|
|
2496
|
+
}
|
|
2497
|
+
var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), void 0, metadata2), nationalNumber = _extractNationalNumbe.nationalNumber, carrierCode = _extractNationalNumbe.carrierCode;
|
|
2498
|
+
var exactCountry = getCountryByCallingCode(countryCallingCode, {
|
|
2499
|
+
nationalNumber,
|
|
2500
|
+
metadata: metadata2
|
|
2501
|
+
});
|
|
2502
|
+
if (exactCountry) {
|
|
2503
|
+
country = exactCountry;
|
|
2504
|
+
if (exactCountry === "001") ;
|
|
2505
|
+
else {
|
|
2506
|
+
metadata2.selectNumberingPlan(country);
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
return {
|
|
2510
|
+
country,
|
|
2511
|
+
countryCallingCode,
|
|
2512
|
+
countryCallingCodeSource,
|
|
2513
|
+
nationalNumber,
|
|
2514
|
+
carrierCode
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
function _typeof$2(o) {
|
|
2518
|
+
"@babel/helpers - typeof";
|
|
2519
|
+
return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2520
|
+
return typeof o2;
|
|
2521
|
+
} : function(o2) {
|
|
2522
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2523
|
+
}, _typeof$2(o);
|
|
2524
|
+
}
|
|
2525
|
+
function ownKeys$2(e, r) {
|
|
2526
|
+
var t = Object.keys(e);
|
|
2527
|
+
if (Object.getOwnPropertySymbols) {
|
|
2528
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2529
|
+
r && (o = o.filter(function(r2) {
|
|
2530
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2531
|
+
})), t.push.apply(t, o);
|
|
2532
|
+
}
|
|
2533
|
+
return t;
|
|
2534
|
+
}
|
|
2535
|
+
function _objectSpread$2(e) {
|
|
2536
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2537
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2538
|
+
r % 2 ? ownKeys$2(Object(t), true).forEach(function(r2) {
|
|
2539
|
+
_defineProperty$2(e, r2, t[r2]);
|
|
2540
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function(r2) {
|
|
2541
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
return e;
|
|
2545
|
+
}
|
|
2546
|
+
function _defineProperty$2(e, r, t) {
|
|
2547
|
+
return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
2548
|
+
}
|
|
2549
|
+
function _toPropertyKey$2(t) {
|
|
2550
|
+
var i = _toPrimitive$2(t, "string");
|
|
2551
|
+
return "symbol" == _typeof$2(i) ? i : i + "";
|
|
2552
|
+
}
|
|
2553
|
+
function _toPrimitive$2(t, r) {
|
|
2554
|
+
if ("object" != _typeof$2(t) || !t) return t;
|
|
2555
|
+
var e = t[Symbol.toPrimitive];
|
|
2556
|
+
if (void 0 !== e) {
|
|
2557
|
+
var i = e.call(t, r);
|
|
2558
|
+
if ("object" != _typeof$2(i)) return i;
|
|
2559
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2560
|
+
}
|
|
2561
|
+
return ("string" === r ? String : Number)(t);
|
|
2562
|
+
}
|
|
2563
|
+
function parsePhoneNumberWithError(text, options, metadata2) {
|
|
2564
|
+
return parse(text, _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
2565
|
+
v2: true
|
|
2566
|
+
}), metadata2);
|
|
2567
|
+
}
|
|
2568
|
+
function _typeof$1(o) {
|
|
2569
|
+
"@babel/helpers - typeof";
|
|
2570
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2571
|
+
return typeof o2;
|
|
2572
|
+
} : function(o2) {
|
|
2573
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2574
|
+
}, _typeof$1(o);
|
|
2575
|
+
}
|
|
2576
|
+
function ownKeys$1(e, r) {
|
|
2577
|
+
var t = Object.keys(e);
|
|
2578
|
+
if (Object.getOwnPropertySymbols) {
|
|
2579
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2580
|
+
r && (o = o.filter(function(r2) {
|
|
2581
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2582
|
+
})), t.push.apply(t, o);
|
|
2583
|
+
}
|
|
2584
|
+
return t;
|
|
2585
|
+
}
|
|
2586
|
+
function _objectSpread$1(e) {
|
|
2587
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2588
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2589
|
+
r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
|
|
2590
|
+
_defineProperty$1(e, r2, t[r2]);
|
|
2591
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
|
|
2592
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2593
|
+
});
|
|
2594
|
+
}
|
|
2595
|
+
return e;
|
|
2596
|
+
}
|
|
2597
|
+
function _defineProperty$1(e, r, t) {
|
|
2598
|
+
return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
2599
|
+
}
|
|
2600
|
+
function _toPropertyKey$1(t) {
|
|
2601
|
+
var i = _toPrimitive$1(t, "string");
|
|
2602
|
+
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
2603
|
+
}
|
|
2604
|
+
function _toPrimitive$1(t, r) {
|
|
2605
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
2606
|
+
var e = t[Symbol.toPrimitive];
|
|
2607
|
+
if (void 0 !== e) {
|
|
2608
|
+
var i = e.call(t, r);
|
|
2609
|
+
if ("object" != _typeof$1(i)) return i;
|
|
2610
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2611
|
+
}
|
|
2612
|
+
return ("string" === r ? String : Number)(t);
|
|
2613
|
+
}
|
|
2614
|
+
function _slicedToArray(r, e) {
|
|
2615
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
2616
|
+
}
|
|
2617
|
+
function _nonIterableRest() {
|
|
2618
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2619
|
+
}
|
|
2620
|
+
function _unsupportedIterableToArray(r, a) {
|
|
2621
|
+
if (r) {
|
|
2622
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
2623
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
2624
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
function _arrayLikeToArray(r, a) {
|
|
2628
|
+
(null == a || a > r.length) && (a = r.length);
|
|
2629
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
2630
|
+
return n;
|
|
2631
|
+
}
|
|
2632
|
+
function _iterableToArrayLimit(r, l) {
|
|
2633
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
2634
|
+
if (null != t) {
|
|
2635
|
+
var e, n, i, u, a = [], f = true, o = false;
|
|
2636
|
+
try {
|
|
2637
|
+
if (i = (t = t.call(r)).next, 0 === l) ;
|
|
2638
|
+
else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
|
|
2639
|
+
} catch (r2) {
|
|
2640
|
+
o = true, n = r2;
|
|
2641
|
+
} finally {
|
|
2642
|
+
try {
|
|
2643
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
2644
|
+
} finally {
|
|
2645
|
+
if (o) throw n;
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
return a;
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
function _arrayWithHoles(r) {
|
|
2652
|
+
if (Array.isArray(r)) return r;
|
|
2653
|
+
}
|
|
2654
|
+
function normalizeArguments(args) {
|
|
2655
|
+
var _Array$prototype$slic = Array.prototype.slice.call(args), _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4), arg_1 = _Array$prototype$slic2[0], arg_2 = _Array$prototype$slic2[1], arg_3 = _Array$prototype$slic2[2], arg_4 = _Array$prototype$slic2[3];
|
|
2656
|
+
var text;
|
|
2657
|
+
var options;
|
|
2658
|
+
var metadata2;
|
|
2659
|
+
if (typeof arg_1 === "string") {
|
|
2660
|
+
text = arg_1;
|
|
2661
|
+
} else throw new TypeError("A text for parsing must be a string.");
|
|
2662
|
+
if (!arg_2 || typeof arg_2 === "string") {
|
|
2663
|
+
if (arg_4) {
|
|
2664
|
+
options = arg_3;
|
|
2665
|
+
metadata2 = arg_4;
|
|
2666
|
+
} else {
|
|
2667
|
+
options = void 0;
|
|
2668
|
+
metadata2 = arg_3;
|
|
2669
|
+
}
|
|
2670
|
+
if (arg_2) {
|
|
2671
|
+
options = _objectSpread$1({
|
|
2672
|
+
defaultCountry: arg_2
|
|
2673
|
+
}, options);
|
|
2674
|
+
}
|
|
2675
|
+
} else if (isObject(arg_2)) {
|
|
2676
|
+
if (arg_3) {
|
|
2677
|
+
options = arg_2;
|
|
2678
|
+
metadata2 = arg_3;
|
|
2679
|
+
} else {
|
|
2680
|
+
metadata2 = arg_2;
|
|
2681
|
+
}
|
|
2682
|
+
} else throw new Error("Invalid second argument: ".concat(arg_2));
|
|
2683
|
+
return {
|
|
2684
|
+
text,
|
|
2685
|
+
options,
|
|
2686
|
+
metadata: metadata2
|
|
2687
|
+
};
|
|
2688
|
+
}
|
|
2689
|
+
function _typeof(o) {
|
|
2690
|
+
"@babel/helpers - typeof";
|
|
2691
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
2692
|
+
return typeof o2;
|
|
2693
|
+
} : function(o2) {
|
|
2694
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
2695
|
+
}, _typeof(o);
|
|
2696
|
+
}
|
|
2697
|
+
function ownKeys(e, r) {
|
|
2698
|
+
var t = Object.keys(e);
|
|
2699
|
+
if (Object.getOwnPropertySymbols) {
|
|
2700
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2701
|
+
r && (o = o.filter(function(r2) {
|
|
2702
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2703
|
+
})), t.push.apply(t, o);
|
|
2704
|
+
}
|
|
2705
|
+
return t;
|
|
2706
|
+
}
|
|
2707
|
+
function _objectSpread(e) {
|
|
2708
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2709
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2710
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
2711
|
+
_defineProperty(e, r2, t[r2]);
|
|
2712
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
2713
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
return e;
|
|
2717
|
+
}
|
|
2718
|
+
function _defineProperty(e, r, t) {
|
|
2719
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
2720
|
+
}
|
|
2721
|
+
function _toPropertyKey(t) {
|
|
2722
|
+
var i = _toPrimitive(t, "string");
|
|
2723
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
2724
|
+
}
|
|
2725
|
+
function _toPrimitive(t, r) {
|
|
2726
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
2727
|
+
var e = t[Symbol.toPrimitive];
|
|
2728
|
+
if (void 0 !== e) {
|
|
2729
|
+
var i = e.call(t, r);
|
|
2730
|
+
if ("object" != _typeof(i)) return i;
|
|
2731
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2732
|
+
}
|
|
2733
|
+
return ("string" === r ? String : Number)(t);
|
|
2734
|
+
}
|
|
2735
|
+
function parsePhoneNumber$2(text, options, metadata2) {
|
|
2736
|
+
if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata2)) {
|
|
2737
|
+
options = _objectSpread(_objectSpread({}, options), {}, {
|
|
2738
|
+
defaultCountry: void 0
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
try {
|
|
2742
|
+
return parsePhoneNumberWithError(text, options, metadata2);
|
|
2743
|
+
} catch (error) {
|
|
2744
|
+
if (error instanceof ParseError) ;
|
|
2745
|
+
else {
|
|
2746
|
+
throw error;
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
function parsePhoneNumber$1() {
|
|
2751
|
+
var _normalizeArguments = normalizeArguments(arguments), text = _normalizeArguments.text, options = _normalizeArguments.options, metadata2 = _normalizeArguments.metadata;
|
|
2752
|
+
return parsePhoneNumber$2(text, options, metadata2);
|
|
2753
|
+
}
|
|
2754
|
+
function parsePhoneNumber() {
|
|
2755
|
+
return withMetadataArgument(parsePhoneNumber$1, arguments);
|
|
2756
|
+
}
|
|
2757
|
+
function getCountryCallingCode() {
|
|
2758
|
+
return withMetadataArgument(getCountryCallingCode$1, arguments);
|
|
2759
|
+
}
|
|
2760
|
+
const PHONE_CHARACTERS = /^[+()\-.\s\d]+$/;
|
|
2761
|
+
const SEPARATORS = /[\s().-]/g;
|
|
2762
|
+
const LOCAL_DIGITS_ASKING_FOR_COUNTRY = { min: 6, max: 15 };
|
|
2763
|
+
const INVALID = { rule: FieldRule.PHONE };
|
|
2764
|
+
const NEEDS_COUNTRY = { rule: FieldRule.PHONE_COUNTRY };
|
|
2765
|
+
function checkPhone(trimmed, rules = {}) {
|
|
2766
|
+
if (!PHONE_CHARACTERS.test(trimmed)) return INVALID;
|
|
2767
|
+
const compact = compactPhone(trimmed);
|
|
2768
|
+
const parsed = compact.startsWith("+") ? parseInternational(compact) : parseLocal(compact, rules.defaultCountry);
|
|
2769
|
+
if (!("number" in parsed)) return parsed;
|
|
2770
|
+
if (!isFromAllowedCountry(parsed.number, rules.allowedCountries)) return NEEDS_COUNTRY;
|
|
2771
|
+
return { rule: FieldRule.NONE, e164: parsed.number.number };
|
|
2772
|
+
}
|
|
2773
|
+
function callingCodesOf(countries) {
|
|
2774
|
+
const codes = countries.map((country) => `+${getCountryCallingCode(country)}`);
|
|
2775
|
+
return [...new Set(codes)];
|
|
2776
|
+
}
|
|
2777
|
+
function compactPhone(trimmed) {
|
|
2778
|
+
const compact = trimmed.replace(SEPARATORS, "");
|
|
2779
|
+
return compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
|
|
2780
|
+
}
|
|
2781
|
+
function parseInternational(compact) {
|
|
2782
|
+
const number = parsePhoneNumber(compact);
|
|
2783
|
+
return number?.isPossible() ? { number } : INVALID;
|
|
2784
|
+
}
|
|
2785
|
+
function parseLocal(compact, defaultCountry) {
|
|
2786
|
+
if (!defaultCountry) return localWithoutCountry(compact);
|
|
2787
|
+
const number = parsePhoneNumber(compact, defaultCountry);
|
|
2788
|
+
return number?.isValid() ? { number } : INVALID;
|
|
2789
|
+
}
|
|
2790
|
+
function localWithoutCountry(compact) {
|
|
2791
|
+
const { min, max } = LOCAL_DIGITS_ASKING_FOR_COUNTRY;
|
|
2792
|
+
const digitCount = compact.replace(/\D/g, "").length;
|
|
2793
|
+
return digitCount >= min && digitCount <= max ? NEEDS_COUNTRY : INVALID;
|
|
2794
|
+
}
|
|
2795
|
+
function isFromAllowedCountry(number, allowedCountries) {
|
|
2796
|
+
if (!allowedCountries?.length) return true;
|
|
2797
|
+
if (number.country) return allowedCountries.includes(number.country);
|
|
2798
|
+
return callingCodesOf(allowedCountries).includes(`+${number.countryCallingCode}`);
|
|
2799
|
+
}
|
|
516
2800
|
function validateFormSummaryField(field, value) {
|
|
517
2801
|
const trimmed = (value ?? "").trim();
|
|
518
2802
|
if (field.required && !trimmed) {
|
|
@@ -535,46 +2819,153 @@ function validateFormSummaryField(field, value) {
|
|
|
535
2819
|
}
|
|
536
2820
|
return "";
|
|
537
2821
|
}
|
|
538
|
-
function
|
|
2822
|
+
function checkFormField(field, value) {
|
|
539
2823
|
if (field.inputType === "checkbox") {
|
|
540
|
-
return field.required && value !== true ?
|
|
2824
|
+
return field.required && value !== true ? requiredFailure(field) : PASSED$1;
|
|
541
2825
|
}
|
|
542
2826
|
if (field.inputType === "multiselect") {
|
|
543
2827
|
const empty = !Array.isArray(value) || value.length === 0;
|
|
544
|
-
return field.required && empty ?
|
|
2828
|
+
return field.required && empty ? requiredFailure(field) : PASSED$1;
|
|
545
2829
|
}
|
|
546
2830
|
const trimmed = (typeof value === "string" ? value : "").trim();
|
|
547
2831
|
if (field.required && !trimmed) {
|
|
548
|
-
return
|
|
2832
|
+
return requiredFailure(field);
|
|
549
2833
|
}
|
|
550
2834
|
if (!trimmed) {
|
|
551
|
-
return
|
|
2835
|
+
return PASSED$1;
|
|
2836
|
+
}
|
|
2837
|
+
return checkTextRules(field, trimmed);
|
|
2838
|
+
}
|
|
2839
|
+
const PASSED$1 = { rule: FieldRule.NONE, message: "" };
|
|
2840
|
+
function requiredFailure(field) {
|
|
2841
|
+
return failure(FieldRule.REQUIRED, field);
|
|
2842
|
+
}
|
|
2843
|
+
function failure(rule, field) {
|
|
2844
|
+
return { rule, message: defaultFieldMessage(rule, field) ?? "" };
|
|
2845
|
+
}
|
|
2846
|
+
function defaultFieldMessage(rule, field) {
|
|
2847
|
+
switch (rule) {
|
|
2848
|
+
case FieldRule.REQUIRED:
|
|
2849
|
+
return `${field.label} is required.`;
|
|
2850
|
+
case FieldRule.MIN_LENGTH:
|
|
2851
|
+
return field.minLength === void 0 ? void 0 : `${field.label} must be at least ${field.minLength} characters.`;
|
|
2852
|
+
case FieldRule.MAX_LENGTH:
|
|
2853
|
+
return field.maxLength === void 0 ? void 0 : `${field.label} must be at most ${field.maxLength} characters.`;
|
|
2854
|
+
case FieldRule.EMAIL:
|
|
2855
|
+
return "Please enter a valid email address.";
|
|
2856
|
+
case FieldRule.URL:
|
|
2857
|
+
return "Please enter a valid URL.";
|
|
2858
|
+
case FieldRule.PHONE:
|
|
2859
|
+
return "Please enter a valid phone number.";
|
|
2860
|
+
case FieldRule.PATTERN:
|
|
2861
|
+
return `${field.label} is not in the expected format.`;
|
|
2862
|
+
case FieldRule.PHONE_COUNTRY:
|
|
2863
|
+
return phoneCountryMessage(field.phone?.allowedCountries);
|
|
2864
|
+
default:
|
|
2865
|
+
return void 0;
|
|
552
2866
|
}
|
|
2867
|
+
}
|
|
2868
|
+
function phoneCountryMessage(allowedCountries) {
|
|
2869
|
+
if (!allowedCountries?.length) return "Please include the country code, starting with +.";
|
|
2870
|
+
const codes = callingCodesOf(allowedCountries).join(", ");
|
|
2871
|
+
return `Please enter a number with one of these country codes: ${codes}.`;
|
|
2872
|
+
}
|
|
2873
|
+
const FORMAT_RULES = {
|
|
2874
|
+
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
2875
|
+
url: /^[a-z][a-z\d+.-]*:\/\/\S+$/i
|
|
2876
|
+
// any scheme: looser than Wix by design (DL#55 Q4)
|
|
2877
|
+
};
|
|
2878
|
+
function checkTextRules(field, trimmed) {
|
|
553
2879
|
if (field.minLength !== void 0 && trimmed.length < field.minLength) {
|
|
554
|
-
return
|
|
2880
|
+
return failure(FieldRule.MIN_LENGTH, field);
|
|
555
2881
|
}
|
|
556
2882
|
if (field.maxLength !== void 0 && trimmed.length > field.maxLength) {
|
|
557
|
-
return
|
|
2883
|
+
return failure(FieldRule.MAX_LENGTH, field);
|
|
558
2884
|
}
|
|
559
|
-
if (field.inputType === "email" &&
|
|
560
|
-
return
|
|
2885
|
+
if (field.inputType === "email" && !FORMAT_RULES.email.test(trimmed)) {
|
|
2886
|
+
return failure(FieldRule.EMAIL, field);
|
|
561
2887
|
}
|
|
562
|
-
if (field.inputType === "url" &&
|
|
563
|
-
return
|
|
2888
|
+
if (field.inputType === "url" && !FORMAT_RULES.url.test(trimmed)) {
|
|
2889
|
+
return failure(FieldRule.URL, field);
|
|
564
2890
|
}
|
|
565
|
-
if (field.inputType === "tel"
|
|
566
|
-
|
|
2891
|
+
if (field.inputType === "tel") {
|
|
2892
|
+
const phone = checkPhone(trimmed, field.phone);
|
|
2893
|
+
if (phone.rule !== FieldRule.NONE) return failure(phone.rule, field);
|
|
2894
|
+
}
|
|
2895
|
+
return checkPattern(field, trimmed);
|
|
2896
|
+
}
|
|
2897
|
+
function checkPattern(field, trimmed) {
|
|
2898
|
+
if (!field.pattern) return PASSED$1;
|
|
2899
|
+
try {
|
|
2900
|
+
return new RegExp(field.pattern).test(trimmed) ? PASSED$1 : failure(FieldRule.PATTERN, field);
|
|
2901
|
+
} catch {
|
|
2902
|
+
return PASSED$1;
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
const PASSED = { rule: FieldRule.NONE, message: "" };
|
|
2906
|
+
function createPageCheckRunner(formId, fields) {
|
|
2907
|
+
const visibleTargets = new Set(
|
|
2908
|
+
fields.filter((field) => !field.hidden).map((field) => field.target)
|
|
2909
|
+
);
|
|
2910
|
+
const targetsWarnedAbout = /* @__PURE__ */ new Set();
|
|
2911
|
+
const registrationsScanned = /* @__PURE__ */ new WeakSet();
|
|
2912
|
+
const checksLoggedAbout = /* @__PURE__ */ new WeakSet();
|
|
2913
|
+
function warnAboutUnknownTargets(registrations) {
|
|
2914
|
+
const unscanned = registrations.filter((checks) => !registrationsScanned.has(checks));
|
|
2915
|
+
unscanned.forEach((checks) => registrationsScanned.add(checks));
|
|
2916
|
+
for (const target of unscanned.flatMap((checks) => Object.keys(checks))) {
|
|
2917
|
+
if (visibleTargets.has(target) || targetsWarnedAbout.has(target)) continue;
|
|
2918
|
+
targetsWarnedAbout.add(target);
|
|
2919
|
+
console.warn(
|
|
2920
|
+
`[wix-forms] field checks registered for "${target}", which is not a visible field of form ${formId}; they never run`
|
|
2921
|
+
);
|
|
2922
|
+
}
|
|
567
2923
|
}
|
|
568
|
-
|
|
2924
|
+
function runCheck(check, value, values) {
|
|
569
2925
|
try {
|
|
570
|
-
|
|
571
|
-
|
|
2926
|
+
return check(value, values);
|
|
2927
|
+
} catch (error) {
|
|
2928
|
+
if (!checksLoggedAbout.has(check)) {
|
|
2929
|
+
checksLoggedAbout.add(check);
|
|
2930
|
+
console.error(
|
|
2931
|
+
"[wix-forms] a field check threw; treated as passing",
|
|
2932
|
+
{ formId },
|
|
2933
|
+
error
|
|
2934
|
+
);
|
|
572
2935
|
}
|
|
573
|
-
|
|
574
|
-
return "";
|
|
2936
|
+
return void 0;
|
|
575
2937
|
}
|
|
576
2938
|
}
|
|
577
|
-
return
|
|
2939
|
+
return (field, value, values) => {
|
|
2940
|
+
const context = useGlobalContext(WIX_FORMS_CONTEXT);
|
|
2941
|
+
if (!context) return PASSED;
|
|
2942
|
+
const registrations = registeredFieldChecks(context, formId);
|
|
2943
|
+
warnAboutUnknownTargets(registrations);
|
|
2944
|
+
for (const checks of registrations) {
|
|
2945
|
+
const fieldChecks = Object.prototype.hasOwnProperty.call(checks, field.target) ? checks[field.target] : [];
|
|
2946
|
+
for (const check of Array.isArray(fieldChecks) ? fieldChecks : []) {
|
|
2947
|
+
const message = runCheck(check, value, values);
|
|
2948
|
+
if (typeof message === "string" && message) {
|
|
2949
|
+
return { rule: FieldRule.CUSTOM, message };
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
return PASSED;
|
|
2954
|
+
};
|
|
2955
|
+
}
|
|
2956
|
+
function createSubmitOutcomeReporter(formId) {
|
|
2957
|
+
const reportedFormId = canonicalFormId(formId) ?? formId;
|
|
2958
|
+
return (outcome) => {
|
|
2959
|
+
const context = useGlobalContext(WIX_FORMS_CONTEXT);
|
|
2960
|
+
if (context) emitSubmitOutcome(context, { formId: reportedFormId, ...outcome });
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
function createSubmitStartReporter(formId) {
|
|
2964
|
+
const reportedFormId = canonicalFormId(formId) ?? formId;
|
|
2965
|
+
return () => {
|
|
2966
|
+
const context = useGlobalContext(WIX_FORMS_CONTEXT);
|
|
2967
|
+
if (context) emitSubmitStart(context, { formId: reportedFormId });
|
|
2968
|
+
};
|
|
578
2969
|
}
|
|
579
2970
|
const SUBMIT_FAILED_MESSAGE = "We could not complete your request. Please try again.";
|
|
580
2971
|
var SubmitState = /* @__PURE__ */ ((SubmitState2) => {
|
|
@@ -593,14 +2984,21 @@ var SubmitFailure = /* @__PURE__ */ ((SubmitFailure2) => {
|
|
|
593
2984
|
SubmitFailure2[SubmitFailure2["UNKNOWN"] = 5] = "UNKNOWN";
|
|
594
2985
|
return SubmitFailure2;
|
|
595
2986
|
})(SubmitFailure || {});
|
|
596
|
-
function presentSubmitRejection(
|
|
597
|
-
const view = {
|
|
598
|
-
|
|
599
|
-
|
|
2987
|
+
function presentSubmitRejection(result2, fields) {
|
|
2988
|
+
const view = {
|
|
2989
|
+
errorByTarget: {},
|
|
2990
|
+
invalidByTarget: {},
|
|
2991
|
+
ruleByTarget: {},
|
|
2992
|
+
statusMessage: ""
|
|
2993
|
+
};
|
|
2994
|
+
const statusLines = result2.message ? [result2.message] : [];
|
|
2995
|
+
for (const [target, message] of Object.entries(result2.fieldErrors ?? {})) {
|
|
600
2996
|
const field = fields.find((candidate) => candidate.target === target);
|
|
601
2997
|
if (field && !field.hidden) {
|
|
602
|
-
|
|
2998
|
+
const rule = serverRuleOf(result2, target);
|
|
2999
|
+
view.errorByTarget[target] = serverFieldMessage(rule, field, message);
|
|
603
3000
|
view.invalidByTarget[target] = true;
|
|
3001
|
+
view.ruleByTarget[target] = rule;
|
|
604
3002
|
} else {
|
|
605
3003
|
statusLines.push(`${field?.label || target}: ${message}`);
|
|
606
3004
|
}
|
|
@@ -611,6 +3009,14 @@ function presentSubmitRejection(result, fields) {
|
|
|
611
3009
|
}
|
|
612
3010
|
return view;
|
|
613
3011
|
}
|
|
3012
|
+
function serverRuleOf(result2, target) {
|
|
3013
|
+
if (result2.fromHook) return FieldRule.HOOK;
|
|
3014
|
+
return result2.fieldRules?.[target] ?? FieldRule.SERVER;
|
|
3015
|
+
}
|
|
3016
|
+
function serverFieldMessage(rule, field, wixText) {
|
|
3017
|
+
if (rule === FieldRule.SERVER || rule === FieldRule.HOOK) return wixText;
|
|
3018
|
+
return defaultFieldMessage(rule, field) ?? wixText;
|
|
3019
|
+
}
|
|
614
3020
|
const PROBE_ORIGIN = "https://site.invalid";
|
|
615
3021
|
function toSitePath(candidate) {
|
|
616
3022
|
if (typeof candidate !== "string" || !candidate.startsWith("/") || /[\u0000-\u001F\u007F\\]/.test(candidate)) {
|
|
@@ -633,10 +3039,24 @@ function emptyValueFor(field) {
|
|
|
633
3039
|
function projectSubmissionValues(fields, store) {
|
|
634
3040
|
const values = {};
|
|
635
3041
|
for (const field of fields) {
|
|
636
|
-
|
|
3042
|
+
const raw = field.target in store ? store[field.target] : emptyValueFor(field);
|
|
3043
|
+
values[field.target] = submittedValueOf(field, raw);
|
|
637
3044
|
}
|
|
638
3045
|
return values;
|
|
639
3046
|
}
|
|
3047
|
+
const TRIMMED_KINDS = /* @__PURE__ */ new Set(["text", "textarea", "email", "tel", "url"]);
|
|
3048
|
+
function submittedValueOf(field, raw) {
|
|
3049
|
+
const isTrimmed = !field.hidden && TRIMMED_KINDS.has(field.inputType) && typeof raw === "string";
|
|
3050
|
+
return isTrimmed ? raw.trim() : raw;
|
|
3051
|
+
}
|
|
3052
|
+
function trimTextValues(fields, store) {
|
|
3053
|
+
const trimmed = { ...store };
|
|
3054
|
+
for (const field of fields) {
|
|
3055
|
+
if (field.target in store)
|
|
3056
|
+
trimmed[field.target] = submittedValueOf(field, store[field.target]);
|
|
3057
|
+
}
|
|
3058
|
+
return trimmed;
|
|
3059
|
+
}
|
|
640
3060
|
function emptyStoreFor(fields) {
|
|
641
3061
|
const store = {};
|
|
642
3062
|
for (const field of fields) {
|
|
@@ -652,27 +3072,43 @@ function toggleSelection(field, { current, optionValue, checked }) {
|
|
|
652
3072
|
}
|
|
653
3073
|
function seedControlValues(store, seeds) {
|
|
654
3074
|
const seeded = { ...store };
|
|
3075
|
+
const changedTargets = [];
|
|
655
3076
|
for (const { target, value, dirty } of seeds) {
|
|
656
|
-
if (dirty ||
|
|
657
|
-
|
|
658
|
-
}
|
|
3077
|
+
if (dirty || value === void 0) continue;
|
|
3078
|
+
if (!sameFieldValue(seeded[target], value)) changedTargets.push(target);
|
|
659
3079
|
seeded[target] = value;
|
|
660
3080
|
}
|
|
661
|
-
return seeded;
|
|
3081
|
+
return { store: seeded, changedTargets };
|
|
662
3082
|
}
|
|
663
|
-
function
|
|
664
|
-
if (
|
|
665
|
-
|
|
666
|
-
|
|
3083
|
+
function sameFieldValue(current, next) {
|
|
3084
|
+
if (Array.isArray(current) && Array.isArray(next)) {
|
|
3085
|
+
return current.length === next.length && current.every((item, index) => item === next[index]);
|
|
3086
|
+
}
|
|
3087
|
+
return current === next;
|
|
667
3088
|
}
|
|
668
|
-
function validateVisibleFields(fields, values) {
|
|
669
|
-
const
|
|
3089
|
+
function validateVisibleFields(fields, values, check = checkFormField) {
|
|
3090
|
+
const failures = {};
|
|
670
3091
|
for (const field of fields) {
|
|
671
3092
|
if (field.hidden) continue;
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
3093
|
+
const result2 = check(field, values[field.target] ?? emptyValueFor(field));
|
|
3094
|
+
if (result2.rule !== FieldRule.NONE) failures[field.target] = result2;
|
|
3095
|
+
}
|
|
3096
|
+
return failures;
|
|
3097
|
+
}
|
|
3098
|
+
function toPostedValues(fields, values) {
|
|
3099
|
+
const posted = { ...values };
|
|
3100
|
+
for (const field of fields) {
|
|
3101
|
+
const value = posted[field.target];
|
|
3102
|
+
if (field.inputType !== "tel" || typeof value !== "string") continue;
|
|
3103
|
+
posted[field.target] = postedPhone(value, field);
|
|
674
3104
|
}
|
|
675
|
-
return
|
|
3105
|
+
return posted;
|
|
3106
|
+
}
|
|
3107
|
+
function postedPhone(value, field) {
|
|
3108
|
+
const trimmed = value.trim();
|
|
3109
|
+
if (!trimmed) return trimmed;
|
|
3110
|
+
const phone = checkPhone(trimmed, field.phone);
|
|
3111
|
+
return phone.rule === FieldRule.NONE ? phone.e164 : value;
|
|
676
3112
|
}
|
|
677
3113
|
var __assign = function() {
|
|
678
3114
|
__assign = Object.assign || function __assign2(t) {
|
|
@@ -698,14 +3134,14 @@ function noCase(input, options) {
|
|
|
698
3134
|
options = {};
|
|
699
3135
|
}
|
|
700
3136
|
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
|
|
701
|
-
var
|
|
3137
|
+
var result2 = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
|
702
3138
|
var start = 0;
|
|
703
|
-
var end =
|
|
704
|
-
while (
|
|
3139
|
+
var end = result2.length;
|
|
3140
|
+
while (result2.charAt(start) === "\0")
|
|
705
3141
|
start++;
|
|
706
|
-
while (
|
|
3142
|
+
while (result2.charAt(end - 1) === "\0")
|
|
707
3143
|
end--;
|
|
708
|
-
return
|
|
3144
|
+
return result2.slice(start, end).split("\0").map(transform).join(delimiter);
|
|
709
3145
|
}
|
|
710
3146
|
function replace(input, re, value) {
|
|
711
3147
|
if (re instanceof RegExp)
|
|
@@ -771,7 +3207,8 @@ function fieldToViewState(field, state) {
|
|
|
771
3207
|
label: field.label,
|
|
772
3208
|
required: field.required,
|
|
773
3209
|
error: state.error,
|
|
774
|
-
invalid: state.invalid
|
|
3210
|
+
invalid: state.invalid,
|
|
3211
|
+
errorRule: state.errorRule
|
|
775
3212
|
};
|
|
776
3213
|
if (field.inputType === "checkbox") {
|
|
777
3214
|
viewState.value = state.value === true;
|
|
@@ -793,12 +3230,13 @@ function fieldToViewState(field, state) {
|
|
|
793
3230
|
}
|
|
794
3231
|
return viewState;
|
|
795
3232
|
}
|
|
796
|
-
function buildFieldsViewState(fields, errorByTarget = {}, invalidByTarget = {}, valueByTarget = {}) {
|
|
3233
|
+
function buildFieldsViewState(fields, errorByTarget = {}, invalidByTarget = {}, valueByTarget = {}, ruleByTarget = {}) {
|
|
797
3234
|
const viewState = {};
|
|
798
3235
|
for (const field of fields) {
|
|
799
3236
|
viewState[contractTagName(field.target)] = fieldToViewState(field, {
|
|
800
3237
|
error: errorByTarget[field.target] ?? "",
|
|
801
3238
|
invalid: invalidByTarget[field.target] ?? false,
|
|
3239
|
+
errorRule: ruleByTarget[field.target] ?? FieldRule.NONE,
|
|
802
3240
|
value: valueByTarget[field.target] ?? ""
|
|
803
3241
|
});
|
|
804
3242
|
}
|
|
@@ -810,7 +3248,8 @@ function buildFormViewState(fields, overrides) {
|
|
|
810
3248
|
fields,
|
|
811
3249
|
overrides.errorByTarget,
|
|
812
3250
|
overrides.invalidByTarget,
|
|
813
|
-
overrides.valueByTarget
|
|
3251
|
+
overrides.valueByTarget,
|
|
3252
|
+
overrides.ruleByTarget
|
|
814
3253
|
),
|
|
815
3254
|
isLoading: fields.length === 0 && !overrides.loadError,
|
|
816
3255
|
loadError: overrides.loadError,
|
|
@@ -823,7 +3262,7 @@ function buildFormViewState(fields, overrides) {
|
|
|
823
3262
|
}
|
|
824
3263
|
function submitStateOf(overrides) {
|
|
825
3264
|
if (overrides.isSubmitted) return SubmitState.SUCCEEDED;
|
|
826
|
-
if (overrides.
|
|
3265
|
+
if (overrides.isHandedOff === true) return SubmitState.SUBMITTING;
|
|
827
3266
|
if (overrides.submitFailure) return SubmitState.FAILED;
|
|
828
3267
|
return SubmitState.IDLE;
|
|
829
3268
|
}
|
|
@@ -842,13 +3281,11 @@ function createSubmitFlight() {
|
|
|
842
3281
|
};
|
|
843
3282
|
}
|
|
844
3283
|
async function runFormSubmit(params) {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
params.setIsSubmitting(true);
|
|
848
|
-
let result;
|
|
3284
|
+
const { generation } = params;
|
|
3285
|
+
let result2;
|
|
849
3286
|
try {
|
|
850
3287
|
await params.ensureSessionFresh();
|
|
851
|
-
|
|
3288
|
+
result2 = await params.submitForm({
|
|
852
3289
|
formId: params.formId,
|
|
853
3290
|
values: params.submissionValues
|
|
854
3291
|
});
|
|
@@ -859,7 +3296,7 @@ async function runFormSubmit(params) {
|
|
|
859
3296
|
return;
|
|
860
3297
|
}
|
|
861
3298
|
if (!params.flight.isCurrent(generation)) return;
|
|
862
|
-
const redirectPath = params.presentSubmitResult(
|
|
3299
|
+
const redirectPath = params.presentSubmitResult(result2);
|
|
863
3300
|
if (redirectPath) {
|
|
864
3301
|
params.navigate(redirectPath);
|
|
865
3302
|
} else {
|
|
@@ -880,26 +3317,43 @@ function WixFormInteractive(_props, refs, _viewStateSignals, carryForward) {
|
|
|
880
3317
|
const [statusMessage, setStatusMessage] = createSignal("");
|
|
881
3318
|
const [errorByTarget, setErrorByTarget] = createSignal({});
|
|
882
3319
|
const [invalidByTarget, setInvalidByTarget] = createSignal({});
|
|
3320
|
+
const [ruleByTarget, setRuleByTarget] = createSignal({});
|
|
883
3321
|
const [isSubmitted, setIsSubmitted] = createSignal(false);
|
|
884
3322
|
const [submitFailure, setSubmitFailure] = createSignal(SubmitFailure.NONE);
|
|
885
3323
|
const [values, setValues] = createSignal({});
|
|
886
3324
|
const dirtyTargets = /* @__PURE__ */ new Set();
|
|
887
3325
|
let honeypotValue = "";
|
|
888
3326
|
const submitFlight = createSubmitFlight();
|
|
3327
|
+
const selectBaselineByTarget = /* @__PURE__ */ new Map();
|
|
3328
|
+
const runPageChecks = createPageCheckRunner(carryForward.formId, carryForward.fields);
|
|
3329
|
+
const reportSubmitOutcome = createSubmitOutcomeReporter(carryForward.formId);
|
|
3330
|
+
const reportSubmitStart = createSubmitStartReporter(carryForward.formId);
|
|
3331
|
+
const [isHandedOff, setIsHandedOff] = createSignal(false);
|
|
3332
|
+
function setBusy(value) {
|
|
3333
|
+
setIsSubmitting(value);
|
|
3334
|
+
if (!value)
|
|
3335
|
+
setIsHandedOff(false);
|
|
3336
|
+
}
|
|
889
3337
|
function setFieldValue(target, value) {
|
|
890
3338
|
setValues((current) => ({ ...current, [target]: value }));
|
|
891
3339
|
}
|
|
892
3340
|
function readFormValues() {
|
|
893
3341
|
return projectSubmissionValues(carryForward.fields, values());
|
|
894
3342
|
}
|
|
3343
|
+
function checkField(field, value = values()[field.target] ?? emptyValueFor(field), allValues = readFormValues()) {
|
|
3344
|
+
const builtIn = checkFormField(field, value);
|
|
3345
|
+
return builtIn.rule === FieldRule.NONE ? runPageChecks(field, submittedValueOf(field, value), allValues) : builtIn;
|
|
3346
|
+
}
|
|
895
3347
|
function validateField(field) {
|
|
896
|
-
const
|
|
3348
|
+
const { rule, message } = checkField(field);
|
|
897
3349
|
setErrorByTarget((current) => ({ ...current, [field.target]: message }));
|
|
898
3350
|
setInvalidByTarget((current) => ({ ...current, [field.target]: Boolean(message) }));
|
|
3351
|
+
setRuleByTarget((current) => ({ ...current, [field.target]: rule }));
|
|
899
3352
|
}
|
|
900
3353
|
function clearFieldError(field) {
|
|
901
3354
|
setErrorByTarget((current) => ({ ...current, [field.target]: "" }));
|
|
902
3355
|
setInvalidByTarget((current) => ({ ...current, [field.target]: false }));
|
|
3356
|
+
setRuleByTarget((current) => ({ ...current, [field.target]: FieldRule.NONE }));
|
|
903
3357
|
}
|
|
904
3358
|
function reflectToInput(field, value) {
|
|
905
3359
|
const fieldRef = refs[contractTagName(field.target)];
|
|
@@ -922,10 +3376,16 @@ function WixFormInteractive(_props, refs, _viewStateSignals, carryForward) {
|
|
|
922
3376
|
}));
|
|
923
3377
|
}
|
|
924
3378
|
}
|
|
3379
|
+
function handleNativeBlur(field) {
|
|
3380
|
+
if (dirtyTargets.has(field.target) || errorByTarget()[field.target])
|
|
3381
|
+
validateField(field);
|
|
3382
|
+
}
|
|
925
3383
|
function handleNativeInput(field, event) {
|
|
926
3384
|
dirtyTargets.add(field.target);
|
|
927
3385
|
setFieldValue(field.target, readNativeValue(field, event.target));
|
|
928
|
-
|
|
3386
|
+
if (errorByTarget()[field.target] && checkField(field).rule === FieldRule.NONE) {
|
|
3387
|
+
clearFieldError(field);
|
|
3388
|
+
}
|
|
929
3389
|
}
|
|
930
3390
|
function handleControl(field, event) {
|
|
931
3391
|
dirtyTargets.add(field.target);
|
|
@@ -941,36 +3401,67 @@ function WixFormInteractive(_props, refs, _viewStateSignals, carryForward) {
|
|
|
941
3401
|
}
|
|
942
3402
|
wireFieldEvents(refs, carryForward.fields, {
|
|
943
3403
|
onNativeInput: handleNativeInput,
|
|
944
|
-
onNativeBlur:
|
|
3404
|
+
onNativeBlur: handleNativeBlur,
|
|
945
3405
|
onControl: handleControl,
|
|
946
3406
|
onOptionToggle: handleOptionToggle
|
|
947
3407
|
});
|
|
948
3408
|
wireHoneypot(refs, (value) => {
|
|
949
3409
|
honeypotValue = value;
|
|
950
3410
|
});
|
|
951
|
-
createEffect(() => {
|
|
952
|
-
void seedControlsIntoStore(refs, carryForward.fields, dirtyTargets, setValues);
|
|
953
|
-
});
|
|
954
3411
|
const reactive = useReactive();
|
|
955
3412
|
function afterRemount(work) {
|
|
956
3413
|
void reactive.toBeClean().then(work);
|
|
957
3414
|
}
|
|
958
3415
|
afterRemount(() => wireNativeFormSubmit(refs, submit));
|
|
3416
|
+
afterRemount(() => void seedAndReflect().then(captureSelectBaselines));
|
|
3417
|
+
afterRemount(() => watchControlValues(refs, carryForward.fields, seedAndReflect));
|
|
3418
|
+
async function seedAndReflect() {
|
|
3419
|
+
const changedTargets = await seedControlsIntoStore(refs, carryForward.fields, dirtyTargets, setValues);
|
|
3420
|
+
for (const field of carryForward.fields) {
|
|
3421
|
+
if (!field.hidden && changedTargets.includes(field.target)) {
|
|
3422
|
+
reflectToInput(field, values()[field.target]);
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
async function captureSelectBaselines() {
|
|
3427
|
+
await Promise.all(reconcilableFields(carryForward.fields).filter((field) => field.inputType === "select").map(async (field) => {
|
|
3428
|
+
const domValue = await readBoundInputValue(refs, field);
|
|
3429
|
+
if (domValue !== void 0)
|
|
3430
|
+
selectBaselineByTarget.set(field.target, domValue);
|
|
3431
|
+
}));
|
|
3432
|
+
}
|
|
3433
|
+
async function reconcileNativeInputs() {
|
|
3434
|
+
await Promise.all(reconcilableFields(carryForward.fields).map(async (field) => {
|
|
3435
|
+
const domValue = await readBoundInputValue(refs, field);
|
|
3436
|
+
if (domValue === void 0 || !isReconcileNeeded(field, domValue))
|
|
3437
|
+
return;
|
|
3438
|
+
dirtyTargets.add(field.target);
|
|
3439
|
+
setFieldValue(field.target, domValue);
|
|
3440
|
+
}));
|
|
3441
|
+
}
|
|
3442
|
+
function isReconcileNeeded(field, domValue) {
|
|
3443
|
+
if (field.inputType === "select" && domValue === (selectBaselineByTarget.get(field.target) ?? "")) {
|
|
3444
|
+
return false;
|
|
3445
|
+
}
|
|
3446
|
+
return domValue !== (values()[field.target] ?? emptyValueFor(field));
|
|
3447
|
+
}
|
|
959
3448
|
function resetForm() {
|
|
960
3449
|
submitFlight.invalidate();
|
|
961
3450
|
setValues(emptyStoreFor(carryForward.fields));
|
|
962
3451
|
setErrorByTarget({});
|
|
963
3452
|
setInvalidByTarget({});
|
|
3453
|
+
setRuleByTarget({});
|
|
964
3454
|
setStatusMessage("");
|
|
965
3455
|
setSubmitFailure(SubmitFailure.NONE);
|
|
966
3456
|
setIsSubmitted(false);
|
|
967
|
-
|
|
3457
|
+
setBusy(false);
|
|
968
3458
|
dirtyTargets.clear();
|
|
969
3459
|
honeypotValue = "";
|
|
970
3460
|
clearNativeInputsAfterRemount();
|
|
971
3461
|
afterRemount(() => focusFirstFieldInput(refs, carryForward.fields, () => true));
|
|
972
3462
|
}
|
|
973
3463
|
function showSubmitted() {
|
|
3464
|
+
setValues((current) => trimTextValues(carryForward.fields, current));
|
|
974
3465
|
setIsSubmitted(true);
|
|
975
3466
|
afterRemount(() => void refs.confirmation?.exec$((element) => element.focus()));
|
|
976
3467
|
}
|
|
@@ -982,7 +3473,11 @@ function WixFormInteractive(_props, refs, _viewStateSignals, carryForward) {
|
|
|
982
3473
|
for (const field of carryForward.fields) {
|
|
983
3474
|
reflectToInput(field, emptyValueFor(field));
|
|
984
3475
|
}
|
|
3476
|
+
selectBaselineByTarget.clear();
|
|
3477
|
+
void captureSelectBaselines();
|
|
985
3478
|
wireNativeFormSubmit(refs, submit);
|
|
3479
|
+
void seedAndReflect();
|
|
3480
|
+
watchControlValues(refs, carryForward.fields, seedAndReflect);
|
|
986
3481
|
});
|
|
987
3482
|
}
|
|
988
3483
|
refs.resetButton?.onclick(({ event }) => {
|
|
@@ -1001,7 +3496,7 @@ function WixFormInteractive(_props, refs, _viewStateSignals, carryForward) {
|
|
|
1001
3496
|
if (typeof window !== "undefined") {
|
|
1002
3497
|
window.addEventListener("pageshow", (event) => {
|
|
1003
3498
|
if (event.persisted)
|
|
1004
|
-
|
|
3499
|
+
setBusy(false);
|
|
1005
3500
|
});
|
|
1006
3501
|
}
|
|
1007
3502
|
async function submit() {
|
|
@@ -1010,63 +3505,109 @@ function WixFormInteractive(_props, refs, _viewStateSignals, carryForward) {
|
|
|
1010
3505
|
setStatusMessage("");
|
|
1011
3506
|
setSubmitFailure(SubmitFailure.NONE);
|
|
1012
3507
|
setErrorByTarget({});
|
|
3508
|
+
setInvalidByTarget({});
|
|
3509
|
+
setRuleByTarget({});
|
|
1013
3510
|
if (honeypotValue.trim()) {
|
|
1014
3511
|
showSubmitted();
|
|
3512
|
+
reportSubmitOutcome({ outcome: "succeeded" });
|
|
1015
3513
|
return;
|
|
1016
3514
|
}
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
submitForm,
|
|
1033
|
-
formId: carryForward.formId,
|
|
1034
|
-
submissionValues,
|
|
1035
|
-
presentSubmitResult,
|
|
1036
|
-
navigate: (path) => window.location.assign(path),
|
|
1037
|
-
onNetworkFailure: () => {
|
|
1038
|
-
setStatusMessage(SUBMIT_FAILED_MESSAGE);
|
|
1039
|
-
setSubmitFailure(SubmitFailure.NETWORK);
|
|
3515
|
+
setBusy(true);
|
|
3516
|
+
const generation = submitFlight.begin();
|
|
3517
|
+
let hasHandedOff = false;
|
|
3518
|
+
try {
|
|
3519
|
+
await reconcileNativeInputs();
|
|
3520
|
+
if (!submitFlight.isCurrent(generation))
|
|
3521
|
+
return;
|
|
3522
|
+
await seedAndReflect();
|
|
3523
|
+
if (!submitFlight.isCurrent(generation))
|
|
3524
|
+
return;
|
|
3525
|
+
const submissionValues = readFormValues();
|
|
3526
|
+
const clientFailures = validateVisibleFields(carryForward.fields, submissionValues, (field, value) => checkField(field, value, submissionValues));
|
|
3527
|
+
if (Object.keys(clientFailures).length) {
|
|
3528
|
+
showClientErrors(clientFailures);
|
|
3529
|
+
return;
|
|
1040
3530
|
}
|
|
3531
|
+
hasHandedOff = true;
|
|
3532
|
+
setIsHandedOff(true);
|
|
3533
|
+
reportSubmitStart();
|
|
3534
|
+
await runFormSubmit({
|
|
3535
|
+
flight: submitFlight,
|
|
3536
|
+
generation,
|
|
3537
|
+
setIsSubmitting: setBusy,
|
|
3538
|
+
ensureSessionFresh,
|
|
3539
|
+
submitForm,
|
|
3540
|
+
formId: carryForward.formId,
|
|
3541
|
+
submissionValues: toPostedValues(carryForward.fields, submissionValues),
|
|
3542
|
+
presentSubmitResult,
|
|
3543
|
+
navigate: (path) => window.location.assign(path),
|
|
3544
|
+
onNetworkFailure: () => {
|
|
3545
|
+
setStatusMessage(SUBMIT_FAILED_MESSAGE);
|
|
3546
|
+
setSubmitFailure(SubmitFailure.NETWORK);
|
|
3547
|
+
reportSubmitOutcome({ outcome: "failed", reason: SubmitFailure.NETWORK });
|
|
3548
|
+
}
|
|
3549
|
+
});
|
|
3550
|
+
} finally {
|
|
3551
|
+
if (!hasHandedOff && submitFlight.isCurrent(generation))
|
|
3552
|
+
setBusy(false);
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
function showClientErrors(failures) {
|
|
3556
|
+
const targets = Object.keys(failures);
|
|
3557
|
+
const errors = Object.fromEntries(targets.map((target) => [target, failures[target].message]));
|
|
3558
|
+
setErrorByTarget(errors);
|
|
3559
|
+
setInvalidByTarget(Object.fromEntries(targets.map((target) => [target, true])));
|
|
3560
|
+
setRuleByTarget(Object.fromEntries(targets.map((target) => [target, failures[target].rule])));
|
|
3561
|
+
showFieldErrors(errors);
|
|
3562
|
+
setSubmitFailure(SubmitFailure.VALIDATION);
|
|
3563
|
+
reportSubmitOutcome({
|
|
3564
|
+
outcome: "failed",
|
|
3565
|
+
reason: SubmitFailure.VALIDATION,
|
|
3566
|
+
fieldErrors: errors
|
|
1041
3567
|
});
|
|
1042
3568
|
}
|
|
1043
|
-
function presentSubmitResult(
|
|
1044
|
-
if (!
|
|
1045
|
-
const rejection = presentSubmitRejection(
|
|
3569
|
+
function presentSubmitResult(result2) {
|
|
3570
|
+
if (!result2.success) {
|
|
3571
|
+
const rejection = presentSubmitRejection(result2, carryForward.fields);
|
|
1046
3572
|
setErrorByTarget(rejection.errorByTarget);
|
|
1047
3573
|
setInvalidByTarget(rejection.invalidByTarget);
|
|
3574
|
+
setRuleByTarget(rejection.ruleByTarget);
|
|
1048
3575
|
setStatusMessage(rejection.statusMessage);
|
|
1049
|
-
setSubmitFailure(
|
|
3576
|
+
setSubmitFailure(result2.reason ?? SubmitFailure.UNKNOWN);
|
|
1050
3577
|
showFieldErrors(rejection.errorByTarget);
|
|
3578
|
+
reportSubmitRejection(result2);
|
|
1051
3579
|
return void 0;
|
|
1052
3580
|
}
|
|
1053
|
-
|
|
1054
|
-
const redirectTo = result.redirectTo;
|
|
3581
|
+
const redirectTo = result2.redirectTo;
|
|
1055
3582
|
const redirectPath = toSitePath(redirectTo);
|
|
1056
3583
|
if (redirectTo !== void 0 && !redirectPath) {
|
|
1057
3584
|
console.error("[wix-forms] dropped an unsafe redirectTo", {
|
|
1058
3585
|
formId: carryForward.formId
|
|
1059
3586
|
});
|
|
1060
3587
|
}
|
|
3588
|
+
if (!redirectPath)
|
|
3589
|
+
showSubmitted();
|
|
3590
|
+
reportSubmitOutcome(redirectPath === void 0 ? { outcome: "succeeded" } : { outcome: "succeeded", redirectTo: redirectPath });
|
|
1061
3591
|
return redirectPath;
|
|
1062
3592
|
}
|
|
3593
|
+
function reportSubmitRejection(result2) {
|
|
3594
|
+
reportSubmitOutcome({
|
|
3595
|
+
outcome: "failed",
|
|
3596
|
+
reason: result2.reason ?? SubmitFailure.UNKNOWN,
|
|
3597
|
+
...result2.code === void 0 ? {} : { code: result2.code },
|
|
3598
|
+
...result2.fieldErrors === void 0 ? {} : { fieldErrors: result2.fieldErrors },
|
|
3599
|
+
...result2.fromHook ? { fromHook: true } : {}
|
|
3600
|
+
});
|
|
3601
|
+
}
|
|
1063
3602
|
return {
|
|
1064
3603
|
render: () => buildFormViewState(carryForward.fields, {
|
|
1065
3604
|
isSubmitting: isSubmitting(),
|
|
3605
|
+
isHandedOff: isHandedOff(),
|
|
1066
3606
|
statusMessage: statusMessage(),
|
|
1067
3607
|
loadError: carryForward.loadError ?? "",
|
|
1068
3608
|
errorByTarget: errorByTarget(),
|
|
1069
3609
|
invalidByTarget: invalidByTarget(),
|
|
3610
|
+
ruleByTarget: ruleByTarget(),
|
|
1070
3611
|
valueByTarget: values(),
|
|
1071
3612
|
isSubmitted: isSubmitted(),
|
|
1072
3613
|
submitFailure: submitFailure()
|
|
@@ -1121,15 +3662,45 @@ function seedControlsIntoStore(refs, fields, dirtyTargets, setValues) {
|
|
|
1121
3662
|
return control.exec$((element) => readControlValue(element)).then((value) => {
|
|
1122
3663
|
seeds.push({
|
|
1123
3664
|
target: field.target,
|
|
1124
|
-
value
|
|
3665
|
+
value,
|
|
1125
3666
|
dirty: dirtyTargets.has(field.target)
|
|
1126
3667
|
});
|
|
1127
3668
|
});
|
|
1128
3669
|
});
|
|
1129
3670
|
return Promise.all(reads).then(() => {
|
|
1130
|
-
|
|
3671
|
+
let changedTargets = [];
|
|
3672
|
+
setValues((current) => {
|
|
3673
|
+
const seeded = seedControlValues(current, seeds);
|
|
3674
|
+
changedTargets = seeded.changedTargets;
|
|
3675
|
+
return seeded.store;
|
|
3676
|
+
});
|
|
3677
|
+
return changedTargets;
|
|
1131
3678
|
});
|
|
1132
3679
|
}
|
|
3680
|
+
const watchedControls = /* @__PURE__ */ new WeakSet();
|
|
3681
|
+
function watchControlValues(refs, fields, onControlValueChange) {
|
|
3682
|
+
if (typeof MutationObserver === "undefined")
|
|
3683
|
+
return;
|
|
3684
|
+
for (const field of fields) {
|
|
3685
|
+
void refs[contractTagName(field.target)]?.control?.exec$((element) => {
|
|
3686
|
+
if (watchedControls.has(element))
|
|
3687
|
+
return;
|
|
3688
|
+
watchedControls.add(element);
|
|
3689
|
+
new MutationObserver(() => void onControlValueChange()).observe(element, {
|
|
3690
|
+
attributeFilter: ["data-value"]
|
|
3691
|
+
});
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
}
|
|
3695
|
+
function reconcilableFields(fields) {
|
|
3696
|
+
return fields.filter((field) => !field.hidden && field.inputType !== "checkbox" && field.inputType !== "multiselect");
|
|
3697
|
+
}
|
|
3698
|
+
function readBoundInputValue(refs, field) {
|
|
3699
|
+
const input = refs[contractTagName(field.target)]?.input;
|
|
3700
|
+
if (!input?.exec$)
|
|
3701
|
+
return Promise.resolve(void 0);
|
|
3702
|
+
return input.exec$((element) => element.value);
|
|
3703
|
+
}
|
|
1133
3704
|
function wireHoneypot(refs, record) {
|
|
1134
3705
|
refs.honeypot?.oninput(({ event }) => {
|
|
1135
3706
|
record(event.target.value ?? "");
|
|
@@ -1238,8 +3809,8 @@ function BookingFlowInteractive(_props, refs, viewStateSignals, _carryForward) {
|
|
|
1238
3809
|
setBookingFailure(BookingFailure.NONE);
|
|
1239
3810
|
setIsConfirmed(false);
|
|
1240
3811
|
}
|
|
1241
|
-
function failBooking(
|
|
1242
|
-
setBookingFailure(
|
|
3812
|
+
function failBooking(failure2, message) {
|
|
3813
|
+
setBookingFailure(failure2);
|
|
1243
3814
|
setBookingError(message);
|
|
1244
3815
|
}
|
|
1245
3816
|
async function onSelectService(service) {
|
|
@@ -1256,16 +3827,16 @@ function BookingFlowInteractive(_props, refs, viewStateSignals, _carryForward) {
|
|
|
1256
3827
|
setSlots([]);
|
|
1257
3828
|
setHasSlots(false);
|
|
1258
3829
|
try {
|
|
1259
|
-
const
|
|
3830
|
+
const result2 = await listSlots({
|
|
1260
3831
|
serviceId: service.id,
|
|
1261
3832
|
serviceType: service.type,
|
|
1262
3833
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
1263
3834
|
});
|
|
1264
|
-
if (!
|
|
3835
|
+
if (!result2.slots.length) {
|
|
1265
3836
|
setSlotsMessage("No available times in the next 14 days.");
|
|
1266
3837
|
}
|
|
1267
|
-
setSlots(
|
|
1268
|
-
setHasSlots(
|
|
3838
|
+
setSlots(result2.slots);
|
|
3839
|
+
setHasSlots(result2.slots.length > 0);
|
|
1269
3840
|
} catch (error) {
|
|
1270
3841
|
setSlotsFailure(SlotsFailure.UNKNOWN);
|
|
1271
3842
|
setSlotsMessage(error instanceof Error ? error.message : "Could not load availability.");
|
|
@@ -1288,8 +3859,8 @@ function BookingFlowInteractive(_props, refs, viewStateSignals, _carryForward) {
|
|
|
1288
3859
|
setFormFields(DEFAULT_PARTICIPANT_FIELDS);
|
|
1289
3860
|
return;
|
|
1290
3861
|
}
|
|
1291
|
-
const
|
|
1292
|
-
setFormFields(
|
|
3862
|
+
const result2 = await getFormSummary({ formId: service.formId });
|
|
3863
|
+
setFormFields(result2.fields.map((field) => ({
|
|
1293
3864
|
target: field.target,
|
|
1294
3865
|
label: field.label,
|
|
1295
3866
|
type: field.type,
|
|
@@ -1333,7 +3904,7 @@ function BookingFlowInteractive(_props, refs, viewStateSignals, _carryForward) {
|
|
|
1333
3904
|
}
|
|
1334
3905
|
setIsBooking(true);
|
|
1335
3906
|
try {
|
|
1336
|
-
const
|
|
3907
|
+
const result2 = await createBooking({
|
|
1337
3908
|
serviceId: service.id,
|
|
1338
3909
|
serviceType: service.type,
|
|
1339
3910
|
slot: {
|
|
@@ -1346,8 +3917,8 @@ function BookingFlowInteractive(_props, refs, viewStateSignals, _carryForward) {
|
|
|
1346
3917
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
1347
3918
|
siteOrigin: window.location.origin
|
|
1348
3919
|
});
|
|
1349
|
-
if (
|
|
1350
|
-
window.location.href =
|
|
3920
|
+
if (result2.outcome === "redirect") {
|
|
3921
|
+
window.location.href = result2.redirectUrl;
|
|
1351
3922
|
return;
|
|
1352
3923
|
}
|
|
1353
3924
|
setBookingStatus("Booking confirmed!");
|
|
@@ -1355,8 +3926,8 @@ function BookingFlowInteractive(_props, refs, viewStateSignals, _carryForward) {
|
|
|
1355
3926
|
setShowForm(false);
|
|
1356
3927
|
setSelectedSlot(null);
|
|
1357
3928
|
} catch (error) {
|
|
1358
|
-
const { failure, message } = describeBookingError(error);
|
|
1359
|
-
failBooking(
|
|
3929
|
+
const { failure: failure2, message } = describeBookingError(error);
|
|
3930
|
+
failBooking(failure2, message);
|
|
1360
3931
|
} finally {
|
|
1361
3932
|
setIsBooking(false);
|
|
1362
3933
|
}
|