@scalemule/chat 0.0.7 → 0.0.8

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 (75) hide show
  1. package/dist/react.cjs +159 -111
  2. package/dist/react.js +83 -35
  3. package/package.json +1 -1
  4. package/dist/ChatClient-DQPHdUHX.d.cts +0 -107
  5. package/dist/ChatClient-DtUKF-4c.d.ts +0 -107
  6. package/dist/constants.d.ts +0 -9
  7. package/dist/constants.d.ts.map +0 -1
  8. package/dist/core/ChatClient.d.ts +0 -96
  9. package/dist/core/ChatClient.d.ts.map +0 -1
  10. package/dist/core/EventEmitter.d.ts +0 -11
  11. package/dist/core/EventEmitter.d.ts.map +0 -1
  12. package/dist/core/MessageCache.d.ts +0 -18
  13. package/dist/core/MessageCache.d.ts.map +0 -1
  14. package/dist/core/OfflineQueue.d.ts +0 -19
  15. package/dist/core/OfflineQueue.d.ts.map +0 -1
  16. package/dist/element.d.cts +0 -2
  17. package/dist/element.d.ts +0 -2
  18. package/dist/element.d.ts.map +0 -1
  19. package/dist/embed/index.d.ts +0 -2
  20. package/dist/embed/index.d.ts.map +0 -1
  21. package/dist/factory.d.ts +0 -8
  22. package/dist/factory.d.ts.map +0 -1
  23. package/dist/iframe.d.cts +0 -17
  24. package/dist/iframe.d.ts +0 -15
  25. package/dist/iframe.d.ts.map +0 -1
  26. package/dist/index.d.cts +0 -166
  27. package/dist/index.d.ts +0 -8
  28. package/dist/index.d.ts.map +0 -1
  29. package/dist/react-components/ChatInput.d.ts +0 -16
  30. package/dist/react-components/ChatInput.d.ts.map +0 -1
  31. package/dist/react-components/ChatMessageItem.d.ts +0 -13
  32. package/dist/react-components/ChatMessageItem.d.ts.map +0 -1
  33. package/dist/react-components/ChatMessageList.d.ts +0 -15
  34. package/dist/react-components/ChatMessageList.d.ts.map +0 -1
  35. package/dist/react-components/ChatThread.d.ts +0 -12
  36. package/dist/react-components/ChatThread.d.ts.map +0 -1
  37. package/dist/react-components/ConversationList.d.ts +0 -13
  38. package/dist/react-components/ConversationList.d.ts.map +0 -1
  39. package/dist/react-components/EmojiPicker.d.ts +0 -8
  40. package/dist/react-components/EmojiPicker.d.ts.map +0 -1
  41. package/dist/react-components/index.d.ts +0 -8
  42. package/dist/react-components/index.d.ts.map +0 -1
  43. package/dist/react-components/theme.d.ts +0 -19
  44. package/dist/react-components/theme.d.ts.map +0 -1
  45. package/dist/react-components/utils.d.ts +0 -4
  46. package/dist/react-components/utils.d.ts.map +0 -1
  47. package/dist/react.d.cts +0 -145
  48. package/dist/react.d.ts +0 -72
  49. package/dist/react.d.ts.map +0 -1
  50. package/dist/shared/ChatController.d.ts +0 -65
  51. package/dist/shared/ChatController.d.ts.map +0 -1
  52. package/dist/shared/upload.d.ts +0 -3
  53. package/dist/shared/upload.d.ts.map +0 -1
  54. package/dist/support.d.ts +0 -99
  55. package/dist/support.d.ts.map +0 -1
  56. package/dist/transport/HttpTransport.d.ts +0 -20
  57. package/dist/transport/HttpTransport.d.ts.map +0 -1
  58. package/dist/transport/WebSocketTransport.d.ts +0 -78
  59. package/dist/transport/WebSocketTransport.d.ts.map +0 -1
  60. package/dist/types-COPVrm3K.d.cts +0 -256
  61. package/dist/types-COPVrm3K.d.ts +0 -256
  62. package/dist/types.d.ts +0 -271
  63. package/dist/types.d.ts.map +0 -1
  64. package/dist/umd.d.ts +0 -6
  65. package/dist/umd.d.ts.map +0 -1
  66. package/dist/version.d.ts +0 -2
  67. package/dist/version.d.ts.map +0 -1
  68. package/dist/widget/icons.d.ts +0 -8
  69. package/dist/widget/icons.d.ts.map +0 -1
  70. package/dist/widget/index.d.ts +0 -2
  71. package/dist/widget/index.d.ts.map +0 -1
  72. package/dist/widget/storage.d.ts +0 -5
  73. package/dist/widget/storage.d.ts.map +0 -1
  74. package/dist/widget/styles.d.ts +0 -3
  75. package/dist/widget/styles.d.ts.map +0 -1
package/dist/react.cjs CHANGED
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkW2PWFS3E_cjs = require('./chunk-W2PWFS3E.cjs');
4
- var React3 = require('react');
4
+ var React4 = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactDom = require('react-dom');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
9
 
9
- var React3__default = /*#__PURE__*/_interopDefault(React3);
10
+ var React4__default = /*#__PURE__*/_interopDefault(React4);
10
11
 
11
12
  function ChatInput({
12
13
  onSend,
@@ -14,13 +15,13 @@ function ChatInput({
14
15
  onUploadAttachment,
15
16
  placeholder = "Type a message..."
16
17
  }) {
17
- const [content, setContent] = React3.useState("");
18
- const [attachments, setAttachments] = React3.useState([]);
19
- const [isSending, setIsSending] = React3.useState(false);
20
- const [isDragging, setIsDragging] = React3.useState(false);
21
- const fileInputRef = React3.useRef(null);
22
- const typingTimeoutRef = React3.useRef(null);
23
- const readyAttachments = React3.useMemo(
18
+ const [content, setContent] = React4.useState("");
19
+ const [attachments, setAttachments] = React4.useState([]);
20
+ const [isSending, setIsSending] = React4.useState(false);
21
+ const [isDragging, setIsDragging] = React4.useState(false);
22
+ const fileInputRef = React4.useRef(null);
23
+ const typingTimeoutRef = React4.useRef(null);
24
+ const readyAttachments = React4.useMemo(
24
25
  () => attachments.filter((attachment) => attachment.attachment).map((attachment) => attachment.attachment),
25
26
  [attachments]
26
27
  );
@@ -235,43 +236,90 @@ function ChatInput({
235
236
  }
236
237
  );
237
238
  }
238
- var DEFAULT_EMOJIS = ["\u{1F44D}", "\u2764\uFE0F", "\u{1F602}", "\u{1F389}", "\u{1F62E}", "\u{1F440}"];
239
+ var QUICK_REACTIONS = ["\u2764\uFE0F", "\u{1F602}", "\u{1F44D}", "\u{1F525}", "\u{1F62E}", "\u{1F622}", "\u{1F44F}", "\u{1F64C}"];
239
240
  function EmojiPicker({
240
241
  onSelect,
241
- emojis = DEFAULT_EMOJIS
242
+ onClose,
243
+ anchorRef,
244
+ emojis = QUICK_REACTIONS
242
245
  }) {
243
- return /* @__PURE__ */ jsxRuntime.jsx(
244
- "div",
245
- {
246
- style: {
247
- display: "inline-flex",
248
- gap: 6,
249
- padding: 6,
250
- borderRadius: 999,
251
- background: "var(--sm-surface, #fff)",
252
- border: "1px solid var(--sm-border-color, #e5e7eb)",
253
- boxShadow: "0 10px 25px rgba(15, 23, 42, 0.12)"
254
- },
255
- children: emojis.map((emoji) => /* @__PURE__ */ jsxRuntime.jsx(
256
- "button",
257
- {
258
- type: "button",
259
- onClick: () => onSelect(emoji),
260
- "aria-label": `React with ${emoji}`,
261
- style: {
262
- width: 32,
263
- height: 32,
264
- border: "none",
265
- background: "transparent",
266
- borderRadius: 999,
267
- cursor: "pointer",
268
- fontSize: 18
269
- },
270
- children: emoji
271
- },
272
- emoji
273
- ))
246
+ const ref = React4.useRef(null);
247
+ const [position, setPosition] = React4.useState(null);
248
+ React4.useEffect(() => {
249
+ const anchor = anchorRef.current;
250
+ if (!anchor) return;
251
+ const rect = anchor.getBoundingClientRect();
252
+ const pickerWidth = emojis.length * 36 + 16;
253
+ let left = rect.left + rect.width / 2 - pickerWidth / 2;
254
+ if (left < 8) left = 8;
255
+ if (left + pickerWidth > window.innerWidth - 8)
256
+ left = window.innerWidth - 8 - pickerWidth;
257
+ setPosition({ top: rect.top - 8, left });
258
+ }, [anchorRef, emojis.length]);
259
+ React4.useEffect(() => {
260
+ function handleClickOutside(e) {
261
+ if (ref.current && !ref.current.contains(e.target) && anchorRef.current && !anchorRef.current.contains(e.target)) {
262
+ onClose();
263
+ }
274
264
  }
265
+ document.addEventListener("mousedown", handleClickOutside);
266
+ return () => document.removeEventListener("mousedown", handleClickOutside);
267
+ }, [onClose, anchorRef]);
268
+ if (!position) return null;
269
+ return reactDom.createPortal(
270
+ /* @__PURE__ */ jsxRuntime.jsx(
271
+ "div",
272
+ {
273
+ ref,
274
+ style: {
275
+ position: "fixed",
276
+ top: position.top,
277
+ left: position.left,
278
+ transform: "translateY(-100%)",
279
+ background: "var(--sm-surface, #fff)",
280
+ border: "1px solid var(--sm-border-color, #e5e7eb)",
281
+ borderRadius: 12,
282
+ boxShadow: "0 10px 25px rgba(15, 23, 42, 0.12)",
283
+ padding: 8,
284
+ display: "flex",
285
+ gap: 4,
286
+ zIndex: 9999
287
+ },
288
+ children: emojis.map((emoji) => /* @__PURE__ */ jsxRuntime.jsx(
289
+ "button",
290
+ {
291
+ onClick: () => {
292
+ onSelect(emoji);
293
+ onClose();
294
+ },
295
+ type: "button",
296
+ "aria-label": `React with ${emoji}`,
297
+ style: {
298
+ width: 32,
299
+ height: 32,
300
+ display: "flex",
301
+ alignItems: "center",
302
+ justifyContent: "center",
303
+ borderRadius: 8,
304
+ border: "none",
305
+ background: "transparent",
306
+ cursor: "pointer",
307
+ fontSize: 18,
308
+ transition: "background 0.15s ease"
309
+ },
310
+ onMouseEnter: (e) => {
311
+ e.target.style.background = "var(--sm-surface-muted, #f8fafc)";
312
+ },
313
+ onMouseLeave: (e) => {
314
+ e.target.style.background = "transparent";
315
+ },
316
+ children: emoji
317
+ },
318
+ emoji
319
+ ))
320
+ }
321
+ ),
322
+ document.body
275
323
  );
276
324
  }
277
325
 
@@ -391,10 +439,10 @@ function ChatMessageItem({
391
439
  onReport,
392
440
  highlight = false
393
441
  }) {
394
- const [showPicker, setShowPicker] = React3.useState(false);
442
+ const [showPicker, setShowPicker] = React4.useState(false);
395
443
  const isOwn = Boolean(currentUserId && message.sender_id === currentUserId);
396
444
  const canReact = Boolean(onAddReaction || onRemoveReaction);
397
- const reactionEntries = React3.useMemo(() => message.reactions ?? [], [message.reactions]);
445
+ const reactionEntries = React4.useMemo(() => message.reactions ?? [], [message.reactions]);
398
446
  return /* @__PURE__ */ jsxRuntime.jsxs(
399
447
  "div",
400
448
  {
@@ -529,13 +577,13 @@ function ChatMessageList({
529
577
  onReport,
530
578
  emptyState
531
579
  }) {
532
- const containerRef = React3.useRef(null);
533
- const unreadMarkerRef = React3.useRef(null);
534
- const lastMessageCountRef = React3.useRef(messages.length);
535
- const didScrollToUnreadRef = React3.useRef(false);
536
- const [showJumpToLatest, setShowJumpToLatest] = React3.useState(false);
537
- const unreadIndex = React3.useMemo(() => getUnreadIndex(messages, unreadSince), [messages, unreadSince]);
538
- React3.useEffect(() => {
580
+ const containerRef = React4.useRef(null);
581
+ const unreadMarkerRef = React4.useRef(null);
582
+ const lastMessageCountRef = React4.useRef(messages.length);
583
+ const didScrollToUnreadRef = React4.useRef(false);
584
+ const [showJumpToLatest, setShowJumpToLatest] = React4.useState(false);
585
+ const unreadIndex = React4.useMemo(() => getUnreadIndex(messages, unreadSince), [messages, unreadSince]);
586
+ React4.useEffect(() => {
539
587
  const container = containerRef.current;
540
588
  if (!container) return;
541
589
  const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
@@ -548,7 +596,7 @@ function ChatMessageList({
548
596
  }
549
597
  lastMessageCountRef.current = messages.length;
550
598
  }, [messages]);
551
- React3.useEffect(() => {
599
+ React4.useEffect(() => {
552
600
  if (!scrollToUnreadOnMount || unreadIndex < 0 || didScrollToUnreadRef.current) {
553
601
  return;
554
602
  }
@@ -595,7 +643,7 @@ function ChatMessageList({
595
643
  const previousMessage = messages[index - 1];
596
644
  const showDateDivider = !previousMessage || !isSameDay(previousMessage.created_at, message.created_at);
597
645
  const showUnreadDivider = unreadIndex === index;
598
- return /* @__PURE__ */ jsxRuntime.jsxs(React3__default.default.Fragment, { children: [
646
+ return /* @__PURE__ */ jsxRuntime.jsxs(React4__default.default.Fragment, { children: [
599
647
  showDateDivider ? /* @__PURE__ */ jsxRuntime.jsx(
600
648
  "div",
601
649
  {
@@ -720,19 +768,19 @@ function ChatThread({
720
768
  } = useChat(conversationId);
721
769
  const { typingUsers, sendTyping } = useTyping(conversationId);
722
770
  const { members } = usePresence(conversationId);
723
- const ownReadStatus = React3.useMemo(
771
+ const ownReadStatus = React4.useMemo(
724
772
  () => resolvedUserId ? readStatuses.find((status) => status.user_id === resolvedUserId)?.last_read_at : void 0,
725
773
  [readStatuses, resolvedUserId]
726
774
  );
727
- const otherTypingUsers = React3.useMemo(
775
+ const otherTypingUsers = React4.useMemo(
728
776
  () => typingUsers.filter((userId) => userId !== resolvedUserId),
729
777
  [typingUsers, resolvedUserId]
730
778
  );
731
- const activeMembers = React3.useMemo(
779
+ const activeMembers = React4.useMemo(
732
780
  () => members.filter((member) => member.userId !== resolvedUserId),
733
781
  [members, resolvedUserId]
734
782
  );
735
- React3.useEffect(() => {
783
+ React4.useEffect(() => {
736
784
  if (!messages.length) return;
737
785
  void markRead();
738
786
  }, [markRead, messages.length, messages[messages.length - 1]?.id]);
@@ -871,8 +919,8 @@ function ConversationList({
871
919
  const { conversations, isLoading } = useConversations({
872
920
  conversationType
873
921
  });
874
- const [search, setSearch] = React3.useState("");
875
- const filtered = React3.useMemo(() => {
922
+ const [search, setSearch] = React4.useState("");
923
+ const filtered = React4.useMemo(() => {
876
924
  const query = search.trim().toLowerCase();
877
925
  if (!query) return conversations;
878
926
  return conversations.filter((conversation) => {
@@ -1019,15 +1067,15 @@ function ConversationList({
1019
1067
  }
1020
1068
  );
1021
1069
  }
1022
- var ChatContext = React3.createContext(null);
1070
+ var ChatContext = React4.createContext(null);
1023
1071
  function useChatContext() {
1024
- const ctx = React3.useContext(ChatContext);
1072
+ const ctx = React4.useContext(ChatContext);
1025
1073
  if (!ctx) throw new Error("useChatContext must be used within a ChatProvider");
1026
1074
  return ctx;
1027
1075
  }
1028
1076
  function ChatProvider({ config, children }) {
1029
- const [client] = React3.useState(() => new chunkW2PWFS3E_cjs.ChatClient(config));
1030
- React3.useEffect(() => {
1077
+ const [client] = React4.useState(() => new chunkW2PWFS3E_cjs.ChatClient(config));
1078
+ React4.useEffect(() => {
1031
1079
  return () => {
1032
1080
  client.destroy();
1033
1081
  };
@@ -1042,28 +1090,28 @@ function useChatConfig() {
1042
1090
  }
1043
1091
  function useConnection() {
1044
1092
  const { client } = useChatContext();
1045
- const [status, setStatus] = React3.useState(client.status);
1046
- React3.useEffect(() => {
1093
+ const [status, setStatus] = React4.useState(client.status);
1094
+ React4.useEffect(() => {
1047
1095
  return client.on("connected", () => setStatus("connected"));
1048
1096
  }, [client]);
1049
- React3.useEffect(() => {
1097
+ React4.useEffect(() => {
1050
1098
  return client.on("disconnected", () => setStatus("disconnected"));
1051
1099
  }, [client]);
1052
- React3.useEffect(() => {
1100
+ React4.useEffect(() => {
1053
1101
  return client.on("reconnecting", () => setStatus("reconnecting"));
1054
1102
  }, [client]);
1055
- const connect = React3.useCallback(() => client.connect(), [client]);
1056
- const disconnect = React3.useCallback(() => client.disconnect(), [client]);
1103
+ const connect = React4.useCallback(() => client.connect(), [client]);
1104
+ const disconnect = React4.useCallback(() => client.disconnect(), [client]);
1057
1105
  return { status, connect, disconnect };
1058
1106
  }
1059
1107
  function useChat(conversationId) {
1060
1108
  const { client } = useChatContext();
1061
- const [messages, setMessages] = React3.useState([]);
1062
- const [readStatuses, setReadStatuses] = React3.useState([]);
1063
- const [isLoading, setIsLoading] = React3.useState(false);
1064
- const [error, setError] = React3.useState(null);
1065
- const [hasMore, setHasMore] = React3.useState(false);
1066
- React3.useEffect(() => {
1109
+ const [messages, setMessages] = React4.useState([]);
1110
+ const [readStatuses, setReadStatuses] = React4.useState([]);
1111
+ const [isLoading, setIsLoading] = React4.useState(false);
1112
+ const [error, setError] = React4.useState(null);
1113
+ const [hasMore, setHasMore] = React4.useState(false);
1114
+ React4.useEffect(() => {
1067
1115
  if (!conversationId) return;
1068
1116
  setIsLoading(true);
1069
1117
  setError(null);
@@ -1094,7 +1142,7 @@ function useChat(conversationId) {
1094
1142
  unsub?.();
1095
1143
  };
1096
1144
  }, [client, conversationId]);
1097
- React3.useEffect(() => {
1145
+ React4.useEffect(() => {
1098
1146
  if (!conversationId) return;
1099
1147
  return client.on("message", ({ message, conversationId: convId }) => {
1100
1148
  if (convId === conversationId) {
@@ -1102,7 +1150,7 @@ function useChat(conversationId) {
1102
1150
  }
1103
1151
  });
1104
1152
  }, [client, conversationId]);
1105
- React3.useEffect(() => {
1153
+ React4.useEffect(() => {
1106
1154
  if (!conversationId) return;
1107
1155
  return client.on("message:updated", ({ message, conversationId: convId }) => {
1108
1156
  if (convId === conversationId) {
@@ -1110,7 +1158,7 @@ function useChat(conversationId) {
1110
1158
  }
1111
1159
  });
1112
1160
  }, [client, conversationId]);
1113
- React3.useEffect(() => {
1161
+ React4.useEffect(() => {
1114
1162
  if (!conversationId) return;
1115
1163
  return client.on("message:deleted", ({ messageId, conversationId: convId }) => {
1116
1164
  if (convId === conversationId) {
@@ -1118,7 +1166,7 @@ function useChat(conversationId) {
1118
1166
  }
1119
1167
  });
1120
1168
  }, [client, conversationId]);
1121
- React3.useEffect(() => {
1169
+ React4.useEffect(() => {
1122
1170
  if (!conversationId) return;
1123
1171
  return client.on("reaction", ({ conversationId: convId }) => {
1124
1172
  if (convId === conversationId) {
@@ -1126,7 +1174,7 @@ function useChat(conversationId) {
1126
1174
  }
1127
1175
  });
1128
1176
  }, [client, conversationId]);
1129
- React3.useEffect(() => {
1177
+ React4.useEffect(() => {
1130
1178
  if (!conversationId) return;
1131
1179
  return client.on("read", ({ conversationId: convId, userId, lastReadAt }) => {
1132
1180
  if (convId !== conversationId) return;
@@ -1141,14 +1189,14 @@ function useChat(conversationId) {
1141
1189
  });
1142
1190
  });
1143
1191
  }, [client, conversationId]);
1144
- const sendMessage = React3.useCallback(
1192
+ const sendMessage = React4.useCallback(
1145
1193
  async (content, options) => {
1146
1194
  if (!conversationId) return;
1147
1195
  return client.sendMessage(conversationId, { content, ...options });
1148
1196
  },
1149
1197
  [client, conversationId]
1150
1198
  );
1151
- const loadMore = React3.useCallback(async () => {
1199
+ const loadMore = React4.useCallback(async () => {
1152
1200
  if (!conversationId || !messages.length) return;
1153
1201
  const oldestId = messages[0]?.id;
1154
1202
  const result = await client.getMessages(conversationId, { before: oldestId });
@@ -1157,7 +1205,7 @@ function useChat(conversationId) {
1157
1205
  setHasMore(result.data.has_more ?? false);
1158
1206
  }
1159
1207
  }, [client, conversationId, messages]);
1160
- const editMessage = React3.useCallback(
1208
+ const editMessage = React4.useCallback(
1161
1209
  async (messageId, content) => {
1162
1210
  const result = await client.editMessage(messageId, content);
1163
1211
  if (result.error) {
@@ -1167,7 +1215,7 @@ function useChat(conversationId) {
1167
1215
  },
1168
1216
  [client]
1169
1217
  );
1170
- const deleteMessage = React3.useCallback(
1218
+ const deleteMessage = React4.useCallback(
1171
1219
  async (messageId) => {
1172
1220
  const result = await client.deleteMessage(messageId);
1173
1221
  if (result.error) {
@@ -1177,7 +1225,7 @@ function useChat(conversationId) {
1177
1225
  },
1178
1226
  [client]
1179
1227
  );
1180
- const addReaction = React3.useCallback(
1228
+ const addReaction = React4.useCallback(
1181
1229
  async (messageId, emoji) => {
1182
1230
  const result = await client.addReaction(messageId, emoji);
1183
1231
  if (result.error) {
@@ -1187,7 +1235,7 @@ function useChat(conversationId) {
1187
1235
  },
1188
1236
  [client]
1189
1237
  );
1190
- const removeReaction = React3.useCallback(
1238
+ const removeReaction = React4.useCallback(
1191
1239
  async (messageId, emoji) => {
1192
1240
  const result = await client.removeReaction(messageId, emoji);
1193
1241
  if (result.error) {
@@ -1197,7 +1245,7 @@ function useChat(conversationId) {
1197
1245
  },
1198
1246
  [client]
1199
1247
  );
1200
- const uploadAttachment = React3.useCallback(
1248
+ const uploadAttachment = React4.useCallback(
1201
1249
  async (file, onProgress, signal) => {
1202
1250
  const result = await client.uploadAttachment(file, onProgress, signal);
1203
1251
  if (result.error) {
@@ -1207,7 +1255,7 @@ function useChat(conversationId) {
1207
1255
  },
1208
1256
  [client]
1209
1257
  );
1210
- const refreshAttachmentUrl = React3.useCallback(
1258
+ const refreshAttachmentUrl = React4.useCallback(
1211
1259
  async (messageId, fileId) => {
1212
1260
  const result = await client.refreshAttachmentUrl(messageId, fileId);
1213
1261
  if (result.error) {
@@ -1217,7 +1265,7 @@ function useChat(conversationId) {
1217
1265
  },
1218
1266
  [client]
1219
1267
  );
1220
- const reportMessage = React3.useCallback(
1268
+ const reportMessage = React4.useCallback(
1221
1269
  async (messageId, reason, description) => {
1222
1270
  const result = await client.reportMessage(messageId, reason, description);
1223
1271
  if (result.error) {
@@ -1227,7 +1275,7 @@ function useChat(conversationId) {
1227
1275
  },
1228
1276
  [client]
1229
1277
  );
1230
- const muteConversation = React3.useCallback(
1278
+ const muteConversation = React4.useCallback(
1231
1279
  async (mutedUntil) => {
1232
1280
  if (!conversationId) return;
1233
1281
  const result = await client.muteConversation(conversationId, mutedUntil);
@@ -1238,7 +1286,7 @@ function useChat(conversationId) {
1238
1286
  },
1239
1287
  [client, conversationId]
1240
1288
  );
1241
- const unmuteConversation = React3.useCallback(async () => {
1289
+ const unmuteConversation = React4.useCallback(async () => {
1242
1290
  if (!conversationId) return;
1243
1291
  const result = await client.unmuteConversation(conversationId);
1244
1292
  if (result.error) {
@@ -1246,7 +1294,7 @@ function useChat(conversationId) {
1246
1294
  }
1247
1295
  return result;
1248
1296
  }, [client, conversationId]);
1249
- const getReadStatus = React3.useCallback(async () => {
1297
+ const getReadStatus = React4.useCallback(async () => {
1250
1298
  if (!conversationId) return;
1251
1299
  const result = await client.getReadStatus(conversationId);
1252
1300
  if (result.data?.statuses) {
@@ -1256,7 +1304,7 @@ function useChat(conversationId) {
1256
1304
  }
1257
1305
  return result;
1258
1306
  }, [client, conversationId]);
1259
- const markRead = React3.useCallback(async () => {
1307
+ const markRead = React4.useCallback(async () => {
1260
1308
  if (!conversationId) return;
1261
1309
  await client.markRead(conversationId);
1262
1310
  await getReadStatus();
@@ -1284,8 +1332,8 @@ function useChat(conversationId) {
1284
1332
  }
1285
1333
  function usePresence(conversationId) {
1286
1334
  const { client } = useChatContext();
1287
- const [members, setMembers] = React3.useState([]);
1288
- React3.useEffect(() => {
1335
+ const [members, setMembers] = React4.useState([]);
1336
+ React4.useEffect(() => {
1289
1337
  if (!conversationId) return;
1290
1338
  let cancelled = false;
1291
1339
  (async () => {
@@ -1342,9 +1390,9 @@ function usePresence(conversationId) {
1342
1390
  }
1343
1391
  function useTyping(conversationId) {
1344
1392
  const { client } = useChatContext();
1345
- const [typingUsers, setTypingUsers] = React3.useState([]);
1346
- const typingTimers = React3.useRef(/* @__PURE__ */ new Map());
1347
- React3.useEffect(() => {
1393
+ const [typingUsers, setTypingUsers] = React4.useState([]);
1394
+ const typingTimers = React4.useRef(/* @__PURE__ */ new Map());
1395
+ React4.useEffect(() => {
1348
1396
  if (!conversationId) return;
1349
1397
  const unsubTyping = client.on("typing", ({ conversationId: convId, userId }) => {
1350
1398
  if (convId !== conversationId) return;
@@ -1377,7 +1425,7 @@ function useTyping(conversationId) {
1377
1425
  typingTimers.current.clear();
1378
1426
  };
1379
1427
  }, [client, conversationId]);
1380
- const sendTyping = React3.useCallback(
1428
+ const sendTyping = React4.useCallback(
1381
1429
  (isTyping = true) => {
1382
1430
  if (!conversationId) return;
1383
1431
  client.sendTyping(conversationId, isTyping);
@@ -1388,10 +1436,10 @@ function useTyping(conversationId) {
1388
1436
  }
1389
1437
  function useConversations(options) {
1390
1438
  const { client } = useChatContext();
1391
- const [conversations, setConversations] = React3.useState([]);
1392
- const [isLoading, setIsLoading] = React3.useState(true);
1393
- const refreshTimer = React3.useRef(null);
1394
- const fetchConversations = React3.useCallback(async () => {
1439
+ const [conversations, setConversations] = React4.useState([]);
1440
+ const [isLoading, setIsLoading] = React4.useState(true);
1441
+ const refreshTimer = React4.useRef(null);
1442
+ const fetchConversations = React4.useCallback(async () => {
1395
1443
  const result = await client.listConversations({
1396
1444
  conversation_type: options?.conversationType
1397
1445
  });
@@ -1400,10 +1448,10 @@ function useConversations(options) {
1400
1448
  }
1401
1449
  setIsLoading(false);
1402
1450
  }, [client, options?.conversationType]);
1403
- React3.useEffect(() => {
1451
+ React4.useEffect(() => {
1404
1452
  fetchConversations();
1405
1453
  }, [fetchConversations]);
1406
- React3.useEffect(() => {
1454
+ React4.useEffect(() => {
1407
1455
  return client.on("inbox:update", () => {
1408
1456
  if (refreshTimer.current) clearTimeout(refreshTimer.current);
1409
1457
  refreshTimer.current = setTimeout(() => {
@@ -1411,14 +1459,14 @@ function useConversations(options) {
1411
1459
  }, 500);
1412
1460
  });
1413
1461
  }, [client, fetchConversations]);
1414
- React3.useEffect(() => {
1462
+ React4.useEffect(() => {
1415
1463
  return client.on("read", ({ conversationId }) => {
1416
1464
  setConversations(
1417
1465
  (prev) => prev.map((c) => c.id === conversationId ? { ...c, unread_count: 0 } : c)
1418
1466
  );
1419
1467
  });
1420
1468
  }, [client]);
1421
- React3.useEffect(() => {
1469
+ React4.useEffect(() => {
1422
1470
  return () => {
1423
1471
  if (refreshTimer.current) clearTimeout(refreshTimer.current);
1424
1472
  };
@@ -1427,8 +1475,8 @@ function useConversations(options) {
1427
1475
  }
1428
1476
  function useUnreadCount() {
1429
1477
  const { client } = useChatContext();
1430
- const [totalUnread, setTotalUnread] = React3.useState(0);
1431
- React3.useEffect(() => {
1478
+ const [totalUnread, setTotalUnread] = React4.useState(0);
1479
+ React4.useEffect(() => {
1432
1480
  (async () => {
1433
1481
  const result = await client.getUnreadTotal();
1434
1482
  if (result.data) {
@@ -1436,12 +1484,12 @@ function useUnreadCount() {
1436
1484
  }
1437
1485
  })();
1438
1486
  }, [client]);
1439
- React3.useEffect(() => {
1487
+ React4.useEffect(() => {
1440
1488
  return client.on("inbox:update", () => {
1441
1489
  setTotalUnread((prev) => prev + 1);
1442
1490
  });
1443
1491
  }, [client]);
1444
- React3.useEffect(() => {
1492
+ React4.useEffect(() => {
1445
1493
  return client.on("read", () => {
1446
1494
  (async () => {
1447
1495
  const result = await client.getUnreadTotal();