@tixyel/streamelements 2.0.0 → 3.0.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.es.js CHANGED
@@ -1,4 +1,4 @@
1
- class N {
1
+ class D {
2
2
  constructor() {
3
3
  this.registeredEvents = {};
4
4
  }
@@ -8,38 +8,38 @@ class N {
8
8
  * @param eventName The name of the event.
9
9
  * @param args Arguments to pass to the listeners.
10
10
  */
11
- emit(e, ...n) {
12
- return (this.registeredEvents[e] || []).map((t) => t.apply(this, n));
11
+ emit(e, ...a) {
12
+ return (this.registeredEvents[e] || []).map((n) => n.apply(this, a));
13
13
  }
14
14
  /**
15
15
  * Registers an event listener.
16
16
  * @param eventName The name of the event.
17
17
  * @param callback The callback function.
18
18
  */
19
- on(e, n) {
20
- if (typeof n != "function")
19
+ on(e, a) {
20
+ if (typeof a != "function")
21
21
  throw new TypeError("Callback must be a function");
22
- return this.registeredEvents[e] || (this.registeredEvents[e] = []), this.registeredEvents[e].push(n), this;
22
+ return this.registeredEvents[e] || (this.registeredEvents[e] = []), this.registeredEvents[e].push(a), this;
23
23
  }
24
24
  /**
25
25
  * Removes a specific event listener.
26
26
  * @param eventName The name of the event.
27
27
  * @param callback The callback function to remove.
28
28
  */
29
- off(e, n) {
30
- const a = this.registeredEvents[e] || [];
31
- return n ? (this.registeredEvents[e] = a.filter((t) => t !== n), this) : (this.registeredEvents[e] = [], this);
29
+ off(e, a) {
30
+ const t = this.registeredEvents[e] || [];
31
+ return a ? (this.registeredEvents[e] = t.filter((n) => n !== a), this) : (this.registeredEvents[e] = [], this);
32
32
  }
33
33
  /**
34
34
  * Registers a listener that is executed only once.
35
35
  * @param eventName The name of the event.
36
36
  * @param callback The callback function.
37
37
  */
38
- once(e, n) {
39
- const a = (...t) => {
40
- this.off(e, a), n.apply(this, t);
38
+ once(e, a) {
39
+ const t = (...n) => {
40
+ this.off(e, t), a.apply(this, n);
41
41
  };
42
- return this.on(e, a), this;
42
+ return this.on(e, t), this;
43
43
  }
44
44
  /**
45
45
  * Removes all listeners for a specific event.
@@ -49,14 +49,15 @@ class N {
49
49
  return this.registeredEvents[e] = [], this;
50
50
  }
51
51
  }
52
- class P extends N {
52
+ var U = [];
53
+ class G extends D {
53
54
  constructor(e) {
54
55
  if (super(), this.id = "default", this.loaded = !1, this.id = e.id || this.id, this.data = e.data ?? {}, !SE_API || !SE_API.store) throw new Error("SE_API.store is not available");
55
- SE_API.store.get(this.id).then((n) => {
56
- this.data = n ?? this.data, this.loaded = !0, this.emit("load", this.data);
56
+ SE_API.store.get(this.id).then((a) => {
57
+ this.data = a ?? this.data, this.loaded = !0, this.emit("load", this.data), JSON.stringify(this.data) !== JSON.stringify(a) && this.emit("update", this.data);
57
58
  }).catch(() => {
58
59
  this.loaded = !0, this.emit("load", null);
59
- });
60
+ }), U.push(this);
60
61
  }
61
62
  /**
62
63
  * Saves the current data to storage.
@@ -65,21 +66,40 @@ class P extends N {
65
66
  save(e = this.data) {
66
67
  this.loaded && (this.data = e, SE_API.store.set(this.id, this.data), this.emit("save", this.data));
67
68
  }
68
- add(e, n) {
69
- this.loaded && (this.setByPath(this.data, e, n), this.save(this.data));
69
+ /**
70
+ * Updates the storage data and emits an update event if the data has changed.
71
+ * @param data Data to update (defaults to current)
72
+ */
73
+ update(e = this.data) {
74
+ this.loaded && JSON.stringify(this.data) !== JSON.stringify(e) && (this.data = { ...this.data, ...e }, this.emit("update", this.data));
75
+ }
76
+ /**
77
+ * Adds a value to the storage at the specified path.
78
+ * @param path Path to add the value to
79
+ * @param value Value to add
80
+ */
81
+ add(e, a) {
82
+ this.loaded && (G.setByPath(this.data, e, a), this.save(this.data));
70
83
  }
71
- setByPath(e, n, a) {
72
- const t = n.split(".");
73
- let d = e;
74
- for (let c = 0; c < t.length - 1; c++)
75
- (typeof d[t[c]] != "object" || d[t[c]] == null) && (d[t[c]] = {}), d = d[t[c]];
76
- d[t[t.length - 1]] = a;
84
+ /**
85
+ * Sets a value in the storage at the specified path.
86
+ * @param obj The object to set the value in
87
+ * @param path The path to set the value at
88
+ * @param value The value to set
89
+ * @returns The updated object
90
+ */
91
+ static setByPath(e, a, t) {
92
+ const n = a.split(".");
93
+ let r = e;
94
+ for (let d = 0; d < n.length - 1; d++)
95
+ (typeof r[n[d]] != "object" || r[n[d]] == null) && (r[n[d]] = {}), r = r[n[d]];
96
+ return r[n[n.length - 1]] = t, r;
77
97
  }
78
- on(e, n) {
79
- return e === "load" && this.loaded ? (n.apply(this, [this.data]), this) : (super.on(e, n), this);
98
+ on(e, a) {
99
+ return e === "load" && this.loaded ? (a.apply(this, [this.data]), this) : (super.on(e, a), this);
80
100
  }
81
101
  }
82
- class I extends N {
102
+ class E extends D {
83
103
  constructor(e) {
84
104
  super(), this.id = "default", this.fields = {}, this.loaded = !1, this.actions = {
85
105
  commands: [],
@@ -88,7 +108,7 @@ class I extends N {
88
108
  avatar: 30,
89
109
  pronoun: 30,
90
110
  emote: 30
91
- }, this.id = e.id || this.id, window.client = this, this.storage = new P({
111
+ }, this.id = e.id || this.id, this.storage = new G({
92
112
  id: this.id,
93
113
  data: {
94
114
  user: {},
@@ -96,10 +116,10 @@ class I extends N {
96
116
  pronoun: {},
97
117
  emote: {}
98
118
  }
99
- });
119
+ }), window.client = this;
100
120
  }
101
- on(e, n) {
102
- return e === "load" && this.loaded ? (n.apply(this, [
121
+ on(e, a) {
122
+ return e === "load" && this.loaded ? (a.apply(this, [
103
123
  {
104
124
  channel: this.details.user,
105
125
  currency: this.details.currency,
@@ -116,51 +136,51 @@ class I extends N {
116
136
  overlay: this.details.overlay,
117
137
  emulated: !1
118
138
  }
119
- ]), this) : (super.on(e, n), this);
139
+ ]), this) : (super.on(e, a), this);
120
140
  }
121
141
  }
122
- var z = /* @__PURE__ */ ((u) => (u.hehim = "He/Him", u.sheher = "She/Her", u.theythem = "They/Them", u.shethem = "She/They", u.hethem = "He/They", u.heshe = "He/She", u.xexem = "Xe/Xem", u.faefaer = "Fae/Faer", u.vever = "Ve/Ver", u.aeaer = "Ae/Aer", u.ziehir = "Zie/Hir", u.perper = "Per/Per", u.eem = "E/Em", u.itits = "It/Its", u))(z || {});
123
- function D(u, e = L.data.emotes) {
124
- const n = [];
125
- return e.forEach((a) => {
126
- const t = a.name;
127
- let d = 0, c = 0;
128
- for (; d < u.length; ) {
129
- const i = u.indexOf(t, c);
130
- if (i === -1) break;
131
- const l = i > 0 ? u[i - 1] : " ", y = i + t.length < u.length ? u[i + t.length] : " ";
132
- /\s/.test(l) && /\s/.test(y) && n.push({ ...a, start: i, end: i + t.length }), c = i + 1;
142
+ var H = /* @__PURE__ */ ((u) => (u.hehim = "He/Him", u.sheher = "She/Her", u.theythem = "They/Them", u.shethem = "She/They", u.hethem = "He/They", u.heshe = "He/She", u.xexem = "Xe/Xem", u.faefaer = "Fae/Faer", u.vever = "Ve/Ver", u.aeaer = "Ae/Aer", u.ziehir = "Zie/Hir", u.perper = "Per/Per", u.eem = "E/Em", u.itits = "It/Its", u))(H || {});
143
+ function N(u, e = j.data.emotes) {
144
+ const a = [];
145
+ return e.forEach((t) => {
146
+ const n = t.name;
147
+ let r = 0, d = 0;
148
+ for (; r < u.length; ) {
149
+ const o = u.indexOf(n, d);
150
+ if (o === -1) break;
151
+ const c = o > 0 ? u[o - 1] : " ", w = o + n.length < u.length ? u[o + n.length] : " ";
152
+ /\s/.test(c) && /\s/.test(w) && a.push({ ...t, start: o, end: o + n.length }), d = o + 1;
133
153
  }
134
- }), n.sort((a, t) => a.start - t.start);
154
+ }), a.sort((t, n) => t.start - n.start);
135
155
  }
136
- function G(u, e) {
156
+ function B(u, e) {
137
157
  if (!e.length) return u;
138
- let n = "", a = 0;
139
- return e.forEach((t) => {
140
- n += u.substring(a, t.start);
141
- const d = t.urls[4] || t.urls[2] || t.urls[1];
142
- n += `<img src="${d}" alt="${t.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, a = t.end;
143
- }), n += u.substring(a), n;
158
+ let a = "", t = 0;
159
+ return e.forEach((n) => {
160
+ a += u.substring(t, n.start);
161
+ const r = n.urls[4] || n.urls[2] || n.urls[1];
162
+ a += `<img src="${r}" alt="${n.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, t = n.end;
163
+ }), a += u.substring(t), a;
144
164
  }
145
- async function U(u = [], e = "twitch") {
146
- if (!Array.isArray(u) && typeof u == "string" && (u = u.split(",").map((c) => c.trim())), !u || !u.length) {
147
- var n = L.rand.number(1, 3);
148
- for await (const c of Array.from({ length: n }, () => "")) {
149
- var a = L.rand.array(Object.keys(L.data.badges))[0];
150
- !u.includes(a) && Array.isArray(u) ? u.push(a) : u = [a];
165
+ async function z(u = [], e = "twitch") {
166
+ if (!Array.isArray(u) && typeof u == "string" && (u = u.split(",").map((d) => d.trim())), !u || !u.length) {
167
+ var a = j.rand.number(1, 3);
168
+ for await (const d of Array.from({ length: a }, () => "")) {
169
+ var t = j.rand.array(Object.keys(j.data.badges))[0];
170
+ !u.includes(t) && Array.isArray(u) ? u.push(t) : u = [t];
151
171
  }
152
172
  }
153
- var t;
173
+ var n;
154
174
  switch (e) {
155
175
  case "twitch": {
156
- t = {
157
- keys: Array.from(u).filter((c) => c in L.data.badges),
158
- badges: Array.from(u).slice(0, 3).map((c) => L.data.badges[c]).filter(Boolean)
176
+ n = {
177
+ keys: Array.from(u).filter((d) => d in j.data.badges),
178
+ badges: Array.from(u).slice(0, 3).map((d) => j.data.badges[d]).filter(Boolean)
159
179
  };
160
180
  break;
161
181
  }
162
182
  case "youtube": {
163
- var d = {
183
+ var r = {
164
184
  verified: { isVerified: !1 },
165
185
  broadcaster: { isChatOwner: !1 },
166
186
  host: { isChatOwner: !1 },
@@ -168,8 +188,8 @@ async function U(u = [], e = "twitch") {
168
188
  subscriber: { isChatSponsor: !1 },
169
189
  moderator: { isChatModerator: !1 }
170
190
  };
171
- t = Object.entries(u).reduce(
172
- (c, [i]) => (i in d && Object.assign(c, d[i]), c),
191
+ n = Object.entries(u).reduce(
192
+ (d, [o]) => (o in r && Object.assign(d, r[o]), d),
173
193
  {
174
194
  isVerified: !1,
175
195
  isChatOwner: !1,
@@ -180,11 +200,11 @@ async function U(u = [], e = "twitch") {
180
200
  break;
181
201
  }
182
202
  }
183
- return t;
203
+ return n;
184
204
  }
185
- const r = class r {
205
+ const s = class s {
186
206
  static fields(e) {
187
- const n = {
207
+ const a = {
188
208
  from: "main",
189
209
  endsWith: [],
190
210
  ignore: [],
@@ -234,128 +254,181 @@ const r = class r {
234
254
  ]
235
255
  }
236
256
  };
237
- function a(m) {
257
+ function t(m) {
238
258
  return {
239
- ...n,
259
+ ...a,
240
260
  ...m,
241
- endsWith: Array.isArray(m.endsWith) ? m.endsWith : n.endsWith,
242
- ignore: Array.isArray(m.ignore) ? m.ignore : n.ignore,
243
- replace: { ...n.replace, ...m.replace ?? {} },
261
+ endsWith: Array.isArray(m.endsWith) ? m.endsWith : a.endsWith,
262
+ ignore: Array.isArray(m.ignore) ? m.ignore : a.ignore,
263
+ replace: { ...a.replace, ...m.replace ?? {} },
244
264
  settings: {
245
- types: Array.isArray(m.settings?.types) ? m.settings.types : n.settings.types,
246
- addons: Array.isArray(m.settings?.addons) ? m.settings.addons : n.settings.addons,
247
- transforms: Array.isArray(m.settings?.transforms) ? m.settings.transforms : n.settings.transforms,
248
- labels: Array.isArray(m.settings?.labels) ? m.settings.labels : n.settings.labels
265
+ types: Array.isArray(m.settings?.types) ? m.settings.types : a.settings.types,
266
+ addons: Array.isArray(m.settings?.addons) ? m.settings.addons : a.settings.addons,
267
+ transforms: Array.isArray(m.settings?.transforms) ? m.settings.transforms : a.settings.transforms,
268
+ labels: Array.isArray(m.settings?.labels) ? m.settings.labels : a.settings.labels
249
269
  },
250
- subgroup: m.subgroup ?? n.subgroup,
251
- template: m.template ?? n.template,
252
- subgroupTemplate: m.subgroupTemplate ?? n.subgroupTemplate,
253
- from: m.from ?? n.from
270
+ subgroup: m.subgroup ?? a.subgroup,
271
+ template: m.template ?? a.template,
272
+ subgroupTemplate: m.subgroupTemplate ?? a.subgroupTemplate,
273
+ from: m.from ?? a.from
254
274
  };
255
275
  }
256
- const t = a(e), c = Array.from(document.styleSheets).filter(({ href: m }) => !m || m.startsWith(window.location.origin)).reduce(
257
- (m, { cssRules: v }) => (v && Array.from(v).forEach((b) => {
258
- b instanceof CSSStyleRule && b.selectorText === t.from && Array.from(b.style).some((s) => s.startsWith("--")) && Array.from(b.style).filter((s) => s.startsWith("--")).forEach((s) => {
259
- m[s] = b.style.getPropertyValue(s).trim();
276
+ const n = t(e), d = Array.from(document.styleSheets).filter(({ href: m }) => !m || m.startsWith(window.location.origin)).reduce(
277
+ (m, { cssRules: b }) => (b && Array.from(b).forEach((y) => {
278
+ y instanceof CSSStyleRule && y.selectorText === n.from && Array.from(y.style).some((i) => i.startsWith("--")) && Array.from(y.style).filter((i) => i.startsWith("--")).forEach((i) => {
279
+ m[i] = y.style.getPropertyValue(i).trim();
260
280
  });
261
281
  }), m),
262
282
  {}
263
- ), i = Object.entries(c).filter(([m]) => t.endsWith.some((v) => m.toLowerCase().endsWith(v.toLowerCase()) && !m.includes("-options-"))).filter(([m]) => !t.ignore.some((v) => m.toLowerCase() === v.toLowerCase())).reduce(
264
- (m, [v, b]) => (m[v.replace("--", "")] = String(t.replace?.[v] ?? b), m),
283
+ ), o = Object.entries(d).filter(([m]) => n.endsWith.some((b) => m.toLowerCase().endsWith(b.toLowerCase()) && !m.includes("-options-"))).filter(([m]) => !n.ignore.some((b) => m.toLowerCase() === b.toLowerCase())).reduce(
284
+ (m, [b, y]) => (m[b.replace("--", "")] = String(n.replace?.[b] ?? y), m),
265
285
  {}
266
286
  );
267
- let l = [];
268
- const y = Object.entries(i).reduce(
269
- (m, [v, b]) => {
270
- let s = t.settings.types.find(([w]) => w.some((g) => v.toLowerCase().includes(g)))?.[1] || "text", o = t.settings.transforms.find(([w]) => w.some((g) => v.toLowerCase().includes(g)))?.[1] || ((w) => w), h = {
287
+ let c = [];
288
+ const w = Object.entries(o).reduce(
289
+ (m, [b, y]) => {
290
+ let i = n.settings.types.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || "text", l = n.settings.transforms.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || ((v) => v), p = {
271
291
  type: "text",
272
- label: t.settings.labels.find(([w]) => w.some((g) => v.toLowerCase().includes(g)))?.[1] || "",
273
- ...t.settings.addons.find(([w]) => w.some((g) => v.toLowerCase().includes(g)))?.[1] || {}
292
+ label: n.settings.labels.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || "",
293
+ ...n.settings.addons.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || {}
274
294
  };
275
- ["min", "max", "step", "label", "type"].forEach((w) => {
276
- const g = c[`--${v}-${w}`];
277
- g && g.length && (h[w] = isNaN(parseFloat(g)) ? String(g).replace(/^['"]|['"]$/g, "") : String(parseFloat(g)));
295
+ ["min", "max", "step", "label", "type"].forEach((v) => {
296
+ const g = d[`--${b}-${v}`];
297
+ g && g.length && (p[v] = isNaN(parseFloat(g)) ? String(g).replace(/^['"]|['"]$/g, "") : String(parseFloat(g)));
278
298
  });
279
- let x = v.replace(/-(size|color|weight|width|height|gap|duration|radius|amount)$/g, "").replace(/-([a-z])/g, (w, g) => g.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase().trim(), k = Object.keys(i).filter(
280
- (w) => w.startsWith(x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1))
299
+ let x = b.replace(/-(size|color|weight|width|height|gap|duration|radius|amount)$/g, "").replace(/-([a-z])/g, (v, g) => g.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase().trim(), k = Object.keys(o).filter(
300
+ (v) => v.startsWith(x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1))
281
301
  );
282
- t.subgroup && !m[`${x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1)}-subgroup`] && k.length > 1 && !l.includes(v) && (l.push(...k), m[`${x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1)}-subgroup`] = {
302
+ n.subgroup && !m[`${x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1)}-subgroup`] && k.length > 1 && !c.includes(b) && (c.push(...k), m[`${x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1)}-subgroup`] = {
283
303
  type: "hidden",
284
- label: t.subgroupTemplate.replaceAll("{key}", r.string.capitalize(x))
304
+ label: n.subgroupTemplate.replaceAll("{key}", s.string.capitalize(x))
285
305
  });
286
- let S = r.string.capitalize(
287
- v.replace(/-([a-z])/g, (w, g) => g.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase()
306
+ let S = s.string.capitalize(
307
+ b.replace(/-([a-z])/g, (v, g) => g.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase()
288
308
  );
289
- b = o(b) ?? b;
290
- const C = (() => {
291
- const w = Object.entries(c).filter(([g]) => g.startsWith(`--${v}-options-`)).reduce(
292
- (g, [E, M]) => {
293
- const T = E.replace(`--${v}-options-`, "");
294
- return T && (g[String(M)] = r.string.capitalize(
295
- T.replace(/-([a-z])/g, (F, B) => B.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase()
309
+ y = l(y) ?? y;
310
+ const M = (() => {
311
+ const v = Object.entries(d).filter(([g]) => g.startsWith(`--${b}-options-`)).reduce(
312
+ (g, [R, A]) => {
313
+ const I = R.replace(`--${b}-options-`, "");
314
+ return I && (g[String(A)] = s.string.capitalize(
315
+ I.replace(/-([a-z])/g, (T, W) => W.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase()
296
316
  )), g;
297
317
  },
298
318
  {}
299
319
  );
300
- return Object.keys(w).length ? w : null;
320
+ return Object.keys(v).length ? v : null;
301
321
  })();
302
- return C && (s = "dropdown", h.options = C, b = String(b)), Object.entries(h).forEach(([w, g]) => {
303
- [!1, "inherit", "auto", null].includes(g) && (h[w] = b);
304
- }), m[v] = {
305
- type: h.type || s,
306
- label: t.template.toString().replaceAll("{key}", r.string.capitalize(S) + h.label),
307
- value: b,
308
- min: h.min,
309
- max: h.max,
310
- step: h.step,
311
- options: h.options
322
+ return M && (i = "dropdown", p.options = M, y = String(y)), Object.entries(p).forEach(([v, g]) => {
323
+ [!1, "inherit", "auto", null].includes(g) && (p[v] = y);
324
+ }), m[b] = {
325
+ type: p.type || i,
326
+ label: n.template.toString().replaceAll("{key}", s.string.capitalize(S) + p.label),
327
+ value: y,
328
+ min: p.min,
329
+ max: p.max,
330
+ step: p.step,
331
+ options: p.options
312
332
  }, m;
313
333
  },
314
334
  {}
315
- ), f = Object.entries(y).reduce(
316
- (m, [v, b]) => {
317
- const s = b?.label?.includes("undefined"), o = !["hidden", "button"].includes(b.type) && b.value === void 0;
318
- return (s || o) && (m[v] = b), m;
335
+ ), h = Object.entries(w).reduce(
336
+ (m, [b, y]) => {
337
+ const i = y?.label?.includes("undefined"), l = !["hidden", "button"].includes(y.type) && y.value === void 0;
338
+ return (i || l) && (m[b] = y), m;
319
339
  },
320
340
  {}
321
341
  );
322
- if (Object.keys(f).length)
323
- throw R.logger.error("Simulation.fields: Detected errors in generated fields:", f), new Error("Error while processing fields");
324
- return y;
342
+ if (Object.keys(h).length)
343
+ throw O.logger.error("Simulation.fields: Detected errors in generated fields:", h), new Error("Error while processing fields");
344
+ return w;
325
345
  }
326
346
  static async start() {
327
347
  const e = {
328
- fields: ["fields.json", "cf.json", "field.json", "customfields.json"].find((a) => {
348
+ fields: ["fields.json", "cf.json", "field.json", "customfields.json"].find((t) => {
329
349
  try {
330
- return new URL("./" + a, window.location.href), !0;
350
+ return new URL("./" + t, window.location.href), !0;
331
351
  } catch {
332
352
  return !1;
333
353
  }
334
354
  }),
335
- data: ["data.json", "fielddata.json", "fd.json", "DATA.json"].find((a) => {
355
+ data: ["data.json", "fielddata.json", "fd.json", "DATA.json"].find((t) => {
336
356
  try {
337
- return new URL("./" + a, window.location.href), !0;
357
+ return new URL("./" + t, window.location.href), !0;
338
358
  } catch {
339
359
  return !1;
340
360
  }
341
361
  })
342
- }, n = await fetch("./" + (e.data ?? "data.json"), {
362
+ }, a = await fetch("./" + (e.data ?? "data.json"), {
343
363
  cache: "no-store"
344
- }).then((a) => a.json()).catch(() => ({}));
364
+ }).then((t) => t.json()).catch(() => ({}));
345
365
  await fetch("./" + (e.fields ?? "fields.json"), {
346
366
  cache: "no-store"
347
- }).then((a) => a.json()).then(async (a) => {
348
- const t = Object.entries(a).filter(([c, { value: i }]) => i != null).reduce(
349
- (c, [i, { value: l }]) => (n && n[i] !== void 0 && (l = n[i]), c[i] = l, c),
350
- {}
351
- ), d = await r.generate.event.onWidgetLoad(t, await r.generate.session.get());
352
- window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: d }));
367
+ }).then((t) => t.json()).then(async (t) => {
368
+ const n = Object.entries(t).filter(([d, { value: o }]) => o != null).reduce(
369
+ (d, [o, { value: c }]) => (a && a[o] !== void 0 && (c = a[o]), d[o] = c, d),
370
+ {
371
+ ...a
372
+ }
373
+ ), r = await s.generate.event.onWidgetLoad(n, await s.generate.session.get());
374
+ window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: r }));
353
375
  });
354
376
  }
355
377
  };
356
- r.data = {
357
- names: ["local", "tixyel", "urie_s2", "itzzcatt", "beniarts", "cupidiko", "shy_madeit"],
358
- messages: ["Hello!", "How are you?", "Goodbye!", "Have fun!"],
378
+ s.data = {
379
+ names: ["Local", "Tixyel", "Urie_s2", "itzzcatt", "BeniArts", "Cupidiko", "shy_madeit"],
380
+ messages: [
381
+ "Hello everyone!",
382
+ "PogChamp",
383
+ "This stream is amazing!",
384
+ "catJAM catJAM catJAM",
385
+ "LUL that was funny",
386
+ "GG!",
387
+ "First time here, loving it!",
388
+ "DinoDance",
389
+ "Can we get some hype in chat?",
390
+ "TransgenderPride PansexualPride NonbinaryPride",
391
+ "POGGERS",
392
+ "I just followed! PogChamp",
393
+ "Great gameplay btw",
394
+ "LUL LUL LUL",
395
+ "This is so wholesome AngelThump",
396
+ "catJAM vibing",
397
+ "haHAA",
398
+ "Wait what just happened? D:",
399
+ "GlitchCat GlitchCat",
400
+ "Best stream on Twitch right now!",
401
+ "DarkMode gang where you at?",
402
+ "PogChamp PogChamp PogChamp PogChamp",
403
+ "Anyone else eating? DoritosChip",
404
+ "I love this community!",
405
+ "TheIlluminati confirmed",
406
+ "bUrself be yourself!",
407
+ "CookieTime nom nom",
408
+ "imGlitch technical difficulties",
409
+ "This music is fire catJAM",
410
+ "bttvNice",
411
+ "LesbianPride GayPride BisexualPride",
412
+ "SSSsss Minecraft time",
413
+ "PopNemo",
414
+ "Going to bed, good night everyone!",
415
+ "Just got here, what did I miss?",
416
+ ":tf: trollface",
417
+ "ariW wave",
418
+ "BroBalt nice one",
419
+ "AsexualPride IntersexPride GenderFluidPride",
420
+ "This chat is moving so fast!",
421
+ "CandianRage",
422
+ "PunchTrees PunchTrees",
423
+ "CiGrip",
424
+ "ConcernDoge hmm",
425
+ "CruW salute",
426
+ "cvHazmat stay safe",
427
+ "DuckerZ quack",
428
+ "BloodTrail hunting time",
429
+ "CatBag kitty!",
430
+ "c! poggers"
431
+ ],
359
432
  tiers: ["1000", "2000", "3000", "prime"],
360
433
  avatars: [
361
434
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/13e5fa74-defa-11e9-809c-784f43822e80-profile_image-300x300.png",
@@ -1115,7 +1188,7 @@ r.data = {
1115
1188
  description: "VIP"
1116
1189
  }
1117
1190
  },
1118
- pronouns: z,
1191
+ pronouns: H,
1119
1192
  tts: [
1120
1193
  "Filiz",
1121
1194
  "Astrid",
@@ -1205,21 +1278,21 @@ r.data = {
1205
1278
  "Hoda",
1206
1279
  "Naayf"
1207
1280
  ]
1208
- }, r.color = {
1209
- opacity(e = 100, n) {
1210
- n = n.length > 7 ? n.substring(0, 6) : n, e = e > 1 ? e / 100 : e;
1211
- let a = Math.round(Math.min(Math.max(e, 0), 1) * 255).toString(16).toLowerCase();
1212
- return a = a.padStart(2, "0"), n + a;
1281
+ }, s.color = {
1282
+ opacity(e = 100, a) {
1283
+ a = a.length > 7 ? a.substring(0, 6) : a, e = e > 1 ? e / 100 : e;
1284
+ let t = Math.round(Math.min(Math.max(e, 0), 1) * 255).toString(16).toLowerCase();
1285
+ return t = t.padStart(2, "0"), a + t;
1213
1286
  },
1214
1287
  getOpacity(e) {
1215
1288
  if (!e.startsWith("#") || e.length <= 7) return { opacity: 100, hex: e };
1216
- var n = e.slice(-2), a = parseInt(n, 16) / 255, t = Math.round(a * 100), d = e.length > 7 ? e.slice(0, 7) : e;
1217
- return { opacity: t, color: d };
1289
+ var a = e.slice(-2), t = parseInt(a, 16) / 255, n = Math.round(t * 100), r = e.length > 7 ? e.slice(0, 7) : e;
1290
+ return { opacity: n, color: r };
1218
1291
  },
1219
1292
  validate(e) {
1220
1293
  if (typeof e != "string" || !e.length) return !1;
1221
- const n = e.trim();
1222
- return /^#([A-Fa-f0-9]{3}){1,2}$/.test(n) || /^#([A-Fa-f0-9]{4}|[A-Fa-f0-9]{8})$/.test(n) ? "hex" : /^rgb\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)$/.test(n) ? "rgb" : /^rgba\(\s*(?:\d{1,3}\s*,\s*){3}(?:0|1|0?\.\d+)\s*\)$/.test(n) ? "rgba" : /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(n) ? "hsl" : /^hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0|1|0?\.\d+)\s*\)$/.test(n) ? "hsla" : [
1294
+ const a = e.trim();
1295
+ return /^#([A-Fa-f0-9]{3}){1,2}$/.test(a) || /^#([A-Fa-f0-9]{4}|[A-Fa-f0-9]{8})$/.test(a) ? "hex" : /^rgb\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)$/.test(a) ? "rgb" : /^rgba\(\s*(?:\d{1,3}\s*,\s*){3}(?:0|1|0?\.\d+)\s*\)$/.test(a) ? "rgba" : /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(a) ? "hsl" : /^hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0|1|0?\.\d+)\s*\)$/.test(a) ? "hsla" : [
1223
1296
  "aliceblue",
1224
1297
  "antiquewhite",
1225
1298
  "aqua",
@@ -1369,36 +1442,36 @@ r.data = {
1369
1442
  "yellow",
1370
1443
  "yellowgreen",
1371
1444
  "transparent"
1372
- ].includes(n.toLowerCase()) ? "css-color-name" : !1;
1445
+ ].includes(a.toLowerCase()) ? "css-color-name" : !1;
1373
1446
  }
1374
- }, r.rand = {
1447
+ }, s.rand = {
1375
1448
  color(e = "hex") {
1376
1449
  switch (e) {
1377
1450
  default:
1378
1451
  case "hex":
1379
1452
  return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
1380
1453
  case "hexa": {
1381
- const a = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`, t = Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
1382
- return a + t;
1454
+ const t = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`, n = Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
1455
+ return t + n;
1383
1456
  }
1384
1457
  case "rgb": {
1385
- const a = Math.floor(Math.random() * 256), t = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256);
1386
- return `rgb(${a}, ${t}, ${d})`;
1458
+ const t = Math.floor(Math.random() * 256), n = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256);
1459
+ return `rgb(${t}, ${n}, ${r})`;
1387
1460
  }
1388
1461
  case "rgba": {
1389
- const a = Math.floor(Math.random() * 256), t = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256), c = Math.random().toFixed(2);
1390
- return `rgba(${a}, ${t}, ${d}, ${c})`;
1462
+ const t = Math.floor(Math.random() * 256), n = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256), d = Math.random().toFixed(2);
1463
+ return `rgba(${t}, ${n}, ${r}, ${d})`;
1391
1464
  }
1392
1465
  case "hsl": {
1393
- const a = Math.floor(Math.random() * 361), t = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101);
1394
- return `hsl(${a}, ${t}%, ${d}%)`;
1466
+ const t = Math.floor(Math.random() * 361), n = Math.floor(Math.random() * 101), r = Math.floor(Math.random() * 101);
1467
+ return `hsl(${t}, ${n}%, ${r}%)`;
1395
1468
  }
1396
1469
  case "hsla": {
1397
- const a = Math.floor(Math.random() * 361), t = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101), c = Math.random().toFixed(2);
1398
- return `hsla(${a}, ${t}%, ${d}%, ${c})`;
1470
+ const t = Math.floor(Math.random() * 361), n = Math.floor(Math.random() * 101), r = Math.floor(Math.random() * 101), d = Math.random().toFixed(2);
1471
+ return `hsla(${t}, ${n}%, ${r}%, ${d})`;
1399
1472
  }
1400
1473
  case "css-color-name": {
1401
- var n = [
1474
+ var a = [
1402
1475
  "aliceblue",
1403
1476
  "antiquewhite",
1404
1477
  "aqua",
@@ -1549,31 +1622,31 @@ r.data = {
1549
1622
  "yellowgreen",
1550
1623
  "transparent"
1551
1624
  ];
1552
- return this.array(n)[0];
1625
+ return this.array(a)[0];
1553
1626
  }
1554
1627
  }
1555
1628
  },
1556
- number(e, n, a = 0) {
1557
- e > n && ([e, n] = [n, e]);
1558
- const t = Math.random() * (n - e) + e;
1559
- return a ? Number(t.toFixed(a)) : Math.round(t);
1629
+ number(e, a, t = 0) {
1630
+ e > a && ([e, a] = [a, e]);
1631
+ const n = Math.random() * (a - e) + e;
1632
+ return t ? Number(n.toFixed(t)) : Math.round(n);
1560
1633
  },
1561
1634
  boolean(e = 0.5) {
1562
1635
  return Math.random() > e;
1563
1636
  },
1564
- string(e, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
1565
- let a = "";
1566
- for (let t = 0; t < e; t++)
1567
- a += n.charAt(Math.floor(Math.random() * n.length));
1568
- return a;
1637
+ string(e, a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
1638
+ let t = "";
1639
+ for (let n = 0; n < e; n++)
1640
+ t += a.charAt(Math.floor(Math.random() * a.length));
1641
+ return t;
1569
1642
  },
1570
1643
  array(e) {
1571
- const n = this.number(0, e.length - 1);
1572
- return [e[n], n];
1644
+ const a = this.number(0, e.length - 1);
1645
+ return [e[a], a];
1573
1646
  },
1574
1647
  date(e = 365) {
1575
- const a = Date.now() - this.number(0, e * 24 * 60 * 60 * 1e3);
1576
- return new Date(a).toISOString();
1648
+ const t = Date.now() - this.number(0, e * 24 * 60 * 60 * 1e3);
1649
+ return new Date(t).toISOString();
1577
1650
  },
1578
1651
  uuid() {
1579
1652
  return window.crypto && typeof crypto?.randomUUID == "function" ? crypto.randomUUID() : "10000000-1000-4000-8000-100000000000".replace(
@@ -1581,7 +1654,7 @@ r.data = {
1581
1654
  (e) => (+e ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +e / 4).toString(16)
1582
1655
  );
1583
1656
  }
1584
- }, r.string = {
1657
+ }, s.string = {
1585
1658
  /**
1586
1659
  * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
1587
1660
  * @param string - The input string to perform replacements on.
@@ -1596,14 +1669,14 @@ r.data = {
1596
1669
  * console.log(result); // Output will depend on the fetched data
1597
1670
  * ```
1598
1671
  */
1599
- async replace(e, n, a) {
1600
- const t = [];
1601
- e.replace(n, (c, ...i) => {
1602
- const l = typeof a == "function" ? a(c, ...i) : c;
1603
- return t.push(Promise.resolve(l)), c;
1672
+ async replace(e, a, t) {
1673
+ const n = [];
1674
+ e.replace(a, (d, ...o) => {
1675
+ const c = typeof t == "function" ? t(d, ...o) : d;
1676
+ return n.push(Promise.resolve(c)), d;
1604
1677
  });
1605
- const d = await Promise.all(t);
1606
- return e.replace(n, () => d.shift() ?? "");
1678
+ const r = await Promise.all(n);
1679
+ return e.replace(a, () => r.shift() ?? "");
1607
1680
  },
1608
1681
  /**
1609
1682
  * Capitalizes the first letter of a given string.
@@ -1632,47 +1705,47 @@ r.data = {
1632
1705
  * console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
1633
1706
  * ```
1634
1707
  */
1635
- compose(e, n, a = { method: "index", modifiers: {} }) {
1636
- const { mergeSpanStyles: t } = r.element, d = Object.entries(r.object.flatten(n)).reduce(
1637
- (s, [o, p]) => {
1638
- if (s[o] = String(p), ["username", "name", "nick", "nickname", "sender"].some((h) => o === h)) {
1639
- const h = s?.username || s?.name || s?.nick || s?.nickname || s?.sender;
1640
- s.username = s.username || h, s.usernameAt = `@${s.username}`, s.name = s.name || h, s.nick = s.nick || h, s.nickname = s.nickname || h, s.sender = s.sender || h, s.senderAt = `@${s.sender}`;
1708
+ compose(e, a, t = { method: "index", modifiers: {} }) {
1709
+ const { mergeSpanStyles: n } = s.element, r = Object.entries(s.object.flatten(a)).reduce(
1710
+ (i, [l, f]) => {
1711
+ if (i[l] = String(f), ["username", "name", "nick", "nickname", "sender"].some((p) => l === p)) {
1712
+ const p = i?.username || i?.name || i?.nick || i?.nickname || i?.sender;
1713
+ i.username = i.username || p, i.usernameAt = `@${i.username}`, i.name = i.name || p, i.nick = i.nick || p, i.nickname = i.nickname || p, i.sender = i.sender || p, i.senderAt = `@${i.sender}`;
1641
1714
  }
1642
- return ["amount", "count"].some((h) => o === h) && (s.amount = String(i), s.count = String(s?.count || i)), s.currency = s.currency || window.client?.details.currency.symbol || "$", s.currencyCode = s.currencyCode || window.client?.details.currency.code || "USD", s.skip = "<br/>", s.newline = "<br/>", s;
1715
+ return ["amount", "count"].some((p) => l === p) && (i.amount = String(o), i.count = String(i?.count || o)), i.currency = i.currency || window.client?.details.currency.symbol || "$", i.currencyCode = i.currencyCode || window.client?.details.currency.code || "USD", i.skip = "<br/>", i.newline = "<br/>", i;
1643
1716
  },
1644
1717
  {}
1645
- ), c = {
1718
+ ), d = {
1646
1719
  PLACEHOLDERS: /{([^}]+)}/g,
1647
1720
  MODIFIERS: /\[(\w+)(:[^=]+)?=([^\]]+)\]/g
1648
1721
  };
1649
- var i = parseFloat(d?.amount ?? d?.count ?? 0);
1650
- const l = {
1651
- BT1: (s) => i > 1 ? s : "",
1652
- BT0: (s) => i > 0 ? s : "",
1653
- ST1: (s) => i < 1 ? s : "",
1654
- ST0: (s) => i < 0 ? s : "",
1655
- UPC: (s) => s.toUpperCase(),
1656
- LOW: (s) => s.toLowerCase(),
1657
- REV: (s) => s.split("").reverse().join(""),
1658
- CAP: (s) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase(),
1659
- FALLBACK: (s, o) => s.length ? s : o ?? s,
1660
- COLOR: (s, o) => t(o && r.color.validate(o) ? `color: ${o}` : "", s),
1661
- WEIGHT: (s, o) => t(o && !isNaN(parseInt(o)) ? `font-weight: ${o}` : "", s),
1662
- BOLD: (s) => t("font-weight: bold", s),
1663
- LIGHT: (s) => t("font-weight: lighter", s),
1664
- STRONG: (s) => t("font-weight: bolder", s),
1665
- ITALIC: (s) => t("font-style: italic", s),
1666
- UNDERLINE: (s) => t("text-decoration: underline", s),
1667
- STRIKETHROUGH: (s) => t("text-decoration: line-through", s),
1668
- SUB: (s) => t("vertical-align: sub", s),
1669
- SUP: (s) => t("vertical-align: super", s),
1670
- LARGER: (s) => t("font-size: larger", s),
1671
- SMALL: (s) => t("font-size: smaller", s),
1672
- SHADOW: (s, o) => t(`text-shadow: ${o}`, s),
1673
- SIZE: (s, o) => t(o ? `font-size: ${o}` : "", s),
1674
- ...a.modifiers ?? {}
1675
- }, y = {
1722
+ var o = parseFloat(r?.amount ?? r?.count ?? 0);
1723
+ const c = {
1724
+ BT1: (i) => o > 1 ? i : "",
1725
+ BT0: (i) => o > 0 ? i : "",
1726
+ ST1: (i) => o < 1 ? i : "",
1727
+ ST0: (i) => o < 0 ? i : "",
1728
+ UPC: (i) => i.toUpperCase(),
1729
+ LOW: (i) => i.toLowerCase(),
1730
+ REV: (i) => i.split("").reverse().join(""),
1731
+ CAP: (i) => i.charAt(0).toUpperCase() + i.slice(1).toLowerCase(),
1732
+ FALLBACK: (i, l) => i.length ? i : l ?? i,
1733
+ COLOR: (i, l) => n(l && s.color.validate(l) ? `color: ${l}` : "", i),
1734
+ WEIGHT: (i, l) => n(l && !isNaN(parseInt(l)) ? `font-weight: ${l}` : "", i),
1735
+ BOLD: (i) => n("font-weight: bold", i),
1736
+ LIGHT: (i) => n("font-weight: lighter", i),
1737
+ STRONG: (i) => n("font-weight: bolder", i),
1738
+ ITALIC: (i) => n("font-style: italic", i),
1739
+ UNDERLINE: (i) => n("text-decoration: underline", i),
1740
+ STRIKETHROUGH: (i) => n("text-decoration: line-through", i),
1741
+ SUB: (i) => n("vertical-align: sub", i),
1742
+ SUP: (i) => n("vertical-align: super", i),
1743
+ LARGER: (i) => n("font-size: larger", i),
1744
+ SMALL: (i) => n("font-size: smaller", i),
1745
+ SHADOW: (i, l) => n(`text-shadow: ${l}`, i),
1746
+ SIZE: (i, l) => n(l ? `font-size: ${l}` : "", i),
1747
+ ...t.modifiers ?? {}
1748
+ }, w = {
1676
1749
  UPC: ["UPPERCASE", "UPPER", "UPP"],
1677
1750
  LOW: ["LOWERCASE", "LOWER", "LWC"],
1678
1751
  REV: ["REVERSE", "RVS"],
@@ -1694,59 +1767,59 @@ r.data = {
1694
1767
  SHADOW: ["SHADOW", "SHD"],
1695
1768
  FALLBACK: ["FALLBACK", "FB"]
1696
1769
  };
1697
- function f(s, o, p) {
1698
- const h = Object.entries(y).find(([k, S]) => S.some((A) => A.toUpperCase() === o.toUpperCase()) ? !0 : k.toUpperCase() === o.toUpperCase()), x = h ? h[0] : o.toUpperCase();
1699
- return l[x] ? l[x](s, typeof p == "string" ? p.trim() : null, d) : s;
1770
+ function h(i, l, f) {
1771
+ const p = Object.entries(w).find(([k, S]) => S.some((C) => C.toUpperCase() === l.toUpperCase()) ? !0 : k.toUpperCase() === l.toUpperCase()), x = p ? p[0] : l.toUpperCase();
1772
+ return c[x] ? c[x](i, typeof f == "string" ? f.trim() : null, r) : i;
1700
1773
  }
1701
- function m(s) {
1702
- let o = s, p;
1703
- for (; (p = c.MODIFIERS.exec(o)) !== null; ) {
1704
- const [h, x, k, S] = p, A = f(m(S), x, k);
1705
- o = o.replace(h, A ?? ""), c.MODIFIERS.lastIndex = 0;
1774
+ function m(i) {
1775
+ let l = i, f;
1776
+ for (; (f = d.MODIFIERS.exec(l)) !== null; ) {
1777
+ const [p, x, k, S] = f, C = h(m(S), x, k);
1778
+ l = l.replace(p, C ?? ""), d.MODIFIERS.lastIndex = 0;
1706
1779
  }
1707
- return o;
1780
+ return l;
1708
1781
  }
1709
- function v(s) {
1710
- let o = 0;
1711
- const p = s.length;
1712
- function h(k) {
1782
+ function b(i) {
1783
+ let l = 0;
1784
+ const f = i.length;
1785
+ function p(k) {
1713
1786
  let S = "";
1714
- for (; o < p; )
1715
- if (s[o] === "\\")
1716
- o + 1 < p ? (S += s[o + 1], o += 2) : o++;
1717
- else if (s[o] === "[" && (!k || k !== "["))
1787
+ for (; l < f; )
1788
+ if (i[l] === "\\")
1789
+ l + 1 < f ? (S += i[l + 1], l += 2) : l++;
1790
+ else if (i[l] === "[" && (!k || k !== "["))
1718
1791
  S += x();
1719
- else if (k && s[o] === k) {
1720
- o++;
1792
+ else if (k && i[l] === k) {
1793
+ l++;
1721
1794
  break;
1722
1795
  } else
1723
- S += s[o++];
1796
+ S += i[l++];
1724
1797
  return S;
1725
1798
  }
1726
1799
  function x() {
1727
- o++;
1800
+ l++;
1728
1801
  let k = "";
1729
- for (; o < p && /[A-Za-z0-9]/.test(s[o]); ) k += s[o++];
1802
+ for (; l < f && /[A-Za-z0-9]/.test(i[l]); ) k += i[l++];
1730
1803
  let S = null;
1731
- if (s[o] === ":") {
1732
- o++;
1733
- const C = o;
1734
- for (; o < p && s[o] !== "="; ) o++;
1735
- S = s.slice(C, o);
1804
+ if (i[l] === ":") {
1805
+ l++;
1806
+ const M = l;
1807
+ for (; l < f && i[l] !== "="; ) l++;
1808
+ S = i.slice(M, l);
1736
1809
  }
1737
- s[o] === "=" && o++;
1738
- const A = h("]");
1739
- return f(A, k, S);
1810
+ i[l] === "=" && l++;
1811
+ const C = p("]");
1812
+ return h(C, k, S);
1740
1813
  }
1741
- return h();
1814
+ return p();
1742
1815
  }
1743
- let b = e.replace(
1744
- c.PLACEHOLDERS,
1745
- (s, o) => typeof d[o] == "string" || typeof d[o] == "number" ? String(d[o]) : o ?? o
1816
+ let y = e.replace(
1817
+ d.PLACEHOLDERS,
1818
+ (i, l) => typeof r[l] == "string" || typeof r[l] == "number" ? String(r[l]) : l ?? l
1746
1819
  );
1747
- return b = a.method === "loop" ? m(b) : v(b), b;
1820
+ return y = t.method === "loop" ? m(y) : b(y), y;
1748
1821
  }
1749
- }, r.element = {
1822
+ }, s.element = {
1750
1823
  /**
1751
1824
  * Merges outer span styles with inner span styles in the provided HTML string.
1752
1825
  * @param outerStyle - The style string to be applied to the outer span.
@@ -1758,15 +1831,15 @@ r.data = {
1758
1831
  * console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
1759
1832
  * ```
1760
1833
  */
1761
- mergeSpanStyles(e, n) {
1762
- const a = n.match(/^<span style="([^"]*)">(.*)<\/span>$/s);
1763
- if (a) {
1764
- const t = a[1], d = a[2];
1765
- return `<span style="${[t, e].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${d}</span>`;
1834
+ mergeSpanStyles(e, a) {
1835
+ const t = a.match(/^<span style="([^"]*)">(.*)<\/span>$/s);
1836
+ if (t) {
1837
+ const n = t[1], r = t[2];
1838
+ return `<span style="${[n, e].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${r}</span>`;
1766
1839
  } else
1767
- return `<span style="${e}">${n}</span>`;
1840
+ return `<span style="${e}">${a}</span>`;
1768
1841
  }
1769
- }, r.object = {
1842
+ }, s.object = {
1770
1843
  /**
1771
1844
  * Flattens a nested object into a single-level object with dot-separated keys.
1772
1845
  * @param obj - The nested object to be flattened.
@@ -1780,48 +1853,48 @@ r.data = {
1780
1853
  * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
1781
1854
  * ```
1782
1855
  */
1783
- flatten(e, n = "") {
1784
- const a = {};
1785
- for (const t in e) {
1786
- if (!Object.prototype.hasOwnProperty.call(e, t)) continue;
1787
- const d = e[t], c = n ? `${n}.${t}` : t;
1788
- if (d == null) {
1789
- a[c] = String(d);
1856
+ flatten(e, a = "") {
1857
+ const t = {};
1858
+ for (const n in e) {
1859
+ if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
1860
+ const r = e[n], d = a ? `${a}.${n}` : n;
1861
+ if (r == null) {
1862
+ t[d] = String(r);
1790
1863
  continue;
1791
1864
  }
1792
- if (d instanceof Date) {
1793
- a[c] = d.toISOString();
1865
+ if (r instanceof Date) {
1866
+ t[d] = r.toISOString();
1794
1867
  continue;
1795
1868
  }
1796
- if (d instanceof Map) {
1797
- d.forEach((i, l) => {
1798
- a[`${c}.${l}`] = JSON.stringify(i);
1869
+ if (r instanceof Map) {
1870
+ r.forEach((o, c) => {
1871
+ t[`${d}.${c}`] = JSON.stringify(o);
1799
1872
  });
1800
1873
  continue;
1801
1874
  }
1802
- if (Array.isArray(d)) {
1803
- d.forEach((i, l) => {
1804
- const y = `${c}:${l}`;
1805
- typeof i == "object" ? Object.assign(a, this.flatten(i, y)) : a[y] = String(i);
1875
+ if (Array.isArray(r)) {
1876
+ r.forEach((o, c) => {
1877
+ const w = `${d}:${c}`;
1878
+ typeof o == "object" ? Object.assign(t, this.flatten(o, w)) : t[w] = String(o);
1806
1879
  });
1807
1880
  continue;
1808
1881
  }
1809
- if (typeof d == "object") {
1810
- Object.assign(a, this.flatten(d, c));
1882
+ if (typeof r == "object") {
1883
+ Object.assign(t, this.flatten(r, d));
1811
1884
  continue;
1812
1885
  }
1813
- a[c] = String(d);
1886
+ t[d] = String(r);
1814
1887
  }
1815
- return a;
1888
+ return t;
1816
1889
  }
1817
- }, r.generate = {
1890
+ }, s.generate = {
1818
1891
  session: {
1819
1892
  types: {
1820
- name: { type: "string", options: r.data.names.filter((e) => e.length) },
1821
- tier: { type: "string", options: r.data.tiers.filter((e) => e.length) },
1822
- message: { type: "string", options: r.data.messages.filter((e) => e.length) },
1823
- item: { type: "array", options: r.data.items },
1824
- avatar: { type: "string", options: r.data.avatars.filter((e) => e.length) }
1893
+ name: { type: "string", options: s.data.names.filter((e) => e.length) },
1894
+ tier: { type: "string", options: s.data.tiers.filter((e) => e.length) },
1895
+ message: { type: "string", options: s.data.messages.filter((e) => e.length) },
1896
+ item: { type: "array", options: s.data.items },
1897
+ avatar: { type: "string", options: s.data.avatars.filter((e) => e.length) }
1825
1898
  },
1826
1899
  available() {
1827
1900
  const e = this.types;
@@ -2067,49 +2140,49 @@ r.data = {
2067
2140
  };
2068
2141
  },
2069
2142
  async get() {
2070
- const e = this.available(), n = (t) => {
2071
- const d = (l) => {
2072
- if (!l || !("amount" in l)) return [];
2073
- const y = [];
2074
- for (let f = 0; f < l.amount; f++)
2075
- y.push(n(l.value));
2076
- return y.sort((f, m) => new Date(m.createdAt).getTime() - new Date(f.createdAt).getTime());
2077
- }, c = (l) => {
2078
- const y = {};
2079
- for (const f in l) {
2080
- const m = f.replace("_type", "type");
2081
- y[m] = n(l[f]);
2143
+ const e = this.available(), a = (n) => {
2144
+ const r = (c) => {
2145
+ if (!c || !("amount" in c)) return [];
2146
+ const w = [];
2147
+ for (let h = 0; h < c.amount; h++)
2148
+ w.push(a(c.value));
2149
+ return w.sort((h, m) => new Date(m.createdAt).getTime() - new Date(h.createdAt).getTime());
2150
+ }, d = (c) => {
2151
+ const w = {};
2152
+ for (const h in c) {
2153
+ const m = h.replace("_type", "type");
2154
+ w[m] = a(c[h]);
2082
2155
  }
2083
- return y;
2084
- }, i = (l) => {
2085
- if (!l) return l;
2086
- switch (l.type) {
2156
+ return w;
2157
+ }, o = (c) => {
2158
+ if (!c) return c;
2159
+ switch (c.type) {
2087
2160
  case "int":
2088
- return r.rand.number(l.min, l.max);
2161
+ return s.rand.number(c.min, c.max);
2089
2162
  case "string":
2090
- return r.rand.array(l.options)[0];
2163
+ return s.rand.array(c.options)[0];
2091
2164
  case "date":
2092
- return r.rand.date(l.range);
2165
+ return s.rand.date(c.range);
2093
2166
  case "array":
2094
- return r.rand.array(l.options)[0];
2167
+ return s.rand.array(c.options)[0];
2095
2168
  case "recent":
2096
- return d(l);
2169
+ return r(c);
2097
2170
  default:
2098
- return l;
2171
+ return c;
2099
2172
  }
2100
2173
  };
2101
- return typeof t != "object" || t === null ? t : "type" in t && typeof t.type == "string" ? i(t) : c(t);
2174
+ return typeof n != "object" || n === null ? n : "type" in n && typeof n.type == "string" ? o(n) : d(n);
2102
2175
  };
2103
- var a = Object.entries(n(e)).reduce(
2104
- (t, [d, c]) => (Object.entries(c).forEach(
2105
- ([i, l]) => (
2176
+ var t = Object.entries(a(e)).reduce(
2177
+ (n, [r, d]) => (Object.entries(d).forEach(
2178
+ ([o, c]) => (
2106
2179
  //
2107
- t[`${d}-${i}`] = l
2180
+ n[`${r}-${o}`] = c
2108
2181
  )
2109
- ), t),
2182
+ ), n),
2110
2183
  {}
2111
2184
  );
2112
- return a;
2185
+ return t;
2113
2186
  }
2114
2187
  },
2115
2188
  event: {
@@ -2120,8 +2193,8 @@ r.data = {
2120
2193
  * @param currency - The currency to be used (default is 'USD').
2121
2194
  * @returns A Promise that resolves to the simulated onWidgetLoad event data.
2122
2195
  */
2123
- async onWidgetLoad(e, n, a = "USD") {
2124
- const t = {
2196
+ async onWidgetLoad(e, a, t = "USD") {
2197
+ const n = {
2125
2198
  BRL: { code: "BRL", name: "Brazilian Real", symbol: "R$" },
2126
2199
  USD: { code: "USD", name: "US Dollar", symbol: "$" },
2127
2200
  EUR: { code: "EUR", name: "Euro", symbol: "€" }
@@ -2134,11 +2207,11 @@ r.data = {
2134
2207
  providerId: "",
2135
2208
  avatar: ""
2136
2209
  },
2137
- currency: t[a] ?? t.USD,
2210
+ currency: n[t] ?? n.USD,
2138
2211
  fieldData: e,
2139
2212
  recents: [],
2140
2213
  session: {
2141
- data: n,
2214
+ data: a,
2142
2215
  settings: {
2143
2216
  autoReset: !1,
2144
2217
  calendar: !1,
@@ -2158,7 +2231,7 @@ r.data = {
2158
2231
  * @returns A Promise that resolves to the simulated onSessionUpdate event data.
2159
2232
  */
2160
2233
  async onSessionUpdate(e) {
2161
- return e ??= await r.generate.session.get(), { session: e };
2234
+ return e ??= await s.generate.session.get(), { session: e };
2162
2235
  },
2163
2236
  /**
2164
2237
  * Simulates the onEventReceived event for a widget.
@@ -2175,8 +2248,8 @@ r.data = {
2175
2248
  * const twitchMessageEvent = await Simulation.generate.event.onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' });
2176
2249
  * ```
2177
2250
  */
2178
- async onEventReceived(e = "random", n = "random", a = {}) {
2179
- const t = {
2251
+ async onEventReceived(e = "random", a = "random", t = {}) {
2252
+ const n = {
2180
2253
  twitch: ["message", "follower-latest", "cheer-latest", "raid-latest", "subscriber-latest"],
2181
2254
  streamelements: ["tip-latest"],
2182
2255
  youtube: ["message", "superchat-latest", "subscriber-latest", "sponsor-latest"],
@@ -2186,52 +2259,52 @@ r.data = {
2186
2259
  switch (e) {
2187
2260
  default:
2188
2261
  case "random": {
2189
- var d = r.rand.array(Object.keys(t).filter((C) => t[C].length))[0], c = r.rand.array(t[d])[0];
2190
- return this.onEventReceived(d, c);
2262
+ var r = s.rand.array(Object.keys(n).filter((v) => n[v].length))[0], d = s.rand.array(n[r])[0];
2263
+ return this.onEventReceived(r, d);
2191
2264
  }
2192
2265
  case "twitch":
2193
- switch (n) {
2266
+ switch (a) {
2194
2267
  default:
2195
2268
  case "random": {
2196
- var c = r.rand.array(t[e])[0];
2197
- return this.onEventReceived(e, c);
2269
+ var d = s.rand.array(n[e])[0];
2270
+ return this.onEventReceived(e, d);
2198
2271
  }
2199
2272
  case "message": {
2200
- var i = a?.name ?? r.rand.array(r.data.names.filter((w) => w.length))[0], l = a?.message ?? r.rand.array(r.data.messages.filter((w) => w.length))[0], y = await U(a?.badges ?? [], e), f = D(l), m = G(l, f), v = a?.color ?? r.rand.color("hex"), b = a?.userId ?? r.rand.number(1e7, 99999999).toString(), s = Date.now();
2273
+ var o = t?.name ?? s.rand.array(s.data.names.filter((g) => g.length))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((g) => g.length))[0], w = await z(t?.badges ?? [], e), h = N(c), m = B(c, h), b = t?.color ?? s.rand.color("hex"), y = t?.userId ?? s.rand.number(1e7, 99999999).toString(), i = Date.now();
2201
2274
  return {
2202
2275
  listener: "message",
2203
2276
  event: {
2204
2277
  service: e,
2205
2278
  data: {
2206
- time: s,
2279
+ time: i,
2207
2280
  tags: {
2208
- "badge-info": `${y.keys.map((w) => `${w}/${r.rand.number(1, 5)}`).join(",")}`,
2209
- badges: y.keys.join("/1,"),
2210
- mod: y.keys.includes("moderator") ? "1" : "0",
2211
- subscriber: y.keys.includes("subscriber") ? "1" : "0",
2212
- turbo: y.keys.includes("turbo") ? "1" : "0",
2213
- "tmi-sent-ts": s.toString(),
2214
- "user-id": b,
2281
+ "badge-info": `${w.keys.map((g) => `${g}/${s.rand.number(1, 5)}`).join(",")}`,
2282
+ badges: w.keys.join("/1,"),
2283
+ mod: w.keys.includes("moderator") ? "1" : "0",
2284
+ subscriber: w.keys.includes("subscriber") ? "1" : "0",
2285
+ turbo: w.keys.includes("turbo") ? "1" : "0",
2286
+ "tmi-sent-ts": i.toString(),
2287
+ "user-id": y,
2215
2288
  "user-type": "",
2216
- color: v,
2217
- "display-name": i,
2289
+ color: b,
2290
+ "display-name": o,
2218
2291
  emotes: "",
2219
- "client-nonce": r.rand.string(16),
2292
+ "client-nonce": s.rand.string(16),
2220
2293
  flags: "",
2221
- id: r.rand.uuid(),
2294
+ id: s.rand.uuid(),
2222
2295
  "first-msg": "0",
2223
2296
  "returning-chatter": "0"
2224
2297
  },
2225
- nick: i.toLowerCase(),
2226
- displayName: i,
2227
- displayColor: v,
2298
+ nick: o.toLowerCase(),
2299
+ displayName: o,
2300
+ displayColor: b,
2228
2301
  channel: "local",
2229
- text: l,
2302
+ text: c,
2230
2303
  isAction: !1,
2231
- userId: b,
2232
- msgId: r.rand.uuid(),
2233
- badges: y.badges,
2234
- emotes: f
2304
+ userId: y,
2305
+ msgId: s.rand.uuid(),
2306
+ badges: w.badges,
2307
+ emotes: h
2235
2308
  },
2236
2309
  renderedText: m
2237
2310
  }
@@ -2239,17 +2312,17 @@ r.data = {
2239
2312
  }
2240
2313
  case "cheer":
2241
2314
  case "cheer-latest": {
2242
- var o = a?.amount ?? r.rand.number(100, 1e4), p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((E) => E.length))[0], l = a?.message ?? r.rand.array(r.data.messages.filter((E) => E.length))[0];
2315
+ var l = t?.amount ?? s.rand.number(100, 1e4), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((A) => A.length))[0];
2243
2316
  return {
2244
2317
  listener: "cheer-latest",
2245
2318
  event: {
2246
- amount: o,
2247
- avatar: p,
2248
- name: i.toLowerCase(),
2249
- displayName: i,
2250
- message: l,
2319
+ amount: l,
2320
+ avatar: f,
2321
+ name: o.toLowerCase(),
2322
+ displayName: o,
2323
+ message: c,
2251
2324
  providerId: "",
2252
- _id: r.rand.uuid(),
2325
+ _id: s.rand.uuid(),
2253
2326
  sessionTop: !1,
2254
2327
  type: "cheer",
2255
2328
  originalEventName: "cheer-latest"
@@ -2258,15 +2331,15 @@ r.data = {
2258
2331
  }
2259
2332
  case "follower":
2260
2333
  case "follower-latest": {
2261
- var p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((E) => E.length))[0];
2334
+ var f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
2262
2335
  return {
2263
2336
  listener: "follower-latest",
2264
2337
  event: {
2265
- avatar: p,
2266
- name: i.toLowerCase(),
2267
- displayName: i,
2338
+ avatar: f,
2339
+ name: o.toLowerCase(),
2340
+ displayName: o,
2268
2341
  providerId: "",
2269
- _id: r.rand.uuid(),
2342
+ _id: s.rand.uuid(),
2270
2343
  sessionTop: !1,
2271
2344
  type: "follower",
2272
2345
  originalEventName: "follower-latest"
@@ -2275,16 +2348,16 @@ r.data = {
2275
2348
  }
2276
2349
  case "raid":
2277
2350
  case "raid-latest": {
2278
- var o = a?.amount ?? r.rand.number(1, 100), p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((M) => M.length))[0];
2351
+ var l = t?.amount ?? s.rand.number(1, 100), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((I) => I.length))[0];
2279
2352
  return {
2280
2353
  listener: "raid-latest",
2281
2354
  event: {
2282
- amount: o,
2283
- avatar: p,
2284
- name: i.toLowerCase(),
2285
- displayName: i,
2355
+ amount: l,
2356
+ avatar: f,
2357
+ name: o.toLowerCase(),
2358
+ displayName: o,
2286
2359
  providerId: "",
2287
- _id: r.rand.uuid(),
2360
+ _id: s.rand.uuid(),
2288
2361
  sessionTop: !1,
2289
2362
  type: "raid",
2290
2363
  originalEventName: "raid-latest"
@@ -2293,10 +2366,10 @@ r.data = {
2293
2366
  }
2294
2367
  case "subscriber":
2295
2368
  case "subscriber-latest": {
2296
- var h = a?.tier ?? r.rand.array(["1000", "2000", "3000"])[0], o = a?.amount ?? r.rand.number(1, 24), p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((T) => T.length))[0], x = a?.sender ?? r.rand.array(r.data.names.filter((T) => T.length && T !== i))[0], l = a?.message ?? r.rand.array(r.data.messages.filter((T) => T.length))[0], k = {
2369
+ var p = t?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], l = t?.amount ?? s.rand.number(1, 24), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((T) => T.length))[0], x = t?.sender ?? s.rand.array(s.data.names.filter((T) => T.length && T !== o))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((T) => T.length))[0], k = {
2297
2370
  default: {
2298
- avatar: p,
2299
- tier: h,
2371
+ avatar: f,
2372
+ tier: p,
2300
2373
  playedAsCommunityGift: !1
2301
2374
  },
2302
2375
  gift: {
@@ -2304,7 +2377,7 @@ r.data = {
2304
2377
  gifted: !0
2305
2378
  },
2306
2379
  community: {
2307
- message: l,
2380
+ message: c,
2308
2381
  sender: x,
2309
2382
  bulkGifted: !0
2310
2383
  },
@@ -2313,17 +2386,17 @@ r.data = {
2313
2386
  gifted: !0,
2314
2387
  isCommunityGift: !0
2315
2388
  }
2316
- }, S = ["default", "gift", "community", "spam"], A = a?.subType ?? r.rand.array(S)[0];
2317
- return A = S.includes(A) ? A : "default", {
2389
+ }, S = ["default", "gift", "community", "spam"], C = t?.subType ?? s.rand.array(S)[0];
2390
+ return C = S.includes(C) ? C : "default", {
2318
2391
  listener: "subscriber-latest",
2319
2392
  event: {
2320
- amount: o,
2321
- name: i.toLowerCase(),
2322
- displayName: i,
2393
+ amount: l,
2394
+ name: o.toLowerCase(),
2395
+ displayName: o,
2323
2396
  providerId: "",
2324
2397
  ...k.default,
2325
- ...k[A],
2326
- _id: r.rand.uuid(),
2398
+ ...k[C],
2399
+ _id: s.rand.uuid(),
2327
2400
  sessionTop: !1,
2328
2401
  type: "subscriber",
2329
2402
  originalEventName: "subscriber-latest"
@@ -2334,36 +2407,36 @@ r.data = {
2334
2407
  return {
2335
2408
  listener: "delete-message",
2336
2409
  event: {
2337
- msgId: a?.id ?? r.rand.uuid()
2410
+ msgId: t?.id ?? s.rand.uuid()
2338
2411
  }
2339
2412
  };
2340
2413
  case "delete-messages":
2341
2414
  return {
2342
2415
  listener: "delete-messages",
2343
2416
  event: {
2344
- userId: a?.id ?? r.rand.number(1e7, 99999999).toString()
2417
+ userId: t?.id ?? s.rand.number(1e7, 99999999).toString()
2345
2418
  }
2346
2419
  };
2347
2420
  }
2348
2421
  case "streamelements":
2349
- switch (n) {
2422
+ switch (a) {
2350
2423
  default:
2351
2424
  case "random": {
2352
- var c = r.rand.array(t[e])[0];
2353
- return this.onEventReceived(e, c);
2425
+ var d = s.rand.array(n[e])[0];
2426
+ return this.onEventReceived(e, d);
2354
2427
  }
2355
2428
  case "tip":
2356
2429
  case "tip-latest": {
2357
- var o = a?.amount ?? r.rand.number(100, 4e3), p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((M) => M.length))[0];
2430
+ var l = t?.amount ?? s.rand.number(100, 4e3), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((I) => I.length))[0];
2358
2431
  return {
2359
2432
  listener: "tip-latest",
2360
2433
  event: {
2361
- amount: o,
2362
- avatar: p,
2363
- name: i.toLowerCase(),
2364
- displayName: i,
2434
+ amount: l,
2435
+ avatar: f,
2436
+ name: o.toLowerCase(),
2437
+ displayName: o,
2365
2438
  providerId: "",
2366
- _id: r.rand.uuid(),
2439
+ _id: s.rand.uuid(),
2367
2440
  sessionTop: !1,
2368
2441
  type: "tip",
2369
2442
  originalEventName: "tip-latest"
@@ -2375,8 +2448,8 @@ r.data = {
2375
2448
  listener: "kvstore:update",
2376
2449
  event: {
2377
2450
  data: {
2378
- key: `customWidget.${a?.key ?? "sampleKey"}`,
2379
- value: a?.value ?? "sampleValue"
2451
+ key: `customWidget.${t?.key ?? "sampleKey"}`,
2452
+ value: t?.value ?? "sampleValue"
2380
2453
  }
2381
2454
  }
2382
2455
  };
@@ -2384,17 +2457,19 @@ r.data = {
2384
2457
  return {
2385
2458
  listener: "bot:counter",
2386
2459
  event: {
2387
- counter: a?.counter ?? "sampleCounter",
2388
- value: a?.value ?? r.rand.number(0, 100)
2460
+ counter: t?.counter ?? "sampleCounter",
2461
+ value: t?.value ?? s.rand.number(0, 100)
2389
2462
  }
2390
2463
  };
2391
2464
  case "mute":
2392
2465
  case "unmute":
2393
- case "alertService:toggleSound":
2466
+ case "alertService:toggleSound": {
2467
+ var M = t?.muted ?? !client.details.overlay.muted;
2394
2468
  return {
2395
2469
  listener: "alertService:toggleSound",
2396
- event: {}
2470
+ event: { muted: M }
2397
2471
  };
2472
+ }
2398
2473
  case "skip":
2399
2474
  case "event:skip":
2400
2475
  return {
@@ -2403,16 +2478,16 @@ r.data = {
2403
2478
  };
2404
2479
  }
2405
2480
  case "youtube":
2406
- switch (n) {
2481
+ switch (a) {
2407
2482
  default:
2408
2483
  case "random": {
2409
- var c = r.rand.array(t[e])[0];
2410
- return this.onEventReceived(e, c);
2484
+ var d = s.rand.array(n[e])[0];
2485
+ return this.onEventReceived(e, d);
2411
2486
  }
2412
2487
  case "message": {
2413
- var i = a?.name ?? r.rand.array(r.data.names.filter((j) => j.length))[0], l = a?.message ?? r.rand.array(r.data.messages.filter((j) => j.length))[0];
2414
- const g = await U(a?.badges ?? [], e);
2415
- var f = D(l), m = G(l, f), v = a?.color ?? r.rand.color("hex"), b = a?.userId ?? r.rand.number(1e7, 99999999).toString(), s = Date.now(), p = a?.avatar ?? r.rand.array(r.data.avatars)[0];
2488
+ var o = t?.name ?? s.rand.array(s.data.names.filter((L) => L.length))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((L) => L.length))[0];
2489
+ const R = await z(t?.badges ?? [], e);
2490
+ var h = N(c), m = B(c, h), b = t?.color ?? s.rand.color("hex"), y = t?.userId ?? s.rand.number(1e7, 99999999).toString(), i = Date.now(), f = t?.avatar ?? s.rand.array(s.data.avatars)[0];
2416
2491
  return {
2417
2492
  listener: "message",
2418
2493
  event: {
@@ -2427,47 +2502,47 @@ r.data = {
2427
2502
  authorChannelId: "local",
2428
2503
  publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
2429
2504
  hasDisplayContent: !0,
2430
- displayMessage: l,
2505
+ displayMessage: c,
2431
2506
  textMessageDetails: {
2432
- messageText: l
2507
+ messageText: c
2433
2508
  }
2434
2509
  },
2435
2510
  authorDetails: {
2436
2511
  channelId: "local",
2437
2512
  channelUrl: "",
2438
- displayName: i,
2439
- profileImageUrl: p,
2440
- ...g
2513
+ displayName: o,
2514
+ profileImageUrl: f,
2515
+ ...R
2441
2516
  },
2442
- msgId: r.rand.uuid(),
2443
- userId: r.rand.uuid(),
2444
- nick: i.toLowerCase(),
2517
+ msgId: s.rand.uuid(),
2518
+ userId: s.rand.uuid(),
2519
+ nick: o.toLowerCase(),
2445
2520
  badges: [],
2446
- displayName: i,
2521
+ displayName: o,
2447
2522
  isAction: !1,
2448
2523
  time: Date.now(),
2449
2524
  tags: [],
2450
- displayColor: r.rand.color("hex"),
2525
+ displayColor: s.rand.color("hex"),
2451
2526
  channel: "local",
2452
- text: l,
2453
- avatar: p,
2527
+ text: c,
2528
+ avatar: f,
2454
2529
  emotes: []
2455
2530
  },
2456
- renderedText: l
2531
+ renderedText: c
2457
2532
  }
2458
2533
  };
2459
2534
  }
2460
2535
  case "subscriber":
2461
2536
  case "subscriber-latest": {
2462
- var p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((E) => E.length))[0];
2537
+ var f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
2463
2538
  return {
2464
2539
  listener: "subscriber-latest",
2465
2540
  event: {
2466
- avatar: p,
2467
- displayName: i,
2468
- name: i.toLowerCase(),
2541
+ avatar: f,
2542
+ displayName: o,
2543
+ name: o.toLowerCase(),
2469
2544
  providerId: "",
2470
- _id: r.rand.uuid(),
2545
+ _id: s.rand.uuid(),
2471
2546
  sessionTop: !1,
2472
2547
  type: "subscriber",
2473
2548
  originalEventName: "subscriber-latest"
@@ -2476,16 +2551,16 @@ r.data = {
2476
2551
  }
2477
2552
  case "superchat":
2478
2553
  case "superchat-latest": {
2479
- var o = a?.amount ?? r.rand.number(100, 4e3), p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((M) => M.length))[0];
2554
+ var l = t?.amount ?? s.rand.number(100, 4e3), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((I) => I.length))[0];
2480
2555
  return {
2481
2556
  listener: "superchat-latest",
2482
2557
  event: {
2483
- amount: o,
2484
- avatar: p,
2485
- name: i.toLowerCase(),
2486
- displayName: i,
2558
+ amount: l,
2559
+ avatar: f,
2560
+ name: o.toLowerCase(),
2561
+ displayName: o,
2487
2562
  providerId: "",
2488
- _id: r.rand.uuid(),
2563
+ _id: s.rand.uuid(),
2489
2564
  sessionTop: !1,
2490
2565
  type: "superchat",
2491
2566
  originalEventName: "superchat-latest"
@@ -2494,10 +2569,10 @@ r.data = {
2494
2569
  }
2495
2570
  case "sponsor":
2496
2571
  case "sponsor-latest": {
2497
- var h = a?.tier ?? r.rand.array(["1000", "2000", "3000"])[0], o = a?.amount ?? r.rand.number(1, 24), p = a?.avatar ?? r.rand.array(r.data.avatars)[0], i = a?.name ?? r.rand.array(r.data.names.filter((j) => j.length))[0], x = a?.sender ?? r.rand.array(r.data.names.filter((j) => j.length && j !== i))[0], l = a?.message ?? r.rand.array(r.data.messages.filter((j) => j.length))[0], k = {
2572
+ var p = t?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], l = t?.amount ?? s.rand.number(1, 24), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((L) => L.length))[0], x = t?.sender ?? s.rand.array(s.data.names.filter((L) => L.length && L !== o))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((L) => L.length))[0], k = {
2498
2573
  default: {
2499
- avatar: p,
2500
- tier: h,
2574
+ avatar: f,
2575
+ tier: p,
2501
2576
  playedAsCommunityGift: !1
2502
2577
  },
2503
2578
  gift: {
@@ -2505,7 +2580,7 @@ r.data = {
2505
2580
  gifted: !0
2506
2581
  },
2507
2582
  community: {
2508
- message: l,
2583
+ message: c,
2509
2584
  sender: x,
2510
2585
  bulkGifted: !0
2511
2586
  },
@@ -2514,17 +2589,17 @@ r.data = {
2514
2589
  gifted: !0,
2515
2590
  isCommunityGift: !0
2516
2591
  }
2517
- }, S = ["default", "gift", "community", "spam"], A = a?.subType ?? r.rand.array(S)[0];
2518
- return A = S.includes(A) ? A : "default", {
2592
+ }, S = ["default", "gift", "community", "spam"], C = t?.subType ?? s.rand.array(S)[0];
2593
+ return C = S.includes(C) ? C : "default", {
2519
2594
  listener: "sponsor-latest",
2520
2595
  event: {
2521
- amount: o,
2522
- name: i.toLowerCase(),
2523
- displayName: i,
2596
+ amount: l,
2597
+ name: o.toLowerCase(),
2598
+ displayName: o,
2524
2599
  providerId: "",
2525
2600
  ...k.default,
2526
- ...k[A],
2527
- _id: r.rand.uuid(),
2601
+ ...k[C],
2602
+ _id: s.rand.uuid(),
2528
2603
  sessionTop: !1,
2529
2604
  type: "sponsor",
2530
2605
  originalEventName: "sponsor-latest"
@@ -2536,8 +2611,8 @@ r.data = {
2536
2611
  }
2537
2612
  }
2538
2613
  };
2539
- let L = r;
2540
- class W {
2614
+ let j = s;
2615
+ class q {
2541
2616
  constructor() {
2542
2617
  this.themes = [
2543
2618
  {
@@ -2621,42 +2696,48 @@ class W {
2621
2696
  }, this.simple = () => {
2622
2697
  }, this.info = () => {
2623
2698
  }, this.themes.forEach((e) => {
2624
- const n = [];
2625
- e.background && e.background !== "transparent" && n.push(`background-color: ${e.background}`), e.color && n.push(`color: ${e.color}`), e.bold && n.push("font-weight: bold"), e.italic && n.push("font-style: italic"), e.underline && n.push("text-decoration: underline"), e.fontSize && n.push(`font-size: ${e.fontSize}px`);
2626
- const a = "%c", t = (...d) => {
2627
- const c = Array.from(d).filter((f) => typeof f == "string" || typeof f == "number"), i = Array.from(d).filter((f) => typeof f != "string" && typeof f != "number"), l = c.length > 0 ? n.join("; ") : null, y = [
2628
- c.length > 0 ? a + (e.template?.before ?? "") + c.join(" ") + (e.template?.after ?? "") : null,
2629
- l,
2630
- ...i
2699
+ const a = [];
2700
+ e.background && e.background !== "transparent" && a.push(`background-color: ${e.background}`), e.color && a.push(`color: ${e.color}`), e.bold && a.push("font-weight: bold"), e.italic && a.push("font-style: italic"), e.underline && a.push("text-decoration: underline"), e.fontSize && a.push(`font-size: ${e.fontSize}px`);
2701
+ const t = "%c", n = (...r) => {
2702
+ const d = Array.from(r).filter((h) => typeof h == "string" || typeof h == "number"), o = Array.from(r).filter((h) => typeof h != "string" && typeof h != "number"), c = d.length > 0 ? a.join("; ") : null, w = [
2703
+ d.length > 0 ? t + (e.template?.before ?? "") + d.join(" ") + (e.template?.after ?? "") : null,
2704
+ c,
2705
+ ...o
2631
2706
  ].filter(Boolean);
2632
- return console.log(...y);
2707
+ return console.log(...w);
2633
2708
  };
2634
- this[e.name] = t;
2709
+ this[e.name] = n;
2635
2710
  });
2636
2711
  }
2637
2712
  }
2638
- class O {
2713
+ class $ {
2639
2714
  constructor(e) {
2640
- this.field = "button", this.template = "button", window.client instanceof I && (this.field = e.field ?? this.field, this.template = e.template ?? this.template, this.run = e.run, window.client.actions.buttons.push(this));
2715
+ this.field = "button", this.template = "button", window.client instanceof E && (this.field = e.field ?? this.field, this.template = e.template ?? this.template, this.run = e.run, window.client.actions.buttons.push(this), window.client.emit("action", this, "created"));
2641
2716
  }
2642
- parse(e, n) {
2643
- var a = e.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
2717
+ parse(e, a) {
2718
+ var t = e.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
2644
2719
  try {
2645
- this.run.apply(window.client, [a.length ? a : e ?? e, n]);
2646
- } catch (t) {
2647
- throw new Error(`Error running button "${this.field}": ${t instanceof Error ? t.message : t}`);
2720
+ this.run.apply(window.client, [t.length ? t : e ?? e, a]);
2721
+ } catch (n) {
2722
+ throw new Error(`Error running button "${this.field}": ${n instanceof Error ? n.message : n}`);
2648
2723
  }
2649
2724
  return this;
2650
2725
  }
2651
- static execute(e, n) {
2726
+ static execute(e, a) {
2652
2727
  try {
2653
- if (!(window.client instanceof I)) return !1;
2728
+ if (!(window.client instanceof E)) return !1;
2654
2729
  if (window.client.actions.buttons.length) {
2655
- const a = window.client.actions.buttons.find(
2656
- (t) => typeof t.field == "string" ? t.field === e : typeof t.field == "function" ? t.field(e, n) : !1
2730
+ const t = window.client.actions.buttons.find(
2731
+ (n) => typeof n.field == "string" ? n.field === e : typeof n.field == "function" ? n.field(e, a) : !1
2657
2732
  );
2658
- if (a && a instanceof O)
2659
- return a.parse(e, n), R.logger.received(`Button executed: ${e} with value: ${n}`), !0;
2733
+ if (t && t instanceof $) {
2734
+ try {
2735
+ t.parse(e, a), window.client.emit("action", t, "executed"), O.logger.received(`Button executed: ${e} with value: ${a}`);
2736
+ } catch (n) {
2737
+ O.logger.error(`Error executing button "${e}": ${n instanceof Error ? n.message : n}`);
2738
+ }
2739
+ return !0;
2740
+ }
2660
2741
  }
2661
2742
  } catch {
2662
2743
  return !1;
@@ -2665,50 +2746,50 @@ class O {
2665
2746
  }
2666
2747
  }
2667
2748
  }
2668
- class $ {
2749
+ class P {
2669
2750
  constructor(e) {
2670
- this.prefix = "!", this.arguments = !1, this.test = `${this.prefix}${this.name} arg1 arg2`, this.aliases = [], this.permissions = void 0, this.admins = [], window.client instanceof I && (this.prefix = e.prefix ?? this.prefix, this.name = e.name, this.description = e.description ?? this.description, this.arguments = e.arguments ?? this.arguments, this.run = e.run, this.test = e.test ?? this.test, this.aliases = e.aliases ?? this.aliases, this.permissions = e.permissions ?? this.permissions, this.admins = e.admins ?? this.admins, window.client.actions.commands.push(this));
2751
+ this.prefix = "!", this.arguments = !1, this.test = `${this.prefix}${this.name} arg1 arg2`, this.aliases = [], this.permissions = void 0, this.admins = [], window.client instanceof E && (this.prefix = e.prefix ?? this.prefix, this.name = e.name, this.description = e.description ?? this.description, this.arguments = e.arguments ?? this.arguments, this.run = e.run, this.test = e.test ?? this.test, this.aliases = e.aliases ?? this.aliases, this.permissions = e.permissions ?? this.permissions, this.admins = e.admins ?? this.admins, window.client.actions.commands.push(this), window.client.emit("action", this, "created"));
2671
2752
  }
2672
- run(e, n) {
2753
+ run(e, a) {
2673
2754
  }
2674
- verify(e, n, a) {
2675
- return this.arguments === !0 && (!a || !a.length) ? !1 : this.admins.some((t) => e.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) => n.map((d) => d.toLowerCase()).includes(t.toLowerCase())));
2755
+ verify(e, a, t) {
2756
+ return this.arguments === !0 && (!t || !t.length) ? !1 : this.admins.some((n) => e.toLocaleLowerCase() === n.toLocaleLowerCase()) ? !0 : this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length ? !1 : !!(Array.isArray(this.permissions) && this.permissions.some((n) => a.map((r) => r.toLowerCase()).includes(n.toLowerCase())));
2676
2757
  }
2677
- parse(e, n) {
2678
- if (!(window.client instanceof I)) return !1;
2679
- const a = e.replace(this.prefix, "").split(" ").slice(1).map((l) => l.trim());
2680
- var t = "", d = [];
2681
- const c = { bits: "cheer", premium: "prime" };
2682
- switch (n.provider) {
2758
+ parse(e, a) {
2759
+ if (!(window.client instanceof E)) return !1;
2760
+ const t = e.replace(this.prefix, "").split(" ").slice(1).map((c) => c.trim());
2761
+ var n = "", r = [];
2762
+ const d = { bits: "cheer", premium: "prime" };
2763
+ switch (a.provider) {
2683
2764
  case "twitch": {
2684
- const l = n.data;
2685
- t = l.event.data.nick || l.event.data.displayName, l.event.data.tags?.badges && (d = l.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((f) => f in c ? c[f] : f));
2765
+ const c = a.data;
2766
+ n = c.event.data.nick || c.event.data.displayName, c.event.data.tags?.badges && (r = c.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((h) => h in d ? d[h] : h));
2686
2767
  break;
2687
2768
  }
2688
2769
  case "youtube": {
2689
- const l = n.data, y = {
2770
+ const c = a.data, w = {
2690
2771
  isVerified: "verified",
2691
2772
  isChatOwner: "owner",
2692
2773
  isChatSponsor: "sponsor",
2693
2774
  isChatModerator: "moderator"
2694
2775
  };
2695
- t = l.event.data.nick || l.event.data.displayName, d = Object.entries(l.event.data.authorDetails).filter(([f, m]) => f.startsWith("is") && m).map(([f]) => y[f]).filter(Boolean);
2776
+ n = c.event.data.nick || c.event.data.displayName, r = Object.entries(c.event.data.authorDetails).filter(([h, m]) => h.startsWith("is") && m).map(([h]) => w[h]).filter(Boolean);
2696
2777
  break;
2697
2778
  }
2698
2779
  case "kick":
2699
2780
  return !1;
2700
2781
  }
2701
- const i = this.verify(t, d, a);
2702
- return i === !0 && this.run.apply(window.client, [a, n]), i;
2782
+ const o = this.verify(n, r, t);
2783
+ return o === !0 && this.run.apply(window.client, [t, a]), o;
2703
2784
  }
2704
2785
  static execute(e) {
2705
- if (!(window.client instanceof I)) return !1;
2706
- const n = e.data;
2786
+ if (!(window.client instanceof E)) return !1;
2787
+ const a = e.data;
2707
2788
  try {
2708
- if (window.client.actions.commands.length && window.client.actions.commands.some((a) => n.event.data.text.startsWith(a.prefix))) {
2709
- const a = window.client.actions.commands.find((t) => n.event.data.text.replace(t.prefix, "").split(" ")[0] === t.name);
2710
- if (a && a instanceof $)
2711
- return a.parse(n.event.data.text, e), R.logger.received(`Command executed: ${n.event.data.text} by ${n.event.data.nick || n.event.data.displayName}`, n), !0;
2789
+ if (window.client.actions.commands.length && window.client.actions.commands.some((t) => a.event.data.text.startsWith(t.prefix))) {
2790
+ const t = window.client.actions.commands.find((n) => a.event.data.text.replace(n.prefix, "").split(" ")[0] === n.name);
2791
+ if (t && t instanceof P)
2792
+ return t.parse(a.event.data.text, e), window.client.emit("action", t, "executed"), O.logger.received(`Command executed: ${a.event.data.text} by ${a.event.data.nick || a.event.data.displayName}`, a), !0;
2712
2793
  }
2713
2794
  } catch {
2714
2795
  return !1;
@@ -2718,154 +2799,230 @@ class $ {
2718
2799
  }
2719
2800
  }
2720
2801
  window.addEventListener("load", () => {
2721
- window.client instanceof I && L.start();
2802
+ window.client instanceof E && j.start();
2722
2803
  });
2723
2804
  window.addEventListener("onWidgetLoad", async (u) => {
2724
2805
  const { detail: e } = u;
2725
- if (window.client instanceof I) {
2726
- const n = window.client;
2727
- n.fields = e.fieldData, n.session = e.session.data, n.details = {
2728
- ...n.details,
2806
+ if (window.client instanceof E) {
2807
+ const a = window.client;
2808
+ a.fields = e.fieldData, a.session = e.session.data, a.details = {
2809
+ ...a.details,
2729
2810
  user: e.channel,
2730
2811
  currency: e.currency,
2731
2812
  overlay: e.overlay
2732
- }, e.channel.id && !e.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${e.channel.id}/`).then((a) => a.json()).then((a) => {
2733
- if (a.provider)
2734
- return n.details.provider = a.provider, a.provider;
2735
- n.details.provider = "local";
2813
+ }, e.channel.id && !e.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${e.channel.id}/`).then((t) => t.json()).then((t) => {
2814
+ if (t.provider)
2815
+ return a.details.provider = t.provider, t.provider;
2816
+ a.details.provider = "local";
2736
2817
  }).catch(() => {
2737
- n.details.provider = "local";
2738
- }) : n.details.provider = "local", n.emit("load", e), n.loaded = !0, n.storage.on("load", () => {
2739
- n.storage.add(`avatar.${e.channel.providerId.toLowerCase()}`, {
2818
+ a.details.provider = "local";
2819
+ }) : a.details.provider = "local", a.emit("load", e), a.loaded = !0, a.storage.on("load", () => {
2820
+ a.storage.add(`avatar.${e.channel.providerId.toLowerCase()}`, {
2740
2821
  value: e.channel.avatar,
2741
2822
  timestamp: Date.now(),
2742
- expire: Date.now() + n.cache.avatar * 60 * 60 * 1e3
2823
+ expire: Date.now() + a.cache.avatar * 60 * 60 * 1e3
2743
2824
  });
2744
2825
  });
2745
2826
  }
2746
2827
  });
2747
2828
  window.addEventListener("onSessionUpdate", (u) => {
2748
2829
  const { detail: e } = u;
2749
- if (window.client instanceof I) {
2750
- const n = window.client;
2751
- n.session = e.session, n.emit("session", e.session);
2830
+ if (window.client instanceof E) {
2831
+ const a = window.client;
2832
+ a.session = e.session, a.emit("session", e.session);
2752
2833
  }
2753
2834
  });
2754
2835
  window.addEventListener("onEventReceived", ({ detail: u }) => {
2755
- if (window.client instanceof I) {
2836
+ if (window.client instanceof E) {
2756
2837
  var e = (
2757
2838
  // @ts-ignore
2758
2839
  u.event?.provider || u.event?.service || u.event?.data?.provider || window.client.details.provider
2759
2840
  );
2760
- ["kvstore:update", "bot:counter", "alertService:toggleSound", "event:skip", "tip-latest", "event:test"].some((t) => t === u.listener) && (e = "streamelements");
2761
- const a = { provider: e, data: u };
2762
- switch (a.provider) {
2841
+ ["kvstore:update", "bot:counter", "alertService:toggleSound", "event:skip", "tip-latest", "event:test"].some((r) => r === u.listener) && (e = "streamelements");
2842
+ const n = { provider: e, data: u };
2843
+ switch (n.provider) {
2763
2844
  case "streamelements": {
2764
- const t = a.data;
2765
- switch (t.listener) {
2845
+ const r = n.data;
2846
+ switch (r.listener) {
2766
2847
  case "tip-latest": {
2767
- t.event;
2848
+ r.event;
2768
2849
  break;
2769
2850
  }
2770
2851
  case "event:skip": {
2771
- t.event;
2852
+ r.event;
2772
2853
  break;
2773
2854
  }
2774
2855
  case "event:test": {
2775
- switch (t.event.listener) {
2856
+ switch (r.event.listener) {
2776
2857
  case "widget-button": {
2777
- const d = t.event;
2778
- O.execute(d.field, d.value);
2858
+ const d = r.event;
2859
+ $.execute(d.field, d.value);
2779
2860
  break;
2780
2861
  }
2781
2862
  case "subscriber-latest": {
2782
- t.event;
2863
+ r.event;
2783
2864
  break;
2784
2865
  }
2785
2866
  }
2786
2867
  break;
2787
2868
  }
2788
2869
  case "kvstore:update": {
2789
- t.event;
2870
+ const d = r.event;
2871
+ if (U.length) {
2872
+ var a = U.find((o) => o.id === d.data.key.replace("customWidget.", ""));
2873
+ a && a.update(d.data.value);
2874
+ }
2790
2875
  break;
2791
2876
  }
2792
2877
  case "bot:counter": {
2793
- t.event;
2878
+ r.event;
2794
2879
  break;
2795
2880
  }
2796
2881
  case "alertService:toggleSound": {
2797
- t.event;
2882
+ const d = r.event;
2883
+ client.details.overlay.muted = !!d.muted;
2798
2884
  break;
2799
2885
  }
2800
2886
  }
2801
2887
  break;
2802
2888
  }
2803
2889
  case "twitch": {
2804
- const t = a.data;
2805
- switch (t.listener) {
2890
+ const r = n.data;
2891
+ switch (r.listener) {
2806
2892
  case "delete-message": {
2807
- t.event;
2893
+ r.event;
2808
2894
  break;
2809
2895
  }
2810
2896
  case "delete-messages": {
2811
- t.event;
2897
+ r.event;
2812
2898
  break;
2813
2899
  }
2814
2900
  case "message": {
2815
- t.event;
2901
+ r.event;
2816
2902
  break;
2817
2903
  }
2818
2904
  case "follower-latest": {
2819
- t.event;
2905
+ r.event;
2820
2906
  break;
2821
2907
  }
2822
2908
  case "cheer-latest": {
2823
- t.event;
2909
+ r.event;
2824
2910
  break;
2825
2911
  }
2826
2912
  case "subscriber-latest": {
2827
- (!t.event.gifted && !t.event.bulkGifted && !t.event.isCommunityGift || t.event.gifted && !t.event.bulkGifted && !t.event.isCommunityGift || t.event.gifted && !t.event.bulkGifted && t.event.isCommunityGift || !t.event.gifted && t.event.bulkGifted && !t.event.isCommunityGift) && t.event;
2913
+ (!r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && r.event.isCommunityGift || !r.event.gifted && r.event.bulkGifted && !r.event.isCommunityGift) && r.event;
2828
2914
  break;
2829
2915
  }
2830
2916
  case "raid-latest": {
2831
- t.event;
2917
+ r.event;
2832
2918
  break;
2833
2919
  }
2834
2920
  }
2835
2921
  break;
2836
2922
  }
2837
2923
  case "youtube": {
2838
- const t = a.data;
2839
- switch (t.listener) {
2924
+ const r = n.data;
2925
+ switch (r.listener) {
2840
2926
  case "message": {
2841
- t.event, $.execute({ provider: "youtube", data: t });
2927
+ r.event, P.execute({ provider: "youtube", data: r });
2842
2928
  break;
2843
2929
  }
2844
2930
  case "subscriber-latest": {
2845
- t.event;
2931
+ r.event;
2846
2932
  break;
2847
2933
  }
2848
2934
  case "sponsor-latest": {
2849
- t.event, (!t.event.gifted && !t.event.bulkGifted && !t.event.isCommunityGift || t.event.gifted && !t.event.bulkGifted && !t.event.isCommunityGift || t.event.gifted && !t.event.bulkGifted && t.event.isCommunityGift || !t.event.gifted && t.event.bulkGifted && !t.event.isCommunityGift) && t.event;
2935
+ r.event, (!r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && r.event.isCommunityGift || !r.event.gifted && r.event.bulkGifted && !r.event.isCommunityGift) && r.event;
2850
2936
  break;
2851
2937
  }
2852
2938
  case "superchat-latest": {
2853
- t.event;
2939
+ r.event;
2854
2940
  break;
2855
2941
  }
2856
2942
  }
2857
2943
  break;
2858
2944
  }
2945
+ case "kick": {
2946
+ n.data;
2947
+ break;
2948
+ }
2949
+ case "facebook": {
2950
+ n.data;
2951
+ break;
2952
+ }
2859
2953
  }
2954
+ window.client.emit("event", n);
2860
2955
  }
2861
2956
  });
2862
- const R = {
2863
- Client: I,
2864
- Simulation: L,
2865
- logger: new W()
2957
+ class V extends D {
2958
+ constructor(e) {
2959
+ window.client instanceof E && (super(), this.queue = [], this.priorityQueue = [], this.history = [], this.timeouts = [], this.running = !1, this.duration = void 0, this.loaded = !1, this.duration = e.duration, this.processor = e.processor, window.client.on("load", () => {
2960
+ this.emit("load"), this.loaded = !0;
2961
+ }));
2962
+ }
2963
+ enqueue(e, a = {}) {
2964
+ const t = {
2965
+ isoDate: (/* @__PURE__ */ new Date()).toISOString(),
2966
+ isLoop: a?.isLoop ?? !1,
2967
+ isPriority: a?.isPriority ?? !1,
2968
+ isImmediate: a?.isImmediate ?? !1,
2969
+ value: e
2970
+ }, n = this.hasItems();
2971
+ return t.isPriority && t.isImmediate ? (this.cancel(), this.priorityQueue.unshift(t)) : (t.isPriority ? this.priorityQueue : this.queue).push(t), this.running === !1 && n === !1 && this.run(), this.emit("update", this.queue, this.priorityQueue, this.history, this.timeouts), this;
2972
+ }
2973
+ async run() {
2974
+ if (!this.hasItems()) {
2975
+ this.running = !1;
2976
+ return;
2977
+ }
2978
+ this.running = !0, await this.next(), typeof this.duration == "number" && this.duration > 0 ? this.timeouts.push(setTimeout(() => this.run(), this.duration)) : (this.duration === 0 || this.duration === !1) && this.run();
2979
+ }
2980
+ async next() {
2981
+ const e = this.priorityQueue.length > 0 ? this.priorityQueue.shift() : this.queue.shift();
2982
+ if (!e) {
2983
+ this.running = !1;
2984
+ return;
2985
+ }
2986
+ try {
2987
+ await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
2988
+ } catch (t) {
2989
+ O.logger.error(`Error during item processing: ${t instanceof Error ? t.message : String(t)}`);
2990
+ }
2991
+ this.history.push(e);
2992
+ const a = e.isPriority ? this.priorityQueue : this.queue;
2993
+ e.isLoop && a.push(e);
2994
+ }
2995
+ resume() {
2996
+ return this.cancel(), this.hasItems() && this.run(), this;
2997
+ }
2998
+ update(e) {
2999
+ return this.queue = e.queue ?? this.queue, this.priorityQueue = e.priorityQueue ?? this.priorityQueue, this.history = e.history ?? this.history, this.hasItems() && this.running === !1 && window.client?.on("load", () => this.run()), this;
3000
+ }
3001
+ cancel() {
3002
+ this.timeouts.forEach((e) => clearTimeout(e)), this.timeouts = [], this.running = !1, this.emit("cancel");
3003
+ }
3004
+ hasItems() {
3005
+ return this.queue.length > 0 || this.priorityQueue.length > 0;
3006
+ }
3007
+ }
3008
+ const O = {
3009
+ Client: E,
3010
+ Simulation: j,
3011
+ logger: new q(),
3012
+ utils: {
3013
+ findEmotesInText: N,
3014
+ replaceEmotesWithHTML: B
3015
+ },
3016
+ modules: {
3017
+ Button: $,
3018
+ Command: P,
3019
+ EventProvider: D,
3020
+ useStorage: G,
3021
+ useQueue: V
3022
+ }
2866
3023
  };
2867
- typeof window < "u" && (window.Tixyel = R);
3024
+ typeof window < "u" && (window.Tixyel = O);
2868
3025
  export {
2869
- R as Tixyel
3026
+ O as Tixyel
2870
3027
  };
2871
3028
  //# sourceMappingURL=index.es.js.map