1(function(factory){ 2if(typeof module==='object'&&module.exports){ 3module.exports=factory(); 4}else{ 5window.intlTelInput=factory(); 6}}(()=> { 7var factoryOutput=(()=> { 8var __defProp=Object.defineProperty; 9var __getOwnPropDesc=Object.getOwnPropertyDescriptor; 10var __getOwnPropNames=Object.getOwnPropertyNames; 11var __hasOwnProp=Object.prototype.hasOwnProperty; 12var __export=(target, all)=> { 13for (var name in all) 14__defProp(target, name, { get: all[name], enumerable: true }); 15}; 16var __copyProps=(to, from, except, desc)=> { 17if(from&&typeof from==="object"||typeof from==="function"){ 18for (let key of __getOwnPropNames(from)) 19if(!__hasOwnProp.call(to, key)&&key!==except) 20__defProp(to, key, { get: ()=> from[key], enumerable: !(desc=__getOwnPropDesc(from, key))||desc.enumerable }); 21} 22return to; 23}; 24var __toCommonJS=(mod)=> __copyProps(__defProp({}, "__esModule", { value: true }), mod); 25var intl_tel_input_exports={}; 26__export(intl_tel_input_exports, { 27Iti: ()=> Iti, 28default: ()=> intl_tel_input_default 29}); 30var rawCountryData=[ 31[ 32"af", 33"93" 34], 35[ 36"al", 37"355" 38], 39[ 40"dz", 41"213" 42], 43[ 44"as", 45"1", 465, 47["684"] 48], 49[ 50"ad", 51"376" 52], 53[ 54"ao", 55"244" 56], 57[ 58"ai", 59"1", 606, 61["264"] 62], 63[ 64"ag", 65"1", 667, 67["268"] 68], 69[ 70"ar", 71"54" 72], 73[ 74"am", 75"374" 76], 77[ 78"aw", 79"297" 80], 81[ 82"ac", 83"247" 84], 85[ 86"au", 87"61", 880 89], 90[ 91"at", 92"43" 93], 94[ 95"az", 96"994" 97], 98[ 99"bs", 100"1", 1018, 102["242"] 103], 104[ 105"bh", 106"973" 107], 108[ 109"bd", 110"880" 111], 112[ 113"bb", 114"1", 1159, 116["246"] 117], 118[ 119"by", 120"375" 121], 122[ 123"be", 124"32" 125], 126[ 127"bz", 128"501" 129], 130[ 131"bj", 132"229" 133], 134[ 135"bm", 136"1", 13710, 138["441"] 139], 140[ 141"bt", 142"975" 143], 144[ 145"bo", 146"591" 147], 148[ 149"ba", 150"387" 151], 152[ 153"bw", 154"267" 155], 156[ 157"br", 158"55" 159], 160[ 161"io", 162"246" 163], 164[ 165"vg", 166"1", 16711, 168["284"] 169], 170[ 171"bn", 172"673" 173], 174[ 175"bg", 176"359" 177], 178[ 179"bf", 180"226" 181], 182[ 183"bi", 184"257" 185], 186[ 187"kh", 188"855" 189], 190[ 191"cm", 192"237" 193], 194[ 195"ca", 196"1", 1971, 198["204", "226", "236", "249", "250", "263", "289", "306", "343", "354", "365", "367", "368", "382", "387", "403", "416", "418", "428", "431", "437", "438", "450", "584", "468", "474", "506", "514", "519", "548", "579", "581", "584", "587", "604", "613", "639", "647", "672", "683", "705", "709", "742", "753", "778", "780", "782", "807", "819", "825", "867", "873", "879", "902", "905"] 199], 200[ 201"cv", 202"238" 203], 204[ 205"bq", 206"599", 2071, 208["3", "4", "7"] 209], 210[ 211"ky", 212"1", 21312, 214["345"] 215], 216[ 217"cf", 218"236" 219], 220[ 221"td", 222"235" 223], 224[ 225"cl", 226"56" 227], 228[ 229"cn", 230"86" 231], 232[ 233"cx", 234"61", 2352, 236["89164"] 237], 238[ 239"cc", 240"61", 2411, 242["89162"] 243], 244[ 245"co", 246"57" 247], 248[ 249"km", 250"269" 251], 252[ 253"cg", 254"242" 255], 256[ 257"cd", 258"243" 259], 260[ 261"ck", 262"682" 263], 264[ 265"cr", 266"506" 267], 268[ 269"ci", 270"225" 271], 272[ 273"hr", 274"385" 275], 276[ 277"cu", 278"53" 279], 280[ 281"cw", 282"599", 2830 284], 285[ 286"cy", 287"357" 288], 289[ 290"cz", 291"420" 292], 293[ 294"dk", 295"45" 296], 297[ 298"dj", 299"253" 300], 301[ 302"dm", 303"1", 30413, 305["767"] 306], 307[ 308"do", 309"1", 3102, 311["809", "829", "849"] 312], 313[ 314"ec", 315"593" 316], 317[ 318"eg", 319"20" 320], 321[ 322"sv", 323"503" 324], 325[ 326"gq", 327"240" 328], 329[ 330"er", 331"291" 332], 333[ 334"ee", 335"372" 336], 337[ 338"sz", 339"268" 340], 341[ 342"et", 343"251" 344], 345[ 346"fk", 347"500" 348], 349[ 350"fo", 351"298" 352], 353[ 354"fj", 355"679" 356], 357[ 358"fi", 359"358", 3600 361], 362[
363"fr", 364"33" 365], 366[ 367"gf", 368"594" 369], 370[ 371"pf", 372"689" 373], 374[ 375"ga", 376"241" 377], 378[ 379"gm", 380"220" 381], 382[ 383"ge", 384"995" 385], 386[ 387"de", 388"49" 389], 390[ 391"gh", 392"233" 393], 394[ 395"gi", 396"350" 397], 398[ 399"gr", 400"30" 401], 402[ 403"gl", 404"299" 405], 406[ 407"gd", 408"1", 40914, 410["473"] 411], 412[ 413"gp", 414"590", 4150 416], 417[ 418"gu", 419"1", 42015, 421["671"] 422], 423[ 424"gt", 425"502" 426], 427[ 428"gg", 429"44", 4301, 431["1481", "7781", "7839", "7911"] 432], 433[ 434"gn", 435"224" 436], 437[ 438"gw", 439"245" 440], 441[ 442"gy", 443"592" 444], 445[ 446"ht", 447"509" 448], 449[ 450"hn", 451"504" 452], 453[ 454"hk", 455"852" 456], 457[ 458"hu", 459"36" 460], 461[ 462"is", 463"354" 464], 465[ 466"in", 467"91" 468], 469[ 470"id", 471"62" 472], 473[ 474"ir", 475"98" 476], 477[ 478"iq", 479"964" 480], 481[ 482"ie", 483"353" 484], 485[ 486"im", 487"44", 4882, 489["1624", "74576", "7524", "7924", "7624"] 490], 491[ 492"il", 493"972" 494], 495[ 496"it", 497"39", 4980 499], 500[ 501"jm", 502"1", 5034, 504["876", "658"] 505], 506[ 507"jp", 508"81" 509], 510[ 511"je", 512"44", 5133, 514["1534", "7509", "7700", "7797", "7829", "7937"] 515], 516[ 517"jo", 518"962" 519], 520[ 521"kz", 522"7", 5231, 524["33", "7"] 525], 526[ 527"ke", 528"254" 529], 530[ 531"ki", 532"686" 533], 534[ 535"xk", 536"383" 537], 538[ 539"kw", 540"965" 541], 542[ 543"kg", 544"996" 545], 546[ 547"la", 548"856" 549], 550[ 551"lv", 552"371" 553], 554[ 555"lb", 556"961" 557], 558[ 559"ls", 560"266" 561], 562[ 563"lr", 564"231" 565], 566[ 567"ly", 568"218" 569], 570[ 571"li", 572"423" 573], 574[ 575"lt", 576"370" 577], 578[ 579"lu", 580"352" 581], 582[ 583"mo", 584"853" 585], 586[ 587"mg", 588"261" 589], 590[ 591"mw", 592"265" 593], 594[ 595"my", 596"60" 597], 598[ 599"mv", 600"960" 601], 602[ 603"ml", 604"223" 605], 606[ 607"mt", 608"356" 609], 610[ 611"mh", 612"692" 613], 614[ 615"mq", 616"596" 617], 618[ 619"mr", 620"222" 621], 622[ 623"mu", 624"230" 625], 626[ 627"yt", 628"262", 6291, 630["269", "639"] 631], 632[ 633"mx", 634"52" 635], 636[ 637"fm", 638"691" 639], 640[ 641"md", 642"373" 643], 644[ 645"mc", 646"377" 647], 648[ 649"mn", 650"976" 651], 652[ 653"me", 654"382" 655], 656[ 657"ms", 658"1", 65916, 660["664"] 661], 662[ 663"ma", 664"212", 6650 666], 667[ 668"mz", 669"258" 670], 671[ 672"mm", 673"95" 674], 675[ 676"na", 677"264" 678], 679[ 680"nr", 681"674" 682], 683[ 684"np", 685"977" 686], 687[ 688"nl", 689"31" 690], 691[ 692"nc", 693"687" 694], 695[ 696"nz", 697"64" 698], 699[ 700"ni", 701"505" 702], 703[ 704"ne", 705"227" 706], 707[ 708"ng", 709"234" 710], 711[ 712"nu", 713"683" 714], 715[ 716"nf", 717"672" 718], 719[ 720"kp", 721"850" 722], 723[ 724"mk", 725"389" 726], 727[ 728"mp", 729"1", 73017, 731["670"] 732], 733[ 734"no", 735"47", 7360 737], 738[ 739"om", 740"968" 741], 742[ 743"pk", 744"92" 745], 746[ 747"pw", 748"680" 749], 750[ 751"ps", 752"970" 753], 754[ 755"pa", 756"507" 757], 758[ 759"pg", 760"675" 761], 762[ 763"py", 764"595" 765], 766[ 767"pe", 768"51" 769], 770[ 771"ph", 772"63" 773], 774[ 775"pl", 776"48" 777], 778[ 779"pt", 780"351" 781], 782[ 783"pr", 784"1", 7853, 786["787", "939"] 787], 788[ 789"qa", 790"974" 791], 792[ 793"re", 794"262", 7950 796], 797[ 798"ro", 799"40" 800], 801[ 802"ru", 803"7", 8040 805], 806[ 807"rw", 808"250" 809], 810[ 811"ws", 812"685" 813], 814[ 815"sm", 816"378" 817], 818[ 819"st", 820"239" 821], 822[ 823"sa", 824"966" 825], 826[ 827"sn", 828"221" 829], 830[ 831"rs", 832"381" 833], 834[ 835"sc", 836"248" 837], 838[ 839"sl", 840"232" 841], 842[ 843"sg", 844"65" 845], 846[ 847"sx", 848"1", 84921, 850["721"] 851], 852[ 853"sk", 854"421" 855], 856[ 857"si", 858"386" 859], 860[ 861"sb", 862"677" 863], 864[ 865"so", 866"252" 867], 868[ 869"za", 870"27" 871], 872[ 873"kr", 874"82" 875], 876[ 877"ss", 878"211" 879], 880[ 881"es", 882"34" 883], 884[ 885"lk", 886"94" 887], 888[ 889"bl", 890"590", 8911 892], 893[ 894"sh", 895"290" 896], 897[ 898"kn", 899"1", 90018, 901["869"] 902], 903[ 904"lc", 905"1", 90619, 907["758"] 908], 909[ 910"mf", 911"590", 9122 913], 914[ 915"pm", 916"508" 917], 918[ 919"vc", 920"1", 92120, 922["784"] 923], 924[ 925"sd", 926"249" 927], 928[ 929"sr", 930"597" 931], 932[ 933"sj", 934"47", 9351, 936["79"] 937], 938[ 939"se", 940"46" 941], 942[ 943"ch", 944"41" 945], 946[ 947"sy", 948"963" 949], 950[ 951"tw", 952"886" 953], 954[ 955"tj", 956"992" 957], 958[ 959"tz", 960"255" 961], 962[ 963"th", 964"66" 965], 966[ 967"tl", 968"670" 969], 970[ 971"tg", 972"228" 973], 974[ 975"tk", 976"690" 977], 978[ 979"to", 980"676" 981], 982[ 983"tt", 984"1", 98522, 986["868"] 987], 988[ 989"tn", 990"216" 991], 992[ 993"tr", 994"90" 995], 996[ 997"tm", 998"993" 999], 1000[ 1001"tc", 1002"1", 100323, 1004["649"] 1005], 1006[ 1007"tv", 1008"688" 1009], 1010[ 1011"ug", 1012"256" 1013], 1014[ 1015"ua", 1016"380" 1017], 1018[ 1019"ae", 1020"971" 1021], 1022[ 1023"gb", 1024"44", 10250 1026], 1027[ 1028"us", 1029"1", 10300 1031], 1032[ 1033"uy", 1034"598" 1035], 1036[ 1037"vi", 1038"1", 103924, 1040["340"] 1041], 1042[ 1043"uz", 1044"998" 1045], 1046[ 1047"vu", 1048"678" 1049], 1050[ 1051"va", 1052"39", 10531, 1054["06698"] 1055], 1056[ 1057"ve", 1058"58" 1059], 1060[ 1061"vn", 1062"84" 1063], 1064[ 1065"wf", 1066"681" 1067], 1068[ 1069"eh", 1070"212", 10711, 1072["5288", "5289"] 1073], 1074[ 1075"ye", 1076"967" 1077], 1078[ 1079"zm", 1080"260" 1081], 1082[ 1083"zw", 1084"263" 1085], 1086[ 1087"ax", 1088"358", 10891, 1090["18"] 1091] 1092]; 1093var allCountries=[]; 1094for (let i=0; i < rawCountryData.length; i++){ 1095const c=rawCountryData[i]; 1096allCountries[i]={ 1097name: "", 1098iso2: c[0], 1099dialCode: c[1], 1100priority: c[2]||0, 1101areaCodes: c[3]||null, 1102nodeById: {}};} 1103var data_default=allCountries; 1104var countries_default={ 1105af: "Afghanistan", 1106ax: "\xC5land Islands", 1107al: "Albania", 1108dz: "Algeria", 1109as: "American Samoa", 1110ad: "Andorra", 1111ao: "Angola", 1112ai: "Anguilla", 1113aq: "Antarctica", 1114ag: "Antigua & Barbuda", 1115ar: "Argentina", 1116am: "Armenia", 1117aw: "Aruba", 1118au: "Australia", 1119at: "Austria", 1120az: "Azerbaijan", 1121bs: "Bahamas", 1122bh: "Bahrain", 1123bd: "Bangladesh", 1124bb: "Barbados", 1125by: "Belarus", 1126be: "Belgium", 1127bz: "Belize", 1128bj: "Benin", 1129bm: "Bermuda", 1130bt: "Bhutan", 1131bo: "Bolivia", 1132ba: "Bosnia & Herzegovina", 1133bw: "Botswana", 1134bv: "Bouvet Island", 1135br: "Brazil", 1136io: "British Indian Ocean Territory", 1137vg: "British Virgin Islands", 1138bn: "Brunei", 1139bg: "Bulgaria", 1140bf: "Burkina Faso", 1141bi: "Burundi", 1142kh: "Cambodia", 1143cm: "Cameroon", 1144ca: "Canada", 1145cv: "Cape Verde", 1146bq: "Caribbean Netherlands", 1147ky: "Cayman Islands", 1148cf: "Central African Republic", 1149td: "Chad", 1150cl: "Chile", 1151cn: "China", 1152cx: "Christmas Island", 1153cc: "Cocos (Keeling) Islands", 1154co: "Colombia", 1155km: "Comoros", 1156cg: "Congo - Brazzaville", 1157cd: "Congo - Kinshasa", 1158ck: "Cook Islands", 1159cr: "Costa Rica", 1160ci: "C\xF4te d\u2019Ivoire", 1161hr: "Croatia", 1162cu: "Cuba", 1163cw: "Cura\xE7ao", 1164cy: "Cyprus", 1165cz: "Czechia", 1166dk: "Denmark", 1167dj: "Djibouti", 1168dm: "Dominica", 1169do: "Dominican Republic", 1170ec: "Ecuador",
1171eg: "Egypt", 1172sv: "El Salvador", 1173gq: "Equatorial Guinea", 1174er: "Eritrea", 1175ee: "Estonia", 1176sz: "Eswatini", 1177et: "Ethiopia", 1178fk: "Falkland Islands", 1179fo: "Faroe Islands", 1180fj: "Fiji", 1181fi: "Finland", 1182fr: "France", 1183gf: "French Guiana", 1184pf: "French Polynesia", 1185tf: "French Southern Territories", 1186ga: "Gabon", 1187gm: "Gambia", 1188ge: "Georgia", 1189de: "Germany", 1190gh: "Ghana", 1191gi: "Gibraltar", 1192gr: "Greece", 1193gl: "Greenland", 1194gd: "Grenada", 1195gp: "Guadeloupe", 1196gu: "Guam", 1197gt: "Guatemala", 1198gg: "Guernsey", 1199gn: "Guinea", 1200gw: "Guinea-Bissau", 1201gy: "Guyana", 1202ht: "Haiti", 1203hm: "Heard & McDonald Islands", 1204hn: "Honduras", 1205hk: "Hong Kong SAR China", 1206hu: "Hungary", 1207is: "Iceland", 1208in: "India", 1209id: "Indonesia", 1210ir: "Iran", 1211iq: "Iraq", 1212ie: "Ireland", 1213im: "Isle of Man", 1214il: "Israel", 1215it: "Italy", 1216jm: "Jamaica", 1217jp: "Japan", 1218je: "Jersey", 1219jo: "Jordan", 1220kz: "Kazakhstan", 1221ke: "Kenya", 1222ki: "Kiribati", 1223kw: "Kuwait", 1224kg: "Kyrgyzstan", 1225la: "Laos", 1226lv: "Latvia", 1227lb: "Lebanon", 1228ls: "Lesotho", 1229lr: "Liberia", 1230ly: "Libya", 1231li: "Liechtenstein", 1232lt: "Lithuania", 1233lu: "Luxembourg", 1234mo: "Macao SAR China", 1235mg: "Madagascar", 1236mw: "Malawi", 1237my: "Malaysia", 1238mv: "Maldives", 1239ml: "Mali", 1240mt: "Malta", 1241mh: "Marshall Islands", 1242mq: "Martinique", 1243mr: "Mauritania", 1244mu: "Mauritius", 1245yt: "Mayotte", 1246mx: "Mexico", 1247fm: "Micronesia", 1248md: "Moldova", 1249mc: "Monaco", 1250mn: "Mongolia", 1251me: "Montenegro", 1252ms: "Montserrat", 1253ma: "Morocco", 1254mz: "Mozambique", 1255mm: "Myanmar (Burma)", 1256na: "Namibia", 1257nr: "Nauru", 1258np: "Nepal", 1259nl: "Netherlands", 1260nc: "New Caledonia", 1261nz: "New Zealand", 1262ni: "Nicaragua", 1263ne: "Niger", 1264ng: "Nigeria", 1265nu: "Niue", 1266nf: "Norfolk Island", 1267kp: "North Korea", 1268mk: "North Macedonia", 1269mp: "Northern Mariana Islands", 1270no: "Norway", 1271om: "Oman", 1272pk: "Pakistan", 1273pw: "Palau", 1274ps: "Palestinian Territories", 1275pa: "Panama", 1276pg: "Papua New Guinea", 1277py: "Paraguay", 1278pe: "Peru", 1279ph: "Philippines", 1280pn: "Pitcairn Islands", 1281pl: "Poland", 1282pt: "Portugal", 1283pr: "Puerto Rico", 1284qa: "Qatar", 1285re: "R\xE9union", 1286ro: "Romania", 1287ru: "Russia", 1288rw: "Rwanda", 1289ws: "Samoa", 1290sm: "San Marino", 1291st: "S\xE3o Tom\xE9 & Pr\xEDncipe", 1292sa: "Saudi Arabia", 1293sn: "Senegal", 1294rs: "Serbia", 1295sc: "Seychelles", 1296sl: "Sierra Leone", 1297sg: "Singapore", 1298sx: "Sint Maarten", 1299sk: "Slovakia", 1300si: "Slovenia", 1301sb: "Solomon Islands", 1302so: "Somalia", 1303za: "South Africa", 1304gs: "South Georgia & South Sandwich Islands", 1305kr: "South Korea", 1306ss: "South Sudan", 1307es: "Spain", 1308lk: "Sri Lanka", 1309bl: "St. Barth\xE9lemy", 1310sh: "St. Helena", 1311kn: "St. Kitts & Nevis", 1312lc: "St. Lucia", 1313mf: "St. Martin", 1314pm: "St. Pierre & Miquelon", 1315vc: "St. Vincent & Grenadines", 1316sd: "Sudan", 1317sr: "Suriname", 1318sj: "Svalbard & Jan Mayen", 1319se: "Sweden", 1320ch: "Switzerland", 1321sy: "Syria", 1322tw: "Taiwan", 1323tj: "Tajikistan", 1324tz: "Tanzania", 1325th: "Thailand", 1326tl: "Timor-Leste", 1327tg: "Togo", 1328tk: "Tokelau", 1329to: "Tonga", 1330tt: "Trinidad & Tobago", 1331tn: "Tunisia", 1332tr: "Turkey", 1333tm: "Turkmenistan", 1334tc: "Turks & Caicos Islands", 1335tv: "Tuvalu", 1336um: "U.S. Outlying Islands", 1337vi: "U.S. Virgin Islands", 1338ug: "Uganda", 1339ua: "Ukraine", 1340ae: "United Arab Emirates", 1341gb: "United Kingdom", 1342us: "United States", 1343uy: "Uruguay", 1344uz: "Uzbekistan", 1345vu: "Vanuatu", 1346va: "Vatican City", 1347ve: "Venezuela", 1348vn: "Vietnam", 1349wf: "Wallis & Futuna", 1350eh: "Western Sahara", 1351ye: "Yemen", 1352zm: "Zambia", 1353zw: "Zimbabwe" 1354}; 1355var interface_default={ 1356selectedCountryAriaLabel: "Selected country", 1357noCountrySelected: "No country selected", 1358countryListAriaLabel: "List of countries", 1359searchPlaceholder: "Search", 1360zeroSearchResults: "No results found", 1361oneSearchResult: "1 result found", 1362multipleSearchResults: "${count} results found", 1363ac: "Ascension Island", 1364xk: "Kosovo" 1365}; 1366var en_default={ ...countries_default, ...interface_default }; 1367var id=0; 1368var defaults={ 1369allowDropdown: true, 1370autoPlaceholder: "polite", 1371containerClass: "", 1372countryOrder: null, 1373customPlaceholder: null, 1374dropdownContainer: null, 1375excludeCountries: [], 1376fixDropdownWidth: true, 1377formatAsYouType: true, 1378formatOnDisplay: true, 1379geoIpLookup: null, 1380hiddenInput: null, 1381i18n: {}, 1382initialCountry: "", 1383nationalMode: true, 1384onlyCountries: [], 1385placeholderNumberType: "MOBILE", 1386showFlags: true, 1387separateDialCode: false, 1388strictMode: false, 1389useFullscreenPopup: typeof navigator!=="undefined"&&typeof window!=="undefined" ? ( 1390/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent 1391)||window.innerWidth <=500 1392):false, 1393utilsScript: "", 1394validationNumberType: "MOBILE" 1395}; 1396var regionlessNanpNumbers=[ 1397"800", 1398"822", 1399"833", 1400"844", 1401"855", 1402"866", 1403"877", 1404"880", 1405"881", 1406"882", 1407"883", 1408"884", 1409"885", 1410"886", 1411"887", 1412"888", 1413"889" 1414]; 1415var getNumeric=(s)=> s.replace(/\D/g, ""); 1416var normaliseString=(s="")=> s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(); 1417var isRegionlessNanp=(number)=> { 1418const numeric=getNumeric(number); 1419if(numeric.charAt(0)==="1"){ 1420const areaCode=numeric.substr(1, 3); 1421return regionlessNanpNumbers.indexOf(areaCode)!==-1; 1422} 1423return false;
1424}; 1425var translateCursorPosition=(relevantChars, formattedValue, prevCaretPos, isDeleteForwards)=> { 1426if(prevCaretPos===0&&!isDeleteForwards){ 1427return 0; 1428} 1429let count=0; 1430for (let i=0; i < formattedValue.length; i++){ 1431if(/[+0-9]/.test(formattedValue[i])){ 1432count++; 1433} 1434if(count===relevantChars&&!isDeleteForwards){ 1435return i + 1; 1436} 1437if(isDeleteForwards&&count===relevantChars + 1){ 1438return i; 1439}} 1440return formattedValue.length; 1441}; 1442var createEl=(name, attrs, container)=> { 1443const el=document.createElement(name); 1444if(attrs){ 1445Object.entries(attrs).forEach(([key, value])=> el.setAttribute(key, value)); 1446} 1447if(container){ 1448container.appendChild(el); 1449} 1450return el; 1451}; 1452var forEachInstance=(method)=> { 1453const { instances }=intlTelInput; 1454Object.values(instances).forEach((instance)=> instance[method]()); 1455}; 1456var Iti=class { 1457id; 1458promise; 1459telInput; 1460highlightedItem; 1461options; 1462hadInitialPlaceholder; 1463isRTL; 1464selectedCountryData; 1465countries; 1466dialCodeMaxLen; 1467dialCodeToIso2Map; 1468dialCodes; 1469countryContainer; 1470selectedCountry; 1471selectedCountryInner; 1472selectedCountryA11yText; 1473selectedDialCode; 1474dropdownArrow; 1475dropdownContent; 1476searchInput; 1477searchResultsA11yText; 1478countryList; 1479dropdown; 1480hiddenInput; 1481hiddenInputCountry; 1482maxCoreNumberLength; 1483defaultCountry; 1484_handleHiddenInputSubmit; 1485_handleLabelClick; 1486_handleClickSelectedCountry; 1487_handleCountryContainerKeydown; 1488_handleInputEvent; 1489_handleKeydownEvent; 1490_handleWindowScroll; 1491_handleMouseoverCountryList; 1492_handleClickCountryList; 1493_handleClickOffToClose; 1494_handleKeydownOnDropdown; 1495_handleSearchChange; 1496resolveAutoCountryPromise; 1497rejectAutoCountryPromise; 1498resolveUtilsScriptPromise; 1499rejectUtilsScriptPromise; 1500constructor(input, customOptions={}){ 1501this.id=id++; 1502this.telInput=input; 1503this.highlightedItem=null; 1504this.options=Object.assign({}, defaults, customOptions); 1505this.hadInitialPlaceholder=Boolean(input.getAttribute("placeholder")); 1506} 1507_init(){ 1508if(this.options.useFullscreenPopup){ 1509this.options.fixDropdownWidth=false; 1510} 1511if(this.options.separateDialCode){ 1512this.options.allowDropdown=true; 1513this.options.nationalMode=false; 1514} 1515if(!this.options.showFlags&&!this.options.separateDialCode){ 1516this.options.nationalMode=false; 1517} 1518if(this.options.useFullscreenPopup&&!this.options.dropdownContainer){ 1519this.options.dropdownContainer=document.body; 1520} 1521this.isRTL = !!this.telInput.closest("[dir=rtl]"); 1522this.options.i18n={ ...en_default, ...this.options.i18n }; 1523const autoCountryPromise=new Promise((resolve, reject)=> { 1524this.resolveAutoCountryPromise=resolve; 1525this.rejectAutoCountryPromise=reject; 1526}); 1527const utilsScriptPromise=new Promise((resolve, reject)=> { 1528this.resolveUtilsScriptPromise=resolve; 1529this.rejectUtilsScriptPromise=reject; 1530}); 1531this.promise=Promise.all([autoCountryPromise, utilsScriptPromise]); 1532this.selectedCountryData={}; 1533this._processCountryData(); 1534this._generateMarkup(); 1535this._setInitialState(); 1536this._initListeners(); 1537this._initRequests(); 1538} 1539_processCountryData(){ 1540this._processAllCountries(); 1541this._processDialCodes(); 1542this._translateCountryNames(); 1543if(this.options.countryOrder){ 1544this.options.countryOrder=this.options.countryOrder.map((country)=> country.toLowerCase()); 1545} 1546this._sortCountries(); 1547} 1548_sortCountries(){ 1549this.countries.sort((a, b)=> { 1550const { countryOrder }=this.options; 1551if(countryOrder){ 1552const aIndex=countryOrder.indexOf(a.iso2); 1553const bIndex=countryOrder.indexOf(b.iso2); 1554const aIndexExists=aIndex > -1; 1555const bIndexExists=bIndex > -1; 1556if(aIndexExists||bIndexExists){ 1557if(aIndexExists&&bIndexExists){ 1558return aIndex - bIndex; 1559} 1560return aIndexExists ? -1:1; 1561}} 1562if(a.name < b.name){ 1563return -1; 1564} 1565if(a.name > b.name){ 1566return 1; 1567} 1568return 0; 1569}); 1570} 1571_addToDialCodeMap(iso2, dialCode, priority){ 1572if(dialCode.length > this.dialCodeMaxLen){ 1573this.dialCodeMaxLen=dialCode.length; 1574} 1575if(!this.dialCodeToIso2Map.hasOwnProperty(dialCode)){ 1576this.dialCodeToIso2Map[dialCode]=[]; 1577} 1578for (let i=0; i < this.dialCodeToIso2Map[dialCode].length; i++){ 1579if(this.dialCodeToIso2Map[dialCode][i]===iso2){ 1580return; 1581}} 1582const index=priority!==void 0 ? priority:this.dialCodeToIso2Map[dialCode].length; 1583this.dialCodeToIso2Map[dialCode][index]=iso2; 1584} 1585_processAllCountries(){ 1586const { onlyCountries, excludeCountries }=this.options; 1587if(onlyCountries.length){ 1588const lowerCaseOnlyCountries=onlyCountries.map((country)=> country.toLowerCase() 1589); 1590this.countries=data_default.filter((country)=> lowerCaseOnlyCountries.indexOf(country.iso2) > -1 1591); 1592}else if(excludeCountries.length){ 1593const lowerCaseExcludeCountries=excludeCountries.map((country)=> country.toLowerCase() 1594); 1595this.countries=data_default.filter((country)=> lowerCaseExcludeCountries.indexOf(country.iso2)===-1 1596); 1597}else{ 1598this.countries=data_default; 1599}} 1600_translateCountryNames(){ 1601for (let i=0; i < this.countries.length; i++){ 1602const iso2=this.countries[i].iso2.toLowerCase(); 1603if(this.options.i18n.hasOwnProperty(iso2)){ 1604this.countries[i].name=this.options.i18n[iso2]; 1605}} 1606} 1607_processDialCodes(){ 1608this.dialCodes={}; 1609this.dialCodeMaxLen=0; 1610this.dialCodeToIso2Map={}; 1611for (let i=0; i < this.countries.length; i++){ 1612const c=this.countries[i]; 1613if(!this.dialCodes[c.dialCode]){ 1614this.dialCodes[c.dialCode]=true; 1615} 1616this._addToDialCodeMap(c.iso2, c.dialCode, c.priority); 1617} 1618for (let i=0; i < this.countries.length; i++){ 1619const c=this.countries[i]; 1620if(c.areaCodes){ 1621const rootIso2Code=this.dialCodeToIso2Map[c.dialCode][0]; 1622for (let j=0; j < c.areaCodes.length; j++){ 1623const areaCode=c.areaCodes[j]; 1624for (let k=1; k < areaCode.length; k++){ 1625const partialDialCode=c.dialCode + areaCode.substr(0, k); 1626this._addToDialCodeMap(rootIso2Code, partialDialCode); 1627this._addToDialCodeMap(c.iso2, partialDialCode); 1628} 1629this._addToDialCodeMap(c.iso2, c.dialCode + areaCode); 1630}} 1631}} 1632_generateMarkup(){ 1633this.telInput.classList.add("iti__tel-input"); 1634if(!this.telInput.hasAttribute("autocomplete")&&!(this.telInput.form&&this.telInput.form.hasAttribute("autocomplete"))){ 1635this.telInput.setAttribute("autocomplete", "off"); 1636} 1637const { 1638allowDropdown, 1639separateDialCode, 1640showFlags, 1641containerClass, 1642hiddenInput, 1643dropdownContainer, 1644fixDropdownWidth, 1645useFullscreenPopup, 1646i18n 1647}=this.options; 1648let parentClass="iti"; 1649if(allowDropdown){ 1650parentClass +=" iti--allow-dropdown"; 1651} 1652if(showFlags){ 1653parentClass +=" iti--show-flags"; 1654} 1655if(containerClass){ 1656parentClass +=` ${containerClass}`; 1657} 1658if(!useFullscreenPopup){ 1659parentClass +=" iti--inline-dropdown"; 1660} 1661const wrapper=createEl("div", { class: parentClass }); 1662this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
1663if(allowDropdown||showFlags){ 1664this.countryContainer=createEl( 1665"div", 1666{ class: "iti__country-container" }, 1667wrapper 1668); 1669this.selectedCountry=createEl( 1670"div", 1671{ 1672type: "div", 1673class: "iti__selected-country", 1674...allowDropdown&&{ 1675"aria-expanded": "false", 1676"aria-label": this.options.i18n.selectedCountryAriaLabel, 1677"aria-haspopup": "true", 1678"aria-controls": `iti-${this.id}__dropdown-content`, 1679"role": "combobox" 1680}}, 1681this.countryContainer 1682); 1683const selectedCountryPrimary=createEl("div", { class: "iti__selected-country-primary" }, this.selectedCountry); 1684this.selectedCountryInner=createEl("div", null, selectedCountryPrimary); 1685this.selectedCountryA11yText=createEl( 1686"span", 1687{ class: "iti__a11y-text" }, 1688this.selectedCountryInner 1689); 1690if(this.telInput.disabled){ 1691this.selectedCountry.setAttribute("aria-disabled", "true"); 1692}else{ 1693this.selectedCountry.setAttribute("tabindex", "0"); 1694} 1695if(allowDropdown){ 1696this.dropdownArrow=createEl( 1697"div", 1698{ class: "iti__arrow", "aria-hidden": "true" }, 1699selectedCountryPrimary 1700); 1701} 1702if(separateDialCode){ 1703this.selectedDialCode=createEl( 1704"div", 1705{ class: "iti__selected-dial-code" }, 1706this.selectedCountry 1707); 1708} 1709if(allowDropdown){ 1710const extraClasses=fixDropdownWidth ? "":"iti--flexible-dropdown-width"; 1711this.dropdownContent=createEl("div", { 1712id: `iti-${this.id}__dropdown-content`, 1713class: `iti__dropdown-content iti__hide ${extraClasses}` 1714}); 1715this.searchInput=createEl( 1716"input", 1717{ 1718type: "text", 1719class: "iti__search-input", 1720placeholder: i18n.searchPlaceholder, 1721role: "combobox", 1722"aria-expanded": "true", 1723"aria-label": i18n.searchPlaceholder, 1724"aria-controls": `iti-${this.id}__country-listbox`, 1725"aria-autocomplete": "list", 1726"autocomplete": "off" 1727}, 1728this.dropdownContent 1729); 1730this.searchResultsA11yText=createEl( 1731"span", 1732{ class: "iti__a11y-text" }, 1733this.dropdownContent 1734); 1735this.countryList=createEl( 1736"ul", 1737{ 1738class: "iti__country-list", 1739id: `iti-${this.id}__country-listbox`, 1740role: "listbox", 1741"aria-label": i18n.countryListAriaLabel 1742}, 1743this.dropdownContent 1744); 1745this._appendListItems(this.countries, "iti__standard"); 1746this._updateSearchResultsText(); 1747if(dropdownContainer){ 1748let dropdownClasses="iti iti--container"; 1749if(useFullscreenPopup){ 1750dropdownClasses +=" iti--fullscreen-popup"; 1751}else{ 1752dropdownClasses +=" iti--inline-dropdown"; 1753} 1754this.dropdown=createEl("div", { class: dropdownClasses }); 1755this.dropdown.appendChild(this.dropdownContent); 1756}else{ 1757this.countryContainer.appendChild(this.dropdownContent); 1758}} 1759} 1760wrapper.appendChild(this.telInput); 1761if(hiddenInput){ 1762const telInputName=this.telInput.getAttribute("name")||""; 1763const names=hiddenInput(telInputName); 1764if(names.phone){ 1765this.hiddenInput=createEl("input", { 1766type: "hidden", 1767name: names.phone 1768}); 1769wrapper.appendChild(this.hiddenInput); 1770} 1771if(names.country){ 1772this.hiddenInputCountry=createEl("input", { 1773type: "hidden", 1774name: names.country 1775}); 1776wrapper.appendChild(this.hiddenInputCountry); 1777}} 1778} 1779_appendListItems(countries, className){ 1780for (let i=0; i < countries.length; i++){ 1781const c=countries[i]; 1782const listItem=createEl( 1783"li", 1784{ 1785id: `iti-${this.id}__item-${c.iso2}`, 1786class: `iti__country ${className}`, 1787tabindex: "-1", 1788role: "option", 1789"data-dial-code": c.dialCode, 1790"data-country-code": c.iso2, 1791"aria-selected": "false" 1792}, 1793this.countryList 1794); 1795c.nodeById[this.id]=listItem; 1796let content=""; 1797if(this.options.showFlags){ 1798content +=`<div class='iti__flag-box'><div class='iti__flag iti__${c.iso2}'></div></div>`; 1799} 1800content +=`<span class='iti__country-name'>${c.name}</span>`; 1801content +=`<span class='iti__dial-code'>+${c.dialCode}</span>`; 1802listItem.insertAdjacentHTML("beforeend", content); 1803}} 1804_setInitialState(overrideAutoCountry=false){ 1805const attributeValue=this.telInput.getAttribute("value"); 1806const inputValue=this.telInput.value; 1807const useAttribute=attributeValue&&attributeValue.charAt(0)==="+"&&(!inputValue||inputValue.charAt(0)!=="+"); 1808const val=useAttribute ? attributeValue:inputValue; 1809const dialCode=this._getDialCode(val); 1810const isRegionlessNanpNumber=isRegionlessNanp(val); 1811const { initialCountry }=this.options; 1812if(dialCode&&!isRegionlessNanpNumber){ 1813this._updateCountryFromNumber(val); 1814}else if(initialCountry!=="auto"||overrideAutoCountry){ 1815const lowerInitialCountry=initialCountry ? initialCountry.toLowerCase():""; 1816const isValidInitialCountry=lowerInitialCountry&&this._getCountryData(lowerInitialCountry, true); 1817if(isValidInitialCountry){ 1818this._setCountry(lowerInitialCountry); 1819}else{ 1820if(dialCode&&isRegionlessNanpNumber){ 1821this._setCountry("us"); 1822}else{ 1823this._setCountry(); 1824}} 1825} 1826if(val){
1827this._updateValFromNumber(val); 1828}} 1829_initListeners(){ 1830this._initTelInputListeners(); 1831if(this.options.allowDropdown){ 1832this._initDropdownListeners(); 1833} 1834if((this.hiddenInput||this.hiddenInputCountry)&&this.telInput.form){ 1835this._initHiddenInputListener(); 1836}} 1837_initHiddenInputListener(){ 1838this._handleHiddenInputSubmit=()=> { 1839if(this.hiddenInput){ 1840this.hiddenInput.value=this.getNumber(); 1841} 1842if(this.hiddenInputCountry){ 1843this.hiddenInputCountry.value=this.getSelectedCountryData().iso2||""; 1844}}; 1845this.telInput.form?.addEventListener("submit", 1846this._handleHiddenInputSubmit 1847); 1848} 1849_initDropdownListeners(){ 1850this._handleLabelClick=(e)=> { 1851if(this.dropdownContent.classList.contains("iti__hide")){ 1852this.telInput.focus(); 1853}else{ 1854e.preventDefault(); 1855}}; 1856const label=this.telInput.closest("label"); 1857if(label){ 1858label.addEventListener("click", this._handleLabelClick); 1859} 1860this._handleClickSelectedCountry=()=> { 1861if(this.dropdownContent.classList.contains("iti__hide")&&!this.telInput.disabled&&!this.telInput.readOnly){ 1862this._openDropdown(); 1863}}; 1864this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry); 1865this._handleCountryContainerKeydown=(e)=> { 1866const isDropdownHidden=this.dropdownContent.classList.contains("iti__hide"); 1867if(isDropdownHidden&&["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)){ 1868e.preventDefault(); 1869e.stopPropagation(); 1870this._openDropdown(); 1871} 1872if(e.key==="Tab"){ 1873this._closeDropdown(); 1874}}; 1875this.countryContainer.addEventListener("keydown", 1876this._handleCountryContainerKeydown 1877); 1878} 1879_initRequests(){ 1880if(this.options.utilsScript&&!intlTelInput.utils){ 1881if(intlTelInput.documentReady()){ 1882intlTelInput.loadUtils(this.options.utilsScript); 1883}else{ 1884window.addEventListener("load", ()=> { 1885intlTelInput.loadUtils(this.options.utilsScript); 1886}); 1887}}else{ 1888this.resolveUtilsScriptPromise(); 1889} 1890if(this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2){ 1891this._loadAutoCountry(); 1892}else{ 1893this.resolveAutoCountryPromise(); 1894}} 1895_loadAutoCountry(){ 1896if(intlTelInput.autoCountry){ 1897this.handleAutoCountry(); 1898}else if(!intlTelInput.startedLoadingAutoCountry){ 1899intlTelInput.startedLoadingAutoCountry=true; 1900if(typeof this.options.geoIpLookup==="function"){ 1901this.options.geoIpLookup((iso2="")=> { 1902const iso2Lower=iso2.toLowerCase(); 1903const isValidIso2=iso2Lower&&this._getCountryData(iso2Lower, true); 1904if(isValidIso2){ 1905intlTelInput.autoCountry=iso2Lower; 1906setTimeout(()=> forEachInstance("handleAutoCountry")); 1907}else{ 1908this._setInitialState(true); 1909forEachInstance("rejectAutoCountryPromise"); 1910}}, 1911()=> { 1912this._setInitialState(true); 1913forEachInstance("rejectAutoCountryPromise"); 1914} 1915); 1916}} 1917} 1918_initTelInputListeners(){ 1919const { strictMode, formatAsYouType, separateDialCode }=this.options; 1920let userOverrideFormatting=false; 1921this._handleInputEvent=(e)=> { 1922if(this._updateCountryFromNumber(this.telInput.value)){ 1923this._triggerCountryChange(); 1924} 1925const isFormattingChar=e&&e.data&&/[^+0-9]/.test(e.data); 1926const isPaste=e&&e.inputType==="insertFromPaste"&&this.telInput.value; 1927if(isFormattingChar||isPaste&&!strictMode){ 1928userOverrideFormatting=true; 1929}else if(!/[^+0-9]/.test(this.telInput.value)){ 1930userOverrideFormatting=false; 1931} 1932if(formatAsYouType&&!userOverrideFormatting){ 1933const currentCaretPos=this.telInput.selectionStart||0; 1934const valueBeforeCaret=this.telInput.value.substring(0, currentCaretPos); 1935const relevantCharsBeforeCaret=valueBeforeCaret.replace(/[^+0-9]/g, "").length; 1936const isDeleteForwards=e&&e.inputType==="deleteContentForward"; 1937const formattedValue=this._formatNumberAsYouType(); 1938const newCaretPos=translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards); 1939this.telInput.value=formattedValue; 1940this.telInput.setSelectionRange(newCaretPos, newCaretPos); 1941}}; 1942this.telInput.addEventListener("input", this._handleInputEvent); 1943if(strictMode||separateDialCode){ 1944this._handleKeydownEvent=(e)=> { 1945if(e.key&&e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){ 1946if(separateDialCode&&e.key==="+"){ 1947e.preventDefault(); 1948this._openDropdown(); 1949this.searchInput.value="+"; 1950this._filterCountries("", true); 1951return; 1952} 1953if(strictMode){ 1954const isInitialPlus=this.telInput.selectionStart===0&&e.key==="+"; 1955const isNumeric=/^[0-9]$/.test(e.key); 1956const isAllowedChar=isInitialPlus||isNumeric; 1957const fullNumber=this._getFullNumber(); 1958const coreNumber=intlTelInput.utils.getCoreNumber(fullNumber, this.selectedCountryData.iso2); 1959const hasReachedMaxLength=this.maxCoreNumberLength&&coreNumber.length >=this.maxCoreNumberLength; 1960const selectedText=this.telInput.value.substring(this.telInput.selectionStart, this.telInput.selectionEnd); 1961const hasSelectedDigit=/\d/.test(selectedText); 1962if(!isAllowedChar||hasReachedMaxLength&&!hasSelectedDigit){ 1963e.preventDefault(); 1964}} 1965}}; 1966this.telInput.addEventListener("keydown", this._handleKeydownEvent); 1967}} 1968_cap(number){ 1969const max=parseInt(this.telInput.getAttribute("maxlength")||"", 10); 1970return max&&number.length > max ? number.substr(0, max):number; 1971} 1972_trigger(name){ 1973const e=new Event(name, { 1974bubbles: true, 1975cancelable: true 1976}); 1977this.telInput.dispatchEvent(e); 1978} 1979_openDropdown(){ 1980const { fixDropdownWidth }=this.options; 1981if(fixDropdownWidth){ 1982this.dropdownContent.style.width=`${this.telInput.offsetWidth}px`; 1983} 1984this.dropdownContent.classList.remove("iti__hide"); 1985this.selectedCountry.setAttribute("aria-expanded", "true"); 1986this._setDropdownPosition(); 1987const firstCountryItem=this.countryList.firstElementChild; 1988if(firstCountryItem){ 1989this._highlightListItem(firstCountryItem, false); 1990this.countryList.scrollTop=0; 1991} 1992this.searchInput.focus(); 1993this._bindDropdownListeners(); 1994this.dropdownArrow.classList.add("iti__arrow--up"); 1995this._trigger("open:countrydropdown"); 1996} 1997_setDropdownPosition(){ 1998if(this.options.dropdownContainer){ 1999this.options.dropdownContainer.appendChild(this.dropdown); 2000} 2001if(!this.options.useFullscreenPopup){ 2002const inputPosRelativeToVP=this.telInput.getBoundingClientRect(); 2003const inputHeight=this.telInput.offsetHeight; 2004if(this.options.dropdownContainer){ 2005this.dropdown.style.top=`${inputPosRelativeToVP.top + inputHeight}px`; 2006this.dropdown.style.left=`${inputPosRelativeToVP.left}px`; 2007this._handleWindowScroll=()=> this._closeDropdown(); 2008window.addEventListener("scroll", this._handleWindowScroll); 2009}} 2010} 2011_bindDropdownListeners(){ 2012this._handleMouseoverCountryList=(e)=>
2012 { 2013const listItem=e.target?.closest(".iti__country"); 2014if(listItem){ 2015this._highlightListItem(listItem, false); 2016}}; 2017this.countryList.addEventListener("mouseover", 2018this._handleMouseoverCountryList 2019); 2020this._handleClickCountryList=(e)=> { 2021const listItem=e.target?.closest(".iti__country"); 2022if(listItem){ 2023this._selectListItem(listItem); 2024}}; 2025this.countryList.addEventListener("click", this._handleClickCountryList); 2026let isOpening=true; 2027this._handleClickOffToClose=()=> { 2028if(!isOpening){ 2029this._closeDropdown(); 2030} 2031isOpening=false; 2032}; 2033document.documentElement.addEventListener("click", 2034this._handleClickOffToClose 2035); 2036this._handleKeydownOnDropdown=(e)=> { 2037if(["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)){ 2038e.preventDefault(); 2039e.stopPropagation(); 2040if(e.key==="ArrowUp"||e.key==="ArrowDown"){ 2041this._handleUpDownKey(e.key); 2042}else if(e.key==="Enter"){ 2043this._handleEnterKey(); 2044}else if(e.key==="Escape"){ 2045this._closeDropdown(); 2046}} 2047}; 2048document.addEventListener("keydown", this._handleKeydownOnDropdown); 2049const doFilter=()=> { 2050const inputQuery=this.searchInput.value.trim(); 2051if(inputQuery){ 2052this._filterCountries(inputQuery); 2053}else{ 2054this._filterCountries("", true); 2055}}; 2056let keyupTimer=null; 2057this._handleSearchChange=()=> { 2058if(keyupTimer){ 2059clearTimeout(keyupTimer); 2060} 2061keyupTimer=setTimeout(()=> { 2062doFilter(); 2063keyupTimer=null; 2064}, 100); 2065}; 2066this.searchInput.addEventListener("input", this._handleSearchChange); 2067this.searchInput.addEventListener("click", (e)=> e.stopPropagation()); 2068} 2069_filterCountries(query, isReset=false){ 2070let noCountriesAddedYet=true; 2071this.countryList.innerHTML=""; 2072const normalisedQuery=normaliseString(query); 2073for (let i=0; i < this.countries.length; i++){ 2074const c=this.countries[i]; 2075const normalisedCountryName=normaliseString(c.name); 2076const fullDialCode=`+${c.dialCode}`; 2077if(isReset||normalisedCountryName.includes(normalisedQuery)||fullDialCode.includes(normalisedQuery)||c.iso2.includes(normalisedQuery)){ 2078const listItem=c.nodeById[this.id]; 2079if(listItem){ 2080this.countryList.appendChild(listItem); 2081} 2082if(noCountriesAddedYet){ 2083this._highlightListItem(listItem, false); 2084noCountriesAddedYet=false; 2085}} 2086} 2087if(noCountriesAddedYet){ 2088this._highlightListItem(null, false); 2089} 2090this.countryList.scrollTop=0; 2091this._updateSearchResultsText(); 2092} 2093_updateSearchResultsText(){ 2094const { i18n }=this.options; 2095const count=this.countryList.childElementCount; 2096let searchText; 2097if(count===0){ 2098searchText=i18n.zeroSearchResults; 2099}else if(count===1){ 2100searchText=i18n.oneSearchResult; 2101}else{ 2102searchText=i18n.multipleSearchResults.replace("${count}", count.toString()); 2103} 2104this.searchResultsA11yText.textContent=searchText; 2105} 2106_handleUpDownKey(key){ 2107let next=key==="ArrowUp" ? this.highlightedItem?.previousElementSibling:this.highlightedItem?.nextElementSibling; 2108if(!next&&this.countryList.childElementCount > 1){ 2109next=key==="ArrowUp" ? this.countryList.lastElementChild:this.countryList.firstElementChild; 2110} 2111if(next){ 2112this._scrollTo(next); 2113this._highlightListItem(next, false); 2114}} 2115_handleEnterKey(){ 2116if(this.highlightedItem){ 2117this._selectListItem(this.highlightedItem); 2118}} 2119_updateValFromNumber(fullNumber){ 2120let number=fullNumber; 2121if(this.options.formatOnDisplay&&intlTelInput.utils&&this.selectedCountryData){ 2122const useNational=this.options.nationalMode||number.charAt(0)!=="+"&&!this.options.separateDialCode; 2123const { NATIONAL, INTERNATIONAL }=intlTelInput.utils.numberFormat; 2124const format=useNational ? NATIONAL:INTERNATIONAL; 2125number=intlTelInput.utils.formatNumber(number, 2126this.selectedCountryData.iso2, 2127format 2128); 2129} 2130number=this._beforeSetNumber(number); 2131this.telInput.value=number; 2132} 2133_updateCountryFromNumber(fullNumber){ 2134const plusIndex=fullNumber.indexOf("+"); 2135let number=plusIndex ? fullNumber.substring(plusIndex):fullNumber; 2136const selectedDialCode=this.selectedCountryData.dialCode; 2137const isNanp=selectedDialCode==="1"; 2138if(number&&isNanp&&number.charAt(0)!=="+"){ 2139if(number.charAt(0)!=="1"){ 2140number=`1${number}`; 2141} 2142number=`+${number}`; 2143} 2144if(this.options.separateDialCode&&selectedDialCode&&number.charAt(0)!=="+"){ 2145number=`+${selectedDialCode}${number}`; 2146} 2147const dialCode=this._getDialCode(number, true); 2148const numeric=getNumeric(number); 2149let iso2=null; 2150if(dialCode){ 2151const iso2Codes=this.dialCodeToIso2Map[getNumeric(dialCode)]; 2152const alreadySelected=iso2Codes.indexOf(this.selectedCountryData.iso2)!==-1&&numeric.length <=dialCode.length - 1; 2153const isRegionlessNanpNumber=selectedDialCode==="1"&&isRegionlessNanp(numeric); 2154if(!isRegionlessNanpNumber&&!alreadySelected){ 2155for (let j=0; j < iso2Codes.length; j++){ 2156if(iso2Codes[j]){ 2157iso2=iso2Codes[j]; 2158break; 2159}} 2160}}
2160else if(number.charAt(0)==="+"&&numeric.length){ 2161iso2=""; 2162}else if((!number||number==="+")&&!this.selectedCountryData.iso2){ 2163iso2=this.defaultCountry; 2164} 2165if(iso2!==null){ 2166return this._setCountry(iso2); 2167} 2168return false; 2169} 2170_highlightListItem(listItem, shouldFocus){ 2171const prevItem=this.highlightedItem; 2172if(prevItem){ 2173prevItem.classList.remove("iti__highlight"); 2174prevItem.setAttribute("aria-selected", "false"); 2175} 2176this.highlightedItem=listItem; 2177if(this.highlightedItem){ 2178this.highlightedItem.classList.add("iti__highlight"); 2179this.highlightedItem.setAttribute("aria-selected", "true"); 2180const activeDescendant=this.highlightedItem.getAttribute("id")||""; 2181this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant); 2182this.searchInput.setAttribute("aria-activedescendant", activeDescendant); 2183} 2184if(shouldFocus){ 2185this.highlightedItem.focus(); 2186}} 2187_getCountryData(iso2, allowFail){ 2188for (let i=0; i < this.countries.length; i++){ 2189if(this.countries[i].iso2===iso2){ 2190return this.countries[i]; 2191}} 2192if(allowFail){ 2193return null; 2194} 2195throw new Error(`No country data for '${iso2}'`); 2196} 2197_setCountry(iso2){ 2198const { separateDialCode, showFlags, i18n }=this.options; 2199const prevCountry=this.selectedCountryData.iso2 ? this.selectedCountryData:{}; 2200this.selectedCountryData=iso2 ? this._getCountryData(iso2, false)||{}:{}; 2201if(this.selectedCountryData.iso2){ 2202this.defaultCountry=this.selectedCountryData.iso2; 2203} 2204if(this.selectedCountryInner){ 2205let flagClass=""; 2206let a11yText=""; 2207if(iso2&&showFlags){ 2208flagClass=`iti__flag iti__${iso2}`; 2209a11yText=`${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`; 2210}else{ 2211flagClass="iti__flag iti__globe"; 2212a11yText=i18n.noCountrySelected; 2213} 2214this.selectedCountryInner.className=flagClass; 2215this.selectedCountryA11yText.textContent=a11yText; 2216} 2217this._setSelectedCountryTitleAttribute(iso2, separateDialCode); 2218if(separateDialCode){ 2219const dialCode=this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}`:""; 2220this.selectedDialCode.innerHTML=dialCode; 2221const selectedCountryWidth=this.selectedCountry.offsetWidth||this._getHiddenSelectedCountryWidth(); 2222const inputPadding=selectedCountryWidth + 8; 2223if(this.isRTL){ 2224this.telInput.style.paddingRight=`${inputPadding}px`; 2225}else{ 2226this.telInput.style.paddingLeft=`${inputPadding}px`; 2227}} 2228this._updatePlaceholder(); 2229this._updateMaxLength(); 2230return prevCountry.iso2!==iso2; 2231} 2232_updateMaxLength(){ 2233const { strictMode, placeholderNumberType, validationNumberType }=this.options; 2234if(strictMode&&intlTelInput.utils){ 2235if(this.selectedCountryData.iso2){ 2236const numberType=intlTelInput.utils.numberType[placeholderNumberType]; 2237let exampleNumber=intlTelInput.utils.getExampleNumber(this.selectedCountryData.iso2, 2238false, 2239numberType, 2240true 2241); 2242let validNumber=exampleNumber; 2243while (intlTelInput.utils.isPossibleNumber(exampleNumber, this.selectedCountryData.iso2, validationNumberType)){ 2244validNumber=exampleNumber; 2245exampleNumber +="0"; 2246} 2247const coreNumber=intlTelInput.utils.getCoreNumber(validNumber, this.selectedCountryData.iso2); 2248this.maxCoreNumberLength=coreNumber.length; 2249}else{ 2250this.maxCoreNumberLength=null; 2251}} 2252} 2253_setSelectedCountryTitleAttribute(iso2=null, separateDialCode){ 2254if(!this.selectedCountry){ 2255return; 2256} 2257let title; 2258if(iso2&&!separateDialCode){ 2259title=`${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}`; 2260}else if(iso2){ 2261title=this.selectedCountryData.name; 2262}else{ 2263title="Unknown"; 2264} 2265this.selectedCountry.setAttribute("title", title); 2266} 2267_getHiddenSelectedCountryWidth(){ 2268if(this.telInput.parentNode){ 2269const containerClone=this.telInput.parentNode.cloneNode(false); 2270containerClone.style.visibility="hidden"; 2271document.body.appendChild(containerClone); 2272const countryContainerClone=this.countryContainer.cloneNode(); 2273containerClone.appendChild(countryContainerClone); 2274const selectedCountryClone=this.selectedCountry.cloneNode(true); 2275countryContainerClone.appendChild(selectedCountryClone); 2276const width=selectedCountryClone.offsetWidth; 2277document.body.removeChild(containerClone); 2278return width; 2279} 2280return 0; 2281} 2282_updatePlaceholder(){ 2283const { 2284autoPlaceholder, 2285placeholderNumberType, 2286nationalMode, 2287customPlaceholder 2288}=this.options; 2289const shouldSetPlaceholder=autoPlaceholder==="aggressive"||!this.hadInitialPlaceholder&&autoPlaceholder==="polite"; 2290if(intlTelInput.utils&&shouldSetPlaceholder){ 2291const numberType=intlTelInput.utils.numberType[placeholderNumberType]; 2292let placeholder=this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(this.selectedCountryData.iso2, 2293nationalMode, 2294numberType 2295):""; 2296placeholder=this._beforeSetNumber(placeholder); 2297if(typeof customPlaceholder==="function"){ 2298placeholder=customPlaceholder(placeholder, this.selectedCountryData); 2299} 2300this.telInput.setAttribute("placeholder", placeholder); 2301}} 2302_selectListItem(listItem){ 2303const countryChanged=this._setCountry(listItem.getAttribute("data-country-code") 2304); 2305this._closeDropdown(); 2306this._updateDialCode(listItem.getAttribute("data-dial-code")); 2307this.telInput.focus(); 2308if(countryChanged){ 2309this._triggerCountryChange(); 2310}} 2311_closeDropdown(){ 2312this.dropdownContent.classList.add("iti__hide"); 2313this.selectedCountry.setAttribute("aria-expanded", "false"); 2314this.selectedCountry.removeAttribute("aria-activedescendant"); 2315if(this.highlightedItem){ 2316this.highlightedItem.setAttribute("aria-selected", "false"); 2317} 2318this.searchInput.removeAttribute("aria-activedescendant"); 2319this.dropdownArrow.classList.remove("iti__arrow--up"); 2320document.removeEventListener("keydown", this._handleKeydownOnDropdown); 2321this.searchInput.removeEventListener("input", this._handleSearchChange); 2322document.documentElement.removeEventListener("click", 2323this._handleClickOffToClose 2324); 2325this.countryList.removeEventListener("mouseover", 2326this._handleMouseoverCountryList 2327); 2328this.countryList.removeEventListener("click", this._handleClickCountryList); 2329if(this.options.dropdownContainer){ 2330if(!this.options.useFullscreenPopup){ 2331window.removeEventListener("scroll", this._handleWindowScroll); 2332} 2333if(this.dropdown.parentNode){ 2334this.dropdown.parentNode.removeChild(this.dropdown); 2335}} 2336this._trigger("close:countrydropdown"); 2337} 2338_scrollTo(element){ 2339const container=this.countryList; 2340const scrollTop=document.documentElement.scrollTop; 2341const containerHeight=container.offsetHeight; 2342const containerTop=container.getBoundingClientRect().top + scrollTop; 2343const containerBottom=containerTop + containerHeight; 2344const elementHeight=element.offsetHeight; 2345const elementTop=element.getBoundingClientRect().top + scrollTop; 2346const elementBottom=elementTop + elementHeight; 2347const newScrollTop=elementTop - containerTop + container.scrollTop;
2348if(elementTop < containerTop){ 2349container.scrollTop=newScrollTop; 2350}else if(elementBottom > containerBottom){ 2351const heightDifference=containerHeight - elementHeight; 2352container.scrollTop=newScrollTop - heightDifference; 2353}} 2354_updateDialCode(newDialCodeBare){ 2355const inputVal=this.telInput.value; 2356const newDialCode=`+${newDialCodeBare}`; 2357let newNumber; 2358if(inputVal.charAt(0)==="+"){ 2359const prevDialCode=this._getDialCode(inputVal); 2360if(prevDialCode){ 2361newNumber=inputVal.replace(prevDialCode, newDialCode); 2362}else{ 2363newNumber=newDialCode; 2364} 2365this.telInput.value=newNumber; 2366}} 2367_getDialCode(number, includeAreaCode){ 2368let dialCode=""; 2369if(number.charAt(0)==="+"){ 2370let numericChars=""; 2371for (let i=0; i < number.length; i++){ 2372const c=number.charAt(i); 2373if(!isNaN(parseInt(c, 10))){ 2374numericChars +=c; 2375if(includeAreaCode){ 2376if(this.dialCodeToIso2Map[numericChars]){ 2377dialCode=number.substr(0, i + 1); 2378}}else{ 2379if(this.dialCodes[numericChars]){ 2380dialCode=number.substr(0, i + 1); 2381break; 2382}} 2383if(numericChars.length===this.dialCodeMaxLen){ 2384break; 2385}} 2386}} 2387return dialCode; 2388} 2389_getFullNumber(){ 2390const val=this.telInput.value.trim(); 2391const { dialCode }=this.selectedCountryData; 2392let prefix; 2393const numericVal=getNumeric(val); 2394if(this.options.separateDialCode&&val.charAt(0)!=="+"&&dialCode&&numericVal){ 2395prefix=`+${dialCode}`; 2396}else{ 2397prefix=""; 2398} 2399return prefix + val; 2400} 2401_beforeSetNumber(fullNumber){ 2402let number=fullNumber; 2403if(this.options.separateDialCode){ 2404let dialCode=this._getDialCode(number); 2405if(dialCode){ 2406dialCode=`+${this.selectedCountryData.dialCode}`; 2407const start=number[dialCode.length]===" "||number[dialCode.length]==="-" ? dialCode.length + 1:dialCode.length; 2408number=number.substr(start); 2409}} 2410return this._cap(number); 2411} 2412_triggerCountryChange(){ 2413this._trigger("countrychange"); 2414} 2415_formatNumberAsYouType(){ 2416const val=this._getFullNumber(); 2417const result=intlTelInput.utils ? intlTelInput.utils.formatNumberAsYouType(val, this.selectedCountryData.iso2):val; 2418const { dialCode }=this.selectedCountryData; 2419if(this.options.separateDialCode&&this.telInput.value.charAt(0)!=="+"&&result.includes(`+${dialCode}`)){ 2420const afterDialCode=result.split(`+${dialCode}`)[1]||""; 2421return afterDialCode.trim(); 2422} 2423return result; 2424} 2425handleAutoCountry(){ 2426if(this.options.initialCountry==="auto"&&intlTelInput.autoCountry){ 2427this.defaultCountry=intlTelInput.autoCountry; 2428if(!this.telInput.value){ 2429this.setCountry(this.defaultCountry); 2430} 2431this.resolveAutoCountryPromise(); 2432}} 2433handleUtils(){ 2434if(intlTelInput.utils){ 2435if(this.telInput.value){ 2436this._updateValFromNumber(this.telInput.value); 2437} 2438if(this.selectedCountryData.iso2){ 2439this._updatePlaceholder(); 2440this._updateMaxLength(); 2441}} 2442this.resolveUtilsScriptPromise(); 2443} 2444destroy(){ 2445if(this.options.allowDropdown){ 2446this._closeDropdown(); 2447this.selectedCountry.removeEventListener("click", 2448this._handleClickSelectedCountry 2449); 2450this.countryContainer.removeEventListener("keydown", 2451this._handleCountryContainerKeydown 2452); 2453const label=this.telInput.closest("label"); 2454if(label){ 2455label.removeEventListener("click", this._handleLabelClick); 2456}} 2457const { form }=this.telInput; 2458if(this._handleHiddenInputSubmit&&form){ 2459form.removeEventListener("submit", this._handleHiddenInputSubmit); 2460} 2461this.telInput.removeEventListener("input", this._handleInputEvent); 2462if(this._handleKeydownEvent){ 2463this.telInput.removeEventListener("keydown", this._handleKeydownEvent); 2464} 2465this.telInput.removeAttribute("data-intl-tel-input-id"); 2466const wrapper=this.telInput.parentNode; 2467wrapper?.parentNode?.insertBefore(this.telInput, wrapper); 2468wrapper?.parentNode?.removeChild(wrapper); 2469delete intlTelInput.instances[this.id]; 2470} 2471getExtension(){ 2472if(intlTelInput.utils){ 2473return intlTelInput.utils.getExtension(this._getFullNumber(), 2474this.selectedCountryData.iso2 2475); 2476} 2477return ""; 2478} 2479getNumber(format){ 2480if(intlTelInput.utils){ 2481const { iso2 }=this.selectedCountryData; 2482return intlTelInput.utils.formatNumber(this._getFullNumber(), 2483iso2, 2484format 2485); 2486} 2487return ""; 2488} 2489getNumberType(){ 2490if(intlTelInput.utils){ 2491return intlTelInput.utils.getNumberType(this._getFullNumber(), 2492this.selectedCountryData.iso2 2493); 2494} 2495return -99; 2496} 2497getSelectedCountryData(){ 2498return this.selectedCountryData; 2499} 2500getValidationError(){ 2501if(intlTelInput.utils){ 2502const { iso2 }=this.selectedCountryData; 2503return intlTelInput.utils.getValidationError(this._getFullNumber(), iso2); 2504} 2505return -99; 2506} 2507isValidNumber(){ 2508const val=this._getFullNumber(); 2509if(/\p{L}/u.test(val)){ 2510return false;
2511} 2512return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType):null; 2513} 2514isValidNumberPrecise(){ 2515const val=this._getFullNumber(); 2516if(/\p{L}/u.test(val)){ 2517return false; 2518} 2519return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2):null; 2520} 2521setCountry(iso2){ 2522const iso2Lower=iso2.toLowerCase(); 2523if(this.selectedCountryData.iso2!==iso2Lower){ 2524this._setCountry(iso2Lower); 2525this._updateDialCode(this.selectedCountryData.dialCode); 2526this._triggerCountryChange(); 2527}} 2528setNumber(number){ 2529const countryChanged=this._updateCountryFromNumber(number); 2530this._updateValFromNumber(number); 2531if(countryChanged){ 2532this._triggerCountryChange(); 2533}} 2534setPlaceholderNumberType(type){ 2535this.options.placeholderNumberType=type; 2536this._updatePlaceholder(); 2537}}; 2538var loadUtils=(path)=> { 2539if(!intlTelInput.utils&&!intlTelInput.startedLoadingUtilsScript){ 2540intlTelInput.startedLoadingUtilsScript=true; 2541return new Promise((resolve, reject)=> { 2542import( 2543path 2544).then(({ default: utils })=> { 2545intlTelInput.utils=utils; 2546forEachInstance("handleUtils"); 2547resolve(true); 2548}).catch(()=> { 2549forEachInstance("rejectUtilsScriptPromise"); 2550reject(); 2551}); 2552}); 2553} 2554return null; 2555}; 2556var intlTelInput=Object.assign((input, options)=> { 2557const iti=new Iti(input, options); 2558iti._init(); 2559input.setAttribute("data-intl-tel-input-id", iti.id.toString()); 2560intlTelInput.instances[iti.id]=iti; 2561return iti; 2562}, 2563{ 2564defaults, 2565documentReady: ()=> document.readyState==="complete", 2566getCountryData: ()=> data_default, 2567getInstance: (input)=> { 2568const id2=input.getAttribute("data-intl-tel-input-id"); 2569return id2 ? intlTelInput.instances[id2]:null; 2570}, 2571instances: {}, 2572loadUtils, 2573version: "23.0.7" 2574} 2575); 2576var intl_tel_input_default=intlTelInput; 2577return __toCommonJS(intl_tel_input_exports); 2578})(); 2579return factoryOutput.default; 2580}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.