intl-tel-input 25.10.12 → 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.
@@ -2050,6 +2050,7 @@ var getNumeric = (s) => s.replace(/\D/g, "");
2050
2050
  var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
2051
2051
 
2052
2052
  // src/js/modules/utils/dom.ts
2053
+ var buildClassNames = (flags) => Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
2053
2054
  var createEl = (tagName, attrs, container) => {
2054
2055
  const el = document.createElement(tagName);
2055
2056
  if (attrs) {
@@ -2061,251 +2062,23 @@ var createEl = (tagName, attrs, container) => {
2061
2062
  return el;
2062
2063
  };
2063
2064
 
2064
- // src/js/modules/data/country-data.ts
2065
- function processAllCountries(options) {
2066
- const { onlyCountries, excludeCountries } = options;
2067
- if (onlyCountries.length) {
2068
- const lowerCaseOnlyCountries = onlyCountries.map((country) => country.toLowerCase());
2069
- return data_default.filter((country) => lowerCaseOnlyCountries.includes(country.iso2));
2070
- } else if (excludeCountries.length) {
2071
- const lowerCaseExcludeCountries = excludeCountries.map((country) => country.toLowerCase());
2072
- return data_default.filter((country) => !lowerCaseExcludeCountries.includes(country.iso2));
2073
- }
2074
- return data_default;
2075
- }
2076
- function translateCountryNames(countries, options) {
2077
- for (const c of countries) {
2078
- const iso2 = c.iso2.toLowerCase();
2079
- if (options.i18n[iso2]) {
2080
- c.name = options.i18n[iso2];
2081
- }
2082
- }
2083
- }
2084
- function processDialCodes(countries, options) {
2085
- const dialCodes = /* @__PURE__ */ new Set();
2086
- let dialCodeMaxLen = 0;
2087
- const dialCodeToIso2Map = {};
2088
- const _addToDialCodeMap = (iso2, dialCode, priority) => {
2089
- if (!iso2 || !dialCode) {
2090
- return;
2091
- }
2092
- if (dialCode.length > dialCodeMaxLen) {
2093
- dialCodeMaxLen = dialCode.length;
2094
- }
2095
- if (!dialCodeToIso2Map.hasOwnProperty(dialCode)) {
2096
- dialCodeToIso2Map[dialCode] = [];
2097
- }
2098
- const iso2List = dialCodeToIso2Map[dialCode];
2099
- if (iso2List.includes(iso2)) {
2100
- return;
2101
- }
2102
- const index = priority !== void 0 ? priority : iso2List.length;
2103
- iso2List[index] = iso2;
2104
- };
2105
- for (const c of countries) {
2106
- if (!dialCodes.has(c.dialCode)) {
2107
- dialCodes.add(c.dialCode);
2108
- }
2109
- for (let k = 1; k < c.dialCode.length; k++) {
2110
- const partialDialCode = c.dialCode.substring(0, k);
2111
- _addToDialCodeMap(c.iso2, partialDialCode);
2112
- }
2113
- _addToDialCodeMap(c.iso2, c.dialCode, c.priority);
2114
- }
2115
- if (options.onlyCountries.length || options.excludeCountries.length) {
2116
- dialCodes.forEach((dialCode) => {
2117
- dialCodeToIso2Map[dialCode] = dialCodeToIso2Map[dialCode].filter(Boolean);
2118
- });
2119
- }
2120
- for (const c of countries) {
2121
- if (c.areaCodes) {
2122
- const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
2123
- for (const areaCode of c.areaCodes) {
2124
- for (let k = 1; k < areaCode.length; k++) {
2125
- const partialAreaCode = areaCode.substring(0, k);
2126
- const partialDialCode = c.dialCode + partialAreaCode;
2127
- _addToDialCodeMap(rootIso2Code, partialDialCode);
2128
- _addToDialCodeMap(c.iso2, partialDialCode);
2129
- }
2130
- _addToDialCodeMap(c.iso2, c.dialCode + areaCode);
2131
- }
2132
- }
2133
- }
2134
- return { dialCodes, dialCodeMaxLen, dialCodeToIso2Map };
2135
- }
2136
- function sortCountries(countries, options) {
2137
- if (options.countryOrder) {
2138
- options.countryOrder = options.countryOrder.map((iso2) => iso2.toLowerCase());
2139
- }
2140
- countries.sort((a, b) => {
2141
- const { countryOrder } = options;
2142
- if (countryOrder) {
2143
- const aIndex = countryOrder.indexOf(a.iso2);
2144
- const bIndex = countryOrder.indexOf(b.iso2);
2145
- const aIndexExists = aIndex > -1;
2146
- const bIndexExists = bIndex > -1;
2147
- if (aIndexExists || bIndexExists) {
2148
- if (aIndexExists && bIndexExists) {
2149
- return aIndex - bIndex;
2150
- }
2151
- return aIndexExists ? -1 : 1;
2152
- }
2153
- }
2154
- return a.name.localeCompare(b.name);
2155
- });
2156
- }
2157
- function cacheSearchTokens(countries) {
2158
- for (const c of countries) {
2159
- c.normalisedName = normaliseString(c.name);
2160
- c.initials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2161
- c.dialCodePlus = `+${c.dialCode}`;
2162
- }
2163
- }
2164
-
2165
- // src/js/modules/format/formatting.ts
2166
- function beforeSetNumber(fullNumber, dialCode, separateDialCode, selectedCountryData) {
2167
- let number = fullNumber;
2168
- if (separateDialCode) {
2169
- if (dialCode) {
2170
- dialCode = `+${selectedCountryData.dialCode}`;
2171
- const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2172
- number = number.substring(start);
2173
- }
2174
- }
2175
- return number;
2176
- }
2177
- function formatNumberAsYouType(fullNumber, telInputValue, utils2, selectedCountryData, separateDialCode) {
2178
- const result = utils2 ? utils2.formatNumberAsYouType(fullNumber, selectedCountryData.iso2) : fullNumber;
2179
- const { dialCode } = selectedCountryData;
2180
- if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
2181
- const afterDialCode = result.split(`+${dialCode}`)[1] || "";
2182
- return afterDialCode.trim();
2183
- }
2184
- return result;
2185
- }
2186
-
2187
- // src/js/modules/format/caret.ts
2188
- function translateCursorPosition(relevantChars, formattedValue, prevCaretPos, isDeleteForwards) {
2189
- if (prevCaretPos === 0 && !isDeleteForwards) {
2190
- return 0;
2191
- }
2192
- let relevantCharCount = 0;
2193
- for (let i = 0; i < formattedValue.length; i++) {
2194
- if (/[+0-9]/.test(formattedValue[i])) {
2195
- relevantCharCount++;
2196
- }
2197
- if (relevantCharCount === relevantChars && !isDeleteForwards) {
2198
- return i + 1;
2199
- }
2200
- if (isDeleteForwards && relevantCharCount === relevantChars + 1) {
2201
- return i;
2202
- }
2203
- }
2204
- return formattedValue.length;
2205
- }
2206
-
2207
- // src/js/modules/data/nanp-regionless.ts
2208
- var regionlessNanpNumbers = [
2209
- "800",
2210
- "822",
2211
- "833",
2212
- "844",
2213
- "855",
2214
- "866",
2215
- "877",
2216
- "880",
2217
- "881",
2218
- "882",
2219
- "883",
2220
- "884",
2221
- "885",
2222
- "886",
2223
- "887",
2224
- "888",
2225
- "889"
2226
- ];
2227
- var isRegionlessNanp = (number) => {
2228
- const numeric = getNumeric(number);
2229
- if (numeric.charAt(0) === "1") {
2230
- const areaCode = numeric.substring(1, 4);
2231
- return regionlessNanpNumbers.includes(areaCode);
2232
- }
2233
- return false;
2234
- };
2235
-
2236
- // src/js/intl-tel-input.ts
2237
- for (const c of data_default) {
2238
- c.name = en_default[c.iso2];
2239
- }
2240
- var id = 0;
2241
- var iso2Set = new Set(data_default.map((c) => c.iso2));
2242
- var isIso2 = (val) => iso2Set.has(val);
2243
- var forEachInstance = (method, ...args) => {
2244
- const { instances } = intlTelInput;
2245
- Object.values(instances).forEach((instance) => instance[method](...args));
2246
- };
2247
- var Iti = class _Iti {
2248
- /**
2249
- * Build a space-delimited class string from an object map of className -> truthy/falsey.
2250
- * Only keys with truthy values are included.
2251
- */
2252
- static _buildClassNames(flags) {
2253
- return Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
2254
- }
2255
- constructor(input, customOptions = {}) {
2256
- this.id = id++;
2257
- this.telInput = input;
2065
+ // src/js/modules/core/ui.ts
2066
+ var UI = class {
2067
+ constructor(input, options, id2) {
2258
2068
  this.highlightedItem = null;
2259
- this.options = Object.assign({}, defaults, customOptions);
2069
+ input.dataset.intlTelInputId = id2.toString();
2070
+ this.telInput = input;
2071
+ this.options = options;
2072
+ this.id = id2;
2260
2073
  this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
2261
- }
2262
- _detectEnvironmentAndLayout() {
2263
- this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
2264
2074
  this.isRTL = !!this.telInput.closest("[dir=rtl]");
2265
2075
  if (this.options.separateDialCode) {
2266
2076
  this.originalPaddingLeft = this.telInput.style.paddingLeft;
2267
2077
  }
2268
2078
  }
2269
- _createInitPromises() {
2270
- const autoCountryPromise = new Promise((resolve, reject) => {
2271
- this.resolveAutoCountryPromise = resolve;
2272
- this.rejectAutoCountryPromise = reject;
2273
- });
2274
- const utilsScriptPromise = new Promise((resolve, reject) => {
2275
- this.resolveUtilsScriptPromise = resolve;
2276
- this.rejectUtilsScriptPromise = reject;
2277
- });
2278
- this.promise = Promise.all([autoCountryPromise, utilsScriptPromise]);
2279
- }
2280
- //* Can't be private as it's called from intlTelInput convenience wrapper.
2281
- _init() {
2282
- applyOptionSideEffects(this.options);
2283
- this._detectEnvironmentAndLayout();
2284
- this._createInitPromises();
2285
- this.selectedCountryData = {};
2286
- this._processCountryData();
2287
- this._generateMarkup();
2288
- this._setInitialState();
2289
- this._initListeners();
2290
- this._initRequests();
2291
- }
2292
- //********************
2293
- //* PRIVATE METHODS
2294
- //********************
2295
- //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
2296
- _processCountryData() {
2297
- this.countries = processAllCountries(this.options);
2298
- const dialRes = processDialCodes(this.countries, this.options);
2299
- this.dialCodes = dialRes.dialCodes;
2300
- this.dialCodeMaxLen = dialRes.dialCodeMaxLen;
2301
- this.dialCodeToIso2Map = dialRes.dialCodeToIso2Map;
2302
- translateCountryNames(this.countries, this.options);
2303
- sortCountries(this.countries, this.options);
2304
- this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
2305
- cacheSearchTokens(this.countries);
2306
- }
2307
2079
  //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
2308
- _generateMarkup() {
2080
+ generateMarkup(countries) {
2081
+ this.countries = countries;
2309
2082
  this._prepareTelInput();
2310
2083
  const wrapper = this._createWrapperAndInsert();
2311
2084
  this._maybeBuildCountryContainer(wrapper);
@@ -2315,7 +2088,7 @@ var Iti = class _Iti {
2315
2088
  }
2316
2089
  _prepareTelInput() {
2317
2090
  this.telInput.classList.add("iti__tel-input");
2318
- if (!this.telInput.hasAttribute("autocomplete") && !(this.telInput.form && this.telInput.form.hasAttribute("autocomplete"))) {
2091
+ if (!this.telInput.hasAttribute("autocomplete") && !this.telInput.form?.hasAttribute("autocomplete")) {
2319
2092
  this.telInput.setAttribute("autocomplete", "off");
2320
2093
  }
2321
2094
  }
@@ -2326,8 +2099,8 @@ var Iti = class _Iti {
2326
2099
  containerClass,
2327
2100
  useFullscreenPopup
2328
2101
  } = this.options;
2329
- const parentClasses = _Iti._buildClassNames({
2330
- "iti": true,
2102
+ const parentClasses = buildClassNames({
2103
+ iti: true,
2331
2104
  "iti--allow-dropdown": allowDropdown,
2332
2105
  "iti--show-flags": showFlags,
2333
2106
  "iti--inline-dropdown": !useFullscreenPopup,
@@ -2337,15 +2110,11 @@ var Iti = class _Iti {
2337
2110
  if (this.isRTL) {
2338
2111
  wrapper.setAttribute("dir", "ltr");
2339
2112
  }
2340
- this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
2113
+ this.telInput.before(wrapper);
2341
2114
  return wrapper;
2342
2115
  }
2343
2116
  _maybeBuildCountryContainer(wrapper) {
2344
- const {
2345
- allowDropdown,
2346
- separateDialCode,
2347
- showFlags
2348
- } = this.options;
2117
+ const { allowDropdown, separateDialCode, showFlags } = this.options;
2349
2118
  if (allowDropdown || showFlags || separateDialCode) {
2350
2119
  this.countryContainer = createEl(
2351
2120
  "div",
@@ -2438,12 +2207,12 @@ var Iti = class _Iti {
2438
2207
  this.dropdownContent
2439
2208
  );
2440
2209
  this._appendListItems();
2441
- if (countrySearch) {
2442
- this._updateSearchResultsA11yText();
2210
+ if (this.options.countrySearch) {
2211
+ this.updateSearchResultsA11yText();
2443
2212
  }
2444
2213
  if (dropdownContainer) {
2445
- const dropdownClasses = _Iti._buildClassNames({
2446
- "iti": true,
2214
+ const dropdownClasses = buildClassNames({
2215
+ iti: true,
2447
2216
  "iti--container": true,
2448
2217
  "iti--fullscreen-popup": useFullscreenPopup,
2449
2218
  "iti--inline-dropdown": !useFullscreenPopup,
@@ -2489,7 +2258,7 @@ var Iti = class _Iti {
2489
2258
  "aria-label": i18n.searchPlaceholder,
2490
2259
  "aria-controls": `iti-${this.id}__country-listbox`,
2491
2260
  "aria-autocomplete": "list",
2492
- "autocomplete": "off"
2261
+ autocomplete: "off"
2493
2262
  },
2494
2263
  searchWrapper
2495
2264
  );
@@ -2526,80 +2295,478 @@ var Iti = class _Iti {
2526
2295
  },
2527
2296
  this.dropdownContent
2528
2297
  );
2529
- this.searchNoResults.textContent = i18n.zeroSearchResults;
2298
+ this.searchNoResults.textContent = i18n.zeroSearchResults;
2299
+ }
2300
+ _maybeUpdateInputPaddingAndReveal() {
2301
+ if (this.countryContainer) {
2302
+ this.updateInputPadding();
2303
+ this.countryContainer.classList.remove("iti__v-hide");
2304
+ }
2305
+ }
2306
+ _maybeBuildHiddenInputs(wrapper) {
2307
+ const { hiddenInput } = this.options;
2308
+ if (hiddenInput) {
2309
+ const telInputName = this.telInput.getAttribute("name") || "";
2310
+ const names = hiddenInput(telInputName);
2311
+ if (names.phone) {
2312
+ const existingInput = this.telInput.form?.querySelector(
2313
+ `input[name="${names.phone}"]`
2314
+ );
2315
+ if (existingInput) {
2316
+ this.hiddenInput = existingInput;
2317
+ } else {
2318
+ this.hiddenInput = createEl("input", {
2319
+ type: "hidden",
2320
+ name: names.phone
2321
+ });
2322
+ wrapper.appendChild(this.hiddenInput);
2323
+ }
2324
+ }
2325
+ if (names.country) {
2326
+ const existingInput = this.telInput.form?.querySelector(
2327
+ `input[name="${names.country}"]`
2328
+ );
2329
+ if (existingInput) {
2330
+ this.hiddenInputCountry = existingInput;
2331
+ } else {
2332
+ this.hiddenInputCountry = createEl("input", {
2333
+ type: "hidden",
2334
+ name: names.country
2335
+ });
2336
+ wrapper.appendChild(this.hiddenInputCountry);
2337
+ }
2338
+ }
2339
+ }
2340
+ }
2341
+ //* For each country: add a country list item <li> to the countryList <ul> container.
2342
+ _appendListItems() {
2343
+ const frag = document.createDocumentFragment();
2344
+ for (let i = 0; i < this.countries.length; i++) {
2345
+ const c = this.countries[i];
2346
+ const liClass = buildClassNames({
2347
+ iti__country: true,
2348
+ iti__highlight: i === 0
2349
+ });
2350
+ const listItem = createEl("li", {
2351
+ id: `iti-${this.id}__item-${c.iso2}`,
2352
+ class: liClass,
2353
+ tabindex: "-1",
2354
+ role: "option",
2355
+ "aria-selected": "false"
2356
+ });
2357
+ listItem.dataset.dialCode = c.dialCode;
2358
+ listItem.dataset.countryCode = c.iso2;
2359
+ c.nodeById[this.id] = listItem;
2360
+ if (this.options.showFlags) {
2361
+ createEl("div", { class: `iti__flag iti__${c.iso2}` }, listItem);
2362
+ }
2363
+ const nameEl = createEl("span", { class: "iti__country-name" }, listItem);
2364
+ nameEl.textContent = c.name;
2365
+ const dialEl = createEl("span", { class: "iti__dial-code" }, listItem);
2366
+ if (this.isRTL) {
2367
+ dialEl.setAttribute("dir", "ltr");
2368
+ }
2369
+ dialEl.textContent = `+${c.dialCode}`;
2370
+ frag.appendChild(listItem);
2371
+ }
2372
+ this.countryList.appendChild(frag);
2373
+ }
2374
+ //* Update the input padding to make space for the selected country/dial code.
2375
+ updateInputPadding() {
2376
+ if (this.selectedCountry) {
2377
+ const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
2378
+ const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
2379
+ const inputPadding = selectedCountryWidth + 6;
2380
+ this.telInput.style.paddingLeft = `${inputPadding}px`;
2381
+ }
2382
+ }
2383
+ //* When input is in a hidden container during init, we cannot calculate the selected country width.
2384
+ //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
2385
+ //* To get the right styling to apply, all we need is a shallow clone of the container,
2386
+ //* and then to inject a deep clone of the selectedCountry element.
2387
+ _getHiddenSelectedCountryWidth() {
2388
+ if (this.telInput.parentNode) {
2389
+ let body;
2390
+ try {
2391
+ body = window.top.document.body;
2392
+ } catch (e) {
2393
+ body = document.body;
2394
+ }
2395
+ const containerClone = this.telInput.parentNode.cloneNode(
2396
+ false
2397
+ );
2398
+ containerClone.style.visibility = "hidden";
2399
+ body.appendChild(containerClone);
2400
+ const countryContainerClone = this.countryContainer.cloneNode();
2401
+ containerClone.appendChild(countryContainerClone);
2402
+ const selectedCountryClone = this.selectedCountry.cloneNode(
2403
+ true
2404
+ );
2405
+ countryContainerClone.appendChild(selectedCountryClone);
2406
+ const width = selectedCountryClone.offsetWidth;
2407
+ body.removeChild(containerClone);
2408
+ return width;
2409
+ }
2410
+ return 0;
2411
+ }
2412
+ //* Update search results text (for a11y).
2413
+ updateSearchResultsA11yText() {
2414
+ const { i18n } = this.options;
2415
+ const count = this.countryList.childElementCount;
2416
+ let searchText;
2417
+ if (count === 0) {
2418
+ searchText = i18n.zeroSearchResults;
2419
+ } else {
2420
+ if (i18n.searchResultsText) {
2421
+ searchText = i18n.searchResultsText(count);
2422
+ } else if (count === 1) {
2423
+ searchText = i18n.oneSearchResult;
2424
+ } else {
2425
+ searchText = i18n.multipleSearchResults.replace(
2426
+ "${count}",
2427
+ count.toString()
2428
+ );
2429
+ }
2430
+ }
2431
+ this.searchResultsA11yText.textContent = searchText;
2432
+ }
2433
+ //* Check if an element is visible within it's container, else scroll until it is.
2434
+ scrollTo(element) {
2435
+ const container = this.countryList;
2436
+ const scrollTop = document.documentElement.scrollTop;
2437
+ const containerHeight = container.offsetHeight;
2438
+ const containerTop = container.getBoundingClientRect().top + scrollTop;
2439
+ const containerBottom = containerTop + containerHeight;
2440
+ const elementHeight = element.offsetHeight;
2441
+ const elementTop = element.getBoundingClientRect().top + scrollTop;
2442
+ const elementBottom = elementTop + elementHeight;
2443
+ const newScrollTop = elementTop - containerTop + container.scrollTop;
2444
+ if (elementTop < containerTop) {
2445
+ container.scrollTop = newScrollTop;
2446
+ } else if (elementBottom > containerBottom) {
2447
+ const heightDifference = containerHeight - elementHeight;
2448
+ container.scrollTop = newScrollTop - heightDifference;
2449
+ }
2450
+ }
2451
+ //* Remove highlighting from other list items and highlight the given item.
2452
+ highlightListItem(listItem, shouldFocus) {
2453
+ const prevItem = this.highlightedItem;
2454
+ if (prevItem) {
2455
+ prevItem.classList.remove("iti__highlight");
2456
+ prevItem.setAttribute("aria-selected", "false");
2457
+ }
2458
+ this.highlightedItem = listItem;
2459
+ if (this.highlightedItem) {
2460
+ this.highlightedItem.classList.add("iti__highlight");
2461
+ this.highlightedItem.setAttribute("aria-selected", "true");
2462
+ if (this.options.countrySearch) {
2463
+ const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2464
+ this.searchInput.setAttribute(
2465
+ "aria-activedescendant",
2466
+ activeDescendant
2467
+ );
2468
+ }
2469
+ }
2470
+ if (shouldFocus) {
2471
+ this.highlightedItem.focus();
2472
+ }
2473
+ }
2474
+ //* Country search: Filter the country list to the given array of countries.
2475
+ filterCountries(matchedCountries) {
2476
+ this.countryList.innerHTML = "";
2477
+ let noCountriesAddedYet = true;
2478
+ for (const c of matchedCountries) {
2479
+ const listItem = c.nodeById[this.id];
2480
+ if (listItem) {
2481
+ this.countryList.appendChild(listItem);
2482
+ if (noCountriesAddedYet) {
2483
+ this.highlightListItem(listItem, false);
2484
+ noCountriesAddedYet = false;
2485
+ }
2486
+ }
2487
+ }
2488
+ if (noCountriesAddedYet) {
2489
+ this.highlightListItem(null, false);
2490
+ if (this.searchNoResults) {
2491
+ this.searchNoResults.classList.remove("iti__hide");
2492
+ }
2493
+ } else if (this.searchNoResults) {
2494
+ this.searchNoResults.classList.add("iti__hide");
2495
+ }
2496
+ this.countryList.scrollTop = 0;
2497
+ this.updateSearchResultsA11yText();
2498
+ }
2499
+ destroy() {
2500
+ this.telInput.iti = void 0;
2501
+ delete this.telInput.dataset.intlTelInputId;
2502
+ if (this.options.separateDialCode) {
2503
+ this.telInput.style.paddingLeft = this.originalPaddingLeft;
2504
+ }
2505
+ const wrapper = this.telInput.parentNode;
2506
+ wrapper.before(this.telInput);
2507
+ wrapper.remove();
2508
+ this.telInput = null;
2509
+ this.countryContainer = null;
2510
+ this.selectedCountry = null;
2511
+ this.selectedCountryInner = null;
2512
+ this.selectedDialCode = null;
2513
+ this.dropdownArrow = null;
2514
+ this.dropdownContent = null;
2515
+ this.searchInput = null;
2516
+ this.searchIcon = null;
2517
+ this.searchClearButton = null;
2518
+ this.searchNoResults = null;
2519
+ this.searchResultsA11yText = null;
2520
+ this.countryList = null;
2521
+ this.dropdown = null;
2522
+ this.hiddenInput = null;
2523
+ this.hiddenInputCountry = null;
2524
+ this.highlightedItem = null;
2525
+ for (const c of this.countries) {
2526
+ delete c.nodeById[this.id];
2527
+ }
2528
+ this.countries = null;
2529
+ }
2530
+ };
2531
+
2532
+ // src/js/modules/data/country-data.ts
2533
+ function processAllCountries(options) {
2534
+ const { onlyCountries, excludeCountries } = options;
2535
+ if (onlyCountries.length) {
2536
+ const lowerCaseOnlyCountries = onlyCountries.map((country) => country.toLowerCase());
2537
+ return data_default.filter((country) => lowerCaseOnlyCountries.includes(country.iso2));
2538
+ } else if (excludeCountries.length) {
2539
+ const lowerCaseExcludeCountries = excludeCountries.map((country) => country.toLowerCase());
2540
+ return data_default.filter((country) => !lowerCaseExcludeCountries.includes(country.iso2));
2541
+ }
2542
+ return data_default;
2543
+ }
2544
+ function translateCountryNames(countries, options) {
2545
+ for (const c of countries) {
2546
+ const iso2 = c.iso2.toLowerCase();
2547
+ if (options.i18n[iso2]) {
2548
+ c.name = options.i18n[iso2];
2549
+ }
2550
+ }
2551
+ }
2552
+ function processDialCodes(countries, options) {
2553
+ const dialCodes = /* @__PURE__ */ new Set();
2554
+ let dialCodeMaxLen = 0;
2555
+ const dialCodeToIso2Map = {};
2556
+ const _addToDialCodeMap = (iso2, dialCode, priority) => {
2557
+ if (!iso2 || !dialCode) {
2558
+ return;
2559
+ }
2560
+ if (dialCode.length > dialCodeMaxLen) {
2561
+ dialCodeMaxLen = dialCode.length;
2562
+ }
2563
+ if (!dialCodeToIso2Map.hasOwnProperty(dialCode)) {
2564
+ dialCodeToIso2Map[dialCode] = [];
2565
+ }
2566
+ const iso2List = dialCodeToIso2Map[dialCode];
2567
+ if (iso2List.includes(iso2)) {
2568
+ return;
2569
+ }
2570
+ const index = priority !== void 0 ? priority : iso2List.length;
2571
+ iso2List[index] = iso2;
2572
+ };
2573
+ for (const c of countries) {
2574
+ if (!dialCodes.has(c.dialCode)) {
2575
+ dialCodes.add(c.dialCode);
2576
+ }
2577
+ for (let k = 1; k < c.dialCode.length; k++) {
2578
+ const partialDialCode = c.dialCode.substring(0, k);
2579
+ _addToDialCodeMap(c.iso2, partialDialCode);
2580
+ }
2581
+ _addToDialCodeMap(c.iso2, c.dialCode, c.priority);
2582
+ }
2583
+ if (options.onlyCountries.length || options.excludeCountries.length) {
2584
+ dialCodes.forEach((dialCode) => {
2585
+ dialCodeToIso2Map[dialCode] = dialCodeToIso2Map[dialCode].filter(Boolean);
2586
+ });
2587
+ }
2588
+ for (const c of countries) {
2589
+ if (c.areaCodes) {
2590
+ const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
2591
+ for (const areaCode of c.areaCodes) {
2592
+ for (let k = 1; k < areaCode.length; k++) {
2593
+ const partialAreaCode = areaCode.substring(0, k);
2594
+ const partialDialCode = c.dialCode + partialAreaCode;
2595
+ _addToDialCodeMap(rootIso2Code, partialDialCode);
2596
+ _addToDialCodeMap(c.iso2, partialDialCode);
2597
+ }
2598
+ _addToDialCodeMap(c.iso2, c.dialCode + areaCode);
2599
+ }
2600
+ }
2601
+ }
2602
+ return { dialCodes, dialCodeMaxLen, dialCodeToIso2Map };
2603
+ }
2604
+ function sortCountries(countries, options) {
2605
+ if (options.countryOrder) {
2606
+ options.countryOrder = options.countryOrder.map((iso2) => iso2.toLowerCase());
2607
+ }
2608
+ countries.sort((a, b) => {
2609
+ const { countryOrder } = options;
2610
+ if (countryOrder) {
2611
+ const aIndex = countryOrder.indexOf(a.iso2);
2612
+ const bIndex = countryOrder.indexOf(b.iso2);
2613
+ const aIndexExists = aIndex > -1;
2614
+ const bIndexExists = bIndex > -1;
2615
+ if (aIndexExists || bIndexExists) {
2616
+ if (aIndexExists && bIndexExists) {
2617
+ return aIndex - bIndex;
2618
+ }
2619
+ return aIndexExists ? -1 : 1;
2620
+ }
2621
+ }
2622
+ return a.name.localeCompare(b.name);
2623
+ });
2624
+ }
2625
+ function cacheSearchTokens(countries) {
2626
+ for (const c of countries) {
2627
+ c.normalisedName = normaliseString(c.name);
2628
+ c.initials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2629
+ c.dialCodePlus = `+${c.dialCode}`;
2630
+ }
2631
+ }
2632
+
2633
+ // src/js/modules/format/formatting.ts
2634
+ function beforeSetNumber(fullNumber, dialCode, separateDialCode, selectedCountryData) {
2635
+ let number = fullNumber;
2636
+ if (separateDialCode) {
2637
+ if (dialCode) {
2638
+ dialCode = `+${selectedCountryData.dialCode}`;
2639
+ const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
2640
+ number = number.substring(start);
2641
+ }
2642
+ }
2643
+ return number;
2644
+ }
2645
+ function formatNumberAsYouType(fullNumber, telInputValue, utils2, selectedCountryData, separateDialCode) {
2646
+ const result = utils2 ? utils2.formatNumberAsYouType(fullNumber, selectedCountryData.iso2) : fullNumber;
2647
+ const { dialCode } = selectedCountryData;
2648
+ if (separateDialCode && telInputValue.charAt(0) !== "+" && result.includes(`+${dialCode}`)) {
2649
+ const afterDialCode = result.split(`+${dialCode}`)[1] || "";
2650
+ return afterDialCode.trim();
2651
+ }
2652
+ return result;
2653
+ }
2654
+
2655
+ // src/js/modules/format/caret.ts
2656
+ function translateCursorPosition(relevantChars, formattedValue, prevCaretPos, isDeleteForwards) {
2657
+ if (prevCaretPos === 0 && !isDeleteForwards) {
2658
+ return 0;
2659
+ }
2660
+ let relevantCharCount = 0;
2661
+ for (let i = 0; i < formattedValue.length; i++) {
2662
+ if (/[+0-9]/.test(formattedValue[i])) {
2663
+ relevantCharCount++;
2664
+ }
2665
+ if (relevantCharCount === relevantChars && !isDeleteForwards) {
2666
+ return i + 1;
2667
+ }
2668
+ if (isDeleteForwards && relevantCharCount === relevantChars + 1) {
2669
+ return i;
2670
+ }
2671
+ }
2672
+ return formattedValue.length;
2673
+ }
2674
+
2675
+ // src/js/modules/data/nanp-regionless.ts
2676
+ var regionlessNanpNumbers = [
2677
+ "800",
2678
+ "822",
2679
+ "833",
2680
+ "844",
2681
+ "855",
2682
+ "866",
2683
+ "877",
2684
+ "880",
2685
+ "881",
2686
+ "882",
2687
+ "883",
2688
+ "884",
2689
+ "885",
2690
+ "886",
2691
+ "887",
2692
+ "888",
2693
+ "889"
2694
+ ];
2695
+ var isRegionlessNanp = (number) => {
2696
+ const numeric = getNumeric(number);
2697
+ if (numeric.charAt(0) === "1") {
2698
+ const areaCode = numeric.substring(1, 4);
2699
+ return regionlessNanpNumbers.includes(areaCode);
2700
+ }
2701
+ return false;
2702
+ };
2703
+
2704
+ // src/js/intl-tel-input.ts
2705
+ for (const c of data_default) {
2706
+ c.name = countries_default[c.iso2];
2707
+ }
2708
+ var id = 0;
2709
+ var iso2Set = new Set(data_default.map((c) => c.iso2));
2710
+ var isIso2 = (val) => iso2Set.has(val);
2711
+ var Iti = class _Iti {
2712
+ constructor(input, customOptions = {}) {
2713
+ this.id = id++;
2714
+ this.options = { ...defaults, ...customOptions };
2715
+ applyOptionSideEffects(this.options);
2716
+ this.ui = new UI(input, this.options, this.id);
2717
+ this.isAndroid = _Iti._getIsAndroid();
2718
+ this.promise = this._createInitPromises();
2719
+ this.countries = processAllCountries(this.options);
2720
+ const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(
2721
+ this.countries,
2722
+ this.options
2723
+ );
2724
+ this.dialCodes = dialCodes;
2725
+ this.dialCodeMaxLen = dialCodeMaxLen;
2726
+ this.dialCodeToIso2Map = dialCodeToIso2Map;
2727
+ this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
2728
+ this._init();
2530
2729
  }
2531
- _maybeUpdateInputPaddingAndReveal() {
2532
- if (this.countryContainer) {
2533
- this._updateInputPadding();
2534
- this.countryContainer.classList.remove("iti__v-hide");
2535
- }
2730
+ static _getIsAndroid() {
2731
+ return typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
2536
2732
  }
2537
- _maybeBuildHiddenInputs(wrapper) {
2538
- const { hiddenInput } = this.options;
2539
- if (hiddenInput) {
2540
- const telInputName = this.telInput.getAttribute("name") || "";
2541
- const names = hiddenInput(telInputName);
2542
- if (names.phone) {
2543
- const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`);
2544
- if (existingInput) {
2545
- this.hiddenInput = existingInput;
2546
- } else {
2547
- this.hiddenInput = createEl("input", {
2548
- type: "hidden",
2549
- name: names.phone
2550
- });
2551
- wrapper.appendChild(this.hiddenInput);
2552
- }
2553
- }
2554
- if (names.country) {
2555
- const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
2556
- if (existingInput) {
2557
- this.hiddenInputCountry = existingInput;
2558
- } else {
2559
- this.hiddenInputCountry = createEl("input", {
2560
- type: "hidden",
2561
- name: names.country
2562
- });
2563
- wrapper.appendChild(this.hiddenInputCountry);
2564
- }
2565
- }
2566
- }
2733
+ _createInitPromises() {
2734
+ const autoCountryPromise = new Promise((resolve, reject) => {
2735
+ this.resolveAutoCountryPromise = resolve;
2736
+ this.rejectAutoCountryPromise = reject;
2737
+ });
2738
+ const utilsScriptPromise = new Promise((resolve, reject) => {
2739
+ this.resolveUtilsScriptPromise = resolve;
2740
+ this.rejectUtilsScriptPromise = reject;
2741
+ });
2742
+ return Promise.all([autoCountryPromise, utilsScriptPromise]);
2567
2743
  }
2568
- //* For each country: add a country list item <li> to the countryList <ul> container.
2569
- _appendListItems() {
2570
- for (let i = 0; i < this.countries.length; i++) {
2571
- const c = this.countries[i];
2572
- const extraClass = i === 0 ? "iti__highlight" : "";
2573
- const listItem = createEl(
2574
- "li",
2575
- {
2576
- id: `iti-${this.id}__item-${c.iso2}`,
2577
- class: `iti__country ${extraClass}`,
2578
- tabindex: "-1",
2579
- role: "option",
2580
- "data-dial-code": c.dialCode,
2581
- "data-country-code": c.iso2,
2582
- "aria-selected": "false"
2583
- },
2584
- this.countryList
2585
- );
2586
- c.nodeById[this.id] = listItem;
2587
- let content = "";
2588
- if (this.options.showFlags) {
2589
- content += `<div class='iti__flag iti__${c.iso2}'></div>`;
2590
- }
2591
- content += `<span class='iti__country-name'>${c.name}</span>`;
2592
- content += `<span class='iti__dial-code' dir='ltr'>+${c.dialCode}</span>`;
2593
- listItem.insertAdjacentHTML("beforeend", content);
2594
- }
2744
+ //* Can't be private as it's called from intlTelInput convenience wrapper.
2745
+ _init() {
2746
+ this.selectedCountryData = {};
2747
+ this.abortController = new AbortController();
2748
+ this._processCountryData();
2749
+ this.ui.generateMarkup(this.countries);
2750
+ this._setInitialState();
2751
+ this._initListeners();
2752
+ this._initRequests();
2753
+ }
2754
+ //********************
2755
+ //* PRIVATE METHODS
2756
+ //********************
2757
+ //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
2758
+ _processCountryData() {
2759
+ translateCountryNames(this.countries, this.options);
2760
+ sortCountries(this.countries, this.options);
2761
+ cacheSearchTokens(this.countries);
2595
2762
  }
2596
2763
  //* Set the initial state of the input value and the selected country by:
2597
2764
  //* 1. Extracting a dial code from the given number
2598
2765
  //* 2. Using explicit initialCountry
2599
2766
  _setInitialState(overrideAutoCountry = false) {
2600
- const attributeValue = this.telInput.getAttribute("value");
2601
- const inputValue = this.telInput.value;
2602
- const useAttribute = attributeValue && attributeValue.charAt(0) === "+" && (!inputValue || inputValue.charAt(0) !== "+");
2767
+ const attributeValue = this.ui.telInput.getAttribute("value");
2768
+ const inputValue = this.ui.telInput.value;
2769
+ const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
2603
2770
  const val = useAttribute ? attributeValue : inputValue;
2604
2771
  const dialCode = this._getDialCode(val);
2605
2772
  const isRegionlessNanpNumber = isRegionlessNanp(val);
@@ -2629,47 +2796,49 @@ var Iti = class _Iti {
2629
2796
  if (this.options.allowDropdown) {
2630
2797
  this._initDropdownListeners();
2631
2798
  }
2632
- if ((this.hiddenInput || this.hiddenInputCountry) && this.telInput.form) {
2799
+ if ((this.ui.hiddenInput || this.ui.hiddenInputCountry) && this.ui.telInput.form) {
2633
2800
  this._initHiddenInputListener();
2634
2801
  }
2635
2802
  }
2636
2803
  //* Update hidden input on form submit.
2637
2804
  _initHiddenInputListener() {
2638
- this._handleHiddenInputSubmit = () => {
2639
- if (this.hiddenInput) {
2640
- this.hiddenInput.value = this.getNumber();
2805
+ const handleHiddenInputSubmit = () => {
2806
+ if (this.ui.hiddenInput) {
2807
+ this.ui.hiddenInput.value = this.getNumber();
2641
2808
  }
2642
- if (this.hiddenInputCountry) {
2643
- this.hiddenInputCountry.value = this.getSelectedCountryData().iso2 || "";
2809
+ if (this.ui.hiddenInputCountry) {
2810
+ this.ui.hiddenInputCountry.value = this.selectedCountryData.iso2 || "";
2644
2811
  }
2645
2812
  };
2646
- this.telInput.form?.addEventListener(
2647
- "submit",
2648
- this._handleHiddenInputSubmit
2649
- );
2813
+ this.ui.telInput.form?.addEventListener("submit", handleHiddenInputSubmit, {
2814
+ signal: this.abortController.signal
2815
+ });
2650
2816
  }
2651
2817
  //* initialise the dropdown listeners.
2652
2818
  _initDropdownListeners() {
2653
- this._handleLabelClick = (e) => {
2654
- if (this.dropdownContent.classList.contains("iti__hide")) {
2655
- this.telInput.focus();
2819
+ const signal = this.abortController.signal;
2820
+ const handleLabelClick = (e) => {
2821
+ if (this.ui.dropdownContent.classList.contains("iti__hide")) {
2822
+ this.ui.telInput.focus();
2656
2823
  } else {
2657
2824
  e.preventDefault();
2658
2825
  }
2659
2826
  };
2660
- const label = this.telInput.closest("label");
2827
+ const label = this.ui.telInput.closest("label");
2661
2828
  if (label) {
2662
- label.addEventListener("click", this._handleLabelClick);
2829
+ label.addEventListener("click", handleLabelClick, { signal });
2663
2830
  }
2664
- this._handleClickSelectedCountry = () => {
2665
- const dropdownClosed = this.dropdownContent.classList.contains("iti__hide");
2666
- if (dropdownClosed && !this.telInput.disabled && !this.telInput.readOnly) {
2831
+ const handleClickSelectedCountry = () => {
2832
+ const dropdownClosed = this.ui.dropdownContent.classList.contains("iti__hide");
2833
+ if (dropdownClosed && !this.ui.telInput.disabled && !this.ui.telInput.readOnly) {
2667
2834
  this._openDropdown();
2668
2835
  }
2669
2836
  };
2670
- this.selectedCountry.addEventListener("click", this._handleClickSelectedCountry);
2671
- this._handleCountryContainerKeydown = (e) => {
2672
- const isDropdownHidden = this.dropdownContent.classList.contains("iti__hide");
2837
+ this.ui.selectedCountry.addEventListener("click", handleClickSelectedCountry, {
2838
+ signal
2839
+ });
2840
+ const handleCountryContainerKeydown = (e) => {
2841
+ const isDropdownHidden = this.ui.dropdownContent.classList.contains("iti__hide");
2673
2842
  if (isDropdownHidden && ["ArrowUp", "ArrowDown", " ", "Enter"].includes(e.key)) {
2674
2843
  e.preventDefault();
2675
2844
  e.stopPropagation();
@@ -2679,26 +2848,29 @@ var Iti = class _Iti {
2679
2848
  this._closeDropdown();
2680
2849
  }
2681
2850
  };
2682
- this.countryContainer.addEventListener(
2851
+ this.ui.countryContainer.addEventListener(
2683
2852
  "keydown",
2684
- this._handleCountryContainerKeydown
2853
+ handleCountryContainerKeydown,
2854
+ { signal }
2685
2855
  );
2686
2856
  }
2687
2857
  //* Init many requests: utils script / geo ip lookup.
2688
2858
  _initRequests() {
2689
- let { loadUtils, initialCountry, geoIpLookup } = this.options;
2859
+ const { loadUtils, initialCountry, geoIpLookup } = this.options;
2690
2860
  if (loadUtils && !intlTelInput.utils) {
2691
- this._doAttachUtils = () => {
2861
+ const doAttachUtils = () => {
2692
2862
  intlTelInput.attachUtils(loadUtils)?.catch(() => {
2693
2863
  });
2694
2864
  };
2695
2865
  if (intlTelInput.documentReady()) {
2696
- this._doAttachUtils();
2866
+ doAttachUtils();
2697
2867
  } else {
2698
- this._handlePageLoad = () => {
2699
- this._doAttachUtils();
2868
+ const handlePageLoad = () => {
2869
+ doAttachUtils();
2700
2870
  };
2701
- window.addEventListener("load", this._handlePageLoad);
2871
+ window.addEventListener("load", handlePageLoad, {
2872
+ signal: this.abortController.signal
2873
+ });
2702
2874
  }
2703
2875
  } else {
2704
2876
  this.resolveUtilsScriptPromise();
@@ -2738,8 +2910,8 @@ var Iti = class _Iti {
2738
2910
  }
2739
2911
  _openDropdownWithPlus() {
2740
2912
  this._openDropdown();
2741
- this.searchInput.value = "+";
2742
- this._filterCountries("");
2913
+ this.ui.searchInput.value = "+";
2914
+ this._filterCountriesByQuery("");
2743
2915
  }
2744
2916
  //* Initialize the tel input listeners.
2745
2917
  _initTelInputListeners() {
@@ -2748,55 +2920,77 @@ var Iti = class _Iti {
2748
2920
  this._maybeBindPasteListener();
2749
2921
  }
2750
2922
  _bindInputListener() {
2751
- const { strictMode, formatAsYouType, separateDialCode, allowDropdown, countrySearch } = this.options;
2923
+ const {
2924
+ strictMode,
2925
+ formatAsYouType,
2926
+ separateDialCode,
2927
+ allowDropdown,
2928
+ countrySearch
2929
+ } = this.options;
2752
2930
  let userOverrideFormatting = false;
2753
- if (/\p{L}/u.test(this.telInput.value)) {
2931
+ if (/\p{L}/u.test(this.ui.telInput.value)) {
2754
2932
  userOverrideFormatting = true;
2755
2933
  }
2756
- this._handleInputEvent = (e) => {
2934
+ const handleInputEvent = (e) => {
2757
2935
  if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
2758
- const currentCaretPos = this.telInput.selectionStart || 0;
2759
- const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1);
2760
- const valueAfterCaret = this.telInput.value.substring(currentCaretPos);
2761
- this.telInput.value = valueBeforeCaret + valueAfterCaret;
2936
+ const currentCaretPos = this.ui.telInput.selectionStart || 0;
2937
+ const valueBeforeCaret = this.ui.telInput.value.substring(
2938
+ 0,
2939
+ currentCaretPos - 1
2940
+ );
2941
+ const valueAfterCaret = this.ui.telInput.value.substring(currentCaretPos);
2942
+ this.ui.telInput.value = valueBeforeCaret + valueAfterCaret;
2762
2943
  this._openDropdownWithPlus();
2763
2944
  return;
2764
2945
  }
2765
- if (this._updateCountryFromNumber(this.telInput.value)) {
2946
+ if (this._updateCountryFromNumber(this.ui.telInput.value)) {
2766
2947
  this._triggerCountryChange();
2767
2948
  }
2768
2949
  const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
2769
- const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
2950
+ const isPaste = e?.inputType === "insertFromPaste" && this.ui.telInput.value;
2770
2951
  if (isFormattingChar || isPaste && !strictMode) {
2771
2952
  userOverrideFormatting = true;
2772
- } else if (!/[^+0-9]/.test(this.telInput.value)) {
2953
+ } else if (!/[^+0-9]/.test(this.ui.telInput.value)) {
2773
2954
  userOverrideFormatting = false;
2774
2955
  }
2775
2956
  const isSetNumber = e?.detail && e.detail["isSetNumber"];
2776
2957
  if (formatAsYouType && !userOverrideFormatting && !isSetNumber) {
2777
- const currentCaretPos = this.telInput.selectionStart || 0;
2778
- const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2779
- const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2958
+ const currentCaretPos = this.ui.telInput.selectionStart || 0;
2959
+ const valueBeforeCaret = this.ui.telInput.value.substring(
2960
+ 0,
2961
+ currentCaretPos
2962
+ );
2963
+ const relevantCharsBeforeCaret = valueBeforeCaret.replace(
2964
+ /[^+0-9]/g,
2965
+ ""
2966
+ ).length;
2780
2967
  const isDeleteForwards = e?.inputType === "deleteContentForward";
2781
2968
  const fullNumber = this._getFullNumber();
2782
2969
  const formattedValue = formatNumberAsYouType(
2783
2970
  fullNumber,
2784
- this.telInput.value,
2971
+ this.ui.telInput.value,
2785
2972
  intlTelInput.utils,
2786
2973
  this.selectedCountryData,
2787
2974
  this.options.separateDialCode
2788
2975
  );
2789
- const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2790
- this.telInput.value = formattedValue;
2791
- this.telInput.setSelectionRange(newCaretPos, newCaretPos);
2976
+ const newCaretPos = translateCursorPosition(
2977
+ relevantCharsBeforeCaret,
2978
+ formattedValue,
2979
+ currentCaretPos,
2980
+ isDeleteForwards
2981
+ );
2982
+ this.ui.telInput.value = formattedValue;
2983
+ this.ui.telInput.setSelectionRange(newCaretPos, newCaretPos);
2792
2984
  }
2793
2985
  };
2794
- this.telInput.addEventListener("input", this._handleInputEvent);
2986
+ this.ui.telInput.addEventListener("input", handleInputEvent, {
2987
+ signal: this.abortController.signal
2988
+ });
2795
2989
  }
2796
2990
  _maybeBindKeydownListener() {
2797
2991
  const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.options;
2798
2992
  if (strictMode || separateDialCode) {
2799
- this._handleKeydownEvent = (e) => {
2993
+ const handleKeydownEvent = (e) => {
2800
2994
  if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
2801
2995
  if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
2802
2996
  e.preventDefault();
@@ -2804,14 +2998,17 @@ var Iti = class _Iti {
2804
2998
  return;
2805
2999
  }
2806
3000
  if (strictMode) {
2807
- const value = this.telInput.value;
2808
- const alreadyHasPlus = value.charAt(0) === "+";
2809
- const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
3001
+ const value = this.ui.telInput.value;
3002
+ const alreadyHasPlus = value.startsWith("+");
3003
+ const isInitialPlus = !alreadyHasPlus && this.ui.telInput.selectionStart === 0 && e.key === "+";
2810
3004
  const isNumeric = /^[0-9]$/.test(e.key);
2811
3005
  const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
2812
- const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
3006
+ const newValue = value.slice(0, this.ui.telInput.selectionStart) + e.key + value.slice(this.ui.telInput.selectionEnd);
2813
3007
  const newFullNumber = this._getFullNumber(newValue);
2814
- const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
3008
+ const coreNumber = intlTelInput.utils.getCoreNumber(
3009
+ newFullNumber,
3010
+ this.selectedCountryData.iso2
3011
+ );
2815
3012
  const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
2816
3013
  const newCountry = this._getNewCountryFromNumber(newFullNumber);
2817
3014
  const isChangingDialCode = newCountry !== null;
@@ -2821,14 +3018,16 @@ var Iti = class _Iti {
2821
3018
  }
2822
3019
  }
2823
3020
  };
2824
- this.telInput.addEventListener("keydown", this._handleKeydownEvent);
3021
+ this.ui.telInput.addEventListener("keydown", handleKeydownEvent, {
3022
+ signal: this.abortController.signal
3023
+ });
2825
3024
  }
2826
3025
  }
2827
3026
  _maybeBindPasteListener() {
2828
3027
  if (this.options.strictMode) {
2829
- this._handlePasteEvent = (e) => {
3028
+ const handlePasteEvent = (e) => {
2830
3029
  e.preventDefault();
2831
- const input = this.telInput;
3030
+ const input = this.ui.telInput;
2832
3031
  const selStart = input.selectionStart;
2833
3032
  const selEnd = input.selectionEnd;
2834
3033
  const before = input.value.slice(0, selStart);
@@ -2863,82 +3062,95 @@ var Iti = class _Iti {
2863
3062
  input.setSelectionRange(caretPos, caretPos);
2864
3063
  input.dispatchEvent(new InputEvent("input", { bubbles: true }));
2865
3064
  };
2866
- this.telInput.addEventListener("paste", this._handlePasteEvent);
3065
+ this.ui.telInput.addEventListener("paste", handlePasteEvent, {
3066
+ signal: this.abortController.signal
3067
+ });
2867
3068
  }
2868
3069
  }
2869
3070
  //* Adhere to the input's maxlength attr.
2870
3071
  _cap(number) {
2871
- const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
3072
+ const max = Number(this.ui.telInput.getAttribute("maxlength"));
2872
3073
  return max && number.length > max ? number.substring(0, max) : number;
2873
3074
  }
2874
- //* Trigger a custom event on the input.
3075
+ //* Trigger a custom event on the input (typed via ItiEventMap).
2875
3076
  _trigger(name, detailProps = {}) {
2876
3077
  const e = new CustomEvent(name, {
2877
3078
  bubbles: true,
2878
3079
  cancelable: true,
2879
3080
  detail: detailProps
2880
3081
  });
2881
- this.telInput.dispatchEvent(e);
3082
+ this.ui.telInput.dispatchEvent(e);
2882
3083
  }
2883
3084
  //* Open the dropdown.
2884
3085
  _openDropdown() {
2885
3086
  const { fixDropdownWidth, countrySearch } = this.options;
3087
+ this.dropdownAbortController = new AbortController();
2886
3088
  if (fixDropdownWidth) {
2887
- this.dropdownContent.style.width = `${this.telInput.offsetWidth}px`;
3089
+ this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`;
2888
3090
  }
2889
- this.dropdownContent.classList.remove("iti__hide");
2890
- this.selectedCountry.setAttribute("aria-expanded", "true");
3091
+ this.ui.dropdownContent.classList.remove("iti__hide");
3092
+ this.ui.selectedCountry.setAttribute("aria-expanded", "true");
2891
3093
  this._setDropdownPosition();
2892
3094
  if (countrySearch) {
2893
- const firstCountryItem = this.countryList.firstElementChild;
3095
+ const firstCountryItem = this.ui.countryList.firstElementChild;
2894
3096
  if (firstCountryItem) {
2895
- this._highlightListItem(firstCountryItem, false);
2896
- this.countryList.scrollTop = 0;
3097
+ this.ui.highlightListItem(firstCountryItem, false);
3098
+ this.ui.countryList.scrollTop = 0;
2897
3099
  }
2898
- this.searchInput.focus();
3100
+ this.ui.searchInput.focus();
2899
3101
  }
2900
3102
  this._bindDropdownListeners();
2901
- this.dropdownArrow.classList.add("iti__arrow--up");
3103
+ this.ui.dropdownArrow.classList.add("iti__arrow--up");
2902
3104
  this._trigger("open:countrydropdown");
2903
3105
  }
2904
3106
  //* Set the dropdown position
2905
3107
  _setDropdownPosition() {
2906
3108
  if (this.options.dropdownContainer) {
2907
- this.options.dropdownContainer.appendChild(this.dropdown);
3109
+ this.options.dropdownContainer.appendChild(this.ui.dropdown);
2908
3110
  }
2909
3111
  if (!this.options.useFullscreenPopup) {
2910
- const inputPosRelativeToVP = this.telInput.getBoundingClientRect();
2911
- const inputHeight = this.telInput.offsetHeight;
3112
+ const inputPosRelativeToVP = this.ui.telInput.getBoundingClientRect();
3113
+ const inputHeight = this.ui.telInput.offsetHeight;
2912
3114
  if (this.options.dropdownContainer) {
2913
- this.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
2914
- this.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
2915
- this._handleWindowScroll = () => this._closeDropdown();
2916
- window.addEventListener("scroll", this._handleWindowScroll);
3115
+ this.ui.dropdown.style.top = `${inputPosRelativeToVP.top + inputHeight}px`;
3116
+ this.ui.dropdown.style.left = `${inputPosRelativeToVP.left}px`;
3117
+ const handleWindowScroll = () => this._closeDropdown();
3118
+ window.addEventListener("scroll", handleWindowScroll, {
3119
+ signal: this.dropdownAbortController.signal
3120
+ });
2917
3121
  }
2918
3122
  }
2919
3123
  }
2920
3124
  //* We only bind dropdown listeners when the dropdown is open.
2921
3125
  _bindDropdownListeners() {
2922
- this._handleMouseoverCountryList = (e) => {
2923
- const listItem = e.target?.closest(".iti__country");
3126
+ const signal = this.dropdownAbortController.signal;
3127
+ const handleMouseoverCountryList = (e) => {
3128
+ const listItem = e.target?.closest(
3129
+ ".iti__country"
3130
+ );
2924
3131
  if (listItem) {
2925
- this._highlightListItem(listItem, false);
3132
+ this.ui.highlightListItem(listItem, false);
2926
3133
  }
2927
3134
  };
2928
- this.countryList.addEventListener(
2929
- "mouseover",
2930
- this._handleMouseoverCountryList
2931
- );
2932
- this._handleClickCountryList = (e) => {
2933
- const listItem = e.target?.closest(".iti__country");
3135
+ this.ui.countryList.addEventListener("mouseover", handleMouseoverCountryList, {
3136
+ signal
3137
+ });
3138
+ const handleClickCountryList = (e) => {
3139
+ const listItem = e.target?.closest(
3140
+ ".iti__country"
3141
+ );
2934
3142
  if (listItem) {
2935
3143
  this._selectListItem(listItem);
2936
3144
  }
2937
3145
  };
2938
- this.countryList.addEventListener("click", this._handleClickCountryList);
2939
- this._handleClickOffToClose = (e) => {
3146
+ this.ui.countryList.addEventListener("click", handleClickCountryList, {
3147
+ signal
3148
+ });
3149
+ const handleClickOffToClose = (e) => {
2940
3150
  const target = e.target;
2941
- const clickedInsideDropdown = !!target.closest(`#iti-${this.id}__dropdown-content`);
3151
+ const clickedInsideDropdown = !!target.closest(
3152
+ `#iti-${this.id}__dropdown-content`
3153
+ );
2942
3154
  if (!clickedInsideDropdown) {
2943
3155
  this._closeDropdown();
2944
3156
  }
@@ -2946,12 +3158,13 @@ var Iti = class _Iti {
2946
3158
  setTimeout(() => {
2947
3159
  document.documentElement.addEventListener(
2948
3160
  "click",
2949
- this._handleClickOffToClose
3161
+ handleClickOffToClose,
3162
+ { signal }
2950
3163
  );
2951
3164
  }, 0);
2952
3165
  let query = "";
2953
3166
  let queryTimer = null;
2954
- this._handleKeydownOnDropdown = (e) => {
3167
+ const handleKeydownOnDropdown = (e) => {
2955
3168
  if (["ArrowUp", "ArrowDown", "Enter", "Escape"].includes(e.key)) {
2956
3169
  e.preventDefault();
2957
3170
  e.stopPropagation();
@@ -2975,19 +3188,19 @@ var Iti = class _Iti {
2975
3188
  }, 1e3);
2976
3189
  }
2977
3190
  };
2978
- document.addEventListener("keydown", this._handleKeydownOnDropdown);
3191
+ document.addEventListener("keydown", handleKeydownOnDropdown, { signal });
2979
3192
  if (this.options.countrySearch) {
2980
3193
  const doFilter = () => {
2981
- const inputQuery = this.searchInput.value.trim();
2982
- this._filterCountries(inputQuery);
2983
- if (this.searchInput.value) {
2984
- this.searchClearButton.classList.remove("iti__hide");
3194
+ const inputQuery = this.ui.searchInput.value.trim();
3195
+ this._filterCountriesByQuery(inputQuery);
3196
+ if (this.ui.searchInput.value) {
3197
+ this.ui.searchClearButton.classList.remove("iti__hide");
2985
3198
  } else {
2986
- this.searchClearButton.classList.add("iti__hide");
3199
+ this.ui.searchClearButton.classList.add("iti__hide");
2987
3200
  }
2988
3201
  };
2989
3202
  let keyupTimer = null;
2990
- this._handleSearchChange = () => {
3203
+ const handleSearchChange = () => {
2991
3204
  if (keyupTimer) {
2992
3205
  clearTimeout(keyupTimer);
2993
3206
  }
@@ -2996,13 +3209,17 @@ var Iti = class _Iti {
2996
3209
  keyupTimer = null;
2997
3210
  }, 100);
2998
3211
  };
2999
- this.searchInput.addEventListener("input", this._handleSearchChange);
3000
- this._handleSearchClear = () => {
3001
- this.searchInput.value = "";
3002
- this.searchInput.focus();
3212
+ this.ui.searchInput.addEventListener("input", handleSearchChange, {
3213
+ signal
3214
+ });
3215
+ const handleSearchClear = () => {
3216
+ this.ui.searchInput.value = "";
3217
+ this.ui.searchInput.focus();
3003
3218
  doFilter();
3004
3219
  };
3005
- this.searchClearButton.addEventListener("click", this._handleSearchClear);
3220
+ this.ui.searchClearButton.addEventListener("click", handleSearchClear, {
3221
+ signal
3222
+ });
3006
3223
  }
3007
3224
  }
3008
3225
  //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
@@ -3011,42 +3228,21 @@ var Iti = class _Iti {
3011
3228
  const startsWith = c.name.substring(0, query.length).toLowerCase() === query;
3012
3229
  if (startsWith) {
3013
3230
  const listItem = c.nodeById[this.id];
3014
- this._highlightListItem(listItem, false);
3015
- this._scrollTo(listItem);
3231
+ this.ui.highlightListItem(listItem, false);
3232
+ this.ui.scrollTo(listItem);
3016
3233
  break;
3017
3234
  }
3018
3235
  }
3019
3236
  }
3020
- //* Country search enabled: Filter the countries according to the search query.
3021
- _filterCountries(query) {
3022
- this.countryList.innerHTML = "";
3237
+ //* Country search: Filter the countries according to the search query.
3238
+ _filterCountriesByQuery(query) {
3023
3239
  let matchedCountries;
3024
3240
  if (query === "") {
3025
3241
  matchedCountries = this.countries;
3026
3242
  } else {
3027
3243
  matchedCountries = this._getMatchedCountries(query);
3028
3244
  }
3029
- let noCountriesAddedYet = true;
3030
- for (const c of matchedCountries) {
3031
- const listItem = c.nodeById[this.id];
3032
- if (listItem) {
3033
- this.countryList.appendChild(listItem);
3034
- if (noCountriesAddedYet) {
3035
- this._highlightListItem(listItem, false);
3036
- noCountriesAddedYet = false;
3037
- }
3038
- }
3039
- }
3040
- if (noCountriesAddedYet) {
3041
- this._highlightListItem(null, false);
3042
- if (this.searchNoResults) {
3043
- this.searchNoResults.classList.remove("iti__hide");
3044
- }
3045
- } else if (this.searchNoResults) {
3046
- this.searchNoResults.classList.add("iti__hide");
3047
- }
3048
- this.countryList.scrollTop = 0;
3049
- this._updateSearchResultsA11yText();
3245
+ this.ui.filterCountries(matchedCountries);
3050
3246
  }
3051
3247
  _getMatchedCountries(query) {
3052
3248
  const normalisedQuery = normaliseString(query);
@@ -3080,39 +3276,21 @@ var Iti = class _Iti {
3080
3276
  ...initialsMatches.sort((a, b) => a.priority - b.priority)
3081
3277
  ];
3082
3278
  }
3083
- //* Update search results text (for a11y).
3084
- _updateSearchResultsA11yText() {
3085
- const { i18n } = this.options;
3086
- const count = this.countryList.childElementCount;
3087
- let searchText;
3088
- if (count === 0) {
3089
- searchText = i18n.zeroSearchResults;
3090
- } else {
3091
- if (i18n.searchResultsText) {
3092
- searchText = i18n.searchResultsText(count);
3093
- } else if (count === 1) {
3094
- searchText = i18n.oneSearchResult;
3095
- } else {
3096
- searchText = i18n.multipleSearchResults.replace("${count}", count.toString());
3097
- }
3098
- }
3099
- this.searchResultsA11yText.textContent = searchText;
3100
- }
3101
3279
  //* Highlight the next/prev item in the list (and ensure it is visible).
3102
3280
  _handleUpDownKey(key) {
3103
- let next = key === "ArrowUp" ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
3104
- if (!next && this.countryList.childElementCount > 1) {
3105
- next = key === "ArrowUp" ? this.countryList.lastElementChild : this.countryList.firstElementChild;
3281
+ let next = key === "ArrowUp" ? this.ui.highlightedItem?.previousElementSibling : this.ui.highlightedItem?.nextElementSibling;
3282
+ if (!next && this.ui.countryList.childElementCount > 1) {
3283
+ next = key === "ArrowUp" ? this.ui.countryList.lastElementChild : this.ui.countryList.firstElementChild;
3106
3284
  }
3107
3285
  if (next) {
3108
- this._scrollTo(next);
3109
- this._highlightListItem(next, false);
3286
+ this.ui.scrollTo(next);
3287
+ this.ui.highlightListItem(next, false);
3110
3288
  }
3111
3289
  }
3112
3290
  //* Select the currently highlighted item.
3113
3291
  _handleEnterKey() {
3114
- if (this.highlightedItem) {
3115
- this._selectListItem(this.highlightedItem);
3292
+ if (this.ui.highlightedItem) {
3293
+ this._selectListItem(this.ui.highlightedItem);
3116
3294
  }
3117
3295
  }
3118
3296
  //* Update the input's value to the given val (format first if possible)
@@ -3120,7 +3298,7 @@ var Iti = class _Iti {
3120
3298
  _updateValFromNumber(fullNumber) {
3121
3299
  let number = fullNumber;
3122
3300
  if (this.options.formatOnDisplay && intlTelInput.utils && this.selectedCountryData) {
3123
- const useNational = this.options.nationalMode || number.charAt(0) !== "+" && !this.options.separateDialCode;
3301
+ const useNational = this.options.nationalMode || !number.startsWith("+") && !this.options.separateDialCode;
3124
3302
  const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
3125
3303
  const format = useNational ? NATIONAL : INTERNATIONAL;
3126
3304
  number = intlTelInput.utils.formatNumber(
@@ -3130,7 +3308,7 @@ var Iti = class _Iti {
3130
3308
  );
3131
3309
  }
3132
3310
  number = this._beforeSetNumber(number);
3133
- this.telInput.value = number;
3311
+ this.ui.telInput.value = number;
3134
3312
  }
3135
3313
  //* Check if need to select a new country based on the given number
3136
3314
  //* Note: called from _setInitialState, keyup handler, setNumber.
@@ -3144,11 +3322,11 @@ var Iti = class _Iti {
3144
3322
  // if there is a selected country, and the number doesn't start with a dial code, then add it
3145
3323
  _ensureHasDialCode(number) {
3146
3324
  const { dialCode, nationalPrefix } = this.selectedCountryData;
3147
- const alreadyHasPlus = number.charAt(0) === "+";
3325
+ const alreadyHasPlus = number.startsWith("+");
3148
3326
  if (alreadyHasPlus || !dialCode) {
3149
3327
  return number;
3150
3328
  }
3151
- const hasPrefix = nationalPrefix && number.charAt(0) === nationalPrefix && !this.options.separateDialCode;
3329
+ const hasPrefix = nationalPrefix && number.startsWith(nationalPrefix) && !this.options.separateDialCode;
3152
3330
  const cleanNumber = hasPrefix ? number.substring(1) : number;
3153
3331
  return `+${dialCode}${cleanNumber}`;
3154
3332
  }
@@ -3181,7 +3359,9 @@ var Iti = class _Iti {
3181
3359
  }
3182
3360
  const { areaCodes, priority } = this.selectedCountryData;
3183
3361
  if (areaCodes) {
3184
- const dialCodeAreaCodes = areaCodes.map((areaCode) => `${selectedDialCode}${areaCode}`);
3362
+ const dialCodeAreaCodes = areaCodes.map(
3363
+ (areaCode) => `${selectedDialCode}${areaCode}`
3364
+ );
3185
3365
  for (const dialCodeAreaCode of dialCodeAreaCodes) {
3186
3366
  if (numeric.startsWith(dialCodeAreaCode)) {
3187
3367
  return null;
@@ -3195,33 +3375,13 @@ var Iti = class _Iti {
3195
3375
  if (!isValidSelection && !alreadySelected) {
3196
3376
  return iso2Codes[0];
3197
3377
  }
3198
- } else if (number.charAt(0) === "+" && numeric.length) {
3378
+ } else if (number.startsWith("+") && numeric.length) {
3199
3379
  return "";
3200
3380
  } else if ((!number || number === "+") && !selectedIso2) {
3201
3381
  return this.defaultCountry;
3202
3382
  }
3203
3383
  return null;
3204
3384
  }
3205
- //* Remove highlighting from other list items and highlight the given item.
3206
- _highlightListItem(listItem, shouldFocus) {
3207
- const prevItem = this.highlightedItem;
3208
- if (prevItem) {
3209
- prevItem.classList.remove("iti__highlight");
3210
- prevItem.setAttribute("aria-selected", "false");
3211
- }
3212
- this.highlightedItem = listItem;
3213
- if (this.highlightedItem) {
3214
- this.highlightedItem.classList.add("iti__highlight");
3215
- this.highlightedItem.setAttribute("aria-selected", "true");
3216
- if (this.options.countrySearch) {
3217
- const activeDescendant = this.highlightedItem.getAttribute("id") || "";
3218
- this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
3219
- }
3220
- }
3221
- if (shouldFocus) {
3222
- this.highlightedItem.focus();
3223
- }
3224
- }
3225
3385
  //* Update the selected country, dial code (if separateDialCode), placeholder, title, and active list item.
3226
3386
  //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
3227
3387
  _setCountry(iso2) {
@@ -3231,7 +3391,7 @@ var Iti = class _Iti {
3231
3391
  if (this.selectedCountryData.iso2) {
3232
3392
  this.defaultCountry = this.selectedCountryData.iso2;
3233
3393
  }
3234
- if (this.selectedCountry) {
3394
+ if (this.ui.selectedCountry) {
3235
3395
  const flagClass = iso2 && showFlags ? `iti__flag iti__${iso2}` : "iti__flag iti__globe";
3236
3396
  let ariaLabel, title;
3237
3397
  if (iso2) {
@@ -3242,28 +3402,19 @@ var Iti = class _Iti {
3242
3402
  title = i18n.noCountrySelected;
3243
3403
  ariaLabel = i18n.noCountrySelected;
3244
3404
  }
3245
- this.selectedCountryInner.className = flagClass;
3246
- this.selectedCountry.setAttribute("title", title);
3247
- this.selectedCountry.setAttribute("aria-label", ariaLabel);
3405
+ this.ui.selectedCountryInner.className = flagClass;
3406
+ this.ui.selectedCountry.setAttribute("title", title);
3407
+ this.ui.selectedCountry.setAttribute("aria-label", ariaLabel);
3248
3408
  }
3249
3409
  if (separateDialCode) {
3250
3410
  const dialCode = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
3251
- this.selectedDialCode.innerHTML = dialCode;
3252
- this._updateInputPadding();
3411
+ this.ui.selectedDialCode.textContent = dialCode;
3412
+ this.ui.updateInputPadding();
3253
3413
  }
3254
3414
  this._updatePlaceholder();
3255
3415
  this._updateMaxLength();
3256
3416
  return prevIso2 !== iso2;
3257
3417
  }
3258
- //* Update the input padding to make space for the selected country/dial code.
3259
- _updateInputPadding() {
3260
- if (this.selectedCountry) {
3261
- const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
3262
- const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
3263
- const inputPadding = selectedCountryWidth + 6;
3264
- this.telInput.style.paddingLeft = `${inputPadding}px`;
3265
- }
3266
- }
3267
3418
  //* Update the maximum valid number length for the currently selected country.
3268
3419
  _updateMaxLength() {
3269
3420
  const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
@@ -3278,7 +3429,11 @@ var Iti = class _Iti {
3278
3429
  true
3279
3430
  );
3280
3431
  let validNumber = exampleNumber;
3281
- while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
3432
+ while (intlTelInput.utils.isPossibleNumber(
3433
+ exampleNumber,
3434
+ iso2,
3435
+ validationNumberTypes
3436
+ )) {
3282
3437
  validNumber = exampleNumber;
3283
3438
  exampleNumber += "0";
3284
3439
  }
@@ -3292,31 +3447,6 @@ var Iti = class _Iti {
3292
3447
  }
3293
3448
  }
3294
3449
  }
3295
- //* When input is in a hidden container during init, we cannot calculate the selected country width.
3296
- //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
3297
- //* To get the right styling to apply, all we need is a shallow clone of the container,
3298
- //* and then to inject a deep clone of the selectedCountry element.
3299
- _getHiddenSelectedCountryWidth() {
3300
- if (this.telInput.parentNode) {
3301
- let body;
3302
- try {
3303
- body = window.top.document.body;
3304
- } catch (e) {
3305
- body = document.body;
3306
- }
3307
- const containerClone = this.telInput.parentNode.cloneNode(false);
3308
- containerClone.style.visibility = "hidden";
3309
- body.appendChild(containerClone);
3310
- const countryContainerClone = this.countryContainer.cloneNode();
3311
- containerClone.appendChild(countryContainerClone);
3312
- const selectedCountryClone = this.selectedCountry.cloneNode(true);
3313
- countryContainerClone.appendChild(selectedCountryClone);
3314
- const width = selectedCountryClone.offsetWidth;
3315
- body.removeChild(containerClone);
3316
- return width;
3317
- }
3318
- return 0;
3319
- }
3320
3450
  //* Update the input placeholder to an example number from the currently selected country.
3321
3451
  _updatePlaceholder() {
3322
3452
  const {
@@ -3325,7 +3455,7 @@ var Iti = class _Iti {
3325
3455
  nationalMode,
3326
3456
  customPlaceholder
3327
3457
  } = this.options;
3328
- const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.hadInitialPlaceholder && autoPlaceholder === "polite";
3458
+ const shouldSetPlaceholder = autoPlaceholder === "aggressive" || !this.ui.hadInitialPlaceholder && autoPlaceholder === "polite";
3329
3459
  if (intlTelInput.utils && shouldSetPlaceholder) {
3330
3460
  const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3331
3461
  let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(
@@ -3337,98 +3467,66 @@ var Iti = class _Iti {
3337
3467
  if (typeof customPlaceholder === "function") {
3338
3468
  placeholder = customPlaceholder(placeholder, this.selectedCountryData);
3339
3469
  }
3340
- this.telInput.setAttribute("placeholder", placeholder);
3470
+ this.ui.telInput.setAttribute("placeholder", placeholder);
3341
3471
  }
3342
3472
  }
3343
3473
  //* Called when the user selects a list item from the dropdown.
3344
3474
  _selectListItem(listItem) {
3345
- const iso2 = listItem.getAttribute("data-country-code");
3475
+ const iso2 = listItem.dataset.countryCode;
3346
3476
  const countryChanged = this._setCountry(iso2);
3347
3477
  this._closeDropdown();
3348
- const dialCode = listItem.getAttribute("data-dial-code");
3478
+ const dialCode = listItem.dataset.dialCode;
3349
3479
  this._updateDialCode(dialCode);
3350
3480
  if (this.options.formatOnDisplay) {
3351
- this._updateValFromNumber(this.telInput.value);
3481
+ this._updateValFromNumber(this.ui.telInput.value);
3352
3482
  }
3353
- this.telInput.focus();
3483
+ this.ui.telInput.focus();
3354
3484
  if (countryChanged) {
3355
3485
  this._triggerCountryChange();
3356
3486
  }
3357
3487
  }
3358
3488
  //* Close the dropdown and unbind any listeners.
3359
3489
  _closeDropdown() {
3360
- this.dropdownContent.classList.add("iti__hide");
3361
- this.selectedCountry.setAttribute("aria-expanded", "false");
3362
- if (this.highlightedItem) {
3363
- this.highlightedItem.setAttribute("aria-selected", "false");
3490
+ if (this.ui.dropdownContent.classList.contains("iti__hide")) {
3491
+ return;
3364
3492
  }
3365
- if (this.options.countrySearch) {
3366
- this.searchInput.removeAttribute("aria-activedescendant");
3493
+ this.ui.dropdownContent.classList.add("iti__hide");
3494
+ this.ui.selectedCountry.setAttribute("aria-expanded", "false");
3495
+ if (this.ui.highlightedItem) {
3496
+ this.ui.highlightedItem.setAttribute("aria-selected", "false");
3367
3497
  }
3368
- this.dropdownArrow.classList.remove("iti__arrow--up");
3369
3498
  if (this.options.countrySearch) {
3370
- this.searchInput.removeEventListener("input", this._handleSearchChange);
3371
- this.searchClearButton.removeEventListener("click", this._handleSearchClear);
3499
+ this.ui.searchInput.removeAttribute("aria-activedescendant");
3372
3500
  }
3373
- document.removeEventListener("keydown", this._handleKeydownOnDropdown);
3374
- document.documentElement.removeEventListener(
3375
- "click",
3376
- this._handleClickOffToClose
3377
- );
3378
- this.countryList.removeEventListener(
3379
- "mouseover",
3380
- this._handleMouseoverCountryList
3381
- );
3382
- this.countryList.removeEventListener("click", this._handleClickCountryList);
3501
+ this.ui.dropdownArrow.classList.remove("iti__arrow--up");
3502
+ this.dropdownAbortController.abort();
3503
+ this.dropdownAbortController = null;
3383
3504
  if (this.options.dropdownContainer) {
3384
- if (!this.options.useFullscreenPopup) {
3385
- window.removeEventListener("scroll", this._handleWindowScroll);
3386
- }
3387
- if (this.dropdown.parentNode) {
3388
- this.dropdown.parentNode.removeChild(this.dropdown);
3389
- }
3505
+ this.ui.dropdown.remove();
3390
3506
  }
3391
3507
  this._trigger("close:countrydropdown");
3392
3508
  }
3393
- //* Check if an element is visible within it's container, else scroll until it is.
3394
- _scrollTo(element) {
3395
- const container = this.countryList;
3396
- const scrollTop = document.documentElement.scrollTop;
3397
- const containerHeight = container.offsetHeight;
3398
- const containerTop = container.getBoundingClientRect().top + scrollTop;
3399
- const containerBottom = containerTop + containerHeight;
3400
- const elementHeight = element.offsetHeight;
3401
- const elementTop = element.getBoundingClientRect().top + scrollTop;
3402
- const elementBottom = elementTop + elementHeight;
3403
- const newScrollTop = elementTop - containerTop + container.scrollTop;
3404
- if (elementTop < containerTop) {
3405
- container.scrollTop = newScrollTop;
3406
- } else if (elementBottom > containerBottom) {
3407
- const heightDifference = containerHeight - elementHeight;
3408
- container.scrollTop = newScrollTop - heightDifference;
3409
- }
3410
- }
3411
3509
  //* Replace any existing dial code with the new one
3412
3510
  //* Note: called from _selectListItem and setCountry
3413
3511
  _updateDialCode(newDialCodeBare) {
3414
- const inputVal = this.telInput.value;
3512
+ const inputVal = this.ui.telInput.value;
3415
3513
  const newDialCode = `+${newDialCodeBare}`;
3416
3514
  let newNumber;
3417
- if (inputVal.charAt(0) === "+") {
3515
+ if (inputVal.startsWith("+")) {
3418
3516
  const prevDialCode = this._getDialCode(inputVal);
3419
3517
  if (prevDialCode) {
3420
3518
  newNumber = inputVal.replace(prevDialCode, newDialCode);
3421
3519
  } else {
3422
3520
  newNumber = newDialCode;
3423
3521
  }
3424
- this.telInput.value = newNumber;
3522
+ this.ui.telInput.value = newNumber;
3425
3523
  }
3426
3524
  }
3427
3525
  //* Try and extract a valid international dial code from a full telephone number.
3428
3526
  //* Note: returns the raw string inc plus character and any whitespace/dots etc.
3429
3527
  _getDialCode(number, includeAreaCode) {
3430
3528
  let dialCode = "";
3431
- if (number.charAt(0) === "+") {
3529
+ if (number.startsWith("+")) {
3432
3530
  let numericChars = "";
3433
3531
  for (let i = 0; i < number.length; i++) {
3434
3532
  const c = number.charAt(i);
@@ -3454,11 +3552,11 @@ var Iti = class _Iti {
3454
3552
  }
3455
3553
  //* Get the input val, adding the dial code if separateDialCode is enabled.
3456
3554
  _getFullNumber(overrideVal) {
3457
- const val = overrideVal || this.telInput.value.trim();
3555
+ const val = overrideVal || this.ui.telInput.value.trim();
3458
3556
  const { dialCode } = this.selectedCountryData;
3459
3557
  let prefix;
3460
3558
  const numericVal = getNumeric(val);
3461
- if (this.options.separateDialCode && val.charAt(0) !== "+" && dialCode && numericVal) {
3559
+ if (this.options.separateDialCode && !val.startsWith("+") && dialCode && numericVal) {
3462
3560
  prefix = `+${dialCode}`;
3463
3561
  } else {
3464
3562
  prefix = "";
@@ -3487,7 +3585,7 @@ var Iti = class _Iti {
3487
3585
  handleAutoCountry() {
3488
3586
  if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) {
3489
3587
  this.defaultCountry = intlTelInput.autoCountry;
3490
- const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe");
3588
+ const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains("iti__globe");
3491
3589
  if (!hasSelectedCountryOrGlobe) {
3492
3590
  this.setCountry(this.defaultCountry);
3493
3591
  }
@@ -3497,8 +3595,8 @@ var Iti = class _Iti {
3497
3595
  //* This is called when the utils request completes.
3498
3596
  handleUtils() {
3499
3597
  if (intlTelInput.utils) {
3500
- if (this.telInput.value) {
3501
- this._updateValFromNumber(this.telInput.value);
3598
+ if (this.ui.telInput.value) {
3599
+ this._updateValFromNumber(this.ui.telInput.value);
3502
3600
  }
3503
3601
  if (this.selectedCountryData.iso2) {
3504
3602
  this._updatePlaceholder();
@@ -3512,45 +3610,20 @@ var Iti = class _Iti {
3512
3610
  //********************
3513
3611
  //* Remove plugin.
3514
3612
  destroy() {
3515
- this.telInput.iti = void 0;
3516
- const { allowDropdown, separateDialCode } = this.options;
3517
- if (allowDropdown) {
3518
- this._closeDropdown();
3519
- this.selectedCountry.removeEventListener(
3520
- "click",
3521
- this._handleClickSelectedCountry
3522
- );
3523
- this.countryContainer.removeEventListener(
3524
- "keydown",
3525
- this._handleCountryContainerKeydown
3526
- );
3527
- const label = this.telInput.closest("label");
3528
- if (label) {
3529
- label.removeEventListener("click", this._handleLabelClick);
3530
- }
3531
- }
3532
- const { form } = this.telInput;
3533
- if (this._handleHiddenInputSubmit && form) {
3534
- form.removeEventListener("submit", this._handleHiddenInputSubmit);
3535
- }
3536
- this.telInput.removeEventListener("input", this._handleInputEvent);
3537
- if (this._handleKeydownEvent) {
3538
- this.telInput.removeEventListener("keydown", this._handleKeydownEvent);
3539
- }
3540
- if (this._handlePasteEvent) {
3541
- this.telInput.removeEventListener("paste", this._handlePasteEvent);
3613
+ if (!this.ui.telInput) {
3614
+ return;
3542
3615
  }
3543
- if (this._handlePageLoad) {
3544
- window.removeEventListener("load", this._handlePageLoad);
3616
+ if (this.options.allowDropdown) {
3617
+ this._closeDropdown();
3545
3618
  }
3546
- this.telInput.removeAttribute("data-intl-tel-input-id");
3547
- if (separateDialCode) {
3548
- this.telInput.style.paddingLeft = this.originalPaddingLeft;
3619
+ this.abortController.abort();
3620
+ this.abortController = null;
3621
+ this.ui.destroy();
3622
+ if (intlTelInput.instances instanceof Map) {
3623
+ intlTelInput.instances.delete(this.id);
3624
+ } else {
3625
+ delete intlTelInput.instances[this.id];
3549
3626
  }
3550
- const wrapper = this.telInput.parentNode;
3551
- wrapper?.parentNode?.insertBefore(this.telInput, wrapper);
3552
- wrapper?.parentNode?.removeChild(wrapper);
3553
- delete intlTelInput.instances[this.id];
3554
3627
  }
3555
3628
  //* Get the extension from the current number.
3556
3629
  getExtension() {
@@ -3613,7 +3686,11 @@ var Iti = class _Iti {
3613
3686
  return this._validateNumber(true);
3614
3687
  }
3615
3688
  _utilsIsPossibleNumber(val) {
3616
- return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3689
+ return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(
3690
+ val,
3691
+ this.selectedCountryData.iso2,
3692
+ this.options.validationNumberTypes
3693
+ ) : null;
3617
3694
  }
3618
3695
  //* Shared internal validation logic to handle alpha character extension rules.
3619
3696
  _validateNumber(precise) {
@@ -3636,7 +3713,11 @@ var Iti = class _Iti {
3636
3713
  return testValidity(val);
3637
3714
  }
3638
3715
  _utilsIsValidNumber(val) {
3639
- return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
3716
+ return intlTelInput.utils ? intlTelInput.utils.isValidNumber(
3717
+ val,
3718
+ this.selectedCountryData.iso2,
3719
+ this.options.validationNumberTypes
3720
+ ) : null;
3640
3721
  }
3641
3722
  //* Update the selected country, and update the input val accordingly.
3642
3723
  setCountry(iso2) {
@@ -3650,7 +3731,7 @@ var Iti = class _Iti {
3650
3731
  this._setCountry(iso2Lower);
3651
3732
  this._updateDialCode(this.selectedCountryData.dialCode);
3652
3733
  if (this.options.formatOnDisplay) {
3653
- this._updateValFromNumber(this.telInput.value);
3734
+ this._updateValFromNumber(this.ui.telInput.value);
3654
3735
  }
3655
3736
  this._triggerCountryChange();
3656
3737
  }
@@ -3670,11 +3751,11 @@ var Iti = class _Iti {
3670
3751
  this._updatePlaceholder();
3671
3752
  }
3672
3753
  setDisabled(disabled) {
3673
- this.telInput.disabled = disabled;
3754
+ this.ui.telInput.disabled = disabled;
3674
3755
  if (disabled) {
3675
- this.selectedCountry.setAttribute("disabled", "true");
3756
+ this.ui.selectedCountry.setAttribute("disabled", "true");
3676
3757
  } else {
3677
- this.selectedCountry.removeAttribute("disabled");
3758
+ this.ui.selectedCountry.removeAttribute("disabled");
3678
3759
  }
3679
3760
  }
3680
3761
  };
@@ -3688,13 +3769,19 @@ var attachUtils = (source) => {
3688
3769
  return Promise.reject(error);
3689
3770
  }
3690
3771
  } else {
3691
- return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`));
3772
+ return Promise.reject(
3773
+ new TypeError(
3774
+ `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`
3775
+ )
3776
+ );
3692
3777
  }
3693
3778
  intlTelInput.startedLoadingUtilsScript = true;
3694
3779
  return loadCall.then((module) => {
3695
3780
  const utils2 = module?.default;
3696
3781
  if (!utils2 || typeof utils2 !== "object") {
3697
- throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
3782
+ throw new TypeError(
3783
+ "The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
3784
+ );
3698
3785
  }
3699
3786
  intlTelInput.utils = utils2;
3700
3787
  forEachInstance("handleUtils");
@@ -3706,11 +3793,17 @@ var attachUtils = (source) => {
3706
3793
  }
3707
3794
  return null;
3708
3795
  };
3796
+ var forEachInstance = (method, ...args) => {
3797
+ Object.values(intlTelInput.instances).forEach((instance) => {
3798
+ const fn = instance[method];
3799
+ if (typeof fn === "function") {
3800
+ fn.apply(instance, args);
3801
+ }
3802
+ });
3803
+ };
3709
3804
  var intlTelInput = Object.assign(
3710
3805
  (input, options) => {
3711
3806
  const iti = new Iti(input, options);
3712
- iti._init();
3713
- input.setAttribute("data-intl-tel-input-id", iti.id.toString());
3714
3807
  intlTelInput.instances[iti.id] = iti;
3715
3808
  input.iti = iti;
3716
3809
  return iti;
@@ -3723,7 +3816,7 @@ var intlTelInput = Object.assign(
3723
3816
  getCountryData: () => data_default,
3724
3817
  //* A getter for the plugin instance.
3725
3818
  getInstance: (input) => {
3726
- const id2 = input.getAttribute("data-intl-tel-input-id");
3819
+ const id2 = input.dataset.intlTelInputId;
3727
3820
  return id2 ? intlTelInput.instances[id2] : null;
3728
3821
  },
3729
3822
  //* A map from instance ID to instance object.
@@ -3731,7 +3824,7 @@ var intlTelInput = Object.assign(
3731
3824
  attachUtils,
3732
3825
  startedLoadingUtilsScript: false,
3733
3826
  startedLoadingAutoCountry: false,
3734
- version: "25.10.12"
3827
+ version: "25.11.0"
3735
3828
  }
3736
3829
  );
3737
3830
  var intl_tel_input_default = intlTelInput;
@@ -6841,7 +6934,7 @@ var intl_tel_input_default = intlTelInput;
6841
6934
  ,
6842
6935
  ,
6843
6936
  [7, 8, 9]
6844
- ], [, , "(?:1(?:0[0-8]|1[0-7]|2[014]|30)|7\\d\\d)\\d{6}", , , , "712123456", , , [9]], [, , "800[02-8]\\d{5,6}", , , , "800223456", , , [9, 10]], [, , "900[02-9]\\d{5}", , , , "900223456", , , [9]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "KE", 254, "000", "0", , , "0", , , , [[, "(\\d{2})(\\d{5,7})", "$1 $2", ["[24-6]"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[17]"], "0$1"], [, "(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[89]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
6937
+ ], [, , "(?:1(?:0[0-8]|1\\d|2[014]|[34]0)|7\\d\\d)\\d{6}", , , , "712123456", , , [9]], [, , "800[02-8]\\d{5,6}", , , , "800223456", , , [9, 10]], [, , "900[02-9]\\d{5}", , , , "900223456", , , [9]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "KE", 254, "000", "0", , , "0", , , , [[, "(\\d{2})(\\d{5,7})", "$1 $2", ["[24-6]"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[17]"], "0$1"], [, "(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[89]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
6845
6938
  KG: [, [
6846
6939
  ,
6847
6940
  ,
@@ -8897,7 +8990,7 @@ var intl_tel_input_default = intlTelInput;
8897
8990
  ,
8898
8991
  ,
8899
8992
  [5, 6, 7]
8900
- ], [, , "72[48]0\\d{5}|7(?:[014-8]\\d|2[067]|36|9[0189])\\d{6}", , , , "712345678"], [, , "800[1-3]\\d{5}", , , , "800123456"], [, , "90[1-3]\\d{6}", , , , "901123456"], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "UG", 256, "00[057]", "0", , , "0", , , , [[, "(\\d{4})(\\d{5})", "$1 $2", ["202", "2024"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[27-9]|4(?:6[45]|[7-9])"], "0$1"], [, "(\\d{2})(\\d{7})", "$1 $2", ["[34]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
8993
+ ], [, , "72[48]0\\d{5}|7(?:[014-8]\\d|2[067]|36|9[0-289])\\d{6}", , , , "712345678"], [, , "800[1-3]\\d{5}", , , , "800123456"], [, , "90[1-3]\\d{6}", , , , "901123456"], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], "UG", 256, "00[057]", "0", , , "0", , , , [[, "(\\d{4})(\\d{5})", "$1 $2", ["202", "2024"], "0$1"], [, "(\\d{3})(\\d{6})", "$1 $2", ["[27-9]|4(?:6[45]|[7-9])"], "0$1"], [, "(\\d{2})(\\d{7})", "$1 $2", ["[34]"], "0$1"]], , [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]], [, , , , , , , , , [-1]], , , [, , , , , , , , , [-1]]],
8901
8994
  US: [, [
8902
8995
  ,
8903
8996
  ,
@@ -8913,7 +9006,7 @@ var intl_tel_input_default = intlTelInput;
8913
9006
  ], [
8914
9007
  ,
8915
9008
  ,
8916
- "(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[0-68]))\\d{4}|(?:2742|305[3-9]|(?:472|983)[2-47-9]|505[2-57-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
9009
+ "3052(?:0[0-8]|[1-9]\\d)\\d{4}|(?:2742|305[3-9])\\d{6}|(?:472|983)[2-47-9]\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
8917
9010
  ,
8918
9011
  ,
8919
9012
  ,
@@ -8925,7 +9018,7 @@ var intl_tel_input_default = intlTelInput;
8925
9018
  ], [
8926
9019
  ,
8927
9020
  ,
8928
- "(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[0-68]))\\d{4}|(?:2742|305[3-9]|(?:472|983)[2-47-9]|505[2-57-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
9021
+ "3052(?:0[0-8]|[1-9]\\d)\\d{4}|(?:2742|305[3-9])\\d{6}|(?:472|983)[2-47-9]\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}",
8929
9022
  ,
8930
9023
  ,
8931
9024
  ,