@microsoft/omnichannel-chat-widget 0.1.0-main.ae3aa42 → 0.1.0-main.b511ad6

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 (123) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +16 -2
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +26 -3
  4. package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
  5. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +8 -9
  6. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
  7. package/lib/cjs/common/utils.js +63 -2
  8. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  9. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
  10. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  11. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
  12. package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
  13. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
  14. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  16. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
  17. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
  18. package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
  19. package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
  20. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  21. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -15
  22. package/lib/cjs/components/livechatwidget/common/endChat.js +63 -16
  23. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +20 -3
  24. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +23 -15
  25. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  26. package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
  27. package/lib/cjs/components/livechatwidget/common/startChat.js +177 -67
  28. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +206 -85
  29. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
  30. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  31. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  32. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  33. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
  40. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  41. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +24 -21
  42. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
  43. package/lib/cjs/contexts/createReducer.js +16 -0
  44. package/lib/cjs/controller/componentController.js +3 -3
  45. package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
  46. package/lib/esm/common/Constants.js +16 -2
  47. package/lib/esm/common/telemetry/TelemetryConstants.js +26 -3
  48. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  49. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +8 -6
  50. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
  51. package/lib/esm/common/utils.js +44 -0
  52. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  53. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
  54. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  55. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
  56. package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
  57. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
  58. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
  59. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  60. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
  61. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
  62. package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
  63. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
  64. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  65. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -15
  66. package/lib/esm/components/livechatwidget/common/endChat.js +61 -17
  67. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +19 -5
  68. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +23 -15
  69. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  70. package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
  71. package/lib/esm/components/livechatwidget/common/startChat.js +172 -68
  72. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +197 -87
  73. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
  74. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  75. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  76. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  77. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  81. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  82. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  83. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
  84. package/lib/esm/contexts/common/ConversationState.js +3 -2
  85. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +24 -21
  86. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
  87. package/lib/esm/contexts/createReducer.js +16 -0
  88. package/lib/esm/controller/componentController.js +3 -3
  89. package/lib/esm/plugins/newMessageEventHandler.js +10 -12
  90. package/lib/types/common/Constants.d.ts +8 -1
  91. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  92. package/lib/types/common/telemetry/TelemetryConstants.d.ts +25 -5
  93. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -1
  94. package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
  95. package/lib/types/common/utils.d.ts +6 -1
  96. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
  97. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  98. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  99. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  100. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  101. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  102. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  103. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  104. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
  105. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  106. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  107. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  108. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
  109. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
  110. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
  111. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  112. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  113. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  114. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  115. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
  116. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
  117. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  118. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  119. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  120. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  121. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
  122. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +24 -21
  123. package/package.json +2 -2
@@ -13,8 +13,6 @@ var _Constants = require("../common/Constants");
13
13
 
14
14
  var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
15
15
 
16
- var _TelemetryManager = require("../common/telemetry/TelemetryManager");
17
-
18
16
  const createOnNewAdapterActivityHandler = (chatId, userId) => {
19
17
  const onNewAdapterActivityHandler = activity => {
20
18
  var _activity$channelData, _activity$channelData2, _activity$channelData3;
@@ -29,18 +27,16 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
29
27
 
30
28
  const raiseMessageEvent = activity => {
31
29
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
32
- var _TelemetryManager$Int, _activity$from;
30
+ var _text, _text2, _activity$channelData4, _activity$from;
33
31
 
34
32
  const payload = {
33
+ // To identify hidden contents vs empty content
35
34
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- text: activity === null || activity === void 0 ? void 0 : activity.text,
37
- id: activity === null || activity === void 0 ? void 0 : activity.id,
35
+ text: (activity === null || activity === void 0 ? void 0 : (_text = activity.text) === null || _text === void 0 ? void 0 : _text.length) >= 1 ? `*contents hidden (${activity === null || activity === void 0 ? void 0 : (_text2 = activity.text) === null || _text2 === void 0 ? void 0 : _text2.length} chars)*` : "",
38
36
  type: activity === null || activity === void 0 ? void 0 : activity.type,
39
37
  timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
40
- chatId: chatId,
41
38
  userId: userId,
42
- conversationId: ((_TelemetryManager$Int = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.conversationId) ?? "",
43
- channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
39
+ tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags,
44
40
  messageType: ""
45
41
  };
46
42
 
@@ -59,18 +55,18 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
59
55
  Description: "New message sent"
60
56
  });
61
57
  } else {
62
- var _activity$channelData4, _activity$channelData5;
58
+ var _activity$channelData5, _activity$channelData6;
63
59
 
64
- if (activity !== null && activity !== void 0 && (_activity$channelData4 = activity.channelData) !== null && _activity$channelData4 !== void 0 && (_activity$channelData5 = _activity$channelData4.tags) !== null && _activity$channelData5 !== void 0 && _activity$channelData5.includes(_Constants.Constants.systemMessageTag)) {
60
+ if (activity !== null && activity !== void 0 && (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.systemMessageTag)) {
65
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
62
  payload.messageType = _Constants.Constants.systemMessageTag;
67
63
  } else {
68
- var _activity$channelData6, _activity$channelData7, _activity$channelData8;
64
+ var _activity$channelData7, _activity$channelData8, _activity$channelData9;
69
65
 
70
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
67
  const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
68
 
73
- const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData6 = activity.channelData) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : (_activity$channelData8 = _activity$channelData7.tags) === null || _activity$channelData8 === void 0 ? void 0 : _activity$channelData8.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && _activity$channelData7.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.tags) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
70
 
75
71
  const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
76
72
 
@@ -90,7 +86,8 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
90
86
 
91
87
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
92
88
  Event: _TelemetryConstants.TelemetryEvent.MessageReceived,
93
- Description: "New message received"
89
+ Description: "New message received",
90
+ Data: payload
94
91
  });
95
92
  }
96
93
  }
@@ -4,6 +4,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
4
4
 
5
5
  export class Constants {}
6
6
 
7
+ _defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
8
+
9
+ _defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
10
+
7
11
  _defineProperty(Constants, "systemMessageTag", "system");
8
12
 
9
13
  _defineProperty(Constants, "userMessageTag", "user");
@@ -36,8 +40,6 @@ _defineProperty(Constants, "false", "false");
36
40
 
37
41
  _defineProperty(Constants, "maximumUnreadMessageCount", 99);
38
42
 
39
- _defineProperty(Constants, "widgetStateDataKey", "LcwChatWidgetState");
40
-
41
43
  _defineProperty(Constants, "channelIdKey", "ChannelId-");
42
44
 
43
45
  _defineProperty(Constants, "ChannelId", "lcw");
@@ -72,6 +74,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
72
74
 
73
75
  _defineProperty(Constants, "message", "message");
74
76
 
77
+ _defineProperty(Constants, "hiddenTag", "Hidden");
78
+
79
+ _defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
80
+
81
+ _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
82
+
83
+ _defineProperty(Constants, "publicMessageTag", "public");
84
+
75
85
  _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"]);
76
86
 
77
87
  _defineProperty(Constants, "maxUploadFileSize", "500000");
@@ -146,6 +156,10 @@ _defineProperty(Constants, "internetConnectionTestUrl", "https://ocsdk-prod.azur
146
156
 
147
157
  _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
148
158
 
159
+ _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
160
+
161
+ _defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
162
+
149
163
  export 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);
150
164
  export class HtmlIdNames {}
151
165
 
@@ -26,18 +26,29 @@ export let BroadcastEvent; // Events being logged
26
26
 
27
27
  (function (BroadcastEvent) {
28
28
  BroadcastEvent["LoadPostChatSurvey"] = "LoadPostChatSurvey";
29
- BroadcastEvent["EndChat"] = "ChatEnded";
29
+ BroadcastEvent["ChatEnded"] = "ChatEnded";
30
30
  BroadcastEvent["NewMessageNotification"] = "NewMessageNotification";
31
31
  BroadcastEvent["UnreadMessageCount"] = "UnreadMessageCount";
32
- BroadcastEvent["ChatWidgetStateChanged"] = "ChatWidgetStateChanged";
32
+ BroadcastEvent["StartProactiveChat"] = "StartProactiveChat";
33
33
  BroadcastEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
34
34
  BroadcastEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
35
+ BroadcastEvent["ProactiveChatIsInPopoutMode"] = "ProactiveChatIsInPopoutMode";
36
+ BroadcastEvent["ResetProactiveChatParams"] = "ResetProactiveChatParams";
35
37
  BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
36
38
  BroadcastEvent["NewMessageSent"] = "NewMessageSent";
37
39
  BroadcastEvent["NewMessageReceived"] = "NewMessageReceived";
38
40
  BroadcastEvent["RedirectPageRequest"] = "RedirectPageRequest";
41
+ BroadcastEvent["StartChat"] = "StartChat";
39
42
  BroadcastEvent["StartChatSkippingChatButtonRendering"] = "StartChatSkippingChatButtonRendering";
40
43
  BroadcastEvent["StartUnauthenticatedReconnectChat"] = "StartUnauthenticatedReconnectChat";
44
+ BroadcastEvent["InitiateEndChat"] = "InitiateEndChat";
45
+ BroadcastEvent["SetCustomContext"] = "SetCustomContext";
46
+ BroadcastEvent["ChatRetrievedFromCache"] = "ChatRetrievedFromCache";
47
+ BroadcastEvent["MaximizeChat"] = "MaximizeChat";
48
+ BroadcastEvent["ChatInitiated"] = "ChatInitiated";
49
+ BroadcastEvent["CloseChat"] = "CloseChat";
50
+ BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
51
+ BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
41
52
  })(BroadcastEvent || (BroadcastEvent = {}));
42
53
 
43
54
  export let TelemetryEvent;
@@ -89,8 +100,9 @@ export let TelemetryEvent;
89
100
  TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
90
101
  TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
91
102
  TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
92
- TelemetryEvent["EndChatSDKCall"] = "EndChatCall";
103
+ TelemetryEvent["EndChatSDKCall"] = "EndChatSDKCall";
93
104
  TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
105
+ TelemetryEvent["WindowClosed"] = "WindowClosed";
94
106
  TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
95
107
  TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
96
108
  TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
@@ -115,6 +127,12 @@ export let TelemetryEvent;
115
127
  TelemetryEvent["EmailTranscriptButtonClicked"] = "EmailTranscriptButtonClicked";
116
128
  TelemetryEvent["EmailTranscriptCancelButtonClicked"] = "EmailTranscriptCancelButtonClicked";
117
129
  TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
130
+ TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
131
+ TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
132
+ TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
133
+ TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
134
+ TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
135
+ TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
118
136
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
119
137
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
120
138
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -140,6 +158,7 @@ export let TelemetryEvent;
140
158
  TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
141
159
  TelemetryEvent["MessageSent"] = "MessageSent";
142
160
  TelemetryEvent["MessageReceived"] = "MessageReceived";
161
+ TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
143
162
  })(TelemetryEvent || (TelemetryEvent = {}));
144
163
 
145
164
  export class TelemetryConstants {
@@ -182,6 +201,10 @@ export class TelemetryConstants {
182
201
  case TelemetryEvent.PreChatSurveyStartChatMethodFailed:
183
202
  case TelemetryEvent.HeaderCloseButtonClicked:
184
203
  case TelemetryEvent.HeaderMinimizeButtonClicked:
204
+ case TelemetryEvent.MessageSent:
205
+ case TelemetryEvent.MessageReceived:
206
+ case TelemetryEvent.CustomContextReceived:
207
+ case TelemetryEvent.BrowserUnloadEventStarted:
185
208
  return ScenarioType.ACTIONS;
186
209
 
187
210
  case TelemetryEvent.StartChatSDKCall:
@@ -5,6 +5,7 @@ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
5
5
  import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
6
6
  import { consoleLogger } from "./loggers/consoleLogger";
7
7
  import { defaultAriaConfig } from "./defaultConfigs/defaultAriaConfig";
8
+ import { TelemetryHelper } from "./TelemetryHelper";
8
9
  export class TelemetryTimers {}
9
10
 
10
11
  _defineProperty(TelemetryTimers, "LcwLoadToChatButtonTimer", void 0);
@@ -72,7 +73,11 @@ export const RegisterLoggers = () => {
72
73
 
73
74
  const logLevel = telemetryEvent.logLevel ?? LogLevel.INFO;
74
75
  const scenarioType = ((_payload = telemetryEvent.payload) === null || _payload === void 0 ? void 0 : _payload.scenarioType) ?? ScenarioType.UNDEFINED;
75
- logger.log(logLevel, parseInput(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload, scenarioType));
76
+ const telemetryInput = parseInput(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload, scenarioType);
77
+ telemetryInput.telemetryInfo = {
78
+ telemetryInfo: TelemetryHelper.buildTelemetryEvent(logLevel, telemetryInput)
79
+ };
80
+ logger.log(logLevel, telemetryInput);
76
81
  });
77
82
  };
78
83
 
@@ -3,7 +3,6 @@ import AWTEventProperties from "@microsoft/omnichannel-chat-sdk/lib/external/ari
3
3
  import AWTLogManager from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AWTLogManager";
4
4
  import { AWTPiiKind } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
5
5
  import { Constants, AriaTelemetryConstants, EnvironmentVersion } from "../../Constants";
6
- import { TelemetryHelper } from "../TelemetryHelper";
7
6
  import { TelemetryManager } from "../TelemetryManager";
8
7
  export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
9
8
  let _logger;
@@ -51,16 +50,19 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
51
50
  log: (logLevel, telemetryInput) => {
52
51
  try {
53
52
  let property;
53
+ const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo;
54
54
  const eventProperties = new AWTEventProperties();
55
- const event = TelemetryHelper.buildTelemetryEvent(logLevel, telemetryInput);
56
55
  eventProperties.setName(telemetryInput.scenarioType);
57
56
 
58
- for (const key of Object.keys(event)) {
59
- property = typeof event[key] === "object" ? JSON.stringify(event[key]) : event[key];
60
- eventProperties.setProperty(key, property);
57
+ if (telemetryInfo) {
58
+ for (const key of Object.keys(telemetryInfo)) {
59
+ property = typeof telemetryInfo[key] === "object" ? JSON.stringify(telemetryInfo[key]) : telemetryInfo[key];
60
+ eventProperties.setProperty(key, property);
61
+ }
62
+
63
+ eventProperties.setPropertyWithPii(ariaTelemetryApplicationName, Constants.LiveChatWidget, AWTPiiKind.GenericData);
61
64
  }
62
65
 
63
- eventProperties.setPropertyWithPii(ariaTelemetryApplicationName, Constants.LiveChatWidget, AWTPiiKind.GenericData);
64
66
  logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
65
67
  } catch (error) {
66
68
  console.error("Error in logging telemetry to Aria logger:" + error);
@@ -4,27 +4,28 @@ export const consoleLogger = () => {
4
4
  const consoleLogger = {
5
5
  log: (logLevel, telemetryInput) => {
6
6
  const payload = telemetryInput !== null && telemetryInput !== void 0 && telemetryInput.payload && Object.keys(telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.payload).length > 0 ? telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.payload : "";
7
+ const telemetryInfo = telemetryInput !== null && telemetryInput !== void 0 && telemetryInput.telemetryInfo && Object.keys(telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo).length > 0 ? telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo : "";
7
8
 
8
9
  try {
9
10
  switch (logLevel) {
10
11
  case LogLevel.INFO:
11
- console.info(Constants.LiveChatWidget, payload);
12
+ console.info(Constants.LiveChatWidget, payload, telemetryInfo);
12
13
  break;
13
14
 
14
15
  case LogLevel.DEBUG:
15
- console.debug(Constants.LiveChatWidget, payload);
16
+ console.debug(Constants.LiveChatWidget, payload, telemetryInfo);
16
17
  break;
17
18
 
18
19
  case LogLevel.WARN:
19
- console.warn(Constants.LiveChatWidget, payload);
20
+ console.warn(Constants.LiveChatWidget, payload, telemetryInfo);
20
21
  break;
21
22
 
22
23
  case LogLevel.ERROR:
23
- console.error(Constants.LiveChatWidget, payload);
24
+ console.error(Constants.LiveChatWidget, payload, telemetryInfo);
24
25
  break;
25
26
 
26
27
  default:
27
- console.debug(Constants.LiveChatWidget, payload);
28
+ console.debug(Constants.LiveChatWidget, payload, telemetryInfo);
28
29
  break;
29
30
  }
30
31
  } catch (ex) {
@@ -1,5 +1,7 @@
1
1
  import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
2
+ import { DataStoreManager } from "./contextDataStore/DataStoreManager";
2
3
  import { KeyCodes } from "./KeyCodes";
4
+ import { BroadcastEvent } from "./telemetry/TelemetryConstants";
3
5
 
4
6
  const getElementBySelector = selector => {
5
7
  let element;
@@ -277,6 +279,7 @@ export const createTimer = () => {
277
279
 
278
280
  };
279
281
  }; // Returns the domain of the org
282
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
280
283
 
281
284
  export const getDomain = hostValue => {
282
285
  for (let i = 0; i < AriaTelemetryConstants.lcwEUDomainNames.length; i++) {
@@ -286,4 +289,45 @@ export const getDomain = hostValue => {
286
289
  }
287
290
 
288
291
  return AriaTelemetryConstants.Public;
292
+ };
293
+ export const getWidgetCacheId = (orgId, widgetId) => {
294
+ return `${Constants.ChatWidgetStateChangedPrefix}_${orgId}_${widgetId}`;
295
+ };
296
+ export const getWidgetEndChatEventName = (orgId, widgetId) => {
297
+ return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
298
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
299
+
300
+ export const getStateFromCache = (orgId, widgetId) => {
301
+ // Getting updated state from cache
302
+ try {
303
+ if (DataStoreManager.clientDataStore) {
304
+ var _DataStoreManager$cli;
305
+
306
+ const widgetStateEventName = getWidgetCacheId(orgId, widgetId);
307
+ const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
308
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
309
+ return persistedState;
310
+ } else {
311
+ return null;
312
+ }
313
+ } catch (error) {
314
+ console.log(error);
315
+ return null;
316
+ }
317
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
318
+
319
+ export const isUndefinedOrEmpty = object => {
320
+ if (object) {
321
+ if (Object.keys(object).length === 0) {
322
+ return true;
323
+ }
324
+
325
+ return false;
326
+ } else {
327
+ return true;
328
+ }
329
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
+
331
+ export const addDelayInMs = ms => {
332
+ return new Promise(resolve => setTimeout(resolve, ms));
289
333
  };
@@ -177,6 +177,20 @@ export const CallingContainerStateful = props => {
177
177
  });
178
178
  }
179
179
  });
180
+ window.addEventListener("beforeunload", () => {
181
+ if (state.uiStates.isIncomingCall) {
182
+ voiceVideoCallingSdk === null || voiceVideoCallingSdk === void 0 ? void 0 : voiceVideoCallingSdk.rejectCall();
183
+ } else {
184
+ voiceVideoCallingSdk === null || voiceVideoCallingSdk === void 0 ? void 0 : voiceVideoCallingSdk.stopCall();
185
+ }
186
+
187
+ voiceVideoCallingSdk === null || voiceVideoCallingSdk === void 0 ? void 0 : voiceVideoCallingSdk.close();
188
+ dispatch({
189
+ type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
190
+ payload: false
191
+ });
192
+ resetCallingStates(true);
193
+ });
180
194
  }, []);
181
195
  const controlProps = {
182
196
  id: "oc-lcw-callingcontainer",
@@ -1,6 +1,6 @@
1
- import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
- import React, { useEffect, useState } from "react";
3
- import { ChatButton } from "@microsoft/omnichannel-chat-components";
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
+ import React, { useEffect, useRef, useState } from "react";
3
+ import { BroadcastService, ChatButton } from "@microsoft/omnichannel-chat-components";
4
4
  import { Constants } from "../../common/Constants";
5
5
  import { setFocusOnElement } from "../../common/utils";
6
6
  import { ConversationState } from "../../contexts/common/ConversationState";
@@ -10,7 +10,7 @@ import { TelemetryTimers } from "../../common/telemetry/TelemetryManager";
10
10
  import { defaultOutOfOfficeChatButtonStyleProps } from "./common/styleProps/defaultOutOfOfficeChatButtonStyleProps";
11
11
  import useChatContextStore from "../../hooks/useChatContextStore";
12
12
  export const ChatButtonStateful = props => {
13
- var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP;
13
+ var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
14
14
 
15
15
  const [state, dispatch] = useChatContextStore();
16
16
  const {
@@ -20,20 +20,26 @@ export const ChatButtonStateful = props => {
20
20
  } = props; //Setting OutOfOperatingHours Flag
21
21
 
22
22
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
23
+ const proactiveChatInNewWindow = useRef(state.appStates.proactiveChatStates.proactiveChatInNewWindow);
23
24
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
24
25
  const controlProps = {
25
26
  id: "oc-lcw-chat-button",
26
27
  dir: state.domainStates.globalDir,
27
28
  titleText: "Let's Chat!",
28
29
  subtitleText: "We're online.",
29
- hideNotificationBubble: !(state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) || (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true,
30
- unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > Constants.maximumUnreadMessageCount ? Constants.maximumUnreadMessageCount.toString() + "+" : state.appStates.unreadMessageCount.toString() : "0",
30
+ 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,
31
+ unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > 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",
31
32
  onClick: async () => {
32
33
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
33
34
  Event: TelemetryEvent.LCWChatButtonClicked
34
35
  });
35
36
 
36
- if (state.appStates.isMinimized) {
37
+ if (proactiveChatInNewWindow.current) {
38
+ const proactiveChatIsInPopoutModeEvent = {
39
+ eventName: BroadcastEvent.ProactiveChatIsInPopoutMode
40
+ };
41
+ BroadcastService.postMessage(proactiveChatIsInPopoutModeEvent);
42
+ } else if (state.appStates.isMinimized) {
37
43
  dispatch({
38
44
  type: LiveChatWidgetActionType.SET_MINIMIZED,
39
45
  payload: false
@@ -42,6 +48,7 @@ export const ChatButtonStateful = props => {
42
48
  await startChat();
43
49
  }
44
50
  },
51
+ 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,
45
52
  ...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
46
53
  };
47
54
  const outOfOfficeControlProps = {
@@ -50,6 +57,10 @@ export const ChatButtonStateful = props => {
50
57
  titleText: "We're Offline",
51
58
  subtitleText: "No agents available",
52
59
  onClick: async () => {
60
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
61
+ Event: TelemetryEvent.LCWChatButtonClicked
62
+ });
63
+
53
64
  if (state.appStates.isMinimized) {
54
65
  dispatch({
55
66
  type: LiveChatWidgetActionType.SET_MINIMIZED,
@@ -62,6 +73,7 @@ export const ChatButtonStateful = props => {
62
73
  });
63
74
  }
64
75
  },
76
+ 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,
65
77
  ...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
66
78
  };
67
79
  useEffect(() => {
@@ -83,6 +95,9 @@ export const ChatButtonStateful = props => {
83
95
  });
84
96
  }
85
97
  }, []);
98
+ useEffect(() => {
99
+ proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
100
+ }, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
86
101
  return /*#__PURE__*/React.createElement(ChatButton, {
87
102
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
88
103
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -17,7 +17,6 @@ export const ConfirmationPaneStateful = props => {
17
17
  const {
18
18
  prepareEndChat
19
19
  } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
20
 
22
21
  const [adapter] = useChatAdapterStore();
23
22
  const controlProps = {
@@ -105,8 +105,14 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
105
105
  let fileAttachmentName = TranscriptConstants.DefaultFileAttachmentName;
106
106
  let dialogColor = TranscriptConstants.CustomerDialogColor;
107
107
  let fontColor = TranscriptConstants.CustomerFontColor;
108
-
109
- if (value.tags && value.tags.toLowerCase().indexOf(Constants.systemMessageTag) !== -1 || value.isControlMessage && value.isControlMessage === true || value.contentType && value.contentType.toLowerCase() === TranscriptConstants.AdaptiveCardType || value.deliveryMode && value.deliveryMode.toLowerCase() === TranscriptConstants.InternalMode) {
108
+ const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.systemMessageTag) !== -1;
109
+ const isControlMessage = value.isControlMessage && value.isControlMessage === true;
110
+ const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === TranscriptConstants.AdaptiveCardType;
111
+ const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === TranscriptConstants.InternalMode;
112
+ const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.hiddenTag.toLowerCase()) !== -1;
113
+ const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
114
+
115
+ if (shouldIgnoreMessage) {
110
116
  return;
111
117
  } else if (value.from) {
112
118
  if (value.from.application) {
@@ -127,7 +133,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
127
133
 
128
134
  if (value.attachments && value.attachments.length > 0 && value.attachments[0].name) {
129
135
  fileAttachmentName = value.attachments[0].name;
130
- value.content = attachmentMessage ?? "The following attachment was uploaded during the conversation:" + fileAttachmentName;
136
+ value.content = attachmentMessage ? attachmentMessage + " " + fileAttachmentName : "The following attachment was uploaded during the conversation: " + fileAttachmentName;
131
137
  }
132
138
  }
133
139
 
@@ -58,8 +58,8 @@ export const HeaderStateful = props => {
58
58
  });
59
59
  },
60
60
  ...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
61
- hideTitle: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
62
- hideIcon: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
61
+ hideTitle: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
62
+ hideIcon: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
63
63
  hideCloseButton: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
64
64
  };
65
65
  const outOfOfficeControlProps = {
@@ -0,0 +1,34 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { Deferred } from "./Deferred";
4
+ export class ActivityStreamHandler {
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ /**
9
+ * Use of a deferred pattern, to hold the execution of the activity.
10
+ *
11
+ * */
12
+ static cork() {
13
+ ActivityStreamHandler.restoreDeferred = new Deferred();
14
+ ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
15
+ }
16
+ /**
17
+ * Resolve the promise, releasing it to continue with the execution of the activity.
18
+ *
19
+ * */
20
+
21
+
22
+ static uncork() {
23
+ ActivityStreamHandler.restoreDeferred.resolve();
24
+ }
25
+
26
+ }
27
+
28
+ _defineProperty(ActivityStreamHandler, "restoreDeferred", {
29
+ resolve: () => {
30
+ return "initialState";
31
+ }
32
+ });
33
+
34
+ _defineProperty(ActivityStreamHandler, "restorePromise", void 0);
@@ -0,0 +1,14 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ export class DefaultActivitySubscriber {
4
+ constructor() {
5
+ _defineProperty(this, "observer", void 0);
6
+ }
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ async next(activity) {
10
+ this.observer.next(activity);
11
+ return false;
12
+ }
13
+
14
+ }
@@ -0,0 +1,29 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { ActivityStreamHandler } from "../ActivityStreamHandler";
4
+ export class PauseActivitySubscriber {
5
+ constructor() {
6
+ _defineProperty(this, "observer", void 0);
7
+ }
8
+
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ async apply(activity) {
11
+ await ActivityStreamHandler.restorePromise;
12
+ return activity;
13
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
14
+
15
+
16
+ applicable(activity) {
17
+ return true;
18
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+
20
+
21
+ async next(activity) {
22
+ if (this.applicable(activity)) {
23
+ return await this.apply(activity);
24
+ }
25
+
26
+ return activity;
27
+ }
28
+
29
+ }
@@ -0,0 +1,59 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { DefaultActivitySubscriber } from "./ActivitySubscriber/DefaultActivitySubscriber";
4
+ import { shareObservable } from "./shareObservable";
5
+ export class ChatAdapterShim {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ constructor(chatAdapter) {
11
+ _defineProperty(this, "chatAdapter", void 0);
12
+
13
+ _defineProperty(this, "activityObserver", void 0);
14
+
15
+ _defineProperty(this, "subscribers", void 0);
16
+
17
+ this.subscribers = [];
18
+ this.chatAdapter = { ...chatAdapter,
19
+ activity$: shareObservable( // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ new window.Observable(observer => {
21
+ this.activityObserver = observer; // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+
23
+ const abortController = new window.AbortController();
24
+
25
+ (async () => {
26
+ try {
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ for await (let activity of chatAdapter.activities({
29
+ signal: abortController.signal
30
+ })) {
31
+ for (const subscriber of [...this.subscribers, new DefaultActivitySubscriber()]) {
32
+ subscriber.observer = this.activityObserver;
33
+ activity = await subscriber.next(activity);
34
+
35
+ if (!activity) {
36
+ break;
37
+ }
38
+ }
39
+ }
40
+
41
+ observer.complete();
42
+ } catch (error) {
43
+ observer.error(error);
44
+ }
45
+ })();
46
+
47
+ return () => {
48
+ abortController.abort();
49
+ };
50
+ }))
51
+ };
52
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+
54
+
55
+ addSubscriber(subscriber) {
56
+ this.subscribers.push(subscriber);
57
+ }
58
+
59
+ }