@tixyel/streamelements 5.2.0 → 5.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/index.d.ts +341 -311
- package/dist/index.es.js +441 -411
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -103,10 +103,10 @@ class W extends N {
|
|
|
103
103
|
*/
|
|
104
104
|
static setByPath(e, t, a) {
|
|
105
105
|
const i = t.split(".");
|
|
106
|
-
let
|
|
106
|
+
let s = e;
|
|
107
107
|
for (let r = 0; r < i.length - 1; r++)
|
|
108
|
-
(typeof
|
|
109
|
-
return
|
|
108
|
+
(typeof s[i[r]] != "object" || s[i[r]] == null) && (s[i[r]] = {}), s = s[i[r]];
|
|
109
|
+
return s[i[i.length - 1]] = a, s;
|
|
110
110
|
}
|
|
111
111
|
on(e, t) {
|
|
112
112
|
return e === "load" && this.loaded ? (t.apply(this, [this.data]), this) : (super.on(e, t), this);
|
|
@@ -161,17 +161,17 @@ class M {
|
|
|
161
161
|
run(e, t) {
|
|
162
162
|
}
|
|
163
163
|
verify(e, t, a) {
|
|
164
|
-
return this.arguments === !0 && (!a || !a.length) ? !1 : !!(this.admins.some((i) => e.toLocaleLowerCase() === i.toLocaleLowerCase()) || this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length || Array.isArray(this.permissions) && (this.permissions.some((i) => e.toLowerCase() === i.toLowerCase() || t.map((
|
|
164
|
+
return this.arguments === !0 && (!a || !a.length) ? !1 : !!(this.admins.some((i) => e.toLocaleLowerCase() === i.toLocaleLowerCase()) || this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length || Array.isArray(this.permissions) && (this.permissions.some((i) => e.toLowerCase() === i.toLowerCase() || t.map((s) => s.toLowerCase()).includes(i.toLowerCase())) || this.permissions.includes("*")));
|
|
165
165
|
}
|
|
166
166
|
parse(e, t) {
|
|
167
167
|
if (!(window.client instanceof E)) return !1;
|
|
168
168
|
const a = e.replace(this.prefix, "").split(" ").slice(1).map((c) => c.trim());
|
|
169
|
-
var i = "",
|
|
169
|
+
var i = "", s = [];
|
|
170
170
|
const r = { bits: "cheer", premium: "prime" };
|
|
171
171
|
switch (t.provider) {
|
|
172
172
|
case "twitch": {
|
|
173
173
|
const c = t.data;
|
|
174
|
-
i = c.event.data.nick || c.event.data.displayName, c.event.data.tags?.badges && (
|
|
174
|
+
i = c.event.data.nick || c.event.data.displayName, c.event.data.tags?.badges && (s = c.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((h) => h in r ? r[h] : h));
|
|
175
175
|
break;
|
|
176
176
|
}
|
|
177
177
|
case "youtube": {
|
|
@@ -181,13 +181,13 @@ class M {
|
|
|
181
181
|
isChatSponsor: "sponsor",
|
|
182
182
|
isChatModerator: "moderator"
|
|
183
183
|
};
|
|
184
|
-
i = c.event.data.nick || c.event.data.displayName,
|
|
184
|
+
i = c.event.data.nick || c.event.data.displayName, s = Object.entries(c.event.data.authorDetails).filter(([h, p]) => h.startsWith("is") && p).map(([h]) => l[h]).filter(Boolean), s.includes("sponsor") && (s.push("premium"), s.push("prime")), s.includes("owner") && (s.push("moderator"), s.push("broadcaster"));
|
|
185
185
|
break;
|
|
186
186
|
}
|
|
187
187
|
case "kick":
|
|
188
188
|
return !1;
|
|
189
189
|
}
|
|
190
|
-
const o = this.verify(i,
|
|
190
|
+
const o = this.verify(i, s, a);
|
|
191
191
|
return o === !0 && this.run.apply(window.client, [a, t]), o;
|
|
192
192
|
}
|
|
193
193
|
remove() {
|
|
@@ -201,8 +201,8 @@ class M {
|
|
|
201
201
|
try {
|
|
202
202
|
if (window.client.actions.commands.length && window.client.actions.commands.some((a) => t.event.data.text.startsWith(a.prefix))) {
|
|
203
203
|
const a = window.client.actions.commands.filter((i) => {
|
|
204
|
-
var
|
|
205
|
-
return
|
|
204
|
+
var s = [i.name, ...i.aliases ?? []], r = t.event.data.text.replace(i.prefix, "").split(" ")[0];
|
|
205
|
+
return s.includes(r);
|
|
206
206
|
});
|
|
207
207
|
if (a.length && a.every((i) => i instanceof M))
|
|
208
208
|
return a.forEach((i) => {
|
|
@@ -216,46 +216,59 @@ class M {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
219
|
+
const B = {
|
|
220
|
+
/**
|
|
221
|
+
* Delays execution for a specified number of milliseconds.
|
|
222
|
+
* @param ms - The number of milliseconds to delay.
|
|
223
|
+
* @returns A Promise that resolves after the specified delay.
|
|
224
|
+
*/
|
|
225
|
+
delay(n, e) {
|
|
226
|
+
return new Promise(
|
|
227
|
+
(t) => setTimeout(() => {
|
|
228
|
+
if (e) {
|
|
229
|
+
const a = e();
|
|
230
|
+
t(a ?? null);
|
|
231
|
+
} else t(null);
|
|
232
|
+
}, n)
|
|
233
|
+
);
|
|
234
|
+
},
|
|
235
|
+
/**
|
|
236
|
+
* Returns typed entries of an object.
|
|
237
|
+
* @param obj - The object to get entries from.
|
|
238
|
+
* @returns An array of key-value pairs from the object.
|
|
239
|
+
*/
|
|
240
|
+
typedEntries(n) {
|
|
241
|
+
return Object.entries(n);
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Returns typed values of an object.
|
|
245
|
+
* @param obj - The object to get values from.
|
|
246
|
+
* @returns An array of values from the object.
|
|
247
|
+
*/
|
|
248
|
+
typedValues(n) {
|
|
249
|
+
return Object.values(n);
|
|
250
|
+
},
|
|
251
|
+
/**
|
|
252
|
+
* Returns typed keys of an object.
|
|
253
|
+
* @param obj - The object to get keys from.
|
|
254
|
+
* @returns An array of keys from the object.
|
|
255
|
+
*/
|
|
256
|
+
typedKeys(n) {
|
|
257
|
+
return Object.keys(n);
|
|
258
|
+
},
|
|
259
|
+
/**
|
|
260
|
+
* Selects an item based on weighted probabilities.
|
|
261
|
+
* @param items - An object where keys are items and values are their weights.
|
|
262
|
+
* @returns A randomly selected item based on the given probabilities.
|
|
263
|
+
*/
|
|
264
|
+
probability(n) {
|
|
265
|
+
const e = Object.values(n).reduce((s, r) => s + r, 0), t = B.typedEntries(n).sort((s, r) => r[1] - s[1]), a = Math.random() * e;
|
|
266
|
+
let i = 0;
|
|
267
|
+
for (const [s, r] of t)
|
|
268
|
+
if (i += r, a < i)
|
|
269
|
+
return s;
|
|
256
270
|
}
|
|
257
|
-
}
|
|
258
|
-
const Y = {
|
|
271
|
+
}, X = {
|
|
259
272
|
/**
|
|
260
273
|
* Translate number to words
|
|
261
274
|
* @param num - Number to translate
|
|
@@ -267,7 +280,7 @@ const Y = {
|
|
|
267
280
|
* console.log(cardinal); // "forty-two"
|
|
268
281
|
* ```
|
|
269
282
|
*/
|
|
270
|
-
translate(
|
|
283
|
+
translate(n, e = "cardinal") {
|
|
271
284
|
const t = {
|
|
272
285
|
single: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],
|
|
273
286
|
tens: ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"],
|
|
@@ -276,12 +289,12 @@ const Y = {
|
|
|
276
289
|
single: ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"],
|
|
277
290
|
tens: ["tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"],
|
|
278
291
|
decades: ["twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"]
|
|
279
|
-
}, i = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"],
|
|
280
|
-
if (
|
|
281
|
-
const g =
|
|
282
|
-
if (g >= 11 && g <= 13) return `${
|
|
283
|
-
const y =
|
|
284
|
-
return `${
|
|
292
|
+
}, i = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"], s = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion"], r = s.map((g) => g ? `${g}th` : "");
|
|
293
|
+
if (n = Math.abs(Math.floor(n)), e === "suffix") {
|
|
294
|
+
const g = n % 100;
|
|
295
|
+
if (g >= 11 && g <= 13) return `${n}th`;
|
|
296
|
+
const y = n % 10;
|
|
297
|
+
return `${n}${i[y]}`;
|
|
285
298
|
}
|
|
286
299
|
function o(g, y) {
|
|
287
300
|
if (g < 10) return y === "ordinal" ? a.single[g] : t.single[g];
|
|
@@ -296,9 +309,9 @@ const Y = {
|
|
|
296
309
|
const b = Math.floor(g / 100), d = g % 100, m = [];
|
|
297
310
|
return b > 0 && (y === "ordinal" && d === 0 ? m.push(`${t.single[b]} hundredth`) : m.push(`${t.single[b]} hundred`)), d > 0 && m.push(o(d, y)), m.join(" ");
|
|
298
311
|
}
|
|
299
|
-
if (
|
|
312
|
+
if (n < 1e3) return c(n, e);
|
|
300
313
|
const l = [];
|
|
301
|
-
let h =
|
|
314
|
+
let h = n;
|
|
302
315
|
for (; h > 0; )
|
|
303
316
|
l.push(h % 1e3), h = Math.floor(h / 1e3);
|
|
304
317
|
let p = -1;
|
|
@@ -307,7 +320,7 @@ const Y = {
|
|
|
307
320
|
for (let g = l.length - 1; g >= 0; g--) {
|
|
308
321
|
const y = l[g];
|
|
309
322
|
if (y === 0) continue;
|
|
310
|
-
const b =
|
|
323
|
+
const b = s[g];
|
|
311
324
|
if (e === "cardinal") {
|
|
312
325
|
let d = c(y, "cardinal");
|
|
313
326
|
b && (d += ` ${b}`), f.push(d);
|
|
@@ -338,8 +351,8 @@ const Y = {
|
|
|
338
351
|
* console.log(balancedValue); // 100
|
|
339
352
|
* ```
|
|
340
353
|
*/
|
|
341
|
-
balance(
|
|
342
|
-
return Math.min(Math.max(
|
|
354
|
+
balance(n, e = 0, t = 100) {
|
|
355
|
+
return Math.min(Math.max(n, e), t);
|
|
343
356
|
},
|
|
344
357
|
/**
|
|
345
358
|
* Rounds a number to a specified number of decimal places
|
|
@@ -352,11 +365,11 @@ const Y = {
|
|
|
352
365
|
* console.log(roundedValue); // 3.142
|
|
353
366
|
* ```
|
|
354
367
|
*/
|
|
355
|
-
round(
|
|
368
|
+
round(n, e = 2) {
|
|
356
369
|
const t = Math.pow(10, e);
|
|
357
|
-
return Math.round(
|
|
370
|
+
return Math.round(n * t) / t;
|
|
358
371
|
}
|
|
359
|
-
},
|
|
372
|
+
}, Q = {
|
|
360
373
|
/**
|
|
361
374
|
* Merges outer span styles with inner span styles in the provided HTML string.
|
|
362
375
|
* @param outerStyle - The style string to be applied to the outer span.
|
|
@@ -368,14 +381,14 @@ const Y = {
|
|
|
368
381
|
* console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
|
|
369
382
|
* ```
|
|
370
383
|
*/
|
|
371
|
-
mergeSpanStyles(
|
|
384
|
+
mergeSpanStyles(n, e, t) {
|
|
372
385
|
const a = e.match(/^<span(?: class="[^"]*")? style="([^"]*)">(.*)<\/span>$/s);
|
|
373
386
|
if (a) {
|
|
374
|
-
const i = a[1],
|
|
375
|
-
let o = [i,
|
|
376
|
-
return o.endsWith(";") || (o += ";"), `<span${r ? ` class="${r} ${t ?? ""}"` : ""}${o ? ` style="${o}"` : ""}>${
|
|
387
|
+
const i = a[1], s = a[2], r = a[0].match(/class="([^"]*)"/)?.[1] || "";
|
|
388
|
+
let o = [i, n].filter((c) => c.length).map((c) => c.endsWith(";") ? c.slice(0, -1) : c).join("; ").replace(/\s*;\s*/g, "; ").trim();
|
|
389
|
+
return o.endsWith(";") || (o += ";"), `<span${r ? ` class="${r} ${t ?? ""}"` : ""}${o ? ` style="${o}"` : ""}>${s}</span>`;
|
|
377
390
|
} else
|
|
378
|
-
return
|
|
391
|
+
return n && n.length && !n.endsWith(";") && (n += ";"), `<span${t ? ` class="${t}"` : ""}${n ? ` style="${n}"` : ""}>${e}</span>`;
|
|
379
392
|
},
|
|
380
393
|
/**
|
|
381
394
|
* Scales an HTML element to fit within its parent element based on specified minimum and maximum scale factors.
|
|
@@ -390,11 +403,11 @@ const Y = {
|
|
|
390
403
|
* scale(element, 0.5, 1, { return: false });
|
|
391
404
|
* ```
|
|
392
405
|
*/
|
|
393
|
-
scale(
|
|
394
|
-
const { return: i = !1, parent:
|
|
406
|
+
scale(n, e = 0, t = 1, a) {
|
|
407
|
+
const { return: i = !1, parent: s, base: r } = a || {}, o = s || n.parentElement || document.body;
|
|
395
408
|
if (!o)
|
|
396
409
|
throw new Error("No parent element found for scaling");
|
|
397
|
-
const c = o.getBoundingClientRect(), l =
|
|
410
|
+
const c = o.getBoundingClientRect(), l = n.offsetWidth, h = n.offsetHeight;
|
|
398
411
|
if (l === 0 || h === 0)
|
|
399
412
|
throw new Error("Element has zero width or height, cannot scale");
|
|
400
413
|
const p = c.width * t / l, f = c.height * t / h;
|
|
@@ -408,7 +421,7 @@ const Y = {
|
|
|
408
421
|
height: h * g,
|
|
409
422
|
scale: g
|
|
410
423
|
};
|
|
411
|
-
return i || (
|
|
424
|
+
return i || (n.style.transform = `scale(${g})`, n.style.transformOrigin = "center center"), y;
|
|
412
425
|
},
|
|
413
426
|
/**
|
|
414
427
|
* Scales an HTML element to fit within its parent element based on specified options.
|
|
@@ -427,17 +440,17 @@ const Y = {
|
|
|
427
440
|
* console.log(`Element scaled by a factor of ${scaleFactor}`);
|
|
428
441
|
* ```
|
|
429
442
|
*/
|
|
430
|
-
scalev2(
|
|
431
|
-
const { parent: t =
|
|
443
|
+
scalev2(n, e = {}) {
|
|
444
|
+
const { parent: t = n.parentElement, prefer: a = "auto", min: i = 0, max: s = 1, apply: r = () => {
|
|
432
445
|
} } = e;
|
|
433
446
|
if (!t)
|
|
434
447
|
throw new Error("No parent element found for scaling");
|
|
435
|
-
const o = t.getBoundingClientRect(), c =
|
|
436
|
-
let g = l * i / p, y = h * i / f, b = l *
|
|
448
|
+
const o = t.getBoundingClientRect(), c = n.getBoundingClientRect(), l = o.width, h = o.height, p = c.width, f = c.height;
|
|
449
|
+
let g = l * i / p, y = h * i / f, b = l * s / p, d = h * s / f, m = Math.min(b, d);
|
|
437
450
|
const k = Math.max(g, y);
|
|
438
451
|
m = Math.max(m, k);
|
|
439
452
|
const v = p * m, I = f * m;
|
|
440
|
-
return a === "width" ? m = Math.max(g, Math.min(b, l / p)) : a === "height" ? m = Math.max(y, Math.min(d, h / f)) : v > l ? m = Math.max(g, Math.min(b, l / p)) : I > h && (m = Math.max(y, Math.min(d, h / f))), r.apply(
|
|
453
|
+
return a === "width" ? m = Math.max(g, Math.min(b, l / p)) : a === "height" ? m = Math.max(y, Math.min(d, h / f)) : v > l ? m = Math.max(g, Math.min(b, l / p)) : I > h && (m = Math.max(y, Math.min(d, h / f))), r.apply(n, [m, n]), m;
|
|
441
454
|
},
|
|
442
455
|
/**
|
|
443
456
|
* Fits the text within the parent element by adjusting the font size.
|
|
@@ -452,15 +465,15 @@ const Y = {
|
|
|
452
465
|
* console.log(`Adjusted font size: ${element.style.fontSize}`);
|
|
453
466
|
* ```
|
|
454
467
|
*/
|
|
455
|
-
fitText(
|
|
456
|
-
const a = parseFloat(getComputedStyle(
|
|
468
|
+
fitText(n, e = 1, t = {}) {
|
|
469
|
+
const a = parseFloat(getComputedStyle(n).getPropertyValue("font-size")), i = {
|
|
457
470
|
minFontSize: t?.minFontSize ?? 0,
|
|
458
471
|
maxFontSize: t?.maxFontSize ?? a
|
|
459
|
-
},
|
|
460
|
-
if (!
|
|
472
|
+
}, s = t?.parent || n.parentElement;
|
|
473
|
+
if (!s)
|
|
461
474
|
throw new Error("No parent element found for fitting text");
|
|
462
|
-
const r =
|
|
463
|
-
return
|
|
475
|
+
const r = s.clientWidth * e, o = n.offsetWidth, c = r / o, l = a * c, h = X.balance(l, i.minFontSize, i.maxFontSize);
|
|
476
|
+
return n.style.fontSize = h + "px", n;
|
|
464
477
|
},
|
|
465
478
|
/**
|
|
466
479
|
* Wraps formatted HTML text with containers and splits characters into indexed spans.
|
|
@@ -475,10 +488,10 @@ const Y = {
|
|
|
475
488
|
* // Output: '<span class="container" data-index="0"><span class="char" data-index="0">T</span><span class="char" data-index="1">e</span>...'
|
|
476
489
|
* ```
|
|
477
490
|
*/
|
|
478
|
-
splitTextToChars(
|
|
479
|
-
const a = new DOMParser().parseFromString(
|
|
491
|
+
splitTextToChars(n, e = 0) {
|
|
492
|
+
const a = new DOMParser().parseFromString(n, "text/html");
|
|
480
493
|
let i = e;
|
|
481
|
-
function
|
|
494
|
+
function s(l) {
|
|
482
495
|
if (l.nodeType === Node.TEXT_NODE) {
|
|
483
496
|
const p = (l.textContent || "").split("").map((g, y) => {
|
|
484
497
|
const b = document.createElement("span");
|
|
@@ -489,7 +502,7 @@ const Y = {
|
|
|
489
502
|
} else if (l.nodeType === Node.ELEMENT_NODE) {
|
|
490
503
|
const h = l.cloneNode(!1);
|
|
491
504
|
return h.classList.add("container"), h.dataset.index = String(i), h.style.setProperty("--char-index", String(i)), l.childNodes.forEach((p) => {
|
|
492
|
-
const f =
|
|
505
|
+
const f = s(p);
|
|
493
506
|
(f instanceof DocumentFragment || f instanceof Node) && h.appendChild(f);
|
|
494
507
|
}), h;
|
|
495
508
|
}
|
|
@@ -499,7 +512,7 @@ const Y = {
|
|
|
499
512
|
r.childNodes.forEach((l) => {
|
|
500
513
|
if (l.nodeType === Node.TEXT_NODE && !l.textContent?.trim())
|
|
501
514
|
return;
|
|
502
|
-
const h =
|
|
515
|
+
const h = s(l);
|
|
503
516
|
(h instanceof DocumentFragment || h instanceof Node) && o.appendChild(h);
|
|
504
517
|
});
|
|
505
518
|
let c = "";
|
|
@@ -507,7 +520,7 @@ const Y = {
|
|
|
507
520
|
l.nodeType === Node.TEXT_NODE ? c += l.textContent : c += l.outerHTML;
|
|
508
521
|
}), c;
|
|
509
522
|
}
|
|
510
|
-
},
|
|
523
|
+
}, Z = {
|
|
511
524
|
/**
|
|
512
525
|
* Flattens a nested object into a single-level object with dot-separated keys.
|
|
513
526
|
* @param obj - The nested object to be flattened.
|
|
@@ -521,104 +534,68 @@ const Y = {
|
|
|
521
534
|
* // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
|
|
522
535
|
* ```
|
|
523
536
|
*/
|
|
524
|
-
flatten(
|
|
537
|
+
flatten(n, e = !0, t = "") {
|
|
525
538
|
const a = {};
|
|
526
|
-
for (const i in
|
|
527
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
528
|
-
const
|
|
529
|
-
if (
|
|
530
|
-
a[r] = String(
|
|
539
|
+
for (const i in n) {
|
|
540
|
+
if (!Object.prototype.hasOwnProperty.call(n, i)) continue;
|
|
541
|
+
const s = n[i], r = t ? `${t}.${i}` : i;
|
|
542
|
+
if (s == null) {
|
|
543
|
+
a[r] = String(s);
|
|
531
544
|
continue;
|
|
532
545
|
}
|
|
533
|
-
if (typeof
|
|
546
|
+
if (typeof s == "number" && isNaN(s)) {
|
|
534
547
|
a[r] = "NaN";
|
|
535
548
|
continue;
|
|
536
549
|
}
|
|
537
|
-
if (typeof
|
|
538
|
-
a[r] = e ? String(
|
|
550
|
+
if (typeof s == "number" && !isNaN(s)) {
|
|
551
|
+
a[r] = e ? String(s) : s;
|
|
539
552
|
continue;
|
|
540
553
|
}
|
|
541
|
-
if (
|
|
542
|
-
a[r] =
|
|
554
|
+
if (s instanceof Date) {
|
|
555
|
+
a[r] = s.toISOString();
|
|
543
556
|
continue;
|
|
544
557
|
}
|
|
545
|
-
if (
|
|
546
|
-
|
|
558
|
+
if (s instanceof Map) {
|
|
559
|
+
s.forEach((o, c) => {
|
|
547
560
|
a[`${r}.${c}`] = JSON.stringify(o);
|
|
548
561
|
});
|
|
549
562
|
continue;
|
|
550
563
|
}
|
|
551
|
-
if (Array.isArray(
|
|
552
|
-
|
|
564
|
+
if (Array.isArray(s)) {
|
|
565
|
+
s.forEach((o, c) => {
|
|
553
566
|
const l = `${r}:${c}`;
|
|
554
567
|
typeof o == "object" ? Object.assign(a, this.flatten(o, e, l)) : a[l] = e ? String(o) : o;
|
|
555
568
|
});
|
|
556
569
|
continue;
|
|
557
570
|
}
|
|
558
|
-
if (typeof
|
|
559
|
-
Object.assign(a, this.flatten(
|
|
571
|
+
if (typeof s == "object") {
|
|
572
|
+
Object.assign(a, this.flatten(s, e, r));
|
|
560
573
|
continue;
|
|
561
574
|
}
|
|
562
|
-
a[r] = String(
|
|
575
|
+
a[r] = String(s);
|
|
563
576
|
}
|
|
564
577
|
return a;
|
|
565
578
|
}
|
|
566
579
|
}, st = {
|
|
567
580
|
playing: !1,
|
|
568
581
|
audio: null,
|
|
569
|
-
play(
|
|
570
|
-
if (!
|
|
582
|
+
play(n, e = 100, t = !1) {
|
|
583
|
+
if (!n || !n.length)
|
|
571
584
|
throw new Error("No sound URL provided");
|
|
572
585
|
try {
|
|
573
586
|
t && this.playing && this.audio && this.audio.state !== "closed" && this.audio.close();
|
|
574
587
|
let a = new AudioContext(), i = a.createGain();
|
|
575
|
-
i.connect(a.destination), t && (this.audio = a, this.playing = !0), fetch(
|
|
588
|
+
i.connect(a.destination), t && (this.audio = a, this.playing = !0), fetch(n).then((s) => s.arrayBuffer()).then((s) => a.decodeAudioData(s)).then((s) => {
|
|
576
589
|
if (a.state !== "closed") {
|
|
577
590
|
const r = a.createBufferSource();
|
|
578
|
-
r.buffer =
|
|
591
|
+
r.buffer = s, r.connect(i), i.gain.value = e / 100, r.start(a.currentTime);
|
|
579
592
|
}
|
|
580
593
|
});
|
|
581
594
|
} catch (a) {
|
|
582
595
|
throw new Error(`Error playing sound: ${a}`);
|
|
583
596
|
}
|
|
584
597
|
}
|
|
585
|
-
},
|
|
586
|
-
/**
|
|
587
|
-
* Delays execution for a specified number of milliseconds.
|
|
588
|
-
* @param ms - The number of milliseconds to delay.
|
|
589
|
-
* @returns A Promise that resolves after the specified delay.
|
|
590
|
-
*/
|
|
591
|
-
delay(s, e) {
|
|
592
|
-
return new Promise(
|
|
593
|
-
(t) => setTimeout(() => {
|
|
594
|
-
if (e) {
|
|
595
|
-
const a = e();
|
|
596
|
-
t(a ?? null);
|
|
597
|
-
} else t(null);
|
|
598
|
-
}, s)
|
|
599
|
-
);
|
|
600
|
-
},
|
|
601
|
-
/**
|
|
602
|
-
* Returns typed entries of an object.
|
|
603
|
-
* @param obj - The object to get entries from.
|
|
604
|
-
* @returns An array of key-value pairs from the object.
|
|
605
|
-
*/
|
|
606
|
-
typedEntries(s) {
|
|
607
|
-
return Object.entries(s);
|
|
608
|
-
},
|
|
609
|
-
/**
|
|
610
|
-
* Selects an item based on weighted probabilities.
|
|
611
|
-
* @param items - An object where keys are items and values are their weights.
|
|
612
|
-
* @returns A randomly selected item based on the given probabilities.
|
|
613
|
-
*/
|
|
614
|
-
probability(s) {
|
|
615
|
-
const e = Object.values(s).reduce((n, r) => n + r, 0), t = Z.typedEntries(s).sort((n, r) => r[1] - n[1]), a = Math.random() * e;
|
|
616
|
-
let i = 0;
|
|
617
|
-
for (const [n, r] of t)
|
|
618
|
-
if (i += r, a < i)
|
|
619
|
-
return n;
|
|
620
|
-
}
|
|
621
|
-
}, V = [
|
|
598
|
+
}, _ = [
|
|
622
599
|
"aliceblue",
|
|
623
600
|
"antiquewhite",
|
|
624
601
|
"aqua",
|
|
@@ -769,17 +746,17 @@ const Y = {
|
|
|
769
746
|
"yellowgreen",
|
|
770
747
|
"transparent"
|
|
771
748
|
];
|
|
772
|
-
function nt(
|
|
749
|
+
function nt(n, e) {
|
|
773
750
|
if (!e) return null;
|
|
774
751
|
switch (e) {
|
|
775
752
|
case "hex": {
|
|
776
|
-
const t =
|
|
777
|
-
let a = 0, i = 0,
|
|
778
|
-
return t.length === 3 ? (a = parseInt(t[0] + t[0], 16), i = parseInt(t[1] + t[1], 16),
|
|
753
|
+
const t = n.replace("#", "");
|
|
754
|
+
let a = 0, i = 0, s = 0, r = 1;
|
|
755
|
+
return t.length === 3 ? (a = parseInt(t[0] + t[0], 16), i = parseInt(t[1] + t[1], 16), s = parseInt(t[2] + t[2], 16)) : t.length === 6 ? (a = parseInt(t.slice(0, 2), 16), i = parseInt(t.slice(2, 4), 16), s = parseInt(t.slice(4, 6), 16)) : t.length === 4 ? (a = parseInt(t[0] + t[0], 16), i = parseInt(t[1] + t[1], 16), s = parseInt(t[2] + t[2], 16), r = parseInt(t[3] + t[3], 16) / 255) : t.length === 8 && (a = parseInt(t.slice(0, 2), 16), i = parseInt(t.slice(2, 4), 16), s = parseInt(t.slice(4, 6), 16), r = parseInt(t.slice(6, 8), 16) / 255), { r: a, g: i, b: s, a: r };
|
|
779
756
|
}
|
|
780
757
|
case "rgb":
|
|
781
758
|
case "rgba": {
|
|
782
|
-
const t =
|
|
759
|
+
const t = n.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);
|
|
783
760
|
return t ? {
|
|
784
761
|
r: parseInt(t[1]),
|
|
785
762
|
g: parseInt(t[2]),
|
|
@@ -789,44 +766,44 @@ function nt(s, e) {
|
|
|
789
766
|
}
|
|
790
767
|
case "hsl":
|
|
791
768
|
case "hsla": {
|
|
792
|
-
const t =
|
|
769
|
+
const t = n.match(/hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*([\d.]+))?\s*\)/);
|
|
793
770
|
if (!t) return null;
|
|
794
|
-
const a = parseInt(t[1]), i = parseInt(t[2]),
|
|
795
|
-
return { ...ot(a, i,
|
|
771
|
+
const a = parseInt(t[1]), i = parseInt(t[2]), s = parseInt(t[3]), r = t[4] ? parseFloat(t[4]) : 1;
|
|
772
|
+
return { ...ot(a, i, s), a: r };
|
|
796
773
|
}
|
|
797
774
|
case "css-color-name": {
|
|
798
775
|
const t = document.createElement("canvas");
|
|
799
776
|
t.width = t.height = 1;
|
|
800
777
|
const a = t.getContext("2d");
|
|
801
778
|
if (!a) return null;
|
|
802
|
-
a.fillStyle =
|
|
803
|
-
const [i,
|
|
804
|
-
return { r: i, g:
|
|
779
|
+
a.fillStyle = n, a.fillRect(0, 0, 1, 1);
|
|
780
|
+
const [i, s, r] = a.getImageData(0, 0, 1, 1).data;
|
|
781
|
+
return { r: i, g: s, b: r, a: 1 };
|
|
805
782
|
}
|
|
806
783
|
default:
|
|
807
784
|
return null;
|
|
808
785
|
}
|
|
809
786
|
}
|
|
810
|
-
function rt(
|
|
787
|
+
function rt(n, e = !0) {
|
|
811
788
|
const t = (i) => Math.round(i).toString(16).padStart(2, "0");
|
|
812
|
-
let a = `#${t(
|
|
813
|
-
return e &&
|
|
789
|
+
let a = `#${t(n.r)}${t(n.g)}${t(n.b)}`;
|
|
790
|
+
return e && n.a < 1 && (a += t(n.a * 255)), a;
|
|
814
791
|
}
|
|
815
|
-
function
|
|
816
|
-
|
|
817
|
-
const a = Math.max(
|
|
792
|
+
function K(n, e, t) {
|
|
793
|
+
n /= 255, e /= 255, t /= 255;
|
|
794
|
+
const a = Math.max(n, e, t), i = Math.min(n, e, t), s = a - i;
|
|
818
795
|
let r = 0, o = 0;
|
|
819
796
|
const c = (a + i) / 2;
|
|
820
|
-
if (
|
|
821
|
-
switch (o = c > 0.5 ?
|
|
822
|
-
case
|
|
823
|
-
r = ((e - t) /
|
|
797
|
+
if (s !== 0)
|
|
798
|
+
switch (o = c > 0.5 ? s / (2 - a - i) : s / (a + i), a) {
|
|
799
|
+
case n:
|
|
800
|
+
r = ((e - t) / s + (e < t ? 6 : 0)) / 6;
|
|
824
801
|
break;
|
|
825
802
|
case e:
|
|
826
|
-
r = ((t -
|
|
803
|
+
r = ((t - n) / s + 2) / 6;
|
|
827
804
|
break;
|
|
828
805
|
case t:
|
|
829
|
-
r = ((
|
|
806
|
+
r = ((n - e) / s + 4) / 6;
|
|
830
807
|
break;
|
|
831
808
|
}
|
|
832
809
|
return {
|
|
@@ -835,32 +812,32 @@ function B(s, e, t) {
|
|
|
835
812
|
l: Math.round(c * 100)
|
|
836
813
|
};
|
|
837
814
|
}
|
|
838
|
-
function ot(
|
|
839
|
-
|
|
840
|
-
let a, i,
|
|
815
|
+
function ot(n, e, t) {
|
|
816
|
+
n /= 360, e /= 100, t /= 100;
|
|
817
|
+
let a, i, s;
|
|
841
818
|
if (e === 0)
|
|
842
|
-
a = i =
|
|
819
|
+
a = i = s = t;
|
|
843
820
|
else {
|
|
844
821
|
const r = (l, h, p) => (p < 0 && (p += 1), p > 1 && (p -= 1), p < 0.16666666666666666 ? l + (h - l) * 6 * p : p < 0.5 ? h : p < 0.6666666666666666 ? l + (h - l) * (0.6666666666666666 - p) * 6 : l), o = t < 0.5 ? t * (1 + e) : t + e - t * e, c = 2 * t - o;
|
|
845
|
-
a = r(c, o,
|
|
822
|
+
a = r(c, o, n + 1 / 3), i = r(c, o, n), s = r(c, o, n - 1 / 3);
|
|
846
823
|
}
|
|
847
824
|
return {
|
|
848
825
|
r: Math.round(a * 255),
|
|
849
826
|
g: Math.round(i * 255),
|
|
850
|
-
b: Math.round(
|
|
827
|
+
b: Math.round(s * 255)
|
|
851
828
|
};
|
|
852
829
|
}
|
|
853
|
-
async function ct(
|
|
854
|
-
const a =
|
|
855
|
-
let i = a[0],
|
|
830
|
+
async function ct(n, e, t) {
|
|
831
|
+
const a = _;
|
|
832
|
+
let i = a[0], s = 1 / 0;
|
|
856
833
|
for await (const r of a) {
|
|
857
834
|
const o = document.createElement("canvas");
|
|
858
835
|
o.width = o.height = 1;
|
|
859
836
|
const c = o.getContext("2d");
|
|
860
837
|
if (!c) continue;
|
|
861
838
|
c.fillStyle = r, c.fillRect(0, 0, 1, 1);
|
|
862
|
-
const [l, h, p] = c.getImageData(0, 0, 1, 1).data, f = Math.sqrt(Math.pow(
|
|
863
|
-
if (f <
|
|
839
|
+
const [l, h, p] = c.getImageData(0, 0, 1, 1).data, f = Math.sqrt(Math.pow(n - l, 2) + Math.pow(e - h, 2) + Math.pow(t - p, 2));
|
|
840
|
+
if (f < s && (s = f, i = r), f === 0) break;
|
|
864
841
|
}
|
|
865
842
|
return i;
|
|
866
843
|
}
|
|
@@ -878,8 +855,8 @@ const O = {
|
|
|
878
855
|
* console.log(rgbColor); // e.g. rgb(62, 146, 204)
|
|
879
856
|
* ```
|
|
880
857
|
*/
|
|
881
|
-
color(
|
|
882
|
-
switch (
|
|
858
|
+
color(n = "hex") {
|
|
859
|
+
switch (n) {
|
|
883
860
|
default:
|
|
884
861
|
case "hex":
|
|
885
862
|
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
|
|
@@ -892,19 +869,19 @@ const O = {
|
|
|
892
869
|
return `rgb(${t}, ${a}, ${i})`;
|
|
893
870
|
}
|
|
894
871
|
case "rgba": {
|
|
895
|
-
const t = Math.floor(Math.random() * 256), a = Math.floor(Math.random() * 256), i = Math.floor(Math.random() * 256),
|
|
896
|
-
return `rgba(${t}, ${a}, ${i}, ${
|
|
872
|
+
const t = Math.floor(Math.random() * 256), a = Math.floor(Math.random() * 256), i = Math.floor(Math.random() * 256), s = Math.random().toFixed(2);
|
|
873
|
+
return `rgba(${t}, ${a}, ${i}, ${s})`;
|
|
897
874
|
}
|
|
898
875
|
case "hsl": {
|
|
899
876
|
const t = Math.floor(Math.random() * 361), a = Math.floor(Math.random() * 101), i = Math.floor(Math.random() * 101);
|
|
900
877
|
return `hsl(${t}, ${a}%, ${i}%)`;
|
|
901
878
|
}
|
|
902
879
|
case "hsla": {
|
|
903
|
-
const t = Math.floor(Math.random() * 361), a = Math.floor(Math.random() * 101), i = Math.floor(Math.random() * 101),
|
|
904
|
-
return `hsla(${t}, ${a}%, ${i}%, ${
|
|
880
|
+
const t = Math.floor(Math.random() * 361), a = Math.floor(Math.random() * 101), i = Math.floor(Math.random() * 101), s = Math.random().toFixed(2);
|
|
881
|
+
return `hsla(${t}, ${a}%, ${i}%, ${s})`;
|
|
905
882
|
}
|
|
906
883
|
case "css-color-name": {
|
|
907
|
-
var e =
|
|
884
|
+
var e = _;
|
|
908
885
|
return this.array(e)[0];
|
|
909
886
|
}
|
|
910
887
|
}
|
|
@@ -924,9 +901,9 @@ const O = {
|
|
|
924
901
|
* console.log(floatNumber); // e.g. 3.14
|
|
925
902
|
* ```
|
|
926
903
|
*/
|
|
927
|
-
number(
|
|
928
|
-
|
|
929
|
-
const a = Math.random() * (e -
|
|
904
|
+
number(n, e, t = 0) {
|
|
905
|
+
n > e && ([n, e] = [e, n]);
|
|
906
|
+
const a = Math.random() * (e - n) + n;
|
|
930
907
|
return t ? Number(a.toFixed(t)) : Math.round(a);
|
|
931
908
|
},
|
|
932
909
|
/**
|
|
@@ -939,8 +916,8 @@ const O = {
|
|
|
939
916
|
* console.log(boolValue); // e.g. true (70% chance)
|
|
940
917
|
* ```
|
|
941
918
|
*/
|
|
942
|
-
boolean(
|
|
943
|
-
return Math.random() >
|
|
919
|
+
boolean(n = 0.5) {
|
|
920
|
+
return Math.random() > n;
|
|
944
921
|
},
|
|
945
922
|
/**
|
|
946
923
|
* Generate random string
|
|
@@ -953,9 +930,9 @@ const O = {
|
|
|
953
930
|
* console.log(randString); // e.g. "aZ3bT9xYqP"
|
|
954
931
|
* ```
|
|
955
932
|
*/
|
|
956
|
-
string(
|
|
933
|
+
string(n, e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
|
|
957
934
|
let t = "";
|
|
958
|
-
for (let a = 0; a <
|
|
935
|
+
for (let a = 0; a < n; a++)
|
|
959
936
|
t += e.charAt(Math.floor(Math.random() * e.length));
|
|
960
937
|
return t;
|
|
961
938
|
},
|
|
@@ -969,9 +946,9 @@ const O = {
|
|
|
969
946
|
* console.log(element, index); // e.g. "banana", 1
|
|
970
947
|
* ```
|
|
971
948
|
*/
|
|
972
|
-
array(
|
|
973
|
-
const e = this.number(0,
|
|
974
|
-
return [
|
|
949
|
+
array(n) {
|
|
950
|
+
const e = this.number(0, n.length - 1);
|
|
951
|
+
return [n[e], e];
|
|
975
952
|
},
|
|
976
953
|
/**
|
|
977
954
|
* Generate random date
|
|
@@ -984,8 +961,8 @@ const O = {
|
|
|
984
961
|
* console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
|
|
985
962
|
* ```
|
|
986
963
|
*/
|
|
987
|
-
date(
|
|
988
|
-
return new Date(this.number(
|
|
964
|
+
date(n = new Date(2e3, 0, 1), e = /* @__PURE__ */ new Date()) {
|
|
965
|
+
return new Date(this.number(n.getTime(), e.getTime()));
|
|
989
966
|
},
|
|
990
967
|
/**
|
|
991
968
|
* Generate ISO date string offset by days
|
|
@@ -1000,8 +977,8 @@ const O = {
|
|
|
1000
977
|
* console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
|
|
1001
978
|
* ```
|
|
1002
979
|
*/
|
|
1003
|
-
daysOffset(
|
|
1004
|
-
const t = Date.now() - this.number(0,
|
|
980
|
+
daysOffset(n) {
|
|
981
|
+
const t = Date.now() - this.number(0, n * 24 * 60 * 60 * 1e3);
|
|
1005
982
|
return new Date(t).toISOString();
|
|
1006
983
|
},
|
|
1007
984
|
/**
|
|
@@ -1023,9 +1000,9 @@ const O = {
|
|
|
1023
1000
|
* @param color - Hex color code
|
|
1024
1001
|
* @returns - Hex color code with opacity
|
|
1025
1002
|
*/
|
|
1026
|
-
opacity(
|
|
1027
|
-
e = e.length > 7 ? e?.substring(0, 6) : e,
|
|
1028
|
-
let t = Math.round(Math.min(Math.max(
|
|
1003
|
+
opacity(n = 100, e = "") {
|
|
1004
|
+
e = e.length > 7 ? e?.substring(0, 6) : e, n = n > 1 ? n / 100 : n;
|
|
1005
|
+
let t = Math.round(Math.min(Math.max(n, 0), 1) * 255).toString(16).toLowerCase().padStart(2, "0");
|
|
1029
1006
|
return e + t;
|
|
1030
1007
|
},
|
|
1031
1008
|
/**
|
|
@@ -1033,13 +1010,13 @@ const O = {
|
|
|
1033
1010
|
* @param hex - Hex color code
|
|
1034
1011
|
* @returns - Object with color and opacity
|
|
1035
1012
|
*/
|
|
1036
|
-
extract(
|
|
1037
|
-
if (!
|
|
1013
|
+
extract(n) {
|
|
1014
|
+
if (!n.startsWith("#") || n.length <= 7)
|
|
1038
1015
|
return {
|
|
1039
|
-
color:
|
|
1016
|
+
color: n,
|
|
1040
1017
|
opacity: 100
|
|
1041
1018
|
};
|
|
1042
|
-
var a =
|
|
1019
|
+
var a = n.slice(-2), e = parseInt(a, 16) / 255, t = Math.round(e * 100), a = n.length > 7 ? n.slice(0, 7) : n;
|
|
1043
1020
|
return {
|
|
1044
1021
|
color: a,
|
|
1045
1022
|
opacity: t
|
|
@@ -1058,10 +1035,10 @@ const O = {
|
|
|
1058
1035
|
* const format5 = color.validate("invalid-color"); // false
|
|
1059
1036
|
* ```
|
|
1060
1037
|
*/
|
|
1061
|
-
validate(
|
|
1062
|
-
if (typeof
|
|
1063
|
-
const e =
|
|
1064
|
-
return /^#([A-Fa-f0-9]{3}){1,2}$/.test(e) || /^#([A-Fa-f0-9]{4}|[A-Fa-f0-9]{8})$/.test(e) ? "hex" : /^rgb\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)$/.test(e) ? "rgb" : /^rgba\(\s*(?:\d{1,3}\s*,\s*){3}(?:0|1|0?\.\d+)\s*\)$/.test(e) ? "rgba" : /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(e) ? "hsl" : /^hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0|1|0?\.\d+)\s*\)$/.test(e) ? "hsla" :
|
|
1038
|
+
validate(n) {
|
|
1039
|
+
if (typeof n != "string" || !String(n).trim().length) return !1;
|
|
1040
|
+
const e = n.trim();
|
|
1041
|
+
return /^#([A-Fa-f0-9]{3}){1,2}$/.test(e) || /^#([A-Fa-f0-9]{4}|[A-Fa-f0-9]{8})$/.test(e) ? "hex" : /^rgb\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)$/.test(e) ? "rgb" : /^rgba\(\s*(?:\d{1,3}\s*,\s*){3}(?:0|1|0?\.\d+)\s*\)$/.test(e) ? "rgba" : /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(e) ? "hsl" : /^hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0|1|0?\.\d+)\s*\)$/.test(e) ? "hsla" : _.includes(e.toLowerCase()) ? "css-color-name" : !1;
|
|
1065
1042
|
},
|
|
1066
1043
|
/**
|
|
1067
1044
|
* Convert color to different format
|
|
@@ -1076,12 +1053,12 @@ const O = {
|
|
|
1076
1053
|
* const colorName = color.convert("#FF5733", "css-color-name"); // "orangered"
|
|
1077
1054
|
* ```
|
|
1078
1055
|
*/
|
|
1079
|
-
async convert(
|
|
1080
|
-
const t = this.validate(
|
|
1081
|
-
if (!t) throw new Error(`Invalid color format: ${
|
|
1056
|
+
async convert(n, e) {
|
|
1057
|
+
const t = this.validate(n);
|
|
1058
|
+
if (!t) throw new Error(`Invalid color format: ${n}`);
|
|
1082
1059
|
if (t === e) throw new Error(`Color is already in the desired format: ${e}`);
|
|
1083
|
-
const a = nt(
|
|
1084
|
-
if (!a) throw new Error(`Failed to parse color: ${
|
|
1060
|
+
const a = nt(n.trim(), t);
|
|
1061
|
+
if (!a) throw new Error(`Failed to parse color: ${n}`);
|
|
1085
1062
|
switch (e) {
|
|
1086
1063
|
case "hex":
|
|
1087
1064
|
return rt(a, !1);
|
|
@@ -1090,11 +1067,11 @@ const O = {
|
|
|
1090
1067
|
case "rgba":
|
|
1091
1068
|
return `rgba(${a.r}, ${a.g}, ${a.b}, ${a.a})`;
|
|
1092
1069
|
case "hsl": {
|
|
1093
|
-
const i =
|
|
1070
|
+
const i = K(a.r, a.g, a.b);
|
|
1094
1071
|
return `hsl(${i.h}, ${i.s}%, ${i.l}%)`;
|
|
1095
1072
|
}
|
|
1096
1073
|
case "hsla": {
|
|
1097
|
-
const i =
|
|
1074
|
+
const i = K(a.r, a.g, a.b);
|
|
1098
1075
|
return `hsla(${i.h}, ${i.s}%, ${i.l}%, ${a.a})`;
|
|
1099
1076
|
}
|
|
1100
1077
|
case "css-color-name":
|
|
@@ -1132,14 +1109,14 @@ const O = {
|
|
|
1132
1109
|
* console.log(result); // Output will depend on the fetched data
|
|
1133
1110
|
* ```
|
|
1134
1111
|
*/
|
|
1135
|
-
async replace(
|
|
1112
|
+
async replace(n, e, t) {
|
|
1136
1113
|
const a = [];
|
|
1137
|
-
|
|
1138
|
-
const o = typeof t == "function" ? t(
|
|
1139
|
-
return a.push(Promise.resolve(o)),
|
|
1114
|
+
n.replace(e, (s, ...r) => {
|
|
1115
|
+
const o = typeof t == "function" ? t(s, ...r) : s;
|
|
1116
|
+
return a.push(Promise.resolve(o)), s;
|
|
1140
1117
|
});
|
|
1141
1118
|
const i = await Promise.all(a);
|
|
1142
|
-
return
|
|
1119
|
+
return n.replace(e, () => i.shift() ?? "");
|
|
1143
1120
|
},
|
|
1144
1121
|
/**
|
|
1145
1122
|
* Capitalizes the first letter of a given string.
|
|
@@ -1151,8 +1128,8 @@ const O = {
|
|
|
1151
1128
|
* console.log(result); // Output: "Hello world"
|
|
1152
1129
|
* ```
|
|
1153
1130
|
*/
|
|
1154
|
-
capitalize(
|
|
1155
|
-
return
|
|
1131
|
+
capitalize(n) {
|
|
1132
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
1156
1133
|
},
|
|
1157
1134
|
/**
|
|
1158
1135
|
* Composes a template string by replacing placeholders with corresponding values and applying optional modifiers.
|
|
@@ -1168,15 +1145,15 @@ const O = {
|
|
|
1168
1145
|
* console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
|
|
1169
1146
|
* ```
|
|
1170
1147
|
*/
|
|
1171
|
-
compose(
|
|
1148
|
+
compose(n, e = {}, t = {
|
|
1172
1149
|
method: "index",
|
|
1173
1150
|
html: !1,
|
|
1174
1151
|
modifiers: {},
|
|
1175
1152
|
aliases: {}
|
|
1176
1153
|
}) {
|
|
1177
|
-
const { mergeSpanStyles: a } =
|
|
1154
|
+
const { mergeSpanStyles: a } = Q, i = (d, m, k) => t.html ? a(d, m, k) : m;
|
|
1178
1155
|
e.skip = "<br/>", e.newline = "<br/>";
|
|
1179
|
-
const
|
|
1156
|
+
const s = Object.entries(Z.flatten(e)).reduce(
|
|
1180
1157
|
(d, [m, k]) => {
|
|
1181
1158
|
if (d[m] = String(k), ["username", "name", "nick", "nickname", "sender"].some((v) => m === v)) {
|
|
1182
1159
|
const v = d?.username || d?.name || d?.nick || d?.nickname || d?.sender;
|
|
@@ -1189,7 +1166,7 @@ const O = {
|
|
|
1189
1166
|
PLACEHOLDERS: /{([^}]+)}/g,
|
|
1190
1167
|
MODIFIERS: /\[(\w+)(:[^=]+)?=([^\]]+)\]/g
|
|
1191
1168
|
};
|
|
1192
|
-
var o = parseFloat(
|
|
1169
|
+
var o = parseFloat(s?.amount ?? s?.count ?? 0);
|
|
1193
1170
|
const c = {
|
|
1194
1171
|
COLOR: (d, m) => i(m && $.validate(m) ? `color: ${m}` : "", d, "color"),
|
|
1195
1172
|
WEIGHT: (d, m) => i(m && !isNaN(parseInt(m)) ? `font-weight: ${m}` : "", d, "weight"),
|
|
@@ -1245,7 +1222,7 @@ const O = {
|
|
|
1245
1222
|
function f(d, m, k) {
|
|
1246
1223
|
const v = Object.entries(p).find(([j, x]) => x.some((T) => T.toUpperCase() === m.toUpperCase()) ? !0 : j.toUpperCase() === m.toUpperCase()), I = v ? v[0] : m.toUpperCase();
|
|
1247
1224
|
try {
|
|
1248
|
-
return h[I] ? h[I](d, typeof k == "string" ? k.trim() : null,
|
|
1225
|
+
return h[I] ? h[I](d, typeof k == "string" ? k.trim() : null, s) : t?.html ? i("", d, I.toLowerCase()) : d;
|
|
1249
1226
|
} catch {
|
|
1250
1227
|
return d;
|
|
1251
1228
|
}
|
|
@@ -1292,9 +1269,9 @@ const O = {
|
|
|
1292
1269
|
}
|
|
1293
1270
|
return v();
|
|
1294
1271
|
}
|
|
1295
|
-
let b =
|
|
1272
|
+
let b = n.replace(
|
|
1296
1273
|
r.PLACEHOLDERS,
|
|
1297
|
-
(d, m) => typeof
|
|
1274
|
+
(d, m) => typeof s[m] == "string" || typeof s[m] == "number" ? String(s[m]) : m ?? m
|
|
1298
1275
|
);
|
|
1299
1276
|
return b = t.method === "loop" ? g(b) : y(b), b;
|
|
1300
1277
|
}
|
|
@@ -2748,11 +2725,11 @@ const O = {
|
|
|
2748
2725
|
}
|
|
2749
2726
|
}
|
|
2750
2727
|
]).reduce(
|
|
2751
|
-
(
|
|
2728
|
+
(n, e) => (n.some((t) => t.name === e.name) || n.push({
|
|
2752
2729
|
...e,
|
|
2753
2730
|
start: 0,
|
|
2754
2731
|
end: 0
|
|
2755
|
-
}),
|
|
2732
|
+
}), n),
|
|
2756
2733
|
[]
|
|
2757
2734
|
), ut = [], gt = [
|
|
2758
2735
|
"Hello everyone!",
|
|
@@ -6068,8 +6045,8 @@ const O = {
|
|
|
6068
6045
|
}
|
|
6069
6046
|
];
|
|
6070
6047
|
var w;
|
|
6071
|
-
((
|
|
6072
|
-
|
|
6048
|
+
((n) => {
|
|
6049
|
+
n.avatars = ht, n.badges = lt, n.css_color_names = _, n.emotes = mt, n.items = ut, n.messages = gt, n.names = pt, n.tiers = ft, n.tts = bt, n.youtube_emotes = yt;
|
|
6073
6050
|
})(w || (w = {}));
|
|
6074
6051
|
const wt = {
|
|
6075
6052
|
/**
|
|
@@ -6078,15 +6055,15 @@ const wt = {
|
|
|
6078
6055
|
* @param emotes - An array of emotes to search for. Defaults to Local data emotes.
|
|
6079
6056
|
* @returns An array of emotes found in the text with their positions.
|
|
6080
6057
|
*/
|
|
6081
|
-
findEmotesInText(
|
|
6058
|
+
findEmotesInText(n, e = w.emotes) {
|
|
6082
6059
|
const t = [];
|
|
6083
6060
|
return e.forEach((a) => {
|
|
6084
6061
|
const i = a.name;
|
|
6085
|
-
let
|
|
6086
|
-
for (;
|
|
6087
|
-
const o =
|
|
6062
|
+
let s = 0, r = 0;
|
|
6063
|
+
for (; s < n.length; ) {
|
|
6064
|
+
const o = n.indexOf(i, r);
|
|
6088
6065
|
if (o === -1) break;
|
|
6089
|
-
const c = o > 0 ?
|
|
6066
|
+
const c = o > 0 ? n[o - 1] : " ", l = o + i.length < n.length ? n[o + i.length] : " ";
|
|
6090
6067
|
/\s/.test(c) && /\s/.test(l) && t.push({ ...a, start: o, end: o + i.length }), r = o + 1;
|
|
6091
6068
|
}
|
|
6092
6069
|
}), t.sort((a, i) => a.start - i.start);
|
|
@@ -6097,14 +6074,14 @@ const wt = {
|
|
|
6097
6074
|
* @param emotes - An array of emotes with their positions in the text.
|
|
6098
6075
|
* @returns The text with emotes replaced by HTML image tags.
|
|
6099
6076
|
*/
|
|
6100
|
-
replaceEmotesWithHTML(
|
|
6101
|
-
if (!e.length) return
|
|
6077
|
+
replaceEmotesWithHTML(n, e) {
|
|
6078
|
+
if (!e.length) return n;
|
|
6102
6079
|
let t = "", a = 0;
|
|
6103
6080
|
return e.forEach((i) => {
|
|
6104
|
-
t +=
|
|
6081
|
+
t += n.substring(a, i.start);
|
|
6105
6082
|
const r = Array.from({ ...i.urls, length: 5 }).slice(1).reverse().filter(Boolean)[0] || i.urls[1];
|
|
6106
6083
|
t += `<img src="${r}" alt="${i.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, a = i.end;
|
|
6107
|
-
}), t +=
|
|
6084
|
+
}), t += n.substring(a), t;
|
|
6108
6085
|
},
|
|
6109
6086
|
/**
|
|
6110
6087
|
* Replaces YouTube emotes in the text with corresponding HTML image tags.
|
|
@@ -6112,14 +6089,14 @@ const wt = {
|
|
|
6112
6089
|
* @param emotes - An array of YouTube emotes. Defaults to Local data YouTube emotes.
|
|
6113
6090
|
* @returns The text with YouTube emotes replaced by HTML image tags.
|
|
6114
6091
|
*/
|
|
6115
|
-
replaceYoutubeEmotesWithHTML(
|
|
6116
|
-
return Array.from(
|
|
6117
|
-
const i = e.find((
|
|
6092
|
+
replaceYoutubeEmotesWithHTML(n, e = w.youtube_emotes) {
|
|
6093
|
+
return Array.from(n.matchAll(/:(.*?):/gim), (a) => a[0]).forEach((a) => {
|
|
6094
|
+
const i = e.find((s) => s.shortcuts.includes(a) || s.searchTerms.includes(a.slice(1, -1)));
|
|
6118
6095
|
if (i) {
|
|
6119
|
-
const
|
|
6120
|
-
|
|
6096
|
+
const s = i.image.thumbnails.at(-1)?.url, r = i.image.accessibility.accessibilityData.label;
|
|
6097
|
+
s && (n = n.replace(a, `<img src="${s}" alt="${r}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`));
|
|
6121
6098
|
}
|
|
6122
|
-
}),
|
|
6099
|
+
}), n;
|
|
6123
6100
|
},
|
|
6124
6101
|
/**
|
|
6125
6102
|
* Generates badge data based on the provided badges and platform.
|
|
@@ -6134,25 +6111,25 @@ const wt = {
|
|
|
6134
6111
|
* const youtubeBadges = await generateBadges('sponsor, moderator', 'youtube');
|
|
6135
6112
|
* ```
|
|
6136
6113
|
*/
|
|
6137
|
-
async generateBadges(
|
|
6138
|
-
if (!Array.isArray(
|
|
6114
|
+
async generateBadges(n = [], e) {
|
|
6115
|
+
if (!Array.isArray(n) && typeof n == "string" && (n = n.split(",").map((r) => r.trim())), !n || !n.length) {
|
|
6139
6116
|
var t = O.number(1, 3);
|
|
6140
6117
|
for await (const r of Array.from({ length: t }, () => "")) {
|
|
6141
6118
|
var a = O.array(Object.keys(w.badges))[0];
|
|
6142
|
-
!
|
|
6119
|
+
!n.includes(a) && Array.isArray(n) ? n.push(a) : n = [a];
|
|
6143
6120
|
}
|
|
6144
6121
|
}
|
|
6145
6122
|
var i;
|
|
6146
6123
|
switch (e) {
|
|
6147
6124
|
case "twitch": {
|
|
6148
6125
|
i = {
|
|
6149
|
-
keys: Array.from(
|
|
6150
|
-
badges: Array.from(
|
|
6126
|
+
keys: Array.from(n).filter((r) => r in w.badges),
|
|
6127
|
+
badges: Array.from(n).slice(0, 3).map((r) => w.badges[r]).filter(Boolean)
|
|
6151
6128
|
};
|
|
6152
6129
|
break;
|
|
6153
6130
|
}
|
|
6154
6131
|
case "youtube": {
|
|
6155
|
-
var
|
|
6132
|
+
var s = {
|
|
6156
6133
|
verified: { isVerified: !0 },
|
|
6157
6134
|
broadcaster: { isChatOwner: !0 },
|
|
6158
6135
|
host: { isChatOwner: !0 },
|
|
@@ -6160,8 +6137,8 @@ const wt = {
|
|
|
6160
6137
|
subscriber: { isChatSponsor: !0 },
|
|
6161
6138
|
moderator: { isChatModerator: !0 }
|
|
6162
6139
|
};
|
|
6163
|
-
i = Object.entries(
|
|
6164
|
-
(r, [o]) => (o in
|
|
6140
|
+
i = Object.entries(n).reduce(
|
|
6141
|
+
(r, [o]) => (o in s && Object.assign(r, s[o]), r),
|
|
6165
6142
|
{
|
|
6166
6143
|
isVerified: !1,
|
|
6167
6144
|
isChatOwner: !1,
|
|
@@ -6175,8 +6152,8 @@ const wt = {
|
|
|
6175
6152
|
return i;
|
|
6176
6153
|
}
|
|
6177
6154
|
}, vt = {
|
|
6178
|
-
parseProvider(
|
|
6179
|
-
var e =
|
|
6155
|
+
parseProvider(n) {
|
|
6156
|
+
var e = n.event?.provider || n.event?.service || n.event?.data?.provider || window.client.details.provider;
|
|
6180
6157
|
return [
|
|
6181
6158
|
"kvstore:update",
|
|
6182
6159
|
"bot:counter",
|
|
@@ -6184,16 +6161,69 @@ const wt = {
|
|
|
6184
6161
|
"tip-latest",
|
|
6185
6162
|
"event:test",
|
|
6186
6163
|
"event:skip"
|
|
6187
|
-
].some((i) => i ===
|
|
6164
|
+
].some((i) => i === n.listener) && (e = "streamelements"), { provider: e, data: n };
|
|
6188
6165
|
}
|
|
6189
6166
|
};
|
|
6190
6167
|
var u;
|
|
6191
|
-
((
|
|
6192
|
-
|
|
6168
|
+
((n) => {
|
|
6169
|
+
n.sound = st, n.element = Q, n.color = $, n.object = Z, n.utils = B, n.random = O, n.number = X, n.string = dt, n.message = wt, n.event = vt;
|
|
6193
6170
|
})(u || (u = {}));
|
|
6171
|
+
class V {
|
|
6172
|
+
constructor(e) {
|
|
6173
|
+
this.field = "button", this.template = "button", this.name = "Button", this.value = "", window.client instanceof E && (this.field = e.field ?? this.field, this.template = e.template ?? this.template, this.name = e.name ?? this.name, this.value = e.value ?? this.value, this.run = e.run, window.client.actions.buttons.push(this), window.client.emit("action", this, "created"));
|
|
6174
|
+
}
|
|
6175
|
+
generate(e) {
|
|
6176
|
+
return B.typedValues(e).reduce(
|
|
6177
|
+
(a, i, s) => {
|
|
6178
|
+
const r = u.string.compose(this.template, { index: s, ...i }, { html: !1 }), o = u.string.compose(this.name, { index: s, ...i }, { html: !1 });
|
|
6179
|
+
a[r] = {
|
|
6180
|
+
type: "button",
|
|
6181
|
+
label: o
|
|
6182
|
+
};
|
|
6183
|
+
let c = u.string.compose(String(this.value), { index: s, ...i }, { html: !1 });
|
|
6184
|
+
return isNaN(Number(c)) ? c.toLowerCase() === "true" ? c = !0 : c.toLowerCase() === "false" && (c = !1) : c = Number(c), typeof c < "u" && c && (typeof c != "string" || c.length) && (a[r].value = c), a;
|
|
6185
|
+
},
|
|
6186
|
+
{}
|
|
6187
|
+
);
|
|
6188
|
+
}
|
|
6189
|
+
parse(e, t) {
|
|
6190
|
+
var a = e.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
|
|
6191
|
+
try {
|
|
6192
|
+
this.run.apply(window.client, [a.length ? a : e ?? e, t]);
|
|
6193
|
+
} catch (i) {
|
|
6194
|
+
throw new Error(`Error running button "${this.field}": ${i instanceof Error ? i.message : i}`);
|
|
6195
|
+
}
|
|
6196
|
+
return this;
|
|
6197
|
+
}
|
|
6198
|
+
remove() {
|
|
6199
|
+
if (!(window.client instanceof E)) return;
|
|
6200
|
+
const e = window.client.actions.buttons.indexOf(this);
|
|
6201
|
+
e > -1 && (window.client.actions.buttons.splice(e, 1), window.client.emit("action", this, "removed"));
|
|
6202
|
+
}
|
|
6203
|
+
static execute(e, t) {
|
|
6204
|
+
try {
|
|
6205
|
+
if (!(window.client instanceof E)) return !1;
|
|
6206
|
+
if (window.client.actions.buttons.length) {
|
|
6207
|
+
const a = window.client.actions.buttons.filter((i) => typeof i.field == "string" ? i.field === e : typeof i.field == "function" ? i.field(e, t) : !1);
|
|
6208
|
+
if (a.length && a.every((i) => i instanceof V))
|
|
6209
|
+
return a.forEach((i) => {
|
|
6210
|
+
try {
|
|
6211
|
+
i.parse(e, t), window.client.emit("action", i, "executed"), C.received(`Button executed: ${e}${t ? ` with value: ${t}` : ""}`);
|
|
6212
|
+
} catch (s) {
|
|
6213
|
+
C.error(`Error executing button "${e}": ${s instanceof Error ? s.message : s}`);
|
|
6214
|
+
}
|
|
6215
|
+
}), !0;
|
|
6216
|
+
}
|
|
6217
|
+
} catch {
|
|
6218
|
+
return !1;
|
|
6219
|
+
} finally {
|
|
6220
|
+
return !1;
|
|
6221
|
+
}
|
|
6222
|
+
}
|
|
6223
|
+
}
|
|
6194
6224
|
var U;
|
|
6195
|
-
((
|
|
6196
|
-
|
|
6225
|
+
((n) => {
|
|
6226
|
+
n.generate = {
|
|
6197
6227
|
session: {
|
|
6198
6228
|
types: {
|
|
6199
6229
|
name: { type: "string", options: w.names.filter((t) => t.length) },
|
|
@@ -6481,7 +6511,7 @@ var U;
|
|
|
6481
6511
|
};
|
|
6482
6512
|
return typeof r != "object" || r === null ? r : "type" in r && typeof r.type == "string" ? l(r) : c(r);
|
|
6483
6513
|
};
|
|
6484
|
-
var
|
|
6514
|
+
var s = Object.entries(i(a)).reduce(
|
|
6485
6515
|
(r, [o, c]) => (Object.entries(c).forEach(
|
|
6486
6516
|
([l, h]) => (
|
|
6487
6517
|
//
|
|
@@ -6490,7 +6520,7 @@ var U;
|
|
|
6490
6520
|
), r),
|
|
6491
6521
|
{}
|
|
6492
6522
|
);
|
|
6493
|
-
return
|
|
6523
|
+
return s;
|
|
6494
6524
|
}
|
|
6495
6525
|
},
|
|
6496
6526
|
event: {
|
|
@@ -6502,7 +6532,7 @@ var U;
|
|
|
6502
6532
|
* @returns A Promise that resolves to the simulated onWidgetLoad event data.
|
|
6503
6533
|
*/
|
|
6504
6534
|
async onWidgetLoad(t, a, i = "USD") {
|
|
6505
|
-
const
|
|
6535
|
+
const s = {
|
|
6506
6536
|
BRL: { code: "BRL", name: "Brazilian Real", symbol: "R$" },
|
|
6507
6537
|
USD: { code: "USD", name: "US Dollar", symbol: "$" },
|
|
6508
6538
|
EUR: { code: "EUR", name: "Euro", symbol: "€" }
|
|
@@ -6515,7 +6545,7 @@ var U;
|
|
|
6515
6545
|
providerId: "",
|
|
6516
6546
|
avatar: ""
|
|
6517
6547
|
},
|
|
6518
|
-
currency:
|
|
6548
|
+
currency: s[i] ?? s.USD,
|
|
6519
6549
|
fieldData: t,
|
|
6520
6550
|
recents: [],
|
|
6521
6551
|
session: {
|
|
@@ -6539,14 +6569,14 @@ var U;
|
|
|
6539
6569
|
* @returns A Promise that resolves to the simulated onSessionUpdate event data.
|
|
6540
6570
|
*/
|
|
6541
6571
|
async onSessionUpdate(t, a) {
|
|
6542
|
-
if (t ??= await
|
|
6543
|
-
const i = (
|
|
6572
|
+
if (t ??= await n.generate.session.get(), a) {
|
|
6573
|
+
const i = (s, r) => new Date(r.createdAt).getTime() - new Date(s.createdAt).getTime();
|
|
6544
6574
|
switch (a.provider) {
|
|
6545
6575
|
case "twitch": {
|
|
6546
|
-
const
|
|
6547
|
-
switch (
|
|
6576
|
+
const s = a.data;
|
|
6577
|
+
switch (s.listener) {
|
|
6548
6578
|
case "cheer-latest": {
|
|
6549
|
-
const r =
|
|
6579
|
+
const r = s.event.amount, o = s.event.displayName ?? s.event.name, c = s.event.message;
|
|
6550
6580
|
t["cheer-latest"] = { name: o, amount: r, message: c };
|
|
6551
6581
|
const l = (h) => {
|
|
6552
6582
|
if (h === "all") {
|
|
@@ -6562,14 +6592,14 @@ var U;
|
|
|
6562
6592
|
break;
|
|
6563
6593
|
}
|
|
6564
6594
|
case "follower-latest": {
|
|
6565
|
-
const r =
|
|
6595
|
+
const r = s.event.displayName ?? s.event.name;
|
|
6566
6596
|
t["follower-latest"].name = r, t["follower-session"].count += 1, t["follower-week"].count += 1, t["follower-month"].count += 1, t["follower-total"].count += 1, t["follower-goal"].amount += 1, t["follower-recent"].unshift({ name: r, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["follower-recent"] = (t["follower-recent"] || []).sort(i);
|
|
6567
6597
|
break;
|
|
6568
6598
|
}
|
|
6569
6599
|
case "subscriber-latest": {
|
|
6570
|
-
const r =
|
|
6571
|
-
if (t["subscriber-latest"] = { name: r, amount: o, tier: c, message: l ?? "" }, t["subscriber-recent"].find((h) => h.name.toLowerCase() === r.toLowerCase()) ? o > 1 && (t["subscriber-resub-latest"] = { name: r, amount: o, message: l ?? "" }, t["subscriber-resub-session"].count += 1) : (t["subscriber-new-latest"] = { name: r, amount: o, message: l ?? "" }, t["subscriber-new-session"].count += 1), !(!
|
|
6572
|
-
const h =
|
|
6600
|
+
const r = s.event.displayName ?? s.event.name, o = s.event.amount, c = s.event.tier, l = s.event.message;
|
|
6601
|
+
if (t["subscriber-latest"] = { name: r, amount: o, tier: c, message: l ?? "" }, t["subscriber-recent"].find((h) => h.name.toLowerCase() === r.toLowerCase()) ? o > 1 && (t["subscriber-resub-latest"] = { name: r, amount: o, message: l ?? "" }, t["subscriber-resub-session"].count += 1) : (t["subscriber-new-latest"] = { name: r, amount: o, message: l ?? "" }, t["subscriber-new-session"].count += 1), !(!s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift)) if (s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift) {
|
|
6602
|
+
const h = s.event.sender;
|
|
6573
6603
|
t["subscriber-gifted-latest"] = {
|
|
6574
6604
|
name: r,
|
|
6575
6605
|
amount: o,
|
|
@@ -6577,12 +6607,12 @@ var U;
|
|
|
6577
6607
|
message: l ?? "",
|
|
6578
6608
|
sender: h
|
|
6579
6609
|
}, t["subscriber-gifted-session"].count += 1, t["subscriber-alltime-gifter"] = { name: h, amount: o };
|
|
6580
|
-
} else
|
|
6610
|
+
} else s.event.gifted && !s.event.bulkGifted && s.event.isCommunityGift || !s.event.gifted && s.event.bulkGifted && s.event.isCommunityGift;
|
|
6581
6611
|
t["subscriber-session"].count += o, t["subscriber-week"].count += o, t["subscriber-month"].count += o, t["subscriber-total"].count += o, t["subscriber-goal"].amount += o, t["subscriber-points"].amount += o, t["subscriber-recent"].unshift({ name: r, amount: o, tier: c, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["subscriber-recent"] = (t["subscriber-recent"] || []).sort(i);
|
|
6582
6612
|
break;
|
|
6583
6613
|
}
|
|
6584
6614
|
case "raid-latest": {
|
|
6585
|
-
const r =
|
|
6615
|
+
const r = s.event.displayName ?? s.event.name, o = s.event.amount;
|
|
6586
6616
|
t["raid-latest"] = { name: r, amount: o }, t["raid-recent"].unshift({ name: r, amount: o, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["raid-recent"] = (t["raid-recent"] || []).sort(i);
|
|
6587
6617
|
break;
|
|
6588
6618
|
}
|
|
@@ -6590,10 +6620,10 @@ var U;
|
|
|
6590
6620
|
break;
|
|
6591
6621
|
}
|
|
6592
6622
|
case "youtube": {
|
|
6593
|
-
const
|
|
6594
|
-
switch (
|
|
6623
|
+
const s = a.data;
|
|
6624
|
+
switch (s.listener) {
|
|
6595
6625
|
case "superchat-latest": {
|
|
6596
|
-
const r =
|
|
6626
|
+
const r = s.event.displayName ?? s.event.name, o = s.event.amount;
|
|
6597
6627
|
t["superchat-latest"] = {
|
|
6598
6628
|
name: r.toLowerCase(),
|
|
6599
6629
|
displayName: r,
|
|
@@ -6632,10 +6662,10 @@ var U;
|
|
|
6632
6662
|
break;
|
|
6633
6663
|
}
|
|
6634
6664
|
case "streamelements": {
|
|
6635
|
-
const
|
|
6636
|
-
switch (
|
|
6665
|
+
const s = a.data;
|
|
6666
|
+
switch (s.listener) {
|
|
6637
6667
|
case "tip-latest": {
|
|
6638
|
-
const r =
|
|
6668
|
+
const r = s.event.displayName ?? s.event.name, o = s.event.amount;
|
|
6639
6669
|
t["tip-latest"] = { name: r, amount: o };
|
|
6640
6670
|
const c = (l) => {
|
|
6641
6671
|
if (l === "all") {
|
|
@@ -6673,7 +6703,7 @@ var U;
|
|
|
6673
6703
|
* ```
|
|
6674
6704
|
*/
|
|
6675
6705
|
async onEventReceived(t = "random", a = "random", i = {}) {
|
|
6676
|
-
const
|
|
6706
|
+
const s = {
|
|
6677
6707
|
twitch: ["message", "follower-latest", "cheer-latest", "raid-latest", "subscriber-latest"],
|
|
6678
6708
|
streamelements: ["tip-latest"],
|
|
6679
6709
|
youtube: ["message", "superchat-latest", "subscriber-latest", "sponsor-latest"],
|
|
@@ -6683,14 +6713,14 @@ var U;
|
|
|
6683
6713
|
switch (t) {
|
|
6684
6714
|
default:
|
|
6685
6715
|
case "random": {
|
|
6686
|
-
var r = u.random.array(Object.keys(
|
|
6716
|
+
var r = u.random.array(Object.keys(s).filter((J) => s[J].length))[0], o = u.random.array(s[r])[0];
|
|
6687
6717
|
return this.onEventReceived(r, o);
|
|
6688
6718
|
}
|
|
6689
6719
|
case "twitch":
|
|
6690
6720
|
switch (a) {
|
|
6691
6721
|
default:
|
|
6692
6722
|
case "random": {
|
|
6693
|
-
var o = u.random.array(
|
|
6723
|
+
var o = u.random.array(s[t])[0];
|
|
6694
6724
|
return this.onEventReceived(t, o);
|
|
6695
6725
|
}
|
|
6696
6726
|
case "message": {
|
|
@@ -6866,7 +6896,7 @@ var U;
|
|
|
6866
6896
|
switch (a) {
|
|
6867
6897
|
default:
|
|
6868
6898
|
case "random": {
|
|
6869
|
-
var o = u.random.array(
|
|
6899
|
+
var o = u.random.array(s[t])[0];
|
|
6870
6900
|
return this.onEventReceived(t, o);
|
|
6871
6901
|
}
|
|
6872
6902
|
case "tip":
|
|
@@ -6943,7 +6973,7 @@ var U;
|
|
|
6943
6973
|
switch (a) {
|
|
6944
6974
|
default:
|
|
6945
6975
|
case "random": {
|
|
6946
|
-
var o = u.random.array(
|
|
6976
|
+
var o = u.random.array(s[t])[0];
|
|
6947
6977
|
return this.onEventReceived(t, o);
|
|
6948
6978
|
}
|
|
6949
6979
|
case "message": {
|
|
@@ -7082,11 +7112,11 @@ var U;
|
|
|
7082
7112
|
}
|
|
7083
7113
|
}
|
|
7084
7114
|
}
|
|
7085
|
-
},
|
|
7115
|
+
}, n.emulate = {
|
|
7086
7116
|
twitch: {
|
|
7087
7117
|
message(t = {}) {
|
|
7088
|
-
|
|
7089
|
-
a &&
|
|
7118
|
+
n.generate.event.onEventReceived("twitch", "message", t).then((a) => {
|
|
7119
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7090
7120
|
});
|
|
7091
7121
|
},
|
|
7092
7122
|
deleteMessage(t) {
|
|
@@ -7097,7 +7127,7 @@ var U;
|
|
|
7097
7127
|
msgId: t
|
|
7098
7128
|
}
|
|
7099
7129
|
};
|
|
7100
|
-
|
|
7130
|
+
n.emulate.send("onEventReceived", a);
|
|
7101
7131
|
},
|
|
7102
7132
|
deleteMessages(t) {
|
|
7103
7133
|
if (!t || typeof t != "string") return;
|
|
@@ -7107,68 +7137,68 @@ var U;
|
|
|
7107
7137
|
userId: t
|
|
7108
7138
|
}
|
|
7109
7139
|
};
|
|
7110
|
-
|
|
7140
|
+
n.emulate.send("onEventReceived", a);
|
|
7111
7141
|
},
|
|
7112
7142
|
follower(t = {}) {
|
|
7113
|
-
|
|
7114
|
-
a &&
|
|
7143
|
+
n.generate.event.onEventReceived("twitch", "follower-latest", t).then((a) => {
|
|
7144
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7115
7145
|
});
|
|
7116
7146
|
},
|
|
7117
7147
|
raid(t = {}) {
|
|
7118
|
-
|
|
7119
|
-
a &&
|
|
7148
|
+
n.generate.event.onEventReceived("twitch", "raid-latest", t).then((a) => {
|
|
7149
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7120
7150
|
});
|
|
7121
7151
|
},
|
|
7122
7152
|
cheer(t = {}) {
|
|
7123
|
-
|
|
7124
|
-
a &&
|
|
7153
|
+
n.generate.event.onEventReceived("twitch", "cheer-latest", t).then((a) => {
|
|
7154
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7125
7155
|
});
|
|
7126
7156
|
},
|
|
7127
7157
|
subscriber(t = {}) {
|
|
7128
|
-
|
|
7129
|
-
a &&
|
|
7158
|
+
n.generate.event.onEventReceived("twitch", "subscriber-latest", t).then((a) => {
|
|
7159
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7130
7160
|
});
|
|
7131
7161
|
}
|
|
7132
7162
|
},
|
|
7133
7163
|
streamelements: {
|
|
7134
7164
|
tip(t = {}) {
|
|
7135
|
-
|
|
7136
|
-
a &&
|
|
7165
|
+
n.generate.event.onEventReceived("streamelements", "tip-latest", t).then((a) => {
|
|
7166
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7137
7167
|
});
|
|
7138
7168
|
}
|
|
7139
7169
|
},
|
|
7140
7170
|
youtube: {
|
|
7141
7171
|
message(t = {}) {
|
|
7142
|
-
|
|
7143
|
-
a &&
|
|
7172
|
+
n.generate.event.onEventReceived("youtube", "message", t).then((a) => {
|
|
7173
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7144
7174
|
});
|
|
7145
7175
|
},
|
|
7146
7176
|
subscriber(t = {}) {
|
|
7147
|
-
|
|
7148
|
-
a &&
|
|
7177
|
+
n.generate.event.onEventReceived("youtube", "subscriber-latest", t).then((a) => {
|
|
7178
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7149
7179
|
});
|
|
7150
7180
|
},
|
|
7151
7181
|
superchat(t = {}) {
|
|
7152
|
-
|
|
7153
|
-
a &&
|
|
7182
|
+
n.generate.event.onEventReceived("youtube", "superchat-latest", t).then((a) => {
|
|
7183
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7154
7184
|
});
|
|
7155
7185
|
},
|
|
7156
7186
|
sponsor(t = {}) {
|
|
7157
|
-
|
|
7158
|
-
a &&
|
|
7187
|
+
n.generate.event.onEventReceived("youtube", "sponsor-latest", t).then((a) => {
|
|
7188
|
+
a && n.emulate.send("onEventReceived", a);
|
|
7159
7189
|
});
|
|
7160
7190
|
}
|
|
7161
7191
|
},
|
|
7162
7192
|
kick: {},
|
|
7163
7193
|
facebook: {},
|
|
7164
7194
|
send(t, a) {
|
|
7165
|
-
if (!
|
|
7195
|
+
if (!n.queue) {
|
|
7166
7196
|
C.warn("Local queue is not initialized."), window.dispatchEvent(new CustomEvent(t, { detail: a }));
|
|
7167
7197
|
return;
|
|
7168
7198
|
}
|
|
7169
7199
|
switch (t) {
|
|
7170
7200
|
case "onEventReceived": {
|
|
7171
|
-
|
|
7201
|
+
n.queue.enqueue({
|
|
7172
7202
|
listener: t,
|
|
7173
7203
|
data: a,
|
|
7174
7204
|
session: t === "onEventReceived" ? !0 : void 0
|
|
@@ -7176,14 +7206,14 @@ var U;
|
|
|
7176
7206
|
break;
|
|
7177
7207
|
}
|
|
7178
7208
|
case "onSessionUpdate": {
|
|
7179
|
-
|
|
7209
|
+
n.queue.enqueue({
|
|
7180
7210
|
listener: t,
|
|
7181
7211
|
data: a
|
|
7182
7212
|
});
|
|
7183
7213
|
break;
|
|
7184
7214
|
}
|
|
7185
7215
|
case "onWidgetLoad": {
|
|
7186
|
-
|
|
7216
|
+
n.queue.enqueue({
|
|
7187
7217
|
listener: t,
|
|
7188
7218
|
data: a
|
|
7189
7219
|
});
|
|
@@ -7193,7 +7223,7 @@ var U;
|
|
|
7193
7223
|
}
|
|
7194
7224
|
};
|
|
7195
7225
|
async function e(t = ["fields.json", "cf.json", "field.json", "customfields.json"], a = ["data.json", "fielddata.json", "fd.json", "DATA.json"], i) {
|
|
7196
|
-
const
|
|
7226
|
+
const s = {
|
|
7197
7227
|
fields: t.find((o) => {
|
|
7198
7228
|
try {
|
|
7199
7229
|
return new URL("./" + o, window.location.href), !0;
|
|
@@ -7208,10 +7238,10 @@ var U;
|
|
|
7208
7238
|
return !1;
|
|
7209
7239
|
}
|
|
7210
7240
|
})
|
|
7211
|
-
}, r = await fetch("./" + (
|
|
7241
|
+
}, r = await fetch("./" + (s.data ?? "data.json"), {
|
|
7212
7242
|
cache: "no-store"
|
|
7213
7243
|
}).then((o) => o.json()).catch(() => ({}));
|
|
7214
|
-
await fetch("./" + (
|
|
7244
|
+
await fetch("./" + (s.fields ?? "fields.json"), {
|
|
7215
7245
|
cache: "no-store"
|
|
7216
7246
|
}).then((o) => o.json()).then(async (o) => {
|
|
7217
7247
|
const c = Object.entries(o).filter(([h, { value: p }]) => p != null).reduce(
|
|
@@ -7219,11 +7249,11 @@ var U;
|
|
|
7219
7249
|
{
|
|
7220
7250
|
...r
|
|
7221
7251
|
}
|
|
7222
|
-
), l = await
|
|
7252
|
+
), l = await n.generate.event.onWidgetLoad(c, await n.generate.session.get(i));
|
|
7223
7253
|
window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: l }));
|
|
7224
7254
|
});
|
|
7225
7255
|
}
|
|
7226
|
-
|
|
7256
|
+
n.start = e;
|
|
7227
7257
|
})(U || (U = {}));
|
|
7228
7258
|
class tt extends N {
|
|
7229
7259
|
constructor(e) {
|
|
@@ -7293,8 +7323,8 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
|
|
|
7293
7323
|
}
|
|
7294
7324
|
}
|
|
7295
7325
|
}));
|
|
7296
|
-
}), window.addEventListener("onWidgetLoad", async (
|
|
7297
|
-
const { detail: e } =
|
|
7326
|
+
}), window.addEventListener("onWidgetLoad", async (n) => {
|
|
7327
|
+
const { detail: e } = n;
|
|
7298
7328
|
if (window.client instanceof E) {
|
|
7299
7329
|
const t = window.client;
|
|
7300
7330
|
if (t.fields = e.fieldData, t.session = e.session.data, t.details = {
|
|
@@ -7309,8 +7339,8 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
|
|
|
7309
7339
|
}).catch(() => {
|
|
7310
7340
|
t.details.provider = "local";
|
|
7311
7341
|
}) : t.details.provider = "local", t.emit("load", e), t.debug) {
|
|
7312
|
-
C.received("Widget loaded!",
|
|
7313
|
-
const a =
|
|
7342
|
+
C.received("Widget loaded!", n.detail);
|
|
7343
|
+
const a = n.detail.fieldData;
|
|
7314
7344
|
Object.keys(a).length && C.received("Field data:", a);
|
|
7315
7345
|
}
|
|
7316
7346
|
t.loaded = !0, t.storage.on("load", (a) => {
|
|
@@ -7323,9 +7353,9 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
|
|
|
7323
7353
|
g.expire && g.expire > h && (p[f] = g);
|
|
7324
7354
|
}
|
|
7325
7355
|
return p;
|
|
7326
|
-
},
|
|
7356
|
+
}, s = i(a.user || {}), r = i(a.avatar || {}), o = i(a.pronoun || {}), c = i(a.emote || {});
|
|
7327
7357
|
t.storage.update({
|
|
7328
|
-
user:
|
|
7358
|
+
user: s,
|
|
7329
7359
|
avatar: r,
|
|
7330
7360
|
pronoun: o,
|
|
7331
7361
|
emote: c
|
|
@@ -7338,15 +7368,15 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
|
|
|
7338
7368
|
});
|
|
7339
7369
|
});
|
|
7340
7370
|
}
|
|
7341
|
-
}), window.addEventListener("onSessionUpdate", (
|
|
7342
|
-
const { detail: e } =
|
|
7371
|
+
}), window.addEventListener("onSessionUpdate", (n) => {
|
|
7372
|
+
const { detail: e } = n;
|
|
7343
7373
|
if (window.client instanceof E) {
|
|
7344
7374
|
const t = window.client;
|
|
7345
7375
|
t.session = e.session, t.emit("session", e.session), t.debug && C.debug("[Client]", "Session updated", e.session);
|
|
7346
7376
|
}
|
|
7347
|
-
}), window.addEventListener("onEventReceived", ({ detail:
|
|
7377
|
+
}), window.addEventListener("onEventReceived", ({ detail: n }) => {
|
|
7348
7378
|
if (window.client instanceof E) {
|
|
7349
|
-
const t = u.event.parseProvider(
|
|
7379
|
+
const t = u.event.parseProvider(n);
|
|
7350
7380
|
switch (t.provider) {
|
|
7351
7381
|
case "streamelements": {
|
|
7352
7382
|
const i = t.data;
|
|
@@ -7362,8 +7392,8 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
|
|
|
7362
7392
|
case "event:test": {
|
|
7363
7393
|
switch (i.event.listener) {
|
|
7364
7394
|
case "widget-button": {
|
|
7365
|
-
const
|
|
7366
|
-
|
|
7395
|
+
const s = i.event;
|
|
7396
|
+
V.execute(s.field, s.value);
|
|
7367
7397
|
break;
|
|
7368
7398
|
}
|
|
7369
7399
|
case "subscriber-latest": {
|
|
@@ -7374,10 +7404,10 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
|
|
|
7374
7404
|
break;
|
|
7375
7405
|
}
|
|
7376
7406
|
case "kvstore:update": {
|
|
7377
|
-
const
|
|
7407
|
+
const s = i.event;
|
|
7378
7408
|
if (L.length) {
|
|
7379
|
-
var e = L.find((r) => r.id ===
|
|
7380
|
-
e && e.update(
|
|
7409
|
+
var e = L.find((r) => r.id === s.data.key.replace("customWidget.", ""));
|
|
7410
|
+
e && e.update(s.data.value);
|
|
7381
7411
|
}
|
|
7382
7412
|
break;
|
|
7383
7413
|
}
|
|
@@ -7386,8 +7416,8 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
|
|
|
7386
7416
|
break;
|
|
7387
7417
|
}
|
|
7388
7418
|
case "alertService:toggleSound": {
|
|
7389
|
-
const
|
|
7390
|
-
client.details.overlay.muted = !!
|
|
7419
|
+
const s = i.event;
|
|
7420
|
+
client.details.overlay.muted = !!s.muted;
|
|
7391
7421
|
break;
|
|
7392
7422
|
}
|
|
7393
7423
|
}
|
|
@@ -7480,72 +7510,72 @@ const G = {
|
|
|
7480
7510
|
resumeQueue: () => {
|
|
7481
7511
|
},
|
|
7482
7512
|
responses: {},
|
|
7483
|
-
sendMessage(
|
|
7513
|
+
sendMessage(n, e) {
|
|
7484
7514
|
},
|
|
7485
7515
|
counters: {
|
|
7486
|
-
get(
|
|
7516
|
+
get(n) {
|
|
7487
7517
|
return null;
|
|
7488
7518
|
}
|
|
7489
7519
|
},
|
|
7490
|
-
sanitize(
|
|
7491
|
-
return
|
|
7520
|
+
sanitize(n) {
|
|
7521
|
+
return n;
|
|
7492
7522
|
},
|
|
7493
|
-
cheerFilter(
|
|
7494
|
-
return
|
|
7523
|
+
cheerFilter(n) {
|
|
7524
|
+
return n;
|
|
7495
7525
|
},
|
|
7496
|
-
setField(
|
|
7526
|
+
setField(n, e, t) {
|
|
7497
7527
|
},
|
|
7498
7528
|
store: {
|
|
7499
|
-
set: function(
|
|
7500
|
-
this.list[
|
|
7529
|
+
set: function(n, e) {
|
|
7530
|
+
this.list[n] = e, localStorage.setItem("SE_API-STORE", JSON.stringify(G.store.list));
|
|
7501
7531
|
},
|
|
7502
|
-
get: async function(
|
|
7503
|
-
return this.list[
|
|
7532
|
+
get: async function(n) {
|
|
7533
|
+
return this.list[n] ? this.list[n] : null;
|
|
7504
7534
|
},
|
|
7505
7535
|
list: {}
|
|
7506
7536
|
}
|
|
7507
7537
|
};
|
|
7508
7538
|
async function kt() {
|
|
7509
|
-
let
|
|
7539
|
+
let n = localStorage.getItem("SE_API-STORE") ?? "", e = n ? JSON.parse(n) : {};
|
|
7510
7540
|
return G.store.list = e, G;
|
|
7511
7541
|
}
|
|
7512
7542
|
var F;
|
|
7513
|
-
((
|
|
7543
|
+
((n) => {
|
|
7514
7544
|
let e;
|
|
7515
7545
|
((i) => {
|
|
7516
|
-
((
|
|
7517
|
-
|
|
7546
|
+
((s) => {
|
|
7547
|
+
s.hehim = "He/Him", s.sheher = "She/Her", s.theythem = "They/Them", s.shethem = "She/They", s.hethem = "He/They", s.heshe = "He/She", s.xexem = "Xe/Xem", s.faefaer = "Fae/Faer", s.vever = "Ve/Ver", s.aeaer = "Ae/Aer", s.ziehir = "Zie/Hir", s.perper = "Per/Per", s.eem = "E/Em", s.itits = "It/Its";
|
|
7518
7548
|
})(i.map || (i.map = {}));
|
|
7519
|
-
})(e =
|
|
7549
|
+
})(e = n.Pronouns || (n.Pronouns = {}));
|
|
7520
7550
|
async function t() {
|
|
7521
7551
|
try {
|
|
7522
|
-
const i = await fetch("https://pronouns.alejo.io/api/pronouns").then((
|
|
7552
|
+
const i = await fetch("https://pronouns.alejo.io/api/pronouns").then((s) => s.json());
|
|
7523
7553
|
if (Array.isArray(i) && i.length) {
|
|
7524
|
-
const
|
|
7525
|
-
return { ...e.map, ...
|
|
7554
|
+
const s = Object.fromEntries(i.map(({ name: r, display: o }) => [r, o]));
|
|
7555
|
+
return { ...e.map, ...s };
|
|
7526
7556
|
}
|
|
7527
7557
|
} catch {
|
|
7528
7558
|
}
|
|
7529
7559
|
return { ...e.map };
|
|
7530
7560
|
}
|
|
7531
|
-
|
|
7561
|
+
n.list = t;
|
|
7532
7562
|
async function a(i) {
|
|
7533
7563
|
if (!i) throw new Error("Username is required to fetch Alejo data.");
|
|
7534
7564
|
if (i = i.toLowerCase(), i in client.storage.data.pronoun && client.storage.data.pronoun[i].expire > Date.now())
|
|
7535
7565
|
return client.storage.data.pronoun[i].value;
|
|
7536
7566
|
try {
|
|
7537
|
-
const
|
|
7538
|
-
if (
|
|
7567
|
+
const s = await fetch(`https://pronouns.alejo.io/api/users/${i}`).then((r) => r.json()).then(([r]) => r);
|
|
7568
|
+
if (s)
|
|
7539
7569
|
return client.storage.add(`pronoun.${i}`, {
|
|
7540
|
-
value:
|
|
7570
|
+
value: s.pronoun_id,
|
|
7541
7571
|
timestamp: Date.now(),
|
|
7542
7572
|
expire: Date.now() + client.cache.pronoun * 60 * 1e3
|
|
7543
|
-
}), client.storage.data.pronoun[i].value ??
|
|
7544
|
-
} catch (
|
|
7545
|
-
throw new Error(`Failed to fetch pronoun data for user "${i}": ${
|
|
7573
|
+
}), client.storage.data.pronoun[i].value ?? s.pronoun_id;
|
|
7574
|
+
} catch (s) {
|
|
7575
|
+
throw new Error(`Failed to fetch pronoun data for user "${i}": ${s instanceof Error ? s.message : s}`);
|
|
7546
7576
|
}
|
|
7547
7577
|
}
|
|
7548
|
-
|
|
7578
|
+
n.get = a;
|
|
7549
7579
|
})(F || (F = {}));
|
|
7550
7580
|
class Ct extends N {
|
|
7551
7581
|
/**
|
|
@@ -7578,8 +7608,8 @@ class Ct extends N {
|
|
|
7578
7608
|
connect() {
|
|
7579
7609
|
this.instance.onError = (e) => {
|
|
7580
7610
|
this.emit("error", e), client.debug && C.error("[Client]", "ComfyJS Error:", e);
|
|
7581
|
-
}, this.instance.onCommand = (e, t, a, i,
|
|
7582
|
-
if (this.emit("command", e, t, a, i,
|
|
7611
|
+
}, this.instance.onCommand = (e, t, a, i, s) => {
|
|
7612
|
+
if (this.emit("command", e, t, a, i, s), client.debug && C.debug("[Client]", `ComfyJS Command: !${t} ${a} (User: ${e})`), this.emulate) {
|
|
7583
7613
|
const r = {
|
|
7584
7614
|
...i,
|
|
7585
7615
|
broadcaster: i.broadcaster,
|
|
@@ -7591,19 +7621,19 @@ class Ct extends N {
|
|
|
7591
7621
|
name: e,
|
|
7592
7622
|
message: `!${t} ${a}`,
|
|
7593
7623
|
badges: Object.entries(r).map(([c, l]) => l ? c : null).filter(Boolean),
|
|
7594
|
-
color:
|
|
7595
|
-
time: new Date(
|
|
7596
|
-
userId:
|
|
7597
|
-
msgId:
|
|
7598
|
-
channel:
|
|
7624
|
+
color: s.userColor,
|
|
7625
|
+
time: new Date(s.timestamp).getTime(),
|
|
7626
|
+
userId: s.userId,
|
|
7627
|
+
msgId: s.id,
|
|
7628
|
+
channel: s.channel
|
|
7599
7629
|
};
|
|
7600
7630
|
U.emulate.twitch.message(o);
|
|
7601
7631
|
}
|
|
7602
|
-
}, this.instance.onChat = (e, t, a, i,
|
|
7603
|
-
if (this.emit("chat", e, t, a, i,
|
|
7632
|
+
}, this.instance.onChat = (e, t, a, i, s) => {
|
|
7633
|
+
if (this.emit("chat", e, t, a, i, s), client.debug && C.debug("[Client]", `ComfyJS Chat: ${t} (User: ${e})`), this.emulate) {
|
|
7604
7634
|
const r = {
|
|
7605
7635
|
...a,
|
|
7606
|
-
...
|
|
7636
|
+
...s.userBadges,
|
|
7607
7637
|
broadcaster: a.broadcaster,
|
|
7608
7638
|
moderator: a.mod,
|
|
7609
7639
|
vip: a.vip,
|
|
@@ -7614,15 +7644,15 @@ class Ct extends N {
|
|
|
7614
7644
|
name: e,
|
|
7615
7645
|
message: t,
|
|
7616
7646
|
badges: Object.entries(r).map(([o, c]) => c ? o : null).filter(Boolean),
|
|
7617
|
-
color:
|
|
7618
|
-
time: new Date(
|
|
7619
|
-
userId:
|
|
7620
|
-
msgId:
|
|
7621
|
-
channel:
|
|
7647
|
+
color: s.userColor,
|
|
7648
|
+
time: new Date(s.timestamp).getTime(),
|
|
7649
|
+
userId: s.userId,
|
|
7650
|
+
msgId: s.id,
|
|
7651
|
+
channel: s.channel
|
|
7622
7652
|
});
|
|
7623
7653
|
}
|
|
7624
|
-
}, this.instance.onWhisper = (e, t, a, i,
|
|
7625
|
-
this.emit("whisper", e, t, a, i,
|
|
7654
|
+
}, this.instance.onWhisper = (e, t, a, i, s) => {
|
|
7655
|
+
this.emit("whisper", e, t, a, i, s), client.debug && C.debug("[Client]", `ComfyJS Whisper: ${t} (User: ${e})`);
|
|
7626
7656
|
}, this.instance.onMessageDeleted = (e, t) => {
|
|
7627
7657
|
this.emit("messageDeleted", e, t), client.debug && C.debug("[Client]", `ComfyJS Message Deleted: ${e}`), this.emulate && U.emulate.twitch.deleteMessage(e);
|
|
7628
7658
|
}, this.instance.onJoin = (e, t, a) => {
|
|
@@ -7638,17 +7668,17 @@ class Ct extends N {
|
|
|
7638
7668
|
});
|
|
7639
7669
|
}, this.instance.onSub = (e, t, a, i) => {
|
|
7640
7670
|
if (this.emit("sub", e, t, a, i), client.debug && C.debug("[Client]", `ComfyJS Sub: ${e} (${a.plan})`), this.emulate) {
|
|
7641
|
-
const
|
|
7671
|
+
const s = a.plan === "Prime" ? "prime" : a.plan;
|
|
7642
7672
|
U.emulate.twitch.subscriber({
|
|
7643
7673
|
name: e,
|
|
7644
7674
|
message: t,
|
|
7645
|
-
tier:
|
|
7675
|
+
tier: s,
|
|
7646
7676
|
subType: "default"
|
|
7647
7677
|
});
|
|
7648
7678
|
}
|
|
7649
|
-
}, this.instance.onResub = (e, t, a, i,
|
|
7650
|
-
if (this.emit("resub", e, t, a, i,
|
|
7651
|
-
const o =
|
|
7679
|
+
}, this.instance.onResub = (e, t, a, i, s, r) => {
|
|
7680
|
+
if (this.emit("resub", e, t, a, i, s, r), client.debug && C.debug("[Client]", `ComfyJS Resub: ${e} (${i} months)`), this.emulate) {
|
|
7681
|
+
const o = s.plan === "Prime" ? "prime" : s.plan;
|
|
7652
7682
|
U.emulate.twitch.subscriber({
|
|
7653
7683
|
name: e,
|
|
7654
7684
|
message: t,
|
|
@@ -7657,9 +7687,9 @@ class Ct extends N {
|
|
|
7657
7687
|
subType: "default"
|
|
7658
7688
|
});
|
|
7659
7689
|
}
|
|
7660
|
-
}, this.instance.onSubGift = (e, t, a, i,
|
|
7661
|
-
if (this.emit("subGift", e, t, a, i,
|
|
7662
|
-
const o =
|
|
7690
|
+
}, this.instance.onSubGift = (e, t, a, i, s, r) => {
|
|
7691
|
+
if (this.emit("subGift", e, t, a, i, s, r), client.debug && C.debug("[Client]", `ComfyJS Sub Gift: ${e} gifted ${i} subs`), this.emulate) {
|
|
7692
|
+
const o = s.plan === "Prime" ? "prime" : s.plan;
|
|
7663
7693
|
U.emulate.twitch.subscriber({
|
|
7664
7694
|
name: a,
|
|
7665
7695
|
message: "",
|
|
@@ -7669,8 +7699,8 @@ class Ct extends N {
|
|
|
7669
7699
|
subType: "gift"
|
|
7670
7700
|
});
|
|
7671
7701
|
}
|
|
7672
|
-
}, this.instance.onSubMysteryGift = (e, t, a, i,
|
|
7673
|
-
if (this.emit("subMysteryGift", e, t, a, i,
|
|
7702
|
+
}, this.instance.onSubMysteryGift = (e, t, a, i, s) => {
|
|
7703
|
+
if (this.emit("subMysteryGift", e, t, a, i, s), client.debug && C.debug("[Client]", `ComfyJS Sub Mystery Gift: ${e} gifted ${t} subs`), this.emulate) {
|
|
7674
7704
|
const r = i.plan === "Prime" ? "prime" : i.plan;
|
|
7675
7705
|
U.emulate.twitch.subscriber({
|
|
7676
7706
|
name: e,
|
|
@@ -7688,16 +7718,16 @@ class Ct extends N {
|
|
|
7688
7718
|
tier: "1000",
|
|
7689
7719
|
subType: "gift"
|
|
7690
7720
|
});
|
|
7691
|
-
}, this.instance.onCheer = (e, t, a, i,
|
|
7692
|
-
this.emit("cheer", e, t, a, i,
|
|
7721
|
+
}, this.instance.onCheer = (e, t, a, i, s) => {
|
|
7722
|
+
this.emit("cheer", e, t, a, i, s), client.debug && C.debug("[Client]", `ComfyJS Cheer: ${e} cheered ${a} bits - ${t}`), this.emulate && U.emulate.twitch.cheer({
|
|
7693
7723
|
name: e,
|
|
7694
7724
|
message: t,
|
|
7695
7725
|
amount: a
|
|
7696
7726
|
});
|
|
7697
7727
|
}, this.instance.onChatMode = (e, t) => {
|
|
7698
7728
|
this.emit("chatMode", e, t), client.debug && C.debug("[Client]", `ComfyJS Chat Mode Changed on ${t}`);
|
|
7699
|
-
}, this.instance.onReward = (e, t, a, i,
|
|
7700
|
-
this.emit("reward", e, t, a, i,
|
|
7729
|
+
}, this.instance.onReward = (e, t, a, i, s) => {
|
|
7730
|
+
this.emit("reward", e, t, a, i, s), client.debug && C.debug("[Client]", `ComfyJS Reward: ${e} redeemed ${t} for ${a} - ${i}`);
|
|
7701
7731
|
}, this.instance.onConnected = (e, t, a) => {
|
|
7702
7732
|
this.emit("connected", e, t, a), client.debug && C.debug("[Client]", `ComfyJS Connected: ${e}:${t} (First Connect: ${a})`);
|
|
7703
7733
|
}, this.instance.onReconnect = (e) => {
|
|
@@ -7770,15 +7800,15 @@ class et {
|
|
|
7770
7800
|
const t = this.style(e), a = e.icon ? `${e.icon} ` : "";
|
|
7771
7801
|
return (...i) => {
|
|
7772
7802
|
if (!this.enabled || typeof console > "u") return;
|
|
7773
|
-
let
|
|
7774
|
-
typeof this.prefix == "function" ?
|
|
7803
|
+
let s = "";
|
|
7804
|
+
typeof this.prefix == "function" ? s = this.prefix() : typeof this.prefix == "string" && (s = this.prefix);
|
|
7775
7805
|
const r = [], o = [];
|
|
7776
7806
|
if (i.forEach((c) => {
|
|
7777
7807
|
typeof c == "string" || typeof c == "number" || typeof c == "boolean" ? r.push(c) : o.push(c);
|
|
7778
7808
|
}), r.length > 0) {
|
|
7779
7809
|
const c = r.join(" ");
|
|
7780
|
-
console.log(`%c${
|
|
7781
|
-
} else o.length > 0 && console.log(`%c${
|
|
7810
|
+
console.log(`%c${s.endsWith(" ") ? s : s.trim() + " "}${a}${c}`, t, ...o);
|
|
7811
|
+
} else o.length > 0 && console.log(`%c${s.endsWith(" ") ? s : s.trim() + " "}${a}`, t, ...o);
|
|
7782
7812
|
};
|
|
7783
7813
|
}
|
|
7784
7814
|
style(e) {
|
|
@@ -7804,7 +7834,7 @@ class et {
|
|
|
7804
7834
|
!this.enabled || !console.timeEnd || console.timeEnd(e);
|
|
7805
7835
|
}
|
|
7806
7836
|
}
|
|
7807
|
-
const it = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(kt()), C = new et(),
|
|
7837
|
+
const it = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(kt()), C = new et(), Y = {
|
|
7808
7838
|
SeAPI: it,
|
|
7809
7839
|
Client: E,
|
|
7810
7840
|
Helper: u,
|
|
@@ -7812,13 +7842,13 @@ const it = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(kt())
|
|
|
7812
7842
|
Data: w,
|
|
7813
7843
|
logger: C,
|
|
7814
7844
|
modules: { EventProvider: N, useStorage: W, useQueue: tt, useLogger: et },
|
|
7815
|
-
actions: { Button:
|
|
7845
|
+
actions: { Button: V, Command: M },
|
|
7816
7846
|
multistream: { useComfyJs: Ct },
|
|
7817
7847
|
data: { usedStorages: L },
|
|
7818
7848
|
pronouns: { Alejo: F }
|
|
7819
7849
|
};
|
|
7820
|
-
typeof window < "u" ? window.Tixyel =
|
|
7850
|
+
typeof window < "u" ? window.Tixyel = Y : globalThis.Tixyel = Y;
|
|
7821
7851
|
export {
|
|
7822
|
-
|
|
7852
|
+
Y as default
|
|
7823
7853
|
};
|
|
7824
7854
|
//# sourceMappingURL=index.es.js.map
|