@carbon/ai-chat 0.4.0-rc.2 → 0.4.0-rc.3

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 (295) hide show
  1. package/dist/es/aiChatEntry.js +220 -14
  2. package/dist/es/chat.AppContainer.js +6491 -0
  3. package/dist/es/chat.AppState.js +40 -0
  4. package/dist/es/{chat/shared/components/BasePanelComponent.js → chat.BasePanelComponent.js} +3 -3
  5. package/dist/es/{chat/shared/components/panels/BodyAndFooterPanelComponent.js → chat.BodyAndFooterPanelComponent.js} +92 -9
  6. package/dist/es/chat.BodyWithFooterComponent.js +140 -0
  7. package/dist/es/{chat/shared/components/header/BotHeader.js → chat.BotHeader.js} +7 -9
  8. package/dist/es/{chat/shared/components/responseTypes/carousel/Carousel.js → chat.Carousel.js} +3 -3
  9. package/dist/es/chat.CatastrophicError.js +381 -0
  10. package/dist/es/chat.Chat.js +2009 -0
  11. package/dist/es/chat.Disclaimer.js +553 -0
  12. package/dist/es/chat.Header.js +1025 -0
  13. package/dist/es/{chat/shared/components/util/HideComponent.js → chat.HideComponent.js} +9 -2
  14. package/dist/es/{types/config/HomeScreenConfig.js → chat.HomeScreenConfig.js} +1 -1
  15. package/dist/es/{chat/shared/components/homeScreen/HomeScreen.js → chat.HomeScreenContainer.js} +159 -14
  16. package/dist/es/{chat/shared/components/homeScreen/HomeScreenHeader.js → chat.HomeScreenHeader.js} +3 -3
  17. package/dist/es/{chat/shared/services/haa/HumanAgentServiceImpl.js → chat.HumanAgentServiceImpl.js} +215 -17
  18. package/dist/es/{chat/shared/components/responseTypes/iframe/IFrameComponent.js → chat.IFrameComponent.js} +4 -8
  19. package/dist/es/chat.IFramePanel.js +151 -0
  20. package/dist/es/{chat/shared/components/input/Input.js → chat.Input.js} +214 -18
  21. package/dist/es/{types/config/ServiceDeskConfig.js → chat.LocalMessageItem.js} +17 -1
  22. package/dist/es/chat.MessageTypeComponent.js +3580 -0
  23. package/dist/es/{types/messaging/Messages.js → chat.Messages.js} +1 -1
  24. package/dist/es/chat.MountChildrenOnDelay.js +97 -0
  25. package/dist/es/{chat/shared/components/OverlayPanel.js → chat.PageObjectId.js} +70 -4
  26. package/dist/es/{chat/web-components/components/markdownText/src/markdownText.scss.js → chat.RichText.js} +347 -1
  27. package/dist/es/chat.TourContainer.js +524 -0
  28. package/dist/es/{chat/languages/en.json.js → chat.VideoComponent.js} +561 -1
  29. package/dist/es/chat.ViewSourcePanel.js +187 -0
  30. package/dist/es/{chat/shared/store/actions.js → chat.actions.js} +2 -2
  31. package/dist/es/{chat/shared/utils/browserUtils.js → chat.browserUtils.js} +1 -1
  32. package/dist/es/{types/utilities/carbonTypes.js → chat.carbonTypes.js} +2 -2
  33. package/dist/es/{chat/web-components/components/codeElement/src/codeElement.scss.js → chat.cds-aichat-code.js} +64 -1
  34. package/dist/es/{chat/shared/utils/constants.js → chat.constants.js} +4 -7
  35. package/dist/es/{types/events/eventBusTypes.js → chat.customElement.js} +32 -1
  36. package/dist/es/chat.dynamic-imports.js +192 -0
  37. package/dist/es/{chat/shared/utils/htmlUtils.js → chat.htmlUtils.js} +16 -2
  38. package/dist/es/{chat/shared/utils/messageUtils.js → chat.messageUtils.js} +54 -7
  39. package/dist/es/{chat/shared/utils/miscUtils.js → chat.miscUtils.js} +24 -5
  40. package/dist/es/chat.resolvablePromise.js +315 -0
  41. package/dist/es/{chat/shared/store/selectors.js → chat.selectors.js} +1 -1
  42. package/dist/es/{chat/shared/utils/lang/stringUtils.js → chat.stringUtils.js} +2 -2
  43. package/dist/es/{chat/shared/hooks/useCounter.js → chat.useCounter.js} +1 -1
  44. package/dist/es/{chat/shared/hooks/useOnMount.js → chat.useOnMount.js} +1 -1
  45. package/dist/es/{chat/shared/utils/domUtils.js → chat.usePrevious.js} +47 -1
  46. package/dist/es/{chat/shared/utils/lang/UUIDType.js → chat.uuid.js} +15 -3
  47. package/dist/es/web-components/cds-aichat-container/index.js +73 -4
  48. package/dist/es/web-components/cds-aichat-custom-element/index.js +1 -3
  49. package/package.json +2 -2
  50. package/dist/es/chat/dynamic-imports/dynamic-imports.js +0 -96
  51. package/dist/es/chat/react/components/AppContainer.js +0 -197
  52. package/dist/es/chat/react/components/UserDefinedResponsePortalsContainer.js +0 -31
  53. package/dist/es/chat/react/components/WriteableElementsPortalsContainer.js +0 -28
  54. package/dist/es/chat/react/components/chainOfThought/ChainOfThought.js +0 -20
  55. package/dist/es/chat/react/components/chatHeader/ChatHeaderAvatar.js +0 -20
  56. package/dist/es/chat/react/components/chatHeader/ChatHeaderLink.js +0 -22
  57. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenu.js +0 -27
  58. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuButton.js +0 -60
  59. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItem.js +0 -24
  60. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItemRadioGroup.js +0 -28
  61. package/dist/es/chat/react/components/chatHeader/ChatHeaderOverflowMenu.js +0 -69
  62. package/dist/es/chat/react/components/chatHeader/ChatHeaderTitle.js +0 -22
  63. package/dist/es/chat/react/components/feedback/FeedbackButtonsComponent.js +0 -20
  64. package/dist/es/chat/react/components/feedback/FeedbackComponent.js +0 -20
  65. package/dist/es/chat/react/components/inlineLoading/InlineLoadingComponent.js +0 -20
  66. package/dist/es/chat/react/components/markdownText/MarkdownText.js +0 -20
  67. package/dist/es/chat/react/components/stopStreamingButton/StopStreamingButton.js +0 -20
  68. package/dist/es/chat/react/components/table/Table.js +0 -20
  69. package/dist/es/chat/shared/Chat.js +0 -115
  70. package/dist/es/chat/shared/ChatInstanceImpl.js +0 -360
  71. package/dist/es/chat/shared/chatEntryFunctions.js +0 -46
  72. package/dist/es/chat/shared/components/Avatar.js +0 -286
  73. package/dist/es/chat/shared/components/BodyWithFooterComponent.js +0 -56
  74. package/dist/es/chat/shared/components/CatastrophicError.js +0 -77
  75. package/dist/es/chat/shared/components/Chat.js +0 -244
  76. package/dist/es/chat/shared/components/ChatBubbleDark.js +0 -124
  77. package/dist/es/chat/shared/components/ChatBubbleLight.js +0 -216
  78. package/dist/es/chat/shared/components/Disclaimer.js +0 -86
  79. package/dist/es/chat/shared/components/ErrorIcon.js +0 -20
  80. package/dist/es/chat/shared/components/ErrorMessageDark.js +0 -89
  81. package/dist/es/chat/shared/components/ErrorMessageLight.js +0 -135
  82. package/dist/es/chat/shared/components/HydrationPanel.js +0 -58
  83. package/dist/es/chat/shared/components/LatestWelcomeNodes.js +0 -26
  84. package/dist/es/chat/shared/components/ResponseStopped.js +0 -19
  85. package/dist/es/chat/shared/components/SkeletonPicker.js +0 -32
  86. package/dist/es/chat/shared/components/WriteableElement.js +0 -22
  87. package/dist/es/chat/shared/components/agent/AgentAvatar.js +0 -54
  88. package/dist/es/chat/shared/components/agent/AgentBanner.js +0 -109
  89. package/dist/es/chat/shared/components/agent/AgentBannerContainer.js +0 -28
  90. package/dist/es/chat/shared/components/agent/AvailabilityMessage.js +0 -49
  91. package/dist/es/chat/shared/components/aria/AriaAnnouncerComponent.js +0 -122
  92. package/dist/es/chat/shared/components/aria/AriaAnnouncerProvider.js +0 -48
  93. package/dist/es/chat/shared/components/aria/AriaLiveMessage.js +0 -22
  94. package/dist/es/chat/shared/components/header/AISlug.js +0 -22
  95. package/dist/es/chat/shared/components/header/Header.js +0 -460
  96. package/dist/es/chat/shared/components/header/SimpleHeader.js +0 -27
  97. package/dist/es/chat/shared/components/homeScreen/HomeScreenContainer.js +0 -68
  98. package/dist/es/chat/shared/components/launcher/Launcher.js +0 -88
  99. package/dist/es/chat/shared/components/launcher/LauncherComplex.js +0 -63
  100. package/dist/es/chat/shared/components/launcher/LauncherContainer.js +0 -73
  101. package/dist/es/chat/shared/components/launcher/LauncherDesktopContainer.js +0 -221
  102. package/dist/es/chat/shared/components/launcher/LauncherExtended.js +0 -244
  103. package/dist/es/chat/shared/components/launcher/LauncherMobileContainer.js +0 -175
  104. package/dist/es/chat/shared/components/launcher/launcherUtils.js +0 -16
  105. package/dist/es/chat/shared/components/modals/ConfirmModal.js +0 -67
  106. package/dist/es/chat/shared/components/modals/EndAgentChatModal.js +0 -46
  107. package/dist/es/chat/shared/components/modals/RequestScreenShareModal.js +0 -43
  108. package/dist/es/chat/shared/components/notifications/Notifications.js +0 -58
  109. package/dist/es/chat/shared/components/panels/CustomPanel.js +0 -136
  110. package/dist/es/chat/shared/components/responseTypes/agent/ConnectToAgent.js +0 -30
  111. package/dist/es/chat/shared/components/responseTypes/agent/RealConnectToAgent.js +0 -102
  112. package/dist/es/chat/shared/components/responseTypes/audio/AudioComponent.js +0 -26
  113. package/dist/es/chat/shared/components/responseTypes/buttonItem/BaseButtonItemComponent.js +0 -69
  114. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemComponent.js +0 -48
  115. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemCustomEventComponent.js +0 -42
  116. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemPostBackComponent.js +0 -54
  117. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemShowPanelComponent.js +0 -36
  118. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemURLComponent.js +0 -42
  119. package/dist/es/chat/shared/components/responseTypes/card/CardItemComponent.js +0 -34
  120. package/dist/es/chat/shared/components/responseTypes/carousel/CarouselItemComponent.js +0 -39
  121. package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearch.js +0 -92
  122. package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearchText.js +0 -158
  123. package/dist/es/chat/shared/components/responseTypes/custom/UserDefinedResponse.js +0 -33
  124. package/dist/es/chat/shared/components/responseTypes/datePicker/DatePickerComponent.js +0 -176
  125. package/dist/es/chat/shared/components/responseTypes/error/InlineError.js +0 -32
  126. package/dist/es/chat/shared/components/responseTypes/grid/GridItemComponent.js +0 -109
  127. package/dist/es/chat/shared/components/responseTypes/iframe/IFrameMessage.js +0 -32
  128. package/dist/es/chat/shared/components/responseTypes/iframe/IFramePanel.js +0 -51
  129. package/dist/es/chat/shared/components/responseTypes/iframe/IFramePreviewCard.js +0 -64
  130. package/dist/es/chat/shared/components/responseTypes/iframe/InlineIFrame.js +0 -55
  131. package/dist/es/chat/shared/components/responseTypes/image/Image.js +0 -120
  132. package/dist/es/chat/shared/components/responseTypes/options/OptionComponent.js +0 -83
  133. package/dist/es/chat/shared/components/responseTypes/options/SelectComponent.js +0 -84
  134. package/dist/es/chat/shared/components/responseTypes/table/TableContainer.js +0 -96
  135. package/dist/es/chat/shared/components/responseTypes/text/TextArea.js +0 -68
  136. package/dist/es/chat/shared/components/responseTypes/tour/TourCard.js +0 -73
  137. package/dist/es/chat/shared/components/responseTypes/util/BodyMessageComponents.js +0 -65
  138. package/dist/es/chat/shared/components/responseTypes/util/ClickableImage.js +0 -36
  139. package/dist/es/chat/shared/components/responseTypes/util/Description.js +0 -21
  140. package/dist/es/chat/shared/components/responseTypes/util/FooterButtonComponents.js +0 -36
  141. package/dist/es/chat/shared/components/responseTypes/util/MediaPlayer.js +0 -157
  142. package/dist/es/chat/shared/components/responseTypes/util/Metablock.js +0 -27
  143. package/dist/es/chat/shared/components/responseTypes/util/RichText.js +0 -31
  144. package/dist/es/chat/shared/components/responseTypes/util/SearchResultBody.js +0 -53
  145. package/dist/es/chat/shared/components/responseTypes/util/StreamingRichText.js +0 -38
  146. package/dist/es/chat/shared/components/responseTypes/util/TextHolderTile.js +0 -35
  147. package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCard.js +0 -65
  148. package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCardContent.js +0 -62
  149. package/dist/es/chat/shared/components/responseTypes/util/citations/CitationClickableCard.js +0 -23
  150. package/dist/es/chat/shared/components/responseTypes/util/citations/ExpandToPanelCard.js +0 -50
  151. package/dist/es/chat/shared/components/responseTypes/util/citations/ViewSourcePanel.js +0 -57
  152. package/dist/es/chat/shared/components/responseTypes/video/VideoComponent.js +0 -23
  153. package/dist/es/chat/shared/components/tour/TourCloseMinimizeComponent.js +0 -44
  154. package/dist/es/chat/shared/components/tour/TourContainer.js +0 -212
  155. package/dist/es/chat/shared/components/tour/TourControlsComponent.js +0 -98
  156. package/dist/es/chat/shared/components/tour/TourStepContentComponent.js +0 -156
  157. package/dist/es/chat/shared/components/tour/TourStepSkeletonComponent.js +0 -20
  158. package/dist/es/chat/shared/components/util/AnnounceOnMountComponent.js +0 -42
  159. package/dist/es/chat/shared/components/util/IconHolder.js +0 -16
  160. package/dist/es/chat/shared/components/util/ImageWithFallback.js +0 -31
  161. package/dist/es/chat/shared/components/util/MaybeDangerouslySetInnerHTML.js +0 -42
  162. package/dist/es/chat/shared/components/util/MountChildrenOnDelay.js +0 -40
  163. package/dist/es/chat/shared/components/util/VisuallyHidden.js +0 -18
  164. package/dist/es/chat/shared/containers/App.js +0 -181
  165. package/dist/es/chat/shared/containers/MessageComponent.js +0 -465
  166. package/dist/es/chat/shared/containers/MessageTypeComponent.js +0 -496
  167. package/dist/es/chat/shared/containers/MessagesComponent.js +0 -469
  168. package/dist/es/chat/shared/containers/ModalPortal.js +0 -53
  169. package/dist/es/chat/shared/containers/main/MainWindow.js +0 -708
  170. package/dist/es/chat/shared/contexts/AriaAnnouncerContext.js +0 -12
  171. package/dist/es/chat/shared/contexts/HideComponentContext.js +0 -12
  172. package/dist/es/chat/shared/contexts/LanguagePackContext.js +0 -12
  173. package/dist/es/chat/shared/contexts/ModalPortalRootContext.js +0 -12
  174. package/dist/es/chat/shared/contexts/ServiceManagerContext.js +0 -12
  175. package/dist/es/chat/shared/contexts/WindowSizeContext.js +0 -12
  176. package/dist/es/chat/shared/environmentVariables.js +0 -13
  177. package/dist/es/chat/shared/events/ChatActionsImpl.js +0 -783
  178. package/dist/es/chat/shared/events/EventBus.js +0 -161
  179. package/dist/es/chat/shared/hocs/withAriaAnnouncer.js +0 -25
  180. package/dist/es/chat/shared/hocs/withServiceManager.js +0 -25
  181. package/dist/es/chat/shared/hooks/useAriaAnnouncer.js +0 -16
  182. package/dist/es/chat/shared/hooks/useCSSCustomProperties.js +0 -21
  183. package/dist/es/chat/shared/hooks/useCallbackOnChange.js +0 -24
  184. package/dist/es/chat/shared/hooks/useEffectDidUpdate.js +0 -21
  185. package/dist/es/chat/shared/hooks/useLanguagePack.js +0 -16
  186. package/dist/es/chat/shared/hooks/usePrevious.js +0 -18
  187. package/dist/es/chat/shared/hooks/useServiceManager.js +0 -16
  188. package/dist/es/chat/shared/hooks/useShouldSanitizeHTML.js +0 -15
  189. package/dist/es/chat/shared/hooks/useUUID.js +0 -22
  190. package/dist/es/chat/shared/hooks/useWindowSize.js +0 -16
  191. package/dist/es/chat/shared/loadServices.js +0 -72
  192. package/dist/es/chat/shared/schema/historyToMessages.js +0 -231
  193. package/dist/es/chat/shared/schema/inputItemToLocalItem.js +0 -30
  194. package/dist/es/chat/shared/schema/outputItemToLocalItem.js +0 -124
  195. package/dist/es/chat/shared/services/CustomPanelInstance.js +0 -26
  196. package/dist/es/chat/shared/services/CustomPanelManager.js +0 -23
  197. package/dist/es/chat/shared/services/HistoryService.js +0 -59
  198. package/dist/es/chat/shared/services/MessageService.js +0 -351
  199. package/dist/es/chat/shared/services/NamespaceService.js +0 -26
  200. package/dist/es/chat/shared/services/ServiceManager.js +0 -19
  201. package/dist/es/chat/shared/services/UserSessionStorageService.js +0 -89
  202. package/dist/es/chat/shared/services/haa/agentStatusMessage.js +0 -108
  203. package/dist/es/chat/shared/services/haa/humanAgentUtils.js +0 -114
  204. package/dist/es/chat/shared/services/mockStorage.js +0 -30
  205. package/dist/es/chat/shared/store/agentActions.js +0 -125
  206. package/dist/es/chat/shared/store/agentReducers.js +0 -215
  207. package/dist/es/chat/shared/store/doCreateStore.js +0 -142
  208. package/dist/es/chat/shared/store/reducerUtils.js +0 -320
  209. package/dist/es/chat/shared/store/reducers.js +0 -871
  210. package/dist/es/chat/shared/store/subscriptions.js +0 -55
  211. package/dist/es/chat/shared/store/tourReducerUtils.js +0 -51
  212. package/dist/es/chat/shared/utils/ListenerList.js +0 -26
  213. package/dist/es/chat/shared/utils/PageObjectId.js +0 -25
  214. package/dist/es/chat/shared/utils/animationUtils.js +0 -77
  215. package/dist/es/chat/shared/utils/colors.js +0 -71
  216. package/dist/es/chat/shared/utils/customizers.js +0 -16
  217. package/dist/es/chat/shared/utils/dateUtils.js +0 -38
  218. package/dist/es/chat/shared/utils/homeScreenUtils.js +0 -27
  219. package/dist/es/chat/shared/utils/intlUtils.js +0 -21
  220. package/dist/es/chat/shared/utils/lang/arrayUtils.js +0 -53
  221. package/dist/es/chat/shared/utils/lang/langUtils.js +0 -13
  222. package/dist/es/chat/shared/utils/lang/objectUtils.js +0 -19
  223. package/dist/es/chat/shared/utils/lang/promiseUtils.js +0 -25
  224. package/dist/es/chat/shared/utils/lang/uuid.js +0 -16
  225. package/dist/es/chat/shared/utils/languages.js +0 -156
  226. package/dist/es/chat/shared/utils/memoizerUtils.js +0 -38
  227. package/dist/es/chat/shared/utils/messageServiceUtils.js +0 -36
  228. package/dist/es/chat/shared/utils/resolvablePromise.js +0 -32
  229. package/dist/es/chat/shared/utils/styleUtils.js +0 -231
  230. package/dist/es/chat/shared/utils/timeUtils.js +0 -14
  231. package/dist/es/chat/shared/utils/viewStateUtils.js +0 -38
  232. package/dist/es/chat/web-components/components/chainOfThought/cds-aichat-chain-of-thought.js +0 -26
  233. package/dist/es/chat/web-components/components/chainOfThought/src/ChainOfThoughtElement.js +0 -130
  234. package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.scss.js +0 -3
  235. package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.template.js +0 -186
  236. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/cds-aichat-chat-header-avatar.js +0 -26
  237. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatar.template.js +0 -32
  238. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.js +0 -52
  239. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.scss.js +0 -3
  240. package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/cds-aichat-chat-header-link.js +0 -44
  241. package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/src/chatHeaderLinkElement.template.js +0 -28
  242. package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/cds-aichat-chat-header-title.js +0 -42
  243. package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.scss.js +0 -3
  244. package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.template.js +0 -20
  245. package/dist/es/chat/web-components/components/codeElement/cds-aichat-code.js +0 -66
  246. package/dist/es/chat/web-components/components/feedbackButtonsElement/cds-aichat-feedback-buttons.js +0 -26
  247. package/dist/es/chat/web-components/components/feedbackButtonsElement/src/FeedbackButtonsElement.js +0 -93
  248. package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.scss.js +0 -3
  249. package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.template.js +0 -84
  250. package/dist/es/chat/web-components/components/feedbackElement/cds-aichat-feedback.js +0 -30
  251. package/dist/es/chat/web-components/components/feedbackElement/src/FeedbackElement.js +0 -157
  252. package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.scss.js +0 -3
  253. package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.template.js +0 -95
  254. package/dist/es/chat/web-components/components/inlineLoadingElement/cds-aichat-inline-loading.js +0 -85
  255. package/dist/es/chat/web-components/components/inlineLoadingElement/src/styles.scss.js +0 -3
  256. package/dist/es/chat/web-components/components/markdownText/cds-aichat-markdown-text.js +0 -32
  257. package/dist/es/chat/web-components/components/markdownText/markdown/markdownToHTML.js +0 -28
  258. package/dist/es/chat/web-components/components/markdownText/markdown/utils/renderTokenTree.js +0 -191
  259. package/dist/es/chat/web-components/components/markdownText/markdown/workers/workerManager.js +0 -16
  260. package/dist/es/chat/web-components/components/markdownText/src/MarkdownElement.js +0 -70
  261. package/dist/es/chat/web-components/components/markdownText/src/markdownElement.template.js +0 -19
  262. package/dist/es/chat/web-components/components/roundedButton/cds-aichat-rounded-button.js +0 -29
  263. package/dist/es/chat/web-components/components/stopStreamingButton/cds-aichat-stop-streaming-button.js +0 -26
  264. package/dist/es/chat/web-components/components/stopStreamingButton/src/StopStreamingButtonElement.js +0 -49
  265. package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.scss.js +0 -3
  266. package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.template.js +0 -44
  267. package/dist/es/chat/web-components/components/table/cds-aichat-table.js +0 -229
  268. package/dist/es/chat/web-components/components/table/src/table.scss.js +0 -3
  269. package/dist/es/chat/web-components/components/table/src/table.template.js +0 -81
  270. package/dist/es/chat/web-components/components/table/src/tablePagination.template.js +0 -43
  271. package/dist/es/chat/web-components/components/table/src/tableSkeleton.template.js +0 -17
  272. package/dist/es/chat/web-components/components/tagListElement/cds-aichat-tag-list.js +0 -28
  273. package/dist/es/chat/web-components/components/tagListElement/src/TagListElement.js +0 -70
  274. package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.scss.js +0 -3
  275. package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.template.js +0 -40
  276. package/dist/es/chat/web-components/decorators/customElement.js +0 -33
  277. package/dist/es/chat/web-components/internal/cds-aichat-internal.js +0 -78
  278. package/dist/es/chat/web-components/settings.js +0 -13
  279. package/dist/es/node_modules/@carbon/colors/es/index.js +0 -11
  280. package/dist/es/react/ChatContainer.js +0 -162
  281. package/dist/es/react/ChatCustomElement.js +0 -58
  282. package/dist/es/types/config/ChatHeaderConfig.js +0 -18
  283. package/dist/es/types/config/CornersType.js +0 -16
  284. package/dist/es/types/config/LauncherConfig.js +0 -19
  285. package/dist/es/types/config/PublicConfig.js +0 -36
  286. package/dist/es/types/instance/ChatInstance.js +0 -31
  287. package/dist/es/types/instance/apiTypes.js +0 -33
  288. package/dist/es/types/messaging/LocalMessageItem.js +0 -18
  289. package/dist/es/types/state/AppState.js +0 -18
  290. package/dist/es/types/utilities/Animation.js +0 -31
  291. package/dist/es/types/utilities/HasAddRemoveClassName.js +0 -27
  292. /package/dist/es/{chat/shared/styles/export.carbon.scss.js → chat.export.carbon.js} +0 -0
  293. /package/dist/es/{chat/shared/styles/export.scss.js → chat.export.js} +0 -0
  294. /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/markdown.js → chat.markdown.js} +0 -0
  295. /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/tokenTree.js → chat.tokenTree.js} +0 -0
@@ -1,871 +0,0 @@
1
- import merge from "lodash-es/merge.js";
2
-
3
- import mergeWith from "lodash-es/mergeWith.js";
4
-
5
- import { outputItemToLocalItem } from "../schema/outputItemToLocalItem.js";
6
-
7
- import "../utils/constants.js";
8
-
9
- import { replaceCurrentArrayValue } from "../utils/customizers.js";
10
-
11
- import { streamItemID, isResponse, isRequest } from "../utils/messageUtils.js";
12
-
13
- import { UPDATE_MAIN_HEADER_AVATAR, SET_STREAM_ID, SET_STOP_STREAMING_BUTTON_DISABLED, SET_STOP_STREAMING_BUTTON_VISIBLE, UPDATE_MAX_VISIBLE_HEADER_OBJECTS, UPDATE_CHAT_HEADER_CONFIG, STREAMING_ADD_CHUNK, STREAMING_MERGE_HISTORY, STREAMING_START, SET_RESPONSE_PANEL_CONTENT, SET_RESPONSE_PANEL_IS_OPEN, ADD_NESTED_MESSAGES, FILE_UPLOAD_INPUT_ERROR, CLEAR_INPUT_FILES, REMOVE_ALL_NOTIFICATIONS, REMOVE_NOTIFICATIONS, ADD_NOTIFICATION, REMOVE_LOCAL_MESSAGE_ITEM, REMOVE_INPUT_FILE, ADD_INPUT_FILE, SET_IS_BROWSER_PAGE_VISIBLE, UPDATE_INPUT_STATE, CHANGE_STEP_IN_TOUR, CLEAR_TOUR_DATA, SET_TOUR_DATA, SET_CUSTOM_PANEL_OPTIONS, SET_CUSTOM_PANEL_OPEN, SET_CONVERSATIONAL_SEARCH_CITATION_PANEL_IS_OPEN, CLOSE_IFRAME_PANEL, OPEN_IFRAME_CONTENT, SET_LAUNCHER_MINIMIZED, SET_CHAT_MESSAGES_PROPERTY, SET_LAUNCHER_CONFIG_PROPERTY, SET_LAUNCHER_PROPERTY, UPDATE_LAUNCHER_CONFIG, TOGGLE_HOME_SCREEN, SET_HOME_SCREEN_IS_OPEN, ACCEPTED_DISCLAIMER, ANNOUNCE_MESSAGE, MERGE_HISTORY, SET_MESSAGE_HISTORY_PROPERTY, SET_MESSAGE_UI_PROPERTY, UPDATE_HOME_SCREEN_CONFIG, UPDATE_CSS_VARIABLES, UPDATE_MAIN_HEADER_TITLE, UPDATE_LAUNCHER_AVATAR_URL, UPDATE_BOT_AVATAR_URL, UPDATE_BOT_NAME, SET_INITIAL_VIEW_CHANGE_COMPLETE, SET_VIEW_CHANGING, SET_VIEW_STATE, UPDATE_HAS_SENT_NON_WELCOME_MESSAGE, UPDATE_PERSISTED_CHAT_STATE, SET_APP_STATE_VALUE, ADD_IS_HYDRATING_COUNTER, ADD_IS_LOADING_COUNTER, ADD_IS_TYPING_COUNTER, MESSAGE_SET_OPTION_SELECTED, ADD_MESSAGE, UPDATE_MESSAGE, UPDATE_LOCAL_MESSAGE_ITEM, REMOVE_MESSAGES, ADD_LOCAL_MESSAGE_ITEM, HYDRATE_MESSAGE_HISTORY, RESTART_CONVERSATION, HYDRATE_CHAT, CHANGE_STATE } from "./actions.js";
14
-
15
- import { agentReducers } from "./agentReducers.js";
16
-
17
- import { setHomeScreenOpenState, applyFullMessage, applyBotMessageState, applyLocalMessageUIState, handleViewStateChange, DEFAULT_CUSTOM_PANEL_STATE, DEFAULT_CITATION_PANEL_STATE, DEFAULT_IFRAME_PANEL_STATE } from "./reducerUtils.js";
18
-
19
- import { clearTourState, populateTourStepItems } from "./tourReducerUtils.js";
20
-
21
- import { AgentMessageType } from "../../../types/messaging/Messages.js";
22
-
23
- import { FileStatusValue, LauncherType } from "../../../types/instance/apiTypes.js";
24
-
25
- /*
26
- * Copyright IBM Corp. 2025
27
- *
28
- * This source code is licensed under the Apache-2.0 license found in the
29
- * LICENSE file in the root directory of this source tree.
30
- *
31
- * @license
32
- */
33
- const EXCLUDE_AGENT_UNREAD = new Set([ AgentMessageType.USER_ENDED_CHAT, AgentMessageType.CHAT_WAS_ENDED, AgentMessageType.RELOAD_WARNING ]);
34
-
35
- const reducers = {
36
- [CHANGE_STATE]: (state, action) => merge({}, state, action.partialState),
37
- [HYDRATE_CHAT]: state => ({
38
- ...state,
39
- isHydrated: true
40
- }),
41
- [RESTART_CONVERSATION]: state => {
42
- let newState = {
43
- ...state,
44
- botMessageState: {
45
- ...state.botMessageState,
46
- localMessageIDs: [],
47
- messageIDs: [],
48
- isTypingCounter: 0,
49
- isScrollAnchored: false
50
- },
51
- allMessageItemsByID: {},
52
- allMessagesByID: {},
53
- iFramePanelState: {
54
- ...DEFAULT_IFRAME_PANEL_STATE
55
- },
56
- viewSourcePanelState: {
57
- ...DEFAULT_CITATION_PANEL_STATE
58
- },
59
- customPanelState: {
60
- ...DEFAULT_CUSTOM_PANEL_STATE
61
- },
62
- persistedToBrowserStorage: {
63
- ...state.persistedToBrowserStorage,
64
- chatState: {
65
- ...state.persistedToBrowserStorage.chatState,
66
- homeScreenState: {
67
- ...state.persistedToBrowserStorage.chatState.homeScreenState,
68
- showBackToBot: false
69
- }
70
- }
71
- },
72
- isHydrated: false,
73
- catastrophicErrorType: null
74
- };
75
- newState = clearTourState(newState);
76
- if (newState.homeScreenConfig.is_on) {
77
- newState = setHomeScreenOpenState(newState, true);
78
- }
79
- return newState;
80
- },
81
- [HYDRATE_MESSAGE_HISTORY]: (state, action) => {
82
- let newState = {
83
- ...state,
84
- ...action.messageHistory
85
- };
86
- if (state.persistedToBrowserStorage.chatState.persistedTourState.activeTourID) {
87
- newState = populateTourStepItems(newState);
88
- }
89
- return newState;
90
- },
91
- [ADD_LOCAL_MESSAGE_ITEM]: (state, action) => {
92
- const {messageItem: messageItem, message: message, addMessage: addMessage, addAfterID: addAfterID} = action;
93
- const {id: id} = messageItem.ui_state;
94
- const isSilent = message.history.silent;
95
- let newState = state;
96
- if (addMessage) {
97
- newState = applyFullMessage(newState, message);
98
- }
99
- const currentIndex = newState.botMessageState.localMessageIDs.findIndex(existingID => existingID === id);
100
- const newLocalMessageIDs = [ ...newState.botMessageState.localMessageIDs ];
101
- let insertAtIndex = currentIndex;
102
- if (currentIndex !== -1) {
103
- newLocalMessageIDs.splice(currentIndex, 1);
104
- } else {
105
- insertAtIndex = newLocalMessageIDs.length;
106
- }
107
- if (addAfterID) {
108
- const afterIDIndex = newLocalMessageIDs.findIndex(existingID => existingID === addAfterID);
109
- if (afterIDIndex !== -1) {
110
- insertAtIndex = afterIDIndex + 1;
111
- }
112
- }
113
- newLocalMessageIDs.splice(insertAtIndex, 0, id);
114
- if (!isSilent) {
115
- newState = {
116
- ...newState,
117
- allMessageItemsByID: {
118
- ...newState.allMessageItemsByID,
119
- [id]: messageItem
120
- },
121
- botMessageState: {
122
- ...newState.botMessageState,
123
- localMessageIDs: newLocalMessageIDs
124
- }
125
- };
126
- if (newState.persistedToBrowserStorage.chatState.homeScreenState.isHomeScreenOpen) {
127
- newState = setHomeScreenOpenState(newState, false);
128
- }
129
- const isBotMessage = !messageItem.item.agent_message_type;
130
- const isMainWindowOpen = state.persistedToBrowserStorage.launcherState.viewState.mainWindow;
131
- if (!isBotMessage && (!isMainWindowOpen || !state.isBrowserPageVisible)) {
132
- const fromAgent = !isRequest(message);
133
- if (fromAgent && !EXCLUDE_AGENT_UNREAD.has(messageItem.item.agent_message_type)) {
134
- newState = {
135
- ...newState,
136
- agentState: {
137
- ...newState.agentState,
138
- numUnreadMessages: newState.agentState.numUnreadMessages + 1
139
- }
140
- };
141
- }
142
- }
143
- }
144
- return newState;
145
- },
146
- [REMOVE_MESSAGES]: (state, {messageIDs: messageIDs}) => {
147
- const idsSet = new Set(messageIDs);
148
- const newAllMessages = {
149
- ...state.allMessagesByID
150
- };
151
- const newAllMessageItems = {
152
- ...state.allMessageItemsByID
153
- };
154
- const newMessageIDs = state.botMessageState.messageIDs.filter(messageID => !idsSet.has(messageID));
155
- const newMessageItemsIDs = state.botMessageState.localMessageIDs.filter(messageItemID => {
156
- const messageItem = newAllMessageItems[messageItemID];
157
- const removeItem = idsSet.has(messageItem?.fullMessageID);
158
- if (removeItem) {
159
- delete newAllMessageItems[messageItemID];
160
- }
161
- return !removeItem;
162
- });
163
- messageIDs.forEach(messageID => {
164
- delete newAllMessages[messageID];
165
- });
166
- const newState = {
167
- ...state,
168
- allMessagesByID: newAllMessages,
169
- allMessageItemsByID: newAllMessageItems,
170
- botMessageState: {
171
- ...state.botMessageState,
172
- messageIDs: newMessageIDs,
173
- localMessageIDs: newMessageItemsIDs
174
- }
175
- };
176
- return newState;
177
- },
178
- [UPDATE_LOCAL_MESSAGE_ITEM]: (state, action) => {
179
- const {messageItem: messageItem} = action;
180
- return {
181
- ...state,
182
- allMessageItemsByID: {
183
- ...state.allMessageItemsByID,
184
- [messageItem.ui_state.id]: messageItem
185
- }
186
- };
187
- },
188
- [UPDATE_MESSAGE]: (state, action) => {
189
- const {message: message} = action;
190
- return {
191
- ...state,
192
- allMessagesByID: {
193
- ...state.allMessagesByID,
194
- [message.id]: message
195
- }
196
- };
197
- },
198
- [ADD_MESSAGE]: (state, action) => {
199
- const {message: message} = action;
200
- const messageID = message.id;
201
- let newState = state;
202
- if (isResponse(message)) {
203
- const itemIDsInNewMessage = [];
204
- message.output.generic.forEach(item => {
205
- const id = streamItemID(messageID, item);
206
- if (id) {
207
- itemIDsInNewMessage.push(id);
208
- }
209
- });
210
- const newAllMessageItemsByID = {
211
- ...state.allMessageItemsByID
212
- };
213
- const existingItemIDs = [];
214
- let firstFoundIndex;
215
- const newLocalMessageIDs = state.botMessageState.localMessageIDs.filter((itemID, index) => {
216
- const item = state.allMessageItemsByID[itemID];
217
- const isItemInMessage = item.fullMessageID === messageID;
218
- if (isItemInMessage) {
219
- if (firstFoundIndex === undefined) {
220
- firstFoundIndex = index;
221
- }
222
- if (!itemIDsInNewMessage.includes(itemID)) {
223
- delete newAllMessageItemsByID[itemID];
224
- } else {
225
- existingItemIDs.push(itemID);
226
- }
227
- }
228
- return !isItemInMessage;
229
- });
230
- if (existingItemIDs.length) {
231
- const itemIDsToInsert = itemIDsInNewMessage.filter(itemID => existingItemIDs.includes(itemID));
232
- if (itemIDsToInsert.length) {
233
- newLocalMessageIDs.splice(firstFoundIndex, 0, ...itemIDsToInsert);
234
- }
235
- }
236
- newState = {
237
- ...newState,
238
- allMessageItemsByID: newAllMessageItemsByID,
239
- botMessageState: {
240
- ...newState.botMessageState,
241
- localMessageIDs: newLocalMessageIDs
242
- }
243
- };
244
- }
245
- return applyFullMessage(newState, message);
246
- },
247
- [MESSAGE_SET_OPTION_SELECTED]: (state, action) => {
248
- const newMessagesByID = {
249
- ...state.allMessageItemsByID
250
- };
251
- newMessagesByID[action.messageID] = {
252
- ...state.allMessageItemsByID[action.messageID],
253
- ui_state: {
254
- ...state.allMessageItemsByID[action.messageID].ui_state,
255
- optionSelected: action.sentMessage
256
- }
257
- };
258
- return {
259
- ...state,
260
- allMessageItemsByID: newMessagesByID
261
- };
262
- },
263
- [ADD_IS_TYPING_COUNTER]: (state, action) => ({
264
- ...state,
265
- botMessageState: {
266
- ...state.botMessageState,
267
- isTypingCounter: Math.max(state.botMessageState.isTypingCounter + action.addToIsTyping, 0)
268
- }
269
- }),
270
- [ADD_IS_LOADING_COUNTER]: (state, action) => ({
271
- ...state,
272
- botMessageState: {
273
- ...state.botMessageState,
274
- isLoadingCounter: Math.max(state.botMessageState.isLoadingCounter + action.addToIsLoading, 0)
275
- }
276
- }),
277
- [ADD_IS_HYDRATING_COUNTER]: (state, action) => ({
278
- ...state,
279
- botMessageState: {
280
- ...state.botMessageState,
281
- isHydratingCounter: Math.max(state.botMessageState.isHydratingCounter + action.addToIsHydrating, 0)
282
- }
283
- }),
284
- [SET_APP_STATE_VALUE]: (state, action) => ({
285
- ...state,
286
- [action.key]: action.value
287
- }),
288
- [UPDATE_PERSISTED_CHAT_STATE]: (state, action) => ({
289
- ...state,
290
- persistedToBrowserStorage: {
291
- ...state.persistedToBrowserStorage,
292
- chatState: {
293
- ...state.persistedToBrowserStorage.chatState,
294
- ...action.chatState
295
- }
296
- }
297
- }),
298
- [UPDATE_HAS_SENT_NON_WELCOME_MESSAGE]: (state, action) => {
299
- if (state.persistedToBrowserStorage.chatState.hasSentNonWelcomeMessage === action.hasSentNonWelcomeMessage) {
300
- return state;
301
- }
302
- return {
303
- ...state,
304
- persistedToBrowserStorage: {
305
- ...state.persistedToBrowserStorage,
306
- chatState: {
307
- ...state.persistedToBrowserStorage.chatState,
308
- hasSentNonWelcomeMessage: action.hasSentNonWelcomeMessage
309
- },
310
- launcherState: {
311
- ...state.persistedToBrowserStorage.launcherState,
312
- hasSentNonWelcomeMessage: action.hasSentNonWelcomeMessage
313
- }
314
- }
315
- };
316
- },
317
- [SET_VIEW_STATE]: (state, action) => handleViewStateChange(state, action.viewState),
318
- [SET_VIEW_CHANGING]: (state, action) => ({
319
- ...state,
320
- viewChanging: action.viewChanging
321
- }),
322
- [SET_INITIAL_VIEW_CHANGE_COMPLETE]: (state, action) => ({
323
- ...state,
324
- initialViewChangeComplete: action.changeComplete
325
- }),
326
- [UPDATE_BOT_NAME]: (state, action) => ({
327
- ...state,
328
- botName: action.name,
329
- headerDisplayName: state.theme.useAITheme ? state.headerDisplayName : action.name
330
- }),
331
- [UPDATE_BOT_AVATAR_URL]: (state, action) => ({
332
- ...state,
333
- botAvatarURL: action.url
334
- }),
335
- [UPDATE_LAUNCHER_AVATAR_URL]: (state, action) => ({
336
- ...state,
337
- launcher: {
338
- ...state.launcher,
339
- config: {
340
- ...state.launcher.config,
341
- mobile: {
342
- ...state.launcher.config.mobile,
343
- avatar_url_override: action.source
344
- },
345
- desktop: {
346
- ...state.launcher.config.desktop,
347
- avatar_url_override: action.source
348
- }
349
- }
350
- }
351
- }),
352
- [UPDATE_MAIN_HEADER_TITLE]: (state, action) => ({
353
- ...state,
354
- headerDisplayName: action.title
355
- }),
356
- [UPDATE_CSS_VARIABLES]: (state, action) => {
357
- const {config: config} = state;
358
- const {variables: variables} = action;
359
- const newConfig = {
360
- public: {
361
- ...config.public
362
- }
363
- };
364
- return {
365
- ...state,
366
- config: newConfig,
367
- cssVariableOverrides: variables
368
- };
369
- },
370
- [UPDATE_HOME_SCREEN_CONFIG]: (state, action) => {
371
- const newHomeScreenConfig = action.homeScreenConfig;
372
- return {
373
- ...state,
374
- homeScreenConfig: mergeWith({}, state.homeScreenConfig, newHomeScreenConfig, replaceCurrentArrayValue)
375
- };
376
- },
377
- [SET_MESSAGE_UI_PROPERTY]: (state, action) => applyLocalMessageUIState(state, action.localMessageID, action.propertyName, action.propertyValue),
378
- [SET_MESSAGE_HISTORY_PROPERTY]: (state, action) => {
379
- const {messageID: messageID, propertyName: propertyName, propertyValue: propertyValue} = action;
380
- const oldMessage = state.allMessagesByID[messageID];
381
- if (oldMessage) {
382
- return {
383
- ...state,
384
- allMessagesByID: {
385
- ...state.allMessagesByID,
386
- [messageID]: {
387
- ...oldMessage,
388
- history: {
389
- ...oldMessage.history,
390
- [propertyName]: propertyValue
391
- }
392
- }
393
- }
394
- };
395
- }
396
- return state;
397
- },
398
- [MERGE_HISTORY]: (state, action) => {
399
- const oldMessage = state.allMessagesByID[action.messageID];
400
- if (oldMessage) {
401
- return {
402
- ...state,
403
- allMessagesByID: {
404
- ...state.allMessagesByID,
405
- [action.messageID]: {
406
- ...oldMessage,
407
- history: merge({}, oldMessage.history, action.history)
408
- }
409
- }
410
- };
411
- }
412
- return state;
413
- },
414
- [ANNOUNCE_MESSAGE]: (state, action) => ({
415
- ...state,
416
- announceMessage: action.message
417
- }),
418
- [ACCEPTED_DISCLAIMER]: state => ({
419
- ...state,
420
- persistedToBrowserStorage: {
421
- ...state.persistedToBrowserStorage,
422
- chatState: {
423
- ...state.persistedToBrowserStorage.chatState,
424
- disclaimersAccepted: {
425
- ...state.persistedToBrowserStorage.chatState.disclaimersAccepted,
426
- [window.location.hostname]: true
427
- }
428
- }
429
- }
430
- }),
431
- [SET_HOME_SCREEN_IS_OPEN]: (state, {isOpen: isOpen}) => setHomeScreenOpenState(state, isOpen),
432
- [TOGGLE_HOME_SCREEN]: state => setHomeScreenOpenState(state, !state.persistedToBrowserStorage.chatState.homeScreenState.isHomeScreenOpen, true),
433
- [UPDATE_LAUNCHER_CONFIG]: (state, action) => {
434
- const newConfig = merge({}, state.launcher.config, action.launcherConfig);
435
- return {
436
- ...state,
437
- launcher: {
438
- ...state.launcher,
439
- config: newConfig
440
- },
441
- persistedToBrowserStorage: {
442
- ...state.persistedToBrowserStorage,
443
- launcherState: {
444
- ...state.persistedToBrowserStorage.launcherState,
445
- desktopLauncherIsExpanded: newConfig.is_on && newConfig.desktop.is_on ? state.persistedToBrowserStorage.launcherState.desktopLauncherIsExpanded : false,
446
- mobileLauncherIsExtended: newConfig.is_on && newConfig.mobile.is_on ? state.persistedToBrowserStorage.launcherState.mobileLauncherIsExtended : false
447
- }
448
- }
449
- };
450
- },
451
- [SET_LAUNCHER_PROPERTY]: (state, action) => ({
452
- ...state,
453
- persistedToBrowserStorage: {
454
- ...state.persistedToBrowserStorage,
455
- launcherState: {
456
- ...state.persistedToBrowserStorage.launcherState,
457
- [action.propertyName]: action.propertyValue
458
- }
459
- }
460
- }),
461
- [SET_LAUNCHER_CONFIG_PROPERTY]: (state, action) => {
462
- const newState = {
463
- ...state,
464
- launcher: {
465
- ...state.launcher,
466
- config: {
467
- ...state.launcher.config
468
- }
469
- }
470
- };
471
- if (!action.launcherType || action.launcherType === LauncherType.DESKTOP) {
472
- newState.launcher.config.desktop = {
473
- ...state.launcher.config.desktop,
474
- [action.propertyName]: action.propertyValue
475
- };
476
- }
477
- if (!action.launcherType || action.launcherType === LauncherType.MOBILE) {
478
- newState.launcher.config.mobile = {
479
- ...state.launcher.config.mobile,
480
- [action.propertyName]: action.propertyValue
481
- };
482
- }
483
- return newState;
484
- },
485
- [SET_CHAT_MESSAGES_PROPERTY]: (state, action) => applyBotMessageState(state, {
486
- [action.propertyName]: action.propertyValue
487
- }),
488
- [SET_LAUNCHER_MINIMIZED]: state => ({
489
- ...state,
490
- persistedToBrowserStorage: {
491
- ...state.persistedToBrowserStorage,
492
- launcherState: {
493
- ...state.persistedToBrowserStorage.launcherState,
494
- desktopLauncherIsExpanded: false,
495
- desktopLauncherWasMinimized: true
496
- }
497
- }
498
- }),
499
- [OPEN_IFRAME_CONTENT]: (state, {messageItem: messageItem}) => ({
500
- ...state,
501
- iFramePanelState: {
502
- ...state.iFramePanelState,
503
- messageItem: messageItem,
504
- isOpen: true
505
- },
506
- announceMessage: {
507
- messageID: "iframe_ariaOpenedPanel"
508
- }
509
- }),
510
- [CLOSE_IFRAME_PANEL]: state => ({
511
- ...state,
512
- iFramePanelState: {
513
- ...state.iFramePanelState,
514
- isOpen: false
515
- },
516
- announceMessage: {
517
- messageID: "iframe_ariaClosedPanel"
518
- }
519
- }),
520
- [SET_CONVERSATIONAL_SEARCH_CITATION_PANEL_IS_OPEN]: (state, action) => ({
521
- ...state,
522
- viewSourcePanelState: {
523
- ...state.viewSourcePanelState,
524
- citationItem: action.citationItem,
525
- relatedSearchResult: action.relatedSearchResult,
526
- isOpen: action.isOpen
527
- }
528
- }),
529
- [SET_CUSTOM_PANEL_OPEN]: (state, action) => ({
530
- ...state,
531
- customPanelState: {
532
- ...state.customPanelState,
533
- isOpen: action.isOpen
534
- }
535
- }),
536
- [SET_CUSTOM_PANEL_OPTIONS]: (state, action) => ({
537
- ...state,
538
- customPanelState: {
539
- ...state.customPanelState,
540
- options: action.options
541
- }
542
- }),
543
- [SET_TOUR_DATA]: (state, action) => {
544
- const newStateWithPersistedTourData = {
545
- ...state,
546
- persistedToBrowserStorage: {
547
- ...state.persistedToBrowserStorage,
548
- chatState: {
549
- ...state.persistedToBrowserStorage.chatState,
550
- persistedTourState: {
551
- activeTourID: action.newActiveTourMessageID,
552
- activeTourCurrentStepIndex: 0
553
- }
554
- },
555
- launcherState: {
556
- ...state.persistedToBrowserStorage.launcherState,
557
- activeTour: true
558
- }
559
- }
560
- };
561
- return populateTourStepItems(newStateWithPersistedTourData);
562
- },
563
- [CLEAR_TOUR_DATA]: state => clearTourState(state),
564
- [CHANGE_STEP_IN_TOUR]: (state, action) => ({
565
- ...state,
566
- persistedToBrowserStorage: {
567
- ...state.persistedToBrowserStorage,
568
- chatState: {
569
- ...state.persistedToBrowserStorage.chatState,
570
- persistedTourState: {
571
- ...state.persistedToBrowserStorage.chatState.persistedTourState,
572
- activeTourCurrentStepIndex: Math.max(Math.min(action.newStepNumber, state.tourState.activeTourStepItems.length - 1), 0)
573
- }
574
- }
575
- }
576
- }),
577
- [UPDATE_INPUT_STATE]: (state, action) => {
578
- const currentInputState = getInputState(state, action.isInputToAgent);
579
- const newInputState = {
580
- ...currentInputState,
581
- ...action.newState
582
- };
583
- const newState = applyInputState(state, newInputState, action.isInputToAgent);
584
- return newState;
585
- },
586
- [SET_IS_BROWSER_PAGE_VISIBLE]: (state, action) => {
587
- let numUnreadMessages;
588
- const isMainWindowOpen = state.persistedToBrowserStorage.launcherState.viewState.mainWindow;
589
- if (isMainWindowOpen && action.isVisible) {
590
- numUnreadMessages = 0;
591
- } else {
592
- numUnreadMessages = state.agentState.numUnreadMessages;
593
- }
594
- return {
595
- ...state,
596
- isBrowserPageVisible: action.isVisible,
597
- agentState: {
598
- ...state.agentState,
599
- numUnreadMessages: numUnreadMessages
600
- }
601
- };
602
- },
603
- [ADD_INPUT_FILE]: (state, {file: file, isInputToAgent: isInputToAgent}) => {
604
- const currentInputState = getInputState(state, isInputToAgent);
605
- return applyInputState(state, {
606
- ...currentInputState,
607
- files: [ ...currentInputState.files, file ]
608
- }, isInputToAgent);
609
- },
610
- [REMOVE_INPUT_FILE]: (state, {fileID: fileID, isInputToAgent: isInputToAgent}) => {
611
- const currentInputState = getInputState(state, isInputToAgent);
612
- const newUploads = [ ...currentInputState.files ];
613
- const index = newUploads.findIndex(file => file.id === fileID);
614
- if (index !== -1) {
615
- newUploads.splice(index, 1);
616
- }
617
- return applyInputState(state, {
618
- ...currentInputState,
619
- files: newUploads
620
- }, isInputToAgent);
621
- },
622
- [REMOVE_LOCAL_MESSAGE_ITEM]: (state, {localMessageItemID: localMessageItemID}) => {
623
- const newLocalMessageIDs = state.botMessageState.localMessageIDs.filter(id => id !== localMessageItemID);
624
- const allMessageItemsByID = {
625
- ...state.allMessageItemsByID
626
- };
627
- if (allMessageItemsByID[localMessageItemID]) {
628
- delete allMessageItemsByID[localMessageItemID];
629
- }
630
- return {
631
- ...state,
632
- allMessageItemsByID: allMessageItemsByID,
633
- botMessageState: {
634
- ...state.botMessageState,
635
- localMessageIDs: newLocalMessageIDs
636
- }
637
- };
638
- },
639
- [ADD_NOTIFICATION]: (state, {notification: notification, notificationID: notificationID}) => ({
640
- ...state,
641
- notifications: state.notifications.concat({
642
- id: notificationID,
643
- notification: notification
644
- })
645
- }),
646
- [REMOVE_NOTIFICATIONS]: (state, {groupID: groupID, notificationID: notificationID}) => ({
647
- ...state,
648
- notifications: state.notifications.filter(notification => {
649
- if (notificationID) {
650
- return notification.id !== notificationID;
651
- }
652
- return notification.notification.groupID !== groupID;
653
- })
654
- }),
655
- [REMOVE_ALL_NOTIFICATIONS]: state => ({
656
- ...state,
657
- notifications: []
658
- }),
659
- [CLEAR_INPUT_FILES]: (state, {isInputToAgent: isInputToAgent}) => {
660
- const currentInputState = getInputState(state, isInputToAgent);
661
- return applyInputState(state, {
662
- ...currentInputState,
663
- files: []
664
- }, isInputToAgent);
665
- },
666
- [FILE_UPLOAD_INPUT_ERROR]: (state, {fileID: fileID, errorMessage: errorMessage, isInputToAgent: isInputToAgent}) => {
667
- const currentInputSate = getInputState(state, isInputToAgent);
668
- const newUploads = [ ...currentInputSate.files ];
669
- const index = newUploads.findIndex(file => file.id === fileID);
670
- if (index !== -1) {
671
- newUploads[index] = {
672
- ...newUploads[index],
673
- isError: true,
674
- errorMessage: errorMessage,
675
- status: FileStatusValue.COMPLETE
676
- };
677
- }
678
- return applyInputState(state, {
679
- ...currentInputSate,
680
- files: newUploads
681
- }, isInputToAgent);
682
- },
683
- [ADD_NESTED_MESSAGES]: (state, {localMessageItems: localMessageItems}) => {
684
- const allMessageItemsByID = {
685
- ...state.allMessageItemsByID
686
- };
687
- localMessageItems.forEach(localMessageItem => {
688
- allMessageItemsByID[localMessageItem.ui_state.id] = localMessageItem;
689
- });
690
- return {
691
- ...state,
692
- allMessageItemsByID: allMessageItemsByID
693
- };
694
- },
695
- [SET_RESPONSE_PANEL_IS_OPEN]: (state, {isOpen: isOpen}) => ({
696
- ...state,
697
- responsePanelState: {
698
- ...state.responsePanelState,
699
- isOpen: isOpen
700
- }
701
- }),
702
- [SET_RESPONSE_PANEL_CONTENT]: (state, {localMessageItem: localMessageItem, isMessageForInput: isMessageForInput}) => ({
703
- ...state,
704
- responsePanelState: {
705
- ...state.responsePanelState,
706
- localMessageItem: localMessageItem,
707
- isMessageForInput: isMessageForInput
708
- }
709
- }),
710
- [STREAMING_START]: (state, {messageID: messageID}) => {
711
- const streamIntoResponse = {
712
- id: messageID,
713
- output: {
714
- generic: []
715
- },
716
- history: {
717
- timestamp: Date.now()
718
- }
719
- };
720
- return applyFullMessage(state, streamIntoResponse);
721
- },
722
- [STREAMING_MERGE_HISTORY]: (state, {messageID: messageID, history: history}) => {
723
- const existingMessage = state.allMessagesByID[messageID];
724
- const newMessage = merge({}, existingMessage, {
725
- history: history
726
- });
727
- if (existingMessage) {
728
- return {
729
- ...state,
730
- allMessagesByID: {
731
- ...state.allMessagesByID,
732
- [messageID]: newMessage
733
- }
734
- };
735
- }
736
- return state;
737
- },
738
- [STREAMING_ADD_CHUNK]: (state, {chunkItem: chunkItem, fullMessageID: fullMessageID, isCompleteItem: isCompleteItem, disableFadeAnimation: disableFadeAnimation}) => {
739
- const message = state.allMessagesByID[fullMessageID];
740
- const localItemID = streamItemID(fullMessageID, chunkItem);
741
- const existingLocalMessageItem = state.allMessageItemsByID[localItemID];
742
- let {localMessageIDs: localMessageIDs} = state.botMessageState;
743
- let newItem;
744
- if (!existingLocalMessageItem) {
745
- newItem = outputItemToLocalItem(chunkItem, message, false);
746
- newItem.ui_state.needsAnnouncement = false;
747
- newItem.ui_state.disableFadeAnimation = disableFadeAnimation;
748
- newItem.ui_state.isIntermediateStreaming = true;
749
- if (isCompleteItem) {
750
- newItem.ui_state.streamingState = {
751
- chunks: [],
752
- isDone: true
753
- };
754
- } else {
755
- newItem.ui_state.streamingState = {
756
- chunks: [ chunkItem ],
757
- isDone: false
758
- };
759
- }
760
- localMessageIDs = [ ...localMessageIDs, localItemID ];
761
- if (!newItem.item.response_type) {
762
- throw new Error(`New chunk item does not have a response_type: ${JSON.stringify(chunkItem)}`);
763
- }
764
- } else if (isCompleteItem) {
765
- newItem = outputItemToLocalItem(chunkItem, message, false);
766
- newItem.ui_state.needsAnnouncement = false;
767
- newItem.ui_state.disableFadeAnimation = disableFadeAnimation;
768
- newItem.ui_state.streamingState = {
769
- chunks: [],
770
- isDone: true
771
- };
772
- } else {
773
- newItem = {
774
- ...existingLocalMessageItem,
775
- ui_state: {
776
- ...existingLocalMessageItem?.ui_state,
777
- streamingState: {
778
- ...existingLocalMessageItem?.ui_state.streamingState,
779
- chunks: [ ...existingLocalMessageItem?.ui_state.streamingState?.chunks || [], chunkItem ]
780
- }
781
- }
782
- };
783
- }
784
- return {
785
- ...state,
786
- allMessageItemsByID: {
787
- ...state.allMessageItemsByID,
788
- [localItemID]: newItem
789
- },
790
- botMessageState: {
791
- ...state.botMessageState,
792
- localMessageIDs: localMessageIDs
793
- }
794
- };
795
- },
796
- [UPDATE_CHAT_HEADER_CONFIG]: (state, {chatHeaderConfig: chatHeaderConfig}) => ({
797
- ...state,
798
- chatHeaderState: {
799
- ...state.chatHeaderState,
800
- config: {
801
- ...state.chatHeaderState.config,
802
- ...chatHeaderConfig
803
- }
804
- }
805
- }),
806
- [UPDATE_MAX_VISIBLE_HEADER_OBJECTS]: (state, {maxTotal: maxTotal}) => ({
807
- ...state,
808
- chatHeaderState: {
809
- ...state.chatHeaderState,
810
- maxVisibleHeaderObjects: maxTotal
811
- }
812
- }),
813
- [SET_STOP_STREAMING_BUTTON_VISIBLE]: (state, {isVisible: isVisible}) => ({
814
- ...state,
815
- botInputState: {
816
- ...state.botInputState,
817
- stopStreamingButtonState: {
818
- ...state.botInputState.stopStreamingButtonState,
819
- isVisible: isVisible
820
- }
821
- }
822
- }),
823
- [SET_STOP_STREAMING_BUTTON_DISABLED]: (state, {isDisabled: isDisabled}) => ({
824
- ...state,
825
- botInputState: {
826
- ...state.botInputState,
827
- stopStreamingButtonState: {
828
- ...state.botInputState.stopStreamingButtonState,
829
- isDisabled: isDisabled
830
- }
831
- }
832
- }),
833
- [SET_STREAM_ID]: (state, {currentStreamID: currentStreamID}) => ({
834
- ...state,
835
- botInputState: {
836
- ...state.botInputState,
837
- stopStreamingButtonState: {
838
- ...state.botInputState.stopStreamingButtonState,
839
- currentStreamID: currentStreamID
840
- }
841
- }
842
- }),
843
- [UPDATE_MAIN_HEADER_AVATAR]: (state, {config: config}) => ({
844
- ...state,
845
- headerAvatarConfig: config
846
- })
847
- };
848
-
849
- function applyInputState(state, newInputState, isInputToAgent) {
850
- if (isInputToAgent) {
851
- return {
852
- ...state,
853
- agentState: {
854
- ...state.agentState,
855
- inputState: newInputState
856
- }
857
- };
858
- }
859
- return {
860
- ...state,
861
- botInputState: newInputState
862
- };
863
- }
864
-
865
- function getInputState(state, isInputToAgent) {
866
- return isInputToAgent ? state.agentState.inputState : state.botInputState;
867
- }
868
-
869
- Object.assign(reducers, agentReducers);
870
-
871
- export { reducers };