@microsoft/omnichannel-chat-widget 0.1.0-main.50fdaaa → 0.1.0-main.52fa2fc

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 (51) hide show
  1. package/lib/cjs/common/Constants.js +8 -1
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +22 -4
  3. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
  4. package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
  5. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  6. package/lib/cjs/components/livechatwidget/common/endChat.js +38 -64
  7. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +10 -61
  8. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +6 -2
  9. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -2
  10. package/lib/cjs/components/livechatwidget/common/startChat.js +14 -6
  11. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +65 -25
  12. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  13. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  14. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +1 -0
  15. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  16. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  17. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -7
  18. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +6 -2
  19. package/lib/cjs/contexts/createReducer.js +36 -2
  20. package/lib/esm/common/Constants.js +6 -0
  21. package/lib/esm/common/telemetry/TelemetryConstants.js +22 -4
  22. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
  23. package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
  24. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  25. package/lib/esm/components/livechatwidget/common/endChat.js +40 -66
  26. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +12 -63
  27. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +6 -2
  28. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -3
  29. package/lib/esm/components/livechatwidget/common/startChat.js +14 -6
  30. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +65 -25
  31. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  32. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  33. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +2 -0
  34. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  35. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  36. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -7
  37. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +6 -2
  38. package/lib/esm/contexts/createReducer.js +36 -2
  39. package/lib/types/common/Constants.d.ts +7 -0
  40. package/lib/types/common/telemetry/TelemetryConstants.d.ts +18 -6
  41. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  42. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  43. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  44. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
  45. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  46. package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
  47. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
  48. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  49. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
  50. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -7
  51. package/package.json +1 -1
@@ -3,12 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setPostChatContextAndLoadSurvey = void 0;
6
+ exports.setPostChatContextAndLoadSurvey = exports.initiatePostChat = exports.checkPostChatEnabled = void 0;
7
7
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
8
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
9
9
  var _ConversationState = require("../../../contexts/common/ConversationState");
10
10
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
11
11
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
12
+ var _Constants = require("../../../common/Constants");
13
+ var _endChat = require("./endChat");
14
+ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
15
+ var _utils = require("../../../common/utils");
16
+ var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
17
+ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
18
+ var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
12
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
20
  const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
14
21
  try {
@@ -41,4 +48,250 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
41
48
  });
42
49
  });
43
50
  };
44
- exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
51
+
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
54
+ const checkPostChatEnabled = (props, state) => {
55
+ var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2;
56
+ const isPostChatEnabled = ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveyenable) ?? ((_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);
57
+ return isPostChatEnabled === _Constants.Constants.true;
58
+ };
59
+
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ exports.checkPostChatEnabled = checkPostChatEnabled;
62
+ const initiatePostChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
63
+ // Check if Postchat already in progress and handle case where chat is ended by customer
64
+ if (state.appStates.postChatWorkflowInProgress && state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
65
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
66
+ return;
67
+ }
68
+
69
+ // Conversation Details call required by customer as well as agent
70
+ const conversationDetails = await getConversationDetailsCall(chatSDK);
71
+ // Start Postchat workflow
72
+ dispatch({
73
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS,
74
+ payload: true
75
+ });
76
+
77
+ // Below logic checks if agent or bot or noone joins conversation and handles them separately
78
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.userParticipantTypeTag) {
79
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
80
+ // Set use bot settings to false
81
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
82
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
83
+ await postChatInitiatedByAgent(props, setWebChatStyles, dispatch, state);
84
+ } else {
85
+ const error = `Conversation was Ended after agent joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
86
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
87
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
88
+ ExceptionDetails: {
89
+ exception: error
90
+ }
91
+ });
92
+ throw new Error(error);
93
+ }
94
+ } else if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.botParticipantTypeTag) {
95
+ // Set Use bot survey to true
96
+ dispatch({
97
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY,
98
+ payload: true
99
+ });
100
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
101
+ // Set use bot settings to true
102
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, true);
103
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
104
+ await postChatInitiatedByBot(props, setWebChatStyles, dispatch, state);
105
+ } else {
106
+ const error = `Conversation was Ended after bot joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
107
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
108
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
109
+ ExceptionDetails: {
110
+ exception: error
111
+ }
112
+ });
113
+ throw new Error(error);
114
+ }
115
+ } else {
116
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
117
+ // No one has joined chat will be handled by postChat customer
118
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
119
+ } else {
120
+ const error = `ConversationDetails and App state was not set correctly: conversationDetails = ${JSON.stringify(conversationDetails)} , conversationEndedBy = ${state.appStates.conversationEndedBy}`;
121
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
122
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
123
+ ExceptionDetails: {
124
+ exception: error
125
+ }
126
+ });
127
+ throw new Error(error);
128
+ }
129
+ }
130
+ };
131
+
132
+ // Function for link mode postchat workflow which is essentially same for both customer and agent
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ exports.initiatePostChat = initiatePostChat;
135
+ const linkModePostChatWorkflow = (props, dispatch, setWebChatStyles) => {
136
+ var _props$webChatContain, _props$webChatContain2;
137
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
138
+ Event: _TelemetryConstants.TelemetryEvent.LinkModePostChatWorkflowStarted
139
+ });
140
+ dispatch({
141
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
142
+ payload: _ConversationState.ConversationState.InActive
143
+ });
144
+
145
+ // Disable SendBox
146
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
+ setWebChatStyles(styles => {
149
+ return {
150
+ ...styles,
151
+ hideSendBox: true
152
+ };
153
+ });
154
+ }
155
+ };
156
+
157
+ // Function for embed mode postchat workflow which is essentially same for both customer and agent
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
+ const embedModePostChatWorkflow = async (dispatch, state) => {
160
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
161
+ Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
162
+ });
163
+ if (state.domainStates.postChatContext) {
164
+ dispatch({
165
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
166
+ payload: _ConversationState.ConversationState.PostchatLoading
167
+ });
168
+ await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
169
+ const loadPostChatEvent = {
170
+ eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
171
+ };
172
+ _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
173
+ } else {
174
+ const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
175
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
176
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
177
+ ExceptionDetails: {
178
+ exception: error
179
+ }
180
+ });
181
+ throw new Error(error);
182
+ }
183
+ };
184
+
185
+ // Function will handle only postchat cases initiated by customer
186
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
187
+ const postChatInitiatedByCustomer = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, shouldUseBotSetting) => {
188
+ let postChatSurveyMode = "";
189
+ if (shouldUseBotSetting) {
190
+ var _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4;
191
+ postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_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_postconversationsurveybotsurveymode);
192
+ } else {
193
+ var _props$chatConfig3, _props$chatConfig3$Li, _state$domainStates$l5, _state$domainStates$l6;
194
+ postChatSurveyMode = ((_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : (_state$domainStates$l6 = _state$domainStates$l5.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.msdyn_postconversationsurveymode);
195
+ }
196
+ // Check if agent or bot has joined conversation
197
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
198
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
199
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromCustomer,
200
+ Description: shouldUseBotSetting ? "PostChat Workflow was started by customer using bot settings" : "PostChat Workflow was started by customer using agent settings"
201
+ });
202
+ const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
203
+ // End chat call to end chatsdk but not close chat, only if chat ended by customer
204
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, true, false);
205
+ // Saving request Id below for chat transcript calls
206
+ if (chatSession) {
207
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
208
+ chatSDK.chatToken = chatSession.chatToken ?? {};
209
+ chatSDK.requestId = chatSession.requestId;
210
+ }
211
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
212
+ await embedModePostChatWorkflow(dispatch, state);
213
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
214
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
215
+ } else {
216
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
217
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
218
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
219
+ ExceptionDetails: {
220
+ exception: error
221
+ }
222
+ });
223
+ throw new Error(error);
224
+ }
225
+ } else {
226
+ // Agent did not join chat so end chat normally
227
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
228
+ }
229
+ };
230
+
231
+ // Function will handle only postchat cases initiated by agent
232
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
233
+ const postChatInitiatedByAgent = async (props, setWebChatStyles, dispatch, state) => {
234
+ var _props$chatConfig4, _props$chatConfig4$Li, _state$domainStates$l7, _state$domainStates$l8;
235
+ const postChatSurveyMode = ((_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : (_state$domainStates$l8 = _state$domainStates$l7.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l8 === void 0 ? void 0 : _state$domainStates$l8.msdyn_postconversationsurveymode);
236
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
237
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromAgent,
238
+ Description: "PostChat Workflow was started by agent"
239
+ });
240
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
241
+ await embedModePostChatWorkflow(dispatch, state);
242
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
243
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
244
+ } else {
245
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
246
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
247
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
248
+ ExceptionDetails: {
249
+ exception: error
250
+ }
251
+ });
252
+ throw new Error(error);
253
+ }
254
+ };
255
+
256
+ // Function will handle only postchat cases initiated by bot
257
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
258
+ const postChatInitiatedByBot = async (props, setWebChatStyles, dispatch, state) => {
259
+ var _props$chatConfig5, _props$chatConfig5$Li, _state$domainStates$l9, _state$domainStates$l10;
260
+ const postChatSurveyMode = ((_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l9 = state.domainStates.liveChatConfig) === null || _state$domainStates$l9 === void 0 ? void 0 : (_state$domainStates$l10 = _state$domainStates$l9.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l10 === void 0 ? void 0 : _state$domainStates$l10.msdyn_postconversationsurveybotsurveymode);
261
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
262
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromBot,
263
+ Description: "PostChat Workflow was started by bot"
264
+ });
265
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
266
+ await embedModePostChatWorkflow(dispatch, state);
267
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
268
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
269
+ } else {
270
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveybotsurveymode = ${postChatSurveyMode}`;
271
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
272
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
273
+ ExceptionDetails: {
274
+ exception: error
275
+ }
276
+ });
277
+ throw new Error(error);
278
+ }
279
+ };
280
+
281
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
282
+ const getConversationDetailsCall = async chatSDK => {
283
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
284
+ let conversationDetails = undefined;
285
+ try {
286
+ conversationDetails = await chatSDK.getConversationDetails();
287
+ } catch (error) {
288
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
289
+ Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
290
+ ExceptionDetails: {
291
+ exception: `Get Conversation Details Call Failed : ${error}`
292
+ }
293
+ });
294
+ _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + error);
295
+ }
296
+ return conversationDetails;
297
+ };
@@ -32,10 +32,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
32
32
  optionalParams = {}; //Resetting to ensure no stale values
33
33
  widgetInstanceId = props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId;
34
34
 
35
- // Can connect to existing chat session
36
- if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
37
- return;
38
- }
35
+ // reconnect > chat from cache
39
36
  await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, initStartChat, state);
40
37
 
41
38
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
@@ -43,6 +40,11 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
43
40
  return;
44
41
  }
45
42
 
43
+ // Can connect to existing chat session
44
+ if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
45
+ return;
46
+ }
47
+
46
48
  // Setting Proactive chat settings
47
49
  const isProactiveChat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat;
48
50
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
@@ -312,12 +314,18 @@ const setCustomContextParams = chatSDK => {
312
314
  };
313
315
 
314
316
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
315
- const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch) => {
317
+ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
318
+ var _state$domainStates, _state$domainStates$l;
319
+ const requestId = (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatContext) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.requestId;
316
320
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
317
321
  let conversationDetails = undefined;
318
322
 
319
323
  //Preserve old requestId
320
- const oldRequestId = chatSDK.requestId;
324
+ const oldRequestId = chatSDK.requestId ?? "";
325
+ dispatch({
326
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID,
327
+ payload: oldRequestId
328
+ });
321
329
  try {
322
330
  chatSDK.requestId = requestId;
323
331
  conversationDetails = await chatSDK.getConversationDetails();
@@ -50,12 +50,15 @@ var _startProactiveChat = require("../common/startProactiveChat");
50
50
  var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
51
51
  var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
52
52
  var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
53
+ var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
54
+ var _agentEndConversationHelper = require("../common/agentEndConversationHelper");
55
+ var _reconnectChatHelper = require("../common/reconnectChatHelper");
53
56
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54
57
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
55
58
  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; }
56
59
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
57
60
  const LiveChatWidgetStateful = props => {
58
- var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps14, _props$controlProps15, _props$componentOverr, _props$controlProps16, _props$componentOverr2, _props$controlProps17, _props$componentOverr3, _props$controlProps18, _props$componentOverr4, _props$controlProps19, _props$componentOverr5, _props$controlProps20, _props$componentOverr6, _props$controlProps21, _props$componentOverr7, _props$controlProps22, _props$controlProps23, _props$componentOverr8, _props$controlProps24, _props$componentOverr9, _props$controlProps25, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
61
+ var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps15, _props$controlProps16, _props$componentOverr, _props$controlProps17, _props$componentOverr2, _props$controlProps18, _props$componentOverr3, _props$controlProps19, _props$componentOverr4, _props$controlProps20, _props$componentOverr5, _props$controlProps21, _props$componentOverr6, _props$controlProps22, _props$componentOverr7, _props$controlProps23, _props$controlProps24, _props$componentOverr8, _props$controlProps25, _props$componentOverr9, _props$controlProps26, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
59
62
  const [state, dispatch] = (0, _useChatContextStore.default)();
60
63
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
64
  const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
@@ -113,7 +116,6 @@ const LiveChatWidgetStateful = props => {
113
116
 
114
117
  //Start a chat from cache/reconnectid
115
118
  if (activeCachedChatExist === true) {
116
- var _state$domainStates3, _state$domainStates3$;
117
119
  dispatch({
118
120
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
119
121
  payload: _ConversationState.ConversationState.Loading
@@ -123,8 +125,16 @@ const LiveChatWidgetStateful = props => {
123
125
  }
124
126
 
125
127
  //Check if conversation state is not in wrapup or closed state
126
- isChatValid = await (0, _startChat.checkIfConversationStillValid)(chatSDK, props, (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.liveChatContext) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.requestId, dispatch);
128
+ isChatValid = await (0, _startChat.checkIfConversationStillValid)(chatSDK, dispatch, state);
127
129
  if (isChatValid === true) {
130
+ //Check if reconnect enabled
131
+ if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true) {
132
+ await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
133
+ // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
134
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat) {
135
+ return;
136
+ }
137
+ }
128
138
  await (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams);
129
139
  return;
130
140
  }
@@ -214,7 +224,7 @@ const LiveChatWidgetStateful = props => {
214
224
 
215
225
  // useEffect for custom context
216
226
  (0, _react2.useEffect)(() => {
217
- var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps12;
227
+ var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps13;
218
228
  // Add the custom context on receiving the SetCustomContext event
219
229
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
220
230
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -242,14 +252,33 @@ const LiveChatWidgetStateful = props => {
242
252
  }
243
253
  });
244
254
 
255
+ // Toggle chat visibility
256
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(event => {
257
+ var _event$payload;
258
+ if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
259
+ var _event$payload2, _props$controlProps10;
260
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
261
+ Event: _TelemetryConstants.TelemetryEvent.ChatVisibilityChanged,
262
+ Description: "Chat visibility changed to " + (event === null || event === void 0 ? void 0 : (_event$payload2 = event.payload) === null || _event$payload2 === void 0 ? void 0 : _event$payload2.isChatHidden)
263
+ });
264
+ if ((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideStartChatButton) {
265
+ var _event$payload3;
266
+ dispatch({
267
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
268
+ payload: event === null || event === void 0 ? void 0 : (_event$payload3 = event.payload) === null || _event$payload3 === void 0 ? void 0 : _event$payload3.isChatHidden
269
+ });
270
+ }
271
+ }
272
+ });
273
+
245
274
  // Start chat from SDK Event
246
275
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
247
- var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps10;
276
+ var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps11;
248
277
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
249
278
  Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
250
279
  Description: "Start chat event received."
251
280
  });
252
- const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
281
+ const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
253
282
 
254
283
  // Chat not found in cache
255
284
  if (persistedState === undefined) {
@@ -290,9 +319,9 @@ const LiveChatWidgetStateful = props => {
290
319
  // End chat
291
320
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
292
321
  if (state.appStates.hideStartChatButton === false) {
293
- var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps11;
322
+ var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps12;
294
323
  // This is to ensure to get latest state from cache in multitab
295
- const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
324
+ const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
296
325
  if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
297
326
  (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
298
327
  } else {
@@ -312,14 +341,14 @@ const LiveChatWidgetStateful = props => {
312
341
  });
313
342
 
314
343
  // Listen to end chat event from other tabs
315
- const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
344
+ const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
316
345
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
317
346
  (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
318
347
  return;
319
348
  });
320
349
 
321
350
  // When conversation ended by agent
322
- if (state.appStates.conversationEndedByAgent) {
351
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
323
352
  (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
324
353
  }
325
354
 
@@ -417,7 +446,7 @@ const LiveChatWidgetStateful = props => {
417
446
 
418
447
  // Publish chat widget state
419
448
  (0, _react2.useEffect)(() => {
420
- var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps13;
449
+ var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps14;
421
450
  // Only activate these windows events when conversation state is active and chat widget is in popout mode
422
451
  // Ghost chat scenarios
423
452
  /* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
@@ -435,7 +464,7 @@ const LiveChatWidgetStateful = props => {
435
464
  };
436
465
  }*/
437
466
 
438
- widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
467
+ widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps14 = props.controlProps) === null || _props$controlProps14 === void 0 ? void 0 : _props$controlProps14.widgetInstanceId) ?? "");
439
468
  const chatWidgetStateChangeEvent = {
440
469
  eventName: widgetStateEventName,
441
470
  payload: {
@@ -444,6 +473,20 @@ const LiveChatWidgetStateful = props => {
444
473
  };
445
474
  _omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
446
475
  }, [state]);
476
+
477
+ // Initiate End chat from a single point
478
+ (0, _react2.useEffect)(() => {
479
+ if (state.appStates.conversationEndedBy !== undefined) {
480
+ (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
481
+ }
482
+ }, [state.appStates.conversationEndedBy]);
483
+
484
+ // Handle Agent end conversation cases
485
+ (0, _react2.useEffect)(() => {
486
+ if (state.appStates.conversationEndedByAgentEventReceived) {
487
+ (0, _agentEndConversationHelper.handleAgentEndConversation)(props, state, dispatch);
488
+ }
489
+ }, [state.appStates.conversationEndedByAgentEventReceived]);
447
490
  const initiateEndChatOnBrowserUnload = () => {
448
491
  var _DataStoreManager$cli;
449
492
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -463,12 +506,10 @@ const LiveChatWidgetStateful = props => {
463
506
  eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
464
507
  });
465
508
  };
466
- const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
509
+ const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, setAdapter, state, dispatch, adapter, setWebChatStyles);
467
510
  const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
468
511
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
469
512
  const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
470
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
471
- const prepareEndChatRelay = (adapter, state) => (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
472
513
  const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
473
514
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
474
515
  const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
@@ -497,29 +538,28 @@ const LiveChatWidgetStateful = props => {
497
538
  id: widgetElementId,
498
539
  styles: generalStyles,
499
540
  className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
500
- }, !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideChatButton) && !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideStartChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
541
+ }, !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideChatButton) && !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideStartChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
501
542
  buttonProps: props.chatButtonProps,
502
543
  outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
503
544
  startChat: prepareStartChatRelay
504
- })), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
545
+ })), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
505
546
  proactiveChatProps: props.proactiveChatPaneProps,
506
547
  startChat: prepareStartChatRelay
507
- })), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
548
+ })), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
508
549
  headerProps: props.headerProps,
509
550
  outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
510
551
  endChat: endChatRelay
511
- })), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
552
+ })), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
512
553
  reconnectChatProps: props.reconnectChatPaneProps,
513
554
  initStartChat: initStartChatRelay
514
- })), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
555
+ })), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
515
556
  surveyProps: props.preChatSurveyPaneProps,
516
557
  initStartChat: initStartChatRelay
517
- })), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
558
+ })), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
518
559
  voiceVideoCallingSdk: voiceVideoCallingSDK
519
- }, props.callingContainerProps)), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
520
- setPostChatContext: setPostChatContextRelay,
521
- prepareEndChat: prepareEndChatRelay
522
- }))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane)))));
560
+ }, props.callingContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
561
+ setPostChatContext: setPostChatContextRelay
562
+ }))), !((_props$controlProps26 = props.controlProps) !== null && _props$controlProps26 !== void 0 && _props$controlProps26.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane)))));
523
563
  };
524
564
  exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
525
565
  var _default = LiveChatWidgetStateful;
@@ -24,7 +24,9 @@ const PostChatSurveyPaneStateful = props => {
24
24
  display: state.appStates.isMinimized ? "none" : ""
25
25
  });
26
26
  let surveyInviteLink = "";
27
- if (state.domainStates.postChatContext.surveyInviteLink) {
27
+ if (state.appStates.shouldUseBotSurvey && state.domainStates.postChatContext.botSurveyInviteLink) {
28
+ surveyInviteLink = state.domainStates.postChatContext.botSurveyInviteLink + "&embed=" + (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
29
+ } else {
28
30
  surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink + "&embed=" + (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
29
31
  }
30
32
  const styleProps = {
@@ -35,10 +35,12 @@ const ReconnectChatPaneStateful = props => {
35
35
  };
36
36
  await initStartChat(optionalParams);
37
37
  } else {
38
+ var _state$domainStates;
38
39
  dispatch({
39
40
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
40
41
  payload: undefined
41
42
  });
43
+ chatSDK.requestId = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.initialChatSdkRequestId;
42
44
  const parseToJson = false;
43
45
  const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
44
46
  if (preChatSurveyResponse) {
@@ -22,6 +22,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
22
22
  * This middleware changes the component that shows who's actively typing. It uses the default Microsoft LiveChatWidget styles.
23
23
  ******/
24
24
 
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
26
  const TypingIndicator = _ref => {
26
27
  var _state$domainStates$l, _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3;
27
28
  let {