@linktr.ee/messaging-react 1.11.4 → 1.11.5-rc-1765005296

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { jsx as e, jsxs as i, Fragment as he } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as i, Fragment as fe } from "react/jsx-runtime";
2
2
  import p from "classnames";
3
- import Z, { createContext as Ie, useContext as Se, useCallback as F, useState as v, useRef as z, useEffect as G } from "react";
4
- import { StreamChatService as ke } from "@linktr.ee/messaging-core";
5
- import { Chat as pe, ChannelList as Re, useMessageComposer as De, useStateStore as _e, MessageInput as Me, useMessageInputContext as Fe, useMessageComposerHasSendableData as Te, SimpleAttachmentSelector as Pe, QuotedMessagePreview as Le, AttachmentPreviewList as Ue, TextareaComposer as Oe, MessageTimestamp as je, Channel as Ae, useChannelStateContext as fe, Window as Be, MessageList as ze } from "stream-chat-react";
6
- import { XIcon as le, ArrowUpIcon as Ge, ArrowLeftIcon as ae, DotsThreeIcon as ie, SpinnerGapIcon as ee, SignOutIcon as He, ProhibitInsetIcon as ce, FlagIcon as $e, MagnifyingGlassIcon as Ve, ChatCircleDotsIcon as de } from "@phosphor-icons/react";
7
- import { LinkPreviewsManager as ue } from "stream-chat";
8
- const ge = Ie({
3
+ import L, { createContext as De, useContext as Me, useCallback as M, useState as v, useRef as $, useEffect as G } from "react";
4
+ import { StreamChatService as Fe } from "@linktr.ee/messaging-core";
5
+ import { Chat as Pe, ChannelList as Te, useMessageComposer as Le, useStateStore as Ue, MessageInput as Oe, useMessageInputContext as je, useMessageComposerHasSendableData as Be, SimpleAttachmentSelector as Ae, QuotedMessagePreview as ze, AttachmentPreviewList as $e, TextareaComposer as Ge, MessageTimestamp as He, Channel as Ve, useChannelStateContext as ge, Window as We, MessageList as Ze } from "stream-chat-react";
6
+ import { XIcon as ae, ArrowUpIcon as qe, ArrowLeftIcon as ie, DotsThreeIcon as ce, SpinnerGapIcon as se, SignOutIcon as Ye, ProhibitInsetIcon as de, FlagIcon as Je, MagnifyingGlassIcon as Qe, ChatCircleDotsIcon as ue } from "@phosphor-icons/react";
7
+ import { LinkPreviewsManager as me } from "stream-chat";
8
+ const xe = De({
9
9
  service: null,
10
10
  client: null,
11
11
  isConnected: !1,
@@ -15,48 +15,48 @@ const ge = Ie({
15
15
  refreshConnection: async () => {
16
16
  },
17
17
  debug: !1
18
- }), se = () => Se(ge), Is = ({
18
+ }), ne = () => Me(xe), ks = ({
19
19
  children: t,
20
20
  user: s,
21
21
  serviceConfig: n,
22
22
  apiKey: r,
23
- capabilities: o = {},
24
- debug: a = !1
23
+ capabilities: a = {},
24
+ debug: o = !1
25
25
  }) => {
26
- const l = F(
26
+ const l = M(
27
27
  (u, ...x) => {
28
- a && console.log(`🔥 [MessagingProvider] ${u}`, ...x);
28
+ o && console.log(`🔥 [MessagingProvider] ${u}`, ...x);
29
29
  },
30
- [a]
30
+ [o]
31
31
  );
32
32
  l("🔄 RENDER START", {
33
33
  userId: s == null ? void 0 : s.id,
34
34
  apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
35
35
  serviceConfig: !!n,
36
- capabilities: Object.keys(o)
36
+ capabilities: Object.keys(a)
37
37
  });
38
- const [c, m] = v(null), [g, E] = v(null), [h, f] = v(!1), [k, b] = v(!1), [w, y] = v(null), N = z(!1), I = z({
38
+ const [c, m] = v(null), [g, y] = v(null), [h, f] = v(!1), [S, b] = v(!1), [w, E] = v(null), N = $(!1), I = $({
39
39
  userId: s == null ? void 0 : s.id,
40
40
  apiKey: r,
41
41
  serviceConfig: n,
42
- capabilities: o
43
- }), S = z(0);
44
- S.current++, l("📊 RENDER INFO", {
45
- renderCount: S.current,
42
+ capabilities: a
43
+ }), k = $(0);
44
+ k.current++, l("📊 RENDER INFO", {
45
+ renderCount: k.current,
46
46
  currentProps: { userId: s == null ? void 0 : s.id, apiKey: (r == null ? void 0 : r.substring(0, 8)) + "..." },
47
47
  propChanges: {
48
48
  userChanged: I.current.userId !== (s == null ? void 0 : s.id),
49
49
  apiKeyChanged: I.current.apiKey !== r,
50
50
  serviceConfigChanged: I.current.serviceConfig !== n,
51
- capabilitiesChanged: I.current.capabilities !== o
51
+ capabilitiesChanged: I.current.capabilities !== a
52
52
  }
53
53
  }), I.current = {
54
54
  userId: s == null ? void 0 : s.id,
55
55
  apiKey: r,
56
56
  serviceConfig: n,
57
- capabilities: o
57
+ capabilities: a
58
58
  }, G(() => {
59
- const u = S.current;
59
+ const u = k.current;
60
60
  if (l("🔧 SERVICE INIT EFFECT TRIGGERED", {
61
61
  renderCount: u,
62
62
  apiKey: !!r,
@@ -79,10 +79,10 @@ const ge = Ie({
79
79
  apiKey: (r == null ? void 0 : r.substring(0, 8)) + "...",
80
80
  serviceConfigChanged: I.current.serviceConfig !== n
81
81
  });
82
- const x = new ke({
82
+ const x = new Fe({
83
83
  ...n,
84
84
  apiKey: r,
85
- debug: a
85
+ debug: o
86
86
  });
87
87
  return m(x), l("✅ SERVICE SET", {
88
88
  renderCount: u,
@@ -93,10 +93,10 @@ const ge = Ie({
93
93
  reason: "Effect cleanup"
94
94
  }), x.disconnectUser().catch(console.error);
95
95
  };
96
- }, [r, n, a, l]);
97
- const R = z(null);
96
+ }, [r, n, o, l]);
97
+ const R = $(null);
98
98
  G(() => {
99
- var x, j;
99
+ var x, A;
100
100
  if (l("🔗 USER CONNECTION EFFECT TRIGGERED", {
101
101
  hasService: !!c,
102
102
  hasUser: !!s,
@@ -112,7 +112,7 @@ const ge = Ie({
112
112
  l("⚠️ USER CONNECTION SKIPPED", "Already connecting");
113
113
  return;
114
114
  }
115
- if (((x = R.current) == null ? void 0 : x.serviceId) === c && ((j = R.current) == null ? void 0 : j.userId) === s.id) {
115
+ if (((x = R.current) == null ? void 0 : x.serviceId) === c && ((A = R.current) == null ? void 0 : A.userId) === s.id) {
116
116
  l(
117
117
  "⚠️ USER CONNECTION SKIPPED",
118
118
  "Already connected this user with this service"
@@ -120,19 +120,19 @@ const ge = Ie({
120
120
  return;
121
121
  }
122
122
  (async () => {
123
- l("🚀 STARTING USER CONNECTION", { userId: s.id }), N.current = !0, b(!0), y(null);
123
+ l("🚀 STARTING USER CONNECTION", { userId: s.id }), N.current = !0, b(!0), E(null);
124
124
  try {
125
125
  l("📞 CALLING SERVICE.CONNECTUSER", { userId: s.id });
126
- const A = await c.connectUser(s);
127
- E(A), f(!0), R.current = { serviceId: c, userId: s.id }, l("✅ USER CONNECTION SUCCESS", {
126
+ const z = await c.connectUser(s);
127
+ y(z), f(!0), R.current = { serviceId: c, userId: s.id }, l("✅ USER CONNECTION SUCCESS", {
128
128
  userId: s.id,
129
- clientId: A.userID
129
+ clientId: z.userID
130
130
  });
131
- } catch (A) {
132
- const W = A instanceof Error ? A.message : "Connection failed";
133
- y(W), l("❌ USER CONNECTION ERROR", {
131
+ } catch (z) {
132
+ const Z = z instanceof Error ? z.message : "Connection failed";
133
+ E(Z), l("❌ USER CONNECTION ERROR", {
134
134
  userId: s.id,
135
- error: W
135
+ error: Z
136
136
  });
137
137
  } finally {
138
138
  b(!1), N.current = !1, l("🔄 USER CONNECTION FINISHED", {
@@ -153,7 +153,7 @@ const ge = Ie({
153
153
  isConnected: h
154
154
  });
155
155
  }), [c, h, l]);
156
- const _ = F(async () => {
156
+ const F = M(async () => {
157
157
  if (l("🔄 REFRESH CONNECTION CALLED", {
158
158
  hasService: !!c,
159
159
  hasUser: !!s
@@ -165,49 +165,49 @@ const ge = Ie({
165
165
  try {
166
166
  l("🔌 DISCONNECTING FOR REFRESH"), await c.disconnectUser(), l("📞 RECONNECTING FOR REFRESH");
167
167
  const u = await c.connectUser(s);
168
- E(u), f(!0), y(null), l("✅ CONNECTION REFRESH SUCCESS", { userId: s.id });
168
+ y(u), f(!0), E(null), l("✅ CONNECTION REFRESH SUCCESS", { userId: s.id });
169
169
  } catch (u) {
170
170
  const x = u instanceof Error ? u.message : "Refresh failed";
171
- y(x), l("❌ CONNECTION REFRESH ERROR", {
171
+ E(x), l("❌ CONNECTION REFRESH ERROR", {
172
172
  userId: s.id,
173
173
  error: x
174
174
  });
175
175
  } finally {
176
176
  b(!1), l("🔄 CONNECTION REFRESH FINISHED", { userId: s.id });
177
177
  }
178
- }, [c, s, l]), d = Z.useMemo(() => (l("💫 CONTEXT VALUE MEMOIZATION", {
178
+ }, [c, s, l]), d = L.useMemo(() => (l("💫 CONTEXT VALUE MEMOIZATION", {
179
179
  hasService: !!c,
180
180
  hasClient: !!g,
181
181
  isConnected: h,
182
- isLoading: k,
182
+ isLoading: S,
183
183
  hasError: !!w,
184
- capabilitiesKeys: Object.keys(o)
184
+ capabilitiesKeys: Object.keys(a)
185
185
  }), {
186
186
  service: c,
187
187
  client: g,
188
188
  isConnected: h,
189
- isLoading: k,
189
+ isLoading: S,
190
190
  error: w,
191
- capabilities: o,
192
- refreshConnection: _,
193
- debug: a
191
+ capabilities: a,
192
+ refreshConnection: F,
193
+ debug: o
194
194
  }), [
195
195
  c,
196
196
  g,
197
197
  h,
198
- k,
198
+ S,
199
199
  w,
200
- o,
201
- _,
202
200
  a,
201
+ F,
202
+ o,
203
203
  l
204
204
  ]);
205
205
  return l("🔄 RENDER END", {
206
- renderCount: S.current,
206
+ renderCount: k.current,
207
207
  willRenderChat: !!(g && h),
208
208
  contextValueReady: !!d
209
- }), /* @__PURE__ */ e(ge.Provider, { value: d, children: g && h ? /* @__PURE__ */ e(
210
- pe,
209
+ }), /* @__PURE__ */ e(xe.Provider, { value: d, children: g && h ? /* @__PURE__ */ e(
210
+ Pe,
211
211
  {
212
212
  client: g,
213
213
  customClasses: {
@@ -216,18 +216,18 @@ const ge = Ie({
216
216
  children: t
217
217
  }
218
218
  ) : t });
219
- }, We = () => se(), Ze = (t, s) => {
219
+ }, Xe = () => ne(), Ke = (t, s) => {
220
220
  const n = new Date(
221
221
  Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate())
222
- ), o = new Date(
222
+ ), a = new Date(
223
223
  Date.UTC(s.getUTCFullYear(), s.getUTCMonth(), s.getUTCDate())
224
224
  ).getTime() - n.getTime();
225
- return Math.floor(o / (1e3 * 60 * 60 * 24));
226
- }, qe = (t) => {
225
+ return Math.floor(a / (1e3 * 60 * 60 * 24));
226
+ }, es = (t) => {
227
227
  const s = /* @__PURE__ */ new Date();
228
228
  if (Math.floor((s.getTime() - t.getTime()) / 1e3) < 60)
229
229
  return "Just now";
230
- const r = Ze(t, s);
230
+ const r = Ke(t, s);
231
231
  return r === 0 ? t.toLocaleTimeString([], {
232
232
  hour: "numeric",
233
233
  minute: "2-digit"
@@ -236,7 +236,7 @@ const ge = Ie({
236
236
  day: "numeric",
237
237
  year: "2-digit"
238
238
  });
239
- }, me = [
239
+ }, he = [
240
240
  "🍎",
241
241
  // Apple
242
242
  "🍌",
@@ -264,7 +264,7 @@ const ge = Ie({
264
264
  "🍈"
265
265
  // Melon
266
266
  ];
267
- function Ye(t) {
267
+ function ss(t) {
268
268
  let s = 0;
269
269
  for (let n = 0; n < t.length; n++) {
270
270
  const r = t.charCodeAt(n);
@@ -272,18 +272,18 @@ function Ye(t) {
272
272
  }
273
273
  return Math.abs(s);
274
274
  }
275
- function Je(t) {
276
- const n = Ye(t) % me.length;
277
- return me[n];
275
+ function ts(t) {
276
+ const n = ss(t) % he.length;
277
+ return he[n];
278
278
  }
279
279
  const q = ({
280
280
  id: t,
281
281
  image: s,
282
282
  size: n = 40,
283
283
  className: r,
284
- shape: o = "squircle"
284
+ shape: a = "squircle"
285
285
  }) => {
286
- const a = Je(t), c = n < 32 ? "text-xs" : n < 56 ? "text-sm" : "text-lg", m = o === "circle" ? { borderRadius: "50%" } : {
286
+ const o = ts(t), c = n < 32 ? "text-xs" : n < 56 ? "text-sm" : "text-lg", m = a === "circle" ? { borderRadius: "50%" } : {
287
287
  borderRadius: "33%",
288
288
  "corner-shape": "superellipse(1.3)"
289
289
  };
@@ -311,130 +311,130 @@ const q = ({
311
311
  "avatar-fallback flex h-full w-full items-center justify-center font-semibold bg-[#E6E5E3] select-none transition-colors",
312
312
  c
313
313
  ),
314
- children: a
314
+ children: o
315
315
  }
316
316
  )
317
317
  }
318
318
  );
319
- }, Qe = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: r = !1, unread: o }) => {
320
- var y, N, I, S, R, _;
321
- const a = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), l = () => {
322
- t && n(t);
323
- }, m = Object.values(((y = t == null ? void 0 : t.state) == null ? void 0 : y.members) || {}).find(
324
- (d) => {
325
- var u, x;
326
- return ((u = d.user) == null ? void 0 : u.id) && d.user.id !== ((x = t == null ? void 0 : t._client) == null ? void 0 : x.userID);
327
- }
328
- ), g = ((N = m == null ? void 0 : m.user) == null ? void 0 : N.name) || "Conversation", E = (I = m == null ? void 0 : m.user) == null ? void 0 : I.image, h = (R = (S = t == null ? void 0 : t.state) == null ? void 0 : S.messages) == null ? void 0 : R[t.state.messages.length - 1], k = (() => {
329
- var u;
330
- if (h != null && h.text) return h.text;
331
- const d = (u = h == null ? void 0 : h.attachments) == null ? void 0 : u[0];
332
- return d != null && d.asset_url ? d.asset_url : d != null && d.image_url ? d.image_url : d != null && d.og_scrape_url ? d.og_scrape_url : d != null && d.thumb_url ? d.thumb_url : "No messages yet";
333
- })(), b = h != null && h.created_at ? qe(new Date(h.created_at)) : "", w = o ?? 0;
334
- return r && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
335
- channelId: t == null ? void 0 : t.id,
336
- isSelected: a,
337
- participantName: g,
338
- unreadCount: w,
339
- hasTimestamp: !!b
340
- }), /* @__PURE__ */ e(
341
- "button",
342
- {
343
- type: "button",
344
- onClick: l,
345
- className: p(
346
- "group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring",
347
- {
348
- "bg-primary-alt/10 border-l-4 border-l-primary": a,
349
- "hover:bg-sand": !a
350
- }
351
- ),
352
- children: /* @__PURE__ */ i("div", { className: "flex items-start gap-3", children: [
353
- /* @__PURE__ */ e(
354
- q,
319
+ }, Ce = L.memo(
320
+ ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: r = !1, unread: a }) => {
321
+ var E, N, I, k, R, F;
322
+ const o = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), l = () => {
323
+ t && n(t);
324
+ }, m = Object.values(((E = t == null ? void 0 : t.state) == null ? void 0 : E.members) || {}).find(
325
+ (d) => {
326
+ var u, x;
327
+ return ((u = d.user) == null ? void 0 : u.id) && d.user.id !== ((x = t == null ? void 0 : t._client) == null ? void 0 : x.userID);
328
+ }
329
+ ), g = ((N = m == null ? void 0 : m.user) == null ? void 0 : N.name) || "Conversation", y = (I = m == null ? void 0 : m.user) == null ? void 0 : I.image, h = (R = (k = t == null ? void 0 : t.state) == null ? void 0 : k.messages) == null ? void 0 : R[t.state.messages.length - 1], S = (() => {
330
+ var u;
331
+ if (h != null && h.text) return h.text;
332
+ const d = (u = h == null ? void 0 : h.attachments) == null ? void 0 : u[0];
333
+ return d != null && d.asset_url ? d.asset_url : d != null && d.image_url ? d.image_url : d != null && d.og_scrape_url ? d.og_scrape_url : d != null && d.thumb_url ? d.thumb_url : "No messages yet";
334
+ })(), b = h != null && h.created_at ? es(new Date(h.created_at)) : "", w = a ?? 0;
335
+ return r && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
336
+ channelId: t == null ? void 0 : t.id,
337
+ isSelected: o,
338
+ participantName: g,
339
+ unreadCount: w,
340
+ hasTimestamp: !!b
341
+ }), /* @__PURE__ */ e(
342
+ "button",
343
+ {
344
+ type: "button",
345
+ onClick: l,
346
+ className: p(
347
+ "group w-full px-4 py-3 transition-colors text-left max-w-full overflow-hidden focus-ring",
355
348
  {
356
- id: ((_ = m == null ? void 0 : m.user) == null ? void 0 : _.id) || t.id || "unknown",
357
- name: g,
358
- image: E,
359
- size: 44,
360
- className: "[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"
349
+ "bg-primary-alt/10 border-l-4 border-l-primary": o,
350
+ "hover:bg-sand": !o
361
351
  }
362
352
  ),
363
- /* @__PURE__ */ i("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
364
- /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-2", children: [
365
- /* @__PURE__ */ e(
366
- "h3",
367
- {
368
- className: p(
369
- "text-sm font-medium truncate",
370
- a ? "text-primary" : "text-charcoal"
371
- ),
372
- children: g
373
- }
374
- ),
375
- b && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: b })
376
- ] }),
377
- /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
378
- /* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children: k }),
379
- w > 0 && /* @__PURE__ */ e("span", { className: "bg-[#7f22fe] text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0", children: w > 99 ? "99+" : w })
353
+ children: /* @__PURE__ */ i("div", { className: "flex items-start gap-3", children: [
354
+ /* @__PURE__ */ e(
355
+ q,
356
+ {
357
+ id: ((F = m == null ? void 0 : m.user) == null ? void 0 : F.id) || t.id || "unknown",
358
+ name: g,
359
+ image: y,
360
+ size: 44,
361
+ className: "[&_.avatar-fallback]:group-hover:bg-[#eeeeee]"
362
+ }
363
+ ),
364
+ /* @__PURE__ */ i("div", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
365
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-2", children: [
366
+ /* @__PURE__ */ e(
367
+ "h3",
368
+ {
369
+ className: p(
370
+ "text-sm font-medium truncate",
371
+ o ? "text-primary" : "text-charcoal"
372
+ ),
373
+ children: g
374
+ }
375
+ ),
376
+ b && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: b })
377
+ ] }),
378
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
379
+ /* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children: S }),
380
+ w > 0 && /* @__PURE__ */ e("span", { className: "bg-[#7f22fe] text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0", children: w > 99 ? "99+" : w })
381
+ ] })
380
382
  ] })
381
383
  ] })
382
- ] })
383
- }
384
- );
385
- }, Xe = ({
386
- onChannelSelect: t,
387
- selectedChannel: s,
388
- filters: n,
389
- className: r,
390
- customEmptyStateIndicator: o
391
- }) => {
392
- const a = Z.useRef(0);
393
- a.current++;
394
- const { debug: l = !1 } = se();
395
- return l && console.log("📺 [ChannelList] 🔄 RENDER START", {
396
- renderCount: a.current,
397
- selectedChannelId: s == null ? void 0 : s.id,
398
- filters: n
399
- }), /* @__PURE__ */ e(
400
- "div",
401
- {
402
- className: p(
403
- "messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
404
- r
405
- ),
406
- children: /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: (l && console.log("📺 [ChannelList] 🎬 RENDERING STREAM CHANNEL LIST", {
407
- renderCount: a.current,
408
- filters: n
409
- }), /* @__PURE__ */ e(
410
- Re,
411
- {
412
- filters: n,
413
- sort: { last_message_at: -1 },
414
- options: { limit: 30 },
415
- Preview: (c) => {
416
- var m, g;
417
- return l && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
418
- channelId: (m = c.channel) == null ? void 0 : m.id,
419
- selectedChannelId: s == null ? void 0 : s.id,
420
- isSelected: (s == null ? void 0 : s.id) === ((g = c.channel) == null ? void 0 : g.id)
421
- }), /* @__PURE__ */ e(
422
- Qe,
423
- {
424
- ...c,
425
- selectedChannel: s,
426
- onChannelSelect: t,
427
- debug: l
428
- }
429
- );
384
+ }
385
+ );
386
+ }
387
+ );
388
+ Ce.displayName = "CustomChannelPreview";
389
+ const Ne = L.memo(
390
+ ({
391
+ onChannelSelect: t,
392
+ selectedChannel: s,
393
+ filters: n,
394
+ className: r,
395
+ customEmptyStateIndicator: a
396
+ }) => {
397
+ const o = L.useRef(0);
398
+ o.current++;
399
+ const { debug: l = !1 } = ne();
400
+ l && console.log("📺 [ChannelList] 🔄 RENDER START", {
401
+ renderCount: o.current,
402
+ selectedChannelId: s == null ? void 0 : s.id,
403
+ filters: n
404
+ });
405
+ const c = L.useMemo(() => (g) => /* @__PURE__ */ e(
406
+ Ce,
407
+ {
408
+ ...g,
409
+ selectedChannel: s,
410
+ onChannelSelect: t,
411
+ debug: l
412
+ }
413
+ ), [s, t, l]);
414
+ return /* @__PURE__ */ e(
415
+ "div",
416
+ {
417
+ className: p(
418
+ "messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
419
+ r
420
+ ),
421
+ children: /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: /* @__PURE__ */ e(
422
+ Te,
423
+ {
424
+ filters: n,
425
+ sort: { last_message_at: -1 },
426
+ options: { limit: 30 },
427
+ Preview: c,
428
+ EmptyStateIndicator: a
430
429
  },
431
- EmptyStateIndicator: o
432
- },
433
- JSON.stringify(n)
434
- )) })
435
- }
436
- );
437
- }, K = ({
430
+ JSON.stringify(n)
431
+ ) })
432
+ }
433
+ );
434
+ }
435
+ );
436
+ Ne.displayName = "ChannelList";
437
+ const ee = ({
438
438
  variant: t = "default",
439
439
  className: s,
440
440
  children: n,
@@ -452,7 +452,7 @@ const q = ({
452
452
  children: n
453
453
  }
454
454
  );
455
- function xe({ label: t, className: s, children: n, ...r }) {
455
+ function be({ label: t, className: s, children: n, ...r }) {
456
456
  return /* @__PURE__ */ i(
457
457
  "button",
458
458
  {
@@ -473,18 +473,18 @@ function xe({ label: t, className: s, children: n, ...r }) {
473
473
  }
474
474
  );
475
475
  }
476
- function Ce({ onClick: t }) {
477
- return /* @__PURE__ */ e(xe, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(le, { className: "h-5 w-5 text-stone", weight: "bold" }) });
476
+ function ve({ onClick: t }) {
477
+ return /* @__PURE__ */ e(be, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(ae, { className: "h-5 w-5 text-stone", weight: "bold" }) });
478
478
  }
479
- const Ke = (t) => ({
479
+ const ns = (t) => ({
480
480
  linkPreviews: Array.from(t.previews.values()).filter(
481
- (s) => ue.previewIsLoaded(s) || ue.previewIsLoading(s)
481
+ (s) => me.previewIsLoaded(s) || me.previewIsLoading(s)
482
482
  )
483
- }), es = ({
483
+ }), rs = ({
484
484
  link: t,
485
485
  onDismiss: s
486
486
  }) => {
487
- const { og_scrape_url: n, title: r, image_url: o } = t;
487
+ const { og_scrape_url: n, title: r, image_url: a } = t;
488
488
  return /* @__PURE__ */ i(
489
489
  "a",
490
490
  {
@@ -493,10 +493,10 @@ const Ke = (t) => ({
493
493
  rel: "noopener noreferrer",
494
494
  className: "relative w-full block rounded-[24px] bg-[#121110] p-2 no-underline transition-opacity hover:opacity-90",
495
495
  children: [
496
- o && /* @__PURE__ */ e(
496
+ a && /* @__PURE__ */ e(
497
497
  "img",
498
498
  {
499
- src: o,
499
+ src: a,
500
500
  alt: r || "",
501
501
  className: "h-[148px] w-full rounded-[20px] object-cover"
502
502
  }
@@ -510,7 +510,7 @@ const Ke = (t) => ({
510
510
  },
511
511
  className: "absolute right-4 top-4 flex size-6 items-center justify-center rounded-full border border-white/40 bg-white/70 backdrop-blur-2xl",
512
512
  "aria-label": "Close link preview",
513
- children: /* @__PURE__ */ e(le, { className: "size-4 text-black/90" })
513
+ children: /* @__PURE__ */ e(ae, { className: "size-4 text-black/90" })
514
514
  }
515
515
  ),
516
516
  /* @__PURE__ */ i("div", { className: "p-2", children: [
@@ -520,32 +520,32 @@ const Ke = (t) => ({
520
520
  ]
521
521
  }
522
522
  );
523
- }, ss = () => {
524
- const { linkPreviewsManager: t } = De(), { linkPreviews: s } = _e(
523
+ }, ls = () => {
524
+ const { linkPreviewsManager: t } = Le(), { linkPreviews: s } = Ue(
525
525
  t.state,
526
- Ke
527
- ), n = (o) => {
528
- t.dismissPreview(o);
526
+ ns
527
+ ), n = (a) => {
528
+ t.dismissPreview(a);
529
529
  };
530
- return s.length > 0 ? /* @__PURE__ */ e("div", { className: "str-chat__link-preview-list p-0 gap-2 mb-4", children: s.map((o) => /* @__PURE__ */ e(
531
- es,
530
+ return s.length > 0 ? /* @__PURE__ */ e("div", { className: "str-chat__link-preview-list p-0 gap-2 mb-4", children: s.map((a) => /* @__PURE__ */ e(
531
+ rs,
532
532
  {
533
- link: o,
533
+ link: a,
534
534
  onDismiss: n
535
535
  },
536
- o.og_scrape_url
536
+ a.og_scrape_url
537
537
  )) }) : null;
538
- }, ts = () => {
539
- const { handleSubmit: t } = Fe(), s = Te();
540
- return /* @__PURE__ */ i(he, { children: [
541
- /* @__PURE__ */ e("div", { className: "left-container", children: /* @__PURE__ */ e(Pe, {}) }),
538
+ }, as = () => {
539
+ const { handleSubmit: t } = je(), s = Be();
540
+ return /* @__PURE__ */ i(fe, { children: [
541
+ /* @__PURE__ */ e("div", { className: "left-container", children: /* @__PURE__ */ e(Ae, {}) }),
542
542
  /* @__PURE__ */ i("div", { className: "central-container min-w-0 w-full p-2 bg-white rounded-[1.5rem] shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]", children: [
543
- /* @__PURE__ */ e(Le, {}),
544
- /* @__PURE__ */ e(ss, {}),
545
- /* @__PURE__ */ e(Ue, {}),
543
+ /* @__PURE__ */ e(ze, {}),
544
+ /* @__PURE__ */ e(ls, {}),
545
+ /* @__PURE__ */ e($e, {}),
546
546
  /* @__PURE__ */ i("div", { className: "flex", children: [
547
547
  /* @__PURE__ */ e("div", { className: "w-full ml-2 mr-4 self-center leading-[0]", children: /* @__PURE__ */ e(
548
- Oe,
548
+ Ge,
549
549
  {
550
550
  className: "w-full resize-none outline-none leading-6",
551
551
  maxRows: 4
@@ -560,18 +560,18 @@ const Ke = (t) => ({
560
560
  disabled: !s,
561
561
  onClick: t,
562
562
  type: "button",
563
- children: /* @__PURE__ */ e(Ge, { className: "size-4" })
563
+ children: /* @__PURE__ */ e(qe, { className: "size-4" })
564
564
  }
565
565
  )
566
566
  ] })
567
567
  ] })
568
568
  ] });
569
- }, ns = ({
569
+ }, os = ({
570
570
  renderActions: t
571
571
  }) => /* @__PURE__ */ i("div", { className: "message-input flex items-center gap-2 p-4", children: [
572
572
  t && (t == null ? void 0 : t()),
573
- /* @__PURE__ */ e(Me, { Input: ts })
574
- ] }), rs = (t) => {
573
+ /* @__PURE__ */ e(Oe, { Input: as })
574
+ ] }), is = (t) => {
575
575
  const s = t.message.hide_date === !0;
576
576
  return /* @__PURE__ */ i("div", { className: "str-chat__message--system", "data-testid": "message-system", children: [
577
577
  /* @__PURE__ */ i("div", { className: "str-chat__message--system__text", children: [
@@ -579,16 +579,16 @@ const Ke = (t) => ({
579
579
  /* @__PURE__ */ e("p", { children: t.message.text }),
580
580
  /* @__PURE__ */ e("div", { className: "str-chat__message--system__line" })
581
581
  ] }),
582
- !s && /* @__PURE__ */ e(je, { message: t.message })
582
+ !s && /* @__PURE__ */ e(He, { message: t.message })
583
583
  ] });
584
- }, ls = () => null, os = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) => {
585
- var m, g, E, h, f;
586
- const { channel: o } = fe(), a = Z.useMemo(() => Object.values(o.state.members || {}).find(
584
+ }, cs = () => null, ds = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: r }) => {
585
+ var m, g, y, h, f;
586
+ const { channel: a } = ge(), o = L.useMemo(() => Object.values(a.state.members || {}).find(
587
587
  (b) => {
588
588
  var w;
589
- return ((w = b.user) == null ? void 0 : w.id) && b.user.id !== o._client.userID;
589
+ return ((w = b.user) == null ? void 0 : w.id) && b.user.id !== a._client.userID;
590
590
  }
591
- ), [o._client.userID, o.state.members]), l = ((m = a == null ? void 0 : a.user) == null ? void 0 : m.name) || ((g = a == null ? void 0 : a.user) == null ? void 0 : g.id) || "Unknown member", c = (E = a == null ? void 0 : a.user) == null ? void 0 : E.image;
591
+ ), [a._client.userID, a.state.members]), l = ((m = o == null ? void 0 : o.user) == null ? void 0 : m.name) || ((g = o == null ? void 0 : o.user) == null ? void 0 : g.id) || "Unknown member", c = (y = o == null ? void 0 : o.user) == null ? void 0 : y.image;
592
592
  return /* @__PURE__ */ i("div", { className: "@container", children: [
593
593
  /* @__PURE__ */ i("div", { className: "flex justify-between items-center @lg:hidden", children: [
594
594
  /* @__PURE__ */ e(
@@ -600,14 +600,14 @@ const Ke = (t) => ({
600
600
  ),
601
601
  onClick: t || (() => {
602
602
  }),
603
- children: /* @__PURE__ */ e(ae, { className: "size-5 text-black/90" })
603
+ children: /* @__PURE__ */ e(ie, { className: "size-5 text-black/90" })
604
604
  }
605
605
  ),
606
606
  /* @__PURE__ */ i("div", { className: "flex flex-col gap-1 items-center", children: [
607
607
  /* @__PURE__ */ e(
608
608
  q,
609
609
  {
610
- id: ((h = a == null ? void 0 : a.user) == null ? void 0 : h.id) || o.id || "unknown",
610
+ id: ((h = o == null ? void 0 : o.user) == null ? void 0 : h.id) || a.id || "unknown",
611
611
  name: l,
612
612
  image: c,
613
613
  size: 40
@@ -623,7 +623,7 @@ const Ke = (t) => ({
623
623
  ),
624
624
  onClick: n || (() => {
625
625
  }),
626
- children: /* @__PURE__ */ e(ie, { className: "size-5 text-black/90" })
626
+ children: /* @__PURE__ */ e(ce, { className: "size-5 text-black/90" })
627
627
  }
628
628
  )
629
629
  ] }),
@@ -636,13 +636,13 @@ const Ke = (t) => ({
636
636
  onClick: t,
637
637
  className: "size-10 rounded-full bg-[#F1F0EE] flex items-center justify-center",
638
638
  "aria-label": "Back to conversations",
639
- children: /* @__PURE__ */ e(ae, { className: "size-5 text-black/90" })
639
+ children: /* @__PURE__ */ e(ie, { className: "size-5 text-black/90" })
640
640
  }
641
641
  ),
642
642
  /* @__PURE__ */ e(
643
643
  q,
644
644
  {
645
- id: ((f = a == null ? void 0 : a.user) == null ? void 0 : f.id) || o.id || "unknown",
645
+ id: ((f = o == null ? void 0 : o.user) == null ? void 0 : f.id) || a.id || "unknown",
646
646
  name: l,
647
647
  image: c,
648
648
  size: 40
@@ -657,80 +657,80 @@ const Ke = (t) => ({
657
657
  "size-10 rounded-full bg-[#F1F0EE] flex items-center justify-center"
658
658
  ),
659
659
  onClick: n,
660
- children: /* @__PURE__ */ e(ie, { className: "size-5 text-black/90" })
660
+ children: /* @__PURE__ */ e(ce, { className: "size-5 text-black/90" })
661
661
  }
662
662
  )
663
663
  ] })
664
664
  ] });
665
- }, as = ({
665
+ }, us = ({
666
666
  isOpen: t,
667
667
  onClose: s,
668
668
  participant: n,
669
669
  channel: r,
670
- followerStatusLabel: o,
671
- onLeaveConversation: a,
670
+ followerStatusLabel: a,
671
+ onLeaveConversation: o,
672
672
  onBlockParticipant: l
673
673
  }) => {
674
- var W, O, $, Y, H, V, J;
675
- const { service: c, debug: m } = se(), g = z(null), [E, h] = v(!1), [f, k] = v(!1), [b, w] = v(!1);
674
+ var Z, B, V, Y, H, W, J;
675
+ const { service: c, debug: m } = ne(), g = $(null), [y, h] = v(!1), [f, S] = v(!1), [b, w] = v(!1);
676
676
  G(() => {
677
- const D = g.current;
678
- D && (t ? D.showModal() : D.close());
677
+ const _ = g.current;
678
+ _ && (t ? _.showModal() : _.close());
679
679
  }, [t]);
680
- const y = F(async () => {
681
- var D;
682
- if (!(!c || !((D = n == null ? void 0 : n.user) != null && D.id)))
680
+ const E = M(async () => {
681
+ var _;
682
+ if (!(!c || !((_ = n == null ? void 0 : n.user) != null && _.id)))
683
683
  try {
684
- const P = (await c.getBlockedUsers()).some(
685
- (L) => {
684
+ const U = (await c.getBlockedUsers()).some(
685
+ (O) => {
686
686
  var Q;
687
- return L.blocked_user_id === ((Q = n == null ? void 0 : n.user) == null ? void 0 : Q.id);
687
+ return O.blocked_user_id === ((Q = n == null ? void 0 : n.user) == null ? void 0 : Q.id);
688
688
  }
689
689
  );
690
- h(P);
691
- } catch (T) {
690
+ h(U);
691
+ } catch (P) {
692
692
  console.error(
693
693
  "[ChannelInfoDialog] Failed to check blocked status:",
694
- T
694
+ P
695
695
  );
696
696
  }
697
- }, [c, (W = n == null ? void 0 : n.user) == null ? void 0 : W.id]);
697
+ }, [c, (Z = n == null ? void 0 : n.user) == null ? void 0 : Z.id]);
698
698
  G(() => {
699
- t && y();
700
- }, [t, y]);
699
+ t && E();
700
+ }, [t, E]);
701
701
  const N = async () => {
702
- var D;
702
+ var _;
703
703
  if (!f) {
704
- m && console.log("[ChannelInfoDialog] Leave conversation", r.cid), k(!0);
704
+ m && console.log("[ChannelInfoDialog] Leave conversation", r.cid), S(!0);
705
705
  try {
706
- const T = ((D = r._client) == null ? void 0 : D.userID) ?? null;
707
- await r.hide(T, !1), a && await a(r), s();
708
- } catch (T) {
709
- console.error("[ChannelInfoDialog] Failed to leave conversation", T);
706
+ const P = ((_ = r._client) == null ? void 0 : _.userID) ?? null;
707
+ await r.hide(P, !1), o && await o(r), s();
708
+ } catch (P) {
709
+ console.error("[ChannelInfoDialog] Failed to leave conversation", P);
710
710
  } finally {
711
- k(!1);
711
+ S(!1);
712
712
  }
713
713
  }
714
714
  }, I = async () => {
715
- var D, T, P;
715
+ var _, P, U;
716
716
  if (!(b || !c)) {
717
- m && console.log("[ChannelInfoDialog] Block member", (D = n == null ? void 0 : n.user) == null ? void 0 : D.id), w(!0);
717
+ m && console.log("[ChannelInfoDialog] Block member", (_ = n == null ? void 0 : n.user) == null ? void 0 : _.id), w(!0);
718
718
  try {
719
- await c.blockUser((T = n == null ? void 0 : n.user) == null ? void 0 : T.id), l && await l((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), s();
720
- } catch (L) {
721
- console.error("[ChannelInfoDialog] Failed to block member", L);
719
+ await c.blockUser((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), l && await l((U = n == null ? void 0 : n.user) == null ? void 0 : U.id), s();
720
+ } catch (O) {
721
+ console.error("[ChannelInfoDialog] Failed to block member", O);
722
722
  } finally {
723
723
  w(!1);
724
724
  }
725
725
  }
726
- }, S = async () => {
727
- var D, T, P;
726
+ }, k = async () => {
727
+ var _, P, U;
728
728
  if (!(b || !c)) {
729
- m && console.log("[ChannelInfoDialog] Unblock member", (D = n == null ? void 0 : n.user) == null ? void 0 : D.id), w(!0);
729
+ m && console.log("[ChannelInfoDialog] Unblock member", (_ = n == null ? void 0 : n.user) == null ? void 0 : _.id), w(!0);
730
730
  try {
731
- await c.unBlockUser((T = n == null ? void 0 : n.user) == null ? void 0 : T.id), l && await l((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), s();
732
- } catch (L) {
733
- console.error("[ChannelInfoDialog] Failed to unblock member", L);
731
+ await c.unBlockUser((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), l && await l((U = n == null ? void 0 : n.user) == null ? void 0 : U.id), s();
732
+ } catch (O) {
733
+ console.error("[ChannelInfoDialog] Failed to unblock member", O);
734
734
  } finally {
735
735
  w(!1);
736
736
  }
@@ -743,7 +743,7 @@ const Ke = (t) => ({
743
743
  );
744
744
  };
745
745
  if (!n) return null;
746
- const _ = ((O = n.user) == null ? void 0 : O.name) || (($ = n.user) == null ? void 0 : $.id) || "Unknown member", d = (Y = n.user) == null ? void 0 : Y.image, u = (H = n.user) == null ? void 0 : H.email, x = (V = n.user) == null ? void 0 : V.username, j = u || (x ? `linktr.ee/${x}` : void 0), A = ((J = n.user) == null ? void 0 : J.id) || "unknown";
746
+ const F = ((B = n.user) == null ? void 0 : B.name) || ((V = n.user) == null ? void 0 : V.id) || "Unknown member", d = (Y = n.user) == null ? void 0 : Y.image, u = (H = n.user) == null ? void 0 : H.email, x = (W = n.user) == null ? void 0 : W.username, A = u || (x ? `linktr.ee/${x}` : void 0), z = ((J = n.user) == null ? void 0 : J.id) || "unknown";
747
747
  return (
748
748
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
749
749
  /* @__PURE__ */ e(
@@ -752,13 +752,13 @@ const Ke = (t) => ({
752
752
  ref: g,
753
753
  className: "mes-dialog group",
754
754
  onClose: s,
755
- onClick: (D) => {
756
- D.target === g.current && s();
755
+ onClick: (_) => {
756
+ _.target === g.current && s();
757
757
  },
758
758
  children: /* @__PURE__ */ i("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-none transition-shadow duration-200 group-open:shadow-max-elevation-light", children: [
759
759
  /* @__PURE__ */ i("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
760
760
  /* @__PURE__ */ e("h2", { className: "text-base font-semibold text-charcoal", children: "Chat info" }),
761
- /* @__PURE__ */ e(Ce, { onClick: s })
761
+ /* @__PURE__ */ e(ve, { onClick: s })
762
762
  ] }),
763
763
  /* @__PURE__ */ i("div", { className: "flex-1 px-2 overflow-y-auto w-full", children: [
764
764
  /* @__PURE__ */ e(
@@ -770,28 +770,28 @@ const Ke = (t) => ({
770
770
  /* @__PURE__ */ e(
771
771
  q,
772
772
  {
773
- id: A,
774
- name: _,
773
+ id: z,
774
+ name: F,
775
775
  image: d,
776
776
  size: 88,
777
777
  shape: "circle"
778
778
  }
779
779
  ),
780
780
  /* @__PURE__ */ i("div", { className: "flex flex-col min-w-0 flex-1", children: [
781
- /* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: _ }),
782
- j && /* @__PURE__ */ e("p", { className: "truncate text-sm text-[#00000055]", children: j }),
783
- o && /* @__PURE__ */ e(
781
+ /* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: F }),
782
+ A && /* @__PURE__ */ e("p", { className: "truncate text-sm text-[#00000055]", children: A }),
783
+ a && /* @__PURE__ */ e(
784
784
  "span",
785
785
  {
786
786
  className: "mt-1 rounded-full text-xs font-normal w-fit",
787
787
  style: {
788
788
  padding: "4px 8px",
789
- backgroundColor: o === "Subscribed to you" ? "#DCFCE7" : "#F5F5F4",
790
- color: o === "Subscribed to you" ? "#008236" : "#78716C",
789
+ backgroundColor: a === "Subscribed to you" ? "#DCFCE7" : "#F5F5F4",
790
+ color: a === "Subscribed to you" ? "#008236" : "#78716C",
791
791
  lineHeight: "133.333%",
792
792
  letterSpacing: "0.21px"
793
793
  },
794
- children: o
794
+ children: a
795
795
  }
796
796
  )
797
797
  ] })
@@ -800,42 +800,42 @@ const Ke = (t) => ({
800
800
  ),
801
801
  /* @__PURE__ */ i("ul", { className: "flex flex-col gap-2 mt-2", children: [
802
802
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ i(
803
- K,
803
+ ee,
804
804
  {
805
805
  onClick: N,
806
806
  disabled: f,
807
807
  "aria-busy": f,
808
808
  children: [
809
- f ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(He, { className: "h-5 w-5" }),
809
+ f ? /* @__PURE__ */ e(se, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(Ye, { className: "h-5 w-5" }),
810
810
  /* @__PURE__ */ e("span", { children: "Delete Conversation" })
811
811
  ]
812
812
  }
813
813
  ) }),
814
- /* @__PURE__ */ e("li", { children: E ? /* @__PURE__ */ i(
815
- K,
814
+ /* @__PURE__ */ e("li", { children: y ? /* @__PURE__ */ i(
815
+ ee,
816
816
  {
817
- onClick: S,
817
+ onClick: k,
818
818
  disabled: b,
819
819
  "aria-busy": b,
820
820
  children: [
821
- b ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(ce, { className: "h-5 w-5" }),
821
+ b ? /* @__PURE__ */ e(se, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(de, { className: "h-5 w-5" }),
822
822
  /* @__PURE__ */ e("span", { children: "Unblock" })
823
823
  ]
824
824
  }
825
825
  ) : /* @__PURE__ */ i(
826
- K,
826
+ ee,
827
827
  {
828
828
  onClick: I,
829
829
  disabled: b,
830
830
  "aria-busy": b,
831
831
  children: [
832
- b ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(ce, { className: "h-5 w-5" }),
832
+ b ? /* @__PURE__ */ e(se, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(de, { className: "h-5 w-5" }),
833
833
  /* @__PURE__ */ e("span", { children: "Block" })
834
834
  ]
835
835
  }
836
836
  ) }),
837
- /* @__PURE__ */ e("li", { children: /* @__PURE__ */ i(K, { variant: "danger", onClick: R, children: [
838
- /* @__PURE__ */ e($e, { className: "h-5 w-5" }),
837
+ /* @__PURE__ */ e("li", { children: /* @__PURE__ */ i(ee, { variant: "danger", onClick: R, children: [
838
+ /* @__PURE__ */ e(Je, { className: "h-5 w-5" }),
839
839
  /* @__PURE__ */ e("span", { children: "Report" })
840
840
  ] }) })
841
841
  ] })
@@ -844,29 +844,29 @@ const Ke = (t) => ({
844
844
  }
845
845
  )
846
846
  );
847
- }, is = ({
847
+ }, ms = ({
848
848
  onBack: t,
849
849
  showBackButton: s,
850
850
  renderMessageInputActions: n,
851
851
  onLeaveConversation: r,
852
- onBlockParticipant: o
852
+ onBlockParticipant: a
853
853
  }) => {
854
- const { channel: a } = fe(), [l, c] = v(!1), m = Z.useMemo(() => Object.values(a.state.members || {}).find(
854
+ const { channel: o } = ge(), [l, c] = v(!1), m = L.useMemo(() => Object.values(o.state.members || {}).find(
855
855
  (h) => {
856
856
  var f;
857
- return ((f = h.user) == null ? void 0 : f.id) && h.user.id !== a._client.userID;
857
+ return ((f = h.user) == null ? void 0 : f.id) && h.user.id !== o._client.userID;
858
858
  }
859
- ), [a._client.userID, a.state.members]), g = Z.useMemo(() => {
860
- const E = a.data ?? {};
861
- if (E.followerStatus)
862
- return String(E.followerStatus);
863
- if (E.isFollower !== void 0)
864
- return E.isFollower ? "Subscribed to you" : "Not subscribed";
865
- }, [a.data]);
866
- return /* @__PURE__ */ i(he, { children: [
867
- /* @__PURE__ */ i(Be, { children: [
859
+ ), [o._client.userID, o.state.members]), g = L.useMemo(() => {
860
+ const y = o.data ?? {};
861
+ if (y.followerStatus)
862
+ return String(y.followerStatus);
863
+ if (y.isFollower !== void 0)
864
+ return y.isFollower ? "Subscribed to you" : "Not subscribed";
865
+ }, [o.data]);
866
+ return /* @__PURE__ */ i(fe, { children: [
867
+ /* @__PURE__ */ i(We, { children: [
868
868
  /* @__PURE__ */ e("div", { className: "p-4", children: /* @__PURE__ */ e(
869
- os,
869
+ ds,
870
870
  {
871
871
  onBack: t,
872
872
  showBackButton: s,
@@ -875,7 +875,7 @@ const Ke = (t) => ({
875
875
  }
876
876
  ) }),
877
877
  /* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e(
878
- ze,
878
+ Ze,
879
879
  {
880
880
  hideDeletedMessages: !0,
881
881
  hideNewMessageSeparator: !1,
@@ -883,71 +883,74 @@ const Ke = (t) => ({
883
883
  }
884
884
  ) }),
885
885
  /* @__PURE__ */ e(
886
- ns,
886
+ os,
887
887
  {
888
- renderActions: () => n == null ? void 0 : n(a)
888
+ renderActions: () => n == null ? void 0 : n(o)
889
889
  }
890
890
  )
891
891
  ] }),
892
892
  /* @__PURE__ */ e(
893
- as,
893
+ us,
894
894
  {
895
895
  isOpen: l,
896
896
  onClose: () => c(!1),
897
897
  participant: m,
898
- channel: a,
898
+ channel: o,
899
899
  followerStatusLabel: g,
900
900
  onLeaveConversation: r,
901
- onBlockParticipant: o
901
+ onBlockParticipant: a
902
902
  }
903
903
  )
904
904
  ] });
905
- }, cs = ({
906
- channel: t,
907
- onBack: s,
908
- showBackButton: n = !1,
909
- renderMessageInputActions: r,
910
- onLeaveConversation: o,
911
- onBlockParticipant: a,
912
- className: l,
913
- CustomChannelEmptyState: c = ls
914
- }) => /* @__PURE__ */ e(
915
- "div",
916
- {
917
- className: p(
918
- "messaging-channel-view h-full flex flex-col",
919
- l
920
- ),
921
- children: /* @__PURE__ */ e(
922
- Ae,
923
- {
924
- channel: t,
925
- MessageSystem: rs,
926
- EmptyStateIndicator: c,
927
- children: /* @__PURE__ */ e(
928
- is,
929
- {
930
- onBack: s,
931
- showBackButton: n,
932
- renderMessageInputActions: r,
933
- onLeaveConversation: o,
934
- onBlockParticipant: a,
935
- CustomChannelEmptyState: c
936
- }
937
- )
938
- }
939
- )
940
- }
905
+ }, we = L.memo(
906
+ ({
907
+ channel: t,
908
+ onBack: s,
909
+ showBackButton: n = !1,
910
+ renderMessageInputActions: r,
911
+ onLeaveConversation: a,
912
+ onBlockParticipant: o,
913
+ className: l,
914
+ CustomChannelEmptyState: c = cs
915
+ }) => /* @__PURE__ */ e(
916
+ "div",
917
+ {
918
+ className: p(
919
+ "messaging-channel-view h-full flex flex-col",
920
+ l
921
+ ),
922
+ children: /* @__PURE__ */ e(
923
+ Ve,
924
+ {
925
+ channel: t,
926
+ MessageSystem: is,
927
+ EmptyStateIndicator: c,
928
+ children: /* @__PURE__ */ e(
929
+ ms,
930
+ {
931
+ onBack: s,
932
+ showBackButton: n,
933
+ renderMessageInputActions: r,
934
+ onLeaveConversation: a,
935
+ onBlockParticipant: o,
936
+ CustomChannelEmptyState: c
937
+ }
938
+ )
939
+ }
940
+ )
941
+ }
942
+ )
941
943
  );
942
- function ds({
944
+ we.displayName = "ChannelView";
945
+ function hs({
943
946
  searchQuery: t,
944
947
  setSearchQuery: s,
945
948
  placeholder: n
946
949
  }) {
947
- const r = z(null);
950
+ const r = $(null);
948
951
  return /* @__PURE__ */ i("div", { className: "relative", children: [
949
952
  /* @__PURE__ */ e(
950
- Ve,
953
+ Qe,
951
954
  {
952
955
  className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-stone",
953
956
  weight: "bold"
@@ -960,36 +963,36 @@ function ds({
960
963
  type: "text",
961
964
  placeholder: n,
962
965
  value: t,
963
- onChange: (o) => s(o.target.value),
966
+ onChange: (a) => s(a.target.value),
964
967
  className: "w-full pl-10 pr-10 py-3 text-sm border border-sand rounded-xl focus:outline-none focus:ring-2 focus:ring-black focus:border-transparent"
965
968
  }
966
969
  ),
967
970
  t && /* @__PURE__ */ e(
968
- xe,
971
+ be,
969
972
  {
970
973
  label: "Clear search",
971
974
  onClick: () => {
972
- var o;
973
- s(""), (o = r.current) == null || o.focus();
975
+ var a;
976
+ s(""), (a = r.current) == null || a.focus();
974
977
  },
975
978
  className: "absolute right-3 top-1/2 -translate-y-1/2 p-1 text-stone hover:text-charcoal",
976
- children: /* @__PURE__ */ e(le, { className: "h-4 w-4", weight: "bold" })
979
+ children: /* @__PURE__ */ e(ae, { className: "h-4 w-4", weight: "bold" })
977
980
  }
978
981
  )
979
982
  ] });
980
983
  }
981
- const us = ({
984
+ const fs = ({
982
985
  participantSource: t,
983
986
  onSelectParticipant: s,
984
987
  onClose: n,
985
988
  existingParticipantIds: r = /* @__PURE__ */ new Set(),
986
- participantLabel: o = "participants",
987
- searchPlaceholder: a = "Search participants...",
989
+ participantLabel: a = "participants",
990
+ searchPlaceholder: o = "Search participants...",
988
991
  className: l
989
992
  }) => {
990
- const { debug: c } = se(), [m, g] = v(""), [E, h] = v([]), [f, k] = v(!1), [b, w] = v(null), [y, N] = v(
993
+ const { debug: c } = ne(), [m, g] = v(""), [y, h] = v([]), [f, S] = v(!1), [b, w] = v(null), [E, N] = v(
991
994
  null
992
- ), I = z(!1);
995
+ ), I = $(!1);
993
996
  G(() => {
994
997
  if (t.loading) {
995
998
  c && console.log(
@@ -999,7 +1002,7 @@ const us = ({
999
1002
  }
1000
1003
  if (I.current) return;
1001
1004
  (async () => {
1002
- c && console.log("[ParticipantPicker] Loading initial participants..."), k(!0), w(null);
1005
+ c && console.log("[ParticipantPicker] Loading initial participants..."), S(!0), w(null);
1003
1006
  try {
1004
1007
  const u = await t.loadParticipants({
1005
1008
  search: "",
@@ -1014,18 +1017,18 @@ const us = ({
1014
1017
  const x = u instanceof Error ? u.message : "Failed to load participants";
1015
1018
  w(x), console.error("[ParticipantPicker] Failed to load participants:", u);
1016
1019
  } finally {
1017
- k(!1);
1020
+ S(!1);
1018
1021
  }
1019
1022
  })();
1020
1023
  }, [t.loading, c]);
1021
- const S = E.filter((d) => !r.has(d.id)).filter((d) => {
1024
+ const k = y.filter((d) => !r.has(d.id)).filter((d) => {
1022
1025
  var x;
1023
1026
  if (!m) return !0;
1024
1027
  const u = m.toLowerCase();
1025
1028
  return d.name.toLowerCase().includes(u) || ((x = d.email) == null ? void 0 : x.toLowerCase().includes(u)) || !1;
1026
- }), R = F(
1029
+ }), R = M(
1027
1030
  async (d) => {
1028
- if (!y) {
1031
+ if (!E) {
1029
1032
  N(d.id);
1030
1033
  try {
1031
1034
  await s(d);
@@ -1034,59 +1037,59 @@ const us = ({
1034
1037
  }
1035
1038
  }
1036
1039
  },
1037
- [s, y]
1038
- ), _ = (d, u) => {
1040
+ [s, E]
1041
+ ), F = (d, u) => {
1039
1042
  (d.key === "Enter" || d.key === " ") && (d.preventDefault(), R(u));
1040
1043
  };
1041
1044
  return /* @__PURE__ */ i("div", { className: p("flex flex-col h-full", l), children: [
1042
1045
  /* @__PURE__ */ i("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
1043
1046
  /* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-3", children: [
1044
1047
  /* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
1045
- /* @__PURE__ */ e(Ce, { onClick: n })
1048
+ /* @__PURE__ */ e(ve, { onClick: n })
1046
1049
  ] }),
1047
1050
  /* @__PURE__ */ i("p", { className: "text-xs text-stone mb-3", children: [
1048
1051
  "Select a ",
1049
- o.slice(0, -1),
1052
+ a.slice(0, -1),
1050
1053
  " to start messaging (",
1051
- S.length,
1054
+ k.length,
1052
1055
  " available)",
1053
- t.totalCount !== void 0 && ` • ${t.totalCount} ${o} total`
1056
+ t.totalCount !== void 0 && ` • ${t.totalCount} ${a} total`
1054
1057
  ] }),
1055
1058
  /* @__PURE__ */ e(
1056
- ds,
1059
+ hs,
1057
1060
  {
1058
1061
  searchQuery: m,
1059
1062
  setSearchQuery: g,
1060
- placeholder: a
1063
+ placeholder: o
1061
1064
  }
1062
1065
  )
1063
1066
  ] }),
1064
1067
  b && /* @__PURE__ */ i("div", { className: "p-4 text-sm text-danger bg-danger-alt", children: [
1065
1068
  "Error loading ",
1066
- o,
1069
+ a,
1067
1070
  ": ",
1068
1071
  b
1069
1072
  ] }),
1070
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: f && S.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */ i("div", { className: "flex items-center space-x-2", children: [
1073
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: f && k.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */ i("div", { className: "flex items-center space-x-2", children: [
1071
1074
  /* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
1072
1075
  /* @__PURE__ */ i("span", { className: "text-sm text-stone", children: [
1073
1076
  "Loading ",
1074
- o,
1077
+ a,
1075
1078
  "..."
1076
1079
  ] })
1077
- ] }) }) : S.length === 0 ? /* @__PURE__ */ i("div", { className: "p-6 text-center", children: [
1078
- /* @__PURE__ */ e("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-sand", children: /* @__PURE__ */ e(de, { className: "h-8 w-8 text-charcoal" }) }),
1079
- /* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: m ? `No ${o} found` : E.length > 0 ? `Already chatting with all ${o}` : `No ${o} yet` }),
1080
- /* @__PURE__ */ e("p", { className: "text-xs text-stone", children: m ? "Try a different search term" : E.length > 0 ? `You have existing conversations with all your ${o}` : `${o.charAt(0).toUpperCase() + o.slice(1)} will appear here` })
1080
+ ] }) }) : k.length === 0 ? /* @__PURE__ */ i("div", { className: "p-6 text-center", children: [
1081
+ /* @__PURE__ */ e("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-sand", children: /* @__PURE__ */ e(ue, { className: "h-8 w-8 text-charcoal" }) }),
1082
+ /* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: m ? `No ${a} found` : y.length > 0 ? `Already chatting with all ${a}` : `No ${a} yet` }),
1083
+ /* @__PURE__ */ e("p", { className: "text-xs text-stone", children: m ? "Try a different search term" : y.length > 0 ? `You have existing conversations with all your ${a}` : `${a.charAt(0).toUpperCase() + a.slice(1)} will appear here` })
1081
1084
  ] }) : /* @__PURE__ */ i("ul", { className: "space-y-0", children: [
1082
- S.map((d) => {
1085
+ k.map((d) => {
1083
1086
  const u = d.name || d.email || d.id, x = d.email && d.name ? d.email : d.phone;
1084
1087
  return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
1085
1088
  "button",
1086
1089
  {
1087
1090
  type: "button",
1088
1091
  onClick: () => R(d),
1089
- onKeyDown: (j) => _(j, d),
1092
+ onKeyDown: (A) => F(A, d),
1090
1093
  className: "w-full px-4 py-3 hover:bg-sand transition-colors border-b border-sand text-left focus:outline-none focus:ring-2 focus:ring-black",
1091
1094
  children: /* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
1092
1095
  /* @__PURE__ */ i("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
@@ -1104,7 +1107,7 @@ const us = ({
1104
1107
  x && /* @__PURE__ */ e("p", { className: "text-xs text-stone truncate", children: x })
1105
1108
  ] })
1106
1109
  ] }),
1107
- /* @__PURE__ */ e("div", { className: "flex-shrink-0", children: y === d.id ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 text-primary animate-spin" }) : /* @__PURE__ */ e(de, { className: "h-5 w-5 text-stone" }) })
1110
+ /* @__PURE__ */ e("div", { className: "flex-shrink-0", children: E === d.id ? /* @__PURE__ */ e(se, { className: "h-5 w-5 text-primary animate-spin" }) : /* @__PURE__ */ e(ue, { className: "h-5 w-5 text-stone" }) })
1108
1111
  ] })
1109
1112
  }
1110
1113
  ) }, d.id);
@@ -1115,7 +1118,7 @@ const us = ({
1115
1118
  ] }) })
1116
1119
  ] }) })
1117
1120
  ] });
1118
- }, ms = ({ className: t }) => /* @__PURE__ */ i(
1121
+ }, gs = ({ className: t }) => /* @__PURE__ */ i(
1119
1122
  "svg",
1120
1123
  {
1121
1124
  width: "140",
@@ -1249,13 +1252,17 @@ const us = ({
1249
1252
  ] })
1250
1253
  ]
1251
1254
  }
1252
- ), hs = ({ hasChannels: t }) => /* @__PURE__ */ e("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ i("div", { className: "flex flex-col items-center max-w-sm text-center", children: [
1253
- /* @__PURE__ */ e(ms, {}),
1254
- !t && /* @__PURE__ */ i("div", { className: "mt-8", children: [
1255
- /* @__PURE__ */ e("h2", { className: "font-medium text-black text-[18px] mb-2", children: "Your inbox is empty" }),
1256
- /* @__PURE__ */ e("p", { className: "text-[#676B5F] text-sm mb-6", children: "Share with your followers to start receiving messages" })
1257
- ] })
1258
- ] }) }), re = ({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ i("div", { className: "text-center max-w-sm", children: [
1255
+ ), ye = L.memo(
1256
+ ({ hasChannels: t }) => /* @__PURE__ */ e("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ i("div", { className: "flex flex-col items-center max-w-sm text-center", children: [
1257
+ /* @__PURE__ */ e(gs, {}),
1258
+ !t && /* @__PURE__ */ i("div", { className: "mt-8", children: [
1259
+ /* @__PURE__ */ e("h2", { className: "font-medium text-black text-[18px] mb-2", children: "Your inbox is empty" }),
1260
+ /* @__PURE__ */ e("p", { className: "text-[#676B5F] text-sm mb-6", children: "Share with your followers to start receiving messages" })
1261
+ ] })
1262
+ ] }) })
1263
+ );
1264
+ ye.displayName = "EmptyState";
1265
+ const te = L.memo(({ message: t, onBack: s }) => /* @__PURE__ */ e("div", { className: "messaging-error-state flex items-center justify-center h-full p-8", children: /* @__PURE__ */ i("div", { className: "text-center max-w-sm", children: [
1259
1266
  /* @__PURE__ */ e("div", { className: "w-24 h-24 bg-danger-alt/20 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ e("span", { className: "text-4xl", children: "⚠️" }) }),
1260
1267
  /* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal mb-2", children: "Oops!" }),
1261
1268
  /* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t }),
@@ -1268,7 +1275,9 @@ const us = ({
1268
1275
  children: "Go Back"
1269
1276
  }
1270
1277
  )
1271
- ] }) }), fs = ({ className: t, message: s }) => /* @__PURE__ */ i(
1278
+ ] }) }));
1279
+ te.displayName = "ErrorState";
1280
+ const xs = ({ className: t, message: s }) => /* @__PURE__ */ i(
1272
1281
  "div",
1273
1282
  {
1274
1283
  className: p("flex items-center justify-center h-full", t),
@@ -1311,31 +1320,33 @@ const us = ({
1311
1320
  s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
1312
1321
  ]
1313
1322
  }
1314
- ), gs = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ i("div", { className: "flex items-center", children: [
1315
- /* @__PURE__ */ e(fs, { className: "w-6 h-6" }),
1323
+ ), Ee = L.memo(() => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ i("div", { className: "flex items-center", children: [
1324
+ /* @__PURE__ */ e(xs, { className: "w-6 h-6" }),
1316
1325
  /* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
1317
- ] }) }), Ss = ({
1326
+ ] }) }));
1327
+ Ee.displayName = "LoadingState";
1328
+ const Ss = ({
1318
1329
  capabilities: t = {},
1319
1330
  className: s,
1320
1331
  renderMessageInputActions: n,
1321
1332
  onChannelSelect: r,
1322
- onParticipantSelect: o,
1323
- initialParticipantFilter: a,
1333
+ onParticipantSelect: a,
1334
+ initialParticipantFilter: o,
1324
1335
  initialParticipantData: l,
1325
1336
  CustomChannelEmptyState: c,
1326
1337
  showChannelList: m = !0,
1327
1338
  filters: g,
1328
- channelListCustomEmptyStateIndicator: E
1339
+ channelListCustomEmptyStateIndicator: y
1329
1340
  }) => {
1330
1341
  const {
1331
1342
  service: h,
1332
1343
  client: f,
1333
- isConnected: k,
1344
+ isConnected: S,
1334
1345
  isLoading: b,
1335
1346
  error: w,
1336
- refreshConnection: y,
1347
+ refreshConnection: E,
1337
1348
  debug: N
1338
- } = We(), [I, S] = v(null), [R, _] = v(!1), [d, u] = v(!1), [x, j] = v(/* @__PURE__ */ new Set()), [A, W] = v(0), [O, $] = v(!1), [Y, H] = v(null), V = z(null), { participantSource: J, participantLabel: D = "participants" } = t, T = Z.useMemo(() => {
1349
+ } = Xe(), [I, k] = v(null), [R, F] = v(!1), [d, u] = v(!1), [x, A] = v(/* @__PURE__ */ new Set()), [z, Z] = v(0), [B, V] = v(!1), [Y, H] = v(null), W = $(null), { participantSource: J, participantLabel: _ = "participants" } = t, P = L.useMemo(() => {
1339
1350
  const C = f == null ? void 0 : f.userID;
1340
1351
  return {
1341
1352
  ...{
@@ -1348,61 +1359,61 @@ const us = ({
1348
1359
  },
1349
1360
  ...g
1350
1361
  };
1351
- }, [g, f == null ? void 0 : f.userID]), P = z(null), L = F(async () => {
1352
- if (!f || !k) return;
1362
+ }, [g, f == null ? void 0 : f.userID]), U = $(null), O = M(async () => {
1363
+ if (!f || !S) return;
1353
1364
  const C = f.userID;
1354
1365
  if (C)
1355
1366
  try {
1356
1367
  N && console.log("[MessagingShell] Syncing channels for user:", C);
1357
- const U = await f.queryChannels(
1368
+ const j = await f.queryChannels(
1358
1369
  {
1359
1370
  type: "messaging",
1360
1371
  members: { $in: [C] }
1361
1372
  },
1362
1373
  {},
1363
1374
  { limit: 100 }
1364
- ), M = /* @__PURE__ */ new Set();
1365
- U.forEach((B) => {
1366
- const Ee = B.state.members;
1367
- Object.values(Ee).forEach((ye) => {
1375
+ ), D = /* @__PURE__ */ new Set();
1376
+ j.forEach((T) => {
1377
+ const re = T.state.members;
1378
+ Object.values(re).forEach((_e) => {
1368
1379
  var oe;
1369
- const ne = (oe = ye.user) == null ? void 0 : oe.id;
1370
- ne && ne !== C && M.add(ne);
1380
+ const le = (oe = _e.user) == null ? void 0 : oe.id;
1381
+ le && le !== C && D.add(le);
1371
1382
  });
1372
- }), j(M), _(U.length > 0), P.current = C, N && console.log("[MessagingShell] Channels synced successfully:", {
1373
- channelCount: U.length,
1374
- memberCount: M.size
1383
+ }), A((T) => T.size === D.size && [...T].every((re) => D.has(re)) ? T : D), F(j.length > 0), U.current = C, N && console.log("[MessagingShell] Channels synced successfully:", {
1384
+ channelCount: j.length,
1385
+ memberCount: D.size
1375
1386
  });
1376
- } catch (U) {
1377
- console.error("[MessagingShell] Failed to sync channels:", U);
1387
+ } catch (j) {
1388
+ console.error("[MessagingShell] Failed to sync channels:", j);
1378
1389
  }
1379
- }, [f, k, N]);
1390
+ }, [f, S, N]);
1380
1391
  G(() => {
1381
- if (!f || !k) return;
1392
+ if (!f || !S) return;
1382
1393
  const C = f.userID;
1383
- C && P.current !== C && L();
1384
- }, [f, k, L]), G(() => {
1385
- if (!a || !f || !k) return;
1394
+ C && U.current !== C && O();
1395
+ }, [f, S, O]), G(() => {
1396
+ if (!o || !f || !S) return;
1386
1397
  (async () => {
1387
- const U = f.userID;
1388
- if (U)
1398
+ const j = f.userID;
1399
+ if (j)
1389
1400
  try {
1390
1401
  N && console.log(
1391
1402
  "[MessagingShell] Loading initial conversation with:",
1392
- a
1403
+ o
1393
1404
  );
1394
- const M = await f.queryChannels(
1405
+ const D = await f.queryChannels(
1395
1406
  {
1396
1407
  type: "messaging",
1397
- members: { $eq: [U, a] }
1408
+ members: { $eq: [j, o] }
1398
1409
  },
1399
1410
  {},
1400
1411
  { limit: 1 }
1401
1412
  );
1402
- if (M.length > 0)
1403
- S(M[0]), $(!0), H(null), r && r(M[0]), N && console.log(
1413
+ if (D.length > 0)
1414
+ k(D[0]), V(!0), H(null), r && r(D[0]), N && console.log(
1404
1415
  "[MessagingShell] Initial conversation loaded:",
1405
- M[0].id
1416
+ D[0].id
1406
1417
  );
1407
1418
  else if (l && h) {
1408
1419
  N && console.log(
@@ -1410,20 +1421,20 @@ const us = ({
1410
1421
  l
1411
1422
  );
1412
1423
  try {
1413
- const B = await h.startChannelWithParticipant({
1424
+ const T = await h.startChannelWithParticipant({
1414
1425
  id: l.id,
1415
1426
  name: l.name,
1416
1427
  email: l.email,
1417
1428
  phone: l.phone
1418
1429
  });
1419
- S(B), $(!0), H(null), r && r(B), N && console.log(
1430
+ k(T), V(!0), H(null), r && r(T), N && console.log(
1420
1431
  "[MessagingShell] Channel created and loaded:",
1421
- B.id
1432
+ T.id
1422
1433
  );
1423
- } catch (B) {
1434
+ } catch (T) {
1424
1435
  console.error(
1425
1436
  "[MessagingShell] Failed to create conversation:",
1426
- B
1437
+ T
1427
1438
  ), H("Failed to create conversation");
1428
1439
  }
1429
1440
  } else
@@ -1431,78 +1442,83 @@ const us = ({
1431
1442
  "No conversation found with this account"
1432
1443
  ), N && console.log(
1433
1444
  "[MessagingShell] No conversation found for:",
1434
- a
1445
+ o
1435
1446
  );
1436
- } catch (M) {
1447
+ } catch (D) {
1437
1448
  console.error(
1438
1449
  "[MessagingShell] Failed to load initial conversation:",
1439
- M
1450
+ D
1440
1451
  ), H("Failed to load conversation");
1441
1452
  }
1442
1453
  })();
1443
1454
  }, [
1444
- a,
1455
+ o,
1445
1456
  l,
1446
1457
  f,
1447
- k,
1458
+ S,
1448
1459
  h,
1449
1460
  N,
1450
1461
  r
1451
1462
  ]);
1452
- const Q = F(
1463
+ const Q = M(
1453
1464
  (C) => {
1454
- S(C), r == null || r(C);
1465
+ k(C), r == null || r(C);
1455
1466
  },
1456
1467
  [r]
1457
- ), Ne = F(() => {
1458
- O || S(null);
1459
- }, [O]), be = F(
1468
+ ), Ie = M(() => {
1469
+ B || k(null);
1470
+ }, [B]), ke = M(
1460
1471
  async (C) => {
1461
- var U;
1472
+ var j;
1462
1473
  if (h)
1463
1474
  try {
1464
1475
  N && console.log(
1465
1476
  "[MessagingShell] Starting conversation with:",
1466
1477
  C.id
1467
1478
  );
1468
- const M = await h.startChannelWithParticipant({
1479
+ const D = await h.startChannelWithParticipant({
1469
1480
  id: C.id,
1470
1481
  name: C.name,
1471
1482
  email: C.email,
1472
1483
  phone: C.phone
1473
1484
  });
1474
1485
  try {
1475
- await M.show();
1476
- } catch (B) {
1477
- console.warn("[MessagingShell] Failed to unhide channel:", B);
1486
+ await D.show();
1487
+ } catch (T) {
1488
+ console.warn("[MessagingShell] Failed to unhide channel:", T);
1478
1489
  }
1479
- S(M), u(!1), (U = V.current) == null || U.close(), o == null || o(C);
1480
- } catch (M) {
1481
- console.error("[MessagingShell] Failed to start conversation:", M);
1490
+ k(D), u(!1), (j = W.current) == null || j.close(), a == null || a(C);
1491
+ } catch (D) {
1492
+ console.error("[MessagingShell] Failed to start conversation:", D);
1482
1493
  }
1483
1494
  },
1484
- [h, o, N]
1485
- ), te = F(() => {
1495
+ [h, a, N]
1496
+ ), X = M(() => {
1486
1497
  var C;
1487
- u(!1), (C = V.current) == null || C.close();
1488
- }, []), ve = F(
1498
+ u(!1), (C = W.current) == null || C.close();
1499
+ }, []), Se = M(
1500
+ (C) => {
1501
+ C.target === W.current && X();
1502
+ },
1503
+ [X]
1504
+ ), pe = M(
1489
1505
  async (C) => {
1490
- N && console.log("[MessagingShell] Leaving conversation:", C.id), S(null), $(!1), P.current = null, await L();
1506
+ N && console.log("[MessagingShell] Leaving conversation:", C.id), k(null), V(!1), U.current = null, await O();
1491
1507
  },
1492
- [L, N]
1493
- ), we = F(
1508
+ [O, N]
1509
+ ), Re = M(
1494
1510
  async (C) => {
1495
- N && console.log("[MessagingShell] Blocking participant:", C), S(null), $(!1), P.current = null, await L();
1511
+ N && console.log("[MessagingShell] Blocking participant:", C), k(null), V(!1), U.current = null, await O();
1496
1512
  },
1497
- [L, N]
1498
- ), X = !!I;
1499
- return b ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(gs, {}) }) : w ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(re, { message: w, onBack: y }) }) : !k || !f ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(
1500
- re,
1513
+ [O, N]
1514
+ ), K = !!I;
1515
+ return b ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(Ee, {}) }) : w ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(te, { message: w, onBack: E }) }) : !S || !f ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(
1516
+ te,
1501
1517
  {
1502
1518
  message: "Not connected to messaging service",
1503
- onBack: y
1519
+ onBack: E
1504
1520
  }
1505
- ) }) : Y ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(re, { message: Y }) }) : /* @__PURE__ */ i(
1521
+ ) }) : Y ? /* @__PURE__ */ e("div", { className: p("h-full", s), children: /* @__PURE__ */ e(te, { message: Y }) }) : /* @__PURE__ */ i(
1506
1522
  "div",
1507
1523
  {
1508
1524
  className: p(
@@ -1518,20 +1534,20 @@ const us = ({
1518
1534
  "messaging-channel-list-sidebar min-h-0 min-w-0 lg:flex lg:flex-col",
1519
1535
  {
1520
1536
  // Explicitly hidden via prop or in direct conversation mode
1521
- "!hidden": m === !1 || O,
1537
+ "!hidden": m === !1 || B,
1522
1538
  // Normal mode: hide on mobile when channel selected, show on desktop
1523
- "hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": m !== !1 && !O && X,
1539
+ "hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": m !== !1 && !B && K,
1524
1540
  // Normal mode: show when no channel selected
1525
- "flex flex-col w-full lg:flex-1 lg:max-w-2xl": m !== !1 && !O && !X
1541
+ "flex flex-col w-full lg:flex-1 lg:max-w-2xl": m !== !1 && !B && !K
1526
1542
  }
1527
1543
  ),
1528
1544
  children: /* @__PURE__ */ e(
1529
- Xe,
1545
+ Ne,
1530
1546
  {
1531
1547
  onChannelSelect: Q,
1532
1548
  selectedChannel: I || void 0,
1533
- filters: T,
1534
- customEmptyStateIndicator: E
1549
+ filters: P,
1550
+ customEmptyStateIndicator: y
1535
1551
  }
1536
1552
  )
1537
1553
  }
@@ -1543,24 +1559,24 @@ const us = ({
1543
1559
  "messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",
1544
1560
  {
1545
1561
  // In direct conversation mode, always show (full width)
1546
- flex: O || X,
1562
+ flex: B || K,
1547
1563
  // Normal mode: hide on mobile when no channel selected
1548
- "hidden lg:flex": !O && !X
1564
+ "hidden lg:flex": !B && !K
1549
1565
  }
1550
1566
  ),
1551
1567
  children: I ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
1552
- cs,
1568
+ we,
1553
1569
  {
1554
1570
  channel: I,
1555
- onBack: Ne,
1556
- showBackButton: !O,
1571
+ onBack: Ie,
1572
+ showBackButton: !B,
1557
1573
  renderMessageInputActions: n,
1558
- onLeaveConversation: ve,
1559
- onBlockParticipant: we,
1574
+ onLeaveConversation: pe,
1575
+ onBlockParticipant: Re,
1560
1576
  CustomChannelEmptyState: c
1561
1577
  },
1562
1578
  I.id
1563
- ) }) : /* @__PURE__ */ e(hs, { hasChannels: R })
1579
+ ) }) : /* @__PURE__ */ e(ye, { hasChannels: R })
1564
1580
  }
1565
1581
  )
1566
1582
  ] }),
@@ -1568,30 +1584,28 @@ const us = ({
1568
1584
  /* @__PURE__ */ e(
1569
1585
  "dialog",
1570
1586
  {
1571
- ref: V,
1587
+ ref: W,
1572
1588
  className: "mes-dialog",
1573
- onClick: (C) => {
1574
- C.target === V.current && te();
1575
- },
1576
- onClose: te,
1589
+ onClick: Se,
1590
+ onClose: X,
1577
1591
  children: /* @__PURE__ */ e("div", { className: "h-full w-full bg-white shadow-max-elevation-light", children: /* @__PURE__ */ e(
1578
- us,
1592
+ fs,
1579
1593
  {
1580
1594
  participantSource: J,
1581
- onSelectParticipant: be,
1582
- onClose: te,
1595
+ onSelectParticipant: ke,
1596
+ onClose: X,
1583
1597
  existingParticipantIds: x,
1584
- participantLabel: D,
1585
- searchPlaceholder: `Search ${D}...`
1598
+ participantLabel: _,
1599
+ searchPlaceholder: `Search ${_}...`
1586
1600
  },
1587
- A
1601
+ z
1588
1602
  ) })
1589
1603
  }
1590
1604
  )
1591
1605
  ]
1592
1606
  }
1593
1607
  );
1594
- }, xs = ({
1608
+ }, Cs = ({
1595
1609
  question: t,
1596
1610
  onClick: s,
1597
1611
  loading: n = !1,
@@ -1613,23 +1627,23 @@ const us = ({
1613
1627
  ),
1614
1628
  children: t
1615
1629
  }
1616
- ), ks = ({
1630
+ ), ps = ({
1617
1631
  faqs: t,
1618
1632
  onFaqClick: s,
1619
1633
  loadingFaqId: n,
1620
1634
  headerText: r,
1621
- className: o,
1622
- avatarImage: a,
1635
+ className: a,
1636
+ avatarImage: o,
1623
1637
  avatarName: l
1624
1638
  }) => {
1625
1639
  const c = t.filter((m) => m.enabled).sort((m, g) => (m.order ?? 0) - (g.order ?? 0));
1626
- return c.length === 0 ? null : /* @__PURE__ */ e("div", { className: o, children: /* @__PURE__ */ i("div", { className: "flex gap-3 items-end", children: [
1627
- (a || l) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
1640
+ return c.length === 0 ? null : /* @__PURE__ */ e("div", { className: a, children: /* @__PURE__ */ i("div", { className: "flex gap-3 items-end", children: [
1641
+ (o || l) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
1628
1642
  q,
1629
1643
  {
1630
1644
  id: l || "account",
1631
1645
  name: l || "Account",
1632
- image: a,
1646
+ image: o,
1633
1647
  size: 24,
1634
1648
  shape: "circle"
1635
1649
  }
@@ -1642,7 +1656,7 @@ const us = ({
1642
1656
  children: [
1643
1657
  r && /* @__PURE__ */ e("p", { className: "text-md text-charcoal mb-4", children: r }),
1644
1658
  c.map((m) => /* @__PURE__ */ e(
1645
- xs,
1659
+ Cs,
1646
1660
  {
1647
1661
  question: m.question,
1648
1662
  onClick: () => s(m.id),
@@ -1654,10 +1668,10 @@ const us = ({
1654
1668
  }
1655
1669
  )
1656
1670
  ] }) });
1657
- }, ps = (t, s = {}) => {
1658
- const { initialSearch: n = "", pageSize: r = 20 } = s, [o, a] = v([]), [l, c] = v(!1), [m, g] = v(null), [E, h] = v(n), [f, k] = v(!0), [b, w] = v(), y = F(async (R = !1, _) => {
1671
+ }, Rs = (t, s = {}) => {
1672
+ const { initialSearch: n = "", pageSize: r = 20 } = s, [a, o] = v([]), [l, c] = v(!1), [m, g] = v(null), [y, h] = v(n), [f, S] = v(!0), [b, w] = v(), E = M(async (R = !1, F) => {
1659
1673
  if (l) return;
1660
- const d = _ !== void 0 ? _ : E;
1674
+ const d = F !== void 0 ? F : y;
1661
1675
  c(!0), g(null);
1662
1676
  try {
1663
1677
  const u = await t.loadParticipants({
@@ -1665,48 +1679,48 @@ const us = ({
1665
1679
  limit: r,
1666
1680
  cursor: R ? void 0 : b
1667
1681
  });
1668
- a(
1682
+ o(
1669
1683
  (x) => R ? u.participants : [...x, ...u.participants]
1670
- ), k(u.hasMore), w(u.nextCursor);
1684
+ ), S(u.hasMore), w(u.nextCursor);
1671
1685
  } catch (u) {
1672
1686
  const x = u instanceof Error ? u.message : "Failed to load participants";
1673
1687
  g(x), console.error("[useParticipants] Load error:", u);
1674
1688
  } finally {
1675
1689
  c(!1);
1676
1690
  }
1677
- }, [t, E, b, r, l]), N = F(() => {
1678
- f && !l && y(!1);
1679
- }, [f, l, y]), I = F((R) => {
1680
- h(R), w(void 0), y(!0, R);
1681
- }, [y]), S = F(() => {
1682
- w(void 0), y(!0);
1683
- }, [y]);
1691
+ }, [t, y, b, r, l]), N = M(() => {
1692
+ f && !l && E(!1);
1693
+ }, [f, l, E]), I = M((R) => {
1694
+ h(R), w(void 0), E(!0, R);
1695
+ }, [E]), k = M(() => {
1696
+ w(void 0), E(!0);
1697
+ }, [E]);
1684
1698
  return G(() => {
1685
- y(!0);
1699
+ E(!0);
1686
1700
  }, [t.loadParticipants]), {
1687
- participants: o,
1701
+ participants: a,
1688
1702
  loading: l,
1689
1703
  error: m,
1690
- searchQuery: E,
1704
+ searchQuery: y,
1691
1705
  hasMore: f,
1692
1706
  totalCount: t.totalCount,
1693
1707
  loadMore: N,
1694
1708
  search: I,
1695
- refresh: S
1709
+ refresh: k
1696
1710
  };
1697
1711
  };
1698
1712
  export {
1699
1713
  q as Avatar,
1700
- ls as ChannelEmptyState,
1701
- Xe as ChannelList,
1702
- cs as ChannelView,
1703
- ks as FaqList,
1704
- xs as FaqListItem,
1705
- Is as MessagingProvider,
1714
+ cs as ChannelEmptyState,
1715
+ Ne as ChannelList,
1716
+ we as ChannelView,
1717
+ ps as FaqList,
1718
+ Cs as FaqListItem,
1719
+ ks as MessagingProvider,
1706
1720
  Ss as MessagingShell,
1707
- us as ParticipantPicker,
1708
- qe as formatRelativeTime,
1709
- We as useMessaging,
1710
- ps as useParticipants
1721
+ fs as ParticipantPicker,
1722
+ es as formatRelativeTime,
1723
+ Xe as useMessaging,
1724
+ Rs as useParticipants
1711
1725
  };
1712
1726
  //# sourceMappingURL=index.js.map