From c251a965054a7bd944731ec460c16dcf0a005009 Mon Sep 17 00:00:00 2001 From: Jack OConnor Date: Mon, 26 Feb 2024 17:38:49 +0000 Subject: [PATCH] Release v19.5.3 --- README.md | 6 +++--- build/js/data.js | 2 +- build/js/data.min.js | 2 +- build/js/intlTelInput-jquery.js | 4 ++-- build/js/intlTelInput-jquery.min.js | 4 ++-- build/js/intlTelInput.js | 4 ++-- build/js/intlTelInput.min.js | 4 ++-- composer.json | 2 +- package-lock.json | 2 +- package.json | 2 +- react/build/IntlTelInput.cjs.js | 2 +- react/build/IntlTelInput.cjs.js.map | 2 +- react/build/IntlTelInput.esm.js | 2 +- react/build/IntlTelInput.esm.js.map | 2 +- react/demo/simple-bundle.js | 2 +- react/demo/validation-bundle.js | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 295fa68cf..90a9bfce6 100644 --- a/README.md +++ b/README.md @@ -62,16 +62,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because ## Getting Started (Using a CDN) 1. Add the CSS ```html - + ``` 2. Add the plugin script and initialise it on your input element ```html - + ``` diff --git a/build/js/data.js b/build/js/data.js index 5cc628934..3a9a29627 100644 --- a/build/js/data.js +++ b/build/js/data.js @@ -1,5 +1,5 @@ /* - * International Telephone Input v19.5.2 + * International Telephone Input v19.5.3 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ diff --git a/build/js/data.min.js b/build/js/data.min.js index 812c092b6..11f5e5f32 100644 --- a/build/js/data.min.js +++ b/build/js/data.min.js @@ -1,5 +1,5 @@ /* - * International Telephone Input v19.5.2 + * International Telephone Input v19.5.3 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ diff --git a/build/js/intlTelInput-jquery.js b/build/js/intlTelInput-jquery.js index 062f26a78..ee4ae84f9 100644 --- a/build/js/intlTelInput-jquery.js +++ b/build/js/intlTelInput-jquery.js @@ -1,5 +1,5 @@ /* - * International Telephone Input v19.5.2 + * International Telephone Input v19.5.3 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ @@ -1773,7 +1773,7 @@ // default options intlTelInputGlobals.defaults = defaults; // version - intlTelInputGlobals.version = "19.5.2"; + intlTelInputGlobals.version = "19.5.3"; var pluginName = "intlTelInput"; // A really lightweight plugin wrapper around the constructor, // preventing against multiple instantiations diff --git a/build/js/intlTelInput-jquery.min.js b/build/js/intlTelInput-jquery.min.js index f335d9fdb..330565e84 100644 --- a/build/js/intlTelInput-jquery.min.js +++ b/build/js/intlTelInput-jquery.min.js @@ -1,8 +1,8 @@ /* - * International Telephone Input v19.5.2 + * International Telephone Input v19.5.3 * https://github.com/jackocnr/intl-tel-input.git * Licensed under the MIT license */ !function(a){"object"==typeof module&&module.exports?module.exports=a(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],function(b){a(b)}):a(jQuery)}(function(a,b){"use strict";function c(a){for(var b=1;ba.length)&&(b=a.length);for(var c=0,d=new Array(b);c1&&arguments[1]!==b?arguments[1]:{};k(this,a),this.id=t++,this.a=c,this.b=null,this.c=null,this.d=Object.assign({},u,d),this.e=Boolean(c.getAttribute("placeholder"))}return m(a,[{key:"_init",value:function(){var a=this;this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.countrySearch&&!this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!0),this.d.nationalMode&&(this.d.autoInsertDialCode=!1),this.d.showSelectedDialCode&&(this.d.autoInsertDialCode=!1);var b=this.d.allowDropdown&&!this.d.showSelectedDialCode;if(!this.d.showFlags&&b&&(this.d.showFlags=!0),this.d.useFullscreenPopup&&!this.d.dropdownContainer&&(this.d.dropdownContainer=document.body),this.isRTL=!!this.a.closest("[dir=rtl]"),"undefined"!=typeof Promise){var c=new Promise(function(b,c){a.h=b,a.i=c}),d=new Promise(function(b,c){a.i0=b,a.i1=c});this.promise=Promise.all([c,d])}else this.h=this.i=function(){},this.i0=this.i1=function(){};this.s={},this._b(),this._f(),this._h(),this._i(),this._i3()}},{key:"_b",value:function(){this._d(),this._d2(),this._e(),this._d0(),(this.d.onlyCountries.length||this.d.i18n)&&this.p.sort(this._d1)}},{key:"_c",value:function(a,c,d){c.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=c.length),this.q.hasOwnProperty(c)||(this.q[c]=[]);for(var e=0;e-1})}else if(this.d.excludeCountries.length){var b=this.d.excludeCountries.map(function(a){return a.toLowerCase()});this.p=p.filter(function(a){return-1===b.indexOf(a.iso2)})}else this.p=p}},{key:"_d0",value:function(){for(var a=0;ab.name?1:0}},{key:"_d2",value:function(){this.dialCodes={},this.dialCodeMaxLen=0,this.q={};for(var a=0;a")),h+="".concat(e.name,""),h+="+".concat(e.dialCode,""),g.insertAdjacentHTML("beforeend",h)}}},{key:"_h",value:function(){var a=arguments.length>0&&arguments[0]!==b&&arguments[0],c=this.a.getAttribute("value"),d=this.a.value,e=c&&"+"===c.charAt(0)&&(!d||"+"!==d.charAt(0)),f=e?c:d,g=this._5(f),h=this._w(f),i=this.d,j=i.initialCountry,k=i.autoInsertDialCode,l=i.defaultToFirstCountry;if(g&&!h)this._v(f);else if("auto"!==j||a){var m=j?j.toLowerCase():"",n=m&&this._y(m,!0);n?this._z(m):g&&h?this._z("us"):l&&(this.j=this.preferredCountries.length?this.preferredCountries[0].iso2:this.p[0].iso2,f||this._z(this.j)),!f&&k&&(this.a.value="+".concat(this.s.dialCode))}f&&this._u(f)}},{key:"_i",value:function(){this._j(),this.d.autoInsertDialCode&&this._l(),this.d.allowDropdown&&this._i2(),this.hiddenInput&&this._i0()}},{key:"_i0",value:function(){var a=this;this._a14=function(){a.hiddenInput.value=a.getNumber(),a.hiddenInputCountry.value=a.getSelectedCountryData().iso2},this.a.form&&this.a.form.addEventListener("submit",this._a14)}},{key:"_i2",value:function(){var a=this;this._a9=function(b){a.dropdownContent.classList.contains("iti__hide")?a.a.focus():b.preventDefault()};var b=this.a.closest("label");b&&b.addEventListener("click",this._a9),this._a10=function(){!a.dropdownContent.classList.contains("iti__hide")||a.a.disabled||a.a.readOnly||a._n()},this.selectedFlag.addEventListener("click",this._a10),this._a11=function(b){a.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(b.key)&&(b.preventDefault(),b.stopPropagation(),a._n()),"Tab"===b.key&&a._2()},this.k.addEventListener("keydown",this._a11)}},{key:"_i3",value:function(){var a=this;this.d.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.d.utilsScript):window.addEventListener("load",function(){window.intlTelInputGlobals.loadUtils(a.d.utilsScript)}):this.i0(),"auto"!==this.d.initialCountry||this.s.iso2?this.h():this._i4()}},{key:"_i4",value:function(){var a=this;window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.d.geoIpLookup&&this.d.geoIpLookup(function(){var c=arguments.length>0&&arguments[0]!==b?arguments[0]:"",d=c.toLowerCase();d&&a._y(d,!0)?(window.intlTelInputGlobals.autoCountry=d,setTimeout(function(){return w("handleAutoCountry")})):(a._h(!0),w("rejectAutoCountryPromise"))},function(){return w("rejectAutoCountryPromise")}))}},{key:"_j",value:function(){var a=this,b=!1;this._a12=function(c){if(a._v(a.a.value)&&a._m2CountryChange(),c&&c.data&&/[^+0-9]/.test(c.data)?b=!0:/[^+0-9]/.test(a.a.value)||(b=!1),a.d.formatAsYouType&&!b){var d=a.a.selectionStart,e=a.a.value.substring(0,d),f=e.replace(/[^+0-9]/g,"").length,g=c&&"deleteContentForward"===c.inputType,h=a._formatNumberAsYouType(),i=a._translateCursorPosition(f,h,d,g);a.a.value=h,a.a.setSelectionRange(i,i)}},this.a.addEventListener("input",this._a12),this._a13=function(){setTimeout(a._a12)},this.a.addEventListener("cut",this._a13),this.a.addEventListener("paste",this._a13)}},{key:"_translateCursorPosition",value:function(a,b,c,d){if(0===c&&!d)return 0;for(var e=0,f=0;fb?a.substr(0,b):a}},{key:"_l",value:function(){var a=this;this._a8=function(){a._l2()},this.a.form&&this.a.form.addEventListener("submit",this._a8),this.a.addEventListener("blur",this._a8)}},{key:"_l2",value:function(){if("+"===this.a.value.charAt(0)){var a=this._m(this.a.value);a&&this.s.dialCode!==a||(this.a.value="")}}},{key:"_m",value:function(a){return a.replace(/\D/g,"")}},{key:"_m2",value:function(a){var b=new Event(a,{bubbles:!0,cancelable:!0});this.a.dispatchEvent(b)}},{key:"_n",value:function(){if(this.d.fixDropdownWidth&&(this.dropdownContent.style.width="".concat(this.a.offsetWidth,"px")),this.dropdownContent.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._o(),this.d.countrySearch){var a=this.countryList.firstElementChild;a&&this._x(a,!1),this.searchInput.focus()}else this.b&&(this._x(this.b,!1),this._3(this.b,!0));this._p(),this.u.classList.add("iti__arrow--up"),this._m2("open:countrydropdown")}},{key:"_n2",value:function(a,b,c){c&&!a.classList.contains(b)?a.classList.add(b):!c&&a.classList.contains(b)&&a.classList.remove(b)}},{key:"_o",value:function(){var a=this;if(this.d.dropdownContainer&&this.d.dropdownContainer.appendChild(this.dropdown),!this.d.useFullscreenPopup){var b=this.a.getBoundingClientRect(),c=document.documentElement.scrollTop,d=b.top+c,e=this.dropdownContent.offsetHeight,f=d+this.a.offsetHeight+ec,h=!this.d.countrySearch&&!f&&g;if(this._n2(this.dropdownContent,"iti__dropdown-content--dropup",h),this.d.dropdownContainer){var i=h?0:this.a.offsetHeight;this.dropdown.style.top="".concat(d+i,"px"),this.dropdown.style.left="".concat(b.left+document.body.scrollLeft,"px"),this._a4=function(){return a._2()},window.addEventListener("scroll",this._a4)}}}},{key:"_p",value:function(){var a=this;this._a0=function(b){var c=b.target.closest(".iti__country");c&&a._x(c,!1)},this.countryList.addEventListener("mouseover",this._a0),this._a1=function(b){var c=b.target.closest(".iti__country");c&&a._1(c)},this.countryList.addEventListener("click",this._a1);var b=!0;this._a2=function(){b||a._2(),b=!1},document.documentElement.addEventListener("click",this._a2);var c="",d=null;if(this._a3=function(b){["ArrowUp","ArrowDown","Enter","Escape"].includes(b.key)&&(b.preventDefault(),b.stopPropagation(),"ArrowUp"===b.key||"ArrowDown"===b.key?a._q(b.key):"Enter"===b.key?a._r():"Escape"===b.key&&a._2()),!a.d.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(b.key)&&(b.stopPropagation(),d&&clearTimeout(d),c+=b.key.toLowerCase(),a._s(c),d=setTimeout(function(){c=""},1e3))},document.addEventListener("keydown",this._a3),this.d.countrySearch){var e=function(){var b=a.searchInput.value.trim();b?a._filterCountries(b):a._filterCountries("",!0)},f=null;this._handleSearchChange=function(){f&&clearTimeout(f),f=setTimeout(function(){e(),f=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",function(a){return a.stopPropagation()})}}},{key:"_normaliseString",value:function(){return(arguments.length>0&&arguments[0]!==b?arguments[0]:"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}},{key:"_filterCountries",value:function(a){var c=arguments.length>1&&arguments[1]!==b&&arguments[1],d=!0;this.countryList.innerHTML="";for(var e=this._normaliseString(a),f=0;f1&&(b="ArrowUp"===a?this.countryList.lastElementChild:this.countryList.firstElementChild),b){var c=!this.d.countrySearch;this._x(b,c),this.d.countrySearch&&this._3(b,!1)}}},{key:"_r",value:function(){this.c&&this._1(this.c)}},{key:"_s",value:function(a){for(var b=0;bg){b&&(k+=l);var m=e-h;c.scrollTop=k-m}}},{key:"_4",value:function(a){var b,c=this.a.value,d="+".concat(a);if("+"===c.charAt(0)){var e=this._5(c);b=e?c.replace(e,d):d,this.a.value=b}else this.d.autoInsertDialCode&&(b=c?d+c:d,this.a.value=b)}},{key:"_5",value:function(a,b){var c="";if("+"===a.charAt(0))for(var d="",e=0;eg){b&&(k+=l);var m=e-h;c.scrollTop=k-m}}},{key:"_4",value:function(a){var b,c=this.a.value,d="+".concat(a);if("+"===c.charAt(0)){var e=this._5(c);b=e?c.replace(e,d):d,this.a.value=b}else this.d.autoInsertDialCode&&(b=c?d+c:d,this.a.value=b)}},{key:"_5",value:function(a,b){var c="";if("+"===a.charAt(0))for(var d="",e=0;ea.length)&&(b=a.length);for(var c=0,d=new Array(b);c1&&arguments[1]!==a?arguments[1]:{};j(this,c),this.id=s++,this.a=b,this.b=null,this.c=null,this.d=Object.assign({},t,d),this.e=Boolean(b.getAttribute("placeholder"))}return l(c,[{key:"_init",value:function(){var a=this;this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!1),this.d.countrySearch&&!this.d.useFullscreenPopup&&(this.d.fixDropdownWidth=!0),this.d.nationalMode&&(this.d.autoInsertDialCode=!1),this.d.showSelectedDialCode&&(this.d.autoInsertDialCode=!1);var b=this.d.allowDropdown&&!this.d.showSelectedDialCode;if(!this.d.showFlags&&b&&(this.d.showFlags=!0),this.d.useFullscreenPopup&&!this.d.dropdownContainer&&(this.d.dropdownContainer=document.body),this.isRTL=!!this.a.closest("[dir=rtl]"),"undefined"!=typeof Promise){var c=new Promise(function(b,c){a.h=b,a.i=c}),d=new Promise(function(b,c){a.i0=b,a.i1=c});this.promise=Promise.all([c,d])}else this.h=this.i=function(){},this.i0=this.i1=function(){};this.s={},this._b(),this._f(),this._h(),this._i(),this._i3()}},{key:"_b",value:function(){this._d(),this._d2(),this._e(),this._d0(),(this.d.onlyCountries.length||this.d.i18n)&&this.p.sort(this._d1)}},{key:"_c",value:function(b,c,d){c.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=c.length),this.q.hasOwnProperty(c)||(this.q[c]=[]);for(var e=0;e-1})}else if(this.d.excludeCountries.length){var b=this.d.excludeCountries.map(function(a){return a.toLowerCase()});this.p=o.filter(function(a){return-1===b.indexOf(a.iso2)})}else this.p=o}},{key:"_d0",value:function(){for(var a=0;ab.name?1:0}},{key:"_d2",value:function(){this.dialCodes={},this.dialCodeMaxLen=0,this.q={};for(var a=0;a")),h+="".concat(e.name,""),h+="+".concat(e.dialCode,""),g.insertAdjacentHTML("beforeend",h)}}},{key:"_h",value:function(){var b=arguments.length>0&&arguments[0]!==a&&arguments[0],c=this.a.getAttribute("value"),d=this.a.value,e=c&&"+"===c.charAt(0)&&(!d||"+"!==d.charAt(0)),f=e?c:d,g=this._5(f),h=this._w(f),i=this.d,j=i.initialCountry,k=i.autoInsertDialCode,l=i.defaultToFirstCountry;if(g&&!h)this._v(f);else if("auto"!==j||b){var m=j?j.toLowerCase():"",n=m&&this._y(m,!0);n?this._z(m):g&&h?this._z("us"):l&&(this.j=this.preferredCountries.length?this.preferredCountries[0].iso2:this.p[0].iso2,f||this._z(this.j)),!f&&k&&(this.a.value="+".concat(this.s.dialCode))}f&&this._u(f)}},{key:"_i",value:function(){this._j(),this.d.autoInsertDialCode&&this._l(),this.d.allowDropdown&&this._i2(),this.hiddenInput&&this._i0()}},{key:"_i0",value:function(){var a=this;this._a14=function(){a.hiddenInput.value=a.getNumber(),a.hiddenInputCountry.value=a.getSelectedCountryData().iso2},this.a.form&&this.a.form.addEventListener("submit",this._a14)}},{key:"_i2",value:function(){var a=this;this._a9=function(b){a.dropdownContent.classList.contains("iti__hide")?a.a.focus():b.preventDefault()};var b=this.a.closest("label");b&&b.addEventListener("click",this._a9),this._a10=function(){!a.dropdownContent.classList.contains("iti__hide")||a.a.disabled||a.a.readOnly||a._n()},this.selectedFlag.addEventListener("click",this._a10),this._a11=function(b){a.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(b.key)&&(b.preventDefault(),b.stopPropagation(),a._n()),"Tab"===b.key&&a._2()},this.k.addEventListener("keydown",this._a11)}},{key:"_i3",value:function(){var a=this;this.d.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.d.utilsScript):window.addEventListener("load",function(){window.intlTelInputGlobals.loadUtils(a.d.utilsScript)}):this.i0(),"auto"!==this.d.initialCountry||this.s.iso2?this.h():this._i4()}},{key:"_i4",value:function(){var b=this;window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.d.geoIpLookup&&this.d.geoIpLookup(function(){var c=arguments.length>0&&arguments[0]!==a?arguments[0]:"",d=c.toLowerCase();d&&b._y(d,!0)?(window.intlTelInputGlobals.autoCountry=d,setTimeout(function(){return v("handleAutoCountry")})):(b._h(!0),v("rejectAutoCountryPromise"))},function(){return v("rejectAutoCountryPromise")}))}},{key:"_j",value:function(){var a=this,b=!1;this._a12=function(c){if(a._v(a.a.value)&&a._m2CountryChange(),c&&c.data&&/[^+0-9]/.test(c.data)?b=!0:/[^+0-9]/.test(a.a.value)||(b=!1),a.d.formatAsYouType&&!b){var d=a.a.selectionStart,e=a.a.value.substring(0,d),f=e.replace(/[^+0-9]/g,"").length,g=c&&"deleteContentForward"===c.inputType,h=a._formatNumberAsYouType(),i=a._translateCursorPosition(f,h,d,g);a.a.value=h,a.a.setSelectionRange(i,i)}},this.a.addEventListener("input",this._a12),this._a13=function(){setTimeout(a._a12)},this.a.addEventListener("cut",this._a13),this.a.addEventListener("paste",this._a13)}},{key:"_translateCursorPosition",value:function(a,b,c,d){if(0===c&&!d)return 0;for(var e=0,f=0;fb?a.substr(0,b):a}},{key:"_l",value:function(){var a=this;this._a8=function(){a._l2()},this.a.form&&this.a.form.addEventListener("submit",this._a8),this.a.addEventListener("blur",this._a8)}},{key:"_l2",value:function(){if("+"===this.a.value.charAt(0)){var a=this._m(this.a.value);a&&this.s.dialCode!==a||(this.a.value="")}}},{key:"_m",value:function(a){return a.replace(/\D/g,"")}},{key:"_m2",value:function(a){var b=new Event(a,{bubbles:!0,cancelable:!0});this.a.dispatchEvent(b)}},{key:"_n",value:function(){if(this.d.fixDropdownWidth&&(this.dropdownContent.style.width="".concat(this.a.offsetWidth,"px")),this.dropdownContent.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._o(),this.d.countrySearch){var a=this.countryList.firstElementChild;a&&this._x(a,!1),this.searchInput.focus()}else this.b&&(this._x(this.b,!1),this._3(this.b,!0));this._p(),this.u.classList.add("iti__arrow--up"),this._m2("open:countrydropdown")}},{key:"_n2",value:function(a,b,c){c&&!a.classList.contains(b)?a.classList.add(b):!c&&a.classList.contains(b)&&a.classList.remove(b)}},{key:"_o",value:function(){var a=this;if(this.d.dropdownContainer&&this.d.dropdownContainer.appendChild(this.dropdown),!this.d.useFullscreenPopup){var b=this.a.getBoundingClientRect(),c=document.documentElement.scrollTop,d=b.top+c,e=this.dropdownContent.offsetHeight,f=d+this.a.offsetHeight+ec,h=!this.d.countrySearch&&!f&&g;if(this._n2(this.dropdownContent,"iti__dropdown-content--dropup",h),this.d.dropdownContainer){var i=h?0:this.a.offsetHeight;this.dropdown.style.top="".concat(d+i,"px"),this.dropdown.style.left="".concat(b.left+document.body.scrollLeft,"px"),this._a4=function(){return a._2()},window.addEventListener("scroll",this._a4)}}}},{key:"_p",value:function(){var a=this;this._a0=function(b){var c=b.target.closest(".iti__country");c&&a._x(c,!1)},this.countryList.addEventListener("mouseover",this._a0),this._a1=function(b){var c=b.target.closest(".iti__country");c&&a._1(c)},this.countryList.addEventListener("click",this._a1);var b=!0;this._a2=function(){b||a._2(),b=!1},document.documentElement.addEventListener("click",this._a2);var c="",d=null;if(this._a3=function(b){["ArrowUp","ArrowDown","Enter","Escape"].includes(b.key)&&(b.preventDefault(),b.stopPropagation(),"ArrowUp"===b.key||"ArrowDown"===b.key?a._q(b.key):"Enter"===b.key?a._r():"Escape"===b.key&&a._2()),!a.d.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(b.key)&&(b.stopPropagation(),d&&clearTimeout(d),c+=b.key.toLowerCase(),a._s(c),d=setTimeout(function(){c=""},1e3))},document.addEventListener("keydown",this._a3),this.d.countrySearch){var e=function(){var b=a.searchInput.value.trim();b?a._filterCountries(b):a._filterCountries("",!0)},f=null;this._handleSearchChange=function(){f&&clearTimeout(f),f=setTimeout(function(){e(),f=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",function(a){return a.stopPropagation()})}}},{key:"_normaliseString",value:function(){return(arguments.length>0&&arguments[0]!==a?arguments[0]:"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}},{key:"_filterCountries",value:function(b){var c=arguments.length>1&&arguments[1]!==a&&arguments[1],d=!0;this.countryList.innerHTML="";for(var e=this._normaliseString(b),f=0;f1&&(b="ArrowUp"===a?this.countryList.lastElementChild:this.countryList.firstElementChild),b){var c=!this.d.countrySearch;this._x(b,c),this.d.countrySearch&&this._3(b,!1)}}},{key:"_r",value:function(){this.c&&this._1(this.c)}},{key:"_s",value:function(a){for(var b=0;bg){b&&(k+=l);var m=e-h;c.scrollTop=k-m}}},{key:"_4",value:function(a){var b,c=this.a.value,d="+".concat(a);if("+"===c.charAt(0)){var e=this._5(c);b=e?c.replace(e,d):d,this.a.value=b}else this.d.autoInsertDialCode&&(b=c?d+c:d,this.a.value=b)}},{key:"_5",value:function(a,b){var c="";if("+"===a.charAt(0))for(var d="",e=0;eg){b&&(k+=l);var m=e-h;c.scrollTop=k-m}}},{key:"_4",value:function(a){var b,c=this.a.value,d="+".concat(a);if("+"===c.charAt(0)){var e=this._5(c);b=e?c.replace(e,d):d,this.a.value=b}else this.d.autoInsertDialCode&&(b=c?d+c:d,this.a.value=b)}},{key:"_5",value:function(a,b){var c="";if("+"===a.charAt(0))for(var d="",e=0;e()=>(p||h((p={exports:{}}).exports,p),p.exports),st=(h,p)=>{for(var g in p)P(h,g,{get:p[g],enumerable:!0})},q=(h,p,g,m)=>{if(p&&typeof p=="object"||typeof p=="function")for(let _ of nt(p))!rt.call(h,_)&&_!==g&&P(h,_,{get:()=>p[_],enumerable:!(m=it(p,_))||m.enumerable});return h};var z=(h,p,g)=>(g=h!=null?et(ot(h)):{},q(p||!h||!h.__esModule?P(g,"default",{value:h,enumerable:!0}):g,h)),lt=h=>q(P({},"__esModule",{value:!0}),h);var Y=at((ct,M)=>{(function(h){typeof M=="object"&&M.exports?M.exports=h():window.intlTelInput=h()})(function(h){"use strict";return function(){for(var p=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua & Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria","at","43"],["Azerbaijan","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus","by","375"],["Belgium","be","32"],["Belize","bz","501"],["Benin","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia & Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","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","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros","km","269"],["Congo - Brazzaville","cg","242"],["Congo - Kinshasa","cd","243"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["C\xF4te d\u2019Ivoire","ci","225"],["Croatia","hr","385"],["Cuba","cu","53"],["Cura\xE7ao","cw","599",0],["Cyprus","cy","357"],["Czech Republic","cz","420"],["Denmark","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands","fk","500"],["Faroe Islands","fo","298"],["Fiji","fj","679"],["Finland","fi","358",0],["France","fr","33"],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49"],["Ghana","gh","233"],["Gibraltar","gi","350"],["Greece","gr","30"],["Greenland","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong","hk","852"],["Hungary","hu","36"],["Iceland","is","354"],["India","in","91"],["Indonesia","id","62"],["Iran","ir","98"],["Iraq","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel","il","972"],["Italy","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan","jo","962"],["Kazakhstan","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996"],["Laos","la","856"],["Latvia","lv","371"],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico","mx","52"],["Micronesia","fm","691"],["Moldova","md","373"],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco","ma","212",0],["Mozambique","mz","258"],["Myanmar (Burma)","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31"],["New Caledonia","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea","kp","850"],["North Macedonia","mk","389"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway","no","47",0],["Oman","om","968"],["Pakistan","pk","92"],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63"],["Poland","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar","qa","974"],["R\xE9union","re","262",0],["Romania","ro","40"],["Russia","ru","7",0],["Rwanda","rw","250"],["Samoa","ws","685"],["San Marino","sm","378"],["S\xE3o Tom\xE9 & Pr\xEDncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82"],["South Sudan","ss","211"],["Spain","es","34"],["Sri Lanka","lk","94"],["St Barth\xE9lemy","bl","590",1],["St Helena","sh","290"],["St Kitts & Nevis","kn","1",18,["869"]],["St Lucia","lc","1",19,["758"]],["St Martin","mf","590",2],["St Pierre & Miquelon","pm","508"],["St Vincent & Grenadines","vc","1",20,["784"]],["Sudan","sd","249"],["Suriname","sr","597"],["Svalbard & Jan Mayen","sj","47",1,["79"]],["Sweden","se","46"],["Switzerland","ch","41"],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad & Tobago","tt","1",22,["868"]],["Tunisia","tn","216"],["Turkey","tr","90"],["Turkmenistan","tm","993"],["Turks & Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380"],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["US Virgin Islands","vi","1",24,["340"]],["Uzbekistan","uz","998"],["Vanuatu","vu","678"],["Vatican City","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam","vn","84"],["Wallis & Futuna","wf","681"],["Western Sahara","eh","212",1,["5288","5289"]],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["\xC5land Islands","ax","358",1,["18"]]],g=0;ga.length)&&(n=a.length);for(var t=0,e=new Array(n);t1&&arguments[1]!==h?arguments[1]:{};C(this,a),this.id=Z++,this.telInput=n,this.activeItem=null,this.highlightedItem=null,this.options=Object.assign({},H,t),this.hadInitialPlaceholder=!!n.getAttribute("placeholder")}return I(a,[{key:"_init",value:function(){var t=this;this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0),this.options.nationalMode&&(this.options.autoInsertDialCode=!1),this.options.showSelectedDialCode&&(this.options.autoInsertDialCode=!1);var e=this.options.allowDropdown&&!this.options.showSelectedDialCode;if(!this.options.showFlags&&e&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),typeof Promise<"u"){var i=new Promise(function(r,s){t.resolveAutoCountryPromise=r,t.rejectAutoCountryPromise=s}),o=new Promise(function(r,s){t.resolveUtilsScriptPromise=r,t.rejectUtilsScriptPromise=s});this.promise=Promise.all([i,o])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processDialCodes(),this._processPreferredCountries(),this._translateCountryNames(),(this.options.onlyCountries.length||this.options.i18n)&&this.countries.sort(this._countryNameSort)}},{key:"_addToDialCodeMap",value:function(t,e,i){e.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=e.length),this.dialCodeToIso2Map.hasOwnProperty(e)||(this.dialCodeToIso2Map[e]=[]);for(var o=0;o-1})}else if(this.options.excludeCountries.length){var e=this.options.excludeCountries.map(function(i){return i.toLowerCase()});this.countries=p.filter(function(i){return e.indexOf(i.iso2)===-1})}else this.countries=p}},{key:"_translateCountryNames",value:function(){for(var t=0;te.name?1:0}},{key:"_processDialCodes",value:function(){this.dialCodes={},this.dialCodeMaxLen=0,this.dialCodeToIso2Map={};for(var t=0;t")),u+="".concat(r.name,""),u+="+".concat(r.dialCode,""),l.insertAdjacentHTML("beforeend",u)}}},{key:"_setInitialState",value:function(){var t=arguments.length>0&&arguments[0]!==h?arguments[0]:!1,e=this.telInput.getAttribute("value"),i=this.telInput.value,o=e&&e.charAt(0)==="+"&&(!i||i.charAt(0)!=="+"),r=o?e:i,s=this._getDialCode(r),l=this._isRegionlessNanp(r),u=this.options,c=u.initialCountry,y=u.autoInsertDialCode,v=u.defaultToFirstCountry;if(s&&!l)this._updateFlagFromNumber(r);else if(c!=="auto"||t){var f=c?c.toLowerCase():"",L=f&&this._getCountryData(f,!0);L?this._setFlag(f):s&&l?this._setFlag("us"):v&&(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,r||this._setFlag(this.defaultCountry)),!r&&y&&(this.telInput.value="+".concat(this.selectedCountryData.dialCode))}r&&this._updateValFromNumber(r)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoInsertDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var t=this;this._handleHiddenInputSubmit=function(){t.hiddenInput.value=t.getNumber(),t.hiddenInputCountry.value=t.getSelectedCountryData().iso2},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_initDropdownListeners",value:function(){var t=this;this._handleLabelClick=function(i){t.dropdownContent.classList.contains("iti__hide")?t.telInput.focus():i.preventDefault()};var e=this.telInput.closest("label");e&&e.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){t.dropdownContent.classList.contains("iti__hide")&&!t.telInput.disabled&&!t.telInput.readOnly&&t._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(i){var o=t.dropdownContent.classList.contains("iti__hide");o&&["ArrowUp","ArrowDown"," ","Enter"].includes(i.key)&&(i.preventDefault(),i.stopPropagation(),t._showDropdown()),i.key==="Tab"&&t._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var t=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",function(){window.intlTelInputGlobals.loadUtils(t.options.utilsScript)}):this.resolveUtilsScriptPromise(),this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){var t=this;window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup(function(){var e=arguments.length>0&&arguments[0]!==h?arguments[0]:"",i=e.toLowerCase(),o=i&&t._getCountryData(i,!0);o?(window.intlTelInputGlobals.autoCountry=i,setTimeout(function(){return T("handleAutoCountry")})):(t._setInitialState(!0),T("rejectAutoCountryPromise"))},function(){return T("rejectAutoCountryPromise")}))}},{key:"_initKeyListeners",value:function(){var t=this,e=!1;this._handleKeyEvent=function(i){if(t._updateFlagFromNumber(t.telInput.value)&&t._triggerCountryChange(),i&&i.data&&/[^+0-9]/.test(i.data)?e=!0:/[^+0-9]/.test(t.telInput.value)||(e=!1),t.options.formatAsYouType&&!e){var o=t.telInput.selectionStart,r=t.telInput.value.substring(0,o),s=r.replace(/[^+0-9]/g,"").length,l=i&&i.inputType==="deleteContentForward",u=t._formatNumberAsYouType(),c=t._translateCursorPosition(s,u,o,l);t.telInput.value=u,t.telInput.setSelectionRange(c,c)}},this.telInput.addEventListener("input",this._handleKeyEvent),this._handleClipboardEvent=function(){setTimeout(t._handleKeyEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_translateCursorPosition",value:function(t,e,i,o){if(i===0&&!o)return 0;for(var r=0,s=0;se?t.substr(0,e):t}},{key:"_initBlurListeners",value:function(){var t=this;this._handleSubmitOrBlurEvent=function(){t._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if(this.telInput.value.charAt(0)==="+"){var t=this._getNumeric(this.telInput.value);(!t||this.selectedCountryData.dialCode===t)&&(this.telInput.value="")}}},{key:"_getNumeric",value:function(t){return t.replace(/\D/g,"")}},{key:"_trigger",value:function(t){var e=new Event(t,{bubbles:!0,cancelable:!0});this.telInput.dispatchEvent(e)}},{key:"_showDropdown",value:function(){if(this.options.fixDropdownWidth&&(this.dropdownContent.style.width="".concat(this.telInput.offsetWidth,"px")),this.dropdownContent.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.options.countrySearch){var t=this.countryList.firstElementChild;t&&this._highlightListItem(t,!1),this.searchInput.focus()}else this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0));this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(t,e,i){i&&!t.classList.contains(e)?t.classList.add(e):!i&&t.classList.contains(e)&&t.classList.remove(e)}},{key:"_setDropdownPosition",value:function(){var t=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.options.useFullscreenPopup){var e=this.telInput.getBoundingClientRect(),i=document.documentElement.scrollTop,o=e.top+i,r=this.dropdownContent.offsetHeight,s=o+this.telInput.offsetHeight+ri,u=!this.options.countrySearch&&!s&&l;if(this._toggleClass(this.dropdownContent,"iti__dropdown-content--dropup",u),this.options.dropdownContainer){var c=u?0:this.telInput.offsetHeight;this.dropdown.style.top="".concat(o+c,"px"),this.dropdown.style.left="".concat(e.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return t._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll)}}}},{key:"_bindDropdownListeners",value:function(){var t=this;this._handleMouseoverCountryList=function(l){var u=l.target.closest(".iti__country");u&&t._highlightListItem(u,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(l){var u=l.target.closest(".iti__country");u&&t._selectListItem(u)},this.countryList.addEventListener("click",this._handleClickCountryList);var e=!0;this._handleClickOffToClose=function(){e||t._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var i="",o=null;if(this._handleKeydownOnDropdown=function(l){["ArrowUp","ArrowDown","Enter","Escape"].includes(l.key)&&(l.preventDefault(),l.stopPropagation(),l.key==="ArrowUp"||l.key==="ArrowDown"?t._handleUpDownKey(l.key):l.key==="Enter"?t._handleEnterKey():l.key==="Escape"&&t._closeDropdown()),!t.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(l.key)&&(l.stopPropagation(),o&&clearTimeout(o),i+=l.key.toLowerCase(),t._searchForCountry(i),o=setTimeout(function(){i=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){var r=function(){var u=t.searchInput.value.trim();u?t._filterCountries(u):t._filterCountries("",!0)},s=null;this._handleSearchChange=function(){s&&clearTimeout(s),s=setTimeout(function(){r(),s=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",function(l){return l.stopPropagation()})}}},{key:"_normaliseString",value:function(){var t=arguments.length>0&&arguments[0]!==h?arguments[0]:"";return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}},{key:"_filterCountries",value:function(t){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:!1,i=!0;this.countryList.innerHTML="";for(var o=this._normaliseString(t),r=0;r1&&(e=t==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),e){var i=!this.options.countrySearch;this._highlightListItem(e,i),this.options.countrySearch&&this._scrollTo(e,!1)}}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(t){for(var e=0;el){e&&(v+=f);var L=r-u;i.scrollTop=v-L}}},{key:"_updateDialCode",value:function(t){var e=this.telInput.value,i="+".concat(t),o;if(e.charAt(0)==="+"){var r=this._getDialCode(e);r?o=e.replace(r,i):o=i,this.telInput.value=o}else this.options.autoInsertDialCode&&(e?o=i+e:o=i,this.telInput.value=o)}},{key:"_getDialCode",value:function(t,e){var i="";if(t.charAt(0)==="+")for(var o="",r=0;rut});module.exports=lt(dt);var b=z(require("react")),d=z(require("prop-types")),J=z(Y()),V=({initialValue:h,onChangeNumber:p,onChangeCountry:g,onChangeValidity:m,onChangeErrorCode:_,initOptions:x,className:O,disabled:U,onFocus:B,onBlur:E,placeholder:j})=>{let S=(0,b.useRef)(null),C=(0,b.useRef)(null),w=()=>{let I=C.current.getNumber(),N=C.current.getSelectedCountryData().iso2;if(p(I),g(N),C.current.isValidNumber())m(!0),_(null);else{let G=C.current.getValidationError();m(!1),_(G)}};return(0,b.useEffect)(()=>{let I=S.current;return C.current=(0,J.default)(S.current,x),I.addEventListener("countrychange",w),()=>{I.removeEventListener("countrychange",w),C.current.destroy()}},[]),b.default.createElement("input",{type:"tel",ref:S,onInput:w,defaultValue:h,className:O,disabled:U,onFocus:B,onBlur:E,placeholder:j})};V.propTypes={initialValue:d.default.string,placeholder:d.default.string,onChangeNumber:d.default.func,onChangeCountry:d.default.func,onChangeValidity:d.default.func,onChangeErrorCode:d.default.func,initOptions:d.default.shape({allowDropdown:d.default.bool,autoInsertDialCode:d.default.bool,autoPlaceholder:d.default.string,containerClass:d.default.string,countrySearch:d.default.bool,customPlaceholder:d.default.func,dropdownContainer:d.default.node,excludeCountries:d.default.arrayOf(d.default.string),fixDropdownWidth:d.default.bool,formatAsYouType:d.default.bool,formatOnDisplay:d.default.bool,geoIpLookup:d.default.func,hiddenInput:d.default.func,i18n:d.default.objectOf(d.default.string),initialCountry:d.default.string,nationalMode:d.default.bool,onlyCountries:d.default.arrayOf(d.default.string),placeholderNumberType:d.default.string,preferredCountries:d.default.arrayOf(d.default.string),showFlags:d.default.bool,showSelectedDialCode:d.default.bool,useFullscreenPopup:d.default.bool,utilsScript:d.default.string}),className:d.default.string,disabled:d.default.bool,onFocus:d.default.func,onBlur:d.default.func};V.defaultProps={initialValue:"",placeholder:"",onChangeNumber:()=>{},onChangeCountry:()=>{},onChangeValidity:()=>{},onChangeErrorCode:()=>{},initOptions:{},className:"",disabled:!1,onFocus:()=>{},onBlur:()=>{}};var ut=V; +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B(a,n){if(a){if(typeof a=="string")return E(a,n);var t=Object.prototype.toString.call(a).slice(8,-1);if(t==="Object"&&a.constructor&&(t=a.constructor.name),t==="Map"||t==="Set")return Array.from(a);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(a,n)}}function E(a,n){(n==null||n>a.length)&&(n=a.length);for(var t=0,e=new Array(n);t1&&arguments[1]!==h?arguments[1]:{};C(this,a),this.id=Z++,this.telInput=n,this.activeItem=null,this.highlightedItem=null,this.options=Object.assign({},H,t),this.hadInitialPlaceholder=!!n.getAttribute("placeholder")}return I(a,[{key:"_init",value:function(){var t=this;this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0),this.options.nationalMode&&(this.options.autoInsertDialCode=!1),this.options.showSelectedDialCode&&(this.options.autoInsertDialCode=!1);var e=this.options.allowDropdown&&!this.options.showSelectedDialCode;if(!this.options.showFlags&&e&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),typeof Promise<"u"){var i=new Promise(function(r,s){t.resolveAutoCountryPromise=r,t.rejectAutoCountryPromise=s}),o=new Promise(function(r,s){t.resolveUtilsScriptPromise=r,t.rejectUtilsScriptPromise=s});this.promise=Promise.all([i,o])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processDialCodes(),this._processPreferredCountries(),this._translateCountryNames(),(this.options.onlyCountries.length||this.options.i18n)&&this.countries.sort(this._countryNameSort)}},{key:"_addToDialCodeMap",value:function(t,e,i){e.length>this.dialCodeMaxLen&&(this.dialCodeMaxLen=e.length),this.dialCodeToIso2Map.hasOwnProperty(e)||(this.dialCodeToIso2Map[e]=[]);for(var o=0;o-1})}else if(this.options.excludeCountries.length){var e=this.options.excludeCountries.map(function(i){return i.toLowerCase()});this.countries=p.filter(function(i){return e.indexOf(i.iso2)===-1})}else this.countries=p}},{key:"_translateCountryNames",value:function(){for(var t=0;te.name?1:0}},{key:"_processDialCodes",value:function(){this.dialCodes={},this.dialCodeMaxLen=0,this.dialCodeToIso2Map={};for(var t=0;t")),u+="".concat(r.name,""),u+="+".concat(r.dialCode,""),l.insertAdjacentHTML("beforeend",u)}}},{key:"_setInitialState",value:function(){var t=arguments.length>0&&arguments[0]!==h?arguments[0]:!1,e=this.telInput.getAttribute("value"),i=this.telInput.value,o=e&&e.charAt(0)==="+"&&(!i||i.charAt(0)!=="+"),r=o?e:i,s=this._getDialCode(r),l=this._isRegionlessNanp(r),u=this.options,c=u.initialCountry,y=u.autoInsertDialCode,v=u.defaultToFirstCountry;if(s&&!l)this._updateFlagFromNumber(r);else if(c!=="auto"||t){var f=c?c.toLowerCase():"",L=f&&this._getCountryData(f,!0);L?this._setFlag(f):s&&l?this._setFlag("us"):v&&(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,r||this._setFlag(this.defaultCountry)),!r&&y&&(this.telInput.value="+".concat(this.selectedCountryData.dialCode))}r&&this._updateValFromNumber(r)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoInsertDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var t=this;this._handleHiddenInputSubmit=function(){t.hiddenInput.value=t.getNumber(),t.hiddenInputCountry.value=t.getSelectedCountryData().iso2},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_initDropdownListeners",value:function(){var t=this;this._handleLabelClick=function(i){t.dropdownContent.classList.contains("iti__hide")?t.telInput.focus():i.preventDefault()};var e=this.telInput.closest("label");e&&e.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){t.dropdownContent.classList.contains("iti__hide")&&!t.telInput.disabled&&!t.telInput.readOnly&&t._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(i){var o=t.dropdownContent.classList.contains("iti__hide");o&&["ArrowUp","ArrowDown"," ","Enter"].includes(i.key)&&(i.preventDefault(),i.stopPropagation(),t._showDropdown()),i.key==="Tab"&&t._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var t=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",function(){window.intlTelInputGlobals.loadUtils(t.options.utilsScript)}):this.resolveUtilsScriptPromise(),this.options.initialCountry==="auto"&&!this.selectedCountryData.iso2?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){var t=this;window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,typeof this.options.geoIpLookup=="function"&&this.options.geoIpLookup(function(){var e=arguments.length>0&&arguments[0]!==h?arguments[0]:"",i=e.toLowerCase(),o=i&&t._getCountryData(i,!0);o?(window.intlTelInputGlobals.autoCountry=i,setTimeout(function(){return T("handleAutoCountry")})):(t._setInitialState(!0),T("rejectAutoCountryPromise"))},function(){return T("rejectAutoCountryPromise")}))}},{key:"_initKeyListeners",value:function(){var t=this,e=!1;this._handleKeyEvent=function(i){if(t._updateFlagFromNumber(t.telInput.value)&&t._triggerCountryChange(),i&&i.data&&/[^+0-9]/.test(i.data)?e=!0:/[^+0-9]/.test(t.telInput.value)||(e=!1),t.options.formatAsYouType&&!e){var o=t.telInput.selectionStart,r=t.telInput.value.substring(0,o),s=r.replace(/[^+0-9]/g,"").length,l=i&&i.inputType==="deleteContentForward",u=t._formatNumberAsYouType(),c=t._translateCursorPosition(s,u,o,l);t.telInput.value=u,t.telInput.setSelectionRange(c,c)}},this.telInput.addEventListener("input",this._handleKeyEvent),this._handleClipboardEvent=function(){setTimeout(t._handleKeyEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_translateCursorPosition",value:function(t,e,i,o){if(i===0&&!o)return 0;for(var r=0,s=0;se?t.substr(0,e):t}},{key:"_initBlurListeners",value:function(){var t=this;this._handleSubmitOrBlurEvent=function(){t._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if(this.telInput.value.charAt(0)==="+"){var t=this._getNumeric(this.telInput.value);(!t||this.selectedCountryData.dialCode===t)&&(this.telInput.value="")}}},{key:"_getNumeric",value:function(t){return t.replace(/\D/g,"")}},{key:"_trigger",value:function(t){var e=new Event(t,{bubbles:!0,cancelable:!0});this.telInput.dispatchEvent(e)}},{key:"_showDropdown",value:function(){if(this.options.fixDropdownWidth&&(this.dropdownContent.style.width="".concat(this.telInput.offsetWidth,"px")),this.dropdownContent.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.options.countrySearch){var t=this.countryList.firstElementChild;t&&this._highlightListItem(t,!1),this.searchInput.focus()}else this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0));this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(t,e,i){i&&!t.classList.contains(e)?t.classList.add(e):!i&&t.classList.contains(e)&&t.classList.remove(e)}},{key:"_setDropdownPosition",value:function(){var t=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.options.useFullscreenPopup){var e=this.telInput.getBoundingClientRect(),i=document.documentElement.scrollTop,o=e.top+i,r=this.dropdownContent.offsetHeight,s=o+this.telInput.offsetHeight+ri,u=!this.options.countrySearch&&!s&&l;if(this._toggleClass(this.dropdownContent,"iti__dropdown-content--dropup",u),this.options.dropdownContainer){var c=u?0:this.telInput.offsetHeight;this.dropdown.style.top="".concat(o+c,"px"),this.dropdown.style.left="".concat(e.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return t._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll)}}}},{key:"_bindDropdownListeners",value:function(){var t=this;this._handleMouseoverCountryList=function(l){var u=l.target.closest(".iti__country");u&&t._highlightListItem(u,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(l){var u=l.target.closest(".iti__country");u&&t._selectListItem(u)},this.countryList.addEventListener("click",this._handleClickCountryList);var e=!0;this._handleClickOffToClose=function(){e||t._closeDropdown(),e=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var i="",o=null;if(this._handleKeydownOnDropdown=function(l){["ArrowUp","ArrowDown","Enter","Escape"].includes(l.key)&&(l.preventDefault(),l.stopPropagation(),l.key==="ArrowUp"||l.key==="ArrowDown"?t._handleUpDownKey(l.key):l.key==="Enter"?t._handleEnterKey():l.key==="Escape"&&t._closeDropdown()),!t.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(l.key)&&(l.stopPropagation(),o&&clearTimeout(o),i+=l.key.toLowerCase(),t._searchForCountry(i),o=setTimeout(function(){i=""},1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){var r=function(){var u=t.searchInput.value.trim();u?t._filterCountries(u):t._filterCountries("",!0)},s=null;this._handleSearchChange=function(){s&&clearTimeout(s),s=setTimeout(function(){r(),s=null},100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",function(l){return l.stopPropagation()})}}},{key:"_normaliseString",value:function(){var t=arguments.length>0&&arguments[0]!==h?arguments[0]:"";return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}},{key:"_filterCountries",value:function(t){var e=arguments.length>1&&arguments[1]!==h?arguments[1]:!1,i=!0;this.countryList.innerHTML="";for(var o=this._normaliseString(t),r=0;r1&&(e=t==="ArrowUp"?this.countryList.lastElementChild:this.countryList.firstElementChild),e){var i=!this.options.countrySearch;this._highlightListItem(e,i),this.options.countrySearch&&this._scrollTo(e,!1)}}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(t){for(var e=0;el){e&&(v+=f);var L=r-u;i.scrollTop=v-L}}},{key:"_updateDialCode",value:function(t){var e=this.telInput.value,i="+".concat(t),o;if(e.charAt(0)==="+"){var r=this._getDialCode(e);r?o=e.replace(r,i):o=i,this.telInput.value=o}else this.options.autoInsertDialCode&&(e?o=i+e:o=i,this.telInput.value=o)}},{key:"_getDialCode",value:function(t,e){var i="";if(t.charAt(0)==="+")for(var o="",r=0;rut});module.exports=lt(dt);var b=z(require("react")),d=z(require("prop-types")),J=z(Y()),V=({initialValue:h,onChangeNumber:p,onChangeCountry:g,onChangeValidity:m,onChangeErrorCode:_,initOptions:x,className:O,disabled:U,onFocus:B,onBlur:E,placeholder:j})=>{let S=(0,b.useRef)(null),C=(0,b.useRef)(null),w=()=>{let I=C.current.getNumber(),N=C.current.getSelectedCountryData().iso2;if(p(I),g(N),C.current.isValidNumber())m(!0),_(null);else{let G=C.current.getValidationError();m(!1),_(G)}};return(0,b.useEffect)(()=>{let I=S.current;return C.current=(0,J.default)(S.current,x),I.addEventListener("countrychange",w),()=>{I.removeEventListener("countrychange",w),C.current.destroy()}},[]),b.default.createElement("input",{type:"tel",ref:S,onInput:w,defaultValue:h,className:O,disabled:U,onFocus:B,onBlur:E,placeholder:j})};V.propTypes={initialValue:d.default.string,placeholder:d.default.string,onChangeNumber:d.default.func,onChangeCountry:d.default.func,onChangeValidity:d.default.func,onChangeErrorCode:d.default.func,initOptions:d.default.shape({allowDropdown:d.default.bool,autoInsertDialCode:d.default.bool,autoPlaceholder:d.default.string,containerClass:d.default.string,countrySearch:d.default.bool,customPlaceholder:d.default.func,dropdownContainer:d.default.node,excludeCountries:d.default.arrayOf(d.default.string),fixDropdownWidth:d.default.bool,formatAsYouType:d.default.bool,formatOnDisplay:d.default.bool,geoIpLookup:d.default.func,hiddenInput:d.default.func,i18n:d.default.objectOf(d.default.string),initialCountry:d.default.string,nationalMode:d.default.bool,onlyCountries:d.default.arrayOf(d.default.string),placeholderNumberType:d.default.string,preferredCountries:d.default.arrayOf(d.default.string),showFlags:d.default.bool,showSelectedDialCode:d.default.bool,useFullscreenPopup:d.default.bool,utilsScript:d.default.string}),className:d.default.string,disabled:d.default.bool,onFocus:d.default.func,onBlur:d.default.func};V.defaultProps={initialValue:"",placeholder:"",onChangeNumber:()=>{},onChangeCountry:()=>{},onChangeValidity:()=>{},onChangeErrorCode:()=>{},initOptions:{},className:"",disabled:!1,onFocus:()=>{},onBlur:()=>{}};var ut=V; //# sourceMappingURL=IntlTelInput.cjs.js.map diff --git a/react/build/IntlTelInput.cjs.js.map b/react/build/IntlTelInput.cjs.js.map index ade219480..3bc38bf3e 100644 --- a/react/build/IntlTelInput.cjs.js.map +++ b/react/build/IntlTelInput.cjs.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../build/js/intlTelInput.js", "../src/IntlTelInput.js"], - "sourcesContent": ["/*\n * International Telephone Input v19.5.2\n * https://github.com/jackocnr/intl-tel-input.git\n * Licensed under the MIT license\n */\n\n// wrap in UMD\n(function(factory) {\n if (typeof module === \"object\" && module.exports) module.exports = factory(); else window.intlTelInput = factory();\n})(function(undefined) {\n \"use strict\";\n return function() {\n // Array of country objects for the flag dropdown.\n // Here is the criteria for the plugin to support a given country/territory\n // - It has an iso2 code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2\n // - It has it's own country calling code (it is not a sub-region of another country): https://en.wikipedia.org/wiki/List_of_country_calling_codes\n // - It has a flag in the region-flags project: https://github.com/behdad/region-flags/tree/gh-pages/png\n // - It is supported by libphonenumber (it must be listed on this page): https://github.com/googlei18n/libphonenumber/blob/master/resources/ShortNumberMetadata.xml\n // Each country array has the following information:\n // [\n // Country name,\n // iso2 code,\n // International dial code,\n // Order (if >1 country with same dial code),\n // Area codes\n // ]\n var allCountries = [ [ \"Afghanistan\", \"af\", \"93\" ], [ \"Albania\", \"al\", \"355\" ], [ \"Algeria\", \"dz\", \"213\" ], [ \"American Samoa\", \"as\", \"1\", 5, [ \"684\" ] ], [ \"Andorra\", \"ad\", \"376\" ], [ \"Angola\", \"ao\", \"244\" ], [ \"Anguilla\", \"ai\", \"1\", 6, [ \"264\" ] ], [ \"Antigua & Barbuda\", \"ag\", \"1\", 7, [ \"268\" ] ], [ \"Argentina\", \"ar\", \"54\" ], [ \"Armenia\", \"am\", \"374\" ], [ \"Aruba\", \"aw\", \"297\" ], [ \"Ascension Island\", \"ac\", \"247\" ], [ \"Australia\", \"au\", \"61\", 0 ], [ \"Austria\", \"at\", \"43\" ], [ \"Azerbaijan\", \"az\", \"994\" ], [ \"Bahamas\", \"bs\", \"1\", 8, [ \"242\" ] ], [ \"Bahrain\", \"bh\", \"973\" ], [ \"Bangladesh\", \"bd\", \"880\" ], [ \"Barbados\", \"bb\", \"1\", 9, [ \"246\" ] ], [ \"Belarus\", \"by\", \"375\" ], [ \"Belgium\", \"be\", \"32\" ], [ \"Belize\", \"bz\", \"501\" ], [ \"Benin\", \"bj\", \"229\" ], [ \"Bermuda\", \"bm\", \"1\", 10, [ \"441\" ] ], [ \"Bhutan\", \"bt\", \"975\" ], [ \"Bolivia\", \"bo\", \"591\" ], [ \"Bosnia & Herzegovina\", \"ba\", \"387\" ], [ \"Botswana\", \"bw\", \"267\" ], [ \"Brazil\", \"br\", \"55\" ], [ \"British Indian Ocean Territory\", \"io\", \"246\" ], [ \"British Virgin Islands\", \"vg\", \"1\", 11, [ \"284\" ] ], [ \"Brunei\", \"bn\", \"673\" ], [ \"Bulgaria\", \"bg\", \"359\" ], [ \"Burkina Faso\", \"bf\", \"226\" ], [ \"Burundi\", \"bi\", \"257\" ], [ \"Cambodia\", \"kh\", \"855\" ], [ \"Cameroon\", \"cm\", \"237\" ], [ \"Canada\", \"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\", \"902\", \"905\" ] ], [ \"Cape Verde\", \"cv\", \"238\" ], [ \"Caribbean Netherlands\", \"bq\", \"599\", 1, [ \"3\", \"4\", \"7\" ] ], [ \"Cayman Islands\", \"ky\", \"1\", 12, [ \"345\" ] ], [ \"Central African Republic\", \"cf\", \"236\" ], [ \"Chad\", \"td\", \"235\" ], [ \"Chile\", \"cl\", \"56\" ], [ \"China\", \"cn\", \"86\" ], [ \"Christmas Island\", \"cx\", \"61\", 2, [ \"89164\" ] ], [ \"Cocos (Keeling) Islands\", \"cc\", \"61\", 1, [ \"89162\" ] ], [ \"Colombia\", \"co\", \"57\" ], [ \"Comoros\", \"km\", \"269\" ], [ \"Congo - Brazzaville\", \"cg\", \"242\" ], [ \"Congo - Kinshasa\", \"cd\", \"243\" ], [ \"Cook Islands\", \"ck\", \"682\" ], [ \"Costa Rica\", \"cr\", \"506\" ], [ \"C\u00F4te d\u2019Ivoire\", \"ci\", \"225\" ], [ \"Croatia\", \"hr\", \"385\" ], [ \"Cuba\", \"cu\", \"53\" ], [ \"Cura\u00E7ao\", \"cw\", \"599\", 0 ], [ \"Cyprus\", \"cy\", \"357\" ], [ \"Czech Republic\", \"cz\", \"420\" ], [ \"Denmark\", \"dk\", \"45\" ], [ \"Djibouti\", \"dj\", \"253\" ], [ \"Dominica\", \"dm\", \"1\", 13, [ \"767\" ] ], [ \"Dominican Republic\", \"do\", \"1\", 2, [ \"809\", \"829\", \"849\" ] ], [ \"Ecuador\", \"ec\", \"593\" ], [ \"Egypt\", \"eg\", \"20\" ], [ \"El Salvador\", \"sv\", \"503\" ], [ \"Equatorial Guinea\", \"gq\", \"240\" ], [ \"Eritrea\", \"er\", \"291\" ], [ \"Estonia\", \"ee\", \"372\" ], [ \"Eswatini\", \"sz\", \"268\" ], [ \"Ethiopia\", \"et\", \"251\" ], [ \"Falkland Islands\", \"fk\", \"500\" ], [ \"Faroe Islands\", \"fo\", \"298\" ], [ \"Fiji\", \"fj\", \"679\" ], [ \"Finland\", \"fi\", \"358\", 0 ], [ \"France\", \"fr\", \"33\" ], [ \"French Guiana\", \"gf\", \"594\" ], [ \"French Polynesia\", \"pf\", \"689\" ], [ \"Gabon\", \"ga\", \"241\" ], [ \"Gambia\", \"gm\", \"220\" ], [ \"Georgia\", \"ge\", \"995\" ], [ \"Germany\", \"de\", \"49\" ], [ \"Ghana\", \"gh\", \"233\" ], [ \"Gibraltar\", \"gi\", \"350\" ], [ \"Greece\", \"gr\", \"30\" ], [ \"Greenland\", \"gl\", \"299\" ], [ \"Grenada\", \"gd\", \"1\", 14, [ \"473\" ] ], [ \"Guadeloupe\", \"gp\", \"590\", 0 ], [ \"Guam\", \"gu\", \"1\", 15, [ \"671\" ] ], [ \"Guatemala\", \"gt\", \"502\" ], [ \"Guernsey\", \"gg\", \"44\", 1, [ \"1481\", \"7781\", \"7839\", \"7911\" ] ], [ \"Guinea\", \"gn\", \"224\" ], [ \"Guinea-Bissau\", \"gw\", \"245\" ], [ \"Guyana\", \"gy\", \"592\" ], [ \"Haiti\", \"ht\", \"509\" ], [ \"Honduras\", \"hn\", \"504\" ], [ \"Hong Kong\", \"hk\", \"852\" ], [ \"Hungary\", \"hu\", \"36\" ], [ \"Iceland\", \"is\", \"354\" ], [ \"India\", \"in\", \"91\" ], [ \"Indonesia\", \"id\", \"62\" ], [ \"Iran\", \"ir\", \"98\" ], [ \"Iraq\", \"iq\", \"964\" ], [ \"Ireland\", \"ie\", \"353\" ], [ \"Isle of Man\", \"im\", \"44\", 2, [ \"1624\", \"74576\", \"7524\", \"7924\", \"7624\" ] ], [ \"Israel\", \"il\", \"972\" ], [ \"Italy\", \"it\", \"39\", 0 ], [ \"Jamaica\", \"jm\", \"1\", 4, [ \"876\", \"658\" ] ], [ \"Japan\", \"jp\", \"81\" ], [ \"Jersey\", \"je\", \"44\", 3, [ \"1534\", \"7509\", \"7700\", \"7797\", \"7829\", \"7937\" ] ], [ \"Jordan\", \"jo\", \"962\" ], [ \"Kazakhstan\", \"kz\", \"7\", 1, [ \"33\", \"7\" ] ], [ \"Kenya\", \"ke\", \"254\" ], [ \"Kiribati\", \"ki\", \"686\" ], [ \"Kosovo\", \"xk\", \"383\" ], [ \"Kuwait\", \"kw\", \"965\" ], [ \"Kyrgyzstan\", \"kg\", \"996\" ], [ \"Laos\", \"la\", \"856\" ], [ \"Latvia\", \"lv\", \"371\" ], [ \"Lebanon\", \"lb\", \"961\" ], [ \"Lesotho\", \"ls\", \"266\" ], [ \"Liberia\", \"lr\", \"231\" ], [ \"Libya\", \"ly\", \"218\" ], [ \"Liechtenstein\", \"li\", \"423\" ], [ \"Lithuania\", \"lt\", \"370\" ], [ \"Luxembourg\", \"lu\", \"352\" ], [ \"Macau\", \"mo\", \"853\" ], [ \"Madagascar\", \"mg\", \"261\" ], [ \"Malawi\", \"mw\", \"265\" ], [ \"Malaysia\", \"my\", \"60\" ], [ \"Maldives\", \"mv\", \"960\" ], [ \"Mali\", \"ml\", \"223\" ], [ \"Malta\", \"mt\", \"356\" ], [ \"Marshall Islands\", \"mh\", \"692\" ], [ \"Martinique\", \"mq\", \"596\" ], [ \"Mauritania\", \"mr\", \"222\" ], [ \"Mauritius\", \"mu\", \"230\" ], [ \"Mayotte\", \"yt\", \"262\", 1, [ \"269\", \"639\" ] ], [ \"Mexico\", \"mx\", \"52\" ], [ \"Micronesia\", \"fm\", \"691\" ], [ \"Moldova\", \"md\", \"373\" ], [ \"Monaco\", \"mc\", \"377\" ], [ \"Mongolia\", \"mn\", \"976\" ], [ \"Montenegro\", \"me\", \"382\" ], [ \"Montserrat\", \"ms\", \"1\", 16, [ \"664\" ] ], [ \"Morocco\", \"ma\", \"212\", 0 ], [ \"Mozambique\", \"mz\", \"258\" ], [ \"Myanmar (Burma)\", \"mm\", \"95\" ], [ \"Namibia\", \"na\", \"264\" ], [ \"Nauru\", \"nr\", \"674\" ], [ \"Nepal\", \"np\", \"977\" ], [ \"Netherlands\", \"nl\", \"31\" ], [ \"New Caledonia\", \"nc\", \"687\" ], [ \"New Zealand\", \"nz\", \"64\" ], [ \"Nicaragua\", \"ni\", \"505\" ], [ \"Niger\", \"ne\", \"227\" ], [ \"Nigeria\", \"ng\", \"234\" ], [ \"Niue\", \"nu\", \"683\" ], [ \"Norfolk Island\", \"nf\", \"672\" ], [ \"North Korea\", \"kp\", \"850\" ], [ \"North Macedonia\", \"mk\", \"389\" ], [ \"Northern Mariana Islands\", \"mp\", \"1\", 17, [ \"670\" ] ], [ \"Norway\", \"no\", \"47\", 0 ], [ \"Oman\", \"om\", \"968\" ], [ \"Pakistan\", \"pk\", \"92\" ], [ \"Palau\", \"pw\", \"680\" ], [ \"Palestine\", \"ps\", \"970\" ], [ \"Panama\", \"pa\", \"507\" ], [ \"Papua New Guinea\", \"pg\", \"675\" ], [ \"Paraguay\", \"py\", \"595\" ], [ \"Peru\", \"pe\", \"51\" ], [ \"Philippines\", \"ph\", \"63\" ], [ \"Poland\", \"pl\", \"48\" ], [ \"Portugal\", \"pt\", \"351\" ], [ \"Puerto Rico\", \"pr\", \"1\", 3, [ \"787\", \"939\" ] ], [ \"Qatar\", \"qa\", \"974\" ], [ \"R\u00E9union\", \"re\", \"262\", 0 ], [ \"Romania\", \"ro\", \"40\" ], [ \"Russia\", \"ru\", \"7\", 0 ], [ \"Rwanda\", \"rw\", \"250\" ], [ \"Samoa\", \"ws\", \"685\" ], [ \"San Marino\", \"sm\", \"378\" ], [ \"S\u00E3o Tom\u00E9 & Pr\u00EDncipe\", \"st\", \"239\" ], [ \"Saudi Arabia\", \"sa\", \"966\" ], [ \"Senegal\", \"sn\", \"221\" ], [ \"Serbia\", \"rs\", \"381\" ], [ \"Seychelles\", \"sc\", \"248\" ], [ \"Sierra Leone\", \"sl\", \"232\" ], [ \"Singapore\", \"sg\", \"65\" ], [ \"Sint Maarten\", \"sx\", \"1\", 21, [ \"721\" ] ], [ \"Slovakia\", \"sk\", \"421\" ], [ \"Slovenia\", \"si\", \"386\" ], [ \"Solomon Islands\", \"sb\", \"677\" ], [ \"Somalia\", \"so\", \"252\" ], [ \"South Africa\", \"za\", \"27\" ], [ \"South Korea\", \"kr\", \"82\" ], [ \"South Sudan\", \"ss\", \"211\" ], [ \"Spain\", \"es\", \"34\" ], [ \"Sri Lanka\", \"lk\", \"94\" ], [ \"St Barth\u00E9lemy\", \"bl\", \"590\", 1 ], [ \"St Helena\", \"sh\", \"290\" ], [ \"St Kitts & Nevis\", \"kn\", \"1\", 18, [ \"869\" ] ], [ \"St Lucia\", \"lc\", \"1\", 19, [ \"758\" ] ], [ \"St Martin\", \"mf\", \"590\", 2 ], [ \"St Pierre & Miquelon\", \"pm\", \"508\" ], [ \"St Vincent & Grenadines\", \"vc\", \"1\", 20, [ \"784\" ] ], [ \"Sudan\", \"sd\", \"249\" ], [ \"Suriname\", \"sr\", \"597\" ], [ \"Svalbard & Jan Mayen\", \"sj\", \"47\", 1, [ \"79\" ] ], [ \"Sweden\", \"se\", \"46\" ], [ \"Switzerland\", \"ch\", \"41\" ], [ \"Syria\", \"sy\", \"963\" ], [ \"Taiwan\", \"tw\", \"886\" ], [ \"Tajikistan\", \"tj\", \"992\" ], [ \"Tanzania\", \"tz\", \"255\" ], [ \"Thailand\", \"th\", \"66\" ], [ \"Timor-Leste\", \"tl\", \"670\" ], [ \"Togo\", \"tg\", \"228\" ], [ \"Tokelau\", \"tk\", \"690\" ], [ \"Tonga\", \"to\", \"676\" ], [ \"Trinidad & Tobago\", \"tt\", \"1\", 22, [ \"868\" ] ], [ \"Tunisia\", \"tn\", \"216\" ], [ \"Turkey\", \"tr\", \"90\" ], [ \"Turkmenistan\", \"tm\", \"993\" ], [ \"Turks & Caicos Islands\", \"tc\", \"1\", 23, [ \"649\" ] ], [ \"Tuvalu\", \"tv\", \"688\" ], [ \"Uganda\", \"ug\", \"256\" ], [ \"Ukraine\", \"ua\", \"380\" ], [ \"United Arab Emirates\", \"ae\", \"971\" ], [ \"United Kingdom\", \"gb\", \"44\", 0 ], [ \"United States\", \"us\", \"1\", 0 ], [ \"Uruguay\", \"uy\", \"598\" ], [ \"US Virgin Islands\", \"vi\", \"1\", 24, [ \"340\" ] ], [ \"Uzbekistan\", \"uz\", \"998\" ], [ \"Vanuatu\", \"vu\", \"678\" ], [ \"Vatican City\", \"va\", \"39\", 1, [ \"06698\" ] ], [ \"Venezuela\", \"ve\", \"58\" ], [ \"Vietnam\", \"vn\", \"84\" ], [ \"Wallis & Futuna\", \"wf\", \"681\" ], [ \"Western Sahara\", \"eh\", \"212\", 1, [ \"5288\", \"5289\" ] ], [ \"Yemen\", \"ye\", \"967\" ], [ \"Zambia\", \"zm\", \"260\" ], [ \"Zimbabwe\", \"zw\", \"263\" ], [ \"\u00C5land Islands\", \"ax\", \"358\", 1, [ \"18\" ] ] ];\n // loop over all of the countries above, restructuring the data to be objects with named keys\n for (var i = 0; i < allCountries.length; i++) {\n var c = allCountries[i];\n allCountries[i] = {\n name: c[0],\n iso2: c[1],\n dialCode: c[2],\n priority: c[3] || 0,\n areaCodes: c[4] || null,\n nodeById: {}\n };\n }\n \"use strict\";\n function _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? Object(arguments[i]) : {};\n var ownKeys = Object.keys(source);\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function(sym) {\n return Object.getOwnPropertyDescriptor(source, sym).enumerable;\n }));\n }\n ownKeys.forEach(function(key) {\n _defineProperty(target, key, source[key]);\n });\n }\n return target;\n }\n function _defineProperty(obj, key, value) {\n key = _toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n }\n function _slicedToArray(arr, i) {\n return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();\n }\n function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n }\n function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) {\n arr2[i] = arr[i];\n }\n return arr2;\n }\n function _iterableToArrayLimit(arr, i) {\n var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"];\n if (null != _i) {\n var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1;\n try {\n if (_x = (_i = _i.call(arr)).next, 0 === i) {\n if (Object(_i) !== _i) return;\n _n = !1;\n } else for (;!(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {\n }\n } catch (err) {\n _d = !0, _e = err;\n } finally {\n try {\n if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;\n } finally {\n if (_d) throw _e;\n }\n }\n return _arr;\n }\n }\n function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n }\n function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n }\n function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);\n }\n }\n function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n }\n function _toPropertyKey(arg) {\n var key = _toPrimitive(arg, \"string\");\n return typeof key === \"symbol\" ? key : String(key);\n }\n function _toPrimitive(input, hint) {\n if (typeof input !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (typeof res !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n }\n var intlTelInputGlobals = {\n getInstance: function getInstance(input) {\n var id = input.getAttribute(\"data-intl-tel-input-id\");\n return window.intlTelInputGlobals.instances[id];\n },\n instances: {},\n // using a global like this allows us to mock it in the tests\n documentReady: function documentReady() {\n return document.readyState === \"complete\";\n }\n };\n if (typeof window === \"object\") {\n window.intlTelInputGlobals = intlTelInputGlobals;\n }\n // these vars persist through all instances of the plugin\n var id = 0;\n var defaults = {\n // whether or not to allow the dropdown\n allowDropdown: true,\n // auto insert dial code (A) on init, (B) on user selecting a country, (C) on calling setCountry\n autoInsertDialCode: false,\n // add a placeholder in the input with an example number for the selected country\n autoPlaceholder: \"polite\",\n // add a country search input at the top of the dropdown\n countrySearch: true,\n // modify the parentClass\n containerClass: \"\",\n // modify the auto placeholder\n customPlaceholder: null,\n // by default, initialise with the first country in the list selected (if no country set via the initial value or initialCountry option)\n defaultToFirstCountry: true,\n // append menu to specified element\n dropdownContainer: null,\n // don't display these countries\n excludeCountries: [],\n // fix the dropdown width to the input width (rather than being as wide as the longest country name)\n fixDropdownWidth: true,\n // format the number as the user types\n formatAsYouType: true,\n // format the input value during initialisation and on setNumber\n formatOnDisplay: true,\n // geoIp lookup function\n geoIpLookup: null,\n // inject a hidden input with this name, and on submit, populate it with the result of getNumber\n hiddenInput: null,\n // internationalise the plugin text e.g. search input placeholder, country names\n i18n: {},\n // initial country\n initialCountry: \"\",\n // national vs international formatting for numbers e.g. placeholders and displaying existing numbers\n nationalMode: true,\n // display only these countries\n onlyCountries: [],\n // number type to use for placeholders\n placeholderNumberType: \"MOBILE\",\n // the countries at the top of the list\n preferredCountries: [],\n // option to hide the flags - must be used with showSelectedDialCode, or allowDropdown=false\n showFlags: true,\n // display the international dial code next to the selected flag\n showSelectedDialCode: false,\n // use full screen popup instead of dropdown for country list\n useFullscreenPopup: typeof navigator !== \"undefined\" && typeof window !== \"undefined\" ? // we cannot just test screen size as some smartphones/website meta tags will report desktop\n // resolutions\n // Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'\n /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 500 : false,\n // specify the path to the libphonenumber script to enable validation/formatting\n utilsScript: \"\"\n };\n // https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes#Non-geographic_area_codes\n var regionlessNanpNumbers = [ \"800\", \"822\", \"833\", \"844\", \"855\", \"866\", \"877\", \"880\", \"881\", \"882\", \"883\", \"884\", \"885\", \"886\", \"887\", \"888\", \"889\" ];\n // run a method on each instance of the plugin\n var forEachInstance = function forEachInstance(method) {\n var instances = window.intlTelInputGlobals.instances;\n Object.values(instances).forEach(function(instance) {\n return instance[method]();\n });\n };\n // this is our plugin class that we will create an instance of\n // eslint-disable-next-line no-unused-vars\n var Iti = /*#__PURE__*/ function() {\n function Iti(input) {\n var customOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck(this, Iti);\n this.id = id++;\n this.telInput = input;\n this.activeItem = null;\n this.highlightedItem = null;\n // process specified options / defaults\n this.options = Object.assign({}, defaults, customOptions);\n this.hadInitialPlaceholder = Boolean(input.getAttribute(\"placeholder\"));\n }\n _createClass(Iti, [ {\n key: \"_init\",\n value: function _init() {\n var _this = this;\n // if showing fullscreen popup, do not fix the width\n if (this.options.useFullscreenPopup) {\n this.options.fixDropdownWidth = false;\n }\n // when search enabled, we must fix the width else it would change with different results\n if (this.options.countrySearch && !this.options.useFullscreenPopup) {\n this.options.fixDropdownWidth = true;\n }\n // if in nationalMode, do not insert dial codes\n if (this.options.nationalMode) {\n this.options.autoInsertDialCode = false;\n }\n // if showSelectedDialCode enabled, do not insert dial codes\n if (this.options.showSelectedDialCode) {\n this.options.autoInsertDialCode = false;\n }\n // force showFlags=true if there's a dropdown and we're not displaying the dial code,\n // as otherwise you just have a down arrow on it's own which doesn't make sense\n var forceShowFlags = this.options.allowDropdown && !this.options.showSelectedDialCode;\n if (!this.options.showFlags && forceShowFlags) {\n this.options.showFlags = true;\n }\n // on mobile, we want a full screen dropdown, so we must append it to the body\n if (this.options.useFullscreenPopup && !this.options.dropdownContainer) {\n this.options.dropdownContainer = document.body;\n }\n // check if input has one parent with RTL\n this.isRTL = !!this.telInput.closest(\"[dir=rtl]\");\n // these promises get resolved when their individual requests complete\n // this way the dev can do something like iti.promise.then(...) to know when all requests are\n // complete\n if (typeof Promise !== \"undefined\") {\n var autoCountryPromise = new Promise(function(resolve, reject) {\n _this.resolveAutoCountryPromise = resolve;\n _this.rejectAutoCountryPromise = reject;\n });\n var utilsScriptPromise = new Promise(function(resolve, reject) {\n _this.resolveUtilsScriptPromise = resolve;\n _this.rejectUtilsScriptPromise = reject;\n });\n this.promise = Promise.all([ autoCountryPromise, utilsScriptPromise ]);\n } else {\n // prevent errors when Promise doesn't exist\n this.resolveAutoCountryPromise = this.rejectAutoCountryPromise = function() {};\n this.resolveUtilsScriptPromise = this.rejectUtilsScriptPromise = function() {};\n }\n // in various situations there could be no country selected initially, but we need to be able\n // to assume this variable exists\n this.selectedCountryData = {};\n // process all the data: onlyCountries, excludeCountries, preferredCountries etc\n this._processCountryData();\n // generate the markup\n this._generateMarkup();\n // set the initial state of the input value and the selected flag\n this._setInitialState();\n // start all of the event listeners: autoInsertDialCode, input keydown, selectedFlag click\n this._initListeners();\n // utils script, and auto country\n this._initRequests();\n }\n }, {\n key: \"_processCountryData\",\n value: function _processCountryData() {\n // process onlyCountries or excludeCountries array if present\n this._processAllCountries();\n // generate this.dialCodes and this.dialCodeToIso2Map\n this._processDialCodes();\n // process the preferredCountries\n this._processPreferredCountries();\n // translate country names according to i18n option\n this._translateCountryNames();\n // sort countries by name\n if (this.options.onlyCountries.length || this.options.i18n) {\n this.countries.sort(this._countryNameSort);\n }\n }\n }, {\n key: \"_addToDialCodeMap\",\n value: function _addToDialCodeMap(iso2, dialCode, priority) {\n if (dialCode.length > this.dialCodeMaxLen) {\n this.dialCodeMaxLen = dialCode.length;\n }\n if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {\n this.dialCodeToIso2Map[dialCode] = [];\n }\n // bail if we already have this country for this dialCode\n for (var i = 0; i < this.dialCodeToIso2Map[dialCode].length; i++) {\n if (this.dialCodeToIso2Map[dialCode][i] === iso2) {\n return;\n }\n }\n // check for undefined as 0 is falsy\n var index = priority !== undefined ? priority : this.dialCodeToIso2Map[dialCode].length;\n this.dialCodeToIso2Map[dialCode][index] = iso2;\n }\n }, {\n key: \"_processAllCountries\",\n value: function _processAllCountries() {\n if (this.options.onlyCountries.length) {\n var lowerCaseOnlyCountries = this.options.onlyCountries.map(function(country) {\n return country.toLowerCase();\n });\n this.countries = allCountries.filter(function(country) {\n return lowerCaseOnlyCountries.indexOf(country.iso2) > -1;\n });\n } else if (this.options.excludeCountries.length) {\n var lowerCaseExcludeCountries = this.options.excludeCountries.map(function(country) {\n return country.toLowerCase();\n });\n this.countries = allCountries.filter(function(country) {\n return lowerCaseExcludeCountries.indexOf(country.iso2) === -1;\n });\n } else {\n this.countries = allCountries;\n }\n }\n }, {\n key: \"_translateCountryNames\",\n value: function _translateCountryNames() {\n for (var i = 0; i < this.countries.length; i++) {\n var iso2 = this.countries[i].iso2.toLowerCase();\n if (this.options.i18n.hasOwnProperty(iso2)) {\n this.countries[i].name = this.options.i18n[iso2];\n }\n }\n }\n }, {\n key: \"_countryNameSort\",\n value: function _countryNameSort(a, b) {\n if (a.name < b.name) {\n return -1;\n }\n if (a.name > b.name) {\n return 1;\n }\n return 0;\n }\n }, {\n key: \"_processDialCodes\",\n value: function _processDialCodes() {\n // here we store just dial codes, where the key is the dial code, and the value is true\n // e.g. { 1: true, 7: true, 20: true, ... }\n this.dialCodes = {};\n this.dialCodeMaxLen = 0;\n // here we map dialCodes (inc both dialCode and dialCode+areaCode) to iso2 codes\n /* e.g.\n * {\n * 1: [ 'us', 'ca', ... ], # all NANP countries\n * 12: [ 'us', 'ca', ... ], # subset of NANP countries\n * 120: [ 'us', 'ca' ], # just US and Canada\n * 1204: [ 'ca' ], # only Canada\n * ...\n * }\n */\n this.dialCodeToIso2Map = {};\n // first: add dial codes\n for (var i = 0; i < this.countries.length; i++) {\n var c = this.countries[i];\n if (!this.dialCodes[c.dialCode]) {\n this.dialCodes[c.dialCode] = true;\n }\n this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);\n }\n // next: add area codes\n // this is a second loop over countries, to make sure we have all of the \"root\" countries\n // already in the map, so that we can access them, as each time we add an area code substring\n // to the map, we also need to include the \"root\" country's code, as that also matches\n for (var _i = 0; _i < this.countries.length; _i++) {\n var _c = this.countries[_i];\n // area codes\n if (_c.areaCodes) {\n var rootIso2Code = this.dialCodeToIso2Map[_c.dialCode][0];\n // for each area code\n for (var j = 0; j < _c.areaCodes.length; j++) {\n var areaCode = _c.areaCodes[j];\n // for each digit in the area code to add all partial matches as well\n for (var k = 1; k < areaCode.length; k++) {\n var partialDialCode = _c.dialCode + areaCode.substr(0, k);\n // start with the root country, as that also matches this dial code\n this._addToDialCodeMap(rootIso2Code, partialDialCode);\n this._addToDialCodeMap(_c.iso2, partialDialCode);\n }\n // add the full area code\n this._addToDialCodeMap(_c.iso2, _c.dialCode + areaCode);\n }\n }\n }\n }\n }, {\n key: \"_processPreferredCountries\",\n value: function _processPreferredCountries() {\n this.preferredCountries = [];\n for (var i = 0; i < this.options.preferredCountries.length; i++) {\n var iso2 = this.options.preferredCountries[i].toLowerCase();\n var countryData = this._getCountryData(iso2, true);\n if (countryData) {\n this.preferredCountries.push(countryData);\n }\n }\n }\n }, {\n key: \"_createEl\",\n value: function _createEl(name, attrs, container) {\n var el = document.createElement(name);\n if (attrs) {\n Object.entries(attrs).forEach(function(_ref) {\n var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];\n return el.setAttribute(key, value);\n });\n }\n if (container) {\n container.appendChild(el);\n }\n return el;\n }\n }, {\n key: \"_generateMarkup\",\n value: function _generateMarkup() {\n this.telInput.classList.add(\"iti__tel-input\");\n // if autocomplete does not exist on the element and its form, then\n // prevent autocomplete as there's no safe, cross-browser event we can react to, so it can\n // easily put the plugin in an inconsistent state e.g. the wrong flag selected for the\n // autocompleted number, which on submit could mean wrong number is saved\n if (!this.telInput.hasAttribute(\"autocomplete\") && !(this.telInput.form && this.telInput.form.hasAttribute(\"autocomplete\"))) {\n this.telInput.setAttribute(\"autocomplete\", \"off\");\n }\n var _this$options = this.options, allowDropdown = _this$options.allowDropdown, showSelectedDialCode = _this$options.showSelectedDialCode, showFlags = _this$options.showFlags, containerClass = _this$options.containerClass, hiddenInput = _this$options.hiddenInput, dropdownContainer = _this$options.dropdownContainer, fixDropdownWidth = _this$options.fixDropdownWidth, useFullscreenPopup = _this$options.useFullscreenPopup, countrySearch = _this$options.countrySearch;\n // containers (mostly for positioning)\n var parentClass = \"iti\";\n if (allowDropdown) {\n parentClass += \" iti--allow-dropdown\";\n }\n if (showSelectedDialCode) {\n parentClass += \" iti--show-selected-dial-code\";\n }\n if (showFlags) {\n parentClass += \" iti--show-flags\";\n }\n if (containerClass) {\n parentClass += \" \".concat(containerClass);\n }\n if (!useFullscreenPopup) {\n parentClass += \" iti--inline-dropdown\";\n }\n var wrapper = this._createEl(\"div\", {\n \"class\": parentClass\n });\n this.telInput.parentNode.insertBefore(wrapper, this.telInput);\n // only hide the flagsContainer if allowDropdown, showFlags and showSelectedDialCode are all false\n var showFlagsContainer = allowDropdown || showFlags || showSelectedDialCode;\n if (showFlagsContainer) {\n this.flagsContainer = this._createEl(\"div\", {\n \"class\": \"iti__flag-container\"\n }, wrapper);\n }\n wrapper.appendChild(this.telInput);\n // selected flag (displayed to left of input)\n // using Aria tags for \"Select-Only Combobox Example\"\n // https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/\n if (showFlagsContainer) {\n this.selectedFlag = this._createEl(\"div\", _objectSpread({\n \"class\": \"iti__selected-flag\"\n }, allowDropdown && {\n role: \"combobox\",\n \"aria-haspopup\": \"listbox\",\n \"aria-controls\": \"iti-\".concat(this.id, \"__country-listbox\"),\n \"aria-expanded\": \"false\",\n \"aria-label\": this.options.i18n.selectedCountryAriaLabel || \"Selected country\"\n }), this.flagsContainer);\n }\n if (showFlags) {\n this.selectedFlagInner = this._createEl(\"div\", {\n \"class\": \"iti__flag iti__globe\"\n }, this.selectedFlag);\n }\n if (this.selectedFlag && this.telInput.disabled) {\n this.selectedFlag.setAttribute(\"aria-disabled\", \"true\");\n }\n if (showSelectedDialCode) {\n this.selectedDialCode = this._createEl(\"div\", {\n \"class\": \"iti__selected-dial-code\"\n }, this.selectedFlag);\n }\n if (allowDropdown) {\n if (!this.telInput.disabled) {\n // make element focusable and tab navigable\n this.selectedFlag.setAttribute(\"tabindex\", \"0\");\n }\n this.dropdownArrow = this._createEl(\"div\", {\n \"class\": \"iti__arrow\"\n }, this.selectedFlag);\n var extraClasses = fixDropdownWidth ? \"\" : \"iti--flexible-dropdown-width\";\n this.dropdownContent = this._createEl(\"div\", {\n \"class\": \"iti__dropdown-content iti__hide \".concat(extraClasses)\n });\n if (countrySearch) {\n this.searchInput = this._createEl(\"input\", {\n type: \"text\",\n \"class\": \"iti__search-input\",\n placeholder: this.options.i18n.searchPlaceholder || \"Search\"\n }, this.dropdownContent);\n }\n // country list: preferred countries, then divider, then all countries\n this.countryList = this._createEl(\"ul\", {\n \"class\": \"iti__country-list\",\n id: \"iti-\".concat(this.id, \"__country-listbox\"),\n role: \"listbox\",\n \"aria-label\": this.options.i18n.countryListAriaLabel || \"List of countries\"\n }, this.dropdownContent);\n if (this.preferredCountries.length && !countrySearch) {\n this._appendListItems(this.preferredCountries, \"iti__preferred\", true);\n this._createEl(\"li\", {\n \"class\": \"iti__divider\",\n \"aria-hidden\": \"true\"\n }, this.countryList);\n }\n this._appendListItems(this.countries, \"iti__standard\");\n // create dropdownContainer markup\n if (dropdownContainer) {\n var dropdownClasses = \"iti iti--container\";\n if (useFullscreenPopup) {\n dropdownClasses += \" iti--fullscreen-popup\";\n } else {\n dropdownClasses += \" iti--inline-dropdown\";\n }\n if (countrySearch) {\n dropdownClasses += \" iti--country-search\";\n }\n this.dropdown = this._createEl(\"div\", {\n \"class\": dropdownClasses\n });\n this.dropdown.appendChild(this.dropdownContent);\n } else {\n this.flagsContainer.appendChild(this.dropdownContent);\n }\n }\n if (hiddenInput) {\n var telInputName = this.telInput.getAttribute(\"name\");\n var result = hiddenInput(telInputName);\n var isObject = result !== null && typeof result === \"object\";\n var hiddenInputPhoneName;\n var hiddenInputCountryName;\n if (isObject) {\n hiddenInputPhoneName = result.phone || telInputName;\n hiddenInputCountryName = result.country || \"\".concat(hiddenInputPhoneName, \"_country\");\n } else {\n hiddenInputPhoneName = result || telInputName;\n hiddenInputCountryName = \"\".concat(hiddenInputPhoneName, \"_country\");\n }\n // Check if a name has been determined for the phone input field after all conditions\n if (!hiddenInputPhoneName) {\n return;\n }\n // Create hidden input for the full international number\n this.hiddenInput = this._createEl(\"input\", {\n type: \"hidden\",\n name: hiddenInputPhoneName\n });\n // Create hidden input for the selected country iso2 code\n this.hiddenInputCountry = this._createEl(\"input\", {\n type: \"hidden\",\n name: hiddenInputCountryName\n });\n wrapper.appendChild(this.hiddenInput);\n wrapper.appendChild(this.hiddenInputCountry);\n }\n }\n }, {\n key: \"_appendListItems\",\n value: function _appendListItems(countries, className, preferred) {\n for (var i = 0; i < countries.length; i++) {\n var c = countries[i];\n var idSuffix = preferred ? \"-preferred\" : \"\";\n var listItem = this._createEl(\"li\", {\n id: \"iti-\".concat(this.id, \"__item-\").concat(c.iso2).concat(idSuffix),\n \"class\": \"iti__country \".concat(className),\n tabindex: \"-1\",\n role: \"option\",\n \"data-dial-code\": c.dialCode,\n \"data-country-code\": c.iso2,\n \"aria-selected\": \"false\"\n }, this.countryList);\n // store this for later use e.g. country search filtering\n c.nodeById[this.id] = listItem;\n var content = \"\";\n // add the flag\n if (this.options.showFlags) {\n content += \"
\");\n }\n // and the country name and dial code\n content += \"\".concat(c.name, \"\");\n content += \"+\".concat(c.dialCode, \"\");\n listItem.insertAdjacentHTML(\"beforeend\", content);\n }\n }\n }, {\n key: \"_setInitialState\",\n value: function _setInitialState() {\n var overrideAutoCountry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n // fix firefox bug: when first load page (with input with value set to number with intl dial\n // code) and initialising plugin removes the dial code from the input, then refresh page,\n // and we try to init plugin again but this time on number without dial code so get grey flag\n var attributeValue = this.telInput.getAttribute(\"value\");\n var inputValue = this.telInput.value;\n var useAttribute = attributeValue && attributeValue.charAt(0) === \"+\" && (!inputValue || inputValue.charAt(0) !== \"+\");\n var val = useAttribute ? attributeValue : inputValue;\n var dialCode = this._getDialCode(val);\n var isRegionlessNanp = this._isRegionlessNanp(val);\n var _this$options2 = this.options, initialCountry = _this$options2.initialCountry, autoInsertDialCode = _this$options2.autoInsertDialCode, defaultToFirstCountry = _this$options2.defaultToFirstCountry;\n // if we already have a dial code, and it's not a regionlessNanp, we can go ahead and set the\n // flag, else fall back to the default country\n if (dialCode && !isRegionlessNanp) {\n this._updateFlagFromNumber(val);\n } else if (initialCountry !== \"auto\" || overrideAutoCountry) {\n var lowerInitialCountry = initialCountry ? initialCountry.toLowerCase() : \"\";\n var isValidInitialCountry = lowerInitialCountry && this._getCountryData(lowerInitialCountry, true);\n // see if we should select a flag\n if (isValidInitialCountry) {\n this._setFlag(lowerInitialCountry);\n } else {\n if (dialCode && isRegionlessNanp) {\n // has intl dial code, is regionless nanp, and no initialCountry, so default to US\n this._setFlag(\"us\");\n } else if (defaultToFirstCountry) {\n // no dial code and no initialCountry, so default to first in list\n this.defaultCountry = this.preferredCountries.length ? this.preferredCountries[0].iso2 : this.countries[0].iso2;\n if (!val) {\n this._setFlag(this.defaultCountry);\n }\n }\n }\n // if empty and autoInsertDialCode then insert the dial code\n if (!val && autoInsertDialCode) {\n this.telInput.value = \"+\".concat(this.selectedCountryData.dialCode);\n }\n }\n // NOTE: if initialCountry is set to auto, that will be handled separately\n // format - note this wont be run after _updateDialCode as that's only called if no val\n if (val) {\n this._updateValFromNumber(val);\n }\n }\n }, {\n key: \"_initListeners\",\n value: function _initListeners() {\n this._initKeyListeners();\n if (this.options.autoInsertDialCode) {\n this._initBlurListeners();\n }\n if (this.options.allowDropdown) {\n this._initDropdownListeners();\n }\n if (this.hiddenInput) {\n this._initHiddenInputListener();\n }\n }\n }, {\n key: \"_initHiddenInputListener\",\n value: function _initHiddenInputListener() {\n var _this2 = this;\n this._handleHiddenInputSubmit = function() {\n _this2.hiddenInput.value = _this2.getNumber();\n _this2.hiddenInputCountry.value = _this2.getSelectedCountryData().iso2;\n };\n if (this.telInput.form) {\n this.telInput.form.addEventListener(\"submit\", this._handleHiddenInputSubmit);\n }\n }\n }, {\n key: \"_initDropdownListeners\",\n value: function _initDropdownListeners() {\n var _this3 = this;\n // hack for input nested inside label (which is valid markup): clicking the selected-flag to\n // open the dropdown would then automatically trigger a 2nd click on the input which would\n // close it again\n this._handleLabelClick = function(e) {\n // if the dropdown is closed, then focus the input, else ignore the click\n if (_this3.dropdownContent.classList.contains(\"iti__hide\")) {\n _this3.telInput.focus();\n } else {\n e.preventDefault();\n }\n };\n var label = this.telInput.closest(\"label\");\n if (label) {\n label.addEventListener(\"click\", this._handleLabelClick);\n }\n // toggle country dropdown on click\n this._handleClickSelectedFlag = function() {\n // only intercept this event if we're opening the dropdown\n // else let it bubble up to the top (\"click-off-to-close\" listener)\n // we cannot just stopPropagation as it may be needed to close another instance\n if (_this3.dropdownContent.classList.contains(\"iti__hide\") && !_this3.telInput.disabled && !_this3.telInput.readOnly) {\n _this3._showDropdown();\n }\n };\n this.selectedFlag.addEventListener(\"click\", this._handleClickSelectedFlag);\n // open dropdown if selected flag is focused and they press up/down/space/enter\n this._handleFlagsContainerKeydown = function(e) {\n var isDropdownHidden = _this3.dropdownContent.classList.contains(\"iti__hide\");\n if (isDropdownHidden && [ \"ArrowUp\", \"ArrowDown\", \" \", \"Enter\" ].includes(e.key)) {\n // prevent form from being submitted if \"ENTER\" was pressed\n e.preventDefault();\n // prevent event from being handled again by document\n e.stopPropagation();\n _this3._showDropdown();\n }\n // allow navigation from dropdown to input on TAB\n if (e.key === \"Tab\") {\n _this3._closeDropdown();\n }\n };\n this.flagsContainer.addEventListener(\"keydown\", this._handleFlagsContainerKeydown);\n }\n }, {\n key: \"_initRequests\",\n value: function _initRequests() {\n var _this4 = this;\n // if the user has specified the path to the utils script, fetch it on window.load, else resolve\n if (this.options.utilsScript && !window.intlTelInputUtils) {\n // if the plugin is being initialised after the window.load event has already been fired\n if (window.intlTelInputGlobals.documentReady()) {\n window.intlTelInputGlobals.loadUtils(this.options.utilsScript);\n } else {\n // wait until the load event so we don't block any other requests e.g. the flags image\n window.addEventListener(\"load\", function() {\n window.intlTelInputGlobals.loadUtils(_this4.options.utilsScript);\n });\n }\n } else {\n this.resolveUtilsScriptPromise();\n }\n // dont bother with IP lookup if we already have a selected country\n if (this.options.initialCountry === \"auto\" && !this.selectedCountryData.iso2) {\n this._loadAutoCountry();\n } else {\n this.resolveAutoCountryPromise();\n }\n }\n }, {\n key: \"_loadAutoCountry\",\n value: function _loadAutoCountry() {\n var _this5 = this;\n // 3 options:\n // 1) already loaded (we're done)\n // 2) not already started loading (start)\n // 3) already started loading (do nothing - just wait for loading callback to fire)\n if (window.intlTelInputGlobals.autoCountry) {\n this.handleAutoCountry();\n } else if (!window.intlTelInputGlobals.startedLoadingAutoCountry) {\n // don't do this twice!\n window.intlTelInputGlobals.startedLoadingAutoCountry = true;\n if (typeof this.options.geoIpLookup === \"function\") {\n this.options.geoIpLookup(function() {\n var iso2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"\";\n var iso2Lower = iso2.toLowerCase();\n var isValidIso2 = iso2Lower && _this5._getCountryData(iso2Lower, true);\n if (isValidIso2) {\n window.intlTelInputGlobals.autoCountry = iso2Lower;\n // tell all instances the auto country is ready\n // TODO: this should just be the current instances\n // UPDATE: use setTimeout in case their geoIpLookup function calls this callback straight\n // away (e.g. if they have already done the geo ip lookup somewhere else). Using\n // setTimeout means that the current thread of execution will finish before executing\n // this, which allows the plugin to finish initialising.\n setTimeout(function() {\n return forEachInstance(\"handleAutoCountry\");\n });\n } else {\n _this5._setInitialState(true);\n forEachInstance(\"rejectAutoCountryPromise\");\n }\n }, function() {\n return forEachInstance(\"rejectAutoCountryPromise\");\n });\n }\n }\n }\n }, {\n key: \"_initKeyListeners\",\n value: function _initKeyListeners() {\n var _this6 = this;\n var userOverrideFormatting = false;\n // update flag on input event\n this._handleKeyEvent = function(e) {\n if (_this6._updateFlagFromNumber(_this6.telInput.value)) {\n _this6._triggerCountryChange();\n }\n // if user types their own formatting char (not a plus or a numeric), then set the override\n if (e && e.data && /[^+0-9]/.test(e.data)) {\n userOverrideFormatting = true;\n } else if (!/[^+0-9]/.test(_this6.telInput.value)) {\n userOverrideFormatting = false;\n }\n if (_this6.options.formatAsYouType && !userOverrideFormatting) {\n // maintain caret position after reformatting\n var currentCaretPos = _this6.telInput.selectionStart;\n var valueBeforeCaret = _this6.telInput.value.substring(0, currentCaretPos);\n var relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, \"\").length;\n var isDeleteForwards = e && e.inputType === \"deleteContentForward\";\n var formattedValue = _this6._formatNumberAsYouType();\n var newCaretPos = _this6._translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);\n _this6.telInput.value = formattedValue;\n _this6.telInput.setSelectionRange(newCaretPos, newCaretPos);\n }\n };\n this.telInput.addEventListener(\"input\", this._handleKeyEvent);\n // update flag on cut/paste events (now supported in all major browsers)\n this._handleClipboardEvent = function() {\n // hack because \"paste\" event is fired before input is updated\n setTimeout(_this6._handleKeyEvent);\n };\n this.telInput.addEventListener(\"cut\", this._handleClipboardEvent);\n this.telInput.addEventListener(\"paste\", this._handleClipboardEvent);\n }\n }, {\n key: \"_translateCursorPosition\",\n value: function _translateCursorPosition(relevantChars, formattedValue, prevCaretPos, isDeleteForwards) {\n // if the first char is a formatting char, and they backspace delete it:\n // cursor should stay at the start (pos 0), rather than stick to the first digit (pos 1)\n if (prevCaretPos === 0 && !isDeleteForwards) {\n return 0;\n }\n var count = 0;\n for (var i = 0; i < formattedValue.length; i++) {\n if (/[+0-9]/.test(formattedValue[i])) {\n count++;\n }\n // normal case: stop when you hit the right number of relevant chars\n // (cursor will be just after the final relevant char)\n if (count === relevantChars && !isDeleteForwards) {\n return i + 1;\n }\n // spacial case: delete forwards (fn + delete on a mac):\n // wait until hit one extra relevant char, and put the cursor just before it (after any formatting chars)\n if (isDeleteForwards && count === relevantChars + 1) {\n return i;\n }\n }\n return formattedValue.length;\n }\n }, {\n key: \"_cap\",\n value: function _cap(number) {\n var max = this.telInput.getAttribute(\"maxlength\");\n return max && number.length > max ? number.substr(0, max) : number;\n }\n }, {\n key: \"_initBlurListeners\",\n value: function _initBlurListeners() {\n var _this7 = this;\n // on blur or form submit: if just a dial code then remove it\n this._handleSubmitOrBlurEvent = function() {\n _this7._removeEmptyDialCode();\n };\n if (this.telInput.form) {\n this.telInput.form.addEventListener(\"submit\", this._handleSubmitOrBlurEvent);\n }\n this.telInput.addEventListener(\"blur\", this._handleSubmitOrBlurEvent);\n }\n }, {\n key: \"_removeEmptyDialCode\",\n value: function _removeEmptyDialCode() {\n if (this.telInput.value.charAt(0) === \"+\") {\n var numeric = this._getNumeric(this.telInput.value);\n // if just a plus, or if just a dial code\n if (!numeric || this.selectedCountryData.dialCode === numeric) {\n this.telInput.value = \"\";\n }\n }\n }\n }, {\n key: \"_getNumeric\",\n value: function _getNumeric(s) {\n return s.replace(/\\D/g, \"\");\n }\n }, {\n key: \"_trigger\",\n value: function _trigger(name) {\n var e = new Event(name, {\n bubbles: true,\n cancelable: true\n });\n this.telInput.dispatchEvent(e);\n }\n }, {\n key: \"_showDropdown\",\n value: function _showDropdown() {\n if (this.options.fixDropdownWidth) {\n this.dropdownContent.style.width = \"\".concat(this.telInput.offsetWidth, \"px\");\n }\n this.dropdownContent.classList.remove(\"iti__hide\");\n this.selectedFlag.setAttribute(\"aria-expanded\", \"true\");\n this._setDropdownPosition();\n if (this.options.countrySearch) {\n // start by highlighting the first item in the list\n var firstElementChild = this.countryList.firstElementChild;\n if (firstElementChild) {\n this._highlightListItem(firstElementChild, false);\n }\n this.searchInput.focus();\n } else if (this.activeItem) {\n // update highlighting and scroll to active list item\n this._highlightListItem(this.activeItem, false);\n this._scrollTo(this.activeItem, true);\n }\n // bind all the dropdown-related listeners: mouseover, click, click-off, keydown\n this._bindDropdownListeners();\n // update the arrow\n this.dropdownArrow.classList.add(\"iti__arrow--up\");\n this._trigger(\"open:countrydropdown\");\n }\n }, {\n key: \"_toggleClass\",\n value: function _toggleClass(el, className, shouldHaveClass) {\n if (shouldHaveClass && !el.classList.contains(className)) {\n el.classList.add(className);\n } else if (!shouldHaveClass && el.classList.contains(className)) {\n el.classList.remove(className);\n }\n }\n }, {\n key: \"_setDropdownPosition\",\n value: function _setDropdownPosition() {\n var _this8 = this;\n if (this.options.dropdownContainer) {\n this.options.dropdownContainer.appendChild(this.dropdown);\n }\n if (!this.options.useFullscreenPopup) {\n var pos = this.telInput.getBoundingClientRect();\n // windowTop from https://stackoverflow.com/a/14384091/217866\n var windowTop = document.documentElement.scrollTop;\n var inputTop = pos.top + windowTop;\n var dropdownHeight = this.dropdownContent.offsetHeight;\n // dropdownFitsBelow = (dropdownBottom < windowBottom)\n var dropdownFitsBelow = inputTop + this.telInput.offsetHeight + dropdownHeight < windowTop + window.innerHeight;\n var dropdownFitsAbove = inputTop - dropdownHeight > windowTop;\n // dont allow positioning above when country search enabled as the search box jumps around as you filter countries\n var positionDropdownAboveInput = !this.options.countrySearch && !dropdownFitsBelow && dropdownFitsAbove;\n // by default, the dropdown will be below the input. If we want to position it above the\n // input, we add the dropup class.\n this._toggleClass(this.dropdownContent, \"iti__dropdown-content--dropup\", positionDropdownAboveInput);\n // if dropdownContainer is enabled, calculate postion\n if (this.options.dropdownContainer) {\n // if we want to position the dropdown below the input, we need to add the input height to the top value\n var extraTop = positionDropdownAboveInput ? 0 : this.telInput.offsetHeight;\n // calculate placement\n this.dropdown.style.top = \"\".concat(inputTop + extraTop, \"px\");\n this.dropdown.style.left = \"\".concat(pos.left + document.body.scrollLeft, \"px\");\n // close menu on window scroll\n this._handleWindowScroll = function() {\n return _this8._closeDropdown();\n };\n window.addEventListener(\"scroll\", this._handleWindowScroll);\n }\n }\n }\n }, {\n key: \"_bindDropdownListeners\",\n value: function _bindDropdownListeners() {\n var _this9 = this;\n // when mouse over a list item, just highlight that one\n // we add the class \"highlight\", so if they hit \"enter\" we know which one to select\n this._handleMouseoverCountryList = function(e) {\n // handle event delegation, as we're listening for this event on the countryList\n var listItem = e.target.closest(\".iti__country\");\n if (listItem) {\n _this9._highlightListItem(listItem, false);\n }\n };\n this.countryList.addEventListener(\"mouseover\", this._handleMouseoverCountryList);\n // listen for country selection\n this._handleClickCountryList = function(e) {\n var listItem = e.target.closest(\".iti__country\");\n if (listItem) {\n _this9._selectListItem(listItem);\n }\n };\n this.countryList.addEventListener(\"click\", this._handleClickCountryList);\n // click off to close\n // (except when this initial opening click is bubbling up)\n // we cannot just stopPropagation as it may be needed to close another instance\n var isOpening = true;\n this._handleClickOffToClose = function() {\n if (!isOpening) {\n _this9._closeDropdown();\n }\n isOpening = false;\n };\n document.documentElement.addEventListener(\"click\", this._handleClickOffToClose);\n // listen for up/down scrolling, enter to select, or escape to close\n // use keydown as keypress doesn't fire for non-char keys and we want to catch if they\n // just hit down and hold it to scroll down (no keyup event).\n // listen on the document because that's where key events are triggered if no input has focus\n var query = \"\";\n var queryTimer = null;\n this._handleKeydownOnDropdown = function(e) {\n // prevent down key from scrolling the whole page,\n // and enter key from submitting a form etc\n if ([ \"ArrowUp\", \"ArrowDown\", \"Enter\", \"Escape\" ].includes(e.key)) {\n e.preventDefault();\n e.stopPropagation();\n // up and down to navigate\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n _this9._handleUpDownKey(e.key);\n } else if (e.key === \"Enter\") {\n _this9._handleEnterKey();\n } else if (e.key === \"Escape\") {\n _this9._closeDropdown();\n }\n }\n // alpha chars to perform search\n // regex allows one latin alpha char or space, based on https://stackoverflow.com/a/26900132/217866)\n if (!_this9.options.countrySearch && /^[a-zA-Z\u00C0-\u00FF\u0430-\u044F\u0410-\u042F ]$/.test(e.key)) {\n e.stopPropagation();\n // jump to countries that start with the query string\n if (queryTimer) {\n clearTimeout(queryTimer);\n }\n query += e.key.toLowerCase();\n _this9._searchForCountry(query);\n // if the timer hits 1 second, reset the query\n queryTimer = setTimeout(function() {\n query = \"\";\n }, 1e3);\n }\n };\n document.addEventListener(\"keydown\", this._handleKeydownOnDropdown);\n if (this.options.countrySearch) {\n var doFilter = function doFilter() {\n var inputQuery = _this9.searchInput.value.trim();\n if (inputQuery) {\n _this9._filterCountries(inputQuery);\n } else {\n _this9._filterCountries(\"\", true);\n }\n };\n var keyupTimer = null;\n this._handleSearchChange = function() {\n // filtering country nodes is expensive (lots of DOM manipulation), so rate limit it\n if (keyupTimer) {\n clearTimeout(keyupTimer);\n }\n keyupTimer = setTimeout(function() {\n doFilter();\n keyupTimer = null;\n }, 100);\n };\n this.searchInput.addEventListener(\"input\", this._handleSearchChange);\n // stop propagation on search input click, so doesn't trigger click-off-to-close listener\n this.searchInput.addEventListener(\"click\", function(e) {\n return e.stopPropagation();\n });\n }\n }\n }, {\n key: \"_normaliseString\",\n value: function _normaliseString() {\n var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"\";\n return s.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\").toLowerCase();\n }\n }, {\n key: \"_filterCountries\",\n value: function _filterCountries(query) {\n var isReset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var isFirst = true;\n this.countryList.innerHTML = \"\";\n var normalisedQuery = this._normaliseString(query);\n for (var i = 0; i < this.countries.length; i++) {\n var c = this.countries[i];\n var normalisedCountryName = this._normaliseString(c.name);\n var fullDialCode = \"+\".concat(c.dialCode);\n if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {\n this.countryList.appendChild(c.nodeById[this.id]);\n // highlight the first item\n if (isFirst) {\n this._highlightListItem(c.nodeById[this.id], false);\n isFirst = false;\n }\n }\n }\n }\n }, {\n key: \"_handleUpDownKey\",\n value: function _handleUpDownKey(key) {\n var next = key === \"ArrowUp\" ? this.highlightedItem.previousElementSibling : this.highlightedItem.nextElementSibling;\n if (next) {\n // skip the divider\n if (next.classList.contains(\"iti__divider\")) {\n next = key === \"ArrowUp\" ? next.previousElementSibling : next.nextElementSibling;\n }\n } else if (this.countryList.childElementCount > 1) {\n // otherwise, we must be at the end, so loop round again\n next = key === \"ArrowUp\" ? this.countryList.lastElementChild : this.countryList.firstElementChild;\n }\n if (next) {\n // if country search enabled, dont lose focus from the search input on up/down\n var doFocus = !this.options.countrySearch;\n this._highlightListItem(next, doFocus);\n if (this.options.countrySearch) {\n this._scrollTo(next, false);\n }\n }\n }\n }, {\n key: \"_handleEnterKey\",\n value: function _handleEnterKey() {\n if (this.highlightedItem) {\n this._selectListItem(this.highlightedItem);\n }\n }\n }, {\n key: \"_searchForCountry\",\n value: function _searchForCountry(query) {\n for (var i = 0; i < this.countries.length; i++) {\n if (this._startsWith(this.countries[i].name, query)) {\n var listItem = this.countries[i].nodeById[this.id];\n // update highlighting and scroll\n this._highlightListItem(listItem, false);\n this._scrollTo(listItem, true);\n break;\n }\n }\n }\n }, {\n key: \"_startsWith\",\n value: function _startsWith(a, b) {\n return a.substr(0, b.length).toLowerCase() === b;\n }\n }, {\n key: \"_updateValFromNumber\",\n value: function _updateValFromNumber(fullNumber) {\n var number = fullNumber;\n if (this.options.formatOnDisplay && window.intlTelInputUtils && this.selectedCountryData) {\n var useNational = this.options.nationalMode || number.charAt(0) !== \"+\" && !this.options.showSelectedDialCode;\n var _intlTelInputUtils$nu = intlTelInputUtils.numberFormat, NATIONAL = _intlTelInputUtils$nu.NATIONAL, INTERNATIONAL = _intlTelInputUtils$nu.INTERNATIONAL;\n var format = useNational ? NATIONAL : INTERNATIONAL;\n number = intlTelInputUtils.formatNumber(number, this.selectedCountryData.iso2, format);\n }\n number = this._beforeSetNumber(number);\n this.telInput.value = number;\n }\n }, {\n key: \"_updateFlagFromNumber\",\n value: function _updateFlagFromNumber(fullNumber) {\n var plusIndex = fullNumber.indexOf(\"+\");\n // if it contains a plus, discard any chars before it e.g. accidental space char.\n // this keeps the selected country auto-updating correctly, which we want as\n // libphonenumber's validation/getNumber methods will ignore these chars anyway\n var number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;\n // if we already have US/Canada selected, make sure the number starts\n // with a +1 so _getDialCode will be able to extract the area code\n // update: if we dont yet have selectedCountryData, but we're here (trying to update the flag\n // from the number), that means we're initialising the plugin with a number that already has a\n // dial code, so fine to ignore this bit\n var selectedDialCode = this.selectedCountryData.dialCode;\n var isNanp = selectedDialCode === \"1\";\n if (number && isNanp && number.charAt(0) !== \"+\") {\n if (number.charAt(0) !== \"1\") {\n number = \"1\".concat(number);\n }\n number = \"+\".concat(number);\n }\n // if showSelectedDialCode enabled, then consider the selected dial code to be part of the number\n if (this.options.showSelectedDialCode && selectedDialCode && number.charAt(0) !== \"+\") {\n number = \"+\".concat(selectedDialCode).concat(number);\n }\n // try and extract valid dial code from input\n var dialCode = this._getDialCode(number, true);\n var numeric = this._getNumeric(number);\n var iso2 = null;\n if (dialCode) {\n var iso2Codes = this.dialCodeToIso2Map[this._getNumeric(dialCode)];\n // check if the right country is already selected. this should be false if the number is\n // longer than the matched dial code because in this case we need to make sure that if\n // there are multiple country matches, that the first one is selected (note: we could\n // just check that here, but it requires the same loop that we already have later)\n var alreadySelected = iso2Codes.indexOf(this.selectedCountryData.iso2) !== -1 && numeric.length <= dialCode.length - 1;\n var isRegionlessNanpNumber = selectedDialCode === \"1\" && this._isRegionlessNanp(numeric);\n // only update the flag if:\n // A) NOT (we currently have a NANP flag selected, and the number is a regionlessNanp)\n // AND\n // B) the right country is not already selected\n if (!isRegionlessNanpNumber && !alreadySelected) {\n // if using onlyCountries option, iso2Codes[0] may be empty, so we must find the first\n // non-empty index\n for (var j = 0; j < iso2Codes.length; j++) {\n if (iso2Codes[j]) {\n iso2 = iso2Codes[j];\n break;\n }\n }\n }\n } else if (number.charAt(0) === \"+\" && numeric.length) {\n // invalid dial code, so empty\n // Note: use getNumeric here because the number has not been formatted yet, so could contain\n // bad chars\n iso2 = \"\";\n } else if ((!number || number === \"+\") && !this.selectedCountryData.iso2) {\n // if no selected flag, and user either clears the input, or just types a plus, then show default\n iso2 = this.defaultCountry;\n }\n if (iso2 !== null) {\n return this._setFlag(iso2);\n }\n return false;\n }\n }, {\n key: \"_isRegionlessNanp\",\n value: function _isRegionlessNanp(number) {\n var numeric = this._getNumeric(number);\n if (numeric.charAt(0) === \"1\") {\n var areaCode = numeric.substr(1, 3);\n return regionlessNanpNumbers.indexOf(areaCode) !== -1;\n }\n return false;\n }\n }, {\n key: \"_highlightListItem\",\n value: function _highlightListItem(listItem, shouldFocus) {\n var prevItem = this.highlightedItem;\n if (prevItem) {\n prevItem.classList.remove(\"iti__highlight\");\n }\n this.highlightedItem = listItem;\n this.highlightedItem.classList.add(\"iti__highlight\");\n this.selectedFlag.setAttribute(\"aria-activedescendant\", listItem.getAttribute(\"id\"));\n if (shouldFocus) {\n this.highlightedItem.focus();\n }\n }\n }, {\n key: \"_getCountryData\",\n value: function _getCountryData(iso2, allowFail) {\n for (var i = 0; i < this.countries.length; i++) {\n if (this.countries[i].iso2 === iso2) {\n return this.countries[i];\n }\n }\n if (allowFail) {\n return null;\n }\n throw new Error(\"No country data for '\".concat(iso2, \"'\"));\n }\n }, {\n key: \"_setFlag\",\n value: function _setFlag(iso2) {\n var _this$options3 = this.options, allowDropdown = _this$options3.allowDropdown, showSelectedDialCode = _this$options3.showSelectedDialCode, showFlags = _this$options3.showFlags, countrySearch = _this$options3.countrySearch;\n var prevCountry = this.selectedCountryData.iso2 ? this.selectedCountryData : {};\n // do this first as it will throw an error and stop if iso2 is invalid\n this.selectedCountryData = iso2 ? this._getCountryData(iso2, false) : {};\n // update the defaultCountry - we only need the iso2 from now on, so just store that\n if (this.selectedCountryData.iso2) {\n this.defaultCountry = this.selectedCountryData.iso2;\n }\n if (showFlags) {\n var flagClass = iso2 ? \"iti__\".concat(iso2) : \"iti__globe\";\n this.selectedFlagInner.setAttribute(\"class\", \"iti__flag \".concat(flagClass));\n }\n this._setSelectedCountryFlagTitleAttribute(iso2, showSelectedDialCode);\n if (showSelectedDialCode) {\n var dialCode = this.selectedCountryData.dialCode ? \"+\".concat(this.selectedCountryData.dialCode) : \"\";\n this.selectedDialCode.innerHTML = dialCode;\n // offsetWidth is zero if input is in a hidden container during initialisation\n var selectedFlagWidth = this.selectedFlag.offsetWidth || this._getHiddenSelectedFlagWidth();\n // add 6px of padding after the grey selected-dial-code box, as this is what we use in the css\n if (this.isRTL) {\n this.telInput.style.paddingRight = \"\".concat(selectedFlagWidth + 6, \"px\");\n } else {\n this.telInput.style.paddingLeft = \"\".concat(selectedFlagWidth + 6, \"px\");\n }\n }\n // and the input's placeholder\n this._updatePlaceholder();\n // update the active list item (only if country search disabled, as country search doesn't store the active item)\n if (allowDropdown && !countrySearch) {\n var prevItem = this.activeItem;\n if (prevItem) {\n prevItem.classList.remove(\"iti__active\");\n prevItem.setAttribute(\"aria-selected\", \"false\");\n }\n if (iso2) {\n // check if there is a preferred item first, else fall back to standard\n var nextItem = this.countryList.querySelector(\"#iti-\".concat(this.id, \"__item-\").concat(iso2, \"-preferred\")) || this.countryList.querySelector(\"#iti-\".concat(this.id, \"__item-\").concat(iso2));\n nextItem.setAttribute(\"aria-selected\", \"true\");\n nextItem.classList.add(\"iti__active\");\n this.activeItem = nextItem;\n }\n }\n // return if the flag has changed or not\n return prevCountry.iso2 !== iso2;\n }\n }, {\n key: \"_setSelectedCountryFlagTitleAttribute\",\n value: function _setSelectedCountryFlagTitleAttribute(iso2, showSelectedDialCode) {\n if (!this.selectedFlag) {\n return;\n }\n var title;\n if (iso2 && !showSelectedDialCode) {\n title = \"\".concat(this.selectedCountryData.name, \": +\").concat(this.selectedCountryData.dialCode);\n } else if (iso2) {\n // For screen reader output, we don't want to include the dial code in the reader output twice\n // so just use the selected country name here:\n title = this.selectedCountryData.name;\n } else {\n title = \"Unknown\";\n }\n this.selectedFlag.setAttribute(\"title\", title);\n }\n }, {\n key: \"_getHiddenSelectedFlagWidth\",\n value: function _getHiddenSelectedFlagWidth() {\n // to get the right styling to apply, all we need is a shallow clone of the container,\n // and then to inject a deep clone of the selectedFlag element\n var containerClone = this.telInput.parentNode.cloneNode();\n containerClone.style.visibility = \"hidden\";\n document.body.appendChild(containerClone);\n var flagsContainerClone = this.flagsContainer.cloneNode();\n containerClone.appendChild(flagsContainerClone);\n var selectedFlagClone = this.selectedFlag.cloneNode(true);\n flagsContainerClone.appendChild(selectedFlagClone);\n var width = selectedFlagClone.offsetWidth;\n containerClone.parentNode.removeChild(containerClone);\n return width;\n }\n }, {\n key: \"_updatePlaceholder\",\n value: function _updatePlaceholder() {\n var shouldSetPlaceholder = this.options.autoPlaceholder === \"aggressive\" || !this.hadInitialPlaceholder && this.options.autoPlaceholder === \"polite\";\n if (window.intlTelInputUtils && shouldSetPlaceholder) {\n var numberType = intlTelInputUtils.numberType[this.options.placeholderNumberType];\n var placeholder = this.selectedCountryData.iso2 ? intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2, this.options.nationalMode, numberType) : \"\";\n placeholder = this._beforeSetNumber(placeholder);\n if (typeof this.options.customPlaceholder === \"function\") {\n placeholder = this.options.customPlaceholder(placeholder, this.selectedCountryData);\n }\n this.telInput.setAttribute(\"placeholder\", placeholder);\n }\n }\n }, {\n key: \"_selectListItem\",\n value: function _selectListItem(listItem) {\n // update selected flag and active list item\n var flagChanged = this._setFlag(listItem.getAttribute(\"data-country-code\"));\n this._closeDropdown();\n this._updateDialCode(listItem.getAttribute(\"data-dial-code\"));\n // focus the input\n this.telInput.focus();\n if (flagChanged) {\n this._triggerCountryChange();\n }\n }\n }, {\n key: \"_closeDropdown\",\n value: function _closeDropdown() {\n this.dropdownContent.classList.add(\"iti__hide\");\n this.selectedFlag.setAttribute(\"aria-expanded\", \"false\");\n this.selectedFlag.removeAttribute(\"aria-activedescendant\");\n // update the arrow\n this.dropdownArrow.classList.remove(\"iti__arrow--up\");\n // unbind key events\n document.removeEventListener(\"keydown\", this._handleKeydownOnDropdown);\n if (this.options.countrySearch) {\n this.searchInput.removeEventListener(\"input\", this._handleSearchChange);\n }\n document.documentElement.removeEventListener(\"click\", this._handleClickOffToClose);\n this.countryList.removeEventListener(\"mouseover\", this._handleMouseoverCountryList);\n this.countryList.removeEventListener(\"click\", this._handleClickCountryList);\n // remove menu from container\n if (this.options.dropdownContainer) {\n if (!this.options.useFullscreenPopup) {\n window.removeEventListener(\"scroll\", this._handleWindowScroll);\n }\n if (this.dropdown.parentNode) {\n this.dropdown.parentNode.removeChild(this.dropdown);\n }\n }\n this._trigger(\"close:countrydropdown\");\n }\n }, {\n key: \"_scrollTo\",\n value: function _scrollTo(element, middle) {\n var container = this.countryList;\n // windowTop from https://stackoverflow.com/a/14384091/217866\n var windowTop = document.documentElement.scrollTop;\n var containerHeight = container.offsetHeight;\n var containerTop = container.getBoundingClientRect().top + windowTop;\n var containerBottom = containerTop + containerHeight;\n var elementHeight = element.offsetHeight;\n var elementTop = element.getBoundingClientRect().top + windowTop;\n var elementBottom = elementTop + elementHeight;\n var newScrollTop = elementTop - containerTop + container.scrollTop;\n var middleOffset = containerHeight / 2 - elementHeight / 2;\n if (elementTop < containerTop) {\n // scroll up\n if (middle) {\n newScrollTop -= middleOffset;\n }\n container.scrollTop = newScrollTop;\n } else if (elementBottom > containerBottom) {\n // scroll down\n if (middle) {\n newScrollTop += middleOffset;\n }\n var heightDifference = containerHeight - elementHeight;\n container.scrollTop = newScrollTop - heightDifference;\n }\n }\n }, {\n key: \"_updateDialCode\",\n value: function _updateDialCode(newDialCodeBare) {\n var inputVal = this.telInput.value;\n // save having to pass this every time\n var newDialCode = \"+\".concat(newDialCodeBare);\n var newNumber;\n if (inputVal.charAt(0) === \"+\") {\n // there's a plus so we're dealing with a replacement\n var prevDialCode = this._getDialCode(inputVal);\n if (prevDialCode) {\n // current number contains a valid dial code, so replace it\n newNumber = inputVal.replace(prevDialCode, newDialCode);\n } else {\n // current number contains an invalid dial code, so ditch it\n // (no way to determine where the invalid dial code ends and the rest of the number begins)\n newNumber = newDialCode;\n }\n this.telInput.value = newNumber;\n } else if (this.options.autoInsertDialCode) {\n if (inputVal) {\n // there is an existing value with no dial code: prefix the new dial code\n newNumber = newDialCode + inputVal;\n } else {\n newNumber = newDialCode;\n }\n this.telInput.value = newNumber;\n }\n }\n }, {\n key: \"_getDialCode\",\n value: function _getDialCode(number, includeAreaCode) {\n var dialCode = \"\";\n // only interested in international numbers (starting with a plus)\n if (number.charAt(0) === \"+\") {\n var numericChars = \"\";\n // iterate over chars\n for (var i = 0; i < number.length; i++) {\n var c = number.charAt(i);\n // if char is number (https://stackoverflow.com/a/8935649/217866)\n if (!isNaN(parseInt(c, 10))) {\n numericChars += c;\n // if current numericChars make a valid dial code\n if (includeAreaCode) {\n if (this.dialCodeToIso2Map[numericChars]) {\n // store the actual raw string (useful for matching later)\n dialCode = number.substr(0, i + 1);\n }\n } else {\n if (this.dialCodes[numericChars]) {\n dialCode = number.substr(0, i + 1);\n // if we're just looking for a dial code, we can break as soon as we find one\n break;\n }\n }\n // stop searching as soon as we can - in this case when we hit max len\n if (numericChars.length === this.dialCodeMaxLen) {\n break;\n }\n }\n }\n }\n return dialCode;\n }\n }, {\n key: \"_getFullNumber\",\n value: function _getFullNumber() {\n var val = this.telInput.value.trim();\n var dialCode = this.selectedCountryData.dialCode;\n var prefix;\n var numericVal = this._getNumeric(val);\n if (this.options.showSelectedDialCode && !this.options.nationalMode && val.charAt(0) !== \"+\" && dialCode && numericVal) {\n // when using showSelectedDialCode, it is visible so is effectively part of the typed number\n prefix = \"+\".concat(dialCode);\n } else {\n prefix = \"\";\n }\n return prefix + val;\n }\n }, {\n key: \"_beforeSetNumber\",\n value: function _beforeSetNumber(fullNumber) {\n var number = fullNumber;\n if (this.options.showSelectedDialCode) {\n var dialCode = this._getDialCode(number);\n // if there is a valid dial code\n if (dialCode) {\n // in case _getDialCode returned an area code as well\n dialCode = \"+\".concat(this.selectedCountryData.dialCode);\n // a lot of numbers will have a space separating the dial code and the main number, and\n // some NANP numbers will have a hyphen e.g. +1 684-733-1234 - in both cases we want to get\n // rid of it\n // NOTE: don't just trim all non-numerics as may want to preserve an open parenthesis etc\n var start = number[dialCode.length] === \" \" || number[dialCode.length] === \"-\" ? dialCode.length + 1 : dialCode.length;\n number = number.substr(start);\n }\n }\n return this._cap(number);\n }\n }, {\n key: \"_triggerCountryChange\",\n value: function _triggerCountryChange() {\n this._trigger(\"countrychange\");\n }\n }, {\n key: \"_formatNumberAsYouType\",\n value: function _formatNumberAsYouType() {\n var val = this._getFullNumber();\n var result = window.intlTelInputUtils ? intlTelInputUtils.formatNumberAsYouType(val, this.selectedCountryData.iso2) : val;\n // if showSelectedDialCode and they haven't (re)typed the dial code in the input as well, then remove the dial code\n var dialCode = this.selectedCountryData.dialCode;\n if (this.options.showSelectedDialCode && !this.options.nationalMode && this.telInput.value.charAt(0) !== \"+\" && result.includes(\"+\".concat(dialCode))) {\n var afterDialCode = result.split(\"+\".concat(dialCode))[1] || \"\";\n return afterDialCode.trim();\n }\n return result;\n }\n }, {\n key: \"handleAutoCountry\",\n value: function handleAutoCountry() {\n if (this.options.initialCountry === \"auto\") {\n // we must set this even if there is an initial val in the input: in case the initial val is\n // invalid and they delete it - they should see their auto country\n this.defaultCountry = window.intlTelInputGlobals.autoCountry;\n // if there's no initial value in the input, then update the flag\n if (!this.telInput.value) {\n this.setCountry(this.defaultCountry);\n }\n this.resolveAutoCountryPromise();\n }\n }\n }, {\n key: \"handleUtils\",\n value: function handleUtils() {\n // if the request was successful\n if (window.intlTelInputUtils) {\n // if there's an initial value in the input, then format it\n if (this.telInput.value) {\n this._updateValFromNumber(this.telInput.value);\n }\n this._updatePlaceholder();\n }\n this.resolveUtilsScriptPromise();\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n var form = this.telInput.form;\n if (this.options.allowDropdown) {\n // make sure the dropdown is closed (and unbind listeners)\n this._closeDropdown();\n this.selectedFlag.removeEventListener(\"click\", this._handleClickSelectedFlag);\n this.flagsContainer.removeEventListener(\"keydown\", this._handleFlagsContainerKeydown);\n // label click hack\n var label = this.telInput.closest(\"label\");\n if (label) {\n label.removeEventListener(\"click\", this._handleLabelClick);\n }\n }\n // unbind hiddenInput listeners\n if (this.hiddenInput && form) {\n form.removeEventListener(\"submit\", this._handleHiddenInputSubmit);\n }\n // unbind autoInsertDialCode listeners\n if (this.options.autoInsertDialCode) {\n if (form) {\n form.removeEventListener(\"submit\", this._handleSubmitOrBlurEvent);\n }\n this.telInput.removeEventListener(\"blur\", this._handleSubmitOrBlurEvent);\n }\n // unbind key events, and cut/paste events\n this.telInput.removeEventListener(\"input\", this._handleKeyEvent);\n this.telInput.removeEventListener(\"cut\", this._handleClipboardEvent);\n this.telInput.removeEventListener(\"paste\", this._handleClipboardEvent);\n // remove attribute of id instance: data-intl-tel-input-id\n this.telInput.removeAttribute(\"data-intl-tel-input-id\");\n // remove markup (but leave the original input)\n var wrapper = this.telInput.parentNode;\n wrapper.parentNode.insertBefore(this.telInput, wrapper);\n wrapper.parentNode.removeChild(wrapper);\n delete window.intlTelInputGlobals.instances[this.id];\n }\n }, {\n key: \"getExtension\",\n value: function getExtension() {\n if (window.intlTelInputUtils) {\n return intlTelInputUtils.getExtension(this._getFullNumber(), this.selectedCountryData.iso2);\n }\n return \"\";\n }\n }, {\n key: \"getNumber\",\n value: function getNumber(format) {\n if (window.intlTelInputUtils) {\n var iso2 = this.selectedCountryData.iso2;\n return intlTelInputUtils.formatNumber(this._getFullNumber(), iso2, format);\n }\n return \"\";\n }\n }, {\n key: \"getNumberType\",\n value: function getNumberType() {\n if (window.intlTelInputUtils) {\n return intlTelInputUtils.getNumberType(this._getFullNumber(), this.selectedCountryData.iso2);\n }\n return -99;\n }\n }, {\n key: \"getSelectedCountryData\",\n value: function getSelectedCountryData() {\n return this.selectedCountryData;\n }\n }, {\n key: \"getValidationError\",\n value: function getValidationError() {\n if (window.intlTelInputUtils) {\n var iso2 = this.selectedCountryData.iso2;\n return intlTelInputUtils.getValidationError(this._getFullNumber(), iso2);\n }\n return -99;\n }\n }, {\n key: \"isValidNumber\",\n value: function isValidNumber() {\n var val = this._getFullNumber();\n return window.intlTelInputUtils ? intlTelInputUtils.isPossibleNumber(val, this.selectedCountryData.iso2) : null;\n }\n }, {\n key: \"isValidNumberPrecise\",\n value: function isValidNumberPrecise() {\n var val = this._getFullNumber();\n return window.intlTelInputUtils ? intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2) : null;\n }\n }, {\n key: \"setCountry\",\n value: function setCountry(iso2) {\n var iso2Lower = iso2.toLowerCase();\n // check if already selected\n if (this.selectedCountryData.iso2 !== iso2Lower) {\n this._setFlag(iso2Lower);\n this._updateDialCode(this.selectedCountryData.dialCode);\n this._triggerCountryChange();\n }\n }\n }, {\n key: \"setNumber\",\n value: function setNumber(number) {\n // we must update the flag first, which updates this.selectedCountryData, which is used for\n // formatting the number before displaying it\n var flagChanged = this._updateFlagFromNumber(number);\n this._updateValFromNumber(number);\n if (flagChanged) {\n this._triggerCountryChange();\n }\n }\n }, {\n key: \"setPlaceholderNumberType\",\n value: function setPlaceholderNumberType(type) {\n this.options.placeholderNumberType = type;\n this._updatePlaceholder();\n }\n } ]);\n return Iti;\n }();\n /********************\n * STATIC METHODS\n ********************/\n // get the country data object\n intlTelInputGlobals.getCountryData = function() {\n return allCountries;\n };\n // inject a