@microsoft/omnichannel-chat-widget 0.1.0-main.8e79cb8 → 0.1.0-main.9e62ed8

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 (55) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +12 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +14 -2
  4. package/lib/cjs/common/utils.js +1 -1
  5. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +15 -3
  6. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
  7. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -1
  8. package/lib/cjs/components/livechatwidget/common/endChat.js +3 -3
  9. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -3
  10. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +129 -36
  11. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
  12. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  13. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  14. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  15. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  16. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  17. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  18. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  19. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
  20. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
  21. package/lib/cjs/contexts/createReducer.js +8 -0
  22. package/lib/cjs/controller/componentController.js +1 -1
  23. package/lib/esm/common/Constants.js +12 -0
  24. package/lib/esm/common/telemetry/TelemetryConstants.js +14 -2
  25. package/lib/esm/common/utils.js +1 -1
  26. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -6
  27. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
  28. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -1
  29. package/lib/esm/components/livechatwidget/common/endChat.js +3 -2
  30. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +7 -4
  31. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +120 -35
  32. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
  33. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  34. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  35. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  36. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  37. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  38. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  39. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  40. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
  41. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
  42. package/lib/esm/contexts/createReducer.js +8 -0
  43. package/lib/esm/controller/componentController.js +1 -1
  44. package/lib/types/common/Constants.d.ts +6 -0
  45. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  46. package/lib/types/common/telemetry/TelemetryConstants.d.ts +15 -3
  47. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  48. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  49. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  50. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  51. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  52. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  53. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  54. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  55. package/package.json +2 -2
package/README.md CHANGED
@@ -11,6 +11,8 @@
11
11
  1. [Installation](#installation)
12
12
  1. [Example Usage](#example-usage)
13
13
  1. [Components](#components)
14
+ 1. [Common Scenarios](#common-scenarios)
15
+ - [Disable Bot Magic Code](#disable-bot-magic-code)
14
16
  1. [See Also](#see-also)
15
17
 
16
18
  ## Introduction
@@ -218,6 +220,36 @@ const customizedFooterProp: IFooterProps = {
218
220
 
219
221
  > :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
220
222
 
223
+ ## Common Scenarios
224
+
225
+ ### Disable Bot Magic Code
226
+
227
+ Configuration to disable the default behaviour of having to type the magic code in the conversation to complete the sign-in proccess with a bot. Instead, the magic code will be sent to the bot behind the scenes.
228
+
229
+ 1. Add [MagicCodeForwarder.html](sample/MagicCodeForwarder.html) in the same location as the chat widget
230
+
231
+ 2. Add `botMagicCode` configuration to disable default magic code feature
232
+
233
+ > :exclamation: `fwdUrl` **MUST** have the same `origin` as the chat widget URL
234
+
235
+ ```js
236
+ const liveChatWidgetProps = {
237
+ chatSDK: chatSDK, // mandatory
238
+ chatConfig: chatConfig, // mandatory
239
+ webChatContainerProps: {
240
+ botMagicCode: {
241
+ disabled: true,
242
+ fwdUrl: 'http://localhost:8000/sample/MagicCodeForwarder.html'
243
+ }
244
+ },
245
+ };
246
+
247
+ ReactDOM.render(
248
+ <LiveChatWidget {...liveChatWidgetProps}/>,
249
+ document.getElementById("my-container")
250
+ );
251
+ ```
252
+
221
253
  ## See Also
222
254
 
223
255
  [Telemetry](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Telemetry.md)\
@@ -13,6 +13,10 @@ class Constants {}
13
13
 
14
14
  exports.Constants = Constants;
15
15
 
16
+ _defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
17
+
18
+ _defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
19
+
16
20
  _defineProperty(Constants, "systemMessageTag", "system");
17
21
 
18
22
  _defineProperty(Constants, "userMessageTag", "user");
@@ -79,6 +83,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
79
83
 
80
84
  _defineProperty(Constants, "message", "message");
81
85
 
86
+ _defineProperty(Constants, "hiddenTag", "Hidden");
87
+
88
+ _defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
89
+
90
+ _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
91
+
92
+ _defineProperty(Constants, "publicMessageTag", "public");
93
+
82
94
  _defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
83
95
 
84
96
  _defineProperty(Constants, "maxUploadFileSize", "500000");
@@ -37,19 +37,28 @@ exports.BroadcastEvent = BroadcastEvent;
37
37
 
38
38
  (function (BroadcastEvent) {
39
39
  BroadcastEvent["LoadPostChatSurvey"] = "LoadPostChatSurvey";
40
- BroadcastEvent["EndChat"] = "ChatEnded";
40
+ BroadcastEvent["ChatEnded"] = "ChatEnded";
41
41
  BroadcastEvent["NewMessageNotification"] = "NewMessageNotification";
42
42
  BroadcastEvent["UnreadMessageCount"] = "UnreadMessageCount";
43
+ BroadcastEvent["StartProactiveChat"] = "StartProactiveChat";
43
44
  BroadcastEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
44
45
  BroadcastEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
46
+ BroadcastEvent["ProactiveChatIsInPopoutMode"] = "ProactiveChatIsInPopoutMode";
47
+ BroadcastEvent["ResetProactiveChatParams"] = "ResetProactiveChatParams";
45
48
  BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
46
49
  BroadcastEvent["NewMessageSent"] = "NewMessageSent";
47
50
  BroadcastEvent["NewMessageReceived"] = "NewMessageReceived";
48
51
  BroadcastEvent["RedirectPageRequest"] = "RedirectPageRequest";
52
+ BroadcastEvent["StartChat"] = "StartChat";
49
53
  BroadcastEvent["StartChatSkippingChatButtonRendering"] = "StartChatSkippingChatButtonRendering";
50
54
  BroadcastEvent["StartUnauthenticatedReconnectChat"] = "StartUnauthenticatedReconnectChat";
55
+ BroadcastEvent["InitiateEndChat"] = "InitiateEndChat";
51
56
  BroadcastEvent["SetCustomContext"] = "SetCustomContext";
52
57
  BroadcastEvent["ChatRetrievedFromCache"] = "ChatRetrievedFromCache";
58
+ BroadcastEvent["MaximizeChat"] = "MaximizeChat";
59
+ BroadcastEvent["ChatInitiated"] = "ChatInitiated";
60
+ BroadcastEvent["CloseChat"] = "CloseChat";
61
+ BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
53
62
  })(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
54
63
 
55
64
  let TelemetryEvent;
@@ -102,8 +111,9 @@ exports.TelemetryEvent = TelemetryEvent;
102
111
  TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
103
112
  TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
104
113
  TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
105
- TelemetryEvent["EndChatSDKCall"] = "EndChatCall";
114
+ TelemetryEvent["EndChatSDKCall"] = "EndChatSDKCall";
106
115
  TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
116
+ TelemetryEvent["WindowClosed"] = "WindowClosed";
107
117
  TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
108
118
  TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
109
119
  TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
@@ -128,6 +138,8 @@ exports.TelemetryEvent = TelemetryEvent;
128
138
  TelemetryEvent["EmailTranscriptButtonClicked"] = "EmailTranscriptButtonClicked";
129
139
  TelemetryEvent["EmailTranscriptCancelButtonClicked"] = "EmailTranscriptCancelButtonClicked";
130
140
  TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
141
+ TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
142
+ TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
131
143
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
132
144
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
133
145
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -359,7 +359,7 @@ const getWidgetCacheId = (orgId, widgetId) => {
359
359
  exports.getWidgetCacheId = getWidgetCacheId;
360
360
 
361
361
  const getWidgetEndChatEventName = (orgId, widgetId) => {
362
- return `${_TelemetryConstants.BroadcastEvent.EndChat}_${orgId}_${widgetId}`;
362
+ return `${_TelemetryConstants.BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
363
363
  };
364
364
 
365
365
  exports.getWidgetEndChatEventName = getWidgetEndChatEventName;
@@ -34,7 +34,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
34
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
35
 
36
36
  const ChatButtonStateful = props => {
37
- var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP;
37
+ var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
38
38
 
39
39
  const [state, dispatch] = (0, _useChatContextStore.default)();
40
40
  const {
@@ -44,6 +44,7 @@ const ChatButtonStateful = props => {
44
44
  } = props; //Setting OutOfOperatingHours Flag
45
45
 
46
46
  const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.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");
47
+ const proactiveChatInNewWindow = (0, _react.useRef)(state.appStates.proactiveChatStates.proactiveChatInNewWindow);
47
48
  const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
48
49
  const controlProps = {
49
50
  id: "oc-lcw-chat-button",
@@ -51,13 +52,19 @@ const ChatButtonStateful = props => {
51
52
  titleText: "Let's Chat!",
52
53
  subtitleText: "We're online.",
53
54
  hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
54
- unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > _Constants.Constants.maximumUnreadMessageCount ? _Constants.Constants.maximumUnreadMessageCount.toString() + "+" : state.appStates.unreadMessageCount.toString() : "0",
55
+ unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > _Constants.Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
55
56
  onClick: async () => {
56
57
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
57
58
  Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
58
59
  });
59
60
 
60
- if (state.appStates.isMinimized) {
61
+ if (proactiveChatInNewWindow.current) {
62
+ const proactiveChatIsInPopoutModeEvent = {
63
+ eventName: _TelemetryConstants.BroadcastEvent.ProactiveChatIsInPopoutMode
64
+ };
65
+
66
+ _omnichannelChatComponents.BroadcastService.postMessage(proactiveChatIsInPopoutModeEvent);
67
+ } else if (state.appStates.isMinimized) {
61
68
  dispatch({
62
69
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
63
70
  payload: false
@@ -66,6 +73,7 @@ const ChatButtonStateful = props => {
66
73
  await startChat();
67
74
  }
68
75
  },
76
+ unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
69
77
  ...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
70
78
  };
71
79
  const outOfOfficeControlProps = {
@@ -86,6 +94,7 @@ const ChatButtonStateful = props => {
86
94
  });
87
95
  }
88
96
  },
97
+ unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
89
98
  ...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
90
99
  };
91
100
  (0, _react.useEffect)(() => {
@@ -107,6 +116,9 @@ const ChatButtonStateful = props => {
107
116
  });
108
117
  }
109
118
  }, []);
119
+ (0, _react.useEffect)(() => {
120
+ proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
121
+ }, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
110
122
  return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
111
123
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
112
124
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -116,8 +116,17 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
116
116
  let fileAttachmentName = _Constants.TranscriptConstants.DefaultFileAttachmentName;
117
117
  let dialogColor = _Constants.TranscriptConstants.CustomerDialogColor;
118
118
  let fontColor = _Constants.TranscriptConstants.CustomerFontColor;
119
+ const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.systemMessageTag) !== -1;
120
+ const isControlMessage = value.isControlMessage && value.isControlMessage === true;
119
121
 
120
- if (value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.systemMessageTag) !== -1 || value.isControlMessage && value.isControlMessage === true || value.contentType && value.contentType.toLowerCase() === _Constants.TranscriptConstants.AdaptiveCardType || value.deliveryMode && value.deliveryMode.toLowerCase() === _Constants.TranscriptConstants.InternalMode) {
122
+ const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === _Constants.TranscriptConstants.AdaptiveCardType;
123
+
124
+ const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === _Constants.TranscriptConstants.InternalMode;
125
+
126
+ const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.hiddenTag.toLowerCase()) !== -1;
127
+ const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
128
+
129
+ if (shouldIgnoreMessage) {
121
130
  return;
122
131
  } else if (value.from) {
123
132
  if (value.from.application) {
@@ -337,7 +337,9 @@ const dummyDefaultProps = {
337
337
  hideChatTextContainer: false,
338
338
  hideChatSubtitle: false,
339
339
  hideChatTitle: false,
340
- hideNotificationBubble: true
340
+ hideNotificationBubble: true,
341
+ unreadMessageString: "new messages",
342
+ largeUnreadMessageString: "99+"
341
343
  },
342
344
  styleProps: {
343
345
  generalStyleProps: {
@@ -1697,6 +1699,10 @@ const dummyDefaultProps = {
1697
1699
  MIDDLEWARE_MESSAGE_RETRY: "Retry",
1698
1700
  PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
1699
1701
  MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
1702
+ },
1703
+ botMagicCode: {
1704
+ disabled: false,
1705
+ fwdUrl: ""
1700
1706
  }
1701
1707
  },
1702
1708
  telemetryConfig: undefined
@@ -113,9 +113,9 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
113
113
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
114
114
  payload: null
115
115
  });
116
-
117
- _omnichannelChatComponents.BroadcastService.postMessage({
118
- eventName: _TelemetryConstants.BroadcastEvent.EndChat
116
+ dispatch({
117
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
118
+ payload: 0
119
119
  });
120
120
 
121
121
  if (postMessageToOtherTab) {
@@ -63,11 +63,15 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
63
63
 
64
64
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
65
65
 
66
+ var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
67
+
68
+ var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
69
+
66
70
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
67
71
 
68
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
73
  const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
70
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
74
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
71
75
 
72
76
  const localizedTexts = { ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
73
77
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
@@ -130,7 +134,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
130
134
  };
131
135
 
132
136
  webChatStore = (0, _botframeworkWebchat.createStore)({}, //initial state
133
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
+ _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
138
  ...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
135
139
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
136
140
  } // Initialize the remaining Web Chat props
@@ -148,7 +152,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
148
152
  groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
149
153
  typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
150
154
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
151
- ...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
155
+ cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
156
+ ...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
152
157
  };
153
158
  return webChatProps;
154
159
  };
@@ -122,6 +122,37 @@ const LiveChatWidgetStateful = props => {
122
122
  _TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
123
123
  const widgetElementId = ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.id) || "oc-lcw";
124
124
  const currentMessageCountRef = (0, _react2.useRef)(0);
125
+ let widgetStateEventName = "";
126
+
127
+ const initiateEndChatOnBrowserUnload = () => {
128
+ var _DataStoreManager$cli;
129
+
130
+ const persistedState = getStateFromCache(); // End chat if the chat is still active and browser closed
131
+
132
+ if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
133
+ //Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
134
+ (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
135
+ } // Clean local storage
136
+
137
+
138
+ (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
139
+
140
+ _omnichannelChatComponents.BroadcastService.postMessage({
141
+ eventName: _TelemetryConstants.BroadcastEvent.ChatEnded
142
+ });
143
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
144
+
145
+
146
+ const getStateFromCache = () => {
147
+ var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
148
+
149
+ // Getting updated state from cache
150
+ const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
151
+ const widgetStateFromCache = (_DataStoreManager$cli2 = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.getData(widgetStateEventName, "localStorage");
152
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
153
+ return persistedState;
154
+ };
155
+
125
156
  (0, _react2.useEffect)(() => {
126
157
  var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _state$domainStates;
127
158
 
@@ -168,11 +199,16 @@ const LiveChatWidgetStateful = props => {
168
199
  };
169
200
  (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
170
201
  }
171
- }, []);
202
+ }, []); // useEffect for when skip chat button rendering
203
+
172
204
  (0, _react2.useEffect)(() => {
173
205
  if (state.appStates.skipChatButtonRendering) {
174
206
  var _props$reconnectChatP3;
175
207
 
208
+ _omnichannelChatComponents.BroadcastService.postMessage({
209
+ eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
210
+ });
211
+
176
212
  if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
177
213
  var _props$reconnectChatP4, _props$reconnectChatP5;
178
214
 
@@ -204,9 +240,10 @@ const LiveChatWidgetStateful = props => {
204
240
  });
205
241
  }
206
242
  }
207
- }, [state.appStates.skipChatButtonRendering]);
243
+ }, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
244
+
208
245
  (0, _react2.useEffect)(() => {
209
- var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
246
+ var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
210
247
 
211
248
  // Add the custom context on receiving the SetCustomContext event
212
249
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
@@ -221,7 +258,7 @@ const LiveChatWidgetStateful = props => {
221
258
  });
222
259
  });
223
260
 
224
- _omnichannelChatComponents.BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
261
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartProactiveChat).subscribe(msg => {
225
262
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
226
263
  Event: _TelemetryConstants.TelemetryEvent.StartProactiveChatEventReceived,
227
264
  Description: "Start proactive chat event received."
@@ -237,32 +274,52 @@ const LiveChatWidgetStateful = props => {
237
274
  Description: "Start proactive chat method called, when chat was already triggered."
238
275
  });
239
276
  }
240
- }); // start chat from SDK Event
277
+ }); // Start chat from SDK Event
241
278
 
242
279
 
243
- _omnichannelChatComponents.BroadcastService.getMessageByEventName("StartChat").subscribe(() => {
280
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
244
281
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
245
282
  Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
246
283
  Description: "Start chat event received."
247
284
  });
248
285
 
249
- if (state.appStates.isMinimized) {
286
+ const persistedState = getStateFromCache();
287
+
288
+ if (persistedState && (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat)) {
289
+ // Embedded mode
290
+ _omnichannelChatComponents.BroadcastService.postMessage({
291
+ eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
292
+ });
293
+
294
+ (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
295
+ } else if (!persistedState) {
296
+ // Popout chat
297
+ _omnichannelChatComponents.BroadcastService.postMessage({
298
+ eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
299
+ });
300
+
301
+ (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
302
+ } else {
303
+ var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
304
+
305
+ // Minimize to Maximize
250
306
  dispatch({
251
307
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
252
308
  payload: false
253
309
  });
254
- } else {
255
- (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
256
- }
257
- }); // end chat from SDK Event
258
310
 
311
+ _omnichannelChatComponents.BroadcastService.postMessage({
312
+ eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
313
+ payload: {
314
+ height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
315
+ width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
316
+ }
317
+ });
318
+ }
319
+ }); // End chat
259
320
 
260
- _omnichannelChatComponents.BroadcastService.getMessageByEventName("EndChat").subscribe(async () => {
261
- _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
262
- Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
263
- Description: "End chat event received."
264
- });
265
321
 
322
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
266
323
  if (canEndChat.current) {
267
324
  (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
268
325
  } else {
@@ -270,25 +327,58 @@ const LiveChatWidgetStateful = props => {
270
327
  const skipCloseChat = false;
271
328
  (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
272
329
  }
330
+
331
+ _omnichannelChatComponents.BroadcastService.postMessage({
332
+ eventName: _TelemetryConstants.BroadcastEvent.CloseChat
333
+ });
334
+ });
335
+
336
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
337
+ initiateEndChatOnBrowserUnload();
338
+ }); // reset proactive chat params
339
+
340
+
341
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
342
+ dispatch({
343
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
344
+ payload: {
345
+ proactiveChatBodyTitle: "",
346
+ proactiveChatEnablePrechat: false,
347
+ proactiveChatInNewWindow: false
348
+ }
349
+ });
273
350
  }); // Listen to end chat event from other tabs
274
351
 
275
352
 
276
- const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
353
+ const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
277
354
 
278
355
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
279
356
  (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
280
- });
357
+ }); // Close popout window
358
+
281
359
 
282
360
  window.addEventListener("beforeunload", () => {
361
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
362
+ Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
363
+ Description: "Closed window."
364
+ });
365
+
283
366
  (0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
284
367
  });
285
368
 
286
369
  if (state.appStates.conversationEndedByAgent) {
287
370
  (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
288
- }
371
+ } //Listen to WidgetSize
372
+
373
+
374
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
375
+ dispatch({
376
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE,
377
+ payload: msg === null || msg === void 0 ? void 0 : msg.payload
378
+ });
379
+ });
289
380
  }, []);
290
381
  (0, _react2.useEffect)(() => {
291
- canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed;
292
382
  canEndChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Active;
293
383
 
294
384
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
@@ -309,7 +399,10 @@ const LiveChatWidgetStateful = props => {
309
399
  });
310
400
  });
311
401
  }
312
- }, [state.appStates.conversationState]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
402
+ }, [state.appStates.conversationState]);
403
+ (0, _react2.useEffect)(() => {
404
+ canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed && !state.appStates.proactiveChatStates.proactiveChatInNewWindow;
405
+ }, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
313
406
 
314
407
  (0, _react2.useEffect)(() => {
315
408
  currentMessageCountRef.current = -1;
@@ -343,7 +436,20 @@ const LiveChatWidgetStateful = props => {
343
436
  setWebChatStyles({ ...webChatStyles,
344
437
  ...((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.webChatStyles)
345
438
  });
346
- }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
439
+ }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
440
+
441
+ (0, _react2.useEffect)(() => {
442
+ var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
443
+
444
+ widgetStateEventName = (0, _utils.getWidgetCacheId)(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, 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);
445
+ const chatWidgetStateChangeEvent = {
446
+ eventName: widgetStateEventName,
447
+ payload: { ...state
448
+ }
449
+ };
450
+
451
+ _omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
452
+ }, [state]);
347
453
  const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
348
454
 
349
455
  const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -359,20 +465,7 @@ const LiveChatWidgetStateful = props => {
359
465
 
360
466
  const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
361
467
 
362
- const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props); // publish chat widget state
363
-
364
- (0, _react2.useEffect)(() => {
365
- var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
366
-
367
- const widgetStateEventName = (0, _utils.getWidgetCacheId)(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, 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);
368
- const chatWidgetStateChangeEvent = {
369
- eventName: widgetStateEventName,
370
- payload: { ...state
371
- }
372
- };
373
-
374
- _omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
375
- }, [state]);
468
+ const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
376
469
  return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
377
470
  styleOptions: webChatStyles,
378
471
  directLine: ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
@@ -46,6 +46,14 @@ const ProactiveChatPaneStateful = props => {
46
46
  const handleProactiveChatInviteTimeout = () => {
47
47
  if (!timeoutRemoved) {
48
48
  setTimeoutRemoved(true);
49
+ dispatch({
50
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
51
+ payload: {
52
+ proactiveChatBodyTitle: "",
53
+ proactiveChatEnablePrechat: false,
54
+ proactiveChatInNewWindow: false
55
+ }
56
+ });
49
57
  dispatch({
50
58
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
51
59
  payload: _ConversationState.ConversationState.Closed
@@ -111,6 +119,14 @@ const ProactiveChatPaneStateful = props => {
111
119
  Description: "Proactive chat closed."
112
120
  });
113
121
 
122
+ dispatch({
123
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
124
+ payload: {
125
+ proactiveChatBodyTitle: "",
126
+ proactiveChatEnablePrechat: false,
127
+ proactiveChatInNewWindow: false
128
+ }
129
+ });
114
130
  dispatch({
115
131
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
116
132
  payload: _ConversationState.ConversationState.Closed