@cossistant/react 0.0.26 → 0.0.29

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 (247) hide show
  1. package/README.md +1 -1
  2. package/api.d.ts +1 -1
  3. package/api.d.ts.map +1 -1
  4. package/checks.d.ts +1 -1
  5. package/checks.d.ts.map +1 -1
  6. package/coerce.d.ts +1 -1
  7. package/coerce.d.ts.map +1 -1
  8. package/conversation.d.ts +6 -3
  9. package/conversation.d.ts.map +1 -1
  10. package/core.d.ts +1 -1
  11. package/core.d.ts.map +1 -1
  12. package/errors.d.ts +12 -3
  13. package/errors.d.ts.map +1 -1
  14. package/errors2.d.ts +1 -1
  15. package/errors2.d.ts.map +1 -1
  16. package/hooks/index.d.ts +3 -2
  17. package/hooks/index.js +6 -5
  18. package/hooks/private/store/use-website-store.js +2 -1
  19. package/hooks/private/store/use-website-store.js.map +1 -1
  20. package/hooks/private/use-client-query.d.ts +6 -0
  21. package/hooks/private/use-client-query.d.ts.map +1 -1
  22. package/hooks/private/use-client-query.js +26 -3
  23. package/hooks/private/use-client-query.js.map +1 -1
  24. package/hooks/private/use-grouped-messages.d.ts +8 -5
  25. package/hooks/private/use-grouped-messages.d.ts.map +1 -1
  26. package/hooks/private/use-grouped-messages.js +44 -11
  27. package/hooks/private/use-grouped-messages.js.map +1 -1
  28. package/hooks/private/use-multimodal-input.d.ts.map +1 -1
  29. package/hooks/private/use-multimodal-input.js +7 -5
  30. package/hooks/private/use-multimodal-input.js.map +1 -1
  31. package/hooks/private/use-visitor-typing-reporter.d.ts +18 -1
  32. package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -1
  33. package/hooks/private/use-visitor-typing-reporter.js +34 -4
  34. package/hooks/private/use-visitor-typing-reporter.js.map +1 -1
  35. package/hooks/use-conversation-page.d.ts +1 -0
  36. package/hooks/use-conversation-page.d.ts.map +1 -1
  37. package/hooks/use-conversation-page.js +6 -1
  38. package/hooks/use-conversation-page.js.map +1 -1
  39. package/hooks/use-conversation-preview.d.ts +2 -1
  40. package/hooks/use-conversation-preview.d.ts.map +1 -1
  41. package/hooks/use-conversation-preview.js +1 -1
  42. package/hooks/use-conversation-preview.js.map +1 -1
  43. package/hooks/use-conversation-seen.js +1 -1
  44. package/hooks/use-conversation-seen.js.map +1 -1
  45. package/hooks/use-conversation-timeline-items.js +2 -1
  46. package/hooks/use-conversation-timeline-items.js.map +1 -1
  47. package/hooks/use-conversation-timeline.d.ts.map +1 -1
  48. package/hooks/use-conversation-timeline.js +1 -3
  49. package/hooks/use-conversation-timeline.js.map +1 -1
  50. package/hooks/use-conversation.js +2 -1
  51. package/hooks/use-conversation.js.map +1 -1
  52. package/hooks/use-conversations.js +1 -0
  53. package/hooks/use-conversations.js.map +1 -1
  54. package/hooks/use-create-conversation.d.ts.map +1 -1
  55. package/hooks/use-file-upload.d.ts +55 -0
  56. package/hooks/use-file-upload.d.ts.map +1 -0
  57. package/hooks/use-file-upload.js +100 -0
  58. package/hooks/use-file-upload.js.map +1 -0
  59. package/hooks/use-message-composer.d.ts +11 -0
  60. package/hooks/use-message-composer.d.ts.map +1 -1
  61. package/hooks/use-message-composer.js +7 -3
  62. package/hooks/use-message-composer.js.map +1 -1
  63. package/hooks/use-send-message.d.ts +1 -0
  64. package/hooks/use-send-message.d.ts.map +1 -1
  65. package/hooks/use-send-message.js +63 -11
  66. package/hooks/use-send-message.js.map +1 -1
  67. package/index.d.ts +7 -4
  68. package/index.js +13 -10
  69. package/json-schema.d.ts +70 -0
  70. package/json-schema.d.ts.map +1 -0
  71. package/package.json +4 -3
  72. package/parse.d.ts +1 -1
  73. package/parse.d.ts.map +1 -1
  74. package/primitives/avatar/fallback.d.ts.map +1 -1
  75. package/primitives/avatar/fallback.js +1 -1
  76. package/primitives/avatar/fallback.js.map +1 -1
  77. package/primitives/conversation-timeline.d.ts.map +1 -1
  78. package/primitives/conversation-timeline.js +10 -5
  79. package/primitives/conversation-timeline.js.map +1 -1
  80. package/primitives/day-separator.d.ts +76 -0
  81. package/primitives/day-separator.d.ts.map +1 -0
  82. package/primitives/day-separator.js +111 -0
  83. package/primitives/day-separator.js.map +1 -0
  84. package/primitives/index.d.ts +5 -3
  85. package/primitives/index.js +17 -5
  86. package/primitives/index.parts.d.ts +4 -2
  87. package/primitives/index.parts.js +5 -3
  88. package/primitives/timeline-item-attachments.d.ts +100 -0
  89. package/primitives/timeline-item-attachments.d.ts.map +1 -0
  90. package/primitives/timeline-item-attachments.js +151 -0
  91. package/primitives/timeline-item-attachments.js.map +1 -0
  92. package/primitives/timeline-item-group.d.ts.map +1 -1
  93. package/primitives/timeline-item-group.js +1 -1
  94. package/primitives/timeline-item-group.js.map +1 -1
  95. package/primitives/timeline-item.js +1 -1
  96. package/primitives/timeline-item.js.map +1 -1
  97. package/primitives/trigger.d.ts +91 -0
  98. package/primitives/trigger.d.ts.map +1 -0
  99. package/primitives/trigger.js +74 -0
  100. package/primitives/trigger.js.map +1 -0
  101. package/primitives/window.d.ts +22 -1
  102. package/primitives/window.d.ts.map +1 -1
  103. package/primitives/window.js +91 -5
  104. package/primitives/window.js.map +1 -1
  105. package/provider.d.ts.map +1 -1
  106. package/provider.js +8 -3
  107. package/provider.js.map +1 -1
  108. package/realtime/index.js +1 -1
  109. package/realtime/provider.js +1 -1
  110. package/realtime/support-provider.js +5 -1
  111. package/realtime/support-provider.js.map +1 -1
  112. package/realtime-events.d.ts +165 -2
  113. package/realtime-events.d.ts.map +1 -1
  114. package/registries.d.ts +1 -1
  115. package/registries.d.ts.map +1 -1
  116. package/schemas.d.ts +305 -7
  117. package/schemas.d.ts.map +1 -1
  118. package/schemas2.d.ts +29 -4
  119. package/schemas2.d.ts.map +1 -1
  120. package/schemas3.d.ts +2 -1
  121. package/schemas3.d.ts.map +1 -1
  122. package/standard-schema.d.ts +83 -21
  123. package/standard-schema.d.ts.map +1 -1
  124. package/support/components/button.d.ts +1 -1
  125. package/support/components/content.d.ts +30 -0
  126. package/support/components/content.d.ts.map +1 -0
  127. package/support/components/content.js +282 -0
  128. package/support/components/content.js.map +1 -0
  129. package/support/components/conversation-button-link.js +1 -1
  130. package/support/components/conversation-timeline.d.ts +5 -0
  131. package/support/components/conversation-timeline.d.ts.map +1 -1
  132. package/support/components/conversation-timeline.js +25 -5
  133. package/support/components/conversation-timeline.js.map +1 -1
  134. package/support/components/header.js +1 -1
  135. package/support/components/image-lightbox.d.ts +49 -0
  136. package/support/components/image-lightbox.d.ts.map +1 -0
  137. package/support/components/image-lightbox.js +142 -0
  138. package/support/components/image-lightbox.js.map +1 -0
  139. package/support/components/index.d.ts +5 -4
  140. package/support/components/index.js +4 -4
  141. package/support/components/multimodal-input.d.ts +4 -1
  142. package/support/components/multimodal-input.d.ts.map +1 -1
  143. package/support/components/multimodal-input.js +71 -45
  144. package/support/components/multimodal-input.js.map +1 -1
  145. package/support/components/navigation-tab.js +1 -1
  146. package/support/components/root.d.ts +23 -0
  147. package/support/components/root.d.ts.map +1 -0
  148. package/support/components/root.js +36 -0
  149. package/support/components/root.js.map +1 -0
  150. package/support/components/timeline-message-item.d.ts.map +1 -1
  151. package/support/components/timeline-message-item.js +82 -18
  152. package/support/components/timeline-message-item.js.map +1 -1
  153. package/support/components/trigger.d.ts +14 -0
  154. package/support/components/trigger.d.ts.map +1 -0
  155. package/support/components/{bubble.js → trigger.js} +16 -12
  156. package/support/components/trigger.js.map +1 -0
  157. package/support/components/typing-indicator.d.ts.map +1 -1
  158. package/support/components/typing-indicator.js +1 -0
  159. package/support/components/typing-indicator.js.map +1 -1
  160. package/support/context/controlled-state.d.ts +46 -0
  161. package/support/context/controlled-state.d.ts.map +1 -0
  162. package/support/context/controlled-state.js +34 -0
  163. package/support/context/controlled-state.js.map +1 -0
  164. package/support/context/events.d.ts +103 -0
  165. package/support/context/events.d.ts.map +1 -0
  166. package/support/context/events.js +139 -0
  167. package/support/context/events.js.map +1 -0
  168. package/support/context/handle.d.ts +90 -0
  169. package/support/context/handle.d.ts.map +1 -0
  170. package/support/context/handle.js +79 -0
  171. package/support/context/handle.js.map +1 -0
  172. package/support/context/positioning.d.ts +17 -0
  173. package/support/context/positioning.d.ts.map +1 -0
  174. package/support/context/positioning.js +26 -0
  175. package/support/context/positioning.js.map +1 -0
  176. package/support/context/slots.d.ts +85 -0
  177. package/support/context/slots.d.ts.map +1 -0
  178. package/support/context/slots.js +115 -0
  179. package/support/context/slots.js.map +1 -0
  180. package/support/context/websocket.d.ts +8 -1
  181. package/support/context/websocket.d.ts.map +1 -1
  182. package/support/context/websocket.js +8 -1
  183. package/support/context/websocket.js.map +1 -1
  184. package/support/index.d.ts +239 -54
  185. package/support/index.d.ts.map +1 -1
  186. package/support/index.js +254 -33
  187. package/support/index.js.map +1 -1
  188. package/support/pages/articles.d.ts.map +1 -1
  189. package/support/pages/articles.js +3 -4
  190. package/support/pages/articles.js.map +1 -1
  191. package/support/pages/conversation-history.js +2 -2
  192. package/support/pages/conversation.js +6 -5
  193. package/support/pages/conversation.js.map +1 -1
  194. package/support/pages/home.js +2 -2
  195. package/support/router.d.ts +52 -12
  196. package/support/router.d.ts.map +1 -1
  197. package/support/router.js +78 -30
  198. package/support/router.js.map +1 -1
  199. package/support/store/index.d.ts +2 -2
  200. package/support/store/support-store.d.ts +26 -20
  201. package/support/store/support-store.d.ts.map +1 -1
  202. package/support/store/support-store.js +47 -6
  203. package/support/store/support-store.js.map +1 -1
  204. package/support/{support-D2EgfIts.css → support-C7Xaw-N6.css} +1 -2
  205. package/support/support-C7Xaw-N6.css.map +1 -0
  206. package/support/text/index.d.ts +1 -1
  207. package/support/text/index.d.ts.map +1 -1
  208. package/support/text/index.js.map +1 -1
  209. package/support/types.d.ts +75 -12
  210. package/support/types.d.ts.map +1 -1
  211. package/support.css +2 -2
  212. package/tailwind.css +0 -1
  213. package/timeline-item.d.ts +68 -2
  214. package/timeline-item.d.ts.map +1 -1
  215. package/to-json-schema.d.ts +96 -0
  216. package/to-json-schema.d.ts.map +1 -0
  217. package/util.d.ts +6 -2
  218. package/util.d.ts.map +1 -1
  219. package/utils/index.d.ts +2 -1
  220. package/utils/index.js +2 -1
  221. package/utils/merge-refs.d.ts +30 -0
  222. package/utils/merge-refs.d.ts.map +1 -0
  223. package/utils/merge-refs.js +46 -0
  224. package/utils/merge-refs.js.map +1 -0
  225. package/utils/use-render-element.d.ts.map +1 -1
  226. package/utils/use-render-element.js +36 -8
  227. package/utils/use-render-element.js.map +1 -1
  228. package/versions.d.ts +2 -2
  229. package/versions.d.ts.map +1 -1
  230. package/zod-extensions.d.ts +1 -1
  231. package/zod-extensions.d.ts.map +1 -1
  232. package/primitives/bubble.d.ts +0 -38
  233. package/primitives/bubble.d.ts.map +0 -1
  234. package/primitives/bubble.js +0 -57
  235. package/primitives/bubble.js.map +0 -1
  236. package/support/components/bubble.d.ts +0 -10
  237. package/support/components/bubble.d.ts.map +0 -1
  238. package/support/components/bubble.js.map +0 -1
  239. package/support/components/container.d.ts +0 -13
  240. package/support/components/container.d.ts.map +0 -1
  241. package/support/components/container.js +0 -109
  242. package/support/components/container.js.map +0 -1
  243. package/support/components/support-content.d.ts +0 -22
  244. package/support/components/support-content.d.ts.map +0 -1
  245. package/support/components/support-content.js +0 -48
  246. package/support/components/support-content.js.map +0 -1
  247. package/support/support-D2EgfIts.css.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/support/index.tsx"],"sourcesContent":["import \"./support.css\";\n\nimport type { DefaultMessage } from \"@cossistant/types\";\nimport React, { type ReactElement } from \"react\";\nimport { useSupport } from \"../provider\";\nimport { SupportRealtimeProvider } from \"../realtime\";\nimport { SupportConfig } from \"../support-config\";\nimport { SupportContent } from \"./components/support-content\";\nimport { ThemeWrapper } from \"./components/theme-wrapper\";\nimport type { CustomPage } from \"./router\";\nimport { initializeSupportStore } from \"./store/support-store\";\nimport type { SupportLocale, SupportTextContentOverrides } from \"./text\";\nimport { SupportTextProvider } from \"./text\";\nimport type {\n\tBubbleSlotProps,\n\tContainerSlotProps,\n\tRouterSlotProps,\n} from \"./types\";\n\nexport type SupportProps<Locale extends string = SupportLocale> = {\n\t// Existing props\n\tclassName?: string;\n\tposition?: \"top\" | \"bottom\";\n\talign?: \"right\" | \"left\";\n\tpositioning?: \"fixed\" | \"absolute\";\n\tquickOptions?: string[];\n\tdefaultMessages?: DefaultMessage[];\n\tdefaultOpen?: boolean;\n\tlocale?: Locale;\n\tcontent?: SupportTextContentOverrides<Locale>;\n\n\t// NEW: Theme control\n\ttheme?: \"light\" | \"dark\";\n\n\t// NEW: Slot customization\n\tslots?: {\n\t\tbubble?: React.ComponentType<BubbleSlotProps>;\n\t\tcontainer?: React.ComponentType<ContainerSlotProps>;\n\t\trouter?: React.ComponentType<RouterSlotProps>;\n\t};\n\n\t// NEW: Granular className overrides\n\tclassNames?: {\n\t\troot?: string;\n\t\tbubble?: string;\n\t\tcontainer?: string;\n\t};\n\n\t// NEW: Type-safe custom pages\n\tcustomPages?: CustomPage[];\n\n\tchildren?: React.ReactNode;\n};\n\n/**\n * Complete support widget with chat, routing, and real-time features.\n *\n * @example\n * // Zero config\n * <Support />\n *\n * @example\n * // With customization and custom pages\n * <Support\n * theme=\"dark\"\n * classNames={{ bubble: \"bg-purple-600\" }}\n * customPages={[\n * { name: \"FAQ\", component: FAQPage }\n * ]}\n * />\n */\nexport function Support<Locale extends string = SupportLocale>({\n\tclassName,\n\tposition = \"bottom\",\n\talign = \"right\",\n\tpositioning = \"fixed\",\n\tquickOptions,\n\tdefaultMessages,\n\tdefaultOpen,\n\tlocale,\n\tcontent,\n\ttheme,\n\tslots,\n\tclassNames,\n\tcustomPages,\n\tchildren,\n}: SupportProps<Locale>): ReactElement | null {\n\tconst { website } = useSupport();\n\tconst isVisitorBlocked = website?.visitor?.isBlocked ?? false;\n\n\t// Initialize support store with defaultOpen when component mounts or prop changes\n\tReact.useEffect(() => {\n\t\tif (defaultOpen !== undefined) {\n\t\t\tinitializeSupportStore({ defaultOpen });\n\t\t}\n\t}, [defaultOpen]);\n\n\tif (!website || isVisitorBlocked) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ThemeWrapper theme={theme}>\n\t\t\t<SupportRealtimeProvider>\n\t\t\t\t<SupportTextProvider content={content} locale={locale}>\n\t\t\t\t\t<SupportContent\n\t\t\t\t\t\talign={align}\n\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\tclassNames={classNames}\n\t\t\t\t\t\tcustomPages={customPages}\n\t\t\t\t\t\tposition={position}\n\t\t\t\t\t\tpositioning={positioning}\n\t\t\t\t\t\tslots={slots}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</SupportContent>\n\t\t\t\t</SupportTextProvider>\n\t\t\t</SupportRealtimeProvider>\n\t\t\t<SupportConfig\n\t\t\t\tdefaultMessages={defaultMessages}\n\t\t\t\tquickOptions={quickOptions}\n\t\t\t/>\n\t\t</ThemeWrapper>\n\t);\n}\n\nexport default Support;\n\n// Type exports from core\nexport type {\n\tDefaultRoutes,\n\tNavigationState,\n\tRouteRegistry,\n\tSupportPage,\n} from \"@cossistant/core\";\nexport { CoButton as Button } from \"./components/button\";\n// UI components for building custom pages\nexport { Header } from \"./components/header\";\n// WebSocket context\nexport type { WebSocketContextValue } from \"./context/websocket\";\nexport { useWebSocket, WebSocketProvider } from \"./context/websocket\";\n// Custom page type for type-safe routing\nexport type { CustomPage } from \"./router\";\n// Navigation hooks and store\nexport {\n\tuseSupportConfig,\n\tuseSupportNavigation,\n\tuseSupportStore,\n} from \"./store\";\n// Text and localization\nexport type { SupportLocale, SupportTextContentOverrides } from \"./text\";\nexport { Text, useSupportText } from \"./text\";\n\n// Slot prop types\nexport type {\n\tBubbleSlotProps,\n\tContainerSlotProps,\n\tRouterSlotProps,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,SAAgB,QAA+C,EAC9D,WACA,WAAW,UACX,QAAQ,SACR,cAAc,SACd,cACA,iBACA,aACA,QACA,SACA,OACA,OACA,YACA,aACA,YAC6C;CAC7C,MAAM,EAAE,YAAY,YAAY;CAChC,MAAM,mBAAmB,SAAS,SAAS,aAAa;AAGxD,OAAM,gBAAgB;AACrB,MAAI,gBAAgB,OACnB,wBAAuB,EAAE,aAAa,CAAC;IAEtC,CAAC,YAAY,CAAC;AAEjB,KAAI,CAAC,WAAW,iBACf,QAAO;AAGR,QACC,qBAAC;EAAoB;aACpB,oBAAC,qCACA,oBAAC;GAA6B;GAAiB;aAC9C,oBAAC;IACO;IACI;IACC;IACC;IACH;IACG;IACN;IAEN;KACe;IACI,GACG,EAC1B,oBAAC;GACiB;GACH;IACb;GACY;;AAIjB,sBAAe"}
1
+ {"version":3,"file":"index.js","names":["result: ParsedChildren","React","Primitive.Trigger","SupportContent: React.FC<SupportContentProps>","SupportRouter: React.FC<SupportRouterProps>"],"sources":["../../src/support/index.tsx"],"sourcesContent":["import \"./support.css\";\n\nimport type { DefaultMessage } from \"@cossistant/types\";\nimport * as React from \"react\";\nimport * as Primitive from \"../primitives\";\nimport { useSupport } from \"../provider\";\nimport { SupportRealtimeProvider } from \"../realtime\";\nimport { SupportConfig } from \"../support-config\";\nimport { Content } from \"./components/content\";\nimport { Root } from \"./components/root\";\nimport { ThemeWrapper } from \"./components/theme-wrapper\";\nimport { DefaultTrigger } from \"./components/trigger\";\nimport { ControlledStateProvider } from \"./context/controlled-state\";\nimport {\n\ttype ConversationEndEvent,\n\ttype ConversationStartEvent,\n\ttype ErrorEvent,\n\ttype MessageReceivedEvent,\n\ttype MessageSentEvent,\n\tSupportEventsProvider,\n} from \"./context/events\";\nimport { type SupportHandle, SupportHandleProvider } from \"./context/handle\";\nimport { FooterSlot, HeaderSlot } from \"./context/slots\";\nimport { type CustomPage, Page, Router } from \"./router\";\nimport { initializeSupportStore } from \"./store/support-store\";\nimport type { SupportLocale, SupportTextContentOverrides } from \"./text\";\nimport { SupportTextProvider } from \"./text\";\nimport type {\n\tAlign,\n\tCollisionPadding,\n\tSide,\n\tTriggerRenderProps,\n} from \"./types\";\n\n// =============================================================================\n// Support Props\n// =============================================================================\n\nexport type SupportProps<Locale extends string = SupportLocale> = {\n\t/**\n\t * Additional CSS classes for the root wrapper.\n\t */\n\tclassName?: string;\n\n\t/**\n\t * Which side of the trigger to place the content.\n\t * @default \"top\"\n\t */\n\tside?: Side;\n\n\t/**\n\t * Alignment along the side axis.\n\t * @default \"end\"\n\t */\n\talign?: Align;\n\n\t/**\n\t * Distance (in pixels) between the trigger and the content.\n\t * @default 16\n\t */\n\tsideOffset?: number;\n\n\t/**\n\t * Enable automatic collision avoidance.\n\t * When true, the content repositions to stay within the viewport.\n\t * @default true\n\t */\n\tavoidCollisions?: boolean;\n\n\t/**\n\t * Padding from viewport edges when avoiding collisions.\n\t * @default 8\n\t */\n\tcollisionPadding?: CollisionPadding;\n\n\t/**\n\t * Granular className overrides for specific parts.\n\t */\n\tclassNames?: {\n\t\ttrigger?: string;\n\t\tcontent?: string;\n\t};\n\n\t/**\n\t * Force a specific theme. Omit for automatic detection.\n\t */\n\ttheme?: \"light\" | \"dark\";\n\n\t/**\n\t * Controlled open state.\n\t * When provided, the widget operates in controlled mode.\n\t * Use with `onOpenChange` to manage state externally.\n\t */\n\topen?: boolean;\n\n\t/**\n\t * Callback fired when the open state should change.\n\t * Use with `open` prop for controlled mode.\n\t *\n\t * @example\n\t * const [isOpen, setIsOpen] = useState(false);\n\t * <Support open={isOpen} onOpenChange={setIsOpen} />\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\n\t/**\n\t * Whether the widget should open automatically on mount (uncontrolled mode).\n\t * Ignored when `open` prop is provided (controlled mode).\n\t * @default false\n\t */\n\tdefaultOpen?: boolean;\n\n\t/**\n\t * Quick reply options displayed to users.\n\t */\n\tquickOptions?: string[];\n\n\t/**\n\t * Custom welcome messages shown before a conversation starts.\n\t */\n\tdefaultMessages?: DefaultMessage[];\n\n\t/**\n\t * Locale string for widget translations.\n\t */\n\tlocale?: Locale;\n\n\t/**\n\t * Custom text content overrides for internationalization.\n\t */\n\tcontent?: SupportTextContentOverrides<Locale>;\n\n\t/**\n\t * Custom pages to add to the router.\n\t */\n\tcustomPages?: CustomPage[];\n\n\t// =========================================================================\n\t// Event Callbacks\n\t// =========================================================================\n\n\t/**\n\t * Called when a new conversation is started.\n\t */\n\tonConversationStart?: (event: ConversationStartEvent) => void;\n\n\t/**\n\t * Called when a conversation ends (resolved, closed, etc.).\n\t */\n\tonConversationEnd?: (event: ConversationEndEvent) => void;\n\n\t/**\n\t * Called when the visitor sends a message.\n\t */\n\tonMessageSent?: (event: MessageSentEvent) => void;\n\n\t/**\n\t * Called when a message is received from an agent (human or AI).\n\t */\n\tonMessageReceived?: (event: MessageReceivedEvent) => void;\n\n\t/**\n\t * Called when an error occurs within the widget.\n\t */\n\tonError?: (event: ErrorEvent) => void;\n\n\t/**\n\t * Children for composition. Can include:\n\t * - <Support.Trigger> for custom trigger\n\t * - <Support.Content> for custom content positioning\n\t * - <Support.Page> components for custom routes\n\t */\n\tchildren?: React.ReactNode;\n};\n\n// =============================================================================\n// Child Component Detection\n// =============================================================================\n\ntype ParsedChildren = {\n\ttrigger: React.ReactNode | null;\n\tcontent: React.ReactNode | null;\n\tpages: React.ReactNode[];\n\tother: React.ReactNode[];\n};\n\nfunction parseChildren(children: React.ReactNode): ParsedChildren {\n\tconst result: ParsedChildren = {\n\t\ttrigger: null,\n\t\tcontent: null,\n\t\tpages: [],\n\t\tother: [],\n\t};\n\n\tReact.Children.forEach(children, (child) => {\n\t\tif (!React.isValidElement(child)) {\n\t\t\tresult.other.push(child);\n\t\t\treturn;\n\t\t}\n\n\t\t// Check component type by displayName or the component reference\n\t\tconst displayName = (child.type as React.ComponentType)?.displayName ?? \"\";\n\n\t\tif (displayName === \"Support.Trigger\" || child.type === SupportTrigger) {\n\t\t\tresult.trigger = child;\n\t\t} else if (\n\t\t\tdisplayName === \"Support.Content\" ||\n\t\t\tchild.type === SupportContent\n\t\t) {\n\t\t\tresult.content = child;\n\t\t} else if (displayName === \"Support.Page\" || child.type === Page) {\n\t\t\tresult.pages.push(child);\n\t\t} else {\n\t\t\tresult.other.push(child);\n\t\t}\n\t});\n\n\treturn result;\n}\n\n// =============================================================================\n// Main Support Component\n// =============================================================================\n\n/**\n * Complete support widget with chat, routing, and real-time features.\n *\n * @example\n * // Zero config - works instantly\n * <Support />\n *\n * @example\n * // With styling\n * <Support\n * theme=\"dark\"\n * classNames={{\n * trigger: \"bg-purple-600\",\n * content: \"border-purple-200\",\n * }}\n * />\n *\n * @example\n * // With custom positioning\n * <Support side=\"bottom\" align=\"end\" sideOffset={8} />\n *\n * @example\n * // Controlled mode - external state management\n * const [isOpen, setIsOpen] = useState(false);\n * <Support open={isOpen} onOpenChange={setIsOpen} />\n *\n * @example\n * // With imperative ref\n * const supportRef = useRef<SupportHandle>(null);\n * supportRef.current?.open();\n * supportRef.current?.startConversation(\"Hello!\");\n * <Support ref={supportRef} />\n *\n * @example\n * // With custom trigger\n * <Support side=\"bottom\" align=\"end\">\n * <Support.Trigger className=\"px-4 py-2\">\n * {({ isOpen, unreadCount }) => (\n * <span>{isOpen ? \"Close\" : `Help (${unreadCount})`}</span>\n * )}\n * </Support.Trigger>\n * </Support>\n *\n * @example\n * // With custom pages\n * <Support>\n * <Support.Page name=\"FAQ\" component={FAQPage} />\n * </Support>\n */\nfunction SupportComponentInner<Locale extends string = SupportLocale>(\n\t{\n\t\tclassName,\n\t\tside = \"top\",\n\t\talign = \"end\",\n\t\tsideOffset = 16,\n\t\tavoidCollisions = true,\n\t\tcollisionPadding = 8,\n\t\tclassNames = {},\n\t\ttheme,\n\t\topen,\n\t\tonOpenChange,\n\t\tdefaultOpen,\n\t\tquickOptions,\n\t\tdefaultMessages,\n\t\tlocale,\n\t\tcontent,\n\t\tcustomPages,\n\t\tonConversationStart,\n\t\tonConversationEnd,\n\t\tonMessageSent,\n\t\tonMessageReceived,\n\t\tonError,\n\t\tchildren,\n\t}: SupportProps<Locale>,\n\tref: React.Ref<SupportHandle>\n): React.ReactElement | null {\n\tconst { website } = useSupport();\n\tconst isVisitorBlocked = website?.visitor?.isBlocked ?? false;\n\n\t// Initialize store for uncontrolled mode (when open prop is not provided)\n\tReact.useEffect(() => {\n\t\tif (open === undefined && defaultOpen !== undefined) {\n\t\t\tinitializeSupportStore({ defaultOpen });\n\t\t}\n\t}, [open, defaultOpen]);\n\n\tif (!website || isVisitorBlocked) {\n\t\treturn null;\n\t}\n\n\t// Parse children to detect custom components\n\tconst parsed = parseChildren(children);\n\n\t// Determine which components to render\n\tconst triggerElement = parsed.trigger ?? (\n\t\t<DefaultTrigger className={classNames.trigger} />\n\t);\n\n\t// If custom content is provided, use it; otherwise create default\n\tconst contentElement = parsed.content ?? (\n\t\t<Content\n\t\t\talign={align}\n\t\t\tavoidCollisions={avoidCollisions}\n\t\t\tclassName={classNames.content}\n\t\t\tcollisionPadding={collisionPadding}\n\t\t\tside={side}\n\t\t\tsideOffset={sideOffset}\n\t\t>\n\t\t\t<Router customPages={customPages}>{parsed.pages}</Router>\n\t\t</Content>\n\t);\n\n\treturn (\n\t\t<ControlledStateProvider onOpenChange={onOpenChange} open={open}>\n\t\t\t<SupportEventsProvider\n\t\t\t\tonConversationEnd={onConversationEnd}\n\t\t\t\tonConversationStart={onConversationStart}\n\t\t\t\tonError={onError}\n\t\t\t\tonMessageReceived={onMessageReceived}\n\t\t\t\tonMessageSent={onMessageSent}\n\t\t\t>\n\t\t\t\t<SupportHandleProvider forwardedRef={ref}>\n\t\t\t\t\t<ThemeWrapper theme={theme}>\n\t\t\t\t\t\t<SupportRealtimeProvider>\n\t\t\t\t\t\t\t<SupportTextProvider content={content} locale={locale}>\n\t\t\t\t\t\t\t\t<Root className={className}>\n\t\t\t\t\t\t\t\t\t{triggerElement}\n\t\t\t\t\t\t\t\t\t{contentElement}\n\t\t\t\t\t\t\t\t</Root>\n\t\t\t\t\t\t\t</SupportTextProvider>\n\t\t\t\t\t\t</SupportRealtimeProvider>\n\t\t\t\t\t\t<SupportConfig\n\t\t\t\t\t\t\tdefaultMessages={defaultMessages}\n\t\t\t\t\t\t\tquickOptions={quickOptions}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ThemeWrapper>\n\t\t\t\t</SupportHandleProvider>\n\t\t\t</SupportEventsProvider>\n\t\t</ControlledStateProvider>\n\t);\n}\n\n// Forward ref with proper generic typing\nconst SupportComponent = React.forwardRef(SupportComponentInner) as <\n\tLocale extends string = SupportLocale,\n>(\n\tprops: SupportProps<Locale> & { ref?: React.Ref<SupportHandle> }\n) => React.ReactElement | null;\n\n// =============================================================================\n// Trigger Compound Component\n// =============================================================================\n\nexport type SupportTriggerProps = Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t\"children\"\n> & {\n\t/**\n\t * Content to render inside the trigger.\n\t * Can be static content or a function receiving render props.\n\t */\n\tchildren?: React.ReactNode | ((props: TriggerRenderProps) => React.ReactNode);\n\t/**\n\t * When true, renders children directly with all props passed through.\n\t */\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Custom trigger component for the support widget.\n * Use this inside <Support> to replace the default floating button.\n *\n * @example\n * <Support.Trigger className=\"my-button\">\n * {({ isOpen, unreadCount }) => (\n * <span>{isOpen ? \"Close\" : `Help (${unreadCount})`}</span>\n * )}\n * </Support.Trigger>\n */\nconst SupportTrigger = React.forwardRef<HTMLButtonElement, SupportTriggerProps>(\n\t({ children, className, asChild = false, ...props }, ref) => (\n\t\t<Primitive.Trigger\n\t\t\tasChild={asChild}\n\t\t\tclassName={className}\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t>\n\t\t\t{children}\n\t\t</Primitive.Trigger>\n\t)\n);\n\nSupportTrigger.displayName = \"Support.Trigger\";\n\n// =============================================================================\n// Content Compound Component\n// =============================================================================\n\nexport type SupportContentProps = {\n\tclassName?: string;\n\t/**\n\t * Which side of the trigger to place the content.\n\t * @default \"top\"\n\t */\n\tside?: Side;\n\t/**\n\t * Alignment along the side axis.\n\t * @default \"end\"\n\t */\n\talign?: Align;\n\t/**\n\t * Distance (in pixels) between the trigger and the content.\n\t * @default 16\n\t */\n\tsideOffset?: number;\n\t/**\n\t * Enable automatic collision avoidance.\n\t * When true, the content repositions to stay within the viewport.\n\t * @default true\n\t */\n\tavoidCollisions?: boolean;\n\t/**\n\t * Padding from viewport edges when avoiding collisions.\n\t * @default 8\n\t */\n\tcollisionPadding?: CollisionPadding;\n\tchildren?: React.ReactNode;\n};\n\n/**\n * Custom content wrapper for the support widget.\n * Use this inside <Support> for custom positioning or styling.\n *\n * @example\n * <Support>\n * <Support.Trigger>Help</Support.Trigger>\n * <Support.Content side=\"bottom\" align=\"end\" className=\"my-content\">\n * <Support.Router />\n * </Support.Content>\n * </Support>\n */\nconst SupportContent: React.FC<SupportContentProps> = ({\n\tclassName,\n\tside = \"top\",\n\talign = \"end\",\n\tsideOffset = 16,\n\tavoidCollisions = true,\n\tcollisionPadding = 8,\n\tchildren,\n}) => (\n\t<Content\n\t\talign={align}\n\t\tavoidCollisions={avoidCollisions}\n\t\tclassName={className}\n\t\tcollisionPadding={collisionPadding}\n\t\tside={side}\n\t\tsideOffset={sideOffset}\n\t>\n\t\t{children ?? <Router />}\n\t</Content>\n);\n\n(SupportContent as React.FC & { displayName?: string }).displayName =\n\t\"Support.Content\";\n\n// =============================================================================\n// Router Compound Component\n// =============================================================================\n\nexport type SupportRouterProps = {\n\t/**\n\t * Custom pages to add alongside built-in pages.\n\t */\n\tcustomPages?: CustomPage[];\n\t/**\n\t * Page components to register.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * Router with all default pages (Home, Conversation, etc.).\n * Use inside <Support.Content> for full control.\n *\n * @example\n * <Support.Content>\n * <Support.Router />\n * </Support.Content>\n *\n * @example\n * // With custom pages\n * <Support.Router>\n * <Support.Page name=\"FAQ\" component={FAQPage} />\n * </Support.Router>\n */\nconst SupportRouter: React.FC<SupportRouterProps> = ({\n\tcustomPages,\n\tchildren,\n}) => <Router customPages={customPages}>{children}</Router>;\n\n(SupportRouter as React.FC & { displayName?: string }).displayName =\n\t\"Support.Router\";\n\n// =============================================================================\n// Page Compound Component\n// =============================================================================\n\nexport type SupportPageProps<\n\tK extends\n\t\tkeyof import(\"@cossistant/core\").RouteRegistry = keyof import(\"@cossistant/core\").RouteRegistry,\n> = {\n\tname: K;\n\tcomponent: React.ComponentType<{\n\t\tparams?: import(\"@cossistant/core\").RouteRegistry[K];\n\t}>;\n};\n\n/**\n * Declarative page registration for custom routes.\n *\n * @example\n * <Support>\n * <Support.Page name=\"FAQ\" component={FAQPage} />\n * <Support.Page name=\"SETTINGS\" component={SettingsPage} />\n * </Support>\n */\nconst SupportPage = Page;\n\n(SupportPage as unknown as { displayName?: string }).displayName =\n\t\"Support.Page\";\n\n// =============================================================================\n// Root Compound Component (for full composition)\n// =============================================================================\n\nexport type SupportRootProps = {\n\t/**\n\t * Controlled open state.\n\t * When provided, the widget operates in controlled mode.\n\t */\n\topen?: boolean;\n\t/**\n\t * Callback fired when the open state should change.\n\t * Use with `open` prop for controlled mode.\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\t/**\n\t * Whether the widget should open automatically (uncontrolled mode).\n\t * Ignored when `open` prop is provided.\n\t * @default false\n\t */\n\tdefaultOpen?: boolean;\n\t/**\n\t * Force a specific theme.\n\t */\n\ttheme?: \"light\" | \"dark\";\n\t/**\n\t * Additional CSS classes.\n\t */\n\tclassName?: string;\n\t/**\n\t * Called when a new conversation is started.\n\t */\n\tonConversationStart?: (event: ConversationStartEvent) => void;\n\t/**\n\t * Called when a conversation ends.\n\t */\n\tonConversationEnd?: (event: ConversationEndEvent) => void;\n\t/**\n\t * Called when the visitor sends a message.\n\t */\n\tonMessageSent?: (event: MessageSentEvent) => void;\n\t/**\n\t * Called when a message is received from an agent.\n\t */\n\tonMessageReceived?: (event: MessageReceivedEvent) => void;\n\t/**\n\t * Called when an error occurs.\n\t */\n\tonError?: (event: ErrorEvent) => void;\n\tchildren: React.ReactNode;\n};\n\n/**\n * Root component for full composition mode.\n * Use when you need complete control over the widget structure.\n *\n * @example\n * // Uncontrolled\n * <Support.Root defaultOpen={false}>\n * <Support.Trigger asChild>\n * <button>Help</button>\n * </Support.Trigger>\n * <Support.Content side=\"bottom\" align=\"end\">\n * <Support.Router />\n * </Support.Content>\n * </Support.Root>\n *\n * @example\n * // Controlled\n * const [isOpen, setIsOpen] = useState(false);\n * <Support.Root open={isOpen} onOpenChange={setIsOpen}>\n * ...\n * </Support.Root>\n *\n * @example\n * // With imperative ref\n * const supportRef = useRef<SupportHandle>(null);\n * <Support.Root ref={supportRef}>\n * ...\n * </Support.Root>\n */\nconst SupportRoot = React.forwardRef<SupportHandle, SupportRootProps>(\n\t(\n\t\t{\n\t\t\topen,\n\t\t\tonOpenChange,\n\t\t\tdefaultOpen,\n\t\t\ttheme,\n\t\t\tclassName,\n\t\t\tonConversationStart,\n\t\t\tonConversationEnd,\n\t\t\tonMessageSent,\n\t\t\tonMessageReceived,\n\t\t\tonError,\n\t\t\tchildren,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { website } = useSupport();\n\t\tconst isVisitorBlocked = website?.visitor?.isBlocked ?? false;\n\n\t\t// Initialize store for uncontrolled mode\n\t\tReact.useEffect(() => {\n\t\t\tif (open === undefined && defaultOpen !== undefined) {\n\t\t\t\tinitializeSupportStore({ defaultOpen });\n\t\t\t}\n\t\t}, [open, defaultOpen]);\n\n\t\tif (!website || isVisitorBlocked) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<ControlledStateProvider onOpenChange={onOpenChange} open={open}>\n\t\t\t\t<SupportEventsProvider\n\t\t\t\t\tonConversationEnd={onConversationEnd}\n\t\t\t\t\tonConversationStart={onConversationStart}\n\t\t\t\t\tonError={onError}\n\t\t\t\t\tonMessageReceived={onMessageReceived}\n\t\t\t\t\tonMessageSent={onMessageSent}\n\t\t\t\t>\n\t\t\t\t\t<SupportHandleProvider forwardedRef={ref}>\n\t\t\t\t\t\t<ThemeWrapper theme={theme}>\n\t\t\t\t\t\t\t<SupportRealtimeProvider>\n\t\t\t\t\t\t\t\t<Root className={className}>{children}</Root>\n\t\t\t\t\t\t\t</SupportRealtimeProvider>\n\t\t\t\t\t\t</ThemeWrapper>\n\t\t\t\t\t</SupportHandleProvider>\n\t\t\t\t</SupportEventsProvider>\n\t\t\t</ControlledStateProvider>\n\t\t);\n\t}\n);\n\nSupportRoot.displayName = \"Support.Root\";\n\n// =============================================================================\n// Compound Component Assembly\n// =============================================================================\n\nexport const Support = Object.assign(SupportComponent, {\n\tRoot: SupportRoot,\n\tTrigger: SupportTrigger,\n\tContent: SupportContent,\n\tRouter: SupportRouter,\n\tPage: SupportPage,\n\tHeader: HeaderSlot,\n\tFooter: FooterSlot,\n});\n\nexport default Support;\n\n// =============================================================================\n// Type Exports\n// =============================================================================\n\nexport type {\n\tDefaultRoutes,\n\tNavigationState,\n\tRouteRegistry,\n\tSupportPage as SupportPageType,\n} from \"@cossistant/core\";\n// Custom page type\nexport type { CustomPage } from \"./router\";\n// Types from ./types.ts\nexport type {\n\tAlign,\n\tCollisionPadding,\n\tContentProps,\n\tRootProps,\n\tSide,\n\tTriggerRenderProps,\n} from \"./types\";\n\n// =============================================================================\n// Component Exports\n// =============================================================================\n\nexport { CoButton as Button } from \"./components/button\";\nexport { Header } from \"./components/header\";\n\n// =============================================================================\n// Hook Exports\n// =============================================================================\n\nexport type { WebSocketContextValue } from \"./context/websocket\";\nexport { useWebSocket, WebSocketProvider } from \"./context/websocket\";\nexport {\n\tuseSupportConfig,\n\tuseSupportNavigation,\n\tuseSupportStore,\n} from \"./store\";\n\n// =============================================================================\n// Text & Localization\n// =============================================================================\n\nexport type { SupportLocale, SupportTextContentOverrides } from \"./text\";\nexport { Text, useSupportText } from \"./text\";\n\n// =============================================================================\n// Events\n// =============================================================================\n\nexport type {\n\tConversationEndEvent,\n\tConversationStartEvent,\n\tErrorEvent,\n\tMessageReceivedEvent,\n\tMessageSentEvent,\n\tSupportEvent,\n\tSupportEventCallbacks,\n\tSupportEventType,\n} from \"./context/events\";\nexport { useSupportEventEmitter, useSupportEvents } from \"./context/events\";\n\n// =============================================================================\n// Imperative Handle\n// =============================================================================\n\nexport type { SupportHandle } from \"./context/handle\";\nexport { useSupportHandle } from \"./context/handle\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0LA,SAAS,cAAc,UAA2C;CACjE,MAAMA,SAAyB;EAC9B,SAAS;EACT,SAAS;EACT,OAAO,EAAE;EACT,OAAO,EAAE;EACT;AAED,SAAM,SAAS,QAAQ,WAAW,UAAU;AAC3C,MAAI,CAACC,QAAM,eAAe,MAAM,EAAE;AACjC,UAAO,MAAM,KAAK,MAAM;AACxB;;EAID,MAAM,cAAe,MAAM,MAA8B,eAAe;AAExE,MAAI,gBAAgB,qBAAqB,MAAM,SAAS,eACvD,QAAO,UAAU;WAEjB,gBAAgB,qBAChB,MAAM,SAAS,eAEf,QAAO,UAAU;WACP,gBAAgB,kBAAkB,MAAM,SAAS,KAC3D,QAAO,MAAM,KAAK,MAAM;MAExB,QAAO,MAAM,KAAK,MAAM;GAExB;AAEF,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDR,SAAS,sBACR,EACC,WACA,OAAO,OACP,QAAQ,OACR,aAAa,IACb,kBAAkB,MAClB,mBAAmB,GACnB,aAAa,EAAE,EACf,OACA,MACA,cACA,aACA,cACA,iBACA,QACA,SACA,aACA,qBACA,mBACA,eACA,mBACA,SACA,YAED,KAC4B;CAC5B,MAAM,EAAE,YAAY,YAAY;CAChC,MAAM,mBAAmB,SAAS,SAAS,aAAa;AAGxD,SAAM,gBAAgB;AACrB,MAAI,SAAS,UAAa,gBAAgB,OACzC,wBAAuB,EAAE,aAAa,CAAC;IAEtC,CAAC,MAAM,YAAY,CAAC;AAEvB,KAAI,CAAC,WAAW,iBACf,QAAO;CAIR,MAAM,SAAS,cAAc,SAAS;AAqBtC,QACC,oBAAC;EAAsC;EAAoB;YAC1D,oBAAC;GACmB;GACE;GACZ;GACU;GACJ;aAEf,oBAAC;IAAsB,cAAc;cACpC,qBAAC;KAAoB;gBACpB,oBAAC,qCACA,oBAAC;MAA6B;MAAiB;gBAC9C,qBAAC;OAAgB;kBA/BD,OAAO,WAC7B,oBAAC,kBAAe,WAAW,WAAW,UAAW,EAI3B,OAAO,WAC7B,oBAAC;QACO;QACU;QACjB,WAAW,WAAW;QACJ;QACZ;QACM;kBAEZ,oBAAC;SAAoB;mBAAc,OAAO;UAAe;SAChD;QAmBG;OACc,GACG,EAC1B,oBAAC;MACiB;MACH;OACb;MACY;KACQ;IACD;GACC;;AAK5B,MAAM,mBAAmBA,QAAM,WAAW,sBAAsB;;;;;;;;;;;;AAqChE,MAAM,iBAAiBA,QAAM,YAC3B,EAAE,UAAU,WAAW,UAAU,MAAO,GAAG,SAAS,QACpD,oBAACC;CACS;CACE;CACN;CACL,GAAI;CAEH;EACkB,CAErB;AAED,eAAe,cAAc;;;;;;;;;;;;;AAiD7B,MAAMC,kBAAiD,EACtD,WACA,OAAO,OACP,QAAQ,OACR,aAAa,IACb,kBAAkB,MAClB,mBAAmB,GACnB,eAEA,oBAAC;CACO;CACU;CACN;CACO;CACZ;CACM;WAEX,YAAY,oBAAC,WAAS;EACd;AAGX,AAAC,eAAuD,cACvD;;;;;;;;;;;;;;;;AAgCD,MAAMC,iBAA+C,EACpD,aACA,eACK,oBAAC;CAAoB;CAAc;EAAkB;AAE3D,AAAC,cAAsD,cACtD;;;;;;;;;;AAyBD,MAAM,cAAc;AAEpB,AAAC,YAAoD,cACpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFD,MAAM,cAAcH,QAAM,YAExB,EACC,MACA,cACA,aACA,OACA,WACA,qBACA,mBACA,eACA,mBACA,SACA,YAED,QACI;CACJ,MAAM,EAAE,YAAY,YAAY;CAChC,MAAM,mBAAmB,SAAS,SAAS,aAAa;AAGxD,SAAM,gBAAgB;AACrB,MAAI,SAAS,UAAa,gBAAgB,OACzC,wBAAuB,EAAE,aAAa,CAAC;IAEtC,CAAC,MAAM,YAAY,CAAC;AAEvB,KAAI,CAAC,WAAW,iBACf,QAAO;AAGR,QACC,oBAAC;EAAsC;EAAoB;YAC1D,oBAAC;GACmB;GACE;GACZ;GACU;GACJ;aAEf,oBAAC;IAAsB,cAAc;cACpC,oBAAC;KAAoB;eACpB,oBAAC,qCACA,oBAAC;MAAgB;MAAY;OAAgB,GACpB;MACZ;KACQ;IACD;GACC;EAG5B;AAED,YAAY,cAAc;AAM1B,MAAa,UAAU,OAAO,OAAO,kBAAkB;CACtD,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,CAAC;AAEF,sBAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"articles.d.ts","names":[],"sources":["../../../src/support/pages/articles.tsx"],"sourcesContent":[],"mappings":";;;KAKK,iBAAA;;AAL0B,CAAA;AASlB,cAAA,YAAuB,EAAT,KAAA,CAAM,EAAG,CAAA,iBAAD,CAAA"}
1
+ {"version":3,"file":"articles.d.ts","names":[],"sources":["../../../src/support/pages/articles.tsx"],"sourcesContent":[],"mappings":";;;KAIK,iBAAA;;AAJ0B,CAAA;AAQlB,cAAA,YAAuB,EAAT,KAAA,CAAM,EAAG,CAAA,iBAAD,CAAA"}
@@ -1,11 +1,10 @@
1
- import { Container } from "../components/container.js";
2
1
  import { Header } from "../components/header.js";
3
2
  import { NavigationTab } from "../components/navigation-tab.js";
4
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
4
 
6
5
  //#region src/support/pages/articles.tsx
7
- const ArticlesPage = (_props = {}) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsx(NavigationTab, {}) }), /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx("div", {
8
- className: "p-2",
6
+ const ArticlesPage = (_props = {}) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsx(NavigationTab, {}) }), /* @__PURE__ */ jsx("div", {
7
+ className: "flex flex-1 flex-col p-2",
9
8
  children: /* @__PURE__ */ jsxs("div", {
10
9
  className: "flex flex-col gap-5",
11
10
  children: [
@@ -32,7 +31,7 @@ const ArticlesPage = (_props = {}) => /* @__PURE__ */ jsxs(Fragment, { children:
32
31
  })] })
33
32
  ]
34
33
  })
35
- }) })] });
34
+ })] });
36
35
 
37
36
  //#endregion
38
37
  export { ArticlesPage };
@@ -1 +1 @@
1
- {"version":3,"file":"articles.js","names":["ArticlesPage: React.FC<ArticlesPageProps>"],"sources":["../../../src/support/pages/articles.tsx"],"sourcesContent":["import type React from \"react\";\nimport { Container } from \"../components/container\";\nimport { Header } from \"../components/header\";\nimport { NavigationTab } from \"../components/navigation-tab\";\n\ntype ArticlesPageProps = {\n\tparams?: undefined;\n};\n\nexport const ArticlesPage: React.FC<ArticlesPageProps> = (_props = {}) => (\n\t<>\n\t\t<Header>\n\t\t\t<NavigationTab />\n\t\t</Header>\n\t\t<Container>\n\t\t\t<div className=\"p-2\">\n\t\t\t\t<div className=\"flex flex-col gap-5\">\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-co-primary\">\n\t\t\t\t\t\t\tHow do I start a conversation?\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t<p className=\"text-co-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\t\tClick the \"Start New Conversation\" button on the home page to\n\t\t\t\t\t\t\tbegin chatting with our support team.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-co-primary\">\n\t\t\t\t\t\t\tCan I view previous conversations?\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t<p className=\"text-co-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\t\tYes! Navigate to the Conversation History page to see all your\n\t\t\t\t\t\t\tpast conversations.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-co-primary\">\n\t\t\t\t\t\t\tHow quickly will I get a response?\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t<p className=\"text-co-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\t\tOur team typically responds within a few minutes during business\n\t\t\t\t\t\t\thours.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Container>\n\t</>\n);\n"],"mappings":";;;;;;AASA,MAAaA,gBAA6C,SAAS,EAAE,KACpE,4CACC,oBAAC,oBACA,oBAAC,kBAAgB,GACT,EACT,oBAAC,uBACA,oBAAC;CAAI,WAAU;WACd,qBAAC;EAAI,WAAU;;GACd,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA6C;KAEtD,EACL,oBAAC;IAAE,WAAU;cAA6C;KAGtD,IACC;GACN,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA6C;KAEtD,EACL,oBAAC;IAAE,WAAU;cAA6C;KAGtD,IACC;GACN,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA6C;KAEtD,EACL,oBAAC;IAAE,WAAU;cAA6C;KAGtD,IACC;;GACD;EACD,GACK,IACV"}
1
+ {"version":3,"file":"articles.js","names":["ArticlesPage: React.FC<ArticlesPageProps>"],"sources":["../../../src/support/pages/articles.tsx"],"sourcesContent":["import type React from \"react\";\nimport { Header } from \"../components/header\";\nimport { NavigationTab } from \"../components/navigation-tab\";\n\ntype ArticlesPageProps = {\n\tparams?: undefined;\n};\n\nexport const ArticlesPage: React.FC<ArticlesPageProps> = (_props = {}) => (\n\t<>\n\t\t<Header>\n\t\t\t<NavigationTab />\n\t\t</Header>\n\t\t<div className=\"flex flex-1 flex-col p-2\">\n\t\t\t<div className=\"flex flex-col gap-5\">\n\t\t\t\t<div>\n\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-co-primary\">\n\t\t\t\t\t\tHow do I start a conversation?\n\t\t\t\t\t</h3>\n\t\t\t\t\t<p className=\"text-co-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\tClick the \"Start New Conversation\" button on the home page to begin\n\t\t\t\t\t\tchatting with our support team.\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t\t<div>\n\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-co-primary\">\n\t\t\t\t\t\tCan I view previous conversations?\n\t\t\t\t\t</h3>\n\t\t\t\t\t<p className=\"text-co-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\tYes! Navigate to the Conversation History page to see all your past\n\t\t\t\t\t\tconversations.\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t\t<div>\n\t\t\t\t\t<h3 className=\"mb-2 font-medium text-base text-co-primary\">\n\t\t\t\t\t\tHow quickly will I get a response?\n\t\t\t\t\t</h3>\n\t\t\t\t\t<p className=\"text-co-primary/60 text-sm leading-relaxed\">\n\t\t\t\t\t\tOur team typically responds within a few minutes during business\n\t\t\t\t\t\thours.\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</>\n);\n"],"mappings":";;;;;AAQA,MAAaA,gBAA6C,SAAS,EAAE,KACpE,4CACC,oBAAC,oBACA,oBAAC,kBAAgB,GACT,EACT,oBAAC;CAAI,WAAU;WACd,qBAAC;EAAI,WAAU;;GACd,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA6C;KAEtD,EACL,oBAAC;IAAE,WAAU;cAA6C;KAGtD,IACC;GACN,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA6C;KAEtD,EACL,oBAAC;IAAE,WAAU;cAA6C;KAGtD,IACC;GACN,qBAAC,oBACA,oBAAC;IAAG,WAAU;cAA6C;KAEtD,EACL,oBAAC;IAAE,WAAU;cAA6C;KAGtD,IACC;;GACD;EACD,IACJ"}
@@ -1,10 +1,10 @@
1
1
  import { AvatarStack } from "../components/avatar-stack.js";
2
2
  import { useSupportNavigation } from "../store/support-store.js";
3
- import { CoButton } from "../components/button.js";
4
3
  import icons_default from "../components/icons.js";
4
+ import { PENDING_CONVERSATION_ID } from "../../utils/id.js";
5
+ import { CoButton } from "../components/button.js";
5
6
  import { Header } from "../components/header.js";
6
7
  import { Text, useSupportText } from "../text/index.js";
7
- import { PENDING_CONVERSATION_ID } from "../../utils/id.js";
8
8
  import { Watermark } from "../components/watermark.js";
9
9
  import { useConversationHistoryPage } from "../../hooks/use-conversation-history-page.js";
10
10
  import { ConversationButtonLink } from "../components/conversation-button-link.js";
@@ -1,10 +1,10 @@
1
+ import { useStoreSelector } from "../../hooks/private/store/use-store-selector.js";
1
2
  import { AvatarStack } from "../components/avatar-stack.js";
2
3
  import { useSupportConfig, useSupportNavigation } from "../store/support-store.js";
4
+ import { useNewMessageSound } from "../../hooks/use-new-message-sound.js";
3
5
  import { Header } from "../components/header.js";
4
6
  import { Text, useSupportText } from "../text/index.js";
5
- import { useConversation } from "../../hooks/use-conversation.js";
6
7
  import { useConversationPage } from "../../hooks/use-conversation-page.js";
7
- import { useNewMessageSound } from "../../hooks/use-new-message-sound.js";
8
8
  import { ConversationTimelineList } from "../components/conversation-timeline.js";
9
9
  import { MultimodalInput } from "../components/multimodal-input.js";
10
10
  import { IdentificationTimelineTool } from "../components/timeline-identification-tool.js";
@@ -18,7 +18,7 @@ const ConversationPage = ({ params, conversationId: legacyConversationId, initia
18
18
  const initialConversationId = params?.conversationId ?? legacyConversationId ?? "";
19
19
  const initialMessage = params?.initialMessage ?? legacyInitialMessage;
20
20
  const passedItems = params?.items ?? legacyItems ?? [];
21
- const { website, availableAIAgents, availableHumanAgents, visitor } = useSupport();
21
+ const { website, availableAIAgents, availableHumanAgents, visitor, client } = useSupport();
22
22
  const { navigate, replace, goBack, canGoBack } = useSupportNavigation();
23
23
  const { isOpen } = useSupportConfig();
24
24
  const text = useSupportText();
@@ -40,7 +40,7 @@ const ConversationPage = ({ params, conversationId: legacyConversationId, initia
40
40
  });
41
41
  }
42
42
  });
43
- const { conversation: activeConversation } = useConversation(conversation.isPending ? null : conversation.conversationId, { enabled: !conversation.isPending });
43
+ const activeConversation = useStoreSelector(client.conversationsStore, (state) => conversation.isPending ? null : state.byId[conversation.conversationId]);
44
44
  const isConversationClosed = Boolean(activeConversation && (activeConversation.status === ConversationStatus.RESOLVED || activeConversation.status === ConversationStatus.SPAM || activeConversation.deletedAt));
45
45
  const handleGoBack = () => {
46
46
  if (canGoBack) goBack();
@@ -102,10 +102,11 @@ const ConversationPage = ({ params, conversationId: legacyConversationId, initia
102
102
  }) : /* @__PURE__ */ jsx("div", {
103
103
  className: "flex-shrink-0 p-1",
104
104
  children: /* @__PURE__ */ jsx(MultimodalInput, {
105
- disabled: conversation.composer.isSubmitting,
105
+ disabled: conversation.composer.isSubmitting || conversation.composer.isUploading,
106
106
  error: conversation.error,
107
107
  files: conversation.composer.files,
108
108
  isSubmitting: conversation.composer.isSubmitting,
109
+ isUploading: conversation.composer.isUploading,
109
110
  onChange: conversation.composer.setMessage,
110
111
  onFileSelect: conversation.composer.addFiles,
111
112
  onRemoveFile: conversation.composer.removeFile,
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.js","names":["ConversationPage: ConversationPageComponent"],"sources":["../../../src/support/pages/conversation.tsx"],"sourcesContent":["import { ConversationStatus } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport { type ReactElement, useEffect, useMemo, useRef } from \"react\";\nimport { useConversation } from \"../../hooks/use-conversation\";\nimport { useConversationPage } from \"../../hooks/use-conversation-page\";\nimport { useNewMessageSound } from \"../../hooks/use-new-message-sound\";\nimport { useSupport } from \"../../provider\";\nimport { AvatarStack } from \"../components/avatar-stack\";\nimport { ConversationTimelineList } from \"../components/conversation-timeline\";\nimport { Header } from \"../components/header\";\nimport { MultimodalInput } from \"../components/multimodal-input\";\nimport { IdentificationTimelineTool } from \"../components/timeline-identification-tool\";\nimport { useSupportConfig, useSupportNavigation } from \"../store\";\nimport { Text, useSupportText } from \"../text\";\n\ntype ConversationPageProps = {\n\t/**\n\t * Page params object (for compatibility with Page component)\n\t */\n\tparams?: {\n\t\t/**\n\t\t * The conversation ID to display (can be PENDING_CONVERSATION_ID or a real ID).\n\t\t */\n\t\tconversationId: string;\n\n\t\t/**\n\t\t * Optional initial message to send when opening the conversation.\n\t\t */\n\t\tinitialMessage?: string;\n\n\t\t/**\n\t\t * Optional timeline items to display (for optimistic updates or initial state).\n\t\t */\n\t\titems?: TimelineItem[];\n\t};\n\n\t// Legacy direct props support (deprecated but maintained for backward compatibility)\n\tconversationId?: string;\n\tinitialMessage?: string;\n\titems?: TimelineItem[];\n};\n\n/**\n * Conversation page with message timeline and input composer.\n */\ntype ConversationPageComponent = (props: ConversationPageProps) => ReactElement;\n\nexport const ConversationPage: ConversationPageComponent = ({\n\tparams,\n\tconversationId: legacyConversationId,\n\tinitialMessage: legacyInitialMessage,\n\titems: legacyItems,\n}: ConversationPageProps) => {\n\t// Support both params object (new) and direct props (legacy)\n\tconst initialConversationId =\n\t\tparams?.conversationId ?? legacyConversationId ?? \"\";\n\tconst initialMessage = params?.initialMessage ?? legacyInitialMessage;\n\tconst passedItems = params?.items ?? legacyItems ?? [];\n\tconst { website, availableAIAgents, availableHumanAgents, visitor } =\n\t\tuseSupport();\n\tconst { navigate, replace, goBack, canGoBack } = useSupportNavigation();\n\tconst { isOpen } = useSupportConfig();\n\tconst text = useSupportText();\n\tconst playNewMessageSound = useNewMessageSound({\n\t\tvolume: 0.7,\n\t\tplaybackRate: 1.0,\n\t});\n\tconst previousItemsRef = useRef<TimelineItem[]>([]);\n\n\tconst timelineTools = useMemo(\n\t\t() => ({\n\t\t\tidentification: { component: IdentificationTimelineTool },\n\t\t}),\n\t\t[]\n\t);\n\n\t// Main conversation hook - handles all logic\n\tconst conversation = useConversationPage({\n\t\tconversationId: initialConversationId,\n\t\titems: passedItems,\n\t\tinitialMessage,\n\t\tautoSeenEnabled: isOpen,\n\t\tonConversationIdChange: (newConversationId) => {\n\t\t\t// Update navigation when conversation is created\n\t\t\treplace({\n\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\tparams: { conversationId: newConversationId },\n\t\t\t});\n\t\t},\n\t});\n\n\tconst { conversation: activeConversation } = useConversation(\n\t\tconversation.isPending ? null : conversation.conversationId,\n\t\t{ enabled: !conversation.isPending }\n\t);\n\n\tconst isConversationClosed = Boolean(\n\t\tactiveConversation &&\n\t\t\t(activeConversation.status === ConversationStatus.RESOLVED ||\n\t\t\t\tactiveConversation.status === ConversationStatus.SPAM ||\n\t\t\t\tactiveConversation.deletedAt)\n\t);\n\n\tconst handleGoBack = () => {\n\t\tif (canGoBack) {\n\t\t\tgoBack();\n\t\t} else {\n\t\t\tnavigate({ page: \"HOME\" });\n\t\t}\n\t};\n\n\t// Play sound when new messages arrive from agents (not visitor)\n\tuseEffect(() => {\n\t\tconst currentItems = conversation.items;\n\t\tconst previousItems = previousItemsRef.current;\n\n\t\t// Check if there are new items\n\t\tif (currentItems.length > previousItems.length) {\n\t\t\t// Find the new items\n\t\t\tconst newItems = currentItems.slice(previousItems.length);\n\n\t\t\t// Play sound only if new message is from agent (not visitor)\n\t\t\tfor (const item of newItems) {\n\t\t\t\tif (item.type === \"message\" && !item.visitorId) {\n\t\t\t\t\tplayNewMessageSound();\n\t\t\t\t\tbreak; // Only play once per batch\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update the ref\n\t\tpreviousItemsRef.current = currentItems;\n\t}, [conversation.items, playNewMessageSound]);\n\n\treturn (\n\t\t<div className=\"flex h-full flex-col gap-0 overflow-hidden\">\n\t\t\t<Header onGoBack={handleGoBack}>\n\t\t\t\t<div className=\"flex w-full items-center justify-between gap-2 py-3\">\n\t\t\t\t\t<div className=\"flex flex-col\">\n\t\t\t\t\t\t<p className=\"font-medium text-co-primary text-sm\">\n\t\t\t\t\t\t\t{website?.name}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\t\tclassName=\"text-co-muted-foreground text-sm\"\n\t\t\t\t\t\t\ttextKey=\"common.labels.supportOnline\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={availableAIAgents}\n\t\t\t\t\t\tgapWidth={2}\n\t\t\t\t\t\thumanAgents={availableHumanAgents}\n\t\t\t\t\t\tsize={32}\n\t\t\t\t\t\tspacing={28}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</Header>\n\n\t\t\t<ConversationTimelineList\n\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\tclassName=\"min-h-0 flex-1 px-4\"\n\t\t\t\tconversationId={conversation.conversationId}\n\t\t\t\tcurrentVisitorId={visitor?.id}\n\t\t\t\titems={conversation.items}\n\t\t\t\ttools={timelineTools}\n\t\t\t/>\n\n\t\t\t{isConversationClosed ? (\n\t\t\t\t<div className=\"m-4 flex items-center justify-center text-balance px-4 pb-6 text-center font-medium text-co-muted-foreground text-sm\">\n\t\t\t\t\t<Text as=\"p\" textKey=\"component.conversationPage.closedMessage\" />\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"flex-shrink-0 p-1\">\n\t\t\t\t\t<MultimodalInput\n\t\t\t\t\t\tdisabled={conversation.composer.isSubmitting}\n\t\t\t\t\t\terror={conversation.error}\n\t\t\t\t\t\tfiles={conversation.composer.files}\n\t\t\t\t\t\tisSubmitting={conversation.composer.isSubmitting}\n\t\t\t\t\t\tonChange={conversation.composer.setMessage}\n\t\t\t\t\t\tonFileSelect={conversation.composer.addFiles}\n\t\t\t\t\t\tonRemoveFile={conversation.composer.removeFile}\n\t\t\t\t\t\tonSubmit={conversation.composer.submit}\n\t\t\t\t\t\tplaceholder={text(\"component.multimodalInput.placeholder\")}\n\t\t\t\t\t\tvalue={conversation.composer.message}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA+CA,MAAaA,oBAA+C,EAC3D,QACA,gBAAgB,sBAChB,gBAAgB,sBAChB,OAAO,kBACqB;CAE5B,MAAM,wBACL,QAAQ,kBAAkB,wBAAwB;CACnD,MAAM,iBAAiB,QAAQ,kBAAkB;CACjD,MAAM,cAAc,QAAQ,SAAS,eAAe,EAAE;CACtD,MAAM,EAAE,SAAS,mBAAmB,sBAAsB,YACzD,YAAY;CACb,MAAM,EAAE,UAAU,SAAS,QAAQ,cAAc,sBAAsB;CACvE,MAAM,EAAE,WAAW,kBAAkB;CACrC,MAAM,OAAO,gBAAgB;CAC7B,MAAM,sBAAsB,mBAAmB;EAC9C,QAAQ;EACR,cAAc;EACd,CAAC;CACF,MAAM,mBAAmB,OAAuB,EAAE,CAAC;CAEnD,MAAM,gBAAgB,eACd,EACN,gBAAgB,EAAE,WAAW,4BAA4B,EACzD,GACD,EAAE,CACF;CAGD,MAAM,eAAe,oBAAoB;EACxC,gBAAgB;EAChB,OAAO;EACP;EACA,iBAAiB;EACjB,yBAAyB,sBAAsB;AAE9C,WAAQ;IACP,MAAM;IACN,QAAQ,EAAE,gBAAgB,mBAAmB;IAC7C,CAAC;;EAEH,CAAC;CAEF,MAAM,EAAE,cAAc,uBAAuB,gBAC5C,aAAa,YAAY,OAAO,aAAa,gBAC7C,EAAE,SAAS,CAAC,aAAa,WAAW,CACpC;CAED,MAAM,uBAAuB,QAC5B,uBACE,mBAAmB,WAAW,mBAAmB,YACjD,mBAAmB,WAAW,mBAAmB,QACjD,mBAAmB,WACrB;CAED,MAAM,qBAAqB;AAC1B,MAAI,UACH,SAAQ;MAER,UAAS,EAAE,MAAM,QAAQ,CAAC;;AAK5B,iBAAgB;EACf,MAAM,eAAe,aAAa;EAClC,MAAM,gBAAgB,iBAAiB;AAGvC,MAAI,aAAa,SAAS,cAAc,QAAQ;GAE/C,MAAM,WAAW,aAAa,MAAM,cAAc,OAAO;AAGzD,QAAK,MAAM,QAAQ,SAClB,KAAI,KAAK,SAAS,aAAa,CAAC,KAAK,WAAW;AAC/C,yBAAqB;AACrB;;;AAMH,mBAAiB,UAAU;IACzB,CAAC,aAAa,OAAO,oBAAoB,CAAC;AAE7C,QACC,qBAAC;EAAI,WAAU;;GACd,oBAAC;IAAO,UAAU;cACjB,qBAAC;KAAI,WAAU;gBACd,qBAAC;MAAI,WAAU;iBACd,oBAAC;OAAE,WAAU;iBACX,SAAS;QACP,EACJ,oBAAC;OACA,IAAG;OACH,WAAU;OACV,SAAQ;QACP;OACG,EACN,oBAAC;MACA,UAAU;MACV,UAAU;MACV,aAAa;MACb,MAAM;MACN,SAAS;OACR;MACG;KACE;GAET,oBAAC;IACmB;IACG;IACtB,WAAU;IACV,gBAAgB,aAAa;IAC7B,kBAAkB,SAAS;IAC3B,OAAO,aAAa;IACpB,OAAO;KACN;GAED,uBACA,oBAAC;IAAI,WAAU;cACd,oBAAC;KAAK,IAAG;KAAI,SAAQ;MAA6C;KAC7D,GAEN,oBAAC;IAAI,WAAU;cACd,oBAAC;KACA,UAAU,aAAa,SAAS;KAChC,OAAO,aAAa;KACpB,OAAO,aAAa,SAAS;KAC7B,cAAc,aAAa,SAAS;KACpC,UAAU,aAAa,SAAS;KAChC,cAAc,aAAa,SAAS;KACpC,cAAc,aAAa,SAAS;KACpC,UAAU,aAAa,SAAS;KAChC,aAAa,KAAK,wCAAwC;KAC1D,OAAO,aAAa,SAAS;MAC5B;KACG;;GAEF"}
1
+ {"version":3,"file":"conversation.js","names":["ConversationPage: ConversationPageComponent"],"sources":["../../../src/support/pages/conversation.tsx"],"sourcesContent":["import { ConversationStatus } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport { type ReactElement, useEffect, useMemo, useRef } from \"react\";\nimport { useStoreSelector } from \"../../hooks/private/store/use-store-selector\";\nimport { useConversationPage } from \"../../hooks/use-conversation-page\";\nimport { useNewMessageSound } from \"../../hooks/use-new-message-sound\";\nimport { useSupport } from \"../../provider\";\nimport { AvatarStack } from \"../components/avatar-stack\";\nimport { ConversationTimelineList } from \"../components/conversation-timeline\";\nimport { Header } from \"../components/header\";\nimport { MultimodalInput } from \"../components/multimodal-input\";\nimport { IdentificationTimelineTool } from \"../components/timeline-identification-tool\";\nimport { useSupportConfig, useSupportNavigation } from \"../store\";\nimport { Text, useSupportText } from \"../text\";\n\ntype ConversationPageProps = {\n\t/**\n\t * Page params object (for compatibility with Page component)\n\t */\n\tparams?: {\n\t\t/**\n\t\t * The conversation ID to display (can be PENDING_CONVERSATION_ID or a real ID).\n\t\t */\n\t\tconversationId: string;\n\n\t\t/**\n\t\t * Optional initial message to send when opening the conversation.\n\t\t */\n\t\tinitialMessage?: string;\n\n\t\t/**\n\t\t * Optional timeline items to display (for optimistic updates or initial state).\n\t\t */\n\t\titems?: TimelineItem[];\n\t};\n\n\t// Legacy direct props support (deprecated but maintained for backward compatibility)\n\tconversationId?: string;\n\tinitialMessage?: string;\n\titems?: TimelineItem[];\n};\n\n/**\n * Conversation page with message timeline and input composer.\n */\ntype ConversationPageComponent = (props: ConversationPageProps) => ReactElement;\n\nexport const ConversationPage: ConversationPageComponent = ({\n\tparams,\n\tconversationId: legacyConversationId,\n\tinitialMessage: legacyInitialMessage,\n\titems: legacyItems,\n}: ConversationPageProps) => {\n\t// Support both params object (new) and direct props (legacy)\n\tconst initialConversationId =\n\t\tparams?.conversationId ?? legacyConversationId ?? \"\";\n\tconst initialMessage = params?.initialMessage ?? legacyInitialMessage;\n\tconst passedItems = params?.items ?? legacyItems ?? [];\n\tconst { website, availableAIAgents, availableHumanAgents, visitor, client } =\n\t\tuseSupport();\n\tconst { navigate, replace, goBack, canGoBack } = useSupportNavigation();\n\tconst { isOpen } = useSupportConfig();\n\tconst text = useSupportText();\n\tconst playNewMessageSound = useNewMessageSound({\n\t\tvolume: 0.7,\n\t\tplaybackRate: 1.0,\n\t});\n\tconst previousItemsRef = useRef<TimelineItem[]>([]);\n\n\tconst timelineTools = useMemo(\n\t\t() => ({\n\t\t\tidentification: { component: IdentificationTimelineTool },\n\t\t}),\n\t\t[]\n\t);\n\n\t// Main conversation hook - handles all logic\n\tconst conversation = useConversationPage({\n\t\tconversationId: initialConversationId,\n\t\titems: passedItems,\n\t\tinitialMessage,\n\t\tautoSeenEnabled: isOpen,\n\t\tonConversationIdChange: (newConversationId) => {\n\t\t\t// Update navigation when conversation is created\n\t\t\treplace({\n\t\t\t\tpage: \"CONVERSATION\",\n\t\t\t\tparams: { conversationId: newConversationId },\n\t\t\t});\n\t\t},\n\t});\n\n\t// Get conversation from store (no API call) to check status\n\tconst activeConversation = useStoreSelector(\n\t\tclient.conversationsStore,\n\t\t(state) =>\n\t\t\tconversation.isPending ? null : state.byId[conversation.conversationId]\n\t);\n\n\tconst isConversationClosed = Boolean(\n\t\tactiveConversation &&\n\t\t\t(activeConversation.status === ConversationStatus.RESOLVED ||\n\t\t\t\tactiveConversation.status === ConversationStatus.SPAM ||\n\t\t\t\tactiveConversation.deletedAt)\n\t);\n\n\tconst handleGoBack = () => {\n\t\tif (canGoBack) {\n\t\t\tgoBack();\n\t\t} else {\n\t\t\tnavigate({ page: \"HOME\" });\n\t\t}\n\t};\n\n\t// Play sound when new messages arrive from agents (not visitor)\n\tuseEffect(() => {\n\t\tconst currentItems = conversation.items;\n\t\tconst previousItems = previousItemsRef.current;\n\n\t\t// Check if there are new items\n\t\tif (currentItems.length > previousItems.length) {\n\t\t\t// Find the new items\n\t\t\tconst newItems = currentItems.slice(previousItems.length);\n\n\t\t\t// Play sound only if new message is from agent (not visitor)\n\t\t\tfor (const item of newItems) {\n\t\t\t\tif (item.type === \"message\" && !item.visitorId) {\n\t\t\t\t\tplayNewMessageSound();\n\t\t\t\t\tbreak; // Only play once per batch\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update the ref\n\t\tpreviousItemsRef.current = currentItems;\n\t}, [conversation.items, playNewMessageSound]);\n\n\treturn (\n\t\t<div className=\"flex h-full flex-col gap-0 overflow-hidden\">\n\t\t\t<Header onGoBack={handleGoBack}>\n\t\t\t\t<div className=\"flex w-full items-center justify-between gap-2 py-3\">\n\t\t\t\t\t<div className=\"flex flex-col\">\n\t\t\t\t\t\t<p className=\"font-medium text-co-primary text-sm\">\n\t\t\t\t\t\t\t{website?.name}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\t\tclassName=\"text-co-muted-foreground text-sm\"\n\t\t\t\t\t\t\ttextKey=\"common.labels.supportOnline\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={availableAIAgents}\n\t\t\t\t\t\tgapWidth={2}\n\t\t\t\t\t\thumanAgents={availableHumanAgents}\n\t\t\t\t\t\tsize={32}\n\t\t\t\t\t\tspacing={28}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</Header>\n\n\t\t\t<ConversationTimelineList\n\t\t\t\tavailableAIAgents={availableAIAgents}\n\t\t\t\tavailableHumanAgents={availableHumanAgents}\n\t\t\t\tclassName=\"min-h-0 flex-1 px-4\"\n\t\t\t\tconversationId={conversation.conversationId}\n\t\t\t\tcurrentVisitorId={visitor?.id}\n\t\t\t\titems={conversation.items}\n\t\t\t\ttools={timelineTools}\n\t\t\t/>\n\n\t\t\t{isConversationClosed ? (\n\t\t\t\t<div className=\"m-4 flex items-center justify-center text-balance px-4 pb-6 text-center font-medium text-co-muted-foreground text-sm\">\n\t\t\t\t\t<Text as=\"p\" textKey=\"component.conversationPage.closedMessage\" />\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"flex-shrink-0 p-1\">\n\t\t\t\t\t<MultimodalInput\n\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\tconversation.composer.isSubmitting ||\n\t\t\t\t\t\t\tconversation.composer.isUploading\n\t\t\t\t\t\t}\n\t\t\t\t\t\terror={conversation.error}\n\t\t\t\t\t\tfiles={conversation.composer.files}\n\t\t\t\t\t\tisSubmitting={conversation.composer.isSubmitting}\n\t\t\t\t\t\tisUploading={conversation.composer.isUploading}\n\t\t\t\t\t\tonChange={conversation.composer.setMessage}\n\t\t\t\t\t\tonFileSelect={conversation.composer.addFiles}\n\t\t\t\t\t\tonRemoveFile={conversation.composer.removeFile}\n\t\t\t\t\t\tonSubmit={conversation.composer.submit}\n\t\t\t\t\t\tplaceholder={text(\"component.multimodalInput.placeholder\")}\n\t\t\t\t\t\tvalue={conversation.composer.message}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA+CA,MAAaA,oBAA+C,EAC3D,QACA,gBAAgB,sBAChB,gBAAgB,sBAChB,OAAO,kBACqB;CAE5B,MAAM,wBACL,QAAQ,kBAAkB,wBAAwB;CACnD,MAAM,iBAAiB,QAAQ,kBAAkB;CACjD,MAAM,cAAc,QAAQ,SAAS,eAAe,EAAE;CACtD,MAAM,EAAE,SAAS,mBAAmB,sBAAsB,SAAS,WAClE,YAAY;CACb,MAAM,EAAE,UAAU,SAAS,QAAQ,cAAc,sBAAsB;CACvE,MAAM,EAAE,WAAW,kBAAkB;CACrC,MAAM,OAAO,gBAAgB;CAC7B,MAAM,sBAAsB,mBAAmB;EAC9C,QAAQ;EACR,cAAc;EACd,CAAC;CACF,MAAM,mBAAmB,OAAuB,EAAE,CAAC;CAEnD,MAAM,gBAAgB,eACd,EACN,gBAAgB,EAAE,WAAW,4BAA4B,EACzD,GACD,EAAE,CACF;CAGD,MAAM,eAAe,oBAAoB;EACxC,gBAAgB;EAChB,OAAO;EACP;EACA,iBAAiB;EACjB,yBAAyB,sBAAsB;AAE9C,WAAQ;IACP,MAAM;IACN,QAAQ,EAAE,gBAAgB,mBAAmB;IAC7C,CAAC;;EAEH,CAAC;CAGF,MAAM,qBAAqB,iBAC1B,OAAO,qBACN,UACA,aAAa,YAAY,OAAO,MAAM,KAAK,aAAa,gBACzD;CAED,MAAM,uBAAuB,QAC5B,uBACE,mBAAmB,WAAW,mBAAmB,YACjD,mBAAmB,WAAW,mBAAmB,QACjD,mBAAmB,WACrB;CAED,MAAM,qBAAqB;AAC1B,MAAI,UACH,SAAQ;MAER,UAAS,EAAE,MAAM,QAAQ,CAAC;;AAK5B,iBAAgB;EACf,MAAM,eAAe,aAAa;EAClC,MAAM,gBAAgB,iBAAiB;AAGvC,MAAI,aAAa,SAAS,cAAc,QAAQ;GAE/C,MAAM,WAAW,aAAa,MAAM,cAAc,OAAO;AAGzD,QAAK,MAAM,QAAQ,SAClB,KAAI,KAAK,SAAS,aAAa,CAAC,KAAK,WAAW;AAC/C,yBAAqB;AACrB;;;AAMH,mBAAiB,UAAU;IACzB,CAAC,aAAa,OAAO,oBAAoB,CAAC;AAE7C,QACC,qBAAC;EAAI,WAAU;;GACd,oBAAC;IAAO,UAAU;cACjB,qBAAC;KAAI,WAAU;gBACd,qBAAC;MAAI,WAAU;iBACd,oBAAC;OAAE,WAAU;iBACX,SAAS;QACP,EACJ,oBAAC;OACA,IAAG;OACH,WAAU;OACV,SAAQ;QACP;OACG,EACN,oBAAC;MACA,UAAU;MACV,UAAU;MACV,aAAa;MACb,MAAM;MACN,SAAS;OACR;MACG;KACE;GAET,oBAAC;IACmB;IACG;IACtB,WAAU;IACV,gBAAgB,aAAa;IAC7B,kBAAkB,SAAS;IAC3B,OAAO,aAAa;IACpB,OAAO;KACN;GAED,uBACA,oBAAC;IAAI,WAAU;cACd,oBAAC;KAAK,IAAG;KAAI,SAAQ;MAA6C;KAC7D,GAEN,oBAAC;IAAI,WAAU;cACd,oBAAC;KACA,UACC,aAAa,SAAS,gBACtB,aAAa,SAAS;KAEvB,OAAO,aAAa;KACpB,OAAO,aAAa,SAAS;KAC7B,cAAc,aAAa,SAAS;KACpC,aAAa,aAAa,SAAS;KACnC,UAAU,aAAa,SAAS;KAChC,cAAc,aAAa,SAAS;KACpC,cAAc,aAAa,SAAS;KACpC,UAAU,aAAa,SAAS;KAChC,aAAa,KAAK,wCAAwC;KAC1D,OAAO,aAAa,SAAS;MAC5B;KACG;;GAEF"}
@@ -1,10 +1,10 @@
1
1
  import { AvatarStack } from "../components/avatar-stack.js";
2
2
  import { useSupportNavigation } from "../store/support-store.js";
3
- import { CoButton } from "../components/button.js";
4
3
  import icons_default from "../components/icons.js";
4
+ import { PENDING_CONVERSATION_ID } from "../../utils/id.js";
5
+ import { CoButton } from "../components/button.js";
5
6
  import { Header } from "../components/header.js";
6
7
  import { Text, useSupportText } from "../text/index.js";
7
- import { PENDING_CONVERSATION_ID } from "../../utils/id.js";
8
8
  import { Watermark } from "../components/watermark.js";
9
9
  import { ConversationButtonLink } from "../components/conversation-button-link.js";
10
10
  import { useHomePage } from "../../hooks/use-home-page.js";
@@ -1,29 +1,69 @@
1
- import React from "react";
1
+ import * as React$1 from "react";
2
2
  import { RouteRegistry } from "@cossistant/core";
3
3
 
4
4
  //#region src/support/router.d.ts
5
+
6
+ /**
7
+ * Type for custom pages that ensures they match RouteRegistry.
8
+ */
5
9
  type CustomPage<K extends keyof RouteRegistry = keyof RouteRegistry> = {
6
10
  name: K;
7
- component: React.ComponentType<{
11
+ component: React$1.ComponentType<{
8
12
  params?: RouteRegistry[K];
9
13
  }>;
10
14
  };
11
- type SupportRouterProps = {
15
+ type RouterProps = {
16
+ /**
17
+ * Custom pages to add alongside the built-in pages.
18
+ */
12
19
  customPages?: CustomPage[];
13
- children?: React.ReactNode;
20
+ /**
21
+ * Children can include <Support.Page /> components.
22
+ */
23
+ children?: React$1.ReactNode;
14
24
  };
15
25
  /**
16
26
  * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).
17
- * Add custom pages via customPages prop.
27
+ * Add custom pages via the customPages prop or as children.
28
+ *
29
+ * @example
30
+ * // Default pages only
31
+ * <Support.Router />
32
+ *
33
+ * @example
34
+ * // With custom pages via prop
35
+ * <Support.Router customPages={[{ name: "FAQ", component: FAQPage }]} />
36
+ *
37
+ * @example
38
+ * // With custom pages as children
39
+ * <Support.Router>
40
+ * <Support.Page name="FAQ" component={FAQPage} />
41
+ * <Support.Page name="SETTINGS" component={SettingsPage} />
42
+ * </Support.Router>
43
+ */
44
+ declare const Router: React$1.FC<RouterProps>;
45
+ type PageProps<K extends keyof RouteRegistry = keyof RouteRegistry> = {
46
+ /**
47
+ * The route name for this page.
48
+ */
49
+ name: K;
50
+ /**
51
+ * The component to render for this page.
52
+ */
53
+ component: React$1.ComponentType<{
54
+ params?: RouteRegistry[K];
55
+ }>;
56
+ };
57
+ /**
58
+ * Declarative way to register custom pages.
59
+ * This component is collected by the Router and doesn't render anything itself.
18
60
  *
19
61
  * @example
20
- * <SupportRouter
21
- * customPages={[
22
- * { name: "SETTINGS", component: SettingsPage }
23
- * ]}
24
- * />
62
+ * <Support.Router>
63
+ * <Support.Page name="FAQ" component={FAQPage} />
64
+ * </Support.Router>
25
65
  */
26
- declare const SupportRouter: React.FC<SupportRouterProps>;
66
+ declare const Page: <K extends keyof RouteRegistry>(_props: PageProps<K>) => null;
27
67
  //#endregion
28
- export { CustomPage, SupportRouter, SupportRouterProps };
68
+ export { CustomPage, Page, PageProps, Router, RouterProps };
29
69
  //# sourceMappingURL=router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","names":[],"sources":["../../src/support/router.tsx"],"sourcesContent":[],"mappings":";;;;KAWY,2BAA2B,sBAAsB;QACtD;EADK,SAAA,EAEA,KAAA,CAAM,aAFI,CAAA;IAAiB,MAAA,CAAA,EAEI,aAFJ,CAEkB,CAFlB,CAAA;EAAsB,CAAA,CAAA;CACtD;AACoC,KAG/B,kBAAA,GAH+B;EAAc,WAAA,CAAA,EAI1C,UAJ0C,EAAA;EAA7C,QAAM,CAAA,EAKN,KAAA,CAAM,SALA;CAAa;AAG/B;AAgBA;;;;;;;;;;cAAa,eAAe,KAAA,CAAM,GAAG"}
1
+ {"version":3,"file":"router.d.ts","names":[],"sources":["../../src/support/router.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAaA;AAAuC,KAA3B,UAA2B,CAAA,UAAA,MAAA,aAAA,GAAA,MAAsB,aAAtB,CAAA,GAAA;EAAsB,IAAA,EACtD,CADsD;EACtD,SAAA,EACK,OAAA,CAAM,aADX,CAAA;IACoC,MAAA,CAAA,EAAA,aAAA,CAAc,CAAd,CAAA;EAAc,CAAA,CAAA;CAA7C;AAAmB,KAGnB,WAAA,GAHmB;EAGnB;AAsEZ;AAmCA;EAAsC,WAAA,CAAA,EArGvB,UAqGuB,EAAA;EAAsB;;;EAQH,QAAA,CAAA,EAzG7C,OAAA,CAAM,SAyGuC;CAA7C;;AAYZ;;;;;;;;;;;;;;;;;;cAvDa,QAAQ,OAAA,CAAM,GAAG;KAmClB,0BAA0B,sBAAsB;;;;QAIrD;;;;aAIK,OAAA,CAAM;aAAyB,cAAc;;;;;;;;;;;;cAY5C,uBAAwB,uBAAuB,UAAU"}
package/support/router.js CHANGED
@@ -1,51 +1,99 @@
1
- import { Router } from "../primitives/router.js";
1
+ import { Router as Router$1 } from "../primitives/router.js";
2
2
  import { useSupportNavigation } from "./store/support-store.js";
3
3
  import { ArticlesPage } from "./pages/articles.js";
4
4
  import { ConversationPage } from "./pages/conversation.js";
5
5
  import { ConversationHistoryPage } from "./pages/conversation-history.js";
6
6
  import { HomePage } from "./pages/home.js";
7
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import * as React$1 from "react";
8
+ import { jsx } from "react/jsx-runtime";
8
9
 
9
10
  //#region src/support/router.tsx
10
11
  /**
12
+ * Built-in pages that are always available.
13
+ * Type assertion is needed because each page component has different param types,
14
+ * but they all satisfy the PageDefinition interface.
15
+ */
16
+ const builtInPages = [
17
+ {
18
+ name: "HOME",
19
+ component: HomePage
20
+ },
21
+ {
22
+ name: "ARTICLES",
23
+ component: ArticlesPage
24
+ },
25
+ {
26
+ name: "CONVERSATION",
27
+ component: ConversationPage
28
+ },
29
+ {
30
+ name: "CONVERSATION_HISTORY",
31
+ component: ConversationHistoryPage
32
+ }
33
+ ];
34
+ /**
35
+ * Extract page definitions from Support.Page children.
36
+ * This allows declarative page registration via JSX.
37
+ */
38
+ function extractPagesFromChildren(children) {
39
+ const pages = [];
40
+ React$1.Children.forEach(children, (child) => {
41
+ if (!React$1.isValidElement(child)) return;
42
+ const props = child.props;
43
+ if (props.name && props.component) pages.push({
44
+ name: props.name,
45
+ component: props.component
46
+ });
47
+ });
48
+ return pages;
49
+ }
50
+ /**
11
51
  * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).
12
- * Add custom pages via customPages prop.
52
+ * Add custom pages via the customPages prop or as children.
13
53
  *
14
54
  * @example
15
- * <SupportRouter
16
- * customPages={[
17
- * { name: "SETTINGS", component: SettingsPage }
18
- * ]}
19
- * />
55
+ * // Default pages only
56
+ * <Support.Router />
57
+ *
58
+ * @example
59
+ * // With custom pages via prop
60
+ * <Support.Router customPages={[{ name: "FAQ", component: FAQPage }]} />
61
+ *
62
+ * @example
63
+ * // With custom pages as children
64
+ * <Support.Router>
65
+ * <Support.Page name="FAQ" component={FAQPage} />
66
+ * <Support.Page name="SETTINGS" component={SettingsPage} />
67
+ * </Support.Router>
20
68
  */
21
- const SupportRouter = ({ customPages = [], children }) => {
69
+ const Router = ({ customPages = [], children }) => {
22
70
  const { current } = useSupportNavigation();
23
- const allPages = [...[
24
- {
25
- name: "HOME",
26
- component: HomePage
27
- },
28
- {
29
- name: "ARTICLES",
30
- component: ArticlesPage
31
- },
32
- {
33
- name: "CONVERSATION",
34
- component: ConversationPage
35
- },
36
- {
37
- name: "CONVERSATION_HISTORY",
38
- component: ConversationHistoryPage
39
- }
40
- ], ...customPages];
41
- return /* @__PURE__ */ jsxs(Fragment, { children: [children, /* @__PURE__ */ jsx(Router, {
71
+ const extractedPages = React$1.useMemo(() => extractPagesFromChildren(children), [children]);
72
+ const allPages = React$1.useMemo(() => [
73
+ ...builtInPages,
74
+ ...customPages,
75
+ ...extractedPages
76
+ ], [customPages, extractedPages]);
77
+ return /* @__PURE__ */ jsx(Router$1, {
42
78
  fallback: HomePage,
43
79
  page: current.page,
44
80
  pages: allPages,
45
81
  params: current.params
46
- })] });
82
+ });
83
+ };
84
+ /**
85
+ * Declarative way to register custom pages.
86
+ * This component is collected by the Router and doesn't render anything itself.
87
+ *
88
+ * @example
89
+ * <Support.Router>
90
+ * <Support.Page name="FAQ" component={FAQPage} />
91
+ * </Support.Router>
92
+ */
93
+ const Page = (_props) => {
94
+ return null;
47
95
  };
48
96
 
49
97
  //#endregion
50
- export { SupportRouter };
98
+ export { Page, Router };
51
99
  //# sourceMappingURL=router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","names":["SupportRouter: React.FC<SupportRouterProps>","Primitive.Router"],"sources":["../../src/support/router.tsx"],"sourcesContent":["import type { RouteRegistry } from \"@cossistant/core\";\nimport type React from \"react\";\nimport type { PageDefinition } from \"../primitives\";\nimport * as Primitive from \"../primitives\";\nimport { ArticlesPage } from \"./pages/articles\";\nimport { ConversationPage } from \"./pages/conversation\";\nimport { ConversationHistoryPage } from \"./pages/conversation-history\";\nimport { HomePage } from \"./pages/home\";\nimport { useSupportNavigation } from \"./store/support-store\";\n\n// Type for custom pages that ensures they match RouteRegistry\nexport type CustomPage<K extends keyof RouteRegistry = keyof RouteRegistry> = {\n\tname: K;\n\tcomponent: React.ComponentType<{ params?: RouteRegistry[K] }>;\n};\n\nexport type SupportRouterProps = {\n\tcustomPages?: CustomPage[];\n\tchildren?: React.ReactNode;\n};\n\n/**\n * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).\n * Add custom pages via customPages prop.\n *\n * @example\n * <SupportRouter\n * customPages={[\n * { name: \"SETTINGS\", component: SettingsPage }\n * ]}\n * />\n */\nexport const SupportRouter: React.FC<SupportRouterProps> = ({\n\tcustomPages = [],\n\tchildren,\n}) => {\n\tconst { current } = useSupportNavigation();\n\n\t// Define all pages with proper typing\n\tconst builtInPages = [\n\t\t{\n\t\t\tname: \"HOME\",\n\t\t\tcomponent: HomePage,\n\t\t},\n\t\t{\n\t\t\tname: \"ARTICLES\",\n\t\t\tcomponent: ArticlesPage,\n\t\t},\n\t\t{\n\t\t\tname: \"CONVERSATION\",\n\t\t\tcomponent: ConversationPage,\n\t\t},\n\t\t{\n\t\t\tname: \"CONVERSATION_HISTORY\",\n\t\t\tcomponent: ConversationHistoryPage,\n\t\t},\n\t] as PageDefinition<keyof RouteRegistry>[];\n\n\t// Combine built-in and custom pages\n\tconst allPages = [...builtInPages, ...customPages] as PageDefinition<\n\t\tkeyof RouteRegistry\n\t>[];\n\n\treturn (\n\t\t<>\n\t\t\t{children}\n\t\t\t<Primitive.Router\n\t\t\t\tfallback={HomePage as React.ComponentType<{ params?: unknown }>}\n\t\t\t\tpage={current.page}\n\t\t\t\tpages={allPages}\n\t\t\t\tparams={current.params}\n\t\t\t/>\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAaA,iBAA+C,EAC3D,cAAc,EAAE,EAChB,eACK;CACL,MAAM,EAAE,YAAY,sBAAsB;CAuB1C,MAAM,WAAW,CAAC,GApBG;EACpB;GACC,MAAM;GACN,WAAW;GACX;EACD;GACC,MAAM;GACN,WAAW;GACX;EACD;GACC,MAAM;GACN,WAAW;GACX;EACD;GACC,MAAM;GACN,WAAW;GACX;EACD,EAGkC,GAAG,YAAY;AAIlD,QACC,4CACE,UACD,oBAACC;EACA,UAAU;EACV,MAAM,QAAQ;EACd,OAAO;EACP,QAAQ,QAAQ;GACf,IACA"}
1
+ {"version":3,"file":"router.js","names":["pages: CustomPage[]","React","Router: React.FC<RouterProps>","Primitive.Router"],"sources":["../../src/support/router.tsx"],"sourcesContent":["import type { RouteRegistry } from \"@cossistant/core\";\nimport * as React from \"react\";\nimport type { PageDefinition } from \"../primitives\";\nimport * as Primitive from \"../primitives\";\nimport { ArticlesPage } from \"./pages/articles\";\nimport { ConversationPage } from \"./pages/conversation\";\nimport { ConversationHistoryPage } from \"./pages/conversation-history\";\nimport { HomePage } from \"./pages/home\";\nimport { useSupportNavigation } from \"./store/support-store\";\n\n/**\n * Type for custom pages that ensures they match RouteRegistry.\n */\nexport type CustomPage<K extends keyof RouteRegistry = keyof RouteRegistry> = {\n\tname: K;\n\tcomponent: React.ComponentType<{ params?: RouteRegistry[K] }>;\n};\n\nexport type RouterProps = {\n\t/**\n\t * Custom pages to add alongside the built-in pages.\n\t */\n\tcustomPages?: CustomPage[];\n\t/**\n\t * Children can include <Support.Page /> components.\n\t */\n\tchildren?: React.ReactNode;\n};\n\n/**\n * Built-in pages that are always available.\n * Type assertion is needed because each page component has different param types,\n * but they all satisfy the PageDefinition interface.\n */\nconst builtInPages = [\n\t{ name: \"HOME\", component: HomePage },\n\t{ name: \"ARTICLES\", component: ArticlesPage },\n\t{ name: \"CONVERSATION\", component: ConversationPage },\n\t{ name: \"CONVERSATION_HISTORY\", component: ConversationHistoryPage },\n] as PageDefinition[];\n\n/**\n * Extract page definitions from Support.Page children.\n * This allows declarative page registration via JSX.\n */\nfunction extractPagesFromChildren(children: React.ReactNode): CustomPage[] {\n\tconst pages: CustomPage[] = [];\n\n\tReact.Children.forEach(children, (child) => {\n\t\tif (!React.isValidElement(child)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if this is a Page component by looking for name and component props\n\t\tconst props = child.props as {\n\t\t\tname?: string;\n\t\t\tcomponent?: React.ComponentType;\n\t\t};\n\t\tif (props.name && props.component) {\n\t\t\tpages.push({\n\t\t\t\tname: props.name as keyof RouteRegistry,\n\t\t\t\tcomponent: props.component,\n\t\t\t});\n\t\t}\n\t});\n\n\treturn pages;\n}\n\n/**\n * Router with default support pages (HOME, ARTICLES, CONVERSATION, CONVERSATION_HISTORY).\n * Add custom pages via the customPages prop or as children.\n *\n * @example\n * // Default pages only\n * <Support.Router />\n *\n * @example\n * // With custom pages via prop\n * <Support.Router customPages={[{ name: \"FAQ\", component: FAQPage }]} />\n *\n * @example\n * // With custom pages as children\n * <Support.Router>\n * <Support.Page name=\"FAQ\" component={FAQPage} />\n * <Support.Page name=\"SETTINGS\" component={SettingsPage} />\n * </Support.Router>\n */\nexport const Router: React.FC<RouterProps> = ({\n\tcustomPages = [],\n\tchildren,\n}) => {\n\tconst { current } = useSupportNavigation();\n\n\t// Extract pages from JSX children (Support.Page components)\n\tconst extractedPages = React.useMemo(\n\t\t() => extractPagesFromChildren(children),\n\t\t[children]\n\t);\n\n\t// Merge built-in pages, prop-based custom pages, and JSX-declared pages\n\tconst allPages = React.useMemo(\n\t\t() =>\n\t\t\t[...builtInPages, ...customPages, ...extractedPages] as PageDefinition<\n\t\t\t\tkeyof RouteRegistry\n\t\t\t>[],\n\t\t[customPages, extractedPages]\n\t);\n\n\treturn (\n\t\t<Primitive.Router\n\t\t\tfallback={HomePage as React.ComponentType<{ params?: unknown }>}\n\t\t\tpage={current.page}\n\t\t\tpages={allPages}\n\t\t\tparams={current.params}\n\t\t/>\n\t);\n};\n\n// =============================================================================\n// Page Component\n// =============================================================================\n\nexport type PageProps<K extends keyof RouteRegistry = keyof RouteRegistry> = {\n\t/**\n\t * The route name for this page.\n\t */\n\tname: K;\n\t/**\n\t * The component to render for this page.\n\t */\n\tcomponent: React.ComponentType<{ params?: RouteRegistry[K] }>;\n};\n\n/**\n * Declarative way to register custom pages.\n * This component is collected by the Router and doesn't render anything itself.\n *\n * @example\n * <Support.Router>\n * <Support.Page name=\"FAQ\" component={FAQPage} />\n * </Support.Router>\n */\nexport const Page = <K extends keyof RouteRegistry>(_props: PageProps<K>) => {\n\t// This component is declarative and doesn't render anything.\n\t// The Router collects Page children and uses them for routing.\n\treturn null;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAM,eAAe;CACpB;EAAE,MAAM;EAAQ,WAAW;EAAU;CACrC;EAAE,MAAM;EAAY,WAAW;EAAc;CAC7C;EAAE,MAAM;EAAgB,WAAW;EAAkB;CACrD;EAAE,MAAM;EAAwB,WAAW;EAAyB;CACpE;;;;;AAMD,SAAS,yBAAyB,UAAyC;CAC1E,MAAMA,QAAsB,EAAE;AAE9B,SAAM,SAAS,QAAQ,WAAW,UAAU;AAC3C,MAAI,CAACC,QAAM,eAAe,MAAM,CAC/B;EAID,MAAM,QAAQ,MAAM;AAIpB,MAAI,MAAM,QAAQ,MAAM,UACvB,OAAM,KAAK;GACV,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,CAAC;GAEF;AAEF,QAAO;;;;;;;;;;;;;;;;;;;;;AAsBR,MAAaC,UAAiC,EAC7C,cAAc,EAAE,EAChB,eACK;CACL,MAAM,EAAE,YAAY,sBAAsB;CAG1C,MAAM,iBAAiBD,QAAM,cACtB,yBAAyB,SAAS,EACxC,CAAC,SAAS,CACV;CAGD,MAAM,WAAWA,QAAM,cAErB;EAAC,GAAG;EAAc,GAAG;EAAa,GAAG;EAAe,EAGrD,CAAC,aAAa,eAAe,CAC7B;AAED,QACC,oBAACE;EACA,UAAU;EACV,MAAM,QAAQ;EACd,OAAO;EACP,QAAQ,QAAQ;GACf;;;;;;;;;;;AA4BJ,MAAa,QAAuC,WAAyB;AAG5E,QAAO"}
@@ -1,2 +1,2 @@
1
- import { UseSupportStoreResult, initializeSupportStore, useSupportConfig, useSupportNavigation, useSupportStore } from "./support-store.js";
2
- export { UseSupportStoreResult, initializeSupportStore, useSupportConfig, useSupportNavigation, useSupportStore };
1
+ import { UseSupportConfigResult, UseSupportStoreResult, initializeSupportStore, useSupportConfig, useSupportNavigation, useSupportStore } from "./support-store.js";
2
+ export { UseSupportConfigResult, UseSupportStoreResult, initializeSupportStore, useSupportConfig, useSupportNavigation, useSupportStore };
@@ -1,4 +1,4 @@
1
- import * as _cossistant_core0 from "@cossistant/core";
1
+ import * as _cossistant_core3 from "@cossistant/core";
2
2
  import { SupportConfig, SupportStore, SupportStoreState } from "@cossistant/core";
3
3
 
4
4
  //#region src/support/store/support-store.d.ts
@@ -10,26 +10,32 @@ type UseSupportStoreResult = SupportStoreState & Pick<SupportStore, "navigate" |
10
10
  * const { isOpen, navigate, toggle } = useSupportStore();
11
11
  */
12
12
  declare function useSupportStore(): UseSupportStoreResult;
13
+ type UseSupportConfigResult = {
14
+ isOpen: boolean;
15
+ size: SupportConfig["size"];
16
+ open: () => void;
17
+ close: () => void;
18
+ toggle: () => void;
19
+ };
13
20
  /**
14
21
  * Access widget configuration (isOpen, size) and toggle helpers.
22
+ * Supports both controlled and uncontrolled modes.
23
+ *
24
+ * In controlled mode (when `open` prop is provided to Support),
25
+ * the `isOpen` state is driven by the prop, and `open`/`close`/`toggle`
26
+ * will call `onOpenChange` instead of updating internal state.
15
27
  *
16
28
  * @example
29
+ * // Uncontrolled (internal state)
17
30
  * const { isOpen, open, close, toggle } = useSupportConfig();
31
+ *
32
+ * @example
33
+ * // Controlled (external state via Support props)
34
+ * <Support open={isOpen} onOpenChange={setIsOpen}>
35
+ * <MyComponent />
36
+ * </Support>
18
37
  */
19
- declare const useSupportConfig: () => {
20
- open: () => void;
21
- close: () => void;
22
- toggle: () => void;
23
- size: "normal" | "larger";
24
- isOpen: boolean;
25
- content: {
26
- home?: {
27
- header?: string;
28
- subheader?: string;
29
- ctaLabel?: string;
30
- };
31
- };
32
- };
38
+ declare const useSupportConfig: () => UseSupportConfigResult;
33
39
  /**
34
40
  * Access navigation state and routing methods.
35
41
  *
@@ -37,15 +43,15 @@ declare const useSupportConfig: () => {
37
43
  * const { navigate, goBack, page, params } = useSupportNavigation();
38
44
  */
39
45
  declare const useSupportNavigation: () => {
40
- current: _cossistant_core0.NavigationState<_cossistant_core0.RouteRegistry>;
46
+ current: _cossistant_core3.NavigationState<_cossistant_core3.RouteRegistry>;
41
47
  page: "HOME" | "ARTICLES" | "CONVERSATION" | "CONVERSATION_HISTORY";
42
48
  params: {
43
49
  conversationId: string;
44
50
  initialMessage?: string;
45
51
  } | undefined;
46
- previousPages: _cossistant_core0.NavigationState<_cossistant_core0.RouteRegistry>[];
47
- navigate: (state: _cossistant_core0.NavigationState<_cossistant_core0.RouteRegistry>) => void;
48
- replace: (state: _cossistant_core0.NavigationState<_cossistant_core0.RouteRegistry>) => void;
52
+ previousPages: _cossistant_core3.NavigationState<_cossistant_core3.RouteRegistry>[];
53
+ navigate: (state: _cossistant_core3.NavigationState<_cossistant_core3.RouteRegistry>) => void;
54
+ replace: (state: _cossistant_core3.NavigationState<_cossistant_core3.RouteRegistry>) => void;
49
55
  goBack: () => void;
50
56
  canGoBack: boolean;
51
57
  };
@@ -57,5 +63,5 @@ declare const initializeSupportStore: (props: {
57
63
  defaultOpen?: boolean;
58
64
  }) => void;
59
65
  //#endregion
60
- export { UseSupportStoreResult, initializeSupportStore, useSupportConfig, useSupportNavigation, useSupportStore };
66
+ export { UseSupportConfigResult, UseSupportStoreResult, initializeSupportStore, useSupportConfig, useSupportNavigation, useSupportStore };
61
67
  //# sourceMappingURL=support-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"support-store.d.ts","names":[],"sources":["../../../src/support/store/support-store.ts"],"sourcesContent":[],"mappings":";;;;KA8CY,qBAAA,GAAwB,oBACnC,KACC;;;AAFF;;;;AACK,iBAkBW,eAAA,CAAA,CAlBX,EAkB8B,qBAlB9B;AAkBL;AAyBA;AAoBA;;;;cApBa;;;;;;EA0CA,OAAA,EAAA;;;;;;;;;;;;;;cAtBA;6CAiBZ,iBAAA,CAAA,aAAA;;;;;;;;;;;;;;;cAKY;SACL"}
1
+ {"version":3,"file":"support-store.d.ts","names":[],"sources":["../../../src/support/store/support-store.ts"],"sourcesContent":[],"mappings":";;;;KA+CY,qBAAA,GAAwB,oBACnC,KACC;;;AAFF;;;;AACK,iBAkBW,eAAA,CAAA,CAlBX,EAkB8B,qBAlB9B;AAkBW,KAmBJ,sBAAA,GAnBuB;EAmBvB,MAAA,EAAA,OAAA;EA0BC,IAAA,EAxBN,aAuEN,CAAA,MAAA,CAAA;EAQY,IAAA,EAAA,GAAA,GAAA,IAAA;EAiBZ,KAAA,EAAA,GAAA,GAAA,IAAA;;;;;;;;;AAKD;;;;;;;;;;;;cA7Ea,wBAAuB;;;;;;;cAuDvB;6CAiBZ,iBAAA,CAAA,aAAA;;;;;;;;;;;;;;;cAKY;SACL"}