@arkyn/shared 3.0.1-beta.116 → 3.0.1-beta.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/bundle.js +342 -282
  2. package/dist/bundle.umd.cjs +6 -6
  3. package/dist/formats/formatDate.d.ts +43 -15
  4. package/dist/formats/formatDate.d.ts.map +1 -1
  5. package/dist/formats/formatDate.js +60 -25
  6. package/dist/formats/formatJsonObject.d.ts +6 -7
  7. package/dist/formats/formatJsonObject.d.ts.map +1 -1
  8. package/dist/formats/formatJsonObject.js +17 -17
  9. package/dist/formats/formatToCep.d.ts +5 -12
  10. package/dist/formats/formatToCep.d.ts.map +1 -1
  11. package/dist/formats/formatToCep.js +11 -16
  12. package/dist/formats/formatToCnpj.d.ts +3 -13
  13. package/dist/formats/formatToCnpj.d.ts.map +1 -1
  14. package/dist/formats/formatToCnpj.js +9 -17
  15. package/dist/formats/formatToCpf.d.ts +5 -13
  16. package/dist/formats/formatToCpf.d.ts.map +1 -1
  17. package/dist/formats/formatToCpf.js +11 -17
  18. package/dist/formats/formatToCurrency.d.ts +18 -14
  19. package/dist/formats/formatToCurrency.d.ts.map +1 -1
  20. package/dist/formats/formatToCurrency.js +21 -14
  21. package/dist/formats/formatToEllipsis.d.ts +8 -5
  22. package/dist/formats/formatToEllipsis.d.ts.map +1 -1
  23. package/dist/formats/formatToEllipsis.js +21 -7
  24. package/dist/formats/formatToHiddenDigits.d.ts +16 -16
  25. package/dist/formats/formatToHiddenDigits.d.ts.map +1 -1
  26. package/dist/formats/formatToHiddenDigits.js +19 -19
  27. package/dist/formats/formatToPhone.d.ts +1 -1
  28. package/dist/formats/formatToPhone.d.ts.map +1 -1
  29. package/dist/formats/formatToPhone.js +3 -3
  30. package/dist/generators/generateColorByString.d.ts +7 -4
  31. package/dist/generators/generateColorByString.d.ts.map +1 -1
  32. package/dist/generators/generateColorByString.js +10 -6
  33. package/dist/generators/generateId.d.ts +3 -3
  34. package/dist/generators/generateSlug.d.ts +10 -3
  35. package/dist/generators/generateSlug.d.ts.map +1 -1
  36. package/dist/generators/generateSlug.js +11 -4
  37. package/dist/index.d.ts +10 -10
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +12 -10
  40. package/dist/parsers/parseDate.d.ts +41 -0
  41. package/dist/parsers/parseDate.d.ts.map +1 -0
  42. package/dist/parsers/parseDate.js +67 -0
  43. package/dist/{services/truncateLargeFields.d.ts → parsers/parseLargeFields.d.ts} +9 -11
  44. package/dist/parsers/parseLargeFields.d.ts.map +1 -0
  45. package/dist/{services/truncateLargeFields.js → parsers/parseLargeFields.js} +12 -13
  46. package/dist/parsers/parseSensitiveData.d.ts +23 -0
  47. package/dist/parsers/parseSensitiveData.d.ts.map +1 -0
  48. package/dist/{services/maskSensitiveData.js → parsers/parseSensitiveData.js} +10 -12
  49. package/dist/services/validateDateService.d.ts +9 -0
  50. package/dist/services/validateDateService.d.ts.map +1 -0
  51. package/dist/services/validateDateService.js +56 -0
  52. package/dist/{services → utilities}/calculateCardInstallment.d.ts +16 -18
  53. package/dist/utilities/calculateCardInstallment.d.ts.map +1 -0
  54. package/dist/{services → utilities}/calculateCardInstallment.js +12 -15
  55. package/dist/utilities/ensureQuotes.d.ts +21 -0
  56. package/dist/utilities/ensureQuotes.d.ts.map +1 -0
  57. package/dist/{services → utilities}/ensureQuotes.js +12 -4
  58. package/dist/utilities/isHtml.d.ts +22 -0
  59. package/dist/utilities/isHtml.d.ts.map +1 -0
  60. package/dist/utilities/isHtml.js +24 -0
  61. package/dist/{services → utilities}/removeCurrencySymbols.d.ts +6 -4
  62. package/dist/utilities/removeCurrencySymbols.d.ts.map +1 -0
  63. package/dist/{services → utilities}/removeCurrencySymbols.js +8 -7
  64. package/dist/utilities/removeNonNumeric.d.ts +16 -0
  65. package/dist/utilities/removeNonNumeric.d.ts.map +1 -0
  66. package/dist/utilities/removeNonNumeric.js +17 -0
  67. package/dist/utilities/stripHtmlTags.d.ts +19 -0
  68. package/dist/utilities/stripHtmlTags.d.ts.map +1 -0
  69. package/dist/utilities/stripHtmlTags.js +24 -0
  70. package/package.json +1 -4
  71. package/dist/formats/formatToCpfCnpj.d.ts +0 -24
  72. package/dist/formats/formatToCpfCnpj.d.ts.map +0 -1
  73. package/dist/formats/formatToCpfCnpj.js +0 -33
  74. package/dist/formats/formatToDate.d.ts +0 -32
  75. package/dist/formats/formatToDate.d.ts.map +0 -1
  76. package/dist/formats/formatToDate.js +0 -50
  77. package/dist/services/calculateCardInstallment.d.ts.map +0 -1
  78. package/dist/services/ensureQuotes.d.ts +0 -14
  79. package/dist/services/ensureQuotes.d.ts.map +0 -1
  80. package/dist/services/isHtml.d.ts +0 -22
  81. package/dist/services/isHtml.d.ts.map +0 -1
  82. package/dist/services/isHtml.js +0 -24
  83. package/dist/services/maskSensitiveData.d.ts +0 -26
  84. package/dist/services/maskSensitiveData.d.ts.map +0 -1
  85. package/dist/services/removeCurrencySymbols.d.ts.map +0 -1
  86. package/dist/services/removeNonNumeric.d.ts +0 -16
  87. package/dist/services/removeNonNumeric.d.ts.map +0 -1
  88. package/dist/services/removeNonNumeric.js +0 -16
  89. package/dist/services/stripHtmlTags.d.ts +0 -16
  90. package/dist/services/stripHtmlTags.d.ts.map +0 -1
  91. package/dist/services/stripHtmlTags.js +0 -16
  92. package/dist/services/truncateLargeFields.d.ts.map +0 -1
package/dist/bundle.js CHANGED
@@ -1,102 +1,147 @@
1
- function E(_, n) {
2
- const e = (a) => a.toString().padStart(2, "0"), s = {
3
- YYYY: _.getFullYear().toString(),
4
- YY: _.getFullYear().toString().slice(-2),
5
- MM: e(_.getMonth() + 1),
6
- DD: e(_.getDate()),
7
- hh: e(_.getHours()),
8
- mm: e(_.getMinutes()),
9
- ss: e(_.getSeconds())
1
+ class I {
2
+ isLeapYear(_) {
3
+ return _ % 4 === 0 && _ % 100 !== 0 || _ % 400 === 0;
4
+ }
5
+ getDaysInMonth(_, s) {
6
+ const n = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
7
+ return _ === 2 && this.isLeapYear(s) ? 29 : n[_ - 1];
8
+ }
9
+ validateDayInMonth(_, s, n) {
10
+ const e = this.getDaysInMonth(s, n);
11
+ if (_ > e) {
12
+ const c = `Day ${_} is not valid for ${[
13
+ "January",
14
+ "February",
15
+ "March",
16
+ "April",
17
+ "May",
18
+ "June",
19
+ "July",
20
+ "August",
21
+ "September",
22
+ "October",
23
+ "November",
24
+ "December"
25
+ ][s - 1]}`, i = `Day ${_} is not valid for February ${n} (non-leap year)`;
26
+ throw s === 2 && _ === 29 ? new Error(i) : new Error(c);
27
+ }
28
+ }
29
+ validateDateParts(_, s, n) {
30
+ const e = {
31
+ year: "Year should be four digits",
32
+ month: "Month should be between 1 and 12",
33
+ day: "Day should be between 1 and 31"
34
+ };
35
+ if (`${_}`.length !== 4) throw new Error(e.year);
36
+ if (s < 1 || s > 12) throw new Error(e.month);
37
+ if (n < 1 || n > 31) throw new Error(e.day);
38
+ this.validateDayInMonth(n, s, _);
39
+ }
40
+ validateInputFormat(_) {
41
+ if (!["brazilianDate", "isoDate", "timestamp"].includes(_))
42
+ throw new Error(`Invalid input format: ${_}`);
43
+ }
44
+ }
45
+ function P(a, _) {
46
+ const s = (e) => e.toString().padStart(2, "0"), n = {
47
+ YYYY: a.getUTCFullYear().toString(),
48
+ YY: a.getUTCFullYear().toString().slice(-2),
49
+ MM: s(a.getUTCMonth() + 1),
50
+ DD: s(a.getUTCDate()),
51
+ hh: s(a.getUTCHours()),
52
+ mm: s(a.getUTCMinutes()),
53
+ ss: s(a.getUTCSeconds())
10
54
  };
11
- return n.replace(
55
+ return _.replace(
12
56
  /YYYY|YY|MM|DD|hh|mm|ss/g,
13
- (a) => s[a]
57
+ (e) => n[e]
14
58
  );
15
59
  }
16
- const Z = ([_, n = "00:00:00"], e, s, a = 0) => {
17
- const o = _.split(/[-/]/).map(Number), c = n.split(".")[0].split(":").map(Number);
18
- let r, t, i;
19
- const [p = 0, y = 0, m = 0] = c;
20
- switch (e) {
60
+ function Z([a, _ = "00:00:00"], s, n, e = 0) {
61
+ const t = new I();
62
+ t.validateInputFormat(s);
63
+ const c = a.split(/[-/]/).map(Number), i = _.split(".")[0].split(":").map(Number);
64
+ let o, r, g;
65
+ const [h = 0, C = 0, m = 0] = i;
66
+ switch (s) {
21
67
  case "brazilianDate":
22
- [r, t, i] = o;
68
+ [o, r, g] = c, t.validateDateParts(g, r, o);
23
69
  break;
24
70
  case "isoDate":
25
- [i, t, r] = o;
71
+ [r, o, g] = c, t.validateDateParts(g, r, o);
26
72
  break;
27
73
  case "timestamp":
28
- [i, t, r] = o.map(Number);
74
+ [g, r, o] = c, t.validateDateParts(g, r, o);
29
75
  break;
30
- default:
31
- throw new Error("Invalid input format");
32
76
  }
33
- const k = new Date(i, t - 1, r, p, y, m);
34
- if (isNaN(k.getTime())) throw new Error("Invalid date");
35
- return k.setUTCHours(k.getUTCHours() + a), E(k, s);
36
- }, f = (_, n) => {
37
- const e = " ".repeat(n);
38
- let s = "";
39
- if (typeof _ == "object" && _ !== null)
40
- if (Array.isArray(_))
41
- _.length === 0 ? s += "[]" : (s += `[
42
- `, _.forEach((a, o) => {
43
- s += e + " " + f(a, n + 1), o < _.length - 1 && (s += ","), s += `
77
+ const d = new Date(
78
+ Date.UTC(g, r - 1, o, h, C, m)
79
+ );
80
+ if (isNaN(d.getTime())) throw new Error("Invalid date");
81
+ return d.setUTCHours(d.getUTCHours() + e), P(d, n);
82
+ }
83
+ const y = (a, _) => {
84
+ const s = " ".repeat(_);
85
+ let n = "";
86
+ if (typeof a == "object" && a !== null)
87
+ if (Array.isArray(a))
88
+ a.length === 0 ? n += "[]" : (n += `[
89
+ `, a.forEach((e, t) => {
90
+ n += s + " " + y(e, _ + 1), t < a.length - 1 && (n += ","), n += `
44
91
  `;
45
- }), s += e + "]");
92
+ }), n += s + "]");
46
93
  else {
47
- const a = Object.keys(_);
48
- a.length === 0 ? s += "{}" : (s += `{
49
- `, a.forEach((o, c) => {
50
- s += e + ' "' + o + '": ' + f(_[o], n + 1), c < a.length - 1 && (s += ","), s += `
94
+ const e = Object.keys(a);
95
+ e.length === 0 ? n += "{}" : (n += `{
96
+ `, e.forEach((t, c) => {
97
+ n += s + ' "' + t + '": ' + y(a[t], _ + 1), c < e.length - 1 && (n += ","), n += `
51
98
  `;
52
- }), s += e + "}");
99
+ }), n += s + "}");
53
100
  }
54
- else if (typeof _ == "string")
101
+ else if (typeof a == "string")
55
102
  try {
56
- const a = JSON.parse(_);
57
- s += f(a, n);
103
+ const e = JSON.parse(a);
104
+ n += y(e, _);
58
105
  } catch {
59
- s += '"' + _ + '"';
106
+ n += '"' + a + '"';
60
107
  }
61
108
  else
62
- s += _;
63
- return s;
64
- }, q = (_) => {
109
+ n += a;
110
+ return n;
111
+ }, q = (a) => {
65
112
  try {
66
- const n = JSON.parse(_);
67
- return f(n, 0);
68
- } catch (n) {
113
+ const _ = JSON.parse(a);
114
+ return y(_, 0);
115
+ } catch (_) {
69
116
  throw new Error(`Invalid JSON string
70
- ${n}`);
117
+ ${_}`);
71
118
  }
72
119
  };
73
- function j(_) {
74
- return _.split(" ").map((s) => {
75
- const a = s.charAt(0).toUpperCase(), o = s.slice(1).toLowerCase();
76
- return a + o;
120
+ function j(a) {
121
+ return a.split(" ").map((n) => {
122
+ const e = n.charAt(0).toUpperCase(), t = n.slice(1).toLowerCase();
123
+ return e + t;
77
124
  }).join(" ");
78
125
  }
79
- const g = (_) => _.replace(/[^0-9]/g, ""), Q = (_) => {
80
- const e = g(_).match(/^(\d{5})(\d{3})$/);
81
- if (e) return `${e[1]}-${e[2]}`;
82
- throw new Error("Invalid CEP format");
83
- }, D = (_) => {
84
- const e = g(_).match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/);
85
- if (e)
86
- return `${e[1]}.${e[2]}.${e[3]}/${e[4]}-${e[5]}`;
87
- throw new Error("Invalid CNPJ length");
88
- }, L = (_) => {
89
- const e = g(_).match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/);
90
- if (e) return `${e[1]}.${e[2]}.${e[3]}-${e[4]}`;
91
- throw new Error("Invalid CPF format");
92
- }, X = (_) => {
93
- const n = _.replace(/\D/g, "");
94
- if (n.length === 11)
95
- return L(n);
96
- if (n.length === 14)
97
- return D(n);
98
- throw new Error("Invalid CPF or CNPJ length");
99
- }, N = [
126
+ function k(a) {
127
+ return a.replace(/[^0-9]/g, "");
128
+ }
129
+ function Q(a) {
130
+ const s = k(a).match(/^(\d{5})(\d{3})$/), n = `CEP must be contain 8 numeric digits: ${a}`;
131
+ if (!s) throw new Error(n);
132
+ return `${s[1]}-${s[2]}`;
133
+ }
134
+ function X(a) {
135
+ const s = k(a).match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/), n = `CNPJ must be contain 14 numeric digits: ${a}`;
136
+ if (!s) throw new Error(n);
137
+ return `${s[1]}.${s[2]}.${s[3]}/${s[4]}-${s[5]}`;
138
+ }
139
+ function aa(a) {
140
+ const s = k(a).match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/), n = `CPF must be contain 11 numeric digits: ${a}`;
141
+ if (!s) throw new Error(n);
142
+ return `${s[1]}.${s[2]}.${s[3]}-${s[4]}`;
143
+ }
144
+ const N = [
100
145
  {
101
146
  name: "Afghanistan",
102
147
  code: "+93",
@@ -2049,7 +2094,7 @@ const g = (_) => _.replace(/[^0-9]/g, ""), Q = (_) => {
2049
2094
  flag: "https://cdn.kcak11.com/CountryFlags/countries/zw.svg",
2050
2095
  mask: "_-______"
2051
2096
  }
2052
- ], C = {
2097
+ ], f = {
2053
2098
  USD: { countryLanguage: "en-US", countryCurrency: "USD" },
2054
2099
  EUR: { countryLanguage: "de-DE", countryCurrency: "EUR" },
2055
2100
  JPY: { countryLanguage: "ja-JP", countryCurrency: "JPY" },
@@ -2072,266 +2117,281 @@ const g = (_) => _.replace(/[^0-9]/g, ""), Q = (_) => {
2072
2117
  TRY: { countryLanguage: "tr-TR", countryCurrency: "TRY" },
2073
2118
  IDR: { countryLanguage: "id-ID", countryCurrency: "IDR" },
2074
2119
  THB: { countryLanguage: "th-TH", countryCurrency: "THB" }
2075
- }, R = (_) => _.replace(new RegExp("(?:R\\$|\\p{Sc}|[$€¥£])", "gu"), "").trim(), __ = (_, n, e = { showPrefix: !0 }) => {
2076
- if (!C[n])
2120
+ };
2121
+ function L(a) {
2122
+ return a.replace(new RegExp("(?:R\\$|\\p{Sc}|[$€¥£])", "gu"), "").trim();
2123
+ }
2124
+ function _a(a, _, s) {
2125
+ if (!(f != null && f[_]))
2077
2126
  throw new Error("Unsupported currency code");
2078
- const { countryCurrency: s, countryLanguage: a } = C[n], o = new Intl.NumberFormat(a, {
2127
+ const n = (s == null ? void 0 : s.showPrefix) ?? !0, { countryCurrency: e, countryLanguage: t } = f[_], c = new Intl.NumberFormat(t, {
2079
2128
  style: "currency",
2080
- currency: s
2081
- }).format(_);
2082
- return e.showPrefix ? o.replace(/\s/g, " ") : R(o).replace(/\s/g, " ");
2083
- }, n_ = ([_, n = "00:00:00"], e, s = 0) => {
2084
- const a = _.split(/[-/]/).map(Number), o = n.split(".")[0].split(":").map(Number);
2085
- let c, r, t;
2086
- const [i = 0, p = 0, y = 0] = o;
2087
- switch (e) {
2088
- case "brazilianDate":
2089
- [c, r, t] = a;
2090
- break;
2091
- case "isoDate":
2092
- [t, r, c] = a;
2093
- break;
2094
- case "timestamp":
2095
- [t, r, c] = a.map(Number);
2096
- break;
2097
- default:
2098
- throw new Error("Invalid input format");
2099
- }
2100
- const m = new Date(
2101
- Date.UTC(t, r - 1, c, i - s, p, y)
2102
- );
2103
- if (isNaN(m.getTime())) throw new Error("Invalid date");
2104
- return m;
2105
- }, a_ = (_, n) => {
2106
- if (_.length > n) {
2107
- let e = _.substring(0, n).trimEnd();
2108
- return e = e.replace(/[.,!?;:]$/, ""), `${e}...`;
2129
+ currency: e
2130
+ }).format(a);
2131
+ return n ? c.replace(/\s/g, " ") : L(c).replace(/\s/g, " ");
2132
+ }
2133
+ function na(a, _) {
2134
+ if (a.length > _) {
2135
+ let s = a.substring(0, _);
2136
+ const n = s.lastIndexOf(" ");
2137
+ return n > 0 && (s = s.substring(0, n)), s = s.replace(/[\s.,!?;:]+$/, ""), s.trim().length === 0 || /^[.,!?;:\s]+$/.test(s) ? "..." : `${s}...`;
2109
2138
  }
2110
- return _;
2111
- }, G = /^\d$/, P = (_) => {
2112
- let n = 0;
2113
- const e = _.split("").map((s) => G.test(s) ? { character: s, kind: "digit", digit: ++n } : { character: s, kind: "other" });
2114
- return { digits: n, children: e, kind: "root" };
2115
- }, B = (_, n) => Array.isArray(_) ? _ : _ >= 0 ? [0, _] : [n + 1 - Math.abs(_), n], U = (_, n) => n >= _[0] && n <= _[1], s_ = (_, n) => {
2116
- const e = P(_), s = B(n.range ?? 3, e.digits);
2117
- return e.children.map((a) => a.kind === "digit" && U(s, a.digit) ? n.hider ?? "*" : a.character).join("");
2118
- };
2119
- function K(_) {
2120
- return _.length > 10 ? "NINE" : "EIGTH";
2139
+ return a;
2140
+ }
2141
+ const R = /^\d$/, G = (a) => {
2142
+ let _ = 0;
2143
+ const s = a.split("").map((n) => R.test(n) ? { character: n, kind: "digit", digit: ++_ } : { character: n, kind: "other" });
2144
+ return { digits: _, children: s, kind: "root" };
2145
+ }, U = (a, _) => Array.isArray(a) ? a : a >= 0 ? [0, a] : [_ + 1 - Math.abs(a), _], B = (a, _) => _ >= a[0] && _ <= a[1];
2146
+ function sa(a, _) {
2147
+ const s = G(a), n = U((_ == null ? void 0 : _.range) ?? 3, s.digits);
2148
+ return s.children.map((t) => t.kind === "digit" && B(n, t.digit) ? (_ == null ? void 0 : _.hider) ?? "*" : t.character).join("");
2149
+ }
2150
+ function H(a) {
2151
+ return a.length > 10 ? "NINE" : "EIGHT";
2121
2152
  }
2122
- const w = {
2123
- EIGTH: "(99) 9999-9999",
2153
+ const D = {
2154
+ EIGHT: "(99) 9999-9999",
2124
2155
  NINE: "(99) 99999-9999"
2125
- }, H = g(w.NINE).length;
2126
- function O(_, n) {
2127
- let e = "", s = 0;
2128
- for (let a = 0; a < n.length; a++)
2129
- if (n[a] === "9")
2130
- if (s < _.length)
2131
- e += _[s], s++;
2156
+ }, K = k(D.NINE).length;
2157
+ function O(a, _) {
2158
+ let s = "", n = 0;
2159
+ for (let e = 0; e < _.length; e++)
2160
+ if (_[e] === "9")
2161
+ if (n < a.length)
2162
+ s += a[n], n++;
2132
2163
  else
2133
2164
  break;
2134
- else if (s < _.length)
2135
- e += n[a];
2165
+ else if (n < a.length)
2166
+ s += _[e];
2136
2167
  else
2137
2168
  break;
2138
- return e;
2169
+ return s;
2139
2170
  }
2140
- function v(_, n) {
2141
- if (n.code === "+55") {
2142
- let a = g(_);
2143
- const o = K(a);
2144
- return a.length > H || (a = O(a, w[o])), a;
2171
+ function x(a, _) {
2172
+ if (_.code === "+55") {
2173
+ let e = k(a);
2174
+ const t = H(e);
2175
+ return e.length > K || (e = O(e, D[t])), e;
2145
2176
  }
2146
- let s = n.mask;
2147
- if (n.prefix) {
2148
- const a = /\$+/g;
2149
- s = s.replace(a, n.prefix);
2177
+ let n = _.mask;
2178
+ if (_.prefix) {
2179
+ const e = /\$+/g;
2180
+ n = n.replace(e, _.prefix);
2150
2181
  }
2151
- for (let a = 0, o = 0; a < s.length && o < _.length; a++)
2152
- s[a] === "_" && (s = s.substring(0, a) + _[o] + s.substring(a + 1), o++);
2153
- return s;
2182
+ for (let e = 0, t = 0; e < n.length && t < a.length; e++)
2183
+ n[e] === "_" && (n = n.substring(0, e) + a[t] + n.substring(e + 1), t++);
2184
+ return n;
2154
2185
  }
2155
- function z(_, n) {
2156
- const e = N.find(
2157
- (s) => s.code === _ && s.prefix === n
2186
+ function z(a, _) {
2187
+ const s = N.find(
2188
+ (n) => n.code === a && n.prefix === _
2158
2189
  );
2159
- if (!e) throw new Error("Invalid country code or prefix");
2160
- if (e.prefix !== n)
2190
+ if (!s) throw new Error("Invalid country code or prefix");
2191
+ if (s.prefix !== _)
2161
2192
  throw new Error("Invalid country code or prefix");
2162
- if (!e.prefix)
2193
+ if (!s.prefix)
2163
2194
  throw new Error("Invalid country code or prefix");
2164
- return e;
2195
+ return s;
2165
2196
  }
2166
- function J(_) {
2167
- const n = N.find((e) => e.code === _);
2168
- if (!n) throw new Error("Invalid country code");
2169
- if (n.prefix) throw new Error("Invalid country code");
2170
- return n;
2197
+ function Y(a) {
2198
+ const _ = N.find((s) => s.code === a);
2199
+ if (!_) throw new Error("Invalid country code");
2200
+ if (_.prefix) throw new Error("Invalid country code");
2201
+ return _;
2171
2202
  }
2172
- const e_ = (_) => {
2173
- if (!/^\+\d{1,4}(-\d{1,4})? \d+$/.test(_))
2203
+ const ea = (a) => {
2204
+ if (!/^\+\d{1,4}(-\d{1,4})? \d+$/.test(a))
2174
2205
  throw new Error(
2175
2206
  "Invalid phone number format. Expected format: +<countryCode>-<optionalPrefix> <phoneNumber>"
2176
2207
  );
2177
- const e = _.split(" ")[0].split("-")[0], s = _.split(" ")[0].split("-")[1], a = _.split(" ")[1];
2178
- if (!e || !a)
2208
+ const s = a.split(" ")[0].split("-")[0], n = a.split(" ")[0].split("-")[1], e = a.split(" ")[1];
2209
+ if (!s || !e)
2179
2210
  throw new Error("Invalid phone number format");
2180
- if (s) {
2181
- const c = z(e, s);
2182
- return v(a, c);
2211
+ if (n) {
2212
+ const c = z(s, n);
2213
+ return x(e, c);
2183
2214
  }
2184
- const o = J(e);
2185
- return v(a, o);
2186
- }, o_ = (_) => {
2187
- for (var n = 0, e = 0; e < _.length; e++)
2188
- n = _.charCodeAt(e) + ((n << 5) - n);
2189
- var s = (n & 16711680) >> 16, a = (n & 65280) >> 8, o = n & 255, c = s.toString(16).padStart(2, "0"), r = a.toString(16).padStart(2, "0"), t = o.toString(16).padStart(2, "0");
2190
- return "#" + c + r + t;
2215
+ const t = Y(s);
2216
+ return x(e, t);
2191
2217
  };
2218
+ function ta(a) {
2219
+ for (var _ = 0, s = 0; s < a.length; s++)
2220
+ _ = a.charCodeAt(s) + ((_ << 5) - _);
2221
+ var n = (_ & 16711680) >> 16, e = (_ & 65280) >> 8, t = _ & 255, c = n.toString(16).padStart(2, "0"), i = e.toString(16).padStart(2, "0"), o = t.toString(16).padStart(2, "0");
2222
+ return "#" + c + i + o;
2223
+ }
2192
2224
  var l = [];
2193
- for (var h = 0; h < 256; ++h)
2194
- l.push((h + 256).toString(16).slice(1));
2195
- function M(_, n = 0) {
2196
- return (l[_[n + 0]] + l[_[n + 1]] + l[_[n + 2]] + l[_[n + 3]] + "-" + l[_[n + 4]] + l[_[n + 5]] + "-" + l[_[n + 6]] + l[_[n + 7]] + "-" + l[_[n + 8]] + l[_[n + 9]] + "-" + l[_[n + 10]] + l[_[n + 11]] + l[_[n + 12]] + l[_[n + 13]] + l[_[n + 14]] + l[_[n + 15]]).toLowerCase();
2225
+ for (var v = 0; v < 256; ++v)
2226
+ l.push((v + 256).toString(16).slice(1));
2227
+ function T(a, _ = 0) {
2228
+ return (l[a[_ + 0]] + l[a[_ + 1]] + l[a[_ + 2]] + l[a[_ + 3]] + "-" + l[a[_ + 4]] + l[a[_ + 5]] + "-" + l[a[_ + 6]] + l[a[_ + 7]] + "-" + l[a[_ + 8]] + l[a[_ + 9]] + "-" + l[a[_ + 10]] + l[a[_ + 11]] + l[a[_ + 12]] + l[a[_ + 13]] + l[a[_ + 14]] + l[a[_ + 15]]).toLowerCase();
2197
2229
  }
2198
- var d, Y = new Uint8Array(16);
2199
- function T() {
2200
- if (!d && (d = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !d))
2230
+ var p, J = new Uint8Array(16);
2231
+ function A() {
2232
+ if (!p && (p = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !p))
2201
2233
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2202
- return d(Y);
2234
+ return p(J);
2203
2235
  }
2204
2236
  var $ = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2205
- const x = {
2237
+ const F = {
2206
2238
  randomUUID: $
2207
2239
  };
2208
- function V(_, n, e) {
2209
- if (x.randomUUID && !_)
2210
- return x.randomUUID();
2211
- _ = _ || {};
2212
- var s = _.random || (_.rng || T)();
2213
- return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, M(s);
2240
+ function V(a, _, s) {
2241
+ if (F.randomUUID && !a)
2242
+ return F.randomUUID();
2243
+ a = a || {};
2244
+ var n = a.random || (a.rng || A)();
2245
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, T(n);
2214
2246
  }
2215
- var F = null, S = null, u = 0;
2216
- function W(_, n, e) {
2217
- _ = _ || {};
2218
- var s = 0, a = new Uint8Array(16), o = _.random || (_.rng || T)(), c = _.msecs !== void 0 ? _.msecs : Date.now(), r = _.seq !== void 0 ? _.seq : null, t = S, i = F;
2219
- return c > u && _.msecs === void 0 && (u = c, r !== null && (t = null, i = null)), r !== null && (r > 2147483647 && (r = 2147483647), t = r >>> 19 & 4095, i = r & 524287), (t === null || i === null) && (t = o[6] & 127, t = t << 8 | o[7], i = o[8] & 63, i = i << 8 | o[9], i = i << 5 | o[10] >>> 3), c + 1e4 > u && r === null ? ++i > 524287 && (i = 0, ++t > 4095 && (t = 0, u++)) : u = c, S = t, F = i, a[s++] = u / 1099511627776 & 255, a[s++] = u / 4294967296 & 255, a[s++] = u / 16777216 & 255, a[s++] = u / 65536 & 255, a[s++] = u / 256 & 255, a[s++] = u & 255, a[s++] = t >>> 4 & 15 | 112, a[s++] = t & 255, a[s++] = i >>> 13 & 63 | 128, a[s++] = i >>> 5 & 255, a[s++] = i << 3 & 255 | o[10] & 7, a[s++] = o[11], a[s++] = o[12], a[s++] = o[13], a[s++] = o[14], a[s++] = o[15], n || M(a);
2247
+ var b = null, S = null, u = 0;
2248
+ function W(a, _, s) {
2249
+ a = a || {};
2250
+ var n = 0, e = new Uint8Array(16), t = a.random || (a.rng || A)(), c = a.msecs !== void 0 ? a.msecs : Date.now(), i = a.seq !== void 0 ? a.seq : null, o = S, r = b;
2251
+ return c > u && a.msecs === void 0 && (u = c, i !== null && (o = null, r = null)), i !== null && (i > 2147483647 && (i = 2147483647), o = i >>> 19 & 4095, r = i & 524287), (o === null || r === null) && (o = t[6] & 127, o = o << 8 | t[7], r = t[8] & 63, r = r << 8 | t[9], r = r << 5 | t[10] >>> 3), c + 1e4 > u && i === null ? ++r > 524287 && (r = 0, ++o > 4095 && (o = 0, u++)) : u = c, S = o, b = r, e[n++] = u / 1099511627776 & 255, e[n++] = u / 4294967296 & 255, e[n++] = u / 16777216 & 255, e[n++] = u / 65536 & 255, e[n++] = u / 256 & 255, e[n++] = u & 255, e[n++] = o >>> 4 & 15 | 112, e[n++] = o & 255, e[n++] = r >>> 13 & 63 | 128, e[n++] = r >>> 5 & 255, e[n++] = r << 3 & 255 | t[10] & 7, e[n++] = t[11], e[n++] = t[12], e[n++] = t[13], e[n++] = t[14], e[n++] = t[15], _ || T(e);
2220
2252
  }
2221
- function A(_) {
2222
- _ = _.replace(/-/g, "");
2223
- const n = new Uint8Array(_.length / 2);
2224
- for (let e = 0; e < _.length; e += 2)
2225
- n[e / 2] = parseInt(_.substring(e, e + 2), 16);
2226
- return n;
2253
+ function E(a) {
2254
+ a = a.replace(/-/g, "");
2255
+ const _ = new Uint8Array(a.length / 2);
2256
+ for (let s = 0; s < a.length; s += 2)
2257
+ _[s / 2] = parseInt(a.substring(s, s + 2), 16);
2258
+ return _;
2227
2259
  }
2228
- function b() {
2229
- const _ = V();
2230
- return { text: _, binary: A(_) };
2260
+ function M() {
2261
+ const a = V();
2262
+ return { text: a, binary: E(a) };
2231
2263
  }
2232
- function I() {
2233
- const _ = W();
2234
- return { text: _, binary: A(_) };
2264
+ function w() {
2265
+ const a = W();
2266
+ return { text: a, binary: E(a) };
2235
2267
  }
2236
- function t_(_, n) {
2237
- if (_ === "text" && n === "v4") return b().text;
2238
- if (_ === "binary" && n === "v4") return b().binary;
2239
- if (_ === "text" && n === "v7") return I().text;
2240
- if (_ === "binary" && n === "v7") return I().binary;
2268
+ function oa(a, _) {
2269
+ if (a === "text" && _ === "v4") return M().text;
2270
+ if (a === "binary" && _ === "v4") return M().binary;
2271
+ if (a === "text" && _ === "v7") return w().text;
2272
+ if (a === "binary" && _ === "v7") return w().binary;
2241
2273
  throw new Error("Invalid type or format");
2242
2274
  }
2243
- function c_(_) {
2244
- let n = _.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
2245
- return n = n.replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").toLowerCase(), n = n.replace(/-{2,}/g, "-"), n = n.replace(/^-+|-+$/g, ""), n;
2275
+ function ca(a) {
2276
+ let _ = a.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
2277
+ return _ = _.replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").toLowerCase(), _ = _.replace(/-{2,}/g, "-"), _ = _.replace(/^-+|-+$/g, ""), _;
2246
2278
  }
2247
- const r_ = (_) => {
2248
- const { cashPrice: n, numberInstallments: e, fees: s = 0.0349 } = _;
2249
- if (s === 0 || e === 1)
2250
- return {
2251
- totalPrice: n,
2252
- installmentPrice: n / e
2253
- };
2254
- if (e <= 0)
2255
- throw new Error("Number of installments must be greater than 0");
2256
- if (s < 0)
2257
- throw new Error("Fees must be greater than or equal to 0");
2258
- let a = 0, o = 0, c = Math.pow(1 + s, e) * s, r = Math.pow(1 + s, e) - 1;
2259
- return a = n * (c / r), o = e * a, {
2260
- totalPrice: +o.toFixed(2),
2261
- installmentPrice: +a.toFixed(2)
2262
- };
2263
- }, i_ = (_) => {
2264
- const n = _.startsWith("'") && _.endsWith("'"), e = _.startsWith('"') && _.endsWith('"');
2265
- return n || e ? _ : `"${_}"`;
2266
- };
2267
- function l_(_) {
2268
- return /<\/?[a-z][\s\S]*>/i.test(_);
2279
+ function ra([a, _ = "00:00:00"], s, n = 0) {
2280
+ const e = new I();
2281
+ e.validateInputFormat(s);
2282
+ const t = a.split(/[-/]/).map(Number), c = _.split(".")[0].split(":").map(Number);
2283
+ let i, o, r;
2284
+ const [g = 0, h = 0, C = 0] = c;
2285
+ switch (s) {
2286
+ case "brazilianDate":
2287
+ [i, o, r] = t, e.validateDateParts(r, o, i);
2288
+ break;
2289
+ case "isoDate":
2290
+ [o, i, r] = t, e.validateDateParts(r, o, i);
2291
+ break;
2292
+ case "timestamp":
2293
+ [r, o, i] = t, e.validateDateParts(r, o, i);
2294
+ break;
2295
+ }
2296
+ const m = new Date(
2297
+ Date.UTC(r, o - 1, i, g, h, C)
2298
+ );
2299
+ if (isNaN(m.getTime())) throw new Error("Invalid date");
2300
+ return m.setUTCHours(m.getUTCHours() + n), m;
2269
2301
  }
2270
- const u_ = (_, n = ["password", "confirmPassword", "creditCard"]) => {
2271
- function e(a, o) {
2272
- return n.includes(a) ? "****" : o;
2302
+ function ia(a, _ = 1e3) {
2303
+ function s(e) {
2304
+ return typeof e == "string" && e.length > _ ? `To large information: field as ${e.length} characters` : e;
2273
2305
  }
2274
- function s(a) {
2275
- return Array.isArray(a) ? a.map((o) => s(o)) : a !== null && typeof a == "object" ? Object.keys(a).reduce((o, c) => {
2276
- let r = a[c];
2277
- if (typeof r == "string")
2278
- try {
2279
- const t = JSON.parse(r);
2280
- typeof t == "object" && (r = JSON.stringify(s(t)));
2281
- } catch {
2282
- }
2283
- return o[c] = s(e(c, r)), o;
2284
- }, {}) : a;
2306
+ function n(e) {
2307
+ return Array.isArray(e) ? e.map((t) => n(t)) : e !== null && typeof e == "object" ? Object.fromEntries(
2308
+ Object.entries(e).map(([t, c]) => [
2309
+ t,
2310
+ n(c)
2311
+ ])
2312
+ ) : s(e);
2285
2313
  }
2286
2314
  try {
2287
- const a = JSON.parse(_), o = s(a);
2288
- return JSON.stringify(o);
2315
+ const e = JSON.parse(a), t = n(e);
2316
+ return JSON.stringify(t);
2289
2317
  } catch {
2290
- return _;
2318
+ throw new Error("Invalid JSON string");
2291
2319
  }
2292
- }, g_ = (_) => _.replace(/<\/?[^>]+(>|$)/g, ""), m_ = (_, n = 1e3) => {
2293
- function e(a) {
2294
- return typeof a == "string" && a.length > n ? `To large information: field as ${a.length} characters` : a;
2320
+ }
2321
+ function la(a, _ = ["password", "confirmPassword", "creditCard"]) {
2322
+ function s(e, t) {
2323
+ return _.includes(e) ? "****" : t;
2295
2324
  }
2296
- function s(a) {
2297
- return Array.isArray(a) ? a.map((o) => s(o)) : a !== null && typeof a == "object" ? Object.fromEntries(
2298
- Object.entries(a).map(([o, c]) => [
2299
- o,
2300
- s(c)
2301
- // Corrigido para aplicar recursão corretamente
2302
- ])
2303
- ) : e(a);
2325
+ function n(e) {
2326
+ return Array.isArray(e) ? e.map((t) => n(t)) : e !== null && typeof e == "object" ? Object.keys(e).reduce((t, c) => {
2327
+ let i = e[c];
2328
+ if (typeof i == "string")
2329
+ try {
2330
+ const o = JSON.parse(i);
2331
+ typeof o == "object" && (i = JSON.stringify(n(o)));
2332
+ } catch {
2333
+ }
2334
+ return t[c] = n(s(c, i)), t;
2335
+ }, {}) : e;
2304
2336
  }
2305
2337
  try {
2306
- const a = JSON.parse(_), o = s(a);
2307
- return JSON.stringify(o);
2338
+ const e = JSON.parse(a), t = n(e);
2339
+ return JSON.stringify(t);
2308
2340
  } catch {
2309
- throw new Error("Invalid JSON string");
2341
+ return a;
2310
2342
  }
2311
- };
2343
+ }
2344
+ function ua(a) {
2345
+ const { cashPrice: _, numberInstallments: s, fees: n = 0.0349 } = a;
2346
+ if (n === 0 || s === 1)
2347
+ return {
2348
+ totalPrice: _,
2349
+ installmentPrice: _ / s
2350
+ };
2351
+ if (s <= 0)
2352
+ throw new Error("Number of installments must be greater than 0");
2353
+ if (n < 0)
2354
+ throw new Error("Fees must be greater than or equal to 0");
2355
+ let e = Math.pow(1 + n, s) * n, t = Math.pow(1 + n, s) - 1;
2356
+ const c = +(_ * (e / t)).toFixed(2);
2357
+ return {
2358
+ totalPrice: +(+(c * s).toFixed(2)).toFixed(2),
2359
+ installmentPrice: +c.toFixed(2)
2360
+ };
2361
+ }
2362
+ function ga(a) {
2363
+ const _ = a.startsWith("'") && a.endsWith("'"), s = a.startsWith('"') && a.endsWith('"');
2364
+ return _ || s ? a : `"${a}"`;
2365
+ }
2366
+ function ma(a) {
2367
+ return /<\/?[a-z][\s\S]*>/i.test(a);
2368
+ }
2369
+ function ka(a) {
2370
+ return a.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<\/?[a-z][a-z0-9]*[^>]*>/gi, "");
2371
+ }
2312
2372
  export {
2313
- r_ as calculateCardInstallment,
2314
- i_ as ensureQuotes,
2373
+ I as ValidateDateService,
2374
+ ua as calculateCardInstallment,
2375
+ ga as ensureQuotes,
2315
2376
  Z as formatDate,
2316
- f as formatJsonObject,
2377
+ y as formatJsonObject,
2317
2378
  q as formatJsonString,
2318
2379
  j as formatToCapitalizeFirstWordLetter,
2319
2380
  Q as formatToCep,
2320
- D as formatToCnpj,
2321
- L as formatToCpf,
2322
- X as formatToCpfCnpj,
2323
- __ as formatToCurrency,
2324
- n_ as formatToDate,
2325
- a_ as formatToEllipsis,
2326
- s_ as formatToHiddenDigits,
2327
- e_ as formatToPhone,
2328
- o_ as generateColorByString,
2329
- t_ as generateId,
2330
- c_ as generateSlug,
2331
- l_ as isHtml,
2332
- u_ as maskSensitiveData,
2333
- R as removeCurrencySymbols,
2334
- g as removeNonNumeric,
2335
- g_ as stripHtmlTags,
2336
- m_ as truncateLargeFields
2381
+ X as formatToCnpj,
2382
+ aa as formatToCpf,
2383
+ _a as formatToCurrency,
2384
+ na as formatToEllipsis,
2385
+ sa as formatToHiddenDigits,
2386
+ ea as formatToPhone,
2387
+ ta as generateColorByString,
2388
+ oa as generateId,
2389
+ ca as generateSlug,
2390
+ ma as isHtml,
2391
+ ia as parseLargeFields,
2392
+ la as parseSensitiveData,
2393
+ ra as parseToDate,
2394
+ L as removeCurrencySymbols,
2395
+ k as removeNonNumeric,
2396
+ ka as stripHtmlTags
2337
2397
  };