intl-tel-input
Version:
A JavaScript plugin for entering and validating international telephone numbers
2,252 lines • 60.1 kB
JavaScript
import { computed as e, createElementBlock as t, defineComponent as n, getCurrentInstance as r, mergeProps as i, onMounted as a, onUnmounted as o, openBlock as s, ref as c, shallowRef as l, watch as u } from "vue";
//#region dist/js/intlTelInput.mjs
var d = [
[
"af",
"93",
0,
null,
"0"
],
[
"ax",
"358",
1,
["18", "4"],
"0"
],
[
"al",
"355",
0,
null,
"0"
],
[
"dz",
"213",
0,
null,
"0"
],
[
"as",
"1",
5,
["684"],
"1"
],
["ad", "376"],
["ao", "244"],
[
"ai",
"1",
6,
["264"],
"1"
],
[
"ag",
"1",
7,
["268"],
"1"
],
[
"ar",
"54",
0,
null,
"0"
],
[
"am",
"374",
0,
null,
"0"
],
["aw", "297"],
["ac", "247"],
[
"au",
"61",
0,
["4"],
"0"
],
[
"at",
"43",
0,
null,
"0"
],
[
"az",
"994",
0,
null,
"0"
],
[
"bs",
"1",
8,
["242"],
"1"
],
["bh", "973"],
[
"bd",
"880",
0,
null,
"0"
],
[
"bb",
"1",
9,
["246"],
"1"
],
[
"by",
"375",
0,
null,
"8"
],
[
"be",
"32",
0,
null,
"0"
],
["bz", "501"],
["bj", "229"],
[
"bm",
"1",
10,
["441"],
"1"
],
["bt", "975"],
[
"bo",
"591",
0,
null,
"0"
],
[
"ba",
"387",
0,
null,
"0"
],
["bw", "267"],
[
"br",
"55",
0,
null,
"0"
],
["io", "246"],
[
"vg",
"1",
11,
["284"],
"1"
],
["bn", "673"],
[
"bg",
"359",
0,
null,
"0"
],
["bf", "226"],
["bi", "257"],
[
"kh",
"855",
0,
null,
"0"
],
["cm", "237"],
[
"ca",
"1",
1,
/* @__PURE__ */ "204.226.236.249.250.257.263.289.306.343.354.365.367.368.382.403.416.418.428.431.437.438.450.468.474.506.514.519.548.579.581.584.587.604.613.639.647.672.683.705.709.742.753.778.780.782.807.819.825.867.873.879.902.905.942".split("."),
"1"
],
["cv", "238"],
[
"bq",
"599",
1,
[
"3",
"4",
"7"
]
],
[
"ky",
"1",
12,
["345"],
"1"
],
["cf", "236"],
["td", "235"],
["cl", "56"],
[
"cn",
"86",
0,
null,
"0"
],
[
"cx",
"61",
2,
["4", "89164"],
"0"
],
[
"cc",
"61",
1,
["4", "89162"],
"0"
],
[
"co",
"57",
0,
null,
"0"
],
["km", "269"],
["cg", "242"],
[
"cd",
"243",
0,
null,
"0"
],
["ck", "682"],
["cr", "506"],
["ci", "225"],
[
"hr",
"385",
0,
null,
"0"
],
[
"cu",
"53",
0,
null,
"0"
],
[
"cw",
"599",
0
],
["cy", "357"],
["cz", "420"],
["dk", "45"],
["dj", "253"],
[
"dm",
"1",
13,
["767"],
"1"
],
[
"do",
"1",
2,
[
"809",
"829",
"849"
],
"1"
],
[
"ec",
"593",
0,
null,
"0"
],
[
"eg",
"20",
0,
null,
"0"
],
["sv", "503"],
["gq", "240"],
[
"er",
"291",
0,
null,
"0"
],
["ee", "372"],
["sz", "268"],
[
"et",
"251",
0,
null,
"0"
],
["fk", "500"],
["fo", "298"],
["fj", "679"],
[
"fi",
"358",
0,
["4"],
"0"
],
[
"fr",
"33",
0,
null,
"0"
],
[
"gf",
"594",
0,
null,
"0"
],
["pf", "689"],
["ga", "241"],
["gm", "220"],
[
"ge",
"995",
0,
null,
"0"
],
[
"de",
"49",
0,
null,
"0"
],
[
"gh",
"233",
0,
null,
"0"
],
["gi", "350"],
["gr", "30"],
["gl", "299"],
[
"gd",
"1",
14,
["473"],
"1"
],
[
"gp",
"590",
0,
null,
"0"
],
[
"gu",
"1",
15,
["671"],
"1"
],
["gt", "502"],
[
"gg",
"44",
1,
[
"1481",
"7781",
"7839",
"7911"
],
"0"
],
["gn", "224"],
["gw", "245"],
["gy", "592"],
["ht", "509"],
["hn", "504"],
["hk", "852"],
[
"hu",
"36",
0,
null,
"06"
],
["is", "354"],
[
"in",
"91",
0,
null,
"0"
],
[
"id",
"62",
0,
null,
"0"
],
[
"ir",
"98",
0,
null,
"0"
],
[
"iq",
"964",
0,
null,
"0"
],
[
"ie",
"353",
0,
null,
"0"
],
[
"im",
"44",
2,
[
"1624",
"74576",
"7524",
"7624",
"7924"
],
"0"
],
[
"il",
"972",
0,
null,
"0"
],
[
"it",
"39",
0,
["3"]
],
[
"jm",
"1",
4,
["658", "876"],
"1"
],
[
"jp",
"81",
0,
null,
"0"
],
[
"je",
"44",
3,
[
"1534",
"7509",
"7700",
"7797",
"7829",
"7937"
],
"0"
],
[
"jo",
"962",
0,
null,
"0"
],
[
"kz",
"7",
1,
["33", "7"],
"8"
],
[
"ke",
"254",
0,
null,
"0"
],
[
"ki",
"686",
0,
null,
"0"
],
[
"xk",
"383",
0,
null,
"0"
],
["kw", "965"],
[
"kg",
"996",
0,
null,
"0"
],
[
"la",
"856",
0,
null,
"0"
],
["lv", "371"],
[
"lb",
"961",
0,
null,
"0"
],
["ls", "266"],
[
"lr",
"231",
0,
null,
"0"
],
[
"ly",
"218",
0,
null,
"0"
],
[
"li",
"423",
0,
null,
"0"
],
[
"lt",
"370",
0,
null,
"0"
],
["lu", "352"],
["mo", "853"],
[
"mg",
"261",
0,
null,
"0"
],
[
"mw",
"265",
0,
null,
"0"
],
[
"my",
"60",
0,
null,
"0"
],
["mv", "960"],
["ml", "223"],
["mt", "356"],
[
"mh",
"692",
0,
null,
"1"
],
[
"mq",
"596",
0,
null,
"0"
],
["mr", "222"],
["mu", "230"],
[
"yt",
"262",
1,
["269", "639"],
"0"
],
["mx", "52"],
["fm", "691"],
[
"md",
"373",
0,
null,
"0"
],
[
"mc",
"377",
0,
null,
"0"
],
[
"mn",
"976",
0,
null,
"0"
],
[
"me",
"382",
0,
null,
"0"
],
[
"ms",
"1",
16,
["664"],
"1"
],
[
"ma",
"212",
0,
["6", "7"],
"0"
],
["mz", "258"],
[
"mm",
"95",
0,
null,
"0"
],
[
"na",
"264",
0,
null,
"0"
],
["nr", "674"],
[
"np",
"977",
0,
null,
"0"
],
[
"nl",
"31",
0,
null,
"0"
],
["nc", "687"],
[
"nz",
"64",
0,
null,
"0"
],
["ni", "505"],
["ne", "227"],
[
"ng",
"234",
0,
null,
"0"
],
["nu", "683"],
["nf", "672"],
[
"kp",
"850",
0,
null,
"0"
],
[
"mk",
"389",
0,
null,
"0"
],
[
"mp",
"1",
17,
["670"],
"1"
],
[
"no",
"47",
0,
["4", "9"]
],
["om", "968"],
[
"pk",
"92",
0,
null,
"0"
],
["pw", "680"],
[
"ps",
"970",
0,
null,
"0"
],
["pa", "507"],
["pg", "675"],
[
"py",
"595",
0,
null,
"0"
],
[
"pe",
"51",
0,
null,
"0"
],
[
"ph",
"63",
0,
null,
"0"
],
["pl", "48"],
["pt", "351"],
[
"pr",
"1",
3,
["787", "939"],
"1"
],
["qa", "974"],
[
"re",
"262",
0,
null,
"0"
],
[
"ro",
"40",
0,
null,
"0"
],
[
"ru",
"7",
0,
["33"],
"8"
],
[
"rw",
"250",
0,
null,
"0"
],
["ws", "685"],
["sm", "378"],
["st", "239"],
[
"sa",
"966",
0,
null,
"0"
],
["sn", "221"],
[
"rs",
"381",
0,
null,
"0"
],
["sc", "248"],
[
"sl",
"232",
0,
null,
"0"
],
["sg", "65"],
[
"sx",
"1",
21,
["721"],
"1"
],
[
"sk",
"421",
0,
null,
"0"
],
[
"si",
"386",
0,
null,
"0"
],
["sb", "677"],
[
"so",
"252",
0,
null,
"0"
],
[
"za",
"27",
0,
null,
"0"
],
[
"kr",
"82",
0,
null,
"0"
],
[
"ss",
"211",
0,
null,
"0"
],
["es", "34"],
[
"lk",
"94",
0,
null,
"0"
],
[
"bl",
"590",
1,
null,
"0"
],
["sh", "290"],
[
"kn",
"1",
18,
["869"],
"1"
],
[
"lc",
"1",
19,
["758"],
"1"
],
[
"mf",
"590",
2,
null,
"0"
],
[
"pm",
"508",
0,
null,
"0"
],
[
"vc",
"1",
20,
["784"],
"1"
],
[
"sd",
"249",
0,
null,
"0"
],
["sr", "597"],
[
"sj",
"47",
1,
[
"4",
"79",
"9"
]
],
[
"se",
"46",
0,
null,
"0"
],
[
"ch",
"41",
0,
null,
"0"
],
[
"sy",
"963",
0,
null,
"0"
],
[
"tw",
"886",
0,
null,
"0"
],
["tj", "992"],
[
"tz",
"255",
0,
null,
"0"
],
[
"th",
"66",
0,
null,
"0"
],
["tl", "670"],
["tg", "228"],
["tk", "690"],
["to", "676"],
[
"tt",
"1",
22,
["868"],
"1"
],
["tn", "216"],
[
"tr",
"90",
0,
null,
"0"
],
[
"tm",
"993",
0,
null,
"8"
],
[
"tc",
"1",
23,
["649"],
"1"
],
["tv", "688"],
[
"vi",
"1",
24,
["340"],
"1"
],
[
"ug",
"256",
0,
null,
"0"
],
[
"ua",
"380",
0,
null,
"0"
],
[
"ae",
"971",
0,
null,
"0"
],
[
"gb",
"44",
0,
null,
"0"
],
[
"us",
"1",
0,
null,
"1"
],
[
"uy",
"598",
0,
null,
"0"
],
["uz", "998"],
["vu", "678"],
[
"va",
"39",
1,
["06698", "3"]
],
[
"ve",
"58",
0,
null,
"0"
],
[
"vn",
"84",
0,
null,
"0"
],
["wf", "681"],
[
"eh",
"212",
1,
[
"5288",
"5289",
"6",
"7"
],
"0"
],
[
"ye",
"967",
0,
null,
"0"
],
[
"zm",
"260",
0,
null,
"0"
],
[
"zw",
"263",
0,
null,
"0"
]
], f = [];
for (let e of d) f.push({
name: "",
iso2: e[0],
dialCode: e[1],
priority: e[2] || 0,
areaCodes: e[3] || null,
nodeById: {},
nationalPrefix: e[4] || null,
normalisedName: "",
initials: "",
dialCodePlus: ""
});
var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
COUNTRY_CHANGE: "countrychange",
INPUT: "input"
}, _ = {
HIDE: "iti__hide",
V_HIDE: "iti__v-hide",
ARROW_UP: "iti__arrow--up",
GLOBE: "iti__globe",
FLAG: "iti__flag",
LOADING: "iti__loading",
COUNTRY_ITEM: "iti__country",
HIGHLIGHT: "iti__highlight"
}, v = {
ARROW_UP: "ArrowUp",
ARROW_DOWN: "ArrowDown",
SPACE: " ",
ENTER: "Enter",
ESC: "Escape",
TAB: "Tab"
}, y = {
PASTE: "insertFromPaste",
DELETE_FWD: "deleteContentForward"
}, b = {
ALPHA_UNICODE: /\p{L}/u,
NON_PLUS_NUMERIC: /[^+0-9]/,
NON_PLUS_NUMERIC_GLOBAL: /[^+0-9]/g,
HIDDEN_SEARCH_CHAR: /^[a-zA-ZÀ-ÿа-яА-Я ]$/
}, x = {
SEARCH_DEBOUNCE_MS: 100,
HIDDEN_SEARCH_RESET_MS: 1e3,
NEXT_TICK: 0
}, S = {
UNKNOWN_NUMBER_TYPE: -99,
UNKNOWN_VALIDATION_ERROR: -99
}, C = {
NARROW_VIEWPORT_WIDTH: 500,
SANE_SELECTED_WITH_DIAL_WIDTH: 78,
SANE_SELECTED_NO_DIAL_WIDTH: 42,
INPUT_PADDING_EXTRA_LEFT: 6,
DROPDOWN_MARGIN: 3,
SANE_DROPDOWN_HEIGHT: 200
}, w = {
PLUS: "+",
NANP: "1"
}, T = {
ISO2: "gb",
DIAL_CODE: "44",
MOBILE_PREFIX: "7",
MOBILE_CORE_LENGTH: 10
}, E = {
ISO2: "us",
DIAL_CODE: "1"
}, D = {
AGGRESSIVE: "aggressive",
POLITE: "polite",
OFF: "off"
}, O = { AUTO: "auto" }, k = new Set([
"FIXED_LINE",
"MOBILE",
"FIXED_LINE_OR_MOBILE",
"TOLL_FREE",
"PREMIUM_RATE",
"SHARED_COST",
"VOIP",
"PERSONAL_NUMBER",
"PAGER",
"UAN",
"VOICEMAIL",
"UNKNOWN"
]), A = {
COUNTRY_CODE: "countryCode",
DIAL_CODE: "dialCode"
}, j = {
EXPANDED: "aria-expanded",
LABEL: "aria-label",
SELECTED: "aria-selected",
ACTIVE_DESCENDANT: "aria-activedescendant",
HASPOPUP: "aria-haspopup",
CONTROLS: "aria-controls",
HIDDEN: "aria-hidden",
AUTOCOMPLETE: "aria-autocomplete",
MODAL: "aria-modal"
}, ee = {
selectedCountryAriaLabel: "Change country for phone number, currently selected ${countryName} (${dialCode})",
noCountrySelected: "Select country for phone number",
countryListAriaLabel: "List of countries",
searchPlaceholder: "Search",
clearSearchAriaLabel: "Clear search",
searchEmptyState: "No results found",
searchSummaryAria(e) {
return e === 0 ? "No results found" : e === 1 ? "1 result found" : `${e} results found`;
}
}, M = (e) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(e).matches, N = () => M(`(max-width: ${C.NARROW_VIEWPORT_WIDTH}px)`), P = {
allowDropdown: !0,
allowedNumberTypes: ["MOBILE", "FIXED_LINE"],
allowNumberExtensions: !1,
allowPhonewords: !1,
autoPlaceholder: D.POLITE,
containerClass: "",
countryNameLocale: "en",
countryOrder: null,
countrySearch: !0,
customPlaceholder: null,
dropdownAlwaysOpen: !1,
dropdownContainer: null,
excludeCountries: null,
fixDropdownWidth: !0,
formatAsYouType: !0,
formatOnDisplay: !0,
geoIpLookup: null,
hiddenInput: null,
i18n: {},
initialCountry: "",
loadUtils: null,
nationalMode: !0,
onlyCountries: null,
placeholderNumberType: "MOBILE",
searchInputClass: "",
separateDialCode: !1,
showFlags: !0,
strictMode: !1,
useFullscreenPopup: (() => {
if (typeof navigator < "u" && typeof window < "u") {
let e = M("(max-height: 600px)"), t = M("(pointer: coarse)");
return N() || t && e;
}
return !1;
})()
}, te = (e) => JSON.stringify(e), F = (e) => !!e && typeof e == "object" && !Array.isArray(e), ne = (e) => typeof e == "function", re = (e) => {
if (!e || typeof e != "object") return !1;
let t = e;
return t.nodeType === 1 && typeof t.tagName == "string" && typeof t.appendChild == "function";
}, I = new Set(Object.values(D)), L = (e) => {
console.warn(`[intl-tel-input] ${e}`);
}, R = (e, t, n) => {
L(`Option '${e}' must be ${t}; got ${te(n)}. Ignoring.`);
}, z = (e, t) => {
let n = "an array of ISO2 country code strings";
if (!Array.isArray(t)) return R(e, n, t), !1;
let r = [];
for (let i of t) {
if (typeof i != "string") return R(e, n, t), !1;
m(i.toLowerCase()) ? r.push(i) : L(`Invalid country code in '${e}': '${i}'. Skipping.`);
}
return r;
}, ie = (e) => {
if (e === void 0) return {};
if (!F(e)) return L(`The second argument must be an options object; got ${te(e)}. Using defaults.`), {};
let t = {};
for (let [n, r] of Object.entries(e)) {
if (!Object.hasOwn(P, n)) {
L(`Unknown option '${n}'. Ignoring.`);
continue;
}
switch (n) {
case "allowDropdown":
case "allowNumberExtensions":
case "allowPhonewords":
case "countrySearch":
case "dropdownAlwaysOpen":
case "fixDropdownWidth":
case "formatAsYouType":
case "formatOnDisplay":
case "nationalMode":
case "showFlags":
case "separateDialCode":
case "strictMode":
case "useFullscreenPopup":
if (typeof r != "boolean") {
R(n, "a boolean", r);
break;
}
t[n] = r;
break;
case "autoPlaceholder":
if (typeof r != "string" || !I.has(r)) {
R("autoPlaceholder", `one of ${Array.from(I).join(", ")}`, r);
break;
}
t[n] = r;
break;
case "containerClass":
case "searchInputClass":
case "countryNameLocale":
if (typeof r != "string") {
R(n, "a string", r);
break;
}
t[n] = r;
break;
case "countryOrder":
if (r === null) t[n] = r;
else {
let e = z(n, r);
e !== !1 && (t[n] = e);
}
break;
case "customPlaceholder":
case "geoIpLookup":
case "hiddenInput":
case "loadUtils":
if (r !== null && !ne(r)) {
R(n, "a function or null", r);
break;
}
t[n] = r;
break;
case "dropdownContainer":
if (r !== null && !re(r)) {
R("dropdownContainer", "an HTMLElement or null", r);
break;
}
t[n] = r;
break;
case "excludeCountries":
case "onlyCountries":
if (r === null) t[n] = r;
else {
let e = z(n, r);
e !== !1 && (t[n] = e);
}
break;
case "i18n":
if (r && !F(r)) {
R("i18n", "an object", r);
break;
}
t[n] = r;
break;
case "initialCountry": {
if (typeof r != "string") {
R("initialCountry", "a string", r);
break;
}
let e = r.toLowerCase();
if (e && e !== O.AUTO && !m(e)) {
R("initialCountry", "a valid ISO2 country code or 'auto'", r);
break;
}
t[n] = r;
break;
}
case "placeholderNumberType":
if (typeof r != "string" || !k.has(r)) {
R("placeholderNumberType", `one of ${Array.from(k).join(", ")}`, r);
break;
}
t[n] = r;
break;
case "allowedNumberTypes":
if (r !== null) {
if (!Array.isArray(r)) {
R("allowedNumberTypes", "an array of number types or null", r);
break;
}
let e = !0;
for (let t of r) if (typeof t != "string" || !k.has(t)) {
R("allowedNumberTypes", `an array of valid number types (${Array.from(k).join(", ")})`, t), e = !1;
break;
}
e && (t[n] = r);
} else t[n] = null;
break;
}
}
return t;
}, ae = (e) => {
e.initialCountry &&= e.initialCountry.toLowerCase(), e.onlyCountries?.length && (e.onlyCountries = e.onlyCountries.map((e) => e.toLowerCase())), e.excludeCountries?.length && (e.excludeCountries = e.excludeCountries.map((e) => e.toLowerCase())), e.countryOrder &&= e.countryOrder.map((e) => e.toLowerCase());
}, oe = (e) => {
e.dropdownAlwaysOpen && (e.useFullscreenPopup = !1, e.allowDropdown = !0), e.useFullscreenPopup ? e.fixDropdownWidth = !1 : N() && (e.fixDropdownWidth = !0), e.onlyCountries?.length === 1 && (e.initialCountry = e.onlyCountries[0]), e.separateDialCode && (e.nationalMode = !1), e.allowDropdown && !e.showFlags && !e.separateDialCode && (e.nationalMode = !1), e.useFullscreenPopup && !e.dropdownContainer && (e.dropdownContainer = document.body), e.i18n = {
...ee,
...e.i18n
};
}, B = (e) => e.replace(/\D/g, ""), V = (e = "") => e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), se = () => typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, ce = (e, t) => {
let n = V(t), r = [], i = [], a = [], o = [], s = [], c = [];
for (let t of e) t.iso2 === n ? r.push(t) : t.normalisedName.startsWith(n) ? i.push(t) : t.normalisedName.includes(n) ? a.push(t) : n === t.dialCode || n === t.dialCodePlus ? o.push(t) : t.dialCodePlus.includes(n) ? s.push(t) : t.initials.includes(n) && c.push(t);
let l = (e, t) => e.priority - t.priority;
return [
...r,
...i,
...a,
...o.sort(l),
...s.sort(l),
...c
];
}, le = (e, t) => {
let n = V(t);
for (let t of e) if (t.normalisedName.startsWith(n)) return t;
return null;
}, H = (e) => Object.keys(e).filter((t) => !!e[t]).join(" "), U = (e, t, n) => {
let r = document.createElement(e);
return t && Object.entries(t).forEach(([e, t]) => r.setAttribute(e, t)), n && n.appendChild(r), r;
}, ue = () => `
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${j.HIDDEN}="true">
<circle cx="11" cy="11" r="7" />
<line x1="21" y1="21" x2="16.65" y2="16.65" />
</svg>`, de = (e) => {
let t = `iti-${e}-clear-mask`;
return `
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${j.HIDDEN}="true" focusable="false">
<mask id="${t}" maskUnits="userSpaceOnUse">
<rect width="16" height="16" fill="white" />
<path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
</mask>
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${t})" />
</svg>`;
}, fe = () => `
<svg class="iti__country-check-svg" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" focusable="false" ${j.HIDDEN}="true">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
</svg>`, W = () => "\n <svg width=\"256\" height=\"256\" viewBox=\"0 0 512 512\" class=\"iti__globe-svg\">\n <path d=\"M508 213a240 240 0 0 0-449-87l-2 5-2 5c-8 14-13 30-17 46a65 65 0 0 1 56 4c16-10 35-19 56-27l9-3c-6 23-10 48-10 74h-16l4 6c3 4 5 8 6 13h6c0 22 3 44 8 65l2 10-25-10-4 5 12 18 9 3 6 2 8 3 9 26 1 2 16-7h1l-5-13-1-2c24 6 49 9 75 10v26l11 10 7 7v-30l1-13c22 0 44-3 65-8l10-2-21 48-1 1a317 317 0 0 1-14 23l-21 5h-2c6 16 7 33 1 50a240 240 0 0 0 211-265m-401-56-11 6c19-44 54-79 98-98-11 20-21 44-29 69-21 6-40 15-58 23m154 182v4c-29-1-57-6-81-13-7-25-12-52-13-81h94zm0-109h-94c1-29 6-56 13-81 24-7 52-12 81-13zm0-112c-22 1-44 4-65 8l-10 2 12-30 9-17 1-2a332 332 0 0 1 13-23c13-4 26-6 40-7zm187 69 6 4c4 12 6 25 6 38v1h-68c-1-26-4-51-10-74l48 20 1 1 14 8zm-14-44 10 20c-20-11-43-21-68-29-8-25-18-49-29-69 37 16 67 44 87 78M279 49h1c13 1 27 3 39 7l14 23 1 2a343 343 0 0 1 12 26l2 5 6 16c-23-6-48-9-74-10h-1zm0 87h1c29 1 56 6 81 13 7 24 12 51 12 80v1h-94zm2 207h-2v-94h95c-1 29-6 56-13 81-24 7-51 12-80 13m86 60-20 10c11-20 21-43 29-68 25-8 48-18 68-29-16 37-43 67-77 87m87-115-7 5-16 9-2 1a337 337 0 0 1-47 21c6-24 9-49 10-75h68c0 13-2 27-6 39\"/>\n <path d=\"m261 428-2-2-22-21a40 40 0 0 0-32-11h-1a37 37 0 0 0-18 8l-1 1-4 2-2 2-5 4c-9-3-36-31-47-44s-32-45-34-55l3-2a151 151 0 0 0 11-9v-1a39 39 0 0 0 5-48l-3-3-11-19-3-4-5-7h-1l-3-3-4-3-5-2a35 35 0 0 0-16-3h-5c-4 1-14 5-24 11l-4 2-4 3-4 2c-9 8-17 17-18 27a380 380 0 0 0 212 259h3c12 0 25-10 36-21l10-12 6-11a39 39 0 0 0-8-40\"/>\n </svg>", G = class e {
#e;
#t;
#n;
#r = "";
#i;
#a = null;
#o;
#s;
#c;
#l;
#u;
#d;
#f;
#p;
#m = null;
#h = null;
telInput;
countryContainer;
selectedCountry;
selectedCountryInner;
searchInput;
searchClearButton;
countryList;
hiddenInputPhone;
hiddenInputCountry;
highlightedItem = null;
hadInitialPlaceholder;
constructor(e, t, n) {
e.dataset.intlTelInputId = n.toString(), this.telInput = e, this.#e = t, this.#t = n, this.hadInitialPlaceholder = !!e.getAttribute("placeholder"), this.#n = !!this.telInput.closest("[dir=rtl]"), this.#e.separateDialCode && (this.#r = this.telInput.style.paddingLeft);
}
static validateInput(e) {
let t = e?.tagName;
if (!(e && typeof e == "object" && t === "INPUT" && typeof e.setAttribute == "function")) {
let t = Object.prototype.toString.call(e);
throw TypeError(`The first argument must be an HTMLInputElement, not ${t}`);
}
}
generateMarkup(e) {
this.#i = e, this.telInput.classList.add("iti__tel-input"), this.telInput.hasAttribute("type") || this.telInput.setAttribute("type", "tel"), this.telInput.hasAttribute("autocomplete") || this.telInput.setAttribute("autocomplete", "tel"), this.telInput.hasAttribute("inputmode") || this.telInput.setAttribute("inputmode", "tel");
let t = this.#g();
this.#_(t), t.appendChild(this.telInput), this.#b(), this.#x(t);
}
#g() {
let { allowDropdown: e, showFlags: t, containerClass: n, useFullscreenPopup: r } = this.#e, i = U("div", { class: H({
iti: !0,
"iti--allow-dropdown": e,
"iti--show-flags": t,
"iti--inline-dropdown": !r,
[n]: !!n
}) });
return this.#n && i.setAttribute("dir", "ltr"), this.telInput.before(i), i;
}
#_(e) {
let { allowDropdown: t, separateDialCode: n, showFlags: r } = this.#e;
if (!t && !r && !n) return;
this.countryContainer = U("div", { class: `iti__country-container ${_.V_HIDE}` }, e), t ? (this.selectedCountry = U("button", {
type: "button",
class: "iti__selected-country",
[j.EXPANDED]: "false",
[j.LABEL]: this.#e.i18n.noCountrySelected,
[j.HASPOPUP]: "dialog",
[j.CONTROLS]: `iti-${this.#t}__dropdown-content`
}, this.countryContainer), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = U("div", { class: "iti__selected-country" }, this.countryContainer);
let i = U("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
this.selectedCountryInner = U("div", { class: _.FLAG }, i), t && (this.#c = U("div", {
class: "iti__arrow",
[j.HIDDEN]: "true"
}, i)), n && (this.#s = U("div", { class: "iti__selected-dial-code" }, this.selectedCountry)), t && this.#v();
}
maybeEnsureDropdownWidthSet() {
let { fixDropdownWidth: e, allowDropdown: t } = this.#e;
if (!t || !e || this.#l.style.width) return;
let n = this.telInput.offsetWidth;
n > 0 && (this.#l.style.width = `${n}px`);
}
#v() {
let { fixDropdownWidth: e, useFullscreenPopup: t, countrySearch: n, i18n: r, dropdownContainer: i, containerClass: a } = this.#e, o = e ? "" : "iti--flexible-dropdown-width";
this.#l = U("div", {
id: `iti-${this.#t}__dropdown-content`,
class: `iti__dropdown-content ${_.HIDE} ${o}`,
role: "dialog",
[j.MODAL]: "true"
}), this.#n && this.#l.setAttribute("dir", "rtl"), n && this.#y(), this.countryList = U("ul", {
class: "iti__country-list",
id: `iti-${this.#t}__country-listbox`,
role: "listbox",
[j.LABEL]: r.countryListAriaLabel
}, this.#l), this.#S(), n && this.#D(), t || (this.#o = this.#E(), n && (this.#l.style.height = `${this.#o}px`)), i ? (this.#p = U("div", { class: H({
iti: !0,
"iti--container": !0,
"iti--fullscreen-popup": t,
"iti--inline-dropdown": !t,
[a]: !!a
}) }), this.#p.appendChild(this.#l)) : this.countryContainer.appendChild(this.#l);
}
#y() {
let { i18n: e, searchInputClass: t } = this.#e, n = U("div", { class: "iti__search-input-wrapper" }, this.#l);
this.#u = U("span", {
class: "iti__search-icon",
[j.HIDDEN]: "true"
}, n), this.#u.innerHTML = ue(), this.searchInput = U("input", {
id: `iti-${this.#t}__search-input`,
type: "search",
class: `iti__search-input ${t}`,
placeholder: e.searchPlaceholder,
role: "combobox",
[j.EXPANDED]: "true",
[j.LABEL]: e.searchPlaceholder,
[j.CONTROLS]: `iti-${this.#t}__country-listbox`,
[j.AUTOCOMPLETE]: "list",
autocomplete: "off"
}, n), this.searchClearButton = U("button", {
type: "button",
class: `iti__search-clear ${_.HIDE}`,
[j.LABEL]: e.clearSearchAriaLabel,
tabindex: "-1"
}, n), this.searchClearButton.innerHTML = de(this.#t), this.#f = U("span", { class: "iti__a11y-text" }, this.#l), this.#d = U("div", {
class: `iti__no-results ${_.HIDE}`,
[j.HIDDEN]: "true"
}, this.#l), this.#d.textContent = e.searchEmptyState ?? null;
}
#b() {
this.countryContainer && (this.#C(), this.countryContainer.classList.remove(_.V_HIDE));
}
#x(e) {
let { hiddenInput: t } = this.#e;
if (!t) return;
let n = t(this.telInput.getAttribute("name") || "");
if (n.phone) {
let t = this.telInput.form?.querySelector(`input[name="${n.phone}"]`);
t ? this.hiddenInputPhone = t : (this.hiddenInputPhone = U("input", {
type: "hidden",
name: n.phone
}), e.appendChild(this.hiddenInputPhone));
}
if (n.country) {
let t = this.telInput.form?.querySelector(`input[name="${n.country}"]`);
t ? this.hiddenInputCountry = t : (this.hiddenInputCountry = U("input", {
type: "hidden",
name: n.country
}), e.appendChild(this.hiddenInputCountry));
}
}
#S() {
let e = document.createDocumentFragment();
for (let t = 0; t < this.#i.length; t++) {
let n = this.#i[t], r = H({ [_.COUNTRY_ITEM]: !0 }), i = U("li", {
id: `iti-${this.#t}__item-${n.iso2}`,
class: r,
tabindex: "-1",
role: "option",
[j.SELECTED]: "false"
});
i.dataset.dialCode = n.dialCode, i.dataset.countryCode = n.iso2, n.nodeById[this.#t] = i, this.#e.showFlags && U("div", { class: `${_.FLAG} iti__${n.iso2}` }, i);
let a = U("span", { class: "iti__country-name" }, i);
a.textContent = `${n.name} `;
let o = U("span", { class: "iti__dial-code" }, a);
this.#n && o.setAttribute("dir", "ltr"), o.textContent = `(+${n.dialCode})`, e.appendChild(i);
}
this.countryList.appendChild(e);
}
#C() {
if (this.selectedCountry) {
let e = this.#e.separateDialCode ? C.SANE_SELECTED_WITH_DIAL_WIDTH : C.SANE_SELECTED_NO_DIAL_WIDTH, t = (this.selectedCountry.offsetWidth || this.#T() || e) + C.INPUT_PADDING_EXTRA_LEFT;
this.telInput.style.paddingLeft = `${t}px`;
}
}
static #w() {
let e;
try {
e = window.top.document.body;
} catch {
e = document.body;
}
return e;
}
#T() {
if (!this.telInput.parentNode) return 0;
let t = e.#w(), n = this.telInput.parentNode.cloneNode(!1);
n.style.visibility = "hidden", t.appendChild(n);
let r = this.countryContainer.cloneNode();
n.appendChild(r);
let i = this.selectedCountry.cloneNode(!0);
r.appendChild(i);
let a = i.offsetWidth;
return t.removeChild(n), a;
}
#E() {
let t = e.#w();
this.#l.classList.remove(_.HIDE);
let n = U("div", { class: "iti iti--inline-dropdown" });
n.appendChild(this.#l), n.style.visibility = "hidden", t.appendChild(n);
let r = this.#l.offsetHeight;
return t.removeChild(n), n.style.visibility = "", this.#l.classList.add(_.HIDE), r > 0 ? r : C.SANE_DROPDOWN_HEIGHT;
}
#D() {
let { i18n: e } = this.#e, t = this.countryList.childElementCount;
this.#f.textContent = e.searchSummaryAria(t);
}
filterCountriesByQuery(e) {
let t;
t = e === "" ? this.#i : ce(this.#i, e), this.#A(t);
}
#O() {
let e = this.searchInput.value.trim();
this.filterCountriesByQuery(e), this.searchInput.value ? this.searchClearButton.classList.remove(_.HIDE) : this.searchClearButton.classList.add(_.HIDE);
}
handleSearchChange() {
this.#a && clearTimeout(this.#a), this.#a = setTimeout(() => {
this.#O(), this.#a = null;
}, x.SEARCH_DEBOUNCE_MS);
}
handleSearchClear() {
this.searchInput.value = "", this.searchInput.focus(), this.#O();
}
scrollCountryListToItem(e) {
let t = this.countryList, n = t.getBoundingClientRect(), r = e.getBoundingClientRect(), i = r.top - n.top + t.scrollTop;
r.top < n.top ? t.scrollTop = i : r.bottom > n.bottom && (t.scrollTop = i - n.height + r.height);
}
highlightListItem(e, t) {
let n = this.highlightedItem;
if (n && n.classList.remove(_.HIGHLIGHT), this.highlightedItem = e, this.highlightedItem) {
if (this.highlightedItem.classList.add(_.HIGHLIGHT), this.#e.countrySearch) {
let e = this.highlightedItem.getAttribute("id") || "";
this.searchInput.setAttribute(j.ACTIVE_DESCENDANT, e);
}
t && this.highlightedItem.focus();
}
}
handleUpDownKey(e) {
let t = e === v.ARROW_UP ? this.highlightedItem?.previousElementSibling : this.highlightedItem?.nextElementSibling;
!t && this.countryList.childElementCount > 1 && (t = e === v.ARROW_UP ? this.countryList.lastElementChild : this.countryList.firstElementChild), t && (this.scrollCountryListToItem(t), this.highlightListItem(t, !1));
}
#k(e) {
if (this.#m && this.#m.dataset.countryCode !== e && (this.#m.setAttribute(j.SELECTED, "false"), this.#m.querySelector(".iti__country-check")?.remove(), this.#m = null), e && !this.#m) {
let t = this.countryList.querySelector(`[data-country-code="${e}"]`);
if (t) {
t.setAttribute(j.SELECTED, "true");
let e = U("span", {
class: "iti__country-check",
[j.HIDDEN]: "true"
}, t);
e.innerHTML = fe(), this.#m = t;
}
}
}
#A(e) {
this.countryList.replaceChildren();
let t = !0;
for (let n of e) {
let e = n.nodeById[this.#t];
e && (this.countryList.appendChild(e), t &&= (this.highlightListItem(e, !1), !1));
}
t ? (this.highlightListItem(null, !1), this.#d && this.#d.classList.remove(_.HIDE)) : this.#d && this.#d.classList.add(_.HIDE), this.countryList.scrollTop = 0, this.#D();
}
destroy() {
this.telInput.iti = void 0, delete this.telInput.dataset.intlTelInputId, this.#e.separateDialCode && (this.telInput.style.paddingLeft = this.#r);
let e = this.telInput.parentNode;
e.before(this.telInput), e.remove();
for (let e of this.#i) delete e.nodeById[this.#t];
}
openDropdown() {
let { countrySearch: e, dropdownAlwaysOpen: t, dropdownContainer: n } = this.#e;
if (this.maybeEnsureDropdownWidthSet(), n) this.#M();
else {
let e = this.#j(), t = this.telInput.offsetHeight + C.DROPDOWN_MARGIN;
e ? this.#l.style.top = `${t}px` : this.#l.style.bottom = `${t}px`;
}
this.#l.classList.remove(_.HIDE), this.selectedCountry.setAttribute(j.EXPANDED, "true");
let r = this.#m ?? this.countryList.firstElementChild;
r && (this.highlightListItem(r, !1), this.scrollCountryListToItem(r)), e && !t && this.searchInput.focus(), this.#e.useFullscreenPopup && this.#p && window.visualViewport && (this.#h = () => {
this.#N(), this.highlightedItem && this.scrollCountryListToItem(this.highlightedItem);
}, window.visualViewport.addEventListener("resize", this.#h)), this.#c.classList.add(_.ARROW_UP);
}
closeDropdown() {
let { countrySearch: e, dropdownContainer: t } = this.#e;
this.#l.classList.add(_.HIDE), this.selectedCountry.setAttribute(j.EXPANDED, "false"), e && (this.searchInput.removeAttribute(j.ACTIVE_DESCENDANT), this.searchInput.value = "", this.#O(), this.highlightedItem &&= (this.highlightedItem.classList.remove(_.HIGHLIGHT), null)), this.#c.classList.remove(_.ARROW_UP), this.#h && window.visualViewport && (window.visualViewport.removeEventListener("resize", this.#h), this.#h = null), t ? (this.#p.remove(), this.#p.style.top = "", this.#p.style.bottom = "", this.#p.style.paddingLeft = "", this.#p.style.paddingRight = "") : (this.#l.style.top = "", this.#l.style.bottom = "");
}
#j() {
if (this.#e.dropdownAlwaysOpen) return !0;
let e = this.telInput.getBoundingClientRect(), t = e.top, n = window.innerHeight - e.bottom;
return n >= this.#o || n >= t;
}
#M() {
let { dropdownContainer: e, useFullscreenPopup: t } = this.#e;
if (t) {
if (window.innerWidth >= C.NARROW_VIEWPORT_WIDTH) {
let e = this.telInput.getBoundingClientRect();
this.#p.style.paddingLeft = `${e.left}px`, this.#p.style.paddingRight = `${window.innerWidth - e.right}px`;
}
} else {
let e = this.telInput.getBoundingClientRect();
this.#p.style.left = `${e.left}px`, this.#j() ? this.#p.style.top = `${e.bottom + C.DROPDOWN_MARGIN}px` : (this.#p.style.top = "unset", this.#p.style.bottom = `${window.innerHeight - e.top + C.DROPDOWN_MARGIN}px`);
}
e.appendChild(this.#p);
}
#N() {
let e = window.visualViewport;
if (!e || !this.#p) return;
let t = window.innerHeight - e.height;
this.#p.style.bottom = `${t}px`;
}
isDropdownClosed() {
return this.#l.classList.contains(_.HIDE);
}
setCountry(e) {
let { allowDropdown: t, showFlags: n, separateDialCode: r, i18n: i } = this.#e, a = e?.name, o = e?.dialCode, s = e?.iso2 ?? "";
if (t && this.#k(s), this.selectedCountry) {
let e = s && n ? `${_.FLAG} iti__${s}` : `${_.FLAG} ${_.GLOBE}`, t, r, c;
s ? (r = a, t = i.selectedCountryAriaLabel.replace("${countryName}", a).replace("${dialCode}", `+${o}`), c = n ? "" : W()) : (r = i.noCountrySelected, t = i.noCountrySelected, c = W()), this.selectedCountryInner.className = e, this.selectedCountry.setAttribute("title", r), this.selectedCountry.setAttribute(j.LABEL, t), this.selectedCountryInner.innerHTML = c;
}
if (r) {
let e = o ? `+${o}` : "";
this.#s.textContent = e, this.#C();
}
}
}, pe = (e) => {
let { onlyCountries: t, excludeCountries: n } = e;
return t?.length ? h.filter((e) => t.includes(e.iso2)) : n?.length ? h.filter((e) => !n.includes(e.iso2)) : [...h];
}, me = (e, t) => {
let { countryNameLocale: n, i18n: r } = t, i;
try {
i = typeof Intl < "u" && typeof Intl.DisplayNames == "function" ? new Intl.DisplayNames(n, { type: "region" }) : null;
} catch (e) {
console.error(e), i = null;
}
for (let t of e) t.name = r[t.iso2] || i?.of(t.iso2.toUpperCase()) || "";
}, he = (e) => {
let t = /* @__PURE__ */ new Set(), n = 0, r = {}, i = (e, t) => {
if (!e || !t) return;
t.length > n && (n = t.length), Object.hasOwn(r, t) || (r[t] = []);
let i = r[t];
i.includes(e) || i.push(e);
}, a = [...e].sort((e, t) => e.priority - t.priority);
for (let e of a) {
t.has(e.dialCode) || t.add(e.dialCode);
for (let t = 1; t < e.dialCode.length; t++) {
let n = e.dialCode.substring(0, t);
i(e.iso2, n);
}
if (i(e.iso2, e.dialCode), e.areaCodes) {
let t = r[e.dialCode][0];
for (let n of e.areaCodes) {
for (let r = 1; r < n.length; r++) {
let a = n.substring(0, r), o = e.dialCode + a;
i(t, o), i(e.iso2, o);
}
i(e.iso2, e.dialCode + n);
}
}
}
return {
dialCodes: t,
dialCodeMaxLen: n,
dialCodeToIso2Map: r
};
}, ge = (e, t) => {
let { countryOrder: n } = t;
e.sort((e, t) => {
if (n) {
let r = n.indexOf(e.iso2), i = n.indexOf(t.iso2), a = r > -1, o = i > -1;
if (a || o) return a && o ? r - i : a ? -1 : 1;
}
return e.name.localeCompare(t.name);
});
}, _e = (e) => {
for (let t of e) t.normalisedName = V(t.name), t.initials = t.normalisedName.split(/[^a-z]/).map((e) => e[0]).join(""), t.dialCodePlus = `+${t.dialCode}`;
}, ve = /* @__PURE__ */ new Set([
"800",
"808",
"870",
"881",
"882",
"883",
"888",
"979"
]), K = (e) => {
let t = B(e).slice(0, 3);
return e.startsWith("+") && ve.has(t);
}, q = (e, t, n, r) => {
if (!n || !t) return e;
let i = `+${r.dialCode}`, a = e[i.length] === " " || e[i.length] === "-" ? i.length + 1 : i.length;
return e.substring(a);
}, ye = (e, t, n, r, i) => {
let a = n ? n.formatNumberAsYouType(e, r?.iso2) : e, o = r?.dialCode;
return i && t.charAt(0) !== "+" && a.includes(`+${o}`) ? (a.split(`+${o}`)[1] || "").trim() : a;
}, be = (e, t, n, r) => {
if (n === 0 && !r) return 0;
let i = 0;
for (let n = 0; n < t.length; n++) {
if (/[+0-9]/.test(t[n]) && i++, i === e && !r) return n + 1;
if (r && i === e + 1) return n;
}
return t.length;
}, xe = /* @__PURE__ */ new Set([
"800",
"822",
"833",
"844",
"855",
"866",
"877",
"880",
"881",
"882",
"883",
"884",
"885",
"886",
"887",
"888",
"889"
]), J = (e) => {
let t = B(e);
if (t.startsWith(w.NANP) && t.length >= 4) {
let e = t.substring(1, 4);
return xe.has(e);
}
return !1;
}, Se = class {
#e;
constructor(e) {
e && this.#t(e);
}
#t(e) {
/[\u0660-\u0669]/.test(e) ? this.#e = "arabic-indic" : /[\u06F0-\u06F9]/.test(e) ? this.#e = "persian" : this.#e = "ascii";
}
denormalise(e) {
if (!this.#e || this.#e === "ascii") return e;
let t = this.#e === "arabic-indic" ? 1632 : 1776;
return e.replace(/[0-9]/g, (e) => String.fromCharCode(t + Number(e)));
}
normalise(e) {
if (!e) return "";
if (this.#t(e), this.#e === "ascii") return e;
let t = this.#e === "arabic-indic" ? 1632 : 1776, n = this.#e === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
return e.replace(n, (e) => String.fromCharCode(48 + (e.charCodeAt(0) - t)));
}
isAscii() {
return !this.#e || this.#e === "ascii";
}
}, Ce = 0, Y = (e) => {
if (!Q.utils) throw Error(`intlTelInput.utils is required for ${e}(). See: https://intl-tel-input.com/docs/utils`);
}, X = () => {
let e, t;
return {
promise: new Promise((n, r) => {
e = n, t = r;
}),
resolve: e,
reject: t
};
}, Z = class e {
id;
promise;
#e;
#t;
#n;
#r;
#i;
#a;
#o;
#s;
#c = null;
#l = null;
#u;
#d = !1;
#f;
#p = null;
#m;
#h;
#g;
constructor(e, t = {}) {
this.id = Ce++, G.validateInput(e);
let n = ie(t);
this.#t = {
...P,
...n
}, ae(this.#t), oe(this.#t), this.#e = new G(e, this.#t, this.id), this.#n = se(), this.#m = new Se(e.value), this.promise = this.#y(this.#t), this.#r = pe(this.#t);
let { dialCodes: r, dialCodeMaxLen: i, dialCodeToIso2Map: a } = he(this.#r);
this.#o = r, this.#i = i, this.#a = a, this.#s = new Map(this.#r.map((e) => [e.iso2, e])), this.#b();
}
#_() {
let e = this.#e.telInput.value.trim();
return this.#m.normalise(e);
}
#v(e) {
this.#e.telInput.value = this.#m.denormalise(e);
}
#y(e) {
let { initialCountry: t, geoIpLookup: n, loadUtils: r } = e, i = t === O.AUTO && !!n, a = !!r && !Q.utils;
return i && (this.#h = X()), a && (this.#g = X()), Promise.all([this.#h?.promise, this.#g?.promise]).then(() => {});
}
#b() {
this.#f = new AbortController(), this.#x(), this.#e.generateMarkup(this.#r), this.#S(), this.#e.maybeEnsureDropdownWidthSet(), this.#C(), this.#E(), this.#t.dropdownAlwaysOpen && this.#F();
}
#x() {
me(this.#r, this.#t), ge(this.#r, this.#t), _e(this.#r);
}
#S(e = !1) {
let t = this.#e.telInput.getAttribute("value"), n = this.#m.normalise(t ?? ""), r = this.#_(), i = n && n.startsWith("+") && (!r || !r.startsWith("+")) ? n : r, a = this.#ee(i), o = J(i), { initialCountry: s, geoIpLookup: c } = this.#t, l = s === O.AUTO && c && !e, u = m(s);
a ? o ? u ? this.#J(s) : l || this.#J(E.ISO2) : this.#G(i) : u ? this.#J(s) : l || this.#J(""), i && this.#W(i);
}
#C() {
this.#k(), this.#t.allowDropdown && this.#T(), (this.#e.hiddenInputPhone || this.#e.hiddenInputCountry) && this.#e.telInput.form && this.#w();
}
#w() {
this.#e.telInput.form?.addEventListener("submit", () => {
this.#e.hiddenInputPhone && (this.#e.hiddenInputPhone.value = this.getNumber()), this.#e.hiddenInputCountry && (this.#e.hiddenInputCountry.value = this.#c?.iso2 || "");
}, { signal: this.#f.signal });
}
#T() {
let e = this.#f.signal, t = (e) => {
this.#e.isDropdownClosed() ? this.#e.telInput.focus() : e.preventDefault();
}, n = this.#e.telInput.closest("label");
n && n.addEventListener("click", t, { signal: e }), this.#e.selectedCountry.addEventListener("click", () => {
this.#e.isDropdownClosed() && !this.#e.telInput.disabled && !this.#e.telInput.readOnly && this.#F();
}, { signal: e }), this.#e.countryContainer.addEventListener("keydown", (e) => {
let t = [
v.ARROW_UP,
v.ARROW_DOWN,
v.SPACE,
v.ENTER
];
this.#e.isDropdownClosed() && t.includes(e.key) && (e.preventDefault(), e.stopPropagation(), this.#F()), e.key === v.TAB && this.#Q();
}, { signal: e });
}
#E() {
if (this.#g) {
let { loadUtils: e } = this.#t, t = () => {
Q.attachUtils(e)?.catch(() => {});
};
Q.documentReady() ? t() : window.addEventListener("load", t, { signal: this.#f.signal });
}
this.#h && (this.#c ? this.#h.resolve() : this.#D());
}
#D() {
if (Q.autoCountry) {
this.#ae();
return;
}
this.#e.selectedCountryInner.classList.add(_.LOADING), !Q.startedLoadingAutoCountry && (Q.startedLoadingAutoCountry = !0, typeof this.#t.geoIpLookup == "function" && this.#t.geoIpLookup((t = "") => {
this.#e.selectedCountryInner.classList.remove(_.LOADING);
let n = t.toLowerCase();
m(n) ? (Q.autoCountry = n, setTimeout(() => e.forEachInstance("handleAutoCountry"))) : e.forEachInstance("handleAutoCountryFailure");
}, () => {
this.#e.selectedCountryInner.classList.remove(_.LOADING), e.forEachInstance("handleAutoCountryFailure");
}));
}
#O() {
this.#F(), this.#e.searchInput.value = "+", this.#e.filterCountriesByQuery("");
}
#k() {
this.#A(), this.#j(), this.#M();
}
#A() {
let { strictMode: e, formatAsYouType: t, separateDialCode: n, allowDropdown: r, countrySearch: i } = this.#t, a = !1;
b.ALPHA_UNICODE.test(this.#_()) && (a = !0), this.#e.telInput.addEventListener("input", (o) => {
let s = this.#_();
if (this.#n && o?.data === "+" && n && r && i) {
let e = this.#e.telInput.selectionStart || 0, t = s.substring(0, e - 1), n = s.substring(e);
this.#v(t + n), this.#O();
return;
}
this.#G(s) && this.#ie();
let c = o?.data && b.NON_PLUS_NUMERIC.test(o.data), l = o?.inputType === y.PASTE && s;
c || l && !e ? a = !0 : b.NON_PLUS_NUMERIC.test(s) || (a = !1);
let u = o?.detail && o.detail.isSetNumber, d = this.#m.isAscii();
if (t && !a && !u && d) {
let e = this.#e.telInput.selectionStart || 0, t = s.substring(0, e).replace(b.NON_PLUS_NUMERIC_GLOBAL, "").length, r = o?.inputType === y.DELETE_FWD, i = ye(this.#te(), s, Q.utils, this.#c, n), a = be(t, i, e, r);
this.#v(i), this.#e.telInput.setSelectionRange(a, a);
}
if (n && s.startsWith("+") && this.#c?.dialCode) {
let e = q(s, !0, n, this.#c);
this.#v(e);
}
}, { signal: this.#f.signal });
}
#j() {
let { strictMode: e, separateDialCode: t, allowDropdown: n, countrySearch: r } = this.#t;
!e && !t || this.#e.telInput.addEventListener("keydown", (i) => {
if (!i.key || i.key.length !== 1 || i.altKey || i.ctrlKey || i.metaKey) return;
if (t && n && r && i.key === "+") {
i.preventDefault(), this.#O();
return;
}
if (!e) return;
let a = this.#_(), o = !a.startsWith("+") && this.#e.telInput.selectionStart === 0 && i.key === "+", s = this.#m.normalise(i.key), c = /^[0-9]$/.test(s), l = t ? c : o || c, u = this.#e.telInput, d = u.selectionStart, f = u.selectionEnd, p = a.slice(0, d ?? void 0), m = a.slice(f ?? void 0), h = p + i.key + m, g = this.#te(h), _ = !1;
Q.utils && this.#l && (_ = Q.utils.getCoreNumber(g, this.#c?.iso2).length > this.#l);
let v = this.#q(g) !== null;
(!l || _ && !v && !o) && i.preventDefault();
}, { signal: this.#f.signal });
}
#M() {
this.#t.strictMode && this.#e.telInput.addEventListener("paste", (e) => {
e.preventDefault();
let t = this.#e.telInput, n = t.selectionStart, r = t.selectionEnd, i = this.#_(), a = i.slice(0, n ?? void 0), o = i.slice(r ?? void 0), s = this.#c?.iso2, c = e.clipboardData.getData("text"), l = this.#m.normalise(c), u = n === 0 && r > 0, d = !i.startsWith("+") || u, f = l.replace(b.NON_PLUS_NUMERIC_GLOBAL, ""), p = f.startsWith("+"), m = f.replace(/\+/g, ""), h = p && d ? `+${m}` : m, g = a + h + o;
if (g.length > 5 && Q.utils) {
let e = Q.utils.getCoreNumber(g, s);
for (; e.length === 0 && g.length > 0;) g = g.slice(0, -1), e = Q.utils.getCoreNumber(g, s);
if (!e) return;
if (this.#l && e.length > this.#l) if (t.selectionEnd === i.length) {
let t = e.length - this.#l;
g = g.slice(0, g.length - t);
} else return;
}
this.#v(g);
let _ = n + h.length;
t.setSelectionRange(_, _), t.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
}, { signal: this.#f.signal });
}
#N(e) {
let t = Number(this.#e.telInput.getAttribute("maxlength"));
return t && e.length > t ? e.substring(0, t) : e;
}
#P(e, t = {}) {
let n = new CustomEvent(e, {
bubbles: !0,
cancelable: !0,
detail: t
});
this.#e.telInput.dispatchEvent(n);
}
#F() {
let { dropdownContainer: e, useFullscreenPopup: t } = this.#t;
this.#p = new AbortController(), this.#e.openDropdown(), !t && e && window.addEventListener("scroll", () => this.#Q(), { signal: this.#p.signal }), this.#I(), this.#P(g.OPEN_COUNTRY_DROPDOWN);
}
#I() {
let e = this.#p.signal;
this.#L(e), this.#R(e), this.#t.dropdownAlwaysOpen || this.#z(e), this.#B(e), this.#t.countrySearch && this.#V(e);
}
#L(e) {
this.#e.countryList.addEventListener("mouseover", (e) => {
let t = e.target?.closest(`.${_.COUNTRY_ITEM}`);
t && this.#e.highlightListItem(t, !1);
}, { signal: e });
}
#R(e) {
this.#e.countryList.addEventListener("click", (e) => {
let t = e.target?.closest(`.${_.COUNTRY_ITEM}`);
t && this.#Z(t);
}, { signal: e });
}
#z(e) {
let t = (e) => {
e.target.closest(`#iti-${this.id}__dropdown-content`) || this.#Q();
};
setTimeout(() => {
document.documentElement.addEventListener("click", t, { signal: e });
}, 0);
}
#B(e) {
let t = "", n = null;
document.addEventListener("keydown", (e) => {
[
v.ARROW_UP,
v.ARROW_DOWN,
v.ENTER,
v.ESC
].includes(e.key) && (e.preventDefault(), e.stopPropagation(), e.key === v.ARROW_UP || e.key === v.ARROW_DOWN ? this.#e.handleUpDownKey(e.key) : e.key === v.ENTER && !e.isComposing ? this.#U() : e.key === v.ESC && (this.#Q(), this.#e.selectedCountry.focus())), !this.#t.countrySearch && b.HIDDEN_SEARCH_CHAR.test(e.key) && (e.stopPropagation(), n && clearTimeout(n), t += e.key.toLowerCase(), this.#H(t), n = setTimeout(() => {
t = "";
}, x.HIDDEN_SEARCH_RESET_MS));
}, { signal: e });
}
#V(e) {
this.#e.searchInput.addEventListener("input", () => this.#e.handleSearchChange(), { signal: e }), this.#e.searchClearButton.addEventListener("click", () => this.#e.handleSearchClear(), { signal: e });
}
#H(e) {
let t = le(this.#r, e);
if (t) {
let e = t.nodeById[this.id];
this.#e.highlightListItem(e, !1), this.#e.scrollCountryListToItem(e);
}
}
#U() {
this.#e.highlightedItem && this.#Z(this.#e.highlightedItem);
}
#W(e) {
let { formatOnDisplay: t, nationalMode: n, separateDialCode: r } = this.#t, i = e;
if (t && Q.utils && this.#c) {
let t = K(e), a = n && !t || !i.startsWith("+") && !r, { NATIONAL: o, INTERNATIONAL: s } = Q.utils.numberFormat, c = a ? o : s;
i = Q.utils.formatNumber(i, this.#c?.iso2, c);
}
i = this.#ne(i), this.#v(i);
}
#G(e) {
let t = this.#q(e);
return t === null ? !1 : this.#J(t);
}
#K(e) {
let t = this.#c?.dialCode, n = this.#c?.nationalPrefix;
return e.startsWith("+") || !t ? e : `+${t}${n && e.startsWith(n) && !this.#t.separateDialCode ? e.substring(1) : e}`;
}
#q(e) {
let t = e.indexOf("+"), n = t > 0 ? e.substring(t) : e, r = this.#c?.iso2, i = this.#c?.dialCode;
n = this.#K(n);
let a = this.#ee(n, !0), o = B(n);
if (a) {
let e = B(a), t = this.#a[e];
if (t.length === 1) return t[0] === r ? null : t[0];
if (!r && this.#u && t.includes(this.#u)) return this.#u;
if (i === w.NANP && J(o)) return null;
let n = this.#c?.areaCodes, s = this.#c?.priority;
if (n) {
let e = n.map((e) => `${i}${e}`);
for (let t of e) if (o.startsWith(t)) return null;
}
let c = n && s !== 0 && o.length > e.length, l = r && t.includes(r) && !c, u = r === t[0];
if (!l && !u) return t[0];
} else if (n.startsWith("+") && o.length) {
let e = this.#c?.dialCode || "";
return e && e.startsWith(o) ? null : "";
} else if ((!n || n === "+") && !r && this.#u) return this.#u;
return null;
}
#J(e) {
let t = this.#c?.iso2 || "";
return this.#c = e ? this.#s.get(e) : null, this.#c && (this.#u = this.#c.iso2), this.#e.setCountry(this.#c), this.#X(), this.#Y(), t !== e;
}
#Y() {
let { strictMode: e, placeholderNumberType: t, allowedNumberTypes: n } = this.#t;
if (!e || !Q.utils) return;
let r = this.#c?.iso2;
if (!r) {
this.#l = null;
return;
}
let i = Q.utils.numberType[t], a = Q.utils.getExampleNumber(r, !1, i, !0), o = a;
for (; Q.utils.isPossibleNumber(a, r, n);) o = a, a += "0";
let s = Q.utils.getCoreNumber(o, r);
this.#l = s.length, r === "by" && (this.#l = s.length + 1);
}
#X() {
let { autoPlaceholder: e, placeholderNumberType: t, nationalMode: n, customPlaceholder: r } = this.#t, i = e === D.AGGRESSIVE || !this.#e.hadInitialPlaceholder && e === D.POLITE;
if (!Q.utils || !i) return;
let a = Q.utils.numberType[t], o = this.#c ? Q.utils.getExampleNumber(this.#c.iso2, n, a) : "";
o = this.#ne(o), typeof r == "function" && (o = r(o, this.#c)), this.#e.telInput.setAttribute("placeholder", o);
}
#Z(e) {
let t = e.dataset[A.COUNTRY_CODE], n = this.#J(t);
this.#Q();
let r = e.dataset[A.DIAL_CODE];
if (this.#$(r), this.#t.formatOnDisplay) {
let e = this.#_();
this.#W(e);
}
this.#e.telInput.focus(), n && this.#ie();
}
#Q(e) {
this.#e.isDropdownClosed() || this.#t.dropdownAlwaysOpen && !e || (this.#e.closeDropdown(), this.#p.abort(), this.#p = null, this.#P(g.CLOSE_COUNTRY_DROPDOWN));
}
#$(e)