intl-tel-input 23.0.4 → 23.0.5

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