@primoui/utils 1.4.0 → 1.4.2

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.
@@ -15,9 +15,10 @@ export declare const formatNumber: (number: number, notation?: Notation, locale?
15
15
  * Formats a given amount of money into a currency string.
16
16
  * @param amount The amount of money to format.
17
17
  * @param currency The currency to format the amount in. Defaults to 'USD'.
18
+ * @param locale - The locale to use for formatting. Defaults to 'en-US'.
18
19
  * @returns The formatted currency string.
19
20
  */
20
- export declare const formatCurrency: (amount: number, currency?: Currency) => string;
21
+ export declare const formatCurrency: (amount: number, currency?: Currency, locale?: string) => string;
21
22
  /**
22
23
  * Formats a given amount with an interval
23
24
  * @param amount The amount of money to format.
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AACpD,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,WAAU,QAAoB,EAAE,eAAgB,WAI5F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,WAAU,QAAgB,WAOxE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,EAAE,WAAU,OAAO,GAAG,MAAgB,WAExF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,kBAAa,KAAG,MAEhE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,kBAAa,KAAG,MAc1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,SAY1D,CAAA"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AACpD,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,WAAU,QAAoB,EAAE,eAAgB,WAI5F,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,WAAU,QAAgB,EAAE,eAAgB,WAO1F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,EAAE,WAAU,OAAO,GAAG,MAAgB,WAExF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,kBAAa,KAAG,MAEhE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,kBAAa,KAAG,MAc1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,SAY1D,CAAA"}
@@ -78,8 +78,10 @@ export declare const setQueryParams: (url: string, params: Record<string, string
78
78
  export declare const removeQueryParams: (url?: string) => string;
79
79
  /** Options for checkUrlAvailability */
80
80
  export type CheckUrlAvailabilityOptions = {
81
- /** Request timeout in milliseconds */
81
+ /** Request timeout in milliseconds (default: 5000) */
82
82
  timeout?: number;
83
+ /** HTTP status codes below this value are considered successful (default: 400) */
84
+ successStatusBelow?: number;
83
85
  /** User-Agent header to send with requests */
84
86
  userAgent?: string;
85
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http/http.ts"],"names":[],"mappings":"A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hD,CAAA;AAED,uCAAuC;AACvC,MAAM,MAAM,2BAA2B,GAAG;IACxC,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,MAAM,EACX,UAAS,2BAAgC,KACxC,OAAO,CAAC,OAAO,CAwCjB,CAAA"}
package/dist/index.js CHANGED
@@ -1,66 +1,66 @@
1
- import p from "@sindresorhus/slugify";
2
- const B = (t, e) => {
1
+ import d from "@sindresorhus/slugify";
2
+ const F = (t, e) => {
3
3
  const r = e - t + 1;
4
4
  return Array.from({ length: r }, (n, s) => s + t);
5
- }, g = async (t) => new Promise((e) => setTimeout(e, t)), x = ({ key: t, metaKey: e }) => `${e ? "⌘" : ""}${t.toUpperCase()}`, d = (t) => t.replace(/<[^>]*>?/gm, ""), y = (t, e = " ") => t.replace(/\n+/g, e), F = (t, e = 250) => {
5
+ }, y = async (t) => new Promise((e) => setTimeout(e, t)), j = ({ key: t, metaKey: e }) => `${e ? "⌘" : ""}${t.toUpperCase()}`, w = (t) => t.replace(/<[^>]*>?/gm, ""), b = (t, e = " ") => t.replace(/\n+/g, e), z = (t, e = 250) => {
6
6
  if (!t)
7
7
  return null;
8
- const r = y(d(t)), n = r.slice(0, e).trim();
8
+ const r = b(w(t)), n = r.slice(0, e).trim();
9
9
  return n.length < r.length ? `${n}...` : n;
10
- }, j = (t, e = !1) => p(t, {
10
+ }, W = (t, e = !1) => d(t, {
11
11
  decamelize: e,
12
12
  customReplacements: [
13
13
  ["#", "sharp"],
14
14
  ["+", "plus"]
15
15
  ]
16
- }), z = (t) => t.length === 25 && t[0] === "c", w = (t) => !!t, W = (t, e = 0) => {
16
+ }), K = (t) => t.length === 25 && t[0] === "c", U = (t) => !!t, J = (t, e = 0) => {
17
17
  const r = (t || "").trim();
18
18
  if (r.length === 0 || r.length === 1 || r.length === 2)
19
19
  return r.toUpperCase();
20
- const s = r.split(" ").filter(w).map((o) => o.charAt(0).toUpperCase()).join("");
20
+ const s = r.split(" ").filter(U).map((o) => o.charAt(0).toUpperCase()).join("");
21
21
  return e > 0 ? s.slice(0, e) : s;
22
- }, K = (t) => new Promise((e, r) => {
22
+ }, V = (t) => new Promise((e, r) => {
23
23
  const n = new FileReader();
24
24
  n.readAsDataURL(t), n.onload = () => e(n.result), n.onerror = (s) => r(s);
25
- }), b = (t, e) => {
25
+ }), M = (t, e) => {
26
26
  const r = [];
27
27
  for (let n = 0; n < t.length; n += e)
28
28
  r.push(t.slice(n, n + e));
29
29
  return r;
30
- }, J = (t, e, r = !1) => {
30
+ }, H = (t, e, r = !1) => {
31
31
  Object.getOwnPropertyDescriptor(
32
32
  HTMLInputElement.prototype,
33
33
  "value"
34
34
  )?.set?.call(t, e), r && t?.dispatchEvent(new Event("input", { bubbles: !0 }));
35
- }, V = (t, e = 3, r = "and") => t.slice(0, e).join(", ").replace(/, ([^,]*)$/, ` ${r} $1`), H = async (t) => {
35
+ }, Z = (t, e = 3, r = "and") => t.slice(0, e).join(", ").replace(/, ([^,]*)$/, ` ${r} $1`), G = async (t) => {
36
36
  try {
37
37
  return { data: await t, error: null };
38
38
  } catch (e) {
39
39
  return { data: null, error: e };
40
40
  }
41
- }, U = (t) => {
41
+ }, E = (t) => {
42
42
  if (t !== null) {
43
43
  if (t?.constructor.name === "Object")
44
44
  for (const e in t)
45
- t[e] = U(t[e]);
45
+ t[e] = E(t[e]);
46
46
  return t;
47
47
  }
48
- }, Z = (t, e) => e.some((r) => {
48
+ }, Q = (t, e) => e.some((r) => {
49
49
  const [n, s] = t.split("/"), [o, c] = r.split("/");
50
50
  return n !== o ? !1 : c === "*" ? !0 : s === c;
51
- }), M = async (t, e, r) => {
51
+ }), S = async (t, e, r) => {
52
52
  const { batchSize: n, concurrency: s = n, delay: o = 0 } = r;
53
53
  if (t.length === 0) return [];
54
- const c = [], a = b(t, n);
54
+ const c = [], a = M(t, n);
55
55
  for (const [i, u] of a.entries()) {
56
56
  console.log(`Processing batch ${i + 1}/${a.length} (${u.length} items)`);
57
- const f = await E(u, e, s);
58
- c.push(...f), o > 0 && i < a.length - 1 && (console.log(`Waiting ${o}ms before next batch...`), await g(o));
57
+ const l = await R(u, e, s);
58
+ c.push(...l), o > 0 && i < a.length - 1 && (console.log(`Waiting ${o}ms before next batch...`), await y(o));
59
59
  }
60
60
  return c;
61
- }, G = async (t, e, r) => {
61
+ }, _ = async (t, e, r) => {
62
62
  const { onError: n } = r;
63
- return M(t, async (o) => {
63
+ return S(t, async (o) => {
64
64
  try {
65
65
  return await e(o);
66
66
  } catch (c) {
@@ -68,7 +68,7 @@ const B = (t, e) => {
68
68
  return n?.(a, o), a;
69
69
  }
70
70
  }, r);
71
- }, E = async (t, e, r) => {
71
+ }, R = async (t, e, r) => {
72
72
  if (r >= t.length)
73
73
  return Promise.all(t.map(e));
74
74
  const n = [], s = [];
@@ -79,42 +79,42 @@ const B = (t, e) => {
79
79
  s.push(c), s.length >= r && (await Promise.race(s), s.splice(0, s.length - s.filter((a) => a !== c).length));
80
80
  }
81
81
  return await Promise.all(s), n;
82
- }, Q = (t) => {
82
+ }, q = (t) => {
83
83
  const e = t.replace("#", "").substring(0, 6), r = Number.parseInt(e.substring(0, 2), 16), n = Number.parseInt(e.substring(2, 4), 16), s = Number.parseInt(e.substring(4, 6), 16);
84
84
  return r * 0.299 + n * 0.587 + s * 0.114 > 186;
85
- }, _ = (t) => {
85
+ }, Y = (t) => {
86
86
  const e = document.getElementById(t || "");
87
87
  if (!e) return;
88
88
  const r = window.getComputedStyle(e), n = Number.parseFloat(r.scrollMarginTop), s = Math.floor(window.scrollY + e.getBoundingClientRect().top - n);
89
89
  return { id: t, top: s };
90
- }, S = (t) => typeof t == "object" && t !== null && "message" in t && typeof t.message == "string", R = (t) => {
91
- if (S(t)) return t;
90
+ }, P = (t) => typeof t == "object" && t !== null && "message" in t && typeof t.message == "string", N = (t) => {
91
+ if (P(t)) return t;
92
92
  try {
93
93
  return new Error(JSON.stringify(t));
94
94
  } catch {
95
95
  return new Error(String(t));
96
96
  }
97
- }, Y = (t) => R(t).message, q = (t, e) => {
97
+ }, X = (t) => N(t).message, tt = (t, e) => {
98
98
  document.addEventListener(t, e);
99
- }, X = (t, e) => {
99
+ }, et = (t, e) => {
100
100
  document.removeEventListener(t, e);
101
- }, tt = (t, e) => {
101
+ }, rt = (t, e) => {
102
102
  const r = new CustomEvent(t, { detail: e });
103
103
  document.dispatchEvent(r);
104
- }, et = () => {
104
+ }, nt = () => {
105
105
  const t = new KeyboardEvent("keydown", { key: "Escape" });
106
106
  document.dispatchEvent(t);
107
- }, rt = (t, e = "compact", r = "en-US") => new Intl.NumberFormat(r, { notation: e }).format(t), nt = (t, e = "USD") => new Intl.NumberFormat("en-US", {
107
+ }, st = (t, e = "compact", r = "en-US") => new Intl.NumberFormat(r, { notation: e }).format(t), ot = (t, e = "USD", r = "en-US") => new Intl.NumberFormat(r, {
108
108
  style: "currency",
109
109
  currency: e
110
- }).format(t).replace(/\D00(?=\D*$)/, ""), st = (t, e = "month") => h(t / (e === "year" ? 12 : 1), 2), h = (t, e = 0) => t.toFixed(e < 0 ? 0 : e).replace(/\.0+$/, ""), ot = (t, e = 0) => {
110
+ }).format(t).replace(/\D00(?=\D*$)/, ""), ct = (t, e = "month") => f(t / (e === "year" ? 12 : 1), 2), f = (t, e = 0) => t.toFixed(e < 0 ? 0 : e).replace(/\.0+$/, ""), at = (t, e = 0) => {
111
111
  if (t < 1024) {
112
112
  const c = 10 ** e;
113
113
  return `${Math.floor(t / 1024 * c) / c} KB`;
114
114
  }
115
115
  const n = Math.floor(Math.log(t) / Math.log(1024));
116
- return `${h(t / 1024 ** n, e)} ${["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][n]}`;
117
- }, ct = (t) => {
116
+ return `${f(t / 1024 ** n, e)} ${["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][n]}`;
117
+ }, it = (t) => {
118
118
  const [, e] = t.split("/");
119
119
  let r;
120
120
  switch (e) {
@@ -124,14 +124,14 @@ const B = (t, e) => {
124
124
  r = e;
125
125
  }
126
126
  return r?.toUpperCase();
127
- }, P = /^https?:\/\/(?:www\.)?(?:[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,63}\b|localhost(?::\d+)?|127\.0\.0\.1(?::\d+)?)(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/, T = (t) => {
128
- if (!t || typeof t != "string" || !P.test(t)) return !1;
127
+ }, v = /^https?:\/\/(?:www\.)?(?:[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,63}\b|localhost(?::\d+)?|127\.0\.0\.1(?::\d+)?)(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/, I = (t) => {
128
+ if (!t || typeof t != "string" || !v.test(t)) return !1;
129
129
  try {
130
130
  return new URL(t), !0;
131
131
  } catch {
132
132
  return !1;
133
133
  }
134
- }, I = (t, e) => t ? t.startsWith("http://") || t.startsWith("https://") ? t : `${e !== void 0 ? e ? "https" : "http" : N(t) ? "http" : "https"}://${t}` : "", at = (t) => t?.replace(/^https?:\/\//, "") ?? "", l = (t) => {
134
+ }, T = (t, e) => t ? t.startsWith("http://") || t.startsWith("https://") ? t : `${e !== void 0 ? e ? "https" : "http" : D(t) ? "http" : "https"}://${t}` : "", ut = (t) => t?.replace(/^https?:\/\//, "") ?? "", h = (t) => {
135
135
  if (!t) return "";
136
136
  let e = t.trim();
137
137
  if (e.includes("?") || e.includes("#"))
@@ -142,39 +142,39 @@ const B = (t, e) => {
142
142
  return e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e;
143
143
  }
144
144
  return e.length > 1 && e.endsWith("/") && (e = e.slice(0, -1)), e;
145
- }, it = (t) => {
145
+ }, lt = (t) => {
146
146
  try {
147
147
  const e = new URL(t);
148
148
  return `${e.protocol}//${e.host}`;
149
149
  } catch {
150
150
  return t;
151
151
  }
152
- }, ut = (t) => {
152
+ }, ht = (t) => {
153
153
  try {
154
- if (!T(t)) return t;
154
+ if (!I(t)) return t;
155
155
  const e = new URL(t).hostname;
156
156
  return e.startsWith("www.") ? e.slice(4) : e;
157
157
  } catch {
158
158
  return t;
159
159
  }
160
- }, lt = (t) => t ? /^https?:\/\//.test(t) : !1, N = (t) => {
160
+ }, mt = (t) => t ? /^https?:\/\//.test(t) : !1, D = (t) => {
161
161
  if (!t) return !1;
162
162
  try {
163
- const r = new URL(I(t)).hostname;
163
+ const r = new URL(T(t)).hostname;
164
164
  return r === "localhost" || r === "127.0.0.1" || r.endsWith(".localhost");
165
165
  } catch {
166
166
  return t.includes("localhost") || t.includes("127.0.0.1");
167
167
  }
168
- }, ht = (t, ...e) => {
168
+ }, ft = (t, ...e) => {
169
169
  if (!t) return "";
170
- let r = l(t);
170
+ let r = h(t);
171
171
  for (const n of e) {
172
172
  if (!n) continue;
173
173
  const s = n.replace(/^\/+|\/+$/g, "");
174
174
  s && (r += `/${s}`);
175
175
  }
176
176
  return r;
177
- }, v = (t) => {
177
+ }, O = (t) => {
178
178
  try {
179
179
  const e = new URL(t), r = {};
180
180
  return e.searchParams.forEach((n, s) => {
@@ -183,7 +183,7 @@ const B = (t, e) => {
183
183
  } catch {
184
184
  return {};
185
185
  }
186
- }, mt = (t, e) => {
186
+ }, pt = (t, e) => {
187
187
  try {
188
188
  const r = new URL(t);
189
189
  Object.entries(e).forEach(([s, o]) => {
@@ -194,164 +194,157 @@ const B = (t, e) => {
194
194
  } catch {
195
195
  return t;
196
196
  }
197
- }, ft = (t) => {
197
+ }, gt = (t) => {
198
198
  if (!t) return "";
199
199
  try {
200
200
  const e = new URL(t);
201
- return e.search = "", l(e.toString());
201
+ return e.search = "", h(e.toString());
202
202
  } catch {
203
203
  const e = t.indexOf("?");
204
204
  return e !== -1 ? t.substring(0, e) : t;
205
205
  }
206
- }, pt = async (t, e = {}) => {
206
+ }, dt = async (t, e = {}) => {
207
207
  if (!t)
208
208
  return !1;
209
- const { timeout: r = 5e3, userAgent: n = "Mozilla/5.0 (compatible; URLChecker/1.0)" } = e;
210
- try {
211
- const s = l(t), o = new AbortController(), c = setTimeout(() => o.abort(), r);
209
+ const {
210
+ timeout: r = 5e3,
211
+ successStatusBelow: n = 400,
212
+ userAgent: s = "Mozilla/5.0 (compatible; URLChecker/1.0)"
213
+ } = e, o = h(t), c = async (u) => {
214
+ const l = new AbortController(), m = setTimeout(() => l.abort(), r);
212
215
  try {
213
- const a = await fetch(s, {
214
- method: "HEAD",
215
- signal: o.signal,
216
+ const g = await fetch(o, {
217
+ method: u,
218
+ signal: l.signal,
216
219
  redirect: "follow",
217
- headers: { "User-Agent": n }
220
+ headers: { "User-Agent": s }
218
221
  });
219
- return clearTimeout(c), a.status < 400;
222
+ return clearTimeout(m), g;
220
223
  } catch {
221
- clearTimeout(c);
222
- const a = new AbortController(), i = setTimeout(() => a.abort(), r);
223
- try {
224
- const u = await fetch(s, {
225
- method: "GET",
226
- signal: a.signal,
227
- redirect: "follow",
228
- headers: { "User-Agent": n }
229
- });
230
- return clearTimeout(i), u.status < 400;
231
- } catch {
232
- return clearTimeout(i), !1;
233
- }
224
+ return clearTimeout(m), null;
234
225
  }
235
- } catch {
236
- return !1;
237
- }
238
- }, gt = (t, e, r) => e !== void 0 && r !== void 0 ? Math.min(Math.max(t, e), r) : e !== void 0 ? Math.max(t, e) : r !== void 0 ? Math.min(t, r) : t, dt = (t) => {
226
+ }, a = await c("HEAD");
227
+ if (a && a.status < n)
228
+ return !0;
229
+ const i = await c("GET");
230
+ return i !== null && i.status < n;
231
+ }, yt = (t, e, r) => e !== void 0 && r !== void 0 ? Math.min(Math.max(t, e), r) : e !== void 0 ? Math.max(t, e) : r !== void 0 ? Math.min(t, r) : t, wt = (t) => {
239
232
  if (t == null) return;
240
233
  const e = Number.parseFloat(t.toString());
241
234
  return Number.isNaN(e) ? void 0 : e;
242
- }, yt = (t, e = 2) => {
243
- const r = Math.pow(10, e);
235
+ }, bt = (t, e = 2) => {
236
+ const r = 10 ** e;
244
237
  return Math.round((t + Number.EPSILON) * r) / r;
245
- }, wt = (t = {}) => t.constructor === Object && !Object.entries(t).length, bt = (t, e) => t in e, Ut = (t) => (e, r) => {
238
+ }, Ut = (t = {}) => t.constructor === Object && !Object.entries(t).length, Mt = (t, e) => t in e, Et = (t) => (e, r) => {
246
239
  const n = t.indexOf(Object.keys(e)[0] ?? ""), s = t.indexOf(Object.keys(r)[0] ?? "");
247
240
  return n === -1 && s === -1 ? 0 : n === -1 ? 1 : s === -1 ? -1 : n - s;
248
- }, Mt = (t, e) => Object.keys(t).sort(e).reduce((r, n) => ({ ...r, [n]: t[n] }), {}), Et = (t, e) => {
241
+ }, St = (t, e) => Object.keys(t).sort(e).reduce((r, n) => ({ ...r, [n]: t[n] }), {}), Rt = (t, e) => {
249
242
  const r = {};
250
243
  for (const n of e)
251
244
  n in t && (r[n] = t[n]);
252
245
  return r;
253
- }, D = (t) => Math.max(t && !Number.isNaN(Number(t)) ? Number.parseInt(t || "1", 10) : 1, 1), St = (t, e) => {
254
- const { page: r, ...n } = v(t), o = (D(r) - 1) * e;
246
+ }, $ = (t) => Math.max(t && !Number.isNaN(Number(t)) ? Number.parseInt(t || "1", 10) : 1, 1), Pt = (t, e) => {
247
+ const { page: r, ...n } = O(t), o = ($(r) - 1) * e;
255
248
  return { take: e, skip: o, ...n };
256
- }, Rt = (t, e, r) => (t.set("page", r.toString()), `${e}?${t.toString()}`), Pt = (t) => {
249
+ }, Nt = (t, e, r) => (t.set("page", r.toString()), `${e}?${t.toString()}`), vt = (t) => {
257
250
  try {
258
251
  return JSON.parse(t);
259
252
  } catch {
260
253
  return t;
261
254
  }
262
- }, Tt = (t) => typeof t == "object" ? JSON.stringify(t) : t, It = () => Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"), Nt = (t = 16) => {
255
+ }, It = (t) => typeof t == "object" ? JSON.stringify(t) : t, Tt = () => Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"), Dt = (t = 16) => {
263
256
  const e = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
264
257
  return Array.from({ length: t }, () => e[Math.floor(Math.random() * e.length)]).join("");
265
- }, vt = (t, e) => Math.floor(Math.random() * (e - t + 1)) + t, Dt = (t) => Array.from({ length: t }, () => Math.floor(Math.random() * 10)).join(""), Ot = (t) => {
258
+ }, Ot = (t, e) => Math.floor(Math.random() * (e - t + 1)) + t, $t = (t) => Array.from({ length: t }, () => Math.floor(Math.random() * 10)).join(""), Lt = (t) => {
266
259
  const e = Math.floor(Math.random() * t.length);
267
260
  return t[e];
268
- }, $t = (t) => {
261
+ }, kt = (t) => {
269
262
  const e = Object.keys(t), r = e[Math.floor(e.length * Math.random())];
270
263
  return t[r];
271
- }, Ct = (t) => typeof t != "string" ? "" : t.length === 0 ? t : t[0]?.toUpperCase() + t.slice(1), Lt = (t) => typeof t != "string" ? "" : t.length === 0 ? t : t[0]?.toLowerCase() + t.slice(1), m = (t, e) => new Intl.DateTimeFormat(t, { dateStyle: e }), O = (t, e) => new Intl.DateTimeFormat(t, { timeStyle: e }), $ = (t, e, r) => new Intl.DateTimeFormat(t, { dateStyle: e, timeStyle: r }), C = (t, e = "medium", r = "en-US") => m(r, e).format(new Date(t)), L = (t, e = "short", r = "en-US") => O(r, e).format(new Date(t)), k = (t, e = "medium", r = "short", n = "en-US") => $(n, e, r).format(new Date(t)), kt = (t, e, r = "medium", n = "short", s = "en-US") => {
264
+ }, Ct = (t) => typeof t != "string" ? "" : t.length === 0 ? t : t[0]?.toUpperCase() + t.slice(1), Bt = (t) => typeof t != "string" ? "" : t.length === 0 ? t : t[0]?.toLowerCase() + t.slice(1), p = (t, e) => new Intl.DateTimeFormat(t, { dateStyle: e }), L = (t, e) => new Intl.DateTimeFormat(t, { timeStyle: e }), k = (t, e, r) => new Intl.DateTimeFormat(t, { dateStyle: e, timeStyle: r }), C = (t, e = "medium", r = "en-US") => p(r, e).format(new Date(t)), B = (t, e = "short", r = "en-US") => L(r, e).format(new Date(t)), x = (t, e = "medium", r = "short", n = "en-US") => k(n, e, r).format(new Date(t)), xt = (t, e, r = "medium", n = "short", s = "en-US") => {
272
265
  switch (e) {
273
266
  case "date":
274
267
  return C(t, r, s);
275
268
  case "time":
276
- return L(t, n, s);
269
+ return B(t, n, s);
277
270
  default:
278
- return k(t, r, n, s);
271
+ return x(t, r, n, s);
279
272
  }
280
- }, At = (t, e, r = "medium", n = "en-US") => m(n, r).formatRange(new Date(t), new Date(e)), Bt = (t, e = 265) => t ? Math.ceil(t.trim().split(/\s+/).length / e) : 0;
273
+ }, At = (t, e, r = "medium", n = "en-US") => p(n, r).formatRange(new Date(t), new Date(e)), Ft = (t, e = 265) => t ? Math.ceil(t.trim().split(/\s+/).length / e) : 0;
281
274
  export {
282
- I as addProtocol,
283
- pt as checkUrlAvailability,
284
- y as convertNewlines,
285
- ot as formatBytes,
286
- nt as formatCurrency,
275
+ T as addProtocol,
276
+ dt as checkUrlAvailability,
277
+ b as convertNewlines,
278
+ at as formatBytes,
279
+ ot as formatCurrency,
287
280
  C as formatDate,
288
- kt as formatDateOrTime,
281
+ xt as formatDateOrTime,
289
282
  At as formatDateRange,
290
- k as formatDateTime,
291
- st as formatIntervalAmount,
292
- ct as formatMimeType,
293
- rt as formatNumber,
294
- L as formatTime,
295
- h as formatToDecimals,
296
- it as getBaseUrl,
297
- D as getCurrentPage,
298
- ut as getDomain,
299
- _ as getElementPosition,
300
- Y as getErrorMessage,
301
- F as getExcerpt,
302
- W as getInitials,
303
- Rt as getPageLink,
304
- St as getPageParams,
305
- v as getQueryParams,
306
- It as getRandomColor,
307
- Dt as getRandomDigits,
308
- Ot as getRandomElement,
309
- vt as getRandomNumber,
310
- $t as getRandomProperty,
311
- Nt as getRandomString,
312
- Bt as getReadTime,
313
- x as getShortcutLabel,
314
- z as isCuid,
315
- wt as isEmptyObject,
316
- S as isErrorWithMessage,
317
- lt as isExternalUrl,
318
- bt as isKeyInObject,
319
- Q as isLightColor,
320
- N as isLocalhostUrl,
321
- Z as isMimeTypeMatch,
322
- w as isTruthy,
323
- T as isValidUrl,
324
- V as joinAsSentence,
325
- ht as joinUrlPaths,
326
- gt as keepNumberInRange,
327
- Lt as lcFirst,
328
- Pt as maybeParseJson,
329
- Tt as maybeStringifyJson,
330
- l as normalizeUrl,
331
- U as nullsToUndefined,
332
- dt as parseNumericValue,
333
- Et as pickFromObject,
334
- yt as preciseRound,
335
- M as processBatch,
336
- G as processBatchWithErrorHandling,
337
- tt as publish,
338
- et as publishEscape,
339
- B as range,
340
- at as removeProtocol,
341
- ft as removeQueryParams,
342
- J as setInputValue,
343
- mt as setQueryParams,
344
- g as sleep,
345
- j as slugify,
346
- Mt as sortObject,
347
- Ut as sortObjectKeys,
348
- b as splitArrayIntoChunks,
349
- d as stripHtml,
350
- q as subscribe,
351
- K as toBase64,
352
- R as toErrorWithMessage,
353
- H as tryCatch,
283
+ x as formatDateTime,
284
+ ct as formatIntervalAmount,
285
+ it as formatMimeType,
286
+ st as formatNumber,
287
+ B as formatTime,
288
+ f as formatToDecimals,
289
+ lt as getBaseUrl,
290
+ $ as getCurrentPage,
291
+ ht as getDomain,
292
+ Y as getElementPosition,
293
+ X as getErrorMessage,
294
+ z as getExcerpt,
295
+ J as getInitials,
296
+ Nt as getPageLink,
297
+ Pt as getPageParams,
298
+ O as getQueryParams,
299
+ Tt as getRandomColor,
300
+ $t as getRandomDigits,
301
+ Lt as getRandomElement,
302
+ Ot as getRandomNumber,
303
+ kt as getRandomProperty,
304
+ Dt as getRandomString,
305
+ Ft as getReadTime,
306
+ j as getShortcutLabel,
307
+ K as isCuid,
308
+ Ut as isEmptyObject,
309
+ P as isErrorWithMessage,
310
+ mt as isExternalUrl,
311
+ Mt as isKeyInObject,
312
+ q as isLightColor,
313
+ D as isLocalhostUrl,
314
+ Q as isMimeTypeMatch,
315
+ U as isTruthy,
316
+ I as isValidUrl,
317
+ Z as joinAsSentence,
318
+ ft as joinUrlPaths,
319
+ yt as keepNumberInRange,
320
+ Bt as lcFirst,
321
+ vt as maybeParseJson,
322
+ It as maybeStringifyJson,
323
+ h as normalizeUrl,
324
+ E as nullsToUndefined,
325
+ wt as parseNumericValue,
326
+ Rt as pickFromObject,
327
+ bt as preciseRound,
328
+ S as processBatch,
329
+ _ as processBatchWithErrorHandling,
330
+ rt as publish,
331
+ nt as publishEscape,
332
+ F as range,
333
+ ut as removeProtocol,
334
+ gt as removeQueryParams,
335
+ H as setInputValue,
336
+ pt as setQueryParams,
337
+ y as sleep,
338
+ W as slugify,
339
+ St as sortObject,
340
+ Et as sortObjectKeys,
341
+ M as splitArrayIntoChunks,
342
+ w as stripHtml,
343
+ tt as subscribe,
344
+ V as toBase64,
345
+ N as toErrorWithMessage,
346
+ G as tryCatch,
354
347
  Ct as ucFirst,
355
- X as unsubscribe
348
+ et as unsubscribe
356
349
  };
357
350
  //# sourceMappingURL=index.js.map