lite-phone-input 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3536 @@
1
+ // src/preact/PhoneInput.tsx
2
+ import { h } from "preact";
3
+ import { forwardRef } from "preact/compat";
4
+ import { useEffect, useRef, useImperativeHandle } from "preact/hooks";
5
+
6
+ // data/phone-countries.json
7
+ var phone_countries_default = [
8
+ {
9
+ c: "AF",
10
+ n: "Afghanistan",
11
+ d: "93",
12
+ f: "XX XXX XXXX",
13
+ p: "0",
14
+ min: 9,
15
+ max: 9,
16
+ pri: 0
17
+ },
18
+ {
19
+ c: "AX",
20
+ n: "\xC5land Islands",
21
+ d: "358",
22
+ f: "XX XXXXXXX",
23
+ p: "0",
24
+ min: 6,
25
+ max: 10,
26
+ pri: 1
27
+ },
28
+ {
29
+ c: "AL",
30
+ n: "Albania",
31
+ d: "355",
32
+ f: "XX XXX XXXX",
33
+ p: "0",
34
+ min: 8,
35
+ max: 9,
36
+ pri: 0
37
+ },
38
+ {
39
+ c: "DZ",
40
+ n: "Algeria",
41
+ d: "213",
42
+ f: "XXX XX XX XX",
43
+ p: "0",
44
+ min: 8,
45
+ max: 9,
46
+ pri: 0
47
+ },
48
+ {
49
+ c: "AS",
50
+ n: "American Samoa",
51
+ d: "1",
52
+ f: "XXX XXX XXXX",
53
+ p: "1",
54
+ min: 10,
55
+ max: 10,
56
+ pri: 3
57
+ },
58
+ {
59
+ c: "AD",
60
+ n: "Andorra",
61
+ d: "376",
62
+ f: "XXX XXX",
63
+ p: null,
64
+ min: 6,
65
+ max: 9,
66
+ pri: 0
67
+ },
68
+ {
69
+ c: "AO",
70
+ n: "Angola",
71
+ d: "244",
72
+ f: "XXX XXX XXX",
73
+ p: null,
74
+ min: 9,
75
+ max: 9,
76
+ pri: 0
77
+ },
78
+ {
79
+ c: "AI",
80
+ n: "Anguilla",
81
+ d: "1",
82
+ f: "XXX XXX XXXX",
83
+ p: "1",
84
+ min: 10,
85
+ max: 10,
86
+ pri: 2
87
+ },
88
+ {
89
+ c: "AG",
90
+ n: "Antigua & Barbuda",
91
+ d: "1",
92
+ f: "XXX XXX XXXX",
93
+ p: "1",
94
+ min: 10,
95
+ max: 10,
96
+ pri: 1
97
+ },
98
+ {
99
+ c: "AR",
100
+ n: "Argentina",
101
+ d: "54",
102
+ f: "XX XX XXXX XXXX",
103
+ p: "0",
104
+ min: 10,
105
+ max: 11,
106
+ pri: 0
107
+ },
108
+ {
109
+ c: "AM",
110
+ n: "Armenia",
111
+ d: "374",
112
+ f: "XX XXXXXX",
113
+ p: "0",
114
+ min: 8,
115
+ max: 8,
116
+ pri: 0
117
+ },
118
+ {
119
+ c: "AW",
120
+ n: "Aruba",
121
+ d: "297",
122
+ f: "XXX XXXX",
123
+ p: null,
124
+ min: 7,
125
+ max: 7,
126
+ pri: 0
127
+ },
128
+ {
129
+ c: "AC",
130
+ n: "Ascension Island",
131
+ d: "247",
132
+ f: null,
133
+ p: null,
134
+ min: 5,
135
+ max: 5,
136
+ pri: 0
137
+ },
138
+ {
139
+ c: "AU",
140
+ n: "Australia",
141
+ d: "61",
142
+ f: "XXX XXX XXX",
143
+ p: "0",
144
+ min: 9,
145
+ max: 9,
146
+ pri: 0
147
+ },
148
+ {
149
+ c: "AT",
150
+ n: "Austria",
151
+ d: "43",
152
+ f: "XXX XXXXXX",
153
+ p: "0",
154
+ min: 4,
155
+ max: 13,
156
+ pri: 0
157
+ },
158
+ {
159
+ c: "AZ",
160
+ n: "Azerbaijan",
161
+ d: "994",
162
+ f: "XX XXX XX XX",
163
+ p: "0",
164
+ min: 9,
165
+ max: 9,
166
+ pri: 0
167
+ },
168
+ {
169
+ c: "BS",
170
+ n: "Bahamas",
171
+ d: "1",
172
+ f: "XXX XXX XXXX",
173
+ p: "1",
174
+ min: 10,
175
+ max: 10,
176
+ pri: 6
177
+ },
178
+ {
179
+ c: "BH",
180
+ n: "Bahrain",
181
+ d: "973",
182
+ f: "XXXX XXXX",
183
+ p: null,
184
+ min: 8,
185
+ max: 8,
186
+ pri: 0
187
+ },
188
+ {
189
+ c: "BD",
190
+ n: "Bangladesh",
191
+ d: "880",
192
+ f: "XXXX XXXXXX",
193
+ p: "0",
194
+ min: 6,
195
+ max: 10,
196
+ pri: 0
197
+ },
198
+ {
199
+ c: "BB",
200
+ n: "Barbados",
201
+ d: "1",
202
+ f: "XXX XXX XXXX",
203
+ p: "1",
204
+ min: 10,
205
+ max: 10,
206
+ pri: 4
207
+ },
208
+ {
209
+ c: "BY",
210
+ n: "Belarus",
211
+ d: "375",
212
+ f: "XX XXX XX XX",
213
+ p: "8",
214
+ min: 9,
215
+ max: 9,
216
+ pri: 0
217
+ },
218
+ {
219
+ c: "BE",
220
+ n: "Belgium",
221
+ d: "32",
222
+ f: "XXX XX XX XX",
223
+ p: "0",
224
+ min: 8,
225
+ max: 9,
226
+ pri: 0
227
+ },
228
+ {
229
+ c: "BZ",
230
+ n: "Belize",
231
+ d: "501",
232
+ f: "XXX XXXX",
233
+ p: null,
234
+ min: 7,
235
+ max: 7,
236
+ pri: 0
237
+ },
238
+ {
239
+ c: "BJ",
240
+ n: "Benin",
241
+ d: "229",
242
+ f: "XX XX XX XX XX",
243
+ p: null,
244
+ min: 10,
245
+ max: 10,
246
+ pri: 0
247
+ },
248
+ {
249
+ c: "BM",
250
+ n: "Bermuda",
251
+ d: "1",
252
+ f: "XXX XXX XXXX",
253
+ p: "1",
254
+ min: 10,
255
+ max: 10,
256
+ pri: 5
257
+ },
258
+ {
259
+ c: "BT",
260
+ n: "Bhutan",
261
+ d: "975",
262
+ f: "XX XX XX XX",
263
+ p: null,
264
+ min: 7,
265
+ max: 8,
266
+ pri: 0
267
+ },
268
+ {
269
+ c: "BO",
270
+ n: "Bolivia",
271
+ d: "591",
272
+ f: "XXXXXXXX",
273
+ p: "0",
274
+ min: 8,
275
+ max: 8,
276
+ pri: 0
277
+ },
278
+ {
279
+ c: "BA",
280
+ n: "Bosnia & Herzegovina",
281
+ d: "387",
282
+ f: "XX XXX XXX",
283
+ p: "0",
284
+ min: 8,
285
+ max: 9,
286
+ pri: 0
287
+ },
288
+ {
289
+ c: "BW",
290
+ n: "Botswana",
291
+ d: "267",
292
+ f: "XX XXX XXX",
293
+ p: null,
294
+ min: 7,
295
+ max: 8,
296
+ pri: 0
297
+ },
298
+ {
299
+ c: "BR",
300
+ n: "Brazil",
301
+ d: "55",
302
+ f: "XX XXXXX XXXX",
303
+ p: "0",
304
+ min: 10,
305
+ max: 11,
306
+ pri: 0
307
+ },
308
+ {
309
+ c: "IO",
310
+ n: "British Indian Ocean Territory",
311
+ d: "246",
312
+ f: "XXX XXXX",
313
+ p: null,
314
+ min: 7,
315
+ max: 7,
316
+ pri: 0
317
+ },
318
+ {
319
+ c: "VG",
320
+ n: "British Virgin Islands",
321
+ d: "1",
322
+ f: "XXX XXX XXXX",
323
+ p: "1",
324
+ min: 10,
325
+ max: 10,
326
+ pri: 23
327
+ },
328
+ {
329
+ c: "BN",
330
+ n: "Brunei",
331
+ d: "673",
332
+ f: "XXX XXXX",
333
+ p: null,
334
+ min: 7,
335
+ max: 7,
336
+ pri: 0
337
+ },
338
+ {
339
+ c: "BG",
340
+ n: "Bulgaria",
341
+ d: "359",
342
+ f: "XX XXX XXX",
343
+ p: "0",
344
+ min: 6,
345
+ max: 9,
346
+ pri: 0
347
+ },
348
+ {
349
+ c: "BF",
350
+ n: "Burkina Faso",
351
+ d: "226",
352
+ f: "XX XX XX XX",
353
+ p: null,
354
+ min: 8,
355
+ max: 8,
356
+ pri: 0
357
+ },
358
+ {
359
+ c: "BI",
360
+ n: "Burundi",
361
+ d: "257",
362
+ f: "XX XX XX XX",
363
+ p: null,
364
+ min: 8,
365
+ max: 8,
366
+ pri: 0
367
+ },
368
+ {
369
+ c: "KH",
370
+ n: "Cambodia",
371
+ d: "855",
372
+ f: "XX XXX XXX",
373
+ p: "0",
374
+ min: 8,
375
+ max: 9,
376
+ pri: 0
377
+ },
378
+ {
379
+ c: "CM",
380
+ n: "Cameroon",
381
+ d: "237",
382
+ f: "X XX XX XX XX",
383
+ p: null,
384
+ min: 9,
385
+ max: 9,
386
+ pri: 0
387
+ },
388
+ {
389
+ c: "CA",
390
+ n: "Canada",
391
+ d: "1",
392
+ f: "XXX XXX XXXX",
393
+ p: "1",
394
+ min: 10,
395
+ max: 10,
396
+ pri: 7
397
+ },
398
+ {
399
+ c: "CV",
400
+ n: "Cape Verde",
401
+ d: "238",
402
+ f: "XXX XX XX",
403
+ p: null,
404
+ min: 7,
405
+ max: 7,
406
+ pri: 0
407
+ },
408
+ {
409
+ c: "BQ",
410
+ n: "Caribbean Netherlands",
411
+ d: "599",
412
+ f: "XXX XXXX",
413
+ p: null,
414
+ min: 7,
415
+ max: 7,
416
+ pri: 1
417
+ },
418
+ {
419
+ c: "KY",
420
+ n: "Cayman Islands",
421
+ d: "1",
422
+ f: "XXX XXX XXXX",
423
+ p: "1",
424
+ min: 10,
425
+ max: 10,
426
+ pri: 14
427
+ },
428
+ {
429
+ c: "CF",
430
+ n: "Central African Republic",
431
+ d: "236",
432
+ f: "XX XX XX XX",
433
+ p: null,
434
+ min: 8,
435
+ max: 8,
436
+ pri: 0
437
+ },
438
+ {
439
+ c: "TD",
440
+ n: "Chad",
441
+ d: "235",
442
+ f: "XX XX XX XX",
443
+ p: null,
444
+ min: 8,
445
+ max: 8,
446
+ pri: 0
447
+ },
448
+ {
449
+ c: "CL",
450
+ n: "Chile",
451
+ d: "56",
452
+ f: "X XXXX XXXX",
453
+ p: null,
454
+ min: 9,
455
+ max: 9,
456
+ pri: 0
457
+ },
458
+ {
459
+ c: "CN",
460
+ n: "China",
461
+ d: "86",
462
+ f: "XXX XXXX XXXX",
463
+ p: "0",
464
+ min: 7,
465
+ max: 11,
466
+ pri: 0
467
+ },
468
+ {
469
+ c: "CX",
470
+ n: "Christmas Island",
471
+ d: "61",
472
+ f: "XXX XXX XXX",
473
+ p: "0",
474
+ min: 9,
475
+ max: 9,
476
+ pri: 2
477
+ },
478
+ {
479
+ c: "CC",
480
+ n: "Cocos (Keeling) Islands",
481
+ d: "61",
482
+ f: "XXX XXX XXX",
483
+ p: "0",
484
+ min: 9,
485
+ max: 9,
486
+ pri: 1
487
+ },
488
+ {
489
+ c: "CO",
490
+ n: "Colombia",
491
+ d: "57",
492
+ f: "XXX XXXXXXX",
493
+ p: "0",
494
+ min: 8,
495
+ max: 10,
496
+ pri: 0
497
+ },
498
+ {
499
+ c: "KM",
500
+ n: "Comoros",
501
+ d: "269",
502
+ f: "XXX XX XX",
503
+ p: null,
504
+ min: 7,
505
+ max: 7,
506
+ pri: 0
507
+ },
508
+ {
509
+ c: "CG",
510
+ n: "Congo - Brazzaville",
511
+ d: "242",
512
+ f: "XX XXX XXXX",
513
+ p: null,
514
+ min: 9,
515
+ max: 9,
516
+ pri: 0
517
+ },
518
+ {
519
+ c: "CD",
520
+ n: "Congo - Kinshasa",
521
+ d: "243",
522
+ f: "XXX XXX XXX",
523
+ p: "0",
524
+ min: 7,
525
+ max: 10,
526
+ pri: 0
527
+ },
528
+ {
529
+ c: "CK",
530
+ n: "Cook Islands",
531
+ d: "682",
532
+ f: "XX XXX",
533
+ p: null,
534
+ min: 5,
535
+ max: 5,
536
+ pri: 0
537
+ },
538
+ {
539
+ c: "CR",
540
+ n: "Costa Rica",
541
+ d: "506",
542
+ f: "XXXX XXXX",
543
+ p: null,
544
+ min: 8,
545
+ max: 8,
546
+ pri: 0
547
+ },
548
+ {
549
+ c: "CI",
550
+ n: "C\xF4te d\u2019Ivoire",
551
+ d: "225",
552
+ f: "XX XX XX XXXX",
553
+ p: null,
554
+ min: 10,
555
+ max: 10,
556
+ pri: 0
557
+ },
558
+ {
559
+ c: "HR",
560
+ n: "Croatia",
561
+ d: "385",
562
+ f: "XX XXX XXXX",
563
+ p: "0",
564
+ min: 8,
565
+ max: 9,
566
+ pri: 0
567
+ },
568
+ {
569
+ c: "CU",
570
+ n: "Cuba",
571
+ d: "53",
572
+ f: "X XXXXXXX",
573
+ p: "0",
574
+ min: 6,
575
+ max: 10,
576
+ pri: 0
577
+ },
578
+ {
579
+ c: "CW",
580
+ n: "Cura\xE7ao",
581
+ d: "599",
582
+ f: "X XXX XXXX",
583
+ p: null,
584
+ min: 7,
585
+ max: 8,
586
+ pri: 0
587
+ },
588
+ {
589
+ c: "CY",
590
+ n: "Cyprus",
591
+ d: "357",
592
+ f: "XX XXXXXX",
593
+ p: null,
594
+ min: 8,
595
+ max: 8,
596
+ pri: 0
597
+ },
598
+ {
599
+ c: "CZ",
600
+ n: "Czechia",
601
+ d: "420",
602
+ f: "XXX XXX XXX",
603
+ p: null,
604
+ min: 9,
605
+ max: 9,
606
+ pri: 0
607
+ },
608
+ {
609
+ c: "DK",
610
+ n: "Denmark",
611
+ d: "45",
612
+ f: "XX XX XX XX",
613
+ p: null,
614
+ min: 8,
615
+ max: 8,
616
+ pri: 0
617
+ },
618
+ {
619
+ c: "DJ",
620
+ n: "Djibouti",
621
+ d: "253",
622
+ f: "XX XX XX XX",
623
+ p: null,
624
+ min: 8,
625
+ max: 8,
626
+ pri: 0
627
+ },
628
+ {
629
+ c: "DM",
630
+ n: "Dominica",
631
+ d: "1",
632
+ f: "XXX XXX XXXX",
633
+ p: "1",
634
+ min: 10,
635
+ max: 10,
636
+ pri: 8
637
+ },
638
+ {
639
+ c: "DO",
640
+ n: "Dominican Republic",
641
+ d: "1",
642
+ f: "XXX XXX XXXX",
643
+ p: "1",
644
+ min: 10,
645
+ max: 10,
646
+ pri: 9
647
+ },
648
+ {
649
+ c: "EC",
650
+ n: "Ecuador",
651
+ d: "593",
652
+ f: "XX XXX XXXX",
653
+ p: "0",
654
+ min: 8,
655
+ max: 9,
656
+ pri: 0
657
+ },
658
+ {
659
+ c: "EG",
660
+ n: "Egypt",
661
+ d: "20",
662
+ f: "XX XXXXXXXX",
663
+ p: "0",
664
+ min: 8,
665
+ max: 10,
666
+ pri: 0
667
+ },
668
+ {
669
+ c: "SV",
670
+ n: "El Salvador",
671
+ d: "503",
672
+ f: "XXXX XXXX",
673
+ p: null,
674
+ min: 8,
675
+ max: 8,
676
+ pri: 0
677
+ },
678
+ {
679
+ c: "GQ",
680
+ n: "Equatorial Guinea",
681
+ d: "240",
682
+ f: "XXX XXX XXX",
683
+ p: null,
684
+ min: 9,
685
+ max: 9,
686
+ pri: 0
687
+ },
688
+ {
689
+ c: "ER",
690
+ n: "Eritrea",
691
+ d: "291",
692
+ f: "X XXX XXX",
693
+ p: "0",
694
+ min: 7,
695
+ max: 7,
696
+ pri: 0
697
+ },
698
+ {
699
+ c: "EE",
700
+ n: "Estonia",
701
+ d: "372",
702
+ f: "XXX XXXX",
703
+ p: null,
704
+ min: 7,
705
+ max: 8,
706
+ pri: 0
707
+ },
708
+ {
709
+ c: "SZ",
710
+ n: "Eswatini",
711
+ d: "268",
712
+ f: "XXXX XXXX",
713
+ p: null,
714
+ min: 8,
715
+ max: 8,
716
+ pri: 0
717
+ },
718
+ {
719
+ c: "ET",
720
+ n: "Ethiopia",
721
+ d: "251",
722
+ f: "XX XXX XXXX",
723
+ p: "0",
724
+ min: 9,
725
+ max: 9,
726
+ pri: 0
727
+ },
728
+ {
729
+ c: "FK",
730
+ n: "Falkland Islands",
731
+ d: "500",
732
+ f: null,
733
+ p: null,
734
+ min: 5,
735
+ max: 5,
736
+ pri: 0
737
+ },
738
+ {
739
+ c: "FO",
740
+ n: "Faroe Islands",
741
+ d: "298",
742
+ f: "XXXXXX",
743
+ p: null,
744
+ min: 6,
745
+ max: 6,
746
+ pri: 0
747
+ },
748
+ {
749
+ c: "FJ",
750
+ n: "Fiji",
751
+ d: "679",
752
+ f: "XXX XXXX",
753
+ p: null,
754
+ min: 7,
755
+ max: 7,
756
+ pri: 0
757
+ },
758
+ {
759
+ c: "FI",
760
+ n: "Finland",
761
+ d: "358",
762
+ f: "XX XXXXXXX",
763
+ p: "0",
764
+ min: 5,
765
+ max: 10,
766
+ pri: 0
767
+ },
768
+ {
769
+ c: "FR",
770
+ n: "France",
771
+ d: "33",
772
+ f: "X XX XX XX XX",
773
+ p: "0",
774
+ min: 9,
775
+ max: 9,
776
+ pri: 0
777
+ },
778
+ {
779
+ c: "GF",
780
+ n: "French Guiana",
781
+ d: "594",
782
+ f: "XXX XX XX XX",
783
+ p: "0",
784
+ min: 9,
785
+ max: 9,
786
+ pri: 0
787
+ },
788
+ {
789
+ c: "PF",
790
+ n: "French Polynesia",
791
+ d: "689",
792
+ f: "XX XX XX XX",
793
+ p: null,
794
+ min: 8,
795
+ max: 8,
796
+ pri: 0
797
+ },
798
+ {
799
+ c: "GA",
800
+ n: "Gabon",
801
+ d: "241",
802
+ f: "XX XX XX XX",
803
+ p: null,
804
+ min: 7,
805
+ max: 8,
806
+ pri: 0
807
+ },
808
+ {
809
+ c: "GM",
810
+ n: "Gambia",
811
+ d: "220",
812
+ f: "XXX XXXX",
813
+ p: null,
814
+ min: 7,
815
+ max: 7,
816
+ pri: 0
817
+ },
818
+ {
819
+ c: "GE",
820
+ n: "Georgia",
821
+ d: "995",
822
+ f: "XXX XX XX XX",
823
+ p: "0",
824
+ min: 9,
825
+ max: 9,
826
+ pri: 0
827
+ },
828
+ {
829
+ c: "DE",
830
+ n: "Germany",
831
+ d: "49",
832
+ f: "XXXX XXXXXXX",
833
+ p: "0",
834
+ min: 5,
835
+ max: 15,
836
+ pri: 0
837
+ },
838
+ {
839
+ c: "GH",
840
+ n: "Ghana",
841
+ d: "233",
842
+ f: "XX XXX XXXX",
843
+ p: "0",
844
+ min: 9,
845
+ max: 9,
846
+ pri: 0
847
+ },
848
+ {
849
+ c: "GI",
850
+ n: "Gibraltar",
851
+ d: "350",
852
+ f: "XXX XXXXX",
853
+ p: null,
854
+ min: 8,
855
+ max: 8,
856
+ pri: 0
857
+ },
858
+ {
859
+ c: "GR",
860
+ n: "Greece",
861
+ d: "30",
862
+ f: "XXX XXX XXXX",
863
+ p: null,
864
+ min: 10,
865
+ max: 10,
866
+ pri: 0
867
+ },
868
+ {
869
+ c: "GL",
870
+ n: "Greenland",
871
+ d: "299",
872
+ f: "XX XX XX",
873
+ p: null,
874
+ min: 6,
875
+ max: 6,
876
+ pri: 0
877
+ },
878
+ {
879
+ c: "GD",
880
+ n: "Grenada",
881
+ d: "1",
882
+ f: "XXX XXX XXXX",
883
+ p: "1",
884
+ min: 10,
885
+ max: 10,
886
+ pri: 10
887
+ },
888
+ {
889
+ c: "GP",
890
+ n: "Guadeloupe",
891
+ d: "590",
892
+ f: "XXX XX XX XX",
893
+ p: "0",
894
+ min: 9,
895
+ max: 9,
896
+ pri: 0
897
+ },
898
+ {
899
+ c: "GU",
900
+ n: "Guam",
901
+ d: "1",
902
+ f: "XXX XXX XXXX",
903
+ p: "1",
904
+ min: 10,
905
+ max: 10,
906
+ pri: 11
907
+ },
908
+ {
909
+ c: "GT",
910
+ n: "Guatemala",
911
+ d: "502",
912
+ f: "XXXX XXXX",
913
+ p: null,
914
+ min: 8,
915
+ max: 8,
916
+ pri: 0
917
+ },
918
+ {
919
+ c: "GG",
920
+ n: "Guernsey",
921
+ d: "44",
922
+ f: "XXXX XXXXXX",
923
+ p: "0",
924
+ min: 10,
925
+ max: 10,
926
+ pri: 1
927
+ },
928
+ {
929
+ c: "GN",
930
+ n: "Guinea",
931
+ d: "224",
932
+ f: "XXX XX XX XX",
933
+ p: null,
934
+ min: 8,
935
+ max: 9,
936
+ pri: 0
937
+ },
938
+ {
939
+ c: "GW",
940
+ n: "Guinea-Bissau",
941
+ d: "245",
942
+ f: "XXX XXX XXX",
943
+ p: null,
944
+ min: 9,
945
+ max: 9,
946
+ pri: 0
947
+ },
948
+ {
949
+ c: "GY",
950
+ n: "Guyana",
951
+ d: "592",
952
+ f: "XXX XXXX",
953
+ p: null,
954
+ min: 7,
955
+ max: 7,
956
+ pri: 0
957
+ },
958
+ {
959
+ c: "HT",
960
+ n: "Haiti",
961
+ d: "509",
962
+ f: "XX XX XXXX",
963
+ p: null,
964
+ min: 8,
965
+ max: 8,
966
+ pri: 0
967
+ },
968
+ {
969
+ c: "HN",
970
+ n: "Honduras",
971
+ d: "504",
972
+ f: "XXXX XXXX",
973
+ p: null,
974
+ min: 8,
975
+ max: 8,
976
+ pri: 0
977
+ },
978
+ {
979
+ c: "HK",
980
+ n: "Hong Kong SAR China",
981
+ d: "852",
982
+ f: "XXXX XXXX",
983
+ p: null,
984
+ min: 8,
985
+ max: 8,
986
+ pri: 0
987
+ },
988
+ {
989
+ c: "HU",
990
+ n: "Hungary",
991
+ d: "36",
992
+ f: "XX XXX XXXX",
993
+ p: "06",
994
+ min: 8,
995
+ max: 9,
996
+ pri: 0
997
+ },
998
+ {
999
+ c: "IS",
1000
+ n: "Iceland",
1001
+ d: "354",
1002
+ f: "XXX XXXX",
1003
+ p: null,
1004
+ min: 7,
1005
+ max: 9,
1006
+ pri: 0
1007
+ },
1008
+ {
1009
+ c: "IN",
1010
+ n: "India",
1011
+ d: "91",
1012
+ f: "XXXXX XXXXX",
1013
+ p: "0",
1014
+ min: 10,
1015
+ max: 10,
1016
+ pri: 0
1017
+ },
1018
+ {
1019
+ c: "ID",
1020
+ n: "Indonesia",
1021
+ d: "62",
1022
+ f: "XXX XXX XXX",
1023
+ p: "0",
1024
+ min: 7,
1025
+ max: 12,
1026
+ pri: 0
1027
+ },
1028
+ {
1029
+ c: "IR",
1030
+ n: "Iran",
1031
+ d: "98",
1032
+ f: "XXX XXX XXXX",
1033
+ p: "0",
1034
+ min: 6,
1035
+ max: 10,
1036
+ pri: 0
1037
+ },
1038
+ {
1039
+ c: "IQ",
1040
+ n: "Iraq",
1041
+ d: "964",
1042
+ f: "XXX XXX XXXX",
1043
+ p: "0",
1044
+ min: 8,
1045
+ max: 10,
1046
+ pri: 0
1047
+ },
1048
+ {
1049
+ c: "IE",
1050
+ n: "Ireland",
1051
+ d: "353",
1052
+ f: "XX XXX XXXX",
1053
+ p: "0",
1054
+ min: 7,
1055
+ max: 10,
1056
+ pri: 0
1057
+ },
1058
+ {
1059
+ c: "IM",
1060
+ n: "Isle of Man",
1061
+ d: "44",
1062
+ f: "XXXX XXXXXX",
1063
+ p: "0",
1064
+ min: 10,
1065
+ max: 10,
1066
+ pri: 2
1067
+ },
1068
+ {
1069
+ c: "IL",
1070
+ n: "Israel",
1071
+ d: "972",
1072
+ f: "XX XXX XXXX",
1073
+ p: "0",
1074
+ min: 8,
1075
+ max: 12,
1076
+ pri: 0
1077
+ },
1078
+ {
1079
+ c: "IT",
1080
+ n: "Italy",
1081
+ d: "39",
1082
+ f: "XXX XXX XXXX",
1083
+ p: null,
1084
+ min: 6,
1085
+ max: 12,
1086
+ pri: 0
1087
+ },
1088
+ {
1089
+ c: "JM",
1090
+ n: "Jamaica",
1091
+ d: "1",
1092
+ f: "XXX XXX XXXX",
1093
+ p: "1",
1094
+ min: 10,
1095
+ max: 10,
1096
+ pri: 12
1097
+ },
1098
+ {
1099
+ c: "JP",
1100
+ n: "Japan",
1101
+ d: "81",
1102
+ f: "XX XXXX XXXX",
1103
+ p: "0",
1104
+ min: 9,
1105
+ max: 10,
1106
+ pri: 0
1107
+ },
1108
+ {
1109
+ c: "JE",
1110
+ n: "Jersey",
1111
+ d: "44",
1112
+ f: "XXXX XXXXXX",
1113
+ p: "0",
1114
+ min: 10,
1115
+ max: 10,
1116
+ pri: 3
1117
+ },
1118
+ {
1119
+ c: "JO",
1120
+ n: "Jordan",
1121
+ d: "962",
1122
+ f: "X XXXX XXXX",
1123
+ p: "0",
1124
+ min: 8,
1125
+ max: 9,
1126
+ pri: 0
1127
+ },
1128
+ {
1129
+ c: "KZ",
1130
+ n: "Kazakhstan",
1131
+ d: "7",
1132
+ f: "XXX XXX XXXX",
1133
+ p: "8",
1134
+ min: 10,
1135
+ max: 10,
1136
+ pri: 1
1137
+ },
1138
+ {
1139
+ c: "KE",
1140
+ n: "Kenya",
1141
+ d: "254",
1142
+ f: "XXX XXXXXX",
1143
+ p: "0",
1144
+ min: 7,
1145
+ max: 9,
1146
+ pri: 0
1147
+ },
1148
+ {
1149
+ c: "KI",
1150
+ n: "Kiribati",
1151
+ d: "686",
1152
+ f: null,
1153
+ p: "0",
1154
+ min: 5,
1155
+ max: 8,
1156
+ pri: 0
1157
+ },
1158
+ {
1159
+ c: "XK",
1160
+ n: "Kosovo",
1161
+ d: "383",
1162
+ f: "XX XXX XXX",
1163
+ p: "0",
1164
+ min: 8,
1165
+ max: 12,
1166
+ pri: 0
1167
+ },
1168
+ {
1169
+ c: "KW",
1170
+ n: "Kuwait",
1171
+ d: "965",
1172
+ f: "XXX XXXXX",
1173
+ p: null,
1174
+ min: 8,
1175
+ max: 8,
1176
+ pri: 0
1177
+ },
1178
+ {
1179
+ c: "KG",
1180
+ n: "Kyrgyzstan",
1181
+ d: "996",
1182
+ f: "XXX XXX XXX",
1183
+ p: "0",
1184
+ min: 9,
1185
+ max: 9,
1186
+ pri: 0
1187
+ },
1188
+ {
1189
+ c: "LA",
1190
+ n: "Laos",
1191
+ d: "856",
1192
+ f: "XX XX XXX XXX",
1193
+ p: "0",
1194
+ min: 8,
1195
+ max: 10,
1196
+ pri: 0
1197
+ },
1198
+ {
1199
+ c: "LV",
1200
+ n: "Latvia",
1201
+ d: "371",
1202
+ f: "XX XXX XXX",
1203
+ p: null,
1204
+ min: 8,
1205
+ max: 8,
1206
+ pri: 0
1207
+ },
1208
+ {
1209
+ c: "LB",
1210
+ n: "Lebanon",
1211
+ d: "961",
1212
+ f: "XX XXX XXX",
1213
+ p: "0",
1214
+ min: 7,
1215
+ max: 8,
1216
+ pri: 0
1217
+ },
1218
+ {
1219
+ c: "LS",
1220
+ n: "Lesotho",
1221
+ d: "266",
1222
+ f: "XXXX XXXX",
1223
+ p: null,
1224
+ min: 8,
1225
+ max: 8,
1226
+ pri: 0
1227
+ },
1228
+ {
1229
+ c: "LR",
1230
+ n: "Liberia",
1231
+ d: "231",
1232
+ f: "XX XXX XXXX",
1233
+ p: "0",
1234
+ min: 7,
1235
+ max: 9,
1236
+ pri: 0
1237
+ },
1238
+ {
1239
+ c: "LY",
1240
+ n: "Libya",
1241
+ d: "218",
1242
+ f: "XX XXXXXXX",
1243
+ p: "0",
1244
+ min: 9,
1245
+ max: 9,
1246
+ pri: 0
1247
+ },
1248
+ {
1249
+ c: "LI",
1250
+ n: "Liechtenstein",
1251
+ d: "423",
1252
+ f: "XXX XXX XXX",
1253
+ p: "0",
1254
+ min: 7,
1255
+ max: 9,
1256
+ pri: 0
1257
+ },
1258
+ {
1259
+ c: "LT",
1260
+ n: "Lithuania",
1261
+ d: "370",
1262
+ f: "XXX XXXXX",
1263
+ p: "0",
1264
+ min: 8,
1265
+ max: 8,
1266
+ pri: 0
1267
+ },
1268
+ {
1269
+ c: "LU",
1270
+ n: "Luxembourg",
1271
+ d: "352",
1272
+ f: "XXX XXX XXX",
1273
+ p: null,
1274
+ min: 4,
1275
+ max: 11,
1276
+ pri: 0
1277
+ },
1278
+ {
1279
+ c: "MO",
1280
+ n: "Macao SAR China",
1281
+ d: "853",
1282
+ f: "XXXX XXXX",
1283
+ p: null,
1284
+ min: 8,
1285
+ max: 8,
1286
+ pri: 0
1287
+ },
1288
+ {
1289
+ c: "MG",
1290
+ n: "Madagascar",
1291
+ d: "261",
1292
+ f: "XX XX XXX XX",
1293
+ p: "0",
1294
+ min: 9,
1295
+ max: 9,
1296
+ pri: 0
1297
+ },
1298
+ {
1299
+ c: "MW",
1300
+ n: "Malawi",
1301
+ d: "265",
1302
+ f: "XXX XX XX XX",
1303
+ p: "0",
1304
+ min: 7,
1305
+ max: 9,
1306
+ pri: 0
1307
+ },
1308
+ {
1309
+ c: "MY",
1310
+ n: "Malaysia",
1311
+ d: "60",
1312
+ f: "XX XXX XXXX",
1313
+ p: "0",
1314
+ min: 8,
1315
+ max: 10,
1316
+ pri: 0
1317
+ },
1318
+ {
1319
+ c: "MV",
1320
+ n: "Maldives",
1321
+ d: "960",
1322
+ f: "XXX XXXX",
1323
+ p: null,
1324
+ min: 7,
1325
+ max: 7,
1326
+ pri: 0
1327
+ },
1328
+ {
1329
+ c: "ML",
1330
+ n: "Mali",
1331
+ d: "223",
1332
+ f: "XX XX XX XX",
1333
+ p: null,
1334
+ min: 8,
1335
+ max: 8,
1336
+ pri: 0
1337
+ },
1338
+ {
1339
+ c: "MT",
1340
+ n: "Malta",
1341
+ d: "356",
1342
+ f: "XXXX XXXX",
1343
+ p: null,
1344
+ min: 8,
1345
+ max: 8,
1346
+ pri: 0
1347
+ },
1348
+ {
1349
+ c: "MH",
1350
+ n: "Marshall Islands",
1351
+ d: "692",
1352
+ f: "XXX XXXX",
1353
+ p: "1",
1354
+ min: 7,
1355
+ max: 7,
1356
+ pri: 0
1357
+ },
1358
+ {
1359
+ c: "MQ",
1360
+ n: "Martinique",
1361
+ d: "596",
1362
+ f: "XXX XX XX XX",
1363
+ p: "0",
1364
+ min: 9,
1365
+ max: 9,
1366
+ pri: 0
1367
+ },
1368
+ {
1369
+ c: "MR",
1370
+ n: "Mauritania",
1371
+ d: "222",
1372
+ f: "XX XX XX XX",
1373
+ p: null,
1374
+ min: 8,
1375
+ max: 8,
1376
+ pri: 0
1377
+ },
1378
+ {
1379
+ c: "MU",
1380
+ n: "Mauritius",
1381
+ d: "230",
1382
+ f: "XXXX XXXX",
1383
+ p: null,
1384
+ min: 7,
1385
+ max: 8,
1386
+ pri: 0
1387
+ },
1388
+ {
1389
+ c: "YT",
1390
+ n: "Mayotte",
1391
+ d: "262",
1392
+ f: "XXX XX XX XX",
1393
+ p: "0",
1394
+ min: 9,
1395
+ max: 9,
1396
+ pri: 1
1397
+ },
1398
+ {
1399
+ c: "MX",
1400
+ n: "Mexico",
1401
+ d: "52",
1402
+ f: "XXX XXX XXXX",
1403
+ p: null,
1404
+ min: 10,
1405
+ max: 10,
1406
+ pri: 0
1407
+ },
1408
+ {
1409
+ c: "FM",
1410
+ n: "Micronesia",
1411
+ d: "691",
1412
+ f: "XXX XXXX",
1413
+ p: null,
1414
+ min: 7,
1415
+ max: 7,
1416
+ pri: 0
1417
+ },
1418
+ {
1419
+ c: "MD",
1420
+ n: "Moldova",
1421
+ d: "373",
1422
+ f: "XXX XX XXX",
1423
+ p: "0",
1424
+ min: 8,
1425
+ max: 8,
1426
+ pri: 0
1427
+ },
1428
+ {
1429
+ c: "MC",
1430
+ n: "Monaco",
1431
+ d: "377",
1432
+ f: "X XX XX XX XX",
1433
+ p: "0",
1434
+ min: 8,
1435
+ max: 9,
1436
+ pri: 0
1437
+ },
1438
+ {
1439
+ c: "MN",
1440
+ n: "Mongolia",
1441
+ d: "976",
1442
+ f: "XXXX XXXX",
1443
+ p: "0",
1444
+ min: 8,
1445
+ max: 10,
1446
+ pri: 0
1447
+ },
1448
+ {
1449
+ c: "ME",
1450
+ n: "Montenegro",
1451
+ d: "382",
1452
+ f: "XX XXX XXX",
1453
+ p: "0",
1454
+ min: 8,
1455
+ max: 8,
1456
+ pri: 0
1457
+ },
1458
+ {
1459
+ c: "MS",
1460
+ n: "Montserrat",
1461
+ d: "1",
1462
+ f: "XXX XXX XXXX",
1463
+ p: "1",
1464
+ min: 10,
1465
+ max: 10,
1466
+ pri: 17
1467
+ },
1468
+ {
1469
+ c: "MA",
1470
+ n: "Morocco",
1471
+ d: "212",
1472
+ f: "X XX XX XX XX",
1473
+ p: "0",
1474
+ min: 9,
1475
+ max: 9,
1476
+ pri: 0
1477
+ },
1478
+ {
1479
+ c: "MZ",
1480
+ n: "Mozambique",
1481
+ d: "258",
1482
+ f: "XX XXX XXXX",
1483
+ p: null,
1484
+ min: 8,
1485
+ max: 9,
1486
+ pri: 0
1487
+ },
1488
+ {
1489
+ c: "MM",
1490
+ n: "Myanmar (Burma)",
1491
+ d: "95",
1492
+ f: "X XXX XXXX",
1493
+ p: "0",
1494
+ min: 6,
1495
+ max: 10,
1496
+ pri: 0
1497
+ },
1498
+ {
1499
+ c: "NA",
1500
+ n: "Namibia",
1501
+ d: "264",
1502
+ f: "XX XXX XXXX",
1503
+ p: "0",
1504
+ min: 8,
1505
+ max: 9,
1506
+ pri: 0
1507
+ },
1508
+ {
1509
+ c: "NR",
1510
+ n: "Nauru",
1511
+ d: "674",
1512
+ f: "XXX XXXX",
1513
+ p: null,
1514
+ min: 7,
1515
+ max: 7,
1516
+ pri: 0
1517
+ },
1518
+ {
1519
+ c: "NP",
1520
+ n: "Nepal",
1521
+ d: "977",
1522
+ f: "XXX XXXXXXX",
1523
+ p: "0",
1524
+ min: 8,
1525
+ max: 10,
1526
+ pri: 0
1527
+ },
1528
+ {
1529
+ c: "NL",
1530
+ n: "Netherlands",
1531
+ d: "31",
1532
+ f: "X XXXXXXXX",
1533
+ p: "0",
1534
+ min: 9,
1535
+ max: 11,
1536
+ pri: 0
1537
+ },
1538
+ {
1539
+ c: "NC",
1540
+ n: "New Caledonia",
1541
+ d: "687",
1542
+ f: "XX XX XX",
1543
+ p: null,
1544
+ min: 6,
1545
+ max: 6,
1546
+ pri: 0
1547
+ },
1548
+ {
1549
+ c: "NZ",
1550
+ n: "New Zealand",
1551
+ d: "64",
1552
+ f: "XX XXX XXXX",
1553
+ p: "0",
1554
+ min: 8,
1555
+ max: 10,
1556
+ pri: 0
1557
+ },
1558
+ {
1559
+ c: "NI",
1560
+ n: "Nicaragua",
1561
+ d: "505",
1562
+ f: "XXXX XXXX",
1563
+ p: null,
1564
+ min: 8,
1565
+ max: 8,
1566
+ pri: 0
1567
+ },
1568
+ {
1569
+ c: "NE",
1570
+ n: "Niger",
1571
+ d: "227",
1572
+ f: "XX XX XX XX",
1573
+ p: null,
1574
+ min: 8,
1575
+ max: 8,
1576
+ pri: 0
1577
+ },
1578
+ {
1579
+ c: "NG",
1580
+ n: "Nigeria",
1581
+ d: "234",
1582
+ f: "XXX XXX XXXX",
1583
+ p: "0",
1584
+ min: 10,
1585
+ max: 10,
1586
+ pri: 0
1587
+ },
1588
+ {
1589
+ c: "NU",
1590
+ n: "Niue",
1591
+ d: "683",
1592
+ f: "XXX XXXX",
1593
+ p: null,
1594
+ min: 4,
1595
+ max: 7,
1596
+ pri: 0
1597
+ },
1598
+ {
1599
+ c: "NF",
1600
+ n: "Norfolk Island",
1601
+ d: "672",
1602
+ f: "X XXXXX",
1603
+ p: null,
1604
+ min: 6,
1605
+ max: 6,
1606
+ pri: 0
1607
+ },
1608
+ {
1609
+ c: "KP",
1610
+ n: "North Korea",
1611
+ d: "850",
1612
+ f: "XXX XXX XXXX",
1613
+ p: "0",
1614
+ min: 8,
1615
+ max: 10,
1616
+ pri: 0
1617
+ },
1618
+ {
1619
+ c: "MK",
1620
+ n: "North Macedonia",
1621
+ d: "389",
1622
+ f: "XX XXX XXX",
1623
+ p: "0",
1624
+ min: 8,
1625
+ max: 8,
1626
+ pri: 0
1627
+ },
1628
+ {
1629
+ c: "MP",
1630
+ n: "Northern Mariana Islands",
1631
+ d: "1",
1632
+ f: "XXX XXX XXXX",
1633
+ p: "1",
1634
+ min: 10,
1635
+ max: 10,
1636
+ pri: 16
1637
+ },
1638
+ {
1639
+ c: "NO",
1640
+ n: "Norway",
1641
+ d: "47",
1642
+ f: "XX XX XX XX",
1643
+ p: null,
1644
+ min: 8,
1645
+ max: 8,
1646
+ pri: 0
1647
+ },
1648
+ {
1649
+ c: "OM",
1650
+ n: "Oman",
1651
+ d: "968",
1652
+ f: "XXXX XXXX",
1653
+ p: null,
1654
+ min: 8,
1655
+ max: 8,
1656
+ pri: 0
1657
+ },
1658
+ {
1659
+ c: "PK",
1660
+ n: "Pakistan",
1661
+ d: "92",
1662
+ f: "XXX XXXXXXX",
1663
+ p: "0",
1664
+ min: 9,
1665
+ max: 10,
1666
+ pri: 0
1667
+ },
1668
+ {
1669
+ c: "PW",
1670
+ n: "Palau",
1671
+ d: "680",
1672
+ f: "XXX XXXX",
1673
+ p: null,
1674
+ min: 7,
1675
+ max: 7,
1676
+ pri: 0
1677
+ },
1678
+ {
1679
+ c: "PS",
1680
+ n: "Palestinian Territories",
1681
+ d: "970",
1682
+ f: "XXX XXX XXX",
1683
+ p: "0",
1684
+ min: 8,
1685
+ max: 9,
1686
+ pri: 0
1687
+ },
1688
+ {
1689
+ c: "PA",
1690
+ n: "Panama",
1691
+ d: "507",
1692
+ f: "XXXX XXXX",
1693
+ p: null,
1694
+ min: 7,
1695
+ max: 8,
1696
+ pri: 0
1697
+ },
1698
+ {
1699
+ c: "PG",
1700
+ n: "Papua New Guinea",
1701
+ d: "675",
1702
+ f: "XXXX XXXX",
1703
+ p: null,
1704
+ min: 7,
1705
+ max: 8,
1706
+ pri: 0
1707
+ },
1708
+ {
1709
+ c: "PY",
1710
+ n: "Paraguay",
1711
+ d: "595",
1712
+ f: "XXX XXXXXX",
1713
+ p: "0",
1714
+ min: 7,
1715
+ max: 9,
1716
+ pri: 0
1717
+ },
1718
+ {
1719
+ c: "PE",
1720
+ n: "Peru",
1721
+ d: "51",
1722
+ f: "XXX XXX XXX",
1723
+ p: "0",
1724
+ min: 8,
1725
+ max: 9,
1726
+ pri: 0
1727
+ },
1728
+ {
1729
+ c: "PH",
1730
+ n: "Philippines",
1731
+ d: "63",
1732
+ f: "XXX XXX XXXX",
1733
+ p: "0",
1734
+ min: 6,
1735
+ max: 10,
1736
+ pri: 0
1737
+ },
1738
+ {
1739
+ c: "PL",
1740
+ n: "Poland",
1741
+ d: "48",
1742
+ f: "XXX XXX XXX",
1743
+ p: null,
1744
+ min: 7,
1745
+ max: 9,
1746
+ pri: 0
1747
+ },
1748
+ {
1749
+ c: "PT",
1750
+ n: "Portugal",
1751
+ d: "351",
1752
+ f: "XXX XXX XXX",
1753
+ p: null,
1754
+ min: 9,
1755
+ max: 9,
1756
+ pri: 0
1757
+ },
1758
+ {
1759
+ c: "PR",
1760
+ n: "Puerto Rico",
1761
+ d: "1",
1762
+ f: "XXX XXX XXXX",
1763
+ p: "1",
1764
+ min: 10,
1765
+ max: 10,
1766
+ pri: 18
1767
+ },
1768
+ {
1769
+ c: "QA",
1770
+ n: "Qatar",
1771
+ d: "974",
1772
+ f: "XXXX XXXX",
1773
+ p: null,
1774
+ min: 8,
1775
+ max: 8,
1776
+ pri: 0
1777
+ },
1778
+ {
1779
+ c: "RE",
1780
+ n: "R\xE9union",
1781
+ d: "262",
1782
+ f: "XXX XX XX XX",
1783
+ p: "0",
1784
+ min: 9,
1785
+ max: 9,
1786
+ pri: 0
1787
+ },
1788
+ {
1789
+ c: "RO",
1790
+ n: "Romania",
1791
+ d: "40",
1792
+ f: "XXX XXX XXX",
1793
+ p: "0",
1794
+ min: 6,
1795
+ max: 9,
1796
+ pri: 0
1797
+ },
1798
+ {
1799
+ c: "RU",
1800
+ n: "Russia",
1801
+ d: "7",
1802
+ f: "XXX XXX XX XX",
1803
+ p: "8",
1804
+ min: 10,
1805
+ max: 10,
1806
+ pri: 0
1807
+ },
1808
+ {
1809
+ c: "RW",
1810
+ n: "Rwanda",
1811
+ d: "250",
1812
+ f: "XXX XXX XXX",
1813
+ p: "0",
1814
+ min: 8,
1815
+ max: 9,
1816
+ pri: 0
1817
+ },
1818
+ {
1819
+ c: "WS",
1820
+ n: "Samoa",
1821
+ d: "685",
1822
+ f: "XX XXXXX",
1823
+ p: null,
1824
+ min: 5,
1825
+ max: 10,
1826
+ pri: 0
1827
+ },
1828
+ {
1829
+ c: "SM",
1830
+ n: "San Marino",
1831
+ d: "378",
1832
+ f: "XX XX XX XX",
1833
+ p: null,
1834
+ min: 8,
1835
+ max: 10,
1836
+ pri: 0
1837
+ },
1838
+ {
1839
+ c: "ST",
1840
+ n: "S\xE3o Tom\xE9 & Pr\xEDncipe",
1841
+ d: "239",
1842
+ f: "XXX XXXX",
1843
+ p: null,
1844
+ min: 7,
1845
+ max: 7,
1846
+ pri: 0
1847
+ },
1848
+ {
1849
+ c: "SA",
1850
+ n: "Saudi Arabia",
1851
+ d: "966",
1852
+ f: "XX XXX XXXX",
1853
+ p: "0",
1854
+ min: 9,
1855
+ max: 9,
1856
+ pri: 0
1857
+ },
1858
+ {
1859
+ c: "SN",
1860
+ n: "Senegal",
1861
+ d: "221",
1862
+ f: "XX XXX XX XX",
1863
+ p: null,
1864
+ min: 9,
1865
+ max: 9,
1866
+ pri: 0
1867
+ },
1868
+ {
1869
+ c: "RS",
1870
+ n: "Serbia",
1871
+ d: "381",
1872
+ f: "XX XXXXXXX",
1873
+ p: "0",
1874
+ min: 7,
1875
+ max: 12,
1876
+ pri: 0
1877
+ },
1878
+ {
1879
+ c: "SC",
1880
+ n: "Seychelles",
1881
+ d: "248",
1882
+ f: "X XXX XXX",
1883
+ p: null,
1884
+ min: 7,
1885
+ max: 7,
1886
+ pri: 0
1887
+ },
1888
+ {
1889
+ c: "SL",
1890
+ n: "Sierra Leone",
1891
+ d: "232",
1892
+ f: "XX XXXXXX",
1893
+ p: "0",
1894
+ min: 8,
1895
+ max: 8,
1896
+ pri: 0
1897
+ },
1898
+ {
1899
+ c: "SG",
1900
+ n: "Singapore",
1901
+ d: "65",
1902
+ f: "XXXX XXXX",
1903
+ p: null,
1904
+ min: 8,
1905
+ max: 8,
1906
+ pri: 0
1907
+ },
1908
+ {
1909
+ c: "SX",
1910
+ n: "Sint Maarten",
1911
+ d: "1",
1912
+ f: "XXX XXX XXXX",
1913
+ p: "1",
1914
+ min: 10,
1915
+ max: 10,
1916
+ pri: 19
1917
+ },
1918
+ {
1919
+ c: "SK",
1920
+ n: "Slovakia",
1921
+ d: "421",
1922
+ f: "XXX XXX XXX",
1923
+ p: "0",
1924
+ min: 6,
1925
+ max: 9,
1926
+ pri: 0
1927
+ },
1928
+ {
1929
+ c: "SI",
1930
+ n: "Slovenia",
1931
+ d: "386",
1932
+ f: "XX XXX XXX",
1933
+ p: "0",
1934
+ min: 8,
1935
+ max: 8,
1936
+ pri: 0
1937
+ },
1938
+ {
1939
+ c: "SB",
1940
+ n: "Solomon Islands",
1941
+ d: "677",
1942
+ f: "XX XXXXX",
1943
+ p: null,
1944
+ min: 5,
1945
+ max: 7,
1946
+ pri: 0
1947
+ },
1948
+ {
1949
+ c: "SO",
1950
+ n: "Somalia",
1951
+ d: "252",
1952
+ f: "X XXXXXXX",
1953
+ p: "0",
1954
+ min: 6,
1955
+ max: 9,
1956
+ pri: 0
1957
+ },
1958
+ {
1959
+ c: "ZA",
1960
+ n: "South Africa",
1961
+ d: "27",
1962
+ f: "XX XXX XXXX",
1963
+ p: "0",
1964
+ min: 5,
1965
+ max: 9,
1966
+ pri: 0
1967
+ },
1968
+ {
1969
+ c: "KR",
1970
+ n: "South Korea",
1971
+ d: "82",
1972
+ f: "XXXX XXXX",
1973
+ p: "0",
1974
+ min: 5,
1975
+ max: 10,
1976
+ pri: 0
1977
+ },
1978
+ {
1979
+ c: "SS",
1980
+ n: "South Sudan",
1981
+ d: "211",
1982
+ f: "XXX XXX XXX",
1983
+ p: "0",
1984
+ min: 9,
1985
+ max: 9,
1986
+ pri: 0
1987
+ },
1988
+ {
1989
+ c: "ES",
1990
+ n: "Spain",
1991
+ d: "34",
1992
+ f: "XXX XX XX XX",
1993
+ p: null,
1994
+ min: 9,
1995
+ max: 9,
1996
+ pri: 0
1997
+ },
1998
+ {
1999
+ c: "LK",
2000
+ n: "Sri Lanka",
2001
+ d: "94",
2002
+ f: "XX XXX XXXX",
2003
+ p: "0",
2004
+ min: 9,
2005
+ max: 9,
2006
+ pri: 0
2007
+ },
2008
+ {
2009
+ c: "BL",
2010
+ n: "St. Barth\xE9lemy",
2011
+ d: "590",
2012
+ f: "XXX XX XX XX",
2013
+ p: "0",
2014
+ min: 9,
2015
+ max: 9,
2016
+ pri: 1
2017
+ },
2018
+ {
2019
+ c: "SH",
2020
+ n: "St. Helena",
2021
+ d: "290",
2022
+ f: null,
2023
+ p: null,
2024
+ min: 4,
2025
+ max: 5,
2026
+ pri: 0
2027
+ },
2028
+ {
2029
+ c: "KN",
2030
+ n: "St. Kitts & Nevis",
2031
+ d: "1",
2032
+ f: "XXX XXX XXXX",
2033
+ p: "1",
2034
+ min: 10,
2035
+ max: 10,
2036
+ pri: 13
2037
+ },
2038
+ {
2039
+ c: "LC",
2040
+ n: "St. Lucia",
2041
+ d: "1",
2042
+ f: "XXX XXX XXXX",
2043
+ p: "1",
2044
+ min: 10,
2045
+ max: 10,
2046
+ pri: 15
2047
+ },
2048
+ {
2049
+ c: "MF",
2050
+ n: "St. Martin",
2051
+ d: "590",
2052
+ f: "XXX XX XX XX",
2053
+ p: "0",
2054
+ min: 9,
2055
+ max: 9,
2056
+ pri: 2
2057
+ },
2058
+ {
2059
+ c: "PM",
2060
+ n: "St. Pierre & Miquelon",
2061
+ d: "508",
2062
+ f: "XX XX XX",
2063
+ p: "0",
2064
+ min: 6,
2065
+ max: 9,
2066
+ pri: 0
2067
+ },
2068
+ {
2069
+ c: "VC",
2070
+ n: "St. Vincent & Grenadines",
2071
+ d: "1",
2072
+ f: "XXX XXX XXXX",
2073
+ p: "1",
2074
+ min: 10,
2075
+ max: 10,
2076
+ pri: 22
2077
+ },
2078
+ {
2079
+ c: "SD",
2080
+ n: "Sudan",
2081
+ d: "249",
2082
+ f: "XX XXX XXXX",
2083
+ p: "0",
2084
+ min: 9,
2085
+ max: 9,
2086
+ pri: 0
2087
+ },
2088
+ {
2089
+ c: "SR",
2090
+ n: "Suriname",
2091
+ d: "597",
2092
+ f: "XXX XXXX",
2093
+ p: null,
2094
+ min: 6,
2095
+ max: 7,
2096
+ pri: 0
2097
+ },
2098
+ {
2099
+ c: "SJ",
2100
+ n: "Svalbard & Jan Mayen",
2101
+ d: "47",
2102
+ f: "XX XX XX XX",
2103
+ p: null,
2104
+ min: 8,
2105
+ max: 8,
2106
+ pri: 1
2107
+ },
2108
+ {
2109
+ c: "SE",
2110
+ n: "Sweden",
2111
+ d: "46",
2112
+ f: "XX XXX XX XX",
2113
+ p: "0",
2114
+ min: 7,
2115
+ max: 9,
2116
+ pri: 0
2117
+ },
2118
+ {
2119
+ c: "CH",
2120
+ n: "Switzerland",
2121
+ d: "41",
2122
+ f: "XX XXX XX XX",
2123
+ p: "0",
2124
+ min: 9,
2125
+ max: 9,
2126
+ pri: 0
2127
+ },
2128
+ {
2129
+ c: "SY",
2130
+ n: "Syria",
2131
+ d: "963",
2132
+ f: "XXX XXX XXX",
2133
+ p: "0",
2134
+ min: 8,
2135
+ max: 9,
2136
+ pri: 0
2137
+ },
2138
+ {
2139
+ c: "TW",
2140
+ n: "Taiwan",
2141
+ d: "886",
2142
+ f: "XXX XXX XXX",
2143
+ p: "0",
2144
+ min: 8,
2145
+ max: 9,
2146
+ pri: 0
2147
+ },
2148
+ {
2149
+ c: "TJ",
2150
+ n: "Tajikistan",
2151
+ d: "992",
2152
+ f: "XX XXX XXXX",
2153
+ p: null,
2154
+ min: 9,
2155
+ max: 9,
2156
+ pri: 0
2157
+ },
2158
+ {
2159
+ c: "TZ",
2160
+ n: "Tanzania",
2161
+ d: "255",
2162
+ f: "XXX XXX XXX",
2163
+ p: "0",
2164
+ min: 9,
2165
+ max: 9,
2166
+ pri: 0
2167
+ },
2168
+ {
2169
+ c: "TH",
2170
+ n: "Thailand",
2171
+ d: "66",
2172
+ f: "XX XXX XXXX",
2173
+ p: "0",
2174
+ min: 8,
2175
+ max: 9,
2176
+ pri: 0
2177
+ },
2178
+ {
2179
+ c: "TL",
2180
+ n: "Timor-Leste",
2181
+ d: "670",
2182
+ f: "XXXX XXXX",
2183
+ p: null,
2184
+ min: 7,
2185
+ max: 8,
2186
+ pri: 0
2187
+ },
2188
+ {
2189
+ c: "TG",
2190
+ n: "Togo",
2191
+ d: "228",
2192
+ f: "XX XX XX XX",
2193
+ p: null,
2194
+ min: 8,
2195
+ max: 8,
2196
+ pri: 0
2197
+ },
2198
+ {
2199
+ c: "TK",
2200
+ n: "Tokelau",
2201
+ d: "690",
2202
+ f: null,
2203
+ p: null,
2204
+ min: 4,
2205
+ max: 7,
2206
+ pri: 0
2207
+ },
2208
+ {
2209
+ c: "TO",
2210
+ n: "Tonga",
2211
+ d: "676",
2212
+ f: "XXX XXXX",
2213
+ p: null,
2214
+ min: 5,
2215
+ max: 7,
2216
+ pri: 0
2217
+ },
2218
+ {
2219
+ c: "TT",
2220
+ n: "Trinidad & Tobago",
2221
+ d: "1",
2222
+ f: "XXX XXX XXXX",
2223
+ p: "1",
2224
+ min: 10,
2225
+ max: 10,
2226
+ pri: 21
2227
+ },
2228
+ {
2229
+ c: "TA",
2230
+ n: "Tristan da Cunha",
2231
+ d: "290",
2232
+ f: null,
2233
+ p: null,
2234
+ min: 4,
2235
+ max: 4,
2236
+ pri: 1
2237
+ },
2238
+ {
2239
+ c: "TN",
2240
+ n: "Tunisia",
2241
+ d: "216",
2242
+ f: "XX XXX XXX",
2243
+ p: null,
2244
+ min: 8,
2245
+ max: 8,
2246
+ pri: 0
2247
+ },
2248
+ {
2249
+ c: "TR",
2250
+ n: "T\xFCrkiye",
2251
+ d: "90",
2252
+ f: "XXX XXX XX XX",
2253
+ p: "0",
2254
+ min: 10,
2255
+ max: 10,
2256
+ pri: 0
2257
+ },
2258
+ {
2259
+ c: "TM",
2260
+ n: "Turkmenistan",
2261
+ d: "993",
2262
+ f: "XX XXXXXX",
2263
+ p: "8",
2264
+ min: 8,
2265
+ max: 8,
2266
+ pri: 0
2267
+ },
2268
+ {
2269
+ c: "TC",
2270
+ n: "Turks & Caicos Islands",
2271
+ d: "1",
2272
+ f: "XXX XXX XXXX",
2273
+ p: "1",
2274
+ min: 10,
2275
+ max: 10,
2276
+ pri: 20
2277
+ },
2278
+ {
2279
+ c: "TV",
2280
+ n: "Tuvalu",
2281
+ d: "688",
2282
+ f: "XX XXXX",
2283
+ p: null,
2284
+ min: 5,
2285
+ max: 7,
2286
+ pri: 0
2287
+ },
2288
+ {
2289
+ c: "VI",
2290
+ n: "U.S. Virgin Islands",
2291
+ d: "1",
2292
+ f: "XXX XXX XXXX",
2293
+ p: "1",
2294
+ min: 10,
2295
+ max: 10,
2296
+ pri: 24
2297
+ },
2298
+ {
2299
+ c: "UG",
2300
+ n: "Uganda",
2301
+ d: "256",
2302
+ f: "XXX XXXXXX",
2303
+ p: "0",
2304
+ min: 9,
2305
+ max: 9,
2306
+ pri: 0
2307
+ },
2308
+ {
2309
+ c: "UA",
2310
+ n: "Ukraine",
2311
+ d: "380",
2312
+ f: "XX XXX XXXX",
2313
+ p: "0",
2314
+ min: 9,
2315
+ max: 9,
2316
+ pri: 0
2317
+ },
2318
+ {
2319
+ c: "AE",
2320
+ n: "United Arab Emirates",
2321
+ d: "971",
2322
+ f: "XX XXX XXXX",
2323
+ p: "0",
2324
+ min: 8,
2325
+ max: 9,
2326
+ pri: 0
2327
+ },
2328
+ {
2329
+ c: "GB",
2330
+ n: "United Kingdom",
2331
+ d: "44",
2332
+ f: "XXXX XXXXXX",
2333
+ p: "0",
2334
+ min: 9,
2335
+ max: 10,
2336
+ pri: 0
2337
+ },
2338
+ {
2339
+ c: "US",
2340
+ n: "United States",
2341
+ d: "1",
2342
+ f: "XXX XXX XXXX",
2343
+ p: "1",
2344
+ min: 10,
2345
+ max: 10,
2346
+ pri: 0
2347
+ },
2348
+ {
2349
+ c: "UY",
2350
+ n: "Uruguay",
2351
+ d: "598",
2352
+ f: "XX XXX XXX",
2353
+ p: "0",
2354
+ min: 8,
2355
+ max: 8,
2356
+ pri: 0
2357
+ },
2358
+ {
2359
+ c: "UZ",
2360
+ n: "Uzbekistan",
2361
+ d: "998",
2362
+ f: "XX XXX XX XX",
2363
+ p: null,
2364
+ min: 9,
2365
+ max: 9,
2366
+ pri: 0
2367
+ },
2368
+ {
2369
+ c: "VU",
2370
+ n: "Vanuatu",
2371
+ d: "678",
2372
+ f: "XXX XXXX",
2373
+ p: null,
2374
+ min: 5,
2375
+ max: 7,
2376
+ pri: 0
2377
+ },
2378
+ {
2379
+ c: "VA",
2380
+ n: "Vatican City",
2381
+ d: "39",
2382
+ f: "XXX XXX XXXX",
2383
+ p: null,
2384
+ min: 6,
2385
+ max: 11,
2386
+ pri: 1
2387
+ },
2388
+ {
2389
+ c: "VE",
2390
+ n: "Venezuela",
2391
+ d: "58",
2392
+ f: "XXX XXXXXXX",
2393
+ p: "0",
2394
+ min: 10,
2395
+ max: 10,
2396
+ pri: 0
2397
+ },
2398
+ {
2399
+ c: "VN",
2400
+ n: "Vietnam",
2401
+ d: "84",
2402
+ f: "XXX XXX XXX",
2403
+ p: "0",
2404
+ min: 9,
2405
+ max: 10,
2406
+ pri: 0
2407
+ },
2408
+ {
2409
+ c: "WF",
2410
+ n: "Wallis & Futuna",
2411
+ d: "681",
2412
+ f: "XX XX XX",
2413
+ p: null,
2414
+ min: 6,
2415
+ max: 6,
2416
+ pri: 0
2417
+ },
2418
+ {
2419
+ c: "EH",
2420
+ n: "Western Sahara",
2421
+ d: "212",
2422
+ f: "X XX XX XX XX",
2423
+ p: "0",
2424
+ min: 9,
2425
+ max: 9,
2426
+ pri: 1
2427
+ },
2428
+ {
2429
+ c: "YE",
2430
+ n: "Yemen",
2431
+ d: "967",
2432
+ f: "XXX XXX XXX",
2433
+ p: "0",
2434
+ min: 7,
2435
+ max: 9,
2436
+ pri: 0
2437
+ },
2438
+ {
2439
+ c: "ZM",
2440
+ n: "Zambia",
2441
+ d: "260",
2442
+ f: "XX XXXXXXX",
2443
+ p: "0",
2444
+ min: 9,
2445
+ max: 9,
2446
+ pri: 0
2447
+ },
2448
+ {
2449
+ c: "ZW",
2450
+ n: "Zimbabwe",
2451
+ d: "263",
2452
+ f: "XX XXX XXXX",
2453
+ p: "0",
2454
+ min: 5,
2455
+ max: 10,
2456
+ pri: 0
2457
+ }
2458
+ ];
2459
+
2460
+ // src/core/format.ts
2461
+ var TRAILING_SEP = /[\s\-]+$/;
2462
+ var FALLBACK_GROUP = /(.{4})(?=.)/g;
2463
+ var NON_ASCII_DIGITS = /[\u0660-\u0669\u06F0-\u06F9]/g;
2464
+ function isDigit(ch) {
2465
+ const c = ch.charCodeAt(0);
2466
+ return c >= 48 && c <= 57;
2467
+ }
2468
+ function formatPhone(digits, pattern) {
2469
+ if (!digits) return "";
2470
+ if (!pattern) {
2471
+ return digits.replace(FALLBACK_GROUP, "$1 ");
2472
+ }
2473
+ let result = "";
2474
+ let digitIndex = 0;
2475
+ for (const char of pattern) {
2476
+ if (digitIndex >= digits.length) break;
2477
+ if (char === "X") {
2478
+ result += digits[digitIndex++];
2479
+ } else {
2480
+ result += char;
2481
+ }
2482
+ }
2483
+ if (digitIndex < digits.length) {
2484
+ result += digits.slice(digitIndex);
2485
+ }
2486
+ return result.replace(TRAILING_SEP, "");
2487
+ }
2488
+ function getCursorPosition(oldValue, oldCursor, newValue) {
2489
+ let digitsBeforeCursor = 0;
2490
+ for (let i = 0; i < oldCursor && i < oldValue.length; i++) {
2491
+ if (isDigit(oldValue[i])) {
2492
+ digitsBeforeCursor++;
2493
+ }
2494
+ }
2495
+ let digitCount = 0;
2496
+ for (let i = 0; i < newValue.length; i++) {
2497
+ if (isDigit(newValue[i])) {
2498
+ digitCount++;
2499
+ }
2500
+ if (digitCount === digitsBeforeCursor) {
2501
+ return i + 1;
2502
+ }
2503
+ }
2504
+ return newValue.length;
2505
+ }
2506
+ function extractDigits(value) {
2507
+ return value.replace(/\D/g, "");
2508
+ }
2509
+ function normalizeNumerals(value) {
2510
+ return value.replace(NON_ASCII_DIGITS, (c) => {
2511
+ const code = c.charCodeAt(0);
2512
+ return code <= 1641 ? String(code - 1632) : String(code - 1776);
2513
+ });
2514
+ }
2515
+
2516
+ // src/core/countries.ts
2517
+ function getFlag(code) {
2518
+ return String.fromCodePoint(
2519
+ ...[...code.toUpperCase()].map((c) => 127462 + c.charCodeAt(0) - 65)
2520
+ );
2521
+ }
2522
+ function processCountryData(raw) {
2523
+ return raw.map((d) => ({
2524
+ code: d.c,
2525
+ name: d.n,
2526
+ dialCode: d.d,
2527
+ format: d.f,
2528
+ nationalPrefix: d.p,
2529
+ minLength: d.min,
2530
+ maxLength: d.max,
2531
+ priority: d.pri
2532
+ }));
2533
+ }
2534
+ function getCountryByCode(countries, code) {
2535
+ const upper = code.toUpperCase();
2536
+ return countries.find((c) => c.code === upper);
2537
+ }
2538
+ var _allCountries = null;
2539
+ function getAllCountries() {
2540
+ if (!_allCountries) _allCountries = processCountryData(phone_countries_default);
2541
+ return _allCountries;
2542
+ }
2543
+ function getCountryByDialCode(countries, dialCode) {
2544
+ let best;
2545
+ for (const c of countries) {
2546
+ if (c.dialCode !== dialCode) continue;
2547
+ if (!best || c.priority < best.priority) best = c;
2548
+ }
2549
+ return best;
2550
+ }
2551
+
2552
+ // src/core/validate.ts
2553
+ function validatePhone(digits, country) {
2554
+ const currentDigits = digits.length;
2555
+ const { minLength, maxLength } = country;
2556
+ if (currentDigits < minLength) {
2557
+ return {
2558
+ valid: false,
2559
+ reason: "too_short",
2560
+ minDigits: minLength,
2561
+ maxDigits: maxLength,
2562
+ currentDigits
2563
+ };
2564
+ }
2565
+ if (currentDigits > maxLength) {
2566
+ return {
2567
+ valid: false,
2568
+ reason: "too_long",
2569
+ minDigits: minLength,
2570
+ maxDigits: maxLength,
2571
+ currentDigits
2572
+ };
2573
+ }
2574
+ return {
2575
+ valid: true,
2576
+ minDigits: minLength,
2577
+ maxDigits: maxLength,
2578
+ currentDigits
2579
+ };
2580
+ }
2581
+
2582
+ // src/vanilla/dropdown.ts
2583
+ var nextId = 0;
2584
+ var Dropdown = class {
2585
+ constructor(options) {
2586
+ this.el = null;
2587
+ this.searchInput = null;
2588
+ this.listEl = null;
2589
+ this.liveRegion = null;
2590
+ this.highlightIndex = -1;
2591
+ this.filteredItems = [];
2592
+ this.orderedCountries = null;
2593
+ this.searchTimeout = null;
2594
+ this.ac = null;
2595
+ this.displayNames = null;
2596
+ this.options = options;
2597
+ this.id = nextId++;
2598
+ if (options.locale && typeof Intl?.DisplayNames === "function") {
2599
+ try {
2600
+ this.displayNames = new Intl.DisplayNames([options.locale], { type: "region" });
2601
+ } catch {
2602
+ }
2603
+ }
2604
+ }
2605
+ open(anchorEl) {
2606
+ if (this.el) return;
2607
+ this.ac = new AbortController();
2608
+ const signal = this.ac.signal;
2609
+ this.el = document.createElement("div");
2610
+ this.el.className = "lpi__dropdown";
2611
+ this.el.setAttribute("role", "dialog");
2612
+ this.el.setAttribute("aria-label", "Select country");
2613
+ this.searchInput = document.createElement("input");
2614
+ this.searchInput.className = "lpi__search";
2615
+ this.searchInput.type = "text";
2616
+ this.searchInput.setAttribute("role", "combobox");
2617
+ this.searchInput.setAttribute("aria-expanded", "true");
2618
+ this.searchInput.setAttribute("aria-controls", `lpi-list-${this.id}`);
2619
+ this.searchInput.setAttribute("aria-autocomplete", "list");
2620
+ this.searchInput.placeholder = "Search...";
2621
+ this.el.appendChild(this.searchInput);
2622
+ this.liveRegion = document.createElement("div");
2623
+ this.liveRegion.className = "lpi__sr-only";
2624
+ this.liveRegion.setAttribute("aria-live", "polite");
2625
+ this.el.appendChild(this.liveRegion);
2626
+ this.listEl = document.createElement("ul");
2627
+ this.listEl.className = "lpi__list";
2628
+ this.listEl.setAttribute("role", "listbox");
2629
+ this.listEl.id = `lpi-list-${this.id}`;
2630
+ this.el.appendChild(this.listEl);
2631
+ this.filteredItems = this.getOrderedCountries();
2632
+ this.buildList();
2633
+ this.options.container.appendChild(this.el);
2634
+ this.position(anchorEl);
2635
+ if (typeof window.matchMedia === "function" && window.matchMedia("(max-width: 500px), (pointer: coarse) and (max-height: 600px)").matches) {
2636
+ this.el.classList.add("lpi__dropdown--fullscreen");
2637
+ }
2638
+ this.searchInput.focus();
2639
+ const selectedIdx = this.filteredItems.findIndex((c) => c.code === this.options.selectedCode);
2640
+ if (selectedIdx >= 0) {
2641
+ this.updateHighlight(selectedIdx);
2642
+ }
2643
+ this.searchInput.addEventListener("input", () => this.handleSearchInput(), { signal });
2644
+ this.el.addEventListener("keydown", (e) => this.handleKeyDown(e), { signal });
2645
+ this.listEl.addEventListener("click", (e) => this.handleListClick(e), { signal });
2646
+ document.addEventListener("mousedown", (e) => this.handleClickOutside(e), { signal });
2647
+ this.setupScrollListeners(anchorEl, signal);
2648
+ }
2649
+ close() {
2650
+ if (!this.el) return;
2651
+ this.ac?.abort();
2652
+ this.ac = null;
2653
+ if (this.searchTimeout) {
2654
+ clearTimeout(this.searchTimeout);
2655
+ this.searchTimeout = null;
2656
+ }
2657
+ this.el.remove();
2658
+ this.el = null;
2659
+ this.searchInput = null;
2660
+ this.listEl = null;
2661
+ this.liveRegion = null;
2662
+ this.highlightIndex = -1;
2663
+ this.filteredItems = [];
2664
+ this.orderedCountries = null;
2665
+ }
2666
+ isOpen() {
2667
+ return this.el !== null;
2668
+ }
2669
+ setSelected(code) {
2670
+ const prevCode = this.options.selectedCode;
2671
+ this.options.selectedCode = code;
2672
+ if (this.listEl) {
2673
+ if (prevCode) {
2674
+ const oldEl = this.listEl.querySelector(`[data-code="${prevCode}"]`);
2675
+ if (oldEl) {
2676
+ oldEl.setAttribute("aria-selected", "false");
2677
+ oldEl.classList.remove("lpi__option--selected");
2678
+ }
2679
+ }
2680
+ const newEl = this.listEl.querySelector(`[data-code="${code}"]`);
2681
+ if (newEl) {
2682
+ newEl.setAttribute("aria-selected", "true");
2683
+ newEl.classList.add("lpi__option--selected");
2684
+ }
2685
+ }
2686
+ }
2687
+ updateCountries(countries, preferredCountries) {
2688
+ this.options.countries = countries;
2689
+ this.options.preferredCountries = preferredCountries;
2690
+ this.orderedCountries = null;
2691
+ }
2692
+ destroy() {
2693
+ this.close();
2694
+ }
2695
+ // --- Internal ---
2696
+ getOrderedCountries() {
2697
+ if (this.orderedCountries) return this.orderedCountries;
2698
+ const { countries, preferredCountries } = this.options;
2699
+ if (!preferredCountries.length) {
2700
+ this.orderedCountries = countries;
2701
+ return countries;
2702
+ }
2703
+ const prefSet = new Set(preferredCountries.map((c) => c.toUpperCase()));
2704
+ const preferred = [];
2705
+ const rest = [];
2706
+ for (const c of countries) {
2707
+ if (prefSet.has(c.code)) {
2708
+ preferred.push(c);
2709
+ } else {
2710
+ rest.push(c);
2711
+ }
2712
+ }
2713
+ preferred.sort((a, b) => {
2714
+ return preferredCountries.indexOf(a.code) - preferredCountries.indexOf(b.code);
2715
+ });
2716
+ this.orderedCountries = [...preferred, ...rest];
2717
+ return this.orderedCountries;
2718
+ }
2719
+ buildList() {
2720
+ if (!this.listEl) return;
2721
+ this.listEl.replaceChildren();
2722
+ const { preferredCountries, selectedCode } = this.options;
2723
+ const prefSet = preferredCountries.length > 0 ? new Set(preferredCountries.map((c) => c.toUpperCase())) : null;
2724
+ let addedSeparator = false;
2725
+ for (let i = 0; i < this.filteredItems.length; i++) {
2726
+ const country = this.filteredItems[i];
2727
+ if (!addedSeparator && prefSet && !prefSet.has(country.code)) {
2728
+ if (i > 0) {
2729
+ const sep = document.createElement("li");
2730
+ sep.className = "lpi__separator";
2731
+ sep.setAttribute("role", "separator");
2732
+ sep.innerHTML = "<hr>";
2733
+ this.listEl.appendChild(sep);
2734
+ }
2735
+ addedSeparator = true;
2736
+ }
2737
+ const li = document.createElement("li");
2738
+ li.className = "lpi__option";
2739
+ if (country.code === selectedCode) li.classList.add("lpi__option--selected");
2740
+ li.setAttribute("role", "option");
2741
+ li.setAttribute("aria-selected", country.code === selectedCode ? "true" : "false");
2742
+ li.dataset.code = country.code;
2743
+ li.id = `lpi-opt-${this.id}-${country.code}`;
2744
+ const flag = document.createElement("span");
2745
+ flag.className = "lpi__flag";
2746
+ if (this.options.renderFlag) {
2747
+ flag.innerHTML = this.options.renderFlag(country.code);
2748
+ } else {
2749
+ flag.textContent = getFlag(country.code);
2750
+ }
2751
+ const name = document.createElement("span");
2752
+ name.className = "lpi__option-name";
2753
+ name.textContent = this.getCountryName(country);
2754
+ const dial = document.createElement("span");
2755
+ dial.className = "lpi__option-dial";
2756
+ dial.textContent = `+${country.dialCode}`;
2757
+ li.appendChild(flag);
2758
+ li.appendChild(name);
2759
+ li.appendChild(dial);
2760
+ this.listEl.appendChild(li);
2761
+ }
2762
+ this.updateLiveRegion();
2763
+ }
2764
+ getCountryName(country) {
2765
+ if (this.displayNames) {
2766
+ try {
2767
+ return this.displayNames.of(country.code) ?? country.name;
2768
+ } catch {
2769
+ return country.name;
2770
+ }
2771
+ }
2772
+ return country.name;
2773
+ }
2774
+ /** 3-bucket search: exact code/dial → starts-with → contains */
2775
+ search(query) {
2776
+ if (!query) return this.getOrderedCountries();
2777
+ const q = query.trim().toLowerCase();
2778
+ const qUpper = q.toUpperCase();
2779
+ const ordered = this.getOrderedCountries();
2780
+ const exact = [];
2781
+ const startsWith = [];
2782
+ const contains = [];
2783
+ for (const c of ordered) {
2784
+ const name = this.getCountryName(c).toLowerCase();
2785
+ if (c.code === qUpper || c.dialCode === q) {
2786
+ exact.push(c);
2787
+ } else if (name.startsWith(q)) {
2788
+ startsWith.push(c);
2789
+ } else if (name.includes(q)) {
2790
+ contains.push(c);
2791
+ }
2792
+ }
2793
+ return [...exact, ...startsWith, ...contains];
2794
+ }
2795
+ handleSearchInput() {
2796
+ if (this.searchTimeout) clearTimeout(this.searchTimeout);
2797
+ this.searchTimeout = setTimeout(() => {
2798
+ const query = this.searchInput?.value ?? "";
2799
+ this.filteredItems = this.search(query);
2800
+ this.highlightIndex = -1;
2801
+ this.buildList();
2802
+ if (this.filteredItems.length > 0) {
2803
+ this.updateHighlight(0);
2804
+ }
2805
+ }, 100);
2806
+ }
2807
+ handleKeyDown(e) {
2808
+ switch (e.key) {
2809
+ case "ArrowDown":
2810
+ e.preventDefault();
2811
+ if (this.filteredItems.length > 0) {
2812
+ const next = this.highlightIndex < this.filteredItems.length - 1 ? this.highlightIndex + 1 : 0;
2813
+ this.updateHighlight(next);
2814
+ }
2815
+ break;
2816
+ case "ArrowUp":
2817
+ e.preventDefault();
2818
+ if (this.filteredItems.length > 0) {
2819
+ const prev = this.highlightIndex > 0 ? this.highlightIndex - 1 : this.filteredItems.length - 1;
2820
+ this.updateHighlight(prev);
2821
+ }
2822
+ break;
2823
+ case "Enter":
2824
+ e.preventDefault();
2825
+ if (this.highlightIndex >= 0 && this.highlightIndex < this.filteredItems.length) {
2826
+ this.options.onSelect(this.filteredItems[this.highlightIndex]);
2827
+ }
2828
+ break;
2829
+ case "Escape":
2830
+ e.preventDefault();
2831
+ this.options.onClose();
2832
+ break;
2833
+ case "Tab":
2834
+ this.options.onClose();
2835
+ break;
2836
+ }
2837
+ }
2838
+ handleListClick(e) {
2839
+ const target = e.target.closest(".lpi__option");
2840
+ if (!target?.dataset.code) return;
2841
+ const country = this.filteredItems.find((c) => c.code === target.dataset.code);
2842
+ if (country) this.options.onSelect(country);
2843
+ }
2844
+ handleClickOutside(e) {
2845
+ if (this.el && !this.el.contains(e.target)) {
2846
+ this.options.onClose();
2847
+ }
2848
+ }
2849
+ setupScrollListeners(anchorEl, signal) {
2850
+ let node = anchorEl.parentElement;
2851
+ while (node && node !== document.documentElement) {
2852
+ const ancestor = node;
2853
+ ancestor.addEventListener("scroll", () => {
2854
+ if (this.el && this.el.contains(ancestor)) return;
2855
+ this.options.onClose();
2856
+ }, { signal, passive: true });
2857
+ node = node.parentElement;
2858
+ }
2859
+ }
2860
+ position(anchorEl) {
2861
+ if (!this.el) return;
2862
+ const rect = anchorEl.getBoundingClientRect();
2863
+ const spaceBelow = window.innerHeight - rect.bottom;
2864
+ const spaceAbove = rect.top;
2865
+ const container = this.options.container;
2866
+ const isPortal = container === document.body;
2867
+ if (isPortal) {
2868
+ this.el.style.position = "absolute";
2869
+ const scrollTop = window.scrollY;
2870
+ const scrollLeft = window.scrollX;
2871
+ const dropdownHeight = Math.min(300, spaceAbove);
2872
+ if (spaceBelow >= 300 || spaceBelow >= spaceAbove) {
2873
+ this.el.style.top = `${rect.bottom + scrollTop}px`;
2874
+ this.el.style.left = `${rect.left + scrollLeft}px`;
2875
+ this.el.classList.remove("lpi__dropdown--above");
2876
+ } else {
2877
+ this.el.style.top = `${rect.top + scrollTop - dropdownHeight}px`;
2878
+ this.el.style.left = `${rect.left + scrollLeft}px`;
2879
+ this.el.classList.add("lpi__dropdown--above");
2880
+ }
2881
+ this.el.style.width = `${Math.max(rect.width, 280)}px`;
2882
+ } else {
2883
+ if (spaceBelow >= 300 || spaceBelow >= spaceAbove) {
2884
+ this.el.classList.remove("lpi__dropdown--above");
2885
+ } else {
2886
+ this.el.classList.add("lpi__dropdown--above");
2887
+ }
2888
+ }
2889
+ }
2890
+ updateHighlight(index) {
2891
+ if (!this.listEl || !this.searchInput) return;
2892
+ if (this.highlightIndex >= 0) {
2893
+ const oldItem = this.getOptionElement(this.highlightIndex);
2894
+ oldItem?.classList.remove("lpi__option--highlighted");
2895
+ }
2896
+ this.highlightIndex = index;
2897
+ const item = this.getOptionElement(index);
2898
+ if (item) {
2899
+ item.classList.add("lpi__option--highlighted");
2900
+ item.scrollIntoView?.({ block: "nearest" });
2901
+ this.searchInput.setAttribute("aria-activedescendant", item.id);
2902
+ }
2903
+ }
2904
+ getOptionElement(index) {
2905
+ if (!this.listEl) return null;
2906
+ const options = this.listEl.querySelectorAll(".lpi__option");
2907
+ return options[index] ?? null;
2908
+ }
2909
+ updateLiveRegion() {
2910
+ if (this.liveRegion) {
2911
+ const count = this.filteredItems.length;
2912
+ this.liveRegion.textContent = `${count} ${count === 1 ? "result" : "results"}`;
2913
+ }
2914
+ }
2915
+ };
2916
+
2917
+ // src/vanilla/phone-input.ts
2918
+ var isClient = typeof window !== "undefined";
2919
+ var PhoneInput = class _PhoneInput {
2920
+ constructor(el, options) {
2921
+ this.nationalDigits = "";
2922
+ this.lastValidation = null;
2923
+ this.dropdown = null;
2924
+ this.dialCodeEl = null;
2925
+ this.arrowEl = null;
2926
+ this.hiddenPhoneEl = null;
2927
+ this.hiddenCountryEl = null;
2928
+ this.el = el;
2929
+ this.opts = { ...options };
2930
+ this.ac = new AbortController();
2931
+ this.countries = this.filterCountries(getAllCountries());
2932
+ this.selectedCountry = this.resolveCountry(this.opts.defaultCountry) ?? this.countries[0];
2933
+ if (isClient) {
2934
+ this.buildDOM();
2935
+ this.attachListeners();
2936
+ if (this.opts.value) {
2937
+ this.setValueInternal(this.opts.value, false);
2938
+ }
2939
+ }
2940
+ }
2941
+ static mount(el, options) {
2942
+ return new _PhoneInput(el, options);
2943
+ }
2944
+ // --- Public API ---
2945
+ getValue() {
2946
+ if (!this.nationalDigits) return "";
2947
+ return `+${this.selectedCountry.dialCode}${this.nationalDigits}`;
2948
+ }
2949
+ getNationalNumber() {
2950
+ return this.nationalDigits;
2951
+ }
2952
+ getCountry() {
2953
+ return {
2954
+ code: this.selectedCountry.code,
2955
+ dialCode: this.selectedCountry.dialCode,
2956
+ name: this.selectedCountry.name
2957
+ };
2958
+ }
2959
+ setValue(e164) {
2960
+ this.setValueInternal(e164, true);
2961
+ }
2962
+ setCountry(code) {
2963
+ const country = this.resolveCountry(code);
2964
+ if (country) this.selectCountry(country, true);
2965
+ }
2966
+ isValid() {
2967
+ return this.validate().valid;
2968
+ }
2969
+ validate() {
2970
+ return validatePhone(this.nationalDigits, this.selectedCountry);
2971
+ }
2972
+ setOptions(opts) {
2973
+ const prev = { ...this.opts };
2974
+ Object.assign(this.opts, opts);
2975
+ if (opts.allowedCountries !== void 0 || opts.excludedCountries !== void 0) {
2976
+ this.countries = this.filterCountries(getAllCountries());
2977
+ if (!this.countries.find((c) => c.code === this.selectedCountry.code)) {
2978
+ this.selectCountry(this.countries[0], true);
2979
+ }
2980
+ if (this.dropdown) {
2981
+ this.dropdown.updateCountries(this.countries, this.opts.preferredCountries ?? []);
2982
+ }
2983
+ }
2984
+ if (opts.disabled !== void 0) {
2985
+ this.inputEl.disabled = !!opts.disabled;
2986
+ this.containerEl.classList.toggle("lpi--disabled", !!opts.disabled);
2987
+ if (this.triggerEl instanceof HTMLButtonElement) {
2988
+ this.triggerEl.disabled = !!opts.disabled;
2989
+ }
2990
+ }
2991
+ if (opts.separateDialCode !== void 0 && opts.separateDialCode !== prev.separateDialCode) {
2992
+ this.updateDisplayMode();
2993
+ }
2994
+ if (opts.renderFlag !== void 0) {
2995
+ this.updateFlag();
2996
+ }
2997
+ if (opts.placeholder !== void 0) {
2998
+ this.updatePlaceholder();
2999
+ }
3000
+ if (opts.formatAsYouType !== void 0 || opts.strict !== void 0) {
3001
+ this.reformatInput();
3002
+ }
3003
+ if (opts.allowDropdown !== void 0) {
3004
+ this.rebuildTrigger();
3005
+ }
3006
+ }
3007
+ destroy() {
3008
+ this.ac.abort();
3009
+ if (this.dropdown) {
3010
+ this.dropdown.destroy();
3011
+ this.dropdown = null;
3012
+ }
3013
+ this.el.innerHTML = "";
3014
+ }
3015
+ // --- DOM Construction ---
3016
+ buildDOM() {
3017
+ this.containerEl = document.createElement("div");
3018
+ this.containerEl.className = "lpi";
3019
+ if (this.opts.containerClass) {
3020
+ this.containerEl.className += ` ${this.opts.containerClass}`;
3021
+ }
3022
+ if (this.opts.separateDialCode) {
3023
+ this.containerEl.classList.add("lpi--separate-dial-code");
3024
+ }
3025
+ if (this.opts.disabled) {
3026
+ this.containerEl.classList.add("lpi--disabled");
3027
+ }
3028
+ this.buildTrigger();
3029
+ this.inputEl = document.createElement("input");
3030
+ this.inputEl.className = "lpi__input";
3031
+ this.inputEl.type = "tel";
3032
+ this.inputEl.inputMode = "tel";
3033
+ this.inputEl.autocomplete = "tel";
3034
+ this.inputEl.dir = "ltr";
3035
+ if (this.opts.disabled) this.inputEl.disabled = true;
3036
+ if (this.opts.inputAttributes) {
3037
+ for (const [key, value] of Object.entries(this.opts.inputAttributes)) {
3038
+ this.inputEl.setAttribute(key, value);
3039
+ }
3040
+ }
3041
+ this.updatePlaceholder();
3042
+ this.containerEl.appendChild(this.inputEl);
3043
+ if (this.opts.hiddenInput) {
3044
+ if (this.opts.hiddenInput.phone) {
3045
+ this.hiddenPhoneEl = document.createElement("input");
3046
+ this.hiddenPhoneEl.type = "hidden";
3047
+ this.hiddenPhoneEl.name = this.opts.hiddenInput.phone;
3048
+ this.containerEl.appendChild(this.hiddenPhoneEl);
3049
+ }
3050
+ if (this.opts.hiddenInput.country) {
3051
+ this.hiddenCountryEl = document.createElement("input");
3052
+ this.hiddenCountryEl.type = "hidden";
3053
+ this.hiddenCountryEl.name = this.opts.hiddenInput.country;
3054
+ this.hiddenCountryEl.value = this.selectedCountry.code;
3055
+ this.containerEl.appendChild(this.hiddenCountryEl);
3056
+ }
3057
+ }
3058
+ this.el.appendChild(this.containerEl);
3059
+ }
3060
+ buildTrigger() {
3061
+ const allowDropdown = this.opts.allowDropdown !== false;
3062
+ if (allowDropdown) {
3063
+ const btn = document.createElement("button");
3064
+ btn.className = "lpi__trigger";
3065
+ btn.type = "button";
3066
+ btn.setAttribute("role", "combobox");
3067
+ btn.setAttribute("aria-expanded", "false");
3068
+ btn.setAttribute("aria-haspopup", "listbox");
3069
+ btn.setAttribute("aria-label", "Select country");
3070
+ if (this.opts.disabled) btn.disabled = true;
3071
+ this.triggerEl = btn;
3072
+ } else {
3073
+ const span = document.createElement("span");
3074
+ span.className = "lpi__trigger";
3075
+ this.triggerEl = span;
3076
+ }
3077
+ this.flagEl = document.createElement("span");
3078
+ this.flagEl.className = "lpi__flag";
3079
+ this.updateFlag();
3080
+ this.triggerEl.appendChild(this.flagEl);
3081
+ if (this.opts.separateDialCode) {
3082
+ this.dialCodeEl = document.createElement("span");
3083
+ this.dialCodeEl.className = "lpi__dial-code";
3084
+ this.dialCodeEl.textContent = `+${this.selectedCountry.dialCode}`;
3085
+ this.triggerEl.appendChild(this.dialCodeEl);
3086
+ }
3087
+ if (allowDropdown) {
3088
+ this.arrowEl = document.createElement("span");
3089
+ this.arrowEl.className = "lpi__arrow";
3090
+ this.arrowEl.textContent = "\u25BC";
3091
+ this.triggerEl.appendChild(this.arrowEl);
3092
+ this.triggerEl.addEventListener("click", () => this.handleTriggerClick(), { signal: this.ac.signal });
3093
+ }
3094
+ this.containerEl.appendChild(this.triggerEl);
3095
+ }
3096
+ rebuildTrigger() {
3097
+ this.triggerEl.remove();
3098
+ this.dialCodeEl = null;
3099
+ this.arrowEl = null;
3100
+ this.buildTrigger();
3101
+ this.containerEl.insertBefore(this.triggerEl, this.inputEl);
3102
+ }
3103
+ // --- Event Handling ---
3104
+ attachListeners() {
3105
+ const signal = this.ac.signal;
3106
+ this.inputEl.addEventListener("input", (e) => this.handleInput(e), { signal });
3107
+ this.inputEl.addEventListener("keydown", (e) => this.handleKeyDown(e), { signal });
3108
+ this.inputEl.addEventListener("paste", (e) => this.handlePaste(e), { signal });
3109
+ }
3110
+ handleInput(e) {
3111
+ if (this.opts.strict !== false && e.data === "+" && this.opts.separateDialCode) {
3112
+ this.inputEl.value = this.inputEl.value.replace("+", "");
3113
+ }
3114
+ const oldCursor = this.inputEl.selectionStart ?? 0;
3115
+ let raw = normalizeNumerals(this.inputEl.value);
3116
+ if (this.opts.separateDialCode) {
3117
+ let digits = extractDigits(raw);
3118
+ digits = this.stripNationalPrefix(digits);
3119
+ if (this.opts.strict !== false && digits.length > this.selectedCountry.maxLength) {
3120
+ digits = digits.slice(0, this.selectedCountry.maxLength);
3121
+ }
3122
+ this.nationalDigits = digits;
3123
+ const formatted = this.opts.formatAsYouType !== false ? formatPhone(digits, this.selectedCountry.format) : digits;
3124
+ const newCursor = getCursorPosition(this.inputEl.value, oldCursor, formatted);
3125
+ this.inputEl.value = formatted;
3126
+ this.inputEl.setSelectionRange(newCursor, newCursor);
3127
+ } else {
3128
+ const digits = extractDigits(raw);
3129
+ const hasPlus = raw.startsWith("+");
3130
+ if (hasPlus && digits.length > 0) {
3131
+ this.detectCountryFromDigits(digits);
3132
+ }
3133
+ let national = this.extractNationalFromFull(digits, hasPlus);
3134
+ national = this.stripNationalPrefix(national);
3135
+ if (this.opts.strict !== false && national.length > this.selectedCountry.maxLength) {
3136
+ national = national.slice(0, this.selectedCountry.maxLength);
3137
+ }
3138
+ this.nationalDigits = national;
3139
+ const formatted = this.formatFullValue();
3140
+ const newCursor = getCursorPosition(this.inputEl.value, oldCursor, formatted);
3141
+ this.inputEl.value = formatted;
3142
+ this.inputEl.setSelectionRange(newCursor, newCursor);
3143
+ }
3144
+ this.syncHiddenInputs();
3145
+ this.fireCallbacks();
3146
+ }
3147
+ handleKeyDown(e) {
3148
+ if (this.opts.strict === false) return;
3149
+ if (e.key === "Backspace" || e.key === "Delete" || e.key === "Tab" || e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Home" || e.key === "End" || e.ctrlKey || e.metaKey) {
3150
+ return;
3151
+ }
3152
+ if (!this.opts.separateDialCode && e.key === "+" && this.inputEl.selectionStart === 0) {
3153
+ return;
3154
+ }
3155
+ if (e.key.length === 1 && !/\d/.test(e.key)) {
3156
+ const code = e.key.charCodeAt(0);
3157
+ if (!(code >= 1632 && code <= 1641 || code >= 1776 && code <= 1785)) {
3158
+ e.preventDefault();
3159
+ }
3160
+ }
3161
+ }
3162
+ handlePaste(e) {
3163
+ e.preventDefault();
3164
+ const text = e.clipboardData?.getData("text") ?? "";
3165
+ if (!text) return;
3166
+ const cleaned = normalizeNumerals(text);
3167
+ let digits = cleaned.replace(/[^\d]/g, "");
3168
+ const isInternational = cleaned.startsWith("+") || cleaned.startsWith("00");
3169
+ if (isInternational) {
3170
+ if (cleaned.startsWith("00")) {
3171
+ digits = digits.slice(2);
3172
+ }
3173
+ this.detectCountryFromDigits(digits);
3174
+ digits = this.extractNationalFromFull(digits, true);
3175
+ }
3176
+ digits = this.stripNationalPrefix(digits);
3177
+ if (this.opts.strict !== false && digits.length > this.selectedCountry.maxLength) {
3178
+ digits = digits.slice(0, this.selectedCountry.maxLength);
3179
+ }
3180
+ this.nationalDigits = digits;
3181
+ if (this.opts.separateDialCode) {
3182
+ this.inputEl.value = this.opts.formatAsYouType !== false ? formatPhone(this.nationalDigits, this.selectedCountry.format) : this.nationalDigits;
3183
+ } else {
3184
+ this.inputEl.value = this.formatFullValue();
3185
+ }
3186
+ this.syncHiddenInputs();
3187
+ this.fireCallbacks();
3188
+ }
3189
+ handleTriggerClick() {
3190
+ if (this.opts.allowDropdown === false) return;
3191
+ if (this.dropdown) {
3192
+ this.closeDropdown();
3193
+ } else {
3194
+ this.openDropdown();
3195
+ }
3196
+ }
3197
+ // --- Dropdown ---
3198
+ openDropdown() {
3199
+ if (this.dropdown) return;
3200
+ this.dropdown = new Dropdown({
3201
+ countries: this.countries,
3202
+ preferredCountries: this.opts.preferredCountries ?? [],
3203
+ selectedCode: this.selectedCountry.code,
3204
+ locale: this.opts.locale,
3205
+ renderFlag: this.opts.renderFlag,
3206
+ onSelect: (country) => {
3207
+ this.selectCountry(country, true);
3208
+ this.closeDropdown();
3209
+ this.inputEl.focus();
3210
+ },
3211
+ onClose: () => {
3212
+ this.closeDropdown();
3213
+ if (this.triggerEl instanceof HTMLButtonElement) {
3214
+ this.triggerEl.focus();
3215
+ }
3216
+ },
3217
+ container: this.opts.dropdownContainer ?? document.body
3218
+ });
3219
+ this.dropdown.open(this.triggerEl);
3220
+ this.containerEl.classList.add("lpi--open");
3221
+ if (this.triggerEl instanceof HTMLButtonElement) {
3222
+ this.triggerEl.setAttribute("aria-expanded", "true");
3223
+ }
3224
+ this.opts.onDropdownOpen?.();
3225
+ }
3226
+ closeDropdown() {
3227
+ if (!this.dropdown) return;
3228
+ this.dropdown.close();
3229
+ this.dropdown = null;
3230
+ this.containerEl.classList.remove("lpi--open");
3231
+ if (this.triggerEl instanceof HTMLButtonElement) {
3232
+ this.triggerEl.setAttribute("aria-expanded", "false");
3233
+ }
3234
+ this.opts.onDropdownClose?.();
3235
+ }
3236
+ // --- Country Logic ---
3237
+ selectCountry(country, fireEvent) {
3238
+ const prev = this.selectedCountry;
3239
+ this.selectedCountry = country;
3240
+ this.updateFlag();
3241
+ this.updateDialCodeDisplay();
3242
+ this.reformatInput();
3243
+ this.updatePlaceholder();
3244
+ this.syncHiddenInputs();
3245
+ if (this.dropdown) {
3246
+ this.dropdown.setSelected(country.code);
3247
+ }
3248
+ if (fireEvent && prev.code !== country.code) {
3249
+ this.opts.onCountryChange?.(country);
3250
+ this.fireCallbacks();
3251
+ }
3252
+ }
3253
+ detectCountryFromDigits(digits) {
3254
+ for (let len = Math.min(4, digits.length); len >= 1; len--) {
3255
+ const prefix = digits.slice(0, len);
3256
+ const match = getCountryByDialCode(this.countries, prefix);
3257
+ if (match) {
3258
+ if (this.selectedCountry.dialCode === prefix) return;
3259
+ this.selectCountry(match, true);
3260
+ return;
3261
+ }
3262
+ }
3263
+ }
3264
+ extractNationalFromFull(digits, hasInternationalPrefix) {
3265
+ if (!hasInternationalPrefix) return digits;
3266
+ const dc = this.selectedCountry.dialCode;
3267
+ if (digits.startsWith(dc)) {
3268
+ return digits.slice(dc.length);
3269
+ }
3270
+ return digits;
3271
+ }
3272
+ stripNationalPrefix(digits) {
3273
+ const prefix = this.selectedCountry.nationalPrefix;
3274
+ if (prefix && digits.startsWith(prefix)) {
3275
+ const remaining = digits.slice(prefix.length);
3276
+ if (remaining.length > 0) {
3277
+ return remaining;
3278
+ }
3279
+ }
3280
+ return digits;
3281
+ }
3282
+ // --- Display ---
3283
+ formatFullValue() {
3284
+ if (!this.nationalDigits) return "";
3285
+ const formatted = this.opts.formatAsYouType !== false ? formatPhone(this.nationalDigits, this.selectedCountry.format) : this.nationalDigits;
3286
+ return `+${this.selectedCountry.dialCode} ${formatted}`;
3287
+ }
3288
+ updateFlag() {
3289
+ if (!this.flagEl) return;
3290
+ if (this.opts.renderFlag) {
3291
+ this.flagEl.innerHTML = this.opts.renderFlag(this.selectedCountry.code);
3292
+ } else {
3293
+ this.flagEl.textContent = getFlag(this.selectedCountry.code);
3294
+ }
3295
+ }
3296
+ updateDialCodeDisplay() {
3297
+ if (this.dialCodeEl) {
3298
+ this.dialCodeEl.textContent = `+${this.selectedCountry.dialCode}`;
3299
+ }
3300
+ }
3301
+ updatePlaceholder() {
3302
+ if (!this.inputEl) return;
3303
+ const placeholder = this.opts.placeholder;
3304
+ if (placeholder === "auto" || placeholder === void 0) {
3305
+ const mask = this.selectedCountry.format;
3306
+ if (mask) {
3307
+ const example = mask.replace(/X/g, "0");
3308
+ if (this.opts.separateDialCode) {
3309
+ this.inputEl.placeholder = example;
3310
+ } else {
3311
+ this.inputEl.placeholder = `+${this.selectedCountry.dialCode} ${example}`;
3312
+ }
3313
+ } else {
3314
+ this.inputEl.placeholder = "";
3315
+ }
3316
+ } else if (placeholder) {
3317
+ this.inputEl.placeholder = placeholder;
3318
+ } else {
3319
+ this.inputEl.placeholder = "";
3320
+ }
3321
+ }
3322
+ updateDisplayMode() {
3323
+ this.containerEl.classList.toggle("lpi--separate-dial-code", !!this.opts.separateDialCode);
3324
+ if (this.opts.separateDialCode && !this.dialCodeEl) {
3325
+ this.dialCodeEl = document.createElement("span");
3326
+ this.dialCodeEl.className = "lpi__dial-code";
3327
+ this.dialCodeEl.textContent = `+${this.selectedCountry.dialCode}`;
3328
+ if (this.arrowEl) {
3329
+ this.triggerEl.insertBefore(this.dialCodeEl, this.arrowEl);
3330
+ } else {
3331
+ this.triggerEl.appendChild(this.dialCodeEl);
3332
+ }
3333
+ } else if (!this.opts.separateDialCode && this.dialCodeEl) {
3334
+ this.dialCodeEl.remove();
3335
+ this.dialCodeEl = null;
3336
+ }
3337
+ this.reformatInput();
3338
+ this.updatePlaceholder();
3339
+ }
3340
+ reformatInput() {
3341
+ if (!this.inputEl) return;
3342
+ if (this.opts.separateDialCode) {
3343
+ this.inputEl.value = this.opts.formatAsYouType !== false ? formatPhone(this.nationalDigits, this.selectedCountry.format) : this.nationalDigits;
3344
+ } else {
3345
+ this.inputEl.value = this.formatFullValue();
3346
+ }
3347
+ }
3348
+ // --- Helpers ---
3349
+ filterCountries(all) {
3350
+ let filtered = all;
3351
+ if (this.opts.allowedCountries?.length) {
3352
+ const allowed = new Set(this.opts.allowedCountries.map((c) => c.toUpperCase()));
3353
+ filtered = filtered.filter((c) => allowed.has(c.code));
3354
+ }
3355
+ if (this.opts.excludedCountries?.length) {
3356
+ const excluded = new Set(this.opts.excludedCountries.map((c) => c.toUpperCase()));
3357
+ filtered = filtered.filter((c) => !excluded.has(c.code));
3358
+ }
3359
+ return filtered;
3360
+ }
3361
+ resolveCountry(code) {
3362
+ return getCountryByCode(this.countries, code);
3363
+ }
3364
+ setValueInternal(e164, updateInput) {
3365
+ if (!e164) {
3366
+ this.nationalDigits = "";
3367
+ if (updateInput) this.reformatInput();
3368
+ this.syncHiddenInputs();
3369
+ this.fireCallbacks();
3370
+ return;
3371
+ }
3372
+ let digits = extractDigits(normalizeNumerals(e164));
3373
+ const hasPlus = e164.startsWith("+");
3374
+ if (hasPlus) {
3375
+ this.detectCountryFromDigits(digits);
3376
+ digits = this.extractNationalFromFull(digits, true);
3377
+ }
3378
+ digits = this.stripNationalPrefix(digits);
3379
+ this.nationalDigits = digits;
3380
+ if (updateInput) this.reformatInput();
3381
+ this.syncHiddenInputs();
3382
+ this.fireCallbacks();
3383
+ }
3384
+ syncHiddenInputs() {
3385
+ if (this.hiddenPhoneEl) {
3386
+ this.hiddenPhoneEl.value = this.getValue();
3387
+ }
3388
+ if (this.hiddenCountryEl) {
3389
+ this.hiddenCountryEl.value = this.selectedCountry.code;
3390
+ }
3391
+ }
3392
+ fireCallbacks() {
3393
+ const v = validatePhone(this.nationalDigits, this.selectedCountry);
3394
+ const e164 = this.getValue();
3395
+ this.opts.onChange?.(e164, this.selectedCountry, v);
3396
+ if (this.lastValidation === null || v.valid !== this.lastValidation.valid) {
3397
+ this.opts.onValidationChange?.(v);
3398
+ }
3399
+ this.lastValidation = v;
3400
+ }
3401
+ };
3402
+
3403
+ // src/preact/PhoneInput.tsx
3404
+ var WIDGET_KEYS = /* @__PURE__ */ new Set([
3405
+ "defaultCountry",
3406
+ "allowedCountries",
3407
+ "excludedCountries",
3408
+ "preferredCountries",
3409
+ "allowDropdown",
3410
+ "formatAsYouType",
3411
+ "strict",
3412
+ "separateDialCode",
3413
+ "placeholder",
3414
+ "disabled",
3415
+ "locale",
3416
+ "renderFlag",
3417
+ "hiddenInput",
3418
+ "value",
3419
+ "containerClass",
3420
+ "dropdownContainer",
3421
+ "onChange",
3422
+ "onCountryChange",
3423
+ "onValidationChange",
3424
+ "onDropdownOpen",
3425
+ "onDropdownClose"
3426
+ ]);
3427
+ var DYNAMIC_OPTION_KEYS = [
3428
+ "disabled",
3429
+ "allowedCountries",
3430
+ "excludedCountries",
3431
+ "preferredCountries",
3432
+ "allowDropdown",
3433
+ "formatAsYouType",
3434
+ "strict",
3435
+ "separateDialCode",
3436
+ "placeholder",
3437
+ "locale",
3438
+ "renderFlag"
3439
+ ];
3440
+ function extractInputAttrs(props) {
3441
+ const attrs = {};
3442
+ for (const [key, val] of Object.entries(props)) {
3443
+ if (!WIDGET_KEYS.has(key) && key !== "class" && key !== "className" && val !== void 0) {
3444
+ attrs[key] = String(val);
3445
+ }
3446
+ }
3447
+ return attrs;
3448
+ }
3449
+ var PhoneInput2 = forwardRef(
3450
+ function PhoneInput3(props, ref) {
3451
+ const containerRef = useRef(null);
3452
+ const instanceRef = useRef(null);
3453
+ const propsRef = useRef(props);
3454
+ const prevValueRef = useRef(void 0);
3455
+ const prevOptsRef = useRef({});
3456
+ propsRef.current = props;
3457
+ useEffect(() => {
3458
+ if (!containerRef.current) return;
3459
+ const p = propsRef.current;
3460
+ const inputAttributes = extractInputAttrs(p);
3461
+ const options = {
3462
+ defaultCountry: p.defaultCountry,
3463
+ allowedCountries: p.allowedCountries,
3464
+ excludedCountries: p.excludedCountries,
3465
+ preferredCountries: p.preferredCountries,
3466
+ allowDropdown: p.allowDropdown,
3467
+ formatAsYouType: p.formatAsYouType,
3468
+ strict: p.strict,
3469
+ separateDialCode: p.separateDialCode,
3470
+ placeholder: p.placeholder,
3471
+ disabled: p.disabled,
3472
+ locale: p.locale,
3473
+ renderFlag: p.renderFlag,
3474
+ hiddenInput: p.hiddenInput,
3475
+ containerClass: p.containerClass,
3476
+ dropdownContainer: p.dropdownContainer,
3477
+ value: p.value,
3478
+ inputAttributes,
3479
+ onChange: (e164, country, validation) => propsRef.current.onChange?.(e164, country, validation),
3480
+ onCountryChange: (country) => propsRef.current.onCountryChange?.(country),
3481
+ onValidationChange: (validation) => propsRef.current.onValidationChange?.(validation),
3482
+ onDropdownOpen: () => propsRef.current.onDropdownOpen?.(),
3483
+ onDropdownClose: () => propsRef.current.onDropdownClose?.()
3484
+ };
3485
+ instanceRef.current = PhoneInput.mount(containerRef.current, options);
3486
+ return () => {
3487
+ instanceRef.current?.destroy();
3488
+ instanceRef.current = null;
3489
+ };
3490
+ }, []);
3491
+ useEffect(() => {
3492
+ if (!instanceRef.current) return;
3493
+ const instance = instanceRef.current;
3494
+ const opts = {};
3495
+ let hasChanges = false;
3496
+ for (const key of DYNAMIC_OPTION_KEYS) {
3497
+ if (props[key] !== void 0 && props[key] !== prevOptsRef.current[key]) {
3498
+ opts[key] = props[key];
3499
+ hasChanges = true;
3500
+ }
3501
+ }
3502
+ const currentOpts = {};
3503
+ for (const key of DYNAMIC_OPTION_KEYS) {
3504
+ currentOpts[key] = props[key];
3505
+ }
3506
+ prevOptsRef.current = currentOpts;
3507
+ opts.inputAttributes = extractInputAttrs(props);
3508
+ if (hasChanges) {
3509
+ instance.setOptions(opts);
3510
+ }
3511
+ if (props.value !== void 0 && props.value !== prevValueRef.current) {
3512
+ instance.setValue(props.value);
3513
+ }
3514
+ prevValueRef.current = props.value;
3515
+ });
3516
+ useImperativeHandle(ref, () => ({
3517
+ getValue: () => instanceRef.current?.getValue() ?? "",
3518
+ getNationalNumber: () => instanceRef.current?.getNationalNumber() ?? "",
3519
+ getCountry: () => instanceRef.current?.getCountry() ?? { code: "", dialCode: "", name: "" },
3520
+ setValue: (e164) => instanceRef.current?.setValue(e164),
3521
+ setCountry: (code) => instanceRef.current?.setCountry(code),
3522
+ isValid: () => instanceRef.current?.isValid() ?? false,
3523
+ validate: () => instanceRef.current?.validate() ?? {
3524
+ valid: false,
3525
+ minDigits: 0,
3526
+ maxDigits: 0,
3527
+ currentDigits: 0
3528
+ }
3529
+ }));
3530
+ return h("div", { ref: containerRef, class: props.class ?? props.className });
3531
+ }
3532
+ );
3533
+ export {
3534
+ PhoneInput2 as PhoneInput
3535
+ };
3536
+ //# sourceMappingURL=index.js.map