@microsoft/omnichannel-chat-widget 1.1.1-main.45472ff → 1.1.1-main.75135c5

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 (61) hide show
  1. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +20 -15
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
  3. package/lib/cjs/common/telemetry/TelemetryHelper.js +9 -0
  4. package/lib/cjs/components/draggable/DraggableChatWidget.js +168 -0
  5. package/lib/cjs/components/draggable/DraggableEventEmitter.js +74 -0
  6. package/lib/cjs/components/draggable/DraggableEventNames.js +14 -0
  7. package/lib/cjs/components/draggable/DraggableEventReceiver.js +34 -0
  8. package/lib/cjs/components/draggable/IDraggableElementPosition.js +1 -0
  9. package/lib/cjs/components/draggable/IDraggableElementPositionDelta.js +1 -0
  10. package/lib/cjs/components/draggable/IDraggableEvent.js +1 -0
  11. package/lib/cjs/components/headerstateful/HeaderStateful.js +27 -0
  12. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -3
  13. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
  14. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +15 -5
  15. package/lib/cjs/components/livechatwidget/interfaces/IDraggableChatWidgetProps.js +1 -0
  16. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -8
  17. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +41 -14
  18. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  19. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +1 -0
  20. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +5 -0
  21. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
  22. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +18 -14
  23. package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
  24. package/lib/esm/common/telemetry/TelemetryHelper.js +9 -0
  25. package/lib/esm/components/draggable/DraggableChatWidget.js +158 -0
  26. package/lib/esm/components/draggable/DraggableEventEmitter.js +64 -0
  27. package/lib/esm/components/draggable/DraggableEventNames.js +7 -0
  28. package/lib/esm/components/draggable/DraggableEventReceiver.js +25 -0
  29. package/lib/esm/components/draggable/IDraggableElementPosition.js +1 -0
  30. package/lib/esm/components/draggable/IDraggableElementPositionDelta.js +1 -0
  31. package/lib/esm/components/draggable/IDraggableEvent.js +1 -0
  32. package/lib/esm/components/headerstateful/HeaderStateful.js +27 -0
  33. package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
  34. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
  35. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +15 -5
  36. package/lib/esm/components/livechatwidget/interfaces/IDraggableChatWidgetProps.js +1 -0
  37. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -8
  38. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +41 -14
  39. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  40. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +1 -0
  41. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +5 -0
  42. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
  43. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -0
  44. package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -0
  45. package/lib/types/components/draggable/DraggableChatWidget.d.ts +9 -0
  46. package/lib/types/components/draggable/DraggableEventEmitter.d.ts +27 -0
  47. package/lib/types/components/draggable/DraggableEventNames.d.ts +6 -0
  48. package/lib/types/components/draggable/DraggableEventReceiver.d.ts +27 -0
  49. package/lib/types/components/draggable/IDraggableElementPosition.d.ts +5 -0
  50. package/lib/types/components/draggable/IDraggableElementPositionDelta.d.ts +5 -0
  51. package/lib/types/components/draggable/IDraggableEvent.d.ts +12 -0
  52. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +12 -0
  53. package/lib/types/components/livechatwidget/interfaces/IDraggableChatWidgetProps.d.ts +10 -0
  54. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  55. package/lib/types/components/webchatcontainerstateful/WebChatContainerStateful.d.ts +2 -2
  56. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +5 -0
  57. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
  58. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
  59. package/lib/types/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.d.ts +2 -1
  60. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
  61. package/package.json +3 -3
@@ -12,6 +12,7 @@ var _react = require("@fluentui/react");
12
12
  var _react2 = _interopRequireWildcard(require("react"));
13
13
  var _startChat = require("../common/startChat");
14
14
  var _utils = require("../../../common/utils");
15
+ var _defaultClientDataStoreProvider = require("../../../common/storage/default/defaultClientDataStoreProvider");
15
16
  var _endChat = require("../common/endChat");
16
17
  var _reconnectChatHelper = require("../common/reconnectChatHelper");
17
18
  var _componentController = require("../../../controller/componentController");
@@ -20,8 +21,8 @@ var _CallingContainerStateful = _interopRequireDefault(require("../../callingcon
20
21
  var _ChatButtonStateful = _interopRequireDefault(require("../../chatbuttonstateful/ChatButtonStateful"));
21
22
  var _ConfirmationPaneStateful = _interopRequireDefault(require("../../confirmationpanestateful/ConfirmationPaneStateful"));
22
23
  var _ConversationState = require("../../../contexts/common/ConversationState");
23
- var _createDownloadTranscriptProps = _interopRequireDefault(require("../common/createDownloadTranscriptProps"));
24
24
  var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
25
+ var _DraggableChatWidget = _interopRequireDefault(require("../../draggable/DraggableChatWidget"));
25
26
  var _EmailTranscriptPaneStateful = _interopRequireDefault(require("../../emailtranscriptpanestateful/EmailTranscriptPaneStateful"));
26
27
  var _HeaderStateful = _interopRequireDefault(require("../../headerstateful/HeaderStateful"));
27
28
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
@@ -35,9 +36,9 @@ var _ReconnectChatPaneStateful = _interopRequireDefault(require("../../reconnect
35
36
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
36
37
  var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
37
38
  var _WebChatContainerStateful = _interopRequireDefault(require("../../webchatcontainerstateful/WebChatContainerStateful"));
39
+ var _createDownloadTranscriptProps = _interopRequireDefault(require("../common/createDownloadTranscriptProps"));
38
40
  var _createFooter = require("../common/createFooter");
39
41
  var _createInternetConnectionChangeHandler = require("../common/createInternetConnectionChangeHandler");
40
- var _defaultClientDataStoreProvider = require("../../../common/storage/default/defaultClientDataStoreProvider");
41
42
  var _defaultScrollBarProps = require("../common/defaultProps/defaultScrollBarProps");
42
43
  var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
43
44
  var _disposeTelemetryLoggers = require("../common/disposeTelemetryLoggers");
@@ -58,7 +59,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
58
59
  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; }
59
60
  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); }
60
61
  const LiveChatWidgetStateful = props => {
61
- var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$contro10, _livechatProps$compon8, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$compon11, _livechatProps$compon12;
62
+ var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps11, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$contro10, _livechatProps$compon8, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$compon11, _livechatProps$compon12;
62
63
  const [state, dispatch] = (0, _useChatContextStore.default)();
63
64
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
65
  const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
@@ -433,6 +434,9 @@ const LiveChatWidgetStateful = props => {
433
434
  payload: undefined
434
435
  });
435
436
  });
437
+
438
+ // Check for TPC and log in telemetry if blocked
439
+ (0, _defaultClientDataStoreProvider.isCookieAllowed)();
436
440
  return () => {
437
441
  (0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
438
442
  };
@@ -617,6 +621,22 @@ const LiveChatWidgetStateful = props => {
617
621
  ...props,
618
622
  downloadTranscriptProps
619
623
  };
624
+ const chatWidgetDraggableConfig = {
625
+ elementId: widgetElementId,
626
+ channel: ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "lcw",
627
+ disabled: ((_props$draggableChatW = props.draggableChatWidgetProps) === null || _props$draggableChatW === void 0 ? void 0 : _props$draggableChatW.disabled) === true ?? false // Draggable by default, unless explicitly disabled
628
+ };
629
+
630
+ // Disable receiving IDraggableEvent in current window
631
+ if (((_props$draggableChatW2 = props.draggableChatWidgetProps) === null || _props$draggableChatW2 === void 0 ? void 0 : _props$draggableChatW2.disabled) === false && (_props$draggableChatW3 = props.draggableChatWidgetProps) !== null && _props$draggableChatW3 !== void 0 && _props$draggableChatW3.targetIframe) {
632
+ chatWidgetDraggableConfig.disabled = true;
633
+ }
634
+ const headerDraggableConfig = {
635
+ draggableEventChannel: chatWidgetDraggableConfig.channel ?? "lcw",
636
+ draggableEventEmitterTargetWindow: (_props$draggableChatW4 = props.draggableChatWidgetProps) !== null && _props$draggableChatW4 !== void 0 && _props$draggableChatW4.targetIframe ? window.parent : window,
637
+ draggable: ((_props$draggableChatW5 = props.draggableChatWidgetProps) === null || _props$draggableChatW5 === void 0 ? void 0 : _props$draggableChatW5.disabled) !== true // Draggable by default, unless explicitly disabled
638
+ };
639
+
620
640
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
621
641
  ::-webkit-scrollbar {
622
642
  width: ${scrollbarProps.width};
@@ -634,7 +654,7 @@ const LiveChatWidgetStateful = props => {
634
654
  ::-webkit-scrollbar-thumb:hover {
635
655
  background: ${scrollbarProps.thumbHoverColor};
636
656
  }
637
- `), /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
657
+ `), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
638
658
  styleOptions: webChatStyles,
639
659
  directLine: ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
640
660
  }), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
@@ -648,11 +668,11 @@ const LiveChatWidgetStateful = props => {
648
668
  })), !((_livechatProps$contro3 = livechatProps.controlProps) !== null && _livechatProps$contro3 !== void 0 && _livechatProps$contro3.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon2 = livechatProps.componentOverrides) === null || _livechatProps$compon2 === void 0 ? void 0 : _livechatProps$compon2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
649
669
  proactiveChatProps: livechatProps.proactiveChatPaneProps,
650
670
  startChat: prepareStartChatRelay
651
- })), !((_livechatProps$contro4 = livechatProps.controlProps) !== null && _livechatProps$contro4 !== void 0 && _livechatProps$contro4.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon3 = livechatProps.componentOverrides) === null || _livechatProps$compon3 === void 0 ? void 0 : _livechatProps$compon3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
671
+ })), !((_livechatProps$contro4 = livechatProps.controlProps) !== null && _livechatProps$contro4 !== void 0 && _livechatProps$contro4.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon3 = livechatProps.componentOverrides) === null || _livechatProps$compon3 === void 0 ? void 0 : _livechatProps$compon3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, _extends({
652
672
  headerProps: livechatProps.headerProps,
653
673
  outOfOfficeHeaderProps: livechatProps.outOfOfficeHeaderProps,
654
674
  endChat: endChatRelay
655
- })), !((_livechatProps$contro5 = livechatProps.controlProps) !== null && _livechatProps$contro5 !== void 0 && _livechatProps$contro5.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon4 = livechatProps.componentOverrides) === null || _livechatProps$compon4 === void 0 ? void 0 : _livechatProps$compon4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, {
675
+ }, headerDraggableConfig))), !((_livechatProps$contro5 = livechatProps.controlProps) !== null && _livechatProps$contro5 !== void 0 && _livechatProps$contro5.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon4 = livechatProps.componentOverrides) === null || _livechatProps$compon4 === void 0 ? void 0 : _livechatProps$compon4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, {
656
676
  loadingPaneProps: livechatProps.loadingPaneProps,
657
677
  startChatErrorPaneProps: livechatProps.startChatErrorPaneProps
658
678
  })), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon5 = livechatProps.componentOverrides) === null || _livechatProps$compon5 === void 0 ? void 0 : _livechatProps$compon5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, livechatProps.outOfOfficeHoursPaneProps)), !((_livechatProps$contro7 = livechatProps.controlProps) !== null && _livechatProps$contro7 !== void 0 && _livechatProps$contro7.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon6 = livechatProps.componentOverrides) === null || _livechatProps$compon6 === void 0 ? void 0 : _livechatProps$compon6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
@@ -663,10 +683,10 @@ const LiveChatWidgetStateful = props => {
663
683
  initStartChat: initStartChatRelay
664
684
  })), !((_livechatProps$contro9 = livechatProps.controlProps) !== null && _livechatProps$contro9 !== void 0 && _livechatProps$contro9.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
665
685
  voiceVideoCallingSdk: voiceVideoCallingSDK
666
- }, livechatProps.callingContainerProps)), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon8 = livechatProps.componentOverrides) === null || _livechatProps$compon8 === void 0 ? void 0 : _livechatProps$compon8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, livechatProps.webChatContainerProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
686
+ }, livechatProps.callingContainerProps)), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon8 = livechatProps.componentOverrides) === null || _livechatProps$compon8 === void 0 ? void 0 : _livechatProps$compon8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, livechatProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
667
687
  setPostChatContext: setPostChatContextRelay,
668
688
  prepareEndChat: prepareEndChatRelay
669
- }))), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, livechatProps.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), (0, _createFooter.createFooter)(livechatProps, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, livechatProps.emailTranscriptPane)))));
689
+ }))), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, livechatProps.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), (0, _createFooter.createFooter)(livechatProps, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, livechatProps.emailTranscriptPane))))));
670
690
  };
671
691
  exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
672
692
  var _default = LiveChatWidgetStateful;
@@ -12,20 +12,24 @@ var _broadcastChannel = require("broadcast-channel");
12
12
  var _botframeworkWebchat = require("botframework-webchat");
13
13
  var _Constants = require("../../common/Constants");
14
14
  var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
15
+ var _NotificationHandler = require("./webchatcontroller/notification/NotificationHandler");
16
+ var _NotificationScenarios = require("./webchatcontroller/enums/NotificationScenarios");
15
17
  var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
16
18
  var _WebChatActionType = require("./webchatcontroller/enums/WebChatActionType");
17
19
  var _WebChatStoreLoader = require("./webchatcontroller/WebChatStoreLoader");
18
20
  var _defaultAdaptiveCardStyles = require("./common/defaultStyles/defaultAdaptiveCardStyles");
19
21
  var _defaultMiddlewareLocalizedTexts = require("./common/defaultProps/defaultMiddlewareLocalizedTexts");
20
22
  var _defaultReceivedMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles");
23
+ var _defaultSentMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles");
21
24
  var _defaultSystemMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles");
22
25
  var _defaultUserMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles");
23
26
  var _defaultWebChatContainerStatefulProps = require("./common/defaultProps/defaultWebChatContainerStatefulProps");
24
27
  var _utils = require("../../common/utils");
25
28
  var _ = require("../..");
26
- var _defaultSentMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles");
27
29
  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); }
28
30
  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; }
31
+ /* eslint-disable @typescript-eslint/no-explicit-any */
32
+
29
33
  const broadcastChannelMessageEvent = "message";
30
34
  const postActivity = activity => {
31
35
  // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -52,28 +56,33 @@ const createMagicCodeSuccessResponse = signin => {
52
56
  };
53
57
  };
54
58
  const WebChatContainerStateful = props => {
55
- var _props$adaptiveCardSt, _props$renderingMiddl, _props$renderingMiddl2, _props$renderingMiddl3, _props$renderingMiddl4, _props$adaptiveCardSt2, _props$adaptiveCardSt3, _props$adaptiveCardSt4, _props$renderingMiddl5, _props$renderingMiddl6, _props$renderingMiddl7, _props$renderingMiddl8, _props$renderingMiddl9, _props$renderingMiddl10;
59
+ var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15;
56
60
  const {
57
61
  BasicWebChat
58
62
  } = _botframeworkWebchat.Components;
59
63
  const [state, dispatch] = (0, _.useChatContextStore)();
60
64
  const magicCodeBroadcastChannel = new _broadcastChannel.BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel);
61
65
  const magicCodeResponseBroadcastChannel = new _broadcastChannel.BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel);
66
+ const {
67
+ webChatContainerProps,
68
+ contextDataStore
69
+ } = props;
62
70
  const containerStyles = {
63
- root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, props === null || props === void 0 ? void 0 : props.containerStyles, {
71
+ root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
64
72
  display: state.appStates.isMinimized ? "none" : ""
65
73
  }) // Use this instead of removing WebChat from the picture so that the activity observer inside the adapter is not invoked
66
74
  };
67
75
 
68
76
  const localizedTexts = {
69
77
  ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
70
- ...(props === null || props === void 0 ? void 0 : props.localizedTexts)
78
+ ...(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.localizedTexts)
71
79
  };
72
80
  (0, _react2.useEffect)(() => {
81
+ var _props$webChatContain, _props$webChatContain2;
73
82
  (0, _utils.setFocusOnSendBox)();
74
83
  dispatch({
75
84
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
76
- payload: props === null || props === void 0 ? void 0 : props.renderingMiddlewareProps
85
+ payload: webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.renderingMiddlewareProps
77
86
  });
78
87
  dispatch({
79
88
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MIDDLEWARE_LOCALIZED_TEXTS,
@@ -82,6 +91,17 @@ const WebChatContainerStateful = props => {
82
91
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
83
92
  Event: _TelemetryConstants.TelemetryEvent.WebChatLoaded
84
93
  });
94
+ if (((_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.disableThirdPartyCookiesAlert) !== true && !contextDataStore) {
95
+ try {
96
+ localStorage;
97
+ sessionStorage;
98
+ } catch (error) {
99
+ if (!window.TPCWarningShown) {
100
+ _NotificationHandler.NotificationHandler.notifyWarning(_NotificationScenarios.NotificationScenarios.TPC, (localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE) ?? "");
101
+ window.TPCWarningShown = true;
102
+ }
103
+ }
104
+ }
85
105
  }, []);
86
106
  (0, _react2.useEffect)(() => {
87
107
  const eventListener = event => {
@@ -122,26 +142,33 @@ const WebChatContainerStateful = props => {
122
142
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
123
143
 
124
144
  .webchat__bubble__content>div#ms_lcw_webchat_adaptive_card {
125
- background: ${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt = props.adaptiveCardStyles) === null || _props$adaptiveCardSt === void 0 ? void 0 : _props$adaptiveCardSt.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background};
145
+ background: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp === void 0 ? void 0 : _webChatContainerProp.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background};
126
146
  }
127
147
 
128
148
  .webchat__stacked-layout__content div.webchat__stacked-layout__message-row div.webchat__bubble--from-user {
129
- max-width: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl = props.renderingMiddlewareProps) === null || _props$renderingMiddl === void 0 ? void 0 : (_props$renderingMiddl2 = _props$renderingMiddl.userMessageBoxStyles) === null || _props$renderingMiddl2 === void 0 ? void 0 : _props$renderingMiddl2.maxWidth) ?? (_defaultUserMessageBoxStyles.defaultUserMessageBoxStyles === null || _defaultUserMessageBoxStyles.defaultUserMessageBoxStyles === void 0 ? void 0 : _defaultUserMessageBoxStyles.defaultUserMessageBoxStyles.maxWidth)}
149
+ max-width: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp2 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp2 === void 0 ? void 0 : (_webChatContainerProp3 = _webChatContainerProp2.userMessageBoxStyles) === null || _webChatContainerProp3 === void 0 ? void 0 : _webChatContainerProp3.maxWidth) ?? (_defaultUserMessageBoxStyles.defaultUserMessageBoxStyles === null || _defaultUserMessageBoxStyles.defaultUserMessageBoxStyles === void 0 ? void 0 : _defaultUserMessageBoxStyles.defaultUserMessageBoxStyles.maxWidth)}
130
150
  }
131
151
 
132
152
  .webchat__stacked-layout--show-avatar div.webchat__stacked-layout__content div.webchat__stacked-layout__message-row div.webchat__stacked-layout__message {
133
- max-width: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl3 = props.renderingMiddlewareProps) === null || _props$renderingMiddl3 === void 0 ? void 0 : (_props$renderingMiddl4 = _props$renderingMiddl3.systemMessageBoxStyles) === null || _props$renderingMiddl4 === void 0 ? void 0 : _props$renderingMiddl4.maxWidth) ?? (_defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles === null || _defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles === void 0 ? void 0 : _defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles.maxWidth)}
153
+ max-width: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp4 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp4 === void 0 ? void 0 : (_webChatContainerProp5 = _webChatContainerProp4.systemMessageBoxStyles) === null || _webChatContainerProp5 === void 0 ? void 0 : _webChatContainerProp5.maxWidth) ?? (_defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles === null || _defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles === void 0 ? void 0 : _defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles.maxWidth)}
134
154
  }
135
155
 
136
- div[class="ac-textBlock"]>p{color:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt2 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt2 === void 0 ? void 0 : _props$adaptiveCardSt2.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color}; white-space:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt3 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt3 === void 0 ? void 0 : _props$adaptiveCardSt3.textWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.textWhiteSpace}}
137
-
138
- .webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt4 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt4 === void 0 ? void 0 : _props$adaptiveCardSt4.buttonWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
156
+ div[class="ac-textBlock"] *,
157
+ div[class="ac-input-container"] * {color:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp6 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp6 === void 0 ? void 0 : _webChatContainerProp6.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color}; white-space:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp7 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp7 === void 0 ? void 0 : _webChatContainerProp7.textWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.textWhiteSpace}}
158
+ div[class="ac-textBlock"] a:link,
159
+ div[class="ac-textBlock"] a:visited,
160
+ div[class="ac-textBlock"] a:hover,
161
+ div[class="ac-textBlock"] a:active {
162
+ color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp8 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp8 === void 0 ? void 0 : _webChatContainerProp8.anchorColor) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.anchorColor};
163
+ }
164
+
165
+ .webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp9 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp9 === void 0 ? void 0 : _webChatContainerProp9.buttonWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
139
166
 
140
167
  .ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
141
168
  background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
142
169
  height: '.75em';
143
170
  marginLeft: '.25em';
144
- filter:${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl5 = props.renderingMiddlewareProps) === null || _props$renderingMiddl5 === void 0 ? void 0 : (_props$renderingMiddl6 = _props$renderingMiddl5.receivedMessageAnchorStyles) === null || _props$renderingMiddl6 === void 0 ? void 0 : _props$renderingMiddl6.filter) ?? "none"};
171
+ filter:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp10 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp10 === void 0 ? void 0 : (_webChatContainerProp11 = _webChatContainerProp10.receivedMessageAnchorStyles) === null || _webChatContainerProp11 === void 0 ? void 0 : _webChatContainerProp11.filter) ?? "none"};
145
172
  }
146
173
  pre {
147
174
  white-space: pre-wrap;
@@ -154,13 +181,13 @@ const WebChatContainerStateful = props => {
154
181
  .ms_lcw_webchat_received_message a:visited,
155
182
  .ms_lcw_webchat_received_message a:hover,
156
183
  .ms_lcw_webchat_received_message a:active {
157
- color: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl7 = props.renderingMiddlewareProps) === null || _props$renderingMiddl7 === void 0 ? void 0 : (_props$renderingMiddl8 = _props$renderingMiddl7.receivedMessageAnchorStyles) === null || _props$renderingMiddl8 === void 0 ? void 0 : _props$renderingMiddl8.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
184
+ color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp12 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp12 === void 0 ? void 0 : (_webChatContainerProp13 = _webChatContainerProp12.receivedMessageAnchorStyles) === null || _webChatContainerProp13 === void 0 ? void 0 : _webChatContainerProp13.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
158
185
  }
159
186
  .ms_lcw_webchat_sent_message a:link,
160
187
  .ms_lcw_webchat_sent_message a:visited,
161
188
  .ms_lcw_webchat_sent_message a:hover,
162
189
  .ms_lcw_webchat_sent_message a:active {
163
- color: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl9 = props.renderingMiddlewareProps) === null || _props$renderingMiddl9 === void 0 ? void 0 : (_props$renderingMiddl10 = _props$renderingMiddl9.sentMessageAnchorStyles) === null || _props$renderingMiddl10 === void 0 ? void 0 : _props$renderingMiddl10.color) ?? (_defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === null || _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === void 0 ? void 0 : _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles.color)};
190
+ color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp14 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp14 === void 0 ? void 0 : (_webChatContainerProp15 = _webChatContainerProp14.sentMessageAnchorStyles) === null || _webChatContainerProp15 === void 0 ? void 0 : _webChatContainerProp15.color) ?? (_defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === null || _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === void 0 ? void 0 : _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles.color)};
164
191
  }
165
192
  `), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
166
193
  styles: containerStyles
@@ -30,6 +30,7 @@ const defaultMiddlewareLocalizedTexts = {
30
30
  MIDDLEWARE_MESSAGE_DELIVERED: "Sent",
31
31
  MIDDLEWARE_MESSAGE_NOT_DELIVERED: "Not Delivered",
32
32
  MIDDLEWARE_MESSAGE_RETRY: "Retry",
33
- MIDDLEWARE_BANNER_CHAT_DISCONNECT: "Your conversation has been disconnected. For additional assistance, please start a new chat."
33
+ MIDDLEWARE_BANNER_CHAT_DISCONNECT: "Your conversation has been disconnected. For additional assistance, please start a new chat.",
34
+ THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Third party cookies are blocked. Reloading this page will start a new conversation."
34
35
  };
35
36
  exports.defaultMiddlewareLocalizedTexts = defaultMiddlewareLocalizedTexts;
@@ -7,6 +7,7 @@ exports.defaultAdaptiveCardStyles = void 0;
7
7
  const defaultAdaptiveCardStyles = {
8
8
  background: "white",
9
9
  color: "black",
10
+ anchorColor: "blue",
10
11
  textWhiteSpace: "normal",
11
12
  buttonWhiteSpace: "normal"
12
13
  };
@@ -15,6 +15,11 @@ class MockChatSDK {
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  _defineProperty(this, "sleep", ms => new Promise(r => setTimeout(r, ms)));
17
17
  _defineProperty(this, "isMockModeOn", true);
18
+ _defineProperty(this, "omnichannelConfig", {
19
+ widgetId: "00000000-0000-0000-0000-000000000000",
20
+ orgId: "00000000-0000-0000-0000-000000000000",
21
+ orgUrl: "https://contoso.crm.dynamics.com"
22
+ });
18
23
  }
19
24
  async startChat() {
20
25
  await this.sleep(1000);
@@ -14,4 +14,5 @@ exports.NotificationScenarios = NotificationScenarios;
14
14
  NotificationScenarios["InternetConnection"] = "internet connection";
15
15
  NotificationScenarios["MaxSizeError"] = "max size";
16
16
  NotificationScenarios["ChatDisconnect"] = "chat disconnect";
17
+ NotificationScenarios["TPC"] = "tpc blocked";
17
18
  })(NotificationScenarios || (exports.NotificationScenarios = NotificationScenarios = {}));
@@ -1,26 +1,30 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
 
3
3
  import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
4
+ import { StorageType } from "../../Constants";
4
5
  import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
5
6
  import { inMemoryDataStore } from "./defaultInMemoryDataStore";
6
- import { StorageType } from "../../Constants";
7
+ export const isCookieAllowed = () => {
8
+ try {
9
+ localStorage;
10
+ sessionStorage;
11
+ return true;
12
+ } catch (error) {
13
+ if (!window.TPCWarningLogged) {
14
+ console.warn("Third party cookies blocked.");
15
+ TelemetryHelper.logActionEvent(LogLevel.WARN, {
16
+ Event: TelemetryEvent.ThirdPartyCookiesBlocked,
17
+ Description: "Third party cookies are blocked. Cannot access local storage or session storage."
18
+ });
19
+ window.TPCWarningLogged = true;
20
+ }
21
+ return false;
22
+ }
23
+ };
7
24
  export const defaultClientDataStoreProvider = function () {
8
25
  let cacheTtlinMins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
9
26
  let storageType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : StorageType.localStorage;
10
27
  let ttlInMs = 0;
11
- const isCookieAllowed = () => {
12
- try {
13
- localStorage;
14
- sessionStorage;
15
- return true;
16
- } catch (error) {
17
- if (!window.TPCWarningShown) {
18
- console.warn("Third party cookies blocked.");
19
- window.TPCWarningShown = true;
20
- }
21
- return false;
22
- }
23
- };
24
28
  if (ttlInMs == 0) {
25
29
  ttlInMs = cacheTtlinMins * 60 * 1000;
26
30
  }
@@ -158,6 +158,7 @@ export let TelemetryEvent;
158
158
  TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
159
159
  TelemetryEvent["SetBotAuthProviderDisplayCard"] = "SetBotAuthProviderDisplayCard";
160
160
  TelemetryEvent["SetBotAuthProviderNotFound"] = "SetBotAuthProviderNotFound";
161
+ TelemetryEvent["ThirdPartyCookiesBlocked"] = "ThirdPartyCookiesBlocked";
161
162
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
162
163
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
163
164
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -225,6 +226,7 @@ export class TelemetryConstants {
225
226
  case TelemetryEvent.OutOfOfficePaneLoaded:
226
227
  case TelemetryEvent.ConfirmationPaneLoaded:
227
228
  case TelemetryEvent.ProactiveChatPaneLoaded:
229
+ case TelemetryEvent.ThirdPartyCookiesBlocked:
228
230
  return ScenarioType.LOAD;
229
231
  case TelemetryEvent.PrechatSubmitted:
230
232
  case TelemetryEvent.LCWChatButtonClicked:
@@ -161,6 +161,15 @@ export class TelemetryHelper {
161
161
  }
162
162
  static addWidgetDataToTelemetry(telemetryConfig, telemetryInternalData) {
163
163
  const telemetryDataLocal = telemetryInternalData;
164
+ if (!(telemetryConfig !== null && telemetryConfig !== void 0 && telemetryConfig.appId) || (telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.appId.trim()) === "") {
165
+ throw new Error("TelemetryConfig.appId is not set");
166
+ }
167
+ if (!(telemetryConfig !== null && telemetryConfig !== void 0 && telemetryConfig.orgId) || (telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgId.trim()) === "") {
168
+ throw new Error("TelemetryConfig.orgId is not set");
169
+ }
170
+ if (!(telemetryConfig !== null && telemetryConfig !== void 0 && telemetryConfig.orgUrl) || (telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgUrl.trim()) === "") {
171
+ throw new Error("TelemetryConfig.orgUrl is not set");
172
+ }
164
173
  telemetryDataLocal.widgetId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.appId;
165
174
  telemetryDataLocal.orgId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgId;
166
175
  telemetryDataLocal.orgUrl = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgUrl;
@@ -0,0 +1,158 @@
1
+ import React, { useCallback, useEffect, useState } from "react";
2
+ import DraggableEventReceiver from "./DraggableEventReceiver";
3
+ import DraggableEventNames from "./DraggableEventNames";
4
+ import useChatContextStore from "../../hooks/useChatContextStore";
5
+ import { ConversationState } from "../../contexts/common/ConversationState";
6
+ import { isNullOrUndefined } from "../../common/utils";
7
+ const DraggableChatWidget = props => {
8
+ const [state] = useChatContextStore();
9
+ const [initialPosition, setInitialPosition] = useState({
10
+ offsetLeft: 0,
11
+ offsetTop: 0
12
+ });
13
+ const [cachedPosition, setCachedPosition] = useState(undefined);
14
+ const [position, setPosition] = useState({
15
+ offsetLeft: 0,
16
+ offsetTop: 0
17
+ });
18
+ const [delta, setDelta] = useState({
19
+ left: 0,
20
+ top: 0
21
+ });
22
+ const repositionElement = (draggableElement, offsetLeft, offsetTop) => {
23
+ draggableElement.style.left = `${offsetLeft}px`;
24
+ draggableElement.style.top = `${offsetTop}px`;
25
+ };
26
+ const calculateOffsetsWithinViewport = useCallback((id, offset, delta) => {
27
+ const draggableElement = document.getElementById(id);
28
+ const positionRelativeToViewport = draggableElement.getBoundingClientRect();
29
+ if (isNullOrUndefined(draggableElement) || isNullOrUndefined(positionRelativeToViewport) || isNullOrUndefined(offset.offsetLeft) || isNullOrUndefined(offset.offsetTop)) {
30
+ return;
31
+ }
32
+ let offsetLeft = offset.offsetLeft;
33
+ let offsetTop = offset.offsetTop;
34
+
35
+ // Widget size larger than viewport would not have any restriction
36
+ if (positionRelativeToViewport.width > window.innerWidth) {
37
+ return;
38
+ }
39
+ if (positionRelativeToViewport.height > window.innerHeight) {
40
+ return;
41
+ }
42
+
43
+ // Ensures widget is within viewport
44
+ if (positionRelativeToViewport.x < 0) {
45
+ offsetLeft = 0 - delta.left;
46
+ }
47
+ if (positionRelativeToViewport.y < 0) {
48
+ offsetTop = 0 - delta.top;
49
+ }
50
+ if (positionRelativeToViewport.x + positionRelativeToViewport.width > window.innerWidth) {
51
+ offsetLeft = window.innerWidth - positionRelativeToViewport.width - delta.left;
52
+ }
53
+ if (positionRelativeToViewport.y + positionRelativeToViewport.height > window.innerHeight) {
54
+ offsetTop = window.innerHeight - positionRelativeToViewport.height - delta.top;
55
+ }
56
+ repositionElement(draggableElement, offsetLeft, offsetTop);
57
+ setPosition({
58
+ offsetLeft,
59
+ offsetTop
60
+ });
61
+ }, []);
62
+ const resetPosition = useCallback(targetPosition => {
63
+ calculateOffsetsWithinViewport(props.elementId, targetPosition, delta); // Ensure viewport restriction
64
+ }, [delta]);
65
+ useEffect(() => {
66
+ if (props.disabled === true) {
67
+ return;
68
+ }
69
+ const cacheInitialPosition = () => {
70
+ const draggableElement = document.getElementById(props.elementId);
71
+ const offsetLeft = draggableElement.offsetLeft;
72
+ const offsetTop = draggableElement.offsetTop;
73
+ setInitialPosition({
74
+ offsetLeft,
75
+ offsetTop
76
+ });
77
+ };
78
+ const calculateOffsets = () => {
79
+ const draggableElement = document.getElementById(props.elementId);
80
+ const offsetLeft = draggableElement.offsetLeft;
81
+ const offsetTop = draggableElement.offsetTop;
82
+
83
+ // Calculates the delta between the position of the widget and the position of the widget relative to the viewport which will be used for repositioning
84
+ const positionRelativeToViewport = draggableElement.getBoundingClientRect();
85
+ const left = positionRelativeToViewport.left - offsetLeft;
86
+ const top = positionRelativeToViewport.top - offsetTop;
87
+ setDelta({
88
+ left,
89
+ top
90
+ });
91
+ calculateOffsetsWithinViewport(props.elementId, {
92
+ offsetLeft,
93
+ offsetTop
94
+ }, {
95
+ left,
96
+ top
97
+ });
98
+ };
99
+ calculateOffsets();
100
+ cacheInitialPosition();
101
+ window.addEventListener("resize", calculateOffsets);
102
+ return () => {
103
+ window.removeEventListener("resize", calculateOffsets);
104
+ };
105
+ }, [props.disabled]);
106
+ useEffect(() => {
107
+ if (props.disabled === true) {
108
+ return;
109
+ }
110
+ if (state.appStates.conversationState == ConversationState.Closed) {
111
+ resetPosition(initialPosition);
112
+ } else if (state.appStates.isMinimized) {
113
+ const draggableElement = document.getElementById(props.elementId);
114
+ const offsetLeft = draggableElement.offsetLeft;
115
+ const offsetTop = draggableElement.offsetTop;
116
+ if (!cachedPosition) {
117
+ setCachedPosition({
118
+ offsetLeft,
119
+ offsetTop
120
+ });
121
+ }
122
+ resetPosition(initialPosition);
123
+ } else if (!isNullOrUndefined(state.appStates.isMinimized) && !state.appStates.isMinimized) {
124
+ if (cachedPosition) {
125
+ resetPosition(cachedPosition);
126
+ setCachedPosition(undefined);
127
+ }
128
+ }
129
+ }, [props.disabled, state.appStates.isMinimized, state.appStates.conversationState, initialPosition, cachedPosition]);
130
+ const onEvent = useCallback(event => {
131
+ if (event.eventName === DraggableEventNames.Dragging) {
132
+ if (event.offset) {
133
+ const offsetLeft = position.offsetLeft + event.offset.x;
134
+ const offsetTop = position.offsetTop + event.offset.y;
135
+
136
+ // Update position via DOM manipulation to prevent <Stack/> continuously rendering on style change causing high CPU spike
137
+ const draggableElement = document.getElementById(props.elementId);
138
+ repositionElement(draggableElement, offsetLeft, offsetTop);
139
+ setPosition({
140
+ offsetLeft,
141
+ offsetTop
142
+ });
143
+ calculateOffsetsWithinViewport(props.elementId, {
144
+ offsetLeft,
145
+ offsetTop
146
+ }, delta);
147
+ }
148
+ }
149
+ }, [position, delta]);
150
+ if (props.disabled === true) {
151
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
152
+ }
153
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DraggableEventReceiver, {
154
+ channel: props.channel ?? "lcw",
155
+ onEvent: onEvent
156
+ }, props.children));
157
+ };
158
+ export default DraggableChatWidget;
@@ -0,0 +1,64 @@
1
+ import React, { useCallback, useEffect, useState } from "react";
2
+ import DraggableEventNames from "./DraggableEventNames";
3
+ /**
4
+ * Trigger component which would send IDraggableEvent to the receiver to update the draggable component position
5
+ *
6
+ * @param props IDraggableEventEmitterProps
7
+ * @returns
8
+ */
9
+ const DraggableEventEmitter = props => {
10
+ const [initialized, setInitialized] = useState(false);
11
+ const postMessage = useCallback(data => {
12
+ const targetWindow = props.targetWindow ?? window;
13
+ targetWindow.postMessage(data, "*");
14
+ }, [props.targetWindow]);
15
+ const dragStart = useCallback(event => {
16
+ postMessage({
17
+ channel: props.channel,
18
+ eventName: DraggableEventNames.DragStart
19
+ });
20
+ let cursor = {
21
+ x: event.screenX,
22
+ y: event.screenY
23
+ }; // Cursor init position
24
+ const dragging = event => {
25
+ event.preventDefault();
26
+ const newX = event.screenX;
27
+ const newY = event.screenY;
28
+ const offset = {
29
+ x: newX - cursor.x,
30
+ y: newY - cursor.y
31
+ }; // Calculate cursor position diff
32
+ cursor = {
33
+ ...cursor,
34
+ x: newX,
35
+ y: newY
36
+ }; // Update cursor new position
37
+
38
+ postMessage({
39
+ channel: props.channel,
40
+ eventName: DraggableEventNames.Dragging,
41
+ offset
42
+ });
43
+ };
44
+ const dragEnd = () => {
45
+ postMessage({
46
+ channel: props.channel,
47
+ eventName: DraggableEventNames.DragEnd
48
+ });
49
+ document.removeEventListener("mousemove", dragging);
50
+ document.removeEventListener("mouseup", dragEnd);
51
+ };
52
+ document.addEventListener("mousemove", dragging);
53
+ document.addEventListener("mouseup", dragEnd);
54
+ }, [props.channel]);
55
+ useEffect(() => {
56
+ if (!initialized && props.elementId) {
57
+ const element = document.getElementById(props.elementId);
58
+ element === null || element === void 0 ? void 0 : element.addEventListener("mousedown", dragStart);
59
+ setInitialized(true);
60
+ }
61
+ }, [dragStart, props.elementId, initialized]);
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, " ", props.children, " ");
63
+ };
64
+ export default DraggableEventEmitter;
@@ -0,0 +1,7 @@
1
+ var DraggableEventNames;
2
+ (function (DraggableEventNames) {
3
+ DraggableEventNames["DragStart"] = "DragStart";
4
+ DraggableEventNames["Dragging"] = "Dragging";
5
+ DraggableEventNames["DragEnd"] = "DragEnd";
6
+ })(DraggableEventNames || (DraggableEventNames = {}));
7
+ export default DraggableEventNames;