@prozilla-os/shared 1.2.1 → 1.3.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,11 +1,7 @@
1
- var g = Object.defineProperty;
2
- var m = (t) => {
3
- throw TypeError(t);
4
- };
5
- var M = (t, n, e) => n in t ? g(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
6
- var d = (t, n, e) => M(t, typeof n != "symbol" ? n + "" : n, e), y = (t, n, e) => n.has(t) || m("Cannot " + e);
7
- var i = (t, n, e) => (y(t, n, "read from private field"), e ? e.call(t) : n.get(t)), x = (t, n, e) => n.has(t) ? m("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(t) : n.set(t, e);
8
- const A = {
1
+ const h = {
2
+ /**
3
+ * Foreground colors.
4
+ */
9
5
  fg: {
10
6
  black: "\x1B[30m",
11
7
  red: "\x1B[31m",
@@ -16,24 +12,49 @@ const A = {
16
12
  cyan: "\x1B[36m",
17
13
  white: "\x1B[37m"
18
14
  },
19
- bg: {},
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
+ home: "\x1B[H"
36
+ },
37
+ /**
38
+ * Decorations.
39
+ */
20
40
  decoration: {
21
41
  dim: "\x1B[2m",
22
- bold: "\x1B[1m"
42
+ bold: "\x1B[1m",
43
+ underline: "\x1B[4m"
23
44
  },
24
45
  reset: "\x1B[0m"
25
46
  };
26
- function E(t, n) {
27
- const e = n.indexOf(t);
28
- e !== -1 && n.splice(e, 1);
47
+ function x(r, t) {
48
+ const e = t.indexOf(r);
49
+ e !== -1 && t.splice(e, 1);
29
50
  }
30
- function O(t) {
31
- return t[Math.floor(Math.random() * t.length)];
51
+ function A(r) {
52
+ return r[Math.floor(Math.random() * r.length)];
32
53
  }
33
- function T(t) {
34
- return t.filter((n, e) => t.indexOf(n) === e);
54
+ function F(r) {
55
+ return r.filter((t, e) => r.indexOf(t) === e);
35
56
  }
36
- const p = {
57
+ const m = {
37
58
  s: 1e3,
38
59
  m: 1e3 * 60,
39
60
  h: 1e3 * 60 * 60,
@@ -43,97 +64,675 @@ const p = {
43
64
  y: 1e3 * 60 * 60 * 24 * 365,
44
65
  c: 1e3 * 60 * 60 * 24 * 365 * 100
45
66
  };
46
- function b(t, n = 3, e) {
47
- const s = [], a = (o, f) => {
67
+ function y(r, t = 3, e = !1) {
68
+ const i = [], s = (o, l) => {
48
69
  if (!e)
49
70
  return o.join(", ");
50
- let u = "", h = "";
51
- return f ? h = "ago" : u = "in", [u, o.join(", "), h].join(" ").trim();
71
+ let f = "", g = "";
72
+ return l ? g = "ago" : f = "in", [f, o.join(", "), g].join(" ").trim();
52
73
  };
53
- let c = !1;
54
- if (t < 0 && (t = -t, c = !0), Math.abs(t) < p.s)
55
- return a(["less than a second"], c);
56
- const l = [], B = {
57
- s: "seconds",
58
- m: "minutes",
59
- h: "hours",
60
- d: "days",
61
- n: "months",
62
- y: "years"
74
+ let u = !1;
75
+ if (r < 0 && (r = -r, u = !0), Math.abs(r) < m.s)
76
+ return s(["less than a second"], u);
77
+ const c = [], d = {
78
+ s: "second",
79
+ m: "minute",
80
+ h: "hour",
81
+ d: "day",
82
+ n: "month",
83
+ y: "year"
63
84
  };
64
- for (const [o, f] of Object.entries(p).reverse()) {
85
+ for (const [o, l] of Object.entries(m).reverse()) {
65
86
  if (o === "w" || o === "c")
66
87
  continue;
67
- const u = Math.floor(t / f);
68
- t -= u * f, u > 0 && l.push({ amount: u, label: B[o] });
88
+ const f = Math.floor(r / l);
89
+ r -= f * l, f > 0 && c.push({ amount: f, label: f != 1 ? d[o] + "s" : d[o] });
90
+ }
91
+ for (let o = 0; o < t; o++)
92
+ if (o < c.length) {
93
+ const l = c[o];
94
+ i.push(`${l.amount} ${l.label}`);
95
+ }
96
+ return i.length === 0 ? s(["less than a second"], u) : s(i, u);
97
+ }
98
+ function C(r, t = 3, e = !1) {
99
+ const i = r.valueOf() - Date.now();
100
+ return y(i, t, e);
101
+ }
102
+ class R {
103
+ #t = {};
104
+ /**
105
+ * Starts listening to an event.
106
+ * @param event - The event to listen to.
107
+ * @param listener - The function to call when the event is emitted.
108
+ * @returns The listener.
109
+ */
110
+ on(t, e) {
111
+ return this.#t[t] === void 0 ? this.#t[t] = [e] : this.#t[t].push(e), e;
112
+ }
113
+ /**
114
+ * Registers an event listener that is automatically removed when called.
115
+ * @param event - The event to listen to.
116
+ * @param listener - The function to call once the event is emitted.
117
+ * @returns The wrapped listener.
118
+ */
119
+ once(t, e) {
120
+ const i = this.on(t, (...s) => {
121
+ this.off(t, i), e(...s);
122
+ });
123
+ return i;
69
124
  }
70
- for (let o = 0; o < n; o++) {
71
- const f = l[o];
72
- f && s.push(`${f.amount} ${f.label}`);
125
+ /**
126
+ * Starts listening to an event.
127
+ * @param event - The event to listen to.
128
+ * @param listener - The function to call when the event is emitted.
129
+ * @returns The wrapped listener.
130
+ */
131
+ onAsync(t, e, i) {
132
+ return this.on(t, (...s) => {
133
+ e(...s).catch((u) => {
134
+ i ? i(u) : console.error(u);
135
+ });
136
+ });
73
137
  }
74
- return s.length === 0 ? a(["less than a second"], c) : a(s, c);
138
+ /**
139
+ * Removes an event listener.
140
+ * @param event - The event to remove the listener from.
141
+ * @param listener - The listener to remove.
142
+ */
143
+ off(t, e) {
144
+ this.#t[t] !== void 0 && x(e, this.#t[t]);
145
+ }
146
+ /**
147
+ * Emits an event to all its listeners.
148
+ * @param event - The event to emit.
149
+ * @param args - The arguments to pass to the listeners.
150
+ */
151
+ emit(t, ...e) {
152
+ if (this.#t[t] !== void 0)
153
+ for (const i of this.#t[t])
154
+ i(...e);
155
+ }
156
+ }
157
+ function q(r, t, e) {
158
+ return r < t ? t : r > e ? e : r;
159
+ }
160
+ function O(r, t) {
161
+ return Math.random() * (t - r) + r;
162
+ }
163
+ function W(r, t) {
164
+ const e = Math.pow(10, t ?? 0);
165
+ return Math.round(r * e) / e;
166
+ }
167
+ function p(r) {
168
+ return typeof r == "number" ? !0 : r.trim() === "" ? !1 : Number.isInteger(Number(r));
169
+ }
170
+ function b(r) {
171
+ return typeof r == "number" ? !0 : r.trim() === "" ? !1 : !isNaN(Number(r));
172
+ }
173
+ function X(r, t = 0) {
174
+ return r !== void 0 && p(r) ? Number(r) : t;
175
+ }
176
+ function Y(r, t = 0) {
177
+ return r !== void 0 && b(r) ? parseFloat(r) : t;
75
178
  }
76
- function j(t, n = 3, e) {
77
- const s = t.valueOf() - Date.now();
78
- return b(s, n, e);
179
+ function Z(r) {
180
+ return r.trim().toLowerCase() === "true";
79
181
  }
80
- var r;
81
- class w {
82
- constructor() {
83
- x(this, r, {});
182
+ function H(r) {
183
+ if (!r.length) return "";
184
+ let t = r[0];
185
+ for (let e = 1; e < r.length; e++)
186
+ for (; r[e].indexOf(t) !== 0; )
187
+ if (t = t.substring(0, t.length - 1), t === "") return "";
188
+ return t;
189
+ }
190
+ class n {
191
+ /**
192
+ * Makes text black using {@link ANSI.fg.black}.
193
+ */
194
+ static black(t) {
195
+ return n.#t(t, h.fg.black);
84
196
  }
85
197
  /**
86
- * Add event listener for an event
198
+ * Makes text red using {@link ANSI.fg.red}.
87
199
  */
88
- on(n, e) {
89
- return i(this, r)[n] || (i(this, r)[n] = []), i(this, r)[n].push(e), e;
200
+ static red(t) {
201
+ return n.#t(t, h.fg.red);
90
202
  }
91
203
  /**
92
- * Remove event listener for an event
204
+ * Makes text green using {@link ANSI.fg.green}.
93
205
  */
94
- off(n, e) {
95
- i(this, r)[n] && (i(this, r)[n] = i(this, r)[n].filter(
96
- (s) => s !== e
97
- ));
206
+ static green(t) {
207
+ return n.#t(t, h.fg.green);
98
208
  }
99
209
  /**
100
- * Dispatch event
210
+ * Makes text yellow using {@link ANSI.fg.yellow}.
101
211
  */
102
- emit(n, e) {
103
- i(this, r)[n] && i(this, r)[n].forEach((s) => {
104
- s(e);
105
- });
212
+ static yellow(t) {
213
+ return n.#t(t, h.fg.yellow);
214
+ }
215
+ /**
216
+ * Makes text blue using {@link ANSI.fg.blue}.
217
+ */
218
+ static blue(t) {
219
+ return n.#t(t, h.fg.blue);
220
+ }
221
+ /**
222
+ * Makes text magenta using {@link ANSI.fg.magenta}.
223
+ */
224
+ static magenta(t) {
225
+ return n.#t(t, h.fg.magenta);
226
+ }
227
+ /**
228
+ * Makes text cyan using {@link ANSI.fg.cyan}.
229
+ */
230
+ static cyan(t) {
231
+ return n.#t(t, h.fg.cyan);
232
+ }
233
+ /**
234
+ * Makes text white using {@link ANSI.fg.white}.
235
+ */
236
+ static white(t) {
237
+ return n.#t(t, h.fg.white);
238
+ }
239
+ /**
240
+ * Makes text bold using {@link ANSI.decoration.bold}.
241
+ */
242
+ static bold(t) {
243
+ return n.#t(t, h.decoration.bold);
244
+ }
245
+ /**
246
+ * Makes text dim using {@link ANSI.decoration.dim}.
247
+ */
248
+ static dim(t) {
249
+ return n.#t(t, h.decoration.dim);
250
+ }
251
+ static #t(t, e) {
252
+ return t = t.replaceAll(h.reset, h.reset + e), e + t + h.reset;
253
+ }
254
+ /**
255
+ * Removes all ANSI escape sequences.
256
+ */
257
+ static strip(t) {
258
+ return t.replace(/\u001b\[[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
259
+ }
260
+ /**
261
+ * Removes ANSI escape sequences for colors and background colors (SGR).
262
+ */
263
+ static stripColors(t) {
264
+ return t.replace(/\u001b\[[0-9;]*m/g, "");
265
+ }
266
+ }
267
+ var w = /* @__PURE__ */ ((r) => (r[r.Debug = 0] = "Debug", r[r.Info = 1] = "Info", r[r.Success = 2] = "Success", r[r.Warning = 3] = "Warning", r[r.Error = 4] = "Error", r))(w || {});
268
+ class J {
269
+ /**
270
+ * The minimum log level or an array of log levels to enable.
271
+ *
272
+ * `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.
273
+ * @default LogLevel.Debug
274
+ */
275
+ level;
276
+ /**
277
+ * The current level of indentation.
278
+ * @default 0
279
+ */
280
+ indent = 0;
281
+ /**
282
+ * The string to use for indentation.
283
+ * @default "\t"
284
+ */
285
+ indentString;
286
+ /**
287
+ * The function to use when highlighting text.
288
+ * @default Ansi.cyan
289
+ * @see {@link Ansi.cyan}
290
+ */
291
+ highlight = n.cyan;
292
+ /**
293
+ * The function to use when emphasizing text.
294
+ * @default Ansi.bold
295
+ * @see {@link Ansi.bold}
296
+ */
297
+ emphasize = n.bold;
298
+ /**
299
+ * The prefixes to prepend to logs.
300
+ * @default {
301
+ [LogLevel.Info]: Ansi.cyan("[info]"),
302
+ [LogLevel.Success]: Ansi.green("[success]"),
303
+ [LogLevel.Warning]: Ansi.yellow("[warning]"),
304
+ [LogLevel.Error]: Ansi.red("[error]"),
305
+ }
306
+ */
307
+ prefix = {};
308
+ #t = 0;
309
+ #e = 0;
310
+ constructor(t) {
311
+ 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 = {
312
+ ...this.prefix,
313
+ ...t.prefix
314
+ })));
315
+ }
316
+ // ===== Modifying state =====
317
+ /**
318
+ * Resets all properties to their default values.
319
+ */
320
+ reset() {
321
+ return this.level = 0, this.indent = 0, this.indentString = " ", this.highlight = n.cyan, this.emphasize = n.bold, this.prefix = {
322
+ 1: n.cyan("[info]"),
323
+ 2: n.green("[success]"),
324
+ 3: n.yellow("[warning]"),
325
+ 4: n.red("[error]")
326
+ }, this.#t = 0, this.#e = 0, this;
327
+ }
328
+ indented(t, e = 1, i) {
329
+ return i !== void 0 && !this.isLevelEnabled(i) ? this : (this.indent + e < 0 && (e = -this.indent), this.tab(e), typeof t == "function" ? t() : Array.isArray(t) ? this.lines(t, i) : this.log(t, i), this.shiftTab(e), this);
330
+ }
331
+ /**
332
+ * Increases the level of indentation.
333
+ * @param amount - The amount to increase the level of indentation with.
334
+ */
335
+ tab(t = 1) {
336
+ return this.indent += t, this.indent < 0 && (this.indent = 0), this;
337
+ }
338
+ /**
339
+ * Decreases the level of indentation.
340
+ * @param amount - The amount to decrease the level of indentation with.
341
+ */
342
+ shiftTab(t = 1) {
343
+ return this.indent -= t, this.indent < 0 && (this.indent = 0), this;
344
+ }
345
+ setPrefix(t, e) {
346
+ return typeof t == "string" ? this.prefix = {
347
+ global: t
348
+ } : typeof t == "object" ? this.prefix = t : this.prefix[t] = e, this;
349
+ }
350
+ // ===== Logging status messages =====
351
+ /**
352
+ * Logs an info message about a URL being fetched.
353
+ * @param url - The URL being fetched.
354
+ */
355
+ fetching(t) {
356
+ return this.pending(`Fetching: ${this.highlight(t)}`);
106
357
  }
358
+ /**
359
+ * Logs an info message that implies a pending state.
360
+ * @param message - The status message.
361
+ */
362
+ pending(t) {
363
+ return this.info(n.yellow(t));
364
+ }
365
+ /**
366
+ * Logs an error message.
367
+ * @param message - The error message or reason.
368
+ * @param details - The details of the error message.
369
+ */
370
+ error(t, ...e) {
371
+ return this.#t++, this.isLevelEnabled(
372
+ 4
373
+ /* Error */
374
+ ) ? (typeof t == "string" ? this.statusMessage(
375
+ n.red(t),
376
+ e,
377
+ 4
378
+ /* Error */
379
+ ) : console.error(t, ...e), this) : this;
380
+ }
381
+ /**
382
+ * Logs a warning message.
383
+ * @param message - The warning message.
384
+ * @param details - The details of the warning message.
385
+ */
386
+ warn(t, ...e) {
387
+ return this.#e++, this.statusMessage(
388
+ n.yellow(t),
389
+ e,
390
+ 3
391
+ /* Warning */
392
+ );
393
+ }
394
+ /**
395
+ * Logs a success message.
396
+ * @param message - The success message.
397
+ * @param details - The details of the success message.
398
+ */
399
+ success(t, ...e) {
400
+ return this.statusMessage(
401
+ n.green(t),
402
+ e,
403
+ 2
404
+ /* Success */
405
+ );
406
+ }
407
+ /**
408
+ * Logs an info message.
409
+ * @param message - The info message.
410
+ * @param details - The details of the info message.
411
+ */
412
+ info(t, ...e) {
413
+ return this.statusMessage(
414
+ t,
415
+ e,
416
+ 1
417
+ /* Info */
418
+ );
419
+ }
420
+ /**
421
+ * Logs a status message.
422
+ * @param message - The status message.
423
+ * @param details - The details of the status message.
424
+ * @param level - The log level.
425
+ */
426
+ statusMessage(t, e, i) {
427
+ let s = t;
428
+ if (e.length) {
429
+ const u = this.indentString ? this.indentString.repeat(this.indent + 1) : " ";
430
+ s += `
431
+ ` + e.map((c) => u + String(c)).join(`
432
+ `);
433
+ }
434
+ return this.text(s, i);
435
+ }
436
+ /**
437
+ * Logs the amount of errors and warnings that have been logged since the previous call to this function or the creation of this logger.
438
+ */
439
+ summary() {
440
+ const t = `${this.#t} error${this.#t != 1 ? "s" : ""}`, e = `${this.#e} warning${this.#e != 1 ? "s" : ""}`;
441
+ let i = `Found ${t} and ${e}`;
442
+ return this.#t > 0 ? i = n.red(i) : this.#e > 0 ? i = n.yellow(i) : i = n.green(i), this.text(i), this.#t = 0, this.#e = 0, this;
443
+ }
444
+ // ===== Logging text =====
445
+ /**
446
+ * Logs a labeled parameter.
447
+ *
448
+ * The value is emphasized using {@link emphasize}.
449
+ * @param label - The label of the parameter.
450
+ * @param value - The value of the parameter.
451
+ * @param level - The log level.
452
+ */
453
+ parameter(t, e, i) {
454
+ return this.text(`${t}: ${this.emphasize(String(e))}`, i);
455
+ }
456
+ /**
457
+ * Logs properties as a list of key-value pairs.
458
+ * @param properties - The properties to log.
459
+ * @param level - The log level.
460
+ * @see {@link value()}
461
+ */
462
+ properties(t, e) {
463
+ for (const [i, s] of Object.entries(t))
464
+ this.value(`- ${i}`, s, e);
465
+ return this;
466
+ }
467
+ /**
468
+ * Logs a labeled value.
469
+ *
470
+ * The value is highlighted using {@link highlight}.
471
+ * @param label - The label of the value.
472
+ * @param value - The value.
473
+ * @param level - The log level.
474
+ */
475
+ value(t, e, i) {
476
+ return this.text(`${t}: ${this.highlight(String(e))}`, i);
477
+ }
478
+ /**
479
+ * Logs emphasized text.
480
+ * @param text - The text to log.
481
+ * @param level - The log level.
482
+ */
483
+ emphasized(t, e) {
484
+ return this.text(this.emphasize(t), e);
485
+ }
486
+ /**
487
+ * Logs highlighted text.
488
+ * @param text - The text to log.
489
+ * @param level - The log level.
490
+ */
491
+ highlighted(t, e) {
492
+ return this.text(this.highlight(t), e);
493
+ }
494
+ /**
495
+ * Logs each item on a new line.
496
+ * @param lines - The items to log.
497
+ * @param level - The log level.
498
+ */
499
+ lines(t, e) {
500
+ return t.map(String).forEach((i) => this.text(i, e)), this;
501
+ }
502
+ /**
503
+ * Logs a message.
504
+ * @param message - The message to log.
505
+ * @param level - The log level.
506
+ */
507
+ log(t, e) {
508
+ return this.text(String(t), e);
509
+ }
510
+ /**
511
+ * Logs text using this logger's format.
512
+ * @param text - The text to log.
513
+ * @param level - The log level.
514
+ */
515
+ text(t, e = 0) {
516
+ if (!this.isLevelEnabled(e))
517
+ return this;
518
+ const i = this.format(this.applyPrefix(t, e));
519
+ switch (e) {
520
+ case 1:
521
+ console.info(i);
522
+ break;
523
+ case 3:
524
+ console.warn(i);
525
+ break;
526
+ case 4:
527
+ console.error(i);
528
+ break;
529
+ default:
530
+ console.log(i);
531
+ break;
532
+ }
533
+ return this;
534
+ }
535
+ /**
536
+ * Logs an newline character.
537
+ */
538
+ newLine() {
539
+ return console.log(`
540
+ `), this;
541
+ }
542
+ /**
543
+ * Checks if the given log level is enabled.
544
+ * @param level - The log level to check.
545
+ */
546
+ isLevelEnabled(t) {
547
+ return this.level === void 0 ? !0 : Array.isArray(this.level) ? this.level.includes(t) : this.level <= t;
548
+ }
549
+ // ===== Formatting strings =====
550
+ /**
551
+ * Formats text using this logger's formatting properties.
552
+ * @param text - The text to format.
553
+ */
554
+ format(t) {
555
+ return this.indentString ? this.applyPrefix(this.indentString.repeat(this.indent) + t) : this.applyPrefix(t);
556
+ }
557
+ /**
558
+ * Prepends a prefix to text.
559
+ * @param text - The text to apply the prefix to.
560
+ * @param level - The log level.
561
+ */
562
+ applyPrefix(t, e) {
563
+ const i = e ? this.prefix[e] : this.prefix.global;
564
+ return i ? `${i} ${t}` : t;
565
+ }
566
+ }
567
+ function $(r) {
568
+ return `# ${r}`;
569
+ }
570
+ function B(r) {
571
+ return `## ${r}`;
107
572
  }
108
- r = new WeakMap(), d(w, "EVENT_NAMES", {});
109
- function R(t, n, e) {
110
- return t < n ? n : t > e ? e : t;
573
+ function S(r) {
574
+ return `### ${r}`;
111
575
  }
112
- function D(t, n) {
113
- return Math.random() * (n - t) + t;
576
+ function M(r) {
577
+ return `#### ${r}`;
114
578
  }
115
- function F(t, n) {
116
- const e = Math.pow(10, n || 0);
117
- return Math.round(t * e) / e;
579
+ function v(r) {
580
+ return `##### ${r}`;
118
581
  }
119
- function S(t) {
120
- return typeof t == "number" || parseInt(t) || parseInt(t) === 0;
582
+ function k(r) {
583
+ return `###### ${r}`;
121
584
  }
122
- function C(t) {
123
- return t.trim().toLowerCase() === "true";
585
+ function E(r) {
586
+ return `**${r}**`;
587
+ }
588
+ function z(r) {
589
+ return `*${r}*`;
590
+ }
591
+ function D(r) {
592
+ return `\`${r}\``;
593
+ }
594
+ function I(r) {
595
+ return `\`\`\`${r}\`\`\``;
596
+ }
597
+ function N(r) {
598
+ return `~~${r}~~`;
599
+ }
600
+ function P(r, t) {
601
+ return `[${r}](${t})`;
602
+ }
603
+ function T(r) {
604
+ return `> ${r}`;
605
+ }
606
+ function j() {
607
+ return "---";
608
+ }
609
+ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
610
+ __proto__: null,
611
+ bold: E,
612
+ code: D,
613
+ codeBlock: I,
614
+ heading1: $,
615
+ heading2: B,
616
+ heading3: S,
617
+ heading4: M,
618
+ heading5: v,
619
+ heading6: k,
620
+ horizontalRule: j,
621
+ italic: z,
622
+ link: P,
623
+ quote: T,
624
+ strikethrough: N
625
+ }, Symbol.toStringTag, { value: "Module" }));
626
+ class a {
627
+ x;
628
+ y;
629
+ constructor(t, e) {
630
+ this.x = t, this.y = e ?? t;
631
+ }
632
+ static get ZERO() {
633
+ return new a(0, 0);
634
+ }
635
+ get clone() {
636
+ return new a(this.x, this.y);
637
+ }
638
+ get magnitude() {
639
+ return this.getDistance(this);
640
+ }
641
+ setX(t) {
642
+ return this.x = t, this;
643
+ }
644
+ setY(t) {
645
+ return this.y = t, this;
646
+ }
647
+ set(t, e) {
648
+ return this.x = t, this.y = e, this;
649
+ }
650
+ round() {
651
+ return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
652
+ }
653
+ normalize() {
654
+ const t = this.magnitude;
655
+ return this.scale(t === 0 ? 0 : 1 / t);
656
+ }
657
+ scale(t) {
658
+ return this.multiply(t);
659
+ }
660
+ getDistanceSquared(t, e) {
661
+ const i = a.parseVector(t, e), s = this.x - i.x, u = this.y - i.y;
662
+ return s * s + u * u;
663
+ }
664
+ getDistance(t, e) {
665
+ const i = a.parseVector(t, e);
666
+ return Math.sqrt(this.getDistanceSquared(i.x, i.y));
667
+ }
668
+ add(t, e) {
669
+ const i = a.parseVector(t, e);
670
+ return this.x += i.x, this.y += i.y, this;
671
+ }
672
+ subtract(t, e) {
673
+ const i = a.parseVector(t, e);
674
+ return this.x -= i.x, this.y -= i.y, this;
675
+ }
676
+ multiply(t, e) {
677
+ const i = a.parseVector(t, e);
678
+ return this.x *= i.x, this.y *= i.y, this;
679
+ }
680
+ divide(t, e) {
681
+ const i = a.parseVector(t, e);
682
+ return this.x /= i.x, this.y /= i.y, this;
683
+ }
684
+ lerp(t, e) {
685
+ return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this;
686
+ }
687
+ static sum(t, e) {
688
+ return t.clone.add(e);
689
+ }
690
+ static difference(t, e) {
691
+ return t.clone.subtract(e);
692
+ }
693
+ static product(t, e) {
694
+ return t.clone.multiply(e);
695
+ }
696
+ static division(t, e) {
697
+ return t.clone.divide(e);
698
+ }
699
+ static scale(t, e) {
700
+ return t.clone.scale(e);
701
+ }
702
+ static normalize(t) {
703
+ return t.clone.normalize();
704
+ }
705
+ static lerp(t, e, i) {
706
+ return t.clone.lerp(e, i);
707
+ }
708
+ static from({ x: t, y: e }) {
709
+ return new a(t, e);
710
+ }
711
+ static parseVector(t, e) {
712
+ return t instanceof a ? (e = t.y, t = t.x) : e === void 0 && (e = t), { x: t, y: e };
713
+ }
124
714
  }
125
715
  export {
126
- A as ANSI,
127
- w as EventEmitter,
128
- R as clamp,
129
- j as formatRelativeTime,
130
- b as formatTime,
131
- S as isValidInteger,
132
- C as parseBool,
133
- O as randomFromArray,
134
- D as randomRange,
135
- T as removeDuplicatesFromArray,
136
- E as removeFromArray,
137
- F as round
716
+ h as ANSI,
717
+ n as Ansi,
718
+ R as EventEmitter,
719
+ w as LogLevel,
720
+ J as Logger,
721
+ G as Markdown,
722
+ a as Vector2,
723
+ q as clamp,
724
+ C as formatRelativeTime,
725
+ y as formatTime,
726
+ H as getLongestCommonPrefix,
727
+ p as isValidInteger,
728
+ b as isValidNumber,
729
+ Z as parseBool,
730
+ Y as parseOptionalFloat,
731
+ X as parseOptionalInteger,
732
+ A as randomFromArray,
733
+ O as randomRange,
734
+ F as removeDuplicatesFromArray,
735
+ x as removeFromArray,
736
+ W as round
138
737
  };
139
738
  //# sourceMappingURL=main.js.map