@tixyel/streamelements 6.0.2 → 6.1.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.es.js CHANGED
@@ -1,4 +1,4 @@
1
- class Z {
1
+ class X {
2
2
  constructor() {
3
3
  this.registeredEvents = {};
4
4
  }
@@ -49,15 +49,12 @@ class Z {
49
49
  return this.registeredEvents[e] = [], this;
50
50
  }
51
51
  }
52
- var tt = [];
53
- class et extends Z {
52
+ const tt = [];
53
+ class it extends X {
54
54
  constructor(e) {
55
- super(), this.id = "default", this.loaded = !1, this.SE_API = null, this.id = e.id || this.id, this.data = e.data ?? {}, tt.push(this), this.start();
56
- }
57
- start() {
58
- gt?.then((e) => {
59
- this.SE_API = e, e.store.get(this.id).then((t) => {
60
- this.data = t ?? this.data, this.loaded = !0, this.emit("load", this.data), JSON.stringify(this.data) !== JSON.stringify(t) && this.emit("update", this.data);
55
+ super(), this.SE_API = null, this.id = "default", this.loaded = !1, this.id = e.id || this.id, this.data = e.data ?? {}, tt.push(this), ct?.then((t) => {
56
+ this.SE_API = t, t.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);
61
58
  }).catch(() => {
62
59
  this.loaded = !0, this.emit("load", this.data);
63
60
  });
@@ -86,7 +83,7 @@ class et extends Z {
86
83
  * @param value Value to add
87
84
  */
88
85
  add(e, t) {
89
- this.loaded && (et.setByPath(this.data, e, t), this.save(this.data));
86
+ this.loaded && (it.setByPath(this.data, e, t), this.save(this.data));
90
87
  }
91
88
  /**
92
89
  * Clears all data from the storage.
@@ -112,7 +109,7 @@ class et extends Z {
112
109
  return e === "load" && this.loaded ? (t.apply(this, [this.data]), this) : (super.on(e, t), this);
113
110
  }
114
111
  }
115
- class G extends Z {
112
+ class G extends X {
116
113
  constructor(e) {
117
114
  super(), this.id = "default", this.debug = !1, this.fields = {}, this.loaded = !1, this.actions = {
118
115
  commands: [],
@@ -121,7 +118,7 @@ class G extends Z {
121
118
  avatar: 30,
122
119
  pronoun: 60,
123
120
  emote: 120
124
- }, this.id = e.id || this.id, this.storage = new et({
121
+ }, this.id = e.id || this.id, this.storage = new it({
125
122
  id: this.id,
126
123
  data: {
127
124
  user: {},
@@ -154,7 +151,7 @@ class G extends Z {
154
151
  ]), this) : (super.on(e, t), this);
155
152
  }
156
153
  }
157
- class Q {
154
+ class Z {
158
155
  constructor(e) {
159
156
  this.prefix = "!", this.arguments = !1, this.test = `${this.prefix}${this.name} arg1 arg2`, this.aliases = [], this.permissions = void 0, this.admins = [], window.client instanceof G && (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"));
160
157
  }
@@ -187,8 +184,8 @@ class Q {
187
184
  case "kick":
188
185
  return !1;
189
186
  }
190
- const m = this.verify(i, s, a);
191
- return m === !0 && this.run.apply(window.client, [a, t]), m;
187
+ const l = this.verify(i, s, a);
188
+ return l === !0 && this.run.apply(window.client, [a, t]), l;
192
189
  }
193
190
  remove() {
194
191
  if (!(window.client instanceof G)) return;
@@ -204,7 +201,7 @@ class Q {
204
201
  var s = [i.name, ...i.aliases ?? []], n = t.event.data.text.replace(i.prefix, "").split(" ")[0];
205
202
  return s.includes(n);
206
203
  });
207
- if (a.length && a.every((i) => i instanceof Q))
204
+ if (a.length && a.every((i) => i instanceof Z))
208
205
  return a.forEach((i) => {
209
206
  i.parse(t.event.data.text, e), window.client.emit("action", i, "executed"), R.received(`Command executed: ${t.event.data.text} by ${t.event.data.nick || t.event.data.displayName}`, t);
210
207
  }), !0;
@@ -216,7 +213,7 @@ class Q {
216
213
  }
217
214
  }
218
215
  }
219
- const lt = [
216
+ const ut = [
220
217
  "aliceblue",
221
218
  "antiquewhite",
222
219
  "aqua",
@@ -367,7 +364,7 @@ const lt = [
367
364
  "yellowgreen",
368
365
  "transparent"
369
366
  ];
370
- function pt(h, e) {
367
+ function ft(h, e) {
371
368
  if (!e) return null;
372
369
  switch (e) {
373
370
  case "hex": {
@@ -390,7 +387,7 @@ function pt(h, e) {
390
387
  const t = h.match(/hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*([\d.]+))?\s*\)/);
391
388
  if (!t) return null;
392
389
  const a = parseInt(t[1]), i = parseInt(t[2]), s = parseInt(t[3]), n = t[4] ? parseFloat(t[4]) : 1;
393
- return { ...bt(a, i, s), a: n };
390
+ return { ...yt(a, i, s), a: n };
394
391
  }
395
392
  case "css-color-name": {
396
393
  const t = document.createElement("canvas");
@@ -405,18 +402,18 @@ function pt(h, e) {
405
402
  return null;
406
403
  }
407
404
  }
408
- function ft(h, e = !0) {
405
+ function bt(h, e = !0) {
409
406
  const t = (i) => Math.round(i).toString(16).padStart(2, "0");
410
407
  let a = `#${t(h.r)}${t(h.g)}${t(h.b)}`;
411
408
  return e && h.a < 1 && (a += t(h.a * 255)), a;
412
409
  }
413
- function dt(h, e, t) {
410
+ function lt(h, e, t) {
414
411
  h /= 255, e /= 255, t /= 255;
415
412
  const a = Math.max(h, e, t), i = Math.min(h, e, t), s = a - i;
416
- let n = 0, m = 0;
413
+ let n = 0, l = 0;
417
414
  const o = (a + i) / 2;
418
415
  if (s !== 0)
419
- switch (m = o > 0.5 ? s / (2 - a - i) : s / (a + i), a) {
416
+ switch (l = o > 0.5 ? s / (2 - a - i) : s / (a + i), a) {
420
417
  case h:
421
418
  n = ((e - t) / s + (e < t ? 6 : 0)) / 6;
422
419
  break;
@@ -429,18 +426,18 @@ function dt(h, e, t) {
429
426
  }
430
427
  return {
431
428
  h: Math.round(n * 360),
432
- s: Math.round(m * 100),
429
+ s: Math.round(l * 100),
433
430
  l: Math.round(o * 100)
434
431
  };
435
432
  }
436
- function bt(h, e, t) {
433
+ function yt(h, e, t) {
437
434
  h /= 360, e /= 100, t /= 100;
438
435
  let a, i, s;
439
436
  if (e === 0)
440
437
  a = i = s = t;
441
438
  else {
442
- const n = (b, g, c) => (c < 0 && (c += 1), c > 1 && (c -= 1), c < 0.16666666666666666 ? b + (g - b) * 6 * c : c < 0.5 ? g : c < 0.6666666666666666 ? b + (g - b) * (0.6666666666666666 - c) * 6 : b), m = t < 0.5 ? t * (1 + e) : t + e - t * e, o = 2 * t - m;
443
- a = n(o, m, h + 1 / 3), i = n(o, m, h), s = n(o, m, h - 1 / 3);
439
+ const n = (b, g, c) => (c < 0 && (c += 1), c > 1 && (c -= 1), c < 0.16666666666666666 ? b + (g - b) * 6 * c : c < 0.5 ? g : c < 0.6666666666666666 ? b + (g - b) * (0.6666666666666666 - c) * 6 : b), l = t < 0.5 ? t * (1 + e) : t + e - t * e, o = 2 * t - l;
440
+ a = n(o, l, h + 1 / 3), i = n(o, l, h), s = n(o, l, h - 1 / 3);
444
441
  }
445
442
  return {
446
443
  r: Math.round(a * 255),
@@ -448,13 +445,13 @@ function bt(h, e, t) {
448
445
  b: Math.round(s * 255)
449
446
  };
450
447
  }
451
- async function yt(h, e, t) {
452
- const a = lt;
448
+ async function wt(h, e, t) {
449
+ const a = ut;
453
450
  let i = a[0], s = 1 / 0;
454
451
  for await (const n of a) {
455
- const m = document.createElement("canvas");
456
- m.width = m.height = 1;
457
- const o = m.getContext("2d");
452
+ const l = document.createElement("canvas");
453
+ l.width = l.height = 1;
454
+ const o = l.getContext("2d");
458
455
  if (!o) continue;
459
456
  o.fillStyle = n, o.fillRect(0, 0, 1, 1);
460
457
  const [b, g, c] = o.getImageData(0, 0, 1, 1).data, d = Math.sqrt(Math.pow(h - b, 2) + Math.pow(e - g, 2) + Math.pow(t - c, 2));
@@ -462,7 +459,7 @@ async function yt(h, e, t) {
462
459
  }
463
460
  return i;
464
461
  }
465
- const wt = [
462
+ const vt = [
466
463
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/13e5fa74-defa-11e9-809c-784f43822e80-profile_image-300x300.png",
467
464
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/dbdc9198-def8-11e9-8681-784f43822e80-profile_image-300x300.png",
468
465
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/998f01ae-def8-11e9-b95c-784f43822e80-profile_image-300x300.png",
@@ -470,7 +467,7 @@ const wt = [
470
467
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/ebe4cd89-b4f4-4cd9-adac-2f30151b4209-profile_image-300x300.png",
471
468
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/215b7342-def9-11e9-9a66-784f43822e80-profile_image-300x300.png",
472
469
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/ead5c8b2-a4c9-4724-b1dd-9f00b46cbd3d-profile_image-300x300.png"
473
- ], vt = {
470
+ ], kt = {
474
471
  "100 bits": {
475
472
  type: "100 bits",
476
473
  version: "1",
@@ -561,7 +558,7 @@ const wt = [
561
558
  url: "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/3",
562
559
  description: "VIP"
563
560
  }
564
- }, kt = Object.values([
561
+ }, Ct = Object.values([
565
562
  {
566
563
  type: "twitch",
567
564
  name: "TheIlluminati",
@@ -1918,7 +1915,7 @@ const wt = [
1918
1915
  end: 0
1919
1916
  }), h),
1920
1917
  []
1921
- ), Ct = [], jt = [
1918
+ ), jt = [], xt = [
1922
1919
  "Hello everyone!",
1923
1920
  "PogChamp",
1924
1921
  "This stream is amazing!",
@@ -1969,7 +1966,7 @@ const wt = [
1969
1966
  "BloodTrail hunting time",
1970
1967
  "CatBag kitty!",
1971
1968
  "c! poggers"
1972
- ], xt = ["Local", "Tixyel", "Urie_s2", "itzzcatt", "BeniArts", "Cupidiko", "shy_madeit"], Ut = ["1000", "2000", "3000", "prime"], Et = [
1969
+ ], Ut = ["Local", "Tixyel", "Urie_s2", "itzzcatt", "BeniArts", "Cupidiko", "shy_madeit"], Et = ["1000", "2000", "3000", "prime"], It = [
1973
1970
  "Filiz",
1974
1971
  "Astrid",
1975
1972
  "Tatyana",
@@ -5233,13 +5230,13 @@ const wt = [
5233
5230
  ];
5234
5231
  var D;
5235
5232
  ((h) => {
5236
- h.avatars = wt, h.badges = vt, h.css_color_names = lt, h.emotes = kt, h.items = Ct, h.messages = jt, h.names = xt, h.tiers = Ut, h.tts = Et, h.youtube_emotes = Tt;
5233
+ h.avatars = vt, h.badges = kt, h.css_color_names = ut, h.emotes = Ct, h.items = jt, h.messages = xt, h.names = Ut, h.tiers = Et, h.tts = It, h.youtube_emotes = Tt;
5237
5234
  })(D || (D = {}));
5238
5235
  var y;
5239
5236
  ((h) => {
5240
5237
  let e;
5241
5238
  ((n) => {
5242
- function m(g, c = "cardinal") {
5239
+ function l(g, c = "cardinal") {
5243
5240
  const d = {
5244
5241
  single: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],
5245
5242
  tens: ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"],
@@ -5248,12 +5245,12 @@ var y;
5248
5245
  single: ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"],
5249
5246
  tens: ["tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"],
5250
5247
  decades: ["twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"]
5251
- }, l = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"], p = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion"], C = p.map((U) => U ? `${U}th` : "");
5248
+ }, m = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"], p = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion"], C = p.map((U) => U ? `${U}th` : "");
5252
5249
  if (g = Math.abs(Math.floor(g)), c === "suffix") {
5253
5250
  const U = g % 100;
5254
5251
  if (U >= 11 && U <= 13) return `${g}th`;
5255
5252
  const S = g % 10;
5256
- return `${g}${l[S]}`;
5253
+ return `${g}${m[S]}`;
5257
5254
  }
5258
5255
  function v(U, S) {
5259
5256
  if (U < 10) return S === "ordinal" ? f.single[U] : d.single[U];
@@ -5298,7 +5295,7 @@ var y;
5298
5295
  }
5299
5296
  return J.join(", ");
5300
5297
  }
5301
- n.translate = m;
5298
+ n.translate = l;
5302
5299
  function o(g, c = 0, d = 100) {
5303
5300
  return Math.min(Math.max(g, c), d);
5304
5301
  }
@@ -5309,17 +5306,17 @@ var y;
5309
5306
  }
5310
5307
  n.round = b;
5311
5308
  })(e = h.number || (h.number = {})), ((n) => {
5312
- function m(d, f) {
5309
+ function l(d, f) {
5313
5310
  return new Promise(
5314
- (l) => setTimeout(() => {
5311
+ (m) => setTimeout(() => {
5315
5312
  if (f) {
5316
5313
  const p = f();
5317
- l(p ?? null);
5318
- } else l(null);
5314
+ m(p ?? null);
5315
+ } else m(null);
5319
5316
  }, d)
5320
5317
  );
5321
5318
  }
5322
- n.delay = m;
5319
+ n.delay = l;
5323
5320
  function o(d) {
5324
5321
  return Object.entries(d);
5325
5322
  }
@@ -5333,9 +5330,9 @@ var y;
5333
5330
  }
5334
5331
  n.typedKeys = g;
5335
5332
  function c(d) {
5336
- const f = Object.values(d).reduce((v, k) => v + k, 0), l = o(d).sort((v, k) => k[1] - v[1]), p = Math.random() * f;
5333
+ const f = Object.values(d).reduce((v, k) => v + k, 0), m = o(d).sort((v, k) => k[1] - v[1]), p = Math.random() * f;
5337
5334
  let C = 0;
5338
- for (const [v, k] of l)
5335
+ for (const [v, k] of m)
5339
5336
  if (C += k, p < C)
5340
5337
  return v;
5341
5338
  }
@@ -5343,24 +5340,24 @@ var y;
5343
5340
  })(h.utils || (h.utils = {}));
5344
5341
  let t;
5345
5342
  ((n) => {
5346
- function m(d, f, l) {
5343
+ function l(d, f, m) {
5347
5344
  const p = f.match(/^<span(?: class="[^"]*")? style="([^"]*)">(.*)<\/span>$/s);
5348
5345
  if (p) {
5349
5346
  const C = p[1], v = p[2], k = p[0].match(/class="([^"]*)"/)?.[1] || "";
5350
5347
  let j = [C, d].filter((P) => P.length).map((P) => P.endsWith(";") ? P.slice(0, -1) : P).join("; ").replace(/\s*;\s*/g, "; ").trim();
5351
- return j.endsWith(";") || (j += ";"), `<span${k ? ` class="${k} ${l ?? ""}"` : ""}${j ? ` style="${j}"` : ""}>${v}</span>`;
5348
+ return j.endsWith(";") || (j += ";"), `<span${k ? ` class="${k} ${m ?? ""}"` : ""}${j ? ` style="${j}"` : ""}>${v}</span>`;
5352
5349
  } else
5353
- return d && d.length && !d.endsWith(";") && (d += ";"), `<span${l ? ` class="${l}"` : ""}${d ? ` style="${d}"` : ""}>${f}</span>`;
5350
+ return d && d.length && !d.endsWith(";") && (d += ";"), `<span${m ? ` class="${m}"` : ""}${d ? ` style="${d}"` : ""}>${f}</span>`;
5354
5351
  }
5355
- n.mergeSpanStyles = m;
5356
- function o(d, f = 0, l = 1, p) {
5352
+ n.mergeSpanStyles = l;
5353
+ function o(d, f = 0, m = 1, p) {
5357
5354
  const { return: C = !1, parent: v, base: k } = p || {}, j = v || d.parentElement || document.body;
5358
5355
  if (!j)
5359
5356
  throw new Error("No parent element found for scaling");
5360
5357
  const P = j.getBoundingClientRect(), A = d.offsetWidth, J = d.offsetHeight;
5361
5358
  if (A === 0 || J === 0)
5362
5359
  throw new Error("Element has zero width or height, cannot scale");
5363
- const U = P.width * l / A, S = P.height * l / J;
5360
+ const U = P.width * m / A, S = P.height * m / J;
5364
5361
  let L = k === "width" ? U : k === "height" ? S : Math.min(U, S);
5365
5362
  if (f > 0) {
5366
5363
  const z = P.width * f / A, V = P.height * f / J, W = Math.max(z, V);
@@ -5375,23 +5372,23 @@ var y;
5375
5372
  }
5376
5373
  n.scale = o;
5377
5374
  function b(d, f = {}) {
5378
- const { parent: l = d.parentElement, prefer: p = "auto", min: C = 0, max: v = 1, apply: k = () => {
5375
+ const { parent: m = d.parentElement, prefer: p = "auto", min: C = 0, max: v = 1, apply: k = () => {
5379
5376
  } } = f;
5380
- if (!l)
5377
+ if (!m)
5381
5378
  throw new Error("No parent element found for scaling");
5382
- const j = l.getBoundingClientRect(), P = d.getBoundingClientRect(), A = j.width, J = j.height, U = P.width, S = P.height;
5379
+ const j = m.getBoundingClientRect(), P = d.getBoundingClientRect(), A = j.width, J = j.height, U = P.width, S = P.height;
5383
5380
  let L = A * C / U, O = J * C / S, z = A * v / U, V = J * v / S, W = Math.min(z, V);
5384
5381
  const F = Math.max(L, O);
5385
5382
  W = Math.max(W, F);
5386
- const B = U * W, at = S * W;
5387
- return p === "width" ? W = Math.max(L, Math.min(z, A / U)) : p === "height" ? W = Math.max(O, Math.min(V, J / S)) : B > A ? W = Math.max(L, Math.min(z, A / U)) : at > J && (W = Math.max(O, Math.min(V, J / S))), k.apply(d, [W, d]), W;
5383
+ const B = U * W, st = S * W;
5384
+ return p === "width" ? W = Math.max(L, Math.min(z, A / U)) : p === "height" ? W = Math.max(O, Math.min(V, J / S)) : B > A ? W = Math.max(L, Math.min(z, A / U)) : st > J && (W = Math.max(O, Math.min(V, J / S))), k.apply(d, [W, d]), W;
5388
5385
  }
5389
5386
  n.scalev2 = b;
5390
- function g(d, f = 1, l = {}) {
5387
+ function g(d, f = 1, m = {}) {
5391
5388
  const p = parseFloat(getComputedStyle(d).getPropertyValue("font-size")), C = {
5392
- minFontSize: l?.minFontSize ?? 0,
5393
- maxFontSize: l?.maxFontSize ?? p
5394
- }, v = l?.parent || d.parentElement;
5389
+ minFontSize: m?.minFontSize ?? 0,
5390
+ maxFontSize: m?.maxFontSize ?? p
5391
+ }, v = m?.parent || d.parentElement;
5395
5392
  if (!v)
5396
5393
  throw new Error("No parent element found for fitting text");
5397
5394
  const k = v.clientWidth * f, j = d.offsetWidth, P = k / j, A = p * P, J = e.balance(A, C.minFontSize, C.maxFontSize);
@@ -5434,80 +5431,80 @@ var y;
5434
5431
  })(t = h.element || (h.element = {}));
5435
5432
  let a;
5436
5433
  ((n) => {
5437
- function m(o, b = !0, g = "") {
5434
+ function l(o, b = !0, g = "") {
5438
5435
  const c = {};
5439
5436
  for (const d in o) {
5440
5437
  if (!Object.prototype.hasOwnProperty.call(o, d)) continue;
5441
- const f = o[d], l = g ? `${g}.${d}` : d;
5438
+ const f = o[d], m = g ? `${g}.${d}` : d;
5442
5439
  if (f == null) {
5443
- c[l] = String(f);
5440
+ c[m] = String(f);
5444
5441
  continue;
5445
5442
  }
5446
5443
  if (typeof f == "number" && isNaN(f)) {
5447
- c[l] = "NaN";
5444
+ c[m] = "NaN";
5448
5445
  continue;
5449
5446
  }
5450
5447
  if (typeof f == "number" && !isNaN(f)) {
5451
- c[l] = b ? String(f) : f;
5448
+ c[m] = b ? String(f) : f;
5452
5449
  continue;
5453
5450
  }
5454
5451
  if (f instanceof Date) {
5455
- c[l] = f.toISOString();
5452
+ c[m] = f.toISOString();
5456
5453
  continue;
5457
5454
  }
5458
5455
  if (f instanceof Map) {
5459
5456
  f.forEach((p, C) => {
5460
- c[`${l}.${C}`] = JSON.stringify(p);
5457
+ c[`${m}.${C}`] = JSON.stringify(p);
5461
5458
  });
5462
5459
  continue;
5463
5460
  }
5464
5461
  if (Array.isArray(f)) {
5465
5462
  f.forEach((p, C) => {
5466
- const v = `${l}:${C}`;
5467
- typeof p == "object" ? Object.assign(c, m(p, b, v)) : c[v] = b ? String(p) : p;
5463
+ const v = `${m}:${C}`;
5464
+ typeof p == "object" ? Object.assign(c, l(p, b, v)) : c[v] = b ? String(p) : p;
5468
5465
  });
5469
5466
  continue;
5470
5467
  }
5471
5468
  if (typeof f == "object") {
5472
- Object.assign(c, m(f, b, l));
5469
+ Object.assign(c, l(f, b, m));
5473
5470
  continue;
5474
5471
  }
5475
- c[l] = String(f);
5472
+ c[m] = String(f);
5476
5473
  }
5477
5474
  return c;
5478
5475
  }
5479
- n.flatten = m;
5476
+ n.flatten = l;
5480
5477
  })(a = h.object || (h.object = {})), ((n) => {
5481
- function m(c, d = D.emotes) {
5478
+ function l(c, d = D.emotes) {
5482
5479
  const f = [];
5483
- return d.forEach((l) => {
5484
- const p = l.name;
5480
+ return d.forEach((m) => {
5481
+ const p = m.name;
5485
5482
  let C = 0, v = 0;
5486
5483
  for (; C < c.length; ) {
5487
5484
  const k = c.indexOf(p, v);
5488
5485
  if (k === -1) break;
5489
5486
  const j = k > 0 ? c[k - 1] : " ", P = k + p.length < c.length ? c[k + p.length] : " ";
5490
- /\s/.test(j) && /\s/.test(P) && f.push({ ...l, start: k, end: k + p.length }), v = k + 1;
5487
+ /\s/.test(j) && /\s/.test(P) && f.push({ ...m, start: k, end: k + p.length }), v = k + 1;
5491
5488
  }
5492
- }), f.sort((l, p) => l.start - p.start);
5489
+ }), f.sort((m, p) => m.start - p.start);
5493
5490
  }
5494
- n.findEmotesInText = m;
5491
+ n.findEmotesInText = l;
5495
5492
  function o(c, d) {
5496
5493
  if (!d.length) return c;
5497
- let f = "", l = 0;
5494
+ let f = "", m = 0;
5498
5495
  return d.forEach((p) => {
5499
- f += c.substring(l, p.start);
5496
+ f += c.substring(m, p.start);
5500
5497
  const v = Array.from({ ...p.urls, length: 5 }).slice(1).reverse().filter(Boolean)[0] || p.urls[1];
5501
- f += `<img src="${v}" alt="${p.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, l = p.end;
5502
- }), f += c.substring(l), f;
5498
+ f += `<img src="${v}" alt="${p.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, m = p.end;
5499
+ }), f += c.substring(m), f;
5503
5500
  }
5504
5501
  n.replaceEmotesWithHTML = o;
5505
5502
  function b(c, d = D.youtube_emotes) {
5506
- return Array.from(c.matchAll(/:(.*?):/gim), (l) => l[0]).forEach((l) => {
5507
- const p = d.find((C) => C.shortcuts.includes(l) || C.searchTerms.includes(l.slice(1, -1)));
5503
+ return Array.from(c.matchAll(/:(.*?):/gim), (m) => m[0]).forEach((m) => {
5504
+ const p = d.find((C) => C.shortcuts.includes(m) || C.searchTerms.includes(m.slice(1, -1)));
5508
5505
  if (p) {
5509
5506
  const C = p.image.thumbnails.at(-1)?.url, v = p.image.accessibility.accessibilityData.label;
5510
- C && (c = c.replace(l, `<img src="${C}" alt="${v}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`));
5507
+ C && (c = c.replace(m, `<img src="${C}" alt="${v}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`));
5511
5508
  }
5512
5509
  }), c;
5513
5510
  }
@@ -5516,8 +5513,8 @@ var y;
5516
5513
  if (!Array.isArray(c) && typeof c == "string" && (c = c.split(",").map((v) => v.trim())), !c || !c.length) {
5517
5514
  var f = s.number(1, 3);
5518
5515
  for await (const v of Array.from({ length: f }, () => "")) {
5519
- var l = s.array(Object.keys(D.badges))[0];
5520
- !c.includes(l) && Array.isArray(c) ? c.push(l) : c = [l];
5516
+ var m = s.array(Object.keys(D.badges))[0];
5517
+ !c.includes(m) && Array.isArray(c) ? c.push(m) : c = [m];
5521
5518
  }
5522
5519
  }
5523
5520
  var p;
@@ -5554,7 +5551,7 @@ var y;
5554
5551
  }
5555
5552
  n.generateBadges = g;
5556
5553
  })(h.message || (h.message = {})), ((n) => {
5557
- function m(o) {
5554
+ function l(o) {
5558
5555
  var b = o.event?.provider || o.event?.service || o.event?.data?.provider || window.client.details.provider;
5559
5556
  return [
5560
5557
  "kvstore:update",
@@ -5565,19 +5562,19 @@ var y;
5565
5562
  "event:skip"
5566
5563
  ].some((d) => d === o.listener) && (b = "streamelements"), { provider: b, data: o };
5567
5564
  }
5568
- n.parseProvider = m;
5565
+ n.parseProvider = l;
5569
5566
  })(h.event || (h.event = {})), ((n) => {
5570
5567
  n.PRESETS = {};
5571
- async function m(g, c, d) {
5568
+ async function l(g, c, d) {
5572
5569
  const f = [];
5573
5570
  g.replace(c, (p, ...C) => {
5574
5571
  const v = typeof d == "function" ? d(p, ...C) : p;
5575
5572
  return f.push(Promise.resolve(v)), p;
5576
5573
  });
5577
- const l = await Promise.all(f);
5578
- return g.replace(c, () => l.shift() ?? "");
5574
+ const m = await Promise.all(f);
5575
+ return g.replace(c, () => m.shift() ?? "");
5579
5576
  }
5580
- n.replace = m;
5577
+ n.replace = l;
5581
5578
  function o(g) {
5582
5579
  return g.charAt(0).toUpperCase() + g.slice(1);
5583
5580
  }
@@ -5589,7 +5586,7 @@ var y;
5589
5586
  modifiers: {},
5590
5587
  aliases: {}
5591
5588
  }) {
5592
- const { mergeSpanStyles: f } = t, l = (r, u, w) => d.html ? f(r, u, w) : u, p = {
5589
+ const { mergeSpanStyles: f } = t, m = (r, u, w) => d.html ? f(r, u, w) : u, p = {
5593
5590
  skip: "<br/>",
5594
5591
  newline: "<br/>",
5595
5592
  ...c
@@ -5618,8 +5615,8 @@ var y;
5618
5615
  function A(r, u) {
5619
5616
  const w = r?.trim?.() ?? "";
5620
5617
  if (!w.length) return null;
5621
- const x = u[w], T = parseFloat(String(x !== void 0 ? x : w).replace(/\s/g, ""));
5622
- return isNaN(T) ? null : T;
5618
+ const x = u[w], I = parseFloat(String(x !== void 0 ? x : w).replace(/\s/g, ""));
5619
+ return isNaN(I) ? null : I;
5623
5620
  }
5624
5621
  function J(r, u, w) {
5625
5622
  const x = isNaN(Number(u)) ? 0 : Math.max(0, parseInt(String(u))), N = A(r, w);
@@ -5634,45 +5631,45 @@ var y;
5634
5631
  }
5635
5632
  }
5636
5633
  function U(r, u = /* @__PURE__ */ new Date()) {
5637
- const w = u.getTime() - r.getTime(), x = w >= 0, N = Math.abs(w), T = Math.floor(N / 1e3), I = Math.floor(T / 60), M = Math.floor(I / 60), E = Math.floor(M / 24), H = Math.floor(E / 30), _ = Math.floor(E / 365), Y = x ? "ago" : "from now";
5638
- return _ > 0 ? `${_}y ${Y}` : H > 0 ? `${H}mo ${Y}` : E > 0 ? `${E}d ${Y}` : M > 0 ? `${M}h ${Y}` : I > 0 ? `${I}m ${Y}` : `${Math.max(T, 0)}s ${Y}`;
5634
+ const w = u.getTime() - r.getTime(), x = w >= 0, N = Math.abs(w), I = Math.floor(N / 1e3), T = Math.floor(I / 60), M = Math.floor(T / 60), E = Math.floor(M / 24), H = Math.floor(E / 30), _ = Math.floor(E / 365), Y = x ? "ago" : "from now";
5635
+ return _ > 0 ? `${_}y ${Y}` : H > 0 ? `${H}mo ${Y}` : E > 0 ? `${E}d ${Y}` : M > 0 ? `${M}h ${Y}` : T > 0 ? `${T}m ${Y}` : `${Math.max(I, 0)}s ${Y}`;
5639
5636
  }
5640
5637
  function S(r, u, w) {
5641
5638
  const x = r?.trim?.() ?? "";
5642
5639
  if (!x.length) return r;
5643
- const N = w[x] ?? x, T = new Date(N);
5644
- if (isNaN(T.getTime())) return r;
5645
- const I = (u ?? "date").toString().toLowerCase();
5640
+ const N = w[x] ?? x, I = new Date(N);
5641
+ if (isNaN(I.getTime())) return r;
5642
+ const T = (u ?? "date").toString().toLowerCase();
5646
5643
  try {
5647
- switch (I) {
5644
+ switch (T) {
5648
5645
  case "time":
5649
- return T.toLocaleTimeString();
5646
+ return I.toLocaleTimeString();
5650
5647
  case "datetime":
5651
5648
  case "full":
5652
- return T.toLocaleString();
5649
+ return I.toLocaleString();
5653
5650
  case "relative":
5654
5651
  case "ago":
5655
- return U(T);
5652
+ return U(I);
5656
5653
  case "iso":
5657
- return T.toISOString();
5654
+ return I.toISOString();
5658
5655
  default:
5659
- return T.toLocaleDateString();
5656
+ return I.toLocaleDateString();
5660
5657
  }
5661
5658
  } catch {
5662
5659
  return r;
5663
5660
  }
5664
5661
  }
5665
5662
  function L(r, u, w) {
5666
- const x = r ?? "", [N, T = N] = x.split("|", 2), I = u?.trim();
5663
+ const x = r ?? "", [N, I = N] = x.split("|", 2), T = u?.trim();
5667
5664
  let M;
5668
- I && w[I] !== void 0 ? M = w[I] : M = w.amount ?? w.count;
5665
+ T && w[T] !== void 0 ? M = w[T] : M = w.amount ?? w.count;
5669
5666
  const E = parseFloat(String(M));
5670
- return isNaN(E) ? N : Math.abs(E) !== 1 ? T : N;
5667
+ return isNaN(E) ? N : Math.abs(E) !== 1 ? I : N;
5671
5668
  }
5672
5669
  function O(r, u, w) {
5673
- const x = u?.trim() ?? "", N = x && w[x] !== void 0 ? w[x] : "", T = String(N), I = (r ?? "").split("|").map((E) => E.trim()).filter((E) => E.length);
5670
+ const x = u?.trim() ?? "", N = x && w[x] !== void 0 ? w[x] : "", I = String(N), T = (r ?? "").split("|").map((E) => E.trim()).filter((E) => E.length);
5674
5671
  let M;
5675
- for (const E of I) {
5672
+ for (const E of T) {
5676
5673
  const H = E.indexOf(":");
5677
5674
  if (H === -1) continue;
5678
5675
  const _ = E.slice(0, H).trim(), Y = E.slice(H + 1);
@@ -5681,7 +5678,7 @@ var y;
5681
5678
  M = Y;
5682
5679
  continue;
5683
5680
  }
5684
- if (T === _) return Y;
5681
+ if (I === _) return Y;
5685
5682
  }
5686
5683
  }
5687
5684
  return M ?? "";
@@ -5695,14 +5692,14 @@ var y;
5695
5692
  const x = w[0], N = w[w.length - 1];
5696
5693
  if (x === '"' && N === '"' || x === "'" && N === "'")
5697
5694
  return w.slice(1, -1);
5698
- const T = w.toLowerCase();
5699
- if (T === "true") return !0;
5700
- if (T === "false") return !1;
5695
+ const I = w.toLowerCase();
5696
+ if (I === "true") return !0;
5697
+ if (I === "false") return !1;
5701
5698
  if (/^-?\d+(\.\d+)?$/.test(w)) return parseFloat(w);
5702
- const I = u?.[w];
5703
- if (I === void 0) return w;
5704
- const M = String(I).trim(), E = M.toLowerCase();
5705
- return E === "true" ? !0 : E === "false" ? !1 : /^-?\d+(\.\d+)?$/.test(M) ? parseFloat(M) : I;
5699
+ const T = u?.[w];
5700
+ if (T === void 0) return w;
5701
+ const M = String(T).trim(), E = M.toLowerCase();
5702
+ return E === "true" ? !0 : E === "false" ? !1 : /^-?\d+(\.\d+)?$/.test(M) ? parseFloat(M) : T;
5706
5703
  }
5707
5704
  function W(r) {
5708
5705
  if (typeof r == "boolean") return r;
@@ -5717,18 +5714,18 @@ var y;
5717
5714
  for (; w.startsWith("!"); )
5718
5715
  x = !x, w = w.slice(1).trim();
5719
5716
  const N = ["===", "!==", "==", "!=", ">=", "<=", ">", "<"];
5720
- let T = null, I = w, M = "";
5717
+ let I = null, T = w, M = "";
5721
5718
  for (const H of N) {
5722
5719
  const _ = w.indexOf(H);
5723
5720
  if (_ !== -1) {
5724
- T = H, I = w.slice(0, _), M = w.slice(_ + H.length);
5721
+ I = H, T = w.slice(0, _), M = w.slice(_ + H.length);
5725
5722
  break;
5726
5723
  }
5727
5724
  }
5728
5725
  let E;
5729
- if (T) {
5730
- const H = V(I, u), _ = V(M, u);
5731
- switch (T) {
5726
+ if (I) {
5727
+ const H = V(T, u), _ = V(M, u);
5728
+ switch (I) {
5732
5729
  case "===":
5733
5730
  E = H === _;
5734
5731
  break;
@@ -5758,7 +5755,7 @@ var y;
5758
5755
  break;
5759
5756
  }
5760
5757
  } else {
5761
- const H = V(I, u);
5758
+ const H = V(T, u);
5762
5759
  E = W(H);
5763
5760
  }
5764
5761
  return x ? !E : E;
@@ -5769,39 +5766,39 @@ var y;
5769
5766
  let x = !1;
5770
5767
  for (; w.startsWith("!"); )
5771
5768
  x = !x, w = w.slice(1).trim();
5772
- const N = w.split("||").map((I) => I.trim()).filter((I) => I.length);
5769
+ const N = w.split("||").map((T) => T.trim()).filter((T) => T.length);
5773
5770
  if (!N.length) return !!x;
5774
- let T = !1;
5775
- for (const I of N) {
5776
- const M = I.split("&&").map((H) => H.trim()).filter((H) => H.length);
5771
+ let I = !1;
5772
+ for (const T of N) {
5773
+ const M = T.split("&&").map((H) => H.trim()).filter((H) => H.length);
5777
5774
  if (!M.length) continue;
5778
5775
  let E = !0;
5779
5776
  for (const H of M) {
5780
5777
  const _ = F(H, u);
5781
5778
  if (E = E && _, !E) break;
5782
5779
  }
5783
- if (T = T || E, T) break;
5784
- }
5785
- return x ? !T : T;
5786
- }
5787
- const at = {
5788
- COLOR: (r, u) => l(u && i.validate(u) ? `color: ${u}` : "", r, "color"),
5789
- WEIGHT: (r, u) => l(u && !isNaN(parseInt(u)) ? `font-weight: ${u}` : "", r, "weight"),
5790
- SEMIBOLD: (r) => l("font-weight: 600", r, "semibold"),
5791
- BOLD: (r) => l("font-weight: bold", r, "bold"),
5792
- BLACK: (r) => l("font-weight: 900", r, "black"),
5793
- LIGHT: (r) => l("font-weight: lighter", r, "light"),
5794
- STRONG: (r) => l("font-weight: bolder", r, "strong"),
5795
- ITALIC: (r) => l("font-style: italic", r, "italic"),
5796
- UNDERLINE: (r) => l("text-decoration: underline", r, "underline"),
5797
- STRIKETHROUGH: (r) => l("text-decoration: line-through", r, "strikethrough"),
5798
- SUB: (r) => l("vertical-align: sub", r, "sub"),
5799
- SUP: (r) => l("vertical-align: super", r, "sup"),
5800
- LARGER: (r) => l("font-size: larger", r, "larger"),
5801
- SMALL: (r) => l("font-size: smaller", r, "small"),
5802
- SHADOW: (r, u) => l(`text-shadow: ${u}`, r, "shadow"),
5803
- SIZE: (r, u) => l(u ? `font-size: ${u}` : "", r, "size")
5804
- }, ot = {
5780
+ if (I = I || E, I) break;
5781
+ }
5782
+ return x ? !I : I;
5783
+ }
5784
+ const st = {
5785
+ COLOR: (r, u) => m(u && i.validate(u) ? `color: ${u}` : "", r, "color"),
5786
+ WEIGHT: (r, u) => m(u && !isNaN(parseInt(u)) ? `font-weight: ${u}` : "", r, "weight"),
5787
+ SEMIBOLD: (r) => m("font-weight: 600", r, "semibold"),
5788
+ BOLD: (r) => m("font-weight: bold", r, "bold"),
5789
+ BLACK: (r) => m("font-weight: 900", r, "black"),
5790
+ LIGHT: (r) => m("font-weight: lighter", r, "light"),
5791
+ STRONG: (r) => m("font-weight: bolder", r, "strong"),
5792
+ ITALIC: (r) => m("font-style: italic", r, "italic"),
5793
+ UNDERLINE: (r) => m("text-decoration: underline", r, "underline"),
5794
+ STRIKETHROUGH: (r) => m("text-decoration: line-through", r, "strikethrough"),
5795
+ SUB: (r) => m("vertical-align: sub", r, "sub"),
5796
+ SUP: (r) => m("vertical-align: super", r, "sup"),
5797
+ LARGER: (r) => m("font-size: larger", r, "larger"),
5798
+ SMALL: (r) => m("font-size: smaller", r, "small"),
5799
+ SHADOW: (r, u) => m(`text-shadow: ${u}`, r, "shadow"),
5800
+ SIZE: (r, u) => m(u ? `font-size: ${u}` : "", r, "size")
5801
+ }, dt = {
5805
5802
  ...{
5806
5803
  BT1: (r) => P > 1 ? r : "",
5807
5804
  BT0: (r) => P > 0 ? r : "",
@@ -5817,30 +5814,30 @@ var y;
5817
5814
  MAP: (r, u, w) => O(r, u, w),
5818
5815
  ESCAPE: (r) => z(r),
5819
5816
  IF: (r, u, w) => {
5820
- const x = r ?? "", [N, T] = x.split("?", 2);
5821
- if (!T) return x;
5822
- const [I, M = ""] = T.split("|", 2);
5823
- return B(N, w) ? I : M;
5817
+ const x = r ?? "", [N, I] = x.split("?", 2);
5818
+ if (!I) return x;
5819
+ const [T, M = ""] = I.split("|", 2);
5820
+ return B(N, w) ? T : M;
5824
5821
  },
5825
5822
  PRESET: (r, u) => {
5826
5823
  const w = u?.trim() ?? "";
5827
5824
  if (!w.length) return r;
5828
5825
  const x = n.PRESETS[w];
5829
5826
  if (!x || !x.length) return r;
5830
- const N = x.split(",").map((I) => I.trim()).filter((I) => I.length).map((I) => {
5831
- const [M, E] = I.split(":");
5827
+ const N = x.split(",").map((T) => T.trim()).filter((T) => T.length).map((T) => {
5828
+ const [M, E] = T.split(":");
5832
5829
  return { name: M.trim(), param: E?.trim() ?? null };
5833
5830
  });
5834
- let T = r;
5835
- for (const { name: I, param: M } of N)
5836
- T = K(T, I, M);
5837
- return T;
5831
+ let I = r;
5832
+ for (const { name: T, param: M } of N)
5833
+ I = K(I, T, M);
5834
+ return I;
5838
5835
  },
5839
5836
  FALLBACK: (r, u) => r.length ? r : u ?? r
5840
5837
  },
5841
- ...d?.html ? at : {},
5838
+ ...d?.html ? st : {},
5842
5839
  ...d.modifiers ?? {}
5843
- }, ct = {
5840
+ }, ht = {
5844
5841
  UPC: ["UPPERCASE", "UPPER", "UPP"],
5845
5842
  LOW: ["LOWERCASE", "LOWER", "LWC"],
5846
5843
  REV: ["REVERSE", "RVS"],
@@ -5871,47 +5868,47 @@ var y;
5871
5868
  ...d.aliases ?? {}
5872
5869
  };
5873
5870
  function K(r, u, w) {
5874
- const x = Object.entries(ct).find(([T, I]) => I.some((M) => M.toUpperCase() === u.toUpperCase()) ? !0 : T.toUpperCase() === u.toUpperCase()), N = x ? x[0] : u.toUpperCase();
5871
+ const x = Object.entries(ht).find(([I, T]) => T.some((M) => M.toUpperCase() === u.toUpperCase()) ? !0 : I.toUpperCase() === u.toUpperCase()), N = x ? x[0] : u.toUpperCase();
5875
5872
  try {
5876
- return ot[N] ? ot[N](r, typeof w == "string" ? w.trim() : null, k) : d?.html ? l("", r, N.toLowerCase()) : r;
5877
- } catch (T) {
5878
- return d?.debug && typeof console < "u" && typeof console.error == "function" && console.error("[Helper.string.compose] Modifier error", { name: u, param: w, error: T }), r;
5873
+ return dt[N] ? dt[N](r, typeof w == "string" ? w.trim() : null, k) : d?.html ? m("", r, N.toLowerCase()) : r;
5874
+ } catch (I) {
5875
+ return d?.debug && typeof console < "u" && typeof console.error == "function" && console.error("[Helper.string.compose] Modifier error", { name: u, param: w, error: I }), r;
5879
5876
  }
5880
5877
  }
5881
- function st(r) {
5878
+ function nt(r) {
5882
5879
  let u = r, w;
5883
5880
  for (; (w = j.MODIFIERS.exec(u)) !== null; ) {
5884
- const [x, N, T] = w, I = N.split(",").map((E) => E.trim()).filter((E) => E.length).map((E) => {
5881
+ const [x, N, I] = w, T = N.split(",").map((E) => E.trim()).filter((E) => E.length).map((E) => {
5885
5882
  const [H, _] = E.split(":");
5886
5883
  return { name: H.trim(), param: _?.trim() ?? null };
5887
5884
  });
5888
- let M = st(T);
5889
- for (const { name: E, param: H } of I)
5885
+ let M = nt(I);
5886
+ for (const { name: E, param: H } of T)
5890
5887
  M = K(M, E, H);
5891
5888
  u = u.replace(x, M ?? ""), j.MODIFIERS.lastIndex = 0;
5892
5889
  }
5893
5890
  return u;
5894
5891
  }
5895
- function X(r) {
5892
+ function Q(r) {
5896
5893
  let u = 0;
5897
5894
  const w = r.length;
5898
- function x(T) {
5899
- let I = "";
5895
+ function x(I) {
5896
+ let T = "";
5900
5897
  for (; u < w; )
5901
5898
  if (r[u] === "\\")
5902
- u + 1 < w ? (I += r[u + 1], u += 2) : u++;
5903
- else if (r[u] === "[" && (!T || T !== "["))
5904
- I += N();
5905
- else if (T && r[u] === T) {
5899
+ u + 1 < w ? (T += r[u + 1], u += 2) : u++;
5900
+ else if (r[u] === "[" && (!I || I !== "["))
5901
+ T += N();
5902
+ else if (I && r[u] === I) {
5906
5903
  u++;
5907
5904
  break;
5908
5905
  } else
5909
- I += r[u++];
5910
- return I;
5906
+ T += r[u++];
5907
+ return T;
5911
5908
  }
5912
5909
  function N() {
5913
5910
  u++;
5914
- const T = [];
5911
+ const I = [];
5915
5912
  for (; u < w && r[u] !== "="; ) {
5916
5913
  if (r[u] === ",") {
5917
5914
  u++;
@@ -5926,11 +5923,11 @@ var y;
5926
5923
  for (; u < w && r[u] !== "," && r[u] !== "="; ) u++;
5927
5924
  E = r.slice(H, u);
5928
5925
  }
5929
- M.length && T.push({ name: M, param: E }), r[u] === "," && u++;
5926
+ M.length && I.push({ name: M, param: E }), r[u] === "," && u++;
5930
5927
  }
5931
5928
  r[u] === "=" && u++;
5932
- const I = x("]");
5933
- return T.reduce((M, { name: E, param: H }) => K(M, E, H), I);
5929
+ const T = x("]");
5930
+ return I.reduce((M, { name: E, param: H }) => K(M, E, H), T);
5934
5931
  }
5935
5932
  return x();
5936
5933
  }
@@ -5938,12 +5935,12 @@ var y;
5938
5935
  j.PLACEHOLDERS,
5939
5936
  (r, u) => typeof k[u] == "string" || typeof k[u] == "number" ? String(k[u]) : u ?? u
5940
5937
  );
5941
- return $ = d.method === "loop" ? st($) : X($), $;
5938
+ return $ = d.method === "loop" ? nt($) : Q($), $;
5942
5939
  }
5943
5940
  n.compose = b;
5944
5941
  })(h.string || (h.string = {})), ((n) => {
5945
5942
  n.playing = !1;
5946
- function m(o, b = 100, g = !1) {
5943
+ function l(o, b = 100, g = !1) {
5947
5944
  if (!o || !o.length)
5948
5945
  throw new Error("No sound URL provided");
5949
5946
  try {
@@ -5951,33 +5948,33 @@ var y;
5951
5948
  let c = new AudioContext(), d = c.createGain();
5952
5949
  d.connect(c.destination), g && (n.audio = c, n.playing = !0), fetch(o).then((f) => f.arrayBuffer()).then((f) => c.decodeAudioData(f)).then((f) => {
5953
5950
  if (c.state !== "closed") {
5954
- const l = c.createBufferSource();
5955
- l.buffer = f, l.connect(d), d.gain.value = b / 100, l.start(c.currentTime);
5951
+ const m = c.createBufferSource();
5952
+ m.buffer = f, m.connect(d), d.gain.value = b / 100, m.start(c.currentTime);
5956
5953
  }
5957
5954
  });
5958
5955
  } catch (c) {
5959
5956
  throw new Error(`Error playing sound: ${c}`);
5960
5957
  }
5961
5958
  }
5962
- n.play = m;
5959
+ n.play = l;
5963
5960
  })(h.sound || (h.sound = {}));
5964
5961
  let i;
5965
5962
  ((n) => {
5966
- function m(c = 100, d = "") {
5963
+ function l(c = 100, d = "") {
5967
5964
  d = d.length > 7 ? d?.substring(0, 6) : d, c = c > 1 ? c / 100 : c;
5968
5965
  let f = Math.round(Math.min(Math.max(c, 0), 1) * 255).toString(16).toLowerCase().padStart(2, "0");
5969
5966
  return d + f;
5970
5967
  }
5971
- n.opacity = m;
5968
+ n.opacity = l;
5972
5969
  function o(c) {
5973
5970
  if (!c.startsWith("#") || c.length <= 7)
5974
5971
  return {
5975
5972
  color: c,
5976
5973
  opacity: 100
5977
5974
  };
5978
- var l = c.slice(-2), d = parseInt(l, 16) / 255, f = Math.round(d * 100), l = c.length > 7 ? c.slice(0, 7) : c;
5975
+ var m = c.slice(-2), d = parseInt(m, 16) / 255, f = Math.round(d * 100), m = c.length > 7 ? c.slice(0, 7) : c;
5979
5976
  return {
5980
- color: l,
5977
+ color: m,
5981
5978
  opacity: f
5982
5979
  };
5983
5980
  }
@@ -5992,25 +5989,25 @@ var y;
5992
5989
  const f = b(c);
5993
5990
  if (!f) throw new Error(`Invalid color format: ${c}`);
5994
5991
  if (f === d) throw new Error(`Color is already in the desired format: ${d}`);
5995
- const l = pt(c.trim(), f);
5996
- if (!l) throw new Error(`Failed to parse color: ${c}`);
5992
+ const m = ft(c.trim(), f);
5993
+ if (!m) throw new Error(`Failed to parse color: ${c}`);
5997
5994
  switch (d) {
5998
5995
  case "hex":
5999
- return ft(l, !1);
5996
+ return bt(m, !1);
6000
5997
  case "rgb":
6001
- return `rgb(${l.r}, ${l.g}, ${l.b})`;
5998
+ return `rgb(${m.r}, ${m.g}, ${m.b})`;
6002
5999
  case "rgba":
6003
- return `rgba(${l.r}, ${l.g}, ${l.b}, ${l.a})`;
6000
+ return `rgba(${m.r}, ${m.g}, ${m.b}, ${m.a})`;
6004
6001
  case "hsl": {
6005
- const p = dt(l.r, l.g, l.b);
6002
+ const p = lt(m.r, m.g, m.b);
6006
6003
  return `hsl(${p.h}, ${p.s}%, ${p.l}%)`;
6007
6004
  }
6008
6005
  case "hsla": {
6009
- const p = dt(l.r, l.g, l.b);
6010
- return `hsla(${p.h}, ${p.s}%, ${p.l}%, ${l.a})`;
6006
+ const p = lt(m.r, m.g, m.b);
6007
+ return `hsla(${p.h}, ${p.s}%, ${p.l}%, ${m.a})`;
6011
6008
  }
6012
6009
  case "css-color-name":
6013
- return await yt(l.r, l.g, l.b);
6010
+ return await wt(m.r, m.g, m.b);
6014
6011
  default:
6015
6012
  return null;
6016
6013
  }
@@ -6019,7 +6016,7 @@ var y;
6019
6016
  })(i = h.color || (h.color = {}));
6020
6017
  let s;
6021
6018
  ((n) => {
6022
- function m(p = "hex") {
6019
+ function l(p = "hex") {
6023
6020
  switch (p) {
6024
6021
  default:
6025
6022
  case "hex":
@@ -6050,7 +6047,7 @@ var y;
6050
6047
  }
6051
6048
  }
6052
6049
  }
6053
- n.color = m;
6050
+ n.color = l;
6054
6051
  function o(p, C, v = 0) {
6055
6052
  p > C && ([p, C] = [C, p]);
6056
6053
  const k = Math.random() * (C - p) + p;
@@ -6082,23 +6079,23 @@ var y;
6082
6079
  return new Date(v).toISOString();
6083
6080
  }
6084
6081
  n.daysOffset = f;
6085
- function l() {
6082
+ function m() {
6086
6083
  return crypto.randomUUID();
6087
6084
  }
6088
- n.uuid = l;
6085
+ n.uuid = m;
6089
6086
  })(s = h.random || (h.random = {}));
6090
6087
  })(y || (y = {}));
6091
- class it {
6088
+ class at {
6092
6089
  constructor(e) {
6093
6090
  this.field = "button", this.template = "button", this.name = "Button", this.value = "", window.client instanceof G && (this.field = e.field ?? this.field, this.template = e.template ?? (typeof this.field == "string" ? this.field : this.template), this.name = e.name ?? this.name, this.value = e.value ?? this.value, this.run = e.run, window.client.actions.buttons.push(this), window.client.emit("action", this, "created"));
6094
6091
  }
6095
6092
  generate(e) {
6096
6093
  return y.utils.typedValues(e).reduce(
6097
6094
  (a, i, s) => {
6098
- const n = y.string.compose(this.template, { index: s, ...i }, { html: !1 }), m = y.string.compose(this.name, { index: s, ...i }, { html: !1 });
6095
+ const n = y.string.compose(this.template, { index: s, ...i }, { html: !1 }), l = y.string.compose(this.name, { index: s, ...i }, { html: !1 });
6099
6096
  a[n] = {
6100
6097
  type: "button",
6101
- label: m
6098
+ label: l
6102
6099
  };
6103
6100
  let o = y.string.compose(String(this.value), { index: s, ...i }, { html: !1 });
6104
6101
  return isNaN(Number(o)) ? o.toLowerCase() === "true" ? o = !0 : o.toLowerCase() === "false" && (o = !1) : o = Number(o), typeof o < "u" && o && (typeof o != "string" || o.length) && (a[n].value = o), a;
@@ -6125,7 +6122,7 @@ class it {
6125
6122
  if (!(window.client instanceof G)) return !1;
6126
6123
  if (window.client.actions.buttons.length) {
6127
6124
  const a = window.client.actions.buttons.filter((i) => typeof i.field == "string" ? i.field === e : typeof i.field == "function" ? i.field(e, t) : !1);
6128
- if (a.length && a.every((i) => i instanceof it))
6125
+ if (a.length && a.every((i) => i instanceof at))
6129
6126
  return a.forEach((i) => {
6130
6127
  try {
6131
6128
  i.parse(e, t), window.client.emit("action", i, "executed"), R.received(`Button executed: ${e}${t ? ` with value: ${t}` : ""}`);
@@ -6239,14 +6236,32 @@ var q;
6239
6236
  },
6240
6237
  charityCampaignDonation: {
6241
6238
  latest: { name: t.name, amount: { type: "int", min: 50, max: 150 } },
6242
- "session-top-donation": { name: t.name, amount: { type: "int", min: 50, max: 200 } },
6243
- "weekly-top-donation": { name: t.name, amount: { type: "int", min: 200, max: 500 } },
6244
- "monthly-top-donation": { name: t.name, amount: { type: "int", min: 500, max: 800 } },
6245
- "alltime-top-donation": { name: t.name, amount: { type: "int", min: 800, max: 1e3 } },
6239
+ "session-top-donation": {
6240
+ name: t.name,
6241
+ amount: { type: "int", min: 50, max: 200 }
6242
+ },
6243
+ "weekly-top-donation": {
6244
+ name: t.name,
6245
+ amount: { type: "int", min: 200, max: 500 }
6246
+ },
6247
+ "monthly-top-donation": {
6248
+ name: t.name,
6249
+ amount: { type: "int", min: 500, max: 800 }
6250
+ },
6251
+ "alltime-top-donation": {
6252
+ name: t.name,
6253
+ amount: { type: "int", min: 800, max: 1e3 }
6254
+ },
6246
6255
  "session-top-donator": { name: t.name, amount: { type: "int", min: 50, max: 200 } },
6247
6256
  "weekly-top-donator": { name: t.name, amount: { type: "int", min: 200, max: 500 } },
6248
- "monthly-top-donator": { name: t.name, amount: { type: "int", min: 500, max: 800 } },
6249
- "alltime-top-donator": { name: t.name, amount: { type: "int", min: 800, max: 1e3 } },
6257
+ "monthly-top-donator": {
6258
+ name: t.name,
6259
+ amount: { type: "int", min: 500, max: 800 }
6260
+ },
6261
+ "alltime-top-donator": {
6262
+ name: t.name,
6263
+ amount: { type: "int", min: 800, max: 1e3 }
6264
+ },
6250
6265
  recent: {
6251
6266
  type: "recent",
6252
6267
  amount: 25,
@@ -6258,15 +6273,43 @@ var q;
6258
6273
  }
6259
6274
  },
6260
6275
  cheer: {
6261
- latest: { name: t.name, amount: { type: "int", min: 200, max: 800 }, message: t.message },
6262
- "session-top-donation": { name: t.name, amount: { type: "int", min: 200, max: 1e3 } },
6263
- "weekly-top-donation": { name: t.name, amount: { type: "int", min: 1e3, max: 5e3 } },
6264
- "monthly-top-donation": { name: t.name, amount: { type: "int", min: 5e3, max: 12e3 } },
6265
- "alltime-top-donation": { name: t.name, amount: { type: "int", min: 12e3, max: 2e4 } },
6266
- "session-top-donator": { name: t.name, amount: { type: "int", min: 200, max: 1e3 } },
6267
- "weekly-top-donator": { name: t.name, amount: { type: "int", min: 1e3, max: 5e3 } },
6268
- "monthly-top-donator": { name: t.name, amount: { type: "int", min: 5e3, max: 12e3 } },
6269
- "alltime-top-donator": { name: t.name, amount: { type: "int", min: 12e3, max: 2e4 } },
6276
+ latest: {
6277
+ name: t.name,
6278
+ amount: { type: "int", min: 200, max: 800 },
6279
+ message: t.message
6280
+ },
6281
+ "session-top-donation": {
6282
+ name: t.name,
6283
+ amount: { type: "int", min: 200, max: 1e3 }
6284
+ },
6285
+ "weekly-top-donation": {
6286
+ name: t.name,
6287
+ amount: { type: "int", min: 1e3, max: 5e3 }
6288
+ },
6289
+ "monthly-top-donation": {
6290
+ name: t.name,
6291
+ amount: { type: "int", min: 5e3, max: 12e3 }
6292
+ },
6293
+ "alltime-top-donation": {
6294
+ name: t.name,
6295
+ amount: { type: "int", min: 12e3, max: 2e4 }
6296
+ },
6297
+ "session-top-donator": {
6298
+ name: t.name,
6299
+ amount: { type: "int", min: 200, max: 1e3 }
6300
+ },
6301
+ "weekly-top-donator": {
6302
+ name: t.name,
6303
+ amount: { type: "int", min: 1e3, max: 5e3 }
6304
+ },
6305
+ "monthly-top-donator": {
6306
+ name: t.name,
6307
+ amount: { type: "int", min: 5e3, max: 12e3 }
6308
+ },
6309
+ "alltime-top-donator": {
6310
+ name: t.name,
6311
+ amount: { type: "int", min: 12e3, max: 2e4 }
6312
+ },
6270
6313
  session: { amount: { type: "int", min: 200, max: 1e3 } },
6271
6314
  week: { amount: { type: "int", min: 1e3, max: 5e3 } },
6272
6315
  month: { amount: { type: "int", min: 5e3, max: 12e3 } },
@@ -6285,14 +6328,35 @@ var q;
6285
6328
  },
6286
6329
  cheerPurchase: {
6287
6330
  latest: { name: t.name, amount: { type: "int", min: 200, max: 400 } },
6288
- "session-top-donation": { name: t.name, amount: { type: "int", min: 200, max: 400 } },
6289
- "weekly-top-donation": { name: t.name, amount: { type: "int", min: 400, max: 800 } },
6290
- "monthly-top-donation": { name: t.name, amount: { type: "int", min: 800, max: 1500 } },
6291
- "alltime-top-donation": { name: t.name, amount: { type: "int", min: 1500, max: 2e3 } },
6292
- "session-top-donator": { name: t.name, amount: { type: "int", min: 200, max: 400 } },
6331
+ "session-top-donation": {
6332
+ name: t.name,
6333
+ amount: { type: "int", min: 200, max: 400 }
6334
+ },
6335
+ "weekly-top-donation": {
6336
+ name: t.name,
6337
+ amount: { type: "int", min: 400, max: 800 }
6338
+ },
6339
+ "monthly-top-donation": {
6340
+ name: t.name,
6341
+ amount: { type: "int", min: 800, max: 1500 }
6342
+ },
6343
+ "alltime-top-donation": {
6344
+ name: t.name,
6345
+ amount: { type: "int", min: 1500, max: 2e3 }
6346
+ },
6347
+ "session-top-donator": {
6348
+ name: t.name,
6349
+ amount: { type: "int", min: 200, max: 400 }
6350
+ },
6293
6351
  "weekly-top-donator": { name: t.name, amount: { type: "int", min: 400, max: 800 } },
6294
- "monthly-top-donator": { name: t.name, amount: { type: "int", min: 800, max: 1500 } },
6295
- "alltime-top-donator": { name: t.name, amount: { type: "int", min: 1500, max: 2e3 } },
6352
+ "monthly-top-donator": {
6353
+ name: t.name,
6354
+ amount: { type: "int", min: 800, max: 1500 }
6355
+ },
6356
+ "alltime-top-donator": {
6357
+ name: t.name,
6358
+ amount: { type: "int", min: 1500, max: 2e3 }
6359
+ },
6296
6360
  recent: {
6297
6361
  type: "recent",
6298
6362
  amount: 25,
@@ -6305,14 +6369,38 @@ var q;
6305
6369
  },
6306
6370
  superchat: {
6307
6371
  latest: { name: t.name, amount: { type: "int", min: 100, max: 400 } },
6308
- "session-top-donation": { name: t.name, amount: { type: "int", min: 100, max: 500 } },
6309
- "weekly-top-donation": { name: t.name, amount: { type: "int", min: 500, max: 1e3 } },
6310
- "monthly-top-donation": { name: t.name, amount: { type: "int", min: 1e3, max: 2e3 } },
6311
- "alltime-top-donation": { name: t.name, amount: { type: "int", min: 2e3, max: 2500 } },
6312
- "session-top-donator": { name: t.name, amount: { type: "int", min: 100, max: 500 } },
6313
- "weekly-top-donator": { name: t.name, amount: { type: "int", min: 500, max: 1e3 } },
6314
- "monthly-top-donator": { name: t.name, amount: { type: "int", min: 1e3, max: 2e3 } },
6315
- "alltime-top-donator": { name: t.name, amount: { type: "int", min: 2e3, max: 2500 } },
6372
+ "session-top-donation": {
6373
+ name: t.name,
6374
+ amount: { type: "int", min: 100, max: 500 }
6375
+ },
6376
+ "weekly-top-donation": {
6377
+ name: t.name,
6378
+ amount: { type: "int", min: 500, max: 1e3 }
6379
+ },
6380
+ "monthly-top-donation": {
6381
+ name: t.name,
6382
+ amount: { type: "int", min: 1e3, max: 2e3 }
6383
+ },
6384
+ "alltime-top-donation": {
6385
+ name: t.name,
6386
+ amount: { type: "int", min: 2e3, max: 2500 }
6387
+ },
6388
+ "session-top-donator": {
6389
+ name: t.name,
6390
+ amount: { type: "int", min: 100, max: 500 }
6391
+ },
6392
+ "weekly-top-donator": {
6393
+ name: t.name,
6394
+ amount: { type: "int", min: 500, max: 1e3 }
6395
+ },
6396
+ "monthly-top-donator": {
6397
+ name: t.name,
6398
+ amount: { type: "int", min: 1e3, max: 2e3 }
6399
+ },
6400
+ "alltime-top-donator": {
6401
+ name: t.name,
6402
+ amount: { type: "int", min: 2e3, max: 2500 }
6403
+ },
6316
6404
  session: { amount: { type: "int", min: 100, max: 500 } },
6317
6405
  week: { amount: { type: "int", min: 500, max: 1e3 } },
6318
6406
  month: { amount: { type: "int", min: 1e3, max: 2e3 } },
@@ -6339,7 +6427,10 @@ var q;
6339
6427
  _type: { type: "array", options: ["follower", "subscriber", "cheer", "donation"] }
6340
6428
  },
6341
6429
  "level-goal": { amount: { type: "int", min: 0, max: 100 } },
6342
- "level-progress": { amount: { type: "int", min: 0, max: 100 }, percent: { type: "int", min: 0, max: 100 } },
6430
+ "level-progress": {
6431
+ amount: { type: "int", min: 0, max: 100 },
6432
+ percent: { type: "int", min: 0, max: 100 }
6433
+ },
6343
6434
  total: { amount: { type: "int", min: 0, max: 100 } },
6344
6435
  "latest-top-contributors": { type: "recent", amount: 25, value: { name: t.name } }
6345
6436
  },
@@ -6353,14 +6444,38 @@ var q;
6353
6444
  },
6354
6445
  tip: {
6355
6446
  latest: { name: t.name, amount: { type: "int", min: 100, max: 400 } },
6356
- "session-top-donation": { name: t.name, amount: { type: "int", min: 100, max: 500 } },
6357
- "weekly-top-donation": { name: t.name, amount: { type: "int", min: 500, max: 1e3 } },
6358
- "monthly-top-donation": { name: t.name, amount: { type: "int", min: 1e3, max: 2e3 } },
6359
- "alltime-top-donation": { name: t.name, amount: { type: "int", min: 2e3, max: 2500 } },
6360
- "session-top-donator": { name: t.name, amount: { type: "int", min: 100, max: 500 } },
6361
- "weekly-top-donator": { name: t.name, amount: { type: "int", min: 500, max: 1e3 } },
6362
- "monthly-top-donator": { name: t.name, amount: { type: "int", min: 1e3, max: 2e3 } },
6363
- "alltime-top-donator": { name: t.name, amount: { type: "int", min: 2e3, max: 2500 } },
6447
+ "session-top-donation": {
6448
+ name: t.name,
6449
+ amount: { type: "int", min: 100, max: 500 }
6450
+ },
6451
+ "weekly-top-donation": {
6452
+ name: t.name,
6453
+ amount: { type: "int", min: 500, max: 1e3 }
6454
+ },
6455
+ "monthly-top-donation": {
6456
+ name: t.name,
6457
+ amount: { type: "int", min: 1e3, max: 2e3 }
6458
+ },
6459
+ "alltime-top-donation": {
6460
+ name: t.name,
6461
+ amount: { type: "int", min: 2e3, max: 2500 }
6462
+ },
6463
+ "session-top-donator": {
6464
+ name: t.name,
6465
+ amount: { type: "int", min: 100, max: 500 }
6466
+ },
6467
+ "weekly-top-donator": {
6468
+ name: t.name,
6469
+ amount: { type: "int", min: 500, max: 1e3 }
6470
+ },
6471
+ "monthly-top-donator": {
6472
+ name: t.name,
6473
+ amount: { type: "int", min: 1e3, max: 2e3 }
6474
+ },
6475
+ "alltime-top-donator": {
6476
+ name: t.name,
6477
+ amount: { type: "int", min: 2e3, max: 2500 }
6478
+ },
6364
6479
  session: { amount: { type: "int", min: 100, max: 500 } },
6365
6480
  week: { amount: { type: "int", min: 500, max: 1e3 } },
6366
6481
  month: { amount: { type: "int", min: 1e3, max: 2e3 } },
@@ -6378,7 +6493,11 @@ var q;
6378
6493
  }
6379
6494
  },
6380
6495
  merch: {
6381
- latest: { name: t.name, amount: { type: "int", min: 0, max: 100 }, items: t.item },
6496
+ latest: {
6497
+ name: t.name,
6498
+ amount: { type: "int", min: 0, max: 100 },
6499
+ items: t.item
6500
+ },
6382
6501
  "goal-orders": { amount: { type: "int", min: 0, max: 100 } },
6383
6502
  "goal-items": { amount: { type: "int", min: 0, max: 100 } },
6384
6503
  "goal-total": { amount: { type: "int", min: 0, max: 100 } },
@@ -6399,12 +6518,14 @@ var q;
6399
6518
  const a = this.available();
6400
6519
  if (t) return t;
6401
6520
  const i = (n) => {
6402
- const m = (g) => {
6521
+ const l = (g) => {
6403
6522
  if (!g || !("amount" in g)) return [];
6404
6523
  const c = [];
6405
6524
  for (let d = 0; d < g.amount; d++)
6406
6525
  c.push(i(g.value));
6407
- return c.sort((d, f) => new Date(f.createdAt).getTime() - new Date(d.createdAt).getTime());
6526
+ return c.sort(
6527
+ (d, f) => new Date(f.createdAt).getTime() - new Date(d.createdAt).getTime()
6528
+ );
6408
6529
  }, o = (g) => {
6409
6530
  const c = {};
6410
6531
  for (const d in g) {
@@ -6424,7 +6545,7 @@ var q;
6424
6545
  case "array":
6425
6546
  return y.random.array(g.options)[0];
6426
6547
  case "recent":
6427
- return m(g);
6548
+ return l(g);
6428
6549
  default:
6429
6550
  return g;
6430
6551
  }
@@ -6432,10 +6553,10 @@ var q;
6432
6553
  return typeof n != "object" || n === null ? n : "type" in n && typeof n.type == "string" ? b(n) : o(n);
6433
6554
  };
6434
6555
  var s = Object.entries(i(a)).reduce(
6435
- (n, [m, o]) => (Object.entries(o).forEach(
6556
+ (n, [l, o]) => (Object.entries(o).forEach(
6436
6557
  ([b, g]) => (
6437
6558
  //
6438
- n[`${m}-${b}`] = g
6559
+ n[`${l}-${b}`] = g
6439
6560
  )
6440
6561
  ), n),
6441
6562
  {}
@@ -6496,44 +6617,66 @@ var q;
6496
6617
  const s = a.data;
6497
6618
  switch (s.listener) {
6498
6619
  case "cheer-latest": {
6499
- const n = s.event.amount, m = s.event.displayName ?? s.event.name, o = s.event.message;
6500
- t["cheer-latest"] = { name: m, amount: n, message: o };
6620
+ const n = s.event.amount, l = s.event.displayName ?? s.event.name, o = s.event.message;
6621
+ t["cheer-latest"] = { name: l, amount: n, message: o };
6501
6622
  const b = (g) => {
6502
6623
  if (g === "all") {
6503
6624
  b("alltime"), b("monthly"), b("weekly"), b("session");
6504
6625
  return;
6505
6626
  }
6506
6627
  const c = t[`cheer-${g}-top-donation`];
6507
- c && n > c.amount && (c.amount = n, c.name = m);
6508
- const d = t[`cheer-${g}-top-donator`], f = t["cheer-recent"].filter((p) => p.name.toLowerCase() === d.name.toLowerCase()).reduce((p, C) => p + C.amount, 0), l = t["cheer-recent"].filter((p) => p.name.toLowerCase() === m.toLowerCase()).reduce((p, C) => p + C.amount, 0);
6509
- l > f && (d.amount = l, d.name = m);
6628
+ c && n > c.amount && (c.amount = n, c.name = l);
6629
+ const d = t[`cheer-${g}-top-donator`], f = t["cheer-recent"].filter((p) => p.name.toLowerCase() === d.name.toLowerCase()).reduce((p, C) => p + C.amount, 0), m = t["cheer-recent"].filter((p) => p.name.toLowerCase() === l.toLowerCase()).reduce((p, C) => p + C.amount, 0);
6630
+ m > f && (d.amount = m, d.name = l);
6510
6631
  };
6511
- b("all"), t["cheer-session"].amount += n, t["cheer-week"].amount += n, t["cheer-month"].amount += n, t["cheer-total"].amount += n, t["cheer-count"].count += 1, t["cheer-goal"].amount += n, t["cheer-recent"].unshift({ name: m, amount: n, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["cheer-recent"] = (t["cheer-recent"] || []).sort(i);
6632
+ b("all"), t["cheer-session"].amount += n, t["cheer-week"].amount += n, t["cheer-month"].amount += n, t["cheer-total"].amount += n, t["cheer-count"].count += 1, t["cheer-goal"].amount += n, t["cheer-recent"].unshift({
6633
+ name: l,
6634
+ amount: n,
6635
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
6636
+ }), t["cheer-recent"] = (t["cheer-recent"] || []).sort(i);
6512
6637
  break;
6513
6638
  }
6514
6639
  case "follower-latest": {
6515
6640
  const n = s.event.displayName ?? s.event.name;
6516
- t["follower-latest"].name = n, t["follower-session"].count += 1, t["follower-week"].count += 1, t["follower-month"].count += 1, t["follower-total"].count += 1, t["follower-goal"].amount += 1, t["follower-recent"].unshift({ name: n, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["follower-recent"] = (t["follower-recent"] || []).sort(i);
6641
+ t["follower-latest"].name = n, t["follower-session"].count += 1, t["follower-week"].count += 1, t["follower-month"].count += 1, t["follower-total"].count += 1, t["follower-goal"].amount += 1, t["follower-recent"].unshift({
6642
+ name: n,
6643
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
6644
+ }), t["follower-recent"] = (t["follower-recent"] || []).sort(
6645
+ i
6646
+ );
6517
6647
  break;
6518
6648
  }
6519
6649
  case "subscriber-latest": {
6520
- const n = s.event.displayName ?? s.event.name, m = s.event.amount, o = s.event.tier, b = s.event.message;
6521
- if (t["subscriber-latest"] = { name: n, amount: m, tier: o, message: b ?? "" }, t["subscriber-recent"].find((g) => g.name.toLowerCase() === n.toLowerCase()) ? m > 1 && (t["subscriber-resub-latest"] = { name: n, amount: m, message: b ?? "" }, t["subscriber-resub-session"].count += 1) : (t["subscriber-new-latest"] = { name: n, amount: m, message: b ?? "" }, t["subscriber-new-session"].count += 1), !(!s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift)) if (s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift) {
6650
+ const n = s.event.displayName ?? s.event.name, l = s.event.amount, o = s.event.tier, b = s.event.message;
6651
+ if (t["subscriber-latest"] = { name: n, amount: l, tier: o, message: b ?? "" }, t["subscriber-recent"].find(
6652
+ (g) => g.name.toLowerCase() === n.toLowerCase()
6653
+ ) ? l > 1 && (t["subscriber-resub-latest"] = { name: n, amount: l, message: b ?? "" }, t["subscriber-resub-session"].count += 1) : (t["subscriber-new-latest"] = { name: n, amount: l, message: b ?? "" }, t["subscriber-new-session"].count += 1), !(!s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift)) if (s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift) {
6522
6654
  const g = s.event.sender;
6523
6655
  t["subscriber-gifted-latest"] = {
6524
6656
  name: n,
6525
- amount: m,
6657
+ amount: l,
6526
6658
  tier: o,
6527
6659
  message: b ?? "",
6528
6660
  sender: g
6529
- }, t["subscriber-gifted-session"].count += 1, t["subscriber-alltime-gifter"] = { name: g, amount: m };
6661
+ }, t["subscriber-gifted-session"].count += 1, t["subscriber-alltime-gifter"] = { name: g, amount: l };
6530
6662
  } else s.event.gifted && !s.event.bulkGifted && s.event.isCommunityGift || !s.event.gifted && s.event.bulkGifted && s.event.isCommunityGift;
6531
- t["subscriber-session"].count += m, t["subscriber-week"].count += m, t["subscriber-month"].count += m, t["subscriber-total"].count += m, t["subscriber-goal"].amount += m, t["subscriber-points"].amount += m, t["subscriber-recent"].unshift({ name: n, amount: m, tier: o, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["subscriber-recent"] = (t["subscriber-recent"] || []).sort(i);
6663
+ t["subscriber-session"].count += l, t["subscriber-week"].count += l, t["subscriber-month"].count += l, t["subscriber-total"].count += l, t["subscriber-goal"].amount += l, t["subscriber-points"].amount += l, t["subscriber-recent"].unshift({
6664
+ name: n,
6665
+ amount: l,
6666
+ tier: o,
6667
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
6668
+ }), t["subscriber-recent"] = (t["subscriber-recent"] || []).sort(
6669
+ i
6670
+ );
6532
6671
  break;
6533
6672
  }
6534
6673
  case "raid-latest": {
6535
- const n = s.event.displayName ?? s.event.name, m = s.event.amount;
6536
- t["raid-latest"] = { name: n, amount: m }, t["raid-recent"].unshift({ name: n, amount: m, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["raid-recent"] = (t["raid-recent"] || []).sort(i);
6674
+ const n = s.event.displayName ?? s.event.name, l = s.event.amount;
6675
+ t["raid-latest"] = { name: n, amount: l }, t["raid-recent"].unshift({
6676
+ name: n,
6677
+ amount: l,
6678
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
6679
+ }), t["raid-recent"] = (t["raid-recent"] || []).sort(i);
6537
6680
  break;
6538
6681
  }
6539
6682
  }
@@ -6542,11 +6685,11 @@ var q;
6542
6685
  case "youtube": {
6543
6686
  const s = a.data;
6544
6687
  if (s.listener === "superchat-latest") {
6545
- const n = s.event.displayName ?? s.event.name, m = s.event.amount;
6688
+ const n = s.event.displayName ?? s.event.name, l = s.event.amount;
6546
6689
  t["superchat-latest"] = {
6547
6690
  name: n.toLowerCase(),
6548
6691
  displayName: n,
6549
- amount: m,
6692
+ amount: l,
6550
6693
  _id: y.random.uuid(),
6551
6694
  sessionTop: !1,
6552
6695
  type: "superchat",
@@ -6560,14 +6703,14 @@ var q;
6560
6703
  return;
6561
6704
  }
6562
6705
  const g = t[`superchat-${b}-top-donation`];
6563
- g && m > g.amount && (g.amount = m, g.name = n);
6564
- const c = t[`superchat-${b}-top-donator`], d = t["superchat-recent"].filter((l) => l.name.toLowerCase() === c.name.toLowerCase()).reduce((l, p) => l + p.amount, 0), f = t["superchat-recent"].filter((l) => l.name.toLowerCase() === n.toLowerCase()).reduce((l, p) => l + p.amount, 0);
6706
+ g && l > g.amount && (g.amount = l, g.name = n);
6707
+ const c = t[`superchat-${b}-top-donator`], d = t["superchat-recent"].filter((m) => m.name.toLowerCase() === c.name.toLowerCase()).reduce((m, p) => m + p.amount, 0), f = t["superchat-recent"].filter((m) => m.name.toLowerCase() === n.toLowerCase()).reduce((m, p) => m + p.amount, 0);
6565
6708
  f > d && (c.amount = f, c.name = n);
6566
6709
  };
6567
- o("all"), t["superchat-session"].amount += m, t["superchat-week"].amount += m, t["superchat-month"].amount += m, t["superchat-total"].amount += m, t["superchat-count"].count += 1, t["superchat-goal"].amount += m, t["superchat-recent"].unshift({
6710
+ o("all"), t["superchat-session"].amount += l, t["superchat-week"].amount += l, t["superchat-month"].amount += l, t["superchat-total"].amount += l, t["superchat-count"].count += 1, t["superchat-goal"].amount += l, t["superchat-recent"].unshift({
6568
6711
  name: n.toLowerCase(),
6569
6712
  displayName: n,
6570
- amount: m,
6713
+ amount: l,
6571
6714
  _id: y.random.uuid(),
6572
6715
  sessionTop: !1,
6573
6716
  type: "superchat",
@@ -6581,19 +6724,23 @@ var q;
6581
6724
  case "streamelements": {
6582
6725
  const s = a.data;
6583
6726
  if (s.listener === "tip-latest") {
6584
- const n = s.event.displayName ?? s.event.name, m = s.event.amount;
6585
- t["tip-latest"] = { name: n, amount: m };
6727
+ const n = s.event.displayName ?? s.event.name, l = s.event.amount;
6728
+ t["tip-latest"] = { name: n, amount: l };
6586
6729
  const o = (b) => {
6587
6730
  if (b === "all") {
6588
6731
  o("alltime"), o("monthly"), o("weekly"), o("session");
6589
6732
  return;
6590
6733
  }
6591
6734
  const g = t[`tip-${b}-top-donation`];
6592
- g && m > g.amount && (g.amount = m, g.name = n);
6593
- const c = t[`tip-${b}-top-donator`], d = t["tip-recent"].filter((l) => l.name.toLowerCase() === c.name.toLowerCase()).reduce((l, p) => l + p.amount, 0), f = t["tip-recent"].filter((l) => l.name.toLowerCase() === n.toLowerCase()).reduce((l, p) => l + p.amount, 0);
6735
+ g && l > g.amount && (g.amount = l, g.name = n);
6736
+ const c = t[`tip-${b}-top-donator`], d = t["tip-recent"].filter((m) => m.name.toLowerCase() === c.name.toLowerCase()).reduce((m, p) => m + p.amount, 0), f = t["tip-recent"].filter((m) => m.name.toLowerCase() === n.toLowerCase()).reduce((m, p) => m + p.amount, 0);
6594
6737
  f > d && (c.amount = f, c.name = n);
6595
6738
  };
6596
- o("all"), t["tip-session"].amount += m, t["tip-week"].amount += m, t["tip-month"].amount += m, t["tip-total"].amount += m, t["tip-count"].count += 1, t["tip-goal"].amount += m, t["tip-recent"].unshift({ name: n, amount: m, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["tip-recent"] = (t["tip-recent"] || []).sort(i);
6739
+ o("all"), t["tip-session"].amount += l, t["tip-week"].amount += l, t["tip-month"].amount += l, t["tip-total"].amount += l, t["tip-count"].count += 1, t["tip-goal"].amount += l, t["tip-recent"].unshift({
6740
+ name: n,
6741
+ amount: l,
6742
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
6743
+ }), t["tip-recent"] = (t["tip-recent"] || []).sort(i);
6597
6744
  }
6598
6745
  break;
6599
6746
  }
@@ -6618,7 +6765,13 @@ var q;
6618
6765
  */
6619
6766
  async onEventReceived(t = "random", a = "random", i = {}) {
6620
6767
  const s = {
6621
- twitch: ["message", "follower-latest", "cheer-latest", "raid-latest", "subscriber-latest"],
6768
+ twitch: [
6769
+ "message",
6770
+ "follower-latest",
6771
+ "cheer-latest",
6772
+ "raid-latest",
6773
+ "subscriber-latest"
6774
+ ],
6622
6775
  streamelements: ["tip-latest"],
6623
6776
  youtube: ["message", "superchat-latest", "subscriber-latest", "sponsor-latest"],
6624
6777
  kick: [],
@@ -6627,18 +6780,27 @@ var q;
6627
6780
  switch (t) {
6628
6781
  default:
6629
6782
  case "random": {
6630
- var n = y.random.array(Object.keys(s).filter((O) => s[O].length))[0], m = y.random.array(s[n])[0];
6631
- return this.onEventReceived(n, m);
6783
+ var n = y.random.array(
6784
+ Object.keys(s).filter((O) => s[O].length)
6785
+ )[0], l = y.random.array(
6786
+ s[n]
6787
+ )[0];
6788
+ return this.onEventReceived(n, l);
6632
6789
  }
6633
6790
  case "twitch":
6634
6791
  switch (a) {
6635
6792
  default:
6636
6793
  case "random": {
6637
- var m = y.random.array(s[t])[0];
6638
- return this.onEventReceived(t, m);
6794
+ var l = y.random.array(
6795
+ s[t]
6796
+ )[0];
6797
+ return this.onEventReceived(t, l);
6639
6798
  }
6640
6799
  case "message": {
6641
- var o = i?.name ?? y.random.array(D.names.filter((z) => z.length))[0], b = i?.message ?? y.random.array(D.messages.filter((z) => z.length))[0], g = await y.message.generateBadges(i?.badges ?? [], t), c = y.message.findEmotesInText(b), d = y.message.replaceEmotesWithHTML(b, c), f = i?.color ?? y.random.color("hex"), l = i?.userId ?? y.random.number(1e7, 99999999).toString(), p = i?.msgId ?? y.random.uuid(), C = i?.time ?? Date.now(), v = i?.channel ?? client.details.user.username;
6800
+ var o = i?.name ?? y.random.array(D.names.filter((z) => z.length))[0], b = i?.message ?? y.random.array(D.messages.filter((z) => z.length))[0], g = await y.message.generateBadges(
6801
+ i?.badges ?? [],
6802
+ t
6803
+ ), c = y.message.findEmotesInText(b), d = y.message.replaceEmotesWithHTML(b, c), f = i?.color ?? y.random.color("hex"), m = i?.userId ?? y.random.number(1e7, 99999999).toString(), p = i?.msgId ?? y.random.uuid(), C = i?.time ?? Date.now(), v = i?.channel ?? client.details.user.username;
6642
6804
  return {
6643
6805
  listener: "message",
6644
6806
  event: {
@@ -6652,7 +6814,7 @@ var q;
6652
6814
  subscriber: g.keys.includes("subscriber") ? "1" : "0",
6653
6815
  turbo: g.keys.includes("turbo") ? "1" : "0",
6654
6816
  "tmi-sent-ts": C.toString(),
6655
- "user-id": l,
6817
+ "user-id": m,
6656
6818
  "user-type": "",
6657
6819
  color: f,
6658
6820
  "display-name": o,
@@ -6669,7 +6831,7 @@ var q;
6669
6831
  channel: v,
6670
6832
  text: b,
6671
6833
  isAction: !1,
6672
- userId: l,
6834
+ userId: m,
6673
6835
  msgId: p,
6674
6836
  badges: g.badges,
6675
6837
  emotes: c
@@ -6810,8 +6972,10 @@ var q;
6810
6972
  switch (a) {
6811
6973
  default:
6812
6974
  case "random": {
6813
- var m = y.random.array(s[t])[0];
6814
- return this.onEventReceived(t, m);
6975
+ var l = y.random.array(
6976
+ s[t]
6977
+ )[0];
6978
+ return this.onEventReceived(t, l);
6815
6979
  }
6816
6980
  case "tip":
6817
6981
  case "tip-latest": {
@@ -6887,13 +7051,18 @@ var q;
6887
7051
  switch (a) {
6888
7052
  default:
6889
7053
  case "random": {
6890
- var m = y.random.array(s[t])[0];
6891
- return this.onEventReceived(t, m);
7054
+ var l = y.random.array(
7055
+ s[t]
7056
+ )[0];
7057
+ return this.onEventReceived(t, l);
6892
7058
  }
6893
7059
  case "message": {
6894
- var o = i?.name ?? y.random.array(D.names.filter((X) => X.length))[0], b = i?.message ?? y.random.array(D.messages.filter((X) => X.length))[0];
6895
- const V = await y.message.generateBadges(i?.badges ?? [], t);
6896
- var c = y.message.findEmotesInText(b), d = y.message.replaceEmotesWithHTML(b, c), f = i?.color ?? y.random.color("hex"), l = i?.userId ?? y.random.number(1e7, 99999999).toString(), p = i?.msgId ?? y.random.uuid(), C = i?.time ?? Date.now(), j = i?.avatar ?? y.random.array(D.avatars)[0], v = i?.channel ?? client.details.user.username;
7060
+ var o = i?.name ?? y.random.array(D.names.filter((Q) => Q.length))[0], b = i?.message ?? y.random.array(D.messages.filter((Q) => Q.length))[0];
7061
+ const V = await y.message.generateBadges(
7062
+ i?.badges ?? [],
7063
+ t
7064
+ );
7065
+ var c = y.message.findEmotesInText(b), d = y.message.replaceEmotesWithHTML(b, c), f = i?.color ?? y.random.color("hex"), m = i?.userId ?? y.random.number(1e7, 99999999).toString(), p = i?.msgId ?? y.random.uuid(), C = i?.time ?? Date.now(), j = i?.avatar ?? y.random.array(D.avatars)[0], v = i?.channel ?? client.details.user.username;
6897
7066
  return {
6898
7067
  listener: "message",
6899
7068
  event: {
@@ -6921,7 +7090,7 @@ var q;
6921
7090
  ...V
6922
7091
  },
6923
7092
  msgId: p,
6924
- userId: l,
7093
+ userId: m,
6925
7094
  nick: o.toLowerCase(),
6926
7095
  badges: [],
6927
7096
  displayName: o,
@@ -7029,7 +7198,11 @@ var q;
7029
7198
  }, h.emulate = {
7030
7199
  twitch: {
7031
7200
  message(t = {}) {
7032
- h.generate.event.onEventReceived("twitch", "message", t).then((a) => {
7201
+ h.generate.event.onEventReceived(
7202
+ "twitch",
7203
+ "message",
7204
+ t
7205
+ ).then((a) => {
7033
7206
  a && h.emulate.send("onEventReceived", a);
7034
7207
  });
7035
7208
  },
@@ -7054,51 +7227,87 @@ var q;
7054
7227
  h.emulate.send("onEventReceived", a);
7055
7228
  },
7056
7229
  follower(t = {}) {
7057
- h.generate.event.onEventReceived("twitch", "follower-latest", t).then((a) => {
7230
+ h.generate.event.onEventReceived(
7231
+ "twitch",
7232
+ "follower-latest",
7233
+ t
7234
+ ).then((a) => {
7058
7235
  a && h.emulate.send("onEventReceived", a);
7059
7236
  });
7060
7237
  },
7061
7238
  raid(t = {}) {
7062
- h.generate.event.onEventReceived("twitch", "raid-latest", t).then((a) => {
7239
+ h.generate.event.onEventReceived(
7240
+ "twitch",
7241
+ "raid-latest",
7242
+ t
7243
+ ).then((a) => {
7063
7244
  a && h.emulate.send("onEventReceived", a);
7064
7245
  });
7065
7246
  },
7066
7247
  cheer(t = {}) {
7067
- h.generate.event.onEventReceived("twitch", "cheer-latest", t).then((a) => {
7248
+ h.generate.event.onEventReceived(
7249
+ "twitch",
7250
+ "cheer-latest",
7251
+ t
7252
+ ).then((a) => {
7068
7253
  a && h.emulate.send("onEventReceived", a);
7069
7254
  });
7070
7255
  },
7071
7256
  subscriber(t = {}) {
7072
- h.generate.event.onEventReceived("twitch", "subscriber-latest", t).then((a) => {
7257
+ h.generate.event.onEventReceived(
7258
+ "twitch",
7259
+ "subscriber-latest",
7260
+ t
7261
+ ).then((a) => {
7073
7262
  a && h.emulate.send("onEventReceived", a);
7074
7263
  });
7075
7264
  }
7076
7265
  },
7077
7266
  streamelements: {
7078
7267
  tip(t = {}) {
7079
- h.generate.event.onEventReceived("streamelements", "tip-latest", t).then((a) => {
7268
+ h.generate.event.onEventReceived(
7269
+ "streamelements",
7270
+ "tip-latest",
7271
+ t
7272
+ ).then((a) => {
7080
7273
  a && h.emulate.send("onEventReceived", a);
7081
7274
  });
7082
7275
  }
7083
7276
  },
7084
7277
  youtube: {
7085
7278
  message(t = {}) {
7086
- h.generate.event.onEventReceived("youtube", "message", t).then((a) => {
7279
+ h.generate.event.onEventReceived(
7280
+ "youtube",
7281
+ "message",
7282
+ t
7283
+ ).then((a) => {
7087
7284
  a && h.emulate.send("onEventReceived", a);
7088
7285
  });
7089
7286
  },
7090
7287
  subscriber(t = {}) {
7091
- h.generate.event.onEventReceived("youtube", "subscriber-latest", t).then((a) => {
7288
+ h.generate.event.onEventReceived(
7289
+ "youtube",
7290
+ "subscriber-latest",
7291
+ t
7292
+ ).then((a) => {
7092
7293
  a && h.emulate.send("onEventReceived", a);
7093
7294
  });
7094
7295
  },
7095
7296
  superchat(t = {}) {
7096
- h.generate.event.onEventReceived("youtube", "superchat-latest", t).then((a) => {
7297
+ h.generate.event.onEventReceived(
7298
+ "youtube",
7299
+ "superchat-latest",
7300
+ t
7301
+ ).then((a) => {
7097
7302
  a && h.emulate.send("onEventReceived", a);
7098
7303
  });
7099
7304
  },
7100
7305
  sponsor(t = {}) {
7101
- h.generate.event.onEventReceived("youtube", "sponsor-latest", t).then((a) => {
7306
+ h.generate.event.onEventReceived(
7307
+ "youtube",
7308
+ "sponsor-latest",
7309
+ t
7310
+ ).then((a) => {
7102
7311
  a && h.emulate.send("onEventReceived", a);
7103
7312
  });
7104
7313
  }
@@ -7138,45 +7347,56 @@ var q;
7138
7347
  };
7139
7348
  async function e(t = ["fields.json", "cf.json", "field.json", "customfields.json"], a = ["data.json", "fielddata.json", "fd.json", "DATA.json"], i) {
7140
7349
  const s = {
7141
- fields: t.find((m) => {
7350
+ fields: t.find((l) => {
7142
7351
  try {
7143
- return new URL("./" + m, window.location.href), !0;
7352
+ return new URL("./" + l, window.location.href), !0;
7144
7353
  } catch {
7145
7354
  return !1;
7146
7355
  }
7147
7356
  }),
7148
- data: a.find((m) => {
7357
+ data: a.find((l) => {
7149
7358
  try {
7150
- return new URL("./" + m, window.location.href), !0;
7359
+ return new URL("./" + l, window.location.href), !0;
7151
7360
  } catch {
7152
7361
  return !1;
7153
7362
  }
7154
7363
  })
7155
- }, n = await fetch("./" + (s.data ?? "data.json"), {
7156
- cache: "no-store"
7157
- }).then((m) => m.json()).catch(() => ({}));
7364
+ }, n = await fetch(
7365
+ "./" + (s.data ?? "data.json"),
7366
+ {
7367
+ cache: "no-store"
7368
+ }
7369
+ ).then((l) => l.json()).catch(() => ({}));
7158
7370
  await fetch("./" + (s.fields ?? "fields.json"), {
7159
7371
  cache: "no-store"
7160
- }).then((m) => m.json()).then(async (m) => {
7161
- const o = Object.entries(m).filter(([g, { value: c }]) => c != null).reduce(
7372
+ }).then((l) => l.json()).then(async (l) => {
7373
+ const o = Object.entries(l).filter(([g, { value: c }]) => c != null).reduce(
7162
7374
  (g, [c, { value: d }]) => (n && n[c] !== void 0 && (d = n[c]), g[c] = d, g),
7163
7375
  {
7164
7376
  ...n
7165
7377
  }
7166
- ), b = await h.generate.event.onWidgetLoad(o, await h.generate.session.get(i));
7378
+ ), b = await h.generate.event.onWidgetLoad(
7379
+ o,
7380
+ await h.generate.session.get(i)
7381
+ );
7167
7382
  window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: b }));
7168
7383
  });
7169
7384
  }
7170
7385
  h.start = e;
7171
7386
  })(q || (q = {}));
7172
- class mt extends Z {
7387
+ class gt extends X {
7173
7388
  constructor(e) {
7174
- if (super(), this.queue = [], this.priorityQueue = [], this.history = [], this.timeouts = [], this.running = !1, this.duration = void 0, this.loaded = !1, !(window.client instanceof G))
7175
- throw new Error("useQueue can only be instantiated after the Client is initialized.");
7176
- if (!e.processor || typeof e.processor != "function")
7389
+ if (super(), this.queue = [], this.priorityQueue = [], this.history = [], this.timeouts = [], this.running = !1, this.duration = void 0, this.loaded = !1, this.clientWaitRetryDelay = 50, !e.processor || typeof e.processor != "function")
7177
7390
  throw new Error("A valid processor function must be provided to useQueue.");
7178
- this.processor = e.processor, e.duration !== "client" && (this.duration = e.duration ?? 0), window.client.on("load", () => {
7179
- e.duration === "client" && (this.duration = window.client.fields?.widgetDuration ?? 0), this.emit("load"), this.loaded = !0;
7391
+ this.processor = e.processor, e.duration !== "client" && (this.duration = e.duration ?? 0), this.waitForClientAndBindLoad(e.duration);
7392
+ }
7393
+ waitForClientAndBindLoad(e = this.duration) {
7394
+ if (!(window?.client instanceof G)) {
7395
+ setTimeout(() => this.waitForClientAndBindLoad(e), this.clientWaitRetryDelay);
7396
+ return;
7397
+ }
7398
+ window.client.on("load", () => {
7399
+ e === "client" && (this.duration = window.client.fields?.widgetDuration ?? 0), this.emit("load"), this.loaded = !0;
7180
7400
  });
7181
7401
  }
7182
7402
  enqueue(e, t = {}) {
@@ -7209,7 +7429,9 @@ class mt extends Z {
7209
7429
  try {
7210
7430
  await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
7211
7431
  } catch (a) {
7212
- R.error(`Error during item processing: ${a instanceof Error ? a.message : String(a)}`);
7432
+ R.error(
7433
+ `Error during item processing: ${a instanceof Error ? a.message : String(a)}`
7434
+ );
7213
7435
  }
7214
7436
  this.history.push(e);
7215
7437
  const t = e.isPriority ? this.priorityQueue : this.queue;
@@ -7260,12 +7482,53 @@ class mt extends Z {
7260
7482
  return e === "load" && this.loaded ? (t.apply(this), this) : (super.on(e, t), this);
7261
7483
  }
7262
7484
  }
7485
+ const et = [];
7486
+ class St extends X {
7487
+ constructor(e = {}) {
7488
+ super(), this.SE_API = null, this.id = "widget communications", this.loaded = !1, this.history = [], this.detected = /* @__PURE__ */ new Set(), this.id = e.id || this.id, et.push(this), ct?.then(async (t) => {
7489
+ this.loaded = !0, this.SE_API = t, Promise.all([
7490
+ async () => {
7491
+ const a = await t.store.get(this.id);
7492
+ a && (this.history = a.slice(-10));
7493
+ },
7494
+ async () => {
7495
+ const a = await t.store.get(this.id + "_detected");
7496
+ a && (this.detected = new Set(a));
7497
+ }
7498
+ ]);
7499
+ });
7500
+ }
7501
+ async send(e, t) {
7502
+ if (this.SE_API) {
7503
+ const a = {
7504
+ nonce: Math.random().toString(36).substring(2),
7505
+ key: e,
7506
+ value: t,
7507
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
7508
+ };
7509
+ this.history.push(a), this.SE_API.store.set(this.id, this.history), this.SE_API.store.set(this.id + "_detected", Array.from(this.detected));
7510
+ }
7511
+ }
7512
+ update(e) {
7513
+ if (!e.length)
7514
+ return;
7515
+ this.history = e, e.filter((a) => !this.detected.has(a.nonce)).forEach((a) => {
7516
+ this.detected.add(a.nonce), this.emit("message", a.key, a.value);
7517
+ });
7518
+ }
7519
+ on(e, t) {
7520
+ return e === "load" && this.loaded ? (t.apply(this), this) : (super.on(e, t), this);
7521
+ }
7522
+ }
7263
7523
  typeof window !== void 0 && (window.addEventListener("load", () => {
7264
- window.client instanceof G && (q.queue = new mt({
7524
+ window.client instanceof G && (q.queue = new gt({
7265
7525
  duration: "client",
7266
7526
  processor: async function(e) {
7267
7527
  if (window.dispatchEvent(new CustomEvent(e.listener, { detail: e.data })), e.listener === "onEventReceived" && e.session) {
7268
- const t = await q.generate.event.onSessionUpdate(client.session, y.event.parseProvider(e.data));
7528
+ const t = await q.generate.event.onSessionUpdate(
7529
+ client.session,
7530
+ y.event.parseProvider(e.data)
7531
+ );
7269
7532
  window.dispatchEvent(new CustomEvent("onSessionUpdate", { detail: t }));
7270
7533
  }
7271
7534
  }
@@ -7291,7 +7554,19 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
7291
7554
  Object.keys(a).length && R.received("Field data:", a);
7292
7555
  }
7293
7556
  t.loaded = !0, t.storage.on("load", (a) => {
7294
- if (t.debug && a ? R.debug("[Client]", "Storage loaded for client", `"${t.id}";`, `Provider: "${t.details.provider}";`, a) : t.debug && R.debug("[Client]", "Storage loaded for client", `"${t.id}";`, `Provider: "${t.details.provider}";`, "No data found."), a) {
7557
+ if (t.debug && a ? R.debug(
7558
+ "[Client]",
7559
+ "Storage loaded for client",
7560
+ `"${t.id}";`,
7561
+ `Provider: "${t.details.provider}";`,
7562
+ a
7563
+ ) : t.debug && R.debug(
7564
+ "[Client]",
7565
+ "Storage loaded for client",
7566
+ `"${t.id}";`,
7567
+ `Provider: "${t.details.provider}";`,
7568
+ "No data found."
7569
+ ), a) {
7295
7570
  const i = (b) => {
7296
7571
  const g = Date.now(), c = {};
7297
7572
  for (const d in b)
@@ -7300,11 +7575,11 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
7300
7575
  f.expire && f.expire > g && (c[d] = f);
7301
7576
  }
7302
7577
  return c;
7303
- }, s = i(a.user || {}), n = i(a.avatar || {}), m = i(a.pronoun || {}), o = i(a.emote || {});
7578
+ }, s = i(a.user || {}), n = i(a.avatar || {}), l = i(a.pronoun || {}), o = i(a.emote || {});
7304
7579
  t.storage.update({
7305
7580
  user: s,
7306
7581
  avatar: n,
7307
- pronoun: m,
7582
+ pronoun: l,
7308
7583
  emote: o
7309
7584
  });
7310
7585
  }
@@ -7340,7 +7615,7 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
7340
7615
  switch (i.event.listener) {
7341
7616
  case "widget-button": {
7342
7617
  const s = i.event;
7343
- it.execute(s.field, s.value);
7618
+ at.execute(s.field, s.value);
7344
7619
  break;
7345
7620
  }
7346
7621
  case "subscriber-latest": {
@@ -7353,9 +7628,17 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
7353
7628
  case "kvstore:update": {
7354
7629
  const s = i.event;
7355
7630
  if (tt.length) {
7356
- var e = tt.find((n) => n.id === s.data.key.replace("customWidget.", "") || n.id === s.data.key);
7631
+ var e = tt.find(
7632
+ (n) => n.id === s.data.key.replace("customWidget.", "") || n.id === s.data.key
7633
+ );
7357
7634
  e && e.update(s.data.value);
7358
7635
  }
7636
+ if (et.length) {
7637
+ const n = et.find(
7638
+ (l) => l.id === s.data.key.replace("customWidget.", "") || l.id === s.data.key
7639
+ );
7640
+ n && n.update(s.data.value);
7641
+ }
7359
7642
  break;
7360
7643
  }
7361
7644
  case "bot:counter": {
@@ -7383,7 +7666,7 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
7383
7666
  break;
7384
7667
  }
7385
7668
  case "message": {
7386
- i.event, Q.execute({ provider: "twitch", data: i });
7669
+ i.event, Z.execute({ provider: "twitch", data: i });
7387
7670
  break;
7388
7671
  }
7389
7672
  case "follower-latest": {
@@ -7410,7 +7693,7 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
7410
7693
  const i = t.data;
7411
7694
  switch (i.listener) {
7412
7695
  case "message": {
7413
- i.event, Q.execute({ provider: "youtube", data: i });
7696
+ i.event, Z.execute({ provider: "youtube", data: i });
7414
7697
  break;
7415
7698
  }
7416
7699
  case "subscriber-latest": {
@@ -7446,10 +7729,14 @@ typeof window !== void 0 && (window.addEventListener("load", () => {
7446
7729
  "event:test",
7447
7730
  "kvstore:update"
7448
7731
  ];
7449
- client.debug && !a.some((i) => i === t.data.listener) && R.received("[Client]", `Event ${t.data.listener} received from ${t.provider}`, t.data.event);
7732
+ client.debug && !a.some((i) => i === t.data.listener) && R.received(
7733
+ "[Client]",
7734
+ `Event ${t.data.listener} received from ${t.provider}`,
7735
+ t.data.event
7736
+ );
7450
7737
  }
7451
7738
  }));
7452
- const nt = {
7739
+ const rt = {
7453
7740
  getOverlayStatus: () => ({
7454
7741
  isEditorMode: !1,
7455
7742
  muted: !1
@@ -7474,7 +7761,7 @@ const nt = {
7474
7761
  },
7475
7762
  store: {
7476
7763
  set: function(h, e) {
7477
- this.list[h] = e, localStorage.setItem("SE_API-STORE", JSON.stringify(nt.store.list));
7764
+ this.list[h] = e, localStorage.setItem("SE_API-STORE", JSON.stringify(rt.store.list));
7478
7765
  },
7479
7766
  get: async function(h) {
7480
7767
  return this.list[h] ? this.list[h] : null;
@@ -7482,11 +7769,11 @@ const nt = {
7482
7769
  list: {}
7483
7770
  }
7484
7771
  };
7485
- async function It() {
7772
+ async function Dt() {
7486
7773
  let h = localStorage.getItem("SE_API-STORE") ?? "", e = h ? JSON.parse(h) : {};
7487
- return nt.store.list = e, nt;
7774
+ return rt.store.list = e, rt;
7488
7775
  }
7489
- var rt;
7776
+ var ot;
7490
7777
  ((h) => {
7491
7778
  let e;
7492
7779
  ((i) => {
@@ -7498,7 +7785,7 @@ var rt;
7498
7785
  try {
7499
7786
  const i = await fetch("https://pronouns.alejo.io/api/pronouns").then((s) => s.json());
7500
7787
  if (Array.isArray(i) && i.length) {
7501
- const s = Object.fromEntries(i.map(({ name: n, display: m }) => [n, m]));
7788
+ const s = Object.fromEntries(i.map(({ name: n, display: l }) => [n, l]));
7502
7789
  return { ...e.map, ...s };
7503
7790
  }
7504
7791
  } catch {
@@ -7523,8 +7810,8 @@ var rt;
7523
7810
  }
7524
7811
  }
7525
7812
  h.get = a;
7526
- })(rt || (rt = {}));
7527
- class St extends Z {
7813
+ })(ot || (ot = {}));
7814
+ class At extends X {
7528
7815
  /**
7529
7816
  * Initializes a new ComfyJS instance and connects to Twitch chat.
7530
7817
  * @param options - Configuration options for ComfyJS instance.
@@ -7544,7 +7831,9 @@ class St extends Z {
7544
7831
  load() {
7545
7832
  return typeof window.ComfyJS > "u" || !window.ComfyJS ? new Promise((e, t) => {
7546
7833
  if (this.emulate && !client)
7547
- return t(new Error("useComfyJs: Cannot emulate chat messages without a Client instance."));
7834
+ return t(
7835
+ new Error("useComfyJs: Cannot emulate chat messages without a Client instance.")
7836
+ );
7548
7837
  const a = document.createElement("script");
7549
7838
  a.src = "https://cdn.jsdelivr.net/npm/comfy.js@1.1.29/dist/comfy.min.js", a.type = "text/javascript", a.async = !0, a.onload = () => e(window.ComfyJS), a.onerror = (i) => t(i), document.head.appendChild(a);
7550
7839
  }) : Promise.resolve(window.ComfyJS);
@@ -7564,7 +7853,7 @@ class St extends Z {
7564
7853
  vip: i.vip,
7565
7854
  subscriber: i.subscriber,
7566
7855
  founder: i.founder
7567
- }, m = {
7856
+ }, l = {
7568
7857
  name: e,
7569
7858
  message: `!${t} ${a}`,
7570
7859
  badges: Object.entries(n).map(([o, b]) => b ? o : null).filter(Boolean),
@@ -7574,7 +7863,7 @@ class St extends Z {
7574
7863
  msgId: s.id,
7575
7864
  channel: s.channel
7576
7865
  };
7577
- q.emulate.twitch.message(m);
7866
+ q.emulate.twitch.message(l);
7578
7867
  }
7579
7868
  }, this.instance.onChat = (e, t, a, i, s) => {
7580
7869
  if (this.emit("chat", e, t, a, i, s), client.debug && R.debug("[Client]", `ComfyJS Chat: ${t} (User: ${e})`), this.emulate) {
@@ -7590,7 +7879,7 @@ class St extends Z {
7590
7879
  q.emulate.twitch.message({
7591
7880
  name: e,
7592
7881
  message: t,
7593
- badges: Object.entries(n).map(([m, o]) => o ? m : null).filter(Boolean),
7882
+ badges: Object.entries(n).map(([l, o]) => o ? l : null).filter(Boolean),
7594
7883
  color: s.userColor,
7595
7884
  time: new Date(s.timestamp).getTime(),
7596
7885
  userId: s.userId,
@@ -7625,29 +7914,40 @@ class St extends Z {
7625
7914
  }
7626
7915
  }, this.instance.onResub = (e, t, a, i, s, n) => {
7627
7916
  if (this.emit("resub", e, t, a, i, s, n), client.debug && R.debug("[Client]", `ComfyJS Resub: ${e} (${i} months)`), this.emulate) {
7628
- const m = s.plan === "Prime" ? "prime" : s.plan;
7917
+ const l = s.plan === "Prime" ? "prime" : s.plan;
7629
7918
  q.emulate.twitch.subscriber({
7630
7919
  name: e,
7631
7920
  message: t,
7632
- tier: m,
7921
+ tier: l,
7633
7922
  amount: i,
7634
7923
  subType: "default"
7635
7924
  });
7636
7925
  }
7637
7926
  }, this.instance.onSubGift = (e, t, a, i, s, n) => {
7638
- if (this.emit("subGift", e, t, a, i, s, n), client.debug && R.debug("[Client]", `ComfyJS Sub Gift: ${e} gifted ${i} subs`), this.emulate) {
7639
- const m = s.plan === "Prime" ? "prime" : s.plan;
7927
+ if (this.emit(
7928
+ "subGift",
7929
+ e,
7930
+ t,
7931
+ a,
7932
+ i,
7933
+ s,
7934
+ n
7935
+ ), client.debug && R.debug("[Client]", `ComfyJS Sub Gift: ${e} gifted ${i} subs`), this.emulate) {
7936
+ const l = s.plan === "Prime" ? "prime" : s.plan;
7640
7937
  q.emulate.twitch.subscriber({
7641
7938
  name: a,
7642
7939
  message: "",
7643
7940
  sender: e,
7644
- tier: m,
7941
+ tier: l,
7645
7942
  amount: i,
7646
7943
  subType: "gift"
7647
7944
  });
7648
7945
  }
7649
7946
  }, this.instance.onSubMysteryGift = (e, t, a, i, s) => {
7650
- if (this.emit("subMysteryGift", e, t, a, i, s), client.debug && R.debug("[Client]", `ComfyJS Sub Mystery Gift: ${e} gifted ${t} subs`), this.emulate) {
7947
+ if (this.emit("subMysteryGift", e, t, a, i, s), client.debug && R.debug(
7948
+ "[Client]",
7949
+ `ComfyJS Sub Mystery Gift: ${e} gifted ${t} subs`
7950
+ ), this.emulate) {
7651
7951
  const n = i.plan === "Prime" ? "prime" : i.plan;
7652
7952
  q.emulate.twitch.subscriber({
7653
7953
  name: e,
@@ -7658,7 +7958,10 @@ class St extends Z {
7658
7958
  });
7659
7959
  }
7660
7960
  }, this.instance.onGiftSubContinue = (e, t, a) => {
7661
- this.emit("giftSubContinue", e, t, a), client.debug && R.debug("[Client]", `ComfyJS Gift Sub Continue: ${e} continued their gifted sub from ${t}`), this.emulate && q.emulate.twitch.subscriber({
7961
+ this.emit("giftSubContinue", e, t, a), client.debug && R.debug(
7962
+ "[Client]",
7963
+ `ComfyJS Gift Sub Continue: ${e} continued their gifted sub from ${t}`
7964
+ ), this.emulate && q.emulate.twitch.subscriber({
7662
7965
  name: e,
7663
7966
  message: "",
7664
7967
  sender: t,
@@ -7674,15 +7977,21 @@ class St extends Z {
7674
7977
  }, this.instance.onChatMode = (e, t) => {
7675
7978
  this.emit("chatMode", e, t), client.debug && R.debug("[Client]", `ComfyJS Chat Mode Changed on ${t}`);
7676
7979
  }, this.instance.onReward = (e, t, a, i, s) => {
7677
- this.emit("reward", e, t, a, i, s), client.debug && R.debug("[Client]", `ComfyJS Reward: ${e} redeemed ${t} for ${a} - ${i}`);
7980
+ this.emit("reward", e, t, a, i, s), client.debug && R.debug(
7981
+ "[Client]",
7982
+ `ComfyJS Reward: ${e} redeemed ${t} for ${a} - ${i}`
7983
+ );
7678
7984
  }, this.instance.onConnected = (e, t, a) => {
7679
- this.emit("connected", e, t, a), client.debug && R.debug("[Client]", `ComfyJS Connected: ${e}:${t} (First Connect: ${a})`);
7985
+ this.emit("connected", e, t, a), client.debug && R.debug(
7986
+ "[Client]",
7987
+ `ComfyJS Connected: ${e}:${t} (First Connect: ${a})`
7988
+ );
7680
7989
  }, this.instance.onReconnect = (e) => {
7681
7990
  this.emit("reconnect", e), client.debug && R.debug("[Client]", `ComfyJS Reconnect: Attempt #${e}`);
7682
7991
  }, this.init && this.instance.Init(this.username, this.password, this.channels, this.isDebug);
7683
7992
  }
7684
7993
  }
7685
- class ut {
7994
+ class pt {
7686
7995
  constructor(e = {}) {
7687
7996
  this.error = this.apply({
7688
7997
  color: "#721c24",
@@ -7749,13 +8058,13 @@ class ut {
7749
8058
  if (!this.enabled || typeof console > "u") return;
7750
8059
  let s = "";
7751
8060
  typeof this.prefix == "function" ? s = this.prefix() : typeof this.prefix == "string" && (s = this.prefix);
7752
- const n = [], m = [];
8061
+ const n = [], l = [];
7753
8062
  if (i.forEach((o) => {
7754
- typeof o == "string" || typeof o == "number" || typeof o == "boolean" ? n.push(o) : m.push(o);
8063
+ typeof o == "string" || typeof o == "number" || typeof o == "boolean" ? n.push(o) : l.push(o);
7755
8064
  }), n.length > 0) {
7756
8065
  const o = n.join(" ");
7757
- console.log(`%c${s.endsWith(" ") ? s : s.trim() + " "}${a}${o}`, t, ...m);
7758
- } else m.length > 0 && console.log(`%c${s.endsWith(" ") ? s : s.trim() + " "}${a}`, t, ...m);
8066
+ console.log(`%c${s.endsWith(" ") ? s : s.trim() + " "}${a}${o}`, t, ...l);
8067
+ } else l.length > 0 && console.log(`%c${s.endsWith(" ") ? s : s.trim() + " "}${a}`, t, ...l);
7759
8068
  };
7760
8069
  }
7761
8070
  style(e) {
@@ -7781,21 +8090,21 @@ class ut {
7781
8090
  !this.enabled || !console.timeEnd || console.timeEnd(e);
7782
8091
  }
7783
8092
  }
7784
- const gt = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(It()), R = new ut(), ht = {
7785
- SeAPI: gt,
8093
+ const ct = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(Dt()), R = new pt(), mt = {
8094
+ SeAPI: ct,
7786
8095
  Client: G,
7787
8096
  Helper: y,
7788
8097
  Local: q,
7789
8098
  Data: D,
7790
8099
  logger: R,
7791
- modules: { EventProvider: Z, useStorage: et, useQueue: mt, useLogger: ut },
7792
- actions: { Button: it, Command: Q },
7793
- multistream: { useComfyJs: St },
7794
- data: { usedStorages: tt },
7795
- pronouns: { Alejo: rt }
8100
+ modules: { EventProvider: X, useStorage: it, useQueue: gt, useLogger: pt, useComms: St },
8101
+ actions: { Button: at, Command: Z },
8102
+ multistream: { useComfyJs: At },
8103
+ data: { usedStorages: tt, usedComms: et },
8104
+ pronouns: { Alejo: ot }
7796
8105
  };
7797
- typeof window < "u" ? window.Tixyel = ht : globalThis.Tixyel = ht;
8106
+ typeof window < "u" ? window.Tixyel = mt : globalThis.Tixyel = mt;
7798
8107
  export {
7799
- ht as default
8108
+ mt as default
7800
8109
  };
7801
8110
  //# sourceMappingURL=index.es.js.map