@carbon/ai-chat 0.4.0-rc.2 → 0.4.0-rc.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 (296) 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/dist/types/aiChatEntry.d.ts +4767 -0
  50. package/package.json +5 -4
  51. package/dist/es/chat/dynamic-imports/dynamic-imports.js +0 -96
  52. package/dist/es/chat/react/components/AppContainer.js +0 -197
  53. package/dist/es/chat/react/components/UserDefinedResponsePortalsContainer.js +0 -31
  54. package/dist/es/chat/react/components/WriteableElementsPortalsContainer.js +0 -28
  55. package/dist/es/chat/react/components/chainOfThought/ChainOfThought.js +0 -20
  56. package/dist/es/chat/react/components/chatHeader/ChatHeaderAvatar.js +0 -20
  57. package/dist/es/chat/react/components/chatHeader/ChatHeaderLink.js +0 -22
  58. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenu.js +0 -27
  59. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuButton.js +0 -60
  60. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItem.js +0 -24
  61. package/dist/es/chat/react/components/chatHeader/ChatHeaderMenuItemRadioGroup.js +0 -28
  62. package/dist/es/chat/react/components/chatHeader/ChatHeaderOverflowMenu.js +0 -69
  63. package/dist/es/chat/react/components/chatHeader/ChatHeaderTitle.js +0 -22
  64. package/dist/es/chat/react/components/feedback/FeedbackButtonsComponent.js +0 -20
  65. package/dist/es/chat/react/components/feedback/FeedbackComponent.js +0 -20
  66. package/dist/es/chat/react/components/inlineLoading/InlineLoadingComponent.js +0 -20
  67. package/dist/es/chat/react/components/markdownText/MarkdownText.js +0 -20
  68. package/dist/es/chat/react/components/stopStreamingButton/StopStreamingButton.js +0 -20
  69. package/dist/es/chat/react/components/table/Table.js +0 -20
  70. package/dist/es/chat/shared/Chat.js +0 -115
  71. package/dist/es/chat/shared/ChatInstanceImpl.js +0 -360
  72. package/dist/es/chat/shared/chatEntryFunctions.js +0 -46
  73. package/dist/es/chat/shared/components/Avatar.js +0 -286
  74. package/dist/es/chat/shared/components/BodyWithFooterComponent.js +0 -56
  75. package/dist/es/chat/shared/components/CatastrophicError.js +0 -77
  76. package/dist/es/chat/shared/components/Chat.js +0 -244
  77. package/dist/es/chat/shared/components/ChatBubbleDark.js +0 -124
  78. package/dist/es/chat/shared/components/ChatBubbleLight.js +0 -216
  79. package/dist/es/chat/shared/components/Disclaimer.js +0 -86
  80. package/dist/es/chat/shared/components/ErrorIcon.js +0 -20
  81. package/dist/es/chat/shared/components/ErrorMessageDark.js +0 -89
  82. package/dist/es/chat/shared/components/ErrorMessageLight.js +0 -135
  83. package/dist/es/chat/shared/components/HydrationPanel.js +0 -58
  84. package/dist/es/chat/shared/components/LatestWelcomeNodes.js +0 -26
  85. package/dist/es/chat/shared/components/ResponseStopped.js +0 -19
  86. package/dist/es/chat/shared/components/SkeletonPicker.js +0 -32
  87. package/dist/es/chat/shared/components/WriteableElement.js +0 -22
  88. package/dist/es/chat/shared/components/agent/AgentAvatar.js +0 -54
  89. package/dist/es/chat/shared/components/agent/AgentBanner.js +0 -109
  90. package/dist/es/chat/shared/components/agent/AgentBannerContainer.js +0 -28
  91. package/dist/es/chat/shared/components/agent/AvailabilityMessage.js +0 -49
  92. package/dist/es/chat/shared/components/aria/AriaAnnouncerComponent.js +0 -122
  93. package/dist/es/chat/shared/components/aria/AriaAnnouncerProvider.js +0 -48
  94. package/dist/es/chat/shared/components/aria/AriaLiveMessage.js +0 -22
  95. package/dist/es/chat/shared/components/header/AISlug.js +0 -22
  96. package/dist/es/chat/shared/components/header/Header.js +0 -460
  97. package/dist/es/chat/shared/components/header/SimpleHeader.js +0 -27
  98. package/dist/es/chat/shared/components/homeScreen/HomeScreenContainer.js +0 -68
  99. package/dist/es/chat/shared/components/launcher/Launcher.js +0 -88
  100. package/dist/es/chat/shared/components/launcher/LauncherComplex.js +0 -63
  101. package/dist/es/chat/shared/components/launcher/LauncherContainer.js +0 -73
  102. package/dist/es/chat/shared/components/launcher/LauncherDesktopContainer.js +0 -221
  103. package/dist/es/chat/shared/components/launcher/LauncherExtended.js +0 -244
  104. package/dist/es/chat/shared/components/launcher/LauncherMobileContainer.js +0 -175
  105. package/dist/es/chat/shared/components/launcher/launcherUtils.js +0 -16
  106. package/dist/es/chat/shared/components/modals/ConfirmModal.js +0 -67
  107. package/dist/es/chat/shared/components/modals/EndAgentChatModal.js +0 -46
  108. package/dist/es/chat/shared/components/modals/RequestScreenShareModal.js +0 -43
  109. package/dist/es/chat/shared/components/notifications/Notifications.js +0 -58
  110. package/dist/es/chat/shared/components/panels/CustomPanel.js +0 -136
  111. package/dist/es/chat/shared/components/responseTypes/agent/ConnectToAgent.js +0 -30
  112. package/dist/es/chat/shared/components/responseTypes/agent/RealConnectToAgent.js +0 -102
  113. package/dist/es/chat/shared/components/responseTypes/audio/AudioComponent.js +0 -26
  114. package/dist/es/chat/shared/components/responseTypes/buttonItem/BaseButtonItemComponent.js +0 -69
  115. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemComponent.js +0 -48
  116. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemCustomEventComponent.js +0 -42
  117. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemPostBackComponent.js +0 -54
  118. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemShowPanelComponent.js +0 -36
  119. package/dist/es/chat/shared/components/responseTypes/buttonItem/ButtonItemURLComponent.js +0 -42
  120. package/dist/es/chat/shared/components/responseTypes/card/CardItemComponent.js +0 -34
  121. package/dist/es/chat/shared/components/responseTypes/carousel/CarouselItemComponent.js +0 -39
  122. package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearch.js +0 -92
  123. package/dist/es/chat/shared/components/responseTypes/conversationalSearch/ConversationalSearchText.js +0 -158
  124. package/dist/es/chat/shared/components/responseTypes/custom/UserDefinedResponse.js +0 -33
  125. package/dist/es/chat/shared/components/responseTypes/datePicker/DatePickerComponent.js +0 -176
  126. package/dist/es/chat/shared/components/responseTypes/error/InlineError.js +0 -32
  127. package/dist/es/chat/shared/components/responseTypes/grid/GridItemComponent.js +0 -109
  128. package/dist/es/chat/shared/components/responseTypes/iframe/IFrameMessage.js +0 -32
  129. package/dist/es/chat/shared/components/responseTypes/iframe/IFramePanel.js +0 -51
  130. package/dist/es/chat/shared/components/responseTypes/iframe/IFramePreviewCard.js +0 -64
  131. package/dist/es/chat/shared/components/responseTypes/iframe/InlineIFrame.js +0 -55
  132. package/dist/es/chat/shared/components/responseTypes/image/Image.js +0 -120
  133. package/dist/es/chat/shared/components/responseTypes/options/OptionComponent.js +0 -83
  134. package/dist/es/chat/shared/components/responseTypes/options/SelectComponent.js +0 -84
  135. package/dist/es/chat/shared/components/responseTypes/table/TableContainer.js +0 -96
  136. package/dist/es/chat/shared/components/responseTypes/text/TextArea.js +0 -68
  137. package/dist/es/chat/shared/components/responseTypes/tour/TourCard.js +0 -73
  138. package/dist/es/chat/shared/components/responseTypes/util/BodyMessageComponents.js +0 -65
  139. package/dist/es/chat/shared/components/responseTypes/util/ClickableImage.js +0 -36
  140. package/dist/es/chat/shared/components/responseTypes/util/Description.js +0 -21
  141. package/dist/es/chat/shared/components/responseTypes/util/FooterButtonComponents.js +0 -36
  142. package/dist/es/chat/shared/components/responseTypes/util/MediaPlayer.js +0 -157
  143. package/dist/es/chat/shared/components/responseTypes/util/Metablock.js +0 -27
  144. package/dist/es/chat/shared/components/responseTypes/util/RichText.js +0 -31
  145. package/dist/es/chat/shared/components/responseTypes/util/SearchResultBody.js +0 -53
  146. package/dist/es/chat/shared/components/responseTypes/util/StreamingRichText.js +0 -38
  147. package/dist/es/chat/shared/components/responseTypes/util/TextHolderTile.js +0 -35
  148. package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCard.js +0 -65
  149. package/dist/es/chat/shared/components/responseTypes/util/citations/CitationCardContent.js +0 -62
  150. package/dist/es/chat/shared/components/responseTypes/util/citations/CitationClickableCard.js +0 -23
  151. package/dist/es/chat/shared/components/responseTypes/util/citations/ExpandToPanelCard.js +0 -50
  152. package/dist/es/chat/shared/components/responseTypes/util/citations/ViewSourcePanel.js +0 -57
  153. package/dist/es/chat/shared/components/responseTypes/video/VideoComponent.js +0 -23
  154. package/dist/es/chat/shared/components/tour/TourCloseMinimizeComponent.js +0 -44
  155. package/dist/es/chat/shared/components/tour/TourContainer.js +0 -212
  156. package/dist/es/chat/shared/components/tour/TourControlsComponent.js +0 -98
  157. package/dist/es/chat/shared/components/tour/TourStepContentComponent.js +0 -156
  158. package/dist/es/chat/shared/components/tour/TourStepSkeletonComponent.js +0 -20
  159. package/dist/es/chat/shared/components/util/AnnounceOnMountComponent.js +0 -42
  160. package/dist/es/chat/shared/components/util/IconHolder.js +0 -16
  161. package/dist/es/chat/shared/components/util/ImageWithFallback.js +0 -31
  162. package/dist/es/chat/shared/components/util/MaybeDangerouslySetInnerHTML.js +0 -42
  163. package/dist/es/chat/shared/components/util/MountChildrenOnDelay.js +0 -40
  164. package/dist/es/chat/shared/components/util/VisuallyHidden.js +0 -18
  165. package/dist/es/chat/shared/containers/App.js +0 -181
  166. package/dist/es/chat/shared/containers/MessageComponent.js +0 -465
  167. package/dist/es/chat/shared/containers/MessageTypeComponent.js +0 -496
  168. package/dist/es/chat/shared/containers/MessagesComponent.js +0 -469
  169. package/dist/es/chat/shared/containers/ModalPortal.js +0 -53
  170. package/dist/es/chat/shared/containers/main/MainWindow.js +0 -708
  171. package/dist/es/chat/shared/contexts/AriaAnnouncerContext.js +0 -12
  172. package/dist/es/chat/shared/contexts/HideComponentContext.js +0 -12
  173. package/dist/es/chat/shared/contexts/LanguagePackContext.js +0 -12
  174. package/dist/es/chat/shared/contexts/ModalPortalRootContext.js +0 -12
  175. package/dist/es/chat/shared/contexts/ServiceManagerContext.js +0 -12
  176. package/dist/es/chat/shared/contexts/WindowSizeContext.js +0 -12
  177. package/dist/es/chat/shared/environmentVariables.js +0 -13
  178. package/dist/es/chat/shared/events/ChatActionsImpl.js +0 -783
  179. package/dist/es/chat/shared/events/EventBus.js +0 -161
  180. package/dist/es/chat/shared/hocs/withAriaAnnouncer.js +0 -25
  181. package/dist/es/chat/shared/hocs/withServiceManager.js +0 -25
  182. package/dist/es/chat/shared/hooks/useAriaAnnouncer.js +0 -16
  183. package/dist/es/chat/shared/hooks/useCSSCustomProperties.js +0 -21
  184. package/dist/es/chat/shared/hooks/useCallbackOnChange.js +0 -24
  185. package/dist/es/chat/shared/hooks/useEffectDidUpdate.js +0 -21
  186. package/dist/es/chat/shared/hooks/useLanguagePack.js +0 -16
  187. package/dist/es/chat/shared/hooks/usePrevious.js +0 -18
  188. package/dist/es/chat/shared/hooks/useServiceManager.js +0 -16
  189. package/dist/es/chat/shared/hooks/useShouldSanitizeHTML.js +0 -15
  190. package/dist/es/chat/shared/hooks/useUUID.js +0 -22
  191. package/dist/es/chat/shared/hooks/useWindowSize.js +0 -16
  192. package/dist/es/chat/shared/loadServices.js +0 -72
  193. package/dist/es/chat/shared/schema/historyToMessages.js +0 -231
  194. package/dist/es/chat/shared/schema/inputItemToLocalItem.js +0 -30
  195. package/dist/es/chat/shared/schema/outputItemToLocalItem.js +0 -124
  196. package/dist/es/chat/shared/services/CustomPanelInstance.js +0 -26
  197. package/dist/es/chat/shared/services/CustomPanelManager.js +0 -23
  198. package/dist/es/chat/shared/services/HistoryService.js +0 -59
  199. package/dist/es/chat/shared/services/MessageService.js +0 -351
  200. package/dist/es/chat/shared/services/NamespaceService.js +0 -26
  201. package/dist/es/chat/shared/services/ServiceManager.js +0 -19
  202. package/dist/es/chat/shared/services/UserSessionStorageService.js +0 -89
  203. package/dist/es/chat/shared/services/haa/agentStatusMessage.js +0 -108
  204. package/dist/es/chat/shared/services/haa/humanAgentUtils.js +0 -114
  205. package/dist/es/chat/shared/services/mockStorage.js +0 -30
  206. package/dist/es/chat/shared/store/agentActions.js +0 -125
  207. package/dist/es/chat/shared/store/agentReducers.js +0 -215
  208. package/dist/es/chat/shared/store/doCreateStore.js +0 -142
  209. package/dist/es/chat/shared/store/reducerUtils.js +0 -320
  210. package/dist/es/chat/shared/store/reducers.js +0 -871
  211. package/dist/es/chat/shared/store/subscriptions.js +0 -55
  212. package/dist/es/chat/shared/store/tourReducerUtils.js +0 -51
  213. package/dist/es/chat/shared/utils/ListenerList.js +0 -26
  214. package/dist/es/chat/shared/utils/PageObjectId.js +0 -25
  215. package/dist/es/chat/shared/utils/animationUtils.js +0 -77
  216. package/dist/es/chat/shared/utils/colors.js +0 -71
  217. package/dist/es/chat/shared/utils/customizers.js +0 -16
  218. package/dist/es/chat/shared/utils/dateUtils.js +0 -38
  219. package/dist/es/chat/shared/utils/homeScreenUtils.js +0 -27
  220. package/dist/es/chat/shared/utils/intlUtils.js +0 -21
  221. package/dist/es/chat/shared/utils/lang/arrayUtils.js +0 -53
  222. package/dist/es/chat/shared/utils/lang/langUtils.js +0 -13
  223. package/dist/es/chat/shared/utils/lang/objectUtils.js +0 -19
  224. package/dist/es/chat/shared/utils/lang/promiseUtils.js +0 -25
  225. package/dist/es/chat/shared/utils/lang/uuid.js +0 -16
  226. package/dist/es/chat/shared/utils/languages.js +0 -156
  227. package/dist/es/chat/shared/utils/memoizerUtils.js +0 -38
  228. package/dist/es/chat/shared/utils/messageServiceUtils.js +0 -36
  229. package/dist/es/chat/shared/utils/resolvablePromise.js +0 -32
  230. package/dist/es/chat/shared/utils/styleUtils.js +0 -231
  231. package/dist/es/chat/shared/utils/timeUtils.js +0 -14
  232. package/dist/es/chat/shared/utils/viewStateUtils.js +0 -38
  233. package/dist/es/chat/web-components/components/chainOfThought/cds-aichat-chain-of-thought.js +0 -26
  234. package/dist/es/chat/web-components/components/chainOfThought/src/ChainOfThoughtElement.js +0 -130
  235. package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.scss.js +0 -3
  236. package/dist/es/chat/web-components/components/chainOfThought/src/chainOfThoughtElement.template.js +0 -186
  237. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/cds-aichat-chat-header-avatar.js +0 -26
  238. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatar.template.js +0 -32
  239. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.js +0 -52
  240. package/dist/es/chat/web-components/components/chatHeader/chatHeaderAvatar/src/chatHeaderAvatarElement.scss.js +0 -3
  241. package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/cds-aichat-chat-header-link.js +0 -44
  242. package/dist/es/chat/web-components/components/chatHeader/chatHeaderLink/src/chatHeaderLinkElement.template.js +0 -28
  243. package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/cds-aichat-chat-header-title.js +0 -42
  244. package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.scss.js +0 -3
  245. package/dist/es/chat/web-components/components/chatHeader/chatHeaderTitle/src/chatHeaderTitle.template.js +0 -20
  246. package/dist/es/chat/web-components/components/codeElement/cds-aichat-code.js +0 -66
  247. package/dist/es/chat/web-components/components/feedbackButtonsElement/cds-aichat-feedback-buttons.js +0 -26
  248. package/dist/es/chat/web-components/components/feedbackButtonsElement/src/FeedbackButtonsElement.js +0 -93
  249. package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.scss.js +0 -3
  250. package/dist/es/chat/web-components/components/feedbackButtonsElement/src/feedbackButtonsElement.template.js +0 -84
  251. package/dist/es/chat/web-components/components/feedbackElement/cds-aichat-feedback.js +0 -30
  252. package/dist/es/chat/web-components/components/feedbackElement/src/FeedbackElement.js +0 -157
  253. package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.scss.js +0 -3
  254. package/dist/es/chat/web-components/components/feedbackElement/src/feedbackElement.template.js +0 -95
  255. package/dist/es/chat/web-components/components/inlineLoadingElement/cds-aichat-inline-loading.js +0 -85
  256. package/dist/es/chat/web-components/components/inlineLoadingElement/src/styles.scss.js +0 -3
  257. package/dist/es/chat/web-components/components/markdownText/cds-aichat-markdown-text.js +0 -32
  258. package/dist/es/chat/web-components/components/markdownText/markdown/markdownToHTML.js +0 -28
  259. package/dist/es/chat/web-components/components/markdownText/markdown/utils/renderTokenTree.js +0 -191
  260. package/dist/es/chat/web-components/components/markdownText/markdown/workers/workerManager.js +0 -16
  261. package/dist/es/chat/web-components/components/markdownText/src/MarkdownElement.js +0 -70
  262. package/dist/es/chat/web-components/components/markdownText/src/markdownElement.template.js +0 -19
  263. package/dist/es/chat/web-components/components/roundedButton/cds-aichat-rounded-button.js +0 -29
  264. package/dist/es/chat/web-components/components/stopStreamingButton/cds-aichat-stop-streaming-button.js +0 -26
  265. package/dist/es/chat/web-components/components/stopStreamingButton/src/StopStreamingButtonElement.js +0 -49
  266. package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.scss.js +0 -3
  267. package/dist/es/chat/web-components/components/stopStreamingButton/src/stopStreamingButton.template.js +0 -44
  268. package/dist/es/chat/web-components/components/table/cds-aichat-table.js +0 -229
  269. package/dist/es/chat/web-components/components/table/src/table.scss.js +0 -3
  270. package/dist/es/chat/web-components/components/table/src/table.template.js +0 -81
  271. package/dist/es/chat/web-components/components/table/src/tablePagination.template.js +0 -43
  272. package/dist/es/chat/web-components/components/table/src/tableSkeleton.template.js +0 -17
  273. package/dist/es/chat/web-components/components/tagListElement/cds-aichat-tag-list.js +0 -28
  274. package/dist/es/chat/web-components/components/tagListElement/src/TagListElement.js +0 -70
  275. package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.scss.js +0 -3
  276. package/dist/es/chat/web-components/components/tagListElement/src/tagListElement.template.js +0 -40
  277. package/dist/es/chat/web-components/decorators/customElement.js +0 -33
  278. package/dist/es/chat/web-components/internal/cds-aichat-internal.js +0 -78
  279. package/dist/es/chat/web-components/settings.js +0 -13
  280. package/dist/es/node_modules/@carbon/colors/es/index.js +0 -11
  281. package/dist/es/react/ChatContainer.js +0 -162
  282. package/dist/es/react/ChatCustomElement.js +0 -58
  283. package/dist/es/types/config/ChatHeaderConfig.js +0 -18
  284. package/dist/es/types/config/CornersType.js +0 -16
  285. package/dist/es/types/config/LauncherConfig.js +0 -19
  286. package/dist/es/types/config/PublicConfig.js +0 -36
  287. package/dist/es/types/instance/ChatInstance.js +0 -31
  288. package/dist/es/types/instance/apiTypes.js +0 -33
  289. package/dist/es/types/messaging/LocalMessageItem.js +0 -18
  290. package/dist/es/types/state/AppState.js +0 -18
  291. package/dist/es/types/utilities/Animation.js +0 -31
  292. package/dist/es/types/utilities/HasAddRemoveClassName.js +0 -27
  293. /package/dist/es/{chat/shared/styles/export.carbon.scss.js → chat.export.carbon.js} +0 -0
  294. /package/dist/es/{chat/shared/styles/export.scss.js → chat.export.js} +0 -0
  295. /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/markdown.js → chat.markdown.js} +0 -0
  296. /package/dist/es/{chat/web-components/components/markdownText/markdown/utils/tokenTree.js → chat.tokenTree.js} +0 -0
@@ -0,0 +1,3580 @@
1
+ import React, { useState, useCallback, Suspense, useMemo, useContext, useRef, useLayoutEffect, useEffect, Component } from "react";
2
+
3
+ import { e as isElement, h as isInputNode, j as isTextAreaNode, k as isImageNode, l as isTextNode, u as useServiceManager, b as usePrevious, m as doScrollElementIntoView } from "./chat.usePrevious.js";
4
+
5
+ import { c as addHTMLSupport, V as VisuallyHidden, e as enLanguagePack, M as MediaPlayerExport, I as ImageExport, S as SkeletonPlaceholder, d as loadDayjsLocale, u as useDynamicCSSProperties, g as createEnglishFormat, a as VideoComponentExport } from "./chat.VideoComponent.js";
6
+
7
+ import Attachment from "@carbon/icons-react/es/Attachment.js";
8
+
9
+ import { FormattedMessage, useIntl } from "react-intl";
10
+
11
+ import { useSelector, shallowEqual } from "react-redux";
12
+
13
+ import { c as carbonElement, B as BusEventType, M as MessageSendSource, a as TourStartReason, d as MainWindowCloseReason, F as FeedbackInteractionType } from "./chat.customElement.js";
14
+
15
+ import { createComponent } from "@lit/react";
16
+
17
+ import { __decorate } from "tslib";
18
+
19
+ import { LitElement, unsafeCSS, css, nothing, html, render } from "lit";
20
+
21
+ import { property, state } from "lit/decorators.js";
22
+
23
+ import "@carbon/web-components/es-custom/components/textarea/index.js";
24
+
25
+ import "@carbon/web-components/es-custom/components/icon-button/index.js";
26
+
27
+ import { toString } from "@carbon/icon-helpers";
28
+
29
+ import ThumbsDown16 from "@carbon/icons/es/thumbs-down/16.js";
30
+
31
+ import ThumbsDownFilled16 from "@carbon/icons/es/thumbs-down--filled/16.js";
32
+
33
+ import ThumbsUp16 from "@carbon/icons/es/thumbs-up/16.js";
34
+
35
+ import ThumbsUpFilled16 from "@carbon/icons/es/thumbs-up--filled/16.js";
36
+
37
+ import { unsafeSVG } from "lit/directives/unsafe-svg.js";
38
+
39
+ import { b as CSS_CLASS_PREFIX, W as WEB_COMPONENT_PREFIX, C as ConfirmModal, u as useUUID } from "./chat.Header.js";
40
+
41
+ import { k as lazyCarousel, V as ViewType } from "./chat.dynamic-imports.js";
42
+
43
+ import "@carbon/web-components/es-custom/components/tag/index.js";
44
+
45
+ import "@carbon/web-components/es-custom/components/chat-button/index.js";
46
+
47
+ import CDSButton from "@carbon/web-components/es-custom/components/button/button.js";
48
+
49
+ import { bind } from "bind-decorator";
50
+
51
+ import "@carbon/web-components/es-custom/components/button/index.js";
52
+
53
+ import "@carbon/web-components/es-custom/components/layer/index.js";
54
+
55
+ import cx from "classnames";
56
+
57
+ import { u as useLanguagePack } from "./chat.AppState.js";
58
+
59
+ import { v as hasServiceDesk, D as createMessageRequestForButtonItemOption, E as createMessageRequestForDate, g as getMediaDimensions, C as createMessageRequestForChoice, F as getOptionType, a as isRequest, b as isResponse, G as isTextItem, H as renderAsTour, r as renderAsUserDefinedMessage } from "./chat.messageUtils.js";
60
+
61
+ import Checkmark from "@carbon/icons-react/es/Checkmark.js";
62
+
63
+ import Headset from "@carbon/icons-react/es/Headset.js";
64
+
65
+ import HelpDesk from "@carbon/icons-react/es/HelpDesk.js";
66
+
67
+ import Logout from "@carbon/icons-react/es/Logout.js";
68
+
69
+ import { Tile, Button, Link, OperationalTag, Layer, DatePicker, DatePickerInput, Dropdown, unstable__ChatButton, Theme } from "@carbon/react";
70
+
71
+ import { A as AgentsOnlineStatus } from "./chat.LocalMessageItem.js";
72
+
73
+ import { R as RichTextExport, g as getMarkdownWorker, r as renderTokenTree, M as MarkdownText } from "./chat.RichText.js";
74
+
75
+ import { b as MessageResponseTypes, B as ButtonItemKind, a as ButtonItemType, W as WidthOptions, I as IFrameItemDisplayOption, C as ChainOfThoughtStepStatus, c as InternalMessageRequestType } from "./chat.Messages.js";
76
+
77
+ import TouchInteraction from "@carbon/icons-react/es/TouchInteraction.js";
78
+
79
+ import Send from "@carbon/icons-react/es/Send.js";
80
+
81
+ import { a as actions } from "./chat.actions.js";
82
+
83
+ import { W as WA_CONSOLE_PREFIX, R as RIGHT_TO_LEFT_MARK, E as ENGLISH_US_DATE_FORMAT, T as THROW_ERROR, L as LIGHT_THEMES } from "./chat.constants.js";
84
+
85
+ import { b as consoleError, o as getResponsiveElementPaddingValue } from "./chat.miscUtils.js";
86
+
87
+ import ArrowRight from "@carbon/icons-react/es/ArrowRight.js";
88
+
89
+ import Launch from "@carbon/icons-react/es/Launch.js";
90
+
91
+ import { B as BodyWithFooterComponent } from "./chat.BodyWithFooterComponent.js";
92
+
93
+ import debounce from "lodash-es/debounce.js";
94
+
95
+ import { I as InlineError, u as useAriaAnnouncer } from "./chat.MountChildrenOnDelay.js";
96
+
97
+ import Link$1 from "@carbon/icons-react/es/Link.js";
98
+
99
+ import Maximize from "@carbon/icons-react/es/Maximize.js";
100
+
101
+ import { i as isValidURL, s as sanitizeHTML } from "./chat.htmlUtils.js";
102
+
103
+ import ChevronDown from "@carbon/icons-react/es/ChevronDown.js";
104
+
105
+ import ChevronUp from "@carbon/icons-react/es/ChevronUp.js";
106
+
107
+ import { u as useCounter } from "./chat.useCounter.js";
108
+
109
+ import dayjs from "dayjs";
110
+
111
+ import { u as useOnMount } from "./chat.useOnMount.js";
112
+
113
+ import { u as uuid, U as UUIDType } from "./chat.uuid.js";
114
+
115
+ import { a as selectInputState, s as selectAgentDisplayState } from "./chat.selectors.js";
116
+
117
+ import { g as getURLHostName } from "./chat.browserUtils.js";
118
+
119
+ import { I as IFrameComponent } from "./chat.IFrameComponent.js";
120
+
121
+ import { B as ButtonSizeEnum, a as ButtonKindEnum } from "./chat.carbonTypes.js";
122
+
123
+ import { stringify } from "csv-stringify/browser/esm/sync";
124
+
125
+ import "@carbon/web-components/es-custom/components/data-table/index.js";
126
+
127
+ import "@carbon/web-components/es-custom/components/checkbox/index.js";
128
+
129
+ import Download16 from "@carbon/icons/es/download/16.js";
130
+
131
+ import { repeat } from "lit-html/directives/repeat.js";
132
+
133
+ import "@carbon/web-components/es-custom/components/pagination/index.js";
134
+
135
+ import "@carbon/web-components/es-custom/components/select/index.js";
136
+
137
+ import "@carbon/web-components/es-custom/components/data-table/table-skeleton.js";
138
+
139
+ import Restart from "@carbon/icons-react/es/Restart.js";
140
+
141
+ import "@carbon/web-components/es-custom/components/inline-loading/index.js";
142
+
143
+ import CheckmarkFilled16 from "@carbon/icons/es/checkmark--filled/16.js";
144
+
145
+ import ChevronRight16 from "@carbon/icons/es/chevron--right/16.js";
146
+
147
+ import ErrorFilled16 from "@carbon/icons/es/error--filled/16.js";
148
+
149
+ import { p as parseUnknownDataToMarkdown } from "./chat.stringUtils.js";
150
+
151
+ /*
152
+ * Copyright IBM Corp. 2025
153
+ *
154
+ * This source code is licensed under the Apache-2.0 license found in the
155
+ * LICENSE file in the root directory of this source tree.
156
+ *
157
+ * @license
158
+ */ function isNil(value) {
159
+ return value === undefined || value === null;
160
+ }
161
+
162
+ /*
163
+ * Copyright IBM Corp. 2025
164
+ *
165
+ * This source code is licensed under the Apache-2.0 license found in the
166
+ * LICENSE file in the root directory of this source tree.
167
+ *
168
+ * @license
169
+ */ function AvailabilityMessage({availability: availability, fallbackText: fallbackText}) {
170
+ let availabilityKey;
171
+ let availabilityValues;
172
+ let availabilityText;
173
+ if (!isNil(availability?.estimated_wait_time)) {
174
+ availabilityKey = "agent_connectingMinutes";
175
+ availabilityValues = {
176
+ time: availability.estimated_wait_time
177
+ };
178
+ } else if (!isNil(availability?.position_in_queue)) {
179
+ availabilityKey = "agent_connectingQueue";
180
+ availabilityValues = {
181
+ position: availability.position_in_queue
182
+ };
183
+ } else if (availability?.message) {
184
+ availabilityText = availability.message;
185
+ } else {
186
+ availabilityText = fallbackText;
187
+ }
188
+ if (availabilityText) {
189
+ return React.createElement(RichTextExport, {
190
+ overrideSanitize: true,
191
+ text: availabilityText
192
+ });
193
+ }
194
+ return React.createElement(FormattedMessage, {
195
+ id: availabilityKey,
196
+ values: addHTMLSupport(availabilityValues)
197
+ });
198
+ }
199
+
200
+ /*
201
+ * Copyright IBM Corp. 2025
202
+ *
203
+ * This source code is licensed under the Apache-2.0 license found in the
204
+ * LICENSE file in the root directory of this source tree.
205
+ *
206
+ * @license
207
+ */ const ANNOUNCE_INPUT_TYPES = new Set([ "button", "date", "datetime-local", "email", "file", "month", "number", "range", "reset", "search", "submit", "tel", "text", "time", "url", "week" ]);
208
+
209
+ const ANNOUNCE_NODE_EXCLUDE_ATTRIBUTE = "data-wac-exclude-node-read";
210
+
211
+ class AriaAnnouncerComponent extends React.PureComponent {
212
+ constructor() {
213
+ super(...arguments);
214
+ this.ref1 = React.createRef();
215
+ this.ref2 = React.createRef();
216
+ this.useRef1 = true;
217
+ this.doAnnouncements = () => {
218
+ const strings = [];
219
+ this.pendingValues.forEach(elementToAnnounce => {
220
+ if (typeof elementToAnnounce === "string") {
221
+ strings.push(elementToAnnounce);
222
+ } else {
223
+ nodeToText(elementToAnnounce, strings);
224
+ }
225
+ });
226
+ const useElement = this.useRef1 ? this.ref1.current : this.ref2.current;
227
+ if (useElement) {
228
+ useElement.innerText = strings.join(" ");
229
+ const clearElement = this.useRef1 ? this.ref2.current : this.ref1.current;
230
+ clearElement.innerHTML = "";
231
+ }
232
+ this.useRef1 = !this.useRef1;
233
+ this.pendingValues = null;
234
+ };
235
+ }
236
+ announceValue(value) {
237
+ if (!value) {
238
+ return;
239
+ }
240
+ if (!this.pendingValues) {
241
+ this.pendingValues = [];
242
+ setTimeout(this.doAnnouncements, 250);
243
+ }
244
+ if (typeof value === "string" || hasNodeType(value)) {
245
+ this.pendingValues.push(value);
246
+ } else if (value.messageID) {
247
+ const formattedMessage = this.props.intl.formatMessage({
248
+ id: value.messageID
249
+ }, value.messageValues);
250
+ this.pendingValues.push(formattedMessage);
251
+ } else {
252
+ this.pendingValues.push(value.messageText);
253
+ }
254
+ }
255
+ render() {
256
+ return React.createElement(VisuallyHidden, {
257
+ className: "WACAriaAnnouncer"
258
+ }, React.createElement("div", {
259
+ ref: this.ref1,
260
+ "aria-live": "polite"
261
+ }), React.createElement("div", {
262
+ ref: this.ref2,
263
+ "aria-live": "polite"
264
+ }));
265
+ }
266
+ }
267
+
268
+ function nodeToText(node, strings) {
269
+ if (isElement(node)) {
270
+ if (window.getComputedStyle(node).display !== "none" && node.getAttribute("aria-hidden") !== "true" && !node.hasAttribute(ANNOUNCE_NODE_EXCLUDE_ATTRIBUTE)) {
271
+ trimAndPush(node.getAttribute("aria-label"), strings);
272
+ if (isInputNode(node) && ANNOUNCE_INPUT_TYPES.has(node.type.toLowerCase())) {
273
+ if (node.value === "") {
274
+ trimAndPush(node.placeholder, strings);
275
+ } else {
276
+ trimAndPush(node.value, strings);
277
+ }
278
+ } else if (isTextAreaNode(node)) {
279
+ if (node.value === "") {
280
+ trimAndPush(node.placeholder, strings);
281
+ }
282
+ } else if (isImageNode(node)) {
283
+ trimAndPush(node.alt, strings);
284
+ }
285
+ if (node.shadowRoot) {
286
+ node.shadowRoot.childNodes?.forEach(childNode => {
287
+ nodeToText(childNode, strings);
288
+ });
289
+ }
290
+ if (node.childNodes) {
291
+ node.childNodes.forEach(childNode => {
292
+ nodeToText(childNode, strings);
293
+ });
294
+ }
295
+ }
296
+ } else if (isTextNode(node)) {
297
+ trimAndPush(node.data, strings);
298
+ }
299
+ }
300
+
301
+ function trimAndPush(value, strings) {
302
+ if (value) {
303
+ value = value.trim();
304
+ if (value) {
305
+ strings.push(value.replaceAll("\n", " "));
306
+ }
307
+ }
308
+ }
309
+
310
+ function hasNodeType(value) {
311
+ return value.nodeType !== undefined;
312
+ }
313
+
314
+ var css_248z$4 = ".cds--aichat-feedback-buttons{\n display:flex;\n margin-block-start:0.5rem;\n}";
315
+
316
+ /*
317
+ * Copyright IBM Corp. 2025
318
+ *
319
+ * This source code is licensed under the Apache-2.0 license found in the
320
+ * LICENSE file in the root directory of this source tree.
321
+ *
322
+ * @license
323
+ */ class FeedbackButtonsElement extends LitElement {}
324
+
325
+ FeedbackButtonsElement.styles = css`
326
+ ${unsafeCSS(css_248z$4)}
327
+ `;
328
+
329
+ __decorate([ property({
330
+ type: Boolean,
331
+ attribute: "is-positive-open",
332
+ reflect: true
333
+ }) ], FeedbackButtonsElement.prototype, "isPositiveOpen", void 0);
334
+
335
+ __decorate([ property({
336
+ type: Boolean,
337
+ attribute: "is-negative-open",
338
+ reflect: true
339
+ }) ], FeedbackButtonsElement.prototype, "isNegativeOpen", void 0);
340
+
341
+ __decorate([ property({
342
+ type: Boolean,
343
+ attribute: "is-positive-selected",
344
+ reflect: true
345
+ }) ], FeedbackButtonsElement.prototype, "isPositiveSelected", void 0);
346
+
347
+ __decorate([ property({
348
+ type: Boolean,
349
+ attribute: "has-positive-details",
350
+ reflect: true
351
+ }) ], FeedbackButtonsElement.prototype, "hasPositiveDetails", void 0);
352
+
353
+ __decorate([ property({
354
+ type: Boolean,
355
+ attribute: "has-negative-details",
356
+ reflect: true
357
+ }) ], FeedbackButtonsElement.prototype, "hasNegativeDetails", void 0);
358
+
359
+ __decorate([ property({
360
+ type: Boolean,
361
+ attribute: "is-negative-selected",
362
+ reflect: true
363
+ }) ], FeedbackButtonsElement.prototype, "isNegativeSelected", void 0);
364
+
365
+ __decorate([ property({
366
+ type: Boolean,
367
+ attribute: "is-positive-disabled",
368
+ reflect: true
369
+ }) ], FeedbackButtonsElement.prototype, "isPositiveDisabled", void 0);
370
+
371
+ __decorate([ property({
372
+ type: Boolean,
373
+ attribute: "is-negative-disabled",
374
+ reflect: true
375
+ }) ], FeedbackButtonsElement.prototype, "isNegativeDisabled", void 0);
376
+
377
+ __decorate([ property({
378
+ type: String,
379
+ attribute: "positive-label",
380
+ reflect: true
381
+ }) ], FeedbackButtonsElement.prototype, "positiveLabel", void 0);
382
+
383
+ __decorate([ property({
384
+ type: String,
385
+ attribute: "negative-label",
386
+ reflect: true
387
+ }) ], FeedbackButtonsElement.prototype, "negativeLabel", void 0);
388
+
389
+ __decorate([ property({
390
+ type: String,
391
+ attribute: "panel-id",
392
+ reflect: true
393
+ }) ], FeedbackButtonsElement.prototype, "panelID", void 0);
394
+
395
+ __decorate([ property({
396
+ type: Object,
397
+ attribute: "on-click"
398
+ }) ], FeedbackButtonsElement.prototype, "onClick", void 0);
399
+
400
+ /*
401
+ * Copyright IBM Corp. 2025
402
+ *
403
+ * This source code is licensed under the Apache-2.0 license found in the
404
+ * LICENSE file in the root directory of this source tree.
405
+ *
406
+ * @license
407
+ */ const ThumbsDown16svg = toString(ThumbsDown16);
408
+
409
+ const ThumbsDownFilled16svg = toString(ThumbsDownFilled16);
410
+
411
+ const ThumbsUp16svg = toString(ThumbsUp16);
412
+
413
+ const ThumbsUpFilled16svg = toString(ThumbsUpFilled16);
414
+
415
+ function feedbackButtonsElementTemplate(customElementClass) {
416
+ const {isPositiveOpen: isPositiveOpen, isNegativeOpen: isNegativeOpen, isPositiveSelected: isPositiveSelected, isNegativeSelected: isNegativeSelected, hasPositiveDetails: hasPositiveDetails, hasNegativeDetails: hasNegativeDetails, isPositiveDisabled: isPositiveDisabled, isNegativeDisabled: isNegativeDisabled, positiveLabel: positiveLabel, negativeLabel: negativeLabel, panelID: panelID, onClick: onClick} = customElementClass;
417
+ return html`<div class="${CSS_CLASS_PREFIX}-feedback-buttons">
418
+ <cds-custom-icon-button
419
+ class="${CSS_CLASS_PREFIX}-feedback-buttons-positive"
420
+ size="sm"
421
+ align="top-left"
422
+ kind="ghost"
423
+ role="button"
424
+ disabled="${isPositiveDisabled || nothing}"
425
+ aria-expanded="${isPositiveDisabled || !hasPositiveDetails ? nothing : isPositiveOpen}"
426
+ aria-pressed="${isPositiveSelected || nothing}"
427
+ aria-controls="${panelID}-feedback-positive"
428
+ @click="${() => onClick(true)}"
429
+ >
430
+ <span slot="icon"
431
+ >${unsafeSVG(isPositiveSelected ? ThumbsUpFilled16svg : ThumbsUp16svg)}</span
432
+ >
433
+ <span slot="tooltip-content"
434
+ >${positiveLabel || enLanguagePack.feedback_positiveLabel}</span
435
+ >
436
+ </cds-custom-icon-button>
437
+ <cds-custom-icon-button
438
+ class="${CSS_CLASS_PREFIX}-feedback-buttons-negative"
439
+ size="sm"
440
+ align="top-left"
441
+ kind="ghost"
442
+ role="button"
443
+ disabled="${isNegativeDisabled || nothing}"
444
+ aria-expanded="${isNegativeDisabled || !hasNegativeDetails ? nothing : isNegativeOpen}"
445
+ aria-pressed="${isNegativeSelected || nothing}"
446
+ aria-controls="${panelID}-feedback-positive"
447
+ @click="${() => onClick(false)}"
448
+ >
449
+ <span slot="icon"
450
+ >${unsafeSVG(isNegativeSelected ? ThumbsDownFilled16svg : ThumbsDown16svg)}</span
451
+ >
452
+ <span slot="tooltip-content"
453
+ >${negativeLabel || enLanguagePack.feedback_negativeLabel}</span
454
+ >
455
+ </cds-custom-icon-button>
456
+ </div>`;
457
+ }
458
+
459
+ /*
460
+ * Copyright IBM Corp. 2025
461
+ *
462
+ * This source code is licensed under the Apache-2.0 license found in the
463
+ * LICENSE file in the root directory of this source tree.
464
+ *
465
+ * @license
466
+ */ const FEEDBACK_BUTTONS_COMPONENT_TAG_NAME = `cds-aichat-feedback-buttons`;
467
+
468
+ let CDSChatFeedbackButtonsElement = class CDSChatFeedbackButtonsElement extends FeedbackButtonsElement {
469
+ render() {
470
+ return feedbackButtonsElementTemplate(this);
471
+ }
472
+ };
473
+
474
+ CDSChatFeedbackButtonsElement = __decorate([ carbonElement(FEEDBACK_BUTTONS_COMPONENT_TAG_NAME) ], CDSChatFeedbackButtonsElement);
475
+
476
+ /*
477
+ * Copyright IBM Corp. 2025
478
+ *
479
+ * This source code is licensed under the Apache-2.0 license found in the
480
+ * LICENSE file in the root directory of this source tree.
481
+ *
482
+ * @license
483
+ */ const FeedbackButtonsComponent = createComponent({
484
+ tagName: FEEDBACK_BUTTONS_COMPONENT_TAG_NAME,
485
+ elementClass: CDSChatFeedbackButtonsElement,
486
+ react: React
487
+ });
488
+
489
+ var css_248z$3 = ".cds--aichat-tag-list-container{\n display:flex;\n flex-wrap:wrap;\n align-items:center;\n padding:0;\n margin:0;\n gap:0.5rem;\n list-style:none;\n}\n\n.cds--aichat-tag-list-item{\n box-sizing:border-box;\n padding:0.125rem;\n animation:fade-in 600ms forwards;\n font-size:var(--cds-chat-BASE-font-size-small);\n opacity:0;\n}\n\n@keyframes fade-in{\n from{\n opacity:0;\n }\n to{\n opacity:1;\n }\n}";
490
+
491
+ /*
492
+ * Copyright IBM Corp. 2025
493
+ *
494
+ * This source code is licensed under the Apache-2.0 license found in the
495
+ * LICENSE file in the root directory of this source tree.
496
+ *
497
+ * @license
498
+ */ class TagListElement extends LitElement {
499
+ constructor() {
500
+ super(...arguments);
501
+ this.selectedTags = new Set;
502
+ }
503
+ updated(changedProperties) {
504
+ if (changedProperties.has("initialSelectedTags")) {
505
+ this._setInitialValues(this.initialSelectedTags);
506
+ }
507
+ }
508
+ _setInitialValues(values) {
509
+ if (values) {
510
+ this.selectedTags = new Set(this.initialSelectedTags);
511
+ }
512
+ }
513
+ _handleTagClick(event) {
514
+ const tagValue = event.target.getAttribute("data-content");
515
+ const isSelected = this.selectedTags.has(tagValue);
516
+ if (isSelected) {
517
+ this.selectedTags.delete(tagValue);
518
+ } else {
519
+ this.selectedTags.add(tagValue);
520
+ }
521
+ this.onTagsChanged?.(Array.from(this.selectedTags));
522
+ this.requestUpdate();
523
+ }
524
+ }
525
+
526
+ TagListElement.styles = css`
527
+ ${unsafeCSS(css_248z$3)}
528
+ `;
529
+
530
+ __decorate([ property({
531
+ type: Array,
532
+ attribute: "tags"
533
+ }) ], TagListElement.prototype, "tags", void 0);
534
+
535
+ __decorate([ property({
536
+ type: Array,
537
+ attribute: "initial-selected-tags"
538
+ }) ], TagListElement.prototype, "initialSelectedTags", void 0);
539
+
540
+ __decorate([ property({
541
+ type: Boolean,
542
+ attribute: "multi-select"
543
+ }) ], TagListElement.prototype, "multiSelect", void 0);
544
+
545
+ __decorate([ property({
546
+ type: Object,
547
+ attribute: "on-tags-changed"
548
+ }) ], TagListElement.prototype, "onTagsChanged", void 0);
549
+
550
+ __decorate([ state() ], TagListElement.prototype, "selectedTags", void 0);
551
+
552
+ /*
553
+ * Copyright IBM Corp. 2025
554
+ *
555
+ * This source code is licensed under the Apache-2.0 license found in the
556
+ * LICENSE file in the root directory of this source tree.
557
+ *
558
+ * @license
559
+ */ function tagListElementTemplate(customElementClass) {
560
+ const {selectedTags: selectedTags, tags: tags, _handleTagClick: handleTagClick} = customElementClass;
561
+ return html`<div class="${CSS_CLASS_PREFIX}-tag-list">
562
+ ${html`<ul class="${CSS_CLASS_PREFIX}-tag-list-container">
563
+ ${tags.map(value => html`<li class="${CSS_CLASS_PREFIX}-tag-list-item}">
564
+ <cds-custom-chat-button
565
+ class="${CSS_CLASS_PREFIX}-tag-list-button"
566
+ kind="primary"
567
+ size="sm"
568
+ type="button"
569
+ is-quick-action
570
+ role="option"
571
+ aria-pressed="${selectedTags.has(value)}"
572
+ ?is-selected="${selectedTags.has(value)}"
573
+ data-content="${value}"
574
+ @click="${handleTagClick}"
575
+ >
576
+ ${value}
577
+ </cds-custom-chat-button>
578
+ </li>`)}
579
+ </div>`}
580
+ </div>`;
581
+ }
582
+
583
+ /*
584
+ * Copyright IBM Corp. 2025
585
+ *
586
+ * This source code is licensed under the Apache-2.0 license found in the
587
+ * LICENSE file in the root directory of this source tree.
588
+ *
589
+ * @license
590
+ */ const TAG_LIST_TAG_NAME = `${WEB_COMPONENT_PREFIX}-tag-list`;
591
+
592
+ let CDSTagListElement = class CDSTagListElement extends TagListElement {
593
+ render() {
594
+ return tagListElementTemplate(this);
595
+ }
596
+ };
597
+
598
+ CDSTagListElement = __decorate([ carbonElement(TAG_LIST_TAG_NAME) ], CDSTagListElement);
599
+
600
+ /*
601
+ * Copyright IBM Corp. 2025
602
+ *
603
+ * This source code is licensed under the Apache-2.0 license found in the
604
+ * LICENSE file in the root directory of this source tree.
605
+ *
606
+ * @license
607
+ */ const ROUNDED_BUTTON_TAG_NAME = `cds-aichat-rounded-button`;
608
+
609
+ const styles = `\n .cds-custom--btn {\n border-start-start-radius: var(--${ROUNDED_BUTTON_TAG_NAME}-top-left);\n border-start-end-radius: var(--${ROUNDED_BUTTON_TAG_NAME}-top-right);\n border-end-start-radius: var(--${ROUNDED_BUTTON_TAG_NAME}-bottom-left);\n border-end-end-radius: var(--${ROUNDED_BUTTON_TAG_NAME}-bottom-right);\n width: var(--${ROUNDED_BUTTON_TAG_NAME}-width);\n max-width: var(--${ROUNDED_BUTTON_TAG_NAME}-max-width);\n }`;
610
+
611
+ let CDSRoundedButtonElement = class CDSRoundedButtonElement extends CDSButton {};
612
+
613
+ CDSRoundedButtonElement.styles = css`
614
+ ${CDSButton.styles}
615
+ ${unsafeCSS(styles)}
616
+ `;
617
+
618
+ CDSRoundedButtonElement = __decorate([ carbonElement(ROUNDED_BUTTON_TAG_NAME) ], CDSRoundedButtonElement);
619
+
620
+ var css_248z$2 = ".cds--aichat-container{\n box-sizing:border-box;\n border:1px solid var(--cds-chat-bubble-border, #e0e0e0);\n border-radius:var(--cds-chat-BASE-border-radius-med);\n animation:fade-in 600ms forwards;\n background-color:var(--cds-chat-shell-background, #ffffff);\n container-type:inline-size;\n inline-size:100%;\n margin-block-start:0.25rem;\n}\n\n.cds--aichat-is-closed{\n display:none;\n}\n\n.cds--aichat-title-row{\n display:flex;\n margin-block-start:0.75rem;\n margin-inline:1rem 0.5rem;\n}\n\n.cds--aichat-title{\n flex:1;\n font-size:var(--cds-chat-BASE-font-size-xlarge);\n line-height:var(--cds-chat-BASE-line-height-xlarge);\n}\n\n.cds--aichat-close{\n margin-inline-start:0.5rem;\n}\n\n.cds--aichat-disclaimer,\n.cds--aichat-prompt{\n color:var(--cds-text-secondary, #525252);\n font-size:var(--cds-chat-BASE-font-size-small);\n line-height:var(--cds-chat-BASE-line-height-small);\n margin-block-start:0.5rem;\n margin-inline:1rem;\n}\n\n.cds--aichat-categories{\n margin-block-start:0.5rem;\n margin-inline:1rem;\n}\n\n.cds--aichat-feedback-text{\n margin-block-start:0.5rem;\n margin-inline:1rem;\n}\n\n.cds--aichat-buttons{\n display:flex;\n inline-size:100%;\n margin-block-start:1rem;\n}\n\n.cds--aichat-submit{\n flex:1;\n --cds-aichat-rounded-button-bottom-right:var(\n --cds-chat-BASE-border-radius-med\n );\n --cds-aichat-rounded-button-width:100%;\n --cds-aichat-rounded-button-max-width:100%;\n}\n\n.cds--aichat-cancel{\n flex:1;\n --cds-aichat-rounded-button-bottom-left:var(\n --cds-chat-BASE-border-radius-med\n );\n --cds-aichat-rounded-button-width:100%;\n --cds-aichat-rounded-button-max-width:100%;\n}\n\n@keyframes fade-in{\n from{\n opacity:0;\n }\n to{\n opacity:1;\n }\n}";
621
+
622
+ /*
623
+ * Copyright IBM Corp. 2025
624
+ *
625
+ * This source code is licensed under the Apache-2.0 license found in the
626
+ * LICENSE file in the root directory of this source tree.
627
+ *
628
+ * @license
629
+ */ class FeedbackElement extends LitElement {
630
+ constructor() {
631
+ super(...arguments);
632
+ this.showTextArea = true;
633
+ this.showPrompt = true;
634
+ }
635
+ updated(changedProperties) {
636
+ if (changedProperties.has("initialValues")) {
637
+ this._setInitialValues(this.initialValues);
638
+ }
639
+ }
640
+ _setInitialValues(values) {
641
+ if (values) {
642
+ this._textInput = values.text;
643
+ this._initialSelectedCategories = values.selectedCategories;
644
+ }
645
+ }
646
+ _handleTextInput(event) {
647
+ this._textInput = event.currentTarget.value;
648
+ }
649
+ _handleSubmit() {
650
+ this.onSubmit?.({
651
+ text: this._textInput,
652
+ selectedCategories: this._selectedCategories
653
+ });
654
+ }
655
+ _handleCancel() {
656
+ this.onClose?.();
657
+ }
658
+ _handleCategoryChange(selectedCategories) {
659
+ this._selectedCategories = selectedCategories;
660
+ }
661
+ }
662
+
663
+ FeedbackElement.styles = css`
664
+ ${unsafeCSS(css_248z$2)}
665
+ `;
666
+
667
+ __decorate([ property({
668
+ type: String,
669
+ attribute: "class",
670
+ reflect: true
671
+ }) ], FeedbackElement.prototype, "class", void 0);
672
+
673
+ __decorate([ property({
674
+ type: String,
675
+ reflect: true
676
+ }) ], FeedbackElement.prototype, "id", void 0);
677
+
678
+ __decorate([ property({
679
+ type: Boolean,
680
+ attribute: "is-open",
681
+ reflect: true
682
+ }) ], FeedbackElement.prototype, "isOpen", void 0);
683
+
684
+ __decorate([ property({
685
+ type: Boolean,
686
+ attribute: "is-readonly",
687
+ reflect: true
688
+ }) ], FeedbackElement.prototype, "isReadonly", void 0);
689
+
690
+ __decorate([ property({
691
+ type: Object,
692
+ attribute: "on-close"
693
+ }) ], FeedbackElement.prototype, "onClose", void 0);
694
+
695
+ __decorate([ property({
696
+ type: Object,
697
+ attribute: "on-submit"
698
+ }) ], FeedbackElement.prototype, "onSubmit", void 0);
699
+
700
+ __decorate([ property({
701
+ type: Object,
702
+ attribute: "initial-values",
703
+ reflect: true
704
+ }) ], FeedbackElement.prototype, "initialValues", void 0);
705
+
706
+ __decorate([ property({
707
+ type: String,
708
+ attribute: "title",
709
+ reflect: true
710
+ }) ], FeedbackElement.prototype, "title", void 0);
711
+
712
+ __decorate([ property({
713
+ type: String,
714
+ attribute: "prompt",
715
+ reflect: true
716
+ }) ], FeedbackElement.prototype, "prompt", void 0);
717
+
718
+ __decorate([ property({
719
+ type: Object,
720
+ attribute: "categories",
721
+ reflect: true
722
+ }) ], FeedbackElement.prototype, "categories", void 0);
723
+
724
+ __decorate([ property({
725
+ type: String,
726
+ attribute: "disclaimer",
727
+ reflect: true
728
+ }) ], FeedbackElement.prototype, "disclaimer", void 0);
729
+
730
+ __decorate([ property({
731
+ type: String,
732
+ attribute: "text-area-placeholder",
733
+ reflect: true
734
+ }) ], FeedbackElement.prototype, "placeholder", void 0);
735
+
736
+ __decorate([ property({
737
+ type: String,
738
+ attribute: "cancel-label",
739
+ reflect: true
740
+ }) ], FeedbackElement.prototype, "cancelLabel", void 0);
741
+
742
+ __decorate([ property({
743
+ type: String,
744
+ attribute: "submit-label",
745
+ reflect: true
746
+ }) ], FeedbackElement.prototype, "submitLabel", void 0);
747
+
748
+ __decorate([ property({
749
+ type: Boolean,
750
+ attribute: "show-text-area",
751
+ reflect: true
752
+ }) ], FeedbackElement.prototype, "showTextArea", void 0);
753
+
754
+ __decorate([ property({
755
+ type: Boolean,
756
+ attribute: "show-prompt",
757
+ reflect: true
758
+ }) ], FeedbackElement.prototype, "showPrompt", void 0);
759
+
760
+ __decorate([ state() ], FeedbackElement.prototype, "_textInput", void 0);
761
+
762
+ __decorate([ state() ], FeedbackElement.prototype, "_initialSelectedCategories", void 0);
763
+
764
+ __decorate([ state() ], FeedbackElement.prototype, "_selectedCategories", void 0);
765
+
766
+ __decorate([ bind ], FeedbackElement.prototype, "_handleCategoryChange", null);
767
+
768
+ /*
769
+ * Copyright IBM Corp. 2025
770
+ *
771
+ * This source code is licensed under the Apache-2.0 license found in the
772
+ * LICENSE file in the root directory of this source tree.
773
+ *
774
+ * @license
775
+ */ const MAX_TEXT_COUNT = 1e3;
776
+
777
+ function feedbackElementTemplate(customElementClass) {
778
+ const {_handleCancel: handleCancel, _handleSubmit: handleSubmit, _handleTextInput: handleTextInput, _initialSelectedCategories: initialSelectedCategories, _textInput: textInput, _handleCategoryChange: handleCategoryChange, id: id, isReadonly: isReadonly, isOpen: isOpen, title: title, prompt: prompt, placeholder: placeholder, categories: categories, disclaimer: disclaimer, showTextArea: showTextArea, showPrompt: showPrompt, submitLabel: submitLabel, cancelLabel: cancelLabel} = customElementClass;
779
+ return html`<div
780
+ class="${cx(`${CSS_CLASS_PREFIX}-container`, {
781
+ [`${CSS_CLASS_PREFIX}-is-closed`]: !isOpen
782
+ })}"
783
+ >
784
+ <div class="${CSS_CLASS_PREFIX}-title-row">
785
+ <div class="${CSS_CLASS_PREFIX}-title">
786
+ ${title || enLanguagePack.feedback_defaultTitle}
787
+ </div>
788
+ </div>
789
+ ${showPrompt ? html`<div class="${CSS_CLASS_PREFIX}-prompt">
790
+ ${prompt || enLanguagePack.feedback_defaultPrompt}
791
+ </div>` : ""}
792
+ ${categories?.length ? html`<div class="${CSS_CLASS_PREFIX}-categories">
793
+ <cds-aichat-tag-list
794
+ .tags=${categories}
795
+ .initialSelectedTags=${initialSelectedCategories}
796
+ .onTagsChanged=${handleCategoryChange}
797
+ >
798
+ </cds-aichat-tag-list>
799
+ </div>` : ""}
800
+ ${showTextArea ? html`<div class="${CSS_CLASS_PREFIX}-feedback-text">
801
+ <cds-custom-layer level="1">
802
+ <cds-custom-textarea
803
+ id="${id}-text-area"
804
+ value="${textInput}"
805
+ class="${CSS_CLASS_PREFIX}-feedback-text-area"
806
+ ?disabled="${isReadonly}"
807
+ placeholder="${placeholder || enLanguagePack.feedback_defaultPlaceholder}"
808
+ rows="3"
809
+ max-count="${MAX_TEXT_COUNT}"
810
+ @input=${handleTextInput}
811
+ ></cds-custom-textarea>
812
+ </cds-custom-layer>
813
+ </div>` : ""}
814
+ ${disclaimer ? html`<div class="${CSS_CLASS_PREFIX}-disclaimer">
815
+ <cds-aichat-markdown-text
816
+ markdown="${disclaimer}"
817
+ ></cds-aichat-markdown-text>
818
+ </div>` : ""}
819
+ <div class="${CSS_CLASS_PREFIX}-buttons">
820
+ <cds-aichat-rounded-button
821
+ class="${CSS_CLASS_PREFIX}-cancel"
822
+ disabled=${isReadonly || nothing}
823
+ size="lg"
824
+ kind="secondary"
825
+ @click=${handleCancel}
826
+ >
827
+ ${cancelLabel || enLanguagePack.feedback_cancelLabel}
828
+ </cds-aichat-rounded-button>
829
+ <cds-aichat-rounded-button
830
+ class="${CSS_CLASS_PREFIX}-submit"
831
+ disabled=${isReadonly || nothing}
832
+ size="lg"
833
+ @click=${handleSubmit}
834
+ >
835
+ ${submitLabel || enLanguagePack.feedback_submitLabel}
836
+ </cds-aichat-rounded-button>
837
+ </div>
838
+ </div>`;
839
+ }
840
+
841
+ /*
842
+ * Copyright IBM Corp. 2025
843
+ *
844
+ * This source code is licensed under the Apache-2.0 license found in the
845
+ * LICENSE file in the root directory of this source tree.
846
+ *
847
+ * @license
848
+ */ const FEEDBACK_COMPONENT_TAG_NAME = `cds-aichat-feedback`;
849
+
850
+ let CDSChatFeedbackElement = class CDSChatFeedbackElement extends FeedbackElement {
851
+ render() {
852
+ return feedbackElementTemplate(this);
853
+ }
854
+ };
855
+
856
+ CDSChatFeedbackElement = __decorate([ carbonElement(FEEDBACK_COMPONENT_TAG_NAME) ], CDSChatFeedbackElement);
857
+
858
+ /*
859
+ * Copyright IBM Corp. 2025
860
+ *
861
+ * This source code is licensed under the Apache-2.0 license found in the
862
+ * LICENSE file in the root directory of this source tree.
863
+ *
864
+ * @license
865
+ */ const FeedbackComponent = createComponent({
866
+ tagName: FEEDBACK_COMPONENT_TAG_NAME,
867
+ elementClass: CDSChatFeedbackElement,
868
+ react: React
869
+ });
870
+
871
+ /*
872
+ * Copyright IBM Corp. 2025
873
+ *
874
+ * This source code is licensed under the Apache-2.0 license found in the
875
+ * LICENSE file in the root directory of this source tree.
876
+ *
877
+ * @license
878
+ */ function ResponseStopped() {
879
+ const {messages_responseStopped: messages_responseStopped} = useLanguagePack();
880
+ return React.createElement("div", {
881
+ className: "WACResponseStopped"
882
+ }, messages_responseStopped);
883
+ }
884
+
885
+ /*
886
+ * Copyright IBM Corp. 2025
887
+ *
888
+ * This source code is licensed under the Apache-2.0 license found in the
889
+ * LICENSE file in the root directory of this source tree.
890
+ *
891
+ * @license
892
+ */ function EndAgentChatModal(props) {
893
+ const {onConfirm: onConfirm, onCancel: onCancel, title: title, message: message} = props;
894
+ const languagePack = useLanguagePack();
895
+ const serviceManager = useServiceManager();
896
+ const {isConnected: isConnected, isSuspended: isSuspended} = useSelector(state => state.persistedToBrowserStorage.chatState.agentState);
897
+ const useTitle = title || (isConnected ? languagePack.agent_endChat : languagePack.agent_confirmCancelRequestTitle);
898
+ const useMessage = message || (isConnected ? languagePack.agent_confirmEndChat : languagePack.agent_confirmCancelRequestMessage);
899
+ const cancelButtonLabel = languagePack.agent_confirmEndChatNo;
900
+ let confirmButtonLabel;
901
+ if (isSuspended) {
902
+ confirmButtonLabel = languagePack.agent_confirmEndSuspendedYes;
903
+ } else if (isConnected) {
904
+ confirmButtonLabel = languagePack.agent_confirmEndChatYes;
905
+ } else {
906
+ confirmButtonLabel = languagePack.agent_confirmCancelRequestYes;
907
+ }
908
+ return React.createElement(ConfirmModal, {
909
+ title: useTitle,
910
+ message: useMessage,
911
+ onConfirm: onConfirm,
912
+ onCancel: onCancel,
913
+ cancelButtonLabel: cancelButtonLabel,
914
+ confirmButtonLabel: confirmButtonLabel,
915
+ modalAnnounceMessage: useMessage,
916
+ serviceManager: serviceManager
917
+ });
918
+ }
919
+
920
+ /*
921
+ * Copyright IBM Corp. 2025
922
+ *
923
+ * This source code is licensed under the Apache-2.0 license found in the
924
+ * LICENSE file in the root directory of this source tree.
925
+ *
926
+ * @license
927
+ */ function RealConnectToAgent(props) {
928
+ const {languagePack: languagePack, localMessage: localMessage, originalMessage: originalMessage, disableUserInputs: disableUserInputs, serviceManager: serviceManager, agentState: agentState, requestFocus: requestFocus, agentDisplayState: agentDisplayState, persistedAgentState: persistedAgentState} = props;
929
+ const {activeLocalMessageID: activeLocalMessageID, availability: availability, isConnecting: isConnecting} = agentState;
930
+ const {isSuspended: isSuspended} = persistedAgentState;
931
+ const [showConfirmSuspended, setShowConfirmSuspended] = useState(false);
932
+ if (!isSuspended && showConfirmSuspended) {
933
+ setShowConfirmSuspended(false);
934
+ }
935
+ function doStartChat() {
936
+ if (isSuspended && !showConfirmSuspended) {
937
+ setShowConfirmSuspended(true);
938
+ } else {
939
+ setShowConfirmSuspended(false);
940
+ serviceManager.humanAgentService.startChat(localMessage, originalMessage);
941
+ setTimeout(requestFocus);
942
+ }
943
+ }
944
+ const noAgentsWereOnline = originalMessage.history.agent_availability === AgentsOnlineStatus.OFFLINE;
945
+ if (noAgentsWereOnline) {
946
+ const agentUnavailableMessage = localMessage.item.agent_unavailable?.message || languagePack.default_agent_unavailableMessage;
947
+ return React.createElement("div", null, agentUnavailableMessage);
948
+ }
949
+ const textFromMessage = localMessage.item.agent_available?.message || languagePack.default_agent_availableMessage;
950
+ let buttonIcon;
951
+ let buttonText;
952
+ let showDisabled = disableUserInputs || agentDisplayState.isConnectingOrConnected;
953
+ let messageToUser = textFromMessage;
954
+ if (localMessage.ui_state.id === activeLocalMessageID) {
955
+ showDisabled = true;
956
+ if (isConnecting) {
957
+ buttonIcon = Checkmark;
958
+ buttonText = languagePack.agent_cardButtonChatRequested;
959
+ messageToUser = React.createElement(AvailabilityMessage, {
960
+ availability: availability,
961
+ fallbackText: languagePack.agent_connectWaiting
962
+ });
963
+ } else {
964
+ buttonIcon = Headset;
965
+ buttonText = languagePack.agent_cardButtonConnected;
966
+ messageToUser = languagePack.agent_cardMessageConnected;
967
+ }
968
+ } else if (disableUserInputs) {
969
+ if (localMessage.ui_state.wasAgentChatEnded) {
970
+ buttonIcon = Logout;
971
+ buttonText = languagePack.agent_cardButtonChatEnded;
972
+ messageToUser = languagePack.agent_cardMessageChatEnded;
973
+ } else {
974
+ buttonIcon = Headset;
975
+ buttonText = languagePack.agent_startChat;
976
+ }
977
+ } else {
978
+ buttonIcon = HelpDesk;
979
+ buttonText = languagePack.agent_startChat;
980
+ }
981
+ return React.createElement(Tile, {
982
+ className: "WACConnectToAgent"
983
+ }, React.createElement("div", {
984
+ className: "WACConnectToAgent__Title"
985
+ }, React.createElement("span", null, languagePack.agent_chatTitle)), React.createElement("div", {
986
+ className: "WACConnectToAgent__Text"
987
+ }, messageToUser), React.createElement(Button, {
988
+ className: "WACConnectToAgent__RequestButton",
989
+ size: "md",
990
+ disabled: showDisabled,
991
+ onClick: doStartChat,
992
+ renderIcon: buttonIcon
993
+ }, buttonText), !showDisabled && isSuspended && React.createElement("div", {
994
+ className: "WACConnectToAgent__SuspendedWarning"
995
+ }, languagePack.agent_suspendedWarning), showConfirmSuspended && React.createElement(EndAgentChatModal, {
996
+ title: languagePack.agent_confirmSuspendedEndChatTitle,
997
+ message: languagePack.agent_confirmSuspendedEndChatMessage,
998
+ onConfirm: doStartChat,
999
+ onCancel: () => setShowConfirmSuspended(false)
1000
+ }));
1001
+ }
1002
+
1003
+ /*
1004
+ * Copyright IBM Corp. 2025
1005
+ *
1006
+ * This source code is licensed under the Apache-2.0 license found in the
1007
+ * LICENSE file in the root directory of this source tree.
1008
+ *
1009
+ * @license
1010
+ */ function ConnectToAgent(props) {
1011
+ const {languagePack: languagePack, localMessage: localMessage, originalMessage: originalMessage, config: config, serviceManager: serviceManager, disableUserInputs: disableUserInputs, agentState: agentState, requestFocus: requestFocus, agentDisplayState: agentDisplayState, persistedAgentState: persistedAgentState} = props;
1012
+ const childDisableUserInputs = disableUserInputs || !hasServiceDesk(config);
1013
+ return React.createElement("div", null, React.createElement(RealConnectToAgent, {
1014
+ localMessage: localMessage,
1015
+ originalMessage: originalMessage,
1016
+ languagePack: languagePack,
1017
+ serviceManager: serviceManager,
1018
+ disableUserInputs: childDisableUserInputs,
1019
+ agentState: agentState,
1020
+ persistedAgentState: persistedAgentState,
1021
+ agentDisplayState: agentDisplayState,
1022
+ requestFocus: requestFocus
1023
+ }));
1024
+ }
1025
+
1026
+ /*
1027
+ * Copyright IBM Corp. 2025
1028
+ *
1029
+ * This source code is licensed under the Apache-2.0 license found in the
1030
+ * LICENSE file in the root directory of this source tree.
1031
+ *
1032
+ * @license
1033
+ */ function AudioComponent({source: source, ...props}) {
1034
+ const isMixCloud = source?.startsWith("https://www.mixcloud.com");
1035
+ return React.createElement(MediaPlayerExport, {
1036
+ type: MessageResponseTypes.AUDIO,
1037
+ source: source,
1038
+ isMixcloud: isMixCloud,
1039
+ ...props
1040
+ });
1041
+ }
1042
+
1043
+ const AudioComponentExport = React.memo(AudioComponent);
1044
+
1045
+ /*
1046
+ * Copyright IBM Corp. 2025
1047
+ *
1048
+ * This source code is licensed under the Apache-2.0 license found in the
1049
+ * LICENSE file in the root directory of this source tree.
1050
+ *
1051
+ * @license
1052
+ */ function ClickableImage({buttonAltText: buttonAltText, isLink: isLink, target: target, disabled: disabled, onClick: onClick, ...imageProps}) {
1053
+ if (isLink) {
1054
+ return React.createElement("a", {
1055
+ className: "WACClickableImage",
1056
+ href: imageProps.displayURL,
1057
+ rel: "noopener noreferrer",
1058
+ target: target,
1059
+ onClick: onClick
1060
+ }, React.createElement(ImageExport, {
1061
+ ...imageProps
1062
+ }), buttonAltText && React.createElement(VisuallyHidden, null, buttonAltText));
1063
+ }
1064
+ return React.createElement("button", {
1065
+ className: "WACClickableImage",
1066
+ type: "button",
1067
+ onClick: onClick,
1068
+ disabled: disabled
1069
+ }, React.createElement(ImageExport, {
1070
+ ...imageProps
1071
+ }), buttonAltText && React.createElement(VisuallyHidden, null, buttonAltText));
1072
+ }
1073
+
1074
+ /*
1075
+ * Copyright IBM Corp. 2025
1076
+ *
1077
+ * This source code is licensed under the Apache-2.0 license found in the
1078
+ * LICENSE file in the root directory of this source tree.
1079
+ *
1080
+ * @license
1081
+ */ function BaseButtonItemComponent({className: className, label: label, kind: kind, url: url, target: target = "_blank", disabled: disabled, renderIcon: renderIcon, imageURL: imageURL, altText: altText, onClick: onClick}) {
1082
+ const {errors_imageSource: errors_imageSource} = useLanguagePack();
1083
+ const useAITheme = useSelector(state => state.theme.useAITheme);
1084
+ const text = label || url;
1085
+ const linkTarget = url ? target : undefined;
1086
+ if (imageURL) {
1087
+ return React.createElement(ClickableImage, {
1088
+ imageError: errors_imageSource,
1089
+ source: imageURL,
1090
+ target: target,
1091
+ title: label,
1092
+ displayURL: url,
1093
+ altText: altText,
1094
+ renderIcon: renderIcon,
1095
+ onClick: onClick,
1096
+ disabled: disabled,
1097
+ isLink: Boolean(url),
1098
+ useAITheme: useAITheme
1099
+ });
1100
+ }
1101
+ return React.createElement(Button, {
1102
+ className: cx("WACButtonItem", className),
1103
+ as: url ? "a" : undefined,
1104
+ kind: getButtonKind(kind),
1105
+ href: url,
1106
+ target: linkTarget,
1107
+ rel: url ? "noopener noreferrer" : undefined,
1108
+ disabled: disabled,
1109
+ renderIcon: renderIcon,
1110
+ onClick: onClick
1111
+ }, text);
1112
+ }
1113
+
1114
+ function getButtonKind(style) {
1115
+ switch (style) {
1116
+ case ButtonItemKind.LINK:
1117
+ case ButtonItemKind.TERTIARY:
1118
+ return "ghost";
1119
+
1120
+ case ButtonItemKind.DEFAULT:
1121
+ return "primary";
1122
+
1123
+ default:
1124
+ return style;
1125
+ }
1126
+ }
1127
+
1128
+ /*
1129
+ * Copyright IBM Corp. 2025
1130
+ *
1131
+ * This source code is licensed under the Apache-2.0 license found in the
1132
+ * LICENSE file in the root directory of this source tree.
1133
+ *
1134
+ * @license
1135
+ */ function ButtonItemCustomEventComponent({localMessageItem: localMessageItem, fullMessage: fullMessage}) {
1136
+ const serviceManager = useServiceManager();
1137
+ const messageItem = localMessageItem.item;
1138
+ const {ui_state: ui_state} = localMessageItem;
1139
+ const {image_url: image_url, alt_text: alt_text, label: label, kind: kind, value: value} = messageItem;
1140
+ const isDisabled = Boolean(value && ui_state.optionSelected);
1141
+ const onClickHandler = useCallback(async () => {
1142
+ await serviceManager.fire({
1143
+ type: BusEventType.MESSAGE_ITEM_CUSTOM,
1144
+ messageItem: messageItem,
1145
+ fullMessage: fullMessage
1146
+ });
1147
+ }, [ messageItem, serviceManager, fullMessage ]);
1148
+ return React.createElement(BaseButtonItemComponent, {
1149
+ imageURL: image_url,
1150
+ altText: alt_text,
1151
+ label: label,
1152
+ kind: kind,
1153
+ disabled: isDisabled,
1154
+ renderIcon: image_url && TouchInteraction || undefined,
1155
+ onClick: onClickHandler
1156
+ });
1157
+ }
1158
+
1159
+ /*
1160
+ * Copyright IBM Corp. 2025
1161
+ *
1162
+ * This source code is licensed under the Apache-2.0 license found in the
1163
+ * LICENSE file in the root directory of this source tree.
1164
+ *
1165
+ * @license
1166
+ */ function ButtonItemPostBackComponent({localMessageItem: localMessageItem, requestFocus: requestFocus, isMessageForInput: isMessageForInput}) {
1167
+ const serviceManager = useServiceManager();
1168
+ const messageItem = localMessageItem.item;
1169
+ const {ui_state: ui_state, fullMessageID: fullMessageID} = localMessageItem;
1170
+ const {image_url: image_url, alt_text: alt_text, label: label, kind: kind} = messageItem;
1171
+ const isDisabled = !isMessageForInput || Boolean(ui_state.optionSelected);
1172
+ const onClickHandler = useCallback(() => {
1173
+ const isInputAvailable = Boolean(messageItem.value?.input?.text || label);
1174
+ if (isInputAvailable) {
1175
+ const messageRequest = createMessageRequestForButtonItemOption(messageItem, fullMessageID);
1176
+ requestFocus();
1177
+ serviceManager.store.dispatch(actions.messageSetOptionSelected(ui_state.id, messageRequest));
1178
+ serviceManager.actions.sendWithCatch(messageRequest, MessageSendSource.POST_BACK_BUTTON);
1179
+ } else {
1180
+ consoleError(`${WA_CONSOLE_PREFIX} post_back button with label "${messageItem.label}" has no input message to send.`);
1181
+ }
1182
+ }, [ messageItem, label, fullMessageID, requestFocus, serviceManager.store, serviceManager.actions, ui_state.id ]);
1183
+ return React.createElement(BaseButtonItemComponent, {
1184
+ imageURL: image_url,
1185
+ altText: alt_text,
1186
+ label: label,
1187
+ kind: kind,
1188
+ onClick: onClickHandler,
1189
+ renderIcon: image_url && Send || undefined,
1190
+ disabled: isDisabled
1191
+ });
1192
+ }
1193
+
1194
+ /*
1195
+ * Copyright IBM Corp. 2025
1196
+ *
1197
+ * This source code is licensed under the Apache-2.0 license found in the
1198
+ * LICENSE file in the root directory of this source tree.
1199
+ *
1200
+ * @license
1201
+ */ function ButtonItemShowPanelComponent({localMessageItem: localMessageItem, isMessageForInput: isMessageForInput}) {
1202
+ const serviceManager = useServiceManager();
1203
+ const {image_url: image_url, alt_text: alt_text, label: label, kind: kind} = localMessageItem.item;
1204
+ const onClickHandler = useCallback(async () => {
1205
+ serviceManager.store.dispatch(actions.setResponsePanelIsOpen(true));
1206
+ serviceManager.store.dispatch(actions.setResponsePanelContent(localMessageItem, isMessageForInput));
1207
+ }, [ localMessageItem, isMessageForInput, serviceManager ]);
1208
+ return React.createElement(BaseButtonItemComponent, {
1209
+ className: "BaseButtonItemComponent__ShowPanel",
1210
+ imageURL: image_url,
1211
+ altText: alt_text,
1212
+ label: label,
1213
+ kind: kind,
1214
+ renderIcon: image_url && ArrowRight || undefined,
1215
+ onClick: onClickHandler
1216
+ });
1217
+ }
1218
+
1219
+ /*
1220
+ * Copyright IBM Corp. 2025
1221
+ *
1222
+ * This source code is licensed under the Apache-2.0 license found in the
1223
+ * LICENSE file in the root directory of this source tree.
1224
+ *
1225
+ * @license
1226
+ */ function ButtonItemURLComponent({localMessageItem: localMessageItem}) {
1227
+ const {image_url: image_url, alt_text: alt_text, url: url, target: target, label: label, kind: kind} = localMessageItem.item;
1228
+ if (!image_url && kind === ButtonItemKind.LINK) {
1229
+ return React.createElement("div", {
1230
+ className: "WAC__received--textContent WACButtonItem"
1231
+ }, React.createElement(Link, {
1232
+ className: "WACWidget__breakWord",
1233
+ href: url,
1234
+ target: target,
1235
+ rel: "noopener noreferrer",
1236
+ renderIcon: Launch
1237
+ }, label || url));
1238
+ }
1239
+ return React.createElement(BaseButtonItemComponent, {
1240
+ imageURL: image_url,
1241
+ altText: alt_text,
1242
+ label: label,
1243
+ kind: kind,
1244
+ url: url,
1245
+ target: target,
1246
+ renderIcon: Launch
1247
+ });
1248
+ }
1249
+
1250
+ /*
1251
+ * Copyright IBM Corp. 2025
1252
+ *
1253
+ * This source code is licensed under the Apache-2.0 license found in the
1254
+ * LICENSE file in the root directory of this source tree.
1255
+ *
1256
+ * @license
1257
+ */ function ButtonItemComponent(props) {
1258
+ switch (props.localMessageItem.item.button_type) {
1259
+ case ButtonItemType.URL:
1260
+ return React.createElement(ButtonItemURLComponent, {
1261
+ localMessageItem: props.localMessageItem
1262
+ });
1263
+
1264
+ case ButtonItemType.SHOW_PANEL:
1265
+ return React.createElement(ButtonItemShowPanelComponent, {
1266
+ localMessageItem: props.localMessageItem,
1267
+ isMessageForInput: props.isMessageForInput
1268
+ });
1269
+
1270
+ case ButtonItemType.CUSTOM_EVENT:
1271
+ return React.createElement(ButtonItemCustomEventComponent, {
1272
+ localMessageItem: props.localMessageItem,
1273
+ fullMessage: props.fullMessage
1274
+ });
1275
+
1276
+ default:
1277
+ return React.createElement(ButtonItemPostBackComponent, {
1278
+ localMessageItem: props.localMessageItem,
1279
+ requestFocus: props.requestFocus,
1280
+ isMessageForInput: props.isMessageForInput
1281
+ });
1282
+ }
1283
+ }
1284
+
1285
+ /*
1286
+ * Copyright IBM Corp. 2025
1287
+ *
1288
+ * This source code is licensed under the Apache-2.0 license found in the
1289
+ * LICENSE file in the root directory of this source tree.
1290
+ *
1291
+ * @license
1292
+ */ function CardItemComponent(props) {
1293
+ const {ignoreMaxWidth: ignoreMaxWidth} = props;
1294
+ const item = props.localMessageItem.item;
1295
+ return React.createElement(Tile, {
1296
+ className: cx("WACCardMessageComponent", {
1297
+ WACMaxWidthSmall: !ignoreMaxWidth && item.max_width === WidthOptions.SMALL,
1298
+ WACMaxWidthMedium: !ignoreMaxWidth && item.max_width === WidthOptions.MEDIUM,
1299
+ WACMaxWidthLarge: !ignoreMaxWidth && item.max_width === WidthOptions.LARGE
1300
+ })
1301
+ }, React.createElement(BodyWithFooterComponent, {
1302
+ ...props,
1303
+ renderMessageComponent: props.renderMessageComponent
1304
+ }));
1305
+ }
1306
+
1307
+ const CardComponentExport = React.memo(CardItemComponent);
1308
+
1309
+ /*
1310
+ * Copyright IBM Corp. 2025
1311
+ *
1312
+ * This source code is licensed under the Apache-2.0 license found in the
1313
+ * LICENSE file in the root directory of this source tree.
1314
+ *
1315
+ * @license
1316
+ */ const Carousel$1 = lazyCarousel();
1317
+
1318
+ function CarouselItemComponent(props) {
1319
+ const {localMessageItem: localMessageItem, fullMessage: fullMessage, isMessageForInput: isMessageForInput, requestFocus: requestFocus, renderMessageComponent: renderMessageComponent} = props;
1320
+ const allMessageItemsByID = useSelector(state => state.allMessageItemsByID);
1321
+ const {itemsLocalMessageItemIDs: itemsLocalMessageItemIDs} = localMessageItem.ui_state;
1322
+ return React.createElement(Suspense, {
1323
+ fallback: React.createElement(SkeletonPlaceholder, null)
1324
+ }, React.createElement(Carousel$1, null, itemsLocalMessageItemIDs.map(nestedLocalMessageItemID => {
1325
+ const localMessageItem = allMessageItemsByID[nestedLocalMessageItemID];
1326
+ return React.createElement(CardComponentExport, {
1327
+ key: nestedLocalMessageItemID,
1328
+ localMessageItem: localMessageItem,
1329
+ fullMessage: fullMessage,
1330
+ isMessageForInput: isMessageForInput,
1331
+ ignoreMaxWidth: true,
1332
+ requestFocus: requestFocus,
1333
+ renderMessageComponent: renderMessageComponent
1334
+ });
1335
+ })));
1336
+ }
1337
+
1338
+ /*
1339
+ * Copyright IBM Corp. 2025
1340
+ *
1341
+ * This source code is licensed under the Apache-2.0 license found in the
1342
+ * LICENSE file in the root directory of this source tree.
1343
+ *
1344
+ * @license
1345
+ */ function useCallbackOnChange(value, callback) {
1346
+ const doDebounced = useMemo(() => callback && debounce(callback, 100, {
1347
+ maxWait: 100,
1348
+ leading: true
1349
+ }), [ callback ]);
1350
+ if (usePrevious(value) !== value && callback) {
1351
+ setTimeout(doDebounced);
1352
+ }
1353
+ }
1354
+
1355
+ /*
1356
+ * Copyright IBM Corp. 2025
1357
+ *
1358
+ * This source code is licensed under the Apache-2.0 license found in the
1359
+ * LICENSE file in the root directory of this source tree.
1360
+ *
1361
+ * @license
1362
+ */ const WindowSizeContext = React.createContext(null);
1363
+
1364
+ /*
1365
+ * Copyright IBM Corp. 2025
1366
+ *
1367
+ * This source code is licensed under the Apache-2.0 license found in the
1368
+ * LICENSE file in the root directory of this source tree.
1369
+ *
1370
+ * @license
1371
+ */ function useWindowSize() {
1372
+ return useContext(WindowSizeContext);
1373
+ }
1374
+
1375
+ /*
1376
+ * Copyright IBM Corp. 2025
1377
+ *
1378
+ * This source code is licensed under the Apache-2.0 license found in the
1379
+ * LICENSE file in the root directory of this source tree.
1380
+ *
1381
+ * @license
1382
+ */ var CitationType;
1383
+
1384
+ (function(CitationType) {
1385
+ CitationType["URL"] = "url";
1386
+ CitationType["EXPAND_IF_NEEDED"] = "expand";
1387
+ })(CitationType || (CitationType = {}));
1388
+
1389
+ function CitationCardContent({citation: citation, type: type, setIsExpandable: setIsExpandable, isExpandable: isExpandable}) {
1390
+ const languagePack = useLanguagePack();
1391
+ const {width: width} = useWindowSize();
1392
+ const {conversationalSearch_viewSourceDocument: conversationalSearch_viewSourceDocument} = languagePack;
1393
+ const ref = useRef(null);
1394
+ const {text: text} = citation;
1395
+ useLayoutEffect(() => {
1396
+ if (ref.current && !isExpandable && setIsExpandable) {
1397
+ if (ref.current.clientHeight && ref.current.scrollHeight) {
1398
+ setIsExpandable(ref.current.clientHeight < ref.current.scrollHeight);
1399
+ }
1400
+ }
1401
+ }, [ text, isExpandable, setIsExpandable, width ]);
1402
+ let label;
1403
+ let icon;
1404
+ if (type === CitationType.URL && citation.url) {
1405
+ label = new URL(citation.url).hostname;
1406
+ icon = React.createElement(Link$1, {
1407
+ size: 16
1408
+ });
1409
+ } else if (isExpandable) {
1410
+ icon = React.createElement(Maximize, {
1411
+ size: 16
1412
+ });
1413
+ label = conversationalSearch_viewSourceDocument;
1414
+ }
1415
+ return React.createElement(React.Fragment, null, React.createElement("div", {
1416
+ className: "WACCitationCard_Header"
1417
+ }, React.createElement("div", {
1418
+ className: "WACCitationCard_Title WACWidget__textEllipsis"
1419
+ }, citation.title), React.createElement("div", {
1420
+ ref: ref,
1421
+ className: "WACCitationCard_Text"
1422
+ }, text)), React.createElement("div", {
1423
+ className: "WACCitationCard_Footer"
1424
+ }, (label || icon) && React.createElement(React.Fragment, null, React.createElement("div", {
1425
+ className: "WACCitationCard_Label WACWidget__textEllipsis"
1426
+ }, label), React.createElement("div", {
1427
+ className: "WACCitationCard_Icon"
1428
+ }, icon))));
1429
+ }
1430
+
1431
+ /*
1432
+ * Copyright IBM Corp. 2025
1433
+ *
1434
+ * This source code is licensed under the Apache-2.0 license found in the
1435
+ * LICENSE file in the root directory of this source tree.
1436
+ *
1437
+ * @license
1438
+ */ function CitationClickableCard({title: title, onClick: onClick, onSelectCitation: onSelectCitation, children: children, className: className}) {
1439
+ return React.createElement("button", {
1440
+ type: "button",
1441
+ className: `${className} WACCitationCard--clickable`,
1442
+ "aria-label": title,
1443
+ onClick: () => {
1444
+ onClick();
1445
+ onSelectCitation?.();
1446
+ },
1447
+ onFocus: onSelectCitation
1448
+ }, children);
1449
+ }
1450
+
1451
+ /*
1452
+ * Copyright IBM Corp. 2025
1453
+ *
1454
+ * This source code is licensed under the Apache-2.0 license found in the
1455
+ * LICENSE file in the root directory of this source tree.
1456
+ *
1457
+ * @license
1458
+ */ function ExpandToPanelCard({className: className, citation: citation, onSelectCitation: onSelectCitation, relatedSearchResult: relatedSearchResult}) {
1459
+ const serviceManager = useServiceManager();
1460
+ const {title: title} = citation;
1461
+ const [isExpandable, setIsExpandable] = useState(Boolean(relatedSearchResult?.body));
1462
+ function onViewSourcePanelButtonClick() {
1463
+ serviceManager.store.dispatch(actions.setViewSourcePanelIsOpen(true, citation, relatedSearchResult));
1464
+ }
1465
+ function renderTile(className) {
1466
+ return React.createElement(Tile, {
1467
+ className: className
1468
+ }, React.createElement(CitationCardContent, {
1469
+ citation: citation,
1470
+ type: CitationType.EXPAND_IF_NEEDED,
1471
+ setIsExpandable: setIsExpandable,
1472
+ isExpandable: isExpandable
1473
+ }));
1474
+ }
1475
+ if (isExpandable) {
1476
+ return React.createElement(CitationClickableCard, {
1477
+ className: className,
1478
+ title: title,
1479
+ onClick: onViewSourcePanelButtonClick,
1480
+ onSelectCitation: onSelectCitation
1481
+ }, renderTile());
1482
+ }
1483
+ return renderTile(className);
1484
+ }
1485
+
1486
+ /*
1487
+ * Copyright IBM Corp. 2025
1488
+ *
1489
+ * This source code is licensed under the Apache-2.0 license found in the
1490
+ * LICENSE file in the root directory of this source tree.
1491
+ *
1492
+ * @license
1493
+ */ function CitationCard({citation: citation, isSelected: isSelected, onSelectCitation: onSelectCitation, relatedSearchResult: relatedSearchResult}) {
1494
+ const {url: url} = citation;
1495
+ function getType() {
1496
+ if (url && isValidURL(url)) {
1497
+ return CitationType.URL;
1498
+ }
1499
+ return CitationType.EXPAND_IF_NEEDED;
1500
+ }
1501
+ const type = getType();
1502
+ const className = cx("WACCitationCard", {
1503
+ "WACCitationCard--selected": isSelected,
1504
+ "WACCitationCard--clickable": type === CitationType.URL,
1505
+ "WACCitationCard--url": type === CitationType.URL,
1506
+ "WACCitationCard--no-url": type !== CitationType.URL
1507
+ }, "WACWidget__textEllipsis");
1508
+ if (type === CitationType.URL) {
1509
+ return React.createElement("a", {
1510
+ className: className,
1511
+ href: url,
1512
+ target: "_blank",
1513
+ rel: "noopener noreferrer",
1514
+ onClick: onSelectCitation,
1515
+ onFocus: onSelectCitation
1516
+ }, React.createElement(Tile, null, React.createElement(CitationCardContent, {
1517
+ citation: citation,
1518
+ type: type
1519
+ })));
1520
+ }
1521
+ return React.createElement(ExpandToPanelCard, {
1522
+ citation: citation,
1523
+ className: className,
1524
+ onSelectCitation: onSelectCitation,
1525
+ relatedSearchResult: relatedSearchResult
1526
+ });
1527
+ }
1528
+
1529
+ const CitationCardExport = React.memo(CitationCard);
1530
+
1531
+ /*
1532
+ * Copyright IBM Corp. 2025
1533
+ *
1534
+ * This source code is licensed under the Apache-2.0 license found in the
1535
+ * LICENSE file in the root directory of this source tree.
1536
+ *
1537
+ * @license
1538
+ */ function templateToString(result) {
1539
+ const container = document.createElement("div");
1540
+ render(result, container);
1541
+ const htmlString = container.innerHTML;
1542
+ render(html``, container);
1543
+ return htmlString;
1544
+ }
1545
+
1546
+ async function processMarkdown(value, sanitzeHTML = false) {
1547
+ const tokenTree = await getMarkdownWorker(value, undefined);
1548
+ const html = templateToString(renderTokenTree(tokenTree, sanitzeHTML));
1549
+ return html;
1550
+ }
1551
+
1552
+ /*
1553
+ * Copyright IBM Corp. 2025
1554
+ *
1555
+ * This source code is licensed under the Apache-2.0 license found in the
1556
+ * LICENSE file in the root directory of this source tree.
1557
+ *
1558
+ * @license
1559
+ */ function ConversationalSearchText(props) {
1560
+ const {highlightCitation: highlightCitation, onToggleCitations: onToggleCitations, citationsOpen: citationsOpen, searchItem: searchItem, showCitationsToggle: showCitationsToggle} = props;
1561
+ const languagePack = useLanguagePack();
1562
+ const serviceManager = useServiceManager();
1563
+ const {streamingState: streamingState} = searchItem.ui_state;
1564
+ const toggleID = `WACConversationalSearchText-${useCounter()}${serviceManager.namespace.suffix}`;
1565
+ const [html, setHtml] = useState("");
1566
+ let text;
1567
+ if (streamingState && !streamingState.isDone) {
1568
+ text = streamingState.chunks.map(chunk => chunk.text).join("");
1569
+ } else {
1570
+ text = searchItem.item.text;
1571
+ }
1572
+ useEffect(() => {
1573
+ async function getHtml() {
1574
+ const newHtml = await createHTMLWithHighlights(text, highlightCitation);
1575
+ setHtml(newHtml);
1576
+ }
1577
+ getHtml();
1578
+ }, [ text, highlightCitation, showCitationsToggle ]);
1579
+ return React.createElement("div", {
1580
+ className: "WACConversationalSearchText"
1581
+ }, React.createElement(MarkdownText, {
1582
+ markdown: html,
1583
+ sanitizeHTML: false
1584
+ }), showCitationsToggle && React.createElement("div", {
1585
+ className: "WACConversationalSearchText__CitationsToggleContainer"
1586
+ }, React.createElement("div", {
1587
+ className: "WACConversationalSearchText__CitationsToggle"
1588
+ }, React.createElement(OperationalTag, {
1589
+ id: toggleID,
1590
+ onClick: onToggleCitations,
1591
+ "aria-expanded": citationsOpen,
1592
+ text: languagePack.conversationalSearch_citationsLabel,
1593
+ renderIcon: citationsOpen ? ChevronUp : ChevronDown,
1594
+ "aria-label": languagePack.conversationalSearch_toggleCitations
1595
+ }))));
1596
+ }
1597
+
1598
+ const HIGHLIGHT_TOKEN_START = "@@:wc-source:@@";
1599
+
1600
+ const HIGHLIGHT_TOKEN_END = "@@/:wc-source:@@";
1601
+
1602
+ const HIGHLIGHT_TOKEN_REGEXP = /@@\/?:wc-source:@@/g;
1603
+
1604
+ async function createHTMLWithHighlights(text, highlightCitation) {
1605
+ const ranges = highlightCitation?.ranges;
1606
+ if (ranges?.length) {
1607
+ const pieces = [];
1608
+ let startIndex = 0;
1609
+ ranges.forEach(range => {
1610
+ const beforeHighlight = text.substring(startIndex, range.start);
1611
+ const highlight = text.substring(range.start, range.end);
1612
+ pieces.push(beforeHighlight);
1613
+ pieces.push(HIGHLIGHT_TOKEN_START);
1614
+ pieces.push(highlight);
1615
+ pieces.push(HIGHLIGHT_TOKEN_END);
1616
+ startIndex = range.end;
1617
+ });
1618
+ const lastPiece = text.substring(startIndex, text.length);
1619
+ pieces.push(lastPiece);
1620
+ text = pieces.join("");
1621
+ }
1622
+ const md = await processMarkdown(text);
1623
+ const afterMarkdownHTML = sanitizeHTML(md);
1624
+ if (ranges) {
1625
+ try {
1626
+ const rootElement = document.createElement("div");
1627
+ rootElement.innerHTML = afterMarkdownHTML;
1628
+ if (ranges) {
1629
+ insertHighlights(rootElement, false);
1630
+ }
1631
+ return rootElement.innerHTML;
1632
+ } catch (error) {
1633
+ consoleError("An error occurred processing source highlights.", text, highlightCitation, error);
1634
+ }
1635
+ }
1636
+ return afterMarkdownHTML;
1637
+ }
1638
+
1639
+ function insertHighlights(parent, isInHighlight) {
1640
+ const childNodes = Array.from(parent.childNodes);
1641
+ childNodes.forEach(child => {
1642
+ if (child instanceof Text) {
1643
+ const text = child.textContent;
1644
+ const tokenMatches = Array.from(text.matchAll(HIGHLIGHT_TOKEN_REGEXP));
1645
+ if (!tokenMatches.length && !isInHighlight) ; else {
1646
+ let startIndex = 0;
1647
+ tokenMatches.forEach(match => {
1648
+ const isInHighlightHere = match[0] === HIGHLIGHT_TOKEN_END;
1649
+ const textContent = text.substring(startIndex, match.index);
1650
+ startIndex = match.index + match[0].length;
1651
+ addTextSegment(textContent, isInHighlightHere, parent, child);
1652
+ isInHighlight = !isInHighlightHere;
1653
+ });
1654
+ const lastText = text.substring(startIndex, text.length);
1655
+ addTextSegment(lastText, isInHighlight, parent, child);
1656
+ child.remove();
1657
+ }
1658
+ } else if (child instanceof Element) {
1659
+ child.getAttributeNames().forEach(name => {
1660
+ const value = child.getAttribute(name);
1661
+ if (value) {
1662
+ child.setAttribute(name, value.replaceAll(HIGHLIGHT_TOKEN_REGEXP, ""));
1663
+ }
1664
+ });
1665
+ }
1666
+ isInHighlight = insertHighlights(child, isInHighlight);
1667
+ });
1668
+ return isInHighlight;
1669
+ }
1670
+
1671
+ function addTextSegment(text, highlighted, parent, beforeChild) {
1672
+ if (text) {
1673
+ const textNode = document.createTextNode(text);
1674
+ if (highlighted && text.trim()) {
1675
+ const highlightNode = document.createElement("span");
1676
+ highlightNode.className = `WACConversationalSearchText--hasCitation`;
1677
+ highlightNode.appendChild(textNode);
1678
+ parent.insertBefore(highlightNode, beforeChild);
1679
+ } else {
1680
+ parent.insertBefore(textNode, beforeChild);
1681
+ }
1682
+ }
1683
+ }
1684
+
1685
+ const ConversationalSearchTextExport = React.memo(ConversationalSearchText);
1686
+
1687
+ /*
1688
+ * Copyright IBM Corp. 2025
1689
+ *
1690
+ * This source code is licensed under the Apache-2.0 license found in the
1691
+ * LICENSE file in the root directory of this source tree.
1692
+ *
1693
+ * @license
1694
+ */ const Carousel = lazyCarousel();
1695
+
1696
+ function ConversationalSearch({localMessageItem: localMessageItem, scrollElementIntoView: scrollElementIntoView, isStreamingError: isStreamingError, doAutoScroll: doAutoScroll}) {
1697
+ const [selectedCitationIndex, setSelectedCitationIndex] = useState(0);
1698
+ const [citationsOpen, setCitationsOpen] = useState(false);
1699
+ const scrollIntoViewArea = useRef();
1700
+ const swiperRef = useRef();
1701
+ const languagePack = useLanguagePack();
1702
+ const messageItem = localMessageItem.item;
1703
+ const sortedCitations = useMemo(() => sortCitations(messageItem.citations), [ messageItem.citations ]);
1704
+ function scrollCitations() {
1705
+ setTimeout(() => scrollElementIntoView(scrollIntoViewArea.current, 32, 64), 50);
1706
+ }
1707
+ useCallbackOnChange(localMessageItem.ui_state.streamingState?.chunks, doAutoScroll);
1708
+ function onSelectCitation(index) {
1709
+ setCitationsOpen(true);
1710
+ setSelectedCitationIndex(index);
1711
+ setTimeout(() => swiperRef.current?.swiper.slideTo(index));
1712
+ scrollCitations();
1713
+ }
1714
+ function onToggleCitations() {
1715
+ setCitationsOpen(!citationsOpen);
1716
+ if (!citationsOpen) {
1717
+ scrollCitations();
1718
+ }
1719
+ }
1720
+ function renderCitations() {
1721
+ const tiles = sortedCitations?.map((citation, index) => React.createElement(CitationCardExport, {
1722
+ key: index,
1723
+ citation: citation,
1724
+ isSelected: index === selectedCitationIndex,
1725
+ onSelectCitation: () => onSelectCitation(index),
1726
+ relatedSearchResult: messageItem.search_results?.[citation.search_result_idx]
1727
+ }));
1728
+ return React.createElement("div", {
1729
+ className: "WACConversationalSearch_Citations"
1730
+ }, React.createElement(Suspense, {
1731
+ fallback: React.createElement(SkeletonPlaceholder, null)
1732
+ }, React.createElement(Carousel, {
1733
+ swiperRef: swiperRef,
1734
+ initialSlide: selectedCitationIndex,
1735
+ onSlideChange: setSelectedCitationIndex
1736
+ }, tiles)));
1737
+ }
1738
+ return React.createElement("div", {
1739
+ className: "WACConversationalSearch"
1740
+ }, React.createElement(ConversationalSearchTextExport, {
1741
+ searchItem: localMessageItem,
1742
+ showCitationsToggle: Boolean(sortedCitations?.length),
1743
+ highlightCitation: citationsOpen ? sortedCitations?.[selectedCitationIndex] : null,
1744
+ onToggleCitations: onToggleCitations,
1745
+ citationsOpen: citationsOpen
1746
+ }), isStreamingError && React.createElement(InlineError, {
1747
+ text: languagePack.conversationalSearch_streamingIncomplete
1748
+ }), React.createElement("div", {
1749
+ ref: scrollIntoViewArea
1750
+ }, citationsOpen && renderCitations()));
1751
+ }
1752
+
1753
+ function sortCitations(citations) {
1754
+ if (!citations) {
1755
+ return null;
1756
+ }
1757
+ const withRanges = citations.filter(citation => citation.ranges?.length);
1758
+ const withoutRanges = citations.filter(citation => !citation.ranges?.length);
1759
+ return withRanges.concat(withoutRanges);
1760
+ }
1761
+
1762
+ /*
1763
+ * Copyright IBM Corp. 2025
1764
+ *
1765
+ * This source code is licensed under the Apache-2.0 license found in the
1766
+ * LICENSE file in the root directory of this source tree.
1767
+ *
1768
+ * @license
1769
+ */ function UserDefinedResponse(props) {
1770
+ const {doAutoScroll: doAutoScroll, isStreamingError: isStreamingError, streamingState: streamingState, serviceManager: serviceManager} = props;
1771
+ const languagePack = useLanguagePack();
1772
+ const userDefinedRegistryItem = serviceManager.actions.getOrCreateUserDefinedElement(props.localMessageID);
1773
+ useCallbackOnChange(streamingState?.chunks, doAutoScroll);
1774
+ return React.createElement("div", {
1775
+ className: "WAC__message-userDefinedResponse",
1776
+ "data-floating-menu-container": true
1777
+ }, React.createElement("slot", {
1778
+ name: userDefinedRegistryItem.slotName
1779
+ }), isStreamingError && React.createElement(InlineError, {
1780
+ text: languagePack.conversationalSearch_streamingIncomplete
1781
+ }));
1782
+ }
1783
+
1784
+ var UserDefinedResponse$1 = React.memo(UserDefinedResponse);
1785
+
1786
+ /*
1787
+ * Copyright IBM Corp. 2025
1788
+ *
1789
+ * This source code is licensed under the Apache-2.0 license found in the
1790
+ * LICENSE file in the root directory of this source tree.
1791
+ *
1792
+ * @license
1793
+ */ const UNWANTED_CHARACTERS_REGEX = new RegExp(`[ ${RIGHT_TO_LEFT_MARK}]|\\.$`, "g");
1794
+
1795
+ function sanitizeDateFormat(value) {
1796
+ let format = value.replace(UNWANTED_CHARACTERS_REGEX, "");
1797
+ if (!format.includes("mm")) {
1798
+ format = format.replace("m", "mm");
1799
+ }
1800
+ if (!format.includes("dd")) {
1801
+ format = format.replace("d", "dd");
1802
+ }
1803
+ return format;
1804
+ }
1805
+
1806
+ function toUserDateFormat(date, format) {
1807
+ const day = String(date.getDate()).padStart(2, "0");
1808
+ const month = String(date.getMonth() + 1).padStart(2, "0");
1809
+ const year = String(date.getFullYear());
1810
+ return format.replace("dd", day).replace("mm", month).replace("yyyy", year);
1811
+ }
1812
+
1813
+ function toAssistantDateFormat(date) {
1814
+ const day = String(date.getDate()).padStart(2, "0");
1815
+ const month = String(date.getMonth() + 1).padStart(2, "0");
1816
+ const year = String(date.getFullYear());
1817
+ return `${year}-${month}-${day}`;
1818
+ }
1819
+
1820
+ /*
1821
+ * Copyright IBM Corp. 2025
1822
+ *
1823
+ * This source code is licensed under the Apache-2.0 license found in the
1824
+ * LICENSE file in the root directory of this source tree.
1825
+ *
1826
+ * @license
1827
+ */ function DatePickerComponent(props) {
1828
+ const {localMessage: localMessage, disabled: disabled, scrollElementIntoView: scrollElementIntoView} = props;
1829
+ const serviceManager = useServiceManager();
1830
+ const intl = useIntl();
1831
+ const webChatLocale = useSelector(state => state.locale);
1832
+ const originalMessage = useSelector(state => state.allMessagesByID[localMessage.fullMessageID]);
1833
+ const uuidRef = useRef(uuid(UUIDType.MISCELLANEOUS));
1834
+ const [isCalendarOpen, setIsCalendarOpen] = useState(false);
1835
+ const [userDisplayValue, setUserDisplayValue] = useState();
1836
+ const [flatpickrFormat, setFlatpickrFormat] = useState();
1837
+ const [userDisplayFormat, setUserDisplayFormat] = useState();
1838
+ const [flatpickrLocale, setFlatpickrLocale] = useState();
1839
+ const [dayjsLocale, setDayjsLocale] = useState();
1840
+ const [datePickerHostElement, setDatePickerHostElement] = useState();
1841
+ const valueForAssistantRef = useRef();
1842
+ const isInputPointerDownEventFiredRef = useRef(false);
1843
+ const inputLabel = intl.formatMessage({
1844
+ id: "datePicker_chooseDate"
1845
+ }, {
1846
+ format: userDisplayFormat
1847
+ });
1848
+ const confirmButtonLabel = intl.formatMessage({
1849
+ id: "datePicker_confirmDate"
1850
+ });
1851
+ const isDateInfoReady = Boolean(flatpickrFormat && userDisplayFormat && flatpickrLocale && dayjsLocale);
1852
+ function setDateInfoForLocale(locale) {
1853
+ const format = dayjs.Ls[locale]?.formats?.L?.toLocaleLowerCase() || ENGLISH_US_DATE_FORMAT;
1854
+ const dateFormat = sanitizeDateFormat(format);
1855
+ setDayjsLocale(locale);
1856
+ setFlatpickrLocale(calcFlatpickrLocale(locale));
1857
+ setUserDisplayFormat(dateFormat);
1858
+ setFlatpickrFormat(getFlatpickrDateFormat(dateFormat));
1859
+ }
1860
+ const handlerSendDate = useCallback(() => {
1861
+ const {ui_state: ui_state, fullMessageID: responseID} = localMessage;
1862
+ const localMessageID = ui_state.id;
1863
+ const request = createMessageRequestForDate(valueForAssistantRef.current, userDisplayValue, responseID);
1864
+ serviceManager.actions.sendWithCatch(request, MessageSendSource.DATE_PICKER, {
1865
+ setValueSelectedForMessageID: localMessageID
1866
+ });
1867
+ }, [ localMessage, serviceManager, userDisplayValue ]);
1868
+ const doScrollElementIntoView = useCallback(() => {
1869
+ scrollElementIntoView(datePickerHostElement, 0, 24);
1870
+ }, [ datePickerHostElement, scrollElementIntoView ]);
1871
+ useOnMount(() => {
1872
+ const localeFromMessage = webChatLocale;
1873
+ const {originalUserText: originalUserText} = localMessage.ui_state;
1874
+ const fromHistory = originalMessage.history.from_history;
1875
+ if (fromHistory && originalUserText) {
1876
+ setUserDisplayValue(originalUserText);
1877
+ }
1878
+ try {
1879
+ if (dayjs.Ls[localeFromMessage]) {
1880
+ setDateInfoForLocale(localeFromMessage);
1881
+ } else {
1882
+ loadDayjsLocale(localeFromMessage).then(locale => {
1883
+ setDateInfoForLocale(locale);
1884
+ });
1885
+ }
1886
+ } catch {
1887
+ consoleError(`Locale ${dayjsLocale} is not recognized by Carbon AI chat. Defaulting to English(US).`);
1888
+ setDateInfoForLocale("en");
1889
+ }
1890
+ });
1891
+ return React.createElement("div", {
1892
+ className: "WACDatePicker"
1893
+ }, isDateInfoReady && datePickerHostElement && React.createElement(Layer, null, React.createElement(DatePicker, {
1894
+ className: "WACDatePicker__Calendar",
1895
+ datePickerType: "single",
1896
+ allowInput: false,
1897
+ locale: flatpickrLocale,
1898
+ appendTo: datePickerHostElement,
1899
+ onChange: dates => {
1900
+ if (dates.length) {
1901
+ const date = dates[0];
1902
+ valueForAssistantRef.current = toAssistantDateFormat(date);
1903
+ setUserDisplayValue(toUserDateFormat(date, userDisplayFormat));
1904
+ }
1905
+ },
1906
+ dateFormat: flatpickrFormat,
1907
+ onOpen: () => {
1908
+ setIsCalendarOpen(true);
1909
+ if (isInputPointerDownEventFiredRef.current) {
1910
+ isInputPointerDownEventFiredRef.current = false;
1911
+ } else {
1912
+ doScrollElementIntoView();
1913
+ }
1914
+ },
1915
+ onClose: () => setIsCalendarOpen(false)
1916
+ }, React.createElement(DatePickerInput, {
1917
+ id: uuidRef.current,
1918
+ labelText: inputLabel,
1919
+ placeholder: userDisplayFormat,
1920
+ disabled: disabled,
1921
+ title: "",
1922
+ onPointerDown: () => {
1923
+ isInputPointerDownEventFiredRef.current = true;
1924
+ },
1925
+ onClick: () => doScrollElementIntoView()
1926
+ }))), React.createElement("div", {
1927
+ className: "WACDatePicker__CalendarContainer",
1928
+ ref: setDatePickerHostElement
1929
+ }), !disabled && !isCalendarOpen && userDisplayValue && React.createElement(Button, {
1930
+ className: "WACDatePicker__ConfirmButton",
1931
+ onClick: handlerSendDate,
1932
+ renderIcon: props => React.createElement(Checkmark, {
1933
+ size: 32,
1934
+ ...props
1935
+ })
1936
+ }, confirmButtonLabel));
1937
+ }
1938
+
1939
+ function calcFlatpickrLocale(localeValue) {
1940
+ if (localeValue === "zh-tw") {
1941
+ return "zh_tw";
1942
+ }
1943
+ return localeValue.includes("-") ? localeValue.split("-")[0] : localeValue;
1944
+ }
1945
+
1946
+ function getFlatpickrDateFormat(format) {
1947
+ const dash = format.includes("-") ? "-" : "/";
1948
+ const firstChar = format.toLocaleLowerCase().trim()[0];
1949
+ if (firstChar === "m") {
1950
+ return `m${dash}d${dash}Y`;
1951
+ }
1952
+ if (firstChar === "d") {
1953
+ return `d${dash}m${dash}Y`;
1954
+ }
1955
+ if (firstChar === "y") {
1956
+ return `Y${dash}m${dash}d`;
1957
+ }
1958
+ throw Error(`The provided format ${format} is invalid.`);
1959
+ }
1960
+
1961
+ const DatePickerComponentExport = React.memo(DatePickerComponent);
1962
+
1963
+ /*
1964
+ * Copyright IBM Corp. 2025
1965
+ *
1966
+ * This source code is licensed under the Apache-2.0 license found in the
1967
+ * LICENSE file in the root directory of this source tree.
1968
+ *
1969
+ * @license
1970
+ */ const VALID_COLUMN_WIDTH_REGEX = /^[0-9]*(px)?$/;
1971
+
1972
+ const DEFAULT_COLUMN_WIDTH = "1";
1973
+
1974
+ function GridItemComponent({localMessageItem: localMessageItem, originalMessage: originalMessage, renderMessageComponent: renderMessageComponent}) {
1975
+ const serviceManager = useServiceManager();
1976
+ const languagePack = useLanguagePack();
1977
+ const appConfig = useSelector(state => state.config);
1978
+ const inputState = useSelector(selectInputState);
1979
+ const allMessageItemsByID = useSelector(state => state.allMessageItemsByID);
1980
+ const {columns: columns, horizontal_alignment: horizontal_alignment, vertical_alignment: vertical_alignment, max_width: max_width} = localMessageItem.item;
1981
+ const gridTemplateColumns = columns?.map(column => column.width).join(" ") || DEFAULT_COLUMN_WIDTH;
1982
+ return React.createElement("div", {
1983
+ className: cx("WACGrid", {
1984
+ WACMaxWidthSmall: max_width === WidthOptions.SMALL,
1985
+ WACMaxWidthMedium: max_width === WidthOptions.MEDIUM,
1986
+ WACMaxWidthLarge: max_width === WidthOptions.LARGE
1987
+ }),
1988
+ style: {
1989
+ gridTemplateColumns: gridTemplateColumns
1990
+ }
1991
+ }, localMessageItem.ui_state.gridLocalMessageItemIDs.map((row, rowIndex) => React.createElement("div", {
1992
+ key: `row-${rowIndex}`,
1993
+ className: "WACGrid__Row"
1994
+ }, row.map((cell, columnIndex) => {
1995
+ const cellData = localMessageItem.item.rows[rowIndex]?.cells[columnIndex];
1996
+ let columnWidthString = columns?.[columnIndex]?.width || DEFAULT_COLUMN_WIDTH;
1997
+ let isPixelValue;
1998
+ if (columnWidthString.match(VALID_COLUMN_WIDTH_REGEX)) {
1999
+ isPixelValue = columnWidthString.endsWith("px");
2000
+ } else {
2001
+ columnWidthString = DEFAULT_COLUMN_WIDTH;
2002
+ isPixelValue = false;
2003
+ }
2004
+ return React.createElement("div", {
2005
+ className: "WACGrid__Cell",
2006
+ style: {
2007
+ width: isPixelValue ? columnWidthString : undefined,
2008
+ flex: isPixelValue ? undefined : Number(columnWidthString),
2009
+ alignItems: getFlexAlignment(cellData?.horizontal_alignment || horizontal_alignment),
2010
+ justifyContent: getFlexAlignment(cellData?.vertical_alignment || vertical_alignment)
2011
+ },
2012
+ key: `cell-${rowIndex}-${columnIndex}`
2013
+ }, cell.map((localMessageItemID, itemIndex) => {
2014
+ const message = allMessageItemsByID[localMessageItemID];
2015
+ return React.createElement(React.Fragment, {
2016
+ key: `item-${rowIndex}-${columnIndex}-${itemIndex}`
2017
+ }, renderMessageComponent({
2018
+ message: message,
2019
+ originalMessage: originalMessage,
2020
+ languagePack: languagePack,
2021
+ requestInputFocus: THROW_ERROR,
2022
+ disableUserInputs: inputState.isReadonly,
2023
+ config: appConfig,
2024
+ isMessageForInput: false,
2025
+ scrollElementIntoView: THROW_ERROR,
2026
+ serviceManager: serviceManager,
2027
+ isNestedMessageItem: true,
2028
+ hideFeedback: true,
2029
+ allowNewFeedback: false
2030
+ }));
2031
+ }));
2032
+ }))));
2033
+ }
2034
+
2035
+ function getFlexAlignment(value) {
2036
+ switch (value) {
2037
+ case "bottom":
2038
+ case "right":
2039
+ return "flex-end";
2040
+
2041
+ case "center":
2042
+ return "center";
2043
+
2044
+ case "top":
2045
+ case "left":
2046
+ default:
2047
+ return "flex-start";
2048
+ }
2049
+ }
2050
+
2051
+ const GridItemComponentExport = React.memo(GridItemComponent);
2052
+
2053
+ /*
2054
+ * Copyright IBM Corp. 2025
2055
+ *
2056
+ * This source code is licensed under the Apache-2.0 license found in the
2057
+ * LICENSE file in the root directory of this source tree.
2058
+ *
2059
+ * @license
2060
+ */ function IFramePreviewCardComponent({messageItem: messageItem, doAutoScroll: doAutoScroll}) {
2061
+ const {source: source, image_url: image_url, title: title, description: description} = messageItem;
2062
+ const useAITheme = useSelector(state => state.theme.useAITheme);
2063
+ const urlHostName = getURLHostName(source);
2064
+ const {store: store} = useServiceManager();
2065
+ const {iframe_ariaImageAltText: iframe_ariaImageAltText} = useLanguagePack();
2066
+ const intl = useIntl();
2067
+ const iframeAriaClickPreviewCardMessage = intl.formatMessage({
2068
+ id: "iframe_ariaClickPreviewCard"
2069
+ }, {
2070
+ source: urlHostName
2071
+ });
2072
+ function handleCardClick() {
2073
+ if (source) {
2074
+ store.dispatch(actions.setIFrameContent(messageItem));
2075
+ }
2076
+ }
2077
+ function handleImageLoaded() {
2078
+ doAutoScroll?.();
2079
+ }
2080
+ return React.createElement("div", null, React.createElement(ClickableImage, {
2081
+ title: title,
2082
+ description: description,
2083
+ source: image_url,
2084
+ displayURL: source,
2085
+ altText: iframe_ariaImageAltText,
2086
+ onImageLoad: handleImageLoaded,
2087
+ renderIcon: ArrowRight,
2088
+ onClick: handleCardClick,
2089
+ preventInlineError: true,
2090
+ useAITheme: useAITheme
2091
+ }), React.createElement(VisuallyHidden, null, iframeAriaClickPreviewCardMessage));
2092
+ }
2093
+
2094
+ const IFramePreviewCardExport = React.memo(IFramePreviewCardComponent);
2095
+
2096
+ /*
2097
+ * Copyright IBM Corp. 2025
2098
+ *
2099
+ * This source code is licensed under the Apache-2.0 license found in the
2100
+ * LICENSE file in the root directory of this source tree.
2101
+ *
2102
+ * @license
2103
+ */ function InlineIFrame({messageItem: messageItem, doAutoScroll: doAutoScroll}) {
2104
+ const ariaAnnouncer = useAriaAnnouncer();
2105
+ const {errors_iframeSource: errors_iframeSource} = useLanguagePack();
2106
+ const [isError, setIsError] = useState(false);
2107
+ const {source: source, title: title} = messageItem;
2108
+ const baseHeight = getMediaDimensions(messageItem)?.base_height;
2109
+ const paddingTop = getResponsiveElementPaddingValue(baseHeight);
2110
+ const inlineStyles = useDynamicCSSProperties({
2111
+ paddingTop: paddingTop
2112
+ });
2113
+ const iframeTitle = title || source;
2114
+ const onTimeoutOverride = useCallback(() => {
2115
+ setIsError(true);
2116
+ ariaAnnouncer(errors_iframeSource);
2117
+ }, [ ariaAnnouncer, errors_iframeSource ]);
2118
+ if (isError) {
2119
+ return React.createElement(InlineError, {
2120
+ text: errors_iframeSource
2121
+ });
2122
+ }
2123
+ return React.createElement("div", {
2124
+ className: "WACInlineIFrame",
2125
+ style: inlineStyles
2126
+ }, React.createElement(IFrameComponent, {
2127
+ source: source,
2128
+ title: iframeTitle,
2129
+ onTimeoutOverride: onTimeoutOverride,
2130
+ onLoad: () => doAutoScroll?.()
2131
+ }));
2132
+ }
2133
+
2134
+ /*
2135
+ * Copyright IBM Corp. 2025
2136
+ *
2137
+ * This source code is licensed under the Apache-2.0 license found in the
2138
+ * LICENSE file in the root directory of this source tree.
2139
+ *
2140
+ * @license
2141
+ */ function IFrameMessage({doAutoScroll: doAutoScroll, localMessage: localMessage, displayOverride: displayOverride}) {
2142
+ const {item: item} = localMessage;
2143
+ const itemDisplay = item.display;
2144
+ if (itemDisplay === IFrameItemDisplayOption.INLINE || displayOverride === IFrameItemDisplayOption.INLINE) {
2145
+ return React.createElement(InlineIFrame, {
2146
+ key: item.source,
2147
+ doAutoScroll: doAutoScroll,
2148
+ messageItem: item
2149
+ });
2150
+ }
2151
+ return React.createElement(IFramePreviewCardExport, {
2152
+ doAutoScroll: doAutoScroll,
2153
+ messageItem: item
2154
+ });
2155
+ }
2156
+
2157
+ /*
2158
+ * Copyright IBM Corp. 2025
2159
+ *
2160
+ * This source code is licensed under the Apache-2.0 license found in the
2161
+ * LICENSE file in the root directory of this source tree.
2162
+ *
2163
+ * @license
2164
+ */ function Description({className: className, text: text, shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion = false}) {
2165
+ return React.createElement("div", {
2166
+ className: `WAC__description ${className}`
2167
+ }, React.createElement(RichTextExport, {
2168
+ text: text,
2169
+ shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion
2170
+ }));
2171
+ }
2172
+
2173
+ /*
2174
+ * Copyright IBM Corp. 2025
2175
+ *
2176
+ * This source code is licensed under the Apache-2.0 license found in the
2177
+ * LICENSE file in the root directory of this source tree.
2178
+ *
2179
+ * @license
2180
+ */ function Metablock({title: title = null, description: description = null, id: id = null, shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion = false}) {
2181
+ return title || description ? React.createElement("div", {
2182
+ className: "WAC__received--metablock",
2183
+ id: id
2184
+ }, title && React.createElement(Description, {
2185
+ className: "WAC__received--metablock-content WACMetablock__Title",
2186
+ text: title,
2187
+ shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion
2188
+ }), description && React.createElement(Description, {
2189
+ className: "WAC__received--metablock-content WACMetablock__Description",
2190
+ text: description,
2191
+ shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion
2192
+ })) : null;
2193
+ }
2194
+
2195
+ /*
2196
+ * Copyright IBM Corp. 2025
2197
+ *
2198
+ * This source code is licensed under the Apache-2.0 license found in the
2199
+ * LICENSE file in the root directory of this source tree.
2200
+ *
2201
+ * @license
2202
+ */ function createProxyEnvironment(shadowRoot) {
2203
+ const properties = {
2204
+ document: shadowRoot.ownerDocument,
2205
+ addEventListener: shadowRoot.ownerDocument.addEventListener.bind(shadowRoot),
2206
+ removeEventListener: shadowRoot.ownerDocument.removeEventListener.bind(shadowRoot),
2207
+ Node: Node
2208
+ };
2209
+ return new Proxy(shadowRoot, {
2210
+ get: (_, prop) => properties[prop]
2211
+ });
2212
+ }
2213
+
2214
+ function SelectComponent(props) {
2215
+ const {title: title, description: description, options: options, onChange: onChange, languagePack: languagePack, disableUserInputs: disableUserInputs, serviceManager: serviceManager, shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion} = props;
2216
+ const [isBeingOpened, setIsBeingOpened] = useState(false);
2217
+ const rootRef = useRef();
2218
+ const counter = useCounter();
2219
+ const id = `${counter}${serviceManager.namespace.suffix}`;
2220
+ const environment = rootRef.current?.getRootNode ? createProxyEnvironment(rootRef.current.getRootNode()) : undefined;
2221
+ function findOptionForValue() {
2222
+ const {value: value, options: options} = props;
2223
+ const selectedItem = options.find(item => item.value === value);
2224
+ return selectedItem;
2225
+ }
2226
+ function onIsOpenChange(changes) {
2227
+ if (changes.isOpen && rootRef.current) {
2228
+ setTimeout(() => {
2229
+ if (rootRef?.current) {
2230
+ setIsBeingOpened(true);
2231
+ doScrollElementIntoView(rootRef.current, true);
2232
+ setIsBeingOpened(false);
2233
+ }
2234
+ }, 70 * 2);
2235
+ }
2236
+ }
2237
+ return React.createElement("div", {
2238
+ ref: rootRef
2239
+ }, React.createElement(Metablock, {
2240
+ title: title,
2241
+ description: description,
2242
+ id: `WAC__selectUUID_${id}-label`,
2243
+ shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion
2244
+ }), React.createElement("div", {
2245
+ className: cx("WAC__selectHolder", {
2246
+ WAC__customSelectTemporaryPadding: isBeingOpened
2247
+ })
2248
+ }, React.createElement(Layer, null, React.createElement(Dropdown, {
2249
+ id: `WAC__selectUUID_${id}`,
2250
+ items: options,
2251
+ label: languagePack.options_select,
2252
+ titleText: languagePack.options_select,
2253
+ hideLabel: true,
2254
+ "aria-label": disableUserInputs ? languagePack.options_ariaOptionsDisabled : title,
2255
+ disabled: disableUserInputs,
2256
+ onChange: onChange,
2257
+ selectedItem: findOptionForValue(),
2258
+ downshiftProps: {
2259
+ environment: environment,
2260
+ onIsOpenChange: onIsOpenChange,
2261
+ id: `WACSelectComponent__Downshift-${id}`
2262
+ }
2263
+ }))));
2264
+ }
2265
+
2266
+ /*
2267
+ * Copyright IBM Corp. 2025
2268
+ *
2269
+ * This source code is licensed under the Apache-2.0 license found in the
2270
+ * LICENSE file in the root directory of this source tree.
2271
+ *
2272
+ * @license
2273
+ */ class OptionComponent extends Component {
2274
+ constructor() {
2275
+ super(...arguments);
2276
+ this.onOptionSelected = (selectedOption, type) => {
2277
+ const {localMessage: localMessage, serviceManager: serviceManager, originalMessage: originalMessage} = this.props;
2278
+ const {id: responseID} = originalMessage;
2279
+ const messageRequest = createMessageRequestForChoice(selectedOption, responseID);
2280
+ const localMessageID = localMessage.ui_state.id;
2281
+ const source = type === "button" ? MessageSendSource.OPTION_BUTTON : MessageSendSource.OPTION_DROP_DOWN;
2282
+ serviceManager.actions.sendWithCatch(messageRequest, source, {
2283
+ setValueSelectedForMessageID: localMessageID
2284
+ });
2285
+ this.props.requestInputFocus();
2286
+ };
2287
+ this.onButtonClick = (event, item) => {
2288
+ this.onOptionSelected(item, "button");
2289
+ };
2290
+ this.onSelectChange = data => {
2291
+ this.onOptionSelected(data.selectedItem, "dropdown");
2292
+ };
2293
+ }
2294
+ render() {
2295
+ const {localMessage: localMessage, languagePack: languagePack, disableUserInputs: disableUserInputs, serviceManager: serviceManager, shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion} = this.props;
2296
+ const {options: options, title: title, description: description, preference: preference} = localMessage.item;
2297
+ const {optionSelected: optionSelected} = localMessage.ui_state;
2298
+ const type = getOptionType(preference, options.length);
2299
+ return type === "button" ? React.createElement(React.Fragment, null, React.createElement(Metablock, {
2300
+ title: title,
2301
+ description: description,
2302
+ shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion
2303
+ }), React.createElement("div", {
2304
+ className: "WAC__button-holder"
2305
+ }, React.createElement("ul", null, options.map((item, index) => {
2306
+ const isSelected = optionSelected ? item.value.input.text === optionSelected.input.text : false;
2307
+ return React.createElement("li", {
2308
+ key: item.label
2309
+ }, React.createElement(unstable__ChatButton, {
2310
+ kind: ButtonKindEnum.TERTIARY,
2311
+ isQuickAction: true,
2312
+ size: ButtonSizeEnum.SMALL,
2313
+ className: `WAC__button-${index}`,
2314
+ disabled: disableUserInputs,
2315
+ isSelected: isSelected,
2316
+ onClick: event => {
2317
+ this.onButtonClick(event, item);
2318
+ }
2319
+ }, item.label));
2320
+ })))) : React.createElement(SelectComponent, {
2321
+ serviceManager: serviceManager,
2322
+ languagePack: languagePack,
2323
+ title: title,
2324
+ description: description,
2325
+ options: options,
2326
+ disableUserInputs: disableUserInputs,
2327
+ onChange: this.onSelectChange,
2328
+ value: optionSelected,
2329
+ shouldRemoveHTMLBeforeMarkdownConversion: shouldRemoveHTMLBeforeMarkdownConversion
2330
+ });
2331
+ }
2332
+ }
2333
+
2334
+ var css_248z$1 = "cds-custom-table-header-title,\ncds-custom-table-header-description,\ncds-custom-table-toolbar{\n position:sticky;\n inline-size:var(--cds-chat-table-width, auto);\n inset-inline-start:0;\n}\n\n:dir(rtl) cds-custom-table-header-title,\n:dir(rtl) cds-custom-table-header-description,\n:dir(rtl) cds-custom-table-toolbar{\n right:0;\n left:unset;\n}\n\ncds-custom-table-header-title,\ncds-custom-table-header-description{\n padding:0 1rem;\n inline-size:calc(var(--cds-chat-table-width, auto) - 1rem - 1rem);\n margin-inline:-1rem;\n}\n\ncds-custom-table-header-description{\n margin-block-end:-0.5rem;\n}\n\ncds-custom-pagination{\n inline-size:100%;\n}";
2335
+
2336
+ /*
2337
+ * Copyright IBM Corp. 2025
2338
+ *
2339
+ * This source code is licensed under the Apache-2.0 license found in the
2340
+ * LICENSE file in the root directory of this source tree.
2341
+ *
2342
+ * @license
2343
+ */ const Download16svg = toString({
2344
+ ...Download16,
2345
+ attrs: {
2346
+ ...Download16.attrs,
2347
+ slot: "icon"
2348
+ }
2349
+ });
2350
+
2351
+ function tableTemplate(tableElement) {
2352
+ const {tableTitle: tableTitle, tableDescription: tableDescription, headers: headers, containerWidth: containerWidth, filterPlaceholderText: filterPlaceholderText, locale: locale, _handleDownload: handleDownload, _rowsWithIDs: tableRowsWithIDs, _allowFiltering: allowTableFiltering, _handleFilterEvent: handleFilterEvent} = tableElement;
2353
+ function toolbarElement() {
2354
+ return html`<cds-custom-table-toolbar slot="toolbar">
2355
+ <cds-custom-table-toolbar-content>
2356
+ ${allowTableFiltering ? html`<cds-custom-table-toolbar-search
2357
+ persistent
2358
+ placeholder=${filterPlaceholderText}
2359
+ ></cds-custom-table-toolbar-search>` : ""}
2360
+ <cds-custom-button @click=${handleDownload}
2361
+ >${unsafeSVG(Download16svg)}</cds-custom-button
2362
+ >
2363
+ </cds-custom-table-toolbar-content>
2364
+ </cds-custom-table-toolbar>`;
2365
+ }
2366
+ function headersElement() {
2367
+ return html`<cds-custom-table-head>
2368
+ <cds-custom-table-header-row>
2369
+ ${headers.map(header => html`<cds-custom-table-header-cell
2370
+ >${header}</cds-custom-table-header-cell
2371
+ >`)}
2372
+ </cds-custom-table-header-row>
2373
+ </cds-custom-table-head>`;
2374
+ }
2375
+ function rowsElement() {
2376
+ return html`<cds-custom-table-body>
2377
+ ${repeat(tableRowsWithIDs, row => row.id, row => html`<cds-custom-table-row id=${row.id}
2378
+ >${row.cells.map(cell => html`<cds-custom-table-cell>${cell}</cds-custom-table-cell>`)}</cds-custom-table-row
2379
+ >`)}
2380
+ </cds-custom-table-body>`;
2381
+ }
2382
+ return html`<cds-custom-table
2383
+ style="--cds-chat-table-width:${containerWidth}px"
2384
+ size="md"
2385
+ locale=${locale}
2386
+ .isSortable=${allowTableFiltering}
2387
+ .useZebraStyles=${true}
2388
+ @cds-custom-table-filtered=${handleFilterEvent}
2389
+ >
2390
+ ${tableTitle && html`<cds-custom-table-header-title slot="title"
2391
+ >${tableTitle}</cds-custom-table-header-title
2392
+ >`}
2393
+ ${tableDescription && html`<cds-custom-table-header-description slot="description"
2394
+ >${tableDescription}</cds-custom-table-header-description
2395
+ >`}
2396
+ ${toolbarElement()} ${headersElement()} ${rowsElement()}
2397
+ </cds-custom-table>`;
2398
+ }
2399
+
2400
+ /*
2401
+ * Copyright IBM Corp. 2025
2402
+ *
2403
+ * This source code is licensed under the Apache-2.0 license found in the
2404
+ * LICENSE file in the root directory of this source tree.
2405
+ *
2406
+ * @license
2407
+ */ const POSSIBLE_PAGE_SIZES = [ 5, 10, 15, 20, 50 ];
2408
+
2409
+ function tablePaginationTemplate(props) {
2410
+ const {_currentPageSize: currentPageSize, _currentPageNumber: currentPageNumber, _filterVisibleRowIDs: filterVisibleRowIDs, rows: rows, previousPageText: previousPageText, nextPageText: nextPageText, itemsPerPageText: itemsPerPageText, getPaginationSupplementalText: getPaginationSupplementalText, getPaginationStatusText: getPaginationStatusText, _handlePageChangeEvent: handlePageChangeEvent, _handlePageSizeChangeEvent: handlePageSizeChangeEvent} = props;
2411
+ const totalVisibleRows = filterVisibleRowIDs.size;
2412
+ const totalRows = rows.length;
2413
+ const supportedPageSizes = POSSIBLE_PAGE_SIZES.filter(pageSize => pageSize < totalRows);
2414
+ return html`<cds-custom-pagination
2415
+ page-size=${currentPageSize}
2416
+ page=${currentPageNumber}
2417
+ total-items=${totalVisibleRows}
2418
+ totalPages=${Math.ceil(totalVisibleRows / currentPageSize)}
2419
+ backward-text=${previousPageText}
2420
+ forward-text=${nextPageText}
2421
+ items-per-page-text=${itemsPerPageText}
2422
+ .formatSupplementalText=${getPaginationSupplementalText}
2423
+ .formatStatusWithDeterminateTotal=${getPaginationStatusText}
2424
+ @cds-custom-pagination-changed-current=${handlePageChangeEvent}
2425
+ @cds-custom-page-sizes-select-changed=${handlePageSizeChangeEvent}
2426
+ >
2427
+ ${supportedPageSizes.map(pageSize => html`<cds-custom-select-item value="${pageSize}"
2428
+ >${pageSize}</cds-custom-select-item
2429
+ >`)}
2430
+ <cds-custom-select-item value="${totalRows}"
2431
+ >${totalRows}</cds-custom-select-item
2432
+ >
2433
+ </cds-custom-pagination>`;
2434
+ }
2435
+
2436
+ /*
2437
+ * Copyright IBM Corp. 2025
2438
+ *
2439
+ * This source code is licensed under the Apache-2.0 license found in the
2440
+ * LICENSE file in the root directory of this source tree.
2441
+ *
2442
+ * @license
2443
+ */ function tableSkeletonTemplate() {
2444
+ return html`<cds-custom-table-skeleton row-count="3" column-count="2">
2445
+ </cds-custom-table-skeleton>`;
2446
+ }
2447
+
2448
+ /*
2449
+ * Copyright IBM Corp. 2025
2450
+ *
2451
+ * This source code is licensed under the Apache-2.0 license found in the
2452
+ * LICENSE file in the root directory of this source tree.
2453
+ *
2454
+ * @license
2455
+ */ const DEFAULT_TABLE_PAGE_SIZE = 5;
2456
+
2457
+ const DEFAULT_TABLE_PAGE_SIZE_TALL_CHAT = 10;
2458
+
2459
+ const TALL_CHAT_HEIGHT = 850;
2460
+
2461
+ const TABLE_COMPONENT_TAG_NAME = "cds-aichat-table";
2462
+
2463
+ let TableElement = class TableElement extends LitElement {
2464
+ constructor() {
2465
+ super(...arguments);
2466
+ this._isValid = true;
2467
+ this._currentPageNumber = 1;
2468
+ this._rowsPerPageChanged = false;
2469
+ this._rowsWithIDs = [];
2470
+ }
2471
+ updated(changedProperties) {
2472
+ if ((changedProperties.has("headers") || changedProperties.has("rows")) && this.headers !== undefined && this.rows !== undefined) {
2473
+ this._calcIsTableValid();
2474
+ }
2475
+ if (changedProperties.has("rows") && this.rows !== undefined) {
2476
+ this._initializeRowsArrays();
2477
+ }
2478
+ if (this._currentPageSize === undefined && changedProperties.has("chatHeight") && this.chatHeight !== changedProperties.get("chatHeight")) {
2479
+ this._initializePageSize();
2480
+ }
2481
+ }
2482
+ _calcIsTableValid() {
2483
+ const columnCount = this.headers.length;
2484
+ this._isValid = !this.rows.some(row => row.cells.length !== columnCount);
2485
+ }
2486
+ _initializeRowsArrays() {
2487
+ this._rowsWithIDs = [];
2488
+ this._filterVisibleRowIDs = new Set;
2489
+ this.rows.forEach((row, index) => {
2490
+ const id = index.toString();
2491
+ this._rowsWithIDs.push({
2492
+ ...row,
2493
+ id: id
2494
+ });
2495
+ this._filterVisibleRowIDs.add(id);
2496
+ });
2497
+ }
2498
+ _initializePageSize() {
2499
+ if (this.chatHeight > TALL_CHAT_HEIGHT) {
2500
+ this._currentPageSize = DEFAULT_TABLE_PAGE_SIZE_TALL_CHAT;
2501
+ } else {
2502
+ this._currentPageSize = DEFAULT_TABLE_PAGE_SIZE;
2503
+ }
2504
+ this._allowFiltering = this.rows.length > this._currentPageSize;
2505
+ this._updateVisibleRows();
2506
+ }
2507
+ _handlePageChangeEvent(event) {
2508
+ this._updateVisibleRows(event.detail?.page, event.detail?.pageSize);
2509
+ event.stopPropagation();
2510
+ }
2511
+ _handlePageSizeChangeEvent(event) {
2512
+ this._rowsPerPageChanged = true;
2513
+ this._currentPageSize = event.detail?.pageSize;
2514
+ this._updateVisibleRows();
2515
+ event.stopPropagation();
2516
+ }
2517
+ _handleFilterEvent(event) {
2518
+ this._filterVisibleRowIDs = new Set(event?.detail?.unfilteredRows.map(row => row.id));
2519
+ this._currentPageNumber = 1;
2520
+ this._updateVisibleRows();
2521
+ event.stopPropagation();
2522
+ }
2523
+ _updateVisibleRows(page = this._currentPageNumber, pageSize = this._currentPageSize) {
2524
+ this._currentPageNumber = page;
2525
+ const rows = Array.from(this.renderRoot.querySelectorAll("cds-custom-table-row"));
2526
+ rows.forEach(row => row.style.setProperty("display", "none"));
2527
+ const filterVisibleRows = rows.filter(row => this._filterVisibleRowIDs.has(row.id));
2528
+ const pageStart = (page - 1) * pageSize;
2529
+ const pageEnd = page * pageSize - 1;
2530
+ for (let index = pageStart; index <= pageEnd; index++) {
2531
+ filterVisibleRows[index]?.removeAttribute("style");
2532
+ }
2533
+ }
2534
+ _handleDownload() {
2535
+ const tableArray = [ this.headers, ...this.rows.map(row => row.cells) ];
2536
+ const stringifiedTable = stringify(tableArray);
2537
+ const blob = new Blob([ stringifiedTable ], {
2538
+ type: "text/csv;charset=utf-8;"
2539
+ });
2540
+ const link = document.createElement("a");
2541
+ const url = URL.createObjectURL(blob);
2542
+ link.setAttribute("href", url);
2543
+ link.setAttribute("download", "table-data.csv");
2544
+ link.style.visibility = "hidden";
2545
+ document.body.appendChild(link);
2546
+ link.click();
2547
+ document.body.removeChild(link);
2548
+ }
2549
+ render() {
2550
+ if (this.loading) {
2551
+ return tableSkeletonTemplate();
2552
+ }
2553
+ if (this.rows.length > this._currentPageSize || this._rowsPerPageChanged) {
2554
+ return html`${tableTemplate(this)}
2555
+ ${tablePaginationTemplate({
2556
+ _currentPageSize: this._currentPageSize,
2557
+ _currentPageNumber: this._currentPageNumber,
2558
+ _filterVisibleRowIDs: this._filterVisibleRowIDs,
2559
+ rows: this.rows,
2560
+ previousPageText: this.previousPageText,
2561
+ nextPageText: this.nextPageText,
2562
+ itemsPerPageText: this.itemsPerPageText,
2563
+ getPaginationSupplementalText: this.getPaginationSupplementalText,
2564
+ getPaginationStatusText: this.getPaginationStatusText,
2565
+ _handlePageChangeEvent: this._handlePageChangeEvent,
2566
+ _handlePageSizeChangeEvent: this._handlePageSizeChangeEvent
2567
+ })}`;
2568
+ }
2569
+ return html`${tableTemplate(this)}`;
2570
+ }
2571
+ };
2572
+
2573
+ TableElement.styles = css`
2574
+ ${unsafeCSS(css_248z$1)}
2575
+ `;
2576
+
2577
+ __decorate([ property({
2578
+ type: String,
2579
+ attribute: "table-title"
2580
+ }) ], TableElement.prototype, "tableTitle", void 0);
2581
+
2582
+ __decorate([ property({
2583
+ type: String,
2584
+ attribute: "table-description"
2585
+ }) ], TableElement.prototype, "tableDescription", void 0);
2586
+
2587
+ __decorate([ property({
2588
+ type: Array
2589
+ }) ], TableElement.prototype, "headers", void 0);
2590
+
2591
+ __decorate([ property({
2592
+ type: Array
2593
+ }) ], TableElement.prototype, "rows", void 0);
2594
+
2595
+ __decorate([ property({
2596
+ type: Number,
2597
+ attribute: "container-width"
2598
+ }) ], TableElement.prototype, "containerWidth", void 0);
2599
+
2600
+ __decorate([ property({
2601
+ type: Number,
2602
+ attribute: "chat-height"
2603
+ }) ], TableElement.prototype, "chatHeight", void 0);
2604
+
2605
+ __decorate([ property({
2606
+ type: Boolean,
2607
+ attribute: "loading"
2608
+ }) ], TableElement.prototype, "loading", void 0);
2609
+
2610
+ __decorate([ property({
2611
+ type: String,
2612
+ attribute: "filter-placeholder-text"
2613
+ }) ], TableElement.prototype, "filterPlaceholderText", void 0);
2614
+
2615
+ __decorate([ property({
2616
+ type: String,
2617
+ attribute: "previous-page-text"
2618
+ }) ], TableElement.prototype, "previousPageText", void 0);
2619
+
2620
+ __decorate([ property({
2621
+ type: String,
2622
+ attribute: "next-page-text"
2623
+ }) ], TableElement.prototype, "nextPageText", void 0);
2624
+
2625
+ __decorate([ property({
2626
+ type: String,
2627
+ attribute: "items-per-page-text"
2628
+ }) ], TableElement.prototype, "itemsPerPageText", void 0);
2629
+
2630
+ __decorate([ property({
2631
+ type: String,
2632
+ attribute: "locale"
2633
+ }) ], TableElement.prototype, "locale", void 0);
2634
+
2635
+ __decorate([ property({
2636
+ type: Function,
2637
+ attribute: false
2638
+ }) ], TableElement.prototype, "getPaginationSupplementalText", void 0);
2639
+
2640
+ __decorate([ property({
2641
+ type: Function,
2642
+ attribute: false
2643
+ }) ], TableElement.prototype, "getPaginationStatusText", void 0);
2644
+
2645
+ __decorate([ state() ], TableElement.prototype, "_isValid", void 0);
2646
+
2647
+ __decorate([ state() ], TableElement.prototype, "_currentPageNumber", void 0);
2648
+
2649
+ __decorate([ state() ], TableElement.prototype, "_currentPageSize", void 0);
2650
+
2651
+ __decorate([ state() ], TableElement.prototype, "_rowsPerPageChanged", void 0);
2652
+
2653
+ __decorate([ state() ], TableElement.prototype, "_filterVisibleRowIDs", void 0);
2654
+
2655
+ __decorate([ state() ], TableElement.prototype, "_rowsWithIDs", void 0);
2656
+
2657
+ __decorate([ state() ], TableElement.prototype, "_allowFiltering", void 0);
2658
+
2659
+ __decorate([ bind ], TableElement.prototype, "_handlePageChangeEvent", null);
2660
+
2661
+ __decorate([ bind ], TableElement.prototype, "_handlePageSizeChangeEvent", null);
2662
+
2663
+ __decorate([ bind ], TableElement.prototype, "_handleFilterEvent", null);
2664
+
2665
+ TableElement = __decorate([ carbonElement(TABLE_COMPONENT_TAG_NAME) ], TableElement);
2666
+
2667
+ /*
2668
+ * Copyright IBM Corp. 2025
2669
+ *
2670
+ * This source code is licensed under the Apache-2.0 license found in the
2671
+ * LICENSE file in the root directory of this source tree.
2672
+ *
2673
+ * @license
2674
+ */ const Table = createComponent({
2675
+ tagName: TABLE_COMPONENT_TAG_NAME,
2676
+ elementClass: TableElement,
2677
+ react: React
2678
+ });
2679
+
2680
+ /*
2681
+ * Copyright IBM Corp. 2025
2682
+ *
2683
+ * This source code is licensed under the Apache-2.0 license found in the
2684
+ * LICENSE file in the root directory of this source tree.
2685
+ *
2686
+ * @license
2687
+ */ function TableContainer(props) {
2688
+ const {tableItem: tableItem} = props;
2689
+ const {title: title, description: description, headers: headers, rows: rows} = tableItem;
2690
+ const carbonTheme = useSelector(state => state.theme.carbonTheme);
2691
+ const chatHeight = useSelector(state => state.chatHeight);
2692
+ const locale = useSelector(state => state.locale);
2693
+ const languagePack = useLanguagePack();
2694
+ const intl = useIntl();
2695
+ const tableContainerRef = useRef(null);
2696
+ const [tableContainerWidth, setTableContainerWidth] = useState();
2697
+ function onResize() {
2698
+ setTableContainerWidth(tableContainerRef.current?.clientWidth);
2699
+ }
2700
+ useLayoutEffect(() => {
2701
+ const tableResizeObserver = new ResizeObserver(onResize);
2702
+ tableResizeObserver.observe(tableContainerRef.current);
2703
+ });
2704
+ const isValidTable = useMemo(() => {
2705
+ const columnCount = headers.length;
2706
+ const isValid = !rows.some(row => row.cells.length !== columnCount);
2707
+ if (!isValid) {
2708
+ consoleError(`Number of cells in the table header does not match the number of cells in one or more of the table rows. In order to render a table there needs to be the same number of columns in the table header and all of the table rows.`);
2709
+ }
2710
+ return isValid;
2711
+ }, [ rows, headers ]);
2712
+ function getTablePaginationSupplementalText({count: count}) {
2713
+ return intl.formatMessage({
2714
+ id: "table_paginationSupplementalText"
2715
+ }, {
2716
+ pagesCount: count
2717
+ });
2718
+ }
2719
+ function getTablePaginationStatusText({start: start, end: end, count: count}) {
2720
+ return intl.formatMessage({
2721
+ id: "table_paginationStatus"
2722
+ }, {
2723
+ start: start,
2724
+ end: end,
2725
+ count: count
2726
+ });
2727
+ }
2728
+ if (isValidTable) {
2729
+ return React.createElement(Theme, {
2730
+ theme: LIGHT_THEMES.includes(carbonTheme) ? "white" : "g90"
2731
+ }, React.createElement("div", {
2732
+ className: "WACTableContainer",
2733
+ ref: tableContainerRef
2734
+ }, React.createElement(Table, {
2735
+ tableTitle: title,
2736
+ tableDescription: description,
2737
+ headers: headers,
2738
+ rows: rows,
2739
+ containerWidth: tableContainerWidth,
2740
+ chatHeight: chatHeight,
2741
+ filterPlaceholderText: languagePack.table_filterPlaceholder,
2742
+ previousPageText: languagePack.table_previousPage,
2743
+ nextPageText: languagePack.table_nextPage,
2744
+ itemsPerPageText: languagePack.table_itemsPerPage,
2745
+ getPaginationSupplementalText: getTablePaginationSupplementalText,
2746
+ getPaginationStatusText: getTablePaginationStatusText,
2747
+ locale: locale
2748
+ })));
2749
+ }
2750
+ return React.createElement(InlineError, null);
2751
+ }
2752
+
2753
+ const TableContainerExport = React.memo(TableContainer);
2754
+
2755
+ /*
2756
+ * Copyright IBM Corp. 2025
2757
+ *
2758
+ * This source code is licensed under the Apache-2.0 license found in the
2759
+ * LICENSE file in the root directory of this source tree.
2760
+ *
2761
+ * @license
2762
+ */ function TourCard({message: message, serviceManager: serviceManager}) {
2763
+ const {tour_resumeButton: tour_resumeButton, tour_restartButton: tour_restartButton, tour_startButton: tour_startButton} = useLanguagePack();
2764
+ const {activeTourID: activeTourID} = useSelector(state => state.persistedToBrowserStorage.chatState.persistedTourState);
2765
+ const isCurrentTour = message.fullMessageID === activeTourID;
2766
+ const tourTitle = message.item.user_defined?.card_title || "Guided journey";
2767
+ const tourDescription = message.item.user_defined?.card_description || "Follow along as the assistant guides you to where you want to be.";
2768
+ async function onResumeClick() {
2769
+ await serviceManager.actions.changeView(ViewType.TOUR, {
2770
+ mainWindowCloseReason: MainWindowCloseReason.TOUR_CARD_RESUMED_TOUR
2771
+ });
2772
+ }
2773
+ async function onRestartClick() {
2774
+ const newViewState = await serviceManager.actions.changeView(ViewType.TOUR, {
2775
+ mainWindowCloseReason: MainWindowCloseReason.TOUR_CARD_RESTARTED_TOUR
2776
+ });
2777
+ if (newViewState.tour) {
2778
+ serviceManager.actions.changeStepInTour({
2779
+ newStepIndex: 0
2780
+ });
2781
+ }
2782
+ }
2783
+ return React.createElement(Tile, {
2784
+ className: "WACTourCard"
2785
+ }, React.createElement("div", {
2786
+ className: "WACTourCard__Title"
2787
+ }, tourTitle), React.createElement("div", {
2788
+ className: "WACTourCard__Description"
2789
+ }, tourDescription), isCurrentTour && React.createElement("div", null, React.createElement(Button, {
2790
+ className: "WACTourCard__ResumeButton",
2791
+ renderIcon: ArrowRight,
2792
+ onClick: onResumeClick
2793
+ }, tour_resumeButton), React.createElement(Button, {
2794
+ className: "WACTourCard__RestartButton",
2795
+ kind: "ghost",
2796
+ renderIcon: Restart,
2797
+ onClick: onRestartClick
2798
+ }, tour_restartButton)), !isCurrentTour && React.createElement(Button, {
2799
+ className: "WACTourCard__StartButton",
2800
+ renderIcon: ArrowRight,
2801
+ onClick: () => serviceManager.actions.startTour(message, TourStartReason.START_TOUR_CLICKED, {
2802
+ mainWindowCloseReason: MainWindowCloseReason.TOUR_CARD_STARTED_TOUR
2803
+ })
2804
+ }, tour_startButton));
2805
+ }
2806
+
2807
+ const TourCardExport = React.memo(TourCard);
2808
+
2809
+ /*
2810
+ * Copyright IBM Corp. 2025
2811
+ *
2812
+ * This source code is licensed under the Apache-2.0 license found in the
2813
+ * LICENSE file in the root directory of this source tree.
2814
+ *
2815
+ * @license
2816
+ */ function StreamingRichText(props) {
2817
+ const {text: text, streamingState: streamingState, removeHTML: removeHTML, isStreamingError: isStreamingError, doAutoScroll: doAutoScroll} = props;
2818
+ const languagePack = useLanguagePack();
2819
+ useCallbackOnChange(streamingState?.chunks, doAutoScroll);
2820
+ let textToUse;
2821
+ if (streamingState && !streamingState.isDone) {
2822
+ textToUse = streamingState.chunks.map(chunk => chunk.text).join("");
2823
+ } else {
2824
+ textToUse = text;
2825
+ }
2826
+ return React.createElement("div", {
2827
+ className: "WACStreamingRichText"
2828
+ }, React.createElement(RichTextExport, {
2829
+ text: textToUse,
2830
+ shouldRemoveHTMLBeforeMarkdownConversion: removeHTML
2831
+ }), isStreamingError && React.createElement(InlineError, {
2832
+ text: languagePack.conversationalSearch_streamingIncomplete
2833
+ }));
2834
+ }
2835
+
2836
+ var css_248z = ":host{\n display:block;\n margin-block-start:1rem;\n}\n\n:host([open]) .cds--aichat-chain-of-thought-content{\n display:block;\n overflow:visible;\n max-block-size:-moz-fit-content;\n max-block-size:fit-content;\n opacity:1;\n}\n:host([open]) .cds--aichat-chain-of-thought-button-chevron svg{\n transform:rotate(-90deg);\n}\n\n.cds--aichat-chain-of-thought-button-chevron{\n display:flex;\n flex-basis:1.5rem;\n}\n@media screen and (prefers-reduced-motion: reduce){\n .cds--aichat-chain-of-thought-button-chevron svg{\n transform:rotate(-270deg);\n transition:none;\n }\n}\n.cds--aichat-chain-of-thought-button-chevron svg{\n transform:rotate(-270deg);\n transition:all 110ms cubic-bezier(0.2, 0, 0.38, 0.9);\n}\n\n.cds--aichat-chain-of-thought-content{\n display:none;\n overflow:hidden;\n max-block-size:0;\n opacity:0;\n transition:all 110ms cubic-bezier(0, 0, 0.38, 0.9) allow-discrete;\n}\n\n.cds--aichat-chain-of-thought-inner-content{\n border:1px solid var(--cds-border-subtle-01, #c6c6c6);\n background-color:var(--cds-layer-01, #f4f4f4);\n margin-block-start:0.5rem;\n}\n\n.cds--aichat-chain-of-thought-item:not(:last-child){\n padding-block-end:0.75rem;\n}\n\n.cds--aichat-chain-of-thought-item cds-aichat-markdown-text:not(:first-child){\n padding-block-start:0.5rem;\n}\n\n.cds--aichat-chain-of-thought-item-label{\n font-size:var(--cds-heading-01-font-size, 0.875rem);\n font-weight:var(--cds-heading-01-font-weight, 600);\n line-height:var(--cds-heading-01-line-height, 1.42857);\n letter-spacing:var(--cds-heading-01-letter-spacing, 0.16px);\n}\n\nbutton.cds--aichat-chain-of-thought-button{\n box-sizing:border-box;\n padding:0;\n border:0;\n margin:0;\n font-family:inherit;\n font-size:100%;\n vertical-align:baseline;\n display:inline-block;\n padding:0;\n border:0;\n -webkit-appearance:none;\n -moz-appearance:none;\n appearance:none;\n background:none;\n cursor:pointer;\n text-align:start;\n inline-size:100%;\n font-size:var(--cds-heading-01-font-size, 0.875rem);\n font-weight:var(--cds-heading-01-font-weight, 600);\n line-height:var(--cds-heading-01-line-height, 1.42857);\n letter-spacing:var(--cds-heading-01-letter-spacing, 0.16px);\n display:flex;\n align-items:center;\n color:var(--cds-text-primary, #161616);\n}\nbutton.cds--aichat-chain-of-thought-button *,\nbutton.cds--aichat-chain-of-thought-button *::before,\nbutton.cds--aichat-chain-of-thought-button *::after{\n box-sizing:inherit;\n}\nbutton.cds--aichat-chain-of-thought-button::-moz-focus-inner{\n border:0;\n}\n\nbutton.cds--aichat-chain-of-thought-button:focus,\nbutton.cds--aichat-chain-of-thought-button:focus-visible{\n outline:2px solid var(--cds-focus);\n}\n\n.cds--aichat-chain-of-thought-accordion-item-content{\n display:block;\n overflow:visible;\n background:var(--cds-layer-01, #f4f4f4);\n color:var(--cds-text-primary, #161616);\n max-block-size:-moz-fit-content;\n max-block-size:fit-content;\n opacity:1;\n transition:all 110ms cubic-bezier(0, 0, 0.38, 0.9) allow-discrete;\n}\n\n.cds--aichat-chain-of-thought-item{\n padding-block:1rem;\n padding-inline:2rem 1rem;\n}\n\n.cds--aichat-chain-of-thought-accordion-item-content[hidden]{\n display:none;\n overflow:hidden;\n max-block-size:0;\n opacity:0;\n padding-block:0;\n padding-inline:0;\n}\n\n.cds--aichat-chain-of-thought-accordion-item-header-chevron{\n display:flex;\n flex:0 1 2rem;\n justify-content:center;\n color:var(--cds-text-primary, #161616);\n}\n@media screen and (prefers-reduced-motion: reduce){\n .cds--aichat-chain-of-thought-accordion-item-header-chevron svg{\n fill:var(--cds-text-primary, #161616);\n transform:rotate(-270deg);\n transition:none;\n }\n}\n.cds--aichat-chain-of-thought-accordion-item-header-chevron svg{\n fill:var(--cds-text-primary, #161616);\n transform:rotate(-270deg);\n transition:all 110ms cubic-bezier(0.2, 0, 0.38, 0.9);\n}\n\n.cds--aichat-chain-of-thought-accordion-item-header-chevron[data-open] svg{\n transform:rotate(-90deg);\n}\n\n.cds--aichat-chain-of-thought-accordion-item button.cds--aichat-chain-of-thought-accordion-item-header{\n box-sizing:border-box;\n padding:0;\n border:0;\n margin:0;\n font-family:inherit;\n font-size:100%;\n vertical-align:baseline;\n display:inline-block;\n padding:0;\n border:0;\n -webkit-appearance:none;\n -moz-appearance:none;\n appearance:none;\n background:none;\n cursor:pointer;\n text-align:start;\n inline-size:100%;\n font-size:var(--cds-body-01-font-size, 0.875rem);\n font-weight:var(--cds-body-01-font-weight, 400);\n line-height:var(--cds-body-01-line-height, 1.42857);\n letter-spacing:var(--cds-body-01-letter-spacing, 0.16px);\n display:flex;\n align-items:center;\n padding:0.5rem 0;\n background:var(--cds-layer-accent-02, #e0e0e0);\n block-size:2rem;\n}\n.cds--aichat-chain-of-thought-accordion-item button.cds--aichat-chain-of-thought-accordion-item-header *,\n.cds--aichat-chain-of-thought-accordion-item button.cds--aichat-chain-of-thought-accordion-item-header *::before,\n.cds--aichat-chain-of-thought-accordion-item button.cds--aichat-chain-of-thought-accordion-item-header *::after{\n box-sizing:inherit;\n}\n.cds--aichat-chain-of-thought-accordion-item button.cds--aichat-chain-of-thought-accordion-item-header::-moz-focus-inner{\n border:0;\n}\n.cds--aichat-chain-of-thought-accordion-item button.cds--aichat-chain-of-thought-accordion-item-header:focus,\n.cds--aichat-chain-of-thought-accordion-item button.cds--aichat-chain-of-thought-accordion-item-header:focus-visible{\n position:relative;\n z-index:2;\n box-shadow:0 -1px 0 0 var(--cds-focus, #0f62fe), inset 0 1px 0 0 var(--cds-focus, #0f62fe), inset 2px 0 0 0 var(--cds-focus, #0f62fe), 0 1px 0 0 var(--cds-focus, #0f62fe), inset 0 -1px 0 0 var(--cds-focus, #0f62fe), inset -2px 0 0 0 var(--cds-focus, #0f62fe);\n outline:none;\n}\n\n.cds--aichat-chain-of-thought-accordion-item:nth-child(odd) button.cds--aichat-chain-of-thought-accordion-item-header{\n background:var(--cds-layer-02, #ffffff);\n}\n\n.cds--aichat-chain-of-thought-accordion-item-header-title{\n overflow:hidden;\n flex:1 1;\n color:var(--cds-text-primary, #161616);\n margin-inline-end:0.5rem;\n text-overflow:ellipsis;\n white-space:nowrap;\n}\n\n.cds--aichat-chain-of-thought-accordion-item-header-status{\n display:flex;\n flex:0 0 1.5rem;\n align-items:center;\n justify-content:center;\n}\n\n.cds--aichat-chain-of-thought-accordion-item-header-status--failure{\n display:flex;\n align-items:center;\n justify-content:center;\n margin-inline-end:0.5rem;\n}\n.cds--aichat-chain-of-thought-accordion-item-header-status--failure svg{\n fill:var(--cds-support-error, #da1e28);\n}\n\n.cds--aichat-chain-of-thought-accordion-item-header-status--success{\n display:flex;\n align-items:center;\n justify-content:center;\n margin-inline-end:0.5rem;\n}\n.cds--aichat-chain-of-thought-accordion-item-header-status--success svg{\n fill:var(--cds-support-success, #24a148);\n}";
2837
+
2838
+ /*
2839
+ * Copyright IBM Corp. 2025
2840
+ *
2841
+ * This source code is licensed under the Apache-2.0 license found in the
2842
+ * LICENSE file in the root directory of this source tree.
2843
+ *
2844
+ * @license
2845
+ */ const stepTitleFormatter = createEnglishFormat("chainOfThought_stepTitle");
2846
+
2847
+ class ChainOfThoughtElement extends LitElement {
2848
+ constructor() {
2849
+ super(...arguments);
2850
+ this.open = false;
2851
+ this.formatStepLabelText = ({stepNumber: stepNumber, stepTitle: stepTitle}) => stepTitleFormatter.format({
2852
+ stepNumber: stepNumber,
2853
+ stepTitle: stepTitle || ""
2854
+ });
2855
+ this.inputLabelText = enLanguagePack.chainOfThought_inputLabel;
2856
+ this.outputLabelText = enLanguagePack.chainOfThought_outputLabel;
2857
+ this.toolLabelText = enLanguagePack.chainOfThought_toolLabel;
2858
+ this.explainabilityText = enLanguagePack.chainOfThought_explainabilityLabel;
2859
+ this.statusSucceededLabelText = enLanguagePack.chainOfThought_statusSucceededLabel;
2860
+ this.statusFailedLabelText = enLanguagePack.chainOfThought_statusFailedLabel;
2861
+ this.statusProcessingLabelText = enLanguagePack.chainOfThought_statusProcessingLabel;
2862
+ this._chainOfThoughtPanelID = `${CSS_CLASS_PREFIX}-chain-of-thought-panel-id-${uuid()}`;
2863
+ }
2864
+ firstUpdated(_changedProperties) {
2865
+ this._steps = this.steps.map(item => ({
2866
+ ...item,
2867
+ open: false
2868
+ }));
2869
+ }
2870
+ }
2871
+
2872
+ ChainOfThoughtElement.styles = css`
2873
+ ${unsafeCSS(css_248z)}
2874
+ `;
2875
+
2876
+ __decorate([ property({
2877
+ type: Boolean,
2878
+ attribute: "open",
2879
+ reflect: true
2880
+ }) ], ChainOfThoughtElement.prototype, "open", void 0);
2881
+
2882
+ __decorate([ property({
2883
+ type: Array,
2884
+ attribute: "steps",
2885
+ reflect: true
2886
+ }) ], ChainOfThoughtElement.prototype, "steps", void 0);
2887
+
2888
+ __decorate([ property({
2889
+ type: Function,
2890
+ attribute: false
2891
+ }) ], ChainOfThoughtElement.prototype, "formatStepLabelText", void 0);
2892
+
2893
+ __decorate([ property({
2894
+ type: String,
2895
+ attribute: "input-label-text",
2896
+ reflect: true
2897
+ }) ], ChainOfThoughtElement.prototype, "inputLabelText", void 0);
2898
+
2899
+ __decorate([ property({
2900
+ type: String,
2901
+ attribute: "output-label-text",
2902
+ reflect: true
2903
+ }) ], ChainOfThoughtElement.prototype, "outputLabelText", void 0);
2904
+
2905
+ __decorate([ property({
2906
+ type: String,
2907
+ attribute: "tool-label-text",
2908
+ reflect: true
2909
+ }) ], ChainOfThoughtElement.prototype, "toolLabelText", void 0);
2910
+
2911
+ __decorate([ property({
2912
+ type: String,
2913
+ attribute: "explainability-text",
2914
+ reflect: true
2915
+ }) ], ChainOfThoughtElement.prototype, "explainabilityText", void 0);
2916
+
2917
+ __decorate([ property({
2918
+ type: Function,
2919
+ attribute: false
2920
+ }) ], ChainOfThoughtElement.prototype, "onToggle", void 0);
2921
+
2922
+ __decorate([ property({
2923
+ type: Function,
2924
+ attribute: false
2925
+ }) ], ChainOfThoughtElement.prototype, "onStepToggle", void 0);
2926
+
2927
+ __decorate([ property({
2928
+ type: String,
2929
+ attribute: "status-succeeded-label-text",
2930
+ reflect: true
2931
+ }) ], ChainOfThoughtElement.prototype, "statusSucceededLabelText", void 0);
2932
+
2933
+ __decorate([ property({
2934
+ type: String,
2935
+ attribute: "status-failed-label-text",
2936
+ reflect: true
2937
+ }) ], ChainOfThoughtElement.prototype, "statusFailedLabelText", void 0);
2938
+
2939
+ __decorate([ property({
2940
+ type: String,
2941
+ attribute: "status-processing-label-text",
2942
+ reflect: true
2943
+ }) ], ChainOfThoughtElement.prototype, "statusProcessingLabelText", void 0);
2944
+
2945
+ __decorate([ state() ], ChainOfThoughtElement.prototype, "_steps", void 0);
2946
+
2947
+ __decorate([ state() ], ChainOfThoughtElement.prototype, "_chainOfThoughtPanelID", void 0);
2948
+
2949
+ /*
2950
+ * Copyright IBM Corp. 2025
2951
+ *
2952
+ * This source code is licensed under the Apache-2.0 license found in the
2953
+ * LICENSE file in the root directory of this source tree.
2954
+ *
2955
+ * @license
2956
+ */ const CSS_CLASS_ITEM_PREFIX = `${CSS_CLASS_PREFIX}-chain-of-thought-item`;
2957
+
2958
+ const CSS_CLASS_STATUS_PREFIX = `${CSS_CLASS_PREFIX}-chain-of-thought-accordion-item-header-status`;
2959
+
2960
+ const ChevronRight16svg = toString(ChevronRight16);
2961
+
2962
+ const CheckmarkFilled16svg = toString(CheckmarkFilled16);
2963
+
2964
+ const ErrorFilled16svg = toString(ErrorFilled16);
2965
+
2966
+ function stepStatus(status, statusSucceededLabelText, statusFailedLabelText, statusProcessingLabelText) {
2967
+ switch (status) {
2968
+ case ChainOfThoughtStepStatus.PROCESSING:
2969
+ return html`<cds-custom-inline-loading
2970
+ status="active"
2971
+ aria-label="${statusProcessingLabelText}"
2972
+ ></cds-custom-inline-loading>`;
2973
+
2974
+ case ChainOfThoughtStepStatus.FAILURE:
2975
+ return html`<span
2976
+ class="${CSS_CLASS_STATUS_PREFIX}--${ChainOfThoughtStepStatus.FAILURE}"
2977
+ aria-label="${statusFailedLabelText}"
2978
+ >${unsafeSVG(ErrorFilled16svg)}</span
2979
+ >`;
2980
+
2981
+ default:
2982
+ return html`<span
2983
+ class="${CSS_CLASS_STATUS_PREFIX}--${ChainOfThoughtStepStatus.SUCCESS}"
2984
+ aria-label="${statusSucceededLabelText}"
2985
+ >${unsafeSVG(CheckmarkFilled16svg)}</span
2986
+ >`;
2987
+ }
2988
+ }
2989
+
2990
+ function renderToolData(data, label, classPostfix) {
2991
+ const content = parseUnknownDataToMarkdown(data);
2992
+ if (content) {
2993
+ return renderToolDataAsMarkdown(content, label, classPostfix);
2994
+ }
2995
+ return html``;
2996
+ }
2997
+
2998
+ function renderToolDataAsMarkdown(content, label, classPostfix) {
2999
+ return html`<div
3000
+ class="${CSS_CLASS_ITEM_PREFIX} ${CSS_CLASS_ITEM_PREFIX}-${classPostfix}"
3001
+ >
3002
+ <div class="${CSS_CLASS_ITEM_PREFIX}-label">${label}</div>
3003
+ <cds-aichat-markdown-text
3004
+ sanitize-html
3005
+ markdown=${content}
3006
+ ></cds-aichat-markdown-text>
3007
+ </div>`;
3008
+ }
3009
+
3010
+ function accordionItemContent(customElementClass, item) {
3011
+ const {inputLabelText: inputLabelText, outputLabelText: outputLabelText, toolLabelText: toolLabelText} = customElementClass;
3012
+ if (item.open) {
3013
+ return html` ${item.description ? html`<div
3014
+ class="${CSS_CLASS_ITEM_PREFIX} ${CSS_CLASS_ITEM_PREFIX}-description"
3015
+ >
3016
+ <cds-aichat-markdown-text
3017
+ sanitize-html
3018
+ markdown=${item.description}
3019
+ ></cds-aichat-markdown-text>
3020
+ </div>` : null}
3021
+ ${item.tool_name ? html`<div
3022
+ class="${CSS_CLASS_ITEM_PREFIX} ${CSS_CLASS_ITEM_PREFIX}-toolName"
3023
+ >
3024
+ <div class="${CSS_CLASS_ITEM_PREFIX}-label">${toolLabelText}</div>
3025
+ ${item.tool_name}
3026
+ </div>` : null}
3027
+ ${renderToolData(item.request?.args, inputLabelText, "input")}
3028
+ ${renderToolData(item.response?.content, outputLabelText, "output")}`;
3029
+ }
3030
+ return html``;
3031
+ }
3032
+
3033
+ function accordionContent(customElementClass) {
3034
+ const {_steps: _steps, open: open, _chainOfThoughtPanelID: _chainOfThoughtPanelID, onStepToggle: onStepToggle, formatStepLabelText: formatStepLabelText, statusSucceededLabelText: statusSucceededLabelText, statusFailedLabelText: statusFailedLabelText, statusProcessingLabelText: statusProcessingLabelText} = customElementClass;
3035
+ if (open) {
3036
+ return html`${_steps.map((item, index) => {
3037
+ const stepNumber = index + 1;
3038
+ const content_id = `${_chainOfThoughtPanelID}-step-${stepNumber}-content`;
3039
+ return html`<div
3040
+ class="${CSS_CLASS_PREFIX}-chain-of-thought-accordion-item"
3041
+ >
3042
+ <button
3043
+ class="${CSS_CLASS_PREFIX}-chain-of-thought-accordion-item-header"
3044
+ @click=${() => {
3045
+ item.open = !item.open;
3046
+ customElementClass.requestUpdate();
3047
+ const element = customElementClass.shadowRoot.querySelector(`#${content_id}`);
3048
+ onStepToggle?.(item.open, element);
3049
+ }}
3050
+ aria-expanded=${item.open}
3051
+ aria-controls=${content_id}
3052
+ >
3053
+ <span
3054
+ class="${CSS_CLASS_PREFIX}-chain-of-thought-accordion-item-header-chevron"
3055
+ ?data-open=${item.open}
3056
+ >${unsafeSVG(ChevronRight16svg)}</span
3057
+ >
3058
+ <span
3059
+ class="${CSS_CLASS_PREFIX}-chain-of-thought-accordion-item-header-title"
3060
+ >${formatStepLabelText({
3061
+ stepNumber: stepNumber,
3062
+ stepTitle: item.title
3063
+ })}</span
3064
+ >
3065
+ <span class="${CSS_CLASS_STATUS_PREFIX}"
3066
+ >${stepStatus(item.status, statusSucceededLabelText, statusFailedLabelText, statusProcessingLabelText)}</span
3067
+ >
3068
+ </button>
3069
+ <div
3070
+ class="${CSS_CLASS_PREFIX}-chain-of-thought-accordion-item-content"
3071
+ id=${content_id}
3072
+ ?hidden=${!item.open}
3073
+ >
3074
+ ${accordionItemContent(customElementClass, item)}
3075
+ </div>
3076
+ </div>`;
3077
+ })}`;
3078
+ }
3079
+ return html``;
3080
+ }
3081
+
3082
+ function chainOfThoughtElementTemplate(customElementClass) {
3083
+ const {_chainOfThoughtPanelID: _chainOfThoughtPanelID, explainabilityText: explainabilityText, open: open} = customElementClass;
3084
+ function toggle() {
3085
+ customElementClass.open = !customElementClass.open;
3086
+ customElementClass.onToggle?.(customElementClass.open, customElementClass);
3087
+ }
3088
+ return html`<div class="${CSS_CLASS_PREFIX}-chain-of-thought">
3089
+ <button
3090
+ class="${CSS_CLASS_PREFIX}-chain-of-thought-button"
3091
+ @click=${toggle}
3092
+ aria-expanded=${open}
3093
+ aria-controls=${_chainOfThoughtPanelID}
3094
+ >
3095
+ <span class="${CSS_CLASS_PREFIX}-chain-of-thought-button-chevron"
3096
+ >${unsafeSVG(ChevronRight16svg)}</span
3097
+ >
3098
+ ${explainabilityText}
3099
+ </button>
3100
+ <div
3101
+ id=${_chainOfThoughtPanelID}
3102
+ class="${CSS_CLASS_PREFIX}-chain-of-thought-content"
3103
+ ?hidden=${!open}
3104
+ >
3105
+ <div class="${CSS_CLASS_PREFIX}-chain-of-thought-inner-content">
3106
+ ${accordionContent(customElementClass)}
3107
+ </div>
3108
+ </div>
3109
+ </div>`;
3110
+ }
3111
+
3112
+ /*
3113
+ * Copyright IBM Corp. 2025
3114
+ *
3115
+ * This source code is licensed under the Apache-2.0 license found in the
3116
+ * LICENSE file in the root directory of this source tree.
3117
+ *
3118
+ * @license
3119
+ */ const CHAIN_OF_THOUGHT_COMPONENT_TAG_NAME = `cds-aichat-chain-of-thought`;
3120
+
3121
+ let CDSChatChainOfThoughtElement = class CDSChatChainOfThoughtElement extends ChainOfThoughtElement {
3122
+ render() {
3123
+ return chainOfThoughtElementTemplate(this);
3124
+ }
3125
+ };
3126
+
3127
+ CDSChatChainOfThoughtElement = __decorate([ carbonElement(CHAIN_OF_THOUGHT_COMPONENT_TAG_NAME) ], CDSChatChainOfThoughtElement);
3128
+
3129
+ /*
3130
+ * Copyright IBM Corp. 2025
3131
+ *
3132
+ * This source code is licensed under the Apache-2.0 license found in the
3133
+ * LICENSE file in the root directory of this source tree.
3134
+ *
3135
+ * @license
3136
+ */ const ChainOfThought = createComponent({
3137
+ tagName: CHAIN_OF_THOUGHT_COMPONENT_TAG_NAME,
3138
+ elementClass: CDSChatChainOfThoughtElement,
3139
+ react: React
3140
+ });
3141
+
3142
+ /*
3143
+ * Copyright IBM Corp. 2025
3144
+ *
3145
+ * This source code is licensed under the Apache-2.0 license found in the
3146
+ * LICENSE file in the root directory of this source tree.
3147
+ *
3148
+ * @license
3149
+ */ function MessageTypeComponent(props) {
3150
+ const {allowNewFeedback: allowNewFeedback, hideFeedback: hideFeedback, serviceManager: serviceManager, originalMessage: originalMessage, message: message} = props;
3151
+ const intl = useIntl();
3152
+ const languagePack = useLanguagePack();
3153
+ const feedbackDetailsRef = useRef();
3154
+ const agentDisplayState = useSelector(selectAgentDisplayState, shallowEqual);
3155
+ const agentState = useSelector(state => state.agentState);
3156
+ const persistedAgentState = useSelector(state => state.persistedToBrowserStorage.chatState.agentState);
3157
+ const feedbackID = message.item.message_options?.feedback?.id;
3158
+ const feedbackPanelID = useUUID();
3159
+ const feedbackHistory = originalMessage.history?.feedback?.[feedbackID];
3160
+ const feedbackInitialValues = useMemo(() => {
3161
+ if (!feedbackHistory) {
3162
+ return null;
3163
+ }
3164
+ return {
3165
+ text: feedbackHistory.text,
3166
+ selectedCategories: feedbackHistory.categories
3167
+ };
3168
+ }, [ feedbackHistory ]);
3169
+ const [isFeedbackOpen, setIsFeedbackOpen] = useState(false);
3170
+ const [isPositiveFeedbackSelected, setIsPositiveFeedbackSelected] = useState(feedbackHistory && feedbackHistory.is_positive);
3171
+ const [isNegativeFeedbackSelected, setIsNegativeFeedbackSelected] = useState(feedbackHistory && !feedbackHistory.is_positive);
3172
+ const [isFeedbackSubmitted, setIsFeedbackSubmitted] = useState(Boolean(feedbackHistory));
3173
+ function renderSpecificMessage(localMessageItem, message) {
3174
+ if (isRequest(message)) {
3175
+ return renderRequest(localMessageItem, message);
3176
+ }
3177
+ if (isResponse(message)) {
3178
+ const response = renderResponse(localMessageItem, message);
3179
+ const isResponseStopped = localMessageItem.item.streaming_metadata?.stream_stopped;
3180
+ return React.createElement(React.Fragment, null, response, isResponseStopped && React.createElement(ResponseStopped, null), renderChainOfThought(localMessageItem), renderFeedback(localMessageItem, message));
3181
+ }
3182
+ return false;
3183
+ }
3184
+ function renderRequest(localMessageItem, originalMessage) {
3185
+ const messageItem = localMessageItem.item;
3186
+ if (isTextItem(messageItem)) {
3187
+ const text = originalMessage.history?.label || messageItem.text;
3188
+ const userText = localMessageItem.ui_state.originalUserText || text;
3189
+ return React.createElement("div", {
3190
+ className: "WAC__sent--text"
3191
+ }, originalMessage.input.message_type === InternalMessageRequestType.FILE && React.createElement(Attachment, {
3192
+ className: "WAC__sent-fileIcon",
3193
+ "aria-label": props.languagePack.fileSharing_fileIcon
3194
+ }), React.createElement("span", {
3195
+ role: "heading",
3196
+ "aria-level": 2
3197
+ }, userText));
3198
+ }
3199
+ return null;
3200
+ }
3201
+ function renderResponse(localMessageItem, message) {
3202
+ if (renderAsTour(localMessageItem.item)) {
3203
+ return renderTour(localMessageItem);
3204
+ }
3205
+ if (renderAsUserDefinedMessage(localMessageItem.item)) {
3206
+ return renderUserDefinedResponse(localMessageItem, message);
3207
+ }
3208
+ const responseType = localMessageItem.item.response_type;
3209
+ const withHumanAgent = Boolean(localMessageItem.item.agent_message_type);
3210
+ switch (responseType) {
3211
+ case MessageResponseTypes.TEXT:
3212
+ return renderText(localMessageItem, message, withHumanAgent);
3213
+
3214
+ case MessageResponseTypes.IMAGE:
3215
+ return renderImage(localMessageItem);
3216
+
3217
+ case MessageResponseTypes.OPTION:
3218
+ return renderOption(localMessageItem, message);
3219
+
3220
+ case MessageResponseTypes.CONNECT_TO_AGENT:
3221
+ return renderConnectToAgent(localMessageItem, message);
3222
+
3223
+ case MessageResponseTypes.INLINE_ERROR:
3224
+ return renderInlineError(localMessageItem);
3225
+
3226
+ case MessageResponseTypes.IFRAME:
3227
+ return renderIFrameMessage(localMessageItem);
3228
+
3229
+ case MessageResponseTypes.VIDEO:
3230
+ return renderVideoMessage(localMessageItem);
3231
+
3232
+ case MessageResponseTypes.AUDIO:
3233
+ return renderAudioMessage(localMessageItem);
3234
+
3235
+ case MessageResponseTypes.DATE:
3236
+ return renderDateMessage(localMessageItem);
3237
+
3238
+ case MessageResponseTypes.CONVERSATIONAL_SEARCH:
3239
+ return renderConversationalSearchMessage(localMessageItem, message);
3240
+
3241
+ case MessageResponseTypes.TABLE:
3242
+ return renderTable(localMessageItem);
3243
+
3244
+ case MessageResponseTypes.CARD:
3245
+ return renderCard(localMessageItem, message);
3246
+
3247
+ case MessageResponseTypes.CAROUSEL:
3248
+ return renderCarouselMessage(localMessageItem, message);
3249
+
3250
+ case MessageResponseTypes.BUTTON:
3251
+ return renderButtonItem(localMessageItem, message);
3252
+
3253
+ case MessageResponseTypes.GRID:
3254
+ return renderGrid(localMessageItem, message);
3255
+
3256
+ default:
3257
+ return renderUserDefinedResponse(localMessageItem, message);
3258
+ }
3259
+ }
3260
+ function renderText(message, originalMessage, removeHTML) {
3261
+ if (props.isNestedMessageItem) {
3262
+ return renderRichText(message, removeHTML, originalMessage);
3263
+ }
3264
+ return React.createElement("div", {
3265
+ className: "WAC__received--textContent"
3266
+ }, renderRichText(message, removeHTML, originalMessage));
3267
+ }
3268
+ function renderRichText(localMessageItem, removeHTML, originalMessage) {
3269
+ return React.createElement(StreamingRichText, {
3270
+ text: localMessageItem.item.text,
3271
+ streamingState: localMessageItem.ui_state.streamingState,
3272
+ isStreamingError: originalMessage?.history?.is_streaming_error,
3273
+ removeHTML: removeHTML,
3274
+ doAutoScroll: props.doAutoScroll
3275
+ });
3276
+ }
3277
+ function renderOption(message, originalMessage) {
3278
+ const {languagePack: languagePack, requestInputFocus: requestInputFocus, serviceManager: serviceManager, disableUserInputs: disableUserInputs, isMessageForInput: isMessageForInput} = props;
3279
+ const withHumanAgent = Boolean(message.item.agent_message_type);
3280
+ return React.createElement(OptionComponent, {
3281
+ localMessage: message,
3282
+ originalMessage: originalMessage,
3283
+ languagePack: languagePack,
3284
+ disableUserInputs: disableUserInputs || !isMessageForInput,
3285
+ requestInputFocus: requestInputFocus,
3286
+ serviceManager: serviceManager,
3287
+ shouldRemoveHTMLBeforeMarkdownConversion: withHumanAgent
3288
+ });
3289
+ }
3290
+ function renderImage(message) {
3291
+ const {languagePack: languagePack, serviceManager: serviceManager} = props;
3292
+ const {useAITheme: useAITheme} = serviceManager.store.getState().theme;
3293
+ return React.createElement(ImageExport, {
3294
+ imageError: languagePack.errors_imageSource,
3295
+ source: message.item.source,
3296
+ title: message.item.title,
3297
+ description: message.item.description,
3298
+ altText: message.item.alt_text,
3299
+ needsAnnouncement: message.ui_state.needsAnnouncement,
3300
+ useAITheme: useAITheme
3301
+ });
3302
+ }
3303
+ function renderInlineError(message) {
3304
+ return React.createElement(InlineError, {
3305
+ text: message.item.text
3306
+ });
3307
+ }
3308
+ function renderIFrameMessage(message) {
3309
+ const {doAutoScroll: doAutoScroll, isNestedMessageItem: isNestedMessageItem} = props;
3310
+ const display = isNestedMessageItem ? IFrameItemDisplayOption.INLINE : undefined;
3311
+ return React.createElement(IFrameMessage, {
3312
+ localMessage: message,
3313
+ doAutoScroll: doAutoScroll,
3314
+ displayOverride: display
3315
+ });
3316
+ }
3317
+ function renderVideoMessage(message) {
3318
+ const {doAutoScroll: doAutoScroll} = props;
3319
+ const {item: item} = message;
3320
+ const {source: source, title: title, description: description, alt_text: alt_text} = item;
3321
+ return React.createElement(VideoComponentExport, {
3322
+ source: source,
3323
+ title: title,
3324
+ description: description,
3325
+ baseHeight: getMediaDimensions(item)?.base_height,
3326
+ ariaLabel: alt_text,
3327
+ doAutoScroll: doAutoScroll,
3328
+ needsAnnouncement: message.ui_state.needsAnnouncement
3329
+ });
3330
+ }
3331
+ function renderAudioMessage(message) {
3332
+ const {doAutoScroll: doAutoScroll} = props;
3333
+ const {source: source, title: title, description: description, alt_text: alt_text} = message.item;
3334
+ return React.createElement(AudioComponentExport, {
3335
+ source: source,
3336
+ title: title,
3337
+ description: description,
3338
+ ariaLabel: alt_text,
3339
+ doAutoScroll: doAutoScroll,
3340
+ needsAnnouncement: message.ui_state.needsAnnouncement
3341
+ });
3342
+ }
3343
+ function renderDateMessage(message) {
3344
+ return React.createElement(DatePickerComponentExport, {
3345
+ localMessage: message,
3346
+ disabled: !props.isMessageForInput,
3347
+ scrollElementIntoView: props.scrollElementIntoView
3348
+ });
3349
+ }
3350
+ function renderUserDefinedResponse(message, originalMessage) {
3351
+ const {serviceManager: serviceManager} = props;
3352
+ return React.createElement(UserDefinedResponse$1, {
3353
+ streamingState: message.ui_state.streamingState,
3354
+ isStreamingError: originalMessage?.history?.is_streaming_error,
3355
+ doAutoScroll: props.doAutoScroll,
3356
+ localMessageID: message.ui_state.id,
3357
+ serviceManager: serviceManager
3358
+ });
3359
+ }
3360
+ function renderTour(message) {
3361
+ const {serviceManager: serviceManager} = props;
3362
+ return React.createElement(TourCardExport, {
3363
+ message: message,
3364
+ serviceManager: serviceManager
3365
+ });
3366
+ }
3367
+ function renderConnectToAgent(message, originalMessage) {
3368
+ const {languagePack: languagePack, config: config, serviceManager: serviceManager, disableUserInputs: disableUserInputs, isMessageForInput: isMessageForInput} = props;
3369
+ return React.createElement(ConnectToAgent, {
3370
+ localMessage: message,
3371
+ originalMessage: originalMessage,
3372
+ languagePack: languagePack,
3373
+ config: config,
3374
+ serviceManager: serviceManager,
3375
+ agentState: agentState,
3376
+ agentDisplayState: agentDisplayState,
3377
+ persistedAgentState: persistedAgentState,
3378
+ disableUserInputs: disableUserInputs || !isMessageForInput,
3379
+ requestFocus: props.requestInputFocus
3380
+ });
3381
+ }
3382
+ function renderCard(message, originalMessage) {
3383
+ const {isMessageForInput: isMessageForInput, requestInputFocus: requestInputFocus} = props;
3384
+ return React.createElement(CardComponentExport, {
3385
+ localMessageItem: message,
3386
+ fullMessage: originalMessage,
3387
+ isMessageForInput: isMessageForInput,
3388
+ requestFocus: requestInputFocus,
3389
+ renderMessageComponent: childProps => React.createElement(MessageTypeComponent, {
3390
+ ...childProps
3391
+ })
3392
+ });
3393
+ }
3394
+ function renderConversationalSearchMessage(localMessageItem, fullMessage) {
3395
+ const {scrollElementIntoView: scrollElementIntoView, doAutoScroll: doAutoScroll} = props;
3396
+ return React.createElement(ConversationalSearch, {
3397
+ localMessageItem: localMessageItem,
3398
+ scrollElementIntoView: scrollElementIntoView,
3399
+ isStreamingError: fullMessage.history?.is_streaming_error,
3400
+ doAutoScroll: doAutoScroll
3401
+ });
3402
+ }
3403
+ function renderButtonItem(message, originalMessage) {
3404
+ const {isMessageForInput: isMessageForInput, requestInputFocus: requestInputFocus} = props;
3405
+ return React.createElement(ButtonItemComponent, {
3406
+ localMessageItem: message,
3407
+ fullMessage: originalMessage,
3408
+ isMessageForInput: isMessageForInput,
3409
+ requestFocus: requestInputFocus
3410
+ });
3411
+ }
3412
+ function renderCarouselMessage(message, originalMessage) {
3413
+ const {isMessageForInput: isMessageForInput, requestInputFocus: requestInputFocus} = props;
3414
+ return React.createElement(CarouselItemComponent, {
3415
+ localMessageItem: message,
3416
+ fullMessage: originalMessage,
3417
+ isMessageForInput: isMessageForInput,
3418
+ requestFocus: requestInputFocus,
3419
+ renderMessageComponent: childProps => React.createElement(MessageTypeComponent, {
3420
+ ...childProps
3421
+ })
3422
+ });
3423
+ }
3424
+ function renderGrid(message, originalMessage) {
3425
+ return React.createElement(GridItemComponentExport, {
3426
+ localMessageItem: message,
3427
+ originalMessage: originalMessage,
3428
+ renderMessageComponent: childProps => React.createElement(MessageTypeComponent, {
3429
+ ...childProps
3430
+ })
3431
+ });
3432
+ }
3433
+ function renderTable(message) {
3434
+ return React.createElement(TableContainerExport, {
3435
+ tableItem: message.item
3436
+ });
3437
+ }
3438
+ function scrollChainOfThought(open, element) {
3439
+ if (open) {
3440
+ setTimeout(() => {
3441
+ props.scrollElementIntoView(element, 64, 64);
3442
+ });
3443
+ }
3444
+ }
3445
+ function formatStepLabelText({stepNumber: stepNumber, stepTitle: stepTitle}) {
3446
+ return intl.formatMessage({
3447
+ id: "chainOfThought_stepTitle"
3448
+ }, {
3449
+ stepNumber: stepNumber,
3450
+ stepTitle: stepTitle
3451
+ });
3452
+ }
3453
+ function renderChainOfThought(localMessageItem) {
3454
+ const chainOfThought = localMessageItem.item.message_options?.chain_of_thought;
3455
+ if (!chainOfThought || props.isNestedMessageItem) {
3456
+ return false;
3457
+ }
3458
+ return React.createElement(ChainOfThought, {
3459
+ steps: chainOfThought,
3460
+ onToggle: scrollChainOfThought,
3461
+ onStepToggle: scrollChainOfThought,
3462
+ formatStepLabelText: formatStepLabelText,
3463
+ explainabilityText: languagePack.chainOfThought_explainabilityLabel,
3464
+ inputLabelText: languagePack.chainOfThought_inputLabel,
3465
+ outputLabelText: languagePack.chainOfThought_outputLabel,
3466
+ toolLabelText: languagePack.chainOfThought_toolLabel
3467
+ });
3468
+ }
3469
+ function renderFeedback(localMessageItem, message) {
3470
+ const feedbackOptions = localMessageItem.item.message_options?.feedback || {};
3471
+ const {id: feedbackID, is_on: is_on, show_positive_details: show_positive_details = true, show_negative_details: show_negative_details = true, show_text_area: show_text_area = true, show_prompt: show_prompt = true, title: title, prompt: prompt, categories: categories, placeholder: placeholder, disclaimer: disclaimer} = feedbackOptions;
3472
+ if (props.isNestedMessageItem || hideFeedback || !allowNewFeedback && !feedbackHistory || !is_on) {
3473
+ return false;
3474
+ }
3475
+ function updateHistory(data) {
3476
+ if (feedbackID) {
3477
+ const history = {
3478
+ feedback: {
3479
+ [feedbackID]: data
3480
+ }
3481
+ };
3482
+ serviceManager.store.dispatch(actions.mergeMessageHistory(localMessageItem.fullMessageID, history));
3483
+ }
3484
+ }
3485
+ function onFeedbackClicked(isPositive) {
3486
+ const toggleToSelected = isPositive ? !isPositiveFeedbackSelected : !isNegativeFeedbackSelected;
3487
+ const openDetails = (isPositive ? show_positive_details : show_negative_details) && toggleToSelected;
3488
+ if (toggleToSelected && !openDetails) {
3489
+ updateHistory({
3490
+ is_positive: isPositive
3491
+ });
3492
+ setIsFeedbackSubmitted(true);
3493
+ serviceManager.fire({
3494
+ type: BusEventType.FEEDBACK,
3495
+ messageItem: localMessageItem.item,
3496
+ message: message,
3497
+ interactionType: FeedbackInteractionType.SUBMITTED,
3498
+ isPositive: isPositive
3499
+ });
3500
+ } else {
3501
+ setIsFeedbackOpen(openDetails);
3502
+ if (openDetails) {
3503
+ setTimeout(() => {
3504
+ props.scrollElementIntoView(feedbackDetailsRef.current, 48, 56);
3505
+ });
3506
+ }
3507
+ serviceManager.fire({
3508
+ type: BusEventType.FEEDBACK,
3509
+ messageItem: localMessageItem.item,
3510
+ message: message,
3511
+ interactionType: openDetails ? FeedbackInteractionType.DETAILS_OPENED : FeedbackInteractionType.DETAILS_CLOSED,
3512
+ isPositive: isPositive
3513
+ });
3514
+ }
3515
+ setIsPositiveFeedbackSelected(isPositive ? toggleToSelected : false);
3516
+ setIsNegativeFeedbackSelected(isPositive ? false : toggleToSelected);
3517
+ }
3518
+ function onSubmit(isPositive, details) {
3519
+ setIsFeedbackSubmitted(true);
3520
+ setIsFeedbackOpen(false);
3521
+ const event = {
3522
+ type: BusEventType.FEEDBACK,
3523
+ messageItem: localMessageItem.item,
3524
+ message: message,
3525
+ interactionType: FeedbackInteractionType.SUBMITTED,
3526
+ isPositive: isPositive,
3527
+ text: details.text,
3528
+ categories: details.selectedCategories
3529
+ };
3530
+ serviceManager.fire(event);
3531
+ updateHistory({
3532
+ is_positive: event.isPositive,
3533
+ text: event.text,
3534
+ categories: event.categories
3535
+ });
3536
+ }
3537
+ function renderFeedbackPopup(isPositive) {
3538
+ const isOpen = isFeedbackOpen && (isPositive ? isPositiveFeedbackSelected : isNegativeFeedbackSelected);
3539
+ return React.createElement(FeedbackComponent, {
3540
+ class: `${CSS_CLASS_PREFIX}-feedbackDetails-${isPositive ? "positive" : "negative"}`,
3541
+ id: `${feedbackPanelID}-feedback-${isPositive ? "positive" : "negative"}`,
3542
+ isOpen: isOpen,
3543
+ isReadonly: isFeedbackSubmitted,
3544
+ onClose: () => onFeedbackClicked(isPositive),
3545
+ onSubmit: details => onSubmit(isPositive, details),
3546
+ initialValues: feedbackHistory && feedbackHistory?.is_positive === isPositive ? feedbackInitialValues : null,
3547
+ showTextArea: show_text_area,
3548
+ showPrompt: show_prompt,
3549
+ title: title || languagePack.feedback_defaultTitle,
3550
+ prompt: prompt || languagePack.feedback_defaultPrompt,
3551
+ categories: categories,
3552
+ placeholder: placeholder || languagePack.feedback_defaultPlaceholder,
3553
+ disclaimer: disclaimer,
3554
+ submitLabel: languagePack.feedback_submitLabel,
3555
+ cancelLabel: languagePack.feedback_cancelLabel
3556
+ });
3557
+ }
3558
+ return React.createElement("div", {
3559
+ className: "WAC__received--feedback"
3560
+ }, React.createElement(FeedbackButtonsComponent, {
3561
+ isPositiveOpen: isFeedbackOpen && isPositiveFeedbackSelected,
3562
+ isNegativeOpen: isFeedbackOpen && isNegativeFeedbackSelected,
3563
+ isPositiveSelected: isPositiveFeedbackSelected,
3564
+ isNegativeSelected: isNegativeFeedbackSelected,
3565
+ hasPositiveDetails: show_positive_details,
3566
+ hasNegativeDetails: show_negative_details,
3567
+ isPositiveDisabled: isNegativeFeedbackSelected || isFeedbackSubmitted,
3568
+ isNegativeDisabled: isPositiveFeedbackSelected || isFeedbackSubmitted,
3569
+ positiveLabel: languagePack.feedback_positiveLabel,
3570
+ negativeLabel: languagePack.feedback_negativeLabel,
3571
+ panelID: feedbackPanelID,
3572
+ onClick: onFeedbackClicked
3573
+ }), React.createElement("div", {
3574
+ ref: feedbackDetailsRef
3575
+ }, renderFeedbackPopup(true), renderFeedbackPopup(false)));
3576
+ }
3577
+ return renderSpecificMessage(props.message, props.originalMessage);
3578
+ }
3579
+
3580
+ export { AvailabilityMessage as A, EndAgentChatModal as E, MessageTypeComponent as M, WindowSizeContext as W, AriaAnnouncerComponent as a, nodeToText as n };