@arkyn/shared 3.0.1-beta.71 → 3.0.1-beta.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +313 -264
- package/dist/bundle.umd.cjs +6 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/validations/validateEmail.d.ts +22 -0
- package/dist/validations/validateEmail.d.ts.map +1 -0
- package/dist/validations/validateEmail.js +121 -0
- package/package.json +2 -1
package/dist/bundle.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
1
|
+
function L(n, s) {
|
|
2
|
+
const a = (e) => e.toString().padStart(2, "0"), _ = {
|
|
3
3
|
YYYY: n.getFullYear().toString(),
|
|
4
4
|
YY: n.getFullYear().toString().slice(-2),
|
|
5
|
-
MM:
|
|
6
|
-
DD:
|
|
7
|
-
hh:
|
|
8
|
-
mm:
|
|
9
|
-
ss:
|
|
5
|
+
MM: a(n.getMonth() + 1),
|
|
6
|
+
DD: a(n.getDate()),
|
|
7
|
+
hh: a(n.getHours()),
|
|
8
|
+
mm: a(n.getMinutes()),
|
|
9
|
+
ss: a(n.getSeconds())
|
|
10
10
|
};
|
|
11
|
-
return
|
|
11
|
+
return s.replace(
|
|
12
12
|
/YYYY|YY|MM|DD|hh|mm|ss/g,
|
|
13
|
-
(
|
|
13
|
+
(e) => _[e]
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
const t = n.split(/[-/]/).map(Number), c =
|
|
16
|
+
const dn = ([n, s = "00:00:00"], a, _, e = 0) => {
|
|
17
|
+
const t = n.split(/[-/]/).map(Number), c = s.split(".")[0].split(":").map(Number);
|
|
18
18
|
let r, o, i;
|
|
19
|
-
const [m = 0, d = 0,
|
|
20
|
-
switch (
|
|
19
|
+
const [m = 0, d = 0, k = 0] = c;
|
|
20
|
+
switch (a) {
|
|
21
21
|
case "brazilianDate":
|
|
22
22
|
[r, o, i] = t;
|
|
23
23
|
break;
|
|
@@ -30,71 +30,71 @@ const sn = ([n, _ = "00:00:00"], s, e, a = 0) => {
|
|
|
30
30
|
default:
|
|
31
31
|
throw new Error("Invalid input format");
|
|
32
32
|
}
|
|
33
|
-
const u = new Date(i, o - 1, r, m, d,
|
|
33
|
+
const u = new Date(i, o - 1, r, m, d, k);
|
|
34
34
|
if (isNaN(u.getTime())) throw new Error("Invalid date");
|
|
35
|
-
return u.setUTCHours(u.getUTCHours() +
|
|
36
|
-
}, h = (n,
|
|
37
|
-
const
|
|
38
|
-
let
|
|
35
|
+
return u.setUTCHours(u.getUTCHours() + e), L(u, _);
|
|
36
|
+
}, h = (n, s) => {
|
|
37
|
+
const a = " ".repeat(s);
|
|
38
|
+
let _ = "";
|
|
39
39
|
if (typeof n == "object" && n !== null)
|
|
40
40
|
if (Array.isArray(n))
|
|
41
|
-
n.length === 0 ?
|
|
42
|
-
`, n.forEach((
|
|
43
|
-
|
|
41
|
+
n.length === 0 ? _ += "[]" : (_ += `[
|
|
42
|
+
`, n.forEach((e, t) => {
|
|
43
|
+
_ += a + " " + h(e, s + 1), t < n.length - 1 && (_ += ","), _ += `
|
|
44
44
|
`;
|
|
45
|
-
}),
|
|
45
|
+
}), _ += a + "]");
|
|
46
46
|
else {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
`,
|
|
50
|
-
|
|
47
|
+
const e = Object.keys(n);
|
|
48
|
+
e.length === 0 ? _ += "{}" : (_ += `{
|
|
49
|
+
`, e.forEach((t, c) => {
|
|
50
|
+
_ += a + ' "' + t + '": ' + h(n[t], s + 1), c < e.length - 1 && (_ += ","), _ += `
|
|
51
51
|
`;
|
|
52
|
-
}),
|
|
52
|
+
}), _ += a + "}");
|
|
53
53
|
}
|
|
54
54
|
else if (typeof n == "string")
|
|
55
55
|
try {
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const e = JSON.parse(n);
|
|
57
|
+
_ += h(e, s);
|
|
58
58
|
} catch {
|
|
59
|
-
|
|
59
|
+
_ += '"' + n + '"';
|
|
60
60
|
}
|
|
61
61
|
else
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
},
|
|
62
|
+
_ += n;
|
|
63
|
+
return _;
|
|
64
|
+
}, kn = (n) => {
|
|
65
65
|
try {
|
|
66
|
-
const
|
|
67
|
-
return h(
|
|
68
|
-
} catch (
|
|
66
|
+
const s = JSON.parse(n);
|
|
67
|
+
return h(s, 0);
|
|
68
|
+
} catch (s) {
|
|
69
69
|
throw new Error(`Invalid JSON string
|
|
70
|
-
${
|
|
70
|
+
${s}`);
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
-
function
|
|
74
|
-
return n.split(" ").map((
|
|
75
|
-
const
|
|
76
|
-
return
|
|
73
|
+
function pn(n) {
|
|
74
|
+
return n.split(" ").map((_) => {
|
|
75
|
+
const e = _.charAt(0).toUpperCase(), t = _.slice(1).toLowerCase();
|
|
76
|
+
return e + t;
|
|
77
77
|
}).join(" ");
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
79
|
+
const f = (n) => n.replace(/[^0-9]/g, ""), hn = (n) => {
|
|
80
|
+
const a = f(n).match(/^(\d{5})(\d{3})$/);
|
|
81
|
+
if (a) return `${a[1]}-${a[2]}`;
|
|
82
82
|
throw new Error("Invalid CEP format");
|
|
83
83
|
}, w = (n) => {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
return `${
|
|
84
|
+
const a = f(n).match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/);
|
|
85
|
+
if (a)
|
|
86
|
+
return `${a[1]}.${a[2]}.${a[3]}/${a[4]}-${a[5]}`;
|
|
87
87
|
throw new Error("Invalid CNPJ length");
|
|
88
88
|
}, G = (n) => {
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
89
|
+
const a = f(n).match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/);
|
|
90
|
+
if (a) return `${a[1]}.${a[2]}.${a[3]}-${a[4]}`;
|
|
91
91
|
throw new Error("Invalid CPF format");
|
|
92
|
-
},
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
return G(
|
|
96
|
-
if (
|
|
97
|
-
return w(
|
|
92
|
+
}, yn = (n) => {
|
|
93
|
+
const s = n.replace(/\D/g, "");
|
|
94
|
+
if (s.length === 11)
|
|
95
|
+
return G(s);
|
|
96
|
+
if (s.length === 14)
|
|
97
|
+
return w(s);
|
|
98
98
|
throw new Error("Invalid CPF or CNPJ length");
|
|
99
99
|
}, C = [
|
|
100
100
|
{
|
|
@@ -2072,131 +2072,131 @@ const k = (n) => n.replace(/[^0-9]/g, ""), on = (n) => {
|
|
|
2072
2072
|
TRY: { countryLanguage: "tr-TR", countryCurrency: "TRY" },
|
|
2073
2073
|
IDR: { countryLanguage: "id-ID", countryCurrency: "IDR" },
|
|
2074
2074
|
THB: { countryLanguage: "th-TH", countryCurrency: "THB" }
|
|
2075
|
-
},
|
|
2076
|
-
if (!v[
|
|
2075
|
+
}, B = (n) => n.replace(new RegExp("(?:R\\$|\\p{Sc}|[$€¥£])", "gu"), "").trim(), Cn = (n, s, a = { showPrefix: !0 }) => {
|
|
2076
|
+
if (!v[s])
|
|
2077
2077
|
throw new Error("Unsupported currency code");
|
|
2078
|
-
const { countryCurrency:
|
|
2078
|
+
const { countryCurrency: _, countryLanguage: e } = v[s], t = new Intl.NumberFormat(e, {
|
|
2079
2079
|
style: "currency",
|
|
2080
|
-
currency:
|
|
2080
|
+
currency: _
|
|
2081
2081
|
}).format(n);
|
|
2082
|
-
return
|
|
2083
|
-
},
|
|
2084
|
-
const
|
|
2082
|
+
return a.showPrefix ? t.replace(/\s/g, " ") : B(t).replace(/\s/g, " ");
|
|
2083
|
+
}, vn = ([n, s = "00:00:00"], a, _ = 0) => {
|
|
2084
|
+
const e = n.split(/[-/]/).map(Number), t = s.split(".")[0].split(":").map(Number);
|
|
2085
2085
|
let c, r, o;
|
|
2086
2086
|
const [i = 0, m = 0, d = 0] = t;
|
|
2087
|
-
switch (
|
|
2087
|
+
switch (a) {
|
|
2088
2088
|
case "brazilianDate":
|
|
2089
|
-
[c, r, o] =
|
|
2089
|
+
[c, r, o] = e;
|
|
2090
2090
|
break;
|
|
2091
2091
|
case "isoDate":
|
|
2092
|
-
[o, r, c] =
|
|
2092
|
+
[o, r, c] = e;
|
|
2093
2093
|
break;
|
|
2094
2094
|
case "timestamp":
|
|
2095
|
-
[o, r, c] =
|
|
2095
|
+
[o, r, c] = e.map(Number);
|
|
2096
2096
|
break;
|
|
2097
2097
|
default:
|
|
2098
2098
|
throw new Error("Invalid input format");
|
|
2099
2099
|
}
|
|
2100
|
-
const
|
|
2101
|
-
Date.UTC(o, r - 1, c, i -
|
|
2100
|
+
const k = new Date(
|
|
2101
|
+
Date.UTC(o, r - 1, c, i - _, m, d)
|
|
2102
2102
|
);
|
|
2103
|
-
if (isNaN(
|
|
2104
|
-
return
|
|
2105
|
-
},
|
|
2106
|
-
if (n.length >
|
|
2107
|
-
let
|
|
2108
|
-
return
|
|
2103
|
+
if (isNaN(k.getTime())) throw new Error("Invalid date");
|
|
2104
|
+
return k;
|
|
2105
|
+
}, xn = (n, s) => {
|
|
2106
|
+
if (n.length > s) {
|
|
2107
|
+
let a = n.substring(0, s).trimEnd();
|
|
2108
|
+
return a = a.replace(/[.,!?;:]$/, ""), `${a}...`;
|
|
2109
2109
|
}
|
|
2110
2110
|
return n;
|
|
2111
|
-
},
|
|
2112
|
-
let
|
|
2113
|
-
const
|
|
2114
|
-
return { digits:
|
|
2115
|
-
},
|
|
2116
|
-
const
|
|
2117
|
-
return
|
|
2111
|
+
}, P = /^\d$/, Y = (n) => {
|
|
2112
|
+
let s = 0;
|
|
2113
|
+
const a = n.split("").map((_) => P.test(_) ? { character: _, kind: "digit", digit: ++s } : { character: _, kind: "other" });
|
|
2114
|
+
return { digits: s, children: a, kind: "root" };
|
|
2115
|
+
}, $ = (n, s) => Array.isArray(n) ? n : n >= 0 ? [0, n] : [s + 1 - Math.abs(n), s], U = (n, s) => s >= n[0] && s <= n[1], Fn = (n, s) => {
|
|
2116
|
+
const a = Y(n), _ = $(s.range ?? 3, a.digits);
|
|
2117
|
+
return a.children.map((e) => e.kind === "digit" && U(_, e.digit) ? s.hider ?? "*" : e.character).join("");
|
|
2118
2118
|
};
|
|
2119
|
-
function
|
|
2119
|
+
function z(n) {
|
|
2120
2120
|
return n.length > 10 ? "NINE" : "EIGTH";
|
|
2121
2121
|
}
|
|
2122
|
-
const
|
|
2122
|
+
const D = {
|
|
2123
2123
|
EIGTH: "(99) 9999-9999",
|
|
2124
2124
|
NINE: "(99) 99999-9999"
|
|
2125
|
-
},
|
|
2126
|
-
function
|
|
2127
|
-
let
|
|
2128
|
-
for (let
|
|
2129
|
-
if (
|
|
2130
|
-
if (
|
|
2131
|
-
|
|
2125
|
+
}, H = f(D.NINE).length;
|
|
2126
|
+
function K(n, s) {
|
|
2127
|
+
let a = "", _ = 0;
|
|
2128
|
+
for (let e = 0; e < s.length; e++)
|
|
2129
|
+
if (s[e] === "9")
|
|
2130
|
+
if (_ < n.length)
|
|
2131
|
+
a += n[_], _++;
|
|
2132
2132
|
else
|
|
2133
2133
|
break;
|
|
2134
|
-
else if (
|
|
2135
|
-
|
|
2134
|
+
else if (_ < n.length)
|
|
2135
|
+
a += s[e];
|
|
2136
2136
|
else
|
|
2137
2137
|
break;
|
|
2138
|
-
return
|
|
2138
|
+
return a;
|
|
2139
2139
|
}
|
|
2140
|
-
function x(n,
|
|
2141
|
-
if (
|
|
2142
|
-
let
|
|
2143
|
-
const t =
|
|
2144
|
-
return
|
|
2140
|
+
function x(n, s) {
|
|
2141
|
+
if (s.code === "+55") {
|
|
2142
|
+
let e = f(n);
|
|
2143
|
+
const t = z(e);
|
|
2144
|
+
return e.length > H || (e = K(e, D[t])), e;
|
|
2145
2145
|
}
|
|
2146
|
-
let
|
|
2147
|
-
if (
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2146
|
+
let _ = s.mask;
|
|
2147
|
+
if (s.prefix) {
|
|
2148
|
+
const e = /\$+/g;
|
|
2149
|
+
_ = _.replace(e, s.prefix);
|
|
2150
2150
|
}
|
|
2151
|
-
for (let
|
|
2152
|
-
e
|
|
2153
|
-
return
|
|
2151
|
+
for (let e = 0, t = 0; e < _.length && t < n.length; e++)
|
|
2152
|
+
_[e] === "_" && (_ = _.substring(0, e) + n[t] + _.substring(e + 1), t++);
|
|
2153
|
+
return _;
|
|
2154
2154
|
}
|
|
2155
|
-
function O(n,
|
|
2156
|
-
const
|
|
2157
|
-
(
|
|
2155
|
+
function O(n, s) {
|
|
2156
|
+
const a = C.find(
|
|
2157
|
+
(_) => _.code === n && _.prefix === s
|
|
2158
2158
|
);
|
|
2159
|
-
if (!
|
|
2160
|
-
if (
|
|
2159
|
+
if (!a) throw new Error("Invalid country code or prefix");
|
|
2160
|
+
if (a.prefix !== s)
|
|
2161
2161
|
throw new Error("Invalid country code or prefix");
|
|
2162
|
-
if (!
|
|
2162
|
+
if (!a.prefix)
|
|
2163
2163
|
throw new Error("Invalid country code or prefix");
|
|
2164
|
-
return
|
|
2164
|
+
return a;
|
|
2165
2165
|
}
|
|
2166
2166
|
function J(n) {
|
|
2167
|
-
const
|
|
2168
|
-
if (!
|
|
2169
|
-
if (
|
|
2170
|
-
return
|
|
2167
|
+
const s = C.find((a) => a.code === n);
|
|
2168
|
+
if (!s) throw new Error("Invalid country code");
|
|
2169
|
+
if (s.prefix) throw new Error("Invalid country code");
|
|
2170
|
+
return s;
|
|
2171
2171
|
}
|
|
2172
|
-
const
|
|
2172
|
+
const Sn = (n) => {
|
|
2173
2173
|
if (!/^\+\d{1,4}(-\d{1,4})? \d+$/.test(n))
|
|
2174
2174
|
throw new Error(
|
|
2175
2175
|
"Invalid phone number format. Expected format: +<countryCode>-<optionalPrefix> <phoneNumber>"
|
|
2176
2176
|
);
|
|
2177
|
-
const
|
|
2178
|
-
if (!
|
|
2177
|
+
const a = n.split(" ")[0].split("-")[0], _ = n.split(" ")[0].split("-")[1], e = n.split(" ")[1];
|
|
2178
|
+
if (!a || !e)
|
|
2179
2179
|
throw new Error("Invalid phone number format");
|
|
2180
|
-
if (
|
|
2181
|
-
const c = O(
|
|
2182
|
-
return x(
|
|
2180
|
+
if (_) {
|
|
2181
|
+
const c = O(a, _);
|
|
2182
|
+
return x(e, c);
|
|
2183
2183
|
}
|
|
2184
|
-
const t = J(
|
|
2185
|
-
return x(
|
|
2186
|
-
},
|
|
2187
|
-
for (var
|
|
2188
|
-
|
|
2189
|
-
var
|
|
2184
|
+
const t = J(a);
|
|
2185
|
+
return x(e, t);
|
|
2186
|
+
}, bn = (n) => {
|
|
2187
|
+
for (var s = 0, a = 0; a < n.length; a++)
|
|
2188
|
+
s = n.charCodeAt(a) + ((s << 5) - s);
|
|
2189
|
+
var _ = (s & 16711680) >> 16, e = (s & 65280) >> 8, t = s & 255, c = _.toString(16).padStart(2, "0"), r = e.toString(16).padStart(2, "0"), o = t.toString(16).padStart(2, "0");
|
|
2190
2190
|
return "#" + c + r + o;
|
|
2191
2191
|
};
|
|
2192
2192
|
var l = [];
|
|
2193
2193
|
for (var y = 0; y < 256; ++y)
|
|
2194
2194
|
l.push((y + 256).toString(16).slice(1));
|
|
2195
|
-
function T(n,
|
|
2196
|
-
return (l[n[
|
|
2195
|
+
function T(n, s = 0) {
|
|
2196
|
+
return (l[n[s + 0]] + l[n[s + 1]] + l[n[s + 2]] + l[n[s + 3]] + "-" + l[n[s + 4]] + l[n[s + 5]] + "-" + l[n[s + 6]] + l[n[s + 7]] + "-" + l[n[s + 8]] + l[n[s + 9]] + "-" + l[n[s + 10]] + l[n[s + 11]] + l[n[s + 12]] + l[n[s + 13]] + l[n[s + 14]] + l[n[s + 15]]).toLowerCase();
|
|
2197
2197
|
}
|
|
2198
2198
|
var p, V = new Uint8Array(16);
|
|
2199
|
-
function
|
|
2199
|
+
function E() {
|
|
2200
2200
|
if (!p && (p = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !p))
|
|
2201
2201
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
2202
2202
|
return p(V);
|
|
@@ -2205,182 +2205,182 @@ var Z = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypt
|
|
|
2205
2205
|
const F = {
|
|
2206
2206
|
randomUUID: Z
|
|
2207
2207
|
};
|
|
2208
|
-
function W(n,
|
|
2208
|
+
function W(n, s, a) {
|
|
2209
2209
|
if (F.randomUUID && !n)
|
|
2210
2210
|
return F.randomUUID();
|
|
2211
2211
|
n = n || {};
|
|
2212
|
-
var
|
|
2213
|
-
return
|
|
2212
|
+
var _ = n.random || (n.rng || E)();
|
|
2213
|
+
return _[6] = _[6] & 15 | 64, _[8] = _[8] & 63 | 128, T(_);
|
|
2214
2214
|
}
|
|
2215
2215
|
var S = null, b = null, g = 0;
|
|
2216
|
-
function q(n,
|
|
2216
|
+
function q(n, s, a) {
|
|
2217
2217
|
n = n || {};
|
|
2218
|
-
var
|
|
2219
|
-
return c > g && n.msecs === void 0 && (g = c, r !== null && (o = null, i = null)), r !== null && (r > 2147483647 && (r = 2147483647), o = r >>> 19 & 4095, i = r & 524287), (o === null || i === null) && (o = t[6] & 127, o = o << 8 | t[7], i = t[8] & 63, i = i << 8 | t[9], i = i << 5 | t[10] >>> 3), c + 1e4 > g && r === null ? ++i > 524287 && (i = 0, ++o > 4095 && (o = 0, g++)) : g = c, b = o, S = i,
|
|
2218
|
+
var _ = 0, e = new Uint8Array(16), t = n.random || (n.rng || E)(), c = n.msecs !== void 0 ? n.msecs : Date.now(), r = n.seq !== void 0 ? n.seq : null, o = b, i = S;
|
|
2219
|
+
return c > g && n.msecs === void 0 && (g = c, r !== null && (o = null, i = null)), r !== null && (r > 2147483647 && (r = 2147483647), o = r >>> 19 & 4095, i = r & 524287), (o === null || i === null) && (o = t[6] & 127, o = o << 8 | t[7], i = t[8] & 63, i = i << 8 | t[9], i = i << 5 | t[10] >>> 3), c + 1e4 > g && r === null ? ++i > 524287 && (i = 0, ++o > 4095 && (o = 0, g++)) : g = c, b = o, S = i, e[_++] = g / 1099511627776 & 255, e[_++] = g / 4294967296 & 255, e[_++] = g / 16777216 & 255, e[_++] = g / 65536 & 255, e[_++] = g / 256 & 255, e[_++] = g & 255, e[_++] = o >>> 4 & 15 | 112, e[_++] = o & 255, e[_++] = i >>> 13 & 63 | 128, e[_++] = i >>> 5 & 255, e[_++] = i << 3 & 255 | t[10] & 7, e[_++] = t[11], e[_++] = t[12], e[_++] = t[13], e[_++] = t[14], e[_++] = t[15], s || T(e);
|
|
2220
2220
|
}
|
|
2221
|
-
function
|
|
2221
|
+
function R(n) {
|
|
2222
2222
|
n = n.replace(/-/g, "");
|
|
2223
|
-
const
|
|
2224
|
-
for (let
|
|
2225
|
-
|
|
2226
|
-
return
|
|
2223
|
+
const s = new Uint8Array(n.length / 2);
|
|
2224
|
+
for (let a = 0; a < n.length; a += 2)
|
|
2225
|
+
s[a / 2] = parseInt(n.substring(a, a + 2), 16);
|
|
2226
|
+
return s;
|
|
2227
2227
|
}
|
|
2228
2228
|
function N() {
|
|
2229
2229
|
const n = W();
|
|
2230
|
-
return { text: n, binary:
|
|
2230
|
+
return { text: n, binary: R(n) };
|
|
2231
2231
|
}
|
|
2232
2232
|
function I() {
|
|
2233
2233
|
const n = q();
|
|
2234
|
-
return { text: n, binary:
|
|
2234
|
+
return { text: n, binary: R(n) };
|
|
2235
2235
|
}
|
|
2236
|
-
function
|
|
2237
|
-
if (n === "text" &&
|
|
2238
|
-
if (n === "binary" &&
|
|
2239
|
-
if (n === "text" &&
|
|
2240
|
-
if (n === "binary" &&
|
|
2236
|
+
function Nn(n, s) {
|
|
2237
|
+
if (n === "text" && s === "v4") return N().text;
|
|
2238
|
+
if (n === "binary" && s === "v4") return N().binary;
|
|
2239
|
+
if (n === "text" && s === "v7") return I().text;
|
|
2240
|
+
if (n === "binary" && s === "v7") return I().binary;
|
|
2241
2241
|
throw new Error("Invalid type or format");
|
|
2242
2242
|
}
|
|
2243
|
-
function
|
|
2244
|
-
let
|
|
2245
|
-
return
|
|
2243
|
+
function In(n) {
|
|
2244
|
+
let s = n.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
2245
|
+
return s = s.replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").toLowerCase(), s = s.replace(/-{2,}/g, "-"), s = s.replace(/^-+|-+$/g, ""), s;
|
|
2246
2246
|
}
|
|
2247
|
-
const
|
|
2248
|
-
const { cashPrice:
|
|
2249
|
-
if (
|
|
2247
|
+
const Mn = (n) => {
|
|
2248
|
+
const { cashPrice: s, numberInstallments: a, fees: _ = 0.0349 } = n;
|
|
2249
|
+
if (_ === 0 || a === 1)
|
|
2250
2250
|
return {
|
|
2251
|
-
totalPrice:
|
|
2252
|
-
installmentPrice:
|
|
2251
|
+
totalPrice: s,
|
|
2252
|
+
installmentPrice: s / a
|
|
2253
2253
|
};
|
|
2254
|
-
if (
|
|
2254
|
+
if (a <= 0)
|
|
2255
2255
|
throw new Error("Number of installments must be greater than 0");
|
|
2256
|
-
if (
|
|
2256
|
+
if (_ < 0)
|
|
2257
2257
|
throw new Error("Fees must be greater than or equal to 0");
|
|
2258
|
-
let
|
|
2259
|
-
return
|
|
2258
|
+
let e = 0, t = 0, c = Math.pow(1 + _, a) * _, r = Math.pow(1 + _, a) - 1;
|
|
2259
|
+
return e = s * (c / r), t = a * e, {
|
|
2260
2260
|
totalPrice: +t.toFixed(2),
|
|
2261
|
-
installmentPrice: +
|
|
2261
|
+
installmentPrice: +e.toFixed(2)
|
|
2262
2262
|
};
|
|
2263
|
-
},
|
|
2264
|
-
const
|
|
2265
|
-
return
|
|
2263
|
+
}, An = (n) => {
|
|
2264
|
+
const s = n.startsWith("'") && n.endsWith("'"), a = n.startsWith('"') && n.endsWith('"');
|
|
2265
|
+
return s || a ? n : `"${n}"`;
|
|
2266
2266
|
};
|
|
2267
|
-
function
|
|
2267
|
+
function Dn(n) {
|
|
2268
2268
|
return /<\/?[a-z][\s\S]*>/i.test(n);
|
|
2269
2269
|
}
|
|
2270
|
-
const
|
|
2271
|
-
function
|
|
2272
|
-
return
|
|
2270
|
+
const Tn = (n, s = ["password", "confirmPassword", "creditCard"]) => {
|
|
2271
|
+
function a(e, t) {
|
|
2272
|
+
return s.includes(e) ? "****" : t;
|
|
2273
2273
|
}
|
|
2274
|
-
function e
|
|
2275
|
-
return Array.isArray(
|
|
2276
|
-
let r =
|
|
2274
|
+
function _(e) {
|
|
2275
|
+
return Array.isArray(e) ? e.map((t) => _(t)) : e !== null && typeof e == "object" ? Object.keys(e).reduce((t, c) => {
|
|
2276
|
+
let r = e[c];
|
|
2277
2277
|
if (typeof r == "string")
|
|
2278
2278
|
try {
|
|
2279
2279
|
const o = JSON.parse(r);
|
|
2280
|
-
typeof o == "object" && (r = JSON.stringify(
|
|
2280
|
+
typeof o == "object" && (r = JSON.stringify(_(o)));
|
|
2281
2281
|
} catch {
|
|
2282
2282
|
}
|
|
2283
|
-
return t[c] =
|
|
2284
|
-
}, {}) :
|
|
2283
|
+
return t[c] = _(a(c, r)), t;
|
|
2284
|
+
}, {}) : e;
|
|
2285
2285
|
}
|
|
2286
2286
|
try {
|
|
2287
|
-
const
|
|
2287
|
+
const e = JSON.parse(n), t = _(e);
|
|
2288
2288
|
return JSON.stringify(t);
|
|
2289
2289
|
} catch {
|
|
2290
2290
|
return n;
|
|
2291
2291
|
}
|
|
2292
|
-
},
|
|
2293
|
-
function
|
|
2294
|
-
return typeof
|
|
2292
|
+
}, En = (n) => n.replace(/<\/?[^>]+(>|$)/g, ""), Rn = (n, s = 1e3) => {
|
|
2293
|
+
function a(e) {
|
|
2294
|
+
return typeof e == "string" && e.length > s ? `To large information: field as ${e.length} characters` : e;
|
|
2295
2295
|
}
|
|
2296
|
-
function e
|
|
2297
|
-
return Array.isArray(
|
|
2298
|
-
Object.entries(
|
|
2296
|
+
function _(e) {
|
|
2297
|
+
return Array.isArray(e) ? e.map((t) => _(t)) : e !== null && typeof e == "object" ? Object.fromEntries(
|
|
2298
|
+
Object.entries(e).map(([t, c]) => [
|
|
2299
2299
|
t,
|
|
2300
|
-
|
|
2300
|
+
_(c)
|
|
2301
2301
|
// Corrigido para aplicar recursão corretamente
|
|
2302
2302
|
])
|
|
2303
|
-
) :
|
|
2303
|
+
) : a(e);
|
|
2304
2304
|
}
|
|
2305
2305
|
try {
|
|
2306
|
-
const
|
|
2306
|
+
const e = JSON.parse(n), t = _(e);
|
|
2307
2307
|
return JSON.stringify(t);
|
|
2308
2308
|
} catch {
|
|
2309
2309
|
throw new Error("Invalid JSON string");
|
|
2310
2310
|
}
|
|
2311
|
-
},
|
|
2311
|
+
}, Ln = (n) => {
|
|
2312
2312
|
if (!n || !/^[0-9-]+$/.test(n)) return !1;
|
|
2313
|
-
const
|
|
2314
|
-
return
|
|
2313
|
+
const a = f(n), _ = 8, e = /^\d{8}$/.test(a);
|
|
2314
|
+
return a.length === _ && e;
|
|
2315
2315
|
};
|
|
2316
2316
|
function j(n) {
|
|
2317
2317
|
return n.length !== 14;
|
|
2318
2318
|
}
|
|
2319
2319
|
function X(n) {
|
|
2320
|
-
const [
|
|
2321
|
-
return [...n].every((
|
|
2320
|
+
const [s] = n;
|
|
2321
|
+
return [...n].every((a) => a === s);
|
|
2322
2322
|
}
|
|
2323
|
-
function M(n,
|
|
2324
|
-
let
|
|
2325
|
-
for (let
|
|
2326
|
-
|
|
2327
|
-
const
|
|
2328
|
-
return
|
|
2323
|
+
function M(n, s) {
|
|
2324
|
+
let a = 0;
|
|
2325
|
+
for (let e = 0; e < s.length; e++)
|
|
2326
|
+
a += parseInt(n[e]) * s[e];
|
|
2327
|
+
const _ = a % 11;
|
|
2328
|
+
return _ < 2 ? 0 : 11 - _;
|
|
2329
2329
|
}
|
|
2330
2330
|
function Q(n) {
|
|
2331
2331
|
return n.slice(12);
|
|
2332
2332
|
}
|
|
2333
|
-
const
|
|
2333
|
+
const wn = (n) => {
|
|
2334
2334
|
if (!n) return !1;
|
|
2335
|
-
const
|
|
2336
|
-
if (j(
|
|
2337
|
-
const
|
|
2338
|
-
|
|
2335
|
+
const s = f(n);
|
|
2336
|
+
if (j(s) || X(s)) return !1;
|
|
2337
|
+
const a = s.slice(0, 12), _ = M(a, [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]), e = M(
|
|
2338
|
+
a + _,
|
|
2339
2339
|
[6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
2340
2340
|
);
|
|
2341
|
-
return Q(
|
|
2341
|
+
return Q(s) === `${_}${e}`;
|
|
2342
2342
|
};
|
|
2343
2343
|
function nn(n) {
|
|
2344
2344
|
return n.length !== 11;
|
|
2345
2345
|
}
|
|
2346
|
-
function
|
|
2347
|
-
const [
|
|
2348
|
-
return [...n].every((
|
|
2346
|
+
function sn(n) {
|
|
2347
|
+
const [s] = n;
|
|
2348
|
+
return [...n].every((a) => a === s);
|
|
2349
2349
|
}
|
|
2350
|
-
function
|
|
2351
|
-
let
|
|
2352
|
-
for (const
|
|
2353
|
-
|
|
2354
|
-
const
|
|
2355
|
-
return
|
|
2350
|
+
function A(n, s) {
|
|
2351
|
+
let a = 0;
|
|
2352
|
+
for (const e of n)
|
|
2353
|
+
s > 1 && (a += parseInt(e) * s--);
|
|
2354
|
+
const _ = a % 11;
|
|
2355
|
+
return _ < 2 ? 0 : 11 - _;
|
|
2356
2356
|
}
|
|
2357
2357
|
function an(n) {
|
|
2358
2358
|
return n.slice(9);
|
|
2359
2359
|
}
|
|
2360
|
-
const
|
|
2360
|
+
const Gn = (n) => {
|
|
2361
2361
|
if (!n) return !1;
|
|
2362
|
-
const
|
|
2363
|
-
if (nn(
|
|
2364
|
-
const
|
|
2365
|
-
return an(
|
|
2366
|
-
},
|
|
2367
|
-
let
|
|
2368
|
-
const t = (
|
|
2362
|
+
const s = f(n);
|
|
2363
|
+
if (nn(s) || sn(s)) return !1;
|
|
2364
|
+
const a = A(s, 10), _ = A(s, 11);
|
|
2365
|
+
return an(s) === `${a}${_}`;
|
|
2366
|
+
}, Bn = (n, s) => {
|
|
2367
|
+
let a, _, e;
|
|
2368
|
+
const t = (s == null ? void 0 : s.inputFormat) || "DD/MM/YYYY", c = (s == null ? void 0 : s.minYear) || 1900, r = (s == null ? void 0 : s.maxYear) || 3e3;
|
|
2369
2369
|
if (t === "DD/MM/YYYY") {
|
|
2370
2370
|
const u = /^(\d{2})\/(\d{2})\/(\d{4})$/;
|
|
2371
2371
|
if (!u.test(n)) return !1;
|
|
2372
|
-
[,
|
|
2372
|
+
[, a, _, e] = n.match(u) || [];
|
|
2373
2373
|
} else if (t === "MM-DD-YYYY") {
|
|
2374
2374
|
const u = /^(\d{2})-(\d{2})-(\d{4})$/;
|
|
2375
2375
|
if (!u.test(n)) return !1;
|
|
2376
|
-
[,
|
|
2376
|
+
[, _, a, e] = n.match(u) || [];
|
|
2377
2377
|
} else if (t === "YYYY-MM-DD") {
|
|
2378
2378
|
const u = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2379
2379
|
if (!u.test(n)) return !1;
|
|
2380
|
-
[,
|
|
2380
|
+
[, e, _, a] = n.match(u) || [];
|
|
2381
2381
|
} else
|
|
2382
2382
|
throw new Error("Invalid date format");
|
|
2383
|
-
const o = parseInt(
|
|
2383
|
+
const o = parseInt(a, 10), i = parseInt(_, 10), m = parseInt(e, 10);
|
|
2384
2384
|
if (o < 1 || o > 31 || i < 1 || i > 12) return !1;
|
|
2385
2385
|
const d = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
2386
2386
|
if (i === 2) {
|
|
@@ -2389,63 +2389,112 @@ const bn = (n) => {
|
|
|
2389
2389
|
} else if (o > d[i - 1])
|
|
2390
2390
|
return !1;
|
|
2391
2391
|
return m < c || m > r ? !1 : new Date(m, i - 1, o).getDate() === o;
|
|
2392
|
-
},
|
|
2392
|
+
}, en = {}, _n = en.promises.resolve;
|
|
2393
|
+
function tn(n) {
|
|
2394
|
+
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(n);
|
|
2395
|
+
}
|
|
2396
|
+
function on(n) {
|
|
2397
|
+
return !(n.length === 0 || n.length > 64 || n.startsWith(".") || n.endsWith(".") || n.includes("..") || !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(n));
|
|
2398
|
+
}
|
|
2399
|
+
function cn(n) {
|
|
2400
|
+
return !(n.length === 0 || n.length > 63 || n.startsWith("-") || n.endsWith("-") || !/^[a-zA-Z0-9-]+$/.test(n));
|
|
2401
|
+
}
|
|
2402
|
+
function rn(n) {
|
|
2403
|
+
if (n.length === 0 || n.length > 253 || n.startsWith(".") || n.endsWith(".") || n.startsWith("-") || n.endsWith("-"))
|
|
2404
|
+
return !1;
|
|
2405
|
+
const s = n.split(".");
|
|
2406
|
+
if (s.length < 2) return !1;
|
|
2407
|
+
for (const _ of s) if (!cn(_)) return !1;
|
|
2408
|
+
const a = s[s.length - 1];
|
|
2409
|
+
return !(a.length < 2 || !/^[a-zA-Z]+$/.test(a));
|
|
2410
|
+
}
|
|
2411
|
+
function ln(n) {
|
|
2412
|
+
const s = n.split("@");
|
|
2413
|
+
if (s.length !== 2) return !1;
|
|
2414
|
+
const [a, _] = s;
|
|
2415
|
+
return !(!on(a) || !rn(_));
|
|
2416
|
+
}
|
|
2417
|
+
function un(n) {
|
|
2418
|
+
const s = n.split("@");
|
|
2419
|
+
return s.length === 2 ? s[1].toLowerCase() : null;
|
|
2420
|
+
}
|
|
2421
|
+
const gn = ["MX", "A", "AAAA"];
|
|
2422
|
+
async function mn(n, s) {
|
|
2423
|
+
try {
|
|
2424
|
+
return await _n(n, s), !0;
|
|
2425
|
+
} catch {
|
|
2426
|
+
return !1;
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
async function fn(n) {
|
|
2430
|
+
for (const s of gn)
|
|
2431
|
+
if (await mn(n, s)) return !0;
|
|
2432
|
+
return !1;
|
|
2433
|
+
}
|
|
2434
|
+
const Pn = async (n) => {
|
|
2435
|
+
if (!n || typeof n != "string") return !1;
|
|
2436
|
+
const s = n.trim();
|
|
2437
|
+
if (!tn(s) || !ln(s)) return !1;
|
|
2438
|
+
const a = un(s);
|
|
2439
|
+
return a ? await fn(a) : !1;
|
|
2440
|
+
}, Yn = (n) => {
|
|
2393
2441
|
if (!n) return !1;
|
|
2394
|
-
const
|
|
2442
|
+
const s = n.length >= 8, a = /[A-Z]/.test(n), _ = /[a-z]/.test(n), e = /\d/.test(n), t = /[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(
|
|
2395
2443
|
n
|
|
2396
2444
|
);
|
|
2397
2445
|
return [
|
|
2398
|
-
_,
|
|
2399
2446
|
s,
|
|
2400
|
-
e,
|
|
2401
2447
|
a,
|
|
2448
|
+
_,
|
|
2449
|
+
e,
|
|
2402
2450
|
t
|
|
2403
2451
|
].every((c) => c);
|
|
2404
|
-
},
|
|
2405
|
-
for (const
|
|
2406
|
-
const
|
|
2407
|
-
if (
|
|
2408
|
-
if (new RegExp(`^\\${
|
|
2452
|
+
}, $n = (n) => {
|
|
2453
|
+
for (const s of C) {
|
|
2454
|
+
const a = s.code, _ = s.prefix ? `-${s.prefix}` : "", e = s.mask.replace(/[^_]/g, "").length;
|
|
2455
|
+
if (s.iso === "BR") {
|
|
2456
|
+
if (new RegExp(`^\\${a} \\d{2}9?\\d{8}$`).test(n)) return !0;
|
|
2409
2457
|
continue;
|
|
2410
2458
|
}
|
|
2411
|
-
if (new RegExp(`^\\${
|
|
2459
|
+
if (new RegExp(`^\\${a}${_} \\d{${e}}$`).test(n)) return !0;
|
|
2412
2460
|
}
|
|
2413
2461
|
return !1;
|
|
2414
|
-
},
|
|
2462
|
+
}, Un = (n) => {
|
|
2415
2463
|
if (!n || !/^[0-9a-zA-Z.-]+$/.test(n)) return !1;
|
|
2416
|
-
const
|
|
2417
|
-
return
|
|
2464
|
+
const a = n.replace(/[^a-zA-Z0-9]/g, "");
|
|
2465
|
+
return a.length < 7 || a.length > 9 ? !1 : /^[0-9]{7,8}[0-9Xx]?$/.test(a);
|
|
2418
2466
|
};
|
|
2419
2467
|
export {
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2468
|
+
Mn as calculateCardInstallment,
|
|
2469
|
+
An as ensureQuotes,
|
|
2470
|
+
dn as formatDate,
|
|
2423
2471
|
h as formatJsonObject,
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2472
|
+
kn as formatJsonString,
|
|
2473
|
+
pn as formatToCapitalizeFirstWordLetter,
|
|
2474
|
+
hn as formatToCep,
|
|
2427
2475
|
w as formatToCnpj,
|
|
2428
2476
|
G as formatToCpf,
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2477
|
+
yn as formatToCpfCnpj,
|
|
2478
|
+
Cn as formatToCurrency,
|
|
2479
|
+
vn as formatToDate,
|
|
2480
|
+
xn as formatToEllipsis,
|
|
2481
|
+
Fn as formatToHiddenDigits,
|
|
2482
|
+
Sn as formatToPhone,
|
|
2483
|
+
bn as generateColorByString,
|
|
2484
|
+
Nn as generateId,
|
|
2485
|
+
In as generateSlug,
|
|
2486
|
+
Dn as isHtml,
|
|
2487
|
+
Tn as maskSensitiveData,
|
|
2488
|
+
B as removeCurrencySymbols,
|
|
2489
|
+
f as removeNonNumeric,
|
|
2490
|
+
En as stripHtmlTags,
|
|
2491
|
+
Rn as truncateLargeFields,
|
|
2492
|
+
Ln as validateCep,
|
|
2493
|
+
wn as validateCnpj,
|
|
2494
|
+
Gn as validateCpf,
|
|
2495
|
+
Bn as validateDate,
|
|
2496
|
+
Pn as validateEmail,
|
|
2497
|
+
Yn as validatePassword,
|
|
2498
|
+
$n as validatePhone,
|
|
2499
|
+
Un as validateRg
|
|
2451
2500
|
};
|