@memori.ai/memori-react 8.45.2 → 8.45.4

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 (543) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/Chat/Chat.js +4 -1
  3. package/dist/components/Chat/Chat.js.map +1 -1
  4. package/dist/components/ChatHistoryDrawer/ChatResumeDrawer.d.ts +39 -0
  5. package/dist/components/ChatHistoryDrawer/ChatResumeDrawer.js +66 -0
  6. package/dist/components/ChatHistoryDrawer/ChatResumeDrawer.js.map +1 -0
  7. package/dist/components/DrawerFooter/DrawerFooter.d.ts +12 -0
  8. package/dist/components/DrawerFooter/DrawerFooter.js +10 -0
  9. package/dist/components/DrawerFooter/DrawerFooter.js.map +1 -0
  10. package/dist/components/IconButton/IconButton.d.ts +9 -0
  11. package/dist/components/IconButton/IconButton.js +36 -0
  12. package/dist/components/IconButton/IconButton.js.map +1 -0
  13. package/dist/components/MemoriWidget/MemoriWidget.d.ts +1 -1
  14. package/dist/components/MemoriWidget/MemoriWidget.js +2 -1
  15. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  16. package/dist/components/MobileSessionPanel/MobileSessionPanel.d.ts +65 -0
  17. package/dist/components/MobileSessionPanel/MobileSessionPanel.js +294 -0
  18. package/dist/components/MobileSessionPanel/MobileSessionPanel.js.map +1 -0
  19. package/dist/components/PositionPopover/PositionPopover.d.ts +22 -0
  20. package/dist/components/PositionPopover/PositionPopover.js +208 -0
  21. package/dist/components/PositionPopover/PositionPopover.js.map +1 -0
  22. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.d.ts +4 -0
  23. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js +64 -0
  24. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -0
  25. package/dist/components/layouts/chat.css +27 -4
  26. package/dist/context/widgetSurfaceContext.d.ts +3 -0
  27. package/dist/context/widgetSurfaceContext.js +11 -0
  28. package/dist/context/widgetSurfaceContext.js.map +1 -0
  29. package/dist/helpers/positionPopover.d.ts +2 -0
  30. package/dist/helpers/positionPopover.js +16 -0
  31. package/dist/helpers/positionPopover.js.map +1 -0
  32. package/dist/helpers/tts/muteSpeaker.d.ts +13 -0
  33. package/dist/helpers/tts/muteSpeaker.js +27 -0
  34. package/dist/helpers/tts/muteSpeaker.js.map +1 -0
  35. package/dist/helpers/usePressTooltip.d.ts +13 -0
  36. package/dist/helpers/usePressTooltip.js +24 -0
  37. package/dist/helpers/usePressTooltip.js.map +1 -0
  38. package/dist/icons/FacebookIcon.d.ts +3 -0
  39. package/dist/icons/FacebookIcon.js +6 -0
  40. package/dist/icons/FacebookIcon.js.map +1 -0
  41. package/dist/icons/LinkedinIcon.d.ts +3 -0
  42. package/dist/icons/LinkedinIcon.js +6 -0
  43. package/dist/icons/LinkedinIcon.js.map +1 -0
  44. package/dist/icons/MemoriIcon.d.ts +3 -0
  45. package/dist/icons/MemoriIcon.js +8 -0
  46. package/dist/icons/MemoriIcon.js.map +1 -0
  47. package/dist/icons/TelegramIcon.d.ts +3 -0
  48. package/dist/icons/TelegramIcon.js +6 -0
  49. package/dist/icons/TelegramIcon.js.map +1 -0
  50. package/dist/icons/TwitterIcon.d.ts +3 -0
  51. package/dist/icons/TwitterIcon.js +6 -0
  52. package/dist/icons/TwitterIcon.js.map +1 -0
  53. package/dist/icons/WhatsappIcon.d.ts +3 -0
  54. package/dist/icons/WhatsappIcon.js +6 -0
  55. package/dist/icons/WhatsappIcon.js.map +1 -0
  56. package/dist/icons/artifacts/DocumentIcon.d.ts +3 -0
  57. package/dist/icons/artifacts/DocumentIcon.js +6 -0
  58. package/dist/icons/artifacts/DocumentIcon.js.map +1 -0
  59. package/dist/icons/artifacts/HtmlIcon.d.ts +3 -0
  60. package/dist/icons/artifacts/HtmlIcon.js +6 -0
  61. package/dist/icons/artifacts/HtmlIcon.js.map +1 -0
  62. package/dist/icons/artifacts/JavascriptIcon.d.ts +3 -0
  63. package/dist/icons/artifacts/JavascriptIcon.js +6 -0
  64. package/dist/icons/artifacts/JavascriptIcon.js.map +1 -0
  65. package/dist/icons/artifacts/MarkdownIcon.d.ts +3 -0
  66. package/dist/icons/artifacts/MarkdownIcon.js +6 -0
  67. package/dist/icons/artifacts/MarkdownIcon.js.map +1 -0
  68. package/dist/icons/artifacts/PythonIcon.d.ts +3 -0
  69. package/dist/icons/artifacts/PythonIcon.js +6 -0
  70. package/dist/icons/artifacts/PythonIcon.js.map +1 -0
  71. package/dist/icons/artifacts/SvgIcon.d.ts +3 -0
  72. package/dist/icons/artifacts/SvgIcon.js +6 -0
  73. package/dist/icons/artifacts/SvgIcon.js.map +1 -0
  74. package/dist/icons/artifacts/XmlIcon.d.ts +3 -0
  75. package/dist/icons/artifacts/XmlIcon.js +6 -0
  76. package/dist/icons/artifacts/XmlIcon.js.map +1 -0
  77. package/dist/icons/artifacts/cssIcon.d.ts +3 -0
  78. package/dist/icons/artifacts/cssIcon.js +6 -0
  79. package/dist/icons/artifacts/cssIcon.js.map +1 -0
  80. package/dist/styles.css +1 -2
  81. package/dist/version.d.ts +1 -1
  82. package/dist/version.js +1 -1
  83. package/esm/components/Chat/Chat.js +4 -1
  84. package/esm/components/Chat/Chat.js.map +1 -1
  85. package/esm/components/MemoriWidget/MemoriWidget.d.ts +1 -1
  86. package/esm/components/MemoriWidget/MemoriWidget.js +2 -1
  87. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  88. package/esm/components/layouts/chat.css +27 -4
  89. package/esm/styles.css +1 -2
  90. package/esm/version.d.ts +1 -1
  91. package/esm/version.js +1 -1
  92. package/package.json +6 -7
  93. package/dist/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.d.ts +0 -3
  94. package/dist/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js +0 -64
  95. package/dist/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js.map +0 -1
  96. package/esm/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.d.ts +0 -3
  97. package/esm/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js +0 -62
  98. package/esm/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.js.map +0 -1
  99. package/src/I18nWrapper.tsx +0 -13
  100. package/src/__snapshots__/index.test.tsx.snap +0 -96
  101. package/src/components/AgeVerificationModal/AgeVerificationModal.css +0 -95
  102. package/src/components/AgeVerificationModal/AgeVerificationModal.stories.tsx +0 -46
  103. package/src/components/AgeVerificationModal/AgeVerificationModal.test.tsx +0 -33
  104. package/src/components/AgeVerificationModal/AgeVerificationModal.tsx +0 -99
  105. package/src/components/AgeVerificationModal/__snapshots__/AgeVerificationModal.test.tsx.snap +0 -19
  106. package/src/components/Auth/Auth.css +0 -57
  107. package/src/components/Auth/Auth.stories.tsx +0 -90
  108. package/src/components/Auth/Auth.test.tsx +0 -63
  109. package/src/components/Auth/Auth.tsx +0 -201
  110. package/src/components/Auth/__snapshots__/Auth.test.tsx.snap +0 -143
  111. package/src/components/Avatar/Avatar.css +0 -151
  112. package/src/components/Avatar/Avatar.stories.tsx +0 -160
  113. package/src/components/Avatar/Avatar.test.tsx +0 -158
  114. package/src/components/Avatar/Avatar.tsx +0 -245
  115. package/src/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.tsx +0 -103
  116. package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +0 -105
  117. package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +0 -338
  118. package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/types.ts +0 -44
  119. package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.ts +0 -1091
  120. package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarPositionController.ts +0 -83
  121. package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.ts +0 -301
  122. package/src/components/Avatar/AvatarView/AvatarComponent/components/controls.tsx +0 -100
  123. package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +0 -152
  124. package/src/components/Avatar/AvatarView/AvatarComponent/components/loader.tsx +0 -31
  125. package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +0 -141
  126. package/src/components/Avatar/AvatarView/AvatarComponent/lights/Lights.tsx +0 -145
  127. package/src/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.css +0 -111
  128. package/src/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.tsx +0 -201
  129. package/src/components/Avatar/AvatarView/AvatarView.stories.tsx +0 -254
  130. package/src/components/Avatar/AvatarView/index.tsx +0 -194
  131. package/src/components/Avatar/AvatarView/utils/hideHands.ts +0 -11
  132. package/src/components/Avatar/AvatarView/utils/useEyeBlink.ts +0 -100
  133. package/src/components/Avatar/AvatarView/utils/useHeadMovement.ts +0 -72
  134. package/src/components/Avatar/AvatarView/utils/useLoadingMorphAnim.ts +0 -38
  135. package/src/components/Avatar/AvatarView/utils/useMouthAnimation.ts +0 -93
  136. package/src/components/Avatar/AvatarView/utils/useSmile.ts +0 -39
  137. package/src/components/Avatar/AvatarView/utils/utils.ts +0 -55
  138. package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +0 -246
  139. package/src/components/Blob/Blob.css +0 -286
  140. package/src/components/Blob/Blob.stories.tsx +0 -53
  141. package/src/components/Blob/Blob.test.tsx +0 -18
  142. package/src/components/Blob/Blob.tsx +0 -26
  143. package/src/components/Blob/__snapshots__/Blob.test.tsx.snap +0 -80
  144. package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.css +0 -40
  145. package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.stories.tsx +0 -58
  146. package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.test.tsx +0 -53
  147. package/src/components/BlockedMemoriBadge/BlockedMemoriBadge.tsx +0 -74
  148. package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +0 -181
  149. package/src/components/ChangeMode/ChangeMode.css +0 -22
  150. package/src/components/ChangeMode/ChangeMode.stories.tsx +0 -50
  151. package/src/components/ChangeMode/ChangeMode.test.tsx +0 -24
  152. package/src/components/ChangeMode/ChangeMode.tsx +0 -51
  153. package/src/components/ChangeMode/__snapshots__/ChangeMode.test.tsx.snap +0 -107
  154. package/src/components/Chat/Chat.css +0 -285
  155. package/src/components/Chat/Chat.stories.tsx +0 -1684
  156. package/src/components/Chat/Chat.test.tsx +0 -372
  157. package/src/components/Chat/Chat.tsx +0 -778
  158. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +0 -6816
  159. package/src/components/ChatBubble/ChatBubble.css +0 -430
  160. package/src/components/ChatBubble/ChatBubble.stories.tsx +0 -1192
  161. package/src/components/ChatBubble/ChatBubble.test.tsx +0 -481
  162. package/src/components/ChatBubble/ChatBubble.tsx +0 -776
  163. package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +0 -8734
  164. package/src/components/ChatHistoryDrawer/ChatHistory.css +0 -587
  165. package/src/components/ChatHistoryDrawer/ChatHistory.stories.tsx +0 -410
  166. package/src/components/ChatHistoryDrawer/ChatHistory.test.tsx +0 -107
  167. package/src/components/ChatHistoryDrawer/ChatHistory.tsx +0 -1298
  168. package/src/components/ChatHistoryDrawer/__snapshots__/ChatHistory.test.tsx.snap +0 -27
  169. package/src/components/ChatInputs/ChatInputs.css +0 -340
  170. package/src/components/ChatInputs/ChatInputs.stories.tsx +0 -251
  171. package/src/components/ChatInputs/ChatInputs.tsx +0 -487
  172. package/src/components/ChatTextArea/ChatTextArea.css +0 -185
  173. package/src/components/ChatTextArea/ChatTextArea.stories.tsx +0 -55
  174. package/src/components/ChatTextArea/ChatTextArea.test.tsx +0 -28
  175. package/src/components/ChatTextArea/ChatTextArea.tsx +0 -171
  176. package/src/components/ChatTextArea/__snapshots__/ChatTextArea.test.tsx.snap +0 -68
  177. package/src/components/CompletionProviderStatus/CompletionProviderStatus.css +0 -36
  178. package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +0 -296
  179. package/src/components/CompletionProviderStatus/CompletionProviderStatus.test.tsx +0 -31
  180. package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +0 -232
  181. package/src/components/CompletionProviderStatus/__snapshots__/CompletionProviderStatus.test.tsx.snap +0 -96
  182. package/src/components/ContentPreviewModal/ContentPreviewModal.css +0 -128
  183. package/src/components/ContentPreviewModal/ContentPreviewModal.tsx +0 -67
  184. package/src/components/ContentPreviewModal/index.ts +0 -2
  185. package/src/components/CustomGLBModelViewer/ModelViewer.css +0 -11
  186. package/src/components/CustomGLBModelViewer/ModelViewer.stories.tsx +0 -58
  187. package/src/components/CustomGLBModelViewer/ModelViewer.test.tsx +0 -13
  188. package/src/components/CustomGLBModelViewer/ModelViewer.tsx +0 -37
  189. package/src/components/CustomGLBModelViewer/__snapshots__/ModelViewer.test.tsx.snap +0 -20
  190. package/src/components/DateSelector/DateSelector.css +0 -158
  191. package/src/components/DateSelector/DateSelector.stories.tsx +0 -47
  192. package/src/components/DateSelector/DateSelector.test.tsx +0 -149
  193. package/src/components/DateSelector/DateSelector.tsx +0 -251
  194. package/src/components/DateSelector/__snapshots__/DateSelector.test.tsx.snap +0 -1954
  195. package/src/components/ErrorBoundary/ErrorBoundary.tsx +0 -54
  196. package/src/components/ExpertsDrawer/ExpertsDrawer.css +0 -67
  197. package/src/components/ExpertsDrawer/ExpertsDrawer.stories.tsx +0 -54
  198. package/src/components/ExpertsDrawer/ExpertsDrawer.test.tsx +0 -53
  199. package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +0 -69
  200. package/src/components/ExpertsDrawer/__snapshots__/ExpertsDrawer.test.tsx.snap +0 -11
  201. package/src/components/ExportHistoryButton/ExportHistoryButton.css +0 -22
  202. package/src/components/FeedbackButtons/FeedbackButtons.css +0 -107
  203. package/src/components/FeedbackButtons/FeedbackButtons.stories.tsx +0 -52
  204. package/src/components/FeedbackButtons/FeedbackButtons.test.tsx +0 -11
  205. package/src/components/FeedbackButtons/FeedbackButtons.tsx +0 -152
  206. package/src/components/FeedbackButtons/__snapshots__/FeedbackButtons.test.tsx.snap +0 -42
  207. package/src/components/FilePreview/FilePreview.css +0 -358
  208. package/src/components/FilePreview/FilePreview.stories.tsx +0 -63
  209. package/src/components/FilePreview/FilePreview.test.tsx +0 -26
  210. package/src/components/FilePreview/FilePreview.tsx +0 -277
  211. package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +0 -185
  212. package/src/components/Header/ChatConsumptionDropdown.test.tsx +0 -117
  213. package/src/components/Header/ChatConsumptionDropdown.tsx +0 -275
  214. package/src/components/Header/Header.css +0 -282
  215. package/src/components/Header/Header.stories.tsx +0 -338
  216. package/src/components/Header/Header.test.tsx +0 -371
  217. package/src/components/Header/Header.tsx +0 -442
  218. package/src/components/Header/__snapshots__/Header.test.tsx.snap +0 -964
  219. package/src/components/KnownFacts/KnownFacts.css +0 -19
  220. package/src/components/KnownFacts/KnownFacts.stories.tsx +0 -80
  221. package/src/components/KnownFacts/KnownFacts.test.tsx +0 -57
  222. package/src/components/KnownFacts/KnownFacts.tsx +0 -376
  223. package/src/components/KnownFacts/__snapshots__/KnownFacts.test.tsx.snap +0 -19
  224. package/src/components/LoginDrawer/LoginDrawer.css +0 -1616
  225. package/src/components/LoginDrawer/LoginDrawer.stories.tsx +0 -102
  226. package/src/components/LoginDrawer/LoginDrawer.test.tsx +0 -199
  227. package/src/components/LoginDrawer/LoginDrawer.tsx +0 -600
  228. package/src/components/LoginDrawer/__snapshots__/LoginDrawer.test.tsx.snap +0 -91
  229. package/src/components/MediaWidget/DocumentCard.test.tsx +0 -45
  230. package/src/components/MediaWidget/DocumentCard.tsx +0 -19
  231. package/src/components/MediaWidget/MediaItemWidget.css +0 -1398
  232. package/src/components/MediaWidget/MediaItemWidget.stories.tsx +0 -423
  233. package/src/components/MediaWidget/MediaItemWidget.test.tsx +0 -248
  234. package/src/components/MediaWidget/MediaItemWidget.tsx +0 -997
  235. package/src/components/MediaWidget/MediaItemWidget.types.ts +0 -65
  236. package/src/components/MediaWidget/MediaItemWidget.utils.test.ts +0 -367
  237. package/src/components/MediaWidget/MediaItemWidget.utils.ts +0 -227
  238. package/src/components/MediaWidget/MediaPreviewModal.test.tsx +0 -271
  239. package/src/components/MediaWidget/MediaPreviewModal.tsx +0 -425
  240. package/src/components/MediaWidget/MediaWidget.css +0 -131
  241. package/src/components/MediaWidget/MediaWidget.stories.tsx +0 -319
  242. package/src/components/MediaWidget/MediaWidget.test.tsx +0 -41
  243. package/src/components/MediaWidget/MediaWidget.tsx +0 -107
  244. package/src/components/MediaWidget/__snapshots__/DocumentCard.test.tsx.snap +0 -24
  245. package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +0 -791
  246. package/src/components/MediaWidget/__snapshots__/MediaWidget.test.tsx.snap +0 -154
  247. package/src/components/MemoriArtifactSystem/ArtifactDrawer.stories.tsx +0 -2299
  248. package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +0 -163
  249. package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.tsx +0 -250
  250. package/src/components/MemoriArtifactSystem/components/ArtifactActions/CopyButton.stories.tsx +0 -30
  251. package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.tsx +0 -467
  252. package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.tsx +0 -89
  253. package/src/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.ts +0 -619
  254. package/src/components/MemoriArtifactSystem/components/ArtifactActions/index.ts +0 -9
  255. package/src/components/MemoriArtifactSystem/components/ArtifactActions/styles.css +0 -489
  256. package/src/components/MemoriArtifactSystem/components/ArtifactActions/test/CopyButtonTest.tsx +0 -90
  257. package/src/components/MemoriArtifactSystem/components/ArtifactActions/types.ts +0 -73
  258. package/src/components/MemoriArtifactSystem/components/ArtifactActions/utils/PDFExporter.ts +0 -454
  259. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +0 -1059
  260. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +0 -431
  261. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.css +0 -150
  262. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.tsx +0 -79
  263. package/src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +0 -253
  264. package/src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.tsx +0 -561
  265. package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +0 -355
  266. package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.tsx +0 -160
  267. package/src/components/MemoriArtifactSystem/context/ArtifactContext.tsx +0 -167
  268. package/src/components/MemoriArtifactSystem/types/artifact.types.ts +0 -35
  269. package/src/components/MemoriArtifactSystem/utils/ArtifactAPI.test.tsx +0 -308
  270. package/src/components/MemoriArtifactSystem/utils/ArtifactAPI.tsx +0 -379
  271. package/src/components/MemoriArtifactSystem/utils/applyEdits.test.ts +0 -85
  272. package/src/components/MemoriArtifactSystem/utils/applyEdits.ts +0 -173
  273. package/src/components/MemoriWidget/MemoriWidget.css +0 -220
  274. package/src/components/MemoriWidget/MemoriWidget.stories.tsx +0 -274
  275. package/src/components/MemoriWidget/MemoriWidget.tsx +0 -3930
  276. package/src/components/MicrophoneButton/MicrophoneButton.css +0 -142
  277. package/src/components/MicrophoneButton/MicrophoneButton.stories.tsx +0 -52
  278. package/src/components/MicrophoneButton/MicrophoneButton.tsx +0 -128
  279. package/src/components/PositionDrawer/PositionDrawer.stories.tsx +0 -51
  280. package/src/components/PositionDrawer/PositionDrawer.test.tsx +0 -39
  281. package/src/components/PositionDrawer/PositionDrawer.tsx +0 -50
  282. package/src/components/PositionDrawer/__snapshots__/PositionDrawer.test.tsx.snap +0 -17
  283. package/src/components/PoweredBy/PoweredBy.css +0 -47
  284. package/src/components/PoweredBy/PoweredBy.stories.tsx +0 -75
  285. package/src/components/PoweredBy/PoweredBy.test.tsx +0 -15
  286. package/src/components/PoweredBy/PoweredBy.tsx +0 -44
  287. package/src/components/PoweredBy/__snapshots__/PoweredBy.test.tsx.snap +0 -55
  288. package/src/components/SendOnEnterMenu/SendOnEnterMenu.css +0 -47
  289. package/src/components/SendOnEnterMenu/SendOnEnterMenu.stories.tsx +0 -58
  290. package/src/components/SendOnEnterMenu/SendOnEnterMenu.test.tsx +0 -17
  291. package/src/components/SendOnEnterMenu/SendOnEnterMenu.tsx +0 -82
  292. package/src/components/SendOnEnterMenu/__snapshots__/SendOnEnterMenu.test.tsx.snap +0 -57
  293. package/src/components/SettingsDrawer/SettingsDrawer.css +0 -24
  294. package/src/components/SettingsDrawer/SettingsDrawer.stories.tsx +0 -94
  295. package/src/components/SettingsDrawer/SettingsDrawer.test.tsx +0 -202
  296. package/src/components/SettingsDrawer/SettingsDrawer.tsx +0 -255
  297. package/src/components/SettingsDrawer/__snapshots__/SettingsDrawer.test.tsx.snap +0 -59
  298. package/src/components/ShareButton/ShareButton.css +0 -73
  299. package/src/components/ShareButton/ShareButton.stories.tsx +0 -98
  300. package/src/components/ShareButton/ShareButton.test.tsx +0 -53
  301. package/src/components/ShareButton/ShareButton.tsx +0 -395
  302. package/src/components/ShareButton/__snapshots__/ShareButton.test.tsx.snap +0 -316
  303. package/src/components/Snippet/Snippet.css +0 -142
  304. package/src/components/Snippet/Snippet.stories.tsx +0 -286
  305. package/src/components/Snippet/Snippet.test.tsx +0 -176
  306. package/src/components/Snippet/Snippet.tsx +0 -148
  307. package/src/components/Snippet/__snapshots__/Snippet.test.tsx.snap +0 -603
  308. package/src/components/StartPanel/StartPanel.css +0 -273
  309. package/src/components/StartPanel/StartPanel.stories.tsx +0 -404
  310. package/src/components/StartPanel/StartPanel.test.tsx +0 -360
  311. package/src/components/StartPanel/StartPanel.tsx +0 -426
  312. package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +0 -1986
  313. package/src/components/Typing/Typing.stories.tsx +0 -130
  314. package/src/components/Typing/Typing.test.tsx +0 -62
  315. package/src/components/Typing/Typing.tsx +0 -154
  316. package/src/components/Typing/__snapshots__/Typing.test.tsx.snap +0 -133
  317. package/src/components/UploadButton/UploadButton.css +0 -542
  318. package/src/components/UploadButton/UploadButton.stories.tsx +0 -376
  319. package/src/components/UploadButton/UploadButton.test.tsx +0 -11
  320. package/src/components/UploadButton/UploadButton.tsx +0 -688
  321. package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +0 -421
  322. package/src/components/UploadButton/UploadImages/UploadImages.tsx +0 -538
  323. package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +0 -165
  324. package/src/components/VenueWidget/VenueWidget.css +0 -163
  325. package/src/components/VenueWidget/VenueWidget.stories.tsx +0 -66
  326. package/src/components/VenueWidget/VenueWidget.test.tsx +0 -49
  327. package/src/components/VenueWidget/VenueWidget.tsx +0 -458
  328. package/src/components/VenueWidget/__snapshots__/VenueWidget.test.tsx.snap +0 -370
  329. package/src/components/WhyThisAnswer/WhyThisAnswer.css +0 -171
  330. package/src/components/WhyThisAnswer/WhyThisAnswer.stories.tsx +0 -285
  331. package/src/components/WhyThisAnswer/WhyThisAnswer.test.tsx +0 -245
  332. package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +0 -233
  333. package/src/components/WhyThisAnswer/__snapshots__/WhyThisAnswer.test.tsx.snap +0 -27
  334. package/src/components/icons/AI.tsx +0 -34
  335. package/src/components/icons/Alert.tsx +0 -31
  336. package/src/components/icons/ArrowUp.tsx +0 -28
  337. package/src/components/icons/Bug.tsx +0 -81
  338. package/src/components/icons/Chat.tsx +0 -30
  339. package/src/components/icons/ChevronDown.tsx +0 -26
  340. package/src/components/icons/ChevronLeft.tsx +0 -28
  341. package/src/components/icons/ChevronRight.tsx +0 -28
  342. package/src/components/icons/ChevronUp.tsx +0 -24
  343. package/src/components/icons/Clear.tsx +0 -23
  344. package/src/components/icons/Close.tsx +0 -30
  345. package/src/components/icons/Code.tsx +0 -24
  346. package/src/components/icons/Copy.tsx +0 -23
  347. package/src/components/icons/DeepThought.tsx +0 -38
  348. package/src/components/icons/Delete.tsx +0 -23
  349. package/src/components/icons/Document.tsx +0 -50
  350. package/src/components/icons/Download.tsx +0 -23
  351. package/src/components/icons/Edit.tsx +0 -17
  352. package/src/components/icons/Expand.tsx +0 -23
  353. package/src/components/icons/Eye.tsx +0 -17
  354. package/src/components/icons/EyeInvisible.tsx +0 -24
  355. package/src/components/icons/Facebook.tsx +0 -23
  356. package/src/components/icons/Feedback.tsx +0 -24
  357. package/src/components/icons/File.tsx +0 -17
  358. package/src/components/icons/FileExcel.tsx +0 -23
  359. package/src/components/icons/FilePdf.tsx +0 -23
  360. package/src/components/icons/FileWord.tsx +0 -23
  361. package/src/components/icons/Fullscreen.tsx +0 -23
  362. package/src/components/icons/FullscreenExit.tsx +0 -23
  363. package/src/components/icons/GasStation.tsx +0 -36
  364. package/src/components/icons/Group.tsx +0 -30
  365. package/src/components/icons/History.tsx +0 -33
  366. package/src/components/icons/Image.tsx +0 -37
  367. package/src/components/icons/Info.tsx +0 -31
  368. package/src/components/icons/Link.tsx +0 -17
  369. package/src/components/icons/Linkedin.tsx +0 -23
  370. package/src/components/icons/Loading.tsx +0 -28
  371. package/src/components/icons/Logout.tsx +0 -27
  372. package/src/components/icons/Mail.tsx +0 -17
  373. package/src/components/icons/MapMarker.tsx +0 -26
  374. package/src/components/icons/MenuHorizontal.tsx +0 -29
  375. package/src/components/icons/MenuVertical.tsx +0 -29
  376. package/src/components/icons/Message.tsx +0 -23
  377. package/src/components/icons/Microphone.tsx +0 -23
  378. package/src/components/icons/Minus.tsx +0 -23
  379. package/src/components/icons/MinusCircle.tsx +0 -24
  380. package/src/components/icons/PaperClip.tsx +0 -23
  381. package/src/components/icons/Picture.tsx +0 -23
  382. package/src/components/icons/Plus.tsx +0 -18
  383. package/src/components/icons/Preview.tsx +0 -29
  384. package/src/components/icons/Print.tsx +0 -38
  385. package/src/components/icons/QuestionHelp.tsx +0 -30
  386. package/src/components/icons/Refresh.tsx +0 -30
  387. package/src/components/icons/SelectIcon.tsx +0 -28
  388. package/src/components/icons/Send.tsx +0 -17
  389. package/src/components/icons/Setting.tsx +0 -23
  390. package/src/components/icons/Share.tsx +0 -23
  391. package/src/components/icons/Sound.tsx +0 -23
  392. package/src/components/icons/SoundDeactivated.tsx +0 -27
  393. package/src/components/icons/Telegram.tsx +0 -26
  394. package/src/components/icons/ThumbDown.tsx +0 -29
  395. package/src/components/icons/ThumbUp.tsx +0 -29
  396. package/src/components/icons/Translation.tsx +0 -24
  397. package/src/components/icons/Twitter.tsx +0 -23
  398. package/src/components/icons/Upload.tsx +0 -34
  399. package/src/components/icons/User.tsx +0 -17
  400. package/src/components/icons/Warning.tsx +0 -24
  401. package/src/components/icons/WhatsApp.tsx +0 -24
  402. package/src/components/icons/icons.stories.css +0 -5
  403. package/src/components/icons/icons.stories.tsx +0 -81
  404. package/src/components/icons/loading.css +0 -14
  405. package/src/components/layouts/Chat.test.tsx +0 -40
  406. package/src/components/layouts/Chat.tsx +0 -69
  407. package/src/components/layouts/FullBody/FullBody.stories.tsx +0 -110
  408. package/src/components/layouts/FullPage.test.tsx +0 -65
  409. package/src/components/layouts/FullPage.tsx +0 -80
  410. package/src/components/layouts/HiddenChat.test.tsx +0 -40
  411. package/src/components/layouts/HiddenChat.tsx +0 -233
  412. package/src/components/layouts/Totem/Totem.stories.tsx +0 -131
  413. package/src/components/layouts/Totem.test.tsx +0 -40
  414. package/src/components/layouts/Totem.tsx +0 -49
  415. package/src/components/layouts/WebsiteAssistant.test.tsx +0 -40
  416. package/src/components/layouts/WebsiteAssistant.tsx +0 -132
  417. package/src/components/layouts/ZoomedFullBody/ZoomedFullBody.stories.tsx +0 -131
  418. package/src/components/layouts/ZoomedFullBody.test.tsx +0 -40
  419. package/src/components/layouts/ZoomedFullBody.tsx +0 -81
  420. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +0 -457
  421. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +0 -1045
  422. package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +0 -460
  423. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +0 -566
  424. package/src/components/layouts/__snapshots__/WebsiteAssistant.test.tsx.snap +0 -59
  425. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +0 -523
  426. package/src/components/layouts/chat.css +0 -451
  427. package/src/components/layouts/hidden-chat.css +0 -276
  428. package/src/components/layouts/layouts.stories.tsx +0 -231
  429. package/src/components/layouts/totem.css +0 -221
  430. package/src/components/layouts/website-assistant.css +0 -677
  431. package/src/components/layouts/zoomed-full-body.css +0 -18
  432. package/src/components/ui/Alert.css +0 -93
  433. package/src/components/ui/Alert.stories.tsx +0 -137
  434. package/src/components/ui/Alert.test.tsx +0 -129
  435. package/src/components/ui/Alert.tsx +0 -123
  436. package/src/components/ui/Button.css +0 -167
  437. package/src/components/ui/Button.stories.tsx +0 -156
  438. package/src/components/ui/Button.test.tsx +0 -74
  439. package/src/components/ui/Button.tsx +0 -107
  440. package/src/components/ui/Card.css +0 -65
  441. package/src/components/ui/Card.stories.tsx +0 -95
  442. package/src/components/ui/Card.test.tsx +0 -47
  443. package/src/components/ui/Card.tsx +0 -48
  444. package/src/components/ui/Checkbox.css +0 -116
  445. package/src/components/ui/Checkbox.stories.tsx +0 -74
  446. package/src/components/ui/Checkbox.test.tsx +0 -28
  447. package/src/components/ui/Checkbox.tsx +0 -58
  448. package/src/components/ui/ConfirmDialog.css +0 -42
  449. package/src/components/ui/ConfirmDialog.stories.tsx +0 -216
  450. package/src/components/ui/ConfirmDialog.test.tsx +0 -124
  451. package/src/components/ui/ConfirmDialog.tsx +0 -58
  452. package/src/components/ui/Details.css +0 -66
  453. package/src/components/ui/Drawer.css +0 -270
  454. package/src/components/ui/Drawer.stories.tsx +0 -267
  455. package/src/components/ui/Drawer.test.tsx +0 -130
  456. package/src/components/ui/Drawer.tsx +0 -293
  457. package/src/components/ui/Dropdown.css +0 -173
  458. package/src/components/ui/Dropdown.tsx +0 -63
  459. package/src/components/ui/Expandable.css +0 -15
  460. package/src/components/ui/Expandable.stories.tsx +0 -180
  461. package/src/components/ui/Expandable.test.tsx +0 -107
  462. package/src/components/ui/Expandable.tsx +0 -121
  463. package/src/components/ui/Modal.css +0 -98
  464. package/src/components/ui/Modal.stories.tsx +0 -171
  465. package/src/components/ui/Modal.test.tsx +0 -111
  466. package/src/components/ui/Modal.tsx +0 -117
  467. package/src/components/ui/Select.css +0 -138
  468. package/src/components/ui/Select.stories.tsx +0 -79
  469. package/src/components/ui/Select.test.tsx +0 -84
  470. package/src/components/ui/Select.tsx +0 -79
  471. package/src/components/ui/Slider.css +0 -192
  472. package/src/components/ui/Slider.stories.tsx +0 -63
  473. package/src/components/ui/Slider.tsx +0 -142
  474. package/src/components/ui/Spin.css +0 -31
  475. package/src/components/ui/Spin.stories.tsx +0 -64
  476. package/src/components/ui/Spin.test.tsx +0 -41
  477. package/src/components/ui/Spin.tsx +0 -31
  478. package/src/components/ui/Table.css +0 -132
  479. package/src/components/ui/Tooltip.css +0 -171
  480. package/src/components/ui/Tooltip.stories.tsx +0 -109
  481. package/src/components/ui/Tooltip.test.tsx +0 -102
  482. package/src/components/ui/Tooltip.tsx +0 -163
  483. package/src/components/ui/__snapshots__/Alert.test.tsx.snap +0 -59
  484. package/src/components/ui/__snapshots__/Button.test.tsx.snap +0 -204
  485. package/src/components/ui/__snapshots__/Card.test.tsx.snap +0 -321
  486. package/src/components/ui/__snapshots__/Checkbox.test.tsx.snap +0 -131
  487. package/src/components/ui/__snapshots__/ConfirmDialog.test.tsx.snap +0 -35
  488. package/src/components/ui/__snapshots__/Drawer.test.tsx.snap +0 -67
  489. package/src/components/ui/__snapshots__/Expandable.test.tsx.snap +0 -159
  490. package/src/components/ui/__snapshots__/Modal.test.tsx.snap +0 -59
  491. package/src/components/ui/__snapshots__/Select.test.tsx.snap +0 -254
  492. package/src/components/ui/__snapshots__/Spin.test.tsx.snap +0 -193
  493. package/src/components/ui/__snapshots__/Tooltip.test.tsx.snap +0 -113
  494. package/src/components/ui/definitions.stories.tsx +0 -139
  495. package/src/context/visemeContext.tsx +0 -384
  496. package/src/helpers/chatPdfExport.ts +0 -544
  497. package/src/helpers/configuration.ts +0 -42
  498. package/src/helpers/constants.ts +0 -268
  499. package/src/helpers/convertDocument.test.ts +0 -67
  500. package/src/helpers/convertDocument.ts +0 -35
  501. package/src/helpers/credits.ts +0 -54
  502. package/src/helpers/error.test.ts +0 -29
  503. package/src/helpers/error.ts +0 -278
  504. package/src/helpers/imageCompression.ts +0 -230
  505. package/src/helpers/llmUsage.ts +0 -328
  506. package/src/helpers/markedExtendedTables.js +0 -217
  507. package/src/helpers/media.test.ts +0 -169
  508. package/src/helpers/media.ts +0 -81
  509. package/src/helpers/message.test.ts +0 -126
  510. package/src/helpers/message.ts +0 -219
  511. package/src/helpers/nats/getNatsConfig.ts +0 -148
  512. package/src/helpers/nats/isSessionExpiredError.test.ts +0 -38
  513. package/src/helpers/nats/isSessionExpiredError.ts +0 -51
  514. package/src/helpers/nats/useNats.test.tsx +0 -81
  515. package/src/helpers/nats/useNats.ts +0 -204
  516. package/src/helpers/nats/useNatsSession.test.ts +0 -16
  517. package/src/helpers/nats/useNatsSession.ts +0 -460
  518. package/src/helpers/piiDetection.test.ts +0 -186
  519. package/src/helpers/piiDetection.ts +0 -91
  520. package/src/helpers/sanitizer.ts +0 -17
  521. package/src/helpers/statistics.ts +0 -58
  522. package/src/helpers/stt/useSTT.ts +0 -515
  523. package/src/helpers/translations.ts +0 -39
  524. package/src/helpers/tts/ttsVoiceUtility.ts +0 -275
  525. package/src/helpers/tts/useTTS.ts +0 -621
  526. package/src/helpers/utils.test.ts +0 -331
  527. package/src/helpers/utils.ts +0 -591
  528. package/src/helpers/venue.ts +0 -36
  529. package/src/i18n.ts +0 -39
  530. package/src/index.stories.tsx +0 -220
  531. package/src/index.test.tsx +0 -156
  532. package/src/index.tsx +0 -592
  533. package/src/locales/de.json +0 -680
  534. package/src/locales/en.json +0 -754
  535. package/src/locales/es.json +0 -682
  536. package/src/locales/fr.json +0 -682
  537. package/src/locales/it.json +0 -750
  538. package/src/mocks/data.ts +0 -790
  539. package/src/styles.css +0 -126
  540. package/src/types/integration.test.ts +0 -32
  541. package/src/types/integration.ts +0 -31
  542. package/src/types/layout.ts +0 -50
  543. package/src/version.ts +0 -2
@@ -1,1298 +0,0 @@
1
- import Drawer from '../ui/Drawer';
2
- import { useTranslation } from 'react-i18next';
3
- import memoriApiClient from '@memori.ai/memori-api-client';
4
- import React, {
5
- useEffect,
6
- useMemo,
7
- useState,
8
- useCallback,
9
- ChangeEvent,
10
- } from 'react';
11
- import {
12
- ChatLog,
13
- ChatLogLine,
14
- Memori,
15
- Medium,
16
- Message,
17
- ChatLogFilters,
18
- } from '@memori.ai/memori-api-client/dist/types';
19
- import Card from '../ui/Card';
20
- import Button from '../ui/Button';
21
- import ChatRound from '../icons/Chat';
22
- import { stripHTML } from '../../helpers/utils';
23
- import { stripAllInternalTags } from '../../helpers/message';
24
- import { Dialog } from '@headlessui/react';
25
- import debounce from 'lodash/debounce';
26
- import Spin from '../ui/Spin';
27
- import Chat from '../Chat/Chat';
28
- import Download from '../icons/Download';
29
- import MessageIcon from '../icons/Message';
30
- import ArrowUpIcon from '../icons/ArrowUp';
31
- import Select from '../ui/Select';
32
- import ChevronLeft from '../icons/ChevronLeft';
33
- // Helpers / Utils
34
- import { getTranslation } from '../../helpers/translations';
35
- import Close from '../icons/Close';
36
-
37
- export interface Props {
38
- open: boolean;
39
- onClose: () => void;
40
- apiClient: ReturnType<typeof memoriApiClient>;
41
- sessionId: string;
42
- memori: Memori;
43
- resumeSession: (chatLog: ChatLog) => void;
44
- baseUrl: string;
45
- apiUrl: string;
46
- history: Message[];
47
- loginToken?: string;
48
- language: string;
49
- userLang: string;
50
- isMultilanguageEnabled?: boolean;
51
- }
52
-
53
- const ITEMS_PER_PAGE = 8;
54
- const DEBOUNCE_DELAY = 300;
55
-
56
- // This function calculates the title of the chat log based on the most meaningful user message
57
- const calculateTitle = (lines: ChatLogLine[]): string => {
58
- const userMessages = lines.filter(line => line.inbound);
59
- if (userMessages.length === 0) return '';
60
-
61
- // Common non-significant phrases that shouldn't be used as titles (English and Italian)
62
- const insignificantPhrases = [
63
- // English phrases
64
- 'hello',
65
- 'hi',
66
- 'hey',
67
- 'good morning',
68
- 'good afternoon',
69
- 'good evening',
70
- 'thanks',
71
- 'thank you',
72
- 'thx',
73
- 'tnx',
74
- 'ty',
75
- 'thanks!',
76
- 'thank you!',
77
- 'ok',
78
- 'okay',
79
- 'k',
80
- 'yes',
81
- 'no',
82
- 'yep',
83
- 'nope',
84
- 'yeah',
85
- 'nah',
86
- 'good',
87
- 'great',
88
- 'nice',
89
- 'cool',
90
- 'awesome',
91
- 'perfect',
92
- 'excellent',
93
- 'bye',
94
- 'goodbye',
95
- 'see you',
96
- 'see ya',
97
- 'later',
98
- 'good night',
99
- 'how are you',
100
- 'how are you doing',
101
- "what's up",
102
- 'sup',
103
- 'please',
104
- 'pls',
105
- 'sorry',
106
- 'excuse me',
107
- 'pardon',
108
- 'i see',
109
- 'i understand',
110
- 'got it',
111
- 'gotcha',
112
- 'understood',
113
- 'continue',
114
- 'go on',
115
- 'tell me more',
116
- 'more',
117
- 'next',
118
- 'start',
119
- 'begin',
120
- "let's start",
121
- "let's begin",
122
- 'help',
123
- 'can you help',
124
- 'i need help',
125
- 'test',
126
- 'testing',
127
- 'test message',
128
- '?',
129
- '??',
130
- '???',
131
- '!',
132
- '!!',
133
- '!!!',
134
- '...',
135
- '..',
136
- '.',
137
- 'a',
138
- 'an',
139
- 'the',
140
- 'and',
141
- 'or',
142
- 'but',
143
- 'in',
144
- 'on',
145
- 'at',
146
- 'to',
147
- 'for',
148
- 'of',
149
- 'with',
150
- 'by',
151
-
152
- // Italian phrases
153
- 'ciao',
154
- 'salve',
155
- 'buongiorno',
156
- 'buonasera',
157
- 'buonanotte',
158
- 'grazie',
159
- 'grazie mille',
160
- 'grazie!',
161
- 'grazie mille!',
162
- 'thx',
163
- 'tnx',
164
- 'ok',
165
- 'va bene',
166
- 'va bene così',
167
- 'perfetto',
168
- 'ottimo',
169
- 'bene',
170
- 'sì',
171
- 'si',
172
- 'no',
173
- 'certo',
174
- 'certamente',
175
- 'assolutamente',
176
- 'arrivederci',
177
- 'a presto',
178
- 'a dopo',
179
- 'ci vediamo',
180
- 'addio',
181
- 'come stai',
182
- 'come va',
183
- 'tutto bene',
184
- 'che succede',
185
- 'per favore',
186
- 'per piacere',
187
- 'scusa',
188
- 'scusami',
189
- 'mi dispiace',
190
- 'capisco',
191
- 'ho capito',
192
- 'capito',
193
- 'perfetto',
194
- 'continua',
195
- 'vai avanti',
196
- 'dimmi di più',
197
- 'altro',
198
- 'altro ancora',
199
- 'inizia',
200
- 'iniziamo',
201
- 'comincia',
202
- 'cominciamo',
203
- 'aiuto',
204
- 'puoi aiutarmi',
205
- 'ho bisogno di aiuto',
206
- 'test',
207
- 'prova',
208
- 'messaggio di prova',
209
- '?',
210
- '??',
211
- '???',
212
- '!',
213
- '!!',
214
- '!!!',
215
- '...',
216
- '..',
217
- '.',
218
- 'un',
219
- 'una',
220
- 'il',
221
- 'la',
222
- 'gli',
223
- 'le',
224
- 'e',
225
- 'o',
226
- 'ma',
227
- 'in',
228
- 'su',
229
- 'a',
230
- 'per',
231
- 'di',
232
- 'con',
233
- 'da',
234
- ];
235
-
236
- // Function to calculate message significance score
237
- const calculateSignificanceScore = (message: string): number => {
238
- const cleanMessage = message.toLowerCase().trim();
239
-
240
- // Check if it's an insignificant phrase
241
- if (insignificantPhrases.includes(cleanMessage)) {
242
- return 0;
243
- }
244
-
245
- // Check if it's too short (less than 3 words)
246
- const wordCount = cleanMessage
247
- .split(/\s+/)
248
- .filter(word => word.length > 0).length;
249
- if (wordCount < 3) {
250
- return 0.1;
251
- }
252
-
253
- // Check if it's just punctuation or very short
254
- if (cleanMessage.length < 5) {
255
- return 0.1;
256
- }
257
-
258
- // Check if it's a question (questions are often more significant) - English and Italian
259
- const isQuestion =
260
- /\?$/.test(cleanMessage) ||
261
- // English question starters
262
- /^(what|how|why|when|where|who|which|can|could|would|will|do|does|did|is|are|was|were)/.test(
263
- cleanMessage
264
- ) ||
265
- // Italian question starters
266
- /^(cosa|come|perché|perche|quando|dove|chi|quale|quali|può|puo|potrebbe|vorrebbe|sarà|sara|fa|fai|fanno|è|e|sono|era|erano)/.test(
267
- cleanMessage
268
- );
269
-
270
- // Calculate base score
271
- let score = 0.5;
272
-
273
- // Boost score for questions
274
- if (isQuestion) score += 0.3;
275
-
276
- // Boost score for longer, more detailed messages
277
- if (wordCount > 5) score += 0.2;
278
- if (wordCount > 10) score += 0.2;
279
-
280
- // Reduce score for very long messages (might be too verbose for a title)
281
- if (wordCount > 20) score -= 0.1;
282
-
283
- // Boost score for messages with specific details (numbers, dates, names)
284
- if (/\d/.test(cleanMessage)) score += 0.1;
285
- if (
286
- /[A-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŸ][a-zàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ]+/.test(
287
- message
288
- )
289
- )
290
- score += 0.1; // Proper nouns (including accented characters)
291
-
292
- return Math.min(score, 1.0);
293
- };
294
-
295
- // Score all user messages
296
- const scoredMessages = userMessages.map((msg, index) => {
297
- const cleanText = stripHTML(stripAllInternalTags(msg.text || ''));
298
- const score = calculateSignificanceScore(cleanText);
299
- return {
300
- text: cleanText,
301
- score,
302
- index,
303
- originalIndex: index,
304
- };
305
- });
306
-
307
- // Sort by score (highest first) and then by position (earlier messages preferred for same score)
308
- scoredMessages.sort((a, b) => {
309
- if (Math.abs(a.score - b.score) < 0.1) {
310
- // If scores are close, prefer earlier messages
311
- return a.index - b.index;
312
- }
313
- return b.score - a.score;
314
- });
315
-
316
- // Find the best message
317
- let bestMessage = scoredMessages[0];
318
-
319
- // If the best message has a very low score, try to find a better one
320
- if (bestMessage.score < 0.3) {
321
- // Look for the first message that's not completely insignificant
322
- const betterMessage = scoredMessages.find(msg => msg.score > 0.1);
323
- if (betterMessage) {
324
- bestMessage = betterMessage;
325
- }
326
- }
327
-
328
- // If we still don't have a good message, try to create a title from multiple messages
329
- if (bestMessage.score < 0.2) {
330
- // Try to combine first few meaningful messages
331
- const meaningfulMessages = scoredMessages
332
- .filter(msg => msg.score > 0.1)
333
- .slice(0, 3)
334
- .sort((a, b) => a.index - b.index);
335
-
336
- if (meaningfulMessages.length > 1) {
337
- const combinedText = meaningfulMessages
338
- .map(msg => msg.text)
339
- .join(' - ')
340
- .substring(0, 80);
341
- return combinedText.length > 80 ? `${combinedText}...` : combinedText;
342
- }
343
- }
344
-
345
- // Format the final title
346
- const title = bestMessage.text;
347
- const maxLength = 100;
348
-
349
- if (title.length > maxLength) {
350
- // Try to cut at a word boundary
351
- const truncated = title.substring(0, maxLength);
352
- const lastSpace = truncated.lastIndexOf(' ');
353
- if (lastSpace > maxLength * 0.7) {
354
- // If we can cut at a word boundary without losing too much
355
- return `${truncated.substring(0, lastSpace)}...`;
356
- }
357
- return `${truncated}...`;
358
- }
359
-
360
- return title;
361
- };
362
-
363
- // Function to translate all chat logs lines
364
- const translateChatLogs = async (
365
- chatLogs: ChatLog[],
366
- fromLanguage: string,
367
- toLanguage: string,
368
- baseUrl: string
369
- ): Promise<ChatLog[]> => {
370
- try {
371
- const translatedChatLogs = await Promise.all(
372
- chatLogs.map(async chatLog => {
373
- const translatedLines = await Promise.all(
374
- chatLog.lines.map(async line => {
375
- if (!line.text) return line;
376
-
377
- try {
378
- const translation = await getTranslation(
379
- line.text,
380
- toLanguage,
381
- fromLanguage,
382
- baseUrl
383
- );
384
-
385
- return {
386
- ...line,
387
- originalText: line.text,
388
- text: translation.text,
389
- };
390
- } catch (e) {
391
- console.error('Error translating line:', e);
392
- return line; // Return original line if translation fails
393
- }
394
- })
395
- );
396
-
397
- return {
398
- ...chatLog,
399
- lines: translatedLines,
400
- };
401
- })
402
- );
403
-
404
- return translatedChatLogs;
405
- } catch (e) {
406
- console.error('Error translating chat logs:', e);
407
- return chatLogs; // Return original chat logs if translation fails
408
- }
409
- };
410
-
411
- const downloadFile = (text: string, filename: string) => {
412
- const data = new Blob([text], { type: 'text/plain' });
413
- const url = URL.createObjectURL(data);
414
- const element = document.createElement('a');
415
- element.setAttribute('href', url);
416
- element.setAttribute('download', filename);
417
- element.style.display = 'none';
418
-
419
- document.body.appendChild(element);
420
- element.click();
421
- document.body.removeChild(element);
422
- };
423
-
424
- const ChatHistoryDrawer = ({
425
- open,
426
- onClose,
427
- apiClient,
428
- sessionId,
429
- memori,
430
- resumeSession,
431
- baseUrl,
432
- apiUrl,
433
- history,
434
- loginToken,
435
- language,
436
- userLang,
437
- isMultilanguageEnabled = false,
438
- }: Props) => {
439
- const { t } = useTranslation();
440
- const { getUserChatLogsByTokenPaged } = apiClient.chatLogs;
441
-
442
- const textCurrentChat = `${t(
443
- 'write_and_speak.conversationStartedLabel'
444
- )} ${new Intl.DateTimeFormat('it', {
445
- dateStyle: 'short',
446
- timeStyle: 'short',
447
- }).format(new Date())}\n\n`.concat(
448
- history
449
- .map(m => `${m.fromUser ? 'YOU' : memori.name}: ${stripAllInternalTags(m.text)}`)
450
- .join('\n')
451
- );
452
- const [chatLogs, setChatLogs] = useState<ChatLog[]>([]);
453
- const [selectedChatLog, setSelectedChatLog] = useState<ChatLog | null>(null);
454
- const [currentPage, setCurrentPage] = useState(1);
455
- const [indexPage, setIndexPage] = useState(0);
456
- const [searchText, setSearchText] = useState('');
457
- const [isLoading, setIsLoading] = useState(false);
458
- const [error, setError] = useState<string | null>(null);
459
- const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');
460
- const [dateRange, setDateRange] = useState<
461
- 'today' | 'yesterday' | 'last_7_days' | 'last_30_days' | 'all'
462
- >('all');
463
- const [totalItems, setTotalItems] = useState(0);
464
- const [totalPages, setTotalPages] = useState(0);
465
- const [isMobile, setIsMobile] = useState(false);
466
- const [isViewingChatDetail, setIsViewingChatDetail] = useState(false);
467
-
468
- // New filter for minimum messages per chat
469
- const [minimumMessagesPerChat, setMinimumMessagesPerChat] =
470
- useState<number>(3);
471
-
472
- const [customMinimumMessages, setCustomMinimumMessages] = useState<number>(1);
473
-
474
- const formatDateForAPI = (date: Date) => {
475
- const year = date.getFullYear();
476
- const month = String(date.getMonth() + 1).padStart(2, '0');
477
- const day = String(date.getDate()).padStart(2, '0');
478
- const hours = String(date.getHours()).padStart(2, '0');
479
- const minutes = String(date.getMinutes()).padStart(2, '0');
480
- const seconds = String(date.getSeconds()).padStart(2, '0');
481
- const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
482
-
483
- return `${year}${month}${day}${hours}${minutes}${seconds}${milliseconds}`;
484
- };
485
-
486
- const formatDateRangeForAPI = (
487
- dateRange: 'today' | 'yesterday' | 'last_7_days' | 'last_30_days'
488
- ) => {
489
- if (dateRange === 'today') {
490
- const now = new Date();
491
- const yesterday = new Date(
492
- now.getFullYear(),
493
- now.getMonth(),
494
- now.getDate() - 1
495
- );
496
- const dateFrom = formatDateForAPI(yesterday);
497
- const dateTo = formatDateForAPI(now);
498
- return { dateFrom, dateTo };
499
- }
500
- if (dateRange === 'yesterday') {
501
- const now = new Date();
502
- const yesterday = new Date(
503
- now.getFullYear(),
504
- now.getMonth(),
505
- now.getDate() - 1
506
- );
507
- const dayBeforeYesterday = new Date(
508
- yesterday.getFullYear(),
509
- yesterday.getMonth(),
510
- yesterday.getDate() - 2
511
- );
512
- const dateFrom = formatDateForAPI(dayBeforeYesterday);
513
- const dateTo = formatDateForAPI(yesterday);
514
- return { dateFrom, dateTo };
515
- }
516
- if (dateRange === 'last_7_days') {
517
- const now = new Date();
518
- const sevenDaysAgo = new Date(
519
- now.getFullYear(),
520
- now.getMonth(),
521
- now.getDate() - 7
522
- );
523
- const dateFrom = formatDateForAPI(sevenDaysAgo);
524
- const dateTo = formatDateForAPI(now);
525
- return { dateFrom, dateTo };
526
- }
527
- if (dateRange === 'last_30_days') {
528
- const now = new Date();
529
- const thirtyDaysAgo = new Date(
530
- now.getFullYear(),
531
- now.getMonth(),
532
- now.getDate() - 30
533
- );
534
- const dateFrom = formatDateForAPI(thirtyDaysAgo);
535
- const dateTo = formatDateForAPI(now);
536
- return { dateFrom, dateTo };
537
- }
538
- };
539
-
540
- const fetchChatLogs = useCallback(
541
- async (
542
- dateRangeValue:
543
- | 'today'
544
- | 'yesterday'
545
- | 'last_7_days'
546
- | 'last_30_days'
547
- | 'all' = 'all'
548
- ) => {
549
- if (!loginToken) {
550
- setError(
551
- t('errorFetchingSession') ||
552
- 'Login token required to fetch chat history'
553
- );
554
- return;
555
- }
556
-
557
- // Calculate the index based on current page
558
- const calculatedIndex = ITEMS_PER_PAGE * (currentPage - 1);
559
- setIndexPage(calculatedIndex);
560
-
561
- setIsLoading(true);
562
- setError(null);
563
- let response;
564
- let filters: any = {
565
- loginToken: loginToken,
566
- memoriID: memori.engineMemoriID,
567
- dateFrom: undefined,
568
- dateTo: undefined,
569
- from: calculatedIndex,
570
- howMany: ITEMS_PER_PAGE,
571
- minimumMessagesPerChat:
572
- minimumMessagesPerChat === 0
573
- ? customMinimumMessages
574
- : minimumMessagesPerChat,
575
- };
576
- try {
577
- if (dateRangeValue === 'all') {
578
- response = await getUserChatLogsByTokenPaged(filters);
579
- } else {
580
- const { dateFrom, dateTo } =
581
- formatDateRangeForAPI(dateRangeValue) ?? {};
582
- response = await getUserChatLogsByTokenPaged({
583
- ...filters,
584
- dateFrom: dateFrom ?? undefined,
585
- dateTo: dateTo ?? undefined,
586
- });
587
- }
588
-
589
- const res = response;
590
-
591
- // Sort the chat logs by date
592
- let sortedChatLogs = res.chatLogs.sort((a: ChatLog, b: ChatLog) => {
593
- const dateA = Math.max(
594
- ...a.lines.map((l: any) => new Date(l.timestamp).getTime())
595
- );
596
- const dateB = Math.max(
597
- ...b.lines.map((l: any) => new Date(l.timestamp).getTime())
598
- );
599
- return sortOrder === 'desc' ? dateB - dateA : dateA - dateB;
600
- });
601
-
602
- // Translate chat logs if needed
603
- if (
604
- language.toUpperCase() !== userLang.toUpperCase() &&
605
- isMultilanguageEnabled
606
- ) {
607
- sortedChatLogs = await translateChatLogs(
608
- sortedChatLogs,
609
- language,
610
- userLang,
611
- baseUrl
612
- );
613
- }
614
-
615
- setChatLogs(sortedChatLogs);
616
- setTotalItems(res.count || sortedChatLogs.length);
617
- setTotalPages(
618
- Math.ceil((res.count || sortedChatLogs.length) / ITEMS_PER_PAGE)
619
- );
620
- } catch (err) {
621
- setError(t('errorFetchingSession') || 'Error loading chat history');
622
- console.error('Error fetching chat logs:', err);
623
- } finally {
624
- setIsLoading(false);
625
- }
626
- },
627
- [
628
- loginToken,
629
- memori.engineMemoriID,
630
- currentPage,
631
- sortOrder,
632
- apiUrl,
633
- minimumMessagesPerChat,
634
- customMinimumMessages,
635
- ]
636
- );
637
-
638
- // Mobile detection
639
- useEffect(() => {
640
- const checkMobile = () => {
641
- setIsMobile(window.innerWidth <= 768);
642
- };
643
-
644
- checkMobile();
645
- window.addEventListener('resize', checkMobile);
646
-
647
- return () => window.removeEventListener('resize', checkMobile);
648
- }, []);
649
-
650
- useEffect(() => {
651
- if (open) {
652
- setCurrentPage(1); // Reset to first page when opening
653
- setIndexPage(0); // Reset index to 0
654
- setIsViewingChatDetail(false); // Reset detail view when opening
655
- setSelectedChatLog(null); // Reset selected chat when opening
656
- }
657
- }, [open]);
658
-
659
- // Reset to first page when changing sort order, date range, or minimum messages filter
660
- useEffect(() => {
661
- if (open) {
662
- setCurrentPage(1);
663
- setIndexPage(0);
664
- }
665
- }, [sortOrder, dateRange, minimumMessagesPerChat, customMinimumMessages, open]);
666
-
667
- // Fetch chat logs when current page, date range, or minimum messages filter changes
668
- useEffect(() => {
669
- if (open && currentPage > 0) {
670
- fetchChatLogs(dateRange);
671
- }
672
- }, [currentPage, dateRange, minimumMessagesPerChat, customMinimumMessages, fetchChatLogs, open]);
673
-
674
- const debouncedSearch = useMemo(
675
- () => debounce((value: string) => setSearchText(value), DEBOUNCE_DELAY),
676
- []
677
- );
678
- // Remove client-side pagination since we're now using server-side pagination
679
- const paginatedChatLogs = chatLogs;
680
-
681
- const handleResumeChat = async () => {
682
- if (selectedChatLog) {
683
- resumeSession(selectedChatLog);
684
- onClose();
685
- }
686
- };
687
-
688
- const handleExportChat = (chatLog: ChatLog, e: React.MouseEvent) => {
689
- e.stopPropagation(); // Prevent the card from toggling
690
- const text = `${t(
691
- 'write_and_speak.conversationStartedLabel'
692
- )} ${new Intl.DateTimeFormat(navigator.language, {
693
- dateStyle: 'short',
694
- timeStyle: 'short',
695
- }).format(new Date())}\n\n`.concat(
696
- chatLog.lines
697
- .map(line => `${line.inbound ? 'YOU' : memori.name}: ${stripAllInternalTags(line.text)}`)
698
- .join('\n')
699
- );
700
-
701
- downloadFile(
702
- text,
703
- `${memori.name.replace(/\W+/g, '-')}-chat-${chatLog.chatLogID.substring(
704
- 0,
705
- 4
706
- )}.txt`
707
- );
708
- };
709
-
710
- const formatDate = (timestamp: string) => {
711
- return new Intl.DateTimeFormat(navigator.language, {
712
- dateStyle: 'medium',
713
- timeStyle: 'short',
714
- }).format(new Date(timestamp));
715
- };
716
-
717
- const escapeUnderScore = (value: string) => {
718
- return value.replace(/_/g, ' ');
719
- };
720
-
721
- const renderContent = () => {
722
- if (isLoading) {
723
- return (
724
- <div className="memori-chat-history-drawer--loading">
725
- <Spin
726
- spinning={true}
727
- primary={true}
728
- className="memori-chat-history-drawer--loading--spinner"
729
- />
730
- <p className="memori-chat-history-drawer--loading--text">
731
- {t('write_and_speak.loadingChatHistory') ||
732
- 'Loading chat history...'}
733
- </p>
734
- </div>
735
- );
736
- }
737
-
738
- if (error) {
739
- return (
740
- <div className="memori-chat-history-drawer--error">
741
- <p>{error}</p>
742
- </div>
743
- );
744
- }
745
-
746
- if (!chatLogs.length) {
747
- return (
748
- <div className="memori-chat-history-drawer--empty">
749
- <ChatRound className="memori-chat-history-drawer--empty--icon" />
750
- <p className="memori-chat-history-drawer--empty--text">
751
- {t('write_and_speak.noChatHistoryAvailable') ||
752
- 'No chat history available'}
753
- </p>
754
- </div>
755
- );
756
- }
757
-
758
- if (chatLogs.length === 0) {
759
- return (
760
- <div className="memori-chat-history-drawer--no-results">
761
- <p>
762
- {t('write_and_speak.noResultsFound', {
763
- searchText: searchText || '',
764
- }) || 'No results found'}
765
- </p>
766
- </div>
767
- );
768
- }
769
-
770
- return (
771
- <>
772
- <ul className="memori-chat-history-drawer--list">
773
- {paginatedChatLogs.map((chatLog: ChatLog) => {
774
- const lastMessageDate = Math.max(
775
- ...chatLog.lines.map(line => new Date(line.timestamp).getTime())
776
- );
777
-
778
- return (
779
- <Card
780
- hoverable={chatLog?.sessionID !== sessionId}
781
- onClick={async () => {
782
- // the active chat
783
- if (chatLog?.sessionID === sessionId) {
784
- return;
785
- }
786
- if (selectedChatLog?.chatLogID === chatLog.chatLogID) {
787
- setSelectedChatLog(null);
788
- if (isMobile) {
789
- setIsViewingChatDetail(false);
790
- }
791
- return;
792
- }
793
- setSelectedChatLog(chatLog);
794
- // if (isMobile) {
795
- setIsViewingChatDetail(true);
796
- // }
797
- }}
798
- key={chatLog.chatLogID}
799
- className={`memori-chat-history-drawer--card ${
800
- selectedChatLog?.chatLogID === chatLog.chatLogID
801
- ? 'memori-chat-history-drawer--card--selected'
802
- : ''
803
- } ${
804
- chatLog?.sessionID === sessionId
805
- ? 'memori-chat-history-drawer--card--disabled'
806
- : 'memori-chat-history-drawer--card--hoverable'
807
- }`}
808
- >
809
- <>
810
- <div className="memori-chat-history-drawer--card--header">
811
- <div className="memori-chat-history-drawer--card--header--content">
812
- <div className="memori-chat-history-drawer--card--header--info">
813
- <div className="memori-chat-history-drawer--card--header--title-wrapper">
814
- <Dialog.Title
815
- as="h3"
816
- className="memori-chat-history-drawer--card--header--title"
817
- >
818
- {calculateTitle(chatLog.lines) ||
819
- 'Chat-' + chatLog.chatLogID.substring(0, 4)}
820
- </Dialog.Title>
821
- {chatLog.boardOfExperts && (
822
- <div className="memori-chat-history-drawer--card--header--badge">
823
- BOE
824
- </div>
825
- )}
826
- </div>
827
- </div>
828
- </div>
829
- </div>
830
- <div className="memori-chat-history-drawer--card--header--meta">
831
- <time
832
- className="memori-chat-history-drawer--card--header--meta--time"
833
- dateTime={new Date(lastMessageDate).toISOString()}
834
- >
835
- {/* <svg
836
- className="memori-chat-history-drawer--card--header--meta--icon"
837
- fill="none"
838
- viewBox="0 0 24 24"
839
- stroke="currentColor"
840
- >
841
- <path
842
- strokeLinecap="round"
843
- strokeLinejoin="round"
844
- strokeWidth={2}
845
- d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
846
- />
847
- </svg> */}
848
- {formatDate(new Date(lastMessageDate).toISOString())}
849
- </time>
850
- {chatLog.lines.some(
851
- line =>
852
- line.media &&
853
- line.media.filter(
854
- m =>
855
- m.mimeType !== 'text/html' &&
856
- m.mimeType !== 'text/plain'
857
- ).length > 0
858
- ) && (
859
- <span className="memori-chat-history-drawer--card--header--meta--messages">
860
- <svg
861
- className="memori-chat-history-drawer--card--header--meta--icon"
862
- fill="none"
863
- viewBox="0 0 24 24"
864
- stroke="currentColor"
865
- >
866
- <path
867
- strokeLinecap="round"
868
- strokeLinejoin="round"
869
- strokeWidth={2}
870
- d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
871
- />
872
- </svg>
873
- {chatLog.lines.reduce(
874
- (acc, line) =>
875
- acc +
876
- (line.media?.filter(
877
- m =>
878
- m.mimeType !== 'text/html' &&
879
- m.mimeType !== 'text/plain'
880
- ).length || 0),
881
- 0
882
- )}
883
- </span>
884
- )}
885
- <span className="memori-chat-history-drawer--card--header--meta--messages">
886
- <svg
887
- className="memori-chat-history-drawer--card--header--meta--icon"
888
- fill="none"
889
- viewBox="0 0 24 24"
890
- stroke="currentColor"
891
- >
892
- <path
893
- strokeLinecap="round"
894
- strokeLinejoin="round"
895
- strokeWidth={2}
896
- d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"
897
- />
898
- </svg>
899
- {chatLog.lines.length}
900
- </span>
901
- {!isMobile && (
902
- <div className="memori-chat-history-drawer--card--content--header">
903
- <Button
904
- className="memori-chat-history-drawer--card--content--export-button"
905
- onClick={e => handleExportChat(chatLog, e)}
906
- disabled={chatLog?.sessionID === sessionId}
907
- >
908
- <div className="memori-chat-history-drawer--card--content--export-button--content">
909
- <Download className="memori-chat-history-drawer--card--content--export-button--icon" />
910
- {/* <span className="memori-chat-history-drawer--card--content--export-button--text">
911
- {t('write_and_speak.exportChat') || 'Export Chat'}
912
- </span> */}
913
- </div>
914
- </Button>
915
- </div>
916
- )}
917
- </div>
918
-
919
- {/* {selectedChatLog?.chatLogID === chatLog.chatLogID &&
920
- !isMobile && (
921
- <div className="memori-chat-history-drawer--card--content">
922
- <div className="memori-chat-history-drawer--card--content--messages">
923
- <Chat
924
- key={`${chatLog.chatLogID}-${chatLog.lines.length}`}
925
- baseUrl={baseUrl}
926
- apiUrl={apiUrl}
927
- memoriTyping={false}
928
- showTypingText={false}
929
- showAIicon={true}
930
- showTranslationOriginal={false}
931
- showWhyThisAnswer={false}
932
- showCopyButton={false}
933
- isChatlogPanel={true}
934
- showInputs={false}
935
- history={chatLog.lines.map(line => ({
936
- text: line.text, // Don't truncate to preserve document_attachment tags
937
- contextVars: line.contextVars,
938
- media: line.media as Medium[],
939
- fromUser: line.inbound,
940
- timestamp: line.timestamp,
941
- }))}
942
- memori={memori}
943
- sessionID={sessionId}
944
- pushMessage={() => {}}
945
- simulateUserPrompt={() => {}}
946
- setSendOnEnter={() => {}}
947
- attachmentsMenuOpen={undefined}
948
- setAttachmentsMenuOpen={() => {}}
949
- userMessage={''}
950
- onChangeUserMessage={() => {}}
951
- sendMessage={() => {}}
952
- startListening={() => {}}
953
- stopListening={() => {}}
954
- listening={false}
955
- setEnableFocusChatInput={() => {}}
956
- stopAudio={() => {}}
957
- isHistoryView={true}
958
- />
959
- </div>
960
- <div className="memori-chat-history-drawer--card--content--actions">
961
- <Button
962
- className="memori-chat-history-drawer--card--content--resume-button"
963
- primary
964
- onClick={handleResumeChat}
965
- >
966
- <div className="memori-chat-history-drawer--card--content--resume-button--content">
967
- <ChatRound className="memori-chat-history-drawer--card--content--resume-button--icon" />
968
- <span className="memori-chat-history-drawer--card--content--resume-button--text">
969
- {t('write_and_speak.resumeButton') ||
970
- 'Resume chat'}
971
- </span>
972
- </div>
973
- </Button>
974
- </div>
975
- </div>
976
- )} */}
977
- </>
978
- </Card>
979
- );
980
- })}
981
- </ul>
982
-
983
- {totalPages > 1 && (
984
- <div className="memori-chat-history-drawer--pagination">
985
- <Button
986
- primary
987
- onClick={() => {
988
- setCurrentPage(p => Math.max(1, p - 1));
989
- // fetchChatLogs will be triggered by the useEffect that depends on currentPage
990
- }}
991
- disabled={currentPage === 1}
992
- className="memori-chat-history-drawer--pagination--button"
993
- >
994
- {t('previous') || 'Previous'}
995
- </Button>
996
- <span className="memori-chat-history-drawer--pagination--info">
997
- {t('write_and_speak.page', {
998
- current: currentPage,
999
- total: totalPages,
1000
- })}
1001
- </span>
1002
- <Button
1003
- primary
1004
- onClick={() => {
1005
- setCurrentPage(p => Math.min(totalPages, p + 1));
1006
- // fetchChatLogs will be triggered by the useEffect that depends on currentPage
1007
- }}
1008
- disabled={currentPage === totalPages}
1009
- className="memori-chat-history-drawer--pagination--button"
1010
- >
1011
- {t('next') || 'Next'}
1012
- </Button>
1013
- </div>
1014
- )}
1015
- </>
1016
- );
1017
- };
1018
-
1019
- const renderChatDetailView = () => {
1020
- if (!selectedChatLog) return null;
1021
-
1022
- // Calculate the date of the chat (using the last message timestamp)
1023
- const lastMessageDate = Math.max(
1024
- ...selectedChatLog.lines.map(line => new Date(line.timestamp).getTime())
1025
- );
1026
- const chatDate = formatDate(new Date(lastMessageDate).toISOString());
1027
-
1028
- return (
1029
- <div className="memori-chat-history-drawer--detail-view">
1030
- <div className="memori-chat-history-drawer--detail-view--header">
1031
- <Button
1032
- className="memori-chat-history-drawer--detail-view--back-button"
1033
- onClick={() => {
1034
- setIsViewingChatDetail(false);
1035
- setSelectedChatLog(null);
1036
- }}
1037
- icon={<ChevronLeft />}
1038
- />
1039
- <div className="memori-chat-history-drawer--detail-view--header--title-wrapper">
1040
- <div className="memori-chat-history-drawer--detail-view--header--title">
1041
- {calculateTitle(selectedChatLog.lines) ||
1042
- 'Chat-' + selectedChatLog.chatLogID.substring(0, 4)}
1043
- </div>
1044
- <div className="memori-chat-history-drawer--detail-view--header--date">
1045
- {chatDate}
1046
- </div>
1047
- </div>
1048
- </div>
1049
- <div className="memori-chat-history-drawer--detail-view--content">
1050
- <div className="memori-chat-history-drawer--detail-view--messages">
1051
- <Chat
1052
- key={`${selectedChatLog.chatLogID}-${selectedChatLog.lines.length}`}
1053
- baseUrl={baseUrl}
1054
- apiUrl={apiUrl}
1055
- memoriTyping={false}
1056
- showTypingText={false}
1057
- showAIicon={true}
1058
- showTranslationOriginal={false}
1059
- showWhyThisAnswer={false}
1060
- showCopyButton={false}
1061
- isChatlogPanel={true}
1062
- showInputs={false}
1063
- history={selectedChatLog.lines.map(line => ({
1064
- text: line.text,
1065
- contextVars: line.contextVars,
1066
- media: line.media as Medium[],
1067
- fromUser: line.inbound,
1068
- timestamp: line.timestamp,
1069
- }))}
1070
- memori={memori}
1071
- sessionID={sessionId}
1072
- pushMessage={() => {}}
1073
- simulateUserPrompt={() => {}}
1074
- setSendOnEnter={() => {}}
1075
- attachmentsMenuOpen={undefined}
1076
- setAttachmentsMenuOpen={() => {}}
1077
- userMessage={''}
1078
- onChangeUserMessage={() => {}}
1079
- sendMessage={() => {}}
1080
- startListening={() => {}}
1081
- stopListening={() => {}}
1082
- listening={false}
1083
- setEnableFocusChatInput={() => {}}
1084
- stopAudio={() => {}}
1085
- isHistoryView={true}
1086
- />
1087
- </div>
1088
- <div className="memori-chat-history-drawer--detail-view--actions">
1089
- <Button
1090
- className="memori-chat-history-drawer--detail-view--resume-button"
1091
- primary
1092
- onClick={handleResumeChat}
1093
- >
1094
- <div className="memori-chat-history-drawer--detail-view--resume-button--content">
1095
- {/* <ChatRound className="memori-chat-history-drawer--detail-view--resume-button--icon" /> */}
1096
- <span className="memori-chat-history-drawer--detail-view--resume-button--text">
1097
- {t('write_and_speak.resumeButton') || 'Resume chat'}
1098
- </span>
1099
- </div>
1100
- </Button>
1101
- </div>
1102
- </div>
1103
- </div>
1104
- );
1105
- };
1106
-
1107
- return (
1108
- <Drawer
1109
- className="memori-chat-history-drawer"
1110
- open={open}
1111
- onClose={onClose}
1112
- titleWithClosable={{
1113
- title: t('write_and_speak.chatHistory') || 'Chat History',
1114
- actions: [
1115
- {
1116
- icon: <Download />,
1117
- visible: isViewingChatDetail,
1118
- onClick: () => {
1119
- //download the chat already opened
1120
- const fileName = `${memori.name.replace(/\W+/g, '-')}-chat-${
1121
- new Date().toISOString().split('T')[0]
1122
- }.txt`;
1123
- const text =
1124
- selectedChatLog?.lines
1125
- .map(
1126
- line =>
1127
- `${line.inbound ? 'YOU' : memori.name}: ${stripAllInternalTags(line.text)}`
1128
- )
1129
- .join('\n')
1130
- .replaceAll(/<think.*?>(.*?)<\/think>/gs, '')
1131
- .replaceAll(
1132
- /<output.*?<\/output>/gsi,
1133
- ''
1134
- )
1135
- .replaceAll(/```markdown([^```]+)```/g, '$1')
1136
- .replaceAll('($', '( $')
1137
- .replaceAll(':$', ': $')
1138
- .replaceAll('\frac', '\\frac')
1139
- .replaceAll('\beta', '\\beta')
1140
- .replaceAll('cdot', '\\cdot') || 'No chat history available';
1141
- downloadFile(text, fileName);
1142
- },
1143
- },
1144
- ],
1145
- showClosable: true,
1146
- }}
1147
- title={
1148
- <div
1149
- className="memori-chat-history-drawer--title-wrapper"
1150
- style={{
1151
- display: 'flex',
1152
- justifyContent: 'space-between',
1153
- alignItems: 'center',
1154
- width: '100%',
1155
- }}
1156
- >
1157
- <span>{t('write_and_speak.chatHistory') || 'Chat History'}</span>
1158
- </div>
1159
- }
1160
- description={
1161
- !isViewingChatDetail
1162
- ? t('write_and_speak.chatHistoryDescription')
1163
- : undefined
1164
- }
1165
- >
1166
- {isViewingChatDetail ? (
1167
- renderChatDetailView()
1168
- ) : (
1169
- <div className="memori-chat-history-drawer--content">
1170
- <div className="memori-chat-history-drawer--toolbar">
1171
- {/* New minimum messages filter */}
1172
- <div className="memori-chat-history-drawer--toolbar--min-messages-filter">
1173
- {/* <label className={styles.filterLabel}>
1174
- {t('chatLogs.minimumMessages', { ns: 'admin' })}
1175
- </label> */}
1176
- <Select
1177
- displayValue={
1178
- minimumMessagesPerChat === 0
1179
- ? (t('chatLogs.customMinimumMessages') ||
1180
- 'Customize the number of messages') ??
1181
- 'Customize the number of messages'
1182
- : minimumMessagesPerChat === 1
1183
- ? (t('chatLogs.anyMessage') || 'Any message') ??
1184
- 'Any message'
1185
- : t('chatLogs.atLeast', {
1186
- count: minimumMessagesPerChat,
1187
- }) ?? `At least ${minimumMessagesPerChat} messages`
1188
- }
1189
- placeholder={
1190
- (t('chatLogs.customMinimumMessages') ||
1191
- 'Customize the number of messages') ??
1192
- 'Customize the number of messages'
1193
- }
1194
- value={minimumMessagesPerChat}
1195
- onChange={value => {
1196
- setMinimumMessagesPerChat(value);
1197
- }}
1198
- className="memori-chat-history-drawer--toolbar--min-messages-filter--select"
1199
- options={[
1200
- {
1201
- value: 1,
1202
- label: t('chatLogs.anyMessage') || 'Any message',
1203
- },
1204
- {
1205
- value: 2,
1206
- label: t('chatLogs.atLeast2') || 'At least 2 messages',
1207
- },
1208
- {
1209
- value: 3,
1210
- label: t('chatLogs.atLeast3') || 'At least 3 messages',
1211
- },
1212
- {
1213
- value: 5,
1214
- label: t('chatLogs.atLeast5') || 'At least 5 messages',
1215
- },
1216
- {
1217
- value: 10,
1218
- label: t('chatLogs.atLeast10') || 'At least 10 messages',
1219
- },
1220
- {
1221
- value: 15,
1222
- label: t('chatLogs.atLeast15') || 'At least 15 messages',
1223
- },
1224
- {
1225
- value: 20,
1226
- label: t('chatLogs.atLeast20') || 'At least 20 messages',
1227
- },
1228
- {
1229
- value: 0,
1230
- label:
1231
- t('chatLogs.customMinimumMessages') ||
1232
- 'Customize the number of messages',
1233
- },
1234
- ]}
1235
- />
1236
- {minimumMessagesPerChat === 0 && (
1237
- <input
1238
- type="number"
1239
- min={1}
1240
- value={customMinimumMessages}
1241
- onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
1242
- const value = parseInt(e.target.value, 10);
1243
- setCustomMinimumMessages(value);
1244
- }}
1245
- style={{ minWidth: 50 }}
1246
- className="memori-chat-history-drawer--toolbar--min-messages-filter--input-number"
1247
- />
1248
- )}
1249
- </div>
1250
- <div className="memori-chat-history-drawer--toolbar--actions">
1251
- <Select
1252
- options={[
1253
- {
1254
- label: t('all') || 'All',
1255
- value: 'all',
1256
- },
1257
- {
1258
- label: t('today') || 'Today',
1259
- value: 'today',
1260
- },
1261
- {
1262
- label: t('yesterday') || 'Yesterday',
1263
- value: 'yesterday',
1264
- },
1265
- {
1266
- label: t('last_7_days') || 'Last 7 days',
1267
- value: 'last_7_days',
1268
- },
1269
- {
1270
- label: t('last_30_days') || 'Last 30 days',
1271
- value: 'last_30_days',
1272
- },
1273
- ]}
1274
- value={t(dateRange) || 'All'}
1275
- className="memori-chat-history-drawer--toolbar--actions--select"
1276
- onChange={(value: string) => {
1277
- setDateRange(
1278
- value as
1279
- | 'today'
1280
- | 'yesterday'
1281
- | 'last_7_days'
1282
- | 'last_30_days'
1283
- | 'all'
1284
- );
1285
- setCurrentPage(1);
1286
- // fetchChatLogs will be triggered by the useEffect that depends on dateRange
1287
- }}
1288
- />
1289
- </div>
1290
- </div>
1291
- {renderContent()}
1292
- </div>
1293
- )}
1294
- </Drawer>
1295
- );
1296
- };
1297
-
1298
- export default ChatHistoryDrawer;