isometrik-plugin-chat-sdk 1.3.19 → 2.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 (476) hide show
  1. package/dist/cjs/app-globals-61a8bfde.js +38 -0
  2. package/dist/cjs/app-globals-61a8bfde.js.map +1 -0
  3. package/dist/cjs/attachment-preview_22.cjs.entry.js +122 -44
  4. package/dist/cjs/attachment-preview_22.cjs.entry.js.map +1 -1
  5. package/dist/cjs/audio-bubble_4.cjs.entry.js +38 -8
  6. package/dist/cjs/audio-bubble_4.cjs.entry.js.map +1 -1
  7. package/dist/cjs/chat-app.cjs.entry.js +2 -2
  8. package/dist/cjs/chat-app.cjs.entry.js.map +1 -1
  9. package/dist/cjs/{chat-creds-cf537d4b.js → chat-creds-2dbc4087.js} +3 -3
  10. package/dist/cjs/chat-creds-2dbc4087.js.map +1 -0
  11. package/dist/cjs/chat-document-message-bubble.cjs.entry.js +1 -1
  12. package/dist/cjs/chat-image-message-bubble.cjs.entry.js +1 -1
  13. package/dist/cjs/chat-video-message-bubble.cjs.entry.js +1 -1
  14. package/dist/cjs/client-80851676.js +482 -0
  15. package/dist/cjs/client-80851676.js.map +1 -0
  16. package/dist/cjs/{contracts-31632812.js → contracts-dfc84075.js} +2 -2
  17. package/dist/cjs/contracts-dfc84075.js.map +1 -0
  18. package/dist/cjs/destroy-chat-7ae8fc99.js +24 -0
  19. package/dist/cjs/destroy-chat-7ae8fc99.js.map +1 -0
  20. package/dist/cjs/doublecheck-c2461adc.js +36 -0
  21. package/dist/cjs/doublecheck-c2461adc.js.map +1 -0
  22. package/dist/cjs/{drawer-28cc94a4.js → drawer-811d2ce8.js} +2 -2
  23. package/dist/cjs/{drawer-28cc94a4.js.map → drawer-811d2ce8.js.map} +1 -1
  24. package/dist/cjs/forward-memebers.cjs.entry.js +2 -2
  25. package/dist/cjs/forward-message.cjs.entry.js +2 -2
  26. package/dist/cjs/group-chat-contacts.cjs.entry.js +2 -2
  27. package/dist/cjs/{group-members-73ad1074.js → group-members-5a82ec8a.js} +1 -125
  28. package/dist/cjs/group-members-5a82ec8a.js.map +1 -0
  29. package/dist/cjs/{helpers-8061ec7d.js → helpers-154861e9.js} +2 -2
  30. package/dist/cjs/{helpers-8061ec7d.js.map → helpers-154861e9.js.map} +1 -1
  31. package/dist/cjs/{index-1a26d11d.js → index-66f98408.js} +2 -2
  32. package/dist/cjs/index-66f98408.js.map +1 -0
  33. package/dist/cjs/index.cjs.js +55 -182
  34. package/dist/cjs/index.cjs.js.map +1 -1
  35. package/dist/cjs/isometrik-webchat.cjs.js +10 -2
  36. package/dist/cjs/isometrik-webchat.cjs.js.map +1 -1
  37. package/dist/cjs/loader.cjs.js +10 -2
  38. package/dist/cjs/loader.cjs.js.map +1 -1
  39. package/dist/cjs/login-page_3.cjs.entry.js +689 -369
  40. package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
  41. package/dist/cjs/media-gallery.cjs.entry.js +1 -1
  42. package/dist/cjs/media-limits-eba42629.js +165 -0
  43. package/dist/cjs/media-limits-eba42629.js.map +1 -0
  44. package/dist/cjs/member-add.cjs.entry.js +3 -3
  45. package/dist/cjs/message-bubble.cjs.entry.js +30 -8
  46. package/dist/cjs/message-bubble.cjs.entry.js.map +1 -1
  47. package/dist/cjs/my-component.cjs.entry.js +1 -1
  48. package/dist/cjs/new-chat-sidebar.cjs.entry.js +2 -2
  49. package/dist/cjs/reaction-container.cjs.entry.js +4 -4
  50. package/dist/cjs/runtime-controls-201c71ba.js +650 -0
  51. package/dist/cjs/runtime-controls-201c71ba.js.map +1 -0
  52. package/dist/cjs/send-media-14908d4b.js +375 -0
  53. package/dist/cjs/send-media-14908d4b.js.map +1 -0
  54. package/dist/cjs/signup-page.cjs.entry.js +1 -1
  55. package/dist/cjs/{toast-0bf1e688.js → toast-f810e550.js} +8 -8
  56. package/dist/cjs/toast-f810e550.js.map +1 -0
  57. package/dist/collection/collection-manifest.json +2 -1
  58. package/dist/collection/components/ChatUIComponent/ChatDocumentMessageBubble.js +1 -1
  59. package/dist/collection/components/ChatUIComponent/ChatImageMessageBubble.js +1 -1
  60. package/dist/collection/components/ChatUIComponent/ChatVideoMessageBubble.js +1 -1
  61. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js +61 -14
  62. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js.map +1 -1
  63. package/dist/collection/components/ChatUIComponent/ReactionContainer.js +2 -2
  64. package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js +7 -6
  65. package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js.map +1 -1
  66. package/dist/collection/components/ChatUIComponent/shared/attachment-preview/attachment-preview.js +39 -8
  67. package/dist/collection/components/ChatUIComponent/shared/attachment-preview/attachment-preview.js.map +1 -1
  68. package/dist/collection/components/ChatUIComponent/shared/document-message/document-message.js +53 -3
  69. package/dist/collection/components/ChatUIComponent/shared/document-message/document-message.js.map +1 -1
  70. package/dist/collection/components/ChatUIComponent/shared/forward-message/forward-message.js +2 -2
  71. package/dist/collection/components/ChatUIComponent/shared/image-message/image-message.js +19 -1
  72. package/dist/collection/components/ChatUIComponent/shared/image-message/image-message.js.map +1 -1
  73. package/dist/collection/components/ChatUIComponent/shared/incoming-text-message-bubble/incoming-text-message-bubble.js +1 -1
  74. package/dist/collection/components/ChatUIComponent/shared/message-bubble/message-bubble.js +47 -7
  75. package/dist/collection/components/ChatUIComponent/shared/message-bubble/message-bubble.js.map +1 -1
  76. package/dist/collection/components/ChatUIComponent/shared/message-date-pill/message-date-pill.js +1 -1
  77. package/dist/collection/components/ChatUIComponent/shared/new chat/new-chat.stories.js +1 -1
  78. package/dist/collection/components/ChatUIComponent/shared/outgoing-text-message-bubble/outgoing-text-message-bubble.js +19 -1
  79. package/dist/collection/components/ChatUIComponent/shared/outgoing-text-message-bubble/outgoing-text-message-bubble.js.map +1 -1
  80. package/dist/collection/components/ChatUIComponent/shared/reply-message-container/reply-message-container.js +1 -1
  81. package/dist/collection/components/ChatUIComponent/shared/video-message/video-message.js +20 -2
  82. package/dist/collection/components/ChatUIComponent/shared/video-message/video-message.js.map +1 -1
  83. package/dist/collection/components/my-component/my-component.js +1 -1
  84. package/dist/collection/components/my-component/web-chat/FLOW.js +1 -1
  85. package/dist/collection/components/my-component/web-chat/FLOW.js.map +1 -1
  86. package/dist/collection/components/my-component/web-chat/WebChat.js +113 -12
  87. package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -1
  88. package/dist/collection/components/my-component/web-chat/bootstrap.js +7 -0
  89. package/dist/collection/components/my-component/web-chat/bootstrap.js.map +1 -1
  90. package/dist/collection/components/my-component/web-chat/data-fetch.js +14 -5
  91. package/dist/collection/components/my-component/web-chat/data-fetch.js.map +1 -1
  92. package/dist/collection/components/my-component/web-chat/mqtt-host.js +133 -34
  93. package/dist/collection/components/my-component/web-chat/mqtt-host.js.map +1 -1
  94. package/dist/collection/components/my-component/web-chat/offline-host.js +212 -0
  95. package/dist/collection/components/my-component/web-chat/offline-host.js.map +1 -0
  96. package/dist/collection/components/my-component/web-chat/public-send.js +96 -21
  97. package/dist/collection/components/my-component/web-chat/public-send.js.map +1 -1
  98. package/dist/collection/components/my-component/web-chat/shell-render.js +47 -28
  99. package/dist/collection/components/my-component/web-chat/shell-render.js.map +1 -1
  100. package/dist/collection/components/theme-provider.js +114 -45
  101. package/dist/collection/components/theme-provider.js.map +1 -1
  102. package/dist/collection/constants/chat-creds.js +2 -2
  103. package/dist/collection/demos/custom-ui-demo-elements.js +2 -2
  104. package/dist/collection/demos/custom-ui-demo-elements.js.map +1 -1
  105. package/dist/collection/global/expose-sdk.js +29 -0
  106. package/dist/collection/global/expose-sdk.js.map +1 -0
  107. package/dist/collection/index.js +10 -141
  108. package/dist/collection/index.js.map +1 -1
  109. package/dist/collection/lib/chat/index.js +3 -0
  110. package/dist/collection/lib/chat/index.js.map +1 -1
  111. package/dist/collection/lib/chat/media-limits.js +21 -0
  112. package/dist/collection/lib/chat/media-limits.js.map +1 -0
  113. package/dist/collection/lib/chat/media-outbox.js +43 -0
  114. package/dist/collection/lib/chat/media-outbox.js.map +1 -0
  115. package/dist/collection/lib/chat/preview-kind.js +41 -0
  116. package/dist/collection/lib/chat/preview-kind.js.map +1 -0
  117. package/dist/collection/lib/chat/send-media.js +5 -2
  118. package/dist/collection/lib/chat/send-media.js.map +1 -1
  119. package/dist/collection/lib/custom-ui/contracts.js +1 -1
  120. package/dist/collection/lib/custom-ui/contracts.js.map +1 -1
  121. package/dist/collection/lib/custom-ui/index.js +1 -1
  122. package/dist/collection/lib/custom-ui/index.js.map +1 -1
  123. package/dist/collection/lib/custom-ui/public-api.js +1 -0
  124. package/dist/collection/lib/custom-ui/public-api.js.map +1 -1
  125. package/dist/collection/lib/destroy-chat.js +15 -16
  126. package/dist/collection/lib/destroy-chat.js.map +1 -0
  127. package/dist/collection/lib/mqtt/inbound-queue.js +17 -0
  128. package/dist/collection/lib/mqtt/inbound-queue.js.map +1 -0
  129. package/dist/collection/lib/mqtt/index.js +2 -1
  130. package/dist/collection/lib/mqtt/index.js.map +1 -1
  131. package/dist/collection/lib/mqtt/session.js +50 -6
  132. package/dist/collection/lib/mqtt/session.js.map +1 -1
  133. package/dist/collection/lib/offline/client.js +167 -0
  134. package/dist/collection/lib/offline/client.js.map +1 -0
  135. package/dist/collection/lib/offline/idb.js +181 -0
  136. package/dist/collection/lib/offline/idb.js.map +1 -0
  137. package/dist/collection/lib/offline/index.js +10 -0
  138. package/dist/collection/lib/offline/index.js.map +1 -0
  139. package/dist/collection/lib/offline/memory-db.js +64 -0
  140. package/dist/collection/lib/offline/memory-db.js.map +1 -0
  141. package/dist/collection/lib/offline/merge.js +24 -0
  142. package/dist/collection/lib/offline/merge.js.map +1 -0
  143. package/dist/collection/lib/offline/multitab.js +47 -0
  144. package/dist/collection/lib/offline/multitab.js.map +1 -0
  145. package/dist/collection/lib/offline/types.js +2 -0
  146. package/dist/collection/lib/offline/types.js.map +1 -0
  147. package/dist/collection/lib/toast.js +6 -6
  148. package/dist/collection/lib/toast.js.map +1 -1
  149. package/dist/collection/sdk/api.js +4 -0
  150. package/dist/collection/sdk/api.js.map +1 -0
  151. package/dist/collection/sdk/composition.js +43 -0
  152. package/dist/collection/sdk/composition.js.map +1 -0
  153. package/dist/collection/sdk/headless-api.js +37 -0
  154. package/dist/collection/sdk/headless-api.js.map +1 -0
  155. package/dist/collection/sdk/index.js +11 -0
  156. package/dist/collection/sdk/index.js.map +1 -0
  157. package/dist/collection/sdk/init.js +207 -0
  158. package/dist/collection/sdk/init.js.map +1 -0
  159. package/dist/collection/sdk/instance.js +63 -0
  160. package/dist/collection/sdk/instance.js.map +1 -0
  161. package/dist/collection/sdk/react-bridge.js +145 -0
  162. package/dist/collection/sdk/react-bridge.js.map +1 -0
  163. package/dist/collection/sdk/runtime-controls.js +54 -0
  164. package/dist/collection/sdk/runtime-controls.js.map +1 -0
  165. package/dist/collection/sdk/slots.js +57 -0
  166. package/dist/collection/sdk/slots.js.map +1 -0
  167. package/dist/collection/sdk/theme-tokens.js +99 -0
  168. package/dist/collection/sdk/theme-tokens.js.map +1 -0
  169. package/dist/collection/sdk/webchat-api.js +36 -0
  170. package/dist/collection/sdk/webchat-api.js.map +1 -0
  171. package/dist/collection/testing/chat-assets-mock.js +45 -0
  172. package/dist/collection/testing/chat-creds-mock.js +18 -0
  173. package/dist/collection/testing/emoji-picker-mock.js +2 -0
  174. package/dist/collection/testing/file-mock.js +1 -0
  175. package/dist/collection/testing/groupcast-mock.js +7 -0
  176. package/dist/collection/testing/helpers-mock.js +4 -0
  177. package/dist/collection/testing/iso-chat-sdk-mock.js +19 -0
  178. package/dist/collection/testing/toast-mock.js +2 -0
  179. package/dist/components/ChatFooter.js +62 -15
  180. package/dist/components/ChatFooter.js.map +1 -1
  181. package/dist/components/ChatSidebar.js +1 -1
  182. package/dist/components/{GroupCast.js → GroupCast2.js} +2 -2
  183. package/dist/components/GroupCast2.js.map +1 -0
  184. package/dist/components/WebChat.js +624 -305
  185. package/dist/components/WebChat.js.map +1 -1
  186. package/dist/components/WebChatBody.js +8 -7
  187. package/dist/components/WebChatBody.js.map +1 -1
  188. package/dist/components/attachment-preview2.js +40 -9
  189. package/dist/components/attachment-preview2.js.map +1 -1
  190. package/dist/components/chat-app.js +3 -3
  191. package/dist/components/chat-app.js.map +1 -1
  192. package/dist/components/chat-assets.js +1 -1
  193. package/dist/components/chat-creds.js +2 -2
  194. package/dist/components/chat-creds.js.map +1 -1
  195. package/dist/components/chat-document-message-bubble.js +1 -1
  196. package/dist/components/chat-image-message-bubble.js +1 -1
  197. package/dist/components/chat-tile2.js +1 -1
  198. package/dist/components/chat-video-message-bubble.js +1 -1
  199. package/dist/components/client.js +728 -0
  200. package/dist/components/client.js.map +1 -0
  201. package/dist/components/contact-info2.js +2 -117
  202. package/dist/components/contact-info2.js.map +1 -1
  203. package/dist/components/contracts.js +1 -1
  204. package/dist/components/contracts.js.map +1 -1
  205. package/dist/components/destroy-chat.js +14 -16
  206. package/dist/components/destroy-chat.js.map +1 -1
  207. package/dist/components/document-message2.js +35 -5
  208. package/dist/components/document-message2.js.map +1 -1
  209. package/dist/components/forward-message.js +2 -2
  210. package/dist/components/group-cast.js +1 -1
  211. package/dist/components/{groupcast2.js → groupcast.js} +1 -1
  212. package/dist/components/groupcast.js.map +1 -0
  213. package/dist/components/image-message2.js +3 -1
  214. package/dist/components/image-message2.js.map +1 -1
  215. package/dist/components/incoming-text-message-bubble2.js +1 -1
  216. package/dist/components/index.js +551 -60
  217. package/dist/components/index.js.map +1 -1
  218. package/dist/components/index2.js +1 -1
  219. package/dist/components/index2.js.map +1 -1
  220. package/dist/components/media-limits.js +24 -0
  221. package/dist/components/media-limits.js.map +1 -0
  222. package/dist/components/member-add.js +1 -1
  223. package/dist/components/message-bubble2.js +31 -7
  224. package/dist/components/message-bubble2.js.map +1 -1
  225. package/dist/components/message-date-pill2.js +1 -1
  226. package/dist/components/messages.js +131 -0
  227. package/dist/components/messages.js.map +1 -0
  228. package/dist/components/my-component.js +1 -1
  229. package/dist/components/outgoing-text-message-bubble2.js +3 -1
  230. package/dist/components/outgoing-text-message-bubble2.js.map +1 -1
  231. package/dist/components/preview-kind.js +30 -0
  232. package/dist/components/preview-kind.js.map +1 -0
  233. package/dist/components/reaction-container.js +2 -2
  234. package/dist/components/reply-message-container2.js +1 -1
  235. package/dist/components/theme-provider2.js +56 -44
  236. package/dist/components/theme-provider2.js.map +1 -1
  237. package/dist/components/theme-tokens.js +102 -0
  238. package/dist/components/theme-tokens.js.map +1 -0
  239. package/dist/components/toast.js +6 -6
  240. package/dist/components/toast.js.map +1 -1
  241. package/dist/components/video-message2.js +4 -2
  242. package/dist/components/video-message2.js.map +1 -1
  243. package/dist/esm/app-globals-2beecb81.js +36 -0
  244. package/dist/esm/app-globals-2beecb81.js.map +1 -0
  245. package/dist/esm/attachment-preview_22.entry.js +120 -42
  246. package/dist/esm/attachment-preview_22.entry.js.map +1 -1
  247. package/dist/esm/audio-bubble_4.entry.js +39 -9
  248. package/dist/esm/audio-bubble_4.entry.js.map +1 -1
  249. package/dist/esm/chat-app.entry.js +2 -2
  250. package/dist/esm/chat-app.entry.js.map +1 -1
  251. package/dist/esm/{chat-assets-e3173222.js → chat-assets-bb056958.js} +2 -2
  252. package/dist/esm/{chat-assets-e3173222.js.map → chat-assets-bb056958.js.map} +1 -1
  253. package/dist/esm/{chat-creds-5d0982fc.js → chat-creds-aafad4d0.js} +3 -3
  254. package/dist/esm/chat-creds-aafad4d0.js.map +1 -0
  255. package/dist/esm/chat-document-message-bubble.entry.js +1 -1
  256. package/dist/esm/chat-image-message-bubble.entry.js +1 -1
  257. package/dist/esm/chat-tile_3.entry.js +1 -1
  258. package/dist/esm/chat-video-message-bubble.entry.js +1 -1
  259. package/dist/esm/client-4a3e00da.js +477 -0
  260. package/dist/esm/client-4a3e00da.js.map +1 -0
  261. package/dist/esm/{contracts-614be4db.js → contracts-50f4ddae.js} +2 -2
  262. package/dist/esm/contracts-50f4ddae.js.map +1 -0
  263. package/dist/esm/destroy-chat-d0ee28d6.js +22 -0
  264. package/dist/esm/destroy-chat-d0ee28d6.js.map +1 -0
  265. package/dist/esm/doublecheck-261763ef.js +32 -0
  266. package/dist/esm/doublecheck-261763ef.js.map +1 -0
  267. package/dist/esm/{drawer-8f721119.js → drawer-74c188f1.js} +2 -2
  268. package/dist/esm/{drawer-8f721119.js.map → drawer-74c188f1.js.map} +1 -1
  269. package/dist/esm/forward-memebers.entry.js +3 -3
  270. package/dist/esm/forward-message.entry.js +2 -2
  271. package/dist/esm/group-chat-contacts.entry.js +2 -2
  272. package/dist/esm/{group-members-806fd7a2.js → group-members-05414da2.js} +2 -118
  273. package/dist/esm/group-members-05414da2.js.map +1 -0
  274. package/dist/esm/{groupcast-2ce7187f.js → groupcast-9c7d2a32.js} +2 -2
  275. package/dist/esm/{groupcast-2ce7187f.js.map → groupcast-9c7d2a32.js.map} +1 -1
  276. package/dist/esm/{helpers-4c6d09a7.js → helpers-f33b895c.js} +2 -2
  277. package/dist/esm/{helpers-4c6d09a7.js.map → helpers-f33b895c.js.map} +1 -1
  278. package/dist/esm/{index-beb184c6.js → index-4c865e34.js} +2 -2
  279. package/dist/esm/index-4c865e34.js.map +1 -0
  280. package/dist/esm/index.js +17 -171
  281. package/dist/esm/index.js.map +1 -1
  282. package/dist/esm/isometrik-webchat.js +10 -2
  283. package/dist/esm/isometrik-webchat.js.map +1 -1
  284. package/dist/esm/loader.js +10 -2
  285. package/dist/esm/loader.js.map +1 -1
  286. package/dist/esm/login-page_3.entry.js +672 -352
  287. package/dist/esm/login-page_3.entry.js.map +1 -1
  288. package/dist/esm/media-gallery.entry.js +1 -1
  289. package/dist/esm/media-limits-3fa07c09.js +152 -0
  290. package/dist/esm/media-limits-3fa07c09.js.map +1 -0
  291. package/dist/esm/member-add.entry.js +5 -5
  292. package/dist/esm/message-bubble.entry.js +30 -8
  293. package/dist/esm/message-bubble.entry.js.map +1 -1
  294. package/dist/esm/my-component.entry.js +1 -1
  295. package/dist/esm/new-chat-sidebar.entry.js +3 -3
  296. package/dist/esm/reaction-container.entry.js +4 -4
  297. package/dist/esm/runtime-controls-cf599fe2.js +623 -0
  298. package/dist/esm/runtime-controls-cf599fe2.js.map +1 -0
  299. package/dist/esm/send-media-917dcc2f.js +353 -0
  300. package/dist/esm/send-media-917dcc2f.js.map +1 -0
  301. package/dist/esm/signup-page.entry.js +1 -1
  302. package/dist/esm/{toast-d8ea763c.js → toast-533dd183.js} +8 -8
  303. package/dist/esm/toast-533dd183.js.map +1 -0
  304. package/dist/isometrik-webchat/index.esm.js +1 -1
  305. package/dist/isometrik-webchat/index.esm.js.map +1 -1
  306. package/dist/isometrik-webchat/isometrik-webchat.css +1 -1
  307. package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
  308. package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -1
  309. package/dist/isometrik-webchat/p-0731d488.js +2 -0
  310. package/dist/isometrik-webchat/p-0731d488.js.map +1 -0
  311. package/dist/isometrik-webchat/{p-a15092d9.entry.js → p-1854b156.entry.js} +2 -2
  312. package/dist/isometrik-webchat/p-1854b156.entry.js.map +1 -0
  313. package/dist/isometrik-webchat/{p-5fea3fd2.entry.js → p-2d3e8cd4.entry.js} +2 -2
  314. package/dist/isometrik-webchat/p-315eee9a.js +2 -0
  315. package/dist/isometrik-webchat/p-315eee9a.js.map +1 -0
  316. package/dist/isometrik-webchat/{p-e7f58d3f.entry.js → p-39b626ed.entry.js} +2 -2
  317. package/dist/isometrik-webchat/{p-eb1f3118.entry.js → p-3c70c22c.entry.js} +2 -2
  318. package/dist/isometrik-webchat/p-4cb54460.js +2 -0
  319. package/dist/isometrik-webchat/p-4cb54460.js.map +1 -0
  320. package/dist/isometrik-webchat/{p-f24cdbbb.js → p-5162774c.js} +1 -1
  321. package/dist/isometrik-webchat/p-5162774c.js.map +1 -0
  322. package/dist/isometrik-webchat/p-53ee98a7.entry.js +2 -0
  323. package/dist/isometrik-webchat/p-53ee98a7.entry.js.map +1 -0
  324. package/dist/isometrik-webchat/{p-5cbc1a16.entry.js → p-586f6978.entry.js} +2 -2
  325. package/dist/isometrik-webchat/{p-5f7eebbf.entry.js → p-5d243250.entry.js} +2 -2
  326. package/dist/isometrik-webchat/{p-23df1c24.js → p-5d98a8a0.js} +2 -2
  327. package/dist/isometrik-webchat/p-7f415f28.js +2 -0
  328. package/dist/isometrik-webchat/p-7f415f28.js.map +1 -0
  329. package/dist/isometrik-webchat/{p-d386acfe.js → p-7fd2c1ad.js} +1 -1
  330. package/dist/isometrik-webchat/p-7fd2c1ad.js.map +1 -0
  331. package/dist/isometrik-webchat/{p-e5884258.js → p-9982fa21.js} +2 -2
  332. package/dist/isometrik-webchat/{p-4db39c93.js → p-a5707f12.js} +2 -2
  333. package/dist/isometrik-webchat/{p-af775c83.entry.js → p-a876991d.entry.js} +2 -2
  334. package/dist/isometrik-webchat/{p-7b80b0b2.js → p-adc45831.js} +1 -1
  335. package/dist/isometrik-webchat/p-adc45831.js.map +1 -0
  336. package/dist/isometrik-webchat/p-ae168135.js +2 -0
  337. package/dist/isometrik-webchat/p-ae168135.js.map +1 -0
  338. package/dist/isometrik-webchat/{p-a6897edc.js → p-b1330793.js} +1 -1
  339. package/dist/isometrik-webchat/p-b1330793.js.map +1 -0
  340. package/dist/isometrik-webchat/p-b61d6c0c.entry.js +2 -0
  341. package/dist/isometrik-webchat/p-b61d6c0c.entry.js.map +1 -0
  342. package/dist/isometrik-webchat/p-b667a9fc.js +2 -0
  343. package/dist/isometrik-webchat/p-b667a9fc.js.map +1 -0
  344. package/dist/isometrik-webchat/p-b857775d.entry.js +2 -0
  345. package/dist/isometrik-webchat/p-bdcdf1c5.js +2 -0
  346. package/dist/isometrik-webchat/p-bdcdf1c5.js.map +1 -0
  347. package/dist/isometrik-webchat/p-c0c19621.entry.js +2 -0
  348. package/dist/isometrik-webchat/{p-064d6200.entry.js → p-ca47d693.entry.js} +2 -2
  349. package/dist/isometrik-webchat/p-d720cf14.entry.js +2 -0
  350. package/dist/isometrik-webchat/{p-53695fc6.entry.js.map → p-d720cf14.entry.js.map} +1 -1
  351. package/dist/isometrik-webchat/{p-5c22ee37.entry.js → p-d892b4d4.entry.js} +2 -2
  352. package/dist/isometrik-webchat/{p-7eb12da3.js → p-dd62bd69.js} +2 -2
  353. package/dist/isometrik-webchat/p-eb54f75d.js +2 -0
  354. package/dist/isometrik-webchat/p-eb54f75d.js.map +1 -0
  355. package/dist/isometrik-webchat/p-f1fbf3be.entry.js +2 -0
  356. package/dist/isometrik-webchat/p-f1fbf3be.entry.js.map +1 -0
  357. package/dist/isometrik-webchat/p-fb705915.entry.js +2 -0
  358. package/dist/isometrik-webchat/p-fb705915.entry.js.map +1 -0
  359. package/dist/isometrik-webchat/{p-2f6bb0a4.entry.js → p-fd6ce589.entry.js} +2 -2
  360. package/dist/isometrik-webchat/p-fdd327f5.entry.js +2 -0
  361. package/dist/types/components/ChatUIComponent/Footer/ChatFooter.d.ts +1 -0
  362. package/dist/types/components/ChatUIComponent/shared/attachment-preview/attachment-preview.d.ts +2 -0
  363. package/dist/types/components/ChatUIComponent/shared/document-message/document-message.d.ts +5 -0
  364. package/dist/types/components/ChatUIComponent/shared/image-message/image-message.d.ts +1 -0
  365. package/dist/types/components/ChatUIComponent/shared/message-bubble/message-bubble.d.ts +3 -0
  366. package/dist/types/components/ChatUIComponent/shared/outgoing-text-message-bubble/outgoing-text-message-bubble.d.ts +1 -0
  367. package/dist/types/components/ChatUIComponent/shared/video-message/video-message.d.ts +1 -0
  368. package/dist/types/components/my-component/web-chat/FLOW.d.ts +1 -1
  369. package/dist/types/components/my-component/web-chat/mqtt-host.d.ts +5 -0
  370. package/dist/types/components/my-component/web-chat/offline-host.d.ts +22 -0
  371. package/dist/types/components/theme-provider.d.ts +22 -27
  372. package/dist/types/components.d.ts +84 -11
  373. package/dist/types/demos/custom-ui-demo-elements.d.ts +1 -1
  374. package/dist/types/global/expose-sdk.d.ts +1 -0
  375. package/dist/types/index.d.ts +3 -44
  376. package/dist/types/lib/chat/index.d.ts +3 -0
  377. package/dist/types/lib/chat/media-limits.d.ts +11 -0
  378. package/dist/types/lib/chat/media-outbox.d.ts +8 -0
  379. package/dist/types/lib/chat/preview-kind.d.ts +30 -0
  380. package/dist/types/lib/custom-ui/contracts.d.ts +1 -1
  381. package/dist/types/lib/custom-ui/index.d.ts +1 -1
  382. package/dist/types/lib/custom-ui/public-api.d.ts +1 -1
  383. package/dist/types/lib/destroy-chat.d.ts +2 -0
  384. package/dist/types/lib/mqtt/inbound-queue.d.ts +7 -0
  385. package/dist/types/lib/mqtt/index.d.ts +2 -1
  386. package/dist/types/lib/mqtt/session.d.ts +22 -0
  387. package/dist/types/lib/offline/client.d.ts +44 -0
  388. package/dist/types/lib/offline/idb.d.ts +36 -0
  389. package/dist/types/lib/offline/index.d.ts +10 -0
  390. package/dist/types/lib/offline/memory-db.d.ts +20 -0
  391. package/dist/types/lib/offline/merge.d.ts +3 -0
  392. package/dist/types/lib/offline/multitab.d.ts +13 -0
  393. package/dist/types/lib/offline/types.d.ts +63 -0
  394. package/dist/types/sdk/api.d.ts +3 -0
  395. package/dist/types/sdk/composition.d.ts +32 -0
  396. package/dist/types/sdk/headless-api.d.ts +37 -0
  397. package/dist/types/sdk/index.d.ts +10 -0
  398. package/dist/types/sdk/init.d.ts +87 -0
  399. package/dist/types/sdk/instance.d.ts +15 -0
  400. package/dist/types/sdk/react-bridge.d.ts +64 -0
  401. package/dist/types/sdk/runtime-controls.d.ts +14 -0
  402. package/dist/types/sdk/slots.d.ts +15 -0
  403. package/dist/types/sdk/theme-tokens.d.ts +22 -0
  404. package/dist/types/sdk/webchat-api.d.ts +22 -0
  405. package/docs/ARCHITECTURE.md +272 -0
  406. package/docs/CUSTOMIZATION.md +236 -0
  407. package/docs/INTEGRATION.md +286 -0
  408. package/docs/RELIABILITY.md +51 -0
  409. package/docs/theme-tokens.template.css +72 -0
  410. package/package.json +8 -2
  411. package/readme.md +38 -17
  412. package/dist/cjs/app-globals-3a1e7e63.js +0 -7
  413. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  414. package/dist/cjs/chat-creds-cf537d4b.js.map +0 -1
  415. package/dist/cjs/contracts-31632812.js.map +0 -1
  416. package/dist/cjs/destroy-chat-be25dec7.js +0 -26
  417. package/dist/cjs/destroy-chat-be25dec7.js.map +0 -1
  418. package/dist/cjs/doublecheck-997afc94.js +0 -7
  419. package/dist/cjs/doublecheck-997afc94.js.map +0 -1
  420. package/dist/cjs/group-members-73ad1074.js.map +0 -1
  421. package/dist/cjs/index-1a26d11d.js.map +0 -1
  422. package/dist/cjs/toast-0bf1e688.js.map +0 -1
  423. package/dist/components/GroupCast.js.map +0 -1
  424. package/dist/components/groupcast2.js.map +0 -1
  425. package/dist/esm/app-globals-0f993ce5.js +0 -5
  426. package/dist/esm/app-globals-0f993ce5.js.map +0 -1
  427. package/dist/esm/chat-creds-5d0982fc.js.map +0 -1
  428. package/dist/esm/contracts-614be4db.js.map +0 -1
  429. package/dist/esm/destroy-chat-e2ebe165.js +0 -24
  430. package/dist/esm/destroy-chat-e2ebe165.js.map +0 -1
  431. package/dist/esm/doublecheck-5e208ef0.js +0 -5
  432. package/dist/esm/doublecheck-5e208ef0.js.map +0 -1
  433. package/dist/esm/group-members-806fd7a2.js.map +0 -1
  434. package/dist/esm/index-beb184c6.js.map +0 -1
  435. package/dist/esm/toast-d8ea763c.js.map +0 -1
  436. package/dist/isometrik-webchat/p-01fd0eb4.entry.js +0 -2
  437. package/dist/isometrik-webchat/p-01fd0eb4.entry.js.map +0 -1
  438. package/dist/isometrik-webchat/p-0f9c3f95.entry.js +0 -2
  439. package/dist/isometrik-webchat/p-0f9c3f95.entry.js.map +0 -1
  440. package/dist/isometrik-webchat/p-1c53e658.js +0 -2
  441. package/dist/isometrik-webchat/p-1c53e658.js.map +0 -1
  442. package/dist/isometrik-webchat/p-1df58381.entry.js +0 -2
  443. package/dist/isometrik-webchat/p-1df58381.entry.js.map +0 -1
  444. package/dist/isometrik-webchat/p-3c690532.entry.js +0 -2
  445. package/dist/isometrik-webchat/p-3c690532.entry.js.map +0 -1
  446. package/dist/isometrik-webchat/p-3c8cbd5f.js +0 -2
  447. package/dist/isometrik-webchat/p-3c8cbd5f.js.map +0 -1
  448. package/dist/isometrik-webchat/p-4e762019.js +0 -2
  449. package/dist/isometrik-webchat/p-4e762019.js.map +0 -1
  450. package/dist/isometrik-webchat/p-53695fc6.entry.js +0 -2
  451. package/dist/isometrik-webchat/p-7b80b0b2.js.map +0 -1
  452. package/dist/isometrik-webchat/p-9924b1bf.entry.js +0 -2
  453. package/dist/isometrik-webchat/p-a15092d9.entry.js.map +0 -1
  454. package/dist/isometrik-webchat/p-a6897edc.js.map +0 -1
  455. package/dist/isometrik-webchat/p-b2bf55b1.entry.js +0 -2
  456. package/dist/isometrik-webchat/p-bfecfa97.entry.js +0 -2
  457. package/dist/isometrik-webchat/p-d386acfe.js.map +0 -1
  458. package/dist/isometrik-webchat/p-e1255160.js +0 -2
  459. package/dist/isometrik-webchat/p-e1255160.js.map +0 -1
  460. package/dist/isometrik-webchat/p-f24cdbbb.js.map +0 -1
  461. /package/dist/isometrik-webchat/{p-5fea3fd2.entry.js.map → p-2d3e8cd4.entry.js.map} +0 -0
  462. /package/dist/isometrik-webchat/{p-e7f58d3f.entry.js.map → p-39b626ed.entry.js.map} +0 -0
  463. /package/dist/isometrik-webchat/{p-eb1f3118.entry.js.map → p-3c70c22c.entry.js.map} +0 -0
  464. /package/dist/isometrik-webchat/{p-5cbc1a16.entry.js.map → p-586f6978.entry.js.map} +0 -0
  465. /package/dist/isometrik-webchat/{p-5f7eebbf.entry.js.map → p-5d243250.entry.js.map} +0 -0
  466. /package/dist/isometrik-webchat/{p-23df1c24.js.map → p-5d98a8a0.js.map} +0 -0
  467. /package/dist/isometrik-webchat/{p-e5884258.js.map → p-9982fa21.js.map} +0 -0
  468. /package/dist/isometrik-webchat/{p-4db39c93.js.map → p-a5707f12.js.map} +0 -0
  469. /package/dist/isometrik-webchat/{p-af775c83.entry.js.map → p-a876991d.entry.js.map} +0 -0
  470. /package/dist/isometrik-webchat/{p-bfecfa97.entry.js.map → p-b857775d.entry.js.map} +0 -0
  471. /package/dist/isometrik-webchat/{p-9924b1bf.entry.js.map → p-c0c19621.entry.js.map} +0 -0
  472. /package/dist/isometrik-webchat/{p-064d6200.entry.js.map → p-ca47d693.entry.js.map} +0 -0
  473. /package/dist/isometrik-webchat/{p-5c22ee37.entry.js.map → p-d892b4d4.entry.js.map} +0 -0
  474. /package/dist/isometrik-webchat/{p-7eb12da3.js.map → p-dd62bd69.js.map} +0 -0
  475. /package/dist/isometrik-webchat/{p-2f6bb0a4.entry.js.map → p-fd6ce589.entry.js.map} +0 -0
  476. /package/dist/isometrik-webchat/{p-b2bf55b1.entry.js.map → p-fdd327f5.entry.js.map} +0 -0
@@ -1,21 +1,24 @@
1
1
  import { h, Fragment, proxyCustomElement, HTMLElement, createEvent } from '@stencil/core/internal/client';
2
2
  import { d as defineCustomElement$5 } from './spinner-loader2.js';
3
3
  import { d as defineCustomElement$s } from './ChatSidebar.js';
4
- import { d as defineCustomElement$n } from './GroupCast.js';
4
+ import { d as defineCustomElement$n } from './GroupCast2.js';
5
5
  import { d as defineCustomElement$2 } from './WebChatHeader.js';
6
6
  import { d as defineCustomElement$u } from './ChatFooter.js';
7
7
  import { d as defineCustomElement$a } from './Profile.js';
8
8
  import { d as defineCustomElement$9 } from './profile-sidebar2.js';
9
- import { f as fetchMessagesPage, s as searchMessages, a as fetchLinkMessages, b as fetchMediaCount, c as fetchMediaAttachments, d as defineCustomElement$q } from './contact-info2.js';
9
+ import { d as defineCustomElement$q } from './contact-info2.js';
10
10
  import { g as groupMembersStore, d as defineCustomElement$1 } from './WebchatRightSide.js';
11
11
  import { d as defineCustomElement$t } from './chat-loading-placeholder2.js';
12
12
  import { d as drawerDialogService } from './drawer.js';
13
13
  import { g as getDeviceID, a as getGroupcastUrlQuery } from './helpers.js';
14
14
  import { M } from './index.m.js';
15
15
  import { c as createStore } from './conversation.js';
16
- import { g as getGroupcast, a as getGroupcastMembers, b as getGroupcastMessage, r as removeGroupcastMember, d as deleteGroupCast } from './groupcast2.js';
17
- import { C as CHAT_CREDS, i as isometrikFlutterAppSecrets, M as MQTT_CREDS } from './chat-creds.js';
16
+ import { b as getGroupcastMessage, r as removeGroupcastMember, d as deleteGroupCast } from './groupcast.js';
17
+ import { n as getOfflineClient, o as mergeMessagesById, q as isBrowserOnline, p as prepareMediaAttachments, u as uploadAndPostMediaMessage, i as initializeChatSdk, f as fetchUserDetails, a as fetchConversationsPage, m as mergeUniqueConversations, c as fetchGroupcastDetails, b as fetchConversationDetails, d as fetchGroupcastMembersPage, e as fetchGroupcastContactsPage, v as buildLocalMediaAttachments, h as customTypeFromMime, j as buildReplyMetaData, s as sortConversationsByLatestMessage, k as resolveRegionMode } from './client.js';
18
+ import { t as takeMediaFiles, M as MAX_MEDIA_PER_MESSAGE, m as mediaLimitToastMessage } from './media-limits.js';
19
+ import { f as fetchMessagesPage, s as searchMessages, a as fetchLinkMessages, b as fetchMediaCount, c as fetchMediaAttachments } from './messages.js';
18
20
  import { s as showToast } from './toast.js';
21
+ import { M as MQTT_CREDS, i as isometrikFlutterAppSecrets } from './chat-creds.js';
19
22
  import { r as removeConversationMember, g as getConversationEligibleMembers } from './group-members.js';
20
23
  import { W as WEB_CONTENT } from './content.js';
21
24
  import { h as hasNamedSlot } from './index2.js';
@@ -44,10 +47,64 @@ import { d as defineCustomElement$6 } from './searchable-list2.js';
44
47
  import { d as defineCustomElement$4 } from './video-message2.js';
45
48
  import { d as defineCustomElement$3 } from './WebChatBody.js';
46
49
 
50
+ const MAX_OUTBOX_MEDIA_BYTES = 12 * 1024 * 1024;
51
+ function arrayBufferToBase64(buf) {
52
+ const bytes = new Uint8Array(buf);
53
+ const chunk = 0x8000;
54
+ let binary = '';
55
+ for (let i = 0; i < bytes.length; i += chunk) {
56
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
57
+ }
58
+ return btoa(binary);
59
+ }
60
+ function base64ToUint8(base64) {
61
+ const binary = atob(base64);
62
+ const out = new Uint8Array(binary.length);
63
+ for (let i = 0; i < binary.length; i++)
64
+ out[i] = binary.charCodeAt(i);
65
+ return out;
66
+ }
67
+ async function filesToOutboxMedia(files) {
68
+ const accepted = takeMediaFiles(files, 0).accepted;
69
+ let total = 0;
70
+ const out = [];
71
+ for (const file of accepted) {
72
+ // Skip oversized; keep packing remaining files that still fit
73
+ if (total + file.size > MAX_OUTBOX_MEDIA_BYTES)
74
+ continue;
75
+ const base64 = arrayBufferToBase64(await file.arrayBuffer());
76
+ out.push({
77
+ name: file.name,
78
+ mimeType: file.type || 'application/octet-stream',
79
+ size: file.size,
80
+ base64,
81
+ });
82
+ total += file.size;
83
+ }
84
+ return out;
85
+ }
86
+ function outboxMediaToFiles(mediaFiles) {
87
+ if (!(mediaFiles === null || mediaFiles === void 0 ? void 0 : mediaFiles.length))
88
+ return [];
89
+ return mediaFiles.slice(0, MAX_MEDIA_PER_MESSAGE).map(m => new File([base64ToUint8(m.base64)], m.name, { type: m.mimeType || 'application/octet-stream' }));
90
+ }
91
+
47
92
  /**
48
93
  * Thin MQTT lifecycle helper around test-iso-chat-sdk's mqtt client.
49
94
  * Keeps connect/subscribe/teardown idempotent so remounts don't stack listeners.
95
+ *
96
+ * Supports mqtt.js reconnect: on each `connect` (including after reconnect)
97
+ * call `resubscribe()` so the user topic is always live.
50
98
  */
99
+ /** Sensible mqtt.js reconnect defaults (ms). */
100
+ const MQTT_RECONNECT_PERIOD_MS = 2000;
101
+ const MQTT_CONNECT_TIMEOUT_MS = 12000;
102
+ function applyMqttReconnectOptions(rawClient) {
103
+ if (!(rawClient === null || rawClient === void 0 ? void 0 : rawClient.options))
104
+ return;
105
+ rawClient.options.reconnectPeriod = MQTT_RECONNECT_PERIOD_MS;
106
+ rawClient.options.connectTimeout = MQTT_CONNECT_TIMEOUT_MS;
107
+ }
51
108
  function removeClientListener(client, event, handler) {
52
109
  if (typeof client.removeListener === 'function') {
53
110
  client.removeListener(event, handler);
@@ -62,14 +119,18 @@ class MqttSession {
62
119
  this.handlers = {};
63
120
  this.boundConnect = null;
64
121
  this.boundDisconnect = null;
122
+ this.boundOffline = null;
123
+ this.boundReconnect = null;
65
124
  this.boundError = null;
66
125
  this.boundMessage = null;
126
+ /** Last successfully subscribed topic. */
67
127
  this.subscribedTopic = null;
128
+ /** Topic we want — used to force resubscribe after reconnect. */
129
+ this.desiredTopic = null;
68
130
  this.listenersAttached = false;
69
131
  this.messageListenerAttached = false;
70
132
  }
71
133
  attach(mqtt, handlers) {
72
- // Teardown previous bindings if re-attaching to same or new client
73
134
  this.detachListenersOnly();
74
135
  this.mqtt = mqtt;
75
136
  this.handlers = handlers;
@@ -81,6 +142,14 @@ class MqttSession {
81
142
  var _a, _b;
82
143
  (_b = (_a = this.handlers).onDisconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
83
144
  };
145
+ this.boundOffline = () => {
146
+ var _a, _b;
147
+ (_b = (_a = this.handlers).onOffline) === null || _b === void 0 ? void 0 : _b.call(_a);
148
+ };
149
+ this.boundReconnect = () => {
150
+ var _a, _b;
151
+ (_b = (_a = this.handlers).onReconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
152
+ };
84
153
  this.boundError = (error) => {
85
154
  var _a, _b;
86
155
  (_b = (_a = this.handlers).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
@@ -89,14 +158,18 @@ class MqttSession {
89
158
  var _a, _b;
90
159
  void ((_b = (_a = this.handlers).onMessage) === null || _b === void 0 ? void 0 : _b.call(_a, topic, payload));
91
160
  };
92
- mqtt.client.on('connect', this.boundConnect);
93
- mqtt.client.on('disconnect', this.boundDisconnect);
94
- mqtt.client.on('error', this.boundError);
161
+ const { client } = mqtt;
162
+ client.on('connect', this.boundConnect);
163
+ client.on('disconnect', this.boundDisconnect);
164
+ client.on('offline', this.boundOffline);
165
+ client.on('reconnect', this.boundReconnect);
166
+ client.on('error', this.boundError);
95
167
  this.listenersAttached = true;
96
168
  }
97
169
  subscribe(topic) {
98
170
  if (!this.mqtt)
99
171
  return;
172
+ this.desiredTopic = topic;
100
173
  if (this.subscribedTopic === topic) {
101
174
  this.ensureMessageListener();
102
175
  return;
@@ -106,7 +179,7 @@ class MqttSession {
106
179
  this.mqtt.client.unsubscribe(this.subscribedTopic);
107
180
  }
108
181
  catch (_a) {
109
- // ignore
182
+ /* ignore */
110
183
  }
111
184
  }
112
185
  this.mqtt.client.subscribe(topic, err => {
@@ -118,6 +191,16 @@ class MqttSession {
118
191
  });
119
192
  this.ensureMessageListener();
120
193
  }
194
+ /** After reconnect, force subscribe again even if topic string is unchanged. */
195
+ resubscribe() {
196
+ if (!this.desiredTopic)
197
+ return;
198
+ this.subscribedTopic = null;
199
+ this.subscribe(this.desiredTopic);
200
+ }
201
+ getDesiredTopic() {
202
+ return this.desiredTopic;
203
+ }
121
204
  ensureMessageListener() {
122
205
  if (!this.mqtt || this.messageListenerAttached || !this.boundMessage)
123
206
  return;
@@ -135,6 +218,10 @@ class MqttSession {
135
218
  removeClientListener(client, 'connect', this.boundConnect);
136
219
  if (this.boundDisconnect)
137
220
  removeClientListener(client, 'disconnect', this.boundDisconnect);
221
+ if (this.boundOffline)
222
+ removeClientListener(client, 'offline', this.boundOffline);
223
+ if (this.boundReconnect)
224
+ removeClientListener(client, 'reconnect', this.boundReconnect);
138
225
  if (this.boundError)
139
226
  removeClientListener(client, 'error', this.boundError);
140
227
  if (this.boundMessage && this.messageListenerAttached) {
@@ -151,7 +238,7 @@ class MqttSession {
151
238
  this.mqtt.client.unsubscribe(this.subscribedTopic);
152
239
  }
153
240
  catch (_a) {
154
- // ignore
241
+ /* ignore */
155
242
  }
156
243
  }
157
244
  this.detachListenersOnly();
@@ -160,6 +247,7 @@ class MqttSession {
160
247
  this.mqtt.disconnect();
161
248
  }
162
249
  else if (typeof this.mqtt.client.end === 'function') {
250
+ // force end — do not leave zombie reconnect loops after unmount
163
251
  this.mqtt.client.end(true);
164
252
  }
165
253
  }
@@ -168,6 +256,7 @@ class MqttSession {
168
256
  }
169
257
  this.mqtt = null;
170
258
  this.subscribedTopic = null;
259
+ this.desiredTopic = null;
171
260
  this.handlers = {};
172
261
  }
173
262
  }
@@ -738,211 +827,234 @@ async function dispatchMqttMessage(parsedMessage, ctx) {
738
827
  }
739
828
  }
740
829
 
741
- /** Newest last-message first. Skips empty/cleared last messages when sorting. */
742
- function sortConversationsByLatestMessage(conversations) {
743
- return [...conversations].sort((a, b) => {
744
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
745
- 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') &&
746
- (((_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')) {
747
- return 0;
748
- }
749
- 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') &&
750
- (((_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')) {
751
- return 0;
752
- }
753
- const timestampA = (_j = a === null || a === void 0 ? void 0 : a.lastMessageDetails) === null || _j === void 0 ? void 0 : _j.updatedAt;
754
- const timestampB = (_k = b === null || b === void 0 ? void 0 : b.lastMessageDetails) === null || _k === void 0 ? void 0 : _k.updatedAt;
755
- return timestampB - timestampA;
756
- });
757
- }
758
- function mergeUniqueConversations(existing, incoming) {
759
- const list = Array.isArray(existing) ? existing : [];
760
- const next = Array.isArray(incoming) ? incoming : [];
761
- return [
762
- ...list,
763
- ...next.filter(newConv => !list.some(existingConv => existingConv.conversationId === newConv.conversationId)),
764
- ];
765
- }
766
- async function fetchConversationsPage(opts) {
767
- var _a, _b, _c;
768
- const query = {
769
- limit: (_a = opts.limit) !== null && _a !== void 0 ? _a : 20,
770
- skip: (_b = opts.skip) !== null && _b !== void 0 ? _b : 0,
771
- includeMembers: (_c = opts.includeMembers) !== null && _c !== void 0 ? _c : true,
772
- };
773
- if (opts.searchTag)
774
- query.searchTag = opts.searchTag;
775
- const res = await M.getInstance().Conversation.getConversations(query);
776
- return (res === null || res === void 0 ? void 0 : res.conversations) || [];
777
- }
778
- async function fetchConversationDetails(conversationId, includeMembers = true) {
779
- const res = await M.getInstance().Conversation.getConversationDetails({ conversationId, includeMembers }, conversationId);
780
- return res === null || res === void 0 ? void 0 : res.conversationDetails;
830
+ /**
831
+ * Serialize inbound MQTT handling per host so rapid messages don't race @State updates.
832
+ */
833
+ const tails = new WeakMap();
834
+ /** Run `task` after any prior MQTT tasks for this host have finished. */
835
+ function enqueueMqttTask(host, task) {
836
+ const prev = tails.get(host) || Promise.resolve();
837
+ const next = prev
838
+ .then(() => task())
839
+ .catch(err => {
840
+ console.error('MQTT inbound task failed:', err);
841
+ })
842
+ .then(() => undefined);
843
+ tails.set(host, next);
844
+ return next;
781
845
  }
782
846
 
783
- /** Init ChatSDK singleton. Props win; chat-creds used as local-demo fallback. */
784
- function initializeChatSdk(config) {
785
- M.initializeInstance({
786
- baseUrl: config.baseUrl || CHAT_CREDS.baseUrl,
787
- licenseKey: config.licenseKey || isometrikFlutterAppSecrets.licenseKey,
788
- appSecret: config.appSecret || isometrikFlutterAppSecrets.appSecret,
789
- userSecret: config.userSecret || isometrikFlutterAppSecrets.userSecret,
790
- userToken: config.userToken,
791
- });
792
- }
793
- /** Normalize getUserDetails API response into the shape WebChat stores. */
794
- async function fetchUserDetails() {
795
- var _a, _b, _c;
796
- const res = await M.getInstance().user.getUserDetails();
797
- return {
798
- userId: (res === null || res === void 0 ? void 0 : res.userId) || '',
799
- userIdentifier: (res === null || res === void 0 ? void 0 : res.userIdentifier) || '',
800
- firstName: ((_a = res === null || res === void 0 ? void 0 : res.metaData) === null || _a === void 0 ? void 0 : _a.firstName) || '',
801
- lastName: ((_b = res === null || res === void 0 ? void 0 : res.metaData) === null || _b === void 0 ? void 0 : _b.lastName) || '',
802
- updatedAt: (res === null || res === void 0 ? void 0 : res.updatedAt) || '',
803
- userName: (res === null || res === void 0 ? void 0 : res.userName) || '',
804
- online: (res === null || res === void 0 ? void 0 : res.online) || '',
805
- userProfileImageUrl: (res === null || res === void 0 ? void 0 : res.userProfileImageUrl) || '',
806
- profilePic: ((_c = res === null || res === void 0 ? void 0 : res.metaData) === null || _c === void 0 ? void 0 : _c.profilePic) || '',
807
- };
808
- }
847
+ const getTotalUnreadConversationsCount = async () => {
848
+ const response = await M.getInstance().Conversation.getConversationUnreadCount();
849
+ return response?.count;
850
+ };
809
851
 
810
- async function fetchGroupcastDetails(groupcastId) {
852
+ /**
853
+ * Wire OfflineClient into <web-chat> lifecycle.
854
+ */
855
+ function userIdOf(host) {
811
856
  var _a;
812
- const res = await getGroupcast({ ids: groupcastId });
813
- return ((_a = res === null || res === void 0 ? void 0 : res.groupcasts) === null || _a === void 0 ? void 0 : _a[0]) || null;
857
+ return ((_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId) || host.isometrikUserId || host.isometrikUserIdFromCookie || null;
858
+ }
859
+ function hostInitOffline(host) {
860
+ const client = getOfflineClient();
861
+ const uid = userIdOf(host);
862
+ if (uid)
863
+ client.setUser(uid);
864
+ client.startTabSync(event => {
865
+ var _a;
866
+ if (event.type === 'messages' && event.conversationId === host.selectedConversationId) {
867
+ host.allMessages = mergeMessagesById(host.allMessages || [], event.messages || []);
868
+ }
869
+ if (event.type === 'conversations') {
870
+ // Prefer newer network list; only fill gaps from peer tab
871
+ const incoming = event.conversations || [];
872
+ if (!((_a = host.allConversationList) === null || _a === void 0 ? void 0 : _a.length) && incoming.length) {
873
+ host.allConversationList = incoming;
874
+ }
875
+ }
876
+ });
877
+ if (typeof window !== 'undefined') {
878
+ host._onOnline = () => {
879
+ void hostFlushOutbox(host);
880
+ };
881
+ window.addEventListener('online', host._onOnline);
882
+ }
814
883
  }
815
- async function fetchGroupcastMembersPage(groupcastId) {
816
- const res = await getGroupcastMembers({ groupcastId });
817
- return (res === null || res === void 0 ? void 0 : res.members) || [];
884
+ function hostTeardownOffline(host) {
885
+ getOfflineClient().stopTabSync();
886
+ if (typeof window !== 'undefined' && host._onOnline) {
887
+ window.removeEventListener('online', host._onOnline);
888
+ host._onOnline = null;
889
+ }
818
890
  }
819
- async function fetchGroupcastContactsPage(opts = {}) {
820
- var _a, _b;
821
- const res = await getGroupcast({ skip: (_a = opts.skip) !== null && _a !== void 0 ? _a : 0, limit: (_b = opts.limit) !== null && _b !== void 0 ? _b : 20 });
822
- return (res === null || res === void 0 ? void 0 : res.groupcasts) || [];
891
+ /** Paint cached conversations immediately (before network). */
892
+ async function hostHydrateConversationsFromCache(host) {
893
+ const uid = userIdOf(host);
894
+ if (!uid)
895
+ return;
896
+ try {
897
+ const cached = await getOfflineClient().loadConversations(uid);
898
+ if (cached.length && (!host.allConversationList || host.allConversationList.length === 0)) {
899
+ host.allConversationList = cached;
900
+ }
901
+ }
902
+ catch (e) {
903
+ console.error('offline hydrate conversations failed', e);
904
+ }
823
905
  }
824
-
825
- /**
826
- * Shared media-send helpers for ChatFooter + public web-chat.sendMedia.
827
- * Conversation path only (groupcast keeps using ChatFooter).
828
- */
829
- function mediaTypeFromMime(mime) {
830
- if (!mime)
831
- return 3;
832
- if (mime.startsWith('image/'))
833
- return 0;
834
- if (mime.startsWith('video/'))
835
- return 1;
836
- if (mime.startsWith('audio/'))
837
- return 2;
838
- return 3;
839
- }
840
- function customTypeFromMime(mime) {
841
- if (!mime)
842
- return 'AttachmentMessage:Multiple';
843
- if (mime.startsWith('image/'))
844
- return 'AttachmentMessage:Image';
845
- if (mime.startsWith('video/'))
846
- return 'AttachmentMessage:Video';
847
- if (mime.startsWith('audio/'))
848
- return 'AttachmentMessage:Audio';
849
- if (mime.startsWith('application/'))
850
- return 'AttachmentMessage:Doc';
851
- return 'AttachmentMessage:Multiple';
852
- }
853
- function buildReplyMetaData(replyMessage, caption) {
854
- var _a, _b, _c;
855
- if (!replyMessage && !(caption === null || caption === void 0 ? void 0 : caption.trim()))
856
- return {};
857
- return Object.assign(Object.assign({}, (replyMessage && Object.assign({ parentMessageId: replyMessage.messageId, parentMessage: replyMessage.body, parentMessageTime: replyMessage.sentAt, parentMessageSenderId: ((_a = replyMessage.senderInfo) === null || _a === void 0 ? void 0 : _a.userId) || replyMessage.senderId, parentMessageSenderName: ((_b = replyMessage.senderInfo) === null || _b === void 0 ? void 0 : _b.userName) || replyMessage.userName }, (((_c = replyMessage === null || replyMessage === void 0 ? void 0 : replyMessage.attachments) === null || _c === void 0 ? void 0 : _c[0]) && {
858
- parentMessageName: replyMessage.attachments[0].name,
859
- parentMessageMediaUrl: replyMessage.attachments[0].mediaUrl,
860
- parentMessageType: replyMessage.attachments[0].mimeType,
861
- })))), ((caption === null || caption === void 0 ? void 0 : caption.trim()) && { captionMessage: caption.trim() }));
862
- }
863
- function prepareMediaAttachments(files) {
864
- return files.map(file => ({
865
- nameWithExtension: file.name,
866
- mediaType: mediaTypeFromMime(file.type),
867
- mediaId: String(file.lastModified || Date.now()),
868
- mimeType: file.type || 'application/octet-stream',
869
- size: file.size,
870
- file,
871
- }));
906
+ async function hostHydrateMessagesFromCache(host, conversationId) {
907
+ const uid = userIdOf(host);
908
+ const id = conversationId || host.selectedConversationId;
909
+ if (!uid || !id)
910
+ return;
911
+ try {
912
+ const cached = await getOfflineClient().loadMessages(uid, id);
913
+ if (cached.length) {
914
+ host.allMessages = mergeMessagesById(host.allMessages || [], cached);
915
+ }
916
+ }
917
+ catch (e) {
918
+ console.error('offline hydrate messages failed', e);
919
+ }
872
920
  }
873
- function buildLocalMediaAttachments(files) {
874
- return files.map(file => ({
875
- name: file.name,
876
- size: file.size,
877
- type: (file.type || '').split('/')[0] || 'file',
878
- mediaUrl: typeof URL !== 'undefined' ? URL.createObjectURL(file) : '',
879
- mimeType: file.type || 'application/octet-stream',
880
- }));
921
+ async function hostPersistConversations(host) {
922
+ var _a;
923
+ const uid = userIdOf(host);
924
+ if (!uid || !((_a = host.allConversationList) === null || _a === void 0 ? void 0 : _a.length))
925
+ return;
926
+ try {
927
+ await getOfflineClient().persistConversations(uid, host.allConversationList);
928
+ }
929
+ catch (e) {
930
+ console.error('offline persist conversations failed', e);
931
+ }
881
932
  }
882
- /** Presign → PUT files → postMessages. Returns API messageId. */
883
- async function uploadAndPostMediaMessage(args) {
884
- const { conversationId, deviceId, attachments, replyMessage, caption, mentionedUsers } = args;
885
- if (!conversationId || !(attachments === null || attachments === void 0 ? void 0 : attachments.length))
886
- return null;
887
- const resForPresignedUrl = await M.getInstance().message.postMessagesPresignedurls({
888
- conversationId,
889
- attachments,
933
+ async function hostPersistMessages(host, conversationId) {
934
+ var _a;
935
+ const uid = userIdOf(host);
936
+ const id = conversationId || host.selectedConversationId;
937
+ if (!uid || !id || !((_a = host.allMessages) === null || _a === void 0 ? void 0 : _a.length))
938
+ return;
939
+ try {
940
+ await getOfflineClient().persistMessages(uid, id, host.allMessages);
941
+ const last = host.allMessages[host.allMessages.length - 1];
942
+ const cursor = (last === null || last === void 0 ? void 0 : last.sentAt) || (last === null || last === void 0 ? void 0 : last.updatedAt) || Date.now();
943
+ await getOfflineClient().setCursor(uid, id, cursor);
944
+ }
945
+ catch (e) {
946
+ console.error('offline persist messages failed', e);
947
+ }
948
+ }
949
+ async function hostEnqueueFailedText(host, opts) {
950
+ var _a, _b, _c;
951
+ const uid = userIdOf(host);
952
+ if (!uid)
953
+ return;
954
+ const reply = host.replyMessage;
955
+ await getOfflineClient().enqueueText({
956
+ localId: opts.localId,
957
+ userId: uid,
958
+ conversationId: opts.conversationId,
959
+ body: opts.body,
960
+ metaData: (_a = opts.localMessage) === null || _a === void 0 ? void 0 : _a.metaData,
961
+ messageType: (_c = (_b = opts.localMessage) === null || _b === void 0 ? void 0 : _b.messageType) !== null && _c !== void 0 ? _c : 0,
962
+ parentMessageId: reply === null || reply === void 0 ? void 0 : reply.messageId,
963
+ customType: opts.body.match(/(https?:\/\/[^\s]+)/g)
964
+ ? 'AttachmentMessage:Link'
965
+ : 'AttachmentMessage:Text',
966
+ searchableTags: opts.body.split(/\s+/).filter(Boolean).slice(0, 20),
890
967
  });
891
- const presignedUrls = (resForPresignedUrl === null || resForPresignedUrl === void 0 ? void 0 : resForPresignedUrl.presignedUrls)
892
- ? resForPresignedUrl.presignedUrls
893
- : (resForPresignedUrl === null || resForPresignedUrl === void 0 ? void 0 : resForPresignedUrl.presignedUrl)
894
- ? [resForPresignedUrl]
895
- : null;
896
- if (!(presignedUrls === null || presignedUrls === void 0 ? void 0 : presignedUrls.length)) {
897
- throw new Error('No presigned URLs returned for media upload');
898
- }
899
- const allPayloads = [];
900
- await Promise.all(presignedUrls.map(async (urlDetails, index) => {
901
- const { mediaPresignedUrl, mediaId, mediaUrl, thumbnailUrl } = urlDetails;
902
- const attachmentPayload = attachments[index];
903
- if (!attachmentPayload || !mediaPresignedUrl)
904
- return;
905
- allPayloads.push({
906
- mediaId,
907
- mediaUrl,
908
- thumbnailUrl,
909
- mediaType: attachmentPayload.mediaType,
910
- nameWithExtension: attachmentPayload.nameWithExtension,
911
- name: attachmentPayload.nameWithExtension,
912
- mimeType: attachmentPayload.mimeType,
913
- extension: attachmentPayload.mimeType.split('/')[1] || '',
914
- size: attachmentPayload.size,
915
- attachmentType: 0,
916
- });
917
- await fetch(mediaPresignedUrl, {
918
- method: 'PUT',
919
- body: attachmentPayload.file,
920
- headers: { 'Content-Type': attachmentPayload.mimeType },
968
+ // Mark bubble as pending/outbox so UI can show retry state
969
+ host.allMessages = (host.allMessages || []).map((m) => m.messageId === opts.localId
970
+ ? Object.assign(Object.assign({}, m), { deliveredToAll: 'pending', deliveryStatus: 'outbox', outbox: true }) : m);
971
+ await hostPersistMessages(host, opts.conversationId);
972
+ }
973
+ async function hostEnqueueFailedMedia(host, opts) {
974
+ var _a, _b, _c, _d, _e, _f;
975
+ const uid = userIdOf(host);
976
+ if (!uid)
977
+ return;
978
+ const mediaFiles = await filesToOutboxMedia(opts.files);
979
+ if (!mediaFiles.length)
980
+ return;
981
+ const reply = host.replyMessage;
982
+ await getOfflineClient().enqueueMedia({
983
+ localId: opts.localId,
984
+ userId: uid,
985
+ conversationId: opts.conversationId,
986
+ body: ((_a = opts.caption) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = opts.localMessage) === null || _b === void 0 ? void 0 : _b.body) || 'AttachmentMessage:Multiple',
987
+ caption: opts.caption,
988
+ mediaFiles,
989
+ metaData: (_c = opts.localMessage) === null || _c === void 0 ? void 0 : _c.metaData,
990
+ messageType: (_e = (_d = opts.localMessage) === null || _d === void 0 ? void 0 : _d.messageType) !== null && _e !== void 0 ? _e : 0,
991
+ parentMessageId: reply === null || reply === void 0 ? void 0 : reply.messageId,
992
+ customType: ((_f = opts.localMessage) === null || _f === void 0 ? void 0 : _f.customType) || 'AttachmentMessage:Multiple',
993
+ });
994
+ host.allMessages = (host.allMessages || []).map((m) => m.messageId === opts.localId
995
+ ? Object.assign(Object.assign({}, m), { deliveredToAll: 'pending', deliveryStatus: 'outbox', outbox: true }) : m);
996
+ await hostPersistMessages(host, opts.conversationId);
997
+ }
998
+ async function sendOutboxItem(host, item) {
999
+ var _a;
1000
+ const deviceId = host.deviceId || (await getDeviceID());
1001
+ if (item.kind === 'media') {
1002
+ const files = outboxMediaToFiles(item.mediaFiles);
1003
+ if (!files.length)
1004
+ throw new Error('Media outbox item has no files');
1005
+ const attachments = prepareMediaAttachments(files);
1006
+ const apiId = await uploadAndPostMediaMessage({
1007
+ conversationId: item.conversationId,
1008
+ deviceId,
1009
+ attachments,
1010
+ caption: item.caption || item.body,
1011
+ replyMessage: item.parentMessageId
1012
+ ? { messageId: item.parentMessageId }
1013
+ : null,
921
1014
  });
922
- }));
923
- const customType = attachments.length === 1 ? customTypeFromMime(attachments[0].mimeType) : 'AttachmentMessage:Multiple';
1015
+ if (apiId && item.conversationId === host.selectedConversationId) {
1016
+ host.allMessages = (host.allMessages || []).map((m) => m.messageId === item.localId
1017
+ ? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, outbox: false, deliveryStatus: 'sent' }) : m);
1018
+ await hostPersistMessages(host, item.conversationId);
1019
+ }
1020
+ return apiId || null;
1021
+ }
924
1022
  const payload = {
925
1023
  showInConversation: true,
926
- messageType: replyMessage ? 2 : 0,
927
- parentMessageId: replyMessage === null || replyMessage === void 0 ? void 0 : replyMessage.messageId,
1024
+ messageType: (_a = item.messageType) !== null && _a !== void 0 ? _a : 0,
1025
+ parentMessageId: item.parentMessageId,
1026
+ searchableTags: item.searchableTags || [],
928
1027
  encrypted: false,
929
- conversationId,
930
- body: (caption === null || caption === void 0 ? void 0 : caption.trim()) || 'AttachmentMessage:Multiple',
931
- customType,
932
- attachments: allPayloads,
1028
+ conversationId: item.conversationId,
933
1029
  deviceId,
934
- metaData: buildReplyMetaData(replyMessage, caption),
1030
+ customType: item.customType || 'AttachmentMessage:Text',
1031
+ body: item.body,
1032
+ metaData: item.metaData || {},
935
1033
  };
936
- if (mentionedUsers === null || mentionedUsers === void 0 ? void 0 : mentionedUsers.length)
937
- payload.mentionedUsers = mentionedUsers;
938
- const sendMessageRes = await M.getInstance().message.postMessages(payload);
939
- return (sendMessageRes === null || sendMessageRes === void 0 ? void 0 : sendMessageRes.messageId) || null;
1034
+ const res = await M.getInstance().message.postMessages(payload);
1035
+ const apiId = res === null || res === void 0 ? void 0 : res.messageId;
1036
+ if (apiId && item.conversationId === host.selectedConversationId) {
1037
+ host.allMessages = (host.allMessages || []).map((m) => m.messageId === item.localId
1038
+ ? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, outbox: false, deliveryStatus: 'sent' }) : m);
1039
+ await hostPersistMessages(host, item.conversationId);
1040
+ }
1041
+ return apiId || null;
1042
+ }
1043
+ async function hostFlushOutbox(host) {
1044
+ var _a;
1045
+ const uid = userIdOf(host);
1046
+ if (!uid || !isBrowserOnline())
1047
+ return;
1048
+ try {
1049
+ const result = await getOfflineClient().flushOutbox(uid, item => sendOutboxItem(host, item));
1050
+ if (result.sent > 0) {
1051
+ void Promise.resolve((_a = host.getConversations) === null || _a === void 0 ? void 0 : _a.call(host, 0)).catch(() => undefined);
1052
+ }
1053
+ }
1054
+ catch (e) {
1055
+ console.error('outbox flush failed', e);
1056
+ }
940
1057
  }
941
-
942
- const getTotalUnreadConversationsCount = async () => {
943
- const response = await M.getInstance().Conversation.getConversationUnreadCount();
944
- return response?.count;
945
- };
946
1058
 
947
1059
  /**
948
1060
  * Ordered startup for <web-chat>.
@@ -960,6 +1072,9 @@ const getTotalUnreadConversationsCount = async () => {
960
1072
  */
961
1073
  async function bootstrapWebChat(host, generation) {
962
1074
  try {
1075
+ hostInitOffline(host);
1076
+ // Instant paint from IndexedDB while network warms up
1077
+ void hostHydrateConversationsFromCache(host);
963
1078
  try {
964
1079
  host.updateLoading(10, 'Preparing secure session…');
965
1080
  const deviceId = await getDeviceID();
@@ -998,6 +1113,8 @@ async function bootstrapWebChat(host, generation) {
998
1113
  try {
999
1114
  host.updateLoading(55, 'Fetching users…');
1000
1115
  await host.getUserDetails();
1116
+ hostInitOffline(host); // re-bind userId after profile load
1117
+ void hostHydrateConversationsFromCache(host);
1001
1118
  }
1002
1119
  catch (userError) {
1003
1120
  console.error('Failed to get user details:', userError);
@@ -1052,6 +1169,7 @@ async function bootstrapWebChat(host, generation) {
1052
1169
  host.checkMobileView();
1053
1170
  window.addEventListener('resize', host.boundCheckMobileView);
1054
1171
  host.updateLoading(100, 'Almost ready…');
1172
+ void hostFlushOutbox(host);
1055
1173
  }
1056
1174
  catch (error) {
1057
1175
  console.error('Critical initialization error:', error);
@@ -1124,6 +1242,7 @@ async function hostGetConversations(host, skip = 0, searchTag = null, showLoader
1124
1242
  try {
1125
1243
  const conversations = await fetchConversationsPage({ skip, searchTag });
1126
1244
  host.allConversationList = mergeUniqueConversations(host.allConversationList, conversations);
1245
+ void hostPersistConversations(host);
1127
1246
  }
1128
1247
  catch (error) {
1129
1248
  console.error('getConversations fetching error', error);
@@ -1167,17 +1286,23 @@ async function hostGetMessages(host, skip, conversationId) {
1167
1286
  conversationId: conversationId || host.selectedConversationId,
1168
1287
  skip,
1169
1288
  });
1289
+ const targetId = conversationId || host.selectedConversationId;
1170
1290
  if (skip == 0) {
1171
- if (conversationId)
1172
- host.selectConversationMessages = [...messages];
1173
- else
1174
- host.allMessages = [...messages];
1291
+ if (conversationId) {
1292
+ host.selectConversationMessages = mergeMessagesById(host.selectConversationMessages || [], messages);
1293
+ }
1294
+ else {
1295
+ // Merge with any optimistic/outbox rows already on screen
1296
+ host.allMessages = mergeMessagesById(host.allMessages || [], messages);
1297
+ }
1175
1298
  }
1176
1299
  else {
1177
- host.allMessages = [...messages, ...host.allMessages];
1300
+ host.allMessages = mergeMessagesById(messages, host.allMessages || []);
1178
1301
  }
1179
1302
  // API 404s a page past the end; a short page means this page is the last.
1180
1303
  host.isMessageLimitEnd = messages.length < 20;
1304
+ if (targetId)
1305
+ void hostPersistMessages(host, targetId);
1181
1306
  }
1182
1307
  catch (error) {
1183
1308
  if ((error === null || error === void 0 ? void 0 : error.status) === 404 || (error === null || error === void 0 ? void 0 : error.statusCode) === 404) {
@@ -1313,7 +1438,7 @@ async function hostSendText(host, body, conversationId) {
1313
1438
  const deviceId = host.deviceId || (await getDeviceID());
1314
1439
  const localId = `localId${Date.now()}${Math.random() * 100}`;
1315
1440
  const reply = host.replyMessage;
1316
- const localMessage = Object.assign({ body: text, messageId: localId, deliveredToAll: 'pending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now() }, (reply && {
1441
+ const localMessage = Object.assign({ body: text, messageId: localId, deliveredToAll: 'pending', deliveryStatus: 'sending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now() }, (reply && {
1317
1442
  parentMessageId: reply.messageId,
1318
1443
  metaData: {
1319
1444
  parentMessageId: reply.messageId,
@@ -1326,6 +1451,26 @@ async function hostSendText(host, body, conversationId) {
1326
1451
  host.allMessages = [...host.allMessages, localMessage];
1327
1452
  host.isMessageSending = true;
1328
1453
  host.isScrollToBottom = true;
1454
+ const bumpConversationPreview = () => {
1455
+ host.allConversationList = sortConversationsByLatestMessage(host.allConversationList.map(c => {
1456
+ var _a;
1457
+ return c.conversationId === id
1458
+ ? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: text, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
1459
+ }));
1460
+ };
1461
+ // Offline → optimistic bubble + outbox (sent when back online)
1462
+ if (!isBrowserOnline()) {
1463
+ await hostEnqueueFailedText(host, { localId, conversationId: id, body: text, localMessage });
1464
+ bumpConversationPreview();
1465
+ host.replyMessage = null;
1466
+ host.isMessageSending = false;
1467
+ showToast({
1468
+ message: 'You’re offline — message queued',
1469
+ type: 'warning',
1470
+ position: 'bottom-right',
1471
+ });
1472
+ return localId;
1473
+ }
1329
1474
  try {
1330
1475
  const payload = {
1331
1476
  showInConversation: true,
@@ -1342,21 +1487,26 @@ async function hostSendText(host, body, conversationId) {
1342
1487
  const res = await M.getInstance().message.postMessages(payload);
1343
1488
  const apiId = res === null || res === void 0 ? void 0 : res.messageId;
1344
1489
  if (apiId) {
1345
- host.allMessages = host.allMessages.map(m => m.messageId === localId ? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false }) : m);
1490
+ host.allMessages = host.allMessages.map(m => m.messageId === localId
1491
+ ? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, deliveryStatus: 'sent' }) : m);
1346
1492
  }
1347
- host.allConversationList = sortConversationsByLatestMessage(host.allConversationList.map(c => {
1348
- var _a;
1349
- return c.conversationId === id
1350
- ? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: text, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
1351
- }));
1493
+ bumpConversationPreview();
1352
1494
  host.replyMessage = null;
1495
+ void hostPersistMessages(host, id);
1353
1496
  return apiId || localId;
1354
1497
  }
1355
1498
  catch (error) {
1356
1499
  console.error('web-chat sendText failed', error);
1357
- host.emitChatError('sendText', (error === null || error === void 0 ? void 0 : error.message) || 'Failed to send message', error);
1358
- showToast({ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to send message', type: 'error', position: 'bottom-right' });
1359
- return null;
1500
+ // Keep bubble + queue for retry (network blip / server error)
1501
+ await hostEnqueueFailedText(host, { localId, conversationId: id, body: text, localMessage });
1502
+ bumpConversationPreview();
1503
+ host.emitChatError('sendText', (error === null || error === void 0 ? void 0 : error.message) || 'Failed to send — queued for retry', error);
1504
+ showToast({
1505
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Send failed — queued for retry',
1506
+ type: 'warning',
1507
+ position: 'bottom-right',
1508
+ });
1509
+ return localId;
1360
1510
  }
1361
1511
  finally {
1362
1512
  host.isMessageSending = false;
@@ -1364,22 +1514,59 @@ async function hostSendText(host, body, conversationId) {
1364
1514
  }
1365
1515
  async function hostSendMedia(host, files, conversationId, caption) {
1366
1516
  var _a;
1367
- const list = Array.from(files || []).filter(Boolean);
1517
+ const raw = Array.from(files || []).filter(Boolean);
1518
+ const { accepted: list, rejected } = takeMediaFiles(raw, 0);
1368
1519
  const id = conversationId || host.selectedConversationId;
1369
- if (!list.length || !id) {
1520
+ if (!raw.length || !id) {
1370
1521
  host.emitChatError('sendMedia', 'Missing files or conversationId');
1371
1522
  return null;
1372
1523
  }
1524
+ if (rejected > 0) {
1525
+ showToast({
1526
+ message: mediaLimitToastMessage(rejected, MAX_MEDIA_PER_MESSAGE),
1527
+ type: 'warning',
1528
+ position: 'bottom-right',
1529
+ });
1530
+ }
1531
+ if (!list.length) {
1532
+ host.emitChatError('sendMedia', `Max ${MAX_MEDIA_PER_MESSAGE} files per message`);
1533
+ return null;
1534
+ }
1373
1535
  const deviceId = host.deviceId || (await getDeviceID());
1374
1536
  const reply = host.replyMessage;
1375
1537
  const localId = `${Date.now()}${Math.random() * 100}`;
1376
1538
  const attachments = prepareMediaAttachments(list);
1377
1539
  const localAttachments = buildLocalMediaAttachments(list);
1378
1540
  const body = (caption || '').trim() || 'AttachmentMessage:Multiple';
1379
- const localMessage = Object.assign({ body, messageId: localId, deliveredToAll: 'pending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now(), attachments: localAttachments, customType: list.length === 1 ? customTypeFromMime(list[0].type) : 'AttachmentMessage:Multiple', metaData: buildReplyMetaData(reply, caption) }, (reply && { parentMessageId: reply.messageId }));
1541
+ const localMessage = Object.assign({ body, messageId: localId, deliveredToAll: 'pending', deliveryStatus: 'sending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now(), attachments: localAttachments, customType: list.length === 1 ? customTypeFromMime(list[0].type) : 'AttachmentMessage:Multiple', metaData: buildReplyMetaData(reply, caption) }, (reply && { parentMessageId: reply.messageId }));
1380
1542
  host.allMessages = [...host.allMessages, localMessage];
1381
1543
  host.isMessageSending = true;
1382
1544
  host.isScrollToBottom = true;
1545
+ const bumpConversationPreview = () => {
1546
+ host.allConversationList = sortConversationsByLatestMessage(host.allConversationList.map(c => {
1547
+ var _a;
1548
+ return c.conversationId === id
1549
+ ? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: localMessage.customType || body, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
1550
+ }));
1551
+ };
1552
+ if (!isBrowserOnline()) {
1553
+ await hostEnqueueFailedMedia(host, {
1554
+ localId,
1555
+ conversationId: id,
1556
+ files: list,
1557
+ caption,
1558
+ localMessage,
1559
+ });
1560
+ bumpConversationPreview();
1561
+ host.replyMessage = null;
1562
+ host.isMessageSending = false;
1563
+ showToast({
1564
+ message: 'You’re offline — media queued',
1565
+ type: 'warning',
1566
+ position: 'bottom-right',
1567
+ });
1568
+ return localId;
1569
+ }
1383
1570
  try {
1384
1571
  const apiId = await uploadAndPostMediaMessage({
1385
1572
  conversationId: id,
@@ -1389,21 +1576,31 @@ async function hostSendMedia(host, files, conversationId, caption) {
1389
1576
  caption,
1390
1577
  });
1391
1578
  if (apiId) {
1392
- host.allMessages = host.allMessages.map(m => m.messageId === localId ? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false }) : m);
1579
+ host.allMessages = host.allMessages.map(m => m.messageId === localId
1580
+ ? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, deliveryStatus: 'sent' }) : m);
1393
1581
  }
1394
- host.allConversationList = sortConversationsByLatestMessage(host.allConversationList.map(c => {
1395
- var _a;
1396
- return c.conversationId === id
1397
- ? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: localMessage.customType || body, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
1398
- }));
1582
+ bumpConversationPreview();
1399
1583
  host.replyMessage = null;
1584
+ void hostPersistMessages(host, id);
1400
1585
  return apiId || localId;
1401
1586
  }
1402
1587
  catch (error) {
1403
1588
  console.error('web-chat sendMedia failed', error);
1589
+ await hostEnqueueFailedMedia(host, {
1590
+ localId,
1591
+ conversationId: id,
1592
+ files: list,
1593
+ caption,
1594
+ localMessage,
1595
+ });
1596
+ bumpConversationPreview();
1404
1597
  host.emitChatError('sendMedia', (error === null || error === void 0 ? void 0 : error.message) || 'Failed to send media', error);
1405
- showToast({ message: (error === null || error === void 0 ? void 0 : error.message) || 'Failed to send media', type: 'error', position: 'bottom-right' });
1406
- return null;
1598
+ showToast({
1599
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Send failed — media queued for retry',
1600
+ type: 'warning',
1601
+ position: 'bottom-right',
1602
+ });
1603
+ return localId;
1407
1604
  }
1408
1605
  finally {
1409
1606
  host.isMessageSending = false;
@@ -1510,9 +1707,17 @@ function createMqttContext(host) {
1510
1707
 
1511
1708
  /**
1512
1709
  * MQTT connect / subscribe / forward for <web-chat>.
1710
+ *
1711
+ * Butter path:
1712
+ * - mqtt.js auto-reconnect (bounded period)
1713
+ * - on every connect → resubscribe + gap-fill (soft merge, no UI wipe)
1714
+ * - while offline → light REST poll for open thread only
1715
+ * - inbound messages processed on a per-host serial queue
1513
1716
  */
1717
+ const OFFLINE_POLL_MS = 15000;
1514
1718
  function hostAppendInboundMessage(host, parsedMessage) {
1515
1719
  host.allMessages = appendUniqueById(host.allMessages, parsedMessage);
1720
+ void hostPersistMessages(host);
1516
1721
  }
1517
1722
  /**
1518
1723
  * Build MQTT dispatch context from the live <web-chat> host.
@@ -1529,10 +1734,12 @@ function hostCreateMqttContext(host) {
1529
1734
  }));
1530
1735
  }
1531
1736
  async function hostHandleMqttMessage(host, message) {
1532
- const parsedMessage = parseMqttPayload(message);
1533
- if (!parsedMessage)
1534
- return;
1535
- await dispatchMqttMessage(parsedMessage, hostCreateMqttContext(host));
1737
+ return enqueueMqttTask(host, async () => {
1738
+ const parsedMessage = parseMqttPayload(message);
1739
+ if (!parsedMessage)
1740
+ return;
1741
+ await dispatchMqttMessage(parsedMessage, hostCreateMqttContext(host));
1742
+ });
1536
1743
  }
1537
1744
  function hostSubscribeToMqtt(host) {
1538
1745
  const userId = host.isometrikUserId || host.isometrikUserIdFromCookie;
@@ -1547,8 +1754,111 @@ function hostSubscribeToMqtt(host) {
1547
1754
  host.isSubscribedToTopic = true;
1548
1755
  host.isMessageListenerAttached = true;
1549
1756
  }
1757
+ function clearOfflinePoll(host) {
1758
+ if (host.mqttRefetchInterval) {
1759
+ clearInterval(host.mqttRefetchInterval);
1760
+ host.mqttRefetchInterval = null;
1761
+ }
1762
+ }
1763
+ /** While MQTT is down, lightly refresh the open conversation (not a full wipe). */
1764
+ function startOfflinePoll(host) {
1765
+ if (host.mqttRefetchInterval)
1766
+ return;
1767
+ host.mqttRefetchInterval = setInterval(() => {
1768
+ if (host.isMqttConnected) {
1769
+ clearOfflinePoll(host);
1770
+ return;
1771
+ }
1772
+ void hostGapFillMessages(host);
1773
+ }, OFFLINE_POLL_MS);
1774
+ }
1775
+ /**
1776
+ * Soft gap-fill: fetch latest page and merge by messageId — no clearing the thread
1777
+ * (avoids flicker after reconnect).
1778
+ */
1779
+ async function hostGapFillMessages(host) {
1780
+ const conversationId = host.selectedConversationId;
1781
+ if (!conversationId || typeof host.getMessages !== 'function')
1782
+ return;
1783
+ try {
1784
+ const page = await fetchMessagesPage({ conversationId, skip: 0 });
1785
+ if (!Array.isArray(page) || page.length === 0)
1786
+ return;
1787
+ const existing = Array.isArray(host.allMessages) ? host.allMessages : [];
1788
+ const byId = new Map();
1789
+ existing.forEach((m) => {
1790
+ if (m === null || m === void 0 ? void 0 : m.messageId)
1791
+ byId.set(m.messageId, m);
1792
+ });
1793
+ page.forEach((m) => {
1794
+ if (m === null || m === void 0 ? void 0 : m.messageId)
1795
+ byId.set(m.messageId, m);
1796
+ });
1797
+ const merged = Array.from(byId.values()).sort((a, b) => {
1798
+ var _a, _b, _c, _d;
1799
+ const ta = (_b = (_a = a === null || a === void 0 ? void 0 : a.sentAt) !== null && _a !== void 0 ? _a : a === null || a === void 0 ? void 0 : a.updatedAt) !== null && _b !== void 0 ? _b : 0;
1800
+ const tb = (_d = (_c = b === null || b === void 0 ? void 0 : b.sentAt) !== null && _c !== void 0 ? _c : b === null || b === void 0 ? void 0 : b.updatedAt) !== null && _d !== void 0 ? _d : 0;
1801
+ return ta - tb;
1802
+ });
1803
+ // Only write if something new arrived
1804
+ if (merged.length !== existing.length || page.some((m) => (m === null || m === void 0 ? void 0 : m.messageId) && !existing.some((e) => (e === null || e === void 0 ? void 0 : e.messageId) === m.messageId))) {
1805
+ host.allMessages = merged;
1806
+ }
1807
+ }
1808
+ catch (e) {
1809
+ console.error('MQTT gap-fill failed:', e);
1810
+ }
1811
+ }
1812
+ async function onMqttConnected(host) {
1813
+ var _a, _b;
1814
+ const wasReconnect = (host.mqttConnectCount || 0) > 0;
1815
+ host.mqttConnectCount = (host.mqttConnectCount || 0) + 1;
1816
+ host.mqttInitialized = true;
1817
+ host.isMqttConnected = true;
1818
+ hostSubscribeToMqtt(host);
1819
+ host.mqttSession.resubscribe();
1820
+ clearOfflinePoll(host);
1821
+ if (host.selectedConversationId) {
1822
+ if (!host.isInitialCallDone) {
1823
+ try {
1824
+ await M.getInstance().message.putRead({ conversationId: host.selectedConversationId });
1825
+ }
1826
+ catch (_c) {
1827
+ /* non-fatal */
1828
+ }
1829
+ host.isInitialCallDone = true;
1830
+ }
1831
+ if (wasReconnect) {
1832
+ await hostGapFillMessages(host);
1833
+ void hostPersistMessages(host);
1834
+ // Refresh sidebar previews without blocking UI
1835
+ void Promise.resolve((_a = host.getConversations) === null || _a === void 0 ? void 0 : _a.call(host, 0)).catch(() => undefined);
1836
+ }
1837
+ // Drain any text messages queued while offline / failed
1838
+ void hostFlushOutbox(host);
1839
+ }
1840
+ else if (wasReconnect) {
1841
+ void Promise.resolve((_b = host.getConversations) === null || _b === void 0 ? void 0 : _b.call(host, 0)).catch(() => undefined);
1842
+ void hostFlushOutbox(host);
1843
+ }
1844
+ else {
1845
+ void hostFlushOutbox(host);
1846
+ }
1847
+ }
1848
+ function onMqttUnavailable(host, reason, error) {
1849
+ host.isMqttConnected = false;
1850
+ if (reason === 'error') {
1851
+ host.mqttInitialized = false;
1852
+ const msg = String((error === null || error === void 0 ? void 0 : error.message) || error || '');
1853
+ if (/not authorized/i.test(msg)) {
1854
+ // Auth failure — do not spin reconnect poll forever
1855
+ clearOfflinePoll(host);
1856
+ return;
1857
+ }
1858
+ }
1859
+ startOfflinePoll(host);
1860
+ }
1550
1861
  async function hostSetupMqttClient(host) {
1551
- var _a;
1552
1862
  const deviceID = await getDeviceID();
1553
1863
  const clientId = host.isometrikUserId || host.isometrikUserIdFromCookie;
1554
1864
  const mqttClient = M.getInstance().initializeMqtt({
@@ -1561,44 +1871,28 @@ async function hostSetupMqttClient(host) {
1561
1871
  deviceId: deviceID,
1562
1872
  });
1563
1873
  const raw = mqttClient.client;
1564
- if (raw === null || raw === void 0 ? void 0 : raw.options)
1565
- raw.options.reconnectPeriod = 0;
1566
- if (raw === null || raw === void 0 ? void 0 : raw.reconnectTimer) {
1567
- clearInterval(raw.reconnectTimer);
1568
- raw.reconnectTimer = null;
1569
- }
1570
- (_a = raw === null || raw === void 0 ? void 0 : raw.removeAllListeners) === null || _a === void 0 ? void 0 : _a.call(raw, 'error');
1874
+ // Enable mqtt.js reconnect (was previously forced to 0).
1875
+ applyMqttReconnectOptions(raw);
1571
1876
  host.mqttClient = mqttClient;
1572
1877
  host.isMqttConnected = false;
1878
+ host.mqttConnectCount = host.mqttConnectCount || 0;
1573
1879
  host.mqttSession.attach(mqttClient, {
1574
1880
  onConnect: async () => {
1575
- host.mqttInitialized = true;
1576
- host.isMqttConnected = true;
1577
- hostSubscribeToMqtt(host);
1578
- if (host.mqttRefetchInterval) {
1579
- clearInterval(host.mqttRefetchInterval);
1580
- host.mqttRefetchInterval = null;
1581
- }
1582
- if (!host.isInitialCallDone && host.selectedConversationId) {
1583
- await M.getInstance().message.putRead({ conversationId: host.selectedConversationId });
1584
- host.refetchMessages();
1585
- host.isInitialCallDone = true;
1586
- }
1881
+ await onMqttConnected(host);
1587
1882
  },
1588
1883
  onDisconnect: () => {
1884
+ onMqttUnavailable(host, 'disconnect');
1885
+ },
1886
+ onOffline: () => {
1887
+ onMqttUnavailable(host, 'offline');
1888
+ },
1889
+ onReconnect: () => {
1890
+ // mqtt.js is attempting reconnect — keep poll until connect succeeds
1589
1891
  host.isMqttConnected = false;
1590
1892
  },
1591
1893
  onError: (error) => {
1592
1894
  console.error('MQTT connection error:', error);
1593
- host.mqttInitialized = false;
1594
- host.isMqttConnected = false;
1595
- if (/not authorized/i.test(String((error === null || error === void 0 ? void 0 : error.message) || error)))
1596
- return;
1597
- if (!host.mqttRefetchInterval) {
1598
- host.mqttRefetchInterval = setInterval(() => {
1599
- host.refetchMessages();
1600
- }, 30000);
1601
- }
1895
+ onMqttUnavailable(host, 'error', error);
1602
1896
  },
1603
1897
  onMessage: async (_topic, message) => {
1604
1898
  await hostHandleMqttMessage(host, message);
@@ -2110,16 +2404,26 @@ const selectChatPlaceholderSvg = `
2110
2404
  `;
2111
2405
 
2112
2406
  /** Presentational shell tree for <web-chat> — keeps WebChat.tsx thin. */
2407
+ /** show / custom-slot / default matrix for any named region. */
2408
+ function renderRegion(host, slotName, show, renderDefault) {
2409
+ const mode = resolveRegionMode({
2410
+ show,
2411
+ hasCustomSlot: hasNamedSlot(host.el, slotName),
2412
+ });
2413
+ if (mode === 'hidden')
2414
+ return null;
2415
+ if (mode === 'custom')
2416
+ return h("slot", { name: slotName });
2417
+ return renderDefault();
2418
+ }
2113
2419
  function renderBootLoader(host) {
2114
- return (h("div", { class: "boot-loader-shell" },
2115
- h("slot", { name: "boot-loader" },
2116
- h("chat-loading-placeholder", { progress: host.loadingProgress, loadingStatus: host.loadingStatus }))));
2420
+ return (h("div", { class: "boot-loader-shell" }, renderRegion(host, 'boot-loader', true, () => (h("chat-loading-placeholder", { progress: host.loadingProgress, loadingStatus: host.loadingStatus })))));
2117
2421
  }
2118
2422
  function renderBusyOverlay(host) {
2119
2423
  if (!host.isConversationLoading)
2120
2424
  return null;
2121
2425
  return (h("div", { class: "loaderoverlay" },
2122
- h("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary-color)", spinnerSecondaryColor: "var(--text-primary-color)", spinnerBorderWidth: "2px" })));
2426
+ h("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary)", spinnerSecondaryColor: "var(--text-primary)", spinnerBorderWidth: "2px" })));
2123
2427
  }
2124
2428
  function renderDefaultConversationList(host) {
2125
2429
  var _a;
@@ -2137,47 +2441,50 @@ function renderDefaultConversationList(host) {
2137
2441
  marginBottom: '10px',
2138
2442
  }, filterTab: {
2139
2443
  padding: '10px 15px',
2140
- border: '1px solid var(--bg-primary-light)',
2444
+ border: '1px solid var(--brand-soft)',
2141
2445
  borderRadius: '25px',
2142
2446
  backgroundColor: 'transparent',
2143
2447
  cursor: 'pointer',
2144
2448
  transition: 'background-color 0.3s',
2145
- color: 'var(--text-tertiary-color)',
2449
+ color: 'var(--text-tertiary)',
2146
2450
  fontSize: '12px',
2147
2451
  textTransform: 'uppercase',
2148
2452
  }, filterTabHover: {
2149
- backgroundColor: 'var(--bg-primary-light)',
2453
+ backgroundColor: 'var(--brand-soft)',
2150
2454
  }, isSidebarHeaderLabel: host.isSidebarHeaderLabel, isSidebarHeaderSearch: host.isSidebarHeaderSearch, sidebarHeaderLabel: host.sidebarHeaderLabel, sidebarColor: host.sidebarColor, sidebarSelectedColor: host.sidebarSelectedColor, onGroupExited: (e) => host.handleGroupExited(e), handleSearchData: (searchTag) => host.getConversations(0, searchTag, true), allMessages: host.allMessages, isConversationLoading: host.isLoadingConversationList }));
2151
2455
  }
2152
2456
  function renderSidebarTab(host) {
2153
- if (host.activeTab === 'GroupCast') {
2154
- return (h("slot", { name: "group-cast" },
2155
- h("group-cast", { isLoadingMore: host.isLoadingMoreGroupcast, groupCastData: host.allGroupCastContacts, userMetaData: host.userMetaData, onGroupcastTileSelected: (e) => host.handleChatSelect(e.detail), onCreated: (g) => {
2156
- if (!(g === null || g === void 0 ? void 0 : g.groupcastId))
2157
- return;
2158
- host.allGroupCastContacts = [g, ...(host.allGroupCastContacts || [])];
2159
- } })));
2160
- }
2161
- if (host.activeTab === 'Profile') {
2162
- return (h("slot", { name: "profile-page" },
2163
- h("profile-page", { getUserDetails: host.getUserDetails, name: host.userMetaData.userName, profilePhotoUrl: host.userMetaData.userProfileImageUrl, closeDrawer: () => (host.activeTab = 'Chat'), toggleTheme: host.toggleTheme, defaultTheme: host.defaultTheme })));
2164
- }
2165
- return h("slot", { name: "conversation-list" }, renderDefaultConversationList(host));
2457
+ const groupcastOn = host.groupcastEnabled !== false;
2458
+ const tab = host.activeTab === 'GroupCast' && !groupcastOn ? 'Chat' : host.activeTab;
2459
+ if (tab === 'GroupCast') {
2460
+ return renderRegion(host, 'group-cast', true, () => (h("group-cast", { isLoadingMore: host.isLoadingMoreGroupcast, groupCastData: host.allGroupCastContacts, userMetaData: host.userMetaData, onGroupcastTileSelected: (e) => host.handleChatSelect(e.detail), onCreated: (g) => {
2461
+ if (!(g === null || g === void 0 ? void 0 : g.groupcastId))
2462
+ return;
2463
+ host.allGroupCastContacts = [g, ...(host.allGroupCastContacts || [])];
2464
+ } })));
2465
+ }
2466
+ if (tab === 'Profile') {
2467
+ return renderRegion(host, 'profile-page', true, () => (h("profile-page", { getUserDetails: host.getUserDetails, name: host.userMetaData.userName, profilePhotoUrl: host.userMetaData.userProfileImageUrl, closeDrawer: () => (host.activeTab = 'Chat'), toggleTheme: host.toggleTheme, defaultTheme: host.defaultTheme })));
2468
+ }
2469
+ return renderRegion(host, 'conversation-list', host.showConversationList, () => renderDefaultConversationList(host));
2470
+ }
2471
+ function renderProfileRail(host) {
2472
+ return renderRegion(host, 'profile-rail', host.showProfileRail, () => (h("profile-sidebar", { userMetaData: host.userMetaData, activeTab: host.activeTab, openChat: () => (host.activeTab = 'Chat'), openProfile: () => (host.activeTab = 'Profile'), openGroupCast: () => {
2473
+ if (host.groupcastEnabled === false)
2474
+ return;
2475
+ host.getGroupCastContacts();
2476
+ }, unreadConversationsCount: host.unreadConversationsCount })));
2166
2477
  }
2167
2478
  function renderDefaultSidebar(host) {
2168
- // Hosts can pass showProfileRail={false} — no DOM poke / empty slots needed.
2169
- const showRail = host.showProfileRail !== false;
2170
2479
  return (h(Fragment, null,
2171
- showRail ? (h("slot", { name: "profile-rail" },
2172
- h("profile-sidebar", { userMetaData: host.userMetaData, activeTab: host.activeTab, openChat: () => (host.activeTab = 'Chat'), openProfile: () => (host.activeTab = 'Profile'), openGroupCast: () => host.getGroupCastContacts(), unreadConversationsCount: host.unreadConversationsCount }))) : null,
2480
+ renderProfileRail(host),
2173
2481
  h("div", { class: "sidebar-tab" }, renderSidebarTab(host))));
2174
2482
  }
2175
2483
  function renderLeftRail(host) {
2176
2484
  return (h("div", { class: {
2177
2485
  'chat-sidebar-container': true,
2178
2486
  'hidden': host.isMobileView && !host.showSidebar,
2179
- } },
2180
- h("slot", { name: "sidebar" }, renderDefaultSidebar(host))));
2487
+ } }, renderRegion(host, 'sidebar', true, () => renderDefaultSidebar(host))));
2181
2488
  }
2182
2489
  function renderDefaultComposer(host) {
2183
2490
  var _a;
@@ -2185,9 +2492,9 @@ function renderDefaultComposer(host) {
2185
2492
  return (h("div", { style: {
2186
2493
  padding: '1rem',
2187
2494
  textAlign: 'center',
2188
- backgroundColor: 'var(--bg-secondary-color)',
2189
- color: 'var(--text-primary-color)',
2190
- borderTop: '1px solid var(--bg-secondary-color)',
2495
+ backgroundColor: 'var(--bg-secondary)',
2496
+ color: 'var(--text-primary)',
2497
+ borderTop: '1px solid var(--bg-secondary)',
2191
2498
  } }, "You are no longer a member of this group"));
2192
2499
  }
2193
2500
  if (host.isBlocked === 'loading') {
@@ -2196,9 +2503,6 @@ function renderDefaultComposer(host) {
2196
2503
  if ((_a = host.conversationMetaData) === null || _a === void 0 ? void 0 : _a.messagingDisabled) {
2197
2504
  return h("p", { class: "blockMessageContainer" }, WEB_CONTENT.BLOCK_CHAT_MESSAGE);
2198
2505
  }
2199
- // Only re-project when the host actually filled the slot. An empty
2200
- // <slot slot="composer-input"> still counts as assigned content and
2201
- // suppresses chat-footer's default <my-test-footer-ui> fallback.
2202
2506
  const el = host.el;
2203
2507
  return (h("chat-footer", { userMetaData: host.userMetaData, updateAllMessages: host.updateAllMessages, changeMessageSendingState: host.changeMessageSendingState, changeScrollToBottomState: host.changeScrollToBottomState, refetchMessages: host.refetchMessages, allMessages: host.allMessages, selectedConversationId: host.selectedConversationId, replyMessage: host.replyMessage, handleremoveReplyMessage: host.handleremoveReplyMessage, conversationDetails: host.conversationMetaData, allConversationList: host.allConversationList, updateConversationListProp: host.updateConversationList },
2204
2508
  hasNamedSlot(el, 'reply-preview') ? h("slot", { name: "reply-preview", slot: "reply-preview" }) : null,
@@ -2207,10 +2511,10 @@ function renderDefaultComposer(host) {
2207
2511
  }
2208
2512
  /** slot="composer" replaces whole footer; else reply-preview / attachment-preview / composer-input */
2209
2513
  function renderComposerOrBanner(host) {
2210
- return h("slot", { name: "composer" }, renderDefaultComposer(host));
2514
+ return renderRegion(host, 'composer', host.showComposer, () => renderDefaultComposer(host));
2211
2515
  }
2212
2516
  function renderDefaultEmptyChat(_host) {
2213
- return (h("div", { style: { backgroundColor: 'var(--bg-secondary-color)', color: 'var(--text-tertiary-color)' }, class: "noChatSelectedPlaceholder" },
2517
+ return (h("div", { style: { backgroundColor: 'var(--bg-secondary)', color: 'var(--text-tertiary)' }, class: "noChatSelectedPlaceholder" },
2214
2518
  h("div", { innerHTML: selectChatPlaceholderSvg }),
2215
2519
  h("span", null, "\"Start a Conversation\""),
2216
2520
  h("span", null,
@@ -2220,23 +2524,23 @@ function renderDefaultEmptyChat(_host) {
2220
2524
  }
2221
2525
  function renderDefaultHeader(host) {
2222
2526
  var _a, _b;
2223
- return (h("web-chat-header", { searchedMessageDetails: host.searchedMessageDetails, onSearchHandler: (text) => host.getMessagesByQuery(text), onSearchResultClick: host.handleSearchResultClick, headerBgColor: "var(--bg-primary-color)", headerLastSeenColor: "var(--text-last-seen)", headerSvgColor: "var(--text-primary-color)", headerUsernameColor: "var(--text-primary-color)", onClearConversation: () => host.clearConversation(), conversationDetails: host.conversationMetaData, isTyping: host.isTyping && host.selectedConversationId === host.typingConversationId, typingUserName: host.typingUserName, chatBodyRef: host.chatBodyRef, onTextClick: () => host.getAllAttachments(host.selectedConversationId), allAttachments: host.allAttachments, lastSeen: (_b = (_a = host.conversationMetaData) === null || _a === void 0 ? void 0 : _a.opponentDetails) === null || _b === void 0 ? void 0 : _b.lastSeen, userMetaData: host.userMetaData, selectedConversationId: host.selectedConversationId, messageAction: host.messageAction, eligibleMembers: host.eligibleMembers, hasMoreEligibleMembers: host.hasMoreEligibleMembers, handleCloseChat: () => host.handleCloseChat(), typingConversationId: host.typingConversationId, isBlocked: host.isBlocked, onBackButtonClick: () => host.handleBackButton() }));
2527
+ return (h("web-chat-header", { searchedMessageDetails: host.searchedMessageDetails, onSearchHandler: (text) => host.getMessagesByQuery(text), onSearchResultClick: host.handleSearchResultClick, headerBgColor: "var(--bg-primary)", headerLastSeenColor: "var(--text-secondary)", headerSvgColor: "var(--text-primary)", headerUsernameColor: "var(--text-primary)", onClearConversation: () => host.clearConversation(), conversationDetails: host.conversationMetaData, isTyping: host.isTyping && host.selectedConversationId === host.typingConversationId, typingUserName: host.typingUserName, chatBodyRef: host.chatBodyRef, onTextClick: () => host.getAllAttachments(host.selectedConversationId), allAttachments: host.allAttachments, lastSeen: (_b = (_a = host.conversationMetaData) === null || _a === void 0 ? void 0 : _a.opponentDetails) === null || _b === void 0 ? void 0 : _b.lastSeen, userMetaData: host.userMetaData, selectedConversationId: host.selectedConversationId, messageAction: host.messageAction, eligibleMembers: host.eligibleMembers, hasMoreEligibleMembers: host.hasMoreEligibleMembers, handleCloseChat: () => host.handleCloseChat(), typingConversationId: host.typingConversationId, isBlocked: host.isBlocked, onBackButtonClick: () => host.handleBackButton() }));
2224
2528
  }
2225
2529
  function renderDefaultMessages(host) {
2226
2530
  var _a;
2227
2531
  return (h("web-chat-body", { ref: el => (host.chatBodyRef = el), allAttachments: host.allAttachments, isMessagesLoading: host.isMessagesLoading, updateSkip: host.updateSkip, isMessageLimitEnd: host.isMessageLimitEnd, allMessages: host.allMessages, userMetaData: host.userMetaData, skip: host.skip, isScrollToBottom: host.isScrollToBottom, changeScrollToBottomState: host.changeScrollToBottomState, isMessageSending: host.isMessageSending, isScrollToTop: host.isScrollToTop, changeScrollToTopState: host.changeScrollToTopState, deleteForSelf: host.deleteMessageFromSelf, deleteForAll: host.deleteMeassageFromEveryOne, isChatClosed: host.isChatClosed, isChatMinimized: host.isChatMinimized, updateAllMessages: host.updateAllMessages, selectedConversationId: host.selectedConversationId, highlightedMessageId: host.highlightedMessageId, onMediaClick: () => host.getAllAttachments(host.selectedConversationId), onReplyMessageDetails: host.handleReplyMessage, conversationList: host.allConversationList, newMessageNotification: host.newMessageNotification, onNewMessageCountReset: () => host.resetNewMessageNotification(), conversationDetails: host.conversationMetaData, loadingMediaGallery: host.loadingMediaGallery, customParts: (_a = host.customParts) !== null && _a !== void 0 ? _a : {} }, hasNamedSlot(host.el, 'message-info') ? h("slot", { name: "message-info", slot: "message-info" }) : null));
2228
2532
  }
2229
2533
  function renderActiveChat(host) {
2230
- const info = host.messageInfoPanel;
2534
+ const info = host.messageInfoView;
2231
2535
  return (h("div", { class: { 'chat-pane-row': true, 'info-open': !!(info === null || info === void 0 ? void 0 : info.open) } },
2232
2536
  h("div", { class: "chat-main-stack" },
2233
- h("slot", { name: "header" }, renderDefaultHeader(host)),
2234
- h("slot", { name: "messages" }, renderDefaultMessages(host)),
2537
+ renderRegion(host, 'header', host.showHeader, () => renderDefaultHeader(host)),
2538
+ renderRegion(host, 'messages', true, () => renderDefaultMessages(host)),
2235
2539
  renderComposerOrBanner(host)),
2236
2540
  (info === null || info === void 0 ? void 0 : info.open) ? (h("div", { class: "message-info-dock" }, info.isLoading ? (h("div", { class: "message-info-loading" },
2237
2541
  h("spinner-loader", { height: "20px", width: "20px", spinTime: "1s", spinnerPrimaryColor: "var(--brand, #2563eb)", spinnerSecondaryColor: "var(--border, #e5e7eb)", spinnerBorderWidth: "2px" }))) : (h("message-info", { selectedMessage: info.selectedMessage, messageDeliveryTime: info.messageDeliveryTime, messageReadTime: info.messageReadTime, readUserList: info.readUserList || [], deliveryUserList: info.deliveryUserList || [], isGroup: info.isGroup, pendingReadCount: info.pendingReadCount, pendingDeliveryCount: info.pendingDeliveryCount, allAttachments: host.allAttachments, onMediaClick: () => host.getAllAttachments(host.selectedConversationId), closePopup: () => {
2238
2542
  var _a, _b;
2239
- host.messageInfoPanel = null;
2543
+ host.messageInfoView = null;
2240
2544
  (_b = (_a = host.chatBodyRef) === null || _a === void 0 ? void 0 : _a.closeMessageInfo) === null || _b === void 0 ? void 0 : _b.call(_a);
2241
2545
  } })))) : null));
2242
2546
  }
@@ -2254,7 +2558,7 @@ function renderChatPane(host) {
2254
2558
  }
2255
2559
  : host.selectedConversationId
2256
2560
  ? { background: 'var(--bg-tertiary, #f4f4f5)' }
2257
- : undefined }, host.selectedConversationId ? (renderActiveChat(host)) : (h("slot", { name: "empty" }, renderDefaultEmptyChat()))));
2561
+ : undefined }, host.selectedConversationId ? (renderActiveChat(host)) : (renderRegion(host, 'empty', host.showEmptyState, () => renderDefaultEmptyChat()))));
2258
2562
  }
2259
2563
  function renderDefaultRightPanel(host) {
2260
2564
  return (h("web-chat-right-sidebar", { conversationMetaData: host.isProfileInfoOpen ? host.selctConversationMetaData : host.conversationMetaData, selectedConversationId: host.selectedConversationId, hasMoreEligibleMembers: host.hasMoreEligibleMembers, eligibleMembers: host.eligibleMembers, allAttachments: host.isProfileInfoOpen ? host.selectConverSationAttachments : host.allAttachments, userMetaData: host.userMetaData, messageAction: host.messageAction, searchedMessageDetails: host.searchedMessageDetails, onSearchHandler: (text) => host.getMessagesByQuery(text), onSearchResultClick: host.handleSearchResultClick, isContactInfoOpen: host.isContactInfoOpen, isProfileInfoOpen: host.isProfileInfoOpen, isOpenSearchBar: host.isOpenSearchBar, chatBodyRef: host.chatBodyRef, isLoadingMessage: host.isLoadingMessage, conversationIdFromContactinfo: host.conversationIdFromContactinfo, openOwnProfile: () => (host.activeTab = 'Profile'), handleChatSelect: conversationId => host.handleChatSelect(conversationId), allLinks: host.allLinks, allLinksCount: host.allLinksCount, isBlocked: host.isBlocked, groupcastMembers: host.groupcastMembers },
@@ -2263,10 +2567,11 @@ function renderDefaultRightPanel(host) {
2263
2567
  hasNamedSlot(host.el, 'message-search') ? h("slot", { name: "message-search", slot: "message-search" }) : null));
2264
2568
  }
2265
2569
  function renderRightRail(host) {
2570
+ if (host.showRightPanel === false)
2571
+ return null;
2266
2572
  if (!host.showRightSideBar)
2267
2573
  return null;
2268
- return (h("div", { class: "chat-sidebar-right" },
2269
- h("slot", { name: "right-panel" }, renderDefaultRightPanel(host))));
2574
+ return (h("div", { class: "chat-sidebar-right" }, renderRegion(host, 'right-panel', true, () => renderDefaultRightPanel(host))));
2270
2575
  }
2271
2576
 
2272
2577
  const webChatCss = ":host{display:flex;flex:1;width:var(--w-full);min-height:100dvh;height:var(--h-full)}web-chat{display:flex;flex:1;width:var(--w-full);min-height:100dvh;height:var(--h-full)}.boot-loader-shell{display:flex;flex:1;width:var(--w-full);min-height:100dvh;height:var(--h-full);align-items:stretch;justify-content:stretch}.boot-loader-shell>chat-loading-placeholder,.boot-loader-shell>slot[name='boot-loader']{display:flex;flex:1;width:var(--w-full);min-height:100dvh}.isometrik-quickchat{box-shadow:0 0 1.25rem 1px color-mix(in srgb, var(--brand) 15%, transparent);display:flex;height:100dvh;width:var(--w-full)}.chat-sidebar-container{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-right:1px solid var(--border);display:flex;flex-direction:row;background-color:var(--bg-primary);overflow:hidden;min-height:0}profile-sidebar,profile-sidebar-ui{display:flex;height:var(--h-full);flex-shrink:0}.chat-sidebar-right{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-left:1px solid var(--border);background-color:var(--bg-primary)}.loaderoverlay{width:var(--w-full);position:absolute;margin:auto;background:var(--overlay);z-index:1400}.sidebar-tab{flex:1;min-width:0;height:var(--h-full);min-height:0;background-color:var(--bg-primary);display:flex;flex-direction:column;overflow:hidden}.sidebar-tab>*{flex:1;min-height:0;min-width:0;width:var(--w-full);max-width:var(--w-full)}.chat-body-container{flex:1;display:flex;flex-direction:column;transition:all 0.3s ease;background-color:var(--bg-secondary);position:relative;min-height:0;min-width:0}.chat-pane-row{flex:1;min-height:0;min-width:0;display:flex;flex-direction:row;align-items:stretch;overflow:hidden}.chat-main-stack{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}.message-info-dock{flex:0 0 clamp(280px, 36%, 380px);height:var(--h-full);min-height:0;display:flex;flex-direction:column;background:var(--bg-primary);border-left:1px solid var(--border);overflow:hidden}.message-info-dock message-info{flex:1;min-height:0;height:var(--h-full);display:block}.message-info-loading{flex:1;display:flex;align-items:center;justify-content:center}.chat-sidebar-container>slot[name='sidebar'],.chat-sidebar-container slot[name='profile-rail'],.sidebar-tab>slot[name='conversation-list'],.sidebar-tab>slot[name='profile-page'],.sidebar-tab>slot[name='group-cast'],.chat-body-container>slot[name='empty'],.chat-main-stack>slot[name='header'],.chat-main-stack>slot[name='messages'],.chat-main-stack>slot[name='composer'],.chat-sidebar-right>slot[name='right-panel']{display:contents}::slotted([slot='sidebar']),::slotted([slot='profile-rail']),::slotted([slot='conversation-list']),::slotted([slot='profile-page']),::slotted([slot='group-cast']),::slotted([slot='empty']),::slotted([slot='messages']),::slotted([slot='right-panel']),::slotted([slot='contact-info']),::slotted([slot='profile-info']),::slotted([slot='message-search']),::slotted([slot='boot-loader']){display:flex;flex-direction:column;flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}::slotted([slot='header']),::slotted([slot='composer']),::slotted([slot='composer-input']),::slotted([slot='reply-preview']),::slotted([slot='attachment-preview']){display:block;width:var(--w-full);flex-shrink:0}.noChatSelectedPlaceholder{height:var(--h-full);width:var(--w-full);display:flex;align-items:center;justify-content:center;font-size:var(--text-20);flex-direction:column;gap:var(--gap-4);color:var(--text-primary)}.noChatSelectedPlaceholder span:nth-child(2){font-size:var(--text-24);font-weight:var(--fw-700);margin-top:var(--space-16)}.noChatSelectedPlaceholder span:nth-child(3){font-size:var(--text-18);text-align:center;color:var(--text-secondary)}.loadingPlaceholder{height:var(--h-full);width:var(--w-full);z-index:12839283}.back-button{display:none;padding:0;background:none;border:none;cursor:pointer;align-items:center;gap:var(--gap-4)}spinner-loader{display:flex;height:100dvh}.blockMessageContainer{text-align:center;padding:var(--space-16) 0;margin:0;background-color:var(--bg-secondary);color:var(--text-secondary)}@media (max-width: 768px){.isometrik-quickchat{position:relative;overflow:hidden}.chat-sidebar-right{width:var(--w-full);height:var(--h-full);min-width:100% !important;position:absolute;left:0;top:0;z-index:20;display:flex;flex-direction:column;background-color:var(--bg-primary);transition:all 0.3s ease;border:none}.chat-sidebar-right>*{flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}.chat-sidebar-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(0);transition:transform 0.3s ease;z-index:2;min-width:100% !important}.chat-sidebar-container.hidden{transform:translateX(-100%)}.chat-body-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(100%);transition:transform 0.3s ease;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:var(--rail-width);z-index:10;top:var(--space-16)}}";
@@ -2291,6 +2596,8 @@ const WebChat = /*@__PURE__*/ proxyCustomElement(class WebChat extends HTMLEleme
2291
2596
  this.mqttSession = new MqttSession();
2292
2597
  this.boundCheckMobileView = () => this.checkMobileView();
2293
2598
  this.mqttRefetchInterval = null;
2599
+ /** How many successful MQTT connects this mount (0 = first, >0 = reconnect). Used by mqtt-host. */
2600
+ this.mqttConnectCount = 0;
2294
2601
  this.typingClearTimeout = null;
2295
2602
  this.initGeneration = 0;
2296
2603
  this.chatReadyEmitted = false;
@@ -2383,9 +2690,8 @@ const WebChat = /*@__PURE__*/ proxyCustomElement(class WebChat extends HTMLEleme
2383
2690
  this.skip += 20;
2384
2691
  }
2385
2692
  }
2386
- const chatBody = document.querySelector('web-chat-body');
2387
- if (chatBody) {
2388
- // @ts-ignore
2693
+ const chatBody = this.chatBodyRef;
2694
+ if (chatBody === null || chatBody === void 0 ? void 0 : chatBody.scrollToMessage) {
2389
2695
  chatBody.scrollToMessage(messageId);
2390
2696
  }
2391
2697
  };
@@ -2416,9 +2722,14 @@ const WebChat = /*@__PURE__*/ proxyCustomElement(class WebChat extends HTMLEleme
2416
2722
  this.accountId = undefined;
2417
2723
  this.conversationId = undefined;
2418
2724
  this.hostUrl = undefined;
2419
- this.groupcastEnabled = undefined;
2725
+ this.groupcastEnabled = true;
2420
2726
  this.showProfileRail = true;
2421
2727
  this.showChatWallpaper = true;
2728
+ this.showHeader = true;
2729
+ this.showComposer = true;
2730
+ this.showEmptyState = true;
2731
+ this.showConversationList = true;
2732
+ this.showRightPanel = true;
2422
2733
  this.unreadConversations = [];
2423
2734
  this.allLinks = undefined;
2424
2735
  this.allLinksCount = undefined;
@@ -2471,8 +2782,8 @@ const WebChat = /*@__PURE__*/ proxyCustomElement(class WebChat extends HTMLEleme
2471
2782
  this.isSidebarHeaderLabel = true;
2472
2783
  this.sidebarHeaderLabel = 'Chats';
2473
2784
  this.isSidebarHeaderSearch = true;
2474
- this.sidebarColor = 'var(--bg-primary-color)';
2475
- this.sidebarSelectedColor = 'var(--bg-primary-light)';
2785
+ this.sidebarColor = 'var(--bg-primary)';
2786
+ this.sidebarSelectedColor = 'var(--brand-soft)';
2476
2787
  this.messageSearchText = '';
2477
2788
  this.searchedMessageDetails = [];
2478
2789
  this.initialConversationIdFromURL = '';
@@ -2658,6 +2969,7 @@ const WebChat = /*@__PURE__*/ proxyCustomElement(class WebChat extends HTMLEleme
2658
2969
  clearTimeout(this.typingClearTimeout);
2659
2970
  this.typingClearTimeout = null;
2660
2971
  }
2972
+ hostTeardownOffline(this);
2661
2973
  this.mqttSession.teardown();
2662
2974
  this.mqttClient = null;
2663
2975
  this.isMqttConnected = false;
@@ -2676,6 +2988,8 @@ const WebChat = /*@__PURE__*/ proxyCustomElement(class WebChat extends HTMLEleme
2676
2988
  this.isContactInfoOpen = false;
2677
2989
  this.isOpenSearchBar = false;
2678
2990
  this.conversationMetaData = metaFromConversationList(this.allConversationList, conversationId);
2991
+ // Show cached thread instantly while network fetch runs
2992
+ void hostHydrateMessagesFromCache(this, conversationId);
2679
2993
  if (typeof param === 'string') {
2680
2994
  this.getAllAttachments(conversationId);
2681
2995
  pushConversationUrl(conversationId || null);
@@ -2855,6 +3169,11 @@ const WebChat = /*@__PURE__*/ proxyCustomElement(class WebChat extends HTMLEleme
2855
3169
  "groupcastEnabled": [4, "groupcast-enabled"],
2856
3170
  "showProfileRail": [4, "show-profile-rail"],
2857
3171
  "showChatWallpaper": [4, "show-chat-wallpaper"],
3172
+ "showHeader": [4, "show-header"],
3173
+ "showComposer": [4, "show-composer"],
3174
+ "showEmptyState": [4, "show-empty-state"],
3175
+ "showConversationList": [4, "show-conversation-list"],
3176
+ "showRightPanel": [4, "show-right-panel"],
2858
3177
  "isChatFilter": [4, "is-chat-filter"],
2859
3178
  "isAllChatButton": [4, "is-all-chat-button"],
2860
3179
  "isSidebarHeaderLabel": [4, "is-sidebar-header-label"],