@microsoft/omnichannel-chat-widget 0.1.0-main.a2e5071 → 0.1.0-main.a3902df

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 (101) hide show
  1. package/lib/cjs/assets/Icons.js +4 -2
  2. package/lib/cjs/common/Constants.js +7 -3
  3. package/lib/cjs/common/KeyCodes.js +3 -1
  4. package/lib/cjs/common/contextDataStore/DataStoreManager.js +3 -1
  5. package/lib/cjs/common/storage/default/defaultCacheManager.js +5 -3
  6. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  7. package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
  8. package/lib/cjs/common/telemetry/TelemetryHelper.js +5 -2
  9. package/lib/cjs/common/telemetry/TelemetryManager.js +3 -1
  10. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
  11. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  12. package/lib/cjs/components/headerstateful/HeaderStateful.js +6 -4
  13. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
  14. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
  16. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +3 -1
  17. package/lib/cjs/components/livechatwidget/common/Deferred.js +3 -1
  18. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +64 -13
  19. package/lib/cjs/components/livechatwidget/common/endChat.js +20 -2
  20. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +13 -19
  21. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +4 -7
  22. package/lib/cjs/components/livechatwidget/common/startChat.js +79 -19
  23. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +38 -37
  24. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +15 -2
  25. package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
  26. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  27. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  28. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +3 -1
  29. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
  30. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  40. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +29 -28
  41. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +5 -2
  42. package/lib/cjs/contexts/createReducer.js +8 -0
  43. package/lib/cjs/plugins/newMessageEventHandler.js +4 -0
  44. package/lib/esm/assets/Icons.js +2 -1
  45. package/lib/esm/common/Constants.js +7 -3
  46. package/lib/esm/common/KeyCodes.js +3 -1
  47. package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -1
  48. package/lib/esm/common/storage/default/defaultCacheManager.js +5 -3
  49. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  50. package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
  51. package/lib/esm/common/telemetry/TelemetryHelper.js +5 -2
  52. package/lib/esm/common/telemetry/TelemetryManager.js +3 -1
  53. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
  54. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  55. package/lib/esm/components/headerstateful/HeaderStateful.js +6 -4
  56. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
  57. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
  58. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
  59. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +3 -1
  60. package/lib/esm/components/livechatwidget/common/Deferred.js +3 -1
  61. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +64 -13
  62. package/lib/esm/components/livechatwidget/common/endChat.js +20 -2
  63. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -19
  64. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +5 -7
  65. package/lib/esm/components/livechatwidget/common/startChat.js +79 -19
  66. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +39 -38
  67. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +15 -2
  68. package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
  69. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  70. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  71. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +3 -1
  72. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
  73. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  74. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
  75. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
  76. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  77. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
  81. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  82. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  83. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +29 -28
  84. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +5 -2
  85. package/lib/esm/contexts/createReducer.js +8 -0
  86. package/lib/esm/plugins/newMessageEventHandler.js +4 -0
  87. package/lib/types/assets/Icons.d.ts +1 -0
  88. package/lib/types/common/Constants.d.ts +2 -0
  89. package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
  90. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
  91. package/lib/types/common/telemetry/TelemetryConstants.d.ts +5 -1
  92. package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
  93. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  94. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  95. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
  96. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
  97. package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
  98. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  99. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  100. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +29 -28
  101. package/package.json +3 -3
@@ -1,4 +1,6 @@
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; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  import { LogLevel, ScenarioType, TelemetryConstants, TelemetryEvent } from "./TelemetryConstants";
3
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
6
  import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
@@ -82,7 +82,7 @@ export const ConfirmationPaneStateful = props => {
82
82
  Event: TelemetryEvent.ConfirmationPaneLoaded
83
83
  });
84
84
  }, []);
85
- return /*#__PURE__*/React.createElement(React.Fragment, null, !(controlProps !== null && controlProps !== void 0 && controlProps.disableDimLayer) && /*#__PURE__*/React.createElement(DimLayer, {
85
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DimLayer, {
86
86
  brightness: (controlProps === null || controlProps === void 0 ? void 0 : controlProps.brightnessValueOnDim) ?? "0.2"
87
87
  }), /*#__PURE__*/React.createElement(ConfirmationPane, {
88
88
  componentOverrides: props === null || props === void 0 ? void 0 : props.componentOverrides,
@@ -88,7 +88,7 @@ export const EmailTranscriptPaneStateful = props => {
88
88
  Event: TelemetryEvent.EmailTranscriptLoaded
89
89
  });
90
90
  }, [initialEmail]);
91
- return /*#__PURE__*/React.createElement(React.Fragment, null, !(controlProps !== null && controlProps !== void 0 && controlProps.disableDimLayer) && /*#__PURE__*/React.createElement(DimLayer, {
91
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DimLayer, {
92
92
  brightness: (controlProps === null || controlProps === void 0 ? void 0 : controlProps.brightnessValueOnDim) ?? "0.2"
93
93
  }), /*#__PURE__*/React.createElement(InputValidationPane, {
94
94
  componentOverrides: props.componentOverrides,
@@ -21,6 +21,7 @@ export const HeaderStateful = props => {
21
21
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
22
22
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
23
23
  const conversationState = useRef(state.appStates.conversationState);
24
+ const conversationEndedByAgent = useRef(state.appStates.conversationEndedByAgent);
24
25
  const controlProps = {
25
26
  id: "oc-lcw-header",
26
27
  dir: state.domainStates.globalDir,
@@ -40,7 +41,7 @@ export const HeaderStateful = props => {
40
41
  Event: TelemetryEvent.HeaderCloseButtonClicked,
41
42
  Description: "Header Close button clicked."
42
43
  });
43
- if (conversationState.current === ConversationState.Active) {
44
+ if (conversationState.current === ConversationState.Active || conversationEndedByAgent.current) {
44
45
  dispatch({
45
46
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
46
47
  payload: true
@@ -60,9 +61,9 @@ export const HeaderStateful = props => {
60
61
  }
61
62
  },
62
63
  ...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
63
- 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),
64
- 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),
65
- 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
+ hideTitle: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
65
+ hideIcon: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
66
+ hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
66
67
  };
67
68
  const outOfOfficeControlProps = {
68
69
  id: "oc-lcw-header",
@@ -86,6 +87,7 @@ export const HeaderStateful = props => {
86
87
  if (state.appStates.conversationState) {
87
88
  conversationState.current = state.appStates.conversationState;
88
89
  }
90
+ conversationEndedByAgent.current = state.appStates.conversationEndedByAgent;
89
91
  }, [state.appStates]);
90
92
  return /*#__PURE__*/React.createElement(Header, {
91
93
  componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
@@ -1,4 +1,6 @@
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; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  import { Deferred } from "./Deferred";
3
5
  export class ActivityStreamHandler {
4
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,4 +1,6 @@
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; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  export class DefaultActivitySubscriber {
3
5
  constructor() {
4
6
  _defineProperty(this, "observer", void 0);
@@ -1,4 +1,6 @@
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; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  import { ActivityStreamHandler } from "../ActivityStreamHandler";
3
5
  export class PauseActivitySubscriber {
4
6
  constructor() {
@@ -1,4 +1,6 @@
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; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  import { DefaultActivitySubscriber } from "./ActivitySubscriber/DefaultActivitySubscriber";
3
5
  import { shareObservable } from "./shareObservable";
4
6
  export class ChatAdapterShim {
@@ -1,4 +1,6 @@
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; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  export class Deferred {
3
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
6
 
@@ -9,9 +9,9 @@ import { createActivityMiddleware } from "../../../webchatcontainerstateful/webc
9
9
  import createAttachmentMiddleware from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
10
10
  import { createAvatarMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
11
11
  import { createMarkdown } from "../createMarkdown";
12
+ import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
12
13
  import { groupActivitiesMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
13
14
  import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
14
- import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
15
15
 
16
16
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
17
  export const dummyDefaultProps = {
@@ -407,6 +407,7 @@ export const dummyDefaultProps = {
407
407
  width: "90px",
408
408
  cursor: "pointer",
409
409
  overflow: "hidden",
410
+ padding: "0px",
410
411
  whiteSpace: "nowrap"
411
412
  },
412
413
  subtitleStyleProps: {
@@ -414,12 +415,14 @@ export const dummyDefaultProps = {
414
415
  fontWeight: "200",
415
416
  color: "#666",
416
417
  overflow: "hidden",
418
+ padding: "0px",
417
419
  fontFamily: "'Segoe UI',Arial,sans-serif",
418
420
  display: "block",
419
421
  alignItems: "center",
420
422
  margin: "0px 14px 0px 14px",
421
423
  textOverflow: "ellipsis !important",
422
- width: "max-content",
424
+ width: "90px",
425
+ whiteSpace: "nowrap",
423
426
  cursor: "pointer"
424
427
  },
425
428
  classNames: {
@@ -469,7 +472,6 @@ export const dummyDefaultProps = {
469
472
  cancelButtonText: "Cancel",
470
473
  cancelButtonAriaLabel: "Cancel. Return to Chat",
471
474
  brightnessValueOnDim: "0.2",
472
- disableDimLayer: false,
473
475
  onConfirm: () => {},
474
476
  // Detailed implementation omitted
475
477
  onCancel: () => {} // Detailed implementation omitted
@@ -477,20 +479,23 @@ export const dummyDefaultProps = {
477
479
 
478
480
  styleProps: {
479
481
  generalStyleProps: {
482
+ display: "flex",
483
+ minHeight: "160px",
484
+ maxHeight: "300px",
485
+ boxSizing: "border-box",
480
486
  backgroundColor: "#FFFFFF",
481
487
  borderRadius: "2px",
482
488
  color: "black",
483
489
  fontFamily: "Segoe UI, Arial, sans-serif",
484
490
  fontSize: "14px",
485
- height: "160px",
486
491
  padding: "10px 20px",
487
- width: "262px",
488
492
  position: "absolute",
489
493
  justifyContent: "center",
490
494
  alignItems: "center",
491
- display: "flex",
492
495
  flexFlow: "column",
493
- zIndex: "9999"
496
+ zIndex: "9999",
497
+ left: "26px",
498
+ right: "26px"
494
499
  },
495
500
  titleStyleProps: {
496
501
  color: "#323130",
@@ -512,10 +517,14 @@ export const dummyDefaultProps = {
512
517
  },
513
518
  buttonGroupStyleProps: {
514
519
  display: "flex",
520
+ width: "auto",
521
+ height: "auto",
522
+ boxSizing: "border-box",
515
523
  flexFlow: "row",
516
524
  justifyContent: "center",
517
525
  alignItems: "center",
518
- gap: "10px"
526
+ gap: "10px",
527
+ marginBottom: "10px"
519
528
  },
520
529
  confirmButtonStyleProps: {
521
530
  backgroundColor: "rgba(9,72,159,1)",
@@ -570,6 +579,7 @@ export const dummyDefaultProps = {
570
579
  hideCallingContainer: false,
571
580
  hideChatButton: false,
572
581
  hideConfirmationPane: false,
582
+ hideErrorUIPane: false,
573
583
  hideFooter: false,
574
584
  hideHeader: false,
575
585
  hideLoadingPane: false,
@@ -620,7 +630,6 @@ export const dummyDefaultProps = {
620
630
  cancelButtonText: "Cancel",
621
631
  cancelButtonAriaLabel: "Cancel",
622
632
  brightnessValueOnDim: "0.2",
623
- disableDimLayer: false,
624
633
  onSend: undefined,
625
634
  onCancel: undefined,
626
635
  checkInput: undefined
@@ -1110,7 +1119,8 @@ export const dummyDefaultProps = {
1110
1119
  dir: "auto",
1111
1120
  hideOOOHPane: false,
1112
1121
  hideTitle: false,
1113
- titleText: "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open."
1122
+ titleText: "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open. Please see link https://microsoft.com",
1123
+ openLinkInNewTab: true
1114
1124
  },
1115
1125
  styleProps: {
1116
1126
  generalStyleProps: {
@@ -1153,7 +1163,7 @@ export const dummyDefaultProps = {
1153
1163
  subtitleText: "Please take a moment to give us feedback about your chat experience. We are loading the survey for you now."
1154
1164
  },
1155
1165
  styleProps: {
1156
- // ...[Existing chat button style props]
1166
+ // ...[Existing loading pane style props]
1157
1167
  generalStyleProps: {
1158
1168
  position: "initial",
1159
1169
  width: "100%",
@@ -1184,6 +1194,47 @@ export const dummyDefaultProps = {
1184
1194
  },
1185
1195
  isCustomerVoiceSurveyCompact: undefined
1186
1196
  },
1197
+ preChatSurveyPaneProps: {
1198
+ controlProps: {
1199
+ id: "oc-lcw-prechatsurveypane-default",
1200
+ dir: "auto",
1201
+ hidePreChatSurveyPane: false,
1202
+ adaptiveCardHostConfig: "{\"fontFamily\":\"Segoe UI, Helvetica Neue, sans-serif\",\"containerStyles\":{\"default\":{\"foregroundColors\":{\"default\":{\"default\":\"#000000\"}},\"backgroundColor\":\"#FFFFFF\"}},\"actions\":{\"actionsOrientation\":\"Vertical\",\"actionAlignment\":\"stretch\"}}",
1203
+ payload: "{\"$schema\":\"http://adaptivecards.io/schemas/adaptive-card.json\",\"type\":\"AdaptiveCard\",\"version\":\"1.1\",\"body\":[{\"type\":\"TextBlock\",\"weight\":\"bolder\",\"text\":\"Please answer below questions.\"},{\"type\":\"Input.Text\",\"id\":\"1e5e4e7a-8f0b-ec11-b6e6-000d3a305d38\",\"label\":\"name pls?\",\"maxLength\":100,\"isRequired\":true,\"errorMessage\":\"Name is required\"},{\"type\":\"Input.Text\",\"id\":\"7f8f5d6d-995e-ec11-8f8f-000d3a31376e\",\"label\":\"multi\\nmulti\\nmulti\",\"style\":\"text\",\"isMultiline\":true,\"maxLength\":250},{\"type\":\"Input.ChoiceSet\",\"id\":\"e4bdf7cb-995e-ec11-8f8f-000d3a31376e\",\"label\":\"options\",\"isMultiSelect\":false,\"value\":\"1\",\"style\":\"compact\",\"choices\":[{\"title\":\"one\",\"value\":\"1\"},{\"title\":\"two\",\"value\":\"2\"},{\"title\":\"three\",\"value\":\"3\"}]},{\"type\":\"Input.Toggle\",\"id\":\"b26011d2-995e-ec11-8f8f-000d3a31376e\",\"title\":\"consent\",\"valueOn\":\"True\",\"valueOff\":\"False\",\"value\":\"false\"},{\"type\":\"TextBlock\",\"isSubtle\":true,\"text\":\"Fields marked with * are mandatory.\",\"wrap\":true}],\"actions\":[{\"type\":\"Action.Submit\",\"title\":\"Submit\",\"data\":{\"Type\":\"InputSubmit\"}}]}",
1204
+ onSubmit: function () {} // Detailed implementation omitted
1205
+ },
1206
+
1207
+ styleProps: {
1208
+ generalStyleProps: {
1209
+ borderStyle: "solid",
1210
+ borderRadius: "4px",
1211
+ borderWidth: "0px",
1212
+ backgroundColor: "#FFFFFF",
1213
+ borderColor: "#F1F1F1",
1214
+ overflowY: "auto",
1215
+ height: "inherit",
1216
+ width: "inherit"
1217
+ },
1218
+ customButtonStyleProps: {
1219
+ backgroundColor: "rgb(49, 95, 162)",
1220
+ color: "#FFFFFF",
1221
+ fontFamily: "Segoe UI, Arial, sans-serif",
1222
+ fontSize: "15px",
1223
+ height: "48px"
1224
+ },
1225
+ adaptiveCardContainerStyleProps: {
1226
+ border: "1px solid #ECECEC",
1227
+ borderRadius: "4px",
1228
+ margin: "3%"
1229
+ },
1230
+ customTextInputStyleProps: {
1231
+ height: "20px"
1232
+ },
1233
+ customMultilineTextInputStyleProps: {
1234
+ height: "52px"
1235
+ }
1236
+ }
1237
+ },
1187
1238
  proactiveChatPaneProps: {
1188
1239
  componentOverrides: {
1189
1240
  title: undefined,
@@ -1562,10 +1613,10 @@ export const dummyDefaultProps = {
1562
1613
  padding: "0px 10px 0 10px"
1563
1614
  },
1564
1615
  userMessageBoxStyles: {
1565
- maxWidth: "75%"
1616
+ maxWidth: "90%"
1566
1617
  },
1567
1618
  systemMessageBoxStyles: {
1568
- maxWidth: "75%"
1619
+ maxWidth: "90%"
1569
1620
  },
1570
1621
  typingIndicatorStyleProps: {
1571
1622
  marginLeft: "10px",
@@ -48,7 +48,13 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
48
48
  if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === Constants.truePascal) {
49
49
  const skipEndChatSDK = false;
50
50
  const skipCloseChat = true;
51
+ const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
51
52
  await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, false);
53
+ if (chatSession) {
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ chatSDK.chatToken = chatSession.chatToken ?? {};
56
+ chatSDK.requestId = chatSession.requestId;
57
+ }
52
58
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
53
59
  dispatch({
54
60
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
@@ -60,10 +66,22 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
60
66
  };
61
67
  BroadcastService.postMessage(loadPostChatEvent);
62
68
  } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
69
+ var _props$webChatContain, _props$webChatContain2;
63
70
  dispatch({
64
71
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
65
72
  payload: ConversationState.InActive
66
73
  });
74
+
75
+ // Disable SendBox
76
+ 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) {
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ setWebChatStyles(styles => {
79
+ return {
80
+ ...styles,
81
+ hideSendBox: true
82
+ };
83
+ });
84
+ }
67
85
  }
68
86
  return;
69
87
  }
@@ -108,12 +126,12 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
108
126
  });
109
127
  if (!skipCloseChat) {
110
128
  try {
111
- var _props$webChatContain;
129
+ var _props$webChatContain3;
112
130
  adapter === null || adapter === void 0 ? void 0 : adapter.end();
113
131
  setAdapter(undefined);
114
132
  setWebChatStyles({
115
133
  ...defaultWebChatContainerStatefulProps.webChatStyles,
116
- ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
134
+ ...((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles)
117
135
  });
118
136
  WebChatStoreLoader.store = null;
119
137
  dispatch({
@@ -62,25 +62,19 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
62
62
  };
63
63
  });
64
64
  }
65
- if (isPostChatEnabled === "true") {
66
- if (postChatSurveyMode === PostChatSurveyMode.Embed) {
67
- WebChatStoreLoader.store = null;
68
- dispatch({
69
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
70
- payload: ConversationState.PostchatLoading
71
- });
72
- await addDelayInMs(Constants.PostChatLoadingDurationInMs);
73
- const loadPostChatEvent = {
74
- eventName: BroadcastEvent.LoadPostChatSurvey
75
- };
76
- BroadcastService.postMessage(loadPostChatEvent);
77
- } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
78
- dispatch({
79
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
80
- payload: ConversationState.InActive
81
- });
82
- }
83
- } else {
65
+ if (isPostChatEnabled === "true" && postChatSurveyMode === PostChatSurveyMode.Embed && state.appStates.conversationState === ConversationState.Active) {
66
+ WebChatStoreLoader.store = null;
67
+ dispatch({
68
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
69
+ payload: ConversationState.PostchatLoading
70
+ });
71
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
72
+ const loadPostChatEvent = {
73
+ eventName: BroadcastEvent.LoadPostChatSurvey
74
+ };
75
+ BroadcastService.postMessage(loadPostChatEvent);
76
+ }
77
+ if (state.appStates.conversationState === ConversationState.Active) {
84
78
  dispatch({
85
79
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
86
80
  payload: ConversationState.InActive
@@ -1,11 +1,12 @@
1
1
  import "regenerator-runtime/runtime";
2
2
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
+ import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
4
+ import { isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
3
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
6
  import { ConversationState } from "../../../contexts/common/ConversationState";
5
7
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
8
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
- import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
8
- import { isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
9
+
9
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
11
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
11
12
  var _props$chatConfig, _props$chatConfig$Liv;
@@ -76,10 +77,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
76
77
 
77
78
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
79
  const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, dispatch, setAdapter, reconnectId, initStartChat) => {
79
- if (isAuthenticatedChat) {
80
- // Get auth token for for getting chat reconnect context
81
- await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
82
- } else {
80
+ if (!isAuthenticatedChat) {
83
81
  const startUnauthenticatedReconnectChat = {
84
82
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
85
83
  };
@@ -96,7 +94,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, d
96
94
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
97
95
  payload: ConversationState.Loading
98
96
  });
99
- await initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
97
+ await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
100
98
  };
101
99
  const redirectPage = (redirectURL, redirectInSameWindow) => {
102
100
  const redirectPageRequest = {
@@ -1,5 +1,9 @@
1
- import { ChatSDKError, LiveWorkItemState } from "../../../common/Constants";
2
1
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { ChatSDKError, LiveWorkItemState } from "../../../common/Constants";
3
+ import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
4
+ import { getAuthClientFunction, handleAuthentication } from "./authHelper";
5
+ import { ActivityStreamHandler } from "./ActivityStreamHandler";
6
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
7
  import { ConversationState } from "../../../contexts/common/ConversationState";
4
8
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
9
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
@@ -8,13 +12,9 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
12
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
9
13
  import { createAdapter } from "./createAdapter";
10
14
  import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
11
- import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
15
+ import { handleChatReconnect } from "./reconnectChatHelper";
12
16
  import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
13
17
  import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
14
- import { BroadcastService } from "@microsoft/omnichannel-chat-components";
15
- import { ActivityStreamHandler } from "./ActivityStreamHandler";
16
- import { getAuthClientFunction, handleAuthentication } from "./authHelper";
17
- import { handleChatReconnect } from "./reconnectChatHelper";
18
18
 
19
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
20
  let optionalParams = {};
@@ -78,11 +78,19 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
78
78
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
79
79
  payload: ConversationState.Loading
80
80
  });
81
- await initStartChat(chatSDK, props === null || props === void 0 ? void 0 : props.chatConfig, props === null || props === void 0 ? void 0 : props.getAuthToken, dispatch, setAdapter);
81
+ const optionalParams = {
82
+ isProactiveChat
83
+ };
84
+ await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
82
85
  };
83
86
 
84
87
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
- const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, params, persistedState) => {
88
+ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persistedState) => {
89
+ var _props$controlProps2;
90
+ let isStartChatSuccessful = false;
91
+ const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
92
+ const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
93
+ const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
86
94
  try {
87
95
  var _newAdapter$activity$, _TelemetryTimers$Widg;
88
96
  //Start widget load timer
@@ -99,7 +107,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
99
107
  return;
100
108
  }
101
109
  }
102
- let isStartChatSuccessful = false;
103
110
 
104
111
  //Check if chat retrieved from cache
105
112
  if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
@@ -113,14 +120,16 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
113
120
  });
114
121
  }
115
122
  try {
116
- TelemetryHelper.logSDKEvent(LogLevel.INFO, {
117
- Event: TelemetryEvent.StartChatSDKCall
118
- });
119
-
123
+ var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
120
124
  // Set custom context params
121
125
  setCustomContextParams(chatSDK);
122
- optionalParams = Object.assign({}, params, optionalParams);
123
- await chatSDK.startChat(optionalParams);
126
+ const defaultOptionalParams = {
127
+ sendDefaultInitContext: true,
128
+ isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
129
+ portalContactId: (_window$Microsoft = window.Microsoft) === null || _window$Microsoft === void 0 ? void 0 : (_window$Microsoft$Dyn = _window$Microsoft.Dynamic365) === null || _window$Microsoft$Dyn === void 0 ? void 0 : (_window$Microsoft$Dyn2 = _window$Microsoft$Dyn.Portal) === null || _window$Microsoft$Dyn2 === void 0 ? void 0 : (_window$Microsoft$Dyn3 = _window$Microsoft$Dyn2.User) === null || _window$Microsoft$Dyn3 === void 0 ? void 0 : _window$Microsoft$Dyn3.contactId
130
+ };
131
+ const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
132
+ await chatSDK.startChat(startChatOptionalParams);
124
133
  isStartChatSuccessful = true;
125
134
  } catch (error) {
126
135
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
@@ -173,6 +182,11 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
173
182
  // Set app state to Active
174
183
  if (isStartChatSuccessful) {
175
184
  ActivityStreamHandler.uncork();
185
+ // Update start chat failure app state if chat loads successfully
186
+ dispatch({
187
+ type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
188
+ payload: false
189
+ });
176
190
  dispatch({
177
191
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
178
192
  payload: ConversationState.Active
@@ -203,25 +217,53 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
203
217
  });
204
218
  return;
205
219
  }
220
+ if (!hideErrorUIPane) {
221
+ // Set app state to failing start chat if hideErrorUI is not turned on
222
+ dispatch({
223
+ type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
224
+ payload: true
225
+ });
226
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
227
+ Event: TelemetryEvent.ErrorUIPaneLoaded,
228
+ Description: "Error UI Pane Loaded"
229
+ });
230
+ }
206
231
  // Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
207
232
  dispatch({
208
233
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
209
234
  payload: ConversationState.Loading
210
235
  });
236
+
237
+ // If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
238
+ // we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
239
+ if (isStartChatSuccessful === true) {
240
+ await forceEndChat(chatSDK);
241
+ }
211
242
  } finally {
212
243
  optionalParams = {};
213
244
  widgetInstanceId = "";
214
245
  }
215
246
  };
216
247
 
248
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
249
+ const forceEndChat = async chatSDK => {
250
+ TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
251
+ Event: TelemetryEvent.WidgetLoadFailed,
252
+ ExceptionDetails: {
253
+ Exception: "SessionInit was successful, but widget load failed."
254
+ }
255
+ });
256
+ chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
257
+ };
258
+
217
259
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
218
260
  const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
219
- var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps2, _persistedState$domai6, _persistedState$appSt;
261
+ var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps3, _persistedState$domai6, _persistedState$appSt;
220
262
  // By pass this function in case of popout chat
221
263
  if (state.appStates.hideStartChatButton === true) {
222
264
  return false;
223
265
  }
224
- const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
266
+ const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.widgetInstanceId) ?? "");
225
267
 
226
268
  //Connect to only active chat session
227
269
  if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === ConversationState.Active) {
@@ -233,7 +275,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
233
275
  const optionalParams = {
234
276
  liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
235
277
  };
236
- await initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
278
+ await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
237
279
  return true;
238
280
  } else {
239
281
  return false;
@@ -281,11 +323,29 @@ const handleAuthenticationIfEnabled = async (chatSDK, props) => {
281
323
  };
282
324
 
283
325
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
284
- const checkIfConversationStillValid = async (chatSDK, props, requestId) => {
326
+ const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch) => {
285
327
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
286
328
  let conversationDetails = undefined;
329
+
330
+ // Show Loading screen during auth check and start chat calls
331
+ dispatch({
332
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
333
+ payload: ConversationState.Loading
334
+ });
287
335
  const authSucceed = await handleAuthenticationIfEnabled(chatSDK, props);
288
336
  if (!authSucceed) {
337
+ var _props$controlProps4;
338
+ if (!(props !== null && props !== void 0 && (_props$controlProps4 = props.controlProps) !== null && _props$controlProps4 !== void 0 && _props$controlProps4.hideErrorUIPane)) {
339
+ // Set app state to failing start chat if hideErrorUI is not turned on
340
+ dispatch({
341
+ type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
342
+ payload: true
343
+ });
344
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
345
+ Event: TelemetryEvent.ErrorUIPaneLoaded,
346
+ Description: "Error UI Pane Loaded"
347
+ });
348
+ }
289
349
  return false;
290
350
  }
291
351