kilfx 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kilfx.cjs ADDED
@@ -0,0 +1,2055 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.js
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ KILFX_CSS: () => KILFX_CSS,
23
+ STYLE_ID: () => STYLE_ID,
24
+ autoInit: () => autoInit,
25
+ countriesData: () => countries_default,
26
+ default: () => index_default,
27
+ defaults: () => defaults,
28
+ ensureStylesInjected: () => ensureStylesInjected,
29
+ init: () => init2
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+
33
+ // src/data/countries.json
34
+ var countries_default = [
35
+ {
36
+ name: "Afghanistan",
37
+ dial_code: "+93",
38
+ code: "AF"
39
+ },
40
+ {
41
+ name: "Aland Islands",
42
+ dial_code: "+358",
43
+ code: "AX"
44
+ },
45
+ {
46
+ name: "Albania",
47
+ dial_code: "+355",
48
+ code: "AL"
49
+ },
50
+ {
51
+ name: "Algeria",
52
+ dial_code: "+213",
53
+ code: "DZ"
54
+ },
55
+ {
56
+ name: "AmericanSamoa",
57
+ dial_code: "+1 684",
58
+ code: "AS"
59
+ },
60
+ {
61
+ name: "Andorra",
62
+ dial_code: "+376",
63
+ code: "AD"
64
+ },
65
+ {
66
+ name: "Angola",
67
+ dial_code: "+244",
68
+ code: "AO"
69
+ },
70
+ {
71
+ name: "Anguilla",
72
+ dial_code: "+1 264",
73
+ code: "AI"
74
+ },
75
+ {
76
+ name: "Antarctica",
77
+ dial_code: "+672",
78
+ code: "AQ"
79
+ },
80
+ {
81
+ name: "Antigua and Barbuda",
82
+ dial_code: "+1268",
83
+ code: "AG"
84
+ },
85
+ {
86
+ name: "Argentina",
87
+ dial_code: "+54",
88
+ code: "AR"
89
+ },
90
+ {
91
+ name: "Armenia",
92
+ dial_code: "+374",
93
+ code: "AM"
94
+ },
95
+ {
96
+ name: "Aruba",
97
+ dial_code: "+297",
98
+ code: "AW"
99
+ },
100
+ {
101
+ name: "Australia",
102
+ dial_code: "+61",
103
+ code: "AU"
104
+ },
105
+ {
106
+ name: "Austria",
107
+ dial_code: "+43",
108
+ code: "AT"
109
+ },
110
+ {
111
+ name: "Azerbaijan",
112
+ dial_code: "+994",
113
+ code: "AZ"
114
+ },
115
+ {
116
+ name: "Bahamas",
117
+ dial_code: "+1 242",
118
+ code: "BS"
119
+ },
120
+ {
121
+ name: "Bahrain",
122
+ dial_code: "+973",
123
+ code: "BH"
124
+ },
125
+ {
126
+ name: "Bangladesh",
127
+ dial_code: "+880",
128
+ code: "BD"
129
+ },
130
+ {
131
+ name: "Barbados",
132
+ dial_code: "+1 246",
133
+ code: "BB"
134
+ },
135
+ {
136
+ name: "Belarus",
137
+ dial_code: "+375",
138
+ code: "BY"
139
+ },
140
+ {
141
+ name: "Belgium",
142
+ dial_code: "+32",
143
+ code: "BE"
144
+ },
145
+ {
146
+ name: "Belize",
147
+ dial_code: "+501",
148
+ code: "BZ"
149
+ },
150
+ {
151
+ name: "Benin",
152
+ dial_code: "+229",
153
+ code: "BJ"
154
+ },
155
+ {
156
+ name: "Bermuda",
157
+ dial_code: "+1 441",
158
+ code: "BM"
159
+ },
160
+ {
161
+ name: "Bhutan",
162
+ dial_code: "+975",
163
+ code: "BT"
164
+ },
165
+ {
166
+ name: "Bolivia, Plurinational State of",
167
+ dial_code: "+591",
168
+ code: "BO"
169
+ },
170
+ {
171
+ name: "Bosnia and Herzegovina",
172
+ dial_code: "+387",
173
+ code: "BA"
174
+ },
175
+ {
176
+ name: "Botswana",
177
+ dial_code: "+267",
178
+ code: "BW"
179
+ },
180
+ {
181
+ name: "Brazil",
182
+ dial_code: "+55",
183
+ code: "BR"
184
+ },
185
+ {
186
+ name: "British Indian Ocean Territory",
187
+ dial_code: "+246",
188
+ code: "IO"
189
+ },
190
+ {
191
+ name: "Brunei Darussalam",
192
+ dial_code: "+673",
193
+ code: "BN"
194
+ },
195
+ {
196
+ name: "Bulgaria",
197
+ dial_code: "+359",
198
+ code: "BG"
199
+ },
200
+ {
201
+ name: "Burkina Faso",
202
+ dial_code: "+226",
203
+ code: "BF"
204
+ },
205
+ {
206
+ name: "Burundi",
207
+ dial_code: "+257",
208
+ code: "BI"
209
+ },
210
+ {
211
+ name: "Cambodia",
212
+ dial_code: "+855",
213
+ code: "KH"
214
+ },
215
+ {
216
+ name: "Cameroon",
217
+ dial_code: "+237",
218
+ code: "CM"
219
+ },
220
+ {
221
+ name: "Canada",
222
+ dial_code: "+1",
223
+ code: "CA"
224
+ },
225
+ {
226
+ name: "Cape Verde",
227
+ dial_code: "+238",
228
+ code: "CV"
229
+ },
230
+ {
231
+ name: "Cayman Islands",
232
+ dial_code: "+ 345",
233
+ code: "KY"
234
+ },
235
+ {
236
+ name: "Central African Republic",
237
+ dial_code: "+236",
238
+ code: "CF"
239
+ },
240
+ {
241
+ name: "Chad",
242
+ dial_code: "+235",
243
+ code: "TD"
244
+ },
245
+ {
246
+ name: "Chile",
247
+ dial_code: "+56",
248
+ code: "CL"
249
+ },
250
+ {
251
+ name: "China",
252
+ dial_code: "+86",
253
+ code: "CN"
254
+ },
255
+ {
256
+ name: "Christmas Island",
257
+ dial_code: "+61",
258
+ code: "CX"
259
+ },
260
+ {
261
+ name: "Cocos (Keeling) Islands",
262
+ dial_code: "+61",
263
+ code: "CC"
264
+ },
265
+ {
266
+ name: "Colombia",
267
+ dial_code: "+57",
268
+ code: "CO"
269
+ },
270
+ {
271
+ name: "Comoros",
272
+ dial_code: "+269",
273
+ code: "KM"
274
+ },
275
+ {
276
+ name: "Congo",
277
+ dial_code: "+242",
278
+ code: "CG"
279
+ },
280
+ {
281
+ name: "Congo, The Democratic Republic of the Congo",
282
+ dial_code: "+243",
283
+ code: "CD"
284
+ },
285
+ {
286
+ name: "Cook Islands",
287
+ dial_code: "+682",
288
+ code: "CK"
289
+ },
290
+ {
291
+ name: "Costa Rica",
292
+ dial_code: "+506",
293
+ code: "CR"
294
+ },
295
+ {
296
+ name: "Cote d'Ivoire",
297
+ dial_code: "+225",
298
+ code: "CI"
299
+ },
300
+ {
301
+ name: "Croatia",
302
+ dial_code: "+385",
303
+ code: "HR"
304
+ },
305
+ {
306
+ name: "Cuba",
307
+ dial_code: "+53",
308
+ code: "CU"
309
+ },
310
+ {
311
+ name: "Cyprus",
312
+ dial_code: "+357",
313
+ code: "CY"
314
+ },
315
+ {
316
+ name: "Czech Republic",
317
+ dial_code: "+420",
318
+ code: "CZ"
319
+ },
320
+ {
321
+ name: "Denmark",
322
+ dial_code: "+45",
323
+ code: "DK"
324
+ },
325
+ {
326
+ name: "Djibouti",
327
+ dial_code: "+253",
328
+ code: "DJ"
329
+ },
330
+ {
331
+ name: "Dominica",
332
+ dial_code: "+1 767",
333
+ code: "DM"
334
+ },
335
+ {
336
+ name: "Dominican Republic",
337
+ dial_code: "+1 849",
338
+ code: "DO"
339
+ },
340
+ {
341
+ name: "Ecuador",
342
+ dial_code: "+593",
343
+ code: "EC"
344
+ },
345
+ {
346
+ name: "Egypt",
347
+ dial_code: "+20",
348
+ code: "EG"
349
+ },
350
+ {
351
+ name: "El Salvador",
352
+ dial_code: "+503",
353
+ code: "SV"
354
+ },
355
+ {
356
+ name: "Equatorial Guinea",
357
+ dial_code: "+240",
358
+ code: "GQ"
359
+ },
360
+ {
361
+ name: "Eritrea",
362
+ dial_code: "+291",
363
+ code: "ER"
364
+ },
365
+ {
366
+ name: "Estonia",
367
+ dial_code: "+372",
368
+ code: "EE"
369
+ },
370
+ {
371
+ name: "Ethiopia",
372
+ dial_code: "+251",
373
+ code: "ET"
374
+ },
375
+ {
376
+ name: "Falkland Islands (Malvinas)",
377
+ dial_code: "+500",
378
+ code: "FK"
379
+ },
380
+ {
381
+ name: "Faroe Islands",
382
+ dial_code: "+298",
383
+ code: "FO"
384
+ },
385
+ {
386
+ name: "Fiji",
387
+ dial_code: "+679",
388
+ code: "FJ"
389
+ },
390
+ {
391
+ name: "Finland",
392
+ dial_code: "+358",
393
+ code: "FI"
394
+ },
395
+ {
396
+ name: "France",
397
+ dial_code: "+33",
398
+ code: "FR"
399
+ },
400
+ {
401
+ name: "French Guiana",
402
+ dial_code: "+594",
403
+ code: "GF"
404
+ },
405
+ {
406
+ name: "French Polynesia",
407
+ dial_code: "+689",
408
+ code: "PF"
409
+ },
410
+ {
411
+ name: "Gabon",
412
+ dial_code: "+241",
413
+ code: "GA"
414
+ },
415
+ {
416
+ name: "Gambia",
417
+ dial_code: "+220",
418
+ code: "GM"
419
+ },
420
+ {
421
+ name: "Georgia",
422
+ dial_code: "+995",
423
+ code: "GE"
424
+ },
425
+ {
426
+ name: "Germany",
427
+ dial_code: "+49",
428
+ code: "DE"
429
+ },
430
+ {
431
+ name: "Ghana",
432
+ dial_code: "+233",
433
+ code: "GH"
434
+ },
435
+ {
436
+ name: "Gibraltar",
437
+ dial_code: "+350",
438
+ code: "GI"
439
+ },
440
+ {
441
+ name: "Greece",
442
+ dial_code: "+30",
443
+ code: "GR"
444
+ },
445
+ {
446
+ name: "Greenland",
447
+ dial_code: "+299",
448
+ code: "GL"
449
+ },
450
+ {
451
+ name: "Grenada",
452
+ dial_code: "+1 473",
453
+ code: "GD"
454
+ },
455
+ {
456
+ name: "Guadeloupe",
457
+ dial_code: "+590",
458
+ code: "GP"
459
+ },
460
+ {
461
+ name: "Guam",
462
+ dial_code: "+1 671",
463
+ code: "GU"
464
+ },
465
+ {
466
+ name: "Guatemala",
467
+ dial_code: "+502",
468
+ code: "GT"
469
+ },
470
+ {
471
+ name: "Guernsey",
472
+ dial_code: "+44",
473
+ code: "GG"
474
+ },
475
+ {
476
+ name: "Guinea",
477
+ dial_code: "+224",
478
+ code: "GN"
479
+ },
480
+ {
481
+ name: "Guinea-Bissau",
482
+ dial_code: "+245",
483
+ code: "GW"
484
+ },
485
+ {
486
+ name: "Guyana",
487
+ dial_code: "+595",
488
+ code: "GY"
489
+ },
490
+ {
491
+ name: "Haiti",
492
+ dial_code: "+509",
493
+ code: "HT"
494
+ },
495
+ {
496
+ name: "Holy See (Vatican City State)",
497
+ dial_code: "+379",
498
+ code: "VA"
499
+ },
500
+ {
501
+ name: "Honduras",
502
+ dial_code: "+504",
503
+ code: "HN"
504
+ },
505
+ {
506
+ name: "Hong Kong",
507
+ dial_code: "+852",
508
+ code: "HK"
509
+ },
510
+ {
511
+ name: "Hungary",
512
+ dial_code: "+36",
513
+ code: "HU"
514
+ },
515
+ {
516
+ name: "Iceland",
517
+ dial_code: "+354",
518
+ code: "IS"
519
+ },
520
+ {
521
+ name: "India",
522
+ dial_code: "+91",
523
+ code: "IN"
524
+ },
525
+ {
526
+ name: "Indonesia",
527
+ dial_code: "+62",
528
+ code: "ID"
529
+ },
530
+ {
531
+ name: "Iran, Islamic Republic of Persian Gulf",
532
+ dial_code: "+98",
533
+ code: "IR"
534
+ },
535
+ {
536
+ name: "Iraq",
537
+ dial_code: "+964",
538
+ code: "IQ"
539
+ },
540
+ {
541
+ name: "Ireland",
542
+ dial_code: "+353",
543
+ code: "IE"
544
+ },
545
+ {
546
+ name: "Isle of Man",
547
+ dial_code: "+44",
548
+ code: "IM"
549
+ },
550
+ {
551
+ name: "Israel",
552
+ dial_code: "+972",
553
+ code: "IL"
554
+ },
555
+ {
556
+ name: "Italy",
557
+ dial_code: "+39",
558
+ code: "IT"
559
+ },
560
+ {
561
+ name: "Jamaica",
562
+ dial_code: "+1 876",
563
+ code: "JM"
564
+ },
565
+ {
566
+ name: "Japan",
567
+ dial_code: "+81",
568
+ code: "JP"
569
+ },
570
+ {
571
+ name: "Jersey",
572
+ dial_code: "+44",
573
+ code: "JE"
574
+ },
575
+ {
576
+ name: "Jordan",
577
+ dial_code: "+962",
578
+ code: "JO"
579
+ },
580
+ {
581
+ name: "Kazakhstan",
582
+ dial_code: "+7 7",
583
+ code: "KZ"
584
+ },
585
+ {
586
+ name: "Kenya",
587
+ dial_code: "+254",
588
+ code: "KE"
589
+ },
590
+ {
591
+ name: "Kiribati",
592
+ dial_code: "+686",
593
+ code: "KI"
594
+ },
595
+ {
596
+ name: "Korea, Democratic People's Republic of Korea",
597
+ dial_code: "+850",
598
+ code: "KP"
599
+ },
600
+ {
601
+ name: "Korea, Republic of South Korea",
602
+ dial_code: "+82",
603
+ code: "KR"
604
+ },
605
+ {
606
+ name: "Kuwait",
607
+ dial_code: "+965",
608
+ code: "KW"
609
+ },
610
+ {
611
+ name: "Kyrgyzstan",
612
+ dial_code: "+996",
613
+ code: "KG"
614
+ },
615
+ {
616
+ name: "Laos",
617
+ dial_code: "+856",
618
+ code: "LA"
619
+ },
620
+ {
621
+ name: "Latvia",
622
+ dial_code: "+371",
623
+ code: "LV"
624
+ },
625
+ {
626
+ name: "Lebanon",
627
+ dial_code: "+961",
628
+ code: "LB"
629
+ },
630
+ {
631
+ name: "Lesotho",
632
+ dial_code: "+266",
633
+ code: "LS"
634
+ },
635
+ {
636
+ name: "Liberia",
637
+ dial_code: "+231",
638
+ code: "LR"
639
+ },
640
+ {
641
+ name: "Libyan Arab Jamahiriya",
642
+ dial_code: "+218",
643
+ code: "LY"
644
+ },
645
+ {
646
+ name: "Liechtenstein",
647
+ dial_code: "+423",
648
+ code: "LI"
649
+ },
650
+ {
651
+ name: "Lithuania",
652
+ dial_code: "+370",
653
+ code: "LT"
654
+ },
655
+ {
656
+ name: "Luxembourg",
657
+ dial_code: "+352",
658
+ code: "LU"
659
+ },
660
+ {
661
+ name: "Macao",
662
+ dial_code: "+853",
663
+ code: "MO"
664
+ },
665
+ {
666
+ name: "Macedonia",
667
+ dial_code: "+389",
668
+ code: "MK"
669
+ },
670
+ {
671
+ name: "Madagascar",
672
+ dial_code: "+261",
673
+ code: "MG"
674
+ },
675
+ {
676
+ name: "Malawi",
677
+ dial_code: "+265",
678
+ code: "MW"
679
+ },
680
+ {
681
+ name: "Malaysia",
682
+ dial_code: "+60",
683
+ code: "MY"
684
+ },
685
+ {
686
+ name: "Maldives",
687
+ dial_code: "+960",
688
+ code: "MV"
689
+ },
690
+ {
691
+ name: "Mali",
692
+ dial_code: "+223",
693
+ code: "ML"
694
+ },
695
+ {
696
+ name: "Malta",
697
+ dial_code: "+356",
698
+ code: "MT"
699
+ },
700
+ {
701
+ name: "Marshall Islands",
702
+ dial_code: "+692",
703
+ code: "MH"
704
+ },
705
+ {
706
+ name: "Martinique",
707
+ dial_code: "+596",
708
+ code: "MQ"
709
+ },
710
+ {
711
+ name: "Mauritania",
712
+ dial_code: "+222",
713
+ code: "MR"
714
+ },
715
+ {
716
+ name: "Mauritius",
717
+ dial_code: "+230",
718
+ code: "MU"
719
+ },
720
+ {
721
+ name: "Mayotte",
722
+ dial_code: "+262",
723
+ code: "YT"
724
+ },
725
+ {
726
+ name: "Mexico",
727
+ dial_code: "+52",
728
+ code: "MX"
729
+ },
730
+ {
731
+ name: "Micronesia, Federated States of Micronesia",
732
+ dial_code: "+691",
733
+ code: "FM"
734
+ },
735
+ {
736
+ name: "Moldova",
737
+ dial_code: "+373",
738
+ code: "MD"
739
+ },
740
+ {
741
+ name: "Monaco",
742
+ dial_code: "+377",
743
+ code: "MC"
744
+ },
745
+ {
746
+ name: "Mongolia",
747
+ dial_code: "+976",
748
+ code: "MN"
749
+ },
750
+ {
751
+ name: "Montenegro",
752
+ dial_code: "+382",
753
+ code: "ME"
754
+ },
755
+ {
756
+ name: "Montserrat",
757
+ dial_code: "+1664",
758
+ code: "MS"
759
+ },
760
+ {
761
+ name: "Morocco",
762
+ dial_code: "+212",
763
+ code: "MA"
764
+ },
765
+ {
766
+ name: "Mozambique",
767
+ dial_code: "+258",
768
+ code: "MZ"
769
+ },
770
+ {
771
+ name: "Myanmar",
772
+ dial_code: "+95",
773
+ code: "MM"
774
+ },
775
+ {
776
+ name: "Namibia",
777
+ dial_code: "+264",
778
+ code: "NA"
779
+ },
780
+ {
781
+ name: "Nauru",
782
+ dial_code: "+674",
783
+ code: "NR"
784
+ },
785
+ {
786
+ name: "Nepal",
787
+ dial_code: "+977",
788
+ code: "NP"
789
+ },
790
+ {
791
+ name: "Netherlands",
792
+ dial_code: "+31",
793
+ code: "NL"
794
+ },
795
+ {
796
+ name: "Netherlands Antilles",
797
+ dial_code: "+599",
798
+ code: "AN"
799
+ },
800
+ {
801
+ name: "New Caledonia",
802
+ dial_code: "+687",
803
+ code: "NC"
804
+ },
805
+ {
806
+ name: "New Zealand",
807
+ dial_code: "+64",
808
+ code: "NZ"
809
+ },
810
+ {
811
+ name: "Nicaragua",
812
+ dial_code: "+505",
813
+ code: "NI"
814
+ },
815
+ {
816
+ name: "Niger",
817
+ dial_code: "+227",
818
+ code: "NE"
819
+ },
820
+ {
821
+ name: "Nigeria",
822
+ dial_code: "+234",
823
+ code: "NG"
824
+ },
825
+ {
826
+ name: "Niue",
827
+ dial_code: "+683",
828
+ code: "NU"
829
+ },
830
+ {
831
+ name: "Norfolk Island",
832
+ dial_code: "+672",
833
+ code: "NF"
834
+ },
835
+ {
836
+ name: "Northern Mariana Islands",
837
+ dial_code: "+1 670",
838
+ code: "MP"
839
+ },
840
+ {
841
+ name: "Norway",
842
+ dial_code: "+47",
843
+ code: "NO"
844
+ },
845
+ {
846
+ name: "Oman",
847
+ dial_code: "+968",
848
+ code: "OM"
849
+ },
850
+ {
851
+ name: "Pakistan",
852
+ dial_code: "+92",
853
+ code: "PK"
854
+ },
855
+ {
856
+ name: "Palau",
857
+ dial_code: "+680",
858
+ code: "PW"
859
+ },
860
+ {
861
+ name: "Palestinian Territory, Occupied",
862
+ dial_code: "+970",
863
+ code: "PS"
864
+ },
865
+ {
866
+ name: "Panama",
867
+ dial_code: "+507",
868
+ code: "PA"
869
+ },
870
+ {
871
+ name: "Papua New Guinea",
872
+ dial_code: "+675",
873
+ code: "PG"
874
+ },
875
+ {
876
+ name: "Paraguay",
877
+ dial_code: "+595",
878
+ code: "PY"
879
+ },
880
+ {
881
+ name: "Peru",
882
+ dial_code: "+51",
883
+ code: "PE"
884
+ },
885
+ {
886
+ name: "Philippines",
887
+ dial_code: "+63",
888
+ code: "PH"
889
+ },
890
+ {
891
+ name: "Pitcairn",
892
+ dial_code: "+872",
893
+ code: "PN"
894
+ },
895
+ {
896
+ name: "Poland",
897
+ dial_code: "+48",
898
+ code: "PL"
899
+ },
900
+ {
901
+ name: "Portugal",
902
+ dial_code: "+351",
903
+ code: "PT"
904
+ },
905
+ {
906
+ name: "Puerto Rico",
907
+ dial_code: "+1 939",
908
+ code: "PR"
909
+ },
910
+ {
911
+ name: "Qatar",
912
+ dial_code: "+974",
913
+ code: "QA"
914
+ },
915
+ {
916
+ name: "Romania",
917
+ dial_code: "+40",
918
+ code: "RO"
919
+ },
920
+ {
921
+ name: "Russia",
922
+ dial_code: "+7",
923
+ code: "RU"
924
+ },
925
+ {
926
+ name: "Rwanda",
927
+ dial_code: "+250",
928
+ code: "RW"
929
+ },
930
+ {
931
+ name: "Reunion",
932
+ dial_code: "+262",
933
+ code: "RE"
934
+ },
935
+ {
936
+ name: "Saint Barthelemy",
937
+ dial_code: "+590",
938
+ code: "BL"
939
+ },
940
+ {
941
+ name: "Saint Helena, Ascension and Tristan Da Cunha",
942
+ dial_code: "+290",
943
+ code: "SH"
944
+ },
945
+ {
946
+ name: "Saint Kitts and Nevis",
947
+ dial_code: "+1 869",
948
+ code: "KN"
949
+ },
950
+ {
951
+ name: "Saint Lucia",
952
+ dial_code: "+1 758",
953
+ code: "LC"
954
+ },
955
+ {
956
+ name: "Saint Martin",
957
+ dial_code: "+590",
958
+ code: "MF"
959
+ },
960
+ {
961
+ name: "Saint Pierre and Miquelon",
962
+ dial_code: "+508",
963
+ code: "PM"
964
+ },
965
+ {
966
+ name: "Saint Vincent and the Grenadines",
967
+ dial_code: "+1 784",
968
+ code: "VC"
969
+ },
970
+ {
971
+ name: "Samoa",
972
+ dial_code: "+685",
973
+ code: "WS"
974
+ },
975
+ {
976
+ name: "San Marino",
977
+ dial_code: "+378",
978
+ code: "SM"
979
+ },
980
+ {
981
+ name: "Sao Tome and Principe",
982
+ dial_code: "+239",
983
+ code: "ST"
984
+ },
985
+ {
986
+ name: "Saudi Arabia",
987
+ dial_code: "+966",
988
+ code: "SA"
989
+ },
990
+ {
991
+ name: "Senegal",
992
+ dial_code: "+221",
993
+ code: "SN"
994
+ },
995
+ {
996
+ name: "Serbia",
997
+ dial_code: "+381",
998
+ code: "RS"
999
+ },
1000
+ {
1001
+ name: "Seychelles",
1002
+ dial_code: "+248",
1003
+ code: "SC"
1004
+ },
1005
+ {
1006
+ name: "Sierra Leone",
1007
+ dial_code: "+232",
1008
+ code: "SL"
1009
+ },
1010
+ {
1011
+ name: "Singapore",
1012
+ dial_code: "+65",
1013
+ code: "SG"
1014
+ },
1015
+ {
1016
+ name: "Slovakia",
1017
+ dial_code: "+421",
1018
+ code: "SK"
1019
+ },
1020
+ {
1021
+ name: "Slovenia",
1022
+ dial_code: "+386",
1023
+ code: "SI"
1024
+ },
1025
+ {
1026
+ name: "Solomon Islands",
1027
+ dial_code: "+677",
1028
+ code: "SB"
1029
+ },
1030
+ {
1031
+ name: "Somalia",
1032
+ dial_code: "+252",
1033
+ code: "SO"
1034
+ },
1035
+ {
1036
+ name: "South Africa",
1037
+ dial_code: "+27",
1038
+ code: "ZA"
1039
+ },
1040
+ {
1041
+ name: "South Georgia and the South Sandwich Islands",
1042
+ dial_code: "+500",
1043
+ code: "GS"
1044
+ },
1045
+ {
1046
+ name: "Spain",
1047
+ dial_code: "+34",
1048
+ code: "ES"
1049
+ },
1050
+ {
1051
+ name: "Sri Lanka",
1052
+ dial_code: "+94",
1053
+ code: "LK"
1054
+ },
1055
+ {
1056
+ name: "Sudan",
1057
+ dial_code: "+249",
1058
+ code: "SD"
1059
+ },
1060
+ {
1061
+ name: "Suriname",
1062
+ dial_code: "+597",
1063
+ code: "SR"
1064
+ },
1065
+ {
1066
+ name: "Svalbard and Jan Mayen",
1067
+ dial_code: "+47",
1068
+ code: "SJ"
1069
+ },
1070
+ {
1071
+ name: "Swaziland",
1072
+ dial_code: "+268",
1073
+ code: "SZ"
1074
+ },
1075
+ {
1076
+ name: "Sweden",
1077
+ dial_code: "+46",
1078
+ code: "SE"
1079
+ },
1080
+ {
1081
+ name: "Switzerland",
1082
+ dial_code: "+41",
1083
+ code: "CH"
1084
+ },
1085
+ {
1086
+ name: "Syrian Arab Republic",
1087
+ dial_code: "+963",
1088
+ code: "SY"
1089
+ },
1090
+ {
1091
+ name: "Taiwan",
1092
+ dial_code: "+886",
1093
+ code: "TW"
1094
+ },
1095
+ {
1096
+ name: "Tajikistan",
1097
+ dial_code: "+992",
1098
+ code: "TJ"
1099
+ },
1100
+ {
1101
+ name: "Tanzania, United Republic of Tanzania",
1102
+ dial_code: "+255",
1103
+ code: "TZ"
1104
+ },
1105
+ {
1106
+ name: "Thailand",
1107
+ dial_code: "+66",
1108
+ code: "TH"
1109
+ },
1110
+ {
1111
+ name: "Timor-Leste",
1112
+ dial_code: "+670",
1113
+ code: "TL"
1114
+ },
1115
+ {
1116
+ name: "Togo",
1117
+ dial_code: "+228",
1118
+ code: "TG"
1119
+ },
1120
+ {
1121
+ name: "Tokelau",
1122
+ dial_code: "+690",
1123
+ code: "TK"
1124
+ },
1125
+ {
1126
+ name: "Tonga",
1127
+ dial_code: "+676",
1128
+ code: "TO"
1129
+ },
1130
+ {
1131
+ name: "Trinidad and Tobago",
1132
+ dial_code: "+1 868",
1133
+ code: "TT"
1134
+ },
1135
+ {
1136
+ name: "Tunisia",
1137
+ dial_code: "+216",
1138
+ code: "TN"
1139
+ },
1140
+ {
1141
+ name: "Turkey",
1142
+ dial_code: "+90",
1143
+ code: "TR"
1144
+ },
1145
+ {
1146
+ name: "Turkmenistan",
1147
+ dial_code: "+993",
1148
+ code: "TM"
1149
+ },
1150
+ {
1151
+ name: "Turks and Caicos Islands",
1152
+ dial_code: "+1 649",
1153
+ code: "TC"
1154
+ },
1155
+ {
1156
+ name: "Tuvalu",
1157
+ dial_code: "+688",
1158
+ code: "TV"
1159
+ },
1160
+ {
1161
+ name: "Uganda",
1162
+ dial_code: "+256",
1163
+ code: "UG"
1164
+ },
1165
+ {
1166
+ name: "Ukraine",
1167
+ dial_code: "+380",
1168
+ code: "UA"
1169
+ },
1170
+ {
1171
+ name: "United Arab Emirates",
1172
+ dial_code: "+971",
1173
+ code: "AE"
1174
+ },
1175
+ {
1176
+ name: "United Kingdom",
1177
+ dial_code: "+44",
1178
+ code: "GB"
1179
+ },
1180
+ {
1181
+ name: "United States",
1182
+ dial_code: "+1",
1183
+ code: "US"
1184
+ },
1185
+ {
1186
+ name: "Uruguay",
1187
+ dial_code: "+598",
1188
+ code: "UY"
1189
+ },
1190
+ {
1191
+ name: "Uzbekistan",
1192
+ dial_code: "+998",
1193
+ code: "UZ"
1194
+ },
1195
+ {
1196
+ name: "Vanuatu",
1197
+ dial_code: "+678",
1198
+ code: "VU"
1199
+ },
1200
+ {
1201
+ name: "Venezuela, Bolivarian Republic of Venezuela",
1202
+ dial_code: "+58",
1203
+ code: "VE"
1204
+ },
1205
+ {
1206
+ name: "Vietnam",
1207
+ dial_code: "+84",
1208
+ code: "VN"
1209
+ },
1210
+ {
1211
+ name: "Virgin Islands, British",
1212
+ dial_code: "+1 284",
1213
+ code: "VG"
1214
+ },
1215
+ {
1216
+ name: "Virgin Islands, U.S.",
1217
+ dial_code: "+1 340",
1218
+ code: "VI"
1219
+ },
1220
+ {
1221
+ name: "Wallis and Futuna",
1222
+ dial_code: "+681",
1223
+ code: "WF"
1224
+ },
1225
+ {
1226
+ name: "Yemen",
1227
+ dial_code: "+967",
1228
+ code: "YE"
1229
+ },
1230
+ {
1231
+ name: "Zambia",
1232
+ dial_code: "+260",
1233
+ code: "ZM"
1234
+ },
1235
+ {
1236
+ name: "Zimbabwe",
1237
+ dial_code: "+263",
1238
+ code: "ZW"
1239
+ }
1240
+ ];
1241
+
1242
+ // src/styles.js
1243
+ var STYLE_ID = "kilfx-styles";
1244
+ var KILFX_CSS = `
1245
+ .kilfx {
1246
+ --kilfx-bg: #fff;
1247
+ --kilfx-fg: #111;
1248
+ --kilfx-border: rgba(0, 0, 0, 0.15);
1249
+ --kilfx-radius: 10px;
1250
+ --kilfx-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
1251
+ --kilfx-focus: rgba(59, 130, 246, 0.4);
1252
+ --kilfx-item-hover: rgba(0, 0, 0, 0.06);
1253
+
1254
+ display: grid;
1255
+ gap: 0.625rem;
1256
+ }
1257
+
1258
+ .kilfx.kilfx--inline {
1259
+ display: inline-grid;
1260
+ }
1261
+
1262
+ .kilfx .kilfx__field {
1263
+ position: relative;
1264
+ width: 100%;
1265
+ }
1266
+
1267
+ .kilfx.kilfx--enhanced select.kilfx__native {
1268
+ position: absolute;
1269
+ width: 1px;
1270
+ height: 1px;
1271
+ opacity: 0;
1272
+ pointer-events: none;
1273
+ border: 0;
1274
+ padding: 0;
1275
+ margin: 0;
1276
+ }
1277
+
1278
+ .kilfx .kilfx__trigger {
1279
+ width: 100%;
1280
+ min-height: 2.4rem;
1281
+ display: flex;
1282
+ align-items: center;
1283
+ gap: 0.625rem;
1284
+ border: 1px solid var(--kilfx-border);
1285
+ border-radius: var(--kilfx-radius);
1286
+ background: var(--kilfx-bg);
1287
+ color: var(--kilfx-fg);
1288
+ padding: 0.5rem 0.625rem;
1289
+ font: inherit;
1290
+ line-height: 1.2;
1291
+ cursor: pointer;
1292
+ text-align: left;
1293
+ box-sizing: border-box;
1294
+ }
1295
+
1296
+ .kilfx .kilfx__trigger:focus-visible,
1297
+ .kilfx .kilfx__search:focus-visible {
1298
+ outline: 2px solid var(--kilfx-focus);
1299
+ outline-offset: 1px;
1300
+ }
1301
+
1302
+ .kilfx .kilfx__label {
1303
+ flex: 1;
1304
+ overflow: hidden;
1305
+ text-overflow: ellipsis;
1306
+ white-space: nowrap;
1307
+ }
1308
+
1309
+ .kilfx .kilfx__caret {
1310
+ width: 0.55rem;
1311
+ height: 0.55rem;
1312
+ border-right: 2px solid currentColor;
1313
+ border-bottom: 2px solid currentColor;
1314
+ transform: rotate(45deg);
1315
+ opacity: 0.75;
1316
+ margin-right: 0.125rem;
1317
+ }
1318
+
1319
+ .kilfx .kilfx__field.kilfx__field--open .kilfx__caret {
1320
+ transform: rotate(-135deg);
1321
+ margin-top: 0.25rem;
1322
+ }
1323
+
1324
+ .kilfx .kilfx__menu {
1325
+ position: absolute;
1326
+ top: calc(100% + 0.35rem);
1327
+ left: 0;
1328
+ right: 0;
1329
+ z-index: 999;
1330
+ border: 1px solid var(--kilfx-border);
1331
+ border-radius: var(--kilfx-radius);
1332
+ background: var(--kilfx-bg);
1333
+ color: var(--kilfx-fg);
1334
+ box-shadow: var(--kilfx-shadow);
1335
+ overflow: hidden;
1336
+ }
1337
+
1338
+ .kilfx .kilfx__field.kilfx__field--up .kilfx__menu {
1339
+ top: auto;
1340
+ bottom: calc(100% + 0.35rem);
1341
+ }
1342
+
1343
+ .kilfx .kilfx__search-wrap {
1344
+ padding: 0.45rem;
1345
+ border-bottom: 1px solid var(--kilfx-border);
1346
+ }
1347
+
1348
+ .kilfx .kilfx__search {
1349
+ width: 100%;
1350
+ min-height: 2.25rem;
1351
+ border: 1px solid var(--kilfx-border);
1352
+ border-radius: calc(var(--kilfx-radius) * 0.7);
1353
+ background: var(--kilfx-bg);
1354
+ color: var(--kilfx-fg);
1355
+ padding: 0.45rem 0.55rem;
1356
+ font: inherit;
1357
+ box-sizing: border-box;
1358
+ }
1359
+
1360
+ .kilfx .kilfx__list {
1361
+ max-height: 15rem;
1362
+ overflow: auto;
1363
+ }
1364
+
1365
+ .kilfx .kilfx__item {
1366
+ min-height: 2.35rem;
1367
+ display: flex;
1368
+ align-items: center;
1369
+ gap: 0.625rem;
1370
+ width: 100%;
1371
+ border: 0;
1372
+ background: transparent;
1373
+ color: inherit;
1374
+ text-align: left;
1375
+ padding: 0.5rem 0.625rem;
1376
+ cursor: pointer;
1377
+ font: inherit;
1378
+ }
1379
+
1380
+ .kilfx .kilfx__item:hover,
1381
+ .kilfx .kilfx__item.kilfx__item--active {
1382
+ background: var(--kilfx-item-hover);
1383
+ }
1384
+
1385
+ .kilfx .kilfx__item.kilfx__item--selected .kilfx__item-label::after {
1386
+ content: " \u2713";
1387
+ opacity: 0.75;
1388
+ }
1389
+
1390
+ .kilfx .kilfx__empty {
1391
+ padding: 0.75rem;
1392
+ opacity: 0.7;
1393
+ }
1394
+
1395
+ .kilfx .kilfx__flag {
1396
+ width: 1.1rem;
1397
+ height: 1.1rem;
1398
+ min-width: 1.1rem;
1399
+ border-radius: 50%;
1400
+ display: inline-flex;
1401
+ align-items: center;
1402
+ justify-content: center;
1403
+ overflow: hidden;
1404
+ border: 1px solid var(--kilfx-border);
1405
+ background: var(--kilfx-bg);
1406
+ font-size: 0.6rem;
1407
+ text-transform: uppercase;
1408
+ }
1409
+
1410
+ .kilfx .kilfx__flag-image {
1411
+ width: 100%;
1412
+ height: 100%;
1413
+ object-fit: cover;
1414
+ display: none;
1415
+ }
1416
+
1417
+ .kilfx .kilfx__flag.kilfx__flag--loaded .kilfx__flag-image {
1418
+ display: block;
1419
+ }
1420
+
1421
+ .kilfx .kilfx__flag.kilfx__flag--loaded .kilfx__flag-fallback {
1422
+ display: none;
1423
+ }
1424
+
1425
+ .kilfx .kilfx__rate[readonly] {
1426
+ cursor: default;
1427
+ }
1428
+
1429
+ @media (max-width: 640px) {
1430
+ .kilfx .kilfx__trigger,
1431
+ .kilfx .kilfx__item,
1432
+ .kilfx .kilfx__search {
1433
+ min-height: 2.35rem;
1434
+ }
1435
+ }
1436
+ `;
1437
+ function ensureStylesInjected() {
1438
+ if (typeof document === "undefined") return;
1439
+ if (document.getElementById(STYLE_ID)) return;
1440
+ const style = document.createElement("style");
1441
+ style.id = STYLE_ID;
1442
+ style.textContent = KILFX_CSS;
1443
+ document.head.appendChild(style);
1444
+ }
1445
+
1446
+ // src/dom.js
1447
+ var DEFAULTS = {
1448
+ rootSelector: ".kilfx",
1449
+ baseName: "kilfx_base",
1450
+ toName: "kilfx_to",
1451
+ rateName: "fx_rate",
1452
+ flagsPath: "/svg",
1453
+ fileCase: "auto",
1454
+ enableSearch: true,
1455
+ defaultBase: "JM",
1456
+ defaultTo: "JM",
1457
+ initCountry: null,
1458
+ only: null,
1459
+ onlyBase: null,
1460
+ onlyTo: null,
1461
+ data: null
1462
+ };
1463
+ var ROOT_INSTANCES = /* @__PURE__ */ new WeakMap();
1464
+ var OPEN_DROPDOWN = null;
1465
+ var GLOBAL_EVENTS_BOUND = false;
1466
+ var UID = 0;
1467
+ function nextUid(prefix) {
1468
+ UID += 1;
1469
+ return `${prefix}-${UID}`;
1470
+ }
1471
+ function normalizeCode(input) {
1472
+ if (!input) return "";
1473
+ return String(input).trim().toUpperCase();
1474
+ }
1475
+ function parseCodeList(input) {
1476
+ if (!input) return [];
1477
+ const raw = Array.isArray(input) ? input : String(input).split(/[,\s]+/);
1478
+ const seen = /* @__PURE__ */ new Set();
1479
+ const out = [];
1480
+ for (const token of raw) {
1481
+ const value = normalizeCode(String(token).replace(/['"]/g, ""));
1482
+ if (!value || seen.has(value)) continue;
1483
+ seen.add(value);
1484
+ out.push(value);
1485
+ }
1486
+ return out;
1487
+ }
1488
+ function pickFirst(...values) {
1489
+ for (const value of values) {
1490
+ if (value !== void 0 && value !== null && value !== "") return value;
1491
+ }
1492
+ return void 0;
1493
+ }
1494
+ function getAttr(el, ...names) {
1495
+ if (!el) return void 0;
1496
+ for (const name of names) {
1497
+ const value = el.getAttribute(name);
1498
+ if (value !== null && value !== "") return value;
1499
+ }
1500
+ return void 0;
1501
+ }
1502
+ function normalizeData(raw) {
1503
+ const source = Array.isArray(raw) ? raw : countries_default;
1504
+ const out = [];
1505
+ const seen = /* @__PURE__ */ new Set();
1506
+ for (const item of source) {
1507
+ if (!item || !item.code) continue;
1508
+ const code = normalizeCode(item.code);
1509
+ if (!code || seen.has(code)) continue;
1510
+ seen.add(code);
1511
+ out.push({
1512
+ name: String(item.name || code),
1513
+ dial_code: String(item.dial_code || ""),
1514
+ code
1515
+ });
1516
+ }
1517
+ return out;
1518
+ }
1519
+ function filterCountries(allCountries, onlyCodes) {
1520
+ const list = parseCodeList(onlyCodes);
1521
+ if (!list.length) return allCountries.slice();
1522
+ const allowed = new Set(list);
1523
+ return allCountries.filter((item) => allowed.has(item.code));
1524
+ }
1525
+ function normalizeFlagsBase(inputPath) {
1526
+ const raw = String(inputPath || "").trim();
1527
+ if (!raw) return "";
1528
+ const stripped = raw.replace(/\/+$/, "");
1529
+ if (typeof document === "undefined") return stripped;
1530
+ try {
1531
+ return new URL(stripped, document.baseURI).href.replace(/\/+$/, "");
1532
+ } catch (e) {
1533
+ return stripped;
1534
+ }
1535
+ }
1536
+ function buildFlagElement(code, config) {
1537
+ const wrap = document.createElement("span");
1538
+ wrap.className = "kilfx__flag";
1539
+ const fallback = document.createElement("span");
1540
+ fallback.className = "kilfx__flag-fallback";
1541
+ fallback.textContent = code;
1542
+ wrap.appendChild(fallback);
1543
+ const img = document.createElement("img");
1544
+ img.className = "kilfx__flag-image";
1545
+ img.alt = code;
1546
+ img.loading = "eager";
1547
+ wrap.appendChild(img);
1548
+ const normalizedPath = normalizeFlagsBase(config.flagsPath);
1549
+ const defaultCdnBase = "https://cdn.jsdelivr.net/npm/kilfx@latest/svg";
1550
+ const lower = code.toLowerCase();
1551
+ const upper = code.toUpperCase();
1552
+ const variants = config.fileCase === "upper" ? [upper] : config.fileCase === "lower" ? [lower] : [lower, upper];
1553
+ const baseCandidates = [];
1554
+ if (normalizedPath) baseCandidates.push(normalizedPath);
1555
+ if (!baseCandidates.includes(defaultCdnBase)) {
1556
+ baseCandidates.push(defaultCdnBase);
1557
+ }
1558
+ const srcCandidates = [];
1559
+ for (const base of baseCandidates) {
1560
+ for (const variant of variants) {
1561
+ srcCandidates.push(`${base}/${variant}.svg`);
1562
+ }
1563
+ }
1564
+ let index = 0;
1565
+ const loadNext = () => {
1566
+ if (index >= srcCandidates.length) {
1567
+ wrap.classList.remove("kilfx__flag--loaded");
1568
+ return;
1569
+ }
1570
+ img.src = srcCandidates[index];
1571
+ index += 1;
1572
+ };
1573
+ img.addEventListener("load", () => {
1574
+ wrap.classList.add("kilfx__flag--loaded");
1575
+ });
1576
+ img.addEventListener("error", () => {
1577
+ loadNext();
1578
+ });
1579
+ loadNext();
1580
+ return wrap;
1581
+ }
1582
+ function countryLabel(item) {
1583
+ return `${item.name} (${item.code})`;
1584
+ }
1585
+ function bindGlobalEvents() {
1586
+ if (GLOBAL_EVENTS_BOUND || typeof document === "undefined") return;
1587
+ GLOBAL_EVENTS_BOUND = true;
1588
+ document.addEventListener("pointerdown", (event) => {
1589
+ if (!OPEN_DROPDOWN) return;
1590
+ if (!OPEN_DROPDOWN.fieldEl.contains(event.target)) {
1591
+ OPEN_DROPDOWN.closeMenu();
1592
+ }
1593
+ });
1594
+ document.addEventListener("keydown", (event) => {
1595
+ if (!OPEN_DROPDOWN) return;
1596
+ if (event.key === "Escape") {
1597
+ OPEN_DROPDOWN.closeMenu(true);
1598
+ }
1599
+ });
1600
+ window.addEventListener("resize", () => {
1601
+ if (OPEN_DROPDOWN) OPEN_DROPDOWN.positionMenu();
1602
+ });
1603
+ }
1604
+ var KilFxSelect = class {
1605
+ constructor(args) {
1606
+ this.rootInstance = args.rootInstance;
1607
+ this.kind = args.kind;
1608
+ this.selectEl = args.selectEl;
1609
+ this.countries = args.countries;
1610
+ this.initialCode = args.initialCode;
1611
+ this.config = args.config;
1612
+ this.preselectedValue = normalizeCode(args.preselectedValue);
1613
+ this.filteredCountries = this.countries.slice();
1614
+ this.activeIndex = -1;
1615
+ this.selectedCode = "";
1616
+ this.selectedItem = null;
1617
+ this.silentNative = false;
1618
+ this.fieldEl = document.createElement("div");
1619
+ this.fieldEl.className = "kilfx__field";
1620
+ this.fieldEl.setAttribute("data-kilfx-kind", this.kind);
1621
+ this.triggerEl = document.createElement("button");
1622
+ this.triggerEl.type = "button";
1623
+ this.triggerEl.className = "kilfx__trigger";
1624
+ this.triggerEl.setAttribute("aria-haspopup", "listbox");
1625
+ this.triggerEl.setAttribute("aria-expanded", "false");
1626
+ this.labelEl = document.createElement("span");
1627
+ this.labelEl.className = "kilfx__label";
1628
+ this.caretEl = document.createElement("span");
1629
+ this.caretEl.className = "kilfx__caret";
1630
+ this.caretEl.setAttribute("aria-hidden", "true");
1631
+ this.menuEl = document.createElement("div");
1632
+ this.menuEl.className = "kilfx__menu";
1633
+ this.menuEl.hidden = true;
1634
+ this.menuEl.id = nextUid("kilfx-menu");
1635
+ this.triggerEl.setAttribute("aria-controls", this.menuEl.id);
1636
+ this.searchWrapEl = document.createElement("div");
1637
+ this.searchWrapEl.className = "kilfx__search-wrap";
1638
+ this.searchEl = document.createElement("input");
1639
+ this.searchEl.className = "kilfx__search";
1640
+ this.searchEl.type = "text";
1641
+ this.searchEl.placeholder = "Search country or ISO";
1642
+ this.searchEl.autocomplete = "off";
1643
+ this.listEl = document.createElement("div");
1644
+ this.listEl.className = "kilfx__list";
1645
+ this.listEl.setAttribute("role", "listbox");
1646
+ this.searchWrapEl.appendChild(this.searchEl);
1647
+ this.menuEl.appendChild(this.searchWrapEl);
1648
+ this.menuEl.appendChild(this.listEl);
1649
+ this.triggerEl.appendChild(this.labelEl);
1650
+ this.triggerEl.appendChild(this.caretEl);
1651
+ this.fieldEl.appendChild(this.triggerEl);
1652
+ this.fieldEl.appendChild(this.menuEl);
1653
+ this.selectEl.classList.add("kilfx__native");
1654
+ this.selectEl.insertAdjacentElement("afterend", this.fieldEl);
1655
+ this.selectEl.setAttribute("data-kilfx-role", this.kind);
1656
+ if (!this.config.enableSearch) {
1657
+ this.searchWrapEl.hidden = true;
1658
+ }
1659
+ this.syncNativeOptions();
1660
+ this.bindEvents();
1661
+ this.setSelectedCode(this.resolveStartingCode(), {
1662
+ emitNative: false,
1663
+ emitWidget: false
1664
+ });
1665
+ }
1666
+ bindEvents() {
1667
+ this.triggerEl.addEventListener("click", () => {
1668
+ if (this.menuEl.hidden) this.openMenu();
1669
+ else this.closeMenu();
1670
+ });
1671
+ this.triggerEl.addEventListener("keydown", (event) => {
1672
+ this.onKeyDown(event, true);
1673
+ });
1674
+ this.searchEl.addEventListener("input", () => {
1675
+ this.applyFilter(this.searchEl.value);
1676
+ });
1677
+ this.searchEl.addEventListener("keydown", (event) => {
1678
+ this.onKeyDown(event, false);
1679
+ });
1680
+ this.listEl.addEventListener("keydown", (event) => {
1681
+ this.onKeyDown(event, false);
1682
+ });
1683
+ this.selectEl.addEventListener("change", () => {
1684
+ if (this.silentNative) return;
1685
+ this.setSelectedCode(this.selectEl.value, {
1686
+ emitNative: false,
1687
+ emitWidget: true
1688
+ });
1689
+ });
1690
+ }
1691
+ syncNativeOptions() {
1692
+ const fragment = document.createDocumentFragment();
1693
+ for (const item of this.countries) {
1694
+ const option = document.createElement("option");
1695
+ option.value = item.code;
1696
+ option.textContent = countryLabel(item);
1697
+ fragment.appendChild(option);
1698
+ }
1699
+ this.selectEl.innerHTML = "";
1700
+ this.selectEl.appendChild(fragment);
1701
+ this.selectEl.disabled = this.countries.length === 0;
1702
+ this.triggerEl.disabled = this.countries.length === 0;
1703
+ }
1704
+ resolveStartingCode() {
1705
+ if (this.hasCode(this.preselectedValue)) return this.preselectedValue;
1706
+ const initFromSelect = pickFirst(
1707
+ getAttr(this.selectEl, "kilfx_int", "data-kilfx-int"),
1708
+ this.initialCode
1709
+ );
1710
+ const normalizedInit = normalizeCode(initFromSelect);
1711
+ if (this.hasCode(normalizedInit)) return normalizedInit;
1712
+ if (this.countries[0]) return this.countries[0].code;
1713
+ return "";
1714
+ }
1715
+ hasCode(code) {
1716
+ if (!code) return false;
1717
+ return this.countries.some((item) => item.code === code);
1718
+ }
1719
+ setSelectedCode(code, behavior) {
1720
+ const normalized = normalizeCode(code);
1721
+ let selected = this.countries.find((item) => item.code === normalized);
1722
+ if (!selected) selected = this.countries[0] || null;
1723
+ this.selectedItem = selected;
1724
+ this.selectedCode = selected ? selected.code : "";
1725
+ this.selectEl.value = this.selectedCode;
1726
+ this.renderTrigger();
1727
+ this.renderList();
1728
+ if (behavior.emitNative) {
1729
+ this.silentNative = true;
1730
+ this.selectEl.dispatchEvent(new Event("change", { bubbles: true }));
1731
+ this.silentNative = false;
1732
+ }
1733
+ if (behavior.emitWidget) {
1734
+ this.rootInstance.onSelectChanged();
1735
+ }
1736
+ }
1737
+ renderTrigger() {
1738
+ if (!this.selectedItem) {
1739
+ this.labelEl.textContent = "No country available";
1740
+ return;
1741
+ }
1742
+ this.labelEl.textContent = countryLabel(this.selectedItem);
1743
+ const oldFlag = this.triggerEl.querySelector(".kilfx__flag");
1744
+ if (oldFlag) oldFlag.remove();
1745
+ this.triggerEl.insertBefore(
1746
+ buildFlagElement(this.selectedItem.code, this.config),
1747
+ this.labelEl
1748
+ );
1749
+ }
1750
+ applyFilter(term) {
1751
+ const query = String(term || "").trim().toLowerCase();
1752
+ this.filteredCountries = this.countries.filter((item) => {
1753
+ if (!query) return true;
1754
+ return item.name.toLowerCase().includes(query) || item.code.toLowerCase().includes(query);
1755
+ });
1756
+ const selectedIndex = this.filteredCountries.findIndex(
1757
+ (item) => item.code === this.selectedCode
1758
+ );
1759
+ this.activeIndex = selectedIndex >= 0 ? selectedIndex : this.filteredCountries.length ? 0 : -1;
1760
+ this.renderList();
1761
+ }
1762
+ renderList() {
1763
+ this.listEl.innerHTML = "";
1764
+ if (!this.filteredCountries.length) {
1765
+ const empty = document.createElement("div");
1766
+ empty.className = "kilfx__empty";
1767
+ empty.textContent = "No countries found";
1768
+ this.listEl.appendChild(empty);
1769
+ return;
1770
+ }
1771
+ const fragment = document.createDocumentFragment();
1772
+ this.filteredCountries.forEach((item, index) => {
1773
+ const button = document.createElement("button");
1774
+ button.type = "button";
1775
+ button.className = "kilfx__item";
1776
+ button.setAttribute("role", "option");
1777
+ button.setAttribute("data-code", item.code);
1778
+ button.setAttribute("aria-selected", item.code === this.selectedCode ? "true" : "false");
1779
+ if (item.code === this.selectedCode) {
1780
+ button.classList.add("kilfx__item--selected");
1781
+ }
1782
+ if (index === this.activeIndex) {
1783
+ button.classList.add("kilfx__item--active");
1784
+ }
1785
+ const label = document.createElement("span");
1786
+ label.className = "kilfx__item-label";
1787
+ label.textContent = countryLabel(item);
1788
+ button.appendChild(buildFlagElement(item.code, this.config));
1789
+ button.appendChild(label);
1790
+ button.addEventListener("click", () => {
1791
+ this.setSelectedCode(item.code, { emitNative: true, emitWidget: true });
1792
+ this.closeMenu(true);
1793
+ });
1794
+ fragment.appendChild(button);
1795
+ });
1796
+ this.listEl.appendChild(fragment);
1797
+ }
1798
+ moveActive(step) {
1799
+ if (!this.filteredCountries.length) return;
1800
+ if (this.activeIndex < 0) {
1801
+ this.activeIndex = 0;
1802
+ } else {
1803
+ const total = this.filteredCountries.length;
1804
+ this.activeIndex = (this.activeIndex + step + total) % total;
1805
+ }
1806
+ this.renderList();
1807
+ const active = this.listEl.querySelector(".kilfx__item--active");
1808
+ if (active) active.scrollIntoView({ block: "nearest" });
1809
+ }
1810
+ onKeyDown(event, allowOpen) {
1811
+ const { key } = event;
1812
+ if (allowOpen && this.menuEl.hidden && (key === "ArrowDown" || key === "ArrowUp" || key === "Enter" || key === " ")) {
1813
+ event.preventDefault();
1814
+ this.openMenu();
1815
+ return;
1816
+ }
1817
+ if (this.menuEl.hidden) return;
1818
+ if (key === "ArrowDown") {
1819
+ event.preventDefault();
1820
+ this.moveActive(1);
1821
+ } else if (key === "ArrowUp") {
1822
+ event.preventDefault();
1823
+ this.moveActive(-1);
1824
+ } else if (key === "Enter") {
1825
+ event.preventDefault();
1826
+ const target = this.filteredCountries[this.activeIndex];
1827
+ if (target) {
1828
+ this.setSelectedCode(target.code, { emitNative: true, emitWidget: true });
1829
+ this.closeMenu(true);
1830
+ }
1831
+ } else if (key === "Escape") {
1832
+ event.preventDefault();
1833
+ this.closeMenu(true);
1834
+ }
1835
+ }
1836
+ positionMenu() {
1837
+ const rect = this.fieldEl.getBoundingClientRect();
1838
+ const downSpace = window.innerHeight - rect.bottom;
1839
+ const upSpace = rect.top;
1840
+ const openUp = downSpace < 280 && upSpace > downSpace;
1841
+ this.fieldEl.classList.toggle("kilfx__field--up", openUp);
1842
+ }
1843
+ openMenu() {
1844
+ if (!this.countries.length) return;
1845
+ if (OPEN_DROPDOWN && OPEN_DROPDOWN !== this) {
1846
+ OPEN_DROPDOWN.closeMenu();
1847
+ }
1848
+ OPEN_DROPDOWN = this;
1849
+ this.positionMenu();
1850
+ this.menuEl.hidden = false;
1851
+ this.fieldEl.classList.add("kilfx__field--open");
1852
+ this.triggerEl.setAttribute("aria-expanded", "true");
1853
+ if (this.config.enableSearch) {
1854
+ this.searchEl.value = "";
1855
+ }
1856
+ this.applyFilter("");
1857
+ if (this.config.enableSearch) {
1858
+ setTimeout(() => this.searchEl.focus(), 0);
1859
+ }
1860
+ }
1861
+ closeMenu(focusTrigger = false) {
1862
+ this.menuEl.hidden = true;
1863
+ this.fieldEl.classList.remove("kilfx__field--open");
1864
+ this.fieldEl.classList.remove("kilfx__field--up");
1865
+ this.triggerEl.setAttribute("aria-expanded", "false");
1866
+ if (OPEN_DROPDOWN === this) OPEN_DROPDOWN = null;
1867
+ if (focusTrigger) this.triggerEl.focus();
1868
+ }
1869
+ };
1870
+ var KilFxRoot = class {
1871
+ constructor(rootEl, config) {
1872
+ this.rootEl = rootEl;
1873
+ this.config = config;
1874
+ this.baseSelectEl = rootEl.querySelector(`select[name="${config.baseName}"]`);
1875
+ this.toSelectEl = rootEl.querySelector(`select[name="${config.toName}"]`);
1876
+ this.rateInputEl = rootEl.querySelector(`input[name="${config.rateName}"]`);
1877
+ this.baseControl = null;
1878
+ this.toControl = null;
1879
+ }
1880
+ mount() {
1881
+ if (!this.baseSelectEl || !this.toSelectEl) return false;
1882
+ this.rootEl.classList.add("kilfx", "kilfx--enhanced");
1883
+ const mergedData = normalizeData(this.config.data);
1884
+ const rootOnly = pickFirst(
1885
+ getAttr(this.rootEl, "kilfx_only", "data-kilfx-only"),
1886
+ this.config.only
1887
+ );
1888
+ const rootInt = pickFirst(
1889
+ getAttr(this.rootEl, "kilfx_int", "data-kilfx-int"),
1890
+ this.config.initCountry
1891
+ );
1892
+ const baseOnly = pickFirst(
1893
+ getAttr(
1894
+ this.baseSelectEl,
1895
+ "kilfx_only",
1896
+ "data-kilfx-only",
1897
+ "data-kilfx-base-only"
1898
+ ),
1899
+ getAttr(this.rootEl, "kilfx_base_only", "data-kilfx-base-only"),
1900
+ this.config.onlyBase,
1901
+ rootOnly
1902
+ );
1903
+ const toOnly = pickFirst(
1904
+ getAttr(
1905
+ this.toSelectEl,
1906
+ "kilfx_only",
1907
+ "data-kilfx-only",
1908
+ "data-kilfx-to-only"
1909
+ ),
1910
+ getAttr(this.rootEl, "kilfx_to_only", "data-kilfx-to-only"),
1911
+ this.config.onlyTo,
1912
+ rootOnly
1913
+ );
1914
+ const baseCountries = filterCountries(mergedData, baseOnly);
1915
+ const toCountries = filterCountries(mergedData, toOnly);
1916
+ const preselectedBase = normalizeCode(this.baseSelectEl.value);
1917
+ const preselectedTo = normalizeCode(this.toSelectEl.value);
1918
+ const baseInit = pickFirst(
1919
+ getAttr(this.baseSelectEl, "kilfx_int", "data-kilfx-int"),
1920
+ getAttr(this.rootEl, "kilfx_base_int", "data-kilfx-base-int"),
1921
+ rootInt,
1922
+ this.config.defaultBase,
1923
+ "JM"
1924
+ );
1925
+ const toInit = pickFirst(
1926
+ getAttr(this.toSelectEl, "kilfx_int", "data-kilfx-int"),
1927
+ getAttr(this.rootEl, "kilfx_to_int", "data-kilfx-to-int"),
1928
+ rootInt,
1929
+ this.config.defaultTo,
1930
+ "JM"
1931
+ );
1932
+ this.baseControl = new KilFxSelect({
1933
+ rootInstance: this,
1934
+ kind: "base",
1935
+ selectEl: this.baseSelectEl,
1936
+ countries: baseCountries,
1937
+ initialCode: baseInit,
1938
+ preselectedValue: preselectedBase,
1939
+ config: this.config
1940
+ });
1941
+ this.toControl = new KilFxSelect({
1942
+ rootInstance: this,
1943
+ kind: "to",
1944
+ selectEl: this.toSelectEl,
1945
+ countries: toCountries,
1946
+ initialCode: toInit,
1947
+ preselectedValue: preselectedTo,
1948
+ config: this.config
1949
+ });
1950
+ if (this.rateInputEl) {
1951
+ this.rateInputEl.classList.add("kilfx__rate");
1952
+ this.rateInputEl.readOnly = true;
1953
+ }
1954
+ return true;
1955
+ }
1956
+ onSelectChanged() {
1957
+ var _a, _b, _c, _d;
1958
+ if (this.rateInputEl) {
1959
+ this.rateInputEl.readOnly = true;
1960
+ this.rateInputEl.value = "";
1961
+ }
1962
+ const detail = {
1963
+ base: ((_a = this.baseControl) == null ? void 0 : _a.selectedCode) || "",
1964
+ to: ((_b = this.toControl) == null ? void 0 : _b.selectedCode) || "",
1965
+ rootEl: this.rootEl,
1966
+ baseSelectEl: this.baseSelectEl,
1967
+ toSelectEl: this.toSelectEl,
1968
+ baseItem: ((_c = this.baseControl) == null ? void 0 : _c.selectedItem) || null,
1969
+ toItem: ((_d = this.toControl) == null ? void 0 : _d.selectedItem) || null
1970
+ };
1971
+ document.dispatchEvent(new CustomEvent("kilfx:change", { detail }));
1972
+ }
1973
+ };
1974
+ function normalizeConfig(options = {}) {
1975
+ const config = { ...DEFAULTS, ...options };
1976
+ config.initCountry = pickFirst(options.initCountry, options.kilfx_int, config.initCountry);
1977
+ config.only = pickFirst(options.only, options.kilfx_only, config.only);
1978
+ config.onlyBase = pickFirst(options.onlyBase, options.kilfx_base_only, config.onlyBase);
1979
+ config.onlyTo = pickFirst(options.onlyTo, options.kilfx_to_only, config.onlyTo);
1980
+ const fileCase = String(config.fileCase || "auto").toLowerCase();
1981
+ config.fileCase = fileCase === "upper" || fileCase === "lower" ? fileCase : "auto";
1982
+ config.enableSearch = config.enableSearch !== false;
1983
+ config.defaultBase = normalizeCode(
1984
+ pickFirst(options.defaultBase, options.kilfx_base_int, config.initCountry, "JM")
1985
+ );
1986
+ config.defaultTo = normalizeCode(
1987
+ pickFirst(options.defaultTo, options.kilfx_to_int, config.initCountry, "JM")
1988
+ );
1989
+ return config;
1990
+ }
1991
+ function resolveRoots(config, options) {
1992
+ if (options.rootElements && Array.isArray(options.rootElements)) {
1993
+ return options.rootElements.filter(Boolean);
1994
+ }
1995
+ if (typeof document === "undefined") return [];
1996
+ return Array.from(document.querySelectorAll(config.rootSelector));
1997
+ }
1998
+ function init(options = {}) {
1999
+ if (typeof document === "undefined") return [];
2000
+ const config = normalizeConfig(options);
2001
+ ensureStylesInjected();
2002
+ bindGlobalEvents();
2003
+ const roots = resolveRoots(config, options);
2004
+ const instances = [];
2005
+ for (const rootEl of roots) {
2006
+ if (ROOT_INSTANCES.has(rootEl)) {
2007
+ instances.push(ROOT_INSTANCES.get(rootEl));
2008
+ continue;
2009
+ }
2010
+ const root = new KilFxRoot(rootEl, config);
2011
+ if (!root.mount()) continue;
2012
+ ROOT_INSTANCES.set(rootEl, root);
2013
+ instances.push(root);
2014
+ }
2015
+ return instances;
2016
+ }
2017
+ var defaults = { ...DEFAULTS };
2018
+
2019
+ // src/index.js
2020
+ var autoInitAttached = false;
2021
+ var manualInitCalled = false;
2022
+ function init2(options = {}) {
2023
+ manualInitCalled = true;
2024
+ return init(options);
2025
+ }
2026
+ function autoInit(options = {}) {
2027
+ if (typeof document === "undefined") return;
2028
+ if (document.readyState === "loading") {
2029
+ if (autoInitAttached) return;
2030
+ autoInitAttached = true;
2031
+ document.addEventListener(
2032
+ "DOMContentLoaded",
2033
+ () => {
2034
+ if (manualInitCalled) return;
2035
+ init2(options);
2036
+ },
2037
+ { once: true }
2038
+ );
2039
+ } else {
2040
+ if (manualInitCalled) return;
2041
+ init2(options);
2042
+ }
2043
+ }
2044
+ var api = {
2045
+ init: init2,
2046
+ autoInit,
2047
+ countriesData: countries_default,
2048
+ defaults,
2049
+ ensureStylesInjected
2050
+ };
2051
+ if (typeof window !== "undefined") {
2052
+ window.KILFX = api;
2053
+ autoInit();
2054
+ }
2055
+ var index_default = api;