@webinex/chatify 2.0.0-alpha1 → 2.0.0-alpha12

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 (401) hide show
  1. package/dist/Chatify-CwAfN1wu.js +2396 -0
  2. package/dist/Chatify-CwAfN1wu.js.map +1 -0
  3. package/dist/Chatify.css +717 -0
  4. package/dist/audit.css +60 -0
  5. package/dist/audit.js +242 -0
  6. package/dist/audit.js.map +1 -0
  7. package/dist/index.js +104 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/types/audit/AuditChatList.d.ts +9 -0
  10. package/dist/types/audit/AuditConversationPanel.d.ts +10 -0
  11. package/dist/types/audit/AuditPanel.d.ts +14 -0
  12. package/dist/types/audit/AuditPanelCustomizeValue.d.ts +9 -0
  13. package/dist/types/audit/AuditSearch.d.ts +5 -0
  14. package/dist/types/audit/AuditSearchValue.d.ts +14 -0
  15. package/dist/types/audit/auditApi.d.ts +101 -0
  16. package/dist/types/audit/index.d.ts +17 -0
  17. package/dist/{esm/types → types}/core/api/baseApi.d.ts +1 -1
  18. package/dist/{esm/types → types}/core/client.d.ts +12 -7
  19. package/dist/{esm/types → types}/core/types.d.ts +28 -6
  20. package/dist/types/ui/Chat/ChatEditableHeaderName.d.ts +1 -0
  21. package/dist/types/ui/Chat/ChatHeaderActions.d.ts +1 -0
  22. package/dist/{esm/types → types}/ui/Chat/ChatView.d.ts +1 -2
  23. package/dist/types/ui/Chat/Members/ChatMembersButton.d.ts +1 -0
  24. package/dist/types/ui/Chat/Members/ChatMembersPanel.d.ts +1 -0
  25. package/dist/types/ui/Chat/Members/ChatMembersPreview.d.ts +1 -0
  26. package/dist/types/ui/ChatGroup/AutoReply/AutoReplyButton.d.ts +1 -0
  27. package/dist/types/ui/ChatGroup/AutoReply/AutoReplyForm.d.ts +12 -0
  28. package/dist/types/ui/ChatGroup/AutoReply/AutoReplyPanel.d.ts +1 -0
  29. package/dist/types/ui/ChatGroup/AutoReply/AutoReplyPeriodInput.d.ts +4 -0
  30. package/dist/types/ui/ChatGroup/AutoReply/AutoReplyTextInput.d.ts +4 -0
  31. package/dist/types/ui/ChatGroup/AutoReply/index.d.ts +17 -0
  32. package/dist/{esm/types → types}/ui/ChatGroup/ChatGroupContext.d.ts +2 -1
  33. package/dist/{esm/types → types}/ui/ChatGroup/ChatGroupPanel.d.ts +3 -2
  34. package/dist/types/ui/ChatGroup/Create/CreateChatButton.d.ts +1 -0
  35. package/{src → dist}/types/ui/ChatGroup/Create/CreateChatForm.d.ts +1 -2
  36. package/dist/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +4 -0
  37. package/dist/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +4 -0
  38. package/dist/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +1 -0
  39. package/dist/types/ui/ChatGroup/Layout/ChatGroupActions.d.ts +1 -0
  40. package/dist/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +1 -0
  41. package/dist/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +1 -0
  42. package/dist/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +1 -0
  43. package/dist/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +1 -0
  44. package/dist/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +1 -0
  45. package/{src → dist}/types/ui/ChatGroup/Layout/index.d.ts +3 -0
  46. package/dist/types/ui/ChatGroup/List/ChatListPanel.d.ts +1 -0
  47. package/dist/types/ui/ChatGroup/List/index.d.ts +6 -0
  48. package/dist/{esm/types → types}/ui/ChatGroup/index.d.ts +1 -0
  49. package/dist/types/ui/Chatify.d.ts +9 -0
  50. package/dist/{esm/types → types}/ui/Conversation/Conversation.d.ts +3 -2
  51. package/dist/types/ui/Conversation/ConversationActions.d.ts +1 -0
  52. package/dist/types/ui/Conversation/ConversationBody.d.ts +1 -0
  53. package/dist/{esm/types → types}/ui/Conversation/ConversationContext.d.ts +7 -4
  54. package/dist/types/ui/Conversation/ConversationHeader.d.ts +1 -0
  55. package/dist/types/ui/Conversation/ConversationName.d.ts +1 -0
  56. package/dist/types/ui/Conversation/InputBox/InputBox.d.ts +1 -0
  57. package/dist/types/ui/Conversation/InputBox/InputBoxFile.d.ts +7 -0
  58. package/dist/types/ui/Conversation/InputBox/InputBoxFileList.d.ts +7 -0
  59. package/dist/types/ui/Conversation/InputBox/InputFilesBox.d.ts +11 -0
  60. package/dist/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +6 -0
  61. package/dist/{esm/types → types}/ui/Conversation/InputBox/InputTextBox.d.ts +2 -1
  62. package/{src → dist}/types/ui/Conversation/InputBox/index.d.ts +8 -1
  63. package/dist/types/ui/Conversation/Message/MessageAuthor.d.ts +2 -0
  64. package/dist/types/ui/Conversation/Message/MessageBox.d.ts +5 -0
  65. package/dist/types/ui/Conversation/Message/MessageContent.d.ts +2 -0
  66. package/dist/types/ui/Conversation/Message/MessageFile.d.ts +5 -0
  67. package/dist/types/ui/Conversation/Message/MessageFileList.d.ts +2 -0
  68. package/dist/types/ui/Conversation/Message/MessageInfoBox.d.ts +2 -0
  69. package/dist/{esm/types → types}/ui/Conversation/Message/MessageRow.d.ts +1 -1
  70. package/dist/types/ui/Conversation/Message/MessageText.d.ts +2 -0
  71. package/{src → dist}/types/ui/Conversation/Message/index.d.ts +6 -0
  72. package/dist/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +6 -0
  73. package/dist/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +2 -0
  74. package/dist/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +2 -0
  75. package/dist/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +2 -0
  76. package/dist/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +5 -0
  77. package/{src → dist}/types/ui/Conversation/SystemMessage/SystemMessageRow.d.ts +1 -1
  78. package/dist/types/ui/Thread/ThreadActions.d.ts +1 -0
  79. package/dist/{esm/types → types}/ui/Thread/ThreadContext.d.ts +1 -1
  80. package/dist/types/ui/common/Avatar.d.ts +5 -0
  81. package/dist/types/ui/common/ChatList/ChatList.d.ts +16 -0
  82. package/dist/types/ui/common/ChatList/ChatListItemAvatar.d.ts +2 -0
  83. package/dist/types/ui/common/ChatList/ChatListItemBox.d.ts +9 -0
  84. package/dist/types/ui/common/ChatList/ChatListItemLastMessage.d.ts +2 -0
  85. package/dist/types/ui/common/ChatList/ChatListItemLastMessageAuthor.d.ts +2 -0
  86. package/dist/types/ui/common/ChatList/ChatListItemLastMessageContent.d.ts +2 -0
  87. package/dist/types/ui/common/ChatList/ChatListItemLastMessageSentAt.d.ts +2 -0
  88. package/dist/types/ui/common/ChatList/ChatListItemName.d.ts +2 -0
  89. package/dist/types/ui/common/ChatList/ChatListItemUnreadCount.d.ts +2 -0
  90. package/dist/types/ui/common/ChatList/ChatListValue.d.ts +8 -0
  91. package/{src/types/ui/ChatGroup/List → dist/types/ui/common/ChatList}/index.d.ts +1 -0
  92. package/dist/types/ui/common/Icon.d.ts +22 -0
  93. package/dist/types/ui/common/MessageSkeleton.d.ts +4 -0
  94. package/dist/{esm/types → types}/ui/common/index.d.ts +1 -0
  95. package/{src → dist}/types/ui/customize.d.ts +3 -3
  96. package/dist/{esm/types → types}/ui/index.d.ts +1 -3
  97. package/dist/{esm/types → types}/ui/localizer.d.ts +27 -2
  98. package/dist/types/ui/useFormatter.d.ts +3 -0
  99. package/package.json +81 -93
  100. package/src/audit/AuditChatList.tsx +25 -0
  101. package/src/audit/AuditConversationPanel.tsx +48 -0
  102. package/src/audit/AuditPanel.tsx +76 -0
  103. package/src/audit/AuditPanelCustomizeValue.ts +11 -0
  104. package/src/audit/AuditSearch.tsx +89 -0
  105. package/src/audit/AuditSearchValue.tsx +42 -0
  106. package/src/audit/auditApi.tsx +113 -0
  107. package/src/audit/index.d.ts +18 -0
  108. package/src/audit/index.tsx +28 -0
  109. package/src/audit/styles.scss +72 -0
  110. package/src/core/api/api.ts +669 -642
  111. package/src/core/api/baseApi.ts +38 -38
  112. package/src/core/api/index.ts +1 -1
  113. package/src/core/client.ts +298 -280
  114. package/src/core/constants.ts +1 -1
  115. package/src/core/debounce.ts +90 -90
  116. package/src/core/index.ts +4 -4
  117. package/src/core/types.tsx +182 -152
  118. package/src/index.ts +2 -2
  119. package/src/styles/aside.scss +26 -161
  120. package/src/styles/chat-list.scss +138 -0
  121. package/src/styles/chat.scss +11 -208
  122. package/src/styles/conversation.scss +200 -0
  123. package/src/styles/index.scss +220 -110
  124. package/src/styles/input.scss +148 -74
  125. package/src/styles/keyframes.scss +14 -14
  126. package/src/styles/members.scss +13 -13
  127. package/src/styles/mixins.scss +25 -20
  128. package/src/styles/variables.scss +13 -10
  129. package/src/ui/Chat/ChatContext.tsx +30 -30
  130. package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
  131. package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
  132. package/src/ui/Chat/ChatPanel.tsx +30 -30
  133. package/src/ui/Chat/ChatView.tsx +115 -115
  134. package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
  135. package/src/ui/Chat/Members/ChatMembersPanel.tsx +112 -112
  136. package/src/ui/Chat/Members/ChatMembersPreview.tsx +25 -25
  137. package/src/ui/Chat/Members/index.ts +13 -13
  138. package/src/ui/Chat/index.ts +6 -6
  139. package/src/ui/ChatGroup/AutoReply/AutoReplyButton.tsx +21 -0
  140. package/src/ui/ChatGroup/AutoReply/AutoReplyForm.tsx +50 -0
  141. package/src/ui/ChatGroup/AutoReply/AutoReplyPanel.tsx +94 -0
  142. package/src/ui/ChatGroup/AutoReply/AutoReplyPeriodInput.tsx +22 -0
  143. package/src/ui/ChatGroup/AutoReply/AutoReplyTextInput.tsx +22 -0
  144. package/src/ui/ChatGroup/AutoReply/index.ts +19 -0
  145. package/src/ui/ChatGroup/ChatGroupContext.tsx +61 -50
  146. package/src/ui/ChatGroup/ChatGroupPanel.tsx +75 -73
  147. package/src/ui/ChatGroup/Create/CreateChatButton.tsx +15 -15
  148. package/src/ui/ChatGroup/Create/CreateChatForm.tsx +36 -36
  149. package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +65 -65
  150. package/src/ui/ChatGroup/Create/CreateChatNameInput.tsx +25 -25
  151. package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +45 -45
  152. package/src/ui/ChatGroup/Create/index.ts +19 -19
  153. package/src/ui/ChatGroup/Layout/ChatGroupActions.tsx +15 -0
  154. package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
  155. package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +10 -10
  156. package/src/ui/ChatGroup/Layout/ChatGroupFooter.tsx +3 -3
  157. package/src/ui/ChatGroup/Layout/ChatGroupHeader.tsx +5 -5
  158. package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +19 -17
  159. package/src/ui/ChatGroup/Layout/index.ts +22 -19
  160. package/src/ui/ChatGroup/List/ChatListPanel.tsx +28 -0
  161. package/src/ui/ChatGroup/List/index.ts +8 -31
  162. package/src/ui/ChatGroup/index.ts +6 -5
  163. package/src/ui/Chatify.tsx +15 -9
  164. package/src/ui/Conversation/Conversation.tsx +92 -76
  165. package/src/ui/Conversation/ConversationActions.tsx +12 -5
  166. package/src/ui/Conversation/ConversationBody.tsx +28 -28
  167. package/src/ui/Conversation/ConversationContext.ts +30 -27
  168. package/src/ui/Conversation/ConversationHeader.tsx +19 -23
  169. package/src/ui/Conversation/ConversationName.tsx +7 -7
  170. package/src/ui/Conversation/InputBox/InputBox.tsx +126 -40
  171. package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -0
  172. package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -0
  173. package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -9
  174. package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -17
  175. package/src/ui/Conversation/InputBox/InputTextBox.tsx +61 -53
  176. package/src/ui/Conversation/InputBox/index.ts +23 -16
  177. package/src/ui/Conversation/Message/MessageAuthor.tsx +13 -13
  178. package/src/ui/Conversation/Message/MessageBox.tsx +20 -20
  179. package/src/ui/Conversation/Message/MessageContent.tsx +15 -11
  180. package/src/ui/Conversation/Message/MessageFile.tsx +54 -0
  181. package/src/ui/Conversation/Message/MessageFileList.tsx +14 -0
  182. package/src/ui/Conversation/Message/MessageInfoBox.tsx +28 -28
  183. package/src/ui/Conversation/Message/MessageRow.tsx +28 -28
  184. package/src/ui/Conversation/Message/MessageText.tsx +7 -7
  185. package/src/ui/Conversation/Message/index.ts +28 -22
  186. package/src/ui/Conversation/NextObserver/NextMessagesObserver.tsx +47 -47
  187. package/src/ui/Conversation/NextObserver/index.ts +1 -1
  188. package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +49 -49
  189. package/src/ui/Conversation/ReadObserver/index.ts +1 -1
  190. package/src/ui/Conversation/SendingMessage/SendingMessageBox.tsx +16 -16
  191. package/src/ui/Conversation/SendingMessage/SendingMessageContent.tsx +13 -13
  192. package/src/ui/Conversation/SendingMessage/SendingMessageInfoBox.tsx +13 -13
  193. package/src/ui/Conversation/SendingMessage/SendingMessageText.tsx +7 -7
  194. package/src/ui/Conversation/SendingMessage/index.ts +16 -16
  195. package/src/ui/Conversation/SystemMessage/SystemMessageBox.tsx +20 -20
  196. package/src/ui/Conversation/SystemMessage/SystemMessageRow.tsx +28 -28
  197. package/src/ui/Conversation/SystemMessage/index.ts +10 -10
  198. package/src/ui/Conversation/index.ts +13 -13
  199. package/src/ui/Thread/ThreadActions.tsx +22 -22
  200. package/src/ui/Thread/ThreadContext.ts +13 -13
  201. package/src/ui/Thread/ThreadPanel.tsx +127 -127
  202. package/src/ui/Thread/index.tsx +3 -3
  203. package/src/ui/color.ts +20 -20
  204. package/src/ui/common/Avatar.tsx +20 -20
  205. package/src/ui/common/ChatList/ChatList.tsx +84 -0
  206. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemAvatar.tsx +22 -22
  207. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemBox.tsx +32 -26
  208. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessage.tsx +15 -15
  209. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessageAuthor.tsx +15 -15
  210. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessageContent.tsx +21 -21
  211. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessageSentAt.tsx +22 -22
  212. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemName.tsx +8 -8
  213. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemUnreadCount.tsx +12 -12
  214. package/src/ui/common/ChatList/ChatListValue.ts +9 -0
  215. package/{dist/esm/types/ui/ChatGroup/List/index.d.ts → src/ui/common/ChatList/index.ts} +12 -9
  216. package/src/ui/common/Icon.tsx +48 -40
  217. package/src/ui/common/MessageSkeleton.tsx +20 -20
  218. package/src/ui/common/index.ts +14 -13
  219. package/src/ui/customize.tsx +51 -53
  220. package/src/ui/index.ts +11 -11
  221. package/src/ui/localizer.tsx +137 -81
  222. package/src/ui/useFormatter.tsx +17 -0
  223. package/dist/css/chatify.css +0 -560
  224. package/dist/esm/index.js +0 -11
  225. package/dist/esm/index.js.map +0 -1
  226. package/dist/esm/types/core/api/accountApi.d.ts +0 -5
  227. package/dist/esm/types/core/api/api.d.ts +0 -2380
  228. package/dist/esm/types/core/api/chatApi.d.ts +0 -16
  229. package/dist/esm/types/core/api/chatListApi.d.ts +0 -5
  230. package/dist/esm/types/core/api/chatMemberApi.d.ts +0 -6
  231. package/dist/esm/types/core/api/chatMessageApi.d.ts +0 -3
  232. package/dist/esm/types/core/api/threadApi.d.ts +0 -1
  233. package/dist/esm/types/core/api/threadMessageApi.d.ts +0 -6
  234. package/dist/esm/types/ui/Chat/ChatEditableHeaderName.d.ts +0 -2
  235. package/dist/esm/types/ui/Chat/ChatHeaderActions.d.ts +0 -2
  236. package/dist/esm/types/ui/Chat/Members/ChatMembersButton.d.ts +0 -2
  237. package/dist/esm/types/ui/Chat/Members/ChatMembersPanel.d.ts +0 -2
  238. package/dist/esm/types/ui/Chat/Members/ChatMembersPreview.d.ts +0 -2
  239. package/dist/esm/types/ui/ChatGroup/Create/CreateChatButton.d.ts +0 -2
  240. package/dist/esm/types/ui/ChatGroup/Create/CreateChatForm.d.ts +0 -11
  241. package/dist/esm/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +0 -5
  242. package/dist/esm/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +0 -5
  243. package/dist/esm/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +0 -2
  244. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +0 -2
  245. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +0 -2
  246. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +0 -2
  247. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +0 -2
  248. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +0 -2
  249. package/dist/esm/types/ui/ChatGroup/Layout/index.d.ts +0 -17
  250. package/dist/esm/types/ui/ChatGroup/List/ChatList.d.ts +0 -2
  251. package/dist/esm/types/ui/ChatGroup/List/ChatListItemAvatar.d.ts +0 -3
  252. package/dist/esm/types/ui/ChatGroup/List/ChatListItemBox.d.ts +0 -6
  253. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessage.d.ts +0 -3
  254. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessageAuthor.d.ts +0 -3
  255. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessageContent.d.ts +0 -3
  256. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessageSentAt.d.ts +0 -3
  257. package/dist/esm/types/ui/ChatGroup/List/ChatListItemName.d.ts +0 -3
  258. package/dist/esm/types/ui/ChatGroup/List/ChatListItemUnreadCount.d.ts +0 -3
  259. package/dist/esm/types/ui/Chatify.d.ts +0 -8
  260. package/dist/esm/types/ui/Conversation/ConversationActions.d.ts +0 -2
  261. package/dist/esm/types/ui/Conversation/ConversationBody.d.ts +0 -2
  262. package/dist/esm/types/ui/Conversation/ConversationHeader.d.ts +0 -2
  263. package/dist/esm/types/ui/Conversation/ConversationName.d.ts +0 -2
  264. package/dist/esm/types/ui/Conversation/InputBox/InputBox.d.ts +0 -2
  265. package/dist/esm/types/ui/Conversation/InputBox/InputFilesBox.d.ts +0 -2
  266. package/dist/esm/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +0 -5
  267. package/dist/esm/types/ui/Conversation/InputBox/index.d.ts +0 -14
  268. package/dist/esm/types/ui/Conversation/Message/MessageAuthor.d.ts +0 -3
  269. package/dist/esm/types/ui/Conversation/Message/MessageBox.d.ts +0 -6
  270. package/dist/esm/types/ui/Conversation/Message/MessageContent.d.ts +0 -3
  271. package/dist/esm/types/ui/Conversation/Message/MessageInfoBox.d.ts +0 -3
  272. package/dist/esm/types/ui/Conversation/Message/MessageText.d.ts +0 -3
  273. package/dist/esm/types/ui/Conversation/Message/index.d.ts +0 -20
  274. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +0 -7
  275. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +0 -3
  276. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +0 -3
  277. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +0 -3
  278. package/dist/esm/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +0 -6
  279. package/dist/esm/types/ui/Conversation/SystemMessage/SystemMessageRow.d.ts +0 -9
  280. package/dist/esm/types/ui/Thread/ThreadActions.d.ts +0 -2
  281. package/dist/esm/types/ui/common/Avatar.d.ts +0 -6
  282. package/dist/esm/types/ui/common/Icon.d.ts +0 -20
  283. package/dist/esm/types/ui/common/MessageSkeleton.d.ts +0 -5
  284. package/dist/esm/types/ui/customize.d.ts +0 -9
  285. package/dist/index.d.ts +0 -3005
  286. package/src/core/api/accountApi.ts +0 -11
  287. package/src/core/api/chatApi.ts +0 -87
  288. package/src/core/api/chatListApi.ts +0 -134
  289. package/src/core/api/chatMemberApi.ts +0 -20
  290. package/src/core/api/chatMessageApi.ts +0 -12
  291. package/src/core/api/threadApi.ts +0 -8
  292. package/src/core/api/threadMessageApi.ts +0 -20
  293. package/src/types/core/api/accountApi.d.ts +0 -5
  294. package/src/types/core/api/api.d.ts +0 -2380
  295. package/src/types/core/api/baseApi.d.ts +0 -15
  296. package/src/types/core/api/chatApi.d.ts +0 -16
  297. package/src/types/core/api/chatListApi.d.ts +0 -5
  298. package/src/types/core/api/chatMemberApi.d.ts +0 -6
  299. package/src/types/core/api/chatMessageApi.d.ts +0 -3
  300. package/src/types/core/api/index.d.ts +0 -1
  301. package/src/types/core/api/threadApi.d.ts +0 -1
  302. package/src/types/core/api/threadMessageApi.d.ts +0 -6
  303. package/src/types/core/client.d.ts +0 -83
  304. package/src/types/core/constants.d.ts +0 -1
  305. package/src/types/core/debounce.d.ts +0 -27
  306. package/src/types/core/index.d.ts +0 -4
  307. package/src/types/core/types.d.ts +0 -105
  308. package/src/types/index.d.ts +0 -2
  309. package/src/types/ui/Chat/ChatContext.d.ts +0 -10
  310. package/src/types/ui/Chat/ChatEditableHeaderName.d.ts +0 -2
  311. package/src/types/ui/Chat/ChatHeaderActions.d.ts +0 -2
  312. package/src/types/ui/Chat/ChatPanel.d.ts +0 -13
  313. package/src/types/ui/Chat/ChatView.d.ts +0 -17
  314. package/src/types/ui/Chat/Members/ChatMembersButton.d.ts +0 -2
  315. package/src/types/ui/Chat/Members/ChatMembersPanel.d.ts +0 -2
  316. package/src/types/ui/Chat/Members/ChatMembersPreview.d.ts +0 -2
  317. package/src/types/ui/Chat/Members/index.d.ts +0 -11
  318. package/src/types/ui/Chat/index.d.ts +0 -6
  319. package/src/types/ui/ChatGroup/ChatGroupContext.d.ts +0 -12
  320. package/src/types/ui/ChatGroup/ChatGroupPanel.d.ts +0 -15
  321. package/src/types/ui/ChatGroup/Create/CreateChatButton.d.ts +0 -2
  322. package/src/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +0 -5
  323. package/src/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +0 -5
  324. package/src/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +0 -2
  325. package/src/types/ui/ChatGroup/Create/index.d.ts +0 -17
  326. package/src/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +0 -2
  327. package/src/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +0 -2
  328. package/src/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +0 -2
  329. package/src/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +0 -2
  330. package/src/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +0 -2
  331. package/src/types/ui/ChatGroup/List/ChatList.d.ts +0 -2
  332. package/src/types/ui/ChatGroup/List/ChatListItemAvatar.d.ts +0 -3
  333. package/src/types/ui/ChatGroup/List/ChatListItemBox.d.ts +0 -6
  334. package/src/types/ui/ChatGroup/List/ChatListItemLastMessage.d.ts +0 -3
  335. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageAuthor.d.ts +0 -3
  336. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageContent.d.ts +0 -3
  337. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageSentAt.d.ts +0 -3
  338. package/src/types/ui/ChatGroup/List/ChatListItemName.d.ts +0 -3
  339. package/src/types/ui/ChatGroup/List/ChatListItemUnreadCount.d.ts +0 -3
  340. package/src/types/ui/ChatGroup/index.d.ts +0 -5
  341. package/src/types/ui/Chatify.d.ts +0 -8
  342. package/src/types/ui/Conversation/Conversation.d.ts +0 -21
  343. package/src/types/ui/Conversation/ConversationActions.d.ts +0 -2
  344. package/src/types/ui/Conversation/ConversationBody.d.ts +0 -2
  345. package/src/types/ui/Conversation/ConversationContext.d.ts +0 -20
  346. package/src/types/ui/Conversation/ConversationHeader.d.ts +0 -2
  347. package/src/types/ui/Conversation/ConversationName.d.ts +0 -2
  348. package/src/types/ui/Conversation/InputBox/InputBox.d.ts +0 -2
  349. package/src/types/ui/Conversation/InputBox/InputFilesBox.d.ts +0 -2
  350. package/src/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +0 -5
  351. package/src/types/ui/Conversation/InputBox/InputTextBox.d.ts +0 -8
  352. package/src/types/ui/Conversation/Message/MessageAuthor.d.ts +0 -3
  353. package/src/types/ui/Conversation/Message/MessageBox.d.ts +0 -6
  354. package/src/types/ui/Conversation/Message/MessageContent.d.ts +0 -3
  355. package/src/types/ui/Conversation/Message/MessageInfoBox.d.ts +0 -3
  356. package/src/types/ui/Conversation/Message/MessageRow.d.ts +0 -6
  357. package/src/types/ui/Conversation/Message/MessageText.d.ts +0 -3
  358. package/src/types/ui/Conversation/NextObserver/NextMessagesObserver.d.ts +0 -5
  359. package/src/types/ui/Conversation/NextObserver/index.d.ts +0 -1
  360. package/src/types/ui/Conversation/ReadObserver/MessageReadObserver.d.ts +0 -6
  361. package/src/types/ui/Conversation/ReadObserver/index.d.ts +0 -1
  362. package/src/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +0 -7
  363. package/src/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +0 -3
  364. package/src/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +0 -3
  365. package/src/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +0 -3
  366. package/src/types/ui/Conversation/SendingMessage/index.d.ts +0 -14
  367. package/src/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +0 -6
  368. package/src/types/ui/Conversation/SystemMessage/index.d.ts +0 -8
  369. package/src/types/ui/Conversation/index.d.ts +0 -12
  370. package/src/types/ui/Thread/ThreadActions.d.ts +0 -2
  371. package/src/types/ui/Thread/ThreadContext.d.ts +0 -8
  372. package/src/types/ui/Thread/ThreadPanel.d.ts +0 -14
  373. package/src/types/ui/Thread/index.d.ts +0 -3
  374. package/src/types/ui/color.d.ts +0 -6
  375. package/src/types/ui/common/Avatar.d.ts +0 -6
  376. package/src/types/ui/common/Icon.d.ts +0 -20
  377. package/src/types/ui/common/MessageSkeleton.d.ts +0 -5
  378. package/src/types/ui/common/index.d.ts +0 -11
  379. package/src/types/ui/index.d.ts +0 -11
  380. package/src/types/ui/localizer.d.ts +0 -35
  381. package/src/ui/ChatGroup/List/ChatList.tsx +0 -42
  382. /package/dist/{esm/types → types}/core/api/index.d.ts +0 -0
  383. /package/dist/{esm/types → types}/core/constants.d.ts +0 -0
  384. /package/dist/{esm/types → types}/core/debounce.d.ts +0 -0
  385. /package/dist/{esm/types → types}/core/index.d.ts +0 -0
  386. /package/dist/{esm/types → types}/index.d.ts +0 -0
  387. /package/dist/{esm/types → types}/ui/Chat/ChatContext.d.ts +0 -0
  388. /package/dist/{esm/types → types}/ui/Chat/ChatPanel.d.ts +0 -0
  389. /package/dist/{esm/types → types}/ui/Chat/Members/index.d.ts +0 -0
  390. /package/dist/{esm/types → types}/ui/Chat/index.d.ts +0 -0
  391. /package/dist/{esm/types → types}/ui/ChatGroup/Create/index.d.ts +0 -0
  392. /package/dist/{esm/types → types}/ui/Conversation/NextObserver/NextMessagesObserver.d.ts +0 -0
  393. /package/dist/{esm/types → types}/ui/Conversation/NextObserver/index.d.ts +0 -0
  394. /package/dist/{esm/types → types}/ui/Conversation/ReadObserver/MessageReadObserver.d.ts +0 -0
  395. /package/dist/{esm/types → types}/ui/Conversation/ReadObserver/index.d.ts +0 -0
  396. /package/dist/{esm/types → types}/ui/Conversation/SendingMessage/index.d.ts +0 -0
  397. /package/dist/{esm/types → types}/ui/Conversation/SystemMessage/index.d.ts +0 -0
  398. /package/dist/{esm/types → types}/ui/Conversation/index.d.ts +0 -0
  399. /package/dist/{esm/types → types}/ui/Thread/ThreadPanel.d.ts +0 -0
  400. /package/dist/{esm/types → types}/ui/Thread/index.d.ts +0 -0
  401. /package/dist/{esm/types → types}/ui/color.d.ts +0 -0
@@ -0,0 +1,2396 @@
1
+ import './Chatify.css';var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
+ import { Button, Avatar as Avatar$1, List, Space, Tooltip, Input, Skeleton, Menu, Row, Col, Form, DatePicker, Checkbox } from "antd";
6
+ import React, { useContext, useState, useMemo, forwardRef, useCallback, useRef, useEffect, memo, useLayoutEffect } from "react";
7
+ import { SettingOutlined, DownloadOutlined, DeleteOutlined, EyeInvisibleOutlined, EyeOutlined, TeamOutlined, CloseOutlined, EditOutlined, UsergroupAddOutlined, UserAddOutlined, UsergroupDeleteOutlined, UserDeleteOutlined, SendOutlined, PaperClipOutlined } from "@ant-design/icons";
8
+ import { createApi, fakeBaseQuery } from "@reduxjs/toolkit/query/react";
9
+ import { useSelector } from "react-redux";
10
+ import * as SignalR from "@microsoft/signalr";
11
+ import { isHotkey } from "is-hotkey";
12
+ import dayjs from "dayjs";
13
+ const DEFAULT_COLOR_OPTIONS = {
14
+ saturation: 100,
15
+ lightness: 75
16
+ };
17
+ function color(value, options = {}) {
18
+ options = Object.assign({}, DEFAULT_COLOR_OPTIONS, options);
19
+ let hash = 0;
20
+ for (let i = 0; i < value.length; i++) {
21
+ hash = value.charCodeAt(i) + ((hash << 5) - hash);
22
+ hash = hash & hash;
23
+ }
24
+ return `hsl(${hash % 360}, ${options.saturation}%, ${options.lightness}%)`;
25
+ }
26
+ const CustomizeContext = React.createContext(null);
27
+ function useCustomizeContext() {
28
+ return useContext(CustomizeContext);
29
+ }
30
+ function useCustom(key) {
31
+ const value = useContext(CustomizeContext);
32
+ return value ? value[key] : void 0;
33
+ }
34
+ function useCustomize(custom) {
35
+ const Custom = useCustom(custom.key);
36
+ if (Custom == null) {
37
+ return null;
38
+ }
39
+ return Custom ?? custom.Component;
40
+ }
41
+ function customize(key, Component) {
42
+ const Result = React.forwardRef((props, forwardRef2) => {
43
+ const Custom = useCustom(key);
44
+ if (Custom === null) {
45
+ return null;
46
+ }
47
+ if (Custom) {
48
+ return /* @__PURE__ */ jsx(Custom, { ...props, ref: forwardRef2 });
49
+ }
50
+ return /* @__PURE__ */ jsx(Component, { ...props, ref: forwardRef2 });
51
+ });
52
+ Component.displayName = Component.displayName || key;
53
+ Result.displayName = "Customizable." + Component.displayName;
54
+ return Object.assign(Result, { key, Component });
55
+ }
56
+ const ICONS = {
57
+ attach: PaperClipOutlined,
58
+ send: SendOutlined,
59
+ "remove-member": UserDeleteOutlined,
60
+ "remove-member-delete-history": UsergroupDeleteOutlined,
61
+ "add-member": UserAddOutlined,
62
+ "add-member-with-history": UsergroupAddOutlined,
63
+ members: TeamOutlined,
64
+ edit: EditOutlined,
65
+ close: CloseOutlined,
66
+ chat: TeamOutlined,
67
+ watch: EyeOutlined,
68
+ unwatch: EyeInvisibleOutlined,
69
+ "delete-file": DeleteOutlined,
70
+ "open-file": DownloadOutlined,
71
+ settings: SettingOutlined
72
+ };
73
+ const Icon = customize("Icon", (props) => {
74
+ const { type } = props;
75
+ const IconComponent = ICONS[type];
76
+ return IconComponent ? /* @__PURE__ */ jsx(IconComponent, {}) : null;
77
+ });
78
+ const ChatReactContext = React.createContext(null);
79
+ function useChatContext() {
80
+ return useContext(ChatReactContext);
81
+ }
82
+ function ChatContext(props) {
83
+ const { id, children } = props;
84
+ const [showMembers, onShowMembers] = useState(false);
85
+ const value = useMemo(
86
+ () => ({
87
+ id,
88
+ showMembers,
89
+ onShowMembers
90
+ }),
91
+ [id, showMembers]
92
+ );
93
+ return /* @__PURE__ */ jsx(ChatReactContext.Provider, { value, children });
94
+ }
95
+ const ChatMembersButton = customize("ChatMembersButton", () => {
96
+ const { showMembers, onShowMembers } = useChatContext();
97
+ return /* @__PURE__ */ jsx(Button, { onClick: () => onShowMembers(!showMembers), type: "link", icon: /* @__PURE__ */ jsx(Icon, { type: "members" }) });
98
+ });
99
+ const SYSTEM_ID = "chatify::system";
100
+ function chatId(messageId) {
101
+ return messageId.slice(0, 36);
102
+ }
103
+ function messageSequencePart(id) {
104
+ return id.slice(37);
105
+ }
106
+ function parseThreadMessageId(messageId) {
107
+ const [threadId, index] = messageId.split("::", 2);
108
+ return [threadId, parseInt(index, 10)];
109
+ }
110
+ function calcThreadUnreadCount(thread) {
111
+ var _a, _b;
112
+ const lastReadMessageIndex = thread.lastReadMessageId != null ? parseThreadMessageId(thread.lastReadMessageId)[1] : -1;
113
+ const lastThreadMessageIndex = ((_a = thread.lastMessage) == null ? void 0 : _a.id) != null ? parseThreadMessageId((_b = thread.lastMessage) == null ? void 0 : _b.id)[1] : -1;
114
+ return lastThreadMessageIndex - lastReadMessageIndex;
115
+ }
116
+ function calcThreadListUnreadCount(threads) {
117
+ return threads.reduce((prev, thread) => {
118
+ return prev + calcThreadUnreadCount(thread);
119
+ }, 0);
120
+ }
121
+ class Debounce {
122
+ constructor(config) {
123
+ __publicField(this, "_enqueued", []);
124
+ __publicField(this, "_processing", []);
125
+ __publicField(this, "_timeoutByGroup", {});
126
+ __publicField(this, "_subscribers", []);
127
+ __publicField(this, "subscribe", (callback) => {
128
+ this._subscribers.push(callback);
129
+ return () => {
130
+ this._subscribers = this._subscribers.filter((x) => x !== callback);
131
+ };
132
+ });
133
+ __publicField(this, "notify", () => {
134
+ this._subscribers.forEach((subscriber) => subscriber(this));
135
+ });
136
+ this.config = config;
137
+ }
138
+ get units() {
139
+ return [
140
+ ...this._enqueued.map((x) => ({ ...x, state: "enqueued" })),
141
+ ...this._processing.map((x) => ({ ...x, state: "processing" }))
142
+ ];
143
+ }
144
+ push(value) {
145
+ const group = this.config.groupBy(value);
146
+ const unit = this._enqueued.find((unit2) => this.config.groupBy(unit2.value) === group);
147
+ if (!unit) {
148
+ this._enqueued.push({ value, enqueueTime: Date.now() });
149
+ } else if (this.config.compare(unit.value, value) >= 0) {
150
+ unit.value = value;
151
+ unit.enqueueTime = Date.now();
152
+ }
153
+ this._process(group);
154
+ }
155
+ _process(group) {
156
+ if (!this._enqueued.some((unit) => this.config.groupBy(unit.value) === group)) {
157
+ return;
158
+ }
159
+ let timeout = this._timeoutByGroup[group];
160
+ timeout && clearTimeout(timeout);
161
+ if (this._processing.some((unit) => this.config.groupBy(unit.value) === group)) {
162
+ return;
163
+ }
164
+ timeout = setTimeout(() => {
165
+ const processing = this._enqueued.find((unit) => this.config.groupBy(unit.value) === group);
166
+ this._processing.push(processing);
167
+ this._enqueued.splice(this._enqueued.indexOf(processing), 1);
168
+ this.notify();
169
+ this.config.callback(processing.value).then(() => {
170
+ this._processing.splice(this._processing.indexOf(processing), 1);
171
+ this.notify();
172
+ this._process(group);
173
+ }).catch(() => {
174
+ this._processing.splice(this._processing.indexOf(processing), 1);
175
+ this.push(processing.value);
176
+ });
177
+ }, this.config.timeout);
178
+ this._timeoutByGroup[group] = timeout;
179
+ }
180
+ }
181
+ const DEFAULT_MESSAGE_LIST_TAKE = 20;
182
+ const __settings = {
183
+ me: null,
184
+ client: null
185
+ };
186
+ const TAG_TYPES = ["chat", "account", "message", "thread", "thread-message"];
187
+ const baseApi = createApi({
188
+ baseQuery: fakeBaseQuery(),
189
+ reducerPath: "chatify",
190
+ tagTypes: TAG_TYPES,
191
+ endpoints: (_) => ({})
192
+ });
193
+ const __baseApi = baseApi;
194
+ const DEFAULT_SIGNALR_CONFIG = {
195
+ hubUri: "/api/chatify/hub",
196
+ headersFactory: () => Promise.resolve({})
197
+ };
198
+ const CHATIFY_SIGNALR_METHODS = [
199
+ "chatify://chat-new-message",
200
+ "chatify://chat-created",
201
+ "chatify://chat-message-read",
202
+ "chatify://chat-member-added",
203
+ "chatify://chat-member-removed",
204
+ "chatify://chat-name-changed",
205
+ "chatify://thread-created",
206
+ "chatify://thread-message-new",
207
+ "chatify://thread-message-read",
208
+ "chatify://thread-watch-added",
209
+ "chatify://thread-watch-removed",
210
+ "chatify://thread-updated"
211
+ ];
212
+ class ChatifyClient {
213
+ constructor(config) {
214
+ __publicField(this, "_config");
215
+ __publicField(this, "_connection", null);
216
+ __publicField(this, "_connectionPromise", null);
217
+ __publicField(this, "_subscribers", {});
218
+ __publicField(this, "_reconnectSubscribers", []);
219
+ __publicField(this, "_threadConnectionByThreadId", /* @__PURE__ */ new Map());
220
+ __publicField(this, "connect", async () => {
221
+ if (this._connection) {
222
+ return;
223
+ }
224
+ if (this._connectionPromise) {
225
+ return await this._connectionPromise;
226
+ }
227
+ this._connectionPromise = this.createAndStartConnection();
228
+ this._connection = await this._connectionPromise;
229
+ });
230
+ __publicField(this, "createAndStartConnection", async () => {
231
+ const headers = await this._config.signalR.headersFactory();
232
+ const connection = new SignalR.HubConnectionBuilder().withUrl(this._config.signalR.hubUri, {
233
+ accessTokenFactory: this._config.signalR.accessTokenFactory ? this._config.signalR.accessTokenFactory : void 0,
234
+ headers
235
+ }).withAutomaticReconnect().build();
236
+ CHATIFY_SIGNALR_METHODS.forEach((x) => {
237
+ connection.on(x, (...args) => {
238
+ var _a;
239
+ (_a = this._subscribers[x]) == null ? void 0 : _a.forEach((s) => {
240
+ try {
241
+ s(args);
242
+ } catch (ex) {
243
+ console.error(`Failed to notify subscriber`, ex);
244
+ }
245
+ });
246
+ });
247
+ });
248
+ connection.onreconnected(() => this._reconnectSubscribers.forEach((subscriber) => subscriber()));
249
+ await connection.start();
250
+ return connection;
251
+ });
252
+ __publicField(this, "subscribe", (method, subscriber) => {
253
+ this.connect().then(() => {
254
+ this._subscribers[method] = this._subscribers[method] ?? [];
255
+ this._subscribers[method].push(subscriber);
256
+ });
257
+ return () => this._subscribers[method].filter((x) => x !== subscriber);
258
+ });
259
+ __publicField(this, "subscribeReconnect", (subscriber) => {
260
+ this._reconnectSubscribers.push(subscriber);
261
+ return () => this._reconnectSubscribers.filter((x) => x !== subscriber);
262
+ });
263
+ __publicField(this, "accounts", async (args) => {
264
+ var _a;
265
+ const searchParams = new URLSearchParams();
266
+ (_a = args == null ? void 0 : args.ids) == null ? void 0 : _a.forEach((id) => {
267
+ searchParams.append("ids", encodeURIComponent(id));
268
+ });
269
+ const { data } = await this.axios.get(`account?${searchParams.toString()}`);
270
+ return data;
271
+ });
272
+ __publicField(this, "currentUserAccount", async () => {
273
+ const { data } = await this.axios.get("account/me");
274
+ return data;
275
+ });
276
+ __publicField(this, "updateAccount", async (request) => {
277
+ await this.axios.put(`account/${encodeURIComponent(request.id)}`, request);
278
+ });
279
+ __publicField(this, "chats", async () => {
280
+ const { data } = await this.axios.get("chat");
281
+ return data;
282
+ });
283
+ __publicField(this, "chat", async (id) => {
284
+ const { data } = await this.axios.get(`chat/${encodeURIComponent(id)}`);
285
+ return data;
286
+ });
287
+ __publicField(this, "addChat", async (args) => {
288
+ const { data } = await this.axios.post(`chat`, args);
289
+ return data;
290
+ });
291
+ __publicField(this, "chatMessages", async (args) => {
292
+ const { chatId: chatId2, skip = 0, take = 20 } = args;
293
+ const pagingRule = encodeURIComponent(JSON.stringify({ skip, take }));
294
+ const { data } = await this.axios.get(
295
+ `chat/${encodeURIComponent(chatId2)}/message?pagingRule=${pagingRule}`
296
+ );
297
+ return data;
298
+ });
299
+ __publicField(this, "sendChatMessage", async (request) => {
300
+ const { chatId: chatId2, ...rest } = request;
301
+ await this.axios.post(`chat/${encodeURIComponent(chatId2)}/message`, rest);
302
+ });
303
+ __publicField(this, "readChatMessage", async (request) => {
304
+ await this.axios.put(`chat/message/read`, request);
305
+ });
306
+ __publicField(this, "removeChatMember", async (request) => {
307
+ await this.axios.delete(`chat/${encodeURIComponent(request.chatId)}/member`, { data: request });
308
+ });
309
+ __publicField(this, "updateChatName", async (request) => {
310
+ await this.axios.put(`chat/${encodeURIComponent(request.id)}/name`, request);
311
+ });
312
+ __publicField(this, "addChatMember", async (request) => {
313
+ await this.axios.post(`chat/${encodeURIComponent(request.chatId)}/member`, request);
314
+ });
315
+ __publicField(this, "sendThreadMessage", async ({ body, threadId }) => {
316
+ const { data: id } = await this.axios.post(`thread/${encodeURIComponent(threadId)}/message`, {
317
+ body
318
+ });
319
+ return id;
320
+ });
321
+ __publicField(this, "readThreadMessage", async (id) => {
322
+ await this.axios.put(`thread/message/${encodeURIComponent(id)}/read`);
323
+ });
324
+ __publicField(this, "watchThreads", async () => {
325
+ const { data } = await this.axios.get(`thread/watch`);
326
+ return data;
327
+ });
328
+ __publicField(this, "thread", async (id) => {
329
+ const { data } = await this.axios.get(`thread/${encodeURIComponent(id)}`);
330
+ return data;
331
+ });
332
+ __publicField(this, "threadMessages", async ({
333
+ threadId,
334
+ skip,
335
+ take
336
+ }) => {
337
+ const searchParams = new URLSearchParams();
338
+ searchParams.append("skip", skip.toString());
339
+ searchParams.append("take", take.toString());
340
+ const { data } = await this.axios.get(
341
+ `thread/${encodeURIComponent(threadId)}/message?${searchParams.toString()}`
342
+ );
343
+ return data;
344
+ });
345
+ __publicField(this, "watchThread", async (id, watch) => {
346
+ await this.axios.put(`thread/${encodeURIComponent(id)}/watch`, { watch });
347
+ });
348
+ __publicField(this, "connectToThread", async (id) => {
349
+ const connectionCount = this._threadConnectionByThreadId.get(id) ?? 0;
350
+ this._threadConnectionByThreadId.set(id, connectionCount + 1);
351
+ if (connectionCount === 0) {
352
+ this.connect().then(() => this._connection.invoke("ConnectToThread", id));
353
+ }
354
+ });
355
+ __publicField(this, "disconnectFromThread", async (id) => {
356
+ const connectionCount = this._threadConnectionByThreadId.get(id) ?? 0;
357
+ this._threadConnectionByThreadId.set(id, Math.max(0, connectionCount - 1));
358
+ if (connectionCount === 1) {
359
+ this.connect().then(() => this._connection.invoke("DisconnectFromThread", id));
360
+ }
361
+ });
362
+ this._config = {
363
+ ...config,
364
+ signalR: {
365
+ ...DEFAULT_SIGNALR_CONFIG,
366
+ ...config.signalR
367
+ }
368
+ };
369
+ }
370
+ get axios() {
371
+ return this._config.axios;
372
+ }
373
+ }
374
+ function unsubscribe(...subscribers) {
375
+ const result = () => subscribers.forEach((x) => x());
376
+ result.when = (promise) => promise.then(result);
377
+ return result;
378
+ }
379
+ const THREAD_MESSAGE_READ_QUEUE = new Debounce({
380
+ callback: (id) => __settings.client.readThreadMessage(id),
381
+ compare: (a, b) => -a.localeCompare(b),
382
+ groupBy: (id) => parseThreadMessageId(id)[0],
383
+ timeout: 500
384
+ });
385
+ const CHAT_MESSAGE_READ_QUEUE = new Debounce({
386
+ callback: (id) => __settings.client.readChatMessage({ id }),
387
+ compare: (a, b) => -a.localeCompare(b),
388
+ groupBy: (id) => chatId(id),
389
+ timeout: 500
390
+ });
391
+ const __chatifyApi = __baseApi.injectEndpoints({
392
+ endpoints: (builder) => ({
393
+ // ====================================================
394
+ // ============== ACCOUNT ======================
395
+ // ====================================================
396
+ getAccountList: builder.query({
397
+ queryFn: async (args) => ({ data: await __settings.client.accounts(args) }),
398
+ providesTags: ["account"]
399
+ }),
400
+ geCurrentUserAccount: builder.query({
401
+ queryFn: async () => ({ data: await __settings.client.currentUserAccount() }),
402
+ providesTags: ["account"]
403
+ }),
404
+ updateAccount: builder.mutation({
405
+ queryFn: async (request) => {
406
+ await __settings.client.updateAccount(request);
407
+ return { data: null };
408
+ },
409
+ invalidatesTags: ["account"]
410
+ }),
411
+ // ====================================================
412
+ // ================ CHAT =======================
413
+ // ====================================================
414
+ getChat: builder.query({
415
+ queryFn: async ({ id }) => ({ data: await __settings.client.chat(id) }),
416
+ providesTags: ["chat", "account"],
417
+ onCacheEntryAdded: async ({ id }, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
418
+ await cacheDataLoaded;
419
+ unsubscribe(
420
+ __settings.client.subscribe(
421
+ "chatify://chat-member-added",
422
+ ([chatId2, _, account, message, , read]) => chatId2 === id && updateCachedData((chat) => {
423
+ chat.members.push(account);
424
+ chat.lastReadMessageId = read ? message.id : chat.lastReadMessageId;
425
+ })
426
+ ),
427
+ __settings.client.subscribe(
428
+ "chatify://chat-member-removed",
429
+ ([chatId2, accountId, , message, read]) => id === chatId2 && updateCachedData((chat) => {
430
+ chat.members = chat.members.filter((x) => x.id !== accountId);
431
+ chat.lastReadMessageId = read ? message.id : chat.lastReadMessageId;
432
+ })
433
+ ),
434
+ __settings.client.subscribe(
435
+ "chatify://chat-name-changed",
436
+ ([chatId2, newName, message, read]) => id === chatId2 && updateCachedData((chat) => {
437
+ chat.name = newName;
438
+ chat.lastReadMessageId = read ? message.id : chat.lastReadMessageId;
439
+ })
440
+ ),
441
+ __settings.client.subscribe(
442
+ "chatify://chat-new-message",
443
+ ([message]) => id === message.chatId && updateCachedData((chat) => {
444
+ chat.lastReadMessageId = message.sentBy.id === __settings.me() ? message.id : chat.lastReadMessageId;
445
+ })
446
+ ),
447
+ __settings.client.subscribe(
448
+ "chatify://chat-message-read",
449
+ ([events]) => events.find((x) => x.chatId === id) && updateCachedData((chat) => {
450
+ const event = events.find((x) => x.chatId === id);
451
+ chat.lastReadMessageId = event.newLastReadMessageId;
452
+ })
453
+ )
454
+ ).when(cacheEntryRemoved);
455
+ }
456
+ }),
457
+ addChat: builder.mutation({
458
+ queryFn: async ({ name, members }) => {
459
+ const chatId2 = await __settings.client.addChat({
460
+ name,
461
+ members
462
+ });
463
+ return { data: chatId2 };
464
+ }
465
+ }),
466
+ updateChatName: builder.mutation({
467
+ queryFn: async ({ id, name }) => {
468
+ await __settings.client.updateChatName({ id, name });
469
+ return { data: null };
470
+ }
471
+ }),
472
+ // ====================================================
473
+ // ============= CHAT LIST =====================
474
+ // ====================================================
475
+ getChatList: builder.query({
476
+ queryFn: async () => ({ data: await __settings.client.chats() }),
477
+ providesTags: ["chat", "account"],
478
+ onCacheEntryAdded: async (_, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
479
+ await cacheDataLoaded;
480
+ unsubscribe(
481
+ __settings.client.subscribe(
482
+ "chatify://chat-created",
483
+ ([chat]) => updateCachedData((chatList) => {
484
+ chatList.push(chat);
485
+ })
486
+ ),
487
+ __settings.client.subscribe(
488
+ "chatify://chat-new-message",
489
+ ([message]) => updateCachedData((chatList) => {
490
+ const chat = chatList.find((x) => x.id === message.chatId);
491
+ if (!chat) {
492
+ return;
493
+ }
494
+ chat.message = message;
495
+ if (message.sentBy.id === __settings.me()) {
496
+ chat.lastReadMessageId = message.id;
497
+ chat.totalUnreadCount = 0;
498
+ }
499
+ if (message.sentBy.id !== __settings.me()) {
500
+ chat.totalUnreadCount++;
501
+ }
502
+ })
503
+ ),
504
+ __settings.client.subscribe(
505
+ "chatify://chat-message-read",
506
+ ([events]) => updateCachedData((chatList) => {
507
+ for (const event of events) {
508
+ const chat = chatList.find((x) => x.id === event.chatId);
509
+ if (!chat) {
510
+ return;
511
+ }
512
+ chat.lastReadMessageId = event.newLastReadMessageId;
513
+ chat.totalUnreadCount = chat.totalUnreadCount - event.readCount;
514
+ }
515
+ })
516
+ ),
517
+ __settings.client.subscribe(
518
+ "chatify://chat-member-added",
519
+ ([chatId2, chatName, account, message, , read]) => updateCachedData((chatList) => {
520
+ const chat = chatList.find((x) => x.id === chatId2);
521
+ if (account.id === __settings.me() && !chat) {
522
+ chatList.push({
523
+ id: chatId2,
524
+ name: chatName,
525
+ message,
526
+ totalUnreadCount: read ? 0 : 1,
527
+ active: true,
528
+ lastReadMessageId: read ? message.id : null
529
+ });
530
+ }
531
+ if (!chat) {
532
+ return;
533
+ }
534
+ chat.message = message;
535
+ chat.active = true;
536
+ if (read) {
537
+ chat.totalUnreadCount = 0;
538
+ chat.lastReadMessageId = message.id;
539
+ } else {
540
+ chat.totalUnreadCount++;
541
+ }
542
+ })
543
+ ),
544
+ __settings.client.subscribe(
545
+ "chatify://chat-member-removed",
546
+ ([chatId2, accountId, deleteHistory, message, read]) => updateCachedData((chatList) => {
547
+ if (accountId === __settings.me() && deleteHistory) {
548
+ return chatList.filter((x) => x.id !== chatId2);
549
+ }
550
+ const chat = chatList.find((x) => x.id === chatId2);
551
+ if (!chat) {
552
+ return;
553
+ }
554
+ chat.message = message;
555
+ if (accountId === __settings.me()) {
556
+ chat.active = false;
557
+ }
558
+ if (!read) {
559
+ chat.totalUnreadCount++;
560
+ } else {
561
+ chat.totalUnreadCount = 0;
562
+ chat.lastReadMessageId = message.id;
563
+ }
564
+ })
565
+ ),
566
+ __settings.client.subscribe(
567
+ "chatify://chat-name-changed",
568
+ ([chatId2, newName, message, read]) => updateCachedData((chatList) => {
569
+ const chat = chatList.find((x) => x.id === chatId2);
570
+ if (!chat) return;
571
+ chat.name = newName;
572
+ chat.message = message;
573
+ if (!read) {
574
+ chat.totalUnreadCount++;
575
+ } else {
576
+ chat.totalUnreadCount = 0;
577
+ chat.lastReadMessageId = message.id;
578
+ }
579
+ })
580
+ )
581
+ ).when(cacheEntryRemoved);
582
+ }
583
+ }),
584
+ // ====================================================
585
+ // ============ CHAT MEMBER ====================
586
+ // ====================================================
587
+ removeChatMember: builder.mutation({
588
+ queryFn: async (args) => {
589
+ await __settings.client.removeChatMember(args);
590
+ return { data: null };
591
+ }
592
+ }),
593
+ addChatMember: builder.mutation({
594
+ queryFn: async (args) => {
595
+ await __settings.client.addChatMember(args);
596
+ return { data: null };
597
+ }
598
+ }),
599
+ // ====================================================
600
+ // ============ CHAT MESSAGE ===================
601
+ // ====================================================
602
+ getChatMessageList: builder.query({
603
+ queryFn: async ({ chatId: chatId2 }) => {
604
+ const messages = await __settings.client.chatMessages({
605
+ chatId: chatId2,
606
+ skip: 0,
607
+ take: DEFAULT_MESSAGE_LIST_TAKE + 1
608
+ });
609
+ return {
610
+ data: {
611
+ messages: messages.slice(0, DEFAULT_MESSAGE_LIST_TAKE),
612
+ hasMore: messages.length === DEFAULT_MESSAGE_LIST_TAKE + 1
613
+ }
614
+ };
615
+ },
616
+ providesTags: ["message", "chat", "account"],
617
+ onCacheEntryAdded: async ({ chatId: chatId2 }, { dispatch, cacheEntryRemoved, cacheDataLoaded }) => {
618
+ await cacheDataLoaded;
619
+ unsubscribe(
620
+ __settings.client.subscribe("chatify://chat-new-message", ([message]) => {
621
+ message.chatId === chatId2 && dispatch(
622
+ chatifyApi.util.updateQueryData("getChatMessageList", { chatId: chatId2 }, (draft) => {
623
+ draft.messages.unshift(message);
624
+ })
625
+ );
626
+ }),
627
+ __settings.client.subscribe("chatify://chat-member-added", ([eventChatId, , , message]) => {
628
+ eventChatId === chatId2 && dispatch(
629
+ chatifyApi.util.updateQueryData("getChatMessageList", { chatId: chatId2 }, (draft) => {
630
+ draft.messages.unshift(message);
631
+ })
632
+ );
633
+ }),
634
+ __settings.client.subscribe("chatify://chat-member-removed", ([eventChatId, , , message]) => {
635
+ eventChatId === chatId2 && dispatch(
636
+ chatifyApi.util.updateQueryData("getChatMessageList", { chatId: chatId2 }, (draft) => {
637
+ draft.messages.unshift(message);
638
+ })
639
+ );
640
+ }),
641
+ __settings.client.subscribe("chatify://chat-name-changed", ([eventChatId, , message]) => {
642
+ eventChatId === chatId2 && dispatch(
643
+ chatifyApi.util.updateQueryData("getChatMessageList", { chatId: chatId2 }, (draft) => {
644
+ draft.messages.unshift(message);
645
+ })
646
+ );
647
+ })
648
+ ).when(cacheEntryRemoved);
649
+ }
650
+ }),
651
+ fetchNextChatMessageList: builder.mutation({
652
+ queryFn: async ({ chatId: chatId2 }, { getState }) => {
653
+ const current = chatifyApi.endpoints.getChatMessageList.select({ chatId: chatId2 })(getState());
654
+ const messages = await __settings.client.chatMessages({
655
+ chatId: chatId2,
656
+ skip: current.data.messages.length,
657
+ take: DEFAULT_MESSAGE_LIST_TAKE + 1
658
+ });
659
+ return {
660
+ data: null,
661
+ meta: {
662
+ messages: messages.slice(0, DEFAULT_MESSAGE_LIST_TAKE),
663
+ hasMore: messages.length === DEFAULT_MESSAGE_LIST_TAKE + 1
664
+ }
665
+ };
666
+ },
667
+ onQueryStarted: async ({ chatId: chatId2 }, { dispatch, queryFulfilled }) => {
668
+ const result = await queryFulfilled;
669
+ const meta = result.meta;
670
+ dispatch(
671
+ chatifyApi.util.updateQueryData("getChatMessageList", { chatId: chatId2 }, (draft) => {
672
+ draft.hasMore = meta.hasMore;
673
+ draft.messages.push(...meta.messages);
674
+ })
675
+ );
676
+ }
677
+ }),
678
+ sendChatMessage: builder.mutation({
679
+ queryFn: async ({ chatId: chatId2, text, files }) => {
680
+ await __settings.client.sendChatMessage({
681
+ chatId: chatId2,
682
+ text,
683
+ files
684
+ });
685
+ return { data: null };
686
+ }
687
+ }),
688
+ readChatMessage: builder.mutation({
689
+ queryFn: async () => {
690
+ return { data: null };
691
+ },
692
+ onQueryStarted: async ({ id }, { dispatch }) => {
693
+ CHAT_MESSAGE_READ_QUEUE.push(id);
694
+ dispatch(chatifyApi.endpoints.getChatMessageReadQueue.initiate(void 0, { forceRefetch: true }));
695
+ }
696
+ }),
697
+ getChatMessageReadQueue: builder.query({
698
+ queryFn: async () => ({ data: CHAT_MESSAGE_READ_QUEUE.units }),
699
+ onCacheEntryAdded: async (_, { dispatch, cacheEntryRemoved }) => {
700
+ unsubscribe(
701
+ CHAT_MESSAGE_READ_QUEUE.subscribe((value) => {
702
+ dispatch(
703
+ chatifyApi.util.updateQueryData("getChatMessageReadQueue", void 0, () => value.units)
704
+ );
705
+ })
706
+ ).when(cacheEntryRemoved);
707
+ }
708
+ }),
709
+ // ====================================================
710
+ // =============== THREAD ======================s
711
+ // ====================================================
712
+ getWatchThreadList: builder.query({
713
+ queryFn: async () => {
714
+ const threads = await __settings.client.watchThreads();
715
+ return { data: threads };
716
+ },
717
+ providesTags: ["account", "thread"],
718
+ onCacheEntryAdded: async (_, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
719
+ await cacheDataLoaded;
720
+ unsubscribe(
721
+ __settings.client.subscribe(
722
+ "chatify://thread-created",
723
+ ([thread, watch]) => watch && updateCachedData((threads) => {
724
+ threads.push(thread);
725
+ })
726
+ ),
727
+ __settings.client.subscribe(
728
+ "chatify://thread-message-new",
729
+ ([threadId, message, readForId]) => updateCachedData((threads) => {
730
+ const thread = threads.find((x) => x.id === threadId);
731
+ if (!thread) return;
732
+ thread.lastMessage = message;
733
+ if (readForId === __settings.me()) {
734
+ thread.lastReadMessageId = message.id;
735
+ }
736
+ })
737
+ ),
738
+ __settings.client.subscribe(
739
+ "chatify://thread-message-read",
740
+ ([threadId, messageId]) => updateCachedData((threads) => {
741
+ const thread = threads.find((x) => x.id === threadId);
742
+ if (!thread) return;
743
+ thread.lastReadMessageId = messageId;
744
+ })
745
+ ),
746
+ __settings.client.subscribe(
747
+ "chatify://thread-watch-added",
748
+ ([thread]) => updateCachedData((threads) => {
749
+ threads.push(thread);
750
+ })
751
+ ),
752
+ __settings.client.subscribe(
753
+ "chatify://thread-watch-removed",
754
+ ([id]) => updateCachedData((threads) => {
755
+ const index = threads.findIndex((x) => x.id === id);
756
+ if (index !== -1) threads.splice(index, 1);
757
+ })
758
+ ),
759
+ __settings.client.subscribe(
760
+ "chatify://thread-updated",
761
+ ([threadId, threadName]) => updateCachedData((threads) => {
762
+ const thread = threads.find((x) => x.id === threadId);
763
+ if (!thread) return;
764
+ thread.name = threadName;
765
+ })
766
+ )
767
+ ).when(cacheEntryRemoved);
768
+ }
769
+ }),
770
+ getThread: builder.query({
771
+ queryFn: async ({ id }) => {
772
+ const threads = await __settings.client.thread(id);
773
+ return { data: threads };
774
+ },
775
+ providesTags: ["account", "thread"],
776
+ onCacheEntryAdded: async ({ id }, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
777
+ await cacheDataLoaded;
778
+ unsubscribe(
779
+ __settings.client.subscribe(
780
+ "chatify://thread-message-read",
781
+ ([threadId, messageId]) => id === threadId && updateCachedData((t) => {
782
+ t.lastReadMessageId = messageId;
783
+ })
784
+ ),
785
+ __settings.client.subscribe(
786
+ "chatify://thread-message-new",
787
+ ([threadId, message, readForId]) => id === threadId && updateCachedData((thread) => {
788
+ thread.lastMessageId = message.id;
789
+ thread.lastReadMessageId = readForId === __settings.me() ? message.id : thread.lastReadMessageId;
790
+ })
791
+ ),
792
+ __settings.client.subscribe(
793
+ "chatify://thread-watch-added",
794
+ ([threadListItem]) => id === threadListItem.id && updateCachedData((thread) => {
795
+ var _a;
796
+ thread.watch = true;
797
+ thread.lastMessageId = ((_a = threadListItem.lastMessage) == null ? void 0 : _a.id) ?? null;
798
+ thread.lastReadMessageId = threadListItem.lastReadMessageId ?? null;
799
+ })
800
+ ),
801
+ __settings.client.subscribe(
802
+ "chatify://thread-watch-removed",
803
+ ([threadId]) => id === threadId && updateCachedData((thread) => {
804
+ thread.watch = false;
805
+ })
806
+ ),
807
+ __settings.client.subscribe(
808
+ "chatify://thread-updated",
809
+ ([threadId, threadName]) => id === threadId && updateCachedData((thread) => {
810
+ thread.name = threadName;
811
+ })
812
+ )
813
+ ).when(cacheEntryRemoved);
814
+ }
815
+ }),
816
+ watchThread: builder.mutation({
817
+ queryFn: async ({ id, watch }) => {
818
+ await __settings.client.watchThread(id, watch);
819
+ return { data: null };
820
+ }
821
+ }),
822
+ // ====================================================
823
+ // ============ THREAD MESSAGE =================
824
+ // ====================================================
825
+ getThreadMessageList: builder.query({
826
+ queryFn: async (args) => {
827
+ const requestArgs = {
828
+ skip: 0,
829
+ take: DEFAULT_MESSAGE_LIST_TAKE + 1,
830
+ ...args
831
+ };
832
+ const messages = await __settings.client.threadMessages(requestArgs);
833
+ return {
834
+ data: {
835
+ messages: messages.slice(0, DEFAULT_MESSAGE_LIST_TAKE),
836
+ hasMore: messages.length === DEFAULT_MESSAGE_LIST_TAKE + 1
837
+ }
838
+ };
839
+ },
840
+ providesTags: ["account", "thread", "thread-message"],
841
+ onCacheEntryAdded: async ({ threadId }, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
842
+ await cacheDataLoaded;
843
+ unsubscribe(
844
+ __settings.client.subscribe("chatify://thread-message-new", ([_threadId, message]) => {
845
+ threadId === _threadId && updateCachedData((messageList) => {
846
+ !messageList.messages.some((x) => x.id === message.id) && messageList.messages.unshift(message);
847
+ });
848
+ })
849
+ ).when(cacheEntryRemoved);
850
+ }
851
+ }),
852
+ fetchNextThreadMessageList: builder.mutation({
853
+ queryFn: async ({ threadId }, { getState }) => {
854
+ const current = chatifyApi.endpoints.getThreadMessageList.select({ threadId })(getState());
855
+ const messages = await __settings.client.threadMessages({
856
+ threadId,
857
+ skip: current.data.messages.length,
858
+ take: DEFAULT_MESSAGE_LIST_TAKE + 1
859
+ });
860
+ return {
861
+ data: null,
862
+ meta: {
863
+ messages: messages.slice(0, DEFAULT_MESSAGE_LIST_TAKE),
864
+ hasMore: messages.length === DEFAULT_MESSAGE_LIST_TAKE + 1
865
+ }
866
+ };
867
+ },
868
+ onQueryStarted: async ({ threadId }, { dispatch, queryFulfilled }) => {
869
+ const result = await queryFulfilled;
870
+ const meta = result.meta;
871
+ dispatch(
872
+ chatifyApi.util.updateQueryData("getThreadMessageList", { threadId }, (draft) => {
873
+ draft.hasMore = meta.hasMore;
874
+ draft.messages.push(...meta.messages);
875
+ })
876
+ );
877
+ }
878
+ }),
879
+ sendThreadMessage: builder.mutation({
880
+ queryFn: async (args) => {
881
+ const id = await __settings.client.sendThreadMessage(args);
882
+ return { data: id };
883
+ }
884
+ }),
885
+ readThreadMessage: builder.mutation({
886
+ queryFn: async () => {
887
+ return { data: null };
888
+ },
889
+ onQueryStarted: async ({ id }, { dispatch }) => {
890
+ THREAD_MESSAGE_READ_QUEUE.push(id);
891
+ dispatch(chatifyApi.endpoints.getThreadMessageReadQueue.initiate(void 0, { forceRefetch: true }));
892
+ }
893
+ }),
894
+ getThreadMessageReadQueue: builder.query({
895
+ queryFn: async () => ({ data: THREAD_MESSAGE_READ_QUEUE.units }),
896
+ onCacheEntryAdded: async (_, { dispatch, cacheEntryRemoved }) => {
897
+ unsubscribe(
898
+ THREAD_MESSAGE_READ_QUEUE.subscribe((value) => {
899
+ dispatch(
900
+ chatifyApi.util.updateQueryData("getThreadMessageReadQueue", void 0, () => value.units)
901
+ );
902
+ })
903
+ ).when(cacheEntryRemoved);
904
+ }
905
+ })
906
+ })
907
+ });
908
+ function useChatListItem(id) {
909
+ return useSelector(
910
+ (state) => {
911
+ var _a;
912
+ return id != null ? (_a = __chatifyApi.endpoints.getChatList.select()(state).data) == null ? void 0 : _a.find((x) => x.id === id) : null;
913
+ }
914
+ );
915
+ }
916
+ function useUnreadThreadMessageCount() {
917
+ const { data: threads, ...state } = chatifyApi.useGetWatchThreadListQuery();
918
+ const count = useMemo(() => threads != null ? calcThreadListUnreadCount(threads) : null, [threads]);
919
+ return [count, state];
920
+ }
921
+ const chatifyApi = Object.assign(__chatifyApi, {
922
+ settings: __settings,
923
+ useChatListItem,
924
+ useUnreadThreadMessageCount
925
+ });
926
+ const _Avatar = forwardRef(
927
+ (props, forwardRef2) => {
928
+ const { account } = props;
929
+ return /* @__PURE__ */ jsx(Avatar$1, { ref: forwardRef2, src: account.avatar });
930
+ }
931
+ );
932
+ _Avatar.displayName = "Avatar";
933
+ const Avatar = customize("Avatar", _Avatar);
934
+ function useAdd(chatId2, accountId, withHistory) {
935
+ const [add, state] = chatifyApi.useAddChatMemberMutation();
936
+ const onAdd = useCallback(
937
+ () => add({ chatId: chatId2, accountId, withHistory }),
938
+ [add, chatId2, accountId, withHistory]
939
+ );
940
+ return [onAdd, state];
941
+ }
942
+ function useRemove(chatId2, accountId, deleteHistory) {
943
+ const [remove, state] = chatifyApi.useRemoveChatMemberMutation();
944
+ const onRemove = useCallback(
945
+ () => remove({ chatId: chatId2, accountId, deleteHistory }),
946
+ [remove, chatId2, accountId, deleteHistory]
947
+ );
948
+ return [onRemove, state];
949
+ }
950
+ const ChatMemberListItem = customize("ChatMemberListItem", (props) => {
951
+ const { chatId: chatId2 } = props;
952
+ const { data: chat } = chatifyApi.useGetChatQuery({ id: chatId2 });
953
+ const { data: accounts } = chatifyApi.useGetAccountListQuery({});
954
+ const account = accounts.find((x) => x.id === props.id);
955
+ const isMember = chat.members.some((x) => x.id === account.id);
956
+ const [onAddWithoutHistory] = useAdd(chatId2, account.id, false);
957
+ const [onAddWithHistory] = useAdd(chatId2, account.id, true);
958
+ const [onRemoveKeepHistory] = useRemove(chatId2, account.id, false);
959
+ const [onRemoveDeleteHistory] = useRemove(chatId2, account.id, true);
960
+ return /* @__PURE__ */ jsx(
961
+ List.Item,
962
+ {
963
+ className: "wxchtf-chat-members-list-item",
964
+ actions: isMember ? [
965
+ /* @__PURE__ */ jsx(Tooltip, { title: "Remove (keep history)", children: /* @__PURE__ */ jsx(Button, { onClick: onRemoveKeepHistory, type: "link", icon: /* @__PURE__ */ jsx(Icon, { type: "remove-member" }) }) }, "remove"),
966
+ /* @__PURE__ */ jsx(Tooltip, { title: "Remove (delete history)", children: /* @__PURE__ */ jsx(
967
+ Button,
968
+ {
969
+ onClick: onRemoveDeleteHistory,
970
+ type: "link",
971
+ icon: /* @__PURE__ */ jsx(Icon, { type: "remove-member-delete-history" })
972
+ }
973
+ ) }, "remove_delete_history")
974
+ ] : [
975
+ /* @__PURE__ */ jsx(Tooltip, { title: "Add (no history)", children: /* @__PURE__ */ jsx(Button, { onClick: onAddWithoutHistory, type: "link", icon: /* @__PURE__ */ jsx(Icon, { type: "add-member" }) }) }, "add_no_history"),
976
+ /* @__PURE__ */ jsx(Tooltip, { title: "Add (share history)", children: /* @__PURE__ */ jsx(
977
+ Button,
978
+ {
979
+ onClick: onAddWithHistory,
980
+ type: "link",
981
+ icon: /* @__PURE__ */ jsx(Icon, { type: "add-member-with-history" })
982
+ }
983
+ ) }, "add")
984
+ ],
985
+ children: /* @__PURE__ */ jsxs(Space, { children: [
986
+ /* @__PURE__ */ jsx(Avatar, { account }),
987
+ /* @__PURE__ */ jsx("span", { children: account.name })
988
+ ] })
989
+ }
990
+ );
991
+ });
992
+ const ChatMembersPanel = customize("ChatMembersPanel", () => {
993
+ const { id } = useChatContext();
994
+ const { data: chat } = chatifyApi.useGetChatQuery({ id });
995
+ const { data: accounts } = chatifyApi.useGetAccountListQuery({});
996
+ const ordered = useMemo(
997
+ () => accounts == null ? void 0 : accounts.slice().sort(
998
+ (a, b) => ((chat == null ? void 0 : chat.members.some((m) => m.id === a.id)) ? -100 : 0) - ((chat == null ? void 0 : chat.members.some((m) => m.id === b.id)) ? -100 : 0) + a.name.localeCompare(b.name)
999
+ ),
1000
+ [accounts, chat]
1001
+ );
1002
+ if (!(chat == null ? void 0 : chat.members) || !accounts) {
1003
+ return null;
1004
+ }
1005
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-chat-members-panel", children: /* @__PURE__ */ jsx(
1006
+ List,
1007
+ {
1008
+ className: "wxchtf-chat-members-list",
1009
+ dataSource: ordered,
1010
+ renderItem: (item) => /* @__PURE__ */ jsx(ChatMemberListItem, { id: item.id, chatId: id })
1011
+ }
1012
+ ) });
1013
+ });
1014
+ const ChatMembersPreview = customize("ChatMembersPreview", () => {
1015
+ const { id } = useChatContext();
1016
+ const { data: chat } = chatifyApi.useGetChatQuery({ id });
1017
+ if (!(chat == null ? void 0 : chat.members)) {
1018
+ return null;
1019
+ }
1020
+ return /* @__PURE__ */ jsx(Avatar$1.Group, { max: { count: 5 }, children: chat.members.map((x) => /* @__PURE__ */ jsx(Tooltip, { title: x.name, children: /* @__PURE__ */ jsx(Avatar, { account: x }) }, x.id)) });
1021
+ });
1022
+ const InputFileButton = customize("InputFileButton", (props) => {
1023
+ const { onUpload, onAddedClick, accept, loading, value, disabled } = props;
1024
+ const inputRef = useRef(null);
1025
+ const onClick = useCallback(() => {
1026
+ var _a;
1027
+ return (_a = inputRef.current) == null ? void 0 : _a.click();
1028
+ }, []);
1029
+ const countButtonRef = useRef(null);
1030
+ useEffect(() => {
1031
+ var _a;
1032
+ (_a = countButtonRef.current) == null ? void 0 : _a.classList.add("active");
1033
+ }, [value]);
1034
+ const onCountButtonAnimationEnd = useCallback(() => {
1035
+ var _a;
1036
+ (_a = countButtonRef.current) == null ? void 0 : _a.classList.remove("active");
1037
+ }, []);
1038
+ const onInputChange = useCallback(
1039
+ (e) => {
1040
+ const files = e.target.files;
1041
+ files && files.length > 0 && onUpload(Array.from(files));
1042
+ },
1043
+ [onUpload]
1044
+ );
1045
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1046
+ /* @__PURE__ */ jsx(
1047
+ Button,
1048
+ {
1049
+ loading,
1050
+ onClick,
1051
+ type: "link",
1052
+ disabled,
1053
+ icon: /* @__PURE__ */ jsx(Icon, { type: "attach" }),
1054
+ className: "wxchtf-add-files-btn"
1055
+ }
1056
+ ),
1057
+ value.length > 0 && /* @__PURE__ */ jsx(
1058
+ Button,
1059
+ {
1060
+ ref: countButtonRef,
1061
+ className: "wxchtf-add-files-added-btn",
1062
+ onAnimationIteration: onCountButtonAnimationEnd,
1063
+ onClick: onAddedClick,
1064
+ type: "link",
1065
+ disabled,
1066
+ icon: /* @__PURE__ */ jsxs(Fragment, { children: [
1067
+ "+",
1068
+ value.length
1069
+ ] })
1070
+ }
1071
+ ),
1072
+ /* @__PURE__ */ jsx(
1073
+ "input",
1074
+ {
1075
+ value: "",
1076
+ accept,
1077
+ onChange: onInputChange,
1078
+ ref: inputRef,
1079
+ type: "file",
1080
+ multiple: true,
1081
+ style: { display: "none" }
1082
+ }
1083
+ )
1084
+ ] });
1085
+ });
1086
+ const InputFilesBox = customize("InputFilesBox", (props) => {
1087
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-add-files-box", children: /* @__PURE__ */ jsx(InputFileButton, { ...props }) });
1088
+ });
1089
+ const LocalizerContext = React.createContext(null);
1090
+ function useLocalizer() {
1091
+ return useContext(LocalizerContext);
1092
+ }
1093
+ const base = {
1094
+ isToday: (value) => dayjs(value).isSame(dayjs(), "day"),
1095
+ timestamp: (value) => dayjs(value).format("HH:mm"),
1096
+ dateTime: (value) => dayjs(value).format("DD/MM/YYYY HH:mm"),
1097
+ message: {
1098
+ read: () => "Read",
1099
+ reading: () => "Reading...",
1100
+ sending: () => "Sending..."
1101
+ },
1102
+ addChat: {
1103
+ title: () => "Add chat",
1104
+ name: {
1105
+ label: () => "Name",
1106
+ required: () => `Name is required`,
1107
+ max250: () => "Max 250 characters allowed"
1108
+ },
1109
+ members: {
1110
+ label: () => "Members",
1111
+ required: () => "Members is required"
1112
+ },
1113
+ submitBtn: () => "Submit"
1114
+ },
1115
+ system: {
1116
+ "chatify://chat-created": () => "Chat created",
1117
+ "chatify://member-added": () => "New member added",
1118
+ "chatify://member-removed": () => "Member removed",
1119
+ "chatify://chat-name-changed": (_, { newName }) => `Chat name changed to '${newName}'`
1120
+ },
1121
+ input: {
1122
+ placeholder: () => "Start typing... (Press Enter to send, and Shift+Enter to start a new line)"
1123
+ },
1124
+ settings: {
1125
+ members: () => "Members"
1126
+ },
1127
+ size: {
1128
+ bytes: (value) => `${value.toLocaleString(void 0, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} bytes`,
1129
+ kb: (value) => `${value.toLocaleString(void 0, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} KB`,
1130
+ mb: (value) => `${value.toLocaleString(void 0, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} MB`
1131
+ },
1132
+ chatList: {
1133
+ topShown: (count) => `Latest active ${count} chat${count !== 1 ? "s" : ""} shown`
1134
+ },
1135
+ autoReply: {
1136
+ buttonTitle: () => "Auto-reply",
1137
+ title: () => "Auto-reply",
1138
+ period: {
1139
+ label: () => "Period",
1140
+ required: () => "Please select start and end date",
1141
+ format: () => "DD/MM/YYYY"
1142
+ },
1143
+ text: { label: () => "Message", required: () => "Please enter message" },
1144
+ submitBtn: () => "Submit",
1145
+ clearBtn: () => "Clear"
1146
+ }
1147
+ };
1148
+ const defaultLocalizer = base;
1149
+ const isEnter$1 = isHotkey("enter");
1150
+ const isCtrlEnter = isHotkey("ctrl+enter");
1151
+ const AUTO_SIZE = { maxRows: 5, minRows: 1 };
1152
+ const InputTextBox = customize(
1153
+ "InputTextBox",
1154
+ memo((props) => {
1155
+ const { value, onChange, onSend, disabled, inputRef } = props;
1156
+ const localizer = useLocalizer();
1157
+ const onInputChange = useCallback(
1158
+ (e) => onChange(e.target.value),
1159
+ [onChange]
1160
+ );
1161
+ const onKeyDown = useCallback(
1162
+ (e) => {
1163
+ if (disabled) {
1164
+ e.preventDefault();
1165
+ return;
1166
+ }
1167
+ if (isEnter$1(e) || isCtrlEnter(e)) {
1168
+ e.preventDefault();
1169
+ onSend(value);
1170
+ }
1171
+ },
1172
+ [onSend, value, disabled]
1173
+ );
1174
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-text-input-box", children: /* @__PURE__ */ jsx(
1175
+ Input.TextArea,
1176
+ {
1177
+ ref: inputRef,
1178
+ value,
1179
+ onChange: onInputChange,
1180
+ autoSize: AUTO_SIZE,
1181
+ className: "wxchtf-text-input-textarea",
1182
+ placeholder: localizer.input.placeholder(),
1183
+ onKeyDown
1184
+ }
1185
+ ) });
1186
+ })
1187
+ );
1188
+ const InputSubmitButtonBox = customize("InputSubmitButtonBox", (props) => {
1189
+ const { onSubmit, disabled, loading } = props;
1190
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-submit-btn-box", children: /* @__PURE__ */ jsx(
1191
+ Button,
1192
+ {
1193
+ onClick: onSubmit,
1194
+ type: "link",
1195
+ icon: /* @__PURE__ */ jsx(Icon, { type: "send" }),
1196
+ className: "wxchtf-submit-btn",
1197
+ disabled,
1198
+ loading
1199
+ }
1200
+ ) });
1201
+ });
1202
+ const ConversationContext = React.createContext(void 0);
1203
+ function useConversation$1() {
1204
+ return React.useContext(ConversationContext);
1205
+ }
1206
+ const MessageSkeleton = customize("MessageSkeleton", (props) => {
1207
+ const { count = 1 } = props;
1208
+ return /* @__PURE__ */ jsx(Fragment, { children: Array.from(Array(count)).map((_, index) => /* @__PURE__ */ jsxs("div", { className: "wxchtf-message-skeleton", children: [
1209
+ /* @__PURE__ */ jsx(Skeleton.Avatar, { className: "wxchtf-avatar", active: true }),
1210
+ /* @__PURE__ */ jsx(Skeleton.Button, { active: true, className: "wxchtf-content" })
1211
+ ] }, index)) });
1212
+ });
1213
+ const ChatListItemName = customize("ChatListItemName", (props) => {
1214
+ const { chat } = props;
1215
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-chat-name", children: chat.name });
1216
+ });
1217
+ const ChatListItemUnreadCount = customize("ChatListItemUnreadCount", (props) => {
1218
+ const { totalUnreadCount: unreadCount } = props.chat;
1219
+ if (unreadCount == null || unreadCount <= 0) {
1220
+ return null;
1221
+ }
1222
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-unread-count", children: unreadCount });
1223
+ });
1224
+ function formatSystemMessage(localizer, text) {
1225
+ const [key, payload] = text.split("::", 2);
1226
+ const data = payload ? JSON.parse(payload) : null;
1227
+ return localizer.system[key](key, data);
1228
+ }
1229
+ const SystemMessageRow = customize("SystemMessageRow", (props) => {
1230
+ const { message, containerRef } = props;
1231
+ const { text, sentAt } = message;
1232
+ const localizer = useLocalizer();
1233
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "wxchtf-system-message", children: [
1234
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-text", children: text && formatSystemMessage(localizer, text) }),
1235
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-timestamp", children: localizer.timestamp(sentAt) })
1236
+ ] });
1237
+ });
1238
+ const Observer = (props) => {
1239
+ const { message, messageRef } = props;
1240
+ const { onRead, lastReadMessageId } = useConversation$1();
1241
+ const isRead = lastReadMessageId != null && message.id.localeCompare(lastReadMessageId) <= 0;
1242
+ const readRef = useRef(isRead);
1243
+ useEffect(() => {
1244
+ readRef.current = readRef.current || isRead;
1245
+ }, [isRead]);
1246
+ const observer = useMemo(
1247
+ () => new IntersectionObserver(([entry]) => {
1248
+ if (entry.isIntersecting && !readRef.current) {
1249
+ readRef.current = true;
1250
+ onRead == null ? void 0 : onRead(message.id);
1251
+ }
1252
+ }),
1253
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1254
+ []
1255
+ );
1256
+ useEffect(() => {
1257
+ observer.observe(messageRef.current);
1258
+ return () => observer.disconnect();
1259
+ }, [observer]);
1260
+ return /* @__PURE__ */ jsx(Fragment, {});
1261
+ };
1262
+ function MessageReadObserver(props) {
1263
+ const { noReadTracking } = useConversation$1();
1264
+ if (noReadTracking === true) {
1265
+ return null;
1266
+ }
1267
+ return /* @__PURE__ */ jsx(Observer, { ...props });
1268
+ }
1269
+ const SystemMessageBox = customize("SystemMessageBox", (props) => {
1270
+ const ref = useRef(null);
1271
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1272
+ /* @__PURE__ */ jsx(MessageReadObserver, { messageRef: ref, ...props }),
1273
+ /* @__PURE__ */ jsx(SystemMessageRow, { containerRef: ref, ...props })
1274
+ ] });
1275
+ });
1276
+ const ChatListItemLastMessageContent = customize(
1277
+ "ChatListItemLastMessageContent",
1278
+ (props) => {
1279
+ const { lastMessage } = props.chat;
1280
+ const localizer = useLocalizer();
1281
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-chat-last-message", children: lastMessage.sentBy.id === "chatify::system" ? lastMessage.text && formatSystemMessage(localizer, lastMessage.text) : lastMessage.text });
1282
+ }
1283
+ );
1284
+ const ChatListItemLastMessageAuthor = customize(
1285
+ "ChatListItemLastMessageAuthor",
1286
+ (props) => {
1287
+ const { lastMessage } = props.chat;
1288
+ if (lastMessage.sentBy.id === "chatify::system") {
1289
+ return null;
1290
+ }
1291
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-chat-last-author", children: lastMessage.sentBy.name });
1292
+ }
1293
+ );
1294
+ const ChatListItemLastMessageSentAt = customize(
1295
+ "ChatListItemLastMessageSentAt",
1296
+ (props) => {
1297
+ const {
1298
+ chat: {
1299
+ lastMessage: { sentAt }
1300
+ }
1301
+ } = props;
1302
+ const localizer = useLocalizer();
1303
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-chat-last-sent-at", children: localizer.isToday(sentAt) ? localizer.timestamp(sentAt) : localizer.dateTime(sentAt) });
1304
+ }
1305
+ );
1306
+ const ChatListItemLastMessage = customize("ChatListItemLastMessage", (props) => {
1307
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-chat-last", children: [
1308
+ /* @__PURE__ */ jsx(ChatListItemLastMessageAuthor, { ...props }),
1309
+ /* @__PURE__ */ jsx(ChatListItemLastMessageContent, { ...props }),
1310
+ /* @__PURE__ */ jsx(ChatListItemLastMessageSentAt, { ...props })
1311
+ ] });
1312
+ });
1313
+ const ChatListItemAvatar = customize("ChatListItemAvatar", (props) => {
1314
+ const { id } = props.chat;
1315
+ return /* @__PURE__ */ jsx(
1316
+ "div",
1317
+ {
1318
+ className: "wxchtf-chat-avatar",
1319
+ style: {
1320
+ "--background-color": color(id, { lightness: 90 }),
1321
+ "--color": color(id, { saturation: 60, lightness: 65 })
1322
+ },
1323
+ children: /* @__PURE__ */ jsx(Icon, { type: "chat" })
1324
+ }
1325
+ );
1326
+ });
1327
+ const ChatListItemBox = customize("ChatListItemBox", (props) => {
1328
+ const { noRead = false } = props;
1329
+ const { lastMessage, lastReadMessageId } = props.chat;
1330
+ const read = lastReadMessageId != null && lastReadMessageId.localeCompare(lastMessage.id) >= 0;
1331
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-chat" + (!read && !noRead ? " --unread" : ""), children: [
1332
+ /* @__PURE__ */ jsx(ChatListItemAvatar, { ...props }),
1333
+ /* @__PURE__ */ jsxs("span", { className: "wxchtf-chat-info", children: [
1334
+ /* @__PURE__ */ jsx(ChatListItemName, { ...props }),
1335
+ /* @__PURE__ */ jsx(ChatListItemUnreadCount, { ...props }),
1336
+ /* @__PURE__ */ jsx(ChatListItemLastMessage, { ...props })
1337
+ ] })
1338
+ ] });
1339
+ });
1340
+ function useOnSelect(props) {
1341
+ const { onSelect } = props;
1342
+ return useMemo(
1343
+ () => onSelect ? (info) => onSelect(info.key) : void 0,
1344
+ [onSelect]
1345
+ );
1346
+ }
1347
+ function useMenuItems(props) {
1348
+ const { items, noRead, top } = props;
1349
+ const localizer = useLocalizer();
1350
+ return useMemo(() => {
1351
+ const result = items == null ? void 0 : items.slice().sort(
1352
+ (a, b) => -messageSequencePart(a.lastMessage.id).localeCompare(messageSequencePart(b.lastMessage.id))
1353
+ ).map((x) => ({ key: x.id, label: /* @__PURE__ */ jsx(ChatListItemBox, { chat: x, noRead }) }));
1354
+ if (top != null) {
1355
+ return [
1356
+ ...result,
1357
+ {
1358
+ type: "item",
1359
+ key: "top",
1360
+ disabled: true,
1361
+ label: /* @__PURE__ */ jsx("div", { style: { textAlign: "center", cursor: "text", fontStyle: "italic" }, children: localizer.chatList.topShown(top) })
1362
+ }
1363
+ ];
1364
+ }
1365
+ return result;
1366
+ }, [items, noRead, top, localizer]);
1367
+ }
1368
+ const ChatList = customize("ChatList", (props) => {
1369
+ const { selected: selectedChatId } = props;
1370
+ const selected = useMemo(() => selectedChatId ? [selectedChatId] : [], [selectedChatId]);
1371
+ const onSelect = useOnSelect(props);
1372
+ const items = useMenuItems(props);
1373
+ return /* @__PURE__ */ jsx(Fragment, { children: items && /* @__PURE__ */ jsx(Menu, { className: "wxchtf-chat-list", selectedKeys: selected, onSelect, items }) });
1374
+ });
1375
+ function useFormatter() {
1376
+ const localizer = useLocalizer();
1377
+ return {
1378
+ size: (value) => {
1379
+ if (value < 1024) {
1380
+ return localizer.size.bytes(value);
1381
+ } else if (value < 1024 * 1024) {
1382
+ return localizer.size.kb(value / 1024);
1383
+ } else {
1384
+ return localizer.size.mb(value / 1024 / 1024);
1385
+ }
1386
+ }
1387
+ };
1388
+ }
1389
+ const InputBoxFile = customize("InputBoxFile", (props) => {
1390
+ const { file, disabled, onDelete } = props;
1391
+ const formatter = useFormatter();
1392
+ const onDeleteClick = useCallback(() => onDelete(file), [file, onDelete]);
1393
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-file", children: [
1394
+ /* @__PURE__ */ jsxs("div", { className: "wxchtf-file-info", children: [
1395
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-file-name", title: file.name, children: file.name }),
1396
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-file-size", children: formatter.size(file.bytes) })
1397
+ ] }),
1398
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-file-actions", children: /* @__PURE__ */ jsx(
1399
+ Button,
1400
+ {
1401
+ disabled,
1402
+ className: "wxchtf-delete",
1403
+ type: "link",
1404
+ icon: /* @__PURE__ */ jsx(Icon, { type: "delete-file" }),
1405
+ onClick: onDeleteClick
1406
+ }
1407
+ ) })
1408
+ ] });
1409
+ });
1410
+ const InputBoxFileList = customize("InputBoxFileList", (props) => {
1411
+ const { files, onDelete, disabled } = props;
1412
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-file-list", children: files.map((file) => /* @__PURE__ */ jsx(InputBoxFile, { file, onDelete, disabled }, file.ref)) });
1413
+ });
1414
+ function useFormState() {
1415
+ const { onSend } = useConversation$1();
1416
+ const [text, setText] = useState("");
1417
+ const [sending, setSending] = useState(false);
1418
+ const { onUpload, files, loading, setFiles, showFileBox, onDeleteFile } = useFlippoInputFileBox();
1419
+ const onSubmit = useCallback(() => {
1420
+ if (!onSend) {
1421
+ return;
1422
+ }
1423
+ const textValue = text.trim().length === 0 ? null : text.trim();
1424
+ if (!textValue && files.length === 0 || loading) {
1425
+ return;
1426
+ }
1427
+ setSending(true);
1428
+ Promise.resolve(onSend({ text: textValue, files })).finally(() => setSending(false)).then(() => {
1429
+ setFiles([]);
1430
+ setText("");
1431
+ });
1432
+ }, [text, onSend, files, setFiles, loading]);
1433
+ return [onSubmit, { text, setText, files, onUpload, loading, showFileBox, onDeleteFile, sending }];
1434
+ }
1435
+ function useFlippoInputFileBox() {
1436
+ const [loading, setLoading] = useState(false);
1437
+ const [files, setFiles] = useState([]);
1438
+ const { flippo } = useCustomizeContext();
1439
+ const onUpload = useCallback(
1440
+ (files2) => {
1441
+ if (!flippo) return;
1442
+ setLoading(true);
1443
+ Promise.all(files2.map((file) => flippo.store(file))).then(
1444
+ (references) => setFiles((prev) => [
1445
+ ...prev,
1446
+ ...references.map((reference, index) => ({
1447
+ name: files2[index].name,
1448
+ ref: reference,
1449
+ bytes: files2[index].size
1450
+ }))
1451
+ ])
1452
+ ).finally(() => setLoading(false));
1453
+ },
1454
+ [flippo]
1455
+ );
1456
+ const onDeleteFile = useCallback((file) => {
1457
+ setFiles((prev) => prev.filter((f) => f !== file));
1458
+ }, []);
1459
+ return { onUpload, files, loading, setFiles, showFileBox: !!flippo, onDeleteFile };
1460
+ }
1461
+ const InputBox = customize("InputBox", () => {
1462
+ const [onSend, { text, setText, files, loading, onUpload, showFileBox, onDeleteFile, sending }] = useFormState();
1463
+ const inputRef = useRef(null);
1464
+ const [showFileList, setShowFileList] = useState(false);
1465
+ const toggleShowFileList = useCallback(() => setShowFileList((prev) => !prev), []);
1466
+ const prevFilesLength = useRef(files.length);
1467
+ useLayoutEffect(() => {
1468
+ var _a;
1469
+ return (_a = inputRef.current) == null ? void 0 : _a.focus();
1470
+ }, []);
1471
+ useEffect(() => {
1472
+ if (prevFilesLength.current === 0 && files.length > 0 && !showFileList) {
1473
+ setShowFileList(true);
1474
+ }
1475
+ prevFilesLength.current = files.length;
1476
+ if (files.length === 0 && showFileList) {
1477
+ setShowFileList(false);
1478
+ }
1479
+ }, [files, showFileList]);
1480
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-input-form", children: /* @__PURE__ */ jsxs("div", { className: "wxchtf-input-box", children: [
1481
+ showFileList && /* @__PURE__ */ jsx("div", { className: "wxchtf-file-list-box", children: /* @__PURE__ */ jsx(InputBoxFileList, { files, onDelete: onDeleteFile, disabled: sending }) }),
1482
+ /* @__PURE__ */ jsxs("div", { className: "wxchtf-input-box-row", children: [
1483
+ showFileBox && /* @__PURE__ */ jsx(
1484
+ InputFilesBox,
1485
+ {
1486
+ onAddedClick: toggleShowFileList,
1487
+ onUpload,
1488
+ value: files,
1489
+ loading,
1490
+ disabled: sending
1491
+ }
1492
+ ),
1493
+ /* @__PURE__ */ jsx(
1494
+ InputTextBox,
1495
+ {
1496
+ value: text,
1497
+ onSend,
1498
+ onChange: setText,
1499
+ disabled: sending,
1500
+ inputRef
1501
+ }
1502
+ ),
1503
+ /* @__PURE__ */ jsx(InputSubmitButtonBox, { onSubmit: onSend, disabled: loading, loading: sending })
1504
+ ] })
1505
+ ] }) });
1506
+ });
1507
+ const MessageAuthor = customize("MessageAuthor", (props) => {
1508
+ const { sentBy } = props.message;
1509
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-message-author", children: /* @__PURE__ */ jsx(Avatar, { account: sentBy }) });
1510
+ });
1511
+ const MessageText = customize("MessageText", (props) => {
1512
+ const { text } = props.message;
1513
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-message-text", children: text });
1514
+ });
1515
+ function open(url) {
1516
+ const w = window.open(url, "_blank");
1517
+ w == null ? void 0 : w.focus();
1518
+ }
1519
+ function useOpen(props) {
1520
+ const { file } = props;
1521
+ const { flippo } = useCustomizeContext();
1522
+ const [isOpenFetching, setIsOpenFetching] = useState(false);
1523
+ const onOpen = useCallback(
1524
+ () => flippo && Promise.resolve(setIsOpenFetching(true)).then(() => flippo.getSasUrl(file.ref)).then(open).finally(() => setIsOpenFetching(false)),
1525
+ [flippo, file.ref]
1526
+ );
1527
+ return [onOpen, { isOpenFetching }];
1528
+ }
1529
+ const MessageFile = customize("MessageFile", (props) => {
1530
+ const { file } = props;
1531
+ const formatter = useFormatter();
1532
+ const [onOpen, { isOpenFetching }] = useOpen(props);
1533
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-file", children: [
1534
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-icon", children: /* @__PURE__ */ jsx(Button, { loading: isOpenFetching, onClick: onOpen, type: "link", icon: /* @__PURE__ */ jsx(Icon, { type: "open-file" }) }) }),
1535
+ /* @__PURE__ */ jsxs("div", { className: "wxchtf-file-info", children: [
1536
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-name", title: file.name, children: file.name }),
1537
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-size", children: formatter.size(file.bytes) })
1538
+ ] })
1539
+ ] });
1540
+ });
1541
+ const MessageFileList = customize("MessageFileList", (props) => {
1542
+ const { files } = props.message;
1543
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-file-list", children: files.map((file) => /* @__PURE__ */ jsx(MessageFile, { file }, file.ref)) });
1544
+ });
1545
+ const MessageContent = customize("MessageContent", (props) => {
1546
+ const { files, text } = props.message;
1547
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-message-content", children: [
1548
+ text && /* @__PURE__ */ jsx(MessageText, { ...props }),
1549
+ files.length > 0 && /* @__PURE__ */ jsx(MessageFileList, { ...props })
1550
+ ] });
1551
+ });
1552
+ const MessageInfoBox = customize("MessageInfoBox", (props) => {
1553
+ const { message } = props;
1554
+ const { id, sentBy, sentAt } = message;
1555
+ const { lastReadMessageId, isReading, noReadTracking } = useConversation$1();
1556
+ const me = chatifyApi.settings.me();
1557
+ const my = sentBy.id === me;
1558
+ const localizer = useLocalizer();
1559
+ const isRead = lastReadMessageId != null && id.localeCompare(lastReadMessageId) <= 0;
1560
+ const reading = !isRead && (isReading == null ? void 0 : isReading(id));
1561
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-message-info-box", children: [
1562
+ !my && /* @__PURE__ */ jsxs("div", { className: "wxchtf-message-author-name", children: [
1563
+ sentBy.name,
1564
+ ","
1565
+ ] }),
1566
+ /* @__PURE__ */ jsx("div", { className: "wxchtf-message-sent-at", children: localizer.timestamp(sentAt) }),
1567
+ !my && !noReadTracking && /* @__PURE__ */ jsx("div", { className: "wxchtf-message-read-box", children: reading ? localizer.message.reading() : localizer.message.read() })
1568
+ ] });
1569
+ });
1570
+ const MessageRow = customize("MessageRow", (props) => {
1571
+ const { message, containerRef } = props;
1572
+ const { sentBy } = message;
1573
+ const me = chatifyApi.settings.me();
1574
+ const my = sentBy.id === me;
1575
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "wxchtf-message" + (my ? " --my" : ""), children: [
1576
+ /* @__PURE__ */ jsx(MessageAuthor, { ...props }),
1577
+ /* @__PURE__ */ jsxs("div", { children: [
1578
+ /* @__PURE__ */ jsx(MessageInfoBox, { ...props }),
1579
+ /* @__PURE__ */ jsx(MessageContent, { ...props })
1580
+ ] })
1581
+ ] });
1582
+ });
1583
+ const MessageBox = customize("MessageBox", (props) => {
1584
+ const ref = useRef(null);
1585
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1586
+ /* @__PURE__ */ jsx(MessageReadObserver, { messageRef: ref, ...props }),
1587
+ /* @__PURE__ */ jsx(MessageRow, { containerRef: ref, ...props })
1588
+ ] });
1589
+ });
1590
+ function NextMessagesObserver(props) {
1591
+ const { onLoad, loading } = props;
1592
+ const [intersecting, setIntersecting] = useState(false);
1593
+ const ref = useRef(null);
1594
+ const timerRef = useRef();
1595
+ const observer = useMemo(
1596
+ () => new IntersectionObserver(([entry]) => {
1597
+ if (entry.isIntersecting) {
1598
+ timerRef.current = window.setTimeout(() => setIntersecting(true), 200);
1599
+ } else {
1600
+ clearTimeout(timerRef.current);
1601
+ }
1602
+ }),
1603
+ []
1604
+ );
1605
+ useEffect(() => {
1606
+ observer.observe(ref.current);
1607
+ return () => observer.disconnect();
1608
+ }, [observer]);
1609
+ useEffect(() => {
1610
+ if (!intersecting) {
1611
+ return;
1612
+ }
1613
+ onLoad();
1614
+ }, [intersecting]);
1615
+ if (loading || intersecting) {
1616
+ return /* @__PURE__ */ jsx(MessageSkeleton, { count: 4 });
1617
+ }
1618
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-next", ref });
1619
+ }
1620
+ const SendingMessageText = customize("SendingMessageText", (props) => {
1621
+ const { text } = props;
1622
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-sending-message-text", children: text });
1623
+ });
1624
+ const SendingMessageInfoBox = customize("SendingMessageInfoBox", (_) => {
1625
+ const localizer = useLocalizer();
1626
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-sending-message-info-box", children: /* @__PURE__ */ jsx("div", { className: "wxchtf-sending-message-sending-box", children: localizer.message.sending() }) });
1627
+ });
1628
+ const SendingMessageContent = customize("SendingMessageContent", (props) => {
1629
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-sending-message-content", children: [
1630
+ /* @__PURE__ */ jsx(SendingMessageText, { ...props }),
1631
+ /* @__PURE__ */ jsx(SendingMessageInfoBox, { ...props })
1632
+ ] });
1633
+ });
1634
+ const SendingMessageBox = customize("SendingMessageBox", (props) => {
1635
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-sending-message", children: /* @__PURE__ */ jsx(SendingMessageContent, { ...props }) });
1636
+ });
1637
+ const ConversationActions = customize("ConversationActions", () => {
1638
+ const { onClose } = useConversation$1();
1639
+ if (!onClose) return null;
1640
+ return /* @__PURE__ */ jsx(Button, { onClick: onClose, type: "link", icon: /* @__PURE__ */ jsx(Icon, { type: "close" }) });
1641
+ });
1642
+ const ConversationBody = customize("ConversationBody", () => {
1643
+ const { id, messages = [], hasMore, onNext, nextLoading } = useConversation$1();
1644
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-conversation-body", children: [
1645
+ !messages && /* @__PURE__ */ jsx(MessageSkeleton, { count: 5 }),
1646
+ messages == null ? void 0 : messages.map((x) => {
1647
+ if (x.sentBy.id === SYSTEM_ID) {
1648
+ return /* @__PURE__ */ jsx(SystemMessageBox, { message: x }, x.id);
1649
+ }
1650
+ return /* @__PURE__ */ jsx(MessageBox, { message: x }, x.id);
1651
+ }),
1652
+ hasMore && /* @__PURE__ */ jsx(NextMessagesObserver, { onLoad: onNext, loading: nextLoading }, messages.length + id)
1653
+ ] });
1654
+ });
1655
+ const ConversationName = customize("ConversationName", () => {
1656
+ const { name } = useConversation$1();
1657
+ return /* @__PURE__ */ jsx("span", { className: "wxchtf-conversation-name", children: name });
1658
+ });
1659
+ const ConversationHeader = customize("ConversationHeader", () => {
1660
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-conversation-header", children: /* @__PURE__ */ jsxs(Row, { justify: "space-between", align: "middle", children: [
1661
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(ConversationName, {}) }),
1662
+ /* @__PURE__ */ jsx(Col, { className: "wxchtf-conversation-actions", children: /* @__PURE__ */ jsx(ConversationActions, {}) })
1663
+ ] }) });
1664
+ });
1665
+ const Conversation = customize("Conversation", (props) => {
1666
+ const {
1667
+ value,
1668
+ hasMore,
1669
+ messages,
1670
+ nextLoading,
1671
+ onNext,
1672
+ onRead,
1673
+ onSend,
1674
+ isReading,
1675
+ noReadTracking,
1676
+ onClose
1677
+ } = props;
1678
+ const { id, active, name, lastReadMessageId } = value;
1679
+ const context = useMemo(
1680
+ () => ({
1681
+ id,
1682
+ name,
1683
+ active,
1684
+ lastReadMessageId,
1685
+ hasMore,
1686
+ messages,
1687
+ nextLoading,
1688
+ onNext,
1689
+ onRead,
1690
+ onSend,
1691
+ isReading,
1692
+ noReadTracking,
1693
+ onClose
1694
+ }),
1695
+ [
1696
+ id,
1697
+ name,
1698
+ active,
1699
+ onNext,
1700
+ onRead,
1701
+ onSend,
1702
+ hasMore,
1703
+ messages,
1704
+ nextLoading,
1705
+ lastReadMessageId,
1706
+ isReading,
1707
+ noReadTracking,
1708
+ onClose
1709
+ ]
1710
+ );
1711
+ return /* @__PURE__ */ jsx(ConversationContext.Provider, { value: context, children: /* @__PURE__ */ jsx("div", { className: "wxchtf-conversation", children: /* @__PURE__ */ jsxs("div", { className: "wxchtf-conversation-main", children: [
1712
+ /* @__PURE__ */ jsx(ConversationHeader, {}),
1713
+ /* @__PURE__ */ jsx(ConversationBody, {}),
1714
+ active && /* @__PURE__ */ jsx(InputBox, {})
1715
+ ] }) }) });
1716
+ });
1717
+ const isEscape = isHotkey("escape");
1718
+ const isEnter = isHotkey("enter");
1719
+ function useUpdateChatName(id, value) {
1720
+ const [updateChatName] = chatifyApi.useUpdateChatNameMutation();
1721
+ return () => updateChatName({ id, name: value });
1722
+ }
1723
+ const ChatEditableHeaderName = customize("ChatEditableHeaderName", () => {
1724
+ const { id, name, active } = useConversation$1();
1725
+ const [editNameValue, setEditNameValue] = useState("");
1726
+ const [edit, setEdit] = useState(false);
1727
+ const updateChatName = useUpdateChatName(id, editNameValue);
1728
+ useEffect(() => {
1729
+ if (edit) {
1730
+ setEditNameValue(name ?? "");
1731
+ }
1732
+ }, [edit, name]);
1733
+ if (!active) {
1734
+ return /* @__PURE__ */ jsx("span", { className: "wxchtf-conversation-name", children: name });
1735
+ }
1736
+ if (edit) {
1737
+ return /* @__PURE__ */ jsx(Tooltip, { defaultOpen: true, title: "Press Enter to save new chat name or Escape to cancel editing", children: /* @__PURE__ */ jsx(
1738
+ Input,
1739
+ {
1740
+ value: editNameValue,
1741
+ onChange: (e) => setEditNameValue(e.target.value),
1742
+ onBlur: () => setEdit(false),
1743
+ onKeyDown: (e) => {
1744
+ if (isEscape(e)) {
1745
+ setEdit(false);
1746
+ } else if (isEnter(e)) {
1747
+ setEdit(false);
1748
+ if (editNameValue !== name && editNameValue.trim() !== "") {
1749
+ updateChatName();
1750
+ }
1751
+ }
1752
+ },
1753
+ autoFocus: true
1754
+ }
1755
+ ) });
1756
+ }
1757
+ return /* @__PURE__ */ jsx(Tooltip, { title: "Click to edit name...", children: /* @__PURE__ */ jsx("span", { className: "wxchtf-conversation-name --editable", onClick: () => setEdit(true), children: name }) });
1758
+ });
1759
+ const ChatHeaderActions = customize("ChatHeaderActions", () => {
1760
+ const { active } = useConversation$1();
1761
+ if (!active) {
1762
+ return null;
1763
+ }
1764
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-chat-members", children: [
1765
+ /* @__PURE__ */ jsx(ChatMembersPreview, {}),
1766
+ /* @__PURE__ */ jsx(ChatMembersButton, {})
1767
+ ] });
1768
+ });
1769
+ const DEFAULT_CHAT_VIEW_CUSTOMIZE_VALUE = {
1770
+ ConversationName: () => /* @__PURE__ */ jsx(ChatEditableHeaderName, {}),
1771
+ ConversationActions: () => /* @__PURE__ */ jsx(ChatHeaderActions, {})
1772
+ };
1773
+ function useConversation(props) {
1774
+ const { value: chat } = props;
1775
+ const { id, name, active, lastReadMessageId } = chat;
1776
+ const { data: messageList } = chatifyApi.useGetChatMessageListQuery({ chatId: id });
1777
+ const { messages, hasMore } = messageList ?? {};
1778
+ const [fetchNext, { isLoading: isFetchNextLoading }] = chatifyApi.useFetchNextChatMessageListMutation();
1779
+ const onNext = useCallback(() => fetchNext({ chatId: id }), [fetchNext, id]);
1780
+ const [read] = chatifyApi.useReadChatMessageMutation();
1781
+ const onRead = useCallback((id2) => read({ id: id2 }), [read]);
1782
+ const [send] = chatifyApi.useSendChatMessageMutation();
1783
+ const onSend = useCallback((message) => send({ ...message, chatId: id }).unwrap(), [id, send]);
1784
+ const { data: readQueue } = chatifyApi.useGetChatMessageReadQueueQuery();
1785
+ const conversation = useMemo(() => {
1786
+ if (!id) {
1787
+ return null;
1788
+ }
1789
+ const result = {
1790
+ value: { id, name, active, lastReadMessageId },
1791
+ messages,
1792
+ hasMore,
1793
+ onNext,
1794
+ nextLoading: isFetchNextLoading,
1795
+ onRead,
1796
+ onSend,
1797
+ isReading: (id2) => readQueue.some((x) => chatId(x.value) === chatId(id2) && id2 <= x.value)
1798
+ };
1799
+ return result;
1800
+ }, [
1801
+ onNext,
1802
+ onRead,
1803
+ onSend,
1804
+ isFetchNextLoading,
1805
+ id,
1806
+ name,
1807
+ active,
1808
+ messages,
1809
+ hasMore,
1810
+ lastReadMessageId,
1811
+ readQueue
1812
+ ]);
1813
+ return conversation;
1814
+ }
1815
+ function Content$1(props) {
1816
+ const conversation = useConversation(props);
1817
+ const { showMembers } = useChatContext();
1818
+ if (!conversation) {
1819
+ return null;
1820
+ }
1821
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-chat", children: [
1822
+ /* @__PURE__ */ jsx(Conversation, { ...conversation }),
1823
+ showMembers && /* @__PURE__ */ jsx(ChatMembersPanel, {})
1824
+ ] });
1825
+ }
1826
+ const ChatView = customize("ChatView", (props) => {
1827
+ const { value } = props;
1828
+ const customized = useCustomizeContext();
1829
+ const customize2 = useMemo(
1830
+ () => ({ ...customized ?? {}, ...DEFAULT_CHAT_VIEW_CUSTOMIZE_VALUE }),
1831
+ [customized]
1832
+ );
1833
+ return /* @__PURE__ */ jsx(CustomizeContext.Provider, { value: customize2, children: /* @__PURE__ */ jsx(ChatContext, { id: value.id, children: /* @__PURE__ */ jsx(Content$1, { value }) }) });
1834
+ });
1835
+ function ChatPanel(props) {
1836
+ const { id, className = "", customize: customize2, localizer = defaultLocalizer, style } = props;
1837
+ const { data: chat } = chatifyApi.useGetChatQuery({ id });
1838
+ return /* @__PURE__ */ jsx("div", { className: `wxchtf-chatify wxchtf-chat-panel ${className}`, style, children: /* @__PURE__ */ jsx(LocalizerContext.Provider, { value: localizer, children: /* @__PURE__ */ jsx(CustomizeContext.Provider, { value: customize2, children: chat && /* @__PURE__ */ jsx(ChatView, { value: chat }, id) }) }) });
1839
+ }
1840
+ const ChatGroupReactContext = React.createContext(null);
1841
+ function useChatGroupContext() {
1842
+ return useContext(ChatGroupReactContext);
1843
+ }
1844
+ function ChatGroupContext(props) {
1845
+ const { children } = props;
1846
+ const [state, setState] = useState({
1847
+ chatId: null,
1848
+ view: null,
1849
+ showMembers: false
1850
+ });
1851
+ const value = useMemo(
1852
+ () => ({
1853
+ ...state,
1854
+ openChat: (chatId2) => setState((prev) => ({ ...prev, view: "chat", chatId: chatId2 })),
1855
+ none: () => setState((prev) => ({ ...prev, view: null, chatId: null })),
1856
+ toggleMembers: () => setState((prev) => ({ ...prev, showMembers: !prev.showMembers })),
1857
+ toggleNewChat: () => setState((prev) => {
1858
+ if (prev.view === "new-chat" && !prev.chatId) {
1859
+ return { ...prev, view: null };
1860
+ } else if (prev.view === "new-chat" && prev.chatId) {
1861
+ return { ...prev, view: "chat" };
1862
+ } else {
1863
+ return { ...prev, view: "new-chat" };
1864
+ }
1865
+ }),
1866
+ toggleAutoReply: () => setState((prev) => {
1867
+ if (prev.view === "auto-reply" && prev.chatId) {
1868
+ return { ...prev, view: "chat" };
1869
+ } else if (prev.view === "auto-reply" && !prev.chatId) {
1870
+ return { ...prev, view: null };
1871
+ } else {
1872
+ return { ...prev, view: "auto-reply" };
1873
+ }
1874
+ })
1875
+ }),
1876
+ [state]
1877
+ );
1878
+ return /* @__PURE__ */ jsx(ChatGroupReactContext.Provider, { value, children });
1879
+ }
1880
+ const AutoReplyButton = customize("AutoReplyButton", () => {
1881
+ const { toggleAutoReply } = useChatGroupContext();
1882
+ const localizer = useLocalizer();
1883
+ const titleText = localizer.autoReply.buttonTitle();
1884
+ return /* @__PURE__ */ jsx(
1885
+ Button,
1886
+ {
1887
+ className: "wxchtf-add-btn-settings",
1888
+ onClick: toggleAutoReply,
1889
+ icon: /* @__PURE__ */ jsx(Icon, { type: "settings" }),
1890
+ title: titleText,
1891
+ "aria-label": titleText
1892
+ }
1893
+ );
1894
+ });
1895
+ const AutoReplyPeriodInput = customize("AutoReplyPeriodInput", (props) => {
1896
+ const { name } = props;
1897
+ const localizer = useLocalizer();
1898
+ return /* @__PURE__ */ jsx(
1899
+ Form.Item,
1900
+ {
1901
+ label: localizer.autoReply.period.label(),
1902
+ name,
1903
+ rules: [{ required: true, message: localizer.autoReply.period.required() }],
1904
+ children: /* @__PURE__ */ jsx(DatePicker.RangePicker, { format: localizer.autoReply.period.format() })
1905
+ }
1906
+ );
1907
+ });
1908
+ const AutoReplyTextInput = customize("AutoReplyTextInput", (props) => {
1909
+ const { name } = props;
1910
+ const localizer = useLocalizer();
1911
+ return /* @__PURE__ */ jsx(
1912
+ Form.Item,
1913
+ {
1914
+ label: localizer.autoReply.text.label(),
1915
+ name,
1916
+ rules: [{ required: true, message: localizer.autoReply.text.required() }],
1917
+ children: /* @__PURE__ */ jsx(Input.TextArea, { rows: 4 })
1918
+ }
1919
+ );
1920
+ });
1921
+ const AUTO_REPLY_FORM_INITIAL_VALUE = {
1922
+ period: [],
1923
+ text: ""
1924
+ };
1925
+ const AutoReplyForm = customize("AutoReplyForm", (props) => {
1926
+ const { value, busy = false, onSubmit } = props;
1927
+ const localizer = useLocalizer();
1928
+ const [form] = Form.useForm();
1929
+ useEffect(() => {
1930
+ form.setFieldsValue(value);
1931
+ }, [value, form]);
1932
+ return /* @__PURE__ */ jsxs(
1933
+ Form,
1934
+ {
1935
+ form,
1936
+ layout: "vertical",
1937
+ onFinish: onSubmit,
1938
+ disabled: busy,
1939
+ initialValues: value,
1940
+ children: [
1941
+ /* @__PURE__ */ jsx(AutoReplyPeriodInput, { name: "period" }),
1942
+ /* @__PURE__ */ jsx(AutoReplyTextInput, { name: "text" }),
1943
+ /* @__PURE__ */ jsx(Button, { loading: busy, type: "primary", block: true, htmlType: "submit", children: localizer.autoReply.submitBtn() })
1944
+ ]
1945
+ }
1946
+ );
1947
+ });
1948
+ function mapToFormValue(autoReply) {
1949
+ if (!autoReply) {
1950
+ return AUTO_REPLY_FORM_INITIAL_VALUE;
1951
+ }
1952
+ return {
1953
+ period: [dayjs(autoReply.period.start), dayjs(autoReply.period.end)],
1954
+ text: autoReply.text
1955
+ };
1956
+ }
1957
+ function useValue() {
1958
+ const { data: me } = chatifyApi.useGeCurrentUserAccountQuery();
1959
+ const value = useMemo(() => {
1960
+ return mapToFormValue(me == null ? void 0 : me.autoReply);
1961
+ }, [me]);
1962
+ return value;
1963
+ }
1964
+ function useAutoReplyActions() {
1965
+ const meId = chatifyApi.settings.me();
1966
+ const [updateAccount, { isLoading }] = chatifyApi.useUpdateAccountMutation();
1967
+ const onSubmit = useCallback(
1968
+ (value) => updateAccount({
1969
+ id: meId,
1970
+ autoReply: {
1971
+ hasValue: true,
1972
+ value: {
1973
+ text: value.text,
1974
+ period: {
1975
+ start: value.period[0].toISOString(),
1976
+ end: value.period[1].toISOString()
1977
+ }
1978
+ }
1979
+ }
1980
+ }).unwrap(),
1981
+ [updateAccount, meId]
1982
+ );
1983
+ const onClear = useCallback(
1984
+ () => updateAccount({
1985
+ id: meId,
1986
+ autoReply: {
1987
+ hasValue: true,
1988
+ value: null
1989
+ }
1990
+ }).unwrap(),
1991
+ [updateAccount, meId]
1992
+ );
1993
+ return [onSubmit, isLoading, onClear];
1994
+ }
1995
+ const AutoReplyPanel = customize("AutoReplyPanel", () => {
1996
+ const localizer = useLocalizer();
1997
+ const { toggleAutoReply } = useChatGroupContext();
1998
+ const value = useValue();
1999
+ const [onSubmit, submitting, onClear] = useAutoReplyActions();
2000
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-auto-reply-panel", children: [
2001
+ /* @__PURE__ */ jsx(
2002
+ Button,
2003
+ {
2004
+ onClick: toggleAutoReply,
2005
+ className: "wxchtf-auto-reply-panel-close",
2006
+ type: "link",
2007
+ icon: /* @__PURE__ */ jsx(Icon, { type: "close" })
2008
+ }
2009
+ ),
2010
+ /* @__PURE__ */ jsxs("div", { className: "wxchtf-auto-reply-panel-header", children: [
2011
+ /* @__PURE__ */ jsx("h3", { children: localizer.autoReply.title() }),
2012
+ /* @__PURE__ */ jsx(Button, { type: "link", onClick: onClear, disabled: submitting, className: "wxchtf-auto-reply-panel-clear", children: localizer.autoReply.clearBtn() })
2013
+ ] }),
2014
+ /* @__PURE__ */ jsx(AutoReplyForm, { value, busy: submitting ?? false, onSubmit })
2015
+ ] });
2016
+ });
2017
+ const CreateChatNameInput = customize("CreateChatNameInput", (props) => {
2018
+ const { name } = props;
2019
+ const localizer = useLocalizer();
2020
+ return /* @__PURE__ */ jsx(
2021
+ Form.Item,
2022
+ {
2023
+ name,
2024
+ label: localizer.addChat.name.label(),
2025
+ rules: [
2026
+ { required: true, message: localizer.addChat.name.required() },
2027
+ { max: 250, message: localizer.addChat.name.max250() }
2028
+ ],
2029
+ children: /* @__PURE__ */ jsx(Input, {})
2030
+ }
2031
+ );
2032
+ });
2033
+ function CheckboxList(props) {
2034
+ const { value, onChange } = props;
2035
+ const { data: accounts, isFetching } = chatifyApi.useGetAccountListQuery({});
2036
+ const me = chatifyApi.settings.me();
2037
+ const dataSource = useMemo(() => (accounts == null ? void 0 : accounts.filter((x) => x.id !== me)) ?? [], [accounts, me]);
2038
+ return /* @__PURE__ */ jsx(
2039
+ List,
2040
+ {
2041
+ rowKey: "id",
2042
+ className: "wxchtf-create-chat-member-input-list",
2043
+ loading: isFetching,
2044
+ dataSource,
2045
+ renderItem: (x) => {
2046
+ const checked = value.includes(x.id);
2047
+ return /* @__PURE__ */ jsx(List.Item, { className: checked ? "--selected" : "", children: /* @__PURE__ */ jsx(
2048
+ Checkbox,
2049
+ {
2050
+ checked,
2051
+ onChange: () => onChange(value.includes(x.id) ? value.filter((y) => y !== x.id) : [...value, x.id]),
2052
+ children: /* @__PURE__ */ jsx(List.Item.Meta, { avatar: /* @__PURE__ */ jsx(Avatar, { account: x }), title: x.name })
2053
+ }
2054
+ ) });
2055
+ }
2056
+ }
2057
+ );
2058
+ }
2059
+ const CreateChatMemberInput = customize(
2060
+ "CreateChatMemberInput",
2061
+ (props) => {
2062
+ const { name } = props;
2063
+ const localizer = useLocalizer();
2064
+ return /* @__PURE__ */ jsx(
2065
+ Form.Item,
2066
+ {
2067
+ label: localizer.addChat.members.label(),
2068
+ rules: [{ required: true, message: localizer.addChat.members.required() }],
2069
+ name,
2070
+ children: /* @__PURE__ */ jsx(CheckboxList, {})
2071
+ }
2072
+ );
2073
+ }
2074
+ );
2075
+ const INITIAL_VALUE = {
2076
+ name: "",
2077
+ members: []
2078
+ };
2079
+ const CreateChatForm = customize("CreateChatForm", (props) => {
2080
+ const { value = INITIAL_VALUE, onSubmit, busy = false } = props;
2081
+ const localizer = useLocalizer();
2082
+ return /* @__PURE__ */ jsxs(Form, { onFinish: onSubmit, layout: "vertical", disabled: busy, initialValues: value, children: [
2083
+ /* @__PURE__ */ jsx(CreateChatNameInput, { name: "name" }),
2084
+ /* @__PURE__ */ jsx(CreateChatMemberInput, { name: "members" }),
2085
+ /* @__PURE__ */ jsx(Button, { loading: busy, type: "primary", block: true, htmlType: "submit", children: localizer.addChat.submitBtn() })
2086
+ ] });
2087
+ });
2088
+ function useSubmit() {
2089
+ const [add, { isLoading }] = chatifyApi.useAddChatMutation();
2090
+ const { openChat } = useChatGroupContext();
2091
+ const onSubmit = useCallback(
2092
+ (value) => add({
2093
+ name: value.name,
2094
+ members: value.members
2095
+ }).unwrap().then((id) => openChat(id)),
2096
+ [add, openChat]
2097
+ );
2098
+ return [onSubmit, isLoading];
2099
+ }
2100
+ const CreateChatPanel = customize("CreateChatPanel", () => {
2101
+ const localizer = useLocalizer();
2102
+ const [onSubmit, submitting] = useSubmit();
2103
+ const { toggleNewChat } = useChatGroupContext();
2104
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-create-chat-panel", children: [
2105
+ /* @__PURE__ */ jsx(
2106
+ Button,
2107
+ {
2108
+ onClick: () => toggleNewChat(),
2109
+ className: "wxchtf-create-chat-panel-close",
2110
+ type: "link",
2111
+ icon: /* @__PURE__ */ jsx(Icon, { type: "close" })
2112
+ }
2113
+ ),
2114
+ /* @__PURE__ */ jsx("h3", { children: localizer.addChat.title() }),
2115
+ /* @__PURE__ */ jsx(CreateChatForm, { busy: submitting ?? false, onSubmit })
2116
+ ] });
2117
+ });
2118
+ const CreateChatButton = customize("CreateChatButton", () => {
2119
+ const { toggleNewChat } = useChatGroupContext();
2120
+ return /* @__PURE__ */ jsx("span", { className: "wxchtf-add-btn-wrapper", children: /* @__PURE__ */ jsx(Button, { className: "wxchtf-add-btn", onClick: toggleNewChat, icon: "+", children: "Add chat" }) });
2121
+ });
2122
+ const ChatGroupActions = customize("ChatGroupActions", () => {
2123
+ return /* @__PURE__ */ jsx("span", { className: "wxchtf-add-btn-wrapper", children: /* @__PURE__ */ jsxs(Space.Compact, { className: "wxchtf-add-btn-group", children: [
2124
+ /* @__PURE__ */ jsx(CreateChatButton, {}),
2125
+ /* @__PURE__ */ jsx(AutoReplyButton, {})
2126
+ ] }) });
2127
+ });
2128
+ function useData() {
2129
+ const { data: chats } = chatifyApi.useGetChatListQuery();
2130
+ return useMemo(
2131
+ () => (chats == null ? void 0 : chats.map(
2132
+ (x) => ({
2133
+ id: x.id,
2134
+ name: x.name,
2135
+ lastMessage: x.message,
2136
+ lastReadMessageId: x.lastReadMessageId
2137
+ })
2138
+ )) ?? [],
2139
+ [chats]
2140
+ );
2141
+ }
2142
+ const ChatListPanel = customize("ChatListPanel", () => {
2143
+ const { chatId: chatId2, openChat } = useChatGroupContext();
2144
+ const data = useData();
2145
+ return /* @__PURE__ */ jsx(ChatList, { items: data, selected: chatId2, onSelect: openChat });
2146
+ });
2147
+ const ChatGroupAside = customize("ChatGroupAside", () => {
2148
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-aside", children: [
2149
+ /* @__PURE__ */ jsx(ChatGroupActions, {}),
2150
+ /* @__PURE__ */ jsx(ChatListPanel, {})
2151
+ ] });
2152
+ });
2153
+ const ChatGroupHeader = customize("ChatGroupHeader", () => {
2154
+ return /* @__PURE__ */ jsx("div", { className: "wxchtf-header" });
2155
+ });
2156
+ const ChatGroupFooter = customize("ChatGroupFooter", () => /* @__PURE__ */ jsx("div", { className: "wxchtf-footer" }));
2157
+ const ChatGroupMain = customize("ChatGroupMain", () => {
2158
+ const { chatId: chatId2, view } = useChatGroupContext();
2159
+ const chat = chatifyApi.useChatListItem(chatId2);
2160
+ return /* @__PURE__ */ jsxs("div", { className: "wxchtf-main", children: [
2161
+ view === "chat" && chat && /* @__PURE__ */ jsx(ChatView, { value: chat }, chatId2),
2162
+ view === "new-chat" && /* @__PURE__ */ jsx(CreateChatPanel, {}),
2163
+ view === "auto-reply" && /* @__PURE__ */ jsx(AutoReplyPanel, {})
2164
+ ] });
2165
+ });
2166
+ const ChatGroupBody = customize("ChatGroupBody", () => /* @__PURE__ */ jsxs("div", { className: "wxchtf-body", children: [
2167
+ /* @__PURE__ */ jsx(ChatGroupAside, {}),
2168
+ /* @__PURE__ */ jsx(ChatGroupMain, {})
2169
+ ] }));
2170
+ function Content(props) {
2171
+ const { className = "", style } = props;
2172
+ const { data: chats } = chatifyApi.useGetChatListQuery();
2173
+ const { openChat, none, chatId: chatId2 } = useChatGroupContext();
2174
+ const openFirstChatRef = useRef(false);
2175
+ useEffect(() => {
2176
+ if (chats && !chats.some((x) => x.id === chatId2)) {
2177
+ chats.length ? openChat(chats[0].id) : none();
2178
+ }
2179
+ }, [chats, chatId2]);
2180
+ useEffect(() => {
2181
+ if (chats && !openFirstChatRef.current) {
2182
+ openFirstChatRef.current = true;
2183
+ chats.length && openChat(chats[0].id);
2184
+ }
2185
+ }, [chats]);
2186
+ return /* @__PURE__ */ jsxs("div", { className: className + " wxchtf-chatify wxchtf-chat-group", style, children: [
2187
+ /* @__PURE__ */ jsx(ChatGroupHeader, {}),
2188
+ /* @__PURE__ */ jsx(ChatGroupBody, {}),
2189
+ /* @__PURE__ */ jsx(ChatGroupFooter, {})
2190
+ ] });
2191
+ }
2192
+ const DEFAULT_CUSTOMIZE$1 = {
2193
+ ChatGroupHeader: null,
2194
+ ChatGroupFooter: null
2195
+ };
2196
+ const ChatGroupPanel = (props) => {
2197
+ const { localizer = defaultLocalizer, customize: customize2 = DEFAULT_CUSTOMIZE$1 } = props;
2198
+ const customizeValue = useMemo(() => Object.assign({}, DEFAULT_CUSTOMIZE$1, customize2), [customize2]);
2199
+ return /* @__PURE__ */ jsx(LocalizerContext.Provider, { value: localizer, children: /* @__PURE__ */ jsx(CustomizeContext.Provider, { value: customizeValue, children: /* @__PURE__ */ jsx(ChatGroupContext, { children: /* @__PURE__ */ jsx(Content, { ...props }) }) }) });
2200
+ };
2201
+ const ThreadContext = React.createContext(null);
2202
+ function useThreadContext() {
2203
+ return React.useContext(ThreadContext);
2204
+ }
2205
+ const ThreadActions = customize("ThreadActions", () => {
2206
+ const { watch, onWatch } = useThreadContext();
2207
+ if (!watch) {
2208
+ return /* @__PURE__ */ jsx(Tooltip, { title: "Watch thread", children: /* @__PURE__ */ jsx(Button, { type: "link", icon: /* @__PURE__ */ jsx(Icon, { type: "watch" }), onClick: () => onWatch(true) }) });
2209
+ }
2210
+ return /* @__PURE__ */ jsx(Tooltip, { title: "Unwatch thread", children: /* @__PURE__ */ jsx(Button, { type: "link", icon: /* @__PURE__ */ jsx(Icon, { type: "unwatch" }), onClick: () => onWatch(false) }) });
2211
+ });
2212
+ function usePanelState(props) {
2213
+ const { threadId } = props;
2214
+ const { data: thread } = chatifyApi.useGetThreadQuery({ id: threadId });
2215
+ const { data: messageList } = chatifyApi.useGetThreadMessageListQuery({ threadId });
2216
+ const { id, name, archive, lastReadMessageId, watch } = thread ?? {};
2217
+ const { messages, hasMore } = messageList ?? {};
2218
+ const [read] = chatifyApi.useReadThreadMessageMutation();
2219
+ const onRead = useCallback((id2) => read({ id: id2 }), [read]);
2220
+ const [fetchNext, { isLoading: isFetchNextLoading }] = chatifyApi.useFetchNextThreadMessageListMutation();
2221
+ const onNext = useCallback(() => fetchNext({ threadId }), [fetchNext, threadId]);
2222
+ const [send] = chatifyApi.useSendThreadMessageMutation();
2223
+ const onSend = useCallback(
2224
+ (message) => send({ body: message, threadId }).unwrap(),
2225
+ [threadId, send]
2226
+ );
2227
+ const { data: readQueue } = chatifyApi.useGetThreadMessageReadQueueQuery();
2228
+ const conversation = useMemo(() => {
2229
+ if (!id) {
2230
+ return null;
2231
+ }
2232
+ const result = {
2233
+ value: { id, name, active: !archive, lastReadMessageId: lastReadMessageId ?? null },
2234
+ messages,
2235
+ hasMore,
2236
+ onNext,
2237
+ nextLoading: isFetchNextLoading,
2238
+ onRead,
2239
+ onSend,
2240
+ noReadTracking: !watch,
2241
+ isReading: (id2) => readQueue.some(
2242
+ (unit) => parseThreadMessageId(unit.value)[0] === parseThreadMessageId(id2)[0] && id2 <= unit.value
2243
+ )
2244
+ };
2245
+ return result;
2246
+ }, [
2247
+ onNext,
2248
+ onRead,
2249
+ onSend,
2250
+ isFetchNextLoading,
2251
+ id,
2252
+ name,
2253
+ archive,
2254
+ messages,
2255
+ hasMore,
2256
+ lastReadMessageId,
2257
+ readQueue,
2258
+ watch
2259
+ ]);
2260
+ const [watchThread] = chatifyApi.useWatchThreadMutation();
2261
+ const threadContext = useMemo(
2262
+ () => thread ? {
2263
+ id: thread.id,
2264
+ watch: thread.watch,
2265
+ onWatch: (value) => watchThread({ id: thread.id, watch: value }).unwrap()
2266
+ } : null,
2267
+ [thread, watchThread]
2268
+ );
2269
+ return [conversation, threadContext];
2270
+ }
2271
+ const DEFAULT_CUSTOMIZE = {
2272
+ ConversationActions: () => /* @__PURE__ */ jsx(ThreadActions, {})
2273
+ };
2274
+ function ThreadPanel(props) {
2275
+ const { threadId, customize: customize2, localizer = defaultLocalizer, className = "" } = props;
2276
+ const [conversation, threadContext] = usePanelState(props);
2277
+ const customizeMergeValue = useMemo(() => ({ ...DEFAULT_CUSTOMIZE, ...customize2 }), [customize2]);
2278
+ useEffect(() => {
2279
+ chatifyApi.settings.client.connectToThread(threadId);
2280
+ return () => {
2281
+ chatifyApi.settings.client.disconnectFromThread(threadId);
2282
+ };
2283
+ }, [threadId]);
2284
+ if (!conversation || !threadContext) {
2285
+ return null;
2286
+ }
2287
+ return /* @__PURE__ */ jsx(LocalizerContext.Provider, { value: localizer, children: /* @__PURE__ */ jsx(ThreadContext.Provider, { value: threadContext, children: /* @__PURE__ */ jsx(CustomizeContext.Provider, { value: customizeMergeValue, children: /* @__PURE__ */ jsx("div", { className: `wxchtf-chatify wxchtf-thread ${className}`, children: conversation && /* @__PURE__ */ jsx(Conversation, { ...conversation }) }) }) }) });
2288
+ }
2289
+ const Chatify = {
2290
+ Thread: ThreadPanel,
2291
+ ChatGroup: ChatGroupPanel,
2292
+ Chat: ChatPanel
2293
+ };
2294
+ export {
2295
+ MessageFileList as $,
2296
+ AutoReplyButton as A,
2297
+ ChatGroupActions as B,
2298
+ CustomizeContext as C,
2299
+ DEFAULT_CHAT_VIEW_CUSTOMIZE_VALUE as D,
2300
+ ChatGroupAside as E,
2301
+ ChatGroupHeader as F,
2302
+ ChatGroupFooter as G,
2303
+ ChatGroupMain as H,
2304
+ ChatGroupBody as I,
2305
+ ChatListPanel as J,
2306
+ useChatGroupContext as K,
2307
+ LocalizerContext as L,
2308
+ ChatGroupContext as M,
2309
+ ChatGroupPanel as N,
2310
+ InputBox as O,
2311
+ InputFileButton as P,
2312
+ InputFilesBox as Q,
2313
+ InputSubmitButtonBox as R,
2314
+ InputTextBox as S,
2315
+ InputBoxFileList as T,
2316
+ InputBoxFile as U,
2317
+ MessageAuthor as V,
2318
+ MessageBox as W,
2319
+ MessageContent as X,
2320
+ MessageInfoBox as Y,
2321
+ MessageRow as Z,
2322
+ MessageText as _,
2323
+ useCustomize as a,
2324
+ MessageFile as a0,
2325
+ NextMessagesObserver as a1,
2326
+ MessageReadObserver as a2,
2327
+ SendingMessageBox as a3,
2328
+ SendingMessageContent as a4,
2329
+ SendingMessageInfoBox as a5,
2330
+ SendingMessageText as a6,
2331
+ SystemMessageBox as a7,
2332
+ formatSystemMessage as a8,
2333
+ SystemMessageRow as a9,
2334
+ messageSequencePart as aA,
2335
+ parseThreadMessageId as aB,
2336
+ calcThreadUnreadCount as aC,
2337
+ calcThreadListUnreadCount as aD,
2338
+ useChatListItem as aE,
2339
+ useUnreadThreadMessageCount as aF,
2340
+ chatifyApi as aG,
2341
+ CHATIFY_SIGNALR_METHODS as aH,
2342
+ ChatifyClient as aI,
2343
+ unsubscribe as aJ,
2344
+ ConversationActions as aa,
2345
+ ConversationBody as ab,
2346
+ ConversationHeader as ac,
2347
+ ConversationName as ad,
2348
+ ConversationContext as ae,
2349
+ useConversation$1 as af,
2350
+ Conversation as ag,
2351
+ ThreadActions as ah,
2352
+ ThreadPanel as ai,
2353
+ ThreadContext as aj,
2354
+ useThreadContext as ak,
2355
+ Avatar as al,
2356
+ ICONS as am,
2357
+ Icon as an,
2358
+ MessageSkeleton as ao,
2359
+ ChatList as ap,
2360
+ ChatListItemAvatar as aq,
2361
+ ChatListItemBox as ar,
2362
+ ChatListItemLastMessage as as,
2363
+ ChatListItemLastMessageAuthor as at,
2364
+ ChatListItemLastMessageContent as au,
2365
+ ChatListItemLastMessageSentAt as av,
2366
+ ChatListItemName as aw,
2367
+ ChatListItemUnreadCount as ax,
2368
+ SYSTEM_ID as ay,
2369
+ chatId as az,
2370
+ customize as b,
2371
+ color as c,
2372
+ Chatify as d,
2373
+ useLocalizer as e,
2374
+ defaultLocalizer as f,
2375
+ ChatMembersButton as g,
2376
+ ChatMembersPanel as h,
2377
+ ChatMembersPreview as i,
2378
+ ChatView as j,
2379
+ useChatContext as k,
2380
+ ChatContext as l,
2381
+ ChatEditableHeaderName as m,
2382
+ ChatHeaderActions as n,
2383
+ ChatPanel as o,
2384
+ AUTO_REPLY_FORM_INITIAL_VALUE as p,
2385
+ AutoReplyForm as q,
2386
+ AutoReplyPanel as r,
2387
+ AutoReplyPeriodInput as s,
2388
+ AutoReplyTextInput as t,
2389
+ useCustomizeContext as u,
2390
+ CreateChatForm as v,
2391
+ CreateChatMemberInput as w,
2392
+ CreateChatNameInput as x,
2393
+ CreateChatPanel as y,
2394
+ CreateChatButton as z
2395
+ };
2396
+ //# sourceMappingURL=Chatify-CwAfN1wu.js.map