@microsoft/omnichannel-chat-widget 1.0.3-main.527b216 → 1.0.3-main.87088f3

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 (95) hide show
  1. package/lib/cjs/common/Constants.js +54 -1
  2. package/lib/cjs/common/storage/default/defaultCacheManager.js +7 -6
  3. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +9 -7
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +7 -1
  5. package/lib/cjs/common/utils.js +27 -5
  6. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +1 -10
  7. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
  8. package/lib/cjs/components/footerstateful/FooterStateful.js +1 -1
  9. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +12 -1
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -13
  11. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
  12. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
  13. package/lib/cjs/components/livechatwidget/common/Deferred.js +2 -3
  14. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -2
  15. package/lib/cjs/components/livechatwidget/common/endChat.js +197 -99
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +32 -27
  17. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -8
  18. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +139 -0
  19. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +2 -255
  20. package/lib/cjs/components/livechatwidget/common/startChat.js +85 -69
  21. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +162 -100
  22. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
  23. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +18 -8
  24. package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -2
  25. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
  26. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
  27. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
  28. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
  29. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
  30. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
  31. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
  32. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +16 -13
  33. package/lib/cjs/contexts/createReducer.js +13 -23
  34. package/lib/cjs/controller/componentController.js +2 -1
  35. package/lib/cjs/index.js +20 -0
  36. package/lib/esm/common/Constants.js +49 -0
  37. package/lib/esm/common/storage/default/defaultCacheManager.js +5 -4
  38. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +9 -7
  39. package/lib/esm/common/telemetry/TelemetryConstants.js +7 -1
  40. package/lib/esm/common/utils.js +25 -4
  41. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -13
  42. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
  43. package/lib/esm/components/footerstateful/FooterStateful.js +1 -1
  44. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -1
  45. package/lib/esm/components/headerstateful/HeaderStateful.js +14 -13
  46. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
  47. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
  48. package/lib/esm/components/livechatwidget/common/Deferred.js +2 -3
  49. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -2
  50. package/lib/esm/components/livechatwidget/common/endChat.js +196 -99
  51. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +32 -27
  52. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -8
  53. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +130 -0
  54. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -255
  55. package/lib/esm/components/livechatwidget/common/startChat.js +86 -70
  56. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +164 -102
  57. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
  58. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +18 -8
  59. package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -2
  60. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
  61. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
  62. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
  63. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
  64. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
  65. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
  66. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
  67. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -15
  68. package/lib/esm/contexts/createReducer.js +13 -23
  69. package/lib/esm/controller/componentController.js +2 -1
  70. package/lib/esm/index.js +4 -1
  71. package/lib/types/common/Constants.d.ts +21 -0
  72. package/lib/types/common/interfaces/IContextDataStore.d.ts +3 -3
  73. package/lib/types/common/storage/default/defaultCacheManager.d.ts +2 -1
  74. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -1
  75. package/lib/types/common/telemetry/TelemetryConstants.d.ts +7 -1
  76. package/lib/types/common/utils.d.ts +3 -2
  77. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +6 -0
  78. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
  79. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
  80. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  81. package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +9 -0
  82. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -6
  83. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
  84. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +4 -0
  85. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +8 -7
  86. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  87. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +2 -1
  88. package/lib/types/index.d.ts +3 -0
  89. package/package.json +2 -1
  90. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +0 -36
  91. package/lib/cjs/contexts/common/ConversationEndEntity.js +0 -12
  92. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +0 -30
  93. package/lib/esm/contexts/common/ConversationEndEntity.js +0 -5
  94. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +0 -6
  95. package/lib/types/contexts/common/ConversationEndEntity.d.ts +0 -4
@@ -31,7 +31,6 @@ export let BroadcastEvent;
31
31
  BroadcastEvent["StartProactiveChat"] = "StartProactiveChat";
32
32
  BroadcastEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
33
33
  BroadcastEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
34
- BroadcastEvent["ProactiveChatIsInPopoutMode"] = "ProactiveChatIsInPopoutMode";
35
34
  BroadcastEvent["ResetProactiveChatParams"] = "ResetProactiveChatParams";
36
35
  BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
37
36
  BroadcastEvent["NewMessageSent"] = "NewMessageSent";
@@ -54,6 +53,8 @@ export let BroadcastEvent;
54
53
  BroadcastEvent["SigninCardReceived"] = "SignInCardReceived";
55
54
  BroadcastEvent["BotAuthConfigRequest"] = "BotAuthConfigRequest";
56
55
  BroadcastEvent["BotAuthConfigResponse"] = "BotAuthConfigResponse";
56
+ BroadcastEvent["RemoveWidgetDataFromCache"] = "RemoveWidgetDataFromCache";
57
+ BroadcastEvent["InitiateStartChatInPopoutMode"] = "InitiateStartChatInPopoutMode";
57
58
  BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
58
59
  BroadcastEvent["UpdateSessionDataForTelemetry"] = "UpdateSessionDataForTelemetry";
59
60
  BroadcastEvent["UpdateConversationDataForTelemetry"] = "UpdateConversationDataForTelemetry";
@@ -89,13 +90,18 @@ export let TelemetryEvent;
89
90
  TelemetryEvent["CallingSDKInitFailed"] = "CallingSDKInitFailed";
90
91
  TelemetryEvent["CallingSDKLoadSuccess"] = "CallingSDKLoadSuccess";
91
92
  TelemetryEvent["CallingSDKLoadFailed"] = "CallingSDKLoadFailed";
93
+ TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
92
94
  TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
93
95
  TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
96
+ TelemetryEvent["GetChatReconnectContextSDKCallStarted"] = "GetChatReconnectContextSDKCallStarted";
94
97
  TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
95
98
  TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
96
99
  TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
97
100
  TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
98
101
  TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
102
+ TelemetryEvent["EndChatSucceeded"] = "EndChatSucceeded";
103
+ TelemetryEvent["EndChatFailed"] = "EndChatFailed";
104
+ TelemetryEvent["SetCustomContext"] = "SetCustomContext";
99
105
  TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
100
106
  TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
101
107
  TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
@@ -258,7 +258,11 @@ export const getDomain = hostValue => {
258
258
  }
259
259
  return AriaTelemetryConstants.Public;
260
260
  };
261
- export const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
261
+ export const getWidgetCacheId = function (orgId, widgetId, widgetInstanceId) {
262
+ let popoutChat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
263
+ if (popoutChat) {
264
+ widgetInstanceId = widgetInstanceId + Constants.PopoutCacheSuffix;
265
+ }
262
266
  const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
263
267
  return Md5.init(widgetCacheId);
264
268
  };
@@ -270,13 +274,13 @@ export const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) =>
270
274
  };
271
275
 
272
276
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
273
- export const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
277
+ export const getStateFromCache = widgetCacheId => {
274
278
  // Getting updated state from cache
275
279
  try {
276
280
  if (DataStoreManager.clientDataStore) {
277
281
  var _DataStoreManager$cli;
278
- const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
279
- const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
282
+ const widgetStateEventName = widgetCacheId;
283
+ const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName);
280
284
  const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
281
285
  return persistedState;
282
286
  } else {
@@ -308,6 +312,23 @@ export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
308
312
  return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
309
313
  };
310
314
 
315
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
316
+ export const getWidgetCacheIdfromProps = function (props) {
317
+ var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$controlProps2;
318
+ let popoutChat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
319
+ const orgId = props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId;
320
+ const widgetId = props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId;
321
+ let widgetInstanceId = (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "";
322
+ if (props.useSessionStorage) {
323
+ widgetInstanceId = widgetInstanceId + Constants.SessionCacheSuffix;
324
+ }
325
+ if (props !== null && props !== void 0 && (_props$controlProps2 = props.controlProps) !== null && _props$controlProps2 !== void 0 && _props$controlProps2.hideStartChatButton || popoutChat === true) {
326
+ popoutChat = true;
327
+ }
328
+ const widgetCacheId = getWidgetCacheId(orgId, widgetId, widgetInstanceId, popoutChat);
329
+ return widgetCacheId;
330
+ };
331
+
311
332
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
312
333
  export const debounceLeading = function (fn) {
313
334
  let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3000;
@@ -1,6 +1,6 @@
1
- import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
- import React, { useEffect, useRef, useState } from "react";
3
- import { BroadcastService, ChatButton } from "@microsoft/omnichannel-chat-components";
1
+ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
+ import React, { useEffect, useState } from "react";
3
+ import { ChatButton } from "@microsoft/omnichannel-chat-components";
4
4
  import { Constants } from "../../common/Constants";
5
5
  import { setFocusOnElement } from "../../common/utils";
6
6
  import { ConversationState } from "../../contexts/common/ConversationState";
@@ -19,7 +19,6 @@ export const ChatButtonStateful = props => {
19
19
  } = props;
20
20
  //Setting OutOfOperatingHours Flag
21
21
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
22
- const proactiveChatInNewWindow = useRef(state.appStates.proactiveChatStates.proactiveChatInNewWindow);
23
22
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
24
23
  const controlProps = {
25
24
  id: "oc-lcw-chat-button",
@@ -32,12 +31,7 @@ export const ChatButtonStateful = props => {
32
31
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
33
32
  Event: TelemetryEvent.LCWChatButtonClicked
34
33
  });
35
- if (proactiveChatInNewWindow.current) {
36
- const proactiveChatIsInPopoutModeEvent = {
37
- eventName: BroadcastEvent.ProactiveChatIsInPopoutMode
38
- };
39
- BroadcastService.postMessage(proactiveChatIsInPopoutModeEvent);
40
- } else if (state.appStates.isMinimized) {
34
+ if (state.appStates.isMinimized) {
41
35
  dispatch({
42
36
  type: LiveChatWidgetActionType.SET_MINIMIZED,
43
37
  payload: false
@@ -90,9 +84,6 @@ export const ChatButtonStateful = props => {
90
84
  });
91
85
  }
92
86
  }, []);
93
- useEffect(() => {
94
- proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
95
- }, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
96
87
  return /*#__PURE__*/React.createElement(ChatButton, {
97
88
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
98
89
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -5,9 +5,8 @@ import { findAllFocusableElement, findParentFocusableElementsWithoutChildContain
5
5
  import { DimLayer } from "../dimlayer/DimLayer";
6
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
7
7
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
8
- import useChatAdapterStore from "../../hooks/useChatAdapterStore";
9
8
  import useChatContextStore from "../../hooks/useChatContextStore";
10
- import { ConversationEndEntity } from "../../contexts/common/ConversationEndEntity";
9
+ import { ConfirmationState } from "../../common/Constants";
11
10
 
12
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
12
  export const ConfirmationPaneStateful = props => {
@@ -15,7 +14,6 @@ export const ConfirmationPaneStateful = props => {
15
14
  let elements = [];
16
15
  const [state, dispatch] = useChatContextStore();
17
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
18
- const [adapter] = useChatAdapterStore();
19
17
  const controlProps = {
20
18
  id: "oc-lcw-confirmation-pane",
21
19
  dir: state.domainStates.globalDir,
@@ -28,11 +26,11 @@ export const ConfirmationPaneStateful = props => {
28
26
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
29
27
  payload: false
30
28
  });
31
- setTabIndices(elements, initialTabIndexMap, true);
32
29
  dispatch({
33
- type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
34
- payload: ConversationEndEntity.Customer
30
+ type: LiveChatWidgetActionType.SET_CONFIRMATION_STATE,
31
+ payload: ConfirmationState.Ok
35
32
  });
33
+ setTabIndices(elements, initialTabIndexMap, true);
36
34
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
37
35
  Event: TelemetryEvent.ConversationEndedByCustomer,
38
36
  Description: "Conversation is ended by customer."
@@ -47,6 +45,10 @@ export const ConfirmationPaneStateful = props => {
47
45
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
48
46
  payload: false
49
47
  });
48
+ dispatch({
49
+ type: LiveChatWidgetActionType.SET_CONFIRMATION_STATE,
50
+ payload: ConfirmationState.Cancel
51
+ });
50
52
  const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
51
53
  if (previousFocusedElementId) {
52
54
  setFocusOnElement("#" + previousFocusedElementId);
@@ -36,7 +36,7 @@ export const FooterStateful = props => {
36
36
  Event: TelemetryEvent.DownloadTranscriptButtonClicked,
37
37
  Description: "Download Transcript button clicked."
38
38
  });
39
- await downloadTranscript(chatSDK, downloadTranscriptProps === null || downloadTranscriptProps === void 0 ? void 0 : downloadTranscriptProps.renderMarkDown, downloadTranscriptProps === null || downloadTranscriptProps === void 0 ? void 0 : downloadTranscriptProps.bannerMessageOnError, downloadTranscriptProps === null || downloadTranscriptProps === void 0 ? void 0 : downloadTranscriptProps.attachmentMessage);
39
+ await downloadTranscript(chatSDK, downloadTranscriptProps === null || downloadTranscriptProps === void 0 ? void 0 : downloadTranscriptProps.renderMarkDown, downloadTranscriptProps === null || downloadTranscriptProps === void 0 ? void 0 : downloadTranscriptProps.bannerMessageOnError, downloadTranscriptProps === null || downloadTranscriptProps === void 0 ? void 0 : downloadTranscriptProps.attachmentMessage, state);
40
40
  } catch (ex) {
41
41
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
42
42
  Event: TelemetryEvent.DownloadTranscriptFailed,
@@ -3,6 +3,7 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
3
3
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
4
4
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
5
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
6
+ import DOMPurify from "dompurify";
6
7
  const processDisplayName = displayName => {
7
8
  // if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
8
9
  const displayNameRegex = ".+:.+";
@@ -58,6 +59,8 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
58
59
  }
59
60
  if (renderMarkDown) {
60
61
  transcriptContent = renderMarkDown(transcriptContent);
62
+ } else {
63
+ transcriptContent = DOMPurify.sanitize(transcriptContent);
61
64
  }
62
65
  return transcriptContent;
63
66
  };
@@ -151,8 +154,15 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
151
154
  };
152
155
 
153
156
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
- export const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage) => {
157
+ export const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage, state) => {
158
+ var _state$domainStates, _state$domainStates2, _state$domainStates2$;
159
+ // Need to keep existing request id for scenarios when trnascript is downloaded after endchat
160
+ const existingRequestId = chatSDK.requestId;
161
+ chatSDK.chatToken = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.chatToken;
162
+ chatSDK.requestId = state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.chatToken) === null || _state$domainStates2$ === void 0 ? void 0 : _state$domainStates2$.requestId;
155
163
  let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript());
164
+ // This is used for allowing to start next chat
165
+ chatSDK.requestId = existingRequestId;
156
166
  if (typeof data === Constants.String) {
157
167
  data = JSON.parse(data);
158
168
  }
@@ -7,9 +7,9 @@ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
7
7
  import { defaultOutOfOfficeHeaderStyleProps } from "./common/styleProps/defaultOutOfOfficeHeaderStyleProps";
8
8
  import useChatAdapterStore from "../../hooks/useChatAdapterStore";
9
9
  import useChatContextStore from "../../hooks/useChatContextStore";
10
- import { ConversationEndEntity } from "../../contexts/common/ConversationEndEntity";
10
+ import { ConfirmationState } from "../../common/Constants";
11
11
  export const HeaderStateful = props => {
12
- var _state$domainStates$l, _state$domainStates$l2, _headerProps$controlP, _headerProps$controlP2, _headerProps$controlP3, _outOfOfficeHeaderPro;
12
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates, _headerProps$controlP, _headerProps$controlP2, _headerProps$controlP3, _outOfOfficeHeaderPro, _state$domainStates3;
13
13
  const [state, dispatch] = useChatContextStore();
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  const [adapter] = useChatAdapterStore();
@@ -21,8 +21,9 @@ export const HeaderStateful = props => {
21
21
  //Setting OutOfOperatingHours Flag
22
22
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
23
23
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
24
- const conversationState = useRef(state.appStates.conversationState);
25
- const conversationEndedBy = useRef(state.appStates.conversationEndedBy);
24
+
25
+ // For some reason state object is not getting updated values in this component
26
+ const localConfirmationPaneState = useRef(state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.confirmationState);
26
27
  const controlProps = {
27
28
  id: "oc-lcw-header",
28
29
  dir: state.domainStates.globalDir,
@@ -42,7 +43,7 @@ export const HeaderStateful = props => {
42
43
  Event: TelemetryEvent.HeaderCloseButtonClicked,
43
44
  Description: "Header Close button clicked."
44
45
  });
45
- if (conversationState.current === ConversationState.Active || conversationEndedBy.current === ConversationEndEntity.Agent) {
46
+ if (localConfirmationPaneState.current !== ConfirmationState.Ok) {
46
47
  dispatch({
47
48
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
48
49
  payload: true
@@ -62,9 +63,9 @@ export const HeaderStateful = props => {
62
63
  }
63
64
  },
64
65
  ...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
65
- hideTitle: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
66
- hideIcon: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
67
- hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
66
+ hideTitle: state.appStates.conversationState === ConversationState.Loading && !state.appStates.startChatFailed || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
67
+ hideIcon: state.appStates.conversationState === ConversationState.Loading && !state.appStates.startChatFailed || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
68
+ hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.startChatFailed || state.appStates.conversationState === ConversationState.PostchatLoading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
68
69
  };
69
70
  const outOfOfficeControlProps = {
70
71
  id: "oc-lcw-header",
@@ -85,11 +86,11 @@ export const HeaderStateful = props => {
85
86
  if (state.appStates.outsideOperatingHours) {
86
87
  setOutOfOperatingHours(true);
87
88
  }
88
- if (state.appStates.conversationState) {
89
- conversationState.current = state.appStates.conversationState;
90
- }
91
- conversationEndedBy.current = state.appStates.conversationEndedBy;
92
- }, [state.appStates]);
89
+ }, []);
90
+ useEffect(() => {
91
+ var _state$domainStates2;
92
+ localConfirmationPaneState.current = state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.confirmationState;
93
+ }, [state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.confirmationState]);
93
94
  return /*#__PURE__*/React.createElement(Header, {
94
95
  componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
95
96
  controlProps: outOfOperatingHours || state.appStates.conversationState === ConversationState.OutOfOffice ? outOfOfficeControlProps : controlProps,
@@ -3,6 +3,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
3
3
  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); }
4
4
  export class DefaultActivitySubscriber {
5
5
  constructor() {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
7
  _defineProperty(this, "observer", void 0);
7
8
  }
8
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -4,6 +4,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
4
4
  import { ActivityStreamHandler } from "../ActivityStreamHandler";
5
5
  export class PauseActivitySubscriber {
6
6
  constructor() {
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
8
  _defineProperty(this, "observer", void 0);
8
9
  }
9
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -10,9 +10,11 @@ export class Deferred {
10
10
  _defineProperty(this, "_reject", () => {
11
11
  return;
12
12
  });
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
14
  _defineProperty(this, "resolve", value => {
14
15
  this._resolve(value);
15
16
  });
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
18
  _defineProperty(this, "reject", value => {
17
19
  this._reject(value);
18
20
  });
@@ -21,9 +23,6 @@ export class Deferred {
21
23
  this._reject = reject;
22
24
  });
23
25
  }
24
-
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
-
27
26
  get promise() {
28
27
  return this._promise;
29
28
  }
@@ -1190,7 +1190,13 @@ export const dummyDefaultProps = {
1190
1190
  borderRadius: "0 0 4px 4px",
1191
1191
  borderWidth: "3px",
1192
1192
  backgroundColor: "#FFFFFF",
1193
- borderColor: "#F1F1F1"
1193
+ borderColor: "#F1F1F1",
1194
+ position: "initial",
1195
+ height: "100%",
1196
+ width: "100%",
1197
+ left: "0%",
1198
+ top: "0%",
1199
+ display: "contents"
1194
1200
  }
1195
1201
  },
1196
1202
  isCustomerVoiceSurveyCompact: undefined
@@ -1789,5 +1795,6 @@ export const dummyDefaultProps = {
1789
1795
  hyperlinkTextOverride: false
1790
1796
  },
1791
1797
  telemetryConfig: undefined,
1792
- getAuthToken: undefined
1798
+ getAuthToken: undefined,
1799
+ initialCustomContext: undefined
1793
1800
  };