@cossistant/react 0.0.1

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 (372) hide show
  1. package/_virtual/rolldown_runtime.js +13 -0
  2. package/conversation.d.ts +312 -0
  3. package/conversation.d.ts.map +1 -0
  4. package/hooks/index.d.ts +23 -0
  5. package/hooks/index.js +24 -0
  6. package/hooks/private/store/use-conversations-store.d.ts +13 -0
  7. package/hooks/private/store/use-conversations-store.d.ts.map +1 -0
  8. package/hooks/private/store/use-conversations-store.js +34 -0
  9. package/hooks/private/store/use-conversations-store.js.map +1 -0
  10. package/hooks/private/store/use-store-selector.d.ts +10 -0
  11. package/hooks/private/store/use-store-selector.d.ts.map +1 -0
  12. package/hooks/private/store/use-store-selector.js +17 -0
  13. package/hooks/private/store/use-store-selector.js.map +1 -0
  14. package/hooks/private/store/use-website-store.d.ts +18 -0
  15. package/hooks/private/store/use-website-store.d.ts.map +1 -0
  16. package/hooks/private/store/use-website-store.js +39 -0
  17. package/hooks/private/store/use-website-store.js.map +1 -0
  18. package/hooks/private/use-client-query.d.ts +25 -0
  19. package/hooks/private/use-client-query.d.ts.map +1 -0
  20. package/hooks/private/use-client-query.js +122 -0
  21. package/hooks/private/use-client-query.js.map +1 -0
  22. package/hooks/private/use-default-messages.d.ts +18 -0
  23. package/hooks/private/use-default-messages.d.ts.map +1 -0
  24. package/hooks/private/use-default-messages.js +45 -0
  25. package/hooks/private/use-default-messages.js.map +1 -0
  26. package/hooks/private/use-grouped-messages.d.ts +54 -0
  27. package/hooks/private/use-grouped-messages.d.ts.map +1 -0
  28. package/hooks/private/use-grouped-messages.js +157 -0
  29. package/hooks/private/use-grouped-messages.js.map +1 -0
  30. package/hooks/private/use-multimodal-input.d.ts +40 -0
  31. package/hooks/private/use-multimodal-input.d.ts.map +1 -0
  32. package/hooks/private/use-multimodal-input.js +129 -0
  33. package/hooks/private/use-multimodal-input.js.map +1 -0
  34. package/hooks/private/use-rest-client.d.ts +17 -0
  35. package/hooks/private/use-rest-client.d.ts.map +1 -0
  36. package/hooks/private/use-rest-client.js +41 -0
  37. package/hooks/private/use-rest-client.js.map +1 -0
  38. package/hooks/private/use-visitor-typing-reporter.d.ts +19 -0
  39. package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -0
  40. package/hooks/private/use-visitor-typing-reporter.js +140 -0
  41. package/hooks/private/use-visitor-typing-reporter.js.map +1 -0
  42. package/hooks/use-composer-refocus.d.ts +20 -0
  43. package/hooks/use-composer-refocus.d.ts.map +1 -0
  44. package/hooks/use-composer-refocus.js +32 -0
  45. package/hooks/use-composer-refocus.js.map +1 -0
  46. package/hooks/use-conversation-auto-seen.d.ts +54 -0
  47. package/hooks/use-conversation-auto-seen.d.ts.map +1 -0
  48. package/hooks/use-conversation-auto-seen.js +106 -0
  49. package/hooks/use-conversation-auto-seen.js.map +1 -0
  50. package/hooks/use-conversation-history-page.d.ts +86 -0
  51. package/hooks/use-conversation-history-page.d.ts.map +1 -0
  52. package/hooks/use-conversation-history-page.js +97 -0
  53. package/hooks/use-conversation-history-page.js.map +1 -0
  54. package/hooks/use-conversation-lifecycle.d.ts +80 -0
  55. package/hooks/use-conversation-lifecycle.d.ts.map +1 -0
  56. package/hooks/use-conversation-lifecycle.js +54 -0
  57. package/hooks/use-conversation-lifecycle.js.map +1 -0
  58. package/hooks/use-conversation-page.d.ts +82 -0
  59. package/hooks/use-conversation-page.d.ts.map +1 -0
  60. package/hooks/use-conversation-page.js +138 -0
  61. package/hooks/use-conversation-page.js.map +1 -0
  62. package/hooks/use-conversation-seen.d.ts +17 -0
  63. package/hooks/use-conversation-seen.d.ts.map +1 -0
  64. package/hooks/use-conversation-seen.js +58 -0
  65. package/hooks/use-conversation-seen.js.map +1 -0
  66. package/hooks/use-conversation-timeline-items.d.ts +21 -0
  67. package/hooks/use-conversation-timeline-items.d.ts.map +1 -0
  68. package/hooks/use-conversation-timeline-items.js +87 -0
  69. package/hooks/use-conversation-timeline-items.js.map +1 -0
  70. package/hooks/use-conversation-typing.d.ts +13 -0
  71. package/hooks/use-conversation-typing.d.ts.map +1 -0
  72. package/hooks/use-conversation-typing.js +34 -0
  73. package/hooks/use-conversation-typing.js.map +1 -0
  74. package/hooks/use-conversation.d.ts +18 -0
  75. package/hooks/use-conversation.d.ts.map +1 -0
  76. package/hooks/use-conversation.js +44 -0
  77. package/hooks/use-conversation.js.map +1 -0
  78. package/hooks/use-conversations.d.ts +20 -0
  79. package/hooks/use-conversations.d.ts.map +1 -0
  80. package/hooks/use-conversations.js +68 -0
  81. package/hooks/use-conversations.js.map +1 -0
  82. package/hooks/use-create-conversation.d.ts +30 -0
  83. package/hooks/use-create-conversation.d.ts.map +1 -0
  84. package/hooks/use-create-conversation.js +67 -0
  85. package/hooks/use-create-conversation.js.map +1 -0
  86. package/hooks/use-home-page.d.ts +82 -0
  87. package/hooks/use-home-page.d.ts.map +1 -0
  88. package/hooks/use-home-page.js +89 -0
  89. package/hooks/use-home-page.js.map +1 -0
  90. package/hooks/use-message-composer.d.ts +88 -0
  91. package/hooks/use-message-composer.d.ts.map +1 -0
  92. package/hooks/use-message-composer.js +94 -0
  93. package/hooks/use-message-composer.js.map +1 -0
  94. package/hooks/use-realtime-support.d.ts +25 -0
  95. package/hooks/use-realtime-support.d.ts.map +1 -0
  96. package/hooks/use-realtime-support.js +29 -0
  97. package/hooks/use-realtime-support.js.map +1 -0
  98. package/hooks/use-send-message.d.ts +34 -0
  99. package/hooks/use-send-message.d.ts.map +1 -0
  100. package/hooks/use-send-message.js +118 -0
  101. package/hooks/use-send-message.js.map +1 -0
  102. package/hooks/use-visitor.d.ts +28 -0
  103. package/hooks/use-visitor.d.ts.map +1 -0
  104. package/hooks/use-visitor.js +59 -0
  105. package/hooks/use-visitor.js.map +1 -0
  106. package/hooks/use-window-visibility-focus.d.ts +9 -0
  107. package/hooks/use-window-visibility-focus.d.ts.map +1 -0
  108. package/hooks/use-window-visibility-focus.js +53 -0
  109. package/hooks/use-window-visibility-focus.js.map +1 -0
  110. package/identify-visitor.d.ts +18 -0
  111. package/identify-visitor.d.ts.map +1 -0
  112. package/identify-visitor.js +26 -0
  113. package/identify-visitor.js.map +1 -0
  114. package/index.d.ts +38 -0
  115. package/index.js +38 -0
  116. package/package.json +121 -0
  117. package/primitives/avatar/avatar.d.ts +31 -0
  118. package/primitives/avatar/avatar.d.ts.map +1 -0
  119. package/primitives/avatar/avatar.js +49 -0
  120. package/primitives/avatar/avatar.js.map +1 -0
  121. package/primitives/avatar/fallback.d.ts +24 -0
  122. package/primitives/avatar/fallback.d.ts.map +1 -0
  123. package/primitives/avatar/fallback.js +57 -0
  124. package/primitives/avatar/fallback.js.map +1 -0
  125. package/primitives/avatar/image.d.ts +27 -0
  126. package/primitives/avatar/image.d.ts.map +1 -0
  127. package/primitives/avatar/image.js +58 -0
  128. package/primitives/avatar/image.js.map +1 -0
  129. package/primitives/avatar/index.d.ts +4 -0
  130. package/primitives/avatar/index.js +5 -0
  131. package/primitives/avatar/index.parts.d.ts +4 -0
  132. package/primitives/avatar/index.parts.js +5 -0
  133. package/primitives/bubble.d.ts +28 -0
  134. package/primitives/bubble.d.ts.map +1 -0
  135. package/primitives/bubble.js +43 -0
  136. package/primitives/bubble.js.map +1 -0
  137. package/primitives/button.d.ts +19 -0
  138. package/primitives/button.d.ts.map +1 -0
  139. package/primitives/button.js +27 -0
  140. package/primitives/button.js.map +1 -0
  141. package/primitives/conversation-timeline.d.ts +86 -0
  142. package/primitives/conversation-timeline.d.ts.map +1 -0
  143. package/primitives/conversation-timeline.js +119 -0
  144. package/primitives/conversation-timeline.js.map +1 -0
  145. package/primitives/index.d.ts +20 -0
  146. package/primitives/index.d.ts.map +1 -0
  147. package/primitives/index.js +45 -0
  148. package/primitives/index.js.map +1 -0
  149. package/primitives/index.parts.d.ts +13 -0
  150. package/primitives/index.parts.js +14 -0
  151. package/primitives/multimodal-input.d.ts +53 -0
  152. package/primitives/multimodal-input.d.ts.map +1 -0
  153. package/primitives/multimodal-input.js +106 -0
  154. package/primitives/multimodal-input.js.map +1 -0
  155. package/primitives/timeline-item-group.d.ts +166 -0
  156. package/primitives/timeline-item-group.d.ts.map +1 -0
  157. package/primitives/timeline-item-group.js +204 -0
  158. package/primitives/timeline-item-group.js.map +1 -0
  159. package/primitives/timeline-item.d.ts +75 -0
  160. package/primitives/timeline-item.d.ts.map +1 -0
  161. package/primitives/timeline-item.js +145 -0
  162. package/primitives/timeline-item.js.map +1 -0
  163. package/primitives/window.d.ts +31 -0
  164. package/primitives/window.d.ts.map +1 -0
  165. package/primitives/window.js +58 -0
  166. package/primitives/window.js.map +1 -0
  167. package/provider.d.ts +95 -0
  168. package/provider.d.ts.map +1 -0
  169. package/provider.js +124 -0
  170. package/provider.js.map +1 -0
  171. package/realtime/event-filter.d.ts +8 -0
  172. package/realtime/event-filter.d.ts.map +1 -0
  173. package/realtime/event-filter.js +21 -0
  174. package/realtime/event-filter.js.map +1 -0
  175. package/realtime/index.d.ts +6 -0
  176. package/realtime/index.js +7 -0
  177. package/realtime/provider.d.ts +57 -0
  178. package/realtime/provider.d.ts.map +1 -0
  179. package/realtime/provider.js +351 -0
  180. package/realtime/provider.js.map +1 -0
  181. package/realtime/seen-store.d.ts +23 -0
  182. package/realtime/seen-store.d.ts.map +1 -0
  183. package/realtime/seen-store.js +34 -0
  184. package/realtime/seen-store.js.map +1 -0
  185. package/realtime/support-provider.d.ts +17 -0
  186. package/realtime/support-provider.d.ts.map +1 -0
  187. package/realtime/support-provider.js +54 -0
  188. package/realtime/support-provider.js.map +1 -0
  189. package/realtime/typing-store.d.ts +30 -0
  190. package/realtime/typing-store.d.ts.map +1 -0
  191. package/realtime/typing-store.js +34 -0
  192. package/realtime/typing-store.js.map +1 -0
  193. package/realtime/use-realtime.d.ts +29 -0
  194. package/realtime/use-realtime.d.ts.map +1 -0
  195. package/realtime/use-realtime.js +47 -0
  196. package/realtime/use-realtime.js.map +1 -0
  197. package/realtime-events.d.ts +344 -0
  198. package/realtime-events.d.ts.map +1 -0
  199. package/schemas.d.ts +90 -0
  200. package/schemas.d.ts.map +1 -0
  201. package/support/components/avatar-stack.d.ts +45 -0
  202. package/support/components/avatar-stack.d.ts.map +1 -0
  203. package/support/components/avatar-stack.js +72 -0
  204. package/support/components/avatar-stack.js.map +1 -0
  205. package/support/components/avatar.d.ts +15 -0
  206. package/support/components/avatar.d.ts.map +1 -0
  207. package/support/components/avatar.js +23 -0
  208. package/support/components/avatar.js.map +1 -0
  209. package/support/components/bubble.d.ts +10 -0
  210. package/support/components/bubble.d.ts.map +1 -0
  211. package/support/components/bubble.js +95 -0
  212. package/support/components/bubble.js.map +1 -0
  213. package/support/components/button.d.ts +20 -0
  214. package/support/components/button.d.ts.map +1 -0
  215. package/support/components/button.js +41 -0
  216. package/support/components/button.js.map +1 -0
  217. package/support/components/container.d.ts +14 -0
  218. package/support/components/container.d.ts.map +1 -0
  219. package/support/components/container.js +115 -0
  220. package/support/components/container.js.map +1 -0
  221. package/support/components/conversation-button-link.d.ts +34 -0
  222. package/support/components/conversation-button-link.d.ts.map +1 -0
  223. package/support/components/conversation-button-link.js +195 -0
  224. package/support/components/conversation-button-link.js.map +1 -0
  225. package/support/components/conversation-event.d.ts +14 -0
  226. package/support/components/conversation-event.d.ts.map +1 -0
  227. package/support/components/conversation-event.js +76 -0
  228. package/support/components/conversation-event.js.map +1 -0
  229. package/support/components/conversation-timeline.d.ts +17 -0
  230. package/support/components/conversation-timeline.d.ts.map +1 -0
  231. package/support/components/conversation-timeline.js +95 -0
  232. package/support/components/conversation-timeline.js.map +1 -0
  233. package/support/components/cossistant-branding.d.ts +12 -0
  234. package/support/components/cossistant-branding.d.ts.map +1 -0
  235. package/support/components/cossistant-branding.js +22 -0
  236. package/support/components/cossistant-branding.js.map +1 -0
  237. package/support/components/header.d.ts +11 -0
  238. package/support/components/header.d.ts.map +1 -0
  239. package/support/components/header.js +43 -0
  240. package/support/components/header.js.map +1 -0
  241. package/support/components/icons.d.ts +21 -0
  242. package/support/components/icons.d.ts.map +1 -0
  243. package/support/components/icons.js +131 -0
  244. package/support/components/icons.js.map +1 -0
  245. package/support/components/index.d.ts +11 -0
  246. package/support/components/index.js +12 -0
  247. package/support/components/multimodal-input.d.ts +28 -0
  248. package/support/components/multimodal-input.d.ts.map +1 -0
  249. package/support/components/multimodal-input.js +138 -0
  250. package/support/components/multimodal-input.js.map +1 -0
  251. package/support/components/navigation-tab.d.ts +7 -0
  252. package/support/components/navigation-tab.d.ts.map +1 -0
  253. package/support/components/navigation-tab.js +40 -0
  254. package/support/components/navigation-tab.js.map +1 -0
  255. package/support/components/support-content.d.ts +22 -0
  256. package/support/components/support-content.d.ts.map +1 -0
  257. package/support/components/support-content.js +50 -0
  258. package/support/components/support-content.js.map +1 -0
  259. package/support/components/text-effect.d.ts +49 -0
  260. package/support/components/text-effect.d.ts.map +1 -0
  261. package/support/components/text-effect.js +221 -0
  262. package/support/components/text-effect.js.map +1 -0
  263. package/support/components/timeline-message-group.d.ts +16 -0
  264. package/support/components/timeline-message-group.d.ts.map +1 -0
  265. package/support/components/timeline-message-group.js +117 -0
  266. package/support/components/timeline-message-group.js.map +1 -0
  267. package/support/components/timeline-message-item.d.ts +17 -0
  268. package/support/components/timeline-message-item.d.ts.map +1 -0
  269. package/support/components/timeline-message-item.js +42 -0
  270. package/support/components/timeline-message-item.js.map +1 -0
  271. package/support/components/typing-indicator.d.ts +26 -0
  272. package/support/components/typing-indicator.d.ts.map +1 -0
  273. package/support/components/typing-indicator.js +37 -0
  274. package/support/components/typing-indicator.js.map +1 -0
  275. package/support/components/watermark.d.ts +8 -0
  276. package/support/components/watermark.d.ts.map +1 -0
  277. package/support/components/watermark.js +34 -0
  278. package/support/components/watermark.js.map +1 -0
  279. package/support/context/config.d.ts +32 -0
  280. package/support/context/config.d.ts.map +1 -0
  281. package/support/context/config.js +27 -0
  282. package/support/context/config.js.map +1 -0
  283. package/support/context/websocket.d.ts +22 -0
  284. package/support/context/websocket.d.ts.map +1 -0
  285. package/support/context/websocket.js +113 -0
  286. package/support/context/websocket.js.map +1 -0
  287. package/support/index.d.ts +39 -0
  288. package/support/index.d.ts.map +1 -0
  289. package/support/index.js +43 -0
  290. package/support/index.js.map +1 -0
  291. package/support/pages/articles.d.ts +7 -0
  292. package/support/pages/articles.d.ts.map +1 -0
  293. package/support/pages/articles.js +39 -0
  294. package/support/pages/articles.js.map +1 -0
  295. package/support/pages/conversation-history.d.ts +18 -0
  296. package/support/pages/conversation-history.d.ts.map +1 -0
  297. package/support/pages/conversation-history.js +120 -0
  298. package/support/pages/conversation-history.js.map +1 -0
  299. package/support/pages/conversation.d.ts +32 -0
  300. package/support/pages/conversation.d.ts.map +1 -0
  301. package/support/pages/conversation.js +92 -0
  302. package/support/pages/conversation.js.map +1 -0
  303. package/support/pages/home.d.ts +20 -0
  304. package/support/pages/home.d.ts.map +1 -0
  305. package/support/pages/home.js +184 -0
  306. package/support/pages/home.js.map +1 -0
  307. package/support/router.d.ts +14 -0
  308. package/support/router.d.ts.map +1 -0
  309. package/support/router.js +31 -0
  310. package/support/router.js.map +1 -0
  311. package/support/store/index.d.ts +2 -0
  312. package/support/store/index.js +3 -0
  313. package/support/store/support-store.d.ts +42 -0
  314. package/support/store/support-store.d.ts.map +1 -0
  315. package/support/store/support-store.js +66 -0
  316. package/support/store/support-store.js.map +1 -0
  317. package/support/support-CMoDLQoC.css +408 -0
  318. package/support/support-CMoDLQoC.css.map +1 -0
  319. package/support/support.js +1 -0
  320. package/support/text/index.d.ts +35 -0
  321. package/support/text/index.d.ts.map +1 -0
  322. package/support/text/index.js +71 -0
  323. package/support/text/index.js.map +1 -0
  324. package/support/text/locales/en.d.ts +7 -0
  325. package/support/text/locales/en.d.ts.map +1 -0
  326. package/support/text/locales/en.js +65 -0
  327. package/support/text/locales/en.js.map +1 -0
  328. package/support/text/locales/es.d.ts +7 -0
  329. package/support/text/locales/es.d.ts.map +1 -0
  330. package/support/text/locales/es.js +64 -0
  331. package/support/text/locales/es.js.map +1 -0
  332. package/support/text/locales/fr.d.ts +7 -0
  333. package/support/text/locales/fr.d.ts.map +1 -0
  334. package/support/text/locales/fr.js +64 -0
  335. package/support/text/locales/fr.js.map +1 -0
  336. package/support/text/locales/keys.d.ts +216 -0
  337. package/support/text/locales/keys.d.ts.map +1 -0
  338. package/support/text/locales/keys.js +54 -0
  339. package/support/text/locales/keys.js.map +1 -0
  340. package/support/text/runtime.d.ts +17 -0
  341. package/support/text/runtime.d.ts.map +1 -0
  342. package/support/text/runtime.js +156 -0
  343. package/support/text/runtime.js.map +1 -0
  344. package/support/utils/index.d.ts +7 -0
  345. package/support/utils/index.d.ts.map +1 -0
  346. package/support/utils/index.js +11 -0
  347. package/support/utils/index.js.map +1 -0
  348. package/support/utils/time.d.ts +5 -0
  349. package/support/utils/time.d.ts.map +1 -0
  350. package/support/utils/time.js +28 -0
  351. package/support/utils/time.js.map +1 -0
  352. package/support-config.d.ts +20 -0
  353. package/support-config.d.ts.map +1 -0
  354. package/support-config.js +25 -0
  355. package/support-config.js.map +1 -0
  356. package/support.css +2 -0
  357. package/timeline-item.d.ts +133 -0
  358. package/timeline-item.d.ts.map +1 -0
  359. package/utils/id.d.ts +6 -0
  360. package/utils/id.d.ts.map +1 -0
  361. package/utils/id.js +13 -0
  362. package/utils/id.js.map +1 -0
  363. package/utils/index.d.ts +3 -0
  364. package/utils/index.js +4 -0
  365. package/utils/text.d.ts +5 -0
  366. package/utils/text.d.ts.map +1 -0
  367. package/utils/text.js +9 -0
  368. package/utils/text.js.map +1 -0
  369. package/utils/use-render-element.d.ts +22 -0
  370. package/utils/use-render-element.d.ts.map +1 -0
  371. package/utils/use-render-element.js +35 -0
  372. package/utils/use-render-element.js.map +1 -0
@@ -0,0 +1,31 @@
1
+ import * as React$1 from "react";
2
+
3
+ //#region src/primitives/window.d.ts
4
+ type WindowRenderProps = {
5
+ isOpen: boolean;
6
+ close: () => void;
7
+ };
8
+ type WindowProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
9
+ isOpen?: boolean;
10
+ onOpenChange?: (open: boolean) => void;
11
+ children?: React$1.ReactNode | ((props: WindowRenderProps) => React$1.ReactNode);
12
+ asChild?: boolean;
13
+ closeOnEscape?: boolean;
14
+ id?: string;
15
+ };
16
+ /**
17
+ * Host container for the support experience. Handles responsive mode, escape
18
+ * key dismissal and propagates render props so callers can take over the
19
+ * layout.
20
+ */
21
+ declare const SupportWindow: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
22
+ isOpen?: boolean;
23
+ onOpenChange?: (open: boolean) => void;
24
+ children?: React$1.ReactNode | ((props: WindowRenderProps) => React$1.ReactNode);
25
+ asChild?: boolean;
26
+ closeOnEscape?: boolean;
27
+ id?: string;
28
+ } & React$1.RefAttributes<HTMLDivElement>>;
29
+ //#endregion
30
+ export { SupportWindow, WindowProps, WindowRenderProps };
31
+ //# sourceMappingURL=window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window.d.ts","names":[],"sources":["../../src/primitives/window.tsx"],"sourcesContent":[],"mappings":";;;KAIY,iBAAA;;EAAA,KAAA,EAAA,GAAA,GAAA,IAAA;AAKZ,CAAA;AAAuB,KAAX,WAAA,GAAc,IAAH,CACtB,OAAA,CAAM,cADgB,CACD,cADC,CAAA,EAAA,UAAA,CAAA,GAAA;QACD,CAAA,EAAA,OAAA;cAAf,CAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GAAA,IAAA;UADmB,CAAA,EAMd,OAAA,CAAM,SANQ,GAAA,CAAA,CAAA,KAAA,EAMa,iBANb,EAAA,GAMmC,OAAA,CAAM,SANzC,CAAA;SAMd,CAAA,EAAA,OAAM;eAAqB,CAAA,EAAA,OAAA;KAAsB,EAAA,MAAM;CAAS;AAW5E;;;;;AAXY,cAWC,aAXK,EAWQ,OAAA,CAAA,yBAXR,CAWQ,IAXR,CAWQ,OAAA,CAAA,cAXR,CAWQ,cAXR,CAAA,EAAA,UAAA,CAAA,GAAA;QAAqB,CAAA,EAAA,OAAA;cAA4B,CAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GAAA,IAAA;aAAvD,OAAA,CAAM,qBAAqB,sBAAsB,OAAA,CAAM;;eAWzC,CAAA,EAAA,OAAA;EAAA,EAAA,CAAA,EAAA,MAAA"}
@@ -0,0 +1,58 @@
1
+ import { useRenderElement } from "../utils/use-render-element.js";
2
+ import { useSupportConfig } from "../support/context/config.js";
3
+ import * as React$1 from "react";
4
+
5
+ //#region src/primitives/window.tsx
6
+ /**
7
+ * Host container for the support experience. Handles responsive mode, escape
8
+ * key dismissal and propagates render props so callers can take over the
9
+ * layout.
10
+ */
11
+ const SupportWindow = (() => {
12
+ const Component = React$1.forwardRef(({ isOpen: isOpenProp, onOpenChange, children, className, asChild = false, closeOnEscape = true, id = "cossistant-window",...props }, ref) => {
13
+ const { isOpen, close, mode } = useSupportConfig();
14
+ const open = mode === "responsive" ? true : isOpenProp ?? isOpen ?? false;
15
+ const closeFn = React$1.useCallback(() => {
16
+ if (onOpenChange) onOpenChange(false);
17
+ else if (close) close();
18
+ }, [onOpenChange, close]);
19
+ React$1.useEffect(() => {
20
+ if (!(open && closeOnEscape)) return;
21
+ const onKey = (e) => {
22
+ if (e.key === "Escape") close();
23
+ };
24
+ window.addEventListener("keydown", onKey);
25
+ return () => window.removeEventListener("keydown", onKey);
26
+ }, [
27
+ open,
28
+ close,
29
+ closeOnEscape
30
+ ]);
31
+ const renderProps = {
32
+ isOpen: open,
33
+ close: closeFn
34
+ };
35
+ const content = typeof children === "function" ? children(renderProps) : children;
36
+ return useRenderElement("div", {
37
+ className,
38
+ asChild
39
+ }, {
40
+ ref,
41
+ state: renderProps,
42
+ props: {
43
+ role: "dialog",
44
+ "aria-modal": "true",
45
+ id,
46
+ ...props,
47
+ children: content
48
+ },
49
+ enabled: open
50
+ });
51
+ });
52
+ Component.displayName = "SupportWindow";
53
+ return Component;
54
+ })();
55
+
56
+ //#endregion
57
+ export { SupportWindow };
58
+ //# sourceMappingURL=window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window.js","names":["React","renderProps: WindowRenderProps"],"sources":["../../src/primitives/window.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useSupportConfig } from \"../support/context/config\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\nexport type WindowRenderProps = {\n\tisOpen: boolean;\n\tclose: () => void;\n};\n\nexport type WindowProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tisOpen?: boolean;\n\tonOpenChange?: (open: boolean) => void;\n\tchildren?: React.ReactNode | ((props: WindowRenderProps) => React.ReactNode);\n\tasChild?: boolean;\n\tcloseOnEscape?: boolean;\n\tid?: string;\n};\n\n/**\n * Host container for the support experience. Handles responsive mode, escape\n * key dismissal and propagates render props so callers can take over the\n * layout.\n */\nexport const SupportWindow = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, WindowProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tisOpen: isOpenProp,\n\t\t\t\tonOpenChange,\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tcloseOnEscape = true,\n\t\t\t\tid = \"cossistant-window\",\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst { isOpen, close, mode } = useSupportConfig();\n\n\t\t\t// In responsive mode, window is always open\n\t\t\t// Otherwise use normal open/close logic\n\t\t\tconst open =\n\t\t\t\tmode === \"responsive\" ? true : (isOpenProp ?? isOpen ?? false);\n\n\t\t\tconst closeFn = React.useCallback(() => {\n\t\t\t\tif (onOpenChange) {\n\t\t\t\t\tonOpenChange(false);\n\t\t\t\t} else if (close) {\n\t\t\t\t\tclose();\n\t\t\t\t}\n\t\t\t}, [onOpenChange, close]);\n\n\t\t\t// Close on Escape\n\t\t\tReact.useEffect(() => {\n\t\t\t\tif (!(open && closeOnEscape)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst onKey = (e: KeyboardEvent) => {\n\t\t\t\t\tif (e.key === \"Escape\") {\n\t\t\t\t\t\tclose();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.addEventListener(\"keydown\", onKey);\n\t\t\t\treturn () => window.removeEventListener(\"keydown\", onKey);\n\t\t\t}, [open, close, closeOnEscape]);\n\n\t\t\tconst renderProps: WindowRenderProps = { isOpen: open, close: closeFn };\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\" ? children(renderProps) : children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tstate: renderProps,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\trole: \"dialog\",\n\t\t\t\t\t\t\"aria-modal\": \"true\",\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t\tenabled: open,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"SupportWindow\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;AA0BA,MAAa,uBAAuB;CACnC,MAAM,YAAYA,QAAM,YAEtB,EACC,QAAQ,YACR,cACA,UACA,WACA,UAAU,OACV,gBAAgB,MAChB,KAAK,oBACL,GAAG,SAEJ,QACI;EACJ,MAAM,EAAE,QAAQ,OAAO,SAAS,kBAAkB;EAIlD,MAAM,OACL,SAAS,eAAe,OAAQ,cAAc,UAAU;EAEzD,MAAM,UAAUA,QAAM,kBAAkB;AACvC,OAAI,aACH,cAAa,MAAM;YACT,MACV,QAAO;KAEN,CAAC,cAAc,MAAM,CAAC;AAGzB,UAAM,gBAAgB;AACrB,OAAI,EAAE,QAAQ,eACb;GAED,MAAM,SAAS,MAAqB;AACnC,QAAI,EAAE,QAAQ,SACb,QAAO;;AAGT,UAAO,iBAAiB,WAAW,MAAM;AACzC,gBAAa,OAAO,oBAAoB,WAAW,MAAM;KACvD;GAAC;GAAM;GAAO;GAAc,CAAC;EAEhC,MAAMC,cAAiC;GAAE,QAAQ;GAAM,OAAO;GAAS;EAEvE,MAAM,UACL,OAAO,aAAa,aAAa,SAAS,YAAY,GAAG;AAE1D,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;GACP,OAAO;IACN,MAAM;IACN,cAAc;IACd;IACA,GAAG;IACH,UAAU;IACV;GACD,SAAS;GACT,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
package/provider.d.ts ADDED
@@ -0,0 +1,95 @@
1
+ import * as React$1 from "react";
2
+ import { CossistantClient } from "@cossistant/core";
3
+ import { DefaultMessage, PublicWebsiteResponse } from "@cossistant/types";
4
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
5
+ import { QueryClient } from "@tanstack/react-query";
6
+
7
+ //#region src/provider.d.ts
8
+ type SupportProviderProps = {
9
+ children: React$1.ReactNode;
10
+ defaultOpen?: boolean;
11
+ apiUrl?: string;
12
+ wsUrl?: string;
13
+ publicKey?: string;
14
+ defaultMessages?: DefaultMessage[];
15
+ quickOptions?: string[];
16
+ autoConnect?: boolean;
17
+ onWsConnect?: () => void;
18
+ onWsDisconnect?: () => void;
19
+ onWsError?: (error: Error) => void;
20
+ queryClient?: QueryClient;
21
+ };
22
+ type CossistantProviderProps = SupportProviderProps;
23
+ type CossistantContextValue = {
24
+ website: PublicWebsiteResponse | null;
25
+ defaultMessages: DefaultMessage[];
26
+ quickOptions: string[];
27
+ setDefaultMessages: (messages: DefaultMessage[]) => void;
28
+ setQuickOptions: (options: string[]) => void;
29
+ unreadCount: number;
30
+ setUnreadCount: (count: number) => void;
31
+ isLoading: boolean;
32
+ error: Error | null;
33
+ client: CossistantClient;
34
+ };
35
+ /**
36
+ * Hosts the entire customer support widget ecosystem by handing out context
37
+ * about the current website, visitor, unread counts, realtime subscriptions
38
+ * and the REST client. Provide your Cossistant public key plus optional
39
+ * defaults to configure the widget behaviour.
40
+ */
41
+ declare function SupportProvider({
42
+ children,
43
+ apiUrl,
44
+ wsUrl,
45
+ publicKey,
46
+ defaultMessages,
47
+ quickOptions,
48
+ autoConnect,
49
+ onWsConnect,
50
+ onWsDisconnect,
51
+ onWsError,
52
+ queryClient
53
+ }: SupportProviderProps): react_jsx_runtime2.JSX.Element;
54
+ /**
55
+ * Convenience hook that exposes the aggregated support context. Throws when it
56
+ * is consumed outside of `SupportProvider` to catch integration mistakes.
57
+ */
58
+ declare function useSupport(): {
59
+ availableHumanAgents: {
60
+ id: string;
61
+ name: string;
62
+ image: string | null;
63
+ lastSeenAt: string | null;
64
+ }[];
65
+ availableAIAgents: {
66
+ id: string;
67
+ name: string;
68
+ image: string | null;
69
+ }[];
70
+ visitor: {
71
+ locale: string | null;
72
+ id: string;
73
+ isBlocked: boolean;
74
+ language: string | null;
75
+ contact: {
76
+ id: string;
77
+ name: string | null;
78
+ email: string | null;
79
+ image: string | null;
80
+ } | null;
81
+ } | undefined;
82
+ website: PublicWebsiteResponse | null;
83
+ defaultMessages: DefaultMessage[];
84
+ quickOptions: string[];
85
+ setDefaultMessages: (messages: DefaultMessage[]) => void;
86
+ setQuickOptions: (options: string[]) => void;
87
+ unreadCount: number;
88
+ setUnreadCount: (count: number) => void;
89
+ isLoading: boolean;
90
+ error: Error | null;
91
+ client: CossistantClient;
92
+ };
93
+ //#endregion
94
+ export { CossistantContextValue, CossistantProviderProps, SupportProvider, SupportProviderProps, useSupport };
95
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","names":[],"sources":["../src/provider.tsx"],"sourcesContent":[],"mappings":";;;;;;;KASY,oBAAA;YACD,OAAA,CAAM;;EADL,MAAA,CAAA,EAAA,MAAA;EAAoB,KAAA,CAAA,EAAA,MAAA;WACrB,CAAA,EAAM,MAAA;iBAKE,CAAA,EAAA,cAAA,EAAA;cAKE,CAAA,EAAA,MAAA,EAAA;aACN,CAAA,EAAA,OAAA;EAAW,WAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EAGd,cAAA,CAAA,EAAA,GAAA,GAAA,IAAuB;EAEvB,SAAA,CAAA,EAAA,CAAA,KAAA,EANS,KAMa,EAAA,GAAA,IAAA;EAAA,WAAA,CAAA,EALnB,WAKmB;;AAEhB,KAJN,uBAAA,GAA0B,oBAIpB;AAEc,KAJpB,sBAAA,GAIoB;SAKxB,EARE,qBAQF,GAAA,IAAA;iBACC,EARS,cAQT,EAAA;EAAgB,YAAA,EAAA,MAAA,EAAA;EA+HT,kBAAe,EAAA,CAAA,QAAA,EArIC,cAqID,EAAA,EAAA,GAAA,IAAA;EAAA,eAAA,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,EAAA,GAAA,IAAA;aAC9B,EAAA,MAAA;gBACA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;WACA,EAAA,OAAA;OACA,EApIO,KAoIP,GAAA,IAAA;QACA,EApIQ,gBAoIR;;;;;;;;AAOsB,iBAZP,eAAA,CAYO;EAAA,QAAA;EAAA,MAAA;EAAA,KAAA;EAAA,SAAA;EAAA,eAAA;EAAA,YAAA;EAAA,WAAA;EAAA,WAAA;EAAA,cAAA;EAAA,SAAA;EAAA;AAAA,CAAA,EAApB,oBAAoB,CAAA,EAAA,kBAAA,CAAA,GAAA,CAAA,OAAA;;AAuCvB;;;AA1LkB,iBA0LF,UAAA,CAAA,CA1LE,EAAA;sBAEc,EAAA;IAKxB,EAAA,EAAA,MAAA;IACC,IAAA,EAAA,MAAA;IAAgB,KAAA,EAAA,MAAA,GAAA,IAAA;;;;;;;;;;;;;;;;;;;;WATf;mBACQ;;iCAEc;;;;;SAKxB;UACC"}
package/provider.js ADDED
@@ -0,0 +1,124 @@
1
+ import { QueryClient } from "./node_modules/@tanstack/query-core/build/modern/queryClient.js";
2
+ import { QueryClientProvider } from "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js";
3
+ import { useWebsiteStore } from "./hooks/private/store/use-website-store.js";
4
+ import { useClient } from "./hooks/private/use-rest-client.js";
5
+ import { WebSocketProvider } from "./support/context/websocket.js";
6
+ import * as React$1 from "react";
7
+ import { normalizeLocale } from "@cossistant/core";
8
+ import { jsx } from "react/jsx-runtime";
9
+
10
+ //#region src/provider.tsx
11
+ const SupportContext = React$1.createContext(void 0);
12
+ /**
13
+ * Internal implementation that wires the React Query cache, REST client and
14
+ * websocket provider together before exposing the combined context.
15
+ */
16
+ function SupportProviderInner({ children, apiUrl, wsUrl, publicKey, defaultMessages, quickOptions, autoConnect, onWsConnect, onWsDisconnect, onWsError }) {
17
+ const [unreadCount, setUnreadCount] = React$1.useState(0);
18
+ const [_defaultMessages, _setDefaultMessages] = React$1.useState(defaultMessages || []);
19
+ const [_quickOptions, _setQuickOptions] = React$1.useState(quickOptions || []);
20
+ React$1.useEffect(() => {
21
+ if (defaultMessages && defaultMessages.length > 0) _setDefaultMessages(defaultMessages);
22
+ }, [defaultMessages]);
23
+ React$1.useEffect(() => {
24
+ if (quickOptions && quickOptions.length > 0) _setQuickOptions(quickOptions);
25
+ }, [quickOptions]);
26
+ const { client } = useClient(publicKey, apiUrl, wsUrl);
27
+ const { website, isLoading, error: websiteError } = useWebsiteStore(client);
28
+ const error = websiteError;
29
+ React$1.useEffect(() => {
30
+ if (website) client.restClient?.setWebsiteContext?.(website.id, website.visitor?.id);
31
+ }, [client, website]);
32
+ const setDefaultMessages = React$1.useCallback((messages) => _setDefaultMessages(messages), []);
33
+ const setQuickOptions = React$1.useCallback((options) => _setQuickOptions(options), []);
34
+ const setUnreadCountStable = React$1.useCallback((count) => setUnreadCount(count), []);
35
+ const value = React$1.useMemo(() => ({
36
+ website,
37
+ unreadCount,
38
+ setUnreadCount: setUnreadCountStable,
39
+ isLoading,
40
+ error,
41
+ client,
42
+ defaultMessages: _defaultMessages,
43
+ setDefaultMessages,
44
+ quickOptions: _quickOptions,
45
+ setQuickOptions
46
+ }), [
47
+ website,
48
+ unreadCount,
49
+ isLoading,
50
+ error,
51
+ client,
52
+ _defaultMessages,
53
+ _quickOptions,
54
+ setDefaultMessages,
55
+ setQuickOptions,
56
+ setUnreadCountStable
57
+ ]);
58
+ return /* @__PURE__ */ jsx(SupportContext.Provider, {
59
+ value,
60
+ children: /* @__PURE__ */ jsx(WebSocketProvider, {
61
+ autoConnect,
62
+ onConnect: onWsConnect,
63
+ onDisconnect: onWsDisconnect,
64
+ onError: onWsError,
65
+ publicKey,
66
+ visitorId: website?.visitor?.id,
67
+ websiteId: website?.id,
68
+ wsUrl,
69
+ children
70
+ })
71
+ });
72
+ }
73
+ /**
74
+ * Hosts the entire customer support widget ecosystem by handing out context
75
+ * about the current website, visitor, unread counts, realtime subscriptions
76
+ * and the REST client. Provide your Cossistant public key plus optional
77
+ * defaults to configure the widget behaviour.
78
+ */
79
+ function SupportProvider({ children, apiUrl = "https://api.cossistant.com/v1", wsUrl = "wss://api.cossistant.com/ws", publicKey, defaultMessages, quickOptions, autoConnect = true, onWsConnect, onWsDisconnect, onWsError, queryClient }) {
80
+ const [defaultQueryClient] = React$1.useState(() => new QueryClient({ defaultOptions: { queries: {
81
+ staleTime: 300 * 1e3,
82
+ gcTime: 600 * 1e3
83
+ } } }));
84
+ return /* @__PURE__ */ jsx(QueryClientProvider, {
85
+ client: queryClient || defaultQueryClient,
86
+ children: /* @__PURE__ */ jsx(SupportProviderInner, {
87
+ apiUrl,
88
+ autoConnect,
89
+ defaultMessages,
90
+ onWsConnect,
91
+ onWsDisconnect,
92
+ onWsError,
93
+ publicKey,
94
+ quickOptions,
95
+ wsUrl,
96
+ children
97
+ })
98
+ });
99
+ }
100
+ /**
101
+ * Convenience hook that exposes the aggregated support context. Throws when it
102
+ * is consumed outside of `SupportProvider` to catch integration mistakes.
103
+ */
104
+ function useSupport() {
105
+ const context = React$1.useContext(SupportContext);
106
+ if (!context) throw new Error("useSupport must be used within a cossistant SupportProvider");
107
+ const availableHumanAgents = context.website?.availableHumanAgents || [];
108
+ const availableAIAgents = context.website?.availableAIAgents || [];
109
+ const visitorLanguage = context.website?.visitor?.language || null;
110
+ const visitor = context.website?.visitor ? {
111
+ ...context.website.visitor,
112
+ locale: normalizeLocale(visitorLanguage)
113
+ } : void 0;
114
+ return {
115
+ ...context,
116
+ availableHumanAgents,
117
+ availableAIAgents,
118
+ visitor
119
+ };
120
+ }
121
+
122
+ //#endregion
123
+ export { SupportProvider, useSupport };
124
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","names":["React"],"sources":["../src/provider.tsx"],"sourcesContent":["import type { CossistantClient } from \"@cossistant/core\";\nimport { normalizeLocale } from \"@cossistant/core\";\nimport type { DefaultMessage, PublicWebsiteResponse } from \"@cossistant/types\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport * as React from \"react\";\nimport { useWebsiteStore } from \"./hooks/private/store/use-website-store\";\nimport { useClient } from \"./hooks/private/use-rest-client\";\nimport { WebSocketProvider } from \"./support\";\n\nexport type SupportProviderProps = {\n\tchildren: React.ReactNode;\n\tdefaultOpen?: boolean;\n\tapiUrl?: string;\n\twsUrl?: string;\n\tpublicKey?: string;\n\tdefaultMessages?: DefaultMessage[];\n\tquickOptions?: string[];\n\tautoConnect?: boolean;\n\tonWsConnect?: () => void;\n\tonWsDisconnect?: () => void;\n\tonWsError?: (error: Error) => void;\n\tqueryClient?: QueryClient;\n};\n\nexport type CossistantProviderProps = SupportProviderProps;\n\nexport type CossistantContextValue = {\n\twebsite: PublicWebsiteResponse | null;\n\tdefaultMessages: DefaultMessage[];\n\tquickOptions: string[];\n\tsetDefaultMessages: (messages: DefaultMessage[]) => void;\n\tsetQuickOptions: (options: string[]) => void;\n\tunreadCount: number;\n\tsetUnreadCount: (count: number) => void;\n\tisLoading: boolean;\n\terror: Error | null;\n\tclient: CossistantClient;\n};\n\nconst SupportContext = React.createContext<CossistantContextValue | undefined>(\n\tundefined\n);\n\n/**\n * Internal implementation that wires the React Query cache, REST client and\n * websocket provider together before exposing the combined context.\n */\nfunction SupportProviderInner({\n\tchildren,\n\tapiUrl,\n\twsUrl,\n\tpublicKey,\n\tdefaultMessages,\n\tquickOptions,\n\tautoConnect,\n\tonWsConnect,\n\tonWsDisconnect,\n\tonWsError,\n}: SupportProviderProps) {\n\tconst [unreadCount, setUnreadCount] = React.useState(0);\n\tconst [_defaultMessages, _setDefaultMessages] = React.useState<\n\t\tDefaultMessage[]\n\t>(defaultMessages || []);\n\tconst [_quickOptions, _setQuickOptions] = React.useState<string[]>(\n\t\tquickOptions || []\n\t);\n\t// Update state when props change (for initial values from provider)\n\tReact.useEffect(() => {\n\t\tif (defaultMessages && defaultMessages.length > 0) {\n\t\t\t_setDefaultMessages(defaultMessages);\n\t\t}\n\t}, [defaultMessages]);\n\n\tReact.useEffect(() => {\n\t\tif (quickOptions && quickOptions.length > 0) {\n\t\t\t_setQuickOptions(quickOptions);\n\t\t}\n\t}, [quickOptions]);\n\n\tconst { client } = useClient(publicKey, apiUrl, wsUrl);\n\tconst { website, isLoading, error: websiteError } = useWebsiteStore(client);\n\n\t// Prefetch conversations\n\t// useConversations(client, {\n\t// enabled: !!website && !!website.visitor && isClientPrimed,\n\t// });\n\n\tconst error = websiteError;\n\n\t// Prime REST client with website/visitor context so headers are sent reliably\n\tReact.useEffect(() => {\n\t\tif (website) {\n\t\t\t// @ts-expect-error internal priming: safe in our library context\n\t\t\tclient.restClient?.setWebsiteContext?.(website.id, website.visitor?.id);\n\t\t}\n\t}, [client, website]);\n\n\tconst setDefaultMessages = React.useCallback(\n\t\t(messages: DefaultMessage[]) => _setDefaultMessages(messages),\n\t\t[]\n\t);\n\n\tconst setQuickOptions = React.useCallback(\n\t\t(options: string[]) => _setQuickOptions(options),\n\t\t[]\n\t);\n\n\tconst setUnreadCountStable = React.useCallback(\n\t\t(count: number) => setUnreadCount(count),\n\t\t[]\n\t);\n\n\tconst value = React.useMemo<CossistantContextValue>(\n\t\t() => ({\n\t\t\twebsite,\n\t\t\tunreadCount,\n\t\t\tsetUnreadCount: setUnreadCountStable,\n\t\t\tisLoading,\n\t\t\terror,\n\t\t\tclient,\n\t\t\tdefaultMessages: _defaultMessages,\n\t\t\tsetDefaultMessages,\n\t\t\tquickOptions: _quickOptions,\n\t\t\tsetQuickOptions,\n\t\t}),\n\t\t[\n\t\t\twebsite,\n\t\t\tunreadCount,\n\t\t\tisLoading,\n\t\t\terror,\n\t\t\tclient,\n\t\t\t_defaultMessages,\n\t\t\t_quickOptions,\n\t\t\tsetDefaultMessages,\n\t\t\tsetQuickOptions,\n\t\t\tsetUnreadCountStable,\n\t\t]\n\t);\n\n\treturn (\n\t\t<SupportContext.Provider value={value}>\n\t\t\t<WebSocketProvider\n\t\t\t\tautoConnect={autoConnect}\n\t\t\t\tonConnect={onWsConnect}\n\t\t\t\tonDisconnect={onWsDisconnect}\n\t\t\t\tonError={onWsError}\n\t\t\t\tpublicKey={publicKey}\n\t\t\t\tvisitorId={website?.visitor?.id}\n\t\t\t\twebsiteId={website?.id}\n\t\t\t\twsUrl={wsUrl}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</WebSocketProvider>\n\t\t</SupportContext.Provider>\n\t);\n}\n\n/**\n * Hosts the entire customer support widget ecosystem by handing out context\n * about the current website, visitor, unread counts, realtime subscriptions\n * and the REST client. Provide your Cossistant public key plus optional\n * defaults to configure the widget behaviour.\n */\nexport function SupportProvider({\n\tchildren,\n\tapiUrl = \"https://api.cossistant.com/v1\",\n\twsUrl = \"wss://api.cossistant.com/ws\",\n\tpublicKey,\n\tdefaultMessages,\n\tquickOptions,\n\tautoConnect = true,\n\tonWsConnect,\n\tonWsDisconnect,\n\tonWsError,\n\tqueryClient,\n}: SupportProviderProps) {\n\t// Create a default QueryClient if none provided\n\tconst [defaultQueryClient] = React.useState(\n\t\t() =>\n\t\t\tnew QueryClient({\n\t\t\t\tdefaultOptions: {\n\t\t\t\t\tqueries: {\n\t\t\t\t\t\tstaleTime: 5 * 60 * 1000, // 5 minutes\n\t\t\t\t\t\tgcTime: 10 * 60 * 1000, // 10 minutes\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t})\n\t);\n\n\tconst activeQueryClient = queryClient || defaultQueryClient;\n\n\treturn (\n\t\t<QueryClientProvider client={activeQueryClient}>\n\t\t\t<SupportProviderInner\n\t\t\t\tapiUrl={apiUrl}\n\t\t\t\tautoConnect={autoConnect}\n\t\t\t\tdefaultMessages={defaultMessages}\n\t\t\t\tonWsConnect={onWsConnect}\n\t\t\t\tonWsDisconnect={onWsDisconnect}\n\t\t\t\tonWsError={onWsError}\n\t\t\t\tpublicKey={publicKey}\n\t\t\t\tquickOptions={quickOptions}\n\t\t\t\twsUrl={wsUrl}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</SupportProviderInner>\n\t\t</QueryClientProvider>\n\t);\n}\n\n/**\n * Convenience hook that exposes the aggregated support context. Throws when it\n * is consumed outside of `SupportProvider` to catch integration mistakes.\n */\nexport function useSupport() {\n\tconst context = React.useContext(SupportContext);\n\tif (!context) {\n\t\tthrow new Error(\n\t\t\t\"useSupport must be used within a cossistant SupportProvider\"\n\t\t);\n\t}\n\n\tconst availableHumanAgents = context.website?.availableHumanAgents || [];\n\tconst availableAIAgents = context.website?.availableAIAgents || [];\n\tconst visitorLanguage = context.website?.visitor?.language || null;\n\n\t// Create visitor object with normalized locale\n\tconst visitor = context.website?.visitor\n\t\t? {\n\t\t\t\t...context.website.visitor,\n\t\t\t\tlocale: normalizeLocale(visitorLanguage),\n\t\t\t}\n\t\t: undefined;\n\n\treturn {\n\t\t...context,\n\t\tavailableHumanAgents,\n\t\tavailableAIAgents,\n\t\tvisitor,\n\t};\n}\n"],"mappings":";;;;;;;;;;AAuCA,MAAM,iBAAiBA,QAAM,cAC5B,OACA;;;;;AAMD,SAAS,qBAAqB,EAC7B,UACA,QACA,OACA,WACA,iBACA,cACA,aACA,aACA,gBACA,aACwB;CACxB,MAAM,CAAC,aAAa,kBAAkBA,QAAM,SAAS,EAAE;CACvD,MAAM,CAAC,kBAAkB,uBAAuBA,QAAM,SAEpD,mBAAmB,EAAE,CAAC;CACxB,MAAM,CAAC,eAAe,oBAAoBA,QAAM,SAC/C,gBAAgB,EAAE,CAClB;AAED,SAAM,gBAAgB;AACrB,MAAI,mBAAmB,gBAAgB,SAAS,EAC/C,qBAAoB,gBAAgB;IAEnC,CAAC,gBAAgB,CAAC;AAErB,SAAM,gBAAgB;AACrB,MAAI,gBAAgB,aAAa,SAAS,EACzC,kBAAiB,aAAa;IAE7B,CAAC,aAAa,CAAC;CAElB,MAAM,EAAE,WAAW,UAAU,WAAW,QAAQ,MAAM;CACtD,MAAM,EAAE,SAAS,WAAW,OAAO,iBAAiB,gBAAgB,OAAO;CAO3E,MAAM,QAAQ;AAGd,SAAM,gBAAgB;AACrB,MAAI,QAEH,QAAO,YAAY,oBAAoB,QAAQ,IAAI,QAAQ,SAAS,GAAG;IAEtE,CAAC,QAAQ,QAAQ,CAAC;CAErB,MAAM,qBAAqBA,QAAM,aAC/B,aAA+B,oBAAoB,SAAS,EAC7D,EAAE,CACF;CAED,MAAM,kBAAkBA,QAAM,aAC5B,YAAsB,iBAAiB,QAAQ,EAChD,EAAE,CACF;CAED,MAAM,uBAAuBA,QAAM,aACjC,UAAkB,eAAe,MAAM,EACxC,EAAE,CACF;CAED,MAAM,QAAQA,QAAM,eACZ;EACN;EACA;EACA,gBAAgB;EAChB;EACA;EACA;EACA,iBAAiB;EACjB;EACA,cAAc;EACd;EACA,GACD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,CACD;AAED,QACC,oBAAC,eAAe;EAAgB;YAC/B,oBAAC;GACa;GACb,WAAW;GACX,cAAc;GACd,SAAS;GACE;GACX,WAAW,SAAS,SAAS;GAC7B,WAAW,SAAS;GACb;GAEN;IACkB;GACK;;;;;;;;AAU5B,SAAgB,gBAAgB,EAC/B,UACA,SAAS,iCACT,QAAQ,+BACR,WACA,iBACA,cACA,cAAc,MACd,aACA,gBACA,WACA,eACwB;CAExB,MAAM,CAAC,sBAAsBA,QAAM,eAEjC,IAAI,YAAY,EACf,gBAAgB,EACf,SAAS;EACR,WAAW,MAAS;EACpB,QAAQ,MAAU;EAClB,EACD,EACD,CAAC,CACH;AAID,QACC,oBAAC;EAAoB,QAHI,eAAe;YAIvC,oBAAC;GACQ;GACK;GACI;GACJ;GACG;GACL;GACA;GACG;GACP;GAEN;IACqB;GACF;;;;;;AAQxB,SAAgB,aAAa;CAC5B,MAAM,UAAUA,QAAM,WAAW,eAAe;AAChD,KAAI,CAAC,QACJ,OAAM,IAAI,MACT,8DACA;CAGF,MAAM,uBAAuB,QAAQ,SAAS,wBAAwB,EAAE;CACxE,MAAM,oBAAoB,QAAQ,SAAS,qBAAqB,EAAE;CAClE,MAAM,kBAAkB,QAAQ,SAAS,SAAS,YAAY;CAG9D,MAAM,UAAU,QAAQ,SAAS,UAC9B;EACA,GAAG,QAAQ,QAAQ;EACnB,QAAQ,gBAAgB,gBAAgB;EACxC,GACA;AAEH,QAAO;EACN,GAAG;EACH;EACA;EACA;EACA"}
@@ -0,0 +1,8 @@
1
+ import { AnyRealtimeEvent } from "../realtime-events.js";
2
+
3
+ //#region src/realtime/event-filter.d.ts
4
+ declare function getTargetVisitorId(event: AnyRealtimeEvent): string | null;
5
+ declare function shouldDeliverEvent(event: AnyRealtimeEvent, websiteId: string | null, visitorId: string | null): boolean;
6
+ //#endregion
7
+ export { getTargetVisitorId, shouldDeliverEvent };
8
+ //# sourceMappingURL=event-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-filter.d.ts","names":[],"sources":["../../src/realtime/event-filter.ts"],"sourcesContent":[],"mappings":";;;iBAES,kBAAA,QAA0B;iBAkBnB,kBAAA,QACR"}
@@ -0,0 +1,21 @@
1
+ //#region src/realtime/event-filter.ts
2
+ function getTargetVisitorId(event) {
3
+ const payloadVisitorId = event.payload.visitorId;
4
+ if (typeof payloadVisitorId === "string" && payloadVisitorId.length > 0) return payloadVisitorId;
5
+ if (event.type === "timelineItemCreated") {
6
+ const itemVisitorId = event.payload.item.visitorId;
7
+ if (typeof itemVisitorId === "string" && itemVisitorId.length > 0) return itemVisitorId;
8
+ }
9
+ return null;
10
+ }
11
+ function shouldDeliverEvent(event, websiteId, visitorId) {
12
+ if (websiteId && event.payload.websiteId !== websiteId) return false;
13
+ if (!visitorId) return true;
14
+ const targetVisitorId = getTargetVisitorId(event);
15
+ if (targetVisitorId && targetVisitorId !== visitorId) return false;
16
+ return true;
17
+ }
18
+
19
+ //#endregion
20
+ export { getTargetVisitorId, shouldDeliverEvent };
21
+ //# sourceMappingURL=event-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-filter.js","names":[],"sources":["../../src/realtime/event-filter.ts"],"sourcesContent":["import type { AnyRealtimeEvent } from \"@cossistant/types/realtime-events\";\n\nfunction getTargetVisitorId(event: AnyRealtimeEvent): string | null {\n\tconst payloadVisitorId = event.payload.visitorId;\n\n\tif (typeof payloadVisitorId === \"string\" && payloadVisitorId.length > 0) {\n\t\treturn payloadVisitorId;\n\t}\n\n\tif (event.type === \"timelineItemCreated\") {\n\t\tconst itemVisitorId = event.payload.item.visitorId;\n\n\t\tif (typeof itemVisitorId === \"string\" && itemVisitorId.length > 0) {\n\t\t\treturn itemVisitorId;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function shouldDeliverEvent(\n\tevent: AnyRealtimeEvent,\n\twebsiteId: string | null,\n\tvisitorId: string | null\n): boolean {\n\tif (websiteId && event.payload.websiteId !== websiteId) {\n\t\treturn false;\n\t}\n\n\tif (!visitorId) {\n\t\treturn true;\n\t}\n\n\tconst targetVisitorId = getTargetVisitorId(event);\n\n\tif (targetVisitorId && targetVisitorId !== visitorId) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nexport { getTargetVisitorId };\n"],"mappings":";AAEA,SAAS,mBAAmB,OAAwC;CACnE,MAAM,mBAAmB,MAAM,QAAQ;AAEvC,KAAI,OAAO,qBAAqB,YAAY,iBAAiB,SAAS,EACrE,QAAO;AAGR,KAAI,MAAM,SAAS,uBAAuB;EACzC,MAAM,gBAAgB,MAAM,QAAQ,KAAK;AAEzC,MAAI,OAAO,kBAAkB,YAAY,cAAc,SAAS,EAC/D,QAAO;;AAIT,QAAO;;AAGR,SAAgB,mBACf,OACA,WACA,WACU;AACV,KAAI,aAAa,MAAM,QAAQ,cAAc,UAC5C,QAAO;AAGR,KAAI,CAAC,UACJ,QAAO;CAGR,MAAM,kBAAkB,mBAAmB,MAAM;AAEjD,KAAI,mBAAmB,oBAAoB,UAC1C,QAAO;AAGR,QAAO"}
@@ -0,0 +1,6 @@
1
+ import { RealtimeAuthConfig, RealtimeContextValue, RealtimeProvider, RealtimeProviderProps, useRealtimeConnection } from "./provider.js";
2
+ import { applyConversationSeenEvent, hydrateConversationSeen, upsertConversationSeen } from "./seen-store.js";
3
+ import { SupportRealtimeProvider } from "./support-provider.js";
4
+ import { applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, setTypingState } from "./typing-store.js";
5
+ import { RealtimeEventHandler, RealtimeEventHandlerEntry, RealtimeEventHandlersMap, RealtimeEventMeta, useRealtime } from "./use-realtime.js";
6
+ export { type RealtimeAuthConfig, type RealtimeContextValue, type RealtimeEventHandler, type RealtimeEventHandlerEntry, type RealtimeEventHandlersMap, type RealtimeEventMeta, RealtimeProvider, type RealtimeProviderProps, SupportRealtimeProvider, applyConversationSeenEvent, applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, hydrateConversationSeen, setTypingState, upsertConversationSeen, useRealtime, useRealtimeConnection };
@@ -0,0 +1,7 @@
1
+ import { RealtimeProvider, useRealtimeConnection } from "./provider.js";
2
+ import { applyConversationSeenEvent, hydrateConversationSeen, upsertConversationSeen } from "./seen-store.js";
3
+ import { applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, setTypingState } from "./typing-store.js";
4
+ import { useRealtime } from "./use-realtime.js";
5
+ import { SupportRealtimeProvider } from "./support-provider.js";
6
+
7
+ export { RealtimeProvider, SupportRealtimeProvider, applyConversationSeenEvent, applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, hydrateConversationSeen, setTypingState, upsertConversationSeen, useRealtime, useRealtimeConnection };
@@ -0,0 +1,57 @@
1
+ import { AnyRealtimeEvent, RealtimeEvent } from "../realtime-events.js";
2
+ import React from "react";
3
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
+
5
+ //#region src/realtime/provider.d.ts
6
+ type SubscribeHandler = (event: AnyRealtimeEvent) => void;
7
+ type VisitorAuthConfig = {
8
+ kind: "visitor";
9
+ visitorId: string | null;
10
+ websiteId?: string | null;
11
+ publicKey?: string | null;
12
+ };
13
+ type SessionAuthConfig = {
14
+ kind: "session";
15
+ sessionToken: string | null;
16
+ websiteId?: string | null;
17
+ userId?: string | null;
18
+ };
19
+ type RealtimeAuthConfig = VisitorAuthConfig | SessionAuthConfig;
20
+ type RealtimeProviderProps = {
21
+ children: React.ReactNode;
22
+ wsUrl?: string;
23
+ auth: RealtimeAuthConfig | null;
24
+ autoConnect?: boolean;
25
+ onConnect?: () => void;
26
+ onDisconnect?: () => void;
27
+ onError?: (error: Error) => void;
28
+ };
29
+ type RealtimeConnectionState = {
30
+ isConnected: boolean;
31
+ isConnecting: boolean;
32
+ error: Error | null;
33
+ send: (event: AnyRealtimeEvent) => void;
34
+ sendRaw: (data: string) => void;
35
+ subscribe: (handler: SubscribeHandler) => () => void;
36
+ lastEvent: AnyRealtimeEvent | null;
37
+ connectionId: string | null;
38
+ reconnect: () => void;
39
+ };
40
+ type RealtimeContextValue = RealtimeConnectionState & {
41
+ visitorId: string | null;
42
+ websiteId: string | null;
43
+ userId: string | null;
44
+ };
45
+ declare function RealtimeProvider({
46
+ children,
47
+ wsUrl,
48
+ auth,
49
+ autoConnect,
50
+ onConnect,
51
+ onDisconnect,
52
+ onError
53
+ }: RealtimeProviderProps): react_jsx_runtime0.JSX.Element;
54
+ declare function useRealtimeConnection(): RealtimeContextValue;
55
+ //#endregion
56
+ export { type RealtimeAuthConfig, type RealtimeContextValue, type RealtimeEvent, RealtimeProvider, type RealtimeProviderProps, useRealtimeConnection };
57
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","names":[],"sources":["../../src/realtime/provider.tsx"],"sourcesContent":[],"mappings":";;;;;KAuBK,gBAAA,WAA2B;KA+B3B,iBAAA;;EA/BA,SAAA,EAAA,MAAA,GAAgB,IAAA;EA+BhB,SAAA,CAAA,EAAA,MAAA,GAAiB,IAAA;EAOjB,SAAA,CAAA,EAAA,MAAA,GAAiB,IAAA;AAAA,CAAA;KAAjB,iBAAA,GAOkB;MAAG,EAAA,SAAA;cAAoB,EAAA,MAAA,GAAA,IAAA;EAAiB,SAAA,CAAA,EAAA,MAAA,GAAA,IAAA;EAW1D,MAAA,CAAA,EAAA,MAAA,GAAA,IAAA;CAAqB;KAXrB,kBAAA,GAAqB,iBAYT,GAZ6B,iBAY7B;KADZ,qBAAA,GAGE;UAIY,EANR,KAAA,CAAM,SAME;EAAK,KAAA,CAAA,EAAA,MAAA;EAGnB,IAAA,EAPE,kBAOF,GAAuB,IAAA;EAAA,WAAA,CAAA,EAAA,OAAA;WAGpB,CAAA,EAAA,GAAA,GAAA,IAAA;cACO,CAAA,EAAA,GAAA,GAAA,IAAA;SAEO,CAAA,EAAA,CAAA,KAAA,EATH,KASG,EAAA,GAAA,IAAA;;KANjB,uBAAA,GAOuB;EAKvB,WAAA,EAAA,OAAA;EA2QW,YAAA,EAAA,OAAgB;EAAA,KAAA,EApRxB,KAoRwB,GAAA,IAAA;MAC/B,EAAA,CAAA,KAAA,EApRc,gBAoRd,EAAA,GAAA,IAAA;SACA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,IAAA;WACA,EAAA,CAAA,OAAA,EApRqB,gBAoRrB,EAAA,GAAA,GAAA,GAAA,IAAA;WACA,EApRW,gBAoRX,GAAA,IAAA;cACA,EAAA,MAAA,GAAA,IAAA;WACA,EAAA,GAAA,GAAA,IAAA;;KAjRI,oBAAA,GAAuB,uBAmRzB,GAAA;WAAqB,EAAA,MAAA,GAAA,IAAA;EAAA,SAAA,EAAA,MAAA,GAAA,IAAA;EAmPR,MAAA,EAAA,MAAA,GAAA,IAAA;;iBA3PA,gBAAA;;;;;;;;GAQb,wBAAqB,kBAAA,CAAA,GAAA,CAAA;iBAmPR,qBAAA,CAAA,GAAyB"}