@prozilla-os/shared 1.4.0 → 1.5.0

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/main.js CHANGED
@@ -1,871 +1,156 @@
1
- const a = {
2
- /**
3
- * Foreground colors.
4
- */
5
- fg: {
6
- black: "\x1B[30m",
7
- red: "\x1B[31m",
8
- green: "\x1B[32m",
9
- yellow: "\x1B[33m",
10
- blue: "\x1B[34m",
11
- magenta: "\x1B[35m",
12
- cyan: "\x1B[36m",
13
- white: "\x1B[37m"
14
- },
15
- /**
16
- * Background colors.
17
- */
18
- bg: {
19
- black: "\x1B[40m",
20
- red: "\x1B[41m",
21
- green: "\x1B[42m",
22
- yellow: "\x1B[43m",
23
- blue: "\x1B[44m",
24
- magenta: "\x1B[45m",
25
- cyan: "\x1B[46m",
26
- white: "\x1B[47m"
27
- },
28
- /**
29
- * Screen buffer and clearing controls.
30
- */
31
- screen: {
32
- enterAltBuffer: "\x1B[?1049h",
33
- exitAltBuffer: "\x1B[?1049l",
34
- clear: "\x1B[2J",
35
- clearLine: "\x1B[2K",
36
- home: "\x1B[H"
37
- },
38
- /**
39
- * Cursor controls.
40
- */
41
- cursor: {
42
- /** Changes the position of the cursor. */
43
- position: (e, t) => `\x1B[${e};${t}H`,
44
- hide: "\x1B[?25l",
45
- show: "\x1B[?25h",
46
- save: "\x1B[s",
47
- restore: "\x1B[u"
48
- },
49
- /**
50
- * Terminal input.
51
- */
52
- input: {
53
- /** Move cursor up. */
54
- arrowUp: "\x1B[A",
55
- /** Move cursor down. */
56
- arrowDown: "\x1B[B",
57
- /** Move cursor right. */
58
- arrowRight: "\x1B[C",
59
- /** Move cursor left. */
60
- arrowLeft: "\x1B[D",
61
- horizontalTab: " ",
62
- lineFeed: `
63
- `,
64
- verticalTab: "\v",
65
- formFeed: "\f",
66
- carriageReturn: "\r",
67
- backspace: "\b",
68
- delete: "",
69
- escape: "\x1B",
70
- pageUp: "\x1B[5~",
71
- pageDown: "\x1B[6~",
72
- ctrlA: "",
73
- ctrlB: "",
74
- ctrlC: "",
75
- ctrlD: "",
76
- ctrlE: "",
77
- ctrlF: "",
78
- ctrlG: "\x07",
79
- ctrlH: "\b",
80
- ctrlI: " ",
81
- ctrlJ: `
82
- `,
83
- ctrlK: "\v",
84
- ctrlL: "\f",
85
- ctrlM: "\r",
86
- ctrlN: "",
87
- ctrlO: "",
88
- ctrlP: "",
89
- ctrlQ: "",
90
- ctrlR: "",
91
- ctrlS: "",
92
- ctrlT: "",
93
- ctrlU: "",
94
- ctrlV: "",
95
- ctrlW: "",
96
- ctrlX: "",
97
- ctrlY: "",
98
- ctrlZ: ""
99
- },
100
- /**
101
- * Decorations.
102
- */
103
- decoration: {
104
- dim: "\x1B[2m",
105
- bold: "\x1B[1m",
106
- italic: "\x1B[3m",
107
- underline: "\x1B[4m",
108
- blink: "\x1B[5m",
109
- invert: "\x1B[7m",
110
- strike: "\x1B[9m"
111
- },
112
- reset: "\x1B[0m"
113
- };
114
- function E(e, t) {
115
- const r = t.indexOf(e);
116
- r !== -1 && t.splice(r, 1);
117
- }
118
- function Y(e) {
119
- return e[Math.floor(Math.random() * e.length)];
1
+ import { A as _, a as j, L as P, b as V, i as X, c as Y, d as Z, e as G, f as H, g as J, h as K, j as Q, k as W, l as R } from "./chunks/index-PU_xBoDn.js";
2
+ import { EventEmitter as tr, capitalize as er, clamp as nr, fillTemplate as ir, formatRelativeTime as sr, formatTime as or, getLongestCommonPrefix as ar, interleave as ur, isValidInteger as cr, isValidNumber as lr, isValidUrl as hr, isolateSubstring as fr, kebabToCamelCase as pr, parseBool as dr, parseOptionalFloat as mr, parseOptionalInteger as gr, randomFromArray as yr, randomIndex as vr, randomInt as xr, randomRange as Er, removeBaseUrl as kr, removeDuplicatesFromArray as Or, removeFromArray as $r, removeUrlProtocol as br, replaceAll as wr, resolveUrl as Sr, round as Ar, splitAt as Fr } from "./utils.js";
3
+ import { i as qr, m as Dr } from "./chunks/object.utils-xiWGUq8N.js";
4
+ const I = "https://os.prozilla.dev/";
5
+ function O(n) {
6
+ return `# ${n}`;
120
7
  }
121
- function Z(e) {
122
- return e.filter((t, r) => e.indexOf(t) === r);
8
+ function $(n) {
9
+ return `## ${n}`;
123
10
  }
124
- const w = {
125
- s: 1e3,
126
- m: 1e3 * 60,
127
- h: 1e3 * 60 * 60,
128
- d: 1e3 * 60 * 60 * 24,
129
- w: 1e3 * 60 * 60 * 24 * 7,
130
- n: 1e3 * 60 * 60 * 24 * 31,
131
- y: 1e3 * 60 * 60 * 24 * 365,
132
- c: 1e3 * 60 * 60 * 24 * 365 * 100
133
- };
134
- function S(e, t = 3, r = !1) {
135
- const n = [], u = (l, g) => {
136
- if (!r)
137
- return l.join(", ");
138
- let m = "", b = "";
139
- return g ? b = "ago" : m = "in", [m, l.join(", "), b].join(" ").trim();
140
- };
141
- let h = !1;
142
- if (e < 0 && (e = -e, h = !0), Math.abs(e) < w.s)
143
- return u(["less than a second"], h);
144
- const p = [], y = {
145
- s: "second",
146
- m: "minute",
147
- h: "hour",
148
- d: "day",
149
- n: "month",
150
- y: "year"
151
- };
152
- for (const [l, g] of Object.entries(w).reverse()) {
153
- if (l === "w" || l === "c")
154
- continue;
155
- const m = Math.floor(e / g);
156
- e -= m * g, m > 0 && p.push({ amount: m, label: m != 1 ? y[l] + "s" : y[l] });
157
- }
158
- for (let l = 0; l < t; l++)
159
- if (l < p.length) {
160
- const g = p[l];
161
- n.push(`${g.amount} ${g.label}`);
162
- }
163
- return n.length === 0 ? u(["less than a second"], h) : u(n, h);
164
- }
165
- function J(e, t = 3, r = !1) {
166
- const n = e.valueOf() - Date.now();
167
- return S(n, t, r);
168
- }
169
- class K {
170
- #t = {};
171
- /**
172
- * Starts listening to an event.
173
- * @param event - The event to listen to.
174
- * @param listener - The function to call when the event is emitted.
175
- * @returns The listener.
176
- */
177
- on(t, r) {
178
- return this.#t[t] === void 0 ? this.#t[t] = [r] : this.#t[t].push(r), r;
179
- }
180
- /**
181
- * Registers an event listener that is automatically removed when called.
182
- * @param event - The event to listen to.
183
- * @param listener - The function to call once the event is emitted.
184
- * @returns The wrapped listener.
185
- */
186
- once(t, r) {
187
- const n = (...u) => (this.off(t, n), r(...u));
188
- return this.on(t, n);
189
- }
190
- /**
191
- * Removes an event listener.
192
- * @param event - The event to remove the listener from.
193
- * @param listener - The listener to remove.
194
- */
195
- off(t, r) {
196
- const n = this.#t[t];
197
- n !== void 0 && E(r, n);
198
- }
199
- /**
200
- * Emits an event to all its listeners.
201
- * @param event - The event to emit.
202
- * @param args - The arguments to pass to the listeners.
203
- */
204
- emit(t, ...r) {
205
- const n = this.#t[t];
206
- if (n !== void 0)
207
- for (const u of n)
208
- u(...r);
209
- }
210
- /**
211
- * Emits an event and waits for all listeners to resolve.
212
- * @param event - The event to emit.
213
- * @param args - The arguments to pass to the listeners.
214
- */
215
- async emitAsync(t, ...r) {
216
- const n = this.#t[t];
217
- if (n === void 0)
218
- return;
219
- const u = n.map((h) => h(...r));
220
- await Promise.all(u);
221
- }
11
+ function b(n) {
12
+ return `### ${n}`;
222
13
  }
223
- function G(e, t, r) {
224
- return e < t ? t : e > r ? r : e;
14
+ function w(n) {
15
+ return `#### ${n}`;
225
16
  }
226
- function Q(e, t) {
227
- return Math.random() * (t - e) + e;
17
+ function S(n) {
18
+ return `##### ${n}`;
228
19
  }
229
- function R(e, t) {
230
- const r = Math.pow(10, t ?? 0);
231
- return Math.round(e * r) / r;
20
+ function A(n) {
21
+ return `###### ${n}`;
232
22
  }
233
- function O(e) {
234
- return typeof e == "number" ? !0 : e.trim() === "" ? !1 : Number.isInteger(Number(e));
23
+ function F(n) {
24
+ return `**${n}**`;
235
25
  }
236
- function C(e) {
237
- return typeof e == "number" ? !0 : e.trim() === "" ? !1 : !isNaN(Number(e));
26
+ function z(n) {
27
+ return `*${n}*`;
238
28
  }
239
- function A(e, t = 0) {
240
- return e !== void 0 && O(e) ? Number(e) : t;
29
+ function q(n) {
30
+ return `\`${n}\``;
241
31
  }
242
- function L(e, t = 0) {
243
- return e !== void 0 && C(e) ? parseFloat(e) : t;
32
+ function D(n) {
33
+ return `\`\`\`${n}\`\`\``;
244
34
  }
245
- function _(e) {
246
- return e.trim().toLowerCase() === "true";
35
+ function L(n) {
36
+ return `~~${n}~~`;
247
37
  }
248
- function tt(e) {
249
- return e.replace(/-([a-z])/g, (t, r) => r.toUpperCase());
38
+ function M(n, r) {
39
+ return `[${n}](${r})`;
250
40
  }
251
- function rt(e) {
252
- if (!e.length) return "";
253
- let t = e[0];
254
- for (let r = 1; r < e.length; r++)
255
- for (; e[r].indexOf(t) !== 0; )
256
- if (t = t.substring(0, t.length - 1), t === "") return "";
257
- return t;
41
+ function N(n) {
42
+ return `> ${n}`;
258
43
  }
259
- class s {
260
- /**
261
- * Makes text black using {@link ANSI.fg.black}.
262
- */
263
- static black(t) {
264
- return s.#t(t, a.fg.black);
265
- }
266
- /**
267
- * Makes text red using {@link ANSI.fg.red}.
268
- */
269
- static red(t) {
270
- return s.#t(t, a.fg.red);
271
- }
272
- /**
273
- * Makes text green using {@link ANSI.fg.green}.
274
- */
275
- static green(t) {
276
- return s.#t(t, a.fg.green);
277
- }
278
- /**
279
- * Makes text yellow using {@link ANSI.fg.yellow}.
280
- */
281
- static yellow(t) {
282
- return s.#t(t, a.fg.yellow);
283
- }
284
- /**
285
- * Makes text blue using {@link ANSI.fg.blue}.
286
- */
287
- static blue(t) {
288
- return s.#t(t, a.fg.blue);
289
- }
290
- /**
291
- * Makes text magenta using {@link ANSI.fg.magenta}.
292
- */
293
- static magenta(t) {
294
- return s.#t(t, a.fg.magenta);
295
- }
296
- /**
297
- * Makes text cyan using {@link ANSI.fg.cyan}.
298
- */
299
- static cyan(t) {
300
- return s.#t(t, a.fg.cyan);
301
- }
302
- /**
303
- * Makes text white using {@link ANSI.fg.white}.
304
- */
305
- static white(t) {
306
- return s.#t(t, a.fg.white);
307
- }
308
- /**
309
- * Sets background to black using {@link ANSI.bg.black}.
310
- */
311
- static blackBackground(t) {
312
- return s.#t(t, a.bg.black);
313
- }
314
- /**
315
- * Sets background to red using {@link ANSI.bg.red}.
316
- */
317
- static redBackground(t) {
318
- return s.#t(t, a.bg.red);
319
- }
320
- /**
321
- * Sets background to green using {@link ANSI.bg.green}.
322
- */
323
- static greenBackground(t) {
324
- return s.#t(t, a.bg.green);
325
- }
326
- /**
327
- * Sets background to yellow using {@link ANSI.bg.yellow}.
328
- */
329
- static yellowBackground(t) {
330
- return s.#t(t, a.bg.yellow);
331
- }
332
- /**
333
- * Sets background to blue using {@link ANSI.bg.blue}.
334
- */
335
- static blueBackground(t) {
336
- return s.#t(t, a.bg.blue);
337
- }
338
- /**
339
- * Sets background to magenta using {@link ANSI.bg.magenta}.
340
- */
341
- static magentaBackground(t) {
342
- return s.#t(t, a.bg.magenta);
343
- }
344
- /**
345
- * Sets background to cyan using {@link ANSI.bg.cyan}.
346
- */
347
- static cyanBackground(t) {
348
- return s.#t(t, a.bg.cyan);
349
- }
350
- /**
351
- * Sets background to white using {@link ANSI.bg.white}.
352
- */
353
- static whiteBackground(t) {
354
- return s.#t(t, a.bg.white);
355
- }
356
- /**
357
- * Makes text bold using {@link ANSI.decoration.bold}.
358
- */
359
- static bold(t) {
360
- return s.#t(t, a.decoration.bold);
361
- }
362
- /**
363
- * Makes text dim using {@link ANSI.decoration.dim}.
364
- */
365
- static dim(t) {
366
- return s.#t(t, a.decoration.dim);
367
- }
368
- /**
369
- * Makes text italic using {@link ANSI.decoration.italic}.
370
- */
371
- static italic(t) {
372
- return s.#t(t, a.decoration.italic);
373
- }
374
- /**
375
- * Underlines text using {@link ANSI.decoration.underline}.
376
- */
377
- static underline(t) {
378
- return s.#t(t, a.decoration.underline);
379
- }
380
- /**
381
- * Inverts foreground and background colors using {@link ANSI.decoration.invert}.
382
- */
383
- static invert(t) {
384
- return s.#t(t, a.decoration.invert);
385
- }
386
- /**
387
- * Makes text strike through using {@link ANSI.decoration.strike}.
388
- */
389
- static strike(t) {
390
- return s.#t(t, a.decoration.strike);
391
- }
392
- static #t(t, r) {
393
- return t = t.replaceAll(a.reset, a.reset + r), r + t + a.reset;
394
- }
395
- /**
396
- * Removes all ANSI escape sequences.
397
- */
398
- static strip(t) {
399
- return t.replace(/\u001b\[[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
400
- }
401
- /**
402
- * Removes ANSI escape sequences for colors and background colors (SGR).
403
- */
404
- static stripColors(t) {
405
- return t.replace(/\u001b\[[0-9;]*m/g, "");
406
- }
407
- }
408
- var M = /* @__PURE__ */ ((e) => (e[e.Debug = 0] = "Debug", e[e.Info = 1] = "Info", e[e.Success = 2] = "Success", e[e.Warning = 3] = "Warning", e[e.Error = 4] = "Error", e))(M || {});
409
- class et {
410
- /**
411
- * The minimum log level or an array of log levels to enable.
412
- *
413
- * `undefined` enables all log levels. An array enables all log levels in that array. A single level enables that log level and the ones above.
414
- * @default LogLevel.Debug
415
- */
416
- level;
417
- /**
418
- * The current level of indentation.
419
- * @default 0
420
- */
421
- indent = 0;
422
- /**
423
- * The string to use for indentation.
424
- * @default "\t"
425
- */
426
- indentString;
427
- /**
428
- * The function to use when highlighting text.
429
- * @default Ansi.cyan
430
- * @see {@link Ansi.cyan}
431
- */
432
- highlight = s.cyan;
433
- /**
434
- * The function to use when emphasizing text.
435
- * @default Ansi.bold
436
- * @see {@link Ansi.bold}
437
- */
438
- emphasize = s.bold;
439
- /**
440
- * The prefixes to prepend to logs.
441
- * @default {
442
- [LogLevel.Info]: Ansi.cyan("[info]"),
443
- [LogLevel.Success]: Ansi.green("[success]"),
444
- [LogLevel.Warning]: Ansi.yellow("[warning]"),
445
- [LogLevel.Error]: Ansi.red("[error]"),
446
- }
447
- */
448
- prefix = {};
449
- #t = 0;
450
- #r = 0;
451
- get errorCount() {
452
- return this.#t;
453
- }
454
- set errorCount(t) {
455
- this.#t = t;
456
- }
457
- get warningCount() {
458
- return this.#r;
459
- }
460
- set warningCount(t) {
461
- this.#r = t;
462
- }
463
- constructor(t) {
464
- this.reset(), t !== void 0 && (Array.isArray(t) || typeof t == "number" ? this.level = t : (t.level !== void 0 && (this.level = t.level), t.prefix && (typeof t.prefix == "string" ? this.prefix.global = t.prefix : this.prefix = {
465
- ...this.prefix,
466
- ...t.prefix
467
- })));
468
- }
469
- // ===== Modifying state =====
470
- /**
471
- * Resets all properties to their default values.
472
- */
473
- reset() {
474
- return this.level = 0, this.indent = 0, this.indentString = " ", this.highlight = s.cyan, this.emphasize = s.bold, this.prefix = {
475
- 1: s.cyan("[info]"),
476
- 2: s.green("[success]"),
477
- 3: s.yellow("[warning]"),
478
- 4: s.red("[error]")
479
- }, this.#t = 0, this.#r = 0, this;
480
- }
481
- indented(t, r = 1, n) {
482
- return n !== void 0 && !this.isLevelEnabled(n) ? this : (this.indent + r < 0 && (r = -this.indent), this.tab(r), typeof t == "function" ? t() : Array.isArray(t) ? this.lines(t, n) : this.log(t, n), this.shiftTab(r), this);
483
- }
484
- /**
485
- * Increases the level of indentation.
486
- * @param amount - The amount to increase the level of indentation with.
487
- */
488
- tab(t = 1) {
489
- return this.indent += t, this.indent < 0 && (this.indent = 0), this;
490
- }
491
- /**
492
- * Decreases the level of indentation.
493
- * @param amount - The amount to decrease the level of indentation with.
494
- */
495
- shiftTab(t = 1) {
496
- return this.indent -= t, this.indent < 0 && (this.indent = 0), this;
497
- }
498
- setPrefix(t, r) {
499
- return typeof t == "string" ? this.prefix = {
500
- global: t
501
- } : typeof t == "object" ? this.prefix = t : this.prefix[t] = r, this;
502
- }
503
- // ===== Logging status messages =====
504
- /**
505
- * Logs an info message about a URL being fetched.
506
- * @param url - The URL being fetched.
507
- */
508
- fetching(t) {
509
- return this.pending(`Fetching: ${this.highlight(t)}`);
510
- }
511
- /**
512
- * Logs an info message that implies a pending state.
513
- * @param message - The status message.
514
- */
515
- pending(t) {
516
- return this.info(s.yellow(t));
517
- }
518
- /**
519
- * Logs an error message.
520
- * @param message - The error message or reason.
521
- * @param details - The details of the error message.
522
- */
523
- error(t, ...r) {
524
- return this.#t++, this.isLevelEnabled(
525
- 4
526
- /* Error */
527
- ) ? (typeof t == "string" ? this.statusMessage(
528
- s.red(t),
529
- r,
530
- 4
531
- /* Error */
532
- ) : console.error(t, ...r), this) : this;
533
- }
534
- /**
535
- * Logs a warning message.
536
- * @param message - The warning message.
537
- * @param details - The details of the warning message.
538
- */
539
- warn(t, ...r) {
540
- return this.#r++, this.statusMessage(
541
- s.yellow(t),
542
- r,
543
- 3
544
- /* Warning */
545
- );
546
- }
547
- /**
548
- * Logs a success message.
549
- * @param message - The success message.
550
- * @param details - The details of the success message.
551
- */
552
- success(t, ...r) {
553
- return this.statusMessage(
554
- s.green(t),
555
- r,
556
- 2
557
- /* Success */
558
- );
559
- }
560
- /**
561
- * Logs an info message.
562
- * @param message - The info message.
563
- * @param details - The details of the info message.
564
- */
565
- info(t, ...r) {
566
- return this.statusMessage(
567
- t,
568
- r,
569
- 1
570
- /* Info */
571
- );
572
- }
573
- /**
574
- * Logs a status message.
575
- * @param message - The status message.
576
- * @param details - The details of the status message.
577
- * @param level - The log level.
578
- */
579
- statusMessage(t, r, n) {
580
- let u = t;
581
- if (r.length) {
582
- const h = this.indentString ? this.indentString.repeat(this.indent + 1) : " ";
583
- u += `
584
- ` + r.map((p) => h + String(p)).join(`
585
- `);
586
- }
587
- return this.text(u, n);
588
- }
589
- /**
590
- * Logs the amount of errors and warnings that have been logged since the previous call to this function or the creation of this logger.
591
- */
592
- summary() {
593
- const t = `${this.#t} error${this.#t != 1 ? "s" : ""}`, r = `${this.#r} warning${this.#r != 1 ? "s" : ""}`;
594
- let n = `Found ${t} and ${r}`;
595
- return this.#t > 0 ? n = s.red(n) : this.#r > 0 ? n = s.yellow(n) : n = s.green(n), this.text(n), this.#t = 0, this.#r = 0, this;
596
- }
597
- // ===== Logging text =====
598
- /**
599
- * Logs a labeled parameter.
600
- *
601
- * The value is emphasized using {@link emphasize}.
602
- * @param label - The label of the parameter.
603
- * @param value - The value of the parameter.
604
- * @param level - The log level.
605
- */
606
- parameter(t, r, n) {
607
- return this.text(`${t}: ${this.emphasize(String(r))}`, n);
608
- }
609
- /**
610
- * Logs properties as a list of key-value pairs.
611
- * @param properties - The properties to log.
612
- * @param level - The log level.
613
- * @see {@link value()}
614
- */
615
- properties(t, r) {
616
- for (const [n, u] of Object.entries(t))
617
- this.value(`- ${n}`, u, r);
618
- return this;
619
- }
620
- /**
621
- * Logs a labeled value.
622
- *
623
- * The value is highlighted using {@link highlight}.
624
- * @param label - The label of the value.
625
- * @param value - The value.
626
- * @param level - The log level.
627
- */
628
- value(t, r, n) {
629
- return this.text(`${t}: ${this.highlight(String(r))}`, n);
630
- }
631
- /**
632
- * Logs emphasized text.
633
- * @param text - The text to log.
634
- * @param level - The log level.
635
- */
636
- emphasized(t, r) {
637
- return this.text(this.emphasize(t), r);
638
- }
639
- /**
640
- * Logs highlighted text.
641
- * @param text - The text to log.
642
- * @param level - The log level.
643
- */
644
- highlighted(t, r) {
645
- return this.text(this.highlight(t), r);
646
- }
647
- /**
648
- * Logs each item on a new line.
649
- * @param lines - The items to log.
650
- * @param level - The log level.
651
- */
652
- lines(t, r) {
653
- return t.map(String).forEach((n) => this.text(n, r)), this;
654
- }
655
- /**
656
- * Logs a message.
657
- * @param message - The message to log.
658
- * @param level - The log level.
659
- */
660
- log(t, r) {
661
- return this.text(String(t), r);
662
- }
663
- /**
664
- * Logs text using this logger's format.
665
- * @param text - The text to log.
666
- * @param level - The log level.
667
- */
668
- text(t, r = 0) {
669
- if (!this.isLevelEnabled(r))
670
- return this;
671
- const n = this.format(this.applyPrefix(t, r));
672
- switch (r) {
673
- case 1:
674
- console.info(n);
675
- break;
676
- case 3:
677
- console.warn(n);
678
- break;
679
- case 4:
680
- console.error(n);
681
- break;
682
- default:
683
- console.log(n);
684
- break;
685
- }
686
- return this;
687
- }
688
- /**
689
- * Logs an newline character.
690
- */
691
- newLine() {
692
- return console.log(`
693
- `), this;
694
- }
695
- /**
696
- * Checks if the given log level is enabled.
697
- * @param level - The log level to check.
698
- */
699
- isLevelEnabled(t) {
700
- return this.level === void 0 ? !0 : Array.isArray(this.level) ? this.level.includes(t) : this.level <= t;
701
- }
702
- // ===== Formatting strings =====
703
- /**
704
- * Formats text using this logger's formatting properties.
705
- * @param text - The text to format.
706
- */
707
- format(t) {
708
- return this.indentString ? this.applyPrefix(this.indentString.repeat(this.indent) + t) : this.applyPrefix(t);
709
- }
710
- /**
711
- * Prepends a prefix to text.
712
- * @param text - The text to apply the prefix to.
713
- * @param level - The log level.
714
- */
715
- applyPrefix(t, r) {
716
- const n = r ? this.prefix[r] : this.prefix.global;
717
- return n ? `${n} ${t}` : t;
718
- }
719
- }
720
- function N(e) {
721
- return `# ${e}`;
722
- }
723
- function D(e) {
724
- return `## ${e}`;
725
- }
726
- function T(e) {
727
- return `### ${e}`;
728
- }
729
- function z(e) {
730
- return `#### ${e}`;
731
- }
732
- function F(e) {
733
- return `##### ${e}`;
734
- }
735
- function P(e) {
736
- return `###### ${e}`;
737
- }
738
- function I(e) {
739
- return `**${e}**`;
740
- }
741
- function j(e) {
742
- return `*${e}*`;
743
- }
744
- function q(e) {
745
- return `\`${e}\``;
746
- }
747
- function U(e) {
748
- return `\`\`\`${e}\`\`\``;
749
- }
750
- function H(e) {
751
- return `~~${e}~~`;
752
- }
753
- function V(e, t) {
754
- return `[${e}](${t})`;
755
- }
756
- function W(e) {
757
- return `> ${e}`;
758
- }
759
- function X() {
44
+ function B() {
760
45
  return "---";
761
46
  }
762
- const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47
+ const T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
763
48
  __proto__: null,
764
- bold: I,
49
+ bold: F,
765
50
  code: q,
766
- codeBlock: U,
767
- heading1: N,
768
- heading2: D,
769
- heading3: T,
770
- heading4: z,
771
- heading5: F,
772
- heading6: P,
773
- horizontalRule: X,
774
- italic: j,
775
- link: V,
776
- quote: W,
777
- strikethrough: H
51
+ codeBlock: D,
52
+ heading1: O,
53
+ heading2: $,
54
+ heading3: b,
55
+ heading4: w,
56
+ heading5: S,
57
+ heading6: A,
58
+ horizontalRule: B,
59
+ italic: z,
60
+ link: M,
61
+ quote: N,
62
+ strikethrough: L
778
63
  }, Symbol.toStringTag, { value: "Module" }));
779
- class d {
64
+ class c {
780
65
  x;
781
66
  y;
782
- constructor(t, r) {
783
- this.x = t, this.y = r ?? t;
67
+ constructor(r, e) {
68
+ this.x = r ?? 0, this.y = e ?? this.x;
784
69
  }
785
70
  static get ZERO() {
786
- return new d(0, 0);
71
+ return new c(0, 0);
787
72
  }
788
73
  get clone() {
789
- return new d(this.x, this.y);
74
+ return new c(this.x, this.y);
790
75
  }
791
76
  get magnitude() {
792
77
  return this.getDistance(this);
793
78
  }
794
- setX(t) {
795
- return this.x = t, this;
79
+ setX(r) {
80
+ return this.x = r, this;
796
81
  }
797
- setY(t) {
798
- return this.y = t, this;
82
+ setY(r) {
83
+ return this.y = r, this;
799
84
  }
800
- set(t, r) {
801
- return this.x = t, this.y = r, this;
85
+ set(r, e) {
86
+ return this.x = r, this.y = e, this;
802
87
  }
803
88
  round() {
804
89
  return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
805
90
  }
806
91
  normalize() {
807
- const t = this.magnitude;
808
- return this.scale(t === 0 ? 0 : 1 / t);
92
+ const r = this.magnitude;
93
+ return this.scale(r === 0 ? 0 : 1 / r);
809
94
  }
810
- scale(t) {
811
- return this.multiply(t);
95
+ scale(r) {
96
+ return this.multiply(r);
812
97
  }
813
- getDistanceSquared(t, r) {
814
- const n = d.parseVector(t, r), u = this.x - n.x, h = this.y - n.y;
815
- return u * u + h * h;
98
+ getDistanceSquared(r, e) {
99
+ const i = c.parseVector(r, e), a = this.x - i.x, h = this.y - i.y;
100
+ return a * a + h * h;
816
101
  }
817
- getDistance(t, r) {
818
- const n = d.parseVector(t, r);
819
- return Math.sqrt(this.getDistanceSquared(n.x, n.y));
102
+ getDistance(r, e) {
103
+ const i = c.parseVector(r, e);
104
+ return Math.sqrt(this.getDistanceSquared(i.x, i.y));
820
105
  }
821
- add(t, r) {
822
- const n = d.parseVector(t, r);
823
- return this.x += n.x, this.y += n.y, this;
106
+ add(r, e) {
107
+ const i = c.parseVector(r, e);
108
+ return this.x += i.x, this.y += i.y, this;
824
109
  }
825
- subtract(t, r) {
826
- const n = d.parseVector(t, r);
827
- return this.x -= n.x, this.y -= n.y, this;
110
+ subtract(r, e) {
111
+ const i = c.parseVector(r, e);
112
+ return this.x -= i.x, this.y -= i.y, this;
828
113
  }
829
- multiply(t, r) {
830
- const n = d.parseVector(t, r);
831
- return this.x *= n.x, this.y *= n.y, this;
114
+ multiply(r, e) {
115
+ const i = c.parseVector(r, e);
116
+ return this.x *= i.x, this.y *= i.y, this;
832
117
  }
833
- divide(t, r) {
834
- const n = d.parseVector(t, r);
835
- return this.x /= n.x, this.y /= n.y, this;
118
+ divide(r, e) {
119
+ const i = c.parseVector(r, e);
120
+ return this.x /= i.x, this.y /= i.y, this;
836
121
  }
837
- lerp(t, r) {
838
- return this.x += (t.x - this.x) * r, this.y += (t.y - this.y) * r, this;
122
+ lerp(r, e) {
123
+ return this.x += (r.x - this.x) * e, this.y += (r.y - this.y) * e, this;
839
124
  }
840
- static sum(t, r) {
841
- return t.clone.add(r);
125
+ static sum(r, e) {
126
+ return r.clone.add(e);
842
127
  }
843
- static difference(t, r) {
844
- return t.clone.subtract(r);
128
+ static difference(r, e) {
129
+ return r.clone.subtract(e);
845
130
  }
846
- static product(t, r) {
847
- return t.clone.multiply(r);
131
+ static product(r, e) {
132
+ return r.clone.multiply(e);
848
133
  }
849
- static division(t, r) {
850
- return t.clone.divide(r);
134
+ static division(r, e) {
135
+ return r.clone.divide(e);
851
136
  }
852
- static scale(t, r) {
853
- return t.clone.scale(r);
137
+ static scale(r, e) {
138
+ return r.clone.scale(e);
854
139
  }
855
- static normalize(t) {
856
- return t.clone.normalize();
140
+ static normalize(r) {
141
+ return r.clone.normalize();
857
142
  }
858
- static lerp(t, r, n) {
859
- return t.clone.lerp(r, n);
143
+ static lerp(r, e, i) {
144
+ return r.clone.lerp(e, i);
860
145
  }
861
- static from({ x: t, y: r }) {
862
- return new d(t, r);
146
+ static from({ x: r, y: e }) {
147
+ return new c(r, e);
863
148
  }
864
- static parseVector(t, r) {
865
- return t instanceof d ? (r = t.y, t = t.x) : r === void 0 && (r = t), { x: t, y: r };
149
+ static parseVector(r, e) {
150
+ return r instanceof c ? (e = r.y, r = r.x) : e === void 0 && (e = r), { x: r, y: e };
866
151
  }
867
152
  }
868
- class k {
153
+ class p {
869
154
  /**
870
155
  * Returns `true` if this result is a {@link Result.Success}.
871
156
  */
@@ -881,174 +166,199 @@ class k {
881
166
  /**
882
167
  * Executes a callback for side effects if this result is a {@link Result.Success}.
883
168
  */
884
- ifOk(t) {
885
- return this.isOk() && t(this.value), this;
169
+ ifOk(r) {
170
+ return this.isOk() && r(this.value), this;
886
171
  }
887
172
  /**
888
173
  * Executes a callback for side effects if this result is a {@link Result.Failure}.
889
174
  */
890
- ifError(t) {
891
- return this.isError() && t(this.error), this;
175
+ ifError(r) {
176
+ return this.isError() && r(this.error), this;
892
177
  }
893
178
  }
894
- var v;
895
- ((e) => {
896
- class t extends k {
897
- constructor(i) {
898
- super(), this.value = i;
179
+ var d;
180
+ ((n) => {
181
+ class r extends p {
182
+ constructor(t) {
183
+ super(), this.value = t;
899
184
  }
900
185
  value;
901
186
  isOk() {
902
187
  return !0;
903
188
  }
904
- map(i) {
905
- return n(i(this.value));
906
- }
907
- mapError(i) {
908
- return n(this.value);
189
+ map(t) {
190
+ return i(t(this.value));
909
191
  }
910
- next(i) {
192
+ mapError(t) {
911
193
  return i(this.value);
912
194
  }
913
- orElse(i) {
195
+ next(t) {
196
+ return t(this.value);
197
+ }
198
+ orElse(t) {
914
199
  return this;
915
200
  }
916
- unwrapOr(i) {
201
+ unwrapOr(t) {
917
202
  return this.value;
918
203
  }
919
- match(i, c) {
920
- return i(this.value);
204
+ match(t, o) {
205
+ return t(this.value);
921
206
  }
922
- filter(i, c) {
923
- return i(this.value) ? n(this.value) : u(c(this.value));
207
+ filter(t, o) {
208
+ return t(this.value) ? i(this.value) : a(o(this.value));
924
209
  }
925
210
  }
926
- e.Success = t;
927
- class r extends k {
928
- constructor(i) {
929
- super(), this.error = i;
211
+ n.Success = r;
212
+ class e extends p {
213
+ constructor(t) {
214
+ super(), this.error = t;
930
215
  }
931
216
  error;
932
217
  isError() {
933
218
  return !0;
934
219
  }
935
- map(i) {
936
- return u(this.error);
220
+ map(t) {
221
+ return a(this.error);
937
222
  }
938
- mapError(i) {
939
- return u(i(this.error));
223
+ mapError(t) {
224
+ return a(t(this.error));
940
225
  }
941
- next(i) {
942
- return u(this.error);
226
+ next(t) {
227
+ return a(this.error);
943
228
  }
944
- orElse(i) {
945
- return i(this.error);
229
+ orElse(t) {
230
+ return t(this.error);
946
231
  }
947
- unwrapOr(i) {
948
- return i;
232
+ unwrapOr(t) {
233
+ return t;
949
234
  }
950
- match(i, c) {
951
- return c(this.error);
235
+ match(t, o) {
236
+ return o(this.error);
952
237
  }
953
- filter(i, c) {
954
- return u(this.error);
238
+ filter(t, o) {
239
+ return a(this.error);
955
240
  }
956
241
  }
957
- e.Failure = r;
958
- function n(o) {
959
- return new t(o);
242
+ n.Failure = e;
243
+ function i(s) {
244
+ return new r(s);
960
245
  }
961
- e.ok = n;
962
- function u(o) {
963
- return new r(o);
246
+ n.ok = i;
247
+ function a(s) {
248
+ return new e(s);
964
249
  }
965
- e.error = u;
966
- function h(o, i) {
250
+ n.error = a;
251
+ function h(s, t) {
967
252
  try {
968
- return n(o());
969
- } catch (c) {
970
- return u(i ? i(c) : c);
253
+ return i(s());
254
+ } catch (o) {
255
+ return a(t ? t(o) : o);
971
256
  }
972
257
  }
973
- e.wrap = h;
974
- function p(o, i) {
975
- return o != null ? n(o) : u(i);
976
- }
977
- e.nonNullOr = p;
978
- function y(o, i) {
979
- return o != null ? n(o) : i();
980
- }
981
- e.nonNullOrElse = y;
982
- function l(o, i, c) {
983
- let f = o;
984
- for (; i(f); ) {
985
- const x = c(f);
986
- if (x.isError())
987
- return x;
988
- f = x.value;
258
+ n.wrap = h;
259
+ function m(s, t) {
260
+ return s != null ? i(s) : a(t);
261
+ }
262
+ n.nonNullOr = m;
263
+ function g(s, t) {
264
+ return s != null ? i(s) : t();
265
+ }
266
+ n.nonNullOrElse = g;
267
+ function y(s, t, o) {
268
+ let u = s;
269
+ for (; t(u); ) {
270
+ const l = o(u);
271
+ if (l.isError())
272
+ return l;
273
+ u = l.value;
989
274
  }
990
- return n(f);
991
- }
992
- e.repeat = l;
993
- function g(o, i, c) {
994
- let f = c;
995
- for (const x of o) {
996
- const B = i(f, x);
997
- if (B.isError())
998
- return B;
999
- f = B.value;
275
+ return i(u);
276
+ }
277
+ n.repeat = y;
278
+ function v(s, t, o) {
279
+ let u = o;
280
+ for (const l of s) {
281
+ const f = t(u, l);
282
+ if (f.isError())
283
+ return f;
284
+ u = f.value;
1000
285
  }
1001
- return n(f);
1002
- }
1003
- e.reduce = g;
1004
- function m(o) {
1005
- const i = [];
1006
- for (const c of o) {
1007
- if (c.isError())
1008
- return u(c.error);
1009
- i.push(c.value);
286
+ return i(u);
287
+ }
288
+ n.reduce = v;
289
+ function x(s) {
290
+ const t = [];
291
+ for (const o of s) {
292
+ if (o.isError())
293
+ return a(o.error);
294
+ t.push(o.value);
1010
295
  }
1011
- return n(i);
1012
- }
1013
- e.all = m;
1014
- function b(o, i, c) {
1015
- for (const f of o) {
1016
- const x = i(f);
1017
- if (x.isOk())
1018
- return x;
296
+ return i(t);
297
+ }
298
+ n.all = x;
299
+ function E(s, t, o) {
300
+ for (const u of s) {
301
+ const l = t(u);
302
+ if (l.isOk())
303
+ return l;
1019
304
  }
1020
- return c;
305
+ return o;
1021
306
  }
1022
- e.any = b;
1023
- function $(o, i, c, f) {
1024
- return i(o) ? n(c(o)) : u(f(o));
307
+ n.any = E;
308
+ function k(s, t, o, u) {
309
+ return t(s) ? i(o(s)) : a(u(s));
1025
310
  }
1026
- e.require = $;
1027
- })(v || (v = {}));
311
+ n.require = k;
312
+ })(d || (d = {}));
1028
313
  export {
1029
- a as ANSI,
1030
- s as Ansi,
1031
- k as BaseResult,
1032
- K as EventEmitter,
1033
- M as LogLevel,
1034
- et as Logger,
1035
- nt as Markdown,
1036
- v as Result,
1037
- d as Vector2,
1038
- G as clamp,
1039
- J as formatRelativeTime,
1040
- S as formatTime,
1041
- rt as getLongestCommonPrefix,
1042
- O as isValidInteger,
1043
- C as isValidNumber,
1044
- tt as kebabToCamelCase,
1045
- _ as parseBool,
1046
- L as parseOptionalFloat,
1047
- A as parseOptionalInteger,
1048
- Y as randomFromArray,
1049
- Q as randomRange,
1050
- Z as removeDuplicatesFromArray,
1051
- E as removeFromArray,
1052
- R as round
314
+ _ as ANSI,
315
+ j as Ansi,
316
+ I as BASE_URL,
317
+ p as BaseResult,
318
+ tr as EventEmitter,
319
+ P as LogLevel,
320
+ V as Logger,
321
+ T as Markdown,
322
+ d as Result,
323
+ c as Vector2,
324
+ er as capitalize,
325
+ nr as clamp,
326
+ ir as fillTemplate,
327
+ sr as formatRelativeTime,
328
+ or as formatTime,
329
+ ar as getLongestCommonPrefix,
330
+ X as inspect,
331
+ Y as inspectArray,
332
+ Z as inspectError,
333
+ G as inspectFunction,
334
+ H as inspectFunctionCall,
335
+ J as inspectMap,
336
+ K as inspectObject,
337
+ Q as inspectReactElement,
338
+ W as inspectSet,
339
+ R as inspectString,
340
+ ur as interleave,
341
+ qr as isObject,
342
+ cr as isValidInteger,
343
+ lr as isValidNumber,
344
+ hr as isValidUrl,
345
+ fr as isolateSubstring,
346
+ pr as kebabToCamelCase,
347
+ Dr as mergeDeep,
348
+ dr as parseBool,
349
+ mr as parseOptionalFloat,
350
+ gr as parseOptionalInteger,
351
+ yr as randomFromArray,
352
+ vr as randomIndex,
353
+ xr as randomInt,
354
+ Er as randomRange,
355
+ kr as removeBaseUrl,
356
+ Or as removeDuplicatesFromArray,
357
+ $r as removeFromArray,
358
+ br as removeUrlProtocol,
359
+ wr as replaceAll,
360
+ Sr as resolveUrl,
361
+ Ar as round,
362
+ Fr as splitAt
1053
363
  };
1054
364
  //# sourceMappingURL=main.js.map