@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.424a580

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 (189) hide show
  1. package/lib/cjs/common/Constants.js +7 -0
  2. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +4 -5
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +47 -2
  5. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
  6. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  7. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  8. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  9. package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
  10. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +218 -0
  11. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  12. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  13. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  14. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  16. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  17. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  18. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +287 -0
  19. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  20. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
  21. package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
  22. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  23. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
  24. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  25. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  26. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  27. package/lib/cjs/components/livechatwidget/common/startChat.js +10 -5
  28. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  29. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
  30. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  31. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +51 -8
  32. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +29 -2
  33. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  34. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +127 -11
  35. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  36. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  37. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  38. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  39. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
  40. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  41. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  42. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  43. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
  44. package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
  45. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
  46. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +47 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +50 -1
  53. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  54. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  55. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  56. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  57. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  58. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  59. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
  60. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  61. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
  62. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  63. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  64. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +47 -45
  65. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +9 -1
  66. package/lib/cjs/contexts/createReducer.js +30 -0
  67. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  68. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  69. package/lib/cjs/index.js +9 -1
  70. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  71. package/lib/esm/common/Constants.js +7 -0
  72. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  73. package/lib/esm/common/telemetry/AppInsightsEvents.js +4 -5
  74. package/lib/esm/common/telemetry/TelemetryConstants.js +45 -1
  75. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
  76. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  77. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  78. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  79. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  80. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +207 -0
  81. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  82. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  83. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  84. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
  85. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  86. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  87. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  88. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +280 -0
  89. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  90. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
  91. package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
  92. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  93. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
  94. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  95. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  96. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  97. package/lib/esm/components/livechatwidget/common/startChat.js +12 -7
  98. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  99. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
  100. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  101. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +52 -9
  102. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
  103. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  104. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +130 -12
  105. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  106. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  107. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  108. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  109. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
  110. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  111. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  112. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  113. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
  114. package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
  115. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
  116. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  117. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
  118. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  119. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +39 -0
  120. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
  121. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  122. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +48 -1
  123. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  124. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  125. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  126. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  127. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  128. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  129. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
  130. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  131. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
  132. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  133. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  134. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +47 -45
  135. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +9 -1
  136. package/lib/esm/contexts/createReducer.js +30 -0
  137. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  138. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  139. package/lib/esm/index.js +1 -0
  140. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  141. package/lib/types/common/Constants.d.ts +6 -0
  142. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  143. package/lib/types/common/telemetry/TelemetryConstants.d.ts +42 -2
  144. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  145. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  146. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  147. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  148. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  149. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
  150. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  151. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  152. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  153. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  154. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  155. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  156. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
  157. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  158. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
  159. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
  160. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +12 -0
  161. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
  162. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
  163. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  164. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  165. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  166. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
  167. package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
  168. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  169. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  170. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
  171. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  172. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  173. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  174. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  175. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
  176. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  177. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  178. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  179. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
  180. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
  181. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  182. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
  183. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
  184. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +47 -45
  185. package/lib/types/index.d.ts +1 -0
  186. package/package.json +3 -3
  187. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  188. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  189. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -1,18 +1,19 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
1
  import { Constants, HtmlAttributeNames, HtmlClassNames } from "../../common/Constants";
4
2
  import { Stack } from "@fluentui/react";
5
3
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
6
- import React, { useEffect } from "react";
4
+ import React, { useEffect, useRef, useState } from "react";
7
5
  import { createTimer, getDeviceType, setFocusOnSendBox } from "../../common/utils";
8
6
  import { BotMagicCodeStore } from "./webchatcontroller/BotMagicCodeStore";
7
+ import CitationPaneStateful from "../citationpanestateful/CitationPaneStateful";
9
8
  import { Components } from "botframework-webchat";
10
9
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
11
10
  import { NotificationHandler } from "./webchatcontroller/notification/NotificationHandler";
12
11
  import { NotificationScenarios } from "./webchatcontroller/enums/NotificationScenarios";
13
12
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
14
13
  import { WebChatActionType } from "./webchatcontroller/enums/WebChatActionType";
14
+ import WebChatEventSubscribers from "./webchatcontroller/WebChatEventSubscribers";
15
15
  import { WebChatStoreLoader } from "./webchatcontroller/WebChatStoreLoader";
16
+ import { createIOSOptimizedEmojiFont } from "./common/utils/fontUtils";
16
17
  import { defaultAdaptiveCardStyles } from "./common/defaultStyles/defaultAdaptiveCardStyles";
17
18
  import { defaultMiddlewareLocalizedTexts } from "./common/defaultProps/defaultMiddlewareLocalizedTexts";
18
19
  import { defaultReceivedMessageAnchorStyles } from "./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles";
@@ -20,9 +21,16 @@ import { defaultSentMessageAnchorStyles } from "./webchatcontroller/middlewares/
20
21
  import { defaultSystemMessageBoxStyles } from "./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles";
21
22
  import { defaultUserMessageBoxStyles } from "./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles";
22
23
  import { defaultWebChatContainerStatefulProps } from "./common/defaultProps/defaultWebChatContainerStatefulProps";
24
+ import { isPersistentChatEnabled } from "../livechatwidget/common/liveChatConfigUtils";
23
25
  import { useChatContextStore } from "../..";
26
+ import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
27
+ import usePersistentChatHistory from "./hooks/usePersistentChatHistory";
28
+
29
+ // Types for better type safety
30
+
24
31
  let uiTimer;
25
32
  const broadcastChannelMessageEvent = "message";
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
34
  const postActivity = activity => {
27
35
  // eslint-disable-line @typescript-eslint/no-explicit-any
28
36
  return {
@@ -48,13 +56,29 @@ const createMagicCodeSuccessResponse = signin => {
48
56
  };
49
57
  };
50
58
  export const WebChatContainerStateful = props => {
51
- var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$webChatContain5, _props$webChatContain6, _defaultWebChatContai, _props$webChatContain7, _props$webChatContain8, _defaultWebChatContai2, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _webChatContainerProp17, _webChatContainerProp18, _webChatContainerProp19, _webChatContainerProp20, _webChatContainerProp21, _webChatContainerProp22, _webChatContainerProp23, _props$webChatContain9, _props$webChatContain10;
59
+ var _props$webChatContain, _defaultWebChatContai, _props$persistentChat, _extendedChatConfig$L, _extendedChatConfig$L2, _extendedChatConfig$L3, _extendedChatConfig$L4, _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$webChatContain6, _props$webChatContain7, _defaultWebChatContai2, _props$webChatContain8, _props$webChatContain9, _defaultWebChatContai3, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _webChatContainerProp17, _webChatContainerProp18, _webChatContainerProp19, _webChatContainerProp20, _webChatContainerProp21, _webChatContainerProp22, _webChatContainerProp23, _props$webChatContain10, _props$webChatContain11, _webChatContainerProp24, _webChatContainerProp25, _webChatContainerProp26, _webChatContainerProp27, _props$persistentChat2, _props$citationPanePr, _props$citationPanePr2, _props$citationPanePr3, _props$citationPanePr4, _props$citationPanePr5;
60
+ const [facadeChatSDK] = useFacadeSDKStore();
61
+
62
+ // Create a font family that includes emoji support, based on the primary font or default
63
+ const webChatStyles = ((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles) ?? defaultWebChatContainerStatefulProps.webChatStyles;
64
+ const primaryFont = (webChatStyles === null || webChatStyles === void 0 ? void 0 : webChatStyles.primaryFont) ?? ((_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.primaryFont);
65
+
66
+ // Use iOS-optimized emoji font that prioritizes system-ui for proper emoji rendering
67
+ const fontFamilyWithEmojis = createIOSOptimizedEmojiFont(primaryFont);
52
68
  useEffect(() => {
53
69
  uiTimer = createTimer();
54
70
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
55
71
  Event: TelemetryEvent.UXWebchatContainerCompleted
56
72
  });
57
73
  }, []);
74
+
75
+ // Citation pane state
76
+ const [citationPaneOpen, setCitationPaneOpen] = useState(false);
77
+ const [citationPaneText, setCitationPaneText] = useState("");
78
+
79
+ // Guard to prevent handling multiple rapid clicks which could cause
80
+ // the dim layer and pane to re-render out of sync and create a flicker.
81
+ const citationOpeningRef = useRef(false);
58
82
  const {
59
83
  BasicWebChat
60
84
  } = Components;
@@ -63,6 +87,73 @@ export const WebChatContainerStateful = props => {
63
87
  webChatContainerProps,
64
88
  contextDataStore
65
89
  } = props;
90
+
91
+ // Type the chatConfig properly to avoid 'any' usage
92
+ const extendedChatConfig = props.chatConfig;
93
+ const isHistoryEnabledViaProps = props === null || props === void 0 ? void 0 : (_props$persistentChat = props.persistentChatHistoryProps) === null || _props$persistentChat === void 0 ? void 0 : _props$persistentChat.persistentChatHistoryEnabled;
94
+ const isHistoryEnabledInConfig = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.msdyn_enablepersistentchatpreviousconversations;
95
+ const isHistoryEnabledViaFCB = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.lcwPersistentChatHistoryEnabled;
96
+ const isPersistentChatEnabledForWidget = !!(extendedChatConfig !== null && extendedChatConfig !== void 0 && (_extendedChatConfig$L3 = extendedChatConfig.LiveChatConfigAuthSettings) !== null && _extendedChatConfig$L3 !== void 0 && _extendedChatConfig$L3.msdyn_javascriptclientfunction) || isPersistentChatEnabled(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L4 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L4 === void 0 ? void 0 : _extendedChatConfig$L4.msdyn_conversationmode);
97
+
98
+ // isPersistentHistoryEnabled can only be true if isHistoryEnabledViaFCB is true, and next conditions are met:
99
+ // 1. isHistoryEnabledViaProps is true (takes precedence over config)
100
+ // 2. isHistoryEnabledInConfig is true and isHistoryEnabledViaProps is undefined
101
+ const isPersistentHistoryEnabled = isHistoryEnabledViaProps || isHistoryEnabledInConfig && !isHistoryEnabledViaProps;
102
+
103
+ // Check if both persistent chat and widget support are enabled
104
+ const shouldLoadPersistentHistoryMessages = isPersistentHistoryEnabled && isHistoryEnabledViaFCB && isPersistentChatEnabledForWidget;
105
+ if (shouldLoadPersistentHistoryMessages) {
106
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
107
+ Event: TelemetryEvent.PersistentChatHistoryEnabled
108
+ });
109
+ usePersistentChatHistory(facadeChatSDK, (props === null || props === void 0 ? void 0 : props.persistentChatHistoryProps) ?? {});
110
+ }
111
+ // Delegated click handler for citation anchors. Placed after state is
112
+ // available so we can prefer reading citations from app state and fall
113
+ // back to the legacy window map for backward-compatibility in tests.
114
+ useEffect(() => {
115
+ const clickHandler = ev => {
116
+ try {
117
+ if (citationOpeningRef.current) {
118
+ return;
119
+ }
120
+ const target = ev.target;
121
+ // Only consider anchors whose href starts with the citation scheme
122
+ const anchor = target.closest && target.closest("a[href^=\"cite:\"]");
123
+ if (anchor) {
124
+ ev.preventDefault();
125
+ citationOpeningRef.current = true;
126
+ // Rely only on the href to identify the citation key
127
+ let text = "";
128
+ try {
129
+ var _state$domainStates;
130
+ const cid = anchor.getAttribute("href");
131
+ // Prefer state-based citations injected by middleware
132
+ if (state !== null && state !== void 0 && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.citations && cid) {
133
+ text = state.domainStates.citations[cid] ?? "";
134
+ }
135
+ // If state lookup failed, fall back to the anchor's title or innerText
136
+ if (!text) {
137
+ text = anchor.getAttribute("title") || anchor.innerText || "";
138
+ }
139
+ } catch (e) {
140
+ // ignore
141
+ }
142
+ setCitationPaneOpen(true);
143
+ setCitationPaneText(text);
144
+
145
+ // Simple debounce - reset guard after a short delay
146
+ setTimeout(() => {
147
+ citationOpeningRef.current = false;
148
+ }, 100);
149
+ }
150
+ } catch (e) {
151
+ citationOpeningRef.current = false;
152
+ }
153
+ };
154
+ document.addEventListener("click", clickHandler);
155
+ return () => document.removeEventListener("click", clickHandler);
156
+ }, [state]);
66
157
  const containerStyles = {
67
158
  root: Object.assign({}, defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
68
159
  display: state.appStates.isMinimized ? "none" : ""
@@ -74,7 +165,7 @@ export const WebChatContainerStateful = props => {
74
165
  ...(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.localizedTexts)
75
166
  };
76
167
  useEffect(() => {
77
- var _props$webChatContain, _props$webChatContain2;
168
+ var _props$webChatContain2, _props$webChatContain3;
78
169
  if (getDeviceType() !== "standard" && (webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.webChatHistoryMobileAccessibilityLabel) !== undefined) {
79
170
  const chatHistoryElement = document.querySelector(`.${HtmlClassNames.webChatHistoryContainer}`);
80
171
  if (chatHistoryElement) {
@@ -92,21 +183,23 @@ export const WebChatContainerStateful = props => {
92
183
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
93
184
  Event: TelemetryEvent.WebChatLoaded
94
185
  });
95
- if (((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableThirdPartyCookiesAlert) !== true && !contextDataStore) {
186
+ if (((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.renderingMiddlewareProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableThirdPartyCookiesAlert) !== true && !contextDataStore) {
96
187
  try {
97
188
  localStorage;
98
189
  sessionStorage;
99
190
  } catch (error) {
191
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
192
  if (!window.TPCWarningShown) {
101
193
  NotificationHandler.notifyWarning(NotificationScenarios.TPC, (localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE) ?? "");
194
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
195
  window.TPCWarningShown = true;
103
196
  }
104
197
  }
105
198
  }
106
199
  }, []);
107
200
  useEffect(() => {
108
- var _props$webChatContain3, _props$webChatContain4;
109
- if (!((_props$webChatContain3 = props.webChatContainerProps) !== null && _props$webChatContain3 !== void 0 && (_props$webChatContain4 = _props$webChatContain3.botMagicCode) !== null && _props$webChatContain4 !== void 0 && _props$webChatContain4.disabled)) {
201
+ var _props$webChatContain4, _props$webChatContain5;
202
+ if (!((_props$webChatContain4 = props.webChatContainerProps) !== null && _props$webChatContain4 !== void 0 && (_props$webChatContain5 = _props$webChatContain4.botMagicCode) !== null && _props$webChatContain5 !== void 0 && _props$webChatContain5.disabled)) {
110
203
  return;
111
204
  }
112
205
  if (!window.BroadcastChannel) {
@@ -198,8 +291,8 @@ export const WebChatContainerStateful = props => {
198
291
  }
199
292
 
200
293
  .ms_lcw_webchat_received_message>div.webchat__stacked-layout>div.webchat__stacked-layout__main>div.webchat__stacked-layout__content>div.webchat__stacked-layout__message-row>[class^=webchat]:not(.webchat__bubble--from-user)>.webchat__bubble__content {
201
- background-color: ${((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.webChatStyles) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.bubbleBackground) ?? ((_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.bubbleBackground)};
202
- color:${((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : (_props$webChatContain8 = _props$webChatContain7.webChatStyles) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.bubbleTextColor) ?? ((_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleTextColor)};
294
+ background-color: ${((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : (_props$webChatContain7 = _props$webChatContain6.webChatStyles) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.bubbleBackground) ?? ((_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleBackground)};
295
+ color:${((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : (_props$webChatContain9 = _props$webChatContain8.webChatStyles) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.bubbleTextColor) ?? ((_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.bubbleTextColor)};
203
296
  }
204
297
 
205
298
  div[class="ac-textBlock"] a:link,
@@ -277,7 +370,7 @@ export const WebChatContainerStateful = props => {
277
370
  }
278
371
 
279
372
  .webchat__stacked-layout_container>div {
280
- background: ${(props === null || props === void 0 ? void 0 : (_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : (_props$webChatContain10 = _props$webChatContain9.containerStyles) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.background) ?? ""}
373
+ background: ${(props === null || props === void 0 ? void 0 : (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : (_props$webChatContain11 = _props$webChatContain10.containerStyles) === null || _props$webChatContain11 === void 0 ? void 0 : _props$webChatContain11.background) ?? ""}
281
374
  }
282
375
  .webchat__toast_text {
283
376
  display: flex;
@@ -304,9 +397,34 @@ export const WebChatContainerStateful = props => {
304
397
  height: 100% !important;
305
398
  }
306
399
 
400
+ .webchat__auto-resize-textarea__textarea.webchat__send-box-text-box__html-text-area {
401
+ font-family: ${fontFamilyWithEmojis} !important;
402
+ }
403
+
404
+ /* Suggested actions carousel previous/next navigation focus */
405
+ .webchat__suggested-actions .webchat__suggested-actions__carousel .react-film__flipper:focus-visible .react-film__flipper__body {
406
+ outline: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp24 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp24 === void 0 ? void 0 : _webChatContainerProp24.suggestedActionKeyboardFocusIndicatorBorderStyle) ?? "dashed"} ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp25 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp25 === void 0 ? void 0 : _webChatContainerProp25.suggestedActionKeyboardFocusIndicatorBorderWidth) ?? "1px"} ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp26 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp26 === void 0 ? void 0 : _webChatContainerProp26.suggestedActionKeyboardFocusIndicatorBorderColor) ?? "#605E5C"} !important;
407
+ outline-offset: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp27 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp27 === void 0 ? void 0 : _webChatContainerProp27.suggestedActionKeyboardFocusIndicatorInset) ?? "2px"} !important;
408
+
307
409
  `), /*#__PURE__*/React.createElement(Stack, {
308
410
  styles: containerStyles,
309
411
  className: "webchat__stacked-layout_container"
310
- }, /*#__PURE__*/React.createElement(BasicWebChat, null)));
412
+ }, /*#__PURE__*/React.createElement("div", {
413
+ id: "ms_lcw_webchat_root",
414
+ style: {
415
+ height: "100%",
416
+ width: "100%"
417
+ }
418
+ }, shouldLoadPersistentHistoryMessages && /*#__PURE__*/React.createElement(WebChatEventSubscribers, {
419
+ persistentChatHistoryEnabled: props === null || props === void 0 ? void 0 : (_props$persistentChat2 = props.persistentChatHistoryProps) === null || _props$persistentChat2 === void 0 ? void 0 : _props$persistentChat2.persistentChatHistoryEnabled
420
+ }), /*#__PURE__*/React.createElement(BasicWebChat, null))), citationPaneOpen && /*#__PURE__*/React.createElement(CitationPaneStateful, {
421
+ id: ((_props$citationPanePr = props.citationPaneProps) === null || _props$citationPanePr === void 0 ? void 0 : _props$citationPanePr.id) || HtmlAttributeNames.ocwCitationPaneClassName,
422
+ title: ((_props$citationPanePr2 = props.citationPaneProps) === null || _props$citationPanePr2 === void 0 ? void 0 : _props$citationPanePr2.title) || HtmlAttributeNames.ocwCitationPaneTitle,
423
+ contentHtml: citationPaneText,
424
+ onClose: () => setCitationPaneOpen(false),
425
+ componentOverrides: (_props$citationPanePr3 = props.citationPaneProps) === null || _props$citationPanePr3 === void 0 ? void 0 : _props$citationPanePr3.componentOverrides,
426
+ controlProps: (_props$citationPanePr4 = props.citationPaneProps) === null || _props$citationPanePr4 === void 0 ? void 0 : _props$citationPanePr4.controlProps,
427
+ styleProps: (_props$citationPanePr5 = props.citationPaneProps) === null || _props$citationPanePr5 === void 0 ? void 0 : _props$citationPanePr5.styleProps
428
+ }));
311
429
  };
312
430
  export default WebChatContainerStateful;
@@ -1,8 +1,6 @@
1
1
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
2
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
3
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
4
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
7
5
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -10,28 +8,59 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
10
8
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
10
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
- import { Observable } from "rxjs/Observable";
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
+ import { customerUser, postAgentAttachmentActivity, postAgentMessageActivity, postAgentSuggestedActionsActivity, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
14
15
  import MockAdapter from "./mockadapter";
15
- import { customerUser, postAgentMessageActivity, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
16
+ import { Observable } from "rxjs/Observable";
16
17
  export let DesignerChatAdapter = /*#__PURE__*/function (_MockAdapter) {
17
18
  _inherits(DesignerChatAdapter, _MockAdapter);
18
19
  var _super = _createSuper(DesignerChatAdapter);
19
- function DesignerChatAdapter() {
20
+ function DesignerChatAdapter(messages) {
20
21
  var _this;
21
22
  _classCallCheck(this, DesignerChatAdapter);
22
23
  _this = _super.call(this);
23
- setTimeout(() => {
24
- postBotMessageActivity(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
25
- postBotMessageActivity(_this.activityObserver, "Please accept terms and conditions to proceed. Visit the link for terms and conditions <a href=\"\">here</a>.", undefined, 0);
26
- _this.postUserActivity("I need to change my address.", 0);
27
- postBotMessageActivity(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
28
- postSystemMessageActivity(_this.activityObserver, "John has joined the chat", 100);
29
- postAgentMessageActivity(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
30
- _this.postUserActivity("I have trouble visiting the signin page <a href=\"\">signin</a>.", 0);
31
- }, 1000);
24
+ _defineProperty(_assertThisInitialized(_this), "messages", void 0);
25
+ _this.messages = messages;
26
+ if (_this.messages) {
27
+ if (_this.messages.length > 0) {
28
+ setTimeout(() => {
29
+ var _this$messages;
30
+ (_this$messages = _this.messages) === null || _this$messages === void 0 ? void 0 : _this$messages.forEach((msg, index) => {
31
+ _this.processMessage(msg, index);
32
+ });
33
+ }, 1000); // Initial 1 second delay to ensure activityObserver is ready
34
+ }
35
+ } else {
36
+ // Default hardcoded flow
37
+ setTimeout(() => {
38
+ postBotMessageActivity(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
39
+ postBotMessageActivity(_this.activityObserver, "Please accept terms and conditions to proceed. Visit the link for terms and conditions <a href=\"\">here</a>.", undefined, 0);
40
+ _this.postUserActivity("I need to change my address.", 0);
41
+ postBotMessageActivity(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
42
+ postSystemMessageActivity(_this.activityObserver, "John has joined the chat", 100);
43
+ postAgentMessageActivity(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
44
+ _this.postUserActivity("I have trouble visiting the signin page <a href=\"\">signin</a>.", 0);
45
+ }, 1000);
46
+ }
32
47
  return _this;
33
48
  }
34
49
  _createClass(DesignerChatAdapter, [{
50
+ key: "processMessage",
51
+ value: function processMessage(msg, index) {
52
+ if (msg.text) {
53
+ if (msg.suggestedActions) {
54
+ postAgentSuggestedActionsActivity(this.activityObserver, msg.text, msg.suggestedActions, index * 100);
55
+ } else {
56
+ postBotMessageActivity(this.activityObserver, msg.text, undefined, index * 100);
57
+ }
58
+ }
59
+ if (msg.attachments && msg.attachments.length > 0) {
60
+ postAgentAttachmentActivity(this.activityObserver, msg.attachments, index * 100, msg.attachmentLayout);
61
+ }
62
+ }
63
+ }, {
35
64
  key: "postUserActivity",
36
65
  value: function postUserActivity(text) {
37
66
  let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
@@ -20,13 +20,18 @@ export let DesignerChatSDK = /*#__PURE__*/function (_MockChatSDK) {
20
20
  var _this;
21
21
  _classCallCheck(this, DesignerChatSDK);
22
22
  _this = _super.call(this);
23
+ /**
24
+ * Create a chat adapter for the designer. Uses this.mockMessages if set.
25
+ */
26
+ _defineProperty(_assertThisInitialized(_this), "mockMessages", void 0);
23
27
  _defineProperty(_assertThisInitialized(_this), "localeId", _this.getLiveChatConfig().ChatWidgetLanguage.msdyn_localeid);
24
28
  return _this;
25
29
  }
26
30
  _createClass(DesignerChatSDK, [{
27
31
  key: "createChatAdapter",
28
32
  value: function createChatAdapter() {
29
- return new DesignerChatAdapter();
33
+ const adapter = new DesignerChatAdapter(this.mockMessages);
34
+ return adapter;
30
35
  }
31
36
  }, {
32
37
  key: "getLiveChatConfig",
@@ -0,0 +1,7 @@
1
+ const botActivity = {
2
+ from: {
3
+ role: "bot"
4
+ },
5
+ type: "message"
6
+ };
7
+ export default botActivity;
@@ -0,0 +1,9 @@
1
+ import { Constants } from "../../../../common/Constants";
2
+ import botActivity from "./botActivity";
3
+ const conversationDividerActivity = {
4
+ ...botActivity,
5
+ channelData: {
6
+ tags: [Constants.conversationDividerTag]
7
+ }
8
+ };
9
+ export default conversationDividerActivity;
@@ -0,0 +1,90 @@
1
+ import { Constants } from "../../../../common/Constants";
2
+ import botActivity from "../activities/botActivity";
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ const convertStringValueToInt = value => {
6
+ if (typeof value !== "string" || value === "") {
7
+ return undefined;
8
+ }
9
+ let result;
10
+ try {
11
+ result = parseInt(value);
12
+ } catch (e) {
13
+ return undefined;
14
+ }
15
+ return isNaN(result) ? undefined : result;
16
+ };
17
+
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ const convertPersistentChatHistoryMessageToActivity = message => {
20
+ var _from$user, _from$application;
21
+ const {
22
+ additionalData,
23
+ attachments,
24
+ content,
25
+ created,
26
+ from,
27
+ transcriptOriginalMessageId
28
+ } = message;
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ const activity = {
31
+ ...botActivity,
32
+ channelData: {
33
+ tags: [Constants.persistentChatHistoryMessageTag]
34
+ }
35
+ };
36
+ let webchatSequenceId;
37
+ let timestamp;
38
+ if (transcriptOriginalMessageId) {
39
+ const id = convertStringValueToInt(transcriptOriginalMessageId); // Id used to determine the sequence of messages which is the same as the 'live' messages
40
+ if (id) {
41
+ webchatSequenceId = id;
42
+ timestamp = new Date(id) || created;
43
+ activity.channelData = {
44
+ ...activity.channelData,
45
+ "webchat:sequence-id": webchatSequenceId
46
+ };
47
+ }
48
+ }
49
+ if (additionalData !== null && additionalData !== void 0 && additionalData.tags) {
50
+ const {
51
+ tags,
52
+ ConversationId
53
+ } = additionalData;
54
+ if (ConversationId) {
55
+ activity.channelData.conversationId = ConversationId;
56
+ }
57
+ if (tags) {
58
+ const formattedTags = additionalData.tags.split(",");
59
+ activity.channelData.tags = [...activity.channelData.tags, ...formattedTags];
60
+ }
61
+ }
62
+ if (from !== null && from !== void 0 && (_from$user = from.user) !== null && _from$user !== void 0 && _from$user.displayName) {
63
+ activity.from.name = from.user.displayName;
64
+ }
65
+ if ((from === null || from === void 0 ? void 0 : (_from$application = from.application) === null || _from$application === void 0 ? void 0 : _from$application.displayName) === "Customer") {
66
+ activity.from = {
67
+ role: "user",
68
+ name: from.application.displayName
69
+ };
70
+ }
71
+ if (content) {
72
+ return {
73
+ ...activity,
74
+ text: content,
75
+ timestamp
76
+ };
77
+ }
78
+ if (attachments && attachments.length > 0) {
79
+ const fileName = attachments[0].name || "Unknown";
80
+ const text = `The following attachment was uploaded during the conversation: ${fileName}`;
81
+ return {
82
+ ...activity,
83
+ text,
84
+ timestamp
85
+ };
86
+ }
87
+ // If neither content nor attachments are present, return null to indicate no activity could be created.
88
+ return null;
89
+ };
90
+ export default convertPersistentChatHistoryMessageToActivity;
@@ -28,5 +28,7 @@ export const defaultMiddlewareLocalizedTexts = {
28
28
  THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Allow sites to save/read cookies in browser settings. Reloading page starts a new chat.",
29
29
  MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware.",
30
30
  MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS: "Email will be sent after chat ends!",
31
- MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later."
31
+ MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later.",
32
+ PREVIOUS_MESSAGES_LOADING: "Loading previous messages...",
33
+ CONVERSATION_DIVIDER_ARIA_LABEL: "Conversation history divider"
32
34
  };
@@ -1,9 +1,9 @@
1
- import { activityStatusMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware";
1
+ import { createActivityStatusMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware";
2
2
  import { groupActivitiesMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
3
3
  import { typingIndicatorMiddleware } from "../../webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
4
4
  export const defaultWebChatStatefulProps = {
5
5
  // activityMiddleware: activityMiddleware, - this is implemented elsewhere and can be customized
6
- activityStatusMiddleware: activityStatusMiddleware,
6
+ activityStatusMiddleware: createActivityStatusMiddleware(),
7
7
  // avatarMiddleware: avatarMiddleware, - this is implemented elsewhere and can be customized
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  groupActivitiesMiddleware: groupActivitiesMiddleware,
@@ -17,7 +17,7 @@ export const defaultWebChatStyles = {
17
17
  bubbleTextColor: "White",
18
18
  hideSendBox: false,
19
19
  hideUploadButton: true,
20
- primaryFont: "Segoe UI, Arial, sans-serif",
20
+ primaryFont: "Segoe UI, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\"",
21
21
  rootHeight: "100%",
22
22
  rootWidth: "100%",
23
23
  sendBoxTextWrap: true,
@@ -97,4 +97,36 @@ export const postBotAttachmentActivity = function (activityObserver) {
97
97
  timestamp: new Date().toISOString()
98
98
  });
99
99
  }, delay);
100
+ };
101
+ export const postAgentAttachmentActivity = function (activityObserver) {
102
+ let attachments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
103
+ let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
104
+ let attachmentLayout = arguments.length > 3 ? arguments[3] : undefined;
105
+ setTimeout(() => {
106
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
107
+ id: uuidv4(),
108
+ from: {
109
+ ...agentUser
110
+ },
111
+ attachments,
112
+ attachmentLayout,
113
+ type: "message",
114
+ timestamp: new Date().toISOString()
115
+ });
116
+ }, delay);
117
+ };
118
+ export const postAgentSuggestedActionsActivity = function (activityObserver, text, suggestedActions) {
119
+ let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
120
+ setTimeout(() => {
121
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
122
+ id: uuidv4(),
123
+ from: {
124
+ ...agentUser
125
+ },
126
+ text,
127
+ type: "message",
128
+ suggestedActions,
129
+ timestamp: new Date().toISOString()
130
+ });
131
+ }, delay);
100
132
  };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Utility functions for font handling and emoji support
3
+ */
4
+
5
+ /**
6
+ * Creates a font family optimized for iOS emoji support
7
+ * Uses system-ui as the primary font for better emoji rendering on iOS
8
+ * @param primaryFont - The base font family string (optional, used as fallback)
9
+ * @returns Font family string optimized for iOS emoji support
10
+ */
11
+ export const createIOSOptimizedEmojiFont = primaryFont => {
12
+ // For iOS emoji support, system-ui should be first
13
+ const baseFont = "system-ui";
14
+ const emojiSupport = "\"Apple Color Emoji\", \"Segoe UI Emoji\"";
15
+ if (!primaryFont || primaryFont.includes("system-ui") || primaryFont.includes("Apple Color Emoji")) {
16
+ return `${baseFont}, ${emojiSupport}`;
17
+ }
18
+
19
+ // Add configured font as fallback after emoji fonts
20
+ return `${baseFont}, ${emojiSupport}, ${primaryFont}`;
21
+ };
@@ -0,0 +1,51 @@
1
+ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { useEffect, useRef } from "react";
3
+ import ChatWidgetEvents from "../../livechatwidget/common/ChatWidgetEvents";
4
+ import PersistentConversationHandler from "../../livechatwidget/common/PersistentConversationHandler";
5
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
6
+ import dispatchCustomEvent from "../../../common/utils/dispatchCustomEvent";
7
+ import SecureEventBus from "../../../common/utils/SecureEventBus";
8
+ const usePersistentChatHistory = (facadeChatSDK, props) => {
9
+ const handlerRef = useRef(null);
10
+ useEffect(() => {
11
+ if (!facadeChatSDK) {
12
+ return;
13
+ }
14
+ TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
15
+ Event: TelemetryEvent.UXLCWPersistentChatHistoryInitialized,
16
+ Description: "Persistent chat history hook initialized"
17
+ });
18
+ handlerRef.current = new PersistentConversationHandler(facadeChatSDK, props);
19
+ const handler = async () => {
20
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
21
+ Event: TelemetryEvent.LCWPersistentChatHistoryFetchStarted,
22
+ Description: "Persistent chat history fetch started"
23
+ });
24
+ try {
25
+ var _handlerRef$current;
26
+ await ((_handlerRef$current = handlerRef.current) === null || _handlerRef$current === void 0 ? void 0 : _handlerRef$current.pullHistory());
27
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
28
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
29
+ Event: TelemetryEvent.LCWPersistentChatHistoryFetchCompleted,
30
+ Description: "Persistent chat history fetch completed successfully"
31
+ });
32
+ } catch (error) {
33
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.ERROR, {
34
+ Event: TelemetryEvent.LCWPersistentChatHistoryFetchFailed,
35
+ Description: "Persistent chat history fetch failed",
36
+ ExceptionDetails: error
37
+ });
38
+ }
39
+ };
40
+
41
+ // Subscribe to the secure event bus instead of global window events
42
+ const eventBus = SecureEventBus.getInstance();
43
+ const unsubscribe = eventBus.subscribe(ChatWidgetEvents.FETCH_PERSISTENT_CHAT_HISTORY, handler);
44
+ return () => {
45
+ var _handlerRef$current2;
46
+ unsubscribe();
47
+ (_handlerRef$current2 = handlerRef.current) === null || _handlerRef$current2 === void 0 ? void 0 : _handlerRef$current2.destroy(); // Call destroy instead of reset to properly clean up
48
+ };
49
+ }, [facadeChatSDK]);
50
+ };
51
+ export default usePersistentChatHistory;