intl-tel-input 26.7.5 → 26.8.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.
Files changed (38) hide show
  1. package/angular/build/IntlTelInput.js +1471 -1375
  2. package/angular/build/IntlTelInputWithUtils.js +1553 -1438
  3. package/angular/build/types/intl-tel-input/angular.d.ts +12 -8
  4. package/angular/build/types/intl-tel-input/angularWithUtils.d.ts +12 -8
  5. package/angular/build/types/intl-tel-input.d.ts +4 -67
  6. package/angular/build/types/modules/core/numerals.d.ts +1 -2
  7. package/angular/build/types/modules/core/ui.d.ts +2 -34
  8. package/angular/build/types/modules/types/forEachInstanceArgsMap.d.ts +6 -0
  9. package/build/css/intlTelInput-no-assets.css +7 -2
  10. package/build/css/intlTelInput-no-assets.min.css +1 -1
  11. package/build/css/intlTelInput.css +7 -2
  12. package/build/css/intlTelInput.min.css +1 -1
  13. package/build/js/data.js +1 -1
  14. package/build/js/data.min.js +1 -1
  15. package/build/js/intlTelInput.d.ts +15 -103
  16. package/build/js/intlTelInput.js +639 -564
  17. package/build/js/intlTelInput.min.js +6 -6
  18. package/build/js/intlTelInputWithUtils.js +689 -595
  19. package/build/js/intlTelInputWithUtils.min.js +8 -8
  20. package/build/js/utils.js +11 -11
  21. package/package.json +7 -5
  22. package/react/build/IntlTelInput.cjs +646 -566
  23. package/react/build/IntlTelInput.d.ts +15 -103
  24. package/react/build/IntlTelInput.js +646 -566
  25. package/react/build/IntlTelInputWithUtils.cjs +696 -597
  26. package/react/build/IntlTelInputWithUtils.js +696 -597
  27. package/svelte/build/IntlTelInput.mjs +2092 -2059
  28. package/svelte/build/IntlTelInputWithUtils.mjs +2535 -2483
  29. package/vue/build/IntlTelInput.vue.d.ts +1 -53
  30. package/vue/build/IntlTelInputWithUtils.vue.d.ts +1 -53
  31. package/vue/build/exports/IntlTelInput.mjs +56 -38
  32. package/vue/build/exports/IntlTelInputWithUtils.mjs +451 -414
  33. package/vue/build/intl-tel-input-BdlwU9A8.mjs +3414 -0
  34. package/vue/build/intl-tel-input.d.ts +4 -67
  35. package/vue/build/modules/core/numerals.d.ts +1 -2
  36. package/vue/build/modules/core/ui.d.ts +2 -34
  37. package/vue/build/modules/types/forEachInstanceArgsMap.d.ts +6 -0
  38. package/vue/build/intl-tel-input-Blq9KJbV.mjs +0 -3393
@@ -2203,21 +2203,79 @@ var buildGlobeIcon = () => `
2203
2203
  </svg>`;
2204
2204
 
2205
2205
  // angular/build/temp/modules/core/ui.js
2206
- var UI = class _UI {
2206
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
2207
+ if (kind === "m") throw new TypeError("Private method is not writable");
2208
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2209
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
2210
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2211
+ };
2212
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
2213
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2214
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2215
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2216
+ };
2217
+ var _UI_instances;
2218
+ var _a;
2219
+ var _UI_options;
2220
+ var _UI_id;
2221
+ var _UI_isRTL;
2222
+ var _UI_originalPaddingLeft;
2223
+ var _UI_countries;
2224
+ var _UI_searchKeyupTimer;
2225
+ var _UI_inlineDropdownHeight;
2226
+ var _UI_selectedDialCode;
2227
+ var _UI_dropdownArrow;
2228
+ var _UI_dropdownContent;
2229
+ var _UI_searchIcon;
2230
+ var _UI_searchNoResults;
2231
+ var _UI_searchResultsA11yText;
2232
+ var _UI_dropdownForContainer;
2233
+ var _UI_selectedItem;
2234
+ var _UI_createWrapperAndInsert;
2235
+ var _UI_maybeBuildCountryContainer;
2236
+ var _UI_maybeEnsureDropdownWidthSet;
2237
+ var _UI_buildDropdownContent;
2238
+ var _UI_buildSearchUI;
2239
+ var _UI_maybeUpdateInputPaddingAndReveal;
2240
+ var _UI_maybeBuildHiddenInputs;
2241
+ var _UI_appendListItems;
2242
+ var _UI_updateInputPadding;
2243
+ var _UI_getBody;
2244
+ var _UI_getHiddenSelectedCountryWidth;
2245
+ var _UI_getHiddenInlineDropdownHeight;
2246
+ var _UI_updateSearchResultsA11yText;
2247
+ var _UI_doFilter;
2248
+ var _UI_updateSelectedItem;
2249
+ var _UI_filterCountries;
2250
+ var _UI_shouldPositionInlineDropdownBelowInput;
2251
+ var _UI_handleDropdownContainer;
2252
+ var UI = class {
2207
2253
  constructor(input, options, id2) {
2208
- this.searchKeyupTimer = null;
2209
- this.inlineDropdownHeight = null;
2210
- this.dropdownForContainer = null;
2254
+ _UI_instances.add(this);
2255
+ _UI_options.set(this, void 0);
2256
+ _UI_id.set(this, void 0);
2257
+ _UI_isRTL.set(this, void 0);
2258
+ _UI_originalPaddingLeft.set(this, void 0);
2259
+ _UI_countries.set(this, void 0);
2260
+ _UI_searchKeyupTimer.set(this, null);
2261
+ _UI_inlineDropdownHeight.set(this, null);
2262
+ _UI_selectedDialCode.set(this, void 0);
2263
+ _UI_dropdownArrow.set(this, void 0);
2264
+ _UI_dropdownContent.set(this, void 0);
2265
+ _UI_searchIcon.set(this, void 0);
2266
+ _UI_searchNoResults.set(this, void 0);
2267
+ _UI_searchResultsA11yText.set(this, void 0);
2268
+ _UI_dropdownForContainer.set(this, null);
2269
+ _UI_selectedItem.set(this, null);
2211
2270
  this.highlightedItem = null;
2212
- this.selectedItem = null;
2213
2271
  input.dataset.intlTelInputId = id2.toString();
2214
2272
  this.telInput = input;
2215
- this.options = options;
2216
- this.id = id2;
2273
+ __classPrivateFieldSet(this, _UI_options, options, "f");
2274
+ __classPrivateFieldSet(this, _UI_id, id2, "f");
2217
2275
  this.hadInitialPlaceholder = Boolean(input.getAttribute("placeholder"));
2218
- this.isRTL = !!this.telInput.closest("[dir=rtl]");
2219
- if (this.options.separateDialCode) {
2220
- this.originalPaddingLeft = this.telInput.style.paddingLeft;
2276
+ __classPrivateFieldSet(this, _UI_isRTL, !!this.telInput.closest("[dir=rtl]"), "f");
2277
+ if (__classPrivateFieldGet(this, _UI_options, "f").separateDialCode) {
2278
+ __classPrivateFieldSet(this, _UI_originalPaddingLeft, this.telInput.style.paddingLeft, "f");
2221
2279
  }
2222
2280
  }
2223
2281
  // Validate that the provided element is an HTMLInputElement.
@@ -2231,7 +2289,7 @@ var UI = class _UI {
2231
2289
  }
2232
2290
  //* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
2233
2291
  generateMarkup(countries) {
2234
- this.countries = countries;
2292
+ __classPrivateFieldSet(this, _UI_countries, countries, "f");
2235
2293
  this.telInput.classList.add("iti__tel-input");
2236
2294
  if (!this.telInput.hasAttribute("autocomplete")) {
2237
2295
  this.telInput.setAttribute("autocomplete", "tel");
@@ -2239,318 +2297,35 @@ var UI = class _UI {
2239
2297
  if (!this.telInput.hasAttribute("inputmode")) {
2240
2298
  this.telInput.setAttribute("inputmode", "tel");
2241
2299
  }
2242
- const wrapper = this._createWrapperAndInsert();
2243
- this._maybeBuildCountryContainer(wrapper);
2300
+ const wrapper = __classPrivateFieldGet(this, _UI_instances, "m", _UI_createWrapperAndInsert).call(this);
2301
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_maybeBuildCountryContainer).call(this, wrapper);
2244
2302
  wrapper.appendChild(this.telInput);
2245
- this._maybeUpdateInputPaddingAndReveal();
2246
- this._maybeBuildHiddenInputs(wrapper);
2247
- }
2248
- _createWrapperAndInsert() {
2249
- const { allowDropdown, showFlags, containerClass, useFullscreenPopup } = this.options;
2250
- const parentClasses = buildClassNames({
2251
- iti: true,
2252
- "iti--allow-dropdown": allowDropdown,
2253
- "iti--show-flags": showFlags,
2254
- "iti--inline-dropdown": !useFullscreenPopup,
2255
- [containerClass]: Boolean(containerClass)
2256
- });
2257
- const wrapper = createEl("div", { class: parentClasses });
2258
- if (this.isRTL) {
2259
- wrapper.setAttribute("dir", "ltr");
2260
- }
2261
- this.telInput.before(wrapper);
2262
- return wrapper;
2263
- }
2264
- _maybeBuildCountryContainer(wrapper) {
2265
- const { allowDropdown, separateDialCode, showFlags } = this.options;
2266
- if (allowDropdown || showFlags || separateDialCode) {
2267
- this.countryContainer = createEl(
2268
- "div",
2269
- // visibly hidden until we measure it's width to set the input padding correctly
2270
- { class: `iti__country-container ${CLASSES.V_HIDE}` },
2271
- wrapper
2272
- );
2273
- if (allowDropdown) {
2274
- this.selectedCountry = createEl("button", {
2275
- type: "button",
2276
- class: "iti__selected-country",
2277
- [ARIA.EXPANDED]: "false",
2278
- [ARIA.LABEL]: this.options.i18n.noCountrySelected,
2279
- [ARIA.HASPOPUP]: "dialog",
2280
- [ARIA.CONTROLS]: `iti-${this.id}__dropdown-content`
2281
- }, this.countryContainer);
2282
- if (this.telInput.disabled) {
2283
- this.selectedCountry.setAttribute("disabled", "true");
2284
- }
2285
- } else {
2286
- this.selectedCountry = createEl("div", { class: "iti__selected-country" }, this.countryContainer);
2287
- }
2288
- const selectedCountryPrimary = createEl("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
2289
- this.selectedCountryInner = createEl("div", { class: CLASSES.FLAG }, selectedCountryPrimary);
2290
- if (allowDropdown) {
2291
- this.dropdownArrow = createEl("div", { class: "iti__arrow", [ARIA.HIDDEN]: "true" }, selectedCountryPrimary);
2292
- }
2293
- if (separateDialCode) {
2294
- this.selectedDialCode = createEl("div", { class: "iti__selected-dial-code" }, this.selectedCountry);
2295
- }
2296
- if (allowDropdown) {
2297
- this._buildDropdownContent();
2298
- }
2299
- }
2300
- }
2301
- _maybeEnsureDropdownWidthSet() {
2302
- const { fixDropdownWidth } = this.options;
2303
- if (fixDropdownWidth && !this.dropdownContent.style.width) {
2304
- const inputWidth = this.telInput.offsetWidth;
2305
- if (inputWidth > 0) {
2306
- this.dropdownContent.style.width = `${inputWidth}px`;
2307
- }
2308
- }
2309
- }
2310
- _buildDropdownContent() {
2311
- const { fixDropdownWidth, useFullscreenPopup, countrySearch, i18n, dropdownContainer, containerClass } = this.options;
2312
- const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
2313
- this.dropdownContent = createEl("div", {
2314
- id: `iti-${this.id}__dropdown-content`,
2315
- class: `iti__dropdown-content ${CLASSES.HIDE} ${extraClasses}`,
2316
- role: "dialog",
2317
- [ARIA.MODAL]: "true"
2318
- });
2319
- if (this.isRTL) {
2320
- this.dropdownContent.setAttribute("dir", "rtl");
2321
- }
2322
- if (countrySearch) {
2323
- this._buildSearchUI();
2324
- }
2325
- this.countryList = createEl("ul", {
2326
- class: "iti__country-list",
2327
- id: `iti-${this.id}__country-listbox`,
2328
- role: "listbox",
2329
- [ARIA.LABEL]: i18n.countryListAriaLabel
2330
- }, this.dropdownContent);
2331
- this._appendListItems();
2332
- if (countrySearch) {
2333
- this.updateSearchResultsA11yText();
2334
- }
2335
- if (!useFullscreenPopup) {
2336
- this._maybeEnsureDropdownWidthSet();
2337
- this.inlineDropdownHeight = this.getHiddenInlineDropdownHeight();
2338
- if (countrySearch) {
2339
- this.dropdownContent.style.height = `${this.inlineDropdownHeight}px`;
2340
- }
2341
- }
2342
- if (dropdownContainer) {
2343
- const dropdownClasses = buildClassNames({
2344
- iti: true,
2345
- "iti--container": true,
2346
- "iti--fullscreen-popup": useFullscreenPopup,
2347
- "iti--inline-dropdown": !useFullscreenPopup,
2348
- [containerClass]: Boolean(containerClass)
2349
- });
2350
- this.dropdownForContainer = createEl("div", { class: dropdownClasses });
2351
- this.dropdownForContainer.appendChild(this.dropdownContent);
2352
- } else {
2353
- this.countryContainer.appendChild(this.dropdownContent);
2354
- }
2355
- }
2356
- _buildSearchUI() {
2357
- const { i18n, searchInputClass } = this.options;
2358
- const searchWrapper = createEl("div", { class: "iti__search-input-wrapper" }, this.dropdownContent);
2359
- this.searchIcon = createEl("span", {
2360
- class: "iti__search-icon",
2361
- [ARIA.HIDDEN]: "true"
2362
- }, searchWrapper);
2363
- this.searchIcon.innerHTML = buildSearchIcon();
2364
- this.searchInput = createEl("input", {
2365
- id: `iti-${this.id}__search-input`,
2366
- // Chrome says inputs need either a name or an id
2367
- type: "search",
2368
- class: `iti__search-input ${searchInputClass}`,
2369
- placeholder: i18n.searchPlaceholder,
2370
- // role=combobox + aria-autocomplete=list + aria-activedescendant allows maintaining focus on the search input while allowing users to navigate search results with up/down keyboard keys
2371
- role: "combobox",
2372
- [ARIA.EXPANDED]: "true",
2373
- [ARIA.LABEL]: i18n.searchPlaceholder,
2374
- [ARIA.CONTROLS]: `iti-${this.id}__country-listbox`,
2375
- [ARIA.AUTOCOMPLETE]: "list",
2376
- autocomplete: "off"
2377
- }, searchWrapper);
2378
- this.searchClearButton = createEl("button", {
2379
- type: "button",
2380
- class: `iti__search-clear ${CLASSES.HIDE}`,
2381
- [ARIA.LABEL]: i18n.clearSearchAriaLabel,
2382
- tabindex: "-1"
2383
- }, searchWrapper);
2384
- this.searchClearButton.innerHTML = buildClearIcon(this.id);
2385
- this.searchResultsA11yText = createEl("span", { class: "iti__a11y-text" }, this.dropdownContent);
2386
- this.searchNoResults = createEl("div", {
2387
- class: `iti__no-results ${CLASSES.HIDE}`,
2388
- [ARIA.HIDDEN]: "true"
2389
- // all a11y messaging happens in this.searchResultsA11yText
2390
- }, this.dropdownContent);
2391
- this.searchNoResults.textContent = i18n.searchEmptyState;
2392
- }
2393
- _maybeUpdateInputPaddingAndReveal() {
2394
- if (this.countryContainer) {
2395
- this.updateInputPadding();
2396
- this.countryContainer.classList.remove(CLASSES.V_HIDE);
2397
- }
2398
- }
2399
- _maybeBuildHiddenInputs(wrapper) {
2400
- var _a, _b;
2401
- const { hiddenInput } = this.options;
2402
- if (hiddenInput) {
2403
- const telInputName = this.telInput.getAttribute("name") || "";
2404
- const names = hiddenInput(telInputName);
2405
- if (names.phone) {
2406
- const existingInput = (_a = this.telInput.form) === null || _a === void 0 ? void 0 : _a.querySelector(`input[name="${names.phone}"]`);
2407
- if (existingInput) {
2408
- this.hiddenInput = existingInput;
2409
- } else {
2410
- this.hiddenInput = createEl("input", {
2411
- type: "hidden",
2412
- name: names.phone
2413
- });
2414
- wrapper.appendChild(this.hiddenInput);
2415
- }
2416
- }
2417
- if (names.country) {
2418
- const existingInput = (_b = this.telInput.form) === null || _b === void 0 ? void 0 : _b.querySelector(`input[name="${names.country}"]`);
2419
- if (existingInput) {
2420
- this.hiddenInputCountry = existingInput;
2421
- } else {
2422
- this.hiddenInputCountry = createEl("input", {
2423
- type: "hidden",
2424
- name: names.country
2425
- });
2426
- wrapper.appendChild(this.hiddenInputCountry);
2427
- }
2428
- }
2429
- }
2430
- }
2431
- //* For each country: add a country list item <li> to the countryList <ul> container.
2432
- _appendListItems() {
2433
- const frag = document.createDocumentFragment();
2434
- for (let i = 0; i < this.countries.length; i++) {
2435
- const c = this.countries[i];
2436
- const liClass = buildClassNames({
2437
- [CLASSES.COUNTRY_ITEM]: true
2438
- });
2439
- const listItem = createEl("li", {
2440
- id: `iti-${this.id}__item-${c.iso2}`,
2441
- class: liClass,
2442
- tabindex: "-1",
2443
- role: "option",
2444
- [ARIA.SELECTED]: "false"
2445
- });
2446
- listItem.dataset.dialCode = c.dialCode;
2447
- listItem.dataset.countryCode = c.iso2;
2448
- c.nodeById[this.id] = listItem;
2449
- if (this.options.showFlags) {
2450
- createEl("div", { class: `${CLASSES.FLAG} iti__${c.iso2}` }, listItem);
2451
- }
2452
- const nameEl = createEl("span", { class: "iti__country-name" }, listItem);
2453
- nameEl.textContent = `${c.name} `;
2454
- const dialEl = createEl("span", { class: "iti__dial-code" }, nameEl);
2455
- if (this.isRTL) {
2456
- dialEl.setAttribute("dir", "ltr");
2457
- }
2458
- dialEl.textContent = `(+${c.dialCode})`;
2459
- frag.appendChild(listItem);
2460
- }
2461
- this.countryList.appendChild(frag);
2462
- }
2463
- //* Update the input padding to make space for the selected country/dial code.
2464
- updateInputPadding() {
2465
- if (this.selectedCountry) {
2466
- const fallbackWidth = this.options.separateDialCode ? LAYOUT.SANE_SELECTED_WITH_DIAL_WIDTH : LAYOUT.SANE_SELECTED_NO_DIAL_WIDTH;
2467
- const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || fallbackWidth;
2468
- const inputPadding = selectedCountryWidth + LAYOUT.INPUT_PADDING_EXTRA_LEFT;
2469
- this.telInput.style.paddingLeft = `${inputPadding}px`;
2470
- }
2471
- }
2472
- static getBody() {
2473
- let body;
2474
- try {
2475
- body = window.top.document.body;
2476
- } catch (e) {
2477
- body = document.body;
2478
- }
2479
- return body;
2480
- }
2481
- //* When input is in a hidden container during init, we cannot calculate the selected country width.
2482
- //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
2483
- //* To get the right styling to apply, all we need is a shallow clone of the container,
2484
- //* and then to inject a deep clone of the selectedCountry element.
2485
- _getHiddenSelectedCountryWidth() {
2486
- if (this.telInput.parentNode) {
2487
- const body = _UI.getBody();
2488
- const containerClone = this.telInput.parentNode.cloneNode(false);
2489
- containerClone.style.visibility = "hidden";
2490
- body.appendChild(containerClone);
2491
- const countryContainerClone = this.countryContainer.cloneNode();
2492
- containerClone.appendChild(countryContainerClone);
2493
- const selectedCountryClone = this.selectedCountry.cloneNode(true);
2494
- countryContainerClone.appendChild(selectedCountryClone);
2495
- const width = selectedCountryClone.offsetWidth;
2496
- body.removeChild(containerClone);
2497
- return width;
2498
- }
2499
- return 0;
2500
- }
2501
- // this is run before we add the dropdown to the DOM
2502
- getHiddenInlineDropdownHeight() {
2503
- const body = _UI.getBody();
2504
- this.dropdownContent.classList.remove(CLASSES.HIDE);
2505
- const tempContainer = createEl("div", { class: "iti iti--inline-dropdown" });
2506
- tempContainer.appendChild(this.dropdownContent);
2507
- tempContainer.style.visibility = "hidden";
2508
- body.appendChild(tempContainer);
2509
- const height = this.dropdownContent.offsetHeight;
2510
- body.removeChild(tempContainer);
2511
- tempContainer.style.visibility = "";
2512
- this.dropdownContent.classList.add(CLASSES.HIDE);
2513
- return height > 0 ? height : LAYOUT.SANE_DROPDOWN_HEIGHT;
2514
- }
2515
- //* Update search results text (for a11y).
2516
- updateSearchResultsA11yText() {
2517
- const { i18n } = this.options;
2518
- const count = this.countryList.childElementCount;
2519
- this.searchResultsA11yText.textContent = i18n.searchSummaryAria(count);
2303
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_maybeUpdateInputPaddingAndReveal).call(this);
2304
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_maybeBuildHiddenInputs).call(this, wrapper);
2520
2305
  }
2521
2306
  //* Country search: Filter the countries according to the search query.
2522
2307
  filterCountriesByQuery(query) {
2523
2308
  let matchedCountries;
2524
2309
  if (query === "") {
2525
- matchedCountries = this.countries;
2526
- } else {
2527
- matchedCountries = getMatchedCountries(this.countries, query);
2528
- }
2529
- this.filterCountries(matchedCountries);
2530
- }
2531
- // Search input handlers
2532
- doFilter() {
2533
- const inputQuery = this.searchInput.value.trim();
2534
- this.filterCountriesByQuery(inputQuery);
2535
- if (this.searchInput.value) {
2536
- this.searchClearButton.classList.remove(CLASSES.HIDE);
2310
+ matchedCountries = __classPrivateFieldGet(this, _UI_countries, "f");
2537
2311
  } else {
2538
- this.searchClearButton.classList.add(CLASSES.HIDE);
2312
+ matchedCountries = getMatchedCountries(__classPrivateFieldGet(this, _UI_countries, "f"), query);
2539
2313
  }
2314
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_filterCountries).call(this, matchedCountries);
2540
2315
  }
2541
2316
  handleSearchChange() {
2542
- if (this.searchKeyupTimer) {
2543
- clearTimeout(this.searchKeyupTimer);
2317
+ if (__classPrivateFieldGet(this, _UI_searchKeyupTimer, "f")) {
2318
+ clearTimeout(__classPrivateFieldGet(this, _UI_searchKeyupTimer, "f"));
2544
2319
  }
2545
- this.searchKeyupTimer = setTimeout(() => {
2546
- this.doFilter();
2547
- this.searchKeyupTimer = null;
2548
- }, TIMINGS.SEARCH_DEBOUNCE_MS);
2320
+ __classPrivateFieldSet(this, _UI_searchKeyupTimer, setTimeout(() => {
2321
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_doFilter).call(this);
2322
+ __classPrivateFieldSet(this, _UI_searchKeyupTimer, null, "f");
2323
+ }, TIMINGS.SEARCH_DEBOUNCE_MS), "f");
2549
2324
  }
2550
2325
  handleSearchClear() {
2551
2326
  this.searchInput.value = "";
2552
2327
  this.searchInput.focus();
2553
- this.doFilter();
2328
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_doFilter).call(this);
2554
2329
  }
2555
2330
  //* Check if an element is visible within it's container, else scroll until it is.
2556
2331
  scrollTo(element) {
@@ -2579,7 +2354,7 @@ var UI = class _UI {
2579
2354
  this.highlightedItem = listItem;
2580
2355
  if (this.highlightedItem) {
2581
2356
  this.highlightedItem.classList.add(CLASSES.HIGHLIGHT);
2582
- if (this.options.countrySearch) {
2357
+ if (__classPrivateFieldGet(this, _UI_options, "f").countrySearch) {
2583
2358
  const activeDescendant = this.highlightedItem.getAttribute("id") || "";
2584
2359
  this.searchInput.setAttribute(ARIA.ACTIVE_DESCENDANT, activeDescendant);
2585
2360
  }
@@ -2590,8 +2365,8 @@ var UI = class _UI {
2590
2365
  }
2591
2366
  //* Highlight the next/prev item in the list (and ensure it is visible).
2592
2367
  handleUpDownKey(key) {
2593
- var _a, _b;
2594
- let next = key === KEYS.ARROW_UP ? (_a = this.highlightedItem) === null || _a === void 0 ? void 0 : _a.previousElementSibling : (_b = this.highlightedItem) === null || _b === void 0 ? void 0 : _b.nextElementSibling;
2368
+ var _b, _c;
2369
+ let next = key === KEYS.ARROW_UP ? (_b = this.highlightedItem) === null || _b === void 0 ? void 0 : _b.previousElementSibling : (_c = this.highlightedItem) === null || _c === void 0 ? void 0 : _c.nextElementSibling;
2595
2370
  if (!next && this.countryList.childElementCount > 1) {
2596
2371
  next = key === KEYS.ARROW_UP ? this.countryList.lastElementChild : this.countryList.firstElementChild;
2597
2372
  }
@@ -2600,54 +2375,11 @@ var UI = class _UI {
2600
2375
  this.highlightListItem(next, false);
2601
2376
  }
2602
2377
  }
2603
- // Update the selected list item in the dropdown
2604
- updateSelectedItem(iso2) {
2605
- var _a;
2606
- if (this.selectedItem && this.selectedItem.dataset.countryCode !== iso2) {
2607
- this.selectedItem.setAttribute(ARIA.SELECTED, "false");
2608
- (_a = this.selectedItem.querySelector(".iti__country-check")) === null || _a === void 0 ? void 0 : _a.remove();
2609
- this.selectedItem = null;
2610
- }
2611
- if (iso2 && !this.selectedItem) {
2612
- const newListItem = this.countryList.querySelector(`[data-country-code="${iso2}"]`);
2613
- if (newListItem) {
2614
- newListItem.setAttribute(ARIA.SELECTED, "true");
2615
- const checkIcon = createEl("span", { class: "iti__country-check", [ARIA.HIDDEN]: "true" }, newListItem);
2616
- checkIcon.innerHTML = buildCheckIcon();
2617
- this.selectedItem = newListItem;
2618
- }
2619
- }
2620
- }
2621
- //* Country search: Filter the country list to the given array of countries.
2622
- filterCountries(matchedCountries) {
2623
- this.countryList.innerHTML = "";
2624
- let noCountriesAddedYet = true;
2625
- for (const c of matchedCountries) {
2626
- const listItem = c.nodeById[this.id];
2627
- if (listItem) {
2628
- this.countryList.appendChild(listItem);
2629
- if (noCountriesAddedYet) {
2630
- this.highlightListItem(listItem, false);
2631
- noCountriesAddedYet = false;
2632
- }
2633
- }
2634
- }
2635
- if (noCountriesAddedYet) {
2636
- this.highlightListItem(null, false);
2637
- if (this.searchNoResults) {
2638
- this.searchNoResults.classList.remove(CLASSES.HIDE);
2639
- }
2640
- } else if (this.searchNoResults) {
2641
- this.searchNoResults.classList.add(CLASSES.HIDE);
2642
- }
2643
- this.countryList.scrollTop = 0;
2644
- this.updateSearchResultsA11yText();
2645
- }
2646
2378
  destroy() {
2647
2379
  this.telInput.iti = void 0;
2648
2380
  delete this.telInput.dataset.intlTelInputId;
2649
- if (this.options.separateDialCode) {
2650
- this.telInput.style.paddingLeft = this.originalPaddingLeft;
2381
+ if (__classPrivateFieldGet(this, _UI_options, "f").separateDialCode) {
2382
+ this.telInput.style.paddingLeft = __classPrivateFieldGet(this, _UI_originalPaddingLeft, "f");
2651
2383
  }
2652
2384
  const wrapper = this.telInput.parentNode;
2653
2385
  wrapper.before(this.telInput);
@@ -2656,41 +2388,41 @@ var UI = class _UI {
2656
2388
  this.countryContainer = null;
2657
2389
  this.selectedCountry = null;
2658
2390
  this.selectedCountryInner = null;
2659
- this.selectedDialCode = null;
2660
- this.dropdownArrow = null;
2661
- this.dropdownContent = null;
2662
2391
  this.searchInput = null;
2663
- this.searchIcon = null;
2664
2392
  this.searchClearButton = null;
2665
- this.searchNoResults = null;
2666
- this.searchResultsA11yText = null;
2667
2393
  this.countryList = null;
2668
- this.dropdownForContainer = null;
2669
2394
  this.hiddenInput = null;
2670
2395
  this.hiddenInputCountry = null;
2671
2396
  this.highlightedItem = null;
2672
- this.selectedItem = null;
2673
- for (const c of this.countries) {
2674
- delete c.nodeById[this.id];
2675
- }
2676
- this.countries = null;
2397
+ __classPrivateFieldSet(this, _UI_selectedDialCode, null, "f");
2398
+ __classPrivateFieldSet(this, _UI_dropdownArrow, null, "f");
2399
+ __classPrivateFieldSet(this, _UI_dropdownContent, null, "f");
2400
+ __classPrivateFieldSet(this, _UI_searchIcon, null, "f");
2401
+ __classPrivateFieldSet(this, _UI_searchNoResults, null, "f");
2402
+ __classPrivateFieldSet(this, _UI_searchResultsA11yText, null, "f");
2403
+ __classPrivateFieldSet(this, _UI_dropdownForContainer, null, "f");
2404
+ __classPrivateFieldSet(this, _UI_selectedItem, null, "f");
2405
+ for (const c of __classPrivateFieldGet(this, _UI_countries, "f")) {
2406
+ delete c.nodeById[__classPrivateFieldGet(this, _UI_id, "f")];
2407
+ }
2408
+ __classPrivateFieldSet(this, _UI_countries, null, "f");
2677
2409
  }
2678
2410
  // UI: Open the dropdown (DOM only).
2679
2411
  openDropdown() {
2680
- const { countrySearch, dropdownAlwaysOpen, dropdownContainer } = this.options;
2681
- this._maybeEnsureDropdownWidthSet();
2412
+ const { countrySearch, dropdownAlwaysOpen, dropdownContainer } = __classPrivateFieldGet(this, _UI_options, "f");
2413
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_maybeEnsureDropdownWidthSet).call(this);
2682
2414
  if (dropdownContainer) {
2683
- this._handleDropdownContainer();
2415
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_handleDropdownContainer).call(this);
2684
2416
  } else {
2685
- const positionBelow = this._shouldPositionInlineDropdownBelowInput();
2417
+ const positionBelow = __classPrivateFieldGet(this, _UI_instances, "m", _UI_shouldPositionInlineDropdownBelowInput).call(this);
2686
2418
  const distance = this.telInput.offsetHeight + LAYOUT.DROPDOWN_MARGIN;
2687
2419
  if (positionBelow) {
2688
- this.dropdownContent.style.top = `${distance}px`;
2420
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").style.top = `${distance}px`;
2689
2421
  } else {
2690
- this.dropdownContent.style.bottom = `${distance}px`;
2422
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").style.bottom = `${distance}px`;
2691
2423
  }
2692
2424
  }
2693
- this.dropdownContent.classList.remove(CLASSES.HIDE);
2425
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").classList.remove(CLASSES.HIDE);
2694
2426
  this.selectedCountry.setAttribute(ARIA.EXPANDED, "true");
2695
2427
  if (countrySearch) {
2696
2428
  const firstCountryItem = this.countryList.firstElementChild;
@@ -2702,12 +2434,12 @@ var UI = class _UI {
2702
2434
  this.searchInput.focus();
2703
2435
  }
2704
2436
  }
2705
- this.dropdownArrow.classList.add(CLASSES.ARROW_UP);
2437
+ __classPrivateFieldGet(this, _UI_dropdownArrow, "f").classList.add(CLASSES.ARROW_UP);
2706
2438
  }
2707
2439
  // UI: Close the dropdown (DOM only).
2708
2440
  closeDropdown() {
2709
- const { countrySearch, dropdownContainer } = this.options;
2710
- this.dropdownContent.classList.add(CLASSES.HIDE);
2441
+ const { countrySearch, dropdownContainer } = __classPrivateFieldGet(this, _UI_options, "f");
2442
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").classList.add(CLASSES.HIDE);
2711
2443
  this.selectedCountry.setAttribute(ARIA.EXPANDED, "false");
2712
2444
  if (countrySearch) {
2713
2445
  this.searchInput.removeAttribute(ARIA.ACTIVE_DESCENDANT);
@@ -2716,53 +2448,25 @@ var UI = class _UI {
2716
2448
  this.highlightedItem = null;
2717
2449
  }
2718
2450
  }
2719
- this.dropdownArrow.classList.remove(CLASSES.ARROW_UP);
2451
+ __classPrivateFieldGet(this, _UI_dropdownArrow, "f").classList.remove(CLASSES.ARROW_UP);
2720
2452
  if (dropdownContainer) {
2721
- this.dropdownForContainer.remove();
2722
- this.dropdownForContainer.style.top = "";
2723
- this.dropdownForContainer.style.bottom = "";
2453
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").remove();
2454
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").style.top = "";
2455
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").style.bottom = "";
2724
2456
  } else {
2725
- this.dropdownContent.style.top = "";
2726
- this.dropdownContent.style.bottom = "";
2457
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").style.top = "";
2458
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").style.bottom = "";
2727
2459
  }
2728
2460
  }
2729
- _shouldPositionInlineDropdownBelowInput() {
2730
- if (this.options.dropdownAlwaysOpen) {
2731
- return true;
2732
- }
2733
- const inputPos = this.telInput.getBoundingClientRect();
2734
- const spaceAbove = inputPos.top;
2735
- const spaceBelow = window.innerHeight - inputPos.bottom;
2736
- return spaceBelow >= this.inlineDropdownHeight || spaceBelow >= spaceAbove;
2737
- }
2738
- // inject dropdown into container and apply positioning styles
2739
- _handleDropdownContainer() {
2740
- const { dropdownContainer, useFullscreenPopup } = this.options;
2741
- if (!dropdownContainer) {
2742
- return;
2743
- }
2744
- if (!useFullscreenPopup) {
2745
- const inputPos = this.telInput.getBoundingClientRect();
2746
- this.dropdownForContainer.style.left = `${inputPos.left}px`;
2747
- const positionBelow = this._shouldPositionInlineDropdownBelowInput();
2748
- if (positionBelow) {
2749
- this.dropdownForContainer.style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
2750
- } else {
2751
- this.dropdownForContainer.style.top = "unset";
2752
- this.dropdownForContainer.style.bottom = `${window.innerHeight - inputPos.top + LAYOUT.DROPDOWN_MARGIN}px`;
2753
- }
2754
- }
2755
- dropdownContainer.appendChild(this.dropdownForContainer);
2756
- }
2757
2461
  // UI: Whether the dropdown is currently closed (hidden).
2758
2462
  isDropdownClosed() {
2759
- return this.dropdownContent.classList.contains(CLASSES.HIDE);
2463
+ return __classPrivateFieldGet(this, _UI_dropdownContent, "f").classList.contains(CLASSES.HIDE);
2760
2464
  }
2761
2465
  setCountry(selectedCountryData) {
2762
- const { allowDropdown, showFlags, separateDialCode, i18n } = this.options;
2466
+ const { allowDropdown, showFlags, separateDialCode, i18n } = __classPrivateFieldGet(this, _UI_options, "f");
2763
2467
  const { name, dialCode, iso2 = "" } = selectedCountryData;
2764
2468
  if (allowDropdown) {
2765
- this.updateSelectedItem(iso2);
2469
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_updateSelectedItem).call(this, iso2);
2766
2470
  }
2767
2471
  if (this.selectedCountry) {
2768
2472
  const flagClass = iso2 && showFlags ? `${CLASSES.FLAG} iti__${iso2}` : `${CLASSES.FLAG} ${CLASSES.GLOBE}`;
@@ -2783,11 +2487,337 @@ var UI = class _UI {
2783
2487
  }
2784
2488
  if (separateDialCode) {
2785
2489
  const fullDialCode = dialCode ? `+${dialCode}` : "";
2786
- this.selectedDialCode.textContent = fullDialCode;
2787
- this.updateInputPadding();
2490
+ __classPrivateFieldGet(this, _UI_selectedDialCode, "f").textContent = fullDialCode;
2491
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_updateInputPadding).call(this);
2492
+ }
2493
+ }
2494
+ };
2495
+ _a = UI, _UI_options = /* @__PURE__ */ new WeakMap(), _UI_id = /* @__PURE__ */ new WeakMap(), _UI_isRTL = /* @__PURE__ */ new WeakMap(), _UI_originalPaddingLeft = /* @__PURE__ */ new WeakMap(), _UI_countries = /* @__PURE__ */ new WeakMap(), _UI_searchKeyupTimer = /* @__PURE__ */ new WeakMap(), _UI_inlineDropdownHeight = /* @__PURE__ */ new WeakMap(), _UI_selectedDialCode = /* @__PURE__ */ new WeakMap(), _UI_dropdownArrow = /* @__PURE__ */ new WeakMap(), _UI_dropdownContent = /* @__PURE__ */ new WeakMap(), _UI_searchIcon = /* @__PURE__ */ new WeakMap(), _UI_searchNoResults = /* @__PURE__ */ new WeakMap(), _UI_searchResultsA11yText = /* @__PURE__ */ new WeakMap(), _UI_dropdownForContainer = /* @__PURE__ */ new WeakMap(), _UI_selectedItem = /* @__PURE__ */ new WeakMap(), _UI_instances = /* @__PURE__ */ new WeakSet(), _UI_createWrapperAndInsert = function _UI_createWrapperAndInsert2() {
2496
+ const { allowDropdown, showFlags, containerClass, useFullscreenPopup } = __classPrivateFieldGet(this, _UI_options, "f");
2497
+ const parentClasses = buildClassNames({
2498
+ iti: true,
2499
+ "iti--allow-dropdown": allowDropdown,
2500
+ "iti--show-flags": showFlags,
2501
+ "iti--inline-dropdown": !useFullscreenPopup,
2502
+ [containerClass]: Boolean(containerClass)
2503
+ });
2504
+ const wrapper = createEl("div", { class: parentClasses });
2505
+ if (__classPrivateFieldGet(this, _UI_isRTL, "f")) {
2506
+ wrapper.setAttribute("dir", "ltr");
2507
+ }
2508
+ this.telInput.before(wrapper);
2509
+ return wrapper;
2510
+ }, _UI_maybeBuildCountryContainer = function _UI_maybeBuildCountryContainer2(wrapper) {
2511
+ const { allowDropdown, separateDialCode, showFlags } = __classPrivateFieldGet(this, _UI_options, "f");
2512
+ if (allowDropdown || showFlags || separateDialCode) {
2513
+ this.countryContainer = createEl(
2514
+ "div",
2515
+ // visibly hidden until we measure it's width to set the input padding correctly
2516
+ { class: `iti__country-container ${CLASSES.V_HIDE}` },
2517
+ wrapper
2518
+ );
2519
+ if (allowDropdown) {
2520
+ this.selectedCountry = createEl("button", {
2521
+ type: "button",
2522
+ class: "iti__selected-country",
2523
+ [ARIA.EXPANDED]: "false",
2524
+ [ARIA.LABEL]: __classPrivateFieldGet(this, _UI_options, "f").i18n.noCountrySelected,
2525
+ [ARIA.HASPOPUP]: "dialog",
2526
+ [ARIA.CONTROLS]: `iti-${__classPrivateFieldGet(this, _UI_id, "f")}__dropdown-content`
2527
+ }, this.countryContainer);
2528
+ if (this.telInput.disabled) {
2529
+ this.selectedCountry.setAttribute("disabled", "true");
2530
+ }
2531
+ } else {
2532
+ this.selectedCountry = createEl("div", { class: "iti__selected-country" }, this.countryContainer);
2533
+ }
2534
+ const selectedCountryPrimary = createEl("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
2535
+ this.selectedCountryInner = createEl("div", { class: CLASSES.FLAG }, selectedCountryPrimary);
2536
+ if (allowDropdown) {
2537
+ __classPrivateFieldSet(this, _UI_dropdownArrow, createEl("div", { class: "iti__arrow", [ARIA.HIDDEN]: "true" }, selectedCountryPrimary), "f");
2538
+ }
2539
+ if (separateDialCode) {
2540
+ __classPrivateFieldSet(this, _UI_selectedDialCode, createEl("div", { class: "iti__selected-dial-code" }, this.selectedCountry), "f");
2541
+ }
2542
+ if (allowDropdown) {
2543
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_buildDropdownContent).call(this);
2544
+ }
2545
+ }
2546
+ }, _UI_maybeEnsureDropdownWidthSet = function _UI_maybeEnsureDropdownWidthSet2() {
2547
+ const { fixDropdownWidth } = __classPrivateFieldGet(this, _UI_options, "f");
2548
+ if (fixDropdownWidth && !__classPrivateFieldGet(this, _UI_dropdownContent, "f").style.width) {
2549
+ const inputWidth = this.telInput.offsetWidth;
2550
+ if (inputWidth > 0) {
2551
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").style.width = `${inputWidth}px`;
2552
+ }
2553
+ }
2554
+ }, _UI_buildDropdownContent = function _UI_buildDropdownContent2() {
2555
+ const { fixDropdownWidth, useFullscreenPopup, countrySearch, i18n, dropdownContainer, containerClass } = __classPrivateFieldGet(this, _UI_options, "f");
2556
+ const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
2557
+ __classPrivateFieldSet(this, _UI_dropdownContent, createEl("div", {
2558
+ id: `iti-${__classPrivateFieldGet(this, _UI_id, "f")}__dropdown-content`,
2559
+ class: `iti__dropdown-content ${CLASSES.HIDE} ${extraClasses}`,
2560
+ role: "dialog",
2561
+ [ARIA.MODAL]: "true"
2562
+ }), "f");
2563
+ if (__classPrivateFieldGet(this, _UI_isRTL, "f")) {
2564
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").setAttribute("dir", "rtl");
2565
+ }
2566
+ if (countrySearch) {
2567
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_buildSearchUI).call(this);
2568
+ }
2569
+ this.countryList = createEl("ul", {
2570
+ class: "iti__country-list",
2571
+ id: `iti-${__classPrivateFieldGet(this, _UI_id, "f")}__country-listbox`,
2572
+ role: "listbox",
2573
+ [ARIA.LABEL]: i18n.countryListAriaLabel
2574
+ }, __classPrivateFieldGet(this, _UI_dropdownContent, "f"));
2575
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_appendListItems).call(this);
2576
+ if (countrySearch) {
2577
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_updateSearchResultsA11yText).call(this);
2578
+ }
2579
+ if (!useFullscreenPopup) {
2580
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_maybeEnsureDropdownWidthSet).call(this);
2581
+ __classPrivateFieldSet(this, _UI_inlineDropdownHeight, __classPrivateFieldGet(this, _UI_instances, "m", _UI_getHiddenInlineDropdownHeight).call(this), "f");
2582
+ if (countrySearch) {
2583
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").style.height = `${__classPrivateFieldGet(this, _UI_inlineDropdownHeight, "f")}px`;
2584
+ }
2585
+ }
2586
+ if (dropdownContainer) {
2587
+ const dropdownClasses = buildClassNames({
2588
+ iti: true,
2589
+ "iti--container": true,
2590
+ "iti--fullscreen-popup": useFullscreenPopup,
2591
+ "iti--inline-dropdown": !useFullscreenPopup,
2592
+ [containerClass]: Boolean(containerClass)
2593
+ });
2594
+ __classPrivateFieldSet(this, _UI_dropdownForContainer, createEl("div", { class: dropdownClasses }), "f");
2595
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").appendChild(__classPrivateFieldGet(this, _UI_dropdownContent, "f"));
2596
+ } else {
2597
+ this.countryContainer.appendChild(__classPrivateFieldGet(this, _UI_dropdownContent, "f"));
2598
+ }
2599
+ }, _UI_buildSearchUI = function _UI_buildSearchUI2() {
2600
+ const { i18n, searchInputClass } = __classPrivateFieldGet(this, _UI_options, "f");
2601
+ const searchWrapper = createEl("div", { class: "iti__search-input-wrapper" }, __classPrivateFieldGet(this, _UI_dropdownContent, "f"));
2602
+ __classPrivateFieldSet(this, _UI_searchIcon, createEl("span", {
2603
+ class: "iti__search-icon",
2604
+ [ARIA.HIDDEN]: "true"
2605
+ }, searchWrapper), "f");
2606
+ __classPrivateFieldGet(this, _UI_searchIcon, "f").innerHTML = buildSearchIcon();
2607
+ this.searchInput = createEl("input", {
2608
+ id: `iti-${__classPrivateFieldGet(this, _UI_id, "f")}__search-input`,
2609
+ // Chrome says inputs need either a name or an id
2610
+ type: "search",
2611
+ class: `iti__search-input ${searchInputClass}`,
2612
+ placeholder: i18n.searchPlaceholder,
2613
+ // role=combobox + aria-autocomplete=list + aria-activedescendant allows maintaining focus on the search input while allowing users to navigate search results with up/down keyboard keys
2614
+ role: "combobox",
2615
+ [ARIA.EXPANDED]: "true",
2616
+ [ARIA.LABEL]: i18n.searchPlaceholder,
2617
+ [ARIA.CONTROLS]: `iti-${__classPrivateFieldGet(this, _UI_id, "f")}__country-listbox`,
2618
+ [ARIA.AUTOCOMPLETE]: "list",
2619
+ autocomplete: "off"
2620
+ }, searchWrapper);
2621
+ this.searchClearButton = createEl("button", {
2622
+ type: "button",
2623
+ class: `iti__search-clear ${CLASSES.HIDE}`,
2624
+ [ARIA.LABEL]: i18n.clearSearchAriaLabel,
2625
+ tabindex: "-1"
2626
+ }, searchWrapper);
2627
+ this.searchClearButton.innerHTML = buildClearIcon(__classPrivateFieldGet(this, _UI_id, "f"));
2628
+ __classPrivateFieldSet(this, _UI_searchResultsA11yText, createEl("span", { class: "iti__a11y-text" }, __classPrivateFieldGet(this, _UI_dropdownContent, "f")), "f");
2629
+ __classPrivateFieldSet(this, _UI_searchNoResults, createEl("div", {
2630
+ class: `iti__no-results ${CLASSES.HIDE}`,
2631
+ [ARIA.HIDDEN]: "true"
2632
+ // all a11y messaging happens in this.#searchResultsA11yText
2633
+ }, __classPrivateFieldGet(this, _UI_dropdownContent, "f")), "f");
2634
+ __classPrivateFieldGet(this, _UI_searchNoResults, "f").textContent = i18n.searchEmptyState;
2635
+ }, _UI_maybeUpdateInputPaddingAndReveal = function _UI_maybeUpdateInputPaddingAndReveal2() {
2636
+ if (this.countryContainer) {
2637
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_updateInputPadding).call(this);
2638
+ this.countryContainer.classList.remove(CLASSES.V_HIDE);
2639
+ }
2640
+ }, _UI_maybeBuildHiddenInputs = function _UI_maybeBuildHiddenInputs2(wrapper) {
2641
+ var _b, _c;
2642
+ const { hiddenInput } = __classPrivateFieldGet(this, _UI_options, "f");
2643
+ if (hiddenInput) {
2644
+ const telInputName = this.telInput.getAttribute("name") || "";
2645
+ const names = hiddenInput(telInputName);
2646
+ if (names.phone) {
2647
+ const existingInput = (_b = this.telInput.form) === null || _b === void 0 ? void 0 : _b.querySelector(`input[name="${names.phone}"]`);
2648
+ if (existingInput) {
2649
+ this.hiddenInput = existingInput;
2650
+ } else {
2651
+ this.hiddenInput = createEl("input", {
2652
+ type: "hidden",
2653
+ name: names.phone
2654
+ });
2655
+ wrapper.appendChild(this.hiddenInput);
2656
+ }
2657
+ }
2658
+ if (names.country) {
2659
+ const existingInput = (_c = this.telInput.form) === null || _c === void 0 ? void 0 : _c.querySelector(`input[name="${names.country}"]`);
2660
+ if (existingInput) {
2661
+ this.hiddenInputCountry = existingInput;
2662
+ } else {
2663
+ this.hiddenInputCountry = createEl("input", {
2664
+ type: "hidden",
2665
+ name: names.country
2666
+ });
2667
+ wrapper.appendChild(this.hiddenInputCountry);
2668
+ }
2669
+ }
2670
+ }
2671
+ }, _UI_appendListItems = function _UI_appendListItems2() {
2672
+ const frag = document.createDocumentFragment();
2673
+ for (let i = 0; i < __classPrivateFieldGet(this, _UI_countries, "f").length; i++) {
2674
+ const c = __classPrivateFieldGet(this, _UI_countries, "f")[i];
2675
+ const liClass = buildClassNames({
2676
+ [CLASSES.COUNTRY_ITEM]: true
2677
+ });
2678
+ const listItem = createEl("li", {
2679
+ id: `iti-${__classPrivateFieldGet(this, _UI_id, "f")}__item-${c.iso2}`,
2680
+ class: liClass,
2681
+ tabindex: "-1",
2682
+ role: "option",
2683
+ [ARIA.SELECTED]: "false"
2684
+ });
2685
+ listItem.dataset.dialCode = c.dialCode;
2686
+ listItem.dataset.countryCode = c.iso2;
2687
+ c.nodeById[__classPrivateFieldGet(this, _UI_id, "f")] = listItem;
2688
+ if (__classPrivateFieldGet(this, _UI_options, "f").showFlags) {
2689
+ createEl("div", { class: `${CLASSES.FLAG} iti__${c.iso2}` }, listItem);
2690
+ }
2691
+ const nameEl = createEl("span", { class: "iti__country-name" }, listItem);
2692
+ nameEl.textContent = `${c.name} `;
2693
+ const dialEl = createEl("span", { class: "iti__dial-code" }, nameEl);
2694
+ if (__classPrivateFieldGet(this, _UI_isRTL, "f")) {
2695
+ dialEl.setAttribute("dir", "ltr");
2696
+ }
2697
+ dialEl.textContent = `(+${c.dialCode})`;
2698
+ frag.appendChild(listItem);
2699
+ }
2700
+ this.countryList.appendChild(frag);
2701
+ }, _UI_updateInputPadding = function _UI_updateInputPadding2() {
2702
+ if (this.selectedCountry) {
2703
+ const fallbackWidth = __classPrivateFieldGet(this, _UI_options, "f").separateDialCode ? LAYOUT.SANE_SELECTED_WITH_DIAL_WIDTH : LAYOUT.SANE_SELECTED_NO_DIAL_WIDTH;
2704
+ const selectedCountryWidth = this.selectedCountry.offsetWidth || __classPrivateFieldGet(this, _UI_instances, "m", _UI_getHiddenSelectedCountryWidth).call(this) || fallbackWidth;
2705
+ const inputPadding = selectedCountryWidth + LAYOUT.INPUT_PADDING_EXTRA_LEFT;
2706
+ this.telInput.style.paddingLeft = `${inputPadding}px`;
2707
+ }
2708
+ }, _UI_getBody = function _UI_getBody2() {
2709
+ let body;
2710
+ try {
2711
+ body = window.top.document.body;
2712
+ } catch (e) {
2713
+ body = document.body;
2714
+ }
2715
+ return body;
2716
+ }, _UI_getHiddenSelectedCountryWidth = function _UI_getHiddenSelectedCountryWidth2() {
2717
+ if (this.telInput.parentNode) {
2718
+ const body = __classPrivateFieldGet(_a, _a, "m", _UI_getBody).call(_a);
2719
+ const containerClone = this.telInput.parentNode.cloneNode(false);
2720
+ containerClone.style.visibility = "hidden";
2721
+ body.appendChild(containerClone);
2722
+ const countryContainerClone = this.countryContainer.cloneNode();
2723
+ containerClone.appendChild(countryContainerClone);
2724
+ const selectedCountryClone = this.selectedCountry.cloneNode(true);
2725
+ countryContainerClone.appendChild(selectedCountryClone);
2726
+ const width = selectedCountryClone.offsetWidth;
2727
+ body.removeChild(containerClone);
2728
+ return width;
2729
+ }
2730
+ return 0;
2731
+ }, _UI_getHiddenInlineDropdownHeight = function _UI_getHiddenInlineDropdownHeight2() {
2732
+ const body = __classPrivateFieldGet(_a, _a, "m", _UI_getBody).call(_a);
2733
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").classList.remove(CLASSES.HIDE);
2734
+ const tempContainer = createEl("div", { class: "iti iti--inline-dropdown" });
2735
+ tempContainer.appendChild(__classPrivateFieldGet(this, _UI_dropdownContent, "f"));
2736
+ tempContainer.style.visibility = "hidden";
2737
+ body.appendChild(tempContainer);
2738
+ const height = __classPrivateFieldGet(this, _UI_dropdownContent, "f").offsetHeight;
2739
+ body.removeChild(tempContainer);
2740
+ tempContainer.style.visibility = "";
2741
+ __classPrivateFieldGet(this, _UI_dropdownContent, "f").classList.add(CLASSES.HIDE);
2742
+ return height > 0 ? height : LAYOUT.SANE_DROPDOWN_HEIGHT;
2743
+ }, _UI_updateSearchResultsA11yText = function _UI_updateSearchResultsA11yText2() {
2744
+ const { i18n } = __classPrivateFieldGet(this, _UI_options, "f");
2745
+ const count = this.countryList.childElementCount;
2746
+ __classPrivateFieldGet(this, _UI_searchResultsA11yText, "f").textContent = i18n.searchSummaryAria(count);
2747
+ }, _UI_doFilter = function _UI_doFilter2() {
2748
+ const inputQuery = this.searchInput.value.trim();
2749
+ this.filterCountriesByQuery(inputQuery);
2750
+ if (this.searchInput.value) {
2751
+ this.searchClearButton.classList.remove(CLASSES.HIDE);
2752
+ } else {
2753
+ this.searchClearButton.classList.add(CLASSES.HIDE);
2754
+ }
2755
+ }, _UI_updateSelectedItem = function _UI_updateSelectedItem2(iso2) {
2756
+ var _b;
2757
+ if (__classPrivateFieldGet(this, _UI_selectedItem, "f") && __classPrivateFieldGet(this, _UI_selectedItem, "f").dataset.countryCode !== iso2) {
2758
+ __classPrivateFieldGet(this, _UI_selectedItem, "f").setAttribute(ARIA.SELECTED, "false");
2759
+ (_b = __classPrivateFieldGet(this, _UI_selectedItem, "f").querySelector(".iti__country-check")) === null || _b === void 0 ? void 0 : _b.remove();
2760
+ __classPrivateFieldSet(this, _UI_selectedItem, null, "f");
2761
+ }
2762
+ if (iso2 && !__classPrivateFieldGet(this, _UI_selectedItem, "f")) {
2763
+ const newListItem = this.countryList.querySelector(`[data-country-code="${iso2}"]`);
2764
+ if (newListItem) {
2765
+ newListItem.setAttribute(ARIA.SELECTED, "true");
2766
+ const checkIcon = createEl("span", { class: "iti__country-check", [ARIA.HIDDEN]: "true" }, newListItem);
2767
+ checkIcon.innerHTML = buildCheckIcon();
2768
+ __classPrivateFieldSet(this, _UI_selectedItem, newListItem, "f");
2769
+ }
2770
+ }
2771
+ }, _UI_filterCountries = function _UI_filterCountries2(matchedCountries) {
2772
+ this.countryList.innerHTML = "";
2773
+ let noCountriesAddedYet = true;
2774
+ for (const c of matchedCountries) {
2775
+ const listItem = c.nodeById[__classPrivateFieldGet(this, _UI_id, "f")];
2776
+ if (listItem) {
2777
+ this.countryList.appendChild(listItem);
2778
+ if (noCountriesAddedYet) {
2779
+ this.highlightListItem(listItem, false);
2780
+ noCountriesAddedYet = false;
2781
+ }
2782
+ }
2783
+ }
2784
+ if (noCountriesAddedYet) {
2785
+ this.highlightListItem(null, false);
2786
+ if (__classPrivateFieldGet(this, _UI_searchNoResults, "f")) {
2787
+ __classPrivateFieldGet(this, _UI_searchNoResults, "f").classList.remove(CLASSES.HIDE);
2788
+ }
2789
+ } else if (__classPrivateFieldGet(this, _UI_searchNoResults, "f")) {
2790
+ __classPrivateFieldGet(this, _UI_searchNoResults, "f").classList.add(CLASSES.HIDE);
2791
+ }
2792
+ this.countryList.scrollTop = 0;
2793
+ __classPrivateFieldGet(this, _UI_instances, "m", _UI_updateSearchResultsA11yText).call(this);
2794
+ }, _UI_shouldPositionInlineDropdownBelowInput = function _UI_shouldPositionInlineDropdownBelowInput2() {
2795
+ if (__classPrivateFieldGet(this, _UI_options, "f").dropdownAlwaysOpen) {
2796
+ return true;
2797
+ }
2798
+ const inputPos = this.telInput.getBoundingClientRect();
2799
+ const spaceAbove = inputPos.top;
2800
+ const spaceBelow = window.innerHeight - inputPos.bottom;
2801
+ return spaceBelow >= __classPrivateFieldGet(this, _UI_inlineDropdownHeight, "f") || spaceBelow >= spaceAbove;
2802
+ }, _UI_handleDropdownContainer = function _UI_handleDropdownContainer2() {
2803
+ const { dropdownContainer, useFullscreenPopup } = __classPrivateFieldGet(this, _UI_options, "f");
2804
+ if (!dropdownContainer) {
2805
+ return;
2806
+ }
2807
+ if (!useFullscreenPopup) {
2808
+ const inputPos = this.telInput.getBoundingClientRect();
2809
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").style.left = `${inputPos.left}px`;
2810
+ const positionBelow = __classPrivateFieldGet(this, _UI_instances, "m", _UI_shouldPositionInlineDropdownBelowInput).call(this);
2811
+ if (positionBelow) {
2812
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").style.top = `${inputPos.bottom + LAYOUT.DROPDOWN_MARGIN}px`;
2813
+ } else {
2814
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").style.top = "unset";
2815
+ __classPrivateFieldGet(this, _UI_dropdownForContainer, "f").style.bottom = `${window.innerHeight - inputPos.top + LAYOUT.DROPDOWN_MARGIN}px`;
2788
2816
  }
2789
2817
  }
2818
+ dropdownContainer.appendChild(__classPrivateFieldGet(this, _UI_dropdownForContainer, "f"));
2790
2819
  };
2820
+ var ui_default = UI;
2791
2821
 
2792
2822
  // angular/build/temp/modules/data/country-data.js
2793
2823
  var processAllCountries = (options) => {
@@ -2825,7 +2855,7 @@ var processDialCodes = (countries) => {
2825
2855
  const dialCodes = /* @__PURE__ */ new Set();
2826
2856
  let dialCodeMaxLen = 0;
2827
2857
  const dialCodeToIso2Map = {};
2828
- const _addToDialCodeMap = (iso2, dialCode) => {
2858
+ const addToDialCodeMap = (iso2, dialCode) => {
2829
2859
  if (!iso2 || !dialCode) {
2830
2860
  return;
2831
2861
  }
@@ -2848,19 +2878,19 @@ var processDialCodes = (countries) => {
2848
2878
  }
2849
2879
  for (let k = 1; k < c.dialCode.length; k++) {
2850
2880
  const partialDialCode = c.dialCode.substring(0, k);
2851
- _addToDialCodeMap(c.iso2, partialDialCode);
2881
+ addToDialCodeMap(c.iso2, partialDialCode);
2852
2882
  }
2853
- _addToDialCodeMap(c.iso2, c.dialCode);
2883
+ addToDialCodeMap(c.iso2, c.dialCode);
2854
2884
  if (c.areaCodes) {
2855
2885
  const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
2856
2886
  for (const areaCode of c.areaCodes) {
2857
2887
  for (let k = 1; k < areaCode.length; k++) {
2858
2888
  const partialAreaCode = areaCode.substring(0, k);
2859
2889
  const partialDialCode = c.dialCode + partialAreaCode;
2860
- _addToDialCodeMap(rootIso2Code, partialDialCode);
2861
- _addToDialCodeMap(c.iso2, partialDialCode);
2890
+ addToDialCodeMap(rootIso2Code, partialDialCode);
2891
+ addToDialCodeMap(c.iso2, partialDialCode);
2862
2892
  }
2863
- _addToDialCodeMap(c.iso2, c.dialCode + areaCode);
2893
+ addToDialCodeMap(c.iso2, c.dialCode + areaCode);
2864
2894
  }
2865
2895
  }
2866
2896
  }
@@ -2983,28 +3013,34 @@ var isRegionlessNanp = (number) => {
2983
3013
  };
2984
3014
 
2985
3015
  // angular/build/temp/modules/core/numerals.js
3016
+ var __classPrivateFieldSet2 = function(receiver, state, value, kind, f) {
3017
+ if (kind === "m") throw new TypeError("Private method is not writable");
3018
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3019
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3020
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3021
+ };
3022
+ var __classPrivateFieldGet2 = function(receiver, state, kind, f) {
3023
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3024
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3025
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3026
+ };
3027
+ var _Numerals_instances;
3028
+ var _Numerals_userNumeralSet;
3029
+ var _Numerals_updateNumeralSet;
2986
3030
  var Numerals = class {
2987
3031
  constructor() {
2988
- }
2989
- // If any Arabic-Indic digits, then label it as that set. Same for Persian. Otherwise assume ASCII.
2990
- updateNumeralSet(str) {
2991
- if (/[\u0660-\u0669]/.test(str)) {
2992
- this.userNumeralSet = "arabic-indic";
2993
- } else if (/[\u06F0-\u06F9]/.test(str)) {
2994
- this.userNumeralSet = "persian";
2995
- } else {
2996
- this.userNumeralSet = "ascii";
2997
- }
3032
+ _Numerals_instances.add(this);
3033
+ _Numerals_userNumeralSet.set(this, void 0);
2998
3034
  }
2999
3035
  // Denormalise ASCII 0-9 to the user's numeral set, if known. If not known, return the string as-is.
3000
3036
  denormalise(str, currentInputValue) {
3001
- if (!this.userNumeralSet) {
3002
- this.updateNumeralSet(currentInputValue);
3037
+ if (!__classPrivateFieldGet2(this, _Numerals_userNumeralSet, "f")) {
3038
+ __classPrivateFieldGet2(this, _Numerals_instances, "m", _Numerals_updateNumeralSet).call(this, currentInputValue);
3003
3039
  }
3004
- if (this.userNumeralSet === "ascii") {
3040
+ if (__classPrivateFieldGet2(this, _Numerals_userNumeralSet, "f") === "ascii") {
3005
3041
  return str;
3006
3042
  }
3007
- const base = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
3043
+ const base = __classPrivateFieldGet2(this, _Numerals_userNumeralSet, "f") === "arabic-indic" ? 1632 : 1776;
3008
3044
  return str.replace(/[0-9]/g, (d) => String.fromCharCode(base + Number(d)));
3009
3045
  }
3010
3046
  // Normalize Eastern Arabic (U+0660-0669) and Persian/Extended Arabic-Indic (U+06F0-06F9) numerals to ASCII 0-9
@@ -3012,851 +3048,163 @@ var Numerals = class {
3012
3048
  if (!str) {
3013
3049
  return "";
3014
3050
  }
3015
- this.updateNumeralSet(str);
3016
- if (this.userNumeralSet === "ascii") {
3051
+ __classPrivateFieldGet2(this, _Numerals_instances, "m", _Numerals_updateNumeralSet).call(this, str);
3052
+ if (__classPrivateFieldGet2(this, _Numerals_userNumeralSet, "f") === "ascii") {
3017
3053
  return str;
3018
3054
  }
3019
- const base = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
3020
- const regex = this.userNumeralSet === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
3055
+ const base = __classPrivateFieldGet2(this, _Numerals_userNumeralSet, "f") === "arabic-indic" ? 1632 : 1776;
3056
+ const regex = __classPrivateFieldGet2(this, _Numerals_userNumeralSet, "f") === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
3021
3057
  return str.replace(regex, (ch) => String.fromCharCode(48 + (ch.charCodeAt(0) - base)));
3022
3058
  }
3023
3059
  isAscii() {
3024
- return this.userNumeralSet === "ascii";
3060
+ return __classPrivateFieldGet2(this, _Numerals_userNumeralSet, "f") === "ascii";
3061
+ }
3062
+ };
3063
+ _Numerals_userNumeralSet = /* @__PURE__ */ new WeakMap(), _Numerals_instances = /* @__PURE__ */ new WeakSet(), _Numerals_updateNumeralSet = function _Numerals_updateNumeralSet2(str) {
3064
+ if (/[\u0660-\u0669]/.test(str)) {
3065
+ __classPrivateFieldSet2(this, _Numerals_userNumeralSet, "arabic-indic", "f");
3066
+ } else if (/[\u06F0-\u06F9]/.test(str)) {
3067
+ __classPrivateFieldSet2(this, _Numerals_userNumeralSet, "persian", "f");
3068
+ } else {
3069
+ __classPrivateFieldSet2(this, _Numerals_userNumeralSet, "ascii", "f");
3025
3070
  }
3026
3071
  };
3027
3072
 
3028
3073
  // angular/build/temp/intl-tel-input.js
3074
+ var __classPrivateFieldSet3 = function(receiver, state, value, kind, f) {
3075
+ if (kind === "m") throw new TypeError("Private method is not writable");
3076
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3077
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3078
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3079
+ };
3080
+ var __classPrivateFieldGet3 = function(receiver, state, kind, f) {
3081
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3082
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3083
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3084
+ };
3085
+ var _Iti_instances;
3086
+ var _a2;
3087
+ var _Iti_ui;
3088
+ var _Iti_options;
3089
+ var _Iti_isAndroid;
3090
+ var _Iti_countries;
3091
+ var _Iti_dialCodeMaxLen;
3092
+ var _Iti_dialCodeToIso2Map;
3093
+ var _Iti_dialCodes;
3094
+ var _Iti_countryByIso2;
3095
+ var _Iti_selectedCountryData;
3096
+ var _Iti_maxCoreNumberLength;
3097
+ var _Iti_defaultCountry;
3098
+ var _Iti_abortController;
3099
+ var _Iti_dropdownAbortController;
3100
+ var _Iti_numerals;
3101
+ var _Iti_resolveAutoCountryPromise;
3102
+ var _Iti_rejectAutoCountryPromise;
3103
+ var _Iti_resolveUtilsScriptPromise;
3104
+ var _Iti_rejectUtilsScriptPromise;
3105
+ var _Iti_getTelInputValue;
3106
+ var _Iti_setTelInputValue;
3107
+ var _Iti_createInitPromises;
3108
+ var _Iti_init;
3109
+ var _Iti_processCountryData;
3110
+ var _Iti_setInitialState;
3111
+ var _Iti_initListeners;
3112
+ var _Iti_initHiddenInputListener;
3113
+ var _Iti_initDropdownListeners;
3114
+ var _Iti_initRequests;
3115
+ var _Iti_loadAutoCountry;
3116
+ var _Iti_openDropdownWithPlus;
3117
+ var _Iti_initTelInputListeners;
3118
+ var _Iti_bindInputListener;
3119
+ var _Iti_maybeBindKeydownListener;
3120
+ var _Iti_maybeBindPasteListener;
3121
+ var _Iti_cap;
3122
+ var _Iti_trigger;
3123
+ var _Iti_openDropdown;
3124
+ var _Iti_bindDropdownListeners;
3125
+ var _Iti_bindDropdownMouseoverListener;
3126
+ var _Iti_bindDropdownCountryClickListener;
3127
+ var _Iti_bindDropdownClickOffListener;
3128
+ var _Iti_bindDropdownKeydownListener;
3129
+ var _Iti_bindDropdownSearchListeners;
3130
+ var _Iti_searchForCountry;
3131
+ var _Iti_handleEnterKey;
3132
+ var _Iti_updateValFromNumber;
3133
+ var _Iti_updateCountryFromNumber;
3134
+ var _Iti_ensureHasDialCode;
3135
+ var _Iti_getNewCountryFromNumber;
3136
+ var _Iti_setCountry;
3137
+ var _Iti_updateMaxLength;
3138
+ var _Iti_updatePlaceholder;
3139
+ var _Iti_selectListItem;
3140
+ var _Iti_closeDropdown;
3141
+ var _Iti_updateDialCode;
3142
+ var _Iti_getDialCode;
3143
+ var _Iti_getFullNumber;
3144
+ var _Iti_beforeSetNumber;
3145
+ var _Iti_triggerCountryChange;
3146
+ var _Iti_handleAutoCountry;
3147
+ var _Iti_handleAutoCountryFailure;
3148
+ var _Iti_handleUtils;
3149
+ var _Iti_handleUtilsFailure;
3150
+ var _Iti_utilsIsPossibleNumber;
3151
+ var _Iti_validateNumber;
3152
+ var _Iti_utilsIsValidNumber;
3029
3153
  var id = 0;
3030
3154
  var iso2Set2 = new Set(data_default.map((c) => c.iso2));
3031
3155
  var isIso22 = (val) => iso2Set2.has(val);
3032
3156
  var Iti = class {
3033
3157
  constructor(input, customOptions = {}) {
3158
+ _Iti_instances.add(this);
3159
+ _Iti_ui.set(this, void 0);
3160
+ _Iti_options.set(this, void 0);
3161
+ _Iti_isAndroid.set(this, void 0);
3162
+ _Iti_countries.set(this, void 0);
3163
+ _Iti_dialCodeMaxLen.set(this, void 0);
3164
+ _Iti_dialCodeToIso2Map.set(this, void 0);
3165
+ _Iti_dialCodes.set(this, void 0);
3166
+ _Iti_countryByIso2.set(this, void 0);
3167
+ _Iti_selectedCountryData.set(this, void 0);
3168
+ _Iti_maxCoreNumberLength.set(this, void 0);
3169
+ _Iti_defaultCountry.set(this, void 0);
3170
+ _Iti_abortController.set(this, void 0);
3171
+ _Iti_dropdownAbortController.set(this, void 0);
3172
+ _Iti_numerals.set(this, void 0);
3173
+ _Iti_resolveAutoCountryPromise.set(this, void 0);
3174
+ _Iti_rejectAutoCountryPromise.set(this, void 0);
3175
+ _Iti_resolveUtilsScriptPromise.set(this, void 0);
3176
+ _Iti_rejectUtilsScriptPromise.set(this, void 0);
3034
3177
  this.id = id++;
3035
- UI.validateInput(input);
3178
+ ui_default.validateInput(input);
3036
3179
  const validatedOptions = validateOptions(customOptions);
3037
- this.options = Object.assign(Object.assign({}, defaults), validatedOptions);
3038
- applyOptionSideEffects(this.options);
3039
- this.ui = new UI(input, this.options, this.id);
3040
- this.isAndroid = getIsAndroid();
3041
- this.numerals = new Numerals();
3042
- this.promise = this._createInitPromises(this.options);
3043
- this.countries = processAllCountries(this.options);
3044
- const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(this.countries);
3045
- this.dialCodes = dialCodes;
3046
- this.dialCodeMaxLen = dialCodeMaxLen;
3047
- this.dialCodeToIso2Map = dialCodeToIso2Map;
3048
- this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
3049
- this._init();
3050
- }
3051
- _getTelInputValue() {
3052
- const inputValue = this.ui.telInput.value.trim();
3053
- return this.numerals.normalise(inputValue);
3054
- }
3055
- _setTelInputValue(asciiValue) {
3056
- const currentValue = this.ui.telInput.value;
3057
- this.ui.telInput.value = this.numerals.denormalise(asciiValue, currentValue);
3058
- }
3059
- _createInitPromises(options) {
3060
- const { initialCountry, geoIpLookup, loadUtils } = options;
3061
- const needsAutoCountryPromise = initialCountry === INITIAL_COUNTRY.AUTO && Boolean(geoIpLookup);
3062
- const needsUtilsScriptPromise = Boolean(loadUtils) && !intlTelInput.utils;
3063
- let autoCountryPromise;
3064
- if (needsAutoCountryPromise) {
3065
- autoCountryPromise = new Promise((resolve, reject) => {
3066
- this.resolveAutoCountryPromise = resolve;
3067
- this.rejectAutoCountryPromise = reject;
3068
- });
3069
- } else {
3070
- autoCountryPromise = Promise.resolve(void 0);
3071
- this.resolveAutoCountryPromise = () => {
3072
- };
3073
- this.rejectAutoCountryPromise = () => {
3074
- };
3075
- }
3076
- let utilsScriptPromise;
3077
- if (needsUtilsScriptPromise) {
3078
- utilsScriptPromise = new Promise((resolve, reject) => {
3079
- this.resolveUtilsScriptPromise = resolve;
3080
- this.rejectUtilsScriptPromise = reject;
3081
- });
3082
- } else {
3083
- utilsScriptPromise = Promise.resolve(void 0);
3084
- this.resolveUtilsScriptPromise = () => {
3085
- };
3086
- this.rejectUtilsScriptPromise = () => {
3087
- };
3088
- }
3089
- return Promise.all([autoCountryPromise, utilsScriptPromise]);
3090
- }
3091
- //* Can't be private as it's called from intlTelInput convenience wrapper.
3092
- _init() {
3093
- this.selectedCountryData = {};
3094
- this.abortController = new AbortController();
3095
- this._processCountryData();
3096
- this.ui.generateMarkup(this.countries);
3097
- this._setInitialState();
3098
- this._initListeners();
3099
- this._initRequests();
3100
- if (this.options.dropdownAlwaysOpen) {
3101
- this._openDropdown();
3102
- }
3103
- }
3104
- //********************
3105
- //* PRIVATE METHODS
3106
- //********************
3107
- //* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
3108
- _processCountryData() {
3109
- generateCountryNames(this.countries, this.options);
3110
- sortCountries(this.countries, this.options);
3111
- cacheSearchTokens(this.countries);
3112
- }
3113
- //* Set the initial state of the input value and the selected country by:
3114
- //* 1. Extracting a dial code from the given number
3115
- //* 2. Using explicit initialCountry
3116
- _setInitialState(overrideAutoCountry = false) {
3117
- const attributeValueRaw = this.ui.telInput.getAttribute("value");
3118
- const attributeValue = this.numerals.normalise(attributeValueRaw);
3119
- const inputValue = this._getTelInputValue();
3120
- const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
3121
- const val = useAttribute ? attributeValue : inputValue;
3122
- const dialCode = this._getDialCode(val);
3123
- const isRegionlessNanpNumber = isRegionlessNanp(val);
3124
- const { initialCountry, geoIpLookup } = this.options;
3125
- const isAutoCountry = initialCountry === INITIAL_COUNTRY.AUTO && geoIpLookup;
3126
- const doingAutoCountryLookup = isAutoCountry && !overrideAutoCountry;
3127
- const initialCountryLower = initialCountry.toLowerCase();
3128
- const isValidInitialCountry = isIso22(initialCountryLower);
3129
- if (dialCode) {
3130
- if (isRegionlessNanpNumber) {
3131
- if (isValidInitialCountry) {
3132
- this._setCountry(initialCountryLower);
3133
- } else if (!doingAutoCountryLookup) {
3134
- this._setCountry(US.ISO2);
3135
- }
3136
- } else {
3137
- this._updateCountryFromNumber(val);
3138
- }
3139
- } else if (isValidInitialCountry) {
3140
- this._setCountry(initialCountryLower);
3141
- } else if (!doingAutoCountryLookup) {
3142
- this._setCountry("");
3143
- }
3144
- if (val) {
3145
- this._updateValFromNumber(val);
3146
- }
3147
- }
3148
- //* Initialise the main event listeners: input keyup, and click selected country.
3149
- _initListeners() {
3150
- this._initTelInputListeners();
3151
- if (this.options.allowDropdown) {
3152
- this._initDropdownListeners();
3153
- }
3154
- if ((this.ui.hiddenInput || this.ui.hiddenInputCountry) && this.ui.telInput.form) {
3155
- this._initHiddenInputListener();
3156
- }
3157
- }
3158
- //* Update hidden input on form submit.
3159
- _initHiddenInputListener() {
3160
- var _a;
3161
- const handleHiddenInputSubmit = () => {
3162
- if (this.ui.hiddenInput) {
3163
- this.ui.hiddenInput.value = this.getNumber();
3164
- }
3165
- if (this.ui.hiddenInputCountry) {
3166
- this.ui.hiddenInputCountry.value = this.selectedCountryData.iso2 || "";
3167
- }
3168
- };
3169
- (_a = this.ui.telInput.form) === null || _a === void 0 ? void 0 : _a.addEventListener("submit", handleHiddenInputSubmit, {
3170
- signal: this.abortController.signal
3171
- });
3172
- }
3173
- //* initialise the dropdown listeners.
3174
- _initDropdownListeners() {
3175
- const signal = this.abortController.signal;
3176
- const handleLabelClick = (e) => {
3177
- if (this.ui.isDropdownClosed()) {
3178
- this.ui.telInput.focus();
3179
- } else {
3180
- e.preventDefault();
3181
- }
3182
- };
3183
- const label = this.ui.telInput.closest("label");
3184
- if (label) {
3185
- label.addEventListener("click", handleLabelClick, { signal });
3186
- }
3187
- const handleClickSelectedCountry = () => {
3188
- if (this.ui.isDropdownClosed() && !this.ui.telInput.disabled && !this.ui.telInput.readOnly) {
3189
- this._openDropdown();
3190
- }
3191
- };
3192
- this.ui.selectedCountry.addEventListener("click", handleClickSelectedCountry, {
3193
- signal
3194
- });
3195
- const handleCountryContainerKeydown = (e) => {
3196
- const allowedKeys = [KEYS.ARROW_UP, KEYS.ARROW_DOWN, KEYS.SPACE, KEYS.ENTER];
3197
- if (this.ui.isDropdownClosed() && allowedKeys.includes(e.key)) {
3198
- e.preventDefault();
3199
- e.stopPropagation();
3200
- this._openDropdown();
3201
- }
3202
- if (e.key === KEYS.TAB) {
3203
- this._closeDropdown();
3204
- }
3205
- };
3206
- this.ui.countryContainer.addEventListener("keydown", handleCountryContainerKeydown, { signal });
3207
- }
3208
- //* Init requests: utils script / geo ip lookup.
3209
- _initRequests() {
3210
- const { loadUtils, initialCountry, geoIpLookup } = this.options;
3211
- if (loadUtils && !intlTelInput.utils) {
3212
- const doAttachUtils = () => {
3213
- var _a;
3214
- (_a = intlTelInput.attachUtils(loadUtils)) === null || _a === void 0 ? void 0 : _a.catch(() => {
3215
- });
3216
- };
3217
- if (intlTelInput.documentReady()) {
3218
- doAttachUtils();
3219
- } else {
3220
- const handlePageLoad = () => {
3221
- doAttachUtils();
3222
- };
3223
- window.addEventListener("load", handlePageLoad, {
3224
- signal: this.abortController.signal
3225
- });
3226
- }
3227
- } else {
3228
- this.resolveUtilsScriptPromise();
3229
- }
3230
- const isAutoCountry = initialCountry === INITIAL_COUNTRY.AUTO && geoIpLookup;
3231
- if (isAutoCountry) {
3232
- if (this.selectedCountryData.iso2) {
3233
- this.resolveAutoCountryPromise();
3234
- } else {
3235
- this._loadAutoCountry();
3236
- }
3237
- }
3238
- }
3239
- //* Perform the geo ip lookup.
3240
- _loadAutoCountry() {
3241
- if (intlTelInput.autoCountry) {
3242
- this.handleAutoCountry();
3243
- } else {
3244
- this.ui.selectedCountryInner.classList.add(CLASSES.LOADING);
3245
- if (!intlTelInput.startedLoadingAutoCountry) {
3246
- intlTelInput.startedLoadingAutoCountry = true;
3247
- if (typeof this.options.geoIpLookup === "function") {
3248
- const successCallback = (iso2 = "") => {
3249
- this.ui.selectedCountryInner.classList.remove(CLASSES.LOADING);
3250
- const iso2Lower = iso2.toLowerCase();
3251
- if (isIso22(iso2Lower)) {
3252
- intlTelInput.autoCountry = iso2Lower;
3253
- setTimeout(() => forEachInstance("handleAutoCountry"));
3254
- } else {
3255
- forEachInstance("handleAutoCountryFailure");
3256
- }
3257
- };
3258
- const failureCallback = () => {
3259
- this.ui.selectedCountryInner.classList.remove(CLASSES.LOADING);
3260
- forEachInstance("handleAutoCountryFailure");
3261
- };
3262
- this.options.geoIpLookup(successCallback, failureCallback);
3263
- }
3264
- }
3265
- }
3266
- }
3267
- _openDropdownWithPlus() {
3268
- this._openDropdown();
3269
- this.ui.searchInput.value = "+";
3270
- this.ui.filterCountriesByQuery("");
3271
- }
3272
- //* Initialize the tel input listeners.
3273
- _initTelInputListeners() {
3274
- this._bindInputListener();
3275
- this._maybeBindKeydownListener();
3276
- this._maybeBindPasteListener();
3277
- }
3278
- _bindInputListener() {
3279
- const { strictMode, formatAsYouType, separateDialCode, allowDropdown, countrySearch } = this.options;
3280
- let userOverrideFormatting = false;
3281
- if (REGEX.ALPHA_UNICODE.test(this._getTelInputValue())) {
3282
- userOverrideFormatting = true;
3283
- }
3284
- const handleInputEvent = (e) => {
3285
- const inputValue = this._getTelInputValue();
3286
- if (this.isAndroid && (e === null || e === void 0 ? void 0 : e.data) === "+" && separateDialCode && allowDropdown && countrySearch) {
3287
- const currentCaretPos = this.ui.telInput.selectionStart || 0;
3288
- const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
3289
- const valueAfterCaret = inputValue.substring(currentCaretPos);
3290
- this._setTelInputValue(valueBeforeCaret + valueAfterCaret);
3291
- this._openDropdownWithPlus();
3292
- return;
3293
- }
3294
- if (this._updateCountryFromNumber(inputValue)) {
3295
- this._triggerCountryChange();
3296
- }
3297
- const isFormattingChar = (e === null || e === void 0 ? void 0 : e.data) && REGEX.NON_PLUS_NUMERIC.test(e.data);
3298
- const isPaste = (e === null || e === void 0 ? void 0 : e.inputType) === INPUT_TYPES.PASTE && inputValue;
3299
- if (isFormattingChar || isPaste && !strictMode) {
3300
- userOverrideFormatting = true;
3301
- } else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
3302
- userOverrideFormatting = false;
3303
- }
3304
- const isSetNumber = (e === null || e === void 0 ? void 0 : e.detail) && e.detail["isSetNumber"];
3305
- const isAscii = this.numerals.isAscii();
3306
- if (formatAsYouType && !userOverrideFormatting && !isSetNumber && isAscii) {
3307
- const currentCaretPos = this.ui.telInput.selectionStart || 0;
3308
- const valueBeforeCaret = inputValue.substring(0, currentCaretPos);
3309
- const relevantCharsBeforeCaret = valueBeforeCaret.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "").length;
3310
- const isDeleteForwards = (e === null || e === void 0 ? void 0 : e.inputType) === INPUT_TYPES.DELETE_FWD;
3311
- const fullNumber = this._getFullNumber();
3312
- const formattedValue = formatNumberAsYouType(fullNumber, inputValue, intlTelInput.utils, this.selectedCountryData, separateDialCode);
3313
- const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
3314
- this._setTelInputValue(formattedValue);
3315
- this.ui.telInput.setSelectionRange(newCaretPos, newCaretPos);
3316
- }
3317
- if (separateDialCode && inputValue.startsWith("+") && this.selectedCountryData.dialCode) {
3318
- const cleanNumber = beforeSetNumber(inputValue, true, separateDialCode, this.selectedCountryData);
3319
- this._setTelInputValue(cleanNumber);
3320
- }
3321
- };
3322
- this.ui.telInput.addEventListener("input", handleInputEvent, {
3323
- signal: this.abortController.signal
3324
- });
3325
- }
3326
- _maybeBindKeydownListener() {
3327
- const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.options;
3328
- if (strictMode || separateDialCode) {
3329
- const handleKeydownEvent = (e) => {
3330
- if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
3331
- if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
3332
- e.preventDefault();
3333
- this._openDropdownWithPlus();
3334
- return;
3335
- }
3336
- if (strictMode) {
3337
- const inputValue = this._getTelInputValue();
3338
- const alreadyHasPlus = inputValue.startsWith("+");
3339
- const isInitialPlus = !alreadyHasPlus && this.ui.telInput.selectionStart === 0 && e.key === "+";
3340
- const normalisedKey = this.numerals.normalise(e.key);
3341
- const isNumeric = /^[0-9]$/.test(normalisedKey);
3342
- const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
3343
- const input = this.ui.telInput;
3344
- const selStart = input.selectionStart;
3345
- const selEnd = input.selectionEnd;
3346
- const before = inputValue.slice(0, selStart);
3347
- const after = inputValue.slice(selEnd);
3348
- const newValue = before + e.key + after;
3349
- const newFullNumber = this._getFullNumber(newValue);
3350
- const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
3351
- const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
3352
- const newCountry = this._getNewCountryFromNumber(newFullNumber);
3353
- const isChangingDialCode = newCountry !== null;
3354
- if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
3355
- e.preventDefault();
3356
- }
3357
- }
3358
- }
3359
- };
3360
- this.ui.telInput.addEventListener("keydown", handleKeydownEvent, {
3361
- signal: this.abortController.signal
3362
- });
3363
- }
3364
- }
3365
- _maybeBindPasteListener() {
3366
- if (this.options.strictMode) {
3367
- const handlePasteEvent = (e) => {
3368
- e.preventDefault();
3369
- const input = this.ui.telInput;
3370
- const selStart = input.selectionStart;
3371
- const selEnd = input.selectionEnd;
3372
- const inputValue = this._getTelInputValue();
3373
- const before = inputValue.slice(0, selStart);
3374
- const after = inputValue.slice(selEnd);
3375
- const iso2 = this.selectedCountryData.iso2;
3376
- const pastedRaw = e.clipboardData.getData("text");
3377
- const pasted = this.numerals.normalise(pastedRaw);
3378
- const initialCharSelected = selStart === 0 && selEnd > 0;
3379
- const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
3380
- const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
3381
- const hasLeadingPlus = allowedChars.startsWith("+");
3382
- const numerics = allowedChars.replace(/\+/g, "");
3383
- const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
3384
- let newVal = before + sanitised + after;
3385
- if (newVal.length > 5) {
3386
- let coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
3387
- while (coreNumber.length === 0 && newVal.length > 0) {
3388
- newVal = newVal.slice(0, -1);
3389
- coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
3390
- }
3391
- if (!coreNumber) {
3392
- return;
3393
- }
3394
- if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
3395
- if (input.selectionEnd === inputValue.length) {
3396
- const trimLength = coreNumber.length - this.maxCoreNumberLength;
3397
- newVal = newVal.slice(0, newVal.length - trimLength);
3398
- } else {
3399
- return;
3400
- }
3401
- }
3402
- }
3403
- this._setTelInputValue(newVal);
3404
- const caretPos = selStart + sanitised.length;
3405
- input.setSelectionRange(caretPos, caretPos);
3406
- input.dispatchEvent(new InputEvent("input", { bubbles: true }));
3407
- };
3408
- this.ui.telInput.addEventListener("paste", handlePasteEvent, {
3409
- signal: this.abortController.signal
3410
- });
3411
- }
3412
- }
3413
- //* Adhere to the input's maxlength attr.
3414
- _cap(number) {
3415
- const max = Number(this.ui.telInput.getAttribute("maxlength"));
3416
- return max && number.length > max ? number.substring(0, max) : number;
3417
- }
3418
- //* Trigger a custom event on the input (typed via ItiEventMap).
3419
- _trigger(name, detailProps = {}) {
3420
- const e = new CustomEvent(name, {
3421
- bubbles: true,
3422
- cancelable: true,
3423
- detail: detailProps
3424
- });
3425
- this.ui.telInput.dispatchEvent(e);
3426
- }
3427
- //* Open the dropdown.
3428
- _openDropdown() {
3429
- const { dropdownContainer, useFullscreenPopup } = this.options;
3430
- this.dropdownAbortController = new AbortController();
3431
- this.ui.openDropdown();
3432
- if (!useFullscreenPopup && dropdownContainer) {
3433
- const handleWindowScroll = () => this._closeDropdown();
3434
- window.addEventListener("scroll", handleWindowScroll, {
3435
- signal: this.dropdownAbortController.signal
3436
- });
3437
- }
3438
- this._bindDropdownListeners();
3439
- this._trigger(EVENTS.OPEN_COUNTRY_DROPDOWN);
3440
- }
3441
- //* We only bind dropdown listeners when the dropdown is open.
3442
- _bindDropdownListeners() {
3443
- const signal = this.dropdownAbortController.signal;
3444
- this._bindDropdownMouseoverListener(signal);
3445
- this._bindDropdownCountryClickListener(signal);
3446
- if (!this.options.dropdownAlwaysOpen) {
3447
- this._bindDropdownClickOffListener(signal);
3448
- }
3449
- this._bindDropdownKeydownListener(signal);
3450
- if (this.options.countrySearch) {
3451
- this._bindDropdownSearchListeners(signal);
3452
- }
3453
- }
3454
- //* When mouse over a list item, just highlight that one
3455
- //* we add the class "highlight", so if they hit "enter" we know which one to select.
3456
- _bindDropdownMouseoverListener(signal) {
3457
- const handleMouseoverCountryList = (e) => {
3458
- var _a;
3459
- const listItem = (_a = e.target) === null || _a === void 0 ? void 0 : _a.closest(`.${CLASSES.COUNTRY_ITEM}`);
3460
- if (listItem) {
3461
- this.ui.highlightListItem(listItem, false);
3462
- }
3463
- };
3464
- this.ui.countryList.addEventListener("mouseover", handleMouseoverCountryList, {
3465
- signal
3466
- });
3467
- }
3468
- //* Listen for country selection.
3469
- _bindDropdownCountryClickListener(signal) {
3470
- const handleClickCountryList = (e) => {
3471
- var _a;
3472
- const listItem = (_a = e.target) === null || _a === void 0 ? void 0 : _a.closest(`.${CLASSES.COUNTRY_ITEM}`);
3473
- if (listItem) {
3474
- this._selectListItem(listItem);
3475
- }
3476
- };
3477
- this.ui.countryList.addEventListener("click", handleClickCountryList, {
3478
- signal
3479
- });
3480
- }
3481
- //* Click off to close (except when this initial opening click is bubbling up).
3482
- //* We cannot just stopPropagation as it may be needed to close another instance.
3483
- _bindDropdownClickOffListener(signal) {
3484
- const handleClickOffToClose = (e) => {
3485
- const target = e.target;
3486
- const clickedInsideDropdown = !!target.closest(`#iti-${this.id}__dropdown-content`);
3487
- if (!clickedInsideDropdown) {
3488
- this._closeDropdown();
3489
- }
3490
- };
3491
- setTimeout(() => {
3492
- document.documentElement.addEventListener("click", handleClickOffToClose, { signal });
3493
- }, 0);
3494
- }
3495
- //* Listen for up/down scrolling, enter to select, or escape to close.
3496
- //* Use keydown as keypress doesn't fire for non-char keys and we want to catch if they
3497
- //* just hit down and hold it to scroll down (no keyup event).
3498
- //* Listen on the document because that's where key events are triggered if no input has focus.
3499
- _bindDropdownKeydownListener(signal) {
3500
- let query = "";
3501
- let queryTimer = null;
3502
- const handleKeydownOnDropdown = (e) => {
3503
- const allowedKeys = [
3504
- KEYS.ARROW_UP,
3505
- KEYS.ARROW_DOWN,
3506
- KEYS.ENTER,
3507
- KEYS.ESC
3508
- ];
3509
- if (allowedKeys.includes(e.key)) {
3510
- e.preventDefault();
3511
- e.stopPropagation();
3512
- if (e.key === KEYS.ARROW_UP || e.key === KEYS.ARROW_DOWN) {
3513
- this.ui.handleUpDownKey(e.key);
3514
- } else if (e.key === KEYS.ENTER) {
3515
- this._handleEnterKey();
3516
- } else if (e.key === KEYS.ESC) {
3517
- this._closeDropdown();
3518
- this.ui.selectedCountry.focus();
3519
- }
3520
- }
3521
- if (!this.options.countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
3522
- e.stopPropagation();
3523
- if (queryTimer) {
3524
- clearTimeout(queryTimer);
3525
- }
3526
- query += e.key.toLowerCase();
3527
- this._searchForCountry(query);
3528
- queryTimer = setTimeout(() => {
3529
- query = "";
3530
- }, TIMINGS.HIDDEN_SEARCH_RESET_MS);
3531
- }
3532
- };
3533
- document.addEventListener("keydown", handleKeydownOnDropdown, { signal });
3534
- }
3535
- //* Search input listeners when countrySearch enabled.
3536
- _bindDropdownSearchListeners(signal) {
3537
- this.ui.searchInput.addEventListener("input", () => this.ui.handleSearchChange(), { signal });
3538
- this.ui.searchClearButton.addEventListener("click", () => this.ui.handleSearchClear(), { signal });
3539
- }
3540
- //* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
3541
- _searchForCountry(query) {
3542
- const match = findFirstCountryStartingWith(this.countries, query);
3543
- if (match) {
3544
- const listItem = match.nodeById[this.id];
3545
- this.ui.highlightListItem(listItem, false);
3546
- this.ui.scrollTo(listItem);
3547
- }
3548
- }
3549
- //* Select the currently highlighted item.
3550
- _handleEnterKey() {
3551
- if (this.ui.highlightedItem) {
3552
- this._selectListItem(this.ui.highlightedItem);
3553
- }
3554
- }
3555
- //* Update the input's value to the given val (format first if possible)
3556
- //* NOTE: this is called from _setInitialState, handleUtils and setNumber.
3557
- _updateValFromNumber(fullNumber) {
3558
- const { formatOnDisplay, nationalMode, separateDialCode } = this.options;
3559
- let number = fullNumber;
3560
- if (formatOnDisplay && intlTelInput.utils && this.selectedCountryData) {
3561
- const isRegionless = hasRegionlessDialCode(fullNumber);
3562
- const useNational = nationalMode && !isRegionless || !number.startsWith("+") && !separateDialCode;
3563
- const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
3564
- const format = useNational ? NATIONAL : INTERNATIONAL;
3565
- number = intlTelInput.utils.formatNumber(number, this.selectedCountryData.iso2, format);
3566
- }
3567
- number = this._beforeSetNumber(number);
3568
- this._setTelInputValue(number);
3569
- }
3570
- //* Check if need to select a new country based on the given number
3571
- //* Note: called from _setInitialState, keyup handler, setNumber.
3572
- _updateCountryFromNumber(fullNumber) {
3573
- const iso2 = this._getNewCountryFromNumber(fullNumber);
3574
- if (iso2 !== null) {
3575
- return this._setCountry(iso2);
3576
- }
3577
- return false;
3578
- }
3579
- // if there is a selected country, and the number doesn't start with a dial code, then add it
3580
- _ensureHasDialCode(number) {
3581
- const { dialCode, nationalPrefix } = this.selectedCountryData;
3582
- const alreadyHasPlus = number.startsWith("+");
3583
- if (alreadyHasPlus || !dialCode) {
3584
- return number;
3585
- }
3586
- const hasPrefix = nationalPrefix && number.startsWith(nationalPrefix) && !this.options.separateDialCode;
3587
- const cleanNumber = hasPrefix ? number.substring(1) : number;
3588
- return `+${dialCode}${cleanNumber}`;
3589
- }
3590
- //* Get the new country based on the input number, or return null if no change, or empty string if should be empty (e.g. if they type an invalid dial code).
3591
- _getNewCountryFromNumber(fullNumber) {
3592
- const plusIndex = fullNumber.indexOf("+");
3593
- let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
3594
- const selectedIso2 = this.selectedCountryData.iso2;
3595
- const selectedDialCode = this.selectedCountryData.dialCode;
3596
- number = this._ensureHasDialCode(number);
3597
- const dialCodeMatch = this._getDialCode(number, true);
3598
- const numeric = getNumeric(number);
3599
- if (dialCodeMatch) {
3600
- const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
3601
- const iso2Codes = this.dialCodeToIso2Map[dialCodeMatchNumeric];
3602
- if (iso2Codes.length === 1) {
3603
- if (iso2Codes[0] === selectedIso2) {
3604
- return null;
3605
- }
3606
- return iso2Codes[0];
3607
- }
3608
- if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
3609
- return this.defaultCountry;
3610
- }
3611
- const isRegionlessNanpNumber = selectedDialCode === DIAL.NANP && isRegionlessNanp(numeric);
3612
- if (isRegionlessNanpNumber) {
3613
- return null;
3614
- }
3615
- const { areaCodes, priority } = this.selectedCountryData;
3616
- if (areaCodes) {
3617
- const dialCodeAreaCodes = areaCodes.map((areaCode) => `${selectedDialCode}${areaCode}`);
3618
- for (const dialCodeAreaCode of dialCodeAreaCodes) {
3619
- if (numeric.startsWith(dialCodeAreaCode)) {
3620
- return null;
3621
- }
3622
- }
3623
- }
3624
- const isMainCountry = priority === 0;
3625
- const hasAreaCodesButNoneMatched = areaCodes && !isMainCountry && numeric.length > dialCodeMatchNumeric.length;
3626
- const isValidSelection = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
3627
- const alreadySelected = selectedIso2 === iso2Codes[0];
3628
- if (!isValidSelection && !alreadySelected) {
3629
- return iso2Codes[0];
3630
- }
3631
- } else if (number.startsWith("+") && numeric.length) {
3632
- const currentDial = this.selectedCountryData.dialCode || "";
3633
- if (currentDial && currentDial.startsWith(numeric)) {
3634
- return null;
3635
- }
3636
- return "";
3637
- } else if ((!number || number === "+") && !selectedIso2 && this.defaultCountry) {
3638
- return this.defaultCountry;
3639
- }
3640
- return null;
3641
- }
3642
- //* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
3643
- //* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
3644
- _setCountry(iso2) {
3645
- const prevIso2 = this.selectedCountryData.iso2 || "";
3646
- this.selectedCountryData = iso2 ? this.countryByIso2.get(iso2) : {};
3647
- if (this.selectedCountryData.iso2) {
3648
- this.defaultCountry = this.selectedCountryData.iso2;
3649
- }
3650
- this.ui.setCountry(this.selectedCountryData);
3651
- this._updatePlaceholder();
3652
- this._updateMaxLength();
3653
- return prevIso2 !== iso2;
3654
- }
3655
- //* Update the maximum valid number length for the currently selected country.
3656
- _updateMaxLength() {
3657
- const { strictMode, placeholderNumberType, allowedNumberTypes } = this.options;
3658
- const { iso2 } = this.selectedCountryData;
3659
- if (strictMode && intlTelInput.utils) {
3660
- if (iso2) {
3661
- const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3662
- let exampleNumber = intlTelInput.utils.getExampleNumber(iso2, false, numberType, true);
3663
- let validNumber = exampleNumber;
3664
- while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, allowedNumberTypes)) {
3665
- validNumber = exampleNumber;
3666
- exampleNumber += "0";
3667
- }
3668
- const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
3669
- this.maxCoreNumberLength = coreNumber.length;
3670
- if (iso2 === "by") {
3671
- this.maxCoreNumberLength = coreNumber.length + 1;
3672
- }
3673
- } else {
3674
- this.maxCoreNumberLength = null;
3675
- }
3676
- }
3677
- }
3678
- //* Update the input placeholder to an example number from the currently selected country.
3679
- _updatePlaceholder() {
3680
- const { autoPlaceholder, placeholderNumberType, nationalMode, customPlaceholder } = this.options;
3681
- const shouldSetPlaceholder = autoPlaceholder === PLACEHOLDER_MODES.AGGRESSIVE || !this.ui.hadInitialPlaceholder && autoPlaceholder === PLACEHOLDER_MODES.POLITE;
3682
- if (intlTelInput.utils && shouldSetPlaceholder) {
3683
- const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3684
- let placeholder = this.selectedCountryData.iso2 ? intlTelInput.utils.getExampleNumber(this.selectedCountryData.iso2, nationalMode, numberType) : "";
3685
- placeholder = this._beforeSetNumber(placeholder);
3686
- if (typeof customPlaceholder === "function") {
3687
- placeholder = customPlaceholder(placeholder, this.selectedCountryData);
3688
- }
3689
- this.ui.telInput.setAttribute("placeholder", placeholder);
3690
- }
3691
- }
3692
- //* Called when the user selects a list item from the dropdown.
3693
- _selectListItem(listItem) {
3694
- const iso2 = listItem.dataset[DATA_KEYS.COUNTRY_CODE];
3695
- const countryChanged = this._setCountry(iso2);
3696
- this._closeDropdown();
3697
- const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
3698
- this._updateDialCode(dialCode);
3699
- if (this.options.formatOnDisplay) {
3700
- const inputValue = this._getTelInputValue();
3701
- this._updateValFromNumber(inputValue);
3702
- }
3703
- this.ui.telInput.focus();
3704
- if (countryChanged) {
3705
- this._triggerCountryChange();
3706
- }
3707
- }
3708
- //* Close the dropdown and unbind any listeners.
3709
- _closeDropdown(isDestroy) {
3710
- if (this.ui.isDropdownClosed() || this.options.dropdownAlwaysOpen && !isDestroy) {
3711
- return;
3712
- }
3713
- this.ui.closeDropdown();
3714
- this.dropdownAbortController.abort();
3715
- this.dropdownAbortController = null;
3716
- this._trigger(EVENTS.CLOSE_COUNTRY_DROPDOWN);
3717
- }
3718
- //* Replace any existing dial code with the new one
3719
- //* Note: called from _selectListItem and setCountry
3720
- _updateDialCode(newDialCodeBare) {
3721
- const inputVal = this._getTelInputValue();
3722
- const newDialCode = `+${newDialCodeBare}`;
3723
- let newNumber;
3724
- if (inputVal.startsWith("+")) {
3725
- const prevDialCode = this._getDialCode(inputVal);
3726
- if (prevDialCode) {
3727
- newNumber = inputVal.replace(prevDialCode, newDialCode);
3728
- } else {
3729
- newNumber = newDialCode;
3730
- }
3731
- this._setTelInputValue(newNumber);
3732
- }
3733
- }
3734
- //* Try and extract a valid international dial code from a full telephone number.
3735
- //* Note: returns the raw string inc plus character and any whitespace/dots etc.
3736
- _getDialCode(number, includeAreaCode) {
3737
- let dialCode = "";
3738
- if (number.startsWith("+")) {
3739
- let numericChars = "";
3740
- let foundBaseDialCode = false;
3741
- for (let i = 0; i < number.length; i++) {
3742
- const c = number.charAt(i);
3743
- if (/[0-9]/.test(c)) {
3744
- numericChars += c;
3745
- const hasMapEntry = Boolean(this.dialCodeToIso2Map[numericChars]);
3746
- if (!hasMapEntry) {
3747
- break;
3748
- }
3749
- if (this.dialCodes.has(numericChars)) {
3750
- dialCode = number.substring(0, i + 1);
3751
- foundBaseDialCode = true;
3752
- if (!includeAreaCode) {
3753
- break;
3754
- }
3755
- } else if (includeAreaCode && foundBaseDialCode) {
3756
- dialCode = number.substring(0, i + 1);
3757
- }
3758
- if (numericChars.length === this.dialCodeMaxLen) {
3759
- break;
3760
- }
3761
- }
3762
- }
3763
- }
3764
- return dialCode;
3765
- }
3766
- //* Get the input val, adding the dial code if separateDialCode is enabled.
3767
- _getFullNumber(overrideVal) {
3768
- const val = overrideVal ? this.numerals.normalise(overrideVal) : this._getTelInputValue();
3769
- const { dialCode } = this.selectedCountryData;
3770
- let prefix;
3771
- const numericVal = getNumeric(val);
3772
- if (this.options.separateDialCode && !val.startsWith("+") && dialCode && numericVal) {
3773
- prefix = `+${dialCode}`;
3774
- } else {
3775
- prefix = "";
3776
- }
3777
- return prefix + val;
3778
- }
3779
- //* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
3780
- _beforeSetNumber(fullNumber) {
3781
- const hasValidDialCode = Boolean(this._getDialCode(fullNumber));
3782
- const number = beforeSetNumber(fullNumber, hasValidDialCode, this.options.separateDialCode, this.selectedCountryData);
3783
- return this._cap(number);
3784
- }
3785
- //* Trigger the 'countrychange' event.
3786
- _triggerCountryChange() {
3787
- this._trigger(EVENTS.COUNTRY_CHANGE);
3788
- }
3789
- //**************************
3790
- //* SECRET PUBLIC METHODS
3791
- //**************************
3792
- //* This is called when the geoip call returns.
3793
- handleAutoCountry() {
3794
- var _a, _b;
3795
- if (!((_a = this.ui) === null || _a === void 0 ? void 0 : _a.telInput)) {
3796
- (_b = this.resolveAutoCountryPromise) === null || _b === void 0 ? void 0 : _b.call(this);
3797
- return;
3798
- }
3799
- if (this.options.initialCountry === INITIAL_COUNTRY.AUTO && intlTelInput.autoCountry) {
3800
- this.defaultCountry = intlTelInput.autoCountry;
3801
- const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains(CLASSES.GLOBE);
3802
- if (!hasSelectedCountryOrGlobe) {
3803
- this.setCountry(this.defaultCountry);
3804
- }
3805
- this.resolveAutoCountryPromise();
3806
- }
3807
- }
3808
- //* This is called when the geoip call fails or times out.
3809
- handleAutoCountryFailure() {
3810
- var _a, _b;
3811
- if (!((_a = this.ui) === null || _a === void 0 ? void 0 : _a.telInput)) {
3812
- (_b = this.rejectAutoCountryPromise) === null || _b === void 0 ? void 0 : _b.call(this);
3813
- return;
3814
- }
3815
- this._setInitialState(true);
3816
- this.rejectAutoCountryPromise();
3817
- }
3818
- //* This is called when the utils request completes.
3819
- handleUtils() {
3820
- var _a, _b;
3821
- if (!((_a = this.ui) === null || _a === void 0 ? void 0 : _a.telInput)) {
3822
- (_b = this.resolveUtilsScriptPromise) === null || _b === void 0 ? void 0 : _b.call(this);
3823
- return;
3824
- }
3825
- if (intlTelInput.utils) {
3826
- const inputValue = this._getTelInputValue();
3827
- if (inputValue) {
3828
- this._updateValFromNumber(inputValue);
3829
- }
3830
- if (this.selectedCountryData.iso2) {
3831
- this._updatePlaceholder();
3832
- this._updateMaxLength();
3833
- }
3834
- }
3835
- this.resolveUtilsScriptPromise();
3836
- }
3837
- //* This is called when the utils request fails or times out.
3838
- handleUtilsFailure(error) {
3839
- var _a, _b;
3840
- if (!((_a = this.ui) === null || _a === void 0 ? void 0 : _a.telInput)) {
3841
- (_b = this.rejectUtilsScriptPromise) === null || _b === void 0 ? void 0 : _b.call(this, error);
3842
- return;
3843
- }
3844
- this.rejectUtilsScriptPromise(error);
3180
+ __classPrivateFieldSet3(this, _Iti_options, Object.assign(Object.assign({}, defaults), validatedOptions), "f");
3181
+ applyOptionSideEffects(__classPrivateFieldGet3(this, _Iti_options, "f"));
3182
+ __classPrivateFieldSet3(this, _Iti_ui, new ui_default(input, __classPrivateFieldGet3(this, _Iti_options, "f"), this.id), "f");
3183
+ __classPrivateFieldSet3(this, _Iti_isAndroid, getIsAndroid(), "f");
3184
+ __classPrivateFieldSet3(this, _Iti_numerals, new Numerals(), "f");
3185
+ this.promise = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_createInitPromises).call(this, __classPrivateFieldGet3(this, _Iti_options, "f"));
3186
+ __classPrivateFieldSet3(this, _Iti_countries, processAllCountries(__classPrivateFieldGet3(this, _Iti_options, "f")), "f");
3187
+ const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(__classPrivateFieldGet3(this, _Iti_countries, "f"));
3188
+ __classPrivateFieldSet3(this, _Iti_dialCodes, dialCodes, "f");
3189
+ __classPrivateFieldSet3(this, _Iti_dialCodeMaxLen, dialCodeMaxLen, "f");
3190
+ __classPrivateFieldSet3(this, _Iti_dialCodeToIso2Map, dialCodeToIso2Map, "f");
3191
+ __classPrivateFieldSet3(this, _Iti_countryByIso2, new Map(__classPrivateFieldGet3(this, _Iti_countries, "f").map((c) => [c.iso2, c])), "f");
3192
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_init).call(this);
3845
3193
  }
3846
3194
  //********************
3847
3195
  //* PUBLIC METHODS
3848
3196
  //********************
3849
3197
  //* Remove plugin.
3850
3198
  destroy() {
3851
- if (!this.ui.telInput) {
3199
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3852
3200
  return;
3853
3201
  }
3854
- if (this.options.allowDropdown) {
3855
- this._closeDropdown(true);
3202
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").allowDropdown) {
3203
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_closeDropdown).call(this, true);
3856
3204
  }
3857
- this.abortController.abort();
3858
- this.abortController = null;
3859
- this.ui.destroy();
3205
+ __classPrivateFieldGet3(this, _Iti_abortController, "f").abort();
3206
+ __classPrivateFieldSet3(this, _Iti_abortController, null, "f");
3207
+ __classPrivateFieldGet3(this, _Iti_ui, "f").destroy();
3860
3208
  if (intlTelInput.instances instanceof Map) {
3861
3209
  intlTelInput.instances.delete(this.id);
3862
3210
  } else {
@@ -3864,151 +3212,884 @@ var Iti = class {
3864
3212
  }
3865
3213
  }
3866
3214
  // check if the instance is still valid (not destroyed/unmounted)
3867
- getIsValid() {
3868
- var _a;
3869
- return !!((_a = this.ui) === null || _a === void 0 ? void 0 : _a.telInput);
3215
+ isActive() {
3216
+ var _b;
3217
+ return !!((_b = __classPrivateFieldGet3(this, _Iti_ui, "f")) === null || _b === void 0 ? void 0 : _b.telInput);
3870
3218
  }
3871
3219
  //* Get the extension from the current number.
3872
3220
  getExtension() {
3873
- if (intlTelInput.utils && this.ui.telInput) {
3874
- return intlTelInput.utils.getExtension(this._getFullNumber(), this.selectedCountryData.iso2);
3221
+ if (intlTelInput.utils && __classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3222
+ return intlTelInput.utils.getExtension(__classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this), __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2);
3875
3223
  }
3876
3224
  return "";
3877
3225
  }
3878
3226
  //* Format the number to the given format.
3879
3227
  getNumber(format) {
3880
- if (intlTelInput.utils && this.ui.telInput) {
3881
- const { iso2 } = this.selectedCountryData;
3882
- const fullNumber = this._getFullNumber();
3228
+ if (intlTelInput.utils && __classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3229
+ const { iso2 } = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
3230
+ const fullNumber = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this);
3883
3231
  const formattedNumber = intlTelInput.utils.formatNumber(fullNumber, iso2, format);
3884
- const currentVal = this.ui.telInput.value;
3885
- return this.numerals.denormalise(formattedNumber, currentVal);
3232
+ const currentVal = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.value;
3233
+ return __classPrivateFieldGet3(this, _Iti_numerals, "f").denormalise(formattedNumber, currentVal);
3886
3234
  }
3887
3235
  return "";
3888
3236
  }
3889
3237
  //* Get the type of the entered number e.g. landline/mobile.
3890
3238
  getNumberType() {
3891
- if (intlTelInput.utils && this.ui.telInput) {
3892
- return intlTelInput.utils.getNumberType(this._getFullNumber(), this.selectedCountryData.iso2);
3239
+ if (intlTelInput.utils && __classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3240
+ return intlTelInput.utils.getNumberType(__classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this), __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2);
3893
3241
  }
3894
3242
  return SENTINELS.UNKNOWN_NUMBER_TYPE;
3895
3243
  }
3896
3244
  //* Get the country data for the currently selected country.
3897
3245
  getSelectedCountryData() {
3898
- return this.selectedCountryData;
3246
+ return __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
3899
3247
  }
3900
3248
  //* Get the validation error.
3901
3249
  getValidationError() {
3902
- if (intlTelInput.utils && this.ui.telInput) {
3903
- const { iso2 } = this.selectedCountryData;
3904
- return intlTelInput.utils.getValidationError(this._getFullNumber(), iso2);
3250
+ if (intlTelInput.utils && __classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3251
+ const { iso2 } = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
3252
+ return intlTelInput.utils.getValidationError(__classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this), iso2);
3905
3253
  }
3906
3254
  return SENTINELS.UNKNOWN_VALIDATION_ERROR;
3907
3255
  }
3908
3256
  //* Validate the input val using number length only
3909
3257
  isValidNumber() {
3910
- const { dialCode, iso2 } = this.selectedCountryData;
3911
- if (dialCode === UK.DIAL_CODE && intlTelInput.utils && this.ui.telInput) {
3912
- const number = this._getFullNumber();
3258
+ const { dialCode, iso2 } = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
3259
+ if (intlTelInput.utils && __classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3260
+ const number = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this);
3913
3261
  const coreNumber = intlTelInput.utils.getCoreNumber(number, iso2);
3914
- if (coreNumber && coreNumber[0] === UK.MOBILE_PREFIX && coreNumber.length !== UK.MOBILE_CORE_LENGTH) {
3915
- return false;
3262
+ if (coreNumber) {
3263
+ if (dialCode === UK.DIAL_CODE) {
3264
+ if (coreNumber[0] === UK.MOBILE_PREFIX && coreNumber.length !== UK.MOBILE_CORE_LENGTH) {
3265
+ return false;
3266
+ }
3267
+ }
3268
+ const hasAlphaChar = REGEX.ALPHA_UNICODE.test(number);
3269
+ if (!hasAlphaChar && dialCode) {
3270
+ const nationalPortion = number.startsWith("+") ? number.slice(1 + dialCode.length) : number;
3271
+ const nationalDigitCount = getNumeric(nationalPortion).length;
3272
+ if (coreNumber.length > nationalDigitCount) {
3273
+ return false;
3274
+ }
3275
+ }
3916
3276
  }
3917
3277
  }
3918
- return this._validateNumber(false);
3278
+ return __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_validateNumber).call(this, false);
3919
3279
  }
3920
3280
  //* Validate the input val with precise validation
3921
3281
  isValidNumberPrecise() {
3922
- return this._validateNumber(true);
3923
- }
3924
- _utilsIsPossibleNumber(val) {
3925
- return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.allowedNumberTypes) : null;
3926
- }
3927
- //* Shared internal validation logic to handle alpha character extension rules.
3928
- _validateNumber(precise) {
3929
- if (!intlTelInput.utils || !this.ui.telInput) {
3930
- return null;
3931
- }
3932
- const { allowNumberExtensions, allowPhonewords } = this.options;
3933
- const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
3934
- const val = this._getFullNumber();
3935
- if (!this.selectedCountryData.iso2) {
3936
- const isRegionlessDialCode = hasRegionlessDialCode(val);
3937
- if (!isRegionlessDialCode) {
3938
- return false;
3939
- }
3940
- }
3941
- if (!testValidity(val)) {
3942
- return false;
3943
- }
3944
- const alphaCharPosition = val.search(REGEX.ALPHA_UNICODE);
3945
- const hasAlphaChar = alphaCharPosition > -1;
3946
- if (hasAlphaChar) {
3947
- const selectedIso2 = this.selectedCountryData.iso2;
3948
- const hasExtension = Boolean(intlTelInput.utils.getExtension(val, selectedIso2));
3949
- if (hasExtension) {
3950
- return allowNumberExtensions;
3951
- }
3952
- return allowPhonewords;
3953
- }
3954
- return true;
3955
- }
3956
- _utilsIsValidNumber(val) {
3957
- return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.allowedNumberTypes) : null;
3282
+ return __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_validateNumber).call(this, true);
3958
3283
  }
3959
3284
  //* Update the selected country, and update the input val accordingly.
3960
3285
  setCountry(iso2) {
3961
- if (!this.ui.telInput) {
3286
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3962
3287
  return;
3963
3288
  }
3964
3289
  const iso2Lower = iso2 === null || iso2 === void 0 ? void 0 : iso2.toLowerCase();
3965
3290
  if (!isIso22(iso2Lower)) {
3966
3291
  throw new Error(`Invalid country code: '${iso2Lower}'`);
3967
3292
  }
3968
- const currentCountry = this.selectedCountryData.iso2;
3293
+ const currentCountry = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2;
3969
3294
  const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry;
3970
3295
  if (isCountryChange) {
3971
- this._setCountry(iso2Lower);
3972
- this._updateDialCode(this.selectedCountryData.dialCode);
3973
- if (this.options.formatOnDisplay) {
3974
- const inputValue = this._getTelInputValue();
3975
- this._updateValFromNumber(inputValue);
3296
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setCountry).call(this, iso2Lower);
3297
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateDialCode).call(this, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").dialCode);
3298
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").formatOnDisplay) {
3299
+ const inputValue = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
3300
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateValFromNumber).call(this, inputValue);
3976
3301
  }
3977
- this._triggerCountryChange();
3302
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_triggerCountryChange).call(this);
3978
3303
  }
3979
3304
  }
3980
3305
  //* Set the input value and update the country.
3981
3306
  setNumber(number) {
3982
- if (!this.ui.telInput) {
3307
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3983
3308
  return;
3984
3309
  }
3985
- const normalisedNumber = this.numerals.normalise(number);
3986
- const countryChanged = this._updateCountryFromNumber(normalisedNumber);
3987
- this._updateValFromNumber(normalisedNumber);
3310
+ const normalisedNumber = __classPrivateFieldGet3(this, _Iti_numerals, "f").normalise(number);
3311
+ const countryChanged = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateCountryFromNumber).call(this, normalisedNumber);
3312
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateValFromNumber).call(this, normalisedNumber);
3988
3313
  if (countryChanged) {
3989
- this._triggerCountryChange();
3314
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_triggerCountryChange).call(this);
3990
3315
  }
3991
- this._trigger(EVENTS.INPUT, { isSetNumber: true });
3316
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_trigger).call(this, EVENTS.INPUT, { isSetNumber: true });
3992
3317
  }
3993
3318
  //* Set the placeholder number typ
3994
3319
  setPlaceholderNumberType(type) {
3995
- if (!this.ui.telInput) {
3320
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
3996
3321
  return;
3997
3322
  }
3998
- this.options.placeholderNumberType = type;
3999
- this._updatePlaceholder();
3323
+ __classPrivateFieldGet3(this, _Iti_options, "f").placeholderNumberType = type;
3324
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updatePlaceholder).call(this);
4000
3325
  }
4001
3326
  setDisabled(disabled) {
4002
- if (!this.ui.telInput) {
3327
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
4003
3328
  return;
4004
3329
  }
4005
- this.ui.telInput.disabled = disabled;
3330
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.disabled = disabled;
4006
3331
  if (disabled) {
4007
- this.ui.selectedCountry.setAttribute("disabled", "true");
3332
+ __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountry.setAttribute("disabled", "true");
3333
+ } else {
3334
+ __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountry.removeAttribute("disabled");
3335
+ }
3336
+ }
3337
+ //********************
3338
+ //* STATIC METHODS
3339
+ //********************
3340
+ // Internal instance notification used by utils/geoip loaders.
3341
+ // Kept public so module-level helpers (e.g. attachUtils) can call it, while still allowing
3342
+ // access to private instance methods.
3343
+ static forEachInstance(method, ...args) {
3344
+ const instances = intlTelInput.instances;
3345
+ const values = instances instanceof Map ? Array.from(instances.values()) : Object.values(instances);
3346
+ const arg = args[0];
3347
+ values.forEach((instance) => {
3348
+ if (!(instance instanceof _a2)) {
3349
+ return;
3350
+ }
3351
+ switch (method) {
3352
+ case "handleUtils":
3353
+ __classPrivateFieldGet3(instance, _Iti_instances, "m", _Iti_handleUtils).call(instance);
3354
+ break;
3355
+ case "handleUtilsFailure":
3356
+ __classPrivateFieldGet3(instance, _Iti_instances, "m", _Iti_handleUtilsFailure).call(instance, arg);
3357
+ break;
3358
+ case "handleAutoCountry":
3359
+ __classPrivateFieldGet3(instance, _Iti_instances, "m", _Iti_handleAutoCountry).call(instance);
3360
+ break;
3361
+ case "handleAutoCountryFailure":
3362
+ __classPrivateFieldGet3(instance, _Iti_instances, "m", _Iti_handleAutoCountryFailure).call(instance);
3363
+ break;
3364
+ }
3365
+ });
3366
+ }
3367
+ };
3368
+ _a2 = Iti, _Iti_ui = /* @__PURE__ */ new WeakMap(), _Iti_options = /* @__PURE__ */ new WeakMap(), _Iti_isAndroid = /* @__PURE__ */ new WeakMap(), _Iti_countries = /* @__PURE__ */ new WeakMap(), _Iti_dialCodeMaxLen = /* @__PURE__ */ new WeakMap(), _Iti_dialCodeToIso2Map = /* @__PURE__ */ new WeakMap(), _Iti_dialCodes = /* @__PURE__ */ new WeakMap(), _Iti_countryByIso2 = /* @__PURE__ */ new WeakMap(), _Iti_selectedCountryData = /* @__PURE__ */ new WeakMap(), _Iti_maxCoreNumberLength = /* @__PURE__ */ new WeakMap(), _Iti_defaultCountry = /* @__PURE__ */ new WeakMap(), _Iti_abortController = /* @__PURE__ */ new WeakMap(), _Iti_dropdownAbortController = /* @__PURE__ */ new WeakMap(), _Iti_numerals = /* @__PURE__ */ new WeakMap(), _Iti_resolveAutoCountryPromise = /* @__PURE__ */ new WeakMap(), _Iti_rejectAutoCountryPromise = /* @__PURE__ */ new WeakMap(), _Iti_resolveUtilsScriptPromise = /* @__PURE__ */ new WeakMap(), _Iti_rejectUtilsScriptPromise = /* @__PURE__ */ new WeakMap(), _Iti_instances = /* @__PURE__ */ new WeakSet(), _Iti_getTelInputValue = function _Iti_getTelInputValue2() {
3369
+ const inputValue = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.value.trim();
3370
+ return __classPrivateFieldGet3(this, _Iti_numerals, "f").normalise(inputValue);
3371
+ }, _Iti_setTelInputValue = function _Iti_setTelInputValue2(asciiValue) {
3372
+ const currentValue = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.value;
3373
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.value = __classPrivateFieldGet3(this, _Iti_numerals, "f").denormalise(asciiValue, currentValue);
3374
+ }, _Iti_createInitPromises = function _Iti_createInitPromises2(options) {
3375
+ const { initialCountry, geoIpLookup, loadUtils } = options;
3376
+ const needsAutoCountryPromise = initialCountry === INITIAL_COUNTRY.AUTO && Boolean(geoIpLookup);
3377
+ const needsUtilsScriptPromise = Boolean(loadUtils) && !intlTelInput.utils;
3378
+ let autoCountryPromise;
3379
+ if (needsAutoCountryPromise) {
3380
+ autoCountryPromise = new Promise((resolve, reject) => {
3381
+ __classPrivateFieldSet3(this, _Iti_resolveAutoCountryPromise, resolve, "f");
3382
+ __classPrivateFieldSet3(this, _Iti_rejectAutoCountryPromise, reject, "f");
3383
+ });
3384
+ } else {
3385
+ autoCountryPromise = Promise.resolve(void 0);
3386
+ __classPrivateFieldSet3(this, _Iti_resolveAutoCountryPromise, () => {
3387
+ }, "f");
3388
+ __classPrivateFieldSet3(this, _Iti_rejectAutoCountryPromise, () => {
3389
+ }, "f");
3390
+ }
3391
+ let utilsScriptPromise;
3392
+ if (needsUtilsScriptPromise) {
3393
+ utilsScriptPromise = new Promise((resolve, reject) => {
3394
+ __classPrivateFieldSet3(this, _Iti_resolveUtilsScriptPromise, resolve, "f");
3395
+ __classPrivateFieldSet3(this, _Iti_rejectUtilsScriptPromise, reject, "f");
3396
+ });
3397
+ } else {
3398
+ utilsScriptPromise = Promise.resolve(void 0);
3399
+ __classPrivateFieldSet3(this, _Iti_resolveUtilsScriptPromise, () => {
3400
+ }, "f");
3401
+ __classPrivateFieldSet3(this, _Iti_rejectUtilsScriptPromise, () => {
3402
+ }, "f");
3403
+ }
3404
+ return Promise.all([autoCountryPromise, utilsScriptPromise]);
3405
+ }, _Iti_init = function _Iti_init2() {
3406
+ __classPrivateFieldSet3(this, _Iti_selectedCountryData, {}, "f");
3407
+ __classPrivateFieldSet3(this, _Iti_abortController, new AbortController(), "f");
3408
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_processCountryData).call(this);
3409
+ __classPrivateFieldGet3(this, _Iti_ui, "f").generateMarkup(__classPrivateFieldGet3(this, _Iti_countries, "f"));
3410
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setInitialState).call(this);
3411
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_initListeners).call(this);
3412
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_initRequests).call(this);
3413
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").dropdownAlwaysOpen) {
3414
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_openDropdown).call(this);
3415
+ }
3416
+ }, _Iti_processCountryData = function _Iti_processCountryData2() {
3417
+ generateCountryNames(__classPrivateFieldGet3(this, _Iti_countries, "f"), __classPrivateFieldGet3(this, _Iti_options, "f"));
3418
+ sortCountries(__classPrivateFieldGet3(this, _Iti_countries, "f"), __classPrivateFieldGet3(this, _Iti_options, "f"));
3419
+ cacheSearchTokens(__classPrivateFieldGet3(this, _Iti_countries, "f"));
3420
+ }, _Iti_setInitialState = function _Iti_setInitialState2(overrideAutoCountry = false) {
3421
+ const attributeValueRaw = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.getAttribute("value");
3422
+ const attributeValue = __classPrivateFieldGet3(this, _Iti_numerals, "f").normalise(attributeValueRaw);
3423
+ const inputValue = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
3424
+ const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
3425
+ const val = useAttribute ? attributeValue : inputValue;
3426
+ const dialCode = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getDialCode).call(this, val);
3427
+ const isRegionlessNanpNumber = isRegionlessNanp(val);
3428
+ const { initialCountry, geoIpLookup } = __classPrivateFieldGet3(this, _Iti_options, "f");
3429
+ const isAutoCountry = initialCountry === INITIAL_COUNTRY.AUTO && geoIpLookup;
3430
+ const doingAutoCountryLookup = isAutoCountry && !overrideAutoCountry;
3431
+ const initialCountryLower = initialCountry.toLowerCase();
3432
+ const isValidInitialCountry = isIso22(initialCountryLower);
3433
+ if (dialCode) {
3434
+ if (isRegionlessNanpNumber) {
3435
+ if (isValidInitialCountry) {
3436
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setCountry).call(this, initialCountryLower);
3437
+ } else if (!doingAutoCountryLookup) {
3438
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setCountry).call(this, US.ISO2);
3439
+ }
3440
+ } else {
3441
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateCountryFromNumber).call(this, val);
3442
+ }
3443
+ } else if (isValidInitialCountry) {
3444
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setCountry).call(this, initialCountryLower);
3445
+ } else if (!doingAutoCountryLookup) {
3446
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setCountry).call(this, "");
3447
+ }
3448
+ if (val) {
3449
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateValFromNumber).call(this, val);
3450
+ }
3451
+ }, _Iti_initListeners = function _Iti_initListeners2() {
3452
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_initTelInputListeners).call(this);
3453
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").allowDropdown) {
3454
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_initDropdownListeners).call(this);
3455
+ }
3456
+ if ((__classPrivateFieldGet3(this, _Iti_ui, "f").hiddenInput || __classPrivateFieldGet3(this, _Iti_ui, "f").hiddenInputCountry) && __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.form) {
3457
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_initHiddenInputListener).call(this);
3458
+ }
3459
+ }, _Iti_initHiddenInputListener = function _Iti_initHiddenInputListener2() {
3460
+ var _b;
3461
+ const handleHiddenInputSubmit = () => {
3462
+ if (__classPrivateFieldGet3(this, _Iti_ui, "f").hiddenInput) {
3463
+ __classPrivateFieldGet3(this, _Iti_ui, "f").hiddenInput.value = this.getNumber();
3464
+ }
3465
+ if (__classPrivateFieldGet3(this, _Iti_ui, "f").hiddenInputCountry) {
3466
+ __classPrivateFieldGet3(this, _Iti_ui, "f").hiddenInputCountry.value = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2 || "";
3467
+ }
3468
+ };
3469
+ (_b = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.form) === null || _b === void 0 ? void 0 : _b.addEventListener("submit", handleHiddenInputSubmit, {
3470
+ signal: __classPrivateFieldGet3(this, _Iti_abortController, "f").signal
3471
+ });
3472
+ }, _Iti_initDropdownListeners = function _Iti_initDropdownListeners2() {
3473
+ const signal = __classPrivateFieldGet3(this, _Iti_abortController, "f").signal;
3474
+ const handleLabelClick = (e) => {
3475
+ if (__classPrivateFieldGet3(this, _Iti_ui, "f").isDropdownClosed()) {
3476
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.focus();
3477
+ } else {
3478
+ e.preventDefault();
3479
+ }
3480
+ };
3481
+ const label = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.closest("label");
3482
+ if (label) {
3483
+ label.addEventListener("click", handleLabelClick, { signal });
3484
+ }
3485
+ const handleClickSelectedCountry = () => {
3486
+ if (__classPrivateFieldGet3(this, _Iti_ui, "f").isDropdownClosed() && !__classPrivateFieldGet3(this, _Iti_ui, "f").telInput.disabled && !__classPrivateFieldGet3(this, _Iti_ui, "f").telInput.readOnly) {
3487
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_openDropdown).call(this);
3488
+ }
3489
+ };
3490
+ __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountry.addEventListener("click", handleClickSelectedCountry, {
3491
+ signal
3492
+ });
3493
+ const handleCountryContainerKeydown = (e) => {
3494
+ const allowedKeys = [KEYS.ARROW_UP, KEYS.ARROW_DOWN, KEYS.SPACE, KEYS.ENTER];
3495
+ if (__classPrivateFieldGet3(this, _Iti_ui, "f").isDropdownClosed() && allowedKeys.includes(e.key)) {
3496
+ e.preventDefault();
3497
+ e.stopPropagation();
3498
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_openDropdown).call(this);
3499
+ }
3500
+ if (e.key === KEYS.TAB) {
3501
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_closeDropdown).call(this);
3502
+ }
3503
+ };
3504
+ __classPrivateFieldGet3(this, _Iti_ui, "f").countryContainer.addEventListener("keydown", handleCountryContainerKeydown, { signal });
3505
+ }, _Iti_initRequests = function _Iti_initRequests2() {
3506
+ const { loadUtils, initialCountry, geoIpLookup } = __classPrivateFieldGet3(this, _Iti_options, "f");
3507
+ if (loadUtils && !intlTelInput.utils) {
3508
+ const doAttachUtils = () => {
3509
+ var _b;
3510
+ (_b = intlTelInput.attachUtils(loadUtils)) === null || _b === void 0 ? void 0 : _b.catch(() => {
3511
+ });
3512
+ };
3513
+ if (intlTelInput.documentReady()) {
3514
+ doAttachUtils();
3515
+ } else {
3516
+ const handlePageLoad = () => {
3517
+ doAttachUtils();
3518
+ };
3519
+ window.addEventListener("load", handlePageLoad, {
3520
+ signal: __classPrivateFieldGet3(this, _Iti_abortController, "f").signal
3521
+ });
3522
+ }
3523
+ } else {
3524
+ __classPrivateFieldGet3(this, _Iti_resolveUtilsScriptPromise, "f").call(this);
3525
+ }
3526
+ const isAutoCountry = initialCountry === INITIAL_COUNTRY.AUTO && geoIpLookup;
3527
+ if (isAutoCountry) {
3528
+ if (__classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2) {
3529
+ __classPrivateFieldGet3(this, _Iti_resolveAutoCountryPromise, "f").call(this);
3530
+ } else {
3531
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_loadAutoCountry).call(this);
3532
+ }
3533
+ }
3534
+ }, _Iti_loadAutoCountry = function _Iti_loadAutoCountry2() {
3535
+ if (intlTelInput.autoCountry) {
3536
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_handleAutoCountry).call(this);
3537
+ } else {
3538
+ __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountryInner.classList.add(CLASSES.LOADING);
3539
+ if (!intlTelInput.startedLoadingAutoCountry) {
3540
+ intlTelInput.startedLoadingAutoCountry = true;
3541
+ if (typeof __classPrivateFieldGet3(this, _Iti_options, "f").geoIpLookup === "function") {
3542
+ const successCallback = (iso2 = "") => {
3543
+ __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountryInner.classList.remove(CLASSES.LOADING);
3544
+ const iso2Lower = iso2.toLowerCase();
3545
+ if (isIso22(iso2Lower)) {
3546
+ intlTelInput.autoCountry = iso2Lower;
3547
+ setTimeout(() => _a2.forEachInstance("handleAutoCountry"));
3548
+ } else {
3549
+ _a2.forEachInstance("handleAutoCountryFailure");
3550
+ }
3551
+ };
3552
+ const failureCallback = () => {
3553
+ __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountryInner.classList.remove(CLASSES.LOADING);
3554
+ _a2.forEachInstance("handleAutoCountryFailure");
3555
+ };
3556
+ __classPrivateFieldGet3(this, _Iti_options, "f").geoIpLookup(successCallback, failureCallback);
3557
+ }
3558
+ }
3559
+ }
3560
+ }, _Iti_openDropdownWithPlus = function _Iti_openDropdownWithPlus2() {
3561
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_openDropdown).call(this);
3562
+ __classPrivateFieldGet3(this, _Iti_ui, "f").searchInput.value = "+";
3563
+ __classPrivateFieldGet3(this, _Iti_ui, "f").filterCountriesByQuery("");
3564
+ }, _Iti_initTelInputListeners = function _Iti_initTelInputListeners2() {
3565
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_bindInputListener).call(this);
3566
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_maybeBindKeydownListener).call(this);
3567
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_maybeBindPasteListener).call(this);
3568
+ }, _Iti_bindInputListener = function _Iti_bindInputListener2() {
3569
+ const { strictMode, formatAsYouType, separateDialCode, allowDropdown, countrySearch } = __classPrivateFieldGet3(this, _Iti_options, "f");
3570
+ let userOverrideFormatting = false;
3571
+ if (REGEX.ALPHA_UNICODE.test(__classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this))) {
3572
+ userOverrideFormatting = true;
3573
+ }
3574
+ const handleInputEvent = (e) => {
3575
+ const inputValue = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
3576
+ if (__classPrivateFieldGet3(this, _Iti_isAndroid, "f") && (e === null || e === void 0 ? void 0 : e.data) === "+" && separateDialCode && allowDropdown && countrySearch) {
3577
+ const currentCaretPos = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.selectionStart || 0;
3578
+ const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
3579
+ const valueAfterCaret = inputValue.substring(currentCaretPos);
3580
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setTelInputValue).call(this, valueBeforeCaret + valueAfterCaret);
3581
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_openDropdownWithPlus).call(this);
3582
+ return;
3583
+ }
3584
+ if (__classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateCountryFromNumber).call(this, inputValue)) {
3585
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_triggerCountryChange).call(this);
3586
+ }
3587
+ const isFormattingChar = (e === null || e === void 0 ? void 0 : e.data) && REGEX.NON_PLUS_NUMERIC.test(e.data);
3588
+ const isPaste = (e === null || e === void 0 ? void 0 : e.inputType) === INPUT_TYPES.PASTE && inputValue;
3589
+ if (isFormattingChar || isPaste && !strictMode) {
3590
+ userOverrideFormatting = true;
3591
+ } else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
3592
+ userOverrideFormatting = false;
3593
+ }
3594
+ const isSetNumber = (e === null || e === void 0 ? void 0 : e.detail) && e.detail["isSetNumber"];
3595
+ const isAscii = __classPrivateFieldGet3(this, _Iti_numerals, "f").isAscii();
3596
+ if (formatAsYouType && !userOverrideFormatting && !isSetNumber && isAscii) {
3597
+ const currentCaretPos = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.selectionStart || 0;
3598
+ const valueBeforeCaret = inputValue.substring(0, currentCaretPos);
3599
+ const relevantCharsBeforeCaret = valueBeforeCaret.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "").length;
3600
+ const isDeleteForwards = (e === null || e === void 0 ? void 0 : e.inputType) === INPUT_TYPES.DELETE_FWD;
3601
+ const fullNumber = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this);
3602
+ const formattedValue = formatNumberAsYouType(fullNumber, inputValue, intlTelInput.utils, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f"), separateDialCode);
3603
+ const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
3604
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setTelInputValue).call(this, formattedValue);
3605
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.setSelectionRange(newCaretPos, newCaretPos);
3606
+ }
3607
+ if (separateDialCode && inputValue.startsWith("+") && __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").dialCode) {
3608
+ const cleanNumber = beforeSetNumber(inputValue, true, separateDialCode, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f"));
3609
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setTelInputValue).call(this, cleanNumber);
3610
+ }
3611
+ };
3612
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.addEventListener("input", handleInputEvent, {
3613
+ signal: __classPrivateFieldGet3(this, _Iti_abortController, "f").signal
3614
+ });
3615
+ }, _Iti_maybeBindKeydownListener = function _Iti_maybeBindKeydownListener2() {
3616
+ const { strictMode, separateDialCode, allowDropdown, countrySearch } = __classPrivateFieldGet3(this, _Iti_options, "f");
3617
+ if (strictMode || separateDialCode) {
3618
+ const handleKeydownEvent = (e) => {
3619
+ if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
3620
+ if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
3621
+ e.preventDefault();
3622
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_openDropdownWithPlus).call(this);
3623
+ return;
3624
+ }
3625
+ if (strictMode) {
3626
+ const inputValue = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
3627
+ const alreadyHasPlus = inputValue.startsWith("+");
3628
+ const isInitialPlus = !alreadyHasPlus && __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.selectionStart === 0 && e.key === "+";
3629
+ const normalisedKey = __classPrivateFieldGet3(this, _Iti_numerals, "f").normalise(e.key);
3630
+ const isNumeric = /^[0-9]$/.test(normalisedKey);
3631
+ const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
3632
+ const input = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput;
3633
+ const selStart = input.selectionStart;
3634
+ const selEnd = input.selectionEnd;
3635
+ const before = inputValue.slice(0, selStart);
3636
+ const after = inputValue.slice(selEnd);
3637
+ const newValue = before + e.key + after;
3638
+ const newFullNumber = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this, newValue);
3639
+ const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2);
3640
+ const hasExceededMaxLength = __classPrivateFieldGet3(this, _Iti_maxCoreNumberLength, "f") && coreNumber.length > __classPrivateFieldGet3(this, _Iti_maxCoreNumberLength, "f");
3641
+ const newCountry = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getNewCountryFromNumber).call(this, newFullNumber);
3642
+ const isChangingDialCode = newCountry !== null;
3643
+ if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
3644
+ e.preventDefault();
3645
+ }
3646
+ }
3647
+ }
3648
+ };
3649
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.addEventListener("keydown", handleKeydownEvent, {
3650
+ signal: __classPrivateFieldGet3(this, _Iti_abortController, "f").signal
3651
+ });
3652
+ }
3653
+ }, _Iti_maybeBindPasteListener = function _Iti_maybeBindPasteListener2() {
3654
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").strictMode) {
3655
+ const handlePasteEvent = (e) => {
3656
+ e.preventDefault();
3657
+ const input = __classPrivateFieldGet3(this, _Iti_ui, "f").telInput;
3658
+ const selStart = input.selectionStart;
3659
+ const selEnd = input.selectionEnd;
3660
+ const inputValue = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
3661
+ const before = inputValue.slice(0, selStart);
3662
+ const after = inputValue.slice(selEnd);
3663
+ const iso2 = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2;
3664
+ const pastedRaw = e.clipboardData.getData("text");
3665
+ const pasted = __classPrivateFieldGet3(this, _Iti_numerals, "f").normalise(pastedRaw);
3666
+ const initialCharSelected = selStart === 0 && selEnd > 0;
3667
+ const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
3668
+ const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
3669
+ const hasLeadingPlus = allowedChars.startsWith("+");
3670
+ const numerics = allowedChars.replace(/\+/g, "");
3671
+ const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
3672
+ let newVal = before + sanitised + after;
3673
+ if (newVal.length > 5) {
3674
+ let coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
3675
+ while (coreNumber.length === 0 && newVal.length > 0) {
3676
+ newVal = newVal.slice(0, -1);
3677
+ coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
3678
+ }
3679
+ if (!coreNumber) {
3680
+ return;
3681
+ }
3682
+ if (__classPrivateFieldGet3(this, _Iti_maxCoreNumberLength, "f") && coreNumber.length > __classPrivateFieldGet3(this, _Iti_maxCoreNumberLength, "f")) {
3683
+ if (input.selectionEnd === inputValue.length) {
3684
+ const trimLength = coreNumber.length - __classPrivateFieldGet3(this, _Iti_maxCoreNumberLength, "f");
3685
+ newVal = newVal.slice(0, newVal.length - trimLength);
3686
+ } else {
3687
+ return;
3688
+ }
3689
+ }
3690
+ }
3691
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setTelInputValue).call(this, newVal);
3692
+ const caretPos = selStart + sanitised.length;
3693
+ input.setSelectionRange(caretPos, caretPos);
3694
+ input.dispatchEvent(new InputEvent("input", { bubbles: true }));
3695
+ };
3696
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.addEventListener("paste", handlePasteEvent, {
3697
+ signal: __classPrivateFieldGet3(this, _Iti_abortController, "f").signal
3698
+ });
3699
+ }
3700
+ }, _Iti_cap = function _Iti_cap2(number) {
3701
+ const max = Number(__classPrivateFieldGet3(this, _Iti_ui, "f").telInput.getAttribute("maxlength"));
3702
+ return max && number.length > max ? number.substring(0, max) : number;
3703
+ }, _Iti_trigger = function _Iti_trigger2(name, detailProps = {}) {
3704
+ const e = new CustomEvent(name, {
3705
+ bubbles: true,
3706
+ cancelable: true,
3707
+ detail: detailProps
3708
+ });
3709
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.dispatchEvent(e);
3710
+ }, _Iti_openDropdown = function _Iti_openDropdown2() {
3711
+ const { dropdownContainer, useFullscreenPopup } = __classPrivateFieldGet3(this, _Iti_options, "f");
3712
+ __classPrivateFieldSet3(this, _Iti_dropdownAbortController, new AbortController(), "f");
3713
+ __classPrivateFieldGet3(this, _Iti_ui, "f").openDropdown();
3714
+ if (!useFullscreenPopup && dropdownContainer) {
3715
+ const handleWindowScroll = () => __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_closeDropdown).call(this);
3716
+ window.addEventListener("scroll", handleWindowScroll, {
3717
+ signal: __classPrivateFieldGet3(this, _Iti_dropdownAbortController, "f").signal
3718
+ });
3719
+ }
3720
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_bindDropdownListeners).call(this);
3721
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_trigger).call(this, EVENTS.OPEN_COUNTRY_DROPDOWN);
3722
+ }, _Iti_bindDropdownListeners = function _Iti_bindDropdownListeners2() {
3723
+ const signal = __classPrivateFieldGet3(this, _Iti_dropdownAbortController, "f").signal;
3724
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_bindDropdownMouseoverListener).call(this, signal);
3725
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_bindDropdownCountryClickListener).call(this, signal);
3726
+ if (!__classPrivateFieldGet3(this, _Iti_options, "f").dropdownAlwaysOpen) {
3727
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_bindDropdownClickOffListener).call(this, signal);
3728
+ }
3729
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_bindDropdownKeydownListener).call(this, signal);
3730
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").countrySearch) {
3731
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_bindDropdownSearchListeners).call(this, signal);
3732
+ }
3733
+ }, _Iti_bindDropdownMouseoverListener = function _Iti_bindDropdownMouseoverListener2(signal) {
3734
+ const handleMouseoverCountryList = (e) => {
3735
+ var _b;
3736
+ const listItem = (_b = e.target) === null || _b === void 0 ? void 0 : _b.closest(`.${CLASSES.COUNTRY_ITEM}`);
3737
+ if (listItem) {
3738
+ __classPrivateFieldGet3(this, _Iti_ui, "f").highlightListItem(listItem, false);
3739
+ }
3740
+ };
3741
+ __classPrivateFieldGet3(this, _Iti_ui, "f").countryList.addEventListener("mouseover", handleMouseoverCountryList, {
3742
+ signal
3743
+ });
3744
+ }, _Iti_bindDropdownCountryClickListener = function _Iti_bindDropdownCountryClickListener2(signal) {
3745
+ const handleClickCountryList = (e) => {
3746
+ var _b;
3747
+ const listItem = (_b = e.target) === null || _b === void 0 ? void 0 : _b.closest(`.${CLASSES.COUNTRY_ITEM}`);
3748
+ if (listItem) {
3749
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_selectListItem).call(this, listItem);
3750
+ }
3751
+ };
3752
+ __classPrivateFieldGet3(this, _Iti_ui, "f").countryList.addEventListener("click", handleClickCountryList, {
3753
+ signal
3754
+ });
3755
+ }, _Iti_bindDropdownClickOffListener = function _Iti_bindDropdownClickOffListener2(signal) {
3756
+ const handleClickOffToClose = (e) => {
3757
+ const target = e.target;
3758
+ const clickedInsideDropdown = !!target.closest(`#iti-${this.id}__dropdown-content`);
3759
+ if (!clickedInsideDropdown) {
3760
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_closeDropdown).call(this);
3761
+ }
3762
+ };
3763
+ setTimeout(() => {
3764
+ document.documentElement.addEventListener("click", handleClickOffToClose, { signal });
3765
+ }, 0);
3766
+ }, _Iti_bindDropdownKeydownListener = function _Iti_bindDropdownKeydownListener2(signal) {
3767
+ let query = "";
3768
+ let queryTimer = null;
3769
+ const handleKeydownOnDropdown = (e) => {
3770
+ const allowedKeys = [
3771
+ KEYS.ARROW_UP,
3772
+ KEYS.ARROW_DOWN,
3773
+ KEYS.ENTER,
3774
+ KEYS.ESC
3775
+ ];
3776
+ if (allowedKeys.includes(e.key)) {
3777
+ e.preventDefault();
3778
+ e.stopPropagation();
3779
+ if (e.key === KEYS.ARROW_UP || e.key === KEYS.ARROW_DOWN) {
3780
+ __classPrivateFieldGet3(this, _Iti_ui, "f").handleUpDownKey(e.key);
3781
+ } else if (e.key === KEYS.ENTER) {
3782
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_handleEnterKey).call(this);
3783
+ } else if (e.key === KEYS.ESC) {
3784
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_closeDropdown).call(this);
3785
+ __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountry.focus();
3786
+ }
3787
+ }
3788
+ if (!__classPrivateFieldGet3(this, _Iti_options, "f").countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
3789
+ e.stopPropagation();
3790
+ if (queryTimer) {
3791
+ clearTimeout(queryTimer);
3792
+ }
3793
+ query += e.key.toLowerCase();
3794
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_searchForCountry).call(this, query);
3795
+ queryTimer = setTimeout(() => {
3796
+ query = "";
3797
+ }, TIMINGS.HIDDEN_SEARCH_RESET_MS);
3798
+ }
3799
+ };
3800
+ document.addEventListener("keydown", handleKeydownOnDropdown, { signal });
3801
+ }, _Iti_bindDropdownSearchListeners = function _Iti_bindDropdownSearchListeners2(signal) {
3802
+ __classPrivateFieldGet3(this, _Iti_ui, "f").searchInput.addEventListener("input", () => __classPrivateFieldGet3(this, _Iti_ui, "f").handleSearchChange(), { signal });
3803
+ __classPrivateFieldGet3(this, _Iti_ui, "f").searchClearButton.addEventListener("click", () => __classPrivateFieldGet3(this, _Iti_ui, "f").handleSearchClear(), { signal });
3804
+ }, _Iti_searchForCountry = function _Iti_searchForCountry2(query) {
3805
+ const match = findFirstCountryStartingWith(__classPrivateFieldGet3(this, _Iti_countries, "f"), query);
3806
+ if (match) {
3807
+ const listItem = match.nodeById[this.id];
3808
+ __classPrivateFieldGet3(this, _Iti_ui, "f").highlightListItem(listItem, false);
3809
+ __classPrivateFieldGet3(this, _Iti_ui, "f").scrollTo(listItem);
3810
+ }
3811
+ }, _Iti_handleEnterKey = function _Iti_handleEnterKey2() {
3812
+ if (__classPrivateFieldGet3(this, _Iti_ui, "f").highlightedItem) {
3813
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_selectListItem).call(this, __classPrivateFieldGet3(this, _Iti_ui, "f").highlightedItem);
3814
+ }
3815
+ }, _Iti_updateValFromNumber = function _Iti_updateValFromNumber2(fullNumber) {
3816
+ const { formatOnDisplay, nationalMode, separateDialCode } = __classPrivateFieldGet3(this, _Iti_options, "f");
3817
+ let number = fullNumber;
3818
+ if (formatOnDisplay && intlTelInput.utils && __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f")) {
3819
+ const isRegionless = hasRegionlessDialCode(fullNumber);
3820
+ const useNational = nationalMode && !isRegionless || !number.startsWith("+") && !separateDialCode;
3821
+ const { NATIONAL, INTERNATIONAL } = intlTelInput.utils.numberFormat;
3822
+ const format = useNational ? NATIONAL : INTERNATIONAL;
3823
+ number = intlTelInput.utils.formatNumber(number, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2, format);
3824
+ }
3825
+ number = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_beforeSetNumber).call(this, number);
3826
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setTelInputValue).call(this, number);
3827
+ }, _Iti_updateCountryFromNumber = function _Iti_updateCountryFromNumber2(fullNumber) {
3828
+ const iso2 = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getNewCountryFromNumber).call(this, fullNumber);
3829
+ if (iso2 !== null) {
3830
+ return __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setCountry).call(this, iso2);
3831
+ }
3832
+ return false;
3833
+ }, _Iti_ensureHasDialCode = function _Iti_ensureHasDialCode2(number) {
3834
+ const { dialCode, nationalPrefix } = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
3835
+ const alreadyHasPlus = number.startsWith("+");
3836
+ if (alreadyHasPlus || !dialCode) {
3837
+ return number;
3838
+ }
3839
+ const hasPrefix = nationalPrefix && number.startsWith(nationalPrefix) && !__classPrivateFieldGet3(this, _Iti_options, "f").separateDialCode;
3840
+ const cleanNumber = hasPrefix ? number.substring(1) : number;
3841
+ return `+${dialCode}${cleanNumber}`;
3842
+ }, _Iti_getNewCountryFromNumber = function _Iti_getNewCountryFromNumber2(fullNumber) {
3843
+ const plusIndex = fullNumber.indexOf("+");
3844
+ let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
3845
+ const selectedIso2 = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2;
3846
+ const selectedDialCode = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").dialCode;
3847
+ number = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_ensureHasDialCode).call(this, number);
3848
+ const dialCodeMatch = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getDialCode).call(this, number, true);
3849
+ const numeric = getNumeric(number);
3850
+ if (dialCodeMatch) {
3851
+ const dialCodeMatchNumeric = getNumeric(dialCodeMatch);
3852
+ const iso2Codes = __classPrivateFieldGet3(this, _Iti_dialCodeToIso2Map, "f")[dialCodeMatchNumeric];
3853
+ if (iso2Codes.length === 1) {
3854
+ if (iso2Codes[0] === selectedIso2) {
3855
+ return null;
3856
+ }
3857
+ return iso2Codes[0];
3858
+ }
3859
+ if (!selectedIso2 && __classPrivateFieldGet3(this, _Iti_defaultCountry, "f") && iso2Codes.includes(__classPrivateFieldGet3(this, _Iti_defaultCountry, "f"))) {
3860
+ return __classPrivateFieldGet3(this, _Iti_defaultCountry, "f");
3861
+ }
3862
+ const isRegionlessNanpNumber = selectedDialCode === DIAL.NANP && isRegionlessNanp(numeric);
3863
+ if (isRegionlessNanpNumber) {
3864
+ return null;
3865
+ }
3866
+ const { areaCodes, priority } = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
3867
+ if (areaCodes) {
3868
+ const dialCodeAreaCodes = areaCodes.map((areaCode) => `${selectedDialCode}${areaCode}`);
3869
+ for (const dialCodeAreaCode of dialCodeAreaCodes) {
3870
+ if (numeric.startsWith(dialCodeAreaCode)) {
3871
+ return null;
3872
+ }
3873
+ }
3874
+ }
3875
+ const isMainCountry = priority === 0;
3876
+ const hasAreaCodesButNoneMatched = areaCodes && !isMainCountry && numeric.length > dialCodeMatchNumeric.length;
3877
+ const isValidSelection = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
3878
+ const alreadySelected = selectedIso2 === iso2Codes[0];
3879
+ if (!isValidSelection && !alreadySelected) {
3880
+ return iso2Codes[0];
3881
+ }
3882
+ } else if (number.startsWith("+") && numeric.length) {
3883
+ const currentDial = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").dialCode || "";
3884
+ if (currentDial && currentDial.startsWith(numeric)) {
3885
+ return null;
3886
+ }
3887
+ return "";
3888
+ } else if ((!number || number === "+") && !selectedIso2 && __classPrivateFieldGet3(this, _Iti_defaultCountry, "f")) {
3889
+ return __classPrivateFieldGet3(this, _Iti_defaultCountry, "f");
3890
+ }
3891
+ return null;
3892
+ }, _Iti_setCountry = function _Iti_setCountry2(iso2) {
3893
+ const prevIso2 = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2 || "";
3894
+ __classPrivateFieldSet3(this, _Iti_selectedCountryData, iso2 ? __classPrivateFieldGet3(this, _Iti_countryByIso2, "f").get(iso2) : {}, "f");
3895
+ if (__classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2) {
3896
+ __classPrivateFieldSet3(this, _Iti_defaultCountry, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2, "f");
3897
+ }
3898
+ __classPrivateFieldGet3(this, _Iti_ui, "f").setCountry(__classPrivateFieldGet3(this, _Iti_selectedCountryData, "f"));
3899
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updatePlaceholder).call(this);
3900
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateMaxLength).call(this);
3901
+ return prevIso2 !== iso2;
3902
+ }, _Iti_updateMaxLength = function _Iti_updateMaxLength2() {
3903
+ const { strictMode, placeholderNumberType, allowedNumberTypes } = __classPrivateFieldGet3(this, _Iti_options, "f");
3904
+ const { iso2 } = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
3905
+ if (strictMode && intlTelInput.utils) {
3906
+ if (iso2) {
3907
+ const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3908
+ let exampleNumber = intlTelInput.utils.getExampleNumber(iso2, false, numberType, true);
3909
+ let validNumber = exampleNumber;
3910
+ while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, allowedNumberTypes)) {
3911
+ validNumber = exampleNumber;
3912
+ exampleNumber += "0";
3913
+ }
3914
+ const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
3915
+ __classPrivateFieldSet3(this, _Iti_maxCoreNumberLength, coreNumber.length, "f");
3916
+ if (iso2 === "by") {
3917
+ __classPrivateFieldSet3(this, _Iti_maxCoreNumberLength, coreNumber.length + 1, "f");
3918
+ }
3919
+ } else {
3920
+ __classPrivateFieldSet3(this, _Iti_maxCoreNumberLength, null, "f");
3921
+ }
3922
+ }
3923
+ }, _Iti_updatePlaceholder = function _Iti_updatePlaceholder2() {
3924
+ const { autoPlaceholder, placeholderNumberType, nationalMode, customPlaceholder } = __classPrivateFieldGet3(this, _Iti_options, "f");
3925
+ const shouldSetPlaceholder = autoPlaceholder === PLACEHOLDER_MODES.AGGRESSIVE || !__classPrivateFieldGet3(this, _Iti_ui, "f").hadInitialPlaceholder && autoPlaceholder === PLACEHOLDER_MODES.POLITE;
3926
+ if (intlTelInput.utils && shouldSetPlaceholder) {
3927
+ const numberType = intlTelInput.utils.numberType[placeholderNumberType];
3928
+ let placeholder = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2 ? intlTelInput.utils.getExampleNumber(__classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2, nationalMode, numberType) : "";
3929
+ placeholder = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_beforeSetNumber).call(this, placeholder);
3930
+ if (typeof customPlaceholder === "function") {
3931
+ placeholder = customPlaceholder(placeholder, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f"));
3932
+ }
3933
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.setAttribute("placeholder", placeholder);
3934
+ }
3935
+ }, _Iti_selectListItem = function _Iti_selectListItem2(listItem) {
3936
+ const iso2 = listItem.dataset[DATA_KEYS.COUNTRY_CODE];
3937
+ const countryChanged = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setCountry).call(this, iso2);
3938
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_closeDropdown).call(this);
3939
+ const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
3940
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateDialCode).call(this, dialCode);
3941
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").formatOnDisplay) {
3942
+ const inputValue = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
3943
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateValFromNumber).call(this, inputValue);
3944
+ }
3945
+ __classPrivateFieldGet3(this, _Iti_ui, "f").telInput.focus();
3946
+ if (countryChanged) {
3947
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_triggerCountryChange).call(this);
3948
+ }
3949
+ }, _Iti_closeDropdown = function _Iti_closeDropdown2(isDestroy) {
3950
+ if (__classPrivateFieldGet3(this, _Iti_ui, "f").isDropdownClosed() || __classPrivateFieldGet3(this, _Iti_options, "f").dropdownAlwaysOpen && !isDestroy) {
3951
+ return;
3952
+ }
3953
+ __classPrivateFieldGet3(this, _Iti_ui, "f").closeDropdown();
3954
+ __classPrivateFieldGet3(this, _Iti_dropdownAbortController, "f").abort();
3955
+ __classPrivateFieldSet3(this, _Iti_dropdownAbortController, null, "f");
3956
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_trigger).call(this, EVENTS.CLOSE_COUNTRY_DROPDOWN);
3957
+ }, _Iti_updateDialCode = function _Iti_updateDialCode2(newDialCodeBare) {
3958
+ const inputVal = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
3959
+ const newDialCode = `+${newDialCodeBare}`;
3960
+ let newNumber;
3961
+ if (inputVal.startsWith("+")) {
3962
+ const prevDialCode = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getDialCode).call(this, inputVal);
3963
+ if (prevDialCode) {
3964
+ newNumber = inputVal.replace(prevDialCode, newDialCode);
4008
3965
  } else {
4009
- this.ui.selectedCountry.removeAttribute("disabled");
3966
+ newNumber = newDialCode;
3967
+ }
3968
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setTelInputValue).call(this, newNumber);
3969
+ }
3970
+ }, _Iti_getDialCode = function _Iti_getDialCode2(number, includeAreaCode) {
3971
+ let dialCode = "";
3972
+ if (number.startsWith("+")) {
3973
+ let numericChars = "";
3974
+ let foundBaseDialCode = false;
3975
+ for (let i = 0; i < number.length; i++) {
3976
+ const c = number.charAt(i);
3977
+ if (/[0-9]/.test(c)) {
3978
+ numericChars += c;
3979
+ const hasMapEntry = Boolean(__classPrivateFieldGet3(this, _Iti_dialCodeToIso2Map, "f")[numericChars]);
3980
+ if (!hasMapEntry) {
3981
+ break;
3982
+ }
3983
+ if (__classPrivateFieldGet3(this, _Iti_dialCodes, "f").has(numericChars)) {
3984
+ dialCode = number.substring(0, i + 1);
3985
+ foundBaseDialCode = true;
3986
+ if (!includeAreaCode) {
3987
+ break;
3988
+ }
3989
+ } else if (includeAreaCode && foundBaseDialCode) {
3990
+ dialCode = number.substring(0, i + 1);
3991
+ }
3992
+ if (numericChars.length === __classPrivateFieldGet3(this, _Iti_dialCodeMaxLen, "f")) {
3993
+ break;
3994
+ }
3995
+ }
3996
+ }
3997
+ }
3998
+ return dialCode;
3999
+ }, _Iti_getFullNumber = function _Iti_getFullNumber2(overrideVal) {
4000
+ const val = overrideVal ? __classPrivateFieldGet3(this, _Iti_numerals, "f").normalise(overrideVal) : __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
4001
+ const { dialCode } = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f");
4002
+ let prefix;
4003
+ const numericVal = getNumeric(val);
4004
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").separateDialCode && !val.startsWith("+") && dialCode && numericVal) {
4005
+ prefix = `+${dialCode}`;
4006
+ } else {
4007
+ prefix = "";
4008
+ }
4009
+ return prefix + val;
4010
+ }, _Iti_beforeSetNumber = function _Iti_beforeSetNumber2(fullNumber) {
4011
+ const hasValidDialCode = Boolean(__classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getDialCode).call(this, fullNumber));
4012
+ const number = beforeSetNumber(fullNumber, hasValidDialCode, __classPrivateFieldGet3(this, _Iti_options, "f").separateDialCode, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f"));
4013
+ return __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_cap).call(this, number);
4014
+ }, _Iti_triggerCountryChange = function _Iti_triggerCountryChange2() {
4015
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_trigger).call(this, EVENTS.COUNTRY_CHANGE);
4016
+ }, _Iti_handleAutoCountry = function _Iti_handleAutoCountry2() {
4017
+ var _b;
4018
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
4019
+ (_b = __classPrivateFieldGet3(this, _Iti_resolveAutoCountryPromise, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
4020
+ return;
4021
+ }
4022
+ if (__classPrivateFieldGet3(this, _Iti_options, "f").initialCountry === INITIAL_COUNTRY.AUTO && intlTelInput.autoCountry) {
4023
+ __classPrivateFieldSet3(this, _Iti_defaultCountry, intlTelInput.autoCountry, "f");
4024
+ const hasSelectedCountryOrGlobe = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2 || __classPrivateFieldGet3(this, _Iti_ui, "f").selectedCountryInner.classList.contains(CLASSES.GLOBE);
4025
+ if (!hasSelectedCountryOrGlobe) {
4026
+ this.setCountry(__classPrivateFieldGet3(this, _Iti_defaultCountry, "f"));
4027
+ }
4028
+ __classPrivateFieldGet3(this, _Iti_resolveAutoCountryPromise, "f").call(this);
4029
+ }
4030
+ }, _Iti_handleAutoCountryFailure = function _Iti_handleAutoCountryFailure2() {
4031
+ var _b;
4032
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
4033
+ (_b = __classPrivateFieldGet3(this, _Iti_rejectAutoCountryPromise, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
4034
+ return;
4035
+ }
4036
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_setInitialState).call(this, true);
4037
+ __classPrivateFieldGet3(this, _Iti_rejectAutoCountryPromise, "f").call(this);
4038
+ }, _Iti_handleUtils = function _Iti_handleUtils2() {
4039
+ var _b;
4040
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
4041
+ (_b = __classPrivateFieldGet3(this, _Iti_resolveUtilsScriptPromise, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
4042
+ return;
4043
+ }
4044
+ if (intlTelInput.utils) {
4045
+ const inputValue = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getTelInputValue).call(this);
4046
+ if (inputValue) {
4047
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateValFromNumber).call(this, inputValue);
4048
+ }
4049
+ if (__classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2) {
4050
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updatePlaceholder).call(this);
4051
+ __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_updateMaxLength).call(this);
4052
+ }
4053
+ }
4054
+ __classPrivateFieldGet3(this, _Iti_resolveUtilsScriptPromise, "f").call(this);
4055
+ }, _Iti_handleUtilsFailure = function _Iti_handleUtilsFailure2(error) {
4056
+ var _b;
4057
+ if (!__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
4058
+ (_b = __classPrivateFieldGet3(this, _Iti_rejectUtilsScriptPromise, "f")) === null || _b === void 0 ? void 0 : _b.call(this, error);
4059
+ return;
4060
+ }
4061
+ __classPrivateFieldGet3(this, _Iti_rejectUtilsScriptPromise, "f").call(this, error);
4062
+ }, _Iti_utilsIsPossibleNumber = function _Iti_utilsIsPossibleNumber2(val) {
4063
+ return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2, __classPrivateFieldGet3(this, _Iti_options, "f").allowedNumberTypes) : null;
4064
+ }, _Iti_validateNumber = function _Iti_validateNumber2(precise) {
4065
+ if (!intlTelInput.utils || !__classPrivateFieldGet3(this, _Iti_ui, "f").telInput) {
4066
+ return null;
4067
+ }
4068
+ const { allowNumberExtensions, allowPhonewords } = __classPrivateFieldGet3(this, _Iti_options, "f");
4069
+ const testValidity = (s) => precise ? __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_utilsIsValidNumber).call(this, s) : __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_utilsIsPossibleNumber).call(this, s);
4070
+ const val = __classPrivateFieldGet3(this, _Iti_instances, "m", _Iti_getFullNumber).call(this);
4071
+ if (!__classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2) {
4072
+ const isRegionlessDialCode = hasRegionlessDialCode(val);
4073
+ if (!isRegionlessDialCode) {
4074
+ return false;
4075
+ }
4076
+ }
4077
+ if (!testValidity(val)) {
4078
+ return false;
4079
+ }
4080
+ const alphaCharPosition = val.search(REGEX.ALPHA_UNICODE);
4081
+ const hasAlphaChar = alphaCharPosition > -1;
4082
+ if (hasAlphaChar) {
4083
+ const selectedIso2 = __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2;
4084
+ const hasExtension = Boolean(intlTelInput.utils.getExtension(val, selectedIso2));
4085
+ if (hasExtension) {
4086
+ return allowNumberExtensions;
4010
4087
  }
4088
+ return allowPhonewords;
4011
4089
  }
4090
+ return true;
4091
+ }, _Iti_utilsIsValidNumber = function _Iti_utilsIsValidNumber2(val) {
4092
+ return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, __classPrivateFieldGet3(this, _Iti_selectedCountryData, "f").iso2, __classPrivateFieldGet3(this, _Iti_options, "f").allowedNumberTypes) : null;
4012
4093
  };
4013
4094
  var attachUtils = (source) => {
4014
4095
  if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
@@ -4029,23 +4110,15 @@ var attachUtils = (source) => {
4029
4110
  throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
4030
4111
  }
4031
4112
  intlTelInput.utils = utils;
4032
- forEachInstance("handleUtils");
4113
+ Iti.forEachInstance("handleUtils");
4033
4114
  return true;
4034
4115
  }).catch((error) => {
4035
- forEachInstance("handleUtilsFailure", error);
4116
+ Iti.forEachInstance("handleUtilsFailure", error);
4036
4117
  throw error;
4037
4118
  });
4038
4119
  }
4039
4120
  return null;
4040
4121
  };
4041
- var forEachInstance = (method, ...args) => {
4042
- Object.values(intlTelInput.instances).forEach((instance) => {
4043
- const fn = instance[method];
4044
- if (typeof fn === "function") {
4045
- fn.apply(instance, args);
4046
- }
4047
- });
4048
- };
4049
4122
  var intlTelInput = Object.assign((input, options) => {
4050
4123
  const iti = new Iti(input, options);
4051
4124
  intlTelInput.instances[iti.id] = iti;
@@ -4067,7 +4140,7 @@ var intlTelInput = Object.assign((input, options) => {
4067
4140
  attachUtils,
4068
4141
  startedLoadingUtilsScript: false,
4069
4142
  startedLoadingAutoCountry: false,
4070
- version: "26.7.5"
4143
+ version: "26.8.0"
4071
4144
  });
4072
4145
  var intl_tel_input_default = intlTelInput;
4073
4146
 
@@ -4085,10 +4158,9 @@ var PHONE_ERROR_MESSAGES = [
4085
4158
  ];
4086
4159
  var IntlTelInputComponent = class {
4087
4160
  constructor() {
4088
- this.initialValue = "";
4089
4161
  this.usePreciseValidation = false;
4090
4162
  this.inputProps = {};
4091
- this.initOptions = {};
4163
+ this.disabled = false;
4092
4164
  this.numberChange = new EventEmitter();
4093
4165
  this.countryChange = new EventEmitter();
4094
4166
  this.validityChange = new EventEmitter();
@@ -4099,7 +4171,7 @@ var IntlTelInputComponent = class {
4099
4171
  this.keyup = new EventEmitter();
4100
4172
  this.paste = new EventEmitter();
4101
4173
  this.click = new EventEmitter();
4102
- this.iti = null;
4174
+ this.appliedInputPropKeys = /* @__PURE__ */ new Set();
4103
4175
  this.countryChangeHandler = () => this.handleInput();
4104
4176
  this.onChange = () => {
4105
4177
  };
@@ -4108,26 +4180,27 @@ var IntlTelInputComponent = class {
4108
4180
  this.onValidatorChange = () => {
4109
4181
  };
4110
4182
  }
4111
- ngOnInit() {
4183
+ ngAfterViewInit() {
4184
+ var _a3, _b;
4112
4185
  if (this.inputRef.nativeElement) {
4113
4186
  this.iti = intl_tel_input_default(this.inputRef.nativeElement, this.initOptions);
4114
4187
  }
4115
4188
  this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
4116
4189
  this.applyInputProps();
4117
- }
4118
- ngAfterViewInit() {
4119
- var _a, _b;
4120
4190
  if (this.initialValue) {
4121
- (_a = this.iti) === null || _a === void 0 ? void 0 : _a.setNumber(this.initialValue);
4191
+ (_a3 = this.iti) === null || _a3 === void 0 ? void 0 : _a3.setNumber(this.initialValue);
4122
4192
  }
4123
4193
  if (this.disabled) {
4124
4194
  (_b = this.iti) === null || _b === void 0 ? void 0 : _b.setDisabled(this.disabled);
4125
4195
  }
4126
4196
  }
4127
4197
  ngOnChanges(changes) {
4128
- var _a;
4198
+ var _a3;
4129
4199
  if (changes["disabled"]) {
4130
- (_a = this.iti) === null || _a === void 0 ? void 0 : _a.setDisabled(this.disabled || false);
4200
+ (_a3 = this.iti) === null || _a3 === void 0 ? void 0 : _a3.setDisabled(this.disabled);
4201
+ }
4202
+ if (changes["inputProps"]) {
4203
+ this.applyInputProps();
4131
4204
  }
4132
4205
  }
4133
4206
  handleInput() {
@@ -4135,18 +4208,33 @@ var IntlTelInputComponent = class {
4135
4208
  return;
4136
4209
  const num = this.iti.getNumber() || "";
4137
4210
  const countryIso = this.iti.getSelectedCountryData().iso2 || "";
4138
- this.numberChange.emit(num);
4139
- this.countryChange.emit(countryIso);
4211
+ let hasChanged = false;
4212
+ if (num !== this.lastEmittedNumber) {
4213
+ this.lastEmittedNumber = num;
4214
+ this.numberChange.emit(num);
4215
+ this.onChange(num);
4216
+ hasChanged = true;
4217
+ }
4218
+ if (countryIso !== this.lastEmittedCountry) {
4219
+ this.lastEmittedCountry = countryIso;
4220
+ this.countryChange.emit(countryIso);
4221
+ hasChanged = true;
4222
+ }
4140
4223
  const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();
4141
- if (isValid) {
4142
- this.validityChange.emit(true);
4143
- this.errorCodeChange.emit(null);
4144
- } else {
4145
- this.validityChange.emit(false);
4146
- this.errorCodeChange.emit(this.iti.getValidationError());
4224
+ const errorCode = isValid ? null : this.iti.getValidationError();
4225
+ if (isValid !== this.lastEmittedValidity) {
4226
+ this.lastEmittedValidity = isValid;
4227
+ this.validityChange.emit(isValid);
4228
+ hasChanged = true;
4229
+ }
4230
+ if (errorCode !== this.lastEmittedErrorCode) {
4231
+ this.lastEmittedErrorCode = errorCode;
4232
+ this.errorCodeChange.emit(errorCode);
4233
+ hasChanged = true;
4234
+ }
4235
+ if (hasChanged) {
4236
+ this.onValidatorChange();
4147
4237
  }
4148
- this.onChange(num);
4149
- this.onValidatorChange();
4150
4238
  }
4151
4239
  handleBlur(event) {
4152
4240
  this.onTouched();
@@ -4182,15 +4270,22 @@ var IntlTelInputComponent = class {
4182
4270
  return this.inputRef.nativeElement;
4183
4271
  }
4184
4272
  ngOnDestroy() {
4185
- var _a;
4186
- (_a = this.iti) === null || _a === void 0 ? void 0 : _a.destroy();
4273
+ var _a3;
4274
+ (_a3 = this.iti) === null || _a3 === void 0 ? void 0 : _a3.destroy();
4187
4275
  this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
4188
4276
  }
4189
4277
  applyInputProps() {
4190
- const props = this.inputProps;
4191
- Object.entries(props).forEach(([key, value]) => {
4278
+ const currentKeys = /* @__PURE__ */ new Set();
4279
+ Object.entries(this.inputProps).forEach(([key, value]) => {
4280
+ currentKeys.add(key);
4192
4281
  this.inputRef.nativeElement.setAttribute(key, value);
4193
4282
  });
4283
+ this.appliedInputPropKeys.forEach((key) => {
4284
+ if (!currentKeys.has(key)) {
4285
+ this.inputRef.nativeElement.removeAttribute(key);
4286
+ }
4287
+ });
4288
+ this.appliedInputPropKeys = currentKeys;
4194
4289
  }
4195
4290
  // ============ ControlValueAccessor Implementation ============
4196
4291
  writeValue(value) {
@@ -4205,12 +4300,13 @@ var IntlTelInputComponent = class {
4205
4300
  this.onTouched = fn;
4206
4301
  }
4207
4302
  setDisabledState(isDisabled) {
4208
- var _a;
4303
+ var _a3;
4209
4304
  this.disabled = isDisabled;
4210
- (_a = this.iti) === null || _a === void 0 ? void 0 : _a.setDisabled(isDisabled);
4305
+ (_a3 = this.iti) === null || _a3 === void 0 ? void 0 : _a3.setDisabled(isDisabled);
4211
4306
  }
4212
4307
  // ============ Validator Implementation ============
4213
4308
  validate(control) {
4309
+ var _a3;
4214
4310
  if (!control.value || !this.iti) {
4215
4311
  return null;
4216
4312
  }
@@ -4222,7 +4318,7 @@ var IntlTelInputComponent = class {
4222
4318
  return {
4223
4319
  invalidPhone: {
4224
4320
  errorCode,
4225
- errorMessage: PHONE_ERROR_MESSAGES[errorCode]
4321
+ errorMessage: (_a3 = PHONE_ERROR_MESSAGES[errorCode]) !== null && _a3 !== void 0 ? _a3 : "unknown"
4226
4322
  }
4227
4323
  };
4228
4324
  }
@@ -4349,7 +4445,7 @@ IntlTelInputComponent.\u0275cmp = /* @__PURE__ */ i0.\u0275\u0275defineComponent
4349
4445
  }] });
4350
4446
  })();
4351
4447
  (() => {
4352
- (typeof ngDevMode === "undefined" || ngDevMode) && i0.\u0275setClassDebugInfo(IntlTelInputComponent, { className: "IntlTelInputComponent", filePath: "intl-tel-input/angular.ts", lineNumber: 67 });
4448
+ (typeof ngDevMode === "undefined" || ngDevMode) && i0.\u0275setClassDebugInfo(IntlTelInputComponent, { className: "IntlTelInputComponent", filePath: "intl-tel-input/angular.ts", lineNumber: 66 });
4353
4449
  })();
4354
4450
  export {
4355
4451
  IntlTelInputComponent,