@easemob-community/uikit-sdk-websdk5 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/adapter/conversation-adapter.d.ts.map +1 -1
  2. package/dist/adapter/internal-stores/user-info.d.ts.map +1 -1
  3. package/dist/adapter/repositories/user-info.d.ts.map +1 -1
  4. package/dist/adapter/user-info-cache.d.ts +10 -0
  5. package/dist/adapter/user-info-cache.d.ts.map +1 -0
  6. package/dist/adapter/user-info-cache.test.d.ts +2 -0
  7. package/dist/adapter/user-info-cache.test.d.ts.map +1 -0
  8. package/dist/adapter.d.ts.map +1 -1
  9. package/dist/client.d.ts +2 -0
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/domain/__tests__/presence-batching.test.d.ts +2 -0
  12. package/dist/domain/__tests__/presence-batching.test.d.ts.map +1 -0
  13. package/dist/domain/conversation-domain.d.ts +2 -0
  14. package/dist/domain/conversation-domain.d.ts.map +1 -1
  15. package/dist/domain/presence-domain.d.ts +12 -3
  16. package/dist/domain/presence-domain.d.ts.map +1 -1
  17. package/dist/domain/user-info-domain.d.ts +10 -7
  18. package/dist/domain/user-info-domain.d.ts.map +1 -1
  19. package/dist/easemob-uikit-sdk-websdk5.js +1389 -1109
  20. package/dist/easemob-uikit-sdk-websdk5.umd.cjs +1 -1
  21. package/dist/event/__tests__/conversation-mute.test.d.ts +2 -0
  22. package/dist/event/__tests__/conversation-mute.test.d.ts.map +1 -0
  23. package/dist/event/chat-events.d.ts.map +1 -1
  24. package/dist/event/connection-events.d.ts +3 -0
  25. package/dist/event/connection-events.d.ts.map +1 -1
  26. package/dist/event/conversation-mute.d.ts +56 -0
  27. package/dist/event/conversation-mute.d.ts.map +1 -0
  28. package/dist/event/types.d.ts +1 -0
  29. package/dist/event/types.d.ts.map +1 -1
  30. package/dist/utils/__tests__/conversation-log.test.d.ts +2 -0
  31. package/dist/utils/__tests__/conversation-log.test.d.ts.map +1 -0
  32. package/dist/utils/conversation-log.d.ts +15 -0
  33. package/dist/utils/conversation-log.d.ts.map +1 -0
  34. package/package.json +2 -2
@@ -1,33 +1,33 @@
1
- import { ChatClient as it, isSDKError as Ve, ChatManager as qe, ChatRoomManager as at, UserInfoManager as We, ContactManager as ct, GroupManager as ut, PresenceManager as dt, PushManager as lt } from "easemob-websdk";
2
- import { log as Ce, GROUP_MEMBER_ROLE as L, customEventPreviewMap as gt, mergeMessagePreviewLabels as Je, MESSAGE_TYPE as C, resolveMultiBodyPreview as $e, isTextBody as ft, isImageBody as mt, MESSAGE_EXT_KEY as Qe, isVoiceBody as ze, isVideoBody as pt, isFileBody as ht, isLocationBody as vt, isCustomBody as It, isCmdBody as Mt, isCombineBody as Ye, CONVERSATION_TYPE as M, normalizeUserId as E, MESSAGE_STATUS as O, isMultiBody as yt, createLogger as T, toMessageRecord as we, formatConversationPreview as Xe, PRESENCE_STATUS as X, isKickErrorCode as bt, resolveLastMessageText as Ct, isStreamActive as wt, toConversationRecord as _e, NOTICE_EVENT_TYPE as A, SDK_CONTRACT_VERSION as St, normalizeLoginUserId as At } from "@easemob-community/uikit-sdk-contract";
3
- import { normalizeUserId as rs } from "@easemob-community/uikit-sdk-contract";
4
- import { markRaw as Ne, computed as me, reactive as Gt } from "vue";
5
- let ce = null;
6
- function qn(s) {
7
- ce = s;
1
+ import { ChatClient as It, isSDKError as et, ChatManager as tt, ChatRoomManager as Mt, UserInfoManager as nt, ContactManager as yt, GroupManager as Ct, PresenceManager as bt, PushManager as wt } from "easemob-websdk";
2
+ import { log as Le, GROUP_MEMBER_ROLE as R, customEventPreviewMap as St, mergeMessagePreviewLabels as st, MESSAGE_TYPE as b, resolveMultiBodyPreview as rt, isTextBody as At, isImageBody as Et, MESSAGE_EXT_KEY as ot, isVoiceBody as it, isVideoBody as Gt, isFileBody as Tt, isLocationBody as Ut, isCustomBody as Rt, isCmdBody as Lt, isCombineBody as at, CONVERSATION_TYPE as I, normalizeUserId as G, MESSAGE_STATUS as k, isMultiBody as _t, createLogger as T, toMessageRecord as _e, formatConversationPreview as ct, PRESENCE_STATUS as ee, isKickErrorCode as Dt, resolveLastMessageText as Nt, isStreamActive as kt, toConversationRecord as Ke, NOTICE_EVENT_TYPE as E, SDK_CONTRACT_VERSION as Ot, normalizeLoginUserId as xt } from "@easemob-community/uikit-sdk-contract";
3
+ import { normalizeUserId as Es } from "@easemob-community/uikit-sdk-contract";
4
+ import { markRaw as qe, computed as Me, reactive as Pt } from "vue";
5
+ let de = null;
6
+ function gs(s) {
7
+ de = s;
8
8
  }
9
- function Et(s) {
10
- ce == null || ce(s);
9
+ function Bt(s) {
10
+ de == null || de(s);
11
11
  }
12
- const Ze = "uikit-sdk-log-capture", Tt = /^%c\[Chat\]\[(DEBUG|WARN|ERROR)\]\[[^\]]*\]/, et = {
12
+ const ut = "uikit-sdk-log-capture", Ft = /^%c\[Chat\]\[(DEBUG|WARN|ERROR)\]\[[^\]]*\]/, dt = {
13
13
  DEBUG: "debug",
14
14
  WARN: "warn",
15
15
  ERROR: "error"
16
16
  };
17
- let Q = !1, K = null, V = null, ue = null, Se = !1, H = null, de = null;
18
- function Rt(s) {
19
- de = s;
17
+ let z = !1, j = null, W = null, le = null, De = !1, q = null, fe = null;
18
+ function Ht(s) {
19
+ fe = s;
20
20
  }
21
- function ee(s, e, t) {
22
- Q && Et({
23
- level: et[s],
21
+ function ne(s, e, t) {
22
+ z && Bt({
23
+ level: dt[s],
24
24
  source: "sdk",
25
25
  message: typeof e == "string" ? e : String(e),
26
26
  args: t
27
27
  });
28
28
  }
29
- function pe(s, e, t) {
30
- const n = V ?? console.log, o = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
29
+ function ye(s, e, t) {
30
+ const n = W ?? console.log, o = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
31
31
  n.call(
32
32
  console,
33
33
  `%c[Chat][${s}][${o}]`,
@@ -36,72 +36,72 @@ function pe(s, e, t) {
36
36
  ...t
37
37
  );
38
38
  }
39
- function Ut() {
40
- V || (V = console.log, console.log = (...s) => {
39
+ function Kt() {
40
+ W || (W = console.log, console.log = (...s) => {
41
41
  try {
42
42
  const e = s[0];
43
43
  if (typeof e == "string") {
44
- const t = e.match(Tt);
45
- t && ee(t[1], s[2], s.slice(3));
44
+ const t = e.match(Ft);
45
+ t && ne(t[1], s[2], s.slice(3));
46
46
  }
47
47
  } catch {
48
48
  }
49
- V.apply(console, s);
49
+ W.apply(console, s);
50
50
  });
51
51
  }
52
- function Lt() {
53
- V && (console.log = V, V = null);
52
+ function qt() {
53
+ W && (console.log = W, W = null);
54
54
  }
55
- async function Wn() {
55
+ async function ms() {
56
56
  var s;
57
- if (!Q) {
58
- Q = !0;
57
+ if (!z) {
58
+ z = !0;
59
59
  try {
60
60
  const e = await import("easemob-websdk");
61
- typeof e.setLogLevel == "function" && (e.setLogLevel("DEBUG"), Se = !0);
61
+ typeof e.setLogLevel == "function" && (e.setLogLevel("DEBUG"), De = !0);
62
62
  const t = e.LogEventName ? (s = e.ChatClient) == null ? void 0 : s.instance : null;
63
- t && typeof t.addEventHandler == "function" ? (t.addEventHandler(Ze, {
63
+ t && typeof t.addEventHandler == "function" ? (t.addEventHandler(ut, {
64
64
  onLog: (n) => {
65
65
  const o = n;
66
- o && typeof o.level == "string" && o.level in et && ee(o.level, o.message, [...o.args ?? []]);
66
+ o && typeof o.level == "string" && o.level in dt && ne(o.level, o.message, [...o.args ?? []]);
67
67
  }
68
- }), H = t, K = "onlog") : typeof e.setLogger == "function" ? (ue = typeof e.getLogger == "function" ? e.getLogger() : null, e.setLogger({
68
+ }), q = t, j = "onlog") : typeof e.setLogger == "function" ? (le = typeof e.getLogger == "function" ? e.getLogger() : null, e.setLogger({
69
69
  debug: (n, ...o) => {
70
- ee("DEBUG", n, o), pe("DEBUG", n, o);
70
+ ne("DEBUG", n, o), ye("DEBUG", n, o);
71
71
  },
72
72
  warn: (n, ...o) => {
73
- ee("WARN", n, o), pe("WARN", n, o);
73
+ ne("WARN", n, o), ye("WARN", n, o);
74
74
  },
75
75
  error: (n, ...o) => {
76
- ee("ERROR", n, o), pe("ERROR", n, o);
76
+ ne("ERROR", n, o), ye("ERROR", n, o);
77
77
  }
78
- }), K = "inject") : (Ut(), K = "console");
78
+ }), j = "inject") : (Kt(), j = "console");
79
79
  } catch (e) {
80
- Q = !1, console.warn("[UIKit:SdkLogCapture] failed to enable SDK log capture", e);
80
+ z = !1, console.warn("[UIKit:SdkLogCapture] failed to enable SDK log capture", e);
81
81
  }
82
82
  }
83
83
  }
84
- async function Jn() {
84
+ async function ps() {
85
85
  var s;
86
- if (Q) {
87
- Q = !1;
86
+ if (z) {
87
+ z = !1;
88
88
  try {
89
- K === "console" && Lt(), K === "onlog" && ((s = H == null ? void 0 : H.removeEventHandler) == null || s.call(H, Ze));
89
+ j === "console" && qt(), j === "onlog" && ((s = q == null ? void 0 : q.removeEventHandler) == null || s.call(q, ut));
90
90
  const e = await import("easemob-websdk");
91
- K === "inject" && typeof e.setLogger == "function" && ue && e.setLogger(ue), Se && !(de != null && de()) && typeof e.setLogLevel == "function" && e.setLogLevel("WARN");
91
+ j === "inject" && typeof e.setLogger == "function" && le && e.setLogger(le), De && !(fe != null && fe()) && typeof e.setLogLevel == "function" && e.setLogLevel("WARN");
92
92
  } catch {
93
93
  } finally {
94
- K = null, H = null, ue = null, Se = !1;
94
+ j = null, q = null, le = null, De = !1;
95
95
  }
96
96
  }
97
97
  }
98
- let Re = !1;
99
- function $n() {
100
- return Re;
98
+ let Pe = !1;
99
+ function hs() {
100
+ return Pe;
101
101
  }
102
- let tt = null;
103
- function Dt(s) {
104
- const e = tt;
102
+ let lt = null;
103
+ function jt(s) {
104
+ const e = lt;
105
105
  if (!e)
106
106
  return s;
107
107
  if (s.appKey !== e.appKey || s.appId !== e.appId)
@@ -111,13 +111,13 @@ function Dt(s) {
111
111
  const { managers: t, ...n } = s, o = [];
112
112
  for (const a of Object.keys(n))
113
113
  JSON.stringify(n[a]) !== JSON.stringify(e[a]) && o.push(a);
114
- return o.length > 0 && Ce(
114
+ return o.length > 0 && Le(
115
115
  "[UIKit] SDK 已初始化,本次 init 配置以首次初始化为准(忽略字段:%s)。",
116
116
  o.join(", ")
117
117
  ), { ...e, managers: t };
118
118
  }
119
- Rt(() => Re);
120
- class _t {
119
+ Ht(() => Pe);
120
+ class Vt {
121
121
  constructor(e) {
122
122
  var i;
123
123
  const { debug: t, clientName: n = "UIKit", clientVersion: o, ...a } = e;
@@ -125,25 +125,25 @@ class _t {
125
125
  throw new Error(
126
126
  "[UIKit] ClientConfig.managers 未注入:SDK manager 列表由 adapter 负责传入"
127
127
  );
128
- const r = Dt({
128
+ const r = jt({
129
129
  ...a,
130
130
  enableUserInfoSync: a.enableUserInfoSync ?? !0,
131
131
  managers: a.managers
132
132
  });
133
- this._deleteConversationOnGroupDestroyed = r.deleteConversationOnGroupDestroyed ?? !0, this._client = it.init(r), tt = r, t && (Re = !0, import("easemob-websdk").then(({ setLogLevel: c }) => {
133
+ this._deleteConversationOnGroupDestroyed = r.deleteConversationOnGroupDestroyed ?? !0, this._client = It.init(r), lt = r, t && (Pe = !0, import("easemob-websdk").then(({ setLogLevel: c }) => {
134
134
  c("DEBUG");
135
- })), o ? Ce(
135
+ })), o ? Le(
136
136
  "%c[Easemob] SDK version: %s, %s version: %s, Adapter version: %s",
137
137
  "color: green; font-weight: bold;",
138
- "5.2.0",
138
+ "5.2.1",
139
139
  n,
140
140
  o,
141
- "1.6.2"
142
- ) : Ce(
141
+ "1.7.0"
142
+ ) : Le(
143
143
  "%c[Easemob] SDK version: %s, Adapter version: %s",
144
144
  "color: green; font-weight: bold;",
145
- "5.2.0",
146
- "1.6.2"
145
+ "5.2.1",
146
+ "1.7.0"
147
147
  );
148
148
  }
149
149
  get chatManager() {
@@ -179,6 +179,12 @@ class _t {
179
179
  get currentUserId() {
180
180
  return this._client.getCurrentUserId();
181
181
  }
182
+ /** SDK internal 缓存入口的安全委托,由 adapter 内结构类型消费。 */
183
+ getCacheManager() {
184
+ var t;
185
+ const e = this._client;
186
+ return ((t = e.getCacheManager) == null ? void 0 : t.call(e)) ?? null;
187
+ }
182
188
  addEventHandler(e, t) {
183
189
  this._client.addEventHandler(e, t);
184
190
  }
@@ -192,10 +198,10 @@ class _t {
192
198
  return this._client.logout();
193
199
  }
194
200
  }
195
- function Nt(s) {
196
- return new _t(s);
201
+ function Wt(s) {
202
+ return new Vt(s);
197
203
  }
198
- function kt(s, e) {
204
+ function Jt(s, e) {
199
205
  let t = !1, n = !1, o = !1;
200
206
  function a() {
201
207
  return n ? "connecting" : t ? "connected" : o ? "reconnectFailed" : "disconnected";
@@ -225,7 +231,7 @@ function kt(s, e) {
225
231
  }
226
232
  };
227
233
  }
228
- function Ot(s) {
234
+ function $t(s) {
229
235
  let e = [], t = [];
230
236
  function o() {
231
237
  var r, i;
@@ -246,19 +252,19 @@ function Ot(s) {
246
252
  e = r, o();
247
253
  },
248
254
  addContact(r) {
249
- var c, d;
250
- const i = e.findIndex((g) => g.userId === r.userId);
251
- i >= 0 ? e[i] = { ...e[i], ...r } : e.push(r), o(), (d = (c = s()) == null ? void 0 : c.onContactUpdated) == null || d.call(c, r);
255
+ var c, u;
256
+ const i = e.findIndex((l) => l.userId === r.userId);
257
+ i >= 0 ? e[i] = { ...e[i], ...r } : e.push(r), o(), (u = (c = s()) == null ? void 0 : c.onContactUpdated) == null || u.call(c, r);
252
258
  },
253
259
  removeContact(r) {
254
- var c, d;
255
- const i = e.find((g) => g.userId === r);
256
- e = e.filter((g) => g.userId !== r), i && (o(), (d = (c = s()) == null ? void 0 : c.onContactUpdated) == null || d.call(c, i));
260
+ var c, u;
261
+ const i = e.find((l) => l.userId === r);
262
+ e = e.filter((l) => l.userId !== r), i && (o(), (u = (c = s()) == null ? void 0 : c.onContactUpdated) == null || u.call(c, i));
257
263
  },
258
264
  updateRemark(r, i) {
259
- var d, g;
260
- const c = e.findIndex((m) => m.userId === r);
261
- c < 0 || (e[c] = { ...e[c], remark: i, name: i || e[c].name }, o(), (g = (d = s()) == null ? void 0 : d.onContactUpdated) == null || g.call(d, e[c]));
265
+ var u, l;
266
+ const c = e.findIndex((g) => g.userId === r);
267
+ c < 0 || (e[c] = { ...e[c], remark: i, name: i || e[c].name }, o(), (l = (u = s()) == null ? void 0 : u.onContactUpdated) == null || l.call(u, e[c]));
262
268
  },
263
269
  setBlocklist(r) {
264
270
  },
@@ -270,7 +276,7 @@ function Ot(s) {
270
276
  t = t.filter((i) => i.id !== r), a();
271
277
  },
272
278
  updateInviteStatus(r, i) {
273
- const c = t.findIndex((d) => d.id === r);
279
+ const c = t.findIndex((u) => u.id === r);
274
280
  c < 0 || (t[c] = { ...t[c], status: i }, a());
275
281
  },
276
282
  getContact(r) {
@@ -287,7 +293,7 @@ function Ot(s) {
287
293
  }
288
294
  };
289
295
  }
290
- function xt(s) {
296
+ function Qt(s) {
291
297
  let e = [], t = null, n = !1;
292
298
  function o() {
293
299
  var a, r;
@@ -316,9 +322,9 @@ function xt(s) {
316
322
  e = e.filter((c) => c.id !== a), (i = (r = s()) == null ? void 0 : r.onConversationDeleted) == null || i.call(r, a);
317
323
  },
318
324
  update(a, r) {
319
- var c, d;
320
- const i = e.findIndex((g) => g.id === a);
321
- i < 0 || (e[i] = { ...e[i], ...r }, o(), (d = (c = s()) == null ? void 0 : c.onConversationUpdated) == null || d.call(c, { id: a, conversation: r }));
325
+ var c, u;
326
+ const i = e.findIndex((l) => l.id === a);
327
+ i < 0 || (e[i] = { ...e[i], ...r }, o(), (u = (c = s()) == null ? void 0 : c.onConversationUpdated) == null || u.call(c, { id: a, conversation: r }));
322
328
  },
323
329
  setConversationList(a) {
324
330
  this.setList(a);
@@ -349,18 +355,18 @@ function xt(s) {
349
355
  }
350
356
  };
351
357
  }
352
- function Pt(s) {
358
+ function zt(s) {
353
359
  let e = [];
354
- const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), g = !1;
355
- function m() {
356
- var u, l;
357
- (l = (u = s()) == null ? void 0 : u.onGroupChange) == null || l.call(u, e);
358
- }
359
- function p(u, l) {
360
- const f = new Map(u.map((h) => [h.userId, h.role]));
361
- return l.map((h) => {
362
- const v = f.get(h.userId);
363
- return v === L.ADMIN && h.role === L.MEMBER ? { ...h, role: v } : h;
360
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), l = !1;
361
+ function g() {
362
+ var d, f;
363
+ (f = (d = s()) == null ? void 0 : d.onGroupChange) == null || f.call(d, e);
364
+ }
365
+ function p(d, f) {
366
+ const m = new Map(d.map((h) => [h.userId, h.role]));
367
+ return f.map((h) => {
368
+ const v = m.get(h.userId);
369
+ return v === R.ADMIN && h.role === R.MEMBER ? { ...h, role: v } : h;
364
370
  });
365
371
  }
366
372
  return {
@@ -368,330 +374,330 @@ function Pt(s) {
368
374
  return e;
369
375
  },
370
376
  get loaded() {
371
- return g;
377
+ return l;
372
378
  },
373
- setList(u) {
374
- e = u, m();
379
+ setList(d) {
380
+ e = d, g();
375
381
  },
376
- addGroup(u) {
377
- var f, h;
378
- const l = e.findIndex((v) => v.groupId === u.groupId);
379
- l >= 0 ? e[l] = { ...e[l], ...u } : e.push(u), m(), (h = (f = s()) == null ? void 0 : f.onGroupUpdated) == null || h.call(f, u);
382
+ addGroup(d) {
383
+ var m, h;
384
+ const f = e.findIndex((v) => v.groupId === d.groupId);
385
+ f >= 0 ? e[f] = { ...e[f], ...d } : e.push(d), g(), (h = (m = s()) == null ? void 0 : m.onGroupUpdated) == null || h.call(m, d);
380
386
  },
381
- removeGroup(u) {
382
- var f, h;
383
- const l = e.find((v) => v.groupId === u);
384
- e = e.filter((v) => v.groupId !== u), l && (m(), (h = (f = s()) == null ? void 0 : f.onGroupUpdated) == null || h.call(f, l));
387
+ removeGroup(d) {
388
+ var m, h;
389
+ const f = e.find((v) => v.groupId === d);
390
+ e = e.filter((v) => v.groupId !== d), f && (g(), (h = (m = s()) == null ? void 0 : m.onGroupUpdated) == null || h.call(m, f));
385
391
  },
386
- updateGroup(u, l) {
392
+ updateGroup(d, f) {
387
393
  var h, v;
388
- const f = e.findIndex((b) => b.groupId === u);
389
- f < 0 || (e[f] = { ...e[f], ...l }, m(), (v = (h = s()) == null ? void 0 : h.onGroupUpdated) == null || v.call(h, e[f]));
394
+ const m = e.findIndex((C) => C.groupId === d);
395
+ m < 0 || (e[m] = { ...e[m], ...f }, g(), (v = (h = s()) == null ? void 0 : h.onGroupUpdated) == null || v.call(h, e[m]));
390
396
  },
391
- setGroupMembers(u, l) {
397
+ setGroupMembers(d, f) {
392
398
  var h, v;
393
- const f = p(t.get(u) ?? [], l);
394
- t.set(u, f), (v = (h = s()) == null ? void 0 : h.onGroupMembersChanged) == null || v.call(h, { groupId: u, members: f });
399
+ const m = p(t.get(d) ?? [], f);
400
+ t.set(d, m), (v = (h = s()) == null ? void 0 : h.onGroupMembersChanged) == null || v.call(h, { groupId: d, members: m });
395
401
  },
396
- getGroupMembers(u) {
397
- return t.get(u) ?? [];
402
+ getGroupMembers(d) {
403
+ return t.get(d) ?? [];
398
404
  },
399
- appendGroupMembers(u, l) {
400
- var b, w;
401
- const f = t.get(u) ?? [], h = new Map(f.map((I) => [I.userId, I]));
402
- for (const I of p(f, l))
403
- h.set(I.userId, I);
405
+ appendGroupMembers(d, f) {
406
+ var C, w;
407
+ const m = t.get(d) ?? [], h = new Map(m.map((M) => [M.userId, M]));
408
+ for (const M of p(m, f))
409
+ h.set(M.userId, M);
404
410
  const v = Array.from(h.values());
405
- t.set(u, v), (w = (b = s()) == null ? void 0 : b.onGroupMembersChanged) == null || w.call(b, { groupId: u, members: v });
411
+ t.set(d, v), (w = (C = s()) == null ? void 0 : C.onGroupMembersChanged) == null || w.call(C, { groupId: d, members: v });
406
412
  },
407
- removeGroupMembers(u, l) {
408
- var v, b;
409
- const f = new Set(l), h = (t.get(u) ?? []).filter((w) => !f.has(w.userId));
410
- t.set(u, h), (b = (v = s()) == null ? void 0 : v.onGroupMembersChanged) == null || b.call(v, { groupId: u, members: h });
413
+ removeGroupMembers(d, f) {
414
+ var v, C;
415
+ const m = new Set(f), h = (t.get(d) ?? []).filter((w) => !m.has(w.userId));
416
+ t.set(d, h), (C = (v = s()) == null ? void 0 : v.onGroupMembersChanged) == null || C.call(v, { groupId: d, members: h });
411
417
  },
412
- updateGroupMemberRole(u, l, f) {
413
- var b, w;
414
- const h = t.get(u) ?? [], v = h.findIndex((I) => I.userId === l);
415
- v < 0 || (h[v] = { ...h[v], role: f }, t.set(u, h), (w = (b = s()) == null ? void 0 : b.onGroupMembersChanged) == null || w.call(b, { groupId: u, members: h }));
418
+ updateGroupMemberRole(d, f, m) {
419
+ var C, w;
420
+ const h = t.get(d) ?? [], v = h.findIndex((M) => M.userId === f);
421
+ v < 0 || (h[v] = { ...h[v], role: m }, t.set(d, h), (w = (C = s()) == null ? void 0 : C.onGroupMembersChanged) == null || w.call(C, { groupId: d, members: h }));
416
422
  },
417
- setGroupAnnouncement(u, l) {
418
- var f, h;
419
- n.set(u, l), (h = (f = s()) == null ? void 0 : f.onGroupAnnouncementChanged) == null || h.call(f, { groupId: u, announcement: l });
423
+ setGroupAnnouncement(d, f) {
424
+ var m, h;
425
+ n.set(d, f), (h = (m = s()) == null ? void 0 : m.onGroupAnnouncementChanged) == null || h.call(m, { groupId: d, announcement: f });
420
426
  },
421
- isGroupAdminSynced(u) {
422
- return d.has(u);
427
+ isGroupAdminSynced(d) {
428
+ return u.has(d);
423
429
  },
424
- markGroupAdminSynced(u) {
425
- d.add(u);
430
+ markGroupAdminSynced(d) {
431
+ u.add(d);
426
432
  },
427
- setGroupMuteList(u, l) {
428
- o.set(u, l);
433
+ setGroupMuteList(d, f) {
434
+ o.set(d, f);
429
435
  },
430
- addGroupMuteMembers(u, l) {
431
- const f = o.get(u) ?? [], h = Array.isArray(l) && l.length > 0 && typeof l[0] == "string" ? l : l.map((v) => v.userId);
436
+ addGroupMuteMembers(d, f) {
437
+ const m = o.get(d) ?? [], h = Array.isArray(f) && f.length > 0 && typeof f[0] == "string" ? f : f.map((v) => v.userId);
432
438
  for (const v of h)
433
- f.some((b) => b.userId === v) || f.push({ userId: v });
434
- o.set(u, f);
439
+ m.some((C) => C.userId === v) || m.push({ userId: v });
440
+ o.set(d, m);
435
441
  },
436
- removeGroupMuteMembers(u, l) {
437
- const f = new Set(l);
438
- o.set(u, (o.get(u) ?? []).filter((h) => !f.has(h.userId)));
442
+ removeGroupMuteMembers(d, f) {
443
+ const m = new Set(f);
444
+ o.set(d, (o.get(d) ?? []).filter((h) => !m.has(h.userId)));
439
445
  },
440
- setGroupBlocklist(u, l) {
441
- a.set(u, l);
446
+ setGroupBlocklist(d, f) {
447
+ a.set(d, f);
442
448
  },
443
- addGroupBlocklistMembers(u, l) {
444
- const f = a.get(u) ?? [];
445
- for (const h of l)
446
- f.some((v) => v.userId === h) || f.push({ userId: h });
447
- a.set(u, f);
449
+ addGroupBlocklistMembers(d, f) {
450
+ const m = a.get(d) ?? [];
451
+ for (const h of f)
452
+ m.some((v) => v.userId === h) || m.push({ userId: h });
453
+ a.set(d, m);
448
454
  },
449
- removeGroupBlocklistMembers(u, l) {
450
- const f = new Set(l);
451
- a.set(u, (a.get(u) ?? []).filter((h) => !f.has(h.userId)));
455
+ removeGroupBlocklistMembers(d, f) {
456
+ const m = new Set(f);
457
+ a.set(d, (a.get(d) ?? []).filter((h) => !m.has(h.userId)));
452
458
  },
453
- setGroupAllowlist(u, l) {
454
- r.set(u, l);
459
+ setGroupAllowlist(d, f) {
460
+ r.set(d, f);
455
461
  },
456
- addGroupAllowlistMembers(u, l) {
457
- const f = r.get(u) ?? [];
458
- for (const h of l)
459
- f.some((v) => v.userId === h) || f.push({ userId: h });
460
- r.set(u, f);
462
+ addGroupAllowlistMembers(d, f) {
463
+ const m = r.get(d) ?? [];
464
+ for (const h of f)
465
+ m.some((v) => v.userId === h) || m.push({ userId: h });
466
+ r.set(d, m);
461
467
  },
462
- removeGroupAllowlistMembers(u, l) {
463
- const f = new Set(l);
464
- r.set(u, (r.get(u) ?? []).filter((h) => !f.has(h.userId)));
468
+ removeGroupAllowlistMembers(d, f) {
469
+ const m = new Set(f);
470
+ r.set(d, (r.get(d) ?? []).filter((h) => !m.has(h.userId)));
465
471
  },
466
- setGroupList(u) {
467
- this.setList(u);
472
+ setGroupList(d) {
473
+ this.setList(d);
468
474
  },
469
- getGroupById(u) {
470
- return e.find((l) => l.groupId === u);
475
+ getGroupById(d) {
476
+ return e.find((f) => f.groupId === d);
471
477
  },
472
- incrementMemberCount(u, l) {
473
- const f = this.getGroupById(u);
474
- f && this.updateGroup(u, { memberCount: (f.memberCount ?? 0) + l });
478
+ incrementMemberCount(d, f) {
479
+ const m = this.getGroupById(d);
480
+ m && this.updateGroup(d, { memberCount: (m.memberCount ?? 0) + f });
475
481
  },
476
- decrementMemberCount(u, l) {
477
- const f = this.getGroupById(u);
478
- f && this.updateGroup(u, { memberCount: Math.max(0, (f.memberCount ?? 0) - l) });
482
+ decrementMemberCount(d, f) {
483
+ const m = this.getGroupById(d);
484
+ m && this.updateGroup(d, { memberCount: Math.max(0, (m.memberCount ?? 0) - f) });
479
485
  },
480
- addGroupSharedFile(u, l) {
481
- const f = i.get(u) ?? [];
482
- f.push(l), i.set(u, f);
486
+ addGroupSharedFile(d, f) {
487
+ const m = i.get(d) ?? [];
488
+ m.push(f), i.set(d, m);
483
489
  },
484
- removeGroupSharedFile(u, l) {
485
- i.set(u, (i.get(u) ?? []).filter((f) => f.fileId !== l));
490
+ removeGroupSharedFile(d, f) {
491
+ i.set(d, (i.get(d) ?? []).filter((m) => m.fileId !== f));
486
492
  },
487
- getGroupJoinRequests(u) {
488
- return c.get(u) ?? [];
493
+ getGroupJoinRequests(d) {
494
+ return c.get(d) ?? [];
489
495
  },
490
- setGroupJoinRequests(u, l) {
491
- c.set(u, l);
496
+ setGroupJoinRequests(d, f) {
497
+ c.set(d, f);
492
498
  },
493
- updateGroupJoinRequest(u, l, f) {
494
- const v = (c.get(u) ?? []).find(
495
- (b) => {
499
+ updateGroupJoinRequest(d, f, m) {
500
+ const v = (c.get(d) ?? []).find(
501
+ (C) => {
496
502
  var w;
497
- return b.applicantId === l || ((w = b.applicant) == null ? void 0 : w.userId) === l;
503
+ return C.applicantId === f || ((w = C.applicant) == null ? void 0 : w.userId) === f;
498
504
  }
499
505
  );
500
- v && (v.status = f);
506
+ v && (v.status = m);
501
507
  }
502
508
  };
503
509
  }
504
- function Bt(s) {
510
+ function Yt(s) {
505
511
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
506
512
  let n = !1;
507
513
  function o(i) {
508
514
  return e.get(i) ?? [];
509
515
  }
510
516
  function a(i) {
511
- for (const [c, d] of e) {
512
- const g = d.findIndex((m) => m.msgServerId === i || m.msgLocalId === i);
513
- if (g >= 0)
514
- return { list: d, index: g, conversationId: c };
517
+ for (const [c, u] of e) {
518
+ const l = u.findIndex((g) => g.msgServerId === i || g.msgLocalId === i);
519
+ if (l >= 0)
520
+ return { list: u, index: l, conversationId: c };
515
521
  }
516
522
  return null;
517
523
  }
518
524
  function r(i) {
519
- const c = i, d = e.get(c.conversationId) ?? [], g = d.findIndex(
520
- (m) => m.msgServerId && m.msgServerId === c.msgServerId
525
+ const c = i, u = e.get(c.conversationId) ?? [], l = u.findIndex(
526
+ (g) => g.msgServerId && g.msgServerId === c.msgServerId
521
527
  );
522
- g >= 0 ? d[g] = c : d.push(c), d.sort((m, p) => (m.timestamp ?? 0) - (p.timestamp ?? 0)), e.set(c.conversationId, d);
528
+ l >= 0 ? u[l] = c : u.push(c), u.sort((g, p) => (g.timestamp ?? 0) - (p.timestamp ?? 0)), e.set(c.conversationId, u);
523
529
  }
524
530
  return {
525
531
  getMessages: o,
526
532
  addMessage(i) {
527
- var c, d;
528
- r(i), (d = (c = s()) == null ? void 0 : c.onMessage) == null || d.call(c, i);
533
+ var c, u;
534
+ r(i), (u = (c = s()) == null ? void 0 : c.onMessage) == null || u.call(c, i);
529
535
  },
530
536
  addSendingMessage(i, c) {
531
537
  t.set(i, c);
532
538
  },
533
539
  replaceWithSent(i, c) {
534
- var d, g;
535
- t.delete(i), r(c), (g = (d = s()) == null ? void 0 : d.onMessage) == null || g.call(d, c);
540
+ var u, l;
541
+ t.delete(i), r(c), (l = (u = s()) == null ? void 0 : u.onMessage) == null || l.call(u, c);
536
542
  },
537
543
  updateUploadProgress(i, c) {
538
- const d = t.get(i);
539
- if (!d)
544
+ const u = t.get(i);
545
+ if (!u)
540
546
  return;
541
- const g = a(d.msgLocalId || d.msgServerId || "");
542
- if (g) {
543
- const m = { ...g.list[g.index], progress: c };
544
- g.list[g.index] = m;
547
+ const l = a(u.msgLocalId || u.msgServerId || "");
548
+ if (l) {
549
+ const g = { ...l.list[l.index], progress: c };
550
+ l.list[l.index] = g;
545
551
  }
546
552
  },
547
553
  markFailed(i, c) {
548
- const d = t.get(i);
554
+ const u = t.get(i);
549
555
  t.delete(i);
550
- const g = (d == null ? void 0 : d.msgLocalId) || (d == null ? void 0 : d.msgServerId);
551
- if (!g)
556
+ const l = (u == null ? void 0 : u.msgLocalId) || (u == null ? void 0 : u.msgServerId);
557
+ if (!l)
552
558
  return;
553
- const m = a(g);
554
- if (m) {
555
- const p = { ...m.list[m.index], status: "failed", failReason: c };
556
- m.list[m.index] = p;
559
+ const g = a(l);
560
+ if (g) {
561
+ const p = { ...g.list[g.index], status: "failed", failReason: c };
562
+ g.list[g.index] = p;
557
563
  }
558
564
  },
559
565
  prependMessages(i, c) {
560
- const d = e.get(i) ?? [], g = /* @__PURE__ */ new Map();
566
+ const u = e.get(i) ?? [], l = /* @__PURE__ */ new Map();
561
567
  for (const p of c) {
562
- const u = p;
563
- u.msgServerId && g.set(u.msgServerId, u);
568
+ const d = p;
569
+ d.msgServerId && l.set(d.msgServerId, d);
564
570
  }
565
- for (const p of d)
566
- p.msgServerId && !g.has(p.msgServerId) && g.set(p.msgServerId, p);
567
- const m = Array.from(g.values()).sort(
568
- (p, u) => (p.timestamp ?? 0) - (u.timestamp ?? 0)
571
+ for (const p of u)
572
+ p.msgServerId && !l.has(p.msgServerId) && l.set(p.msgServerId, p);
573
+ const g = Array.from(l.values()).sort(
574
+ (p, d) => (p.timestamp ?? 0) - (d.timestamp ?? 0)
569
575
  );
570
- e.set(i, m);
576
+ e.set(i, g);
571
577
  },
572
578
  updateStatusByServerId(i, c) {
573
- var g, m;
574
- const d = a(i);
575
- d && (d.list[d.index] = { ...d.list[d.index], status: c }, (m = (g = s()) == null ? void 0 : g.onMessageStatusChanged) == null || m.call(g, { messageId: i, status: c }));
579
+ var l, g;
580
+ const u = a(i);
581
+ u && (u.list[u.index] = { ...u.list[u.index], status: c }, (g = (l = s()) == null ? void 0 : l.onMessageStatusChanged) == null || g.call(l, { messageId: i, status: c }));
576
582
  },
577
583
  recallMessage(i, c) {
578
- var m, p;
579
- const d = a(i);
580
- if (!d)
584
+ var g, p;
585
+ const u = a(i);
586
+ if (!u)
581
587
  return;
582
- const g = d.list[d.index];
583
- g.recalled = !0, g.recalledBy = c, (p = (m = s()) == null ? void 0 : m.onMessagesRecalled) == null || p.call(m, {
588
+ const l = u.list[u.index];
589
+ l.recalled = !0, l.recalledBy = c, (p = (g = s()) == null ? void 0 : g.onMessagesRecalled) == null || p.call(g, {
584
590
  messageId: i,
585
- conversationId: d.conversationId,
586
- conversationType: g.conversationType,
591
+ conversationId: u.conversationId,
592
+ conversationType: l.conversationType,
587
593
  operatorId: c
588
594
  });
589
595
  },
590
596
  updateMessage(i, c) {
591
- var m, p;
592
- const d = a(i);
593
- if (!d)
597
+ var g, p;
598
+ const u = a(i);
599
+ if (!u)
594
600
  return;
595
- const g = c;
596
- d.list[d.index] = g, g.modified && ((p = (m = s()) == null ? void 0 : m.onMessageUpdated) == null || p.call(m, g));
601
+ const l = c;
602
+ u.list[u.index] = l, l.modified && ((p = (g = s()) == null ? void 0 : g.onMessageUpdated) == null || p.call(g, l));
597
603
  },
598
604
  setPinnedMessages(i, c) {
599
605
  },
600
606
  setTranslation(i, c) {
601
- const d = a(i);
602
- if (!d)
607
+ const u = a(i);
608
+ if (!u)
603
609
  return;
604
- const g = d.list[d.index];
605
- g.translation = c, g.showTranslation = !0;
610
+ const l = u.list[u.index];
611
+ l.translation = c, l.showTranslation = !0;
606
612
  },
607
613
  setTranslating(i, c) {
608
- const d = a(i);
609
- d && (d.list[d.index] = { ...d.list[d.index], translating: c });
614
+ const u = a(i);
615
+ u && (u.list[u.index] = { ...u.list[u.index], translating: c });
610
616
  },
611
617
  setVoiceText(i, c) {
612
- const d = a(i);
613
- if (!d)
618
+ const u = a(i);
619
+ if (!u)
614
620
  return;
615
- const g = d.list[d.index];
616
- g.voiceText = c, g.showVoiceText = !0;
621
+ const l = u.list[u.index];
622
+ l.voiceText = c, l.showVoiceText = !0;
617
623
  },
618
624
  setVoiceTranscribing(i, c) {
619
- const d = a(i);
620
- d && (d.list[d.index] = { ...d.list[d.index], voiceTranscribing: c });
625
+ const u = a(i);
626
+ u && (u.list[u.index] = { ...u.list[u.index], voiceTranscribing: c });
621
627
  },
622
628
  clearConversationMessages(i) {
623
629
  e.delete(i);
624
630
  },
625
631
  updateMessageById(i, c) {
626
- var p, u, l, f;
627
- const d = a(i);
628
- if (!d)
632
+ var p, d, f, m;
633
+ const u = a(i);
634
+ if (!u)
629
635
  return;
630
- const g = d.list[d.index], m = { ...g, ...c };
631
- d.list[d.index] = m, (c.modified || c.modifiedInfo) && ((u = (p = s()) == null ? void 0 : p.onMessageUpdated) == null || u.call(p, m)), c.status && c.status !== g.status && ((f = (l = s()) == null ? void 0 : l.onMessageStatusChanged) == null || f.call(l, {
636
+ const l = u.list[u.index], g = { ...l, ...c };
637
+ u.list[u.index] = g, (c.modified || c.modifiedInfo) && ((d = (p = s()) == null ? void 0 : p.onMessageUpdated) == null || d.call(p, g)), c.status && c.status !== l.status && ((m = (f = s()) == null ? void 0 : f.onMessageStatusChanged) == null || m.call(f, {
632
638
  messageId: i,
633
639
  status: c.status
634
640
  }));
635
641
  },
636
642
  replaceMessageById(i, c) {
637
- var m, p;
638
- const d = a(i);
639
- if (!d)
643
+ var g, p;
644
+ const u = a(i);
645
+ if (!u)
640
646
  return;
641
- const g = c;
642
- d.list[d.index] = g, (p = (m = s()) == null ? void 0 : m.onMessageUpdated) == null || p.call(m, g);
647
+ const l = c;
648
+ u.list[u.index] = l, (p = (g = s()) == null ? void 0 : g.onMessageUpdated) == null || p.call(g, l);
643
649
  },
644
650
  addAtMeMessage(i, c) {
645
- var d, g;
646
- (g = (d = s()) == null ? void 0 : d.onAtMe) == null || g.call(d, { conversationId: i, messageId: c });
651
+ var u, l;
652
+ (l = (u = s()) == null ? void 0 : u.onAtMe) == null || l.call(u, { conversationId: i, messageId: c });
647
653
  },
648
654
  updateMessageStatus(i, c) {
649
- var g, m;
650
- const d = a(i);
651
- d && (d.list[d.index] = { ...d.list[d.index], status: c }, (m = (g = s()) == null ? void 0 : g.onMessageStatusChanged) == null || m.call(g, { messageId: i, status: c }));
655
+ var l, g;
656
+ const u = a(i);
657
+ u && (u.list[u.index] = { ...u.list[u.index], status: c }, (g = (l = s()) == null ? void 0 : l.onMessageStatusChanged) == null || g.call(l, { messageId: i, status: c }));
652
658
  },
653
659
  setMessagePinned(i, c) {
654
- const d = a(i);
655
- if (!d)
660
+ const u = a(i);
661
+ if (!u)
656
662
  return;
657
- const g = d.list[d.index];
658
- g.pinned = !0, g.pinTime = c.pinTime, g.pinOperatorId = c.operatorId;
663
+ const l = u.list[u.index];
664
+ l.pinned = !0, l.pinTime = c.pinTime, l.pinOperatorId = c.operatorId;
659
665
  },
660
666
  setMessageUnpinned(i) {
661
667
  const c = a(i);
662
668
  if (!c)
663
669
  return;
664
- const d = c.list[c.index];
665
- d.pinned = !1;
670
+ const u = c.list[c.index];
671
+ u.pinned = !1;
666
672
  },
667
673
  deleteMessages(i) {
668
- var g, m;
669
- const c = new Set(i), d = /* @__PURE__ */ new Map();
670
- for (const [p, u] of e) {
671
- const l = [];
672
- for (const f of u) {
673
- const h = f.msgServerId || f.msgLocalId;
674
+ var l, g;
675
+ const c = new Set(i), u = /* @__PURE__ */ new Map();
676
+ for (const [p, d] of e) {
677
+ const f = [];
678
+ for (const m of d) {
679
+ const h = m.msgServerId || m.msgLocalId;
674
680
  if (h && c.has(h)) {
675
- const v = d.get(p) ?? [];
676
- v.push(h), d.set(p, v);
681
+ const v = u.get(p) ?? [];
682
+ v.push(h), u.set(p, v);
677
683
  } else
678
- l.push(f);
684
+ f.push(m);
679
685
  }
680
- e.set(p, l);
686
+ e.set(p, f);
681
687
  }
682
- for (const [p, u] of d)
683
- (m = (g = s()) == null ? void 0 : g.onMessagesDeleted) == null || m.call(g, { messageIds: u, conversationId: p });
688
+ for (const [p, d] of u)
689
+ (g = (l = s()) == null ? void 0 : l.onMessagesDeleted) == null || g.call(l, { messageIds: d, conversationId: p });
684
690
  },
685
691
  setSyncingMessages(i) {
686
- var c, d;
687
- n !== i && (n = i, (d = (c = s()) == null ? void 0 : c.onSyncStatus) == null || d.call(c, {
692
+ var c, u;
693
+ n !== i && (n = i, (u = (c = s()) == null ? void 0 : c.onSyncStatus) == null || u.call(c, {
688
694
  type: "message",
689
695
  status: i ? "syncing" : "success"
690
696
  }));
691
697
  }
692
698
  };
693
699
  }
694
- function Ft(s) {
700
+ function Xt(s) {
695
701
  let e = [];
696
702
  const t = /* @__PURE__ */ new Set();
697
703
  return {
@@ -708,13 +714,13 @@ function Ft(s) {
708
714
  }
709
715
  };
710
716
  }
711
- function Ht(s) {
717
+ function Zt(s) {
712
718
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
713
719
  let a = !1;
714
720
  const r = /* @__PURE__ */ new Map();
715
721
  function i() {
716
- var c, d;
717
- (d = (c = s()) == null ? void 0 : c.onUserInfoChanged) == null || d.call(c, Array.from(e.values()));
722
+ var c, u;
723
+ (u = (c = s()) == null ? void 0 : c.onUserInfoChanged) == null || u.call(c, Array.from(e.values()));
718
724
  }
719
725
  return {
720
726
  getUserInfo(c) {
@@ -724,48 +730,56 @@ function Ht(s) {
724
730
  e.set(c.userId, c), i();
725
731
  },
726
732
  setUserInfos(c) {
727
- for (const d of c)
728
- e.set(d.userId, d);
733
+ for (const u of c)
734
+ e.set(u.userId, u);
729
735
  i();
730
736
  },
731
- areAttributesFetched(c, d) {
732
- const g = r.get(c);
733
- return g ? d.every((m) => g.has(m)) : !1;
737
+ areAttributesFetched(c, u) {
738
+ const l = r.get(c);
739
+ return l ? u.every((g) => l.has(g)) : !1;
734
740
  },
735
- markFetchedAttributes(c, d) {
736
- for (const g of c) {
737
- const m = r.get(g) ?? /* @__PURE__ */ new Set();
738
- for (const p of d)
739
- m.add(p);
740
- r.set(g, m);
741
+ markFetchedAttributes(c, u) {
742
+ for (const l of c) {
743
+ const g = r.get(l) ?? /* @__PURE__ */ new Set();
744
+ for (const p of u)
745
+ g.add(p);
746
+ r.set(l, g);
741
747
  }
742
748
  },
743
749
  markLoading(c) {
744
- for (const d of c)
745
- t.add(d);
750
+ for (const u of c)
751
+ t.add(u);
746
752
  },
747
753
  markLoaded(c) {
748
- for (const d of c)
749
- t.delete(d);
754
+ for (const u of c)
755
+ t.delete(u);
750
756
  },
751
757
  markFetchFailed(c) {
752
- for (const d of c)
753
- n.add(d);
758
+ for (const u of c)
759
+ n.add(u);
754
760
  },
755
761
  isFetchFailed(c) {
756
762
  return n.has(c);
757
763
  },
764
+ clearFetchFailed(c) {
765
+ if (!c) {
766
+ n.clear();
767
+ return;
768
+ }
769
+ for (const u of c)
770
+ n.delete(u);
771
+ },
758
772
  markSubscribed(c) {
759
- for (const d of c)
760
- o.add(d);
773
+ for (const u of c)
774
+ o.add(u);
761
775
  },
762
776
  markUnsubscribed(c) {
763
- for (const d of c)
764
- o.delete(d);
777
+ for (const u of c)
778
+ o.delete(u);
765
779
  },
766
780
  markSubscribeFailed(c) {
767
- for (const d of c)
768
- n.add(d);
781
+ for (const u of c)
782
+ n.add(u);
769
783
  },
770
784
  isSubscribeFailed(c) {
771
785
  return n.has(c);
@@ -784,18 +798,18 @@ function Ht(s) {
784
798
  }
785
799
  };
786
800
  }
787
- function Kt(s, e) {
801
+ function en(s, e) {
788
802
  return {
789
- client: kt(s, e),
790
- message: Bt(e),
791
- conversation: xt(e),
792
- contact: Ot(e),
793
- group: Pt(e),
794
- presence: Ft(e),
795
- userInfo: Ht(e)
803
+ client: Jt(s, e),
804
+ message: Yt(e),
805
+ conversation: Qt(e),
806
+ contact: $t(e),
807
+ group: zt(e),
808
+ presence: Xt(e),
809
+ userInfo: Zt(e)
796
810
  };
797
811
  }
798
- function jt() {
812
+ function tn() {
799
813
  return {
800
814
  enableContact: !0,
801
815
  enableBlocklist: !0,
@@ -814,11 +828,11 @@ function jt() {
814
828
  filterBlockedContacts: !0
815
829
  };
816
830
  }
817
- function Vt(s) {
831
+ function nn(s) {
818
832
  if (s != null && s.fetchUserInfos)
819
833
  return { fetchUserInfos: s.fetchUserInfos };
820
834
  }
821
- function qt(s) {
835
+ function sn(s) {
822
836
  const e = s;
823
837
  return {
824
838
  // 经 domain.fetchContacts 读取:注入 contact.fetchContacts 时由 domain 委托覆盖
@@ -841,13 +855,13 @@ function qt(s) {
841
855
  }
842
856
  };
843
857
  }
844
- function Wt(s) {
858
+ function rn(s) {
845
859
  const e = s;
846
860
  return {
847
861
  fetchConversations: async () => ({ list: e.syncLocal(), cursor: void 0, hasMore: !1 })
848
862
  };
849
863
  }
850
- function Jt(s) {
864
+ function on(s) {
851
865
  const e = s;
852
866
  return {
853
867
  // 经 domain.fetchGroups 读取:注入 group.fetchGroups 时由 domain 委托覆盖
@@ -914,7 +928,7 @@ function Jt(s) {
914
928
  }
915
929
  };
916
930
  }
917
- function $t(s) {
931
+ function an(s) {
918
932
  const e = s.message, t = s.conversation;
919
933
  return {
920
934
  loadMessages: async (n, o, a, r) => {
@@ -933,7 +947,7 @@ function $t(s) {
933
947
  // 契约的 needReadReceipt 未透传:domain sendLocation 无此参数(SDK 不支持位置消息回执)
934
948
  sendLocation: (n, o, a, r, i, c) => e.sendLocation(n, o, a, r, i, c),
935
949
  sendCustom: (n, o, a, r, i) => {
936
- const c = r ? Object.fromEntries(Object.entries(r).map(([d, g]) => [d, String(g)])) : void 0;
950
+ const c = r ? Object.fromEntries(Object.entries(r).map(([u, l]) => [u, String(l)])) : void 0;
937
951
  return e.sendCustom(n, o, a, c, i);
938
952
  },
939
953
  sendCmd: (n, o, a, r) => e.sendCmd(n, o, a, r),
@@ -953,7 +967,7 @@ function $t(s) {
953
967
  }
954
968
  };
955
969
  }
956
- function Qt(s) {
970
+ function cn(s) {
957
971
  const e = s;
958
972
  return {
959
973
  subscribe: async (t, n) => {
@@ -968,8 +982,9 @@ function Qt(s) {
968
982
  }
969
983
  };
970
984
  }
971
- function zt(s) {
985
+ function un(s) {
972
986
  return {
987
+ readCachedUserInfos: (e) => s.readCachedUserInfos(e),
973
988
  fetchUserInfos: async (e, t) => s.fetchUserInfos(e, t),
974
989
  updateOwnInfo: async (e) => {
975
990
  await s.updateOwnInfo(e);
@@ -986,7 +1001,41 @@ function zt(s) {
986
1001
  getSubscribedUsers: async () => s.getSubscribedUsers()
987
1002
  };
988
1003
  }
989
- const Yt = T("UIKit:MessageAdapter"), Ue = {
1004
+ function dn(s) {
1005
+ return Object.fromEntries(
1006
+ Object.entries({
1007
+ userId: s.userId,
1008
+ nickname: s.nickname,
1009
+ avatarUrl: s.avatarUrl,
1010
+ mail: s.mail,
1011
+ phone: s.phone,
1012
+ gender: s.gender,
1013
+ sign: s.sign,
1014
+ birth: s.birth,
1015
+ ext: s.ext
1016
+ }).filter(([, e]) => e !== void 0)
1017
+ );
1018
+ }
1019
+ function ln(s, e) {
1020
+ var t, n;
1021
+ try {
1022
+ const o = s.getCacheManager();
1023
+ if (!o)
1024
+ return [];
1025
+ const a = [], r = /* @__PURE__ */ new Map();
1026
+ for (const c of e) {
1027
+ const u = (t = o.getRuntimeUserInfo) == null ? void 0 : t.call(o, c, !1);
1028
+ u ? r.set(c, { ...u, userId: c }) : a.push(c);
1029
+ }
1030
+ const i = new Map(
1031
+ (((n = o.getUserInfoSummaries) == null ? void 0 : n.call(o, a, !1)) ?? []).map((c) => [c.userId, c])
1032
+ );
1033
+ return e.map((c) => r.get(c) ?? i.get(c)).filter((c) => !!c).map(dn);
1034
+ } catch {
1035
+ return [];
1036
+ }
1037
+ }
1038
+ const fn = T("UIKit:MessageAdapter"), Be = {
990
1039
  image: "[图片]",
991
1040
  sticker: "[表情]",
992
1041
  voice: "[语音]",
@@ -996,11 +1045,11 @@ const Yt = T("UIKit:MessageAdapter"), Ue = {
996
1045
  combine: "[聊天记录]",
997
1046
  multiBody: "[复合消息]",
998
1047
  multiBodyMore: "...",
999
- custom: gt,
1048
+ custom: St,
1000
1049
  customFallback: "[自定义]",
1001
1050
  unknown: ""
1002
1051
  };
1003
- function ke(s) {
1052
+ function je(s) {
1004
1053
  if (s.event && typeof s.event == "string")
1005
1054
  return s.event;
1006
1055
  const e = s.params;
@@ -1011,35 +1060,35 @@ function ke(s) {
1011
1060
  }
1012
1061
  return "";
1013
1062
  }
1014
- function P(s, e) {
1015
- e || Yt.warn("[toUiMessage] currentUserId is empty, isSelf may be inaccurate", {
1063
+ function H(s, e) {
1064
+ e || fn.warn("[toUiMessage] currentUserId is empty, isSelf may be inaccurate", {
1016
1065
  from: s.from,
1017
1066
  conversationId: s.conversationId,
1018
1067
  type: s.type
1019
1068
  });
1020
- const t = E(s.from) === E(e), n = {
1069
+ const t = G(s.from) === G(e), n = {
1021
1070
  ...s,
1022
1071
  isSelf: t,
1023
1072
  localId: s.msgLocalId,
1024
- status: t && s.isPeerRead === !0 ? O.READ : s.sendStatus ?? O.SENT
1073
+ status: t && s.isPeerRead === !0 ? k.READ : s.sendStatus ?? k.SENT
1025
1074
  };
1026
- return Ye(n.body) && n.body.messageList ? n.body = {
1075
+ return at(n.body) && n.body.messageList ? n.body = {
1027
1076
  ...n.body,
1028
- messageList: Ne([...n.body.messageList])
1029
- } : yt(n.body) && (n.body = Ne([...n.body])), n;
1077
+ messageList: qe([...n.body.messageList])
1078
+ } : _t(n.body) && (n.body = qe([...n.body])), n;
1030
1079
  }
1031
- function Qn(s, e) {
1032
- return s.map((t) => P(t, e));
1080
+ function vs(s, e) {
1081
+ return s.map((t) => H(t, e));
1033
1082
  }
1034
- function Oe(s) {
1083
+ function Ve(s) {
1035
1084
  return {
1036
1085
  ...s,
1037
1086
  isSelf: !1,
1038
1087
  localId: s.msgLocalId,
1039
- status: s.sendStatus ?? O.SENT
1088
+ status: s.sendStatus ?? k.SENT
1040
1089
  };
1041
1090
  }
1042
- function xe(s, e) {
1091
+ function We(s, e) {
1043
1092
  const t = s.from || "";
1044
1093
  return {
1045
1094
  ...s,
@@ -1049,74 +1098,74 @@ function xe(s, e) {
1049
1098
  to: s.to || "",
1050
1099
  sender: s.sender || { userId: t },
1051
1100
  conversationId: s.conversationId || (e == null ? void 0 : e.conversationId) || "",
1052
- conversationType: s.conversationType || (e == null ? void 0 : e.conversationType) || M.SINGLECHAT,
1101
+ conversationType: s.conversationType || (e == null ? void 0 : e.conversationType) || I.SINGLECHAT,
1053
1102
  type: s.type || "unknown",
1054
- sendStatus: s.sendStatus ?? O.SENT,
1103
+ sendStatus: s.sendStatus ?? k.SENT,
1055
1104
  ext: s.ext ?? {},
1056
1105
  timestamp: s.timestamp ?? 0,
1057
1106
  body: s.body || {},
1058
1107
  isSelf: !1,
1059
1108
  localId: s.msgLocalId || s.msgServerId,
1060
- status: s.sendStatus ?? O.SENT
1109
+ status: s.sendStatus ?? k.SENT
1061
1110
  };
1062
1111
  }
1063
- function zn(s, e, t) {
1112
+ function Is(s, e, t) {
1064
1113
  var r;
1065
1114
  if (!s)
1066
1115
  return "";
1067
- const n = t == null ? void 0 : t(Oe(s));
1116
+ const n = t == null ? void 0 : t(Ve(s));
1068
1117
  if (n !== void 0)
1069
1118
  return n;
1070
- const o = Je({ ...Ue, ...e }), { body: a } = s;
1071
- return s.type === C.MULTI_BODY ? $e(Oe(s), o) : ft(a) ? a.content || "" : mt(a) ? ((r = s.ext) == null ? void 0 : r[Qe.IS_STICKER]) === !0 ? o.sticker : o.image : ze(a) ? o.voice : pt(a) ? o.video : ht(a) ? a.filename || o.file : vt(a) ? o.location : It(a) ? o.custom[a.event || ""] || o.customFallback : Mt(a) ? "[命令]" : Ye(a) ? a.summary || o.combine : "";
1119
+ const o = st({ ...Be, ...e }), { body: a } = s;
1120
+ return s.type === b.MULTI_BODY ? rt(Ve(s), o) : At(a) ? a.content || "" : Et(a) ? ((r = s.ext) == null ? void 0 : r[ot.IS_STICKER]) === !0 ? o.sticker : o.image : it(a) ? o.voice : Gt(a) ? o.video : Tt(a) ? a.filename || o.file : Ut(a) ? o.location : Rt(a) ? o.custom[a.event || ""] || o.customFallback : Lt(a) ? "[命令]" : at(a) ? a.summary || o.combine : "";
1072
1121
  }
1073
- function Xt(s, e, t, n) {
1122
+ function gn(s, e, t, n) {
1074
1123
  var i;
1075
1124
  if (!s)
1076
1125
  return "";
1077
- const o = t == null ? void 0 : t(xe(s, n));
1126
+ const o = t == null ? void 0 : t(We(s, n));
1078
1127
  if (o !== void 0)
1079
1128
  return o;
1080
- const a = Je({ ...Ue, ...e }), r = Array.isArray(s.body) ? {} : s.body || {};
1129
+ const a = st({ ...Be, ...e }), r = Array.isArray(s.body) ? {} : s.body || {};
1081
1130
  switch (s.type) {
1082
- case C.MULTI_BODY:
1083
- return $e(xe(s, n), a);
1084
- case C.TEXT:
1131
+ case b.MULTI_BODY:
1132
+ return rt(We(s, n), a);
1133
+ case b.TEXT:
1085
1134
  return r.content || r.summary || "";
1086
- case C.IMAGE:
1087
- return ((i = s.ext) == null ? void 0 : i[Qe.IS_STICKER]) === !0 ? a.sticker : a.image;
1088
- case C.VOICE:
1135
+ case b.IMAGE:
1136
+ return ((i = s.ext) == null ? void 0 : i[ot.IS_STICKER]) === !0 ? a.sticker : a.image;
1137
+ case b.VOICE:
1089
1138
  return a.voice;
1090
- case C.VIDEO:
1139
+ case b.VIDEO:
1091
1140
  return a.video;
1092
- case C.FILE:
1141
+ case b.FILE:
1093
1142
  return r.filename || a.file;
1094
- case C.LOCATION:
1143
+ case b.LOCATION:
1095
1144
  return a.location;
1096
- case C.CUSTOM: {
1097
- const c = ke(r);
1145
+ case b.CUSTOM: {
1146
+ const c = je(r);
1098
1147
  return a.custom[c] || a.customFallback;
1099
1148
  }
1100
- case C.CMD:
1149
+ case b.CMD:
1101
1150
  return "[命令]";
1102
- case C.COMBINE:
1151
+ case b.COMBINE:
1103
1152
  return r.summary || a.combine;
1104
1153
  default: {
1105
- const c = ke(r);
1154
+ const c = je(r);
1106
1155
  return c ? a.custom[c] || a.customFallback : r.content || r.summary || r.msg || "";
1107
1156
  }
1108
1157
  }
1109
1158
  }
1110
- function Yn(s, e, t) {
1159
+ function Ms(s, e, t) {
1111
1160
  return s.conversationId === e && s.conversationType === t;
1112
1161
  }
1113
- function Xn(s, e) {
1114
- return s.conversationType === M.GROUPCHAT || E(s.from) === E(e) ? s.to : s.from;
1162
+ function ys(s, e) {
1163
+ return s.conversationType === I.GROUPCHAT || G(s.from) === G(e) ? s.to : s.from;
1115
1164
  }
1116
- function U(s) {
1117
- return Ve(s) ? s.toJSON() : s;
1165
+ function L(s) {
1166
+ return et(s) ? s.toJSON() : s;
1118
1167
  }
1119
- const Zt = {
1168
+ const mn = {
1120
1169
  // 连接 / 网络
1121
1170
  1: "error.unknown",
1122
1171
  2: "error.network",
@@ -1203,28 +1252,28 @@ const Zt = {
1203
1252
  1600: "error.userInfoSubscriptionLimitExceeded",
1204
1253
  1601: "error.userInfoSubscriptionTargetLimitExceeded"
1205
1254
  };
1206
- function en(s) {
1207
- return Ve(s) ? Zt[s.code] ?? null : null;
1255
+ function pn(s) {
1256
+ return et(s) ? mn[s.code] ?? null : null;
1208
1257
  }
1209
- function tn(s) {
1258
+ function hn(s) {
1210
1259
  return s instanceof Error ? s.message : typeof s == "string" ? s : s && typeof s == "object" && "reason" in s && typeof s.reason == "string" ? s.reason : String(s);
1211
1260
  }
1212
- function nn(s) {
1261
+ function vn(s) {
1213
1262
  const e = s.toLowerCase();
1214
1263
  return e.includes("not connected") || e.includes("disconnected") || e.includes("connection is closed") || e.includes("chatclient is not connected") ? "error.notConnected" : e.includes("network") || e.includes("net::err") || e.includes("failed to fetch") || e.includes("network request failed") ? "error.network" : e.includes("timeout") || e.includes("timed out") ? "error.timeout" : "error.unknown";
1215
1264
  }
1216
- function Zn(s, e, t) {
1217
- const n = en(s);
1265
+ function Cs(s, e, t) {
1266
+ const n = pn(s);
1218
1267
  if (n) {
1219
1268
  const r = t(n);
1220
1269
  if (r && r !== n)
1221
1270
  return r;
1222
1271
  }
1223
- const o = tn(s), a = nn(o);
1272
+ const o = hn(s), a = vn(o);
1224
1273
  return a !== "error.unknown" ? t(a) || t(e) || o : t(n || e) || o || "";
1225
1274
  }
1226
- const he = T("Combine"), ve = T("History"), k = T("MessageDomain"), sn = 150;
1227
- function rn(s) {
1275
+ const Ce = T("Combine"), be = T("History"), N = T("MessageDomain"), In = 150;
1276
+ function Mn(s) {
1228
1277
  return new Promise((e) => {
1229
1278
  if (typeof document > "u" || typeof URL.createObjectURL != "function") {
1230
1279
  e(void 0);
@@ -1242,59 +1291,59 @@ function rn(s) {
1242
1291
  }), n.addEventListener("error", () => a(void 0)), setTimeout(() => a(void 0), 5e3);
1243
1292
  });
1244
1293
  }
1245
- const j = /* @__PURE__ */ new Set(), on = 5e3;
1246
- function an(s) {
1294
+ const V = /* @__PURE__ */ new Set(), yn = 5e3;
1295
+ function Cn(s) {
1247
1296
  for (const e of s)
1248
- if (j.add(e), j.size > on) {
1249
- const t = j.values().next().value;
1250
- t !== void 0 && j.delete(t);
1297
+ if (V.add(e), V.size > yn) {
1298
+ const t = V.values().next().value;
1299
+ t !== void 0 && V.delete(t);
1251
1300
  }
1252
1301
  }
1253
- function se(s) {
1254
- Promise.resolve().then(s).catch((e) => k.warn("persistence 钩子执行失败(已忽略):", e));
1302
+ function oe(s) {
1303
+ Promise.resolve().then(s).catch((e) => N.warn("persistence 钩子执行失败(已忽略):", e));
1255
1304
  }
1256
- function cn(s, e) {
1257
- const t = E(s.from) === E(e);
1305
+ function bn(s, e) {
1306
+ const t = G(s.from) === G(e);
1258
1307
  return {
1259
1308
  ...s,
1260
1309
  isSelf: t,
1261
1310
  localId: s.msgLocalId,
1262
- status: t && s.isPeerRead === !0 ? O.READ : s.sendStatus ?? O.SENT
1311
+ status: t && s.isPeerRead === !0 ? k.READ : s.sendStatus ?? k.SENT
1263
1312
  };
1264
1313
  }
1265
- function un(s, e) {
1314
+ function wn(s, e) {
1266
1315
  switch (e.type) {
1267
- case C.TEXT: {
1316
+ case b.TEXT: {
1268
1317
  const { type: t, ...n } = e;
1269
1318
  return s.createTextMessageBody(n);
1270
1319
  }
1271
- case C.IMAGE: {
1320
+ case b.IMAGE: {
1272
1321
  const { type: t, ...n } = e;
1273
1322
  return s.createImageMessageBody(n);
1274
1323
  }
1275
- case C.FILE: {
1324
+ case b.FILE: {
1276
1325
  const { type: t, ...n } = e;
1277
1326
  return s.createFileMessageBody(n);
1278
1327
  }
1279
- case C.VOICE: {
1328
+ case b.VOICE: {
1280
1329
  const { type: t, ...n } = e;
1281
1330
  return s.createVoiceMessageBody(n);
1282
1331
  }
1283
- case C.VIDEO: {
1332
+ case b.VIDEO: {
1284
1333
  const { type: t, ...n } = e;
1285
1334
  return s.createVideoMessageBody(n);
1286
1335
  }
1287
- case C.LOCATION: {
1336
+ case b.LOCATION: {
1288
1337
  const { type: t, ...n } = e;
1289
1338
  return s.createLocationMessageBody(n);
1290
1339
  }
1291
- case C.CUSTOM: {
1340
+ case b.CUSTOM: {
1292
1341
  const { type: t, ...n } = e;
1293
1342
  return s.createCustomMessageBody(n);
1294
1343
  }
1295
1344
  }
1296
1345
  }
1297
- class dn {
1346
+ class Sn {
1298
1347
  constructor(e, t, n = {}) {
1299
1348
  this.client = e, this.store = t, this.options = n, this.failedMultiBodyMessages = /* @__PURE__ */ new Map();
1300
1349
  }
@@ -1342,7 +1391,7 @@ class dn {
1342
1391
  return this._send(i);
1343
1392
  }
1344
1393
  async sendVideo(e, t, n, o, a, r) {
1345
- const i = typeof n == "string" ? void 0 : await rn(n), c = this.client.chatManager.createVideoMessage({
1394
+ const i = typeof n == "string" ? void 0 : await Mn(n), c = this.client.chatManager.createVideoMessage({
1346
1395
  conversationId: e,
1347
1396
  conversationType: t,
1348
1397
  duration: o,
@@ -1386,7 +1435,7 @@ class dn {
1386
1435
  return this._send(a);
1387
1436
  }
1388
1437
  async sendCombine(e, t, n, o, a, r, i) {
1389
- const c = performance.now(), d = this.client.chatManager.createCombineMessage({
1438
+ const c = performance.now(), u = this.client.chatManager.createCombineMessage({
1390
1439
  conversationId: e,
1391
1440
  conversationType: t,
1392
1441
  title: n,
@@ -1395,13 +1444,13 @@ class dn {
1395
1444
  messageList: r,
1396
1445
  ext: i
1397
1446
  });
1398
- return he.info("createCombineMessage done", {
1447
+ return Ce.info("createCombineMessage done", {
1399
1448
  items: r.length,
1400
1449
  elapsedMs: Math.round(performance.now() - c)
1401
- }), this._send(d);
1450
+ }), this._send(u);
1402
1451
  }
1403
1452
  async sendMultiBody(e, t, n, o, a) {
1404
- const r = n.map((c) => un(this.client.chatManager, c)), i = this.client.chatManager.createMultiBodyMessage({
1453
+ const r = n.map((c) => wn(this.client.chatManager, c)), i = this.client.chatManager.createMultiBodyMessage({
1405
1454
  conversationId: e,
1406
1455
  conversationType: t,
1407
1456
  bodies: r,
@@ -1426,7 +1475,7 @@ class dn {
1426
1475
  this.failedMultiBodyMessages.clear();
1427
1476
  }
1428
1477
  async downloadMultiBodyAttachments(e) {
1429
- if (e.type !== C.MULTI_BODY)
1478
+ if (e.type !== b.MULTI_BODY)
1430
1479
  throw new Error("MULTI_BODY_ATTACHMENT_UNSUPPORTED");
1431
1480
  const t = await this.client.chatManager.downloadAttachment({ message: e });
1432
1481
  return Array.isArray(t) ? t : [t];
@@ -1434,10 +1483,10 @@ class dn {
1434
1483
  /** 通用发送流程 */
1435
1484
  async _send(e) {
1436
1485
  var i;
1437
- const t = e.msgLocalId, n = e.type === C.COMBINE;
1438
- if (e.type === C.CMD)
1486
+ const t = e.msgLocalId, n = e.type === b.COMBINE;
1487
+ if (e.type === b.CMD)
1439
1488
  return this.client.chatManager.sendMessage(e);
1440
- e.requireGroupAck && k.info("[GroupAck] 发送消息携带 needReadReceipt", {
1489
+ e.requireGroupAck && N.info("[GroupAck] 发送消息携带 needReadReceipt", {
1441
1490
  conversationId: e.conversationId,
1442
1491
  conversationType: e.conversationType,
1443
1492
  msgLocalId: e.msgLocalId
@@ -1446,38 +1495,38 @@ class dn {
1446
1495
  const r = performance.now();
1447
1496
  try {
1448
1497
  const c = await this.client.chatManager.sendMessage(e, {
1449
- onFileUploadProgress: (m) => {
1498
+ onFileUploadProgress: (g) => {
1450
1499
  o += 1;
1451
- const p = m.percent ?? 0, u = performance.now();
1452
- p < 100 && u - a < sn || (a = u, this.store.updateUploadProgress(t, p));
1500
+ const p = g.percent ?? 0, d = performance.now();
1501
+ p < 100 && d - a < In || (a = d, this.store.updateUploadProgress(t, p));
1453
1502
  }
1454
1503
  });
1455
- n && he.info("sendMessage done", {
1504
+ n && Ce.info("sendMessage done", {
1456
1505
  elapsedMs: Math.round(performance.now() - r),
1457
1506
  progressEvents: o
1458
1507
  });
1459
- const d = P(c, this.currentUserId);
1460
- this.store.replaceWithSent(t, d);
1461
- const g = (i = this.options.persistence) == null ? void 0 : i.saveMessage;
1462
- return g && se(() => g(we(c))), c;
1508
+ const u = H(c, this.currentUserId);
1509
+ this.store.replaceWithSent(t, u);
1510
+ const l = (i = this.options.persistence) == null ? void 0 : i.saveMessage;
1511
+ return l && oe(() => l(_e(c))), c;
1463
1512
  } catch (c) {
1464
- n && he.warn("sendMessage failed", {
1513
+ n && Ce.warn("sendMessage failed", {
1465
1514
  elapsedMs: Math.round(performance.now() - r),
1466
1515
  progressEvents: o,
1467
1516
  error: c instanceof Error ? c.message : String(c)
1468
1517
  });
1469
- const d = c instanceof Error ? c.message : String(c);
1470
- throw this.store.markFailed(t, d), c;
1518
+ const u = c instanceof Error ? c.message : String(c);
1519
+ throw this.store.markFailed(t, u), c;
1471
1520
  }
1472
1521
  }
1473
1522
  // ===== 历史消息 =====
1474
1523
  async fetchHistory(e, t, n, o = 20) {
1475
- var g, m;
1476
- const a = (g = this.options.messageRepository) == null ? void 0 : g.loadMessages;
1524
+ var l, g;
1525
+ const a = (l = this.options.messageRepository) == null ? void 0 : l.loadMessages;
1477
1526
  if (a) {
1478
- const p = await a(e, t, n, o), u = p.list.filter((l) => l.type !== C.CMD).map((l) => cn(l, this.currentUserId));
1479
- return this.store.prependMessages(e, u), t === M.GROUPCHAT && this.fillGroupReadCounts(u, e), {
1480
- list: u,
1527
+ const p = await a(e, t, n, o), d = p.list.filter((f) => f.type !== b.CMD).map((f) => bn(f, this.currentUserId));
1528
+ return this.store.prependMessages(e, d), t === I.GROUPCHAT && this.fillGroupReadCounts(d, e), {
1529
+ list: d,
1481
1530
  cursor: p.cursor,
1482
1531
  hasMore: p.hasMore
1483
1532
  };
@@ -1489,7 +1538,7 @@ class dn {
1489
1538
  cursor: n,
1490
1539
  searchDirection: "up"
1491
1540
  });
1492
- ve.info("fetchHistory response", {
1541
+ be.info("fetchHistory response", {
1493
1542
  conversationId: e,
1494
1543
  conversationType: t,
1495
1544
  cursor: n,
@@ -1499,10 +1548,10 @@ class dn {
1499
1548
  hasMore: r.hasMore,
1500
1549
  items: r.items.map((p) => `${p.msgServerId || p.msgLocalId}|${p.type}|${p.from}->${p.to}|${p.timestamp}`)
1501
1550
  });
1502
- const i = r.items.filter((p) => p.type !== C.CMD), c = i.map((p) => P(p, this.currentUserId));
1551
+ const i = r.items.filter((p) => p.type !== b.CMD), c = i.map((p) => H(p, this.currentUserId));
1503
1552
  this.store.prependMessages(e, c);
1504
- const d = (m = this.options.persistence) == null ? void 0 : m.saveMessages;
1505
- return d && i.length > 0 && se(() => d(i.map((p) => we(p)))), t === M.GROUPCHAT && this.fillGroupReadCounts(c, e), {
1553
+ const u = (g = this.options.persistence) == null ? void 0 : g.saveMessages;
1554
+ return u && i.length > 0 && oe(() => u(i.map((p) => _e(p)))), t === I.GROUPCHAT && this.fillGroupReadCounts(c, e), {
1506
1555
  list: c,
1507
1556
  cursor: r.cursor,
1508
1557
  hasMore: r.hasMore
@@ -1519,7 +1568,7 @@ class dn {
1519
1568
  */
1520
1569
  async fillGroupReadCounts(e, t) {
1521
1570
  const n = e.filter((r) => r.isSelf && !(r.groupReadCount ?? 0)), o = n.map((r) => r.msgServerId).filter((r) => !!r);
1522
- if (ve.info("fillGroupReadCounts scan", {
1571
+ if (be.info("fillGroupReadCounts scan", {
1523
1572
  groupId: t,
1524
1573
  total: e.length,
1525
1574
  selfMissingCount: n.length,
@@ -1534,11 +1583,11 @@ class dn {
1534
1583
  groupId: t,
1535
1584
  messageIds: i
1536
1585
  });
1537
- ve.info("fillGroupReadCounts result", { groupId: t, batch: i, receipts: c });
1538
- for (const d of c)
1539
- d.count > 0 && this.store.updateMessageById(d.messageId, { groupReadCount: d.count });
1586
+ be.info("fillGroupReadCounts result", { groupId: t, batch: i, receipts: c });
1587
+ for (const u of c)
1588
+ u.count > 0 && this.store.updateMessageById(u.messageId, { groupReadCount: u.count });
1540
1589
  } catch (c) {
1541
- k.warn("[MessageDomain.fillGroupReadCounts] failed:", i, U(c));
1590
+ N.warn("[MessageDomain.fillGroupReadCounts] failed:", i, L(c));
1542
1591
  }
1543
1592
  }
1544
1593
  }
@@ -1551,7 +1600,7 @@ class dn {
1551
1600
  messageId: n
1552
1601
  });
1553
1602
  const o = (a = this.options.persistence) == null ? void 0 : a.markMessageRecalled;
1554
- o && se(() => o(n, this.currentUserId));
1603
+ o && oe(() => o(n, this.currentUserId));
1555
1604
  }
1556
1605
  /**
1557
1606
  * 删除消息:移除当前用户的服务端漫游历史(SDK5 `removeHistoryMessages`)。
@@ -1568,7 +1617,7 @@ class dn {
1568
1617
  messageIds: n
1569
1618
  });
1570
1619
  const o = (a = this.options.persistence) == null ? void 0 : a.deleteMessages;
1571
- o && se(() => o([...n]));
1620
+ o && oe(() => o([...n]));
1572
1621
  }
1573
1622
  /** 批量发送消息已读回执(统一 API,支持单聊/群聊) */
1574
1623
  async markMessagesRead(e, t, n) {
@@ -1594,17 +1643,17 @@ class dn {
1594
1643
  * 失败仅 warn 不阻塞进入会话(先标记后发送,失败回滚以便下次重试)。
1595
1644
  */
1596
1645
  async sendPendingReadReceipts(e, t) {
1597
- const o = this.store.getMessages(e).filter((a) => !a.isSelf && !j.has(a.msgServerId)).map((a) => a.msgServerId).filter((a) => !!a);
1646
+ const o = this.store.getMessages(e).filter((a) => !a.isSelf && !V.has(a.msgServerId)).map((a) => a.msgServerId).filter((a) => !!a);
1598
1647
  if (o.length !== 0) {
1599
- k.info("[MessageDomain.sendPendingReadReceipts] 补发已读回执", { conversationId: e, conversationType: t, pendingCount: o.length, messageIds: o.slice(0, 5) });
1648
+ N.info("[MessageDomain.sendPendingReadReceipts] 补发已读回执", { conversationId: e, conversationType: t, pendingCount: o.length, messageIds: o.slice(0, 5) });
1600
1649
  for (const a of o)
1601
- j.add(a);
1650
+ V.add(a);
1602
1651
  try {
1603
1652
  await this.markMessagesRead(e, t, o);
1604
1653
  } catch (a) {
1605
1654
  for (const r of o)
1606
- j.delete(r);
1607
- k.warn("[MessageDomain.sendPendingReadReceipts] failed:", e, U(a));
1655
+ V.delete(r);
1656
+ N.warn("[MessageDomain.sendPendingReadReceipts] failed:", e, L(a));
1608
1657
  }
1609
1658
  }
1610
1659
  }
@@ -1621,7 +1670,7 @@ class dn {
1621
1670
  const o = (await this.client.chatManager.getPinnedMessageList({
1622
1671
  conversationId: e,
1623
1672
  conversationType: t
1624
- })).items.map((a) => P(a.message, this.currentUserId));
1673
+ })).items.map((a) => H(a.message, this.currentUserId));
1625
1674
  return this.store.setPinnedMessages(e, o), o;
1626
1675
  }
1627
1676
  /** 翻译文本消息 */
@@ -1632,18 +1681,18 @@ class dn {
1632
1681
  targetLanguages: t
1633
1682
  });
1634
1683
  } catch (n) {
1635
- throw k.error("[MessageDomain.translateMessage] raw SDK error:", U(n)), n;
1684
+ throw N.error("[MessageDomain.translateMessage] raw SDK error:", L(n)), n;
1636
1685
  }
1637
1686
  }
1638
1687
  /** 语音消息转文字 */
1639
1688
  async transcribeVoiceMessage(e, t) {
1640
- if (!ze(e.body))
1641
- throw k.warn("[MessageDomain.transcribeVoiceMessage] not a voice message:", e), new Error("not a voice message");
1689
+ if (!it(e.body))
1690
+ throw N.warn("[MessageDomain.transcribeVoiceMessage] not a voice message:", e), new Error("not a voice message");
1642
1691
  const n = {
1643
1692
  ...e.body,
1644
- type: C.VOICE
1693
+ type: b.VOICE
1645
1694
  };
1646
- return k.info("voiceMessageToText raw input:", { message: e, body: n, voiceParams: t }), await this.client.chatManager.voiceMessageToText(n, t);
1695
+ return N.info("voiceMessageToText raw input:", { message: e, body: n, voiceParams: t }), await this.client.chatManager.voiceMessageToText(n, t);
1647
1696
  }
1648
1697
  /** 下载并解析合并消息 */
1649
1698
  async downloadAndParseCombineMessage(e) {
@@ -1667,15 +1716,15 @@ class dn {
1667
1716
  }
1668
1717
  /** 发送单条消息已读回执 */
1669
1718
  async markRead(e, t, n) {
1670
- k.info("[MessageDomain.markRead] 发送单条已读回执", { conversationId: e, conversationType: t, messageId: n });
1719
+ N.info("[MessageDomain.markRead] 发送单条已读回执", { conversationId: e, conversationType: t, messageId: n });
1671
1720
  try {
1672
1721
  await this.client.chatManager.sendMessageReadReceipts({
1673
1722
  conversationId: e,
1674
1723
  conversationType: t,
1675
1724
  messageIds: [n]
1676
- }), k.info("[MessageDomain.markRead] 已读回执发送成功", { conversationId: e, conversationType: t, messageId: n });
1725
+ }), N.info("[MessageDomain.markRead] 已读回执发送成功", { conversationId: e, conversationType: t, messageId: n });
1677
1726
  } catch (o) {
1678
- throw k.warn("[MessageDomain.markRead] 已读回执发送失败", { conversationId: e, conversationType: t, messageId: n, error: U(o) }), o;
1727
+ throw N.warn("[MessageDomain.markRead] 已读回执发送失败", { conversationId: e, conversationType: t, messageId: n, error: L(o) }), o;
1679
1728
  }
1680
1729
  }
1681
1730
  /** 获取群消息已读详情(自动翻页聚合全部已读成员) */
@@ -1706,28 +1755,29 @@ class dn {
1706
1755
  conversationType: t,
1707
1756
  messageId: n,
1708
1757
  message: {
1709
- type: C.TEXT,
1758
+ type: b.TEXT,
1710
1759
  body: { content: o },
1711
1760
  ext: {}
1712
1761
  }
1713
1762
  });
1714
1763
  }
1715
1764
  }
1716
- function ln(s, e) {
1717
- var d, g, m, p, u, l;
1718
- const t = Xt(s.lastMessage, void 0, e == null ? void 0 : e.lastMessageTextResolver, {
1765
+ function An(s, e) {
1766
+ var u, l, g, p, d, f;
1767
+ const t = gn(s.lastMessage, void 0, e == null ? void 0 : e.lastMessageTextResolver, {
1719
1768
  conversationId: s.conversationId,
1720
1769
  conversationType: s.conversationType
1721
- }), n = E(((d = s.lastMessage) == null ? void 0 : d.from) || ""), o = E(((m = (g = s.lastMessage) == null ? void 0 : g.sender) == null ? void 0 : m.userId) || ""), a = o || n, r = a ? (p = e == null ? void 0 : e.resolveSenderName) == null ? void 0 : p.call(e, a) : void 0, i = ((l = (u = s.lastMessage) == null ? void 0 : u.sender) == null ? void 0 : l.nickname) || r || o || n || "", c = Xe(s.conversationType, i, t);
1770
+ }), n = G(((u = s.lastMessage) == null ? void 0 : u.from) || ""), o = G(((g = (l = s.lastMessage) == null ? void 0 : l.sender) == null ? void 0 : g.userId) || ""), a = o || n, r = a ? (p = e == null ? void 0 : e.resolveSenderName) == null ? void 0 : p.call(e, a) : void 0, i = ((f = (d = s.lastMessage) == null ? void 0 : d.sender) == null ? void 0 : f.nickname) || r || o || n || "", c = ct(s.conversationType, i, t);
1722
1771
  return {
1723
1772
  id: s.conversationId,
1724
1773
  name: s.conversationName || s.conversationId,
1725
1774
  avatar: s.conversationAvatar,
1726
- type: s.conversationType === M.GROUPCHAT ? M.GROUPCHAT : M.SINGLECHAT,
1775
+ type: s.conversationType === I.GROUPCHAT ? I.GROUPCHAT : I.SINGLECHAT,
1727
1776
  unreadCount: s.unreadCount || 0,
1728
1777
  lastMessageText: c,
1729
1778
  // 保留群聊最后一条消息发送者 userId,供会话列表项在资料异步就绪后重新解析昵称
1730
1779
  lastMessageFrom: a || void 0,
1780
+ lastMessageSenderName: i || void 0,
1731
1781
  lastMessageTime: s.lastMessageAt,
1732
1782
  isPinned: s.isPinned ?? !1,
1733
1783
  pinnedTime: s.pinnedTimestamp,
@@ -1736,27 +1786,39 @@ function ln(s, e) {
1736
1786
  remindType: s.remindType
1737
1787
  };
1738
1788
  }
1739
- function te(s, e) {
1740
- return s.map((t) => ln(t, e));
1789
+ function se(s, e) {
1790
+ return s.map((t) => An(t, e));
1741
1791
  }
1742
- const Ae = T("Conversation");
1743
- function gn(s) {
1792
+ const En = 20, Je = 3;
1793
+ function ve(s, e, t) {
1794
+ if (t.length <= En) {
1795
+ s.info(`getConversationList raw (${e})`, t);
1796
+ return;
1797
+ }
1798
+ s.info(`getConversationList raw (${e})`, {
1799
+ count: t.length,
1800
+ sampleSize: Je,
1801
+ sample: t.slice(0, Je)
1802
+ });
1803
+ }
1804
+ const Ne = T("Conversation");
1805
+ function Gn(s) {
1744
1806
  return [...s].sort((e, t) => e.isPinned !== t.isPinned ? e.isPinned ? -1 : 1 : e.isPinned ? (t.pinnedTime ?? 0) - (e.pinnedTime ?? 0) : (t.lastMessageTime ?? 0) - (e.lastMessageTime ?? 0));
1745
1807
  }
1746
- function fn(s, e) {
1808
+ function Tn(s, e) {
1747
1809
  var o;
1748
1810
  const t = {}, n = [];
1749
1811
  for (const a of s) {
1750
1812
  const r = String(((o = a.lastMessage) == null ? void 0 : o.type) ?? "(null)");
1751
- t[r] = (t[r] ?? 0) + 1, (r === C.COMBINE || r === "unknown") && n.push({
1813
+ t[r] = (t[r] ?? 0) + 1, (r === b.COMBINE || r === "unknown") && n.push({
1752
1814
  conversationId: a.conversationId,
1753
1815
  lastMessage: a.lastMessage
1754
1816
  });
1755
1817
  }
1756
- n.length > 0 && Ae.info(`raw snippets (${e})`, { typeCount: t, suspects: n });
1818
+ n.length > 0 && Ne.info(`raw snippets (${e})`, { typeCount: t, suspects: n });
1757
1819
  }
1758
- const mn = 1e3;
1759
- class pn {
1820
+ const Un = 1e3;
1821
+ class Rn {
1760
1822
  constructor(e, t, n = {}) {
1761
1823
  this.client = e, this.store = t, this.hooks = n, this.channelAckSentAt = /* @__PURE__ */ new Map();
1762
1824
  }
@@ -1771,20 +1833,26 @@ class pn {
1771
1833
  }
1772
1834
  /** 从本地缓存读取会话列表 */
1773
1835
  syncLocal() {
1836
+ var o, a;
1774
1837
  const e = this.client.chatManager.getConversationList();
1775
- Ae.info("getConversationList raw (syncLocal)", e), fn(e, "syncLocal");
1776
- const t = te(e, {
1838
+ ve(Ne, "syncLocal", e), Tn(e, "syncLocal");
1839
+ const t = Array.from(new Set(e.filter((r) => r.conversationType === I.GROUPCHAT).map((r) => {
1840
+ var i, c, u;
1841
+ return G(((c = (i = r.lastMessage) == null ? void 0 : i.sender) == null ? void 0 : c.userId) || ((u = r.lastMessage) == null ? void 0 : u.from) || "");
1842
+ }).filter(Boolean)));
1843
+ (a = (o = this.hooks).prefillUserInfo) == null || a.call(o, t);
1844
+ const n = se(e, {
1777
1845
  resolveSenderName: this.hooks.resolveSenderName,
1778
1846
  lastMessageTextResolver: this.hooks.lastMessageTextResolver
1779
1847
  });
1780
- return this.store.setList(t), t;
1848
+ return this.store.setList(n), n;
1781
1849
  }
1782
1850
  /** 仅按原始快照重算现有会话摘要,保留本地字段和本地独有会话 */
1783
1851
  refreshPreviews() {
1784
1852
  const e = this.store.conversationList ?? [];
1785
1853
  if (e.length === 0)
1786
1854
  return;
1787
- const t = this.client.chatManager.getConversationList(), n = te(t, {
1855
+ const t = this.client.chatManager.getConversationList(), n = se(t, {
1788
1856
  resolveSenderName: this.hooks.resolveSenderName,
1789
1857
  lastMessageTextResolver: this.hooks.lastMessageTextResolver
1790
1858
  }), o = new Map(n.map((a) => [a.id, a.lastMessageText]));
@@ -1805,19 +1873,19 @@ class pn {
1805
1873
  const o = [];
1806
1874
  let a;
1807
1875
  do {
1808
- const d = await t(a, 50);
1809
- o.push(...d.list), a = d.hasMore ? d.cursor : void 0;
1876
+ const u = await t(a, 50);
1877
+ o.push(...u.list), a = u.hasMore ? u.cursor : void 0;
1810
1878
  } while (a);
1811
- const r = this.store.conversationList ?? [], i = new Map(r.map((d) => [d.id, d])), c = /* @__PURE__ */ new Map();
1812
- for (const d of o) {
1813
- const g = i.get(d.id);
1814
- c.set(d.id, g ? {
1815
- ...d,
1816
- name: (!d.name || d.name === d.id) && g.name && g.name !== g.id ? g.name : d.name,
1817
- avatar: d.avatar || g.avatar
1818
- } : d);
1879
+ const r = this.store.conversationList ?? [], i = new Map(r.map((u) => [u.id, u])), c = /* @__PURE__ */ new Map();
1880
+ for (const u of o) {
1881
+ const l = i.get(u.id);
1882
+ c.set(u.id, l ? {
1883
+ ...u,
1884
+ name: (!u.name || u.name === u.id) && l.name && l.name !== l.id ? l.name : u.name,
1885
+ avatar: u.avatar || l.avatar
1886
+ } : u);
1819
1887
  }
1820
- this.store.setList(gn(Array.from(c.values())));
1888
+ this.store.setList(Gn(Array.from(c.values())));
1821
1889
  return;
1822
1890
  }
1823
1891
  await this.client.chatManager.refreshSessionList({ includeEmpty: e });
@@ -1908,20 +1976,20 @@ class pn {
1908
1976
  if (n !== void 0 && n <= 0)
1909
1977
  return;
1910
1978
  const o = Date.now(), a = this.channelAckSentAt.get(e) || 0;
1911
- o - a < mn || (this.channelAckSentAt.set(e, o), await this.markRead(e, t));
1979
+ o - a < Un || (this.channelAckSentAt.set(e, o), await this.markRead(e, t));
1912
1980
  }
1913
1981
  /** 加载更多会话:SDK5 当前无分页游标,直接返回本地列表 */
1914
1982
  async loadMore(e) {
1915
1983
  const t = this.client.chatManager.getConversationList();
1916
- Ae.info("getConversationList raw (loadMore)", t);
1917
- const n = te(t, {
1984
+ ve(Ne, "loadMore", t);
1985
+ const n = se(t, {
1918
1986
  resolveSenderName: this.hooks.resolveSenderName,
1919
1987
  lastMessageTextResolver: this.hooks.lastMessageTextResolver
1920
1988
  });
1921
1989
  this.store.setList(n);
1922
1990
  }
1923
1991
  }
1924
- function hn(s) {
1992
+ function Ln(s) {
1925
1993
  if ("userId" in s && s.userId !== void 0) {
1926
1994
  const t = s;
1927
1995
  return {
@@ -1941,10 +2009,10 @@ function hn(s) {
1941
2009
  birth: e.birth,
1942
2010
  phone: e.phone,
1943
2011
  mail: e.mail,
1944
- ext: vn(e.ext)
2012
+ ext: _n(e.ext)
1945
2013
  };
1946
2014
  }
1947
- function vn(s) {
2015
+ function _n(s) {
1948
2016
  if (s)
1949
2017
  try {
1950
2018
  const e = JSON.parse(s);
@@ -1953,16 +2021,16 @@ function vn(s) {
1953
2021
  return;
1954
2022
  }
1955
2023
  }
1956
- function Ge(s) {
1957
- return s.map((e) => hn(e));
2024
+ function ke(s) {
2025
+ return s.map((e) => Ln(e));
1958
2026
  }
1959
- class In {
2027
+ class Dn {
1960
2028
  constructor(e, t, n = {}) {
1961
2029
  this.client = e, this.store = t, this.options = n;
1962
2030
  }
1963
2031
  /** 获取当前内存中的联系人列表 */
1964
2032
  syncLocal() {
1965
- const e = this.client.contactManager.getContacts(), t = Ge(e);
2033
+ const e = this.client.contactManager.getContacts(), t = ke(e);
1966
2034
  return this.store.setList(t), t;
1967
2035
  }
1968
2036
  /**
@@ -2018,7 +2086,7 @@ class In {
2018
2086
  const a = await e();
2019
2087
  return this.store.setBlocklist(a), a;
2020
2088
  }
2021
- const t = await this.client.contactManager.getBlocklist(), n = Ge(t);
2089
+ const t = await this.client.contactManager.getBlocklist(), n = ke(t);
2022
2090
  return this.store.setBlocklist(n), n;
2023
2091
  }
2024
2092
  /** 批量加入黑名单 */
@@ -2030,7 +2098,7 @@ class In {
2030
2098
  await this.client.contactManager.removeUserFromBlocklist({ userIds: e });
2031
2099
  }
2032
2100
  }
2033
- function Le(s) {
2101
+ function Fe(s) {
2034
2102
  const e = {
2035
2103
  groupId: s.groupId,
2036
2104
  groupName: s.name,
@@ -2044,10 +2112,10 @@ function Le(s) {
2044
2112
  };
2045
2113
  return s.role && (e.role = s.role), "avatarUrl" in s && (e.avatar = s.avatarUrl), "muteAllMembers" in s && (e.mute = s.muteAllMembers), "ownerId" in s && (e.owner = s.ownerId), "owner" in s && s.owner && (e.owner = s.owner.userId), "createdAt" in s && (e.created = s.createdAt), "messageBlocked" in s && (e.shieldgroup = s.messageBlocked), "ext" in s && (e.ext = s.ext), "inviteNeedConfirm" in s && (e.inviteNeedConfirm = s.inviteNeedConfirm), "joinedAt" in s && (e.joinedAt = s.joinedAt), e;
2046
2114
  }
2047
- function fe(s) {
2048
- return s.map((e) => Le(e));
2115
+ function Ie(s) {
2116
+ return s.map((e) => Fe(e));
2049
2117
  }
2050
- function Mn(s) {
2118
+ function Nn(s) {
2051
2119
  const e = s.user, t = {
2052
2120
  userId: e.userId,
2053
2121
  nickname: e.nickname,
@@ -2056,17 +2124,17 @@ function Mn(s) {
2056
2124
  };
2057
2125
  return "joinedAt" in s && (t.joinedAt = s.joinedAt), "muteExpire" in s && s.muteExpire !== void 0 && (t.muteExpire = s.muteExpire), "muteDuration" in s && s.muteDuration !== void 0 && (t.muteDuration = s.muteDuration), t;
2058
2126
  }
2059
- function Z(s) {
2060
- return s.map((e) => Mn(e));
2127
+ function te(s) {
2128
+ return s.map((e) => Nn(e));
2061
2129
  }
2062
- const re = T("UIKit:GroupDomain"), Ie = /* @__PURE__ */ new Map(), Me = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new Map();
2063
- class yn {
2130
+ const ie = T("UIKit:GroupDomain"), we = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ new Map(), Ae = /* @__PURE__ */ new Map();
2131
+ class kn {
2064
2132
  constructor(e, t, n = {}) {
2065
2133
  this.client = e, this.store = t, this.options = n;
2066
2134
  }
2067
2135
  /** 获取已加入群组本地列表 */
2068
2136
  syncLocal() {
2069
- const e = this.client.groupManager.getJoinedGroupList(), t = fe(e);
2137
+ const e = this.client.groupManager.getJoinedGroupList(), t = Ie(e);
2070
2138
  return this.store.setList(t), t;
2071
2139
  }
2072
2140
  /**
@@ -2089,23 +2157,23 @@ class yn {
2089
2157
  }
2090
2158
  /** 获取单个群详情 */
2091
2159
  async fetchGroupInfo(e) {
2092
- const t = Ie.get(e);
2160
+ const t = we.get(e);
2093
2161
  if (t)
2094
2162
  return t;
2095
2163
  const n = (async () => {
2096
- const o = await this.client.groupManager.getGroupInfo({ groupId: e }), a = Le(o);
2164
+ const o = await this.client.groupManager.getGroupInfo({ groupId: e }), a = Fe(o);
2097
2165
  return this.store.updateGroup(e, a), a;
2098
2166
  })();
2099
- Ie.set(e, n);
2167
+ we.set(e, n);
2100
2168
  try {
2101
2169
  return await n;
2102
2170
  } finally {
2103
- Ie.delete(e);
2171
+ we.delete(e);
2104
2172
  }
2105
2173
  }
2106
2174
  /** 批量获取群详情 */
2107
2175
  async fetchGroupInfoList(e) {
2108
- const t = await this.client.groupManager.getGroupInfoList({ groupIds: e }), n = fe(t);
2176
+ const t = await this.client.groupManager.getGroupInfoList({ groupIds: e }), n = Ie(t);
2109
2177
  return n.forEach((o) => this.store.updateGroup(o.groupId, o)), n;
2110
2178
  }
2111
2179
  /** 创建群组(注入 createGroup 时整体委托业务接管:不调 SDK、不写本地缓存,权威数据由业务源负责) */
@@ -2128,7 +2196,7 @@ class yn {
2128
2196
  groupId: n.groupId,
2129
2197
  groupName: e.name,
2130
2198
  description: e.description,
2131
- role: L.OWNER,
2199
+ role: R.OWNER,
2132
2200
  memberCount: (((a = e.memberIds) == null ? void 0 : a.length) ?? 0) + 1,
2133
2201
  maxUsers: e.maxMembers,
2134
2202
  public: e.public ?? !1,
@@ -2158,7 +2226,7 @@ class yn {
2158
2226
  }
2159
2227
  /** 拉取群成员列表 */
2160
2228
  async fetchGroupMembers(e, t, n = 20) {
2161
- const o = await this.client.groupManager.getGroupMemberList({ groupId: e, cursor: t, pageSize: n }), a = Z(o.items);
2229
+ const o = await this.client.groupManager.getGroupMemberList({ groupId: e, cursor: t, pageSize: n }), a = te(o.items);
2162
2230
  if (t)
2163
2231
  this.store.appendGroupMembers(e, a);
2164
2232
  else {
@@ -2174,42 +2242,42 @@ class yn {
2174
2242
  /** 拉取并合并群管理员到成员缓存 */
2175
2243
  async syncGroupAdmins(e) {
2176
2244
  var o, a;
2177
- const t = Me.get(e);
2245
+ const t = Se.get(e);
2178
2246
  if (t)
2179
2247
  return t;
2180
2248
  if ((a = (o = this.store).isGroupAdminSynced) != null && a.call(o, e))
2181
2249
  return;
2182
2250
  const n = (async () => {
2183
- var c, d;
2184
- const r = await this.client.groupManager.getGroup(e).getAdmins(), i = Z(
2185
- (r || []).map((g) => ({ user: g, role: L.ADMIN }))
2251
+ var c, u;
2252
+ const r = await this.client.groupManager.getGroup(e).getAdmins(), i = te(
2253
+ (r || []).map((l) => ({ user: l, role: R.ADMIN }))
2186
2254
  );
2187
2255
  this.store.appendGroupMembers(e, i);
2188
- for (const g of i)
2189
- this.store.updateGroupMemberRole(e, g.userId, L.ADMIN);
2190
- (d = (c = this.store).markGroupAdminSynced) == null || d.call(c, e);
2256
+ for (const l of i)
2257
+ this.store.updateGroupMemberRole(e, l.userId, R.ADMIN);
2258
+ (u = (c = this.store).markGroupAdminSynced) == null || u.call(c, e);
2191
2259
  })();
2192
- Me.set(e, n);
2260
+ Se.set(e, n);
2193
2261
  try {
2194
2262
  return await n;
2195
2263
  } finally {
2196
- Me.delete(e);
2264
+ Se.delete(e);
2197
2265
  }
2198
2266
  }
2199
2267
  /** 拉取群公告 */
2200
2268
  async fetchGroupAnnouncement(e) {
2201
- const t = ye.get(e);
2269
+ const t = Ae.get(e);
2202
2270
  if (t)
2203
2271
  return t;
2204
2272
  const n = (async () => {
2205
2273
  const a = (await this.client.groupManager.getGroupAnnouncement({ groupId: e })).announcement ?? "";
2206
2274
  return this.store.setGroupAnnouncement(e, a), a;
2207
2275
  })();
2208
- ye.set(e, n);
2276
+ Ae.set(e, n);
2209
2277
  try {
2210
2278
  return await n;
2211
2279
  } finally {
2212
- ye.delete(e);
2280
+ Ae.delete(e);
2213
2281
  }
2214
2282
  }
2215
2283
  /** 更新群公告 */
@@ -2230,11 +2298,11 @@ class yn {
2230
2298
  }
2231
2299
  /** 设置群管理员 */
2232
2300
  async addGroupAdmin(e, t) {
2233
- await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, L.ADMIN);
2301
+ await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, R.ADMIN);
2234
2302
  }
2235
2303
  /** 取消群管理员 */
2236
2304
  async removeGroupAdmin(e, t) {
2237
- await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, L.MEMBER);
2305
+ await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, R.MEMBER);
2238
2306
  }
2239
2307
  /** 接受群邀请 */
2240
2308
  async acceptGroupInvitation(e) {
@@ -2265,25 +2333,25 @@ class yn {
2265
2333
  * @param muteDuration 禁言时长,单位为毫秒;传 -1 表示永久禁言(SDK 5.0.0+ 语义)。
2266
2334
  */
2267
2335
  async muteGroupMembers(e, t, n) {
2268
- re.info("muteGroupMembers request raw", { groupId: e, userIds: t, muteDuration: n });
2336
+ ie.info("muteGroupMembers request raw", { groupId: e, userIds: t, muteDuration: n });
2269
2337
  const o = await this.client.groupManager.getGroup(e).muteMembers({ userIds: t, muteDuration: n });
2270
- re.info("muteGroupMembers response raw", o), this.store.addGroupMuteMembers(e, t);
2338
+ ie.info("muteGroupMembers response raw", o), this.store.addGroupMuteMembers(e, t);
2271
2339
  }
2272
2340
  /** 解除指定成员禁言 */
2273
2341
  async unmuteGroupMembers(e, t) {
2274
- re.info("unmuteGroupMembers request raw", { groupId: e, userIds: t });
2342
+ ie.info("unmuteGroupMembers request raw", { groupId: e, userIds: t });
2275
2343
  const n = await this.client.groupManager.getGroup(e).unmuteMembers({ userIds: t });
2276
- re.info("unmuteGroupMembers response raw", n), this.store.removeGroupMuteMembers(e, t);
2344
+ ie.info("unmuteGroupMembers response raw", n), this.store.removeGroupMuteMembers(e, t);
2277
2345
  }
2278
2346
  /** 获取群禁言列表 */
2279
2347
  async getGroupMuteList(e, t, n) {
2280
2348
  const o = await this.client.groupManager.getGroup(e).getMuteList({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
2281
- return this.store.setGroupMuteList(e, Z(a)), o;
2349
+ return this.store.setGroupMuteList(e, te(a)), o;
2282
2350
  }
2283
2351
  /** 获取群黑名单 */
2284
2352
  async getGroupBlocklist(e, t, n) {
2285
2353
  const o = await this.client.groupManager.getGroup(e).getBlocklist({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
2286
- return this.store.setGroupBlocklist(e, Z(a)), o;
2354
+ return this.store.setGroupBlocklist(e, te(a)), o;
2287
2355
  }
2288
2356
  /** 将成员加入群黑名单 */
2289
2357
  async blockGroupMembers(e, t) {
@@ -2296,7 +2364,7 @@ class yn {
2296
2364
  /** 获取群白名单 */
2297
2365
  async getGroupAllowlist(e) {
2298
2366
  const t = await this.client.groupManager.getGroup(e).getAllowlist(), n = Array.isArray(t) ? t : (t == null ? void 0 : t.data) ?? [];
2299
- return this.store.setGroupAllowlist(e, Z(n)), t;
2367
+ return this.store.setGroupAllowlist(e, te(n)), t;
2300
2368
  }
2301
2369
  /** 将成员加入群白名单 */
2302
2370
  async addUsersToGroupAllowlist(e, t) {
@@ -2361,75 +2429,162 @@ class yn {
2361
2429
  await this.client.groupManager.rejectInvitation({ groupId: e });
2362
2430
  }
2363
2431
  }
2364
- function nt(s, e) {
2432
+ const Ee = T("UIKit:PresenceDomain"), Ge = 100;
2433
+ function Te(s, e) {
2434
+ const t = [];
2435
+ for (let n = 0; n < s.length; n += e)
2436
+ t.push(s.slice(n, n + e));
2437
+ return t;
2438
+ }
2439
+ function ft(s, e) {
2365
2440
  if (!s)
2366
2441
  return "offline";
2367
2442
  if (!e)
2368
2443
  return "online";
2369
- const t = e.toLowerCase(), n = X.ONLINE.toLowerCase(), o = X.AWAY.toLowerCase(), a = X.BUSY.toLowerCase(), r = X.DO_NOT_DISTURB.toLowerCase(), i = X.OFFLINE.toLowerCase();
2444
+ const t = e.toLowerCase(), n = ee.ONLINE.toLowerCase(), o = ee.AWAY.toLowerCase(), a = ee.BUSY.toLowerCase(), r = ee.DO_NOT_DISTURB.toLowerCase(), i = ee.OFFLINE.toLowerCase();
2370
2445
  return t === n ? "online" : t === o ? "away" : t === a ? "busy" : t === r ? "doNotDisturb" : t === i ? "offline" : "custom";
2371
2446
  }
2372
- function Pe(s) {
2447
+ function $e(s) {
2373
2448
  const e = s.publisher || "";
2374
2449
  if (!e)
2375
2450
  return null;
2376
2451
  const t = s.statusList || {}, n = Object.values(t).some((a) => Number(a) === 1), o = s.ext || "";
2377
2452
  return {
2378
2453
  userId: e,
2379
- status: nt(n, o),
2454
+ status: ft(n, o),
2380
2455
  ext: o,
2381
2456
  lastTime: s.latestTime || Date.now()
2382
2457
  };
2383
2458
  }
2384
- class bn {
2459
+ class On {
2385
2460
  constructor(e, t, n = {}) {
2386
2461
  this.client = e, this.store = t, this.options = n;
2387
2462
  }
2388
- /** 订阅用户在线状态 */
2463
+ /** 订阅用户在线状态(>100 人自动分片;任一分片失败会在其余分片完成后抛出首个错误) */
2389
2464
  async subscribe(e, t = 7 * 24 * 60 * 60) {
2390
- var r;
2391
- const n = (r = this.options.presenceRepository) == null ? void 0 : r.subscribe;
2465
+ var c;
2466
+ const n = (c = this.options.presenceRepository) == null ? void 0 : c.subscribe;
2392
2467
  if (n)
2393
2468
  return await n(e, t), [];
2394
2469
  if (!this.client.isConnected)
2395
2470
  return [];
2396
- const o = await this.client.presenceManager.subscribePresence({
2397
- userIds: e,
2398
- expiry: t
2399
- });
2400
- this.store.setSubscribed(e);
2401
- const a = o.map(Pe).filter((i) => i !== null);
2402
- return this.store.updateBatch(a), a;
2471
+ const o = Array.from(new Set(e.filter(Boolean)));
2472
+ if (o.length === 0)
2473
+ return [];
2474
+ const a = [];
2475
+ let r;
2476
+ const i = Te(o, Ge);
2477
+ for (const u of i)
2478
+ try {
2479
+ const l = await this.client.presenceManager.subscribePresence({
2480
+ userIds: u,
2481
+ expiry: t
2482
+ });
2483
+ this.store.setSubscribed(u);
2484
+ const g = l.map($e).filter((p) => p !== null);
2485
+ this.store.updateBatch(g), a.push(...g);
2486
+ } catch (l) {
2487
+ r === void 0 && (r = l, Ee.warn("[PresenceDomain] subscribePresence chunk failed:", {
2488
+ chunkSize: u.length,
2489
+ chunks: i.length
2490
+ }));
2491
+ }
2492
+ if (r !== void 0)
2493
+ throw r;
2494
+ return a;
2403
2495
  }
2404
- /** 取消订阅 */
2496
+ /** 取消订阅(>100 人分片;清理语义,分片失败仅告警不抛出,避免调用方 void 时产生未处理拒绝) */
2405
2497
  async unsubscribe(e) {
2406
- var n;
2407
- const t = (n = this.options.presenceRepository) == null ? void 0 : n.unsubscribe;
2498
+ var o;
2499
+ const t = (o = this.options.presenceRepository) == null ? void 0 : o.unsubscribe;
2408
2500
  if (t) {
2409
2501
  await t(e);
2410
2502
  return;
2411
2503
  }
2412
- this.client.isConnected && await this.client.presenceManager.unsubscribePresence({ userIds: e });
2504
+ if (!this.client.isConnected)
2505
+ return;
2506
+ const n = Array.from(new Set(e.filter(Boolean)));
2507
+ for (const a of Te(n, Ge))
2508
+ try {
2509
+ await this.client.presenceManager.unsubscribePresence({ userIds: a });
2510
+ } catch (r) {
2511
+ Ee.warn("[PresenceDomain] unsubscribePresence chunk failed:", {
2512
+ chunkSize: a.length,
2513
+ err: r
2514
+ });
2515
+ }
2413
2516
  }
2414
- /** 主动查询在线状态 */
2517
+ /** 主动查询在线状态(>100 人分片;任一分片失败会在其余分片完成后抛出首个错误) */
2415
2518
  async fetchStatus(e) {
2416
- var a;
2417
- const t = (a = this.options.presenceRepository) == null ? void 0 : a.fetchStatus;
2519
+ var i;
2520
+ const t = (i = this.options.presenceRepository) == null ? void 0 : i.fetchStatus;
2418
2521
  if (t) {
2419
- const r = await t(e);
2420
- return this.store.updateBatch(r), r;
2522
+ const c = await t(e);
2523
+ return this.store.updateBatch(c), c;
2421
2524
  }
2422
2525
  if (!this.client.isConnected)
2423
2526
  return [];
2424
- const o = (await this.client.presenceManager.getPresenceStatus({ userIds: e })).map(Pe).filter((r) => r !== null);
2425
- return this.store.updateBatch(o), o;
2527
+ const n = Array.from(new Set(e.filter(Boolean)));
2528
+ if (n.length === 0)
2529
+ return [];
2530
+ const o = [];
2531
+ let a;
2532
+ const r = Te(n, Ge);
2533
+ for (const c of r)
2534
+ try {
2535
+ const l = (await this.client.presenceManager.getPresenceStatus({ userIds: c })).map($e).filter((g) => g !== null);
2536
+ this.store.updateBatch(l), o.push(...l);
2537
+ } catch (u) {
2538
+ a === void 0 && (a = u, Ee.warn("[PresenceDomain] getPresenceStatus chunk failed:", {
2539
+ chunkSize: c.length,
2540
+ chunks: r.length
2541
+ }));
2542
+ }
2543
+ if (a !== void 0)
2544
+ throw a;
2545
+ return o;
2426
2546
  }
2427
2547
  /** 发布自定义在线状态 */
2428
2548
  async publish(e) {
2429
2549
  this.client.isConnected && await this.client.presenceManager.publishPresence({ customStatus: e });
2430
2550
  }
2431
2551
  }
2432
- const F = T("UIKit:UserInfoDomain"), Be = [
2552
+ const P = T("UIKit:UserInfoDomain"), F = 100, xn = 300;
2553
+ function Pn(s) {
2554
+ var a;
2555
+ const e = s, t = ((a = e == null ? void 0 : e.details) == null ? void 0 : a.httpStatus) ?? (e == null ? void 0 : e.httpStatus);
2556
+ if (t === 429 || t !== void 0 && t >= 500)
2557
+ return !0;
2558
+ if (t !== void 0)
2559
+ return !1;
2560
+ const n = Number(e == null ? void 0 : e.code);
2561
+ if ([2, 301, 302, 303, 304].includes(n))
2562
+ return !0;
2563
+ if ((e == null ? void 0 : e.code) !== void 0)
2564
+ return !1;
2565
+ const o = s instanceof Error ? s.message : String(s ?? "");
2566
+ return /network|failed to fetch|timeout|timed out/i.test(o);
2567
+ }
2568
+ function Bn(s) {
2569
+ var t, n, o;
2570
+ const e = s;
2571
+ return {
2572
+ code: e == null ? void 0 : e.code,
2573
+ httpStatus: ((t = e == null ? void 0 : e.details) == null ? void 0 : t.httpStatus) ?? (e == null ? void 0 : e.httpStatus),
2574
+ reason: ((n = e == null ? void 0 : e.details) == null ? void 0 : n.reasonKey) ?? ((o = e == null ? void 0 : e.details) == null ? void 0 : o.reason) ?? (e == null ? void 0 : e.reason),
2575
+ message: e == null ? void 0 : e.message
2576
+ };
2577
+ }
2578
+ async function Fn(s) {
2579
+ try {
2580
+ return await s();
2581
+ } catch (e) {
2582
+ if (!Pn(e))
2583
+ throw e;
2584
+ return await new Promise((t) => setTimeout(t, xn)), s();
2585
+ }
2586
+ }
2587
+ const Ue = [
2433
2588
  "nickname",
2434
2589
  "avatarUrl",
2435
2590
  "mail",
@@ -2439,10 +2594,29 @@ const F = T("UIKit:UserInfoDomain"), Be = [
2439
2594
  "birth",
2440
2595
  "ext"
2441
2596
  ];
2442
- class Cn {
2597
+ class Hn {
2443
2598
  constructor(e, t, n = {}, o) {
2444
2599
  this.client = e, this.store = t, this.userInfoRepository = n, this.onSubscriptionPermissionError = o, this.handlerId = "uikit-user-info", this.subscribeQueue = [], this.subscribeFlushPromise = null, this.fetchQueue = [], this.fetchFlushPromise = null, this.hasLoggedPermissionError = !1;
2445
2600
  }
2601
+ readCachedUserInfos(e) {
2602
+ var t, n;
2603
+ try {
2604
+ return ((n = (t = this.userInfoRepository).readCachedUserInfos) == null ? void 0 : n.call(t, Array.from(new Set(e.filter(Boolean))))) ?? [];
2605
+ } catch {
2606
+ return [];
2607
+ }
2608
+ }
2609
+ prefillUserInfos(e) {
2610
+ const t = this.readCachedUserInfos(e);
2611
+ if (t.length === 0)
2612
+ return [];
2613
+ this.store.setUserInfos(t);
2614
+ for (const n of t) {
2615
+ const o = Ue.filter((a) => n[a] !== void 0);
2616
+ o.length > 0 && this.store.markFetchedAttributes([n.userId], o);
2617
+ }
2618
+ return t;
2619
+ }
2446
2620
  /**
2447
2621
  * 启动用户资料变更事件监听。应在 SDK 初始化完成后调用。
2448
2622
  */
@@ -2451,19 +2625,17 @@ class Cn {
2451
2625
  }
2452
2626
  /**
2453
2627
  * 批量获取用户资料;已缓存(且请求属性已覆盖)或正在加载中的 userId 会被跳过。
2454
- * 同一事件循环内的多次调用会合批为一次底层请求(微任务 flush,与 subscribe 合批同构):
2455
- * flush 时合并所有调用的 userIds(去重)与 attributes(并集),只发一次请求,
2628
+ * 同一事件循环内的多次调用会先微任务合批,再按 100 人顺序分片(与 subscribe 合批同构):
2629
+ * flush 时合并所有调用的 userIds(去重)与 attributes(并集),
2456
2630
  * 每个原始调用各自 resolve 回「自己请求的 userIds 对应的 UserInfo[]」(从 store 缓存读回)。
2457
2631
  * @param userIds 目标用户 ID 列表
2458
2632
  * @param attributes 需要查询的属性,默认全量 8 个属性
2459
2633
  */
2460
- async fetchUserInfos(e, t = Be) {
2461
- if (!this.client.isConnected)
2462
- return [];
2463
- const n = Array.from(new Set(e.filter(Boolean)));
2464
- return n.length === 0 ? [] : new Promise((o) => {
2465
- this.fetchQueue.push({ userIds: n, attributes: t, resolve: o }), this.scheduleFetchFlush();
2466
- });
2634
+ async fetchUserInfos(e, t = Ue, n) {
2635
+ const o = Array.from(new Set(e.filter(Boolean)));
2636
+ return o.length === 0 ? [] : this.client.isConnected ? new Promise((a) => {
2637
+ this.fetchQueue.push({ userIds: o, attributes: t, options: n, resolve: a }), this.scheduleFetchFlush();
2638
+ }) : (this.store.markFetchFailed(o), []);
2467
2639
  }
2468
2640
  scheduleFetchFlush() {
2469
2641
  this.fetchFlushPromise || (this.fetchFlushPromise = Promise.resolve().then(() => this.flushFetchQueue()));
@@ -2472,31 +2644,61 @@ class Cn {
2472
2644
  const e = this.fetchQueue;
2473
2645
  this.fetchQueue = [];
2474
2646
  try {
2475
- const t = e.map((a) => ({
2476
- ...a,
2477
- missingIds: a.userIds.filter(
2478
- (r) => !this.store.areAttributesFetched(r, a.attributes) && !this.store.isLoading(r) && !this.store.isFetchFailed(r)
2647
+ const t = Array.from(new Set(e.flatMap((l) => l.userIds.filter(
2648
+ (g) => !this.store.areAttributesFetched(g, l.attributes) && !this.store.isLoading(g) && !this.store.isFetchFailed(g)
2649
+ )))), n = this.prefillUserInfos(t).length, o = e.map((l) => ({
2650
+ ...l,
2651
+ missingIds: l.userIds.filter(
2652
+ (g) => !this.store.areAttributesFetched(g, l.attributes) && !this.store.isLoading(g) && !this.store.isFetchFailed(g)
2479
2653
  )
2480
- })), n = Array.from(new Set(t.flatMap((a) => a.missingIds))), o = Array.from(new Set(e.flatMap((a) => a.attributes)));
2481
- if (n.length > 0) {
2482
- this.store.markLoading(n);
2483
- try {
2484
- const a = this.userInfoRepository.fetchUserInfos ? await this.fetchFromRepository(n) : await this.fetchFromSdk(n, o), r = new Set(a.map((c) => c.userId).filter(Boolean)), i = n.filter((c) => !r.has(c));
2485
- i.length > 0 && this.store.markFetchFailed(i), this.store.setUserInfos(a), this.store.markFetchedAttributes(n, o);
2486
- } catch (a) {
2487
- F.warn("[UserInfoDomain] fetchUserInfos failed:", U(a)), this.store.markFetchFailed(n);
2488
- } finally {
2489
- this.store.markLoaded(n);
2490
- }
2491
- }
2492
- for (const a of t)
2493
- a.resolve(
2494
- a.userIds.map((r) => this.store.getUserInfo(r)).filter((r) => !!r)
2654
+ })), a = Array.from(new Set(o.flatMap((l) => l.missingIds))), r = Array.from(new Set(e.flatMap((l) => l.attributes))), i = Array.from(new Set(e.map((l) => {
2655
+ var g;
2656
+ return ((g = l.options) == null ? void 0 : g.source) ?? "unknown";
2657
+ }))), c = i.join(",");
2658
+ let u = 0;
2659
+ if (a.length > 0)
2660
+ for (let l = 0; l < a.length; l += F)
2661
+ await this.fetchChunk(
2662
+ a.slice(l, l + F),
2663
+ r,
2664
+ { source: c },
2665
+ () => {
2666
+ u += 1;
2667
+ }
2668
+ );
2669
+ P.info("[UserInfoDomain] fetch", {
2670
+ sources: i,
2671
+ prefilled: n,
2672
+ requested: new Set(e.flatMap((l) => l.userIds)).size,
2673
+ missing: a.length,
2674
+ chunks: Math.ceil(a.length / F),
2675
+ failedChunks: u
2676
+ });
2677
+ for (const l of o)
2678
+ l.resolve(
2679
+ l.userIds.map((g) => this.store.getUserInfo(g)).filter((g) => !!g)
2495
2680
  );
2496
2681
  } finally {
2497
2682
  this.fetchFlushPromise = null, this.fetchQueue.length > 0 && this.scheduleFetchFlush();
2498
2683
  }
2499
2684
  }
2685
+ async fetchChunk(e, t, n, o) {
2686
+ this.store.markLoading(e);
2687
+ try {
2688
+ const a = await Fn(() => this.userInfoRepository.fetchUserInfos ? this.fetchFromRepository(e) : this.fetchFromSdk(e, t)), r = new Set(a.map((u) => u.userId).filter(Boolean)), i = e.filter((u) => !r.has(u));
2689
+ i.length > 0 && this.store.markFetchFailed(i), this.store.setUserInfos(a);
2690
+ const c = e.filter((u) => r.has(u));
2691
+ return c.length > 0 && this.store.markFetchedAttributes(c, t), a;
2692
+ } catch (a) {
2693
+ return o == null || o(), P.warn("[UserInfoDomain] chunk failed", {
2694
+ source: (n == null ? void 0 : n.source) ?? "unknown",
2695
+ chunkSize: e.length,
2696
+ ...Bn(a)
2697
+ }), this.store.markFetchFailed(e), [];
2698
+ } finally {
2699
+ this.store.markLoaded(e);
2700
+ }
2701
+ }
2500
2702
  async fetchFromSdk(e, t) {
2501
2703
  const n = await this.client.userInfoManager.getUserInfoByAttribute({
2502
2704
  userIds: e,
@@ -2519,25 +2721,41 @@ class Cn {
2519
2721
  }
2520
2722
  /**
2521
2723
  * 批量订阅陌生人资料变更通知。
2522
- * 同一事件循环内的多次调用会合并为一次 SDK 请求;
2724
+ * 同一事件循环内的多次调用先合批,再按 100 人顺序分片;
2523
2725
  * 若服务端返回无权限,则自动熔断后续订阅并缓存失败用户,避免重复请求与控制台警告刷屏。
2524
2726
  */
2525
- async subscribeUserInfos(e) {
2727
+ async subscribeUserInfos(e, t) {
2526
2728
  if (!this.client.isConnected || this.store.isSubscriptionDisabled())
2527
2729
  return;
2528
- const t = Array.from(new Set(e.filter(Boolean))).filter(
2529
- (n) => !this.store.isSubscribed(n) && !this.store.isSubscribeFailed(n)
2730
+ const n = Array.from(new Set(e.filter(Boolean))).filter(
2731
+ (o) => !this.store.isSubscribed(o) && !this.store.isSubscribeFailed(o)
2530
2732
  );
2531
- if (t.length !== 0)
2532
- return this.subscribeQueue.push(...t), this.subscribeFlushPromise ? this.subscribeFlushPromise : (this.subscribeFlushPromise = Promise.resolve().then(() => this.flushSubscribeQueue()), this.subscribeFlushPromise);
2733
+ if (n.length !== 0)
2734
+ return this.subscribeQueue.push({ userIds: n, options: t }), this.subscribeFlushPromise ? this.subscribeFlushPromise : (this.subscribeFlushPromise = Promise.resolve().then(() => this.flushSubscribeQueue()), this.subscribeFlushPromise);
2533
2735
  }
2534
2736
  async flushSubscribeQueue() {
2535
- const e = Array.from(new Set(this.subscribeQueue));
2737
+ const e = this.subscribeQueue;
2536
2738
  this.subscribeQueue = [];
2739
+ const t = Array.from(new Set(e.flatMap((o) => o.userIds))), n = Array.from(new Set(e.map((o) => {
2740
+ var a;
2741
+ return ((a = o.options) == null ? void 0 : a.source) ?? "unknown";
2742
+ })));
2743
+ P.info("[UserInfoDomain] subscribe", {
2744
+ sources: n,
2745
+ requested: t.length,
2746
+ chunks: Math.ceil(t.length / F)
2747
+ });
2537
2748
  try {
2538
- await this.client.userInfoManager.subscribeUsersInfo({ userIds: e }), this.store.markSubscribed(e);
2539
- } catch (t) {
2540
- this.handleSubscribeError(t, e);
2749
+ for (let o = 0; o < t.length; o += F) {
2750
+ const a = t.slice(o, o + F);
2751
+ try {
2752
+ await this.client.userInfoManager.subscribeUsersInfo({ userIds: a }), this.store.markSubscribed(a);
2753
+ } catch (r) {
2754
+ const i = this.isPermissionError(r);
2755
+ if (this.handleSubscribeError(r, a), i)
2756
+ break;
2757
+ }
2758
+ }
2541
2759
  } finally {
2542
2760
  this.subscribeFlushPromise = null, this.subscribeQueue.length > 0 && (this.subscribeFlushPromise = Promise.resolve().then(() => this.flushSubscribeQueue()));
2543
2761
  }
@@ -2545,30 +2763,28 @@ class Cn {
2545
2763
  handleSubscribeError(e, t) {
2546
2764
  var n;
2547
2765
  if (this.isPermissionError(e)) {
2548
- this.store.markSubscribeFailed(t), this.store.disableSubscription(), this.hasLoggedPermissionError || (this.hasLoggedPermissionError = !0, F.warn(
2766
+ this.store.markSubscribeFailed(t), this.store.disableSubscription(), this.hasLoggedPermissionError || (this.hasLoggedPermissionError = !0, P.warn(
2549
2767
  "[UserInfoDomain] 用户资料订阅无权限或服务未开通,已自动关闭订阅。后续陌生人资料变更将不会实时推送,拉取到的资料仍可正常展示。",
2550
- U(e)
2768
+ L(e)
2551
2769
  ), (n = this.onSubscriptionPermissionError) == null || n.call(this));
2552
2770
  return;
2553
2771
  }
2554
- this.store.markSubscribeFailed(t), F.warn("[UserInfoDomain] subscribeUserInfos failed:", U(e));
2772
+ this.store.markSubscribeFailed(t), P.warn("[UserInfoDomain] subscribeUserInfos failed:", L(e));
2555
2773
  }
2556
2774
  isPermissionError(e) {
2557
2775
  var n, o;
2558
2776
  if (!e || typeof e != "object")
2559
2777
  return !1;
2560
2778
  const t = e;
2561
- return t.code === 210 || ((n = t.details) == null ? void 0 : n.httpStatus) === 403 || ((o = t.details) == null ? void 0 : o.reason) === "service_forbidden";
2779
+ return t.code === 210 || t.code === 1600 || ((n = t.details) == null ? void 0 : n.httpStatus) === 403 || ((o = t.details) == null ? void 0 : o.reason) === "service_forbidden";
2562
2780
  }
2563
2781
  /**
2564
2782
  * 获取当前登录用户自己的资料(默认全量属性,保证签名等登录后回显)。
2565
2783
  */
2566
- async fetchOwnInfo(e = Be) {
2567
- const t = this.client.currentUserId;
2568
- if (!t)
2569
- return;
2570
- const [n] = await this.fetchUserInfos([t], e);
2571
- return n;
2784
+ async fetchOwnInfo(e = Ue, t) {
2785
+ const n = this.client.currentUserId;
2786
+ if (n)
2787
+ return this.client.isConnected ? (!this.store.isLoading(n) && !this.store.isFetchFailed(n) && this.prefillUserInfos([n]), this.store.areAttributesFetched(n, e) || this.store.isLoading(n) || this.store.isFetchFailed(n) ? this.store.getUserInfo(n) : (await this.fetchChunk([n], e, t), this.store.getUserInfo(n))) : (this.store.markFetchFailed([n]), this.store.getUserInfo(n));
2572
2788
  }
2573
2789
  /**
2574
2790
  * 更新当前登录用户资料。
@@ -2579,7 +2795,7 @@ class Cn {
2579
2795
  const t = await this.client.userInfoManager.updateOwnInfo(e);
2580
2796
  return this.store.setUserInfo(t), t;
2581
2797
  } catch (t) {
2582
- F.warn("[UserInfoDomain] updateOwnInfo failed:", U(t));
2798
+ P.warn("[UserInfoDomain] updateOwnInfo failed:", L(t));
2583
2799
  return;
2584
2800
  }
2585
2801
  }
@@ -2592,7 +2808,7 @@ class Cn {
2592
2808
  const n = await this.client.userInfoManager.updateOwnInfoByAttribute(e, t);
2593
2809
  return this.store.setUserInfo(n), n;
2594
2810
  } catch (n) {
2595
- F.warn("[UserInfoDomain] updateOwnInfoByAttribute failed:", U(n));
2811
+ P.warn("[UserInfoDomain] updateOwnInfoByAttribute failed:", L(n));
2596
2812
  return;
2597
2813
  }
2598
2814
  }
@@ -2604,10 +2820,13 @@ class Cn {
2604
2820
  return;
2605
2821
  const t = Array.from(new Set(e.filter(Boolean)));
2606
2822
  if (t.length !== 0)
2607
- try {
2608
- await this.client.userInfoManager.unsubscribeUsersInfo({ userIds: t }), this.store.markUnsubscribed(t);
2609
- } catch (n) {
2610
- F.warn("[UserInfoDomain] unsubscribeUsersInfo failed:", U(n));
2823
+ for (let n = 0; n < t.length; n += F) {
2824
+ const o = t.slice(n, n + F);
2825
+ try {
2826
+ await this.client.userInfoManager.unsubscribeUsersInfo({ userIds: o }), this.store.markUnsubscribed(o);
2827
+ } catch (a) {
2828
+ P.warn("[UserInfoDomain] unsubscribeUsersInfo failed:", L(a));
2829
+ }
2611
2830
  }
2612
2831
  }
2613
2832
  /**
@@ -2619,7 +2838,7 @@ class Cn {
2619
2838
  try {
2620
2839
  return await this.client.userInfoManager.getSubscribedUsers();
2621
2840
  } catch (e) {
2622
- return F.warn("[UserInfoDomain] getSubscribedUsers failed:", U(e)), [];
2841
+ return P.warn("[UserInfoDomain] getSubscribedUsers failed:", L(e)), [];
2623
2842
  }
2624
2843
  }
2625
2844
  /**
@@ -2646,87 +2865,88 @@ class Cn {
2646
2865
  });
2647
2866
  }
2648
2867
  }
2649
- const N = T("UIKit:ConnEvents");
2650
- function wn(s, e = {}) {
2868
+ const D = T("UIKit:ConnEvents");
2869
+ function Kn(s, e = {}) {
2651
2870
  return {
2652
2871
  onConnecting: () => {
2653
- N.info("onConnecting"), s.client.setConnecting(!0);
2872
+ D.info("onConnecting"), s.client.setConnecting(!0);
2654
2873
  },
2655
2874
  onConnected: () => {
2656
- N.info("onConnected"), s.client.setConnected(!0), s.client.setConnecting(!1), s.client.setHasConnectedOnce(!0);
2875
+ var t, n;
2876
+ D.info("onConnected"), s.client.setConnected(!0), s.client.setConnecting(!1), s.client.setHasConnectedOnce(!0), (n = (t = s.userInfo) == null ? void 0 : t.clearFetchFailed) == null || n.call(t);
2657
2877
  },
2658
2878
  onDisconnected: (t) => {
2659
- N.info("onDisconnected", t ? { reason: t.reason, errorCode: t.errorCode } : void 0), s.client.setConnected(!1), s.client.setConnecting(!1), bt(t == null ? void 0 : t.errorCode) && s.client.setKicked(t.errorCode);
2879
+ D.info("onDisconnected", t ? { reason: t.reason, errorCode: t.errorCode } : void 0), s.client.setConnected(!1), s.client.setConnecting(!1), Dt(t == null ? void 0 : t.errorCode) && s.client.setKicked(t.errorCode);
2660
2880
  },
2661
2881
  onReconnectFailed: () => {
2662
- N.info("onReconnectFailed"), s.client.setConnecting(!1), N.error("Auto-reconnect failed after max retries");
2882
+ D.info("onReconnectFailed"), s.client.setConnecting(!1), D.error("Auto-reconnect failed after max retries");
2663
2883
  },
2664
2884
  onTokenWillExpire: () => {
2665
2885
  var t;
2666
- N.info("onTokenWillExpire"), N.warn("Token will expire"), (t = e.onTokenWillExpire) == null || t.call(e);
2886
+ D.info("onTokenWillExpire"), D.warn("Token will expire"), (t = e.onTokenWillExpire) == null || t.call(e);
2667
2887
  },
2668
2888
  onTokenExpired: () => {
2669
2889
  var t;
2670
- N.info("onTokenExpired"), N.error("Token expired"), (t = e.onTokenExpired) == null || t.call(e);
2890
+ D.info("onTokenExpired"), D.error("Token expired"), (t = e.onTokenExpired) == null || t.call(e);
2671
2891
  },
2672
2892
  onOfflineMessageSyncStart: () => {
2673
- N.info("onOfflineMessageSyncStart"), s.conversation.conversationsLoaded || s.message.setSyncingMessages(!0);
2893
+ D.info("onOfflineMessageSyncStart"), s.conversation.conversationsLoaded || s.message.setSyncingMessages(!0);
2674
2894
  },
2675
2895
  onOfflineMessageSyncFinish: () => {
2676
- N.info("onOfflineMessageSyncFinish"), s.message.setSyncingMessages(!1);
2896
+ D.info("onOfflineMessageSyncFinish"), s.message.setSyncingMessages(!1);
2677
2897
  }
2678
2898
  };
2679
2899
  }
2680
- const st = T("UIKit:SyncStatus"), z = Gt({
2900
+ const gt = T("UIKit:SyncStatus"), Y = Pt({
2681
2901
  conversation: { status: "idle" },
2682
2902
  contact: { status: "idle" },
2683
2903
  group: { status: "idle" }
2684
2904
  });
2685
- let ne = null;
2686
- function Sn(s) {
2687
- return ne = s, () => {
2688
- ne = null;
2905
+ let re = null;
2906
+ function qn(s) {
2907
+ return re = s, () => {
2908
+ re = null;
2689
2909
  };
2690
2910
  }
2691
- function be(s, e) {
2692
- const t = z[s];
2693
- t.status = e.status, e.finishedAt !== void 0 && (t.finishedAt = e.finishedAt), e.error !== void 0 && (t.error = e.error), st.info(`sync ${s} -> ${e.status}`, e.error ? { stage: e.error.stage, retryable: e.error.retryable, message: e.error.message } : void 0), ne == null || ne({
2911
+ function Re(s, e) {
2912
+ const t = Y[s];
2913
+ t.status = e.status, e.finishedAt !== void 0 && (t.finishedAt = e.finishedAt), e.error !== void 0 && (t.error = e.error), gt.info(`sync ${s} -> ${e.status}`, e.error ? { stage: e.error.stage, retryable: e.error.retryable, message: e.error.message } : void 0), re == null || re({
2694
2914
  type: s,
2695
2915
  status: e.status === "idle" ? "syncing" : e.status,
2696
2916
  error: e.error
2697
2917
  });
2698
2918
  }
2699
- function An() {
2700
- const s = Object.keys(z);
2919
+ function jn() {
2920
+ const s = Object.keys(Y);
2701
2921
  for (const e of s)
2702
- z[e] = { status: "idle" };
2703
- st.info("sync status reset(事件反注册/登出)");
2704
- }
2705
- function es() {
2706
- const s = me(() => ({ ...z })), e = me(
2707
- () => Object.values(z).some((n) => n.status === "syncing")
2708
- ), t = me(
2709
- () => Object.values(z).every((n) => n.status === "success" || n.status === "failed")
2922
+ Y[e] = { status: "idle" };
2923
+ gt.info("sync status reset(事件反注册/登出)");
2924
+ }
2925
+ function bs() {
2926
+ const s = Me(() => ({ ...Y })), e = Me(
2927
+ () => Object.values(Y).some((n) => n.status === "syncing")
2928
+ ), t = Me(
2929
+ () => Object.values(Y).every((n) => n.status === "success" || n.status === "failed")
2710
2930
  );
2711
2931
  return { status: s, isSyncing: e, allFinished: t };
2712
2932
  }
2713
- let Ee = null;
2714
- function rt(s) {
2715
- Ee = s;
2933
+ let Oe = null;
2934
+ function mt(s) {
2935
+ Oe = s;
2716
2936
  }
2717
- function B() {
2718
- if (!Ee)
2937
+ function K() {
2938
+ if (!Oe)
2719
2939
  throw new Error(
2720
2940
  "[UIKit] 事件层依赖未注入:请在调用 registerEventHandlers 前先执行 setEventHandlerDeps()"
2721
2941
  );
2722
- return Ee;
2942
+ return Oe;
2723
2943
  }
2724
- const Gn = T("UIKit:Websdk5Adapter");
2725
- function En() {
2944
+ const Vn = T("UIKit:Websdk5Adapter");
2945
+ function Wn() {
2726
2946
  try {
2727
- B();
2947
+ K();
2728
2948
  } catch {
2729
- Gn.warn("[Websdk5Adapter] 事件层依赖未注入,使用最小兜底实现"), rt({
2949
+ Vn.warn("[Websdk5Adapter] 事件层依赖未注入,使用最小兜底实现"), mt({
2730
2950
  t: (s) => s,
2731
2951
  insertChatNotice: () => {
2732
2952
  },
@@ -2750,7 +2970,7 @@ function En() {
2750
2970
  });
2751
2971
  }
2752
2972
  }
2753
- function Tn(s, e) {
2973
+ function Jn(s, e) {
2754
2974
  const t = s.contact.getContact(e);
2755
2975
  if (t != null && t.remark)
2756
2976
  return t.remark;
@@ -2758,7 +2978,7 @@ function Tn(s, e) {
2758
2978
  if (n != null && n.nickname)
2759
2979
  return n.nickname;
2760
2980
  }
2761
- function ot(s, e) {
2981
+ function pt(s, e) {
2762
2982
  var r;
2763
2983
  const t = e.from || "", n = s.contact.getContact(t);
2764
2984
  if (n != null && n.remark)
@@ -2769,158 +2989,206 @@ function ot(s, e) {
2769
2989
  const a = (r = e.ext) == null ? void 0 : r.ease_chat_uikit_user_info;
2770
2990
  return a != null && a.nickname ? a.nickname : a != null && a.remark ? a.remark : t;
2771
2991
  }
2772
- function Rn(s, e) {
2773
- var u;
2774
- const { useNotification: t, emitNotificationDelivered: n } = B(), { state: o, notify: a, notifyBrowser: r } = t();
2775
- if (!o.value.enabled || E(e.from) === E(s.client.currentUser) || e.conversationId === s.conversation.currentConversationId)
2992
+ function $n(s, e) {
2993
+ var d;
2994
+ const { useNotification: t, emitNotificationDelivered: n } = K(), { state: o, notify: a, notifyBrowser: r } = t();
2995
+ if (!o.value.enabled || G(e.from) === G(s.client.currentUser) || e.conversationId === s.conversation.currentConversationId)
2776
2996
  return;
2777
- const i = s.conversation.conversationList.find((l) => l.id === e.conversationId);
2997
+ const i = s.conversation.conversationList.find((f) => f.id === e.conversationId);
2778
2998
  if (i != null && i.isMuted)
2779
2999
  return;
2780
3000
  const c = typeof document > "u" || document.visibilityState === "hidden";
2781
3001
  if (o.value.triggerMode === "background" && !c)
2782
3002
  return;
2783
- const d = P(e, s.client.currentUser), g = ot(s, d), m = d.conversationType === M.GROUPCHAT, p = {
3003
+ const u = H(e, s.client.currentUser), l = pt(s, u), g = u.conversationType === I.GROUPCHAT, p = {
2784
3004
  // 群聊标题为群名(正文含 "发送者: 内容" 前缀),单聊标题为发送者名
2785
- title: m && (i == null ? void 0 : i.name) || g,
2786
- body: Ct(d, void 0, g, void 0, Ue),
3005
+ title: g && (i == null ? void 0 : i.name) || l,
3006
+ body: Nt(u, void 0, l, void 0, Be),
2787
3007
  // 群聊用群头像,单聊用发送者头像
2788
- avatar: m ? i == null ? void 0 : i.avatar : (u = s.userInfo.getUserInfo(e.from)) == null ? void 0 : u.avatarUrl,
2789
- timestamp: d.timestamp || Date.now(),
3008
+ avatar: g ? i == null ? void 0 : i.avatar : (d = s.userInfo.getUserInfo(e.from)) == null ? void 0 : d.avatarUrl,
3009
+ timestamp: u.timestamp || Date.now(),
2790
3010
  conversationId: e.conversationId,
2791
- conversationType: d.conversationType
3011
+ conversationType: u.conversationType
2792
3012
  };
2793
- c && o.value.browserEnabled ? r(p).then((l) => {
2794
- l ? n(p, "browser") : o.value.inAppEnabled && (a(p), n(p, "in-app"));
3013
+ c && o.value.browserEnabled ? r(p).then((f) => {
3014
+ f ? n(p, "browser") : o.value.inAppEnabled && (a(p), n(p, "in-app"));
2795
3015
  }) : o.value.inAppEnabled && (a(p), n(p, "in-app"));
2796
3016
  }
2797
- function Fe(s, e, t) {
2798
- const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } = B(), { state: i, notify: c, notifyBrowser: d } = o();
3017
+ function Qe(s, e, t) {
3018
+ const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } = K(), { state: i, notify: c, notifyBrowser: u } = o();
2799
3019
  if (!i.value.enabled)
2800
3020
  return;
2801
- const g = s.userInfo.getUserInfo(e), m = {
2802
- title: r(g) || e,
3021
+ const l = s.userInfo.getUserInfo(e), g = {
3022
+ title: r(l) || e,
2803
3023
  body: n(t === "declined" ? "contact.inviteDeclinedByPeer" : "chat.notice.contactDeleted"),
2804
- avatar: g == null ? void 0 : g.avatarUrl,
3024
+ avatar: l == null ? void 0 : l.avatarUrl,
2805
3025
  timestamp: Date.now(),
2806
3026
  conversationId: e,
2807
- conversationType: M.SINGLECHAT
3027
+ conversationType: I.SINGLECHAT
2808
3028
  };
2809
- (typeof document > "u" || document.visibilityState === "hidden") && i.value.browserEnabled ? d(m).then((u) => {
2810
- u ? a(m, "browser") : i.value.inAppEnabled && (c(m), a(m, "in-app"));
2811
- }) : i.value.inAppEnabled && (c(m), a(m, "in-app"));
3029
+ (typeof document > "u" || document.visibilityState === "hidden") && i.value.browserEnabled ? u(g).then((d) => {
3030
+ d ? a(g, "browser") : i.value.inAppEnabled && (c(g), a(g, "in-app"));
3031
+ }) : i.value.inAppEnabled && (c(g), a(g, "in-app"));
2812
3032
  }
2813
- const y = T("UIKit:ChatEvents"), le = /* @__PURE__ */ new Set(), Te = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Map();
2814
- let ge = !1;
2815
- function Un() {
2816
- le.clear(), Te.clear(), $.clear(), ge = !1;
3033
+ const Qn = 20, zn = 2;
3034
+ function ze(s) {
3035
+ return `${s.conversationType}:${s.conversationId}`;
2817
3036
  }
2818
- function Ln(s, e, t, n) {
3037
+ async function Yn(s) {
3038
+ const e = s.batchSize ?? Qn, t = Math.max(1, s.concurrency ?? zn), n = s.targets.filter((c) => !s.queried.has(ze(c)));
3039
+ if (n.length === 0 || e <= 0)
3040
+ return { queriedCount: 0, batchCount: 0, failedBatchCount: 0 };
3041
+ const o = [];
3042
+ for (let c = 0; c < n.length; c += e)
3043
+ o.push(n.slice(c, c + e));
3044
+ let a = 0, r = 0;
3045
+ async function i() {
3046
+ var c;
3047
+ for (; a < o.length; ) {
3048
+ const u = o[a];
3049
+ a += 1;
3050
+ try {
3051
+ const l = await s.query(u);
3052
+ for (const g of l)
3053
+ s.apply(g);
3054
+ for (const g of u)
3055
+ s.queried.add(ze(g));
3056
+ } catch (l) {
3057
+ r += 1, (c = s.onError) == null || c.call(s, l, u);
3058
+ }
3059
+ }
3060
+ }
3061
+ return await Promise.all(Array.from({ length: Math.min(t, o.length) }, () => i())), { queriedCount: n.length, batchCount: o.length, failedBatchCount: r };
3062
+ }
3063
+ const y = T("UIKit:ChatEvents"), ge = /* @__PURE__ */ new Set(), xe = /* @__PURE__ */ new Set(), ht = /* @__PURE__ */ new Set();
3064
+ let me = !1, pe = !1;
3065
+ const Q = /* @__PURE__ */ new Map();
3066
+ let he = !1;
3067
+ function Xn() {
3068
+ ge.clear(), xe.clear(), ht.clear(), me = !1, pe = !1, Q.clear(), he = !1;
3069
+ }
3070
+ function Zn(s, e, t, n) {
2819
3071
  if (!n)
2820
3072
  return;
2821
- const o = `${e}:${t}`, a = $.get(o) || [];
2822
- a.push(n), $.set(o, a), !ge && (ge = !0, Promise.resolve().then(async () => {
2823
- for (ge = !1; $.size > 0; ) {
2824
- const r = Array.from($.entries());
2825
- $.clear();
3073
+ const o = `${e}:${t}`, a = Q.get(o) || [];
3074
+ a.push(n), Q.set(o, a), !he && (he = !0, Promise.resolve().then(async () => {
3075
+ for (he = !1; Q.size > 0; ) {
3076
+ const r = Array.from(Q.entries());
3077
+ Q.clear();
2826
3078
  for (const [i, c] of r) {
2827
- const [d, g] = i.split(":");
2828
- for (let m = 0; m < c.length; m += 50) {
2829
- const p = c.slice(m, m + 50);
2830
- y.info("[queueMessageReadReceipt] 批量发送已读回执", { conversationType: d, conversationId: g, batchSize: p.length, messageIds: p });
3079
+ const [u, l] = i.split(":");
3080
+ for (let g = 0; g < c.length; g += 50) {
3081
+ const p = c.slice(g, g + 50);
3082
+ y.info("[queueMessageReadReceipt] 批量发送已读回执", { conversationType: u, conversationId: l, batchSize: p.length, messageIds: p });
2831
3083
  try {
2832
3084
  await s.chatManager.sendMessageReadReceipts({
2833
- conversationId: g,
2834
- conversationType: d,
3085
+ conversationId: l,
3086
+ conversationType: u,
2835
3087
  messageIds: p
2836
- }), an(p), y.info("[queueMessageReadReceipt] 已读回执发送成功", { conversationType: d, conversationId: g, messageIds: p });
2837
- } catch (u) {
2838
- y.warn("[queueMessageReadReceipt] sendMessageReadReceipts failed:", { conversationType: d, conversationId: g, messageIds: p, err: u });
3088
+ }), Cn(p), y.info("[queueMessageReadReceipt] 已读回执发送成功", { conversationType: u, conversationId: l, messageIds: p });
3089
+ } catch (d) {
3090
+ y.warn("[queueMessageReadReceipt] sendMessageReadReceipts failed:", { conversationType: u, conversationId: l, messageIds: p, err: d });
2839
3091
  }
2840
3092
  }
2841
3093
  }
2842
3094
  }
2843
3095
  }));
2844
3096
  }
2845
- async function Dn(s, e) {
2846
- const t = s.conversation.conversationList.map((n) => ({
2847
- conversationId: n.id,
2848
- conversationType: n.type
2849
- }));
2850
- if (t.length !== 0)
2851
- for (let n = 0; n < t.length; n += 20)
2852
- try {
2853
- const o = await e.pushManager.getConversationSilentModes({
2854
- conversationList: t.slice(n, n + 20)
2855
- });
2856
- for (const a of o.conversations) {
2857
- const r = a.rule.remindType === "NONE" || a.rule.expireTimestamp !== void 0 && a.rule.expireTimestamp > Date.now(), i = s.conversation.conversationList.find((c) => c.id === a.conversationId);
2858
- i && i.isMuted !== r && s.conversation.updateConversation(a.conversationId, {
2859
- isMuted: r,
2860
- remindType: a.rule.remindType ?? (r ? "NONE" : "DEFAULT")
3097
+ async function es(s, e) {
3098
+ if (me) {
3099
+ pe = !0;
3100
+ return;
3101
+ }
3102
+ me = !0;
3103
+ try {
3104
+ do {
3105
+ pe = !1;
3106
+ const t = Date.now(), n = [];
3107
+ for (const i of s.conversation.conversationList)
3108
+ i.type === I.SINGLECHAT ? n.push({ conversationId: i.id, conversationType: I.SINGLECHAT }) : i.type === I.GROUPCHAT && n.push({ conversationId: i.id, conversationType: I.GROUPCHAT });
3109
+ const { queriedCount: o, batchCount: a, failedBatchCount: r } = await Yn({
3110
+ targets: n,
3111
+ queried: ht,
3112
+ query: async (i) => (await e.pushManager.getConversationSilentModes({ conversationList: i })).conversations,
3113
+ apply: (i) => {
3114
+ const c = i.rule.remindType === "NONE" || i.rule.expireTimestamp !== void 0 && i.rule.expireTimestamp > Date.now(), u = s.conversation.conversationList.find((l) => l.id === i.conversationId);
3115
+ u && u.isMuted !== c && s.conversation.updateConversation(i.conversationId, {
3116
+ isMuted: c,
3117
+ remindType: i.rule.remindType ?? (c ? "NONE" : "DEFAULT")
2861
3118
  });
2862
- }
2863
- } catch (o) {
2864
- y.warn("patch conversation mute states failed:", o);
2865
- }
3119
+ },
3120
+ onError: (i) => y.warn("patch conversation mute states failed:", i)
3121
+ });
3122
+ a > 0 && y.info("patch conversation mute states", {
3123
+ conversations: n.length,
3124
+ queried: o,
3125
+ batches: a,
3126
+ failedBatches: r,
3127
+ durationMs: Date.now() - t
3128
+ });
3129
+ } while (pe);
3130
+ } finally {
3131
+ me = !1;
3132
+ }
2866
3133
  }
2867
- async function oe(s, e) {
3134
+ async function ae(s, e) {
2868
3135
  const t = new Map(s.group.groupList.map((o) => [o.groupId, o.groupName])), n = [];
2869
3136
  for (const o of s.conversation.conversationList)
2870
- if ((!o.name || o.name === o.id) && !Te.has(o.id)) {
2871
- if (o.type === M.GROUPCHAT) {
3137
+ if ((!o.name || o.name === o.id) && !xe.has(o.id)) {
3138
+ if (o.type === I.GROUPCHAT) {
2872
3139
  const r = t.get(o.id);
2873
- r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) : le.has(o.id) || n.push(o.id);
2874
- } else if (o.type === M.SINGLECHAT) {
3140
+ r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) : ge.has(o.id) || n.push(o.id);
3141
+ } else if (o.type === I.SINGLECHAT) {
2875
3142
  const r = s.contact.getContact(o.id), i = s.userInfo.getUserInfo(o.id), c = (r == null ? void 0 : r.remark) || (r == null ? void 0 : r.name) || (i == null ? void 0 : i.nickname);
2876
3143
  c && s.conversation.updateConversation(o.id, { name: c });
2877
3144
  }
2878
3145
  }
2879
3146
  if (n.length !== 0) {
2880
3147
  for (const o of n)
2881
- le.add(o), Te.add(o);
3148
+ ge.add(o), xe.add(o);
2882
3149
  try {
2883
- const o = await e.groupManager.getGroupInfoList({ groupIds: n }), a = fe(o);
3150
+ const o = await e.groupManager.getGroupInfoList({ groupIds: n }), a = Ie(o);
2884
3151
  for (const r of a)
2885
3152
  s.group.updateGroup(r.groupId, r), r.groupName && r.groupName !== r.groupId && s.conversation.updateConversation(r.groupId, { name: r.groupName });
2886
3153
  } catch (o) {
2887
3154
  y.warn("fetch missing group names failed:", o);
2888
3155
  } finally {
2889
- for (const o of n) le.delete(o);
3156
+ for (const o of n) ge.delete(o);
2890
3157
  }
2891
3158
  }
2892
3159
  }
2893
- function _n(s, e, t, n) {
3160
+ function ts(s, e, t, n) {
2894
3161
  const o = s.message.getMessages(e), a = o.findIndex(
2895
- (m) => m.msgServerId === n || m.msgLocalId === n
3162
+ (p) => p.msgServerId === n || p.msgLocalId === n
2896
3163
  );
2897
3164
  if (a === -1 || a !== o.length - 1)
2898
3165
  return;
2899
- const r = o[a], i = s.conversation.conversationList.find((m) => m.id === e);
3166
+ const r = o[a], i = s.conversation.conversationList.find((p) => p.id === e);
2900
3167
  if (!i || i.lastMessageTime && r.timestamp < i.lastMessageTime - 1e3)
2901
3168
  return;
2902
- const d = t === M.GROUPCHAT ? ot(s, r) : void 0, { t: g } = B();
3169
+ const u = t === I.GROUPCHAT ? G(r.from || "") : "", l = u ? pt(s, { ...r, from: u }) : void 0, { t: g } = K();
2903
3170
  s.conversation.updateConversation(e, {
2904
- lastMessageText: Xe(
3171
+ lastMessageText: ct(
2905
3172
  t,
2906
- d,
3173
+ l,
2907
3174
  g("message.recalledPreview")
2908
- )
3175
+ ),
3176
+ ...u ? { lastMessageFrom: u, lastMessageSenderName: l } : {}
2909
3177
  });
2910
3178
  }
2911
- function x(s) {
3179
+ function B(s) {
2912
3180
  Promise.resolve().then(s).catch((e) => y.warn("persistence 钩子执行失败(已忽略):", e));
2913
3181
  }
2914
- function He(s, e) {
3182
+ function Ye(s, e) {
2915
3183
  const t = s.conversation.conversationList, n = new Set(e.map((r) => r.id)), o = e.map((r) => {
2916
- const i = t.find((g) => g.id === r.id);
3184
+ const i = t.find((l) => l.id === r.id);
2917
3185
  if (!i)
2918
3186
  return r;
2919
- const c = (!r.name || r.name === r.id) && i.name && i.name !== i.id, d = !r.avatar && i.avatar;
3187
+ const c = (!r.name || r.name === r.id) && i.name && i.name !== i.id, u = !r.avatar && i.avatar;
2920
3188
  return {
2921
3189
  ...r,
2922
3190
  name: c ? i.name : r.name,
2923
- avatar: d ? i.avatar : r.avatar,
3191
+ avatar: u ? i.avatar : r.avatar,
2924
3192
  // SDK 快照不携带的本地字段保留(草稿)
2925
3193
  draft: r.draft ?? i.draft,
2926
3194
  draftTime: r.draftTime ?? i.draftTime,
@@ -2932,119 +3200,119 @@ function He(s, e) {
2932
3200
  }), a = t.filter((r) => !n.has(r.id)).sort((r, i) => (i.lastMessageTime ?? 0) - (r.lastMessageTime ?? 0));
2933
3201
  return [...o, ...a];
2934
3202
  }
2935
- function Nn(s, e, t, n, o) {
3203
+ function ns(s, e, t, n, o) {
2936
3204
  var p;
2937
- const a = (u) => Tn(e, u), {
3205
+ const a = (d) => Jn(e, d), {
2938
3206
  saveMessage: r,
2939
3207
  updateMessageStatus: i,
2940
3208
  markMessageRecalled: c,
2941
- updateMessageContent: d,
2942
- deleteMessages: g
2943
- } = (n == null ? void 0 : n.message) ?? {}, m = (p = n == null ? void 0 : n.conversation) == null ? void 0 : p.saveConversations;
3209
+ updateMessageContent: u,
3210
+ deleteMessages: l
3211
+ } = (n == null ? void 0 : n.message) ?? {}, g = (p = n == null ? void 0 : n.conversation) == null ? void 0 : p.saveConversations;
2944
3212
  return {
2945
- onSyncDataStart: (u) => {
2946
- y.info("onSyncDataStart", { dataType: u.dataType }), be(u.dataType, { status: "syncing" }), u.dataType === "conversation" && e.conversation.setSyncingConversations(!0);
3213
+ onSyncDataStart: (d) => {
3214
+ y.info("onSyncDataStart", { dataType: d.dataType }), Re(d.dataType, { status: "syncing" }), d.dataType === "conversation" && e.conversation.setSyncingConversations(!0);
2947
3215
  },
2948
- onSyncDataFinished: (u) => {
2949
- if (y.info("onSyncDataFinished", { dataType: u.dataType, status: u.status }), u.status === "failed") {
2950
- const l = u.error;
2951
- be(u.dataType, {
3216
+ onSyncDataFinished: (d) => {
3217
+ if (y.info("onSyncDataFinished", { dataType: d.dataType, status: d.status }), d.status === "failed") {
3218
+ const f = d.error;
3219
+ Re(d.dataType, {
2952
3220
  status: "failed",
2953
3221
  finishedAt: Date.now(),
2954
3222
  error: {
2955
- stage: l == null ? void 0 : l.stage,
2956
- retryable: l == null ? void 0 : l.retryable,
2957
- message: l == null ? void 0 : l.message
3223
+ stage: f == null ? void 0 : f.stage,
3224
+ retryable: f == null ? void 0 : f.retryable,
3225
+ message: f == null ? void 0 : f.message
2958
3226
  }
2959
3227
  }), y.warn("[ChatEvents] 数据同步失败", {
2960
- dataType: u.dataType,
2961
- stage: l == null ? void 0 : l.stage,
2962
- retryable: l == null ? void 0 : l.retryable,
2963
- message: l == null ? void 0 : l.message
2964
- }), u.dataType === "conversation" && (e.conversation.setSyncingConversations(!1), l != null && l.retryable && s.chatManager.refreshSessionList().catch((f) => {
2965
- y.warn("[ChatEvents] conversation 同步失败重试未成功:", U(f));
3228
+ dataType: d.dataType,
3229
+ stage: f == null ? void 0 : f.stage,
3230
+ retryable: f == null ? void 0 : f.retryable,
3231
+ message: f == null ? void 0 : f.message
3232
+ }), d.dataType === "conversation" && (e.conversation.setSyncingConversations(!1), f != null && f.retryable && s.chatManager.refreshSessionList().catch((m) => {
3233
+ y.warn("[ChatEvents] conversation 同步失败重试未成功:", L(m));
2966
3234
  }));
2967
3235
  return;
2968
3236
  }
2969
- switch (be(u.dataType, { status: "success", finishedAt: Date.now() }), u.dataType) {
3237
+ switch (Re(d.dataType, { status: "success", finishedAt: Date.now() }), d.dataType) {
2970
3238
  case "conversation":
2971
3239
  e.conversation.setSyncingConversations(!1);
2972
3240
  {
2973
- const l = s.chatManager.getConversationList().filter((v) => v.conversationType !== "chatRoom");
2974
- y.info("getConversationList raw (onSyncDataFinished)", l);
2975
- const f = te(l, { resolveSenderName: a, lastMessageTextResolver: o }), h = He(e, f);
2976
- e.conversation.setConversationList(h), y.info("conversation 同步回填", { count: h.length }), m && x(() => m(h.map(_e)));
3241
+ const f = s.chatManager.getConversationList().filter((v) => v.conversationType !== "chatRoom");
3242
+ ve(y, "onSyncDataFinished", f);
3243
+ const m = se(f, { resolveSenderName: a, lastMessageTextResolver: o }), h = Ye(e, m);
3244
+ e.conversation.setConversationList(h), y.info("conversation 同步回填", { count: h.length }), g && B(() => g(h.map(Ke)));
2977
3245
  }
2978
- e.conversation.setConversationsLoaded(!0), oe(e, s), Dn(e, s);
3246
+ e.conversation.setConversationsLoaded(!0), ae(e, s), es(e, s);
2979
3247
  break;
2980
3248
  case "contact":
2981
3249
  if (!e.contact.loaded || e.contact.contactList.length === 0) {
2982
- const l = s.contactManager.getContacts();
2983
- e.contact.setContactList(Ge(l)), y.info("contact 同步回填", { count: l.length });
3250
+ const f = s.contactManager.getContacts();
3251
+ e.contact.setContactList(ke(f)), y.info("contact 同步回填", { count: f.length });
2984
3252
  } else
2985
3253
  y.info("contact 同步回填跳过(列表已由业务方填充)", { count: e.contact.contactList.length });
2986
- oe(e, s);
3254
+ ae(e, s);
2987
3255
  break;
2988
3256
  case "group":
2989
3257
  if (!e.group.loaded || e.group.groupList.length === 0) {
2990
- const l = s.groupManager.getJoinedGroupList();
2991
- e.group.setGroupList(fe(l)), y.info("group 同步回填", { count: l.length });
3258
+ const f = s.groupManager.getJoinedGroupList();
3259
+ e.group.setGroupList(Ie(f)), y.info("group 同步回填", { count: f.length });
2992
3260
  } else
2993
3261
  y.info("group 同步回填跳过(列表已由业务方填充)", { count: e.group.groupList.length });
2994
- oe(e, s);
3262
+ ae(e, s);
2995
3263
  break;
2996
3264
  }
2997
3265
  },
2998
- onConversationListUpdate: (u) => {
3266
+ onConversationListUpdate: (d) => {
2999
3267
  var w;
3000
- const l = u.items.filter((I) => I.conversationType !== "chatRoom");
3001
- y.info("onConversationListUpdate", { count: l.length, reset: u.patch.reset, removed: u.patch.removed.length }), y.info("getConversationList raw (onConversationListUpdate)", l);
3268
+ const f = d.items.filter((M) => M.conversationType !== "chatRoom");
3269
+ y.info("onConversationListUpdate", { count: f.length, reset: d.patch.reset, removed: d.patch.removed.length }), ve(y, "onConversationListUpdate", f);
3002
3270
  {
3003
- const I = {}, G = [];
3004
- for (const q of l) {
3005
- const R = String(((w = q.lastMessage) == null ? void 0 : w.type) ?? "(null)");
3006
- I[R] = (I[R] ?? 0) + 1, (R === C.COMBINE || R === "unknown") && G.push({ conversationId: q.conversationId, lastMessage: q.lastMessage });
3271
+ const M = {}, A = [];
3272
+ for (const J of f) {
3273
+ const X = String(((w = J.lastMessage) == null ? void 0 : w.type) ?? "(null)");
3274
+ M[X] = (M[X] ?? 0) + 1, (X === b.COMBINE || X === "unknown") && A.push({ conversationId: J.conversationId, lastMessage: J.lastMessage });
3007
3275
  }
3008
- G.length > 0 && y.info("raw snippets (onConversationListUpdate)", { typeCount: I, suspects: G });
3276
+ A.length > 0 && y.info("raw snippets (onConversationListUpdate)", { typeCount: M, suspects: A });
3009
3277
  }
3010
- const f = te(l, { resolveSenderName: a, lastMessageTextResolver: o }), h = He(e, f), v = new Set(u.patch.removed.map((I) => I.conversationId)), b = v.size > 0 ? h.filter((I) => !v.has(I.id)) : h;
3011
- if (u.patch.reset || u.patch.removed.length > 0)
3012
- e.conversation.setConversationList(b);
3278
+ const m = se(f, { resolveSenderName: a, lastMessageTextResolver: o }), h = Ye(e, m), v = new Set(d.patch.removed.map((M) => M.conversationId)), C = v.size > 0 ? h.filter((M) => !v.has(M.id)) : h;
3279
+ if (d.patch.reset || d.patch.removed.length > 0)
3280
+ e.conversation.setConversationList(C);
3013
3281
  else
3014
- for (const I of b) {
3015
- const G = e.conversation.conversationList.find((q) => q.id === I.id);
3016
- G ? G !== I && e.conversation.updateConversation(I.id, I) : e.conversation.addConversation(I);
3282
+ for (const M of C) {
3283
+ const A = e.conversation.conversationList.find((J) => J.id === M.id);
3284
+ A ? A !== M && e.conversation.updateConversation(M.id, M) : e.conversation.addConversation(M);
3017
3285
  }
3018
- m && x(() => m(b.map(_e))), oe(e, s);
3286
+ g && B(() => g(C.map(Ke))), ae(e, s);
3019
3287
  },
3020
- onMessage: (u) => {
3021
- var b, w, I;
3022
- if (u.conversationType === "chatRoom")
3288
+ onMessage: (d) => {
3289
+ var C, w, M;
3290
+ if (d.conversationType === "chatRoom")
3023
3291
  return;
3024
- if (u.type === C.CMD) {
3025
- const G = u.body.action;
3292
+ if (d.type === b.CMD) {
3293
+ const A = d.body.action;
3026
3294
  y.info("[CMD received]", {
3027
- conversationId: u.conversationId,
3028
- from: u.from,
3029
- action: G,
3030
- ext: u.ext
3031
- }), G === "TypingBegin" && (t == null ? void 0 : t.enableTyping) !== !1 && u.conversationType === M.SINGLECHAT && E(u.from) !== E(e.client.currentUser) && e.conversation.setTyping(u.conversationId, u.from);
3295
+ conversationId: d.conversationId,
3296
+ from: d.from,
3297
+ action: A,
3298
+ ext: d.ext
3299
+ }), A === "TypingBegin" && (t == null ? void 0 : t.enableTyping) !== !1 && d.conversationType === I.SINGLECHAT && G(d.from) !== G(e.client.currentUser) && e.conversation.setTyping(d.conversationId, d.from);
3032
3300
  return;
3033
3301
  }
3034
- y.info("onMessage", { conversationId: u.conversationId, from: u.from, type: u.type });
3035
- const l = P(u, e.client.currentUser), f = e.message.getMessages(u.conversationId).find((G) => G.msgServerId === u.msgServerId);
3036
- f != null && f.stream && wt(f.stream.status) ? e.message.replaceMessageById(u.msgServerId, l) : e.message.addMessage(l), l.type === C.VOICE && !l.isSelf && ((w = (b = e.message).markVoiceUnplayed) == null || w.call(b, l.msgServerId || l.msgLocalId)), r && x(() => r(we(u)));
3302
+ y.info("onMessage", { conversationId: d.conversationId, from: d.from, type: d.type });
3303
+ const f = H(d, e.client.currentUser), m = e.message.getMessages(d.conversationId).find((A) => A.msgServerId === d.msgServerId);
3304
+ m != null && m.stream && kt(m.stream.status) ? e.message.replaceMessageById(d.msgServerId, f) : e.message.addMessage(f), f.type === b.VOICE && !f.isSelf && ((w = (C = e.message).markVoiceUnplayed) == null || w.call(C, f.msgServerId || f.msgLocalId)), r && B(() => r(_e(d)));
3037
3305
  const h = e.conversation.currentConversationId, v = typeof document > "u" || document.visibilityState === "visible";
3038
- if (h && u.conversationId === h && E(u.from) !== E(e.client.currentUser) && v && (s.chatManager.clearConversationUnreadMessageCount({
3039
- conversationId: u.conversationId,
3040
- conversationType: u.conversationType
3041
- }).catch((G) => {
3042
- y.warn("[UIKit] auto clearConversationUnreadMessageCount failed:", U(G));
3043
- }), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (u.conversationType === M.SINGLECHAT || u.conversationType === M.GROUPCHAT) && Ln(s, u.conversationType, u.conversationId, u.msgServerId)), (t == null ? void 0 : t.enableAtMe) !== !1 && u.conversationType === M.GROUPCHAT && E(u.from) !== E(e.client.currentUser)) {
3044
- const G = (I = u.ext) == null ? void 0 : I.em_at_list;
3045
- Array.isArray(G) && G.includes(e.client.currentUser) && (e.conversation.setAtMe(u.conversationId, !0), e.message.addAtMeMessage(u.conversationId, l.msgServerId || l.msgLocalId));
3306
+ if (h && d.conversationId === h && G(d.from) !== G(e.client.currentUser) && v && (s.chatManager.clearConversationUnreadMessageCount({
3307
+ conversationId: d.conversationId,
3308
+ conversationType: d.conversationType
3309
+ }).catch((A) => {
3310
+ y.warn("[UIKit] auto clearConversationUnreadMessageCount failed:", L(A));
3311
+ }), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (d.conversationType === I.SINGLECHAT || d.conversationType === I.GROUPCHAT) && Zn(s, d.conversationType, d.conversationId, d.msgServerId)), (t == null ? void 0 : t.enableAtMe) !== !1 && d.conversationType === I.GROUPCHAT && G(d.from) !== G(e.client.currentUser)) {
3312
+ const A = (M = d.ext) == null ? void 0 : M.em_at_list;
3313
+ Array.isArray(A) && A.includes(e.client.currentUser) && (e.conversation.setAtMe(d.conversationId, !0), e.message.addAtMeMessage(d.conversationId, f.msgServerId || f.msgLocalId));
3046
3314
  }
3047
- Rn(e, u);
3315
+ $n(e, d);
3048
3316
  },
3049
3317
  /**
3050
3318
  * 流式消息(边生成边下发,典型 AI 对话)分片合并。
@@ -3054,141 +3322,141 @@ function Nn(s, e, t, n, o) {
3054
3322
  * - `stream` 状态整体挂载到消息上,供渲染层展示传输中光标 / 终态收敛 / 异常提示,
3055
3323
  * 也供插件插槽按 `customType` 接管(markdown 等富类型)。
3056
3324
  */
3057
- onStreamMessage: (u) => {
3058
- if (u.conversationType === "chatRoom")
3325
+ onStreamMessage: (d) => {
3326
+ if (d.conversationType === "chatRoom")
3059
3327
  return;
3060
- const l = u.stream;
3061
- if (!l)
3328
+ const f = d.stream;
3329
+ if (!f)
3062
3330
  return;
3063
3331
  y.info("onStreamMessage", {
3064
- conversationId: u.conversationId,
3065
- from: u.from,
3066
- msgServerId: u.msgServerId,
3067
- seq: l.seq,
3068
- status: l.status,
3069
- customType: l.customType
3332
+ conversationId: d.conversationId,
3333
+ from: d.from,
3334
+ msgServerId: d.msgServerId,
3335
+ seq: f.seq,
3336
+ status: f.status,
3337
+ customType: f.customType
3070
3338
  });
3071
- const f = u.msgServerId || u.msgLocalId;
3072
- if (!f)
3339
+ const m = d.msgServerId || d.msgLocalId;
3340
+ if (!m)
3073
3341
  return;
3074
- if (!e.message.getMessages(u.conversationId).some(
3075
- (v) => v.msgServerId === u.msgServerId || u.msgLocalId !== void 0 && v.msgLocalId === u.msgLocalId
3342
+ if (!e.message.getMessages(d.conversationId).some(
3343
+ (v) => v.msgServerId === d.msgServerId || d.msgLocalId !== void 0 && v.msgLocalId === d.msgLocalId
3076
3344
  )) {
3077
- e.message.addMessage(P(u, e.client.currentUser));
3345
+ e.message.addMessage(H(d, e.client.currentUser));
3078
3346
  return;
3079
3347
  }
3080
- e.message.updateMessageById(f, {
3081
- body: { ...u.body, content: l.fullText },
3082
- stream: { ...l }
3348
+ e.message.updateMessageById(m, {
3349
+ body: { ...d.body, content: f.fullText },
3350
+ stream: { ...f }
3083
3351
  });
3084
3352
  },
3085
- onMessageRecalled: (u) => {
3086
- u.conversationType !== "chatRoom" && (y.info("onMessageRecalled", { messageId: u.messageId }), e.message.recallMessage(u.messageId, e.client.currentUser), c && x(() => c(u.messageId, e.client.currentUser)), _n(
3353
+ onMessageRecalled: (d) => {
3354
+ d.conversationType !== "chatRoom" && (y.info("onMessageRecalled", { messageId: d.messageId }), e.message.recallMessage(d.messageId, e.client.currentUser), c && B(() => c(d.messageId, e.client.currentUser)), ts(
3087
3355
  e,
3088
- u.conversationId,
3089
- u.conversationType,
3090
- u.messageId
3356
+ d.conversationId,
3357
+ d.conversationType,
3358
+ d.messageId
3091
3359
  ));
3092
3360
  },
3093
- onMessageDelivered: (u) => {
3094
- y.info("onMessageDelivered", { messageId: u.messageId }), e.message.updateMessageStatus(u.messageId, O.DELIVERED), i && x(() => i(u.messageId, O.DELIVERED));
3361
+ onMessageDelivered: (d) => {
3362
+ y.info("onMessageDelivered", { messageId: d.messageId }), e.message.updateMessageStatus(d.messageId, k.DELIVERED), i && B(() => i(d.messageId, k.DELIVERED));
3095
3363
  },
3096
- onMessageReadReceipts: (u) => {
3097
- for (const l of u)
3098
- if (l.conversationType === M.GROUPCHAT) {
3364
+ onMessageReadReceipts: (d) => {
3365
+ for (const f of d)
3366
+ if (f.conversationType === I.GROUPCHAT) {
3099
3367
  y.info("onMessageReadReceipts(group)", {
3100
- conversationId: l.conversationId,
3101
- details: l.receiptDetails.map((f) => ({ messageId: f.messageId, count: f.count }))
3368
+ conversationId: f.conversationId,
3369
+ details: f.receiptDetails.map((m) => ({ messageId: m.messageId, count: m.count }))
3102
3370
  });
3103
- for (const f of l.receiptDetails)
3104
- e.message.updateMessageById(f.messageId, { groupReadCount: f.count });
3371
+ for (const m of f.receiptDetails)
3372
+ e.message.updateMessageById(m.messageId, { groupReadCount: m.count });
3105
3373
  } else {
3106
3374
  y.info("onMessageReadReceipts(single)", {
3107
- conversationId: l.conversationId,
3108
- total: l.messageIds.length,
3109
- messageIds: l.messageIds.slice(0, 5)
3375
+ conversationId: f.conversationId,
3376
+ total: f.messageIds.length,
3377
+ messageIds: f.messageIds.slice(0, 5)
3110
3378
  });
3111
- for (const f of l.messageIds)
3112
- e.message.updateMessageStatus(f, O.READ), i && x(() => i(f, O.READ));
3379
+ for (const m of f.messageIds)
3380
+ e.message.updateMessageStatus(m, k.READ), i && B(() => i(m, k.READ));
3113
3381
  }
3114
3382
  },
3115
- onMessageUpdated: (u) => {
3116
- u.conversationType !== "chatRoom" && (y.info("onMessageUpdated", { messageId: u.messageId }), e.message.updateMessageById(u.messageId, {
3117
- body: u.message.body,
3118
- ext: u.message.ext,
3119
- modifiedInfo: u.message.modifiedInfo,
3383
+ onMessageUpdated: (d) => {
3384
+ d.conversationType !== "chatRoom" && (y.info("onMessageUpdated", { messageId: d.messageId }), e.message.updateMessageById(d.messageId, {
3385
+ body: d.message.body,
3386
+ ext: d.message.ext,
3387
+ modifiedInfo: d.message.modifiedInfo,
3120
3388
  modified: !0
3121
- }), d && x(() => d(
3122
- u.messageId,
3123
- u.message.body,
3124
- u.message.ext,
3125
- u.message.modifiedInfo
3389
+ }), u && B(() => u(
3390
+ d.messageId,
3391
+ d.message.body,
3392
+ d.message.ext,
3393
+ d.message.modifiedInfo
3126
3394
  )));
3127
3395
  },
3128
- onPinnedMessageChanged: async (u) => {
3129
- if (u.conversationType !== "chatRoom" && (y.info("onPinnedMessageChanged", { conversationId: u.conversationId, operation: u.operation }), !!u.messageId && (u.operation === "pin" ? e.message.setMessagePinned(u.messageId, {
3130
- operatorId: u.operatorId || "",
3131
- pinTime: u.pinTime || Date.now()
3132
- }) : u.operation === "unpin" && e.message.setMessageUnpinned(u.messageId), u.conversationId && u.conversationType)))
3396
+ onPinnedMessageChanged: async (d) => {
3397
+ if (d.conversationType !== "chatRoom" && (y.info("onPinnedMessageChanged", { conversationId: d.conversationId, operation: d.operation }), !!d.messageId && (d.operation === "pin" ? e.message.setMessagePinned(d.messageId, {
3398
+ operatorId: d.operatorId || "",
3399
+ pinTime: d.pinTime || Date.now()
3400
+ }) : d.operation === "unpin" && e.message.setMessageUnpinned(d.messageId), d.conversationId && d.conversationType)))
3133
3401
  try {
3134
- const f = (await s.chatManager.getPinnedMessageList({
3135
- conversationId: u.conversationId,
3136
- conversationType: u.conversationType
3137
- })).items.map((h) => P(h.message, e.client.currentUser));
3138
- e.message.setPinnedMessages(u.conversationId, f);
3139
- } catch (l) {
3140
- y.warn("refresh pinned messages failed:", l);
3402
+ const m = (await s.chatManager.getPinnedMessageList({
3403
+ conversationId: d.conversationId,
3404
+ conversationType: d.conversationType
3405
+ })).items.map((h) => H(h.message, e.client.currentUser));
3406
+ e.message.setPinnedMessages(d.conversationId, m);
3407
+ } catch (f) {
3408
+ y.warn("refresh pinned messages failed:", f);
3141
3409
  }
3142
3410
  },
3143
- onMultiDeviceConversation: (u) => {
3144
- if (y.info("onMultiDeviceConversation", { operation: u.operation }), u.operation === "ALL_CONVERSATIONS_UNREAD_MESSAGE_COUNT_CLEARED") {
3411
+ onMultiDeviceConversation: (d) => {
3412
+ if (y.info("onMultiDeviceConversation", { operation: d.operation }), d.operation === "ALL_CONVERSATIONS_UNREAD_MESSAGE_COUNT_CLEARED") {
3145
3413
  for (const h of e.conversation.conversationList)
3146
3414
  e.conversation.updateUnreadCount(h.id, 0);
3147
3415
  return;
3148
3416
  }
3149
- const { operation: l, conversationId: f } = u;
3150
- switch (l) {
3417
+ const { operation: f, conversationId: m } = d;
3418
+ switch (f) {
3151
3419
  case "CONVERSATION_DELETED":
3152
- e.conversation.deleteConversation(f);
3420
+ e.conversation.deleteConversation(m);
3153
3421
  break;
3154
3422
  case "CONVERSATION_PINNED":
3155
- e.conversation.updateConversation(f, { isPinned: !0 });
3423
+ e.conversation.updateConversation(m, { isPinned: !0 });
3156
3424
  break;
3157
3425
  case "CONVERSATION_UNPINNED":
3158
- e.conversation.updateConversation(f, { isPinned: !1 });
3426
+ e.conversation.updateConversation(m, { isPinned: !1 });
3159
3427
  break;
3160
3428
  case "CONVERSATION_UNREAD_MESSAGE_COUNT_CLEARED":
3161
- e.conversation.updateUnreadCount(f, 0);
3429
+ e.conversation.updateUnreadCount(m, 0);
3162
3430
  break;
3163
3431
  case "CONVERSATION_MARK":
3164
- u.mark !== void 0 && e.conversation.updateConversation(f, { marks: [u.mark] });
3432
+ d.mark !== void 0 && e.conversation.updateConversation(m, { marks: [d.mark] });
3165
3433
  break;
3166
3434
  case "CONVERSATION_MUTE_INFO_CHANGED":
3167
- u.remindType && e.conversation.updateConversation(f, {
3168
- isMuted: u.remindType === "NONE",
3169
- remindType: u.remindType
3435
+ d.remindType && e.conversation.updateConversation(m, {
3436
+ isMuted: d.remindType === "NONE",
3437
+ remindType: d.remindType
3170
3438
  });
3171
3439
  break;
3172
3440
  default:
3173
- y.warn("onMultiDeviceConversation unhandled:", u);
3441
+ y.warn("onMultiDeviceConversation unhandled:", d);
3174
3442
  }
3175
3443
  },
3176
- onMultiDeviceMessageRemoved: (u) => {
3177
- y.info("onMultiDeviceMessageRemoved", { conversationId: u.conversationId, operation: u.operation, messageIds: u.messageIds });
3178
- const { operation: l, conversationId: f, messageIds: h, beforeTimestamp: v } = u;
3179
- if (!(!f || l !== "MESSAGE_REMOVED")) {
3444
+ onMultiDeviceMessageRemoved: (d) => {
3445
+ y.info("onMultiDeviceMessageRemoved", { conversationId: d.conversationId, operation: d.operation, messageIds: d.messageIds });
3446
+ const { operation: f, conversationId: m, messageIds: h, beforeTimestamp: v } = d;
3447
+ if (!(!m || f !== "MESSAGE_REMOVED")) {
3180
3448
  if (h && h.length > 0)
3181
- e.message.deleteMessages([...h]), g && x(() => g([...h]));
3449
+ e.message.deleteMessages([...h]), l && B(() => l([...h]));
3182
3450
  else if (v) {
3183
- const w = e.message.getMessages(f).filter((I) => I.timestamp && I.timestamp < v).map((I) => I.msgServerId || I.msgLocalId).filter((I) => !!I);
3184
- w.length > 0 && (e.message.deleteMessages(w), g && x(() => g(w)));
3451
+ const w = e.message.getMessages(m).filter((M) => M.timestamp && M.timestamp < v).map((M) => M.msgServerId || M.msgLocalId).filter((M) => !!M);
3452
+ w.length > 0 && (e.message.deleteMessages(w), l && B(() => l(w)));
3185
3453
  }
3186
3454
  }
3187
3455
  }
3188
3456
  };
3189
3457
  }
3190
- const J = T("UIKit:ContactEvents");
3191
- function Ke(s, e = "pending") {
3458
+ const $ = T("UIKit:ContactEvents");
3459
+ function Xe(s, e = "pending") {
3192
3460
  const t = s.userInfo, n = s.from;
3193
3461
  return {
3194
3462
  id: n,
@@ -3202,47 +3470,47 @@ function Ke(s, e = "pending") {
3202
3470
  timestamp: Date.now()
3203
3471
  };
3204
3472
  }
3205
- function kn(s) {
3206
- const { t: e, insertChatNotice: t } = B();
3473
+ function ss(s) {
3474
+ const { t: e, insertChatNotice: t } = K();
3207
3475
  return {
3208
3476
  onContactInvited: (n) => {
3209
- J.info("onContactInvited", { from: n.from });
3477
+ $.info("onContactInvited", { from: n.from });
3210
3478
  const o = n.from, a = o ? s.contact.getContact(o) : void 0;
3211
- s.contact.addInvite(Ke(n, a ? "accepted" : "pending"));
3479
+ s.contact.addInvite(Xe(n, a ? "accepted" : "pending"));
3212
3480
  },
3213
3481
  onContactAgreed: (n) => {
3214
- J.info("onContactAgreed", { from: n.from });
3482
+ $.info("onContactAgreed", { from: n.from });
3215
3483
  const o = n.from;
3216
3484
  if (!o)
3217
3485
  return;
3218
3486
  s.contact.getInvite(o) && s.contact.updateInviteStatus(o, "accepted"), s.contact.addContact({ userId: o, name: o });
3219
3487
  },
3220
3488
  onContactRefuse: (n) => {
3221
- J.info("onContactRefuse", { from: n.from });
3489
+ $.info("onContactRefuse", { from: n.from });
3222
3490
  const o = n.from;
3223
- o && (s.contact.getInvite(o) ? s.contact.updateInviteStatus(o, "declined") : s.contact.addInvite({ ...Ke(n, "declined"), outgoing: !0, unread: !0 }), Fe(s, o, "declined"));
3491
+ o && (s.contact.getInvite(o) ? s.contact.updateInviteStatus(o, "declined") : s.contact.addInvite({ ...Xe(n, "declined"), outgoing: !0, unread: !0 }), Qe(s, o, "declined"));
3224
3492
  },
3225
3493
  onContactDeleted: (n) => {
3226
- J.info("onContactDeleted", { from: n.from });
3494
+ $.info("onContactDeleted", { from: n.from });
3227
3495
  const o = n.from;
3228
- o && (s.contact.removeContact(o), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
3229
- eventType: A.CONTACT_DELETED,
3496
+ o && (s.contact.removeContact(o), s.contact.removeInvite(o), t(s, o, I.SINGLECHAT, {
3497
+ eventType: E.CONTACT_DELETED,
3230
3498
  params: {},
3231
3499
  defaultText: e("chat.notice.contactDeleted")
3232
- }), Fe(s, o, "deleted"));
3500
+ }), Qe(s, o, "deleted"));
3233
3501
  },
3234
3502
  onContactAdded: (n) => {
3235
- J.info("onContactAdded", { from: n.from });
3503
+ $.info("onContactAdded", { from: n.from });
3236
3504
  const o = n.from;
3237
- o && (s.contact.addContact({ userId: o, name: o }), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
3238
- eventType: A.CONTACT_ADDED,
3505
+ o && (s.contact.addContact({ userId: o, name: o }), s.contact.removeInvite(o), t(s, o, I.SINGLECHAT, {
3506
+ eventType: E.CONTACT_ADDED,
3239
3507
  params: {},
3240
3508
  defaultText: e("chat.notice.contactAdded")
3241
3509
  }));
3242
3510
  },
3243
3511
  onContactInfoUpdated: (n) => {
3244
3512
  var a, r;
3245
- J.info("onContactInfoUpdated", { userId: (a = n.contact) == null ? void 0 : a.userId });
3513
+ $.info("onContactInfoUpdated", { userId: (a = n.contact) == null ? void 0 : a.userId });
3246
3514
  const o = n.contact;
3247
3515
  if (o != null && o.userId && o.remark !== void 0) {
3248
3516
  s.contact.updateContactRemark(o.userId, o.remark);
@@ -3253,7 +3521,7 @@ function kn(s) {
3253
3521
  };
3254
3522
  }
3255
3523
  const S = T("UIKit:GroupEvents");
3256
- function je(s, e = "pending") {
3524
+ function Ze(s, e = "pending") {
3257
3525
  const t = s.groupId, n = "inviter" in s ? s.inviter : void 0, o = "groupName" in s ? s.groupName : void 0;
3258
3526
  return {
3259
3527
  id: t,
@@ -3267,35 +3535,35 @@ function je(s, e = "pending") {
3267
3535
  timestamp: Date.now()
3268
3536
  };
3269
3537
  }
3270
- function ie(s, e, t, n) {
3271
- const { t: o, resolveNoticeUserName: a } = B();
3538
+ function ce(s, e, t, n) {
3539
+ const { t: o, resolveNoticeUserName: a } = K();
3272
3540
  if (s.length === 0)
3273
3541
  return "";
3274
3542
  const r = s[0];
3275
3543
  if (s.length === 1) {
3276
- const d = r.userId === e ? o("chat.notice.you") : a(r);
3277
- return o(t).replace("{name}", d);
3544
+ const u = r.userId === e ? o("chat.notice.you") : a(r);
3545
+ return o(t).replace("{name}", u);
3278
3546
  }
3279
- const i = s.find((d) => d.userId !== e), c = a(i || r);
3547
+ const i = s.find((u) => u.userId !== e), c = a(i || r);
3280
3548
  return o(n).replace("{name}", c).replace("{count}", String(s.length));
3281
3549
  }
3282
- function ae(s, e) {
3283
- const { t, resolveNoticeUserName: n } = B(), o = s.find((r) => r.userId !== e) ?? s[0];
3550
+ function ue(s, e) {
3551
+ const { t, resolveNoticeUserName: n } = K(), o = s.find((r) => r.userId !== e) ?? s[0];
3284
3552
  return {
3285
3553
  name: (o == null ? void 0 : o.userId) === e ? t("chat.notice.you") : n(o),
3286
3554
  count: s.length,
3287
3555
  userIds: s.map((r) => r.userId).join(",")
3288
3556
  };
3289
3557
  }
3290
- function On(s) {
3291
- const { t: e, insertChatNotice: t, buildAnnouncementNoticeText: n, resolveNoticeUserName: o } = B();
3558
+ function rs(s) {
3559
+ const { t: e, insertChatNotice: t, buildAnnouncementNoticeText: n, resolveNoticeUserName: o } = K();
3292
3560
  function a(r) {
3293
3561
  return s.group.groupList.some((i) => i.groupId === r);
3294
3562
  }
3295
3563
  return {
3296
3564
  onInvitationReceived: (r) => {
3297
3565
  S.info("onInvitationReceived raw payload", r);
3298
- const i = je(r, a(r.groupId) ? "accepted" : "pending");
3566
+ const i = Ze(r, a(r.groupId) ? "accepted" : "pending");
3299
3567
  s.contact.addInvite(i);
3300
3568
  },
3301
3569
  onInvitationAccepted: (r) => {
@@ -3305,87 +3573,87 @@ function On(s) {
3305
3573
  S.info("onInvitationDeclined raw payload", r), s.contact.updateInviteStatus(r.groupId, "declined");
3306
3574
  },
3307
3575
  onAutoAcceptInvitationFromGroup: (r) => {
3308
- S.info("onAutoAcceptInvitationFromGroup raw payload", r), s.contact.addInvite(je(r, "accepted"));
3576
+ S.info("onAutoAcceptInvitationFromGroup raw payload", r), s.contact.addInvite(Ze(r, "accepted"));
3309
3577
  },
3310
3578
  onMembersJoined: (r) => {
3311
3579
  S.info("onMembersJoined raw payload", r);
3312
3580
  const i = r.members || [], c = s.client.currentUser;
3313
- i.some((m) => m.userId === c) && (s.contact.getInvite(r.groupId) && s.contact.updateInviteStatus(r.groupId, "accepted"), s.group.getGroupById(r.groupId) || s.group.addGroup({ groupId: r.groupId, groupName: r.groupName })), s.group.incrementMemberCount(r.groupId, i.length);
3314
- const g = ie(
3581
+ i.some((g) => g.userId === c) && (s.contact.getInvite(r.groupId) && s.contact.updateInviteStatus(r.groupId, "accepted"), s.group.getGroupById(r.groupId) || s.group.addGroup({ groupId: r.groupId, groupName: r.groupName })), s.group.incrementMemberCount(r.groupId, i.length);
3582
+ const l = ce(
3315
3583
  i,
3316
3584
  c || "",
3317
3585
  "chat.notice.memberJoined",
3318
3586
  "chat.notice.memberJoinedMultiple"
3319
3587
  );
3320
- t(s, r.groupId, M.GROUPCHAT, {
3321
- eventType: A.MEMBER_JOINED,
3322
- params: ae(i, c || ""),
3323
- defaultText: g
3588
+ t(s, r.groupId, I.GROUPCHAT, {
3589
+ eventType: E.MEMBER_JOINED,
3590
+ params: ue(i, c || ""),
3591
+ defaultText: l
3324
3592
  });
3325
3593
  },
3326
3594
  onMembersExited: (r) => {
3327
3595
  const i = r.members || [];
3328
3596
  S.info("onMembersExited raw payload", r), s.group.decrementMemberCount(r.groupId, i.length);
3329
- const c = ie(
3597
+ const c = ce(
3330
3598
  i,
3331
3599
  s.client.currentUser || "",
3332
3600
  "chat.notice.memberExited",
3333
3601
  "chat.notice.memberExitedMultiple"
3334
3602
  );
3335
- t(s, r.groupId, M.GROUPCHAT, {
3336
- eventType: A.MEMBER_EXITED,
3337
- params: ae(i, s.client.currentUser || ""),
3603
+ t(s, r.groupId, I.GROUPCHAT, {
3604
+ eventType: E.MEMBER_EXITED,
3605
+ params: ue(i, s.client.currentUser || ""),
3338
3606
  defaultText: c
3339
3607
  });
3340
3608
  },
3341
3609
  onGroupInfoChanged: (r) => {
3342
3610
  S.info("onGroupInfoChanged raw payload", r);
3343
- const i = r.groupInfo ?? r, c = i.name ?? i.groupName, d = s.group.getGroupById(r.groupId), g = Le({
3611
+ const i = r.groupInfo ?? r, c = i.name ?? i.groupName, u = s.group.getGroupById(r.groupId), l = Fe({
3344
3612
  ...i,
3345
3613
  groupId: r.groupId,
3346
3614
  name: c,
3347
3615
  avatarUrl: i.avatarUrl ?? i.avatar
3348
- }), p = !!r.groupInfo ? g : Object.fromEntries(Object.entries(g).filter(([, u]) => u !== void 0));
3349
- s.group.updateGroup(r.groupId, p), c && (d != null && d.groupName) && c !== d.groupName && (t(s, r.groupId, M.GROUPCHAT, {
3350
- eventType: A.GROUP_NAME_CHANGED,
3616
+ }), p = !!r.groupInfo ? l : Object.fromEntries(Object.entries(l).filter(([, d]) => d !== void 0));
3617
+ s.group.updateGroup(r.groupId, p), c && (u != null && u.groupName) && c !== u.groupName && (t(s, r.groupId, I.GROUPCHAT, {
3618
+ eventType: E.GROUP_NAME_CHANGED,
3351
3619
  params: { name: c },
3352
3620
  defaultText: e("chat.notice.groupNameChanged").replace("{name}", c)
3353
3621
  }), s.conversation.updateConversation(r.groupId, { name: c }));
3354
3622
  },
3355
3623
  onOwnerChanged: (r) => {
3356
- var l, f, h, v, b, w;
3624
+ var f, m, h, v, C, w;
3357
3625
  S.info("onOwnerChanged raw payload", r);
3358
- const i = (l = s.group.getGroupById(r.groupId)) == null ? void 0 : l.owner, c = (h = (f = s.group).getPendingOwnerTransfer) == null ? void 0 : h.call(f, r.groupId), d = c || ((v = r.newOwner) == null ? void 0 : v.userId) || "", g = { owner: d }, m = s.client.currentUser || "";
3359
- m && (m === d ? g.role = L.OWNER : m === i && (g.role = L.MEMBER)), s.group.updateGroup(r.groupId, g), d && s.group.updateGroupMemberRole(r.groupId, d, L.OWNER), i && i !== d && s.group.updateGroupMemberRole(r.groupId, i, L.MEMBER), c && ((w = (b = s.group).clearPendingOwnerTransfer) == null || w.call(b, r.groupId));
3360
- const p = d === m ? e("chat.notice.you") : o(r.newOwner), u = e("chat.notice.ownerChanged").replace("{name}", p);
3361
- t(s, r.groupId, M.GROUPCHAT, {
3362
- eventType: A.OWNER_CHANGED,
3363
- params: { name: p, ownerId: d },
3364
- defaultText: u
3626
+ const i = (f = s.group.getGroupById(r.groupId)) == null ? void 0 : f.owner, c = (h = (m = s.group).getPendingOwnerTransfer) == null ? void 0 : h.call(m, r.groupId), u = c || ((v = r.newOwner) == null ? void 0 : v.userId) || "", l = { owner: u }, g = s.client.currentUser || "";
3627
+ g && (g === u ? l.role = R.OWNER : g === i && (l.role = R.MEMBER)), s.group.updateGroup(r.groupId, l), u && s.group.updateGroupMemberRole(r.groupId, u, R.OWNER), i && i !== u && s.group.updateGroupMemberRole(r.groupId, i, R.MEMBER), c && ((w = (C = s.group).clearPendingOwnerTransfer) == null || w.call(C, r.groupId));
3628
+ const p = u === g ? e("chat.notice.you") : o(r.newOwner), d = e("chat.notice.ownerChanged").replace("{name}", p);
3629
+ t(s, r.groupId, I.GROUPCHAT, {
3630
+ eventType: E.OWNER_CHANGED,
3631
+ params: { name: p, ownerId: u },
3632
+ defaultText: d
3365
3633
  });
3366
3634
  },
3367
3635
  onAdminAdded: (r) => {
3368
- var m;
3636
+ var g;
3369
3637
  S.info("onAdminAdded raw payload", r);
3370
- const i = (m = r.administrator) == null ? void 0 : m.userId;
3371
- i && s.group.updateGroupMemberRole(r.groupId, i, L.ADMIN);
3372
- const c = s.client.currentUser || "", d = i === c ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminAdded").replace("{name}", d);
3373
- t(s, r.groupId, M.GROUPCHAT, {
3374
- eventType: A.ADMIN_ADDED,
3375
- params: { name: d, userId: i || "" },
3376
- defaultText: g
3638
+ const i = (g = r.administrator) == null ? void 0 : g.userId;
3639
+ i && s.group.updateGroupMemberRole(r.groupId, i, R.ADMIN);
3640
+ const c = s.client.currentUser || "", u = i === c ? e("chat.notice.you") : o(r.administrator), l = e("chat.notice.adminAdded").replace("{name}", u);
3641
+ t(s, r.groupId, I.GROUPCHAT, {
3642
+ eventType: E.ADMIN_ADDED,
3643
+ params: { name: u, userId: i || "" },
3644
+ defaultText: l
3377
3645
  });
3378
3646
  },
3379
3647
  onAdminRemoved: (r) => {
3380
- var m;
3648
+ var g;
3381
3649
  S.info("onAdminRemoved raw payload", r);
3382
- const i = (m = r.administrator) == null ? void 0 : m.userId;
3383
- i && s.group.updateGroupMemberRole(r.groupId, i, L.MEMBER);
3384
- const c = s.client.currentUser || "", d = i === c ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminRemoved").replace("{name}", d);
3385
- t(s, r.groupId, M.GROUPCHAT, {
3386
- eventType: A.ADMIN_REMOVED,
3387
- params: { name: d, userId: i || "" },
3388
- defaultText: g
3650
+ const i = (g = r.administrator) == null ? void 0 : g.userId;
3651
+ i && s.group.updateGroupMemberRole(r.groupId, i, R.MEMBER);
3652
+ const c = s.client.currentUser || "", u = i === c ? e("chat.notice.you") : o(r.administrator), l = e("chat.notice.adminRemoved").replace("{name}", u);
3653
+ t(s, r.groupId, I.GROUPCHAT, {
3654
+ eventType: E.ADMIN_REMOVED,
3655
+ params: { name: u, userId: i || "" },
3656
+ defaultText: l
3389
3657
  });
3390
3658
  },
3391
3659
  onUserRemoved: (r) => {
@@ -3393,96 +3661,96 @@ function On(s) {
3393
3661
  const i = e("chat.notice.you");
3394
3662
  s.group.removeGroup(r.groupId), s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId);
3395
3663
  const c = e("chat.notice.userRemoved").replace("{name}", i);
3396
- t(s, r.groupId, M.GROUPCHAT, {
3397
- eventType: A.USER_REMOVED,
3664
+ t(s, r.groupId, I.GROUPCHAT, {
3665
+ eventType: E.USER_REMOVED,
3398
3666
  params: { name: i },
3399
3667
  defaultText: c
3400
3668
  });
3401
3669
  },
3402
3670
  onGroupDestroyed: (r) => {
3403
3671
  var i;
3404
- S.info("onGroupDestroyed raw payload", r), s.group.removeGroup(r.groupId), (((i = s.client.client) == null ? void 0 : i.deleteConversationOnGroupDestroyed) ?? !0) && (s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId)), t(s, r.groupId, M.GROUPCHAT, {
3405
- eventType: A.GROUP_DESTROYED,
3672
+ S.info("onGroupDestroyed raw payload", r), s.group.removeGroup(r.groupId), (((i = s.client.client) == null ? void 0 : i.deleteConversationOnGroupDestroyed) ?? !0) && (s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId)), t(s, r.groupId, I.GROUPCHAT, {
3673
+ eventType: E.GROUP_DESTROYED,
3406
3674
  params: {},
3407
3675
  defaultText: e("chat.notice.groupDestroyed")
3408
3676
  });
3409
3677
  },
3410
3678
  onAnnouncementChanged: (r) => {
3411
- S.info("onAnnouncementChanged raw payload", r), s.group.updateGroup(r.groupId, { announcement: r.announcement }), s.group.setGroupAnnouncement(r.groupId, r.announcement), t(s, r.groupId, M.GROUPCHAT, {
3412
- eventType: A.ANNOUNCEMENT_CHANGED,
3679
+ S.info("onAnnouncementChanged raw payload", r), s.group.updateGroup(r.groupId, { announcement: r.announcement }), s.group.setGroupAnnouncement(r.groupId, r.announcement), t(s, r.groupId, I.GROUPCHAT, {
3680
+ eventType: E.ANNOUNCEMENT_CHANGED,
3413
3681
  params: { announcement: r.announcement || "" },
3414
3682
  defaultText: n(r.announcement)
3415
3683
  });
3416
3684
  },
3417
3685
  onMuteListAdded: (r) => {
3418
3686
  S.info("onMuteListAdded raw payload", r);
3419
- const i = (r.mutes || []).map((g) => ({
3420
- userId: g.userId,
3687
+ const i = (r.mutes || []).map((l) => ({
3688
+ userId: l.userId,
3421
3689
  muteExpire: r.muteExpire
3422
3690
  }));
3423
3691
  s.group.addGroupMuteMembers(r.groupId, i);
3424
- const c = (r.mutes || []).map((g) => g.nickname || g.userId || ""), d = c.map((g) => e("group.mutelist.muteNotice").replace("{name}", g)).join("、");
3425
- t(s, r.groupId, M.GROUPCHAT, {
3426
- eventType: A.MUTE_ADDED,
3692
+ const c = (r.mutes || []).map((l) => l.nickname || l.userId || ""), u = c.map((l) => e("group.mutelist.muteNotice").replace("{name}", l)).join("、");
3693
+ t(s, r.groupId, I.GROUPCHAT, {
3694
+ eventType: E.MUTE_ADDED,
3427
3695
  params: { names: c.join("、"), count: c.length },
3428
- defaultText: d
3696
+ defaultText: u
3429
3697
  });
3430
3698
  },
3431
3699
  onMuteListRemoved: (r) => {
3432
3700
  S.info("onMuteListRemoved raw payload", r);
3433
- const i = (r.mutes || []).map((g) => g.userId);
3701
+ const i = (r.mutes || []).map((l) => l.userId);
3434
3702
  s.group.removeGroupMuteMembers(r.groupId, i);
3435
- const c = (r.mutes || []).map((g) => g.nickname || g.userId || ""), d = c.map((g) => e("group.mutelist.unmuteNotice").replace("{name}", g)).join("、");
3436
- t(s, r.groupId, M.GROUPCHAT, {
3437
- eventType: A.MUTE_REMOVED,
3703
+ const c = (r.mutes || []).map((l) => l.nickname || l.userId || ""), u = c.map((l) => e("group.mutelist.unmuteNotice").replace("{name}", l)).join("、");
3704
+ t(s, r.groupId, I.GROUPCHAT, {
3705
+ eventType: E.MUTE_REMOVED,
3438
3706
  params: { names: c.join("、"), count: c.length },
3439
- defaultText: d
3707
+ defaultText: u
3440
3708
  });
3441
3709
  },
3442
3710
  onAllMemberMuteStateChanged: (r) => {
3443
3711
  S.info("onAllMemberMuteStateChanged raw payload", r), s.group.updateGroup(r.groupId, { mute: r.isMuted });
3444
3712
  const i = e(r.isMuted ? "group.mutelist.muteAllNotice" : "group.mutelist.unmuteAllNotice");
3445
- t(s, r.groupId, M.GROUPCHAT, {
3446
- eventType: A.ALL_MEMBER_MUTE_CHANGED,
3713
+ t(s, r.groupId, I.GROUPCHAT, {
3714
+ eventType: E.ALL_MEMBER_MUTE_CHANGED,
3447
3715
  params: { muted: r.isMuted },
3448
3716
  defaultText: i
3449
3717
  });
3450
3718
  },
3451
3719
  onAllowListAdded: (r) => {
3452
3720
  S.info("onAllowListAdded raw payload", r);
3453
- const i = (r.allowlist || []).map((d) => d.userId);
3721
+ const i = (r.allowlist || []).map((u) => u.userId);
3454
3722
  s.group.addGroupAllowlistMembers(r.groupId, i);
3455
- const c = ie(
3723
+ const c = ce(
3456
3724
  r.allowlist || [],
3457
3725
  s.client.currentUser || "",
3458
3726
  "chat.notice.allowlistAdded",
3459
3727
  "chat.notice.allowlistAddedMultiple"
3460
3728
  );
3461
- t(s, r.groupId, M.GROUPCHAT, {
3462
- eventType: A.ALLOWLIST_ADDED,
3463
- params: ae(r.allowlist || [], s.client.currentUser || ""),
3729
+ t(s, r.groupId, I.GROUPCHAT, {
3730
+ eventType: E.ALLOWLIST_ADDED,
3731
+ params: ue(r.allowlist || [], s.client.currentUser || ""),
3464
3732
  defaultText: c
3465
3733
  });
3466
3734
  },
3467
3735
  onAllowListRemoved: (r) => {
3468
3736
  S.info("onAllowListRemoved raw payload", r);
3469
- const i = (r.allowlist || []).map((d) => d.userId);
3737
+ const i = (r.allowlist || []).map((u) => u.userId);
3470
3738
  s.group.removeGroupAllowlistMembers(r.groupId, i);
3471
- const c = ie(
3739
+ const c = ce(
3472
3740
  r.allowlist || [],
3473
3741
  s.client.currentUser || "",
3474
3742
  "chat.notice.allowlistRemoved",
3475
3743
  "chat.notice.allowlistRemovedMultiple"
3476
3744
  );
3477
- t(s, r.groupId, M.GROUPCHAT, {
3478
- eventType: A.ALLOWLIST_REMOVED,
3479
- params: ae(r.allowlist || [], s.client.currentUser || ""),
3745
+ t(s, r.groupId, I.GROUPCHAT, {
3746
+ eventType: E.ALLOWLIST_REMOVED,
3747
+ params: ue(r.allowlist || [], s.client.currentUser || ""),
3480
3748
  defaultText: c
3481
3749
  });
3482
3750
  },
3483
3751
  onGroupDisabledChanged: (r) => {
3484
- S.info("onGroupDisabledChanged raw payload", r), s.group.updateGroup(r.groupId, { disabled: r.disabled }), t(s, r.groupId, M.GROUPCHAT, {
3485
- eventType: A.GROUP_DISABLED_CHANGED,
3752
+ S.info("onGroupDisabledChanged raw payload", r), s.group.updateGroup(r.groupId, { disabled: r.disabled }), t(s, r.groupId, I.GROUPCHAT, {
3753
+ eventType: E.GROUP_DISABLED_CHANGED,
3486
3754
  params: { disabled: r.disabled },
3487
3755
  defaultText: e(r.disabled ? "chat.notice.groupDisabled" : "chat.notice.groupEnabled")
3488
3756
  });
@@ -3490,11 +3758,11 @@ function On(s) {
3490
3758
  onSharedFileAdded: (r) => {
3491
3759
  if (S.info("onSharedFileAdded raw payload", r), r.sharedFile) {
3492
3760
  s.group.addGroupSharedFile(r.groupId, r.sharedFile);
3493
- const i = r.sharedFile.fileOwner, c = (i == null ? void 0 : i.userId) === s.client.currentUser ? e("chat.notice.you") : o(i), d = e("chat.notice.sharedFileAdded").replace("{name}", c || (i == null ? void 0 : i.userId) || "").replace("{fileName}", r.sharedFile.fileName);
3494
- t(s, r.groupId, M.GROUPCHAT, {
3495
- eventType: A.SHARED_FILE_ADDED,
3761
+ const i = r.sharedFile.fileOwner, c = (i == null ? void 0 : i.userId) === s.client.currentUser ? e("chat.notice.you") : o(i), u = e("chat.notice.sharedFileAdded").replace("{name}", c || (i == null ? void 0 : i.userId) || "").replace("{fileName}", r.sharedFile.fileName);
3762
+ t(s, r.groupId, I.GROUPCHAT, {
3763
+ eventType: E.SHARED_FILE_ADDED,
3496
3764
  params: { name: c || (i == null ? void 0 : i.userId) || "", fileName: r.sharedFile.fileName },
3497
- defaultText: d
3765
+ defaultText: u
3498
3766
  });
3499
3767
  }
3500
3768
  },
@@ -3521,9 +3789,9 @@ function On(s) {
3521
3789
  },
3522
3790
  onRequestToJoinAccepted: (r) => {
3523
3791
  S.info("onRequestToJoinAccepted raw payload", r);
3524
- const i = s.client.currentUser, c = s.group.getGroupJoinRequests(r.groupId).filter((d) => {
3525
- var g;
3526
- return !(d.status === "pending" && (d.applicantId === i || ((g = d.applicant) == null ? void 0 : g.userId) === i));
3792
+ const i = s.client.currentUser, c = s.group.getGroupJoinRequests(r.groupId).filter((u) => {
3793
+ var l;
3794
+ return !(u.status === "pending" && (u.applicantId === i || ((l = u.applicant) == null ? void 0 : l.userId) === i));
3527
3795
  });
3528
3796
  s.group.setGroupJoinRequests(r.groupId, c);
3529
3797
  },
@@ -3537,17 +3805,17 @@ function On(s) {
3537
3805
  }
3538
3806
  };
3539
3807
  }
3540
- const xn = T("UIKit:PresenceEvents");
3541
- function Pn(s) {
3808
+ const os = T("UIKit:PresenceEvents");
3809
+ function is(s) {
3542
3810
  return {
3543
3811
  onPresenceStatusChange: (e) => {
3544
- if (xn.info("onPresenceStatusChange", { count: Array.isArray(e) ? e.length : 0 }), !Array.isArray(e))
3812
+ if (os.info("onPresenceStatusChange", { count: Array.isArray(e) ? e.length : 0 }), !Array.isArray(e))
3545
3813
  return;
3546
3814
  const t = e.map((n) => {
3547
3815
  const o = n.userId || "", r = (Array.isArray(n.statusDetails) ? n.statusDetails : []).some((c) => Number(c == null ? void 0 : c.status) === 1), i = n.ext || "";
3548
3816
  return {
3549
3817
  userId: o,
3550
- status: nt(r, i),
3818
+ status: ft(r, i),
3551
3819
  ext: i,
3552
3820
  lastTime: n.lastTime || Date.now()
3553
3821
  };
@@ -3556,25 +3824,25 @@ function Pn(s) {
3556
3824
  }
3557
3825
  };
3558
3826
  }
3559
- function Bn(s, e, t = {}, n, o, a) {
3560
- const r = wn(e, t), i = Nn(s, e, n, o, a), c = kn(e), d = On(e), g = Pn(e);
3561
- return s.addEventHandler("uikit-conn", r), s.chatManager.addEventHandler("uikit-chat", i), s.contactManager.addEventHandler("uikit-contact", c), s.groupManager.addEventHandler("uikit-group", d), s.presenceManager.addEventHandler("uikit-presence", g), () => {
3562
- s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"), Un(), An();
3827
+ function as(s, e, t = {}, n, o, a) {
3828
+ const r = Kn(e, t), i = ns(s, e, n, o, a), c = ss(e), u = rs(e), l = is(e);
3829
+ return s.addEventHandler("uikit-conn", r), s.chatManager.addEventHandler("uikit-chat", i), s.contactManager.addEventHandler("uikit-contact", c), s.groupManager.addEventHandler("uikit-group", u), s.presenceManager.addEventHandler("uikit-presence", l), () => {
3830
+ s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"), Xn(), jn();
3563
3831
  };
3564
3832
  }
3565
- const _ = T("UIKit:Websdk5Adapter"), Fn = [
3566
- qe,
3567
- ct,
3568
- ut,
3569
- dt,
3570
- lt,
3571
- We
3572
- ], Hn = [
3573
- qe,
3574
- at,
3575
- We
3833
+ const _ = T("UIKit:Websdk5Adapter"), cs = [
3834
+ tt,
3835
+ yt,
3836
+ Ct,
3837
+ bt,
3838
+ wt,
3839
+ nt
3840
+ ], us = [
3841
+ tt,
3842
+ Mt,
3843
+ nt
3576
3844
  ];
3577
- class ts {
3845
+ class ws {
3578
3846
  constructor(e) {
3579
3847
  this.injectedClient = e, this.capabilities = {
3580
3848
  combineMessage: !0,
@@ -3583,7 +3851,7 @@ class ts {
3583
3851
  streamingMessage: !0,
3584
3852
  groupReadReceipt: !0,
3585
3853
  // 本 adapter 遵循的契约版本(协商机制见 contract capabilities.ts)
3586
- contractVersion: St
3854
+ contractVersion: Ot
3587
3855
  }, this._client = null, this._handlersSet = /* @__PURE__ */ new Set(), this._eventsRegistered = !1, this._registerImEvents = !0;
3588
3856
  }
3589
3857
  /** 原生 SDK 客户端实例(UIKitClient 包装,可选) */
@@ -3614,14 +3882,14 @@ class ts {
3614
3882
  eventDeps: r,
3615
3883
  onUserInfoSubscriptionPermissionError: i,
3616
3884
  registerImEvents: c,
3617
- managerPreset: d,
3618
- repositories: g,
3619
- persistence: m,
3885
+ managerPreset: u,
3886
+ repositories: l,
3887
+ persistence: g,
3620
3888
  lastMessageTextResolver: p,
3621
- ...u
3622
- } = t, l = e.repositories ?? g, f = e.persistence ?? m;
3623
- this._persistence = f, this._lastMessageTextResolver = p, this._loginTimeoutMs = e.loginTimeoutMs;
3624
- const { appKey: h, appId: v, ...b } = u;
3889
+ ...d
3890
+ } = t, f = e.repositories ?? l, m = e.persistence ?? g;
3891
+ this._persistence = m, this._lastMessageTextResolver = p, this._loginTimeoutMs = e.loginTimeoutMs;
3892
+ const { appKey: h, appId: v, ...C } = d;
3625
3893
  let w;
3626
3894
  if (e.appKey)
3627
3895
  w = { appKey: e.appKey };
@@ -3631,75 +3899,86 @@ class ts {
3631
3899
  w = { appKey: "" };
3632
3900
  else
3633
3901
  throw new Error("[Websdk5Adapter] 缺少应用身份:SdkConfig.appKey 与 SdkConfig.appId 必须提供其一");
3634
- this._client = this.injectedClient ?? Nt({
3902
+ const M = (n == null ? void 0 : n.enableUserInfo) === !1 ? !1 : C.enableUserInfoSync ?? !0;
3903
+ this._client = this.injectedClient ?? Wt({
3635
3904
  debug: e.debug,
3636
- managers: u.managers ?? (d === "chatroom" ? Hn : Fn),
3637
- ...b,
3905
+ managers: d.managers ?? (u === "chatroom" ? us : cs),
3906
+ ...C,
3907
+ enableUserInfoSync: M,
3638
3908
  ...w
3639
- }), r && rt(r), this._features = n ?? jt(), this._registerImEvents = c !== !1;
3640
- const I = a ? Object.keys(a) : [];
3909
+ }), r && mt(r), this._features = n ?? tn(), this._registerImEvents = c !== !1;
3910
+ const A = a ? Object.keys(a) : [];
3641
3911
  if (_.info("[Websdk5Adapter] init 开始", {
3642
3912
  mode: this.injectedClient ? "injected-client" : "builtin",
3643
- managerPreset: d ?? "im",
3913
+ managerPreset: u ?? "im",
3644
3914
  registerImEvents: this._registerImEvents,
3645
- injectedStores: I
3646
- }), I.length < 7) {
3647
- const W = ["client", "message", "conversation", "contact", "group", "presence", "userInfo"];
3915
+ injectedStores: A
3916
+ }), A.length < 7) {
3917
+ const O = ["client", "message", "conversation", "contact", "group", "presence", "userInfo"];
3648
3918
  _.debug(
3649
3919
  "[Websdk5Adapter] 以下 store 域未注入,回落 adapter 内置 store:",
3650
- W.filter((D) => !I.includes(D))
3920
+ O.filter((U) => !A.includes(U))
3651
3921
  );
3652
3922
  }
3653
- const R = { ...Kt(this, () => this._getFanout()), ...a };
3654
- this._stores = R, this._domains = {
3655
- message: new dn(this._client, R.message, {
3656
- messageRepository: l == null ? void 0 : l.message,
3657
- persistence: f == null ? void 0 : f.message
3923
+ const x = { ...en(this, () => this._getFanout()), ...a };
3924
+ this._stores = x, this._domains = {
3925
+ message: new Sn(this._client, x.message, {
3926
+ messageRepository: f == null ? void 0 : f.message,
3927
+ persistence: m == null ? void 0 : m.message
3658
3928
  }),
3659
- conversation: new pn(this._client, R.conversation, {
3660
- sendPendingReadReceipts: (W, D) => {
3661
- var Y, De;
3662
- ((Y = this._features) == null ? void 0 : Y.enableReadReceipt) !== !1 && ((De = this._domains) == null || De.message.sendPendingReadReceipts(W, D));
3929
+ conversation: new Rn(this._client, x.conversation, {
3930
+ sendPendingReadReceipts: (O, U) => {
3931
+ var Z, He;
3932
+ ((Z = this._features) == null ? void 0 : Z.enableReadReceipt) !== !1 && ((He = this._domains) == null || He.message.sendPendingReadReceipts(O, U));
3933
+ },
3934
+ resolveSenderName: (O) => {
3935
+ var Z;
3936
+ const U = x.contact.getContact(O);
3937
+ return U != null && U.remark || U != null && U.name ? U.remark || U.name : (Z = x.userInfo.getUserInfo(O)) == null ? void 0 : Z.nickname;
3663
3938
  },
3664
- resolveSenderName: (W) => {
3665
- var Y;
3666
- const D = R.contact.getContact(W);
3667
- return D != null && D.remark || D != null && D.name ? D.remark || D.name : (Y = R.userInfo.getUserInfo(W)) == null ? void 0 : Y.nickname;
3939
+ prefillUserInfo: (O) => {
3940
+ var U;
3941
+ return (U = this._userInfoDomain) == null ? void 0 : U.prefillUserInfos(O);
3668
3942
  },
3669
3943
  lastMessageTextResolver: this._lastMessageTextResolver,
3670
- conversationRepository: l == null ? void 0 : l.conversation,
3671
- persistence: f == null ? void 0 : f.conversation
3944
+ conversationRepository: f == null ? void 0 : f.conversation,
3945
+ persistence: m == null ? void 0 : m.conversation
3672
3946
  }),
3673
- contact: new In(this._client, R.contact, {
3674
- contactRepository: l == null ? void 0 : l.contact
3947
+ contact: new Dn(this._client, x.contact, {
3948
+ contactRepository: f == null ? void 0 : f.contact
3675
3949
  }),
3676
- group: new yn(this._client, R.group, {
3677
- groupRepository: l == null ? void 0 : l.group
3950
+ group: new kn(this._client, x.group, {
3951
+ groupRepository: f == null ? void 0 : f.group
3678
3952
  }),
3679
- presence: new bn(this._client, R.presence, {
3680
- presenceRepository: l == null ? void 0 : l.presence
3953
+ presence: new On(this._client, x.presence, {
3954
+ presenceRepository: f == null ? void 0 : f.presence
3681
3955
  })
3682
- }, this._userInfoDomain = new Cn(
3956
+ };
3957
+ const vt = (f == null ? void 0 : f.userInfo) ?? nn(o) ?? {};
3958
+ this._userInfoDomain = new Hn(
3683
3959
  this._client,
3684
- R.userInfo,
3685
- (l == null ? void 0 : l.userInfo) ?? Vt(o) ?? {},
3960
+ x.userInfo,
3961
+ {
3962
+ readCachedUserInfos: (O) => ln(this._client, O),
3963
+ ...vt
3964
+ },
3686
3965
  i ?? (() => _.warn("[Websdk5Adapter] 用户资料订阅无权限,已自动熔断"))
3687
3966
  ), this._userInfoDomain.listen(), this._setupEventHandlers(), _.info("[Websdk5Adapter] init 完成");
3688
3967
  }
3689
3968
  async login(e, t) {
3690
- var o, a, r, i, c, d, g;
3969
+ var o, a, r, i, c, u, l;
3691
3970
  if (!this._client)
3692
3971
  throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
3693
3972
  this._eventsRegistered || (_.debug("[Websdk5Adapter] 登出后重新登录,恢复事件处理器与用户资料监听"), (o = this._userInfoDomain) == null || o.listen(), this._setupEventHandlers());
3694
- const n = At(e);
3973
+ const n = xt(e);
3695
3974
  n !== e && _.warn("[Websdk5Adapter] 检测到登录 userId 包含大写字母,已强制转换为纯小写后继续登录", {
3696
3975
  originalUserId: e,
3697
3976
  normalizedUserId: n
3698
3977
  }), _.info("[Websdk5Adapter] login 开始", { user: n }), (i = (a = this._stores) == null ? void 0 : (r = a.client).setCurrentUser) == null || i.call(r, n);
3699
3978
  try {
3700
3979
  await this._client.login(n, t, this._loginTimeoutMs);
3701
- } catch (m) {
3702
- throw (g = (c = this._stores) == null ? void 0 : (d = c.client).setCurrentUser) == null || g.call(d, ""), _.error("[Websdk5Adapter] login 失败:", U(m)), m;
3980
+ } catch (g) {
3981
+ throw (l = (c = this._stores) == null ? void 0 : (u = c.client).setCurrentUser) == null || l.call(u, ""), _.error("[Websdk5Adapter] login 失败:", L(g)), g;
3703
3982
  }
3704
3983
  _.info("[Websdk5Adapter] login 成功", { user: n });
3705
3984
  }
@@ -3735,10 +4014,10 @@ class ts {
3735
4014
  _.debug("[Websdk5Adapter] IM 事件套件已关闭(registerImEvents=false),场景事件由业务经 onAdapterReady 自行注册");
3736
4015
  return;
3737
4016
  }
3738
- En(), (e = this._disposeSyncListener) == null || e.call(this), this._disposeSyncListener = Sn((n) => {
4017
+ Wn(), (e = this._disposeSyncListener) == null || e.call(this), this._disposeSyncListener = qn((n) => {
3739
4018
  var o, a;
3740
4019
  (a = (o = this._getFanout()).onSyncStatus) == null || a.call(o, n);
3741
- }), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers = Bn(
4020
+ }), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers = as(
3742
4021
  this._client,
3743
4022
  this._stores,
3744
4023
  {
@@ -3760,89 +4039,90 @@ class ts {
3760
4039
  get message() {
3761
4040
  if (!this._domains)
3762
4041
  throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
3763
- return $t({ message: this._domains.message, conversation: this._domains.conversation });
4042
+ return an({ message: this._domains.message, conversation: this._domains.conversation });
3764
4043
  }
3765
4044
  get conversation() {
3766
4045
  if (!this._domains)
3767
4046
  throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
3768
- return Wt(this._domains.conversation);
4047
+ return rn(this._domains.conversation);
3769
4048
  }
3770
4049
  get contact() {
3771
4050
  if (!this._domains)
3772
4051
  throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
3773
- return qt(this._domains.contact);
4052
+ return sn(this._domains.contact);
3774
4053
  }
3775
4054
  get group() {
3776
4055
  if (!this._domains)
3777
4056
  throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
3778
- return Jt(this._domains.group);
4057
+ return on(this._domains.group);
3779
4058
  }
3780
4059
  get presence() {
3781
4060
  if (!this._domains)
3782
4061
  throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
3783
- return Qt(this._domains.presence);
4062
+ return cn(this._domains.presence);
3784
4063
  }
3785
4064
  get userInfo() {
3786
4065
  if (!this._userInfoDomain)
3787
4066
  throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
3788
- return zt(this._userInfoDomain);
4067
+ return un(this._userInfoDomain);
3789
4068
  }
3790
4069
  }
3791
4070
  export {
3792
- Be as ALL_USER_INFO_ATTRIBUTES,
3793
- In as ContactDomain,
3794
- pn as ConversationDomain,
3795
- yn as GroupDomain,
3796
- dn as MessageDomain,
3797
- bn as PresenceDomain,
3798
- _t as UIKitClient,
3799
- Cn as UserInfoDomain,
3800
- Hn as WEBSDK5_CHATROOM_MANAGERS,
3801
- Fn as WEBSDK5_MANAGERS,
3802
- ts as Websdk5Adapter,
3803
- Nn as createChatHandlers,
3804
- Nt as createClient,
3805
- wn as createConnectionHandlers,
3806
- kn as createContactHandlers,
3807
- On as createGroupHandlers,
3808
- Pn as createPresenceHandlers,
3809
- Ue as defaultAdapterPreviewLabels,
3810
- Jn as disableSdkLogCapture,
3811
- Wn as enableSdkLogCapture,
3812
- zn as extractLastMessageText,
3813
- tn as extractSdkErrorReason,
3814
- Xt as extractSnippetText,
3815
- U as formatSdkError,
3816
- Yn as isMessageInConversation,
3817
- $n as isSdkDebugEnabled,
3818
- an as markReadReceiptSent,
3819
- rs as normalizeUserId,
3820
- Fe as notifyContactEvent,
3821
- Rn as notifyOnNewMessage,
3822
- nt as parsePresenceStatus,
3823
- Bn as registerEventHandlers,
3824
- Un as resetChatEventState,
3825
- An as resetSyncStatus,
3826
- Xn as resolvePeerUserId,
3827
- en as resolveSdkErrorCodeI18nKey,
3828
- nn as resolveSdkErrorI18nKey,
3829
- Zn as resolveSdkErrorMessage,
3830
- ot as resolveSenderDisplayName,
3831
- Tn as resolveUserDisplayName,
3832
- rt as setEventHandlerDeps,
3833
- Rt as setSdkDebugGuard,
3834
- qn as setSdkLogAppender,
3835
- be as setSyncStatus,
3836
- Sn as setSyncStatusListener,
3837
- hn as toUiContact,
3838
- Ge as toUiContacts,
3839
- ln as toUiConversation,
3840
- te as toUiConversations,
3841
- Le as toUiGroup,
3842
- Mn as toUiGroupMember,
3843
- Z as toUiGroupMembers,
3844
- fe as toUiGroups,
3845
- P as toUiMessage,
3846
- Qn as toUiMessages,
3847
- es as useSyncStatus
4071
+ Ue as ALL_USER_INFO_ATTRIBUTES,
4072
+ Dn as ContactDomain,
4073
+ Rn as ConversationDomain,
4074
+ kn as GroupDomain,
4075
+ Sn as MessageDomain,
4076
+ Ge as PRESENCE_REQUEST_BATCH_SIZE,
4077
+ On as PresenceDomain,
4078
+ Vt as UIKitClient,
4079
+ Hn as UserInfoDomain,
4080
+ us as WEBSDK5_CHATROOM_MANAGERS,
4081
+ cs as WEBSDK5_MANAGERS,
4082
+ ws as Websdk5Adapter,
4083
+ ns as createChatHandlers,
4084
+ Wt as createClient,
4085
+ Kn as createConnectionHandlers,
4086
+ ss as createContactHandlers,
4087
+ rs as createGroupHandlers,
4088
+ is as createPresenceHandlers,
4089
+ Be as defaultAdapterPreviewLabels,
4090
+ ps as disableSdkLogCapture,
4091
+ ms as enableSdkLogCapture,
4092
+ Is as extractLastMessageText,
4093
+ hn as extractSdkErrorReason,
4094
+ gn as extractSnippetText,
4095
+ L as formatSdkError,
4096
+ Ms as isMessageInConversation,
4097
+ hs as isSdkDebugEnabled,
4098
+ Cn as markReadReceiptSent,
4099
+ Es as normalizeUserId,
4100
+ Qe as notifyContactEvent,
4101
+ $n as notifyOnNewMessage,
4102
+ ft as parsePresenceStatus,
4103
+ as as registerEventHandlers,
4104
+ Xn as resetChatEventState,
4105
+ jn as resetSyncStatus,
4106
+ ys as resolvePeerUserId,
4107
+ pn as resolveSdkErrorCodeI18nKey,
4108
+ vn as resolveSdkErrorI18nKey,
4109
+ Cs as resolveSdkErrorMessage,
4110
+ pt as resolveSenderDisplayName,
4111
+ Jn as resolveUserDisplayName,
4112
+ mt as setEventHandlerDeps,
4113
+ Ht as setSdkDebugGuard,
4114
+ gs as setSdkLogAppender,
4115
+ Re as setSyncStatus,
4116
+ qn as setSyncStatusListener,
4117
+ Ln as toUiContact,
4118
+ ke as toUiContacts,
4119
+ An as toUiConversation,
4120
+ se as toUiConversations,
4121
+ Fe as toUiGroup,
4122
+ Nn as toUiGroupMember,
4123
+ te as toUiGroupMembers,
4124
+ Ie as toUiGroups,
4125
+ H as toUiMessage,
4126
+ vs as toUiMessages,
4127
+ bs as useSyncStatus
3848
4128
  };