@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.3
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.
- package/lib/cjs/common/Constants.js +2 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
- package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
- package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +21 -2
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +1 -1
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -4
- package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +96 -11
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
- package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/index.js +9 -1
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
- package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
- package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +22 -3
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +1 -1
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/esm/components/livechatwidget/common/startChat.js +5 -4
- package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +96 -12
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/index.js +1 -0
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +3 -0
- package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
- package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
- package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
- package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
- package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
- package/lib/types/index.d.ts +1 -0
- package/package.json +2 -2
- /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
|
@@ -10,6 +10,7 @@ var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
|
10
10
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _utils = require("../../common/utils");
|
|
12
12
|
var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
13
|
+
var _CitationPaneStateful = _interopRequireDefault(require("../citationpanestateful/CitationPaneStateful"));
|
|
13
14
|
var _botframeworkWebchat = require("botframework-webchat");
|
|
14
15
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
15
16
|
var _NotificationHandler = require("./webchatcontroller/notification/NotificationHandler");
|
|
@@ -17,6 +18,7 @@ var _NotificationScenarios = require("./webchatcontroller/enums/NotificationScen
|
|
|
17
18
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
18
19
|
var _WebChatActionType = require("./webchatcontroller/enums/WebChatActionType");
|
|
19
20
|
var _WebChatStoreLoader = require("./webchatcontroller/WebChatStoreLoader");
|
|
21
|
+
var _fontUtils = require("./common/utils/fontUtils");
|
|
20
22
|
var _defaultAdaptiveCardStyles = require("./common/defaultStyles/defaultAdaptiveCardStyles");
|
|
21
23
|
var _defaultMiddlewareLocalizedTexts = require("./common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
22
24
|
var _defaultReceivedMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles");
|
|
@@ -25,12 +27,12 @@ var _defaultSystemMessageBoxStyles = require("./webchatcontroller/middlewares/re
|
|
|
25
27
|
var _defaultUserMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles");
|
|
26
28
|
var _defaultWebChatContainerStatefulProps = require("./common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
27
29
|
var _ = require("../..");
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
31
|
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); }
|
|
29
32
|
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; }
|
|
30
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
31
|
-
|
|
32
33
|
let uiTimer;
|
|
33
34
|
const broadcastChannelMessageEvent = "message";
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
36
|
const postActivity = activity => {
|
|
35
37
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
36
38
|
return {
|
|
@@ -56,13 +58,30 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
56
58
|
};
|
|
57
59
|
};
|
|
58
60
|
const WebChatContainerStateful = props => {
|
|
59
|
-
var _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$
|
|
61
|
+
var _props$webChatContain, _defaultWebChatContai, _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$webChatContain6, _props$webChatContain7, _defaultWebChatContai2, _props$webChatContain8, _props$webChatContain9, _defaultWebChatContai3, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _webChatContainerProp17, _webChatContainerProp18, _webChatContainerProp19, _webChatContainerProp20, _webChatContainerProp21, _webChatContainerProp22, _webChatContainerProp23, _props$webChatContain10, _props$webChatContain11, _webChatContainerProp24, _webChatContainerProp25, _webChatContainerProp26, _webChatContainerProp27, _props$citationPanePr, _props$citationPanePr2, _props$citationPanePr3, _props$citationPanePr4, _props$citationPanePr5;
|
|
62
|
+
// Create a font family that includes emoji support, based on the primary font or default
|
|
63
|
+
const webChatStyles = ((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles;
|
|
64
|
+
const primaryFont = (webChatStyles === null || webChatStyles === void 0 ? void 0 : webChatStyles.primaryFont) ?? ((_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.primaryFont);
|
|
65
|
+
|
|
66
|
+
// Use iOS-optimized emoji font that prioritizes system-ui for proper emoji rendering
|
|
67
|
+
const fontFamilyWithEmojis = (0, _fontUtils.createIOSOptimizedEmojiFont)(primaryFont);
|
|
60
68
|
(0, _react2.useEffect)(() => {
|
|
61
69
|
uiTimer = (0, _utils.createTimer)();
|
|
62
70
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
63
71
|
Event: _TelemetryConstants.TelemetryEvent.UXWebchatContainerCompleted
|
|
64
72
|
});
|
|
65
73
|
}, []);
|
|
74
|
+
|
|
75
|
+
// Citation pane state
|
|
76
|
+
const [citationPaneOpen, setCitationPaneOpen] = (0, _react2.useState)(false);
|
|
77
|
+
const [citationPaneText, setCitationPaneText] = (0, _react2.useState)("");
|
|
78
|
+
|
|
79
|
+
// Guard to prevent handling multiple rapid clicks which could cause
|
|
80
|
+
// the dim layer and pane to re-render out of sync and create a flicker.
|
|
81
|
+
const citationOpeningRef = (0, _react2.useRef)(false);
|
|
82
|
+
|
|
83
|
+
// ...existing code...
|
|
84
|
+
|
|
66
85
|
const {
|
|
67
86
|
BasicWebChat
|
|
68
87
|
} = _botframeworkWebchat.Components;
|
|
@@ -71,6 +90,53 @@ const WebChatContainerStateful = props => {
|
|
|
71
90
|
webChatContainerProps,
|
|
72
91
|
contextDataStore
|
|
73
92
|
} = props;
|
|
93
|
+
|
|
94
|
+
// Delegated click handler for citation anchors. Placed after state is
|
|
95
|
+
// available so we can prefer reading citations from app state and fall
|
|
96
|
+
// back to the legacy window map for backward-compatibility in tests.
|
|
97
|
+
(0, _react2.useEffect)(() => {
|
|
98
|
+
const clickHandler = ev => {
|
|
99
|
+
try {
|
|
100
|
+
if (citationOpeningRef.current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const target = ev.target;
|
|
104
|
+
// Only consider anchors whose href starts with the citation scheme
|
|
105
|
+
const anchor = target.closest && target.closest("a[href^=\"cite:\"]");
|
|
106
|
+
if (anchor) {
|
|
107
|
+
ev.preventDefault();
|
|
108
|
+
citationOpeningRef.current = true;
|
|
109
|
+
// Rely only on the href to identify the citation key
|
|
110
|
+
let text = "";
|
|
111
|
+
try {
|
|
112
|
+
var _state$domainStates;
|
|
113
|
+
const cid = anchor.getAttribute("href");
|
|
114
|
+
// Prefer state-based citations injected by middleware
|
|
115
|
+
if (state !== null && state !== void 0 && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.citations && cid) {
|
|
116
|
+
text = state.domainStates.citations[cid] ?? "";
|
|
117
|
+
}
|
|
118
|
+
// If state lookup failed, fall back to the anchor's title or innerText
|
|
119
|
+
if (!text) {
|
|
120
|
+
text = anchor.getAttribute("title") || anchor.innerText || "";
|
|
121
|
+
}
|
|
122
|
+
} catch (e) {
|
|
123
|
+
// ignore
|
|
124
|
+
}
|
|
125
|
+
setCitationPaneOpen(true);
|
|
126
|
+
setCitationPaneText(text);
|
|
127
|
+
|
|
128
|
+
// Simple debounce - reset guard after a short delay
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
citationOpeningRef.current = false;
|
|
131
|
+
}, 100);
|
|
132
|
+
}
|
|
133
|
+
} catch (e) {
|
|
134
|
+
citationOpeningRef.current = false;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
document.addEventListener("click", clickHandler);
|
|
138
|
+
return () => document.removeEventListener("click", clickHandler);
|
|
139
|
+
}, [state]);
|
|
74
140
|
const containerStyles = {
|
|
75
141
|
root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.containerStyles, {
|
|
76
142
|
display: state.appStates.isMinimized ? "none" : ""
|
|
@@ -82,7 +148,7 @@ const WebChatContainerStateful = props => {
|
|
|
82
148
|
...(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.localizedTexts)
|
|
83
149
|
};
|
|
84
150
|
(0, _react2.useEffect)(() => {
|
|
85
|
-
var _props$
|
|
151
|
+
var _props$webChatContain2, _props$webChatContain3;
|
|
86
152
|
if ((0, _utils.getDeviceType)() !== "standard" && (webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.webChatHistoryMobileAccessibilityLabel) !== undefined) {
|
|
87
153
|
const chatHistoryElement = document.querySelector(`.${_Constants.HtmlClassNames.webChatHistoryContainer}`);
|
|
88
154
|
if (chatHistoryElement) {
|
|
@@ -100,21 +166,23 @@ const WebChatContainerStateful = props => {
|
|
|
100
166
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
101
167
|
Event: _TelemetryConstants.TelemetryEvent.WebChatLoaded
|
|
102
168
|
});
|
|
103
|
-
if (((_props$
|
|
169
|
+
if (((_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.disableThirdPartyCookiesAlert) !== true && !contextDataStore) {
|
|
104
170
|
try {
|
|
105
171
|
localStorage;
|
|
106
172
|
sessionStorage;
|
|
107
173
|
} catch (error) {
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
175
|
if (!window.TPCWarningShown) {
|
|
109
176
|
_NotificationHandler.NotificationHandler.notifyWarning(_NotificationScenarios.NotificationScenarios.TPC, (localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE) ?? "");
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
178
|
window.TPCWarningShown = true;
|
|
111
179
|
}
|
|
112
180
|
}
|
|
113
181
|
}
|
|
114
182
|
}, []);
|
|
115
183
|
(0, _react2.useEffect)(() => {
|
|
116
|
-
var _props$
|
|
117
|
-
if (!((_props$
|
|
184
|
+
var _props$webChatContain4, _props$webChatContain5;
|
|
185
|
+
if (!((_props$webChatContain4 = props.webChatContainerProps) !== null && _props$webChatContain4 !== void 0 && (_props$webChatContain5 = _props$webChatContain4.botMagicCode) !== null && _props$webChatContain5 !== void 0 && _props$webChatContain5.disabled)) {
|
|
118
186
|
return;
|
|
119
187
|
}
|
|
120
188
|
if (!window.BroadcastChannel) {
|
|
@@ -206,8 +274,8 @@ const WebChatContainerStateful = props => {
|
|
|
206
274
|
}
|
|
207
275
|
|
|
208
276
|
.ms_lcw_webchat_received_message>div.webchat__stacked-layout>div.webchat__stacked-layout__main>div.webchat__stacked-layout__content>div.webchat__stacked-layout__message-row>[class^=webchat]:not(.webchat__bubble--from-user)>.webchat__bubble__content {
|
|
209
|
-
background-color: ${((_props$
|
|
210
|
-
color:${((_props$
|
|
277
|
+
background-color: ${((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : (_props$webChatContain7 = _props$webChatContain6.webChatStyles) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.bubbleBackground) ?? ((_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.bubbleBackground)};
|
|
278
|
+
color:${((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : (_props$webChatContain9 = _props$webChatContain8.webChatStyles) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.bubbleTextColor) ?? ((_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.bubbleTextColor)};
|
|
211
279
|
}
|
|
212
280
|
|
|
213
281
|
div[class="ac-textBlock"] a:link,
|
|
@@ -285,7 +353,7 @@ const WebChatContainerStateful = props => {
|
|
|
285
353
|
}
|
|
286
354
|
|
|
287
355
|
.webchat__stacked-layout_container>div {
|
|
288
|
-
background: ${(props === null || props === void 0 ? void 0 : (_props$
|
|
356
|
+
background: ${(props === null || props === void 0 ? void 0 : (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : (_props$webChatContain11 = _props$webChatContain10.containerStyles) === null || _props$webChatContain11 === void 0 ? void 0 : _props$webChatContain11.background) ?? ""}
|
|
289
357
|
}
|
|
290
358
|
.webchat__toast_text {
|
|
291
359
|
display: flex;
|
|
@@ -312,10 +380,27 @@ const WebChatContainerStateful = props => {
|
|
|
312
380
|
height: 100% !important;
|
|
313
381
|
}
|
|
314
382
|
|
|
383
|
+
.webchat__auto-resize-textarea__textarea.webchat__send-box-text-box__html-text-area {
|
|
384
|
+
font-family: ${fontFamilyWithEmojis} !important;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/* Suggested actions carousel previous/next navigation focus */
|
|
388
|
+
.webchat__suggested-actions .webchat__suggested-actions__carousel .react-film__flipper:focus-visible .react-film__flipper__body {
|
|
389
|
+
outline: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp24 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp24 === void 0 ? void 0 : _webChatContainerProp24.suggestedActionKeyboardFocusIndicatorBorderStyle) ?? "dashed"} ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp25 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp25 === void 0 ? void 0 : _webChatContainerProp25.suggestedActionKeyboardFocusIndicatorBorderWidth) ?? "1px"} ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp26 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp26 === void 0 ? void 0 : _webChatContainerProp26.suggestedActionKeyboardFocusIndicatorBorderColor) ?? "#605E5C"} !important;
|
|
390
|
+
outline-offset: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp27 = webChatContainerProps.webChatStyles) === null || _webChatContainerProp27 === void 0 ? void 0 : _webChatContainerProp27.suggestedActionKeyboardFocusIndicatorInset) ?? "2px"} !important;
|
|
391
|
+
|
|
315
392
|
`), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
316
393
|
styles: containerStyles,
|
|
317
394
|
className: "webchat__stacked-layout_container"
|
|
318
|
-
}, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null))
|
|
395
|
+
}, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null)), citationPaneOpen && /*#__PURE__*/_react2.default.createElement(_CitationPaneStateful.default, {
|
|
396
|
+
id: ((_props$citationPanePr = props.citationPaneProps) === null || _props$citationPanePr === void 0 ? void 0 : _props$citationPanePr.id) || _Constants.HtmlAttributeNames.ocwCitationPaneClassName,
|
|
397
|
+
title: ((_props$citationPanePr2 = props.citationPaneProps) === null || _props$citationPanePr2 === void 0 ? void 0 : _props$citationPanePr2.title) || _Constants.HtmlAttributeNames.ocwCitationPaneTitle,
|
|
398
|
+
contentHtml: citationPaneText,
|
|
399
|
+
onClose: () => setCitationPaneOpen(false),
|
|
400
|
+
componentOverrides: (_props$citationPanePr3 = props.citationPaneProps) === null || _props$citationPanePr3 === void 0 ? void 0 : _props$citationPanePr3.componentOverrides,
|
|
401
|
+
controlProps: (_props$citationPanePr4 = props.citationPaneProps) === null || _props$citationPanePr4 === void 0 ? void 0 : _props$citationPanePr4.controlProps,
|
|
402
|
+
styleProps: (_props$citationPanePr5 = props.citationPaneProps) === null || _props$citationPanePr5 === void 0 ? void 0 : _props$citationPanePr5.styleProps
|
|
403
|
+
}));
|
|
319
404
|
};
|
|
320
405
|
exports.WebChatContainerStateful = WebChatContainerStateful;
|
|
321
406
|
var _default = WebChatContainerStateful;
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DesignerChatAdapter = void 0;
|
|
7
|
-
var _Observable = require("rxjs/Observable");
|
|
8
|
-
var _mockadapter = _interopRequireDefault(require("./mockadapter"));
|
|
9
7
|
var _chatAdapterUtils = require("./utils/chatAdapterUtils");
|
|
8
|
+
var _mockadapter = _interopRequireDefault(require("./mockadapter"));
|
|
9
|
+
var _Observable = require("rxjs/Observable");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
13
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
14
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
15
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
18
16
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -20,25 +18,56 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
|
|
|
20
18
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
20
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
24
|
let DesignerChatAdapter = /*#__PURE__*/function (_MockAdapter) {
|
|
24
25
|
_inherits(DesignerChatAdapter, _MockAdapter);
|
|
25
26
|
var _super = _createSuper(DesignerChatAdapter);
|
|
26
|
-
function DesignerChatAdapter() {
|
|
27
|
+
function DesignerChatAdapter(messages) {
|
|
27
28
|
var _this;
|
|
28
29
|
_classCallCheck(this, DesignerChatAdapter);
|
|
29
30
|
_this = _super.call(this);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "messages", void 0);
|
|
32
|
+
_this.messages = messages;
|
|
33
|
+
if (_this.messages) {
|
|
34
|
+
if (_this.messages.length > 0) {
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
var _this$messages;
|
|
37
|
+
(_this$messages = _this.messages) === null || _this$messages === void 0 ? void 0 : _this$messages.forEach((msg, index) => {
|
|
38
|
+
_this.processMessage(msg, index);
|
|
39
|
+
});
|
|
40
|
+
}, 1000); // Initial 1 second delay to ensure activityObserver is ready
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
// Default hardcoded flow
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
|
|
46
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Please accept terms and conditions to proceed. Visit the link for terms and conditions <a href=\"\">here</a>.", undefined, 0);
|
|
47
|
+
_this.postUserActivity("I need to change my address.", 0);
|
|
48
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
|
|
49
|
+
(0, _chatAdapterUtils.postSystemMessageActivity)(_this.activityObserver, "John has joined the chat", 100);
|
|
50
|
+
(0, _chatAdapterUtils.postAgentMessageActivity)(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
|
|
51
|
+
_this.postUserActivity("I have trouble visiting the signin page <a href=\"\">signin</a>.", 0);
|
|
52
|
+
}, 1000);
|
|
53
|
+
}
|
|
39
54
|
return _this;
|
|
40
55
|
}
|
|
41
56
|
_createClass(DesignerChatAdapter, [{
|
|
57
|
+
key: "processMessage",
|
|
58
|
+
value: function processMessage(msg, index) {
|
|
59
|
+
if (msg.text) {
|
|
60
|
+
if (msg.suggestedActions) {
|
|
61
|
+
(0, _chatAdapterUtils.postAgentSuggestedActionsActivity)(this.activityObserver, msg.text, msg.suggestedActions, index * 100);
|
|
62
|
+
} else {
|
|
63
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(this.activityObserver, msg.text, undefined, index * 100);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (msg.attachments && msg.attachments.length > 0) {
|
|
67
|
+
(0, _chatAdapterUtils.postAgentAttachmentActivity)(this.activityObserver, msg.attachments, index * 100, msg.attachmentLayout);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
42
71
|
key: "postUserActivity",
|
|
43
72
|
value: function postUserActivity(text) {
|
|
44
73
|
let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
@@ -26,13 +26,18 @@ let DesignerChatSDK = /*#__PURE__*/function (_MockChatSDK) {
|
|
|
26
26
|
var _this;
|
|
27
27
|
_classCallCheck(this, DesignerChatSDK);
|
|
28
28
|
_this = _super.call(this);
|
|
29
|
+
/**
|
|
30
|
+
* Create a chat adapter for the designer. Uses this.mockMessages if set.
|
|
31
|
+
*/
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "mockMessages", void 0);
|
|
29
33
|
_defineProperty(_assertThisInitialized(_this), "localeId", _this.getLiveChatConfig().ChatWidgetLanguage.msdyn_localeid);
|
|
30
34
|
return _this;
|
|
31
35
|
}
|
|
32
36
|
_createClass(DesignerChatSDK, [{
|
|
33
37
|
key: "createChatAdapter",
|
|
34
38
|
value: function createChatAdapter() {
|
|
35
|
-
|
|
39
|
+
const adapter = new _DesignerChatAdapter.DesignerChatAdapter(this.mockMessages);
|
|
40
|
+
return adapter;
|
|
36
41
|
}
|
|
37
42
|
}, {
|
|
38
43
|
key: "getLiveChatConfig",
|
package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js
CHANGED
|
@@ -23,7 +23,7 @@ const defaultWebChatStyles = {
|
|
|
23
23
|
bubbleTextColor: "White",
|
|
24
24
|
hideSendBox: false,
|
|
25
25
|
hideUploadButton: true,
|
|
26
|
-
primaryFont: "Segoe UI, Arial, sans-serif",
|
|
26
|
+
primaryFont: "Segoe UI, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\"",
|
|
27
27
|
rootHeight: "100%",
|
|
28
28
|
rootWidth: "100%",
|
|
29
29
|
sendBoxTextWrap: true,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.postSystemMessageActivity = exports.postEchoActivity = exports.postBotTypingActivity = exports.postBotMessageActivity = exports.postBotAttachmentActivity = exports.postAgentMessageActivity = exports.customerUser = exports.botUser = exports.agentUser = void 0;
|
|
6
|
+
exports.postSystemMessageActivity = exports.postEchoActivity = exports.postBotTypingActivity = exports.postBotMessageActivity = exports.postBotAttachmentActivity = exports.postAgentSuggestedActionsActivity = exports.postAgentMessageActivity = exports.postAgentAttachmentActivity = exports.customerUser = exports.botUser = exports.agentUser = void 0;
|
|
7
7
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
8
|
const customerUser = {
|
|
9
9
|
id: "usedId",
|
|
@@ -112,4 +112,38 @@ const postBotAttachmentActivity = function (activityObserver) {
|
|
|
112
112
|
});
|
|
113
113
|
}, delay);
|
|
114
114
|
};
|
|
115
|
-
exports.postBotAttachmentActivity = postBotAttachmentActivity;
|
|
115
|
+
exports.postBotAttachmentActivity = postBotAttachmentActivity;
|
|
116
|
+
const postAgentAttachmentActivity = function (activityObserver) {
|
|
117
|
+
let attachments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
118
|
+
let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
119
|
+
let attachmentLayout = arguments.length > 3 ? arguments[3] : undefined;
|
|
120
|
+
setTimeout(() => {
|
|
121
|
+
activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
|
|
122
|
+
id: (0, _omnichannelChatSdk.uuidv4)(),
|
|
123
|
+
from: {
|
|
124
|
+
...agentUser
|
|
125
|
+
},
|
|
126
|
+
attachments,
|
|
127
|
+
attachmentLayout,
|
|
128
|
+
type: "message",
|
|
129
|
+
timestamp: new Date().toISOString()
|
|
130
|
+
});
|
|
131
|
+
}, delay);
|
|
132
|
+
};
|
|
133
|
+
exports.postAgentAttachmentActivity = postAgentAttachmentActivity;
|
|
134
|
+
const postAgentSuggestedActionsActivity = function (activityObserver, text, suggestedActions) {
|
|
135
|
+
let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
|
|
138
|
+
id: (0, _omnichannelChatSdk.uuidv4)(),
|
|
139
|
+
from: {
|
|
140
|
+
...agentUser
|
|
141
|
+
},
|
|
142
|
+
text,
|
|
143
|
+
type: "message",
|
|
144
|
+
suggestedActions,
|
|
145
|
+
timestamp: new Date().toISOString()
|
|
146
|
+
});
|
|
147
|
+
}, delay);
|
|
148
|
+
};
|
|
149
|
+
exports.postAgentSuggestedActionsActivity = postAgentSuggestedActionsActivity;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createIOSOptimizedEmojiFont = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Utility functions for font handling and emoji support
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a font family optimized for iOS emoji support
|
|
13
|
+
* Uses system-ui as the primary font for better emoji rendering on iOS
|
|
14
|
+
* @param primaryFont - The base font family string (optional, used as fallback)
|
|
15
|
+
* @returns Font family string optimized for iOS emoji support
|
|
16
|
+
*/
|
|
17
|
+
const createIOSOptimizedEmojiFont = primaryFont => {
|
|
18
|
+
// For iOS emoji support, system-ui should be first
|
|
19
|
+
const baseFont = "system-ui";
|
|
20
|
+
const emojiSupport = "\"Apple Color Emoji\", \"Segoe UI Emoji\"";
|
|
21
|
+
if (!primaryFont || primaryFont.includes("system-ui") || primaryFont.includes("Apple Color Emoji")) {
|
|
22
|
+
return `${baseFont}, ${emojiSupport}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Add configured font as fallback after emoji fonts
|
|
26
|
+
return `${baseFont}, ${emojiSupport}, ${primaryFont}`;
|
|
27
|
+
};
|
|
28
|
+
exports.createIOSOptimizedEmojiFont = createIOSOptimizedEmojiFont;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.defaultAvatarTextStyles = void 0;
|
|
7
7
|
const defaultAvatarTextStyles = {
|
|
8
8
|
margin: "0",
|
|
9
|
-
fontFamily: "
|
|
9
|
+
fontFamily: "'Segoe UI', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', Arial, sans-serif",
|
|
10
10
|
fontWeight: 600,
|
|
11
11
|
fontSize: "13px",
|
|
12
12
|
lineHeight: "18px",
|
|
@@ -11,7 +11,7 @@ const defaultSystemMessageStyles = {
|
|
|
11
11
|
fontSize: "12px",
|
|
12
12
|
borderRadius: 0,
|
|
13
13
|
minHeight: "auto",
|
|
14
|
-
fontFamily: "Segoe UI",
|
|
14
|
+
fontFamily: "'Segoe UI', 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji', Arial, sans-serif",
|
|
15
15
|
lineHeight: "16px",
|
|
16
16
|
padding: "0px 10px 0 10px"
|
|
17
17
|
};
|
|
@@ -5,59 +5,127 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createCitationsMiddleware = void 0;
|
|
7
7
|
var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
|
|
8
|
+
var _LiveChatWidgetActionType = require("../../../../../contexts/common/LiveChatWidgetActionType");
|
|
8
9
|
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
var _createReducer = require("../../../../../contexts/createReducer");
|
|
11
|
+
// Middleware that extracts citation metadata from incoming ACS activities and
|
|
12
|
+
// updates in-memory app state with a global citation map. Also rewrites
|
|
13
|
+
// per-message citation labels in the activity text to use a stable,
|
|
14
|
+
// message-scoped prefix when the producer provides a message id.
|
|
15
|
+
|
|
16
|
+
const createCitationsMiddleware = (state, dispatch) => () => next => action => {
|
|
17
|
+
var _action$payload;
|
|
18
|
+
if ((_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
|
|
19
|
+
if (isApplicable(action)) {
|
|
20
|
+
try {
|
|
21
|
+
var _action$payload2, _action$payload2$acti, _gptFeedback$summariz, _gptFeedback$summariz2;
|
|
22
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
23
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
24
|
+
payload: null
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Use the producer-supplied messageid as a stable per-message prefix
|
|
28
|
+
// when present. Do not derive a prefix from activity.id or timestamps.
|
|
29
|
+
const messagePrefix = ((_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.messageid) ?? "";
|
|
30
|
+
const gptFeedback = JSON.parse(action.payload.activity.channelData.metadata["pva:gpt-feedback"]);
|
|
31
|
+
// Extract citation objects from the model response
|
|
32
|
+
const citations = (_gptFeedback$summariz = gptFeedback.summarizationOpenAIResponse) === null || _gptFeedback$summariz === void 0 ? void 0 : (_gptFeedback$summariz2 = _gptFeedback$summariz.result) === null || _gptFeedback$summariz2 === void 0 ? void 0 : _gptFeedback$summariz2.textCitations;
|
|
33
|
+
// Rewrite inline citation labels in activity.text to match the global map keys
|
|
34
|
+
const updatedText = replaceCitations(action.payload.activity.text, citations, messagePrefix);
|
|
35
|
+
action.payload.activity.text = updatedText;
|
|
36
|
+
// Build a global citation map keyed by the prefixed citation id and
|
|
37
|
+
// dispatch it to app state so the UI container can render citations.
|
|
17
38
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
var _inMemoryState$domain;
|
|
40
|
+
const citationMap = {};
|
|
41
|
+
if (citations && Array.isArray(citations)) {
|
|
42
|
+
citations.forEach(citation => {
|
|
43
|
+
if (citation !== null && citation !== void 0 && citation.id) {
|
|
44
|
+
// Preserve the 'cite:' scheme so renderer click handling remains consistent
|
|
45
|
+
const idWithoutScheme = citation.id.replace(/^cite:/, "");
|
|
46
|
+
const prefixedId = `cite:${messagePrefix}_${idWithoutScheme}`;
|
|
47
|
+
citationMap[prefixedId] = citation.text || citation.title || "";
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Read current in-memory state to merge with existing citations
|
|
53
|
+
//const inMemoryState = executeReducer(state, { type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE, payload: null });
|
|
54
|
+
const existingCitations = (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : _inMemoryState$domain.citations) || {};
|
|
55
|
+
const updatedCitations = {
|
|
56
|
+
...existingCitations,
|
|
57
|
+
...citationMap
|
|
58
|
+
};
|
|
59
|
+
// Always dispatch to app state
|
|
60
|
+
dispatch({
|
|
61
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CITATIONS,
|
|
62
|
+
payload: updatedCitations
|
|
63
|
+
});
|
|
64
|
+
} catch (innerErr) {
|
|
65
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
24
66
|
Event: _TelemetryConstants.TelemetryEvent.CitationMiddlewareFailed,
|
|
25
67
|
ExceptionDetails: {
|
|
26
|
-
ErrorData: "Error while
|
|
27
|
-
Exception:
|
|
68
|
+
ErrorData: "Error while populating citation map",
|
|
69
|
+
Exception: innerErr
|
|
28
70
|
}
|
|
29
71
|
});
|
|
30
72
|
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
75
|
+
Event: _TelemetryConstants.TelemetryEvent.CitationMiddlewareFailed,
|
|
76
|
+
ExceptionDetails: {
|
|
77
|
+
ErrorData: "Error while converting citation labels",
|
|
78
|
+
Exception: error
|
|
79
|
+
}
|
|
80
|
+
});
|
|
31
81
|
}
|
|
32
82
|
}
|
|
33
|
-
|
|
34
|
-
|
|
83
|
+
}
|
|
84
|
+
return next(action);
|
|
35
85
|
};
|
|
36
86
|
exports.createCitationsMiddleware = createCitationsMiddleware;
|
|
37
87
|
const isApplicable = action => {
|
|
38
|
-
var _action$
|
|
39
|
-
if ((action === null || action === void 0 ? void 0 : (_action$
|
|
40
|
-
var _action$
|
|
41
|
-
//
|
|
42
|
-
if (action !== null && action !== void 0 && (_action$
|
|
88
|
+
var _action$payload3, _action$payload3$acti, _action$payload4, _action$payload4$acti;
|
|
89
|
+
if ((action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : _action$payload3$acti.actionType) === "DIRECT_LINE/INCOMING_ACTIVITY" && (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : _action$payload4$acti.channelId) === "ACS_CHANNEL") {
|
|
90
|
+
var _action$payload5, _action$payload5$acti, _action$payload5$acti2, _action$payload5$acti3;
|
|
91
|
+
// Only applicable for ACS incoming activities that include pva:gpt-feedback
|
|
92
|
+
if (action !== null && action !== void 0 && (_action$payload5 = action.payload) !== null && _action$payload5 !== void 0 && (_action$payload5$acti = _action$payload5.activity) !== null && _action$payload5$acti !== void 0 && (_action$payload5$acti2 = _action$payload5$acti.channelData) !== null && _action$payload5$acti2 !== void 0 && (_action$payload5$acti3 = _action$payload5$acti2.metadata) !== null && _action$payload5$acti3 !== void 0 && _action$payload5$acti3["pva:gpt-feedback"]) {
|
|
43
93
|
return true;
|
|
44
94
|
}
|
|
45
95
|
}
|
|
46
96
|
return false;
|
|
47
97
|
};
|
|
48
|
-
const replaceCitations = (text, citations) => {
|
|
98
|
+
const replaceCitations = (text, citations, messagePrefix) => {
|
|
49
99
|
if (!citations || !Array.isArray(citations)) {
|
|
50
100
|
return text;
|
|
51
101
|
}
|
|
52
102
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
103
|
+
let updatedText = text;
|
|
104
|
+
|
|
105
|
+
// First, handle the citation reference definitions at the end (e.g., [1]: cite:1757450535119_1 "index.html")
|
|
106
|
+
// These should NOT be escaped as they are proper citation definitions
|
|
107
|
+
updatedText = updatedText.replace(/\[(\d+)\]:\s(cite:\d+)\s"([^\\"]+)"/g, (match, number, citeId) => {
|
|
108
|
+
// Attempt to find a citation object matching the inline cite id and
|
|
109
|
+
// update the displayed id/title. When a messagePrefix exists we
|
|
110
|
+
// rewrite the id to the prefixed form so it aligns with the
|
|
111
|
+
// global citation map keys.
|
|
112
|
+
const lookupId = citeId;
|
|
113
|
+
const citation = citations.find(c => c.id === lookupId);
|
|
55
114
|
if (citation) {
|
|
56
|
-
|
|
57
|
-
|
|
115
|
+
const idWithoutScheme = citeId.replace(/^cite:/, "");
|
|
116
|
+
const prefixed = messagePrefix ? `cite:${messagePrefix}_${idWithoutScheme}` : citeId;
|
|
117
|
+
return `[${number}]: ${prefixed} "${citation.title}"`;
|
|
58
118
|
}
|
|
59
|
-
return match;
|
|
119
|
+
return match;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Second, escape inline citation references that are NOT followed by a colon
|
|
123
|
+
// This handles cases like "[1][2]"" in the middle of text that should be escaped for markdown
|
|
124
|
+
updatedText = updatedText.replace(/\[(\d+)\](?!:)/g, (match, number) => {
|
|
125
|
+
// Escape the brackets to prevent markdown from treating them as incomplete link syntax
|
|
126
|
+
return `[${number}]`;
|
|
60
127
|
});
|
|
128
|
+
return updatedText;
|
|
61
129
|
} catch (error) {
|
|
62
130
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
63
131
|
Event: _TelemetryConstants.TelemetryEvent.CitationMiddlewareFailed,
|
|
@@ -66,7 +134,6 @@ const replaceCitations = (text, citations) => {
|
|
|
66
134
|
Exception: error
|
|
67
135
|
}
|
|
68
136
|
});
|
|
69
|
-
// Return the original text in case of issues
|
|
70
137
|
return text;
|
|
71
138
|
}
|
|
72
139
|
};
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createQueueOverflowMiddleware = void 0;
|
|
7
|
-
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
8
7
|
var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
|
|
9
|
-
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
10
8
|
var _LiveChatWidgetActionType = require("../../../../../contexts/common/LiveChatWidgetActionType");
|
|
9
|
+
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
10
|
+
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
11
11
|
var _createReducer = require("../../../../../contexts/createReducer");
|
|
12
12
|
var _utils = require("../../../../../common/utils");
|
|
13
13
|
const queueOverflowHandlingHelper = async (state, dispatch) => {
|