isometrik-plugin-chat-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (507) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/BlockChatList-720a703e.js +423 -0
  3. package/dist/cjs/BlockChatList-720a703e.js.map +1 -0
  4. package/dist/cjs/DocumentMessageBubble-c79bfbe5.js +493 -0
  5. package/dist/cjs/DocumentMessageBubble-c79bfbe5.js.map +1 -0
  6. package/dist/cjs/Image-67c52acd.js +135 -0
  7. package/dist/cjs/Image-67c52acd.js.map +1 -0
  8. package/dist/cjs/ImageMessageBubble-1218fb66.js +675 -0
  9. package/dist/cjs/ImageMessageBubble-1218fb66.js.map +1 -0
  10. package/dist/cjs/IsometrikLogo-976b1c34.js +44 -0
  11. package/dist/cjs/IsometrikLogo-976b1c34.js.map +1 -0
  12. package/dist/cjs/MessageSearch-5fc9dc00.js +5892 -0
  13. package/dist/cjs/MessageSearch-5fc9dc00.js.map +1 -0
  14. package/dist/cjs/ReactionsContainer-a6ce9059.js +375 -0
  15. package/dist/cjs/ReactionsContainer-a6ce9059.js.map +1 -0
  16. package/dist/cjs/Text-fedf6eab.js +60 -0
  17. package/dist/cjs/Text-fedf6eab.js.map +1 -0
  18. package/dist/cjs/VideoMessageBubble-c4694a78.js +571 -0
  19. package/dist/cjs/VideoMessageBubble-c4694a78.js.map +1 -0
  20. package/dist/cjs/WebChat-403e7ab1.js +2884 -0
  21. package/dist/cjs/WebChat-403e7ab1.js.map +1 -0
  22. package/dist/cjs/app-globals-3a1e7e63.js +7 -0
  23. package/dist/cjs/app-globals-3a1e7e63.js.map +1 -0
  24. package/dist/cjs/audio-bubble_8.cjs.entry.js +21011 -0
  25. package/dist/cjs/audio-bubble_8.cjs.entry.js.map +1 -0
  26. package/dist/cjs/block-chat-list.cjs.entry.js +16 -0
  27. package/dist/cjs/block-chat-list.cjs.entry.js.map +1 -0
  28. package/dist/cjs/chat-app.cjs.entry.js +55 -0
  29. package/dist/cjs/chat-app.cjs.entry.js.map +1 -0
  30. package/dist/cjs/chat-assets-6ab1faa6.js +9 -0
  31. package/dist/cjs/chat-assets-6ab1faa6.js.map +1 -0
  32. package/dist/cjs/chat-creds-f4cbf400.js +38 -0
  33. package/dist/cjs/chat-creds-f4cbf400.js.map +1 -0
  34. package/dist/cjs/chat-document-message-bubble.cjs.entry.js +24 -0
  35. package/dist/cjs/chat-document-message-bubble.cjs.entry.js.map +1 -0
  36. package/dist/cjs/chat-image-message-bubble.cjs.entry.js +26 -0
  37. package/dist/cjs/chat-image-message-bubble.cjs.entry.js.map +1 -0
  38. package/dist/cjs/chat-video-message-bubble.cjs.entry.js +24 -0
  39. package/dist/cjs/chat-video-message-bubble.cjs.entry.js.map +1 -0
  40. package/dist/cjs/content-eca5336c.js +81 -0
  41. package/dist/cjs/content-eca5336c.js.map +1 -0
  42. package/dist/cjs/dialog-drawer-9d04911c.js +5313 -0
  43. package/dist/cjs/dialog-drawer-9d04911c.js.map +1 -0
  44. package/dist/cjs/forward-memebers.cjs.entry.js +128 -0
  45. package/dist/cjs/forward-memebers.cjs.entry.js.map +1 -0
  46. package/dist/cjs/group-members-a60fb1cb.js +41 -0
  47. package/dist/cjs/group-members-a60fb1cb.js.map +1 -0
  48. package/dist/cjs/groupcast-49dae5ab.js +202 -0
  49. package/dist/cjs/groupcast-49dae5ab.js.map +1 -0
  50. package/dist/cjs/imagePlaceholder-030cc566.js +4365 -0
  51. package/dist/cjs/imagePlaceholder-030cc566.js.map +1 -0
  52. package/dist/cjs/index-9afe62b6.js +3129 -0
  53. package/dist/cjs/index-9afe62b6.js.map +1 -0
  54. package/dist/cjs/index.cjs.js +148 -0
  55. package/dist/cjs/index.cjs.js.map +1 -0
  56. package/dist/cjs/isometrik-webchat.cjs.js +54 -0
  57. package/dist/cjs/isometrik-webchat.cjs.js.map +1 -0
  58. package/dist/cjs/loader.cjs.js +17 -0
  59. package/dist/cjs/loader.cjs.js.map +1 -0
  60. package/dist/cjs/login-page.cjs.entry.js +85 -0
  61. package/dist/cjs/login-page.cjs.entry.js.map +1 -0
  62. package/dist/cjs/member-add.cjs.entry.js +122 -0
  63. package/dist/cjs/member-add.cjs.entry.js.map +1 -0
  64. package/dist/cjs/message-reaction-976f6261.js +24 -0
  65. package/dist/cjs/message-reaction-976f6261.js.map +1 -0
  66. package/dist/cjs/my-component.cjs.entry.js +29 -0
  67. package/dist/cjs/my-component.cjs.entry.js.map +1 -0
  68. package/dist/cjs/reaction-container.cjs.entry.js +52 -0
  69. package/dist/cjs/reaction-container.cjs.entry.js.map +1 -0
  70. package/dist/cjs/shadow-css-7c4dbc43.js +336 -0
  71. package/dist/cjs/shadow-css-7c4dbc43.js.map +1 -0
  72. package/dist/cjs/signup-page.cjs.entry.js +143 -0
  73. package/dist/cjs/signup-page.cjs.entry.js.map +1 -0
  74. package/dist/cjs/taguser-aca04ed9.js +512 -0
  75. package/dist/cjs/taguser-aca04ed9.js.map +1 -0
  76. package/dist/cjs/theme-provider_2.cjs.entry.js +113 -0
  77. package/dist/cjs/theme-provider_2.cjs.entry.js.map +1 -0
  78. package/dist/cjs/toast-helper-defae4a5.js +84 -0
  79. package/dist/cjs/toast-helper-defae4a5.js.map +1 -0
  80. package/dist/cjs/utils-bcad3386.js +9 -0
  81. package/dist/cjs/utils-bcad3386.js.map +1 -0
  82. package/dist/collection/api/conversations.js +12 -0
  83. package/dist/collection/api/group-members.js +36 -0
  84. package/dist/collection/api/groupcast.js +183 -0
  85. package/dist/collection/api/membership-control.js +13 -0
  86. package/dist/collection/api/message-reaction.js +16 -0
  87. package/dist/collection/api/social-accounts.js +282 -0
  88. package/dist/collection/app-root.js +51 -0
  89. package/dist/collection/app-root.js.map +1 -0
  90. package/dist/collection/assets/images/avatar.svg +1 -0
  91. package/dist/collection/assets/images/chatdefaultbg.svg +6140 -0
  92. package/dist/collection/assets/images/equalizer.svg +1 -0
  93. package/dist/collection/assets/images/imagePlaceholder.svg +2 -0
  94. package/dist/collection/assets/images/link.svg +1 -0
  95. package/dist/collection/assets/images/videoPlaceholder.svg +4 -0
  96. package/dist/collection/assets/images/videoThumbnail.svg +1 -0
  97. package/dist/collection/assets/svg/ExcelDocument.js +2 -0
  98. package/dist/collection/assets/svg/IsometrikLogo.js +38 -0
  99. package/dist/collection/assets/svg/Moon.svg +1 -0
  100. package/dist/collection/assets/svg/NoChatPlaceholder.js +16 -0
  101. package/dist/collection/assets/svg/NoContactsPlaceholder.js +9 -0
  102. package/dist/collection/assets/svg/NoMessagePlaceholder.svg +13 -0
  103. package/dist/collection/assets/svg/PdfDocument.js +2 -0
  104. package/dist/collection/assets/svg/ProfilePlaceholder.js +1 -0
  105. package/dist/collection/assets/svg/SelectChatPlaceholder.js +13 -0
  106. package/dist/collection/assets/svg/Sun.svg +1 -0
  107. package/dist/collection/assets/svg/broadcast-selected.svg +4 -0
  108. package/dist/collection/assets/svg/broadcst-default.svg +4 -0
  109. package/dist/collection/assets/svg/close.svg +1 -0
  110. package/dist/collection/assets/svg/group.svg +7 -0
  111. package/dist/collection/assets/svg/login.svg +3051 -0
  112. package/dist/collection/assets/svg/message-add.svg +5 -0
  113. package/dist/collection/assets/svg/message-bold.svg +3 -0
  114. package/dist/collection/assets/svg/message-outline.svg +5 -0
  115. package/dist/collection/collection-manifest.json +32 -0
  116. package/dist/collection/components/ChatUIComponent/AddMember.js +144 -0
  117. package/dist/collection/components/ChatUIComponent/AddMember.js.map +1 -0
  118. package/dist/collection/components/ChatUIComponent/AudioBubble.js +528 -0
  119. package/dist/collection/components/ChatUIComponent/AudioBubble.js.map +1 -0
  120. package/dist/collection/components/ChatUIComponent/BlockChatList.js +114 -0
  121. package/dist/collection/components/ChatUIComponent/BlockChatList.js.map +1 -0
  122. package/dist/collection/components/ChatUIComponent/ChatDocumentMessageBubble.js +11 -0
  123. package/dist/collection/components/ChatUIComponent/ChatDocumentMessageBubble.js.map +1 -0
  124. package/dist/collection/components/ChatUIComponent/ChatImageMessageBubble.js +11 -0
  125. package/dist/collection/components/ChatUIComponent/ChatImageMessageBubble.js.map +1 -0
  126. package/dist/collection/components/ChatUIComponent/ChatOwnProfile/Profile.js +540 -0
  127. package/dist/collection/components/ChatUIComponent/ChatOwnProfile/Profile.js.map +1 -0
  128. package/dist/collection/components/ChatUIComponent/ChatOwnProfile/profile-page.css +252 -0
  129. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js +1175 -0
  130. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js.map +1 -0
  131. package/dist/collection/components/ChatUIComponent/ChatVideoMessageBubble.js +11 -0
  132. package/dist/collection/components/ChatUIComponent/ChatVideoMessageBubble.js.map +1 -0
  133. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js +790 -0
  134. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js.map +1 -0
  135. package/dist/collection/components/ChatUIComponent/ForwardMessageList.js +152 -0
  136. package/dist/collection/components/ChatUIComponent/ForwardMessageList.js.map +1 -0
  137. package/dist/collection/components/ChatUIComponent/GroupCast.js +218 -0
  138. package/dist/collection/components/ChatUIComponent/GroupCast.js.map +1 -0
  139. package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js +590 -0
  140. package/dist/collection/components/ChatUIComponent/Header/WebChatHeader.js.map +1 -0
  141. package/dist/collection/components/ChatUIComponent/ReactionContainer.js +103 -0
  142. package/dist/collection/components/ChatUIComponent/ReactionContainer.js.map +1 -0
  143. package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js +1352 -0
  144. package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js.map +1 -0
  145. package/dist/collection/components/ChatUIComponent/WebChatBody/web-chat-body.css +277 -0
  146. package/dist/collection/components/Login.js +118 -0
  147. package/dist/collection/components/Login.js.map +1 -0
  148. package/dist/collection/components/Signup.js +177 -0
  149. package/dist/collection/components/Signup.js.map +1 -0
  150. package/dist/collection/components/chat-main.js +131 -0
  151. package/dist/collection/components/chat-main.js.map +1 -0
  152. package/dist/collection/components/my-component/my-component.css +3 -0
  153. package/dist/collection/components/my-component/my-component.js +83 -0
  154. package/dist/collection/components/my-component/my-component.js.map +1 -0
  155. package/dist/collection/components/my-component/web-chat/WebChat.js +2686 -0
  156. package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -0
  157. package/dist/collection/components/my-component/web-chat/WebchatRightSide.js +675 -0
  158. package/dist/collection/components/my-component/web-chat/WebchatRightSide.js.map +1 -0
  159. package/dist/collection/components/my-component/web-chat/web-chat.css +336 -0
  160. package/dist/collection/components/theme-provider.js +182 -0
  161. package/dist/collection/components/theme-provider.js.map +1 -0
  162. package/dist/collection/constants/chat-assets.js +12 -0
  163. package/dist/collection/constants/chat-creds.js +31 -0
  164. package/dist/collection/constants/content.js +75 -0
  165. package/dist/collection/constants/urls.js +1 -0
  166. package/dist/collection/index.js +135 -0
  167. package/dist/collection/index.js.map +1 -0
  168. package/dist/collection/lib/helpers.js +205 -0
  169. package/dist/collection/lib/taguser.js +123 -0
  170. package/dist/collection/store/conversation.js +25 -0
  171. package/dist/collection/store/conversation.js.map +1 -0
  172. package/dist/collection/store/group-members.js +24 -0
  173. package/dist/collection/store/group-members.js.map +1 -0
  174. package/dist/collection/store/unread-count.js +18 -0
  175. package/dist/collection/store/unread-count.js.map +1 -0
  176. package/dist/collection/stories/Components/ActionsPopup/ActionsPopup.js +222 -0
  177. package/dist/collection/stories/Components/ActionsPopup/ActionsPopup.stories.js +148 -0
  178. package/dist/collection/stories/Components/AttachmentBox/AttachmentBox.js +211 -0
  179. package/dist/collection/stories/Components/AttachmentBox/AttachmentPreview/AttachmentPreview.js +708 -0
  180. package/dist/collection/stories/Components/AttachmentBox/AttachmentPreview/AttachmentPreview.stories.js +57 -0
  181. package/dist/collection/stories/Components/AttachmentBox/Attachmentbox.stories.js +74 -0
  182. package/dist/collection/stories/Components/AttachmentBox/CameraPreview.js +231 -0
  183. package/dist/collection/stories/Components/BlockUsers/BlockUsers.js +337 -0
  184. package/dist/collection/stories/Components/Body/Body.js +48 -0
  185. package/dist/collection/stories/Components/Body/Body.stories.js +33 -0
  186. package/dist/collection/stories/Components/Buttons/Buttons.js +65 -0
  187. package/dist/collection/stories/Components/Buttons/Buttons.stories.js +132 -0
  188. package/dist/collection/stories/Components/ChatSidebar/ChatSidebar.js +951 -0
  189. package/dist/collection/stories/Components/ChatSidebar/ChatSidebar.stories.js +75 -0
  190. package/dist/collection/stories/Components/ChatSidebar/ContextMenu.js +109 -0
  191. package/dist/collection/stories/Components/ChatTile/ChatTile.js +290 -0
  192. package/dist/collection/stories/Components/ChatTile/ChatTile.stories.js +180 -0
  193. package/dist/collection/stories/Components/Chip/Chip.js +111 -0
  194. package/dist/collection/stories/Components/Chip/Chip.stories.js +149 -0
  195. package/dist/collection/stories/Components/ContactInfo/ContactInfo.js +1491 -0
  196. package/dist/collection/stories/Components/ContactInfo/ContactInfo.stories.js +118 -0
  197. package/dist/collection/stories/Components/ContactInfo/MediaList.js +147 -0
  198. package/dist/collection/stories/Components/ContactInfo/ProfileInfo.js +1219 -0
  199. package/dist/collection/stories/Components/ContactTile/ContactTile.js +416 -0
  200. package/dist/collection/stories/Components/ContactTile/ContactTile.stories.js +60 -0
  201. package/dist/collection/stories/Components/Dialog-Drawer/confirm.js +113 -0
  202. package/dist/collection/stories/Components/Dialog-Drawer/deletemessage.js +97 -0
  203. package/dist/collection/stories/Components/Dialog-Drawer/dialog-drawer.js +264 -0
  204. package/dist/collection/stories/Components/EmojiReactions/EmojiReactions.js +179 -0
  205. package/dist/collection/stories/Components/Footer/Footer.js +4 -0
  206. package/dist/collection/stories/Components/Footer/Footer.stories.js +155 -0
  207. package/dist/collection/stories/Components/ForwardMessage/ForwardMessageContainer.js +433 -0
  208. package/dist/collection/stories/Components/ForwardMessage/ForwardMessageContainer.stories.js +110 -0
  209. package/dist/collection/stories/Components/ForwardMessage/ForwardUi.js +46 -0
  210. package/dist/collection/stories/Components/GroupChatContacts/GroupChatContacts.js +546 -0
  211. package/dist/collection/stories/Components/GroupChatContacts/GroupChatContacts.stories.js +56 -0
  212. package/dist/collection/stories/Components/GroupInfo/GroupInfo.js +394 -0
  213. package/dist/collection/stories/Components/GroupInfo/GroupInfo.stories.js +107 -0
  214. package/dist/collection/stories/Components/Head/ClosedHeader/ClosedHead.js +129 -0
  215. package/dist/collection/stories/Components/Head/ClosedHeader/ClosedHead.stories.js +78 -0
  216. package/dist/collection/stories/Components/Head/Head.js +672 -0
  217. package/dist/collection/stories/Components/Head/Head.stories.js +91 -0
  218. package/dist/collection/stories/Components/Icon/Icon.js +115 -0
  219. package/dist/collection/stories/Components/Image/Image.js +41 -0
  220. package/dist/collection/stories/Components/Image/Image.stories.js +49 -0
  221. package/dist/collection/stories/Components/Image/Img.stories.js +178 -0
  222. package/dist/collection/stories/Components/Inputbox/Input.js +206 -0
  223. package/dist/collection/stories/Components/Inputbox/Input.stories.js +87 -0
  224. package/dist/collection/stories/Components/InstagramAccounts/InstagramAccountsPanel.js +605 -0
  225. package/dist/collection/stories/Components/Loader/Spinner/Spinner.js +60 -0
  226. package/dist/collection/stories/Components/Loader/Spinner/Spinner.stories.js +38 -0
  227. package/dist/collection/stories/Components/MainPlaceHolder/MainChatPlaceHolder.js +78 -0
  228. package/dist/collection/stories/Components/MainPlaceHolder/MainPlaceHolder.stories.js +130 -0
  229. package/dist/collection/stories/Components/MediaGallery/MediaGallery.js +868 -0
  230. package/dist/collection/stories/Components/MediaGallery/MediaGallery.stories.js +81 -0
  231. package/dist/collection/stories/Components/MembersList/MembersList.js +348 -0
  232. package/dist/collection/stories/Components/MessageBubble/AudioMessageBubble/AudioMesaageBubble.js +533 -0
  233. package/dist/collection/stories/Components/MessageBubble/DocumentMessageBubble/DocumentMessageBubble.js +484 -0
  234. package/dist/collection/stories/Components/MessageBubble/DocumentMessageBubble/DocumentMessageBubble.stories.js +54 -0
  235. package/dist/collection/stories/Components/MessageBubble/ImageMessageBubble/ImageMessageBubble.js +683 -0
  236. package/dist/collection/stories/Components/MessageBubble/ImageMessageBubble/ImageMessageBubble.stories.js +49 -0
  237. package/dist/collection/stories/Components/MessageBubble/IncomingTextMessageBubble/IncomingTextMessageBubble.js +450 -0
  238. package/dist/collection/stories/Components/MessageBubble/IncomingTextMessageBubble/IncomingTextMessageBubble.stories.js +56 -0
  239. package/dist/collection/stories/Components/MessageBubble/LinkMessageBubble/LinkMessageBubble.js +721 -0
  240. package/dist/collection/stories/Components/MessageBubble/OutgoingTextMessageBubble/OutgoingTextMessageBubble.js +139 -0
  241. package/dist/collection/stories/Components/MessageBubble/OutgoingTextMessageBubble/OutgoingTextMessageBubble.stories.js +63 -0
  242. package/dist/collection/stories/Components/MessageBubble/VideoMessageBubble/VideoMessageBubble.js +576 -0
  243. package/dist/collection/stories/Components/MessageBubble/VideoMessageBubble/VideoMessageBubble.stories.js +50 -0
  244. package/dist/collection/stories/Components/MessageDatePill/MessageDatePill.js +66 -0
  245. package/dist/collection/stories/Components/MessageDatePill/MessageDatePill.stories.js +48 -0
  246. package/dist/collection/stories/Components/MessageInfo/MessageInfo.js +465 -0
  247. package/dist/collection/stories/Components/MessageInfo/MessageInfo.stories.js +111 -0
  248. package/dist/collection/stories/Components/MessageSearch/MessageSearch.js +242 -0
  249. package/dist/collection/stories/Components/MessageSearchBar/SearchBar.js +523 -0
  250. package/dist/collection/stories/Components/MessageSearchBar/SearchBar.stories.js +98 -0
  251. package/dist/collection/stories/Components/MessageUnreadCount/MessageUnreadCount.js +51 -0
  252. package/dist/collection/stories/Components/MessageUnreadCount/MessageUnreadCount.stories.js +79 -0
  253. package/dist/collection/stories/Components/NewChatSidebar/NewChatSidebar.js +560 -0
  254. package/dist/collection/stories/Components/NewChatSidebar/NewChatSidebar.stories.js +56 -0
  255. package/dist/collection/stories/Components/Placeholder/NoContactsPlaceholder.js +57 -0
  256. package/dist/collection/stories/Components/Popup/ConfirmationPopup/DeleteConfirmationPopup/DeletePopup.js +114 -0
  257. package/dist/collection/stories/Components/ProfileSidebar/ProfileSidebar.js +166 -0
  258. package/dist/collection/stories/Components/ProfileSidebar/ProfileSidebar.stories.js +125 -0
  259. package/dist/collection/stories/Components/ProfileTab/ProfileTab.js +939 -0
  260. package/dist/collection/stories/Components/ProfileTab/ProfileTab.stories.js +144 -0
  261. package/dist/collection/stories/Components/ReactionsContainer/ReactionsContainer.js +166 -0
  262. package/dist/collection/stories/Components/ReactionsContainer/ReactionsContainer.stories.js +115 -0
  263. package/dist/collection/stories/Components/ReactionsContainer/ReactionsInfoCard/ReactionsInfoCard.js +98 -0
  264. package/dist/collection/stories/Components/ReactionsContainer/ReactionsInfoCard/ReactionsInfoCard.stories.js +55 -0
  265. package/dist/collection/stories/Components/ReadMark/BlueReadMark/BlueReadMark.js +27 -0
  266. package/dist/collection/stories/Components/ReadMark/BlueReadMark/BlueReadMark.stories.js +28 -0
  267. package/dist/collection/stories/Components/ReadMark/ClockMark/ClockMark.js +26 -0
  268. package/dist/collection/stories/Components/ReadMark/ClockMark/ClockMark.stories.js +33 -0
  269. package/dist/collection/stories/Components/ReadMark/DoubleMark/DoubleMark.js +27 -0
  270. package/dist/collection/stories/Components/ReadMark/DoubleMark/DoubleMark.stories.js +28 -0
  271. package/dist/collection/stories/Components/ReadMark/SingleMark/SingleMark.js +38 -0
  272. package/dist/collection/stories/Components/ReadMark/SingleMark/SingleMark.stories.js +33 -0
  273. package/dist/collection/stories/Components/ReplyBlock/MediaIcons.js +16 -0
  274. package/dist/collection/stories/Components/ReplyBlock/ReplyBlock.js +196 -0
  275. package/dist/collection/stories/Components/ReplyBlock/ReplyBlock.stories.js +57 -0
  276. package/dist/collection/stories/Components/ReplyMessageContainer/ReplyMessageContainer.js +645 -0
  277. package/dist/collection/stories/Components/ReplyMessageContainer/ReplyMessageContainer.stories.js +58 -0
  278. package/dist/collection/stories/Components/SearchableList/SearchableList.js +393 -0
  279. package/dist/collection/stories/Components/SearchableList/SearchableList.stories.js +65 -0
  280. package/dist/collection/stories/Components/SharePopup/SharePopup.js +152 -0
  281. package/dist/collection/stories/Components/SharePopup/SharePopup.stories.js +47 -0
  282. package/dist/collection/stories/Components/Splitscreen/Splitscreen.js +157 -0
  283. package/dist/collection/stories/Components/Splitscreen/Splitscreen.stories.js +100 -0
  284. package/dist/collection/stories/Components/TestFooter/MentionUserList.js +194 -0
  285. package/dist/collection/stories/Components/TestFooter/TestFooter.js +1339 -0
  286. package/dist/collection/stories/Components/TestFooter/TestFooter.stories.js +89 -0
  287. package/dist/collection/stories/Components/Text/Text.js +57 -0
  288. package/dist/collection/stories/Components/Text/Text.stories.js +83 -0
  289. package/dist/collection/stories/Components/TextStyle/TextStyle.js +38 -0
  290. package/dist/collection/stories/Components/TextStyle/TextStyle.stories.js +50 -0
  291. package/dist/collection/stories/Components/Time/Timestamp.js +50 -0
  292. package/dist/collection/stories/Components/Time/Timestamp.stories.js +34 -0
  293. package/dist/collection/stories/Components/Toaster/Toaster.js +94 -0
  294. package/dist/collection/stories/Components/Toaster/Toaster.stories.js +108 -0
  295. package/dist/collection/stories/Components/Toaster/toast-helper.js +79 -0
  296. package/dist/collection/stories/Components/Toaster/toast-helper.js.map +1 -0
  297. package/dist/collection/stories/Components/final/final.js +86 -0
  298. package/dist/collection/stories/Components/final/final.stories.js +30 -0
  299. package/dist/collection/stories/assets/SEARCH ICON.svg +1 -0
  300. package/dist/collection/types/ConversationDetailsTypes.js +2 -0
  301. package/dist/collection/types/ConversationDetailsTypes.js.map +1 -0
  302. package/dist/collection/utils/chatSdk.js +14 -0
  303. package/dist/collection/utils/getFomattedDate.js +34 -0
  304. package/dist/collection/utils/getFomattedDate.js.map +1 -0
  305. package/dist/collection/utils/unixTimeConverter.js +28 -0
  306. package/dist/collection/utils/utils.js +4 -0
  307. package/dist/collection/utils/utils.js.map +1 -0
  308. package/dist/esm/BlockChatList-9fc3a42b.js +421 -0
  309. package/dist/esm/BlockChatList-9fc3a42b.js.map +1 -0
  310. package/dist/esm/DocumentMessageBubble-b67726f2.js +491 -0
  311. package/dist/esm/DocumentMessageBubble-b67726f2.js.map +1 -0
  312. package/dist/esm/Image-bb9efda3.js +121 -0
  313. package/dist/esm/Image-bb9efda3.js.map +1 -0
  314. package/dist/esm/ImageMessageBubble-0e473f6e.js +673 -0
  315. package/dist/esm/ImageMessageBubble-0e473f6e.js.map +1 -0
  316. package/dist/esm/IsometrikLogo-14db76af.js +42 -0
  317. package/dist/esm/IsometrikLogo-14db76af.js.map +1 -0
  318. package/dist/esm/MessageSearch-4101a627.js +5875 -0
  319. package/dist/esm/MessageSearch-4101a627.js.map +1 -0
  320. package/dist/esm/ReactionsContainer-bdd74a3c.js +373 -0
  321. package/dist/esm/ReactionsContainer-bdd74a3c.js.map +1 -0
  322. package/dist/esm/Text-3b0b3898.js +58 -0
  323. package/dist/esm/Text-3b0b3898.js.map +1 -0
  324. package/dist/esm/VideoMessageBubble-88a7a53e.js +569 -0
  325. package/dist/esm/VideoMessageBubble-88a7a53e.js.map +1 -0
  326. package/dist/esm/WebChat-5448d615.js +2882 -0
  327. package/dist/esm/WebChat-5448d615.js.map +1 -0
  328. package/dist/esm/app-globals-0f993ce5.js +5 -0
  329. package/dist/esm/app-globals-0f993ce5.js.map +1 -0
  330. package/dist/esm/audio-bubble_8.entry.js +21001 -0
  331. package/dist/esm/audio-bubble_8.entry.js.map +1 -0
  332. package/dist/esm/block-chat-list.entry.js +8 -0
  333. package/dist/esm/block-chat-list.entry.js.map +1 -0
  334. package/dist/esm/chat-app.entry.js +51 -0
  335. package/dist/esm/chat-app.entry.js.map +1 -0
  336. package/dist/esm/chat-assets-bd8778d5.js +6 -0
  337. package/dist/esm/chat-assets-bd8778d5.js.map +1 -0
  338. package/dist/esm/chat-creds-ff086f05.js +35 -0
  339. package/dist/esm/chat-creds-ff086f05.js.map +1 -0
  340. package/dist/esm/chat-document-message-bubble.entry.js +20 -0
  341. package/dist/esm/chat-document-message-bubble.entry.js.map +1 -0
  342. package/dist/esm/chat-image-message-bubble.entry.js +22 -0
  343. package/dist/esm/chat-image-message-bubble.entry.js.map +1 -0
  344. package/dist/esm/chat-video-message-bubble.entry.js +20 -0
  345. package/dist/esm/chat-video-message-bubble.entry.js.map +1 -0
  346. package/dist/esm/content-5aea5e39.js +79 -0
  347. package/dist/esm/content-5aea5e39.js.map +1 -0
  348. package/dist/esm/dialog-drawer-9fa083b1.js +5304 -0
  349. package/dist/esm/dialog-drawer-9fa083b1.js.map +1 -0
  350. package/dist/esm/forward-memebers.entry.js +124 -0
  351. package/dist/esm/forward-memebers.entry.js.map +1 -0
  352. package/dist/esm/group-members-bb3c8db7.js +37 -0
  353. package/dist/esm/group-members-bb3c8db7.js.map +1 -0
  354. package/dist/esm/groupcast-d1c54a27.js +187 -0
  355. package/dist/esm/groupcast-d1c54a27.js.map +1 -0
  356. package/dist/esm/imagePlaceholder-e544f70b.js +4360 -0
  357. package/dist/esm/imagePlaceholder-e544f70b.js.map +1 -0
  358. package/dist/esm/index-fddf30b7.js +3093 -0
  359. package/dist/esm/index-fddf30b7.js.map +1 -0
  360. package/dist/esm/index.js +139 -0
  361. package/dist/esm/index.js.map +1 -0
  362. package/dist/esm/isometrik-webchat.js +49 -0
  363. package/dist/esm/isometrik-webchat.js.map +1 -0
  364. package/dist/esm/loader.js +13 -0
  365. package/dist/esm/loader.js.map +1 -0
  366. package/dist/esm/login-page.entry.js +81 -0
  367. package/dist/esm/login-page.entry.js.map +1 -0
  368. package/dist/esm/member-add.entry.js +118 -0
  369. package/dist/esm/member-add.entry.js.map +1 -0
  370. package/dist/esm/message-reaction-ad47ea1a.js +20 -0
  371. package/dist/esm/message-reaction-ad47ea1a.js.map +1 -0
  372. package/dist/esm/my-component.entry.js +25 -0
  373. package/dist/esm/my-component.entry.js.map +1 -0
  374. package/dist/esm/reaction-container.entry.js +48 -0
  375. package/dist/esm/reaction-container.entry.js.map +1 -0
  376. package/dist/esm/shadow-css-7ad5caf8.js +334 -0
  377. package/dist/esm/shadow-css-7ad5caf8.js.map +1 -0
  378. package/dist/esm/signup-page.entry.js +139 -0
  379. package/dist/esm/signup-page.entry.js.map +1 -0
  380. package/dist/esm/taguser-e9032d65.js +510 -0
  381. package/dist/esm/taguser-e9032d65.js.map +1 -0
  382. package/dist/esm/theme-provider_2.entry.js +108 -0
  383. package/dist/esm/theme-provider_2.entry.js.map +1 -0
  384. package/dist/esm/toast-helper-840fd8dc.js +82 -0
  385. package/dist/esm/toast-helper-840fd8dc.js.map +1 -0
  386. package/dist/esm/utils-11fcde98.js +7 -0
  387. package/dist/esm/utils-11fcde98.js.map +1 -0
  388. package/dist/index.cjs.js +1 -0
  389. package/dist/index.js +1 -0
  390. package/dist/isometrik-webchat/index.esm.js +2 -0
  391. package/dist/isometrik-webchat/index.esm.js.map +1 -0
  392. package/dist/isometrik-webchat/isometrik-webchat.css +2 -0
  393. package/dist/isometrik-webchat/isometrik-webchat.esm.js +2 -0
  394. package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -0
  395. package/dist/isometrik-webchat/p-12774661.js +2 -0
  396. package/dist/isometrik-webchat/p-12774661.js.map +1 -0
  397. package/dist/isometrik-webchat/p-12e56271.js +549 -0
  398. package/dist/isometrik-webchat/p-12e56271.js.map +1 -0
  399. package/dist/isometrik-webchat/p-1415e589.js +2 -0
  400. package/dist/isometrik-webchat/p-1415e589.js.map +1 -0
  401. package/dist/isometrik-webchat/p-18f8d210.js +13 -0
  402. package/dist/isometrik-webchat/p-18f8d210.js.map +1 -0
  403. package/dist/isometrik-webchat/p-1b2461f4.js +357 -0
  404. package/dist/isometrik-webchat/p-1b2461f4.js.map +1 -0
  405. package/dist/isometrik-webchat/p-229095d4.js +2 -0
  406. package/dist/isometrik-webchat/p-229095d4.js.map +1 -0
  407. package/dist/isometrik-webchat/p-2953d06a.entry.js +2 -0
  408. package/dist/isometrik-webchat/p-2953d06a.entry.js.map +1 -0
  409. package/dist/isometrik-webchat/p-3004a123.js +2 -0
  410. package/dist/isometrik-webchat/p-3004a123.js.map +1 -0
  411. package/dist/isometrik-webchat/p-3044698a.js +2 -0
  412. package/dist/isometrik-webchat/p-3044698a.js.map +1 -0
  413. package/dist/isometrik-webchat/p-40517d7f.js +1098 -0
  414. package/dist/isometrik-webchat/p-40517d7f.js.map +1 -0
  415. package/dist/isometrik-webchat/p-42a62cf2.js +2 -0
  416. package/dist/isometrik-webchat/p-42a62cf2.js.map +1 -0
  417. package/dist/isometrik-webchat/p-48e1d174.js +45 -0
  418. package/dist/isometrik-webchat/p-48e1d174.js.map +1 -0
  419. package/dist/isometrik-webchat/p-48e243ec.entry.js +2 -0
  420. package/dist/isometrik-webchat/p-48e243ec.entry.js.map +1 -0
  421. package/dist/isometrik-webchat/p-4d2aca06.js +257 -0
  422. package/dist/isometrik-webchat/p-4d2aca06.js.map +1 -0
  423. package/dist/isometrik-webchat/p-610bfd8a.js +2 -0
  424. package/dist/isometrik-webchat/p-610bfd8a.js.map +1 -0
  425. package/dist/isometrik-webchat/p-674e4bb0.js +9 -0
  426. package/dist/isometrik-webchat/p-674e4bb0.js.map +1 -0
  427. package/dist/isometrik-webchat/p-8490e13d.js +192 -0
  428. package/dist/isometrik-webchat/p-8490e13d.js.map +1 -0
  429. package/dist/isometrik-webchat/p-858b0da8.entry.js +2 -0
  430. package/dist/isometrik-webchat/p-858b0da8.entry.js.map +1 -0
  431. package/dist/isometrik-webchat/p-89108249.entry.js +5010 -0
  432. package/dist/isometrik-webchat/p-89108249.entry.js.map +1 -0
  433. package/dist/isometrik-webchat/p-8dcdea59.js +2963 -0
  434. package/dist/isometrik-webchat/p-8dcdea59.js.map +1 -0
  435. package/dist/isometrik-webchat/p-92d0b21c.js +2 -0
  436. package/dist/isometrik-webchat/p-92d0b21c.js.map +1 -0
  437. package/dist/isometrik-webchat/p-ada9c8e8.entry.js +2 -0
  438. package/dist/isometrik-webchat/p-ada9c8e8.entry.js.map +1 -0
  439. package/dist/isometrik-webchat/p-adbb398d.entry.js +2 -0
  440. package/dist/isometrik-webchat/p-adbb398d.entry.js.map +1 -0
  441. package/dist/isometrik-webchat/p-b07dd267.js +2 -0
  442. package/dist/isometrik-webchat/p-b07dd267.js.map +1 -0
  443. package/dist/isometrik-webchat/p-bf0aeb22.entry.js +2 -0
  444. package/dist/isometrik-webchat/p-bf0aeb22.entry.js.map +1 -0
  445. package/dist/isometrik-webchat/p-bfd51dd4.entry.js +2 -0
  446. package/dist/isometrik-webchat/p-bfd51dd4.entry.js.map +1 -0
  447. package/dist/isometrik-webchat/p-c50aa410.entry.js +2 -0
  448. package/dist/isometrik-webchat/p-c50aa410.entry.js.map +1 -0
  449. package/dist/isometrik-webchat/p-cd34448c.entry.js +2 -0
  450. package/dist/isometrik-webchat/p-cd34448c.entry.js.map +1 -0
  451. package/dist/isometrik-webchat/p-d4b8ece6.entry.js +2 -0
  452. package/dist/isometrik-webchat/p-d4b8ece6.entry.js.map +1 -0
  453. package/dist/isometrik-webchat/p-de8a8642.js +197 -0
  454. package/dist/isometrik-webchat/p-de8a8642.js.map +1 -0
  455. package/dist/isometrik-webchat/p-e09b32eb.js +591 -0
  456. package/dist/isometrik-webchat/p-e09b32eb.js.map +1 -0
  457. package/dist/isometrik-webchat/p-e1255160.js +2 -0
  458. package/dist/isometrik-webchat/p-e1255160.js.map +1 -0
  459. package/dist/isometrik-webchat/p-e3731295.js +274 -0
  460. package/dist/isometrik-webchat/p-e3731295.js.map +1 -0
  461. package/dist/isometrik-webchat/p-e4efea64.entry.js +2 -0
  462. package/dist/isometrik-webchat/p-e4efea64.entry.js.map +1 -0
  463. package/dist/isometrik-webchat/p-ef6e482a.entry.js +2 -0
  464. package/dist/isometrik-webchat/p-ef6e482a.entry.js.map +1 -0
  465. package/dist/isometrik-webchat/p-f1f5d5bd.js +3 -0
  466. package/dist/isometrik-webchat/p-f1f5d5bd.js.map +1 -0
  467. package/dist/isometrik-webchat/p-ff9f3dfe.js +203 -0
  468. package/dist/isometrik-webchat/p-ff9f3dfe.js.map +1 -0
  469. package/dist/loader/cdn.js +1 -0
  470. package/dist/loader/index.cjs.js +1 -0
  471. package/dist/loader/index.d.ts +24 -0
  472. package/dist/loader/index.es2017.js +1 -0
  473. package/dist/loader/index.js +2 -0
  474. package/dist/loader/package.json +11 -0
  475. package/dist/types/app-root.d.ts +0 -0
  476. package/dist/types/components/ChatUIComponent/AddMember.d.ts +13 -0
  477. package/dist/types/components/ChatUIComponent/AudioBubble.d.ts +39 -0
  478. package/dist/types/components/ChatUIComponent/BlockChatList.d.ts +13 -0
  479. package/dist/types/components/ChatUIComponent/ChatDocumentMessageBubble.d.ts +5 -0
  480. package/dist/types/components/ChatUIComponent/ChatImageMessageBubble.d.ts +5 -0
  481. package/dist/types/components/ChatUIComponent/ChatOwnProfile/Profile.d.ts +42 -0
  482. package/dist/types/components/ChatUIComponent/ChatSidebar/ChatSidebar.d.ts +85 -0
  483. package/dist/types/components/ChatUIComponent/ChatVideoMessageBubble.d.ts +5 -0
  484. package/dist/types/components/ChatUIComponent/Footer/ChatFooter.d.ts +154 -0
  485. package/dist/types/components/ChatUIComponent/ForwardMessageList.d.ts +15 -0
  486. package/dist/types/components/ChatUIComponent/GroupCast.d.ts +26 -0
  487. package/dist/types/components/ChatUIComponent/Header/WebChatHeader.d.ts +45 -0
  488. package/dist/types/components/ChatUIComponent/ReactionContainer.d.ts +12 -0
  489. package/dist/types/components/ChatUIComponent/WebChatBody/WebChatBody.d.ts +120 -0
  490. package/dist/types/components/Login.d.ts +13 -0
  491. package/dist/types/components/Signup.d.ts +17 -0
  492. package/dist/types/components/chat-main.d.ts +15 -0
  493. package/dist/types/components/my-component/my-component.d.ts +16 -0
  494. package/dist/types/components/my-component/web-chat/WebchatRightSide.d.ts +42 -0
  495. package/dist/types/components/theme-provider.d.ts +44 -0
  496. package/dist/types/components.d.ts +838 -0
  497. package/dist/types/index.d.ts +37 -0
  498. package/dist/types/stencil-public-runtime.d.ts +1678 -0
  499. package/dist/types/store/conversation.d.ts +17 -0
  500. package/dist/types/store/group-members.d.ts +18 -0
  501. package/dist/types/store/unread-count.d.ts +10 -0
  502. package/dist/types/stories/Components/Toaster/toast-helper.d.ts +8 -0
  503. package/dist/types/types/ConversationDetailsTypes.d.ts +52 -0
  504. package/dist/types/utils/getFomattedDate.d.ts +1 -0
  505. package/dist/types/utils/utils.d.ts +1 -0
  506. package/package.json +89 -0
  507. package/readme.md +569 -0
@@ -0,0 +1,2882 @@
1
+ import { r as registerInstance, a as createEvent, h as h$1, F as Fragment } from './index-fddf30b7.js';
2
+ import { h, i, k as ke, M } from './Image-bb9efda3.js';
3
+ import { C as CHAT_CREDS, M as MQTT_CREDS } from './chat-creds-ff086f05.js';
4
+ import { a as drawerDialogService, b as getDeviceID, c as getGroupcastUrlQuery } from './dialog-drawer-9fa083b1.js';
5
+ import { r as removeConversationMember, g as getConversationEligibleMembers } from './group-members-bb3c8db7.js';
6
+ import { s as showToast } from './toast-helper-840fd8dc.js';
7
+ import { g as getConnectedInstagramAccounts, a as getSocialAccounts, c as connectSocialAccountCallback, b as connectSocialAccount, o as openSocialAuthPopup, d as deleteSocialAccount, e as getSocialRedirectUrl, f as createStore, h as hasConnectedInstagramAccounts, n as notifyOpenerIfSocialPopupCallback, p as parseSocialCallbackParams, i as clearSocialCallbackParamsFromUrl, j as groupMembersStore } from './MessageSearch-4101a627.js';
8
+ import { W as WEB_CONTENT } from './content-5aea5e39.js';
9
+ import { g as getGroupcast, a as getGroupcastMembers, b as getGroupcastMessage, r as removeGroupcastMember, d as deleteGroupCast } from './groupcast-d1c54a27.js';
10
+
11
+ class ProfileSidebar extends h {
12
+ static properties = {
13
+ userMetaData: { type: Object },
14
+ openAccounts: { type: Function },
15
+ openChat: { type: Function },
16
+ activeTab: { type: String },
17
+ isMqttConnected: { type: Boolean },
18
+ unreadConversationsCount: { type: Number },
19
+ };
20
+
21
+ constructor() {
22
+ super();
23
+ this.userMetaData = {};
24
+ this.activeTab = 'Chat';
25
+ }
26
+
27
+ static styles = i`
28
+ :host {
29
+ display: block;
30
+ width: 68px;
31
+ min-width: 68px;
32
+ height: 100%;
33
+ flex-shrink: 0;
34
+ }
35
+
36
+ .profile-tab {
37
+ box-sizing: border-box;
38
+ min-width: 68px;
39
+ width: 68px;
40
+ transition: background-color var(--duration, 180ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
41
+ display: flex;
42
+ align-items: center;
43
+ justify-content: space-between;
44
+ flex-direction: column;
45
+ height: 100%;
46
+ background-color: var(--sidebar-bg, #000000);
47
+ border-right: 1px solid var(--sidebar-border, #333333);
48
+ color: var(--sidebar-foreground, #ffffff);
49
+ padding: 16px 0 18px;
50
+ }
51
+ .chat-button {
52
+ width: 40px;
53
+ height: 40px;
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ cursor: pointer;
58
+ position: relative;
59
+ border-radius: var(--radius-md, 12px);
60
+ color: var(--sidebar-foreground-secondary, #ffffff);
61
+ transition: background-color var(--duration, 180ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)), transform 120ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
62
+ }
63
+ .chat-button:hover {
64
+ background-color: var(--sidebar-accent, color-mix(in srgb, #ffffff 10%, transparent));
65
+ }
66
+ .chat-button:active {
67
+ transform: scale(0.96);
68
+ }
69
+ .active-Chat {
70
+ background-color: var(--sidebar-accent, color-mix(in srgb, #ffffff 10%, transparent));
71
+ border-radius: var(--radius-md, 12px);
72
+ margin-top: 0;
73
+ }
74
+ .mqtt-indicator {
75
+ position: absolute;
76
+ right: 5px;
77
+ bottom: 7px;
78
+ width: 7px;
79
+ height: 7px;
80
+ border-radius: 50%;
81
+ filter: blur(0.3px);
82
+ }
83
+ .mqtt-indicator.connected {
84
+ background-color: var(--success, #0070f3);
85
+ }
86
+ .mqtt-indicator.disconnected {
87
+ background-color: var(--destructive, #ff0000);
88
+ }
89
+ .accounts-icon {
90
+ width: 22px;
91
+ height: 22px;
92
+ color: currentColor;
93
+ }
94
+ .top-buttons,
95
+ .bottom-buttons {
96
+ display: flex;
97
+ align-items: center;
98
+ justify-content: center;
99
+ flex-direction: column;
100
+ gap: 10px;
101
+ padding: 10px 0;
102
+ }
103
+ .unread-count {
104
+ position: absolute;
105
+ right: -2px;
106
+ top: -2px;
107
+ min-width: 16px;
108
+ height: 16px;
109
+ padding: 0 4px;
110
+ border-radius: var(--radius-pill, 999px);
111
+ background: var(--success, #0070f3);
112
+ display: flex;
113
+ align-items: center;
114
+ justify-content: center;
115
+ font-size: 10px;
116
+ font-weight: 600;
117
+ color: #ffffff;
118
+ }
119
+ @media (max-width: 768px) {
120
+ .profile-tab {
121
+ display: none;
122
+ }
123
+ }
124
+ `;
125
+
126
+ renderChatIcon(active) {
127
+ return ke`
128
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="${active ? 'currentColor' : 'none'}" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
129
+ <path d="M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"></path>
130
+ </svg>
131
+ `;
132
+ }
133
+
134
+ renderAccountsIcon() {
135
+ return ke`
136
+ <svg class="accounts-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
137
+ <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
138
+ <circle cx="9" cy="7" r="4"></circle>
139
+ <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
140
+ <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
141
+ </svg>
142
+ `;
143
+ }
144
+
145
+ render() {
146
+ return ke`
147
+ <div class="profile-tab">
148
+ <div class="top-buttons">
149
+ <div class="${this.activeTab === 'Chat' ? 'active-Chat' : ''} chat-button" title="Chat" @click="${this.openChat}">
150
+ ${this.renderChatIcon(this.activeTab === 'Chat')}
151
+ ${this.unreadConversationsCount > 0
152
+ ? ke`<div class="unread-count">${this.unreadConversationsCount}</div>`
153
+ : ''}
154
+ </div>
155
+ </div>
156
+
157
+ <div class="bottom-buttons">
158
+ <div
159
+ class="${this.activeTab === 'Accounts' ? 'active-Chat' : ''} chat-button"
160
+ title="Accounts"
161
+ @click="${this.openAccounts}"
162
+ >
163
+ ${this.renderAccountsIcon()}
164
+ ${this.isMqttConnected
165
+ ? ke`<div class="mqtt-indicator connected"></div>`
166
+ : ke`<div class="mqtt-indicator disconnected"></div>`}
167
+ </div>
168
+ </div>
169
+ </div>
170
+ `;
171
+ }
172
+ }
173
+
174
+ customElements.define('profile-sidebar', ProfileSidebar);
175
+
176
+ class InstagramAccountsPanel extends h {
177
+ static properties = {
178
+ agentUserId: { type: String },
179
+ defaultTheme: { type: String },
180
+ toggleTheme: { type: Function },
181
+ closeDrawer: { type: Function },
182
+ /** Optional callback (prefer CustomEvent for Stencil hosts). */
183
+ accountsChange: { type: Function },
184
+ /** When true, hide the X close (e.g. Instagram gate — no chat to return to). */
185
+ hideClose: { type: Boolean },
186
+ socialAccounts: { type: Array },
187
+ isSocialLoading: { type: Boolean },
188
+ };
189
+
190
+ constructor() {
191
+ super();
192
+ this.agentUserId = '';
193
+ this.defaultTheme = 'light';
194
+ this.toggleTheme = () => {};
195
+ this.closeDrawer = () => {};
196
+ this.accountsChange = null;
197
+ this.hideClose = false;
198
+ this.socialAccounts = [];
199
+ this.isSocialLoading = false;
200
+ }
201
+
202
+ get connectedAccounts() {
203
+ return getConnectedInstagramAccounts(this.socialAccounts);
204
+ }
205
+
206
+ connectedCallback() {
207
+ super.connectedCallback();
208
+ this.loadSocialAccounts();
209
+ }
210
+
211
+ notifyAccountsChange(accounts = this.socialAccounts) {
212
+ const list = accounts || [];
213
+ // Stencil listens via onInstagramAccountsChange → event name "instagramAccountsChange"
214
+ this.dispatchEvent(
215
+ new CustomEvent('instagramAccountsChange', {
216
+ detail: list,
217
+ bubbles: true,
218
+ composed: true,
219
+ })
220
+ );
221
+ if (typeof this.accountsChange === 'function') {
222
+ this.accountsChange(list);
223
+ }
224
+ }
225
+
226
+ async loadSocialAccounts() {
227
+ this.isSocialLoading = true;
228
+ try {
229
+ const data = await getSocialAccounts({ platform: 'instagram' });
230
+ this.socialAccounts = data?.accounts || [];
231
+ this.notifyAccountsChange(this.socialAccounts);
232
+ } catch (error) {
233
+ console.error('Failed to load social accounts:', error);
234
+ this.socialAccounts = [];
235
+ this.notifyAccountsChange([]);
236
+ } finally {
237
+ this.isSocialLoading = false;
238
+ }
239
+ }
240
+
241
+ formatSocialDate(ts) {
242
+ if (!ts) return '-';
243
+ try {
244
+ return new Date(ts).toLocaleDateString(undefined, {
245
+ day: 'numeric',
246
+ month: 'short',
247
+ year: 'numeric',
248
+ });
249
+ } catch {
250
+ return String(ts);
251
+ }
252
+ }
253
+
254
+ async completeSocialCallback(payload) {
255
+ await connectSocialAccountCallback({
256
+ platform: payload.platform || 'instagram',
257
+ username: payload.username || '',
258
+ displayName: payload.displayName || '',
259
+ loginMethod: 'instagram_login',
260
+ });
261
+ await this.loadSocialAccounts();
262
+ showToast({
263
+ message: 'Instagram connected',
264
+ type: 'success',
265
+ position: 'bottom-right',
266
+ });
267
+ }
268
+
269
+ async handleConnectInstagram() {
270
+ this.isSocialLoading = true;
271
+ try {
272
+ const data = await connectSocialAccount({
273
+ platform: 'instagram',
274
+ redirectUrl: getSocialRedirectUrl(),
275
+ loginMethod: 'instagram_login',
276
+ });
277
+ if (!data?.authUrl) throw new Error('No auth URL returned');
278
+
279
+ const result = await openSocialAuthPopup(data.authUrl);
280
+ if (result?.redirected) return;
281
+ if (result?.cancelled) {
282
+ await this.loadSocialAccounts();
283
+ return;
284
+ }
285
+ await this.completeSocialCallback(result || {});
286
+ } catch (error) {
287
+ console.error('Failed to connect Instagram:', error);
288
+ showToast({
289
+ message: error?.message || 'Failed to connect Instagram',
290
+ type: 'error',
291
+ position: 'bottom-right',
292
+ });
293
+ } finally {
294
+ this.isSocialLoading = false;
295
+ }
296
+ }
297
+
298
+ handleDisconnectInstagram(accountId, username) {
299
+ drawerDialogService.openDialog('confirm-dialog', {
300
+ title: 'Disconnect Instagram',
301
+ description: `Disconnect @${username || 'this account'}?`,
302
+ handleConfirm: async () => {
303
+ drawerDialogService.closeDialog('confirm-dialog');
304
+ this.isSocialLoading = true;
305
+ try {
306
+ await deleteSocialAccount({ accountId });
307
+ // API soft-disconnects (status=disconnected) — reload truth from server
308
+ await this.loadSocialAccounts();
309
+ showToast({
310
+ message: 'Instagram disconnected',
311
+ type: 'success',
312
+ position: 'bottom-right',
313
+ });
314
+ } catch (error) {
315
+ console.error('Failed to disconnect Instagram:', error);
316
+ showToast({
317
+ message: error?.message || 'Failed to disconnect Instagram',
318
+ type: 'error',
319
+ position: 'bottom-right',
320
+ });
321
+ } finally {
322
+ this.isSocialLoading = false;
323
+ }
324
+ },
325
+ });
326
+ }
327
+
328
+ renderSocialAccount(account) {
329
+ const name = account.displayName || account.username || 'Instagram';
330
+ const handle = account.username ? `@${account.username}` : '';
331
+ const isConnected = account.status === 'connected';
332
+ const gradId = `igGrad-${account.zernioAccountId || account.username || 'acc'}`;
333
+
334
+ return ke`
335
+ <article class="ig-card">
336
+ <div class="ig-card-top">
337
+ <div class="ig-mark" aria-hidden="true">
338
+ <svg viewBox="0 0 24 24" width="22" height="22" fill="none">
339
+ <defs>
340
+ <linearGradient id=${gradId} x1="0%" y1="100%" x2="100%" y2="0%">
341
+ <stop offset="0%" stop-color="#f58529" />
342
+ <stop offset="50%" stop-color="#dd2a7b" />
343
+ <stop offset="100%" stop-color="#8134af" />
344
+ </linearGradient>
345
+ </defs>
346
+ <rect x="2" y="2" width="20" height="20" rx="5.5" stroke="url(#${gradId})" stroke-width="1.75" />
347
+ <circle cx="12" cy="12" r="4.25" stroke="url(#${gradId})" stroke-width="1.75" />
348
+ <circle cx="17.35" cy="6.65" r="1.15" fill="url(#${gradId})" />
349
+ </svg>
350
+ </div>
351
+ <div class="ig-identity">
352
+ <div class="ig-name-row">
353
+ <h3 class="ig-name">${name}</h3>
354
+ ${isConnected
355
+ ? ke`<span class="ig-badge">Connected</span>`
356
+ : ke`<span class="ig-badge is-muted">${account.status || 'Unknown'}</span>`}
357
+ </div>
358
+ ${handle ? ke`<p class="ig-handle">${handle}</p>` : null}
359
+ <p class="ig-connected-on">Connected ${this.formatSocialDate(account.connectedAt)}</p>
360
+ </div>
361
+ </div>
362
+ <div class="ig-actions">
363
+ ${account.profileUrl
364
+ ? ke`<a class="ig-link" href=${account.profileUrl} target="_blank" rel="noopener noreferrer">View profile</a>`
365
+ : ke`<span></span>`}
366
+ <button
367
+ type="button"
368
+ class="ig-disconnect"
369
+ @click=${() => this.handleDisconnectInstagram(account.zernioAccountId, account.username)}
370
+ >
371
+ Disconnect
372
+ </button>
373
+ </div>
374
+ </article>
375
+ `;
376
+ }
377
+
378
+ renderConnectInstagram() {
379
+ return ke`
380
+ <div class="ig-empty">
381
+ <p class="ig-empty-title">Connect Instagram to see chats</p>
382
+ <p class="ig-empty-copy">
383
+ Link your Instagram account first. After you disconnect, chats stay hidden until you connect again.
384
+ </p>
385
+ <button type="button" class="ig-connect" @click=${() => this.handleConnectInstagram()} ?disabled=${this.isSocialLoading}>
386
+ <span class="ig-mark" aria-hidden="true">
387
+ <svg viewBox="0 0 24 24" width="22" height="22" fill="none">
388
+ <defs>
389
+ <linearGradient id="igGradEmpty" x1="0%" y1="100%" x2="100%" y2="0%">
390
+ <stop offset="0%" stop-color="#f58529" />
391
+ <stop offset="50%" stop-color="#dd2a7b" />
392
+ <stop offset="100%" stop-color="#8134af" />
393
+ </linearGradient>
394
+ </defs>
395
+ <rect x="2" y="2" width="20" height="20" rx="5.5" stroke="url(#igGradEmpty)" stroke-width="1.75" />
396
+ <circle cx="12" cy="12" r="4.25" stroke="url(#igGradEmpty)" stroke-width="1.75" />
397
+ <circle cx="17.35" cy="6.65" r="1.15" fill="url(#igGradEmpty)" />
398
+ </svg>
399
+ </span>
400
+ <span class="ig-connect-copy">
401
+ <span class="ig-connect-title">${this.isSocialLoading ? 'Connecting…' : 'Connect Instagram'}</span>
402
+ <span class="ig-connect-sub">Link your business account to manage DMs here</span>
403
+ </span>
404
+ </button>
405
+ </div>
406
+ `;
407
+ }
408
+
409
+ render() {
410
+ return ke`
411
+ <div class="panel">
412
+ <div class="header">
413
+ ${this.hideClose
414
+ ? null
415
+ : ke`<div class="close-btn" @click=${this.closeDrawer} title="Close">
416
+ <svg xmlns="http://www.w3.org/2000/svg" height="30" viewBox="0 -960 960 960" width="30" fill="var(--text-primary-color)">
417
+ <path d="m249-207-42-42 231-231-231-231 42-42 231 231 231-231 42 42-231 231 231 231-42 42-231-231-231 231Z" />
418
+ </svg>
419
+ </div>`}
420
+ <h1 class="title">Instagram connected accounts</h1>
421
+ </div>
422
+
423
+ <div class="body">
424
+ ${this.isSocialLoading
425
+ ? ke`<div class="ig-skeleton" aria-hidden="true">
426
+ <div class="ig-skeleton-mark"></div>
427
+ <div class="ig-skeleton-lines">
428
+ <div class="ig-skeleton-line wide"></div>
429
+ <div class="ig-skeleton-line"></div>
430
+ </div>
431
+ </div>`
432
+ : this.connectedAccounts.length
433
+ ? this.connectedAccounts.map(account => this.renderSocialAccount(account))
434
+ : this.renderConnectInstagram()}
435
+ </div>
436
+
437
+ <div class="bottom-actions">
438
+ <button type="button" class="action-button" @click=${this.toggleTheme}>
439
+ ${this.defaultTheme === 'dark'
440
+ ? ke`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
441
+ <circle cx="12" cy="12" r="4"></circle>
442
+ <path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"></path>
443
+ </svg>`
444
+ : ke`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
445
+ <path d="M21 14.5A8.5 8.5 0 0 1 9.5 3 7 7 0 1 0 21 14.5z"></path>
446
+ </svg>`}
447
+ <span>${this.defaultTheme === 'dark' ? 'Light Theme' : 'Dark Theme'}</span>
448
+ </button>
449
+ </div>
450
+ </div>
451
+ `;
452
+ }
453
+
454
+ static styles = i`
455
+ :host {
456
+ display: block;
457
+ height: 100%;
458
+ }
459
+
460
+ .panel {
461
+ padding: 16px 20px 24px;
462
+ display: flex;
463
+ flex-direction: column;
464
+ height: 100%;
465
+ box-sizing: border-box;
466
+ overflow-y: auto;
467
+ background-color: var(--bg-primary-color);
468
+ }
469
+
470
+ .header {
471
+ display: flex;
472
+ align-items: center;
473
+ margin-bottom: 24px;
474
+ flex-shrink: 0;
475
+ }
476
+
477
+ .close-btn {
478
+ cursor: pointer;
479
+ display: flex;
480
+ align-items: center;
481
+ }
482
+
483
+ .title {
484
+ font-size: 1.25rem;
485
+ font-weight: 600;
486
+ margin: 0 0 0 8px;
487
+ color: var(--text-primary-color);
488
+ line-height: 1.3;
489
+ }
490
+
491
+ .body {
492
+ flex: 1;
493
+ min-height: 0;
494
+ }
495
+
496
+ .ig-card {
497
+ display: flex;
498
+ flex-direction: column;
499
+ gap: 14px;
500
+ padding: 14px;
501
+ border-radius: 12px;
502
+ border: 1px solid var(--border-subtle, color-mix(in srgb, var(--text-primary-color) 10%, transparent));
503
+ background: color-mix(in srgb, var(--bg-secondary-color, #f5f5f5) 70%, transparent);
504
+ margin-bottom: 12px;
505
+ animation: ig-in 280ms cubic-bezier(0.16, 1, 0.3, 1);
506
+ }
507
+
508
+ @keyframes ig-in {
509
+ from {
510
+ opacity: 0;
511
+ transform: translateY(6px);
512
+ }
513
+ to {
514
+ opacity: 1;
515
+ transform: translateY(0);
516
+ }
517
+ }
518
+
519
+ @media (prefers-reduced-motion: reduce) {
520
+ .ig-card {
521
+ animation: none;
522
+ }
523
+ }
524
+
525
+ .ig-card-top {
526
+ display: flex;
527
+ align-items: flex-start;
528
+ gap: 12px;
529
+ }
530
+
531
+ .ig-mark {
532
+ width: 40px;
533
+ height: 40px;
534
+ border-radius: 12px;
535
+ display: grid;
536
+ place-items: center;
537
+ flex-shrink: 0;
538
+ background: color-mix(in srgb, #dd2a7b 8%, var(--bg-primary-color, #fff));
539
+ }
540
+
541
+ .ig-identity {
542
+ min-width: 0;
543
+ flex: 1;
544
+ }
545
+
546
+ .ig-name-row {
547
+ display: flex;
548
+ align-items: center;
549
+ gap: 8px;
550
+ flex-wrap: wrap;
551
+ }
552
+
553
+ .ig-name {
554
+ margin: 0;
555
+ font-size: 0.9375rem;
556
+ font-weight: 600;
557
+ color: var(--text-primary-color);
558
+ line-height: 1.3;
559
+ overflow: hidden;
560
+ text-overflow: ellipsis;
561
+ white-space: nowrap;
562
+ }
563
+
564
+ .ig-badge {
565
+ font-size: 0.6875rem;
566
+ font-weight: 600;
567
+ letter-spacing: 0.01em;
568
+ padding: 3px 8px;
569
+ border-radius: 999px;
570
+ background: color-mix(in srgb, var(--success) 14%, transparent);
571
+ color: #15803d;
572
+ }
573
+
574
+ .ig-badge.is-muted {
575
+ background: color-mix(in srgb, var(--text-secondary-color) 14%, transparent);
576
+ color: var(--text-secondary-color);
577
+ }
578
+
579
+ .ig-handle {
580
+ margin: 2px 0 0;
581
+ font-size: 0.8125rem;
582
+ color: var(--text-secondary-color);
583
+ overflow: hidden;
584
+ text-overflow: ellipsis;
585
+ white-space: nowrap;
586
+ }
587
+
588
+ .ig-connected-on {
589
+ margin: 6px 0 0;
590
+ font-size: 0.75rem;
591
+ color: var(--text-secondary-color);
592
+ }
593
+
594
+ .ig-actions {
595
+ display: flex;
596
+ align-items: center;
597
+ justify-content: space-between;
598
+ gap: 12px;
599
+ padding-top: 2px;
600
+ border-top: 1px solid var(--border-subtle, color-mix(in srgb, var(--text-primary-color) 8%, transparent));
601
+ }
602
+
603
+ .ig-link {
604
+ font-size: 0.8125rem;
605
+ font-weight: 500;
606
+ color: var(--base-color, var(--primary));
607
+ text-decoration: none;
608
+ }
609
+
610
+ .ig-link:hover {
611
+ text-decoration: underline;
612
+ }
613
+
614
+ .ig-disconnect {
615
+ background: none;
616
+ border: none;
617
+ cursor: pointer;
618
+ color: var(--text-danger-color, #e53935);
619
+ font-size: 0.8125rem;
620
+ font-weight: 500;
621
+ padding: 4px 0;
622
+ }
623
+
624
+ .ig-disconnect:hover {
625
+ opacity: 0.85;
626
+ }
627
+
628
+ .ig-connect {
629
+ width: 100%;
630
+ display: flex;
631
+ align-items: center;
632
+ gap: 12px;
633
+ text-align: left;
634
+ padding: 12px 14px;
635
+ border-radius: 12px;
636
+ border: 1px dashed color-mix(in srgb, var(--text-primary-color) 18%, transparent);
637
+ background: transparent;
638
+ cursor: pointer;
639
+ box-sizing: border-box;
640
+ }
641
+
642
+ .ig-empty {
643
+ display: flex;
644
+ flex-direction: column;
645
+ gap: 12px;
646
+ padding: 8px 0 4px;
647
+ }
648
+
649
+ .ig-empty-title {
650
+ margin: 0;
651
+ font-size: 1rem;
652
+ font-weight: 600;
653
+ color: var(--text-primary-color);
654
+ }
655
+
656
+ .ig-empty-copy {
657
+ margin: 0;
658
+ font-size: 0.875rem;
659
+ line-height: 1.45;
660
+ color: var(--text-secondary-color);
661
+ }
662
+
663
+ .ig-connect:hover {
664
+ background: var(--bg-secondary-color, #f5f5f5);
665
+ border-style: solid;
666
+ }
667
+
668
+ .ig-connect:disabled {
669
+ opacity: 0.6;
670
+ cursor: not-allowed;
671
+ }
672
+
673
+ .ig-connect-copy {
674
+ display: flex;
675
+ flex-direction: column;
676
+ gap: 2px;
677
+ min-width: 0;
678
+ }
679
+
680
+ .ig-connect-title {
681
+ font-size: 0.875rem;
682
+ font-weight: 600;
683
+ color: var(--text-primary-color);
684
+ }
685
+
686
+ .ig-connect-sub {
687
+ font-size: 0.75rem;
688
+ color: var(--text-secondary-color);
689
+ line-height: 1.35;
690
+ }
691
+
692
+ .ig-skeleton {
693
+ display: flex;
694
+ align-items: center;
695
+ gap: 12px;
696
+ padding: 14px;
697
+ border-radius: 12px;
698
+ border: 1px solid var(--border-subtle, color-mix(in srgb, var(--text-primary-color) 10%, transparent));
699
+ }
700
+
701
+ .ig-skeleton-mark {
702
+ width: 40px;
703
+ height: 40px;
704
+ border-radius: 12px;
705
+ background: color-mix(in srgb, var(--text-secondary-color) 12%, transparent);
706
+ }
707
+
708
+ .ig-skeleton-lines {
709
+ flex: 1;
710
+ display: flex;
711
+ flex-direction: column;
712
+ gap: 8px;
713
+ }
714
+
715
+ .ig-skeleton-line {
716
+ height: 10px;
717
+ width: 42%;
718
+ border-radius: 999px;
719
+ background: color-mix(in srgb, var(--text-secondary-color) 12%, transparent);
720
+ }
721
+
722
+ .ig-skeleton-line.wide {
723
+ width: 68%;
724
+ }
725
+
726
+ .bottom-actions {
727
+ margin-top: auto;
728
+ display: flex;
729
+ flex-direction: column;
730
+ gap: 2px;
731
+ padding-top: 16px;
732
+ border-top: 1px solid var(--border-subtle, #eaeaea);
733
+ flex-shrink: 0;
734
+ }
735
+
736
+ .action-button {
737
+ display: flex;
738
+ align-items: center;
739
+ gap: 12px;
740
+ background: none;
741
+ border: none;
742
+ cursor: pointer;
743
+ color: var(--text-primary-color, #111111);
744
+ font-size: 15px;
745
+ line-height: 1.3;
746
+ padding: 12px 8px;
747
+ text-align: left;
748
+ width: 100%;
749
+ box-sizing: border-box;
750
+ border-radius: 8px;
751
+ }
752
+
753
+ .action-button:hover {
754
+ background-color: var(--bg-secondary-color, #f5f5f5);
755
+ }
756
+
757
+ .action-button svg {
758
+ width: 18px;
759
+ height: 18px;
760
+ min-width: 18px;
761
+ flex-shrink: 0;
762
+ stroke: currentColor;
763
+ }
764
+ `;
765
+ }
766
+
767
+ customElements.define('instagram-accounts-panel', InstagramAccountsPanel);
768
+
769
+ class ChatLoadingPlaceholder extends h {
770
+ static properties = {
771
+ progress: { type: Number },
772
+ loadingStatus: { type: String }
773
+ };
774
+
775
+ static styles = i`
776
+ .loading-container {
777
+ position: fixed;
778
+ top: 0;
779
+ left: 0;
780
+ width: 100%;
781
+ height: 100%;
782
+ background-color: var(--bg-secondary-color);
783
+ display: flex;
784
+ flex-direction: column;
785
+ justify-content: center;
786
+ align-items: center;
787
+ z-index: 1000;
788
+ }
789
+
790
+ .whatsapp-logo {
791
+ margin-bottom: 30px;
792
+ }
793
+
794
+ .progress-container {
795
+ width: 250px;
796
+ height: 4px;
797
+ background-color: var(--bg-primary-color);
798
+ border-radius: 2px;
799
+ margin-bottom: 10px;
800
+ overflow: hidden;
801
+ }
802
+
803
+ .progress-bar {
804
+ height: 100%;
805
+ background-color: var(--base-color);
806
+ border-radius: 2px;
807
+ transition: width 0.3s ease;
808
+ }
809
+
810
+ .progress-text {
811
+ font-size: 14px;
812
+ color: var(--text-primary-color);
813
+ }
814
+
815
+ .status-text {
816
+ margin-top: 15px;
817
+ font-size: 16px;
818
+ color: var(--text-secondary-color);
819
+ }
820
+ `;
821
+
822
+ constructor() {
823
+ super();
824
+ this.progress = 0;
825
+ this.loadingStatus = 'Initializing...';
826
+ }
827
+
828
+ render() {
829
+ return ke`
830
+ <div class="loading-container">
831
+
832
+ <div class="progress-container">
833
+ <div class="progress-bar" style="width: ${this.progress}%"></div>
834
+ </div>
835
+ <div class="progress-text">${this.progress}%</div>
836
+ <div class="status-text">${WEB_CONTENT.PLACEHOLDER_CONTENT.LOADING}</div>
837
+ </div>
838
+ `;
839
+ }
840
+ }
841
+
842
+ // Define the element
843
+ customElements.define('chat-loading-placeholder', ChatLoadingPlaceholder);
844
+
845
+ const getTotalUnreadConversationsCount = async () => {
846
+ const response = await M.getInstance().Conversation.getConversationUnreadCount();
847
+ return response?.count;
848
+ };
849
+
850
+ const { state, onChange } = createStore({
851
+ totalUnreadCount: 0
852
+ });
853
+ const unreadCountStore = {
854
+ state,
855
+ // Update total unread count
856
+ updateTotalUnreadCount(count) {
857
+ state.totalUnreadCount = count;
858
+ },
859
+ // Get current unread count
860
+ getTotalUnreadCount() {
861
+ return state.totalUnreadCount;
862
+ },
863
+ // Subscribe to changes
864
+ onChange: onChange
865
+ };
866
+
867
+ const webChatCss = ":host{display:flex;flex:1;font-family:var(--font-sans);color:var(--text-primary-color)}web-chat{display:flex;flex:1}.isometrik-quickchat{display:flex;height:100dvh;width:100%;min-height:0;overflow:hidden;background:var(--bg-primary-color);color:var(--text-primary-color)}.isometrik-quickchat.is-resizing{cursor:col-resize;user-select:none}.isometrik-quickchat.is-resizing *{cursor:col-resize !important;user-select:none !important}.chat-sidebar-container{position:relative;flex:0 0 calc(68px + var(--sidebar-width));width:calc(68px + var(--sidebar-width));max-width:calc(68px + var(--sidebar-width));height:100%;min-height:0;min-width:0;overflow:visible;transition:transform var(--duration) var(--ease-out);border-right:1px solid var(--border-subtle);display:flex;flex-direction:row;background-color:var(--bg-primary-color);box-shadow:none;z-index:2}.isometrik-quickchat.is-instagram-gate .chat-sidebar-container.is-full-gate{flex:1 1 auto;width:100%;max-width:none;border-right:none}.isometrik-quickchat.is-instagram-gate .sidebar-tab{max-width:480px;margin:0 auto;width:100%}.chat-sidebar-container.is-resizing{transition:none}.sidebar-tab{flex:1 1 auto;width:auto;height:100%;min-height:0;min-width:0;overflow:hidden;background-color:var(--bg-primary-color)}.sidebar-resize-handle{position:absolute;top:0;right:-5px;width:10px;height:100%;z-index:30;cursor:col-resize;display:flex;align-items:center;justify-content:center;touch-action:none}.sidebar-resize-handle::before{content:'';position:absolute;top:0;bottom:0;left:50%;width:1px;transform:translateX(-50%);background:transparent;transition:background-color var(--duration) var(--ease-out), width 120ms var(--ease-out)}.sidebar-resize-grip{width:3px;height:32px;border-radius:999px;background:var(--border, #eaeaea);opacity:0;transition:opacity var(--duration) var(--ease-out), background-color var(--duration) var(--ease-out), height 120ms var(--ease-out);pointer-events:none}.sidebar-resize-handle:hover::before,.sidebar-resize-handle.active::before{width:2px;background:var(--text-primary-color)}.sidebar-resize-handle:hover .sidebar-resize-grip,.sidebar-resize-handle.active .sidebar-resize-grip{opacity:1;background:var(--text-primary-color);height:40px}.chat-body-container{flex:1;display:flex;flex-direction:column;min-width:0;background-color:var(--bg-secondary-color)}.noChatSelectedPlaceholder{height:100%;width:100%;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:0;padding:40px 24px;color:var(--text-secondary-color);background-image:radial-gradient(circle, var(--border-subtle) 1px, transparent 1.2px);background-size:22px 22px}.empty-mark{position:relative;width:92px;height:68px;margin-bottom:24px}.empty-mark span{position:absolute;width:56px;height:38px;background:var(--primary, #000000)}.empty-mark span:first-child{left:0;top:0;opacity:0.18;border-radius:18px 18px 4px 18px}.empty-mark span:last-child{right:0;bottom:0;border-radius:18px 18px 18px 4px}.noChatSelectedPlaceholder h2{margin:0;font-size:24px;font-weight:600;letter-spacing:-0.04em;color:var(--text-primary-color);line-height:1.15}.noChatSelectedPlaceholder p{margin:8px 0 0;font-size:14px;line-height:1.5;max-width:34ch;text-align:center;color:var(--text-secondary-color)}.empty-cta{margin-top:20px;border:none;cursor:pointer;font-family:inherit;font-size:13px;font-weight:600;color:var(--primary-foreground, #ffffff);background:var(--primary, #000000);border-radius:var(--radius-pill);padding:10px 18px;transition:transform 120ms var(--ease-out), filter 180ms var(--ease-out)}.empty-cta:hover{filter:brightness(1.06)}.empty-cta:active{transform:scale(0.98)}.chat-sidebar-right{flex:0 0 var(--sidebar-width);width:var(--sidebar-width);max-width:var(--sidebar-width);min-width:0;overflow:hidden;transition:transform var(--duration) var(--ease-out);border-left:1px solid var(--border-subtle);background-color:var(--bg-primary-color)}.loaderoverlay{width:100%;position:absolute;margin:auto;background:var(--overlay-color);z-index:1400}.loadingPlaceholder{height:100%;width:100%;z-index:12839283}.back-button{display:none;padding:0;background:none;border:none;cursor:pointer;align-items:center;gap:4px}spinner-loader{display:flex;height:100dvh}.blockMessageContainer{text-align:center;padding:16px 0;margin:0;background-color:var(--bg-primary-color);color:var(--text-secondary-color);font-size:var(--text-secondary-size);border-top:1px solid var(--border-subtle)}@media (max-width: 768px){.isometrik-quickchat{position:relative;overflow:hidden}.sidebar-resize-handle{display:none}.chat-sidebar-right{width:100%;max-width:none;flex:none;position:fixed;z-index:10;border-right:1px solid var(--border-subtle)}.chat-sidebar-container{width:100%;height:100%;position:absolute;left:0;top:0;transform:translateX(0);transition:transform var(--duration) var(--ease-out);z-index:2;flex:none;max-width:none;min-width:100% !important;overflow:hidden;box-shadow:none}.chat-sidebar-container.hidden{transform:translateX(-100%)}.chat-body-container{width:100%;height:100%;position:absolute;left:0;top:0;transform:translateX(100%);transition:transform var(--duration) var(--ease-out);z-index:1}.chat-body-container.hidden{transform:translateX(0)}.chat-body-container.show{transform:translateX(0);z-index:3}.back-button{display:flex;align-items:center;justify-content:center;position:absolute;right:3rem;z-index:10;top:2.3rem}}";
868
+ const WebChatStyle0 = webChatCss;
869
+
870
+ const WebChat = class {
871
+ constructor(hostRef) {
872
+ registerInstance(this, hostRef);
873
+ this.unreadMessageCountUpdated = createEvent(this, "unreadMessageCountUpdated", 7);
874
+ this.conversationNotFound = createEvent(this, "conversationNotFound", 7);
875
+ this.messageReadStatusUpdated = createEvent(this, "messageReadStatusUpdated", 7);
876
+ this.chatBodyRef = null;
877
+ this.conversationDetailsInterval = null;
878
+ this.SIDEBAR_MIN = 280;
879
+ this.SIDEBAR_MAX = 560;
880
+ this.SIDEBAR_RAIL = 68;
881
+ this.SIDEBAR_WIDTH_KEY = 'isometrik-sidebar-list-width';
882
+ this.sidebarResizeOriginLeft = 0;
883
+ this.clampSidebarWidth = (width) => {
884
+ const maxByViewport = Math.floor(window.innerWidth * 0.55) - this.SIDEBAR_RAIL;
885
+ const max = Math.min(this.SIDEBAR_MAX, Math.max(this.SIDEBAR_MIN, maxByViewport));
886
+ return Math.min(Math.max(Math.round(width), this.SIDEBAR_MIN), max);
887
+ };
888
+ this.onSidebarResizeMove = (e) => {
889
+ if (!this.isResizingSidebar)
890
+ return;
891
+ this.sidebarListWidth = this.clampSidebarWidth(e.clientX - this.sidebarResizeOriginLeft - this.SIDEBAR_RAIL);
892
+ };
893
+ this.onSidebarResizeEnd = () => {
894
+ if (!this.isResizingSidebar)
895
+ return;
896
+ this.isResizingSidebar = false;
897
+ try {
898
+ localStorage.setItem(this.SIDEBAR_WIDTH_KEY, String(this.sidebarListWidth));
899
+ }
900
+ catch (_) { }
901
+ window.removeEventListener('pointermove', this.onSidebarResizeMove);
902
+ window.removeEventListener('pointerup', this.onSidebarResizeEnd);
903
+ };
904
+ this.startSidebarResize = (e) => {
905
+ var _a;
906
+ if (this.isMobileView)
907
+ return;
908
+ e.preventDefault();
909
+ const handle = e.currentTarget;
910
+ const sidebar = handle.closest('.chat-sidebar-container');
911
+ this.sidebarResizeOriginLeft = (_a = sidebar === null || sidebar === void 0 ? void 0 : sidebar.getBoundingClientRect().left) !== null && _a !== void 0 ? _a : 0;
912
+ this.isResizingSidebar = true;
913
+ window.addEventListener('pointermove', this.onSidebarResizeMove);
914
+ window.addEventListener('pointerup', this.onSidebarResizeEnd);
915
+ };
916
+ this.handleReplyMessage = (e) => {
917
+ this.replyMessage = e.detail;
918
+ };
919
+ this.handleremoveReplyMessage = () => {
920
+ this.replyMessage = null;
921
+ };
922
+ this.handleMessageSearchTextChange = (e) => {
923
+ this.messageSearchText = e.detail;
924
+ };
925
+ this.getCookie = (name) => {
926
+ const value = `; ${document.cookie}`;
927
+ const parts = value.split(`; ${name}=`);
928
+ if (parts.length === 2)
929
+ return parts.pop().split(';').shift();
930
+ };
931
+ // Auth from chat-creds (no login UI)
932
+ this.userTokenFromCookie = CHAT_CREDS.userToken;
933
+ this.isometrikUserIdFromCookie = CHAT_CREDS.isometrikUserId;
934
+ this.clearConversationState = () => {
935
+ this.allConversationList = [];
936
+ this.selectedConversationId = null;
937
+ this.initialConversationIdFromURL = '';
938
+ this.allMessages = [];
939
+ this.selectConversationMessages = [];
940
+ this.conversationMetaData = {};
941
+ this.selctConversationMetaData = {};
942
+ this.allAttachments = [];
943
+ this.selectConverSationAttachments = [];
944
+ this.unreadConversationsCount = 0;
945
+ this.hasMoreConversations = false;
946
+ this.isContactInfoOpen = false;
947
+ this.isProfileInfoOpen = false;
948
+ this.showRightSideBar = false;
949
+ unreadCountStore.updateTotalUnreadCount(0);
950
+ if (typeof window !== 'undefined') {
951
+ const url = new URL(window.location.href);
952
+ url.searchParams.delete('conversation');
953
+ url.searchParams.delete('groupcast');
954
+ window.history.replaceState({}, '', url);
955
+ }
956
+ };
957
+ this.applyInstagramAccounts = (accounts = [], options = {}) => {
958
+ const connected = hasConnectedInstagramAccounts(accounts);
959
+ const wasConnected = this.isInstagramConnected;
960
+ this.isInstagramConnected = connected;
961
+ if (!connected) {
962
+ this.clearConversationState();
963
+ this.activeTab = 'Accounts';
964
+ return;
965
+ }
966
+ // After a live connect (not initial boot), switch to Chat and fetch conversations.
967
+ if (!options.bootstrap && !wasConnected) {
968
+ this.activeTab = 'Chat';
969
+ void this.loadConversationsAfterInstagramConnect();
970
+ }
971
+ };
972
+ this.refreshInstagramConnectionGate = async () => {
973
+ const data = await getSocialAccounts({ platform: 'instagram' });
974
+ this.applyInstagramAccounts((data === null || data === void 0 ? void 0 : data.accounts) || [], { bootstrap: true });
975
+ };
976
+ this.loadConversationsAfterInstagramConnect = async () => {
977
+ if (!this.isInstagramConnected)
978
+ return;
979
+ try {
980
+ this.isConversationLoading = true;
981
+ const unreadCount = await getTotalUnreadConversationsCount();
982
+ unreadCountStore.updateTotalUnreadCount(unreadCount);
983
+ this.unreadConversationsCount = unreadCount;
984
+ unreadCountStore.onChange('totalUnreadCount', value => {
985
+ this.unreadConversationsCount = value;
986
+ });
987
+ await this.getConversations();
988
+ }
989
+ catch (error) {
990
+ console.error('Failed to load conversations after Instagram connect:', error);
991
+ }
992
+ finally {
993
+ this.isConversationLoading = false;
994
+ }
995
+ };
996
+ this.handleInstagramAccountsChange = (accounts = []) => {
997
+ this.applyInstagramAccounts(accounts);
998
+ };
999
+ this.openChatTab = () => {
1000
+ if (this.isInstagramConnected) {
1001
+ this.activeTab = 'Chat';
1002
+ return;
1003
+ }
1004
+ this.activeTab = 'Accounts';
1005
+ };
1006
+ this.closeAccountsDrawer = () => {
1007
+ this.activeTab = this.isInstagramConnected ? 'Chat' : 'Accounts';
1008
+ };
1009
+ /// for get user details start
1010
+ this.getUserDetails = async () => {
1011
+ var _a, _b, _c;
1012
+ try {
1013
+ const res = await M.getInstance().user.getUserDetails();
1014
+ const userDetails = {
1015
+ //@ts-ignore
1016
+ userId: (res === null || res === void 0 ? void 0 : res.userId) || '',
1017
+ userIdentifier: (res === null || res === void 0 ? void 0 : res.userIdentifier) || '',
1018
+ //@ts-ignore
1019
+ firstName: ((_a = res === null || res === void 0 ? void 0 : res.metaData) === null || _a === void 0 ? void 0 : _a.firstName) || '',
1020
+ //@ts-ignore
1021
+ lastName: ((_b = res === null || res === void 0 ? void 0 : res.metaData) === null || _b === void 0 ? void 0 : _b.lastName) || '',
1022
+ updatedAt: (res === null || res === void 0 ? void 0 : res.updatedAt) || '',
1023
+ userName: (res === null || res === void 0 ? void 0 : res.userName) || '',
1024
+ online: (res === null || res === void 0 ? void 0 : res.online) || '',
1025
+ userProfileImageUrl: (res === null || res === void 0 ? void 0 : res.userProfileImageUrl) || '',
1026
+ //@ts-ignore
1027
+ profilePic: ((_c = res === null || res === void 0 ? void 0 : res.metaData) === null || _c === void 0 ? void 0 : _c.profilePic) || '',
1028
+ };
1029
+ this.userMetaData = userDetails;
1030
+ }
1031
+ catch (error) {
1032
+ console.error(error, 'getUserDetails fetching error');
1033
+ }
1034
+ };
1035
+ /// for get user details end
1036
+ /** Completes Instagram OAuth when redirected back with zernioAccountId. */
1037
+ this.handleSocialConnectCallback = async () => {
1038
+ // Popup return: hand off to opener and close this window
1039
+ if (notifyOpenerIfSocialPopupCallback())
1040
+ return;
1041
+ const payload = parseSocialCallbackParams();
1042
+ if (!payload)
1043
+ return;
1044
+ try {
1045
+ await connectSocialAccountCallback({
1046
+ platform: payload.platform || 'instagram',
1047
+ username: payload.username || '',
1048
+ displayName: payload.displayName || '',
1049
+ loginMethod: 'instagram_login',
1050
+ });
1051
+ showToast({
1052
+ message: 'Instagram connected',
1053
+ type: 'success',
1054
+ position: 'bottom-right',
1055
+ });
1056
+ this.activeTab = 'Chat';
1057
+ }
1058
+ catch (error) {
1059
+ console.error('Social connect callback failed:', error);
1060
+ showToast({
1061
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to connect Instagram',
1062
+ type: 'error',
1063
+ position: 'bottom-right',
1064
+ });
1065
+ }
1066
+ finally {
1067
+ clearSocialCallbackParamsFromUrl();
1068
+ }
1069
+ };
1070
+ //get all Conversation
1071
+ this.getConversations = async (skip = 0, searchTag = null, showLoader = false) => {
1072
+ this.hasMoreConversations = true;
1073
+ const queryParamsGetConversations = {
1074
+ limit: 20,
1075
+ skip: skip,
1076
+ includeMembers: true,
1077
+ };
1078
+ if (searchTag) {
1079
+ queryParamsGetConversations['searchTag'] = searchTag;
1080
+ }
1081
+ if (showLoader) {
1082
+ this.isLoadingConversationList = true;
1083
+ }
1084
+ try {
1085
+ const res = await M.getInstance().Conversation.getConversations(queryParamsGetConversations);
1086
+ const uniqueConversations = res.conversations.filter(newConv => !this.allConversationList.some(existingConv => existingConv.conversationId === newConv.conversationId));
1087
+ this.allConversationList = [...this.allConversationList, ...uniqueConversations];
1088
+ }
1089
+ catch (error) {
1090
+ console.error('getConversations fetching error', error);
1091
+ if ((error === null || error === void 0 ? void 0 : error.status) === 404 || (error === null || error === void 0 ? void 0 : error.statusCode) === 404) {
1092
+ this.hasMoreConversations = false;
1093
+ }
1094
+ }
1095
+ finally {
1096
+ this.isLoadingConversationList = false;
1097
+ }
1098
+ };
1099
+ //get all Conversation end
1100
+ this.getGroupCastConversationDetails = async (groupcastId) => {
1101
+ var _a;
1102
+ try {
1103
+ const res = await getGroupcast({ ids: groupcastId });
1104
+ this.conversationMetaData = (_a = res === null || res === void 0 ? void 0 : res.groupcasts) === null || _a === void 0 ? void 0 : _a[0];
1105
+ }
1106
+ catch (error) {
1107
+ console.error(error, 'GroupCast details fetching error');
1108
+ }
1109
+ };
1110
+ this.getUserConversationDetails = async (conversationId) => {
1111
+ const queryParamsGetConversationDetails = {
1112
+ conversationId: conversationId || this.selectedConversationId,
1113
+ includeMembers: true,
1114
+ };
1115
+ try {
1116
+ const res = await M.getInstance().Conversation.getConversationDetails(queryParamsGetConversationDetails, conversationId || this.selectedConversationId);
1117
+ if (conversationId) {
1118
+ this.selctConversationMetaData = res.conversationDetails;
1119
+ }
1120
+ else {
1121
+ this.conversationMetaData = res.conversationDetails;
1122
+ }
1123
+ return res.conversationDetails;
1124
+ }
1125
+ catch (error) {
1126
+ console.error(error, 'getConversationDetails fetching error');
1127
+ }
1128
+ };
1129
+ /// for get all messages start
1130
+ this.getMessages = async (skip, conversationId) => {
1131
+ this.isMessagesLoading = true;
1132
+ this.isScrollToTop = true;
1133
+ this.isMessageLimitEnd = false;
1134
+ try {
1135
+ const res = await M.getInstance().message.getMessages({ conversationId: conversationId || this.selectedConversationId, limit: 20, skip: skip });
1136
+ if (skip == 0) {
1137
+ if (conversationId) {
1138
+ this.selectConversationMessages = [...res.messages.reverse()];
1139
+ }
1140
+ else {
1141
+ this.allMessages = [...res.messages.reverse()];
1142
+ }
1143
+ }
1144
+ else {
1145
+ this.allMessages = [...res.messages.reverse(), ...this.allMessages];
1146
+ }
1147
+ this.allMessages.forEach(message => {
1148
+ if (message.hasOwnProperty('attachments') && message.attachments !== null) ;
1149
+ });
1150
+ }
1151
+ catch (error) {
1152
+ if ((error === null || error === void 0 ? void 0 : error.status) === 404 || (error === null || error === void 0 ? void 0 : error.statusCode) === 404) {
1153
+ this.isMessageLimitEnd = true;
1154
+ }
1155
+ }
1156
+ finally {
1157
+ this.isMessagesLoading = false;
1158
+ }
1159
+ };
1160
+ ///for get all messages end
1161
+ //for get unread Messages Count
1162
+ this.getMessageUnreadCount = async () => {
1163
+ try {
1164
+ const res = await M.getInstance().message.getUnreadCount({ converationId: this.selectedConversationId });
1165
+ this.unreadMessageCountFromApi = res.count; // Update state with unread count
1166
+ }
1167
+ catch (error) {
1168
+ console.error('Error while getting unread count', error);
1169
+ }
1170
+ };
1171
+ // for get unread Messages Count END
1172
+ this.getMessagesByQuery = async (searchText) => {
1173
+ const queryParamForMessagesSearch = {
1174
+ conversationId: this.selectedConversationId,
1175
+ searchTag: searchText,
1176
+ skip: 0,
1177
+ limit: 20,
1178
+ };
1179
+ this.isLoadingMessage = true;
1180
+ try {
1181
+ const res = await M.getInstance().message.getMessages(queryParamForMessagesSearch);
1182
+ this.searchedMessageDetails = res.messages;
1183
+ }
1184
+ catch (error) {
1185
+ this.searchedMessageDetails = [];
1186
+ console.error('Error while searching messages in a chat', error);
1187
+ }
1188
+ finally {
1189
+ this.isLoadingMessage = false;
1190
+ }
1191
+ };
1192
+ this.getAllLinks = async (selectedConversationIDForAttachments) => {
1193
+ const queryParamForGetAllAttachments = {
1194
+ conversationId: selectedConversationIDForAttachments,
1195
+ customTypes: 'AttachmentMessage:Link',
1196
+ };
1197
+ try {
1198
+ const res = await M.getInstance().message.getMessages(queryParamForGetAllAttachments);
1199
+ this.allLinks = [...res.messages];
1200
+ }
1201
+ catch (error) {
1202
+ console.error('Error while fetching all the links for a particular conversation', error);
1203
+ this.allLinks = [];
1204
+ }
1205
+ };
1206
+ this.getGroupcastMembers = async (groupcastId) => {
1207
+ try {
1208
+ const res = await getGroupcastMembers({ groupcastId });
1209
+ this.groupcastMembers = res === null || res === void 0 ? void 0 : res.members;
1210
+ }
1211
+ catch (error) {
1212
+ console.error('Error while fetching all the links for a particular conversation', error);
1213
+ this.groupcastMembers = [];
1214
+ }
1215
+ };
1216
+ this.getAllLinksCount = async (selectedConversationIDForAttachments) => {
1217
+ const queryParamForGetAllAttachments = {
1218
+ conversationId: selectedConversationIDForAttachments,
1219
+ customTypes: 'AttachmentMessage:Link,AttachmentMessage:Multiple,AttachmentMessage:Image,AttachmentMessage:Video,AttachmentMessage:Audio,AttachmentMessage:File',
1220
+ };
1221
+ try {
1222
+ const res = await M.getInstance().message.getMessagesCount(queryParamForGetAllAttachments);
1223
+ this.allLinksCount = res.messagesCount;
1224
+ }
1225
+ catch (error) {
1226
+ console.error('Error while fetching all the links for a particular conversation', error);
1227
+ this.allLinksCount = 0;
1228
+ }
1229
+ };
1230
+ this.getAllAttachments = async (selectedConversationIDForAttachments, from) => {
1231
+ const queryParamForGetAllAttachments = {
1232
+ conversationId: selectedConversationIDForAttachments,
1233
+ customTypes: 'AttachmentMessage:Media,AttachmentMessage:Multiple',
1234
+ };
1235
+ this.loadingMediaGallery = true;
1236
+ this.allAttachments = [];
1237
+ this.selectConverSationAttachments = [];
1238
+ try {
1239
+ //@ts-ignore
1240
+ const res = await M.getInstance().message.getMessages(queryParamForGetAllAttachments);
1241
+ if (Array.isArray(res.messages)) {
1242
+ const filteredMessages = res.messages.filter(message => {
1243
+ if (!message.attachments || !Array.isArray(message.attachments)) {
1244
+ return false;
1245
+ }
1246
+ const validAttachments = message.attachments.filter(attachment => attachment.mimeType && !attachment.mimeType.startsWith('application'));
1247
+ return validAttachments.length > 0;
1248
+ });
1249
+ if (from === 'Profile-info') {
1250
+ this.selectConverSationAttachments = [...filteredMessages];
1251
+ }
1252
+ else {
1253
+ this.allAttachments = [...filteredMessages];
1254
+ }
1255
+ }
1256
+ }
1257
+ catch (error) {
1258
+ console.error('Error while fetching all the attachments for a particular conversation', error);
1259
+ this.allAttachments = [];
1260
+ this.selectConverSationAttachments = [];
1261
+ }
1262
+ finally {
1263
+ this.loadingMediaGallery = false;
1264
+ }
1265
+ };
1266
+ // for clear all messages in a conversation for self
1267
+ this.clearConversation = async (conversationId) => {
1268
+ try {
1269
+ // Call the API to clear the conversation
1270
+ await M.getInstance().Conversation.deleteConversationLocal({
1271
+ conversationId: conversationId || this.selectedConversationId,
1272
+ });
1273
+ // Clear messages from local state
1274
+ this.allMessages = [];
1275
+ // Update the conversation list to remove the last message
1276
+ this.allConversationList = this.allConversationList.map(conversation => {
1277
+ if (conversation.conversationId === this.selectedConversationId) {
1278
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: '', updatedAt: Date.now() }) });
1279
+ }
1280
+ return conversation;
1281
+ });
1282
+ }
1283
+ catch (error) {
1284
+ console.error('Error while clearing conversation:', error);
1285
+ }
1286
+ finally {
1287
+ drawerDialogService.closeDialog('confirm-dialog');
1288
+ }
1289
+ };
1290
+ this.deleteConversation = async (conversationId) => {
1291
+ try {
1292
+ await M.getInstance().Conversation.deleteConversationClear({
1293
+ conversationId: conversationId,
1294
+ });
1295
+ // Check if the deleted conversation ID is the same as the selected conversation ID
1296
+ if (this.selectedConversationId === conversationId) {
1297
+ // Remove the conversation ID from the URL
1298
+ const url = new URL(window.location.href);
1299
+ url.searchParams.delete('conversation');
1300
+ window.history.pushState({}, '', url);
1301
+ // Reset the selected conversation ID
1302
+ this.selectedConversationId = null;
1303
+ this.showSidebar = true; // Show sidebar if no conversation is selected
1304
+ }
1305
+ // Remove the conversation from the local state
1306
+ this.allConversationList = this.allConversationList.filter(conversation => conversation.conversationId !== conversationId);
1307
+ }
1308
+ catch (error) {
1309
+ console.error('Error while deleting the chat', error);
1310
+ }
1311
+ finally {
1312
+ drawerDialogService.closeDialog('confirm-dialog');
1313
+ }
1314
+ };
1315
+ this.blockUser = async (conversationId, userName) => {
1316
+ try {
1317
+ await M.getInstance().user.postUserBlock({
1318
+ opponentId: conversationId,
1319
+ });
1320
+ this.isBlocked = null;
1321
+ showToast({
1322
+ message: `${userName} blocked`,
1323
+ type: 'info',
1324
+ duration: 3000,
1325
+ position: 'bottom-left',
1326
+ });
1327
+ }
1328
+ catch (error) {
1329
+ this.isConversationLoading = false;
1330
+ console.error(`Failed to block user with ID ${conversationId}:`, error);
1331
+ }
1332
+ finally {
1333
+ drawerDialogService.closeDialog('confirm-dialog');
1334
+ }
1335
+ };
1336
+ this.unblockUser = async (conversationId, userName) => {
1337
+ try {
1338
+ await M.getInstance().user.postUserUnblock({
1339
+ opponentId: conversationId,
1340
+ });
1341
+ this.isBlocked = null;
1342
+ showToast({
1343
+ message: `${userName} unblocked`,
1344
+ type: 'success',
1345
+ duration: 3000,
1346
+ position: 'bottom-left',
1347
+ });
1348
+ }
1349
+ catch (error) {
1350
+ this.isConversationLoading = false;
1351
+ console.error(`Failed to unblock user with ID ${conversationId}:`, error);
1352
+ }
1353
+ finally {
1354
+ drawerDialogService.closeDialog('confirm-dialog');
1355
+ }
1356
+ };
1357
+ this.changeScrollToBottomState = (newState) => {
1358
+ this.isScrollToBottom = newState;
1359
+ };
1360
+ this.changeScrollToTopState = (newState) => {
1361
+ this.isScrollToTop = newState;
1362
+ };
1363
+ this.updateSkip = () => {
1364
+ if (!this.isMessageLimitEnd) {
1365
+ this.skip += 20;
1366
+ }
1367
+ };
1368
+ this.updateAllMessages = (newMessages) => {
1369
+ this.allMessages = newMessages;
1370
+ };
1371
+ this.refetchMessages = () => {
1372
+ this.isScrollToBottom = true;
1373
+ this.isMessageLimitEnd = true;
1374
+ this.messageAction = { action: '', initiator: false };
1375
+ this.skip = 0;
1376
+ this.allMessages = [];
1377
+ this.getMessages(0);
1378
+ this.getMessageAction();
1379
+ };
1380
+ this.changeMessageSendingState = (newState) => {
1381
+ this.isMessageSending = newState;
1382
+ };
1383
+ this.getMessageAction = () => {
1384
+ var _a, _b, _c, _d, _e;
1385
+ const lastMessage = this.isProfileInfoOpen ? (_a = this.selectConversationMessages) === null || _a === void 0 ? void 0 : _a[((_b = this.selectConversationMessages) === null || _b === void 0 ? void 0 : _b.length) - 1] : (_c = this.allMessages) === null || _c === void 0 ? void 0 : _c[((_d = this.allMessages) === null || _d === void 0 ? void 0 : _d.length) - 1];
1386
+ if (lastMessage && ['userBlockConversation', 'userUnblockConversation'].includes(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.action)) {
1387
+ this.messageAction = { action: lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.action, initiator: (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.initiatorId) == ((_e = this.userMetaData) === null || _e === void 0 ? void 0 : _e.userId) };
1388
+ }
1389
+ };
1390
+ this.deleteMessageFromSelf = async (payload) => {
1391
+ try {
1392
+ await M.getInstance().message.deleteMessageSelf(payload);
1393
+ this.allMessages = this.allMessages.filter((message) => message.messageId !== payload.messageIds);
1394
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1395
+ var _a, _b, _c;
1396
+ if (conversation.conversationId === payload.conversationId && ((_a = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.messageId) === payload.messageIds) {
1397
+ const remainingMessages = this.allMessages.filter(msg => msg.conversationId === payload.conversationId).sort((a, b) => (a.sentAt || 0) - (b.sentAt || 0));
1398
+ const lastMessage = remainingMessages.length > 0 ? remainingMessages[remainingMessages.length - 1] : null;
1399
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: lastMessage
1400
+ ? Object.assign(Object.assign({}, lastMessage), { body: lastMessage.body, updatedAt: lastMessage.sentAt || Date.now(), action: lastMessage.action || '', senderName: (_b = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _b === void 0 ? void 0 : _b.userName, senderId: (_c = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _c === void 0 ? void 0 : _c.userId }) : null });
1401
+ }
1402
+ return conversation;
1403
+ }));
1404
+ }
1405
+ catch (error) {
1406
+ showToast({
1407
+ type: 'error',
1408
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to delete the message',
1409
+ position: 'bottom-right',
1410
+ });
1411
+ }
1412
+ finally {
1413
+ drawerDialogService.closeDialog('delete-message');
1414
+ }
1415
+ };
1416
+ this.deleteMeassageFromEveryOne = async (payload) => {
1417
+ try {
1418
+ await M.getInstance().message.deleteMessagesEveryone(payload);
1419
+ this.allMessages = this.allMessages.filter((message) => message.messageId !== payload.messageIds);
1420
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1421
+ var _a, _b, _c;
1422
+ if (conversation.conversationId === payload.conversationId && ((_a = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.messageId) === payload.messageIds) {
1423
+ const remainingMessages = this.allMessages.filter(msg => msg.conversationId === payload.conversationId).sort((a, b) => (a.sentAt || 0) - (b.sentAt || 0));
1424
+ const lastMessage = remainingMessages.length > 0 ? remainingMessages[remainingMessages.length - 1] : null;
1425
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: lastMessage
1426
+ ? Object.assign(Object.assign({}, lastMessage), { body: lastMessage.body, updatedAt: lastMessage.sentAt || Date.now(), action: lastMessage.action || '', senderName: (_b = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _b === void 0 ? void 0 : _b.userName, senderId: (_c = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _c === void 0 ? void 0 : _c.userId }) : null });
1427
+ }
1428
+ return conversation;
1429
+ }));
1430
+ }
1431
+ catch (error) {
1432
+ console.error(error, 'delete all error');
1433
+ showToast({
1434
+ type: 'error',
1435
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to delete the message',
1436
+ position: 'bottom-right',
1437
+ });
1438
+ }
1439
+ finally {
1440
+ drawerDialogService.closeDialog('delete-message');
1441
+ }
1442
+ };
1443
+ this.typingTimeout = null;
1444
+ this.handleChatOpen = () => {
1445
+ this.isChatClosed = false;
1446
+ };
1447
+ this.handleSearchResultClick = async (messageId) => {
1448
+ this.highlightedMessageId = messageId;
1449
+ const messageExists = this.allMessages.some(message => message.messageId === messageId);
1450
+ if (!messageExists) {
1451
+ while (!this.allMessages.some(message => message.messageId === messageId)) {
1452
+ await this.getMessages(this.skip);
1453
+ this.skip += 20;
1454
+ }
1455
+ }
1456
+ // Scroll to the message once it is loaded
1457
+ const chatBody = document.querySelector('web-chat-body');
1458
+ if (chatBody) {
1459
+ // @ts-ignore
1460
+ chatBody.scrollToMessage(messageId);
1461
+ }
1462
+ };
1463
+ this.handleCloseChat = () => {
1464
+ this.selectedConversationId = null;
1465
+ this.showSidebar = true;
1466
+ const url = new URL(window.location.href);
1467
+ url.searchParams.delete('conversation');
1468
+ url.searchParams.delete('groupcast');
1469
+ window.history.pushState({}, '', url.toString());
1470
+ this.activeTab = 'Chat';
1471
+ drawerDialogService.closeDialog('confirm-dialog');
1472
+ };
1473
+ this.updateConversationList = (updatedList) => {
1474
+ // Ensure the list is sorted
1475
+ const sortedList = this.sortConversationsByLatestMessage(updatedList);
1476
+ // Update the state and return the sorted list
1477
+ this.allConversationList = sortedList;
1478
+ return sortedList;
1479
+ };
1480
+ this.getGroupCastContacts = async (skip = 0) => {
1481
+ var _a;
1482
+ this.activeTab = 'GroupCast';
1483
+ if (!this.hasMoreGroupcast || this.isLoadingMoreGroupcast)
1484
+ return;
1485
+ this.isLoadingMoreGroupcast = true;
1486
+ try {
1487
+ const response = await getGroupcast({ skip, limit: 20 });
1488
+ if (((_a = response === null || response === void 0 ? void 0 : response.groupcasts) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1489
+ this.allGroupCastContacts = skip === 0
1490
+ ? response.groupcasts
1491
+ : [...this.allGroupCastContacts, ...response.groupcasts];
1492
+ this.groupcastSkip = skip;
1493
+ }
1494
+ else {
1495
+ this.hasMoreGroupcast = false;
1496
+ }
1497
+ }
1498
+ catch (error) {
1499
+ console.error('Error fetching groupcast contacts:', error);
1500
+ this.hasMoreGroupcast = false;
1501
+ }
1502
+ finally {
1503
+ this.isLoadingMoreGroupcast = false;
1504
+ }
1505
+ };
1506
+ this.name = undefined;
1507
+ this.baseUrl = undefined;
1508
+ this.licenseKey = undefined;
1509
+ this.appSecret = undefined;
1510
+ this.userSecret = undefined;
1511
+ this.userToken = undefined;
1512
+ this.themeUrl = undefined;
1513
+ this.defaultTheme = undefined;
1514
+ this.isometrikUserId = undefined;
1515
+ this.projectId = undefined;
1516
+ this.keysetId = undefined;
1517
+ this.accountId = undefined;
1518
+ this.conversationId = undefined;
1519
+ this.hostUrl = undefined;
1520
+ this.groupcastEnabled = undefined;
1521
+ this.socialRedirectUrl = undefined;
1522
+ this.unreadConversations = [];
1523
+ this.allLinks = undefined;
1524
+ this.allLinksCount = undefined;
1525
+ this.isInitialized = false;
1526
+ this.findUserId = {};
1527
+ this.mqttClient = null;
1528
+ this.mqttInitialized = false;
1529
+ this.isMqttConnected = false;
1530
+ this.allMessages = [];
1531
+ this.selectConversationMessages = [];
1532
+ this.userMetaData = null;
1533
+ this.allConversationList = [];
1534
+ this.conversationMetaData = {};
1535
+ this.selctConversationMetaData = {};
1536
+ this.isMessageLimitEnd = false;
1537
+ this.skip = 0;
1538
+ this.isMessagesLoading = false;
1539
+ this.isMessageSending = false;
1540
+ this.deviceId = '';
1541
+ this.isScrollToBottom = true;
1542
+ this.isScrollToTop = false;
1543
+ this.isConversationLoading = false;
1544
+ this.isLoadingConversationList = false;
1545
+ this.unreadConversationsCount = 0;
1546
+ this.isChatClosed = false;
1547
+ this.isChatMinimized = false;
1548
+ this.isSubscribedToTopic = false;
1549
+ this.isMessageListenerAttached = false;
1550
+ this.isInitialCallDone = false;
1551
+ this.isTyping = false;
1552
+ this.typingUserName = '';
1553
+ this.selectedConversationId = null;
1554
+ this.unreadMessageCount = null;
1555
+ this.unreadMessageCountFromApi = null;
1556
+ this.isLoading = true;
1557
+ this.loadingProgress = 0;
1558
+ this.loadingStatus = 'Initializing...';
1559
+ this.isLoadingMessage = false;
1560
+ this.hasMoreConversations = false;
1561
+ this.eligibleMembers = [];
1562
+ this.membersListSkip = 0;
1563
+ this.hasMoreEligibleMembers = true;
1564
+ this.isMobileView = false;
1565
+ this.showSidebar = false;
1566
+ this.isContactInfoOpen = false;
1567
+ this.isProfileInfoOpen = false;
1568
+ this.isOpenSearchBar = false;
1569
+ this.isChatFilter = false;
1570
+ this.isAllChatButton = true;
1571
+ this.isSidebarHeaderLabel = true;
1572
+ this.sidebarHeaderLabel = 'Chats';
1573
+ this.isSidebarHeaderSearch = true;
1574
+ this.sidebarColor = 'var(--bg-primary-color)';
1575
+ this.sidebarSelectedColor = 'var(--bg-primary-light)';
1576
+ this.messageSearchText = '';
1577
+ this.searchedMessageDetails = [];
1578
+ this.initialConversationIdFromURL = '';
1579
+ this.allAttachments = [];
1580
+ this.selectConverSationAttachments = [];
1581
+ this.highlightedMessageId = null;
1582
+ this.messageAction = { action: '', initiator: false };
1583
+ this.replyMessage = null;
1584
+ this.loadingMediaGallery = false;
1585
+ this.activeTab = 'Chat';
1586
+ this.isInstagramConnected = false;
1587
+ this.showRightSideBar = false;
1588
+ this.conversationIdFromContactinfo = '';
1589
+ this.exitedGroupIds = new Set();
1590
+ this.conversationCountSkip = 0;
1591
+ this.typingConversationId = null;
1592
+ this.newMessageNotification = null;
1593
+ this.isBlocked = null;
1594
+ this.allGroupCastContacts = [];
1595
+ this.toggleTheme = undefined;
1596
+ this.groupcastSkip = 0;
1597
+ this.isLoadingMoreGroupcast = false;
1598
+ this.hasMoreGroupcast = true;
1599
+ this.groupcastMembers = [];
1600
+ this.sidebarListWidth = 360;
1601
+ this.isResizingSidebar = false;
1602
+ }
1603
+ async handleConversationChange() {
1604
+ this.replyMessage = null;
1605
+ this.isBlocked = null;
1606
+ this.conversationMetaData = {};
1607
+ this.allAttachments = [];
1608
+ }
1609
+ checkMobileView() {
1610
+ this.isMobileView = window.innerWidth <= 768;
1611
+ }
1612
+ componentWillLoad() {
1613
+ var _a;
1614
+ // Instagram OAuth return URL — host page where accounts are linked
1615
+ if ((_a = this.socialRedirectUrl) === null || _a === void 0 ? void 0 : _a.trim()) {
1616
+ CHAT_CREDS.socialRedirectUrl = this.socialRedirectUrl.trim();
1617
+ }
1618
+ // OAuth popup return: notify opener ASAP and close (skip full chat boot)
1619
+ if (notifyOpenerIfSocialPopupCallback())
1620
+ return;
1621
+ const urlParams = new URLSearchParams(window.location.search);
1622
+ const isGroupcast = urlParams.has('groupcast');
1623
+ const conversationId = urlParams.get('conversation');
1624
+ const groupcastId = urlParams.get('groupcast');
1625
+ this.initialConversationIdFromURL = isGroupcast ? groupcastId : conversationId;
1626
+ this.isMobileView = window.innerWidth <= 768;
1627
+ this.selectedConversationId = isGroupcast ? groupcastId : conversationId;
1628
+ if (this.isMobileView && (conversationId || groupcastId)) {
1629
+ this.showSidebar = false;
1630
+ }
1631
+ else {
1632
+ this.showSidebar = true;
1633
+ }
1634
+ try {
1635
+ const saved = localStorage.getItem(this.SIDEBAR_WIDTH_KEY);
1636
+ if (saved) {
1637
+ this.sidebarListWidth = this.clampSidebarWidth(parseInt(saved, 10) || 360);
1638
+ }
1639
+ }
1640
+ catch (_) { }
1641
+ }
1642
+ async componentDidLoad() {
1643
+ try {
1644
+ // Device ID
1645
+ // this.loadTheme();
1646
+ try {
1647
+ this.updateLoading(10, 'Getting device ID...');
1648
+ const deviceId = await getDeviceID();
1649
+ this.deviceId = deviceId;
1650
+ }
1651
+ catch (error) {
1652
+ console.error('Error getting device ID:', error);
1653
+ }
1654
+ // Initialize SDK
1655
+ try {
1656
+ this.updateLoading(25, 'Initializing chat SDK...');
1657
+ M.initializeInstance({
1658
+ baseUrl: CHAT_CREDS.baseUrl,
1659
+ licenseKey: CHAT_CREDS.licenseKey,
1660
+ appSecret: CHAT_CREDS.appSecret,
1661
+ userSecret: CHAT_CREDS.userSecret,
1662
+ userToken: this.userTokenFromCookie,
1663
+ });
1664
+ this.isInitialized = true;
1665
+ }
1666
+ catch (sdkError) {
1667
+ console.error('ChatSDK failed to initialize', sdkError);
1668
+ this.isInitialized = false;
1669
+ throw new Error('Failed to initialize chat SDK');
1670
+ }
1671
+ // MQTT setup
1672
+ try {
1673
+ this.updateLoading(40, 'Setting up MQTT client...');
1674
+ await this.setupMqttClient();
1675
+ }
1676
+ catch (mqttError) {
1677
+ console.error('MQTT client setup failed:', mqttError);
1678
+ }
1679
+ // User details + Instagram OAuth return (if any)
1680
+ try {
1681
+ this.updateLoading(55, 'Getting user details...');
1682
+ await this.getUserDetails();
1683
+ await this.handleSocialConnectCallback();
1684
+ }
1685
+ catch (userError) {
1686
+ console.error('Failed to get user details:', userError);
1687
+ }
1688
+ // Gate chats behind a connected Instagram account
1689
+ try {
1690
+ this.updateLoading(65, 'Checking Instagram connection...');
1691
+ await this.refreshInstagramConnectionGate();
1692
+ }
1693
+ catch (igError) {
1694
+ console.error('Failed to check Instagram accounts:', igError);
1695
+ this.applyInstagramAccounts([]);
1696
+ }
1697
+ if (!this.isInstagramConnected) {
1698
+ this.activeTab = 'Accounts';
1699
+ this.updateLoading(100, 'Connect Instagram to continue');
1700
+ this.checkMobileView();
1701
+ window.addEventListener('resize', this.checkMobileView.bind(this));
1702
+ return;
1703
+ }
1704
+ // Conversation details
1705
+ if (this.initialConversationIdFromURL) {
1706
+ try {
1707
+ this.updateLoading(70, 'Loading conversation...');
1708
+ this.selectedConversationId = this.initialConversationIdFromURL;
1709
+ const urlParams = new URLSearchParams(window.location.search);
1710
+ const isGroupCast = urlParams.has('groupcast');
1711
+ if (isGroupCast) {
1712
+ await this.getGroupCastConversationDetails(this.initialConversationIdFromURL);
1713
+ const messages = await getGroupcastMessage(this.initialConversationIdFromURL);
1714
+ if (messages === null || messages === void 0 ? void 0 : messages.messages) {
1715
+ this.allMessages = messages === null || messages === void 0 ? void 0 : messages.messages.reverse();
1716
+ }
1717
+ }
1718
+ else {
1719
+ await this.getUserConversationDetails();
1720
+ await this.getMessages(0);
1721
+ await this.getAllAttachments(this.initialConversationIdFromURL);
1722
+ }
1723
+ }
1724
+ catch (conversationError) {
1725
+ console.error('Failed to load conversation details:', conversationError);
1726
+ }
1727
+ }
1728
+ try {
1729
+ this.updateLoading(85, 'Checking unread messages...');
1730
+ const unreadCount = await getTotalUnreadConversationsCount();
1731
+ unreadCountStore.updateTotalUnreadCount(unreadCount);
1732
+ this.unreadConversationsCount = unreadCount;
1733
+ unreadCountStore.onChange('totalUnreadCount', value => {
1734
+ this.unreadConversationsCount = value;
1735
+ });
1736
+ }
1737
+ catch (unreadError) {
1738
+ console.error('Error fetching unread conversations:', unreadError);
1739
+ this.unreadConversationsCount = 0;
1740
+ unreadCountStore.updateTotalUnreadCount(0);
1741
+ }
1742
+ // Get all conversations
1743
+ try {
1744
+ this.updateLoading(95, 'Loading conversations...');
1745
+ await this.getConversations();
1746
+ }
1747
+ catch (conversationsError) {
1748
+ console.error('Failed to load conversations:', conversationsError);
1749
+ }
1750
+ this.checkMobileView();
1751
+ window.addEventListener('resize', this.checkMobileView.bind(this));
1752
+ this.updateLoading(100, 'Complete!');
1753
+ }
1754
+ catch (error) {
1755
+ console.error('Critical initialization error:', error);
1756
+ }
1757
+ finally {
1758
+ // Short delay to show the 100% state before hiding
1759
+ setTimeout(() => {
1760
+ this.isLoading = false;
1761
+ }, 500);
1762
+ }
1763
+ }
1764
+ updateLoading(progress, status) {
1765
+ this.loadingProgress = progress;
1766
+ this.loadingStatus = status;
1767
+ }
1768
+ disconnectedCallback() {
1769
+ window.removeEventListener('resize', this.checkMobileView.bind(this));
1770
+ window.removeEventListener('pointermove', this.onSidebarResizeMove);
1771
+ window.removeEventListener('pointerup', this.onSidebarResizeEnd);
1772
+ if (this.conversationDetailsInterval) {
1773
+ clearInterval(this.conversationDetailsInterval);
1774
+ }
1775
+ }
1776
+ async setupMqttClient() {
1777
+ // let retryToConnect:any = null;
1778
+ const deviceID = await getDeviceID();
1779
+ const mqttClient = M.getInstance().initializeMqtt({
1780
+ hostUri: MQTT_CREDS.URL ,
1781
+ clientId: CHAT_CREDS.isometrikUserId,
1782
+ licenseKey: CHAT_CREDS.licenseKey,
1783
+ projectId: CHAT_CREDS.projectId,
1784
+ keysetId: CHAT_CREDS.keysetId,
1785
+ accountId: CHAT_CREDS.accountId,
1786
+ deviceId: deviceID,
1787
+ });
1788
+ // const mqttClient = ChatSDK.getInstance().initializeMqtt({
1789
+ // hostUri: this.hostUrl,
1790
+ // clientId: this.isometrikUserId,
1791
+ // licenseKey: this.licenseKey,
1792
+ // projectId: this.projectId,
1793
+ // keysetId: this.keysetId,
1794
+ // accountId: this.accountId,
1795
+ // deviceId: deviceID,
1796
+ // });
1797
+ this.mqttClient = mqttClient;
1798
+ let refetchInterval = null;
1799
+ this.isMqttConnected = false;
1800
+ this.mqttClient.client.on('connect', async () => {
1801
+ this.mqttInitialized = true;
1802
+ this.isMqttConnected = true;
1803
+ this.subscribeToMQTT();
1804
+ if (refetchInterval) {
1805
+ clearInterval(refetchInterval);
1806
+ refetchInterval = null;
1807
+ }
1808
+ if (!this.isInitialCallDone && this.selectedConversationId) {
1809
+ await M.getInstance().message.putRead({ conversationId: this.selectedConversationId });
1810
+ this.refetchMessages();
1811
+ this.isInitialCallDone = true;
1812
+ }
1813
+ });
1814
+ this.mqttClient.client.on('disconnect', () => {
1815
+ this.isMqttConnected = false;
1816
+ });
1817
+ this.mqttClient.client.on('error', (error) => {
1818
+ console.error('MQTT connection error:--->', error);
1819
+ this.mqttInitialized = false;
1820
+ this.isMqttConnected = false;
1821
+ this.isInitialCallDone = true;
1822
+ if (!refetchInterval) {
1823
+ refetchInterval = setInterval(() => {
1824
+ console.error('MQTT connection failed, refetching messages...');
1825
+ this.refetchMessages();
1826
+ }, 30000);
1827
+ }
1828
+ });
1829
+ }
1830
+ handleChatSelect(param) {
1831
+ const conversationId = typeof param === 'string' ? param : param.groupcastId;
1832
+ this.selectedConversationId = conversationId;
1833
+ this.isProfileInfoOpen = false;
1834
+ this.isContactInfoOpen = false;
1835
+ this.isOpenSearchBar = false;
1836
+ const targetConversation = this.allConversationList.find(conversation => (conversation === null || conversation === void 0 ? void 0 : conversation.conversationId) === conversationId);
1837
+ this.conversationMetaData = targetConversation
1838
+ ? {
1839
+ isGroup: targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.isGroup,
1840
+ conversationImageUrl: (targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.isGroup) ? targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.conversationImageUrl : null,
1841
+ conversationTitle: (targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.isGroup) ? targetConversation === null || targetConversation === void 0 ? void 0 : targetConversation.conversationTitle : null,
1842
+ opponentDetails: Object.assign({}, targetConversation.opponentDetails),
1843
+ }
1844
+ : null;
1845
+ if (typeof param === 'string') {
1846
+ this.getAllAttachments(conversationId);
1847
+ }
1848
+ const url = new URL(window.location.href);
1849
+ url.search = '';
1850
+ if (typeof param === 'object') {
1851
+ url.searchParams.set('groupcast', param.groupcastId);
1852
+ this.activeTab = 'GroupCast';
1853
+ this.getGroupCastContacts();
1854
+ this.conversationMetaData = null;
1855
+ }
1856
+ else {
1857
+ if (conversationId) {
1858
+ url.searchParams.set('conversation', conversationId);
1859
+ if (this.isMobileView) {
1860
+ this.showSidebar = false;
1861
+ }
1862
+ }
1863
+ else {
1864
+ url.searchParams.delete('conversation');
1865
+ this.showSidebar = true;
1866
+ }
1867
+ }
1868
+ window.history.pushState({}, '', url);
1869
+ // Reset unread count for the selected conversation
1870
+ this.allConversationList = this.allConversationList.map(conversation => {
1871
+ if (conversation.conversationId === conversationId) {
1872
+ conversation.unreadMessagesCount = 0;
1873
+ }
1874
+ return conversation;
1875
+ });
1876
+ // Emit event to update unread message count in the sidebar
1877
+ this.unreadMessageCountUpdated.emit({
1878
+ detail: {
1879
+ conversationId: conversationId,
1880
+ count: 0,
1881
+ },
1882
+ });
1883
+ }
1884
+ handleBackButton() {
1885
+ this.showSidebar = true;
1886
+ this.selectedConversationId = null;
1887
+ const url = new URL(window.location.href);
1888
+ url.searchParams.delete('conversation');
1889
+ window.history.pushState({}, '', url);
1890
+ }
1891
+ sortConversationsByLatestMessage(conversations) {
1892
+ return [...conversations].sort((a, b) => {
1893
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1894
+ if ((((_a = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.action) == 'chatMessageSent' || ((_b = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _b === void 0 ? void 0 : _b.action) == 'forward') &&
1895
+ (((_c = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _c === void 0 ? void 0 : _c.body) === '' || ((_d = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _d === void 0 ? void 0 : _d.action) === 'clearConversation'))
1896
+ return;
1897
+ if ((((_e = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _e === void 0 ? void 0 : _e.action) == 'chatMessageSent' || ((_f = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _f === void 0 ? void 0 : _f.action) == 'forward') &&
1898
+ (((_g = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _g === void 0 ? void 0 : _g.body) === '' || ((_h = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _h === void 0 ? void 0 : _h.action) === 'clearConversation'))
1899
+ return;
1900
+ const timestampA = (_j = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _j === void 0 ? void 0 : _j.updatedAt;
1901
+ const timestampB = (_k = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _k === void 0 ? void 0 : _k.updatedAt;
1902
+ return timestampB - timestampA;
1903
+ });
1904
+ }
1905
+ subscribeToMQTT() {
1906
+ const topic = `/${CHAT_CREDS.accountId}/${CHAT_CREDS.projectId}/Message/${CHAT_CREDS.isometrikUserId}`;
1907
+ if (!this.isSubscribedToTopic) {
1908
+ this.mqttClient.client.subscribe(topic, (error) => {
1909
+ if (error) {
1910
+ console.error('Subscribed Failed to subscribe:--->', error);
1911
+ }
1912
+ else {
1913
+ console.log(`Subscribed to MQTT topic--->: ${topic}`);
1914
+ this.isSubscribedToTopic = true;
1915
+ }
1916
+ });
1917
+ }
1918
+ if (!this.isMessageListenerAttached) {
1919
+ // Set up the listener for incoming messages
1920
+ this.mqttClient.client.on('message', async (topic, message) => {
1921
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
1922
+ const parsedMessage = JSON.parse(message.toString());
1923
+ console.log(`New Incoming message from ${topic}:`, parsedMessage);
1924
+ if (parsedMessage.action === 'conversationCreated' && parsedMessage.conversationDetails) {
1925
+ const newConversation = Object.assign({ conversationId: parsedMessage.conversationId, lastMessageDetails: {
1926
+ body: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.body,
1927
+ updatedAt: ((_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationDetails) === null || _a === void 0 ? void 0 : _a.updatedAt) || Date.now(),
1928
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
1929
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderProfileImageUrl,
1930
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
1931
+ isDeliveredToAllMembers: false,
1932
+ isReadByAllMembers: false,
1933
+ senderId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId,
1934
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || 0,
1935
+ members: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) || [],
1936
+ senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
1937
+ messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId,
1938
+ }, isGroup: parsedMessage.conversationDetails.isGroup, conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle, conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl }, parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationDetails);
1939
+ // Add the new conversation to the list and sort
1940
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
1941
+ }
1942
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === '"deleteConversationLocally"') {
1943
+ this.allConversationList = this.allConversationList.filter(conversation => conversation.conversationId !== parsedMessage.conversationId);
1944
+ if (this.selectedConversationId === parsedMessage.conversationId) {
1945
+ this.selectedConversationId = null;
1946
+ this.showSidebar = true;
1947
+ const url = new URL(window.location.href);
1948
+ url.searchParams.delete('conversation');
1949
+ window.history.pushState({}, '', url);
1950
+ }
1951
+ }
1952
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'forward') {
1953
+ this.handleForwardMessage(parsedMessage);
1954
+ }
1955
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'typingEvent' && parsedMessage.userId != this.userMetaData.userId) {
1956
+ this.isTyping = true;
1957
+ this.typingConversationId = parsedMessage.conversationId;
1958
+ this.typingUserName = parsedMessage.userName;
1959
+ // Add a timeout to reset the typing status after a few seconds
1960
+ setTimeout(() => {
1961
+ if (this.typingConversationId === parsedMessage.conversationId) {
1962
+ this.isTyping = false;
1963
+ this.typingConversationId = null;
1964
+ this.typingUserName = '';
1965
+ }
1966
+ }, 3000); // Reset after 3 seconds
1967
+ }
1968
+ else if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) !== 'typingEvent') {
1969
+ this.isTyping = false;
1970
+ this.typingConversationId = null;
1971
+ this.typingUserName = '';
1972
+ }
1973
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'multipleMessagesRead' && parsedMessage.userId != ((_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId)) {
1974
+ // Update messages read status
1975
+ this.allMessages = (_c = this.allMessages) === null || _c === void 0 ? void 0 : _c.map(message => { var _a, _b; return (message === null || message === void 0 ? void 0 : message.readByAll) != true && ((message === null || message === void 0 ? void 0 : message.senderId) || ((_a = message === null || message === void 0 ? void 0 : message.senderInfo) === null || _a === void 0 ? void 0 : _a.userId)) == ((_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId) ? Object.assign(Object.assign({}, message), { readByAll: true }) : message; });
1976
+ // Emit event for message read status update
1977
+ this.messageReadStatusUpdated.emit({
1978
+ detail: {
1979
+ conversationId: parsedMessage.conversationId,
1980
+ isRead: true,
1981
+ isDelivered: true,
1982
+ messageId: parsedMessage.messageId,
1983
+ },
1984
+ });
1985
+ }
1986
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'messagesDeleteForAll') {
1987
+ this.allMessages = this.allMessages.filter((message) => message.messageId != parsedMessage.messageIds[0]);
1988
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userId) !== ((_d = this.userMetaData) === null || _d === void 0 ? void 0 : _d.userId)) {
1989
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
1990
+ var _a, _b, _c, _d;
1991
+ if (conversation.conversationId === parsedMessage.conversationId && ((_a = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.messageId) === parsedMessage.messageIds[0]) {
1992
+ const lastMessage = conversation === null || conversation === void 0 ? void 0 : conversation.lastMessageDetails;
1993
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: lastMessage
1994
+ ? Object.assign(Object.assign({}, lastMessage), { body: conversation.isGroup
1995
+ ? `This Message Was Deleted`
1996
+ : `${(lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderId) === ((_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId) ? 'You' : lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderName} have Delete message`, updatedAt: parsedMessage.sentAt || Date.now(), action: parsedMessage.action || '', senderName: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName) || ((_c = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _c === void 0 ? void 0 : _c.userName), senderId: (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.userId) || ((_d = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.senderInfo) === null || _d === void 0 ? void 0 : _d.userId) }) : null });
1997
+ }
1998
+ if (conversation.conversationId === parsedMessage.conversationId) {
1999
+ return Object.assign(Object.assign({}, conversation), { unreadMessagesCount: conversation.unreadMessagesCount - 1 });
2000
+ }
2001
+ return conversation;
2002
+ }));
2003
+ }
2004
+ }
2005
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) == ((_e = this.userMetaData) === null || _e === void 0 ? void 0 : _e.userId) && ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'chatMessageSent' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'forward')) {
2006
+ this.changeMessageSendingState(false);
2007
+ this.allMessages = this.allMessages.map(message => {
2008
+ var _a, _b;
2009
+ if (message.messageId == parsedMessage.messageId) {
2010
+ return Object.assign(Object.assign({}, parsedMessage), { mentionedUsers: ((_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.mentionedUsers) === null || _a === void 0 ? void 0 : _a.length)
2011
+ ? (_b = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.mentionedUsers) === null || _b === void 0 ? void 0 : _b.map(pmUser => {
2012
+ const matchingUser = message.mentionedUsers.find(mUser => mUser.userId === pmUser.userId);
2013
+ return Object.assign(Object.assign({}, pmUser), { userName: matchingUser ? matchingUser === null || matchingUser === void 0 ? void 0 : matchingUser.userName : undefined });
2014
+ })
2015
+ : [] });
2016
+ }
2017
+ return message;
2018
+ });
2019
+ }
2020
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'messageDelivered' && parsedMessage.senderId != ((_f = this.userMetaData) === null || _f === void 0 ? void 0 : _f.userId)) {
2021
+ this.allMessages = (_g = this.allMessages) === null || _g === void 0 ? void 0 : _g.map(message => ((message === null || message === void 0 ? void 0 : message.messageId) === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId) ? Object.assign(Object.assign({}, message), { deliveredToAll: true }) : message));
2022
+ }
2023
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'userBlockConversation' || parsedMessage.action == 'userUnblockConversation' || parsedMessage.action == 'userUnblock') {
2024
+ if (parsedMessage.action === 'userBlockConversation') {
2025
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2026
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { messagingDisabled: true, updateBlockStatus: Date.now() });
2027
+ }
2028
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2029
+ var _a;
2030
+ if (conversation.conversationId === parsedMessage.conversationId) {
2031
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === ((_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId)
2032
+ ? `🚫 You blocked ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName}`
2033
+ : `🚫 ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName} blocked you`}`, updatedAt: parsedMessage.sentAt || Date.now(), action: parsedMessage.action || '', initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, opponentName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName }) });
2034
+ }
2035
+ if (conversation.conversationId === parsedMessage.conversationId) {
2036
+ return Object.assign(Object.assign({}, conversation), { unreadMessagesCount: conversation.unreadMessagesCount - 1 });
2037
+ }
2038
+ return conversation;
2039
+ }));
2040
+ }
2041
+ if (parsedMessage.action == 'userUnblock' || parsedMessage.action === 'userUnblockConversation') {
2042
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2043
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { messagingDisabled: false, updateBlockStatus: Date.now() });
2044
+ }
2045
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2046
+ var _a;
2047
+ if (conversation.conversationId === parsedMessage.conversationId) {
2048
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === ((_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId) ? `You unblocked ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName}` : `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName} unblocked you`}`, updatedAt: parsedMessage.sentAt || Date.now(), action: parsedMessage.action || '', initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, opponentName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.opponentName }) });
2049
+ }
2050
+ if (conversation.conversationId === parsedMessage.conversationId) {
2051
+ return Object.assign(Object.assign({}, conversation), { unreadMessagesCount: conversation.unreadMessagesCount - 1 });
2052
+ }
2053
+ return conversation;
2054
+ }));
2055
+ }
2056
+ }
2057
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'reactionAdd') {
2058
+ // Only process reactions for the currently selected conversation
2059
+ // Check if conversationId matches, or if message exists in current conversation (fallback)
2060
+ const messageExists = this.allMessages.some(msg => msg.messageId === parsedMessage.messageId);
2061
+ const isCurrentConversation = parsedMessage.conversationId === this.selectedConversationId ||
2062
+ (messageExists && this.selectedConversationId);
2063
+ if (isCurrentConversation) {
2064
+ this.allMessages = this.allMessages.map(message => {
2065
+ if (message.messageId === parsedMessage.messageId) {
2066
+ // Create a copy of existing reactions or initialize empty object
2067
+ const existingReactions = Object.assign({}, (message.reactions || {}));
2068
+ // Get existing users array for this reaction type or initialize empty array
2069
+ // Handle both array of userIds and array of user objects
2070
+ let existingUsers = existingReactions[parsedMessage.reactionType] || [];
2071
+ // If it's an array of objects, extract userIds
2072
+ if (Array.isArray(existingUsers) && existingUsers.length > 0 && typeof existingUsers[0] === 'object') {
2073
+ existingUsers = existingUsers.map(u => u.userId || u);
2074
+ }
2075
+ // Check if user already reacted
2076
+ const userAlreadyReacted = existingUsers.includes(parsedMessage.userId);
2077
+ if (!userAlreadyReacted) {
2078
+ // Update reactions to match API structure
2079
+ const updateReaction = Object.assign(Object.assign({}, existingReactions), { [parsedMessage.reactionType]: [...existingUsers, parsedMessage.userId] });
2080
+ return Object.assign(Object.assign({}, message), { reactions: updateReaction });
2081
+ }
2082
+ return message;
2083
+ }
2084
+ return message;
2085
+ });
2086
+ }
2087
+ }
2088
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'reactionRemove') {
2089
+ // Only process reactions for the currently selected conversation
2090
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2091
+ this.allMessages = this.allMessages.map(message => {
2092
+ if (message.messageId === parsedMessage.messageId) {
2093
+ const existingReactions = Object.assign({}, (message.reactions || {}));
2094
+ const existingUsers = existingReactions[parsedMessage.reactionType] || [];
2095
+ // Filter out the user who removed the reaction
2096
+ const updatedUsers = Array.isArray(existingUsers)
2097
+ ? existingUsers.filter(userId => userId !== parsedMessage.userId)
2098
+ : [];
2099
+ if (updatedUsers.length > 0) {
2100
+ existingReactions[parsedMessage.reactionType] = updatedUsers;
2101
+ }
2102
+ else {
2103
+ delete existingReactions[parsedMessage.reactionType];
2104
+ }
2105
+ return Object.assign(Object.assign({}, message), { reactions: existingReactions });
2106
+ }
2107
+ return message;
2108
+ });
2109
+ }
2110
+ }
2111
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'membersAdd') {
2112
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId));
2113
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2114
+ this.conversationMetaData.members = [
2115
+ ...this.conversationMetaData.members,
2116
+ ...parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members.map(member => ({
2117
+ userId: member.memberId,
2118
+ userName: member.memberName,
2119
+ userProfileImageUrl: member.memberProfileImageUrl,
2120
+ userIdentifier: member.memberIdentifier,
2121
+ isAdmin: member.isAdmin || false,
2122
+ })),
2123
+ ];
2124
+ }
2125
+ const isCurrentUserAdded = (_h = parsedMessage.members) === null || _h === void 0 ? void 0 : _h.some(member => { var _a; return member.memberId === ((_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId); });
2126
+ if (!conversationExists && isCurrentUserAdded) {
2127
+ // Create new conversation object for added member
2128
+ const newConversation = {
2129
+ conversationId: parsedMessage.conversationId,
2130
+ isGroup: true,
2131
+ conversationTitle: parsedMessage.conversationTitle,
2132
+ conversationImageUrl: parsedMessage.conversationImageUrl,
2133
+ lastMessageDetails: {
2134
+ body: `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName} added you`,
2135
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
2136
+ action: 'membersAdd',
2137
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
2138
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl,
2139
+ senderId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userId,
2140
+ senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
2141
+ memberAdded: (_j = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _j === void 0 ? void 0 : _j.map(member => member.memberName),
2142
+ memberAddedUserId: (_k = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _k === void 0 ? void 0 : _k.map(member => member.memberId),
2143
+ },
2144
+ unreadMessagesCount: 1,
2145
+ members: parsedMessage.members || [],
2146
+ };
2147
+ // Add the new conversation to the list and sort
2148
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
2149
+ // Update unread count
2150
+ this.unreadMessageCountUpdated.emit({
2151
+ detail: {
2152
+ conversationId: parsedMessage.conversationId,
2153
+ count: 1,
2154
+ },
2155
+ });
2156
+ }
2157
+ else if (conversationExists) {
2158
+ // Update existing conversation with new member info
2159
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2160
+ var _a, _b, _c, _d;
2161
+ if (conversation.conversationId === parsedMessage.conversationId) {
2162
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName} added ${(_b = (_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.memberName}`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: 'membersAdd', userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, memberAdded: (_c = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _c === void 0 ? void 0 : _c.map(member => member.memberName), memberAddedUserId: (_d = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _d === void 0 ? void 0 : _d.map(member => member.memberId), members: [...(conversation.members || []), ...parsedMessage.members] }), members: [...(conversation.members || []), ...parsedMessage.members] });
2163
+ }
2164
+ return conversation;
2165
+ }));
2166
+ }
2167
+ }
2168
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'membersRemove') {
2169
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId));
2170
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2171
+ this.conversationMetaData.members = (_m = (_l = this.conversationMetaData) === null || _l === void 0 ? void 0 : _l.members) === null || _m === void 0 ? void 0 : _m.filter(user => { var _a, _b; return (user === null || user === void 0 ? void 0 : user.userId) !== ((_b = (_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.memberId); });
2172
+ }
2173
+ if (conversationExists) {
2174
+ // Update existing conversation with new member info
2175
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2176
+ var _a, _b, _c;
2177
+ if (conversation.conversationId === parsedMessage.conversationId) {
2178
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName} removed ${(_a = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members[0]) === null || _a === void 0 ? void 0 : _a.memberName}`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: 'membersRemove', userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, memberAdded: (_b = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _b === void 0 ? void 0 : _b.map(member => member.memberName), memberAddedUserId: (_c = parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) === null || _c === void 0 ? void 0 : _c.map(member => member.memberId), members: [...(conversation.members || []), ...parsedMessage.members] }), members: [...(conversation.members || []), ...parsedMessage.members] });
2179
+ }
2180
+ return conversation;
2181
+ }));
2182
+ }
2183
+ }
2184
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'addAdmin') {
2185
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
2186
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2187
+ this.conversationMetaData.members = (_p = (_o = this.conversationMetaData) === null || _o === void 0 ? void 0 : _o.members) === null || _p === void 0 ? void 0 : _p.map(member => {
2188
+ return Object.assign(Object.assign({}, member), { isAdmin: member.userId === parsedMessage.memberId ? true : member.isAdmin });
2189
+ });
2190
+ }
2191
+ if (conversationExists) {
2192
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2193
+ if (conversation.conversationId === parsedMessage.conversationId) {
2194
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} made ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} an admin`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action, userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName }) });
2195
+ }
2196
+ return conversation;
2197
+ }));
2198
+ }
2199
+ else if (!conversationExists) {
2200
+ const newConversation = {
2201
+ conversationId: parsedMessage.conversationId,
2202
+ lastMessageDetails: {
2203
+ body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} made ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} an admin`,
2204
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
2205
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
2206
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
2207
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl,
2208
+ initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId,
2209
+ initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName,
2210
+ memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName,
2211
+ },
2212
+ isGroup: true,
2213
+ conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle,
2214
+ conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl,
2215
+ };
2216
+ // Add the new conversation to the list and sort
2217
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
2218
+ }
2219
+ }
2220
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'removeAdmin') {
2221
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
2222
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2223
+ this.conversationMetaData.members = (_r = (_q = this.conversationMetaData) === null || _q === void 0 ? void 0 : _q.members) === null || _r === void 0 ? void 0 : _r.map(member => {
2224
+ return Object.assign(Object.assign({}, member), { isAdmin: member.userId === parsedMessage.memberId ? false : member.isAdmin });
2225
+ });
2226
+ }
2227
+ if (conversationExists) {
2228
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2229
+ if (conversation.conversationId === parsedMessage.conversationId) {
2230
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} removed ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} as an admin`, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(), action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action, userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName, userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl, initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId, initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName, memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName }) });
2231
+ }
2232
+ return conversation;
2233
+ }));
2234
+ }
2235
+ else if (!conversationExists) {
2236
+ const newConversation = {
2237
+ conversationId: parsedMessage.conversationId,
2238
+ lastMessageDetails: {
2239
+ body: `${(parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId) === this.userMetaData.userId ? 'you' : parsedMessage.memberName} removed ${parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName} as an admin`,
2240
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
2241
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
2242
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userName,
2243
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.userProfileImageUrl,
2244
+ initiatorId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorId,
2245
+ initiatorName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.initiatorName,
2246
+ memberName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.memberName,
2247
+ },
2248
+ isGroup: true,
2249
+ conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle,
2250
+ conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl,
2251
+ };
2252
+ // Add the new conversation to the list and sort
2253
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
2254
+ }
2255
+ }
2256
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'chatMessageSent' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'forward') {
2257
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
2258
+ const isGroup = !parsedMessage.privateOneToOne;
2259
+ if (!conversationExists) {
2260
+ // Create a new conversation object from the message data
2261
+ const newConversation = {
2262
+ conversationId: parsedMessage.conversationId,
2263
+ lastMessageDetails: {
2264
+ body: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.body,
2265
+ updatedAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || Date.now(),
2266
+ userName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
2267
+ userProfileImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderProfileImageUrl,
2268
+ action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action,
2269
+ isDeliveredToAllMembers: false,
2270
+ isReadByAllMembers: false,
2271
+ isPendingAllMembers: false,
2272
+ senderId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId,
2273
+ sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || 0,
2274
+ members: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) || [],
2275
+ senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName,
2276
+ messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId,
2277
+ },
2278
+ isGroup: isGroup,
2279
+ conversationTitle: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationTitle,
2280
+ conversationImageUrl: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationImageUrl,
2281
+ opponentDetails: !isGroup
2282
+ ? {
2283
+ // Use the sender's details only if they're not the current user
2284
+ userName: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) !== ((_s = this.userMetaData) === null || _s === void 0 ? void 0 : _s.userId) ? parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName : (_u = (_t = this.conversationMetaData) === null || _t === void 0 ? void 0 : _t.opponentDetails) === null || _u === void 0 ? void 0 : _u.userName,
2285
+ userProfileImageUrl: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) !== ((_v = this.userMetaData) === null || _v === void 0 ? void 0 : _v.userId)
2286
+ ? parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderProfileImageUrl
2287
+ : (_x = (_w = this.conversationMetaData) === null || _w === void 0 ? void 0 : _w.opponentDetails) === null || _x === void 0 ? void 0 : _x.userProfileImageUrl,
2288
+ userId: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) !== ((_y = this.userMetaData) === null || _y === void 0 ? void 0 : _y.userId) ? parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId : (_0 = (_z = this.conversationMetaData) === null || _z === void 0 ? void 0 : _z.opponentDetails) === null || _0 === void 0 ? void 0 : _0.userId,
2289
+ }
2290
+ : null,
2291
+ };
2292
+ // Add the new conversation to the list and sort
2293
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
2294
+ }
2295
+ else {
2296
+ // Update existing conversation
2297
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2298
+ if (conversation.conversationId === parsedMessage.conversationId) {
2299
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: parsedMessage.body, updatedAt: parsedMessage.updatedAt || parsedMessage.sentAt || Date.now(), attachments: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.attachments) || [], action: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action, isDeliveredToAllMembers: false, isReadByAllMembers: false, isPendingAllMembers: false, senderId: parsedMessage.senderId, sentAt: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.sentAt) || 0, members: (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.members) || [], senderName: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderName, messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId, opponentDetails: conversation.opponentDetails }), isGroup: conversation.isGroup, conversationTitle: conversation.conversationTitle, conversationImageUrl: conversation.conversationImageUrl, opponentDetails: conversation.opponentDetails });
2300
+ }
2301
+ return conversation;
2302
+ }));
2303
+ }
2304
+ // Re-sort the conversations after update
2305
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList);
2306
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2307
+ if (parsedMessage.senderId !== ((_1 = this.userMetaData) === null || _1 === void 0 ? void 0 : _1.userId)) {
2308
+ const currentCount = ((_2 = this.newMessageNotification) === null || _2 === void 0 ? void 0 : _2.count) || 0;
2309
+ this.newMessageNotification = {
2310
+ messageId: parsedMessage.messageId,
2311
+ count: currentCount + 1,
2312
+ conversationId: parsedMessage.conversationId,
2313
+ };
2314
+ }
2315
+ }
2316
+ }
2317
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.senderId) != ((_3 = this.userMetaData) === null || _3 === void 0 ? void 0 : _3.userId) &&
2318
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'typingEvent' &&
2319
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messageRead' &&
2320
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'multipleMessagesRead' &&
2321
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messageRead' &&
2322
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messagesDeleteForAll' &&
2323
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messagesDeleteLocal' &&
2324
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'messageDelivered' &&
2325
+ (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) != 'conversationCreated') {
2326
+ // if(parsedMessage.conversationId === this.selectedConversationId) {
2327
+ // this.allMessages = [...this.allMessages, parsedMessage];
2328
+ // }
2329
+ if (parsedMessage.conversationId === this.selectedConversationId) {
2330
+ this.allMessages = [...this.allMessages, parsedMessage];
2331
+ }
2332
+ else {
2333
+ this.allConversationList = this.allConversationList.map(conversation => {
2334
+ if (conversation.conversationId === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId)) {
2335
+ const currentUnreadCount = parseInt(conversation.unreadMessagesCount) || 0;
2336
+ conversation.unreadMessagesCount = currentUnreadCount + 1;
2337
+ this.unreadMessageCount = conversation.unreadMessagesCount;
2338
+ }
2339
+ return conversation;
2340
+ });
2341
+ }
2342
+ this.unreadMessageCountUpdated.emit({
2343
+ detail: {
2344
+ conversationId: parsedMessage.conversationId,
2345
+ count: 1,
2346
+ },
2347
+ // bubbles: true,
2348
+ // composed: true
2349
+ });
2350
+ try {
2351
+ await M.getInstance().message.putIndicateDelivered({ conversationId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId, messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId });
2352
+ }
2353
+ catch (error) {
2354
+ console.error(error, 'putIndicateDelivered request error');
2355
+ }
2356
+ }
2357
+ // Handle message delivery status updates
2358
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageDelivered' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageRead') {
2359
+ const isRead = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageRead';
2360
+ const isDelivered = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) === 'messageDelivered';
2361
+ // Update conversation list with new message status
2362
+ this.allConversationList = this.allConversationList.map(conversation => {
2363
+ var _a, _b, _c;
2364
+ if (conversation.conversationId === parsedMessage.conversationId) {
2365
+ // Only update if the status has actually changed
2366
+ const currentReadStatus = (_a = conversation.lastMessageDetails) === null || _a === void 0 ? void 0 : _a.readByAll;
2367
+ const currentDeliveredStatus = (_b = conversation.lastMessageDetails) === null || _b === void 0 ? void 0 : _b.deliveredToAll;
2368
+ if (currentReadStatus !== isRead || currentDeliveredStatus !== isDelivered) {
2369
+ // Emit event when status changes
2370
+ this.messageReadStatusUpdated.emit({
2371
+ detail: {
2372
+ conversationId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.conversationId,
2373
+ isRead,
2374
+ isDelivered,
2375
+ messageId: parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId,
2376
+ },
2377
+ bubbles: true,
2378
+ composed: true,
2379
+ });
2380
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { readByAll: isRead, deliveredToAll: isDelivered, senderId: (_c = conversation.lastMessageDetails) === null || _c === void 0 ? void 0 : _c.senderId }) });
2381
+ }
2382
+ }
2383
+ return conversation;
2384
+ });
2385
+ }
2386
+ if ((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'messageRead' && parsedMessage.senderId != ((_4 = this.userMetaData) === null || _4 === void 0 ? void 0 : _4.userId)) {
2387
+ // Update single message read status
2388
+ this.allMessages = (_5 = this.allMessages) === null || _5 === void 0 ? void 0 : _5.map(message => ((message === null || message === void 0 ? void 0 : message.messageId) === (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.messageId) ? Object.assign(Object.assign({}, message), { readByAll: true }) : message));
2389
+ // Emit event for message read status update
2390
+ this.messageReadStatusUpdated.emit({
2391
+ detail: {
2392
+ conversationId: parsedMessage.conversationId,
2393
+ isRead: true,
2394
+ isDelivered: true,
2395
+ messageId: parsedMessage.messageId,
2396
+ },
2397
+ });
2398
+ }
2399
+ // Update unread count if message is not in current conversation
2400
+ if (((parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'chatMessageSent' || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.action) == 'forward') && parsedMessage.senderId != ((_6 = this.userMetaData) === null || _6 === void 0 ? void 0 : _6.userId)) {
2401
+ const totalUnreadConversation = (_7 = this.allConversationList) === null || _7 === void 0 ? void 0 : _7.filter(conversation => (conversation === null || conversation === void 0 ? void 0 : conversation.unreadMessagesCount) > 0);
2402
+ if ((totalUnreadConversation === null || totalUnreadConversation === void 0 ? void 0 : totalUnreadConversation.length) > 0) {
2403
+ unreadCountStore.updateTotalUnreadCount(totalUnreadConversation === null || totalUnreadConversation === void 0 ? void 0 : totalUnreadConversation.length);
2404
+ }
2405
+ }
2406
+ // Add this to your existing MQTT message handler in subscribeToMQTT()
2407
+ if (topic.includes('/members')) {
2408
+ try {
2409
+ const memberUpdate = JSON.parse(message.toString());
2410
+ if (memberUpdate.type === 'member_removed' && memberUpdate.conversationId === this.selectedConversationId) {
2411
+ // Update conversation metadata and group members store
2412
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { members: memberUpdate.updatedMembers });
2413
+ groupMembersStore.initializeMembers(memberUpdate.updatedMembers, memberUpdate.conversationId);
2414
+ // Show toast notification for other members
2415
+ if (memberUpdate.removedByUserId !== CHAT_CREDS.isometrikUserId) {
2416
+ showToast({
2417
+ message: 'A member has been removed from the group',
2418
+ type: 'info',
2419
+ duration: 3000,
2420
+ position: 'bottom-left',
2421
+ });
2422
+ }
2423
+ }
2424
+ }
2425
+ catch (error) {
2426
+ console.error('Error handling member update message:', error);
2427
+ }
2428
+ }
2429
+ });
2430
+ this.isMessageListenerAttached = true;
2431
+ }
2432
+ }
2433
+ ///
2434
+ async handleForwardMessage(parsedMessage) {
2435
+ var _a, _b;
2436
+ try {
2437
+ // Check if the conversation already exists
2438
+ const conversationExists = this.allConversationList.some(conversation => conversation.conversationId === parsedMessage.conversationId);
2439
+ if (!conversationExists) {
2440
+ // Get conversation details first
2441
+ const conversationDetails = await this.getUserConversationDetails(parsedMessage.conversationId);
2442
+ // Use the conversation details to create the new conversation object
2443
+ const newConversation = {
2444
+ conversationId: parsedMessage.conversationId,
2445
+ lastMessageDetails: {
2446
+ body: parsedMessage.body,
2447
+ updatedAt: parsedMessage.updatedAt || Date.now(),
2448
+ // @ts-ignore
2449
+ userName: (_a = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _a === void 0 ? void 0 : _a.userName,
2450
+ // @ts-ignore
2451
+ userProfileImageUrl: (_b = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _b === void 0 ? void 0 : _b.userProfileImageUrl,
2452
+ },
2453
+ unreadMessagesCount: 0,
2454
+ // Add details from the API response
2455
+ };
2456
+ // Add the new conversation to the list and sort
2457
+ this.allConversationList = this.sortConversationsByLatestMessage([newConversation, ...this.allConversationList]);
2458
+ await this.getAllAttachments(newConversation.conversationId);
2459
+ }
2460
+ else {
2461
+ // Update existing conversation
2462
+ this.allConversationList = this.sortConversationsByLatestMessage(this.allConversationList.map(conversation => {
2463
+ if (conversation.conversationId === parsedMessage.conversationId) {
2464
+ return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: parsedMessage.body, updatedAt: parsedMessage.updatedAt || Date.now() }), isGroup: conversation.isGroup, conversationTitle: conversation.conversationTitle, conversationImageUrl: conversation.conversationImageUrl, opponentDetails: conversation.opponentDetails });
2465
+ }
2466
+ return conversation;
2467
+ }));
2468
+ }
2469
+ this.unreadMessageCountUpdated.emit({
2470
+ detail: {
2471
+ conversationId: parsedMessage.conversationId,
2472
+ count: 1,
2473
+ },
2474
+ });
2475
+ }
2476
+ catch (error) {
2477
+ console.error('Error handling forward message:', error);
2478
+ }
2479
+ }
2480
+ async handleRemoveMemberClicked(event) {
2481
+ var _a;
2482
+ const isGroupcast = event.detail.isGroupcast;
2483
+ const memberToRemove = event.detail.userId;
2484
+ const originalMembers = ((_a = this.conversationMetaData) === null || _a === void 0 ? void 0 : _a.members) || [];
2485
+ const groupcastId = event.detail.conversationId;
2486
+ try {
2487
+ if (isGroupcast) {
2488
+ removeGroupcastMember(groupcastId, memberToRemove);
2489
+ }
2490
+ else {
2491
+ await removeConversationMember(this.selectedConversationId, memberToRemove);
2492
+ const updatedMembers = originalMembers.filter(member => member.userId !== memberToRemove);
2493
+ this.conversationMetaData = Object.assign(Object.assign({}, this.conversationMetaData), { members: updatedMembers });
2494
+ groupMembersStore.initializeMembers(updatedMembers, this.selectedConversationId);
2495
+ }
2496
+ showToast({
2497
+ message: 'Member removed successfully',
2498
+ type: 'success',
2499
+ duration: 3000,
2500
+ position: 'bottom-left',
2501
+ });
2502
+ }
2503
+ catch (error) {
2504
+ console.error('Error removing member:', error);
2505
+ showToast({
2506
+ message: 'Failed to remove member',
2507
+ type: 'error',
2508
+ duration: 3000,
2509
+ position: 'bottom-left',
2510
+ });
2511
+ }
2512
+ finally {
2513
+ drawerDialogService.closeDialog('confirm-dialog');
2514
+ }
2515
+ }
2516
+ async onProfileClick(event) {
2517
+ if (event.type === 'profile-clicked') {
2518
+ this.activeTab = 'Profile';
2519
+ }
2520
+ }
2521
+ async handleMembersListScrolledToBottom(event) {
2522
+ try {
2523
+ this.hasMoreEligibleMembers = true;
2524
+ this.membersListSkip += 20;
2525
+ const newMembers = await getConversationEligibleMembers(this.selectedConversationId);
2526
+ if (newMembers.conversationEligibleMembers.length < 20) {
2527
+ this.hasMoreEligibleMembers = false;
2528
+ }
2529
+ this.eligibleMembers = [...this.eligibleMembers, ...newMembers.conversationEligibleMembers];
2530
+ const membersList = event.target;
2531
+ membersList.isLoading = false;
2532
+ }
2533
+ catch (error) {
2534
+ console.error('Error loading more members:', error);
2535
+ this.hasMoreEligibleMembers = false;
2536
+ const membersList = event.target;
2537
+ membersList.isLoading = false;
2538
+ }
2539
+ }
2540
+ async handleContactInfo(event) {
2541
+ const { type } = event.detail;
2542
+ if (type === 'close-right-Sidebar') {
2543
+ this.showRightSideBar = false;
2544
+ this.isOpenSearchBar = false;
2545
+ this.isContactInfoOpen = false;
2546
+ this.isProfileInfoOpen = false;
2547
+ this.searchedMessageDetails = [];
2548
+ }
2549
+ }
2550
+ async handleProfileInfo(event) {
2551
+ const { type } = event.detail;
2552
+ if (type === 'close-contact-info') {
2553
+ this.showRightSideBar = true;
2554
+ this.isContactInfoOpen = true;
2555
+ this.isProfileInfoOpen = false;
2556
+ this.searchedMessageDetails = [];
2557
+ }
2558
+ }
2559
+ async handleOpen(event) {
2560
+ const { type, renderComponent, userId, userName } = event.detail;
2561
+ const { isGroupcast, groupcastId } = await getGroupcastUrlQuery();
2562
+ if (type === 'open-right-Sidebar') {
2563
+ this.showRightSideBar = true;
2564
+ if (renderComponent === 'message-search-container') {
2565
+ this.isOpenSearchBar = true;
2566
+ this.isContactInfoOpen = false;
2567
+ this.isProfileInfoOpen = false;
2568
+ }
2569
+ else if (renderComponent === 'contact-info') {
2570
+ this.isContactInfoOpen = true;
2571
+ this.getAllLinksCount(this.selectedConversationId);
2572
+ if (isGroupcast) {
2573
+ this.getGroupcastMembers(groupcastId);
2574
+ }
2575
+ this.isOpenSearchBar = false;
2576
+ }
2577
+ else if (renderComponent === 'profile-info') {
2578
+ this.isContactInfoOpen = false;
2579
+ this.isProfileInfoOpen = true;
2580
+ this.isOpenSearchBar = false;
2581
+ this.getConversationId(userId, userName);
2582
+ }
2583
+ }
2584
+ }
2585
+ async getConversationId(selectedContactId, selectedContactName) {
2586
+ try {
2587
+ const paramsForCreateConversation = {
2588
+ typingEvents: true,
2589
+ readEvents: true,
2590
+ pushNotifications: true,
2591
+ members: [selectedContactId],
2592
+ isGroup: false,
2593
+ conversationType: 0,
2594
+ searchableTags: [selectedContactName],
2595
+ };
2596
+ const res = await M.getInstance().Conversation.postConversation(paramsForCreateConversation);
2597
+ if (res.conversationId) {
2598
+ this.conversationIdFromContactinfo = res.conversationId;
2599
+ this.getUserConversationDetails(res.conversationId);
2600
+ this.getAllAttachments(res.conversationId, 'Profile-info');
2601
+ this.getMessages(0, res.conversationId);
2602
+ }
2603
+ }
2604
+ catch (error) {
2605
+ console.error('Error creating conversation:', error);
2606
+ }
2607
+ }
2608
+ async handleGetLinks(event) {
2609
+ const { conversationId } = event.detail;
2610
+ this.getAllLinks(conversationId);
2611
+ }
2612
+ handleSkipChange() {
2613
+ if (!this.isMessageLimitEnd) {
2614
+ this.getMessages(this.skip);
2615
+ }
2616
+ }
2617
+ handleTypingChange() {
2618
+ if (this.isTyping) {
2619
+ if (this.typingTimeout) {
2620
+ clearTimeout(this.typingTimeout);
2621
+ }
2622
+ this.typingTimeout = setTimeout(() => {
2623
+ this.isTyping = false;
2624
+ this.typingUserName = '';
2625
+ }, 10000);
2626
+ }
2627
+ }
2628
+ async handleSelectedConversationChange(newValue) {
2629
+ if (newValue) {
2630
+ this.isConversationLoading = true;
2631
+ const url = new URL(window.location.href);
2632
+ const isGroupcast = url.searchParams.has('groupcast');
2633
+ if (isGroupcast) {
2634
+ const groupcastId = url.searchParams.get('groupcast');
2635
+ try {
2636
+ this.isScrollToBottom = true;
2637
+ this.isMessageLimitEnd = true;
2638
+ this.messageAction = { action: '', initiator: false };
2639
+ this.skip = 0;
2640
+ this.allMessages = [];
2641
+ await this.getGroupCastConversationDetails(groupcastId);
2642
+ const messages = await getGroupcastMessage(groupcastId);
2643
+ if (messages === null || messages === void 0 ? void 0 : messages.messages) {
2644
+ this.allMessages = messages === null || messages === void 0 ? void 0 : messages.messages.reverse();
2645
+ }
2646
+ }
2647
+ catch (error) {
2648
+ console.error('Error while getting groupcast data', error);
2649
+ }
2650
+ }
2651
+ else {
2652
+ this.refetchMessages();
2653
+ this.getUserConversationDetails();
2654
+ }
2655
+ this.isConversationLoading = false;
2656
+ const selectedConversation = this.allConversationList.find(conv => conv.conversationId === newValue);
2657
+ if (selectedConversation && selectedConversation.unreadMessagesCount > 0) {
2658
+ const currentCount = unreadCountStore.getTotalUnreadCount();
2659
+ const newCount = Math.max(0, currentCount - 1);
2660
+ unreadCountStore.updateTotalUnreadCount(newCount);
2661
+ }
2662
+ }
2663
+ else {
2664
+ if (this.conversationDetailsInterval) {
2665
+ clearInterval(this.conversationDetailsInterval);
2666
+ }
2667
+ }
2668
+ }
2669
+ async handlemessageAction() {
2670
+ this.getMessageAction();
2671
+ }
2672
+ handleGroupExited(event) {
2673
+ const { conversationId } = event.detail;
2674
+ // Add the group ID to the set of exited groups
2675
+ this.exitedGroupIds.add(conversationId);
2676
+ }
2677
+ handleTaguserClick(event) {
2678
+ const { userId, userName } = event.detail;
2679
+ if (userId && userName) {
2680
+ this.createConversation(userId, userName);
2681
+ }
2682
+ }
2683
+ async createConversation(selectedContactId, selectedContactName) {
2684
+ try {
2685
+ const paramsForCreateConversation = {
2686
+ typingEvents: true,
2687
+ readEvents: true,
2688
+ pushNotifications: true,
2689
+ members: [selectedContactId],
2690
+ isGroup: false,
2691
+ conversationType: 0,
2692
+ searchableTags: [selectedContactName],
2693
+ };
2694
+ const res = await M.getInstance().Conversation.postConversation(paramsForCreateConversation);
2695
+ if (res.conversationId) {
2696
+ this.handleChatSelect(res.conversationId);
2697
+ }
2698
+ }
2699
+ catch (error) {
2700
+ console.error('Error creating conversation:', error);
2701
+ }
2702
+ }
2703
+ handleContactAction(event) {
2704
+ const action = event.detail.action;
2705
+ switch (action) {
2706
+ case 'exit-group':
2707
+ break;
2708
+ case 'block-contact':
2709
+ this.blockUser(event.detail.oppenentId, event.detail.userName);
2710
+ break;
2711
+ case 'unblock-contact':
2712
+ this.unblockUser(event.detail.oppenentId, event.detail.userName);
2713
+ break;
2714
+ case 'delete-chat':
2715
+ this.deleteConversation(event.detail.conversationId);
2716
+ break;
2717
+ case 'clear-chat':
2718
+ // Call clearConversation with the selected conversation ID
2719
+ this.clearConversation(event.detail.conversationId);
2720
+ break;
2721
+ }
2722
+ }
2723
+ handleChatTileScrolledToBottom() {
2724
+ this.conversationCountSkip += 20;
2725
+ if (this.hasMoreConversations) {
2726
+ this.getConversations(this.conversationCountSkip);
2727
+ }
2728
+ }
2729
+ // Add a method to reset notification count
2730
+ resetNewMessageNotification() {
2731
+ this.newMessageNotification = null;
2732
+ }
2733
+ async handleConversationUpdate(event) {
2734
+ const { conversationId, type, value } = event.detail;
2735
+ // Immediately update the conversation in the list (optimistic update)
2736
+ if (type === 'title' && value) {
2737
+ this.allConversationList = this.allConversationList.map(conv => conv.conversationId === conversationId
2738
+ ? Object.assign(Object.assign({}, conv), { conversationTitle: value }) : conv);
2739
+ }
2740
+ else if (type === 'image' && value) {
2741
+ this.allConversationList = this.allConversationList.map(conv => conv.conversationId === conversationId
2742
+ ? Object.assign(Object.assign({}, conv), { conversationImageUrl: value }) : conv);
2743
+ }
2744
+ try {
2745
+ // Fetch updated conversation details from server for consistency
2746
+ const response = await M.getInstance().Conversation.getConversationDetails(conversationId, 'true');
2747
+ if (response) {
2748
+ // Update the conversation in the list with server response
2749
+ this.allConversationList = this.allConversationList.map(conv => (conv.conversationId === conversationId ? Object.assign(Object.assign({}, conv), response) : conv));
2750
+ // If this is the currently selected conversation, update conversation metadata
2751
+ if (this.selectedConversationId === conversationId) {
2752
+ this.conversationMetaData = response;
2753
+ }
2754
+ }
2755
+ }
2756
+ catch (error) {
2757
+ console.error('Error refreshing conversation details:', error);
2758
+ }
2759
+ }
2760
+ async watchPropHandler(newValue) {
2761
+ if ((newValue === null || newValue === void 0 ? void 0 : newValue.updateBlockStatus) || ((newValue === null || newValue === void 0 ? void 0 : newValue.messagingDisabled) && this.isBlocked === null)) {
2762
+ await this.findBlokedUser();
2763
+ }
2764
+ }
2765
+ async findBlokedUser() {
2766
+ var _a, _b;
2767
+ this.isBlocked = 'loading';
2768
+ try {
2769
+ const findRes = await M.getInstance().user.getUserBlock({
2770
+ searchTag: (_b = (_a = this.conversationMetaData) === null || _a === void 0 ? void 0 : _a.opponentDetails) === null || _b === void 0 ? void 0 : _b.userName,
2771
+ });
2772
+ const users = (findRes === null || findRes === void 0 ? void 0 : findRes.users) || [];
2773
+ const currUser = users === null || users === void 0 ? void 0 : users.find(u => { var _a, _b; return (u === null || u === void 0 ? void 0 : u.userId) === ((_b = (_a = this.conversationMetaData) === null || _a === void 0 ? void 0 : _a.opponentDetails) === null || _b === void 0 ? void 0 : _b.userId); });
2774
+ this.isBlocked = currUser ? true : null;
2775
+ }
2776
+ catch (e) {
2777
+ this.isBlocked = null;
2778
+ }
2779
+ finally {
2780
+ this.isConversationLoading = false;
2781
+ }
2782
+ }
2783
+ handleGroupcastScroll() {
2784
+ if (this.hasMoreGroupcast && !this.isLoadingMoreGroupcast) {
2785
+ this.getGroupCastContacts(this.groupcastSkip + 20);
2786
+ }
2787
+ }
2788
+ async handleDeleteGroupcast(e) {
2789
+ var _a;
2790
+ try {
2791
+ const groupcastId = (_a = e === null || e === void 0 ? void 0 : e.detail) === null || _a === void 0 ? void 0 : _a.groupcastId;
2792
+ await deleteGroupCast(groupcastId);
2793
+ this.allGroupCastContacts = this.allGroupCastContacts.filter(groupcast => groupcast.groupcastId !== groupcastId);
2794
+ const url = new URL(window.location.href);
2795
+ url.searchParams.delete('groupcast');
2796
+ window.history.pushState({}, '', url);
2797
+ this.selectedConversationId = null;
2798
+ this.showSidebar = true;
2799
+ showToast({
2800
+ message: 'Groupcast deleted successfully',
2801
+ type: 'success',
2802
+ duration: 3000,
2803
+ position: 'bottom-left',
2804
+ });
2805
+ }
2806
+ catch (error) {
2807
+ console.error('Error deleting groupcast:', error);
2808
+ showToast({
2809
+ message: 'Error while deleting groupcast',
2810
+ type: 'error',
2811
+ duration: 3000,
2812
+ position: 'bottom-left',
2813
+ });
2814
+ }
2815
+ }
2816
+ render() {
2817
+ var _a, _b, _c, _d, _e;
2818
+ return (h$1(Fragment, { key: '54bf58235570d4cd19ae3bbc1ac54dda2346d644' }, this.isLoading ? (h$1("chat-loading-placeholder", { progress: this.loadingProgress, loadingStatus: this.loadingStatus })) : (h$1(Fragment, null, this.isConversationLoading ? (h$1("div", { class: "loaderoverlay" }, h$1("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary-color)", spinnerSecondaryColor: "var(--text-primary-color)", spinnerBorderWidth: "2px" }))) : null, h$1("div", { class: {
2819
+ 'isometrik-quickchat': true,
2820
+ 'is-resizing': this.isResizingSidebar,
2821
+ 'is-instagram-gate': !this.isInstagramConnected,
2822
+ }, style: { '--sidebar-width': `${this.sidebarListWidth}px` } }, h$1("div", { class: {
2823
+ 'chat-sidebar-container': true,
2824
+ 'hidden': this.isMobileView && !this.showSidebar,
2825
+ 'is-resizing': this.isResizingSidebar,
2826
+ 'is-full-gate': !this.isInstagramConnected,
2827
+ } }, h$1("profile-sidebar", { userMetaData: this.userMetaData, activeTab: this.activeTab, openChat: this.openChatTab, openAccounts: () => (this.activeTab = 'Accounts'), isMqttConnected: this.isMqttConnected, unreadConversationsCount: this.isInstagramConnected ? this.unreadConversationsCount : 0 }), h$1("div", { class: 'sidebar-tab' }, this.activeTab === 'GroupCast' ? (h$1("group-cast", { isLoadingMore: this.isLoadingMoreGroupcast, groupCastData: this.allGroupCastContacts, onGroupcastTileSelected: (e) => this.handleChatSelect(e.detail) })) : this.activeTab === 'Chat' && this.isInstagramConnected ? (h$1("chat-side-bar", { conversationDetails: this.conversationMetaData, isMqttConnected: this.isMqttConnected, unreadConversationsCount: this.unreadConversationsCount, hasMoreConversations: this.hasMoreConversations, userMetaData: this.userMetaData, onChatTileSelected: (e) => this.handleChatSelect(e.detail), onDeleteConversation: (conversationId) => this.deleteConversation(conversationId), conversationList: this.allConversationList, isTyping: this.isTyping, typingUserName: this.typingUserName, typingConversationId: this.typingConversationId,
2828
+ // unreadMessageCount={this.unreadMessageCount}
2829
+ //@ts-ignore
2830
+ isChatFilter: this.isChatFilter, customTypes: [
2831
+ { type: 'Test conversations', label: 'Unread' },
2832
+ { type: 'SingleChat', label: 'Past' },
2833
+ { type: 'Chatbot', label: 'Present' },
2834
+ ], isAllChatButton: this.isAllChatButton, filterTabsContainer: {
2835
+ display: 'flex',
2836
+ gap: '10px',
2837
+ width: '100%',
2838
+ flexWrap: 'wrap',
2839
+ marginBottom: '10px',
2840
+ }, filterTab: {
2841
+ padding: '6px 12px',
2842
+ border: '1px solid var(--border-subtle)',
2843
+ borderRadius: 'var(--radius-pill)',
2844
+ backgroundColor: 'transparent',
2845
+ cursor: 'pointer',
2846
+ transition: 'background-color 0.18s, color 0.18s',
2847
+ color: 'var(--text-secondary-color)',
2848
+ fontSize: '13px',
2849
+ fontWeight: '500',
2850
+ }, filterTabHover: {
2851
+ backgroundColor: 'var(--bg-primary-light)',
2852
+ color: 'var(--text-primary-color)',
2853
+ }, isSidebarHeaderLabel: this.isSidebarHeaderLabel, isSidebarHeaderSearch: this.isSidebarHeaderSearch, sidebarHeaderLabel: this.sidebarHeaderLabel, sidebarColor: this.sidebarColor, sidebarSelectedColor: this.sidebarSelectedColor, onGroupExited: (e) => this.handleGroupExited(e), handleSearchData: (searchTag) => this.getConversations(0, searchTag, true), allMessages: this.allMessages, isConversationLoading: this.isLoadingConversationList })) : this.activeTab === 'Accounts' || !this.isInstagramConnected ? (h$1("instagram-accounts-panel", { agentUserId: (_a = this.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, defaultTheme: this.defaultTheme, toggleTheme: this.toggleTheme, closeDrawer: this.closeAccountsDrawer, hideClose: !this.isInstagramConnected, onInstagramAccountsChange: (e) => this.handleInstagramAccountsChange(e.detail || []) })) : (h$1("profile-page", { getUserDetails: this.getUserDetails, name: this.userMetaData.userName, profilePhotoUrl: this.userMetaData.userProfileImageUrl, closeDrawer: () => (this.activeTab = this.isInstagramConnected ? 'Chat' : 'Accounts'), toggleTheme: this.toggleTheme, defaultTheme: this.defaultTheme, agentUserId: (_b = this.userMetaData) === null || _b === void 0 ? void 0 : _b.userId, onInstagramAccountsChanged: (e) => this.handleInstagramAccountsChange(e.detail || []) }))), !this.isMobileView && this.isInstagramConnected ? (h$1("div", { class: {
2854
+ 'sidebar-resize-handle': true,
2855
+ 'active': this.isResizingSidebar,
2856
+ }, role: "separator", "aria-orientation": "vertical", "aria-label": "Resize sidebar", "aria-valuenow": this.sidebarListWidth, "aria-valuemin": this.SIDEBAR_MIN, "aria-valuemax": this.SIDEBAR_MAX, onPointerDown: this.startSidebarResize }, h$1("span", { class: "sidebar-resize-grip", "aria-hidden": "true" }))) : null), this.isInstagramConnected ? (h$1("div", { class: {
2857
+ 'chat-body-container': true,
2858
+ 'show': this.isMobileView && this.selectedConversationId && !this.showSidebar,
2859
+ } }, this.selectedConversationId ? (h$1(Fragment, null, h$1("web-chat-header", { searchedMessageDetails: this.searchedMessageDetails, onSearchHandler: (text) => this.getMessagesByQuery(text), onSearchResultClick: this.handleSearchResultClick, headerBgColor: "var(--bg-primary-color)", headerLastSeenColor: "var(--text-last-seen)", headerSvgColor: "var(--text-primary-color)", headerUsernameColor: "var(--text-primary-color)", onClearConversation: () => this.clearConversation(), conversationDetails: this.conversationMetaData, isTyping: this.isTyping && this.selectedConversationId === this.typingConversationId, typingUserName: this.typingUserName, chatBodyRef: this.chatBodyRef, onTextClick: () => this.getAllAttachments(this.selectedConversationId), allAttachments: this.allAttachments, lastSeen: (_d = (_c = this.conversationMetaData) === null || _c === void 0 ? void 0 : _c.opponentDetails) === null || _d === void 0 ? void 0 : _d.lastSeen, userMetaData: this.userMetaData, selectedConversationId: this.selectedConversationId, messageAction: this.messageAction, eligibleMembers: this.eligibleMembers, hasMoreEligibleMembers: this.hasMoreEligibleMembers, handleCloseChat: () => this.handleCloseChat(), typingConversationId: this.typingConversationId, isBlocked: this.isBlocked, onBackButtonClick: this.handleBackButton }), h$1("web-chat-body", { ref: el => (this.chatBodyRef = el), allAttachments: this.allAttachments, isMessagesLoading: this.isMessagesLoading, updateSkip: this.updateSkip, isMessageLimitEnd: this.isMessageLimitEnd, allMessages: this.allMessages, userMetaData: this.userMetaData, skip: this.skip, isScrollToBottom: this.isScrollToBottom, changeScrollToBottomState: this.changeScrollToBottomState, isMessageSending: this.isMessageSending, isScrollToTop: this.isScrollToTop, changeScrollToTopState: this.changeScrollToTopState, deleteForSelf: this.deleteMessageFromSelf, deleteForAll: this.deleteMeassageFromEveryOne, isChatClosed: this.isChatClosed, isChatMinimized: this.isChatMinimized, updateAllMessages: this.updateAllMessages, selectedConversationId: this.selectedConversationId, highlightedMessageId: this.highlightedMessageId, onMediaClick: () => this.getAllAttachments(this.selectedConversationId), onReplyMessageDetails: this.handleReplyMessage, conversationList: this.allConversationList, newMessageNotification: this.newMessageNotification, onNewMessageCountReset: () => this.resetNewMessageNotification(), conversationDetails: this.conversationMetaData, loadingMediaGallery: this.loadingMediaGallery }), this.exitedGroupIds.has(this.selectedConversationId) ? (h$1("div", { style: {
2860
+ padding: '1rem',
2861
+ textAlign: 'center',
2862
+ backgroundColor: 'var(--bg-primary-color)',
2863
+ color: 'var(--text-secondary-color)',
2864
+ borderTop: '1px solid var(--border-subtle)',
2865
+ fontSize: '13px',
2866
+ } }, "You are no longer a member of this group")) : this.isBlocked === 'loading' ? (h$1("p", { class: "blockMessageContainer" }, WEB_CONTENT.PLEASE_WAIT)) : ((_e = this.conversationMetaData) === null || _e === void 0 ? void 0 : _e.messagingDisabled) ? (h$1("p", { class: "blockMessageContainer" }, WEB_CONTENT.BLOCK_CHAT_MESSAGE)) : (h$1("chat-footer", { userMetaData: this.userMetaData, updateAllMessages: this.updateAllMessages, changeMessageSendingState: this.changeMessageSendingState, changeScrollToBottomState: this.changeScrollToBottomState, refetchMessages: this.refetchMessages, allMessages: this.allMessages, selectedConversationId: this.selectedConversationId, replyMessage: this.replyMessage, handleremoveReplyMessage: this.handleremoveReplyMessage, conversationDetails: this.conversationMetaData, allConversationList: this.allConversationList, updateConversationListProp: this.updateConversationList })))) : (h$1("div", { class: "noChatSelectedPlaceholder" }, h$1("div", { class: "empty-mark", "aria-hidden": "true" }, h$1("span", null), h$1("span", null)), h$1("h2", null, "Select a chat"), h$1("p", null, "Open a thread on the left to get started."))))) : null, this.isInstagramConnected && this.showRightSideBar ? (h$1("div", { class: 'chat-sidebar-right' }, h$1("web-chat-right-sidebar", { conversationMetaData: this.isProfileInfoOpen ? this.selctConversationMetaData : this.conversationMetaData, selectedConversationId: this.selectedConversationId, hasMoreEligibleMembers: this.hasMoreEligibleMembers, eligibleMembers: this.eligibleMembers, allAttachments: this.isProfileInfoOpen ? this.selectConverSationAttachments : this.allAttachments, userMetaData: this.userMetaData, messageAction: this.messageAction, searchedMessageDetails: this.searchedMessageDetails, onSearchHandler: (text) => this.getMessagesByQuery(text), onSearchResultClick: this.handleSearchResultClick, isContactInfoOpen: this.isContactInfoOpen, isProfileInfoOpen: this.isProfileInfoOpen, isOpenSearchBar: this.isOpenSearchBar, chatBodyRef: this.chatBodyRef, isLoadingMessage: this.isLoadingMessage, conversationIdFromContactinfo: this.conversationIdFromContactinfo, openOwnProfile: () => (this.activeTab = 'Profile'), handleChatSelect: conversationId => this.handleChatSelect(conversationId), allLinks: this.allLinks, allLinksCount: this.allLinksCount, isBlocked: this.isBlocked, groupcastMembers: this.groupcastMembers }))) : null)))));
2867
+ }
2868
+ static get watchers() { return {
2869
+ "selectedConversationId": ["handleConversationChange", "handleSelectedConversationChange"],
2870
+ "skip": ["handleSkipChange"],
2871
+ "isTyping": ["handleTypingChange"],
2872
+ "initialConversationIdFromURL": ["handleSelectedConversationChange"],
2873
+ "allMessages": ["handlemessageAction"],
2874
+ "selectConversationMessages": ["handlemessageAction"],
2875
+ "conversationMetaData": ["watchPropHandler"]
2876
+ }; }
2877
+ };
2878
+ WebChat.style = WebChatStyle0;
2879
+
2880
+ export { WebChat as W };
2881
+
2882
+ //# sourceMappingURL=WebChat-5448d615.js.map