@zinaid/str 0.0.1

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/str.js ADDED
@@ -0,0 +1,1096 @@
1
+ import { substr as x, ltrim as j, rtrim as T, plural as Y, randomInt as M, randomString as v, title as D, trim as tt, upper as nt } from "@zinaid/str";
2
+ import { isArray as S, toLower as W, isString as N, isFunction as et } from "@zinaid/utils";
3
+ import rt from "any-ascii";
4
+ import { transliterate as st } from "transliteration";
5
+ import { ulid as K } from "ulid";
6
+ import { validate as ot, NIL as it, MAX as ct, version as lt, v4 as ft, v7 as ut } from "uuid";
7
+ const E = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map();
8
+ let $ = null, L = null, R = null;
9
+ function Z(t, n) {
10
+ if (n === "")
11
+ return t;
12
+ const e = String(n), r = t.indexOf(e);
13
+ return r === -1 ? t : t.slice(r + e.length);
14
+ }
15
+ function _t(t, n) {
16
+ if (n === "")
17
+ return t;
18
+ const e = t.lastIndexOf(String(n));
19
+ return e === -1 ? t : t.slice(e + String(n).length);
20
+ }
21
+ function at(t) {
22
+ return st(t);
23
+ }
24
+ function Ot(t) {
25
+ return rt(t);
26
+ }
27
+ function pt(t, n) {
28
+ if (n === "")
29
+ return t;
30
+ const e = t.indexOf(String(n));
31
+ return e === -1 ? t : t.slice(0, e);
32
+ }
33
+ function gt(t, n) {
34
+ if (n === "")
35
+ return t;
36
+ const e = t.lastIndexOf(String(n));
37
+ return e === -1 ? t : x(t, 0, e);
38
+ }
39
+ function Mt(t, n, e) {
40
+ return n === "" || e === "" ? t : gt(Z(t, n), e);
41
+ }
42
+ function Wt(t, n, e) {
43
+ return n === "" || e === "" ? t : pt(Z(t, n), e);
44
+ }
45
+ function It(t) {
46
+ if (F.has(t))
47
+ return F.get(t);
48
+ const n = $t(B(t));
49
+ return F.set(t, n), n;
50
+ }
51
+ function Pt(t, n) {
52
+ const e = t.length;
53
+ return (n < 0 ? n < -e : n > e - 1) ? !1 : (n < 0 && (n += e), t.charAt(n));
54
+ }
55
+ function qt(t, n) {
56
+ for (const e of S(n) ? n : [n])
57
+ if (t.startsWith(e)) {
58
+ const r = [...t], s = [...e];
59
+ return r.slice(s.length).join("");
60
+ }
61
+ return t;
62
+ }
63
+ function Gt(t, n) {
64
+ for (const e of S(n) ? n : [n])
65
+ if (t.endsWith(e)) {
66
+ const r = [...t], s = [...e];
67
+ return r.slice(0, -s.length).join("");
68
+ }
69
+ return t;
70
+ }
71
+ function J(t, n, e = !1) {
72
+ e && (t = t.toLowerCase());
73
+ let r;
74
+ typeof n == "string" ? r = [n] : r = Array.from(n);
75
+ for (let s of r)
76
+ if (e && (s = s.toLowerCase()), s !== "" && t.includes(s))
77
+ return !0;
78
+ return !1;
79
+ }
80
+ function jt(t, n = "", e = {}) {
81
+ const r = e.radius ?? 100, s = e.omission ?? "...", o = String(t ?? ""), c = n ?? "", i = (w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`^(.*?)(${i(c)})(.*)$`, "iu").exec(o);
82
+ if (!f)
83
+ return null;
84
+ const m = j(f[1] ?? ""), a = Array.from(m).length, u = x(m, Math.max(a - r, 0), r);
85
+ let p = j(u);
86
+ p !== m && (p = s + p);
87
+ const g = T(f[3] ?? ""), h = x(g, 0, r);
88
+ let d = T(h);
89
+ d !== g && (d = d + s);
90
+ const y = f[2] ?? "";
91
+ return p + y + d;
92
+ }
93
+ function Tt(t, n, e = !1) {
94
+ for (const r of n)
95
+ if (!J(t, r, e))
96
+ return !1;
97
+ return !0;
98
+ }
99
+ function Dt(t, n, e = !1) {
100
+ return !J(t, n, e);
101
+ }
102
+ function Kt(t, n = " ") {
103
+ return S(n) ? (n.forEach((e) => {
104
+ t = t.replace(new RegExp(`${e}+`, "g"), e);
105
+ }), t) : t.replace(new RegExp(`${n}+`, "g"), n);
106
+ }
107
+ function I(t, n) {
108
+ if (t === null)
109
+ return !1;
110
+ t = String(t), S(n) ? n = Array.from(n) : n = [String(n)];
111
+ for (const e of n)
112
+ if (e !== "" && t.endsWith(e))
113
+ return !0;
114
+ return !1;
115
+ }
116
+ function Zt(t, n) {
117
+ return !I(t, n);
118
+ }
119
+ function Jt(t, n) {
120
+ const e = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
121
+ return t.replace(new RegExp(`(?:${e})+$`, "u"), "") + n;
122
+ }
123
+ function Bt(t, n, e = null) {
124
+ return n + t + (e ?? n);
125
+ }
126
+ function Ht(t, n, e = null) {
127
+ return q(t, n) && (t = x(t, z(n))), I(t, e ??= n) && (t = x(t, 0, -z(e))), t;
128
+ }
129
+ function Vt(t, n, e = !1) {
130
+ n = String(n);
131
+ let r;
132
+ typeof t == "string" ? r = [t] : r = Array.from(t);
133
+ for (let s of r) {
134
+ if (s = String(s), s === n || e && W(s) === W(n))
135
+ return !0;
136
+ s = s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), s = s.replace(/\\\*/g, ".*");
137
+ const o = e ? "iu" : "u";
138
+ if (new RegExp(`^${s}$`, o).test(n))
139
+ return !0;
140
+ }
141
+ return !1;
142
+ }
143
+ function Xt(t) {
144
+ for (let n = 0; n < t.length; n++)
145
+ if (t.charCodeAt(n) > 127) return !1;
146
+ return !0;
147
+ }
148
+ function Qt(t) {
149
+ if (!N(t))
150
+ return !1;
151
+ try {
152
+ JSON.parse(t);
153
+ } catch {
154
+ return !1;
155
+ }
156
+ return !0;
157
+ }
158
+ function Yt(t, n = []) {
159
+ if (!N(t))
160
+ return !1;
161
+ const r = (n.length === 0 ? "aaa|aaas|about|acap|acct|acd|acr|adiumxtra|adt|afp|afs|aim|amss|android|appdata|apt|ark|attachment|aw|barion|beshare|bitcoin|bitcoincash|blob|bolo|browserext|calculator|callto|cap|cast|casts|chrome|chrome-extension|cid|coap|coap+tcp|coap+ws|coaps|coaps+tcp|coaps+ws|com-eventbrite-attendee|content|conti|crid|cvs|dab|data|dav|diaspora|dict|did|dis|dlna-playcontainer|dlna-playsingle|dns|dntp|dpp|drm|drop|dtn|dvb|ed2k|elsi|example|facetime|fax|feed|feedready|file|filesystem|finger|first-run-pen-experience|fish|fm|ftp|fuchsia-pkg|geo|gg|git|gizmoproject|go|gopher|graph|gtalk|h323|ham|hcap|hcp|http|https|hxxp|hxxps|hydrazone|iax|icap|icon|im|imap|info|iotdisco|ipn|ipp|ipps|irc|irc6|ircs|iris|iris.beep|iris.lwz|iris.xpc|iris.xpcs|isostore|itms|jabber|jar|jms|keyparc|lastfm|ldap|ldaps|leaptofrogans|lorawan|lvlt|magnet|mailserver|mailto|maps|market|message|mid|mms|modem|mongodb|moz|ms-access|ms-browser-extension|ms-calculator|ms-drive-to|ms-enrollment|ms-excel|ms-eyecontrolspeech|ms-gamebarservices|ms-gamingoverlay|ms-getoffice|ms-help|ms-infopath|ms-inputapp|ms-lockscreencomponent-config|ms-media-stream-id|ms-mixedrealitycapture|ms-mobileplans|ms-officeapp|ms-people|ms-project|ms-powerpoint|ms-publisher|ms-restoretabcompanion|ms-screenclip|ms-screensketch|ms-search|ms-search-repair|ms-secondary-screen-controller|ms-secondary-screen-setup|ms-settings|ms-settings-airplanemode|ms-settings-bluetooth|ms-settings-camera|ms-settings-cellular|ms-settings-cloudstorage|ms-settings-connectabledevices|ms-settings-displays-topology|ms-settings-emailandaccounts|ms-settings-language|ms-settings-location|ms-settings-lock|ms-settings-nfctransactions|ms-settings-notifications|ms-settings-power|ms-settings-privacy|ms-settings-proximity|ms-settings-screenrotation|ms-settings-wifi|ms-settings-workplace|ms-spd|ms-sttoverlay|ms-transit-to|ms-useractivityset|ms-virtualtouchpad|ms-visio|ms-walk-to|ms-whiteboard|ms-whiteboard-cmd|ms-word|msnim|msrp|msrps|mss|mtqp|mumble|mupdate|mvn|news|nfs|ni|nih|nntp|notes|ocf|oid|onenote|onenote-cmd|opaquelocktoken|openpgp4fpr|pack|palm|paparazzi|payto|pkcs11|platform|pop|pres|prospero|proxy|pwid|psyc|pttp|qb|query|redis|rediss|reload|res|resource|rmi|rsync|rtmfp|rtmp|rtsp|rtsps|rtspu|s3|secondlife|service|session|sftp|sgn|shttp|sieve|simpleledger|sip|sips|skype|smb|sms|smtp|snews|snmp|soap.beep|soap.beeps|soldat|spiffe|spotify|ssh|steam|stun|stuns|submit|svn|tag|teamspeak|tel|teliaeid|telnet|tftp|tg|things|thismessage|tip|tn3270|tool|ts3server|turn|turns|tv|udp|unreal|urn|ut2004|v-event|vemmi|ventrilo|videotex|vnc|view-source|wais|webcal|wpid|ws|wss|wtai|wyciwyg|xcon|xcon-userid|xfire|xmlrpc.beep|xmlrpc.beeps|xmpp|xri|ymsgr|z39.50|z39.50r|z39.50s" : n.join("|")).split("|").map((o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
162
+ try {
163
+ const c = new URL(t).protocol.replace(":", "");
164
+ if (r.split("|").includes(c))
165
+ return !0;
166
+ } catch {
167
+ }
168
+ const s = [
169
+ "^(",
170
+ r,
171
+ "):\\/\\/",
172
+ "(?:((?:[_.\\p{L}\\p{N}-]|%[0-9A-Fa-f]{2})+:)?((?:[_.\\p{L}\\p{N}-]|%[0-9A-Fa-f]{2})+)@)?",
173
+ "(",
174
+ "(?:[\\p{L}\\p{N}\\p{S}_\\.-]+(?:\\.?([\\p{L}\\p{N}]|xn--[\\p{L}\\p{N}-]+)+\\.?)",
175
+ "|",
176
+ "(?:\\d{1,3}\\.){3}\\d{1,3}",
177
+ "|",
178
+ "\\[(?:[0-9A-Fa-f:.]+)\\]",
179
+ ")",
180
+ "(?::[0-9]+)?",
181
+ '(?:/(?:[\\p{L}\\p{N}\\-._~!$&"()*,;=:@]|%[0-9A-Fa-f]{2})*)*',
182
+ '(?:\\?(?:[\\p{L}\\p{N}\\-._~!$&"()*,;=:@/?\\[\\]]|%[0-9A-Fa-f]{2})*)?',
183
+ '(?:#(?:[\\p{L}\\p{N}\\-._~!$&"()*,;=:@/?]|%[0-9A-Fa-f]{2})*)?',
184
+ "$"
185
+ ].join("");
186
+ try {
187
+ return new RegExp(s, "iu").test(t);
188
+ } catch {
189
+ return !1;
190
+ }
191
+ }
192
+ function vt(t, n = null) {
193
+ return !N(t) || n !== null && !ot(t) ? !1 : n === null ? /^[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}$/.test(
194
+ t
195
+ ) : n === 0 || n === "nil" ? t.toLowerCase() === it : n === "max" ? t.toLowerCase() === ct : n < 1 || n > 8 ? !1 : lt(t) === n;
196
+ }
197
+ function tn(t) {
198
+ if (!N(t))
199
+ return !1;
200
+ const n = t.toUpperCase();
201
+ return /^[0-9A-HJKMNP-TV-Z]{26}$/.test(n);
202
+ }
203
+ function nn(t) {
204
+ return St(t, "-");
205
+ }
206
+ function z(t) {
207
+ return t.length;
208
+ }
209
+ function en(t, n = 100, e = "...", r = !1) {
210
+ if (t.length <= n)
211
+ return t;
212
+ if (!r)
213
+ return t.slice(0, n).replace(/\s+$/, "") + e;
214
+ t = xt(t).replace(/[\n\r]+/g, " ").trim();
215
+ const s = t.slice(0, n).replace(/\s+$/, "");
216
+ return t.substring(n, n + 1) === " " ? s + e : s.replace(/(.*)\s.*/, "$1") + e;
217
+ }
218
+ function P(t) {
219
+ return W(t);
220
+ }
221
+ function rn(t, n = 100, e = "...") {
222
+ if (n <= 0)
223
+ return t;
224
+ const r = n, s = new RegExp(`^\\s*(?:\\S+\\s*){1,${r}}`, "u"), o = t.match(s);
225
+ return !o || z(t) === z(o[0]) ? t : o[0].replace(/\s+$/, "") + e;
226
+ }
227
+ function sn(t, n, e, r = null) {
228
+ if (n === "")
229
+ return t;
230
+ const s = t.length;
231
+ let o = e;
232
+ e < 0 && (o = e < -s ? 0 : s + e);
233
+ const c = t.slice(
234
+ o,
235
+ r !== null ? o + r : void 0
236
+ );
237
+ if (c === "")
238
+ return t;
239
+ const i = t.slice(0, o), l = c.length, f = t.slice(o + l);
240
+ return i + n.slice(0, 1).repeat(l) + f;
241
+ }
242
+ function on(t, n) {
243
+ let e = "u", r = t;
244
+ if (t.length >= 2 && t[0] === "/") {
245
+ let s = -1;
246
+ for (let o = t.length - 1; o > 0; o--)
247
+ if (t[o] === "/") {
248
+ let c = 0;
249
+ for (let i = o - 1; i >= 0 && t[i] === "\\"; i--)
250
+ c++;
251
+ if (c % 2 === 0) {
252
+ s = o;
253
+ break;
254
+ }
255
+ }
256
+ if (s > 0) {
257
+ r = t.slice(1, s);
258
+ const o = t.slice(s + 1);
259
+ if (o)
260
+ for (const c of o)
261
+ /[imsuy]/.test(c) && !e.includes(c) && (e += c);
262
+ }
263
+ }
264
+ try {
265
+ const o = new RegExp(r, e).exec(n);
266
+ return o ? o[1] !== void 0 ? o[1] : o[0] : "";
267
+ } catch {
268
+ return "";
269
+ }
270
+ }
271
+ function cn(t, n) {
272
+ n = String(n);
273
+ const e = typeof t == "string" ? [t] : Array.from(t);
274
+ for (const r of e) {
275
+ if (typeof r != "string" || r === "") continue;
276
+ let s = "u", o = r;
277
+ if (r.length >= 2 && r[0] === "/") {
278
+ let c = -1;
279
+ for (let i = r.length - 1; i > 0; i--)
280
+ if (r[i] === "/") {
281
+ let l = 0;
282
+ for (let f = i - 1; f >= 0 && r[f] === "\\"; f--)
283
+ l++;
284
+ if (l % 2 === 0) {
285
+ c = i;
286
+ break;
287
+ }
288
+ }
289
+ if (c > 0) {
290
+ o = r.slice(1, c);
291
+ const i = r.slice(c + 1);
292
+ if (i)
293
+ for (const l of i)
294
+ /[imsuy]/.test(l) && !s.includes(l) && (s += l);
295
+ }
296
+ }
297
+ try {
298
+ if (new RegExp(o, s).test(n))
299
+ return !0;
300
+ } catch {
301
+ }
302
+ }
303
+ return !1;
304
+ }
305
+ function ln(t, n) {
306
+ let e = "u", r = t;
307
+ if (t.length >= 2 && t[0] === "/") {
308
+ let o = -1;
309
+ for (let c = t.length - 1; c > 0; c--)
310
+ if (t[c] === "/") {
311
+ let i = 0;
312
+ for (let l = c - 1; l >= 0 && t[l] === "\\"; l--)
313
+ i++;
314
+ if (i % 2 === 0) {
315
+ o = c;
316
+ break;
317
+ }
318
+ }
319
+ if (o > 0) {
320
+ r = t.slice(1, o);
321
+ const c = t.slice(o + 1);
322
+ if (c)
323
+ for (const i of c)
324
+ /[imsuy]/.test(i) && !e.includes(i) && (e += i);
325
+ }
326
+ }
327
+ e.includes("g") || (e += "g");
328
+ let s = [];
329
+ try {
330
+ const o = new RegExp(r, e);
331
+ let c;
332
+ for (; (c = o.exec(n)) !== null; )
333
+ s.push(c[1] !== void 0 ? c[1] : c[0]), c[0] === "" && o.lastIndex++;
334
+ } catch {
335
+ s = [];
336
+ }
337
+ return s;
338
+ }
339
+ function fn(t) {
340
+ return S(t) ? t.map((n) => n.replace(/[^0-9]/g, "")) : t.replace(/[^0-9]/g, "");
341
+ }
342
+ function un(t, n, e = " ") {
343
+ const r = t.length;
344
+ if (n <= r || e === "")
345
+ return t;
346
+ const s = n - r, o = Math.floor(s / 2), c = s - o;
347
+ return _(e, o) + t + _(e, c);
348
+ }
349
+ function an(t, n, e = " ") {
350
+ const r = t.length;
351
+ if (n <= r || e === "")
352
+ return t;
353
+ const o = n - r;
354
+ return _(e, o) + t;
355
+ }
356
+ function pn(t, n, e = " ") {
357
+ const r = t.length;
358
+ if (n <= r || e === "")
359
+ return t;
360
+ const o = n - r;
361
+ return t + _(e, o);
362
+ }
363
+ function _(t, n) {
364
+ if (n <= 0) return "";
365
+ const e = Math.ceil(n / t.length);
366
+ return t.repeat(e).slice(0, n);
367
+ }
368
+ function mt(t, n = 2) {
369
+ const e = t.split(/(?=[A-Z])/), r = String(e.pop());
370
+ return e.join("") + Y(r, n);
371
+ }
372
+ function gn(t, n = 2) {
373
+ return mt(t, n);
374
+ }
375
+ function mn(t = 32, n = !0, e = !0, r = !0, s = !1) {
376
+ const f = [
377
+ n ? [
378
+ "a",
379
+ "b",
380
+ "c",
381
+ "d",
382
+ "e",
383
+ "f",
384
+ "g",
385
+ "h",
386
+ "i",
387
+ "j",
388
+ "k",
389
+ "l",
390
+ "m",
391
+ "n",
392
+ "o",
393
+ "p",
394
+ "q",
395
+ "r",
396
+ "s",
397
+ "t",
398
+ "u",
399
+ "v",
400
+ "w",
401
+ "x",
402
+ "y",
403
+ "z",
404
+ "A",
405
+ "B",
406
+ "C",
407
+ "D",
408
+ "E",
409
+ "F",
410
+ "G",
411
+ "H",
412
+ "I",
413
+ "J",
414
+ "K",
415
+ "L",
416
+ "M",
417
+ "N",
418
+ "O",
419
+ "P",
420
+ "Q",
421
+ "R",
422
+ "S",
423
+ "T",
424
+ "U",
425
+ "V",
426
+ "W",
427
+ "X",
428
+ "Y",
429
+ "Z"
430
+ ] : null,
431
+ e ? ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] : null,
432
+ r ? [
433
+ "~",
434
+ "!",
435
+ "#",
436
+ "$",
437
+ "%",
438
+ "^",
439
+ "&",
440
+ "*",
441
+ "(",
442
+ ")",
443
+ "-",
444
+ "_",
445
+ ".",
446
+ ",",
447
+ "<",
448
+ ">",
449
+ "?",
450
+ "/",
451
+ "\\",
452
+ "{",
453
+ "}",
454
+ "[",
455
+ "]",
456
+ "|",
457
+ ":",
458
+ ";"
459
+ ] : null,
460
+ s ? [" "] : null
461
+ ].filter((p) => S(p));
462
+ if (f.length === 0 || t <= 0)
463
+ return "";
464
+ const m = [];
465
+ for (const p of f) {
466
+ const g = M(0, p.length - 1);
467
+ m.push(p[g]);
468
+ }
469
+ const a = Math.max(0, t - m.length), u = f.flat();
470
+ for (let p = 0; p < a; p++) {
471
+ const g = M(0, u.length - 1);
472
+ m.push(u[g]);
473
+ }
474
+ for (let p = m.length - 1; p > 0; p--) {
475
+ const g = M(0, p), h = m[p];
476
+ m[p] = m[g], m[g] = h;
477
+ }
478
+ return m.join("");
479
+ }
480
+ function hn(t, n, e = 0) {
481
+ if (n === "")
482
+ return !1;
483
+ const r = Array.from(t), s = Array.from(n);
484
+ let o = e >= 0 ? e : r.length + e;
485
+ if (o < 0 && (o = 0), o >= r.length)
486
+ return !1;
487
+ const c = r.length - s.length;
488
+ for (let i = o; i <= c; i++) {
489
+ let l = !0;
490
+ for (let f = 0; f < s.length; f++)
491
+ if (r[i + f] !== s[f]) {
492
+ l = !1;
493
+ break;
494
+ }
495
+ if (l)
496
+ return i;
497
+ }
498
+ return !1;
499
+ }
500
+ function ht(t = 16) {
501
+ return (R ?? ((e) => v(e)))(t);
502
+ }
503
+ function dt(t) {
504
+ R = t;
505
+ }
506
+ function dn(t, n) {
507
+ let e = 0;
508
+ const r = n ?? function(s) {
509
+ const o = R;
510
+ R = null;
511
+ const c = ht(s);
512
+ return R = o, e++, c;
513
+ };
514
+ dt((s) => e < t.length ? String(t[e++]) : r(s));
515
+ }
516
+ function yn() {
517
+ R = null;
518
+ }
519
+ function wn(t, n) {
520
+ return n <= 0 ? "" : t.repeat(n);
521
+ }
522
+ function xn(t, n, e) {
523
+ let r;
524
+ typeof n == "object" && !S(n) ? r = Object.values(n) : r = S(n) ? [...n] : Array.from(n);
525
+ const s = e.split(t);
526
+ if (s.length === 1)
527
+ return e;
528
+ let o = s[0];
529
+ for (let c = 1; c < s.length; c++) {
530
+ const i = r.length ? r.shift() : t;
531
+ o += i + s[c];
532
+ }
533
+ return String(o);
534
+ }
535
+ function Sn(t, n) {
536
+ try {
537
+ const e = String(t);
538
+ if (e.length)
539
+ return e;
540
+ throw new Error("Failed to convert value to string");
541
+ } catch {
542
+ return n;
543
+ }
544
+ }
545
+ function $n(t, n, e, r = !0) {
546
+ const s = (f) => typeof f == "string" ? [f] : Array.from(f), o = s(t), c = s(n), i = (f) => f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = (f) => o.reduce((m, a, u) => {
547
+ if (a === "") return m;
548
+ const p = c[u] ?? "";
549
+ if (!r)
550
+ return m.split(a).join(p);
551
+ const g = new RegExp(i(a), "gi");
552
+ return m.replace(g, () => p);
553
+ }, f);
554
+ return N(e) ? l(e) : Array.from(e).map(l);
555
+ }
556
+ function yt(t, n, e) {
557
+ if (t = String(t), t === "")
558
+ return e;
559
+ const r = e.indexOf(t);
560
+ return r !== -1 ? e.slice(0, r) + n + e.slice(r + t.length) : e;
561
+ }
562
+ function An(t, n, e) {
563
+ return t = String(t), t === "" ? e : q(e, t) ? yt(t, n, e) : e;
564
+ }
565
+ function wt(t, n, e) {
566
+ if (t = String(t), t === "")
567
+ return e;
568
+ const r = e.lastIndexOf(t);
569
+ return r !== -1 ? e.slice(0, r) + n + e.slice(r + t.length) : e;
570
+ }
571
+ function kn(t, n, e) {
572
+ return t = String(t), t === "" ? e : I(e, t) ? wt(t, n, e) : e;
573
+ }
574
+ function Ln(t, n, e, r = -1) {
575
+ const s = (a) => S(a) ? a : [a], o = s(t);
576
+ function c(a) {
577
+ try {
578
+ if (a instanceof RegExp) {
579
+ let g = a.flags;
580
+ return g.includes("g") || (g += "g"), g.includes("u") || (g += "u"), new RegExp(a.source, g);
581
+ }
582
+ let u = a, p = "gu";
583
+ if (a.length >= 2 && a[0] === "/") {
584
+ let g = -1;
585
+ for (let h = a.length - 1; h > 0; h--)
586
+ if (a[h] === "/") {
587
+ let d = 0;
588
+ for (let y = h - 1; y >= 0 && a[y] === "\\"; y--)
589
+ d++;
590
+ if (d % 2 === 0) {
591
+ g = h;
592
+ break;
593
+ }
594
+ }
595
+ if (g > 1) {
596
+ u = a.slice(1, g);
597
+ const h = a.slice(g + 1);
598
+ if (h)
599
+ for (const d of h)
600
+ /[imsuy]/.test(d) && !p.includes(d) && (p += d);
601
+ p.includes("g") || (p += "g"), p.includes("u") || (p += "u");
602
+ }
603
+ }
604
+ return new RegExp(
605
+ u,
606
+ Array.from(new Set(p.split(""))).join("")
607
+ );
608
+ } catch {
609
+ return null;
610
+ }
611
+ }
612
+ const i = [];
613
+ for (const a of o) {
614
+ const u = c(a);
615
+ if (!u) return null;
616
+ i.push(u);
617
+ }
618
+ const l = et(n), f = l ? [] : s(n), m = (a) => {
619
+ let u = a;
620
+ for (let p = 0; p < i.length; p++) {
621
+ const g = i[p];
622
+ if (l) {
623
+ let h = 0;
624
+ const d = n;
625
+ u = u.replace(
626
+ g,
627
+ (y, ...w) => {
628
+ if (r >= 0 && h >= r) return y;
629
+ h++;
630
+ const C = typeof w[w.length - 1] == "object" && typeof w[w.length - 2] == "number" ? w.length - 3 : w.length - 2, A = [];
631
+ for (let k = 0; k < C; k++)
632
+ A.push(w[k]);
633
+ const b = [y, ...A];
634
+ return d(b);
635
+ }
636
+ );
637
+ } else {
638
+ const h = f[p] ?? (f.length === 1 ? f[0] : "");
639
+ if (r < 0)
640
+ u = u.replace(g, (d, ...y) => {
641
+ const O = typeof y[y.length - 1] == "object" && typeof y[y.length - 2] == "number" ? y.length - 3 : y.length - 2, C = y.slice(0, O).map((A) => String(A));
642
+ return h.replace(/\$(\d{1,2})/g, (A, b) => {
643
+ const k = parseInt(b, 10);
644
+ return (C[k - 1] ?? "").toUpperCase();
645
+ });
646
+ });
647
+ else {
648
+ let d = 0;
649
+ u = u.replace(g, (y, ...w) => {
650
+ if (d >= r) return y;
651
+ d++;
652
+ const C = typeof w[w.length - 1] == "object" && typeof w[w.length - 2] == "number" ? w.length - 3 : w.length - 2, A = w.slice(0, C).map((b) => String(b));
653
+ return h.replace(/\$(\d{1,2})/g, (b, k) => {
654
+ const G = parseInt(k, 10);
655
+ return (A[G - 1] ?? "").toUpperCase();
656
+ });
657
+ });
658
+ }
659
+ }
660
+ }
661
+ return u;
662
+ };
663
+ return S(e) ? e.map(m) : m(e);
664
+ }
665
+ function xt(t) {
666
+ return t.replace(/<\/?[^>]+(>|$)/g, "");
667
+ }
668
+ function bn(t, n, e = !0) {
669
+ const r = typeof t == "string" ? [t] : Array.from(t), s = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = (c) => {
670
+ let i = c;
671
+ for (const l of r)
672
+ if (l !== "")
673
+ if (e)
674
+ i = i.split(l).join("");
675
+ else {
676
+ const f = new RegExp(s(l), "gi");
677
+ i = i.replace(f, "");
678
+ }
679
+ return i;
680
+ };
681
+ return typeof n == "string" ? o(n) : Array.from(n, (c) => o(String(c)));
682
+ }
683
+ function Rn(t) {
684
+ return Array.from(t).reverse().join("");
685
+ }
686
+ function Cn(t, n) {
687
+ const e = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
688
+ return n + t.replace(new RegExp(`^(?:${e})+`, "u"), "");
689
+ }
690
+ function En(t) {
691
+ const n = String(t).trim();
692
+ if (n === "")
693
+ return "";
694
+ let e = n.split(/\s+/u);
695
+ return e.length > 1 ? e = e.map((s) => D(s)) : e = At(e.join("_")).map((s) => D(s)), e.join("_").replace(/[-_ ]+/gu, "_").split("_").filter((s) => s.length > 0).join(" ");
696
+ }
697
+ function Fn(t) {
698
+ if (t.trim() === "")
699
+ return t;
700
+ const n = /* @__PURE__ */ new Set([
701
+ "and",
702
+ "as",
703
+ "but",
704
+ "for",
705
+ "if",
706
+ "nor",
707
+ "or",
708
+ "so",
709
+ "yet",
710
+ "a",
711
+ "an",
712
+ "the",
713
+ "at",
714
+ "by",
715
+ "for",
716
+ "in",
717
+ "of",
718
+ "off",
719
+ "on",
720
+ "per",
721
+ "to",
722
+ "up",
723
+ "via",
724
+ "et",
725
+ "ou",
726
+ "un",
727
+ "une",
728
+ "la",
729
+ "le",
730
+ "les",
731
+ "de",
732
+ "du",
733
+ "des",
734
+ "par",
735
+ "à"
736
+ ]), e = /* @__PURE__ */ new Set([".", "!", "?", ":", "—", ","]), r = t.split(/\s+/u), s = (o) => {
737
+ if (!o) return o;
738
+ const c = Array.from(o), i = c[0].toLocaleUpperCase(), l = c.slice(1).join("");
739
+ return i + l;
740
+ };
741
+ for (let o = 0; o < r.length; o++) {
742
+ const c = r[o].toLocaleLowerCase();
743
+ if (c.includes("-")) {
744
+ const l = c.split("-").map((f) => n.has(f) && f.length <= 3 ? f : s(f));
745
+ r[o] = l.join("-");
746
+ } else {
747
+ const i = o > 0 ? r[o - 1] : "", l = i ? Array.from(i).slice(-1)[0] : void 0, f = o === 0 || l !== void 0 && e.has(l);
748
+ n.has(c) && c.length <= 3 && !f ? r[o] = c : r[o] = s(c);
749
+ }
750
+ }
751
+ return r.join(" ");
752
+ }
753
+ function Un(t, n = "-", e = { "@": "at" }) {
754
+ const r = n, s = (a) => a.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"), o = (a) => a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), c = (a) => {
755
+ let u = a;
756
+ const p = r === "-" ? "_" : "-";
757
+ {
758
+ const g = new RegExp(`[${s(p)}]+`, "gu");
759
+ u = u.replace(g, r);
760
+ }
761
+ if (e && typeof e == "object") {
762
+ const g = {};
763
+ for (const [h, d] of Object.entries(e))
764
+ g[h] = (r ?? "") + d + (r ?? "");
765
+ for (const [h, d] of Object.entries(g))
766
+ h !== "" && (u = u.split(h).join(d));
767
+ }
768
+ if (u = P(u), r === "")
769
+ return u = u.replace(/[^\p{L}\p{N}\s]+/gu, ""), u = u.replace(/[\s]+/gu, ""), u;
770
+ {
771
+ const g = new RegExp(
772
+ `[^${s(r)}\\p{L}\\p{N}\\s]+`,
773
+ "gu"
774
+ );
775
+ u = u.replace(g, "");
776
+ const h = new RegExp(
777
+ `[${s(r)}\\s]+`,
778
+ "gu"
779
+ );
780
+ u = u.replace(h, r);
781
+ const d = new RegExp(
782
+ `^${o(r)}+|${o(r)}+$`,
783
+ "gu"
784
+ );
785
+ return u = u.replace(d, ""), u;
786
+ }
787
+ }, i = c(t), l = c(at(t));
788
+ return Object.keys(e || {}).some((a) => /[A-Za-z0-9]/.test(a)) ? l : i;
789
+ }
790
+ function St(t, n = "_") {
791
+ const r = `${t}|${n}`;
792
+ if (E.has(r))
793
+ return E.get(r);
794
+ let s = t;
795
+ return /^[a-z]+$/.test(t) || (s = kt(t).replace(/\s+/gu, ""), s = s.replace(/(.)(?=[A-Z])/g, `$1${n}`), s = P(s)), E.set(r, s), s;
796
+ }
797
+ function Nn(t) {
798
+ return tt(t).replace(/[\s\u3164\u1160]+/gu, " ");
799
+ }
800
+ function q(t, n) {
801
+ if (t == null || n == null)
802
+ return !1;
803
+ let e = [
804
+ n
805
+ ];
806
+ typeof n == "string" || typeof n == "number" ? e = [n] : Symbol.iterator in Object(n) && (e = Array.from(n));
807
+ const r = String(t);
808
+ for (const s of e) {
809
+ if (s == null)
810
+ continue;
811
+ const o = String(s);
812
+ if (o !== "" && r.startsWith(o))
813
+ return !0;
814
+ }
815
+ return !1;
816
+ }
817
+ function zn(t, n) {
818
+ return !q(t, n);
819
+ }
820
+ function B(t) {
821
+ const n = t;
822
+ if (U.has(n))
823
+ return U.get(n);
824
+ const e = String(t).replace(/[-_]+/g, " "), r = e.trim() === "" ? [] : e.split(/\s+/u), s = (c) => {
825
+ if (!c) return c;
826
+ const i = Array.from(c), l = i[0].toUpperCase(), f = i.slice(1).join("");
827
+ return l + f;
828
+ }, o = r.map(s).join("");
829
+ return U.set(n, o), o;
830
+ }
831
+ function _n(t) {
832
+ return B(t);
833
+ }
834
+ function On(t, n) {
835
+ if (!t || Object.keys(t).length === 0)
836
+ return n;
837
+ const e = Object.keys(t).filter((o) => o !== "");
838
+ if (e.length === 0)
839
+ return n;
840
+ e.sort((o, c) => c.length - o.length);
841
+ const r = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), s = new RegExp(e.map(r).join("|"), "gu");
842
+ return n.replace(s, (o) => t[o] ?? o);
843
+ }
844
+ function Mn(t, n) {
845
+ return n < 0 ? x(t, n) : x(t, 0, n);
846
+ }
847
+ function $t(t) {
848
+ return P(x(t, 0, 1)) + x(t, 1);
849
+ }
850
+ function Wn(t) {
851
+ return nt(x(t, 0, 1)) + x(t, 1);
852
+ }
853
+ function At(t) {
854
+ return t.split(new RegExp("(?=\\p{Lu})", "u")).filter(Boolean);
855
+ }
856
+ function kt(t, n = ` \r
857
+ \f\v`) {
858
+ const e = S(n) ? n.join("") : n, r = (i) => i.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"), s = e.length ? r(e) : "", o = s.length ? `(?:\\s|[${s}])` : "\\s", c = new RegExp(`(^|${o})(\\p{Ll})`, "gu");
859
+ return t.replace(c, (i, l, f) => l + f.toUpperCase());
860
+ }
861
+ function In(t, n = null) {
862
+ const e = n && n.length > 0 ? n.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&") : "", r = e.length > 0 ? new RegExp(`[\\p{L}\\p{N}${e}]+`, "gu") : /[\p{L}\p{N}]+/gu, s = t.match(r);
863
+ return s ? s.length : 0;
864
+ }
865
+ function Pn(t, n = 75, e = `
866
+ `, r = !1) {
867
+ if (t.length === 0 || n < 1 || e === "")
868
+ return t;
869
+ const s = t.split(/\r\n|\n|\r/), o = [];
870
+ for (const c of s) {
871
+ let i = c;
872
+ if (i.length === 0) {
873
+ o.push("");
874
+ continue;
875
+ }
876
+ if (r) {
877
+ for (; i.length > 0 && !(/^\s/u.test(i) && (i = i.replace(/^\s+/u, ""), i.length === 0)); ) {
878
+ if (i.length <= n) {
879
+ o.push(i), i = "";
880
+ break;
881
+ }
882
+ let l = i.slice(0, n);
883
+ l = l.replace(/\s+$/u, ""), o.push(l), i = i.slice(n).replace(/^\s+/u, "");
884
+ }
885
+ continue;
886
+ }
887
+ for (; i.length > n; ) {
888
+ const l = i.replace(/^\s+/u, "");
889
+ if (l.length !== i.length && (i = l, i.length <= n))
890
+ break;
891
+ const f = i.slice(0, n + 1);
892
+ let m = -1;
893
+ for (let u = f.length - 1; u >= 0; u--)
894
+ if (/\s/u.test(f[u])) {
895
+ m = u;
896
+ break;
897
+ }
898
+ if (m > 0) {
899
+ o.push(i.slice(0, m)), i = i.slice(m + 1);
900
+ continue;
901
+ }
902
+ const a = i.search(/\s/u);
903
+ if (a >= 0) {
904
+ o.push(i.slice(0, a)), i = i.slice(a + 1);
905
+ continue;
906
+ }
907
+ o.push(i), i = "";
908
+ break;
909
+ }
910
+ i.length > 0 && o.push(i);
911
+ }
912
+ return o.join(e);
913
+ }
914
+ function H() {
915
+ return $ ? $() : ft();
916
+ }
917
+ function qn() {
918
+ return $ ? $() : ut();
919
+ }
920
+ function V(t = null) {
921
+ $ = t;
922
+ }
923
+ function Gn(t, n = null) {
924
+ let e = 0;
925
+ n ??= function() {
926
+ const r = $;
927
+ $ = null;
928
+ const s = H();
929
+ return $ = r, e++, s;
930
+ }, V(function() {
931
+ return e < t.length ? t[e++] : n();
932
+ });
933
+ }
934
+ function jn(t = null) {
935
+ const n = H();
936
+ if (V(() => n), t !== null)
937
+ try {
938
+ t(n);
939
+ } finally {
940
+ Lt();
941
+ }
942
+ return n;
943
+ }
944
+ function Lt() {
945
+ $ = null;
946
+ }
947
+ function X(t = null) {
948
+ if (L)
949
+ return L();
950
+ if (t == null)
951
+ return K();
952
+ let n;
953
+ t instanceof Date ? n = t.getTime() : n = t;
954
+ const e = Date.now;
955
+ try {
956
+ return Date.now = () => n, K();
957
+ } finally {
958
+ Date.now = e;
959
+ }
960
+ }
961
+ function bt() {
962
+ L = null;
963
+ }
964
+ function Q(t = null) {
965
+ L = t;
966
+ }
967
+ function Tn(t, n = null) {
968
+ let e = 0;
969
+ n ??= function() {
970
+ const r = L;
971
+ L = null;
972
+ const s = X();
973
+ return L = r, e++, s;
974
+ }, Q(function() {
975
+ return e < t.length ? t[e++] : n();
976
+ });
977
+ }
978
+ function Dn(t = null) {
979
+ const n = X();
980
+ if (Q(() => n), t !== null)
981
+ try {
982
+ t(n);
983
+ } finally {
984
+ bt();
985
+ }
986
+ return n;
987
+ }
988
+ function Kn() {
989
+ return E.size;
990
+ }
991
+ function Zn() {
992
+ return F.size;
993
+ }
994
+ function Jn() {
995
+ return U.size;
996
+ }
997
+ function Bn() {
998
+ E.clear(), F.clear(), U.clear();
999
+ }
1000
+ export {
1001
+ Z as after,
1002
+ _t as afterLast,
1003
+ Fn as apa,
1004
+ at as ascii,
1005
+ pt as before,
1006
+ gt as beforeLast,
1007
+ Mt as between,
1008
+ Wt as betweenFirst,
1009
+ It as camel,
1010
+ Zn as camelCacheSize,
1011
+ Pt as charAt,
1012
+ Gt as chopEnd,
1013
+ qt as chopStart,
1014
+ J as contains,
1015
+ Tt as containsAll,
1016
+ yn as createRandomStringsNormally,
1017
+ dt as createRandomStringsUsing,
1018
+ dn as createRandomStringsUsingSequence,
1019
+ bt as createUlidsNormally,
1020
+ Q as createUlidsUsing,
1021
+ Tn as createUlidsUsingSequence,
1022
+ Lt as createUuidsNormally,
1023
+ V as createUuidsUsing,
1024
+ Gn as createUuidsUsingSequence,
1025
+ Kt as deduplicate,
1026
+ Dt as doesntContain,
1027
+ Zt as doesntEndWith,
1028
+ zn as doesntStartWith,
1029
+ I as endsWith,
1030
+ jt as excerpt,
1031
+ Jt as finish,
1032
+ Bn as flushCache,
1033
+ Dn as freezeUlids,
1034
+ jn as freezeUuids,
1035
+ En as headline,
1036
+ Vt as is,
1037
+ Xt as isAscii,
1038
+ Qt as isJson,
1039
+ cn as isMatch,
1040
+ tn as isUlid,
1041
+ Yt as isUrl,
1042
+ vt as isUuid,
1043
+ nn as kebab,
1044
+ $t as lcfirst,
1045
+ z as length,
1046
+ en as limit,
1047
+ P as lower,
1048
+ _ as makePad,
1049
+ sn as mask,
1050
+ on as match,
1051
+ ln as matchAll,
1052
+ fn as numbers,
1053
+ un as padBoth,
1054
+ an as padLeft,
1055
+ pn as padRight,
1056
+ _n as pascal,
1057
+ mn as password,
1058
+ gn as pluralPascal,
1059
+ mt as pluralStudly,
1060
+ hn as position,
1061
+ ht as random,
1062
+ bn as remove,
1063
+ wn as repeat,
1064
+ $n as replace,
1065
+ xn as replaceArray,
1066
+ kn as replaceEnd,
1067
+ yt as replaceFirst,
1068
+ wt as replaceLast,
1069
+ Ln as replaceMatches,
1070
+ An as replaceStart,
1071
+ Rn as reverse,
1072
+ Un as slug,
1073
+ St as snake,
1074
+ Kn as snakeCacheSize,
1075
+ Nn as squish,
1076
+ Cn as start,
1077
+ q as startsWith,
1078
+ xt as stripTags,
1079
+ B as studly,
1080
+ Jn as studlyCacheSize,
1081
+ On as swap,
1082
+ Mn as take,
1083
+ Sn as toStringOr,
1084
+ Ot as transliterate,
1085
+ Wn as ucfirst,
1086
+ At as ucsplit,
1087
+ kt as ucwords,
1088
+ X as ulid,
1089
+ Ht as unwrap,
1090
+ H as uuid,
1091
+ qn as uuid7,
1092
+ In as wordCount,
1093
+ Pn as wordWrap,
1094
+ rn as words,
1095
+ Bt as wrap
1096
+ };