intl-tel-input 25.10.11 → 25.11.0

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 A, useModel as E, ref as N, onMounted as M, watch as B, onUnmounted as R, withDirectives as F, createElementBlock as z, openBlock as V, mergeProps as $, vModelText as O } from "vue";
2
- const U = [
1
+ import { mergeModels as P, useModel as B, ref as L, onMounted as F, watch as R, onUnmounted as z, withDirectives as V, createElementBlock as $, openBlock as U, mergeProps as j, vModelText as W } from "vue";
2
+ const O = [
3
3
  [
4
4
  "af",
5
5
  // Afghanistan
@@ -1676,9 +1676,9 @@ const U = [
1676
1676
  null,
1677
1677
  "0"
1678
1678
  ]
1679
- ], b = [];
1680
- for (const l of U)
1681
- b.push({
1679
+ ], w = [];
1680
+ for (const l of O)
1681
+ w.push({
1682
1682
  name: "",
1683
1683
  // populated in the plugin
1684
1684
  iso2: l[0],
@@ -1689,7 +1689,7 @@ for (const l of U)
1689
1689
  // populated by the plugin
1690
1690
  nationalPrefix: l[4] || null
1691
1691
  });
1692
- const j = {
1692
+ const x = {
1693
1693
  ad: "Andorra",
1694
1694
  ae: "United Arab Emirates",
1695
1695
  af: "Afghanistan",
@@ -1944,13 +1944,13 @@ const j = {
1944
1944
  // additional countries (not supported by country-list library)
1945
1945
  ac: "Ascension Island",
1946
1946
  xk: "Kosovo"
1947
- }, P = { ...j, ...H }, D = (l) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(l).matches, K = () => {
1947
+ }, K = { ...x, ...H }, N = (l) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(l).matches, G = () => {
1948
1948
  if (typeof navigator < "u" && typeof window < "u") {
1949
- const l = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), t = D("(max-width: 500px)"), e = D("(max-height: 600px)"), i = D("(pointer: coarse)");
1949
+ const l = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), t = N("(max-width: 500px)"), e = N("(max-height: 600px)"), i = N("(pointer: coarse)");
1950
1950
  return l || t || i && e;
1951
1951
  }
1952
1952
  return !1;
1953
- }, x = {
1953
+ }, T = {
1954
1954
  // Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
1955
1955
  allowPhonewords: !1,
1956
1956
  //* Whether or not to allow the dropdown.
@@ -1998,219 +1998,55 @@ const j = {
1998
1998
  //* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
1999
1999
  strictMode: !1,
2000
2000
  //* Use full screen popup instead of dropdown for country list.
2001
- useFullscreenPopup: K(),
2001
+ useFullscreenPopup: G(),
2002
2002
  //* The number type to enforce during validation.
2003
2003
  validationNumberTypes: ["MOBILE"]
2004
2004
  };
2005
- function W(l) {
2006
- l.useFullscreenPopup && (l.fixDropdownWidth = !1), l.onlyCountries.length === 1 && (l.initialCountry = l.onlyCountries[0]), l.separateDialCode && (l.nationalMode = !1), l.allowDropdown && !l.showFlags && !l.separateDialCode && (l.nationalMode = !1), l.useFullscreenPopup && !l.dropdownContainer && (l.dropdownContainer = document.body), l.i18n = { ...P, ...l.i18n };
2005
+ function q(l) {
2006
+ l.useFullscreenPopup && (l.fixDropdownWidth = !1), l.onlyCountries.length === 1 && (l.initialCountry = l.onlyCountries[0]), l.separateDialCode && (l.nationalMode = !1), l.allowDropdown && !l.showFlags && !l.separateDialCode && (l.nationalMode = !1), l.useFullscreenPopup && !l.dropdownContainer && (l.dropdownContainer = document.body), l.i18n = { ...K, ...l.i18n };
2007
2007
  }
2008
- const v = (l) => l.replace(/\D/g, ""), T = (l = "") => l.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), m = (l, t, e) => {
2008
+ const v = (l) => l.replace(/\D/g, ""), M = (l = "") => l.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), D = (l) => Object.keys(l).filter((t) => !!l[t]).join(" "), p = (l, t, e) => {
2009
2009
  const i = document.createElement(l);
2010
- return t && Object.entries(t).forEach(([n, s]) => i.setAttribute(n, s)), e && e.appendChild(i), i;
2010
+ return t && Object.entries(t).forEach(([s, o]) => i.setAttribute(s, o)), e && e.appendChild(i), i;
2011
2011
  };
2012
- function G(l) {
2013
- const { onlyCountries: t, excludeCountries: e } = l;
2014
- if (t.length) {
2015
- const i = t.map((n) => n.toLowerCase());
2016
- return b.filter((n) => i.includes(n.iso2));
2017
- } else if (e.length) {
2018
- const i = e.map((n) => n.toLowerCase());
2019
- return b.filter((n) => !i.includes(n.iso2));
2020
- }
2021
- return b;
2022
- }
2023
- function q(l, t) {
2024
- for (const e of l) {
2025
- const i = e.iso2.toLowerCase();
2026
- t.i18n[i] && (e.name = t.i18n[i]);
2027
- }
2028
- }
2029
- function Y(l, t) {
2030
- const e = /* @__PURE__ */ new Set();
2031
- let i = 0;
2032
- const n = {}, s = (o, a, u) => {
2033
- if (!o || !a)
2034
- return;
2035
- a.length > i && (i = a.length), n.hasOwnProperty(a) || (n[a] = []);
2036
- const r = n[a];
2037
- if (r.includes(o))
2038
- return;
2039
- const h = u !== void 0 ? u : r.length;
2040
- r[h] = o;
2041
- };
2042
- for (const o of l) {
2043
- e.has(o.dialCode) || e.add(o.dialCode);
2044
- for (let a = 1; a < o.dialCode.length; a++) {
2045
- const u = o.dialCode.substring(0, a);
2046
- s(o.iso2, u);
2047
- }
2048
- s(o.iso2, o.dialCode, o.priority);
2049
- }
2050
- (t.onlyCountries.length || t.excludeCountries.length) && e.forEach((o) => {
2051
- n[o] = n[o].filter(Boolean);
2052
- });
2053
- for (const o of l)
2054
- if (o.areaCodes) {
2055
- const a = n[o.dialCode][0];
2056
- for (const u of o.areaCodes) {
2057
- for (let r = 1; r < u.length; r++) {
2058
- const h = u.substring(0, r), p = o.dialCode + h;
2059
- s(a, p), s(o.iso2, p);
2060
- }
2061
- s(o.iso2, o.dialCode + u);
2062
- }
2063
- }
2064
- return { dialCodes: e, dialCodeMaxLen: i, dialCodeToIso2Map: n };
2065
- }
2066
- function J(l, t) {
2067
- t.countryOrder && (t.countryOrder = t.countryOrder.map((e) => e.toLowerCase())), l.sort((e, i) => {
2068
- const { countryOrder: n } = t;
2069
- if (n) {
2070
- const s = n.indexOf(e.iso2), o = n.indexOf(i.iso2), a = s > -1, u = o > -1;
2071
- if (a || u)
2072
- return a && u ? s - o : a ? -1 : 1;
2073
- }
2074
- return e.name.localeCompare(i.name);
2075
- });
2076
- }
2077
- function Z(l) {
2078
- for (const t of l)
2079
- t.normalisedName = T(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
2080
- }
2081
- function Q(l, t, e, i) {
2082
- let n = l;
2083
- if (e && t) {
2084
- t = `+${i.dialCode}`;
2085
- const s = n[t.length] === " " || n[t.length] === "-" ? t.length + 1 : t.length;
2086
- n = n.substring(s);
2087
- }
2088
- return n;
2089
- }
2090
- function X(l, t, e, i, n) {
2091
- const s = e ? e.formatNumberAsYouType(l, i.iso2) : l, { dialCode: o } = i;
2092
- return n && t.charAt(0) !== "+" && s.includes(`+${o}`) ? (s.split(`+${o}`)[1] || "").trim() : s;
2093
- }
2094
- function tt(l, t, e, i) {
2095
- if (e === 0 && !i)
2096
- return 0;
2097
- let n = 0;
2098
- for (let s = 0; s < t.length; s++) {
2099
- if (/[+0-9]/.test(t[s]) && n++, n === l && !i)
2100
- return s + 1;
2101
- if (i && n === l + 1)
2102
- return s;
2103
- }
2104
- return t.length;
2105
- }
2106
- const et = [
2107
- "800",
2108
- "822",
2109
- "833",
2110
- "844",
2111
- "855",
2112
- "866",
2113
- "877",
2114
- "880",
2115
- "881",
2116
- "882",
2117
- "883",
2118
- "884",
2119
- "885",
2120
- "886",
2121
- "887",
2122
- "888",
2123
- "889"
2124
- ], k = (l) => {
2125
- const t = v(l);
2126
- if (t.charAt(0) === "1") {
2127
- const e = t.substring(1, 4);
2128
- return et.includes(e);
2129
- }
2130
- return !1;
2131
- };
2132
- for (const l of b)
2133
- l.name = P[l.iso2];
2134
- let it = 0;
2135
- const nt = new Set(b.map((l) => l.iso2)), S = (l) => nt.has(l), I = (l, ...t) => {
2136
- const { instances: e } = d;
2137
- Object.values(e).forEach((i) => i[l](...t));
2138
- };
2139
- class L {
2140
- /**
2141
- * Build a space-delimited class string from an object map of className -> truthy/falsey.
2142
- * Only keys with truthy values are included.
2143
- */
2144
- static _buildClassNames(t) {
2145
- return Object.keys(t).filter((e) => !!t[e]).join(" ");
2146
- }
2147
- constructor(t, e = {}) {
2148
- this.id = it++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, x, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
2149
- }
2150
- _detectEnvironmentAndLayout() {
2151
- this.isAndroid = typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.telInput.dir = "ltr";
2152
- const t = this.options.allowDropdown || this.options.separateDialCode;
2153
- this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft);
2154
- }
2155
- _createInitPromises() {
2156
- const t = new Promise((i, n) => {
2157
- this.resolveAutoCountryPromise = i, this.rejectAutoCountryPromise = n;
2158
- }), e = new Promise((i, n) => {
2159
- this.resolveUtilsScriptPromise = i, this.rejectUtilsScriptPromise = n;
2160
- });
2161
- this.promise = Promise.all([t, e]);
2162
- }
2163
- //* Can't be private as it's called from intlTelInput convenience wrapper.
2164
- _init() {
2165
- W(this.options), this._detectEnvironmentAndLayout(), this._createInitPromises(), this.selectedCountryData = {}, this._processCountryData(), this._generateMarkup(), this._setInitialState(), this._initListeners(), this._initRequests();
2166
- }
2167
- //********************
2168
- //* PRIVATE METHODS
2169
- //********************
2170
- //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
2171
- _processCountryData() {
2172
- this.countries = G(this.options);
2173
- const t = Y(this.countries, this.options);
2174
- this.dialCodes = t.dialCodes, this.dialCodeMaxLen = t.dialCodeMaxLen, this.dialCodeToIso2Map = t.dialCodeToIso2Map, q(this.countries, this.options), J(this.countries, this.options), this.countryByIso2 = new Map(this.countries.map((e) => [e.iso2, e])), Z(this.countries);
2012
+ class Q {
2013
+ constructor(t, e, i) {
2014
+ this.highlightedItem = null, t.dataset.intlTelInputId = i.toString(), this.telInput = t, this.options = e, this.id = i, this.hadInitialPlaceholder = !!t.getAttribute("placeholder"), this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.options.separateDialCode && (this.originalPaddingLeft = this.telInput.style.paddingLeft);
2175
2015
  }
2176
2016
  //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
2177
- _generateMarkup() {
2178
- this._prepareTelInput();
2179
- const t = this._createWrapperAndInsert();
2180
- this._maybeBuildCountryContainer(t), t.appendChild(this.telInput), this._maybeUpdateInputPaddingAndReveal(), this._maybeBuildHiddenInputs(t);
2017
+ generateMarkup(t) {
2018
+ this.countries = t, this._prepareTelInput();
2019
+ const e = this._createWrapperAndInsert();
2020
+ this._maybeBuildCountryContainer(e), e.appendChild(this.telInput), this._maybeUpdateInputPaddingAndReveal(), this._maybeBuildHiddenInputs(e);
2181
2021
  }
2182
2022
  _prepareTelInput() {
2183
- this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
2023
+ var t;
2024
+ this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !((t = this.telInput.form) != null && t.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
2184
2025
  }
2185
2026
  _createWrapperAndInsert() {
2186
- var a;
2187
2027
  const {
2188
2028
  allowDropdown: t,
2189
2029
  showFlags: e,
2190
2030
  containerClass: i,
2191
- useFullscreenPopup: n
2192
- } = this.options, s = L._buildClassNames({
2031
+ useFullscreenPopup: s
2032
+ } = this.options, o = D({
2193
2033
  iti: !0,
2194
2034
  "iti--allow-dropdown": t,
2195
2035
  "iti--show-flags": e,
2196
- "iti--inline-dropdown": !n,
2036
+ "iti--inline-dropdown": !s,
2197
2037
  [i]: !!i
2198
- }), o = m("div", { class: s });
2199
- return (a = this.telInput.parentNode) == null || a.insertBefore(o, this.telInput), o;
2038
+ }), n = p("div", { class: o });
2039
+ return this.isRTL && n.setAttribute("dir", "ltr"), this.telInput.before(n), n;
2200
2040
  }
2201
2041
  _maybeBuildCountryContainer(t) {
2202
- const {
2203
- allowDropdown: e,
2204
- separateDialCode: i,
2205
- showFlags: n
2206
- } = this.options;
2207
- if (e || n || i) {
2208
- this.countryContainer = m(
2042
+ const { allowDropdown: e, separateDialCode: i, showFlags: s } = this.options;
2043
+ if (e || s || i) {
2044
+ this.countryContainer = p(
2209
2045
  "div",
2210
2046
  // visibly hidden until we measure it's width to set the input padding correctly
2211
2047
  { class: "iti__country-container iti__v-hide" },
2212
2048
  t
2213
- ), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", e ? (this.selectedCountry = m(
2049
+ ), e ? (this.selectedCountry = p(
2214
2050
  "button",
2215
2051
  {
2216
2052
  type: "button",
@@ -2221,27 +2057,27 @@ class L {
2221
2057
  "aria-controls": `iti-${this.id}__dropdown-content`
2222
2058
  },
2223
2059
  this.countryContainer
2224
- ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = m(
2060
+ ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = p(
2225
2061
  "div",
2226
2062
  { class: "iti__selected-country" },
2227
2063
  this.countryContainer
2228
2064
  );
2229
- const s = m(
2065
+ const o = p(
2230
2066
  "div",
2231
2067
  { class: "iti__selected-country-primary" },
2232
2068
  this.selectedCountry
2233
2069
  );
2234
- this.selectedCountryInner = m(
2070
+ this.selectedCountryInner = p(
2235
2071
  "div",
2236
2072
  { class: "iti__flag" },
2237
- s
2238
- ), e && (this.dropdownArrow = m(
2073
+ o
2074
+ ), e && (this.dropdownArrow = p(
2239
2075
  "div",
2240
2076
  { class: "iti__arrow", "aria-hidden": "true" },
2241
- s
2242
- )), i && (this.selectedDialCode = m(
2077
+ o
2078
+ )), i && (this.selectedDialCode = p(
2243
2079
  "div",
2244
- { class: "iti__selected-dial-code", dir: "ltr" },
2080
+ { class: "iti__selected-dial-code" },
2245
2081
  this.selectedCountry
2246
2082
  )), e && this._buildDropdownContent();
2247
2083
  }
@@ -2251,43 +2087,43 @@ class L {
2251
2087
  fixDropdownWidth: t,
2252
2088
  useFullscreenPopup: e,
2253
2089
  countrySearch: i,
2254
- i18n: n,
2255
- dropdownContainer: s,
2256
- containerClass: o
2090
+ i18n: s,
2091
+ dropdownContainer: o,
2092
+ containerClass: n
2257
2093
  } = this.options, a = t ? "" : "iti--flexible-dropdown-width";
2258
- if (this.dropdownContent = m("div", {
2094
+ if (this.dropdownContent = p("div", {
2259
2095
  id: `iti-${this.id}__dropdown-content`,
2260
2096
  class: `iti__dropdown-content iti__hide ${a}`,
2261
2097
  role: "dialog",
2262
2098
  "aria-modal": "true"
2263
- }), i && this._buildSearchUI(), this.countryList = m(
2099
+ }), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"), i && this._buildSearchUI(), this.countryList = p(
2264
2100
  "ul",
2265
2101
  {
2266
2102
  class: "iti__country-list",
2267
2103
  id: `iti-${this.id}__country-listbox`,
2268
2104
  role: "listbox",
2269
- "aria-label": n.countryListAriaLabel
2105
+ "aria-label": s.countryListAriaLabel
2270
2106
  },
2271
2107
  this.dropdownContent
2272
- ), this._appendListItems(), i && this._updateSearchResultsA11yText(), s) {
2273
- const u = L._buildClassNames({
2108
+ ), this._appendListItems(), this.options.countrySearch && this.updateSearchResultsA11yText(), o) {
2109
+ const r = D({
2274
2110
  iti: !0,
2275
2111
  "iti--container": !0,
2276
2112
  "iti--fullscreen-popup": e,
2277
2113
  "iti--inline-dropdown": !e,
2278
- [o]: !!o
2114
+ [n]: !!n
2279
2115
  });
2280
- this.dropdown = m("div", { class: u }), this.dropdown.appendChild(this.dropdownContent);
2116
+ this.dropdown = p("div", { class: r }), this.dropdown.appendChild(this.dropdownContent);
2281
2117
  } else
2282
2118
  this.countryContainer.appendChild(this.dropdownContent);
2283
2119
  }
2284
2120
  _buildSearchUI() {
2285
- const { i18n: t } = this.options, e = m(
2121
+ const { i18n: t } = this.options, e = p(
2286
2122
  "div",
2287
2123
  { class: "iti__search-input-wrapper" },
2288
2124
  this.dropdownContent
2289
2125
  );
2290
- this.searchIcon = m(
2126
+ this.searchIcon = p(
2291
2127
  "span",
2292
2128
  {
2293
2129
  class: "iti__search-icon",
@@ -2298,7 +2134,7 @@ class L {
2298
2134
  <svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
2299
2135
  <circle cx="11" cy="11" r="7" />
2300
2136
  <line x1="21" y1="21" x2="16.65" y2="16.65" />
2301
- </svg>`, this.searchInput = m(
2137
+ </svg>`, this.searchInput = p(
2302
2138
  "input",
2303
2139
  {
2304
2140
  id: `iti-${this.id}__search-input`,
@@ -2315,7 +2151,7 @@ class L {
2315
2151
  autocomplete: "off"
2316
2152
  },
2317
2153
  e
2318
- ), this.searchClearButton = m(
2154
+ ), this.searchClearButton = p(
2319
2155
  "button",
2320
2156
  {
2321
2157
  type: "button",
@@ -2333,11 +2169,11 @@ class L {
2333
2169
  <path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
2334
2170
  </mask>
2335
2171
  <circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${i})" />
2336
- </svg>`, this.searchResultsA11yText = m(
2172
+ </svg>`, this.searchResultsA11yText = p(
2337
2173
  "span",
2338
2174
  { class: "iti__a11y-text" },
2339
2175
  this.dropdownContent
2340
- ), this.searchNoResults = m(
2176
+ ), this.searchNoResults = p(
2341
2177
  "div",
2342
2178
  {
2343
2179
  class: "iti__no-results iti__hide",
@@ -2348,109 +2184,371 @@ class L {
2348
2184
  ), this.searchNoResults.textContent = t.zeroSearchResults;
2349
2185
  }
2350
2186
  _maybeUpdateInputPaddingAndReveal() {
2351
- this.countryContainer && (this._updateInputPadding(), this.countryContainer.classList.remove("iti__v-hide"));
2187
+ this.countryContainer && (this.updateInputPadding(), this.countryContainer.classList.remove("iti__v-hide"));
2352
2188
  }
2353
2189
  _maybeBuildHiddenInputs(t) {
2354
- var i, n;
2190
+ var i, s;
2355
2191
  const { hiddenInput: e } = this.options;
2356
2192
  if (e) {
2357
- const s = this.telInput.getAttribute("name") || "", o = e(s);
2358
- if (o.phone) {
2359
- const a = (i = this.telInput.form) == null ? void 0 : i.querySelector(`input[name="${o.phone}"]`);
2360
- a ? this.hiddenInput = a : (this.hiddenInput = m("input", {
2193
+ const o = this.telInput.getAttribute("name") || "", n = e(o);
2194
+ if (n.phone) {
2195
+ const a = (i = this.telInput.form) == null ? void 0 : i.querySelector(
2196
+ `input[name="${n.phone}"]`
2197
+ );
2198
+ a ? this.hiddenInput = a : (this.hiddenInput = p("input", {
2361
2199
  type: "hidden",
2362
- name: o.phone
2200
+ name: n.phone
2363
2201
  }), t.appendChild(this.hiddenInput));
2364
2202
  }
2365
- if (o.country) {
2366
- const a = (n = this.telInput.form) == null ? void 0 : n.querySelector(`input[name="${o.country}"]`);
2367
- a ? this.hiddenInputCountry = a : (this.hiddenInputCountry = m("input", {
2203
+ if (n.country) {
2204
+ const a = (s = this.telInput.form) == null ? void 0 : s.querySelector(
2205
+ `input[name="${n.country}"]`
2206
+ );
2207
+ a ? this.hiddenInputCountry = a : (this.hiddenInputCountry = p("input", {
2368
2208
  type: "hidden",
2369
- name: o.country
2209
+ name: n.country
2370
2210
  }), t.appendChild(this.hiddenInputCountry));
2371
2211
  }
2372
2212
  }
2373
2213
  }
2374
2214
  //* For each country: add a country list item <li> to the countryList <ul> container.
2375
2215
  _appendListItems() {
2376
- for (let t = 0; t < this.countries.length; t++) {
2377
- const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", n = m(
2378
- "li",
2379
- {
2380
- id: `iti-${this.id}__item-${e.iso2}`,
2381
- class: `iti__country ${i}`,
2382
- tabindex: "-1",
2383
- role: "option",
2384
- "data-dial-code": e.dialCode,
2385
- "data-country-code": e.iso2,
2386
- "aria-selected": "false"
2387
- },
2388
- this.countryList
2216
+ const t = document.createDocumentFragment();
2217
+ for (let e = 0; e < this.countries.length; e++) {
2218
+ const i = this.countries[e], s = D({
2219
+ iti__country: !0,
2220
+ iti__highlight: e === 0
2221
+ }), o = p("li", {
2222
+ id: `iti-${this.id}__item-${i.iso2}`,
2223
+ class: s,
2224
+ tabindex: "-1",
2225
+ role: "option",
2226
+ "aria-selected": "false"
2227
+ });
2228
+ o.dataset.dialCode = i.dialCode, o.dataset.countryCode = i.iso2, i.nodeById[this.id] = o, this.options.showFlags && p("div", { class: `iti__flag iti__${i.iso2}` }, o);
2229
+ const n = p("span", { class: "iti__country-name" }, o);
2230
+ n.textContent = i.name;
2231
+ const a = p("span", { class: "iti__dial-code" }, o);
2232
+ this.isRTL && a.setAttribute("dir", "ltr"), a.textContent = `+${i.dialCode}`, t.appendChild(o);
2233
+ }
2234
+ this.countryList.appendChild(t);
2235
+ }
2236
+ //* Update the input padding to make space for the selected country/dial code.
2237
+ updateInputPadding() {
2238
+ if (this.selectedCountry) {
2239
+ const t = this.options.separateDialCode ? 78 : 42, i = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || t) + 6;
2240
+ this.telInput.style.paddingLeft = `${i}px`;
2241
+ }
2242
+ }
2243
+ //* When input is in a hidden container during init, we cannot calculate the selected country width.
2244
+ //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
2245
+ //* To get the right styling to apply, all we need is a shallow clone of the container,
2246
+ //* and then to inject a deep clone of the selectedCountry element.
2247
+ _getHiddenSelectedCountryWidth() {
2248
+ if (this.telInput.parentNode) {
2249
+ let t;
2250
+ try {
2251
+ t = window.top.document.body;
2252
+ } catch {
2253
+ t = document.body;
2254
+ }
2255
+ const e = this.telInput.parentNode.cloneNode(
2256
+ !1
2389
2257
  );
2390
- e.nodeById[this.id] = n;
2391
- let s = "";
2392
- this.options.showFlags && (s += `<div class='iti__flag iti__${e.iso2}'></div>`), s += `<span class='iti__country-name'>${e.name}</span>`, s += `<span class='iti__dial-code' dir='ltr'>+${e.dialCode}</span>`, n.insertAdjacentHTML("beforeend", s);
2258
+ e.style.visibility = "hidden", t.appendChild(e);
2259
+ const i = this.countryContainer.cloneNode();
2260
+ e.appendChild(i);
2261
+ const s = this.selectedCountry.cloneNode(
2262
+ !0
2263
+ );
2264
+ i.appendChild(s);
2265
+ const o = s.offsetWidth;
2266
+ return t.removeChild(e), o;
2267
+ }
2268
+ return 0;
2269
+ }
2270
+ //* Update search results text (for a11y).
2271
+ updateSearchResultsA11yText() {
2272
+ const { i18n: t } = this.options, e = this.countryList.childElementCount;
2273
+ let i;
2274
+ e === 0 ? i = t.zeroSearchResults : t.searchResultsText ? i = t.searchResultsText(e) : e === 1 ? i = t.oneSearchResult : i = t.multipleSearchResults.replace(
2275
+ "${count}",
2276
+ e.toString()
2277
+ ), this.searchResultsA11yText.textContent = i;
2278
+ }
2279
+ //* Check if an element is visible within it's container, else scroll until it is.
2280
+ scrollTo(t) {
2281
+ const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, o = e.getBoundingClientRect().top + i, n = o + s, a = t.offsetHeight, r = t.getBoundingClientRect().top + i, u = r + a, c = r - o + e.scrollTop;
2282
+ if (r < o)
2283
+ e.scrollTop = c;
2284
+ else if (u > n) {
2285
+ const C = s - a;
2286
+ e.scrollTop = c - C;
2287
+ }
2288
+ }
2289
+ //* Remove highlighting from other list items and highlight the given item.
2290
+ highlightListItem(t, e) {
2291
+ const i = this.highlightedItem;
2292
+ if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true"), this.options.countrySearch)) {
2293
+ const s = this.highlightedItem.getAttribute("id") || "";
2294
+ this.searchInput.setAttribute(
2295
+ "aria-activedescendant",
2296
+ s
2297
+ );
2298
+ }
2299
+ e && this.highlightedItem.focus();
2300
+ }
2301
+ //* Country search: Filter the country list to the given array of countries.
2302
+ filterCountries(t) {
2303
+ this.countryList.innerHTML = "";
2304
+ let e = !0;
2305
+ for (const i of t) {
2306
+ const s = i.nodeById[this.id];
2307
+ s && (this.countryList.appendChild(s), e && (this.highlightListItem(s, !1), e = !1));
2308
+ }
2309
+ e ? (this.highlightListItem(null, !1), this.searchNoResults && this.searchNoResults.classList.remove("iti__hide")) : this.searchNoResults && this.searchNoResults.classList.add("iti__hide"), this.countryList.scrollTop = 0, this.updateSearchResultsA11yText();
2310
+ }
2311
+ destroy() {
2312
+ this.telInput.iti = void 0, delete this.telInput.dataset.intlTelInputId, this.options.separateDialCode && (this.telInput.style.paddingLeft = this.originalPaddingLeft);
2313
+ const t = this.telInput.parentNode;
2314
+ t.before(this.telInput), t.remove(), this.telInput = null, this.countryContainer = null, this.selectedCountry = null, this.selectedCountryInner = null, this.selectedDialCode = null, this.dropdownArrow = null, this.dropdownContent = null, this.searchInput = null, this.searchIcon = null, this.searchClearButton = null, this.searchNoResults = null, this.searchResultsA11yText = null, this.countryList = null, this.dropdown = null, this.hiddenInput = null, this.hiddenInputCountry = null, this.highlightedItem = null;
2315
+ for (const e of this.countries)
2316
+ delete e.nodeById[this.id];
2317
+ this.countries = null;
2318
+ }
2319
+ }
2320
+ function Y(l) {
2321
+ const { onlyCountries: t, excludeCountries: e } = l;
2322
+ if (t.length) {
2323
+ const i = t.map((s) => s.toLowerCase());
2324
+ return w.filter((s) => i.includes(s.iso2));
2325
+ } else if (e.length) {
2326
+ const i = e.map((s) => s.toLowerCase());
2327
+ return w.filter((s) => !i.includes(s.iso2));
2328
+ }
2329
+ return w;
2330
+ }
2331
+ function J(l, t) {
2332
+ for (const e of l) {
2333
+ const i = e.iso2.toLowerCase();
2334
+ t.i18n[i] && (e.name = t.i18n[i]);
2335
+ }
2336
+ }
2337
+ function Z(l, t) {
2338
+ const e = /* @__PURE__ */ new Set();
2339
+ let i = 0;
2340
+ const s = {}, o = (n, a, r) => {
2341
+ if (!n || !a)
2342
+ return;
2343
+ a.length > i && (i = a.length), s.hasOwnProperty(a) || (s[a] = []);
2344
+ const u = s[a];
2345
+ if (u.includes(n))
2346
+ return;
2347
+ const c = r !== void 0 ? r : u.length;
2348
+ u[c] = n;
2349
+ };
2350
+ for (const n of l) {
2351
+ e.has(n.dialCode) || e.add(n.dialCode);
2352
+ for (let a = 1; a < n.dialCode.length; a++) {
2353
+ const r = n.dialCode.substring(0, a);
2354
+ o(n.iso2, r);
2393
2355
  }
2356
+ o(n.iso2, n.dialCode, n.priority);
2357
+ }
2358
+ (t.onlyCountries.length || t.excludeCountries.length) && e.forEach((n) => {
2359
+ s[n] = s[n].filter(Boolean);
2360
+ });
2361
+ for (const n of l)
2362
+ if (n.areaCodes) {
2363
+ const a = s[n.dialCode][0];
2364
+ for (const r of n.areaCodes) {
2365
+ for (let u = 1; u < r.length; u++) {
2366
+ const c = r.substring(0, u), C = n.dialCode + c;
2367
+ o(a, C), o(n.iso2, C);
2368
+ }
2369
+ o(n.iso2, n.dialCode + r);
2370
+ }
2371
+ }
2372
+ return { dialCodes: e, dialCodeMaxLen: i, dialCodeToIso2Map: s };
2373
+ }
2374
+ function X(l, t) {
2375
+ t.countryOrder && (t.countryOrder = t.countryOrder.map((e) => e.toLowerCase())), l.sort((e, i) => {
2376
+ const { countryOrder: s } = t;
2377
+ if (s) {
2378
+ const o = s.indexOf(e.iso2), n = s.indexOf(i.iso2), a = o > -1, r = n > -1;
2379
+ if (a || r)
2380
+ return a && r ? o - n : a ? -1 : 1;
2381
+ }
2382
+ return e.name.localeCompare(i.name);
2383
+ });
2384
+ }
2385
+ function tt(l) {
2386
+ for (const t of l)
2387
+ t.normalisedName = M(t.name), t.initials = t.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((e) => e[0]).join("").toLowerCase(), t.dialCodePlus = `+${t.dialCode}`;
2388
+ }
2389
+ function et(l, t, e, i) {
2390
+ let s = l;
2391
+ if (e && t) {
2392
+ t = `+${i.dialCode}`;
2393
+ const o = s[t.length] === " " || s[t.length] === "-" ? t.length + 1 : t.length;
2394
+ s = s.substring(o);
2395
+ }
2396
+ return s;
2397
+ }
2398
+ function it(l, t, e, i, s) {
2399
+ const o = e ? e.formatNumberAsYouType(l, i.iso2) : l, { dialCode: n } = i;
2400
+ return s && t.charAt(0) !== "+" && o.includes(`+${n}`) ? (o.split(`+${n}`)[1] || "").trim() : o;
2401
+ }
2402
+ function st(l, t, e, i) {
2403
+ if (e === 0 && !i)
2404
+ return 0;
2405
+ let s = 0;
2406
+ for (let o = 0; o < t.length; o++) {
2407
+ if (/[+0-9]/.test(t[o]) && s++, s === l && !i)
2408
+ return o + 1;
2409
+ if (i && s === l + 1)
2410
+ return o;
2411
+ }
2412
+ return t.length;
2413
+ }
2414
+ const nt = [
2415
+ "800",
2416
+ "822",
2417
+ "833",
2418
+ "844",
2419
+ "855",
2420
+ "866",
2421
+ "877",
2422
+ "880",
2423
+ "881",
2424
+ "882",
2425
+ "883",
2426
+ "884",
2427
+ "885",
2428
+ "886",
2429
+ "887",
2430
+ "888",
2431
+ "889"
2432
+ ], k = (l) => {
2433
+ const t = v(l);
2434
+ if (t.charAt(0) === "1") {
2435
+ const e = t.substring(1, 4);
2436
+ return nt.includes(e);
2437
+ }
2438
+ return !1;
2439
+ };
2440
+ for (const l of w)
2441
+ l.name = x[l.iso2];
2442
+ let ot = 0;
2443
+ const rt = new Set(w.map((l) => l.iso2)), A = (l) => rt.has(l);
2444
+ class S {
2445
+ constructor(t, e = {}) {
2446
+ this.id = ot++, this.options = { ...T, ...e }, q(this.options), this.ui = new Q(t, this.options, this.id), this.isAndroid = S._getIsAndroid(), this.promise = this._createInitPromises(), this.countries = Y(this.options);
2447
+ const { dialCodes: i, dialCodeMaxLen: s, dialCodeToIso2Map: o } = Z(
2448
+ this.countries,
2449
+ this.options
2450
+ );
2451
+ this.dialCodes = i, this.dialCodeMaxLen = s, this.dialCodeToIso2Map = o, this.countryByIso2 = new Map(this.countries.map((n) => [n.iso2, n])), this._init();
2452
+ }
2453
+ static _getIsAndroid() {
2454
+ return typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1;
2455
+ }
2456
+ _createInitPromises() {
2457
+ const t = new Promise((i, s) => {
2458
+ this.resolveAutoCountryPromise = i, this.rejectAutoCountryPromise = s;
2459
+ }), e = new Promise((i, s) => {
2460
+ this.resolveUtilsScriptPromise = i, this.rejectUtilsScriptPromise = s;
2461
+ });
2462
+ return Promise.all([t, e]);
2463
+ }
2464
+ //* Can't be private as it's called from intlTelInput convenience wrapper.
2465
+ _init() {
2466
+ this.selectedCountryData = {}, this.abortController = new AbortController(), this._processCountryData(), this.ui.generateMarkup(this.countries), this._setInitialState(), this._initListeners(), this._initRequests();
2467
+ }
2468
+ //********************
2469
+ //* PRIVATE METHODS
2470
+ //********************
2471
+ //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
2472
+ _processCountryData() {
2473
+ J(this.countries, this.options), X(this.countries, this.options), tt(this.countries);
2394
2474
  }
2395
2475
  //* Set the initial state of the input value and the selected country by:
2396
2476
  //* 1. Extracting a dial code from the given number
2397
2477
  //* 2. Using explicit initialCountry
2398
2478
  _setInitialState(t = !1) {
2399
- const e = this.telInput.getAttribute("value"), i = this.telInput.value, s = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(s), a = k(s), { initialCountry: u, geoIpLookup: r } = this.options, h = u === "auto" && r;
2400
- if (o && !a)
2401
- this._updateCountryFromNumber(s);
2402
- else if (!h || t) {
2403
- const p = u ? u.toLowerCase() : "";
2404
- S(p) ? this._setCountry(p) : o && a ? this._setCountry("us") : this._setCountry("");
2479
+ const e = this.ui.telInput.getAttribute("value"), i = this.ui.telInput.value, o = e && e.startsWith("+") && (!i || !i.startsWith("+")) ? e : i, n = this._getDialCode(o), a = k(o), { initialCountry: r, geoIpLookup: u } = this.options, c = r === "auto" && u;
2480
+ if (n && !a)
2481
+ this._updateCountryFromNumber(o);
2482
+ else if (!c || t) {
2483
+ const C = r ? r.toLowerCase() : "";
2484
+ A(C) ? this._setCountry(C) : n && a ? this._setCountry("us") : this._setCountry("");
2405
2485
  }
2406
- s && this._updateValFromNumber(s);
2486
+ o && this._updateValFromNumber(o);
2407
2487
  }
2408
2488
  //* Initialise the main event listeners: input keyup, and click selected country.
2409
2489
  _initListeners() {
2410
- this._initTelInputListeners(), this.options.allowDropdown && this._initDropdownListeners(), (this.hiddenInput || this.hiddenInputCountry) && this.telInput.form && this._initHiddenInputListener();
2490
+ this._initTelInputListeners(), this.options.allowDropdown && this._initDropdownListeners(), (this.ui.hiddenInput || this.ui.hiddenInputCountry) && this.ui.telInput.form && this._initHiddenInputListener();
2411
2491
  }
2412
2492
  //* Update hidden input on form submit.
2413
2493
  _initHiddenInputListener() {
2414
- var t;
2415
- this._handleHiddenInputSubmit = () => {
2416
- this.hiddenInput && (this.hiddenInput.value = this.getNumber()), this.hiddenInputCountry && (this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "");
2417
- }, (t = this.telInput.form) == null || t.addEventListener(
2418
- "submit",
2419
- this._handleHiddenInputSubmit
2420
- );
2494
+ var e;
2495
+ const t = () => {
2496
+ this.ui.hiddenInput && (this.ui.hiddenInput.value = this.getNumber()), this.ui.hiddenInputCountry && (this.ui.hiddenInputCountry.value = this.selectedCountryData.iso2 || "");
2497
+ };
2498
+ (e = this.ui.telInput.form) == null || e.addEventListener("submit", t, {
2499
+ signal: this.abortController.signal
2500
+ });
2421
2501
  }
2422
2502
  //* initialise the dropdown listeners.
2423
2503
  _initDropdownListeners() {
2424
- this._handleLabelClick = (e) => {
2425
- this.dropdownContent.classList.contains("iti__hide") ? this.telInput.focus() : e.preventDefault();
2504
+ const t = this.abortController.signal, e = (n) => {
2505
+ this.ui.dropdownContent.classList.contains("iti__hide") ? this.ui.telInput.focus() : n.preventDefault();
2506
+ }, i = this.ui.telInput.closest("label");
2507
+ i && i.addEventListener("click", e, { signal: t });
2508
+ const s = () => {
2509
+ this.ui.dropdownContent.classList.contains("iti__hide") && !this.ui.telInput.disabled && !this.ui.telInput.readOnly && this._openDropdown();
2510
+ };
2511
+ this.ui.selectedCountry.addEventListener("click", s, {
2512
+ signal: t
2513
+ });
2514
+ const o = (n) => {
2515
+ this.ui.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(n.key) && (n.preventDefault(), n.stopPropagation(), this._openDropdown()), n.key === "Tab" && this._closeDropdown();
2426
2516
  };
2427
- const t = this.telInput.closest("label");
2428
- t && t.addEventListener("click", this._handleLabelClick), this._handleClickSelectedCountry = () => {
2429
- this.dropdownContent.classList.contains("iti__hide") && !this.telInput.disabled && !this.telInput.readOnly && this._openDropdown();
2430
- }, this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry), this._handleCountryContainerKeydown = (e) => {
2431
- this.dropdownContent.classList.contains("iti__hide") && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key) && (e.preventDefault(), e.stopPropagation(), this._openDropdown()), e.key === "Tab" && this._closeDropdown();
2432
- }, this.countryContainer.addEventListener(
2517
+ this.ui.countryContainer.addEventListener(
2433
2518
  "keydown",
2434
- this._handleCountryContainerKeydown
2519
+ o,
2520
+ { signal: t }
2435
2521
  );
2436
2522
  }
2437
2523
  //* Init many requests: utils script / geo ip lookup.
2438
2524
  _initRequests() {
2439
- let { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
2440
- t && !d.utils ? (this._doAttachUtils = () => {
2441
- var s;
2442
- (s = d.attachUtils(t)) == null || s.catch(() => {
2443
- });
2444
- }, d.documentReady() ? this._doAttachUtils() : (this._handlePageLoad = () => {
2445
- this._doAttachUtils();
2446
- }, window.addEventListener("load", this._handlePageLoad))) : this.resolveUtilsScriptPromise(), e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
2525
+ const { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
2526
+ if (t && !d.utils) {
2527
+ const o = () => {
2528
+ var n;
2529
+ (n = d.attachUtils(t)) == null || n.catch(() => {
2530
+ });
2531
+ };
2532
+ if (d.documentReady())
2533
+ o();
2534
+ else {
2535
+ const n = () => {
2536
+ o();
2537
+ };
2538
+ window.addEventListener("load", n, {
2539
+ signal: this.abortController.signal
2540
+ });
2541
+ }
2542
+ } else
2543
+ this.resolveUtilsScriptPromise();
2544
+ e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
2447
2545
  }
2448
2546
  //* Perform the geo ip lookup.
2449
2547
  _loadAutoCountry() {
2450
2548
  d.autoCountry ? this.handleAutoCountry() : d.startedLoadingAutoCountry || (d.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
2451
2549
  (t = "") => {
2452
2550
  const e = t.toLowerCase();
2453
- S(e) ? (d.autoCountry = e, setTimeout(() => I("handleAutoCountry"))) : (this._setInitialState(!0), I("rejectAutoCountryPromise"));
2551
+ A(e) ? (d.autoCountry = e, setTimeout(() => I("handleAutoCountry"))) : (this._setInitialState(!0), I("rejectAutoCountryPromise"));
2454
2552
  },
2455
2553
  () => {
2456
2554
  this._setInitialState(!0), I("rejectAutoCountryPromise");
@@ -2458,206 +2556,257 @@ class L {
2458
2556
  ));
2459
2557
  }
2460
2558
  _openDropdownWithPlus() {
2461
- this._openDropdown(), this.searchInput.value = "+", this._filterCountries("");
2559
+ this._openDropdown(), this.ui.searchInput.value = "+", this._filterCountriesByQuery("");
2462
2560
  }
2463
2561
  //* Initialize the tel input listeners.
2464
2562
  _initTelInputListeners() {
2465
2563
  this._bindInputListener(), this._maybeBindKeydownListener(), this._maybeBindPasteListener();
2466
2564
  }
2467
2565
  _bindInputListener() {
2468
- const { strictMode: t, formatAsYouType: e, separateDialCode: i, allowDropdown: n, countrySearch: s } = this.options;
2469
- let o = !1;
2470
- new RegExp("\\p{L}", "u").test(this.telInput.value) && (o = !0), this._handleInputEvent = (a) => {
2471
- if (this.isAndroid && (a == null ? void 0 : a.data) === "+" && i && n && s) {
2472
- const p = this.telInput.selectionStart || 0, g = this.telInput.value.substring(0, p - 1), c = this.telInput.value.substring(p);
2473
- this.telInput.value = g + c, this._openDropdownWithPlus();
2566
+ const {
2567
+ strictMode: t,
2568
+ formatAsYouType: e,
2569
+ separateDialCode: i,
2570
+ allowDropdown: s,
2571
+ countrySearch: o
2572
+ } = this.options;
2573
+ let n = !1;
2574
+ new RegExp("\\p{L}", "u").test(this.ui.telInput.value) && (n = !0);
2575
+ const a = (r) => {
2576
+ if (this.isAndroid && (r == null ? void 0 : r.data) === "+" && i && s && o) {
2577
+ const m = this.ui.telInput.selectionStart || 0, h = this.ui.telInput.value.substring(
2578
+ 0,
2579
+ m - 1
2580
+ ), f = this.ui.telInput.value.substring(m);
2581
+ this.ui.telInput.value = h + f, this._openDropdownWithPlus();
2474
2582
  return;
2475
2583
  }
2476
- this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
2477
- const u = (a == null ? void 0 : a.data) && /[^+0-9]/.test(a.data), r = (a == null ? void 0 : a.inputType) === "insertFromPaste" && this.telInput.value;
2478
- u || r && !t ? o = !0 : /[^+0-9]/.test(this.telInput.value) || (o = !1);
2479
- const h = (a == null ? void 0 : a.detail) && a.detail.isSetNumber;
2480
- if (e && !o && !h) {
2481
- const p = this.telInput.selectionStart || 0, c = this.telInput.value.substring(0, p).replace(/[^+0-9]/g, "").length, y = (a == null ? void 0 : a.inputType) === "deleteContentForward", C = this._getFullNumber(), f = X(
2482
- C,
2483
- this.telInput.value,
2584
+ this._updateCountryFromNumber(this.ui.telInput.value) && this._triggerCountryChange();
2585
+ const u = (r == null ? void 0 : r.data) && /[^+0-9]/.test(r.data), c = (r == null ? void 0 : r.inputType) === "insertFromPaste" && this.ui.telInput.value;
2586
+ u || c && !t ? n = !0 : /[^+0-9]/.test(this.ui.telInput.value) || (n = !1);
2587
+ const C = (r == null ? void 0 : r.detail) && r.detail.isSetNumber;
2588
+ if (e && !n && !C) {
2589
+ const m = this.ui.telInput.selectionStart || 0, f = this.ui.telInput.value.substring(
2590
+ 0,
2591
+ m
2592
+ ).replace(
2593
+ /[^+0-9]/g,
2594
+ ""
2595
+ ).length, b = (r == null ? void 0 : r.inputType) === "deleteContentForward", y = this._getFullNumber(), g = it(
2596
+ y,
2597
+ this.ui.telInput.value,
2484
2598
  d.utils,
2485
2599
  this.selectedCountryData,
2486
2600
  this.options.separateDialCode
2487
- ), _ = tt(c, f, p, y);
2488
- this.telInput.value = f, this.telInput.setSelectionRange(_, _);
2601
+ ), _ = st(
2602
+ f,
2603
+ g,
2604
+ m,
2605
+ b
2606
+ );
2607
+ this.ui.telInput.value = g, this.ui.telInput.setSelectionRange(_, _);
2489
2608
  }
2490
- }, this.telInput.addEventListener("input", this._handleInputEvent);
2609
+ };
2610
+ this.ui.telInput.addEventListener("input", a, {
2611
+ signal: this.abortController.signal
2612
+ });
2491
2613
  }
2492
2614
  _maybeBindKeydownListener() {
2493
- const { strictMode: t, separateDialCode: e, allowDropdown: i, countrySearch: n } = this.options;
2494
- (t || e) && (this._handleKeydownEvent = (s) => {
2495
- if (s.key && s.key.length === 1 && !s.altKey && !s.ctrlKey && !s.metaKey) {
2496
- if (e && i && n && s.key === "+") {
2497
- s.preventDefault(), this._openDropdownWithPlus();
2498
- return;
2499
- }
2500
- if (t) {
2501
- const o = this.telInput.value, u = !(o.charAt(0) === "+") && this.telInput.selectionStart === 0 && s.key === "+", r = /^[0-9]$/.test(s.key), h = e ? r : u || r, p = o.slice(0, this.telInput.selectionStart) + s.key + o.slice(this.telInput.selectionEnd), g = this._getFullNumber(p), c = d.utils.getCoreNumber(g, this.selectedCountryData.iso2), y = this.maxCoreNumberLength && c.length > this.maxCoreNumberLength, f = this._getNewCountryFromNumber(g) !== null;
2502
- (!h || y && !f && !u) && s.preventDefault();
2615
+ const { strictMode: t, separateDialCode: e, allowDropdown: i, countrySearch: s } = this.options;
2616
+ if (t || e) {
2617
+ const o = (n) => {
2618
+ if (n.key && n.key.length === 1 && !n.altKey && !n.ctrlKey && !n.metaKey) {
2619
+ if (e && i && s && n.key === "+") {
2620
+ n.preventDefault(), this._openDropdownWithPlus();
2621
+ return;
2622
+ }
2623
+ if (t) {
2624
+ const a = this.ui.telInput.value, u = !a.startsWith("+") && this.ui.telInput.selectionStart === 0 && n.key === "+", c = /^[0-9]$/.test(n.key), C = e ? c : u || c, m = a.slice(0, this.ui.telInput.selectionStart) + n.key + a.slice(this.ui.telInput.selectionEnd), h = this._getFullNumber(m), f = d.utils.getCoreNumber(
2625
+ h,
2626
+ this.selectedCountryData.iso2
2627
+ ), b = this.maxCoreNumberLength && f.length > this.maxCoreNumberLength, g = this._getNewCountryFromNumber(h) !== null;
2628
+ (!C || b && !g && !u) && n.preventDefault();
2629
+ }
2503
2630
  }
2504
- }
2505
- }, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
2631
+ };
2632
+ this.ui.telInput.addEventListener("keydown", o, {
2633
+ signal: this.abortController.signal
2634
+ });
2635
+ }
2506
2636
  }
2507
2637
  _maybeBindPasteListener() {
2508
- this.options.strictMode && (this._handlePasteEvent = (t) => {
2509
- t.preventDefault();
2510
- const e = this.telInput, i = e.selectionStart, n = e.selectionEnd, s = e.value.slice(0, i), o = e.value.slice(n), a = this.selectedCountryData.iso2, u = t.clipboardData.getData("text"), r = i === 0 && n > 0, h = !e.value.startsWith("+") || r, p = u.replace(/[^0-9+]/g, ""), g = p.startsWith("+"), c = p.replace(/\+/g, ""), y = g && h ? `+${c}` : c;
2511
- let C = s + y + o, f = d.utils.getCoreNumber(C, a);
2512
- for (; f.length === 0 && C.length > 0; )
2513
- C = C.slice(0, -1), f = d.utils.getCoreNumber(C, a);
2514
- if (!f)
2515
- return;
2516
- if (this.maxCoreNumberLength && f.length > this.maxCoreNumberLength)
2517
- if (e.selectionEnd === e.value.length) {
2518
- const w = f.length - this.maxCoreNumberLength;
2519
- C = C.slice(0, C.length - w);
2520
- } else
2638
+ if (this.options.strictMode) {
2639
+ const t = (e) => {
2640
+ e.preventDefault();
2641
+ const i = this.ui.telInput, s = i.selectionStart, o = i.selectionEnd, n = i.value.slice(0, s), a = i.value.slice(o), r = this.selectedCountryData.iso2, u = e.clipboardData.getData("text"), c = s === 0 && o > 0, C = !i.value.startsWith("+") || c, m = u.replace(/[^0-9+]/g, ""), h = m.startsWith("+"), f = m.replace(/\+/g, ""), b = h && C ? `+${f}` : f;
2642
+ let y = n + b + a, g = d.utils.getCoreNumber(y, r);
2643
+ for (; g.length === 0 && y.length > 0; )
2644
+ y = y.slice(0, -1), g = d.utils.getCoreNumber(y, r);
2645
+ if (!g)
2521
2646
  return;
2522
- e.value = C;
2523
- const _ = i + y.length;
2524
- e.setSelectionRange(_, _), e.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
2525
- }, this.telInput.addEventListener("paste", this._handlePasteEvent));
2647
+ if (this.maxCoreNumberLength && g.length > this.maxCoreNumberLength)
2648
+ if (i.selectionEnd === i.value.length) {
2649
+ const E = g.length - this.maxCoreNumberLength;
2650
+ y = y.slice(0, y.length - E);
2651
+ } else
2652
+ return;
2653
+ i.value = y;
2654
+ const _ = s + b.length;
2655
+ i.setSelectionRange(_, _), i.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
2656
+ };
2657
+ this.ui.telInput.addEventListener("paste", t, {
2658
+ signal: this.abortController.signal
2659
+ });
2660
+ }
2526
2661
  }
2527
2662
  //* Adhere to the input's maxlength attr.
2528
2663
  _cap(t) {
2529
- const e = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
2664
+ const e = Number(this.ui.telInput.getAttribute("maxlength"));
2530
2665
  return e && t.length > e ? t.substring(0, e) : t;
2531
2666
  }
2532
- //* Trigger a custom event on the input.
2667
+ //* Trigger a custom event on the input (typed via ItiEventMap).
2533
2668
  _trigger(t, e = {}) {
2534
2669
  const i = new CustomEvent(t, {
2535
2670
  bubbles: !0,
2536
2671
  cancelable: !0,
2537
2672
  detail: e
2538
2673
  });
2539
- this.telInput.dispatchEvent(i);
2674
+ this.ui.telInput.dispatchEvent(i);
2540
2675
  }
2541
2676
  //* Open the dropdown.
2542
2677
  _openDropdown() {
2543
2678
  const { fixDropdownWidth: t, countrySearch: e } = this.options;
2544
- 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) {
2545
- const i = this.countryList.firstElementChild;
2546
- i && (this._highlightListItem(i, !1), this.countryList.scrollTop = 0), this.searchInput.focus();
2679
+ if (this.dropdownAbortController = new AbortController(), t && (this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`), this.ui.dropdownContent.classList.remove("iti__hide"), this.ui.selectedCountry.setAttribute("aria-expanded", "true"), this._setDropdownPosition(), e) {
2680
+ const i = this.ui.countryList.firstElementChild;
2681
+ i && (this.ui.highlightListItem(i, !1), this.ui.countryList.scrollTop = 0), this.ui.searchInput.focus();
2547
2682
  }
2548
- this._bindDropdownListeners(), this.dropdownArrow.classList.add("iti__arrow--up"), this._trigger("open:countrydropdown");
2683
+ this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add("iti__arrow--up"), this._trigger("open:countrydropdown");
2549
2684
  }
2550
2685
  //* Set the dropdown position
2551
2686
  _setDropdownPosition() {
2552
- if (this.options.dropdownContainer && this.options.dropdownContainer.appendChild(this.dropdown), !this.options.useFullscreenPopup) {
2553
- const t = this.telInput.getBoundingClientRect(), e = this.telInput.offsetHeight;
2554
- 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));
2687
+ if (this.options.dropdownContainer && this.options.dropdownContainer.appendChild(this.ui.dropdown), !this.options.useFullscreenPopup) {
2688
+ const t = this.ui.telInput.getBoundingClientRect(), e = this.ui.telInput.offsetHeight;
2689
+ if (this.options.dropdownContainer) {
2690
+ this.ui.dropdown.style.top = `${t.top + e}px`, this.ui.dropdown.style.left = `${t.left}px`;
2691
+ const i = () => this._closeDropdown();
2692
+ window.addEventListener("scroll", i, {
2693
+ signal: this.dropdownAbortController.signal
2694
+ });
2695
+ }
2555
2696
  }
2556
2697
  }
2557
2698
  //* We only bind dropdown listeners when the dropdown is open.
2558
2699
  _bindDropdownListeners() {
2559
- this._handleMouseoverCountryList = (i) => {
2560
- var s;
2561
- const n = (s = i.target) == null ? void 0 : s.closest(".iti__country");
2562
- n && this._highlightListItem(n, !1);
2563
- }, this.countryList.addEventListener(
2564
- "mouseover",
2565
- this._handleMouseoverCountryList
2566
- ), this._handleClickCountryList = (i) => {
2567
- var s;
2568
- const n = (s = i.target) == null ? void 0 : s.closest(".iti__country");
2569
- n && this._selectListItem(n);
2570
- }, this.countryList.addEventListener("click", this._handleClickCountryList), this._handleClickOffToClose = (i) => {
2571
- !!i.target.closest(`#iti-${this.id}__dropdown-content`) || this._closeDropdown();
2572
- }, setTimeout(() => {
2700
+ const t = this.dropdownAbortController.signal, e = (r) => {
2701
+ var c;
2702
+ const u = (c = r.target) == null ? void 0 : c.closest(
2703
+ ".iti__country"
2704
+ );
2705
+ u && this.ui.highlightListItem(u, !1);
2706
+ };
2707
+ this.ui.countryList.addEventListener("mouseover", e, {
2708
+ signal: t
2709
+ });
2710
+ const i = (r) => {
2711
+ var c;
2712
+ const u = (c = r.target) == null ? void 0 : c.closest(
2713
+ ".iti__country"
2714
+ );
2715
+ u && this._selectListItem(u);
2716
+ };
2717
+ this.ui.countryList.addEventListener("click", i, {
2718
+ signal: t
2719
+ });
2720
+ const s = (r) => {
2721
+ !!r.target.closest(
2722
+ `#iti-${this.id}__dropdown-content`
2723
+ ) || this._closeDropdown();
2724
+ };
2725
+ setTimeout(() => {
2573
2726
  document.documentElement.addEventListener(
2574
2727
  "click",
2575
- this._handleClickOffToClose
2728
+ s,
2729
+ { signal: t }
2576
2730
  );
2577
2731
  }, 0);
2578
- let t = "", e = null;
2579
- if (this._handleKeydownOnDropdown = (i) => {
2580
- ["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(i.key) && (i.preventDefault(), i.stopPropagation(), i.key === "ArrowUp" || i.key === "ArrowDown" ? this._handleUpDownKey(i.key) : i.key === "Enter" ? this._handleEnterKey() : i.key === "Escape" && this._closeDropdown()), !this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(i.key) && (i.stopPropagation(), e && clearTimeout(e), t += i.key.toLowerCase(), this._searchForCountry(t), e = setTimeout(() => {
2581
- t = "";
2732
+ let o = "", n = null;
2733
+ const a = (r) => {
2734
+ ["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(r.key) && (r.preventDefault(), r.stopPropagation(), r.key === "ArrowUp" || r.key === "ArrowDown" ? this._handleUpDownKey(r.key) : r.key === "Enter" ? this._handleEnterKey() : r.key === "Escape" && this._closeDropdown()), !this.options.countrySearch && /^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(r.key) && (r.stopPropagation(), n && clearTimeout(n), o += r.key.toLowerCase(), this._searchForCountry(o), n = setTimeout(() => {
2735
+ o = "";
2582
2736
  }, 1e3));
2583
- }, document.addEventListener("keydown", this._handleKeydownOnDropdown), this.options.countrySearch) {
2584
- const i = () => {
2585
- const s = this.searchInput.value.trim();
2586
- this._filterCountries(s), this.searchInput.value ? this.searchClearButton.classList.remove("iti__hide") : this.searchClearButton.classList.add("iti__hide");
2737
+ };
2738
+ if (document.addEventListener("keydown", a, { signal: t }), this.options.countrySearch) {
2739
+ const r = () => {
2740
+ const m = this.ui.searchInput.value.trim();
2741
+ this._filterCountriesByQuery(m), this.ui.searchInput.value ? this.ui.searchClearButton.classList.remove("iti__hide") : this.ui.searchClearButton.classList.add("iti__hide");
2587
2742
  };
2588
- let n = null;
2589
- this._handleSearchChange = () => {
2590
- n && clearTimeout(n), n = setTimeout(() => {
2591
- i(), n = null;
2743
+ let u = null;
2744
+ const c = () => {
2745
+ u && clearTimeout(u), u = setTimeout(() => {
2746
+ r(), u = null;
2592
2747
  }, 100);
2593
- }, this.searchInput.addEventListener("input", this._handleSearchChange), this._handleSearchClear = () => {
2594
- this.searchInput.value = "", this.searchInput.focus(), i();
2595
- }, this.searchClearButton.addEventListener("click", this._handleSearchClear);
2748
+ };
2749
+ this.ui.searchInput.addEventListener("input", c, {
2750
+ signal: t
2751
+ });
2752
+ const C = () => {
2753
+ this.ui.searchInput.value = "", this.ui.searchInput.focus(), r();
2754
+ };
2755
+ this.ui.searchClearButton.addEventListener("click", C, {
2756
+ signal: t
2757
+ });
2596
2758
  }
2597
2759
  }
2598
2760
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
2599
2761
  _searchForCountry(t) {
2600
2762
  for (const e of this.countries)
2601
2763
  if (e.name.substring(0, t.length).toLowerCase() === t) {
2602
- const n = e.nodeById[this.id];
2603
- this._highlightListItem(n, !1), this._scrollTo(n);
2764
+ const s = e.nodeById[this.id];
2765
+ this.ui.highlightListItem(s, !1), this.ui.scrollTo(s);
2604
2766
  break;
2605
2767
  }
2606
2768
  }
2607
- //* Country search enabled: Filter the countries according to the search query.
2608
- _filterCountries(t) {
2609
- this.countryList.innerHTML = "";
2769
+ //* Country search: Filter the countries according to the search query.
2770
+ _filterCountriesByQuery(t) {
2610
2771
  let e;
2611
- t === "" ? e = this.countries : e = this._getMatchedCountries(t);
2612
- let i = !0;
2613
- for (const n of e) {
2614
- const s = n.nodeById[this.id];
2615
- s && (this.countryList.appendChild(s), i && (this._highlightListItem(s, !1), i = !1));
2616
- }
2617
- i ? (this._highlightListItem(null, !1), this.searchNoResults && this.searchNoResults.classList.remove("iti__hide")) : this.searchNoResults && this.searchNoResults.classList.add("iti__hide"), this.countryList.scrollTop = 0, this._updateSearchResultsA11yText();
2772
+ t === "" ? e = this.countries : e = this._getMatchedCountries(t), this.ui.filterCountries(e);
2618
2773
  }
2619
2774
  _getMatchedCountries(t) {
2620
- const e = T(t), i = [], n = [], s = [], o = [], a = [], u = [];
2621
- for (const r of this.countries)
2622
- r.iso2 === e ? i.push(r) : r.normalisedName.startsWith(e) ? n.push(r) : r.normalisedName.includes(e) ? s.push(r) : e === r.dialCode || e === r.dialCodePlus ? o.push(r) : r.dialCodePlus.includes(e) ? a.push(r) : r.initials.includes(e) && u.push(r);
2775
+ const e = M(t), i = [], s = [], o = [], n = [], a = [], r = [];
2776
+ for (const u of this.countries)
2777
+ u.iso2 === e ? i.push(u) : u.normalisedName.startsWith(e) ? s.push(u) : u.normalisedName.includes(e) ? o.push(u) : e === u.dialCode || e === u.dialCodePlus ? n.push(u) : u.dialCodePlus.includes(e) ? a.push(u) : u.initials.includes(e) && r.push(u);
2623
2778
  return [
2624
- ...i.sort((r, h) => r.priority - h.priority),
2625
- ...n.sort((r, h) => r.priority - h.priority),
2626
- ...s.sort((r, h) => r.priority - h.priority),
2627
- ...o.sort((r, h) => r.priority - h.priority),
2628
- ...a.sort((r, h) => r.priority - h.priority),
2629
- ...u.sort((r, h) => r.priority - h.priority)
2779
+ ...i.sort((u, c) => u.priority - c.priority),
2780
+ ...s.sort((u, c) => u.priority - c.priority),
2781
+ ...o.sort((u, c) => u.priority - c.priority),
2782
+ ...n.sort((u, c) => u.priority - c.priority),
2783
+ ...a.sort((u, c) => u.priority - c.priority),
2784
+ ...r.sort((u, c) => u.priority - c.priority)
2630
2785
  ];
2631
2786
  }
2632
- //* Update search results text (for a11y).
2633
- _updateSearchResultsA11yText() {
2634
- const { i18n: t } = this.options, e = this.countryList.childElementCount;
2635
- let i;
2636
- e === 0 ? i = t.zeroSearchResults : t.searchResultsText ? i = t.searchResultsText(e) : e === 1 ? i = t.oneSearchResult : i = t.multipleSearchResults.replace("${count}", e.toString()), this.searchResultsA11yText.textContent = i;
2637
- }
2638
2787
  //* Highlight the next/prev item in the list (and ensure it is visible).
2639
2788
  _handleUpDownKey(t) {
2640
- var i, n;
2641
- let e = t === "ArrowUp" ? (i = this.highlightedItem) == null ? void 0 : i.previousElementSibling : (n = this.highlightedItem) == null ? void 0 : n.nextElementSibling;
2642
- !e && this.countryList.childElementCount > 1 && (e = t === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild), e && (this._scrollTo(e), this._highlightListItem(e, !1));
2789
+ var i, s;
2790
+ let e = t === "ArrowUp" ? (i = this.ui.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.ui.highlightedItem) == null ? void 0 : s.nextElementSibling;
2791
+ !e && this.ui.countryList.childElementCount > 1 && (e = t === "ArrowUp" ? this.ui.countryList.lastElementChild : this.ui.countryList.firstElementChild), e && (this.ui.scrollTo(e), this.ui.highlightListItem(e, !1));
2643
2792
  }
2644
2793
  //* Select the currently highlighted item.
2645
2794
  _handleEnterKey() {
2646
- this.highlightedItem && this._selectListItem(this.highlightedItem);
2795
+ this.ui.highlightedItem && this._selectListItem(this.ui.highlightedItem);
2647
2796
  }
2648
2797
  //* Update the input's value to the given val (format first if possible)
2649
2798
  //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
2650
2799
  _updateValFromNumber(t) {
2651
2800
  let e = t;
2652
2801
  if (this.options.formatOnDisplay && d.utils && this.selectedCountryData) {
2653
- const i = this.options.nationalMode || e.charAt(0) !== "+" && !this.options.separateDialCode, { NATIONAL: n, INTERNATIONAL: s } = d.utils.numberFormat, o = i ? n : s;
2802
+ const i = this.options.nationalMode || !e.startsWith("+") && !this.options.separateDialCode, { NATIONAL: s, INTERNATIONAL: o } = d.utils.numberFormat, n = i ? s : o;
2654
2803
  e = d.utils.formatNumber(
2655
2804
  e,
2656
2805
  this.selectedCountryData.iso2,
2657
- o
2806
+ n
2658
2807
  );
2659
2808
  }
2660
- e = this._beforeSetNumber(e), this.telInput.value = e;
2809
+ e = this._beforeSetNumber(e), this.ui.telInput.value = e;
2661
2810
  }
2662
2811
  //* Check if need to select a new country based on the given number
2663
2812
  //* Note: called from _setInitialState, keyup handler, setNumber.
@@ -2668,10 +2817,10 @@ class L {
2668
2817
  // if there is a selected country, and the number doesn't start with a dial code, then add it
2669
2818
  _ensureHasDialCode(t) {
2670
2819
  const { dialCode: e, nationalPrefix: i } = this.selectedCountryData;
2671
- if (t.charAt(0) === "+" || !e)
2820
+ if (t.startsWith("+") || !e)
2672
2821
  return t;
2673
- const o = i && t.charAt(0) === i && !this.options.separateDialCode ? t.substring(1) : t;
2674
- return `+${e}${o}`;
2822
+ const n = i && t.startsWith(i) && !this.options.separateDialCode ? t.substring(1) : t;
2823
+ return `+${e}${n}`;
2675
2824
  }
2676
2825
  // Get the country ISO2 code from the given number
2677
2826
  // BUT ONLY IF ITS CHANGED FROM THE CURRENTLY SELECTED COUNTRY
@@ -2679,186 +2828,137 @@ class L {
2679
2828
  _getNewCountryFromNumber(t) {
2680
2829
  const e = t.indexOf("+");
2681
2830
  let i = e ? t.substring(e) : t;
2682
- const n = this.selectedCountryData.iso2, s = this.selectedCountryData.dialCode;
2831
+ const s = this.selectedCountryData.iso2, o = this.selectedCountryData.dialCode;
2683
2832
  i = this._ensureHasDialCode(i);
2684
- const o = this._getDialCode(i, !0), a = v(i);
2685
- if (o) {
2686
- const u = v(o), r = this.dialCodeToIso2Map[u];
2687
- if (r.length === 1)
2688
- return r[0] === n ? null : r[0];
2689
- if (!n && this.defaultCountry && r.includes(this.defaultCountry))
2833
+ const n = this._getDialCode(i, !0), a = v(i);
2834
+ if (n) {
2835
+ const r = v(n), u = this.dialCodeToIso2Map[r];
2836
+ if (u.length === 1)
2837
+ return u[0] === s ? null : u[0];
2838
+ if (!s && this.defaultCountry && u.includes(this.defaultCountry))
2690
2839
  return this.defaultCountry;
2691
- if (s === "1" && k(a))
2840
+ if (o === "1" && k(a))
2692
2841
  return null;
2693
- const { areaCodes: p, priority: g } = this.selectedCountryData;
2694
- if (p) {
2695
- const _ = p.map((w) => `${s}${w}`);
2696
- for (const w of _)
2697
- if (a.startsWith(w))
2842
+ const { areaCodes: C, priority: m } = this.selectedCountryData;
2843
+ if (C) {
2844
+ const g = C.map(
2845
+ (_) => `${o}${_}`
2846
+ );
2847
+ for (const _ of g)
2848
+ if (a.startsWith(_))
2698
2849
  return null;
2699
2850
  }
2700
- const y = p && !(g === 0) && a.length > u.length, C = n && r.includes(n) && !y, f = n === r[0];
2701
- if (!C && !f)
2702
- return r[0];
2851
+ const f = C && !(m === 0) && a.length > r.length, b = s && u.includes(s) && !f, y = s === u[0];
2852
+ if (!b && !y)
2853
+ return u[0];
2703
2854
  } else {
2704
- if (i.charAt(0) === "+" && a.length)
2855
+ if (i.startsWith("+") && a.length)
2705
2856
  return "";
2706
- if ((!i || i === "+") && !n)
2857
+ if ((!i || i === "+") && !s)
2707
2858
  return this.defaultCountry;
2708
2859
  }
2709
2860
  return null;
2710
2861
  }
2711
- //* Remove highlighting from other list items and highlight the given item.
2712
- _highlightListItem(t, e) {
2713
- const i = this.highlightedItem;
2714
- if (i && (i.classList.remove("iti__highlight"), i.setAttribute("aria-selected", "false")), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add("iti__highlight"), this.highlightedItem.setAttribute("aria-selected", "true"), this.options.countrySearch)) {
2715
- const n = this.highlightedItem.getAttribute("id") || "";
2716
- this.searchInput.setAttribute("aria-activedescendant", n);
2717
- }
2718
- e && this.highlightedItem.focus();
2719
- }
2720
2862
  //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
2721
2863
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
2722
2864
  _setCountry(t) {
2723
- const { separateDialCode: e, showFlags: i, i18n: n } = this.options, s = this.selectedCountryData.iso2 || "";
2724
- if (this.selectedCountryData = t ? this.countryByIso2.get(t) : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.selectedCountry) {
2725
- const o = t && i ? `iti__flag iti__${t}` : "iti__flag iti__globe";
2726
- let a, u;
2865
+ const { separateDialCode: e, showFlags: i, i18n: s } = this.options, o = this.selectedCountryData.iso2 || "";
2866
+ if (this.selectedCountryData = t ? this.countryByIso2.get(t) : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.ui.selectedCountry) {
2867
+ const n = t && i ? `iti__flag iti__${t}` : "iti__flag iti__globe";
2868
+ let a, r;
2727
2869
  if (t) {
2728
- const { name: r, dialCode: h } = this.selectedCountryData;
2729
- u = r, a = n.selectedCountryAriaLabel.replace("${countryName}", r).replace("${dialCode}", `+${h}`);
2870
+ const { name: u, dialCode: c } = this.selectedCountryData;
2871
+ r = u, a = s.selectedCountryAriaLabel.replace("${countryName}", u).replace("${dialCode}", `+${c}`);
2730
2872
  } else
2731
- u = n.noCountrySelected, a = n.noCountrySelected;
2732
- this.selectedCountryInner.className = o, this.selectedCountry.setAttribute("title", u), this.selectedCountry.setAttribute("aria-label", a);
2873
+ r = s.noCountrySelected, a = s.noCountrySelected;
2874
+ this.ui.selectedCountryInner.className = n, this.ui.selectedCountry.setAttribute("title", r), this.ui.selectedCountry.setAttribute("aria-label", a);
2733
2875
  }
2734
2876
  if (e) {
2735
- const o = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
2736
- this.selectedDialCode.innerHTML = o, this._updateInputPadding();
2737
- }
2738
- return this._updatePlaceholder(), this._updateMaxLength(), s !== t;
2739
- }
2740
- //* Update the input padding to make space for the selected country/dial code.
2741
- _updateInputPadding() {
2742
- if (this.selectedCountry) {
2743
- const t = this.options.separateDialCode ? 78 : 42, i = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || t) + 6;
2744
- this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${i}px` : this.telInput.style.paddingRight = `${i}px`;
2877
+ const n = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
2878
+ this.ui.selectedDialCode.textContent = n, this.ui.updateInputPadding();
2745
2879
  }
2880
+ return this._updatePlaceholder(), this._updateMaxLength(), o !== t;
2746
2881
  }
2747
2882
  //* Update the maximum valid number length for the currently selected country.
2748
2883
  _updateMaxLength() {
2749
- const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: n } = this.selectedCountryData;
2884
+ const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
2750
2885
  if (t && d.utils)
2751
- if (n) {
2752
- const s = d.utils.numberType[e];
2753
- let o = d.utils.getExampleNumber(
2754
- n,
2755
- !1,
2886
+ if (s) {
2887
+ const o = d.utils.numberType[e];
2888
+ let n = d.utils.getExampleNumber(
2756
2889
  s,
2890
+ !1,
2891
+ o,
2757
2892
  !0
2758
- ), a = o;
2759
- for (; d.utils.isPossibleNumber(o, n, i); )
2760
- a = o, o += "0";
2761
- const u = d.utils.getCoreNumber(a, n);
2762
- this.maxCoreNumberLength = u.length, n === "by" && (this.maxCoreNumberLength = u.length + 1);
2893
+ ), a = n;
2894
+ for (; d.utils.isPossibleNumber(
2895
+ n,
2896
+ s,
2897
+ i
2898
+ ); )
2899
+ a = n, n += "0";
2900
+ const r = d.utils.getCoreNumber(a, s);
2901
+ this.maxCoreNumberLength = r.length, s === "by" && (this.maxCoreNumberLength = r.length + 1);
2763
2902
  } else
2764
2903
  this.maxCoreNumberLength = null;
2765
2904
  }
2766
- //* When input is in a hidden container during init, we cannot calculate the selected country width.
2767
- //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
2768
- //* To get the right styling to apply, all we need is a shallow clone of the container,
2769
- //* and then to inject a deep clone of the selectedCountry element.
2770
- _getHiddenSelectedCountryWidth() {
2771
- if (this.telInput.parentNode) {
2772
- let t;
2773
- try {
2774
- t = window.top.document.body;
2775
- } catch {
2776
- t = document.body;
2777
- }
2778
- const e = this.telInput.parentNode.cloneNode(!1);
2779
- e.style.visibility = "hidden", t.appendChild(e);
2780
- const i = this.countryContainer.cloneNode();
2781
- e.appendChild(i);
2782
- const n = this.selectedCountry.cloneNode(!0);
2783
- i.appendChild(n);
2784
- const s = n.offsetWidth;
2785
- return t.removeChild(e), s;
2786
- }
2787
- return 0;
2788
- }
2789
2905
  //* Update the input placeholder to an example number from the currently selected country.
2790
2906
  _updatePlaceholder() {
2791
2907
  const {
2792
2908
  autoPlaceholder: t,
2793
2909
  placeholderNumberType: e,
2794
2910
  nationalMode: i,
2795
- customPlaceholder: n
2796
- } = this.options, s = t === "aggressive" || !this.hadInitialPlaceholder && t === "polite";
2797
- if (d.utils && s) {
2798
- const o = d.utils.numberType[e];
2911
+ customPlaceholder: s
2912
+ } = this.options, o = t === "aggressive" || !this.ui.hadInitialPlaceholder && t === "polite";
2913
+ if (d.utils && o) {
2914
+ const n = d.utils.numberType[e];
2799
2915
  let a = this.selectedCountryData.iso2 ? d.utils.getExampleNumber(
2800
2916
  this.selectedCountryData.iso2,
2801
2917
  i,
2802
- o
2918
+ n
2803
2919
  ) : "";
2804
- a = this._beforeSetNumber(a), typeof n == "function" && (a = n(a, this.selectedCountryData)), this.telInput.setAttribute("placeholder", a);
2920
+ a = this._beforeSetNumber(a), typeof s == "function" && (a = s(a, this.selectedCountryData)), this.ui.telInput.setAttribute("placeholder", a);
2805
2921
  }
2806
2922
  }
2807
2923
  //* Called when the user selects a list item from the dropdown.
2808
2924
  _selectListItem(t) {
2809
- const e = t.getAttribute("data-country-code"), i = this._setCountry(e);
2925
+ const e = t.dataset.countryCode, i = this._setCountry(e);
2810
2926
  this._closeDropdown();
2811
- const n = t.getAttribute("data-dial-code");
2812
- this._updateDialCode(n), this.options.formatOnDisplay && this._updateValFromNumber(this.telInput.value), this.telInput.focus(), i && this._triggerCountryChange();
2927
+ const s = t.dataset.dialCode;
2928
+ this._updateDialCode(s), this.options.formatOnDisplay && this._updateValFromNumber(this.ui.telInput.value), this.ui.telInput.focus(), i && this._triggerCountryChange();
2813
2929
  }
2814
2930
  //* Close the dropdown and unbind any listeners.
2815
2931
  _closeDropdown() {
2816
- this.dropdownContent.classList.add("iti__hide"), this.selectedCountry.setAttribute("aria-expanded", "false"), this.highlightedItem && this.highlightedItem.setAttribute("aria-selected", "false"), this.options.countrySearch && this.searchInput.removeAttribute("aria-activedescendant"), this.dropdownArrow.classList.remove("iti__arrow--up"), this.options.countrySearch && (this.searchInput.removeEventListener("input", this._handleSearchChange), this.searchClearButton.removeEventListener("click", this._handleSearchClear)), document.removeEventListener("keydown", this._handleKeydownOnDropdown), document.documentElement.removeEventListener(
2817
- "click",
2818
- this._handleClickOffToClose
2819
- ), this.countryList.removeEventListener(
2820
- "mouseover",
2821
- this._handleMouseoverCountryList
2822
- ), this.countryList.removeEventListener("click", this._handleClickCountryList), this.options.dropdownContainer && (this.options.useFullscreenPopup || window.removeEventListener("scroll", this._handleWindowScroll), this.dropdown.parentNode && this.dropdown.parentNode.removeChild(this.dropdown)), this._trigger("close:countrydropdown");
2823
- }
2824
- //* Check if an element is visible within it's container, else scroll until it is.
2825
- _scrollTo(t) {
2826
- const e = this.countryList, i = document.documentElement.scrollTop, n = e.offsetHeight, s = e.getBoundingClientRect().top + i, o = s + n, a = t.offsetHeight, u = t.getBoundingClientRect().top + i, r = u + a, h = u - s + e.scrollTop;
2827
- if (u < s)
2828
- e.scrollTop = h;
2829
- else if (r > o) {
2830
- const p = n - a;
2831
- e.scrollTop = h - p;
2832
- }
2932
+ this.ui.dropdownContent.classList.contains("iti__hide") || (this.ui.dropdownContent.classList.add("iti__hide"), this.ui.selectedCountry.setAttribute("aria-expanded", "false"), this.ui.highlightedItem && this.ui.highlightedItem.setAttribute("aria-selected", "false"), this.options.countrySearch && this.ui.searchInput.removeAttribute("aria-activedescendant"), this.ui.dropdownArrow.classList.remove("iti__arrow--up"), this.dropdownAbortController.abort(), this.dropdownAbortController = null, this.options.dropdownContainer && this.ui.dropdown.remove(), this._trigger("close:countrydropdown"));
2833
2933
  }
2834
2934
  //* Replace any existing dial code with the new one
2835
2935
  //* Note: called from _selectListItem and setCountry
2836
2936
  _updateDialCode(t) {
2837
- const e = this.telInput.value, i = `+${t}`;
2838
- let n;
2839
- if (e.charAt(0) === "+") {
2840
- const s = this._getDialCode(e);
2841
- s ? n = e.replace(s, i) : n = i, this.telInput.value = n;
2937
+ const e = this.ui.telInput.value, i = `+${t}`;
2938
+ let s;
2939
+ if (e.startsWith("+")) {
2940
+ const o = this._getDialCode(e);
2941
+ o ? s = e.replace(o, i) : s = i, this.ui.telInput.value = s;
2842
2942
  }
2843
2943
  }
2844
2944
  //* Try and extract a valid international dial code from a full telephone number.
2845
2945
  //* Note: returns the raw string inc plus character and any whitespace/dots etc.
2846
2946
  _getDialCode(t, e) {
2847
2947
  let i = "";
2848
- if (t.charAt(0) === "+") {
2849
- let n = "";
2850
- for (let s = 0; s < t.length; s++) {
2851
- const o = t.charAt(s);
2852
- if (/[0-9]/.test(o)) {
2853
- if (n += o, !!!this.dialCodeToIso2Map[n])
2948
+ if (t.startsWith("+")) {
2949
+ let s = "";
2950
+ for (let o = 0; o < t.length; o++) {
2951
+ const n = t.charAt(o);
2952
+ if (/[0-9]/.test(n)) {
2953
+ if (s += n, !!!this.dialCodeToIso2Map[s])
2854
2954
  break;
2855
2955
  if (e)
2856
- i = t.substring(0, s + 1);
2857
- else if (this.dialCodes.has(n)) {
2858
- i = t.substring(0, s + 1);
2956
+ i = t.substring(0, o + 1);
2957
+ else if (this.dialCodes.has(s)) {
2958
+ i = t.substring(0, o + 1);
2859
2959
  break;
2860
2960
  }
2861
- if (n.length === this.dialCodeMaxLen)
2961
+ if (s.length === this.dialCodeMaxLen)
2862
2962
  break;
2863
2963
  }
2864
2964
  }
@@ -2867,14 +2967,14 @@ class L {
2867
2967
  }
2868
2968
  //* Get the input val, adding the dial code if separateDialCode is enabled.
2869
2969
  _getFullNumber(t) {
2870
- const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
2871
- let n;
2872
- const s = v(e);
2873
- return this.options.separateDialCode && e.charAt(0) !== "+" && i && s ? n = `+${i}` : n = "", n + e;
2970
+ const e = t || this.ui.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
2971
+ let s;
2972
+ const o = v(e);
2973
+ return this.options.separateDialCode && !e.startsWith("+") && i && o ? s = `+${i}` : s = "", s + e;
2874
2974
  }
2875
2975
  //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
2876
2976
  _beforeSetNumber(t) {
2877
- const e = this._getDialCode(t), i = Q(
2977
+ const e = this._getDialCode(t), i = et(
2878
2978
  t,
2879
2979
  e,
2880
2980
  this.options.separateDialCode,
@@ -2891,35 +2991,18 @@ class L {
2891
2991
  //**************************
2892
2992
  //* This is called when the geoip call returns.
2893
2993
  handleAutoCountry() {
2894
- this.options.initialCountry === "auto" && d.autoCountry && (this.defaultCountry = d.autoCountry, this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe") || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
2994
+ this.options.initialCountry === "auto" && d.autoCountry && (this.defaultCountry = d.autoCountry, this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains("iti__globe") || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
2895
2995
  }
2896
2996
  //* This is called when the utils request completes.
2897
2997
  handleUtils() {
2898
- d.utils && (this.telInput.value && this._updateValFromNumber(this.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
2998
+ d.utils && (this.ui.telInput.value && this._updateValFromNumber(this.ui.telInput.value), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength())), this.resolveUtilsScriptPromise();
2899
2999
  }
2900
3000
  //********************
2901
3001
  //* PUBLIC METHODS
2902
3002
  //********************
2903
3003
  //* Remove plugin.
2904
3004
  destroy() {
2905
- var s, o;
2906
- this.telInput.iti = void 0;
2907
- const { allowDropdown: t, separateDialCode: e } = this.options;
2908
- if (t) {
2909
- this._closeDropdown(), this.selectedCountry.removeEventListener(
2910
- "click",
2911
- this._handleClickSelectedCountry
2912
- ), this.countryContainer.removeEventListener(
2913
- "keydown",
2914
- this._handleCountryContainerKeydown
2915
- );
2916
- const a = this.telInput.closest("label");
2917
- a && a.removeEventListener("click", this._handleLabelClick);
2918
- }
2919
- const { form: i } = this.telInput;
2920
- this._handleHiddenInputSubmit && i && i.removeEventListener("submit", this._handleHiddenInputSubmit), this.telInput.removeEventListener("input", this._handleInputEvent), this._handleKeydownEvent && this.telInput.removeEventListener("keydown", this._handleKeydownEvent), this._handlePasteEvent && this.telInput.removeEventListener("paste", this._handlePasteEvent), this._handlePageLoad && window.removeEventListener("load", this._handlePageLoad), this.telInput.removeAttribute("data-intl-tel-input-id"), e && (this.isRTL ? this.telInput.style.paddingRight = this.originalPaddingRight : this.telInput.style.paddingLeft = this.originalPaddingLeft);
2921
- const n = this.telInput.parentNode;
2922
- (s = n == null ? void 0 : n.parentNode) == null || s.insertBefore(this.telInput, n), (o = n == null ? void 0 : n.parentNode) == null || o.removeChild(n), delete d.instances[this.id];
3005
+ this.ui.telInput && (this.options.allowDropdown && this._closeDropdown(), this.abortController.abort(), this.abortController = null, this.ui.destroy(), d.instances instanceof Map ? d.instances.delete(this.id) : delete d.instances[this.id]);
2923
3006
  }
2924
3007
  //* Get the extension from the current number.
2925
3008
  getExtension() {
@@ -2959,38 +3042,54 @@ class L {
2959
3042
  }
2960
3043
  return -99;
2961
3044
  }
2962
- //* Validate the input val (with precise=false)
3045
+ //* Validate the input val using number length only
2963
3046
  isValidNumber() {
3047
+ const { dialCode: t, iso2: e } = this.selectedCountryData;
3048
+ if (t === "44" && d.utils) {
3049
+ const i = this._getFullNumber(), s = d.utils.getCoreNumber(i, e);
3050
+ if (s[0] === "7" && s.length !== 10)
3051
+ return !1;
3052
+ }
2964
3053
  return this._validateNumber(!1);
2965
3054
  }
2966
- //* Validate the input val (with precise=true)
3055
+ //* Validate the input val with precise validation
2967
3056
  isValidNumberPrecise() {
2968
3057
  return this._validateNumber(!0);
2969
3058
  }
2970
3059
  _utilsIsPossibleNumber(t) {
2971
- return d.utils ? d.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3060
+ return d.utils ? d.utils.isPossibleNumber(
3061
+ t,
3062
+ this.selectedCountryData.iso2,
3063
+ this.options.validationNumberTypes
3064
+ ) : null;
2972
3065
  }
2973
3066
  //* Shared internal validation logic to handle alpha character extension rules.
2974
3067
  _validateNumber(t) {
3068
+ if (!d.utils)
3069
+ return null;
2975
3070
  if (!this.selectedCountryData.iso2)
2976
3071
  return !1;
2977
- const e = (o) => t ? this._utilsIsValidNumber(o) : this._utilsIsPossibleNumber(o), i = this._getFullNumber(), n = i.search(new RegExp("\\p{L}", "u"));
2978
- if (n > -1 && !this.options.allowPhonewords) {
2979
- const o = i.substring(0, n), a = e(o), u = e(i);
2980
- return a && u;
3072
+ const e = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n), i = this._getFullNumber(), s = i.search(new RegExp("\\p{L}", "u"));
3073
+ if (s > -1 && !this.options.allowPhonewords) {
3074
+ const n = i.substring(0, s), a = e(n), r = e(i);
3075
+ return a && r;
2981
3076
  }
2982
3077
  return e(i);
2983
3078
  }
2984
3079
  _utilsIsValidNumber(t) {
2985
- return d.utils ? d.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3080
+ return d.utils ? d.utils.isValidNumber(
3081
+ t,
3082
+ this.selectedCountryData.iso2,
3083
+ this.options.validationNumberTypes
3084
+ ) : null;
2986
3085
  }
2987
3086
  //* Update the selected country, and update the input val accordingly.
2988
3087
  setCountry(t) {
2989
3088
  const e = t == null ? void 0 : t.toLowerCase();
2990
- if (!S(e))
3089
+ if (!A(e))
2991
3090
  throw new Error(`Invalid country code: '${e}'`);
2992
3091
  const i = this.selectedCountryData.iso2;
2993
- (t && e !== i || !t && i) && (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this.options.formatOnDisplay && this._updateValFromNumber(this.telInput.value), this._triggerCountryChange());
3092
+ (t && e !== i || !t && i) && (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this.options.formatOnDisplay && this._updateValFromNumber(this.ui.telInput.value), this._triggerCountryChange());
2994
3093
  }
2995
3094
  //* Set the input value and update the country.
2996
3095
  setNumber(t) {
@@ -3002,10 +3101,10 @@ class L {
3002
3101
  this.options.placeholderNumberType = t, this._updatePlaceholder();
3003
3102
  }
3004
3103
  setDisabled(t) {
3005
- this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
3104
+ this.ui.telInput.disabled = t, t ? this.ui.selectedCountry.setAttribute("disabled", "true") : this.ui.selectedCountry.removeAttribute("disabled");
3006
3105
  }
3007
3106
  }
3008
- const st = (l) => {
3107
+ const at = (l) => {
3009
3108
  if (!d.utils && !d.startedLoadingUtilsScript) {
3010
3109
  let t;
3011
3110
  if (typeof l == "function")
@@ -3015,43 +3114,54 @@ const st = (l) => {
3015
3114
  return Promise.reject(e);
3016
3115
  }
3017
3116
  else
3018
- return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof l}`));
3117
+ return Promise.reject(
3118
+ new TypeError(
3119
+ `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof l}`
3120
+ )
3121
+ );
3019
3122
  return d.startedLoadingUtilsScript = !0, t.then((e) => {
3020
3123
  const i = e == null ? void 0 : e.default;
3021
3124
  if (!i || typeof i != "object")
3022
- throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
3125
+ throw new TypeError(
3126
+ "The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
3127
+ );
3023
3128
  return d.utils = i, I("handleUtils"), !0;
3024
3129
  }).catch((e) => {
3025
3130
  throw I("rejectUtilsScriptPromise", e), e;
3026
3131
  });
3027
3132
  }
3028
3133
  return null;
3134
+ }, I = (l, ...t) => {
3135
+ Object.values(d.instances).forEach((e) => {
3136
+ const i = e[l];
3137
+ typeof i == "function" && i.apply(e, t);
3138
+ });
3029
3139
  }, d = Object.assign(
3030
3140
  (l, t) => {
3031
- const e = new L(l, t);
3032
- return e._init(), l.setAttribute("data-intl-tel-input-id", e.id.toString()), d.instances[e.id] = e, l.iti = e, e;
3141
+ const e = new S(l, t);
3142
+ return d.instances[e.id] = e, l.iti = e, e;
3033
3143
  },
3034
3144
  {
3035
- defaults: x,
3145
+ defaults: T,
3036
3146
  //* Using a static var like this allows us to mock it in the tests.
3037
3147
  documentReady: () => document.readyState === "complete",
3038
3148
  //* Get the country data object.
3039
- getCountryData: () => b,
3149
+ getCountryData: () => w,
3040
3150
  //* A getter for the plugin instance.
3041
3151
  getInstance: (l) => {
3042
- const t = l.getAttribute("data-intl-tel-input-id");
3152
+ const t = l.dataset.intlTelInputId;
3043
3153
  return t ? d.instances[t] : null;
3044
3154
  },
3045
3155
  //* A map from instance ID to instance object.
3046
3156
  instances: {},
3047
- attachUtils: st,
3157
+ attachUtils: at,
3048
3158
  startedLoadingUtilsScript: !1,
3049
3159
  startedLoadingAutoCountry: !1,
3050
- version: "25.10.11"
3160
+ version: "25.11.0"
3051
3161
  }
3052
- ), at = {
3162
+ ), ut = {
3053
3163
  __name: "IntlTelInput",
3054
- props: /* @__PURE__ */ A({
3164
+ props: /* @__PURE__ */ P({
3055
3165
  disabled: {
3056
3166
  type: Boolean,
3057
3167
  default: !1
@@ -3075,47 +3185,47 @@ const st = (l) => {
3075
3185
  },
3076
3186
  modelModifiers: {}
3077
3187
  }),
3078
- emits: /* @__PURE__ */ A([
3188
+ emits: /* @__PURE__ */ P([
3079
3189
  "changeNumber",
3080
3190
  "changeCountry",
3081
3191
  "changeValidity",
3082
3192
  "changeErrorCode"
3083
3193
  ], ["update:modelValue"]),
3084
3194
  setup(l, { expose: t, emit: e }) {
3085
- const i = E(l, "modelValue"), n = l, s = e, o = N(), a = N(), u = N(!1), r = () => a.value ? n.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, h = () => {
3086
- let c = r();
3087
- u.value !== c && (u.value = c, s("changeValidity", !!c), s(
3195
+ const i = B(l, "modelValue"), s = l, o = e, n = L(), a = L(), r = L(!1), u = () => a.value ? s.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, c = () => {
3196
+ let h = u();
3197
+ r.value !== h && (r.value = h, o("changeValidity", !!h), o(
3088
3198
  "changeErrorCode",
3089
- c ? null : a.value.getValidationError()
3199
+ h ? null : a.value.getValidationError()
3090
3200
  ));
3091
- }, p = () => {
3092
- var c;
3093
- s("changeNumber", ((c = a.value) == null ? void 0 : c.getNumber()) ?? ""), h();
3094
- }, g = () => {
3095
- var c;
3096
- s("changeCountry", ((c = a.value) == null ? void 0 : c.getSelectedCountryData().iso2) ?? ""), p(), h();
3201
+ }, C = () => {
3202
+ var h;
3203
+ o("changeNumber", ((h = a.value) == null ? void 0 : h.getNumber()) ?? ""), c();
3204
+ }, m = () => {
3205
+ var h;
3206
+ o("changeCountry", ((h = a.value) == null ? void 0 : h.getSelectedCountryData().iso2) ?? ""), C(), c();
3097
3207
  };
3098
- return M(() => {
3099
- o.value && (a.value = d(o.value, n.options), n.value && a.value.setNumber(n.value), n.disabled && a.value.setDisabled(n.disabled), u.value = r());
3100
- }), B(
3101
- () => n.disabled,
3102
- (c) => {
3103
- var y;
3104
- return (y = a.value) == null ? void 0 : y.setDisabled(c);
3208
+ return F(() => {
3209
+ n.value && (a.value = d(n.value, s.options), s.value && a.value.setNumber(s.value), s.disabled && a.value.setDisabled(s.disabled), r.value = u());
3210
+ }), R(
3211
+ () => s.disabled,
3212
+ (h) => {
3213
+ var f;
3214
+ return (f = a.value) == null ? void 0 : f.setDisabled(h);
3105
3215
  }
3106
- ), R(() => {
3107
- var c;
3108
- return (c = a.value) == null ? void 0 : c.destroy();
3109
- }), t({ instance: a, input: o }), (c, y) => F((V(), z("input", $({
3216
+ ), z(() => {
3217
+ var h;
3218
+ return (h = a.value) == null ? void 0 : h.destroy();
3219
+ }), t({ instance: a, input: n }), (h, f) => V((U(), $("input", j({
3110
3220
  ref_key: "input",
3111
- ref: o,
3112
- "onUpdate:modelValue": y[0] || (y[0] = (C) => i.value = C),
3221
+ ref: n,
3222
+ "onUpdate:modelValue": f[0] || (f[0] = (b) => i.value = b),
3113
3223
  type: "tel",
3114
- onCountrychange: g,
3115
- onInput: p
3224
+ onCountrychange: m,
3225
+ onInput: C
3116
3226
  }, l.inputProps), null, 16)), [
3117
3227
  [
3118
- O,
3228
+ W,
3119
3229
  i.value,
3120
3230
  void 0,
3121
3231
  { lazy: !0 }
@@ -3124,5 +3234,5 @@ const st = (l) => {
3124
3234
  }
3125
3235
  };
3126
3236
  export {
3127
- at as default
3237
+ ut as default
3128
3238
  };