@tixyel/streamelements 3.6.0 → 3.7.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 +34 -2
- package/dist/index.es.js +390 -336
- 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
|
@@ -1448,7 +1448,7 @@ const X = [
|
|
|
1448
1448
|
}
|
|
1449
1449
|
}
|
|
1450
1450
|
]).reduce(
|
|
1451
|
-
(s, a) => (s.some((
|
|
1451
|
+
(s, a) => (s.some((n) => n.name === a.name) || s.push({
|
|
1452
1452
|
...a,
|
|
1453
1453
|
start: 0,
|
|
1454
1454
|
end: 0
|
|
@@ -4917,110 +4917,140 @@ const X = [
|
|
|
4917
4917
|
index: 121
|
|
4918
4918
|
}
|
|
4919
4919
|
];
|
|
4920
|
-
var
|
|
4920
|
+
var R;
|
|
4921
4921
|
((s) => {
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
})(
|
|
4922
|
+
let a;
|
|
4923
|
+
((t) => {
|
|
4924
|
+
((e) => {
|
|
4925
|
+
e.hehim = "He/Him", e.sheher = "She/Her", e.theythem = "They/Them", e.shethem = "She/They", e.hethem = "He/They", e.heshe = "He/She", e.xexem = "Xe/Xem", e.faefaer = "Fae/Faer", e.vever = "Ve/Ver", e.aeaer = "Ae/Aer", e.ziehir = "Zie/Hir", e.perper = "Per/Per", e.eem = "E/Em", e.itits = "It/Its";
|
|
4926
|
+
})(t.map || (t.map = {}));
|
|
4927
|
+
})(a = s.Pronouns || (s.Pronouns = {}));
|
|
4928
|
+
async function n() {
|
|
4929
|
+
try {
|
|
4930
|
+
const t = await fetch("https://pronouns.alejo.io/api/pronouns").then((e) => e.json());
|
|
4931
|
+
if (Array.isArray(t) && t.length) {
|
|
4932
|
+
const e = Object.fromEntries(t.map(({ name: i, display: r }) => [i, r]));
|
|
4933
|
+
return { ...a.map, ...e };
|
|
4934
|
+
}
|
|
4935
|
+
} catch {
|
|
4936
|
+
}
|
|
4937
|
+
return { ...a.map };
|
|
4938
|
+
}
|
|
4939
|
+
s.list = n;
|
|
4940
|
+
async function o(t) {
|
|
4941
|
+
if (!t) throw new Error("Username is required to fetch Alejo data.");
|
|
4942
|
+
if (t = t.toLowerCase(), t in client.storage.data.pronoun && client.storage.data.pronoun[t].expire > Date.now())
|
|
4943
|
+
return client.storage.data.pronoun[t].value;
|
|
4944
|
+
try {
|
|
4945
|
+
const e = await fetch(`https://pronouns.alejo.io/api/users/${t}`).then((i) => i.json()).then(([i]) => i);
|
|
4946
|
+
if (e)
|
|
4947
|
+
return client.storage.add(`pronoun.${t}`, {
|
|
4948
|
+
value: e.pronoun_id,
|
|
4949
|
+
timestamp: Date.now(),
|
|
4950
|
+
expire: Date.now() + client.cache.pronoun * 60 * 1e3
|
|
4951
|
+
}), client.storage.data.pronoun[t].value ?? e.pronoun_id;
|
|
4952
|
+
} catch (e) {
|
|
4953
|
+
throw new Error(`Failed to fetch pronoun data for user "${t}": ${e instanceof Error ? e.message : e}`);
|
|
4954
|
+
}
|
|
4955
|
+
}
|
|
4956
|
+
s.get = o;
|
|
4957
|
+
})(R || (R = {}));
|
|
4928
4958
|
function rt(s, a) {
|
|
4929
4959
|
if (!a) return null;
|
|
4930
4960
|
switch (a) {
|
|
4931
4961
|
case "hex": {
|
|
4932
|
-
const
|
|
4933
|
-
let
|
|
4934
|
-
return
|
|
4962
|
+
const n = s.replace("#", "");
|
|
4963
|
+
let o = 0, t = 0, e = 0, i = 1;
|
|
4964
|
+
return n.length === 3 ? (o = parseInt(n[0] + n[0], 16), t = parseInt(n[1] + n[1], 16), e = parseInt(n[2] + n[2], 16)) : n.length === 6 ? (o = parseInt(n.slice(0, 2), 16), t = parseInt(n.slice(2, 4), 16), e = parseInt(n.slice(4, 6), 16)) : n.length === 4 ? (o = parseInt(n[0] + n[0], 16), t = parseInt(n[1] + n[1], 16), e = parseInt(n[2] + n[2], 16), i = parseInt(n[3] + n[3], 16) / 255) : n.length === 8 && (o = parseInt(n.slice(0, 2), 16), t = parseInt(n.slice(2, 4), 16), e = parseInt(n.slice(4, 6), 16), i = parseInt(n.slice(6, 8), 16) / 255), { r: o, g: t, b: e, a: i };
|
|
4935
4965
|
}
|
|
4936
4966
|
case "rgb":
|
|
4937
4967
|
case "rgba": {
|
|
4938
|
-
const
|
|
4939
|
-
return
|
|
4940
|
-
r: parseInt(
|
|
4941
|
-
g: parseInt(
|
|
4942
|
-
b: parseInt(
|
|
4943
|
-
a:
|
|
4968
|
+
const n = s.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);
|
|
4969
|
+
return n ? {
|
|
4970
|
+
r: parseInt(n[1]),
|
|
4971
|
+
g: parseInt(n[2]),
|
|
4972
|
+
b: parseInt(n[3]),
|
|
4973
|
+
a: n[4] ? parseFloat(n[4]) : 1
|
|
4944
4974
|
} : null;
|
|
4945
4975
|
}
|
|
4946
4976
|
case "hsl":
|
|
4947
4977
|
case "hsla": {
|
|
4948
|
-
const
|
|
4949
|
-
if (!
|
|
4950
|
-
const
|
|
4951
|
-
return { ...ot(
|
|
4978
|
+
const n = s.match(/hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*([\d.]+))?\s*\)/);
|
|
4979
|
+
if (!n) return null;
|
|
4980
|
+
const o = parseInt(n[1]), t = parseInt(n[2]), e = parseInt(n[3]), i = n[4] ? parseFloat(n[4]) : 1;
|
|
4981
|
+
return { ...ot(o, t, e), a: i };
|
|
4952
4982
|
}
|
|
4953
4983
|
case "css-color-name": {
|
|
4954
|
-
const
|
|
4955
|
-
|
|
4956
|
-
const
|
|
4957
|
-
if (!
|
|
4958
|
-
|
|
4959
|
-
const [t, e,
|
|
4960
|
-
return { r: t, g: e, b:
|
|
4984
|
+
const n = document.createElement("canvas");
|
|
4985
|
+
n.width = n.height = 1;
|
|
4986
|
+
const o = n.getContext("2d");
|
|
4987
|
+
if (!o) return null;
|
|
4988
|
+
o.fillStyle = s, o.fillRect(0, 0, 1, 1);
|
|
4989
|
+
const [t, e, i] = o.getImageData(0, 0, 1, 1).data;
|
|
4990
|
+
return { r: t, g: e, b: i, a: 1 };
|
|
4961
4991
|
}
|
|
4962
4992
|
default:
|
|
4963
4993
|
return null;
|
|
4964
4994
|
}
|
|
4965
4995
|
}
|
|
4966
4996
|
function ct(s, a = !0) {
|
|
4967
|
-
const
|
|
4968
|
-
let
|
|
4969
|
-
return a && s.a < 1 && (
|
|
4997
|
+
const n = (t) => Math.round(t).toString(16).padStart(2, "0");
|
|
4998
|
+
let o = `#${n(s.r)}${n(s.g)}${n(s.b)}`;
|
|
4999
|
+
return a && s.a < 1 && (o += n(s.a * 255)), o;
|
|
4970
5000
|
}
|
|
4971
|
-
function F(s, a,
|
|
4972
|
-
s /= 255, a /= 255,
|
|
4973
|
-
const
|
|
4974
|
-
let
|
|
4975
|
-
const
|
|
5001
|
+
function F(s, a, n) {
|
|
5002
|
+
s /= 255, a /= 255, n /= 255;
|
|
5003
|
+
const o = Math.max(s, a, n), t = Math.min(s, a, n), e = o - t;
|
|
5004
|
+
let i = 0, r = 0;
|
|
5005
|
+
const d = (o + t) / 2;
|
|
4976
5006
|
if (e !== 0)
|
|
4977
|
-
switch (r =
|
|
5007
|
+
switch (r = d > 0.5 ? e / (2 - o - t) : e / (o + t), o) {
|
|
4978
5008
|
case s:
|
|
4979
|
-
|
|
5009
|
+
i = ((a - n) / e + (a < n ? 6 : 0)) / 6;
|
|
4980
5010
|
break;
|
|
4981
5011
|
case a:
|
|
4982
|
-
|
|
5012
|
+
i = ((n - s) / e + 2) / 6;
|
|
4983
5013
|
break;
|
|
4984
|
-
case
|
|
4985
|
-
|
|
5014
|
+
case n:
|
|
5015
|
+
i = ((s - a) / e + 4) / 6;
|
|
4986
5016
|
break;
|
|
4987
5017
|
}
|
|
4988
5018
|
return {
|
|
4989
|
-
h: Math.round(
|
|
5019
|
+
h: Math.round(i * 360),
|
|
4990
5020
|
s: Math.round(r * 100),
|
|
4991
|
-
l: Math.round(
|
|
5021
|
+
l: Math.round(d * 100)
|
|
4992
5022
|
};
|
|
4993
5023
|
}
|
|
4994
|
-
function ot(s, a,
|
|
4995
|
-
s /= 360, a /= 100,
|
|
4996
|
-
let
|
|
5024
|
+
function ot(s, a, n) {
|
|
5025
|
+
s /= 360, a /= 100, n /= 100;
|
|
5026
|
+
let o, t, e;
|
|
4997
5027
|
if (a === 0)
|
|
4998
|
-
|
|
5028
|
+
o = t = e = n;
|
|
4999
5029
|
else {
|
|
5000
|
-
const
|
|
5001
|
-
|
|
5030
|
+
const i = (u, h, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 0.16666666666666666 ? u + (h - u) * 6 * m : m < 0.5 ? h : m < 0.6666666666666666 ? u + (h - u) * (0.6666666666666666 - m) * 6 : u), r = n < 0.5 ? n * (1 + a) : n + a - n * a, d = 2 * n - r;
|
|
5031
|
+
o = i(d, r, s + 1 / 3), t = i(d, r, s), e = i(d, r, s - 1 / 3);
|
|
5002
5032
|
}
|
|
5003
5033
|
return {
|
|
5004
|
-
r: Math.round(
|
|
5034
|
+
r: Math.round(o * 255),
|
|
5005
5035
|
g: Math.round(t * 255),
|
|
5006
5036
|
b: Math.round(e * 255)
|
|
5007
5037
|
};
|
|
5008
5038
|
}
|
|
5009
|
-
function dt(s, a,
|
|
5010
|
-
const
|
|
5011
|
-
let t =
|
|
5012
|
-
for (const
|
|
5039
|
+
function dt(s, a, n) {
|
|
5040
|
+
const o = T.data.css_color_names;
|
|
5041
|
+
let t = o[0], e = 1 / 0;
|
|
5042
|
+
for (const i of o) {
|
|
5013
5043
|
const r = document.createElement("canvas");
|
|
5014
5044
|
r.width = r.height = 1;
|
|
5015
|
-
const
|
|
5016
|
-
if (!
|
|
5017
|
-
|
|
5018
|
-
const [u, h, m] =
|
|
5019
|
-
if (g < e && (e = g, t =
|
|
5045
|
+
const d = r.getContext("2d");
|
|
5046
|
+
if (!d) continue;
|
|
5047
|
+
d.fillStyle = i, d.fillRect(0, 0, 1, 1);
|
|
5048
|
+
const [u, h, m] = d.getImageData(0, 0, 1, 1).data, g = Math.sqrt(Math.pow(s - u, 2) + Math.pow(a - h, 2) + Math.pow(n - m, 2));
|
|
5049
|
+
if (g < e && (e = g, t = i), g === 0) break;
|
|
5020
5050
|
}
|
|
5021
5051
|
return t;
|
|
5022
5052
|
}
|
|
5023
|
-
var
|
|
5053
|
+
var T;
|
|
5024
5054
|
((s) => {
|
|
5025
5055
|
s.data = {
|
|
5026
5056
|
names: tt,
|
|
@@ -5032,7 +5062,7 @@ var A;
|
|
|
5032
5062
|
badges: Q,
|
|
5033
5063
|
items: st,
|
|
5034
5064
|
tts: et,
|
|
5035
|
-
pronouns:
|
|
5065
|
+
pronouns: R.Pronouns.map,
|
|
5036
5066
|
css_color_names: it
|
|
5037
5067
|
}, s.color = {
|
|
5038
5068
|
/**
|
|
@@ -5043,8 +5073,8 @@ var A;
|
|
|
5043
5073
|
*/
|
|
5044
5074
|
opacity(t = 100, e = "") {
|
|
5045
5075
|
e = e.length > 7 ? e?.substring(0, 6) : e, t = t > 1 ? t / 100 : t;
|
|
5046
|
-
let
|
|
5047
|
-
return e +
|
|
5076
|
+
let i = Math.round(Math.min(Math.max(t, 0), 1) * 255).toString(16).toLowerCase().padStart(2, "0");
|
|
5077
|
+
return e + i;
|
|
5048
5078
|
},
|
|
5049
5079
|
/**
|
|
5050
5080
|
* Extract color and opacity from hex code
|
|
@@ -5057,10 +5087,10 @@ var A;
|
|
|
5057
5087
|
color: t,
|
|
5058
5088
|
opacity: 100
|
|
5059
5089
|
};
|
|
5060
|
-
var r = t.slice(-2), e = parseInt(r, 16) / 255,
|
|
5090
|
+
var r = t.slice(-2), e = parseInt(r, 16) / 255, i = Math.round(e * 100), r = t.length > 7 ? t.slice(0, 7) : t;
|
|
5061
5091
|
return {
|
|
5062
5092
|
color: r,
|
|
5063
|
-
opacity:
|
|
5093
|
+
opacity: i
|
|
5064
5094
|
};
|
|
5065
5095
|
},
|
|
5066
5096
|
validate(t) {
|
|
@@ -5082,12 +5112,12 @@ var A;
|
|
|
5082
5112
|
* ```
|
|
5083
5113
|
*/
|
|
5084
5114
|
convert(t, e) {
|
|
5085
|
-
const
|
|
5086
|
-
if (!
|
|
5115
|
+
const i = this.validate(t);
|
|
5116
|
+
if (!i)
|
|
5087
5117
|
throw new Error(`Invalid color format: ${t}`);
|
|
5088
|
-
if (
|
|
5118
|
+
if (i === e)
|
|
5089
5119
|
throw new Error(`Color is already in the desired format: ${e}`);
|
|
5090
|
-
const r = rt(t.trim(),
|
|
5120
|
+
const r = rt(t.trim(), i);
|
|
5091
5121
|
if (!r)
|
|
5092
5122
|
throw new Error(`Failed to parse color: ${t}`);
|
|
5093
5123
|
switch (e) {
|
|
@@ -5098,12 +5128,12 @@ var A;
|
|
|
5098
5128
|
case "rgba":
|
|
5099
5129
|
return `rgba(${r.r}, ${r.g}, ${r.b}, ${r.a})`;
|
|
5100
5130
|
case "hsl": {
|
|
5101
|
-
const
|
|
5102
|
-
return `hsl(${
|
|
5131
|
+
const d = F(r.r, r.g, r.b);
|
|
5132
|
+
return `hsl(${d.h}, ${d.s}%, ${d.l}%)`;
|
|
5103
5133
|
}
|
|
5104
5134
|
case "hsla": {
|
|
5105
|
-
const
|
|
5106
|
-
return `hsla(${
|
|
5135
|
+
const d = F(r.r, r.g, r.b);
|
|
5136
|
+
return `hsla(${d.h}, ${d.s}%, ${d.l}%, ${r.a})`;
|
|
5107
5137
|
}
|
|
5108
5138
|
case "css-color-name":
|
|
5109
5139
|
return dt(r.r, r.g, r.b);
|
|
@@ -5131,24 +5161,24 @@ var A;
|
|
|
5131
5161
|
case "hex":
|
|
5132
5162
|
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
|
|
5133
5163
|
case "hexa": {
|
|
5134
|
-
const
|
|
5135
|
-
return
|
|
5164
|
+
const i = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`, r = Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
|
|
5165
|
+
return i + r;
|
|
5136
5166
|
}
|
|
5137
5167
|
case "rgb": {
|
|
5138
|
-
const
|
|
5139
|
-
return `rgb(${
|
|
5168
|
+
const i = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256);
|
|
5169
|
+
return `rgb(${i}, ${r}, ${d})`;
|
|
5140
5170
|
}
|
|
5141
5171
|
case "rgba": {
|
|
5142
|
-
const
|
|
5143
|
-
return `rgba(${
|
|
5172
|
+
const i = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256), u = Math.random().toFixed(2);
|
|
5173
|
+
return `rgba(${i}, ${r}, ${d}, ${u})`;
|
|
5144
5174
|
}
|
|
5145
5175
|
case "hsl": {
|
|
5146
|
-
const
|
|
5147
|
-
return `hsl(${
|
|
5176
|
+
const i = Math.floor(Math.random() * 361), r = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101);
|
|
5177
|
+
return `hsl(${i}, ${r}%, ${d}%)`;
|
|
5148
5178
|
}
|
|
5149
5179
|
case "hsla": {
|
|
5150
|
-
const
|
|
5151
|
-
return `hsla(${
|
|
5180
|
+
const i = Math.floor(Math.random() * 361), r = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101), u = Math.random().toFixed(2);
|
|
5181
|
+
return `hsla(${i}, ${r}%, ${d}%, ${u})`;
|
|
5152
5182
|
}
|
|
5153
5183
|
case "css-color-name": {
|
|
5154
5184
|
var e = s.data.css_color_names;
|
|
@@ -5171,10 +5201,10 @@ var A;
|
|
|
5171
5201
|
* console.log(floatNumber); // e.g. 3.14
|
|
5172
5202
|
* ```
|
|
5173
5203
|
*/
|
|
5174
|
-
number(t, e,
|
|
5204
|
+
number(t, e, i = 0) {
|
|
5175
5205
|
t > e && ([t, e] = [e, t]);
|
|
5176
5206
|
const r = Math.random() * (e - t) + t;
|
|
5177
|
-
return
|
|
5207
|
+
return i ? Number(r.toFixed(i)) : Math.round(r);
|
|
5178
5208
|
},
|
|
5179
5209
|
/**
|
|
5180
5210
|
* Generate random boolean
|
|
@@ -5201,10 +5231,10 @@ var A;
|
|
|
5201
5231
|
* ```
|
|
5202
5232
|
*/
|
|
5203
5233
|
string(t, e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
|
|
5204
|
-
let
|
|
5234
|
+
let i = "";
|
|
5205
5235
|
for (let r = 0; r < t; r++)
|
|
5206
|
-
|
|
5207
|
-
return
|
|
5236
|
+
i += e.charAt(Math.floor(Math.random() * e.length));
|
|
5237
|
+
return i;
|
|
5208
5238
|
},
|
|
5209
5239
|
/**
|
|
5210
5240
|
* Pick random element from array
|
|
@@ -5248,8 +5278,8 @@ var A;
|
|
|
5248
5278
|
* ```
|
|
5249
5279
|
*/
|
|
5250
5280
|
daysOffset(t) {
|
|
5251
|
-
const
|
|
5252
|
-
return new Date(
|
|
5281
|
+
const i = Date.now() - this.number(0, t * 24 * 60 * 60 * 1e3);
|
|
5282
|
+
return new Date(i).toISOString();
|
|
5253
5283
|
},
|
|
5254
5284
|
/**
|
|
5255
5285
|
* Generate UUID v4
|
|
@@ -5281,14 +5311,14 @@ var A;
|
|
|
5281
5311
|
* console.log(result); // Output will depend on the fetched data
|
|
5282
5312
|
* ```
|
|
5283
5313
|
*/
|
|
5284
|
-
async replace(t, e,
|
|
5314
|
+
async replace(t, e, i) {
|
|
5285
5315
|
const r = [];
|
|
5286
5316
|
t.replace(e, (u, ...h) => {
|
|
5287
|
-
const m = typeof
|
|
5317
|
+
const m = typeof i == "function" ? i(u, ...h) : u;
|
|
5288
5318
|
return r.push(Promise.resolve(m)), u;
|
|
5289
5319
|
});
|
|
5290
|
-
const
|
|
5291
|
-
return t.replace(e, () =>
|
|
5320
|
+
const d = await Promise.all(r);
|
|
5321
|
+
return t.replace(e, () => d.shift() ?? "");
|
|
5292
5322
|
},
|
|
5293
5323
|
/**
|
|
5294
5324
|
* Capitalizes the first letter of a given string.
|
|
@@ -5317,7 +5347,7 @@ var A;
|
|
|
5317
5347
|
* console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
|
|
5318
5348
|
* ```
|
|
5319
5349
|
*/
|
|
5320
|
-
compose(t, e = {},
|
|
5350
|
+
compose(t, e = {}, i = {
|
|
5321
5351
|
method: "index",
|
|
5322
5352
|
html: !1,
|
|
5323
5353
|
modifiers: {},
|
|
@@ -5325,7 +5355,7 @@ var A;
|
|
|
5325
5355
|
}) {
|
|
5326
5356
|
const { mergeSpanStyles: r } = s.element;
|
|
5327
5357
|
e.skip = "<br/>", e.newline = "<br/>";
|
|
5328
|
-
const
|
|
5358
|
+
const d = Object.entries(s.object.flatten(e)).reduce(
|
|
5329
5359
|
(c, [l, b]) => {
|
|
5330
5360
|
if (c[l] = String(b), ["username", "name", "nick", "nickname", "sender"].some((w) => l === w)) {
|
|
5331
5361
|
const w = c?.username || c?.name || c?.nick || c?.nickname || c?.sender;
|
|
@@ -5338,7 +5368,7 @@ var A;
|
|
|
5338
5368
|
PLACEHOLDERS: /{([^}]+)}/g,
|
|
5339
5369
|
MODIFIERS: /\[(\w+)(:[^=]+)?=([^\]]+)\]/g
|
|
5340
5370
|
};
|
|
5341
|
-
var h = parseFloat(
|
|
5371
|
+
var h = parseFloat(d?.amount ?? d?.count ?? 0);
|
|
5342
5372
|
const m = {
|
|
5343
5373
|
COLOR: (c, l) => r(l && s.color.validate(l) ? `color: ${l}` : "", c),
|
|
5344
5374
|
WEIGHT: (c, l) => r(l && !isNaN(parseInt(l)) ? `font-weight: ${l}` : "", c),
|
|
@@ -5366,8 +5396,8 @@ var A;
|
|
|
5366
5396
|
CAP: (c) => c.charAt(0).toUpperCase() + c.slice(1).toLowerCase(),
|
|
5367
5397
|
FALLBACK: (c, l) => c.length ? c : l ?? c
|
|
5368
5398
|
},
|
|
5369
|
-
...
|
|
5370
|
-
...
|
|
5399
|
+
...i?.html ? m : {},
|
|
5400
|
+
...i.modifiers ?? {}
|
|
5371
5401
|
}, v = {
|
|
5372
5402
|
UPC: ["UPPERCASE", "UPPER", "UPP"],
|
|
5373
5403
|
LOW: ["LOWERCASE", "LOWER", "LWC"],
|
|
@@ -5389,11 +5419,11 @@ var A;
|
|
|
5389
5419
|
SMALL: ["SMALLER", "SM"],
|
|
5390
5420
|
SHADOW: ["SHADOW", "SHD"],
|
|
5391
5421
|
FALLBACK: ["FALLBACK", "FB"],
|
|
5392
|
-
...
|
|
5422
|
+
...i.aliases ?? {}
|
|
5393
5423
|
};
|
|
5394
5424
|
function C(c, l, b) {
|
|
5395
5425
|
const w = Object.entries(v).find(([k, x]) => x.some((U) => U.toUpperCase() === l.toUpperCase()) ? !0 : k.toUpperCase() === l.toUpperCase()), I = w ? w[0] : l.toUpperCase();
|
|
5396
|
-
return f[I] ? f[I](c, typeof b == "string" ? b.trim() : null,
|
|
5426
|
+
return f[I] ? f[I](c, typeof b == "string" ? b.trim() : null, d) : c;
|
|
5397
5427
|
}
|
|
5398
5428
|
function j(c) {
|
|
5399
5429
|
let l = c, b;
|
|
@@ -5439,9 +5469,9 @@ var A;
|
|
|
5439
5469
|
}
|
|
5440
5470
|
let y = t.replace(
|
|
5441
5471
|
u.PLACEHOLDERS,
|
|
5442
|
-
(c, l) => typeof
|
|
5472
|
+
(c, l) => typeof d[l] == "string" || typeof d[l] == "number" ? String(d[l]) : l ?? l
|
|
5443
5473
|
);
|
|
5444
|
-
return y =
|
|
5474
|
+
return y = i.method === "loop" ? j(y) : p(y), y;
|
|
5445
5475
|
}
|
|
5446
5476
|
}, s.number = {
|
|
5447
5477
|
/**
|
|
@@ -5456,7 +5486,7 @@ var A;
|
|
|
5456
5486
|
* ```
|
|
5457
5487
|
*/
|
|
5458
5488
|
translate(t, e = "cardinal") {
|
|
5459
|
-
const
|
|
5489
|
+
const i = {
|
|
5460
5490
|
single: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],
|
|
5461
5491
|
tens: ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"],
|
|
5462
5492
|
decades: ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
|
|
@@ -5464,25 +5494,25 @@ var A;
|
|
|
5464
5494
|
single: ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"],
|
|
5465
5495
|
tens: ["tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"],
|
|
5466
5496
|
decades: ["twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"]
|
|
5467
|
-
},
|
|
5497
|
+
}, d = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"], u = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion"], h = u.map((p) => p ? `${p}th` : "");
|
|
5468
5498
|
if (t = Math.abs(Math.floor(t)), e === "suffix") {
|
|
5469
5499
|
const p = t % 100;
|
|
5470
5500
|
if (p >= 11 && p <= 13) return `${t}th`;
|
|
5471
5501
|
const y = t % 10;
|
|
5472
|
-
return `${t}${
|
|
5502
|
+
return `${t}${d[y]}`;
|
|
5473
5503
|
}
|
|
5474
5504
|
function m(p, y) {
|
|
5475
|
-
if (p < 10) return y === "ordinal" ? r.single[p] :
|
|
5476
|
-
if (p < 20) return y === "ordinal" ? r.tens[p - 10] :
|
|
5505
|
+
if (p < 10) return y === "ordinal" ? r.single[p] : i.single[p];
|
|
5506
|
+
if (p < 20) return y === "ordinal" ? r.tens[p - 10] : i.tens[p - 10];
|
|
5477
5507
|
const c = Math.floor(p / 10), l = p % 10;
|
|
5478
|
-
if (l === 0) return y === "ordinal" ? r.decades[c - 2] :
|
|
5479
|
-
const b =
|
|
5508
|
+
if (l === 0) return y === "ordinal" ? r.decades[c - 2] : i.decades[c - 2];
|
|
5509
|
+
const b = i.decades[c - 2], w = y === "ordinal" ? r.single[l] : i.single[l];
|
|
5480
5510
|
return `${b}-${w}`;
|
|
5481
5511
|
}
|
|
5482
5512
|
function g(p, y) {
|
|
5483
|
-
if (p === 0) return y === "ordinal" ? r.single[0] :
|
|
5513
|
+
if (p === 0) return y === "ordinal" ? r.single[0] : i.single[0];
|
|
5484
5514
|
const c = Math.floor(p / 100), l = p % 100, b = [];
|
|
5485
|
-
return c > 0 && (y === "ordinal" && l === 0 ? b.push(`${
|
|
5515
|
+
return c > 0 && (y === "ordinal" && l === 0 ? b.push(`${i.single[c]} hundredth`) : b.push(`${i.single[c]} hundred`)), l > 0 && b.push(m(l, y)), b.join(" ");
|
|
5486
5516
|
}
|
|
5487
5517
|
if (t < 1e3) return g(t, e);
|
|
5488
5518
|
const f = [];
|
|
@@ -5526,8 +5556,8 @@ var A;
|
|
|
5526
5556
|
* console.log(balancedValue); // 100
|
|
5527
5557
|
* ```
|
|
5528
5558
|
*/
|
|
5529
|
-
balance(t, e = 0,
|
|
5530
|
-
return Math.min(Math.max(t, e),
|
|
5559
|
+
balance(t, e = 0, i = 100) {
|
|
5560
|
+
return Math.min(Math.max(t, e), i);
|
|
5531
5561
|
}
|
|
5532
5562
|
}, s.element = {
|
|
5533
5563
|
/**
|
|
@@ -5542,10 +5572,10 @@ var A;
|
|
|
5542
5572
|
* ```
|
|
5543
5573
|
*/
|
|
5544
5574
|
mergeSpanStyles(t, e) {
|
|
5545
|
-
const
|
|
5546
|
-
if (
|
|
5547
|
-
const r =
|
|
5548
|
-
return `<span style="${[r, t].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${
|
|
5575
|
+
const i = e.match(/^<span style="([^"]*)">(.*)<\/span>$/s);
|
|
5576
|
+
if (i) {
|
|
5577
|
+
const r = i[1], d = i[2];
|
|
5578
|
+
return `<span style="${[r, t].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${d}</span>`;
|
|
5549
5579
|
} else
|
|
5550
5580
|
return `<span style="${t}">${e}</span>`;
|
|
5551
5581
|
},
|
|
@@ -5562,8 +5592,8 @@ var A;
|
|
|
5562
5592
|
* Simulation.element.scale(element, 0.5, 1, { return: false });
|
|
5563
5593
|
* ```
|
|
5564
5594
|
*/
|
|
5565
|
-
scale(t, e = 0,
|
|
5566
|
-
const { return:
|
|
5595
|
+
scale(t, e = 0, i = 1, r) {
|
|
5596
|
+
const { return: d = !1, parent: u, base: h } = r || {}, m = u || t.parentElement || document.body;
|
|
5567
5597
|
if (!m) {
|
|
5568
5598
|
J.warn("No parent element found for scaling");
|
|
5569
5599
|
return;
|
|
@@ -5573,7 +5603,7 @@ var A;
|
|
|
5573
5603
|
J.warn("Element has zero width or height, cannot scale");
|
|
5574
5604
|
return;
|
|
5575
5605
|
}
|
|
5576
|
-
const C = g.width *
|
|
5606
|
+
const C = g.width * i / f, j = g.height * i / v;
|
|
5577
5607
|
let p = h === "width" ? C : h === "height" ? j : Math.min(C, j);
|
|
5578
5608
|
if (e > 0) {
|
|
5579
5609
|
const c = g.width * e / f, l = g.height * e / v, b = Math.max(c, l);
|
|
@@ -5584,7 +5614,7 @@ var A;
|
|
|
5584
5614
|
height: v * p,
|
|
5585
5615
|
scale: p
|
|
5586
5616
|
};
|
|
5587
|
-
return
|
|
5617
|
+
return d || (t.style.transform = `scale(${p})`, t.style.transformOrigin = "center center"), y;
|
|
5588
5618
|
},
|
|
5589
5619
|
/**
|
|
5590
5620
|
* Splits the text content of an HTML string into individual characters wrapped in span elements with a data-index attribute.
|
|
@@ -5600,12 +5630,12 @@ var A;
|
|
|
5600
5630
|
*/
|
|
5601
5631
|
splitTextToChars(t, e = 0) {
|
|
5602
5632
|
const r = new DOMParser().parseFromString(t, "text/html");
|
|
5603
|
-
let
|
|
5633
|
+
let d = e;
|
|
5604
5634
|
function u(g) {
|
|
5605
5635
|
if (g.nodeType === Node.TEXT_NODE) {
|
|
5606
5636
|
const v = g.textContent?.split("").map((j) => {
|
|
5607
5637
|
const p = document.createElement("span");
|
|
5608
|
-
return p.className = "char", p.dataset.index = String(
|
|
5638
|
+
return p.className = "char", p.dataset.index = String(d++), p.textContent = j, d++, p.outerHTML;
|
|
5609
5639
|
}), C = document.createElement("span");
|
|
5610
5640
|
return C.innerHTML = v?.join("") ?? "", C;
|
|
5611
5641
|
} else if (g.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -5640,38 +5670,38 @@ var A;
|
|
|
5640
5670
|
* ```
|
|
5641
5671
|
*/
|
|
5642
5672
|
flatten(t, e = "") {
|
|
5643
|
-
const
|
|
5673
|
+
const i = {};
|
|
5644
5674
|
for (const r in t) {
|
|
5645
5675
|
if (!Object.prototype.hasOwnProperty.call(t, r)) continue;
|
|
5646
|
-
const
|
|
5647
|
-
if (
|
|
5648
|
-
|
|
5676
|
+
const d = t[r], u = e ? `${e}.${r}` : r;
|
|
5677
|
+
if (d == null) {
|
|
5678
|
+
i[u] = String(d);
|
|
5649
5679
|
continue;
|
|
5650
5680
|
}
|
|
5651
|
-
if (
|
|
5652
|
-
|
|
5681
|
+
if (d instanceof Date) {
|
|
5682
|
+
i[u] = d.toISOString();
|
|
5653
5683
|
continue;
|
|
5654
5684
|
}
|
|
5655
|
-
if (
|
|
5656
|
-
|
|
5657
|
-
|
|
5685
|
+
if (d instanceof Map) {
|
|
5686
|
+
d.forEach((h, m) => {
|
|
5687
|
+
i[`${u}.${m}`] = JSON.stringify(h);
|
|
5658
5688
|
});
|
|
5659
5689
|
continue;
|
|
5660
5690
|
}
|
|
5661
|
-
if (Array.isArray(
|
|
5662
|
-
|
|
5691
|
+
if (Array.isArray(d)) {
|
|
5692
|
+
d.forEach((h, m) => {
|
|
5663
5693
|
const g = `${u}:${m}`;
|
|
5664
|
-
typeof h == "object" ? Object.assign(
|
|
5694
|
+
typeof h == "object" ? Object.assign(i, this.flatten(h, g)) : i[g] = String(h);
|
|
5665
5695
|
});
|
|
5666
5696
|
continue;
|
|
5667
5697
|
}
|
|
5668
|
-
if (typeof
|
|
5669
|
-
Object.assign(
|
|
5698
|
+
if (typeof d == "object") {
|
|
5699
|
+
Object.assign(i, this.flatten(d, u));
|
|
5670
5700
|
continue;
|
|
5671
5701
|
}
|
|
5672
|
-
|
|
5702
|
+
i[u] = String(d);
|
|
5673
5703
|
}
|
|
5674
|
-
return
|
|
5704
|
+
return i;
|
|
5675
5705
|
}
|
|
5676
5706
|
}, s.generate = {
|
|
5677
5707
|
session: {
|
|
@@ -5927,7 +5957,7 @@ var A;
|
|
|
5927
5957
|
},
|
|
5928
5958
|
async get() {
|
|
5929
5959
|
const t = this.available(), e = (r) => {
|
|
5930
|
-
const
|
|
5960
|
+
const d = (m) => {
|
|
5931
5961
|
if (!m || !("amount" in m)) return [];
|
|
5932
5962
|
const g = [];
|
|
5933
5963
|
for (let f = 0; f < m.amount; f++)
|
|
@@ -5952,23 +5982,23 @@ var A;
|
|
|
5952
5982
|
case "array":
|
|
5953
5983
|
return s.rand.array(m.options)[0];
|
|
5954
5984
|
case "recent":
|
|
5955
|
-
return
|
|
5985
|
+
return d(m);
|
|
5956
5986
|
default:
|
|
5957
5987
|
return m;
|
|
5958
5988
|
}
|
|
5959
5989
|
};
|
|
5960
5990
|
return typeof r != "object" || r === null ? r : "type" in r && typeof r.type == "string" ? h(r) : u(r);
|
|
5961
5991
|
};
|
|
5962
|
-
var
|
|
5963
|
-
(r, [
|
|
5992
|
+
var i = Object.entries(e(t)).reduce(
|
|
5993
|
+
(r, [d, u]) => (Object.entries(u).forEach(
|
|
5964
5994
|
([h, m]) => (
|
|
5965
5995
|
//
|
|
5966
|
-
r[`${
|
|
5996
|
+
r[`${d}-${h}`] = m
|
|
5967
5997
|
)
|
|
5968
5998
|
), r),
|
|
5969
5999
|
{}
|
|
5970
6000
|
);
|
|
5971
|
-
return
|
|
6001
|
+
return i;
|
|
5972
6002
|
}
|
|
5973
6003
|
},
|
|
5974
6004
|
event: {
|
|
@@ -5979,7 +6009,7 @@ var A;
|
|
|
5979
6009
|
* @param currency - The currency to be used (default is 'USD').
|
|
5980
6010
|
* @returns A Promise that resolves to the simulated onWidgetLoad event data.
|
|
5981
6011
|
*/
|
|
5982
|
-
async onWidgetLoad(t, e,
|
|
6012
|
+
async onWidgetLoad(t, e, i = "USD") {
|
|
5983
6013
|
const r = {
|
|
5984
6014
|
BRL: { code: "BRL", name: "Brazilian Real", symbol: "R$" },
|
|
5985
6015
|
USD: { code: "USD", name: "US Dollar", symbol: "$" },
|
|
@@ -5993,7 +6023,7 @@ var A;
|
|
|
5993
6023
|
providerId: "",
|
|
5994
6024
|
avatar: ""
|
|
5995
6025
|
},
|
|
5996
|
-
currency: r[
|
|
6026
|
+
currency: r[i] ?? r.USD,
|
|
5997
6027
|
fieldData: t,
|
|
5998
6028
|
recents: [],
|
|
5999
6029
|
session: {
|
|
@@ -6034,7 +6064,7 @@ var A;
|
|
|
6034
6064
|
* const twitchMessageEvent = await Simulation.generate.event.onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' });
|
|
6035
6065
|
* ```
|
|
6036
6066
|
*/
|
|
6037
|
-
async onEventReceived(t = "random", e = "random",
|
|
6067
|
+
async onEventReceived(t = "random", e = "random", i = {}) {
|
|
6038
6068
|
const r = {
|
|
6039
6069
|
twitch: ["message", "follower-latest", "cheer-latest", "raid-latest", "subscriber-latest"],
|
|
6040
6070
|
streamelements: ["tip-latest"],
|
|
@@ -6045,8 +6075,8 @@ var A;
|
|
|
6045
6075
|
switch (t) {
|
|
6046
6076
|
default:
|
|
6047
6077
|
case "random": {
|
|
6048
|
-
var
|
|
6049
|
-
return this.onEventReceived(
|
|
6078
|
+
var d = s.rand.array(Object.keys(r).filter((U) => r[U].length))[0], u = s.rand.array(r[d])[0];
|
|
6079
|
+
return this.onEventReceived(d, u);
|
|
6050
6080
|
}
|
|
6051
6081
|
case "twitch":
|
|
6052
6082
|
switch (e) {
|
|
@@ -6056,7 +6086,7 @@ var A;
|
|
|
6056
6086
|
return this.onEventReceived(t, u);
|
|
6057
6087
|
}
|
|
6058
6088
|
case "message": {
|
|
6059
|
-
var h =
|
|
6089
|
+
var h = i?.name ?? s.rand.array(s.data.names.filter((H) => H.length))[0], m = i?.message ?? s.rand.array(s.data.messages.filter((H) => H.length))[0], g = await G(i?.badges ?? [], t), f = V(m), v = q(m, f), C = i?.color ?? s.rand.color("hex"), j = i?.userId ?? s.rand.number(1e7, 99999999).toString(), p = Date.now();
|
|
6060
6090
|
return {
|
|
6061
6091
|
listener: "message",
|
|
6062
6092
|
event: {
|
|
@@ -6098,7 +6128,7 @@ var A;
|
|
|
6098
6128
|
}
|
|
6099
6129
|
case "cheer":
|
|
6100
6130
|
case "cheer-latest": {
|
|
6101
|
-
var y =
|
|
6131
|
+
var y = i?.amount ?? s.rand.number(100, 1e4), c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((D) => D.length))[0], m = i?.message ?? s.rand.array(s.data.messages.filter((D) => D.length))[0];
|
|
6102
6132
|
return {
|
|
6103
6133
|
listener: "cheer-latest",
|
|
6104
6134
|
event: {
|
|
@@ -6118,7 +6148,7 @@ var A;
|
|
|
6118
6148
|
}
|
|
6119
6149
|
case "follower":
|
|
6120
6150
|
case "follower-latest": {
|
|
6121
|
-
var c =
|
|
6151
|
+
var c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((D) => D.length))[0];
|
|
6122
6152
|
return {
|
|
6123
6153
|
listener: "follower-latest",
|
|
6124
6154
|
event: {
|
|
@@ -6136,7 +6166,7 @@ var A;
|
|
|
6136
6166
|
}
|
|
6137
6167
|
case "raid":
|
|
6138
6168
|
case "raid-latest": {
|
|
6139
|
-
var y =
|
|
6169
|
+
var y = i?.amount ?? s.rand.number(1, 100), c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
|
|
6140
6170
|
return {
|
|
6141
6171
|
listener: "raid-latest",
|
|
6142
6172
|
event: {
|
|
@@ -6155,7 +6185,7 @@ var A;
|
|
|
6155
6185
|
}
|
|
6156
6186
|
case "subscriber":
|
|
6157
6187
|
case "subscriber-latest": {
|
|
6158
|
-
var l =
|
|
6188
|
+
var l = i?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], y = i?.amount ?? s.rand.number(1, 24), c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((P) => P.length))[0], b = i?.sender ?? s.rand.array(s.data.names.filter((P) => P.length && P !== h))[0], m = i?.message ?? s.rand.array(s.data.messages.filter((P) => P.length))[0], w = {
|
|
6159
6189
|
default: {
|
|
6160
6190
|
avatar: c,
|
|
6161
6191
|
tier: l,
|
|
@@ -6175,7 +6205,7 @@ var A;
|
|
|
6175
6205
|
gifted: !0,
|
|
6176
6206
|
isCommunityGift: !0
|
|
6177
6207
|
}
|
|
6178
|
-
}, I = ["default", "gift", "community", "spam"], k =
|
|
6208
|
+
}, I = ["default", "gift", "community", "spam"], k = i?.subType ?? s.rand.array(I)[0];
|
|
6179
6209
|
return k = I.includes(k) ? k : "default", {
|
|
6180
6210
|
listener: "subscriber-latest",
|
|
6181
6211
|
event: {
|
|
@@ -6197,7 +6227,7 @@ var A;
|
|
|
6197
6227
|
return {
|
|
6198
6228
|
listener: "delete-message",
|
|
6199
6229
|
event: {
|
|
6200
|
-
msgId:
|
|
6230
|
+
msgId: i?.id ?? s.rand.uuid(),
|
|
6201
6231
|
provider: t
|
|
6202
6232
|
}
|
|
6203
6233
|
};
|
|
@@ -6205,7 +6235,7 @@ var A;
|
|
|
6205
6235
|
return {
|
|
6206
6236
|
listener: "delete-messages",
|
|
6207
6237
|
event: {
|
|
6208
|
-
userId:
|
|
6238
|
+
userId: i?.id ?? s.rand.number(1e7, 99999999).toString(),
|
|
6209
6239
|
provider: t
|
|
6210
6240
|
}
|
|
6211
6241
|
};
|
|
@@ -6219,7 +6249,7 @@ var A;
|
|
|
6219
6249
|
}
|
|
6220
6250
|
case "tip":
|
|
6221
6251
|
case "tip-latest": {
|
|
6222
|
-
var y =
|
|
6252
|
+
var y = i?.amount ?? s.rand.number(100, 4e3), c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
|
|
6223
6253
|
return {
|
|
6224
6254
|
listener: "tip-latest",
|
|
6225
6255
|
event: {
|
|
@@ -6241,8 +6271,8 @@ var A;
|
|
|
6241
6271
|
listener: "kvstore:update",
|
|
6242
6272
|
event: {
|
|
6243
6273
|
data: {
|
|
6244
|
-
key: `customWidget.${
|
|
6245
|
-
value:
|
|
6274
|
+
key: `customWidget.${i?.key ?? "sampleKey"}`,
|
|
6275
|
+
value: i?.value ?? "sampleValue"
|
|
6246
6276
|
},
|
|
6247
6277
|
provider: t
|
|
6248
6278
|
}
|
|
@@ -6251,15 +6281,15 @@ var A;
|
|
|
6251
6281
|
return {
|
|
6252
6282
|
listener: "bot:counter",
|
|
6253
6283
|
event: {
|
|
6254
|
-
counter:
|
|
6255
|
-
value:
|
|
6284
|
+
counter: i?.counter ?? "sampleCounter",
|
|
6285
|
+
value: i?.value ?? s.rand.number(0, 100),
|
|
6256
6286
|
provider: t
|
|
6257
6287
|
}
|
|
6258
6288
|
};
|
|
6259
6289
|
case "mute":
|
|
6260
6290
|
case "unmute":
|
|
6261
6291
|
case "alertService:toggleSound": {
|
|
6262
|
-
var x =
|
|
6292
|
+
var x = i?.muted ?? !client.details.overlay.muted;
|
|
6263
6293
|
return {
|
|
6264
6294
|
listener: "alertService:toggleSound",
|
|
6265
6295
|
event: {
|
|
@@ -6285,9 +6315,9 @@ var A;
|
|
|
6285
6315
|
return this.onEventReceived(t, u);
|
|
6286
6316
|
}
|
|
6287
6317
|
case "message": {
|
|
6288
|
-
var h =
|
|
6289
|
-
const L = await G(
|
|
6290
|
-
var f = V(m), v = q(m, f), C =
|
|
6318
|
+
var h = i?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0], m = i?.message ?? s.rand.array(s.data.messages.filter((A) => A.length))[0];
|
|
6319
|
+
const L = await G(i?.badges ?? [], t);
|
|
6320
|
+
var f = V(m), v = q(m, f), C = i?.color ?? s.rand.color("hex"), j = i?.userId ?? s.rand.number(1e7, 99999999).toString(), p = Date.now(), c = i?.avatar ?? s.rand.array(s.data.avatars)[0];
|
|
6291
6321
|
return {
|
|
6292
6322
|
listener: "message",
|
|
6293
6323
|
event: {
|
|
@@ -6334,7 +6364,7 @@ var A;
|
|
|
6334
6364
|
}
|
|
6335
6365
|
case "subscriber":
|
|
6336
6366
|
case "subscriber-latest": {
|
|
6337
|
-
var c =
|
|
6367
|
+
var c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((D) => D.length))[0];
|
|
6338
6368
|
return {
|
|
6339
6369
|
listener: "subscriber-latest",
|
|
6340
6370
|
event: {
|
|
@@ -6352,7 +6382,7 @@ var A;
|
|
|
6352
6382
|
}
|
|
6353
6383
|
case "superchat":
|
|
6354
6384
|
case "superchat-latest": {
|
|
6355
|
-
var y =
|
|
6385
|
+
var y = i?.amount ?? s.rand.number(100, 4e3), c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
|
|
6356
6386
|
return {
|
|
6357
6387
|
listener: "superchat-latest",
|
|
6358
6388
|
event: {
|
|
@@ -6371,7 +6401,7 @@ var A;
|
|
|
6371
6401
|
}
|
|
6372
6402
|
case "sponsor":
|
|
6373
6403
|
case "sponsor-latest": {
|
|
6374
|
-
var l =
|
|
6404
|
+
var l = i?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], y = i?.amount ?? s.rand.number(1, 24), c = i?.avatar ?? s.rand.array(s.data.avatars)[0], h = i?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0], b = i?.sender ?? s.rand.array(s.data.names.filter((A) => A.length && A !== h))[0], m = i?.message ?? s.rand.array(s.data.messages.filter((A) => A.length))[0], w = {
|
|
6375
6405
|
default: {
|
|
6376
6406
|
avatar: c,
|
|
6377
6407
|
tier: l,
|
|
@@ -6391,7 +6421,7 @@ var A;
|
|
|
6391
6421
|
gifted: !0,
|
|
6392
6422
|
isCommunityGift: !0
|
|
6393
6423
|
}
|
|
6394
|
-
}, I = ["default", "gift", "community", "spam"], k =
|
|
6424
|
+
}, I = ["default", "gift", "community", "spam"], k = i?.subType ?? s.rand.array(I)[0];
|
|
6395
6425
|
return k = I.includes(k) ? k : "default", {
|
|
6396
6426
|
listener: "sponsor-latest",
|
|
6397
6427
|
event: {
|
|
@@ -6480,37 +6510,37 @@ var A;
|
|
|
6480
6510
|
return new Promise((e) => setTimeout(e, t));
|
|
6481
6511
|
}
|
|
6482
6512
|
s.delay = a;
|
|
6483
|
-
function
|
|
6484
|
-
const e = Object.values(t).reduce((u, h) => u + h, 0),
|
|
6485
|
-
let
|
|
6486
|
-
for (const [u, h] of
|
|
6487
|
-
if (
|
|
6513
|
+
function n(t) {
|
|
6514
|
+
const e = Object.values(t).reduce((u, h) => u + h, 0), i = Object.entries(t).sort((u, h) => h[1] - u[1]), r = Math.random() * e;
|
|
6515
|
+
let d = 0;
|
|
6516
|
+
for (const [u, h] of i)
|
|
6517
|
+
if (d += h, r < d)
|
|
6488
6518
|
return u;
|
|
6489
6519
|
}
|
|
6490
|
-
s.probability =
|
|
6491
|
-
async function
|
|
6492
|
-
const
|
|
6493
|
-
fields: t.find((
|
|
6520
|
+
s.probability = n;
|
|
6521
|
+
async function o(t = ["fields.json", "cf.json", "field.json", "customfields.json"], e = ["data.json", "fielddata.json", "fd.json", "DATA.json"]) {
|
|
6522
|
+
const i = {
|
|
6523
|
+
fields: t.find((d) => {
|
|
6494
6524
|
try {
|
|
6495
|
-
return new URL("./" +
|
|
6525
|
+
return new URL("./" + d, window.location.href), !0;
|
|
6496
6526
|
} catch {
|
|
6497
6527
|
return !1;
|
|
6498
6528
|
}
|
|
6499
6529
|
}),
|
|
6500
|
-
data: e.find((
|
|
6530
|
+
data: e.find((d) => {
|
|
6501
6531
|
try {
|
|
6502
|
-
return new URL("./" +
|
|
6532
|
+
return new URL("./" + d, window.location.href), !0;
|
|
6503
6533
|
} catch {
|
|
6504
6534
|
return !1;
|
|
6505
6535
|
}
|
|
6506
6536
|
})
|
|
6507
|
-
}, r = await fetch("./" + (
|
|
6537
|
+
}, r = await fetch("./" + (i.data ?? "data.json"), {
|
|
6508
6538
|
cache: "no-store"
|
|
6509
|
-
}).then((
|
|
6510
|
-
await fetch("./" + (
|
|
6539
|
+
}).then((d) => d.json()).catch(() => ({}));
|
|
6540
|
+
await fetch("./" + (i.fields ?? "fields.json"), {
|
|
6511
6541
|
cache: "no-store"
|
|
6512
|
-
}).then((
|
|
6513
|
-
const u = Object.entries(
|
|
6542
|
+
}).then((d) => d.json()).then(async (d) => {
|
|
6543
|
+
const u = Object.entries(d).filter(([m, { value: g }]) => g != null).reduce(
|
|
6514
6544
|
(m, [g, { value: f }]) => (r && r[g] !== void 0 && (f = r[g]), m[g] = f, m),
|
|
6515
6545
|
{
|
|
6516
6546
|
...r
|
|
@@ -6519,44 +6549,53 @@ var A;
|
|
|
6519
6549
|
window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: h }));
|
|
6520
6550
|
});
|
|
6521
6551
|
}
|
|
6522
|
-
s.start =
|
|
6523
|
-
})(
|
|
6524
|
-
function V(s, a =
|
|
6525
|
-
const
|
|
6526
|
-
return a.forEach((
|
|
6527
|
-
const t =
|
|
6528
|
-
let e = 0,
|
|
6552
|
+
s.start = o;
|
|
6553
|
+
})(T || (T = {}));
|
|
6554
|
+
function V(s, a = T.data.emotes) {
|
|
6555
|
+
const n = [];
|
|
6556
|
+
return a.forEach((o) => {
|
|
6557
|
+
const t = o.name;
|
|
6558
|
+
let e = 0, i = 0;
|
|
6529
6559
|
for (; e < s.length; ) {
|
|
6530
|
-
const r = s.indexOf(t,
|
|
6560
|
+
const r = s.indexOf(t, i);
|
|
6531
6561
|
if (r === -1) break;
|
|
6532
|
-
const
|
|
6533
|
-
/\s/.test(
|
|
6562
|
+
const d = r > 0 ? s[r - 1] : " ", u = r + t.length < s.length ? s[r + t.length] : " ";
|
|
6563
|
+
/\s/.test(d) && /\s/.test(u) && n.push({ ...o, start: r, end: r + t.length }), i = r + 1;
|
|
6534
6564
|
}
|
|
6535
|
-
}),
|
|
6565
|
+
}), n.sort((o, t) => o.start - t.start);
|
|
6536
6566
|
}
|
|
6537
6567
|
function q(s, a) {
|
|
6538
6568
|
if (!a.length) return s;
|
|
6539
|
-
let
|
|
6569
|
+
let n = "", o = 0;
|
|
6540
6570
|
return a.forEach((t) => {
|
|
6541
|
-
|
|
6542
|
-
const
|
|
6543
|
-
|
|
6544
|
-
}),
|
|
6571
|
+
n += s.substring(o, t.start);
|
|
6572
|
+
const i = Array.from({ ...t.urls, length: 5 }).slice(1).reverse().filter(Boolean)[0] || t.urls[1];
|
|
6573
|
+
n += `<img src="${i}" alt="${t.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, o = t.end;
|
|
6574
|
+
}), n += s.substring(o), n;
|
|
6575
|
+
}
|
|
6576
|
+
function ht(s, a = T.data.youtube_emotes) {
|
|
6577
|
+
return Array.from(s.matchAll(/:(.*?):/gim), (o) => o[0]).forEach((o) => {
|
|
6578
|
+
const t = a.find((e) => e.shortcuts.includes(o) || e.searchTerms.includes(o.slice(1, -1)));
|
|
6579
|
+
if (t) {
|
|
6580
|
+
const e = t.image.thumbnails.at(-1)?.url, i = t.image.accessibility.accessibilityData.label;
|
|
6581
|
+
e && (s = s.replace(o, `<img src="${e}" alt="${i}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`));
|
|
6582
|
+
}
|
|
6583
|
+
}), s;
|
|
6545
6584
|
}
|
|
6546
6585
|
async function G(s = [], a = "twitch") {
|
|
6547
|
-
if (!Array.isArray(s) && typeof s == "string" && (s = s.split(",").map((
|
|
6548
|
-
var
|
|
6549
|
-
for await (const
|
|
6550
|
-
var
|
|
6551
|
-
!s.includes(
|
|
6586
|
+
if (!Array.isArray(s) && typeof s == "string" && (s = s.split(",").map((i) => i.trim())), !s || !s.length) {
|
|
6587
|
+
var n = T.rand.number(1, 3);
|
|
6588
|
+
for await (const i of Array.from({ length: n }, () => "")) {
|
|
6589
|
+
var o = T.rand.array(Object.keys(T.data.badges))[0];
|
|
6590
|
+
!s.includes(o) && Array.isArray(s) ? s.push(o) : s = [o];
|
|
6552
6591
|
}
|
|
6553
6592
|
}
|
|
6554
6593
|
var t;
|
|
6555
6594
|
switch (a) {
|
|
6556
6595
|
case "twitch": {
|
|
6557
6596
|
t = {
|
|
6558
|
-
keys: Array.from(s).filter((
|
|
6559
|
-
badges: Array.from(s).slice(0, 3).map((
|
|
6597
|
+
keys: Array.from(s).filter((i) => i in T.data.badges),
|
|
6598
|
+
badges: Array.from(s).slice(0, 3).map((i) => T.data.badges[i]).filter(Boolean)
|
|
6560
6599
|
};
|
|
6561
6600
|
break;
|
|
6562
6601
|
}
|
|
@@ -6570,7 +6609,7 @@ async function G(s = [], a = "twitch") {
|
|
|
6570
6609
|
moderator: { isChatModerator: !1 }
|
|
6571
6610
|
};
|
|
6572
6611
|
t = Object.entries(s).reduce(
|
|
6573
|
-
(
|
|
6612
|
+
(i, [r]) => (r in e && Object.assign(i, e[r]), i),
|
|
6574
6613
|
{
|
|
6575
6614
|
isVerified: !1,
|
|
6576
6615
|
isChatOwner: !1,
|
|
@@ -6604,7 +6643,7 @@ const S = {
|
|
|
6604
6643
|
cheerFilter(s) {
|
|
6605
6644
|
return s;
|
|
6606
6645
|
},
|
|
6607
|
-
setField(s, a,
|
|
6646
|
+
setField(s, a, n) {
|
|
6608
6647
|
},
|
|
6609
6648
|
store: {
|
|
6610
6649
|
set: function(s, a) {
|
|
@@ -6616,11 +6655,11 @@ const S = {
|
|
|
6616
6655
|
list: {}
|
|
6617
6656
|
}
|
|
6618
6657
|
};
|
|
6619
|
-
async function
|
|
6658
|
+
async function lt() {
|
|
6620
6659
|
let s = localStorage.getItem("SE_API-STORE") ?? "", a = s ? JSON.parse(s) : {};
|
|
6621
6660
|
return S.store.list = a, S;
|
|
6622
6661
|
}
|
|
6623
|
-
class
|
|
6662
|
+
class N {
|
|
6624
6663
|
/**
|
|
6625
6664
|
* Stores registered event listeners.
|
|
6626
6665
|
*/
|
|
@@ -6631,38 +6670,38 @@ class O {
|
|
|
6631
6670
|
* @param eventName The name of the event.
|
|
6632
6671
|
* @param args Arguments to pass to the listeners.
|
|
6633
6672
|
*/
|
|
6634
|
-
emit(a, ...
|
|
6635
|
-
return (this.registeredEvents[a] || []).map((t) => t.apply(this,
|
|
6673
|
+
emit(a, ...n) {
|
|
6674
|
+
return (this.registeredEvents[a] || []).map((t) => t.apply(this, n));
|
|
6636
6675
|
}
|
|
6637
6676
|
/**
|
|
6638
6677
|
* Registers an event listener.
|
|
6639
6678
|
* @param eventName The name of the event.
|
|
6640
6679
|
* @param callback The callback function.
|
|
6641
6680
|
*/
|
|
6642
|
-
on(a,
|
|
6643
|
-
if (typeof
|
|
6681
|
+
on(a, n) {
|
|
6682
|
+
if (typeof n != "function")
|
|
6644
6683
|
throw new TypeError("Callback must be a function");
|
|
6645
|
-
return this.registeredEvents[a] || (this.registeredEvents[a] = []), this.registeredEvents[a].push(
|
|
6684
|
+
return this.registeredEvents[a] || (this.registeredEvents[a] = []), this.registeredEvents[a].push(n), this;
|
|
6646
6685
|
}
|
|
6647
6686
|
/**
|
|
6648
6687
|
* Removes a specific event listener.
|
|
6649
6688
|
* @param eventName The name of the event.
|
|
6650
6689
|
* @param callback The callback function to remove.
|
|
6651
6690
|
*/
|
|
6652
|
-
off(a,
|
|
6653
|
-
const
|
|
6654
|
-
return
|
|
6691
|
+
off(a, n) {
|
|
6692
|
+
const o = this.registeredEvents[a] || [];
|
|
6693
|
+
return n ? (this.registeredEvents[a] = o.filter((t) => t !== n), this) : (this.registeredEvents[a] = [], this);
|
|
6655
6694
|
}
|
|
6656
6695
|
/**
|
|
6657
6696
|
* Registers a listener that is executed only once.
|
|
6658
6697
|
* @param eventName The name of the event.
|
|
6659
6698
|
* @param callback The callback function.
|
|
6660
6699
|
*/
|
|
6661
|
-
once(a,
|
|
6662
|
-
const
|
|
6663
|
-
this.off(a,
|
|
6700
|
+
once(a, n) {
|
|
6701
|
+
const o = (...t) => {
|
|
6702
|
+
this.off(a, o), n.apply(this, t);
|
|
6664
6703
|
};
|
|
6665
|
-
return this.on(a,
|
|
6704
|
+
return this.on(a, o), this;
|
|
6666
6705
|
}
|
|
6667
6706
|
/**
|
|
6668
6707
|
* Removes all listeners for a specific event.
|
|
@@ -6672,8 +6711,8 @@ class O {
|
|
|
6672
6711
|
return this.registeredEvents[a] = [], this;
|
|
6673
6712
|
}
|
|
6674
6713
|
}
|
|
6675
|
-
var
|
|
6676
|
-
class
|
|
6714
|
+
var O = [];
|
|
6715
|
+
class W extends N {
|
|
6677
6716
|
/**
|
|
6678
6717
|
* The unique identifier for the storage instance.
|
|
6679
6718
|
*/
|
|
@@ -6681,13 +6720,13 @@ class N extends O {
|
|
|
6681
6720
|
loaded = !1;
|
|
6682
6721
|
data;
|
|
6683
6722
|
constructor(a) {
|
|
6684
|
-
super(), this.id = a.id || this.id, this.data = a.data ?? {},
|
|
6723
|
+
super(), this.id = a.id || this.id, this.data = a.data ?? {}, O.push(this), this.start();
|
|
6685
6724
|
}
|
|
6686
6725
|
SE_API = null;
|
|
6687
6726
|
start() {
|
|
6688
6727
|
K?.then((a) => {
|
|
6689
|
-
this.SE_API = a, a.store.get(this.id).then((
|
|
6690
|
-
this.data =
|
|
6728
|
+
this.SE_API = a, a.store.get(this.id).then((n) => {
|
|
6729
|
+
this.data = n ?? this.data, this.loaded = !0, this.emit("load", this.data), JSON.stringify(this.data) !== JSON.stringify(n) && this.emit("update", this.data);
|
|
6691
6730
|
}).catch(() => {
|
|
6692
6731
|
this.loaded = !0, this.emit("load", this.data);
|
|
6693
6732
|
});
|
|
@@ -6712,8 +6751,8 @@ class N extends O {
|
|
|
6712
6751
|
* @param path Path to add the value to
|
|
6713
6752
|
* @param value Value to add
|
|
6714
6753
|
*/
|
|
6715
|
-
add(a,
|
|
6716
|
-
this.loaded && (
|
|
6754
|
+
add(a, n) {
|
|
6755
|
+
this.loaded && (W.setByPath(this.data, a, n), this.save(this.data));
|
|
6717
6756
|
}
|
|
6718
6757
|
/**
|
|
6719
6758
|
* Clears all data from the storage.
|
|
@@ -6728,25 +6767,25 @@ class N extends O {
|
|
|
6728
6767
|
* @param value The value to set
|
|
6729
6768
|
* @returns The updated object
|
|
6730
6769
|
*/
|
|
6731
|
-
static setByPath(a,
|
|
6732
|
-
const t =
|
|
6770
|
+
static setByPath(a, n, o) {
|
|
6771
|
+
const t = n.split(".");
|
|
6733
6772
|
let e = a;
|
|
6734
|
-
for (let
|
|
6735
|
-
(typeof e[t[
|
|
6736
|
-
return e[t[t.length - 1]] =
|
|
6773
|
+
for (let i = 0; i < t.length - 1; i++)
|
|
6774
|
+
(typeof e[t[i]] != "object" || e[t[i]] == null) && (e[t[i]] = {}), e = e[t[i]];
|
|
6775
|
+
return e[t[t.length - 1]] = o, e;
|
|
6737
6776
|
}
|
|
6738
|
-
on(a,
|
|
6739
|
-
return a === "load" && this.loaded ? (
|
|
6777
|
+
on(a, n) {
|
|
6778
|
+
return a === "load" && this.loaded ? (n.apply(this, [this.data]), this) : (super.on(a, n), this);
|
|
6740
6779
|
}
|
|
6741
6780
|
}
|
|
6742
|
-
class E extends
|
|
6781
|
+
class E extends N {
|
|
6743
6782
|
id = "default";
|
|
6744
6783
|
storage;
|
|
6745
6784
|
fields = {};
|
|
6746
6785
|
session;
|
|
6747
6786
|
loaded = !1;
|
|
6748
6787
|
constructor(a) {
|
|
6749
|
-
super(), this.id = a.id || this.id, this.storage = new
|
|
6788
|
+
super(), this.id = a.id || this.id, this.storage = new W({
|
|
6750
6789
|
id: this.id,
|
|
6751
6790
|
data: {
|
|
6752
6791
|
user: {},
|
|
@@ -6763,11 +6802,11 @@ class E extends O {
|
|
|
6763
6802
|
details;
|
|
6764
6803
|
cache = {
|
|
6765
6804
|
avatar: 30,
|
|
6766
|
-
pronoun:
|
|
6767
|
-
emote:
|
|
6805
|
+
pronoun: 60,
|
|
6806
|
+
emote: 120
|
|
6768
6807
|
};
|
|
6769
|
-
on(a,
|
|
6770
|
-
return a === "load" && this.loaded ? (
|
|
6808
|
+
on(a, n) {
|
|
6809
|
+
return a === "load" && this.loaded ? (n.apply(this, [
|
|
6771
6810
|
{
|
|
6772
6811
|
channel: this.details.user,
|
|
6773
6812
|
currency: this.details.currency,
|
|
@@ -6784,7 +6823,7 @@ class E extends O {
|
|
|
6784
6823
|
overlay: this.details.overlay,
|
|
6785
6824
|
emulated: !1
|
|
6786
6825
|
}
|
|
6787
|
-
]), this) : (super.on(a,
|
|
6826
|
+
]), this) : (super.on(a, n), this);
|
|
6788
6827
|
}
|
|
6789
6828
|
}
|
|
6790
6829
|
class M {
|
|
@@ -6799,37 +6838,37 @@ class M {
|
|
|
6799
6838
|
constructor(a) {
|
|
6800
6839
|
window.client instanceof E && (this.prefix = a.prefix ?? this.prefix, this.name = a.name, this.description = a.description ?? this.description, this.arguments = a.arguments ?? this.arguments, this.run = a.run, this.test = a.test ?? this.test, this.aliases = a.aliases ?? this.aliases, this.permissions = a.permissions ?? this.permissions, this.admins = a.admins ?? this.admins, window.client.actions.commands.push(this), window.client.emit("action", this, "created"));
|
|
6801
6840
|
}
|
|
6802
|
-
run(a,
|
|
6841
|
+
run(a, n) {
|
|
6803
6842
|
}
|
|
6804
|
-
verify(a,
|
|
6805
|
-
return this.arguments === !0 && (!
|
|
6843
|
+
verify(a, n, o) {
|
|
6844
|
+
return this.arguments === !0 && (!o || !o.length) ? !1 : this.admins.some((t) => a.toLocaleLowerCase() === t.toLocaleLowerCase()) ? !0 : this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length ? !1 : !!(Array.isArray(this.permissions) && this.permissions.some((t) => a.toLowerCase() === t.toLowerCase() || n.map((e) => e.toLowerCase()).includes(t.toLowerCase())));
|
|
6806
6845
|
}
|
|
6807
|
-
parse(a,
|
|
6846
|
+
parse(a, n) {
|
|
6808
6847
|
if (!(window.client instanceof E)) return !1;
|
|
6809
|
-
const
|
|
6848
|
+
const o = a.replace(this.prefix, "").split(" ").slice(1).map((d) => d.trim());
|
|
6810
6849
|
var t = "", e = [];
|
|
6811
|
-
const
|
|
6812
|
-
switch (
|
|
6850
|
+
const i = { bits: "cheer", premium: "prime" };
|
|
6851
|
+
switch (n.provider) {
|
|
6813
6852
|
case "twitch": {
|
|
6814
|
-
const
|
|
6815
|
-
t =
|
|
6853
|
+
const d = n.data;
|
|
6854
|
+
t = d.event.data.nick || d.event.data.displayName, d.event.data.tags?.badges && (e = d.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((h) => h in i ? i[h] : h));
|
|
6816
6855
|
break;
|
|
6817
6856
|
}
|
|
6818
6857
|
case "youtube": {
|
|
6819
|
-
const
|
|
6858
|
+
const d = n.data, u = {
|
|
6820
6859
|
isVerified: "verified",
|
|
6821
6860
|
isChatOwner: "owner",
|
|
6822
6861
|
isChatSponsor: "sponsor",
|
|
6823
6862
|
isChatModerator: "moderator"
|
|
6824
6863
|
};
|
|
6825
|
-
t =
|
|
6864
|
+
t = d.event.data.nick || d.event.data.displayName, e = Object.entries(d.event.data.authorDetails).filter(([h, m]) => h.startsWith("is") && m).map(([h]) => u[h]).filter(Boolean);
|
|
6826
6865
|
break;
|
|
6827
6866
|
}
|
|
6828
6867
|
case "kick":
|
|
6829
6868
|
return !1;
|
|
6830
6869
|
}
|
|
6831
|
-
const r = this.verify(t, e,
|
|
6832
|
-
return r === !0 && this.run.apply(window.client, [
|
|
6870
|
+
const r = this.verify(t, e, o);
|
|
6871
|
+
return r === !0 && this.run.apply(window.client, [o, n]), r;
|
|
6833
6872
|
}
|
|
6834
6873
|
remove() {
|
|
6835
6874
|
if (!(window.client instanceof E)) return;
|
|
@@ -6838,16 +6877,16 @@ class M {
|
|
|
6838
6877
|
}
|
|
6839
6878
|
static execute(a) {
|
|
6840
6879
|
if (!(window.client instanceof E)) return !1;
|
|
6841
|
-
const
|
|
6880
|
+
const n = a.data;
|
|
6842
6881
|
try {
|
|
6843
|
-
if (window.client.actions.commands.length && window.client.actions.commands.some((
|
|
6844
|
-
const
|
|
6845
|
-
var e = [t.name, ...t.aliases ?? []],
|
|
6846
|
-
return e.includes(
|
|
6882
|
+
if (window.client.actions.commands.length && window.client.actions.commands.some((o) => n.event.data.text.startsWith(o.prefix))) {
|
|
6883
|
+
const o = window.client.actions.commands.filter((t) => {
|
|
6884
|
+
var e = [t.name, ...t.aliases ?? []], i = n.event.data.text.replace(t.prefix, "").split(" ")[0];
|
|
6885
|
+
return e.includes(i);
|
|
6847
6886
|
});
|
|
6848
|
-
if (
|
|
6849
|
-
return
|
|
6850
|
-
t.parse(
|
|
6887
|
+
if (o.length && o.every((t) => t instanceof M))
|
|
6888
|
+
return o.forEach((t) => {
|
|
6889
|
+
t.parse(n.event.data.text, a), window.client.emit("action", t, "executed"), J.received(`Command executed: ${n.event.data.text} by ${n.event.data.nick || n.event.data.displayName}`, n);
|
|
6851
6890
|
}), !0;
|
|
6852
6891
|
}
|
|
6853
6892
|
} catch {
|
|
@@ -6857,7 +6896,7 @@ class M {
|
|
|
6857
6896
|
}
|
|
6858
6897
|
}
|
|
6859
6898
|
}
|
|
6860
|
-
class
|
|
6899
|
+
class mt extends N {
|
|
6861
6900
|
queue = [];
|
|
6862
6901
|
priorityQueue = [];
|
|
6863
6902
|
history = [];
|
|
@@ -6871,15 +6910,15 @@ class lt extends O {
|
|
|
6871
6910
|
this.emit("load"), this.loaded = !0;
|
|
6872
6911
|
}));
|
|
6873
6912
|
}
|
|
6874
|
-
enqueue(a,
|
|
6875
|
-
const
|
|
6913
|
+
enqueue(a, n = {}) {
|
|
6914
|
+
const o = {
|
|
6876
6915
|
isoDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6877
|
-
isLoop:
|
|
6878
|
-
isPriority:
|
|
6879
|
-
isImmediate:
|
|
6916
|
+
isLoop: n?.isLoop ?? !1,
|
|
6917
|
+
isPriority: n?.isPriority ?? !1,
|
|
6918
|
+
isImmediate: n?.isImmediate ?? !1,
|
|
6880
6919
|
value: a
|
|
6881
6920
|
}, t = this.hasItems();
|
|
6882
|
-
return
|
|
6921
|
+
return o.isPriority && o.isImmediate ? (this.cancel(), this.priorityQueue.unshift(o)) : (o.isPriority ? this.priorityQueue : this.queue).push(o), this.running === !1 && t === !1 && this.run(), this.emit("update", this.queue, this.priorityQueue, this.history, this.timeouts), this;
|
|
6883
6922
|
}
|
|
6884
6923
|
async run() {
|
|
6885
6924
|
if (!this.hasItems()) {
|
|
@@ -6896,12 +6935,12 @@ class lt extends O {
|
|
|
6896
6935
|
}
|
|
6897
6936
|
try {
|
|
6898
6937
|
await this.processor.apply(this, [a.value, this]), this.emit("process", a, this);
|
|
6899
|
-
} catch (
|
|
6900
|
-
J.error(`Error during item processing: ${
|
|
6938
|
+
} catch (o) {
|
|
6939
|
+
J.error(`Error during item processing: ${o instanceof Error ? o.message : String(o)}`);
|
|
6901
6940
|
}
|
|
6902
6941
|
this.history.push(a);
|
|
6903
|
-
const
|
|
6904
|
-
a.isLoop &&
|
|
6942
|
+
const n = a.isPriority ? this.priorityQueue : this.queue;
|
|
6943
|
+
a.isLoop && n.push(a);
|
|
6905
6944
|
}
|
|
6906
6945
|
resume() {
|
|
6907
6946
|
return this.running && this.cancel(), this.hasItems() && this.run(), this;
|
|
@@ -6915,21 +6954,21 @@ class lt extends O {
|
|
|
6915
6954
|
hasItems() {
|
|
6916
6955
|
return this.queue.length > 0 || this.priorityQueue.length > 0;
|
|
6917
6956
|
}
|
|
6918
|
-
on(a,
|
|
6919
|
-
return a === "load" && this.loaded ? (
|
|
6957
|
+
on(a, n) {
|
|
6958
|
+
return a === "load" && this.loaded ? (n.apply(this), this) : (super.on(a, n), this);
|
|
6920
6959
|
}
|
|
6921
6960
|
}
|
|
6922
|
-
class
|
|
6961
|
+
class _ {
|
|
6923
6962
|
field = "button";
|
|
6924
6963
|
template = "button";
|
|
6925
6964
|
run;
|
|
6926
6965
|
constructor(a) {
|
|
6927
6966
|
window.client instanceof E && (this.field = a.field ?? this.field, this.template = a.template ?? this.template, this.run = a.run, window.client.actions.buttons.push(this), window.client.emit("action", this, "created"));
|
|
6928
6967
|
}
|
|
6929
|
-
parse(a,
|
|
6930
|
-
var
|
|
6968
|
+
parse(a, n) {
|
|
6969
|
+
var o = a.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
|
|
6931
6970
|
try {
|
|
6932
|
-
this.run.apply(window.client, [
|
|
6971
|
+
this.run.apply(window.client, [o.length ? o : a ?? a, n]);
|
|
6933
6972
|
} catch (t) {
|
|
6934
6973
|
throw new Error(`Error running button "${this.field}": ${t instanceof Error ? t.message : t}`);
|
|
6935
6974
|
}
|
|
@@ -6940,15 +6979,15 @@ class W {
|
|
|
6940
6979
|
const a = window.client.actions.buttons.indexOf(this);
|
|
6941
6980
|
a > -1 && (window.client.actions.buttons.splice(a, 1), window.client.emit("action", this, "removed"));
|
|
6942
6981
|
}
|
|
6943
|
-
static execute(a,
|
|
6982
|
+
static execute(a, n) {
|
|
6944
6983
|
try {
|
|
6945
6984
|
if (!(window.client instanceof E)) return !1;
|
|
6946
6985
|
if (window.client.actions.buttons.length) {
|
|
6947
|
-
const
|
|
6948
|
-
if (
|
|
6949
|
-
return
|
|
6986
|
+
const o = window.client.actions.buttons.filter((t) => typeof t.field == "string" ? t.field === a : typeof t.field == "function" ? t.field(a, n) : !1);
|
|
6987
|
+
if (o.length && o.every((t) => t instanceof _))
|
|
6988
|
+
return o.forEach((t) => {
|
|
6950
6989
|
try {
|
|
6951
|
-
t.parse(a,
|
|
6990
|
+
t.parse(a, n), window.client.emit("action", t, "executed"), J.received(`Button executed: ${a}${n ? ` with value: ${n}` : ""}`);
|
|
6952
6991
|
} catch (e) {
|
|
6953
6992
|
J.error(`Error executing button "${a}": ${e instanceof Error ? e.message : e}`);
|
|
6954
6993
|
}
|
|
@@ -7034,21 +7073,21 @@ class B {
|
|
|
7034
7073
|
this.enabled = a.enabled ?? !0, this.prefix = a.prefix ? `[${a.prefix}]` : "";
|
|
7035
7074
|
}
|
|
7036
7075
|
apply(a) {
|
|
7037
|
-
const
|
|
7076
|
+
const n = this.style(a), o = a.icon ? `${a.icon} ` : "";
|
|
7038
7077
|
return (...t) => {
|
|
7039
7078
|
if (!this.enabled || typeof console > "u") return;
|
|
7040
|
-
const e = this.prefix ? `${this.prefix} ` : "",
|
|
7041
|
-
if (t.forEach((
|
|
7042
|
-
typeof
|
|
7043
|
-
}),
|
|
7044
|
-
const
|
|
7045
|
-
console.log(`%c${
|
|
7046
|
-
} else r.length > 0 && console.log(`%c${
|
|
7079
|
+
const e = this.prefix ? `${this.prefix} ` : "", i = [], r = [];
|
|
7080
|
+
if (t.forEach((d) => {
|
|
7081
|
+
typeof d == "string" || typeof d == "number" || typeof d == "boolean" ? i.push(d) : r.push(d);
|
|
7082
|
+
}), i.length > 0) {
|
|
7083
|
+
const d = i.join(" ");
|
|
7084
|
+
console.log(`%c${o}${e}${d}`, n, ...r);
|
|
7085
|
+
} else r.length > 0 && console.log(`%c${o}${e}`, n, ...r);
|
|
7047
7086
|
};
|
|
7048
7087
|
}
|
|
7049
7088
|
style(a) {
|
|
7050
|
-
const
|
|
7051
|
-
return a.background && a.background !== "transparent" && (
|
|
7089
|
+
const n = [];
|
|
7090
|
+
return a.background && a.background !== "transparent" && (n.push(`background: ${a.background}`), n.push("padding: 2px 6px"), n.push("border-radius: 3px")), a.color && n.push(`color: ${a.color}`), a.bold && n.push("font-weight: bold"), a.italic && n.push("font-style: italic"), a.fontSize && n.push(`font-size: ${a.fontSize}px`), n.join("; ");
|
|
7052
7091
|
}
|
|
7053
7092
|
group(a) {
|
|
7054
7093
|
!this.enabled || !console.group || console.group(a);
|
|
@@ -7074,20 +7113,20 @@ window.addEventListener("load", () => {
|
|
|
7074
7113
|
window.addEventListener("onWidgetLoad", async (s) => {
|
|
7075
7114
|
const { detail: a } = s;
|
|
7076
7115
|
if (window.client instanceof E) {
|
|
7077
|
-
const
|
|
7078
|
-
|
|
7079
|
-
...
|
|
7116
|
+
const n = window.client;
|
|
7117
|
+
n.fields = a.fieldData, n.session = a.session.data, n.details = {
|
|
7118
|
+
...n.details,
|
|
7080
7119
|
user: a.channel,
|
|
7081
7120
|
currency: a.currency,
|
|
7082
7121
|
overlay: a.overlay
|
|
7083
|
-
}, a.channel.id && !a.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${a.channel.id}/`).then((
|
|
7084
|
-
if (
|
|
7085
|
-
return
|
|
7086
|
-
|
|
7122
|
+
}, a.channel.id && !a.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${a.channel.id}/`).then((o) => o.json()).then((o) => {
|
|
7123
|
+
if (o.provider)
|
|
7124
|
+
return n.details.provider = o.provider, o.provider;
|
|
7125
|
+
n.details.provider = "local";
|
|
7087
7126
|
}).catch(() => {
|
|
7088
|
-
|
|
7089
|
-
}) :
|
|
7090
|
-
if (
|
|
7127
|
+
n.details.provider = "local";
|
|
7128
|
+
}) : n.details.provider = "local", n.emit("load", a), n.loaded = !0, n.storage.on("load", (o) => {
|
|
7129
|
+
if (o) {
|
|
7091
7130
|
const t = (u) => {
|
|
7092
7131
|
const h = Date.now(), m = {};
|
|
7093
7132
|
for (const g in u)
|
|
@@ -7096,18 +7135,18 @@ window.addEventListener("onWidgetLoad", async (s) => {
|
|
|
7096
7135
|
f.expire && f.expire > h && (m[g] = f);
|
|
7097
7136
|
}
|
|
7098
7137
|
return m;
|
|
7099
|
-
}, e = t(
|
|
7100
|
-
|
|
7138
|
+
}, e = t(o.user || {}), i = t(o.avatar || {}), r = t(o.pronoun || {}), d = t(o.emote || {});
|
|
7139
|
+
n.storage.update({
|
|
7101
7140
|
user: e,
|
|
7102
|
-
avatar:
|
|
7141
|
+
avatar: i,
|
|
7103
7142
|
pronoun: r,
|
|
7104
|
-
emote:
|
|
7143
|
+
emote: d
|
|
7105
7144
|
});
|
|
7106
7145
|
}
|
|
7107
|
-
a.channel.providerId.length &&
|
|
7146
|
+
a.channel.providerId.length && n.storage.add(`avatar.${a.channel.providerId.toLowerCase()}`, {
|
|
7108
7147
|
value: a.channel.avatar,
|
|
7109
7148
|
timestamp: Date.now(),
|
|
7110
|
-
expire: Date.now() +
|
|
7149
|
+
expire: Date.now() + n.cache.avatar * 60 * 1e3
|
|
7111
7150
|
});
|
|
7112
7151
|
});
|
|
7113
7152
|
}
|
|
@@ -7115,8 +7154,8 @@ window.addEventListener("onWidgetLoad", async (s) => {
|
|
|
7115
7154
|
window.addEventListener("onSessionUpdate", (s) => {
|
|
7116
7155
|
const { detail: a } = s;
|
|
7117
7156
|
if (window.client instanceof E) {
|
|
7118
|
-
const
|
|
7119
|
-
|
|
7157
|
+
const n = window.client;
|
|
7158
|
+
n.session = a.session, n.emit("session", a.session);
|
|
7120
7159
|
}
|
|
7121
7160
|
});
|
|
7122
7161
|
window.addEventListener("onEventReceived", ({ detail: s }) => {
|
|
@@ -7139,8 +7178,8 @@ window.addEventListener("onEventReceived", ({ detail: s }) => {
|
|
|
7139
7178
|
case "event:test": {
|
|
7140
7179
|
switch (e.event.listener) {
|
|
7141
7180
|
case "widget-button": {
|
|
7142
|
-
const
|
|
7143
|
-
|
|
7181
|
+
const i = e.event;
|
|
7182
|
+
_.execute(i.field, i.value);
|
|
7144
7183
|
break;
|
|
7145
7184
|
}
|
|
7146
7185
|
case "subscriber-latest": {
|
|
@@ -7151,10 +7190,10 @@ window.addEventListener("onEventReceived", ({ detail: s }) => {
|
|
|
7151
7190
|
break;
|
|
7152
7191
|
}
|
|
7153
7192
|
case "kvstore:update": {
|
|
7154
|
-
const
|
|
7155
|
-
if (
|
|
7156
|
-
var
|
|
7157
|
-
|
|
7193
|
+
const i = e.event;
|
|
7194
|
+
if (O.length) {
|
|
7195
|
+
var n = O.find((r) => r.id === i.data.key.replace("customWidget.", ""));
|
|
7196
|
+
n && n.update(i.data.value);
|
|
7158
7197
|
}
|
|
7159
7198
|
break;
|
|
7160
7199
|
}
|
|
@@ -7163,8 +7202,8 @@ window.addEventListener("onEventReceived", ({ detail: s }) => {
|
|
|
7163
7202
|
break;
|
|
7164
7203
|
}
|
|
7165
7204
|
case "alertService:toggleSound": {
|
|
7166
|
-
const
|
|
7167
|
-
client.details.overlay.muted = !!
|
|
7205
|
+
const i = e.event;
|
|
7206
|
+
client.details.overlay.muted = !!i.muted;
|
|
7168
7207
|
break;
|
|
7169
7208
|
}
|
|
7170
7209
|
}
|
|
@@ -7240,18 +7279,33 @@ window.addEventListener("onEventReceived", ({ detail: s }) => {
|
|
|
7240
7279
|
}
|
|
7241
7280
|
}
|
|
7242
7281
|
});
|
|
7243
|
-
const K = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(
|
|
7244
|
-
USE_SE_API: K,
|
|
7245
|
-
Simulation: A,
|
|
7282
|
+
const K = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(lt()), J = new B(), ut = {
|
|
7246
7283
|
Client: E,
|
|
7284
|
+
USE_SE_API: K,
|
|
7285
|
+
Simulation: T,
|
|
7247
7286
|
logger: J,
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7287
|
+
Alejo: R,
|
|
7288
|
+
utils: {
|
|
7289
|
+
findEmotesInText: V,
|
|
7290
|
+
replaceEmotesWithHTML: q,
|
|
7291
|
+
replaceYoutubeEmotesWithHTML: ht,
|
|
7292
|
+
generateBadges: G
|
|
7293
|
+
},
|
|
7294
|
+
modules: {
|
|
7295
|
+
Button: _,
|
|
7296
|
+
Command: M,
|
|
7297
|
+
EventProvider: N,
|
|
7298
|
+
useStorage: W,
|
|
7299
|
+
useQueue: mt,
|
|
7300
|
+
Logger: B
|
|
7301
|
+
},
|
|
7302
|
+
data: {
|
|
7303
|
+
usedStorages: O
|
|
7304
|
+
}
|
|
7251
7305
|
};
|
|
7252
|
-
typeof window < "u" && (window.Tixyel =
|
|
7306
|
+
typeof window < "u" && (window.Tixyel = ut);
|
|
7253
7307
|
export {
|
|
7254
|
-
|
|
7308
|
+
ut as Tixyel,
|
|
7255
7309
|
K as USE_SE_API,
|
|
7256
7310
|
J as logger
|
|
7257
7311
|
};
|