intl-tel-input 25.4.1 → 25.4.3

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.
@@ -0,0 +1,3337 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // src/js/intl-tel-input/data.ts
13
+ var rawCountryData = [
14
+ [
15
+ "af",
16
+ // Afghanistan
17
+ "93"
18
+ ],
19
+ [
20
+ "ax",
21
+ // Åland Islands
22
+ "358",
23
+ 1
24
+ ],
25
+ [
26
+ "al",
27
+ // Albania
28
+ "355"
29
+ ],
30
+ [
31
+ "dz",
32
+ // Algeria
33
+ "213"
34
+ ],
35
+ [
36
+ "as",
37
+ // American Samoa
38
+ "1",
39
+ 5,
40
+ ["684"]
41
+ ],
42
+ [
43
+ "ad",
44
+ // Andorra
45
+ "376"
46
+ ],
47
+ [
48
+ "ao",
49
+ // Angola
50
+ "244"
51
+ ],
52
+ [
53
+ "ai",
54
+ // Anguilla
55
+ "1",
56
+ 6,
57
+ ["264"]
58
+ ],
59
+ [
60
+ "ag",
61
+ // Antigua and Barbuda
62
+ "1",
63
+ 7,
64
+ ["268"]
65
+ ],
66
+ [
67
+ "ar",
68
+ // Argentina
69
+ "54"
70
+ ],
71
+ [
72
+ "am",
73
+ // Armenia
74
+ "374"
75
+ ],
76
+ [
77
+ "aw",
78
+ // Aruba
79
+ "297"
80
+ ],
81
+ [
82
+ "ac",
83
+ // Ascension Island
84
+ "247"
85
+ ],
86
+ [
87
+ "au",
88
+ // Australia
89
+ "61",
90
+ 0,
91
+ null,
92
+ "0"
93
+ ],
94
+ [
95
+ "at",
96
+ // Austria
97
+ "43"
98
+ ],
99
+ [
100
+ "az",
101
+ // Azerbaijan
102
+ "994"
103
+ ],
104
+ [
105
+ "bs",
106
+ // Bahamas
107
+ "1",
108
+ 8,
109
+ ["242"]
110
+ ],
111
+ [
112
+ "bh",
113
+ // Bahrain
114
+ "973"
115
+ ],
116
+ [
117
+ "bd",
118
+ // Bangladesh
119
+ "880"
120
+ ],
121
+ [
122
+ "bb",
123
+ // Barbados
124
+ "1",
125
+ 9,
126
+ ["246"]
127
+ ],
128
+ [
129
+ "by",
130
+ // Belarus
131
+ "375"
132
+ ],
133
+ [
134
+ "be",
135
+ // Belgium
136
+ "32"
137
+ ],
138
+ [
139
+ "bz",
140
+ // Belize
141
+ "501"
142
+ ],
143
+ [
144
+ "bj",
145
+ // Benin
146
+ "229"
147
+ ],
148
+ [
149
+ "bm",
150
+ // Bermuda
151
+ "1",
152
+ 10,
153
+ ["441"]
154
+ ],
155
+ [
156
+ "bt",
157
+ // Bhutan
158
+ "975"
159
+ ],
160
+ [
161
+ "bo",
162
+ // Bolivia
163
+ "591"
164
+ ],
165
+ [
166
+ "ba",
167
+ // Bosnia and Herzegovina
168
+ "387"
169
+ ],
170
+ [
171
+ "bw",
172
+ // Botswana
173
+ "267"
174
+ ],
175
+ [
176
+ "br",
177
+ // Brazil
178
+ "55"
179
+ ],
180
+ [
181
+ "io",
182
+ // British Indian Ocean Territory
183
+ "246"
184
+ ],
185
+ [
186
+ "vg",
187
+ // British Virgin Islands
188
+ "1",
189
+ 11,
190
+ ["284"]
191
+ ],
192
+ [
193
+ "bn",
194
+ // Brunei
195
+ "673"
196
+ ],
197
+ [
198
+ "bg",
199
+ // Bulgaria
200
+ "359"
201
+ ],
202
+ [
203
+ "bf",
204
+ // Burkina Faso
205
+ "226"
206
+ ],
207
+ [
208
+ "bi",
209
+ // Burundi
210
+ "257"
211
+ ],
212
+ [
213
+ "kh",
214
+ // Cambodia
215
+ "855"
216
+ ],
217
+ [
218
+ "cm",
219
+ // Cameroon
220
+ "237"
221
+ ],
222
+ [
223
+ "ca",
224
+ // Canada
225
+ "1",
226
+ 1,
227
+ ["204", "226", "236", "249", "250", "263", "289", "306", "343", "354", "365", "367", "368", "382", "387", "403", "416", "418", "428", "431", "437", "438", "450", "584", "468", "474", "506", "514", "519", "548", "579", "581", "584", "587", "604", "613", "639", "647", "672", "683", "705", "709", "742", "753", "778", "780", "782", "807", "819", "825", "867", "873", "879", "902", "905"]
228
+ ],
229
+ [
230
+ "cv",
231
+ // Cape Verde
232
+ "238"
233
+ ],
234
+ [
235
+ "bq",
236
+ // Caribbean Netherlands
237
+ "599",
238
+ 1,
239
+ ["3", "4", "7"]
240
+ ],
241
+ [
242
+ "ky",
243
+ // Cayman Islands
244
+ "1",
245
+ 12,
246
+ ["345"]
247
+ ],
248
+ [
249
+ "cf",
250
+ // Central African Republic
251
+ "236"
252
+ ],
253
+ [
254
+ "td",
255
+ // Chad
256
+ "235"
257
+ ],
258
+ [
259
+ "cl",
260
+ // Chile
261
+ "56"
262
+ ],
263
+ [
264
+ "cn",
265
+ // China
266
+ "86"
267
+ ],
268
+ [
269
+ "cx",
270
+ // Christmas Island
271
+ "61",
272
+ 2,
273
+ ["89164"],
274
+ "0"
275
+ ],
276
+ [
277
+ "cc",
278
+ // Cocos (Keeling) Islands
279
+ "61",
280
+ 1,
281
+ ["89162"],
282
+ "0"
283
+ ],
284
+ [
285
+ "co",
286
+ // Colombia
287
+ "57"
288
+ ],
289
+ [
290
+ "km",
291
+ // Comoros
292
+ "269"
293
+ ],
294
+ [
295
+ "cg",
296
+ // Congo (Brazzaville)
297
+ "242"
298
+ ],
299
+ [
300
+ "cd",
301
+ // Congo (Kinshasa)
302
+ "243"
303
+ ],
304
+ [
305
+ "ck",
306
+ // Cook Islands
307
+ "682"
308
+ ],
309
+ [
310
+ "cr",
311
+ // Costa Rica
312
+ "506"
313
+ ],
314
+ [
315
+ "ci",
316
+ // Côte d'Ivoire
317
+ "225"
318
+ ],
319
+ [
320
+ "hr",
321
+ // Croatia
322
+ "385"
323
+ ],
324
+ [
325
+ "cu",
326
+ // Cuba
327
+ "53"
328
+ ],
329
+ [
330
+ "cw",
331
+ // Curaçao
332
+ "599",
333
+ 0
334
+ ],
335
+ [
336
+ "cy",
337
+ // Cyprus
338
+ "357"
339
+ ],
340
+ [
341
+ "cz",
342
+ // Czech Republic
343
+ "420"
344
+ ],
345
+ [
346
+ "dk",
347
+ // Denmark
348
+ "45"
349
+ ],
350
+ [
351
+ "dj",
352
+ // Djibouti
353
+ "253"
354
+ ],
355
+ [
356
+ "dm",
357
+ // Dominica
358
+ "1",
359
+ 13,
360
+ ["767"]
361
+ ],
362
+ [
363
+ "do",
364
+ // Dominican Republic
365
+ "1",
366
+ 2,
367
+ ["809", "829", "849"]
368
+ ],
369
+ [
370
+ "ec",
371
+ // Ecuador
372
+ "593"
373
+ ],
374
+ [
375
+ "eg",
376
+ // Egypt
377
+ "20"
378
+ ],
379
+ [
380
+ "sv",
381
+ // El Salvador
382
+ "503"
383
+ ],
384
+ [
385
+ "gq",
386
+ // Equatorial Guinea
387
+ "240"
388
+ ],
389
+ [
390
+ "er",
391
+ // Eritrea
392
+ "291"
393
+ ],
394
+ [
395
+ "ee",
396
+ // Estonia
397
+ "372"
398
+ ],
399
+ [
400
+ "sz",
401
+ // Eswatini
402
+ "268"
403
+ ],
404
+ [
405
+ "et",
406
+ // Ethiopia
407
+ "251"
408
+ ],
409
+ [
410
+ "fk",
411
+ // Falkland Islands (Malvinas)
412
+ "500"
413
+ ],
414
+ [
415
+ "fo",
416
+ // Faroe Islands
417
+ "298"
418
+ ],
419
+ [
420
+ "fj",
421
+ // Fiji
422
+ "679"
423
+ ],
424
+ [
425
+ "fi",
426
+ // Finland
427
+ "358",
428
+ 0
429
+ ],
430
+ [
431
+ "fr",
432
+ // France
433
+ "33"
434
+ ],
435
+ [
436
+ "gf",
437
+ // French Guiana
438
+ "594"
439
+ ],
440
+ [
441
+ "pf",
442
+ // French Polynesia
443
+ "689"
444
+ ],
445
+ [
446
+ "ga",
447
+ // Gabon
448
+ "241"
449
+ ],
450
+ [
451
+ "gm",
452
+ // Gambia
453
+ "220"
454
+ ],
455
+ [
456
+ "ge",
457
+ // Georgia
458
+ "995"
459
+ ],
460
+ [
461
+ "de",
462
+ // Germany
463
+ "49"
464
+ ],
465
+ [
466
+ "gh",
467
+ // Ghana
468
+ "233"
469
+ ],
470
+ [
471
+ "gi",
472
+ // Gibraltar
473
+ "350"
474
+ ],
475
+ [
476
+ "gr",
477
+ // Greece
478
+ "30"
479
+ ],
480
+ [
481
+ "gl",
482
+ // Greenland
483
+ "299"
484
+ ],
485
+ [
486
+ "gd",
487
+ // Grenada
488
+ "1",
489
+ 14,
490
+ ["473"]
491
+ ],
492
+ [
493
+ "gp",
494
+ // Guadeloupe
495
+ "590",
496
+ 0
497
+ ],
498
+ [
499
+ "gu",
500
+ // Guam
501
+ "1",
502
+ 15,
503
+ ["671"]
504
+ ],
505
+ [
506
+ "gt",
507
+ // Guatemala
508
+ "502"
509
+ ],
510
+ [
511
+ "gg",
512
+ // Guernsey
513
+ "44",
514
+ 1,
515
+ ["1481", "7781", "7839", "7911"],
516
+ "0"
517
+ ],
518
+ [
519
+ "gn",
520
+ // Guinea
521
+ "224"
522
+ ],
523
+ [
524
+ "gw",
525
+ // Guinea-Bissau
526
+ "245"
527
+ ],
528
+ [
529
+ "gy",
530
+ // Guyana
531
+ "592"
532
+ ],
533
+ [
534
+ "ht",
535
+ // Haiti
536
+ "509"
537
+ ],
538
+ [
539
+ "hn",
540
+ // Honduras
541
+ "504"
542
+ ],
543
+ [
544
+ "hk",
545
+ // Hong Kong SAR China
546
+ "852"
547
+ ],
548
+ [
549
+ "hu",
550
+ // Hungary
551
+ "36"
552
+ ],
553
+ [
554
+ "is",
555
+ // Iceland
556
+ "354"
557
+ ],
558
+ [
559
+ "in",
560
+ // India
561
+ "91"
562
+ ],
563
+ [
564
+ "id",
565
+ // Indonesia
566
+ "62"
567
+ ],
568
+ [
569
+ "ir",
570
+ // Iran
571
+ "98"
572
+ ],
573
+ [
574
+ "iq",
575
+ // Iraq
576
+ "964"
577
+ ],
578
+ [
579
+ "ie",
580
+ // Ireland
581
+ "353"
582
+ ],
583
+ [
584
+ "im",
585
+ // Isle of Man
586
+ "44",
587
+ 2,
588
+ ["1624", "74576", "7524", "7924", "7624"],
589
+ "0"
590
+ ],
591
+ [
592
+ "il",
593
+ // Israel
594
+ "972"
595
+ ],
596
+ [
597
+ "it",
598
+ // Italy
599
+ "39",
600
+ 0
601
+ ],
602
+ [
603
+ "jm",
604
+ // Jamaica
605
+ "1",
606
+ 4,
607
+ ["876", "658"]
608
+ ],
609
+ [
610
+ "jp",
611
+ // Japan
612
+ "81"
613
+ ],
614
+ [
615
+ "je",
616
+ // Jersey
617
+ "44",
618
+ 3,
619
+ ["1534", "7509", "7700", "7797", "7829", "7937"],
620
+ "0"
621
+ ],
622
+ [
623
+ "jo",
624
+ // Jordan
625
+ "962"
626
+ ],
627
+ [
628
+ "kz",
629
+ // Kazakhstan
630
+ "7",
631
+ 1,
632
+ ["33", "7"],
633
+ "8"
634
+ ],
635
+ [
636
+ "ke",
637
+ // Kenya
638
+ "254"
639
+ ],
640
+ [
641
+ "ki",
642
+ // Kiribati
643
+ "686"
644
+ ],
645
+ [
646
+ "xk",
647
+ // Kosovo
648
+ "383"
649
+ ],
650
+ [
651
+ "kw",
652
+ // Kuwait
653
+ "965"
654
+ ],
655
+ [
656
+ "kg",
657
+ // Kyrgyzstan
658
+ "996"
659
+ ],
660
+ [
661
+ "la",
662
+ // Laos
663
+ "856"
664
+ ],
665
+ [
666
+ "lv",
667
+ // Latvia
668
+ "371"
669
+ ],
670
+ [
671
+ "lb",
672
+ // Lebanon
673
+ "961"
674
+ ],
675
+ [
676
+ "ls",
677
+ // Lesotho
678
+ "266"
679
+ ],
680
+ [
681
+ "lr",
682
+ // Liberia
683
+ "231"
684
+ ],
685
+ [
686
+ "ly",
687
+ // Libya
688
+ "218"
689
+ ],
690
+ [
691
+ "li",
692
+ // Liechtenstein
693
+ "423"
694
+ ],
695
+ [
696
+ "lt",
697
+ // Lithuania
698
+ "370"
699
+ ],
700
+ [
701
+ "lu",
702
+ // Luxembourg
703
+ "352"
704
+ ],
705
+ [
706
+ "mo",
707
+ // Macao SAR China
708
+ "853"
709
+ ],
710
+ [
711
+ "mg",
712
+ // Madagascar
713
+ "261"
714
+ ],
715
+ [
716
+ "mw",
717
+ // Malawi
718
+ "265"
719
+ ],
720
+ [
721
+ "my",
722
+ // Malaysia
723
+ "60"
724
+ ],
725
+ [
726
+ "mv",
727
+ // Maldives
728
+ "960"
729
+ ],
730
+ [
731
+ "ml",
732
+ // Mali
733
+ "223"
734
+ ],
735
+ [
736
+ "mt",
737
+ // Malta
738
+ "356"
739
+ ],
740
+ [
741
+ "mh",
742
+ // Marshall Islands
743
+ "692"
744
+ ],
745
+ [
746
+ "mq",
747
+ // Martinique
748
+ "596"
749
+ ],
750
+ [
751
+ "mr",
752
+ // Mauritania
753
+ "222"
754
+ ],
755
+ [
756
+ "mu",
757
+ // Mauritius
758
+ "230"
759
+ ],
760
+ [
761
+ "yt",
762
+ // Mayotte
763
+ "262",
764
+ 1,
765
+ ["269", "639"],
766
+ "0"
767
+ ],
768
+ [
769
+ "mx",
770
+ // Mexico
771
+ "52"
772
+ ],
773
+ [
774
+ "fm",
775
+ // Micronesia
776
+ "691"
777
+ ],
778
+ [
779
+ "md",
780
+ // Moldova
781
+ "373"
782
+ ],
783
+ [
784
+ "mc",
785
+ // Monaco
786
+ "377"
787
+ ],
788
+ [
789
+ "mn",
790
+ // Mongolia
791
+ "976"
792
+ ],
793
+ [
794
+ "me",
795
+ // Montenegro
796
+ "382"
797
+ ],
798
+ [
799
+ "ms",
800
+ // Montserrat
801
+ "1",
802
+ 16,
803
+ ["664"]
804
+ ],
805
+ [
806
+ "ma",
807
+ // Morocco
808
+ "212",
809
+ 0,
810
+ null,
811
+ "0"
812
+ ],
813
+ [
814
+ "mz",
815
+ // Mozambique
816
+ "258"
817
+ ],
818
+ [
819
+ "mm",
820
+ // Myanmar (Burma)
821
+ "95"
822
+ ],
823
+ [
824
+ "na",
825
+ // Namibia
826
+ "264"
827
+ ],
828
+ [
829
+ "nr",
830
+ // Nauru
831
+ "674"
832
+ ],
833
+ [
834
+ "np",
835
+ // Nepal
836
+ "977"
837
+ ],
838
+ [
839
+ "nl",
840
+ // Netherlands
841
+ "31"
842
+ ],
843
+ [
844
+ "nc",
845
+ // New Caledonia
846
+ "687"
847
+ ],
848
+ [
849
+ "nz",
850
+ // New Zealand
851
+ "64"
852
+ ],
853
+ [
854
+ "ni",
855
+ // Nicaragua
856
+ "505"
857
+ ],
858
+ [
859
+ "ne",
860
+ // Niger
861
+ "227"
862
+ ],
863
+ [
864
+ "ng",
865
+ // Nigeria
866
+ "234"
867
+ ],
868
+ [
869
+ "nu",
870
+ // Niue
871
+ "683"
872
+ ],
873
+ [
874
+ "nf",
875
+ // Norfolk Island
876
+ "672"
877
+ ],
878
+ [
879
+ "kp",
880
+ // North Korea
881
+ "850"
882
+ ],
883
+ [
884
+ "mk",
885
+ // North Macedonia
886
+ "389"
887
+ ],
888
+ [
889
+ "mp",
890
+ // Northern Mariana Islands
891
+ "1",
892
+ 17,
893
+ ["670"]
894
+ ],
895
+ [
896
+ "no",
897
+ // Norway
898
+ "47",
899
+ 0
900
+ ],
901
+ [
902
+ "om",
903
+ // Oman
904
+ "968"
905
+ ],
906
+ [
907
+ "pk",
908
+ // Pakistan
909
+ "92"
910
+ ],
911
+ [
912
+ "pw",
913
+ // Palau
914
+ "680"
915
+ ],
916
+ [
917
+ "ps",
918
+ // Palestinian Territories
919
+ "970"
920
+ ],
921
+ [
922
+ "pa",
923
+ // Panama
924
+ "507"
925
+ ],
926
+ [
927
+ "pg",
928
+ // Papua New Guinea
929
+ "675"
930
+ ],
931
+ [
932
+ "py",
933
+ // Paraguay
934
+ "595"
935
+ ],
936
+ [
937
+ "pe",
938
+ // Peru
939
+ "51"
940
+ ],
941
+ [
942
+ "ph",
943
+ // Philippines
944
+ "63"
945
+ ],
946
+ [
947
+ "pl",
948
+ // Poland
949
+ "48"
950
+ ],
951
+ [
952
+ "pt",
953
+ // Portugal
954
+ "351"
955
+ ],
956
+ [
957
+ "pr",
958
+ // Puerto Rico
959
+ "1",
960
+ 3,
961
+ ["787", "939"]
962
+ ],
963
+ [
964
+ "qa",
965
+ // Qatar
966
+ "974"
967
+ ],
968
+ [
969
+ "re",
970
+ // Réunion
971
+ "262",
972
+ 0,
973
+ null,
974
+ "0"
975
+ ],
976
+ [
977
+ "ro",
978
+ // Romania
979
+ "40"
980
+ ],
981
+ [
982
+ "ru",
983
+ // Russia
984
+ "7",
985
+ 0,
986
+ null,
987
+ "8"
988
+ ],
989
+ [
990
+ "rw",
991
+ // Rwanda
992
+ "250"
993
+ ],
994
+ [
995
+ "ws",
996
+ // Samoa
997
+ "685"
998
+ ],
999
+ [
1000
+ "sm",
1001
+ // San Marino
1002
+ "378"
1003
+ ],
1004
+ [
1005
+ "st",
1006
+ // São Tomé & Príncipe
1007
+ "239"
1008
+ ],
1009
+ [
1010
+ "sa",
1011
+ // Saudi Arabia
1012
+ "966"
1013
+ ],
1014
+ [
1015
+ "sn",
1016
+ // Senegal
1017
+ "221"
1018
+ ],
1019
+ [
1020
+ "rs",
1021
+ // Serbia
1022
+ "381"
1023
+ ],
1024
+ [
1025
+ "sc",
1026
+ // Seychelles
1027
+ "248"
1028
+ ],
1029
+ [
1030
+ "sl",
1031
+ // Sierra Leone
1032
+ "232"
1033
+ ],
1034
+ [
1035
+ "sg",
1036
+ // Singapore
1037
+ "65"
1038
+ ],
1039
+ [
1040
+ "sx",
1041
+ // Sint Maarten
1042
+ "1",
1043
+ 21,
1044
+ ["721"]
1045
+ ],
1046
+ [
1047
+ "sk",
1048
+ // Slovakia
1049
+ "421"
1050
+ ],
1051
+ [
1052
+ "si",
1053
+ // Slovenia
1054
+ "386"
1055
+ ],
1056
+ [
1057
+ "sb",
1058
+ // Solomon Islands
1059
+ "677"
1060
+ ],
1061
+ [
1062
+ "so",
1063
+ // Somalia
1064
+ "252"
1065
+ ],
1066
+ [
1067
+ "za",
1068
+ // South Africa
1069
+ "27"
1070
+ ],
1071
+ [
1072
+ "kr",
1073
+ // South Korea
1074
+ "82"
1075
+ ],
1076
+ [
1077
+ "ss",
1078
+ // South Sudan
1079
+ "211"
1080
+ ],
1081
+ [
1082
+ "es",
1083
+ // Spain
1084
+ "34"
1085
+ ],
1086
+ [
1087
+ "lk",
1088
+ // Sri Lanka
1089
+ "94"
1090
+ ],
1091
+ [
1092
+ "bl",
1093
+ // St. Barthélemy
1094
+ "590",
1095
+ 1
1096
+ ],
1097
+ [
1098
+ "sh",
1099
+ // St. Helena
1100
+ "290"
1101
+ ],
1102
+ [
1103
+ "kn",
1104
+ // St. Kitts & Nevis
1105
+ "1",
1106
+ 18,
1107
+ ["869"]
1108
+ ],
1109
+ [
1110
+ "lc",
1111
+ // St. Lucia
1112
+ "1",
1113
+ 19,
1114
+ ["758"]
1115
+ ],
1116
+ [
1117
+ "mf",
1118
+ // St. Martin
1119
+ "590",
1120
+ 2
1121
+ ],
1122
+ [
1123
+ "pm",
1124
+ // St. Pierre & Miquelon
1125
+ "508"
1126
+ ],
1127
+ [
1128
+ "vc",
1129
+ // St. Vincent & Grenadines
1130
+ "1",
1131
+ 20,
1132
+ ["784"]
1133
+ ],
1134
+ [
1135
+ "sd",
1136
+ // Sudan
1137
+ "249"
1138
+ ],
1139
+ [
1140
+ "sr",
1141
+ // Suriname
1142
+ "597"
1143
+ ],
1144
+ [
1145
+ "sj",
1146
+ // Svalbard & Jan Mayen
1147
+ "47",
1148
+ 1,
1149
+ ["79"]
1150
+ ],
1151
+ [
1152
+ "se",
1153
+ // Sweden
1154
+ "46"
1155
+ ],
1156
+ [
1157
+ "ch",
1158
+ // Switzerland
1159
+ "41"
1160
+ ],
1161
+ [
1162
+ "sy",
1163
+ // Syria
1164
+ "963"
1165
+ ],
1166
+ [
1167
+ "tw",
1168
+ // Taiwan
1169
+ "886"
1170
+ ],
1171
+ [
1172
+ "tj",
1173
+ // Tajikistan
1174
+ "992"
1175
+ ],
1176
+ [
1177
+ "tz",
1178
+ // Tanzania
1179
+ "255"
1180
+ ],
1181
+ [
1182
+ "th",
1183
+ // Thailand
1184
+ "66"
1185
+ ],
1186
+ [
1187
+ "tl",
1188
+ // Timor-Leste
1189
+ "670"
1190
+ ],
1191
+ [
1192
+ "tg",
1193
+ // Togo
1194
+ "228"
1195
+ ],
1196
+ [
1197
+ "tk",
1198
+ // Tokelau
1199
+ "690"
1200
+ ],
1201
+ [
1202
+ "to",
1203
+ // Tonga
1204
+ "676"
1205
+ ],
1206
+ [
1207
+ "tt",
1208
+ // Trinidad & Tobago
1209
+ "1",
1210
+ 22,
1211
+ ["868"]
1212
+ ],
1213
+ [
1214
+ "tn",
1215
+ // Tunisia
1216
+ "216"
1217
+ ],
1218
+ [
1219
+ "tr",
1220
+ // Turkey
1221
+ "90"
1222
+ ],
1223
+ [
1224
+ "tm",
1225
+ // Turkmenistan
1226
+ "993"
1227
+ ],
1228
+ [
1229
+ "tc",
1230
+ // Turks & Caicos Islands
1231
+ "1",
1232
+ 23,
1233
+ ["649"]
1234
+ ],
1235
+ [
1236
+ "tv",
1237
+ // Tuvalu
1238
+ "688"
1239
+ ],
1240
+ [
1241
+ "ug",
1242
+ // Uganda
1243
+ "256"
1244
+ ],
1245
+ [
1246
+ "ua",
1247
+ // Ukraine
1248
+ "380"
1249
+ ],
1250
+ [
1251
+ "ae",
1252
+ // United Arab Emirates
1253
+ "971"
1254
+ ],
1255
+ [
1256
+ "gb",
1257
+ // United Kingdom
1258
+ "44",
1259
+ 0,
1260
+ null,
1261
+ "0"
1262
+ ],
1263
+ [
1264
+ "us",
1265
+ // United States
1266
+ "1",
1267
+ 0
1268
+ ],
1269
+ [
1270
+ "uy",
1271
+ // Uruguay
1272
+ "598"
1273
+ ],
1274
+ [
1275
+ "vi",
1276
+ // U.S. Virgin Islands
1277
+ "1",
1278
+ 24,
1279
+ ["340"]
1280
+ ],
1281
+ [
1282
+ "uz",
1283
+ // Uzbekistan
1284
+ "998"
1285
+ ],
1286
+ [
1287
+ "vu",
1288
+ // Vanuatu
1289
+ "678"
1290
+ ],
1291
+ [
1292
+ "va",
1293
+ // Vatican City
1294
+ "39",
1295
+ 1,
1296
+ ["06698"]
1297
+ ],
1298
+ [
1299
+ "ve",
1300
+ // Venezuela
1301
+ "58"
1302
+ ],
1303
+ [
1304
+ "vn",
1305
+ // Vietnam
1306
+ "84"
1307
+ ],
1308
+ [
1309
+ "wf",
1310
+ // Wallis & Futuna
1311
+ "681"
1312
+ ],
1313
+ [
1314
+ "eh",
1315
+ // Western Sahara
1316
+ "212",
1317
+ 1,
1318
+ ["5288", "5289"],
1319
+ "0"
1320
+ ],
1321
+ [
1322
+ "ye",
1323
+ // Yemen
1324
+ "967"
1325
+ ],
1326
+ [
1327
+ "zm",
1328
+ // Zambia
1329
+ "260"
1330
+ ],
1331
+ [
1332
+ "zw",
1333
+ // Zimbabwe
1334
+ "263"
1335
+ ]
1336
+ ];
1337
+ var allCountries = [];
1338
+ for (let i = 0; i < rawCountryData.length; i++) {
1339
+ const c = rawCountryData[i];
1340
+ allCountries[i] = {
1341
+ name: "",
1342
+ // this is now populated in the plugin
1343
+ iso2: c[0],
1344
+ dialCode: c[1],
1345
+ priority: c[2] || 0,
1346
+ areaCodes: c[3] || null,
1347
+ nodeById: {},
1348
+ nationalPrefix: c[4] || null
1349
+ };
1350
+ }
1351
+ var data_default = allCountries;
1352
+
1353
+ // src/js/intl-tel-input/i18n/en/countries.ts
1354
+ var countryTranslations = {
1355
+ ad: "Andorra",
1356
+ ae: "United Arab Emirates",
1357
+ af: "Afghanistan",
1358
+ ag: "Antigua & Barbuda",
1359
+ ai: "Anguilla",
1360
+ al: "Albania",
1361
+ am: "Armenia",
1362
+ ao: "Angola",
1363
+ ar: "Argentina",
1364
+ as: "American Samoa",
1365
+ at: "Austria",
1366
+ au: "Australia",
1367
+ aw: "Aruba",
1368
+ ax: "\xC5land Islands",
1369
+ az: "Azerbaijan",
1370
+ ba: "Bosnia & Herzegovina",
1371
+ bb: "Barbados",
1372
+ bd: "Bangladesh",
1373
+ be: "Belgium",
1374
+ bf: "Burkina Faso",
1375
+ bg: "Bulgaria",
1376
+ bh: "Bahrain",
1377
+ bi: "Burundi",
1378
+ bj: "Benin",
1379
+ bl: "St. Barth\xE9lemy",
1380
+ bm: "Bermuda",
1381
+ bn: "Brunei",
1382
+ bo: "Bolivia",
1383
+ bq: "Caribbean Netherlands",
1384
+ br: "Brazil",
1385
+ bs: "Bahamas",
1386
+ bt: "Bhutan",
1387
+ bw: "Botswana",
1388
+ by: "Belarus",
1389
+ bz: "Belize",
1390
+ ca: "Canada",
1391
+ cc: "Cocos (Keeling) Islands",
1392
+ cd: "Congo - Kinshasa",
1393
+ cf: "Central African Republic",
1394
+ cg: "Congo - Brazzaville",
1395
+ ch: "Switzerland",
1396
+ ci: "C\xF4te d\u2019Ivoire",
1397
+ ck: "Cook Islands",
1398
+ cl: "Chile",
1399
+ cm: "Cameroon",
1400
+ cn: "China",
1401
+ co: "Colombia",
1402
+ cr: "Costa Rica",
1403
+ cu: "Cuba",
1404
+ cv: "Cape Verde",
1405
+ cw: "Cura\xE7ao",
1406
+ cx: "Christmas Island",
1407
+ cy: "Cyprus",
1408
+ cz: "Czechia",
1409
+ de: "Germany",
1410
+ dj: "Djibouti",
1411
+ dk: "Denmark",
1412
+ dm: "Dominica",
1413
+ do: "Dominican Republic",
1414
+ dz: "Algeria",
1415
+ ec: "Ecuador",
1416
+ ee: "Estonia",
1417
+ eg: "Egypt",
1418
+ eh: "Western Sahara",
1419
+ er: "Eritrea",
1420
+ es: "Spain",
1421
+ et: "Ethiopia",
1422
+ fi: "Finland",
1423
+ fj: "Fiji",
1424
+ fk: "Falkland Islands",
1425
+ fm: "Micronesia",
1426
+ fo: "Faroe Islands",
1427
+ fr: "France",
1428
+ ga: "Gabon",
1429
+ gb: "United Kingdom",
1430
+ gd: "Grenada",
1431
+ ge: "Georgia",
1432
+ gf: "French Guiana",
1433
+ gg: "Guernsey",
1434
+ gh: "Ghana",
1435
+ gi: "Gibraltar",
1436
+ gl: "Greenland",
1437
+ gm: "Gambia",
1438
+ gn: "Guinea",
1439
+ gp: "Guadeloupe",
1440
+ gq: "Equatorial Guinea",
1441
+ gr: "Greece",
1442
+ gt: "Guatemala",
1443
+ gu: "Guam",
1444
+ gw: "Guinea-Bissau",
1445
+ gy: "Guyana",
1446
+ hk: "Hong Kong SAR China",
1447
+ hn: "Honduras",
1448
+ hr: "Croatia",
1449
+ ht: "Haiti",
1450
+ hu: "Hungary",
1451
+ id: "Indonesia",
1452
+ ie: "Ireland",
1453
+ il: "Israel",
1454
+ im: "Isle of Man",
1455
+ in: "India",
1456
+ io: "British Indian Ocean Territory",
1457
+ iq: "Iraq",
1458
+ ir: "Iran",
1459
+ is: "Iceland",
1460
+ it: "Italy",
1461
+ je: "Jersey",
1462
+ jm: "Jamaica",
1463
+ jo: "Jordan",
1464
+ jp: "Japan",
1465
+ ke: "Kenya",
1466
+ kg: "Kyrgyzstan",
1467
+ kh: "Cambodia",
1468
+ ki: "Kiribati",
1469
+ km: "Comoros",
1470
+ kn: "St. Kitts & Nevis",
1471
+ kp: "North Korea",
1472
+ kr: "South Korea",
1473
+ kw: "Kuwait",
1474
+ ky: "Cayman Islands",
1475
+ kz: "Kazakhstan",
1476
+ la: "Laos",
1477
+ lb: "Lebanon",
1478
+ lc: "St. Lucia",
1479
+ li: "Liechtenstein",
1480
+ lk: "Sri Lanka",
1481
+ lr: "Liberia",
1482
+ ls: "Lesotho",
1483
+ lt: "Lithuania",
1484
+ lu: "Luxembourg",
1485
+ lv: "Latvia",
1486
+ ly: "Libya",
1487
+ ma: "Morocco",
1488
+ mc: "Monaco",
1489
+ md: "Moldova",
1490
+ me: "Montenegro",
1491
+ mf: "St. Martin",
1492
+ mg: "Madagascar",
1493
+ mh: "Marshall Islands",
1494
+ mk: "North Macedonia",
1495
+ ml: "Mali",
1496
+ mm: "Myanmar (Burma)",
1497
+ mn: "Mongolia",
1498
+ mo: "Macao SAR China",
1499
+ mp: "Northern Mariana Islands",
1500
+ mq: "Martinique",
1501
+ mr: "Mauritania",
1502
+ ms: "Montserrat",
1503
+ mt: "Malta",
1504
+ mu: "Mauritius",
1505
+ mv: "Maldives",
1506
+ mw: "Malawi",
1507
+ mx: "Mexico",
1508
+ my: "Malaysia",
1509
+ mz: "Mozambique",
1510
+ na: "Namibia",
1511
+ nc: "New Caledonia",
1512
+ ne: "Niger",
1513
+ nf: "Norfolk Island",
1514
+ ng: "Nigeria",
1515
+ ni: "Nicaragua",
1516
+ nl: "Netherlands",
1517
+ no: "Norway",
1518
+ np: "Nepal",
1519
+ nr: "Nauru",
1520
+ nu: "Niue",
1521
+ nz: "New Zealand",
1522
+ om: "Oman",
1523
+ pa: "Panama",
1524
+ pe: "Peru",
1525
+ pf: "French Polynesia",
1526
+ pg: "Papua New Guinea",
1527
+ ph: "Philippines",
1528
+ pk: "Pakistan",
1529
+ pl: "Poland",
1530
+ pm: "St. Pierre & Miquelon",
1531
+ pr: "Puerto Rico",
1532
+ ps: "Palestinian Territories",
1533
+ pt: "Portugal",
1534
+ pw: "Palau",
1535
+ py: "Paraguay",
1536
+ qa: "Qatar",
1537
+ re: "R\xE9union",
1538
+ ro: "Romania",
1539
+ rs: "Serbia",
1540
+ ru: "Russia",
1541
+ rw: "Rwanda",
1542
+ sa: "Saudi Arabia",
1543
+ sb: "Solomon Islands",
1544
+ sc: "Seychelles",
1545
+ sd: "Sudan",
1546
+ se: "Sweden",
1547
+ sg: "Singapore",
1548
+ sh: "St. Helena",
1549
+ si: "Slovenia",
1550
+ sj: "Svalbard & Jan Mayen",
1551
+ sk: "Slovakia",
1552
+ sl: "Sierra Leone",
1553
+ sm: "San Marino",
1554
+ sn: "Senegal",
1555
+ so: "Somalia",
1556
+ sr: "Suriname",
1557
+ ss: "South Sudan",
1558
+ st: "S\xE3o Tom\xE9 & Pr\xEDncipe",
1559
+ sv: "El Salvador",
1560
+ sx: "Sint Maarten",
1561
+ sy: "Syria",
1562
+ sz: "Eswatini",
1563
+ tc: "Turks & Caicos Islands",
1564
+ td: "Chad",
1565
+ tg: "Togo",
1566
+ th: "Thailand",
1567
+ tj: "Tajikistan",
1568
+ tk: "Tokelau",
1569
+ tl: "Timor-Leste",
1570
+ tm: "Turkmenistan",
1571
+ tn: "Tunisia",
1572
+ to: "Tonga",
1573
+ tr: "Turkey",
1574
+ tt: "Trinidad & Tobago",
1575
+ tv: "Tuvalu",
1576
+ tw: "Taiwan",
1577
+ tz: "Tanzania",
1578
+ ua: "Ukraine",
1579
+ ug: "Uganda",
1580
+ us: "United States",
1581
+ uy: "Uruguay",
1582
+ uz: "Uzbekistan",
1583
+ va: "Vatican City",
1584
+ vc: "St. Vincent & Grenadines",
1585
+ ve: "Venezuela",
1586
+ vg: "British Virgin Islands",
1587
+ vi: "U.S. Virgin Islands",
1588
+ vn: "Vietnam",
1589
+ vu: "Vanuatu",
1590
+ wf: "Wallis & Futuna",
1591
+ ws: "Samoa",
1592
+ ye: "Yemen",
1593
+ yt: "Mayotte",
1594
+ za: "South Africa",
1595
+ zm: "Zambia",
1596
+ zw: "Zimbabwe"
1597
+ };
1598
+ var countries_default = countryTranslations;
1599
+
1600
+ // src/js/intl-tel-input/i18n/en/interface.ts
1601
+ var interfaceTranslations = {
1602
+ selectedCountryAriaLabel: "Selected country",
1603
+ noCountrySelected: "No country selected",
1604
+ countryListAriaLabel: "List of countries",
1605
+ searchPlaceholder: "Search",
1606
+ zeroSearchResults: "No results found",
1607
+ oneSearchResult: "1 result found",
1608
+ multipleSearchResults: "${count} results found",
1609
+ // additional countries (not supported by country-list library)
1610
+ ac: "Ascension Island",
1611
+ xk: "Kosovo"
1612
+ };
1613
+ var interface_default = interfaceTranslations;
1614
+
1615
+ // src/js/intl-tel-input/i18n/en/index.ts
1616
+ var allTranslations = { ...countries_default, ...interface_default };
1617
+ var en_default = allTranslations;
1618
+
1619
+ // src/js/intl-tel-input.ts
1620
+ for (let i = 0; i < data_default.length; i++) {
1621
+ data_default[i].name = en_default[data_default[i].iso2];
1622
+ }
1623
+ var id = 0;
1624
+ var defaults = {
1625
+ //* Whether or not to allow the dropdown.
1626
+ allowDropdown: true,
1627
+ //* Add a placeholder in the input with an example number for the selected country.
1628
+ autoPlaceholder: "polite",
1629
+ //* Modify the parentClass.
1630
+ containerClass: "",
1631
+ //* The order of the countries in the dropdown. Defaults to alphabetical.
1632
+ countryOrder: null,
1633
+ //* Add a country search input at the top of the dropdown.
1634
+ countrySearch: true,
1635
+ //* Modify the auto placeholder.
1636
+ customPlaceholder: null,
1637
+ //* Append menu to specified element.
1638
+ dropdownContainer: null,
1639
+ //* Don't display these countries.
1640
+ excludeCountries: [],
1641
+ //* Fix the dropdown width to the input width (rather than being as wide as the longest country name).
1642
+ fixDropdownWidth: true,
1643
+ //* Format the number as the user types
1644
+ formatAsYouType: true,
1645
+ //* Format the input value during initialisation and on setNumber.
1646
+ formatOnDisplay: true,
1647
+ //* geoIp lookup function.
1648
+ geoIpLookup: null,
1649
+ //* Inject a hidden input with the name returned from this function, and on submit, populate it with the result of getNumber.
1650
+ hiddenInput: null,
1651
+ //* Internationalise the plugin text e.g. search input placeholder, country names.
1652
+ i18n: {},
1653
+ //* Initial country.
1654
+ initialCountry: "",
1655
+ //* A function to load the utils script.
1656
+ loadUtils: null,
1657
+ //* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
1658
+ nationalMode: true,
1659
+ //* Display only these countries.
1660
+ onlyCountries: [],
1661
+ //* Number type to use for placeholders.
1662
+ placeholderNumberType: "MOBILE",
1663
+ //* Show flags - for both the selected country, and in the country dropdown
1664
+ showFlags: true,
1665
+ //* Display the international dial code next to the selected flag.
1666
+ separateDialCode: false,
1667
+ //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1668
+ strictMode: false,
1669
+ //* Use full screen popup instead of dropdown for country list.
1670
+ useFullscreenPopup: typeof navigator !== "undefined" && typeof window !== "undefined" ? (
1671
+ //* We cannot just test screen size as some smartphones/website meta tags will report desktop resolutions.
1672
+ //* Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
1673
+ /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1674
+ navigator.userAgent
1675
+ ) || window.innerWidth <= 500
1676
+ ) : false,
1677
+ //* The number type to enforce during validation.
1678
+ validationNumberTypes: ["MOBILE"]
1679
+ };
1680
+ var regionlessNanpNumbers = [
1681
+ "800",
1682
+ "822",
1683
+ "833",
1684
+ "844",
1685
+ "855",
1686
+ "866",
1687
+ "877",
1688
+ "880",
1689
+ "881",
1690
+ "882",
1691
+ "883",
1692
+ "884",
1693
+ "885",
1694
+ "886",
1695
+ "887",
1696
+ "888",
1697
+ "889"
1698
+ ];
1699
+ var getNumeric = (s) => s.replace(/\D/g, "");
1700
+ var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
1701
+ var isRegionlessNanp = (number) => {
1702
+ const numeric = getNumeric(number);
1703
+ if (numeric.charAt(0) === "1") {
1704
+ const areaCode = numeric.substr(1, 3);
1705
+ return regionlessNanpNumbers.includes(areaCode);
1706
+ }
1707
+ return false;
1708
+ };
1709
+ var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDeleteForwards) => {
1710
+ if (prevCaretPos === 0 && !isDeleteForwards) {
1711
+ return 0;
1712
+ }
1713
+ let count = 0;
1714
+ for (let i = 0; i < formattedValue.length; i++) {
1715
+ if (/[+0-9]/.test(formattedValue[i])) {
1716
+ count++;
1717
+ }
1718
+ if (count === relevantChars && !isDeleteForwards) {
1719
+ return i + 1;
1720
+ }
1721
+ if (isDeleteForwards && count === relevantChars + 1) {
1722
+ return i;
1723
+ }
1724
+ }
1725
+ return formattedValue.length;
1726
+ };
1727
+ var createEl = (name, attrs, container) => {
1728
+ const el = document.createElement(name);
1729
+ if (attrs) {
1730
+ Object.entries(attrs).forEach(([key, value]) => el.setAttribute(key, value));
1731
+ }
1732
+ if (container) {
1733
+ container.appendChild(el);
1734
+ }
1735
+ return el;
1736
+ };
1737
+ var forEachInstance = (method, ...args) => {
1738
+ const { instances } = intlTelInput;
1739
+ Object.values(instances).forEach((instance) => instance[method](...args));
1740
+ };
1741
+ var Iti = class {
1742
+ constructor(input, customOptions = {}) {
1743
+ this.id = id++;
1744
+ this.telInput = input;
1745
+ this.highlightedItem = null;
1746
+ this.options = Object.assign({}, defaults, customOptions);
1747
+ this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
1748
+ }
1749
+ //* Can't be private as it's called from intlTelInput convenience wrapper.
1750
+ _init() {
1751
+ if (this.options.useFullscreenPopup) {
1752
+ this.options.fixDropdownWidth = false;
1753
+ }
1754
+ if (this.options.onlyCountries.length === 1) {
1755
+ this.options.initialCountry = this.options.onlyCountries[0];
1756
+ }
1757
+ if (this.options.separateDialCode) {
1758
+ this.options.nationalMode = false;
1759
+ }
1760
+ if (this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode) {
1761
+ this.options.nationalMode = false;
1762
+ }
1763
+ if (this.options.useFullscreenPopup && !this.options.dropdownContainer) {
1764
+ this.options.dropdownContainer = document.body;
1765
+ }
1766
+ this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
1767
+ this.isRTL = !!this.telInput.closest("[dir=rtl]");
1768
+ const showOnDefaultSide = this.options.allowDropdown || this.options.separateDialCode;
1769
+ this.showSelectedCountryOnLeft = this.isRTL ? !showOnDefaultSide : showOnDefaultSide;
1770
+ if (this.options.separateDialCode) {
1771
+ if (this.isRTL) {
1772
+ this.originalPaddingRight = this.telInput.style.paddingRight;
1773
+ } else {
1774
+ this.originalPaddingLeft = this.telInput.style.paddingLeft;
1775
+ }
1776
+ }
1777
+ this.options.i18n = { ...en_default, ...this.options.i18n };
1778
+ const autoCountryPromise = new Promise((resolve, reject) => {
1779
+ this.resolveAutoCountryPromise = resolve;
1780
+ this.rejectAutoCountryPromise = reject;
1781
+ });
1782
+ const utilsScriptPromise = new Promise((resolve, reject) => {
1783
+ this.resolveUtilsScriptPromise = resolve;
1784
+ this.rejectUtilsScriptPromise = reject;
1785
+ });
1786
+ this.promise = Promise.all([autoCountryPromise, utilsScriptPromise]);
1787
+ this.selectedCountryData = {};
1788
+ this._processCountryData();
1789
+ this._generateMarkup();
1790
+ this._setInitialState();
1791
+ this._initListeners();
1792
+ this._initRequests();
1793
+ }
1794
+ //********************
1795
+ //* PRIVATE METHODS
1796
+ //********************
1797
+ //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
1798
+ _processCountryData() {
1799
+ this._processAllCountries();
1800
+ this._processDialCodes();
1801
+ this._translateCountryNames();
1802
+ this._sortCountries();
1803
+ }
1804
+ //* Sort countries by countryOrder option (if present), then name.
1805
+ _sortCountries() {
1806
+ if (this.options.countryOrder) {
1807
+ this.options.countryOrder = this.options.countryOrder.map((country) => country.toLowerCase());
1808
+ }
1809
+ this.countries.sort((a, b) => {
1810
+ const { countryOrder } = this.options;
1811
+ if (countryOrder) {
1812
+ const aIndex = countryOrder.indexOf(a.iso2);
1813
+ const bIndex = countryOrder.indexOf(b.iso2);
1814
+ const aIndexExists = aIndex > -1;
1815
+ const bIndexExists = bIndex > -1;
1816
+ if (aIndexExists || bIndexExists) {
1817
+ if (aIndexExists && bIndexExists) {
1818
+ return aIndex - bIndex;
1819
+ }
1820
+ return aIndexExists ? -1 : 1;
1821
+ }
1822
+ }
1823
+ return a.name.localeCompare(b.name);
1824
+ });
1825
+ }
1826
+ //* Add a dial code to this.dialCodeToIso2Map.
1827
+ _addToDialCodeMap(iso2, dialCode, priority) {
1828
+ if (dialCode.length > this.dialCodeMaxLen) {
1829
+ this.dialCodeMaxLen = dialCode.length;
1830
+ }
1831
+ if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {
1832
+ this.dialCodeToIso2Map[dialCode] = [];
1833
+ }
1834
+ for (let i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) {
1835
+ if (this.dialCodeToIso2Map[dialCode][i] === iso2) {
1836
+ return;
1837
+ }
1838
+ }
1839
+ const index = priority !== void 0 ? priority : this.dialCodeToIso2Map[dialCode].length;
1840
+ this.dialCodeToIso2Map[dialCode][index] = iso2;
1841
+ }
1842
+ //* Process onlyCountries or excludeCountries array if present.
1843
+ _processAllCountries() {
1844
+ const { onlyCountries, excludeCountries } = this.options;
1845
+ if (onlyCountries.length) {
1846
+ const lowerCaseOnlyCountries = onlyCountries.map(
1847
+ (country) => country.toLowerCase()
1848
+ );
1849
+ this.countries = data_default.filter(
1850
+ (country) => lowerCaseOnlyCountries.includes(country.iso2)
1851
+ );
1852
+ } else if (excludeCountries.length) {
1853
+ const lowerCaseExcludeCountries = excludeCountries.map(
1854
+ (country) => country.toLowerCase()
1855
+ );
1856
+ this.countries = data_default.filter(
1857
+ (country) => !lowerCaseExcludeCountries.includes(country.iso2)
1858
+ );
1859
+ } else {
1860
+ this.countries = data_default;
1861
+ }
1862
+ }
1863
+ //* Translate Countries by object literal provided on config.
1864
+ _translateCountryNames() {
1865
+ for (let i = 0; i < this.countries.length; i++) {
1866
+ const iso2 = this.countries[i].iso2.toLowerCase();
1867
+ if (this.options.i18n.hasOwnProperty(iso2)) {
1868
+ this.countries[i].name = this.options.i18n[iso2];
1869
+ }
1870
+ }
1871
+ }
1872
+ //* Generate this.dialCodes and this.dialCodeToIso2Map.
1873
+ _processDialCodes() {
1874
+ this.dialCodes = {};
1875
+ this.dialCodeMaxLen = 0;
1876
+ this.dialCodeToIso2Map = {};
1877
+ for (let i = 0; i < this.countries.length; i++) {
1878
+ const c = this.countries[i];
1879
+ if (!this.dialCodes[c.dialCode]) {
1880
+ this.dialCodes[c.dialCode] = true;
1881
+ }
1882
+ this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
1883
+ }
1884
+ for (let i = 0; i < this.countries.length; i++) {
1885
+ const c = this.countries[i];
1886
+ if (c.areaCodes) {
1887
+ const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
1888
+ for (let j = 0; j < c.areaCodes.length; j++) {
1889
+ const areaCode = c.areaCodes[j];
1890
+ for (let k = 1; k < areaCode.length; k++) {
1891
+ const partialAreaCode = areaCode.substr(0, k);
1892
+ const partialDialCode = c.dialCode + partialAreaCode;
1893
+ this._addToDialCodeMap(rootIso2Code, partialDialCode);
1894
+ this._addToDialCodeMap(c.iso2, partialDialCode);
1895
+ }
1896
+ this._addToDialCodeMap(c.iso2, c.dialCode + areaCode);
1897
+ }
1898
+ }
1899
+ }
1900
+ }
1901
+ //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
1902
+ _generateMarkup() {
1903
+ this.telInput.classList.add("iti__tel-input");
1904
+ if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
1905
+ this.telInput.setAttribute("autocomplete", "off");
1906
+ }
1907
+ const {
1908
+ allowDropdown,
1909
+ separateDialCode,
1910
+ showFlags,
1911
+ containerClass,
1912
+ hiddenInput,
1913
+ dropdownContainer,
1914
+ fixDropdownWidth,
1915
+ useFullscreenPopup,
1916
+ countrySearch,
1917
+ i18n
1918
+ } = this.options;
1919
+ let parentClass = "iti";
1920
+ if (allowDropdown) {
1921
+ parentClass += " iti--allow-dropdown";
1922
+ }
1923
+ if (showFlags) {
1924
+ parentClass += " iti--show-flags";
1925
+ }
1926
+ if (containerClass) {
1927
+ parentClass += ` ${containerClass}`;
1928
+ }
1929
+ if (!useFullscreenPopup) {
1930
+ parentClass += " iti--inline-dropdown";
1931
+ }
1932
+ const wrapper = createEl("div", { class: parentClass });
1933
+ this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
1934
+ if (allowDropdown || showFlags || separateDialCode) {
1935
+ this.countryContainer = createEl(
1936
+ "div",
1937
+ { class: "iti__country-container" },
1938
+ wrapper
1939
+ );
1940
+ if (this.showSelectedCountryOnLeft) {
1941
+ this.countryContainer.style.left = "0px";
1942
+ } else {
1943
+ this.countryContainer.style.right = "0px";
1944
+ }
1945
+ if (allowDropdown) {
1946
+ this.selectedCountry = createEl(
1947
+ "button",
1948
+ {
1949
+ type: "button",
1950
+ class: "iti__selected-country",
1951
+ "aria-expanded": "false",
1952
+ "aria-label": this.options.i18n.selectedCountryAriaLabel,
1953
+ "aria-haspopup": "true",
1954
+ "aria-controls": `iti-${this.id}__dropdown-content`,
1955
+ "role": "combobox"
1956
+ },
1957
+ this.countryContainer
1958
+ );
1959
+ if (this.telInput.disabled) {
1960
+ this.selectedCountry.setAttribute("disabled", "true");
1961
+ }
1962
+ } else {
1963
+ this.selectedCountry = createEl(
1964
+ "div",
1965
+ { class: "iti__selected-country" },
1966
+ this.countryContainer
1967
+ );
1968
+ }
1969
+ const selectedCountryPrimary = createEl("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
1970
+ this.selectedCountryInner = createEl("div", { class: "iti__flag" }, selectedCountryPrimary);
1971
+ this.selectedCountryA11yText = createEl(
1972
+ "span",
1973
+ { class: "iti__a11y-text" },
1974
+ this.selectedCountryInner
1975
+ );
1976
+ if (allowDropdown) {
1977
+ this.dropdownArrow = createEl(
1978
+ "div",
1979
+ { class: "iti__arrow", "aria-hidden": "true" },
1980
+ selectedCountryPrimary
1981
+ );
1982
+ }
1983
+ if (separateDialCode) {
1984
+ this.selectedDialCode = createEl(
1985
+ "div",
1986
+ { class: "iti__selected-dial-code" },
1987
+ this.selectedCountry
1988
+ );
1989
+ }
1990
+ if (allowDropdown) {
1991
+ const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
1992
+ this.dropdownContent = createEl("div", {
1993
+ id: `iti-${this.id}__dropdown-content`,
1994
+ class: `iti__dropdown-content iti__hide ${extraClasses}`
1995
+ });
1996
+ if (countrySearch) {
1997
+ this.searchInput = createEl(
1998
+ "input",
1999
+ {
2000
+ type: "text",
2001
+ class: "iti__search-input",
2002
+ placeholder: i18n.searchPlaceholder,
2003
+ role: "combobox",
2004
+ "aria-expanded": "true",
2005
+ "aria-label": i18n.searchPlaceholder,
2006
+ "aria-controls": `iti-${this.id}__country-listbox`,
2007
+ "aria-autocomplete": "list",
2008
+ "autocomplete": "off"
2009
+ },
2010
+ this.dropdownContent
2011
+ );
2012
+ this.searchResultsA11yText = createEl(
2013
+ "span",
2014
+ { class: "iti__a11y-text" },
2015
+ this.dropdownContent
2016
+ );
2017
+ }
2018
+ this.countryList = createEl(
2019
+ "ul",
2020
+ {
2021
+ class: "iti__country-list",
2022
+ id: `iti-${this.id}__country-listbox`,
2023
+ role: "listbox",
2024
+ "aria-label": i18n.countryListAriaLabel
2025
+ },
2026
+ this.dropdownContent
2027
+ );
2028
+ this._appendListItems();
2029
+ if (countrySearch) {
2030
+ this._updateSearchResultsText();
2031
+ }
2032
+ if (dropdownContainer) {
2033
+ let dropdownClasses = "iti iti--container";
2034
+ if (useFullscreenPopup) {
2035
+ dropdownClasses += " iti--fullscreen-popup";
2036
+ } else {
2037
+ dropdownClasses += " iti--inline-dropdown";
2038
+ }
2039
+ this.dropdown = createEl("div", { class: dropdownClasses });
2040
+ this.dropdown.appendChild(this.dropdownContent);
2041
+ } else {
2042
+ this.countryContainer.appendChild(this.dropdownContent);
2043
+ }
2044
+ }
2045
+ }
2046
+ wrapper.appendChild(this.telInput);
2047
+ this._updateInputPadding();
2048
+ if (hiddenInput) {
2049
+ const telInputName = this.telInput.getAttribute("name") || "";
2050
+ const names = hiddenInput(telInputName);
2051
+ if (names.phone) {
2052
+ const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`);
2053
+ if (existingInput) {
2054
+ this.hiddenInput = existingInput;
2055
+ } else {
2056
+ this.hiddenInput = createEl("input", {
2057
+ type: "hidden",
2058
+ name: names.phone
2059
+ });
2060
+ wrapper.appendChild(this.hiddenInput);
2061
+ }
2062
+ }
2063
+ if (names.country) {
2064
+ const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
2065
+ if (existingInput) {
2066
+ this.hiddenInputCountry = existingInput;
2067
+ } else {
2068
+ this.hiddenInputCountry = createEl("input", {
2069
+ type: "hidden",
2070
+ name: names.country
2071
+ });
2072
+ wrapper.appendChild(this.hiddenInputCountry);
2073
+ }
2074
+ }
2075
+ }
2076
+ }
2077
+ //* For each country: add a country list item <li> to the countryList <ul> container.
2078
+ _appendListItems() {
2079
+ for (let i = 0; i < this.countries.length; i++) {
2080
+ const c = this.countries[i];
2081
+ const extraClass = i === 0 ? "iti__highlight" : "";
2082
+ const listItem = createEl(
2083
+ "li",
2084
+ {
2085
+ id: `iti-${this.id}__item-${c.iso2}`,
2086
+ class: `iti__country ${extraClass}`,
2087
+ tabindex: "-1",
2088
+ role: "option",
2089
+ "data-dial-code": c.dialCode,
2090
+ "data-country-code": c.iso2,
2091
+ "aria-selected": "false"
2092
+ },
2093
+ this.countryList
2094
+ );
2095
+ c.nodeById[this.id] = listItem;
2096
+ let content = "";
2097
+ if (this.options.showFlags) {
2098
+ content += `<div class='iti__flag iti__${c.iso2}'></div>`;
2099
+ }
2100
+ content += `<span class='iti__country-name'>${c.name}</span>`;
2101
+ content += `<span class='iti__dial-code'>+${c.dialCode}</span>`;
2102
+ listItem.insertAdjacentHTML("beforeend", content);
2103
+ }
2104
+ }
2105
+ //* Set the initial state of the input value and the selected country by:
2106
+ //* 1. Extracting a dial code from the given number
2107
+ //* 2. Using explicit initialCountry
2108
+ _setInitialState(overrideAutoCountry = false) {
2109
+ const attributeValue = this.telInput.getAttribute("value");
2110
+ const inputValue = this.telInput.value;
2111
+ const useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+");
2112
+ const val = useAttribute ? attributeValue : inputValue;
2113
+ const dialCode = this._getDialCode(val);
2114
+ const isRegionlessNanpNumber = isRegionlessNanp(val);
2115
+ const { initialCountry, geoIpLookup } = this.options;
2116
+ const isAutoCountry = initialCountry === "auto" && geoIpLookup;
2117
+ if (dialCode && !isRegionlessNanpNumber) {
2118
+ this._updateCountryFromNumber(val);
2119
+ } else if (!isAutoCountry || overrideAutoCountry) {
2120
+ const lowerInitialCountry = initialCountry ? initialCountry.toLowerCase() : "";
2121
+ const isValidInitialCountry = lowerInitialCountry && this._getCountryData(lowerInitialCountry, true);
2122
+ if (isValidInitialCountry) {
2123
+ this._setCountry(lowerInitialCountry);
2124
+ } else {
2125
+ if (dialCode && isRegionlessNanpNumber) {
2126
+ this._setCountry("us");
2127
+ } else {
2128
+ this._setCountry();
2129
+ }
2130
+ }
2131
+ }
2132
+ if (val) {
2133
+ this._updateValFromNumber(val);
2134
+ }
2135
+ }
2136
+ //* Initialise the main event listeners: input keyup, and click selected country.
2137
+ _initListeners() {
2138
+ this._initTelInputListeners();
2139
+ if (this.options.allowDropdown) {
2140
+ this._initDropdownListeners();
2141
+ }
2142
+ if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) {
2143
+ this._initHiddenInputListener();
2144
+ }
2145
+ }
2146
+ //* Update hidden input on form submit.
2147
+ _initHiddenInputListener() {
2148
+ this._handleHiddenInputSubmit = () => {
2149
+ if (this.hiddenInput) {
2150
+ this.hiddenInput.value = this.getNumber();
2151
+ }
2152
+ if (this.hiddenInputCountry) {
2153
+ this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "";
2154
+ }
2155
+ };
2156
+ this.telInput.form?.addEventListener(
2157
+ "submit",
2158
+ this._handleHiddenInputSubmit
2159
+ );
2160
+ }
2161
+ //* initialise the dropdown listeners.
2162
+ _initDropdownListeners() {
2163
+ this._handleLabelClick = (e) => {
2164
+ if (this.dropdownContent.classList.contains("iti__hide")) {
2165
+ this.telInput.focus();
2166
+ } else {
2167
+ e.preventDefault();
2168
+ }
2169
+ };
2170
+ const label = this.telInput.closest("label");
2171
+ if (label) {
2172
+ label.addEventListener("click", this._handleLabelClick);
2173
+ }
2174
+ this._handleClickSelectedCountry = () => {
2175
+ if (this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly) {
2176
+ this._openDropdown();
2177
+ }
2178
+ };
2179
+ this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry);
2180
+ this._handleCountryContainerKeydown = (e) => {
2181
+ const isDropdownHidden = this.dropdownContent.classList.contains("iti__hide");
2182
+ if (isDropdownHidden && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)) {
2183
+ e.preventDefault();
2184
+ e.stopPropagation();
2185
+ this._openDropdown();
2186
+ }
2187
+ if (e.key === "Tab") {
2188
+ this._closeDropdown();
2189
+ }
2190
+ };
2191
+ this.countryContainer.addEventListener(
2192
+ "keydown",
2193
+ this._handleCountryContainerKeydown
2194
+ );
2195
+ }
2196
+ //* Init many requests: utils script / geo ip lookup.
2197
+ _initRequests() {
2198
+ let { loadUtils, initialCountry, geoIpLookup } = this.options;
2199
+ if (loadUtils && !intlTelInput.utils) {
2200
+ this._handlePageLoad = () => {
2201
+ window.removeEventListener("load", this._handlePageLoad);
2202
+ intlTelInput.attachUtils(loadUtils)?.catch(() => {
2203
+ });
2204
+ };
2205
+ if (intlTelInput.documentReady()) {
2206
+ this._handlePageLoad();
2207
+ } else {
2208
+ window.addEventListener("load", this._handlePageLoad);
2209
+ }
2210
+ } else {
2211
+ this.resolveUtilsScriptPromise();
2212
+ }
2213
+ const isAutoCountry = initialCountry === "auto" && geoIpLookup;
2214
+ if (isAutoCountry && !this.selectedCountryData.iso2) {
2215
+ this._loadAutoCountry();
2216
+ } else {
2217
+ this.resolveAutoCountryPromise();
2218
+ }
2219
+ }
2220
+ //* Perform the geo ip lookup.
2221
+ _loadAutoCountry() {
2222
+ if (intlTelInput.autoCountry) {
2223
+ this.handleAutoCountry();
2224
+ } else if (!intlTelInput.startedLoadingAutoCountry) {
2225
+ intlTelInput.startedLoadingAutoCountry = true;
2226
+ if (typeof this.options.geoIpLookup === "function") {
2227
+ this.options.geoIpLookup(
2228
+ (iso2 = "") => {
2229
+ const iso2Lower = iso2.toLowerCase();
2230
+ const isValidIso2 = iso2Lower && this._getCountryData(iso2Lower, true);
2231
+ if (isValidIso2) {
2232
+ intlTelInput.autoCountry = iso2Lower;
2233
+ setTimeout(() => forEachInstance("handleAutoCountry"));
2234
+ } else {
2235
+ this._setInitialState(true);
2236
+ forEachInstance("rejectAutoCountryPromise");
2237
+ }
2238
+ },
2239
+ () => {
2240
+ this._setInitialState(true);
2241
+ forEachInstance("rejectAutoCountryPromise");
2242
+ }
2243
+ );
2244
+ }
2245
+ }
2246
+ }
2247
+ _openDropdownWithPlus() {
2248
+ this._openDropdown();
2249
+ this.searchInput.value = "+";
2250
+ this._filterCountries("", true);
2251
+ }
2252
+ //* Initialize the tel input listeners.
2253
+ _initTelInputListeners() {
2254
+ const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay, allowDropdown, countrySearch } = this.options;
2255
+ let userOverrideFormatting = false;
2256
+ if (/\p{L}/u.test(this.telInput.value)) {
2257
+ userOverrideFormatting = true;
2258
+ }
2259
+ this._handleInputEvent = (e) => {
2260
+ if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
2261
+ const currentCaretPos = this.telInput.selectionStart || 0;
2262
+ const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1);
2263
+ const valueAfterCaret = this.telInput.value.substring(currentCaretPos);
2264
+ this.telInput.value = valueBeforeCaret + valueAfterCaret;
2265
+ this._openDropdownWithPlus();
2266
+ return;
2267
+ }
2268
+ if (this._updateCountryFromNumber(this.telInput.value)) {
2269
+ this._triggerCountryChange();
2270
+ }
2271
+ const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
2272
+ const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
2273
+ if (isFormattingChar || isPaste && !strictMode) {
2274
+ userOverrideFormatting = true;
2275
+ } else if (!/[^+0-9]/.test(this.telInput.value)) {
2276
+ userOverrideFormatting = false;
2277
+ }
2278
+ const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay;
2279
+ if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) {
2280
+ const currentCaretPos = this.telInput.selectionStart || 0;
2281
+ const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2282
+ const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2283
+ const isDeleteForwards = e?.inputType === "deleteContentForward";
2284
+ const formattedValue = this._formatNumberAsYouType();
2285
+ const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2286
+ this.telInput.value = formattedValue;
2287
+ this.telInput.setSelectionRange(newCaretPos, newCaretPos);
2288
+ }
2289
+ };
2290
+ this.telInput.addEventListener("input", this._handleInputEvent);
2291
+ if (strictMode || separateDialCode) {
2292
+ this._handleKeydownEvent = (e) => {
2293
+ if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
2294
+ if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
2295
+ e.preventDefault();
2296
+ this._openDropdownWithPlus();
2297
+ return;
2298
+ }
2299
+ if (strictMode) {
2300
+ const value = this.telInput.value;
2301
+ const alreadyHasPlus = value.charAt(0) === "+";
2302
+ const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
2303
+ const isNumeric = /^[0-9]$/.test(e.key);
2304
+ const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
2305
+ const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
2306
+ const newFullNumber = this._getFullNumber(newValue);
2307
+ const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
2308
+ const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
2309
+ let isChangingDialCode = false;
2310
+ if (alreadyHasPlus) {
2311
+ const currentCountry = this.selectedCountryData.iso2;
2312
+ const newCountry = this._getCountryFromNumber(newFullNumber);
2313
+ isChangingDialCode = newCountry !== currentCountry;
2314
+ }
2315
+ if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
2316
+ e.preventDefault();
2317
+ }
2318
+ }
2319
+ }
2320
+ };
2321
+ this.telInput.addEventListener("keydown", this._handleKeydownEvent);
2322
+ }
2323
+ }
2324
+ //* Adhere to the input's maxlength attr.
2325
+ _cap(number) {
2326
+ const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2327
+ return max && number.length > max ? number.substr(0, max) : number;
2328
+ }
2329
+ //* Trigger a custom event on the input.
2330
+ _trigger(name, detailProps = {}) {
2331
+ const e = new CustomEvent(name, {
2332
+ bubbles: true,
2333
+ cancelable: true,
2334
+ detail: detailProps
2335
+ });
2336
+ this.telInput.dispatchEvent(e);
2337
+ }
2338
+ //* Open the dropdown.
2339
+ _openDropdown() {
2340
+ const { fixDropdownWidth, countrySearch } = this.options;
2341
+ if (fixDropdownWidth) {
2342
+ this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`;
2343
+ }
2344
+ this.dropdownContent.classList.remove("iti__hide");
2345
+ this.selectedCountry.setAttribute("aria-expanded", "true");
2346
+ this._setDropdownPosition();
2347
+ if (countrySearch) {
2348
+ const firstCountryItem = this.countryList.firstElementChild;
2349
+ if (firstCountryItem) {
2350
+ this._highlightListItem(firstCountryItem, false);
2351
+ this.countryList.scrollTop = 0;
2352
+ }
2353
+ this.searchInput.focus();
2354
+ }
2355
+ this._bindDropdownListeners();
2356
+ this.dropdownArrow.classList.add("iti__arrow--up");
2357
+ this._trigger("open:countrydropdown");
2358
+ }
2359
+ //* Set the dropdown position
2360
+ _setDropdownPosition() {
2361
+ if (this.options.dropdownContainer) {
2362
+ this.options.dropdownContainer.appendChild(this.dropdown);
2363
+ }
2364
+ if (!this.options.useFullscreenPopup) {
2365
+ const inputPosRelativeToVP = this.telInput.getBoundingClientRect();
2366
+ const inputHeight = this.telInput.offsetHeight;
2367
+ if (this.options.dropdownContainer) {
2368
+ this.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
2369
+ this.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
2370
+ this._handleWindowScroll = () => this._closeDropdown();
2371
+ window.addEventListener("scroll", this._handleWindowScroll);
2372
+ }
2373
+ }
2374
+ }
2375
+ //* We only bind dropdown listeners when the dropdown is open.
2376
+ _bindDropdownListeners() {
2377
+ this._handleMouseoverCountryList = (e) => {
2378
+ const listItem = e.target?.closest(".iti__country");
2379
+ if (listItem) {
2380
+ this._highlightListItem(listItem, false);
2381
+ }
2382
+ };
2383
+ this.countryList.addEventListener(
2384
+ "mouseover",
2385
+ this._handleMouseoverCountryList
2386
+ );
2387
+ this._handleClickCountryList = (e) => {
2388
+ const listItem = e.target?.closest(".iti__country");
2389
+ if (listItem) {
2390
+ this._selectListItem(listItem);
2391
+ }
2392
+ };
2393
+ this.countryList.addEventListener("click", this._handleClickCountryList);
2394
+ let isOpening = true;
2395
+ this._handleClickOffToClose = () => {
2396
+ if (!isOpening) {
2397
+ this._closeDropdown();
2398
+ }
2399
+ isOpening = false;
2400
+ };
2401
+ document.documentElement.addEventListener(
2402
+ "click",
2403
+ this._handleClickOffToClose
2404
+ );
2405
+ let query = "";
2406
+ let queryTimer = null;
2407
+ this._handleKeydownOnDropdown = (e) => {
2408
+ if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) {
2409
+ e.preventDefault();
2410
+ e.stopPropagation();
2411
+ if (e.key === "ArrowUp" || e.key === "ArrowDown") {
2412
+ this._handleUpDownKey(e.key);
2413
+ } else if (e.key === "Enter") {
2414
+ this._handleEnterKey();
2415
+ } else if (e.key === "Escape") {
2416
+ this._closeDropdown();
2417
+ }
2418
+ }
2419
+ if (!this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(e.key)) {
2420
+ e.stopPropagation();
2421
+ if (queryTimer) {
2422
+ clearTimeout(queryTimer);
2423
+ }
2424
+ query += e.key.toLowerCase();
2425
+ this._searchForCountry(query);
2426
+ queryTimer = setTimeout(() => {
2427
+ query = "";
2428
+ }, 1e3);
2429
+ }
2430
+ };
2431
+ document.addEventListener("keydown", this._handleKeydownOnDropdown);
2432
+ if (this.options.countrySearch) {
2433
+ const doFilter = () => {
2434
+ const inputQuery = this.searchInput.value.trim();
2435
+ if (inputQuery) {
2436
+ this._filterCountries(inputQuery);
2437
+ } else {
2438
+ this._filterCountries("", true);
2439
+ }
2440
+ };
2441
+ let keyupTimer = null;
2442
+ this._handleSearchChange = () => {
2443
+ if (keyupTimer) {
2444
+ clearTimeout(keyupTimer);
2445
+ }
2446
+ keyupTimer = setTimeout(() => {
2447
+ doFilter();
2448
+ keyupTimer = null;
2449
+ }, 100);
2450
+ };
2451
+ this.searchInput.addEventListener("input", this._handleSearchChange);
2452
+ this.searchInput.addEventListener("click", (e) => e.stopPropagation());
2453
+ }
2454
+ }
2455
+ //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2456
+ _searchForCountry(query) {
2457
+ for (let i = 0; i < this.countries.length; i++) {
2458
+ const c = this.countries[i];
2459
+ const startsWith = c.name.substr(0, query.length).toLowerCase() === query;
2460
+ if (startsWith) {
2461
+ const listItem = c.nodeById[this.id];
2462
+ this._highlightListItem(listItem, false);
2463
+ this._scrollTo(listItem);
2464
+ break;
2465
+ }
2466
+ }
2467
+ }
2468
+ //* Country search enabled: Filter the countries according to the search query.
2469
+ _filterCountries(query, isReset = false) {
2470
+ let noCountriesAddedYet = true;
2471
+ this.countryList.innerHTML = "";
2472
+ const normalisedQuery = normaliseString(query);
2473
+ for (let i = 0; i < this.countries.length; i++) {
2474
+ const c = this.countries[i];
2475
+ const normalisedCountryName = normaliseString(c.name);
2476
+ const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2477
+ const fullDialCode = `+${c.dialCode}`;
2478
+ if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
2479
+ const listItem = c.nodeById[this.id];
2480
+ if (listItem) {
2481
+ this.countryList.appendChild(listItem);
2482
+ }
2483
+ if (noCountriesAddedYet) {
2484
+ this._highlightListItem(listItem, false);
2485
+ noCountriesAddedYet = false;
2486
+ }
2487
+ }
2488
+ }
2489
+ if (noCountriesAddedYet) {
2490
+ this._highlightListItem(null, false);
2491
+ }
2492
+ this.countryList.scrollTop = 0;
2493
+ this._updateSearchResultsText();
2494
+ }
2495
+ //* Update search results text (for a11y).
2496
+ _updateSearchResultsText() {
2497
+ const { i18n } = this.options;
2498
+ const count = this.countryList.childElementCount;
2499
+ let searchText;
2500
+ if ("searchResultsText" in i18n) {
2501
+ searchText = i18n.searchResultsText(count);
2502
+ } else {
2503
+ if (count === 0) {
2504
+ searchText = i18n.zeroSearchResults;
2505
+ } else if (count === 1) {
2506
+ searchText = i18n.oneSearchResult;
2507
+ } else {
2508
+ searchText = i18n.multipleSearchResults.replace("${count}", count.toString());
2509
+ }
2510
+ }
2511
+ this.searchResultsA11yText.textContent = searchText;
2512
+ }
2513
+ //* Highlight the next/prev item in the list (and ensure it is visible).
2514
+ _handleUpDownKey(key) {
2515
+ let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
2516
+ if (!next && this.countryList.childElementCount > 1) {
2517
+ next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild;
2518
+ }
2519
+ if (next) {
2520
+ this._scrollTo(next);
2521
+ this._highlightListItem(next, false);
2522
+ }
2523
+ }
2524
+ //* Select the currently highlighted item.
2525
+ _handleEnterKey() {
2526
+ if (this.highlightedItem) {
2527
+ this._selectListItem(this.highlightedItem);
2528
+ }
2529
+ }
2530
+ //* Update the input's value to the given val (format first if possible)
2531
+ //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
2532
+ _updateValFromNumber(fullNumber) {
2533
+ let number = fullNumber;
2534
+ if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) {
2535
+ const useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.separateDialCode;
2536
+ const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
2537
+ const format = useNational ? NATIONAL : INTERNATIONAL;
2538
+ number = intlTelInput.utils.formatNumber(
2539
+ number,
2540
+ this.selectedCountryData.iso2,
2541
+ format
2542
+ );
2543
+ }
2544
+ number = this._beforeSetNumber(number);
2545
+ this.telInput.value = number;
2546
+ }
2547
+ //* Check if need to select a new country based on the given number
2548
+ //* Note: called from _setInitialState, keyup handler, setNumber.
2549
+ _updateCountryFromNumber(fullNumber) {
2550
+ const iso2 = this._getCountryFromNumber(fullNumber);
2551
+ if (iso2 !== null) {
2552
+ return this._setCountry(iso2);
2553
+ }
2554
+ return false;
2555
+ }
2556
+ _ensureHasDialCode(number) {
2557
+ const { dialCode, nationalPrefix } = this.selectedCountryData;
2558
+ const alreadyHasPlus = number.charAt(0) === "+";
2559
+ if (alreadyHasPlus || !dialCode) {
2560
+ return number;
2561
+ }
2562
+ const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode;
2563
+ const cleanNumber = hasPrefix ? number.substring(1) : number;
2564
+ return `+${dialCode}${cleanNumber}`;
2565
+ }
2566
+ _getCountryFromNumber(fullNumber) {
2567
+ const plusIndex = fullNumber.indexOf("+");
2568
+ let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
2569
+ const selectedIso2 = this.selectedCountryData.iso2;
2570
+ const selectedDialCode = this.selectedCountryData.dialCode;
2571
+ number = this._ensureHasDialCode(number);
2572
+ const dialCodeMatch = this._getDialCode(number, true);
2573
+ const numeric = getNumeric(number);
2574
+ if (dialCodeMatch) {
2575
+ const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
2576
+ const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
2577
+ if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
2578
+ return this.defaultCountry;
2579
+ }
2580
+ const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && (numeric.length === dialCodeMatchNumeric.length || !this.selectedCountryData.areaCodes);
2581
+ const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
2582
+ if (!isRegionlessNanpNumber && !alreadySelected) {
2583
+ for (let j = 0; j < iso2Codes.length; j++) {
2584
+ if (iso2Codes[j]) {
2585
+ return iso2Codes[j];
2586
+ }
2587
+ }
2588
+ }
2589
+ } else if (number.charAt(0) === "+" && numeric.length) {
2590
+ return "";
2591
+ } else if ((!number || number === "+") && !this.selectedCountryData.iso2) {
2592
+ return this.defaultCountry;
2593
+ }
2594
+ return null;
2595
+ }
2596
+ //* Remove highlighting from other list items and highlight the given item.
2597
+ _highlightListItem(listItem, shouldFocus) {
2598
+ const prevItem = this.highlightedItem;
2599
+ if (prevItem) {
2600
+ prevItem.classList.remove("iti__highlight");
2601
+ prevItem.setAttribute("aria-selected", "false");
2602
+ }
2603
+ this.highlightedItem = listItem;
2604
+ if (this.highlightedItem) {
2605
+ this.highlightedItem.classList.add("iti__highlight");
2606
+ this.highlightedItem.setAttribute("aria-selected", "true");
2607
+ const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2608
+ this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant);
2609
+ if (this.options.countrySearch) {
2610
+ this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
2611
+ }
2612
+ }
2613
+ if (shouldFocus) {
2614
+ this.highlightedItem.focus();
2615
+ }
2616
+ }
2617
+ //* Find the country data for the given iso2 code
2618
+ //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2619
+ _getCountryData(iso2, allowFail) {
2620
+ for (let i = 0; i < this.countries.length; i++) {
2621
+ if (this.countries[i].iso2 === iso2) {
2622
+ return this.countries[i];
2623
+ }
2624
+ }
2625
+ if (allowFail) {
2626
+ return null;
2627
+ }
2628
+ throw new Error(`No country data for '${iso2}'`);
2629
+ }
2630
+ //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
2631
+ //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2632
+ _setCountry(iso2) {
2633
+ const { separateDialCode, showFlags, i18n } = this.options;
2634
+ const prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2635
+ this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) || {} : {};
2636
+ if (this.selectedCountryData.iso2) {
2637
+ this.defaultCountry = this.selectedCountryData.iso2;
2638
+ }
2639
+ if (this.selectedCountryInner) {
2640
+ let flagClass = "";
2641
+ let a11yText = "";
2642
+ if (iso2 && showFlags) {
2643
+ flagClass = `iti__flag iti__${iso2}`;
2644
+ a11yText = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`;
2645
+ } else {
2646
+ flagClass = "iti__flag iti__globe";
2647
+ a11yText = i18n.noCountrySelected;
2648
+ }
2649
+ this.selectedCountryInner.className = flagClass;
2650
+ this.selectedCountryA11yText.textContent = a11yText;
2651
+ }
2652
+ this._setSelectedCountryTitleAttribute(iso2, separateDialCode);
2653
+ if (separateDialCode) {
2654
+ const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
2655
+ this.selectedDialCode.innerHTML = dialCode;
2656
+ this._updateInputPadding();
2657
+ }
2658
+ this._updatePlaceholder();
2659
+ this._updateMaxLength();
2660
+ return prevCountry.iso2 !== iso2;
2661
+ }
2662
+ //* Update the input padding to make space for the selected country/dial code.
2663
+ _updateInputPadding() {
2664
+ if (this.selectedCountry) {
2665
+ const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
2666
+ const inputPadding = selectedCountryWidth + 6;
2667
+ if (this.showSelectedCountryOnLeft) {
2668
+ this.telInput.style.paddingLeft = `${inputPadding}px`;
2669
+ } else {
2670
+ this.telInput.style.paddingRight = `${inputPadding}px`;
2671
+ }
2672
+ }
2673
+ }
2674
+ //* Update the maximum valid number length for the currently selected country.
2675
+ _updateMaxLength() {
2676
+ const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
2677
+ const { iso2 } = this.selectedCountryData;
2678
+ if (strictMode && intlTelInput.utils) {
2679
+ if (iso2) {
2680
+ const numberType = intlTelInput.utils.numberType[placeholderNumberType];
2681
+ let exampleNumber = intlTelInput.utils.getExampleNumber(
2682
+ iso2,
2683
+ false,
2684
+ numberType,
2685
+ true
2686
+ );
2687
+ let validNumber = exampleNumber;
2688
+ while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
2689
+ validNumber = exampleNumber;
2690
+ exampleNumber += "0";
2691
+ }
2692
+ const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
2693
+ this.maxCoreNumberLength = coreNumber.length;
2694
+ if (iso2 === "by") {
2695
+ this.maxCoreNumberLength = coreNumber.length + 1;
2696
+ }
2697
+ } else {
2698
+ this.maxCoreNumberLength = null;
2699
+ }
2700
+ }
2701
+ }
2702
+ _setSelectedCountryTitleAttribute(iso2 = null, separateDialCode) {
2703
+ if (!this.selectedCountry) {
2704
+ return;
2705
+ }
2706
+ let title;
2707
+ if (iso2 && !separateDialCode) {
2708
+ title = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}`;
2709
+ } else if (iso2) {
2710
+ title = this.selectedCountryData.name;
2711
+ } else {
2712
+ title = "Unknown";
2713
+ }
2714
+ this.selectedCountry.setAttribute("title", title);
2715
+ }
2716
+ //* When the input is in a hidden container during initialisation, we must inject some markup
2717
+ //* into the end of the DOM to calculate the correct offsetWidth.
2718
+ //* NOTE: this is only used when separateDialCode is enabled, so countryContainer and selectedCountry
2719
+ //* will definitely exist.
2720
+ _getHiddenSelectedCountryWidth() {
2721
+ if (this.telInput.parentNode) {
2722
+ const containerClone = this.telInput.parentNode.cloneNode(false);
2723
+ containerClone.style.visibility = "hidden";
2724
+ document.body.appendChild(containerClone);
2725
+ const countryContainerClone = this.countryContainer.cloneNode();
2726
+ containerClone.appendChild(countryContainerClone);
2727
+ const selectedCountryClone = this.selectedCountry.cloneNode(true);
2728
+ countryContainerClone.appendChild(selectedCountryClone);
2729
+ const width = selectedCountryClone.offsetWidth;
2730
+ document.body.removeChild(containerClone);
2731
+ return width;
2732
+ }
2733
+ return 0;
2734
+ }
2735
+ //* Update the input placeholder to an example number from the currently selected country.
2736
+ _updatePlaceholder() {
2737
+ const {
2738
+ autoPlaceholder,
2739
+ placeholderNumberType,
2740
+ nationalMode,
2741
+ customPlaceholder
2742
+ } = this.options;
2743
+ const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite";
2744
+ if (intlTelInput.utils && shouldSetPlaceholder) {
2745
+ const numberType = intlTelInput.utils.numberType[placeholderNumberType];
2746
+ let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(
2747
+ this.selectedCountryData.iso2,
2748
+ nationalMode,
2749
+ numberType
2750
+ ) : "";
2751
+ placeholder = this._beforeSetNumber(placeholder);
2752
+ if (typeof customPlaceholder === "function") {
2753
+ placeholder = customPlaceholder(placeholder, this.selectedCountryData);
2754
+ }
2755
+ this.telInput.setAttribute("placeholder", placeholder);
2756
+ }
2757
+ }
2758
+ //* Called when the user selects a list item from the dropdown.
2759
+ _selectListItem(listItem) {
2760
+ const countryChanged = this._setCountry(
2761
+ listItem.getAttribute("data-country-code")
2762
+ );
2763
+ this._closeDropdown();
2764
+ this._updateDialCode(listItem.getAttribute("data-dial-code"));
2765
+ this.telInput.focus();
2766
+ if (countryChanged) {
2767
+ this._triggerCountryChange();
2768
+ }
2769
+ }
2770
+ //* Close the dropdown and unbind any listeners.
2771
+ _closeDropdown() {
2772
+ this.dropdownContent.classList.add("iti__hide");
2773
+ this.selectedCountry.setAttribute("aria-expanded", "false");
2774
+ this.selectedCountry.removeAttribute("aria-activedescendant");
2775
+ if (this.highlightedItem) {
2776
+ this.highlightedItem.setAttribute("aria-selected", "false");
2777
+ }
2778
+ if (this.options.countrySearch) {
2779
+ this.searchInput.removeAttribute("aria-activedescendant");
2780
+ }
2781
+ this.dropdownArrow.classList.remove("iti__arrow--up");
2782
+ document.removeEventListener("keydown", this._handleKeydownOnDropdown);
2783
+ if (this.options.countrySearch) {
2784
+ this.searchInput.removeEventListener("input", this._handleSearchChange);
2785
+ }
2786
+ document.documentElement.removeEventListener(
2787
+ "click",
2788
+ this._handleClickOffToClose
2789
+ );
2790
+ this.countryList.removeEventListener(
2791
+ "mouseover",
2792
+ this._handleMouseoverCountryList
2793
+ );
2794
+ this.countryList.removeEventListener("click", this._handleClickCountryList);
2795
+ if (this.options.dropdownContainer) {
2796
+ if (!this.options.useFullscreenPopup) {
2797
+ window.removeEventListener("scroll", this._handleWindowScroll);
2798
+ }
2799
+ if (this.dropdown.parentNode) {
2800
+ this.dropdown.parentNode.removeChild(this.dropdown);
2801
+ }
2802
+ }
2803
+ if (this._handlePageLoad) {
2804
+ window.removeEventListener("load", this._handlePageLoad);
2805
+ }
2806
+ this._trigger("close:countrydropdown");
2807
+ }
2808
+ //* Check if an element is visible within it's container, else scroll until it is.
2809
+ _scrollTo(element) {
2810
+ const container = this.countryList;
2811
+ const scrollTop = document.documentElement.scrollTop;
2812
+ const containerHeight = container.offsetHeight;
2813
+ const containerTop = container.getBoundingClientRect().top + scrollTop;
2814
+ const containerBottom = containerTop + containerHeight;
2815
+ const elementHeight = element.offsetHeight;
2816
+ const elementTop = element.getBoundingClientRect().top + scrollTop;
2817
+ const elementBottom = elementTop + elementHeight;
2818
+ const newScrollTop = elementTop - containerTop + container.scrollTop;
2819
+ if (elementTop < containerTop) {
2820
+ container.scrollTop = newScrollTop;
2821
+ } else if (elementBottom > containerBottom) {
2822
+ const heightDifference = containerHeight - elementHeight;
2823
+ container.scrollTop = newScrollTop - heightDifference;
2824
+ }
2825
+ }
2826
+ //* Replace any existing dial code with the new one
2827
+ //* Note: called from _selectListItem and setCountry
2828
+ _updateDialCode(newDialCodeBare) {
2829
+ const inputVal = this.telInput.value;
2830
+ const newDialCode = `+${newDialCodeBare}`;
2831
+ let newNumber;
2832
+ if (inputVal.charAt(0) === "+") {
2833
+ const prevDialCode = this._getDialCode(inputVal);
2834
+ if (prevDialCode) {
2835
+ newNumber = inputVal.replace(prevDialCode, newDialCode);
2836
+ } else {
2837
+ newNumber = newDialCode;
2838
+ }
2839
+ this.telInput.value = newNumber;
2840
+ }
2841
+ }
2842
+ //* Try and extract a valid international dial code from a full telephone number.
2843
+ //* Note: returns the raw string inc plus character and any whitespace/dots etc.
2844
+ _getDialCode(number, includeAreaCode) {
2845
+ let dialCode = "";
2846
+ if (number.charAt(0) === "+") {
2847
+ let numericChars = "";
2848
+ for (let i = 0; i < number.length; i++) {
2849
+ const c = number.charAt(i);
2850
+ if (!isNaN(parseInt(c, 10))) {
2851
+ numericChars += c;
2852
+ if (includeAreaCode) {
2853
+ if (this.dialCodeToIso2Map[numericChars]) {
2854
+ dialCode = number.substr(0, i + 1);
2855
+ }
2856
+ } else {
2857
+ if (this.dialCodes[numericChars]) {
2858
+ dialCode = number.substr(0, i + 1);
2859
+ break;
2860
+ }
2861
+ }
2862
+ if (numericChars.length === this.dialCodeMaxLen) {
2863
+ break;
2864
+ }
2865
+ }
2866
+ }
2867
+ }
2868
+ return dialCode;
2869
+ }
2870
+ //* Get the input val, adding the dial code if separateDialCode is enabled.
2871
+ _getFullNumber(overrideVal) {
2872
+ const val = overrideVal || this.telInput.value.trim();
2873
+ const { dialCode } = this.selectedCountryData;
2874
+ let prefix;
2875
+ const numericVal = getNumeric(val);
2876
+ if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) {
2877
+ prefix = `+${dialCode}`;
2878
+ } else {
2879
+ prefix = "";
2880
+ }
2881
+ return prefix + val;
2882
+ }
2883
+ //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
2884
+ _beforeSetNumber(fullNumber) {
2885
+ let number = fullNumber;
2886
+ if (this.options.separateDialCode) {
2887
+ let dialCode = this._getDialCode(number);
2888
+ if (dialCode) {
2889
+ dialCode = `+${this.selectedCountryData.dialCode}`;
2890
+ const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2891
+ number = number.substr(start);
2892
+ }
2893
+ }
2894
+ return this._cap(number);
2895
+ }
2896
+ //* Trigger the 'countrychange' event.
2897
+ _triggerCountryChange() {
2898
+ this._trigger("countrychange");
2899
+ }
2900
+ //* Format the number as the user types.
2901
+ _formatNumberAsYouType() {
2902
+ const val = this._getFullNumber();
2903
+ const result = intlTelInput.utils ? intlTelInput.utils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val;
2904
+ const { dialCode } = this.selectedCountryData;
2905
+ if (this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
2906
+ const afterDialCode = result.split(`+${dialCode}`)[1] || "";
2907
+ return afterDialCode.trim();
2908
+ }
2909
+ return result;
2910
+ }
2911
+ //**************************
2912
+ //* SECRET PUBLIC METHODS
2913
+ //**************************
2914
+ //* This is called when the geoip call returns.
2915
+ handleAutoCountry() {
2916
+ if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) {
2917
+ this.defaultCountry = intlTelInput.autoCountry;
2918
+ const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe");
2919
+ if (!hasSelectedCountryOrGlobe) {
2920
+ this.setCountry(this.defaultCountry);
2921
+ }
2922
+ this.resolveAutoCountryPromise();
2923
+ }
2924
+ }
2925
+ //* This is called when the utils request completes.
2926
+ handleUtils() {
2927
+ if (intlTelInput.utils) {
2928
+ if (this.telInput.value) {
2929
+ this._updateValFromNumber(this.telInput.value);
2930
+ }
2931
+ if (this.selectedCountryData.iso2) {
2932
+ this._updatePlaceholder();
2933
+ this._updateMaxLength();
2934
+ }
2935
+ }
2936
+ this.resolveUtilsScriptPromise();
2937
+ }
2938
+ //********************
2939
+ //* PUBLIC METHODS
2940
+ //********************
2941
+ //* Remove plugin.
2942
+ destroy() {
2943
+ this.telInput.iti = void 0;
2944
+ const { allowDropdown, separateDialCode } = this.options;
2945
+ if (allowDropdown) {
2946
+ this._closeDropdown();
2947
+ this.selectedCountry.removeEventListener(
2948
+ "click",
2949
+ this._handleClickSelectedCountry
2950
+ );
2951
+ this.countryContainer.removeEventListener(
2952
+ "keydown",
2953
+ this._handleCountryContainerKeydown
2954
+ );
2955
+ const label = this.telInput.closest("label");
2956
+ if (label) {
2957
+ label.removeEventListener("click", this._handleLabelClick);
2958
+ }
2959
+ }
2960
+ const { form } = this.telInput;
2961
+ if (this._handleHiddenInputSubmit && form) {
2962
+ form.removeEventListener("submit", this._handleHiddenInputSubmit);
2963
+ }
2964
+ this.telInput.removeEventListener("input", this._handleInputEvent);
2965
+ if (this._handleKeydownEvent) {
2966
+ this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
2967
+ }
2968
+ this.telInput.removeAttribute("data-intl-tel-input-id");
2969
+ if (separateDialCode) {
2970
+ if (this.isRTL) {
2971
+ this.telInput.style.paddingRight = this.originalPaddingRight;
2972
+ } else {
2973
+ this.telInput.style.paddingLeft = this.originalPaddingLeft;
2974
+ }
2975
+ }
2976
+ const wrapper = this.telInput.parentNode;
2977
+ wrapper?.parentNode?.insertBefore(this.telInput, wrapper);
2978
+ wrapper?.parentNode?.removeChild(wrapper);
2979
+ delete intlTelInput.instances[this.id];
2980
+ }
2981
+ //* Get the extension from the current number.
2982
+ getExtension() {
2983
+ if (intlTelInput.utils) {
2984
+ return intlTelInput.utils.getExtension(
2985
+ this._getFullNumber(),
2986
+ this.selectedCountryData.iso2
2987
+ );
2988
+ }
2989
+ return "";
2990
+ }
2991
+ //* Format the number to the given format.
2992
+ getNumber(format) {
2993
+ if (intlTelInput.utils) {
2994
+ const { iso2 } = this.selectedCountryData;
2995
+ return intlTelInput.utils.formatNumber(
2996
+ this._getFullNumber(),
2997
+ iso2,
2998
+ format
2999
+ );
3000
+ }
3001
+ return "";
3002
+ }
3003
+ //* Get the type of the entered number e.g. landline/mobile.
3004
+ getNumberType() {
3005
+ if (intlTelInput.utils) {
3006
+ return intlTelInput.utils.getNumberType(
3007
+ this._getFullNumber(),
3008
+ this.selectedCountryData.iso2
3009
+ );
3010
+ }
3011
+ return -99;
3012
+ }
3013
+ //* Get the country data for the currently selected country.
3014
+ getSelectedCountryData() {
3015
+ return this.selectedCountryData;
3016
+ }
3017
+ //* Get the validation error.
3018
+ getValidationError() {
3019
+ if (intlTelInput.utils) {
3020
+ const { iso2 } = this.selectedCountryData;
3021
+ return intlTelInput.utils.getValidationError(this._getFullNumber(), iso2);
3022
+ }
3023
+ return -99;
3024
+ }
3025
+ //* Validate the input val
3026
+ isValidNumber() {
3027
+ if (!this.selectedCountryData.iso2) {
3028
+ return false;
3029
+ }
3030
+ const val = this._getFullNumber();
3031
+ const alphaCharPosition = val.search(/\p{L}/u);
3032
+ if (alphaCharPosition > -1) {
3033
+ const beforeAlphaChar = val.substring(0, alphaCharPosition);
3034
+ const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
3035
+ const isValid = this._utilsIsPossibleNumber(val);
3036
+ return beforeAlphaIsValid && isValid;
3037
+ }
3038
+ return this._utilsIsPossibleNumber(val);
3039
+ }
3040
+ _utilsIsPossibleNumber(val) {
3041
+ return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3042
+ }
3043
+ //* Validate the input val (precise)
3044
+ isValidNumberPrecise() {
3045
+ if (!this.selectedCountryData.iso2) {
3046
+ return false;
3047
+ }
3048
+ const val = this._getFullNumber();
3049
+ const alphaCharPosition = val.search(/\p{L}/u);
3050
+ if (alphaCharPosition > -1) {
3051
+ const beforeAlphaChar = val.substring(0, alphaCharPosition);
3052
+ const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
3053
+ const isValid = this._utilsIsValidNumber(val);
3054
+ return beforeAlphaIsValid && isValid;
3055
+ }
3056
+ return this._utilsIsValidNumber(val);
3057
+ }
3058
+ _utilsIsValidNumber(val) {
3059
+ return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3060
+ }
3061
+ //* Update the selected country, and update the input val accordingly.
3062
+ setCountry(iso2) {
3063
+ const iso2Lower = iso2?.toLowerCase();
3064
+ const currentCountry = this.selectedCountryData.iso2;
3065
+ const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry;
3066
+ if (isCountryChange) {
3067
+ this._setCountry(iso2Lower);
3068
+ this._updateDialCode(this.selectedCountryData.dialCode);
3069
+ this._triggerCountryChange();
3070
+ }
3071
+ }
3072
+ //* Set the input value and update the country.
3073
+ setNumber(number) {
3074
+ const countryChanged = this._updateCountryFromNumber(number);
3075
+ this._updateValFromNumber(number);
3076
+ if (countryChanged) {
3077
+ this._triggerCountryChange();
3078
+ }
3079
+ this._trigger("input", { isSetNumber: true });
3080
+ }
3081
+ //* Set the placeholder number typ
3082
+ setPlaceholderNumberType(type) {
3083
+ this.options.placeholderNumberType = type;
3084
+ this._updatePlaceholder();
3085
+ }
3086
+ setDisabled(disabled) {
3087
+ this.telInput.disabled = disabled;
3088
+ if (disabled) {
3089
+ this.selectedCountry.setAttribute("disabled", "true");
3090
+ } else {
3091
+ this.selectedCountry.removeAttribute("disabled");
3092
+ }
3093
+ }
3094
+ };
3095
+ var attachUtils = (source) => {
3096
+ if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
3097
+ let loadCall;
3098
+ if (typeof source === "function") {
3099
+ try {
3100
+ loadCall = Promise.resolve(source());
3101
+ } catch (error) {
3102
+ return Promise.reject(error);
3103
+ }
3104
+ } else {
3105
+ return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`));
3106
+ }
3107
+ intlTelInput.startedLoadingUtilsScript = true;
3108
+ return loadCall.then((module) => {
3109
+ const utils = module?.default;
3110
+ if (!utils || typeof utils !== "object") {
3111
+ throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
3112
+ }
3113
+ intlTelInput.utils = utils;
3114
+ forEachInstance("handleUtils");
3115
+ return true;
3116
+ }).catch((error) => {
3117
+ forEachInstance("rejectUtilsScriptPromise", error);
3118
+ throw error;
3119
+ });
3120
+ }
3121
+ return null;
3122
+ };
3123
+ var intlTelInput = Object.assign(
3124
+ (input, options) => {
3125
+ const iti = new Iti(input, options);
3126
+ iti._init();
3127
+ input.setAttribute("data-intl-tel-input-id", iti.id.toString());
3128
+ intlTelInput.instances[iti.id] = iti;
3129
+ input.iti = iti;
3130
+ return iti;
3131
+ },
3132
+ {
3133
+ defaults,
3134
+ //* Using a static var like this allows us to mock it in the tests.
3135
+ documentReady: () => document.readyState === "complete",
3136
+ //* Get the country data object.
3137
+ getCountryData: () => data_default,
3138
+ //* A getter for the plugin instance.
3139
+ getInstance: (input) => {
3140
+ const id2 = input.getAttribute("data-intl-tel-input-id");
3141
+ return id2 ? intlTelInput.instances[id2] : null;
3142
+ },
3143
+ //* A map from instance ID to instance object.
3144
+ instances: {},
3145
+ attachUtils,
3146
+ startedLoadingUtilsScript: false,
3147
+ startedLoadingAutoCountry: false,
3148
+ version: "25.4.3"
3149
+ }
3150
+ );
3151
+ var intl_tel_input_default = intlTelInput;
3152
+
3153
+ // angular/src/intl-tel-input/angular.ts
3154
+ import { Component, Input, ViewChild, Output, EventEmitter, forwardRef } from "@angular/core";
3155
+ import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from "@angular/forms";
3156
+ var PHONE_ERROR_MESSAGES = [
3157
+ "invalid",
3158
+ "invalid-country-code",
3159
+ "too-short",
3160
+ "too-long",
3161
+ "invalid-format"
3162
+ ];
3163
+ var IntlTelInputComponent = class {
3164
+ constructor() {
3165
+ this.initialValue = "";
3166
+ this.usePreciseValidation = false;
3167
+ this.inputProps = {};
3168
+ this.disabled = void 0;
3169
+ this.initOptions = {};
3170
+ this.numberChange = new EventEmitter();
3171
+ this.countryChange = new EventEmitter();
3172
+ this.validityChange = new EventEmitter();
3173
+ this.errorCodeChange = new EventEmitter();
3174
+ this.iti = null;
3175
+ this.countryChangeHandler = () => this.handleInput();
3176
+ // eslint-disable-next-line class-methods-use-this
3177
+ this.onChange = () => {
3178
+ };
3179
+ // eslint-disable-next-line class-methods-use-this
3180
+ this.onTouched = () => {
3181
+ };
3182
+ // eslint-disable-next-line class-methods-use-this
3183
+ this.onValidatorChange = () => {
3184
+ };
3185
+ }
3186
+ ngOnInit() {
3187
+ if (this.inputRef.nativeElement) {
3188
+ this.iti = intl_tel_input_default(this.inputRef.nativeElement, this.initOptions);
3189
+ }
3190
+ this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
3191
+ this.applyInputProps();
3192
+ for (const key in this.inputProps) {
3193
+ if (this.inputProps.hasOwnProperty(key)) {
3194
+ this.inputRef.nativeElement.setAttribute(key, this.inputProps[key]);
3195
+ }
3196
+ }
3197
+ }
3198
+ ngAfterViewInit() {
3199
+ if (this.initialValue) {
3200
+ this.iti?.setNumber(this.initialValue);
3201
+ }
3202
+ }
3203
+ handleInput() {
3204
+ if (!this.iti) return;
3205
+ const num = this.iti.getNumber() || "";
3206
+ const countryIso = this.iti.getSelectedCountryData().iso2 || "";
3207
+ this.numberChange.emit(num);
3208
+ this.countryChange.emit(countryIso);
3209
+ const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
3210
+ if (isValid) {
3211
+ this.validityChange.emit(true);
3212
+ this.errorCodeChange.emit(null);
3213
+ } else {
3214
+ this.validityChange.emit(false);
3215
+ this.errorCodeChange.emit(this.iti.getValidationError());
3216
+ }
3217
+ this.onChange(num);
3218
+ this.onValidatorChange();
3219
+ }
3220
+ handleBlur() {
3221
+ this.onTouched();
3222
+ }
3223
+ getInstance() {
3224
+ return this.iti;
3225
+ }
3226
+ getInput() {
3227
+ return this.inputRef.nativeElement;
3228
+ }
3229
+ ngOnDestroy() {
3230
+ this.iti?.destroy();
3231
+ this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
3232
+ }
3233
+ applyInputProps() {
3234
+ const props = this.inputProps;
3235
+ Object.entries(props).forEach(([key, value]) => {
3236
+ this.inputRef.nativeElement.setAttribute(key, value);
3237
+ });
3238
+ }
3239
+ // ============ ControlValueAccessor Implementation ============
3240
+ writeValue(value) {
3241
+ if (this.iti && value) {
3242
+ this.iti.setNumber(value);
3243
+ }
3244
+ }
3245
+ registerOnChange(fn) {
3246
+ this.onChange = fn;
3247
+ }
3248
+ registerOnTouched(fn) {
3249
+ this.onTouched = fn;
3250
+ }
3251
+ setDisabledState(isDisabled) {
3252
+ this.disabled = isDisabled;
3253
+ }
3254
+ // ============ Validator Implementation ============
3255
+ validate(control) {
3256
+ if (!control.value || !this.iti) {
3257
+ return null;
3258
+ }
3259
+ const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
3260
+ if (isValid) {
3261
+ return null;
3262
+ }
3263
+ const errorCode = this.iti.getValidationError();
3264
+ return {
3265
+ invalidPhone: {
3266
+ errorCode,
3267
+ errorMessage: PHONE_ERROR_MESSAGES[errorCode]
3268
+ }
3269
+ };
3270
+ }
3271
+ registerOnValidatorChange(fn) {
3272
+ this.onValidatorChange = fn;
3273
+ }
3274
+ };
3275
+ __decorateClass([
3276
+ ViewChild("inputRef", { static: true })
3277
+ ], IntlTelInputComponent.prototype, "inputRef", 2);
3278
+ __decorateClass([
3279
+ Input()
3280
+ ], IntlTelInputComponent.prototype, "initialValue", 2);
3281
+ __decorateClass([
3282
+ Input()
3283
+ ], IntlTelInputComponent.prototype, "usePreciseValidation", 2);
3284
+ __decorateClass([
3285
+ Input()
3286
+ ], IntlTelInputComponent.prototype, "inputProps", 2);
3287
+ __decorateClass([
3288
+ Input()
3289
+ ], IntlTelInputComponent.prototype, "disabled", 2);
3290
+ __decorateClass([
3291
+ Input()
3292
+ ], IntlTelInputComponent.prototype, "initOptions", 2);
3293
+ __decorateClass([
3294
+ Output()
3295
+ ], IntlTelInputComponent.prototype, "numberChange", 2);
3296
+ __decorateClass([
3297
+ Output()
3298
+ ], IntlTelInputComponent.prototype, "countryChange", 2);
3299
+ __decorateClass([
3300
+ Output()
3301
+ ], IntlTelInputComponent.prototype, "validityChange", 2);
3302
+ __decorateClass([
3303
+ Output()
3304
+ ], IntlTelInputComponent.prototype, "errorCodeChange", 2);
3305
+ IntlTelInputComponent = __decorateClass([
3306
+ Component({
3307
+ selector: "intl-tel-input",
3308
+ standalone: true,
3309
+ template: `
3310
+ <input
3311
+ type="tel"
3312
+ #inputRef
3313
+ (input)="handleInput()"
3314
+ (blur)="handleBlur()"
3315
+ [disabled]="disabled"
3316
+ />
3317
+ `,
3318
+ providers: [
3319
+ {
3320
+ provide: NG_VALUE_ACCESSOR,
3321
+ useExisting: forwardRef(() => IntlTelInputComponent),
3322
+ multi: true
3323
+ },
3324
+ {
3325
+ provide: NG_VALIDATORS,
3326
+ useExisting: forwardRef(() => IntlTelInputComponent),
3327
+ multi: true
3328
+ }
3329
+ ]
3330
+ })
3331
+ ], IntlTelInputComponent);
3332
+ var angular_default = IntlTelInputComponent;
3333
+ export {
3334
+ PHONE_ERROR_MESSAGES,
3335
+ angular_default as default,
3336
+ intl_tel_input_default as intlTelInput
3337
+ };