@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
1,058 lines (1,056 loc) • 34.7 kB
JavaScript
import { o as Ae } from "./chunk-cI0lbGMq.js";
import { t as X } from "./utils-COaoD3PI.js";
import { Typography as ee } from "./components/Typography/Typography.js";
import { n as Ne } from "./phone-number.provider-CdPQAKnl.js";
import { usePhoneNumberContext as Be } from "./components/PhoneNumberInput/contexts/phone-number.hook.js";
import { labelVariants as Re, phoneNumberInputVariants as Ge } from "./components/PhoneNumberInput/PhoneNumberInput.variants.js";
import { getPhoneMask as Le } from "./components/PhoneNumberInput/utils/index.js";
import { FlagContent as Ve } from "./components/PhoneNumberInput/components/FlagContent/FlagContent.js";
import { FlagSelectorWrapper as xe } from "./components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js";
import { forwardRef as Ke, useCallback as De, useEffect as pe, useId as Fe, useImperativeHandle as Ue, useMemo as _e, useRef as te } from "react";
import { jsx as B, jsxs as Z } from "react/jsx-runtime";
function de(e, n) {
(n == null || n > e.length) && (n = e.length);
for (var t = 0, r = Array(n); t < n; t++) r[t] = e[t];
return r;
}
function $e(e, n, t) {
return n = Y(n), (function(r, o) {
if (o && (typeof o == "object" || typeof o == "function")) return o;
if (o !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
return (function(a) {
if (a === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return a;
})(r);
})(e, we() ? Reflect.construct(n, t || [], Y(e).constructor) : n.apply(e, t));
}
function ze(e, n) {
if (!(e instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function He(e, n, t) {
return Object.defineProperty(e, "prototype", { writable: !1 }), e;
}
function Oe(e, n) {
var t = typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
if (!t) {
if (Array.isArray(e) || (t = (function(i, u) {
if (i) {
if (typeof i == "string") return de(i, u);
var s = {}.toString.call(i).slice(8, -1);
return s === "Object" && i.constructor && (s = i.constructor.name), s === "Map" || s === "Set" ? Array.from(i) : s === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s) ? de(i, u) : void 0;
}
})(e)) || n) {
t && (e = t);
var r = 0, o = function() {
};
return {
s: o,
n: function() {
return r >= e.length ? { done: !0 } : {
done: !1,
value: e[r++]
};
},
e: function(i) {
throw i;
},
f: o
};
}
throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var a, l = !0, c = !1;
return {
s: function() {
t = t.call(e);
},
n: function() {
var i = t.next();
return l = i.done, i;
},
e: function(i) {
c = !0, a = i;
},
f: function() {
try {
l || t.return == null || t.return();
} finally {
if (c) throw a;
}
}
};
}
function Se(e, n, t) {
return (n = (function(r) {
var o = (function(a, l) {
if (typeof a != "object" || !a) return a;
var c = a[Symbol.toPrimitive];
if (c !== void 0) {
var i = c.call(a, l || "default");
if (typeof i != "object") return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (l === "string" ? String : Number)(a);
})(r, "string");
return typeof o == "symbol" ? o : o + "";
})(n)) in e ? Object.defineProperty(e, n, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[n] = t, e;
}
function Y(e) {
return Y = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) {
return n.__proto__ || Object.getPrototypeOf(n);
}, Y(e);
}
function We(e, n) {
if (typeof n != "function" && n !== null) throw new TypeError("Super expression must either be null or a function");
e.prototype = Object.create(n && n.prototype, { constructor: {
value: e,
writable: !0,
configurable: !0
} }), Object.defineProperty(e, "prototype", { writable: !1 }), n && re(e, n);
}
function we() {
try {
var e = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {
})));
} catch {
}
return (we = function() {
return !!e;
})();
}
function fe(e, n) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var r = Object.getOwnPropertySymbols(e);
n && (r = r.filter((function(o) {
return Object.getOwnPropertyDescriptor(e, o).enumerable;
}))), t.push.apply(t, r);
}
return t;
}
function J(e) {
for (var n = 1; n < arguments.length; n++) {
var t = arguments[n] != null ? arguments[n] : {};
n % 2 ? fe(Object(t), !0).forEach((function(r) {
Se(e, r, t[r]);
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : fe(Object(t)).forEach((function(r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
}));
}
return e;
}
function Ze(e, n) {
if (e == null) return {};
var t, r, o = (function(l, c) {
if (l == null) return {};
var i = {};
for (var u in l) if ({}.hasOwnProperty.call(l, u)) {
if (c.includes(u)) continue;
i[u] = l[u];
}
return i;
})(e, n);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(e);
for (r = 0; r < a.length; r++) t = a[r], n.includes(t) || {}.propertyIsEnumerable.call(e, t) && (o[t] = e[t]);
}
return o;
}
function re(e, n) {
return re = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, r) {
return t.__proto__ = r, t;
}, re(e, n);
}
function U(e, n) {
var t, r = n.replacementChars, o = n.replacement, a = n.separate, l = r, c = "", i = Oe(e);
try {
for (i.s(); !(t = i.n()).done; ) {
var u, s = t.value, d = !Object.prototype.hasOwnProperty.call(o, s) && ((u = o[l[0]]) === null || u === void 0 ? void 0 : u.test(s));
(a && s === l[0] || d) && (l = l.slice(1), c += s);
}
} catch (S) {
i.e(S);
} finally {
i.f();
}
return c;
}
function ke(e, n) {
var t, r = n.mask, o = n.replacement, a = n.separate, l = n.showMask, c = 0, i = "", u = Oe(r);
try {
for (u.s(); !(t = u.n()).done; ) {
var s = t.value;
if (!l && e[c] === void 0) break;
Object.prototype.hasOwnProperty.call(o, s) && e[c] !== void 0 ? i += e[c++] : i += s;
}
} catch (S) {
u.e(S);
} finally {
u.f();
}
if (a && !l) {
for (var d = r.length - 1; d >= 0 && i[d] === r[d]; d--) ;
i = i.slice(0, d + 1);
}
return i;
}
function Me(e, n) {
for (var t = n.mask, r = n.replacement, o = [], a = 0; a < t.length; a++) {
var l, c = (l = e[a]) !== null && l !== void 0 ? l : t[a], i = Object.prototype.hasOwnProperty.call(r, c) ? "replacement" : e[a] !== void 0 && e[a] !== t[a] ? "input" : "mask";
o.push({
type: i,
value: c,
index: a
});
}
return o;
}
function K(e) {
return e.length > 0 ? Se({}, e, /./) : {};
}
function ae(e, n) {
for (var t = n.start, r = t === void 0 ? 0 : t, o = n.end, a = n.mask, l = n.replacement, c = n.separate, i = e.slice(r, o), u = a.slice(r, o), s = "", d = 0; d < u.length; d++) {
var S = Object.prototype.hasOwnProperty.call(l, u[d]);
S && i[d] !== void 0 && i[d] !== u[d] ? s += i[d] : S && c && (s += u[d]);
}
return s;
}
function Pe(e, n) {
var t = n.mask, r = n.replacement, o = typeof r == "string" ? K(r) : r, a = RegExp("[^".concat(Object.keys(o).join(""), "]"), "g");
return ke(U(e, {
replacementChars: t.replace(a, ""),
replacement: o,
separate: !1
}), {
mask: t,
replacement: o,
separate: !1,
showMask: !1
});
}
function Je(e, n) {
var t = n.mask, r = n.replacement, o = typeof r == "string" ? K(r) : r, a = ae(e, {
mask: t,
replacement: o,
separate: !1
}), l = RegExp("[^".concat(Object.keys(o).join(""), "]"), "g");
return U(a, {
replacementChars: t.replace(l, ""),
replacement: o,
separate: !1
});
}
function Ye(e, n) {
var t = n.mask, r = n.replacement, o = typeof r == "string" ? K(r) : r;
return Me(Pe(e, {
mask: t,
replacement: o
}), {
mask: t,
replacement: o
});
}
var Qe = [
"[",
"]",
"\\",
"/",
"^",
"$",
".",
"|",
"?",
"*",
"+",
"(",
")",
"{",
"}"
];
function me(e) {
return Qe.includes(e) ? "\\".concat(e) : e;
}
function qe(e, n) {
for (var t = n.mask, r = n.replacement, o = typeof r == "string" ? K(r) : r, a = e === "partial" || e === "partial-inexact", l = e === "full" || e === "partial", c = "", i = 0; i < t.length; i++) {
var u = t[i];
i === 0 && (c = "^"), a && (c += "("), c += Object.prototype.hasOwnProperty.call(o, u) ? "".concat(l ? "(?!".concat(me(u), ")") : "", "(").concat(o[u].source, ")") : me(u), i === t.length - 1 && (a && (c += ")?".repeat(t.length)), c += "$");
}
return c;
}
function Xe(e, n) {
return new Proxy(e, { set: function(t, r, o) {
return r === "current" && (o !== e.current && (e.current !== null && n.unregister(e.current), o !== null && n.register(o)), t[r] = o, !0);
} });
}
function en(e, n, t) {
return n = $(n), (function(r, o) {
if (o && (typeof o == "object" || typeof o == "function")) return o;
if (o !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
return (function(a) {
if (a === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return a;
})(r);
})(e, ie() ? Reflect.construct(n, t || [], $(e).constructor) : n.apply(e, t));
}
function Ee(e, n) {
if (!(e instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function Ce(e, n, t) {
return Object.defineProperty(e, "prototype", { writable: !1 }), e;
}
function nn(e, n, t) {
return (n = (function(r) {
var o = (function(a, l) {
if (typeof a != "object" || !a) return a;
var c = a[Symbol.toPrimitive];
if (c !== void 0) {
var i = c.call(a, l || "default");
if (typeof i != "object") return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (l === "string" ? String : Number)(a);
})(r, "string");
return typeof o == "symbol" ? o : o + "";
})(n)) in e ? Object.defineProperty(e, n, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[n] = t, e;
}
function $(e) {
return $ = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) {
return n.__proto__ || Object.getPrototypeOf(n);
}, $(e);
}
function tn(e, n) {
if (typeof n != "function" && n !== null) throw new TypeError("Super expression must either be null or a function");
e.prototype = Object.create(n && n.prototype, { constructor: {
value: e,
writable: !0,
configurable: !0
} }), Object.defineProperty(e, "prototype", { writable: !1 }), n && z(e, n);
}
function ie() {
try {
var e = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {
})));
} catch {
}
return (ie = function() {
return !!e;
})();
}
function ve(e, n) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var r = Object.getOwnPropertySymbols(e);
n && (r = r.filter((function(o) {
return Object.getOwnPropertyDescriptor(e, o).enumerable;
}))), t.push.apply(t, r);
}
return t;
}
function he(e) {
for (var n = 1; n < arguments.length; n++) {
var t = arguments[n] != null ? arguments[n] : {};
n % 2 ? ve(Object(t), !0).forEach((function(r) {
nn(e, r, t[r]);
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ve(Object(t)).forEach((function(r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
}));
}
return e;
}
function rn(e, n) {
if (e == null) return {};
var t, r, o = (function(l, c) {
if (l == null) return {};
var i = {};
for (var u in l) if ({}.hasOwnProperty.call(l, u)) {
if (c.includes(u)) continue;
i[u] = l[u];
}
return i;
})(e, n);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(e);
for (r = 0; r < a.length; r++) t = a[r], n.includes(t) || {}.propertyIsEnumerable.call(e, t) && (o[t] = e[t]);
}
return o;
}
function z(e, n) {
return z = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, r) {
return t.__proto__ = r, t;
}, z(e, n);
}
function oe(e) {
var n = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
return oe = function(t) {
if (t === null || !(function(o) {
try {
return Function.toString.call(o).indexOf("[native code]") !== -1;
} catch {
return typeof o == "function";
}
})(t)) return t;
if (typeof t != "function") throw new TypeError("Super expression must either be null or a function");
if (n !== void 0) {
if (n.has(t)) return n.get(t);
n.set(t, r);
}
function r() {
return (function(o, a, l) {
if (ie()) return Reflect.construct.apply(null, arguments);
var c = [null];
c.push.apply(c, a);
var i = new (o.bind.apply(o, c))();
return l && z(i, l.prototype), i;
})(t, arguments, $(this).constructor);
}
return r.prototype = Object.create(t.prototype, { constructor: {
value: r,
enumerable: !1,
writable: !0,
configurable: !0
} }), z(r, t);
}, oe(e);
}
var _ = (function(e) {
function n(t) {
var r;
return Ee(this, n), (r = en(this, n, [t])).name = "SyntheticChangeError", r;
}
return tn(n, e), Ce(n);
})(oe(Error)), ye, an = ["options"], ge = [
"text",
"email",
"tel",
"search",
"url"
], je = Ce((function e(n) {
var t = n.init, r = n.tracking;
Ee(this, e);
var o = /* @__PURE__ */ new WeakMap();
this.register = function(a) {
var l;
if (ge.includes(a.type)) {
var c = (l = a._wrapperState) !== null && l !== void 0 ? l : {}, i = c.initialValue, u = i === void 0 ? "" : i, s = c.controlled, d = s !== void 0 && s, S = t({
initialValue: a.value || u,
controlled: d
}), P = S.value, C = S.options, y = {
value: P,
options: C,
fallbackOptions: C
}, m = {
id: -1,
cachedId: -1
}, p = {
value: "",
selectionStart: 0,
selectionEnd: 0
}, w = Object.getOwnPropertyDescriptor("_valueTracker" in a ? a : HTMLInputElement.prototype, "value");
Object.defineProperty(a, "value", he(he({}, w), {}, { set: function(h) {
var f;
p.value = h, w == null || (f = w.set) === null || f === void 0 || f.call(a, h);
} })), a.value = P;
var g = function() {
var h = function() {
var f, k;
p.selectionStart = (f = a.selectionStart) !== null && f !== void 0 ? f : 0, p.selectionEnd = (k = a.selectionEnd) !== null && k !== void 0 ? k : 0, m.id = window.setTimeout(h);
};
m.id = window.setTimeout(h);
}, E = function() {
window.clearTimeout(m.id), m.id = -1, m.cachedId = -1;
}, v = function(h) {
try {
var f, k;
if (m.cachedId === m.id) throw new _("The input selection has not been updated.");
m.cachedId = m.id;
var M = a.value, b = a.selectionStart, N = a.selectionEnd;
if (b === null || N === null) throw new _("The selection attributes have not been initialized.");
var O, j = p.value;
if (h.inputType === void 0 && (p.selectionStart = 0, p.selectionEnd = j.length), b > p.selectionStart ? O = "insert" : b <= p.selectionStart && b < p.selectionEnd ? O = "deleteBackward" : b === p.selectionEnd && M.length < j.length && (O = "deleteForward"), O === void 0 || (O === "deleteBackward" || O === "deleteForward") && M.length > j.length) throw new _("Input type detection error.");
var T = "", I = p.selectionStart, R = p.selectionEnd;
if (O === "insert") T = M.slice(p.selectionStart, b);
else {
var D = j.length - M.length;
I = b, R = b + D;
}
y.value !== j ? y.options = y.fallbackOptions : y.fallbackOptions = y.options;
var F = y.options, G = r({
inputType: O,
previousValue: j,
previousOptions: F,
value: M,
addedValue: T,
changeStart: I,
changeEnd: R,
selectionStart: b,
selectionEnd: N
}), H = G.options, A = rn(G, an);
a.value = A.value, a.setSelectionRange(A.selectionStart, A.selectionEnd), y.value = A.value, y.options = H, p.selectionStart = A.selectionStart, p.selectionEnd = A.selectionEnd, (f = a._valueTracker) === null || f === void 0 || (k = f.setValue) === null || k === void 0 || k.call(f, j);
} catch (W) {
if (a.value = p.value, a.setSelectionRange(p.selectionStart, p.selectionEnd), h.preventDefault(), h.stopPropagation(), W.name !== "SyntheticChangeError") throw W;
}
};
document.activeElement === a && g(), a.addEventListener("focus", g), a.addEventListener("blur", E), a.addEventListener("input", v), o.set(a, {
onFocus: g,
onBlur: E,
onInput: v
});
} else process.env.NODE_ENV !== "production" && console.warn("Warn: The input element type does not match one of the types: ".concat(ge.join(", "), "."));
}, this.unregister = function(a) {
var l = o.get(a);
l !== void 0 && (a.removeEventListener("focus", l.onFocus), a.removeEventListener("blur", l.onBlur), a.removeEventListener("input", l.onInput), o.delete(a));
};
}));
ye = je, Object.defineProperty(ye.prototype, Symbol.toStringTag, {
writable: !1,
enumerable: !1,
configurable: !0,
value: "Input"
});
var ne = function(e) {
return function() {
for (var n = arguments.length, t = new Array(n), r = 0; r < n; r++) t[r] = arguments[r];
return new e("".concat(t.join(`
`), `
`));
};
}, be, on = ["track", "modify"];
function x(e) {
var n, t, r, o;
return {
mask: (n = e.mask) !== null && n !== void 0 ? n : "",
replacement: typeof e.replacement == "string" ? K(e.replacement) : (t = e.replacement) !== null && t !== void 0 ? t : {},
showMask: (r = e.showMask) !== null && r !== void 0 && r,
separate: (o = e.separate) !== null && o !== void 0 && o,
track: e.track,
modify: e.modify
};
}
var Te = (function(e) {
function n() {
var t, r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
return ze(this, n), (t = $e(this, n, [{
init: function(o) {
var a = o.initialValue, l = o.controlled, c = x(r), i = c.mask, u = c.replacement, s = c.separate, d = c.showMask;
return a = l || a ? a : d ? i : "", process.env.NODE_ENV !== "production" && (function(S) {
var P = S.initialValue, C = S.mask, y = S.replacement;
P.length > C.length && console.error(ne(Error)("The initialized value of the `value` or `defaultValue` property is longer than the value specified in the `mask` property. Check the correctness of the initialized value in the specified property.", 'Invalid value: "'.concat(P, '".'), "To initialize an unmasked value, use the `format` utility. More details https://github.com/GoncharukOrg/react-input/tree/main/packages/mask#initializing-the-value."));
var m = Object.keys(y).filter((function(v) {
return v.length > 1;
}));
m.length > 0 && console.error(ne(Error)("Object keys in the `replacement` property are longer than one character. Replacement keys must be one character long. Check the correctness of the value in the specified property.", "Invalid keys: ".concat(m.join(", "), "."), "To initialize an unmasked value, use the `format` utility. More details https://github.com/GoncharukOrg/react-input/tree/main/packages/mask#initializing-the-value."));
for (var p = C.slice(0, P.length), w = -1, g = 0; g < p.length; g++) {
var E = Object.prototype.hasOwnProperty.call(y, p[g]);
if (!(p[g] === P[g] || E && y[p[g]].test(P[g]))) {
w = g;
break;
}
}
w !== -1 && console.error(ne(Error)("An invalid character was found in the initialized property value `value` or `defaultValue` (index: ".concat(w, "). Check the correctness of the initialized value in the specified property."), 'Invalid value: "'.concat(P, '".'), "To initialize an unmasked value, use the `format` utility. More details https://github.com/GoncharukOrg/react-input/tree/main/packages/mask#initializing-the-value."));
})({
initialValue: a,
mask: i,
replacement: u
}), {
value: a,
options: {
mask: i,
replacement: u,
separate: s
}
};
},
tracking: function(o) {
var a = o.inputType, l = o.previousValue, c = o.previousOptions, i = o.addedValue, u = o.changeStart, s = o.changeEnd, d = x(r), S = d.track, P = d.modify, C = Ze(d, on), y = C.mask, m = C.replacement, p = C.showMask, w = C.separate, g = J(J({}, a === "insert" ? {
inputType: a,
data: i
} : {
inputType: a,
data: null
}), {}, {
value: l,
selectionStart: u,
selectionEnd: s
}), E = S?.(g);
if (E === !1) throw new _("Custom tracking stop.");
E === null ? i = "" : E !== !0 && E !== void 0 && (i = E);
var v = P?.(g);
v?.mask !== void 0 && (y = v.mask), v?.replacement !== void 0 && (m = typeof v?.replacement == "string" ? K(v?.replacement) : v.replacement), v?.showMask !== void 0 && (p = v.showMask), v?.separate !== void 0 && (w = v.separate);
var h = ae(l, J({ end: u }, c)), f = ae(l, J({ start: s }, c)), k = RegExp("[^".concat(Object.keys(m).join(""), "]"), "g"), M = y.replace(k, "");
if (h && (h = U(h, {
replacementChars: M,
replacement: m,
separate: w
}), M = M.slice(h.length)), i && (i = U(i, {
replacementChars: M,
replacement: m,
separate: !1
}), M = M.slice(i.length)), a === "insert" && i === "") throw new _("The character does not match the key value of the `replacement` object.");
if (w) {
var b = y.slice(u, s).replace(k, ""), N = b.length - i.length;
N < 0 ? f = f.slice(-N) : N > 0 && (f = b.slice(-N) + f);
}
f && (f = U(f, {
replacementChars: M,
replacement: m,
separate: w
}));
var O = ke(h + i + f, {
mask: y,
replacement: m,
separate: w,
showMask: p
}), j = (function(T) {
var I, R, D, F = T.inputType, G = T.value, H = T.addedValue, A = T.beforeChangeValue, W = T.mask, le = T.replacement, Ie = T.separate, Q = Me(G, {
mask: W,
replacement: le
}).filter((function(q) {
var se = q.type;
return se === "input" || Ie && se === "replacement";
})), ce = (I = Q[A.length + H.length - 1]) === null || I === void 0 ? void 0 : I.index, L = (R = Q[A.length - 1]) === null || R === void 0 ? void 0 : R.index, V = (D = Q[A.length + H.length]) === null || D === void 0 ? void 0 : D.index;
if (F === "insert") {
if (ce !== void 0) return ce + 1;
if (V !== void 0) return V;
if (L !== void 0) return L + 1;
}
if (F === "deleteForward") {
if (V !== void 0) return V;
if (L !== void 0) return L + 1;
}
if (F === "deleteBackward") {
if (L !== void 0) return L + 1;
if (V !== void 0) return V;
}
var ue = G.split("").findIndex((function(q) {
return Object.prototype.hasOwnProperty.call(le, q);
}));
return ue !== -1 ? ue : G.length;
})({
inputType: a,
value: O,
addedValue: i,
beforeChangeValue: h,
mask: y,
replacement: m,
separate: w
});
return {
value: O,
selectionStart: j,
selectionEnd: j,
options: {
mask: y,
replacement: m,
separate: w
}
};
}
}])).format = function(o) {
return Pe(o, x(r));
}, t.formatToParts = function(o) {
return Ye(o, x(r));
}, t.unformat = function(o) {
return Je(o, x(r));
}, t.generatePattern = function(o) {
return qe(o, x(r));
}, t;
}
return We(n, je), He(n);
})();
be = Te, Object.defineProperty(be.prototype, Symbol.toStringTag, {
writable: !1,
enumerable: !1,
configurable: !0,
value: "Mask"
});
function ln() {
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = e.mask, t = e.replacement, r = e.showMask, o = e.separate, a = e.track, l = e.modify, c = te(null), i = te({
mask: n,
replacement: t,
showMask: r,
separate: o,
track: a,
modify: l
});
return i.current.mask = n, i.current.replacement = t, i.current.showMask = r, i.current.separate = o, i.current.track = a, i.current.modify = l, _e((function() {
return Xe(c, new Te(i.current));
}), []);
}
var cn = /* @__PURE__ */ Ae(Ne(), 1);
var un = {
AF: "Afghanistan",
AL: "Albania",
DZ: "Algeria",
AS: "American Samoa",
AD: "Andorra",
AO: "Angola",
AI: "Anguilla",
AQ: "Antarctica",
AG: "Antigua and Barbuda",
AR: "Argentina",
AM: "Armenia",
AW: "Aruba",
AU: "Australia",
AT: "Austria",
AZ: "Azerbaijan",
BS: "Bahamas",
BH: "Bahrain",
BD: "Bangladesh",
BB: "Barbados",
BY: "Belarus",
BE: "Belgium",
BZ: "Belize",
BJ: "Benin",
BM: "Bermuda",
BT: "Bhutan",
BO: "Bolivia",
BA: "Bosnia and Herzegovina",
BW: "Botswana",
BV: "Bouvet Island",
BR: "Brazil",
IO: "British Indian Ocean Territory",
BN: "Brunei Darussalam",
BG: "Bulgaria",
BF: "Burkina Faso",
BI: "Burundi",
KH: "Cambodia",
CM: "Cameroon",
CA: "Canada",
CV: "Cape Verde",
KY: "Cayman Islands",
CF: "Central African Republic",
TD: "Chad",
CL: "Chile",
CN: ["People's Republic of China", "China"],
CX: "Christmas Island",
CC: "Cocos (Keeling) Islands",
CO: "Colombia",
KM: "Comoros",
CG: ["Republic of the Congo", "Congo"],
CD: ["Democratic Republic of the Congo", "Congo"],
CK: "Cook Islands",
CR: "Costa Rica",
CI: [
"Cote d'Ivoire",
"Côte d'Ivoire",
"Ivory Coast"
],
HR: "Croatia",
CU: "Cuba",
CY: "Cyprus",
CZ: ["Czech Republic", "Czechia"],
DK: "Denmark",
DJ: "Djibouti",
DM: "Dominica",
DO: "Dominican Republic",
EC: "Ecuador",
EG: "Egypt",
SV: "El Salvador",
GQ: "Equatorial Guinea",
ER: "Eritrea",
EE: "Estonia",
ET: "Ethiopia",
FK: "Falkland Islands (Malvinas)",
FO: "Faroe Islands",
FJ: "Fiji",
FI: "Finland",
FR: "France",
GF: "French Guiana",
PF: "French Polynesia",
TF: "French Southern Territories",
GA: "Gabon",
GM: [
"Republic of The Gambia",
"The Gambia",
"Gambia"
],
GE: "Georgia",
DE: "Germany",
GH: "Ghana",
GI: "Gibraltar",
GR: "Greece",
GL: "Greenland",
GD: "Grenada",
GP: "Guadeloupe",
GU: "Guam",
GT: "Guatemala",
GN: "Guinea",
GW: "Guinea-Bissau",
GY: "Guyana",
HT: "Haiti",
HM: "Heard Island and McDonald Islands",
VA: "Holy See (Vatican City State)",
HN: "Honduras",
HK: "Hong Kong",
HU: "Hungary",
IS: "Iceland",
IN: "India",
ID: "Indonesia",
IR: ["Islamic Republic of Iran", "Iran"],
IQ: "Iraq",
IE: "Ireland",
IL: "Israel",
IT: "Italy",
JM: "Jamaica",
JP: "Japan",
JO: "Jordan",
KZ: "Kazakhstan",
KE: "Kenya",
KI: "Kiribati",
KP: "North Korea",
KR: [
"South Korea",
"Korea, Republic of",
"Republic of Korea"
],
KW: "Kuwait",
KG: "Kyrgyzstan",
LA: "Lao People's Democratic Republic",
LV: "Latvia",
LB: "Lebanon",
LS: "Lesotho",
LR: "Liberia",
LY: "Libya",
LI: "Liechtenstein",
LT: "Lithuania",
LU: "Luxembourg",
MO: "Macao",
MG: "Madagascar",
MW: "Malawi",
MY: "Malaysia",
MV: "Maldives",
ML: "Mali",
MT: "Malta",
MH: "Marshall Islands",
MQ: "Martinique",
MR: "Mauritania",
MU: "Mauritius",
YT: "Mayotte",
MX: "Mexico",
FM: "Micronesia, Federated States of",
MD: "Moldova, Republic of",
MC: "Monaco",
MN: "Mongolia",
MS: "Montserrat",
MA: "Morocco",
MZ: "Mozambique",
MM: "Myanmar",
NA: "Namibia",
NR: "Nauru",
NP: "Nepal",
NL: [
"Netherlands",
"The Netherlands",
"Netherlands (Kingdom of the)"
],
NC: "New Caledonia",
NZ: "New Zealand",
NI: "Nicaragua",
NE: "Niger",
NG: "Nigeria",
NU: "Niue",
NF: "Norfolk Island",
MK: ["The Republic of North Macedonia", "North Macedonia"],
MP: "Northern Mariana Islands",
NO: "Norway",
OM: "Oman",
PK: "Pakistan",
PW: "Palau",
PS: ["State of Palestine", "Palestine"],
PA: "Panama",
PG: "Papua New Guinea",
PY: "Paraguay",
PE: "Peru",
PH: "Philippines",
PN: ["Pitcairn", "Pitcairn Islands"],
PL: "Poland",
PT: "Portugal",
PR: "Puerto Rico",
QA: "Qatar",
RE: "Reunion",
RO: "Romania",
RU: ["Russian Federation", "Russia"],
RW: "Rwanda",
SH: "Saint Helena",
KN: "Saint Kitts and Nevis",
LC: "Saint Lucia",
PM: "Saint Pierre and Miquelon",
VC: "Saint Vincent and the Grenadines",
WS: "Samoa",
SM: "San Marino",
ST: "Sao Tome and Principe",
SA: "Saudi Arabia",
SN: "Senegal",
SC: "Seychelles",
SL: "Sierra Leone",
SG: "Singapore",
SK: "Slovakia",
SI: "Slovenia",
SB: "Solomon Islands",
SO: "Somalia",
ZA: "South Africa",
GS: "South Georgia and the South Sandwich Islands",
ES: "Spain",
LK: "Sri Lanka",
SD: "Sudan",
SR: "Suriname",
SJ: "Svalbard and Jan Mayen",
SZ: "Eswatini",
SE: "Sweden",
CH: "Switzerland",
SY: "Syrian Arab Republic",
TW: ["Taiwan, Province of China", "Taiwan"],
TJ: "Tajikistan",
TZ: ["United Republic of Tanzania", "Tanzania"],
TH: "Thailand",
TL: "Timor-Leste",
TG: "Togo",
TK: "Tokelau",
TO: "Tonga",
TT: "Trinidad and Tobago",
TN: "Tunisia",
TR: ["Türkiye", "Turkey"],
TM: "Turkmenistan",
TC: "Turks and Caicos Islands",
TV: "Tuvalu",
UG: "Uganda",
UA: "Ukraine",
AE: ["United Arab Emirates", "UAE"],
GB: [
"United Kingdom",
"UK",
"Great Britain"
],
US: [
"United States of America",
"United States",
"USA",
"U.S.A.",
"US",
"U.S."
],
UM: "United States Minor Outlying Islands",
UY: "Uruguay",
UZ: "Uzbekistan",
VU: "Vanuatu",
VE: "Venezuela",
VN: "Vietnam",
VG: "Virgin Islands, British",
VI: "Virgin Islands, U.S.",
WF: "Wallis and Futuna",
EH: "Western Sahara",
YE: "Yemen",
ZM: "Zambia",
ZW: "Zimbabwe",
AX: ["Åland Islands", "Aland Islands"],
BQ: "Bonaire, Sint Eustatius and Saba",
CW: "Curaçao",
GG: "Guernsey",
IM: "Isle of Man",
JE: "Jersey",
ME: "Montenegro",
BL: "Saint Barthélemy",
MF: "Saint Martin (French part)",
RS: "Serbia",
SX: "Sint Maarten (Dutch part)",
SS: "South Sudan",
XK: "Kosovo"
}, sn = {
locale: "en",
countries: un
};
cn.registerLocale(sn);
var wn = Ke(({ disabled: e = !1, error: n, helperText: t, helperTextClassName: r, isRequired: o, label: a, labelClassName: l, labelWrapperClassName: c, name: i, placeholder: u, showFlagOnSearch: s = !0, showInputFilter: d = !0, showNameOnSearch: S = !0, wrapperClassName: P, showPlaceHolder: C, ...y }, m) => {
const p = Fe(), w = i ?? p, g = te(null), { isOpenSelector: E, value: v, selectedCountry: h, onChangeValue: f, handleOpenSelector: k } = Be(), M = typeof n == "string" && n.length >= 0, b = ln({
mask: Le(h),
replacement: { _: /\d/ }
});
Ue(m, () => b.current, [b]);
const N = De((O) => {
O.target.value.startsWith(h.prefix) ? f(O.target.value) : f(`${h.prefix} `);
}, [h.prefix, f]);
return pe(() => {
const O = new AbortController(), j = (I) => {
I.key === "Escape" && k(!1);
}, T = (I) => {
g.current?.contains(I.target) || k(!1);
};
return document.addEventListener("keydown", j, { signal: O.signal }), document.addEventListener("mousedown", T, { signal: O.signal }), document.addEventListener("visibilitychange", () => {
document.hidden && k(!1);
}, { signal: O.signal }), () => {
O.abort();
};
}, [k, g]), pe(() => {
b.current && (b.current.value = h.prefix + " ");
}, [h.code]), /* @__PURE__ */ Z("div", {
className: "w-full flex flex-col gap-2",
children: [
a ? /* @__PURE__ */ B("div", {
className: X(c),
children: /* @__PURE__ */ Z("label", {
id: w,
className: Re({ className: l }),
onClick: () => !e && b.current?.focus(),
children: [a, o && /* @__PURE__ */ B(ee, {
component: "span",
className: "text-red-600 dark:text-red-500 ml-1",
children: "*"
})]
})
}) : null,
/* @__PURE__ */ Z("div", {
ref: g,
"data-state": E ? "open" : "closed",
className: Ge({
className: P,
variant: M ? "error" : "default"
}),
children: [/* @__PURE__ */ Z("div", {
className: "p-2 flex items-center gap-2.5",
children: [/* @__PURE__ */ B(Ve, {}), /* @__PURE__ */ B("input", {
id: a ? w : void 0,
ref: b,
name: i,
autoComplete: "off",
className: X("outline-0", "w-full", "caret-slate-800", "text-slate-800", "bg-transparent", "dark:caret-metal-50", "dark:text-metal-50", "disabled:cursor-not-allowed", "disabled:opacity-50"),
type: "tel",
inputMode: "tel",
value: v,
onChange: N,
disabled: e,
...y
})]
}), E && /* @__PURE__ */ B(xe, {
placeholder: u,
showFlagOnSearch: s,
showInputFilter: d,
showNameOnSearch: S,
showPlaceHolder: C
})]
}),
n ? /* @__PURE__ */ B(ee, {
component: "span",
className: "text-xs text-red-700 dark:text-red-500",
children: n
}) : null,
!n && t ? /* @__PURE__ */ B(ee, {
component: "span",
className: X("text-xs kubefirst-dark:text-slate-200", r),
children: t
}) : null
]
});
});
export {
wn as t
};