dimsum-chat 0.5.2 → 0.5.4

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.
@@ -1,7 +1,7 @@
1
- var T = Object.defineProperty;
2
- var A = (b, t, i) => t in b ? T(b, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : b[t] = i;
3
- var a = (b, t, i) => (A(b, typeof t != "symbol" ? t + "" : t, i), i);
4
- const k = {
1
+ var k = Object.defineProperty;
2
+ var T = (e, t, i) => t in e ? k(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
+ var c = (e, t, i) => (T(e, typeof t != "symbol" ? t + "" : t, i), i);
4
+ const I = {
5
5
  type: "LIVE_OPEN_PLATFORM_DM",
6
6
  content: {
7
7
  cmd: "LIVE_OPEN_PLATFORM_DM",
@@ -14,7 +14,7 @@ const k = {
14
14
  dm_type: 0
15
15
  }
16
16
  }
17
- }, I = {
17
+ }, E = {
18
18
  type: "LIVE_OPEN_PLATFORM_SEND_GIFT",
19
19
  content: {
20
20
  cmd: "LIVE_OPEN_PLATFORM_SEND_GIFT",
@@ -30,17 +30,17 @@ const k = {
30
30
  gift_icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAB+FBMVEX/////UFD/TFD/TVD/TE7/TU//TU//TU//SUv/Skz/Sk3/S03/S07/TE3/TE7/TE//TU7/TU//TVD/Tk//TlD/T1D/T1H/UFH/UFL/UFP/UVL/UVP/UlP/UlT/U1T/U1X/VFX/VFb/VVb/VVf/Vlf/Vlj/V1j/V1n/WFn/WFr/WVr/WVv/Wlv/Wlz/W1z/W13/XF3/XF7/XV7/XV//Xl//XmD/X2D/X2H/YGH/YGL/YWL/YWP/YmP/YmT/Y2T/Y2X/ZGX/ZGb/ZWb/ZWf/Zmf/Zmj/Z2j/Z2n/aGn/aWv/bG7/bW7/bm//b3D/cXL/cnT/dHX/dXb/d3n/eXr/env/e33/fH7/fo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o1bUNP7KZuKq11dXSr62NdeRlRdldDwMr2M7Lx7KzuRFINrdfIpbdoBQGzPZuIvEigRKJnZ2tlRr1/4Wmmz6Gx9JTAAAAAElFTkSuQmCC"
31
31
  }
32
32
  }
33
- }, D = [k, I], f = class f {
33
+ }, w = [I, E], g = class g {
34
34
  constructor() {
35
- a(this, "AUTH_API", "https://api.miego.live/widget/auth");
36
- a(this, "WHITELIST_WIDGETS", ["dimsum-bonk-2024-widget", "douyin-bonk-2024-widget"]);
37
- a(this, "MAX_RETRY_COUNT", 3);
38
- a(this, "authenticatedPlatformAndRoomId");
39
- a(this, "isPiracy", !1);
40
- a(this, "retryCount", 0);
35
+ c(this, "AUTH_API", "https://api.miego.live/widget/auth");
36
+ c(this, "WHITELIST_WIDGETS", ["dimsum-bonk-2024-widget", "douyin-bonk-2024-widget"]);
37
+ c(this, "MAX_RETRY_COUNT", 3);
38
+ c(this, "authenticatedPlatformAndRoomId");
39
+ c(this, "isPiracy", !1);
40
+ c(this, "retryCount", 0);
41
41
  }
42
42
  static getInstance() {
43
- return f.instance || (f.instance = new f()), f.instance;
43
+ return g.instance || (g.instance = new g()), g.instance;
44
44
  }
45
45
  updateWidgetId(t) {
46
46
  return t === "douyin-bonk-2024-widget" ? "dimsum-bonk-2024-widget" : t;
@@ -48,45 +48,45 @@ const k = {
48
48
  checkAuthentication(t, i, s) {
49
49
  if (t = this.updateWidgetId(t), !this.WHITELIST_WIDGETS.includes(t) || this.authenticatedPlatformAndRoomId === `${i}-${s}` || i === "chzzk" && t === "dimsum-bonk-2024-widget")
50
50
  return;
51
- const e = () => {
51
+ const n = () => {
52
52
  this.retryCount++, this.retryCount < this.MAX_RETRY_COUNT ? setTimeout(() => {
53
53
  this.checkAuthentication(t, i, s);
54
54
  }, 1e3) : this.isPiracy = !0;
55
- }, n = new URL(this.AUTH_API);
56
- return n.searchParams.append("widget", t), n.searchParams.append("platform", i), n.searchParams.append("roomId", s), fetch(n).then((p) => {
57
- console.log("checkAuthentication", p.status), p.status === 200 ? (this.authenticatedPlatformAndRoomId = `${i}-${s}`, this.isPiracy = !1) : e();
55
+ }, o = new URL(this.AUTH_API);
56
+ return o.searchParams.append("widget", t), o.searchParams.append("platform", i), o.searchParams.append("roomId", s), fetch(o).then((p) => {
57
+ console.log("checkAuthentication", p.status), p.status === 200 ? (this.authenticatedPlatformAndRoomId = `${i}-${s}`, this.isPiracy = !1) : n();
58
58
  }).catch(() => {
59
- console.log("checkAuthentication error"), e();
59
+ console.log("checkAuthentication error"), n();
60
60
  });
61
61
  }
62
62
  passMessage(t) {
63
63
  try {
64
64
  if (t.type === "DimSumChatRoomInfo") {
65
- const i = t.content.platform ?? t.content.platfrom, s = t.content.roomId, e = window.location.pathname.split("/")[1];
66
- this.checkAuthentication(e, i, s);
65
+ const i = t.content.platform ?? t.content.platfrom, s = t.content.roomId, n = window.location.pathname.split("/")[1];
66
+ this.checkAuthentication(n, i, s);
67
67
  }
68
68
  if (t.type === "INTERACT_WORD") {
69
- const i = typeof t.content == "object" ? t.content : JSON.parse(t.content), s = "bilibili", e = String(i.data.roomid), n = window.location.pathname.split("/")[1];
70
- this.checkAuthentication(n, s, e);
69
+ const i = typeof t.content == "object" ? t.content : JSON.parse(t.content), s = "bilibili", n = String(i.data.roomid), o = window.location.pathname.split("/")[1];
70
+ this.checkAuthentication(o, s, n);
71
71
  }
72
72
  if (t.type === "LIVE_OPEN_PLATFORM_DM" || t.type === "LIVE_OPEN_PLATFORM_SEND_GIFT") {
73
73
  const i = typeof t.content == "object" ? t.content : JSON.parse(t.content);
74
74
  if (i.data.room_id === void 0)
75
75
  return t;
76
- const s = "bilibili", e = String(i.data.room_id), n = window.location.pathname.split("/")[1];
77
- this.checkAuthentication(n, s, e);
76
+ const s = "bilibili", n = String(i.data.room_id), o = window.location.pathname.split("/")[1];
77
+ this.checkAuthentication(o, s, n);
78
78
  }
79
79
  if (this.isPiracy)
80
- return D[Math.floor(Math.random() * D.length)];
80
+ return w[Math.floor(Math.random() * w.length)];
81
81
  } catch (i) {
82
82
  console.log("DimSumAuth error", i);
83
83
  }
84
84
  return t;
85
85
  }
86
86
  };
87
- a(f, "instance");
88
- let _ = f;
89
- const B = {
87
+ c(g, "instance");
88
+ let _ = g;
89
+ const A = {
90
90
  type: "LIVE_OPEN_PLATFORM_DM",
91
91
  content: {
92
92
  cmd: "LIVE_OPEN_PLATFORM_DM",
@@ -97,7 +97,7 @@ const B = {
97
97
  guard_level: 1
98
98
  }
99
99
  }
100
- }, M = {
100
+ }, S = {
101
101
  type: "LIVE_OPEN_PLATFORM_DM",
102
102
  content: {
103
103
  cmd: "LIVE_OPEN_PLATFORM_DM",
@@ -108,25 +108,25 @@ const B = {
108
108
  guard_level: 1
109
109
  }
110
110
  }
111
- }, w = {
112
- connected: B,
113
- welcome: M
111
+ }, C = {
112
+ connected: A,
113
+ welcome: S
114
114
  };
115
- function E() {
115
+ function B() {
116
116
  const t = window.location.pathname.split("/");
117
117
  return t.length > 1 ? t[1] : "unknown base name";
118
118
  }
119
- function L(b, t = {}) {
119
+ function M(e, t = {}) {
120
120
  const { widgetNickName: i } = t;
121
121
  let s;
122
- switch (b.type) {
122
+ switch (e.type) {
123
123
  case "DimSumChatWidgetInfoRequest":
124
124
  s = {
125
125
  type: "DimSumChatWidgetInfoResponse",
126
126
  content: {
127
- base: E(),
127
+ base: B(),
128
128
  url: window.location.href,
129
- ...i ? { widgetNickName: i } : {}
129
+ ...i ? { nickName: i } : {}
130
130
  }
131
131
  };
132
132
  }
@@ -134,15 +134,15 @@ function L(b, t = {}) {
134
134
  }
135
135
  const x = class x {
136
136
  constructor() {
137
- a(this, "webSocket");
138
- a(this, "messageListeners");
137
+ c(this, "webSocket");
138
+ c(this, "messageListeners");
139
139
  /**
140
140
  * Nickname for this widget instance.
141
141
  * Set before connection (via onMessageOptions) or dynamically at runtime.
142
142
  * When non-empty, it will be included in DimSumChatWidgetInfoResponse
143
143
  * so other components can identify this widget via DimSumChatCallMessageRequest.
144
144
  */
145
- a(this, "widgetNickName", "");
145
+ c(this, "widgetNickName", "");
146
146
  this.webSocket = null, this.messageListeners = [];
147
147
  }
148
148
  /**
@@ -166,7 +166,7 @@ const x = class x {
166
166
  this.webSocket || (this.webSocket = new WebSocket(t), this.webSocket.onmessage = this.handleMessage.bind(this), this.webSocket.onopen = () => {
167
167
  console.log("connected"), setTimeout(() => {
168
168
  this.messageListeners.forEach(
169
- (i) => i(JSON.stringify(w.connected))
169
+ (i) => i(JSON.stringify(C.connected))
170
170
  );
171
171
  }, 100);
172
172
  }, this.webSocket.onclose = () => {
@@ -176,13 +176,13 @@ const x = class x {
176
176
  });
177
177
  }
178
178
  handleMessage(t) {
179
- var n;
179
+ var o;
180
180
  const i = t.data;
181
181
  this.messageListeners.forEach((p) => p(i));
182
- const s = JSON.parse(i), e = L(s, {
182
+ const s = JSON.parse(i), n = M(s, {
183
183
  widgetNickName: this.widgetNickName
184
184
  });
185
- e && ((n = this.webSocket) == null || n.send(JSON.stringify(e)));
185
+ n && ((o = this.webSocket) == null || o.send(JSON.stringify(n)));
186
186
  }
187
187
  /**
188
188
  * 注册消息监听器。
@@ -195,7 +195,7 @@ const x = class x {
195
195
  */
196
196
  addMessageListener(t) {
197
197
  this.messageListeners.push(t), setTimeout(() => {
198
- t(JSON.stringify(w.welcome));
198
+ t(JSON.stringify(C.welcome));
199
199
  }, 100);
200
200
  }
201
201
  /**
@@ -234,27 +234,27 @@ const x = class x {
234
234
  return ((i = this.webSocket) == null ? void 0 : i.readyState) === WebSocket.OPEN ? (this.webSocket.send(JSON.stringify(t)), !0) : !1;
235
235
  }
236
236
  };
237
- a(x, "instance");
238
- let z = x;
239
- function S() {
240
- const b = new URL(window.location.href), t = b.protocol === "https:" ? "wss:" : "ws:", i = b.host;
237
+ c(x, "instance");
238
+ let D = x;
239
+ function N() {
240
+ const e = new URL(window.location.href), t = e.protocol === "https:" ? "wss:" : "ws:", i = e.host;
241
241
  return `${t}//${i}/websocket`;
242
242
  }
243
- function P(b) {
243
+ function K(e) {
244
244
  const t = new URL(window.location.href), i = t.protocol, s = t.host;
245
- return `${i}//${s}/bface/${b}`;
245
+ return `${i}//${s}/bface/${e}`;
246
246
  }
247
- function U(b, t = {}) {
247
+ function q(e, t = {}) {
248
248
  const {
249
- customWsServer: i = S(),
249
+ customWsServer: i = N(),
250
250
  widgetNickName: s = ""
251
- } = t, e = _.getInstance(), n = z.getInstance();
252
- n.widgetNickName = s, n.connect(i), n.addMessageListener((p) => {
253
- const h = JSON.parse(p), m = e.passMessage(h), o = new C(m);
254
- b(m, o);
251
+ } = t, n = _.getInstance(), o = D.getInstance();
252
+ s && (o.widgetNickName = s), o.connect(i), o.addMessageListener((p) => {
253
+ const r = JSON.parse(p), f = n.passMessage(r), a = new z(f);
254
+ e(f, a);
255
255
  });
256
256
  }
257
- const l = [
257
+ const y = [
258
258
  ["[过年牛]", "https://p3-pc-sign.douyinpic.com/obj/tos-cn-i-tsj2vxp0zn/3bb984085d52480ca846fa8f9a1782f6?x-expires=1949886000&x-signature=d8vUokaGkWD%2B4sAHNTLJquCrHrs%3D"],
259
259
  ["[元宝]", "https://p3-pc-sign.douyinpic.com/obj/tos-cn-i-tsj2vxp0zn/5f8ac1b1ddd347c4be34b81b496fcc45?x-expires=2023614000&x-signature=UT%2F8fnFld4xuvjj2bttu6fh76lI%3D"],
260
260
  ["[鞭炮]", "https://p3-pc-sign.douyinpic.com/obj/tos-cn-i-tsj2vxp0zn/02f8ee9536de4c6595171584e2322f0f?x-expires=2023614000&x-signature=Aa8eXgZqb0bx0QNeLONQVgNUbLI%3D"],
@@ -806,27 +806,313 @@ const l = [
806
806
  ["[抱拳]", "https://bd.a.yximgs.com/bs2/emotion/1704790113221third_party_s1296853443.png"],
807
807
  ["[早上好]", "https://ali2.a.yximgs.com/bs2/emotion/1704790167344third_party_s1296853922.png"],
808
808
  ["[胡思乱想]", "https://ali2.a.yximgs.com/bs2/emotion/1704790657229third_party_s1296858542.png"]
809
- ], r = class r {
809
+ ], L = 0, P = 2, R = 5;
810
+ class U {
811
+ constructor(t) {
812
+ c(this, "buf");
813
+ c(this, "pos", 0);
814
+ c(this, "end");
815
+ this.buf = t, this.end = t.length;
816
+ }
817
+ /** Read a varint as a JS number. Uses BigInt internally for 64-bit safety. */
818
+ readVarint() {
819
+ let t = 0n, i = 0n;
820
+ for (; ; ) {
821
+ const s = this.buf[this.pos++];
822
+ if (t |= BigInt(s & 127) << i, !(s & 128))
823
+ break;
824
+ i += 7n;
825
+ }
826
+ return Number(t);
827
+ }
828
+ /** Read a length-delimited UTF-8 string. */
829
+ readString() {
830
+ const t = this.readVarint(), i = new TextDecoder().decode(
831
+ this.buf.subarray(this.pos, this.pos + t)
832
+ );
833
+ return this.pos += t, i;
834
+ }
835
+ /** Read a fixed32 as little-endian IEEE 754 float. */
836
+ readFloat() {
837
+ const t = new DataView(
838
+ this.buf.buffer,
839
+ this.buf.byteOffset + this.pos,
840
+ 4
841
+ );
842
+ return this.pos += 4, t.getFloat32(0, !0);
843
+ }
844
+ /** Read a tag: returns [fieldNumber, wireType]. */
845
+ readTag() {
846
+ const t = this.readVarint();
847
+ return [t >>> 3, t & 7];
848
+ }
849
+ /** Skip a field of the given wire type. */
850
+ skip(t) {
851
+ switch (t) {
852
+ case L:
853
+ this.readVarint();
854
+ break;
855
+ case P:
856
+ this.pos += this.readVarint();
857
+ break;
858
+ case R:
859
+ this.pos += 4;
860
+ break;
861
+ }
862
+ }
863
+ /**
864
+ * Decode an embedded message: reads the length prefix, sets a boundary
865
+ * so the sub-decoder cannot read past it, delegates to fn, then aligns
866
+ * position exactly.
867
+ */
868
+ readEmbedded(t) {
869
+ const i = this.readVarint(), s = this.end;
870
+ this.end = this.pos + i;
871
+ const n = t(this);
872
+ return this.pos = this.end, this.end = s, n;
873
+ }
874
+ get isEOF() {
875
+ return this.pos >= this.end;
876
+ }
877
+ }
878
+ function G(e) {
879
+ const t = {
880
+ anchor_uid: 0,
881
+ medal_level: 0,
882
+ medal_name: "",
883
+ color_start: 0,
884
+ color: 0,
885
+ color_border: 0,
886
+ color_end: 0,
887
+ guard_level: 0
888
+ };
889
+ for (; !e.isEOF; ) {
890
+ const [i, s] = e.readTag();
891
+ switch (i) {
892
+ case 1:
893
+ t.anchor_uid = e.readVarint();
894
+ break;
895
+ case 5:
896
+ t.medal_level = e.readVarint();
897
+ break;
898
+ case 6:
899
+ t.medal_name = e.readString();
900
+ break;
901
+ case 7:
902
+ t.color_start = e.readVarint();
903
+ break;
904
+ case 8:
905
+ t.color = e.readVarint();
906
+ break;
907
+ case 9:
908
+ t.color_border = e.readVarint();
909
+ break;
910
+ case 10:
911
+ t.color_end = e.readVarint();
912
+ break;
913
+ case 11:
914
+ t.guard_level = e.readVarint();
915
+ break;
916
+ default:
917
+ e.skip(s);
918
+ }
919
+ }
920
+ return t;
921
+ }
922
+ function O(e) {
923
+ const t = { uname: "", uid: 0 };
924
+ for (; !e.isEOF; ) {
925
+ const [i, s] = e.readTag();
926
+ switch (i) {
927
+ case 1:
928
+ t.uname = e.readString();
929
+ break;
930
+ case 2:
931
+ t.uid = e.readVarint();
932
+ break;
933
+ default:
934
+ e.skip(s);
935
+ }
936
+ }
937
+ return t;
938
+ }
939
+ function V(e) {
940
+ const t = { img_basic: "", img_2: "", img_gif: "" };
941
+ for (; !e.isEOF; ) {
942
+ const [i, s] = e.readTag();
943
+ switch (i) {
944
+ case 1:
945
+ t.img_basic = e.readString();
946
+ break;
947
+ case 2:
948
+ t.img_2 = e.readString();
949
+ break;
950
+ case 5:
951
+ t.img_gif = e.readString();
952
+ break;
953
+ default:
954
+ e.skip(s);
955
+ }
956
+ }
957
+ return t;
958
+ }
959
+ function Q(e) {
960
+ const t = {
961
+ gift_id: 0,
962
+ gift_name: "",
963
+ num: 0,
964
+ price: 0,
965
+ total_coin: 0,
966
+ coin_type: "",
967
+ tid: "",
968
+ timestamp: 0,
969
+ action: "",
970
+ receiver: { uname: "", uid: 0 }
971
+ };
972
+ for (; !e.isEOF; ) {
973
+ const [i, s] = e.readTag();
974
+ switch (i) {
975
+ case 1:
976
+ t.gift_id = e.readVarint();
977
+ break;
978
+ case 2:
979
+ t.gift_name = e.readString();
980
+ break;
981
+ case 3:
982
+ t.num = e.readVarint();
983
+ break;
984
+ case 5:
985
+ t.price = e.readVarint();
986
+ break;
987
+ case 6:
988
+ t.total_coin = e.readVarint();
989
+ break;
990
+ case 8:
991
+ t.coin_type = e.readString();
992
+ break;
993
+ case 9:
994
+ t.tid = e.readString();
995
+ break;
996
+ case 10:
997
+ t.timestamp = e.readVarint();
998
+ break;
999
+ case 18:
1000
+ t.action = e.readString();
1001
+ break;
1002
+ case 29:
1003
+ t.receiver = e.readEmbedded(O);
1004
+ break;
1005
+ case 35:
1006
+ t.effect = e.readEmbedded(V);
1007
+ break;
1008
+ default:
1009
+ e.skip(s);
1010
+ }
1011
+ }
1012
+ return t;
1013
+ }
1014
+ function W(e) {
1015
+ let t = "";
1016
+ for (; !e.isEOF; ) {
1017
+ const [i, s] = e.readTag();
1018
+ if (i === 2) {
1019
+ if (e.readEmbedded((n) => {
1020
+ for (; !n.isEOF; ) {
1021
+ const [o, p] = n.readTag();
1022
+ if (o === 2) {
1023
+ t = n.readString();
1024
+ return;
1025
+ }
1026
+ n.skip(p);
1027
+ }
1028
+ }), t)
1029
+ break;
1030
+ } else
1031
+ e.skip(s);
1032
+ }
1033
+ return t;
1034
+ }
1035
+ function Z(e) {
1036
+ const t = {
1037
+ uid: 0,
1038
+ uname: "",
1039
+ face: "",
1040
+ gift: {
1041
+ gift_id: 0,
1042
+ gift_name: "",
1043
+ num: 0,
1044
+ price: 0,
1045
+ total_coin: 0,
1046
+ coin_type: "",
1047
+ tid: "",
1048
+ timestamp: 0,
1049
+ action: "",
1050
+ receiver: { uname: "", uid: 0 }
1051
+ }
1052
+ };
1053
+ for (; !e.isEOF; ) {
1054
+ const [i, s] = e.readTag();
1055
+ switch (i) {
1056
+ case 1:
1057
+ t.uid = e.readVarint();
1058
+ break;
1059
+ case 2:
1060
+ t.uname = e.readString();
1061
+ break;
1062
+ case 3:
1063
+ e.skip(s);
1064
+ break;
1065
+ case 8:
1066
+ t.medal = e.readEmbedded(G);
1067
+ break;
1068
+ case 10:
1069
+ t.gift = e.readEmbedded(Q);
1070
+ break;
1071
+ case 15:
1072
+ t.face = e.readEmbedded(W);
1073
+ break;
1074
+ default:
1075
+ e.skip(s);
1076
+ }
1077
+ }
1078
+ return t;
1079
+ }
1080
+ function H(e) {
1081
+ const t = atob(e), i = new Uint8Array(t.length);
1082
+ for (let s = 0; s < t.length; s++)
1083
+ i[s] = t.charCodeAt(s);
1084
+ return Z(new U(i));
1085
+ }
1086
+ const b = class b {
810
1087
  constructor(t) {
811
1088
  /** 原始消息类型。 */
812
- a(this, "rawType");
1089
+ c(this, "rawType");
813
1090
  /** 原始消息内容(字符串已自动反序列化为对象)。 */
814
- a(this, "rawContent");
815
- a(this, "_cachedValues", {});
1091
+ c(this, "rawContent");
1092
+ /** SEND_GIFT_V2 的 protobuf 解码结果(仅该类型时有效)。 */
1093
+ c(this, "_pbData");
1094
+ c(this, "_cachedValues", {});
1095
+ var n, o;
816
1096
  this.rawType = t.type;
817
1097
  try {
818
1098
  typeof t.content == "string" ? this.rawContent = JSON.parse(t.content) : this.rawContent = t.content;
819
1099
  } catch {
820
1100
  this.rawContent = t.content;
821
1101
  }
1102
+ if (this.rawType === "SEND_GIFT_V2" && ((o = (n = this.rawContent) == null ? void 0 : n.data) != null && o.pb))
1103
+ try {
1104
+ this._pbData = H(this.rawContent.data.pb);
1105
+ } catch (p) {
1106
+ console.error("[dimsum-chat] Failed to decode SEND_GIFT_V2 protobuf:", p);
1107
+ }
822
1108
  const i = this, s = Object.getPrototypeOf(this);
823
- Object.getOwnPropertyNames(s).forEach((e) => {
824
- const n = Object.getOwnPropertyDescriptor(s, e);
825
- n && typeof n.get == "function" && Object.defineProperty(i, e, {
1109
+ Object.getOwnPropertyNames(s).forEach((p) => {
1110
+ const r = Object.getOwnPropertyDescriptor(s, p);
1111
+ r && typeof r.get == "function" && Object.defineProperty(i, p, {
826
1112
  get: function() {
827
- return i.getCachedValue(e, () => {
828
- var p;
829
- return (p = n.get) == null ? void 0 : p.call(i);
1113
+ return i.getCachedValue(p, () => {
1114
+ var f;
1115
+ return (f = r.get) == null ? void 0 : f.call(i);
830
1116
  });
831
1117
  },
832
1118
  enumerable: !0,
@@ -881,6 +1167,7 @@ const l = [
881
1167
  "CommonActionSignalGift",
882
1168
  "WebcastGiftMessage",
883
1169
  "SEND_GIFT",
1170
+ "SEND_GIFT_V2",
884
1171
  "KuaishouGiftFeeds"
885
1172
  ],
886
1173
  follow: [
@@ -908,6 +1195,7 @@ const l = [
908
1195
  "ChzzkDonationMessage"
909
1196
  ],
910
1197
  enter: [
1198
+ "LIVE_OPEN_PLATFORM_LIVE_ROOM_ENTER",
911
1199
  "CommonActionSignalUserEnterRoom",
912
1200
  "WebcastMemberMessage"
913
1201
  ],
@@ -939,6 +1227,8 @@ const l = [
939
1227
  if (this.platform === "bilibili" || this.platform === "openblive") {
940
1228
  if (this.rawType === "DANMU_MSG")
941
1229
  return this.rawContent.info[2][1];
1230
+ if (this.rawType === "SEND_GIFT_V2" && this._pbData)
1231
+ return this._pbData.uname;
942
1232
  if ("data" in this.rawContent) {
943
1233
  const s = this.rawContent.data.user_info || this.rawContent.data;
944
1234
  return (s == null ? void 0 : s.uname) ?? (s == null ? void 0 : s.username);
@@ -964,6 +1254,8 @@ const l = [
964
1254
  if (this.platform === "bilibili" || this.platform === "openblive") {
965
1255
  if (this.rawType === "DANMU_MSG")
966
1256
  return this.rawContent.info[2][0];
1257
+ if (this.rawType === "SEND_GIFT_V2" && this._pbData)
1258
+ return this._pbData.uid;
967
1259
  if ("data" in this.rawContent) {
968
1260
  if ("user_info" in this.rawContent.data && "uid" in this.rawContent.data.user_info)
969
1261
  return this.rawContent.data.user_info.uid;
@@ -986,9 +1278,12 @@ const l = [
986
1278
  }
987
1279
  /** 粉丝团/守护团等级。 */
988
1280
  get clubLevel() {
1281
+ var t;
989
1282
  if (this.platform === "bilibili" || this.platform === "openblive") {
990
1283
  if (this.rawType === "DANMU_MSG")
991
1284
  return this.rawContent.info[3][0];
1285
+ if (this.rawType === "SEND_GIFT_V2" && ((t = this._pbData) != null && t.medal))
1286
+ return this._pbData.medal.medal_level;
992
1287
  if ("data" in this.rawContent) {
993
1288
  if ("medal_info" in this.rawContent.data && "medal_level" in this.rawContent.data.medal_info)
994
1289
  return this.rawContent.data.medal_info.medal_level;
@@ -999,19 +1294,21 @@ const l = [
999
1294
  }
1000
1295
  }
1001
1296
  if (this.platform === "acfun") {
1002
- let t;
1003
- if ("gift" in this.rawContent && (t = this.rawContent.gift.userInfo), "userInfo" in this.rawContent && (t = this.rawContent.userInfo), t && t.badge.length > 0)
1004
- return JSON.parse(t.badge).medalInfo.level;
1297
+ let i;
1298
+ if ("gift" in this.rawContent && (i = this.rawContent.gift.userInfo), "userInfo" in this.rawContent && (i = this.rawContent.userInfo), i && i.badge.length > 0)
1299
+ return JSON.parse(i.badge).medalInfo.level;
1005
1300
  }
1006
1301
  if (this.platform === "douyin" && "user" in this.rawContent && this.rawContent.user.fansClub !== null)
1007
1302
  return this.rawContent.user.fansClub.data.level;
1008
1303
  }
1009
1304
  /** 粉丝团/守护团名称。 */
1010
1305
  get clubName() {
1011
- var t, i;
1306
+ var t, i, s;
1012
1307
  if (this.platform === "bilibili" || this.platform === "openblive") {
1013
1308
  if (this.rawType === "DANMU_MSG")
1014
1309
  return this.rawContent.info[3][1];
1310
+ if (this.rawType === "SEND_GIFT_V2" && ((t = this._pbData) != null && t.medal))
1311
+ return this._pbData.medal.medal_name;
1015
1312
  if ("data" in this.rawContent) {
1016
1313
  if ("medal_info" in this.rawContent.data && "medal_name" in this.rawContent.data.medal_info)
1017
1314
  return this.rawContent.data.medal_info.medal_name;
@@ -1022,12 +1319,12 @@ const l = [
1022
1319
  }
1023
1320
  }
1024
1321
  if (this.platform === "acfun") {
1025
- let s;
1026
- if ("gift" in this.rawContent && (s = this.rawContent.gift.userInfo), "userInfo" in this.rawContent && (s = this.rawContent.userInfo), s && s.badge.length > 0)
1027
- return JSON.parse(s.badge).medalInfo.clubName;
1322
+ let n;
1323
+ if ("gift" in this.rawContent && (n = this.rawContent.gift.userInfo), "userInfo" in this.rawContent && (n = this.rawContent.userInfo), n && n.badge.length > 0)
1324
+ return JSON.parse(n.badge).medalInfo.clubName;
1028
1325
  }
1029
1326
  if (this.platform === "douyin" && "user" in this.rawContent)
1030
- return (i = (t = this.rawContent.user.fansClub) == null ? void 0 : t.data) == null ? void 0 : i.clubName;
1327
+ return (s = (i = this.rawContent.user.fansClub) == null ? void 0 : i.data) == null ? void 0 : s.clubName;
1031
1328
  }
1032
1329
  /** AcFun 守护团所属主播的用户 ID。 */
1033
1330
  get acfunClubUid() {
@@ -1058,17 +1355,21 @@ const l = [
1058
1355
  */
1059
1356
  get avatar() {
1060
1357
  var t, i;
1061
- if ((this.platform === "bilibili" || this.platform === "openblive") && "data" in this.rawContent) {
1062
- if ("user_info" in this.rawContent.data) {
1063
- if ("face" in this.rawContent.data.user_info)
1064
- return this.rawContent.data.user_info.face;
1065
- if ("uface" in this.rawContent.data.user_info)
1066
- return this.rawContent.data.user_info.uface;
1358
+ if (this.platform === "bilibili" || this.platform === "openblive") {
1359
+ if (this.rawType === "SEND_GIFT_V2" && this._pbData)
1360
+ return this._pbData.face;
1361
+ if ("data" in this.rawContent) {
1362
+ if ("user_info" in this.rawContent.data) {
1363
+ if ("face" in this.rawContent.data.user_info)
1364
+ return this.rawContent.data.user_info.face;
1365
+ if ("uface" in this.rawContent.data.user_info)
1366
+ return this.rawContent.data.user_info.uface;
1367
+ }
1368
+ if ("face" in this.rawContent.data)
1369
+ return this.rawContent.data.face;
1370
+ if ("uface" in this.rawContent.data)
1371
+ return this.rawContent.data.uface;
1067
1372
  }
1068
- if ("face" in this.rawContent.data)
1069
- return this.rawContent.data.face;
1070
- if ("uface" in this.rawContent.data)
1071
- return this.rawContent.data.uface;
1072
1373
  }
1073
1374
  if (this.platform === "acfun") {
1074
1375
  if ("gift" in this.rawContent)
@@ -1112,72 +1413,72 @@ const l = [
1112
1413
  const {
1113
1414
  stickerStyle: i = "",
1114
1415
  stickerClass: s = "",
1115
- emotStyle: e = "",
1116
- emotClass: n = "",
1416
+ emotStyle: n = "",
1417
+ emotClass: o = "",
1117
1418
  acfunCustomStickers: p = [],
1118
- acfunCustomHtmlBuilder: h
1119
- } = t, m = {
1419
+ acfunCustomHtmlBuilder: r
1420
+ } = t, f = {
1120
1421
  acfun: () => {
1121
- let o = g(this.rawContent.content);
1422
+ let a = m(this.rawContent.content);
1122
1423
  if ("emotionUrl" in this.rawContent && this.rawContent.emotionUrl)
1123
1424
  return `<img src="${this.rawContent.emotionUrl}" alt="" style="${i}" class="${s}">`;
1124
- let c;
1125
- return p.forEach((d) => {
1126
- o.includes(d.keyWord) && (c = d.path);
1127
- }), c != null ? h != null ? h(c, o) : `<div style="display:flex;">
1128
- <img src="${c}" alt="" style="${i}" class="${s}">
1129
- <div style="flex-grow:1;">${o}</div>
1130
- </div>` : g(this.rawContent.content);
1425
+ let d;
1426
+ return p.forEach((h) => {
1427
+ a.includes(h.keyWord) && (d = h.path);
1428
+ }), d != null ? r != null ? r(d, a) : `<div style="display:flex;">
1429
+ <img src="${d}" alt="" style="${i}" class="${s}">
1430
+ <div style="flex-grow:1;">${a}</div>
1431
+ </div>` : m(this.rawContent.content);
1131
1432
  },
1132
1433
  bilibili: () => {
1133
1434
  if (typeof this.rawContent.info[0][13] == "object")
1134
1435
  return `<img src="${this.rawContent.info[0][13].url}" alt="" style="${i}" class="${s}">`;
1135
- const o = this.rawContent.info[0][15].extra, c = JSON.parse(o);
1136
- let d = g(c.content);
1137
- const u = c.emots;
1138
- for (let y in u) {
1139
- const F = new RegExp(`\\${y}`, "g");
1140
- d = d.replace(F, `<img src="${u[y].url}" alt="" style="${e}" class="${n}">`);
1436
+ const a = this.rawContent.info[0][15].extra, d = JSON.parse(a);
1437
+ let h = m(d.content);
1438
+ const u = d.emots;
1439
+ for (let l in u) {
1440
+ const F = new RegExp(`\\${l}`, "g");
1441
+ h = h.replace(F, `<img src="${u[l].url}" alt="" style="${n}" class="${o}">`);
1141
1442
  }
1142
- return d;
1443
+ return h;
1143
1444
  },
1144
1445
  openblive: () => {
1145
1446
  if (this.rawContent.data.emoji_img_url)
1146
1447
  return `<img src="${this.rawContent.data.emoji_img_url}" alt="" style="${i}" class="${s}">`;
1147
- let o = g(this.rawContent.data.msg);
1148
- return j.forEach((c) => {
1149
- const d = new RegExp(`\\${c[0]}`, "g");
1150
- o = o.replace(d, `<img src="${c[1]}" alt="" style="${e}" class="${n}">`);
1151
- }), o;
1448
+ let a = m(this.rawContent.data.msg);
1449
+ return j.forEach((d) => {
1450
+ const h = new RegExp(`\\${d[0]}`, "g");
1451
+ a = a.replace(h, `<img src="${d[1]}" alt="" style="${n}" class="${o}">`);
1452
+ }), a;
1152
1453
  },
1153
1454
  douyin: () => {
1154
- let o = g(this.rawContent.content);
1155
- return l.forEach((c) => {
1156
- const d = new RegExp(`\\${c[0]}`, "g");
1157
- o = o.replace(d, `<img src="${c[1]}" alt="" style="${e}" class="${n}">`);
1158
- }), o;
1455
+ let a = m(this.rawContent.content);
1456
+ return y.forEach((d) => {
1457
+ const h = new RegExp(`\\${d[0]}`, "g");
1458
+ a = a.replace(h, `<img src="${d[1]}" alt="" style="${n}" class="${o}">`);
1459
+ }), a;
1159
1460
  },
1160
1461
  kuaishou: () => {
1161
- let o = g(this.rawContent.content);
1162
- return v.forEach((c) => {
1163
- const d = new RegExp(`\\${c[0]}`, "g");
1164
- o = o.replace(d, `<img src="${c[1]}" alt="" style="${e}" class="${n}">`);
1165
- }), o;
1462
+ let a = m(this.rawContent.content);
1463
+ return v.forEach((d) => {
1464
+ const h = new RegExp(`\\${d[0]}`, "g");
1465
+ a = a.replace(h, `<img src="${d[1]}" alt="" style="${n}" class="${o}">`);
1466
+ }), a;
1166
1467
  },
1167
1468
  chzzk: () => {
1168
- let o = g(this.rawContent.msg);
1469
+ let a = m(this.rawContent.msg);
1169
1470
  if (this.rawContent.extras) {
1170
- const d = JSON.parse(this.rawContent.extras).emojis || {};
1171
- for (let u in d) {
1172
- const y = new RegExp(`\\{:${u}:}`, "g");
1173
- o = o.replace(y, `<img src="${d[u]}" alt="" style="${e}" class="${n}">`);
1471
+ const h = JSON.parse(this.rawContent.extras).emojis || {};
1472
+ for (let u in h) {
1473
+ const l = new RegExp(`\\{:${u}:}`, "g");
1474
+ a = a.replace(l, `<img src="${h[u]}" alt="" style="${n}" class="${o}">`);
1174
1475
  }
1175
- return o;
1476
+ return a;
1176
1477
  }
1177
1478
  }
1178
1479
  };
1179
- if (this.type === "comment" && m[this.platform])
1180
- return m[this.platform]();
1480
+ if (this.type === "comment" && f[this.platform])
1481
+ return f[this.platform]();
1181
1482
  }
1182
1483
  /**
1183
1484
  * Custom comment content builder.
@@ -1189,39 +1490,39 @@ const l = [
1189
1490
  CommentBuilder(t) {
1190
1491
  const i = {
1191
1492
  acfun: () => {
1192
- let s = g(this.rawContent.content), e = "emotionUrl" in this.rawContent && this.rawContent.emotionUrl ? this.rawContent.emotionUrl : void 0;
1193
- return t(s, e);
1493
+ let s = m(this.rawContent.content), n = "emotionUrl" in this.rawContent && this.rawContent.emotionUrl ? this.rawContent.emotionUrl : void 0;
1494
+ return t(s, n);
1194
1495
  },
1195
1496
  bilibili: () => {
1196
- let s, e = [];
1497
+ let s, n = [];
1197
1498
  typeof this.rawContent.info[0][13] == "object" && (s = this.rawContent.info[0][13].url);
1198
- const n = this.rawContent.info[0][15].extra, p = JSON.parse(n), h = g(p.content), m = p.emots;
1199
- for (let o in m)
1200
- e.push([o, m[o].url]);
1201
- return t(h, s, e);
1499
+ const o = this.rawContent.info[0][15].extra, p = JSON.parse(o), r = m(p.content), f = p.emots;
1500
+ for (let a in f)
1501
+ n.push([a, f[a].url]);
1502
+ return t(r, s, n);
1202
1503
  },
1203
1504
  openblive: () => {
1204
1505
  let s;
1205
1506
  this.rawContent.data.emoji_img_url && (s = this.rawContent.data.emoji_img_url);
1206
- const e = g(this.rawContent.data.msg);
1207
- return t(e, s, j);
1507
+ const n = m(this.rawContent.data.msg);
1508
+ return t(n, s, j);
1208
1509
  },
1209
1510
  douyin: () => {
1210
- const s = g(this.rawContent.content);
1211
- return t(s, void 0, l);
1511
+ const s = m(this.rawContent.content);
1512
+ return t(s, void 0, y);
1212
1513
  },
1213
1514
  kuaishou: () => {
1214
- const s = g(this.rawContent.content);
1515
+ const s = m(this.rawContent.content);
1215
1516
  return t(s, void 0, v);
1216
1517
  },
1217
1518
  chzzk: () => {
1218
- let s = g(this.rawContent.msg), e = [];
1519
+ let s = m(this.rawContent.msg), n = [];
1219
1520
  if (this.rawContent.extras) {
1220
1521
  const p = JSON.parse(this.rawContent.extras).emojis || {};
1221
- for (let h in p)
1222
- e.push([`{:${h}:}`, p[h]]);
1522
+ for (let r in p)
1523
+ n.push([`{:${r}:}`, p[r]]);
1223
1524
  }
1224
- return t(s, void 0, e);
1525
+ return t(s, void 0, n);
1225
1526
  }
1226
1527
  };
1227
1528
  if (this.type === "comment" && i[this.platform])
@@ -1238,9 +1539,12 @@ const l = [
1238
1539
  * @see {@link https://dimsum.chat/zh/api/parser.html#parser-guardlevel}
1239
1540
  */
1240
1541
  get guardLevel() {
1542
+ var t;
1241
1543
  if (this.platform === "bilibili" || this.platform === "openblive") {
1242
1544
  if (this.rawType === "DANMU_MSG")
1243
1545
  return this.rawContent.info[7];
1546
+ if (this.rawType === "SEND_GIFT_V2" && ((t = this._pbData) != null && t.medal))
1547
+ return this._pbData.medal.guard_level;
1244
1548
  if ("data" in this.rawContent) {
1245
1549
  if ("guard_level" in this.rawContent.data)
1246
1550
  return this.rawContent.data.guard_level;
@@ -1249,8 +1553,8 @@ const l = [
1249
1553
  }
1250
1554
  }
1251
1555
  if (this.platform === "chzzk") {
1252
- const t = this.chzzkTier;
1253
- return t && t <= 3 && t >= 1 ? 4 - t : 0;
1556
+ const i = this.chzzkTier;
1557
+ return i && i <= 3 && i >= 1 ? 4 - i : 0;
1254
1558
  }
1255
1559
  }
1256
1560
  /**
@@ -1294,7 +1598,7 @@ const l = [
1294
1598
  get giftName() {
1295
1599
  const t = {
1296
1600
  acfun: () => this.rawContent.giftInfo.name,
1297
- bilibili: () => this.rawContent.data.giftName,
1601
+ bilibili: () => this.rawType === "SEND_GIFT_V2" && this._pbData ? this._pbData.gift.gift_name : this.rawContent.data.giftName,
1298
1602
  openblive: () => this.rawContent.data.gift_name,
1299
1603
  douyin: () => this.rawContent.gift.name,
1300
1604
  kuaishou: () => this.rawContent.giftInfo.name
@@ -1312,20 +1616,20 @@ const l = [
1312
1616
  get giftNum() {
1313
1617
  const t = {
1314
1618
  acfun: () => this.rawContent.gift.batchSize,
1315
- bilibili: () => this.rawContent.data.num,
1619
+ bilibili: () => this.rawType === "SEND_GIFT_V2" && this._pbData ? this._pbData.gift.num : this.rawContent.data.num,
1316
1620
  openblive: () => this.rawContent.data.gift_num,
1317
1621
  douyin: () => {
1318
1622
  if (this.rawContent.sendType === 4) {
1319
- const s = this.rawContent.comboCount, e = this.rawContent.groupId, n = this.rawContent.giftId, p = this.uid, h = `${e}_${p}_${n}`;
1320
- let m = 0;
1321
- return r.douyinGiftGroup.has(h) && (m = r.douyinGiftGroup.get(h) ?? 0), r.douyinGiftGroup.set(h, s), r.douyinGiftGroup.size > 1024 && r.douyinGiftGroup.delete(r.douyinGiftGroup.keys().next().value ?? ""), s - m;
1623
+ const s = this.rawContent.comboCount, n = this.rawContent.groupId, o = this.rawContent.giftId, p = this.uid, r = `${n}_${p}_${o}`;
1624
+ let f = 0;
1625
+ return b.douyinGiftGroup.has(r) && (f = b.douyinGiftGroup.get(r) ?? 0), b.douyinGiftGroup.set(r, s), b.douyinGiftGroup.size > 1024 && b.douyinGiftGroup.delete(b.douyinGiftGroup.keys().next().value ?? ""), s - f;
1322
1626
  }
1323
1627
  return this.rawContent.groupCount;
1324
1628
  },
1325
1629
  kuaishou: () => {
1326
- const s = this.rawContent.batchSize * this.rawContent.comboCount, e = this.rawContent.mergeKey;
1327
- let n = 0;
1328
- return r.kuaishouGiftGroup.has(e) && (n = r.kuaishouGiftGroup.get(e) ?? 0), r.kuaishouGiftGroup.set(e, s), r.kuaishouGiftGroup.size > 1024 && r.kuaishouGiftGroup.delete(r.kuaishouGiftGroup.keys().next().value ?? ""), s - n;
1630
+ const s = this.rawContent.batchSize * this.rawContent.comboCount, n = this.rawContent.mergeKey;
1631
+ let o = 0;
1632
+ return b.kuaishouGiftGroup.has(n) && (o = b.kuaishouGiftGroup.get(n) ?? 0), b.kuaishouGiftGroup.set(n, s), b.kuaishouGiftGroup.size > 1024 && b.kuaishouGiftGroup.delete(b.kuaishouGiftGroup.keys().next().value ?? ""), s - o;
1329
1633
  }
1330
1634
  };
1331
1635
  if (this.type === "gift" && t[this.platform])
@@ -1341,7 +1645,7 @@ const l = [
1341
1645
  get giftUnitPrice() {
1342
1646
  const t = {
1343
1647
  acfun: () => this.rawContent.gift.giftId !== 1 ? this.rawContent.giftInfo.value / 10 : 0,
1344
- bilibili: () => this.rawContent.data.coin_type !== "silver" ? this.rawContent.data.price / 1e3 : 0,
1648
+ bilibili: () => this.rawType === "SEND_GIFT_V2" && this._pbData ? this._pbData.gift.coin_type === "gold" ? this._pbData.gift.price / 1e3 : 0 : this.rawContent.data.coin_type !== "silver" ? this.rawContent.data.price / 1e3 : 0,
1345
1649
  openblive: () => this.rawContent.data.paid ? this.rawContent.data.price / 1e3 : 0,
1346
1650
  douyin: () => this.rawContent.gift.diamondCount / 10,
1347
1651
  kuaishou: () => this.rawContent.giftInfo.unitPrice / 10
@@ -1364,12 +1668,15 @@ const l = [
1364
1668
  get giftImage() {
1365
1669
  return this.type !== "gift" ? void 0 : {
1366
1670
  acfun: () => this.rawContent.giftInfo.pic,
1367
- bilibili: () => this.rawContent.data.gift_info.webp,
1671
+ bilibili: () => {
1672
+ var i, s;
1673
+ return this.rawType === "SEND_GIFT_V2" && this._pbData ? ((i = this._pbData.gift.effect) == null ? void 0 : i.img_gif) ?? ((s = this._pbData.gift.effect) == null ? void 0 : s.img_2) : this.rawContent.data.gift_info.webp;
1674
+ },
1368
1675
  openblive: () => this.rawContent.data.gift_icon,
1369
1676
  douyin: () => {
1370
- var s, e;
1677
+ var s, n;
1371
1678
  const i = this.rawContent.gift.image;
1372
- return ((s = i.urlListList) == null ? void 0 : s[0]) ?? ((e = i.urlList) == null ? void 0 : e[0]);
1679
+ return ((s = i.urlListList) == null ? void 0 : s[0]) ?? ((n = i.urlList) == null ? void 0 : n[0]);
1373
1680
  },
1374
1681
  kuaishou: () => this.rawContent.giftInfo.picUrl[0].url
1375
1682
  }[this.platform]();
@@ -1436,23 +1743,23 @@ const l = [
1436
1743
  const {
1437
1744
  douyinSteps: i = [7, 11, 15],
1438
1745
  kuaishouSteps: s = [7, 11, 15],
1439
- acfunSteps: e = [7, 11, 15],
1440
- acfunClubUid: n = 0
1441
- } = t, p = (o) => {
1746
+ acfunSteps: n = [7, 11, 15],
1747
+ acfunClubUid: o = 0
1748
+ } = t, p = (a) => {
1442
1749
  if (this.clubLevel === void 0)
1443
1750
  return 0;
1444
- const c = o.findIndex((d) => this.clubLevel <= d);
1445
- return c !== -1 ? c : o.length;
1446
- }, h = () => this.guardLevel && this.guardLevel > 0 ? 4 - this.guardLevel : 0, m = {
1751
+ const d = a.findIndex((h) => this.clubLevel <= h);
1752
+ return d !== -1 ? d : a.length;
1753
+ }, r = () => this.guardLevel && this.guardLevel > 0 ? 4 - this.guardLevel : 0, f = {
1447
1754
  douyin: () => p(i),
1448
1755
  kuaishou: () => p(s),
1449
- acfun: () => n > 0 && this.acfunClubUid !== n ? 0 : p(e),
1450
- bilibili: () => h(),
1451
- openblive: () => h(),
1756
+ acfun: () => o > 0 && this.acfunClubUid !== o ? 0 : p(n),
1757
+ bilibili: () => r(),
1758
+ openblive: () => r(),
1452
1759
  chzzk: () => this.chzzkTier ?? 0
1453
1760
  };
1454
- if (m[this.platform])
1455
- return m[this.platform]();
1761
+ if (f[this.platform])
1762
+ return f[this.platform]();
1456
1763
  }
1457
1764
  };
1458
1765
  /**
@@ -1461,23 +1768,23 @@ const l = [
1461
1768
  * @example
1462
1769
  * Parser.DouyinEmots.forEach(([emot, url]) => console.log(emot, url));
1463
1770
  */
1464
- a(r, "DouyinEmots", l), /**
1771
+ c(b, "DouyinEmots", y), /**
1465
1772
  * Bilibili emoji mappings (also used by OpenBLive).
1466
1773
  *
1467
1774
  * @example
1468
1775
  * Parser.BilibiliEmots.forEach(([emot, url]) => console.log(emot, url));
1469
1776
  */
1470
- a(r, "BilibiliEmots", j), /**
1777
+ c(b, "BilibiliEmots", j), /**
1471
1778
  * Kuaishou emoji mappings.
1472
1779
  *
1473
1780
  * @example
1474
1781
  * Parser.KuaishouEmots.forEach(([emot, url]) => console.log(emot, url));
1475
1782
  */
1476
- a(r, "KuaishouEmots", v), // groupId_userId_giftId : comboCount
1477
- a(r, "douyinGiftGroup", /* @__PURE__ */ new Map()), a(r, "kuaishouGiftGroup", /* @__PURE__ */ new Map());
1478
- let C = r;
1479
- function g(b) {
1480
- return b.replace(/[&<>"']/g, function(t) {
1783
+ c(b, "KuaishouEmots", v), // groupId_userId_giftId : comboCount
1784
+ c(b, "douyinGiftGroup", /* @__PURE__ */ new Map()), c(b, "kuaishouGiftGroup", /* @__PURE__ */ new Map());
1785
+ let z = b;
1786
+ function m(e) {
1787
+ return e.replace(/[&<>"']/g, function(t) {
1481
1788
  switch (t) {
1482
1789
  case "&":
1483
1790
  return "&amp;";
@@ -1495,9 +1802,9 @@ function g(b) {
1495
1802
  });
1496
1803
  }
1497
1804
  export {
1498
- C as Parser,
1499
- z as WebSocketManager,
1500
- P as getBfaceURL,
1501
- S as getWebSocketURL,
1502
- U as onMessage
1805
+ z as Parser,
1806
+ D as WebSocketManager,
1807
+ K as getBfaceURL,
1808
+ N as getWebSocketURL,
1809
+ q as onMessage
1503
1810
  };