@swisper.ai/web-chat-ui 0.0.2

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 (609) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +251 -0
  3. package/dist/components/canvas-shell/canvas-shell.d.ts +64 -0
  4. package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -0
  5. package/dist/components/canvas-shell/canvas-shell.stories.d.ts +26 -0
  6. package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -0
  7. package/dist/components/canvas-shell/index.d.ts +2 -0
  8. package/dist/components/canvas-shell/index.d.ts.map +1 -0
  9. package/dist/components/card-item-picker/card-item-picker-context.d.ts +21 -0
  10. package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +1 -0
  11. package/dist/components/card-item-picker/card-item-picker-list.d.ts +24 -0
  12. package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +1 -0
  13. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +28 -0
  14. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +1 -0
  15. package/dist/components/card-item-picker/card-item-picker-row.d.ts +12 -0
  16. package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +1 -0
  17. package/dist/components/card-item-picker/card-item-picker.stories.d.ts +19 -0
  18. package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +1 -0
  19. package/dist/components/card-item-picker/index.d.ts +9 -0
  20. package/dist/components/card-item-picker/index.d.ts.map +1 -0
  21. package/dist/components/chat-card/chat-card.d.ts +4 -0
  22. package/dist/components/chat-card/chat-card.d.ts.map +1 -0
  23. package/dist/components/chat-card/chat-card.stories.d.ts +11 -0
  24. package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -0
  25. package/dist/components/chat-card/components/chat-card-body.d.ts +22 -0
  26. package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -0
  27. package/dist/components/chat-card/components/chat-card-footer.d.ts +20 -0
  28. package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -0
  29. package/dist/components/chat-card/components/chat-card-form.d.ts +28 -0
  30. package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -0
  31. package/dist/components/chat-card/components/chat-card-header.d.ts +36 -0
  32. package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -0
  33. package/dist/components/chat-card/components/index.d.ts +5 -0
  34. package/dist/components/chat-card/components/index.d.ts.map +1 -0
  35. package/dist/components/chat-card/context.d.ts +13 -0
  36. package/dist/components/chat-card/context.d.ts.map +1 -0
  37. package/dist/components/chat-card/contexts.d.ts +16 -0
  38. package/dist/components/chat-card/contexts.d.ts.map +1 -0
  39. package/dist/components/chat-card/hooks.d.ts +13 -0
  40. package/dist/components/chat-card/hooks.d.ts.map +1 -0
  41. package/dist/components/chat-card/index.d.ts +6 -0
  42. package/dist/components/chat-card/index.d.ts.map +1 -0
  43. package/dist/components/chat-card/types.d.ts +21 -0
  44. package/dist/components/chat-card/types.d.ts.map +1 -0
  45. package/dist/components/chat-card-container/chat-card-container.d.ts +43 -0
  46. package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -0
  47. package/dist/components/chat-card-container/chat-card-container.stories.d.ts +17 -0
  48. package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -0
  49. package/dist/components/chat-card-container/index.d.ts +3 -0
  50. package/dist/components/chat-card-container/index.d.ts.map +1 -0
  51. package/dist/components/chat-container/chat-container.d.ts +51 -0
  52. package/dist/components/chat-container/chat-container.d.ts.map +1 -0
  53. package/dist/components/chat-container/chat-container.stories.d.ts +21 -0
  54. package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -0
  55. package/dist/components/chat-container/index.d.ts +3 -0
  56. package/dist/components/chat-container/index.d.ts.map +1 -0
  57. package/dist/components/chat-input/chat-input.d.ts +35 -0
  58. package/dist/components/chat-input/chat-input.d.ts.map +1 -0
  59. package/dist/components/chat-input/chat-input.stories.d.ts +14 -0
  60. package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -0
  61. package/dist/components/chat-input/index.d.ts +3 -0
  62. package/dist/components/chat-input/index.d.ts.map +1 -0
  63. package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts +8 -0
  64. package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts.map +1 -0
  65. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +6 -0
  66. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -0
  67. package/dist/components/chat-input/plugins/disabled-plugin.d.ts +7 -0
  68. package/dist/components/chat-input/plugins/disabled-plugin.d.ts.map +1 -0
  69. package/dist/components/chat-input/plugins/focus-plugin.d.ts +6 -0
  70. package/dist/components/chat-input/plugins/focus-plugin.d.ts.map +1 -0
  71. package/dist/components/chat-input/plugins/has-value-plugin.d.ts +6 -0
  72. package/dist/components/chat-input/plugins/has-value-plugin.d.ts.map +1 -0
  73. package/dist/components/chat-input/plugins/hooks.d.ts +2 -0
  74. package/dist/components/chat-input/plugins/hooks.d.ts.map +1 -0
  75. package/dist/components/chat-input/plugins/index.d.ts +8 -0
  76. package/dist/components/chat-input/plugins/index.d.ts.map +1 -0
  77. package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts +2 -0
  78. package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
  79. package/dist/components/chat-input/plugins/utils.d.ts +4 -0
  80. package/dist/components/chat-input/plugins/utils.d.ts.map +1 -0
  81. package/dist/components/chat-input/plugins/value-plugin.d.ts +6 -0
  82. package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -0
  83. package/dist/components/chat-input/transformers.d.ts +3 -0
  84. package/dist/components/chat-input/transformers.d.ts.map +1 -0
  85. package/dist/components/chat-list/chat-list-item.d.ts +8 -0
  86. package/dist/components/chat-list/chat-list-item.d.ts.map +1 -0
  87. package/dist/components/chat-list/chat-list-items.d.ts +11 -0
  88. package/dist/components/chat-list/chat-list-items.d.ts.map +1 -0
  89. package/dist/components/chat-list/chat-list.d.ts +63 -0
  90. package/dist/components/chat-list/chat-list.d.ts.map +1 -0
  91. package/dist/components/chat-list/chat-list.stories.d.ts +13 -0
  92. package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -0
  93. package/dist/components/chat-list/index.d.ts +4 -0
  94. package/dist/components/chat-list/index.d.ts.map +1 -0
  95. package/dist/components/chat-message/chat-message.d.ts +17 -0
  96. package/dist/components/chat-message/chat-message.d.ts.map +1 -0
  97. package/dist/components/chat-message/chat-message.stories.d.ts +11 -0
  98. package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -0
  99. package/dist/components/chat-message/index.d.ts +2 -0
  100. package/dist/components/chat-message/index.d.ts.map +1 -0
  101. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +9 -0
  102. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -0
  103. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +30 -0
  104. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -0
  105. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +11 -0
  106. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -0
  107. package/dist/components/chat-message-attachment-card/index.d.ts +4 -0
  108. package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -0
  109. package/dist/components/chat-message-attachment-card/utils.d.ts +5 -0
  110. package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -0
  111. package/dist/components/chat-message-history/chat-message-history.d.ts +48 -0
  112. package/dist/components/chat-message-history/chat-message-history.d.ts.map +1 -0
  113. package/dist/components/chat-message-history/chat-message-history.stories.d.ts +7 -0
  114. package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +1 -0
  115. package/dist/components/chat-message-history/index.d.ts +2 -0
  116. package/dist/components/chat-message-history/index.d.ts.map +1 -0
  117. package/dist/components/chat-message-response/chat-message-response.d.ts +7 -0
  118. package/dist/components/chat-message-response/chat-message-response.d.ts.map +1 -0
  119. package/dist/components/chat-message-response/chat-message-response.stories.d.ts +7 -0
  120. package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -0
  121. package/dist/components/chat-message-response/index.d.ts +2 -0
  122. package/dist/components/chat-message-response/index.d.ts.map +1 -0
  123. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +25 -0
  124. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -0
  125. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +7 -0
  126. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -0
  127. package/dist/components/chat-message-toolbar/index.d.ts +2 -0
  128. package/dist/components/chat-message-toolbar/index.d.ts.map +1 -0
  129. package/dist/components/chat-messages/chat-messages.d.ts +24 -0
  130. package/dist/components/chat-messages/chat-messages.d.ts.map +1 -0
  131. package/dist/components/chat-messages/chat-messages.stories.d.ts +8 -0
  132. package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -0
  133. package/dist/components/chat-messages/index.d.ts +2 -0
  134. package/dist/components/chat-messages/index.d.ts.map +1 -0
  135. package/dist/components/chat-notification-card/chat-notification-card.d.ts +114 -0
  136. package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -0
  137. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +10 -0
  138. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -0
  139. package/dist/components/chat-notification-card/index.d.ts +4 -0
  140. package/dist/components/chat-notification-card/index.d.ts.map +1 -0
  141. package/dist/components/chat-notification-card/types.d.ts +2 -0
  142. package/dist/components/chat-notification-card/types.d.ts.map +1 -0
  143. package/dist/components/chat-notification-card/utils.d.ts +3 -0
  144. package/dist/components/chat-notification-card/utils.d.ts.map +1 -0
  145. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +12 -0
  146. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -0
  147. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +8 -0
  148. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -0
  149. package/dist/components/chat-notification-popup/index.d.ts +2 -0
  150. package/dist/components/chat-notification-popup/index.d.ts.map +1 -0
  151. package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts +17 -0
  152. package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts.map +1 -0
  153. package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts +2 -0
  154. package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts.map +1 -0
  155. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +27 -0
  156. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -0
  157. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +9 -0
  158. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -0
  159. package/dist/components/chat-prompt-box/index.d.ts +3 -0
  160. package/dist/components/chat-prompt-box/index.d.ts.map +1 -0
  161. package/dist/components/chat-reply/chat-reply.d.ts +23 -0
  162. package/dist/components/chat-reply/chat-reply.d.ts.map +1 -0
  163. package/dist/components/chat-reply/chat-reply.stories.d.ts +7 -0
  164. package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -0
  165. package/dist/components/chat-reply/index.d.ts +2 -0
  166. package/dist/components/chat-reply/index.d.ts.map +1 -0
  167. package/dist/components/chat-suggestion/chat-suggestion.d.ts +37 -0
  168. package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -0
  169. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +9 -0
  170. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -0
  171. package/dist/components/chat-suggestion/index.d.ts +2 -0
  172. package/dist/components/chat-suggestion/index.d.ts.map +1 -0
  173. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +47 -0
  174. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -0
  175. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +10 -0
  176. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -0
  177. package/dist/components/chat-thinking-process/index.d.ts +2 -0
  178. package/dist/components/chat-thinking-process/index.d.ts.map +1 -0
  179. package/dist/components/chat-thread/chat-thread.d.ts +78 -0
  180. package/dist/components/chat-thread/chat-thread.d.ts.map +1 -0
  181. package/dist/components/chat-thread/chat-thread.stories.d.ts +14 -0
  182. package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -0
  183. package/dist/components/chat-thread/index.d.ts +2 -0
  184. package/dist/components/chat-thread/index.d.ts.map +1 -0
  185. package/dist/components/deprecated-empty-state.d.ts +22 -0
  186. package/dist/components/deprecated-empty-state.d.ts.map +1 -0
  187. package/dist/components/index.d.ts +27 -0
  188. package/dist/components/index.d.ts.map +1 -0
  189. package/dist/components/markdown-viewer/hooks.d.ts +9 -0
  190. package/dist/components/markdown-viewer/hooks.d.ts.map +1 -0
  191. package/dist/components/markdown-viewer/index.d.ts +3 -0
  192. package/dist/components/markdown-viewer/index.d.ts.map +1 -0
  193. package/dist/components/markdown-viewer/markdown-viewer.d.ts +10 -0
  194. package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -0
  195. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +9 -0
  196. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -0
  197. package/dist/components/markdown-viewer/types.d.ts +9 -0
  198. package/dist/components/markdown-viewer/types.d.ts.map +1 -0
  199. package/dist/components/markdown-viewer/utils.d.ts +3 -0
  200. package/dist/components/markdown-viewer/utils.d.ts.map +1 -0
  201. package/dist/components/new-chat-trigger/index.d.ts +2 -0
  202. package/dist/components/new-chat-trigger/index.d.ts.map +1 -0
  203. package/dist/components/new-chat-trigger/new-chat-trigger.d.ts +8 -0
  204. package/dist/components/new-chat-trigger/new-chat-trigger.d.ts.map +1 -0
  205. package/dist/components/rich-text-area/constants/index.d.ts +3 -0
  206. package/dist/components/rich-text-area/constants/index.d.ts.map +1 -0
  207. package/dist/components/rich-text-area/hooks.d.ts +3 -0
  208. package/dist/components/rich-text-area/hooks.d.ts.map +1 -0
  209. package/dist/components/rich-text-area/html-config.d.ts +4 -0
  210. package/dist/components/rich-text-area/html-config.d.ts.map +1 -0
  211. package/dist/components/rich-text-area/index.d.ts +7 -0
  212. package/dist/components/rich-text-area/index.d.ts.map +1 -0
  213. package/dist/components/rich-text-area/nodes/div-block-node.d.ts +18 -0
  214. package/dist/components/rich-text-area/nodes/div-block-node.d.ts.map +1 -0
  215. package/dist/components/rich-text-area/nodes/image-node.d.ts +24 -0
  216. package/dist/components/rich-text-area/nodes/image-node.d.ts.map +1 -0
  217. package/dist/components/rich-text-area/plugins/blur-plugin.d.ts +6 -0
  218. package/dist/components/rich-text-area/plugins/blur-plugin.d.ts.map +1 -0
  219. package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts +7 -0
  220. package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts.map +1 -0
  221. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +7 -0
  222. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -0
  223. package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts +6 -0
  224. package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts.map +1 -0
  225. package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts +10 -0
  226. package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts.map +1 -0
  227. package/dist/components/rich-text-area/plugins/focus-plugin.d.ts +6 -0
  228. package/dist/components/rich-text-area/plugins/focus-plugin.d.ts.map +1 -0
  229. package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts +19 -0
  230. package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts.map +1 -0
  231. package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts +12 -0
  232. package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts.map +1 -0
  233. package/dist/components/rich-text-area/plugins/index.d.ts +11 -0
  234. package/dist/components/rich-text-area/plugins/index.d.ts.map +1 -0
  235. package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts +2 -0
  236. package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
  237. package/dist/components/rich-text-area/plugins/value-plugin.d.ts +7 -0
  238. package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -0
  239. package/dist/components/rich-text-area/rich-text-area.d.ts +20 -0
  240. package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -0
  241. package/dist/components/rich-text-area/rich-text-area.stories.d.ts +7 -0
  242. package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -0
  243. package/dist/components/rich-text-area/styled.d.ts +3 -0
  244. package/dist/components/rich-text-area/styled.d.ts.map +1 -0
  245. package/dist/components/rich-text-area/transformers.d.ts +16 -0
  246. package/dist/components/rich-text-area/transformers.d.ts.map +1 -0
  247. package/dist/components/rich-text-area/types.d.ts +8 -0
  248. package/dist/components/rich-text-area/types.d.ts.map +1 -0
  249. package/dist/components/rich-text-area/utils/index.d.ts +6 -0
  250. package/dist/components/rich-text-area/utils/index.d.ts.map +1 -0
  251. package/dist/components/rich-text-field/components/alignment-select.d.ts +5 -0
  252. package/dist/components/rich-text-field/components/alignment-select.d.ts.map +1 -0
  253. package/dist/components/rich-text-field/components/attachment-button.d.ts +3 -0
  254. package/dist/components/rich-text-field/components/attachment-button.d.ts.map +1 -0
  255. package/dist/components/rich-text-field/components/bold-button.d.ts +3 -0
  256. package/dist/components/rich-text-field/components/bold-button.d.ts.map +1 -0
  257. package/dist/components/rich-text-field/components/clean-format-button.d.ts +3 -0
  258. package/dist/components/rich-text-field/components/clean-format-button.d.ts.map +1 -0
  259. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +11 -0
  260. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -0
  261. package/dist/components/rich-text-field/components/image-button.d.ts +3 -0
  262. package/dist/components/rich-text-field/components/image-button.d.ts.map +1 -0
  263. package/dist/components/rich-text-field/components/index.d.ts +14 -0
  264. package/dist/components/rich-text-field/components/index.d.ts.map +1 -0
  265. package/dist/components/rich-text-field/components/italic-button.d.ts +3 -0
  266. package/dist/components/rich-text-field/components/italic-button.d.ts.map +1 -0
  267. package/dist/components/rich-text-field/components/link-button.d.ts +3 -0
  268. package/dist/components/rich-text-field/components/link-button.d.ts.map +1 -0
  269. package/dist/components/rich-text-field/components/size-select.d.ts +5 -0
  270. package/dist/components/rich-text-field/components/size-select.d.ts.map +1 -0
  271. package/dist/components/rich-text-field/components/text-color-button.d.ts +3 -0
  272. package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -0
  273. package/dist/components/rich-text-field/components/toolbar-button.d.ts +6 -0
  274. package/dist/components/rich-text-field/components/toolbar-button.d.ts.map +1 -0
  275. package/dist/components/rich-text-field/components/toolbar-select.d.ts +5 -0
  276. package/dist/components/rich-text-field/components/toolbar-select.d.ts.map +1 -0
  277. package/dist/components/rich-text-field/components/typography-select.d.ts +5 -0
  278. package/dist/components/rich-text-field/components/typography-select.d.ts.map +1 -0
  279. package/dist/components/rich-text-field/components/underline-button.d.ts +3 -0
  280. package/dist/components/rich-text-field/components/underline-button.d.ts.map +1 -0
  281. package/dist/components/rich-text-field/constants.d.ts +57 -0
  282. package/dist/components/rich-text-field/constants.d.ts.map +1 -0
  283. package/dist/components/rich-text-field/context.d.ts +26 -0
  284. package/dist/components/rich-text-field/context.d.ts.map +1 -0
  285. package/dist/components/rich-text-field/index.d.ts +3 -0
  286. package/dist/components/rich-text-field/index.d.ts.map +1 -0
  287. package/dist/components/rich-text-field/rich-text-field.d.ts +17 -0
  288. package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -0
  289. package/dist/components/rich-text-field/rich-text-field.stories.d.ts +10 -0
  290. package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -0
  291. package/dist/components/rich-text-field/utils.d.ts +1759 -0
  292. package/dist/components/rich-text-field/utils.d.ts.map +1 -0
  293. package/dist/components/spinner/index.d.ts +2 -0
  294. package/dist/components/spinner/index.d.ts.map +1 -0
  295. package/dist/components/spinner/spinner.d.ts +9 -0
  296. package/dist/components/spinner/spinner.d.ts.map +1 -0
  297. package/dist/components/spinner/spinner.stories.d.ts +8 -0
  298. package/dist/components/spinner/spinner.stories.d.ts.map +1 -0
  299. package/dist/contexts/chat-context/chat-context.d.ts +20 -0
  300. package/dist/contexts/chat-context/chat-context.d.ts.map +1 -0
  301. package/dist/contexts/chat-context/index.d.ts +2 -0
  302. package/dist/contexts/chat-context/index.d.ts.map +1 -0
  303. package/dist/contexts/chat-context/utils.d.ts +3 -0
  304. package/dist/contexts/chat-context/utils.d.ts.map +1 -0
  305. package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts +20 -0
  306. package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts.map +1 -0
  307. package/dist/contexts/chat-conversation-context/index.d.ts +2 -0
  308. package/dist/contexts/chat-conversation-context/index.d.ts.map +1 -0
  309. package/dist/contexts/index.d.ts +3 -0
  310. package/dist/contexts/index.d.ts.map +1 -0
  311. package/dist/docs/agent.stories.d.ts +41 -0
  312. package/dist/docs/agent.stories.d.ts.map +1 -0
  313. package/dist/docs/chat-panel.d.ts +33 -0
  314. package/dist/docs/chat-panel.d.ts.map +1 -0
  315. package/dist/docs/chatbot-panel.d.ts +20 -0
  316. package/dist/docs/chatbot-panel.d.ts.map +1 -0
  317. package/dist/docs/chatbot.stories.d.ts +11 -0
  318. package/dist/docs/chatbot.stories.d.ts.map +1 -0
  319. package/dist/domain/actions/constants.d.ts +2 -0
  320. package/dist/domain/actions/constants.d.ts.map +1 -0
  321. package/dist/domain/actions/hooks/index.d.ts +3 -0
  322. package/dist/domain/actions/hooks/index.d.ts.map +1 -0
  323. package/dist/domain/actions/index.d.ts +5 -0
  324. package/dist/domain/actions/index.d.ts.map +1 -0
  325. package/dist/domain/actions/types.d.ts +7 -0
  326. package/dist/domain/actions/types.d.ts.map +1 -0
  327. package/dist/domain/actions/utils/index.d.ts +11 -0
  328. package/dist/domain/actions/utils/index.d.ts.map +1 -0
  329. package/dist/domain/index.d.ts +2 -0
  330. package/dist/domain/index.d.ts.map +1 -0
  331. package/dist/hooks/index.d.ts +7 -0
  332. package/dist/hooks/index.d.ts.map +1 -0
  333. package/dist/hooks/use-chat-prompt-placeholder.d.ts +6 -0
  334. package/dist/hooks/use-chat-prompt-placeholder.d.ts.map +1 -0
  335. package/dist/hooks/use-chat-stream-message.d.ts +42 -0
  336. package/dist/hooks/use-chat-stream-message.d.ts.map +1 -0
  337. package/dist/hooks/use-current-chat-id.d.ts +2 -0
  338. package/dist/hooks/use-current-chat-id.d.ts.map +1 -0
  339. package/dist/hooks/use-is-current-chat-new.d.ts +2 -0
  340. package/dist/hooks/use-is-current-chat-new.d.ts.map +1 -0
  341. package/dist/hooks/use-loaded-chat-ids.d.ts +9 -0
  342. package/dist/hooks/use-loaded-chat-ids.d.ts.map +1 -0
  343. package/dist/hooks/use-on-chat-changed.d.ts +9 -0
  344. package/dist/hooks/use-on-chat-changed.d.ts.map +1 -0
  345. package/dist/index.css +2 -0
  346. package/dist/index.d.ts +7 -0
  347. package/dist/index.d.ts.map +1 -0
  348. package/dist/index.es.js +4404 -0
  349. package/dist/index.es.js.map +1 -0
  350. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +95 -0
  351. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -0
  352. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +24 -0
  353. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -0
  354. package/dist/layouts/chat-card-list-layout/index.d.ts +3 -0
  355. package/dist/layouts/chat-card-list-layout/index.d.ts.map +1 -0
  356. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts +84 -0
  357. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts.map +1 -0
  358. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts +45 -0
  359. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts.map +1 -0
  360. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +37 -0
  361. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -0
  362. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts +81 -0
  363. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts.map +1 -0
  364. package/dist/layouts/chat-card-three-column-layout/index.d.ts +5 -0
  365. package/dist/layouts/chat-card-three-column-layout/index.d.ts.map +1 -0
  366. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +31 -0
  367. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -0
  368. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts +12 -0
  369. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts.map +1 -0
  370. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +19 -0
  371. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -0
  372. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts +35 -0
  373. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts.map +1 -0
  374. package/dist/layouts/chat-card-two-column-layout/index.d.ts +4 -0
  375. package/dist/layouts/chat-card-two-column-layout/index.d.ts.map +1 -0
  376. package/dist/layouts/index.d.ts +4 -0
  377. package/dist/layouts/index.d.ts.map +1 -0
  378. package/dist/types.d.ts +22 -0
  379. package/dist/types.d.ts.map +1 -0
  380. package/dist/utils/use-streaming-markdown.d.ts +18 -0
  381. package/dist/utils/use-streaming-markdown.d.ts.map +1 -0
  382. package/package.json +155 -0
  383. package/src/__tests__/setup.ts +5 -0
  384. package/src/components/canvas-shell/canvas-shell.json +126 -0
  385. package/src/components/canvas-shell/canvas-shell.stories.tsx +194 -0
  386. package/src/components/canvas-shell/canvas-shell.test.tsx +205 -0
  387. package/src/components/canvas-shell/canvas-shell.tsx +250 -0
  388. package/src/components/canvas-shell/index.ts +19 -0
  389. package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +279 -0
  390. package/src/components/card-item-picker/card-item-picker-context.tsx +44 -0
  391. package/src/components/card-item-picker/card-item-picker-list.tsx +95 -0
  392. package/src/components/card-item-picker/card-item-picker-row-parts.tsx +96 -0
  393. package/src/components/card-item-picker/card-item-picker-row.tsx +109 -0
  394. package/src/components/card-item-picker/card-item-picker.json +147 -0
  395. package/src/components/card-item-picker/card-item-picker.stories.tsx +158 -0
  396. package/src/components/card-item-picker/index.ts +24 -0
  397. package/src/components/chat-card/__tests__/chat-card.spec.tsx +118 -0
  398. package/src/components/chat-card/chat-card.json +162 -0
  399. package/src/components/chat-card/chat-card.stories.tsx +349 -0
  400. package/src/components/chat-card/chat-card.tsx +106 -0
  401. package/src/components/chat-card/components/chat-card-body.tsx +115 -0
  402. package/src/components/chat-card/components/chat-card-footer.tsx +95 -0
  403. package/src/components/chat-card/components/chat-card-form.tsx +120 -0
  404. package/src/components/chat-card/components/chat-card-header.tsx +240 -0
  405. package/src/components/chat-card/components/index.ts +4 -0
  406. package/src/components/chat-card/context.tsx +34 -0
  407. package/src/components/chat-card/contexts.tsx +42 -0
  408. package/src/components/chat-card/hooks.ts +51 -0
  409. package/src/components/chat-card/index.ts +5 -0
  410. package/src/components/chat-card/types.ts +23 -0
  411. package/src/components/chat-card-container/chat-card-container.json +84 -0
  412. package/src/components/chat-card-container/chat-card-container.stories.tsx +149 -0
  413. package/src/components/chat-card-container/chat-card-container.tsx +75 -0
  414. package/src/components/chat-card-container/index.ts +2 -0
  415. package/src/components/chat-container/chat-container.json +93 -0
  416. package/src/components/chat-container/chat-container.stories.tsx +179 -0
  417. package/src/components/chat-container/chat-container.tsx +231 -0
  418. package/src/components/chat-container/index.ts +2 -0
  419. package/src/components/chat-input/chat-input.json +106 -0
  420. package/src/components/chat-input/chat-input.stories.tsx +291 -0
  421. package/src/components/chat-input/chat-input.tsx +220 -0
  422. package/src/components/chat-input/index.ts +2 -0
  423. package/src/components/chat-input/plugins/auto-focus-plugin.tsx +43 -0
  424. package/src/components/chat-input/plugins/controlled-value-plugin.tsx +47 -0
  425. package/src/components/chat-input/plugins/disabled-plugin.tsx +18 -0
  426. package/src/components/chat-input/plugins/focus-plugin.tsx +44 -0
  427. package/src/components/chat-input/plugins/has-value-plugin.tsx +51 -0
  428. package/src/components/chat-input/plugins/hooks.ts +7 -0
  429. package/src/components/chat-input/plugins/index.ts +7 -0
  430. package/src/components/chat-input/plugins/markdown-plain-paste-plugin.tsx +63 -0
  431. package/src/components/chat-input/plugins/utils.ts +48 -0
  432. package/src/components/chat-input/plugins/value-plugin.tsx +35 -0
  433. package/src/components/chat-input/transformers.ts +4 -0
  434. package/src/components/chat-list/chat-list-item.tsx +33 -0
  435. package/src/components/chat-list/chat-list-items.tsx +144 -0
  436. package/src/components/chat-list/chat-list.json +117 -0
  437. package/src/components/chat-list/chat-list.stories.tsx +332 -0
  438. package/src/components/chat-list/chat-list.tsx +278 -0
  439. package/src/components/chat-list/index.ts +18 -0
  440. package/src/components/chat-message/chat-message.json +105 -0
  441. package/src/components/chat-message/chat-message.stories.tsx +95 -0
  442. package/src/components/chat-message/chat-message.tsx +66 -0
  443. package/src/components/chat-message/index.ts +1 -0
  444. package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +74 -0
  445. package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +110 -0
  446. package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +131 -0
  447. package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +142 -0
  448. package/src/components/chat-message-attachment-card/index.ts +12 -0
  449. package/src/components/chat-message-attachment-card/utils.ts +41 -0
  450. package/src/components/chat-message-history/chat-message-history.json +99 -0
  451. package/src/components/chat-message-history/chat-message-history.stories.tsx +136 -0
  452. package/src/components/chat-message-history/chat-message-history.tsx +277 -0
  453. package/src/components/chat-message-history/index.ts +13 -0
  454. package/src/components/chat-message-response/chat-message-response.json +68 -0
  455. package/src/components/chat-message-response/chat-message-response.stories.tsx +63 -0
  456. package/src/components/chat-message-response/chat-message-response.tsx +24 -0
  457. package/src/components/chat-message-response/index.ts +1 -0
  458. package/src/components/chat-message-toolbar/chat-message-toolbar.json +100 -0
  459. package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +62 -0
  460. package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +97 -0
  461. package/src/components/chat-message-toolbar/index.ts +6 -0
  462. package/src/components/chat-messages/chat-messages.json +95 -0
  463. package/src/components/chat-messages/chat-messages.stories.tsx +284 -0
  464. package/src/components/chat-messages/chat-messages.tsx +264 -0
  465. package/src/components/chat-messages/index.ts +10 -0
  466. package/src/components/chat-notification-card/chat-notification-card.json +135 -0
  467. package/src/components/chat-notification-card/chat-notification-card.stories.tsx +290 -0
  468. package/src/components/chat-notification-card/chat-notification-card.tsx +684 -0
  469. package/src/components/chat-notification-card/index.ts +3 -0
  470. package/src/components/chat-notification-card/types.ts +1 -0
  471. package/src/components/chat-notification-card/utils.ts +34 -0
  472. package/src/components/chat-notification-popup/chat-notification-popup.json +97 -0
  473. package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +80 -0
  474. package/src/components/chat-notification-popup/chat-notification-popup.tsx +36 -0
  475. package/src/components/chat-notification-popup/index.ts +1 -0
  476. package/src/components/chat-prompt-box/chat-prompt-box-context.tsx +62 -0
  477. package/src/components/chat-prompt-box/chat-prompt-box-focus-plugin.tsx +22 -0
  478. package/src/components/chat-prompt-box/chat-prompt-box.json +106 -0
  479. package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +117 -0
  480. package/src/components/chat-prompt-box/chat-prompt-box.tsx +296 -0
  481. package/src/components/chat-prompt-box/index.ts +16 -0
  482. package/src/components/chat-reply/chat-reply.json +79 -0
  483. package/src/components/chat-reply/chat-reply.stories.tsx +72 -0
  484. package/src/components/chat-reply/chat-reply.tsx +103 -0
  485. package/src/components/chat-reply/index.ts +1 -0
  486. package/src/components/chat-suggestion/chat-suggestion.json +108 -0
  487. package/src/components/chat-suggestion/chat-suggestion.stories.tsx +147 -0
  488. package/src/components/chat-suggestion/chat-suggestion.tsx +184 -0
  489. package/src/components/chat-suggestion/index.ts +8 -0
  490. package/src/components/chat-thinking-process/chat-thinking-process.json +110 -0
  491. package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +202 -0
  492. package/src/components/chat-thinking-process/chat-thinking-process.tsx +268 -0
  493. package/src/components/chat-thinking-process/index.ts +9 -0
  494. package/src/components/chat-thread/__tests__/chat-thread.spec.tsx +385 -0
  495. package/src/components/chat-thread/chat-thread.json +120 -0
  496. package/src/components/chat-thread/chat-thread.stories.tsx +218 -0
  497. package/src/components/chat-thread/chat-thread.tsx +549 -0
  498. package/src/components/chat-thread/index.ts +18 -0
  499. package/src/components/deprecated-empty-state.ts +39 -0
  500. package/src/components/index.ts +26 -0
  501. package/src/components/markdown-viewer/hooks.ts +59 -0
  502. package/src/components/markdown-viewer/index.ts +2 -0
  503. package/src/components/markdown-viewer/markdown-viewer.json +84 -0
  504. package/src/components/markdown-viewer/markdown-viewer.stories.tsx +110 -0
  505. package/src/components/markdown-viewer/markdown-viewer.tsx +95 -0
  506. package/src/components/markdown-viewer/types.ts +10 -0
  507. package/src/components/markdown-viewer/utils.ts +5 -0
  508. package/src/components/new-chat-trigger/index.ts +1 -0
  509. package/src/components/new-chat-trigger/new-chat-trigger.tsx +29 -0
  510. package/src/components/rich-text-area/constants/index.ts +10 -0
  511. package/src/components/rich-text-area/hooks.ts +24 -0
  512. package/src/components/rich-text-area/html-config.ts +195 -0
  513. package/src/components/rich-text-area/index.ts +6 -0
  514. package/src/components/rich-text-area/nodes/div-block-node.tsx +145 -0
  515. package/src/components/rich-text-area/nodes/image-node.tsx +100 -0
  516. package/src/components/rich-text-area/plugins/blur-plugin.tsx +36 -0
  517. package/src/components/rich-text-area/plugins/controlled-plugin.tsx +23 -0
  518. package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +101 -0
  519. package/src/components/rich-text-area/plugins/disabled-plugin.tsx +17 -0
  520. package/src/components/rich-text-area/plugins/file-attachment-plugin.tsx +57 -0
  521. package/src/components/rich-text-area/plugins/focus-plugin.tsx +44 -0
  522. package/src/components/rich-text-area/plugins/html-paste-plugin.tsx +104 -0
  523. package/src/components/rich-text-area/plugins/image-drop-plugin.tsx +56 -0
  524. package/src/components/rich-text-area/plugins/index.ts +10 -0
  525. package/src/components/rich-text-area/plugins/markdown-plain-paste-plugin.tsx +63 -0
  526. package/src/components/rich-text-area/plugins/value-plugin.tsx +46 -0
  527. package/src/components/rich-text-area/rich-text-area.json +102 -0
  528. package/src/components/rich-text-area/rich-text-area.stories.tsx +140 -0
  529. package/src/components/rich-text-area/rich-text-area.tsx +156 -0
  530. package/src/components/rich-text-area/styled.tsx +20 -0
  531. package/src/components/rich-text-area/transformers.ts +175 -0
  532. package/src/components/rich-text-area/types.ts +8 -0
  533. package/src/components/rich-text-area/utils/index.ts +77 -0
  534. package/src/components/rich-text-field/components/alignment-select.tsx +103 -0
  535. package/src/components/rich-text-field/components/attachment-button.tsx +25 -0
  536. package/src/components/rich-text-field/components/bold-button.tsx +21 -0
  537. package/src/components/rich-text-field/components/clean-format-button.tsx +44 -0
  538. package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +69 -0
  539. package/src/components/rich-text-field/components/image-button.tsx +11 -0
  540. package/src/components/rich-text-field/components/index.ts +14 -0
  541. package/src/components/rich-text-field/components/italic-button.tsx +21 -0
  542. package/src/components/rich-text-field/components/link-button.tsx +11 -0
  543. package/src/components/rich-text-field/components/size-select.tsx +27 -0
  544. package/src/components/rich-text-field/components/text-color-button.tsx +41 -0
  545. package/src/components/rich-text-field/components/toolbar-button.tsx +27 -0
  546. package/src/components/rich-text-field/components/toolbar-select.tsx +19 -0
  547. package/src/components/rich-text-field/components/typography-select.tsx +27 -0
  548. package/src/components/rich-text-field/components/underline-button.tsx +21 -0
  549. package/src/components/rich-text-field/constants.ts +33 -0
  550. package/src/components/rich-text-field/context.tsx +251 -0
  551. package/src/components/rich-text-field/index.tsx +6 -0
  552. package/src/components/rich-text-field/rich-text-field.json +118 -0
  553. package/src/components/rich-text-field/rich-text-field.stories.tsx +218 -0
  554. package/src/components/rich-text-field/rich-text-field.tsx +93 -0
  555. package/src/components/rich-text-field/utils.ts +532 -0
  556. package/src/components/spinner/index.ts +1 -0
  557. package/src/components/spinner/spinner.json +73 -0
  558. package/src/components/spinner/spinner.stories.tsx +41 -0
  559. package/src/components/spinner/spinner.tsx +32 -0
  560. package/src/contexts/chat-context/chat-context.tsx +97 -0
  561. package/src/contexts/chat-context/index.ts +1 -0
  562. package/src/contexts/chat-context/utils.ts +7 -0
  563. package/src/contexts/chat-conversation-context/chat-conversation-context.tsx +608 -0
  564. package/src/contexts/chat-conversation-context/index.ts +1 -0
  565. package/src/contexts/index.ts +2 -0
  566. package/src/docs/agent.stories.tsx +567 -0
  567. package/src/docs/chat-panel.tsx +174 -0
  568. package/src/docs/chatbot-panel.tsx +381 -0
  569. package/src/docs/chatbot.mdx +144 -0
  570. package/src/docs/chatbot.stories.tsx +63 -0
  571. package/src/domain/actions/constants.ts +1 -0
  572. package/src/domain/actions/hooks/index.ts +22 -0
  573. package/src/domain/actions/index.ts +4 -0
  574. package/src/domain/actions/types.ts +6 -0
  575. package/src/domain/actions/utils/index.ts +112 -0
  576. package/src/domain/index.ts +1 -0
  577. package/src/hooks/index.tsx +10 -0
  578. package/src/hooks/use-chat-prompt-placeholder.ts +7 -0
  579. package/src/hooks/use-chat-stream-message.ts +189 -0
  580. package/src/hooks/use-current-chat-id.ts +6 -0
  581. package/src/hooks/use-is-current-chat-new.ts +6 -0
  582. package/src/hooks/use-loaded-chat-ids.ts +32 -0
  583. package/src/hooks/use-on-chat-changed.ts +33 -0
  584. package/src/index.css +1 -0
  585. package/src/index.ts +6 -0
  586. package/src/layouts/chat-card-list-layout/__tests__/chat-card-list-layout.spec.tsx +204 -0
  587. package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +116 -0
  588. package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +190 -0
  589. package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +250 -0
  590. package/src/layouts/chat-card-list-layout/index.ts +11 -0
  591. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.sizing.test.ts +73 -0
  592. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +282 -0
  593. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +131 -0
  594. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +78 -0
  595. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +273 -0
  596. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +291 -0
  597. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +135 -0
  598. package/src/layouts/chat-card-three-column-layout/index.ts +24 -0
  599. package/src/layouts/chat-card-two-column-layout/__tests__/chat-card-two-column-layout.spec.tsx +109 -0
  600. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +97 -0
  601. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts +21 -0
  602. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +138 -0
  603. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +132 -0
  604. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts +65 -0
  605. package/src/layouts/chat-card-two-column-layout/index.ts +17 -0
  606. package/src/layouts/index.ts +3 -0
  607. package/src/types.ts +29 -0
  608. package/src/utils/use-streaming-markdown.ts +113 -0
  609. package/tailwind.css +7 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","names":["cn","_Fragment","cn","cn","cn","cn","cn","cn","cn","cn","cn","EXPORT_TRANSFORMERS","IMPORT_TRANSFORMERS","$setSelectionToEnd","ControlledValuePlugin","EXPORT_TRANSFORMERS","IMPORT_TRANSFORMERS","DisabledPlugin","FocusPlugin","MarkdownPlainPastePlugin","ValuePlugin","EXPORT_TRANSFORMERS","cn","DisabledPlugin","ControlledValuePlugin","ValuePlugin","MarkdownPlainPastePlugin","FocusPlugin","cn","cn","cn","cn","_Fragment","cn","cn","cn","cn","cn","cn","cn","cn","cn","cn","MessageScrollerPrimitive","cn","cn","UiEmptyState","UiEmptyStateIcon","UiEmptyStateTitle","UiEmptyStateDescription","UiEmptyStateActionRow","TRANSFORMERS","elementNode","cn","cn","cn","cn","cn","cn","cn","_Fragment","cn","cn","cn","React","EmptyState$1","EmptyStateActionRow$1","EmptyStateDescription$1","EmptyStateIcon$1","EmptyStateTitle$1","cn$1","TRANSFORMERS$1","ScrollAreaPrimitive","mime","rehypeSanitize","RovingFocusGroup","InlineStyleParser","remarkGfm","remarkParse","DEFAULT_VISIBLE_COUNT","ChatCardListLayoutContext","createContext","useChatCardListLayoutContext","context","useContext","ChatCardListLayout","forwardRef","rest","internalExpanded","setInternalExpanded","useState","defaultExpanded","hiddenCount","setHiddenCount","isExpanded","expanded","expand","useCallback","onExpandedChange","contextValue","useMemo","visibleCount","Component","asChild","Slot","className","ChatCardListLayoutItems","items","Children","children","useLayoutEffect","Fragment","ChatCardListLayoutShowMore","handleClick","onClick","event","Button","getSize","width","resolveLayout","size","detailsPlacement","DEFAULT_DETAILS_PLACEMENT","chatCardThreeColumnLayoutVariants","cva","chatCardThreeColumnLayoutListVariants","chatCardThreeColumnLayoutMainVariants","chatCardThreeColumnLayoutDetailsVariants","chatCardThreeColumnLayoutPanelVariants","chatCardThreeColumnLayoutCardVariants","ChatCardThreeColumnLayoutContext","useChatCardThreeColumnLayoutContext","part","renderPane","isFloating","useMergedRef","first","node","second","ChatCardThreeColumnLayout","measureRef","useElementMeasure","mergedRef","ref","isListFloating","isDetailsFloating","isDetailsSheet","ChatCardThreeColumnLayoutList","ChatCardThreeColumnLayoutMain","ChatCardThreeColumnLayoutDetails","ChatCardThreeColumnLayoutPanel","chatCardTwoColumnLayoutVariants","chatCardTwoColumnLayoutGridVariants","chatCardTwoColumnLayoutAsideVariants","chatCardTwoColumnLayoutMainVariants","chatCardTwoColumnLayoutCardVariants","ChatCardTwoColumnLayoutContext","useChatCardTwoColumnLayoutContext","ChatCardTwoColumnLayout","ChatCardTwoColumnLayoutAside","ChatCardTwoColumnLayoutMain","ChatCardContext","useChatCardContext","ChatCardProvider","ChatCardHeader","inner","level","isCollapsible","CollapsibleTrigger","ChatCardIcon","ChatCardHeaderContent","ChatCardTitle","Typography","ChatCardSubTitle","ChatCardActions","ChatCardActionButton","shouldPreventCollapse","content","IconButton","tooltip","Tooltip","ChatCardCollapsibleButton","ChevronDownIcon","ChatCardMedia","ChatCardBody","CollapsibleContent","ChatCardContent","hasPadding","hasHeaderPadding","ChatCardPreview","ChatCardFooter","ChatCardFooterNotes","ChatCardFooterPrice","ChatCardFooterActions","ChatCardForm","ChatCardAttributes","ChatCardAttribute","ChatCardAttributeLabel","Chip","ChatCardAttributeValue","ChatCard","openProp","isControlled","uncontrolledOpen","setUncontrolledOpen","defaultOpen","open","handleOpenChange","next","onOpenChange","Collapsible","isSelected","variant","fullWidth","isRounded","useEditChatCard","isEditing","setIsEditing","defaultEditing","checkIsEditable","isEditable","startEdit","discard","toggleEdit","EditableChatCardContext","useEditableChatCardContext","EditableChatCardContextProvider","ChatCardContainer","inline","DEFAULT_CONTENT_WIDTH","SLOT_VARIABLES","toCssLength","value","ChatContainerContext","useChatContainerContext","ChatContainer","Comp","slotHeights","setSlotHeights","setSlotHeight","current","slot","slotHeight","containerStyle","height","contentWidth","style","useChatContainerSlot","ChatContainerPrompt","ChatContainerWelcome","AutoFocusPlugin","editor","useLexicalComposerContext","useEffect","autoFocus","activeElement","rootElement","defaultSelection","isDisabled","EXPORT_TRANSFORMERS$1","TRANSFORMERS","IMPORT_TRANSFORMERS$1","useChatInputEditor","$getEditorPlainText","$getRoot","$setSelectionToEnd$1","lastDescendant","$isTextNode","selection","$createRangeSelection","endOffset","$setSelection","$getSelection","$isRangeSelection","focusNode","focusOffset","ControlledValuePlugin$1","previousValueRef","useRef","currentValue","$convertToMarkdownString","$addUpdateTag","SKIP_DOM_SELECTION_TAG","$convertFromMarkdownString","DisabledPlugin$1","isReadOnly","FocusPlugin$1","onFocusChange","handleFocus","handleBlur","getHasValue","hasValue","syncHasValue","lastHasValueRef","onHasValueChange","HasValuePlugin","MarkdownPlainPastePlugin$1","PASTE_COMMAND","clipboardData","plainText","root","paragraph","$createParagraphNode","line","$createTextNode","COMMAND_PRIORITY_CRITICAL","ValuePlugin$1","handleChange","onChange","error","OnChangePlugin","ChatInputContext","useChatInputContext","DEFAULT_CONFIG","HeadingNode","QuoteNode","ListNode","ListItemNode","CodeNode","LinkNode","ChatInput","hasError","setHasError","setHasValue","isFocused","setIsFocused","LexicalComposer","ChatInputPlaceholder","ChatInputTextarea","RichTextPlugin","ContentEditable","placeholder","placeholderClassName","LexicalErrorBoundary","HistoryPlugin","ChatListContext","useChatListContext","ChatList","hasMoreProp","ariaLabel","scrollElementRef","loadMoreContentRef","loadMoreVersion","setLoadMoreVersion","skeletonContainer","setSkeletonContainer","setScrollElementVersion","setScrollElement","version","bumpLoadMore","hasMore","totalCount","loadedCount","isEmpty","isLoading","isLoadingMore","onLoadMore","getItemKey","TITLE_WIDTHS","PREVIEW_WIDTHS","ChatListSkeleton","createPortal","rows","Skeleton","index","ChatListEmptyState","ChatListError","ChatListLoadMore","LOAD_MORE_KEY","ChatListItems","memo","loadMoreContent","showSkeleton","count","getItemKeyStable","virtualizer","useVirtualizer","estimateSize","virtualItems","lastItem","ScrollArea","listClassName","isLoaderRow","virtualItem","ChatListItem","ChatPromptBoxContext","useChatPromptBoxContext","ChatPromptBoxContextProvider","focusInputRef","registerFocusInput","focus","unregisterFocusInput","focusInput","reportInputHeight","resetCompact","ChatPromptBoxFocusPlugin","COMPACT_INPUT_HEIGHT_THRESHOLD","INTERACTIVE_SELECTOR","shouldSkipFocus","target","ChatPromptBox","isCompact","setIsCompact","ChatPromptBoxContainer","props","handleMouseDown","onMouseDown","ChatPromptBoxFocusRadials","ChatPromptBoxToolbar","ChatPromptBoxContent","ChatPromptBoxInput","setRef","element","ChatPromptBoxActionsLeft","ChatPromptBoxActionsRight","ChatMessage","isQuestion","ChatMessageContent","ChatMessageActions","getNewChatId","nanoid","ChatContext","useChatContext","ChatProvider","chatIdProp","newChatId","setNewChatId","promptPlaceholder","setPromptPlaceholderState","loadedChatIdsRef","chatId","isNewChat","goToNewChat","nextChatId","setPromptPlaceholder","clearPromptPlaceholder","LAST_ITEM_SCROLL_MAX_COUNT","USER_SCROLL_INTENT_IDLE_MS","ChatConversationContext","useChatConversationContext","ChatConversationProvider","_chatId","isAtBottom","setIsAtBottom","debugInfo","setDebugInfo","viewportNodeRef","bottomTriggerNodeRef","lastItemNodeRef","resizeObserverRef","viewportResizeObserverRef","bottomTriggerObserverRef","messageCountRef","isAtBottomRef","isSmoothScrollRef","hasUserEscapedRef","isProgrammaticScrollRef","userScrollIntentRef","userScrollIntentTimeoutRef","lastScrollTopRef","scrollStrategyRef","lastViewportScrollHeightRef","scrollRef","attachLastItemResizeObserverRef","detachLastItemResizeObserverRef","syncDebugInfoRef","debug","detachLastItemResizeObserver","detachBottomTriggerObserver","detachViewportResizeObserver","syncAtBottomFromViewportRef","clearProgrammaticScroll","clearUserScrollIntent","markUserScrollIntent","applyLastItemScrollStrategy","setHasUserEscaped","hasUserEscaped","scroll","behavior","stickScrollToEnd","scrollHeight","syncAtBottomFromViewport","atBottom","attachViewportResizeObserver","observer","attachLastItemResizeObserver","applyEndScrollStrategy","handleBottomTriggerVisibility","isVisible","handleScroll","lastScrollTop","currentScrollTop","isScrollingUp","handleWheel","handleTouchStart","handlePointerDown","attachBottomTriggerObserver","entry","viewportRef","bottomTriggerRef","lastItemRef","previousNode","setMessageCount","reset","scrollBottom","scrollToLatest","ChatMessagesContext","ChatMessagesListRowContext","useChatMessagesContext","ChatMessages","messageCount","gap","ChatMessagesList","lastIndex","ChatMessagesListRow","bottomTriggerClassName","ChatMessagesScrollBar","isLast","ChatMessageListGroup","orientation","ChatMessagesScrollButton","ChatMessageAttachmentCard","isPreview","isInteractive","ChatMessageAttachmentCardContent","ChatMessageAttachmentCardTitle","ChatMessageAttachmentCardPreview","previewSrc","ChatMessageAttachmentCardActions","onDelete","CloseIcon","CHAT_ATTACHMENT_ICON_MAP","XlsIcon","PdfIcon","PptIcon","DocIcon","CodeIcon","DraftIcon","ChatMessageAttachmentCardIcon","Icon","iconClassName","icon","MIME_TO_ICON","getAttachmentIcon","mimeType","file","isCustomComponentTag","tag","useMarkdownViewer","swiTags","customComponents","key","defaultRemarkPlugins","defaultRehypePlugins","defaultSchema","MarkdownViewer","Streamdown","hasCaret","isStreaming","swiTagHandler","markdown","incompleteMatch","tagName","text","separator","openingTagRegex","openingTags","match","lastTag","closingTag","ChatMessageResponse","message","ChatMessageHistoryContext","useChatMessageHistoryContext","ChatMessageHistory","totalMessages","isCurrentScrollBottom","scrollToLastMessage","useStickToBottom","StickToBottom","contentRef","ChatMessageHistoryScrollBar","ChatMessageHistoryList","ChatMessageHistoryEmptyState","ChatMessageHistoryErrorState","ChatMessageHistoryScrollButton","ChatMessageToolbar","reverse","ChatMessageToolbarActions","ChatMessageToolbarActionButton","ChatMessageToolbarTimestamp","getSnoozeUntilDate","minutes","MINUTES_PER_HOUR","MINUTES_PER_DAY","MILLISECONDS_PER_MINUTE","formatDurationPart","unit","formatSnoozeDate","totalMinutes","date","now","days","hours","parts","prefix","ChatNotificationCardContext","useChatNotificationCardContext","ChatNotificationCard","setExpanded","nextExpanded","toggleExpanded","ChatNotificationCardHead","ChatNotificationCardHeader","ChatNotificationCardHeaderIcon","ChatNotificationCardHeaderTitle","ChatNotificationCardHeaderTitleLabel","CHIP_PRIORITY_MAP","ChatNotificationCardHeaderStatus","color","priority","ChatNotificationCardActions","ChatNotificationCardTimestamp","ChatNotificationCardButtons","ChatNotificationCardReadActionButton","isRead","jsx","SignalUnreadIcon","SignalReadIcon","ChatNotificationCardSnoozeButton","isHovered","setIsHovered","isSnoozed","snoozeUntilDate","handleMouseEnter","onMouseEnter","handleMouseLeave","onMouseLeave","handleCancel","onCancel","SnoozeIcon","formatDate","cancelLabel","ChatNotificationCardDeleteButton","DeleteIcon","ChatNotificationCardCloseButton","ChatNotificationCardContent","ChatNotificationCardExpandButton","ChatNotificationCardContentTitle","ChatNotificationCardContentDescription","ChatNotificationCardContentActions","ChevronUpIcon","ChatNotificationCardIcon","ChatNotificationCardDescription","ChatNotificationCardTimeStamp","ChatNotificationPopup","Popover","ChatNotificationPopupTrigger","PopoverTrigger","ChatNotificationPopupContent","PopoverContent","ChatReplies","ChatReply","isMultiline","ChatReplyLabel","ChatReplyValue","ChatSuggestionContext","useChatSuggestionContext","ChatSuggestions","isValidElement","child","cloneElement","ChatSuggestion","onHover","ChatSuggestionLabelIcon","ChatSuggestionLabel","ChatSuggestionActions","withForwardedRef","Primitive","displayName","ViewportPrimitive","MessageScroller","ContentPrimitive","ItemPrimitive","assignRef","DEFAULT_SCROLL_MARGIN","GROUP_MIN_HEIGHT_VAR","NOOP_COMMANDS","ChatThreadCommandsContext","useChatThread","ChatThreadCommandsBridge","useMessageScroller","commands","scrollToEnd","scrollToMessage","scrollToStart","ChatThreadSessionContext","useChatThreadSession","session","component","createSessionState","conversationId","groupIds","ChatThreadProvider","scrollMode","sessionState","setSessionState","scrollMargin","knownGroupIds","FollowNewGroups","lastGroupId","ChatThread","isAnchored","viewportElementRef","contentElementRef","setViewport","setContent","useGroupMinHeight","contentClassName","ChatThreadErrorState","renderError","scrollButton","ChatThreadScrollButton","scrollButtonClassName","scrollButtonTooltip","viewport","isEnabled","update","minHeight","paddingTop","paddingBottom","ChatThreadGroup","isNew","groupId","ChatThreadQuestion","messageId","ChatThreadAnswer","hasContentBelow","useMessageScrollerScrollable","_children","inert","CanvasShell","cn","CanvasShellHeader","hasBorder","CanvasShellTitle","CanvasShellCloseTrigger","CanvasShellFullScreenTrigger","isFullScreen","labels","OpenInFullIcon","CanvasShellOptionsButton","isOpen","setIsOpen","MenuProvider","MenuTrigger","MoreHorizontalIcon","Menu","menuClassName","canvasShellContentPadding","CanvasShellContent","hasScroll","CanvasShellFooter","CardItemPickerListContext","useCardItemPickerListContext","CardItemPickerRowContext","useCardItemPickerRowContext","CardItemPickerList","lastFocusedId","setLastFocusedId","tabStopId","onHoverChangeRef","onHoverChange","onValueChangeRef","onValueChange","select","itemValue","hover","hoveredValue","CardItemPickerRow","list","id","useId","hasTitle","setHasTitle","hasDescription","setHasDescription","itemContext","handleKeyDown","onKeyDown","forwardedRef","CardItemPickerRowMedia","CardItemPickerRowContent","CardItemPickerRowTitle","registerTitle","titleId","CardItemPickerRowDescription","registerDescription","descriptionId","CardItemPickerRowCheckbox","Checkbox","NewChatTrigger","ChatThinkingProcess","ChatThinkingProcessTrigger","ChatThinkingProcessTriggerIcon","ChatThinkingProcessTriggerLabel","ChatThinkingProcessTriggerArrow","ChatThinkingProcessContent","childrenArray","hasLastMessagePreview","lastItemContent","AnimatePresence","ChatThinkingProcessContentPreview","lastItemIndex","itemsClassName","motion","contentId","ChatThinkingProcessContentItem","EmptyState","EmptyStateIcon","EmptyStateTitle","EmptyStateDescription","EmptyStateActionRow","defaultEditorTheme","ImageNode","DecoratorNode","src","altText","span","img","domNode","alt","$createImageNode","json","$isImageNode","extractFontStyles","fontSizeRegex","fontFamilyRegex","colorRegex","fontSizeMatch","fontFamilyMatch","colorMatch","FONT_STYLE_EXPORT","fontStyles","styleStr","FONT_STYLE_IMPORT","newNode","textNode","UNDERLINE_TRANSFORMER","getAlignment","alignmentMatch","ALIGNMENT_TRANSFORMER","alignment","parentNode","$isParagraphNode","exportChildren","IMAGE_EXPORT_TRANSFORMER","IMAGE_IMPORT_TRANSFORMER","imageNode","EXPORT_TRANSFORMERS","IMPORT_TRANSFORMERS","convertHeadingElement","nodeName","$createHeadingNode","align","setNodeIndentFromDOM","isDomChecklist","isHTMLElement","convertListElement","start","$createListNode","convertListItemElement","input","checked","$createListItemNode","ariaCheckedAttr","IMPORT_PRIORITY","convertSpanElementWithStyles","fontSize","fontFamily","domStyle","lexicalNode","fontWeight","textDecoration","HTML_IMPORT_CONFIG","wrapExportWithStyle","result","OriginalClass","HTML_EXPORT_CONFIG","DivBlockNode","ElementNode","div","prevStyle","prevNode","nextStyle","convertDivElement","$createDivBlockNode","serializedNode","updated","ValuePlugin","source","$generateHtmlFromNodes","useRichTextAreaEditor","useRichTextAreaSelectedText","selectedText","DisabledPlugin","ControlledPlugin","editorRef","useImperativeHandle","controlledRef","EditorRefPlugin","scrollRichTextAreaToBottom","$setSelectionToEnd","getHTMLNodesFromValue","dom","html","$generateNodesFromDOM","p","$replaceEditorHTMLContent","$replaceEditorSelectionHTMLContent","nodes","ControlledValuePlugin","shouldScrollOnInitialValueRef","isDesktop","useIsResolution","BlurPlugin","onBlur","FocusPlugin","INSERT_IMAGE_COMMAND","createCommand","INSERT_IMAGE_EVENT_NAME","ImageAddedEvent","payload","ImageDropPlugin","COMMAND_PRIORITY_EDITOR","handleInsertImage","customEvent","PASTE_HTML_COMMAND","INSERT_HTML_COMMAND","PASTE_HTML_EVENT","INSERT_HTML_EVENT","PasteHtmlEvent","InsertHtmlEvent","HtmlPastePlugin","handlePasteHtml","handleInsertHtml","MarkdownPlainPastePlugin","ATTACH_FILE_COMMAND","FileAttachmentPlugin","inputRef","files","isMultiple","acceptedFiles","Wrapper","INITIAL_CONFIG","TableNode","TableCellNode","TableRowNode","RichTextAreaImpl","containerClassName","name","TablePlugin","RichTextArea","DEFAULT_FONT_FAMILY","FONT_FAMILY_OPTIONS","DEFAULT_FONT_FAMILY_VALUE","FONT_SIZE_OPTIONS","DEFAULT_ALIGNMENT","DEFAULT_TEXT_COLOR","ToolbarSelect","SelectField","toAlignment","format","ALIGNMENT_OPTIONS_MAP","FormatAlignLeftIcon","FormatAlignCenterIcon","FormatAlignRightIcon","AlignmentSelect","setValue","options","$updateValue","parent","$isElementNode","mergeRegister","SELECTION_CHANGE_COMMAND","COMMAND_PRIORITY_LOW","FORMAT_ELEMENT_COMMAND","ToolbarButton","AttachmentButton","AttachmentsIcon","getStyleObjectFromRawCSS","styleObject","token","css","NO_STYLE","parse","v","unparse","styles","k","isEqualValue","a","b","isEqual","styleState","createState","$setStyleObject","$setState","valueOrUpdater","mergeStyleObjects","prevStyles","nextStyles","$patchSelectedTextStyle","prevSelection","$getPreviousSelection","styleCallback","styleObjectOrCallback","getSelectedNode","anchor","anchorNode","$isAtNodeEnd","updateFontSizeInSelection","skipRefocus","$patchStyleText","newFontSize","sanitizeUrl","url","RichTextFieldContext","useRichTextFieldContext","normalizeColorToHex","trimmed","hexMatch","r","g","rgbMatch","clamp","n","toHex","RichTextFieldContextProvider","setFontFamily","setFontSize","isBold","setIsBold","isItalic","setIsItalic","isUnderline","setIsUnderline","textColor","setTextColor","isLink","setIsLink","$updateToolbar","$getSelectionStyleValueForProperty","rawColor","$isLinkNode","onFontFamily","SKIP_SELECTION_FOCUS_TAG","onFontSize","onBold","FORMAT_TEXT_COMMAND","onItalic","onUnderline","onTextColor","onLink","TOGGLE_LINK_COMMAND","BoldButton","FormatBoldIcon","CleanFormatButton","$getNearestBlockElementAncestorOrThrow","FormatCleanIcon","ImageButton","ImageIcon","ItalicButton","FormatItalicIcon","LinkButton","isActive","LinkOnIcon","LinkOffIcon","SizeSelect","TextColorButton","isDefaultColor","handleColorChange","FormatColorIcon","TypographySelect","UnderlineButton","FormatUnderlineIcon","DefaultFormattingToolbarChildren","Divider","hasAttachments","FormattingToolbarPlugin","RichTextField","isToolbarTop","toolbarPlacement","enableAttachments","toolbarClassName","toolbarChildren","isMultipleAttachments","SOURCE_ANIMATION","Spinner","DotLottieReact","autoplay","CHAT_ACTION_PROTOCOL","createChatActionURL","action","params","createChatActionLink","label","isChatActionURL","uri","extractChatActionMetadataFromUrl","link","extractLabelFromNode","extractChatActionFromLink","ast","unified","visit","metadata","useChatActions","actions","defaultTokenParser","data","isAbortError","toError","fallbackMessage","useChatStreamMessage","parseToken","tokenParser","timeoutId","didHandleAbort","clearStreamTimeout","handleAbort","onAbort","resetStreamTimeout","timeout","abortController","decoder","parser","createParser","onChunkReceived","e","stream","chunk","done","onFinish","onError","useOnChatChanged","isNewChatRef","prevChatIdRef","chatChangedFn","onChatChanged","useCurrentChatId","useIsCurrentChatNew","useChatLoadedIds","useChatPromptPlaceholder"],"sources":["../src/layouts/chat-card-list-layout/chat-card-list-layout.tsx","../src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts","../src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts","../src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx","../src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts","../src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx","../src/components/chat-card/context.tsx","../src/components/chat-card/components/chat-card-header.tsx","../src/components/chat-card/components/chat-card-body.tsx","../src/components/chat-card/components/chat-card-footer.tsx","../src/components/chat-card/components/chat-card-form.tsx","../src/components/chat-card/chat-card.tsx","../src/components/chat-card/hooks.ts","../src/components/chat-card/contexts.tsx","../src/components/chat-card-container/chat-card-container.tsx","../src/components/chat-container/chat-container.tsx","../src/components/chat-input/plugins/auto-focus-plugin.tsx","../src/components/chat-input/transformers.ts","../src/components/chat-input/plugins/hooks.ts","../src/components/chat-input/plugins/utils.ts","../src/components/chat-input/plugins/controlled-value-plugin.tsx","../src/components/chat-input/plugins/disabled-plugin.tsx","../src/components/chat-input/plugins/focus-plugin.tsx","../src/components/chat-input/plugins/has-value-plugin.tsx","../src/components/chat-input/plugins/markdown-plain-paste-plugin.tsx","../src/components/chat-input/plugins/value-plugin.tsx","../src/components/chat-input/chat-input.tsx","../src/components/chat-list/chat-list.tsx","../src/components/chat-list/chat-list-items.tsx","../src/components/chat-list/chat-list-item.tsx","../src/components/chat-prompt-box/chat-prompt-box-context.tsx","../src/components/chat-prompt-box/chat-prompt-box-focus-plugin.tsx","../src/components/chat-prompt-box/chat-prompt-box.tsx","../src/components/chat-message/chat-message.tsx","../src/contexts/chat-context/utils.ts","../src/contexts/chat-context/chat-context.tsx","../src/contexts/chat-conversation-context/chat-conversation-context.tsx","../src/components/chat-messages/chat-messages.tsx","../src/components/chat-message-attachment-card/chat-message-attachment-card.tsx","../src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx","../src/components/chat-message-attachment-card/utils.ts","../src/components/markdown-viewer/utils.ts","../src/components/markdown-viewer/hooks.ts","../src/components/markdown-viewer/markdown-viewer.tsx","../src/components/chat-message-response/chat-message-response.tsx","../src/components/chat-message-history/chat-message-history.tsx","../src/components/chat-message-toolbar/chat-message-toolbar.tsx","../src/components/chat-notification-card/utils.ts","../src/components/chat-notification-card/chat-notification-card.tsx","../src/components/chat-notification-popup/chat-notification-popup.tsx","../src/components/chat-reply/chat-reply.tsx","../src/components/chat-suggestion/chat-suggestion.tsx","../src/components/chat-thread/chat-thread.tsx","../src/components/canvas-shell/canvas-shell.tsx","../src/components/card-item-picker/card-item-picker-context.tsx","../src/components/card-item-picker/card-item-picker-list.tsx","../src/components/card-item-picker/card-item-picker-row.tsx","../src/components/card-item-picker/card-item-picker-row-parts.tsx","../src/components/new-chat-trigger/new-chat-trigger.tsx","../src/components/chat-thinking-process/chat-thinking-process.tsx","../src/components/deprecated-empty-state.ts","../src/components/rich-text-area/constants/index.ts","../src/components/rich-text-area/nodes/image-node.tsx","../src/components/rich-text-area/transformers.ts","../src/components/rich-text-area/html-config.ts","../src/components/rich-text-area/nodes/div-block-node.tsx","../src/components/rich-text-area/plugins/value-plugin.tsx","../src/components/rich-text-area/hooks.ts","../src/components/rich-text-area/plugins/disabled-plugin.tsx","../src/components/rich-text-area/plugins/controlled-plugin.tsx","../src/components/rich-text-area/utils/index.ts","../src/components/rich-text-area/plugins/controlled-value-plugin.tsx","../src/components/rich-text-area/plugins/blur-plugin.tsx","../src/components/rich-text-area/plugins/focus-plugin.tsx","../src/components/rich-text-area/plugins/image-drop-plugin.tsx","../src/components/rich-text-area/plugins/html-paste-plugin.tsx","../src/components/rich-text-area/plugins/markdown-plain-paste-plugin.tsx","../src/components/rich-text-area/plugins/file-attachment-plugin.tsx","../src/components/rich-text-area/styled.tsx","../src/components/rich-text-area/rich-text-area.tsx","../src/components/rich-text-field/constants.ts","../src/components/rich-text-field/components/toolbar-select.tsx","../src/components/rich-text-field/components/alignment-select.tsx","../src/components/rich-text-field/components/toolbar-button.tsx","../src/components/rich-text-field/components/attachment-button.tsx","../src/components/rich-text-field/utils.ts","../src/components/rich-text-field/context.tsx","../src/components/rich-text-field/components/bold-button.tsx","../src/components/rich-text-field/components/clean-format-button.tsx","../src/components/rich-text-field/components/image-button.tsx","../src/components/rich-text-field/components/italic-button.tsx","../src/components/rich-text-field/components/link-button.tsx","../src/components/rich-text-field/components/size-select.tsx","../src/components/rich-text-field/components/text-color-button.tsx","../src/components/rich-text-field/components/typography-select.tsx","../src/components/rich-text-field/components/underline-button.tsx","../src/components/rich-text-field/components/formatting-toolbar-plugin.tsx","../src/components/rich-text-field/rich-text-field.tsx","../src/components/spinner/spinner.tsx","../src/domain/actions/constants.ts","../src/domain/actions/utils/index.ts","../src/domain/actions/hooks/index.ts","../src/hooks/use-chat-stream-message.ts","../src/hooks/use-on-chat-changed.ts","../src/hooks/use-current-chat-id.ts","../src/hooks/use-is-current-chat-new.ts","../src/hooks/use-loaded-chat-ids.ts","../src/hooks/use-chat-prompt-placeholder.ts"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport type { ComponentProps, MouseEvent, ReactNode } from 'react';\nimport {\n Children,\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useLayoutEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { Button } from '@swisper.ai/ui';\nimport type { ButtonProps } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\n/**\n * How many items are rendered before the reveal.\n *\n * Three, because the collapsed list has to read as \"there is more here\" at a glance.\n * One or two look like the whole answer and the button gets ignored; from five up the\n * collapsed state is already taller than a phone viewport, which is the thing this\n * layout exists to prevent.\n */\nconst DEFAULT_VISIBLE_COUNT = 3;\n\ninterface ChatCardListLayoutContextValue {\n visibleCount: number;\n isExpanded: boolean;\n expand: () => void;\n hiddenCount: number;\n setHiddenCount: (count: number) => void;\n}\n\nconst ChatCardListLayoutContext = createContext<ChatCardListLayoutContextValue>(null!);\n\n/**\n * Reads the layout's state from any descendant.\n *\n * Exported so a consumer can put the hidden count in their own label (\"Show 5 more\") or\n * build a trigger that isn't a `Button`. `hiddenCount` is `0` on the first render and\n * correct from the first layout effect onwards — see `ChatCardListLayoutItems`.\n */\nexport function useChatCardListLayoutContext() {\n const context = useContext(ChatCardListLayoutContext);\n\n if (!context) {\n throw new Error(\n '[web-chat-ui] \"useChatCardListLayoutContext\" must be used within a ChatCardListLayout. ' +\n 'ChatCardListLayoutItems and ChatCardListLayoutShowMore both read it, so both must be ' +\n 'rendered inside the ChatCardListLayout element, not as siblings of it.',\n );\n }\n\n return context;\n}\n\nexport interface ChatCardListLayoutProps extends ComponentProps<'div'> {\n children: ReactNode;\n /**\n * How many items `ChatCardListLayoutItems` renders while collapsed.\n *\n * Clamped at zero: a negative value would reach `Array.slice` as a count from the end\n * and quietly render the *last* n items, which is the opposite of what the caller\n * asked for.\n */\n visibleCount?: number;\n /**\n * Expanded state for the uncontrolled case. Set it when the surrounding message is\n * restored from history and the reader had already expanded this list.\n */\n defaultExpanded?: boolean;\n /**\n * Controlled expanded state. Pass it only if something outside owns the state —\n * driving it back to `false` re-collapses the list and brings the button back, which\n * the uncontrolled component deliberately cannot do.\n */\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n asChild?: boolean;\n}\n\n/**\n * Holds a list of chat cards and reveals the overflow behind a one-way \"show more\".\n *\n * Structure and state only — the sole class it emits is the `group/chat-card-list-layout`\n * marker, which paints nothing and exists so descendants can react to the expanded state\n * with `group-data-[expanded=true]/chat-card-list-layout:…`. Direction, gap and every\n * other visual decision come from the consumer's `className`, so the same layout serves\n * a stacked card list and a horizontal strip without a variant prop.\n *\n * The three parts exist because the pieces of information live in different places: only\n * `ChatCardListLayoutItems` knows how many children there are, only\n * `ChatCardListLayoutShowMore` needs to know whether any are hidden, and this root owns\n * the state that joins them. Slicing here instead would mean telling item children apart\n * from the button by inspecting `child.type`, which breaks the moment either is wrapped.\n */\nexport const ChatCardListLayout = forwardRef<HTMLDivElement, ChatCardListLayoutProps>(\n function ChatCardListLayout(\n {\n children,\n className,\n visibleCount = DEFAULT_VISIBLE_COUNT,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n asChild = false,\n ...rest\n },\n ref,\n ) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const [hiddenCount, setHiddenCount] = useState(0);\n\n const isExpanded = expanded ?? internalExpanded;\n\n const expand = useCallback(() => {\n if (expanded === undefined) {\n setInternalExpanded(true);\n }\n\n onExpandedChange?.(true);\n }, [expanded, onExpandedChange]);\n\n const contextValue = useMemo(\n () => ({\n visibleCount: Math.max(0, visibleCount),\n isExpanded,\n expand,\n hiddenCount,\n setHiddenCount,\n }),\n [visibleCount, isExpanded, expand, hiddenCount],\n );\n\n const Component = asChild ? Slot : 'div';\n\n return (\n <ChatCardListLayoutContext.Provider value={contextValue}>\n <Component\n ref={ref}\n data-testid=\"chat-card-list-layout\"\n data-expanded={isExpanded}\n className={cn(\n 'group/chat-card-list-layout',\n 'flex flex-col items-start gap-[8px]',\n className,\n )}\n {...rest}\n >\n {children}\n </Component>\n </ChatCardListLayoutContext.Provider>\n );\n },\n);\n\nChatCardListLayout.displayName = 'ChatCardListLayout';\n\nexport interface ChatCardListLayoutItemsProps {\n children: ReactNode;\n}\n\n/**\n * Renders the visible slice of the list, and nothing else — no wrapper element.\n *\n * A `div` here would sit between the root's `className` and the cards, so a consumer's\n * `flex`/`grid` on the root would apply to this one wrapper instead of to the items and\n * the layout would silently collapse to a single column. There is no `className` prop\n * for the same reason: there is no node to hang it on.\n *\n * Hidden items are sliced away rather than hidden with CSS, so they never mount: no DOM,\n * no image or data fetches from cards nobody has asked for, and nothing invisible in the\n * tab order.\n *\n * Only one of these per layout. Two would race on `hiddenCount` and the last effect\n * would win; summing across instances is buildable but nothing needs it yet.\n */\nexport function ChatCardListLayoutItems({ children }: ChatCardListLayoutItemsProps) {\n const { visibleCount, isExpanded, setHiddenCount } = useChatCardListLayoutContext();\n\n // `Children.toArray` flattens fragments and drops `null`/`undefined`/booleans, so a\n // conditionally rendered card counts only when it actually renders. Reading\n // `Children.count` instead would count the holes and the button would offer to reveal\n // items that do not exist.\n const items = Children.toArray(children);\n const hiddenCount = isExpanded ? 0 : Math.max(0, items.length - visibleCount);\n\n // A layout effect, not `useEffect`: `hiddenCount` starts at 0, so the button renders\n // `null` on the first pass and this correction has to land before the browser paints.\n // With `useEffect` the button would visibly pop in after the list.\n useLayoutEffect(() => {\n setHiddenCount(hiddenCount);\n }, [hiddenCount, setHiddenCount]);\n\n return <>{isExpanded ? items : items.slice(0, visibleCount)}</>;\n}\n\nexport interface ChatCardListLayoutShowMoreProps extends Omit<ButtonProps, 'children'> {\n /**\n * The label. Required on purpose: a default `'Show more'` baked into the package would\n * be untranslatable by the app that ships it, and this is the one string in the layout\n * a reader actually sees.\n */\n children: ReactNode;\n}\n\n/**\n * The reveal trigger. Renders nothing once there is nothing left to reveal — either the\n * list is expanded, or it never overflowed — which is what makes the button a one-shot\n * affordance rather than a toggle.\n *\n * It sets no `variant`, `size` or `className` of its own so the design system's `Button`\n * defaults apply untouched and a consumer's props are not fighting ours.\n */\nexport const ChatCardListLayoutShowMore = forwardRef<\n // The same element union `Button` forwards: it renders a `span` when `isSemantic` is\n // false, and narrowing to `HTMLButtonElement` here would make a plain object ref fail\n // to type-check against it.\n HTMLButtonElement | HTMLSpanElement,\n ChatCardListLayoutShowMoreProps\n>(function ChatCardListLayoutShowMore({ children, onClick, className, ...rest }, ref) {\n const { isExpanded, hiddenCount, expand } = useChatCardListLayoutContext();\n\n function handleClick(event: MouseEvent<HTMLButtonElement>) {\n expand();\n onClick?.(event);\n }\n\n if (isExpanded || hiddenCount === 0) {\n return null;\n }\n\n return (\n <Button\n ref={ref}\n variant=\"tertiary\"\n size=\"sm\"\n data-testid=\"chat-card-list-layout-show-more\"\n onClick={handleClick}\n className={cn('mx-auto', className)}\n {...rest}\n >\n {children}\n </Button>\n );\n});\n\nChatCardListLayoutShowMore.displayName = 'ChatCardListLayoutShowMore';\n","import type { ChatCardThreeColumnLayoutDetailsPlacement } from './chat-card-three-column-layout.variants';\n\n/*\n * Pane widths are fixed pixels per size tier, as in the places card this layout came from:\n * List is 290px at `lg` and 358px at `xl`, and Details is always 358px. The recipes in\n * `chat-card-three-column-layout.variants.ts` write them out as literal `290px` / `358px`,\n * because Tailwind cannot read a constant, so change both together.\n */\nexport const LIST_WIDTH_LG = 290;\n/** List at `xl`, and Details at every tier (as a column and as a pinned floating pane). */\nexport const PANE_WIDTH_XL = 358;\n\n/**\n * Narrowest Main may get before a pane has to float over it instead of sitting beside it.\n * Main is usually a map or a chart, and below ~400px a map shows too little context to\n * pick a place from. This is the one number to tune when a card feels cramped.\n */\nexport const MIN_MAIN_WIDTH = 400;\n\n/** Must equal the `gap-[8px]` on the root grid, or the thresholds are off by that much. */\nexport const GAP = 8;\n\n/**\n * Below this, a floating Details is a bottom sheet (`sm`). Pinned to Main's right edge at\n * 358px, it would leave a sliver of Main too thin to read or tap.\n */\nexport const MD_MIN_WIDTH = 640;\n\n/** `lg`: a 290px List column fits beside a usable Main. */\nexport const LG_MIN_WIDTH = LIST_WIDTH_LG + GAP + MIN_MAIN_WIDTH;\n\n/**\n * `xl`: a Details column fits beside a 358px List and a usable Main. List widens to 358px at\n * the same point, as in the original, where both changed at the `xl` breakpoint.\n */\nexport const XL_MIN_WIDTH = PANE_WIDTH_XL * 2 + GAP * 2 + MIN_MAIN_WIDTH;\n\n/** Size tier, named after the viewport breakpoints the original card used. */\nexport type ChatCardThreeColumnLayoutSize = 'sm' | 'md' | 'lg' | 'xl';\n\nexport interface ChatCardThreeColumnLayoutResolved {\n size: ChatCardThreeColumnLayoutSize;\n isListFloating: boolean;\n isDetailsFloating: boolean;\n isDetailsSheet: boolean;\n}\n\nfunction getSize(width: number): ChatCardThreeColumnLayoutSize {\n if (width >= XL_MIN_WIDTH) return 'xl';\n if (width >= LG_MIN_WIDTH) return 'lg';\n if (width >= MD_MIN_WIDTH) return 'md';\n return 'sm';\n}\n\n/**\n * Where each pane goes, given the width the layout actually has.\n *\n * The tiers are the original card's `md` / `lg` / `xl`, but measured on the layout, not\n * the viewport. The card is sized by the chat window, and a sidebar, a split view or the\n * Storybook panel all make the viewport claim room the card doesn't have (or the reverse).\n *\n * `'unset'` means the layout has not been measured yet (on the server, or before the first\n * layout effect). It resolves to `xl`: SSR HTML is mostly seen on desktops, and on the\n * client the measurement lands before paint.\n */\nexport function resolveLayout(\n width: number | 'unset',\n detailsPlacement: ChatCardThreeColumnLayoutDetailsPlacement,\n): ChatCardThreeColumnLayoutResolved {\n const size = width === 'unset' ? 'xl' : getSize(width);\n\n return {\n size,\n isListFloating: size === 'sm' || size === 'md',\n isDetailsFloating: detailsPlacement === 'floating' || size !== 'xl',\n isDetailsSheet: size === 'sm',\n };\n}\n","import { cva } from 'class-variance-authority';\n\n/**\n * Whether Details may take its own right column.\n *\n * - `responsive` — a column whenever the layout is wide enough for List, Details and a\n * usable Main side by side; floating over Main otherwise.\n * - `floating` — always over Main, for a pane that is secondary at every size.\n *\n * There is no \"always a column\": at widths where it would not fit, Main would be squeezed\n * below usefulness, which is exactly what the width check exists to prevent.\n */\nexport type ChatCardThreeColumnLayoutDetailsPlacement = 'responsive' | 'floating';\n\n/**\n * `responsive` because it uses the room when it is there: `floating` would cover Main on\n * a card with space to spare.\n */\nexport const DEFAULT_DETAILS_PLACEMENT: ChatCardThreeColumnLayoutDetailsPlacement = 'responsive';\n\n/*\n * Every recipe below keys on data attributes the components set from the layout's measured\n * width (`data-size`, `data-list-floating`, `data-details-floating` on the root;\n * `data-floating`, `data-sheet` on each pane). `290px` and `358px` are `LIST_WIDTH_LG` and\n * `PANE_WIDTH_XL` from `chat-card-three-column-layout.sizing.ts`, written out because\n * Tailwind cannot read a constant. Change both together.\n *\n * The tiers are the original card's `md` / `lg` / `xl`, but none of the recipes uses viewport\n * breakpoints: the card is sized by the chat window, not the viewport, so `lg:` / `xl:`\n * would switch panes at the wrong widths.\n *\n * Using a recipe without its component means setting those attributes yourself.\n *\n * Class strings are written out in full because Tailwind finds classes by scanning source;\n * a class assembled from a constant is never generated.\n */\n\n/**\n * Root grid.\n *\n * The third track needs both \"Details fits\" (`data-details-floating=false`, from the\n * width) and \"Details is mounted\" (`:has(> [data-slot=…-details])`). The second is CSS, not\n * a prop, because consumers mount Details conditionally and a `hasDetails` prop could\n * disagree with what is rendered.\n */\nexport const chatCardThreeColumnLayoutVariants = cva([\n 'relative grid gap-[8px]',\n // sm + md — Main only; List floats as a strip and Details floats over Main\n \"grid-cols-[1fr] [grid-template-areas:'main']\",\n \"data-[size=lg]:grid-cols-[290px_1fr] data-[size=lg]:[grid-template-areas:'list_main']\",\n \"data-[size=xl]:grid-cols-[358px_1fr] data-[size=xl]:[grid-template-areas:'list_main']\",\n // xl with a mounted Details that is allowed a column\n 'data-[details-floating=false]:has-[>[data-slot=chat-card-three-column-layout-details]]:grid-cols-[358px_1fr_358px]',\n \"data-[details-floating=false]:has-[>[data-slot=chat-card-three-column-layout-details]]:[grid-template-areas:'list_main_details']\",\n]);\n\n/**\n * Column 1, or, when there is no room for it, a strip pinned to the bottom of the layout\n * over Main. One element for both, so the pane never remounts when it switches; only what\n * the consumer's render prop returns changes.\n *\n * Floating is `absolute` rather than a grid row so Main keeps the full height. In the\n * column, `min-h-0` + `overflow-hidden` keep a long list inside the row. Without them the\n * grid item grows to its content and the card gets taller instead of scrolling.\n */\nexport const chatCardThreeColumnLayoutListVariants = cva([\n 'min-w-0',\n 'data-[floating=true]:absolute data-[floating=true]:bottom-0 data-[floating=true]:inset-x-0 data-[floating=true]:z-10',\n 'data-[floating=false]:[grid-area:list] data-[floating=false]:min-h-0 data-[floating=false]:h-full data-[floating=false]:overflow-hidden',\n]);\n\n/**\n * Column 2, the flexible `1fr` track. `min-w-0` because a grid item's minimum width is its\n * content by default: a map or a wide table would push the track past the card. `relative`\n * so the consumer can anchor their own overlays to Main.\n */\nexport const chatCardThreeColumnLayoutMainVariants = cva([\n '[grid-area:main] relative min-w-0 min-h-0 h-full',\n]);\n\n/**\n * Column 3, or floating over Main. Floating shares Main's grid area instead of being\n * `absolute`, so it is sized by the same track Main is.\n *\n * - pinned: the right edge of Main, at the same width the column would have, inset 12px\n * - sheet: on a narrow layout, a bottom sheet at a fixed 85% height, so the pane does not\n * change height as its content changes (the content scrolls instead)\n *\n * `z-20` keeps a floating Details above the floating List (`z-10`): an open Details is\n * what the reader asked for last. `min-w-0` + `max-w-full` stop the fixed width from\n * widening the `1fr` track past the card.\n */\nexport const chatCardThreeColumnLayoutDetailsVariants = cva([\n 'min-h-0 min-w-0 max-w-full',\n 'data-[floating=false]:[grid-area:details] data-[floating=false]:h-full',\n 'data-[floating=true]:z-20 data-[floating=true]:[grid-area:main]',\n 'data-[floating=true]:data-[sheet=false]:w-[358px] data-[floating=true]:data-[sheet=false]:h-full data-[floating=true]:data-[sheet=false]:justify-self-end data-[floating=true]:data-[sheet=false]:self-stretch data-[floating=true]:data-[sheet=false]:p-[12px]',\n 'data-[sheet=true]:w-full data-[sheet=true]:h-[85%] data-[sheet=true]:justify-self-start data-[sheet=true]:self-end',\n]);\n\n/**\n * An overlay over everything but the List column, inset 12px, for a view that takes over the\n * card (all reviews, a filter form) while Main and Details stay mounted underneath.\n *\n * It spans columns in row 1 instead of being `absolute`, so it follows the grid template:\n * from column 2 to the last one when List is a column, all of them when List floats. It\n * never adds a track, so mounting it doesn't move Main. `z-30` keeps it above floating\n * Details (`z-20`) and the List strip (`z-10`).\n */\nexport const chatCardThreeColumnLayoutPanelVariants = cva([\n 'relative z-30 min-w-0 min-h-0 h-full p-[12px] row-1',\n 'data-[list-floating=false]:col-[2/-1]',\n 'data-[list-floating=true]:col-span-full',\n]);\n\n/**\n * Width recipe for the `ChatCard` that wraps the layout.\n *\n * A grid of `1fr` tracks has no intrinsic width, so inside a shrink-to-fit message the card\n * would collapse to nothing. It takes the whole chat window instead, minus the message\n * gutter on both sides, up to 1432px (four 358px columns). The layout then decides which\n * panes fit in whatever width that gives it. `ChatContainer` sets both variables.\n *\n * One cap, not a ladder of viewport steps: a step like `lg:min-w-[1074px]` held the card\n * narrower than the chat window between breakpoints, and Details floated for no reason.\n *\n * Gated on `data-state=open`, which `ChatCard`'s `Collapsible` puts on the card element\n * itself: a collapsed card is only a header, and holding it at full width would leave a\n * wide empty bar in the thread. A non-collapsible card is always `open`.\n */\nexport const chatCardThreeColumnLayoutCardVariants = cva([\n 'data-[state=open]:w-(--message-list-content-width) data-[state=open]:mx-0',\n // `100%` fallback, like every other read of the variable, for a card outside `ChatContainer`\n 'data-[state=open]:min-w-[min(1432px,calc(var(--chat-window-width,100%)-var(--spacing-message)*2))]',\n]);\n","import { Slot } from '@radix-ui/react-slot';\nimport { createContext, forwardRef, useCallback, useContext, useMemo } from 'react';\nimport type { ComponentProps, ForwardedRef, ReactNode } from 'react';\n\nimport { cn, useElementMeasure } from '@swisper.ai/web-core';\n\nimport { resolveLayout } from './chat-card-three-column-layout.sizing';\nimport {\n DEFAULT_DETAILS_PLACEMENT,\n chatCardThreeColumnLayoutDetailsVariants,\n chatCardThreeColumnLayoutListVariants,\n chatCardThreeColumnLayoutMainVariants,\n chatCardThreeColumnLayoutPanelVariants,\n chatCardThreeColumnLayoutVariants,\n} from './chat-card-three-column-layout.variants';\nimport type { ChatCardThreeColumnLayoutDetailsPlacement } from './chat-card-three-column-layout.variants';\n\ninterface ChatCardThreeColumnLayoutContextValue {\n isListFloating: boolean;\n isDetailsFloating: boolean;\n isDetailsSheet: boolean;\n}\n\nconst ChatCardThreeColumnLayoutContext = createContext<ChatCardThreeColumnLayoutContextValue>(\n null!,\n);\n\nfunction useChatCardThreeColumnLayoutContext(part: string) {\n const context = useContext(ChatCardThreeColumnLayoutContext);\n\n if (!context) {\n throw new Error(\n `[web-chat-ui] \"${part}\" must be used within a ChatCardThreeColumnLayout. ` +\n 'It reads its floating state from the layout, so render ' +\n 'it as a child of the ChatCardThreeColumnLayout element, not as a sibling of it.',\n );\n }\n\n return context;\n}\n\n/**\n * A pane's content, or a function of whether the pane is currently floating.\n *\n * The function form exists because a floating pane usually needs different content, not\n * just different styling: the places card shows a vertical list in the column and a\n * horizontal swipe strip when floating. CSS alone cannot swap the component tree.\n */\nexport type ChatCardThreeColumnLayoutPaneChildren =\n ReactNode | ((isFloating: boolean) => ReactNode);\n\nfunction renderPane(children: ChatCardThreeColumnLayoutPaneChildren, isFloating: boolean) {\n return typeof children === 'function' ? children(isFloating) : children;\n}\n\nexport interface ChatCardThreeColumnLayoutProps extends ComponentProps<'div'> {\n children: ReactNode;\n /**\n * Whether Details may take its own column. See `ChatCardThreeColumnLayoutDetailsPlacement`.\n * It is on the root, not on Details, because the root's grid template has to change\n * with it.\n */\n detailsPlacement?: ChatCardThreeColumnLayoutDetailsPlacement;\n asChild?: boolean;\n}\n\n/** Hands one element to the measuring ref and the consumer's forwarded ref alike. */\nfunction useMergedRef<T>(first: (node: T | null) => void, second: ForwardedRef<T>) {\n return useCallback(\n (node: T | null) => {\n first(node);\n\n if (typeof second === 'function') {\n second(node);\n } else if (second) {\n second.current = node;\n }\n },\n [first, second],\n );\n}\n\n/**\n * A three-pane card body: List (fixed column), Main (flexible), Details (floating or a\n * right column).\n *\n * Which panes fit is decided by the layout's **own measured width**, not by viewport\n * breakpoints. The card is sized by the chat window, and a sidebar, a split view or the\n * Storybook panel all make the viewport claim room the card doesn't have (or the\n * reverse). The root measures itself, resolves the panes once (`resolveLayout`), and\n * publishes the result twice: as data attributes for the CSS, and through context for the render props. Both read the same numbers, so the content a\n * render prop picks always matches where its pane is drawn.\n *\n * Height is not set here, because it belongs to the content (a map needs a fixed height, a\n * table might not), so pass it in `className`.\n */\nexport const ChatCardThreeColumnLayout = forwardRef<HTMLDivElement, ChatCardThreeColumnLayoutProps>(\n function ChatCardThreeColumnLayout(\n { children, className, detailsPlacement = DEFAULT_DETAILS_PLACEMENT, asChild = false, ...rest },\n ref,\n ) {\n const { ref: measureRef, width } = useElementMeasure<HTMLDivElement>();\n const mergedRef = useMergedRef(measureRef, ref);\n\n const { size, isListFloating, isDetailsFloating, isDetailsSheet } = resolveLayout(\n width,\n detailsPlacement,\n );\n\n const contextValue = useMemo(\n () => ({ isListFloating, isDetailsFloating, isDetailsSheet }),\n [isListFloating, isDetailsFloating, isDetailsSheet],\n );\n\n const Component = asChild ? Slot : 'div';\n\n return (\n <ChatCardThreeColumnLayoutContext.Provider value={contextValue}>\n <Component\n ref={mergedRef}\n data-testid=\"chat-card-three-column-layout\"\n data-slot=\"chat-card-three-column-layout\"\n data-details-placement={detailsPlacement}\n data-size={size}\n data-list-floating={isListFloating}\n data-details-floating={isDetailsFloating}\n className={cn(chatCardThreeColumnLayoutVariants(), className)}\n {...rest}\n >\n {children}\n </Component>\n </ChatCardThreeColumnLayoutContext.Provider>\n );\n },\n);\n\nChatCardThreeColumnLayout.displayName = 'ChatCardThreeColumnLayout';\n\nexport interface ChatCardThreeColumnLayoutListProps extends Omit<\n ComponentProps<'aside'>,\n 'children'\n> {\n children: ChatCardThreeColumnLayoutPaneChildren;\n asChild?: boolean;\n}\n\n/**\n * Column 1 when the layout has room for it beside a usable Main; otherwise a strip pinned\n * to the bottom, over Main. It is the same element either way, so only the render prop's\n * output changes when it switches.\n *\n * `data-floating` is set too, for styling the pane itself without a render prop.\n */\nexport const ChatCardThreeColumnLayoutList = forwardRef<\n HTMLDivElement,\n ChatCardThreeColumnLayoutListProps\n>(function ChatCardThreeColumnLayoutList({ children, className, asChild = false, ...rest }, ref) {\n const { isListFloating } = useChatCardThreeColumnLayoutContext('ChatCardThreeColumnLayoutList');\n\n const Component = asChild ? Slot : 'aside';\n\n return (\n <Component\n ref={ref}\n data-testid=\"chat-card-three-column-layout-list\"\n data-slot=\"chat-card-three-column-layout-list\"\n data-floating={isListFloating}\n className={cn(chatCardThreeColumnLayoutListVariants(), className)}\n {...rest}\n >\n {renderPane(children, isListFloating)}\n </Component>\n );\n});\n\nChatCardThreeColumnLayoutList.displayName = 'ChatCardThreeColumnLayoutList';\n\nexport interface ChatCardThreeColumnLayoutMainProps extends ComponentProps<'main'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\n/**\n * Column 2, the flexible track. It never floats, so it takes plain children. It still\n * requires the layout, because outside the grid its `[grid-area:main]` means nothing and\n * the pane collapses without any error.\n */\nexport const ChatCardThreeColumnLayoutMain = forwardRef<\n HTMLDivElement,\n ChatCardThreeColumnLayoutMainProps\n>(function ChatCardThreeColumnLayoutMain({ children, className, asChild = false, ...rest }, ref) {\n useChatCardThreeColumnLayoutContext('ChatCardThreeColumnLayoutMain');\n\n const Component = asChild ? Slot : 'main';\n\n return (\n <Component\n ref={ref}\n data-testid=\"chat-card-three-column-layout-main\"\n data-slot=\"chat-card-three-column-layout-main\"\n className={cn(chatCardThreeColumnLayoutMainVariants(), className)}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n\nChatCardThreeColumnLayoutMain.displayName = 'ChatCardThreeColumnLayoutMain';\n\nexport interface ChatCardThreeColumnLayoutDetailsProps extends Omit<\n ComponentProps<'aside'>,\n 'children'\n> {\n children: ChatCardThreeColumnLayoutPaneChildren;\n asChild?: boolean;\n}\n\n/**\n * Column 3. Mount it only while there is something to show: its presence is what adds the\n * third grid track, so rendering it empty would reserve a blank column.\n *\n * It takes a column when the layout is wide enough and `detailsPlacement` allows it, and\n * floats over Main otherwise: pinned to Main's right edge, or a bottom sheet on a narrow\n * layout (`data-sheet`). `isFloating` in the render prop reflects all of that.\n */\nexport const ChatCardThreeColumnLayoutDetails = forwardRef<\n HTMLDivElement,\n ChatCardThreeColumnLayoutDetailsProps\n>(function ChatCardThreeColumnLayoutDetails(\n { children, className, asChild = false, ...rest },\n ref,\n) {\n const { isDetailsFloating, isDetailsSheet } = useChatCardThreeColumnLayoutContext(\n 'ChatCardThreeColumnLayoutDetails',\n );\n\n const Component = asChild ? Slot : 'aside';\n\n return (\n <Component\n ref={ref}\n data-testid=\"chat-card-three-column-layout-details\"\n data-slot=\"chat-card-three-column-layout-details\"\n data-floating={isDetailsFloating}\n data-sheet={isDetailsSheet}\n className={cn(chatCardThreeColumnLayoutDetailsVariants(), className)}\n {...rest}\n >\n {renderPane(children, isDetailsFloating)}\n </Component>\n );\n});\n\nChatCardThreeColumnLayoutDetails.displayName = 'ChatCardThreeColumnLayoutDetails';\n\nexport interface ChatCardThreeColumnLayoutPanelProps extends ComponentProps<'section'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\n/**\n * An overlay covering everything but the List column (the whole layout when List floats),\n * inset 12px. Mount it only while it is open. Main and Details stay mounted under it, so\n * a map keeps its viewport and the open Details item survives closing the Panel.\n *\n * The pane is transparent: draw the surface (background, radius, shadow) in its content,\n * as for Details.\n */\nexport const ChatCardThreeColumnLayoutPanel = forwardRef<\n HTMLElement,\n ChatCardThreeColumnLayoutPanelProps\n>(function ChatCardThreeColumnLayoutPanel({ children, className, asChild = false, ...rest }, ref) {\n const { isListFloating } = useChatCardThreeColumnLayoutContext('ChatCardThreeColumnLayoutPanel');\n const Component = asChild ? Slot : 'section';\n\n return (\n <Component\n ref={ref}\n data-testid=\"chat-card-three-column-layout-panel\"\n data-slot=\"chat-card-three-column-layout-panel\"\n data-list-floating={isListFloating}\n className={cn(chatCardThreeColumnLayoutPanelVariants(), className)}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n\nChatCardThreeColumnLayoutPanel.displayName = 'ChatCardThreeColumnLayoutPanel';\n","import { cva } from 'class-variance-authority';\n\n/*\n * The layout switches on a container query against its own width, not on viewport\n * breakpoints: the card is sized by the chat window, and a sidebar or split view makes the\n * viewport claim room the card doesn't have. `336px` and `744px` are `ASIDE_WIDTH` and\n * `TWO_COLUMN_MIN_WIDTH` from `chat-card-two-column-layout.sizing.ts`, written out because\n * Tailwind cannot read a constant. Change both together.\n *\n * The container is named so a two-column layout nested in another container still queries\n * its own root, not the nearest ancestor.\n *\n * Class strings are written out in full because Tailwind finds classes by scanning source;\n * a class assembled from a constant is never generated.\n */\n\n/**\n * Root: the query container, nothing else. An element cannot match a container query\n * against its own width, so the grid lives one level down, in `…GridVariants`.\n */\nexport const chatCardTwoColumnLayoutVariants = cva(['@container/chat-card-two-column-layout']);\n\n/**\n * The grid, rendered by the root around its children.\n *\n * Stacked, the rows are `auto 1fr`, so with a height on the root Main takes whatever Aside\n * leaves. Side by side there is one `1fr` row; the stacked template would otherwise leave an\n * empty `1fr` second row taking the height.\n */\nexport const chatCardTwoColumnLayoutGridVariants = cva([\n 'grid h-full gap-16',\n 'grid-cols-[minmax(0,1fr)] grid-rows-[auto_1fr]',\n '@[744px]/chat-card-two-column-layout:grid-cols-[336px_minmax(0,1fr)] @[744px]/chat-card-two-column-layout:grid-rows-[minmax(0,1fr)]',\n]);\n\n/**\n * Row 1 when stacked, column 1 when side by side. In the column, `min-h-0` + `overflow-hidden`\n * keep a long list inside the row. Without them the grid item grows to its content and the\n * card gets taller instead of scrolling.\n */\nexport const chatCardTwoColumnLayoutAsideVariants = cva([\n 'min-w-0 min-h-0',\n '@[744px]/chat-card-two-column-layout:h-full @[744px]/chat-card-two-column-layout:overflow-hidden',\n]);\n\n/**\n * The flexible track. `min-w-0` because a grid item's minimum width is its content by\n * default: a map or a wide table would push the track past the card. `relative` so the\n * consumer can anchor their own overlays to Main.\n */\nexport const chatCardTwoColumnLayoutMainVariants = cva(['relative min-w-0 min-h-0 h-full']);\n\n/**\n * Width recipe for the `ChatCard` that wraps the layout. The same recipe, for the same\n * reason, as `chatCardThreeColumnLayoutCardVariants`: a grid of `1fr` tracks has no intrinsic\n * width, so inside a shrink-to-fit message the card would collapse to nothing. It takes the\n * whole chat window instead, and the layout decides whether two columns fit.\n *\n * Gated on `data-state=open` so a collapsed card goes back to header width.\n */\nexport const chatCardTwoColumnLayoutCardVariants = cva([\n 'data-[state=open]:w-full data-[state=open]:mx-0',\n // `100%` fallback, like every other read of the variable, for a card outside `ChatContainer`\n 'data-[state=open]:min-w-[min(1130px,calc(var(--chat-window-width,100%)-var(--spacing-message)*2))]',\n]);\n","import { Slot } from '@radix-ui/react-slot';\nimport { createContext, forwardRef, useContext } from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nimport {\n chatCardTwoColumnLayoutAsideVariants,\n chatCardTwoColumnLayoutGridVariants,\n chatCardTwoColumnLayoutMainVariants,\n chatCardTwoColumnLayoutVariants,\n} from './chat-card-two-column-layout.variants';\n\n/**\n * Carries nothing but \"inside the layout\". The panes' container queries only match inside\n * the root's named container, so a pane outside it would stay stacked forever without any\n * error. The check turns that into one.\n */\nconst ChatCardTwoColumnLayoutContext = createContext(false);\n\nfunction useChatCardTwoColumnLayoutContext(part: string) {\n if (!useContext(ChatCardTwoColumnLayoutContext)) {\n throw new Error(\n `[web-chat-ui] \"${part}\" must be used within a ChatCardTwoColumnLayout. ` +\n 'Its columns come from the layout’s container query, so render it as a child of ' +\n 'the ChatCardTwoColumnLayout element, not as a sibling of it.',\n );\n }\n}\n\nexport interface ChatCardTwoColumnLayoutProps extends ComponentProps<'div'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\n/**\n * A two-pane card body: Aside (a 336px column) beside Main (flexible), stacked as Aside over\n * Main when the layout is narrower than 744px.\n *\n * The switch is a container query on the layout's **own width**, not a viewport breakpoint,\n * because the card is sized by the chat window, not the viewport. Nothing floats, so unlike\n * the three-column layout there is no measuring and no render prop.\n *\n * The root is the query container and renders the grid inside itself: an element cannot\n * query its own width. `className` goes on the root, so a height set there reaches the grid.\n * Height is not set here, because it belongs to the content, so pass it in `className`.\n */\nexport const ChatCardTwoColumnLayout = forwardRef<HTMLDivElement, ChatCardTwoColumnLayoutProps>(\n function ChatCardTwoColumnLayout({ children, className, asChild = false, ...rest }, ref) {\n const Component = asChild ? Slot : 'div';\n\n return (\n <ChatCardTwoColumnLayoutContext.Provider value>\n <Component\n ref={ref}\n data-testid=\"chat-card-two-column-layout\"\n data-slot=\"chat-card-two-column-layout\"\n className={cn(chatCardTwoColumnLayoutVariants(), className)}\n {...rest}\n >\n <div\n data-testid=\"chat-card-two-column-layout-grid\"\n data-slot=\"chat-card-two-column-layout-grid\"\n className={chatCardTwoColumnLayoutGridVariants()}\n >\n {children}\n </div>\n </Component>\n </ChatCardTwoColumnLayoutContext.Provider>\n );\n },\n);\n\nChatCardTwoColumnLayout.displayName = 'ChatCardTwoColumnLayout';\n\nexport interface ChatCardTwoColumnLayoutAsideProps extends ComponentProps<'aside'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\n/** Column 1 (336px) when the layout is at least 744px wide; the first row below that. */\nexport const ChatCardTwoColumnLayoutAside = forwardRef<\n HTMLElement,\n ChatCardTwoColumnLayoutAsideProps\n>(function ChatCardTwoColumnLayoutAside({ children, className, asChild = false, ...rest }, ref) {\n useChatCardTwoColumnLayoutContext('ChatCardTwoColumnLayoutAside');\n\n const Component = asChild ? Slot : 'aside';\n\n return (\n <Component\n ref={ref}\n data-testid=\"chat-card-two-column-layout-aside\"\n data-slot=\"chat-card-two-column-layout-aside\"\n className={cn(chatCardTwoColumnLayoutAsideVariants(), className)}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n\nChatCardTwoColumnLayoutAside.displayName = 'ChatCardTwoColumnLayoutAside';\n\nexport interface ChatCardTwoColumnLayoutMainProps extends ComponentProps<'main'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\n/** The flexible track: column 2 side by side, the second row (taking the rest) stacked. */\nexport const ChatCardTwoColumnLayoutMain = forwardRef<\n HTMLElement,\n ChatCardTwoColumnLayoutMainProps\n>(function ChatCardTwoColumnLayoutMain({ children, className, asChild = false, ...rest }, ref) {\n useChatCardTwoColumnLayoutContext('ChatCardTwoColumnLayoutMain');\n\n const Component = asChild ? Slot : 'main';\n\n return (\n <Component\n ref={ref}\n data-testid=\"chat-card-two-column-layout-main\"\n data-slot=\"chat-card-two-column-layout-main\"\n className={cn(chatCardTwoColumnLayoutMainVariants(), className)}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n\nChatCardTwoColumnLayoutMain.displayName = 'ChatCardTwoColumnLayoutMain';\n","import { createContext, useContext, type ReactNode } from 'react';\n\nimport type { ChatCardLevel } from './types';\n\nexport interface ChatCardContextValue {\n isCollapsible: boolean;\n level: ChatCardLevel;\n open: boolean;\n}\n\nconst ChatCardContext = createContext<ChatCardContextValue | null>(null);\n\nexport function useChatCardContext() {\n const context = useContext(ChatCardContext);\n\n if (!context) {\n throw new Error(\n '[web-chat-ui] useChatCardContext() called outside ChatCard. ' +\n 'Wrap this component in <ChatCard>, or the provider and the caller resolved two copies of the package.',\n );\n }\n\n return context;\n}\n\nexport function ChatCardProvider({\n value,\n children,\n}: {\n value: ChatCardContextValue;\n children: ReactNode;\n}) {\n return <ChatCardContext.Provider value={value}>{children}</ChatCardContext.Provider>;\n}\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { ChevronDownIcon } from '@swisper.ai/icons';\nimport {\n CollapsibleTrigger,\n IconButton,\n Tooltip,\n Typography,\n type IconButtonProps,\n type TypographyProps,\n} from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport { useChatCardContext } from '../context';\n\nexport interface ChatCardHeaderProps extends Omit<ComponentProps<'header'>, 'aria-label'> {\n children: ReactNode;\n}\n\nexport function ChatCardHeader({ className, children, ...rest }: ChatCardHeaderProps) {\n const { isCollapsible, level } = useChatCardContext();\n\n const inner = (\n <div\n data-slot=\"chat-card-header-hover-area\"\n className={cn(\n 'w-full',\n 'flex flex-row items-start',\n 'gap-card-header-gap',\n level === 1 && 'px-card-header-hover-area rounded-card-header',\n level === 1 && isCollapsible && 'hover:bg-layout-accent-low-background-hover-base',\n level === 1 && 'group-hover/chat-card:bg-layout-accent-low-background-hover-base',\n !isCollapsible && 'cursor-default',\n )}\n >\n {children}\n </div>\n );\n\n return (\n <header\n data-slot=\"chat-card-header\"\n className={cn(\n 'flex items-start',\n level === 1 ? 'p-card-header-lvl-1' : 'px-card-header-lvl-2',\n className,\n )}\n {...rest}\n >\n {isCollapsible ? (\n <CollapsibleTrigger className=\"w-full\" asChild>\n {inner}\n </CollapsibleTrigger>\n ) : (\n inner\n )}\n </header>\n );\n}\n\nexport interface ChatCardIconProps extends ComponentProps<'div'> {\n children: ReactNode;\n}\n\nexport function ChatCardIcon({ className, children, ...rest }: ChatCardIconProps) {\n const { level } = useChatCardContext();\n\n return (\n <div\n data-testid=\"chat-card-icon\"\n className={cn(\n 'shrink-0',\n 'inline-flex items-center justify-center self-center',\n 'size-[32px]',\n 'bg-avatar-background',\n 'rounded-full overflow-hidden',\n level === 1 ? 'my-[14px]' : 'my-4',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatCardHeaderContentProps extends ComponentProps<'div'> {\n children: ReactNode;\n}\n\nexport function ChatCardHeaderContent({\n className,\n children,\n ...rest\n}: ChatCardHeaderContentProps) {\n const { level } = useChatCardContext();\n\n return (\n <div\n data-testid=\"chat-card-header-content\"\n className={cn(\n 'flex-1',\n 'flex flex-col gap-0 items-start justify-center',\n level === 1 ? 'min-h-[60px] py-1.5' : 'min-h-[40px] py-4',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatCardTitleProps extends Omit<TypographyProps, 'variant'> {\n children: ReactNode;\n}\n\nexport function ChatCardTitle({ className, children, ...rest }: ChatCardTitleProps) {\n return (\n <Typography\n data-testid=\"chat-card-title\"\n variant=\"body-medium\"\n className={cn(className)}\n {...rest}\n >\n {children}\n </Typography>\n );\n}\n\nexport interface ChatCardSubTitleProps extends Omit<TypographyProps, 'variant'> {\n children: ReactNode;\n}\n\nexport function ChatCardSubTitle({ className, children, ...rest }: ChatCardSubTitleProps) {\n return (\n <Typography\n data-testid=\"chat-card-sub-title\"\n variant=\"body-small-high\"\n className={cn('text-text-secondary', className)}\n {...rest}\n >\n {children}\n </Typography>\n );\n}\n\nexport interface ChatCardActionsProps extends Omit<ComponentProps<'div'>, 'aria-label'> {\n children: ReactNode;\n}\n\nexport function ChatCardActions({ className, children, ...rest }: ChatCardActionsProps) {\n const { level } = useChatCardContext();\n\n return (\n <div\n role=\"group\"\n data-testid=\"chat-card-actions\"\n className={cn(\n 'ml-auto shrink-0',\n 'flex items-center self-center gap-card-header-gap-icon-buttons',\n 'min-h-[32px]',\n '[&>button]:text-secondary-main!',\n level === 1 ? 'my-[14px]' : 'my-4',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatCardActionButtonProps extends Omit<IconButtonProps, 'variant' | 'size'> {\n children: ReactNode;\n shouldPreventCollapse?: boolean;\n tooltip?: ReactNode;\n}\n\nexport function ChatCardActionButton({\n className,\n children,\n shouldPreventCollapse = true,\n tooltip,\n onClick,\n ...rest\n}: ChatCardActionButtonProps) {\n function handleClick(e: React.MouseEvent<HTMLButtonElement>) {\n if (shouldPreventCollapse) {\n e.stopPropagation();\n }\n\n onClick?.(e);\n }\n\n const content = (\n <IconButton\n variant=\"tertiary\"\n size=\"sm\"\n className={cn(className)}\n onClick={handleClick}\n {...rest}\n >\n {children}\n </IconButton>\n );\n\n if (!tooltip) {\n return content;\n }\n\n return <Tooltip tooltip={tooltip}>{content}</Tooltip>;\n}\n\nexport interface ChatCardCollapsibleButtonProps extends Omit<\n ChatCardActionButtonProps,\n 'children' | 'shouldPreventCollapse'\n> {}\n\nexport function ChatCardCollapsibleButton({ className, ...rest }: ChatCardCollapsibleButtonProps) {\n const { isCollapsible } = useChatCardContext();\n if (!isCollapsible) {\n return;\n }\n\n return (\n <ChatCardActionButton\n shouldPreventCollapse={false}\n isSemantic={false}\n className={cn(\n className,\n 'transition-transform duration-300',\n 'group-data-[state=open]/collapsible:rotate-180',\n )}\n {...rest}\n >\n <ChevronDownIcon />\n </ChatCardActionButton>\n );\n}\n","import { Slot } from '@radix-ui/react-slot';\nimport type { ComponentProps, ReactNode } from 'react';\n\nimport { CollapsibleContent } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport { useChatCardContext } from '../context';\n\nexport interface ChatCardMediaProps extends Omit<ComponentProps<'figure'>, 'aria-label'> {\n children: ReactNode;\n}\n\nexport function ChatCardMedia({ className, children, ...rest }: ChatCardMediaProps) {\n return (\n <figure\n data-testid=\"chat-card-media\"\n className={cn('min-h-0 shrink-0 h-[222px]', className)}\n {...rest}\n >\n {children}\n </figure>\n );\n}\n\nexport interface ChatCardBodyProps extends Omit<ComponentProps<'div'>, 'aria-label'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\nexport function ChatCardBody({ className, children, asChild = false, ...rest }: ChatCardBodyProps) {\n const Component = asChild ? Slot : 'div';\n\n return (\n <CollapsibleContent\n data-testid=\"chat-card-body\"\n className={cn(\n 'flex flex-1 flex-col',\n 'min-h-0',\n 'md:group-data-[collapsible=true]/chat-card:max-h-[90vh]',\n 'overflow-hidden',\n className,\n )}\n asChild\n {...rest}\n >\n <Component>{children}</Component>\n </CollapsibleContent>\n );\n}\n\nexport interface ChatCardContentProps extends Omit<ComponentProps<'div'>, 'aria-label'> {\n children: ReactNode;\n asChild?: boolean;\n hasPadding?: boolean;\n hasHeaderPadding?: boolean;\n}\n\nexport function ChatCardContent({\n className,\n children,\n asChild = false,\n hasPadding = true,\n hasHeaderPadding = true,\n ...rest\n}: ChatCardContentProps) {\n const { level } = useChatCardContext();\n const Component = asChild ? Slot : 'div';\n\n return (\n <Component\n data-testid=\"chat-card-content\"\n data-padding={hasPadding}\n data-has-header-padding={hasHeaderPadding}\n data-level={level}\n className={cn(\n 'overflow-auto',\n 'gap-card-slots-gap',\n 'data-[level=1]:p-card-slots-lvl-1',\n 'data-[level=2]:p-card-slots-lvl-2',\n 'data-[has-header-padding=false]:pt-0',\n 'data-[padding=false]:p-0',\n className,\n )}\n {...rest}\n >\n {children}\n </Component>\n );\n}\n\nexport interface ChatCardPreviewProps extends ComponentProps<'div'> {\n children: ReactNode;\n}\n\nexport function ChatCardPreview({ className, children, ...rest }: ChatCardPreviewProps) {\n const { level } = useChatCardContext();\n\n return (\n <div\n data-testid=\"chat-card-preview\"\n data-level={level}\n className={cn(\n 'group-data-[state=open]/collapsible:hidden',\n 'overflow-auto',\n 'pt-0',\n 'data-[level=1]:p-card-slots-lvl-1',\n 'data-[level=2]:p-card-slots-lvl-2',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n}\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nimport { useChatCardContext } from '../context';\n\nexport interface ChatCardFooterProps extends ComponentProps<'footer'> {\n children: ReactNode;\n}\n\nexport function ChatCardFooter({ className, children, ...rest }: ChatCardFooterProps) {\n const { level } = useChatCardContext();\n\n return (\n <footer\n data-slot=\"chat-card-footer\"\n data-level={level}\n className={cn(\n 'mt-auto',\n 'flex flex-row items-center justify-end',\n 'gap-card-footer-gap',\n 'w-full',\n 'data-[level=1]:p-card-footer-lvl-1',\n 'data-[level=2]:p-card-footer-lvl-2',\n className,\n )}\n {...rest}\n >\n {children}\n </footer>\n );\n}\n\nexport interface ChatCardFooterNotesProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatCardFooterNotes({ className, children }: ChatCardFooterNotesProps) {\n return (\n <div\n data-testid=\"chat-card-footer-notes\"\n className={cn(\n 'mr-auto shrink-0',\n 'flex flex-col items-start justify-center',\n 'gap-card-footer-gap-left-notes',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatCardFooterPriceProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatCardFooterPrice({ className, children }: ChatCardFooterPriceProps) {\n return (\n <div\n data-testid=\"chat-card-footer-price\"\n className={cn(\n 'flex flex-col items-end justify-center',\n 'gap-card-footer-gap-prices',\n 'shrink-0',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatCardFooterActionsProps extends Omit<ComponentProps<'div'>, 'aria-label'> {\n children: ReactNode;\n}\n\nexport function ChatCardFooterActions({\n className,\n children,\n ...rest\n}: ChatCardFooterActionsProps) {\n return (\n <div\n role=\"group\"\n data-testid=\"chat-card-footer-actions\"\n className={cn('flex items-center gap-card-footer-gap shrink-0', className)}\n {...rest}\n >\n {children}\n </div>\n );\n}\n","import { Slot } from '@radix-ui/react-slot';\nimport { forwardRef } from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\n\nimport { Chip, Typography } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatCardForm extends ComponentProps<'form'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\nexport const ChatCardForm = forwardRef<HTMLFormElement, ChatCardForm>(function ChatCardForm(\n { className, children, asChild, ...rest },\n ref,\n) {\n const Component = asChild ? Slot : 'form';\n\n return (\n <Component\n ref={ref}\n data-testid=\"chat-card-form\"\n className={cn(\n 'bg-steel-900 border border-steel-700',\n 'rounded-[12px]',\n 'm-8 mb-16 p-[12px]',\n 'overflow-hidden',\n className,\n )}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n\nexport interface ChatCardAttributesProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatCardAttributes({ className, children }: ChatCardAttributesProps) {\n return (\n <ul\n data-testid=\"chat-card-attributes\"\n className={cn('flex flex-col justify-start items-start gap-8', 'mb-24', className)}\n >\n {children}\n </ul>\n );\n}\n\nexport interface ChatCardAttributeProps {\n className?: string;\n children: ReactNode;\n}\n\nexport function ChatCardAttribute({ className, children, ...rest }: ChatCardAttributeProps) {\n return (\n <li\n data-testid=\"chat-card-attribute-item\"\n className={cn('grid grid-cols-[66px_1fr] gap-8', 'w-full', 'min-h-24', className)}\n {...rest}\n >\n {children}\n </li>\n );\n}\n\nexport interface ChatCardAttributeLabelProps {\n children: ReactNode;\n className?: string;\n hasPadding?: boolean;\n}\n\nexport function ChatCardAttributeLabel({\n className,\n children,\n hasPadding = false,\n ...rest\n}: ChatCardAttributeLabelProps) {\n return (\n <Chip\n variant=\"outlined\"\n size=\"md\"\n color=\"info\"\n data-has-padding={hasPadding}\n className={cn('w-full', 'data-[has-padding=true]:my-[5px]', className)}\n data-testid=\"chat-card-attribute-label\"\n {...rest}\n >\n {children}\n </Chip>\n );\n}\n\nexport interface ChatCardAttributeValueProps extends Omit<ComponentProps<'dt'>, 'aria-Value'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\nexport function ChatCardAttributeValue({\n className,\n children,\n asChild = false,\n ...rest\n}: ChatCardAttributeValueProps) {\n const Component = asChild ? Slot : Typography;\n\n return (\n <Component\n data-testid=\"chat-card-attribute-value\"\n variant=\"body-sm\"\n className={cn('flex-1 text-text-secondary', className)}\n {...rest}\n >\n {children}\n </Component>\n );\n}\n","import { forwardRef, useCallback, useMemo, useState } from 'react';\n\nimport { Collapsible } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport { ChatCardProvider } from './context';\nimport type { ChatCardProps } from './types';\n\nexport { useChatCardContext } from './context';\n\nexport const ChatCard = forwardRef<HTMLElement, ChatCardProps>(function ChatCard(\n {\n className,\n variant = 'default',\n level = 1,\n children,\n fullWidth = false,\n defaultOpen = true,\n open: openProp,\n isRounded = true,\n isCollapsible = true,\n isSelected = false,\n onOpenChange,\n onClick,\n ...rest\n },\n ref,\n) {\n const isControlled = openProp !== undefined;\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const open = isControlled ? openProp : uncontrolledOpen;\n\n const handleOpenChange = useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange],\n );\n\n const contextValue = useMemo(\n () => ({\n isCollapsible,\n level,\n open,\n }),\n [isCollapsible, level, open],\n );\n\n function handleClick(event: React.MouseEvent<HTMLElement>) {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n\n // Closed surface is the expand hit target. Never toggle here: an expanded\n // body/footer click must not collapse the card.\n if (isCollapsible && !open) {\n handleOpenChange(true);\n }\n }\n\n return (\n <ChatCardProvider value={contextValue}>\n <Collapsible isDisabled={!isCollapsible} open={open} onOpenChange={handleOpenChange} asChild>\n <section\n ref={ref}\n role=\"region\"\n aria-current={isSelected}\n data-testid=\"chat-card\"\n data-variant={variant}\n data-level={level}\n data-full-width={fullWidth}\n data-rounded={isRounded}\n data-selected={isSelected}\n data-collapsible={isCollapsible}\n onClick={handleClick}\n className={cn(\n 'group/chat-card',\n // keep card smaller width in a closed state\n 'w-full data-[state=closed]:max-w-(--message-list-content-width) data-[state=closed]:mx-auto',\n 'flex flex-col',\n 'relative overflow-hidden',\n 'border border-solid border-card-border-base',\n 'data-[level=1]:bg-card-background-base',\n 'data-[level=2]:bg-card-background-lvl-2',\n 'data-[full-width=true]:w-full',\n 'data-[level=1]:data-[rounded=true]:rounded-card-lvl-1',\n 'data-[level=2]:data-[rounded=true]:rounded-card-lvl-2',\n 'data-[selected=true]:border-primary-main',\n 'hover:data-[variant=action]:bg-secondary-states-hover',\n 'data-[collapsible=true]:data-[state=closed]:cursor-pointer',\n className,\n )}\n {...rest}\n >\n {children}\n </section>\n </Collapsible>\n </ChatCardProvider>\n );\n});\n\nChatCard.displayName = 'ChatCard';\n","import { useState } from 'react';\n\ninterface UseEditChatCardProps {\n isEditable: boolean;\n defaultEditing?: boolean;\n}\n\nexport function useEditChatCard({ isEditable, defaultEditing = false }: UseEditChatCardProps) {\n const [isEditing, setIsEditing] = useState(defaultEditing);\n\n function checkIsEditable() {\n if (!isEditable) {\n console.warn('Chat card is not editable');\n return false;\n }\n\n return true;\n }\n\n function startEdit() {\n if (!checkIsEditable()) {\n return;\n }\n\n setIsEditing(true);\n }\n\n function discard() {\n if (!checkIsEditable()) {\n return;\n }\n\n setIsEditing(false);\n }\n\n function toggleEdit() {\n if (!checkIsEditable()) {\n return;\n }\n\n setIsEditing((e) => !e);\n }\n\n return {\n isEditable,\n isEditing,\n startEdit,\n discard,\n toggleEdit,\n };\n}\n","import { type ReactNode, createContext, useContext } from 'react';\n\nimport { useEditChatCard } from './hooks';\n\ntype EditableChatCardContextValue = ReturnType<typeof useEditChatCard>;\n\nconst EditableChatCardContext = createContext<EditableChatCardContextValue>(null!);\n\nexport function useEditableChatCardContext() {\n const context = useContext(EditableChatCardContext);\n\n if (!context) {\n throw new Error(\n '\"useEditableChatCardContext\" must be used within a EditableChatCardContextProvider',\n );\n }\n\n return context;\n}\n\ninterface EditableChatCardContextProviderProps {\n children: ReactNode;\n defaultEditing?: boolean;\n isEditable?: boolean;\n}\n\nexport function EditableChatCardContextProvider({\n children,\n defaultEditing = false,\n isEditable = false,\n}: EditableChatCardContextProviderProps) {\n const contextValue = useEditChatCard({\n isEditable,\n defaultEditing,\n });\n\n return (\n <EditableChatCardContext.Provider value={contextValue}>\n {children}\n </EditableChatCardContext.Provider>\n );\n}\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nexport type ChatCardContainerVariant = 'fixed' | 'fluid' | 'full';\n\nexport interface ChatCardContainerProps extends ComponentProps<'div'> {\n children: ReactNode;\n /**\n * How the card is sized against the chat window published by `ChatContainer`:\n *\n * - `fixed` — clamped to the reading column (`--message-list-content-width`) from\n * `md` up, so body cards line up with the message text.\n * - `fluid` — shrinks to its content from `md` up, still capped at the window.\n * - `full` — always the full chat window width.\n *\n * Below `md` (820px in this design system, not Tailwind's default 768px) all three\n * are full width. There is no room to distinguish them on a phone, and a card\n * narrower than the viewport there reads as a layout bug.\n */\n variant?: ChatCardContainerVariant;\n /**\n * Set when the card is rendered inside a message body rather than as its own block,\n * so it aligns with the surrounding text.\n *\n * This swaps the inset from margin to padding rather than adding a second one: the\n * width cap opens up to the full `--chat-window-width` and `px-message` supplies the\n * gutter, so the total inset stays at one `--spacing-message` either way. Applying\n * `px-message` on top of the block cap instead would inset an inlined card by two\n * gutters and it would visibly not line up with the text around it.\n */\n inline?: boolean;\n}\n\n/**\n * Sizes a card inside a `ChatContainer`, against the `--chat-window-width` and\n * `--message-list-content-width` variables that container publishes.\n *\n * `full` is the base behaviour and adds no classes of its own — every variant starts\n * at the window width less one `--spacing-message` gutter, and `fixed` and `fluid`\n * narrow it from `md` up.\n *\n * Both variables are read with a `100%` fallback, so a card rendered outside a\n * `ChatContainer` (a portal, a test, a Storybook story) degrades to its parent's width\n * instead of collapsing to zero.\n */\nexport function ChatCardContainer({\n children,\n variant = 'fixed',\n inline = false,\n className,\n ...rest\n}: ChatCardContainerProps) {\n return (\n <div\n data-testid=\"chat-card-container\"\n data-variant={variant}\n data-inline={inline}\n className={cn(\n 'mx-auto w-full',\n 'max-w-[calc(var(--chat-window-width,100%)-var(--spacing-message))]',\n 'md:data-[variant=fixed]:max-w-[calc(var(--message-list-content-width,var(--spacing-chat-area))-var(--spacing-message))]',\n 'md:data-[variant=fluid]:min-w-[calc(var(--message-list-content-width,var(--spacing-chat-area))-var(--spacing-message))]',\n 'md:data-[variant=fluid]:w-fit',\n 'md:data-[variant=full]:max-w-full',\n 'data-[inline=true]:max-w-[var(--chat-window-width,100%)]',\n 'data-[inline=true]:px-message',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n}\n","import { Slot } from '@radix-ui/react-slot';\nimport {\n createContext,\n useCallback,\n useContext,\n useLayoutEffect,\n useMemo,\n useState,\n type ComponentProps,\n type CSSProperties,\n type ReactNode,\n} from 'react';\n\nimport { cn, useElementMeasure } from '@swisper.ai/web-core';\n\n/**\n * Width of the reading column when the consumer does not override it.\n *\n * Read from `--spacing-chat-area` (736px) rather than hardcoded, so a theme that\n * retunes the chat area token moves the reading column with it.\n */\nconst DEFAULT_CONTENT_WIDTH = 'var(--spacing-chat-area)';\n\n/**\n * The slots a child can measure itself into, and the custom property each publishes.\n *\n * These two heights cannot be measured by `ChatContainer` itself — they belong to\n * specific children whose size the rest of the layout has to react to (the composer\n * grows as the user types; the welcome box only exists on an empty chat). The slot\n * reports upward so the variable lands on the container, where *siblings* can read it\n * too; publishing it on the slot's own element would scope it to that subtree and the\n * message list could not size against it.\n */\nconst SLOT_VARIABLES = {\n prompt: '--type-window-height',\n welcome: '--welcome-screen-box-height',\n} as const;\n\ntype ChatContainerSlot = keyof typeof SLOT_VARIABLES;\n\ntype MeasuredLength = number | 'unset';\n\n/** `unset` mirrors the pre-measurement state; for a height it computes as `auto`. */\nfunction toCssLength(value: MeasuredLength): string {\n return value === 'unset' ? 'unset' : `${value}px`;\n}\n\ninterface ChatContainerContextValue {\n setSlotHeight: (slot: ChatContainerSlot, height: MeasuredLength) => void;\n}\n\nconst ChatContainerContext = createContext<ChatContainerContextValue | null>(null);\n\nfunction useChatContainerContext() {\n const context = useContext(ChatContainerContext);\n\n if (!context) {\n throw new Error(\n '[web-chat-ui] ChatContainer slot rendered outside a ChatContainer. ' +\n 'ChatContainerPrompt and ChatContainerWelcome report their measured height up ' +\n 'to the container, so one must be mounted above them. If it is mounted, check ' +\n 'the slot is not rendered through a portal that escapes the provider.',\n );\n }\n\n return context;\n}\n\nexport interface ChatContainerProps extends ComponentProps<'section'> {\n children: ReactNode;\n /**\n * Max width of the reading column, published as `--message-list-content-width` and\n * consumed by `ChatCardContainer`'s `fixed` variant. Any CSS length.\n *\n * The published value is clamped with `min()` against the measured window width, so\n * a container narrower than the reading column never sizes a child wider than\n * itself — the case that makes a card overflow horizontally in a split-pane layout.\n */\n contentWidth?: string;\n asChild?: boolean;\n}\n\n/**\n * Root of a chat surface. Measures its own box and republishes it as CSS custom\n * properties, so descendants size themselves against the chat window without a width\n * being prop-drilled through every layer:\n *\n * - `--chat-window-width` / `--chat-window-height` — the measured border box, or\n * `100%` until the first measurement lands.\n * - `--message-list-content-width` — the reading column (see `contentWidth`).\n * - `--type-window-height` / `--welcome-screen-box-height` — reported up by\n * `ChatContainerPrompt` and `ChatContainerWelcome`; `unset` while unmounted.\n *\n * Deliberately applies **no horizontal padding of its own**. `useElementMeasure`\n * reports the border box, so padding here would be counted inside\n * `--chat-window-width`, and every child sizing against that variable would overflow\n * by exactly that padding. Insetting is the child's job instead, through the\n * `--spacing-message` gutter that `ChatCardContainer` subtracts.\n *\n * Every read site carries a `100%` fallback, so children still lay out sensibly when\n * rendered outside a `ChatContainer` (portals, tests, Storybook).\n */\nexport function ChatContainer({\n asChild = false,\n children,\n className,\n contentWidth = DEFAULT_CONTENT_WIDTH,\n style,\n ...rest\n}: ChatContainerProps) {\n const Comp = asChild ? Slot : 'section';\n const { ref, width, height } = useElementMeasure<HTMLElement>();\n const [slotHeights, setSlotHeights] = useState<Record<ChatContainerSlot, MeasuredLength>>({\n prompt: 'unset',\n welcome: 'unset',\n });\n\n const setSlotHeight = useCallback((slot: ChatContainerSlot, slotHeight: MeasuredLength) => {\n // Returning the same object on an unchanged height keeps a slot's resize effect\n // from re-rendering the whole chat on every observer callback.\n setSlotHeights((current) =>\n current[slot] === slotHeight ? current : { ...current, [slot]: slotHeight },\n );\n }, []);\n\n const contextValue = useMemo<ChatContainerContextValue>(\n () => ({ setSlotHeight }),\n [setSlotHeight],\n );\n\n const containerStyle = useMemo(\n () =>\n ({\n '--chat-window-width': width === 'unset' ? '100%' : `${width}px`,\n '--chat-window-height': height === 'unset' ? '100%' : `${height}px`,\n '--message-list-content-width': `min(${contentWidth}, var(--chat-window-width))`,\n [SLOT_VARIABLES.prompt]: toCssLength(slotHeights.prompt),\n [SLOT_VARIABLES.welcome]: toCssLength(slotHeights.welcome),\n ...style,\n }) as CSSProperties,\n [width, height, contentWidth, slotHeights, style],\n );\n\n return (\n <ChatContainerContext.Provider value={contextValue}>\n <Comp\n ref={ref}\n data-testid=\"chat-container\"\n className={cn('relative flex h-full min-h-0 w-full flex-col', className)}\n style={containerStyle}\n {...rest}\n >\n {children}\n </Comp>\n </ChatContainerContext.Provider>\n );\n}\n\n/** Measures the slot element and reports its height to the nearest `ChatContainer`. */\nfunction useChatContainerSlot(slot: ChatContainerSlot) {\n const { setSlotHeight } = useChatContainerContext();\n // `HTMLElement`, not `HTMLDivElement`: with `asChild` the measured node is whatever\n // element the consumer rendered, and the callback ref has to accept all of them.\n const { ref, height } = useElementMeasure<HTMLElement>();\n\n useLayoutEffect(() => {\n setSlotHeight(slot, height);\n\n // Reset on unmount so a layout that hides the welcome box after the first message\n // does not leave a stale height behind for the message list to reserve space for.\n return () => setSlotHeight(slot, 'unset');\n }, [slot, height, setSlotHeight]);\n\n return ref;\n}\n\nexport interface ChatContainerSlotProps extends ComponentProps<'div'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\n/**\n * Wraps the composer. Publishes its measured height as `--type-window-height` on the\n * container, so the message list can reserve room for a composer that grows as the\n * user types.\n */\nexport function ChatContainerPrompt({\n asChild = false,\n children,\n className,\n ...rest\n}: ChatContainerSlotProps) {\n const ref = useChatContainerSlot('prompt');\n const Comp = asChild ? Slot : 'div';\n\n return (\n <Comp\n ref={ref}\n data-testid=\"chat-container-prompt\"\n className={cn('shrink-0', className)}\n {...rest}\n >\n {children}\n </Comp>\n );\n}\n\n/**\n * Wraps the empty-chat welcome box. Publishes its measured height as\n * `--welcome-screen-box-height` on the container.\n */\nexport function ChatContainerWelcome({\n asChild = false,\n children,\n className,\n ...rest\n}: ChatContainerSlotProps) {\n const ref = useChatContainerSlot('welcome');\n const Comp = asChild ? Slot : 'div';\n\n return (\n <Comp\n ref={ref}\n data-testid=\"chat-container-welcome\"\n className={cn('shrink-0', className)}\n {...rest}\n >\n {children}\n </Comp>\n );\n}\n","import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { useEffect } from 'react';\n\ninterface AutoFocusPluginProps {\n autoFocus?: boolean;\n isDisabled?: boolean;\n defaultSelection?: 'rootStart' | 'rootEnd';\n}\n\nexport function AutoFocusPlugin({\n defaultSelection = 'rootEnd',\n autoFocus,\n isDisabled,\n}: AutoFocusPluginProps) {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n if (!autoFocus || isDisabled) {\n return;\n }\n\n editor.focus(\n () => {\n // If we try and move selection to the same point with setBaseAndExtent, it won't\n // trigger a re-focus on the element. So in the case this occurs, we'll need to correct it.\n // Normally this is fine, Selection API !== Focus API, but fore the intents of the naming\n // of this plugin, which should preserve focus too.\n const activeElement = document.activeElement;\n const rootElement = editor.getRootElement() as HTMLDivElement;\n if (\n rootElement !== null &&\n (activeElement === null || !rootElement.contains(activeElement))\n ) {\n // Note: preventScroll won't work in Webkit.\n rootElement.focus({ preventScroll: true });\n }\n },\n { defaultSelection },\n );\n }, [defaultSelection, editor, autoFocus, isDisabled]);\n\n return null;\n}\n","import { TRANSFORMERS } from '@lexical/markdown';\n\nexport const EXPORT_TRANSFORMERS = TRANSFORMERS;\nexport const IMPORT_TRANSFORMERS = TRANSFORMERS;\n","import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\n\nexport function useChatInputEditor() {\n const [editor] = useLexicalComposerContext();\n\n return editor;\n}\n","import {\n $createParagraphNode,\n $createRangeSelection,\n $createTextNode,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n $selectAll,\n $setSelection,\n} from 'lexical';\n\nexport function $getEditorPlainText(): string {\n return $getRoot().getTextContent();\n}\n\nexport function $setEditorPlainText(value: string): void {\n const root = $getRoot();\n root.clear();\n const paragraph = $createParagraphNode();\n if (value) {\n paragraph.append($createTextNode(value));\n }\n root.append(paragraph);\n}\n\nexport function $setSelectionToEnd(): void {\n const root = $getRoot();\n const lastDescendant = root.getLastDescendant();\n\n if (lastDescendant && $isTextNode(lastDescendant)) {\n const selection = $createRangeSelection();\n const endOffset = lastDescendant.getTextContentSize();\n selection.anchor.set(lastDescendant.getKey(), endOffset, 'text');\n selection.focus.set(lastDescendant.getKey(), endOffset, 'text');\n $setSelection(selection);\n } else {\n $selectAll();\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const focusNode = selection.focus.getNode();\n const focusOffset = $isTextNode(focusNode) ? focusNode.getTextContentSize() : 0;\n selection.anchor.set(selection.focus.key, selection.focus.offset, selection.focus.type);\n selection.focus.set(selection.focus.key, focusOffset, selection.focus.type);\n $setSelection(selection);\n }\n }\n}\n","import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';\nimport { $addUpdateTag, SKIP_DOM_SELECTION_TAG } from 'lexical';\nimport { useEffect, useRef } from 'react';\n\nimport { EXPORT_TRANSFORMERS, IMPORT_TRANSFORMERS } from '../transformers';\n\nimport { useChatInputEditor } from './hooks';\nimport { $setSelectionToEnd } from './utils';\n\ninterface ControlledValuePluginProps {\n value?: string;\n}\n\nexport function ControlledValuePlugin({ value }: ControlledValuePluginProps) {\n const editor = useChatInputEditor();\n const previousValueRef = useRef<string | undefined>();\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n if (value === previousValueRef.current) {\n return;\n }\n\n previousValueRef.current = value;\n\n let currentValue = '';\n editor.getEditorState().read(() => {\n currentValue = $convertToMarkdownString(EXPORT_TRANSFORMERS);\n });\n\n if (value !== undefined && value !== currentValue) {\n editor.update(\n () => {\n $addUpdateTag(SKIP_DOM_SELECTION_TAG);\n $convertFromMarkdownString(value ?? '', IMPORT_TRANSFORMERS);\n $setSelectionToEnd();\n },\n { discrete: true },\n );\n }\n }, [editor, value]);\n\n return null;\n}\n","import { useEffect } from 'react';\n\nimport { useChatInputEditor } from './hooks';\n\ninterface DisabledPluginProps {\n isDisabled?: boolean;\n isReadOnly?: boolean;\n}\n\nexport function DisabledPlugin({ isDisabled, isReadOnly }: DisabledPluginProps) {\n const editor = useChatInputEditor();\n\n useEffect(() => {\n editor.setEditable(!isDisabled && !isReadOnly);\n }, [editor, isDisabled, isReadOnly]);\n\n return null;\n}\n","import { useEffect } from 'react';\n\nimport { useChatInputEditor } from './hooks';\n\ninterface FocusPluginProps {\n onFocusChange?: (isFocused: boolean) => void;\n}\n\nexport function FocusPlugin({ onFocusChange }: FocusPluginProps) {\n const editor = useChatInputEditor();\n\n useEffect(() => {\n if (!onFocusChange) {\n return;\n }\n\n const rootElement = editor.getRootElement();\n if (!rootElement) {\n return;\n }\n\n function handleFocus() {\n if (rootElement && onFocusChange) {\n onFocusChange(true);\n }\n }\n\n function handleBlur(event: FocusEvent) {\n if (rootElement && onFocusChange && !rootElement.contains(event.relatedTarget as Node)) {\n onFocusChange(false);\n }\n }\n\n rootElement.addEventListener('focus', handleFocus, true);\n rootElement.addEventListener('blur', handleBlur, true);\n\n return () => {\n rootElement.removeEventListener('focus', handleFocus, true);\n rootElement.removeEventListener('blur', handleBlur, true);\n };\n }, [editor, onFocusChange]);\n\n return null;\n}\n","import type { LexicalEditor } from 'lexical';\nimport { useEffect, useRef } from 'react';\n\nimport { useChatInputEditor } from './hooks';\nimport { $getEditorPlainText } from './utils';\n\ninterface HasValuePluginProps {\n onHasValueChange?: (hasValue: boolean) => void;\n}\n\nfunction getHasValue(editor: LexicalEditor): boolean {\n let hasValue = false;\n editor.getEditorState().read(() => {\n hasValue = $getEditorPlainText().length > 0;\n });\n return hasValue;\n}\n\nfunction syncHasValue(\n editor: LexicalEditor,\n onHasValueChange: ((hasValue: boolean) => void) | undefined,\n lastHasValueRef: { current: boolean | undefined },\n): void {\n const hasValue = getHasValue(editor);\n\n if (lastHasValueRef.current === hasValue) {\n return;\n }\n\n lastHasValueRef.current = hasValue;\n onHasValueChange?.(hasValue);\n}\n\nexport function HasValuePlugin({ onHasValueChange }: HasValuePluginProps) {\n const editor = useChatInputEditor();\n const lastHasValueRef = useRef<boolean | undefined>();\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n syncHasValue(editor, onHasValueChange, lastHasValueRef);\n\n return editor.registerUpdateListener(() => {\n syncHasValue(editor, onHasValueChange, lastHasValueRef);\n });\n }, [editor, onHasValueChange]);\n\n return null;\n}\n","import {\n $createParagraphNode,\n $createTextNode,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_CRITICAL,\n PASTE_COMMAND,\n} from 'lexical';\nimport { useEffect } from 'react';\n\nimport { useChatInputEditor } from './hooks';\n\nexport function MarkdownPlainPastePlugin() {\n const editor = useChatInputEditor();\n\n useEffect(() => {\n return editor.registerCommand<ClipboardEvent>(\n PASTE_COMMAND,\n (event) => {\n const { clipboardData } = event;\n\n if (!clipboardData) {\n return false;\n }\n\n const plainText = clipboardData.getData('text/plain');\n\n if (!plainText) {\n return false;\n }\n\n event.preventDefault();\n\n editor.update(() => {\n const selection = $getSelection();\n\n if ($isRangeSelection(selection)) {\n selection.insertText(plainText);\n return;\n }\n\n const root = $getRoot();\n root.clear();\n\n const lines = plainText.split(/\\r?\\n/);\n lines.forEach((line) => {\n const paragraph = $createParagraphNode();\n if (line.length > 0) {\n paragraph.append($createTextNode(line));\n }\n root.append(paragraph);\n });\n });\n\n return true;\n },\n COMMAND_PRIORITY_CRITICAL,\n );\n }, [editor]);\n\n return null;\n}\n","import { $convertToMarkdownString } from '@lexical/markdown';\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';\nimport type { EditorState, LexicalEditor } from 'lexical';\nimport { useCallback } from 'react';\n\nimport { EXPORT_TRANSFORMERS } from '../transformers';\n\ninterface ValuePluginProps {\n onChange?: (value: string) => void;\n}\n\nexport function ValuePlugin({ onChange }: ValuePluginProps) {\n const handleChange = useCallback(\n (editorState: EditorState, _editor: LexicalEditor, tags: Set<string>) => {\n if (tags.has('focus')) {\n return;\n }\n\n if (!onChange) {\n return;\n }\n\n try {\n editorState.read(() => {\n onChange($convertToMarkdownString(EXPORT_TRANSFORMERS));\n });\n } catch (error) {\n console.error('ValuePlugin error:', error);\n }\n },\n [onChange],\n );\n\n return <OnChangePlugin onChange={handleChange} />;\n}\n","import { CodeNode } from '@lexical/code';\nimport { LinkNode } from '@lexical/link';\nimport { ListItemNode, ListNode } from '@lexical/list';\nimport { type InitialConfigType, LexicalComposer } from '@lexical/react/LexicalComposer';\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable';\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';\nimport { HeadingNode, QuoteNode } from '@lexical/rich-text';\nimport { createContext, forwardRef, useContext, useMemo, useState } from 'react';\nimport type { CSSProperties, ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from 'react';\n\nimport { Typography } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport {\n AutoFocusPlugin,\n ControlledValuePlugin,\n DisabledPlugin,\n FocusPlugin,\n HasValuePlugin,\n MarkdownPlainPastePlugin,\n ValuePlugin,\n} from './plugins';\n\nexport type ChatInputConfig = InitialConfigType;\n\ninterface ChatInputContextValue {\n isFocused: boolean;\n hasError: boolean;\n hasValue: boolean;\n\n setIsFocused: (isFocused: boolean) => void;\n setHasError: (hasError: boolean) => void;\n setHasValue: (hasValue: boolean) => void;\n}\n\nconst ChatInputContext = createContext<ChatInputContextValue>(null!);\n\nexport function useChatInputContext() {\n const context = useContext(ChatInputContext);\n\n if (!context) {\n throw new Error('\"useChatInputContext\" must be used within a ChatInputContextProvider');\n }\n\n return context;\n}\n\nexport const DEFAULT_CONFIG: ChatInputConfig = {\n namespace: 'chat-input',\n editable: true,\n nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, CodeNode, LinkNode],\n theme: {\n paragraph: 'm-0 min-h-[26px]',\n text: {\n bold: 'font-bold',\n italic: 'italic',\n underline: 'underline',\n },\n },\n onError: (error) => {\n console.error('ChatInput Lexical error:', error);\n },\n};\n\nexport interface ChatInputProps extends ComponentPropsWithoutRef<'div'> {\n initialConfig?: ChatInputConfig;\n}\n\nexport const ChatInput = forwardRef<HTMLDivElement, ChatInputProps>(function ChatInput(\n { className, children, initialConfig = DEFAULT_CONFIG, ...rest },\n ref,\n) {\n const [hasError, setHasError] = useState(false);\n const [hasValue, setHasValue] = useState(false);\n const [isFocused, setIsFocused] = useState(false);\n\n const contextValue = useMemo(\n () => ({\n hasError,\n hasValue,\n isFocused,\n setHasError,\n setHasValue,\n setIsFocused,\n }),\n [hasError, hasValue, isFocused],\n );\n\n return (\n <ChatInputContext.Provider value={contextValue}>\n <LexicalComposer initialConfig={initialConfig}>\n <div\n ref={ref}\n data-testid=\"chat-input\"\n data-focused={isFocused}\n data-empty={!hasValue}\n data-error={hasError}\n aria-invalid={hasError}\n className={cn('group/chat-input', 'relative', className)}\n {...rest}\n >\n {children}\n </div>\n </LexicalComposer>\n </ChatInputContext.Provider>\n );\n});\n\nChatInput.displayName = 'ChatInput';\n\nexport type ChatInputPlaceholderProps = ComponentPropsWithoutRef<'span'>;\n\nexport const ChatInputPlaceholder = forwardRef<HTMLSpanElement, ChatInputPlaceholderProps>(\n function ChatInputPlaceholder({ className, children, ...rest }, ref) {\n return (\n <Typography\n ref={ref}\n variant=\"body\"\n className={cn(\n 'pointer-events-none absolute inset-0 z-0',\n 'min-h-[26px]',\n 'text-text-tertiary',\n className,\n )}\n {...rest}\n >\n {children}\n </Typography>\n );\n },\n);\n\nChatInputPlaceholder.displayName = 'ChatInputPlaceholder';\n\nexport interface ChatInputTextareaProps {\n className?: string;\n style?: CSSProperties | undefined;\n placeholderClassName?: string;\n placeholder?: string;\n children?: ReactNode;\n value?: string;\n autoFocus?: boolean;\n isDisabled?: boolean;\n isReadOnly?: boolean;\n onChange?: (value: string) => void;\n onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;\n}\n\nexport const ChatInputTextarea = forwardRef<HTMLDivElement, ChatInputTextareaProps>(\n function ChatInputTextarea(\n {\n className,\n style,\n placeholderClassName,\n placeholder = 'Input your message...',\n children,\n value,\n autoFocus = true,\n isDisabled = false,\n isReadOnly = false,\n onChange,\n onKeyDown,\n ...rest\n },\n ref,\n ) {\n const { setHasValue, setIsFocused } = useChatInputContext();\n const isReadOnlyState = isReadOnly && !isDisabled;\n\n return (\n <div\n data-testid=\"chat-input-textarea\"\n data-disabled={isDisabled}\n aria-disabled={isDisabled}\n aria-readonly={isReadOnlyState}\n className={cn(\n 'group/chat-input-textarea',\n 'relative',\n 'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-80 data-[disabled=true]:select-none',\n 'data-[readonly=true]:text-text-secondary',\n )}\n style={style}\n {...rest}\n >\n <RichTextPlugin\n contentEditable={\n <ContentEditable\n ref={ref}\n className={cn('min-h-[26px]!', 'overflow-y-auto text-wrap outline-none', className)}\n aria-label=\"Chat input\"\n aria-placeholder={placeholder}\n placeholder={\n <ChatInputPlaceholder className={placeholderClassName}>\n {placeholder}\n </ChatInputPlaceholder>\n }\n onKeyDown={onKeyDown}\n />\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n\n <HistoryPlugin />\n <DisabledPlugin isDisabled={isDisabled} isReadOnly={isReadOnly} />\n <ControlledValuePlugin value={value} />\n <ValuePlugin onChange={onChange} />\n <MarkdownPlainPastePlugin />\n <HasValuePlugin onHasValueChange={setHasValue} />\n <FocusPlugin onFocusChange={setIsFocused} />\n <AutoFocusPlugin autoFocus={autoFocus} isDisabled={isDisabled || isReadOnly} />\n\n {children}\n </div>\n );\n },\n);\n\nChatInputTextarea.displayName = 'ChatInputTextarea';\n","import {\n createContext,\n useCallback,\n useContext,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type MutableRefObject,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { Skeleton } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatListContextValue {\n loadedCount: number;\n totalCount?: number;\n hasMore: boolean;\n isLoading: boolean;\n isLoadingMore: boolean;\n isEmpty: boolean;\n hasError: boolean;\n onLoadMore?: () => void;\n getItemKey: (index: number) => string | number;\n scrollElementRef: RefObject<HTMLDivElement | null>;\n setScrollElement: (node: HTMLDivElement | null) => void;\n loadMoreContentRef: MutableRefObject<ReactNode>;\n loadMoreVersion: number;\n bumpLoadMore: () => void;\n skeletonContainer: HTMLElement | null;\n setSkeletonContainer: (node: HTMLElement | null) => void;\n}\n\nconst ChatListContext = createContext<ChatListContextValue | null>(null);\n\nexport function useChatListContext() {\n const context = useContext(ChatListContext);\n\n if (!context) {\n throw new Error('\"useChatListContext\" must be used within a ChatList');\n }\n\n return context;\n}\n\nexport interface ChatListProps {\n children: ReactNode;\n className?: string;\n loadedCount: number;\n totalCount?: number;\n hasMore?: boolean;\n isLoading?: boolean;\n isLoadingMore?: boolean;\n hasError?: boolean;\n onLoadMore?: () => void;\n getItemKey: (index: number) => string | number;\n 'aria-label'?: string;\n}\n\nexport function ChatList({\n children,\n className,\n loadedCount,\n totalCount,\n hasMore: hasMoreProp,\n isLoading = false,\n isLoadingMore = false,\n hasError = false,\n onLoadMore,\n getItemKey,\n 'aria-label': ariaLabel = 'Chat list',\n}: ChatListProps) {\n const scrollElementRef = useRef<HTMLDivElement | null>(null);\n const loadMoreContentRef = useRef<ReactNode>(null);\n const [loadMoreVersion, setLoadMoreVersion] = useState(0);\n const [skeletonContainer, setSkeletonContainer] = useState<HTMLElement | null>(null);\n const [, setScrollElementVersion] = useState(0);\n\n const setScrollElement = useCallback((node: HTMLDivElement | null) => {\n scrollElementRef.current = node;\n setScrollElementVersion((version) => version + 1);\n }, []);\n\n const bumpLoadMore = useCallback(() => {\n setLoadMoreVersion((version) => version + 1);\n }, []);\n\n const hasMore = hasMoreProp ?? (totalCount != null ? loadedCount < totalCount : false);\n const isEmpty = loadedCount === 0 && !isLoading && !hasError;\n\n const contextValue = useMemo<ChatListContextValue>(\n () => ({\n loadedCount,\n totalCount,\n hasMore,\n isLoading,\n isLoadingMore,\n isEmpty,\n hasError,\n onLoadMore,\n getItemKey,\n scrollElementRef,\n setScrollElement,\n loadMoreContentRef,\n loadMoreVersion,\n bumpLoadMore,\n skeletonContainer,\n setSkeletonContainer,\n }),\n [\n loadedCount,\n totalCount,\n hasMore,\n isLoading,\n isLoadingMore,\n isEmpty,\n hasError,\n onLoadMore,\n getItemKey,\n setScrollElement,\n loadMoreVersion,\n bumpLoadMore,\n skeletonContainer,\n ],\n );\n\n return (\n <ChatListContext.Provider value={contextValue}>\n <div\n data-slot=\"chat-list\"\n data-testid=\"chat-list\"\n data-loading={isLoading}\n data-loading-more={isLoadingMore}\n data-empty={isEmpty}\n data-error={hasError}\n role=\"navigation\"\n aria-label={ariaLabel}\n className={cn('group/chat-list relative flex min-h-0 flex-1 flex-col', className)}\n >\n {children}\n </div>\n </ChatListContext.Provider>\n );\n}\n\nexport interface ChatListSkeletonProps {\n /** Your own placeholder rows. Leave it out to get `rows` default rows built from `Skeleton`. */\n children?: ReactNode;\n /** Number of default rows, used only when `children` is not passed. Rows past the list's height are clipped. */\n rows?: number;\n className?: string;\n}\n\n// Title and preview widths alternate per row, so the placeholder reads as a list of chats.\nconst TITLE_WIDTHS = ['w-2/3', 'w-1/2'] as const;\nconst PREVIEW_WIDTHS = ['w-full', 'w-4/5'] as const;\n\n/**\n * Placeholder for the first page of chats. Renders only while `isLoading` is true and no chats are\n * loaded, in the space `ChatListItems` will fill. It is a `role=\"status\"` region named\n * \"Loading chats\"; its rows are `Skeleton`s from `@swisper.ai/ui`, which are `aria-hidden`.\n */\nexport function ChatListSkeleton({ children, rows = 16, className }: ChatListSkeletonProps) {\n const { isLoading, loadedCount, skeletonContainer } = useChatListContext();\n\n if (!(isLoading && loadedCount === 0) || !skeletonContainer) {\n return null;\n }\n\n return createPortal(\n <div\n data-slot=\"chat-list-skeleton\"\n data-testid=\"chat-list-skeleton\"\n role=\"status\"\n aria-busy=\"true\"\n aria-label=\"Loading chats\"\n className={cn('flex min-h-0 flex-1 flex-col gap-4 overflow-hidden', className)}\n >\n {children ??\n Array.from({ length: rows }, (_, index) => (\n <div\n key={index}\n data-slot=\"chat-list-skeleton-row\"\n className=\"flex shrink-0 flex-col gap-4 px-12 py-8\"\n >\n <div className=\"flex h-20 items-center\">\n <Skeleton className={cn('h-12', TITLE_WIDTHS[index % 2])} />\n </div>\n <div className=\"flex h-16 items-center\">\n <Skeleton className={cn('h-10', PREVIEW_WIDTHS[index % 2])} />\n </div>\n </div>\n ))}\n </div>,\n skeletonContainer,\n );\n}\n\nexport interface ChatListEmptyStateProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatListEmptyState({ children, className }: ChatListEmptyStateProps) {\n const { isEmpty } = useChatListContext();\n\n if (!isEmpty) {\n return null;\n }\n\n return (\n <div\n data-slot=\"chat-list-empty-state\"\n data-testid=\"chat-list-empty-state\"\n role=\"status\"\n aria-live=\"polite\"\n aria-label=\"No chats\"\n className={cn('flex flex-1 items-center justify-center', className)}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatListErrorProps {\n children?: ReactNode;\n error?: Error | string;\n className?: string;\n}\n\nexport function ChatListError({ children, error, className }: ChatListErrorProps) {\n const { hasError, loadedCount } = useChatListContext();\n\n if (!(hasError && loadedCount === 0)) {\n return null;\n }\n\n return (\n <div\n data-slot=\"chat-list-error\"\n data-testid=\"chat-list-error\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-label=\"Error loading chats\"\n className={cn('flex flex-1 items-center justify-center', className)}\n >\n {children || (\n <div className=\"text-text-error-main\">\n {error instanceof Error ? error.message : error || 'An error occurred'}\n </div>\n )}\n </div>\n );\n}\n\nexport interface ChatListLoadMoreProps {\n children?: ReactNode;\n}\n\nexport function ChatListLoadMore({ children }: ChatListLoadMoreProps) {\n const { loadMoreContentRef, bumpLoadMore } = useChatListContext();\n\n loadMoreContentRef.current = children ?? null;\n\n useLayoutEffect(() => {\n bumpLoadMore();\n\n return () => {\n loadMoreContentRef.current = null;\n bumpLoadMore();\n };\n }, [bumpLoadMore, loadMoreContentRef]);\n\n return null;\n}\n","import { useVirtualizer } from '@tanstack/react-virtual';\nimport { memo, useCallback, useEffect, type ReactNode } from 'react';\n\nimport { ScrollArea } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport { useChatListContext } from './chat-list';\n\nconst LOAD_MORE_KEY = 'chat-list-load-more';\n\nexport interface ChatListItemsProps {\n children: (index: number) => ReactNode;\n className?: string;\n listClassName?: string;\n estimateSize?: number;\n overscan?: number;\n gap?: number;\n}\n\nexport const ChatListItems = memo(function ChatListItems({\n children,\n className,\n listClassName,\n estimateSize = 54,\n overscan = 6,\n gap = 4,\n}: ChatListItemsProps) {\n const {\n loadedCount,\n hasMore,\n isLoading,\n isLoadingMore,\n onLoadMore,\n getItemKey,\n scrollElementRef,\n setScrollElement,\n loadMoreContentRef,\n loadMoreVersion,\n setSkeletonContainer,\n } = useChatListContext();\n\n // Re-read registered sentinel content when ChatListLoadMore mounts/unmounts.\n const loadMoreContent = loadMoreVersion >= 0 ? loadMoreContentRef.current : null;\n\n const showSkeleton = isLoading && loadedCount === 0;\n const count = hasMore ? loadedCount + 1 : loadedCount;\n\n const getItemKeyStable = useCallback(\n (index: number) => {\n if (index >= loadedCount) {\n return LOAD_MORE_KEY;\n }\n\n return getItemKey(index);\n },\n [getItemKey, loadedCount],\n );\n\n const virtualizer = useVirtualizer({\n count: showSkeleton ? 0 : count,\n getScrollElement: () => scrollElementRef.current,\n estimateSize: () => estimateSize,\n overscan,\n gap,\n getItemKey: getItemKeyStable,\n });\n\n const virtualItems = virtualizer.getVirtualItems();\n\n useEffect(() => {\n if (showSkeleton) {\n return;\n }\n\n const [lastItem] = [...virtualItems].reverse();\n\n if (!lastItem) {\n return;\n }\n\n if (lastItem.index >= loadedCount - 1 && hasMore && !isLoadingMore) {\n onLoadMore?.();\n }\n }, [virtualItems, loadedCount, hasMore, isLoadingMore, onLoadMore, showSkeleton]);\n\n // The skeleton sits outside the ScrollArea: Radix wraps the viewport's content in a\n // `display: table` box, where the skeleton could neither fill the list height nor clip to it.\n if (showSkeleton) {\n return (\n <div\n ref={setSkeletonContainer}\n data-slot=\"chat-list-items\"\n data-testid=\"chat-list-items\"\n className={cn('flex min-h-0 flex-1 flex-col overflow-hidden', className)}\n />\n );\n }\n\n return (\n <ScrollArea\n ref={setScrollElement}\n data-slot=\"chat-list-items\"\n data-testid=\"chat-list-items\"\n className={cn('min-h-0 flex-1', 'overflow-auto', className)}\n >\n <ul\n role=\"list\"\n aria-label=\"Chats\"\n className={cn(\n 'table relative w-full transform-gpu table-fixed',\n 'space-y-[4px]',\n listClassName,\n )}\n style={{\n height: `${virtualizer.getTotalSize()}px`,\n }}\n >\n {virtualItems.map((virtualItem) => {\n const isLoaderRow = virtualItem.index >= loadedCount;\n\n return (\n <li\n key={virtualItem.key}\n data-index={virtualItem.index}\n ref={virtualizer.measureElement}\n role={isLoaderRow ? 'status' : 'listitem'}\n aria-live={isLoaderRow ? 'polite' : undefined}\n aria-busy={isLoaderRow ? isLoadingMore : undefined}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {isLoaderRow ? loadMoreContent : children(virtualItem.index)}\n </li>\n );\n })}\n </ul>\n </ScrollArea>\n );\n});\n","import { Slot } from '@radix-ui/react-slot';\nimport { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatListItemProps extends ComponentPropsWithoutRef<'div'> {\n children?: ReactNode;\n asChild?: boolean;\n isSelected?: boolean;\n}\n\nexport const ChatListItem = forwardRef<HTMLDivElement, ChatListItemProps>(function ChatListItem(\n { children, className, asChild = false, isSelected = false, ...rest },\n ref,\n) {\n const Component = asChild ? Slot : 'div';\n\n return (\n <Component\n ref={ref}\n data-slot=\"chat-list-item\"\n data-testid=\"chat-list-item\"\n data-selected={isSelected}\n aria-selected={isSelected || undefined}\n className={cn('cursor-pointer outline-none', className)}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n\nChatListItem.displayName = 'ChatListItem';\n","import { createContext, useCallback, useContext, useMemo, useRef, type ReactNode } from 'react';\n\ninterface ChatPromptBoxContextValue {\n reportInputHeight: (height: number) => void;\n resetCompact: () => void;\n registerFocusInput: (focus: () => void) => void;\n unregisterFocusInput: () => void;\n focusInput: () => void;\n}\n\nconst ChatPromptBoxContext = createContext<ChatPromptBoxContextValue | null>(null);\n\nexport function useChatPromptBoxContext() {\n const context = useContext(ChatPromptBoxContext);\n\n if (!context) {\n throw new Error('\"useChatPromptBoxContext\" must be used within a ChatPromptBox');\n }\n\n return context;\n}\n\ninterface ChatPromptBoxContextProviderProps {\n children: ReactNode;\n reportInputHeight: (height: number) => void;\n resetCompact: () => void;\n}\n\nexport function ChatPromptBoxContextProvider({\n children,\n reportInputHeight,\n resetCompact,\n}: ChatPromptBoxContextProviderProps) {\n const focusInputRef = useRef<(() => void) | null>(null);\n\n const registerFocusInput = useCallback((focus: () => void) => {\n focusInputRef.current = focus;\n }, []);\n\n const unregisterFocusInput = useCallback(() => {\n focusInputRef.current = null;\n }, []);\n\n const focusInput = useCallback(() => {\n focusInputRef.current?.();\n }, []);\n\n const contextValue = useMemo(\n () => ({\n reportInputHeight,\n resetCompact,\n registerFocusInput,\n unregisterFocusInput,\n focusInput,\n }),\n [reportInputHeight, resetCompact, registerFocusInput, unregisterFocusInput, focusInput],\n );\n\n return (\n <ChatPromptBoxContext.Provider value={contextValue}>{children}</ChatPromptBoxContext.Provider>\n );\n}\n","import { useEffect } from 'react';\n\nimport { useChatInputEditor } from '../chat-input/plugins/hooks';\n\nimport { useChatPromptBoxContext } from './chat-prompt-box-context';\n\nexport function ChatPromptBoxFocusPlugin() {\n const editor = useChatInputEditor();\n const { registerFocusInput, unregisterFocusInput } = useChatPromptBoxContext();\n\n useEffect(() => {\n registerFocusInput(() => {\n editor.focus();\n });\n\n return () => {\n unregisterFocusInput();\n };\n }, [editor, registerFocusInput, unregisterFocusInput]);\n\n return null;\n}\n","import type { MouseEvent, ReactNode } from 'react';\nimport { forwardRef, useCallback, useLayoutEffect, useState } from 'react';\n\nimport { cn, useElementMeasure } from '@swisper.ai/web-core';\n\nimport { ChatInput, ChatInputTextarea, useChatInputContext } from '../chat-input';\nimport type { ChatInputProps, ChatInputTextareaProps } from '../chat-input';\n\nimport { ChatPromptBoxContextProvider, useChatPromptBoxContext } from './chat-prompt-box-context';\nimport { ChatPromptBoxFocusPlugin } from './chat-prompt-box-focus-plugin';\n\nexport type ChatPromptBoxProps = ChatInputProps;\n\nconst COMPACT_INPUT_HEIGHT_THRESHOLD = 40;\n\nconst INTERACTIVE_SELECTOR = 'button, a, input, select, textarea, [role=\"button\"]';\n\nfunction shouldSkipFocus(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) {\n return false;\n }\n\n return Boolean(target.closest(INTERACTIVE_SELECTOR));\n}\n\nexport const ChatPromptBox = forwardRef<HTMLDivElement, ChatPromptBoxProps>(\n function ChatPromptBox(props, ref) {\n const [isCompact, setIsCompact] = useState(true);\n\n const reportInputHeight = useCallback((height: number) => {\n if (height > COMPACT_INPUT_HEIGHT_THRESHOLD) {\n setIsCompact(false);\n }\n }, []);\n\n const resetCompact = useCallback(() => {\n setIsCompact(true);\n }, []);\n\n return (\n <ChatPromptBoxContextProvider\n reportInputHeight={reportInputHeight}\n resetCompact={resetCompact}\n >\n <ChatPromptBoxContainer ref={ref} data-compact={isCompact} {...props} />\n </ChatPromptBoxContextProvider>\n );\n },\n);\n\nChatPromptBox.displayName = 'ChatPromptBox';\n\nconst ChatPromptBoxContainer = forwardRef<HTMLDivElement, ChatPromptBoxProps>(\n function ChatPromptBoxContainer({ className, onMouseDown, children, ...rest }, ref) {\n const { focusInput } = useChatPromptBoxContext();\n\n const handleMouseDown = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (!shouldSkipFocus(event.target)) {\n focusInput();\n }\n\n onMouseDown?.(event);\n },\n [focusInput, onMouseDown],\n );\n\n return (\n <ChatInput\n ref={ref}\n className={cn(\n 'group/chat-prompt-box',\n 'relative overflow-hidden',\n 'cursor-text',\n 'p-px',\n 'rounded-[16px]',\n // border color\n 'bg-transparent',\n 'hover:bg-promptbox-background-border-base',\n 'data-[focused=true]:bg-promptbox-background-border-base',\n className,\n )}\n onMouseDown={handleMouseDown}\n {...rest}\n >\n <div\n className={cn(\n 'rounded-[15px]',\n 'p-[4px]',\n // regular bg\n 'bg-[#171A20]',\n // hover bg\n 'group-hover/chat-prompt-box:bg-[#252931]',\n // focused bg\n 'group-data-[focused=true]/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]',\n // focused & hover bg\n 'group-data-[focused=true]/chat-prompt-box:group-hover/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]',\n )}\n >\n {children}\n </div>\n\n <ChatPromptBoxFocusRadials />\n </ChatInput>\n );\n },\n);\n\nfunction ChatPromptBoxFocusRadials() {\n return (\n <>\n <div\n className={cn(\n 'absolute left-1/2 top-[-40px]',\n 'translate-x-[-50%]',\n 'pointer-events-none',\n 'w-[380px] h-[72px]',\n 'opacity-0 group-data-[focused=true]/chat-prompt-box:opacity-50',\n )}\n style={{\n borderRadius: '380px',\n background:\n 'gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.00) 100%)',\n }}\n />\n\n <div\n className={cn(\n 'absolute left-1/2 -bottom-22',\n 'translate-x-[-50%]',\n 'pointer-events-none',\n 'w-[1082px] h-[172px]',\n 'opacity-0 group-data-[focused=true]/chat-prompt-box:opacity-5',\n )}\n style={{\n borderRadius: '1082px',\n background:\n 'radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.80) 0%, #2979FF 28%, rgba(63, 70, 88, 0.00) 100%)',\n }}\n />\n </>\n );\n}\n\nexport interface ChatPromptBoxToolbarProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatPromptBoxToolbar({ children, className }: ChatPromptBoxToolbarProps) {\n return (\n <div data-testid=\"chat-prompt-box-toolbar\" className={cn(className)}>\n {children}\n </div>\n );\n}\n\nexport interface ChatPromptBoxContentProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatPromptBoxContent({ children, className }: ChatPromptBoxContentProps) {\n return (\n <div\n data-testid=\"chat-prompt-box-content\"\n className={cn(\n 'relative',\n 'px-[8px] py-[8px]',\n 'flex flex-row gap-[8px]',\n 'group-data-[compact=false]/chat-prompt-box:pb-[calc(8px+4px+40px)]',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport type ChatPromptBoxInputProps = ChatInputTextareaProps;\n\nexport const ChatPromptBoxInput = forwardRef<HTMLDivElement, ChatPromptBoxInputProps>(\n function ChatPromptBoxInput({ className, placeholderClassName, ...rest }, ref) {\n const { reportInputHeight, resetCompact } = useChatPromptBoxContext();\n const { hasValue } = useChatInputContext();\n const { ref: measureRef, height } = useElementMeasure<HTMLDivElement>();\n\n useLayoutEffect(() => {\n if (typeof height === 'number') {\n reportInputHeight(height);\n }\n }, [height, reportInputHeight]);\n\n useLayoutEffect(() => {\n return () => {\n resetCompact();\n };\n }, [resetCompact]);\n\n useLayoutEffect(() => {\n if (!hasValue) {\n resetCompact();\n }\n }, [hasValue, resetCompact]);\n\n const setRef = useCallback(\n (element: HTMLDivElement | null) => {\n measureRef(element);\n\n if (typeof ref === 'function') {\n ref(element);\n } else if (ref) {\n ref.current = element;\n }\n },\n [measureRef, ref],\n );\n\n return (\n <div\n data-testid=\"chat-prompt-box-input\"\n className={cn(\n 'min-h-[40px]',\n 'inline-flex justify-center items-center',\n 'group-data-[compact=false]/chat-prompt-box:items-start',\n 'group-data-[compact=false]/chat-prompt-box:min-h-[48px]',\n 'order-2 grow min-w-0 flex-1',\n '[&>div]:flex-1 [&>div]:min-w-0',\n className,\n )}\n >\n <ChatInputTextarea\n ref={setRef}\n className=\"max-h-[72px]!\"\n placeholderClassName={cn('leading-[24px]!', placeholderClassName)}\n {...rest}\n >\n <ChatPromptBoxFocusPlugin />\n </ChatInputTextarea>\n </div>\n );\n },\n);\n\nChatPromptBoxInput.displayName = 'ChatPromptBoxInput';\n\nexport interface ChatPromptBoxActionsLeftProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatPromptBoxActionsLeft({ children, className }: ChatPromptBoxActionsLeftProps) {\n return (\n <div\n data-testid=\"chat-prompt-box-actions-left\"\n role=\"group\"\n className={cn(\n 'order-1 shrink-0',\n 'group-data-[compact=false]/chat-prompt-box:absolute',\n 'group-data-[compact=false]/chat-prompt-box:bottom-[8px]',\n 'group-data-[compact=false]/chat-prompt-box:left-[8px]',\n 'flex items-center gap-[8px]',\n '[grid-area:left]',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatPromptBoxActionsRightProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatPromptBoxActionsRight({ children, className }: ChatPromptBoxActionsRightProps) {\n return (\n <div\n data-testid=\"chat-prompt-box-actions-right\"\n role=\"group\"\n className={cn(\n 'order-3 shrink-0',\n 'group-data-[compact=false]/chat-prompt-box:order-3',\n 'group-data-[compact=false]/chat-prompt-box:absolute',\n 'group-data-[compact=false]/chat-prompt-box:bottom-[8px]',\n 'group-data-[compact=false]/chat-prompt-box:right-[8px]',\n 'flex items-center justify-end gap-[8px]',\n '[grid-area:right]',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import React from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatMessageProps {\n children: React.ReactNode;\n className?: string;\n isQuestion?: boolean;\n}\n\nexport function ChatMessage({ children, className, isQuestion }: ChatMessageProps) {\n return (\n <div\n data-question={isQuestion}\n className={cn(\n 'group/message',\n 'flex flex-col',\n 'data-[question=true]:items-end',\n 'gap-8',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatMessageContentProps {\n children: React.ReactNode;\n}\n\nexport function ChatMessageContent({ children }: ChatMessageContentProps) {\n return (\n <div\n data-bubble={true}\n className={cn(\n 'w-fit',\n 'min-w-message-mobile-min md:min-w-auto',\n 'group-data-[question=true]/message:data-[bubble=true]:p-16',\n 'group-data-[question=true]/message:data-[bubble=true]:rounded-[20px]',\n 'group-data-[question=true]/message:data-[bubble=true]:bg-[#22283499]',\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatMessageActionsProps {\n children: React.ReactNode;\n className?: string;\n}\n\nexport function ChatMessageActions({ children, className }: ChatMessageActionsProps) {\n return (\n <div\n className={cn(\n 'transition-opacity duration-300',\n 'md:opacity-0 group-hover/message:opacity-100',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import { nanoid } from 'nanoid';\n\nimport { type ChatId } from '@/types';\n\nexport function getNewChatId(): ChatId {\n return `__${nanoid()}__`;\n}\n","import {\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport type { ChatId } from '@/types';\n\nimport { getNewChatId } from './utils';\n\nexport interface ChatContextValue {\n chatId: ChatId;\n newChatId: ChatId;\n loadedChatIdsRef: RefObject<Set<ChatId>>;\n isNewChat: boolean;\n goToNewChat: () => ChatId;\n promptPlaceholder: string | undefined;\n setPromptPlaceholder: (placeholder: string) => void;\n clearPromptPlaceholder: () => void;\n}\n\nconst ChatContext = createContext<ChatContextValue>(null!);\n\nexport function useChatContext() {\n const context = useContext(ChatContext);\n\n if (!context) {\n throw new Error('\"useChatContext\" must be used within a ChatProvider');\n }\n\n return context;\n}\n\ninterface ChatProviderProps {\n children: ReactNode;\n chatId: ChatId | undefined;\n}\n\nexport function ChatProvider({ children, chatId: chatIdProp }: ChatProviderProps) {\n const [newChatId, setNewChatId] = useState<ChatId>(getNewChatId());\n const [promptPlaceholder, setPromptPlaceholderState] = useState<string | undefined>(undefined);\n const loadedChatIdsRef = useRef<Set<ChatId>>(new Set());\n const chatId: ChatId = chatIdProp || newChatId;\n const isNewChat: boolean = chatId === newChatId;\n\n const goToNewChat = useCallback(() => {\n const nextChatId = getNewChatId();\n setNewChatId(nextChatId);\n return nextChatId;\n }, [setNewChatId]);\n\n const setPromptPlaceholder = useCallback((placeholder: string) => {\n setPromptPlaceholderState(placeholder);\n }, []);\n\n const clearPromptPlaceholder = useCallback(() => {\n setPromptPlaceholderState(undefined);\n }, []);\n\n useEffect(\n function resetStateOnChatChange() {\n clearPromptPlaceholder();\n },\n [chatId, newChatId, clearPromptPlaceholder],\n );\n\n const contextValue = useMemo(\n () => ({\n newChatId,\n chatId,\n loadedChatIdsRef,\n isNewChat,\n goToNewChat,\n promptPlaceholder,\n setPromptPlaceholder,\n clearPromptPlaceholder,\n }),\n [\n chatId,\n loadedChatIdsRef,\n newChatId,\n isNewChat,\n goToNewChat,\n promptPlaceholder,\n setPromptPlaceholder,\n clearPromptPlaceholder,\n ],\n );\n\n return <ChatContext.Provider value={contextValue}>{children}</ChatContext.Provider>;\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n type ReactNode,\n useState,\n} from 'react';\n\nimport type { ChatId } from '@/types';\n\nconst LAST_ITEM_SCROLL_MAX_COUNT = 3;\nconst USER_SCROLL_INTENT_IDLE_MS = 250;\n\nexport interface ChatConversationContextValue {\n viewportRef: (node: HTMLDivElement | null) => void;\n bottomTriggerRef: (node: HTMLLIElement | null) => void;\n lastItemRef: (node: HTMLElement | null) => void;\n isAtBottom: boolean;\n setMessageCount: (count: number) => void;\n scrollBottom: () => void;\n scrollToLatest: () => void;\n}\n\nconst ChatConversationContext = createContext<ChatConversationContextValue | null>(null);\n\nexport function useChatConversationContext() {\n const context = useContext(ChatConversationContext);\n\n if (!context) {\n throw new Error('\"useChatConversationContext\" must be used within a ChatConversationProvider');\n }\n\n return context;\n}\n\ninterface ChatConversationProviderProps {\n children: ReactNode;\n chatId: ChatId;\n debug?: boolean;\n}\n\nexport function ChatConversationProvider({\n children,\n chatId: _chatId,\n debug = false,\n}: ChatConversationProviderProps) {\n const [isAtBottom, setIsAtBottom] = useState(true);\n const [debugInfo, setDebugInfo] = useState({\n isAtBottom: true,\n isSmoothScroll: false,\n hasUserEscaped: false,\n isProgrammaticScroll: false,\n userScrollIntent: false,\n scrollStrategy: 'lastItem' as 'end' | 'lastItem',\n });\n\n const viewportNodeRef = useRef<HTMLDivElement | null>(null);\n const bottomTriggerNodeRef = useRef<HTMLLIElement | null>(null);\n const lastItemNodeRef = useRef<HTMLElement | null>(null);\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n const viewportResizeObserverRef = useRef<ResizeObserver | null>(null);\n const bottomTriggerObserverRef = useRef<IntersectionObserver | null>(null);\n\n const messageCountRef = useRef(0);\n const isAtBottomRef = useRef(true);\n const isSmoothScrollRef = useRef<boolean>(false);\n const hasUserEscapedRef = useRef<boolean>(false);\n const isProgrammaticScrollRef = useRef<boolean>(false);\n const userScrollIntentRef = useRef<boolean>(false);\n const userScrollIntentTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const lastScrollTopRef = useRef<number | null>(null);\n const scrollStrategyRef = useRef<'end' | 'lastItem'>('lastItem');\n const lastViewportScrollHeightRef = useRef(0);\n const scrollRef = useRef<() => void>(() => {});\n const attachLastItemResizeObserverRef = useRef<(node: HTMLElement) => void>(() => {});\n const detachLastItemResizeObserverRef = useRef<() => void>(() => {});\n const syncDebugInfoRef = useRef<() => void>(() => {});\n\n const syncDebugInfo = useCallback(() => {\n if (!debug) {\n return;\n }\n\n setDebugInfo({\n isAtBottom: isAtBottomRef.current,\n isSmoothScroll: isSmoothScrollRef.current,\n hasUserEscaped: hasUserEscapedRef.current,\n isProgrammaticScroll: isProgrammaticScrollRef.current,\n userScrollIntent: userScrollIntentRef.current,\n scrollStrategy: scrollStrategyRef.current,\n });\n }, [debug]);\n\n syncDebugInfoRef.current = syncDebugInfo;\n\n const detachLastItemResizeObserver = useCallback(() => {\n resizeObserverRef.current?.disconnect();\n resizeObserverRef.current = null;\n }, []);\n\n detachLastItemResizeObserverRef.current = detachLastItemResizeObserver;\n\n const detachBottomTriggerObserver = useCallback(() => {\n bottomTriggerObserverRef.current?.disconnect();\n bottomTriggerObserverRef.current = null;\n }, []);\n\n const detachViewportResizeObserver = useCallback(() => {\n viewportResizeObserverRef.current?.disconnect();\n viewportResizeObserverRef.current = null;\n }, []);\n\n const syncAtBottomFromViewportRef = useRef<() => void>(() => {});\n\n const clearProgrammaticScroll = useCallback(() => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n isProgrammaticScrollRef.current = false;\n syncAtBottomFromViewportRef.current();\n syncDebugInfoRef.current();\n });\n });\n }, []);\n\n const clearUserScrollIntent = useCallback(() => {\n if (userScrollIntentTimeoutRef.current) {\n clearTimeout(userScrollIntentTimeoutRef.current);\n userScrollIntentTimeoutRef.current = null;\n }\n\n if (!userScrollIntentRef.current) {\n return;\n }\n\n userScrollIntentRef.current = false;\n syncDebugInfoRef.current();\n }, []);\n\n const markUserScrollIntent = useCallback(() => {\n userScrollIntentRef.current = true;\n if (userScrollIntentTimeoutRef.current) {\n clearTimeout(userScrollIntentTimeoutRef.current);\n }\n\n userScrollIntentTimeoutRef.current = setTimeout(() => {\n userScrollIntentTimeoutRef.current = null;\n userScrollIntentRef.current = false;\n syncDebugInfoRef.current();\n }, USER_SCROLL_INTENT_IDLE_MS);\n\n syncDebugInfoRef.current();\n }, []);\n\n const applyLastItemScrollStrategy = useCallback(() => {\n scrollStrategyRef.current = 'lastItem';\n detachLastItemResizeObserverRef.current();\n syncDebugInfoRef.current();\n }, []);\n\n const setHasUserEscaped = useCallback((hasUserEscaped: boolean) => {\n if (hasUserEscapedRef.current === hasUserEscaped) {\n return;\n }\n\n hasUserEscapedRef.current = hasUserEscaped;\n\n if (hasUserEscaped) {\n syncAtBottomFromViewportRef.current();\n }\n\n syncDebugInfoRef.current();\n }, []);\n\n const scroll = useCallback(() => {\n if (hasUserEscapedRef.current) {\n return;\n }\n\n isProgrammaticScrollRef.current = true;\n syncDebugInfoRef.current();\n\n const behavior = isSmoothScrollRef.current ? 'smooth' : 'instant';\n isSmoothScrollRef.current = true;\n\n requestAnimationFrame(() => {\n if (hasUserEscapedRef.current) {\n clearProgrammaticScroll();\n return;\n }\n\n if (scrollStrategyRef.current === 'lastItem') {\n lastItemNodeRef.current?.scrollIntoView({ behavior, block: 'start', inline: 'start' });\n } else {\n viewportNodeRef.current?.scrollTo({\n top: viewportNodeRef.current.scrollHeight,\n behavior,\n });\n }\n\n clearProgrammaticScroll();\n syncDebugInfoRef.current();\n });\n }, [clearProgrammaticScroll]);\n\n scrollRef.current = scroll;\n\n const stickScrollToEnd = useCallback(() => {\n const node = viewportNodeRef.current;\n\n if (!node) {\n return;\n }\n\n const scrollHeight = node.scrollHeight;\n const distanceFromBottom = scrollHeight - node.clientHeight - node.scrollTop;\n\n if (distanceFromBottom <= 1 && scrollHeight === lastViewportScrollHeightRef.current) {\n return;\n }\n\n lastViewportScrollHeightRef.current = scrollHeight;\n isProgrammaticScrollRef.current = true;\n syncDebugInfoRef.current();\n\n requestAnimationFrame(() => {\n node.scrollTo({\n top: scrollHeight,\n behavior: 'instant',\n });\n\n lastViewportScrollHeightRef.current = node.scrollHeight;\n clearProgrammaticScroll();\n syncDebugInfoRef.current();\n });\n }, [clearProgrammaticScroll]);\n\n const syncAtBottomFromViewport = useCallback(() => {\n const node = viewportNodeRef.current;\n\n if (!node) {\n return;\n }\n\n const atBottom = node.scrollHeight - node.clientHeight - node.scrollTop <= 1;\n\n if (!atBottom && !hasUserEscapedRef.current) {\n return;\n }\n\n isAtBottomRef.current = atBottom;\n setIsAtBottom(atBottom);\n\n if (scrollStrategyRef.current === 'end' && atBottom) {\n stickScrollToEnd();\n }\n\n syncDebugInfoRef.current();\n }, [stickScrollToEnd]);\n\n syncAtBottomFromViewportRef.current = syncAtBottomFromViewport;\n\n const attachViewportResizeObserver = useCallback(() => {\n detachViewportResizeObserver();\n\n const node = viewportNodeRef.current;\n\n if (!node) {\n return;\n }\n\n const observer = new ResizeObserver(() => {\n syncAtBottomFromViewportRef.current();\n });\n\n observer.observe(node);\n viewportResizeObserverRef.current = observer;\n }, [detachViewportResizeObserver]);\n\n const attachLastItemResizeObserver = useCallback(\n (node: HTMLElement) => {\n detachLastItemResizeObserver();\n\n if (scrollStrategyRef.current !== 'end') {\n return;\n }\n\n const observer = new ResizeObserver(() => {\n // check the scroll strategy allways in callback to avoid race condition\n if (scrollStrategyRef.current === 'end') {\n stickScrollToEnd();\n }\n });\n\n observer.observe(node);\n resizeObserverRef.current = observer;\n },\n [detachLastItemResizeObserver, stickScrollToEnd],\n );\n\n attachLastItemResizeObserverRef.current = attachLastItemResizeObserver;\n\n const applyEndScrollStrategy = useCallback(() => {\n if (!userScrollIntentRef.current || scrollStrategyRef.current === 'end') {\n return;\n }\n\n scrollStrategyRef.current = 'end';\n clearUserScrollIntent();\n\n const lastItem = lastItemNodeRef.current;\n\n if (lastItem) {\n attachLastItemResizeObserverRef.current(lastItem);\n }\n\n syncDebugInfoRef.current();\n }, [clearUserScrollIntent]);\n\n const handleBottomTriggerVisibility = useCallback(\n (isVisible: boolean) => {\n if (!isVisible && !hasUserEscapedRef.current) {\n syncDebugInfoRef.current();\n return;\n }\n\n isAtBottomRef.current = isVisible;\n setIsAtBottom(isVisible);\n\n if (isProgrammaticScrollRef.current) {\n syncDebugInfoRef.current();\n return;\n }\n\n if (isVisible) {\n setHasUserEscaped(false);\n applyEndScrollStrategy();\n }\n\n syncDebugInfoRef.current();\n },\n [applyEndScrollStrategy, setHasUserEscaped],\n );\n\n const handleScroll = useCallback(\n (event: Event) => {\n if (event.target !== viewportNodeRef.current) {\n return;\n }\n\n const node = event.target as HTMLDivElement;\n const lastScrollTop = lastScrollTopRef.current ?? node.scrollTop;\n const currentScrollTop = node.scrollTop;\n\n lastScrollTopRef.current = currentScrollTop;\n\n if (isProgrammaticScrollRef.current || !userScrollIntentRef.current) {\n return;\n }\n\n const isScrollingUp = currentScrollTop < lastScrollTop;\n const atBottom = node.scrollHeight - node.clientHeight - currentScrollTop <= 1;\n\n if (atBottom) {\n if (scrollStrategyRef.current !== 'end') {\n handleBottomTriggerVisibility(true);\n }\n\n return;\n }\n\n if (isScrollingUp) {\n setHasUserEscaped(true);\n applyLastItemScrollStrategy();\n }\n },\n [applyLastItemScrollStrategy, handleBottomTriggerVisibility, setHasUserEscaped],\n );\n\n const handleWheel = useCallback(\n (event: WheelEvent) => {\n const node = viewportNodeRef.current;\n\n if (event.deltaY < 0 && node && node.scrollHeight > node.clientHeight) {\n setHasUserEscaped(true);\n applyLastItemScrollStrategy();\n }\n\n markUserScrollIntent();\n },\n [applyLastItemScrollStrategy, markUserScrollIntent, setHasUserEscaped],\n );\n\n const handleTouchStart = useCallback(() => {\n markUserScrollIntent();\n }, [markUserScrollIntent]);\n\n const handlePointerDown = useCallback(() => {\n markUserScrollIntent();\n }, [markUserScrollIntent]);\n\n const attachBottomTriggerObserver = useCallback(() => {\n detachBottomTriggerObserver();\n\n const root = viewportNodeRef.current;\n const target = bottomTriggerNodeRef.current;\n\n if (!root || !target) {\n return;\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (!entry) {\n return;\n }\n\n handleBottomTriggerVisibility(entry.isIntersecting);\n },\n { root, threshold: 0 },\n );\n\n observer.observe(target);\n bottomTriggerObserverRef.current = observer;\n }, [detachBottomTriggerObserver, handleBottomTriggerVisibility]);\n\n const viewportRef = useCallback(\n (node: HTMLDivElement | null) => {\n if (viewportNodeRef.current) {\n viewportNodeRef.current.removeEventListener('scroll', handleScroll);\n viewportNodeRef.current.removeEventListener('wheel', handleWheel);\n viewportNodeRef.current.removeEventListener('touchstart', handleTouchStart);\n viewportNodeRef.current.removeEventListener('pointerdown', handlePointerDown);\n detachViewportResizeObserver();\n }\n\n viewportNodeRef.current = node;\n\n if (node) {\n lastScrollTopRef.current = node.scrollTop;\n lastViewportScrollHeightRef.current = node.scrollHeight;\n node.addEventListener('scroll', handleScroll, { passive: true });\n node.addEventListener('wheel', handleWheel, { passive: true });\n node.addEventListener('touchstart', handleTouchStart, { passive: true });\n node.addEventListener('pointerdown', handlePointerDown);\n attachBottomTriggerObserver();\n attachViewportResizeObserver();\n syncAtBottomFromViewport();\n } else {\n clearUserScrollIntent();\n detachBottomTriggerObserver();\n detachViewportResizeObserver();\n }\n },\n [\n attachBottomTriggerObserver,\n attachViewportResizeObserver,\n clearUserScrollIntent,\n detachBottomTriggerObserver,\n detachViewportResizeObserver,\n handlePointerDown,\n handleScroll,\n handleTouchStart,\n handleWheel,\n syncAtBottomFromViewport,\n ],\n );\n\n const bottomTriggerRef = useCallback(\n (node: HTMLLIElement | null) => {\n bottomTriggerNodeRef.current = node;\n\n if (node) {\n attachBottomTriggerObserver();\n } else {\n detachBottomTriggerObserver();\n }\n },\n [attachBottomTriggerObserver, detachBottomTriggerObserver],\n );\n\n const lastItemRef = useCallback(\n (node: HTMLElement | null) => {\n const previousNode = lastItemNodeRef.current;\n\n if (node === null) {\n detachLastItemResizeObserver();\n lastItemNodeRef.current = null;\n syncDebugInfoRef.current();\n return;\n }\n\n if (node === previousNode) {\n if (scrollStrategyRef.current === 'end') {\n attachLastItemResizeObserver(node);\n }\n\n return;\n }\n\n detachLastItemResizeObserver();\n lastItemNodeRef.current = node;\n\n // Intentional: on every new last-item node, reset to lastItem so the viewport\n // shows the head (start) of the new message. Do not change this.\n setHasUserEscaped(false);\n isAtBottomRef.current = true;\n setIsAtBottom(true);\n scrollStrategyRef.current = 'lastItem';\n\n if (node) {\n attachLastItemResizeObserver(node);\n }\n\n syncDebugInfoRef.current();\n },\n [attachLastItemResizeObserver, detachLastItemResizeObserver, setHasUserEscaped],\n );\n\n const setMessageCount = useCallback(\n (count: number) => {\n messageCountRef.current = count;\n\n if (count < LAST_ITEM_SCROLL_MAX_COUNT) {\n scrollStrategyRef.current = 'lastItem';\n detachLastItemResizeObserver();\n } else if (scrollStrategyRef.current === 'end') {\n const lastItem = lastItemNodeRef.current;\n\n if (lastItem) {\n attachLastItemResizeObserver(lastItem);\n }\n }\n\n syncDebugInfoRef.current();\n },\n [attachLastItemResizeObserver, detachLastItemResizeObserver],\n );\n\n const reset = useCallback(() => {\n setHasUserEscaped(false);\n\n if (messageCountRef.current < LAST_ITEM_SCROLL_MAX_COUNT) {\n scrollStrategyRef.current = 'lastItem';\n detachLastItemResizeObserver();\n }\n\n syncDebugInfoRef.current();\n }, [detachLastItemResizeObserver, setHasUserEscaped]);\n\n const scrollBottom = useCallback(() => {\n reset();\n markUserScrollIntent();\n applyEndScrollStrategy();\n isProgrammaticScrollRef.current = true;\n syncDebugInfoRef.current();\n\n const behavior = isSmoothScrollRef.current ? 'smooth' : 'instant';\n isSmoothScrollRef.current = true;\n\n requestAnimationFrame(() => {\n viewportNodeRef.current?.scrollTo({\n top: viewportNodeRef.current.scrollHeight,\n behavior,\n });\n\n clearProgrammaticScroll();\n syncDebugInfoRef.current();\n });\n }, [applyEndScrollStrategy, clearProgrammaticScroll, markUserScrollIntent, reset]);\n\n const scrollToLatest = useCallback(() => {\n scroll();\n }, [scroll]);\n\n const contextValue = useMemo<ChatConversationContextValue>(\n () => ({\n viewportRef,\n bottomTriggerRef,\n lastItemRef,\n isAtBottom,\n setMessageCount,\n scrollBottom,\n scrollToLatest,\n }),\n [\n viewportRef,\n bottomTriggerRef,\n lastItemRef,\n isAtBottom,\n setMessageCount,\n scrollBottom,\n scrollToLatest,\n ],\n );\n\n return (\n <ChatConversationContext.Provider value={contextValue}>\n {debug && (\n <code className=\"absolute top-0 left-0 z-50 w-full bg-red-500/90 p-8 text-white pointer-events-none\">\n {JSON.stringify(debugInfo, null, 2)}\n </code>\n )}\n {children}\n </ChatConversationContext.Provider>\n );\n}\n","import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';\nimport {\n createContext,\n memo,\n useContext,\n useLayoutEffect,\n useMemo,\n type CSSProperties,\n type ReactNode,\n type ComponentProps,\n} from 'react';\n\nimport { useChatConversationContext } from '@/contexts';\nimport { ChevronDownIcon } from '@swisper.ai/icons';\nimport { IconButton, Tooltip } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\ninterface ChatMessagesContextValue {\n messageCount: number;\n}\n\nconst ChatMessagesContext = createContext<ChatMessagesContextValue | null>(null);\n\nconst ChatMessagesListRowContext = createContext(false);\n\nfunction useChatMessagesContext() {\n const context = useContext(ChatMessagesContext);\n\n if (!context) {\n throw new Error('\"ChatMessagesList\" must be used within a ChatMessages');\n }\n\n return context;\n}\n\nexport interface ChatMessagesProps {\n children: ReactNode;\n className?: string;\n messageCount?: number;\n gap?: number;\n}\n\nexport function ChatMessages({\n children,\n className,\n messageCount = 0,\n gap = 16,\n}: ChatMessagesProps) {\n const { setMessageCount } = useChatConversationContext();\n const contextValue = useMemo<ChatMessagesContextValue>(() => ({ messageCount }), [messageCount]);\n\n useLayoutEffect(() => {\n setMessageCount(messageCount);\n }, [messageCount, setMessageCount]);\n\n return (\n <ChatMessagesContext.Provider value={contextValue}>\n <div\n data-testid=\"chat-messages\"\n className={cn('relative flex min-h-0 flex-1 flex-col', className)}\n style={{ '--chat-messages-gap': `${gap}px` } as CSSProperties}\n >\n {children}\n </div>\n </ChatMessagesContext.Provider>\n );\n}\n\nexport interface ChatMessagesListProps {\n children: (index: number) => ReactNode;\n className?: string;\n bottomTriggerClassName?: string;\n}\n\nexport function ChatMessagesList({\n children,\n className,\n bottomTriggerClassName,\n}: ChatMessagesListProps) {\n const { viewportRef, bottomTriggerRef, scrollToLatest } = useChatConversationContext();\n const { messageCount } = useChatMessagesContext();\n\n const rows = useMemo(() => {\n return Array.from({ length: messageCount }, (_, index) => index);\n }, [messageCount]);\n\n const lastIndex = messageCount - 1;\n\n useLayoutEffect(() => {\n scrollToLatest();\n }, [messageCount, scrollToLatest]);\n\n return (\n <ScrollAreaPrimitive.Root\n className={cn(\n 'min-h-0 flex-1',\n 'relative group/scroll-area',\n 'overflow-y-hidden',\n 'transform-gpu',\n )}\n >\n <ScrollAreaPrimitive.Viewport\n ref={viewportRef}\n className={cn('@container-[size]', 'will-change-scroll h-full w-full')}\n style={{ scrollbarGutter: 'stable both-edges' }}\n >\n <ul\n data-testid=\"chat-messages-list\"\n role=\"log\"\n aria-label=\"Message list\"\n aria-atomic=\"false\"\n className={cn('m-0 flex flex-col gap-(--chat-messages-gap) p-0', className)}\n >\n {rows.map((index) => (\n <ChatMessagesListRow key={index} index={index} isLast={index === lastIndex}>\n {children}\n </ChatMessagesListRow>\n ))}\n\n <li\n ref={bottomTriggerRef}\n className={cn('h-px -mt-(--chat-messages-gap)', bottomTriggerClassName)}\n aria-hidden=\"true\"\n />\n </ul>\n </ScrollAreaPrimitive.Viewport>\n\n <ChatMessagesScrollBar orientation=\"vertical\" />\n </ScrollAreaPrimitive.Root>\n );\n}\n\ninterface ChatMessagesListRowProps {\n children: (index: number) => ReactNode;\n index: number;\n isLast: boolean;\n}\n\nconst ChatMessagesListRow = memo(function ChatMessagesListRow({\n children,\n index,\n isLast,\n}: ChatMessagesListRowProps) {\n return (\n <li>\n <ChatMessagesListRowContext.Provider value={isLast}>\n {children(index)}\n </ChatMessagesListRowContext.Provider>\n </li>\n );\n});\n\nexport interface ChatMessageListGroupProps extends ComponentProps<'div'> {}\n\nexport function ChatMessageListGroup({ children, className, ...rest }: ChatMessageListGroupProps) {\n const isLast = useContext(ChatMessagesListRowContext);\n const { lastItemRef } = useChatConversationContext();\n\n return (\n <div\n ref={isLast ? lastItemRef : undefined}\n data-is-last={isLast}\n className={cn(\n 'flex flex-col gap-(--chat-messages-gap)',\n 'data-[is-last=true]:min-h-[calc(100cqh-var(--chat-messages-gap))]',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatMessagesScrollButtonProps {\n className?: string;\n tooltip?: string;\n children?: ReactNode;\n}\n\ninterface ChatMessagesScrollBarProps extends ComponentProps<\n typeof ScrollAreaPrimitive.ScrollAreaScrollbar\n> {\n className?: string;\n orientation?: 'vertical' | 'horizontal';\n}\n\nfunction ChatMessagesScrollBar({\n className,\n orientation = 'vertical',\n ...rest\n}: ChatMessagesScrollBarProps) {\n return (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n data-slot=\"scroll-area-scrollbar\"\n orientation={orientation}\n className={cn(\n 'opacity-0 group-hover/scroll-area:opacity-100',\n 'rounded-[8px]',\n 'bg-scrollbar-track hover:bg-scrollbar-track-hover',\n 'transition-opacity duration-200 ease-in-out',\n 'flextouch-none select-none transition-colors',\n orientation === 'vertical' &&\n 'h-full w-scrollbar border-l border-l-transparent px-4 py-[12px]',\n orientation === 'horizontal' &&\n 'h-scrollbar w-full border-t border-t-transparent px-[12px] py-4',\n className,\n )}\n {...rest}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb\n data-slot=\"scroll-area-thumb\"\n className={cn(\n 'relative flex-1 rounded-full',\n 'bg-scrollbar-thumb hover:bg-scrollbar-thumb-hover',\n orientation === 'vertical' && 'w-scrollbar-thumb!',\n orientation === 'horizontal' && 'h-scrollbar-thumb!',\n )}\n />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n );\n}\n\nexport const ChatMessagesScrollButton = memo(function ChatMessagesScrollButton({\n className,\n tooltip,\n children,\n}: ChatMessagesScrollButtonProps) {\n const { isAtBottom, scrollBottom } = useChatConversationContext();\n\n return (\n <div\n data-testid=\"chat-message-history-scroll-button\"\n data-hidden={isAtBottom}\n aria-hidden={isAtBottom ? true : undefined}\n className={cn(\n 'absolute',\n 'px-[12px]',\n 'bottom-0',\n 'right-0 -translate-x-[12px]',\n 'md:right-auto md:left-1/2 md:-translate-x-1/2',\n '-translate-y-[12px]',\n 'flex items-center justify-center',\n 'transition-opacity duration-200 ease-in-out',\n 'data-[hidden=true]:pointer-events-none',\n 'data-[hidden=true]:opacity-0 data-[hidden=false]:opacity-100',\n className,\n )}\n >\n <Tooltip tooltip={tooltip} side={'top'}>\n <IconButton\n className=\"bg-paper-elevation-2\"\n color=\"primary\"\n size=\"md\"\n onClick={() => scrollBottom()}\n tabIndex={-1}\n aria-label={tooltip}\n >\n {children || <ChevronDownIcon />}\n </IconButton>\n </Tooltip>\n </div>\n );\n});\n","import type { ReactNode } from 'react';\n\nimport { CloseIcon } from '@swisper.ai/icons';\nimport { IconButton, Typography } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatMessageAttachmentCardProps {\n className?: string;\n children?: ReactNode;\n isPreview?: boolean;\n isInteractive?: boolean;\n}\n\nexport function ChatMessageAttachmentCard({\n className,\n children,\n isPreview,\n isInteractive = true,\n}: ChatMessageAttachmentCardProps) {\n return (\n <div\n role=\"group\"\n data-testid=\"chat-message-attachment-card\"\n data-preview={isPreview}\n data-interactive={isInteractive}\n className={cn(\n 'group/chat-message-attachment-card',\n 'relative',\n 'flex flex-row gap-8',\n 'p-8 rounded-promptbox-attachment',\n 'bg-promptbox-attachment-background',\n 'data-[interactive=true]:cursor-pointer',\n 'data-[interactive=true]:hover:bg-[linear-gradient(var(--color-promptbox-attachment-background-hover),var(--color-promptbox-attachment-background-hover)),linear-gradient(var(--color-promptbox-attachment-background),var(--color-promptbox-attachment-background))]',\n 'data-[preview=true]:m-px',\n 'data-[preview=true]:size-[56px]',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatMessageAttachmentCardContentProps {\n className?: string;\n children?: ReactNode;\n}\n\nexport function ChatMessageAttachmentCardContent({\n className,\n children,\n}: ChatMessageAttachmentCardContentProps) {\n return (\n <div\n data-testid=\"chat-message-attachment-card-content\"\n className={cn('flex-1', 'flex items-center', 'overflow-hidden', className)}\n >\n {children}\n </div>\n );\n}\n\ninterface ChatMessageAttachmentCardTitleProps {\n className?: string;\n children?: ReactNode;\n}\n\nexport function ChatMessageAttachmentCardTitle({\n className,\n children,\n}: ChatMessageAttachmentCardTitleProps) {\n return (\n <Typography\n variant=\"body-sm\"\n data-testid=\"chat-message-attachment-card-title\"\n className={cn('truncate', className)}\n >\n {children}\n </Typography>\n );\n}\n\ninterface ChatMessageAttachmentCardPreviewProps {\n className?: string;\n previewSrc: string;\n}\n\nexport function ChatMessageAttachmentCardPreview({\n className,\n previewSrc,\n}: ChatMessageAttachmentCardPreviewProps) {\n return (\n <figure\n data-testid=\"chat-message-attachment-card-preview\"\n className={cn(\n 'absolute top-0 left-0',\n 'inset-0 w-full h-full',\n 'overflow-hidden rounded-promptbox-attachment',\n 'pointer-events-none',\n className,\n )}\n >\n <img src={previewSrc} alt=\"Preview\" className=\"w-full h-full object-cover\" />\n </figure>\n );\n}\n\nexport interface ChatMessageAttachmentCardActionsProps {\n className?: string;\n onDelete?: () => void;\n}\n\nexport function ChatMessageAttachmentCardActions({\n className,\n onDelete,\n}: ChatMessageAttachmentCardActionsProps) {\n return (\n <div\n role=\"group\"\n data-testid=\"chat-message-attachment-card-actions\"\n className={cn(\n 'absolute top-0 right-0',\n 'translate-x-1/2 -translate-y-1/2',\n 'hidden',\n 'group-data-[interactive=true]/chat-message-attachment-card:group-hover/chat-message-attachment-card:flex',\n 'rounded-overlay-tools-wrapper',\n 'bg-overlay-tools-background-base',\n className,\n )}\n >\n <IconButton\n variant=\"tertiary\"\n isSemantic={false}\n onClick={onDelete}\n size=\"xs\"\n className={cn('size-[24px]', 'text-icon-button-tertiary-icon', className)}\n >\n <CloseIcon />\n </IconButton>\n </div>\n );\n}\n","import type { SvgIconProps } from '@mui/material/SvgIcon';\nimport { type FunctionComponent } from 'react';\n\nimport { PdfIcon, PptIcon, CodeIcon, DocIcon, XlsIcon, DraftIcon } from '@swisper.ai/icons';\nimport { cn } from '@swisper.ai/web-core';\n\ntype IconProps = SvgIconProps;\n\nexport type ChatMessageAttachmentCardIconType =\n 'spreadsheet' | 'pdf' | 'presentation' | 'document' | 'code' | 'image' | 'unknown';\n\nconst CHAT_ATTACHMENT_ICON_MAP: Record<\n Exclude<ChatMessageAttachmentCardIconType, 'image'>,\n {\n component: FunctionComponent<IconProps>;\n className?: string;\n }\n> = {\n spreadsheet: {\n component: XlsIcon,\n className: 'bg-data-d',\n },\n pdf: {\n component: PdfIcon,\n className: 'bg-data-a',\n },\n presentation: {\n component: PptIcon,\n className: 'bg-data-e',\n },\n document: {\n component: DocIcon,\n className: 'bg-data-c',\n },\n code: {\n component: CodeIcon,\n className: 'bg-data-f',\n },\n unknown: {\n component: DraftIcon,\n className: 'bg-data-f',\n },\n};\n\nexport interface ChatMessageAttachmentCardIconProps extends IconProps {\n icon: Exclude<ChatMessageAttachmentCardIconType, 'image'>;\n}\n\nexport function ChatMessageAttachmentCardIcon({\n icon,\n className,\n ...rest\n}: ChatMessageAttachmentCardIconProps) {\n const { component: Icon, className: iconClassName } = CHAT_ATTACHMENT_ICON_MAP[icon];\n\n return (\n <span\n data-testid=\"chat-attachment-icon\"\n data-icon={icon}\n className={cn(\n 'inline-flex items-center justify-center',\n 'rounded-[8px]',\n 'p-8',\n 'size-promptbox-attachment-size-icon-container',\n 'text-icon-fill-inverse',\n '[&_svg]:size-[24px]',\n iconClassName,\n className,\n )}\n >\n <Icon {...rest} />\n </span>\n );\n}\n","import mime from 'mime';\n\nimport type { ChatMessageAttachmentCardIconType } from './chat-message-attachment-card-icon';\n\ntype IconType = Exclude<ChatMessageAttachmentCardIconType, 'image'>;\n\nconst MIME_TO_ICON: Record<string, IconType> = {\n 'application/pdf': 'pdf',\n 'application/vnd.ms-excel': 'spreadsheet',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'spreadsheet',\n 'text/csv': 'spreadsheet',\n 'application/vnd.ms-powerpoint': 'presentation',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'presentation',\n 'application/msword': 'document',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'document',\n 'text/plain': 'document',\n 'application/rtf': 'document',\n 'application/vnd.oasis.opendocument.text': 'document',\n};\n\nexport function getAttachmentIcon(file: File): IconType {\n const mimeType = mime.getType(file.name);\n\n if (!mimeType) {\n return 'unknown';\n }\n\n if (mimeType in MIME_TO_ICON) {\n return MIME_TO_ICON[mimeType];\n }\n\n if (\n mimeType.startsWith('text/') ||\n mimeType.includes('javascript') ||\n mimeType.includes('json')\n ) {\n return 'code';\n }\n\n return 'unknown';\n}\n","import type { SwiTagName } from '../../types';\n\nexport function isCustomComponentTag(tag: string): tag is SwiTagName {\n return tag.startsWith('swi-');\n}\n","import { useMemo } from 'react';\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize';\nimport { defaultRehypePlugins, defaultRemarkPlugins, type StreamdownProps } from 'streamdown';\nimport { type PluggableList } from 'unified';\n\nimport type { SwiTagName } from '../../types';\n\nimport type { CustomMarkdownViewerComponents, MarkdownViewerComponents } from './types';\nimport { isCustomComponentTag } from './utils';\n\nexport interface UseMarkdownViewerHookProps {\n customComponents: CustomMarkdownViewerComponents;\n}\n\ntype UseMarkdownViewerHook = Pick<\n StreamdownProps,\n 'components' | 'remarkPlugins' | 'rehypePlugins'\n>;\n\nexport function useMarkdownViewer({\n customComponents,\n}: UseMarkdownViewerHookProps): UseMarkdownViewerHook {\n const swiTags = useMemo<SwiTagName[]>(\n () =>\n Object.keys(customComponents).filter((key): key is SwiTagName => {\n if (!isCustomComponentTag(key)) {\n console.warn(`[MarkdownViewer] Invalid custom component tag: ${key}`);\n return false;\n }\n\n return true;\n }),\n [customComponents],\n );\n\n const remarkPlugins = useMemo<PluggableList>(() => [...Object.values(defaultRemarkPlugins)], []);\n const rehypePlugins = useMemo<PluggableList>(() => {\n return [\n ...Object.values(defaultRehypePlugins),\n [\n rehypeSanitize,\n {\n ...defaultSchema,\n tagNames: [...(defaultSchema?.tagNames || []), ...swiTags],\n protocols: {\n ...defaultSchema?.protocols,\n href: [...(defaultSchema?.protocols?.href ?? []), 'swisper', 'swisper://'],\n },\n },\n ],\n ];\n }, [swiTags]);\n\n return {\n components: customComponents satisfies MarkdownViewerComponents,\n remarkPlugins,\n rehypePlugins,\n };\n}\n","import { Streamdown } from 'streamdown';\n\nimport type { Markdown } from '../../types';\n\nimport { useMarkdownViewer } from './hooks';\nimport type { CustomMarkdownViewerComponents } from './types';\n\nimport 'katex/dist/katex.min.css';\n\nexport interface MarkdownViewerProps {\n markdown: Markdown;\n isStreaming?: boolean;\n hasCaret?: boolean;\n customComponents?: CustomMarkdownViewerComponents;\n}\n\nexport function MarkdownViewer({\n markdown,\n isStreaming = false,\n hasCaret = false,\n customComponents = {},\n}: MarkdownViewerProps) {\n const { components, remarkPlugins, rehypePlugins } = useMarkdownViewer({ customComponents });\n\n return (\n <Streamdown\n caret={hasCaret ? 'block' : undefined}\n isAnimating={isStreaming}\n components={components}\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n linkSafety={{ enabled: false }}\n remend={{\n handlers: [\n {\n name: 'swi-tag-filter',\n handle: swiTagHandler,\n priority: 0,\n },\n ],\n }}\n >\n {markdown}\n </Streamdown>\n );\n}\n\nfunction swiTagHandler(text: string, separator = '|') {\n const incompleteRegex = /<swi-(\\w+)([^>]*)$/gm;\n const [incompleteMatch, tagName] = incompleteRegex.exec(text) ?? [];\n\n if (text.endsWith('<swi-')) {\n return text + '>';\n }\n\n if (incompleteMatch) {\n return text.replace(incompleteMatch, `<swi-${tagName}>`);\n }\n\n if (text.endsWith(separator)) {\n return text.slice(0, -1) + `</swi-${tagName}>`;\n }\n\n const openingTagRegex = /<swi-(\\w+)([^>]*)>/g;\n const openingTags: { name: string; index: number }[] = [];\n let match;\n\n openingTagRegex.lastIndex = 0;\n while ((match = openingTagRegex.exec(text)) !== null) {\n const tagName = match[1];\n const attributes = match[2];\n\n if (attributes.trim().endsWith('/')) {\n continue;\n }\n\n openingTags.push({\n name: tagName,\n index: match.index,\n });\n }\n\n if (openingTags.length > 0) {\n const lastTag = openingTags[openingTags.length - 1];\n const tagName = lastTag.name;\n const closingTag = `</swi-${tagName}>`;\n\n const textAfterOpening = text.substring(lastTag.index);\n if (!textAfterOpening.includes(closingTag)) {\n return text + closingTag;\n }\n }\n\n return text;\n}\n","import { useMemo } from 'react';\n\nimport type { Markdown } from '../../types';\nimport { MarkdownViewer, type CustomMarkdownViewerComponents } from '../markdown-viewer';\n\nexport interface ChatMessageResponseProps {\n message: Markdown;\n isStreaming?: boolean;\n}\n\nexport function ChatMessageResponse({ message, isStreaming }: ChatMessageResponseProps) {\n const customComponents = useMemo<CustomMarkdownViewerComponents>(() => {\n return {};\n }, []);\n\n return (\n <MarkdownViewer\n hasCaret={false}\n markdown={message}\n isStreaming={isStreaming}\n customComponents={customComponents}\n />\n );\n}\n","import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';\nimport { createContext, memo, useContext, useMemo, type ReactNode } from 'react';\nimport { StickToBottom, useStickToBottom, type ScrollToBottom } from 'use-stick-to-bottom';\n\nimport { ChevronDownIcon } from '@swisper.ai/icons';\nimport { IconButton, Tooltip } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\ninterface ChatMessageHistoryContextValue {\n isCurrentScrollBottom: boolean;\n isLoading: boolean;\n isEmpty: boolean;\n hasError: boolean;\n scrollToLastMessage: ScrollToBottom;\n}\n\nconst ChatMessageHistoryContext = createContext<ChatMessageHistoryContextValue>(null!);\n\nexport function useChatMessageHistoryContext() {\n const context = useContext(ChatMessageHistoryContext);\n\n if (!context) {\n throw new Error(\n '\"useChatMessageHistoryContext\" must be used within a ChatMessageHistoryContextProvider',\n );\n }\n\n return context;\n}\n\nexport interface ChatMessageHistoryProps {\n children: ReactNode;\n className?: string;\n totalMessages: number;\n isLoading?: boolean;\n hasError?: boolean;\n}\n\nexport function ChatMessageHistory({\n children,\n className,\n totalMessages,\n isLoading = false,\n hasError = false,\n}: ChatMessageHistoryProps) {\n const isEmpty = totalMessages === 0;\n\n const {\n contentRef,\n scrollRef,\n isAtBottom: isCurrentScrollBottom,\n scrollToBottom: scrollToLastMessage,\n } = useStickToBottom();\n\n const contextValue = useMemo<ChatMessageHistoryContextValue>(\n () => ({\n isCurrentScrollBottom,\n isLoading,\n isEmpty,\n hasError,\n scrollToLastMessage,\n }),\n [isCurrentScrollBottom, isLoading, isEmpty, hasError, scrollToLastMessage],\n );\n\n return (\n <ChatMessageHistoryContext.Provider value={contextValue}>\n <StickToBottom\n data-testid=\"chat-message-history\"\n className={cn('flex', className)}\n initial=\"instant\"\n resize=\"instant\"\n aria-label=\"Chat message history\"\n data-loading={isLoading}\n data-empty={isEmpty}\n data-error={hasError}\n >\n <ScrollAreaPrimitive.Root\n className={cn(\n 'flex-1',\n 'relative group/scroll-area',\n 'overflow-y-hidden',\n 'transform-gpu',\n )}\n >\n <ScrollAreaPrimitive.Viewport\n ref={scrollRef}\n className={cn('will-change-scroll')}\n style={{\n height: '100%',\n width: '100%',\n scrollbarGutter: 'stable both-edges',\n }}\n >\n <div ref={contentRef}>{children}</div>\n </ScrollAreaPrimitive.Viewport>\n\n <ChatMessageHistoryScrollBar orientation=\"vertical\" />\n </ScrollAreaPrimitive.Root>\n </StickToBottom>\n </ChatMessageHistoryContext.Provider>\n );\n}\n\nexport interface ChatMessageHistoryListProps {\n children: ReactNode;\n className?: string;\n}\n\nexport const ChatMessageHistoryList = memo(function ChatMessageHistoryList({\n children,\n className,\n}: ChatMessageHistoryListProps) {\n return (\n <ul\n data-testid=\"chat-message-history-list\"\n role=\"log\"\n aria-label=\"Message list\"\n aria-atomic=\"false\"\n className={cn('flex flex-col p-0 m-0', 'relative gap-16', className)}\n >\n {children}\n </ul>\n );\n});\n\nexport interface ChatMessageHistoryEmptyStateProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatMessageHistoryEmptyState({\n children,\n className,\n}: ChatMessageHistoryEmptyStateProps) {\n const { hasError, isLoading } = useChatMessageHistoryContext();\n\n if (!hasError && !isLoading) {\n return null;\n }\n\n return (\n <div\n data-testid=\"chat-message-history-empty-state\"\n role=\"status\"\n aria-live=\"polite\"\n aria-label=\"No messages\"\n className={cn('flex-1 flex items-center justify-center', className)}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatMessageHistoryErrorStateProps {\n children?: ReactNode;\n error?: Error | string;\n className?: string;\n}\n\nexport function ChatMessageHistoryErrorState({\n children,\n error,\n className,\n}: ChatMessageHistoryErrorStateProps) {\n const { hasError, isLoading } = useChatMessageHistoryContext();\n\n if (hasError && !isLoading) {\n return null;\n }\n\n return (\n <div\n data-testid=\"chat-message-history-error-state\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-label=\"Error loading messages\"\n className={cn('flex-1 flex items-center justify-center', className)}\n >\n {children || (\n <div className=\"text-text-error-main\">\n {error instanceof Error ? error.message : error || 'An error occurred'}\n </div>\n )}\n </div>\n );\n}\n\nexport interface ChatMessageHistoryScrollButtonProps {\n className?: string;\n tooltip?: string;\n}\n\nexport const ChatMessageHistoryScrollButton = memo(function ChatMessageHistoryScrollButton({\n className,\n tooltip,\n}: ChatMessageHistoryScrollButtonProps) {\n const { isCurrentScrollBottom, scrollToLastMessage } = useChatMessageHistoryContext();\n\n return (\n <div\n data-testid=\"chat-message-history-scroll-button\"\n data-hidden={isCurrentScrollBottom}\n aria-hidden={isCurrentScrollBottom ? true : undefined}\n className={cn(\n 'absolute',\n 'px-[12px]',\n 'bottom-0',\n 'right-0 -translate-x-[12px]',\n 'md:right-auto md:left-1/2 md:-translate-x-1/2',\n '-translate-y-[12px]',\n 'flex items-center justify-center',\n 'transition-opacity duration-200 ease-in-out',\n 'data-[hidden=true]:pointer-events-none',\n 'data-[hidden=true]:opacity-0 data-[hidden=false]:opacity-100',\n className,\n )}\n >\n <Tooltip tooltip={tooltip} side={'top'}>\n <IconButton\n className=\"bg-paper-elevation-2\"\n color=\"primary\"\n size=\"md\"\n onClick={() => scrollToLastMessage()}\n tabIndex={-1}\n aria-label={tooltip}\n >\n <ChevronDownIcon />\n </IconButton>\n </Tooltip>\n </div>\n );\n});\n\ninterface ChatMessageHistoryScrollBarProps extends React.ComponentProps<\n typeof ScrollAreaPrimitive.ScrollAreaScrollbar\n> {\n className?: string;\n orientation?: 'vertical' | 'horizontal';\n children?: ReactNode;\n}\n\nexport function ChatMessageHistoryScrollBar({\n className,\n orientation = 'vertical',\n ...rest\n}: ChatMessageHistoryScrollBarProps) {\n return (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n data-slot=\"scroll-area-scrollbar\"\n orientation={orientation}\n className={cn(\n 'opacity-0 group-hover/scroll-area:opacity-100',\n 'rounded-[8px]',\n 'bg-scrollbar-track hover:bg-scrollbar-track-hover',\n 'transition-opacity duration-200 ease-in-out',\n 'flextouch-none select-none transition-colors',\n orientation === 'vertical' &&\n 'h-full w-scrollbar border-l border-l-transparent px-4 py-[12px]',\n orientation === 'horizontal' &&\n 'h-scrollbar w-full border-t border-t-transparent px-[12px] py-4',\n className,\n )}\n {...rest}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb\n data-slot=\"scroll-area-thumb\"\n className={cn(\n 'relative flex-1 rounded-full',\n 'bg-scrollbar-thumb hover:bg-scrollbar-thumb-hover',\n orientation === 'vertical' && 'w-scrollbar-thumb!',\n orientation === 'horizontal' && 'h-scrollbar-thumb!',\n )}\n />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n );\n}\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { IconButton, Tooltip, type IconButtonProps } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatMessageToolbarProps extends ComponentProps<'div'> {\n children: ReactNode;\n className?: string;\n reverse?: boolean;\n}\n\nexport function ChatMessageToolbar({\n children,\n className,\n reverse = false,\n ...rest\n}: ChatMessageToolbarProps) {\n return (\n <div\n data-testid=\"chat-message-toolbar\"\n data-reverse={reverse}\n className={cn(\n 'flex items-center justify-between',\n 'gap-16',\n 'h-24',\n 'data-[reverse=true]:flex-row-reverse',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatMessageToolbarActionsProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatMessageToolbarActions({ children, className }: ChatMessageToolbarActionsProps) {\n return (\n <div\n data-testid=\"chat-message-toolbar-actions\"\n role=\"group\"\n className={cn('flex items-center gap-8', className)}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatMessageToolbarActionButtonProps extends Omit<\n IconButtonProps,\n 'variant' | 'size'\n> {\n children: ReactNode;\n className?: string;\n tooltip?: string;\n}\n\nexport function ChatMessageToolbarActionButton({\n children,\n className,\n tooltip,\n ...rest\n}: ChatMessageToolbarActionButtonProps) {\n const content = (\n <IconButton\n variant=\"tertiary\"\n isSemantic={false}\n size=\"xs\"\n className={cn('text-action-active', className)}\n {...rest}\n >\n {children}\n </IconButton>\n );\n\n if (!tooltip) {\n return content;\n }\n\n return <Tooltip tooltip={tooltip}>{content}</Tooltip>;\n}\n\nexport interface ChatMessageToolbarTimestampProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatMessageToolbarTimestamp({\n className,\n children,\n}: ChatMessageToolbarTimestampProps) {\n return <div className={cn('text-action-active', className)}>{children}</div>;\n}\n","export function getSnoozeUntilDate(minutes: number) {\n return new Date(Date.now() + minutes * 60 * 1000);\n}\n\nconst MINUTES_PER_HOUR = 60;\nconst MINUTES_PER_DAY = 24 * MINUTES_PER_HOUR;\nconst MILLISECONDS_PER_MINUTE = 60 * 1000;\n\nfunction formatDurationPart(value: number, unit: string) {\n return `${value} ${unit}${value === 1 ? '' : 's'}`;\n}\n\nexport function formatSnoozeDate(date: Date, prefix = 'in', now: Date = new Date()) {\n const totalMinutes = Math.max(\n 0,\n Math.ceil((date.getTime() - now.getTime()) / MILLISECONDS_PER_MINUTE),\n );\n const days = Math.floor(totalMinutes / MINUTES_PER_DAY);\n const hours = Math.floor((totalMinutes % MINUTES_PER_DAY) / MINUTES_PER_HOUR);\n const minutes = totalMinutes % MINUTES_PER_HOUR;\n const parts: string[] = [];\n\n if (days > 0) {\n parts.push(formatDurationPart(days, 'day'));\n }\n\n if (hours > 0) {\n parts.push(formatDurationPart(hours, 'hour'));\n }\n\n parts.push(formatDurationPart(minutes, 'minute'));\n\n return [prefix, ...parts].filter(Boolean).join(' ');\n}\n","import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useMemo,\n useState,\n useEffect,\n type ComponentProps,\n type MouseEvent,\n type ReactNode,\n} from 'react';\n\nimport {\n ChevronDownIcon,\n ChevronUpIcon,\n CloseIcon,\n DeleteIcon,\n SignalReadIcon,\n SignalUnreadIcon,\n SnoozeIcon,\n} from '@swisper.ai/icons';\nimport { Button, Chip, IconButton, Typography } from '@swisper.ai/ui';\nimport type { ChipProps, IconButtonProps } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport type { ChatNotificationCardPriority } from './types';\nimport { formatSnoozeDate } from './utils';\n\ninterface ChatNotificationCardContextValue {\n isExpanded: boolean;\n setExpanded: (expanded: boolean) => void;\n toggleExpanded: () => void;\n}\n\nconst ChatNotificationCardContext = createContext<ChatNotificationCardContextValue>(null!);\n\nexport function useChatNotificationCardContext() {\n const context = useContext(ChatNotificationCardContext);\n\n if (!context) {\n throw new Error('\"useChatNotificationCardContext\" must be used within a ChatNotificationCard');\n }\n\n return context;\n}\n\nexport interface ChatNotificationCardProps {\n children?: ReactNode;\n variant?: 'default' | 'floating';\n className?: string;\n defaultExpanded?: boolean;\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onClick?: () => void;\n}\n\nexport function ChatNotificationCard({\n children,\n className,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n onClick,\n}: ChatNotificationCardProps) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const isExpanded = expanded ?? internalExpanded;\n\n const setExpanded = useCallback(\n (nextExpanded: boolean) => {\n if (expanded === undefined) {\n setInternalExpanded(nextExpanded);\n }\n\n onExpandedChange?.(nextExpanded);\n },\n [expanded, onExpandedChange],\n );\n\n const toggleExpanded = useCallback(() => {\n setExpanded(!isExpanded);\n }, [isExpanded, setExpanded]);\n\n const contextValue = useMemo(\n () => ({\n isExpanded,\n setExpanded,\n toggleExpanded,\n }),\n [isExpanded, setExpanded, toggleExpanded],\n );\n\n return (\n <ChatNotificationCardContext.Provider value={contextValue}>\n <div\n role=\"alert\"\n data-testid=\"chat-notification-card\"\n data-expanded={isExpanded}\n aria-expanded={isExpanded}\n className={cn(\n 'group/chat-notification-card',\n 'relative',\n 'p-[12px]',\n 'rounded-[12px] overflow-hidden',\n 'bg-paper-elevation-2',\n 'flex flex-col gap-8',\n 'bg-paper-elevation-2',\n 'data-[variant=floating]:border data-[variant=floating]:border-component-divider',\n className,\n )}\n onClick={onClick}\n >\n {children}\n\n <div className=\"absolute inset-0 pointer-events-none bg-secondary-states-hover opacity-0 group-hover/chat-notification-card:opacity-100 transition-opacity duration-200 ease-in-out\" />\n </div>\n </ChatNotificationCardContext.Provider>\n );\n}\n\nexport interface ChatNotificationCardHeadProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardHead({ children, className }: ChatNotificationCardHeadProps) {\n return (\n <header\n data-testid=\"chat-notification-card-head\"\n className={cn(\n 'grid grid-cols-[minmax(0,1fr)_auto] items-center gap-8',\n 'min-h-[32px]',\n className,\n )}\n >\n {children}\n </header>\n );\n}\n\nexport interface ChatNotificationCardHeaderProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardHeader({\n children,\n className,\n}: ChatNotificationCardHeaderProps) {\n return (\n <div\n data-testid=\"chat-notification-card-header\"\n className={cn(\n 'min-w-0 flex items-center gap-8 overflow-hidden',\n 'text-layout-feedback-info-background-default',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatNotificationCardHeaderIconProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardHeaderIcon({\n children,\n className,\n}: ChatNotificationCardHeaderIconProps) {\n return (\n <div\n data-testid=\"chat-notification-card-header-icon\"\n className={cn(\n 'shrink-0',\n 'inline-flex items-center justify-center',\n 'pointer-events-none',\n '[&_svg]:size-[20px]!',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatNotificationCardHeaderTitleProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardHeaderTitle({\n children,\n className,\n}: ChatNotificationCardHeaderTitleProps) {\n return (\n <div\n data-testid=\"chat-notification-card-header-title\"\n className={cn('min-w-0 flex flex-1 items-center gap-8 overflow-hidden', className)}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatNotificationCardHeaderTitleLabelProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardHeaderTitleLabel({\n children,\n className,\n}: ChatNotificationCardHeaderTitleLabelProps) {\n return (\n <Typography\n variant=\"body-sm\"\n fontWeight=\"semibold\"\n data-testid=\"chat-notification-card-header-title-label\"\n className={cn('min-w-0 truncate', 'text-left text-inherit uppercase', className)}\n asChild\n >\n <span>{children}</span>\n </Typography>\n );\n}\n\nconst CHIP_PRIORITY_MAP: Record<ChatNotificationCardPriority, ChipProps['color']> = {\n low: 'info',\n medium: 'warning',\n high: 'error',\n};\n\nexport interface ChatNotificationCardHeaderStatusProps extends Omit<\n ChipProps,\n 'color' | 'variant' | 'size'\n> {\n children?: ReactNode;\n priority?: ChatNotificationCardPriority;\n className?: string;\n}\n\nexport function ChatNotificationCardHeaderStatus({\n children,\n priority = 'medium',\n className,\n ...rest\n}: ChatNotificationCardHeaderStatusProps) {\n const color = CHIP_PRIORITY_MAP[priority];\n\n if (priority === 'low') {\n return null;\n }\n\n return (\n <Chip\n data-testid=\"chat-notification-card-header-status\"\n className={cn('text-text-secondary', 'shrink-0', className)}\n size=\"2xs\"\n color={color}\n variant=\"outlined\"\n {...rest}\n >\n {children}\n </Chip>\n );\n}\n\nexport interface ChatNotificationCardActionsProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardActions({\n children,\n className,\n}: ChatNotificationCardActionsProps) {\n return (\n <div\n data-testid=\"chat-notification-card-actions\"\n role=\"group\"\n className={cn(\n 'flex flex-row items-center justify-end',\n 'shrink-0 justify-self-end',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatNotificationCardTimestampProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardTimestamp({\n children,\n className,\n}: ChatNotificationCardTimestampProps) {\n return (\n <Typography\n variant=\"caption\"\n data-testid=\"chat-notification-card-timestamp\"\n className={cn('text-text-secondary', 'inline-flex px-8', 'leading-[32px]', className)}\n >\n {children}\n </Typography>\n );\n}\n\nexport interface ChatNotificationCardButtonsProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardButtons({\n children,\n className,\n}: ChatNotificationCardButtonsProps) {\n function handleMouseDown(event: MouseEvent<HTMLDivElement>) {\n event.stopPropagation();\n }\n\n function handleClick(event: MouseEvent<HTMLDivElement>) {\n event.stopPropagation();\n }\n\n return (\n <div\n data-testid=\"chat-notification-card-buttons\"\n role=\"group\"\n className={cn('flex flex-row items-center justify-end', 'gap-8', className)}\n onMouseDown={handleMouseDown}\n onClick={handleClick}\n >\n {children}\n </div>\n );\n}\n\ntype ChatNotificationCardActionButtonProps = Omit<\n ComponentProps<typeof IconButton>,\n 'children' | 'size' | 'variant'\n>;\n\nexport interface ChatNotificationCardReadActionButtonProps extends Omit<\n ChatNotificationCardActionButtonProps,\n 'onClick'\n> {\n children?: ReactNode;\n className?: string;\n isRead?: boolean;\n onRead?: (isRead: boolean) => void;\n}\n\nexport const ChatNotificationCardReadActionButton = forwardRef<\n HTMLButtonElement,\n ChatNotificationCardReadActionButtonProps\n>(function ChatNotificationCardReadActionButton(\n { className, isRead = false, onRead, ...rest },\n ref,\n) {\n function handleClick() {\n onRead?.(!isRead);\n }\n\n return (\n <IconButton\n ref={ref}\n aria-label=\"Mark notifications as read\"\n size=\"sm\"\n variant=\"tertiary\"\n className={className}\n onClick={handleClick}\n {...rest}\n >\n {isRead ? <SignalUnreadIcon /> : <SignalReadIcon />}\n </IconButton>\n );\n});\n\nChatNotificationCardReadActionButton.displayName = 'ChatNotificationCardReadActionButton';\n\nexport interface ChatNotificationCardSnoozeButtonProps extends ChatNotificationCardActionButtonProps {\n children?: ReactNode;\n className?: string;\n snoozeUntilDate?: Date;\n cancelLabel?: ReactNode;\n formatDate?: (date: Date) => ReactNode;\n onCancel?: () => void;\n}\n\nexport const ChatNotificationCardSnoozeButton = forwardRef<\n HTMLButtonElement,\n ChatNotificationCardSnoozeButtonProps\n>(function ChatNotificationCardSnoozeButton(\n {\n className,\n snoozeUntilDate,\n cancelLabel = 'Cancel',\n formatDate = formatSnoozeDate,\n onCancel,\n onClick,\n onMouseEnter,\n onMouseLeave,\n ...rest\n },\n ref,\n) {\n const [isHovered, setIsHovered] = useState(false);\n const isSnoozed = snoozeUntilDate && snoozeUntilDate > new Date();\n\n useEffect(() => {\n if (!isSnoozed) {\n setIsHovered(false);\n }\n }, [isSnoozed]);\n\n function handleMouseEnter(event: MouseEvent<HTMLButtonElement>) {\n setIsHovered(true);\n onMouseEnter?.(event);\n }\n\n function handleMouseLeave(event: MouseEvent<HTMLButtonElement>) {\n setIsHovered(false);\n onMouseLeave?.(event);\n }\n\n function handleCancel() {\n setIsHovered(false);\n onCancel?.();\n }\n\n if (isSnoozed) {\n return (\n <Button\n ref={ref}\n data-hover={isHovered}\n startIcon={isHovered ? <CloseIcon /> : <SnoozeIcon />}\n variant=\"tertiary\"\n size=\"md\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onClick={handleCancel}\n className={cn(\n 'group/snooze-button',\n 'text-chip-outlined-warning-text h-[32px]!',\n className,\n )}\n {...rest}\n >\n <span\n className={cn(\n 'group-data-[hover=true]/snooze-button:opacity-0',\n 'transition-opacity duration-200 ease-in-out',\n )}\n >\n {formatDate(snoozeUntilDate)}\n </span>\n <span\n className={cn(\n 'absolute left-0 w-full text-center pl-[16px]',\n 'transition-opacity duration-200 ease-in-out',\n 'opacity-0',\n 'group-data-[hover=true]/snooze-button:opacity-100',\n )}\n >\n {cancelLabel}\n </span>\n </Button>\n );\n }\n\n return (\n <IconButton\n ref={ref}\n aria-label=\"Snooze notification\"\n size=\"sm\"\n variant=\"tertiary\"\n className={cn('group/snooze-button', className)}\n onClick={onClick}\n {...rest}\n >\n <SnoozeIcon />\n </IconButton>\n );\n});\n\nChatNotificationCardSnoozeButton.displayName = 'ChatNotificationCardSnoozeButton';\n\nexport const ChatNotificationCardDeleteButton = forwardRef<\n HTMLButtonElement,\n ChatNotificationCardActionButtonProps\n>(function ChatNotificationCardDeleteButton({ className, ...rest }, ref) {\n return (\n <IconButton\n ref={ref}\n aria-label=\"Delete notification\"\n size=\"sm\"\n variant=\"tertiary\"\n className={className}\n {...rest}\n >\n <DeleteIcon />\n </IconButton>\n );\n});\n\nChatNotificationCardDeleteButton.displayName = 'ChatNotificationCardDeleteButton';\n\nexport const ChatNotificationCardCloseButton = forwardRef<\n HTMLButtonElement,\n ChatNotificationCardActionButtonProps\n>(function ChatNotificationCardCloseButton({ className, ...rest }, ref) {\n return (\n <IconButton\n ref={ref}\n aria-label=\"Close notification\"\n size=\"sm\"\n variant=\"tertiary\"\n className={className}\n {...rest}\n >\n <CloseIcon />\n </IconButton>\n );\n});\n\nChatNotificationCardCloseButton.displayName = 'ChatNotificationCardCloseButton';\n\nexport interface ChatNotificationCardContentProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardContent({\n children,\n className,\n}: ChatNotificationCardContentProps) {\n return (\n <div\n data-testid=\"chat-notification-card-content\"\n className={cn('flex flex-col items-start text-left gap-4', 'relative pr-[40px]', className)}\n >\n {children}\n\n <ChatNotificationCardExpandButton />\n </div>\n );\n}\n\nexport interface ChatNotificationCardContentTitleProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardContentTitle({\n children,\n className,\n}: ChatNotificationCardContentTitleProps) {\n return (\n <Typography\n variant=\"body-sm\"\n fontWeight=\"semibold\"\n data-testid=\"chat-notification-card-content-title\"\n className={cn('text-text-primary', 'text-left', className)}\n asChild\n >\n <span>{children}</span>\n </Typography>\n );\n}\n\nexport interface ChatNotificationCardContentDescriptionProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardContentDescription({\n children,\n className,\n}: ChatNotificationCardContentDescriptionProps) {\n return (\n <Typography\n variant=\"body-sm\"\n data-testid=\"chat-notification-card-content-description\"\n className={cn(\n 'text-text-primary',\n 'mt-8',\n 'group-data-[expanded=false]/chat-notification-card:line-clamp-2',\n 'w-full [&>div>*]:wrap-break-word',\n className,\n )}\n asChild\n >\n <div>{children}</div>\n </Typography>\n );\n}\n\nexport interface ChatNotificationCardContentActionsProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatNotificationCardContentActions({\n children,\n className,\n}: ChatNotificationCardContentActionsProps) {\n return (\n <div\n data-testid=\"chat-notification-card-content-actions\"\n role=\"group\"\n className={cn(\n 'hidden',\n 'group-data-[expanded=true]/chat-notification-card:flex',\n 'flex-row items-center gap-8',\n 'mt-4',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport interface ChatNotificationCardExpandButtonProps extends Omit<\n IconButtonProps,\n 'children' | 'onClick'\n> {\n className?: string;\n onClick?: (event: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport const ChatNotificationCardExpandButton = forwardRef<\n HTMLButtonElement,\n ChatNotificationCardExpandButtonProps\n>(function ChatNotificationCardExpandButton({ className, onMouseDown, onClick, ...rest }, ref) {\n const { isExpanded, toggleExpanded } = useChatNotificationCardContext();\n\n function handleMouseDown(event: MouseEvent<HTMLButtonElement>) {\n event.stopPropagation();\n onMouseDown?.(event);\n }\n\n function handleClick(event: MouseEvent<HTMLButtonElement>) {\n event.stopPropagation();\n toggleExpanded();\n onClick?.(event);\n }\n\n return (\n <IconButton\n ref={ref}\n data-testid=\"chat-notification-card-expand-button\"\n size=\"sm\"\n variant=\"tertiary\"\n aria-expanded={isExpanded}\n className={cn(\n 'my-4',\n 'h-auto! px-0!',\n 'absolute bottom-0 right-0',\n 'transition-opacity duration-200 ease-in',\n 'opacity-0 group-data-[expanded=true]/chat-notification-card:opacity-100 group-hover/chat-notification-card:opacity-100',\n className,\n )}\n onMouseDown={handleMouseDown}\n onClick={handleClick}\n {...rest}\n >\n {isExpanded ? <ChevronUpIcon /> : <ChevronDownIcon />}\n </IconButton>\n );\n});\n\nChatNotificationCardExpandButton.displayName = 'ChatNotificationCardExpandButton';\n\nexport const ChatNotificationCardIcon = ChatNotificationCardHeaderIcon;\nexport const ChatNotificationCardDescription = ChatNotificationCardContentDescription;\nexport const ChatNotificationCardTimeStamp = ChatNotificationCardTimestamp;\n","import { forwardRef, type ComponentProps } from 'react';\n\nimport { Popover, PopoverContent, PopoverTrigger } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatNotificationPopupProps extends ComponentProps<typeof Popover> {}\n\nexport function ChatNotificationPopup({ children, ...rest }: ChatNotificationPopupProps) {\n return <Popover {...rest}>{children}</Popover>;\n}\n\nexport interface ChatNotificationPopupTriggerProps extends ComponentProps<typeof PopoverTrigger> {}\n\nexport const ChatNotificationPopupTrigger = forwardRef<\n HTMLButtonElement,\n ChatNotificationPopupTriggerProps\n>(function ChatNotificationPopupTrigger(props, ref) {\n return <PopoverTrigger ref={ref} {...props} />;\n});\n\nChatNotificationPopupTrigger.displayName = 'ChatNotificationPopupTrigger';\n\nexport interface ChatNotificationPopupContentProps extends ComponentProps<typeof PopoverContent> {}\n\nexport const ChatNotificationPopupContent = forwardRef<\n HTMLDivElement,\n ChatNotificationPopupContentProps\n>(function ChatNotificationPopupContent({ children, className, ...rest }, ref) {\n return (\n <PopoverContent ref={ref} className={cn('md:w-[467px]', className)} {...rest}>\n {children}\n </PopoverContent>\n );\n});\n\nChatNotificationPopupContent.displayName = 'ChatNotificationPopupContent';\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { Chip, Typography, type TypographyProps } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatRepliesProps {\n children: ReactNode;\n className?: string;\n hasPadding?: boolean;\n}\n\nexport function ChatReplies({ className, children, hasPadding = true }: ChatRepliesProps) {\n return (\n <ul\n data-testid=\"chat-replies\"\n data-padding={hasPadding}\n className={cn(\n 'flex flex-col justify-start items-start gap-8',\n 'data-[padding=true]:py-8 data-[padding=true]:px-16',\n className,\n )}\n >\n {children}\n </ul>\n );\n}\n\nexport interface ChatReplyProps extends ComponentProps<'li'> {\n children: ReactNode;\n isMultiline?: boolean;\n}\n\nexport function ChatReply({ className, children, isMultiline = false, ...rest }: ChatReplyProps) {\n return (\n <li\n data-testid=\"chat-reply\"\n data-multiline={isMultiline}\n className={cn(\n 'group/chat-reply',\n 'flex gap-8 w-full min-h-[24px]',\n 'data-[multiline=false]:flex-row items-center',\n 'data-[multiline=true]:flex-wrap items-start',\n className,\n )}\n {...rest}\n >\n {children}\n </li>\n );\n}\n\nexport interface ChatReplyLabelProps extends ComponentProps<typeof Chip> {\n children: ReactNode;\n}\n\nexport function ChatReplyLabel({ className, children, ...rest }: ChatReplyLabelProps) {\n return (\n <Chip\n variant=\"outlined\"\n // @ts-expect-error TODO(design): Chip has no `sm` size since the size scale changed (md is the old sm); renders without size classes.\n size=\"sm\"\n // @ts-expect-error TODO(design): Chip has no `secondary` color any more; renders without color classes.\n color=\"secondary\"\n data-testid=\"chat-reply-label\"\n className={cn('shrink-0', className)}\n {...rest}\n >\n {children}\n </Chip>\n );\n}\n\nexport interface ChatReplyValueProps extends Omit<TypographyProps, 'variant'> {\n children: ReactNode;\n asChild?: boolean;\n}\n\nexport function ChatReplyValue({\n className,\n children,\n asChild = false,\n ...rest\n}: ChatReplyValueProps) {\n return (\n <Typography\n data-testid=\"chat-reply-value\"\n variant=\"body-sm\"\n className={cn(\n 'leading-[24px]',\n 'flex flex-1 min-w-0 text-text-secondary',\n 'items-start',\n 'group-data-[multiline=false]/chat-reply:flex-1 truncate',\n 'group-data-[multiline=true]/chat-reply:flex-wrap',\n 'group-data-[multiline=true]/chat-reply:gap-4',\n className,\n )}\n asChild\n {...rest}\n >\n <div>{children}</div>\n </Typography>\n );\n}\n","import {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useContext,\n useMemo,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { Typography } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\ninterface ChatSuggestionContextValue {\n index?: number;\n}\n\nconst ChatSuggestionContext = createContext<ChatSuggestionContextValue>(null!);\n\nexport function useChatSuggestionContext() {\n const context = useContext(ChatSuggestionContext);\n\n if (!context) {\n throw new Error('\"useChatSuggestionContext\" must be used within a ChatSuggestion');\n }\n\n return context;\n}\n\nexport interface ChatSuggestionsProps {\n children: ReactNode;\n className?: string;\n onMouseLeave?: () => void;\n}\n\nexport function ChatSuggestions({ children, className, onMouseLeave }: ChatSuggestionsProps) {\n return (\n <div\n role=\"list\"\n data-testid=\"chat-suggestions\"\n className={cn('list-none flex flex-col flex-wrap align-start items-stretch gap-0', className)}\n onMouseLeave={onMouseLeave}\n >\n {Children.map(children, (child, index) => {\n if (!isValidElement(child)) {\n return child;\n }\n\n return cloneElement(child as ReactElement<ChatSuggestionProps>, { index });\n })}\n </div>\n );\n}\n\nexport interface ChatSuggestionProps {\n index?: number;\n children: ReactNode;\n className?: string;\n onHover?: () => void;\n onClick?: () => void;\n}\n\nexport function ChatSuggestion({\n index,\n children,\n className,\n onHover,\n onClick,\n}: ChatSuggestionProps) {\n const contextValue = useMemo(() => ({ index }), [index]);\n\n return (\n <ChatSuggestionContext.Provider value={contextValue}>\n <div\n role=\"listitem\"\n onClick={onClick}\n onMouseEnter={onHover}\n className={cn(\n 'cursor-pointer',\n 'inline-flex flex-row max-w-full',\n 'items-start',\n 'p-4 gap-0 rounded-[12px]',\n 'group/suggestion',\n 'text-typography-text-secondary',\n 'hover:bg-layout-accent-low-background-hover-default',\n 'focus-visible:bg-layout-accent-low-background-hover-default',\n className,\n )}\n >\n {children}\n </div>\n </ChatSuggestionContext.Provider>\n );\n}\n\nexport interface ChatSuggestionLabelIconProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport function ChatSuggestionLabelIcon({ children, className }: ChatSuggestionLabelIconProps) {\n const { index = 0 } = useChatSuggestionContext();\n\n return (\n <span\n aria-hidden=\"true\"\n className={cn(\n 'inline-flex flex-row justify-center items-center shrink-0 size-auto text-inherit',\n className,\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n 'size-[32px]',\n 'inline-flex items-center justify-center',\n 'px-8 py-[7px]',\n '[&_svg]:size-[18px]!',\n )}\n >\n {children || (\n <Typography variant=\"caption-md\" fontWeight=\"normal\" className=\"text-inherit\">\n {index + 1}\n </Typography>\n )}\n </span>\n </span>\n );\n}\n\nexport interface ChatSuggestionLabelProps {\n children: ReactNode;\n className?: string;\n isMultiline?: boolean;\n}\n\nexport function ChatSuggestionLabel({\n children,\n className,\n isMultiline = true,\n}: ChatSuggestionLabelProps) {\n return (\n <Typography\n variant=\"body-small-low\"\n data-multiline={isMultiline}\n className={cn(\n 'gap-0 px-4 my-[7px]',\n 'h-full flex-1 items-center justify-center text-left text-inherit',\n 'data-[multiline=false]:truncate',\n 'data-[multiline=true]:line-clamp-3',\n className,\n )}\n >\n {children}\n </Typography>\n );\n}\n\nexport interface ChatSuggestionActionsProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatSuggestionActions({ children, className }: ChatSuggestionActionsProps) {\n return (\n <div\n role=\"group\"\n className={cn(\n 'shrink-0 flex items-center justify-center gap-8',\n 'self-start',\n 'min-w-[32px] h-[32px]',\n '*:text-secondary-main',\n '[&>svg]:size-[18px]!',\n 'opacity-0',\n 'group-hover/suggestion:opacity-100',\n 'group-focus-visible/suggestion:opacity-100',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import {\n MessageScroller as MessageScrollerPrimitive,\n useMessageScroller,\n useMessageScrollerScrollable,\n} from '@shadcn/react/message-scroller';\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type MutableRefObject,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { ChevronDownIcon } from '@swisper.ai/icons';\nimport { IconButton, Tooltip } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\n/**\n * `@shadcn/react` reads `ref` from props (React 19 style), but React 18 strips `ref` before props reach\n * a component. Calling the primitive directly from a `forwardRef` render puts `ref` back into its props.\n * Not used for Root: it spreads props after its own internal ref, so any `ref` prop (even `null`) replaces it.\n */\nfunction withForwardedRef<TProps>(\n Primitive: (props: TProps) => ReactElement | null,\n displayName: string,\n) {\n const Component = forwardRef<HTMLDivElement, Omit<TProps, 'ref'>>((props, ref) =>\n Primitive({ ...props, ref: ref } as TProps),\n );\n\n Component.displayName = displayName;\n\n return Component;\n}\n\nconst ViewportPrimitive = withForwardedRef(\n MessageScrollerPrimitive.Viewport,\n 'ChatThreadViewportPrimitive',\n);\nconst ContentPrimitive = withForwardedRef(\n MessageScrollerPrimitive.Content,\n 'ChatThreadContentPrimitive',\n);\nconst ItemPrimitive = withForwardedRef(MessageScrollerPrimitive.Item, 'ChatThreadItemPrimitive');\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = value;\n }\n}\n\nconst DEFAULT_SCROLL_MARGIN = 12;\n\n/** CSS variable holding the height the latest group needs to fill the viewport once anchored at its top */\nconst GROUP_MIN_HEIGHT_VAR = '--chat-thread-group-min-height';\n\n// Commands\n\nexport type ChatThreadCommands = ReturnType<typeof useMessageScroller>;\n\nconst NOOP_COMMANDS: ChatThreadCommands = {\n scrollToEnd: () => false,\n scrollToMessage: () => false,\n scrollToStart: () => false,\n};\n\nconst ChatThreadCommandsContext = createContext<ChatThreadCommands | null>(null);\n\n/**\n * Scroll commands of the nearest `ChatThreadProvider`.\n * Safe outside a provider: commands become no-ops returning `false`.\n */\nexport function useChatThread(): ChatThreadCommands {\n return useContext(ChatThreadCommandsContext) ?? NOOP_COMMANDS;\n}\n\nfunction ChatThreadCommandsBridge({ children }: { children?: ReactNode }) {\n const { scrollToEnd, scrollToMessage, scrollToStart } = useMessageScroller();\n\n const commands = useMemo<ChatThreadCommands>(\n () => ({ scrollToEnd, scrollToMessage, scrollToStart }),\n [scrollToEnd, scrollToMessage, scrollToStart],\n );\n\n return (\n <ChatThreadCommandsContext.Provider value={commands}>\n {children}\n </ChatThreadCommandsContext.Provider>\n );\n}\n\n// Session\n\n/**\n * How the thread scrolls as messages arrive.\n * - `anchor`: question and answer chat. A new question settles at the top of the viewport and its answer\n * grows below it, so the reader reads each answer from its start.\n * - `follow`: terminal-style, for agent transcripts, tool runs and logs. New output is appended at the\n * bottom and pushes older content up; the view follows the latest output until the reader scrolls away,\n * and a new group brings it back to the end. A short thread sits at the bottom, next to the input.\n */\nexport type ChatThreadScrollMode = 'anchor' | 'follow';\n\ninterface ChatThreadSession {\n isStreaming: boolean;\n scrollMargin: number;\n scrollMode: ChatThreadScrollMode;\n /**\n * Ids of the groups the session opened with — history. Any other group is a new message and anchors.\n * `null` while the thread is empty.\n */\n knownGroupIds: ReadonlySet<string> | null;\n}\n\nconst ChatThreadSessionContext = createContext<ChatThreadSession | null>(null);\n\nfunction useChatThreadSession(component: string) {\n const session = useContext(ChatThreadSessionContext);\n\n if (!session) {\n throw new Error(`[web-chat-ui] <${component}> must be rendered inside <ChatThreadProvider>`);\n }\n\n return session;\n}\n\ntype ScrollerProviderProps = ComponentProps<typeof MessageScrollerPrimitive.Provider>;\n\nexport type ChatThreadProviderProps = ScrollerProviderProps & {\n /** Identity of the conversation; changing it resets the thread so the new conversation opens at the end */\n conversationId?: string | null;\n /** Ids of the rendered groups, matching each `ChatThreadGroup`'s `groupId` */\n groupIds: readonly string[];\n /** Whether an answer is streaming into the thread */\n isStreaming?: boolean;\n /** How the thread scrolls as messages arrive; see `ChatThreadScrollMode`. Defaults to `anchor` */\n scrollMode?: ChatThreadScrollMode;\n /**\n * Keep following content that grows at the end (late cards, reply chips, images) until the reader scrolls\n * away. In `anchor` mode it defaults to following only while no answer is streaming, so a stream never\n * drags the view down; in `follow` mode it defaults to always following.\n */\n autoScroll?: boolean;\n};\n\ninterface ThreadSessionState {\n id: number;\n conversationId: string | null;\n knownGroupIds: ReadonlySet<string> | null;\n}\n\nfunction createSessionState(\n id: number,\n conversationId: string | null | undefined,\n groupIds: readonly string[],\n): ThreadSessionState {\n return {\n id,\n conversationId: conversationId ?? null,\n knownGroupIds: groupIds.length === 0 ? null : new Set(groupIds),\n };\n}\n\nexport function ChatThreadProvider({\n children,\n conversationId,\n groupIds,\n isStreaming = false,\n scrollMode = 'anchor',\n autoScroll = scrollMode === 'follow' || !isStreaming,\n defaultScrollPosition = 'end',\n scrollPreviousItemPeek = 0,\n scrollMargin = DEFAULT_SCROLL_MARGIN,\n ...rest\n}: ChatThreadProviderProps) {\n const [sessionState, setSessionState] = useState(() =>\n createSessionState(0, conversationId, groupIds),\n );\n\n // A new session per conversation, and whenever the thread empties or fills again: a chat switch renders\n // the old groups under the new id, clears them, then loads the new history — which must open at the end\n if (\n sessionState.conversationId !== (conversationId ?? null) ||\n (sessionState.knownGroupIds === null) !== (groupIds.length === 0)\n ) {\n setSessionState(createSessionState(sessionState.id + 1, conversationId, groupIds));\n }\n\n const { knownGroupIds } = sessionState;\n\n const session = useMemo<ChatThreadSession>(\n () => ({ isStreaming, scrollMargin, scrollMode, knownGroupIds }),\n [isStreaming, scrollMargin, scrollMode, knownGroupIds],\n );\n\n // Keyed on the session so the scroller remounts and applies its opening position again\n return (\n <MessageScrollerPrimitive.Provider\n key={sessionState.id}\n autoScroll={autoScroll}\n scrollPreviousItemPeek={scrollPreviousItemPeek}\n scrollMargin={scrollMargin}\n defaultScrollPosition={defaultScrollPosition}\n {...rest}\n >\n <ChatThreadSessionContext.Provider value={session}>\n {scrollMode === 'follow' && (\n <FollowNewGroups groupIds={groupIds} knownGroupIds={knownGroupIds} />\n )}\n <ChatThreadCommandsBridge>{children}</ChatThreadCommandsBridge>\n </ChatThreadSessionContext.Provider>\n </MessageScrollerPrimitive.Provider>\n );\n}\n\n/**\n * In `follow` mode, a new group (the reader sent a prompt) returns the view to the end and resumes following,\n * even when the reader had scrolled up to read earlier output.\n */\nfunction FollowNewGroups({\n groupIds,\n knownGroupIds,\n}: {\n groupIds: readonly string[];\n knownGroupIds: ReadonlySet<string> | null;\n}) {\n const { scrollToEnd } = useMessageScroller();\n const lastGroupId = groupIds.at(-1);\n\n useLayoutEffect(() => {\n if (lastGroupId === undefined || knownGroupIds === null || knownGroupIds.has(lastGroupId))\n return;\n\n scrollToEnd({ behavior: 'auto' });\n }, [lastGroupId, knownGroupIds, scrollToEnd]);\n\n return null;\n}\n\n// Thread\n\nexport type ChatThreadError = Error | string;\n\nexport interface ChatThreadProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {\n children?: ReactNode;\n contentClassName?: string;\n viewportRef?: Ref<HTMLDivElement>;\n contentRef?: Ref<HTMLDivElement>;\n /** Renders the scroll-to-latest button */\n scrollButton?: boolean;\n scrollButtonClassName?: string;\n scrollButtonTooltip?: string;\n isLoading?: boolean;\n hasError?: boolean;\n error?: ChatThreadError;\n /** Replaces the built-in error message */\n renderError?: (error?: ChatThreadError) => ReactNode;\n}\n\nexport const ChatThread = forwardRef<HTMLDivElement, ChatThreadProps>(function ChatThread(\n {\n children,\n className,\n contentClassName,\n viewportRef,\n contentRef,\n scrollButton = true,\n scrollButtonClassName,\n scrollButtonTooltip,\n isLoading = false,\n hasError = false,\n error,\n renderError,\n ...rest\n },\n ref,\n) {\n const { isStreaming, scrollMargin, scrollMode } = useChatThreadSession('ChatThread');\n const isAnchored = scrollMode === 'anchor';\n\n const viewportElementRef = useRef<HTMLDivElement | null>(null);\n const contentElementRef = useRef<HTMLDivElement | null>(null);\n\n const setViewport = useCallback(\n (element: HTMLDivElement | null) => {\n viewportElementRef.current = element;\n assignRef(viewportRef, element);\n // Root can't take `ref` without losing its internal one; the viewport is always its direct child\n assignRef(ref, (element?.parentElement as HTMLDivElement | null | undefined) ?? null);\n },\n [viewportRef, ref],\n );\n\n const setContent = useCallback(\n (element: HTMLDivElement | null) => {\n contentElementRef.current = element;\n assignRef(contentRef, element);\n },\n [contentRef],\n );\n\n useGroupMinHeight(viewportElementRef, contentElementRef, scrollMargin, isAnchored);\n\n return (\n <MessageScrollerPrimitive.Root\n data-testid=\"chat-thread\"\n data-scroll-mode={scrollMode}\n data-loading={isLoading}\n data-error={hasError}\n className={cn('relative flex flex-col flex-1 min-h-0 overflow-hidden', className)}\n {...rest}\n >\n <ViewportPrimitive\n ref={setViewport}\n aria-label=\"Chat message history\"\n className={cn(\n 'size-full overflow-x-hidden overflow-y-auto outline-none',\n 'will-change-scroll transform-gpu',\n // A continuous stream outruns smooth scrolling, so following jumps instead\n isAnchored && isStreaming && 'scroll-smooth',\n )}\n style={{\n scrollbarGutter: 'stable both-edges',\n scrollbarWidth: 'thin',\n scrollbarColor: 'var(--color-scrollbar-thumb) transparent',\n }}\n >\n <ContentPrimitive\n ref={setContent}\n aria-busy={isStreaming}\n data-testid=\"chat-thread-content\"\n className={cn(\n 'relative flex flex-col gap-16',\n isAnchored\n ? // The primitive always appends its spacer, so the latest group is the second-to-last child\n '[&>[data-chat-thread-group]:nth-last-child(2)]:min-h-(--chat-thread-group-min-height)'\n : // Terminal-style: a short thread sits at the bottom, next to the input\n 'min-h-full justify-end',\n contentClassName,\n )}\n >\n {children}\n </ContentPrimitive>\n </ViewportPrimitive>\n\n {hasError && !isLoading && (\n <ChatThreadErrorState error={error}>{renderError?.(error)}</ChatThreadErrorState>\n )}\n\n {scrollButton && (\n <ChatThreadScrollButton className={scrollButtonClassName} tooltip={scrollButtonTooltip} />\n )}\n </MessageScrollerPrimitive.Root>\n );\n});\n\n/**\n * Keeps the latest group at least as tall as the room below its anchored position, so a new message can\n * settle at the top of the viewport and the answer streams in without the scroll position jumping.\n * Only `anchor` mode needs it.\n */\nfunction useGroupMinHeight(\n viewportRef: MutableRefObject<HTMLDivElement | null>,\n contentRef: MutableRefObject<HTMLDivElement | null>,\n scrollMargin: number,\n isEnabled: boolean,\n) {\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n const content = contentRef.current;\n\n if (!viewport || !content) return;\n\n if (!isEnabled) {\n content.style.removeProperty(GROUP_MIN_HEIGHT_VAR);\n return;\n }\n\n const update = () => {\n const { paddingTop, paddingBottom } = window.getComputedStyle(content);\n const minHeight =\n viewport.clientHeight -\n (Number.parseFloat(paddingTop) || 0) -\n (Number.parseFloat(paddingBottom) || 0) -\n scrollMargin;\n\n content.style.setProperty(GROUP_MIN_HEIGHT_VAR, `${Math.max(0, minHeight)}px`);\n };\n\n update();\n\n if (typeof ResizeObserver === 'undefined') return;\n\n const observer = new ResizeObserver(update);\n observer.observe(viewport);\n observer.observe(content);\n\n return () => observer.disconnect();\n }, [viewportRef, contentRef, scrollMargin, isEnabled]);\n}\n\n// Groups\n\nexport interface ChatThreadGroupProps extends ComponentPropsWithoutRef<'div'> {\n groupId: string;\n}\n\n/**\n * One question with its answer. Groups the session opened with are history; in `anchor` mode any other\n * group is a new message and becomes the scroll anchor, settling at the top of the viewport. In `follow`\n * mode no group anchors.\n */\nexport const ChatThreadGroup = forwardRef<HTMLDivElement, ChatThreadGroupProps>(\n function ChatThreadGroup({ groupId, className, ...rest }, ref) {\n const { knownGroupIds, scrollMode } = useChatThreadSession('ChatThreadGroup');\n const isNew = scrollMode === 'anchor' && knownGroupIds !== null && !knownGroupIds.has(groupId);\n\n return (\n <ItemPrimitive\n ref={ref}\n // Namespaced: `data-message-id` is also how consumers find message bubbles\n messageId={`chat-thread-group-${groupId}`}\n scrollAnchor={isNew}\n data-chat-thread-group=\"\"\n className={cn('flex flex-col gap-16 w-full min-h-px mx-auto', className)}\n {...rest}\n />\n );\n },\n);\n\nexport interface ChatThreadMessageProps extends ComponentPropsWithoutRef<'div'> {\n messageId: string;\n}\n\nexport const ChatThreadQuestion = forwardRef<HTMLDivElement, ChatThreadMessageProps>(\n function ChatThreadQuestion({ messageId, ...rest }, ref) {\n return (\n <div\n ref={ref}\n data-chat-thread-question=\"\"\n data-chat-thread-message-id={messageId}\n {...rest}\n />\n );\n },\n);\n\nexport const ChatThreadAnswer = forwardRef<HTMLDivElement, ChatThreadMessageProps>(\n function ChatThreadAnswer({ messageId, ...rest }, ref) {\n return (\n <div ref={ref} data-chat-thread-answer=\"\" data-chat-thread-message-id={messageId} {...rest} />\n );\n },\n);\n\n// Parts\n\ninterface ChatThreadScrollButtonProps {\n className?: string;\n tooltip?: string;\n}\n\nfunction ChatThreadScrollButton({ className, tooltip }: ChatThreadScrollButtonProps) {\n const { end: hasContentBelow } = useMessageScrollerScrollable();\n\n return (\n <div\n data-testid=\"chat-message-history-scroll-button\"\n data-hidden={!hasContentBelow}\n aria-hidden={hasContentBelow ? undefined : true}\n className={cn(\n 'absolute',\n 'px-[12px]',\n 'bottom-0',\n 'right-0 -translate-x-[12px]',\n 'md:right-auto md:left-1/2 md:-translate-x-1/2',\n '-translate-y-[12px]',\n 'flex items-center justify-center',\n 'transition-opacity duration-200 ease-in-out',\n 'data-[hidden=true]:pointer-events-none',\n 'data-[hidden=true]:opacity-0 data-[hidden=false]:opacity-100',\n className,\n )}\n >\n <MessageScrollerPrimitive.Button\n direction=\"end\"\n // Render function (not element) so Tooltip's trigger gets IconButton's forwarded ref on React 18\n render={({ inert, children: _children, ...props }) => (\n <Tooltip tooltip={tooltip} side=\"top\">\n <IconButton\n {...props}\n // React 18 doesn't know the boolean `inert` prop\n {...{ inert: inert ? '' : undefined }}\n className=\"bg-paper-elevation-2\"\n color=\"primary\"\n size=\"md\"\n tabIndex={-1}\n aria-label={tooltip}\n >\n <ChevronDownIcon />\n </IconButton>\n </Tooltip>\n )}\n />\n </div>\n );\n}\n\nexport interface ChatThreadErrorStateProps {\n children?: ReactNode;\n error?: ChatThreadError;\n className?: string;\n}\n\n/**\n * Covers the thread with an alert when its messages failed to load. Shows `children` when given,\n * otherwise the error's message.\n */\nexport function ChatThreadErrorState({ children, error, className }: ChatThreadErrorStateProps) {\n return (\n <div\n data-testid=\"chat-message-history-error-state\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-label=\"Error loading messages\"\n className={cn('absolute inset-0 flex items-center justify-center', className)}\n >\n {children || (\n <div className=\"text-text-error-main\">\n {error instanceof Error ? error.message : error || 'An error occurred'}\n </div>\n )}\n </div>\n );\n}\n\nexport { useMessageScrollerScrollable as useChatThreadScrollable };\n","import { useState, type ComponentProps, type ReactNode } from 'react';\n\nimport { CloseIcon, OpenInFullIcon, MoreHorizontalIcon } from '@swisper.ai/icons';\nimport {\n IconButton,\n Menu,\n MenuProvider,\n MenuTrigger,\n Typography,\n cn,\n type IconButtonProps,\n type TypographyProps,\n} from '@swisper.ai/ui';\n\n// TODO: move this module to @swisper.ai/web-chat-ui, then switch the consumers to it and delete it here.\n\nexport type CanvasShellProps = ComponentProps<'section'>;\n\n/**\n * Three-row grid: header and footer size to their content, the content row takes the rest.\n * `minmax(0,1fr)` keeps a long list from growing the middle row past the shell's height.\n */\nexport function CanvasShell({ className, ...props }: CanvasShellProps) {\n return (\n <section\n data-slot=\"canvas-shell\"\n className={cn(\n 'grid grid-rows-[auto_minmax(0,1fr)_auto]',\n 'h-full overflow-hidden',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport interface CanvasShellHeaderProps extends ComponentProps<'header'> {\n hasBorder?: boolean;\n}\n\nexport function CanvasShellHeader({\n className,\n hasBorder = true,\n ...props\n}: CanvasShellHeaderProps) {\n return (\n <header\n data-slot=\"canvas-shell-header\"\n data-separator={hasBorder}\n className={cn(\n 'row-start-1',\n 'flex items-center gap-[8px]',\n 'p-[12px] md:p-[16px]',\n 'data-[separator=true]:border-b data-[separator=true]:border-brand-secondary-700',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport type CanvasShellTitleProps = Omit<TypographyProps, 'variant'>;\n\nexport function CanvasShellTitle({ className, ...props }: CanvasShellTitleProps) {\n return (\n <Typography\n data-slot=\"canvas-shell-title\"\n variant=\"label-xl\"\n fontWeight=\"normal\"\n className={cn('flex-1 min-w-0 truncate', className)}\n {...props}\n />\n );\n}\n\nexport type CanvasShellCloseTriggerProps = IconButtonProps;\n\n/**\n * Icon-only close button; the host decides what closing means through `onClick`.\n */\nexport function CanvasShellCloseTrigger({\n className,\n children,\n ...props\n}: CanvasShellCloseTriggerProps) {\n return (\n <IconButton\n data-slot=\"canvas-shell-close-trigger\"\n type=\"button\"\n variant=\"tertiary\"\n size=\"md\"\n aria-label=\"Close panel\"\n className={cn('shrink-0', className)}\n {...props}\n >\n {children || <CloseIcon />}\n </IconButton>\n );\n}\n\nexport interface CanvasShellFullScreenTriggerProps extends Omit<\n IconButtonProps,\n 'aria-label' | 'aria-pressed'\n> {\n /** Whether the canvas currently fills the viewport; drives `aria-pressed` and the label. */\n isFullScreen: boolean;\n /** Accessible names for each state; English by default. */\n labels?: { enter?: string; exit?: string };\n}\n\n/**\n * Toggle between the canvas width and the full viewport; the host owns the state and passes\n * `isFullScreen` and `onClick`. Desktop only: on mobile the canvas already spans the screen.\n */\nexport function CanvasShellFullScreenTrigger({\n className,\n children,\n isFullScreen,\n labels,\n ...props\n}: CanvasShellFullScreenTriggerProps) {\n return (\n <IconButton\n data-slot=\"canvas-shell-full-screen-trigger\"\n type=\"button\"\n variant=\"tertiary\"\n size=\"md\"\n aria-pressed={isFullScreen}\n aria-label={\n isFullScreen ? (labels?.exit ?? 'Exit full screen') : (labels?.enter ?? 'Full screen')\n }\n className={cn('shrink-0 max-md:hidden', className)}\n {...props}\n >\n {children || <OpenInFullIcon />}\n </IconButton>\n );\n}\n\nexport interface CanvasShellOptionsButtonProps extends Omit<IconButtonProps, 'children'> {\n /** Menu contents, typically a `DropdownMenuList` of `DropdownMenuListItem`s. */\n children: ReactNode;\n /** Classes for the dropdown panel. */\n menuClassName?: string;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\n/**\n * \"More options\" button that opens a dropdown of canvas actions passed as children.\n */\nexport function CanvasShellOptionsButton({\n className,\n children,\n menuClassName,\n onOpenChange,\n ...props\n}: CanvasShellOptionsButtonProps) {\n const [isOpen, setIsOpen] = useState(false);\n\n function handleOpenChange(open: boolean) {\n setIsOpen(open);\n onOpenChange?.(open);\n }\n\n return (\n <MenuProvider modal={false} onOpenChange={handleOpenChange}>\n <MenuTrigger asChild>\n <IconButton\n data-slot=\"canvas-shell-options-button\"\n type=\"button\"\n variant=\"tertiary\"\n size=\"md\"\n isActive={isOpen}\n aria-label=\"More options\"\n className={cn('shrink-0', className)}\n {...props}\n >\n <MoreHorizontalIcon />\n </IconButton>\n </MenuTrigger>\n <Menu className={cn('w-[200px]', menuClassName)}>{children}</Menu>\n </MenuProvider>\n );\n}\n\nexport interface CanvasShellContentProps extends ComponentProps<'div'> {\n /**\n * Apply the shell's horizontal padding (`canvasShellContentPadding`).\n * Set false for edge-to-edge children that pad themselves.\n */\n hasPadding?: boolean;\n /**\n * Scroll children that overflow the region, on either axis, with always-visible scrollbars.\n * When false, the region clips overflow: for children that scroll themselves.\n */\n hasScroll?: boolean;\n}\n\n/**\n * Horizontal padding of the content region; reuse it to align custom scroll areas with the shell.\n */\nexport const canvasShellContentPadding = 'px-[12px] md:px-[16px]';\n\nexport function CanvasShellContent({\n className,\n hasPadding = true,\n hasScroll = true,\n children,\n ...props\n}: CanvasShellContentProps) {\n return (\n <div\n data-slot=\"canvas-shell-content\"\n data-has-scroll={hasScroll}\n className={cn('row-start-2', 'relative min-w-0 overflow-hidden', className)}\n {...props}\n >\n <div\n data-slot=\"canvas-shell-content-body\"\n data-spacing={hasPadding}\n className={cn(\n 'size-full',\n 'py-[16px]',\n hasPadding && canvasShellContentPadding,\n hasScroll ? 'overflow-auto' : 'overflow-hidden',\n )}\n >\n {children}\n </div>\n </div>\n );\n}\n\nexport type CanvasShellFooterProps = ComponentProps<'footer'>;\n\nexport function CanvasShellFooter({ className, ...props }: CanvasShellFooterProps) {\n return (\n <footer\n data-slot=\"canvas-shell-footer\"\n className={cn(\n 'row-start-3',\n 'flex items-center justify-end gap-[8px]',\n 'p-[12px] md:p-[16px]',\n 'pb-[20px]',\n className,\n )}\n {...props}\n />\n );\n}\n","import { createContext, useContext } from 'react';\n\nexport type CardItemPickerValue = string | number;\nexport type CardItemPickerOrientation = 'vertical' | 'horizontal';\n\nexport interface CardItemPickerListContextValue {\n value: CardItemPickerValue | null;\n hoveredValue: CardItemPickerValue | null;\n orientation: CardItemPickerOrientation;\n select: (value: CardItemPickerValue) => void;\n hover: (value: CardItemPickerValue | null) => void;\n}\n\nexport const CardItemPickerListContext = createContext<CardItemPickerListContextValue | null>(null);\n\nexport function useCardItemPickerListContext() {\n const context = useContext(CardItemPickerListContext);\n\n if (!context) {\n throw new Error('useCardItemPickerListContext must be used within a CardItemPickerList');\n }\n\n return context;\n}\n\nexport interface CardItemPickerRowContextValue {\n isSelected: boolean;\n titleId: string;\n descriptionId: string;\n registerTitle: () => () => void;\n registerDescription: () => () => void;\n}\n\nexport const CardItemPickerRowContext = createContext<CardItemPickerRowContextValue | null>(null);\n\nexport function useCardItemPickerRowContext() {\n const context = useContext(CardItemPickerRowContext);\n\n if (!context) {\n throw new Error('useCardItemPickerRowContext must be used within a CardItemPickerRow');\n }\n\n return context;\n}\n","import * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport type { ComponentPropsWithoutRef } from 'react';\nimport { useCallback, useMemo, useRef, useState } from 'react';\n\nimport { cn } from '@swisper.ai/ui';\n\nimport {\n CardItemPickerListContext,\n type CardItemPickerListContextValue,\n type CardItemPickerOrientation,\n type CardItemPickerValue,\n} from './card-item-picker-context';\n\nexport interface CardItemPickerListProps<\n V extends CardItemPickerValue = CardItemPickerValue,\n> extends Omit<ComponentPropsWithoutRef<'ul'>, 'role' | 'onKeyDown' | 'aria-orientation'> {\n /** The selected card, or `null` when nothing is selected. */\n value: V | null;\n /** The card under the pointer, mirrored as `data-hovered` (e.g. when a map pin is hovered). */\n hoveredValue?: V | null;\n /** A card was picked by click, Enter or Space. Toggling is up to the caller. */\n onValueChange: (value: V) => void;\n /** The pointer entered a card (`value`) or left it (`null`). */\n onHoverChange?: (value: V | null) => void;\n orientation?: CardItemPickerOrientation;\n}\n\n/**\n * A single-select list of cards, built on the ARIA listbox pattern: the list is\n * one tab stop that moves focus into the last focused card, else the selected\n * one, else the first. Arrow keys (plus Home/End, PageUp/PageDown) move between\n * cards and Enter/Space picks one. Name it with `aria-label` or `aria-labelledby`.\n *\n * Cards are listbox options, so they must not contain their own links or\n * buttons — put those in a details view instead.\n */\nexport function CardItemPickerList<V extends CardItemPickerValue>({\n value,\n hoveredValue = null,\n onValueChange,\n onHoverChange,\n orientation = 'vertical',\n className,\n children,\n ...props\n}: CardItemPickerListProps<V>) {\n // Radix moves focus; we only pick which card is the tab stop. Controlled so the\n // last focused card wins over the selected one (Radix's `active` would not).\n const [lastFocusedId, setLastFocusedId] = useState<string | null>(null);\n const tabStopId = lastFocusedId ?? (value != null ? String(value) : null);\n\n const onHoverChangeRef = useRef(onHoverChange);\n onHoverChangeRef.current = onHoverChange;\n const onValueChangeRef = useRef(onValueChange);\n onValueChangeRef.current = onValueChange;\n\n // items only ever report the values they were given, so these are the caller's `V`\n const select = useCallback(\n (itemValue: CardItemPickerValue) => onValueChangeRef.current(itemValue as V),\n [],\n );\n const hover = useCallback(\n (itemValue: CardItemPickerValue | null) => onHoverChangeRef.current?.(itemValue as V | null),\n [],\n );\n\n const context = useMemo<CardItemPickerListContextValue>(\n () => ({ value, hoveredValue, orientation, select, hover }),\n [value, hoveredValue, orientation, select, hover],\n );\n\n return (\n <CardItemPickerListContext.Provider value={context}>\n <RovingFocusGroup.Root\n asChild\n orientation={orientation}\n currentTabStopId={tabStopId}\n onCurrentTabStopIdChange={setLastFocusedId}\n >\n <ul\n {...props}\n role=\"listbox\"\n aria-orientation={orientation}\n className={cn(\n 'flex gap-[4px]',\n orientation === 'vertical' ? 'flex-col' : 'flex-row',\n className,\n )}\n >\n {children}\n </ul>\n </RovingFocusGroup.Root>\n </CardItemPickerListContext.Provider>\n );\n}\n","import * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport type { ComponentPropsWithoutRef, KeyboardEvent } from 'react';\nimport { forwardRef, useId, useMemo, useState } from 'react';\n\nimport { cn } from '@swisper.ai/ui';\n\nimport {\n CardItemPickerRowContext,\n type CardItemPickerRowContextValue,\n type CardItemPickerValue,\n useCardItemPickerListContext,\n} from './card-item-picker-context';\n\nexport interface CardItemPickerRowProps extends Omit<\n ComponentPropsWithoutRef<'li'>,\n 'role' | 'tabIndex' | 'aria-selected' | 'aria-labelledby' | 'aria-describedby'\n> {\n value: CardItemPickerValue;\n}\n\n/**\n * One card of a {@link CardItemPickerList}: a listbox option. Its accessible name\n * comes from {@link CardItemPickerRowTitle} and its description from\n * {@link CardItemPickerRowDescription}, when rendered.\n */\nexport const CardItemPickerRow = forwardRef<HTMLLIElement, CardItemPickerRowProps>(\n function CardItemPickerRow(\n { value, className, children, onClick, onKeyDown, onMouseEnter, onMouseLeave, ...props },\n forwardedRef,\n ) {\n const list = useCardItemPickerListContext();\n const id = useId();\n const [hasTitle, setHasTitle] = useState(false);\n const [hasDescription, setHasDescription] = useState(false);\n\n const isSelected = list.value === value;\n const isHovered = list.hoveredValue === value;\n\n const itemContext = useMemo<CardItemPickerRowContextValue>(\n () => ({\n isSelected,\n titleId: `${id}-title`,\n descriptionId: `${id}-description`,\n registerTitle: () => {\n setHasTitle(true);\n return () => setHasTitle(false);\n },\n registerDescription: () => {\n setHasDescription(true);\n return () => setHasDescription(false);\n },\n }),\n [id, isSelected],\n );\n\n function handleKeyDown(event: KeyboardEvent<HTMLLIElement>) {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n list.select(value);\n }\n }\n\n return (\n <CardItemPickerRowContext.Provider value={itemContext}>\n <RovingFocusGroup.Item asChild tabStopId={String(value)}>\n <li\n {...props}\n ref={forwardedRef}\n role=\"option\"\n aria-selected={isSelected}\n aria-labelledby={hasTitle ? itemContext.titleId : undefined}\n aria-describedby={hasDescription ? itemContext.descriptionId : undefined}\n data-selected={isSelected}\n data-hovered={isHovered}\n className={cn(\n 'relative flex flex-row items-start gap-4',\n 'w-full cursor-pointer rounded-(--st-border-radius-md) p-8',\n 'transition-colors duration-150',\n 'hover:bg-layout-accent-low-background-hover-base',\n 'data-[selected=true]:bg-layout-accent-low-background-pressed-base',\n // Not while focus-visible: these rules come later in the CSS and would hide the focus ring.\n 'data-[selected=true]:not-focus-visible:ring-1 data-[selected=true]:not-focus-visible:ring-inset',\n 'data-[selected=true]:not-focus-visible:ring-brand-secondary-700',\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary-focus-visible',\n className,\n )}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) list.select(value);\n }}\n onKeyDown={handleKeyDown}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n list.hover(value);\n }}\n onMouseLeave={(event) => {\n onMouseLeave?.(event);\n list.hover(null);\n }}\n >\n {children}\n </li>\n </RovingFocusGroup.Item>\n </CardItemPickerRowContext.Provider>\n );\n },\n);\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { useLayoutEffect } from 'react';\n\nimport { Checkbox, Typography, cn } from '@swisper.ai/ui';\n\nimport { useCardItemPickerRowContext } from './card-item-picker-context';\n\nexport type CardItemPickerRowMediaProps = ComponentPropsWithoutRef<'div'>;\n\n/** Leading visual of a card (a thumbnail); hidden from assistive tech. */\nexport function CardItemPickerRowMedia({ className, ...props }: CardItemPickerRowMediaProps) {\n useCardItemPickerRowContext();\n\n return (\n <div\n aria-hidden\n className={cn(\n 'shrink-0 aspect-square h-[64px] rounded-[4px] overflow-hidden bg-secondary-states-hover',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport type CardItemPickerRowContentProps = ComponentPropsWithoutRef<'div'>;\n\n/** The text column of a card, beside its media. */\nexport function CardItemPickerRowContent({ className, ...props }: CardItemPickerRowContentProps) {\n useCardItemPickerRowContext();\n\n return <div className={cn('flex-1 min-w-0 flex flex-col', className)} {...props} />;\n}\n\nexport interface CardItemPickerRowTitleProps {\n children: string;\n className?: string;\n}\n\n/** The card's name — becomes the option's accessible name. */\nexport function CardItemPickerRowTitle({ children, className }: CardItemPickerRowTitleProps) {\n const { titleId, registerTitle } = useCardItemPickerRowContext();\n\n useLayoutEffect(registerTitle, [registerTitle]);\n\n return (\n <Typography\n id={titleId}\n variant=\"body\"\n fontWeight=\"semibold\"\n className={cn('line-clamp-1', className)}\n title={children}\n >\n {children}\n </Typography>\n );\n}\n\nexport type CardItemPickerRowDescriptionProps = ComponentPropsWithoutRef<'div'>;\n\n/** Secondary details of a card — announced as the option's description. */\nexport function CardItemPickerRowDescription({\n className,\n ...props\n}: CardItemPickerRowDescriptionProps) {\n const { descriptionId, registerDescription } = useCardItemPickerRowContext();\n\n useLayoutEffect(registerDescription, [registerDescription]);\n\n return <div {...props} id={descriptionId} className={className} />;\n}\n\nexport interface CardItemPickerRowCheckboxProps {\n className?: string;\n}\n\n/**\n * A checkbox in the card's top-right corner that mirrors its selection. It only\n * shows the selection: the option already announces it through `aria-selected`,\n * and a listbox option can't hold a control of its own, so the checkbox is out of\n * the tab order, hidden from assistive tech, and clicks pass through to the card.\n * Leave room for it on the right of the card's content.\n */\nexport function CardItemPickerRowCheckbox({ className }: CardItemPickerRowCheckboxProps) {\n const { isSelected } = useCardItemPickerRowContext();\n\n return (\n <div\n aria-hidden\n data-testid=\"card-item-picker-row-checkbox\"\n className={cn('pointer-events-none absolute top-[8px] right-[8px]', className)}\n >\n <Checkbox checked={isSelected} tabIndex={-1} />\n </div>\n );\n}\n","import { Slot } from '@radix-ui/react-slot';\nimport { forwardRef, type ComponentProps, type ReactNode } from 'react';\n\nimport { useChatContext } from '@/contexts';\n\ninterface NewChatTriggerProps extends ComponentProps<'button'> {\n asChild?: boolean;\n children: ReactNode;\n}\n\nexport const NewChatTrigger = forwardRef<HTMLButtonElement, NewChatTriggerProps>(\n ({ asChild = false, children, onClick, ...rest }, ref) => {\n const { goToNewChat } = useChatContext();\n const Component = asChild ? Slot : 'button';\n\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event);\n goToNewChat();\n }\n\n return (\n <Component ref={ref} data-testid=\"new-chat-trigger\" onClick={handleClick} {...rest}>\n {children}\n </Component>\n );\n },\n);\n\nNewChatTrigger.displayName = 'NewChatTrigger';\n","import { AnimatePresence, motion } from 'motion/react';\nimport React, { forwardRef, type ComponentProps, type ReactNode, useMemo } from 'react';\n\nimport { ChevronDownIcon } from '@swisper.ai/icons';\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n Typography,\n type CollapsibleProps,\n} from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ChatThinkingProcessProps extends Omit<CollapsibleProps, 'isDisabled'> {\n children: ReactNode;\n className?: string;\n isStreaming?: boolean;\n}\n\nexport const ChatThinkingProcess = forwardRef<HTMLDivElement, ChatThinkingProcessProps>(\n function ChatThinkingProcess(\n { children, className, defaultOpen = false, isStreaming = false, ...rest },\n ref,\n ) {\n return (\n <Collapsible defaultOpen={defaultOpen} asChild {...rest}>\n <div\n ref={ref}\n data-testid=\"chat-thinking-process\"\n data-streaming={isStreaming}\n className={cn('group/thinking-process', 'flex flex-col', className)}\n >\n {children}\n </div>\n </Collapsible>\n );\n },\n);\n\nChatThinkingProcess.displayName = 'ChatThinkingProcess';\n\nexport interface ChatThinkingProcessTriggerProps extends ComponentProps<'button'> {\n children: ReactNode;\n className?: string;\n isLoading?: boolean;\n}\n\nexport function ChatThinkingProcessTrigger({\n children,\n className,\n ...rest\n}: ChatThinkingProcessTriggerProps) {\n return (\n <CollapsibleTrigger\n data-testid=\"chat-thinking-process-trigger\"\n className={cn('flex w-full items-center gap-4', 'cursor-pointer text-left', className)}\n {...rest}\n >\n {children}\n\n <style>\n {`\n @keyframes shimmer {\n 100% {\n mask-position: left;\n }\n }\n `}\n </style>\n </CollapsibleTrigger>\n );\n}\n\nexport interface ChatThinkingProcessTriggerIconProps extends ComponentProps<'span'> {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatThinkingProcessTriggerIcon({\n children,\n className,\n ...rest\n}: ChatThinkingProcessTriggerIconProps) {\n return (\n <span\n data-testid=\"chat-thinking-process-trigger-icon\"\n className={cn('inline-flex shrink-0 items-center justify-center', className)}\n {...rest}\n >\n {children}\n </span>\n );\n}\n\nexport interface ChatThinkingProcessTriggerLabelProps extends ComponentProps<'span'> {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatThinkingProcessTriggerLabel({\n children,\n className,\n ...rest\n}: ChatThinkingProcessTriggerLabelProps) {\n return (\n <Typography\n asChild\n variant=\"body-sm\"\n data-testid=\"chat-thinking-process-trigger-label\"\n className={cn(\n 'text-text-secondary',\n 'font-semibold',\n 'group-data-[streaming=true]/thinking-process:mask-[linear-gradient(-60deg,#000_30%,rgba(0,0,0,0.2),#192029_70%)]',\n 'group-data-[streaming=true]/thinking-process:mask-size-[300%_100%]',\n 'group-data-[streaming=true]/thinking-process:mask-right',\n 'group-data-[streaming=true]/thinking-process:animate-[shimmer_3.2s_infinite]',\n className,\n )}\n >\n <span {...rest}>{children}</span>\n </Typography>\n );\n}\n\nexport interface ChatThinkingProcessTriggerArrowProps extends ComponentProps<'span'> {\n className?: string;\n}\n\nexport function ChatThinkingProcessTriggerArrow({\n className,\n ...rest\n}: ChatThinkingProcessTriggerArrowProps) {\n return (\n <span\n data-testid=\"chat-thinking-process-trigger-arrow\"\n aria-hidden\n className={cn(\n 'inline-flex shrink-0 items-center justify-center text-text-secondary',\n 'transition-transform duration-300',\n 'group-data-[state=open]/collapsible:rotate-180',\n className,\n )}\n {...rest}\n >\n <ChevronDownIcon />\n </span>\n );\n}\n\nexport interface ChatThinkingProcessContentProps extends ComponentProps<'div'> {\n children: ReactNode;\n className?: string;\n itemsClassName?: string;\n hasLastMessagePreview?: boolean;\n}\n\nexport function ChatThinkingProcessContent({\n children,\n className,\n itemsClassName,\n hasLastMessagePreview = true,\n ...rest\n}: ChatThinkingProcessContentProps) {\n const { lastItemContent, lastItemIndex } = useMemo(() => {\n const childrenArray = React.Children.toArray(children);\n const lastItemContent = childrenArray.at(-1);\n const lastItemIndex = String(childrenArray.length);\n\n return { lastItemContent, lastItemIndex };\n }, [children]);\n\n return (\n <div\n data-testid=\"chat-thinking-process-content\"\n data-preview={hasLastMessagePreview}\n className={cn('pt-8', className)}\n >\n {hasLastMessagePreview && lastItemContent && (\n <AnimatePresence mode=\"wait\">\n <ChatThinkingProcessContentPreview contentId={lastItemIndex}>\n {lastItemContent}\n </ChatThinkingProcessContentPreview>\n </AnimatePresence>\n )}\n\n <CollapsibleContent\n data-testid=\"chat-thinking-process-content-items\"\n className={cn('flex flex-col', itemsClassName)}\n {...rest}\n >\n {React.Children.map(children, (child) => {\n return (\n <div\n className={cn(\n 'relative flex gap-8 text-text-secondary text-sm last:pb-0',\n 'pl-8',\n 'last:[&>div:first-child>span:last-child]:hidden',\n )}\n {...rest}\n >\n <div\n className=\"relative flex w-8 shrink-0 flex-col items-center self-stretch\"\n aria-hidden\n >\n <span className=\"mt-[7px] size-[6px] shrink-0 rounded-full bg-text-secondary\" />\n <span className=\"absolute top-[16px] bottom-[-4px] left-1/2 w-px -translate-x-1/2 bg-component-divider\" />\n </div>\n\n <div className=\"min-w-0 flex-1 pb-8\">{child}</div>\n </div>\n );\n })}\n </CollapsibleContent>\n </div>\n );\n}\n\nexport interface ChatThinkingProcessContentPreviewProps {\n children: ReactNode;\n className?: string;\n contentId: string;\n}\n\nexport function ChatThinkingProcessContentPreview({\n children,\n className,\n contentId,\n}: ChatThinkingProcessContentPreviewProps) {\n return (\n <motion.div\n key={contentId}\n data-testid=\"chat-thinking-process-content-preview\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 0.7 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.25, ease: 'easeOut' }}\n className={cn(\n 'group-data-[streaming=false]/thinking-process:hidden',\n 'group-data-[state=open]/thinking-process:hidden',\n 'px-4',\n className,\n )}\n >\n {children}\n </motion.div>\n );\n}\n\nexport interface ChatThinkingProcessContentItemProps extends ComponentProps<'div'> {\n children: ReactNode;\n className?: string;\n}\n\nexport function ChatThinkingProcessContentItem({\n children,\n className,\n ...rest\n}: ChatThinkingProcessContentItemProps) {\n return (\n <div\n data-testid=\"chat-thinking-process-content-item\"\n className={cn('text-text-secondary text-sm', className)}\n {...rest}\n >\n {children}\n </div>\n );\n}\n","// EmptyState moved to @swisper.ai/ui, so apps without the chat surface can use it too. These aliases\n// keep existing `@swisper.ai/web-chat-ui` imports compiling; the editor strikes them through.\n// A plain `export { … } from` would work at runtime but carries no @deprecated tag per symbol.\n// Kept as a flat file, not a component folder, so the echo-design reference build doesn't list\n// EmptyState under web-chat-ui as well.\nimport {\n EmptyState as UiEmptyState,\n EmptyStateActionRow as UiEmptyStateActionRow,\n EmptyStateDescription as UiEmptyStateDescription,\n EmptyStateIcon as UiEmptyStateIcon,\n EmptyStateTitle as UiEmptyStateTitle,\n type EmptyStateActionRowProps as UiEmptyStateActionRowProps,\n type EmptyStateDescriptionProps as UiEmptyStateDescriptionProps,\n type EmptyStateIconProps as UiEmptyStateIconProps,\n type EmptyStateProps as UiEmptyStateProps,\n type EmptyStateTitleProps as UiEmptyStateTitleProps,\n} from '@swisper.ai/ui';\n\n/** @deprecated Import `EmptyState` from `@swisper.ai/ui`. */\nexport const EmptyState = UiEmptyState;\n/** @deprecated Import `EmptyStateIcon` from `@swisper.ai/ui`. */\nexport const EmptyStateIcon = UiEmptyStateIcon;\n/** @deprecated Import `EmptyStateTitle` from `@swisper.ai/ui`. */\nexport const EmptyStateTitle = UiEmptyStateTitle;\n/** @deprecated Import `EmptyStateDescription` from `@swisper.ai/ui`. */\nexport const EmptyStateDescription = UiEmptyStateDescription;\n/** @deprecated Import `EmptyStateActionRow` from `@swisper.ai/ui`. */\nexport const EmptyStateActionRow = UiEmptyStateActionRow;\n\n/** @deprecated Import `EmptyStateProps` from `@swisper.ai/ui`. */\nexport type EmptyStateProps = UiEmptyStateProps;\n/** @deprecated Import `EmptyStateIconProps` from `@swisper.ai/ui`. */\nexport type EmptyStateIconProps = UiEmptyStateIconProps;\n/** @deprecated Import `EmptyStateTitleProps` from `@swisper.ai/ui`. */\nexport type EmptyStateTitleProps = UiEmptyStateTitleProps;\n/** @deprecated Import `EmptyStateDescriptionProps` from `@swisper.ai/ui`. */\nexport type EmptyStateDescriptionProps = UiEmptyStateDescriptionProps;\n/** @deprecated Import `EmptyStateActionRowProps` from `@swisper.ai/ui`. */\nexport type EmptyStateActionRowProps = UiEmptyStateActionRowProps;\n","import type { EditorThemeClasses } from 'lexical';\n\nexport const defaultEditorTheme: EditorThemeClasses = {\n paragraph: 'editor-paragraph',\n text: {\n bold: 'editor-text-bold',\n italic: 'editor-text-italic',\n underline: 'editor-text-underline',\n },\n} as const;\n","import {\n DecoratorNode,\n type DOMConversionMap,\n type DOMExportOutput,\n type LexicalNode,\n type NodeKey,\n type SerializedLexicalNode,\n type Spread,\n} from 'lexical';\nimport type { JSX } from 'react';\n\nexport type SerializedImageNode = Spread<{ src: string; altText: string }, SerializedLexicalNode>;\n\nexport class ImageNode extends DecoratorNode<JSX.Element> {\n __src: string;\n __altText: string;\n\n static override getType(): string {\n return 'image';\n }\n\n static override clone(node: ImageNode): ImageNode {\n return new ImageNode(node.__src, node.__altText, node.__key);\n }\n\n constructor(src: string, altText: string, key?: NodeKey) {\n super(key);\n this.__src = src;\n this.__altText = altText;\n }\n\n override createDOM(): HTMLElement {\n const span = document.createElement('span');\n span.style.display = 'inline-block';\n return span;\n }\n\n override updateDOM(): false {\n return false;\n }\n\n override decorate(): JSX.Element {\n return (\n <img\n src={this.__src}\n alt={this.__altText}\n style={{ maxWidth: '100%', display: 'block' }}\n draggable={false}\n />\n );\n }\n\n override exportDOM(): DOMExportOutput {\n const img = document.createElement('img');\n img.setAttribute('src', this.__src);\n img.setAttribute('alt', this.__altText);\n img.style.maxWidth = '100%';\n return { element: img };\n }\n\n static override importDOM(): DOMConversionMap | null {\n return {\n img: () => ({\n conversion: (domNode: HTMLElement) => {\n const src = domNode.getAttribute('src') || '';\n const alt = domNode.getAttribute('alt') || '';\n if (!src) return null;\n return { node: $createImageNode(src, alt) };\n },\n priority: 0,\n }),\n };\n }\n\n override exportJSON(): SerializedImageNode {\n return {\n ...super.exportJSON(),\n src: this.__src,\n altText: this.__altText,\n type: 'image',\n version: 1,\n };\n }\n\n static override importJSON(json: SerializedImageNode): ImageNode {\n return $createImageNode(json.src, json.altText);\n }\n\n override isInline(): boolean {\n return false;\n }\n}\n\nexport function $createImageNode(src: string, altText: string): ImageNode {\n return new ImageNode(src, altText);\n}\n\nexport function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode {\n return node instanceof ImageNode;\n}\n","import {\n TRANSFORMERS,\n type TextMatchTransformer,\n type ElementTransformer,\n} from '@lexical/markdown';\nimport { $isParagraphNode, $isTextNode, $createTextNode, type ElementFormatType } from 'lexical';\n\nimport { ImageNode, $createImageNode, $isImageNode } from './nodes/image-node';\n\nexport { TRANSFORMERS as MARKDOWN_TRANSFORMERS };\n\nexport function extractFontStyles(style: string) {\n const fontSizeRegex = /font-size\\s*:\\s*([^;]+)/i;\n const fontFamilyRegex = /font-family\\s*:\\s*([^;]+)/i;\n const colorRegex = /(?<![\\w-])color\\s*:\\s*([^;]+)/i;\n\n const fontSizeMatch = fontSizeRegex.exec(style);\n const fontFamilyMatch = fontFamilyRegex.exec(style);\n const colorMatch = colorRegex.exec(style);\n\n return {\n fontSize: fontSizeMatch ? fontSizeMatch[1].trim() : null,\n fontFamily: fontFamilyMatch ? fontFamilyMatch[1].trim() : null,\n color: colorMatch ? colorMatch[1].trim() : null,\n };\n}\n\nexport const FONT_STYLE_EXPORT: TextMatchTransformer = {\n type: 'text-match',\n trigger: '', // not used for export\n regExp: /./, // not used for export\n importRegExp: /./, // not used for export\n dependencies: [],\n\n export: (node) => {\n if (!$isTextNode(node)) return null;\n\n const style = node.getStyle() ?? '';\n const text = node.getTextContent();\n const fontStyles = extractFontStyles(style);\n\n if (fontStyles.fontSize || fontStyles.fontFamily || fontStyles.color) {\n let styleStr = '';\n\n if (fontStyles.fontSize) {\n styleStr += `font-size: ${fontStyles.fontSize};`;\n }\n\n if (fontStyles.fontFamily) {\n styleStr += `font-family: ${fontStyles.fontFamily};`;\n }\n\n if (fontStyles.color) {\n styleStr += `color: ${fontStyles.color};`;\n }\n\n return `<span style=\"${styleStr}\">${text}</span>`;\n }\n\n return null;\n },\n};\n\nexport const FONT_STYLE_IMPORT: TextMatchTransformer = {\n type: 'text-match',\n trigger: '',\n regExp: /<span\\s+style=\"([^\"]+)\">(.+?)<\\/span>/,\n importRegExp: /<span\\s+style=\"([^\"]+)\">(.+?)<\\/span>/,\n dependencies: [],\n replace: (textNode, match) => {\n const [, style, content] = match;\n const newNode = $createTextNode(content);\n\n // Preserve existing format (bold/underline) from the original node\n newNode.setFormat(textNode.getFormat());\n newNode.setStyle(style);\n textNode.replace(newNode);\n return newNode;\n },\n};\n\nexport const UNDERLINE_TRANSFORMER: TextMatchTransformer = {\n type: 'text-match',\n trigger: '',\n regExp: /<ins>(.*?)<\\/ins>/,\n importRegExp: /<ins>(.*?)<\\/ins>/,\n dependencies: [],\n replace: (textNode, match) => {\n const newNode = $createTextNode(match[1]);\n newNode.setFormat(textNode.getFormat());\n if (!newNode.hasFormat('underline')) {\n newNode.toggleFormat('underline');\n }\n textNode.replace(newNode);\n return newNode;\n },\n export: (node) => {\n if (!$isTextNode(node) || !node.hasFormat('underline')) return null;\n return `<ins>${node.getTextContent()}</ins>`;\n },\n};\n\nconst getAlignment = (style: string) => {\n const alignmentRegex = /text-align:\\s*(\\w+)/i;\n const alignmentMatch = alignmentRegex.exec(style);\n return alignmentMatch ? (alignmentMatch[1].trim() as ElementFormatType) : null;\n};\n\nexport const ALIGNMENT_TRANSFORMER: ElementTransformer = {\n type: 'element',\n dependencies: [],\n regExp: /<div\\s+style=\"([^\"]+)\">(.*?)<\\/div>/,\n replace: (parentNode, children, match) => {\n const alignment = getAlignment(match[1]);\n if (!alignment) return false;\n\n if (!match[2]) return;\n\n const child = children[0];\n if ($isTextNode(child)) {\n child.setTextContent(match[2]);\n }\n\n parentNode.setFormat(alignment);\n parentNode.append(...children);\n },\n export: (node, exportChildren) => {\n if (!$isParagraphNode(node)) return null;\n const alignment = node.getFormatType();\n if (!alignment || alignment === 'left') return null;\n\n const children = exportChildren(node);\n return `<div style=\"text-align: ${alignment}\">${children}</div>`;\n },\n};\n\nexport const IMAGE_EXPORT_TRANSFORMER: TextMatchTransformer = {\n type: 'text-match',\n trigger: '',\n regExp: /./,\n importRegExp: /./,\n dependencies: [ImageNode],\n export: (node) => {\n if (!$isImageNode(node)) return null;\n return `<img src=\"${node.__src}\" alt=\"${node.__altText}\" />`;\n },\n};\n\nexport const IMAGE_IMPORT_TRANSFORMER: TextMatchTransformer = {\n type: 'text-match',\n trigger: '',\n regExp: /<img\\s+src=\"([^\"]+)\"\\s+alt=\"([^\"]*)\"[^>]*\\/?>/,\n importRegExp: /<img\\s+src=\"([^\"]+)\"\\s+alt=\"([^\"]*)\"[^>]*\\/?>/,\n dependencies: [ImageNode],\n replace: (textNode, match) => {\n const [, src, alt] = match;\n const imageNode = $createImageNode(src, alt);\n textNode.replace(imageNode);\n },\n};\n\nexport const EXPORT_TRANSFORMERS = [\n ...TRANSFORMERS,\n FONT_STYLE_EXPORT,\n UNDERLINE_TRANSFORMER,\n ALIGNMENT_TRANSFORMER,\n IMAGE_EXPORT_TRANSFORMER,\n];\nexport const IMPORT_TRANSFORMERS = [\n ...TRANSFORMERS,\n FONT_STYLE_IMPORT,\n UNDERLINE_TRANSFORMER,\n ALIGNMENT_TRANSFORMER,\n IMAGE_IMPORT_TRANSFORMER,\n];\n","import { $createListNode, $createListItemNode, ListNode, ListItemNode } from '@lexical/list';\nimport { $createHeadingNode, HeadingNode } from '@lexical/rich-text';\nimport { setNodeIndentFromDOM, isHTMLElement, $isTextNode } from 'lexical';\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n DOMExportOutputMap,\n LexicalEditor,\n LexicalNode,\n ElementNode,\n} from 'lexical';\n\nimport { extractFontStyles } from './transformers';\n\nfunction convertHeadingElement(element: HTMLElement): DOMConversionOutput | null {\n const nodeName = element.nodeName.toLowerCase();\n if (\n nodeName !== 'h1' &&\n nodeName !== 'h2' &&\n nodeName !== 'h3' &&\n nodeName !== 'h4' &&\n nodeName !== 'h5' &&\n nodeName !== 'h6'\n ) {\n return null;\n }\n const node = $createHeadingNode(nodeName);\n const style = element.getAttribute('style') ?? '';\n node.setStyle(style);\n if (element.style) {\n const align = element.style.textAlign;\n if (\n align === 'left' ||\n align === 'right' ||\n align === 'center' ||\n align === 'justify' ||\n align === 'start' ||\n align === 'end'\n ) {\n node.setFormat(align);\n }\n setNodeIndentFromDOM(element, node);\n }\n return { node };\n}\n\nfunction isDomChecklist(domNode: HTMLElement): boolean {\n if (\n domNode.getAttribute('__lexicallisttype') === 'check' ||\n domNode.classList.contains('contains-task-list')\n ) {\n return true;\n }\n for (const child of domNode.childNodes) {\n if (isHTMLElement(child) && child.hasAttribute('aria-checked')) {\n return true;\n }\n }\n return false;\n}\n\nfunction convertListElement(domNode: HTMLElement): DOMConversionOutput | null {\n const nodeName = domNode.nodeName.toLowerCase();\n let node = null;\n if (nodeName === 'ol') {\n const start = (domNode as HTMLOListElement).start;\n node = $createListNode('number', start);\n } else if (nodeName === 'ul') {\n if (isDomChecklist(domNode)) {\n node = $createListNode('check');\n } else {\n node = $createListNode('bullet');\n }\n }\n if (!node) return null;\n const style = domNode.getAttribute('style') ?? '';\n node.setStyle(style);\n return { node };\n}\n\nfunction convertListItemElement(domNode: HTMLElement): DOMConversionOutput | null {\n const isGitHubCheckList = domNode.classList.contains('task-list-item');\n if (isGitHubCheckList) {\n for (const child of domNode.children) {\n if (child.tagName === 'INPUT') {\n const input = child as HTMLInputElement;\n const isCheckbox = input.getAttribute('type') === 'checkbox';\n if (isCheckbox) {\n const checked = input.hasAttribute('checked');\n const node = $createListItemNode(checked);\n const style = domNode.getAttribute('style') ?? '';\n node.setStyle(style);\n return { node };\n }\n }\n }\n }\n const ariaCheckedAttr = domNode.getAttribute('aria-checked');\n const checked =\n ariaCheckedAttr === 'true' ? true : ariaCheckedAttr === 'false' ? false : undefined;\n const node = $createListItemNode(checked);\n const style = domNode.getAttribute('style') ?? '';\n node.setStyle(style);\n return { node };\n}\n\nconst IMPORT_PRIORITY = 4;\n\nfunction convertSpanElementWithStyles(domNode: HTMLElement): DOMConversionOutput | null {\n const styleAttr = domNode.getAttribute('style') ?? '';\n const { color, fontSize, fontFamily } = extractFontStyles(styleAttr);\n\n if (!color && !fontSize && !fontFamily) {\n return null;\n }\n\n const domStyle = domNode.style;\n\n return {\n forChild: (lexicalNode) => {\n if (!$isTextNode(lexicalNode)) return lexicalNode;\n\n // Replicate Lexical's default text-format handling from applyTextFormatFromStyle\n const fontWeight = domStyle.fontWeight;\n const textDecoration = (domStyle.textDecoration || '').split(' ');\n if ((fontWeight === '700' || fontWeight === 'bold') && !lexicalNode.hasFormat('bold')) {\n lexicalNode.toggleFormat('bold');\n }\n if (textDecoration.includes('line-through') && !lexicalNode.hasFormat('strikethrough')) {\n lexicalNode.toggleFormat('strikethrough');\n }\n if (domStyle.fontStyle === 'italic' && !lexicalNode.hasFormat('italic')) {\n lexicalNode.toggleFormat('italic');\n }\n if (textDecoration.includes('underline') && !lexicalNode.hasFormat('underline')) {\n lexicalNode.toggleFormat('underline');\n }\n if (domStyle.verticalAlign === 'sub' && !lexicalNode.hasFormat('subscript')) {\n lexicalNode.toggleFormat('subscript');\n }\n if (domStyle.verticalAlign === 'super' && !lexicalNode.hasFormat('superscript')) {\n lexicalNode.toggleFormat('superscript');\n }\n\n // Apply inline CSS styles (color, font-size, font-family)\n let styleStr = '';\n if (fontSize) styleStr += `font-size: ${fontSize};`;\n if (fontFamily) styleStr += `font-family: ${fontFamily};`;\n if (color) styleStr += `color: ${color};`;\n lexicalNode.setStyle(styleStr);\n\n return lexicalNode;\n },\n node: null,\n };\n}\n\nexport const HTML_IMPORT_CONFIG: DOMConversionMap = {\n h1: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),\n h2: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),\n h3: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),\n h4: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),\n h5: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),\n h6: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),\n ul: () => ({ conversion: convertListElement, priority: IMPORT_PRIORITY }),\n ol: () => ({ conversion: convertListElement, priority: IMPORT_PRIORITY }),\n li: () => ({ conversion: convertListItemElement, priority: IMPORT_PRIORITY }),\n span: () => ({ conversion: convertSpanElementWithStyles, priority: IMPORT_PRIORITY }),\n};\n\ntype NodeExportDOMFn = (editor: LexicalEditor) => DOMExportOutput;\n\nfunction wrapExportWithStyle(OriginalClass: {\n prototype: { exportDOM: NodeExportDOMFn };\n}): (editor: LexicalEditor, target: LexicalNode) => DOMExportOutput {\n return (editor: LexicalEditor, target: LexicalNode) => {\n const result = OriginalClass.prototype.exportDOM.call(target, editor);\n const elementNode = target as ElementNode;\n const style = elementNode.getStyle();\n if (result.element && style) {\n (result.element as HTMLElement).setAttribute('style', style);\n }\n return result;\n };\n}\n\nexport const HTML_EXPORT_CONFIG: DOMExportOutputMap = new Map<\n unknown,\n (editor: LexicalEditor, target: LexicalNode) => DOMExportOutput\n>([\n [HeadingNode, wrapExportWithStyle(HeadingNode)],\n [ListNode, wrapExportWithStyle(ListNode)],\n [ListItemNode, wrapExportWithStyle(ListItemNode)],\n]) as DOMExportOutputMap;\n","import {\n $createParagraphNode,\n $isTextNode,\n ElementNode,\n setNodeIndentFromDOM,\n type DOMConversionMap,\n type DOMConversionOutput,\n type EditorConfig,\n type LexicalUpdateJSON,\n type RangeSelection,\n type SerializedElementNode,\n type Spread,\n} from 'lexical';\n\nexport type SerializedDivBlockNode = Spread<\n {\n style?: string;\n },\n SerializedElementNode\n>;\n\nexport class DivBlockNode extends ElementNode {\n static override getType(): string {\n return 'div-block';\n }\n\n static override clone(node: DivBlockNode): DivBlockNode {\n return new DivBlockNode(node.__key);\n }\n\n override createDOM(_config: EditorConfig): HTMLElement {\n const div = document.createElement('div');\n const style = this.getStyle();\n if (style) {\n div.style.cssText = style;\n }\n return div;\n }\n\n override updateDOM(prevNode: DivBlockNode, dom: HTMLElement): boolean {\n const prevStyle = prevNode.getStyle();\n const nextStyle = this.getStyle();\n if (prevStyle !== nextStyle) {\n dom.style.cssText = nextStyle;\n return true;\n }\n return false;\n }\n\n static override importDOM(): DOMConversionMap | null {\n return {\n div: () => ({\n conversion: convertDivElement,\n priority: 4,\n }),\n };\n }\n\n override exportJSON(): SerializedDivBlockNode {\n const json = super.exportJSON();\n const style = this.getStyle();\n if (style) {\n return { ...json, style };\n }\n return json;\n }\n\n static override importJSON(serializedNode: SerializedDivBlockNode): DivBlockNode {\n const node = $createDivBlockNode().updateFromJSON(serializedNode);\n if (serializedNode.style !== undefined) {\n node.setStyle(serializedNode.style);\n }\n return node;\n }\n\n override updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedDivBlockNode>): this {\n const updated = super.updateFromJSON(serializedNode);\n if (serializedNode.style !== undefined) {\n updated.setStyle(serializedNode.style);\n }\n return updated;\n }\n\n override collapseAtStart(_selection: RangeSelection): boolean {\n const children = this.getChildren();\n const isEmptyOrBlank =\n children.length === 0 ||\n ($isTextNode(children[0]) && children[0].getTextContent().trim() === '');\n\n if (isEmptyOrBlank) {\n const nextSibling = this.getNextSibling();\n if (nextSibling !== null) {\n this.selectNext();\n this.remove();\n return true;\n }\n const prevSibling = this.getPreviousSibling();\n if (prevSibling !== null) {\n this.selectPrevious();\n this.remove();\n return true;\n }\n } else {\n const paragraph = $createParagraphNode();\n paragraph.setFormat(this.getFormatType());\n paragraph.setStyle(this.getStyle());\n paragraph.setIndent(this.getIndent());\n paragraph.setDirection(this.getDirection());\n children.forEach((child) => paragraph.append(child));\n this.replace(paragraph);\n return true;\n }\n\n return false;\n }\n}\n\nfunction convertDivElement(domNode: HTMLElement): DOMConversionOutput | null {\n const node = $createDivBlockNode();\n const style = domNode.getAttribute('style') ?? '';\n node.setStyle(style);\n if (domNode.style) {\n const align = domNode.style.textAlign;\n if (\n align === 'left' ||\n align === 'right' ||\n align === 'center' ||\n align === 'justify' ||\n align === 'start' ||\n align === 'end'\n ) {\n node.setFormat(align);\n }\n setNodeIndentFromDOM(domNode, node);\n }\n return { node };\n}\n\nexport function $createDivBlockNode(): DivBlockNode {\n return new DivBlockNode();\n}\n\nexport function $isDivBlockNode(node: unknown): node is DivBlockNode {\n return node instanceof DivBlockNode;\n}\n","import { $generateHtmlFromNodes } from '@lexical/html';\nimport { $convertToMarkdownString } from '@lexical/markdown';\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';\nimport { type EditorState, type LexicalEditor } from 'lexical';\nimport { useCallback } from 'react';\n\nimport { EXPORT_TRANSFORMERS } from '../transformers';\n\nexport { MARKDOWN_TRANSFORMERS } from '../transformers';\n\ninterface ValuePluginProps {\n onChange?: (value: string) => void;\n source?: 'html' | 'markdown';\n}\n\nexport function ValuePlugin({ onChange, source = 'markdown' }: ValuePluginProps) {\n const handleChange = useCallback(\n (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => {\n if (tags.has('focus')) {\n return;\n }\n\n if (!onChange) {\n return;\n }\n\n try {\n editorState.read(() => {\n const value =\n source === 'html'\n ? $generateHtmlFromNodes(editor)\n : $convertToMarkdownString(EXPORT_TRANSFORMERS);\n\n onChange(value);\n });\n } catch (error) {\n if (import.meta.env.DEV) {\n console.error('ValuePlugin error:', error);\n }\n }\n },\n [onChange, source],\n );\n\n return <OnChangePlugin onChange={handleChange} />;\n}\n","import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { $getSelection } from 'lexical';\nimport { useCallback } from 'react';\n\nexport function useRichTextAreaEditor() {\n const [editor] = useLexicalComposerContext();\n\n return editor;\n}\n\nexport function useRichTextAreaSelectedText() {\n const [editor] = useLexicalComposerContext();\n\n return useCallback(() => {\n let selectedText = '';\n\n editor.getEditorState().read(() => {\n const selection = $getSelection();\n selectedText = selection?.getTextContent() ?? '';\n });\n\n return selectedText;\n }, [editor]);\n}\n","import { useEffect } from 'react';\n\nimport { useRichTextAreaEditor } from '../hooks';\n\ninterface DisabledPluginProps {\n isDisabled?: boolean;\n}\n\nexport function DisabledPlugin({ isDisabled }: DisabledPluginProps) {\n const editor = useRichTextAreaEditor();\n\n useEffect(() => {\n editor.setEditable(!isDisabled);\n }, [editor, isDisabled]);\n\n return null;\n}\n","import { EditorRefPlugin } from '@lexical/react/LexicalEditorRefPlugin';\nimport { type LexicalEditor } from 'lexical';\nimport { useRef, useImperativeHandle, type Ref } from 'react';\n\ninterface ControlledPluginProps {\n controlledRef: Ref<HTMLInputElement | null>;\n}\n\nexport function ControlledPlugin({ controlledRef }: ControlledPluginProps) {\n const editorRef = useRef<LexicalEditor | null>(null);\n\n useImperativeHandle(controlledRef, (): HTMLInputElement | null => {\n return {\n focus: () => {\n Promise.resolve().then(() => {\n editorRef.current?.focus();\n });\n },\n } as unknown as HTMLInputElement;\n }, []);\n\n return <EditorRefPlugin editorRef={editorRef} />;\n}\n","import { $generateNodesFromDOM } from '@lexical/html';\nimport { type LexicalEditor, type LexicalNode } from 'lexical';\nimport {\n $getRoot,\n $isTextNode,\n $createParagraphNode,\n $createRangeSelection,\n $setSelection,\n $selectAll,\n $getSelection,\n $isRangeSelection,\n} from 'lexical';\n\nexport function scrollRichTextAreaToBottom(editor: LexicalEditor): void {\n const rootElement = editor.getRootElement();\n if (!rootElement) {\n return;\n }\n rootElement.scrollTop = rootElement.scrollHeight;\n}\n\nexport function $setSelectionToEnd() {\n const root = $getRoot();\n const lastDescendant = root.getLastDescendant();\n\n if (lastDescendant && $isTextNode(lastDescendant)) {\n const selection = $createRangeSelection();\n const endOffset = lastDescendant.getTextContentSize();\n selection.anchor.set(lastDescendant.getKey(), endOffset, 'text');\n selection.focus.set(lastDescendant.getKey(), endOffset, 'text');\n $setSelection(selection);\n } else {\n $selectAll();\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const focusNode = selection.focus.getNode();\n const focusOffset = $isTextNode(focusNode) ? focusNode.getTextContentSize() : 0;\n selection.anchor.set(selection.focus.key, selection.focus.offset, selection.focus.type);\n selection.focus.set(selection.focus.key, focusOffset, selection.focus.type);\n $setSelection(selection);\n }\n }\n}\n\nfunction getHTMLNodesFromValue(editor: LexicalEditor, html: string): LexicalNode[] {\n const parser = new DOMParser();\n const dom = parser.parseFromString(html, 'text/html');\n const nodes = $generateNodesFromDOM(editor, dom);\n\n return nodes.map((node) => {\n if ($isTextNode(node)) {\n const p = $createParagraphNode();\n p.append(node);\n return p;\n }\n return node;\n });\n}\n\nexport function $replaceEditorHTMLContent(editor: LexicalEditor, html: string): void {\n const root = $getRoot();\n root.clear();\n getHTMLNodesFromValue(editor, html).forEach((node) => root.append(node));\n}\n\nexport function $replaceEditorSelectionHTMLContent(editor: LexicalEditor, html: string): void {\n const selection = $getSelection();\n const nodes = getHTMLNodesFromValue(editor, html);\n\n if ($isRangeSelection(selection)) {\n selection.insertNodes(nodes);\n } else {\n const root = $getRoot();\n root.clear();\n nodes.forEach((node) => root.append(node));\n }\n}\n","import { $generateHtmlFromNodes } from '@lexical/html';\nimport { $convertToMarkdownString, $convertFromMarkdownString } from '@lexical/markdown';\nimport { $getRoot, $addUpdateTag, SKIP_DOM_SELECTION_TAG } from 'lexical';\nimport { useEffect, useRef } from 'react';\n\nimport { useIsResolution } from '@swisper.ai/ui';\n\nimport { useRichTextAreaEditor } from '../hooks';\nimport { EXPORT_TRANSFORMERS, IMPORT_TRANSFORMERS } from '../transformers';\nimport {\n $replaceEditorHTMLContent,\n $setSelectionToEnd,\n scrollRichTextAreaToBottom,\n} from '../utils';\n\ninterface ControlledValuePluginProps {\n value?: string;\n source?: 'html' | 'markdown';\n}\n\nexport function ControlledValuePlugin({ value, source = 'markdown' }: ControlledValuePluginProps) {\n const editor = useRichTextAreaEditor();\n const previousValueRef = useRef<string | undefined>();\n const shouldScrollOnInitialValueRef = useRef(Boolean(value?.trim()));\n const isDesktop = useIsResolution('desktop');\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n if (value === previousValueRef.current) {\n return;\n }\n\n previousValueRef.current = value;\n\n let currentValue = '';\n editor.getEditorState().read(() => {\n currentValue =\n source === 'html'\n ? $generateHtmlFromNodes(editor)\n : $convertToMarkdownString(EXPORT_TRANSFORMERS);\n });\n\n if (value !== undefined && value !== currentValue) {\n if (value === '') {\n editor.update(\n () => {\n $addUpdateTag(SKIP_DOM_SELECTION_TAG);\n if (source === 'html') {\n $getRoot().clear();\n } else {\n $convertFromMarkdownString('', IMPORT_TRANSFORMERS);\n }\n $setSelectionToEnd();\n },\n {\n discrete: true,\n },\n );\n\n Promise.resolve().then(() => {\n if (isDesktop) {\n editor.focus();\n } else {\n editor.blur();\n }\n });\n\n return;\n }\n\n editor.update(() => {\n $addUpdateTag(SKIP_DOM_SELECTION_TAG);\n if (source === 'html') {\n $replaceEditorHTMLContent(editor, value);\n } else {\n $convertFromMarkdownString(value, IMPORT_TRANSFORMERS);\n }\n $setSelectionToEnd();\n });\n\n if (shouldScrollOnInitialValueRef.current) {\n shouldScrollOnInitialValueRef.current = false;\n Promise.resolve().then(() => {\n requestAnimationFrame(() => scrollRichTextAreaToBottom(editor));\n });\n }\n\n if (isDesktop) {\n // Focus after update completes\n Promise.resolve().then(() => {\n editor.focus();\n });\n }\n }\n }, [editor, value, source, isDesktop]);\n\n return null;\n}\n","import { useEffect } from 'react';\n\nimport { useRichTextAreaEditor } from '../hooks';\n\ninterface BlurPluginProps {\n onBlur?: () => void;\n}\n\nexport function BlurPlugin({ onBlur }: BlurPluginProps) {\n const editor = useRichTextAreaEditor();\n\n useEffect(() => {\n if (!onBlur) {\n return;\n }\n\n const rootElement = editor.getRootElement();\n if (!rootElement) {\n return;\n }\n\n function handleBlur(event: FocusEvent) {\n if (rootElement && onBlur && !rootElement.contains(event.relatedTarget as Node)) {\n onBlur();\n }\n }\n\n rootElement.addEventListener('blur', handleBlur, true);\n\n return () => {\n rootElement.removeEventListener('blur', handleBlur, true);\n };\n }, [editor, onBlur]);\n\n return null;\n}\n","import { useEffect } from 'react';\n\nimport { useRichTextAreaEditor } from '../hooks';\n\ninterface FocusPluginProps {\n onFocusChange?: (isFocused: boolean) => void;\n}\n\nexport function FocusPlugin({ onFocusChange }: FocusPluginProps) {\n const editor = useRichTextAreaEditor();\n\n useEffect(() => {\n if (!onFocusChange) {\n return;\n }\n\n const rootElement = editor.getRootElement();\n if (!rootElement) {\n return;\n }\n\n function handleFocus() {\n if (rootElement && onFocusChange) {\n onFocusChange(true);\n }\n }\n\n function handleBlur(event: FocusEvent) {\n if (rootElement && onFocusChange && !rootElement.contains(event.relatedTarget as Node)) {\n onFocusChange(false);\n }\n }\n\n rootElement.addEventListener('focus', handleFocus, true);\n rootElement.addEventListener('blur', handleBlur, true);\n\n return () => {\n rootElement.removeEventListener('focus', handleFocus, true);\n rootElement.removeEventListener('blur', handleBlur, true);\n };\n }, [editor, onFocusChange]);\n\n return null;\n}\n","import { $insertNodes, COMMAND_PRIORITY_EDITOR, createCommand, type LexicalCommand } from 'lexical';\nimport { useEffect } from 'react';\n\nimport { useRichTextAreaEditor } from '../hooks';\nimport { $createImageNode } from '../nodes/image-node';\n\nexport interface InsertImagePayload {\n src: string;\n altText: string;\n}\n\nexport const INSERT_IMAGE_COMMAND: LexicalCommand<InsertImagePayload> =\n createCommand('INSERT_IMAGE_COMMAND');\n\nexport const INSERT_IMAGE_EVENT_NAME = 'helvetiq:insert-image';\n\nexport class ImageAddedEvent extends CustomEvent<InsertImagePayload> {\n constructor(payload: InsertImagePayload) {\n super(INSERT_IMAGE_EVENT_NAME, { detail: payload });\n }\n}\n\nexport function ImageDropPlugin() {\n const editor = useRichTextAreaEditor();\n\n useEffect(() => {\n return editor.registerCommand(\n INSERT_IMAGE_COMMAND,\n (payload: InsertImagePayload) => {\n editor.update(() => {\n const imageNode = $createImageNode(payload.src, payload.altText);\n $insertNodes([imageNode]);\n });\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\n );\n }, [editor]);\n\n useEffect(() => {\n const rootElement = editor.getRootElement();\n if (!rootElement) return;\n\n function handleInsertImage(event: Event) {\n const customEvent = event as CustomEvent<InsertImagePayload>;\n editor.dispatchCommand(INSERT_IMAGE_COMMAND, customEvent.detail);\n }\n\n document.addEventListener(INSERT_IMAGE_EVENT_NAME, handleInsertImage);\n return () => {\n document.removeEventListener(INSERT_IMAGE_EVENT_NAME, handleInsertImage);\n };\n }, [editor]);\n\n return null;\n}\n","import { $generateNodesFromDOM } from '@lexical/html';\nimport {\n $getRoot,\n $insertNodes,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n type LexicalCommand,\n} from 'lexical';\nimport { useEffect } from 'react';\n\nimport { useRichTextAreaEditor } from '../hooks';\n\nexport interface PasteHtmlPayload {\n html: string;\n}\n\nexport interface InsertHtmlPayload {\n html: string;\n}\n\nexport const PASTE_HTML_COMMAND: LexicalCommand<PasteHtmlPayload> =\n createCommand('PASTE_HTML_COMMAND');\n\nexport const INSERT_HTML_COMMAND: LexicalCommand<InsertHtmlPayload> =\n createCommand('INSERT_HTML_COMMAND');\n\nexport const PASTE_HTML_EVENT = 'helvetiq:paste-html';\nexport const INSERT_HTML_EVENT = 'helvetiq:insert-html';\n\nexport class PasteHtmlEvent extends CustomEvent<PasteHtmlPayload> {\n constructor(payload: PasteHtmlPayload) {\n super(PASTE_HTML_EVENT, { detail: payload });\n }\n}\n\nexport class InsertHtmlEvent extends CustomEvent<InsertHtmlPayload> {\n constructor(payload: InsertHtmlPayload) {\n super(INSERT_HTML_EVENT, { detail: payload });\n }\n}\n\nexport function HtmlPastePlugin() {\n const editor = useRichTextAreaEditor();\n\n useEffect(() => {\n return editor.registerCommand(\n PASTE_HTML_COMMAND,\n (payload: PasteHtmlPayload) => {\n editor.update(() => {\n const root = $getRoot();\n root.clear();\n\n const parser = new DOMParser();\n const dom = parser.parseFromString(payload.html, 'text/html');\n const nodes = $generateNodesFromDOM(editor, dom);\n root.append(...nodes);\n });\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\n );\n }, [editor]);\n\n useEffect(() => {\n return editor.registerCommand(\n INSERT_HTML_COMMAND,\n (payload: InsertHtmlPayload) => {\n editor.update(() => {\n const parser = new DOMParser();\n const dom = parser.parseFromString(payload.html, 'text/html');\n const nodes = $generateNodesFromDOM(editor, dom);\n $insertNodes(nodes);\n });\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\n );\n }, [editor]);\n\n useEffect(() => {\n const rootElement = editor.getRootElement();\n if (!rootElement) return;\n\n function handlePasteHtml(event: Event) {\n const customEvent = event as PasteHtmlEvent;\n editor.dispatchCommand(PASTE_HTML_COMMAND, customEvent.detail);\n }\n\n function handleInsertHtml(event: Event) {\n const customEvent = event as InsertHtmlEvent;\n editor.dispatchCommand(INSERT_HTML_COMMAND, customEvent.detail);\n }\n\n document.addEventListener(PASTE_HTML_EVENT, handlePasteHtml);\n document.addEventListener(INSERT_HTML_EVENT, handleInsertHtml);\n\n return () => {\n document.removeEventListener(PASTE_HTML_EVENT, handlePasteHtml);\n document.removeEventListener(INSERT_HTML_EVENT, handleInsertHtml);\n };\n }, [editor]);\n\n return null;\n}\n","import {\n $createParagraphNode,\n $createTextNode,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_CRITICAL,\n PASTE_COMMAND,\n} from 'lexical';\nimport { useEffect } from 'react';\n\nimport { useRichTextAreaEditor } from '../hooks';\n\nexport function MarkdownPlainPastePlugin() {\n const editor = useRichTextAreaEditor();\n\n useEffect(() => {\n return editor.registerCommand<ClipboardEvent>(\n PASTE_COMMAND,\n (event) => {\n const { clipboardData } = event;\n\n if (!clipboardData) {\n return false;\n }\n\n const plainText = clipboardData.getData('text/plain');\n\n if (!plainText) {\n return false;\n }\n\n event.preventDefault();\n\n editor.update(() => {\n const selection = $getSelection();\n\n if ($isRangeSelection(selection)) {\n selection.insertText(plainText);\n return;\n }\n\n const root = $getRoot();\n root.clear();\n\n const lines = plainText.split(/\\r?\\n/);\n lines.forEach((line) => {\n const paragraph = $createParagraphNode();\n if (line.length > 0) {\n paragraph.append($createTextNode(line));\n }\n root.append(paragraph);\n });\n });\n\n return true;\n },\n COMMAND_PRIORITY_CRITICAL,\n );\n }, [editor]);\n\n return null;\n}\n","import { COMMAND_PRIORITY_EDITOR, createCommand, type LexicalCommand } from 'lexical';\nimport { useEffect, useRef } from 'react';\n\nimport { useRichTextAreaEditor } from '../hooks';\n\nexport const ATTACH_FILE_COMMAND: LexicalCommand<void> = createCommand('ATTACH_FILE_COMMAND');\n\ninterface FileAttachmentPluginProps {\n acceptedFiles?: string[];\n isMultiple?: boolean;\n onFileAttach?: (files: File[]) => void;\n}\n\nexport function FileAttachmentPlugin({\n acceptedFiles = [],\n isMultiple = false,\n onFileAttach,\n}: FileAttachmentPluginProps) {\n const editor = useRichTextAreaEditor();\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n return editor.registerCommand(\n ATTACH_FILE_COMMAND,\n () => {\n inputRef.current?.click();\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\n );\n }, [editor]);\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement>) {\n const files = Array.from(event.target.files ?? []);\n\n if (!isMultiple) {\n const file = files[0];\n onFileAttach?.([file]);\n } else {\n onFileAttach?.(files);\n }\n\n event.target.value = '';\n }\n\n return (\n <input\n ref={inputRef}\n type=\"file\"\n multiple={isMultiple}\n aria-hidden=\"true\"\n className=\"hidden\"\n accept={acceptedFiles?.join(',')}\n onChange={handleChange}\n />\n );\n}\n","import { forwardRef, type HTMLAttributes } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nexport const Wrapper = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n 'w-full resize-none border-none outline-none bg-transparent font-[inherit] text-[inherit] flex items-center [&_.editor-paragraph]:m-0 [&_.editor-paragraph]:min-h-[26px] [&_.editor-text-bold]:font-bold [&_.editor-text-italic]:italic [&_.editor-text-underline]:underline',\n className,\n )}\n {...props}\n />\n );\n },\n);\n\nWrapper.displayName = 'Wrapper';\n","import { CodeNode } from '@lexical/code';\nimport { LinkNode } from '@lexical/link';\nimport { ListNode, ListItemNode } from '@lexical/list';\nimport { type InitialConfigType, LexicalComposer } from '@lexical/react/LexicalComposer';\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable';\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';\nimport { TablePlugin } from '@lexical/react/LexicalTablePlugin';\nimport { HeadingNode, QuoteNode } from '@lexical/rich-text';\nimport { TableCellNode, TableNode, TableRowNode } from '@lexical/table';\nimport { forwardRef } from 'react';\nimport type { KeyboardEvent, Ref, ReactNode } from 'react';\n\nimport { Typography } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport { defaultEditorTheme } from './constants';\nimport { HTML_IMPORT_CONFIG, HTML_EXPORT_CONFIG } from './html-config';\nimport { DivBlockNode } from './nodes/div-block-node';\nimport { ImageNode } from './nodes/image-node';\nimport {\n ValuePlugin,\n DisabledPlugin,\n ControlledPlugin,\n ControlledValuePlugin,\n BlurPlugin,\n FocusPlugin,\n MarkdownPlainPastePlugin,\n} from './plugins';\nimport { Wrapper } from './styled';\n\nexport const INITIAL_CONFIG: InitialConfigType = {\n namespace: 'helvetiq',\n theme: defaultEditorTheme,\n editable: true,\n nodes: [\n ListNode,\n ListItemNode,\n HeadingNode,\n QuoteNode,\n CodeNode,\n LinkNode,\n ImageNode,\n DivBlockNode,\n TableNode,\n TableCellNode,\n TableRowNode,\n ],\n html: {\n import: HTML_IMPORT_CONFIG,\n export: HTML_EXPORT_CONFIG,\n },\n onError: (error: Error) => {\n console.error('Lexical error:', error);\n },\n};\n\nexport interface RichTextAreaProps {\n children?: ReactNode;\n name?: string;\n value?: string;\n source?: 'html' | 'markdown';\n className?: string;\n containerClassName?: string;\n placeholderClassName?: string;\n placeholder?: string;\n isDisabled?: boolean;\n onChange?: (value: string) => void;\n onBlur?: () => void;\n onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;\n onFocusChange?: (isFocused: boolean) => void;\n}\n\nfunction RichTextAreaImpl({\n children,\n name,\n value,\n source = 'markdown',\n className,\n containerClassName,\n placeholderClassName,\n placeholder = '',\n isDisabled = false,\n onChange,\n onBlur,\n onKeyDown,\n onFocusChange,\n forwardedRef,\n ...rest\n}: RichTextAreaProps & { forwardedRef?: Ref<HTMLInputElement> }) {\n return (\n <LexicalComposer initialConfig={INITIAL_CONFIG}>\n <Wrapper\n data-testid=\"rich-text-area\"\n aria-disabled={isDisabled}\n data-disabled={isDisabled}\n className={cn(\n 'relative size-full overflow-hidden',\n 'data-[disabled=true]:opacity-80',\n 'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:select-none',\n containerClassName,\n )}\n {...rest}\n >\n <RichTextPlugin\n contentEditable={\n <ContentEditable\n className={cn('relative inset-0 overflow-y-auto', className)}\n data-name={name}\n aria-placeholder={placeholder}\n placeholder={\n <Typography\n variant=\"body\"\n className={cn(\n 'absolute left-0 top-0',\n 'text-text-tertiary',\n 'pointer-events-none user-select-none',\n placeholderClassName,\n )}\n >\n {placeholder}\n </Typography>\n }\n onKeyDownCapture={onKeyDown}\n style={{\n outline: 'none',\n minHeight: '20px',\n }}\n />\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n\n <DisabledPlugin isDisabled={isDisabled} />\n <ControlledValuePlugin value={value} source={source} />\n <ValuePlugin onChange={onChange} source={source} />\n <BlurPlugin onBlur={onBlur} />\n <HistoryPlugin />\n <ControlledPlugin controlledRef={forwardedRef ?? null} />\n <FocusPlugin onFocusChange={onFocusChange} />\n <TablePlugin />\n\n {source === 'markdown' && <MarkdownPlainPastePlugin />}\n {/* external plugins */}\n {children}\n </Wrapper>\n </LexicalComposer>\n );\n}\n\nexport const RichTextArea = forwardRef<HTMLInputElement, RichTextAreaProps>((props, ref) => {\n return <RichTextAreaImpl {...props} forwardedRef={ref} />;\n});\n\nRichTextArea.displayName = 'RichTextArea';\n","export const DEFAULT_FONT_FAMILY = 'Arial, sans-serif' as const;\n\nexport const FONT_FAMILY_OPTIONS = [\n { value: 'Arial, sans-serif', label: 'Arial' },\n { value: 'Verdana, sans-serif', label: 'Verdana' },\n { value: 'Tahoma, sans-serif', label: 'Tahoma' },\n { value: '\"Trebuchet MS\", sans-serif', label: 'Trebuchet MS' },\n { value: '\"Times New Roman\", serif', label: 'Times New Roman' },\n { value: 'Georgia, serif', label: 'Georgia' },\n { value: 'Garamond, serif', label: 'Garamond' },\n { value: '\"Courier New\", monospace', label: 'Courier New' },\n { value: '\"Brush Script MT\", cursive', label: 'Brush Script MT' },\n] as const;\n\nexport const DEFAULT_FONT_FAMILY_VALUE = DEFAULT_FONT_FAMILY;\n\nexport const DEFAULT_FONT_SIZE = '16';\n\nexport const FONT_SIZE_OPTIONS = [\n { label: '10', value: '10' },\n { label: '12', value: '12' },\n { label: '16', value: '16' },\n { label: '20', value: '20' },\n { label: '24', value: '24' },\n { label: '34', value: '34' },\n { label: '48', value: '48' },\n] as const;\n\nexport const ALIGNMENT_OPTIONS = ['left', 'center', 'right'] as const;\n\nexport const DEFAULT_ALIGNMENT = 'left' as const;\n\nexport const DEFAULT_TEXT_COLOR = '#000000' as const;\n","import { SelectField, type SelectFieldProps } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ToolbarSelectProps extends SelectFieldProps {}\n\nexport function ToolbarSelect({ className, selectItemClassName, ...rest }: ToolbarSelectProps) {\n return (\n <SelectField\n fullWidth={false}\n size=\"small\"\n className={cn(className)}\n labelClassName={'border-none group-data-[state=open]/select:bg-secondary-states-hover!'}\n // chevronIconClassName={cn('text-secondary-main')}\n // selectItemClassName={cn('[&_svg]:size-[20px]', selectItemClassName)}\n // iconClassName={cn('h-16')}\n {...rest}\n />\n );\n}\n","import { mergeRegister } from '@lexical/utils';\nimport {\n $getSelection,\n $isElementNode,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n FORMAT_ELEMENT_COMMAND,\n type ElementFormatType,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical';\nimport { type ReactNode, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport {\n FormatAlignCenterIcon,\n FormatAlignLeftIcon,\n FormatAlignRightIcon,\n} from '@swisper.ai/icons';\nimport { cn } from '@swisper.ai/web-core';\n\nimport { useRichTextAreaEditor } from '../../rich-text-area/hooks';\nimport { DEFAULT_ALIGNMENT } from '../constants';\nimport { type RichTextFieldAlignment } from '../context';\n\nimport { ToolbarSelect } from './toolbar-select';\n\nfunction toAlignment(format: ElementFormatType): RichTextFieldAlignment {\n if (format === 'center' || format === 'right') {\n return format;\n }\n if (format === 'end') {\n return 'right';\n }\n return 'left';\n}\n\nconst ALIGNMENT_OPTIONS_MAP: Record<RichTextFieldAlignment, { label: string; icon: ReactNode }> = {\n left: { label: 'Left', icon: <FormatAlignLeftIcon fontSize=\"inherit\" /> },\n center: { label: 'Center', icon: <FormatAlignCenterIcon fontSize=\"inherit\" /> },\n right: { label: 'Right', icon: <FormatAlignRightIcon fontSize=\"inherit\" /> },\n};\n\nexport interface AlignmentSelectProps {\n className?: string;\n}\n\nexport function AlignmentSelect({ className }: AlignmentSelectProps) {\n const editor = useRichTextAreaEditor();\n const [value, setValue] = useState<RichTextFieldAlignment>(DEFAULT_ALIGNMENT);\n\n const options = useMemo(\n () =>\n Object.entries(ALIGNMENT_OPTIONS_MAP).map(([value, { label, icon }]) => ({\n value: value as RichTextFieldAlignment,\n label,\n icon,\n })),\n [],\n );\n\n const $updateValue = useCallback(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const node = selection.anchor.getNode();\n const parent = node.getParent();\n const element = $isElementNode(node) ? node : parent;\n if ($isElementNode(element)) {\n setValue(toAlignment(element.getFormatType() || DEFAULT_ALIGNMENT));\n }\n }\n }, []);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n $updateValue();\n });\n }),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n $updateValue();\n return false;\n },\n COMMAND_PRIORITY_LOW,\n ),\n );\n }, [editor, $updateValue]);\n\n function handleChange(value: string) {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, value as ElementFormatType);\n }\n\n return (\n <ToolbarSelect\n shouldShowOnlyIcon\n options={options}\n value={value}\n onChange={handleChange}\n className={cn('w-[56px]!', className)}\n />\n );\n}\n","import { IconButton, type IconButtonProps } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nexport interface ToolbarButtonProps extends IconButtonProps {\n isActive?: boolean;\n}\n\nexport function ToolbarButton({\n className,\n children,\n isActive,\n isDisabled = false,\n ...rest\n}: ToolbarButtonProps) {\n return (\n <IconButton\n isActive={isActive}\n className={cn('border-none bg-transparent', className)}\n size=\"sm\"\n variant=\"tertiary\"\n isDisabled={isDisabled}\n {...rest}\n >\n {children}\n </IconButton>\n );\n}\n","import { AttachmentsIcon } from '@swisper.ai/icons';\n\nimport { useRichTextAreaEditor } from '../../rich-text-area/hooks';\nimport { ATTACH_FILE_COMMAND } from '../../rich-text-area/plugins/file-attachment-plugin';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function AttachmentButton(props: ToolbarButtonProps) {\n const editor = useRichTextAreaEditor();\n\n function handleClick() {\n editor.dispatchCommand(ATTACH_FILE_COMMAND, undefined);\n }\n\n return (\n <ToolbarButton\n data-testid=\"attachment-button\"\n aria-label=\"Add Attachment\"\n onClick={handleClick}\n {...props}\n >\n <AttachmentsIcon />\n </ToolbarButton>\n );\n}\n","import { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';\nimport { $isHeadingNode, $isQuoteNode } from '@lexical/rich-text';\nimport { $forEachSelectedTextNode, $isAtNodeEnd, $patchStyleText } from '@lexical/selection';\nimport { $isTableSelection } from '@lexical/table';\nimport { mergeRegister, $getNearestBlockElementAncestorOrThrow } from '@lexical/utils';\nimport type { PropertiesHyphenFallback } from 'csstype';\nimport InlineStyleParser from 'inline-style-parser';\nimport {\n $addUpdateTag,\n $caretRangeFromSelection,\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $getState,\n $isRangeSelection,\n $isTextNode,\n $setSelection,\n $setState,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n createState,\n type DOMConversionMap,\n type DOMExportOutput,\n type ElementNode,\n isDocumentFragment,\n isHTMLElement,\n type LexicalEditor,\n type LexicalNode,\n type RangeSelection,\n RootNode,\n SKIP_DOM_SELECTION_TAG,\n TextNode,\n type ValueOrUpdater,\n} from 'lexical';\n\n/**\n * Creates an object containing all the styles and their values provided in the CSS string.\n * @param css - The CSS string of styles and their values.\n * @returns The styleObject containing all the styles and their values.\n */\nexport function getStyleObjectFromRawCSS(css: string): StyleObject {\n let styleObject: undefined | Record<string, string>;\n for (const token of InlineStyleParser(css, { silent: true })) {\n if (token.type === 'declaration' && token.value) {\n styleObject = styleObject || {};\n styleObject[token.property] = token.value;\n }\n }\n return styleObject || NO_STYLE;\n}\n\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n\nexport type StyleObject = Prettify<{\n [K in keyof PropertiesHyphenFallback]?:\n | undefined\n // This is simplified to not deal with arrays or numbers.\n // This is an example after all!\n | Extract<PropertiesHyphenFallback[K], string>;\n}>;\n\nexport type StyleTuple = Exclude<\n {\n [K in keyof StyleObject]: [K, null | Exclude<StyleObject[K], undefined>];\n }[keyof StyleObject],\n undefined\n>;\n\nexport const NO_STYLE: StyleObject = Object.freeze({});\n\nfunction parse(v: unknown): StyleObject {\n return typeof v === 'string' ? getStyleObjectFromRawCSS(v) : NO_STYLE;\n}\n\nfunction unparse(style: StyleObject): string {\n const styles: string[] = [];\n for (const [k, v] of Object.entries(style)) {\n if (k && v) {\n styles.push(`${k}: ${v};`);\n }\n }\n return styles.sort().join(' ');\n}\n\nfunction isEqualValue(\n a: StyleObject[keyof StyleObject],\n b: StyleObject[keyof StyleObject],\n): boolean {\n return a === b || (!a && !b);\n}\n\nfunction isEqual(a: StyleObject, b: StyleObject): boolean {\n if (a === b) {\n return true;\n }\n for (const k in a) {\n if (!(k in b && isEqualValue(a[k as keyof StyleObject], b[k as keyof StyleObject]))) {\n return false;\n }\n }\n for (const k in b) {\n if (!(k in a)) {\n return false;\n }\n }\n return true;\n}\n\nexport const styleState = createState('style', {\n isEqual,\n parse,\n unparse,\n});\n\nexport function $getStyleProperty<Prop extends keyof StyleObject>(\n node: LexicalNode,\n prop: Prop,\n): undefined | StyleObject[Prop] {\n return $getStyleObject(node)[prop];\n}\n\nexport function getStyleObjectDirect(node: LexicalNode): StyleObject {\n return $getState(node, styleState, 'direct');\n}\n\nexport function $getStyleObject(node: LexicalNode): StyleObject {\n return $getState(node, styleState);\n}\n\nexport function $setStyleObject<T extends LexicalNode>(\n node: T,\n valueOrUpdater: ValueOrUpdater<StyleObject>,\n): T {\n return $setState(node, styleState, valueOrUpdater);\n}\n\nexport function $removeStyleProperty<T extends LexicalNode, Prop extends keyof StyleObject>(\n node: T,\n prop: Prop,\n): T {\n return $setStyleObject(node, (prevStyle) => {\n if (prop in prevStyle) {\n const { [prop]: _ignore, ...nextStyle } = prevStyle;\n return nextStyle;\n }\n return prevStyle;\n });\n}\n\nexport function $setStyleProperty<T extends LexicalNode, Prop extends keyof StyleObject>(\n node: T,\n prop: Prop,\n value: ValueOrUpdater<StyleObject[Prop]>,\n): T {\n return $setStyleObject(node, (prevStyle) => {\n const prevValue = prevStyle[prop];\n const nextValue = typeof value === 'function' ? value(prevValue) : value;\n return prevValue === nextValue ? prevStyle : { ...prevStyle, [prop]: nextValue };\n });\n}\n\nexport function applyStyle(element: HTMLElement, styleObject: StyleObject): void {\n for (const k_ in styleObject) {\n const k = k_ as keyof StyleObject;\n element.style.setProperty(k, styleObject[k] ?? null);\n }\n}\n\nexport function diffStyleObjects(prevStyles: StyleObject, nextStyles: StyleObject): StyleObject {\n let styleDiff: undefined | Record<string, string | undefined>;\n if (prevStyles !== nextStyles) {\n for (const k_ in nextStyles) {\n const k = k_ as keyof StyleObject;\n const nextV = nextStyles[k];\n const prevV = prevStyles[k];\n if (!isEqualValue(nextV, prevV)) {\n styleDiff = styleDiff || {};\n styleDiff[k] = nextV;\n }\n }\n for (const k in prevStyles) {\n if (!(k in nextStyles)) {\n styleDiff = styleDiff || {};\n styleDiff[k] = undefined;\n }\n }\n }\n return styleDiff || NO_STYLE;\n}\n\nexport function mergeStyleObjects(prevStyles: StyleObject, nextStyles: StyleObject): StyleObject {\n return prevStyles === NO_STYLE || prevStyles === nextStyles\n ? nextStyles\n : { ...prevStyles, ...nextStyles };\n}\n\nexport function styleObjectToArray(styleObject: StyleObject): StyleTuple[] {\n const entries: StyleTuple[] = [];\n for (const k_ in styleObject) {\n const k = k_ as keyof StyleObject;\n entries.push([k, styleObject[k] ?? null] as StyleTuple);\n }\n entries.sort(([a], [b]) => a.localeCompare(b));\n return entries;\n}\n\nexport const PATCH_TEXT_STYLE_COMMAND = createCommand<\n StyleObject | ((prevStyles: StyleObject) => StyleObject)\n>('PATCH_TEXT_STYLE_COMMAND');\n\nfunction $nodeHasStyle(node: LexicalNode): boolean {\n return !isEqual(NO_STYLE, $getStyleObject(node));\n}\n\nexport function $selectionHasStyle(): boolean {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const caretRange = $caretRangeFromSelection(selection);\n for (const slice of caretRange.getTextSlices()) {\n if (slice && $nodeHasStyle(slice.caret.origin)) {\n return true;\n }\n }\n for (const caret of caretRange.iterNodeCarets('root')) {\n if ($isTextNode(caret.origin) && $nodeHasStyle(caret.origin)) {\n return true;\n }\n }\n }\n return false;\n}\n\nexport function $patchSelectedTextStyle(\n styleObjectOrCallback: StyleObject | ((prevStyles: StyleObject) => StyleObject),\n): boolean {\n let selection = $getSelection();\n if (!selection) {\n const prevSelection = $getPreviousSelection();\n if (!prevSelection) {\n return false;\n }\n selection = prevSelection.clone();\n $setSelection(selection);\n }\n const styleCallback =\n typeof styleObjectOrCallback === 'function'\n ? styleObjectOrCallback\n : (prevStyles: StyleObject) => mergeStyleObjects(prevStyles, styleObjectOrCallback);\n if ($isRangeSelection(selection) && selection.isCollapsed()) {\n const node = selection.focus.getNode();\n if ($isTextNode(node)) {\n $setStyleObject(node, styleCallback);\n }\n } else {\n $forEachSelectedTextNode((node) => $setStyleObject(node, styleCallback));\n }\n return true;\n}\n\nconst PREV_STYLE_STATE = Symbol.for('styleState');\ninterface HTMLElementWithManagedStyle extends HTMLElement {\n // Store the last reconciled style object directly on the DOM\n // so we don't have to track the previous DOM\n // which can happen even when nodeMutation is 'updated'\n [PREV_STYLE_STATE]?: StyleObject;\n}\n\ninterface LexicalNodeWithUnknownStyle extends LexicalNode {\n // This property exists on all TextNode and ElementNode\n // and likely also some DecoratorNode by convention.\n // We use it as a heuristic to see if the style has likely\n // been overwritten to see if we should apply a diff\n // or all styles.\n __style?: unknown;\n}\n\nfunction styleStringChanged(\n node: LexicalNodeWithUnknownStyle,\n prevNode: LexicalNodeWithUnknownStyle,\n): boolean {\n return typeof node.__style === 'string' && prevNode.__style !== node.__style;\n}\n\nfunction getPreviousStyleObject(\n node: LexicalNode,\n prevNode: null | LexicalNode,\n dom: HTMLElementWithManagedStyle,\n): StyleObject {\n const prevStyleObject = dom[PREV_STYLE_STATE];\n return prevStyleObject && prevNode && !styleStringChanged(node, prevNode)\n ? prevStyleObject\n : NO_STYLE;\n}\n\n// This applies the style to the DOM of any node\nfunction makeStyleUpdateListener(editor: LexicalEditor): () => void {\n return mergeRegister(\n editor.registerMutationListener(RootNode, () => {\n // UpdateListener will only get the mutatedNodes payload when\n // at least one MutationListener is registered\n }),\n editor.registerUpdateListener((payload) => {\n const { prevEditorState, mutatedNodes } = payload;\n editor.getEditorState().read(\n () => {\n if (mutatedNodes) {\n for (const nodes of mutatedNodes.values()) {\n for (const [nodeKey, nodeMutation] of nodes) {\n if (nodeMutation === 'destroyed') {\n continue;\n }\n const node = $getNodeByKey(nodeKey);\n const dom: null | HTMLElementWithManagedStyle = editor.getElementByKey(nodeKey);\n if (!dom || !node) {\n return;\n }\n const prevNode = $getNodeByKey(nodeKey, prevEditorState);\n const prevStyleObject = getPreviousStyleObject(node, prevNode, dom);\n const nextStyleObject = $getStyleObject(node);\n dom[PREV_STYLE_STATE] = nextStyleObject;\n applyStyle(dom, diffStyleObjects(prevStyleObject, nextStyleObject));\n }\n }\n }\n },\n { editor },\n );\n }),\n );\n}\n\n// TODO https://github.com/facebook/lexical/issues/7259\n// there should be a better way to do this, this does not compose with other exportDOM overrides\nexport function $exportNodeStyle(editor: LexicalEditor, target: LexicalNode): DOMExportOutput {\n const output = target.exportDOM(editor);\n const style = $getStyleObject(target);\n if (style === NO_STYLE) {\n return output;\n }\n return {\n ...output,\n after: (generatedElement) => {\n const el = output.after ? output.after(generatedElement) : generatedElement;\n if (isHTMLElement(el)) {\n applyStyle(el, style);\n } else if (isDocumentFragment(el)) {\n // Work around a bug in the type\n return el;\n }\n return el;\n },\n };\n}\n\nconst IGNORE_STYLES = new Set<keyof StyleObject>([\n 'font-weight',\n 'text-decoration',\n 'font-style',\n 'vertical-align',\n]);\n\nexport type StyleMapping = (input: StyleObject) => StyleObject;\n\n// TODO there's no reasonable way to hook into importDOM/exportDOM from a plug-in https://github.com/facebook/lexical/issues/7259\nexport function constructStyleImportMap(\n styleMapping: StyleMapping = (input) => input,\n): DOMConversionMap {\n const importMap: DOMConversionMap = {};\n\n // Wrap all TextNode importers with a function that also imports\n // styles that are not otherwise imported\n for (const [tag, fn] of Object.entries(TextNode.importDOM() || {})) {\n importMap[tag] = (importNode) => {\n const importer = fn(importNode);\n if (!importer) {\n return null;\n }\n return {\n ...importer,\n conversion: (element) => {\n const output = importer.conversion(element);\n if (\n output?.forChild === undefined ||\n output.after !== undefined ||\n output.node !== null ||\n !element.hasAttribute('style')\n ) {\n return output;\n }\n let extraStyles: undefined | Record<string, string>;\n for (const k of element.style) {\n if (IGNORE_STYLES.has(k as keyof StyleObject)) {\n continue;\n }\n extraStyles = extraStyles || {};\n extraStyles[k] = element.style.getPropertyValue(k);\n }\n if (extraStyles) {\n const { forChild } = output;\n return {\n ...output,\n forChild: (child, parent) => {\n const node = forChild(child, parent);\n return $isTextNode(node)\n ? $setStyleObject(node, styleMapping(extraStyles as StyleObject))\n : node;\n },\n };\n }\n return output;\n },\n };\n };\n }\n return importMap;\n}\n\nexport function registerStyleState(editor: LexicalEditor): () => void {\n return mergeRegister(\n editor.registerCommand(\n PATCH_TEXT_STYLE_COMMAND,\n $patchSelectedTextStyle,\n COMMAND_PRIORITY_EDITOR,\n ),\n makeStyleUpdateListener(editor),\n );\n}\n\nexport function getSelectedNode(selection: RangeSelection): TextNode | ElementNode {\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = selection.anchor.getNode();\n const focusNode = selection.focus.getNode();\n if (anchorNode === focusNode) {\n return anchorNode;\n }\n const isBackward = selection.isBackward();\n if (isBackward) {\n return $isAtNodeEnd(focus) ? anchorNode : focusNode;\n } else {\n return $isAtNodeEnd(anchor) ? anchorNode : focusNode;\n }\n}\n\n/**\n * Patches the selection with the updated font size.\n */\nexport const updateFontSizeInSelection = (\n editor: LexicalEditor,\n newFontSize: string | null,\n _updateType: unknown,\n skipRefocus: boolean,\n) => {\n editor.update(() => {\n if (skipRefocus) {\n $addUpdateTag(SKIP_DOM_SELECTION_TAG);\n }\n if (editor.isEditable()) {\n const selection = $getSelection();\n if (selection !== null) {\n $patchStyleText(selection, {\n 'font-size': newFontSize + 'px',\n });\n }\n }\n });\n};\n\nexport function clearFormatting(editor: LexicalEditor, skipRefocus = false) {\n editor.update(() => {\n if (skipRefocus) {\n $addUpdateTag(SKIP_DOM_SELECTION_TAG);\n }\n const selection = $getSelection();\n if ($isRangeSelection(selection) || $isTableSelection(selection)) {\n const anchor = selection.anchor;\n const focus = selection.focus;\n const nodes = selection.getNodes();\n const extractedNodes = selection.extract();\n\n if (anchor.key === focus.key && anchor.offset === focus.offset) {\n return;\n }\n\n nodes.forEach((node, idx) => {\n // We split the first and last node by the selection\n // So that we don't format unselected text inside those nodes\n if ($isTextNode(node)) {\n // Use a separate variable to ensure TS does not lose the refinement\n let textNode = node;\n if (idx === 0 && anchor.offset !== 0) {\n textNode = textNode.splitText(anchor.offset)[1] || textNode;\n }\n if (idx === nodes.length - 1) {\n textNode = textNode.splitText(focus.offset)[0] || textNode;\n }\n /**\n * If the selected text has one format applied\n * selecting a portion of the text, could\n * clear the format to the wrong portion of the text.\n *\n * The cleared text is based on the length of the selected text.\n */\n // We need this in case the selected text only has one format\n const extractedTextNode = extractedNodes[0];\n if (nodes.length === 1 && $isTextNode(extractedTextNode)) {\n textNode = extractedTextNode;\n }\n\n if (textNode.__style !== '') {\n textNode.setStyle('');\n }\n if (textNode.__format !== 0) {\n textNode.setFormat(0);\n }\n const nearestBlockElement = $getNearestBlockElementAncestorOrThrow(textNode);\n if (nearestBlockElement.__format !== 0) {\n nearestBlockElement.setFormat('');\n }\n if (nearestBlockElement.__indent !== 0) {\n nearestBlockElement.setIndent(0);\n }\n } else if ($isHeadingNode(node) || $isQuoteNode(node)) {\n node.replace($createParagraphNode(), true);\n } else if ($isDecoratorBlockNode(node)) {\n node.setFormat('');\n }\n });\n }\n });\n}\n","import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';\nimport { $getSelectionStyleValueForProperty, $patchStyleText } from '@lexical/selection';\nimport { mergeRegister } from '@lexical/utils';\nimport {\n $getSelection,\n $isRangeSelection,\n SELECTION_CHANGE_COMMAND,\n COMMAND_PRIORITY_LOW,\n FORMAT_TEXT_COMMAND,\n $addUpdateTag,\n SKIP_SELECTION_FOCUS_TAG,\n} from 'lexical';\nimport type { ReactNode } from 'react';\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\nimport { useRichTextAreaEditor } from '../rich-text-area/hooks';\n\nimport {\n type ALIGNMENT_OPTIONS,\n DEFAULT_FONT_FAMILY_VALUE,\n DEFAULT_FONT_SIZE,\n DEFAULT_TEXT_COLOR,\n} from './constants';\nimport { updateFontSizeInSelection, getSelectedNode } from './utils';\n\nexport type RichTextFieldAlignment = (typeof ALIGNMENT_OPTIONS)[number];\n\nexport interface RichTextFieldContextValue {\n fontFamily: string;\n fontSize: string;\n textColor: string;\n isBold: boolean;\n isItalic: boolean;\n isUnderline: boolean;\n isLink: boolean;\n onFontFamily: (value: string) => void;\n onFontSize: (value: string) => void;\n onTextColor: (value: string) => void;\n onBold: () => void;\n onItalic: () => void;\n onUnderline: () => void;\n onLink: () => void;\n}\n\nconst sanitizeUrl = (url: string) => {\n return url.startsWith('http') ? url : `https://${url}`;\n};\n\nexport const RichTextFieldContext = createContext<RichTextFieldContextValue>(null!);\n\nexport function useRichTextFieldContext() {\n const context = useContext(RichTextFieldContext);\n\n if (!context) {\n throw new Error('\"useRichTextFieldContext\" must be used within a RichTextFieldContextProvider');\n }\n\n return context;\n}\n\nexport interface RichTextFieldContextProviderProps {\n children: ReactNode;\n}\n\nfunction normalizeColorToHex(color: string): string {\n const trimmed = color.trim();\n\n // hex #rgb or #rrggbb\n const hexMatch = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(trimmed);\n if (hexMatch) {\n const value = hexMatch[1];\n if (value.length === 3) {\n const [r, g, b] = value;\n return `#${r}${r}${g}${g}${b}${b}`.toLowerCase();\n }\n return `#${value.toLowerCase()}`;\n }\n\n // rgb(...) or rgba(...)\n const rgbMatch = /^rgba?\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})/i.exec(trimmed);\n if (rgbMatch) {\n const clamp = (n: number) => Math.max(0, Math.min(255, n));\n const [r, g, b] = rgbMatch.slice(1, 4).map((v) => clamp(Number.parseInt(v, 10)));\n const toHex = (n: number) => n.toString(16).padStart(2, '0');\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n }\n\n return DEFAULT_TEXT_COLOR;\n}\n\nexport function RichTextFieldContextProvider({ children }: RichTextFieldContextProviderProps) {\n const editor = useRichTextAreaEditor();\n\n const [fontFamily, setFontFamily] = useState<string>(DEFAULT_FONT_FAMILY_VALUE);\n const [fontSize, setFontSize] = useState<string>(DEFAULT_FONT_SIZE);\n const [isBold, setIsBold] = useState(false);\n const [isItalic, setIsItalic] = useState(false);\n const [isUnderline, setIsUnderline] = useState(false);\n const [textColor, setTextColor] = useState<string>(DEFAULT_TEXT_COLOR);\n const [isLink, setIsLink] = useState(false);\n\n const $updateToolbar = useCallback(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n // font family\n setFontFamily(\n $getSelectionStyleValueForProperty(selection, 'font-family', DEFAULT_FONT_FAMILY_VALUE),\n );\n // font size\n const fontSize = $getSelectionStyleValueForProperty(\n selection,\n 'font-size',\n DEFAULT_FONT_SIZE + 'px',\n );\n setFontSize(fontSize ? fontSize.replace('px', '') : DEFAULT_FONT_SIZE);\n // bold\n setIsBold(selection.hasFormat('bold'));\n // italic\n setIsItalic(selection.hasFormat('italic'));\n // underline\n setIsUnderline(selection.hasFormat('underline'));\n // text-color\n const rawColor =\n $getSelectionStyleValueForProperty(selection, 'color', DEFAULT_TEXT_COLOR) ||\n DEFAULT_TEXT_COLOR;\n setTextColor(normalizeColorToHex(rawColor));\n // link\n const node = getSelectedNode(selection);\n const parent = node.getParent();\n const isLink = $isLinkNode(parent) || $isLinkNode(node);\n setIsLink(isLink);\n }\n }, []);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n $updateToolbar();\n });\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n $updateToolbar();\n return false;\n },\n COMMAND_PRIORITY_LOW,\n ),\n );\n }, [editor, $updateToolbar]);\n\n const onFontFamily = useCallback(\n (value: string) => {\n editor.update(() => {\n $addUpdateTag(SKIP_SELECTION_FOCUS_TAG);\n const selection = $getSelection();\n if (selection !== null) {\n $patchStyleText(selection, {\n ['font-family']: value,\n });\n }\n });\n },\n [editor],\n );\n\n const onFontSize = useCallback(\n (value: string) => {\n updateFontSizeInSelection(editor, value, null, false);\n },\n [editor],\n );\n\n const onBold = useCallback(() => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');\n }, [editor]);\n\n const onItalic = useCallback(() => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');\n }, [editor]);\n\n const onUnderline = useCallback(() => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline');\n }, [editor]);\n\n const onTextColor = useCallback(\n (value: string) => {\n editor.update(() => {\n $addUpdateTag(SKIP_SELECTION_FOCUS_TAG);\n const selection = $getSelection();\n if (selection !== null) {\n $patchStyleText(selection, {\n color: value,\n });\n }\n });\n },\n [editor],\n );\n\n const onLink = useCallback(() => {\n if (!isLink) {\n setIsLink(true);\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, sanitizeUrl('https://'));\n } else {\n setIsLink(false);\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);\n }\n }, [isLink, setIsLink]);\n\n const contextValue = useMemo<RichTextFieldContextValue>(\n () => ({\n fontFamily,\n fontSize,\n textColor,\n isBold,\n isItalic,\n isUnderline,\n isLink,\n onFontFamily,\n onFontSize,\n onTextColor,\n onBold,\n onItalic,\n onUnderline,\n onLink,\n }),\n [\n fontFamily,\n fontSize,\n textColor,\n isBold,\n isItalic,\n isUnderline,\n isLink,\n onFontFamily,\n onFontSize,\n onTextColor,\n onBold,\n onItalic,\n onUnderline,\n onLink,\n ],\n );\n\n return (\n <RichTextFieldContext.Provider value={contextValue}>{children}</RichTextFieldContext.Provider>\n );\n}\n","import { FormatBoldIcon } from '@swisper.ai/icons';\n\nimport { useRichTextFieldContext } from '../context';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function BoldButton({ ...props }: ToolbarButtonProps) {\n const { isBold, onBold } = useRichTextFieldContext();\n\n return (\n <ToolbarButton\n data-testid=\"bold-button\"\n aria-label=\"Format Bold\"\n isActive={isBold}\n onClick={onBold}\n {...props}\n >\n <FormatBoldIcon />\n </ToolbarButton>\n );\n}\n","import { $getNearestBlockElementAncestorOrThrow } from '@lexical/utils';\nimport { $getSelection, $isRangeSelection, $isTextNode } from 'lexical';\nimport { useCallback } from 'react';\n\nimport { FormatCleanIcon } from '@swisper.ai/icons';\n\nimport { useRichTextAreaEditor } from '../../rich-text-area/hooks';\nimport { $patchSelectedTextStyle, NO_STYLE } from '../utils';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function CleanFormatButton({ ...props }: ToolbarButtonProps) {\n const editor = useRichTextAreaEditor();\n\n const handleClick = useCallback(() => {\n editor.update(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n $patchSelectedTextStyle(() => NO_STYLE);\n\n for (const node of selection.extract()) {\n if ($isTextNode(node)) {\n node.setFormat(0);\n node.setStyle('');\n\n const blockElement = $getNearestBlockElementAncestorOrThrow(node);\n blockElement.setFormat('');\n }\n }\n }\n });\n }, [editor]);\n\n return (\n <ToolbarButton\n data-testid=\"clean-format-button\"\n aria-label=\"Reset Formatting\"\n onClick={handleClick}\n {...props}\n >\n <FormatCleanIcon />\n </ToolbarButton>\n );\n}\n","import { ImageIcon } from '@swisper.ai/icons';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function ImageButton({ ...props }: ToolbarButtonProps) {\n return (\n <ToolbarButton data-testid=\"image-button\" aria-label=\"Add Image\" {...props}>\n <ImageIcon />\n </ToolbarButton>\n );\n}\n","import { FormatItalicIcon } from '@swisper.ai/icons';\n\nimport { useRichTextFieldContext } from '../context';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function ItalicButton({ ...props }: ToolbarButtonProps) {\n const { isItalic, onItalic } = useRichTextFieldContext();\n\n return (\n <ToolbarButton\n data-testid=\"italic-button\"\n aria-label=\"Format Italics\"\n isActive={isItalic}\n onClick={onItalic}\n {...props}\n >\n <FormatItalicIcon />\n </ToolbarButton>\n );\n}\n","import { LinkOnIcon, LinkOffIcon } from '@swisper.ai/icons';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function LinkButton({ isActive, ...props }: ToolbarButtonProps) {\n return (\n <ToolbarButton data-testid=\"link-button\" aria-label=\"Add Link\" {...props}>\n {isActive ? <LinkOnIcon /> : <LinkOffIcon />}\n </ToolbarButton>\n );\n}\n","import { useMemo } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nimport { FONT_SIZE_OPTIONS } from '../constants';\nimport { useRichTextFieldContext } from '../context';\n\nimport { ToolbarSelect } from './toolbar-select';\n\nexport interface SizeSelectProps {\n className?: string;\n}\n\nexport function SizeSelect({ className }: SizeSelectProps) {\n const { fontSize, onFontSize } = useRichTextFieldContext();\n const options = useMemo(() => [...FONT_SIZE_OPTIONS], []);\n\n return (\n <ToolbarSelect\n data-testid=\"size-select\"\n options={options}\n value={fontSize}\n onChange={onFontSize}\n className={cn('w-[72px] gap-0', className)}\n />\n );\n}\n","import { type ChangeEvent } from 'react';\n\nimport { FormatColorIcon } from '@swisper.ai/icons';\n\nimport { DEFAULT_TEXT_COLOR } from '../constants';\nimport { useRichTextFieldContext } from '../context';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function TextColorButton({ ...props }: ToolbarButtonProps) {\n const { textColor, onTextColor } = useRichTextFieldContext();\n const isDefaultColor = textColor === DEFAULT_TEXT_COLOR;\n\n function handleColorChange(e: ChangeEvent<HTMLInputElement>) {\n onTextColor(e.target.value);\n }\n\n return (\n <div style={{ position: 'relative' }}>\n <ToolbarButton data-testid=\"text-color-button\" aria-label=\"Text Color\" {...props}>\n <span style={!isDefaultColor ? { color: textColor } : {}}>\n <FormatColorIcon />\n </span>\n </ToolbarButton>\n <input\n type=\"color\"\n value={textColor}\n onChange={handleColorChange}\n tabIndex={-1}\n style={{\n position: 'absolute',\n inset: 0,\n width: '100%',\n height: '100%',\n opacity: 0,\n cursor: 'pointer',\n }}\n />\n </div>\n );\n}\n","import { useMemo } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nimport { FONT_FAMILY_OPTIONS } from '../constants';\nimport { useRichTextFieldContext } from '../context';\n\nimport { ToolbarSelect } from './toolbar-select';\n\nexport interface TypographySelectProps {\n className?: string;\n}\n\nexport function TypographySelect({ className }: TypographySelectProps) {\n const { fontFamily, onFontFamily } = useRichTextFieldContext();\n const options = useMemo(() => [...FONT_FAMILY_OPTIONS], []);\n\n return (\n <ToolbarSelect\n data-testid=\"typography-select\"\n options={options}\n value={fontFamily}\n onChange={onFontFamily}\n className={cn('w-[90px]', className)}\n />\n );\n}\n","import { FormatUnderlineIcon } from '@swisper.ai/icons';\n\nimport { useRichTextFieldContext } from '../context';\n\nimport { ToolbarButton, type ToolbarButtonProps } from './toolbar-button';\n\nexport function UnderlineButton({ ...props }: ToolbarButtonProps) {\n const { isUnderline, onUnderline } = useRichTextFieldContext();\n\n return (\n <ToolbarButton\n data-testid=\"underline-button\"\n aria-label=\"Format Underline\"\n isActive={isUnderline}\n onClick={onUnderline}\n {...props}\n >\n <FormatUnderlineIcon />\n </ToolbarButton>\n );\n}\n","import type { ReactNode } from 'react';\n\nimport { Divider } from '@swisper.ai/ui';\nimport { cn } from '@swisper.ai/web-core';\n\nimport { AlignmentSelect } from './alignment-select';\nimport { AttachmentButton } from './attachment-button';\nimport { BoldButton } from './bold-button';\nimport { CleanFormatButton } from './clean-format-button';\nimport { ImageButton } from './image-button';\nimport { ItalicButton } from './italic-button';\nimport { LinkButton } from './link-button';\nimport { SizeSelect } from './size-select';\nimport { TextColorButton } from './text-color-button';\nimport { TypographySelect } from './typography-select';\nimport { UnderlineButton } from './underline-button';\n\ninterface FormattingToolbarPluginProps {\n className?: string;\n children?: ({ hasAttachments }: { hasAttachments: boolean }) => ReactNode;\n hasAttachments?: boolean;\n}\n\nconst DefaultFormattingToolbarChildren = ({ hasAttachments }: { hasAttachments: boolean }) => (\n <>\n <TypographySelect />\n <SizeSelect />\n\n <Divider orientation=\"vertical\" />\n\n <BoldButton />\n <ItalicButton />\n <UnderlineButton />\n <TextColorButton />\n\n <Divider orientation=\"vertical\" />\n <LinkButton isDisabled />\n <AttachmentButton isDisabled={!hasAttachments} />\n <ImageButton isDisabled />\n\n <Divider orientation=\"vertical\" />\n\n <AlignmentSelect />\n\n <Divider orientation=\"vertical\" />\n\n <CleanFormatButton />\n </>\n);\n\nexport function FormattingToolbarPlugin({\n className,\n children = DefaultFormattingToolbarChildren,\n hasAttachments = false,\n}: FormattingToolbarPluginProps) {\n return (\n <div\n data-testid=\"formatting-toolbar\"\n className={cn(\n 'flex items-center gap-[2px]',\n 'px-[16px] py-[8px] overflow-x-auto',\n 'bg-paper-elevation-1 border-b border-divider-border-base',\n className,\n )}\n >\n {children({ hasAttachments })}\n </div>\n );\n}\n","import { forwardRef, type ReactNode } from 'react';\n\nimport { cn } from '@swisper.ai/web-core';\n\nimport { RichTextArea, type RichTextAreaProps } from '../rich-text-area';\nimport { FileAttachmentPlugin } from '../rich-text-area/plugins/file-attachment-plugin';\n\nimport { FormattingToolbarPlugin } from './components/formatting-toolbar-plugin';\nimport { RichTextFieldContextProvider } from './context';\n\nexport type RichTextFieldToolbarPlacement = 'top' | 'bottom';\n\nexport interface RichTextFieldProps extends Omit<RichTextAreaProps, 'children'> {\n children?: ReactNode;\n toolbarPlacement?: RichTextFieldToolbarPlacement;\n toolbarClassName?: string;\n toolbarChildren?: ({ hasAttachments }: { hasAttachments: boolean }) => ReactNode;\n isMultipleAttachments?: boolean;\n enableAttachments?: boolean;\n acceptedFiles?: string[];\n onFileAttach?: (files: File[]) => void;\n}\n\nexport const RichTextField = forwardRef<HTMLInputElement, RichTextFieldProps>(\n (\n {\n children,\n className,\n placeholderClassName,\n containerClassName,\n toolbarPlacement = 'top',\n toolbarChildren,\n toolbarClassName,\n isMultipleAttachments,\n enableAttachments,\n acceptedFiles,\n onFileAttach,\n ...rest\n },\n ref,\n ) => {\n const isToolbarTop = toolbarPlacement === 'top';\n\n return (\n <RichTextArea\n ref={ref}\n data-testid=\"rich-text-field\"\n data-toolbar-placement={toolbarPlacement}\n placeholderClassName={cn(\n 'left-(--rich-text-field-editor-padding)',\n isToolbarTop\n ? 'top-[calc(var(--rich-text-field-toolbar-height)+var(--rich-text-field-editor-padding))]'\n : 'top-rich-text-field-editor-padding',\n placeholderClassName,\n )}\n containerClassName={cn(\n 'h-rich-text-field-height',\n 'rounded-rich-text-field-toolbar',\n isToolbarTop ? 'pt-rich-text-field-toolbar-height' : 'pb-rich-text-field-toolbar-height',\n containerClassName,\n )}\n className={cn(\n 'p-rich-text-field-editor-padding',\n 'bg-rich-text-field-background',\n 'size-full',\n className,\n )}\n {...rest}\n >\n <RichTextFieldContextProvider>\n <FormattingToolbarPlugin\n hasAttachments={enableAttachments}\n className={cn(\n 'absolute right-0 w-full',\n isToolbarTop ? 'top-0' : 'bottom-0',\n toolbarClassName,\n )}\n >\n {toolbarChildren}\n </FormattingToolbarPlugin>\n </RichTextFieldContextProvider>\n\n <FileAttachmentPlugin\n acceptedFiles={acceptedFiles}\n onFileAttach={onFileAttach}\n isMultiple={isMultipleAttachments}\n />\n </RichTextArea>\n );\n },\n);\n\nRichTextField.displayName = 'RichTextField';\n","import { DotLottieReact } from '@lottiefiles/dotlottie-react';\n\nimport { cn } from '@swisper.ai/web-core';\n\ntype Size = 'sm' | 'md' | 'lg' | 'xl';\n\nexport const SOURCE_ANIMATION =\n 'https://lottie.host/444a46a4-65b4-4483-b3a8-675160a79dad/LgQ8IVLAzA.lottie';\n\nexport interface SpinnerProps {\n size?: Size;\n autoplay?: boolean;\n}\n\nexport function Spinner({ size = 'md', autoplay = true }: SpinnerProps) {\n return (\n <span\n data-testid=\"spinner\"\n data-size={size}\n className={cn(\n 'pointer-events-none',\n 'inline-flex items-center justify-center',\n 'data-[size=sm]:size-16', // 16px\n 'data-[size=md]:size-24', // 24px\n 'data-[size=lg]:size-32', // 32px\n 'data-[size=xl]:size-[96px]', // 96px\n )}\n >\n <DotLottieReact src={SOURCE_ANIMATION} loop={autoplay} autoplay={autoplay} />\n </span>\n );\n}\n","export const CHAT_ACTION_PROTOCOL = 'swisper';\n","import remarkGfm from 'remark-gfm';\nimport remarkParse from 'remark-parse';\nimport { unified } from 'unified';\nimport { visit } from 'unist-util-visit';\n\nimport { CHAT_ACTION_PROTOCOL } from '../constants';\nimport type { ChatAction } from '../types';\n\ninterface LinkPhrasingChild {\n type: string;\n value?: string;\n}\n\nexport function createChatActionURL(action: string, params?: Record<string, string>): string {\n const url = `${CHAT_ACTION_PROTOCOL}://action/${action}`;\n\n if (!params) {\n return url;\n }\n\n const searchParams = new URLSearchParams(params);\n\n return `${url}?${searchParams.toString()}`;\n}\n\nexport function createChatActionLink({\n action,\n label,\n params,\n}: {\n action: string;\n label: string;\n params?: Record<string, string>;\n}): string {\n return `[${label}](${createChatActionURL(action, params)})`;\n}\n\nexport function isChatActionURL(uri: string | undefined): boolean {\n if (!uri?.startsWith(`${CHAT_ACTION_PROTOCOL}://`)) {\n return false;\n }\n\n const url = new URL(uri);\n\n return (\n url.protocol === CHAT_ACTION_PROTOCOL + ':' &&\n url.hostname === 'action' &&\n url.pathname.startsWith('/') &&\n url.pathname.split('/').length === 2\n );\n}\n\nexport function extractChatActionMetadataFromUrl(\n link: string,\n): Pick<ChatAction, 'option' | 'payload'> | null {\n let url;\n\n try {\n url = new URL(link);\n } catch (error) {\n return null;\n }\n\n if (!isChatActionURL(link)) {\n return null;\n }\n\n const option = url.pathname.replace('/', '');\n const payload = Object.fromEntries(url.searchParams.entries());\n\n return {\n option,\n payload,\n };\n}\n\nfunction extractLabelFromNode(children: LinkPhrasingChild[]): string | null {\n for (const child of children) {\n if (child.type === 'text' && typeof child.value === 'string') {\n return child.value;\n }\n }\n\n return null;\n}\n\nexport function extractChatActionFromLink(markdown: string) {\n const ast = unified().use(remarkParse).use(remarkGfm).parse(markdown);\n\n let action: ChatAction | null = null;\n visit(ast, (node) => {\n if (node.type !== 'link') {\n return;\n }\n\n const metadata = extractChatActionMetadataFromUrl(node.url);\n const label = extractLabelFromNode(node.children);\n\n if (metadata && label) {\n action = {\n label,\n option: metadata.option,\n payload: metadata.payload,\n raw: node.url,\n };\n\n return;\n }\n });\n\n return action;\n}\n","import { useMemo } from 'react';\n\nimport { type ChatAction } from '../types';\nimport { extractChatActionFromLink } from '../utils';\n\nexport function useChatActions(actions: string[]) {\n return useMemo<ChatAction[]>(() => {\n return actions\n .map((link) => {\n const action = extractChatActionFromLink(link);\n\n if (!action) {\n return {\n label: link,\n };\n }\n\n return action;\n })\n .filter((action): action is ChatAction => action !== null);\n }, [actions]);\n}\n","import { createParser, type EventSourceMessage } from 'eventsource-parser';\nimport { useCallback } from 'react';\n\nexport type ChatStreamTokenParser<ParsedToken = string> = (chunk: string) => ParsedToken | null;\n\nexport interface UseChatStreamMessageOptions<ParsedToken = string> {\n stream: ReadableStreamDefaultReader<Uint8Array>;\n abortController?: AbortController;\n timeout?: number;\n tokenParser?: ChatStreamTokenParser<ParsedToken>;\n onChunkReceived: (chunk: ParsedToken) => void;\n onAbort?: (error: Error) => void;\n onFinish?: (message: string) => void;\n onError?: (error: Error) => void;\n}\n\nfunction defaultTokenParser<ParsedToken>(data: string): ParsedToken {\n return JSON.parse(data) as ParsedToken;\n}\n\nfunction isAbortError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return error.name === 'AbortError' || error.name === 'TimeoutError';\n}\n\nfunction toError(value: unknown, fallbackMessage: string): Error {\n return value instanceof Error ? value : new Error(fallbackMessage);\n}\n\n/**\n * Process a chat message from a stream.\n *\n * @param stream - The stream to read from.\n * @param abortController - Optional abort controller to cancel the stream.\n * @param timeout - Optional idle timeout in ms; timer resets on each parsed chunk.\n * @param tokenParser - The function to parse the token.\n * @param onChunkReceived - The function to call when a chunk is received.\n * @param onAbort - Called once when the stream is cancelled (external abort, idle timeout, or reader cancellation).\n * @param onFinish - The function to call when the stream is finished.\n * @param onError - The function to call when an unexpected error occurs.\n *\n * @returns The function to process a chat message from a stream.\n *\n * @example\n * const { streamMessage } = useChatStreamMessage();\n * const stream = await streamMessage({\n * stream: readerStream,\n * timeout: 30_000,\n * onChunkReceived: (chunk) => {\n * console.log('chunk', chunk);\n * },\n * onAbort: (error) => {\n * console.log('stream aborted', error);\n * },\n * });\n */\nexport function useChatStreamMessage() {\n const streamMessage = useCallback(\n async <ParsedToken = string>({\n stream,\n abortController,\n timeout = 20_000, // 20 seconds\n tokenParser,\n onChunkReceived,\n onAbort,\n onFinish,\n onError,\n }: UseChatStreamMessageOptions<ParsedToken>) => {\n const parseToken = tokenParser ?? defaultTokenParser<ParsedToken>;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n let didHandleAbort = false;\n\n const clearStreamTimeout = () => {\n if (timeoutId !== undefined) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n };\n\n const handleAbort = (error: Error) => {\n if (didHandleAbort) {\n return;\n }\n\n didHandleAbort = true;\n clearStreamTimeout();\n onAbort?.(error);\n };\n\n const resetStreamTimeout = () => {\n if (timeout === undefined) {\n return;\n }\n\n clearStreamTimeout();\n timeoutId = setTimeout(() => {\n const error = new DOMException(\n `Stream timed out after ${timeout}ms of inactivity`,\n 'TimeoutError',\n );\n\n // abort will close the stream, so we don't need to cancel it\n abortController?.abort(error);\n\n if (!abortController) {\n handleAbort(error);\n }\n }, timeout);\n };\n\n try {\n let message = '';\n const decoder = new TextDecoder('utf-8');\n\n const parser = createParser({\n onEvent(event: EventSourceMessage) {\n try {\n message += event.data;\n const token = parseToken(event.data);\n\n if (!token) {\n throw new Error(`Failed to parse SSE chunk: ${event.data}`);\n }\n\n if (!abortController?.signal.aborted) {\n onChunkReceived(token);\n resetStreamTimeout();\n }\n } catch (e) {\n abortController?.abort(e);\n console.warn('Failed to parse SSE chunk:', event.data, e);\n }\n },\n onError(error) {\n abortController?.abort(error);\n console.error('Error while parsing stream:', error);\n },\n });\n\n abortController?.signal.addEventListener(\n 'abort',\n () => {\n const error = toError(abortController.signal.reason, 'Stream aborted');\n handleAbort(error);\n },\n {\n once: true,\n },\n );\n\n resetStreamTimeout();\n\n while (!didHandleAbort) {\n const { value, done } = await stream.read();\n const chunk = decoder.decode(value, { stream: true });\n parser.feed(chunk);\n if (done) break;\n }\n\n clearStreamTimeout();\n\n if (!didHandleAbort && !abortController?.signal.aborted) {\n onFinish?.(message);\n }\n } catch (e) {\n const error = e as Error;\n\n if (didHandleAbort || abortController?.signal.aborted || isAbortError(error)) {\n if (!didHandleAbort) {\n handleAbort(toError(error, 'Stream aborted'));\n }\n return;\n }\n\n abortController?.abort(error);\n console.error('Error while reading stream:', error);\n onError?.(error);\n }\n },\n [],\n );\n\n return {\n streamMessage,\n };\n}\n","import { useEffect, useRef } from 'react';\n\nimport { useChatContext } from '@/contexts';\nimport type { ChatId } from '@/types';\n\ntype UseOnChatChangedOptions = (options: {\n chatId: ChatId;\n prevChatId: ChatId;\n isNewChat: boolean;\n}) => void;\n\nexport function useOnChatChanged(onChatChanged: UseOnChatChangedOptions) {\n const { chatId, isNewChat } = useChatContext();\n\n const isNewChatRef = useRef(isNewChat);\n const prevChatIdRef = useRef(chatId);\n const chatChangedFn = useRef(onChatChanged);\n\n chatChangedFn.current = onChatChanged;\n isNewChatRef.current = isNewChat;\n\n useEffect(() => {\n if (prevChatIdRef.current !== chatId) {\n chatChangedFn.current({\n chatId,\n prevChatId: prevChatIdRef.current,\n isNewChat: isNewChatRef.current,\n });\n\n prevChatIdRef.current = chatId;\n }\n }, [chatId]);\n}\n","import { useChatContext } from '@/contexts';\n\nexport function useCurrentChatId() {\n const { chatId } = useChatContext();\n return chatId;\n}\n","import { useChatContext } from '@/contexts';\n\nexport function useIsCurrentChatNew() {\n const { isNewChat } = useChatContext();\n return isNewChat;\n}\n","import { useCallback } from 'react';\n\nimport { useChatContext } from '@/contexts';\nimport type { ChatId } from '@/types';\n\ninterface UseLoadedChatIdsOptions {\n getIsChatLoaded: (chatId: ChatId) => boolean;\n markAsLoaded: (chatId: ChatId) => void;\n markAsUnloaded: (chatId: ChatId) => void;\n}\n\nexport function useChatLoadedIds(): UseLoadedChatIdsOptions {\n const { loadedChatIdsRef } = useChatContext();\n\n const getIsChatLoaded = useCallback((chatId: ChatId) => {\n return loadedChatIdsRef.current?.has(chatId) ?? false;\n }, []);\n\n const markAsLoaded = useCallback((chatId: ChatId) => {\n loadedChatIdsRef.current?.add(chatId);\n }, []);\n\n const markAsUnloaded = useCallback((chatId: ChatId) => {\n loadedChatIdsRef.current?.delete(chatId);\n }, []);\n\n return {\n getIsChatLoaded,\n markAsLoaded,\n markAsUnloaded,\n };\n}\n","import { useChatContext } from '@/contexts';\n\nexport function useChatPromptPlaceholder() {\n const { promptPlaceholder, setPromptPlaceholder, clearPromptPlaceholder } = useChatContext();\n\n return { promptPlaceholder, setPromptPlaceholder, clearPromptPlaceholder };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAM+E,KAAwB,GAUxBC,KAA4BC,EAA8C,IAAK;AASrF,SAAgBC,KAA+B;CAC7C,IAAMC,IAAUC,EAAWJ,EAAyB;CAEpD,IAAI,CAACG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