intl-tel-input 25.0.1 → 25.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { mergeModels as D, useModel as x, ref as L, onMounted as E, watch as M, onUnmounted as F, withDirectives as B, openBlock as O, createElementBlock as V, mergeProps as z, vModelText as R } from "vue";
2
- const N = [
1
+ import { mergeModels as D, useModel as x, ref as L, onMounted as E, watch as M, onUnmounted as F, withDirectives as B, openBlock as V, createElementBlock as O, mergeProps as z, vModelText as R } from "vue";
2
+ const A = [
3
3
  [
4
4
  "af",
5
5
  // Afghanistan
@@ -9,8 +9,7 @@ const N = [
9
9
  "ax",
10
10
  // Åland Islands
11
11
  "358",
12
- 1,
13
- ["18"]
12
+ 1
14
13
  ],
15
14
  [
16
15
  "al",
@@ -1306,15 +1305,16 @@ const N = [
1306
1305
  "263"
1307
1306
  ]
1308
1307
  ], I = [];
1309
- for (let u = 0; u < N.length; u++) {
1310
- const t = N[u];
1308
+ for (let u = 0; u < A.length; u++) {
1309
+ const e = A[u];
1311
1310
  I[u] = {
1312
1311
  name: "",
1313
1312
  // this is now populated in the plugin
1314
- iso2: t[0],
1315
- dialCode: t[1],
1316
- priority: t[2] || 0,
1317
- areaCodes: t[3] || null,
1313
+ iso2: e[0],
1314
+ dialCode: e[1],
1315
+ priority: e[2] || 0,
1316
+ areaCodes: e[3] || null,
1317
+ partialAreaCodes: null,
1318
1318
  nodeById: {}
1319
1319
  };
1320
1320
  }
@@ -1649,46 +1649,46 @@ const T = {
1649
1649
  "887",
1650
1650
  "888",
1651
1651
  "889"
1652
- ], v = (u) => u.replace(/\D/g, ""), A = (u = "") => u.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), S = (u) => {
1653
- const t = v(u);
1654
- if (t.charAt(0) === "1") {
1655
- const e = t.substr(1, 3);
1656
- return K.indexOf(e) !== -1;
1652
+ ], v = (u) => u.replace(/\D/g, ""), N = (u = "") => u.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), S = (u) => {
1653
+ const e = v(u);
1654
+ if (e.charAt(0) === "1") {
1655
+ const t = e.substr(1, 3);
1656
+ return K.indexOf(t) !== -1;
1657
1657
  }
1658
1658
  return !1;
1659
- }, H = (u, t, e, i) => {
1660
- if (e === 0 && !i)
1659
+ }, H = (u, e, t, i) => {
1660
+ if (t === 0 && !i)
1661
1661
  return 0;
1662
1662
  let s = 0;
1663
- for (let n = 0; n < t.length; n++) {
1664
- if (/[+0-9]/.test(t[n]) && s++, s === u && !i)
1663
+ for (let n = 0; n < e.length; n++) {
1664
+ if (/[+0-9]/.test(e[n]) && s++, s === u && !i)
1665
1665
  return n + 1;
1666
1666
  if (i && s === u + 1)
1667
1667
  return n;
1668
1668
  }
1669
- return t.length;
1670
- }, y = (u, t, e) => {
1669
+ return e.length;
1670
+ }, y = (u, e, t) => {
1671
1671
  const i = document.createElement(u);
1672
- return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
1673
- }, w = (u, ...t) => {
1674
- const { instances: e } = l;
1675
- Object.values(e).forEach((i) => i[u](...t));
1672
+ return e && Object.entries(e).forEach(([s, n]) => i.setAttribute(s, n)), t && t.appendChild(i), i;
1673
+ }, w = (u, ...e) => {
1674
+ const { instances: t } = l;
1675
+ Object.values(t).forEach((i) => i[u](...e));
1676
1676
  };
1677
1677
  class G {
1678
- constructor(t, e = {}) {
1679
- this.id = U++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, T, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
1678
+ constructor(e, t = {}) {
1679
+ this.id = U++, this.telInput = e, this.highlightedItem = null, this.options = Object.assign({}, T, t), this.hadInitialPlaceholder = !!e.getAttribute("placeholder");
1680
1680
  }
1681
1681
  //* Can't be private as it's called from intlTelInput convenience wrapper.
1682
1682
  _init() {
1683
1683
  this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.nationalMode = !1), this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode && (this.options.nationalMode = !1), this.options.useFullscreenPopup && !this.options.dropdownContainer && (this.options.dropdownContainer = document.body), this.isAndroid = typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, this.isRTL = !!this.telInput.closest("[dir=rtl]");
1684
- const t = this.options.allowDropdown || this.options.separateDialCode;
1685
- this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...k, ...this.options.i18n };
1686
- const e = new Promise((s, n) => {
1684
+ const e = this.options.allowDropdown || this.options.separateDialCode;
1685
+ this.showSelectedCountryOnLeft = this.isRTL ? !e : e, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...k, ...this.options.i18n };
1686
+ const t = new Promise((s, n) => {
1687
1687
  this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = n;
1688
1688
  }), i = new Promise((s, n) => {
1689
1689
  this.resolveUtilsScriptPromise = s, this.rejectUtilsScriptPromise = n;
1690
1690
  });
1691
- this.promise = Promise.all([e, i]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests();
1691
+ this.promise = Promise.all([t, i]), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests();
1692
1692
  }
1693
1693
  //********************
1694
1694
  //* PRIVATE METHODS
@@ -1699,37 +1699,37 @@ class G {
1699
1699
  }
1700
1700
  //* Sort countries by countryOrder option (if present), then name.
1701
1701
  _sortCountries() {
1702
- this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((t) => t.toLowerCase())), this.countries.sort((t, e) => {
1702
+ this.options.countryOrder && (this.options.countryOrder = this.options.countryOrder.map((e) => e.toLowerCase())), this.countries.sort((e, t) => {
1703
1703
  const { countryOrder: i } = this.options;
1704
1704
  if (i) {
1705
- const s = i.indexOf(t.iso2), n = i.indexOf(e.iso2), o = s > -1, a = n > -1;
1705
+ const s = i.indexOf(e.iso2), n = i.indexOf(t.iso2), o = s > -1, a = n > -1;
1706
1706
  if (o || a)
1707
1707
  return o && a ? s - n : o ? -1 : 1;
1708
1708
  }
1709
- return t.name.localeCompare(e.name);
1709
+ return e.name.localeCompare(t.name);
1710
1710
  });
1711
1711
  }
1712
1712
  //* Add a dial code to this.dialCodeToIso2Map.
1713
- _addToDialCodeMap(t, e, i) {
1714
- e.length > this.dialCodeMaxLen && (this.dialCodeMaxLen = e.length), this.dialCodeToIso2Map.hasOwnProperty(e) || (this.dialCodeToIso2Map[e] = []);
1715
- for (let n = 0; n < this.dialCodeToIso2Map[e].length; n++)
1716
- if (this.dialCodeToIso2Map[e][n] === t)
1713
+ _addToDialCodeMap(e, t, i) {
1714
+ t.length > this.dialCodeMaxLen && (this.dialCodeMaxLen = t.length), this.dialCodeToIso2Map.hasOwnProperty(t) || (this.dialCodeToIso2Map[t] = []);
1715
+ for (let n = 0; n < this.dialCodeToIso2Map[t].length; n++)
1716
+ if (this.dialCodeToIso2Map[t][n] === e)
1717
1717
  return;
1718
- const s = i !== void 0 ? i : this.dialCodeToIso2Map[e].length;
1719
- this.dialCodeToIso2Map[e][s] = t;
1718
+ const s = i !== void 0 ? i : this.dialCodeToIso2Map[t].length;
1719
+ this.dialCodeToIso2Map[t][s] = e;
1720
1720
  }
1721
1721
  //* Process onlyCountries or excludeCountries array if present.
1722
1722
  _processAllCountries() {
1723
- const { onlyCountries: t, excludeCountries: e } = this.options;
1724
- if (t.length) {
1725
- const i = t.map(
1723
+ const { onlyCountries: e, excludeCountries: t } = this.options;
1724
+ if (e.length) {
1725
+ const i = e.map(
1726
1726
  (s) => s.toLowerCase()
1727
1727
  );
1728
1728
  this.countries = I.filter(
1729
1729
  (s) => i.indexOf(s.iso2) > -1
1730
1730
  );
1731
- } else if (e.length) {
1732
- const i = e.map(
1731
+ } else if (t.length) {
1732
+ const i = t.map(
1733
1733
  (s) => s.toLowerCase()
1734
1734
  );
1735
1735
  this.countries = I.filter(
@@ -1740,40 +1740,40 @@ class G {
1740
1740
  }
1741
1741
  //* Translate Countries by object literal provided on config.
1742
1742
  _translateCountryNames() {
1743
- for (let t = 0; t < this.countries.length; t++) {
1744
- const e = this.countries[t].iso2.toLowerCase();
1745
- this.options.i18n.hasOwnProperty(e) && (this.countries[t].name = this.options.i18n[e]);
1743
+ for (let e = 0; e < this.countries.length; e++) {
1744
+ const t = this.countries[e].iso2.toLowerCase();
1745
+ this.options.i18n.hasOwnProperty(t) && (this.countries[e].name = this.options.i18n[t]);
1746
1746
  }
1747
1747
  }
1748
- //* Generate this.dialCodes and this.dialCodeToIso2Map.
1748
+ //* Generate this.dialCodes and this.dialCodeToIso2Map and country.partialAreaCodes.
1749
1749
  _processDialCodes() {
1750
1750
  this.dialCodes = {}, this.dialCodeMaxLen = 0, this.dialCodeToIso2Map = {};
1751
- for (let t = 0; t < this.countries.length; t++) {
1752
- const e = this.countries[t];
1753
- this.dialCodes[e.dialCode] || (this.dialCodes[e.dialCode] = !0), this._addToDialCodeMap(e.iso2, e.dialCode, e.priority);
1751
+ for (let e = 0; e < this.countries.length; e++) {
1752
+ const t = this.countries[e];
1753
+ this.dialCodes[t.dialCode] || (this.dialCodes[t.dialCode] = !0), this._addToDialCodeMap(t.iso2, t.dialCode, t.priority);
1754
1754
  }
1755
- for (let t = 0; t < this.countries.length; t++) {
1756
- const e = this.countries[t];
1757
- if (e.areaCodes) {
1758
- const i = this.dialCodeToIso2Map[e.dialCode][0];
1759
- for (let s = 0; s < e.areaCodes.length; s++) {
1760
- const n = e.areaCodes[s];
1755
+ for (let e = 0; e < this.countries.length; e++) {
1756
+ const t = this.countries[e];
1757
+ if (t.areaCodes) {
1758
+ const i = this.dialCodeToIso2Map[t.dialCode][0];
1759
+ for (let s = 0; s < t.areaCodes.length; s++) {
1760
+ const n = t.areaCodes[s];
1761
1761
  for (let o = 1; o < n.length; o++) {
1762
- const a = e.dialCode + n.substr(0, o);
1763
- this._addToDialCodeMap(i, a), this._addToDialCodeMap(e.iso2, a);
1762
+ const a = n.substr(0, o), r = t.dialCode + a;
1763
+ this._addToDialCodeMap(i, r), this._addToDialCodeMap(t.iso2, r), t.partialAreaCodes || (t.partialAreaCodes = []), t.partialAreaCodes.includes(a) || t.partialAreaCodes.push(a);
1764
1764
  }
1765
- this._addToDialCodeMap(e.iso2, e.dialCode + n);
1765
+ this._addToDialCodeMap(t.iso2, t.dialCode + n);
1766
1766
  }
1767
1767
  }
1768
1768
  }
1769
1769
  }
1770
1770
  //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
1771
1771
  _generateMarkup() {
1772
- var h, m, b;
1772
+ var d, m, b;
1773
1773
  this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
1774
1774
  const {
1775
- allowDropdown: t,
1776
- separateDialCode: e,
1775
+ allowDropdown: e,
1776
+ separateDialCode: t,
1777
1777
  showFlags: i,
1778
1778
  containerClass: s,
1779
1779
  hiddenInput: n,
@@ -1781,17 +1781,17 @@ class G {
1781
1781
  fixDropdownWidth: a,
1782
1782
  useFullscreenPopup: r,
1783
1783
  countrySearch: p,
1784
- i18n: c
1784
+ i18n: h
1785
1785
  } = this.options;
1786
- let d = "iti";
1787
- t && (d += " iti--allow-dropdown"), i && (d += " iti--show-flags"), s && (d += ` ${s}`), r || (d += " iti--inline-dropdown");
1788
- const C = y("div", { class: d });
1789
- if ((h = this.telInput.parentNode) == null || h.insertBefore(C, this.telInput), t || i || e) {
1786
+ let c = "iti";
1787
+ e && (c += " iti--allow-dropdown"), i && (c += " iti--show-flags"), s && (c += ` ${s}`), r || (c += " iti--inline-dropdown");
1788
+ const C = y("div", { class: c });
1789
+ if ((d = this.telInput.parentNode) == null || d.insertBefore(C, this.telInput), e || i || t) {
1790
1790
  this.countryContainer = y(
1791
1791
  "div",
1792
1792
  { class: "iti__country-container" },
1793
1793
  C
1794
- ), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = y(
1794
+ ), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", e ? (this.selectedCountry = y(
1795
1795
  "button",
1796
1796
  {
1797
1797
  type: "button",
@@ -1813,15 +1813,15 @@ class G {
1813
1813
  "span",
1814
1814
  { class: "iti__a11y-text" },
1815
1815
  this.selectedCountryInner
1816
- ), t && (this.dropdownArrow = y(
1816
+ ), e && (this.dropdownArrow = y(
1817
1817
  "div",
1818
1818
  { class: "iti__arrow", "aria-hidden": "true" },
1819
1819
  _
1820
- )), e && (this.selectedDialCode = y(
1820
+ )), t && (this.selectedDialCode = y(
1821
1821
  "div",
1822
1822
  { class: "iti__selected-dial-code" },
1823
1823
  this.selectedCountry
1824
- )), t) {
1824
+ )), e) {
1825
1825
  const f = a ? "" : "iti--flexible-dropdown-width";
1826
1826
  if (this.dropdownContent = y("div", {
1827
1827
  id: `iti-${this.id}__dropdown-content`,
@@ -1831,10 +1831,10 @@ class G {
1831
1831
  {
1832
1832
  type: "text",
1833
1833
  class: "iti__search-input",
1834
- placeholder: c.searchPlaceholder,
1834
+ placeholder: h.searchPlaceholder,
1835
1835
  role: "combobox",
1836
1836
  "aria-expanded": "true",
1837
- "aria-label": c.searchPlaceholder,
1837
+ "aria-label": h.searchPlaceholder,
1838
1838
  "aria-controls": `iti-${this.id}__country-listbox`,
1839
1839
  "aria-autocomplete": "list",
1840
1840
  autocomplete: "off"
@@ -1850,7 +1850,7 @@ class G {
1850
1850
  class: "iti__country-list",
1851
1851
  id: `iti-${this.id}__country-listbox`,
1852
1852
  role: "listbox",
1853
- "aria-label": c.countryListAriaLabel
1853
+ "aria-label": h.countryListAriaLabel
1854
1854
  },
1855
1855
  this.dropdownContent
1856
1856
  ), this._appendListItems(), p && this._updateSearchResultsText(), o) {
@@ -1880,35 +1880,35 @@ class G {
1880
1880
  }
1881
1881
  //* For each country: add a country list item <li> to the countryList <ul> container.
1882
1882
  _appendListItems() {
1883
- for (let t = 0; t < this.countries.length; t++) {
1884
- const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = y(
1883
+ for (let e = 0; e < this.countries.length; e++) {
1884
+ const t = this.countries[e], i = e === 0 ? "iti__highlight" : "", s = y(
1885
1885
  "li",
1886
1886
  {
1887
- id: `iti-${this.id}__item-${e.iso2}`,
1887
+ id: `iti-${this.id}__item-${t.iso2}`,
1888
1888
  class: `iti__country ${i}`,
1889
1889
  tabindex: "-1",
1890
1890
  role: "option",
1891
- "data-dial-code": e.dialCode,
1892
- "data-country-code": e.iso2,
1891
+ "data-dial-code": t.dialCode,
1892
+ "data-country-code": t.iso2,
1893
1893
  "aria-selected": "false"
1894
1894
  },
1895
1895
  this.countryList
1896
1896
  );
1897
- e.nodeById[this.id] = s;
1897
+ t.nodeById[this.id] = s;
1898
1898
  let n = "";
1899
- this.options.showFlags && (n += `<div class='iti__flag iti__${e.iso2}'></div>`), n += `<span class='iti__country-name'>${e.name}</span>`, n += `<span class='iti__dial-code'>+${e.dialCode}</span>`, s.insertAdjacentHTML("beforeend", n);
1899
+ this.options.showFlags && (n += `<div class='iti__flag iti__${t.iso2}'></div>`), n += `<span class='iti__country-name'>${t.name}</span>`, n += `<span class='iti__dial-code'>+${t.dialCode}</span>`, s.insertAdjacentHTML("beforeend", n);
1900
1900
  }
1901
1901
  }
1902
1902
  //* Set the initial state of the input value and the selected country by:
1903
1903
  //* 1. Extracting a dial code from the given number
1904
1904
  //* 2. Using explicit initialCountry
1905
- _setInitialState(t = !1) {
1906
- const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), a = S(n), { initialCountry: r, geoIpLookup: p } = this.options, c = r === "auto" && p;
1905
+ _setInitialState(e = !1) {
1906
+ const t = this.telInput.getAttribute("value"), i = this.telInput.value, n = t && t.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? t : i, o = this._getDialCode(n), a = S(n), { initialCountry: r, geoIpLookup: p } = this.options, h = r === "auto" && p;
1907
1907
  if (o && !a)
1908
1908
  this._updateCountryFromNumber(n);
1909
- else if (!c || t) {
1910
- const d = r ? r.toLowerCase() : "";
1911
- d && this._getCountryData(d, !0) ? this._setCountry(d) : o && a ? this._setCountry("us") : this._setCountry();
1909
+ else if (!h || e) {
1910
+ const c = r ? r.toLowerCase() : "";
1911
+ c && this._getCountryData(c, !0) ? this._setCountry(c) : o && a ? this._setCountry("us") : this._setCountry();
1912
1912
  }
1913
1913
  n && this._updateValFromNumber(n);
1914
1914
  }
@@ -1918,24 +1918,24 @@ class G {
1918
1918
  }
1919
1919
  //* Update hidden input on form submit.
1920
1920
  _initHiddenInputListener() {
1921
- var t;
1921
+ var e;
1922
1922
  this._handleHiddenInputSubmit = () => {
1923
1923
  this.hiddenInput && (this.hiddenInput.value = this.getNumber()), this.hiddenInputCountry && (this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "");
1924
- }, (t = this.telInput.form) == null || t.addEventListener(
1924
+ }, (e = this.telInput.form) == null || e.addEventListener(
1925
1925
  "submit",
1926
1926
  this._handleHiddenInputSubmit
1927
1927
  );
1928
1928
  }
1929
1929
  //* initialise the dropdown listeners.
1930
1930
  _initDropdownListeners() {
1931
- this._handleLabelClick = (e) => {
1932
- this.dropdownContent.classList.contains("iti__hide") ? this.telInput.focus() : e.preventDefault();
1931
+ this._handleLabelClick = (t) => {
1932
+ this.dropdownContent.classList.contains("iti__hide") ? this.telInput.focus() : t.preventDefault();
1933
1933
  };
1934
- const t = this.telInput.closest("label");
1935
- t && t.addEventListener("click", this._handleLabelClick), this._handleClickSelectedCountry = () => {
1934
+ const e = this.telInput.closest("label");
1935
+ e && e.addEventListener("click", this._handleLabelClick), this._handleClickSelectedCountry = () => {
1936
1936
  this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly && this._openDropdown();
1937
- }, this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry), this._handleCountryContainerKeydown = (e) => {
1938
- this.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key) && (e.preventDefault(), e.stopPropagation(), this._openDropdown()), e.key === "Tab" && this._closeDropdown();
1937
+ }, this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry), this._handleCountryContainerKeydown = (t) => {
1938
+ this.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(t.key) && (t.preventDefault(), t.stopPropagation(), this._openDropdown()), t.key === "Tab" && this._closeDropdown();
1939
1939
  }, this.countryContainer.addEventListener(
1940
1940
  "keydown",
1941
1941
  this._handleCountryContainerKeydown
@@ -1943,19 +1943,19 @@ class G {
1943
1943
  }
1944
1944
  //* Init many requests: utils script / geo ip lookup.
1945
1945
  _initRequests() {
1946
- let { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
1947
- t && !l.utils ? (this._handlePageLoad = () => {
1946
+ let { loadUtils: e, initialCountry: t, geoIpLookup: i } = this.options;
1947
+ e && !l.utils ? (this._handlePageLoad = () => {
1948
1948
  var n;
1949
- window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(t)) == null || n.catch(() => {
1949
+ window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(e)) == null || n.catch(() => {
1950
1950
  });
1951
- }, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
1951
+ }, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), t === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
1952
1952
  }
1953
1953
  //* Perform the geo ip lookup.
1954
1954
  _loadAutoCountry() {
1955
1955
  l.autoCountry ? this.handleAutoCountry() : l.startedLoadingAutoCountry || (l.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
1956
- (t = "") => {
1957
- const e = t.toLowerCase();
1958
- e && this._getCountryData(e, !0) ? (l.autoCountry = e, setTimeout(() => w("handleAutoCountry"))) : (this._setInitialState(!0), w("rejectAutoCountryPromise"));
1956
+ (e = "") => {
1957
+ const t = e.toLowerCase();
1958
+ t && this._getCountryData(t, !0) ? (l.autoCountry = t, setTimeout(() => w("handleAutoCountry"))) : (this._setInitialState(!0), w("rejectAutoCountryPromise"));
1959
1959
  },
1960
1960
  () => {
1961
1961
  this._setInitialState(!0), w("rejectAutoCountryPromise");
@@ -1967,58 +1967,58 @@ class G {
1967
1967
  }
1968
1968
  //* Initialize the tel input listeners.
1969
1969
  _initTelInputListeners() {
1970
- const { strictMode: t, formatAsYouType: e, separateDialCode: i, formatOnDisplay: s, allowDropdown: n, countrySearch: o } = this.options;
1970
+ const { strictMode: e, formatAsYouType: t, separateDialCode: i, formatOnDisplay: s, allowDropdown: n, countrySearch: o } = this.options;
1971
1971
  let a = !1;
1972
1972
  new RegExp("\\p{L}", "u").test(this.telInput.value) && (a = !0), this._handleInputEvent = (r) => {
1973
1973
  if (this.isAndroid && (r == null ? void 0 : r.data) === "+" && i && n && o) {
1974
- const C = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, C - 1), m = this.telInput.value.substring(C);
1975
- this.telInput.value = h + m, this._openDropdownWithPlus();
1974
+ const C = this.telInput.selectionStart || 0, d = this.telInput.value.substring(0, C - 1), m = this.telInput.value.substring(C);
1975
+ this.telInput.value = d + m, this._openDropdownWithPlus();
1976
1976
  return;
1977
1977
  }
1978
1978
  this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
1979
- const p = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), c = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.telInput.value;
1980
- p || c && !t ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1);
1981
- const d = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
1982
- if (e && !a && !d) {
1979
+ const p = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), h = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.telInput.value;
1980
+ p || h && !e ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1);
1981
+ const c = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
1982
+ if (t && !a && !c) {
1983
1983
  const C = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, C).replace(/[^+0-9]/g, "").length, b = (r == null ? void 0 : r.inputType) === "deleteContentForward", _ = this._formatNumberAsYouType(), f = H(m, _, C, b);
1984
1984
  this.telInput.value = _, this.telInput.setSelectionRange(f, f);
1985
1985
  }
1986
- }, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (r) => {
1986
+ }, this.telInput.addEventListener("input", this._handleInputEvent), (e || i) && (this._handleKeydownEvent = (r) => {
1987
1987
  if (r.key && r.key.length === 1 && !r.altKey && !r.ctrlKey && !r.metaKey) {
1988
1988
  if (i && n && o && r.key === "+") {
1989
1989
  r.preventDefault(), this._openDropdownWithPlus();
1990
1990
  return;
1991
1991
  }
1992
- if (t) {
1993
- const p = this.telInput.value, c = p.charAt(0) === "+", d = !c && this.telInput.selectionStart === 0 && r.key === "+", C = /^[0-9]$/.test(r.key), h = i ? C : d || C, m = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), b = this._getFullNumber(m), _ = l.utils.getCoreNumber(b, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && _.length > this.maxCoreNumberLength;
1992
+ if (e) {
1993
+ const p = this.telInput.value, h = p.charAt(0) === "+", c = !h && this.telInput.selectionStart === 0 && r.key === "+", C = /^[0-9]$/.test(r.key), d = i ? C : c || C, m = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), b = this._getFullNumber(m), _ = l.utils.getCoreNumber(b, this.selectedCountryData.iso2), f = this.maxCoreNumberLength && _.length > this.maxCoreNumberLength;
1994
1994
  let g = !1;
1995
- if (c) {
1995
+ if (h) {
1996
1996
  const P = this.selectedCountryData.iso2;
1997
1997
  g = this._getCountryFromNumber(b) !== P;
1998
1998
  }
1999
- (!h || f && !g && !d) && r.preventDefault();
1999
+ (!d || f && !g && !c) && r.preventDefault();
2000
2000
  }
2001
2001
  }
2002
2002
  }, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
2003
2003
  }
2004
2004
  //* Adhere to the input's maxlength attr.
2005
- _cap(t) {
2006
- const e = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2007
- return e && t.length > e ? t.substr(0, e) : t;
2005
+ _cap(e) {
2006
+ const t = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2007
+ return t && e.length > t ? e.substr(0, t) : e;
2008
2008
  }
2009
2009
  //* Trigger a custom event on the input.
2010
- _trigger(t, e = {}) {
2011
- const i = new CustomEvent(t, {
2010
+ _trigger(e, t = {}) {
2011
+ const i = new CustomEvent(e, {
2012
2012
  bubbles: !0,
2013
2013
  cancelable: !0,
2014
- detail: e
2014
+ detail: t
2015
2015
  });
2016
2016
  this.telInput.dispatchEvent(i);
2017
2017
  }
2018
2018
  //* Open the dropdown.
2019
2019
  _openDropdown() {
2020
- const { fixDropdownWidth: t, countrySearch: e } = this.options;
2021
- if (t && (this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`), this.dropdownContent.classList.remove("iti__hide"), this.selectedCountry.setAttribute("aria-expanded", "true"), this._setDropdownPosition(), e) {
2020
+ const { fixDropdownWidth: e, countrySearch: t } = this.options;
2021
+ if (e && (this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`), this.dropdownContent.classList.remove("iti__hide"), this.selectedCountry.setAttribute("aria-expanded", "true"), this._setDropdownPosition(), t) {
2022
2022
  const i = this.countryList.firstElementChild;
2023
2023
  i && (this._highlightListItem(i, !1), this.countryList.scrollTop = 0), this.searchInput.focus();
2024
2024
  }
@@ -2027,8 +2027,8 @@ class G {
2027
2027
  //* Set the dropdown position
2028
2028
  _setDropdownPosition() {
2029
2029
  if (this.options.dropdownContainer && this.options.dropdownContainer.appendChild(this.dropdown), !this.options.useFullscreenPopup) {
2030
- const t = this.telInput.getBoundingClientRect(), e = this.telInput.offsetHeight;
2031
- this.options.dropdownContainer && (this.dropdown.style.top = `${t.top + e}px`, this.dropdown.style.left = `${t.left}px`, this._handleWindowScroll = () => this._closeDropdown(), window.addEventListener("scroll", this._handleWindowScroll));
2030
+ const e = this.telInput.getBoundingClientRect(), t = this.telInput.offsetHeight;
2031
+ this.options.dropdownContainer && (this.dropdown.style.top = `${e.top + t}px`, this.dropdown.style.left = `${e.left}px`, this._handleWindowScroll = () => this._closeDropdown(), window.addEventListener("scroll", this._handleWindowScroll));
2032
2032
  }
2033
2033
  }
2034
2034
  //* We only bind dropdown listeners when the dropdown is open.
@@ -2045,17 +2045,17 @@ class G {
2045
2045
  const n = (o = s.target) == null ? void 0 : o.closest(".iti__country");
2046
2046
  n && this._selectListItem(n);
2047
2047
  }, this.countryList.addEventListener("click", this._handleClickCountryList);
2048
- let t = !0;
2048
+ let e = !0;
2049
2049
  this._handleClickOffToClose = () => {
2050
- t || this._closeDropdown(), t = !1;
2050
+ e || this._closeDropdown(), e = !1;
2051
2051
  }, document.documentElement.addEventListener(
2052
2052
  "click",
2053
2053
  this._handleClickOffToClose
2054
2054
  );
2055
- let e = "", i = null;
2055
+ let t = "", i = null;
2056
2056
  if (this._handleKeydownOnDropdown = (s) => {
2057
- ["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(s.key) && (s.preventDefault(), s.stopPropagation(), s.key === "ArrowUp" || s.key === "ArrowDown" ? this._handleUpDownKey(s.key) : s.key === "Enter" ? this._handleEnterKey() : s.key === "Escape" && this._closeDropdown()), !this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(s.key) && (s.stopPropagation(), i && clearTimeout(i), e += s.key.toLowerCase(), this._searchForCountry(e), i = setTimeout(() => {
2058
- e = "";
2057
+ ["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(s.key) && (s.preventDefault(), s.stopPropagation(), s.key === "ArrowUp" || s.key === "ArrowDown" ? this._handleUpDownKey(s.key) : s.key === "Enter" ? this._handleEnterKey() : s.key === "Escape" && this._closeDropdown()), !this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(s.key) && (s.stopPropagation(), i && clearTimeout(i), t += s.key.toLowerCase(), this._searchForCountry(t), i = setTimeout(() => {
2058
+ t = "";
2059
2059
  }, 1e3));
2060
2060
  }, document.addEventListener("keydown", this._handleKeydownOnDropdown), this.options.countrySearch) {
2061
2061
  const s = () => {
@@ -2071,10 +2071,10 @@ class G {
2071
2071
  }
2072
2072
  }
2073
2073
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2074
- _searchForCountry(t) {
2075
- for (let e = 0; e < this.countries.length; e++) {
2076
- const i = this.countries[e];
2077
- if (i.name.substr(0, t.length).toLowerCase() === t) {
2074
+ _searchForCountry(e) {
2075
+ for (let t = 0; t < this.countries.length; t++) {
2076
+ const i = this.countries[t];
2077
+ if (i.name.substr(0, e.length).toLowerCase() === e) {
2078
2078
  const n = i.nodeById[this.id];
2079
2079
  this._highlightListItem(n, !1), this._scrollTo(n);
2080
2080
  break;
@@ -2082,30 +2082,30 @@ class G {
2082
2082
  }
2083
2083
  }
2084
2084
  //* Country search enabled: Filter the countries according to the search query.
2085
- _filterCountries(t, e = !1) {
2085
+ _filterCountries(e, t = !1) {
2086
2086
  let i = !0;
2087
2087
  this.countryList.innerHTML = "";
2088
- const s = A(t);
2088
+ const s = N(e);
2089
2089
  for (let n = 0; n < this.countries.length; n++) {
2090
- const o = this.countries[n], a = A(o.name), r = o.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((c) => c[0]).join("").toLowerCase(), p = `+${o.dialCode}`;
2091
- if (e || a.includes(s) || p.includes(s) || o.iso2.includes(s) || r.includes(s)) {
2092
- const c = o.nodeById[this.id];
2093
- c && this.countryList.appendChild(c), i && (this._highlightListItem(c, !1), i = !1);
2090
+ const o = this.countries[n], a = N(o.name), r = o.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((h) => h[0]).join("").toLowerCase(), p = `+${o.dialCode}`;
2091
+ if (t || a.includes(s) || p.includes(s) || o.iso2.includes(s) || r.includes(s)) {
2092
+ const h = o.nodeById[this.id];
2093
+ h && this.countryList.appendChild(h), i && (this._highlightListItem(h, !1), i = !1);
2094
2094
  }
2095
2095
  }
2096
2096
  i && this._highlightListItem(null, !1), this.countryList.scrollTop = 0, this._updateSearchResultsText();
2097
2097
  }
2098
2098
  //* Update search results text (for a11y).
2099
2099
  _updateSearchResultsText() {
2100
- const { i18n: t } = this.options, e = this.countryList.childElementCount;
2100
+ const { i18n: e } = this.options, t = this.countryList.childElementCount;
2101
2101
  let i;
2102
- e === 0 ? i = t.zeroSearchResults : e === 1 ? i = t.oneSearchResult : i = t.multipleSearchResults.replace("${count}", e.toString()), this.searchResultsA11yText.textContent = i;
2102
+ t === 0 ? i = e.zeroSearchResults : t === 1 ? i = e.oneSearchResult : i = e.multipleSearchResults.replace("${count}", t.toString()), this.searchResultsA11yText.textContent = i;
2103
2103
  }
2104
2104
  //* Highlight the next/prev item in the list (and ensure it is visible).
2105
- _handleUpDownKey(t) {
2105
+ _handleUpDownKey(e) {
2106
2106
  var i, s;
2107
- let e = t === "ArrowUp" ? (i = this.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.highlightedItem) == null ? void 0 : s.nextElementSibling;
2108
- !e && this.countryList.childElementCount > 1 && (e = t === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild), e && (this._scrollTo(e), this._highlightListItem(e, !1));
2107
+ let t = e === "ArrowUp" ? (i = this.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.highlightedItem) == null ? void 0 : s.nextElementSibling;
2108
+ !t && this.countryList.childElementCount > 1 && (t = e === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild), t && (this._scrollTo(t), this._highlightListItem(t, !1));
2109
2109
  }
2110
2110
  //* Select the currently highlighted item.
2111
2111
  _handleEnterKey() {
@@ -2113,36 +2113,42 @@ class G {
2113
2113
  }
2114
2114
  //* Update the input's value to the given val (format first if possible)
2115
2115
  //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
2116
- _updateValFromNumber(t) {
2117
- let e = t;
2116
+ _updateValFromNumber(e) {
2117
+ let t = e;
2118
2118
  if (this.options.formatOnDisplay && l.utils && this.selectedCountryData) {
2119
- const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = l.utils.numberFormat, o = i ? s : n;
2120
- e = l.utils.formatNumber(
2121
- e,
2119
+ const i = this.options.nationalMode || t.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: n } = l.utils.numberFormat, o = i ? s : n;
2120
+ t = l.utils.formatNumber(
2121
+ t,
2122
2122
  this.selectedCountryData.iso2,
2123
2123
  o
2124
2124
  );
2125
2125
  }
2126
- e = this._beforeSetNumber(e), this.telInput.value = e;
2126
+ t = this._beforeSetNumber(t), this.telInput.value = t;
2127
2127
  }
2128
2128
  //* Check if need to select a new country based on the given number
2129
2129
  //* Note: called from _setInitialState, keyup handler, setNumber.
2130
- _updateCountryFromNumber(t) {
2131
- const e = this._getCountryFromNumber(t);
2132
- return e !== null ? this._setCountry(e) : !1;
2133
- }
2134
- _getCountryFromNumber(t) {
2135
- const e = t.indexOf("+");
2136
- let i = e ? t.substring(e) : t;
2130
+ _updateCountryFromNumber(e) {
2131
+ const t = this._getCountryFromNumber(e);
2132
+ return t !== null ? this._setCountry(t) : !1;
2133
+ }
2134
+ //* Check if the given number matches an area code from the selected country.
2135
+ _isAreaCodeMatch(e, t) {
2136
+ const { areaCodes: i, partialAreaCodes: s, dialCode: n } = this.selectedCountryData, o = e.substring(n.length), a = t.substring(n.length);
2137
+ return !!(i.includes(a) || s.includes(o));
2138
+ }
2139
+ _getCountryFromNumber(e) {
2140
+ const t = e.indexOf("+");
2141
+ let i = t ? e.substring(t) : e;
2137
2142
  const s = this.selectedCountryData.dialCode;
2138
2143
  i && s === "1" && i.charAt(0) !== "+" && (i.charAt(0) !== "1" && (i = `1${i}`), i = `+${i}`), this.options.separateDialCode && s && i.charAt(0) !== "+" && (i = `+${s}${i}`);
2139
2144
  const o = this._getDialCode(i, !0), a = v(i);
2140
2145
  if (o) {
2141
- const r = this.dialCodeToIso2Map[v(o)], p = r.indexOf(this.selectedCountryData.iso2) !== -1 && a.length <= o.length - 1;
2142
- if (!(s === "1" && S(a)) && !p) {
2143
- for (let d = 0; d < r.length; d++)
2144
- if (r[d])
2145
- return r[d];
2146
+ const r = v(o), p = this.dialCodeToIso2Map[r], h = this.selectedCountryData.iso2 && p.includes(this.selectedCountryData.iso2);
2147
+ let c = !1;
2148
+ if (h && (this.selectedCountryData.areaCodes && a.length > s.length ? c = this._isAreaCodeMatch(a, r) : c = !0), !(s === "1" && S(a)) && (!h || !c)) {
2149
+ for (let d = 0; d < p.length; d++)
2150
+ if (p[d])
2151
+ return p[d];
2146
2152
  }
2147
2153
  } else {
2148
2154
  if (i.charAt(0) === "+" && a.length)
@@ -2153,52 +2159,52 @@ class G {
2153
2159
  return null;
2154
2160
  }
2155
2161
  //* Remove highlighting from other list items and highlight the given item.
2156
- _highlightListItem(t, e) {
2162
+ _highlightListItem(e, t) {
2157
2163
  const i = this.highlightedItem;
2158
- if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = t, this.highlightedItem) {
2164
+ if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = e, this.highlightedItem) {
2159
2165
  this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true");
2160
2166
  const s = this.highlightedItem.getAttribute("id") || "";
2161
2167
  this.selectedCountry.setAttribute("aria-activedescendant", s), this.options.countrySearch && this.searchInput.setAttribute("aria-activedescendant", s);
2162
2168
  }
2163
- e && this.highlightedItem.focus();
2169
+ t && this.highlightedItem.focus();
2164
2170
  }
2165
2171
  //* Find the country data for the given iso2 code
2166
2172
  //* the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
2167
- _getCountryData(t, e) {
2173
+ _getCountryData(e, t) {
2168
2174
  for (let i = 0; i < this.countries.length; i++)
2169
- if (this.countries[i].iso2 === t)
2175
+ if (this.countries[i].iso2 === e)
2170
2176
  return this.countries[i];
2171
- if (e)
2177
+ if (t)
2172
2178
  return null;
2173
- throw new Error(`No country data for '${t}'`);
2179
+ throw new Error(`No country data for '${e}'`);
2174
2180
  }
2175
2181
  //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
2176
2182
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2177
- _setCountry(t) {
2178
- const { separateDialCode: e, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2179
- if (this.selectedCountryData = t ? this._getCountryData(t, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountryInner) {
2183
+ _setCountry(e) {
2184
+ const { separateDialCode: t, showFlags: i, i18n: s } = this.options, n = this.selectedCountryData.iso2 ? this.selectedCountryData : {};
2185
+ if (this.selectedCountryData = e ? this._getCountryData(e, !1) || {} : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountryInner) {
2180
2186
  let o = "", a = "";
2181
- t && i ? (o = `iti__flag iti__${t}`, a = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`) : (o = "iti__flag iti__globe", a = s.noCountrySelected), this.selectedCountryInner.className = o, this.selectedCountryA11yText.textContent = a;
2187
+ e && i ? (o = `iti__flag iti__${e}`, a = `${this.selectedCountryData.name} +${this.selectedCountryData.dialCode}`) : (o = "iti__flag iti__globe", a = s.noCountrySelected), this.selectedCountryInner.className = o, this.selectedCountryA11yText.textContent = a;
2182
2188
  }
2183
- if (this._setSelectedCountryTitleAttribute(t, e), e) {
2189
+ if (this._setSelectedCountryTitleAttribute(e, t), t) {
2184
2190
  const o = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
2185
2191
  this.selectedDialCode.innerHTML = o, this._updateInputPadding();
2186
2192
  }
2187
- return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !== t;
2193
+ return this._updatePlaceholder(), this._updateMaxLength(), n.iso2 !== e;
2188
2194
  }
2189
2195
  //* Update the input padding to make space for the selected country/dial code.
2190
2196
  _updateInputPadding() {
2191
2197
  if (this.selectedCountry) {
2192
- const e = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth()) + 6;
2193
- this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${e}px` : this.telInput.style.paddingRight = `${e}px`;
2198
+ const t = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth()) + 6;
2199
+ this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${t}px` : this.telInput.style.paddingRight = `${t}px`;
2194
2200
  }
2195
2201
  }
2196
2202
  //* Update the maximum valid number length for the currently selected country.
2197
2203
  _updateMaxLength() {
2198
- const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
2199
- if (t && l.utils)
2204
+ const { strictMode: e, placeholderNumberType: t, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
2205
+ if (e && l.utils)
2200
2206
  if (s) {
2201
- const n = l.utils.numberType[e];
2207
+ const n = l.utils.numberType[t];
2202
2208
  let o = l.utils.getExampleNumber(
2203
2209
  s,
2204
2210
  !1,
@@ -2212,11 +2218,11 @@ class G {
2212
2218
  } else
2213
2219
  this.maxCoreNumberLength = null;
2214
2220
  }
2215
- _setSelectedCountryTitleAttribute(t = null, e) {
2221
+ _setSelectedCountryTitleAttribute(e = null, t) {
2216
2222
  if (!this.selectedCountry)
2217
2223
  return;
2218
2224
  let i;
2219
- t && !e ? i = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : t ? i = this.selectedCountryData.name : i = "Unknown", this.selectedCountry.setAttribute("title", i);
2225
+ e && !t ? i = `${this.selectedCountryData.name}: +${this.selectedCountryData.dialCode}` : e ? i = this.selectedCountryData.name : i = "Unknown", this.selectedCountry.setAttribute("title", i);
2220
2226
  }
2221
2227
  //* When the input is in a hidden container during initialisation, we must inject some markup
2222
2228
  //* into the end of the DOM to calculate the correct offsetWidth.
@@ -2224,27 +2230,27 @@ class G {
2224
2230
  //* will definitely exist.
2225
2231
  _getHiddenSelectedCountryWidth() {
2226
2232
  if (this.telInput.parentNode) {
2227
- const t = this.telInput.parentNode.cloneNode(!1);
2228
- t.style.visibility = "hidden", document.body.appendChild(t);
2229
- const e = this.countryContainer.cloneNode();
2230
- t.appendChild(e);
2233
+ const e = this.telInput.parentNode.cloneNode(!1);
2234
+ e.style.visibility = "hidden", document.body.appendChild(e);
2235
+ const t = this.countryContainer.cloneNode();
2236
+ e.appendChild(t);
2231
2237
  const i = this.selectedCountry.cloneNode(!0);
2232
- e.appendChild(i);
2238
+ t.appendChild(i);
2233
2239
  const s = i.offsetWidth;
2234
- return document.body.removeChild(t), s;
2240
+ return document.body.removeChild(e), s;
2235
2241
  }
2236
2242
  return 0;
2237
2243
  }
2238
2244
  //* Update the input placeholder to an example number from the currently selected country.
2239
2245
  _updatePlaceholder() {
2240
2246
  const {
2241
- autoPlaceholder: t,
2242
- placeholderNumberType: e,
2247
+ autoPlaceholder: e,
2248
+ placeholderNumberType: t,
2243
2249
  nationalMode: i,
2244
2250
  customPlaceholder: s
2245
- } = this.options, n = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
2251
+ } = this.options, n = e === "aggressive" || !this.hadInitialPlaceholder && e === "polite";
2246
2252
  if (l.utils && n) {
2247
- const o = l.utils.numberType[e];
2253
+ const o = l.utils.numberType[t];
2248
2254
  let a = this.selectedCountryData.iso2 ? l.utils.getExampleNumber(
2249
2255
  this.selectedCountryData.iso2,
2250
2256
  i,
@@ -2254,11 +2260,11 @@ class G {
2254
2260
  }
2255
2261
  }
2256
2262
  //* Called when the user selects a list item from the dropdown.
2257
- _selectListItem(t) {
2258
- const e = this._setCountry(
2259
- t.getAttribute("data-country-code")
2263
+ _selectListItem(e) {
2264
+ const t = this._setCountry(
2265
+ e.getAttribute("data-country-code")
2260
2266
  );
2261
- this._closeDropdown(), this._updateDialCode(t.getAttribute("data-dial-code")), this.telInput.focus(), e && this._triggerCountryChange();
2267
+ this._closeDropdown(), this._updateDialCode(e.getAttribute("data-dial-code")), this.telInput.focus(), t && this._triggerCountryChange();
2262
2268
  }
2263
2269
  //* Close the dropdown and unbind any listeners.
2264
2270
  _closeDropdown() {
@@ -2271,38 +2277,38 @@ class G {
2271
2277
  ), this.countryList.removeEventListener("click", this._handleClickCountryList), this.options.dropdownContainer && (this.options.useFullscreenPopup || window.removeEventListener("scroll", this._handleWindowScroll), this.dropdown.parentNode && this.dropdown.parentNode.removeChild(this.dropdown)), this._handlePageLoad && window.removeEventListener("load", this._handlePageLoad), this._trigger("close:countrydropdown");
2272
2278
  }
2273
2279
  //* Check if an element is visible within it's container, else scroll until it is.
2274
- _scrollTo(t) {
2275
- const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, n = e.getBoundingClientRect().top + i, o = n + s, a = t.offsetHeight, r = t.getBoundingClientRect().top + i, p = r + a, c = r - n + e.scrollTop;
2280
+ _scrollTo(e) {
2281
+ const t = this.countryList, i = document.documentElement.scrollTop, s = t.offsetHeight, n = t.getBoundingClientRect().top + i, o = n + s, a = e.offsetHeight, r = e.getBoundingClientRect().top + i, p = r + a, h = r - n + t.scrollTop;
2276
2282
  if (r < n)
2277
- e.scrollTop = c;
2283
+ t.scrollTop = h;
2278
2284
  else if (p > o) {
2279
- const d = s - a;
2280
- e.scrollTop = c - d;
2285
+ const c = s - a;
2286
+ t.scrollTop = h - c;
2281
2287
  }
2282
2288
  }
2283
2289
  //* Replace any existing dial code with the new one
2284
2290
  //* Note: called from _selectListItem and setCountry
2285
- _updateDialCode(t) {
2286
- const e = this.telInput.value, i = `+${t}`;
2291
+ _updateDialCode(e) {
2292
+ const t = this.telInput.value, i = `+${e}`;
2287
2293
  let s;
2288
- if (e.charAt(0) === "+") {
2289
- const n = this._getDialCode(e);
2290
- n ? s = e.replace(n, i) : s = i, this.telInput.value = s;
2294
+ if (t.charAt(0) === "+") {
2295
+ const n = this._getDialCode(t);
2296
+ n ? s = t.replace(n, i) : s = i, this.telInput.value = s;
2291
2297
  }
2292
2298
  }
2293
2299
  //* Try and extract a valid international dial code from a full telephone number.
2294
2300
  //* Note: returns the raw string inc plus character and any whitespace/dots etc.
2295
- _getDialCode(t, e) {
2301
+ _getDialCode(e, t) {
2296
2302
  let i = "";
2297
- if (t.charAt(0) === "+") {
2303
+ if (e.charAt(0) === "+") {
2298
2304
  let s = "";
2299
- for (let n = 0; n < t.length; n++) {
2300
- const o = t.charAt(n);
2305
+ for (let n = 0; n < e.length; n++) {
2306
+ const o = e.charAt(n);
2301
2307
  if (!isNaN(parseInt(o, 10))) {
2302
- if (s += o, e)
2303
- this.dialCodeToIso2Map[s] && (i = t.substr(0, n + 1));
2308
+ if (s += o, t)
2309
+ this.dialCodeToIso2Map[s] && (i = e.substr(0, n + 1));
2304
2310
  else if (this.dialCodes[s]) {
2305
- i = t.substr(0, n + 1);
2311
+ i = e.substr(0, n + 1);
2306
2312
  break;
2307
2313
  }
2308
2314
  if (s.length === this.dialCodeMaxLen)
@@ -2313,24 +2319,24 @@ class G {
2313
2319
  return i;
2314
2320
  }
2315
2321
  //* Get the input val, adding the dial code if separateDialCode is enabled.
2316
- _getFullNumber(t) {
2317
- const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
2322
+ _getFullNumber(e) {
2323
+ const t = e || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
2318
2324
  let s;
2319
- const n = v(e);
2320
- return this.options.separateDialCode && e.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + e;
2325
+ const n = v(t);
2326
+ return this.options.separateDialCode && t.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + t;
2321
2327
  }
2322
2328
  //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
2323
- _beforeSetNumber(t) {
2324
- let e = t;
2329
+ _beforeSetNumber(e) {
2330
+ let t = e;
2325
2331
  if (this.options.separateDialCode) {
2326
- let i = this._getDialCode(e);
2332
+ let i = this._getDialCode(t);
2327
2333
  if (i) {
2328
2334
  i = `+${this.selectedCountryData.dialCode}`;
2329
- const s = e[i.length] === " " || e[i.length] === "-" ? i.length + 1 : i.length;
2330
- e = e.substr(s);
2335
+ const s = t[i.length] === " " || t[i.length] === "-" ? i.length + 1 : i.length;
2336
+ t = t.substr(s);
2331
2337
  }
2332
2338
  }
2333
- return this._cap(e);
2339
+ return this._cap(t);
2334
2340
  }
2335
2341
  //* Trigger the 'countrychange' event.
2336
2342
  _triggerCountryChange() {
@@ -2338,8 +2344,8 @@ class G {
2338
2344
  }
2339
2345
  //* Format the number as the user types.
2340
2346
  _formatNumberAsYouType() {
2341
- const t = this._getFullNumber(), e = l.utils ? l.utils.formatNumberAsYouType(t, this.selectedCountryData.iso2) : t, { dialCode: i } = this.selectedCountryData;
2342
- return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && e.includes(`+${i}`) ? (e.split(`+${i}`)[1] || "").trim() : e;
2347
+ const e = this._getFullNumber(), t = l.utils ? l.utils.formatNumberAsYouType(e, this.selectedCountryData.iso2) : e, { dialCode: i } = this.selectedCountryData;
2348
+ return this.options.separateDialCode && this.telInput.value.charAt(0) !== "+" && t.includes(`+${i}`) ? (t.split(`+${i}`)[1] || "").trim() : t;
2343
2349
  }
2344
2350
  //**************************
2345
2351
  //* SECRET PUBLIC METHODS
@@ -2358,8 +2364,8 @@ class G {
2358
2364
  //* Remove plugin.
2359
2365
  destroy() {
2360
2366
  var n, o;
2361
- const { allowDropdown: t, separateDialCode: e } = this.options;
2362
- if (t) {
2367
+ const { allowDropdown: e, separateDialCode: t } = this.options;
2368
+ if (e) {
2363
2369
  this._closeDropdown(), this.selectedCountry.removeEventListener(
2364
2370
  "click",
2365
2371
  this._handleClickSelectedCountry
@@ -2371,7 +2377,7 @@ class G {
2371
2377
  a && a.removeEventListener("click", this._handleLabelClick);
2372
2378
  }
2373
2379
  const { form: i } = this.telInput;
2374
- this._handleHiddenInputSubmit && i && i.removeEventListener("submit", this._handleHiddenInputSubmit), this.telInput.removeEventListener("input", this._handleInputEvent), this._handleKeydownEvent && this.telInput.removeEventListener("keydown", this._handleKeydownEvent), this.telInput.removeAttribute("data-intl-tel-input-id"), e && (this.isRTL ? this.telInput.style.paddingRight = this.originalPaddingRight : this.telInput.style.paddingLeft = this.originalPaddingLeft);
2380
+ this._handleHiddenInputSubmit && i && i.removeEventListener("submit", this._handleHiddenInputSubmit), this.telInput.removeEventListener("input", this._handleInputEvent), this._handleKeydownEvent && this.telInput.removeEventListener("keydown", this._handleKeydownEvent), this.telInput.removeAttribute("data-intl-tel-input-id"), t && (this.isRTL ? this.telInput.style.paddingRight = this.originalPaddingRight : this.telInput.style.paddingLeft = this.originalPaddingLeft);
2375
2381
  const s = this.telInput.parentNode;
2376
2382
  (n = s == null ? void 0 : s.parentNode) == null || n.insertBefore(this.telInput, s), (o = s == null ? void 0 : s.parentNode) == null || o.removeChild(s), delete l.instances[this.id];
2377
2383
  }
@@ -2383,13 +2389,13 @@ class G {
2383
2389
  ) : "";
2384
2390
  }
2385
2391
  //* Format the number to the given format.
2386
- getNumber(t) {
2392
+ getNumber(e) {
2387
2393
  if (l.utils) {
2388
- const { iso2: e } = this.selectedCountryData;
2394
+ const { iso2: t } = this.selectedCountryData;
2389
2395
  return l.utils.formatNumber(
2390
2396
  this._getFullNumber(),
2391
- e,
2392
- t
2397
+ t,
2398
+ e
2393
2399
  );
2394
2400
  }
2395
2401
  return "";
@@ -2408,8 +2414,8 @@ class G {
2408
2414
  //* Get the validation error.
2409
2415
  getValidationError() {
2410
2416
  if (l.utils) {
2411
- const { iso2: t } = this.selectedCountryData;
2412
- return l.utils.getValidationError(this._getFullNumber(), t);
2417
+ const { iso2: e } = this.selectedCountryData;
2418
+ return l.utils.getValidationError(this._getFullNumber(), e);
2413
2419
  }
2414
2420
  return -99;
2415
2421
  }
@@ -2417,73 +2423,73 @@ class G {
2417
2423
  isValidNumber() {
2418
2424
  if (!this.selectedCountryData.iso2)
2419
2425
  return !1;
2420
- const t = this._getFullNumber(), e = t.search(new RegExp("\\p{L}", "u"));
2421
- if (e > -1) {
2422
- const i = t.substring(0, e), s = this._utilsIsPossibleNumber(i), n = this._utilsIsPossibleNumber(t);
2426
+ const e = this._getFullNumber(), t = e.search(new RegExp("\\p{L}", "u"));
2427
+ if (t > -1) {
2428
+ const i = e.substring(0, t), s = this._utilsIsPossibleNumber(i), n = this._utilsIsPossibleNumber(e);
2423
2429
  return s && n;
2424
2430
  }
2425
- return this._utilsIsPossibleNumber(t);
2431
+ return this._utilsIsPossibleNumber(e);
2426
2432
  }
2427
- _utilsIsPossibleNumber(t) {
2428
- return l.utils ? l.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2433
+ _utilsIsPossibleNumber(e) {
2434
+ return l.utils ? l.utils.isPossibleNumber(e, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2429
2435
  }
2430
2436
  //* Validate the input val (precise)
2431
2437
  isValidNumberPrecise() {
2432
2438
  if (!this.selectedCountryData.iso2)
2433
2439
  return !1;
2434
- const t = this._getFullNumber(), e = t.search(new RegExp("\\p{L}", "u"));
2435
- if (e > -1) {
2436
- const i = t.substring(0, e), s = this._utilsIsValidNumber(i), n = this._utilsIsValidNumber(t);
2440
+ const e = this._getFullNumber(), t = e.search(new RegExp("\\p{L}", "u"));
2441
+ if (t > -1) {
2442
+ const i = e.substring(0, t), s = this._utilsIsValidNumber(i), n = this._utilsIsValidNumber(e);
2437
2443
  return s && n;
2438
2444
  }
2439
- return this._utilsIsValidNumber(t);
2445
+ return this._utilsIsValidNumber(e);
2440
2446
  }
2441
- _utilsIsValidNumber(t) {
2442
- return l.utils ? l.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2447
+ _utilsIsValidNumber(e) {
2448
+ return l.utils ? l.utils.isValidNumber(e, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2443
2449
  }
2444
2450
  //* Update the selected country, and update the input val accordingly.
2445
- setCountry(t) {
2446
- const e = t == null ? void 0 : t.toLowerCase(), i = this.selectedCountryData.iso2;
2447
- (t && e !== i || !t && i) && (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this._triggerCountryChange());
2451
+ setCountry(e) {
2452
+ const t = e == null ? void 0 : e.toLowerCase(), i = this.selectedCountryData.iso2;
2453
+ (e && t !== i || !e && i) && (this._setCountry(t), this._updateDialCode(this.selectedCountryData.dialCode), this._triggerCountryChange());
2448
2454
  }
2449
2455
  //* Set the input value and update the country.
2450
- setNumber(t) {
2451
- const e = this._updateCountryFromNumber(t);
2452
- this._updateValFromNumber(t), e && this._triggerCountryChange(), this._trigger("input", { isSetNumber: !0 });
2456
+ setNumber(e) {
2457
+ const t = this._updateCountryFromNumber(e);
2458
+ this._updateValFromNumber(e), t && this._triggerCountryChange(), this._trigger("input", { isSetNumber: !0 });
2453
2459
  }
2454
2460
  //* Set the placeholder number typ
2455
- setPlaceholderNumberType(t) {
2456
- this.options.placeholderNumberType = t, this._updatePlaceholder();
2461
+ setPlaceholderNumberType(e) {
2462
+ this.options.placeholderNumberType = e, this._updatePlaceholder();
2457
2463
  }
2458
- setDisabled(t) {
2459
- this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
2464
+ setDisabled(e) {
2465
+ this.telInput.disabled = e, e ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
2460
2466
  }
2461
2467
  }
2462
2468
  const W = (u) => {
2463
2469
  if (!l.utils && !l.startedLoadingUtilsScript) {
2464
- let t;
2470
+ let e;
2465
2471
  if (typeof u == "function")
2466
2472
  try {
2467
- t = Promise.resolve(u());
2468
- } catch (e) {
2469
- return Promise.reject(e);
2473
+ e = Promise.resolve(u());
2474
+ } catch (t) {
2475
+ return Promise.reject(t);
2470
2476
  }
2471
2477
  else
2472
2478
  return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof u}`));
2473
- return l.startedLoadingUtilsScript = !0, t.then((e) => {
2474
- const i = e == null ? void 0 : e.default;
2479
+ return l.startedLoadingUtilsScript = !0, e.then((t) => {
2480
+ const i = t == null ? void 0 : t.default;
2475
2481
  if (!i || typeof i != "object")
2476
2482
  throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
2477
2483
  return l.utils = i, w("handleUtils"), !0;
2478
- }).catch((e) => {
2479
- throw w("rejectUtilsScriptPromise", e), e;
2484
+ }).catch((t) => {
2485
+ throw w("rejectUtilsScriptPromise", t), t;
2480
2486
  });
2481
2487
  }
2482
2488
  return null;
2483
2489
  }, l = Object.assign(
2484
- (u, t) => {
2485
- const e = new G(u, t);
2486
- return e._init(), u.setAttribute("data-intl-tel-input-id", e.id.toString()), l.instances[e.id] = e, e;
2490
+ (u, e) => {
2491
+ const t = new G(u, e);
2492
+ return t._init(), u.setAttribute("data-intl-tel-input-id", t.id.toString()), l.instances[t.id] = t, t;
2487
2493
  },
2488
2494
  {
2489
2495
  defaults: T,
@@ -2493,15 +2499,15 @@ const W = (u) => {
2493
2499
  getCountryData: () => I,
2494
2500
  //* A getter for the plugin instance.
2495
2501
  getInstance: (u) => {
2496
- const t = u.getAttribute("data-intl-tel-input-id");
2497
- return t ? l.instances[t] : null;
2502
+ const e = u.getAttribute("data-intl-tel-input-id");
2503
+ return e ? l.instances[e] : null;
2498
2504
  },
2499
2505
  //* A map from instance ID to instance object.
2500
2506
  instances: {},
2501
2507
  attachUtils: W,
2502
2508
  startedLoadingUtilsScript: !1,
2503
2509
  startedLoadingAutoCountry: !1,
2504
- version: "25.0.1"
2510
+ version: "25.0.2"
2505
2511
  }
2506
2512
  ), J = {
2507
2513
  __name: "IntlTelInput",
@@ -2535,38 +2541,38 @@ const W = (u) => {
2535
2541
  "changeValidity",
2536
2542
  "changeErrorCode"
2537
2543
  ], ["update:modelValue"]),
2538
- setup(u, { expose: t, emit: e }) {
2539
- const i = x(u, "modelValue"), s = u, n = e, o = L(), a = L(), r = L(!1), p = () => a.value ? s.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, c = () => {
2540
- let h = p();
2541
- r.value !== h && (r.value = h, n("changeValidity", !!h), n(
2544
+ setup(u, { expose: e, emit: t }) {
2545
+ const i = x(u, "modelValue"), s = u, n = t, o = L(), a = L(), r = L(!1), p = () => a.value ? s.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, h = () => {
2546
+ let d = p();
2547
+ r.value !== d && (r.value = d, n("changeValidity", !!d), n(
2542
2548
  "changeErrorCode",
2543
- h ? null : a.value.getValidationError()
2549
+ d ? null : a.value.getValidationError()
2544
2550
  ));
2545
- }, d = () => {
2546
- var h;
2547
- n("changeNumber", ((h = a.value) == null ? void 0 : h.getNumber()) ?? ""), c();
2551
+ }, c = () => {
2552
+ var d;
2553
+ n("changeNumber", ((d = a.value) == null ? void 0 : d.getNumber()) ?? ""), h();
2548
2554
  }, C = () => {
2549
- var h;
2550
- n("changeCountry", ((h = a.value) == null ? void 0 : h.getSelectedCountryData().iso2) ?? ""), d(), c();
2555
+ var d;
2556
+ n("changeCountry", ((d = a.value) == null ? void 0 : d.getSelectedCountryData().iso2) ?? ""), c(), h();
2551
2557
  };
2552
2558
  return E(() => {
2553
2559
  o.value && (a.value = l(o.value, s.options), s.value && a.value.setNumber(s.value), s.disabled && a.value.setDisabled(s.disabled));
2554
2560
  }), M(
2555
2561
  () => s.disabled,
2556
- (h) => {
2562
+ (d) => {
2557
2563
  var m;
2558
- return (m = a.value) == null ? void 0 : m.setDisabled(h);
2564
+ return (m = a.value) == null ? void 0 : m.setDisabled(d);
2559
2565
  }
2560
2566
  ), F(() => {
2561
- var h;
2562
- return (h = a.value) == null ? void 0 : h.destroy();
2563
- }), t({ instance: a, input: o }), (h, m) => B((O(), V("input", z({
2567
+ var d;
2568
+ return (d = a.value) == null ? void 0 : d.destroy();
2569
+ }), e({ instance: a, input: o }), (d, m) => B((V(), O("input", z({
2564
2570
  ref_key: "input",
2565
2571
  ref: o,
2566
2572
  "onUpdate:modelValue": m[0] || (m[0] = (b) => i.value = b),
2567
2573
  type: "tel",
2568
2574
  onCountrychange: C,
2569
- onInput: d
2575
+ onInput: c
2570
2576
  }, u.inputProps), null, 16)), [
2571
2577
  [R, i.value]
2572
2578
  ]);