UNPKG

v-phone-input

Version:

International phone field for Vuetify 3 and Vue 3.

1,170 lines (1,169 loc) 34.9 kB
import { computed as c, defineComponent as X, h as _, ref as m, watchEffect as Nn, onBeforeMount as Vn, onBeforeUpdate as Rn, markRaw as an, watch as I, onMounted as En, nextTick as sn, resolveComponent as Fn, createElementBlock as cn, openBlock as N, mergeProps as Z, createBlock as K, resolveDynamicComponent as O, createSlots as rn, withCtx as A, createVNode as Kn, normalizeProps as z, guardReactiveProps as W, renderSlot as B, createElementVNode as un, toDisplayString as J, createCommentVNode as On, renderList as ln } from "vue"; import { getSupportedRegionCodes as Un, getCountryCodeForRegionCode as wn, getExample as Dn, parsePhoneNumber as Hn } from "awesome-phonenumber"; import { VTextField as dn, VSelect as kn, VListItem as Zn } from "vuetify/components"; function yn() { return { country: { required: !0, type: Object }, decorative: { type: Boolean, default: !1 } }; } function $n({ props: n }) { const t = c(() => n.decorative ? void 0 : "img"), o = c(() => n.decorative ? void 0 : n.country.name); return { role: t, title: o }; } const zn = X({ props: yn(), setup(n) { const { role: t, title: o } = $n({ props: n }); return () => _("span", { role: t.value, title: o.value, class: ["v-phone-input__country__icon", "f32"] }, _("span", { class: ["flag", n.country.iso2.toLowerCase()] })); } }), Wn = X({ props: yn(), setup(n) { const { role: t, title: o } = $n({ props: n }); return () => _("span", { role: t.value, title: o.value, class: [ "v-phone-input__country__icon", "fi", `fi-${n.country.iso2.toLowerCase()}` ] }); } }); function Jn(n) { return "setPreference" in n; } function V(n) { return n && typeof n == "object" ? n.iso2 : (n || "").toUpperCase(); } function Yn({ props: n }) { const t = Un(), o = m({}), a = m(0), u = m([]), y = m([]), $ = c(() => n.preferCountries.map(V)), s = c(() => n.includeCountries.map(V)), f = c(() => n.excludeCountries.map(V)); Nn(() => { const d = {}, T = [], P = []; n.allCountries.forEach((h) => { const M = V(h.iso2); if (t.indexOf(M) === -1 || s.value.length && s.value.indexOf(M) === -1 || f.value.indexOf(M) !== -1) return; const i = { ...h, iso2: M }; d[i.iso2] = i, $.value.indexOf(M) !== -1 ? T.push(i) : P.push(i); }), T.sort((h, M) => $.value.indexOf(h.iso2) - $.value.indexOf(M.iso2)), o.value = d, u.value = T, y.value = P, a.value = T.length + P.length, a.value || console.error('[v-phone-input] resulting countries from "allCountries", "includeCountries" and "excludeCountries" must be a non-empty list'); }); const S = c(() => { const d = u.value[0] ?? y.value[0]; return d ? o.value[d.iso2] : void 0; }), G = (d) => o.value[V(d)], g = m(!1), R = c(() => !n.disableGuessLoading && g.value); return { countriesCount: a, preferredCountries: u, otherCountries: y, guessingCountry: R, findCountry: G, firstCountry: S, setCountryPreference: (d) => { g.value = !1, Jn(n.countryGuesser) && n.countryGuesser.setPreference(d); }, guessCountry: async () => { if (!n.guessCountry) return; g.value = !0; const d = G(await n.countryGuesser.guess()); return g.value = !1, d == null ? void 0 : d.iso2; } }; } function jn({ props: n }) { return { countryIconComponent: c(() => { switch (n.countryIconMode) { case "svg": return Wn; case "sprite": return zn; case "text": return; default: return n.countryIconMode; } }) }; } function Qn({ props: n }) { return { countrySelectComponent: c(() => n.enableSearchingCountry ? { type: "VAutocomplete", props: { autocomplete: "new-password", "aria-autocomplete": "off", filterKeys: ["raw.name", "raw.iso2", "raw.dialCode"] } } : { type: "VSelect", props: {} }) }; } function _n({ props: n, country: t, example: o }) { const a = (b, v) => typeof b == "function" ? b(v) : b, u = c(() => ({ country: t.value, example: o.value })), y = c(() => a(n.label, u.value)), $ = c(() => a(n.ariaLabel, u.value)), s = c(() => ({ ...u.value, label: y.value || $.value })), f = c(() => a(n.countryLabel, s.value)), S = c( () => a(n.countryAriaLabel, s.value) ), G = c(() => a(n.placeholder, s.value)), g = c(() => a(n.hint, s.value)), R = c( () => a(n.invalidMessage, s.value) ); return { label: y, ariaLabel: $, countryLabel: f, countryAriaLabel: S, placeholder: G, hint: g, invalidMessage: R, messageOptions: u }; } function Xn(n, t) { const o = m({}), a = () => { const u = {}; Object.keys(n).forEach((y) => { const [$, ...s] = y.split(":"); !s.length || t.indexOf($) === -1 ? u.default = { ...u.default || {}, [y]: y } : u[$] = { ...u[$] || {}, [s.join(":")]: y }; }), o.value = u; }; return Vn(a), Rn(a), { namespacedSlots: o }; } const qn = "Andorra", xn = "United Arab Emirates", nt = "Afghanistan", tt = "Antigua and Barbuda", et = "Anguilla", ot = "Albania", at = "Armenia", st = "Angola", ct = "Antarctica", rt = "Argentina", it = "American Samoa", ut = "Austria", lt = "Australia", dt = "Aruba", yt = "Aland", $t = "Azerbaijan", Ct = "Bosnia and Herzegovina", mt = "Barbados", pt = "Bangladesh", St = "Belgium", vt = "Burkina Faso", Mt = "Bulgaria", ft = "Bahrain", gt = "Burundi", ht = "Benin", It = "Saint Barthelemy", Gt = "Bermuda", bt = "Brunei", At = "Bolivia", Bt = "Bonaire", Tt = "Brazil", Pt = "Bahamas", Lt = "Bhutan", Nt = "Bouvet Island", Vt = "Botswana", Rt = "Belarus", Et = "Belize", Ft = "Canada", Kt = "Cocos (Keeling) Islands", Ot = "Democratic Republic of the Congo", Ut = "Central African Republic", wt = "Republic of the Congo", Dt = "Switzerland", Ht = "Ivory Coast", kt = "Cook Islands", Zt = "Chile", zt = "Cameroon", Wt = "China", Jt = "Colombia", Yt = "Costa Rica", jt = "Cuba", Qt = "Cape Verde", _t = "Curacao", Xt = "Christmas Island", qt = "Cyprus", xt = "Czech Republic", ne = "Germany", te = "Djibouti", ee = "Denmark", oe = "Dominica", ae = "Dominican Republic", se = "Algeria", ce = "Ecuador", re = "Estonia", ie = "Egypt", ue = "Western Sahara", le = "Eritrea", de = "Spain", ye = "Ethiopia", $e = "Finland", Ce = "Fiji", me = "Falkland Islands", pe = "Micronesia", Se = "Faroe Islands", ve = "France", Me = "Gabon", fe = "United Kingdom", ge = "Grenada", he = "Georgia", Ie = "French Guiana", Ge = "Guernsey", be = "Ghana", Ae = "Gibraltar", Be = "Greenland", Te = "Gambia", Pe = "Guinea", Le = "Guadeloupe", Ne = "Equatorial Guinea", Ve = "Greece", Re = "South Georgia and the South Sandwich Islands", Ee = "Guatemala", Fe = "Guam", Ke = "Guinea-Bissau", Oe = "Guyana", Ue = "Hong Kong", we = "Heard Island and McDonald Islands", De = "Honduras", He = "Croatia", ke = "Haiti", Ze = "Hungary", ze = "Indonesia", We = "Ireland", Je = "Israel", Ye = "Isle of Man", je = "India", Qe = "British Indian Ocean Territory", _e = "Iraq", Xe = "Iran", qe = "Iceland", xe = "Italy", no = "Jersey", to = "Jamaica", eo = "Jordan", oo = "Japan", ao = "Kenya", so = "Kyrgyzstan", co = "Cambodia", ro = "Kiribati", io = "Comoros", uo = "Saint Kitts and Nevis", lo = "North Korea", yo = "South Korea", $o = "Kuwait", Co = "Cayman Islands", mo = "Kazakhstan", po = "Laos", So = "Lebanon", vo = "Saint Lucia", Mo = "Liechtenstein", fo = "Sri Lanka", go = "Liberia", ho = "Lesotho", Io = "Lithuania", Go = "Luxembourg", bo = "Latvia", Ao = "Libya", Bo = "Morocco", To = "Monaco", Po = "Moldova", Lo = "Montenegro", No = "Saint Martin", Vo = "Madagascar", Ro = "Marshall Islands", Eo = "North Macedonia", Fo = "Mali", Ko = "Myanmar (Burma)", Oo = "Mongolia", Uo = "Macao", wo = "Northern Mariana Islands", Do = "Martinique", Ho = "Mauritania", ko = "Montserrat", Zo = "Malta", zo = "Mauritius", Wo = "Maldives", Jo = "Malawi", Yo = "Mexico", jo = "Malaysia", Qo = "Mozambique", _o = "Namibia", Xo = "New Caledonia", qo = "Niger", xo = "Norfolk Island", na = "Nigeria", ta = "Nicaragua", ea = "Netherlands", oa = "Norway", aa = "Nepal", sa = "Nauru", ca = "Niue", ra = "New Zealand", ia = "Oman", ua = "Panama", la = "Peru", da = "French Polynesia", ya = "Papua New Guinea", $a = "Philippines", Ca = "Pakistan", ma = "Poland", pa = "Saint Pierre and Miquelon", Sa = "Pitcairn Islands", va = "Puerto Rico", Ma = "Palestine", fa = "Portugal", ga = "Palau", ha = "Paraguay", Ia = "Qatar", Ga = "Reunion", ba = "Romania", Aa = "Serbia", Ba = "Russia", Ta = "Rwanda", Pa = "Saudi Arabia", La = "Solomon Islands", Na = "Seychelles", Va = "Sudan", Ra = "Sweden", Ea = "Singapore", Fa = "Saint Helena", Ka = "Slovenia", Oa = "Svalbard and Jan Mayen", Ua = "Slovakia", wa = "Sierra Leone", Da = "San Marino", Ha = "Senegal", ka = "Somalia", Za = "Suriname", za = "South Sudan", Wa = "Sao Tome and Principe", Ja = "El Salvador", Ya = "Sint Maarten", ja = "Syria", Qa = "Eswatini", _a = "Turks and Caicos Islands", Xa = "Chad", qa = "French Southern Territories", xa = "Togo", ns = "Thailand", ts = "Tajikistan", es = "Tokelau", os = "East Timor", as = "Turkmenistan", ss = "Tunisia", cs = "Tonga", rs = "Turkey", is = "Trinidad and Tobago", us = "Tuvalu", ls = "Taiwan", ds = "Tanzania", ys = "Ukraine", $s = "Uganda", Cs = "U.S. Minor Outlying Islands", ms = "United States", ps = "Uruguay", Ss = "Uzbekistan", vs = "Vatican City", Ms = "Saint Vincent and the Grenadines", fs = "Venezuela", gs = "British Virgin Islands", hs = "U.S. Virgin Islands", Is = "Vietnam", Gs = "Vanuatu", bs = "Wallis and Futuna", As = "Samoa", Bs = "Kosovo", Ts = "Yemen", Ps = "Mayotte", Ls = "South Africa", Ns = "Zambia", Vs = "Zimbabwe", Rs = { AD: qn, AE: xn, AF: nt, AG: tt, AI: et, AL: ot, AM: at, AO: st, AQ: ct, AR: rt, AS: it, AT: ut, AU: lt, AW: dt, AX: yt, AZ: $t, BA: Ct, BB: mt, BD: pt, BE: St, BF: vt, BG: Mt, BH: ft, BI: gt, BJ: ht, BL: It, BM: Gt, BN: bt, BO: At, BQ: Bt, BR: Tt, BS: Pt, BT: Lt, BV: Nt, BW: Vt, BY: Rt, BZ: Et, CA: Ft, CC: Kt, CD: Ot, CF: Ut, CG: wt, CH: Dt, CI: Ht, CK: kt, CL: Zt, CM: zt, CN: Wt, CO: Jt, CR: Yt, CU: jt, CV: Qt, CW: _t, CX: Xt, CY: qt, CZ: xt, DE: ne, DJ: te, DK: ee, DM: oe, DO: ae, DZ: se, EC: ce, EE: re, EG: ie, EH: ue, ER: le, ES: de, ET: ye, FI: $e, FJ: Ce, FK: me, FM: pe, FO: Se, FR: ve, GA: Me, GB: fe, GD: ge, GE: he, GF: Ie, GG: Ge, GH: be, GI: Ae, GL: Be, GM: Te, GN: Pe, GP: Le, GQ: Ne, GR: Ve, GS: Re, GT: Ee, GU: Fe, GW: Ke, GY: Oe, HK: Ue, HM: we, HN: De, HR: He, HT: ke, HU: Ze, ID: ze, IE: We, IL: Je, IM: Ye, IN: je, IO: Qe, IQ: _e, IR: Xe, IS: qe, IT: xe, JE: no, JM: to, JO: eo, JP: oo, KE: ao, KG: so, KH: co, KI: ro, KM: io, KN: uo, KP: lo, KR: yo, KW: $o, KY: Co, KZ: mo, LA: po, LB: So, LC: vo, LI: Mo, LK: fo, LR: go, LS: ho, LT: Io, LU: Go, LV: bo, LY: Ao, MA: Bo, MC: To, MD: Po, ME: Lo, MF: No, MG: Vo, MH: Ro, MK: Eo, ML: Fo, MM: Ko, MN: Oo, MO: Uo, MP: wo, MQ: Do, MR: Ho, MS: ko, MT: Zo, MU: zo, MV: Wo, MW: Jo, MX: Yo, MY: jo, MZ: Qo, NA: _o, NC: Xo, NE: qo, NF: xo, NG: na, NI: ta, NL: ea, NO: oa, NP: aa, NR: sa, NU: ca, NZ: ra, OM: ia, PA: ua, PE: la, PF: da, PG: ya, PH: $a, PK: Ca, PL: ma, PM: pa, PN: Sa, PR: va, PS: Ma, PT: fa, PW: ga, PY: ha, QA: Ia, RE: Ga, RO: ba, RS: Aa, RU: Ba, RW: Ta, SA: Pa, SB: La, SC: Na, SD: Va, SE: Ra, SG: Ea, SH: Fa, SI: Ka, SJ: Oa, SK: Ua, SL: wa, SM: Da, SN: Ha, SO: ka, SR: Za, SS: za, ST: Wa, SV: Ja, SX: Ya, SY: ja, SZ: Qa, TC: _a, TD: Xa, TF: qa, TG: xa, TH: ns, TJ: ts, TK: es, TL: os, TM: as, TN: ss, TO: cs, TR: rs, TT: is, TV: us, TW: ls, TZ: ds, UA: ys, UG: $s, UM: Cs, US: ms, UY: ps, UZ: Ss, VA: vs, VC: Ms, VE: fs, VG: gs, VI: hs, VN: Is, VU: Gs, WF: bs, WS: As, XK: Bs, YE: Ts, YT: Ps, ZA: Ls, ZM: Ns, ZW: Vs }, Es = "Andorra", Fs = "دولة الإمارات العربية المتحدة", Ks = "افغانستان", Os = "Antigua and Barbuda", Us = "Anguilla", ws = "Shqipëria", Ds = "Հայաստան", Hs = "Angola", ks = "Antarctica", Zs = "Argentina", zs = "American Samoa", Ws = "Österreich", Js = "Australia", Ys = "Aruba", js = "Åland", Qs = "Azərbaycan", _s = "Bosna i Hercegovina", Xs = "Barbados", qs = "Bangladesh", xs = "België", nc = "Burkina Faso", tc = "България", ec = "‏البحرين", oc = "Burundi", ac = "Bénin", sc = "Saint-Barthélemy", cc = "Bermuda", rc = "Negara Brunei Darussalam", ic = "Bolivia", uc = "Bonaire", lc = "Brasil", dc = "Bahamas", yc = "ʼbrug-yul", $c = "Bouvetøya", Cc = "Botswana", mc = "Белару́сь", pc = "Belize", Sc = "Canada", vc = "Cocos (Keeling) Islands", Mc = "République démocratique du Congo", fc = "Ködörösêse tî Bêafrîka", gc = "République du Congo", hc = "Schweiz", Ic = "Côte d'Ivoire", Gc = "Cook Islands", bc = "Chile", Ac = "Cameroon", Bc = "中国", Tc = "Colombia", Pc = "Costa Rica", Lc = "Cuba", Nc = "Cabo Verde", Vc = "Curaçao", Rc = "Christmas Island", Ec = "Κύπρος", Fc = "Česká republika", Kc = "Deutschland", Oc = "Djibouti", Uc = "Danmark", wc = "Dominica", Dc = "República Dominicana", Hc = "الجزائر", kc = "Ecuador", Zc = "Eesti", zc = "مصر‎", Wc = "الصحراء الغربية", Jc = "ኤርትራ", Yc = "España", jc = "ኢትዮጵያ", Qc = "Suomi", _c = "Fiji", Xc = "Falkland Islands", qc = "Micronesia", xc = "Føroyar", nr = "France", tr = "Gabon", er = "United Kingdom", or = "Grenada", ar = "საქართველო", sr = "Guyane française", cr = "Guernsey", rr = "Ghana", ir = "Gibraltar", ur = "Kalaallit Nunaat", lr = "Gambia", dr = "Guinée", yr = "Guadeloupe", $r = "Guinea Ecuatorial", Cr = "Ελλάδα", mr = "South Georgia", pr = "Guatemala", Sr = "Guam", vr = "Guiné-Bissau", Mr = "Guyana", fr = "香港", gr = "Heard Island and McDonald Islands", hr = "Honduras", Ir = "Hrvatska", Gr = "Haïti", br = "Magyarország", Ar = "Indonesia", Br = "Éire", Tr = "יִשְׂרָאֵל", Pr = "Isle of Man", Lr = "भारत", Nr = "British Indian Ocean Territory", Vr = "العراق", Rr = "ایران", Er = "Ísland", Fr = "Italia", Kr = "Jersey", Or = "Jamaica", Ur = "الأردن", wr = "日本", Dr = "Kenya", Hr = "Кыргызстан", kr = "Kâmpŭchéa", Zr = "Kiribati", zr = "Komori", Wr = "Saint Kitts and Nevis", Jr = "북한", Yr = "대한민국", jr = "الكويت", Qr = "Cayman Islands", _r = "Қазақстан", Xr = "ສປປລາວ", qr = "لبنان", xr = "Saint Lucia", ni = "Liechtenstein", ti = "śrī laṃkāva", ei = "Liberia", oi = "Lesotho", ai = "Lietuva", si = "Luxembourg", ci = "Latvija", ri = "‏ليبيا", ii = "المغرب", ui = "Monaco", li = "Moldova", di = "Црна Гора", yi = "Saint-Martin", $i = "Madagasikara", Ci = "M̧ajeļ", mi = "Северна Македонија", pi = "Mali", Si = "မြန်မာ", vi = "Монгол улс", Mi = "澳門", fi = "Northern Mariana Islands", gi = "Martinique", hi = "موريتانيا", Ii = "Montserrat", Gi = "Malta", bi = "Maurice", Ai = "Maldives", Bi = "Malawi", Ti = "México", Pi = "Malaysia", Li = "Moçambique", Ni = "Namibia", Vi = "Nouvelle-Calédonie", Ri = "Niger", Ei = "Norfolk Island", Fi = "Nigeria", Ki = "Nicaragua", Oi = "Nederland", Ui = "Norge", wi = "नेपाल", Di = "Nauru", Hi = "Niuē", ki = "New Zealand", Zi = "عمان", zi = "Panamá", Wi = "Perú", Ji = "Polynésie française", Yi = "Papua Niugini", ji = "Pilipinas", Qi = "Pakistan", _i = "Polska", Xi = "Saint-Pierre-et-Miquelon", qi = "Pitcairn Islands", xi = "Puerto Rico", nu = "فلسطين", tu = "Portugal", eu = "Palau", ou = "Paraguay", au = "قطر", su = "La Réunion", cu = "România", ru = "Србија", iu = "Россия", uu = "Rwanda", lu = "العربية السعودية", du = "Solomon Islands", yu = "Seychelles", $u = "السودان", Cu = "Sverige", mu = "Singapore", pu = "Saint Helena", Su = "Slovenija", vu = "Svalbard og Jan Mayen", Mu = "Slovensko", fu = "Sierra Leone", gu = "San Marino", hu = "Sénégal", Iu = "Soomaaliya", Gu = "Suriname", bu = "South Sudan", Au = "São Tomé e Príncipe", Bu = "El Salvador", Tu = "Sint Maarten", Pu = "سوريا", Lu = "Eswatini", Nu = "Turks and Caicos Islands", Vu = "Tchad", Ru = "Territoire des Terres australes et antarctiques fr", Eu = "Togo", Fu = "ประเทศไทย", Ku = "Тоҷикистон", Ou = "Tokelau", Uu = "Timor-Leste", wu = "Türkmenistan", Du = "تونس", Hu = "Tonga", ku = "Türkiye", Zu = "Trinidad and Tobago", zu = "Tuvalu", Wu = "臺灣", Ju = "Tanzania", Yu = "Україна", ju = "Uganda", Qu = "United States Minor Outlying Islands", _u = "United States", Xu = "Uruguay", qu = "O'zbekiston", xu = "Vaticano", nl = "Saint Vincent and the Grenadines", tl = "Venezuela", el = "British Virgin Islands", ol = "United States Virgin Islands", al = "Việt Nam", sl = "Vanuatu", cl = "Wallis et Futuna", rl = "Samoa", il = "Republika e Kosovës", ul = "اليَمَن", ll = "Mayotte", dl = "South Africa", yl = "Zambia", $l = "Zimbabwe", Y = { AD: Es, AE: Fs, AF: Ks, AG: Os, AI: Us, AL: ws, AM: Ds, AO: Hs, AQ: ks, AR: Zs, AS: zs, AT: Ws, AU: Js, AW: Ys, AX: js, AZ: Qs, BA: _s, BB: Xs, BD: qs, BE: xs, BF: nc, BG: tc, BH: ec, BI: oc, BJ: ac, BL: sc, BM: cc, BN: rc, BO: ic, BQ: uc, BR: lc, BS: dc, BT: yc, BV: $c, BW: Cc, BY: mc, BZ: pc, CA: Sc, CC: vc, CD: Mc, CF: fc, CG: gc, CH: hc, CI: Ic, CK: Gc, CL: bc, CM: Ac, CN: Bc, CO: Tc, CR: Pc, CU: Lc, CV: Nc, CW: Vc, CX: Rc, CY: Ec, CZ: Fc, DE: Kc, DJ: Oc, DK: Uc, DM: wc, DO: Dc, DZ: Hc, EC: kc, EE: Zc, EG: zc, EH: Wc, ER: Jc, ES: Yc, ET: jc, FI: Qc, FJ: _c, FK: Xc, FM: qc, FO: xc, FR: nr, GA: tr, GB: er, GD: or, GE: ar, GF: sr, GG: cr, GH: rr, GI: ir, GL: ur, GM: lr, GN: dr, GP: yr, GQ: $r, GR: Cr, GS: mr, GT: pr, GU: Sr, GW: vr, GY: Mr, HK: fr, HM: gr, HN: hr, HR: Ir, HT: Gr, HU: br, ID: Ar, IE: Br, IL: Tr, IM: Pr, IN: Lr, IO: Nr, IQ: Vr, IR: Rr, IS: Er, IT: Fr, JE: Kr, JM: Or, JO: Ur, JP: wr, KE: Dr, KG: Hr, KH: kr, KI: Zr, KM: zr, KN: Wr, KP: Jr, KR: Yr, KW: jr, KY: Qr, KZ: _r, LA: Xr, LB: qr, LC: xr, LI: ni, LK: ti, LR: ei, LS: oi, LT: ai, LU: si, LV: ci, LY: ri, MA: ii, MC: ui, MD: li, ME: di, MF: yi, MG: $i, MH: Ci, MK: mi, ML: pi, MM: Si, MN: vi, MO: Mi, MP: fi, MQ: gi, MR: hi, MS: Ii, MT: Gi, MU: bi, MV: Ai, MW: Bi, MX: Ti, MY: Pi, MZ: Li, NA: Ni, NC: Vi, NE: Ri, NF: Ei, NG: Fi, NI: Ki, NL: Oi, NO: Ui, NP: wi, NR: Di, NU: Hi, NZ: ki, OM: Zi, PA: zi, PE: Wi, PF: Ji, PG: Yi, PH: ji, PK: Qi, PL: _i, PM: Xi, PN: qi, PR: xi, PS: nu, PT: tu, PW: eu, PY: ou, QA: au, RE: su, RO: cu, RS: ru, RU: iu, RW: uu, SA: lu, SB: du, SC: yu, SD: $u, SE: Cu, SG: mu, SH: pu, SI: Su, SJ: vu, SK: Mu, SL: fu, SM: gu, SN: hu, SO: Iu, SR: Gu, SS: bu, ST: Au, SV: Bu, SX: Tu, SY: Pu, SZ: Lu, TC: Nu, TD: Vu, TF: Ru, TG: Eu, TH: Fu, TJ: Ku, TK: Ou, TL: Uu, TM: wu, TN: Du, TO: Hu, TR: ku, TT: Zu, TV: zu, TW: Wu, TZ: Ju, UA: Yu, UG: ju, UM: Qu, US: _u, UY: Xu, UZ: qu, VA: xu, VC: nl, VE: tl, VG: el, VI: ol, VN: al, VU: sl, WF: cl, WS: rl, XK: il, YE: ul, YT: ll, ZA: dl, ZM: yl, ZW: $l }, Cl = Object.entries(Rs).sort(([n, t], [o, a]) => t.localeCompare(a)).map(([n, t]) => ({ name: t !== Y[n] ? `${Y[n]} (${t})` : Y[n], iso2: V(n), dialCode: `${wn(n)}` })), w = class w { // eslint-disable-next-line class-methods-use-this async guess() { let t, o; try { t = await fetch(w.IP2C_URL), o = await t.text(); } catch { return; } const a = o.toString().split(";"); if (!(!a || a[0] !== "1")) return a[1]; } }; w.IP2C_URL = "https://ip2c.org/s"; let U = w; class ml extends U { constructor() { super(...arguments), this.memoCountry = void 0; } async guess() { return this.memoCountry || (this.memoCountry = await super.guess()), this.memoCountry; } setPreference(t) { this.memoCountry = t; } } const pl = { label: "Phone", ariaLabel: void 0, countryLabel: void 0, countryAriaLabel: (n) => `Country for ${n.label}`, placeholder: void 0, hint: void 0, invalidMessage: (n) => `The "${n.label}" field is not a valid phone number (example: ${n.example}).`, example: void 0, persistentPlaceholder: void 0, persistentHint: void 0, countryIconMode: void 0, allCountries: Cl, preferCountries: [], includeCountries: [], excludeCountries: [], defaultCountry: void 0, countryGuesser: new ml(), guessCountry: !1, disableGuessLoading: !1, enableSearchingCountry: !1, displayFormat: "national", phoneValidator: (n) => n.valid }, Cn = { ...pl }; function Sl(n) { Object.assign(Cn, n); } function l(n) { return Cn[n]; } function vl(n, t) { var o, a; return ((o = n.number) == null ? void 0 : o[t]) || ((a = n.number) == null ? void 0 : a.input) || ""; } function Ml(n) { return Dn(n); } function j(n, t) { return Hn((n || "").trim(), { regionCode: t }); } const Q = [ "id", "class", "style" ], fl = [ "variant", "flat", "tile", "density", "singleLine", "hideDetails", "direction", "reverse", "color", "bgColor", "theme", "disabled", "readonly", "rounded" ], gl = X({ components: { VListItem: Zn, VSelect: kn, VTextField: dn }, inheritAttrs: !1, props: { label: { type: [String, Function], default: () => l("label") }, ariaLabel: { type: [String, Function], default: () => l("ariaLabel") }, countryLabel: { type: [String, Function], default: () => l("countryLabel") }, countryAriaLabel: { type: [String, Function], default: () => l("countryAriaLabel") }, placeholder: { type: [String, Function], default: () => l("placeholder") }, hint: { type: [String, Function], default: () => l("hint") }, invalidMessage: { type: [String, Function], default: () => l("invalidMessage") }, example: { type: [String, Function], default: () => l("example") }, appendIcon: { type: String, default: void 0 }, appendInnerIcon: { type: String, default: void 0 }, prependIcon: { type: String, default: void 0 }, prependInnerIcon: { type: String, default: void 0 }, rules: { type: Array, default: () => [] }, validateOn: { type: String, default: void 0 }, phoneValidator: { type: Function, default: l("phoneValidator") }, countryIconMode: { type: [String, Object], default: () => l("countryIconMode") }, allCountries: { type: Array, default: () => l("allCountries") }, preferCountries: { type: Array, default: () => l("preferCountries") }, includeCountries: { type: Array, default: () => l("includeCountries") }, excludeCountries: { type: Array, default: () => l("excludeCountries") }, defaultCountry: { type: String, default: () => l("defaultCountry") }, countryGuesser: { type: Object, default: () => l("countryGuesser") }, guessCountry: { type: Boolean, default: () => l("guessCountry") }, disableGuessLoading: { type: Boolean, default: () => l("disableGuessLoading") }, enableSearchingCountry: { type: Boolean, default: () => l("enableSearchingCountry") }, displayFormat: { type: String, default: () => l("displayFormat") }, country: { type: String, default: "" }, modelValue: { type: String, default: "" }, wrapperProps: { type: Object, default: () => ({}) }, countryProps: { type: Object, default: () => ({}) }, phoneProps: { type: Object, default: () => ({}) } }, emits: { "update:modelValue": (n) => !0, "update:country": (n) => !0 }, setup(n, { attrs: t, emit: o, slots: a, expose: u }) { const { countriesCount: y, preferredCountries: $, otherCountries: s, guessingCountry: f, findCountry: S, firstCountry: G, setCountryPreference: g, guessCountry: R } = Yn({ props: n }), b = m(null), v = m(null), { namespacedSlots: d } = Xn(a, ["country"]), { countryIconComponent: T } = jn({ props: n }), { countrySelectComponent: P } = Qn({ props: n }), h = m(!1), M = m([]), i = m(n.country), p = m(n.modelValue || ""), C = m(an(j(""))), D = (e) => Object.keys(t).reduce((r, L) => e(L) ? { ...r, [L]: t[L] } : r, {}), mn = c(() => ({ ...D((e) => Q.indexOf(e) !== -1), ...n.wrapperProps })), pn = c(() => ({ ...P.value.props, ...D((e) => Q.indexOf(e) === -1 && fl.indexOf(e) !== -1), ...n.countryProps, menuProps: { maxHeight: 300, contentClass: "v-phone-input__country__menu", closeOnContentClick: !0, ...(n.countryProps ? n.countryProps.menuProps : void 0) || {} } })), Sn = c(() => ({ ...D((e) => Q.indexOf(e) === -1), ...n.phoneProps })), vn = c(() => S(n.defaultCountry) || G.value), E = c(() => S(i.value) || vn.value), Mn = c(() => [...$.value.map((r) => ({ ...r, preferred: !0 })), ...s.value]), H = (e) => vl(e, n.displayFormat), fn = c(() => n.example !== void 0 ? typeof n.example == "function" ? n.example(E.value) : n.example : H(Ml(E.value.iso2))), gn = c(() => { var r; const e = new Set(((r = n.validateOn) == null ? void 0 : r.split("")) || []); return e.size === 0 || e.has("input"); }), F = _n({ props: n, country: E, example: fn }), q = () => { var e; gn.value && ((e = v.value) == null || e.validate()); }, k = () => { const e = n.rules.map((r) => typeof r == "function" ? () => r(p.value ?? "", C.value, F.messageOptions.value) : r); F.invalidMessage.value ? M.value = [ ...e, () => !p.value || n.phoneValidator(C.value) || F.invalidMessage.value ] : M.value = e; }, hn = () => { n.phoneValidator(C.value) && (p.value = H(C.value)); }, In = () => { var e, r; n.modelValue !== (((e = C.value.number) == null ? void 0 : e.input) ?? "") && n.modelValue !== (((r = C.value.number) == null ? void 0 : r.e164) ?? "") && (p.value = n.modelValue || ""); }, Gn = () => { n.country && n.country !== i.value && (i.value = n.country); }; I(() => n.rules, k, { deep: !0, immediate: !0 }), I(() => n.displayFormat, hn), I(() => n.modelValue, In), I(() => n.country, Gn); const bn = () => { k(), (p.value ?? "") !== "" && q(); }; I(F.invalidMessage, bn); const An = () => { h.value = !0; }, Bn = () => { h.value = !1; }, x = () => { C.value = an(j(p.value, i.value)), n.phoneValidator(C.value) && (p.value = H(C.value)); }, Tn = (e, r) => { i.value ? (o("update:country", i.value), g(i.value)) : sn(() => { i.value || (i.value = r); }), x(), (p.value ?? "") !== "" && q(); }, nn = () => { if ((p.value || "").startsWith("+")) { const r = j(p.value).regionCode; r && i.value !== r && S(r) && (i.value = r); } x(); }, Pn = () => { var en, on; const e = ((en = C.value.number) == null ? void 0 : en.input) || "", r = ((on = C.value.number) == null ? void 0 : on.e164) || e, L = n.phoneValidator(C.value); (n.modelValue !== e || n.modelValue !== r && L) && o("update:modelValue", L ? r : e); }; I(i, Tn), I(p, nn), I(C, Pn, { deep: !0 }); const Ln = async () => { if (i.value) return; if (y.value === 1) { i.value = G.value.iso2; return; } const e = await R(); !i.value && e && (i.value = e), i.value = i.value || E.value.iso2; }; En(() => { nn(), sn(() => { Ln(); }); }); const tn = { countryInputRef: b, phoneInputRef: v, isValid: c(() => { var e; return ((e = v.value) == null ? void 0 : e.isValid) ?? !0; }), errorMessages: c(() => { var e; return ((e = v.value) == null ? void 0 : e.errorMessages) ?? []; }), reset: async () => { var e; await ((e = v.value) == null ? void 0 : e.reset()); }, resetValidation: async () => { var e; await ((e = v.value) == null ? void 0 : e.resetValidation()); }, validate: async (e) => { var r; return await ((r = v.value) == null ? void 0 : r.validate(e)) ?? []; } }; return u(tn), { wrapperAttrs: mn, VTextField: dn, countryInput: b, phoneInput: v, namespacedSlots: d, countrySelectComponent: P, countryIconComponent: T, countryAttrs: pn, phoneAttrs: Sn, countryFocused: h, guessingCountry: f, mergeRules: k, lazyCountry: i, lazyValue: p, mergedRules: M, activeCountry: E, labels: F, countriesItems: Mn, onCountryFocus: An, onCountryBlur: Bn, ...tn }; } }), hl = (n, t) => { const o = n.__vccOpts || n; for (const [a, u] of t) o[a] = u; return o; }, Il = { key: 1 }, Gl = { class: "v-phone-input__country__title" }, bl = { class: "v-phone-input__country__append text-body-2" }; function Al(n, t, o, a, u, y) { const $ = Fn("v-list-item"); return N(), cn("div", Z({ class: [{ "v-phone-input--prepend-inner-icon": n.prependInnerIcon }, "v-phone-input"] }, n.wrapperAttrs), [ (N(), K(O(n.countrySelectComponent.type), Z({ ref: "countryInput", modelValue: n.lazyCountry, "onUpdate:modelValue": t[0] || (t[0] = (s) => n.lazyCountry = s), label: n.labels.countryLabel.value, "aria-label": n.labels.countryAriaLabel.value, items: n.countriesItems, "item-title": "name", "item-value": "iso2", loading: n.guessingCountry, "prepend-icon": n.prependIcon, "prepend-inner-icon": n.prependInnerIcon, class: [{ "v-phone-input--focused": n.countryFocused }, "v-phone-input__country__input"] }, n.countryAttrs, { onFocus: n.onCountryFocus, onBlur: n.onCountryBlur }), rn({ selection: A(() => [ B(n.$slots, "country-selection", { country: n.activeCountry }, () => [ B(n.$slots, "country-icon", { country: n.activeCountry, decorative: !1 }, () => [ n.countryIconComponent ? (N(), K(O(n.countryIconComponent), { key: 0, country: n.activeCountry, decorative: !1 }, null, 8, ["country"])) : (N(), cn("span", Il, J(`+${n.activeCountry.dialCode}`), 1)) ]) ]) ]), item: A((s) => [ Kn($, z(W(s.props)), { prepend: A(() => [ B(n.$slots, "country-icon", { country: s.item.raw, decorative: !0 }, () => [ n.countryIconComponent ? (N(), K(O(n.countryIconComponent), { key: 0, country: s.item.raw, decorative: !0 }, null, 8, ["country"])) : On("", !0) ]) ]), title: A(() => [ B(n.$slots, "country-title", { country: s.item.raw }, () => [ un("span", Gl, J(s.item.raw.name), 1) ]) ]), append: A(() => [ B(n.$slots, "country-append", { country: s.item.raw }, () => [ un("span", bl, " +" + J(s.item.raw.dialCode), 1) ]) ]), _: 2 }, 1040) ]), _: 2 }, [ ln(n.namespacedSlots.country, (s, f) => ({ name: f, fn: A((S) => [ B(n.$slots, s, z(W(S))) ]) })) ]), 1040, ["modelValue", "label", "aria-label", "items", "loading", "prepend-icon", "prepend-inner-icon", "class", "onFocus", "onBlur"])), (N(), K(O(n.VTextField), Z({ ref: "phoneInput", modelValue: n.lazyValue, "onUpdate:modelValue": t[1] || (t[1] = (s) => n.lazyValue = s), label: n.labels.label.value, "aria-label": n.labels.ariaLabel.value, placeholder: n.labels.placeholder.value, hint: n.labels.hint.value, rules: n.mergedRules, "append-icon": n.appendIcon, "append-inner-icon": n.appendInnerIcon, "validate-on": n.validateOn, class: "v-phone-input__phone__input", type: "tel" }, n.phoneAttrs), rn({ _: 2 }, [ ln(n.namespacedSlots.default, (s, f) => ({ name: f, fn: A((S) => [ B(n.$slots, f, z(W(S))) ]) })) ]), 1040, ["modelValue", "label", "aria-label", "placeholder", "hint", "rules", "append-icon", "append-inner-icon", "validate-on"])) ], 16); } const Bl = /* @__PURE__ */ hl(gl, [["render", Al]]); function Nl(n) { return (t, o) => { o && console.warn("[v-phone-input] options must be passed as first argument of createVPhoneInput()"), Sl(n || {}), t.component("VPhoneInput", Bl); }; } class Vl extends U { constructor(t = {}) { super(), this.storage = t.storage || localStorage, this.key = t.key || "v_phone_input_country"; } async guess() { const t = this.retrieveStoredCountry(); if (t) return t; const o = await super.guess(); return o && this.saveStoredCountry(o), o; } setPreference(t) { this.saveStoredCountry(t); } retrieveStoredCountry() { return this.storage.getItem(this.key) || void 0; } saveStoredCountry(t) { this.storage.setItem(this.key, t); } getStorage() { return this.storage; } getKey() { return this.key; } } export { pl as DEFAULT_OPTIONS, U as Ip2cCountryGuesser, ml as MemoIp2cCountryGuesser, Vl as StorageMemoIp2cCountryGuesser, zn as VCountryIconSprite, Wn as VCountryIconSvg, Bl as VPhoneInput, Cl as countries, Nl as createVPhoneInput, vl as formatPhone, l as getOption, Ml as makeExample, j as makePhone, Sl as mergeOptions };