@tixyel/streamelements 4.4.0 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.es.js +453 -431
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -4929,7 +4929,7 @@ var W;
|
|
|
4929
4929
|
try {
|
|
4930
4930
|
const i = await fetch("https://pronouns.alejo.io/api/pronouns").then((t) => t.json());
|
|
4931
4931
|
if (Array.isArray(i) && i.length) {
|
|
4932
|
-
const t = Object.fromEntries(i.map(({ name: n, display:
|
|
4932
|
+
const t = Object.fromEntries(i.map(({ name: n, display: r }) => [n, r]));
|
|
4933
4933
|
return { ...e.map, ...t };
|
|
4934
4934
|
}
|
|
4935
4935
|
} catch {
|
|
@@ -5001,10 +5001,10 @@ function mt(s, e = !0) {
|
|
|
5001
5001
|
function Q(s, e, a) {
|
|
5002
5002
|
s /= 255, e /= 255, a /= 255;
|
|
5003
5003
|
const o = Math.max(s, e, a), i = Math.min(s, e, a), t = o - i;
|
|
5004
|
-
let n = 0,
|
|
5005
|
-
const
|
|
5004
|
+
let n = 0, r = 0;
|
|
5005
|
+
const c = (o + i) / 2;
|
|
5006
5006
|
if (t !== 0)
|
|
5007
|
-
switch (
|
|
5007
|
+
switch (r = c > 0.5 ? t / (2 - o - i) : t / (o + i), o) {
|
|
5008
5008
|
case s:
|
|
5009
5009
|
n = ((e - a) / t + (e < a ? 6 : 0)) / 6;
|
|
5010
5010
|
break;
|
|
@@ -5017,8 +5017,8 @@ function Q(s, e, a) {
|
|
|
5017
5017
|
}
|
|
5018
5018
|
return {
|
|
5019
5019
|
h: Math.round(n * 360),
|
|
5020
|
-
s: Math.round(
|
|
5021
|
-
l: Math.round(
|
|
5020
|
+
s: Math.round(r * 100),
|
|
5021
|
+
l: Math.round(c * 100)
|
|
5022
5022
|
};
|
|
5023
5023
|
}
|
|
5024
5024
|
function ut(s, e, a) {
|
|
@@ -5027,8 +5027,8 @@ function ut(s, e, a) {
|
|
|
5027
5027
|
if (e === 0)
|
|
5028
5028
|
o = i = t = a;
|
|
5029
5029
|
else {
|
|
5030
|
-
const n = (d, l, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 0.16666666666666666 ? d + (l - d) * 6 * m : m < 0.5 ? l : m < 0.6666666666666666 ? d + (l - d) * (0.6666666666666666 - m) * 6 : d),
|
|
5031
|
-
o = n(
|
|
5030
|
+
const n = (d, l, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 0.16666666666666666 ? d + (l - d) * 6 * m : m < 0.5 ? l : m < 0.6666666666666666 ? d + (l - d) * (0.6666666666666666 - m) * 6 : d), r = a < 0.5 ? a * (1 + e) : a + e - a * e, c = 2 * a - r;
|
|
5031
|
+
o = n(c, r, s + 1 / 3), i = n(c, r, s), t = n(c, r, s - 1 / 3);
|
|
5032
5032
|
}
|
|
5033
5033
|
return {
|
|
5034
5034
|
r: Math.round(o * 255),
|
|
@@ -5040,13 +5040,13 @@ function gt(s, e, a) {
|
|
|
5040
5040
|
const o = x.data.css_color_names;
|
|
5041
5041
|
let i = o[0], t = 1 / 0;
|
|
5042
5042
|
for (const n of o) {
|
|
5043
|
-
const
|
|
5044
|
-
|
|
5045
|
-
const
|
|
5046
|
-
if (!
|
|
5047
|
-
|
|
5048
|
-
const [d, l, m] =
|
|
5049
|
-
if (
|
|
5043
|
+
const r = document.createElement("canvas");
|
|
5044
|
+
r.width = r.height = 1;
|
|
5045
|
+
const c = r.getContext("2d");
|
|
5046
|
+
if (!c) continue;
|
|
5047
|
+
c.fillStyle = n, c.fillRect(0, 0, 1, 1);
|
|
5048
|
+
const [d, l, m] = c.getImageData(0, 0, 1, 1).data, f = Math.sqrt(Math.pow(s - d, 2) + Math.pow(e - l, 2) + Math.pow(a - m, 2));
|
|
5049
|
+
if (f < t && (t = f, i = n), f === 0) break;
|
|
5050
5050
|
}
|
|
5051
5051
|
return i;
|
|
5052
5052
|
}
|
|
@@ -5073,8 +5073,8 @@ var x;
|
|
|
5073
5073
|
*/
|
|
5074
5074
|
opacity(t = 100, n = "") {
|
|
5075
5075
|
n = n.length > 7 ? n?.substring(0, 6) : n, t = t > 1 ? t / 100 : t;
|
|
5076
|
-
let
|
|
5077
|
-
return n +
|
|
5076
|
+
let r = Math.round(Math.min(Math.max(t, 0), 1) * 255).toString(16).toLowerCase().padStart(2, "0");
|
|
5077
|
+
return n + r;
|
|
5078
5078
|
},
|
|
5079
5079
|
/**
|
|
5080
5080
|
* Extract color and opacity from hex code
|
|
@@ -5087,10 +5087,10 @@ var x;
|
|
|
5087
5087
|
color: t,
|
|
5088
5088
|
opacity: 100
|
|
5089
5089
|
};
|
|
5090
|
-
var
|
|
5090
|
+
var c = t.slice(-2), n = parseInt(c, 16) / 255, r = Math.round(n * 100), c = t.length > 7 ? t.slice(0, 7) : t;
|
|
5091
5091
|
return {
|
|
5092
|
-
color:
|
|
5093
|
-
opacity:
|
|
5092
|
+
color: c,
|
|
5093
|
+
opacity: r
|
|
5094
5094
|
};
|
|
5095
5095
|
},
|
|
5096
5096
|
validate(t) {
|
|
@@ -5112,31 +5112,31 @@ var x;
|
|
|
5112
5112
|
* ```
|
|
5113
5113
|
*/
|
|
5114
5114
|
convert(t, n) {
|
|
5115
|
-
const
|
|
5116
|
-
if (!
|
|
5115
|
+
const r = this.validate(t);
|
|
5116
|
+
if (!r)
|
|
5117
5117
|
throw new Error(`Invalid color format: ${t}`);
|
|
5118
|
-
if (
|
|
5118
|
+
if (r === n)
|
|
5119
5119
|
throw new Error(`Color is already in the desired format: ${n}`);
|
|
5120
|
-
const
|
|
5121
|
-
if (!
|
|
5120
|
+
const c = lt(t.trim(), r);
|
|
5121
|
+
if (!c)
|
|
5122
5122
|
throw new Error(`Failed to parse color: ${t}`);
|
|
5123
5123
|
switch (n) {
|
|
5124
5124
|
case "hex":
|
|
5125
|
-
return mt(
|
|
5125
|
+
return mt(c, !1);
|
|
5126
5126
|
case "rgb":
|
|
5127
|
-
return `rgb(${
|
|
5127
|
+
return `rgb(${c.r}, ${c.g}, ${c.b})`;
|
|
5128
5128
|
case "rgba":
|
|
5129
|
-
return `rgba(${
|
|
5129
|
+
return `rgba(${c.r}, ${c.g}, ${c.b}, ${c.a})`;
|
|
5130
5130
|
case "hsl": {
|
|
5131
|
-
const d = Q(
|
|
5131
|
+
const d = Q(c.r, c.g, c.b);
|
|
5132
5132
|
return `hsl(${d.h}, ${d.s}%, ${d.l}%)`;
|
|
5133
5133
|
}
|
|
5134
5134
|
case "hsla": {
|
|
5135
|
-
const d = Q(
|
|
5136
|
-
return `hsla(${d.h}, ${d.s}%, ${d.l}%, ${
|
|
5135
|
+
const d = Q(c.r, c.g, c.b);
|
|
5136
|
+
return `hsla(${d.h}, ${d.s}%, ${d.l}%, ${c.a})`;
|
|
5137
5137
|
}
|
|
5138
5138
|
case "css-color-name":
|
|
5139
|
-
return gt(
|
|
5139
|
+
return gt(c.r, c.g, c.b);
|
|
5140
5140
|
default:
|
|
5141
5141
|
return null;
|
|
5142
5142
|
}
|
|
@@ -5161,24 +5161,24 @@ var x;
|
|
|
5161
5161
|
case "hex":
|
|
5162
5162
|
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
|
|
5163
5163
|
case "hexa": {
|
|
5164
|
-
const
|
|
5165
|
-
return
|
|
5164
|
+
const r = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`, c = Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
|
|
5165
|
+
return r + c;
|
|
5166
5166
|
}
|
|
5167
5167
|
case "rgb": {
|
|
5168
|
-
const
|
|
5169
|
-
return `rgb(${
|
|
5168
|
+
const r = Math.floor(Math.random() * 256), c = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256);
|
|
5169
|
+
return `rgb(${r}, ${c}, ${d})`;
|
|
5170
5170
|
}
|
|
5171
5171
|
case "rgba": {
|
|
5172
|
-
const
|
|
5173
|
-
return `rgba(${
|
|
5172
|
+
const r = Math.floor(Math.random() * 256), c = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256), l = Math.random().toFixed(2);
|
|
5173
|
+
return `rgba(${r}, ${c}, ${d}, ${l})`;
|
|
5174
5174
|
}
|
|
5175
5175
|
case "hsl": {
|
|
5176
|
-
const
|
|
5177
|
-
return `hsl(${
|
|
5176
|
+
const r = Math.floor(Math.random() * 361), c = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101);
|
|
5177
|
+
return `hsl(${r}, ${c}%, ${d}%)`;
|
|
5178
5178
|
}
|
|
5179
5179
|
case "hsla": {
|
|
5180
|
-
const
|
|
5181
|
-
return `hsla(${
|
|
5180
|
+
const r = Math.floor(Math.random() * 361), c = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101), l = Math.random().toFixed(2);
|
|
5181
|
+
return `hsla(${r}, ${c}%, ${d}%, ${l})`;
|
|
5182
5182
|
}
|
|
5183
5183
|
case "css-color-name": {
|
|
5184
5184
|
var n = s.data.css_color_names;
|
|
@@ -5201,10 +5201,10 @@ var x;
|
|
|
5201
5201
|
* console.log(floatNumber); // e.g. 3.14
|
|
5202
5202
|
* ```
|
|
5203
5203
|
*/
|
|
5204
|
-
number(t, n,
|
|
5204
|
+
number(t, n, r = 0) {
|
|
5205
5205
|
t > n && ([t, n] = [n, t]);
|
|
5206
|
-
const
|
|
5207
|
-
return
|
|
5206
|
+
const c = Math.random() * (n - t) + t;
|
|
5207
|
+
return r ? Number(c.toFixed(r)) : Math.round(c);
|
|
5208
5208
|
},
|
|
5209
5209
|
/**
|
|
5210
5210
|
* Generate random boolean
|
|
@@ -5231,10 +5231,10 @@ var x;
|
|
|
5231
5231
|
* ```
|
|
5232
5232
|
*/
|
|
5233
5233
|
string(t, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
|
|
5234
|
-
let
|
|
5235
|
-
for (let
|
|
5236
|
-
|
|
5237
|
-
return
|
|
5234
|
+
let r = "";
|
|
5235
|
+
for (let c = 0; c < t; c++)
|
|
5236
|
+
r += n.charAt(Math.floor(Math.random() * n.length));
|
|
5237
|
+
return r;
|
|
5238
5238
|
},
|
|
5239
5239
|
/**
|
|
5240
5240
|
* Pick random element from array
|
|
@@ -5278,8 +5278,8 @@ var x;
|
|
|
5278
5278
|
* ```
|
|
5279
5279
|
*/
|
|
5280
5280
|
daysOffset(t) {
|
|
5281
|
-
const
|
|
5282
|
-
return new Date(
|
|
5281
|
+
const r = Date.now() - this.number(0, t * 24 * 60 * 60 * 1e3);
|
|
5282
|
+
return new Date(r).toISOString();
|
|
5283
5283
|
},
|
|
5284
5284
|
/**
|
|
5285
5285
|
* Generate UUID v4
|
|
@@ -5311,13 +5311,13 @@ var x;
|
|
|
5311
5311
|
* console.log(result); // Output will depend on the fetched data
|
|
5312
5312
|
* ```
|
|
5313
5313
|
*/
|
|
5314
|
-
async replace(t, n,
|
|
5315
|
-
const
|
|
5314
|
+
async replace(t, n, r) {
|
|
5315
|
+
const c = [];
|
|
5316
5316
|
t.replace(n, (l, ...m) => {
|
|
5317
|
-
const
|
|
5318
|
-
return
|
|
5317
|
+
const f = typeof r == "function" ? r(l, ...m) : l;
|
|
5318
|
+
return c.push(Promise.resolve(f)), l;
|
|
5319
5319
|
});
|
|
5320
|
-
const d = await Promise.all(
|
|
5320
|
+
const d = await Promise.all(c);
|
|
5321
5321
|
return t.replace(n, () => d.shift() ?? "");
|
|
5322
5322
|
},
|
|
5323
5323
|
/**
|
|
@@ -5347,21 +5347,21 @@ var x;
|
|
|
5347
5347
|
* console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
|
|
5348
5348
|
* ```
|
|
5349
5349
|
*/
|
|
5350
|
-
compose(t, n = {},
|
|
5350
|
+
compose(t, n = {}, r = {
|
|
5351
5351
|
method: "index",
|
|
5352
5352
|
html: !1,
|
|
5353
5353
|
modifiers: {},
|
|
5354
5354
|
aliases: {}
|
|
5355
5355
|
}) {
|
|
5356
|
-
const { mergeSpanStyles:
|
|
5356
|
+
const { mergeSpanStyles: c } = s.element;
|
|
5357
5357
|
n.skip = "<br/>", n.newline = "<br/>";
|
|
5358
5358
|
const d = Object.entries(s.object.flatten(n)).reduce(
|
|
5359
|
-
(h, [
|
|
5360
|
-
if (h[
|
|
5359
|
+
(h, [u, y]) => {
|
|
5360
|
+
if (h[u] = String(y), ["username", "name", "nick", "nickname", "sender"].some((U) => u === U)) {
|
|
5361
5361
|
const U = h?.username || h?.name || h?.nick || h?.nickname || h?.sender;
|
|
5362
5362
|
h.username = h.username || U, h.usernameAt = `@${h.username}`, h.name = h.name || U, h.nick = h.nick || U, h.nickname = h.nickname || U, h.sender = h.sender || U, h.senderAt = `@${h.sender}`;
|
|
5363
5363
|
}
|
|
5364
|
-
return ["amount", "count"].some((U) =>
|
|
5364
|
+
return ["amount", "count"].some((U) => u === U) && (h.amount = String(h?.amount || h.count || y), h.count = String(h?.count || h?.amount || y)), h.currency = h.currency || window.client?.details.currency.symbol || "$", h.currencyCode = h.currencyCode || window.client?.details.currency.code || "USD", h;
|
|
5365
5365
|
},
|
|
5366
5366
|
{}
|
|
5367
5367
|
), l = {
|
|
@@ -5369,22 +5369,22 @@ var x;
|
|
|
5369
5369
|
MODIFIERS: /\[(\w+)(:[^=]+)?=([^\]]+)\]/g
|
|
5370
5370
|
};
|
|
5371
5371
|
var m = parseFloat(d?.amount ?? d?.count ?? 0);
|
|
5372
|
-
const
|
|
5373
|
-
COLOR: (h,
|
|
5374
|
-
WEIGHT: (h,
|
|
5375
|
-
BOLD: (h) =>
|
|
5376
|
-
LIGHT: (h) =>
|
|
5377
|
-
STRONG: (h) =>
|
|
5378
|
-
ITALIC: (h) =>
|
|
5379
|
-
UNDERLINE: (h) =>
|
|
5380
|
-
STRIKETHROUGH: (h) =>
|
|
5381
|
-
SUB: (h) =>
|
|
5382
|
-
SUP: (h) =>
|
|
5383
|
-
LARGER: (h) =>
|
|
5384
|
-
SMALL: (h) =>
|
|
5385
|
-
SHADOW: (h,
|
|
5386
|
-
SIZE: (h,
|
|
5387
|
-
},
|
|
5372
|
+
const f = {
|
|
5373
|
+
COLOR: (h, u) => c(u && s.color.validate(u) ? `color: ${u}` : "", h),
|
|
5374
|
+
WEIGHT: (h, u) => c(u && !isNaN(parseInt(u)) ? `font-weight: ${u}` : "", h),
|
|
5375
|
+
BOLD: (h) => c("font-weight: bold", h),
|
|
5376
|
+
LIGHT: (h) => c("font-weight: lighter", h),
|
|
5377
|
+
STRONG: (h) => c("font-weight: bolder", h),
|
|
5378
|
+
ITALIC: (h) => c("font-style: italic", h),
|
|
5379
|
+
UNDERLINE: (h) => c("text-decoration: underline", h),
|
|
5380
|
+
STRIKETHROUGH: (h) => c("text-decoration: line-through", h),
|
|
5381
|
+
SUB: (h) => c("vertical-align: sub", h),
|
|
5382
|
+
SUP: (h) => c("vertical-align: super", h),
|
|
5383
|
+
LARGER: (h) => c("font-size: larger", h),
|
|
5384
|
+
SMALL: (h) => c("font-size: smaller", h),
|
|
5385
|
+
SHADOW: (h, u) => c(`text-shadow: ${u}`, h),
|
|
5386
|
+
SIZE: (h, u) => c(u ? `font-size: ${u}` : "", h)
|
|
5387
|
+
}, b = {
|
|
5388
5388
|
...{
|
|
5389
5389
|
BT1: (h) => m > 1 ? h : "",
|
|
5390
5390
|
BT0: (h) => m > 0 ? h : "",
|
|
@@ -5394,11 +5394,11 @@ var x;
|
|
|
5394
5394
|
LOW: (h) => h.toLowerCase(),
|
|
5395
5395
|
REV: (h) => h.split("").reverse().join(""),
|
|
5396
5396
|
CAP: (h) => h.charAt(0).toUpperCase() + h.slice(1).toLowerCase(),
|
|
5397
|
-
FALLBACK: (h,
|
|
5397
|
+
FALLBACK: (h, u) => h.length ? h : u ?? h
|
|
5398
5398
|
},
|
|
5399
|
-
...
|
|
5400
|
-
...
|
|
5401
|
-
},
|
|
5399
|
+
...r?.html ? f : {},
|
|
5400
|
+
...r.modifiers ?? {}
|
|
5401
|
+
}, v = {
|
|
5402
5402
|
UPC: ["UPPERCASE", "UPPER", "UPP"],
|
|
5403
5403
|
LOW: ["LOWERCASE", "LOWER", "LWC"],
|
|
5404
5404
|
REV: ["REVERSE", "RVS"],
|
|
@@ -5419,59 +5419,59 @@ var x;
|
|
|
5419
5419
|
SMALL: ["SMALLER", "SM"],
|
|
5420
5420
|
SHADOW: ["SHADOW", "SHD"],
|
|
5421
5421
|
FALLBACK: ["FALLBACK", "FB"],
|
|
5422
|
-
...
|
|
5422
|
+
...r.aliases ?? {}
|
|
5423
5423
|
};
|
|
5424
|
-
function C(h,
|
|
5425
|
-
const U = Object.entries(
|
|
5426
|
-
return
|
|
5424
|
+
function C(h, u, y) {
|
|
5425
|
+
const U = Object.entries(v).find(([E, I]) => I.some((T) => T.toUpperCase() === u.toUpperCase()) ? !0 : E.toUpperCase() === u.toUpperCase()), D = U ? U[0] : u.toUpperCase();
|
|
5426
|
+
return b[D] ? b[D](h, typeof y == "string" ? y.trim() : null, d) : h;
|
|
5427
5427
|
}
|
|
5428
5428
|
function w(h) {
|
|
5429
|
-
let
|
|
5430
|
-
for (; (
|
|
5431
|
-
const [U, D, E, I] =
|
|
5432
|
-
|
|
5429
|
+
let u = h, y;
|
|
5430
|
+
for (; (y = l.MODIFIERS.exec(u)) !== null; ) {
|
|
5431
|
+
const [U, D, E, I] = y, T = C(w(I), D, E);
|
|
5432
|
+
u = u.replace(U, T ?? ""), l.MODIFIERS.lastIndex = 0;
|
|
5433
5433
|
}
|
|
5434
|
-
return
|
|
5434
|
+
return u;
|
|
5435
5435
|
}
|
|
5436
5436
|
function p(h) {
|
|
5437
|
-
let
|
|
5438
|
-
const
|
|
5437
|
+
let u = 0;
|
|
5438
|
+
const y = h.length;
|
|
5439
5439
|
function U(E) {
|
|
5440
5440
|
let I = "";
|
|
5441
|
-
for (;
|
|
5442
|
-
if (h[
|
|
5443
|
-
|
|
5444
|
-
else if (h[
|
|
5441
|
+
for (; u < y; )
|
|
5442
|
+
if (h[u] === "\\")
|
|
5443
|
+
u + 1 < y ? (I += h[u + 1], u += 2) : u++;
|
|
5444
|
+
else if (h[u] === "[" && (!E || E !== "["))
|
|
5445
5445
|
I += D();
|
|
5446
|
-
else if (E && h[
|
|
5447
|
-
|
|
5446
|
+
else if (E && h[u] === E) {
|
|
5447
|
+
u++;
|
|
5448
5448
|
break;
|
|
5449
5449
|
} else
|
|
5450
|
-
I += h[
|
|
5450
|
+
I += h[u++];
|
|
5451
5451
|
return I;
|
|
5452
5452
|
}
|
|
5453
5453
|
function D() {
|
|
5454
|
-
|
|
5454
|
+
u++;
|
|
5455
5455
|
let E = "";
|
|
5456
|
-
for (;
|
|
5456
|
+
for (; u < y && /[A-Za-z0-9]/.test(h[u]); ) E += h[u++];
|
|
5457
5457
|
let I = null;
|
|
5458
|
-
if (h[
|
|
5459
|
-
|
|
5460
|
-
const
|
|
5461
|
-
for (;
|
|
5462
|
-
I = h.slice(
|
|
5458
|
+
if (h[u] === ":") {
|
|
5459
|
+
u++;
|
|
5460
|
+
const S = u;
|
|
5461
|
+
for (; u < y && h[u] !== "="; ) u++;
|
|
5462
|
+
I = h.slice(S, u);
|
|
5463
5463
|
}
|
|
5464
|
-
h[
|
|
5464
|
+
h[u] === "=" && u++;
|
|
5465
5465
|
const T = U("]");
|
|
5466
5466
|
return C(T, E, I);
|
|
5467
5467
|
}
|
|
5468
5468
|
return U();
|
|
5469
5469
|
}
|
|
5470
|
-
let
|
|
5470
|
+
let k = t.replace(
|
|
5471
5471
|
l.PLACEHOLDERS,
|
|
5472
|
-
(h,
|
|
5472
|
+
(h, u) => typeof d[u] == "string" || typeof d[u] == "number" ? String(d[u]) : u ?? u
|
|
5473
5473
|
);
|
|
5474
|
-
return
|
|
5474
|
+
return k = r.method === "loop" ? w(k) : p(k), k;
|
|
5475
5475
|
}
|
|
5476
5476
|
}, s.number = {
|
|
5477
5477
|
/**
|
|
@@ -5486,11 +5486,11 @@ var x;
|
|
|
5486
5486
|
* ```
|
|
5487
5487
|
*/
|
|
5488
5488
|
translate(t, n = "cardinal") {
|
|
5489
|
-
const
|
|
5489
|
+
const r = {
|
|
5490
5490
|
single: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],
|
|
5491
5491
|
tens: ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"],
|
|
5492
5492
|
decades: ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
|
|
5493
|
-
},
|
|
5493
|
+
}, c = {
|
|
5494
5494
|
single: ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"],
|
|
5495
5495
|
tens: ["tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"],
|
|
5496
5496
|
decades: ["twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"]
|
|
@@ -5498,48 +5498,48 @@ var x;
|
|
|
5498
5498
|
if (t = Math.abs(Math.floor(t)), n === "suffix") {
|
|
5499
5499
|
const p = t % 100;
|
|
5500
5500
|
if (p >= 11 && p <= 13) return `${t}th`;
|
|
5501
|
-
const
|
|
5502
|
-
return `${t}${d[
|
|
5503
|
-
}
|
|
5504
|
-
function
|
|
5505
|
-
if (p < 10) return
|
|
5506
|
-
if (p < 20) return
|
|
5507
|
-
const h = Math.floor(p / 10),
|
|
5508
|
-
if (
|
|
5509
|
-
const
|
|
5510
|
-
return `${
|
|
5511
|
-
}
|
|
5512
|
-
function
|
|
5513
|
-
if (p === 0) return
|
|
5514
|
-
const h = Math.floor(p / 100),
|
|
5515
|
-
return h > 0 && (
|
|
5516
|
-
}
|
|
5517
|
-
if (t < 1e3) return
|
|
5518
|
-
const
|
|
5519
|
-
let
|
|
5520
|
-
for (;
|
|
5521
|
-
|
|
5501
|
+
const k = t % 10;
|
|
5502
|
+
return `${t}${d[k]}`;
|
|
5503
|
+
}
|
|
5504
|
+
function f(p, k) {
|
|
5505
|
+
if (p < 10) return k === "ordinal" ? c.single[p] : r.single[p];
|
|
5506
|
+
if (p < 20) return k === "ordinal" ? c.tens[p - 10] : r.tens[p - 10];
|
|
5507
|
+
const h = Math.floor(p / 10), u = p % 10;
|
|
5508
|
+
if (u === 0) return k === "ordinal" ? c.decades[h - 2] : r.decades[h - 2];
|
|
5509
|
+
const y = r.decades[h - 2], U = k === "ordinal" ? c.single[u] : r.single[u];
|
|
5510
|
+
return `${y}-${U}`;
|
|
5511
|
+
}
|
|
5512
|
+
function g(p, k) {
|
|
5513
|
+
if (p === 0) return k === "ordinal" ? c.single[0] : r.single[0];
|
|
5514
|
+
const h = Math.floor(p / 100), u = p % 100, y = [];
|
|
5515
|
+
return h > 0 && (k === "ordinal" && u === 0 ? y.push(`${r.single[h]} hundredth`) : y.push(`${r.single[h]} hundred`)), u > 0 && y.push(f(u, k)), y.join(" ");
|
|
5516
|
+
}
|
|
5517
|
+
if (t < 1e3) return g(t, n);
|
|
5518
|
+
const b = [];
|
|
5519
|
+
let v = t;
|
|
5520
|
+
for (; v > 0; )
|
|
5521
|
+
b.push(v % 1e3), v = Math.floor(v / 1e3);
|
|
5522
5522
|
let C = -1;
|
|
5523
|
-
for (let p = 0; p <
|
|
5523
|
+
for (let p = 0; p < b.length; p++) b[p] !== 0 && (C = p);
|
|
5524
5524
|
const w = [];
|
|
5525
|
-
for (let p =
|
|
5526
|
-
const
|
|
5527
|
-
if (
|
|
5525
|
+
for (let p = b.length - 1; p >= 0; p--) {
|
|
5526
|
+
const k = b[p];
|
|
5527
|
+
if (k === 0) continue;
|
|
5528
5528
|
const h = l[p];
|
|
5529
5529
|
if (n === "cardinal") {
|
|
5530
|
-
let
|
|
5531
|
-
h && (
|
|
5530
|
+
let u = g(k, "cardinal");
|
|
5531
|
+
h && (u += ` ${h}`), w.push(u);
|
|
5532
5532
|
} else if (p === C)
|
|
5533
5533
|
if (p > 0) {
|
|
5534
|
-
const
|
|
5535
|
-
w.push(
|
|
5534
|
+
const y = g(k, "cardinal"), U = m[p];
|
|
5535
|
+
w.push(y ? `${y} ${U}` : U);
|
|
5536
5536
|
} else {
|
|
5537
|
-
const
|
|
5538
|
-
w.push(
|
|
5537
|
+
const y = g(k, "ordinal");
|
|
5538
|
+
w.push(y);
|
|
5539
5539
|
}
|
|
5540
5540
|
else {
|
|
5541
|
-
let
|
|
5542
|
-
h && (
|
|
5541
|
+
let y = g(k, "cardinal");
|
|
5542
|
+
h && (y += ` ${h}`), w.push(y);
|
|
5543
5543
|
}
|
|
5544
5544
|
}
|
|
5545
5545
|
return w.join(", ");
|
|
@@ -5556,8 +5556,8 @@ var x;
|
|
|
5556
5556
|
* console.log(balancedValue); // 100
|
|
5557
5557
|
* ```
|
|
5558
5558
|
*/
|
|
5559
|
-
balance(t, n = 0,
|
|
5560
|
-
return Math.min(Math.max(t, n),
|
|
5559
|
+
balance(t, n = 0, r = 100) {
|
|
5560
|
+
return Math.min(Math.max(t, n), r);
|
|
5561
5561
|
}
|
|
5562
5562
|
}, s.element = {
|
|
5563
5563
|
/**
|
|
@@ -5572,10 +5572,10 @@ var x;
|
|
|
5572
5572
|
* ```
|
|
5573
5573
|
*/
|
|
5574
5574
|
mergeSpanStyles(t, n) {
|
|
5575
|
-
const
|
|
5576
|
-
if (
|
|
5577
|
-
const
|
|
5578
|
-
return `<span style="${[
|
|
5575
|
+
const r = n.match(/^<span style="([^"]*)">(.*)<\/span>$/s);
|
|
5576
|
+
if (r) {
|
|
5577
|
+
const c = r[1], d = r[2];
|
|
5578
|
+
return `<span style="${[c, t].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${d}</span>`;
|
|
5579
5579
|
} else
|
|
5580
5580
|
return `<span style="${t}">${n}</span>`;
|
|
5581
5581
|
},
|
|
@@ -5592,29 +5592,29 @@ var x;
|
|
|
5592
5592
|
* Simulation.element.scale(element, 0.5, 1, { return: false });
|
|
5593
5593
|
* ```
|
|
5594
5594
|
*/
|
|
5595
|
-
scale(t, n = 0,
|
|
5596
|
-
const { return: d = !1, parent: l, base: m } =
|
|
5597
|
-
if (!
|
|
5598
|
-
|
|
5595
|
+
scale(t, n = 0, r = 1, c) {
|
|
5596
|
+
const { return: d = !1, parent: l, base: m } = c || {}, f = l || t.parentElement || document.body;
|
|
5597
|
+
if (!f) {
|
|
5598
|
+
j.warn("No parent element found for scaling");
|
|
5599
5599
|
return;
|
|
5600
5600
|
}
|
|
5601
|
-
const
|
|
5602
|
-
if (
|
|
5603
|
-
|
|
5601
|
+
const g = f.getBoundingClientRect(), b = t.offsetWidth, v = t.offsetHeight;
|
|
5602
|
+
if (b === 0 || v === 0) {
|
|
5603
|
+
j.warn("Element has zero width or height, cannot scale");
|
|
5604
5604
|
return;
|
|
5605
5605
|
}
|
|
5606
|
-
const C =
|
|
5606
|
+
const C = g.width * r / b, w = g.height * r / v;
|
|
5607
5607
|
let p = m === "width" ? C : m === "height" ? w : Math.min(C, w);
|
|
5608
5608
|
if (n > 0) {
|
|
5609
|
-
const h =
|
|
5610
|
-
p = Math.max(
|
|
5609
|
+
const h = g.width * n / b, u = g.height * n / v, y = Math.max(h, u);
|
|
5610
|
+
p = Math.max(y, p);
|
|
5611
5611
|
}
|
|
5612
|
-
const
|
|
5613
|
-
width:
|
|
5614
|
-
height:
|
|
5612
|
+
const k = {
|
|
5613
|
+
width: b * p,
|
|
5614
|
+
height: v * p,
|
|
5615
5615
|
scale: p
|
|
5616
5616
|
};
|
|
5617
|
-
return d || (t.style.transform = `scale(${p})`, t.style.transformOrigin = "center center"),
|
|
5617
|
+
return d || (t.style.transform = `scale(${p})`, t.style.transformOrigin = "center center"), k;
|
|
5618
5618
|
},
|
|
5619
5619
|
/**
|
|
5620
5620
|
* Splits the text content of an HTML string into individual characters wrapped in span elements with a data-index attribute.
|
|
@@ -5629,31 +5629,31 @@ var x;
|
|
|
5629
5629
|
* ```
|
|
5630
5630
|
*/
|
|
5631
5631
|
splitTextToChars(t, n = 0) {
|
|
5632
|
-
const
|
|
5632
|
+
const c = new DOMParser().parseFromString(t, "text/html");
|
|
5633
5633
|
let d = n;
|
|
5634
|
-
function l(
|
|
5635
|
-
if (
|
|
5636
|
-
const
|
|
5634
|
+
function l(g) {
|
|
5635
|
+
if (g.nodeType === Node.TEXT_NODE) {
|
|
5636
|
+
const v = g.textContent?.split("").map((w) => {
|
|
5637
5637
|
const p = document.createElement("span");
|
|
5638
5638
|
return p.className = "char", p.dataset.index = String(d++), p.textContent = w, d++, p.outerHTML;
|
|
5639
5639
|
}), C = document.createElement("span");
|
|
5640
|
-
return C.innerHTML =
|
|
5641
|
-
} else if (
|
|
5642
|
-
const
|
|
5643
|
-
return
|
|
5644
|
-
const C = l(
|
|
5640
|
+
return C.innerHTML = v?.join("") ?? "", C;
|
|
5641
|
+
} else if (g.nodeType === Node.ELEMENT_NODE) {
|
|
5642
|
+
const b = g.cloneNode(!1);
|
|
5643
|
+
return g.childNodes.forEach((v) => {
|
|
5644
|
+
const C = l(v);
|
|
5645
5645
|
C instanceof Node && Array.from(C.childNodes).forEach((w) => {
|
|
5646
|
-
|
|
5646
|
+
b.appendChild(w);
|
|
5647
5647
|
});
|
|
5648
|
-
}),
|
|
5648
|
+
}), b;
|
|
5649
5649
|
}
|
|
5650
|
-
return
|
|
5650
|
+
return g.cloneNode(!0);
|
|
5651
5651
|
}
|
|
5652
|
-
const m =
|
|
5653
|
-
return m.childNodes.forEach((
|
|
5654
|
-
const
|
|
5655
|
-
|
|
5656
|
-
}),
|
|
5652
|
+
const m = c.body, f = document.createElement("div");
|
|
5653
|
+
return m.childNodes.forEach((g) => {
|
|
5654
|
+
const b = l(g);
|
|
5655
|
+
b instanceof Node && f.appendChild(b);
|
|
5656
|
+
}), f.innerHTML;
|
|
5657
5657
|
}
|
|
5658
5658
|
}, s.object = {
|
|
5659
5659
|
/**
|
|
@@ -5670,38 +5670,38 @@ var x;
|
|
|
5670
5670
|
* ```
|
|
5671
5671
|
*/
|
|
5672
5672
|
flatten(t, n = "") {
|
|
5673
|
-
const
|
|
5674
|
-
for (const
|
|
5675
|
-
if (!Object.prototype.hasOwnProperty.call(t,
|
|
5676
|
-
const d = t[
|
|
5673
|
+
const r = {};
|
|
5674
|
+
for (const c in t) {
|
|
5675
|
+
if (!Object.prototype.hasOwnProperty.call(t, c)) continue;
|
|
5676
|
+
const d = t[c], l = n ? `${n}.${c}` : c;
|
|
5677
5677
|
if (d == null) {
|
|
5678
|
-
|
|
5678
|
+
r[l] = String(d);
|
|
5679
5679
|
continue;
|
|
5680
5680
|
}
|
|
5681
5681
|
if (d instanceof Date) {
|
|
5682
|
-
|
|
5682
|
+
r[l] = d.toISOString();
|
|
5683
5683
|
continue;
|
|
5684
5684
|
}
|
|
5685
5685
|
if (d instanceof Map) {
|
|
5686
|
-
d.forEach((m,
|
|
5687
|
-
|
|
5686
|
+
d.forEach((m, f) => {
|
|
5687
|
+
r[`${l}.${f}`] = JSON.stringify(m);
|
|
5688
5688
|
});
|
|
5689
5689
|
continue;
|
|
5690
5690
|
}
|
|
5691
5691
|
if (Array.isArray(d)) {
|
|
5692
|
-
d.forEach((m,
|
|
5693
|
-
const
|
|
5694
|
-
typeof m == "object" ? Object.assign(
|
|
5692
|
+
d.forEach((m, f) => {
|
|
5693
|
+
const g = `${l}:${f}`;
|
|
5694
|
+
typeof m == "object" ? Object.assign(r, this.flatten(m, g)) : r[g] = String(m);
|
|
5695
5695
|
});
|
|
5696
5696
|
continue;
|
|
5697
5697
|
}
|
|
5698
5698
|
if (typeof d == "object") {
|
|
5699
|
-
Object.assign(
|
|
5699
|
+
Object.assign(r, this.flatten(d, l));
|
|
5700
5700
|
continue;
|
|
5701
5701
|
}
|
|
5702
|
-
|
|
5702
|
+
r[l] = String(d);
|
|
5703
5703
|
}
|
|
5704
|
-
return
|
|
5704
|
+
return r;
|
|
5705
5705
|
}
|
|
5706
5706
|
}, s.generate = {
|
|
5707
5707
|
session: {
|
|
@@ -5955,47 +5955,49 @@ var x;
|
|
|
5955
5955
|
}
|
|
5956
5956
|
};
|
|
5957
5957
|
},
|
|
5958
|
-
async get() {
|
|
5959
|
-
const
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5958
|
+
async get(t) {
|
|
5959
|
+
const n = this.available();
|
|
5960
|
+
if (t) return t;
|
|
5961
|
+
const r = (d) => {
|
|
5962
|
+
const l = (g) => {
|
|
5963
|
+
if (!g || !("amount" in g)) return [];
|
|
5964
|
+
const b = [];
|
|
5965
|
+
for (let v = 0; v < g.amount; v++)
|
|
5966
|
+
b.push(r(g.value));
|
|
5967
|
+
return b.sort((v, C) => new Date(C.createdAt).getTime() - new Date(v.createdAt).getTime());
|
|
5968
|
+
}, m = (g) => {
|
|
5969
|
+
const b = {};
|
|
5970
|
+
for (const v in g) {
|
|
5971
|
+
const C = v.replace("_type", "type");
|
|
5972
|
+
b[C] = r(g[v]);
|
|
5971
5973
|
}
|
|
5972
|
-
return
|
|
5973
|
-
},
|
|
5974
|
-
if (!
|
|
5975
|
-
switch (
|
|
5974
|
+
return b;
|
|
5975
|
+
}, f = (g) => {
|
|
5976
|
+
if (!g) return g;
|
|
5977
|
+
switch (g.type) {
|
|
5976
5978
|
case "int":
|
|
5977
|
-
return s.rand.number(
|
|
5979
|
+
return s.rand.number(g.min, g.max);
|
|
5978
5980
|
case "string":
|
|
5979
|
-
return s.rand.array(
|
|
5981
|
+
return s.rand.array(g.options)[0];
|
|
5980
5982
|
case "date":
|
|
5981
|
-
return s.rand.daysOffset(
|
|
5983
|
+
return s.rand.daysOffset(g.range);
|
|
5982
5984
|
case "array":
|
|
5983
|
-
return s.rand.array(
|
|
5985
|
+
return s.rand.array(g.options)[0];
|
|
5984
5986
|
case "recent":
|
|
5985
|
-
return
|
|
5987
|
+
return l(g);
|
|
5986
5988
|
default:
|
|
5987
|
-
return
|
|
5989
|
+
return g;
|
|
5988
5990
|
}
|
|
5989
5991
|
};
|
|
5990
|
-
return typeof
|
|
5992
|
+
return typeof d != "object" || d === null ? d : "type" in d && typeof d.type == "string" ? f(d) : m(d);
|
|
5991
5993
|
};
|
|
5992
|
-
var c = Object.entries(n
|
|
5993
|
-
(
|
|
5994
|
-
([
|
|
5994
|
+
var c = Object.entries(r(n)).reduce(
|
|
5995
|
+
(d, [l, m]) => (Object.entries(m).forEach(
|
|
5996
|
+
([f, g]) => (
|
|
5995
5997
|
//
|
|
5996
|
-
|
|
5998
|
+
d[`${l}-${f}`] = g
|
|
5997
5999
|
)
|
|
5998
|
-
),
|
|
6000
|
+
), d),
|
|
5999
6001
|
{}
|
|
6000
6002
|
);
|
|
6001
6003
|
return c;
|
|
@@ -6009,8 +6011,8 @@ var x;
|
|
|
6009
6011
|
* @param currency - The currency to be used (default is 'USD').
|
|
6010
6012
|
* @returns A Promise that resolves to the simulated onWidgetLoad event data.
|
|
6011
6013
|
*/
|
|
6012
|
-
async onWidgetLoad(t, n,
|
|
6013
|
-
const
|
|
6014
|
+
async onWidgetLoad(t, n, r = "USD") {
|
|
6015
|
+
const c = {
|
|
6014
6016
|
BRL: { code: "BRL", name: "Brazilian Real", symbol: "R$" },
|
|
6015
6017
|
USD: { code: "USD", name: "US Dollar", symbol: "$" },
|
|
6016
6018
|
EUR: { code: "EUR", name: "Euro", symbol: "€" }
|
|
@@ -6023,7 +6025,7 @@ var x;
|
|
|
6023
6025
|
providerId: "",
|
|
6024
6026
|
avatar: ""
|
|
6025
6027
|
},
|
|
6026
|
-
currency: r
|
|
6028
|
+
currency: c[r] ?? c.USD,
|
|
6027
6029
|
fieldData: t,
|
|
6028
6030
|
recents: [],
|
|
6029
6031
|
session: {
|
|
@@ -6048,94 +6050,114 @@ var x;
|
|
|
6048
6050
|
*/
|
|
6049
6051
|
async onSessionUpdate(t, n) {
|
|
6050
6052
|
if (t ??= await s.generate.session.get(), n) {
|
|
6051
|
-
const
|
|
6053
|
+
const r = (c, d) => new Date(d.createdAt).getTime() - new Date(c.createdAt).getTime();
|
|
6052
6054
|
switch (n.provider) {
|
|
6053
6055
|
case "twitch": {
|
|
6054
|
-
const
|
|
6055
|
-
switch (
|
|
6056
|
+
const c = n.data;
|
|
6057
|
+
switch (c.listener) {
|
|
6056
6058
|
case "cheer-latest": {
|
|
6057
|
-
const d =
|
|
6059
|
+
const d = c.event.amount, l = c.event.displayName ?? c.event.name, m = c.event.message;
|
|
6058
6060
|
t["cheer-latest"] = { name: l, amount: d, message: m };
|
|
6059
|
-
const
|
|
6060
|
-
if (
|
|
6061
|
-
|
|
6061
|
+
const f = (g) => {
|
|
6062
|
+
if (g === "all") {
|
|
6063
|
+
f("alltime"), f("monthly"), f("weekly"), f("session");
|
|
6062
6064
|
return;
|
|
6063
6065
|
}
|
|
6064
|
-
const
|
|
6065
|
-
|
|
6066
|
-
const
|
|
6067
|
-
w > C && (
|
|
6066
|
+
const b = t[`cheer-${g}-top-donation`];
|
|
6067
|
+
b && d > b.amount && (b.amount = d, b.name = l);
|
|
6068
|
+
const v = t[`cheer-${g}-top-donator`], C = t["cheer-recent"].filter((p) => p.name.toLowerCase() === v.name.toLowerCase()).reduce((p, k) => p + k.amount, 0), w = t["cheer-recent"].filter((p) => p.name.toLowerCase() === l.toLowerCase()).reduce((p, k) => p + k.amount, 0);
|
|
6069
|
+
w > C && (v.amount = w, v.name = l);
|
|
6068
6070
|
};
|
|
6069
|
-
|
|
6071
|
+
f("all"), t["cheer-session"].amount += d, t["cheer-week"].amount += d, t["cheer-month"].amount += d, t["cheer-total"].amount += d, t["cheer-count"].count += 1, t["cheer-goal"].amount += d, t["cheer-recent"].unshift({ name: l, amount: d, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["cheer-recent"] = (t["cheer-recent"] || []).sort(r);
|
|
6070
6072
|
break;
|
|
6071
6073
|
}
|
|
6072
6074
|
case "follower-latest": {
|
|
6073
|
-
const d =
|
|
6074
|
-
t["follower-latest"].name = d, 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: d, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["follower-recent"] = (t["follower-recent"] || []).sort(
|
|
6075
|
+
const d = c.event.displayName ?? c.event.name;
|
|
6076
|
+
t["follower-latest"].name = d, 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: d, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["follower-recent"] = (t["follower-recent"] || []).sort(r);
|
|
6075
6077
|
break;
|
|
6076
6078
|
}
|
|
6077
6079
|
case "subscriber-latest": {
|
|
6078
|
-
const d =
|
|
6079
|
-
if (t["subscriber-latest"] = { name: d, amount: l, tier: m, message:
|
|
6080
|
-
const
|
|
6080
|
+
const d = c.event.displayName ?? c.event.name, l = c.event.amount, m = c.event.tier, f = c.event.message;
|
|
6081
|
+
if (t["subscriber-latest"] = { name: d, amount: l, tier: m, message: f ?? "" }, t["subscriber-recent"].find((g) => g.name.toLowerCase() === d.toLowerCase()) ? l > 1 && (t["subscriber-resub-latest"] = { name: d, amount: l, message: f ?? "" }, t["subscriber-resub-session"].count += 1) : (t["subscriber-new-latest"] = { name: d, amount: l, message: f ?? "" }, t["subscriber-new-session"].count += 1), !(!c.event.gifted && !c.event.bulkGifted && !c.event.isCommunityGift)) if (c.event.gifted && !c.event.bulkGifted && !c.event.isCommunityGift) {
|
|
6082
|
+
const g = c.event.sender;
|
|
6081
6083
|
t["subscriber-gifted-latest"] = {
|
|
6082
6084
|
name: d,
|
|
6083
6085
|
amount: l,
|
|
6084
6086
|
tier: m,
|
|
6085
|
-
message:
|
|
6086
|
-
sender:
|
|
6087
|
-
}, t["subscriber-gifted-session"].count += 1, t["subscriber-alltime-gifter"] = { name:
|
|
6088
|
-
} else
|
|
6089
|
-
t["subscriber-session"].count += l, t["subscriber-week"].count += l, t["subscriber-month"].count += l, t["subscriber-total"].count += l, t["subscriber-goal"].amount += l, t["subscriber-points"].amount += l, t["subscriber-recent"].unshift({ name: d, amount: l, tier: m, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["subscriber-recent"] = (t["subscriber-recent"] || []).sort(
|
|
6087
|
+
message: f ?? "",
|
|
6088
|
+
sender: g
|
|
6089
|
+
}, t["subscriber-gifted-session"].count += 1, t["subscriber-alltime-gifter"] = { name: g, amount: l };
|
|
6090
|
+
} else c.event.gifted && !c.event.bulkGifted && c.event.isCommunityGift || !c.event.gifted && c.event.bulkGifted && c.event.isCommunityGift;
|
|
6091
|
+
t["subscriber-session"].count += l, t["subscriber-week"].count += l, t["subscriber-month"].count += l, t["subscriber-total"].count += l, t["subscriber-goal"].amount += l, t["subscriber-points"].amount += l, t["subscriber-recent"].unshift({ name: d, amount: l, tier: m, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["subscriber-recent"] = (t["subscriber-recent"] || []).sort(r);
|
|
6090
6092
|
break;
|
|
6091
6093
|
}
|
|
6092
6094
|
case "raid-latest": {
|
|
6093
|
-
const d =
|
|
6094
|
-
t["raid-latest"] = { name: d, amount: l }, t["raid-recent"].unshift({ name: d, amount: l, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["raid-recent"] = (t["raid-recent"] || []).sort(
|
|
6095
|
+
const d = c.event.displayName ?? c.event.name, l = c.event.amount;
|
|
6096
|
+
t["raid-latest"] = { name: d, amount: l }, t["raid-recent"].unshift({ name: d, amount: l, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["raid-recent"] = (t["raid-recent"] || []).sort(r);
|
|
6095
6097
|
break;
|
|
6096
6098
|
}
|
|
6097
6099
|
}
|
|
6098
6100
|
break;
|
|
6099
6101
|
}
|
|
6100
6102
|
case "youtube": {
|
|
6101
|
-
const
|
|
6102
|
-
switch (
|
|
6103
|
+
const c = n.data;
|
|
6104
|
+
switch (c.listener) {
|
|
6103
6105
|
case "superchat-latest": {
|
|
6104
|
-
const d =
|
|
6105
|
-
t["superchat-latest"] = {
|
|
6106
|
-
|
|
6107
|
-
|
|
6106
|
+
const d = c.event.displayName ?? c.event.name, l = c.event.amount;
|
|
6107
|
+
t["superchat-latest"] = {
|
|
6108
|
+
name: d.toLowerCase(),
|
|
6109
|
+
displayName: d,
|
|
6110
|
+
amount: l,
|
|
6111
|
+
_id: s.rand.uuid(),
|
|
6112
|
+
sessionTop: !1,
|
|
6113
|
+
type: "superchat",
|
|
6114
|
+
originalEventName: "superchat-latest",
|
|
6115
|
+
providerId: "",
|
|
6116
|
+
avatar: ""
|
|
6117
|
+
};
|
|
6118
|
+
const m = (f) => {
|
|
6119
|
+
if (f === "all") {
|
|
6108
6120
|
m("alltime"), m("monthly"), m("weekly"), m("session");
|
|
6109
6121
|
return;
|
|
6110
6122
|
}
|
|
6111
|
-
const
|
|
6112
|
-
|
|
6113
|
-
const
|
|
6114
|
-
C >
|
|
6123
|
+
const g = t[`superchat-${f}-top-donation`];
|
|
6124
|
+
g && l > g.amount && (g.amount = l, g.name = d);
|
|
6125
|
+
const b = t[`superchat-${f}-top-donator`], v = t["superchat-recent"].filter((w) => w.name.toLowerCase() === b.name.toLowerCase()).reduce((w, p) => w + p.amount, 0), C = t["superchat-recent"].filter((w) => w.name.toLowerCase() === d.toLowerCase()).reduce((w, p) => w + p.amount, 0);
|
|
6126
|
+
C > v && (b.amount = C, b.name = d);
|
|
6115
6127
|
};
|
|
6116
|
-
m("all"), t["superchat-session"].amount += l, t["superchat-week"].amount += l, t["superchat-month"].amount += l, t["superchat-total"].amount += l, t["superchat-count"].count += 1, t["superchat-goal"].amount += l, t["superchat-recent"].unshift({
|
|
6128
|
+
m("all"), t["superchat-session"].amount += l, t["superchat-week"].amount += l, t["superchat-month"].amount += l, t["superchat-total"].amount += l, t["superchat-count"].count += 1, t["superchat-goal"].amount += l, t["superchat-recent"].unshift({
|
|
6129
|
+
name: d.toLowerCase(),
|
|
6130
|
+
displayName: d,
|
|
6131
|
+
amount: l,
|
|
6132
|
+
_id: s.rand.uuid(),
|
|
6133
|
+
sessionTop: !1,
|
|
6134
|
+
type: "superchat",
|
|
6135
|
+
originalEventName: "superchat-latest",
|
|
6136
|
+
avatar: "",
|
|
6137
|
+
providerId: ""
|
|
6138
|
+
});
|
|
6117
6139
|
break;
|
|
6118
6140
|
}
|
|
6119
6141
|
}
|
|
6120
6142
|
break;
|
|
6121
6143
|
}
|
|
6122
6144
|
case "streamelements": {
|
|
6123
|
-
const
|
|
6124
|
-
switch (
|
|
6145
|
+
const c = n.data;
|
|
6146
|
+
switch (c.listener) {
|
|
6125
6147
|
case "tip-latest": {
|
|
6126
|
-
const d =
|
|
6148
|
+
const d = c.event.displayName ?? c.event.name, l = c.event.amount;
|
|
6127
6149
|
t["tip-latest"] = { name: d, amount: l };
|
|
6128
|
-
const m = (
|
|
6129
|
-
if (
|
|
6150
|
+
const m = (f) => {
|
|
6151
|
+
if (f === "all") {
|
|
6130
6152
|
m("alltime"), m("monthly"), m("weekly"), m("session");
|
|
6131
6153
|
return;
|
|
6132
6154
|
}
|
|
6133
|
-
const
|
|
6134
|
-
|
|
6135
|
-
const
|
|
6136
|
-
C >
|
|
6155
|
+
const g = t[`tip-${f}-top-donation`];
|
|
6156
|
+
g && l > g.amount && (g.amount = l, g.name = d);
|
|
6157
|
+
const b = t[`tip-${f}-top-donator`], v = t["tip-recent"].filter((w) => w.name.toLowerCase() === b.name.toLowerCase()).reduce((w, p) => w + p.amount, 0), C = t["tip-recent"].filter((w) => w.name.toLowerCase() === d.toLowerCase()).reduce((w, p) => w + p.amount, 0);
|
|
6158
|
+
C > v && (b.amount = C, b.name = d);
|
|
6137
6159
|
};
|
|
6138
|
-
m("all"), t["tip-session"].amount += l, t["tip-week"].amount += l, t["tip-month"].amount += l, t["tip-total"].amount += l, t["tip-count"].count += 1, t["tip-goal"].amount += l, t["tip-recent"].unshift({ name: d, amount: l, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["tip-recent"] = (t["tip-recent"] || []).sort(
|
|
6160
|
+
m("all"), t["tip-session"].amount += l, t["tip-week"].amount += l, t["tip-month"].amount += l, t["tip-total"].amount += l, t["tip-count"].count += 1, t["tip-goal"].amount += l, t["tip-recent"].unshift({ name: d, amount: l, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["tip-recent"] = (t["tip-recent"] || []).sort(r);
|
|
6139
6161
|
break;
|
|
6140
6162
|
}
|
|
6141
6163
|
}
|
|
@@ -6160,8 +6182,8 @@ var x;
|
|
|
6160
6182
|
* const twitchMessageEvent = await Simulation.generate.event.onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' });
|
|
6161
6183
|
* ```
|
|
6162
6184
|
*/
|
|
6163
|
-
async onEventReceived(t = "random", n = "random",
|
|
6164
|
-
const
|
|
6185
|
+
async onEventReceived(t = "random", n = "random", r = {}) {
|
|
6186
|
+
const c = {
|
|
6165
6187
|
twitch: ["message", "follower-latest", "cheer-latest", "raid-latest", "subscriber-latest"],
|
|
6166
6188
|
streamelements: ["tip-latest"],
|
|
6167
6189
|
youtube: ["message", "superchat-latest", "subscriber-latest", "sponsor-latest"],
|
|
@@ -6171,31 +6193,31 @@ var x;
|
|
|
6171
6193
|
switch (t) {
|
|
6172
6194
|
default:
|
|
6173
6195
|
case "random": {
|
|
6174
|
-
var d = s.rand.array(Object.keys(
|
|
6196
|
+
var d = s.rand.array(Object.keys(c).filter((H) => c[H].length))[0], l = s.rand.array(c[d])[0];
|
|
6175
6197
|
return this.onEventReceived(d, l);
|
|
6176
6198
|
}
|
|
6177
6199
|
case "twitch":
|
|
6178
6200
|
switch (n) {
|
|
6179
6201
|
default:
|
|
6180
6202
|
case "random": {
|
|
6181
|
-
var l = s.rand.array(
|
|
6203
|
+
var l = s.rand.array(c[t])[0];
|
|
6182
6204
|
return this.onEventReceived(t, l);
|
|
6183
6205
|
}
|
|
6184
6206
|
case "message": {
|
|
6185
|
-
var m =
|
|
6207
|
+
var m = r?.name ?? s.rand.array(s.data.names.filter((L) => L.length))[0], f = r?.message ?? s.rand.array(s.data.messages.filter((L) => L.length))[0], g = await K(r?.badges ?? [], t), b = F(f), v = B(f, b), C = r?.color ?? s.rand.color("hex"), w = r?.userId ?? s.rand.number(1e7, 99999999).toString(), p = r?.msgId ?? s.rand.uuid(), k = r?.time ?? Date.now(), h = r?.channel ?? client.details.user.username;
|
|
6186
6208
|
return {
|
|
6187
6209
|
listener: "message",
|
|
6188
6210
|
event: {
|
|
6189
6211
|
service: t,
|
|
6190
6212
|
data: {
|
|
6191
|
-
time:
|
|
6213
|
+
time: k,
|
|
6192
6214
|
tags: {
|
|
6193
|
-
"badge-info": `${
|
|
6194
|
-
badges:
|
|
6195
|
-
mod:
|
|
6196
|
-
subscriber:
|
|
6197
|
-
turbo:
|
|
6198
|
-
"tmi-sent-ts":
|
|
6215
|
+
"badge-info": `${g.keys.map((L) => `${L}/${s.rand.number(1, 5)}`).join(",")}`,
|
|
6216
|
+
badges: g.keys.join("/1,"),
|
|
6217
|
+
mod: g.keys.includes("moderator") ? "1" : "0",
|
|
6218
|
+
subscriber: g.keys.includes("subscriber") ? "1" : "0",
|
|
6219
|
+
turbo: g.keys.includes("turbo") ? "1" : "0",
|
|
6220
|
+
"tmi-sent-ts": k.toString(),
|
|
6199
6221
|
"user-id": w,
|
|
6200
6222
|
"user-type": "",
|
|
6201
6223
|
color: C,
|
|
@@ -6211,28 +6233,28 @@ var x;
|
|
|
6211
6233
|
displayName: m,
|
|
6212
6234
|
displayColor: C,
|
|
6213
6235
|
channel: h,
|
|
6214
|
-
text:
|
|
6236
|
+
text: f,
|
|
6215
6237
|
isAction: !1,
|
|
6216
6238
|
userId: w,
|
|
6217
6239
|
msgId: p,
|
|
6218
|
-
badges:
|
|
6219
|
-
emotes:
|
|
6240
|
+
badges: g.badges,
|
|
6241
|
+
emotes: b
|
|
6220
6242
|
},
|
|
6221
|
-
renderedText:
|
|
6243
|
+
renderedText: v
|
|
6222
6244
|
}
|
|
6223
6245
|
};
|
|
6224
6246
|
}
|
|
6225
6247
|
case "cheer":
|
|
6226
6248
|
case "cheer-latest": {
|
|
6227
|
-
var
|
|
6249
|
+
var u = r?.amount ?? s.rand.number(100, 1e4), y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0], f = r?.message ?? s.rand.array(s.data.messages.filter((A) => A.length))[0];
|
|
6228
6250
|
return {
|
|
6229
6251
|
listener: "cheer-latest",
|
|
6230
6252
|
event: {
|
|
6231
|
-
amount:
|
|
6232
|
-
avatar:
|
|
6253
|
+
amount: u,
|
|
6254
|
+
avatar: y,
|
|
6233
6255
|
name: m.toLowerCase(),
|
|
6234
6256
|
displayName: m,
|
|
6235
|
-
message:
|
|
6257
|
+
message: f,
|
|
6236
6258
|
providerId: "",
|
|
6237
6259
|
_id: s.rand.uuid(),
|
|
6238
6260
|
sessionTop: !1,
|
|
@@ -6244,11 +6266,11 @@ var x;
|
|
|
6244
6266
|
}
|
|
6245
6267
|
case "follower":
|
|
6246
6268
|
case "follower-latest": {
|
|
6247
|
-
var
|
|
6269
|
+
var y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
|
|
6248
6270
|
return {
|
|
6249
6271
|
listener: "follower-latest",
|
|
6250
6272
|
event: {
|
|
6251
|
-
avatar:
|
|
6273
|
+
avatar: y,
|
|
6252
6274
|
name: m.toLowerCase(),
|
|
6253
6275
|
displayName: m,
|
|
6254
6276
|
providerId: "",
|
|
@@ -6262,12 +6284,12 @@ var x;
|
|
|
6262
6284
|
}
|
|
6263
6285
|
case "raid":
|
|
6264
6286
|
case "raid-latest": {
|
|
6265
|
-
var
|
|
6287
|
+
var u = r?.amount ?? s.rand.number(1, 100), y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
|
|
6266
6288
|
return {
|
|
6267
6289
|
listener: "raid-latest",
|
|
6268
6290
|
event: {
|
|
6269
|
-
amount:
|
|
6270
|
-
avatar:
|
|
6291
|
+
amount: u,
|
|
6292
|
+
avatar: y,
|
|
6271
6293
|
name: m.toLowerCase(),
|
|
6272
6294
|
displayName: m,
|
|
6273
6295
|
providerId: "",
|
|
@@ -6281,9 +6303,9 @@ var x;
|
|
|
6281
6303
|
}
|
|
6282
6304
|
case "subscriber":
|
|
6283
6305
|
case "subscriber-latest": {
|
|
6284
|
-
var U =
|
|
6306
|
+
var U = r?.tier ?? s.rand.array(["1000", "2000", "3000", "prime"])[0], u = r?.amount ?? s.rand.number(1, 24), y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((P) => P.length))[0], D = r?.sender ?? s.rand.array(s.data.names.filter((P) => P.length && P !== m))[0], f = r?.message ?? s.rand.array(s.data.messages.filter((P) => P.length))[0], E = {
|
|
6285
6307
|
default: {
|
|
6286
|
-
avatar:
|
|
6308
|
+
avatar: y,
|
|
6287
6309
|
playedAsCommunityGift: !1
|
|
6288
6310
|
},
|
|
6289
6311
|
gift: {
|
|
@@ -6291,7 +6313,7 @@ var x;
|
|
|
6291
6313
|
gifted: !0
|
|
6292
6314
|
},
|
|
6293
6315
|
community: {
|
|
6294
|
-
message:
|
|
6316
|
+
message: f,
|
|
6295
6317
|
sender: D,
|
|
6296
6318
|
bulkGifted: !0
|
|
6297
6319
|
},
|
|
@@ -6300,11 +6322,11 @@ var x;
|
|
|
6300
6322
|
gifted: !0,
|
|
6301
6323
|
isCommunityGift: !0
|
|
6302
6324
|
}
|
|
6303
|
-
}, I = ["default", "gift", "community", "spam"], T =
|
|
6325
|
+
}, I = ["default", "gift", "community", "spam"], T = r?.subType ?? s.rand.array(I)[0];
|
|
6304
6326
|
return T = I.includes(T) ? T : "default", {
|
|
6305
6327
|
listener: "subscriber-latest",
|
|
6306
6328
|
event: {
|
|
6307
|
-
amount:
|
|
6329
|
+
amount: u,
|
|
6308
6330
|
name: m.toLowerCase(),
|
|
6309
6331
|
displayName: m,
|
|
6310
6332
|
providerId: "",
|
|
@@ -6323,7 +6345,7 @@ var x;
|
|
|
6323
6345
|
return {
|
|
6324
6346
|
listener: "delete-message",
|
|
6325
6347
|
event: {
|
|
6326
|
-
msgId:
|
|
6348
|
+
msgId: r?.id ?? s.rand.uuid(),
|
|
6327
6349
|
provider: t
|
|
6328
6350
|
}
|
|
6329
6351
|
};
|
|
@@ -6331,7 +6353,7 @@ var x;
|
|
|
6331
6353
|
return {
|
|
6332
6354
|
listener: "delete-messages",
|
|
6333
6355
|
event: {
|
|
6334
|
-
userId:
|
|
6356
|
+
userId: r?.id ?? s.rand.number(1e7, 99999999).toString(),
|
|
6335
6357
|
provider: t
|
|
6336
6358
|
}
|
|
6337
6359
|
};
|
|
@@ -6340,17 +6362,17 @@ var x;
|
|
|
6340
6362
|
switch (n) {
|
|
6341
6363
|
default:
|
|
6342
6364
|
case "random": {
|
|
6343
|
-
var l = s.rand.array(
|
|
6365
|
+
var l = s.rand.array(c[t])[0];
|
|
6344
6366
|
return this.onEventReceived(t, l);
|
|
6345
6367
|
}
|
|
6346
6368
|
case "tip":
|
|
6347
6369
|
case "tip-latest": {
|
|
6348
|
-
var
|
|
6370
|
+
var u = r?.amount ?? s.rand.number(100, 4e3), y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
|
|
6349
6371
|
return {
|
|
6350
6372
|
listener: "tip-latest",
|
|
6351
6373
|
event: {
|
|
6352
|
-
amount:
|
|
6353
|
-
avatar:
|
|
6374
|
+
amount: u,
|
|
6375
|
+
avatar: y,
|
|
6354
6376
|
name: m.toLowerCase(),
|
|
6355
6377
|
displayName: m,
|
|
6356
6378
|
providerId: "",
|
|
@@ -6367,8 +6389,8 @@ var x;
|
|
|
6367
6389
|
listener: "kvstore:update",
|
|
6368
6390
|
event: {
|
|
6369
6391
|
data: {
|
|
6370
|
-
key: `customWidget.${
|
|
6371
|
-
value:
|
|
6392
|
+
key: `customWidget.${r?.key ?? "sampleKey"}`,
|
|
6393
|
+
value: r?.value ?? "sampleValue"
|
|
6372
6394
|
},
|
|
6373
6395
|
provider: t
|
|
6374
6396
|
}
|
|
@@ -6377,19 +6399,19 @@ var x;
|
|
|
6377
6399
|
return {
|
|
6378
6400
|
listener: "bot:counter",
|
|
6379
6401
|
event: {
|
|
6380
|
-
counter:
|
|
6381
|
-
value:
|
|
6402
|
+
counter: r?.counter ?? "sampleCounter",
|
|
6403
|
+
value: r?.value ?? s.rand.number(0, 100),
|
|
6382
6404
|
provider: t
|
|
6383
6405
|
}
|
|
6384
6406
|
};
|
|
6385
6407
|
case "mute":
|
|
6386
6408
|
case "unmute":
|
|
6387
6409
|
case "alertService:toggleSound": {
|
|
6388
|
-
var
|
|
6410
|
+
var S = r?.muted ?? !client.details.overlay.muted;
|
|
6389
6411
|
return {
|
|
6390
6412
|
listener: "alertService:toggleSound",
|
|
6391
6413
|
event: {
|
|
6392
|
-
muted:
|
|
6414
|
+
muted: S,
|
|
6393
6415
|
provider: t
|
|
6394
6416
|
}
|
|
6395
6417
|
};
|
|
@@ -6407,13 +6429,13 @@ var x;
|
|
|
6407
6429
|
switch (n) {
|
|
6408
6430
|
default:
|
|
6409
6431
|
case "random": {
|
|
6410
|
-
var l = s.rand.array(
|
|
6432
|
+
var l = s.rand.array(c[t])[0];
|
|
6411
6433
|
return this.onEventReceived(t, l);
|
|
6412
6434
|
}
|
|
6413
6435
|
case "message": {
|
|
6414
|
-
var m =
|
|
6415
|
-
const
|
|
6416
|
-
var
|
|
6436
|
+
var m = r?.name ?? s.rand.array(s.data.names.filter((G) => G.length))[0], f = r?.message ?? s.rand.array(s.data.messages.filter((G) => G.length))[0];
|
|
6437
|
+
const O = await K(r?.badges ?? [], t);
|
|
6438
|
+
var b = F(f), v = B(f, b), C = r?.color ?? s.rand.color("hex"), w = r?.userId ?? s.rand.number(1e7, 99999999).toString(), p = r?.msgId ?? s.rand.uuid(), k = r?.time ?? Date.now(), y = r?.avatar ?? s.rand.array(s.data.avatars)[0], h = r?.channel ?? client.details.user.username;
|
|
6417
6439
|
return {
|
|
6418
6440
|
listener: "message",
|
|
6419
6441
|
event: {
|
|
@@ -6428,17 +6450,17 @@ var x;
|
|
|
6428
6450
|
authorChannelId: h,
|
|
6429
6451
|
publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6430
6452
|
hasDisplayContent: !0,
|
|
6431
|
-
displayMessage:
|
|
6453
|
+
displayMessage: f,
|
|
6432
6454
|
textMessageDetails: {
|
|
6433
|
-
messageText:
|
|
6455
|
+
messageText: f
|
|
6434
6456
|
}
|
|
6435
6457
|
},
|
|
6436
6458
|
authorDetails: {
|
|
6437
6459
|
channelId: h,
|
|
6438
6460
|
channelUrl: "",
|
|
6439
6461
|
displayName: m,
|
|
6440
|
-
profileImageUrl:
|
|
6441
|
-
...
|
|
6462
|
+
profileImageUrl: y,
|
|
6463
|
+
...O
|
|
6442
6464
|
},
|
|
6443
6465
|
msgId: p,
|
|
6444
6466
|
userId: w,
|
|
@@ -6446,25 +6468,25 @@ var x;
|
|
|
6446
6468
|
badges: [],
|
|
6447
6469
|
displayName: m,
|
|
6448
6470
|
isAction: !1,
|
|
6449
|
-
time:
|
|
6471
|
+
time: k,
|
|
6450
6472
|
tags: [],
|
|
6451
6473
|
displayColor: C,
|
|
6452
6474
|
channel: h,
|
|
6453
|
-
text:
|
|
6454
|
-
avatar:
|
|
6475
|
+
text: f,
|
|
6476
|
+
avatar: y,
|
|
6455
6477
|
emotes: []
|
|
6456
6478
|
},
|
|
6457
|
-
renderedText:
|
|
6479
|
+
renderedText: f
|
|
6458
6480
|
}
|
|
6459
6481
|
};
|
|
6460
6482
|
}
|
|
6461
6483
|
case "subscriber":
|
|
6462
6484
|
case "subscriber-latest": {
|
|
6463
|
-
var
|
|
6485
|
+
var y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
|
|
6464
6486
|
return {
|
|
6465
6487
|
listener: "subscriber-latest",
|
|
6466
6488
|
event: {
|
|
6467
|
-
avatar:
|
|
6489
|
+
avatar: y,
|
|
6468
6490
|
displayName: m,
|
|
6469
6491
|
name: m.toLowerCase(),
|
|
6470
6492
|
providerId: "",
|
|
@@ -6478,12 +6500,12 @@ var x;
|
|
|
6478
6500
|
}
|
|
6479
6501
|
case "superchat":
|
|
6480
6502
|
case "superchat-latest": {
|
|
6481
|
-
var
|
|
6503
|
+
var u = r?.amount ?? s.rand.number(100, 4e3), y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
|
|
6482
6504
|
return {
|
|
6483
6505
|
listener: "superchat-latest",
|
|
6484
6506
|
event: {
|
|
6485
|
-
amount:
|
|
6486
|
-
avatar:
|
|
6507
|
+
amount: u,
|
|
6508
|
+
avatar: y,
|
|
6487
6509
|
name: m.toLowerCase(),
|
|
6488
6510
|
displayName: m,
|
|
6489
6511
|
providerId: "",
|
|
@@ -6497,9 +6519,9 @@ var x;
|
|
|
6497
6519
|
}
|
|
6498
6520
|
case "sponsor":
|
|
6499
6521
|
case "sponsor-latest": {
|
|
6500
|
-
var U =
|
|
6522
|
+
var U = r?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], u = r?.amount ?? s.rand.number(1, 24), y = r?.avatar ?? s.rand.array(s.data.avatars)[0], m = r?.name ?? s.rand.array(s.data.names.filter((M) => M.length))[0], D = r?.sender ?? s.rand.array(s.data.names.filter((M) => M.length && M !== m))[0], f = r?.message ?? s.rand.array(s.data.messages.filter((M) => M.length))[0], E = {
|
|
6501
6523
|
default: {
|
|
6502
|
-
avatar:
|
|
6524
|
+
avatar: y,
|
|
6503
6525
|
playedAsCommunityGift: !1
|
|
6504
6526
|
},
|
|
6505
6527
|
gift: {
|
|
@@ -6507,7 +6529,7 @@ var x;
|
|
|
6507
6529
|
gifted: !0
|
|
6508
6530
|
},
|
|
6509
6531
|
community: {
|
|
6510
|
-
message:
|
|
6532
|
+
message: f,
|
|
6511
6533
|
sender: D,
|
|
6512
6534
|
bulkGifted: !0
|
|
6513
6535
|
},
|
|
@@ -6516,11 +6538,11 @@ var x;
|
|
|
6516
6538
|
gifted: !0,
|
|
6517
6539
|
isCommunityGift: !0
|
|
6518
6540
|
}
|
|
6519
|
-
}, I = ["default", "gift", "community", "spam"], T =
|
|
6541
|
+
}, I = ["default", "gift", "community", "spam"], T = r?.subType ?? s.rand.array(I)[0];
|
|
6520
6542
|
return T = I.includes(T) ? T : "default", {
|
|
6521
6543
|
listener: "sponsor-latest",
|
|
6522
6544
|
event: {
|
|
6523
|
-
amount:
|
|
6545
|
+
amount: u,
|
|
6524
6546
|
name: m.toLowerCase(),
|
|
6525
6547
|
displayName: m,
|
|
6526
6548
|
providerId: "",
|
|
@@ -6619,7 +6641,7 @@ var x;
|
|
|
6619
6641
|
facebook: {},
|
|
6620
6642
|
send(t, n) {
|
|
6621
6643
|
if (!s.queue) {
|
|
6622
|
-
|
|
6644
|
+
j.warn("Simulation queue is not initialized."), window.dispatchEvent(new CustomEvent(t, { detail: n }));
|
|
6623
6645
|
return;
|
|
6624
6646
|
}
|
|
6625
6647
|
switch (t) {
|
|
@@ -6657,42 +6679,42 @@ var x;
|
|
|
6657
6679
|
}
|
|
6658
6680
|
s.typedEntries = a;
|
|
6659
6681
|
function o(t) {
|
|
6660
|
-
const n = Object.values(t).reduce((l, m) => l + m, 0),
|
|
6682
|
+
const n = Object.values(t).reduce((l, m) => l + m, 0), r = a(t).sort((l, m) => m[1] - l[1]), c = Math.random() * n;
|
|
6661
6683
|
let d = 0;
|
|
6662
|
-
for (const [l, m] of
|
|
6663
|
-
if (d += m,
|
|
6684
|
+
for (const [l, m] of r)
|
|
6685
|
+
if (d += m, c < d)
|
|
6664
6686
|
return l;
|
|
6665
6687
|
}
|
|
6666
6688
|
s.probability = o;
|
|
6667
|
-
async function i(t = ["fields.json", "cf.json", "field.json", "customfields.json"], n = ["data.json", "fielddata.json", "fd.json", "DATA.json"]) {
|
|
6689
|
+
async function i(t = ["fields.json", "cf.json", "field.json", "customfields.json"], n = ["data.json", "fielddata.json", "fd.json", "DATA.json"], r) {
|
|
6668
6690
|
const c = {
|
|
6669
|
-
fields: t.find((
|
|
6691
|
+
fields: t.find((l) => {
|
|
6670
6692
|
try {
|
|
6671
|
-
return new URL("./" +
|
|
6693
|
+
return new URL("./" + l, window.location.href), !0;
|
|
6672
6694
|
} catch {
|
|
6673
6695
|
return !1;
|
|
6674
6696
|
}
|
|
6675
6697
|
}),
|
|
6676
|
-
data: n.find((
|
|
6698
|
+
data: n.find((l) => {
|
|
6677
6699
|
try {
|
|
6678
|
-
return new URL("./" +
|
|
6700
|
+
return new URL("./" + l, window.location.href), !0;
|
|
6679
6701
|
} catch {
|
|
6680
6702
|
return !1;
|
|
6681
6703
|
}
|
|
6682
6704
|
})
|
|
6683
|
-
},
|
|
6705
|
+
}, d = await fetch("./" + (c.data ?? "data.json"), {
|
|
6684
6706
|
cache: "no-store"
|
|
6685
|
-
}).then((
|
|
6707
|
+
}).then((l) => l.json()).catch(() => ({}));
|
|
6686
6708
|
await fetch("./" + (c.fields ?? "fields.json"), {
|
|
6687
6709
|
cache: "no-store"
|
|
6688
|
-
}).then((
|
|
6689
|
-
const
|
|
6690
|
-
(
|
|
6710
|
+
}).then((l) => l.json()).then(async (l) => {
|
|
6711
|
+
const m = Object.entries(l).filter(([g, { value: b }]) => b != null).reduce(
|
|
6712
|
+
(g, [b, { value: v }]) => (d && d[b] !== void 0 && (v = d[b]), g[b] = v, g),
|
|
6691
6713
|
{
|
|
6692
|
-
...
|
|
6714
|
+
...d
|
|
6693
6715
|
}
|
|
6694
|
-
),
|
|
6695
|
-
window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail:
|
|
6716
|
+
), f = await s.generate.event.onWidgetLoad(m, await s.generate.session.get(r));
|
|
6717
|
+
window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: f }));
|
|
6696
6718
|
});
|
|
6697
6719
|
}
|
|
6698
6720
|
s.start = i;
|
|
@@ -6703,10 +6725,10 @@ function F(s, e = x.data.emotes) {
|
|
|
6703
6725
|
const i = o.name;
|
|
6704
6726
|
let t = 0, n = 0;
|
|
6705
6727
|
for (; t < s.length; ) {
|
|
6706
|
-
const
|
|
6707
|
-
if (
|
|
6708
|
-
const
|
|
6709
|
-
/\s/.test(
|
|
6728
|
+
const r = s.indexOf(i, n);
|
|
6729
|
+
if (r === -1) break;
|
|
6730
|
+
const c = r > 0 ? s[r - 1] : " ", d = r + i.length < s.length ? s[r + i.length] : " ";
|
|
6731
|
+
/\s/.test(c) && /\s/.test(d) && a.push({ ...o, start: r, end: r + i.length }), n = r + 1;
|
|
6710
6732
|
}
|
|
6711
6733
|
}), a.sort((o, i) => o.start - i.start);
|
|
6712
6734
|
}
|
|
@@ -6755,7 +6777,7 @@ async function K(s = [], e = "twitch") {
|
|
|
6755
6777
|
moderator: { isChatModerator: !0 }
|
|
6756
6778
|
};
|
|
6757
6779
|
i = Object.entries(s).reduce(
|
|
6758
|
-
(n, [
|
|
6780
|
+
(n, [r]) => (r in t && Object.assign(n, t[r]), n),
|
|
6759
6781
|
{
|
|
6760
6782
|
isVerified: !1,
|
|
6761
6783
|
isChatOwner: !1,
|
|
@@ -6805,7 +6827,7 @@ async function ft() {
|
|
|
6805
6827
|
let s = localStorage.getItem("SE_API-STORE") ?? "", e = s ? JSON.parse(s) : {};
|
|
6806
6828
|
return Y.store.list = e, Y;
|
|
6807
6829
|
}
|
|
6808
|
-
class
|
|
6830
|
+
class N {
|
|
6809
6831
|
/**
|
|
6810
6832
|
* Stores registered event listeners.
|
|
6811
6833
|
*/
|
|
@@ -6858,7 +6880,7 @@ class O {
|
|
|
6858
6880
|
}
|
|
6859
6881
|
}
|
|
6860
6882
|
var _ = [];
|
|
6861
|
-
class
|
|
6883
|
+
class q extends N {
|
|
6862
6884
|
/**
|
|
6863
6885
|
* The unique identifier for the storage instance.
|
|
6864
6886
|
*/
|
|
@@ -6898,7 +6920,7 @@ class S extends O {
|
|
|
6898
6920
|
* @param value Value to add
|
|
6899
6921
|
*/
|
|
6900
6922
|
add(e, a) {
|
|
6901
|
-
this.loaded && (
|
|
6923
|
+
this.loaded && (q.setByPath(this.data, e, a), this.save(this.data));
|
|
6902
6924
|
}
|
|
6903
6925
|
/**
|
|
6904
6926
|
* Clears all data from the storage.
|
|
@@ -6924,7 +6946,7 @@ class S extends O {
|
|
|
6924
6946
|
return e === "load" && this.loaded ? (a.apply(this, [this.data]), this) : (super.on(e, a), this);
|
|
6925
6947
|
}
|
|
6926
6948
|
}
|
|
6927
|
-
class bt extends
|
|
6949
|
+
class bt extends N {
|
|
6928
6950
|
instance;
|
|
6929
6951
|
username;
|
|
6930
6952
|
password;
|
|
@@ -6941,7 +6963,7 @@ class bt extends O {
|
|
|
6941
6963
|
super(), this.username = e.username, this.password = e.password, this.channels = e.channels, this.isDebug = !!e.isDebug, this.init = !!e.init, this.emulate = a, this.load().then((o) => {
|
|
6942
6964
|
this.instance = o, this.emit("load", o), this.connect();
|
|
6943
6965
|
}).catch((o) => {
|
|
6944
|
-
|
|
6966
|
+
j.error("useComfyJs: Failed to load ComfyJS", o);
|
|
6945
6967
|
});
|
|
6946
6968
|
}
|
|
6947
6969
|
/**
|
|
@@ -6961,9 +6983,9 @@ class bt extends O {
|
|
|
6961
6983
|
*/
|
|
6962
6984
|
connect() {
|
|
6963
6985
|
this.instance.onError = (e) => {
|
|
6964
|
-
this.emit("error", e), client.debug &&
|
|
6986
|
+
this.emit("error", e), client.debug && j.error("[Client]", "ComfyJS Error:", e);
|
|
6965
6987
|
}, this.instance.onCommand = (e, a, o, i, t) => {
|
|
6966
|
-
if (this.emit("command", e, a, o, i, t), client.debug &&
|
|
6988
|
+
if (this.emit("command", e, a, o, i, t), client.debug && j.debug("[Client]", `ComfyJS Command: !${a} ${o} (User: ${e})`), this.emulate) {
|
|
6967
6989
|
const n = {
|
|
6968
6990
|
...i,
|
|
6969
6991
|
broadcaster: i.broadcaster,
|
|
@@ -6971,20 +6993,20 @@ class bt extends O {
|
|
|
6971
6993
|
vip: i.vip,
|
|
6972
6994
|
subscriber: i.subscriber,
|
|
6973
6995
|
founder: i.founder
|
|
6974
|
-
},
|
|
6996
|
+
}, r = {
|
|
6975
6997
|
name: e,
|
|
6976
6998
|
message: `!${a} ${o}`,
|
|
6977
|
-
badges: Object.entries(n).map(([
|
|
6999
|
+
badges: Object.entries(n).map(([c, d]) => d ? c : null).filter(Boolean),
|
|
6978
7000
|
color: t.userColor,
|
|
6979
7001
|
time: new Date(t.timestamp).getTime(),
|
|
6980
7002
|
userId: t.userId,
|
|
6981
7003
|
msgId: t.id,
|
|
6982
7004
|
channel: t.channel
|
|
6983
7005
|
};
|
|
6984
|
-
x.emulate.twitch.message(
|
|
7006
|
+
x.emulate.twitch.message(r);
|
|
6985
7007
|
}
|
|
6986
7008
|
}, this.instance.onChat = (e, a, o, i, t) => {
|
|
6987
|
-
if (this.emit("chat", e, a, o, i, t), client.debug &&
|
|
7009
|
+
if (this.emit("chat", e, a, o, i, t), client.debug && j.debug("[Client]", `ComfyJS Chat: ${a} (User: ${e})`), this.emulate) {
|
|
6988
7010
|
const n = {
|
|
6989
7011
|
...o,
|
|
6990
7012
|
...t.userBadges,
|
|
@@ -6997,7 +7019,7 @@ class bt extends O {
|
|
|
6997
7019
|
x.emulate.twitch.message({
|
|
6998
7020
|
name: e,
|
|
6999
7021
|
message: a,
|
|
7000
|
-
badges: Object.entries(n).map(([
|
|
7022
|
+
badges: Object.entries(n).map(([r, c]) => c ? r : null).filter(Boolean),
|
|
7001
7023
|
color: t.userColor,
|
|
7002
7024
|
time: new Date(t.timestamp).getTime(),
|
|
7003
7025
|
userId: t.userId,
|
|
@@ -7006,22 +7028,22 @@ class bt extends O {
|
|
|
7006
7028
|
});
|
|
7007
7029
|
}
|
|
7008
7030
|
}, this.instance.onWhisper = (e, a, o, i, t) => {
|
|
7009
|
-
this.emit("whisper", e, a, o, i, t), client.debug &&
|
|
7031
|
+
this.emit("whisper", e, a, o, i, t), client.debug && j.debug("[Client]", `ComfyJS Whisper: ${a} (User: ${e})`);
|
|
7010
7032
|
}, this.instance.onMessageDeleted = (e, a) => {
|
|
7011
|
-
this.emit("messageDeleted", e, a), client.debug &&
|
|
7033
|
+
this.emit("messageDeleted", e, a), client.debug && j.debug("[Client]", `ComfyJS Message Deleted: ${e}`), this.emulate && x.emulate.twitch.deleteMessage(e);
|
|
7012
7034
|
}, this.instance.onJoin = (e, a, o) => {
|
|
7013
|
-
this.emit("join", e, a, o), client.debug &&
|
|
7035
|
+
this.emit("join", e, a, o), client.debug && j.debug("[Client]", `ComfyJS Join: ${e}`);
|
|
7014
7036
|
}, this.instance.onPart = (e, a, o) => {
|
|
7015
|
-
this.emit("part", e, a, o), client.debug &&
|
|
7037
|
+
this.emit("part", e, a, o), client.debug && j.debug("[Client]", `ComfyJS Part: ${e}`);
|
|
7016
7038
|
}, this.instance.onHosted = (e, a, o, i) => {
|
|
7017
|
-
this.emit("hosted", e, a, o, i), client.debug &&
|
|
7039
|
+
this.emit("hosted", e, a, o, i), client.debug && j.debug("[Client]", `ComfyJS Hosted: ${e} (${a} viewers)`);
|
|
7018
7040
|
}, this.instance.onRaid = (e, a, o) => {
|
|
7019
|
-
this.emit("raid", e, a, o), client.debug &&
|
|
7041
|
+
this.emit("raid", e, a, o), client.debug && j.debug("[Client]", `ComfyJS Raid: ${e} (${a} viewers)`), this.emulate && x.emulate.twitch.raid({
|
|
7020
7042
|
name: e,
|
|
7021
7043
|
amount: a
|
|
7022
7044
|
});
|
|
7023
7045
|
}, this.instance.onSub = (e, a, o, i) => {
|
|
7024
|
-
if (this.emit("sub", e, a, o, i), client.debug &&
|
|
7046
|
+
if (this.emit("sub", e, a, o, i), client.debug && j.debug("[Client]", `ComfyJS Sub: ${e} (${o.plan})`), this.emulate) {
|
|
7025
7047
|
const t = o.plan === "Prime" ? "prime" : o.plan;
|
|
7026
7048
|
x.emulate.twitch.subscriber({
|
|
7027
7049
|
name: e,
|
|
@@ -7031,30 +7053,30 @@ class bt extends O {
|
|
|
7031
7053
|
});
|
|
7032
7054
|
}
|
|
7033
7055
|
}, this.instance.onResub = (e, a, o, i, t, n) => {
|
|
7034
|
-
if (this.emit("resub", e, a, o, i, t, n), client.debug &&
|
|
7035
|
-
const
|
|
7056
|
+
if (this.emit("resub", e, a, o, i, t, n), client.debug && j.debug("[Client]", `ComfyJS Resub: ${e} (${i} months)`), this.emulate) {
|
|
7057
|
+
const r = t.plan === "Prime" ? "prime" : t.plan;
|
|
7036
7058
|
x.emulate.twitch.subscriber({
|
|
7037
7059
|
name: e,
|
|
7038
7060
|
message: a,
|
|
7039
|
-
tier:
|
|
7061
|
+
tier: r,
|
|
7040
7062
|
amount: i,
|
|
7041
7063
|
subType: "default"
|
|
7042
7064
|
});
|
|
7043
7065
|
}
|
|
7044
7066
|
}, this.instance.onSubGift = (e, a, o, i, t, n) => {
|
|
7045
|
-
if (this.emit("subGift", e, a, o, i, t, n), client.debug &&
|
|
7046
|
-
const
|
|
7067
|
+
if (this.emit("subGift", e, a, o, i, t, n), client.debug && j.debug("[Client]", `ComfyJS Sub Gift: ${e} gifted ${i} subs`), this.emulate) {
|
|
7068
|
+
const r = t.plan === "Prime" ? "prime" : t.plan;
|
|
7047
7069
|
x.emulate.twitch.subscriber({
|
|
7048
7070
|
name: o,
|
|
7049
7071
|
message: "",
|
|
7050
7072
|
sender: e,
|
|
7051
|
-
tier:
|
|
7073
|
+
tier: r,
|
|
7052
7074
|
amount: i,
|
|
7053
7075
|
subType: "gift"
|
|
7054
7076
|
});
|
|
7055
7077
|
}
|
|
7056
7078
|
}, this.instance.onSubMysteryGift = (e, a, o, i, t) => {
|
|
7057
|
-
if (this.emit("subMysteryGift", e, a, o, i, t), client.debug &&
|
|
7079
|
+
if (this.emit("subMysteryGift", e, a, o, i, t), client.debug && j.debug("[Client]", `ComfyJS Sub Mystery Gift: ${e} gifted ${a} subs`), this.emulate) {
|
|
7058
7080
|
const n = i.plan === "Prime" ? "prime" : i.plan;
|
|
7059
7081
|
x.emulate.twitch.subscriber({
|
|
7060
7082
|
name: e,
|
|
@@ -7065,7 +7087,7 @@ class bt extends O {
|
|
|
7065
7087
|
});
|
|
7066
7088
|
}
|
|
7067
7089
|
}, this.instance.onGiftSubContinue = (e, a, o) => {
|
|
7068
|
-
this.emit("giftSubContinue", e, a, o), client.debug &&
|
|
7090
|
+
this.emit("giftSubContinue", e, a, o), client.debug && j.debug("[Client]", `ComfyJS Gift Sub Continue: ${e} continued their gifted sub from ${a}`), this.emulate && x.emulate.twitch.subscriber({
|
|
7069
7091
|
name: e,
|
|
7070
7092
|
message: "",
|
|
7071
7093
|
sender: a,
|
|
@@ -7073,23 +7095,23 @@ class bt extends O {
|
|
|
7073
7095
|
subType: "gift"
|
|
7074
7096
|
});
|
|
7075
7097
|
}, this.instance.onCheer = (e, a, o, i, t) => {
|
|
7076
|
-
this.emit("cheer", e, a, o, i, t), client.debug &&
|
|
7098
|
+
this.emit("cheer", e, a, o, i, t), client.debug && j.debug("[Client]", `ComfyJS Cheer: ${e} cheered ${o} bits - ${a}`), this.emulate && x.emulate.twitch.cheer({
|
|
7077
7099
|
name: e,
|
|
7078
7100
|
message: a,
|
|
7079
7101
|
amount: o
|
|
7080
7102
|
});
|
|
7081
7103
|
}, this.instance.onChatMode = (e, a) => {
|
|
7082
|
-
this.emit("chatMode", e, a), client.debug &&
|
|
7104
|
+
this.emit("chatMode", e, a), client.debug && j.debug("[Client]", `ComfyJS Chat Mode Changed on ${a}`);
|
|
7083
7105
|
}, this.instance.onReward = (e, a, o, i, t) => {
|
|
7084
|
-
this.emit("reward", e, a, o, i, t), client.debug &&
|
|
7106
|
+
this.emit("reward", e, a, o, i, t), client.debug && j.debug("[Client]", `ComfyJS Reward: ${e} redeemed ${a} for ${o} - ${i}`);
|
|
7085
7107
|
}, this.instance.onConnected = (e, a, o) => {
|
|
7086
|
-
this.emit("connected", e, a, o), client.debug &&
|
|
7108
|
+
this.emit("connected", e, a, o), client.debug && j.debug("[Client]", `ComfyJS Connected: ${e}:${a} (First Connect: ${o})`);
|
|
7087
7109
|
}, this.instance.onReconnect = (e) => {
|
|
7088
|
-
this.emit("reconnect", e), client.debug &&
|
|
7110
|
+
this.emit("reconnect", e), client.debug && j.debug("[Client]", `ComfyJS Reconnect: Attempt #${e}`);
|
|
7089
7111
|
}, this.init && this.instance.Init(this.username, this.password, this.channels, this.isDebug);
|
|
7090
7112
|
}
|
|
7091
7113
|
}
|
|
7092
|
-
class J extends
|
|
7114
|
+
class J extends N {
|
|
7093
7115
|
id = "default";
|
|
7094
7116
|
debug = !1;
|
|
7095
7117
|
storage;
|
|
@@ -7097,7 +7119,7 @@ class J extends O {
|
|
|
7097
7119
|
session;
|
|
7098
7120
|
loaded = !1;
|
|
7099
7121
|
constructor(e) {
|
|
7100
|
-
super(), this.id = e.id || this.id, this.storage = new
|
|
7122
|
+
super(), this.id = e.id || this.id, this.storage = new q({
|
|
7101
7123
|
id: this.id,
|
|
7102
7124
|
data: {
|
|
7103
7125
|
user: {},
|
|
@@ -7155,34 +7177,34 @@ class R {
|
|
|
7155
7177
|
run(e, a) {
|
|
7156
7178
|
}
|
|
7157
7179
|
verify(e, a, o) {
|
|
7158
|
-
return this.arguments === !0 && (!o || !o.length) ? !1 : this.admins.some((i) => e.toLocaleLowerCase() === i.toLocaleLowerCase())
|
|
7180
|
+
return this.arguments === !0 && (!o || !o.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() || a.map((t) => t.toLowerCase()).includes(i.toLowerCase())) || this.permissions.includes("*")));
|
|
7159
7181
|
}
|
|
7160
7182
|
parse(e, a) {
|
|
7161
7183
|
if (!(window.client instanceof J)) return !1;
|
|
7162
|
-
const o = e.replace(this.prefix, "").split(" ").slice(1).map((
|
|
7184
|
+
const o = e.replace(this.prefix, "").split(" ").slice(1).map((c) => c.trim());
|
|
7163
7185
|
var i = "", t = [];
|
|
7164
7186
|
const n = { bits: "cheer", premium: "prime" };
|
|
7165
7187
|
switch (a.provider) {
|
|
7166
7188
|
case "twitch": {
|
|
7167
|
-
const
|
|
7168
|
-
i =
|
|
7189
|
+
const c = a.data;
|
|
7190
|
+
i = c.event.data.nick || c.event.data.displayName, c.event.data.tags?.badges && (t = c.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((l) => l in n ? n[l] : l));
|
|
7169
7191
|
break;
|
|
7170
7192
|
}
|
|
7171
7193
|
case "youtube": {
|
|
7172
|
-
const
|
|
7194
|
+
const c = a.data, d = {
|
|
7173
7195
|
isVerified: "verified",
|
|
7174
7196
|
isChatOwner: "owner",
|
|
7175
7197
|
isChatSponsor: "sponsor",
|
|
7176
7198
|
isChatModerator: "moderator"
|
|
7177
7199
|
};
|
|
7178
|
-
i =
|
|
7200
|
+
i = c.event.data.nick || c.event.data.displayName, t = Object.entries(c.event.data.authorDetails).filter(([l, m]) => l.startsWith("is") && m).map(([l]) => d[l]).filter(Boolean);
|
|
7179
7201
|
break;
|
|
7180
7202
|
}
|
|
7181
7203
|
case "kick":
|
|
7182
7204
|
return !1;
|
|
7183
7205
|
}
|
|
7184
|
-
const
|
|
7185
|
-
return
|
|
7206
|
+
const r = this.verify(i, t, o);
|
|
7207
|
+
return r === !0 && this.run.apply(window.client, [o, a]), r;
|
|
7186
7208
|
}
|
|
7187
7209
|
remove() {
|
|
7188
7210
|
if (!(window.client instanceof J)) return;
|
|
@@ -7200,7 +7222,7 @@ class R {
|
|
|
7200
7222
|
});
|
|
7201
7223
|
if (o.length && o.every((i) => i instanceof R))
|
|
7202
7224
|
return o.forEach((i) => {
|
|
7203
|
-
i.parse(a.event.data.text, e), window.client.emit("action", i, "executed"),
|
|
7225
|
+
i.parse(a.event.data.text, e), window.client.emit("action", i, "executed"), j.received(`Command executed: ${a.event.data.text} by ${a.event.data.nick || a.event.data.displayName}`, a);
|
|
7204
7226
|
}), !0;
|
|
7205
7227
|
}
|
|
7206
7228
|
} catch {
|
|
@@ -7210,7 +7232,7 @@ class R {
|
|
|
7210
7232
|
}
|
|
7211
7233
|
}
|
|
7212
7234
|
}
|
|
7213
|
-
class Z extends
|
|
7235
|
+
class Z extends N {
|
|
7214
7236
|
queue = [];
|
|
7215
7237
|
priorityQueue = [];
|
|
7216
7238
|
history = [];
|
|
@@ -7254,7 +7276,7 @@ class Z extends O {
|
|
|
7254
7276
|
try {
|
|
7255
7277
|
await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
|
|
7256
7278
|
} catch (o) {
|
|
7257
|
-
|
|
7279
|
+
j.error(`Error during item processing: ${o instanceof Error ? o.message : String(o)}`);
|
|
7258
7280
|
}
|
|
7259
7281
|
this.history.push(e);
|
|
7260
7282
|
const a = e.isPriority ? this.priorityQueue : this.queue;
|
|
@@ -7276,7 +7298,7 @@ class Z extends O {
|
|
|
7276
7298
|
return e === "load" && this.loaded ? (a.apply(this), this) : (super.on(e, a), this);
|
|
7277
7299
|
}
|
|
7278
7300
|
}
|
|
7279
|
-
class
|
|
7301
|
+
class V {
|
|
7280
7302
|
field = "button";
|
|
7281
7303
|
template = "button";
|
|
7282
7304
|
run;
|
|
@@ -7302,12 +7324,12 @@ class q {
|
|
|
7302
7324
|
if (!(window.client instanceof J)) return !1;
|
|
7303
7325
|
if (window.client.actions.buttons.length) {
|
|
7304
7326
|
const o = window.client.actions.buttons.filter((i) => typeof i.field == "string" ? i.field === e : typeof i.field == "function" ? i.field(e, a) : !1);
|
|
7305
|
-
if (o.length && o.every((i) => i instanceof
|
|
7327
|
+
if (o.length && o.every((i) => i instanceof V))
|
|
7306
7328
|
return o.forEach((i) => {
|
|
7307
7329
|
try {
|
|
7308
|
-
i.parse(e, a), window.client.emit("action", i, "executed"),
|
|
7330
|
+
i.parse(e, a), window.client.emit("action", i, "executed"), j.received(`Button executed: ${e}${a ? ` with value: ${a}` : ""}`);
|
|
7309
7331
|
} catch (t) {
|
|
7310
|
-
|
|
7332
|
+
j.error(`Error executing button "${e}": ${t instanceof Error ? t.message : t}`);
|
|
7311
7333
|
}
|
|
7312
7334
|
}), !0;
|
|
7313
7335
|
}
|
|
@@ -7394,13 +7416,13 @@ class $ {
|
|
|
7394
7416
|
const a = this.style(e), o = e.icon ? `${e.icon} ` : "";
|
|
7395
7417
|
return (...i) => {
|
|
7396
7418
|
if (!this.enabled || typeof console > "u") return;
|
|
7397
|
-
const t = this.prefix ? `${this.prefix} ` : "", n = [],
|
|
7398
|
-
if (i.forEach((
|
|
7399
|
-
typeof
|
|
7419
|
+
const t = this.prefix ? `${this.prefix} ` : "", n = [], r = [];
|
|
7420
|
+
if (i.forEach((c) => {
|
|
7421
|
+
typeof c == "string" || typeof c == "number" || typeof c == "boolean" ? n.push(c) : r.push(c);
|
|
7400
7422
|
}), n.length > 0) {
|
|
7401
|
-
const
|
|
7402
|
-
console.log(`%c${o}${t}${
|
|
7403
|
-
} else
|
|
7423
|
+
const c = n.join(" ");
|
|
7424
|
+
console.log(`%c${o}${t}${c}`, a, ...r);
|
|
7425
|
+
} else r.length > 0 && console.log(`%c${o}${t}`, a, ...r);
|
|
7404
7426
|
};
|
|
7405
7427
|
}
|
|
7406
7428
|
style(e) {
|
|
@@ -7453,21 +7475,21 @@ window.addEventListener("onWidgetLoad", async (s) => {
|
|
|
7453
7475
|
}).catch(() => {
|
|
7454
7476
|
a.details.provider = "local";
|
|
7455
7477
|
}) : a.details.provider = "local", a.emit("load", e), a.loaded = !0, a.storage.on("load", (o) => {
|
|
7456
|
-
if (a.debug && o ?
|
|
7478
|
+
if (a.debug && o ? j.debug("[Client]", "Storage loaded for client", `"${a.id}";`, `Provider: "${a.details.provider}";`, o) : a.debug && j.debug("[Client]", "Storage loaded for client", `"${a.id}";`, `Provider: "${a.details.provider}";`, "No data found."), o) {
|
|
7457
7479
|
const i = (d) => {
|
|
7458
7480
|
const l = Date.now(), m = {};
|
|
7459
|
-
for (const
|
|
7460
|
-
if (d.hasOwnProperty(
|
|
7461
|
-
const
|
|
7462
|
-
|
|
7481
|
+
for (const f in d)
|
|
7482
|
+
if (d.hasOwnProperty(f)) {
|
|
7483
|
+
const g = d[f];
|
|
7484
|
+
g.expire && g.expire > l && (m[f] = g);
|
|
7463
7485
|
}
|
|
7464
7486
|
return m;
|
|
7465
|
-
}, t = i(o.user || {}), n = i(o.avatar || {}),
|
|
7487
|
+
}, t = i(o.user || {}), n = i(o.avatar || {}), r = i(o.pronoun || {}), c = i(o.emote || {});
|
|
7466
7488
|
a.storage.update({
|
|
7467
7489
|
user: t,
|
|
7468
7490
|
avatar: n,
|
|
7469
|
-
pronoun:
|
|
7470
|
-
emote:
|
|
7491
|
+
pronoun: r,
|
|
7492
|
+
emote: c
|
|
7471
7493
|
});
|
|
7472
7494
|
}
|
|
7473
7495
|
e.channel.providerId.length && a.storage.add(`avatar.${e.channel.providerId.toLowerCase()}`, {
|
|
@@ -7482,7 +7504,7 @@ window.addEventListener("onSessionUpdate", (s) => {
|
|
|
7482
7504
|
const { detail: e } = s;
|
|
7483
7505
|
if (window.client instanceof J) {
|
|
7484
7506
|
const a = window.client;
|
|
7485
|
-
a.session = e.session, a.emit("session", e.session), a.debug &&
|
|
7507
|
+
a.session = e.session, a.emit("session", e.session), a.debug && j.debug("[Client]", "Session updated", e.session);
|
|
7486
7508
|
}
|
|
7487
7509
|
});
|
|
7488
7510
|
function X(s) {
|
|
@@ -7515,7 +7537,7 @@ window.addEventListener("onEventReceived", ({ detail: s }) => {
|
|
|
7515
7537
|
switch (i.event.listener) {
|
|
7516
7538
|
case "widget-button": {
|
|
7517
7539
|
const t = i.event;
|
|
7518
|
-
|
|
7540
|
+
V.execute(t.field, t.value);
|
|
7519
7541
|
break;
|
|
7520
7542
|
}
|
|
7521
7543
|
case "subscriber-latest": {
|
|
@@ -7621,14 +7643,14 @@ window.addEventListener("onEventReceived", ({ detail: s }) => {
|
|
|
7621
7643
|
"event:test",
|
|
7622
7644
|
"kvstore:update"
|
|
7623
7645
|
];
|
|
7624
|
-
client.debug && !o.some((i) => i === a.data.listener) &&
|
|
7646
|
+
client.debug && !o.some((i) => i === a.data.listener) && j.received("[Client]", `Event ${a.data.listener} received from ${a.provider}`, a.data.event);
|
|
7625
7647
|
}
|
|
7626
7648
|
});
|
|
7627
|
-
const tt = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(ft()),
|
|
7649
|
+
const tt = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(ft()), j = new $(), yt = {
|
|
7628
7650
|
Client: J,
|
|
7629
7651
|
USE_SE_API: tt,
|
|
7630
7652
|
Simulation: x,
|
|
7631
|
-
logger:
|
|
7653
|
+
logger: j,
|
|
7632
7654
|
Alejo: W,
|
|
7633
7655
|
utils: {
|
|
7634
7656
|
findEmotesInText: F,
|
|
@@ -7638,11 +7660,11 @@ const tt = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(ft())
|
|
|
7638
7660
|
parseProvider: X
|
|
7639
7661
|
},
|
|
7640
7662
|
modules: {
|
|
7641
|
-
Button:
|
|
7663
|
+
Button: V,
|
|
7642
7664
|
Command: R,
|
|
7643
|
-
EventProvider:
|
|
7665
|
+
EventProvider: N,
|
|
7644
7666
|
useComfyJs: bt,
|
|
7645
|
-
useStorage:
|
|
7667
|
+
useStorage: q,
|
|
7646
7668
|
useQueue: Z,
|
|
7647
7669
|
Logger: $
|
|
7648
7670
|
},
|
|
@@ -7654,6 +7676,6 @@ typeof window < "u" && (window.Tixyel = yt);
|
|
|
7654
7676
|
export {
|
|
7655
7677
|
yt as Tixyel,
|
|
7656
7678
|
tt as USE_SE_API,
|
|
7657
|
-
|
|
7679
|
+
j as logger
|
|
7658
7680
|
};
|
|
7659
7681
|
//# sourceMappingURL=index.es.js.map
|