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

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 (87) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +14 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +18 -2
  4. package/lib/cjs/common/utils.js +49 -3
  5. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
  6. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  7. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
  8. package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
  9. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  10. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -2
  11. package/lib/cjs/components/livechatwidget/common/endChat.js +52 -20
  12. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -3
  13. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +15 -15
  14. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  15. package/lib/cjs/components/livechatwidget/common/startChat.js +124 -84
  16. package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +1 -0
  17. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +172 -89
  18. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
  19. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  20. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  21. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  22. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  23. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  24. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  25. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  26. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  27. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  28. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
  29. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
  30. package/lib/cjs/contexts/createReducer.js +8 -0
  31. package/lib/cjs/controller/componentController.js +3 -3
  32. package/lib/esm/common/Constants.js +14 -0
  33. package/lib/esm/common/telemetry/TelemetryConstants.js +18 -2
  34. package/lib/esm/common/utils.js +37 -1
  35. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
  36. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  37. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
  38. package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
  39. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  40. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -2
  41. package/lib/esm/components/livechatwidget/common/endChat.js +53 -20
  42. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +15 -5
  43. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -16
  44. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  45. package/lib/esm/components/livechatwidget/common/startChat.js +125 -86
  46. package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
  47. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +168 -91
  48. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
  49. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  50. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  51. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  52. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  53. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  54. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  55. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  56. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  57. package/lib/esm/contexts/common/ConversationState.js +3 -2
  58. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
  59. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
  60. package/lib/esm/contexts/createReducer.js +8 -0
  61. package/lib/esm/controller/componentController.js +3 -3
  62. package/lib/types/common/Constants.d.ts +7 -0
  63. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  64. package/lib/types/common/telemetry/TelemetryConstants.d.ts +18 -3
  65. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
  66. package/lib/types/common/utils.d.ts +3 -0
  67. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
  68. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  69. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
  70. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  71. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  72. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
  73. package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +4 -0
  74. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  75. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
  76. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  77. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  78. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  79. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
  80. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
  81. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  82. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  83. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  84. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  85. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
  86. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  87. 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");
@@ -155,6 +167,8 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
155
167
 
156
168
  _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
157
169
 
170
+ _defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
171
+
158
172
  const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
159
173
  exports.Regex = Regex;
160
174
 
@@ -37,19 +37,29 @@ 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";
62
+ BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
53
63
  })(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
54
64
 
55
65
  let TelemetryEvent;
@@ -102,8 +112,9 @@ exports.TelemetryEvent = TelemetryEvent;
102
112
  TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
103
113
  TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
104
114
  TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
105
- TelemetryEvent["EndChatSDKCall"] = "EndChatCall";
115
+ TelemetryEvent["EndChatSDKCall"] = "EndChatSDKCall";
106
116
  TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
117
+ TelemetryEvent["WindowClosed"] = "WindowClosed";
107
118
  TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
108
119
  TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
109
120
  TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
@@ -128,6 +139,10 @@ exports.TelemetryEvent = TelemetryEvent;
128
139
  TelemetryEvent["EmailTranscriptButtonClicked"] = "EmailTranscriptButtonClicked";
129
140
  TelemetryEvent["EmailTranscriptCancelButtonClicked"] = "EmailTranscriptCancelButtonClicked";
130
141
  TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
142
+ TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
143
+ TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
144
+ TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
145
+ TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
131
146
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
132
147
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
133
148
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -199,6 +214,7 @@ class TelemetryConstants {
199
214
  case TelemetryEvent.MessageSent:
200
215
  case TelemetryEvent.MessageReceived:
201
216
  case TelemetryEvent.CustomContextReceived:
217
+ case TelemetryEvent.BrowserUnloadEventStarted:
202
218
  return ScenarioType.ACTIONS;
203
219
 
204
220
  case TelemetryEvent.StartChatSDKCall:
@@ -3,10 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = void 0;
6
+ exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
7
7
 
8
8
  var _Constants = require("./Constants");
9
9
 
10
+ var _DataStoreManager = require("./contextDataStore/DataStoreManager");
11
+
10
12
  var _KeyCodes = require("./KeyCodes");
11
13
 
12
14
  var _TelemetryConstants = require("./telemetry/TelemetryConstants");
@@ -359,7 +361,51 @@ const getWidgetCacheId = (orgId, widgetId) => {
359
361
  exports.getWidgetCacheId = getWidgetCacheId;
360
362
 
361
363
  const getWidgetEndChatEventName = (orgId, widgetId) => {
362
- return `${_TelemetryConstants.BroadcastEvent.EndChat}_${orgId}_${widgetId}`;
364
+ return `${_TelemetryConstants.BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
365
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
366
+
367
+
368
+ exports.getWidgetEndChatEventName = getWidgetEndChatEventName;
369
+
370
+ const getStateFromCache = (orgId, widgetId) => {
371
+ // Getting updated state from cache
372
+ try {
373
+ if (_DataStoreManager.DataStoreManager.clientDataStore) {
374
+ var _DataStoreManager$cli;
375
+
376
+ const widgetStateEventName = getWidgetCacheId(orgId, widgetId);
377
+ const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
378
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
379
+ return persistedState;
380
+ } else {
381
+ return null;
382
+ }
383
+ } catch (error) {
384
+ console.log(error);
385
+ return null;
386
+ }
387
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
388
+
389
+
390
+ exports.getStateFromCache = getStateFromCache;
391
+
392
+ const isUndefinedOrEmpty = object => {
393
+ if (object) {
394
+ if (Object.keys(object).length === 0) {
395
+ return true;
396
+ }
397
+
398
+ return false;
399
+ } else {
400
+ return true;
401
+ }
402
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
403
+
404
+
405
+ exports.isUndefinedOrEmpty = isUndefinedOrEmpty;
406
+
407
+ const addDelayInMs = ms => {
408
+ return new Promise(resolve => setTimeout(resolve, ms));
363
409
  };
364
410
 
365
- exports.getWidgetEndChatEventName = getWidgetEndChatEventName;
411
+ exports.addDelayInMs = addDelayInMs;
@@ -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 = {
@@ -74,6 +82,10 @@ const ChatButtonStateful = props => {
74
82
  titleText: "We're Offline",
75
83
  subtitleText: "No agents available",
76
84
  onClick: async () => {
85
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
86
+ Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
87
+ });
88
+
77
89
  if (state.appStates.isMinimized) {
78
90
  dispatch({
79
91
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
@@ -86,6 +98,7 @@ const ChatButtonStateful = props => {
86
98
  });
87
99
  }
88
100
  },
101
+ 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
102
  ...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
90
103
  };
91
104
  (0, _react.useEffect)(() => {
@@ -107,6 +120,9 @@ const ChatButtonStateful = props => {
107
120
  });
108
121
  }
109
122
  }, []);
123
+ (0, _react.useEffect)(() => {
124
+ proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
125
+ }, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
110
126
  return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
111
127
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
112
128
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -41,7 +41,6 @@ const ConfirmationPaneStateful = props => {
41
41
  const {
42
42
  prepareEndChat
43
43
  } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
44
 
46
45
  const [adapter] = (0, _useChatAdapterStore.default)();
47
46
  const 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) {
@@ -81,8 +81,8 @@ const HeaderStateful = props => {
81
81
  });
82
82
  },
83
83
  ...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
84
- hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
85
- hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
84
+ hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
85
+ hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
86
86
  hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
87
87
  };
88
88
  const outOfOfficeControlProps = {
@@ -26,26 +26,40 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
26
26
  breaks: !disableNewLineMarkdownSupport
27
27
  }); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
28
28
  // markdown.use(MarkdownSlack);
29
- // Markdown override for open link in new tab
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, quotes
29
+ } else {
30
+ markdown = new _markdownIt.default(_Constants.Constants.Zero, {
31
+ html: true,
32
+ linkify: true,
33
+ breaks: !disableNewLineMarkdownSupport
34
+ });
35
+ markdown.enable(["entity", // Rule to process html entity - &#123;, &#xAF;, &quot;
36
+ "linkify", // Rule to replace link-like texts with link nodes
37
+ "html_block", // Rule to process html blocks and paragraphs
38
+ "html_inline", // Rule to process html tags
39
+ "newline" // Rule to proceess '\n'
40
+ ]);
41
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
42
 
32
- markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
33
- const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
34
43
 
35
- const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
44
+ markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
45
+ const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
36
46
 
37
- if (~targetAttrIndex) {
38
- tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
39
- } else {
40
- tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
41
- }
47
+ const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
48
+
49
+ if (~targetAttrIndex) {
50
+ tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
51
+ } else {
52
+ tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
53
+ }
54
+
55
+ const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
42
56
 
43
- const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
57
+ if (~relAttrIndex) {
58
+ tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
59
+ } else {
60
+ tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
44
61
 
45
- if (~relAttrIndex) {
46
- tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
47
- } else {
48
- tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
62
+ if (!disableMarkdownMessageFormatting) {
49
63
  tokens[idx].attrPush([_Constants.Constants.Title, _defaultMarkdownLocalizedTexts.defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
50
64
 
51
65
  const iconTokens = markdown.parseInline(`![${_defaultMarkdownLocalizedTexts.defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT}](${TRANSPARENT_GIF})`, env)[0].children;
@@ -55,21 +69,8 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
55
69
  tokens.splice(idx + 2, 0, ...iconTokens);
56
70
  }
57
71
  }
58
- });
59
- } else {
60
- markdown = new _markdownIt.default(_Constants.Constants.Zero, {
61
- html: true,
62
- linkify: true,
63
- breaks: !disableNewLineMarkdownSupport
64
- });
65
- markdown.enable(["entity", // Rule to process html entity - &#123;, &#xAF;, &quot;
66
- "linkify", // Rule to replace link-like texts with link nodes
67
- "html_block", // Rule to process html blocks and paragraphs
68
- "html_inline", // Rule to process html tags
69
- "newline" // Rule to proceess '\n'
70
- ]);
71
- }
72
-
72
+ }
73
+ });
73
74
  return markdown;
74
75
  };
75
76
 
@@ -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: {
@@ -1432,7 +1434,6 @@ const dummyDefaultProps = {
1432
1434
  startNewChatButtonClassName: undefined
1433
1435
  }
1434
1436
  },
1435
- authClientFunction: undefined,
1436
1437
  isReconnectEnabled: undefined,
1437
1438
  reconnectId: undefined,
1438
1439
  redirectInSameWindow: undefined
@@ -1697,8 +1698,16 @@ const dummyDefaultProps = {
1697
1698
  MIDDLEWARE_MESSAGE_RETRY: "Retry",
1698
1699
  PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
1699
1700
  MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
1701
+ },
1702
+ botMagicCode: {
1703
+ disabled: false,
1704
+ fwdUrl: ""
1700
1705
  }
1701
1706
  },
1707
+ authProps: {
1708
+ authClientFunction: undefined,
1709
+ setAuthTokenProviderToChatSdk: undefined
1710
+ },
1702
1711
  telemetryConfig: undefined
1703
1712
  };
1704
1713
  exports.dummyDefaultProps = dummyDefaultProps;
@@ -27,18 +27,35 @@ var _utils = require("../../../common/utils");
27
27
 
28
28
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
29
  const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
30
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
30
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
31
31
 
32
32
  const isPostChatEnabled = (_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.msdyn_postconversationsurveyenable;
33
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
34
- const conversationDetails = await chatSDK.getConversationDetails();
33
+ const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode; // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
34
 
36
- if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
35
+ let conversationDetails = undefined;
36
+
37
+ try {
38
+ conversationDetails = await chatSDK.getConversationDetails();
39
+ } catch (erorr) {
40
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
41
+ Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsException,
42
+ ExceptionDetails: {
43
+ exception: `Failed to get conversation details: ${erorr}`
44
+ }
45
+ });
46
+ }
47
+
48
+ if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
37
49
  const skipEndChatSDK = false;
38
50
  const skipCloseChat = true;
39
51
  await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
40
52
 
41
53
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
54
+ dispatch({
55
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
56
+ payload: _ConversationState.ConversationState.PostchatLoading
57
+ });
58
+ await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
42
59
  const loadPostChatEvent = {
43
60
  eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
44
61
  };
@@ -50,9 +67,11 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
50
67
  payload: _ConversationState.ConversationState.InActive
51
68
  });
52
69
  }
53
- } else {
54
- await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
70
+
71
+ return;
55
72
  }
73
+
74
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
56
75
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
76
 
58
77
 
@@ -65,16 +84,7 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
65
84
  Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCall
66
85
  });
67
86
 
68
- await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat()); // Need to clear these states immediately when chat ended from OC.
69
-
70
- dispatch({
71
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
72
- payload: undefined
73
- });
74
- dispatch({
75
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
76
- payload: undefined
77
- });
87
+ await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
78
88
  } catch (ex) {
79
89
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
80
90
  Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCallFailed,
@@ -85,7 +95,21 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
85
95
 
86
96
  postMessageToOtherTab = false;
87
97
  }
88
- }
98
+ } // Need to clear these states immediately when chat ended from OC.
99
+
100
+
101
+ dispatch({
102
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
103
+ payload: undefined
104
+ });
105
+ dispatch({
106
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
107
+ payload: undefined
108
+ });
109
+ dispatch({
110
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
111
+ payload: undefined
112
+ });
89
113
 
90
114
  if (!skipCloseChat) {
91
115
  try {
@@ -113,9 +137,17 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
113
137
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
114
138
  payload: null
115
139
  });
116
-
117
- _omnichannelChatComponents.BroadcastService.postMessage({
118
- eventName: _TelemetryConstants.BroadcastEvent.EndChat
140
+ dispatch({
141
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
142
+ payload: 0
143
+ });
144
+ dispatch({
145
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
146
+ payload: {
147
+ proactiveChatBodyTitle: "",
148
+ proactiveChatEnablePrechat: false,
149
+ proactiveChatInNewWindow: false
150
+ }
119
151
  });
120
152
 
121
153
  if (postMessageToOtherTab) {
@@ -63,11 +63,17 @@ 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
+
70
+ var _Constants = require("../../../common/Constants");
71
+
66
72
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
67
73
 
68
74
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
75
  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;
76
+ 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
77
 
72
78
  const localizedTexts = { ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
73
79
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
@@ -101,6 +107,12 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
101
107
 
102
108
  if (isPostChatEnabled === "true") {
103
109
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
110
+ _WebChatStoreLoader.WebChatStoreLoader.store = null;
111
+ dispatch({
112
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
113
+ payload: _ConversationState.ConversationState.PostchatLoading
114
+ });
115
+ await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
104
116
  const loadPostChatEvent = {
105
117
  eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
106
118
  };
@@ -130,7 +142,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
130
142
  };
131
143
 
132
144
  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
145
+ _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
146
  ...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
135
147
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
136
148
  } // Initialize the remaining Web Chat props
@@ -148,7 +160,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
148
160
  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
161
  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
162
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
151
- ...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
163
+ cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
164
+ ...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
152
165
  };
153
166
  return webChatProps;
154
167
  };