@microsoft/omnichannel-chat-widget 1.7.6-main.dca3f60 → 1.7.7-main.37d9c4a

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 (44) hide show
  1. package/lib/cjs/common/Constants.js +3 -0
  2. package/lib/cjs/common/facades/FacadeChatSDK.js +76 -21
  3. package/lib/cjs/common/utils.js +14 -2
  4. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -0
  5. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +3 -2
  6. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +4 -3
  7. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +27 -22
  8. package/lib/cjs/components/livechatwidget/interfaces/IFeatureConfigProps.js +1 -0
  9. package/lib/cjs/components/livechatwidget/interfaces/ISendBox.js +1 -0
  10. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -13
  11. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +10 -5
  12. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +13 -1
  13. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -0
  14. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +3 -1
  15. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +15 -2
  16. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +8 -7
  17. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +3 -1
  18. package/lib/esm/common/Constants.js +3 -0
  19. package/lib/esm/common/facades/FacadeChatSDK.js +76 -21
  20. package/lib/esm/common/utils.js +11 -1
  21. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -0
  22. package/lib/esm/components/livechatwidget/LiveChatWidget.js +3 -2
  23. package/lib/esm/components/livechatwidget/common/createMarkdown.js +4 -3
  24. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +28 -22
  25. package/lib/esm/components/livechatwidget/interfaces/IFeatureConfigProps.js +1 -0
  26. package/lib/esm/components/livechatwidget/interfaces/ISendBox.js +1 -0
  27. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -13
  28. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +10 -5
  29. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +15 -3
  30. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -0
  31. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +3 -1
  32. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +15 -2
  33. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +8 -7
  34. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +3 -1
  35. package/lib/types/common/Constants.d.ts +3 -0
  36. package/lib/types/common/facades/FacadeChatSDK.d.ts +5 -2
  37. package/lib/types/common/utils.d.ts +1 -0
  38. package/lib/types/components/livechatwidget/common/createMarkdown.d.ts +1 -1
  39. package/lib/types/components/livechatwidget/interfaces/IFeatureConfigProps.d.ts +3 -0
  40. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +9 -7
  41. package/lib/types/components/livechatwidget/interfaces/ISendBox.d.ts +12 -0
  42. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +5 -0
  43. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +1 -1
  44. package/package.json +2 -2
@@ -99,6 +99,8 @@ _defineProperty(Constants, "Zero", "zero");
99
99
  _defineProperty(Constants, "Title", "title");
100
100
  _defineProperty(Constants, "Target", "target");
101
101
  _defineProperty(Constants, "Blank", "_blank");
102
+ _defineProperty(Constants, "TargetSelf", "_self");
103
+ _defineProperty(Constants, "TargetTop", "_top");
102
104
  _defineProperty(Constants, "TargetRelationship", "rel");
103
105
  _defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer");
104
106
  // Markdown icons
@@ -130,6 +132,7 @@ class HtmlClassNames {}
130
132
  exports.HtmlClassNames = HtmlClassNames;
131
133
  _defineProperty(HtmlClassNames, "webChatBannerCloseButton", "webchat__toast__dismissButton");
132
134
  _defineProperty(HtmlClassNames, "webChatBannerExpandButton", "webchat__toaster__expandIcon");
135
+ _defineProperty(HtmlClassNames, "webChatHistoryContainer", "webchat__basic-transcript");
133
136
  class HtmlElementSelectors {}
134
137
  exports.HtmlElementSelectors = HtmlElementSelectors;
135
138
  _defineProperty(HtmlElementSelectors, "sendBoxSelector", "textarea[data-id=\"webchat-sendbox-input\"]");
@@ -26,7 +26,7 @@ class FacadeChatSDK {
26
26
  isTokenSet() {
27
27
  return !(0, _utils.isNullOrEmptyString)(this.token);
28
28
  }
29
- constructor(input) {
29
+ constructor(input, disableReauthentication) {
30
30
  _defineProperty(this, "chatSDK", void 0);
31
31
  _defineProperty(this, "chatConfig", void 0);
32
32
  _defineProperty(this, "token", "");
@@ -34,11 +34,13 @@ class FacadeChatSDK {
34
34
  _defineProperty(this, "isAuthenticated", void 0);
35
35
  _defineProperty(this, "getAuthToken", void 0);
36
36
  _defineProperty(this, "sdkMocked", void 0);
37
+ _defineProperty(this, "disableReauthentication", void 0);
37
38
  this.chatSDK = input.chatSDK;
38
39
  this.chatConfig = input.chatConfig;
39
40
  this.getAuthToken = input.getAuthToken;
40
41
  this.isAuthenticated = input.isAuthenticated;
41
42
  this.sdkMocked = input.isSDKMocked;
43
+ this.disableReauthentication = disableReauthentication;
42
44
  }
43
45
 
44
46
  //set default expiration to zero, for undefined or missed exp in jwt
@@ -62,32 +64,75 @@ class FacadeChatSDK {
62
64
 
63
65
  // compare expiration time with current time
64
66
  if (now > this.expiration) {
65
- console.log("Token is expired", now, this.expiration, now > this.expiration);
67
+ console.error("Token is expired", now, this.expiration, now > this.expiration);
66
68
  return true;
67
69
  }
68
70
  return false;
69
71
  }
72
+ enforceBase64Encoding(payload) {
73
+ //base64url when present, switches the "-" and "_" characters with "+" and "/"
74
+ const base64Payload = payload.replace(/-/g, "+").replace(/_/g, "/");
75
+ // since base64 encoding requires padding, we need to add padding to the payload
76
+ return base64Payload.padEnd(base64Payload.length + (4 - base64Payload.length % 4) % 4, "=");
77
+ }
78
+ extractExpFromToken(token) {
79
+ const tokenParts = token.split(".");
80
+ const last3digits = token.slice(-3);
81
+
82
+ // token must have 3 parts as JWT format
83
+ if (tokenParts.length !== 3) {
84
+ _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
85
+ Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
86
+ Description: "Invalid token format",
87
+ ExceptionDetails: {
88
+ message: "Invalid token format, must be in JWT format",
89
+ token: last3digits
90
+ }
91
+ });
92
+ throw new Error("Invalid token format, must be in JWT format");
93
+ }
94
+ try {
95
+ const payload = this.enforceBase64Encoding(tokenParts[1]);
96
+ // decode payload
97
+ const decodedPayload = atob(payload);
98
+ const jsonPayload = JSON.parse(decodedPayload);
99
+ // check if exp is present in payload
100
+ if (jsonPayload) {
101
+ if (jsonPayload.exp) {
102
+ return jsonPayload.exp;
103
+ }
104
+ return 0;
105
+ }
106
+ _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
107
+ Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
108
+ Description: "Invalid token payload",
109
+ ExceptionDetails: {
110
+ message: "Token payload is not valid JSON",
111
+ token: last3digits
112
+ }
113
+ });
114
+ throw new Error("Invalid token payload, payload is not valid JSON");
115
+ } catch (e) {
116
+ console.error("Failed to decode token", e);
117
+ _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
118
+ Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
119
+ Description: "Failed to decode token",
120
+ ExceptionDetails: {
121
+ message: "Failed to decode token",
122
+ token: last3digits
123
+ }
124
+ });
125
+ throw new Error("Failed to decode token");
126
+ }
127
+ }
70
128
  async setToken(token) {
71
129
  // token must be not null, and must be new
72
130
  if (!(0, _utils.isNullOrEmptyString)(token) && token !== this.token) {
73
- var _this$token;
131
+ const last3digits = token.slice(-3);
74
132
  const instant = Math.floor(Date.now() / 1000);
75
133
  this.token = token;
76
- // decompose token
77
- const tokenParts = (_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.split(".");
78
- if (!tokenParts || tokenParts.length <= 1) {
79
- _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
80
- Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
81
- Description: "Invalid token format",
82
- ExceptionDetails: "Token must be in JWT format"
83
- });
84
- throw new Error("Invalid token format, must be in JWT format");
85
- }
86
- // decode token
87
- const tokenDecoded = JSON.parse(atob(tokenParts[1]));
88
134
  // calculate expiration time
89
- this.expiration = this.convertExpiration(tokenDecoded.exp);
90
-
135
+ this.expiration = this.convertExpiration(this.extractExpFromToken(token) || 0);
91
136
  // this is a control , in case the getAuthToken function returns same token
92
137
  if (this.expiration > 0 && this.expiration < instant) {
93
138
  _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
@@ -95,14 +140,23 @@ class FacadeChatSDK {
95
140
  Description: "New token is already expired",
96
141
  ExceptionDetails: {
97
142
  "Instant": instant,
98
- "Expiration": this.expiration
143
+ "Expiration": this.expiration,
144
+ "Token": last3digits
99
145
  }
100
146
  });
101
- throw new Error("New token is already expired, with epoch time " + this.expiration);
147
+ throw new Error(`New token is already expired, with epoch time ${this.expiration} , last 3 digits of token: ${last3digits}`);
102
148
  }
103
149
  }
104
150
  }
105
151
  async tokenRing() {
152
+ if (this.disableReauthentication === true) {
153
+ // facade feature is disabled, so we are bypassing the re authentication and let it fail.
154
+ return {
155
+ result: true,
156
+ message: "Facade is disabled"
157
+ };
158
+ }
159
+
106
160
  // this is needed for storybooks, specifically for reconnect pane which requires authentication bypass
107
161
  if (this.sdkMocked === true) {
108
162
  return {
@@ -154,7 +208,6 @@ class FacadeChatSDK {
154
208
  };
155
209
  } else {
156
210
  var _ring$error, _ring$error2;
157
- console.error("Failed to get token", ring);
158
211
  _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
159
212
  Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
160
213
  Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
@@ -247,7 +300,9 @@ class FacadeChatSDK {
247
300
  return this.validateAndExecuteCall("sendMessage", () => this.chatSDK.sendMessage(message));
248
301
  }
249
302
  async onNewMessage(onNewMessageCallback) {
250
- let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
303
+ let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
304
+ disablePolling: false
305
+ };
251
306
  return this.validateAndExecuteCall("onNewMessage", () => this.chatSDK.onNewMessage(onNewMessageCallback, optionalParams));
252
307
  }
253
308
  async sendTypingEvent() {
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
6
+ exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
7
+ exports.getDeviceType = getDeviceType;
8
+ exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = void 0;
7
9
  var _Constants = require("./Constants");
8
10
  var _TelemetryConstants = require("./telemetry/TelemetryConstants");
9
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
@@ -479,4 +481,14 @@ const setOcUserAgent = chatSDK => {
479
481
  }
480
482
  }
481
483
  };
482
- exports.setOcUserAgent = setOcUserAgent;
484
+ exports.setOcUserAgent = setOcUserAgent;
485
+ function getDeviceType() {
486
+ const userAgent = navigator.userAgent.toLowerCase();
487
+ if (/android/.test(userAgent)) {
488
+ return "android";
489
+ } else if (/iphone|ipad|ipod/.test(userAgent)) {
490
+ return "ios";
491
+ } else {
492
+ return "standard";
493
+ }
494
+ }
@@ -14,6 +14,8 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
14
14
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
15
15
  var _createChatTranscript = _interopRequireDefault(require("../../../plugins/createChatTranscript"));
16
16
  var _createReducer = require("../../../contexts/createReducer");
17
+ var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
18
+ var _ConversationState = require("../../../contexts/common/ConversationState");
17
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
20
  const processDisplayName = displayName => {
19
21
  // if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
@@ -168,11 +170,24 @@ const downloadTranscript = async (facadeChatSDK, downloadTranscriptProps, state)
168
170
  // Need to keep existing live chat context for scenarios when transcript is downloaded after endchat
169
171
  let liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
170
172
  if (!liveChatContext) {
173
+ var _inMemoryState$appSta;
171
174
  const inMemoryState = (0, _createReducer.executeReducer)(state, {
172
175
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
173
176
  payload: null
174
177
  });
175
178
  liveChatContext = inMemoryState.domainStates.liveChatContext;
179
+ if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) !== _ConversationState.ConversationState.Active && !liveChatContext) {
180
+ var _state$domainStates2;
181
+ const chatToken = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.chatToken) || inMemoryState.domainStates.chatToken;
182
+ if (chatToken && Object.keys(chatToken).length > 0) {
183
+ liveChatContext = {
184
+ chatToken: chatToken,
185
+ requestId: chatToken.requestId || (0, _omnichannelChatSdk.uuidv4)()
186
+ };
187
+ } else {
188
+ liveChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getCurrentLiveChatContext());
189
+ }
190
+ }
176
191
  }
177
192
  let data = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getLiveChatTranscript({
178
193
  liveChatContext
@@ -20,13 +20,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
20
20
  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); }
21
21
  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; }
22
22
  const LiveChatWidget = props => {
23
- var _props$mock, _props$chatConfig, _props$chatConfig$Liv;
23
+ var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
24
24
  const reducer = (0, _createReducer.createReducer)();
25
25
  const [state, dispatch] = (0, _react.useReducer)(reducer, (0, _LiveChatWidgetContextInitialState.getLiveChatWidgetContextInitialState)(props));
26
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
27
  const [adapter, setAdapter] = (0, _react.useState)(undefined);
28
28
  const [facadeChatSDK, setFacadeChatSDK] = (0, _react.useState)(undefined);
29
29
  const chatSDK = (0, _getMockChatSDKIfApplicable.getMockChatSDKIfApplicable)(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
30
+ const disableReauthentication = ((_props$featureConfigP = props.featureConfigProps) === null || _props$featureConfigP === void 0 ? void 0 : _props$featureConfigP.disableReauthentication) === true;
30
31
  (0, _overridePropsOnMockIfApplicable.default)(props);
31
32
  if (!props.chatConfig) {
32
33
  throw new Error("chatConfig is required");
@@ -43,7 +44,7 @@ const LiveChatWidget = props => {
43
44
  "getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
44
45
  //when type is not undefined, it means the SDK is mocked
45
46
  "isSDKMocked": !(0, _utils.isNullOrUndefined)(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
46
- }));
47
+ }, disableReauthentication));
47
48
  }
48
49
  return /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
49
50
  value: [facadeChatSDK, setFacadeChatSDK]
@@ -11,7 +11,7 @@ var _defaultMarkdownLocalizedTexts = require("../../webchatcontainerstateful/com
11
11
  var _markdownHelper = require("./helpers/markdownHelper");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport) => {
14
+ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport, opensMarkdownLinksInSameTab) => {
15
15
  let markdown;
16
16
  if (!disableMarkdownMessageFormatting) {
17
17
  markdown = new _markdownIt.default(_Constants.Constants.Default, {
@@ -45,10 +45,11 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
45
45
  const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target);
46
46
  // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
47
47
  const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
48
+ const targetValue = opensMarkdownLinksInSameTab ? _Constants.Constants.TargetTop : _Constants.Constants.Blank;
48
49
  if (~targetAttrIndex) {
49
- tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
50
+ tokens[idx].attrs[targetAttrIndex][1] = targetValue;
50
51
  } else {
51
- tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
52
+ tokens[idx].attrPush([_Constants.Constants.Target, targetValue]);
52
53
  }
53
54
  const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
54
55
  if (~relAttrIndex) {
@@ -40,7 +40,7 @@ var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatconta
40
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
42
  const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
43
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai2, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai3, _props$webChatContain23, _props$webChatContain24;
43
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _defaultWebChatContai, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai2, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai3, _props$webChatContain25, _props$webChatContain26;
44
44
  // Add a hook to make all links open a new window
45
45
  postDomPurifyActivities();
46
46
  const localizedTexts = {
@@ -50,12 +50,14 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
50
50
  const hyperlinkTextOverride = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hyperlinkTextOverride) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.hyperlinkTextOverride;
51
51
  const disableNewLineMarkdownSupport = ((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableNewLineMarkdownSupport) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
52
52
  const disableMarkdownMessageFormatting = ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.disableMarkdownMessageFormatting) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting;
53
+ const opensMarkdownLinksInSameTab = (_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.opensMarkdownLinksInSameTab;
54
+ const honorsTargetInHTMLLinks = (_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.honorsTargetInHTMLLinks;
53
55
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
54
- const markdown = (0, _createMarkdown.createMarkdown)(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
56
+ const markdown = (0, _createMarkdown.createMarkdown)(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport, opensMarkdownLinksInSameTab);
55
57
  // Initialize Web Chat's redux store
56
58
  let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
57
59
  if (!webChatStore) {
58
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
60
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
59
61
  const conversationEndCallback = async () => {
60
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
63
  const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
@@ -87,18 +89,18 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
87
89
  };
88
90
  webChatStore = (0, _botframeworkWebchat.createStore)({},
89
91
  //initial state
90
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
92
+ _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
91
93
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
- ...(((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.storeMiddlewares) ?? []));
94
+ ...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
93
95
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
94
96
  }
95
97
  const hyperlinkTextOverrideRenderer = new _HyperlinkTextOverrideRenderer.default(hyperlinkTextOverride);
96
98
  const markdownRenderers = [hyperlinkTextOverrideRenderer];
97
99
  const renderMarkdown = text => {
98
- var _props$webChatContain6, _props$webChatContain7;
99
- if ((_props$webChatContain6 = props.webChatContainerProps) !== null && _props$webChatContain6 !== void 0 && (_props$webChatContain7 = _props$webChatContain6.webChatProps) !== null && _props$webChatContain7 !== void 0 && _props$webChatContain7.renderMarkdown) {
100
- var _props$webChatContain8;
101
- text = (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatProps.renderMarkdown(text);
100
+ var _props$webChatContain8, _props$webChatContain9;
101
+ if ((_props$webChatContain8 = props.webChatContainerProps) !== null && _props$webChatContain8 !== void 0 && (_props$webChatContain9 = _props$webChatContain8.webChatProps) !== null && _props$webChatContain9 !== void 0 && _props$webChatContain9.renderMarkdown) {
102
+ var _props$webChatContain10;
103
+ text = (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatProps.renderMarkdown(text);
102
104
  } else {
103
105
  const render = disableMarkdownMessageFormatting ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
104
106
  text = render(text);
@@ -108,16 +110,19 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
108
110
  });
109
111
  const config = {
110
112
  FORBID_TAGS: ["form", "button", "script", "div", "input"],
111
- FORBID_ATTR: ["action"]
113
+ FORBID_ATTR: ["action"],
114
+ ADD_ATTR: ["target"]
112
115
  };
113
116
  text = _dompurify.default.sanitize(text, config);
114
117
  return text;
115
118
  };
116
119
  function postDomPurifyActivities() {
117
120
  _dompurify.default.addHook("afterSanitizeAttributes", function (node) {
118
- // set all elements owning target to target=_blank
119
- if ("target" in node) {
120
- node.setAttribute("target", "_blank");
121
+ const target = node.getAttribute(_Constants.Constants.Target);
122
+ if (target === _Constants.Constants.TargetSelf) {
123
+ node.setAttribute(_Constants.Constants.Target, _Constants.Constants.TargetTop);
124
+ } else if (!target) {
125
+ node.setAttribute(_Constants.Constants.Target, _Constants.Constants.Blank);
121
126
  }
122
127
  });
123
128
  }
@@ -127,18 +132,18 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
127
132
  dir: state.domainStates.globalDir,
128
133
  locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
129
134
  store: webChatStore,
130
- activityMiddleware: (_props$webChatContain9 = props.webChatContainerProps) !== null && _props$webChatContain9 !== void 0 && (_props$webChatContain10 = _props$webChatContain9.renderingMiddlewareProps) !== null && _props$webChatContain10 !== void 0 && _props$webChatContain10.disableActivityMiddleware ? undefined : (0, _activityMiddleware.createActivityMiddleware)(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
131
- attachmentMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableAttachmentMiddleware ? undefined : (0, _attachmentMiddleware.createAttachmentMiddleware)(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? _defaultAttachmentProps.defaultAttachmentProps.enableInlinePlaying),
132
- activityStatusMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
133
- toastMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableToastMiddleware ? undefined : (0, _toastMiddleware.createToastMiddleware)(props.notificationPaneProps, endChat),
135
+ activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : (0, _activityMiddleware.createActivityMiddleware)(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
136
+ attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : (0, _attachmentMiddleware.createAttachmentMiddleware)(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? _defaultAttachmentProps.defaultAttachmentProps.enableInlinePlaying),
137
+ activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
138
+ toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : (0, _toastMiddleware.createToastMiddleware)(props.notificationPaneProps, endChat),
134
139
  renderMarkdown,
135
- avatarMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableAvatarMiddleware ? undefined : (0, _avatarMiddleware.createAvatarMiddleware)((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
136
- groupActivitiesMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
137
- typingIndicatorMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
140
+ avatarMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableAvatarMiddleware ? undefined : (0, _avatarMiddleware.createAvatarMiddleware)((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
141
+ groupActivitiesMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
142
+ typingIndicatorMiddleware: (_props$webChatContain23 = props.webChatContainerProps) !== null && _props$webChatContain23 !== void 0 && (_props$webChatContain24 = _props$webChatContain23.renderingMiddlewareProps) !== null && _props$webChatContain24 !== void 0 && _props$webChatContain24.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
138
143
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
139
- cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain23 = props.webChatContainerProps) === null || _props$webChatContain23 === void 0 ? void 0 : _props$webChatContain23.botMagicCode) || undefined),
144
+ cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
140
145
  sendTypingIndicator: true,
141
- ...((_props$webChatContain24 = props.webChatContainerProps) === null || _props$webChatContain24 === void 0 ? void 0 : _props$webChatContain24.webChatProps)
146
+ ...((_props$webChatContain26 = props.webChatContainerProps) === null || _props$webChatContain26 === void 0 ? void 0 : _props$webChatContain26.webChatProps)
142
147
  };
143
148
  return webChatProps;
144
149
  };
@@ -64,7 +64,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
64
64
  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); }
65
65
  let uiTimer;
66
66
  const LiveChatWidgetStateful = props => {
67
- var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain7, _props$webChatContain8, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain9, _props$webChatContain10, _props$webChatContain11, _props$webChatContain12, _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$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
67
+ var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _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$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
68
68
  (0, _react2.useEffect)(() => {
69
69
  uiTimer = (0, _utils.createTimer)();
70
70
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -94,6 +94,7 @@ const LiveChatWidgetStateful = props => {
94
94
 
95
95
  //Scrollbar styles
96
96
  const scrollbarProps = Object.assign({}, _defaultScrollBarProps.defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
97
+ const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.sendBoxTextBox) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.textarea;
97
98
 
98
99
  // In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
99
100
  if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
@@ -588,6 +589,8 @@ const LiveChatWidgetStateful = props => {
588
589
  _omnichannelChatComponents.BroadcastService.postMessage({
589
590
  eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
590
591
  });
592
+ }, {
593
+ disablePolling: true
591
594
  });
592
595
  facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onAgentEndSession(event => {
593
596
  var _inMemoryState$appSta6;
@@ -611,8 +614,8 @@ const LiveChatWidgetStateful = props => {
611
614
  });
612
615
  }
613
616
  if (state.appStates.conversationState === _ConversationState.ConversationState.InActive) {
614
- var _props$webChatContain2, _props$webChatContain3;
615
- if ((props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.renderingMiddlewareProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.hideSendboxOnConversationEnd) !== false) {
617
+ var _props$webChatContain4, _props$webChatContain5;
618
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
616
619
  setWebChatStyles(styles => {
617
620
  return {
618
621
  ...styles,
@@ -656,12 +659,12 @@ const LiveChatWidgetStateful = props => {
656
659
  }
657
660
  }, [state.appStates.unreadMessageCount]);
658
661
  (0, _react2.useEffect)(() => {
659
- var _props$webChatContain4;
662
+ var _props$webChatContain6;
660
663
  setWebChatStyles({
661
664
  ...webChatStyles,
662
- ...((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.webChatStyles)
665
+ ...((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.webChatStyles)
663
666
  });
664
- }, [(_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.webChatStyles]);
667
+ }, [(_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.webChatStyles]);
665
668
  (0, _react2.useEffect)(() => {
666
669
  //Confirmation pane dismissing through OK option, so proceed with end chat
667
670
  if (state.domainStates.confirmationState === _Constants.ConfirmationState.Ok) {
@@ -760,12 +763,12 @@ const LiveChatWidgetStateful = props => {
760
763
 
761
764
  // if props state gets updates we need to update the renderingMiddlewareProps in the state
762
765
  (0, _react2.useEffect)(() => {
763
- var _props$webChatContain6;
766
+ var _props$webChatContain8;
764
767
  dispatch({
765
768
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
766
- payload: (_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.renderingMiddlewareProps
769
+ payload: (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.renderingMiddlewareProps
767
770
  });
768
- }, [(_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.renderingMiddlewareProps]);
771
+ }, [(_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.renderingMiddlewareProps]);
769
772
  (0, _react2.useEffect)(() => {
770
773
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
771
774
  Event: _TelemetryConstants.TelemetryEvent.UXLivechatwidgetCompleted,
@@ -807,7 +810,7 @@ const LiveChatWidgetStateful = props => {
807
810
  const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, state, dispatch, facadeChatSDK, endChatRelay);
808
811
  const downloadTranscriptProps = (0, _createDownloadTranscriptProps.default)(props.downloadTranscriptProps, {
809
812
  ...(_defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === null || _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === void 0 ? void 0 : _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles),
810
- ...((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatStyles)
813
+ ...((_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatStyles)
811
814
  }, props.webChatContainerProps);
812
815
  const livechatProps = {
813
816
  ...props,
@@ -865,13 +868,16 @@ const LiveChatWidgetStateful = props => {
865
868
  height: .75em;
866
869
  margin-left: .25em;
867
870
  }
868
- }
871
+ ${(sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight) && `
872
+ textarea.webchat__send-box-text-box__html-text-area {
873
+ min-height: ${sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight};
874
+ }`}
869
875
  `), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
870
876
  userID: userID,
871
877
  styleOptions: {
872
878
  ...webChatStyles,
873
- bubbleBackground: ((_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : (_props$webChatContain10 = _props$webChatContain9.adaptiveCardStyles) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background,
874
- bubbleTextColor: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.adaptiveCardStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color
879
+ bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.adaptiveCardStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background,
880
+ bubbleTextColor: ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color
875
881
  },
876
882
  directLine: directLine
877
883
  }), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
@@ -145,11 +145,6 @@ const PreChatSurveyPaneStateful = props => {
145
145
  }
146
146
  }
147
147
  }
148
- // Move focus to the first button
149
- const firstElement = (0, _utils.findAllFocusableElement)(`#${controlProps.id}`);
150
- if (firstElement && firstElement[0]) {
151
- firstElement[0].focus();
152
- }
153
148
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
154
149
  Event: _TelemetryConstants.TelemetryEvent.PrechatSurveyLoaded
155
150
  });
@@ -158,6 +153,16 @@ const PreChatSurveyPaneStateful = props => {
158
153
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
159
154
  });
160
155
  }, []);
156
+
157
+ // Set focus to the first element
158
+ (0, _react.useEffect)(() => {
159
+ if (!state.appStates.isMinimized) {
160
+ const firstElement = (0, _utils.findAllFocusableElement)(`#${controlProps.id}`);
161
+ if (firstElement && firstElement[0]) {
162
+ firstElement[0].focus();
163
+ }
164
+ }
165
+ }, [state.appStates.isMinimized]);
161
166
  return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.PreChatSurveyPane, {
162
167
  controlProps: controlProps,
163
168
  styleProps: styleProps
@@ -83,7 +83,12 @@ const WebChatContainerStateful = props => {
83
83
  };
84
84
  (0, _react2.useEffect)(() => {
85
85
  var _props$webChatContain, _props$webChatContain2;
86
- (0, _utils.setFocusOnSendBox)();
86
+ if ((0, _utils.getDeviceType)() !== "standard" && (webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.webChatHistoryMobileAccessibilityLabel) !== undefined) {
87
+ const chatHistoryElement = document.querySelector(`.${_Constants.HtmlClassNames.webChatHistoryContainer}`);
88
+ if (chatHistoryElement) {
89
+ chatHistoryElement.setAttribute(_Constants.HtmlAttributeNames.ariaLabel, webChatContainerProps.webChatHistoryMobileAccessibilityLabel);
90
+ }
91
+ }
87
92
  dispatch({
88
93
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
89
94
  payload: webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.renderingMiddlewareProps
@@ -164,6 +169,13 @@ const WebChatContainerStateful = props => {
164
169
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
165
170
  });
166
171
  }, []);
172
+
173
+ // Set focus to the sendbox
174
+ (0, _react2.useEffect)(() => {
175
+ if (!state.appStates.isMinimized) {
176
+ (0, _utils.setFocusOnSendBox)();
177
+ }
178
+ }, [state.appStates.isMinimized]);
167
179
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
168
180
  .webchat__stacked-layout__content .ac-pushButton {
169
181
  cursor: pointer;
@@ -16,6 +16,8 @@ const defaultWebChatContainerStatefulProps = {
16
16
  containerStyles: _defaultWebChatStatefulContainerStyles.defaultWebChatStatefulContainerStyles,
17
17
  disableNewLineMarkdownSupport: false,
18
18
  disableMarkdownMessageFormatting: false,
19
+ opensMarkdownLinksInSameTab: false,
20
+ honorsTargetInHTMLLinks: false,
19
21
  hyperlinkTextOverride: false,
20
22
  directLine: new _mockadapter.default(),
21
23
  adaptiveCardStyles: _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles
@@ -18,7 +18,9 @@ class HyperlinkTextOverrideRenderer {
18
18
  convertTextToHtmlNode(text) {
19
19
  const htmlNode = document.createElement(_Constants.HtmlAttributeNames.div);
20
20
  try {
21
- text = _dompurify.default.sanitize(text); // eslint-disable-line @typescript-eslint/no-explicit-any
21
+ text = _dompurify.default.sanitize(text, {
22
+ ADD_ATTR: ["target"]
23
+ });
22
24
  htmlNode.innerHTML = text;
23
25
  } catch {
24
26
  return htmlNode;