@xapp/chat-widget 1.79.1 → 1.81.0
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/dist/components/AdminBar/AdminBar.d.ts +0 -0
- package/dist/components/CardContainer/CardContainer.d.ts +0 -0
- package/dist/components/ChatActionButtons/ChatActionButton.d.ts +0 -0
- package/dist/components/ChatActionButtons/ChatActionButtons.d.ts +0 -0
- package/dist/components/ChatFooter/ChatFooter.d.ts +0 -0
- package/dist/components/ChatMedia/ChatMedia.d.ts +1 -1
- package/dist/components/ChatMessage/ChatMessage.d.ts +0 -0
- package/dist/components/ChatMessagePart/ChatMessagePart.d.ts +0 -0
- package/dist/components/ChatRating/ChatRating.d.ts +0 -0
- package/dist/components/Icons/CloseIcon.d.ts +0 -0
- package/dist/components/Icons/LeftDownArrowIcon.d.ts +0 -0
- package/dist/components/Icons/SendIcon.d.ts +0 -0
- package/dist/components/Input/Input.d.ts +0 -0
- package/dist/components/MessageList/MessageList.d.ts +0 -0
- package/dist/components/MessageSvg/MessageSvg.d.ts +0 -0
- package/dist/components/QueuePosition/QueuePosition.d.ts +0 -0
- package/dist/components/ServerOffline/ServerOffline.d.ts +0 -0
- package/dist/components/Suggestions/Suggestions.d.ts +0 -0
- package/dist/components/UknownMessage/UnknownMessage.d.ts +0 -0
- package/dist/components/WsButton/WsButton.d.ts +0 -0
- package/dist/components/WsButton/constants.d.ts +0 -0
- package/dist/components/WsButton/index.d.ts +0 -0
- package/dist/index.css +1 -1
- package/dist/index.es.js +1752 -772
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1896 -916
- package/dist/index.js.map +1 -1
- package/dist/store/ChatAction.d.ts +0 -0
- package/dist/store/ChatState.d.ts +0 -0
- package/dist/store/actions/dismissWsButton.d.ts +0 -0
- package/dist/store/actions/displayWsButton.d.ts +0 -0
- package/dist/store/actions/index.d.ts +0 -0
- package/dist/storybook/store.d.ts +2 -2
- package/dist/xapp/ChatServer.d.ts +0 -0
- package/dist/xapp/LogChat.d.ts +0 -0
- package/dist/xapp/StentorRouterChat.d.ts +0 -0
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +4 -4
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +30 -22
- package/dist/components/ActionButton/ActionButton.stories.d.ts +0 -5
- package/dist/components/ActionButton/ActionButton.test.d.ts +0 -1
- package/dist/components/ActionItem/ActionItem.stories.d.ts +0 -6
- package/dist/components/ActionItem/ActionItem.test.d.ts +0 -1
- package/dist/components/Avatar/Avatar.stories.d.ts +0 -9
- package/dist/components/Avatar/Avatar.test.d.ts +0 -1
- package/dist/components/CardContainer/CardContainer.stories.d.ts +0 -5
- package/dist/components/CardContainer/CardContainer.test.d.ts +0 -1
- package/dist/components/Carousel/Carousel.stories.d.ts +0 -6
- package/dist/components/Carousel/Carousel.test.d.ts +0 -1
- package/dist/components/CarouselItem/CarouselItem.stories.d.ts +0 -9
- package/dist/components/CarouselItem/CarouselItem.test.d.ts +0 -1
- package/dist/components/ChatActionButtons/ChatActionButton.stories.d.ts +0 -5
- package/dist/components/ChatActionButtons/ChatActionButton.test.d.ts +0 -1
- package/dist/components/ChatActionButtons/ChatActionButtons.stories.d.ts +0 -5
- package/dist/components/ChatActionButtons/ChatActionButtons.test.d.ts +0 -1
- package/dist/components/ChatBranding/ChatBranding.stories.d.ts +0 -5
- package/dist/components/ChatButton/ChatButton.stories.d.ts +0 -23
- package/dist/components/ChatButton/ChatButton.test.d.ts +0 -1
- package/dist/components/ChatCard/ChatCard.stories.d.ts +0 -7
- package/dist/components/ChatChip/ChatChip.stories.d.ts +0 -6
- package/dist/components/ChatChip/ChatChip.test.d.ts +0 -1
- package/dist/components/ChatChips/ChatChips.stories.d.ts +0 -6
- package/dist/components/ChatChips/ChatChips.test.d.ts +0 -1
- package/dist/components/ChatFooter/ChatFooter.stories.d.ts +0 -11
- package/dist/components/ChatFooter/ChatFooter.test.d.ts +0 -1
- package/dist/components/ChatHeader/ChatHeader.stories.d.ts +0 -14
- package/dist/components/ChatHeader/ChatHeader.test.d.ts +0 -1
- package/dist/components/ChatImage/ChatImage.stories.d.ts +0 -5
- package/dist/components/ChatImage/ChatImage.test.d.ts +0 -1
- package/dist/components/ChatMarkdownMessage/ChatMarkdownMessage.stories.d.ts +0 -5
- package/dist/components/ChatMedia/ChatMedia.stories.d.ts +0 -6
- package/dist/components/ChatMedia/ChatMedia.test.d.ts +0 -1
- package/dist/components/ChatMenu/ChatMenu.stories.d.ts +0 -10
- package/dist/components/ChatMenu/ChatMenu.test.d.ts +0 -1
- package/dist/components/ChatMessage/ChatMessage.stories.d.ts +0 -20
- package/dist/components/ChatMessageBubble/ChatMessageBubble.stories.d.ts +0 -8
- package/dist/components/ChatMessageBubble/ChatMessageBubble.test.d.ts +0 -1
- package/dist/components/ChatMessagePart/ChatMessagePart.test.d.ts +0 -1
- package/dist/components/ChatRating/ChatRating.stories.d.ts +0 -6
- package/dist/components/ChatRating/ChatRating.test.d.ts +0 -1
- package/dist/components/ChatWidget/ChatWidget.stories.d.ts +0 -56
- package/dist/components/ChatWidget/ChatWidget.test.d.ts +0 -1
- package/dist/components/ChatWidget/ChatWidgetEnv.stories.d.ts +0 -11
- package/dist/components/ChatWidget/StaticChatWidgetContainer.stories.d.ts +0 -5
- package/dist/components/ChatWidget/StaticMessagesChatWidgetContainer.stories.d.ts +0 -5
- package/dist/components/ChevronLeft/ChevronLeft.stories.d.ts +0 -5
- package/dist/components/ChevronRight/ChevronRight.stories.d.ts +0 -5
- package/dist/components/CtaBubble/CtaBubble.stories.d.ts +0 -12
- package/dist/components/DrawerBars/DrawerBars.stories.d.ts +0 -6
- package/dist/components/DrawerBars/DrawerBars.test.d.ts +0 -1
- package/dist/components/ErrorOverlay/ErrorOverlay.stories.d.ts +0 -8
- package/dist/components/ExternalLink/ExternalLink.stories.d.ts +0 -7
- package/dist/components/FailureMessage/FailureMessage.stories.d.ts +0 -5
- package/dist/components/Icons/Icons.stories.d.ts +0 -5
- package/dist/components/Input/Input.stories.d.ts +0 -10
- package/dist/components/Input/Input.test.d.ts +0 -1
- package/dist/components/List/List.stories.d.ts +0 -8
- package/dist/components/List/List.test.d.ts +0 -1
- package/dist/components/ListItem/ListItem.stories.d.ts +0 -9
- package/dist/components/ListItem/ListItem.test.d.ts +0 -1
- package/dist/components/MessageForm/MessageForm.stories.d.ts +0 -7
- package/dist/components/MessageForm/MessageForm.test.d.ts +0 -1
- package/dist/components/MessageList/MessageList.stories.d.ts +0 -7
- package/dist/components/MessageList/MessageList.test.d.ts +0 -1
- package/dist/components/MessageSvg/MessageSvg.stories.d.ts +0 -5
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -5
- package/dist/components/OfflineForm/OfflineForm.stories.d.ts +0 -5
- package/dist/components/OfflineForm/OfflineForm.test.d.ts +0 -1
- package/dist/components/OptionalLink/OptionalLink.stories.d.ts +0 -6
- package/dist/components/PrechatForm/PrechatForm.stories.d.ts +0 -5
- package/dist/components/PrechatForm/PrechatForm.test.d.ts +0 -1
- package/dist/components/QueuePosition/QueuePosition.stories.d.ts +0 -5
- package/dist/components/QueuePosition/QueuePosition.test.d.ts +0 -1
- package/dist/components/SendButton/SendButton.stories.d.ts +0 -9
- package/dist/components/SendButton/SendButton.test.d.ts +0 -1
- package/dist/components/SmartLink/utils.test.d.ts +0 -1
- package/dist/components/Suggestions/Suggestions.stories.d.ts +0 -6
- package/dist/components/SystemMessage/SystemMessage.stories.d.ts +0 -8
- package/dist/components/SystemMessage/SystemMessage.test.d.ts +0 -1
- package/dist/components/TypingIndicator/TypingIndicator.stories.d.ts +0 -6
- package/dist/components/TypingStatus/TypingStatus.stories.d.ts +0 -6
- package/dist/components/TypingStatus/TypingStatus.test.d.ts +0 -1
- package/dist/components/WidgetStylesheet/WidgetStylesheet.stories.d.ts +0 -5
- package/dist/config/getBasePath.test.d.ts +0 -1
- package/dist/middlewares/join.test.d.ts +0 -1
- package/dist/store/reducers/memberJoin.test.d.ts +0 -1
- package/dist/store/reducers/memberLeave.test.d.ts +0 -1
- package/dist/tests/App.test.d.ts +0 -1
- package/dist/utils/PersistentStorage.test.d.ts +0 -1
- package/dist/utils/__tests__/configurableMessages.test.d.ts +0 -1
- package/dist/utils/__tests__/insertSorted.test.d.ts +0 -1
- package/dist/utils/__tests__/responseToMessage.test.d.ts +0 -1
- package/dist/utils/deepMerge.test.d.ts +0 -1
- package/dist/utils/insertSorted.test.d.ts +0 -1
- package/dist/utils/nick-utils.test.d.ts +0 -1
- package/dist/utils/parseEnv.test.d.ts +0 -1
- package/dist/utils/resolveUrlPolicy.test.d.ts +0 -1
- package/dist/xapp/__tests__/StentorRouterChat.test.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var require$$1 = require('react');
|
|
4
|
+
var require$$0 = require('react/jsx-runtime');
|
|
4
5
|
var reactRedux = require('react-redux');
|
|
5
6
|
|
|
6
7
|
var ActionButton = function (_a) {
|
|
@@ -11,45 +12,9 @@ var ActionButton = function (_a) {
|
|
|
11
12
|
onClick(label);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
return (
|
|
15
|
+
return (require$$0.jsx("button", { disabled: disable, type: type, className: "action-button ".concat(addClass), onClick: handleClick, children: label }));
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
var defaultServerUrl = "";
|
|
18
|
-
var defaultWidgetButtonWidth = "48";
|
|
19
|
-
var defaultMobileWidgetButtonWidth = "30";
|
|
20
|
-
var defaultNonMobileScreenWidth = "400";
|
|
21
|
-
var scheduleWidgetUrl = "ScheduleButton";
|
|
22
|
-
var ChatConfigContext = React$1.createContext(null);
|
|
23
|
-
function useWidgetEnv() {
|
|
24
|
-
var ctx = React$1.useContext(ChatConfigContext);
|
|
25
|
-
return ctx === null || ctx === void 0 ? void 0 : ctx.env;
|
|
26
|
-
}
|
|
27
|
-
function getServerConfig(env) {
|
|
28
|
-
if (env === null || env === void 0 ? void 0 : env.connection) {
|
|
29
|
-
return env.connection;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
serverUrl: env === null || env === void 0 ? void 0 : env.serverUrl,
|
|
33
|
-
accountKey: env === null || env === void 0 ? void 0 : env.accountKey,
|
|
34
|
-
type: (env === null || env === void 0 ? void 0 : env.direct) ? "direct" : "websocket",
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function useServerConfig(env, nonce) {
|
|
38
|
-
var connection = getServerConfig(env);
|
|
39
|
-
var accountKey = connection.accountKey, serverUrl = connection.serverUrl, type = connection.type, timeout = connection.timeout;
|
|
40
|
-
return React$1.useMemo(function () { return ({
|
|
41
|
-
accountKey: accountKey,
|
|
42
|
-
serverUrl: serverUrl,
|
|
43
|
-
timeout: timeout,
|
|
44
|
-
type: type,
|
|
45
|
-
nonce: nonce,
|
|
46
|
-
}); }, [accountKey, serverUrl, timeout, type, nonce]);
|
|
47
|
-
}
|
|
48
|
-
function useConnectionInfo(env) {
|
|
49
|
-
var nonce = reactRedux.useSelector(function (state) { return state.connection.nonce; });
|
|
50
|
-
return useServerConfig(env, nonce);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
18
|
/******************************************************************************
|
|
54
19
|
Copyright (c) Microsoft Corporation.
|
|
55
20
|
|
|
@@ -204,14 +169,14 @@ function isAgent(nick) {
|
|
|
204
169
|
}
|
|
205
170
|
|
|
206
171
|
function useIsMounted() {
|
|
207
|
-
var ref =
|
|
208
|
-
|
|
172
|
+
var ref = require$$1.useRef(false);
|
|
173
|
+
require$$1.useEffect(function () {
|
|
209
174
|
ref.current = true;
|
|
210
175
|
return function () {
|
|
211
176
|
ref.current = false;
|
|
212
177
|
};
|
|
213
178
|
}, []);
|
|
214
|
-
return
|
|
179
|
+
return require$$1.useCallback(function () { return ref.current; }, []);
|
|
215
180
|
}
|
|
216
181
|
|
|
217
182
|
var RetryOptions = /** @class */ (function () {
|
|
@@ -313,20 +278,39 @@ if (storedLogLevel) {
|
|
|
313
278
|
window.xaLogLevel = storedLogLevel;
|
|
314
279
|
}
|
|
315
280
|
// Override the setter to persist to localStorage
|
|
316
|
-
Object.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
281
|
+
if (!Object.getOwnPropertyDescriptor(window, "xaLogLevel")) {
|
|
282
|
+
Object.defineProperty(window, "xaLogLevel", {
|
|
283
|
+
get: function () {
|
|
284
|
+
return this._xaLogLevel;
|
|
285
|
+
},
|
|
286
|
+
set: function (value) {
|
|
287
|
+
this._xaLogLevel = value;
|
|
288
|
+
if (value) {
|
|
289
|
+
localStorage.setItem(STORAGE_KEY, value);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
// Create a namespaced API on window.xapp for easier access
|
|
298
|
+
if (typeof window !== 'undefined') {
|
|
299
|
+
window.xapp = window.xapp || {};
|
|
300
|
+
window.xapp.setLogLevel = function (level) {
|
|
301
|
+
if (level === 'off') {
|
|
302
|
+
window.xaLogLevel = null;
|
|
303
|
+
console.log('Log level set to: off (logs disabled)');
|
|
324
304
|
}
|
|
325
305
|
else {
|
|
326
|
-
|
|
306
|
+
window.xaLogLevel = level;
|
|
307
|
+
console.log("Log level set to: ".concat(level));
|
|
327
308
|
}
|
|
328
|
-
}
|
|
329
|
-
|
|
309
|
+
};
|
|
310
|
+
window.xapp.getLogLevel = function () {
|
|
311
|
+
return window.xaLogLevel || 'off';
|
|
312
|
+
};
|
|
313
|
+
}
|
|
330
314
|
// Returns current timestamp
|
|
331
315
|
function getCurrentDateString() {
|
|
332
316
|
return (new Date()).toISOString() + " ::";
|
|
@@ -359,12 +343,49 @@ var logOnce = function (key) {
|
|
|
359
343
|
}
|
|
360
344
|
};
|
|
361
345
|
|
|
346
|
+
var defaultServerUrl = "";
|
|
347
|
+
var defaultWidgetButtonWidth = "48";
|
|
348
|
+
var defaultMobileWidgetButtonWidth = "30";
|
|
349
|
+
var defaultNonMobileScreenWidth = "400";
|
|
350
|
+
var scheduleWidgetUrl = "ScheduleButton";
|
|
351
|
+
var ChatConfigContext = require$$1.createContext(null);
|
|
352
|
+
function useWidgetEnv() {
|
|
353
|
+
var ctx = require$$1.useContext(ChatConfigContext);
|
|
354
|
+
return ctx === null || ctx === void 0 ? void 0 : ctx.env;
|
|
355
|
+
}
|
|
356
|
+
function getServerConfig(env) {
|
|
357
|
+
if (env === null || env === void 0 ? void 0 : env.connection) {
|
|
358
|
+
return env.connection;
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
serverUrl: env === null || env === void 0 ? void 0 : env.serverUrl,
|
|
362
|
+
accountKey: env === null || env === void 0 ? void 0 : env.accountKey,
|
|
363
|
+
type: (env === null || env === void 0 ? void 0 : env.direct) ? "direct" : "websocket",
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function useServerConfig(env, nonce) {
|
|
367
|
+
var connection = getServerConfig(env);
|
|
368
|
+
var accountKey = connection.accountKey, serverUrl = connection.serverUrl, type = connection.type, timeout = connection.timeout;
|
|
369
|
+
return require$$1.useMemo(function () { return ({
|
|
370
|
+
accountKey: accountKey,
|
|
371
|
+
serverUrl: serverUrl,
|
|
372
|
+
timeout: timeout,
|
|
373
|
+
type: type,
|
|
374
|
+
nonce: nonce,
|
|
375
|
+
}); }, [accountKey, serverUrl, timeout, type, nonce]);
|
|
376
|
+
}
|
|
377
|
+
function useConnectionInfo(env) {
|
|
378
|
+
var nonce = reactRedux.useSelector(function (state) { return state.connection.nonce; });
|
|
379
|
+
log("nonce from Redux: ".concat(nonce));
|
|
380
|
+
return useServerConfig(env, nonce);
|
|
381
|
+
}
|
|
382
|
+
|
|
362
383
|
var Avatar = function (props) {
|
|
363
384
|
var _a, _b;
|
|
364
385
|
var style = {};
|
|
365
386
|
var child;
|
|
366
387
|
var entity = props.entity;
|
|
367
|
-
var chatConfig =
|
|
388
|
+
var chatConfig = require$$1.useContext(ChatConfigContext);
|
|
368
389
|
var avatarPath = entity === null || entity === void 0 ? void 0 : entity.avatarPath;
|
|
369
390
|
if (!avatarPath) {
|
|
370
391
|
var avatarImage = GenerateAvatar({
|
|
@@ -383,22 +404,21 @@ var Avatar = function (props) {
|
|
|
383
404
|
child = getVisitorSvg();
|
|
384
405
|
}
|
|
385
406
|
var hasImage = !!style.backgroundImage || !!child;
|
|
386
|
-
return (
|
|
407
|
+
return (require$$0.jsx("div", { className: "avatar ".concat(agentAva ? "avatar--agent" : "avatar--visitor", " ").concat(!hasImage ? "avatar--empty" : ""), style: style, title: entity ? entity.display_name : "Agent", children: child }));
|
|
387
408
|
};
|
|
388
409
|
/**
|
|
389
410
|
* Generates an SVG based on the
|
|
390
411
|
* @returns
|
|
391
412
|
*/
|
|
392
413
|
function getVisitorSvg() {
|
|
393
|
-
return (
|
|
394
|
-
React$1.createElement("path", { d: "M11.5 5c0-1.933-1.567-3.5-3.5-3.5S4.5 3.067 4.5 5 6.067 8.5 8 8.5s3.5-1.567 3.5-3.5zM3 5c0-2.76 2.24-5 5-5s5 2.24 5 5-2.24 5-5 5-5-2.24-5-5zM1.955 17.294c.21-.642.504-1.285.898-1.88C3.963 13.74 5.615 12.75 8 12.75c2.385 0 4.038.99 5.147 2.664.394.595.69 1.238.898 1.88.124.382.19.672.214.822.063.41.447.69.856.625.41-.063.69-.447.625-.856-.034-.225-.118-.59-.27-1.053-.247-.763-.598-1.527-1.073-2.244C13.024 12.51 10.917 11.25 8 11.25c-2.916 0-5.024 1.26-6.397 3.336-.475.717-.826 1.48-1.074 2.245-.152.463-.236.83-.27 1.054-.065.41.215.793.624.857.41.065.793-.215.857-.624.025-.15.09-.44.215-.822z", fill: "#FFF", fillRule: "evenodd" })));
|
|
414
|
+
return (require$$0.jsx("svg", { width: "16", height: "19", viewBox: "0 0 16 19", style: { margin: "0 auto", display: "block" }, children: require$$0.jsx("path", { d: "M11.5 5c0-1.933-1.567-3.5-3.5-3.5S4.5 3.067 4.5 5 6.067 8.5 8 8.5s3.5-1.567 3.5-3.5zM3 5c0-2.76 2.24-5 5-5s5 2.24 5 5-2.24 5-5 5-5-2.24-5-5zM1.955 17.294c.21-.642.504-1.285.898-1.88C3.963 13.74 5.615 12.75 8 12.75c2.385 0 4.038.99 5.147 2.664.394.595.69 1.238.898 1.88.124.382.19.672.214.822.063.41.447.69.856.625.41-.063.69-.447.625-.856-.034-.225-.118-.59-.27-1.053-.247-.763-.598-1.527-1.073-2.244C13.024 12.51 10.917 11.25 8 11.25c-2.916 0-5.024 1.26-6.397 3.336-.475.717-.826 1.48-1.074 2.245-.152.463-.236.83-.27 1.054-.065.41.215.793.624.857.41.065.793-.215.857-.624.025-.15.09-.44.215-.822z", fill: "#FFF", fillRule: "evenodd" }) }));
|
|
395
415
|
}
|
|
396
416
|
function GenerateAvatar(props) {
|
|
397
417
|
var initials = (props === null || props === void 0 ? void 0 : props.initials) || "?";
|
|
398
418
|
var size = (props === null || props === void 0 ? void 0 : props.size) || 40;
|
|
399
419
|
var backgroundColor = (props === null || props === void 0 ? void 0 : props.backgroundColor) || "#007bff";
|
|
400
420
|
var textColor = (props === null || props === void 0 ? void 0 : props.textColor) || "#ffffff";
|
|
401
|
-
var image =
|
|
421
|
+
var image = require$$1.useMemo(function () {
|
|
402
422
|
return generateImage(initials, size, backgroundColor, textColor);
|
|
403
423
|
}, [initials, size, backgroundColor, textColor]);
|
|
404
424
|
return image;
|
|
@@ -444,16 +464,16 @@ var OptionalLink = function (props) {
|
|
|
444
464
|
var chatDispatch = useChatDispatch();
|
|
445
465
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
446
466
|
var url = props.url, className = props.className, onOpen = props.onOpen;
|
|
447
|
-
var handleOpenUrl =
|
|
467
|
+
var handleOpenUrl = require$$1.useCallback(function () {
|
|
448
468
|
if (onOpen) {
|
|
449
469
|
onOpen(url, chatDispatch, visuals);
|
|
450
470
|
}
|
|
451
471
|
}, [url, onOpen]);
|
|
452
472
|
if (url) {
|
|
453
|
-
return (
|
|
473
|
+
return (require$$0.jsx("div", { onClick: handleOpenUrl, className: className, children: props.children }));
|
|
454
474
|
}
|
|
455
475
|
else {
|
|
456
|
-
return (
|
|
476
|
+
return (require$$0.jsx("div", { onClick: props.onClick, className: className, children: props.children }));
|
|
457
477
|
}
|
|
458
478
|
};
|
|
459
479
|
|
|
@@ -461,7 +481,7 @@ var ActionItem = function (props) {
|
|
|
461
481
|
var _a;
|
|
462
482
|
var item = props.item, onButtonClick = props.onButtonClick, onExecute = props.onExecute;
|
|
463
483
|
var singleButton = ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) === 1;
|
|
464
|
-
var handleClick =
|
|
484
|
+
var handleClick = require$$1.useCallback(function () {
|
|
465
485
|
var _a;
|
|
466
486
|
var btns = (_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length;
|
|
467
487
|
// If there is only one button, it takes precedent
|
|
@@ -474,17 +494,17 @@ var ActionItem = function (props) {
|
|
|
474
494
|
}
|
|
475
495
|
}, [item, onExecute, onButtonClick]);
|
|
476
496
|
var className = "xappw-chat-action-item ".concat(singleButton ? "xappw-chat-action-item--action" : "", " ").concat(props.className);
|
|
477
|
-
return (
|
|
497
|
+
return (require$$0.jsx(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl, children: props.children }));
|
|
478
498
|
};
|
|
479
499
|
|
|
480
500
|
var ChatImage = function (props) {
|
|
481
501
|
var cleanUrl = props.imageUrl.replace(/'/g, "%27");
|
|
482
|
-
var content =
|
|
502
|
+
var content = (require$$0.jsx("div", { className: "chat-card-img__content", style: { backgroundImage: "url(".concat(cleanUrl, ")") } }));
|
|
483
503
|
if (!props.imageActionUrl) {
|
|
484
|
-
return
|
|
504
|
+
return require$$0.jsx("div", { className: "chat-card-img", children: content });
|
|
485
505
|
}
|
|
486
506
|
else {
|
|
487
|
-
return (
|
|
507
|
+
return (require$$0.jsx("a", { href: props.imageActionUrl, "aria-label": "read more", target: "_blank", rel: "noopener noreferrer", className: "chat-card-img", children: content }));
|
|
488
508
|
}
|
|
489
509
|
};
|
|
490
510
|
|
|
@@ -495,63 +515,53 @@ var ActionItemImage = function (props) {
|
|
|
495
515
|
var itemUrl = getItemUrl(item);
|
|
496
516
|
if (item.imageUrl) {
|
|
497
517
|
var imageActionUrl = !singleButton ? item.imageActionUrl : null;
|
|
498
|
-
return (
|
|
499
|
-
React$1.createElement(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl })));
|
|
518
|
+
return (require$$0.jsx("div", { className: props.className, children: require$$0.jsx(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl }) }));
|
|
500
519
|
}
|
|
501
520
|
else if (props.emptyImageVisible) {
|
|
502
|
-
return
|
|
521
|
+
return require$$0.jsx("div", { className: props.className });
|
|
503
522
|
}
|
|
504
|
-
return
|
|
523
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
505
524
|
};
|
|
506
525
|
|
|
507
526
|
var ChatActionButtonInner = function (props) {
|
|
508
527
|
var button = props.button, onClick = props.onClick;
|
|
509
|
-
var handleButton =
|
|
528
|
+
var handleButton = require$$1.useCallback(function () {
|
|
510
529
|
onClick(button);
|
|
511
530
|
}, [button, onClick]);
|
|
512
|
-
return
|
|
531
|
+
return require$$0.jsx(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label });
|
|
513
532
|
};
|
|
514
|
-
var ChatActionButton =
|
|
533
|
+
var ChatActionButton = require$$1.memo(ChatActionButtonInner);
|
|
515
534
|
|
|
516
535
|
var ChatActionButtonsInner = function (props) {
|
|
517
|
-
return (
|
|
518
|
-
|
|
519
|
-
|
|
536
|
+
return (require$$0.jsx("div", { className: "buttons-container " + (props.className || ""), children: props.buttons.map(function (button, i) {
|
|
537
|
+
return require$$0.jsx(ChatActionButton, { button: button, onClick: props.onClick }, i);
|
|
538
|
+
}) }));
|
|
520
539
|
};
|
|
521
|
-
var ChatActionButtons =
|
|
540
|
+
var ChatActionButtons = require$$1.memo(ChatActionButtonsInner);
|
|
522
541
|
|
|
523
542
|
var CarouselItem = function (props) {
|
|
524
543
|
var _a;
|
|
525
544
|
var item = props.item;
|
|
526
|
-
return (
|
|
527
|
-
React$1.createElement("div", { className: "chat-list-item" },
|
|
528
|
-
React$1.createElement(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }),
|
|
529
|
-
item.title && React$1.createElement("div", { className: "chat-list-item__title" },
|
|
530
|
-
React$1.createElement("span", null, item.title)),
|
|
531
|
-
item.subTitle && React$1.createElement("div", { className: "chat-list-item__subtitle" },
|
|
532
|
-
React$1.createElement("span", null, item.subTitle)),
|
|
533
|
-
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { className: "chat-list-item__actions", buttons: item.buttons, onClick: props.onButtonClick }))));
|
|
545
|
+
return (require$$0.jsx(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl, children: require$$0.jsxs("div", { className: "chat-list-item", children: [require$$0.jsx(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }), item.title && (require$$0.jsx("div", { className: "chat-list-item__title", children: require$$0.jsx("span", { children: item.title }) })), item.subTitle && (require$$0.jsx("div", { className: "chat-list-item__subtitle", children: require$$0.jsx("span", { children: item.subTitle }) })), !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && (require$$0.jsx(ChatActionButtons, { className: "chat-list-item__actions", buttons: item.buttons, onClick: props.onButtonClick }))] }) }));
|
|
534
546
|
};
|
|
535
547
|
|
|
536
548
|
function getLeftArrowSvg() {
|
|
537
|
-
return (
|
|
538
|
-
React$1.createElement("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
549
|
+
return (require$$0.jsx("svg", { viewBox: "-5 -18 10 36", children: require$$0.jsx("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" }) }));
|
|
539
550
|
}
|
|
540
551
|
var ChevronLeft = function (props) {
|
|
541
|
-
return (
|
|
552
|
+
return (require$$0.jsx("button", { onClick: props.onClick, className: "xa-chevron", children: getLeftArrowSvg() }));
|
|
542
553
|
};
|
|
543
554
|
|
|
544
555
|
function getRightArrowSvg() {
|
|
545
|
-
return (
|
|
546
|
-
React$1.createElement("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
556
|
+
return (require$$0.jsx("svg", { viewBox: "-5 -18 10 36", children: require$$0.jsx("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" }) }));
|
|
547
557
|
}
|
|
548
558
|
var ChevronRight = function (props) {
|
|
549
|
-
return (
|
|
559
|
+
return (require$$0.jsx("button", { onClick: props.onClick, className: "xa-chevron", children: getRightArrowSvg() }));
|
|
550
560
|
};
|
|
551
561
|
|
|
552
562
|
var Carousel = function (props) {
|
|
553
|
-
var listRef =
|
|
554
|
-
var _a =
|
|
563
|
+
var listRef = require$$1.useRef(null);
|
|
564
|
+
var _a = require$$1.useState(0), visibleIndex = _a[0], setSetVisibleIndex = _a[1];
|
|
555
565
|
function scrollMe(direction) {
|
|
556
566
|
var _a, _b;
|
|
557
567
|
var scrollArea = listRef.current;
|
|
@@ -585,21 +595,15 @@ var Carousel = function (props) {
|
|
|
585
595
|
var hasOnlyOneItem = props.list.items.length === 1;
|
|
586
596
|
var hasImage = props.list.items.some(function (item) { return item.imageUrl; });
|
|
587
597
|
var listItems = props.list.items.map(function (item, itemIndex) {
|
|
588
|
-
return (
|
|
589
|
-
React$1.createElement(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
598
|
+
return (require$$0.jsx("div", { className: "xappw-carousel-items__item", children: require$$0.jsx(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl }) }, "item-key-".concat(itemIndex)));
|
|
590
599
|
});
|
|
591
|
-
return (
|
|
592
|
-
!hasOnlyOneItem && (React$1.createElement("div", { className: "xappw-carousel__prev" },
|
|
593
|
-
React$1.createElement(ChevronLeft, { onClick: function () { return scrollMe(-1); } }))),
|
|
594
|
-
React$1.createElement("div", { ref: listRef, className: "xappw-carousel-items ".concat(hasOnlyOneItem ? "xappw-carousel-items--one-item" : "") }, listItems),
|
|
595
|
-
!hasOnlyOneItem && (React$1.createElement("div", { className: "xappw-carousel__next" },
|
|
596
|
-
React$1.createElement(ChevronRight, { onClick: function () { return scrollMe(1); } })))));
|
|
600
|
+
return (require$$0.jsxs("div", { className: "xappw-carousel", children: [!hasOnlyOneItem && (require$$0.jsx("div", { className: "xappw-carousel__prev", children: require$$0.jsx(ChevronLeft, { onClick: function () { return scrollMe(-1); } }) })), require$$0.jsx("div", { ref: listRef, className: "xappw-carousel-items ".concat(hasOnlyOneItem ? "xappw-carousel-items--one-item" : ""), children: listItems }), !hasOnlyOneItem && (require$$0.jsx("div", { className: "xappw-carousel__next", children: require$$0.jsx(ChevronRight, { onClick: function () { return scrollMe(1); } }) }))] }));
|
|
597
601
|
};
|
|
598
602
|
|
|
599
603
|
function useDimensions() {
|
|
600
|
-
var ref =
|
|
601
|
-
var _a =
|
|
602
|
-
|
|
604
|
+
var ref = require$$1.useRef(null);
|
|
605
|
+
var _a = require$$1.useState(), dimensions = _a[0], setDimensions = _a[1];
|
|
606
|
+
require$$1.useLayoutEffect(function () {
|
|
603
607
|
var _a, _b;
|
|
604
608
|
setDimensions((_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.toJSON());
|
|
605
609
|
}, []);
|
|
@@ -695,9 +699,7 @@ var CtaBubbleTail = function (props) {
|
|
|
695
699
|
var _a, _b;
|
|
696
700
|
var _c = useDimensions(), ref = _c[0], rect = _c[1];
|
|
697
701
|
var viewPort = { x: (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0, y: (_b = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _b !== void 0 ? _b : 0 };
|
|
698
|
-
return (
|
|
699
|
-
React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y) },
|
|
700
|
-
React$1.createElement("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" }))));
|
|
702
|
+
return (require$$0.jsx("div", { ref: ref, className: "cta-bubble__tail", children: require$$0.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y), children: require$$0.jsx("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" }) }) }));
|
|
701
703
|
};
|
|
702
704
|
var CtaBubble = function (props) {
|
|
703
705
|
var _a, _b, _c, _d;
|
|
@@ -711,17 +713,12 @@ var CtaBubble = function (props) {
|
|
|
711
713
|
}
|
|
712
714
|
};
|
|
713
715
|
console.log("Returning CTABubble with message: ", props.children);
|
|
714
|
-
return (
|
|
716
|
+
return (require$$0.jsxs("div", { ref: ref, style: {
|
|
715
717
|
border: props.borderStyle ? "solid" : "none",
|
|
716
718
|
borderWidth: ((_a = props.borderStyle) === null || _a === void 0 ? void 0 : _a.width) || "0px",
|
|
717
719
|
borderColor: ((_b = props.borderStyle) === null || _b === void 0 ? void 0 : _b.color) || "transparent",
|
|
718
720
|
animation: "".concat(animation, " 1s infinite"),
|
|
719
|
-
}, className: "cta-bubble", onClick: props.onClick },
|
|
720
|
-
React$1.createElement(CtaBubbleTail, { width: (_c = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _c !== void 0 ? _c : 0, height: (_d = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _d !== void 0 ? _d : 0, direction: 60, angle: 45, length: 16 }),
|
|
721
|
-
React$1.createElement("div", { className: "cta-bubble__content" }, props.children),
|
|
722
|
-
props.dismissible && (React$1.createElement("button", { className: "cta-bubble__dismiss", onClick: handleDismiss, "aria-label": "Dismiss" },
|
|
723
|
-
React$1.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
724
|
-
React$1.createElement("path", { d: "M11 1L1 11M1 1L11 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }))))));
|
|
721
|
+
}, className: "cta-bubble", onClick: props.onClick, children: [require$$0.jsx(CtaBubbleTail, { width: (_c = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _c !== void 0 ? _c : 0, height: (_d = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _d !== void 0 ? _d : 0, direction: 60, angle: 45, length: 16 }), require$$0.jsx("div", { className: "cta-bubble__content", children: props.children }), props.dismissible && (require$$0.jsx("button", { className: "cta-bubble__dismiss", onClick: handleDismiss, "aria-label": "Dismiss", children: require$$0.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: require$$0.jsx("path", { d: "M11 1L1 11M1 1L11 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }));
|
|
725
722
|
};
|
|
726
723
|
|
|
727
724
|
var CtaBubbleContainer = function (props) {
|
|
@@ -739,14 +736,14 @@ var CtaBubbleContainer = function (props) {
|
|
|
739
736
|
hasChildren: !!children,
|
|
740
737
|
childrenContent: children,
|
|
741
738
|
});
|
|
742
|
-
var startTime =
|
|
739
|
+
var startTime = require$$1.useMemo(function () {
|
|
743
740
|
var time = visible ? new Date().valueOf() : undefined;
|
|
744
741
|
log("[CtaBubbleContainer] StartTime calculated: visible=".concat(visible, ", startTime=").concat(time));
|
|
745
742
|
return time;
|
|
746
743
|
}, [visible]);
|
|
747
|
-
var _a =
|
|
744
|
+
var _a = require$$1.useState(false), showBubble = _a[0], setShowBubble = _a[1];
|
|
748
745
|
log("[CtaBubbleContainer] Current state: showBubble=".concat(showBubble));
|
|
749
|
-
|
|
746
|
+
require$$1.useEffect(function () {
|
|
750
747
|
log("[CtaBubbleContainer] useEffect triggered with:", {
|
|
751
748
|
startTime: startTime,
|
|
752
749
|
startTimeExists: !!startTime,
|
|
@@ -816,14 +813,14 @@ var CtaBubbleContainer = function (props) {
|
|
|
816
813
|
// Final render decision
|
|
817
814
|
var shouldRender = visible && showBubble;
|
|
818
815
|
log("[CtaBubbleContainer] Render decision: visible=".concat(visible, ", showBubble=").concat(showBubble, ", shouldRender=").concat(shouldRender));
|
|
819
|
-
return (
|
|
816
|
+
return (require$$0.jsx(require$$0.Fragment, { children: visible && showBubble && (require$$0.jsx(CtaBubble, { onClick: onClick, animate: animate, buttonAnimation: buttonAnimation, dismissible: dismissible, onDismiss: handleDismiss, children: children })) }));
|
|
820
817
|
};
|
|
821
818
|
|
|
822
819
|
var ChatButton = function (_a) {
|
|
823
820
|
var _b;
|
|
824
821
|
var onClick = _a.onClick, addClass = _a.addClass, config = _a.config, visible = _a.visible, borderStyle = _a.borderStyle, imageUrl = _a.imageUrl, hasInteracted = _a.hasInteracted, onCtaDismiss = _a.onCtaDismiss;
|
|
825
|
-
var _c =
|
|
826
|
-
var _d =
|
|
822
|
+
var _c = require$$1.useState(defaultWidgetButtonWidth), buttonWidth = _c[0], setButtonWidth = _c[1];
|
|
823
|
+
var _d = require$$1.useState(false), animate = _d[0], setAnimate = _d[1];
|
|
827
824
|
var mobileWidth = ((_b = config === null || config === void 0 ? void 0 : config.mobile) === null || _b === void 0 ? void 0 : _b.applyAtLessThanWidth) || defaultNonMobileScreenWidth;
|
|
828
825
|
// Determines mobile or normal
|
|
829
826
|
var getConfigToApply = function () {
|
|
@@ -836,7 +833,7 @@ var ChatButton = function (_a) {
|
|
|
836
833
|
}
|
|
837
834
|
};
|
|
838
835
|
var configToApply = getConfigToApply();
|
|
839
|
-
|
|
836
|
+
require$$1.useEffect(function () {
|
|
840
837
|
var _a;
|
|
841
838
|
var delayTimer;
|
|
842
839
|
var timeoutTimer;
|
|
@@ -879,7 +876,7 @@ var ChatButton = function (_a) {
|
|
|
879
876
|
};
|
|
880
877
|
}, [configToApply, setAnimate, hasInteracted]);
|
|
881
878
|
var animation = animate && !hasInteracted ? (configToApply === null || configToApply === void 0 ? void 0 : configToApply.animation) || "wiggle" : "none";
|
|
882
|
-
|
|
879
|
+
require$$1.useEffect(function () {
|
|
883
880
|
var handleResize = function () {
|
|
884
881
|
var screenWidth = window.innerWidth;
|
|
885
882
|
var newButtonWidth = screenWidth < parseInt(mobileWidth, 10)
|
|
@@ -895,23 +892,19 @@ var ChatButton = function (_a) {
|
|
|
895
892
|
}, [mobileWidth]);
|
|
896
893
|
var maxSvgSize = 22;
|
|
897
894
|
var svgSize = Math.min(maxSvgSize, (+buttonWidth / +defaultWidgetButtonWidth) * maxSvgSize);
|
|
898
|
-
return (
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
React$1.createElement("svg", { width: svgSize, height: svgSize, viewBox: "0 0 22 22" },
|
|
912
|
-
React$1.createElement("path", { d: "M13 22l-4-6H2c-1.11-.043-2-.935-2-2V2C0 .89.89 0 2 0h18c1.11 0 2 .892 2 2v12c0 1.067-.89 1.957-2 2h-3l-4 6zm3-8h4c-.005.3-.01-12 0-12-.01.004-18 .006-18 0 .005.006 0 12 0 12h8l3 5 3-5z", fill: "#FFF", fillRule: "evenodd" })))),
|
|
913
|
-
configToApply && configToApply.message && !hasInteracted && (React$1.createElement("div", { className: "xapp-chat-button__cta" },
|
|
914
|
-
React$1.createElement(CtaBubbleContainer, { timeout: configToApply === null || configToApply === void 0 ? void 0 : configToApply.timeout, delay: configToApply === null || configToApply === void 0 ? void 0 : configToApply.delay, animate: animate, buttonAnimation: animation, dismissible: configToApply === null || configToApply === void 0 ? void 0 : configToApply.dismissible, visible: !visible /** Why is this !visible */, onDismiss: onCtaDismiss }, configToApply === null || configToApply === void 0 ? void 0 : configToApply.message)))));
|
|
895
|
+
return (require$$0.jsxs("button", { "aria-label": "open chat", className: "xapp-chat-button ".concat(addClass || "").trim(), onClick: onClick, children: [require$$0.jsx("div", { id: "xapp-widget-button", className: "xapp-chat-button__btn", style: {
|
|
896
|
+
width: "".concat(buttonWidth, "px"),
|
|
897
|
+
height: "".concat(buttonWidth, "px"),
|
|
898
|
+
borderRadius: "".concat(+buttonWidth / 2, "px"),
|
|
899
|
+
border: borderStyle && borderStyle.width ? "solid" : "none",
|
|
900
|
+
borderWidth: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.width) || "0px",
|
|
901
|
+
borderColor: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.color) || "transparent",
|
|
902
|
+
animation: "".concat(animation, " 1s infinite"),
|
|
903
|
+
}, children: imageUrl ? (
|
|
904
|
+
// Display image from URL
|
|
905
|
+
require$$0.jsx("img", { src: imageUrl, alt: "Chat Icon" })) : (
|
|
906
|
+
// Fallback to default SVG
|
|
907
|
+
require$$0.jsx("svg", { width: svgSize, height: svgSize, viewBox: "0 0 22 22", children: require$$0.jsx("path", { d: "M13 22l-4-6H2c-1.11-.043-2-.935-2-2V2C0 .89.89 0 2 0h18c1.11 0 2 .892 2 2v12c0 1.067-.89 1.957-2 2h-3l-4 6zm3-8h4c-.005.3-.01-12 0-12-.01.004-18 .006-18 0 .005.006 0 12 0 12h8l3 5 3-5z", fill: "#FFF", fillRule: "evenodd" }) })) }), configToApply && configToApply.message && !hasInteracted && (require$$0.jsx("div", { className: "xapp-chat-button__cta", children: require$$0.jsx(CtaBubbleContainer, { timeout: configToApply === null || configToApply === void 0 ? void 0 : configToApply.timeout, delay: configToApply === null || configToApply === void 0 ? void 0 : configToApply.delay, animate: animate, buttonAnimation: animation, dismissible: configToApply === null || configToApply === void 0 ? void 0 : configToApply.dismissible, visible: !visible /** Why is this !visible */, onDismiss: onCtaDismiss, children: configToApply === null || configToApply === void 0 ? void 0 : configToApply.message }) }))] }));
|
|
915
908
|
};
|
|
916
909
|
|
|
917
910
|
var ChatCard = function (props) {
|
|
@@ -921,40 +914,32 @@ var ChatCard = function (props) {
|
|
|
921
914
|
var image;
|
|
922
915
|
var content;
|
|
923
916
|
if (card.imageUrl) {
|
|
924
|
-
image =
|
|
925
|
-
React$1.createElement(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }));
|
|
917
|
+
image = (require$$0.jsx("div", { className: "chat-card-container__img", children: require$$0.jsx(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }) }));
|
|
926
918
|
}
|
|
927
919
|
if (card.title) {
|
|
928
|
-
title =
|
|
929
|
-
React$1.createElement("div", { className: "chat-card-title" },
|
|
930
|
-
React$1.createElement("span", null, card.title));
|
|
920
|
+
title = (require$$0.jsx("div", { className: "chat-card-title", children: require$$0.jsx("span", { children: card.title }) }));
|
|
931
921
|
}
|
|
932
922
|
if (card.content) {
|
|
933
|
-
content =
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
}
|
|
937
|
-
return (React$1.createElement("div", { className: "chat-card-container" },
|
|
938
|
-
image,
|
|
939
|
-
title,
|
|
940
|
-
content,
|
|
941
|
-
!!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick })));
|
|
923
|
+
content = (require$$0.jsx("div", { className: "chat-card-sub-title", children: require$$0.jsx("span", { children: card.content }) }));
|
|
924
|
+
}
|
|
925
|
+
return (require$$0.jsxs("div", { className: "chat-card-container", children: [image, title, content, !!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && (require$$0.jsx(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick }))] }));
|
|
942
926
|
};
|
|
943
927
|
|
|
944
928
|
var ChatChip = function (props) {
|
|
945
929
|
var option = props.option;
|
|
946
|
-
var className = option.actionUrl
|
|
947
|
-
|
|
948
|
-
|
|
930
|
+
var className = option.actionUrl
|
|
931
|
+
? "chat-chip chat-chip-link"
|
|
932
|
+
: "chat-chip";
|
|
933
|
+
return (require$$0.jsx("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className, children: require$$0.jsx("span", { children: typeof option === "object" ? option.label : option }) }));
|
|
949
934
|
};
|
|
950
935
|
|
|
951
936
|
/**
|
|
952
937
|
* Render option list. We just follow the order.
|
|
953
938
|
*/
|
|
954
939
|
var ChatChips = function (props) {
|
|
955
|
-
return (
|
|
956
|
-
|
|
957
|
-
|
|
940
|
+
return (require$$0.jsx("div", { className: "chat-chips", children: props.options.map(function (option, i) {
|
|
941
|
+
return require$$0.jsx(ChatChip, { onClick: props.onOptionClick, option: option }, i);
|
|
942
|
+
}) }));
|
|
958
943
|
};
|
|
959
944
|
|
|
960
945
|
var defaultBehavior = {
|
|
@@ -1073,7 +1058,7 @@ function execute(url, dispatch, visuals, behavior) {
|
|
|
1073
1058
|
}
|
|
1074
1059
|
function useOpenUrlCallback() {
|
|
1075
1060
|
var env = useWidgetEnv();
|
|
1076
|
-
return
|
|
1061
|
+
return require$$1.useCallback(function (url, dispatch, visuals, behavior) {
|
|
1077
1062
|
if (!behavior) {
|
|
1078
1063
|
behavior = (env === null || env === void 0 ? void 0 : env.urls) ? resolveUrlPolicy(url, env.urls) : defaultBehavior;
|
|
1079
1064
|
}
|
|
@@ -1271,6 +1256,30 @@ function reset() {
|
|
|
1271
1256
|
};
|
|
1272
1257
|
}
|
|
1273
1258
|
|
|
1259
|
+
function displayWsButton(params) {
|
|
1260
|
+
return {
|
|
1261
|
+
type: "ws_button_display",
|
|
1262
|
+
detail: {
|
|
1263
|
+
id: params.id,
|
|
1264
|
+
text: params.text,
|
|
1265
|
+
pressBehavior: params.pressBehavior,
|
|
1266
|
+
isPressed: params.isPressed,
|
|
1267
|
+
isDismissing: params.isDismissing,
|
|
1268
|
+
timestamp: +new Date()
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
function dismissWsButton(id) {
|
|
1274
|
+
return {
|
|
1275
|
+
type: "ws_button_dismiss",
|
|
1276
|
+
detail: {
|
|
1277
|
+
id: id,
|
|
1278
|
+
timestamp: +new Date()
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1274
1283
|
var LogChat = /** @class */ (function () {
|
|
1275
1284
|
function LogChat(inner) {
|
|
1276
1285
|
this.inner = inner;
|
|
@@ -1334,6 +1343,17 @@ var LogChat = /** @class */ (function () {
|
|
|
1334
1343
|
log("CLIENT: wakeup:");
|
|
1335
1344
|
this.inner.wakeup();
|
|
1336
1345
|
};
|
|
1346
|
+
LogChat.prototype.sendButtonPressed = function (buttonId) {
|
|
1347
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
1348
|
+
return __generator$1(this, function (_a) {
|
|
1349
|
+
log("CLIENT: sendButtonPressed: ".concat(buttonId));
|
|
1350
|
+
if (this.inner.sendButtonPressed) {
|
|
1351
|
+
return [2 /*return*/, this.inner.sendButtonPressed(buttonId)];
|
|
1352
|
+
}
|
|
1353
|
+
return [2 /*return*/];
|
|
1354
|
+
});
|
|
1355
|
+
});
|
|
1356
|
+
};
|
|
1337
1357
|
return LogChat;
|
|
1338
1358
|
}());
|
|
1339
1359
|
|
|
@@ -1343,13 +1363,12 @@ function getDefaultExportFromCjs (x) {
|
|
|
1343
1363
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1344
1364
|
}
|
|
1345
1365
|
|
|
1346
|
-
var
|
|
1366
|
+
var jsxRuntime = require$$0;
|
|
1367
|
+
var react = require$$1;
|
|
1347
1368
|
|
|
1348
1369
|
var IconButton = function (props) {
|
|
1349
1370
|
var Icon = props.icon;
|
|
1350
|
-
return (
|
|
1351
|
-
React.createElement("div", { className: "xapp-search-icon-button__content" },
|
|
1352
|
-
React.createElement(Icon, null))));
|
|
1371
|
+
return (jsxRuntime.jsx("div", { tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "xapp-search-icon-button ".concat(props.className || ""), onClick: props.onClick, children: jsxRuntime.jsx("div", { className: "xapp-search-icon-button__content", children: jsxRuntime.jsx(Icon, {}) }) }));
|
|
1353
1372
|
};
|
|
1354
1373
|
|
|
1355
1374
|
// compile time full switch-case verification
|
|
@@ -1359,17 +1378,17 @@ function throwBadKind(x) {
|
|
|
1359
1378
|
|
|
1360
1379
|
var RichTextBoldSpan = function (props) {
|
|
1361
1380
|
var format = props.format, text = props.text;
|
|
1362
|
-
return (
|
|
1381
|
+
return (jsxRuntime.jsx("span", { "data-rich-text-type": "bold", className: "xapp-search-rich-text-bold-span", children: text.substring(format.start, format.end) }));
|
|
1363
1382
|
};
|
|
1364
1383
|
|
|
1365
1384
|
var RichTextInputSpan = function (props) {
|
|
1366
1385
|
var format = props.format, text = props.text, readOnly = props.readOnly, onClick = props.onClick;
|
|
1367
1386
|
var defaultValue = format.text || text.substring(format.start, format.end);
|
|
1368
|
-
var _a =
|
|
1369
|
-
var handleChange =
|
|
1387
|
+
var _a = react.useState(defaultValue), value = _a[0], setValue = _a[1];
|
|
1388
|
+
var handleChange = react.useCallback(function (ev) {
|
|
1370
1389
|
setValue(ev.target.value);
|
|
1371
1390
|
}, []);
|
|
1372
|
-
var handleClick =
|
|
1391
|
+
var handleClick = react.useCallback(function (ev) {
|
|
1373
1392
|
if (onClick) {
|
|
1374
1393
|
var res = onClick(format);
|
|
1375
1394
|
if (res === false) {
|
|
@@ -1379,14 +1398,14 @@ var RichTextInputSpan = function (props) {
|
|
|
1379
1398
|
}
|
|
1380
1399
|
}, [onClick, format]);
|
|
1381
1400
|
if (readOnly) {
|
|
1382
|
-
return (
|
|
1401
|
+
return (jsxRuntime.jsx("span", { className: "xapp-search-rich-text-input-span xapp-search-rich-text-input-span--readonly", onClick: handleClick, children: defaultValue }));
|
|
1383
1402
|
}
|
|
1384
|
-
return (
|
|
1403
|
+
return (jsxRuntime.jsx("input", { type: "text", value: value, className: "xapp-search-rich-text-input-span", "data-rich-text-type": "inputText", onChange: handleChange, onClick: handleClick, readOnly: readOnly }));
|
|
1385
1404
|
};
|
|
1386
1405
|
|
|
1387
1406
|
var RichTextNormalSpan = function (props) {
|
|
1388
1407
|
var format = props.format, text = props.text;
|
|
1389
|
-
return (
|
|
1408
|
+
return (jsxRuntime.jsx("span", { "data-rich-text-type": "normal", className: "xapp-search-rich-text-normal-span", children: text.substring(format.start, format.end) }));
|
|
1390
1409
|
};
|
|
1391
1410
|
|
|
1392
1411
|
var RichTextSpan = function (props) {
|
|
@@ -1394,11 +1413,11 @@ var RichTextSpan = function (props) {
|
|
|
1394
1413
|
var type = format.type;
|
|
1395
1414
|
switch (type) {
|
|
1396
1415
|
case "normal":
|
|
1397
|
-
return
|
|
1416
|
+
return jsxRuntime.jsx(RichTextNormalSpan, { text: text, format: format, readOnly: readOnly });
|
|
1398
1417
|
case "bold":
|
|
1399
|
-
return
|
|
1418
|
+
return jsxRuntime.jsx(RichTextBoldSpan, { text: text, format: format, readOnly: readOnly });
|
|
1400
1419
|
case "inputText":
|
|
1401
|
-
return (
|
|
1420
|
+
return (jsxRuntime.jsx(RichTextInputSpan, { text: text, format: format, readOnly: readOnly, onClick: onClick }));
|
|
1402
1421
|
default:
|
|
1403
1422
|
throwBadKind(type);
|
|
1404
1423
|
}
|
|
@@ -1483,7 +1502,7 @@ function parseContent(node) {
|
|
|
1483
1502
|
formats.push({
|
|
1484
1503
|
type: type,
|
|
1485
1504
|
start: text.length,
|
|
1486
|
-
end: text.length + innerText.length
|
|
1505
|
+
end: text.length + innerText.length,
|
|
1487
1506
|
});
|
|
1488
1507
|
text += innerText;
|
|
1489
1508
|
}
|
|
@@ -1494,7 +1513,7 @@ function parseContent(node) {
|
|
|
1494
1513
|
formats.push({
|
|
1495
1514
|
type: "normal",
|
|
1496
1515
|
start: text.length,
|
|
1497
|
-
end: text.length + innerText.length
|
|
1516
|
+
end: text.length + innerText.length,
|
|
1498
1517
|
});
|
|
1499
1518
|
text += innerText;
|
|
1500
1519
|
}
|
|
@@ -1502,7 +1521,7 @@ function parseContent(node) {
|
|
|
1502
1521
|
});
|
|
1503
1522
|
return cleanRichTextValue({
|
|
1504
1523
|
text: text,
|
|
1505
|
-
formats: formats
|
|
1524
|
+
formats: formats,
|
|
1506
1525
|
});
|
|
1507
1526
|
}
|
|
1508
1527
|
function cleanContent(node) {
|
|
@@ -1520,22 +1539,21 @@ function cleanContent(node) {
|
|
|
1520
1539
|
try {
|
|
1521
1540
|
(_a = c.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(c);
|
|
1522
1541
|
}
|
|
1523
|
-
catch (_b) {
|
|
1524
|
-
}
|
|
1542
|
+
catch (_b) { }
|
|
1525
1543
|
}
|
|
1526
1544
|
}
|
|
1527
1545
|
var RichText = function (props) {
|
|
1528
1546
|
var value = props.value, className = props.className, readOnly = props.readOnly, onInput = props.onInput, onChange = props.onChange, onSpanClick = props.onSpanClick;
|
|
1529
1547
|
var formatsRaw = value.formats, text = value.text;
|
|
1530
|
-
var formats =
|
|
1531
|
-
var handleInput =
|
|
1548
|
+
var formats = react.useMemo(function () { return extendFormat(formatsRaw, text.length); }, [formatsRaw, text.length]);
|
|
1549
|
+
var handleInput = react.useCallback(function (ev) {
|
|
1532
1550
|
var target = ev.currentTarget;
|
|
1533
1551
|
var newValue = parseContent(target);
|
|
1534
1552
|
if (onInput) {
|
|
1535
1553
|
onInput(newValue);
|
|
1536
1554
|
}
|
|
1537
1555
|
}, [onInput]);
|
|
1538
|
-
var handleBlur =
|
|
1556
|
+
var handleBlur = react.useCallback(function (ev) {
|
|
1539
1557
|
var target = ev.currentTarget;
|
|
1540
1558
|
var newValue = parseContent(target);
|
|
1541
1559
|
cleanContent(target);
|
|
@@ -1543,49 +1561,53 @@ var RichText = function (props) {
|
|
|
1543
1561
|
onChange(newValue);
|
|
1544
1562
|
}
|
|
1545
1563
|
}, [onChange]);
|
|
1546
|
-
return (
|
|
1564
|
+
return (jsxRuntime.jsx("div", { id: props.id, className: "xapp-search-rich-text ".concat(className || ""), contentEditable: !readOnly, suppressContentEditableWarning: true, onInput: handleInput, onBlur: handleBlur, onKeyDown: props.onKeyDown, children: formats.map(function (format, index) { return (jsxRuntime.jsx(RichTextSpan, { format: format, text: text, readOnly: readOnly, onClick: onSpanClick }, index)); }) }));
|
|
1547
1565
|
};
|
|
1548
1566
|
|
|
1549
1567
|
var RichInput = function (props) {
|
|
1550
1568
|
var id = props.id, value = props.value, type = props.type, autoFocus = props.autoFocus, spellCheck = props.spellCheck, tabIndex = props.tabIndex, onChange = props.onChange, onInput = props.onInput, onKeyDown = props.onKeyDown, onSearch = props.onSearch;
|
|
1551
1569
|
var rich = value.formats.some(function (f) { return f.type === "inputText"; });
|
|
1552
|
-
var handleChange =
|
|
1553
|
-
onChange
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1570
|
+
var handleChange = react.useCallback(function (ev) {
|
|
1571
|
+
if (onChange) {
|
|
1572
|
+
onChange({
|
|
1573
|
+
text: ev.target.value,
|
|
1574
|
+
formats: [],
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1557
1577
|
}, [onChange]);
|
|
1558
|
-
var handleRichChange =
|
|
1559
|
-
onChange
|
|
1578
|
+
var handleRichChange = react.useCallback(function (val) {
|
|
1579
|
+
if (onChange) {
|
|
1580
|
+
onChange(val);
|
|
1581
|
+
}
|
|
1560
1582
|
}, [onChange]);
|
|
1561
|
-
var handleInput =
|
|
1583
|
+
var handleInput = react.useCallback(function (ev) {
|
|
1562
1584
|
if (onInput) {
|
|
1563
1585
|
onInput({
|
|
1564
1586
|
text: ev.target.value,
|
|
1565
|
-
formats: []
|
|
1587
|
+
formats: [],
|
|
1566
1588
|
});
|
|
1567
1589
|
}
|
|
1568
1590
|
}, [onInput]);
|
|
1569
|
-
var handleRichInput =
|
|
1591
|
+
var handleRichInput = react.useCallback(function (val) {
|
|
1570
1592
|
if (onInput) {
|
|
1571
1593
|
onInput(val);
|
|
1572
1594
|
}
|
|
1573
1595
|
}, [onInput]);
|
|
1574
|
-
var handleKeyDown =
|
|
1596
|
+
var handleKeyDown = react.useCallback(function (event) {
|
|
1575
1597
|
if (onKeyDown) {
|
|
1576
1598
|
onKeyDown(event);
|
|
1577
1599
|
}
|
|
1578
1600
|
}, [onKeyDown]);
|
|
1579
|
-
var inputRef =
|
|
1601
|
+
var inputRef = react.useRef(null);
|
|
1580
1602
|
var inputNode = inputRef.current;
|
|
1581
|
-
|
|
1603
|
+
react.useEffect(function () {
|
|
1582
1604
|
if (inputNode && onSearch) {
|
|
1583
1605
|
var handler_1 = function (ev) {
|
|
1584
1606
|
var target = ev.target;
|
|
1585
1607
|
if (target) {
|
|
1586
1608
|
onSearch({
|
|
1587
1609
|
text: target.value,
|
|
1588
|
-
formats: []
|
|
1610
|
+
formats: [],
|
|
1589
1611
|
});
|
|
1590
1612
|
}
|
|
1591
1613
|
};
|
|
@@ -1596,12 +1618,11 @@ var RichInput = function (props) {
|
|
|
1596
1618
|
}
|
|
1597
1619
|
return undefined;
|
|
1598
1620
|
}, [inputNode, onSearch]);
|
|
1599
|
-
return (
|
|
1600
|
-
React.createElement(RichText, { id: id, value: value, onChange: handleRichChange, onInput: handleRichInput, onKeyDown: handleKeyDown, className: "xappw-rich-input__input ".concat(props.className, "__input") }) : React.createElement("input", { id: id, ref: inputRef, type: type, value: value.text, autoComplete: "off", autoFocus: autoFocus, placeholder: props.placeholder, spellCheck: spellCheck, tabIndex: tabIndex ? Number(tabIndex) : 0, className: "xappw-rich-input__input ".concat(props.className, "__input"), onFocus: props.onFocus, onChange: handleChange, onInput: handleInput, onKeyDown: handleKeyDown })));
|
|
1621
|
+
return (jsxRuntime.jsx("div", { className: "xappw-rich-input ".concat(props.className), children: rich ? (jsxRuntime.jsx(RichText, { id: id, value: value, onChange: handleRichChange, onInput: handleRichInput, onKeyDown: handleKeyDown, className: "xappw-rich-input__input ".concat(props.className, "__input") })) : (jsxRuntime.jsx("input", { id: id, ref: inputRef, type: type, value: value.text, autoComplete: "off", autoFocus: autoFocus, placeholder: props.placeholder, spellCheck: spellCheck, tabIndex: tabIndex ? Number(tabIndex) : 0, className: "xappw-rich-input__input ".concat(props.className, "__input"), onFocus: props.onFocus, onChange: handleChange, onInput: handleInput, onKeyDown: handleKeyDown })) }));
|
|
1601
1622
|
};
|
|
1602
1623
|
|
|
1603
1624
|
var SuggestionsGroupHeading = function (props) {
|
|
1604
|
-
return
|
|
1625
|
+
return jsxRuntime.jsx("div", { className: "xappw-suggestions-group-heading", children: props.label });
|
|
1605
1626
|
};
|
|
1606
1627
|
|
|
1607
1628
|
function getScrollContainer(node) {
|
|
@@ -1613,22 +1634,22 @@ function getScrollContainer(node) {
|
|
|
1613
1634
|
}
|
|
1614
1635
|
var SuggestionsItem = function (props) {
|
|
1615
1636
|
var data = props.data, current = props.current, ActionsComponent = props.actions, onClick = props.onClick, onHover = props.onHover, onSpanClick = props.onSpanClick;
|
|
1616
|
-
var handleClick =
|
|
1637
|
+
var handleClick = react.useCallback(function () {
|
|
1617
1638
|
onClick(data);
|
|
1618
1639
|
}, [data, onClick]);
|
|
1619
|
-
var handleHover =
|
|
1640
|
+
var handleHover = react.useCallback(function () {
|
|
1620
1641
|
if (onHover) {
|
|
1621
1642
|
onHover(data);
|
|
1622
1643
|
}
|
|
1623
1644
|
}, [data, onHover]);
|
|
1624
|
-
var handleSpanClick =
|
|
1645
|
+
var handleSpanClick = react.useCallback(function (span) {
|
|
1625
1646
|
if (onSpanClick) {
|
|
1626
1647
|
return onSpanClick(data, span);
|
|
1627
1648
|
}
|
|
1628
1649
|
return undefined;
|
|
1629
1650
|
}, [onSpanClick, data]);
|
|
1630
|
-
var ref =
|
|
1631
|
-
|
|
1651
|
+
var ref = react.useRef(null);
|
|
1652
|
+
react.useEffect(function () {
|
|
1632
1653
|
var node = ref.current;
|
|
1633
1654
|
if (current && node) {
|
|
1634
1655
|
var scrollContainer = getScrollContainer(node);
|
|
@@ -1645,22 +1666,13 @@ var SuggestionsItem = function (props) {
|
|
|
1645
1666
|
}
|
|
1646
1667
|
}
|
|
1647
1668
|
}, [current]);
|
|
1648
|
-
return (
|
|
1649
|
-
React.createElement(RichText, { value: data, className: "xappw-suggestions-item__texts", readOnly: true, onSpanClick: handleSpanClick }),
|
|
1650
|
-
ActionsComponent &&
|
|
1651
|
-
React.createElement("div", { className: "xappw-suggestions-item__actions" },
|
|
1652
|
-
React.createElement(ActionsComponent, { data: data, current: current }))));
|
|
1669
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: "xappw-suggestions-item ".concat(current ? "xappw-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover, children: [jsxRuntime.jsx(RichText, { value: data, className: "xappw-suggestions-item__texts", readOnly: true, onSpanClick: handleSpanClick }), ActionsComponent && (jsxRuntime.jsx("div", { className: "xappw-suggestions-item__actions", children: jsxRuntime.jsx(ActionsComponent, { data: data, current: current }) }))] }));
|
|
1653
1670
|
};
|
|
1654
1671
|
|
|
1655
1672
|
var SuggestionsGroup = function (props) {
|
|
1656
1673
|
var group = props.group, currentIndex = props.currentIndex, itemActions = props.itemActions;
|
|
1657
1674
|
var heading = group.heading, items = group.items;
|
|
1658
|
-
return (
|
|
1659
|
-
React.createElement("div", { className: "xappw-suggestions-group__heading" },
|
|
1660
|
-
React.createElement(SuggestionsGroupHeading, { label: heading })),
|
|
1661
|
-
React.createElement("div", { className: "xappw-suggestions-group__items" }, items.map(function (item, itemIndex) {
|
|
1662
|
-
return React.createElement(SuggestionsItem, { key: itemIndex, data: item, current: currentIndex === itemIndex, actions: itemActions, onClick: props.onItemClick, onHover: props.onItemHover, onSpanClick: props.onSpanClick });
|
|
1663
|
-
}))));
|
|
1675
|
+
return (jsxRuntime.jsxs("div", { className: "xappw-suggestions-group", children: [jsxRuntime.jsx("div", { className: "xappw-suggestions-group__heading", children: jsxRuntime.jsx(SuggestionsGroupHeading, { label: heading }) }), jsxRuntime.jsx("div", { className: "xappw-suggestions-group__items", children: items.map(function (item, itemIndex) { return (jsxRuntime.jsx(SuggestionsItem, { data: item, current: currentIndex === itemIndex, actions: itemActions, onClick: props.onItemClick, onHover: props.onItemHover, onSpanClick: props.onSpanClick }, itemIndex)); }) })] }));
|
|
1664
1676
|
};
|
|
1665
1677
|
|
|
1666
1678
|
function getItemsLength(result) {
|
|
@@ -1669,7 +1681,7 @@ function getItemsLength(result) {
|
|
|
1669
1681
|
|
|
1670
1682
|
var SuggestionsList = function (props) {
|
|
1671
1683
|
var suggestions = props.suggestions, itemActions = props.itemActions, className = props.className;
|
|
1672
|
-
var length =
|
|
1684
|
+
var length = react.useMemo(function () {
|
|
1673
1685
|
if (suggestions) {
|
|
1674
1686
|
return getItemsLength(suggestions);
|
|
1675
1687
|
}
|
|
@@ -1677,11 +1689,11 @@ var SuggestionsList = function (props) {
|
|
|
1677
1689
|
}, [suggestions]);
|
|
1678
1690
|
var currentIndex = length >= 0 ? props.index : NaN;
|
|
1679
1691
|
var indexWalker = 0;
|
|
1680
|
-
return (
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1692
|
+
return (jsxRuntime.jsx("div", { className: "xappw-suggestions-list ".concat(className || ""), children: suggestions === null || suggestions === void 0 ? void 0 : suggestions.map(function (group, index) {
|
|
1693
|
+
var res = (jsxRuntime.jsx(SuggestionsGroup, { group: group, currentIndex: currentIndex - indexWalker, itemActions: itemActions, onItemClick: props.onItemClick, onItemHover: props.onItemHover, onSpanClick: props.onSpanClick }, index));
|
|
1694
|
+
indexWalker += group.items.length;
|
|
1695
|
+
return res;
|
|
1696
|
+
}) }));
|
|
1685
1697
|
};
|
|
1686
1698
|
|
|
1687
1699
|
function findItemByIndex(groups, index) {
|
|
@@ -1700,65 +1712,6 @@ function findItemByIndex(groups, index) {
|
|
|
1700
1712
|
return undefined;
|
|
1701
1713
|
}
|
|
1702
1714
|
|
|
1703
|
-
function parseSuggestionsFormat(format) {
|
|
1704
|
-
var types = Object.keys(format);
|
|
1705
|
-
var type = types[0];
|
|
1706
|
-
var item = format[type];
|
|
1707
|
-
if (!item) {
|
|
1708
|
-
throw new Error();
|
|
1709
|
-
}
|
|
1710
|
-
return {
|
|
1711
|
-
type: type,
|
|
1712
|
-
start: item.start,
|
|
1713
|
-
end: item.end
|
|
1714
|
-
};
|
|
1715
|
-
}
|
|
1716
|
-
function parseSuggestionsFormats(formats) {
|
|
1717
|
-
return formats.map(parseSuggestionsFormat);
|
|
1718
|
-
}
|
|
1719
|
-
function parseSuggestionsResponseItem(item) {
|
|
1720
|
-
return {
|
|
1721
|
-
text: item.suggestion,
|
|
1722
|
-
content: item.answer,
|
|
1723
|
-
formats: parseSuggestionsFormats(item.format),
|
|
1724
|
-
type: item.type
|
|
1725
|
-
};
|
|
1726
|
-
}
|
|
1727
|
-
function getHeading(type) {
|
|
1728
|
-
switch (type) {
|
|
1729
|
-
case "FAQ":
|
|
1730
|
-
return "FAQs";
|
|
1731
|
-
case "INTENT":
|
|
1732
|
-
return "Suggestions";
|
|
1733
|
-
case "HISTORICAL":
|
|
1734
|
-
return "Suggestions";
|
|
1735
|
-
default:
|
|
1736
|
-
return type;
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
function parseSuggestionsResponse(response, direction) {
|
|
1740
|
-
if (direction === void 0) { direction = 1; }
|
|
1741
|
-
if (!response) {
|
|
1742
|
-
return undefined;
|
|
1743
|
-
}
|
|
1744
|
-
var items = sortSuggestionItems(response.suggestions, direction);
|
|
1745
|
-
return items.reduce(function (result, current) {
|
|
1746
|
-
var mappedItem = parseSuggestionsResponseItem(current);
|
|
1747
|
-
if (result.length) {
|
|
1748
|
-
var prevGroup = result[result.length - 1];
|
|
1749
|
-
if (prevGroup.heading === getHeading(current.type)) {
|
|
1750
|
-
prevGroup.items.push(mappedItem);
|
|
1751
|
-
return result;
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
result.push({
|
|
1755
|
-
heading: getHeading(current.type),
|
|
1756
|
-
items: [mappedItem]
|
|
1757
|
-
});
|
|
1758
|
-
return result;
|
|
1759
|
-
}, []);
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
1715
|
/******************************************************************************
|
|
1763
1716
|
Copyright (c) Microsoft Corporation.
|
|
1764
1717
|
|
|
@@ -1841,6 +1794,65 @@ function sortSuggestionItems(items, direction) {
|
|
|
1841
1794
|
return __spreadArray([], items).sort(function (left, right) { return compareSuggestionItems(left, right, direction); });
|
|
1842
1795
|
}
|
|
1843
1796
|
|
|
1797
|
+
function parseSuggestionsFormat(format) {
|
|
1798
|
+
var types = Object.keys(format);
|
|
1799
|
+
var type = types[0];
|
|
1800
|
+
var item = format[type];
|
|
1801
|
+
if (!item) {
|
|
1802
|
+
throw new Error();
|
|
1803
|
+
}
|
|
1804
|
+
return {
|
|
1805
|
+
type: type,
|
|
1806
|
+
start: item.start,
|
|
1807
|
+
end: item.end,
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
function parseSuggestionsFormats(formats) {
|
|
1811
|
+
return formats.map(parseSuggestionsFormat);
|
|
1812
|
+
}
|
|
1813
|
+
function parseSuggestionsResponseItem(item) {
|
|
1814
|
+
return {
|
|
1815
|
+
text: item.suggestion,
|
|
1816
|
+
content: item.answer,
|
|
1817
|
+
formats: parseSuggestionsFormats(item.format),
|
|
1818
|
+
type: item.type,
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
function getHeading(type) {
|
|
1822
|
+
switch (type) {
|
|
1823
|
+
case "FAQ":
|
|
1824
|
+
return "FAQs";
|
|
1825
|
+
case "INTENT":
|
|
1826
|
+
return "Suggestions";
|
|
1827
|
+
case "HISTORICAL":
|
|
1828
|
+
return "Suggestions";
|
|
1829
|
+
default:
|
|
1830
|
+
return type;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
function parseSuggestionsResponse(response, direction) {
|
|
1834
|
+
if (direction === void 0) { direction = 1; }
|
|
1835
|
+
if (!response) {
|
|
1836
|
+
return undefined;
|
|
1837
|
+
}
|
|
1838
|
+
var items = sortSuggestionItems(response.suggestions, direction);
|
|
1839
|
+
return items.reduce(function (result, current) {
|
|
1840
|
+
var mappedItem = parseSuggestionsResponseItem(current);
|
|
1841
|
+
if (result.length) {
|
|
1842
|
+
var prevGroup = result[result.length - 1];
|
|
1843
|
+
if (prevGroup.heading === getHeading(current.type)) {
|
|
1844
|
+
prevGroup.items.push(mappedItem);
|
|
1845
|
+
return result;
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
result.push({
|
|
1849
|
+
heading: getHeading(current.type),
|
|
1850
|
+
items: [mappedItem],
|
|
1851
|
+
});
|
|
1852
|
+
return result;
|
|
1853
|
+
}, []);
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1844
1856
|
/**
|
|
1845
1857
|
* Append the provided query params to the URL
|
|
1846
1858
|
*
|
|
@@ -1863,11 +1875,11 @@ function noop$1() {
|
|
|
1863
1875
|
}
|
|
1864
1876
|
function useJsonFetch(url, options) {
|
|
1865
1877
|
if (options === void 0) { options = defaultOptions$2; }
|
|
1866
|
-
var _a =
|
|
1878
|
+
var _a = react.useState({
|
|
1867
1879
|
state: "paused"
|
|
1868
1880
|
}), value = _a[0], setValue = _a[1];
|
|
1869
1881
|
var pause = options.pause;
|
|
1870
|
-
|
|
1882
|
+
react.useEffect(function () {
|
|
1871
1883
|
if (pause) {
|
|
1872
1884
|
setValue({
|
|
1873
1885
|
state: "paused"
|
|
@@ -1932,7 +1944,7 @@ function useJsonFetch(url, options) {
|
|
|
1932
1944
|
|
|
1933
1945
|
function useSuggestionsFetch$1(options) {
|
|
1934
1946
|
var baseUrl = options.url, context = options.context, query = options.query;
|
|
1935
|
-
var url =
|
|
1947
|
+
var url = react.useMemo(function () {
|
|
1936
1948
|
if (!baseUrl) {
|
|
1937
1949
|
return undefined;
|
|
1938
1950
|
}
|
|
@@ -2002,7 +2014,6 @@ function postMessageToStentor(data, url, key, signal) {
|
|
|
2002
2014
|
headers: {
|
|
2003
2015
|
"Content-Type": "application/json",
|
|
2004
2016
|
"Authorization": "Bearer ".concat(key),
|
|
2005
|
-
"User-Agent": "Stentor Chat Server"
|
|
2006
2017
|
},
|
|
2007
2018
|
body: body,
|
|
2008
2019
|
mode: "cors",
|
|
@@ -2743,6 +2754,12 @@ var StentorLocalChat = /** @class */ (function () {
|
|
|
2743
2754
|
return StentorLocalChat;
|
|
2744
2755
|
}());
|
|
2745
2756
|
|
|
2757
|
+
/**
|
|
2758
|
+
* Animation duration for WebSocket button dismiss animation (in milliseconds).
|
|
2759
|
+
* This should match the CSS animation duration in WsButton.scss.
|
|
2760
|
+
*/
|
|
2761
|
+
var WS_BUTTON_DISMISS_ANIMATION_DURATION = 300;
|
|
2762
|
+
|
|
2746
2763
|
/*! Copyright (c) 2022, XAPPmedia */
|
|
2747
2764
|
var PERMISSION_QUESTION_EXPIRATION_MS = 300000; // 5 minutes
|
|
2748
2765
|
function requestFromMessage(message, userId, isNewSession, sessionId, accessToken, attributes, visitorInfo) {
|
|
@@ -2926,9 +2943,10 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2926
2943
|
var _this = this;
|
|
2927
2944
|
var _a, _b;
|
|
2928
2945
|
this.dispatch = dispatch;
|
|
2946
|
+
log("INIT called - setting initial accountStatus to OFFLINE");
|
|
2929
2947
|
this.setAccountStatus("offline");
|
|
2930
2948
|
// Register "handlers" for the incoming events
|
|
2931
|
-
this.handlers["connection update"] = function (data, _sender, _ts) {
|
|
2949
|
+
this.handlers["connection update"] = function (data, _sender, _ts, _attributes) {
|
|
2932
2950
|
log("Connection update received. Session created: ".concat(data.sessionCreated, " Error: ").concat(data.errorMessage || ""));
|
|
2933
2951
|
if (data.sessionCreated) {
|
|
2934
2952
|
_this.sessionCreated = true;
|
|
@@ -2943,7 +2961,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2943
2961
|
}
|
|
2944
2962
|
};
|
|
2945
2963
|
// Server ping (not sent periodically - at least not for now)
|
|
2946
|
-
this.handlers["account status"] = function (_data, _sender, ts) {
|
|
2964
|
+
this.handlers["account status"] = function (_data, _sender, ts, _attributes) {
|
|
2947
2965
|
dispatch({
|
|
2948
2966
|
type: "account_status",
|
|
2949
2967
|
detail: {
|
|
@@ -2952,26 +2970,31 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2952
2970
|
},
|
|
2953
2971
|
});
|
|
2954
2972
|
};
|
|
2955
|
-
this.handlers["failure"] = function (data, sender, _ts) {
|
|
2973
|
+
this.handlers["failure"] = function (data, sender, _ts, _attributes) {
|
|
2956
2974
|
err("SERVER: something's failed: type: ".concat(data.type, " tries: ").concat(data.tries, " error: ").concat(data.error));
|
|
2957
2975
|
var _a = _this.configurableMessages[data.tries], retry = _a.retry, delay = _a.delay, text = _a.text;
|
|
2958
2976
|
_this.sendFailureMessage(retry, data.delay || delay, text, sender);
|
|
2959
2977
|
};
|
|
2960
|
-
this.handlers["new message"] = function (data, sender, ts) {
|
|
2978
|
+
this.handlers["new message"] = function (data, sender, ts, attributes) {
|
|
2961
2979
|
// Because the router's internal message format is Stentor channel compatible.
|
|
2962
2980
|
// So the data is either a stentor Request (from widget) or a stentor Response (from bot)
|
|
2963
|
-
var _a
|
|
2981
|
+
var _a;
|
|
2964
2982
|
var message;
|
|
2965
2983
|
if (sender.deviceId === "Bot") {
|
|
2966
2984
|
var response = data;
|
|
2967
|
-
// Extract
|
|
2968
|
-
if (
|
|
2969
|
-
_this.routerAttributes = __assign({},
|
|
2985
|
+
// Extract router-managed attributes from message root (adjacent to event, data, sender, etc.)
|
|
2986
|
+
if (attributes && typeof attributes === "object" && Object.keys(attributes).length > 0) {
|
|
2987
|
+
_this.routerAttributes = __assign({}, attributes);
|
|
2970
2988
|
log("Extracted router attributes: ".concat(JSON.stringify(_this.routerAttributes)));
|
|
2971
2989
|
}
|
|
2972
|
-
if (typeof ((
|
|
2990
|
+
if (typeof ((_a = _this.options.hooks) === null || _a === void 0 ? void 0 : _a.onResponse) === "function") {
|
|
2973
2991
|
_this.options.hooks.onResponse(response);
|
|
2974
2992
|
}
|
|
2993
|
+
// Session is initialized after first bot response (same as StentorDirectChat)
|
|
2994
|
+
if (_this.isNewSession) {
|
|
2995
|
+
_this.isNewSession = false;
|
|
2996
|
+
log("Session initialized after receiving first bot response");
|
|
2997
|
+
}
|
|
2975
2998
|
message = responseToMessage(response);
|
|
2976
2999
|
}
|
|
2977
3000
|
else if (sender.deviceId === "Widget") {
|
|
@@ -2994,35 +3017,47 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2994
3017
|
},
|
|
2995
3018
|
});
|
|
2996
3019
|
};
|
|
2997
|
-
this.handlers["user joined"] = function (
|
|
3020
|
+
this.handlers["user joined"] = function (data, sender, ts, _attributes) {
|
|
2998
3021
|
var _a, _b;
|
|
3022
|
+
var nick = senderToNick(sender);
|
|
3023
|
+
log("Received \"user joined\" event - deviceId: ".concat(sender.deviceId, ", userId: ").concat(sender.userId, ", displayName: ").concat(sender.displayName, ", nick: ").concat(nick));
|
|
3024
|
+
log("Dispatching chat.memberjoin for ".concat(sender.displayName || "Unknown"));
|
|
3025
|
+
var userData = data;
|
|
2999
3026
|
_this.dispatch({
|
|
3000
3027
|
type: "chat",
|
|
3001
3028
|
detail: {
|
|
3002
3029
|
type: "chat.memberjoin",
|
|
3003
3030
|
user: {
|
|
3004
|
-
avatarPath: (_b = (_a = _this.options) === null || _a === void 0 ? void 0 : _a.bot) === null || _b === void 0 ? void 0 : _b.avatarPath,
|
|
3031
|
+
avatarPath: sender.avatarPath || ((_b = (_a = _this.options) === null || _a === void 0 ? void 0 : _a.bot) === null || _b === void 0 ? void 0 : _b.avatarPath),
|
|
3005
3032
|
displayName: sender.displayName,
|
|
3006
|
-
nick:
|
|
3033
|
+
nick: nick,
|
|
3007
3034
|
},
|
|
3008
3035
|
timestamp: ts || new Date().getTime(),
|
|
3036
|
+
showDivider: userData === null || userData === void 0 ? void 0 : userData.showDivider,
|
|
3037
|
+
message: userData === null || userData === void 0 ? void 0 : userData.message,
|
|
3038
|
+
hideUserInfo: userData === null || userData === void 0 ? void 0 : userData.hideUserInfo,
|
|
3009
3039
|
},
|
|
3010
3040
|
});
|
|
3041
|
+
log("chat.memberjoin dispatched for nick: ".concat(nick));
|
|
3011
3042
|
};
|
|
3012
|
-
this.handlers["user left"] = function (
|
|
3043
|
+
this.handlers["user left"] = function (data, sender, ts, _attributes) {
|
|
3044
|
+
var userData = data;
|
|
3013
3045
|
_this.dispatch({
|
|
3014
3046
|
type: "chat",
|
|
3015
3047
|
detail: {
|
|
3016
3048
|
type: "chat.memberleave",
|
|
3017
3049
|
user: {
|
|
3050
|
+
avatarPath: sender.avatarPath,
|
|
3018
3051
|
displayName: sender.displayName,
|
|
3019
3052
|
nick: senderToNick(sender),
|
|
3020
3053
|
},
|
|
3021
3054
|
timestamp: ts || new Date().getTime(),
|
|
3055
|
+
showDivider: userData === null || userData === void 0 ? void 0 : userData.showDivider,
|
|
3056
|
+
message: userData === null || userData === void 0 ? void 0 : userData.message,
|
|
3022
3057
|
},
|
|
3023
3058
|
});
|
|
3024
3059
|
};
|
|
3025
|
-
this.handlers["typing"] = function (_data, sender, ts) {
|
|
3060
|
+
this.handlers["typing"] = function (_data, sender, ts, _attributes) {
|
|
3026
3061
|
_this.dispatch({
|
|
3027
3062
|
type: "chat",
|
|
3028
3063
|
detail: {
|
|
@@ -3035,7 +3070,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3035
3070
|
},
|
|
3036
3071
|
});
|
|
3037
3072
|
};
|
|
3038
|
-
this.handlers["stop typing"] = function (_data, sender, ts) {
|
|
3073
|
+
this.handlers["stop typing"] = function (_data, sender, ts, _attributes) {
|
|
3039
3074
|
_this.dispatch({
|
|
3040
3075
|
type: "chat",
|
|
3041
3076
|
detail: {
|
|
@@ -3049,6 +3084,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3049
3084
|
});
|
|
3050
3085
|
};
|
|
3051
3086
|
this.handlers["disconnect"] = function () {
|
|
3087
|
+
log("DISCONNECT event received from server");
|
|
3052
3088
|
err("SERVER: requested disconnect");
|
|
3053
3089
|
_this.dispatch(setAccountStatus("offline"));
|
|
3054
3090
|
_this.dispatch(setConnectionStatus("offline"));
|
|
@@ -3066,6 +3102,76 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3066
3102
|
err("SERVER: says there was an error while re-connecting");
|
|
3067
3103
|
_this.dispatch(setAccountStatus("offline"));
|
|
3068
3104
|
};
|
|
3105
|
+
this.handlers["display button"] = function (data, _sender, _ts, _attributes) {
|
|
3106
|
+
log("Received \"display button\" event - id: ".concat(data.id, ", text: ").concat(data.text, ", pressBehavior: ").concat(data.pressBehavior));
|
|
3107
|
+
_this.dispatch(displayWsButton({
|
|
3108
|
+
id: data.id,
|
|
3109
|
+
text: data.text,
|
|
3110
|
+
pressBehavior: data.pressBehavior || "none"
|
|
3111
|
+
}));
|
|
3112
|
+
};
|
|
3113
|
+
this.handlers["dismiss button"] = function (data, _sender, _ts, _attributes) {
|
|
3114
|
+
log("Received \"dismiss button\" event - id: ".concat(data.id));
|
|
3115
|
+
// First, mark button as dismissing to trigger animation
|
|
3116
|
+
_this.dispatch(displayWsButton({
|
|
3117
|
+
id: data.id,
|
|
3118
|
+
text: '',
|
|
3119
|
+
pressBehavior: 'none',
|
|
3120
|
+
isDismissing: true
|
|
3121
|
+
}));
|
|
3122
|
+
// Then actually dismiss after animation completes
|
|
3123
|
+
setTimeout(function () {
|
|
3124
|
+
_this.dispatch(dismissWsButton(data.id));
|
|
3125
|
+
}, WS_BUTTON_DISMISS_ANIMATION_DURATION);
|
|
3126
|
+
};
|
|
3127
|
+
this.handlers["system-message"] = function (data, sender, ts, _attributes) {
|
|
3128
|
+
log("Received \"system-message\" event - id: ".concat(data.id, ", message: ").concat(data.message, ", dismissId: ").concat(data.dismissId));
|
|
3129
|
+
// If there's a dismissId, dispatch dismiss action first
|
|
3130
|
+
if (data.dismissId) {
|
|
3131
|
+
_this.dispatch({
|
|
3132
|
+
type: "chat",
|
|
3133
|
+
detail: {
|
|
3134
|
+
type: "chat.systemmessagedismiss",
|
|
3135
|
+
user: {
|
|
3136
|
+
displayName: sender.displayName || "System",
|
|
3137
|
+
nick: senderToNick(sender),
|
|
3138
|
+
},
|
|
3139
|
+
id: data.dismissId,
|
|
3140
|
+
timestamp: ts || new Date().getTime(),
|
|
3141
|
+
},
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
3144
|
+
// Then dispatch the new system message
|
|
3145
|
+
_this.dispatch({
|
|
3146
|
+
type: "chat",
|
|
3147
|
+
detail: {
|
|
3148
|
+
type: "chat.systemmessage",
|
|
3149
|
+
user: {
|
|
3150
|
+
displayName: sender.displayName || "System",
|
|
3151
|
+
nick: senderToNick(sender),
|
|
3152
|
+
},
|
|
3153
|
+
id: data.id,
|
|
3154
|
+
message: data.message,
|
|
3155
|
+
dismissId: data.dismissId,
|
|
3156
|
+
timestamp: ts || new Date().getTime(),
|
|
3157
|
+
},
|
|
3158
|
+
});
|
|
3159
|
+
};
|
|
3160
|
+
this.handlers["system-message-dismiss"] = function (data, sender, ts, _attributes) {
|
|
3161
|
+
log("Received \"system-message-dismiss\" event - id: ".concat(data.id));
|
|
3162
|
+
_this.dispatch({
|
|
3163
|
+
type: "chat",
|
|
3164
|
+
detail: {
|
|
3165
|
+
type: "chat.systemmessagedismiss",
|
|
3166
|
+
user: {
|
|
3167
|
+
displayName: sender.displayName || "System",
|
|
3168
|
+
nick: senderToNick(sender),
|
|
3169
|
+
},
|
|
3170
|
+
id: data.id,
|
|
3171
|
+
timestamp: ts || new Date().getTime(),
|
|
3172
|
+
},
|
|
3173
|
+
});
|
|
3174
|
+
};
|
|
3069
3175
|
// Register the router as a pseudo-agent (serverInfo) so it can send messages (like internal errors)
|
|
3070
3176
|
this.dispatch({
|
|
3071
3177
|
type: "chat",
|
|
@@ -3104,6 +3210,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3104
3210
|
setActStatus("online");
|
|
3105
3211
|
setConnStatus("online");
|
|
3106
3212
|
ws.onclose = function () {
|
|
3213
|
+
log("WebSocket ONCLOSE event - connection closed unexpectedly");
|
|
3107
3214
|
log("Closed WS connection (onclosed was called)");
|
|
3108
3215
|
startReconnecting();
|
|
3109
3216
|
};
|
|
@@ -3117,10 +3224,12 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3117
3224
|
return;
|
|
3118
3225
|
}
|
|
3119
3226
|
ws.onclose = function () {
|
|
3227
|
+
log("WebSocket ONCLOSE event (initial) - connection closed");
|
|
3120
3228
|
log("Closed WS connection (onclosed was called)");
|
|
3121
3229
|
startReconnecting();
|
|
3122
3230
|
};
|
|
3123
3231
|
this.ws.onopen = function () {
|
|
3232
|
+
log("WebSocket ONOPEN event - connection established");
|
|
3124
3233
|
log("Opened WS connection (onopen was called)");
|
|
3125
3234
|
// We are connected
|
|
3126
3235
|
_this.setAccountStatus("online");
|
|
@@ -3129,6 +3238,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3129
3238
|
};
|
|
3130
3239
|
StentorRouterChat.prototype.wsClose = function () {
|
|
3131
3240
|
if (this.ws) {
|
|
3241
|
+
log("wsClose() - Closing WebSocket (readyState: ".concat(this.ws.readyState, ")"));
|
|
3132
3242
|
this.ws.onclose = null;
|
|
3133
3243
|
this.ws.onerror = null;
|
|
3134
3244
|
this.ws.onopen = null;
|
|
@@ -3170,7 +3280,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3170
3280
|
var message = JSON.parse(me.data);
|
|
3171
3281
|
var handler = _this.handlers[message.event];
|
|
3172
3282
|
if (handler) {
|
|
3173
|
-
_this.handlers[message.event](message.data, message.sender, message.timeMs);
|
|
3283
|
+
_this.handlers[message.event](message.data, message.sender, message.timeMs, message.attributes);
|
|
3174
3284
|
}
|
|
3175
3285
|
else {
|
|
3176
3286
|
err("Unknown router message event: ".concat(message.event));
|
|
@@ -3184,18 +3294,24 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3184
3294
|
};
|
|
3185
3295
|
StentorRouterChat.prototype.emit = function (event, data) {
|
|
3186
3296
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
3187
|
-
var payloadData;
|
|
3297
|
+
var payload, payloadData;
|
|
3188
3298
|
var _this = this;
|
|
3189
3299
|
return __generator$1(this, function (_a) {
|
|
3190
3300
|
switch (_a.label) {
|
|
3191
3301
|
case 0:
|
|
3192
|
-
|
|
3302
|
+
payload = {
|
|
3193
3303
|
event: event,
|
|
3194
3304
|
data: data,
|
|
3195
3305
|
sender: this.visitorInfo,
|
|
3196
3306
|
sessionId: this._sessionId,
|
|
3197
3307
|
timeMs: new Date().getTime()
|
|
3198
|
-
}
|
|
3308
|
+
};
|
|
3309
|
+
// Add router-managed attributes at payload root level if available
|
|
3310
|
+
if (this.routerAttributes && Object.keys(this.routerAttributes).length > 0) {
|
|
3311
|
+
payload.attributes = this.routerAttributes;
|
|
3312
|
+
log("Adding router attributes to outgoing payload: ".concat(JSON.stringify(this.routerAttributes)));
|
|
3313
|
+
}
|
|
3314
|
+
payloadData = JSON.stringify(payload);
|
|
3199
3315
|
log("Widget says: ".concat(payloadData));
|
|
3200
3316
|
if (!this.ws) {
|
|
3201
3317
|
// Fire up the WebSocket
|
|
@@ -3221,10 +3337,12 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3221
3337
|
});
|
|
3222
3338
|
};
|
|
3223
3339
|
StentorRouterChat.prototype.setAccountStatus = function (status) {
|
|
3340
|
+
log("setAccountStatus: ".concat(status));
|
|
3224
3341
|
log("SERVER account_status: ".concat(JSON.stringify(status)));
|
|
3225
3342
|
this.dispatch(setAccountStatus(status));
|
|
3226
3343
|
};
|
|
3227
3344
|
StentorRouterChat.prototype.setConnectionStatus = function (status) {
|
|
3345
|
+
log("setConnectionStatus: ".concat(status));
|
|
3228
3346
|
log("SERVER: connection_update: ".concat(JSON.stringify(status)));
|
|
3229
3347
|
this.dispatch(setConnectionStatus(status));
|
|
3230
3348
|
};
|
|
@@ -3354,6 +3472,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3354
3472
|
};
|
|
3355
3473
|
StentorRouterChat.prototype.flush = function () { };
|
|
3356
3474
|
StentorRouterChat.prototype.dispose = function () {
|
|
3475
|
+
log("DISPOSE called - cleaning up connection");
|
|
3357
3476
|
this.isDisposed = true;
|
|
3358
3477
|
if (this.ws) {
|
|
3359
3478
|
this.wsClose();
|
|
@@ -3365,17 +3484,25 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3365
3484
|
if (this.ws) {
|
|
3366
3485
|
this.wsClose();
|
|
3367
3486
|
}
|
|
3487
|
+
log("SLEEP called - closed web socket");
|
|
3368
3488
|
log("Closed web socket (sleep)");
|
|
3369
3489
|
};
|
|
3370
3490
|
StentorRouterChat.prototype.wakeup = function () {
|
|
3371
3491
|
this.isDisposed = false;
|
|
3492
|
+
log("WAKEUP called - userId:", this._userId);
|
|
3372
3493
|
// wait for the session setup
|
|
3373
3494
|
if (!this._userId) {
|
|
3495
|
+
log("WAKEUP - No userId, returning early");
|
|
3374
3496
|
return;
|
|
3375
3497
|
}
|
|
3376
|
-
//
|
|
3498
|
+
// Set both statuses immediately to show we're reconnecting
|
|
3499
|
+
log("WAKEUP - Setting accountStatus and connectionStatus to ONLINE");
|
|
3500
|
+
this.setAccountStatus("online");
|
|
3501
|
+
this.setConnectionStatus("online");
|
|
3502
|
+
log("Waking up - setting status to online");
|
|
3503
|
+
// Fire up the WebSocket
|
|
3504
|
+
log("WAKEUP - Calling autoReconnect");
|
|
3377
3505
|
this.autoReconnect(this.wsCreate.bind(this, "wakeup"));
|
|
3378
|
-
log("Waking up");
|
|
3379
3506
|
};
|
|
3380
3507
|
StentorRouterChat.prototype.bargeOut = function (_cb) {
|
|
3381
3508
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
@@ -3394,6 +3521,17 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3394
3521
|
});
|
|
3395
3522
|
});
|
|
3396
3523
|
};
|
|
3524
|
+
StentorRouterChat.prototype.sendButtonPressed = function (buttonId) {
|
|
3525
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
3526
|
+
var data;
|
|
3527
|
+
return __generator$1(this, function (_a) {
|
|
3528
|
+
log("Sending \"button pressed\" event - id: ".concat(buttonId));
|
|
3529
|
+
data = { id: buttonId };
|
|
3530
|
+
this.emit("button pressed", data);
|
|
3531
|
+
return [2 /*return*/];
|
|
3532
|
+
});
|
|
3533
|
+
});
|
|
3534
|
+
};
|
|
3397
3535
|
StentorRouterChat.prototype.postVisitorInfo = function () {
|
|
3398
3536
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
3399
3537
|
return __generator$1(this, function (_a) {
|
|
@@ -3405,7 +3543,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3405
3543
|
};
|
|
3406
3544
|
StentorRouterChat.prototype.postMessage = function (message) {
|
|
3407
3545
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
3408
|
-
var userId, sessionId, accessToken, attributes, rwgToken, merchantId, environment, enablePreferredTime, service, origin,
|
|
3546
|
+
var userId, sessionId, accessToken, attributes, rwgToken, merchantId, environment, enablePreferredTime, service, origin, request;
|
|
3409
3547
|
return __generator$1(this, function (_a) {
|
|
3410
3548
|
userId = this._userId;
|
|
3411
3549
|
sessionId = this._sessionId;
|
|
@@ -3435,8 +3573,8 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3435
3573
|
if (origin) {
|
|
3436
3574
|
attributes["origin"] = origin;
|
|
3437
3575
|
}
|
|
3438
|
-
|
|
3439
|
-
|
|
3576
|
+
request = requestFromMessage(message, userId, this.isNewSession, sessionId, accessToken, attributes, this.visitorInfo);
|
|
3577
|
+
// Router attributes are now added at the payload root level in emit()
|
|
3440
3578
|
this.emit("new message", request);
|
|
3441
3579
|
return [2 /*return*/];
|
|
3442
3580
|
});
|
|
@@ -7550,6 +7688,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
7550
7688
|
}
|
|
7551
7689
|
StentorServerChat.prototype.init = function (dispatch) {
|
|
7552
7690
|
var _this = this;
|
|
7691
|
+
log("[StentorServerChat] Creating new socket connection to ".concat(this.config.url));
|
|
7553
7692
|
this.socket = lookup(this.config.url, {
|
|
7554
7693
|
transports: ["websocket"],
|
|
7555
7694
|
reconnection: true,
|
|
@@ -7558,6 +7697,10 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
7558
7697
|
reconnectionAttempts: 5
|
|
7559
7698
|
});
|
|
7560
7699
|
this.dispatch = dispatch;
|
|
7700
|
+
// Log connect event
|
|
7701
|
+
this.socket.on("connect", function () {
|
|
7702
|
+
log("[StentorServerChat] Socket CONNECTED - ID: ".concat(_this.socket.id));
|
|
7703
|
+
});
|
|
7561
7704
|
// TODO: Authenticate - or at least tell the server who you are
|
|
7562
7705
|
// Socket events
|
|
7563
7706
|
this.socket.on("account_status", function (data) {
|
|
@@ -7603,7 +7746,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
7603
7746
|
type: "chat.memberjoin",
|
|
7604
7747
|
user: {
|
|
7605
7748
|
displayName: data.username,
|
|
7606
|
-
nick: "agent:robot",
|
|
7749
|
+
nick: data.nick || "agent:robot",
|
|
7607
7750
|
avatarPath: data.avatarPath
|
|
7608
7751
|
},
|
|
7609
7752
|
timestamp: +new Date(),
|
|
@@ -7654,7 +7797,9 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
7654
7797
|
}
|
|
7655
7798
|
});
|
|
7656
7799
|
});
|
|
7657
|
-
this.socket.on("disconnect", function () {
|
|
7800
|
+
this.socket.on("disconnect", function (reason) {
|
|
7801
|
+
var reasonStr = typeof reason === "string" ? reason : String(reason || "unknown");
|
|
7802
|
+
log("[StentorServerChat] Socket DISCONNECTED - Reason: ".concat(reasonStr));
|
|
7658
7803
|
log("SERVER: disconnect");
|
|
7659
7804
|
_this.dispatch(setAccountStatus("offline"));
|
|
7660
7805
|
_this.dispatch(setConnectionStatus("offline"));
|
|
@@ -7705,6 +7850,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
7705
7850
|
};
|
|
7706
7851
|
StentorServerChat.prototype.dispose = function () {
|
|
7707
7852
|
var _a;
|
|
7853
|
+
log("[StentorServerChat] dispose() called - manually disconnecting socket");
|
|
7708
7854
|
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
7709
7855
|
};
|
|
7710
7856
|
StentorServerChat.prototype.sleep = function () {
|
|
@@ -7753,23 +7899,46 @@ function createChatServerCore(config, options) {
|
|
|
7753
7899
|
function createChatServer(config, options) {
|
|
7754
7900
|
return new LogChat(createChatServerCore(config, options));
|
|
7755
7901
|
}
|
|
7756
|
-
var ChatServerContext =
|
|
7902
|
+
var ChatServerContext = require$$1.createContext(null);
|
|
7757
7903
|
function useChatServer(config, options) {
|
|
7758
|
-
var _a =
|
|
7904
|
+
var _a = require$$1.useState(), server = _a[0], setServer = _a[1];
|
|
7759
7905
|
var dispatch = useChatDispatch();
|
|
7760
7906
|
var deps = [options, config, dispatch];
|
|
7907
|
+
// Track previous values to detect what changed
|
|
7908
|
+
var prevDepsRef = require$$1.useRef(undefined);
|
|
7761
7909
|
// Log what caused the "effect"
|
|
7762
7910
|
// useWhatChanged(deps, "options, config, dispatch");
|
|
7763
|
-
|
|
7911
|
+
require$$1.useEffect(function () {
|
|
7912
|
+
// Log when effect runs and what changed (for debugging connection issues)
|
|
7913
|
+
if (prevDepsRef.current) {
|
|
7914
|
+
var _a = prevDepsRef.current, prevOptions = _a[0], prevConfig = _a[1], prevDispatch = _a[2];
|
|
7915
|
+
var changes = [];
|
|
7916
|
+
if (prevOptions !== options)
|
|
7917
|
+
changes.push("options");
|
|
7918
|
+
if (prevConfig !== config)
|
|
7919
|
+
changes.push("config");
|
|
7920
|
+
if (prevDispatch !== dispatch)
|
|
7921
|
+
changes.push("dispatch");
|
|
7922
|
+
if (changes.length > 0) {
|
|
7923
|
+
log("[useChatServer] Effect re-running due to: ".concat(changes.join(", ")));
|
|
7924
|
+
}
|
|
7925
|
+
}
|
|
7926
|
+
else {
|
|
7927
|
+
log("[useChatServer] Effect running for first time");
|
|
7928
|
+
}
|
|
7929
|
+
prevDepsRef.current = [options, config, dispatch];
|
|
7764
7930
|
// Don't create server if config is null (waiting for async config load)
|
|
7765
7931
|
if (!config || !options) {
|
|
7932
|
+
log("[useChatServer] Config or options null, not creating server");
|
|
7766
7933
|
setServer(undefined);
|
|
7767
7934
|
return undefined;
|
|
7768
7935
|
}
|
|
7936
|
+
log("Creating new chat server - type: ".concat(config.type));
|
|
7769
7937
|
var newServer = createChatServer(config, options);
|
|
7770
7938
|
newServer.init(dispatch);
|
|
7771
7939
|
setServer(newServer);
|
|
7772
7940
|
return function () {
|
|
7941
|
+
log("Cleanup - disposing old server");
|
|
7773
7942
|
newServer.dispose();
|
|
7774
7943
|
};
|
|
7775
7944
|
}, deps);
|
|
@@ -7778,8 +7947,8 @@ function useChatServer(config, options) {
|
|
|
7778
7947
|
|
|
7779
7948
|
function useChatServerDispatch() {
|
|
7780
7949
|
var inner = useChatDispatch();
|
|
7781
|
-
var chatServer =
|
|
7782
|
-
return
|
|
7950
|
+
var chatServer = require$$1.useContext(ChatServerContext);
|
|
7951
|
+
return require$$1.useCallback(function (action) {
|
|
7783
7952
|
if (!action) {
|
|
7784
7953
|
console.warn("react bug? Someone invokes with null");
|
|
7785
7954
|
return;
|
|
@@ -7809,17 +7978,16 @@ var ChatChipsContainer = function (_) {
|
|
|
7809
7978
|
}));
|
|
7810
7979
|
}
|
|
7811
7980
|
}
|
|
7812
|
-
return (
|
|
7813
|
-
React$1.createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
|
|
7981
|
+
return (require$$0.jsx("div", { className: "message-list-container__chips ".concat(!(chips === null || chips === void 0 ? void 0 : chips.length) ? "message-list-container__chips--empty" : ""), children: require$$0.jsx(ChatChips, { options: chips, onOptionClick: optionOnChange }) }));
|
|
7814
7982
|
};
|
|
7815
7983
|
|
|
7816
7984
|
var ButtonGroup = function (_a) {
|
|
7817
7985
|
var children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b;
|
|
7818
|
-
return (
|
|
7986
|
+
return (require$$0.jsx("div", { className: "button-group ".concat(className), children: children }));
|
|
7819
7987
|
};
|
|
7820
7988
|
|
|
7821
7989
|
var CancelButton = function (props) {
|
|
7822
|
-
return (
|
|
7990
|
+
return (require$$0.jsx("div", { id: "xapp-widget-close", "aria-label": "close widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "cancel-button", onClick: props.onClick }));
|
|
7823
7991
|
};
|
|
7824
7992
|
|
|
7825
7993
|
var lib = {};
|
|
@@ -7904,10 +8072,8 @@ var ChatMenuItem = function (props) {
|
|
|
7904
8072
|
props.onClick(props.label);
|
|
7905
8073
|
}
|
|
7906
8074
|
}
|
|
7907
|
-
var content = props.subtitle ? (
|
|
7908
|
-
|
|
7909
|
-
React$1.createElement("div", { className: "chat-menu-item--subtitle" }, props.subtitle))) : (React$1.createElement("span", null, props.label));
|
|
7910
|
-
return (React$1.createElement("button", { type: "button", className: "chat-menu-item", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: handleClick }, content));
|
|
8075
|
+
var content = props.subtitle ? (require$$0.jsxs("span", { children: [require$$0.jsx("div", { children: props.label }), require$$0.jsx("div", { className: "chat-menu-item--subtitle", children: props.subtitle })] })) : (require$$0.jsx("span", { children: props.label }));
|
|
8076
|
+
return (require$$0.jsx("button", { type: "button", className: "chat-menu-item", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: handleClick, children: content }));
|
|
7911
8077
|
};
|
|
7912
8078
|
|
|
7913
8079
|
var _this = undefined;
|
|
@@ -7917,28 +8083,24 @@ var ChatMenu = function (props) {
|
|
|
7917
8083
|
var handleOpenUrl = useOpenUrlCallback();
|
|
7918
8084
|
var chatDispatch = useChatDispatch();
|
|
7919
8085
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
7920
|
-
return (
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
return React$1.createElement("button", { key: i, className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, chatDispatch, visuals, item.behavior) }, item.text);
|
|
7939
|
-
}
|
|
7940
|
-
return React$1.createElement("p", null, "Unknown");
|
|
7941
|
-
})));
|
|
8086
|
+
return (require$$0.jsx("div", { className: "chat-menu-".concat(openFrom, " ").concat(opened ? "chat-menu-".concat(openFrom, "--opened") : "chat-menu-".concat(openFrom, "--closed")), children: items.map(function (item, i) {
|
|
8087
|
+
if (lib.isStandardMenuItem(item)) {
|
|
8088
|
+
return (require$$0.jsx(ChatMenuItem, { onClick: props.onItemClick, label: item.label, subtitle: item.subtitle }, i));
|
|
8089
|
+
}
|
|
8090
|
+
else if (lib.isStaticImageMenuItem(item)) {
|
|
8091
|
+
return (require$$0.jsx("div", { className: "chat-menu-item-static", children: require$$0.jsx("img", { style: {
|
|
8092
|
+
maxHeight: "100%",
|
|
8093
|
+
maxWidth: "auto",
|
|
8094
|
+
}, src: item.imageUrl, alt: "Menu Item" }) }, i));
|
|
8095
|
+
}
|
|
8096
|
+
else if (lib.isStaticTextMenuItem(item)) {
|
|
8097
|
+
return (require$$0.jsx("div", { className: "chat-menu-item-static-text", children: require$$0.jsxs("div", { children: [require$$0.jsx("div", { children: item.title }), require$$0.jsx("div", { className: "chat-menu-item-static-text--body", children: item.body })] }) }, i));
|
|
8098
|
+
}
|
|
8099
|
+
else if (lib.isOpenURLMenuItem(item)) {
|
|
8100
|
+
return (require$$0.jsx("button", { className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, chatDispatch, visuals, item.behavior), children: item.text }, i));
|
|
8101
|
+
}
|
|
8102
|
+
return require$$0.jsx("p", { children: "Unknown" });
|
|
8103
|
+
}) }));
|
|
7942
8104
|
};
|
|
7943
8105
|
|
|
7944
8106
|
var DrawerBars = function (props) {
|
|
@@ -7950,23 +8112,23 @@ var DrawerBars = function (props) {
|
|
|
7950
8112
|
function getBars() {
|
|
7951
8113
|
var barElements = [];
|
|
7952
8114
|
for (var bar = 0; bar < bars; bar++) {
|
|
7953
|
-
barElements.push(
|
|
8115
|
+
barElements.push(require$$0.jsx("div", { className: "drawer-bar bar".concat(bar) }, "drawer-bar-".concat(bar)));
|
|
7954
8116
|
}
|
|
7955
8117
|
return barElements;
|
|
7956
8118
|
}
|
|
7957
|
-
return (
|
|
8119
|
+
return (require$$0.jsx("button", { className: "drawer-bars", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, "aria-label": "open menu", "aria-hidden": false, onClick: props.onToggle, children: getBars() }));
|
|
7958
8120
|
};
|
|
7959
8121
|
|
|
7960
8122
|
var MenuButton = function (props) {
|
|
7961
|
-
return (
|
|
8123
|
+
return (require$$0.jsx("div", { id: "xapp-widget-menu", "aria-label": "open menu", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "menu-button", onClick: props.onClick }));
|
|
7962
8124
|
};
|
|
7963
8125
|
|
|
7964
8126
|
var MinimizeButton = function (props) {
|
|
7965
|
-
return (
|
|
8127
|
+
return (require$$0.jsx("div", { id: "xapp-widget-minimize", "aria-label": "minimize widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "minimize-button ".concat(props.showInRight ? "positionRight" : ""), onClick: props.onClick }));
|
|
7966
8128
|
};
|
|
7967
8129
|
|
|
7968
8130
|
var RefreshButton = function (props) {
|
|
7969
|
-
return (
|
|
8131
|
+
return (require$$0.jsx("div", { id: "xapp-widget-refresh", "aria-label": "refresh chat", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "refresh-button ".concat(props.showInRight ? "positionRight" : props.showInLeft ? "positionLeft" : ""), onClick: props.onClick }));
|
|
7970
8132
|
};
|
|
7971
8133
|
|
|
7972
8134
|
var DEFAULT_STATUS_CONFIG = {
|
|
@@ -7977,6 +8139,7 @@ var DEFAULT_STATUS_CONFIG = {
|
|
|
7977
8139
|
};
|
|
7978
8140
|
function getStatusText(status, config) {
|
|
7979
8141
|
var _a, _b, _c, _d;
|
|
8142
|
+
log("getStatusText called with status: \"".concat(status, "\""));
|
|
7980
8143
|
switch (status) {
|
|
7981
8144
|
case "online":
|
|
7982
8145
|
return (_a = config === null || config === void 0 ? void 0 : config.online) !== null && _a !== void 0 ? _a : DEFAULT_STATUS_CONFIG.online;
|
|
@@ -7988,21 +8151,126 @@ function getStatusText(status, config) {
|
|
|
7988
8151
|
return (_d = config === null || config === void 0 ? void 0 : config.connecting) !== null && _d !== void 0 ? _d : DEFAULT_STATUS_CONFIG.connecting;
|
|
7989
8152
|
}
|
|
7990
8153
|
}
|
|
8154
|
+
/**
|
|
8155
|
+
* Determines if a string contains HTML tags
|
|
8156
|
+
*/
|
|
8157
|
+
function isHtmlString(text) {
|
|
8158
|
+
if (typeof text !== "string") {
|
|
8159
|
+
return false;
|
|
8160
|
+
}
|
|
8161
|
+
// Check for common HTML patterns
|
|
8162
|
+
var htmlPattern = /<\/?[a-z][\s\S]*>/i;
|
|
8163
|
+
return htmlPattern.test(text);
|
|
8164
|
+
}
|
|
8165
|
+
/**
|
|
8166
|
+
* Sanitizes HTML string by removing potentially dangerous elements and attributes
|
|
8167
|
+
*/
|
|
8168
|
+
function sanitizeHtml(html) {
|
|
8169
|
+
try {
|
|
8170
|
+
// Check if DOMParser is available
|
|
8171
|
+
if (typeof DOMParser === "undefined") {
|
|
8172
|
+
log("DOMParser not available, returning text content only");
|
|
8173
|
+
return html.replace(/<[^>]*>/g, ""); // Strip all HTML tags as fallback
|
|
8174
|
+
}
|
|
8175
|
+
// Create a temporary DOM element to parse the HTML
|
|
8176
|
+
var doc_1 = new DOMParser().parseFromString(html, "text/html");
|
|
8177
|
+
// Check if parsing was successful
|
|
8178
|
+
if (!doc_1 || !doc_1.body) {
|
|
8179
|
+
log("DOMParser failed to parse HTML, returning text content only");
|
|
8180
|
+
return html.replace(/<[^>]*>/g, ""); // Strip all HTML tags as fallback
|
|
8181
|
+
}
|
|
8182
|
+
// List of allowed tags (whitelist approach)
|
|
8183
|
+
var allowedTags_1 = ["span", "div", "p", "strong", "em", "b", "i", "u", "br"];
|
|
8184
|
+
// List of allowed style properties
|
|
8185
|
+
var allowedStyleProps_1 = [
|
|
8186
|
+
"color", "background-color", "font-size", "font-weight", "font-style",
|
|
8187
|
+
"text-align", "display", "flex", "align-items", "justify-content",
|
|
8188
|
+
"gap", "margin", "padding", "width", "height", "border-radius"
|
|
8189
|
+
];
|
|
8190
|
+
// Recursive function to clean nodes
|
|
8191
|
+
var cleanNode_1 = function (node) {
|
|
8192
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
8193
|
+
var element_1 = node;
|
|
8194
|
+
var tagName = element_1.tagName.toLowerCase();
|
|
8195
|
+
// Remove if not in allowed tags, but preserve text content
|
|
8196
|
+
if (!allowedTags_1.includes(tagName)) {
|
|
8197
|
+
// Replace the element with its text content
|
|
8198
|
+
var textNode = doc_1.createTextNode(element_1.textContent || "");
|
|
8199
|
+
element_1.replaceWith(textNode);
|
|
8200
|
+
return;
|
|
8201
|
+
}
|
|
8202
|
+
// Remove all attributes except style
|
|
8203
|
+
var attributes = Array.from(element_1.attributes);
|
|
8204
|
+
attributes.forEach(function (attr) {
|
|
8205
|
+
if (attr.name !== "style") {
|
|
8206
|
+
element_1.removeAttribute(attr.name);
|
|
8207
|
+
}
|
|
8208
|
+
});
|
|
8209
|
+
// Clean style attribute - only allow safe properties
|
|
8210
|
+
if (element_1.hasAttribute("style")) {
|
|
8211
|
+
var styleText = element_1.getAttribute("style") || "";
|
|
8212
|
+
var cleanedStyles_1 = [];
|
|
8213
|
+
// Parse individual style properties
|
|
8214
|
+
styleText.split(";").forEach(function (declaration) {
|
|
8215
|
+
var _a = declaration.split(":"), prop = _a[0], valueParts = _a.slice(1);
|
|
8216
|
+
var value = valueParts.join(":").trim(); // Rejoin in case value contains colons
|
|
8217
|
+
var propTrimmed = prop.trim();
|
|
8218
|
+
if (propTrimmed && value && allowedStyleProps_1.includes(propTrimmed.toLowerCase())) {
|
|
8219
|
+
// Additional validation: ensure value doesn't contain javascript: or expression()
|
|
8220
|
+
if (!/javascript:|expression\(|@import|behavior:/i.test(value)) {
|
|
8221
|
+
cleanedStyles_1.push("".concat(propTrimmed, ": ").concat(value));
|
|
8222
|
+
}
|
|
8223
|
+
}
|
|
8224
|
+
});
|
|
8225
|
+
if (cleanedStyles_1.length > 0) {
|
|
8226
|
+
element_1.setAttribute("style", cleanedStyles_1.join("; "));
|
|
8227
|
+
}
|
|
8228
|
+
else {
|
|
8229
|
+
element_1.removeAttribute("style");
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
// Recursively clean child nodes
|
|
8233
|
+
var children = Array.from(element_1.childNodes);
|
|
8234
|
+
children.forEach(function (child) { return cleanNode_1(child); });
|
|
8235
|
+
}
|
|
8236
|
+
};
|
|
8237
|
+
// Clean each child of the body, not the body itself
|
|
8238
|
+
Array.from(doc_1.body.childNodes).forEach(function (child) { return cleanNode_1(child); });
|
|
8239
|
+
return doc_1.body.innerHTML;
|
|
8240
|
+
}
|
|
8241
|
+
catch (error) {
|
|
8242
|
+
log("Error sanitizing HTML: ".concat(error));
|
|
8243
|
+
// Fallback: strip all HTML tags
|
|
8244
|
+
return html.replace(/<[^>]*>/g, "");
|
|
8245
|
+
}
|
|
8246
|
+
}
|
|
8247
|
+
/**
|
|
8248
|
+
* Safely renders subtitle text that can be plain text, JSX, or HTML string
|
|
8249
|
+
*/
|
|
8250
|
+
function renderSubtitleText(text) {
|
|
8251
|
+
// If it's an HTML string, sanitize and render it using dangerouslySetInnerHTML
|
|
8252
|
+
if (isHtmlString(text)) {
|
|
8253
|
+
var sanitizedHtml = sanitizeHtml(text);
|
|
8254
|
+
return require$$0.jsx("span", { dangerouslySetInnerHTML: { __html: sanitizedHtml } });
|
|
8255
|
+
}
|
|
8256
|
+
// Otherwise, render as-is (handles JSX and plain text)
|
|
8257
|
+
return text;
|
|
8258
|
+
}
|
|
7991
8259
|
var refreshButtonAriaLabel = "To refresh chat click on clockwise gapped circle arrow icon in top right side of widget. ";
|
|
7992
8260
|
var minimizeButtonAriaLabel = "To minimize widget click on minus icon in top right side of widget. ";
|
|
7993
8261
|
var closeButtonAriaLabel = "To close widget click on close icon in top right side of widget.";
|
|
7994
8262
|
var ChatHeader = function (props) {
|
|
7995
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
8263
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
7996
8264
|
var innerDispatch = useChatDispatch();
|
|
7997
8265
|
var menuConfig = props.menuConfig, onSubmit = props.onSubmit;
|
|
7998
|
-
var
|
|
8266
|
+
var _r = require$$1.useState(false), drawerOpen = _r[0], setDrawerState = _r[1]; // false initially
|
|
7999
8267
|
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
8000
8268
|
var showMenuLeft = menuPosition === "HEADER_LEFT";
|
|
8001
8269
|
var showMenuRight = menuPosition === "HEADER_RIGHT";
|
|
8002
8270
|
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items;
|
|
8003
8271
|
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex;
|
|
8004
8272
|
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex;
|
|
8005
|
-
var menuItems =
|
|
8273
|
+
var menuItems = require$$1.useMemo(function () { return (menuItemsRaw ? menuItemsRaw : []); }, [menuItemsRaw]);
|
|
8006
8274
|
// Check if we have a right-side menu
|
|
8007
8275
|
var hasRightMenu = showMenuRight && menuItems.length > 0;
|
|
8008
8276
|
function toggleDrawer() {
|
|
@@ -8027,46 +8295,35 @@ var ChatHeader = function (props) {
|
|
|
8027
8295
|
if (canCancel) {
|
|
8028
8296
|
ariaLabel = "".concat(ariaLabel).concat(closeButtonAriaLabel);
|
|
8029
8297
|
}
|
|
8030
|
-
return (
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
React$1.createElement("div", { className: "\n ".concat("status-text", "\n ").concat(showMenuLeft && menuItems.length
|
|
8038
|
-
? "status-text-positionWithMenu"
|
|
8039
|
-
: ((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined
|
|
8040
|
-
? "status-text-positionLeftNoAvatar"
|
|
8041
|
-
: "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter)
|
|
8042
|
-
? "status-text-positionCenter"
|
|
8043
|
-
: "", " \n ") },
|
|
8044
|
-
React$1.createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status)),
|
|
8045
|
-
((_g = (_f = props.config) === null || _f === void 0 ? void 0 : _f.subtitle) === null || _g === void 0 ? void 0 : _g.enabled) && (React$1.createElement("span", { className: "status-text-subtitle" }, (_k = (_j = (_h = props.config) === null || _h === void 0 ? void 0 : _h.subtitle) === null || _j === void 0 ? void 0 : _j.text) !== null && _k !== void 0 ? _k : ""))),
|
|
8046
|
-
React$1.createElement(ButtonGroup, null,
|
|
8047
|
-
hasRightMenu && (React$1.createElement(MenuButton, { onClick: toggleDrawer, tabIndex: menuButtonTabIndex })),
|
|
8048
|
-
props.canRefresh && (React$1.createElement(RefreshButton, { onClick: props.refreshOnClick, tabIndex: (_m = (_l = props.config) === null || _l === void 0 ? void 0 : _l.actions) === null || _m === void 0 ? void 0 : _m.refreshTabIndex, showInLeft: false, showInRight: false })),
|
|
8049
|
-
props.canMinimize && (React$1.createElement(MinimizeButton, { onClick: props.minimizeOnClick, tabIndex: (_p = (_o = props.config) === null || _o === void 0 ? void 0 : _o.actions) === null || _p === void 0 ? void 0 : _p.minimizeTabIndex, showInRight: false })),
|
|
8050
|
-
props.canCancel && (React$1.createElement(CancelButton, { onClick: props.cancelOnClick, tabIndex: (_r = (_q = props.config) === null || _q === void 0 ? void 0 : _q.actions) === null || _r === void 0 ? void 0 : _r.cancelTabIndex })))),
|
|
8051
|
-
drawerOpen ? (React$1.createElement("div", { className: "xa-chat-menu-container" },
|
|
8052
|
-
React$1.createElement(ChatMenu, { openFrom: showMenuRight ? "right" : "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }))) : (React$1.createElement(React$1.Fragment, null))));
|
|
8298
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "status-container background-header", "aria-label": ariaLabel, "aria-hidden": false, children: [showMenuLeft && menuItems.length ? (require$$0.jsx(require$$0.Fragment, { children: require$$0.jsx("div", { className: "chat-footer__menu-icon", children: require$$0.jsx(DrawerBars, { bars: 3, tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }) }) })) : (require$$0.jsx(require$$0.Fragment, {})), ((_b = props === null || props === void 0 ? void 0 : props.agent) === null || _b === void 0 ? void 0 : _b.avatarPath) === undefined ? (require$$0.jsx("div", {})) : (require$$0.jsx("div", { className: "status-container__avatar", children: require$$0.jsx(Avatar, { entity: props.agent }) })), require$$0.jsxs("div", { className: "\n ".concat("status-text", "\n ").concat(showMenuLeft && menuItems.length
|
|
8299
|
+
? "status-text-positionWithMenu"
|
|
8300
|
+
: ((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined
|
|
8301
|
+
? "status-text-positionLeftNoAvatar"
|
|
8302
|
+
: "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter)
|
|
8303
|
+
? "status-text-positionCenter"
|
|
8304
|
+
: "", " \n "), children: [require$$0.jsx("span", { className: "status-text-title", children: getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status) }), ((_g = (_f = props.config) === null || _f === void 0 ? void 0 : _f.subtitle) === null || _g === void 0 ? void 0 : _g.enabled) && (require$$0.jsx("span", { className: "status-text-subtitle", children: renderSubtitleText((_j = (_h = props.config) === null || _h === void 0 ? void 0 : _h.subtitle) === null || _j === void 0 ? void 0 : _j.text) }))] }), require$$0.jsxs(ButtonGroup, { children: [hasRightMenu && (require$$0.jsx(MenuButton, { onClick: toggleDrawer, tabIndex: menuButtonTabIndex })), props.canRefresh && (require$$0.jsx(RefreshButton, { onClick: props.refreshOnClick, tabIndex: (_l = (_k = props.config) === null || _k === void 0 ? void 0 : _k.actions) === null || _l === void 0 ? void 0 : _l.refreshTabIndex, showInLeft: false, showInRight: false })), props.canMinimize && (require$$0.jsx(MinimizeButton, { onClick: props.minimizeOnClick, tabIndex: (_o = (_m = props.config) === null || _m === void 0 ? void 0 : _m.actions) === null || _o === void 0 ? void 0 : _o.minimizeTabIndex, showInRight: false })), props.canCancel && (require$$0.jsx(CancelButton, { onClick: props.cancelOnClick, tabIndex: (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.actions) === null || _q === void 0 ? void 0 : _q.cancelTabIndex }))] })] }), drawerOpen ? (require$$0.jsx("div", { className: "xa-chat-menu-container", children: require$$0.jsx(ChatMenu, { openFrom: showMenuRight ? "right" : "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) })) : (require$$0.jsx(require$$0.Fragment, {}))] }));
|
|
8053
8305
|
};
|
|
8054
8306
|
|
|
8055
|
-
var UnknownMessage = function () { return
|
|
8307
|
+
var UnknownMessage = function () { return require$$0.jsx(require$$0.Fragment, {}); };
|
|
8056
8308
|
|
|
8057
8309
|
function renderAvatar(entity) {
|
|
8058
|
-
return (
|
|
8059
|
-
React$1.createElement(Avatar, { entity: entity })));
|
|
8310
|
+
return (require$$0.jsx("div", { className: "xappw-chat-msg-part__avatar", children: require$$0.jsx(Avatar, { entity: entity }) }));
|
|
8060
8311
|
}
|
|
8061
8312
|
var ChatMessagePart = function (props) {
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8313
|
+
var _a;
|
|
8314
|
+
var position = (_a = props.avatarPosition) !== null && _a !== void 0 ? _a : "left";
|
|
8315
|
+
var containerClass = "xappw-chat-msg-part" +
|
|
8316
|
+
(position === "below" ? " xappw-chat-msg-part--avatar-below" : "") +
|
|
8317
|
+
(position === "bottom" ? " xappw-chat-msg-part--avatar-bottom" : "");
|
|
8318
|
+
var user = props.user, hideUserInfo = props.hideUserInfo;
|
|
8319
|
+
// Hide user info if hideUserInfo is true and position is "bottom"
|
|
8320
|
+
var shouldHideUserInfo = hideUserInfo && position === "bottom";
|
|
8321
|
+
return (require$$0.jsx("div", { className: containerClass, children: position === "left" ? (require$$0.jsxs(require$$0.Fragment, { children: [props.showAvatar && renderAvatar(user), props.children] })) : (require$$0.jsxs(require$$0.Fragment, { children: [props.children, props.showAvatar && !shouldHideUserInfo && (require$$0.jsxs("div", { className: "xappw-chat-msg-part__avatar-wrapper", children: [renderAvatar(user), (user === null || user === void 0 ? void 0 : user.displayName) && (require$$0.jsx("div", { className: "xappw-chat-msg-part__avatar-name", children: user.displayName }))] }))] })) }));
|
|
8065
8322
|
};
|
|
8066
8323
|
|
|
8067
8324
|
function useExecuteActionCallback() {
|
|
8068
8325
|
var dispatch = useChatServerDispatch();
|
|
8069
|
-
return
|
|
8326
|
+
return require$$1.useCallback(function (text, meta) {
|
|
8070
8327
|
dispatch(executeAction(text, meta));
|
|
8071
8328
|
}, [dispatch]);
|
|
8072
8329
|
}
|
|
@@ -8076,7 +8333,7 @@ function useButtonCallback() {
|
|
|
8076
8333
|
var chatDispatch = useChatDispatch();
|
|
8077
8334
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
8078
8335
|
var executeAction = useExecuteActionCallback();
|
|
8079
|
-
return
|
|
8336
|
+
return require$$1.useCallback(function (button) {
|
|
8080
8337
|
if (button.actionUrl) {
|
|
8081
8338
|
handleOpenUrl(button.actionUrl, chatDispatch, visuals);
|
|
8082
8339
|
}
|
|
@@ -8109,17 +8366,15 @@ function isList(display) {
|
|
|
8109
8366
|
|
|
8110
8367
|
var CardMiddlewareWidget = function (props) {
|
|
8111
8368
|
var msg = props.msg, ctx = props.ctx;
|
|
8112
|
-
var card =
|
|
8369
|
+
var card = require$$1.useMemo(function () { return convertFromCardDisplay(msg); }, [msg]);
|
|
8113
8370
|
var user = ctx.user;
|
|
8114
8371
|
var handleButton = useButtonCallback();
|
|
8115
|
-
return (
|
|
8116
|
-
React$1.createElement("div", { className: "chat-msg" },
|
|
8117
|
-
React$1.createElement(ChatCard, { card: card, onButtonClick: handleButton }))));
|
|
8372
|
+
return (require$$0.jsx(ChatMessagePart, { showAvatar: true, user: user, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx(ChatCard, { card: card, onButtonClick: handleButton }) }) }));
|
|
8118
8373
|
};
|
|
8119
8374
|
var CardMiddleware = function (next) { return function (props) {
|
|
8120
8375
|
var msg = props.msg, ctx = props.ctx;
|
|
8121
8376
|
if (isCard(msg)) {
|
|
8122
|
-
return
|
|
8377
|
+
return require$$0.jsx(CardMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
8123
8378
|
}
|
|
8124
8379
|
return next(props);
|
|
8125
8380
|
}; };
|
|
@@ -8161,9 +8416,9 @@ function createSubscribableArray(originalValue) {
|
|
|
8161
8416
|
};
|
|
8162
8417
|
}
|
|
8163
8418
|
function useSubscribableArray(array) {
|
|
8164
|
-
var _a =
|
|
8419
|
+
var _a = require$$1.useState(array.getArray()), res = _a[0], setRes = _a[1];
|
|
8165
8420
|
var mounted = useIsMounted();
|
|
8166
|
-
|
|
8421
|
+
require$$1.useEffect(function () {
|
|
8167
8422
|
var subscription = array.subscribe(function (newVal) {
|
|
8168
8423
|
if (mounted()) {
|
|
8169
8424
|
setRes(newVal);
|
|
@@ -8195,7 +8450,7 @@ function useGlobalSubscribableArray(storage) {
|
|
|
8195
8450
|
}
|
|
8196
8451
|
function useLateMiddlewaresBuilder(storage) {
|
|
8197
8452
|
var middlewares = useGlobalSubscribableArray(storage);
|
|
8198
|
-
return
|
|
8453
|
+
return require$$1.useMemo(function () { return joinMiddlewares(middlewares); }, [middlewares]);
|
|
8199
8454
|
}
|
|
8200
8455
|
var storage = createStorage(globalThis, "xappMsgMiddlewares");
|
|
8201
8456
|
function useLateMiddleware() {
|
|
@@ -8203,16 +8458,14 @@ function useLateMiddleware() {
|
|
|
8203
8458
|
}
|
|
8204
8459
|
|
|
8205
8460
|
function getSvg() {
|
|
8206
|
-
return (
|
|
8207
|
-
React$1.createElement("path", { d: "M17 17H3V3h5V1H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5h-2z" }),
|
|
8208
|
-
React$1.createElement("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })));
|
|
8461
|
+
return (require$$0.jsxs("svg", { viewBox: "0 0 20 20", children: [require$$0.jsx("path", { d: "M17 17H3V3h5V1H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5h-2z" }), require$$0.jsx("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })] }));
|
|
8209
8462
|
}
|
|
8210
8463
|
var ExternalLink = function (props) {
|
|
8211
8464
|
var url = props.url;
|
|
8212
|
-
var handleClick =
|
|
8465
|
+
var handleClick = require$$1.useCallback(function (ev) {
|
|
8213
8466
|
ev.preventDefault();
|
|
8214
8467
|
}, []);
|
|
8215
|
-
return (
|
|
8468
|
+
return (require$$0.jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick, children: getSvg() }));
|
|
8216
8469
|
};
|
|
8217
8470
|
|
|
8218
8471
|
function firstIndex(val, patterns) {
|
|
@@ -8322,10 +8575,10 @@ function reduceLink(url, maxLength) {
|
|
|
8322
8575
|
|
|
8323
8576
|
var SmartLink = function (props) {
|
|
8324
8577
|
var url = props.url, className = props.className;
|
|
8325
|
-
var handleClick =
|
|
8578
|
+
var handleClick = require$$1.useCallback(function (ev) {
|
|
8326
8579
|
ev.preventDefault();
|
|
8327
8580
|
}, []);
|
|
8328
|
-
return (
|
|
8581
|
+
return (require$$0.jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: className, onClick: handleClick, children: reduceLink(url, 40) }));
|
|
8329
8582
|
};
|
|
8330
8583
|
|
|
8331
8584
|
var ListItem = function (props) {
|
|
@@ -8333,33 +8586,18 @@ var ListItem = function (props) {
|
|
|
8333
8586
|
var item = props.item;
|
|
8334
8587
|
var layout = props.layout || "normal";
|
|
8335
8588
|
var url = item.url || item.imageActionUrl;
|
|
8336
|
-
return (
|
|
8337
|
-
React$1.createElement("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout) },
|
|
8338
|
-
React$1.createElement("div", { className: "xappw-vlist-item__description" },
|
|
8339
|
-
item.title && React$1.createElement("div", { className: "xappw-vlist-item__title" },
|
|
8340
|
-
React$1.createElement("span", null, item.title)),
|
|
8341
|
-
url && React$1.createElement(SmartLink, { url: url, className: "xappw-vlist-item__link" }),
|
|
8342
|
-
item.subTitle && React$1.createElement("div", { className: "xappw-vlist-item__subtitle" },
|
|
8343
|
-
React$1.createElement("span", null, item.subTitle)),
|
|
8344
|
-
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick })),
|
|
8345
|
-
React$1.createElement("div", { className: "xappw-vlist-item__side" },
|
|
8346
|
-
url && React$1.createElement(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }),
|
|
8347
|
-
React$1.createElement(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })))));
|
|
8589
|
+
return (require$$0.jsx(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl, children: require$$0.jsxs("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout), children: [require$$0.jsxs("div", { className: "xappw-vlist-item__description", children: [item.title && (require$$0.jsx("div", { className: "xappw-vlist-item__title", children: require$$0.jsx("span", { children: item.title }) })), url && require$$0.jsx(SmartLink, { url: url, className: "xappw-vlist-item__link" }), item.subTitle && (require$$0.jsx("div", { className: "xappw-vlist-item__subtitle", children: require$$0.jsx("span", { children: item.subTitle }) })), !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && (require$$0.jsx(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick }))] }), require$$0.jsxs("div", { className: "xappw-vlist-item__side", children: [url && require$$0.jsx(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }), require$$0.jsx(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })] })] }) }));
|
|
8348
8590
|
};
|
|
8349
8591
|
|
|
8350
8592
|
var List = function (props) {
|
|
8351
8593
|
var list = props.list;
|
|
8352
|
-
var listRef =
|
|
8594
|
+
var listRef = require$$1.useRef(null);
|
|
8353
8595
|
var hasImage = list.items.some(function (item) { return item.imageUrl; });
|
|
8354
8596
|
var titlesOnly = !list.items.some(function (item) { var _a; return item.subTitle || ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length); });
|
|
8355
8597
|
var listItems = list.items.map(function (item, itemIndex) {
|
|
8356
|
-
return (
|
|
8357
|
-
React$1.createElement(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
8598
|
+
return (require$$0.jsx("div", { className: "xappw-vlist-container__item", children: require$$0.jsx(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl }) }, "item-key-".concat(itemIndex)));
|
|
8358
8599
|
});
|
|
8359
|
-
return (
|
|
8360
|
-
React$1.createElement("div", { ref: listRef, className: "xappw-vlist-container" },
|
|
8361
|
-
props.list.title && React$1.createElement("div", { className: "xappw-vlist__header" }, props.list.title),
|
|
8362
|
-
listItems)));
|
|
8600
|
+
return (require$$0.jsx("div", { className: "xappw-vlist", children: require$$0.jsxs("div", { ref: listRef, className: "xappw-vlist-container", children: [props.list.title && require$$0.jsx("div", { className: "xappw-vlist__header", children: props.list.title }), listItems] }) }));
|
|
8363
8601
|
};
|
|
8364
8602
|
|
|
8365
8603
|
var ListMiddlewareWidget = function (props) {
|
|
@@ -8367,38 +8605,31 @@ var ListMiddlewareWidget = function (props) {
|
|
|
8367
8605
|
if (!ctx) {
|
|
8368
8606
|
throw new TypeError("ctx not provided to ".concat(ListMiddlewareWidget.name));
|
|
8369
8607
|
}
|
|
8370
|
-
var list =
|
|
8608
|
+
var list = require$$1.useMemo(function () { return convertFromListDisplay(msg); }, [msg]);
|
|
8371
8609
|
var executeActionCallback = useExecuteActionCallback();
|
|
8372
|
-
var handleExecute =
|
|
8610
|
+
var handleExecute = require$$1.useCallback(function (ui, text, token) {
|
|
8373
8611
|
executeActionCallback(text, { token: token, action: "click", ui: ui });
|
|
8374
8612
|
}, [executeActionCallback]);
|
|
8375
8613
|
var handleButton = useButtonCallback();
|
|
8376
8614
|
var user = ctx.user;
|
|
8377
|
-
return (
|
|
8378
|
-
list.type === "CAROUSEL" && (React$1.createElement("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava" },
|
|
8379
|
-
React$1.createElement(Carousel, { list: list, onExecute: handleExecute.bind(null, "carousel"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }))),
|
|
8380
|
-
list.type === "LIST" && (React$1.createElement("div", { className: "chat-msg chat-msg--expand" },
|
|
8381
|
-
React$1.createElement(List, { list: list, onExecute: handleExecute.bind(null, "list"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl })))));
|
|
8615
|
+
return (require$$0.jsxs(ChatMessagePart, { showAvatar: false, user: user, children: [list.type === "CAROUSEL" && (require$$0.jsx("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava", children: require$$0.jsx(Carousel, { list: list, onExecute: handleExecute.bind(null, "carousel"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }) })), list.type === "LIST" && (require$$0.jsx("div", { className: "chat-msg chat-msg--expand", children: require$$0.jsx(List, { list: list, onExecute: handleExecute.bind(null, "list"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }) }))] }));
|
|
8382
8616
|
};
|
|
8383
8617
|
var ListMiddleware = function (next) { return function (props) {
|
|
8384
8618
|
var msg = props.msg, ctx = props.ctx;
|
|
8385
8619
|
if (isList(msg)) {
|
|
8386
|
-
return
|
|
8620
|
+
return require$$0.jsx(ListMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
8387
8621
|
}
|
|
8388
8622
|
return next(props);
|
|
8389
8623
|
}; };
|
|
8390
8624
|
|
|
8391
8625
|
var MultiSelect = function (props) {
|
|
8392
8626
|
var items = props.items, checked = props.checked, onChange = props.onChange;
|
|
8393
|
-
var handleToggle =
|
|
8627
|
+
var handleToggle = require$$1.useCallback(function (ev) {
|
|
8394
8628
|
var _a;
|
|
8395
8629
|
var id = ev.target.value;
|
|
8396
8630
|
onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
|
|
8397
8631
|
}, [checked, onChange]);
|
|
8398
|
-
return (
|
|
8399
|
-
React$1.createElement("label", null,
|
|
8400
|
-
React$1.createElement("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }),
|
|
8401
|
-
React$1.createElement("span", null, item.title)))); })));
|
|
8632
|
+
return (require$$0.jsx("ul", { className: "xappw-multiselect", children: items === null || items === void 0 ? void 0 : items.map(function (item) { return (require$$0.jsx("li", { children: require$$0.jsxs("label", { children: [require$$0.jsx("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }), require$$0.jsx("span", { children: item.title })] }) }, item.id)); }) }));
|
|
8402
8633
|
};
|
|
8403
8634
|
|
|
8404
8635
|
function isMultiSelect(display) {
|
|
@@ -8409,29 +8640,25 @@ function convertToMultiSelectItems(display) {
|
|
|
8409
8640
|
}
|
|
8410
8641
|
var MultiSelectMiddlewareWidget = function (props) {
|
|
8411
8642
|
var msg = props.msg, ctx = props.ctx;
|
|
8412
|
-
var items =
|
|
8643
|
+
var items = require$$1.useMemo(function () { return convertToMultiSelectItems(msg); }, [msg]);
|
|
8413
8644
|
var user = ctx.user;
|
|
8414
|
-
var _a =
|
|
8415
|
-
var handleSubmit =
|
|
8645
|
+
var _a = require$$1.useState({}), checked = _a[0], setChecked = _a[1];
|
|
8646
|
+
var handleSubmit = require$$1.useCallback(function () {
|
|
8416
8647
|
ctx.send({
|
|
8417
8648
|
type: "custom",
|
|
8418
8649
|
payload: JSON.stringify({
|
|
8419
8650
|
type: "OPTION_SELECT_REQUEST",
|
|
8420
8651
|
intentId: "OptionSelect",
|
|
8421
|
-
selected: Object.keys(checked).map(function (k) { return ({ id: k }); })
|
|
8422
|
-
})
|
|
8652
|
+
selected: Object.keys(checked).map(function (k) { return ({ id: k }); }),
|
|
8653
|
+
}),
|
|
8423
8654
|
});
|
|
8424
8655
|
}, [ctx, checked]);
|
|
8425
|
-
return (
|
|
8426
|
-
React$1.createElement("div", { className: "chat-msg" },
|
|
8427
|
-
React$1.createElement("div", null,
|
|
8428
|
-
React$1.createElement(MultiSelect, { items: items, checked: checked, onChange: setChecked }),
|
|
8429
|
-
React$1.createElement(ActionButton, { label: "Submit", onClick: handleSubmit })))));
|
|
8656
|
+
return (require$$0.jsx(ChatMessagePart, { showAvatar: true, user: user, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsxs("div", { children: [require$$0.jsx(MultiSelect, { items: items, checked: checked, onChange: setChecked }), require$$0.jsx(ActionButton, { label: "Submit", onClick: handleSubmit })] }) }) }));
|
|
8430
8657
|
};
|
|
8431
8658
|
var MultiSelectMiddleware = function (next) { return function (props) {
|
|
8432
8659
|
var msg = props.msg, ctx = props.ctx;
|
|
8433
8660
|
if (isMultiSelect(msg)) {
|
|
8434
|
-
return
|
|
8661
|
+
return require$$0.jsx(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
8435
8662
|
}
|
|
8436
8663
|
return next(props);
|
|
8437
8664
|
}; };
|
|
@@ -8443,14 +8670,14 @@ var StandardMiddlewaresBuilder = joinMiddlewares([
|
|
|
8443
8670
|
]);
|
|
8444
8671
|
function useStandardMiddlewareBuilder() {
|
|
8445
8672
|
var lateMiddleware = useLateMiddleware();
|
|
8446
|
-
return
|
|
8673
|
+
return require$$1.useMemo(function () { return joinMiddlewares([
|
|
8447
8674
|
lateMiddleware,
|
|
8448
8675
|
StandardMiddlewaresBuilder,
|
|
8449
8676
|
]); }, [lateMiddleware]);
|
|
8450
8677
|
}
|
|
8451
8678
|
function useStandardMiddleware() {
|
|
8452
8679
|
var builder = useStandardMiddlewareBuilder();
|
|
8453
|
-
return
|
|
8680
|
+
return require$$1.useMemo(function () { return builder(UnknownMessage); }, [builder]);
|
|
8454
8681
|
}
|
|
8455
8682
|
var StandardMiddlewares = StandardMiddlewaresBuilder(UnknownMessage);
|
|
8456
8683
|
|
|
@@ -8461,36 +8688,33 @@ function getTailSvgPath(owner) {
|
|
|
8461
8688
|
return "m 0 0 v 240 h 60 c -40 -40 -60 -160 -60 -240";
|
|
8462
8689
|
}
|
|
8463
8690
|
function getTailSvg(owner) {
|
|
8464
|
-
return (
|
|
8465
|
-
React$1.createElement("path", { d: getTailSvgPath(owner), fill: "currentColor" })));
|
|
8691
|
+
return (require$$0.jsx("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240", children: require$$0.jsx("path", { d: getTailSvgPath(owner), fill: "currentColor" }) }));
|
|
8466
8692
|
}
|
|
8467
8693
|
var ChatMessageBubble = function (props) {
|
|
8468
8694
|
var owner = props.owner, onClick = props.onClick;
|
|
8469
|
-
var handleClick =
|
|
8695
|
+
var handleClick = require$$1.useCallback(function () {
|
|
8470
8696
|
if (onClick) {
|
|
8471
8697
|
onClick();
|
|
8472
8698
|
}
|
|
8473
8699
|
}, [onClick]);
|
|
8474
|
-
return (
|
|
8475
|
-
(props.hasTail) && getTailSvg(owner),
|
|
8476
|
-
props.children));
|
|
8700
|
+
return (require$$0.jsxs("div", { onClick: handleClick, className: "chat-text-bubble ".concat(owner === "mine" ? "chat-text-bubble--mine" : "chat-text-bubble--others"), children: [props.hasTail && getTailSvg(owner), props.children] }));
|
|
8477
8701
|
};
|
|
8478
8702
|
|
|
8479
8703
|
var ChatMarkdownMessage = function (props) {
|
|
8480
8704
|
var onOpenUrl = props.onOpenUrl;
|
|
8481
8705
|
var agentMessage = isAgent(props.message.user.nick);
|
|
8482
|
-
var ref =
|
|
8706
|
+
var ref = require$$1.useRef(null);
|
|
8483
8707
|
var chatDispatch = useChatDispatch();
|
|
8484
8708
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
8485
8709
|
var html = props.message.msg.html;
|
|
8486
|
-
var handleLinkClick =
|
|
8710
|
+
var handleLinkClick = require$$1.useCallback(function (ev) {
|
|
8487
8711
|
if (onOpenUrl) {
|
|
8488
8712
|
var link = ev.target;
|
|
8489
8713
|
ev.preventDefault();
|
|
8490
8714
|
onOpenUrl(link.href, chatDispatch, visuals);
|
|
8491
8715
|
}
|
|
8492
8716
|
}, [onOpenUrl]);
|
|
8493
|
-
|
|
8717
|
+
require$$1.useEffect(function () {
|
|
8494
8718
|
if (ref.current) {
|
|
8495
8719
|
ref.current.innerHTML = html;
|
|
8496
8720
|
if (onOpenUrl) {
|
|
@@ -8507,11 +8731,7 @@ var ChatMarkdownMessage = function (props) {
|
|
|
8507
8731
|
}
|
|
8508
8732
|
return undefined;
|
|
8509
8733
|
}, [ref, html, onOpenUrl, handleLinkClick]);
|
|
8510
|
-
return (
|
|
8511
|
-
React$1.createElement("div", { className: "chat-text-container" },
|
|
8512
|
-
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
8513
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + (agentMessage ? " the bot said" : " the user said")),
|
|
8514
|
-
React$1.createElement("div", { ref: ref })))));
|
|
8734
|
+
return (require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx("div", { className: "chat-text-container", children: require$$0.jsxs(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling, children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + (agentMessage ? " the bot said" : " the user said") }), require$$0.jsx("div", { ref: ref })] }) }) }));
|
|
8515
8735
|
};
|
|
8516
8736
|
|
|
8517
8737
|
var ChatPermissionMessage = function (props) {
|
|
@@ -8525,57 +8745,59 @@ var ChatPermissionMessage = function (props) {
|
|
|
8525
8745
|
var author = message.user;
|
|
8526
8746
|
var allowLabel = "Allow";
|
|
8527
8747
|
var denyLabel = "Deny";
|
|
8528
|
-
var writeAsAgent =
|
|
8748
|
+
var writeAsAgent = require$$1.useCallback(function (msg) {
|
|
8529
8749
|
ctx.write({
|
|
8530
8750
|
type: "msg",
|
|
8531
8751
|
user: author,
|
|
8532
|
-
msg: msg
|
|
8752
|
+
msg: msg,
|
|
8533
8753
|
});
|
|
8534
8754
|
}, [ctx, author]);
|
|
8535
|
-
var writeAsUser =
|
|
8755
|
+
var writeAsUser = require$$1.useCallback(function (msg) {
|
|
8536
8756
|
ctx.write({
|
|
8537
8757
|
type: "msg",
|
|
8538
8758
|
user: user,
|
|
8539
|
-
msg: msg
|
|
8759
|
+
msg: msg,
|
|
8540
8760
|
});
|
|
8541
8761
|
}, [ctx, user]);
|
|
8542
|
-
var handleFail =
|
|
8762
|
+
var handleFail = require$$1.useCallback(function () {
|
|
8543
8763
|
ctx.send({
|
|
8544
8764
|
type: "msg",
|
|
8545
8765
|
user: undefined,
|
|
8546
8766
|
msg: {
|
|
8547
|
-
text: denyLabel
|
|
8548
|
-
}
|
|
8767
|
+
text: denyLabel,
|
|
8768
|
+
},
|
|
8549
8769
|
});
|
|
8550
8770
|
}, [ctx]);
|
|
8551
|
-
var handleSend =
|
|
8771
|
+
var handleSend = require$$1.useCallback(function (msg) {
|
|
8552
8772
|
ctx.send({
|
|
8553
8773
|
type: "permissionGrant",
|
|
8554
8774
|
user: author,
|
|
8555
|
-
msg: msg
|
|
8775
|
+
msg: msg,
|
|
8556
8776
|
});
|
|
8557
8777
|
}, [author, ctx]);
|
|
8558
|
-
var handleResult =
|
|
8778
|
+
var handleResult = require$$1.useCallback(function (position, userMsg) {
|
|
8559
8779
|
handleSend({
|
|
8560
8780
|
text: userMsg,
|
|
8561
|
-
location: position
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8781
|
+
location: position
|
|
8782
|
+
? {
|
|
8783
|
+
latitude: position.coords.latitude,
|
|
8784
|
+
longitude: position.coords.longitude,
|
|
8785
|
+
}
|
|
8786
|
+
: undefined,
|
|
8787
|
+
permissionRequest: permissionRequest,
|
|
8566
8788
|
});
|
|
8567
8789
|
writeAsUser({
|
|
8568
|
-
text: userMsg
|
|
8790
|
+
text: userMsg,
|
|
8569
8791
|
});
|
|
8570
8792
|
var agentMsg = position ? permissionRequest === null || permissionRequest === void 0 ? void 0 : permissionRequest.approve : permissionRequest === null || permissionRequest === void 0 ? void 0 : permissionRequest.deny;
|
|
8571
8793
|
if (agentMsg) {
|
|
8572
8794
|
writeAsAgent(agentMsg);
|
|
8573
8795
|
}
|
|
8574
8796
|
}, [permissionRequest, writeAsUser, writeAsAgent, handleSend]);
|
|
8575
|
-
var handleDeny =
|
|
8797
|
+
var handleDeny = require$$1.useCallback(function (label) {
|
|
8576
8798
|
handleResult(undefined, label);
|
|
8577
8799
|
}, [handleResult]);
|
|
8578
|
-
var handleAllow =
|
|
8800
|
+
var handleAllow = require$$1.useCallback(function (label) {
|
|
8579
8801
|
if (navigator.geolocation) {
|
|
8580
8802
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
8581
8803
|
handleResult(position, label);
|
|
@@ -8585,25 +8807,17 @@ var ChatPermissionMessage = function (props) {
|
|
|
8585
8807
|
}
|
|
8586
8808
|
}, [handleFail, handleResult]);
|
|
8587
8809
|
if (!permissionRequest) {
|
|
8588
|
-
return
|
|
8810
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
8589
8811
|
}
|
|
8590
|
-
return (
|
|
8591
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + (agentMessage ? " the bot said" : " the user said")),
|
|
8592
|
-
React$1.createElement("div", { className: "buttons-container" },
|
|
8593
|
-
React$1.createElement(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }),
|
|
8594
|
-
React$1.createElement(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny }))));
|
|
8812
|
+
return (require$$0.jsxs("div", { className: "chat-msg", children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + (agentMessage ? " the bot said" : " the user said") }), require$$0.jsxs("div", { className: "buttons-container", children: [require$$0.jsx(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }), require$$0.jsx(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny })] })] }));
|
|
8595
8813
|
};
|
|
8596
8814
|
|
|
8597
8815
|
var ChatTextMessage = function (props) {
|
|
8598
8816
|
var message = props.message;
|
|
8599
8817
|
var date = new Date(message.timestamp);
|
|
8600
|
-
var time = date.getHours() +
|
|
8818
|
+
var time = date.getHours() + ":" + date.getMinutes();
|
|
8601
8819
|
var agentMessage = isAgent(props.message.user.nick);
|
|
8602
|
-
return (
|
|
8603
|
-
React$1.createElement("div", { className: "chat-text-container" },
|
|
8604
|
-
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
8605
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + time + (agentMessage ? " the bot said" : " the user said")),
|
|
8606
|
-
React$1.createElement("span", null, message.msg.text)))));
|
|
8820
|
+
return (require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx("div", { className: "chat-text-container", children: require$$0.jsxs(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling, children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + (agentMessage ? " the bot said" : " the user said") }), require$$0.jsx("span", { children: message.msg.text })] }) }) }));
|
|
8607
8821
|
};
|
|
8608
8822
|
|
|
8609
8823
|
var ChatScheduleWidget = function (props) {
|
|
@@ -8614,10 +8828,7 @@ var ChatScheduleWidget = function (props) {
|
|
|
8614
8828
|
function handleClick() {
|
|
8615
8829
|
openUrl(scheduleWidgetUrl, chatDispatch, visuals);
|
|
8616
8830
|
}
|
|
8617
|
-
return (
|
|
8618
|
-
React$1.createElement("button", { className: "chat-schedule-button", onClick: handleClick },
|
|
8619
|
-
React$1.createElement("i", { className: "fa fa-lg fa-calendar" }),
|
|
8620
|
-
React$1.createElement("span", null, display.label || "Schedule Now!"))));
|
|
8831
|
+
return (require$$0.jsx("div", { className: "chat-schedule-button-container", children: require$$0.jsxs("button", { className: "chat-schedule-button", onClick: handleClick, children: [require$$0.jsx("i", { className: "fa fa-lg fa-calendar" }), require$$0.jsx("span", { children: display.label || "Schedule Now!" })] }) }));
|
|
8621
8832
|
};
|
|
8622
8833
|
|
|
8623
8834
|
function getClassName(msg) {
|
|
@@ -8631,11 +8842,17 @@ var avaKeys = ["text", "html", "card", "list"];
|
|
|
8631
8842
|
* @returns
|
|
8632
8843
|
*/
|
|
8633
8844
|
var ChatMessage = function (props) {
|
|
8845
|
+
var _a;
|
|
8634
8846
|
var middleware = props.messageMiddleware || StandardMiddlewares;
|
|
8847
|
+
var chatConfig = require$$1.useContext(ChatConfigContext);
|
|
8848
|
+
// console.log(`########### chatConfig: ${JSON.stringify(chatConfig, null, 2)}`);
|
|
8635
8849
|
var ctx = props.middlewareContext;
|
|
8636
8850
|
var user = props.agent;
|
|
8851
|
+
// Get hideUserInfo from the agent info based on the message sender's nick
|
|
8852
|
+
var agentInfo = (_a = props.agents) === null || _a === void 0 ? void 0 : _a[props.message.user.nick];
|
|
8853
|
+
var hideUserInfo = (agentInfo === null || agentInfo === void 0 ? void 0 : agentInfo.hideUserInfo) || false;
|
|
8637
8854
|
function renderByType() {
|
|
8638
|
-
var _a;
|
|
8855
|
+
var _a, _b, _c, _d;
|
|
8639
8856
|
var msg = props.message.msg;
|
|
8640
8857
|
switch (props.message.type) {
|
|
8641
8858
|
// TODO: props actually requires it to be "chat.msg". Fix prop typing?
|
|
@@ -8643,38 +8860,27 @@ var ChatMessage = function (props) {
|
|
|
8643
8860
|
// Here is the deal. If we have text (output speech), then text - card - list - options
|
|
8644
8861
|
// OR card OR list only. Avatar with text bubble.
|
|
8645
8862
|
var avaKey = avaKeys.find(function (key) { return !!msg[key]; });
|
|
8646
|
-
return (
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
}
|
|
8657
|
-
var Middleware = middleware;
|
|
8658
|
-
return (React$1.createElement(Middleware, { key: index, msg: display, ctx: props.middlewareContext }));
|
|
8659
|
-
}),
|
|
8660
|
-
msg.permissionRequest && ctx &&
|
|
8661
|
-
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user },
|
|
8662
|
-
React$1.createElement(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: ctx }))));
|
|
8863
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [msg.text &&
|
|
8864
|
+
require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "text", user: user, avatarPosition: (_a = chatConfig.env.theme.messages) === null || _a === void 0 ? void 0 : _a.avatarPosition, hideUserInfo: hideUserInfo, children: require$$0.jsx(ChatTextMessage, { message: props.message, sibling: props.sibling }) }), msg.html &&
|
|
8865
|
+
require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "html", user: user, avatarPosition: (_b = chatConfig.env.theme.messages) === null || _b === void 0 ? void 0 : _b.avatarPosition, hideUserInfo: hideUserInfo, children: require$$0.jsx(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_c = props.middlewareContext) === null || _c === void 0 ? void 0 : _c.openUrl }) }), msg.displays && middleware && msg.displays.map(function (display, index) {
|
|
8866
|
+
if (display.type === "ScheduleButton") {
|
|
8867
|
+
return (require$$0.jsx(ChatScheduleWidget, { minimizeOnClick: props.minimizeOnClick, display: display }));
|
|
8868
|
+
}
|
|
8869
|
+
var Middleware = middleware;
|
|
8870
|
+
return (require$$0.jsx(Middleware, { msg: display, ctx: props.middlewareContext }, index));
|
|
8871
|
+
}), msg.permissionRequest && ctx &&
|
|
8872
|
+
require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user, avatarPosition: (_d = chatConfig.env.theme.messages) === null || _d === void 0 ? void 0 : _d.avatarPosition, hideUserInfo: hideUserInfo, children: require$$0.jsx(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: ctx }) })] }));
|
|
8663
8873
|
}
|
|
8664
|
-
return (
|
|
8874
|
+
return (require$$0.jsx(require$$0.Fragment, {}));
|
|
8665
8875
|
}
|
|
8666
8876
|
function renderTimestamp() {
|
|
8667
8877
|
var timestamp = props.message.timestamp;
|
|
8668
8878
|
var ts = new Date(timestamp);
|
|
8669
8879
|
var timeAgo = getTimeAgo(ts);
|
|
8670
|
-
return (
|
|
8671
|
-
React$1.createElement("span", null, timeAgo)));
|
|
8880
|
+
return (require$$0.jsx("div", { className: "chat-msg-timestamp ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor"), children: require$$0.jsx("span", { children: timeAgo }) }));
|
|
8672
8881
|
}
|
|
8673
8882
|
// empty
|
|
8674
|
-
return (
|
|
8675
|
-
React$1.createElement("div", { className: "chat-msg-container ".concat(getClassName(props.message)) },
|
|
8676
|
-
renderByType(),
|
|
8677
|
-
renderTimestamp())));
|
|
8883
|
+
return (require$$0.jsx("div", { className: "chat-msg-container-wrapper ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor", " ").concat(props.sibling ? "sibling" : ""), children: require$$0.jsxs("div", { className: "chat-msg-container ".concat(getClassName(props.message)), children: [renderByType(), renderTimestamp()] }) }));
|
|
8678
8884
|
};
|
|
8679
8885
|
|
|
8680
8886
|
/**
|
|
@@ -8718,7 +8924,7 @@ function checkSessionExpiration(duration, lastMessageTimestamp, _lastTimestamp)
|
|
|
8718
8924
|
}
|
|
8719
8925
|
|
|
8720
8926
|
function useExternalScript(url) {
|
|
8721
|
-
|
|
8927
|
+
require$$1.useEffect(function () {
|
|
8722
8928
|
if (!url) {
|
|
8723
8929
|
return;
|
|
8724
8930
|
}
|
|
@@ -8760,7 +8966,7 @@ function useChatServerVisitorId() {
|
|
|
8760
8966
|
});
|
|
8761
8967
|
var visitorAccessToken = reactRedux.useSelector(function (state) { return state.accessToken; });
|
|
8762
8968
|
var attributes = reactRedux.useSelector(function (state) { return state.attributes; });
|
|
8763
|
-
return
|
|
8969
|
+
return require$$1.useMemo(function () { return ({
|
|
8764
8970
|
dispatch: dispatch,
|
|
8765
8971
|
visitorId: clientVisitorId,
|
|
8766
8972
|
accessToken: visitorAccessToken,
|
|
@@ -8771,11 +8977,11 @@ function useChatServerVisitorId() {
|
|
|
8771
8977
|
//send whenever server settings or visitor id changes
|
|
8772
8978
|
function useGreeting(active) {
|
|
8773
8979
|
var curr = useChatServerVisitorId();
|
|
8774
|
-
var snapshotRef =
|
|
8775
|
-
var ctx =
|
|
8980
|
+
var snapshotRef = require$$1.useRef(null);
|
|
8981
|
+
var ctx = require$$1.useContext(ChatConfigContext);
|
|
8776
8982
|
var isAdmin = ctx.env.isAdmin;
|
|
8777
8983
|
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
8778
|
-
|
|
8984
|
+
require$$1.useEffect(function () {
|
|
8779
8985
|
if (active) {
|
|
8780
8986
|
if (snapshotRef.current !== curr) {
|
|
8781
8987
|
snapshotRef.current = curr;
|
|
@@ -8820,18 +9026,18 @@ function norm(index, len) {
|
|
|
8820
9026
|
return (index + len) % len;
|
|
8821
9027
|
}
|
|
8822
9028
|
function useSuggestions(search, context) {
|
|
8823
|
-
var _a =
|
|
8824
|
-
var _b =
|
|
8825
|
-
var _c =
|
|
8826
|
-
var _d =
|
|
8827
|
-
|
|
9029
|
+
var _a = require$$1.useState(), suggestions = _a[0], setSuggestions = _a[1];
|
|
9030
|
+
var _b = require$$1.useState(-1), suggestionIndex = _b[0], setSuggestionIndex = _b[1];
|
|
9031
|
+
var _c = require$$1.useState(search), query = _c[0], setQuery = _c[1];
|
|
9032
|
+
var _d = require$$1.useState(context), contextState = _d[0], setContextState = _d[1];
|
|
9033
|
+
require$$1.useEffect(function () {
|
|
8828
9034
|
setQuery(search);
|
|
8829
9035
|
}, [search]);
|
|
8830
|
-
|
|
9036
|
+
require$$1.useEffect(function () {
|
|
8831
9037
|
setContextState(context);
|
|
8832
9038
|
}, [context]);
|
|
8833
|
-
var suggestionItem =
|
|
8834
|
-
var shift =
|
|
9039
|
+
var suggestionItem = require$$1.useMemo(function () { return suggestions ? findItemByIndex_1(suggestions, suggestionIndex) : undefined; }, [suggestions, suggestionIndex]);
|
|
9040
|
+
var shift = require$$1.useCallback(function (delta) {
|
|
8835
9041
|
if (suggestions) {
|
|
8836
9042
|
var len_1 = getItemsLength_1(suggestions);
|
|
8837
9043
|
setSuggestionIndex(function (index) { return norm(index + delta + ((index < 0 && delta <= 0) ? 1 : 0), len_1); });
|
|
@@ -8840,7 +9046,7 @@ function useSuggestions(search, context) {
|
|
|
8840
9046
|
setSuggestionIndex(-1);
|
|
8841
9047
|
}
|
|
8842
9048
|
}, [suggestions]);
|
|
8843
|
-
var execute =
|
|
9049
|
+
var execute = require$$1.useCallback(function (cmd) {
|
|
8844
9050
|
switch (cmd) {
|
|
8845
9051
|
case "prev":
|
|
8846
9052
|
shift(-1);
|
|
@@ -8857,7 +9063,7 @@ function useSuggestions(search, context) {
|
|
|
8857
9063
|
}, [shift]);
|
|
8858
9064
|
var suggestionsResponse = useSuggestionsFetch(query || "", contextState);
|
|
8859
9065
|
var suggestionsData = suggestionsResponse.state === "success" ? suggestionsResponse.data : undefined;
|
|
8860
|
-
var raw =
|
|
9066
|
+
var raw = require$$1.useMemo(function () {
|
|
8861
9067
|
return suggestionsData ?
|
|
8862
9068
|
parseSuggestionsResponse_1(suggestionsData, -1).map(function (suggestion) {
|
|
8863
9069
|
return {
|
|
@@ -8866,14 +9072,14 @@ function useSuggestions(search, context) {
|
|
|
8866
9072
|
};
|
|
8867
9073
|
}) : undefined;
|
|
8868
9074
|
}, [suggestionsData]);
|
|
8869
|
-
|
|
9075
|
+
require$$1.useEffect(function () {
|
|
8870
9076
|
var prev = suggestionItem;
|
|
8871
9077
|
setSuggestions(raw);
|
|
8872
9078
|
if (!prev || !raw) {
|
|
8873
9079
|
setSuggestionIndex(-1);
|
|
8874
9080
|
}
|
|
8875
9081
|
}, [raw, suggestionItem]);
|
|
8876
|
-
return
|
|
9082
|
+
return require$$1.useMemo(function () { return ({
|
|
8877
9083
|
suggestions: suggestions,
|
|
8878
9084
|
index: suggestionIndex,
|
|
8879
9085
|
execute: execute,
|
|
@@ -8883,11 +9089,11 @@ function useSuggestions(search, context) {
|
|
|
8883
9089
|
|
|
8884
9090
|
var AdminBar = function (_a) {
|
|
8885
9091
|
var onAdminJoin = _a.onAdminJoin;
|
|
8886
|
-
var name =
|
|
9092
|
+
var name = require$$1.useRef(null);
|
|
8887
9093
|
// We can manage this locally
|
|
8888
9094
|
// const hasAdminJoined = useSelector<ChatState, boolean | undefined>(state => state.hasAdminJoined);
|
|
8889
|
-
var _b =
|
|
8890
|
-
var _c =
|
|
9095
|
+
var _b = require$$1.useState(false), joined = _b[0], setJoined = _b[1];
|
|
9096
|
+
var _c = require$$1.useState(""), inputName = _c[0], setInputName = _c[1];
|
|
8891
9097
|
function handleInputChange(event) {
|
|
8892
9098
|
setInputName(event.target.value);
|
|
8893
9099
|
}
|
|
@@ -8909,18 +9115,12 @@ var AdminBar = function (_a) {
|
|
|
8909
9115
|
}
|
|
8910
9116
|
}
|
|
8911
9117
|
function renderJoin() {
|
|
8912
|
-
return (
|
|
8913
|
-
React$1.createElement("div", { className: "xappw-admin-input-form__buttons" },
|
|
8914
|
-
React$1.createElement(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Join", disable: disable })),
|
|
8915
|
-
React$1.createElement("div", { className: "xappw-admin-input" },
|
|
8916
|
-
React$1.createElement("input", { ref: name, id: "adminBarInput", placeholder: "Type your name here...", className: "xappw-admin-input__input", onChange: handleInputChange }))));
|
|
9118
|
+
return (require$$0.jsxs("form", { className: "xappw-admin-input-form", onSubmit: onSubmit, children: [require$$0.jsx("div", { className: "xappw-admin-input-form__buttons", children: require$$0.jsx(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Join", disable: disable }) }), require$$0.jsx("div", { className: "xappw-admin-input", children: require$$0.jsx("input", { ref: name, id: "adminBarInput", placeholder: "Type your name here...", className: "xappw-admin-input__input", onChange: handleInputChange }) })] }));
|
|
8917
9119
|
}
|
|
8918
9120
|
function renderLeave() {
|
|
8919
|
-
return (
|
|
8920
|
-
React$1.createElement("div", { className: "xappw-admin-input-form__buttons" },
|
|
8921
|
-
React$1.createElement(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Leave" }))));
|
|
9121
|
+
return (require$$0.jsx("form", { className: "xappw-admin-input-form", onSubmit: onSubmit, children: require$$0.jsx("div", { className: "xappw-admin-input-form__buttons", children: require$$0.jsx(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Leave" }) }) }));
|
|
8922
9122
|
}
|
|
8923
|
-
return (
|
|
9123
|
+
return (require$$0.jsx("div", { className: "xappw-admin-input-container visible", children: joined ? renderLeave() : renderJoin() }));
|
|
8924
9124
|
};
|
|
8925
9125
|
|
|
8926
9126
|
var classnames = {exports: {}};
|
|
@@ -9019,39 +9219,32 @@ var MarkdownBuilder = function (_a) {
|
|
|
9019
9219
|
var level = hashes.length;
|
|
9020
9220
|
return "<h".concat(level, ">").concat(headerText, "</h").concat(level, ">");
|
|
9021
9221
|
});
|
|
9022
|
-
return (
|
|
9222
|
+
return (require$$0.jsx("div", { className: containerClass, dangerouslySetInnerHTML: { __html: parsedText } }));
|
|
9023
9223
|
};
|
|
9024
9224
|
|
|
9025
9225
|
var ChatBranding = function (_a) {
|
|
9026
9226
|
var text = _a.text;
|
|
9027
9227
|
var regex = /\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/;
|
|
9028
9228
|
var match = text === null || text === void 0 ? void 0 : text.match(regex);
|
|
9029
|
-
return match ?
|
|
9030
|
-
:
|
|
9031
|
-
React$1.createElement("div", { className: "chat-footer__branding", style: { color: "white" } }, text);
|
|
9229
|
+
return match ? (require$$0.jsx(MarkdownBuilder, { text: text, applyBrandingClass: true, linkColor: "white" })) : (require$$0.jsx("div", { className: "chat-footer__branding", style: { color: "white" }, children: text }));
|
|
9032
9230
|
};
|
|
9033
9231
|
|
|
9034
9232
|
var CloseIcon = function () {
|
|
9035
9233
|
// Sergey, I added this style, you will probably want to change it to be more appropriate
|
|
9036
|
-
return (
|
|
9037
|
-
React$1.createElement("path", { d: "M1.293 1.293a1 1 0 0 1 1.414 0L8 6.586l5.293-5.293a1 1 0 1 1 1.414 1.414L9.414 8l5.293 5.293a1 1 0 0 1-1.414 1.414L8 9.414l-5.293 5.293a1 1 0 0 1-1.414-1.414L6.586 8 1.293 2.707a1 1 0 0 1 0-1.414z" })));
|
|
9234
|
+
return (require$$0.jsx("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16", children: require$$0.jsx("path", { d: "M1.293 1.293a1 1 0 0 1 1.414 0L8 6.586l5.293-5.293a1 1 0 1 1 1.414 1.414L9.414 8l5.293 5.293a1 1 0 0 1-1.414 1.414L8 9.414l-5.293 5.293a1 1 0 0 1-1.414-1.414L6.586 8 1.293 2.707a1 1 0 0 1 0-1.414z" }) }));
|
|
9038
9235
|
};
|
|
9039
9236
|
|
|
9040
9237
|
var LeftDownArrowIcon = function () {
|
|
9041
|
-
return (
|
|
9042
|
-
React$1.createElement("path", { fillRule: "evenodd", d: "M2 13.5a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 0-1H3.707L13.854 2.854a.5.5 0 0 0-.708-.708L3 12.293V7.5a.5.5 0 0 0-1 0v6z" })));
|
|
9238
|
+
return (require$$0.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16", children: require$$0.jsx("path", { fillRule: "evenodd", d: "M2 13.5a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 0-1H3.707L13.854 2.854a.5.5 0 0 0-.708-.708L3 12.293V7.5a.5.5 0 0 0-1 0v6z" }) }));
|
|
9043
9239
|
};
|
|
9044
9240
|
|
|
9045
9241
|
var SendIcon = function () {
|
|
9046
|
-
return (
|
|
9047
|
-
React$1.createElement("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none" },
|
|
9048
|
-
React$1.createElement("path", { d: "M12670 7345 c-63 -18 -272 -77 -465 -130 -192 -53 -478 -132 -635 -175 -508 -141 -1091 -302 -2345 -649 -676 -187 -2038 -563 -3025 -836 -987 -273 -2072 -573 -2410 -666 -338 -94 -802 -222 -1030 -285 -1857 -514 -2579 -714 -2684 -742 -38 -10 -65 -21 -60 -24 5 -3 67 -22 139 -41 72 -20 326 -90 565 -157 239 -67 611 -170 825 -230 215 -60 586 -163 825 -230 239 -67 491 -137 560 -156 l126 -34 974 439 c1397 629 4128 1858 6050 2724 910 410 1826 822 2035 917 209 94 387 173 395 176 35 10 -66 -39 -8200 -3928 -586 -280 -1068 -512 -1071 -516 -3 -4 33 -117 82 -252 76 -213 355 -996 765 -2147 65 -183 120 -330 122 -329 1 2 114 558 250 1236 l248 1233 3455 2064 c1900 1135 3670 2193 3933 2351 264 158 491 293 505 301 62 33 -5 -12 -271 -182 -1671 -1070 -7188 -4613 -7188 -4617 0 -7 3661 -2455 3669 -2454 4 1 3713 6853 3977 7347 8 15 11 27 7 26 -5 0 -60 -15 -123 -34z" }),
|
|
9049
|
-
React$1.createElement("path", { d: "M5030 2232 c-15 -61 -479 -1861 -531 -2058 -21 -83 -39 -154 -39 -158 0 -3 369 330 820 740 452 411 817 750 813 754 -11 10 -1025 754 -1039 763 -8 4 -16 -10 -24 -41z" }))));
|
|
9242
|
+
return (require$$0.jsx("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg", children: require$$0.jsxs("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none", children: [require$$0.jsx("path", { d: "M12670 7345 c-63 -18 -272 -77 -465 -130 -192 -53 -478 -132 -635 -175 -508 -141 -1091 -302 -2345 -649 -676 -187 -2038 -563 -3025 -836 -987 -273 -2072 -573 -2410 -666 -338 -94 -802 -222 -1030 -285 -1857 -514 -2579 -714 -2684 -742 -38 -10 -65 -21 -60 -24 5 -3 67 -22 139 -41 72 -20 326 -90 565 -157 239 -67 611 -170 825 -230 215 -60 586 -163 825 -230 239 -67 491 -137 560 -156 l126 -34 974 439 c1397 629 4128 1858 6050 2724 910 410 1826 822 2035 917 209 94 387 173 395 176 35 10 -66 -39 -8200 -3928 -586 -280 -1068 -512 -1071 -516 -3 -4 33 -117 82 -252 76 -213 355 -996 765 -2147 65 -183 120 -330 122 -329 1 2 114 558 250 1236 l248 1233 3455 2064 c1900 1135 3670 2193 3933 2351 264 158 491 293 505 301 62 33 -5 -12 -271 -182 -1671 -1070 -7188 -4613 -7188 -4617 0 -7 3661 -2455 3669 -2454 4 1 3713 6853 3977 7347 8 15 11 27 7 26 -5 0 -60 -15 -123 -34z" }), require$$0.jsx("path", { d: "M5030 2232 c-15 -61 -479 -1861 -531 -2058 -21 -83 -39 -154 -39 -158 0 -3 369 330 820 740 452 411 817 750 813 754 -11 10 -1025 754 -1039 763 -8 4 -16 -10 -24 -41z" })] }) }));
|
|
9050
9243
|
};
|
|
9051
9244
|
|
|
9052
9245
|
var SendButton = function (props) {
|
|
9053
9246
|
var _a = props.disabled, disabled = _a === void 0 ? false : _a;
|
|
9054
|
-
var _b =
|
|
9247
|
+
var _b = require$$1.useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
9055
9248
|
// Determine which icon to show based on state
|
|
9056
9249
|
var getIconSrc = function () {
|
|
9057
9250
|
if (disabled && props.sendButtonIconDisabled) {
|
|
@@ -9062,14 +9255,13 @@ var SendButton = function (props) {
|
|
|
9062
9255
|
}
|
|
9063
9256
|
return props.sendButtonIcon;
|
|
9064
9257
|
};
|
|
9065
|
-
return (
|
|
9066
|
-
React$1.createElement("img", { src: getIconSrc(), alt: "Send button", draggable: false, className: "send-button-icon" })))));
|
|
9258
|
+
return (require$$0.jsx(require$$0.Fragment, { children: !props.sendButtonIcon ? (require$$0.jsx(IconButton_1, { className: "xappw-send-button ".concat(props.className || "", " ").concat(disabled ? 'disabled' : ''), tabIndex: props.tabIndex, onClick: disabled ? undefined : props.onClick, icon: SendIcon })) : (require$$0.jsx("button", { className: "xappw-custom-send-button ".concat(disabled ? 'disabled' : ''), tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: props.onClick, disabled: disabled, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, children: require$$0.jsx("img", { src: getIconSrc(), alt: "Send button", draggable: false, className: "send-button-icon" }) })) }));
|
|
9067
9259
|
};
|
|
9068
9260
|
|
|
9069
9261
|
var Input = function (props) {
|
|
9070
9262
|
var _a, _b;
|
|
9071
9263
|
var value = props.value, placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, sendButtonIconHover = props.sendButtonIconHover, sendButtonIconDisabled = props.sendButtonIconDisabled, suggestion = props.suggestion, footerConfig = props.footerConfig, inputConfig = props.inputConfig, onChange = props.onChange, onSubmit = props.onSubmit, onSuggestionCommand = props.onSuggestionCommand;
|
|
9072
|
-
var _c =
|
|
9264
|
+
var _c = require$$1.useState(false), dragover = _c[0], setDragover = _c[1];
|
|
9073
9265
|
function onDragOver(event) {
|
|
9074
9266
|
setDragover(true);
|
|
9075
9267
|
event.preventDefault();
|
|
@@ -9082,17 +9274,17 @@ var Input = function (props) {
|
|
|
9082
9274
|
function onDragLeave() {
|
|
9083
9275
|
setDragover(false);
|
|
9084
9276
|
}
|
|
9085
|
-
var handleOnSubmit =
|
|
9277
|
+
var handleOnSubmit = require$$1.useCallback(function (event) {
|
|
9086
9278
|
event && event.preventDefault();
|
|
9087
9279
|
onSubmit(value); // send to the widget
|
|
9088
9280
|
}, [value, onSubmit]);
|
|
9089
|
-
var handleClear =
|
|
9281
|
+
var handleClear = require$$1.useCallback(function () {
|
|
9090
9282
|
onChange({
|
|
9091
9283
|
text: "",
|
|
9092
9284
|
formats: [],
|
|
9093
9285
|
});
|
|
9094
9286
|
}, [onChange]);
|
|
9095
|
-
var handleKeyDown =
|
|
9287
|
+
var handleKeyDown = require$$1.useCallback(function (event) {
|
|
9096
9288
|
if (suggestion) {
|
|
9097
9289
|
if (event.key === "End" || event.key === "ArrowRight" || event.key === "Enter") {
|
|
9098
9290
|
onChange(suggestion);
|
|
@@ -9114,38 +9306,33 @@ var Input = function (props) {
|
|
|
9114
9306
|
}
|
|
9115
9307
|
}
|
|
9116
9308
|
}, [suggestion, onChange, onSuggestionCommand]);
|
|
9117
|
-
return (
|
|
9309
|
+
return (require$$0.jsx("div", { className: "xappw-input-container ".concat(props.addClass, " ").concat(dragover ? "drag-drop-zone" : ""), "aria-label": "To start typing click on rounded rectangle at the bottom of widget. To send your message click icon on right side of rounded rectangle at the bottom of widget" +
|
|
9118
9310
|
value.text
|
|
9119
9311
|
? "To clear input field click on clear icon on the left of send button"
|
|
9120
|
-
: "", "aria-hidden": false, onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
// onFocus={onFocus}
|
|
9124
|
-
value: value, spellCheck: true }),
|
|
9125
|
-
React$1.createElement("div", { className: "xappw-input-form__buttons" },
|
|
9126
|
-
value.text && (React$1.createElement(IconButton_1, { icon: CloseIcon, tabIndex: (_a = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.clearButton) === null || _a === void 0 ? void 0 : _a.tabIndex, className: "xappw-input-form__btn", onClick: handleClear })),
|
|
9127
|
-
React$1.createElement(SendButton, { className: "xappw-input-form__btn", sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, tabIndex: (_b = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.sendButton) === null || _b === void 0 ? void 0 : _b.tabIndex, disabled: !value.text, onClick: handleOnSubmit })))));
|
|
9312
|
+
: "", "aria-hidden": false, onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave, children: require$$0.jsxs("form", { className: "xappw-input-form", onSubmit: handleOnSubmit, children: [require$$0.jsx(RichInput_1, { id: "chatWidgetInput", className: "xappw-input", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "type your question here", tabIndex: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.tabIndex, onInput: onChange, onChange: onChange, onKeyDown: handleKeyDown,
|
|
9313
|
+
// onFocus={onFocus}
|
|
9314
|
+
value: value, spellCheck: true }, "input"), require$$0.jsxs("div", { className: "xappw-input-form__buttons", children: [value.text && (require$$0.jsx(IconButton_1, { icon: CloseIcon, tabIndex: (_a = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.clearButton) === null || _a === void 0 ? void 0 : _a.tabIndex, className: "xappw-input-form__btn", onClick: handleClear })), require$$0.jsx(SendButton, { className: "xappw-input-form__btn", sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, tabIndex: (_b = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.sendButton) === null || _b === void 0 ? void 0 : _b.tabIndex, disabled: !value.text, onClick: handleOnSubmit })] })] }) }));
|
|
9128
9315
|
};
|
|
9129
9316
|
|
|
9130
9317
|
function createActions(onItemUse) {
|
|
9131
9318
|
return function (innerProps) {
|
|
9132
9319
|
var data = innerProps.data;
|
|
9133
9320
|
var canUse = data.type !== "FAQ";
|
|
9134
|
-
var handleUse =
|
|
9321
|
+
var handleUse = require$$1.useCallback(function (ev) {
|
|
9135
9322
|
onItemUse(data);
|
|
9136
9323
|
ev.stopPropagation();
|
|
9137
9324
|
}, [data]);
|
|
9138
9325
|
if (!canUse) {
|
|
9139
|
-
return
|
|
9326
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
9140
9327
|
}
|
|
9141
|
-
return (
|
|
9328
|
+
return (require$$0.jsx(IconButton_1, { className: "xappw-suggestions__use", onClick: handleUse, icon: LeftDownArrowIcon }));
|
|
9142
9329
|
};
|
|
9143
9330
|
}
|
|
9144
9331
|
var Suggestions = function (props) {
|
|
9145
9332
|
var data = props.data, onItemUse = props.onItemUse, searchTerms = props.searchTerms;
|
|
9146
|
-
var _a =
|
|
9147
|
-
var _b =
|
|
9148
|
-
|
|
9333
|
+
var _a = require$$1.useState(), fixedSuggestions = _a[0], setFixedSuggestions = _a[1];
|
|
9334
|
+
var _b = require$$1.useState(), activeItem = _b[0], setActiveItem = _b[1];
|
|
9335
|
+
require$$1.useEffect(function () {
|
|
9149
9336
|
if (data) {
|
|
9150
9337
|
setFixedSuggestions(data);
|
|
9151
9338
|
}
|
|
@@ -9156,8 +9343,8 @@ var Suggestions = function (props) {
|
|
|
9156
9343
|
}, [data, searchTerms]);
|
|
9157
9344
|
var len = data === null || data === void 0 ? void 0 : data.length;
|
|
9158
9345
|
var currentIndex = len > 0 ? props.index : NaN;
|
|
9159
|
-
var item =
|
|
9160
|
-
var handleSpanClick =
|
|
9346
|
+
var item = require$$1.useMemo(function () { return findItemByIndex_1(data, currentIndex); }, [data, currentIndex]);
|
|
9347
|
+
var handleSpanClick = require$$1.useCallback(function (target, span) {
|
|
9161
9348
|
if (span.type === "inputText") {
|
|
9162
9349
|
onItemUse(target);
|
|
9163
9350
|
setActiveItem(undefined);
|
|
@@ -9165,31 +9352,30 @@ var Suggestions = function (props) {
|
|
|
9165
9352
|
}
|
|
9166
9353
|
return undefined;
|
|
9167
9354
|
}, [onItemUse]);
|
|
9168
|
-
|
|
9355
|
+
require$$1.useEffect(function () {
|
|
9169
9356
|
setActiveItem(item);
|
|
9170
9357
|
}, [item]);
|
|
9171
|
-
var actions =
|
|
9358
|
+
var actions = require$$1.useMemo(function () { return createActions(onItemUse); }, [onItemUse]);
|
|
9172
9359
|
var transformContent = function (content) {
|
|
9173
9360
|
var lines = content.split('\n');
|
|
9174
9361
|
return lines.map(function (line) {
|
|
9175
9362
|
if (line) {
|
|
9176
|
-
return
|
|
9363
|
+
return require$$0.jsx(MarkdownBuilder, { text: line });
|
|
9177
9364
|
}
|
|
9178
|
-
return
|
|
9365
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
9179
9366
|
});
|
|
9180
9367
|
};
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
React$1.createElement(SuggestionsList_1, { suggestions: fixedSuggestions, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem, onSpanClick: handleSpanClick })));
|
|
9368
|
+
var containerClass = "xappw-suggestions ".concat(props.className || "", " ").concat(props.hasWsButton ? "xappw-suggestions--with-ws-button" : "").trim();
|
|
9369
|
+
return (require$$0.jsxs("div", { className: containerClass, children: [(activeItem === null || activeItem === void 0 ? void 0 : activeItem.content) && require$$0.jsx("div", { className: "xappw-suggestions__answer", children: transformContent(activeItem.content) }), fixedSuggestions && fixedSuggestions.length > 0 &&
|
|
9370
|
+
require$$0.jsx(SuggestionsList_1, { suggestions: fixedSuggestions, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem, onSpanClick: handleSpanClick })] }));
|
|
9185
9371
|
};
|
|
9186
9372
|
|
|
9187
9373
|
var ChatFooter = function (props) {
|
|
9188
9374
|
var _a, _b, _c;
|
|
9189
|
-
var isAdmin = props.isAdmin, isChatting = props.isChatting, visible = props.visible, placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, sendButtonIconHover = props.sendButtonIconHover, sendButtonIconDisabled = props.sendButtonIconDisabled, footerConfig = props.footerConfig, menuConfig = props.menuConfig, inputConfig = props.inputConfig, onSubmit = props.onSubmit;
|
|
9375
|
+
var isAdmin = props.isAdmin, isChatting = props.isChatting, visible = props.visible, placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, sendButtonIconHover = props.sendButtonIconHover, sendButtonIconDisabled = props.sendButtonIconDisabled, footerConfig = props.footerConfig, menuConfig = props.menuConfig, inputConfig = props.inputConfig, hasWsButton = props.hasWsButton, onSubmit = props.onSubmit;
|
|
9190
9376
|
var innerDispatch = useChatDispatch();
|
|
9191
|
-
var _d =
|
|
9192
|
-
var _e =
|
|
9377
|
+
var _d = require$$1.useState(false), drawerOpen = _d[0], setDrawerState = _d[1]; // false initially
|
|
9378
|
+
var _e = require$$1.useState(), suggestionSearch = _e[0], setSuggestionSearch = _e[1];
|
|
9193
9379
|
var contexts = reactRedux.useSelector(function (state) { return state.activeContexts; });
|
|
9194
9380
|
var suggestions = useSuggestions(suggestionSearch, contexts);
|
|
9195
9381
|
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
@@ -9197,12 +9383,12 @@ var ChatFooter = function (props) {
|
|
|
9197
9383
|
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items;
|
|
9198
9384
|
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex;
|
|
9199
9385
|
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex;
|
|
9200
|
-
var menuItems =
|
|
9386
|
+
var menuItems = require$$1.useMemo(function () { return menuItemsRaw ? menuItemsRaw : []; }, [menuItemsRaw]);
|
|
9201
9387
|
var brandingEnabled = (_b = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.branding) === null || _b === void 0 ? void 0 : _b.enabled;
|
|
9202
9388
|
var brandingText = (_c = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.branding) === null || _c === void 0 ? void 0 : _c.text;
|
|
9203
9389
|
// If they are NOT an admin, automatically enabled the input
|
|
9204
|
-
var _f =
|
|
9205
|
-
var _g =
|
|
9390
|
+
var _f = require$$1.useState(!isAdmin), enableInput = _f[0], setEnableInput = _f[1];
|
|
9391
|
+
var _g = require$$1.useState({
|
|
9206
9392
|
text: "",
|
|
9207
9393
|
formats: []
|
|
9208
9394
|
}), input = _g[0], setInput = _g[1];
|
|
@@ -9223,7 +9409,7 @@ var ChatFooter = function (props) {
|
|
|
9223
9409
|
setSuggestionSearch(val.text);
|
|
9224
9410
|
}
|
|
9225
9411
|
// Clears out suggestion and input text
|
|
9226
|
-
var handleSubmit =
|
|
9412
|
+
var handleSubmit = require$$1.useCallback(function (message) {
|
|
9227
9413
|
// Clears out the suggestions
|
|
9228
9414
|
setSuggestionSearch("");
|
|
9229
9415
|
// Clears out the input
|
|
@@ -9233,29 +9419,20 @@ var ChatFooter = function (props) {
|
|
|
9233
9419
|
});
|
|
9234
9420
|
onSubmit(message.text);
|
|
9235
9421
|
}, [onSubmit]);
|
|
9236
|
-
var handleItemClick =
|
|
9422
|
+
var handleItemClick = require$$1.useCallback(function (data) {
|
|
9237
9423
|
handleSubmit(data);
|
|
9238
9424
|
}, [handleSubmit]);
|
|
9239
|
-
var handleItemUse =
|
|
9425
|
+
var handleItemUse = require$$1.useCallback(function (data) {
|
|
9240
9426
|
setInput(data);
|
|
9241
9427
|
setSuggestionSearch(data.text);
|
|
9242
9428
|
}, []);
|
|
9243
9429
|
var handleAdminJoin = function (status) {
|
|
9244
9430
|
setEnableInput(status);
|
|
9245
9431
|
};
|
|
9246
|
-
return (
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
React$1.createElement("div", { className: "chat-footer__menu-icon" },
|
|
9251
|
-
React$1.createElement(DrawerBars, { tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }))) : React$1.createElement(React$1.Fragment, null),
|
|
9252
|
-
React$1.createElement(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, searchTerms: suggestionSearch, onItemClick: handleItemClick, onItemUse: handleItemUse }),
|
|
9253
|
-
isAdmin && isChatting && visible && React$1.createElement(AdminBar, { onAdminJoin: handleAdminJoin }),
|
|
9254
|
-
React$1.createElement("div", { style: { pointerEvents: enableInput ? "auto" : "none", opacity: enableInput ? 1 : 0.5 } },
|
|
9255
|
-
React$1.createElement(Input, { addClass: "chat-footer__input " + (isChatting && visible ? "visible" : ""), suggestion: suggestions.item, value: input, placeholder: placeholder, sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, footerConfig: footerConfig, inputConfig: inputConfig, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
|
|
9256
|
-
// onFocus={this.inputOnFocus}
|
|
9257
|
-
onFileUpload: props.onFileUpload })),
|
|
9258
|
-
brandingEnabled && brandingText && React$1.createElement(ChatBranding, { text: brandingText })));
|
|
9432
|
+
return (require$$0.jsxs("div", { className: "chat-footer background-footer", "aria-label": menuItems.length ? "to open menu click a button above the rounded rectangle at the bottom of widget" : "", "aria-hidden": false, children: [showMenu && menuItems.length ?
|
|
9433
|
+
require$$0.jsxs(require$$0.Fragment, { children: [drawerOpen ? require$$0.jsx(ChatMenu, { opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) : require$$0.jsx(require$$0.Fragment, {}), require$$0.jsx("div", { className: "chat-footer__menu-icon", children: require$$0.jsx(DrawerBars, { tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }) })] }) : require$$0.jsx(require$$0.Fragment, {}), require$$0.jsx(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, searchTerms: suggestionSearch, hasWsButton: hasWsButton, onItemClick: handleItemClick, onItemUse: handleItemUse }), isAdmin && isChatting && visible && require$$0.jsx(AdminBar, { onAdminJoin: handleAdminJoin }), require$$0.jsx("div", { style: { pointerEvents: enableInput ? "auto" : "none", opacity: enableInput ? 1 : 0.5 }, children: require$$0.jsx(Input, { addClass: "chat-footer__input " + (isChatting && visible ? "visible" : ""), suggestion: suggestions.item, value: input, placeholder: placeholder, sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, footerConfig: footerConfig, inputConfig: inputConfig, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
|
|
9434
|
+
// onFocus={this.inputOnFocus}
|
|
9435
|
+
onFileUpload: props.onFileUpload }) }), brandingEnabled && brandingText && require$$0.jsx(ChatBranding, { text: brandingText })] }));
|
|
9259
9436
|
};
|
|
9260
9437
|
|
|
9261
9438
|
var noop = function () { };
|
|
@@ -9288,64 +9465,43 @@ var MiddlewareContextFactory = /** @class */ (function () {
|
|
|
9288
9465
|
|
|
9289
9466
|
var CardContainer = function (props) {
|
|
9290
9467
|
function renderIcon() {
|
|
9291
|
-
var isString = typeof
|
|
9292
|
-
return
|
|
9293
|
-
}
|
|
9294
|
-
return (
|
|
9295
|
-
renderIcon(),
|
|
9296
|
-
React$1.createElement("div", { className: "card-container__content ".concat(props.contentAddClass) },
|
|
9297
|
-
React$1.createElement("div", { className: "card-container__title" }, props.title),
|
|
9298
|
-
props.children)));
|
|
9468
|
+
var isString = typeof props.icon === "string";
|
|
9469
|
+
return require$$0.jsx("div", { className: "card-container__icon", children: !isString && props.icon });
|
|
9470
|
+
}
|
|
9471
|
+
return (require$$0.jsxs("div", { className: "card-container ".concat(props.addClass), children: [renderIcon(), require$$0.jsxs("div", { className: "card-container__content ".concat(props.contentAddClass), children: [require$$0.jsx("div", { className: "card-container__title", children: props.title }), props.children] })] }));
|
|
9299
9472
|
};
|
|
9300
9473
|
|
|
9301
|
-
var
|
|
9302
|
-
agent
|
|
9303
|
-
hasRating: false,
|
|
9304
|
-
shouldDisplay: true,
|
|
9305
|
-
onRate: function () {
|
|
9474
|
+
var ChatRating = function (_a) {
|
|
9475
|
+
var _b = _a.agent, agent = _b === void 0 ? {} : _b, _c = _a.hasRating, hasRating = _c === void 0 ? false : _c, _d = _a.shouldDisplay, shouldDisplay = _d === void 0 ? true : _d, _e = _a.onRate, onRate = _e === void 0 ? function () {
|
|
9306
9476
|
// no-op
|
|
9307
|
-
}
|
|
9308
|
-
|
|
9309
|
-
var ChatRating = function (props) {
|
|
9310
|
-
if (props === void 0) { props = defaultProps$2; }
|
|
9311
|
-
var onRate = props.onRate;
|
|
9312
|
-
var rateBadButtonOnClick = React$1.useCallback(function () {
|
|
9477
|
+
} : _e;
|
|
9478
|
+
var rateBadButtonOnClick = require$$1.useCallback(function () {
|
|
9313
9479
|
onRate("bad");
|
|
9314
9480
|
}, [onRate]);
|
|
9315
|
-
var rateGoodButtonOnClick =
|
|
9481
|
+
var rateGoodButtonOnClick = require$$1.useCallback(function () {
|
|
9316
9482
|
onRate("good");
|
|
9317
9483
|
}, [onRate]);
|
|
9318
|
-
var rateAgainButtonOnClick =
|
|
9484
|
+
var rateAgainButtonOnClick = require$$1.useCallback(function () {
|
|
9319
9485
|
onRate(undefined);
|
|
9320
9486
|
}, [onRate]);
|
|
9321
9487
|
// Do not think this prop should be here
|
|
9322
|
-
if (!
|
|
9488
|
+
if (!shouldDisplay) {
|
|
9323
9489
|
return null;
|
|
9324
9490
|
}
|
|
9325
|
-
if (!
|
|
9326
|
-
return (
|
|
9327
|
-
props.agent.displayName,
|
|
9328
|
-
" has requested you to rate the chat service.",
|
|
9329
|
-
React$1.createElement("div", { className: "buttons-container" },
|
|
9330
|
-
React$1.createElement(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }),
|
|
9331
|
-
React$1.createElement(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick }))));
|
|
9491
|
+
if (!hasRating) {
|
|
9492
|
+
return (require$$0.jsxs(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card", children: [agent.displayName, " has requested you to rate the chat service.", require$$0.jsxs("div", { className: "buttons-container", children: [require$$0.jsx(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }), require$$0.jsx(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick })] })] }));
|
|
9332
9493
|
}
|
|
9333
9494
|
else {
|
|
9334
|
-
return (
|
|
9335
|
-
"You have rated the chat service.",
|
|
9336
|
-
React$1.createElement("div", { className: "buttons-container" },
|
|
9337
|
-
React$1.createElement(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }))));
|
|
9495
|
+
return (require$$0.jsxs(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card", children: ["You have rated the chat service.", require$$0.jsx("div", { className: "buttons-container", children: require$$0.jsx(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }) })] }));
|
|
9338
9496
|
}
|
|
9339
9497
|
};
|
|
9340
9498
|
|
|
9341
9499
|
var ChatRatingContainer = function (props) {
|
|
9342
9500
|
var dispatch = useChatServerDispatch();
|
|
9343
|
-
var handleRate =
|
|
9501
|
+
var handleRate = require$$1.useCallback(function (rating) {
|
|
9344
9502
|
dispatch(sendChatRating(rating));
|
|
9345
9503
|
}, [dispatch]);
|
|
9346
|
-
return (
|
|
9347
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
|
|
9348
|
-
React$1.createElement(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate })));
|
|
9504
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate })] }));
|
|
9349
9505
|
};
|
|
9350
9506
|
|
|
9351
9507
|
var dateFns = {};
|
|
@@ -19953,7 +20109,7 @@ var inheritsExports = inherits.exports;
|
|
|
19953
20109
|
|
|
19954
20110
|
var createSuper = {exports: {}};
|
|
19955
20111
|
|
|
19956
|
-
var getPrototypeOf = {exports: {}};
|
|
20112
|
+
var getPrototypeOf$1 = {exports: {}};
|
|
19957
20113
|
|
|
19958
20114
|
(function (module) {
|
|
19959
20115
|
function _getPrototypeOf(t) {
|
|
@@ -19962,9 +20118,9 @@ var getPrototypeOf = {exports: {}};
|
|
|
19962
20118
|
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
|
|
19963
20119
|
}
|
|
19964
20120
|
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
19965
|
-
} (getPrototypeOf));
|
|
20121
|
+
} (getPrototypeOf$1));
|
|
19966
20122
|
|
|
19967
|
-
var getPrototypeOfExports = getPrototypeOf.exports;
|
|
20123
|
+
var getPrototypeOfExports = getPrototypeOf$1.exports;
|
|
19968
20124
|
|
|
19969
20125
|
var isNativeReflectConstruct = {exports: {}};
|
|
19970
20126
|
|
|
@@ -27015,7 +27171,7 @@ var secondsToMinutes = {exports: {}};
|
|
|
27015
27171
|
|
|
27016
27172
|
var secondsToMinutesExports = secondsToMinutes.exports;
|
|
27017
27173
|
|
|
27018
|
-
var set = {exports: {}};
|
|
27174
|
+
var set$1 = {exports: {}};
|
|
27019
27175
|
|
|
27020
27176
|
var setMonth = {exports: {}};
|
|
27021
27177
|
|
|
@@ -27153,9 +27309,9 @@ var setMonthExports = setMonth.exports;
|
|
|
27153
27309
|
return date;
|
|
27154
27310
|
}
|
|
27155
27311
|
module.exports = exports.default;
|
|
27156
|
-
} (set, set.exports));
|
|
27312
|
+
} (set$1, set$1.exports));
|
|
27157
27313
|
|
|
27158
|
-
var setExports = set.exports;
|
|
27314
|
+
var setExports = set$1.exports;
|
|
27159
27315
|
|
|
27160
27316
|
var setDate = {exports: {}};
|
|
27161
27317
|
|
|
@@ -30841,9 +30997,9 @@ function compileSlotValues(responseOutput, slots, replaceWhenUndefined) {
|
|
|
30841
30997
|
|
|
30842
30998
|
var FailureMessage = function (props) {
|
|
30843
30999
|
var agents = props.agents, text = props.text, delay = props.delay, time = props.time;
|
|
30844
|
-
var _a =
|
|
31000
|
+
var _a = require$$1.useState(delay), countdown = _a[0], setCountdown = _a[1];
|
|
30845
31001
|
var agent_names = Object.values(agents).filter(function (agent) { return agent.requestFailed; });
|
|
30846
|
-
|
|
31002
|
+
require$$1.useEffect(function () {
|
|
30847
31003
|
if (delay !== 0) {
|
|
30848
31004
|
var countdownValue_1 = delay;
|
|
30849
31005
|
var myInterval_1 = setInterval(function () {
|
|
@@ -30858,7 +31014,7 @@ var FailureMessage = function (props) {
|
|
|
30858
31014
|
setCountdown(5);
|
|
30859
31015
|
}
|
|
30860
31016
|
}, [delay]);
|
|
30861
|
-
var slots =
|
|
31017
|
+
var slots = require$$1.useMemo(function () {
|
|
30862
31018
|
return {
|
|
30863
31019
|
sec: {
|
|
30864
31020
|
name: "sec",
|
|
@@ -30866,35 +31022,30 @@ var FailureMessage = function (props) {
|
|
|
30866
31022
|
},
|
|
30867
31023
|
};
|
|
30868
31024
|
}, [countdown]);
|
|
30869
|
-
var failureMessage =
|
|
31025
|
+
var failureMessage = require$$1.useMemo(function () {
|
|
30870
31026
|
return compileSlotValues(text, slots);
|
|
30871
31027
|
}, [text, slots]);
|
|
30872
31028
|
if (countdown === 0) {
|
|
30873
|
-
return
|
|
31029
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
30874
31030
|
}
|
|
30875
|
-
return (
|
|
30876
|
-
|
|
30877
|
-
|
|
30878
|
-
|
|
30879
|
-
|
|
30880
|
-
|
|
30881
|
-
React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
30882
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + time + " the bot said"),
|
|
30883
|
-
React$1.createElement("span", null, typeof failureMessage === "object" ? failureMessage.displayText : failureMessage)))))));
|
|
30884
|
-
})));
|
|
31031
|
+
return (require$$0.jsx(require$$0.Fragment, { children: agent_names.map(function (agent) {
|
|
31032
|
+
var _a, _b;
|
|
31033
|
+
return (require$$0.jsx("div", { className: "chat-msg-container-wrapper", children: require$$0.jsx("div", { className: "chat-msg-container agent", children: require$$0.jsx(ChatMessagePart, { user: agent === null || agent === void 0 ? void 0 : agent.user, showAvatar: true, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsxs(ChatMessageBubble, { owner: "others", hasTail: true, children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + " the bot said" }), require$$0.jsx("span", { children: typeof failureMessage === "object"
|
|
31034
|
+
? failureMessage.displayText
|
|
31035
|
+
: failureMessage })] }) }) }) }, (_a = agent === null || agent === void 0 ? void 0 : agent.user) === null || _a === void 0 ? void 0 : _a.nick) }, "failure-msg-".concat((_b = agent === null || agent === void 0 ? void 0 : agent.user) === null || _b === void 0 ? void 0 : _b.nick)));
|
|
31036
|
+
}) }));
|
|
30885
31037
|
};
|
|
30886
31038
|
|
|
30887
31039
|
var MessageSvg = function (_) {
|
|
30888
|
-
return (
|
|
30889
|
-
React$1.createElement("path", { d: "M14.4 0H1.6C.72 0 .008.675.008 1.5L0 10.5c0 .825.72 1.5 1.6 1.5h12.8c.88 0 1.6-.675 1.6-1.5v-9c0-.825-.72-1.5-1.6-1.5zm0 3L8 6.75 1.6 3V1.5L8 5.25l6.4-3.75V3z", fill: "#424242", fillRule: "evenodd" })));
|
|
31040
|
+
return (require$$0.jsx("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12", children: require$$0.jsx("path", { d: "M14.4 0H1.6C.72 0 .008.675.008 1.5L0 10.5c0 .825.72 1.5 1.6 1.5h12.8c.88 0 1.6-.675 1.6-1.5v-9c0-.825-.72-1.5-1.6-1.5zm0 3L8 6.75 1.6 3V1.5L8 5.25l6.4-3.75V3z", fill: "#424242", fillRule: "evenodd" }) }));
|
|
30890
31041
|
};
|
|
30891
31042
|
|
|
30892
31043
|
var MessageForm = function (props) {
|
|
30893
|
-
var name =
|
|
30894
|
-
var email =
|
|
30895
|
-
var message =
|
|
30896
|
-
var form =
|
|
30897
|
-
var _a =
|
|
31044
|
+
var name = require$$1.useRef(null);
|
|
31045
|
+
var email = require$$1.useRef(null);
|
|
31046
|
+
var message = require$$1.useRef(null);
|
|
31047
|
+
var form = require$$1.useRef(null);
|
|
31048
|
+
var _a = require$$1.useState(false), sent = _a[0], setSent = _a[1];
|
|
30898
31049
|
function emailChanged() {
|
|
30899
31050
|
var _a, _b, _c;
|
|
30900
31051
|
if ((_a = email.current) === null || _a === void 0 ? void 0 : _a.validity.patternMismatch) {
|
|
@@ -30914,7 +31065,7 @@ var MessageForm = function (props) {
|
|
|
30914
31065
|
props.onSubmit({
|
|
30915
31066
|
name: (_c = name.current) === null || _c === void 0 ? void 0 : _c.value,
|
|
30916
31067
|
email: (_d = email.current) === null || _d === void 0 ? void 0 : _d.value,
|
|
30917
|
-
message: (_e = message.current) === null || _e === void 0 ? void 0 : _e.value
|
|
31068
|
+
message: (_e = message.current) === null || _e === void 0 ? void 0 : _e.value,
|
|
30918
31069
|
});
|
|
30919
31070
|
setSent(true);
|
|
30920
31071
|
}
|
|
@@ -30922,56 +31073,40 @@ var MessageForm = function (props) {
|
|
|
30922
31073
|
setSent(false);
|
|
30923
31074
|
}
|
|
30924
31075
|
function renderSent() {
|
|
30925
|
-
return (
|
|
30926
|
-
"Your message has been sent. We will get back to you as soon as possible.",
|
|
30927
|
-
React$1.createElement(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })));
|
|
31076
|
+
return (require$$0.jsxs("div", { className: "message-form--sent", children: ["Your message has been sent. We will get back to you as soon as possible.", require$$0.jsx(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })] }, "sent"));
|
|
30928
31077
|
}
|
|
30929
31078
|
function renderForm() {
|
|
30930
|
-
return (
|
|
30931
|
-
|
|
30932
|
-
|
|
30933
|
-
React$1.createElement("label", { className: "label" }, "Name"),
|
|
30934
|
-
React$1.createElement("input", { ref: name, maxLength: 255 })),
|
|
30935
|
-
React$1.createElement("div", { className: "section" },
|
|
30936
|
-
React$1.createElement("label", { className: "label" }, "Email"),
|
|
30937
|
-
React$1.createElement("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })),
|
|
30938
|
-
React$1.createElement("div", { className: "section" },
|
|
30939
|
-
React$1.createElement("label", { className: "label" }, "Message"),
|
|
30940
|
-
React$1.createElement("textarea", { required: true, ref: message }))),
|
|
30941
|
-
React$1.createElement("div", { className: "button-container" },
|
|
30942
|
-
React$1.createElement(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }))));
|
|
30943
|
-
}
|
|
30944
|
-
return (React$1.createElement(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: React$1.createElement(MessageSvg, null) }, sent ? renderSent() : renderForm()));
|
|
31079
|
+
return (require$$0.jsxs("form", { ref: form, className: "message-form", onSubmit: send, children: [require$$0.jsxs("div", { className: "content", children: [require$$0.jsxs("div", { className: "section", children: [require$$0.jsx("label", { className: "label", children: "Name" }), require$$0.jsx("input", { ref: name, maxLength: 255 })] }), require$$0.jsxs("div", { className: "section", children: [require$$0.jsx("label", { className: "label", children: "Email" }), require$$0.jsx("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })] }), require$$0.jsxs("div", { className: "section", children: [require$$0.jsx("label", { className: "label", children: "Message" }), require$$0.jsx("textarea", { required: true, ref: message })] })] }), require$$0.jsx("div", { className: "button-container", children: require$$0.jsx(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }) })] }, "not-sent"));
|
|
31080
|
+
}
|
|
31081
|
+
return (require$$0.jsx(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: require$$0.jsx(MessageSvg, {}), children: sent ? renderSent() : renderForm() }));
|
|
30945
31082
|
};
|
|
30946
31083
|
|
|
30947
31084
|
var OfflineForm = function (props) {
|
|
30948
|
-
return
|
|
31085
|
+
return require$$0.jsx(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
|
|
30949
31086
|
};
|
|
30950
31087
|
|
|
30951
31088
|
var OfflineFormContainer = function (props) {
|
|
30952
31089
|
var dispatch = useChatServerDispatch();
|
|
30953
|
-
var handleSubmit =
|
|
31090
|
+
var handleSubmit = require$$1.useCallback(function (data) {
|
|
30954
31091
|
dispatch(sendOfflineMsg(data));
|
|
30955
31092
|
}, [dispatch]);
|
|
30956
|
-
return (
|
|
30957
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
|
|
30958
|
-
React$1.createElement(OfflineForm, { onSubmit: handleSubmit })));
|
|
31093
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx(OfflineForm, { onSubmit: handleSubmit })] }));
|
|
30959
31094
|
};
|
|
30960
31095
|
|
|
30961
31096
|
var PrechatForm = function (props) {
|
|
30962
|
-
var _a =
|
|
31097
|
+
var _a = require$$1.useState(false), sent = _a[0], setSent = _a[1];
|
|
30963
31098
|
var onSubmit = props.onSubmit;
|
|
30964
|
-
var handleSubmit =
|
|
31099
|
+
var handleSubmit = require$$1.useCallback(function (msg) {
|
|
30965
31100
|
onSubmit(msg);
|
|
30966
31101
|
setSent(true);
|
|
30967
31102
|
}, [onSubmit]);
|
|
30968
|
-
return
|
|
31103
|
+
return require$$0.jsx(require$$0.Fragment, { children: !sent && require$$0.jsx(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit }) });
|
|
30969
31104
|
};
|
|
30970
31105
|
|
|
30971
31106
|
var PrechatFormContainer = function (props) {
|
|
30972
31107
|
var dispatch = useChatServerDispatch();
|
|
30973
31108
|
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
30974
|
-
var handleSubmit =
|
|
31109
|
+
var handleSubmit = require$$1.useCallback(function (data) {
|
|
30975
31110
|
// Don't send empty messages
|
|
30976
31111
|
if (!data.message)
|
|
30977
31112
|
return;
|
|
@@ -30981,34 +31116,34 @@ var PrechatFormContainer = function (props) {
|
|
|
30981
31116
|
}, sessionId));
|
|
30982
31117
|
dispatch(executeAction(data.message));
|
|
30983
31118
|
}, [dispatch, sessionId]);
|
|
30984
|
-
return (
|
|
30985
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
|
|
30986
|
-
React$1.createElement(PrechatForm, { onSubmit: handleSubmit })));
|
|
31119
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx(PrechatForm, { onSubmit: handleSubmit })] }));
|
|
30987
31120
|
};
|
|
30988
31121
|
|
|
30989
|
-
var
|
|
30990
|
-
position:
|
|
30991
|
-
|
|
30992
|
-
var QueuePosition = function (props) {
|
|
30993
|
-
if (props === void 0) { props = defaultProps$1; }
|
|
30994
|
-
if (props.position <= 0)
|
|
31122
|
+
var QueuePosition = function (_a) {
|
|
31123
|
+
var _b = _a.position, position = _b === void 0 ? 0 : _b;
|
|
31124
|
+
if (position <= 0)
|
|
30995
31125
|
return null;
|
|
30996
|
-
return (
|
|
30997
|
-
React$1.createElement("span", { className: "system-msg" },
|
|
30998
|
-
"Queue position: ",
|
|
30999
|
-
props.position)));
|
|
31126
|
+
return (require$$0.jsx("div", { className: "system-msg-container", children: require$$0.jsxs("span", { className: "system-msg", children: ["Queue position: ", position] }) }));
|
|
31000
31127
|
};
|
|
31001
31128
|
|
|
31002
31129
|
function isServerUser(user) {
|
|
31003
31130
|
var _a;
|
|
31004
31131
|
return (_a = user.nick) === null || _a === void 0 ? void 0 : _a.endsWith(ROUTER_USER);
|
|
31005
31132
|
}
|
|
31133
|
+
function shouldShowDivider(message) {
|
|
31134
|
+
return (message.type === "chat.memberjoin" && message.showDivider) ||
|
|
31135
|
+
(message.type === "chat.memberleave" && message.showDivider);
|
|
31136
|
+
}
|
|
31006
31137
|
function getMessageByType(msg) {
|
|
31007
31138
|
switch (msg.type) {
|
|
31008
31139
|
case "chat.memberjoin":
|
|
31009
|
-
|
|
31140
|
+
// Use custom message if provided, otherwise use default
|
|
31141
|
+
return msg.message || "".concat(msg.user.displayName || "Bot", " has joined the chat");
|
|
31010
31142
|
case "chat.memberleave":
|
|
31011
|
-
|
|
31143
|
+
// Use custom message if provided, otherwise use default
|
|
31144
|
+
return msg.message || "".concat(msg.user.displayName || "Bot", " has left the chat");
|
|
31145
|
+
case "chat.systemmessage":
|
|
31146
|
+
return msg.message;
|
|
31012
31147
|
case "chat.rating":
|
|
31013
31148
|
if (!msg.newRating) {
|
|
31014
31149
|
return "You have removed the chat rating";
|
|
@@ -31022,10 +31157,12 @@ function getMessageByType(msg) {
|
|
|
31022
31157
|
}
|
|
31023
31158
|
}
|
|
31024
31159
|
var SystemMessage = function (props) {
|
|
31160
|
+
var _a;
|
|
31025
31161
|
if (!isServerUser(props.message.user)) {
|
|
31026
|
-
|
|
31027
|
-
|
|
31028
|
-
|
|
31162
|
+
var message = props.message;
|
|
31163
|
+
var showDivider = shouldShowDivider(message);
|
|
31164
|
+
var avatarUrl = (_a = message.user) === null || _a === void 0 ? void 0 : _a.avatarPath;
|
|
31165
|
+
return (require$$0.jsxs("div", { className: "system-msg-container", children: [showDivider && avatarUrl && (require$$0.jsxs("div", { className: "system-msg-divider", children: [require$$0.jsx("div", { className: "divider-line" }), require$$0.jsx("div", { className: "divider-avatar", children: require$$0.jsx("img", { src: avatarUrl, alt: "".concat(message.user.displayName || "User", "'s avatar") }) }), require$$0.jsx("div", { className: "divider-line" })] })), require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx("span", { className: "system-msg", children: getMessageByType(props.message) })] }));
|
|
31029
31166
|
}
|
|
31030
31167
|
else {
|
|
31031
31168
|
return null;
|
|
@@ -31036,10 +31173,7 @@ function convertToSentenceCase(s) {
|
|
|
31036
31173
|
}
|
|
31037
31174
|
|
|
31038
31175
|
var TypingIndicator = function (_) {
|
|
31039
|
-
return (
|
|
31040
|
-
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
31041
|
-
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
31042
|
-
React$1.createElement("div", { className: "typing-indicator-part" })));
|
|
31176
|
+
return (require$$0.jsxs("div", { className: "typing-indicator", children: [require$$0.jsx("div", { className: "typing-indicator-part" }), require$$0.jsx("div", { className: "typing-indicator-part" }), require$$0.jsx("div", { className: "typing-indicator-part" })] }));
|
|
31043
31177
|
};
|
|
31044
31178
|
|
|
31045
31179
|
/**
|
|
@@ -31047,52 +31181,65 @@ var TypingIndicator = function (_) {
|
|
|
31047
31181
|
*/
|
|
31048
31182
|
var TypingStatus = function (props) {
|
|
31049
31183
|
var agentsTyping = Object.values(props.agents).filter(function (agent) { return agent.typing; });
|
|
31050
|
-
return (
|
|
31051
|
-
|
|
31052
|
-
|
|
31053
|
-
|
|
31054
|
-
|
|
31055
|
-
|
|
31056
|
-
React$1.createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
|
|
31057
|
-
React$1.createElement("div", { className: "chat-msg" },
|
|
31058
|
-
React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
31059
|
-
React$1.createElement(TypingIndicator, null))))))) : (React$1.createElement("div", { key: "typing-status-".concat(key), className: "chat-msg-agent-typing" },
|
|
31060
|
-
displayName,
|
|
31061
|
-
" is typing"))));
|
|
31062
|
-
})));
|
|
31184
|
+
return (require$$0.jsx(require$$0.Fragment, { children: agentsTyping.map(function (agent, index) {
|
|
31185
|
+
var _a, _b;
|
|
31186
|
+
var key = ((_a = agent.user) === null || _a === void 0 ? void 0 : _a.nick) || "".concat(index);
|
|
31187
|
+
var displayName = ((_b = agent.user) === null || _b === void 0 ? void 0 : _b.displayName) || "Somebody";
|
|
31188
|
+
return (require$$0.jsx("span", { children: !props.textTypingStatusEnabled ? (require$$0.jsx("div", { className: "chat-msg-container-wrapper", children: require$$0.jsx("div", { className: "chat-msg-container agent chat-typing-progress", children: require$$0.jsx(ChatMessagePart, { user: agent.user, showAvatar: true, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx(ChatMessageBubble, { owner: "others", hasTail: true, children: require$$0.jsx(TypingIndicator, {}) }) }) }) }, key) }, "typing-status-".concat(key))) : (require$$0.jsxs("div", { className: "chat-msg-agent-typing", children: [displayName, " is typing"] }, "typing-status-".concat(key))) }, "typing-status-".concat(index)));
|
|
31189
|
+
}) }));
|
|
31063
31190
|
};
|
|
31064
31191
|
|
|
31065
|
-
var
|
|
31066
|
-
visible:
|
|
31067
|
-
|
|
31068
|
-
|
|
31069
|
-
|
|
31070
|
-
|
|
31071
|
-
|
|
31072
|
-
|
|
31073
|
-
|
|
31074
|
-
|
|
31075
|
-
|
|
31076
|
-
|
|
31077
|
-
|
|
31078
|
-
|
|
31079
|
-
}
|
|
31080
|
-
|
|
31081
|
-
|
|
31082
|
-
|
|
31083
|
-
|
|
31084
|
-
|
|
31085
|
-
|
|
31086
|
-
|
|
31087
|
-
|
|
31192
|
+
var MessageList = function (_a) {
|
|
31193
|
+
_a.visible; var _c = _a.messages, messages = _c === void 0 ? [] : _c, _d = _a.agents, agents = _d === void 0 ? {} : _d; _a.isOffline; _a.isChatting; var _g = _a.queuePosition, queuePosition = _g === void 0 ? 0 : _g, _h = _a.lastRatingRequestTimestamp, lastRatingRequestTimestamp = _h === void 0 ? 0 : _h, _j = _a.hasRating, hasRating = _j === void 0 ? false : _j; _a.visitorId; var messageMiddleware = _a.messageMiddleware, textTypingStatusEnabled = _a.textTypingStatusEnabled, agent = _a.agent, hasWsButton = _a.hasWsButton, _l = _a.onSend, onSend = _l === void 0 ? function () { return Promise.resolve(); } : _l, _m = _a.onWrite, onWrite = _m === void 0 ? function () { return Promise.resolve(); } : _m, _o = _a.onOpenUrl, onOpenUrl = _o === void 0 ? function () { } : _o, _p = _a.minimizeOnClick, minimizeOnClick = _p === void 0 ? function () { } : _p; _a.children;
|
|
31194
|
+
var messagesEndRef = require$$1.useRef(null);
|
|
31195
|
+
var containerRef = require$$1.useRef(null);
|
|
31196
|
+
var prevHasWsButtonRef = require$$1.useRef(hasWsButton);
|
|
31197
|
+
// Check if user is scrolled to bottom
|
|
31198
|
+
var isAtBottom = require$$1.useCallback(function () {
|
|
31199
|
+
if (!containerRef.current)
|
|
31200
|
+
return true;
|
|
31201
|
+
var _a = containerRef.current, scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
31202
|
+
return Math.abs(scrollHeight - clientHeight - scrollTop) < 10;
|
|
31203
|
+
}, []);
|
|
31204
|
+
// Scroll to bottom
|
|
31205
|
+
var scrollToBottom = require$$1.useCallback(function (behavior) {
|
|
31206
|
+
if (behavior === void 0) { behavior = "smooth"; }
|
|
31207
|
+
if (messagesEndRef.current) {
|
|
31208
|
+
messagesEndRef.current.scrollIntoView({ behavior: behavior });
|
|
31209
|
+
}
|
|
31210
|
+
}, []);
|
|
31211
|
+
// Always scroll to bottom when messages change
|
|
31212
|
+
require$$1.useEffect(function () {
|
|
31213
|
+
scrollToBottom("smooth");
|
|
31214
|
+
}, [messages, agents, scrollToBottom]);
|
|
31215
|
+
// Handle WS button dismissal - only scroll when button is removed
|
|
31216
|
+
require$$1.useEffect(function () {
|
|
31217
|
+
var prevHasButton = prevHasWsButtonRef.current;
|
|
31218
|
+
var currentHasButton = hasWsButton;
|
|
31219
|
+
// Update ref for next render
|
|
31220
|
+
prevHasWsButtonRef.current = currentHasButton;
|
|
31221
|
+
// Only handle button dismissal (was true, now false)
|
|
31222
|
+
if (prevHasButton && !currentHasButton) {
|
|
31223
|
+
var wasAtBottom = isAtBottom();
|
|
31224
|
+
if (wasAtBottom) {
|
|
31225
|
+
// Delay scroll adjustment to after button animation completes (animation + small buffer)
|
|
31226
|
+
var timer_1 = setTimeout(function () {
|
|
31227
|
+
scrollToBottom("smooth");
|
|
31228
|
+
}, WS_BUTTON_DISMISS_ANIMATION_DURATION + 50);
|
|
31229
|
+
return function () { return clearTimeout(timer_1); };
|
|
31230
|
+
}
|
|
31231
|
+
}
|
|
31232
|
+
return undefined;
|
|
31233
|
+
}, [hasWsButton, isAtBottom, scrollToBottom]);
|
|
31234
|
+
var handleSend = require$$1.useCallback(function (msg) {
|
|
31088
31235
|
onSend(msg);
|
|
31089
31236
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
31090
31237
|
}, [onSend]);
|
|
31091
|
-
var handleWrite =
|
|
31238
|
+
var handleWrite = require$$1.useCallback(function (msg) {
|
|
31092
31239
|
onWrite(msg);
|
|
31093
31240
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
31094
31241
|
}, [onWrite]);
|
|
31095
|
-
var ctxCache =
|
|
31242
|
+
var ctxCache = require$$1.useMemo(function () {
|
|
31096
31243
|
return new MiddlewareContextFactory({
|
|
31097
31244
|
send: handleSend,
|
|
31098
31245
|
write: handleWrite,
|
|
@@ -31115,7 +31262,7 @@ var MessageList = function (props) {
|
|
|
31115
31262
|
user = msg.user;
|
|
31116
31263
|
}
|
|
31117
31264
|
else {
|
|
31118
|
-
user = ((_c =
|
|
31265
|
+
user = ((_c = agents[msg.user.nick]) === null || _c === void 0 ? void 0 : _c.user) || agent;
|
|
31119
31266
|
// Still nothing?
|
|
31120
31267
|
if (!user) {
|
|
31121
31268
|
log("Could not get a user from agents list with nick: \"".concat(msg.user.nick, "\""));
|
|
@@ -31125,26 +31272,23 @@ var MessageList = function (props) {
|
|
|
31125
31272
|
switch (msg.type) {
|
|
31126
31273
|
case "chat.file":
|
|
31127
31274
|
case "chat.msg":
|
|
31128
|
-
return (
|
|
31275
|
+
return (require$$0.jsx(ChatMessage, { message: msg, sibling: sibling, agent: user, messageMiddleware: messageMiddleware, middlewareContext: ctxCache.resolve(user), minimizeOnClick: minimizeOnClick }, "cm-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31129
31276
|
case "chat.failureMsg":
|
|
31130
|
-
return (
|
|
31277
|
+
return (require$$0.jsx(FailureMessage, __assign({ agents: agents, time: time }, msg.failureMsg), "fm-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31131
31278
|
case "chat.memberjoin":
|
|
31132
31279
|
case "chat.memberleave":
|
|
31280
|
+
case "chat.systemmessage":
|
|
31133
31281
|
case "chat.rating":
|
|
31134
31282
|
case "chat.typing":
|
|
31135
|
-
return (
|
|
31283
|
+
return (require$$0.jsx(SystemMessage, { time: time, message: msg }, "sm-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31136
31284
|
case "chat.request.rating":
|
|
31137
|
-
return (
|
|
31285
|
+
return (require$$0.jsx(ChatRatingContainer, { agent: user, hasRating: hasRating, time: time, shouldDisplay: msg.timestamp === lastRatingRequestTimestamp }, "cr-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31138
31286
|
case "chat.offline":
|
|
31139
|
-
return
|
|
31287
|
+
return require$$0.jsx(OfflineFormContainer, { time: time }, "offline-".concat(msg.timestamp));
|
|
31140
31288
|
case "chat.prechat":
|
|
31141
|
-
return
|
|
31289
|
+
return require$$0.jsx(PrechatFormContainer, { time: time }, "prechat");
|
|
31142
31290
|
default:
|
|
31143
|
-
return (
|
|
31144
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + time + " system message"),
|
|
31145
|
-
React$1.createElement("div", { key: "uhm-".concat(+new Date()) },
|
|
31146
|
-
"Unhandled message: ",
|
|
31147
|
-
JSON.stringify(msg))));
|
|
31291
|
+
return (require$$0.jsxs("span", { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + " system message" }), require$$0.jsxs("div", { children: ["Unhandled message: ", JSON.stringify(msg)] }, "uhm-".concat(+new Date()))] }, "default-".concat(msg.timestamp)));
|
|
31148
31292
|
}
|
|
31149
31293
|
}
|
|
31150
31294
|
/**
|
|
@@ -31153,14 +31297,14 @@ var MessageList = function (props) {
|
|
|
31153
31297
|
*/
|
|
31154
31298
|
function renderAll() {
|
|
31155
31299
|
var lastMsgIndex = -1;
|
|
31156
|
-
for (var i =
|
|
31157
|
-
if (
|
|
31300
|
+
for (var i = messages.length - 1; i > 0; i--) {
|
|
31301
|
+
if (messages[i].type === "chat.msg") {
|
|
31158
31302
|
lastMsgIndex = i;
|
|
31159
31303
|
break;
|
|
31160
31304
|
}
|
|
31161
31305
|
}
|
|
31162
|
-
return
|
|
31163
|
-
// const next =
|
|
31306
|
+
return messages.map(function (message, index) {
|
|
31307
|
+
// const next = messages[index + 1];
|
|
31164
31308
|
var _a, _b;
|
|
31165
31309
|
// let sibling = false;
|
|
31166
31310
|
// const currentNick = message.nick;
|
|
@@ -31176,6 +31320,7 @@ var MessageList = function (props) {
|
|
|
31176
31320
|
// "chat.failureMsg",
|
|
31177
31321
|
"chat.memberjoin",
|
|
31178
31322
|
"chat.memberleave",
|
|
31323
|
+
// "chat.systemmessage", // System messages don't show timestamps
|
|
31179
31324
|
"chat.rating",
|
|
31180
31325
|
// "chat.typing",
|
|
31181
31326
|
"chat.request.rating",
|
|
@@ -31185,11 +31330,11 @@ var MessageList = function (props) {
|
|
|
31185
31330
|
// show first and las TS and after at least 5 minutes gap. Don't show "router user"
|
|
31186
31331
|
var showTs = false;
|
|
31187
31332
|
if (tsTypes.includes(message.type) && !((_b = (_a = message.user) === null || _a === void 0 ? void 0 : _a.nick) === null || _b === void 0 ? void 0 : _b.endsWith(ROUTER_USER))) {
|
|
31188
|
-
if (index === 0 || index ===
|
|
31333
|
+
if (index === 0 || index === messages.length - 1 || index === lastMsgIndex) {
|
|
31189
31334
|
showTs = true;
|
|
31190
31335
|
}
|
|
31191
31336
|
else {
|
|
31192
|
-
var previous =
|
|
31337
|
+
var previous = messages[index - 1];
|
|
31193
31338
|
if (message.timestamp && previous.timestamp) {
|
|
31194
31339
|
showTs = message.timestamp - previous.timestamp > 300 * 1000; // 5 minutes
|
|
31195
31340
|
}
|
|
@@ -31200,26 +31345,14 @@ var MessageList = function (props) {
|
|
|
31200
31345
|
showTs = false;
|
|
31201
31346
|
}
|
|
31202
31347
|
var ts = showTs ? new Date(message.timestamp).toLocaleString() : undefined;
|
|
31203
|
-
return (
|
|
31204
|
-
showTs && (React$1.createElement("div", { className: "ts-msg-container" },
|
|
31205
|
-
React$1.createElement("span", { className: "ts-msg" }, ts))),
|
|
31206
|
-
renderByType(message, false)));
|
|
31348
|
+
return (require$$0.jsxs("span", { children: [showTs && (require$$0.jsx("div", { className: "ts-msg-container", children: require$$0.jsx("span", { className: "ts-msg", children: ts }) })), renderByType(message, false)] }, "message-list-render-all-".concat(index)));
|
|
31207
31349
|
});
|
|
31208
31350
|
}
|
|
31209
|
-
|
|
31210
|
-
return (React$1.createElement("div", { className: "message-list-container" },
|
|
31211
|
-
React$1.createElement("div", { className: "message-list-container__msgs" },
|
|
31212
|
-
renderAll(),
|
|
31213
|
-
React$1.createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
|
|
31214
|
-
React$1.createElement(QueuePosition, { position: queuePosition }),
|
|
31215
|
-
React$1.createElement(TypingStatus, { agents: agents, textTypingStatusEnabled: props.textTypingStatusEnabled })),
|
|
31216
|
-
React$1.createElement(ChatChipsContainer, null)));
|
|
31351
|
+
return (require$$0.jsxs("div", { className: "message-list-container", ref: containerRef, children: [require$$0.jsxs("div", { className: "message-list-container__msgs", children: [renderAll(), require$$0.jsx("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }), require$$0.jsx(QueuePosition, { position: queuePosition }), require$$0.jsx(TypingStatus, { agents: agents, textTypingStatusEnabled: textTypingStatusEnabled })] }), require$$0.jsx(ChatChipsContainer, {})] }));
|
|
31217
31352
|
};
|
|
31218
31353
|
|
|
31219
31354
|
var ServerOffline = function () {
|
|
31220
|
-
return
|
|
31221
|
-
React$1.createElement("h2", null, "Chat is currently unavailable"),
|
|
31222
|
-
React$1.createElement("h3", null, "Server is offline"));
|
|
31355
|
+
return (require$$0.jsxs("div", { className: "server-offline", children: [require$$0.jsx("h2", { children: "Chat is currently unavailable" }), require$$0.jsx("h3", { children: "Server is offline" })] }));
|
|
31223
31356
|
};
|
|
31224
31357
|
|
|
31225
31358
|
function buildStyleContent(theme) {
|
|
@@ -31229,7 +31362,7 @@ function buildStyleContent(theme) {
|
|
|
31229
31362
|
function WidgetStylesheet(props) {
|
|
31230
31363
|
var theme = props.theme;
|
|
31231
31364
|
var stylesContent = buildStyleContent(theme);
|
|
31232
|
-
return
|
|
31365
|
+
return require$$0.jsx("style", { children: stylesContent });
|
|
31233
31366
|
}
|
|
31234
31367
|
function buildVariables(gen) {
|
|
31235
31368
|
var result = gen.next();
|
|
@@ -31567,13 +31700,13 @@ var safeStringify = function (arg) {
|
|
|
31567
31700
|
};
|
|
31568
31701
|
var ErrorOverlay = function (_a) {
|
|
31569
31702
|
var enableErrorOverlay = _a.enableErrorOverlay;
|
|
31570
|
-
var _b =
|
|
31571
|
-
var _c =
|
|
31572
|
-
var _d =
|
|
31573
|
-
var _e =
|
|
31574
|
-
var _f =
|
|
31703
|
+
var _b = require$$1.useState([]), errors = _b[0], setErrors = _b[1];
|
|
31704
|
+
var _c = require$$1.useState(false), isMinimized = _c[0], setIsMinimized = _c[1];
|
|
31705
|
+
var _d = require$$1.useState(true), isVisible = _d[0], setIsVisible = _d[1];
|
|
31706
|
+
var _e = require$$1.useState(false), isEnabled = _e[0], setIsEnabled = _e[1];
|
|
31707
|
+
var _f = require$$1.useState("bottom"), position = _f[0], setPosition = _f[1];
|
|
31575
31708
|
// Check if error overlay should be enabled and load position
|
|
31576
|
-
|
|
31709
|
+
require$$1.useEffect(function () {
|
|
31577
31710
|
var _a;
|
|
31578
31711
|
var checkEnabled = function () {
|
|
31579
31712
|
var _a;
|
|
@@ -31612,7 +31745,7 @@ var ErrorOverlay = function (_a) {
|
|
|
31612
31745
|
console.log("[ErrorOverlay] Component mounted, enabled:", enabled, "position:", savedPosition || "bottom");
|
|
31613
31746
|
}, [enableErrorOverlay]);
|
|
31614
31747
|
// Define addError with useCallback to prevent stale closures
|
|
31615
|
-
var addError =
|
|
31748
|
+
var addError = require$$1.useCallback(function (error) {
|
|
31616
31749
|
console.log("[ErrorOverlay] Adding error:", error);
|
|
31617
31750
|
setErrors(function (prev) {
|
|
31618
31751
|
var timestamp = new Date().toISOString();
|
|
@@ -31631,7 +31764,7 @@ var ErrorOverlay = function (_a) {
|
|
|
31631
31764
|
return updated.slice(-50);
|
|
31632
31765
|
});
|
|
31633
31766
|
}, []);
|
|
31634
|
-
|
|
31767
|
+
require$$1.useEffect(function () {
|
|
31635
31768
|
if (!isEnabled) {
|
|
31636
31769
|
console.log("[ErrorOverlay] Not enabled, skipping error interception");
|
|
31637
31770
|
return undefined;
|
|
@@ -31776,51 +31909,53 @@ var ErrorOverlay = function (_a) {
|
|
|
31776
31909
|
if (errors.length === 0) {
|
|
31777
31910
|
return null;
|
|
31778
31911
|
}
|
|
31779
|
-
return (
|
|
31780
|
-
|
|
31781
|
-
|
|
31782
|
-
|
|
31783
|
-
|
|
31784
|
-
|
|
31785
|
-
|
|
31786
|
-
|
|
31787
|
-
|
|
31788
|
-
|
|
31789
|
-
|
|
31790
|
-
|
|
31791
|
-
|
|
31792
|
-
|
|
31793
|
-
|
|
31794
|
-
|
|
31795
|
-
|
|
31796
|
-
|
|
31797
|
-
|
|
31798
|
-
|
|
31799
|
-
|
|
31800
|
-
|
|
31801
|
-
|
|
31802
|
-
|
|
31803
|
-
|
|
31912
|
+
return (require$$0.jsxs("div", { className: "error-overlay error-overlay--".concat(position, " ").concat(isMinimized ? "minimized" : ""), children: [require$$0.jsxs("div", { className: "error-overlay-header", children: [require$$0.jsxs("span", { className: "error-overlay-title", children: ["Debug Console (", errors.length, ")"] }), require$$0.jsxs("div", { className: "error-overlay-actions", children: [require$$0.jsx("button", { onClick: copyToClipboard, title: "Copy all to clipboard", children: "\uD83D\uDCCB" }), require$$0.jsx("button", { onClick: clearErrors, title: "Clear all", children: "\uD83D\uDDD1\uFE0F" }), require$$0.jsx("button", { onClick: togglePosition, title: "Move to ".concat(position === "bottom" ? "top" : "bottom"), children: position === "bottom" ? "⬆️" : "⬇️" }), require$$0.jsx("button", { onClick: toggleEnabled, title: "Disable Error Overlay", children: "\uD83D\uDD27" }), require$$0.jsx("button", { onClick: function () { return setIsMinimized(!isMinimized); }, title: "Minimize/Maximize", children: isMinimized ? "▲" : "▼" }), require$$0.jsx("button", { onClick: function () { return setIsVisible(false); }, title: "Close", children: "\u2715" })] })] }), !isMinimized && (require$$0.jsx("div", { className: "error-overlay-content", children: errors.map(function (error) { return (require$$0.jsxs("div", { className: "error-entry error-".concat(error.type), children: [require$$0.jsxs("div", { className: "error-header", children: [require$$0.jsx("span", { className: "error-time", children: new Date(error.timestamp).toLocaleTimeString() }), error.count > 1 && (require$$0.jsxs("span", { className: "error-count", children: ["(", error.count, "x)"] })), require$$0.jsx("span", { className: "error-badge error-badge-".concat(error.type), children: error.type })] }), require$$0.jsx("div", { className: "error-message", children: error.message }), error.stack && (require$$0.jsxs("details", { className: "error-stack", children: [require$$0.jsx("summary", { children: "Stack trace" }), require$$0.jsx("pre", { children: error.stack })] }))] }, error.id)); }) }))] }));
|
|
31913
|
+
};
|
|
31914
|
+
|
|
31915
|
+
var WsButton = function (_a) {
|
|
31916
|
+
var button = _a.button, onPress = _a.onPress;
|
|
31917
|
+
var handleClick = require$$1.useCallback(function () {
|
|
31918
|
+
if (button.pressBehavior !== "disabled" && !button.isPressed) {
|
|
31919
|
+
onPress(button.id);
|
|
31920
|
+
}
|
|
31921
|
+
}, [button.pressBehavior, button.isPressed, button.id, onPress]);
|
|
31922
|
+
var className = require$$1.useMemo(function () {
|
|
31923
|
+
var classes = ["ws-button"];
|
|
31924
|
+
if (button.pressBehavior === "disabled" || button.isPressed) {
|
|
31925
|
+
classes.push("ws-button--disabled");
|
|
31926
|
+
}
|
|
31927
|
+
if (button.isPressed && button.pressBehavior === "spinning") {
|
|
31928
|
+
classes.push("ws-button--spinning");
|
|
31929
|
+
}
|
|
31930
|
+
return classes.join(" ");
|
|
31931
|
+
}, [button.pressBehavior, button.isPressed]);
|
|
31932
|
+
var containerClassName = require$$1.useMemo(function () {
|
|
31933
|
+
var classes = ["ws-button-container"];
|
|
31934
|
+
if (button.isDismissing) {
|
|
31935
|
+
classes.push("ws-button-container--dismissing");
|
|
31936
|
+
}
|
|
31937
|
+
return classes.join(" ");
|
|
31938
|
+
}, [button.isDismissing]);
|
|
31939
|
+
return (require$$0.jsx("div", { className: containerClassName, children: require$$0.jsxs("button", { className: className, onClick: handleClick, disabled: button.pressBehavior === "disabled" || button.isPressed, "aria-label": button.text, "aria-busy": button.isPressed && button.pressBehavior === "spinning", children: [button.isPressed && button.pressBehavior === "spinning" && (require$$0.jsx("span", { className: "ws-button__spinner" })), require$$0.jsx("span", { className: "ws-button__text", children: button.text })] }) }));
|
|
31804
31940
|
};
|
|
31805
31941
|
|
|
31806
31942
|
var ModalContent = function (_a) {
|
|
31807
31943
|
var onClose = _a.onClose, onReset = _a.onReset;
|
|
31808
|
-
return (
|
|
31809
|
-
React$1.createElement("div", { className: "modalBody" },
|
|
31810
|
-
React$1.createElement("h2", null, "Restart Conversation"),
|
|
31811
|
-
React$1.createElement("p", null, "Would you like to refresh and return to the starting point of the conversation?")),
|
|
31812
|
-
React$1.createElement("div", { className: "modalActions" },
|
|
31813
|
-
React$1.createElement("button", { onClick: onClose, className: "cancelBtn" }, "Cancel"),
|
|
31814
|
-
React$1.createElement("button", { onClick: onReset, className: "restartBtn" }, "Restart"))));
|
|
31944
|
+
return (require$$0.jsxs("div", { className: "modalContent", children: [require$$0.jsxs("div", { className: "modalBody", children: [require$$0.jsx("h2", { children: "Restart Conversation" }), require$$0.jsx("p", { children: "Would you like to refresh and return to the starting point of the conversation?" })] }), require$$0.jsxs("div", { className: "modalActions", children: [require$$0.jsx("button", { onClick: onClose, className: "cancelBtn", children: "Cancel" }), require$$0.jsx("button", { onClick: onReset, className: "restartBtn", children: "Restart" })] })] }));
|
|
31815
31945
|
};
|
|
31816
31946
|
|
|
31947
|
+
/**
|
|
31948
|
+
* Debounce delay for typing indicator in milliseconds.
|
|
31949
|
+
* After this delay of inactivity, the "stop typing" event will be sent.
|
|
31950
|
+
*/
|
|
31951
|
+
var TYPING_INDICATOR_DEBOUNCE_MS = 2000;
|
|
31817
31952
|
var ChatWidgetWrapper = function (props) {
|
|
31818
31953
|
var _a;
|
|
31819
|
-
var _b =
|
|
31820
|
-
var _c =
|
|
31821
|
-
var _d =
|
|
31954
|
+
var _b = require$$1.useState(props.config), rawConfig = _b[0], setRawConfig = _b[1];
|
|
31955
|
+
var _c = require$$1.useState(!!props.getConfig), configLoading = _c[0], setConfigLoading = _c[1];
|
|
31956
|
+
var _d = require$$1.useState(), configError = _d[0], setConfigError = _d[1];
|
|
31822
31957
|
// Load config from callback if provided
|
|
31823
|
-
|
|
31958
|
+
require$$1.useEffect(function () {
|
|
31824
31959
|
var cancelled = false;
|
|
31825
31960
|
if (props.getConfig) {
|
|
31826
31961
|
setConfigLoading(true);
|
|
@@ -31854,12 +31989,12 @@ var ChatWidgetWrapper = function (props) {
|
|
|
31854
31989
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31855
31990
|
}, [props.getConfig, props.config]);
|
|
31856
31991
|
var connection = useConnectionInfo(rawConfig);
|
|
31857
|
-
var config =
|
|
31992
|
+
var config = require$$1.useMemo(function () {
|
|
31858
31993
|
var _a;
|
|
31859
31994
|
return (__assign(__assign({}, rawConfig), { connection: connection, assetUrl: (_a = connection === null || connection === void 0 ? void 0 : connection.serverUrl) !== null && _a !== void 0 ? _a : defaultServerUrl, env: rawConfig }));
|
|
31860
31995
|
}, [connection, rawConfig]);
|
|
31861
31996
|
var token = reactRedux.useSelector(function (state) { return state.connection.token; });
|
|
31862
|
-
var options =
|
|
31997
|
+
var options = require$$1.useMemo(function () {
|
|
31863
31998
|
var configurableMessages = getConfigurableMessages();
|
|
31864
31999
|
if ((rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.configurableMessages) &&
|
|
31865
32000
|
Array.isArray(rawConfig.configurableMessages.items) &&
|
|
@@ -31884,20 +32019,13 @@ var ChatWidgetWrapper = function (props) {
|
|
|
31884
32019
|
var modeClass = "widget-container--".concat(mode);
|
|
31885
32020
|
// Show loading state while config is being fetched
|
|
31886
32021
|
if (configLoading) {
|
|
31887
|
-
return (
|
|
31888
|
-
React$1.createElement("div", { className: "xa-spinner-container visible" },
|
|
31889
|
-
React$1.createElement("div", { className: "xa-spinner" }))));
|
|
32022
|
+
return (require$$0.jsx("div", { className: "widget-container widget-container--loading ".concat(modeClass), children: require$$0.jsx("div", { className: "xa-spinner-container visible", children: require$$0.jsx("div", { className: "xa-spinner" }) }) }));
|
|
31890
32023
|
}
|
|
31891
32024
|
// Show error state if config failed to load
|
|
31892
32025
|
if (configError) {
|
|
31893
|
-
return (
|
|
31894
|
-
|
|
31895
|
-
|
|
31896
|
-
configError.message)));
|
|
31897
|
-
}
|
|
31898
|
-
return (React$1.createElement(ChatConfigContext.Provider, { value: config },
|
|
31899
|
-
React$1.createElement(ChatServerContext.Provider, { value: chatServer },
|
|
31900
|
-
React$1.createElement(ChatWidget, __assign({}, props, { config: rawConfig })))));
|
|
32026
|
+
return (require$$0.jsx("div", { className: "widget-container widget-container--error ".concat(modeClass), children: require$$0.jsxs("div", { className: "widget-error-message", children: ["Failed to load chat configuration: ", configError.message] }) }));
|
|
32027
|
+
}
|
|
32028
|
+
return (require$$0.jsx(ChatConfigContext.Provider, { value: config, children: require$$0.jsx(ChatServerContext.Provider, { value: chatServer, children: require$$0.jsx(ChatWidget, __assign({}, props, { config: rawConfig })) }) }));
|
|
31901
32029
|
};
|
|
31902
32030
|
var ChatWidget = function (props) {
|
|
31903
32031
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
@@ -31906,7 +32034,7 @@ var ChatWidget = function (props) {
|
|
|
31906
32034
|
// From Redux
|
|
31907
32035
|
var chatState = reactRedux.useSelector(function (state) { return state; });
|
|
31908
32036
|
// Refresh modalReference
|
|
31909
|
-
var modalRef =
|
|
32037
|
+
var modalRef = require$$1.useRef({});
|
|
31910
32038
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
31911
32039
|
var dockedMode = mode === "docked";
|
|
31912
32040
|
var staticMode = mode === "static";
|
|
@@ -31928,13 +32056,17 @@ var ChatWidget = function (props) {
|
|
|
31928
32056
|
chatState.visuals = {};
|
|
31929
32057
|
}
|
|
31930
32058
|
// Our state - pull from storage
|
|
31931
|
-
var _8 =
|
|
32059
|
+
var _8 = require$$1.useState((!canMinimize && !canCancel) ||
|
|
31932
32060
|
// !!get("visible") ||
|
|
31933
32061
|
chatState.visuals.visible ||
|
|
31934
32062
|
(((_m = props.config) === null || _m === void 0 ? void 0 : _m.autoOpenOnWidth) &&
|
|
31935
32063
|
window.matchMedia("(min-width: ".concat((_o = props.config) === null || _o === void 0 ? void 0 : _o.autoOpenOnWidth, ")")).matches)), visible = _8[0], setVisibleState = _8[1];
|
|
31936
|
-
var _9 =
|
|
31937
|
-
|
|
32064
|
+
var _9 = require$$1.useState(false); _9[0]; var setTypingState = _9[1]; // false initially - state kept for potential external observers
|
|
32065
|
+
// Ref to track typing state for use in timeout callbacks
|
|
32066
|
+
var typingRef = require$$1.useRef(false);
|
|
32067
|
+
// Timeout ref for debouncing "stop typing" events
|
|
32068
|
+
var stopTypingTimeoutRef = require$$1.useRef(null);
|
|
32069
|
+
var chatServer = require$$1.useContext(ChatServerContext);
|
|
31938
32070
|
var patternsConfig = (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.autoOpenOnPattern) === null || _q === void 0 ? void 0 : _q.patterns;
|
|
31939
32071
|
var currentUrl = window.location.href;
|
|
31940
32072
|
var patternExist = patternsConfig && patternsConfig.length > 0;
|
|
@@ -31942,16 +32074,17 @@ var ChatWidget = function (props) {
|
|
|
31942
32074
|
var configWidth = (_s = (_r = props.config) === null || _r === void 0 ? void 0 : _r.autoOpenOnPattern) === null || _s === void 0 ? void 0 : _s.minimumWidth;
|
|
31943
32075
|
// eslint-disable-next-line no-restricted-globals
|
|
31944
32076
|
var currentWidth = screen.width;
|
|
31945
|
-
var setVisible =
|
|
32077
|
+
var setVisible = require$$1.useCallback(function (newVisible) {
|
|
31946
32078
|
if (staticMode) {
|
|
31947
32079
|
return;
|
|
31948
32080
|
}
|
|
32081
|
+
log("setVisible: ".concat(newVisible));
|
|
31949
32082
|
setVisibleState(newVisible);
|
|
31950
32083
|
innerDispatch(setVisualStatus({
|
|
31951
32084
|
visible: newVisible,
|
|
31952
32085
|
}));
|
|
31953
32086
|
}, [innerDispatch, staticMode]);
|
|
31954
|
-
|
|
32087
|
+
require$$1.useEffect(function () {
|
|
31955
32088
|
var _a, _b;
|
|
31956
32089
|
var handleKeyDown = function (event) {
|
|
31957
32090
|
var body = document.getElementsByTagName("body")[0];
|
|
@@ -31967,11 +32100,15 @@ var ChatWidget = function (props) {
|
|
|
31967
32100
|
}
|
|
31968
32101
|
return function () {
|
|
31969
32102
|
document.removeEventListener("keydown", handleKeyDown);
|
|
32103
|
+
// Cleanup typing timeout on unmount
|
|
32104
|
+
if (stopTypingTimeoutRef.current) {
|
|
32105
|
+
clearTimeout(stopTypingTimeoutRef.current);
|
|
32106
|
+
}
|
|
31970
32107
|
};
|
|
31971
32108
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31972
32109
|
}, []);
|
|
31973
|
-
var _10 =
|
|
31974
|
-
|
|
32110
|
+
var _10 = require$$1.useState(!document.hidden), isTabVisible = _10[0], setIsTabVisible = _10[1];
|
|
32111
|
+
require$$1.useEffect(function () {
|
|
31975
32112
|
var handleVisibilityChange = function () {
|
|
31976
32113
|
setIsTabVisible(!document.hidden);
|
|
31977
32114
|
};
|
|
@@ -31980,19 +32117,22 @@ var ChatWidget = function (props) {
|
|
|
31980
32117
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
31981
32118
|
};
|
|
31982
32119
|
}, []);
|
|
31983
|
-
|
|
32120
|
+
require$$1.useEffect(function () {
|
|
31984
32121
|
// Too early?
|
|
31985
32122
|
if (!chatServer) {
|
|
32123
|
+
log("Tab visibility changed but no chatServer yet");
|
|
31986
32124
|
return;
|
|
31987
32125
|
}
|
|
31988
32126
|
if (!isTabVisible) {
|
|
32127
|
+
log("Tab is HIDDEN - calling sleep()");
|
|
31989
32128
|
chatServer.sleep();
|
|
31990
32129
|
}
|
|
31991
32130
|
else {
|
|
32131
|
+
log("Tab is VISIBLE - calling wakeup()");
|
|
31992
32132
|
chatServer.wakeup();
|
|
31993
32133
|
}
|
|
31994
32134
|
}, [chatServer, innerDispatch, isTabVisible]);
|
|
31995
|
-
|
|
32135
|
+
require$$1.useEffect(function () {
|
|
31996
32136
|
// For reopen widget after move on same window
|
|
31997
32137
|
// if (get("opened")) {
|
|
31998
32138
|
// setVisible(true);
|
|
@@ -32020,19 +32160,34 @@ var ChatWidget = function (props) {
|
|
|
32020
32160
|
chatState.visuals.opened,
|
|
32021
32161
|
mode,
|
|
32022
32162
|
]);
|
|
32023
|
-
function
|
|
32024
|
-
if (!
|
|
32025
|
-
dispatch(sendTyping(true));
|
|
32026
|
-
setTypingState(true);
|
|
32027
|
-
}
|
|
32028
|
-
stopTyping();
|
|
32029
|
-
}
|
|
32030
|
-
function stopTyping() {
|
|
32031
|
-
if (!typing)
|
|
32163
|
+
var stopTyping = require$$1.useCallback(function () {
|
|
32164
|
+
if (!typingRef.current)
|
|
32032
32165
|
return;
|
|
32166
|
+
// Clear the timeout if it exists
|
|
32167
|
+
if (stopTypingTimeoutRef.current) {
|
|
32168
|
+
clearTimeout(stopTypingTimeoutRef.current);
|
|
32169
|
+
stopTypingTimeoutRef.current = null;
|
|
32170
|
+
}
|
|
32033
32171
|
dispatch(sendTyping(false));
|
|
32034
32172
|
setTypingState(false);
|
|
32035
|
-
|
|
32173
|
+
typingRef.current = false;
|
|
32174
|
+
}, [dispatch]);
|
|
32175
|
+
var handleOnChange = require$$1.useCallback(function () {
|
|
32176
|
+
// Send "typing" event only on first keystroke
|
|
32177
|
+
if (!typingRef.current) {
|
|
32178
|
+
dispatch(sendTyping(true));
|
|
32179
|
+
setTypingState(true);
|
|
32180
|
+
typingRef.current = true;
|
|
32181
|
+
}
|
|
32182
|
+
// Clear any existing timeout
|
|
32183
|
+
if (stopTypingTimeoutRef.current) {
|
|
32184
|
+
clearTimeout(stopTypingTimeoutRef.current);
|
|
32185
|
+
}
|
|
32186
|
+
// Set a new timeout to send "stop typing" after inactivity
|
|
32187
|
+
stopTypingTimeoutRef.current = window.setTimeout(function () {
|
|
32188
|
+
stopTyping();
|
|
32189
|
+
}, TYPING_INDICATOR_DEBOUNCE_MS);
|
|
32190
|
+
}, [dispatch, stopTyping]);
|
|
32036
32191
|
function handleSendMessage(msg) {
|
|
32037
32192
|
dispatch(sendMessage(msg));
|
|
32038
32193
|
}
|
|
@@ -32122,12 +32277,56 @@ var ChatWidget = function (props) {
|
|
|
32122
32277
|
hasInteracted: true,
|
|
32123
32278
|
}));
|
|
32124
32279
|
}
|
|
32280
|
+
function handleWsButtonPress(buttonId) {
|
|
32281
|
+
var _a, _b;
|
|
32282
|
+
log("WS Button pressed: ".concat(buttonId));
|
|
32283
|
+
// If the button has spinning behavior, update state to show spinner
|
|
32284
|
+
if (((_a = chatState.wsButton) === null || _a === void 0 ? void 0 : _a.pressBehavior) === "spinning") {
|
|
32285
|
+
// Update the button state to show it's pressed
|
|
32286
|
+
innerDispatch({
|
|
32287
|
+
type: "ws_button_display",
|
|
32288
|
+
detail: __assign(__assign({}, chatState.wsButton), { isPressed: true, timestamp: +new Date() })
|
|
32289
|
+
});
|
|
32290
|
+
}
|
|
32291
|
+
// Send the button pressed event to the server
|
|
32292
|
+
if (chatServer && chatServer.sendButtonPressed) {
|
|
32293
|
+
chatServer.sendButtonPressed(buttonId).catch(function (error) {
|
|
32294
|
+
err("Failed to send button press: ".concat(error));
|
|
32295
|
+
// Reset button state on error
|
|
32296
|
+
if (chatState.wsButton) {
|
|
32297
|
+
innerDispatch({
|
|
32298
|
+
type: "ws_button_display",
|
|
32299
|
+
detail: __assign(__assign({}, chatState.wsButton), { isPressed: false, timestamp: +new Date() })
|
|
32300
|
+
});
|
|
32301
|
+
}
|
|
32302
|
+
});
|
|
32303
|
+
}
|
|
32304
|
+
// If the button has disabled behavior, animate out then dismiss
|
|
32305
|
+
if (((_b = chatState.wsButton) === null || _b === void 0 ? void 0 : _b.pressBehavior) === "disabled") {
|
|
32306
|
+
// First set dismissing state to trigger animation
|
|
32307
|
+
innerDispatch({
|
|
32308
|
+
type: "ws_button_display",
|
|
32309
|
+
detail: __assign(__assign({}, chatState.wsButton), { isDismissing: true, timestamp: +new Date() })
|
|
32310
|
+
});
|
|
32311
|
+
// Then actually dismiss after animation completes
|
|
32312
|
+
setTimeout(function () {
|
|
32313
|
+
innerDispatch({
|
|
32314
|
+
type: "ws_button_dismiss",
|
|
32315
|
+
detail: {
|
|
32316
|
+
id: buttonId,
|
|
32317
|
+
timestamp: +new Date()
|
|
32318
|
+
}
|
|
32319
|
+
});
|
|
32320
|
+
}, WS_BUTTON_DISMISS_ANIMATION_DURATION);
|
|
32321
|
+
}
|
|
32322
|
+
}
|
|
32125
32323
|
var isOffline = chatState.accountStatus === "offline" && !chatState.isChatting;
|
|
32126
32324
|
var messages = chatState && chatState.chats;
|
|
32325
|
+
log("Rendering - accountStatus: \"".concat(chatState.accountStatus, "\", connectionStatus: \"").concat(chatState.connection.connectionStatus, "\""));
|
|
32127
32326
|
var config = props.config, onConnectionStatusChange = props.onConnectionStatusChange;
|
|
32128
32327
|
useGreeting(!isOffline && !props.preChatFormEnabled && visible);
|
|
32129
32328
|
var connectionStatus = chatState.connection.connectionStatus;
|
|
32130
|
-
|
|
32329
|
+
require$$1.useEffect(function () {
|
|
32131
32330
|
if (onConnectionStatusChange) {
|
|
32132
32331
|
onConnectionStatusChange(connectionStatus);
|
|
32133
32332
|
}
|
|
@@ -32140,19 +32339,7 @@ var ChatWidget = function (props) {
|
|
|
32140
32339
|
avatarPath: config.avatarUrl,
|
|
32141
32340
|
display_name: "Agent",
|
|
32142
32341
|
};
|
|
32143
|
-
return (
|
|
32144
|
-
React$1.createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
32145
|
-
React$1.createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
32146
|
-
React$1.createElement(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, onSubmit: handleOnSubmit }),
|
|
32147
|
-
React$1.createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.typingStatus) === null || _w === void 0 ? void 0 : _w.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }),
|
|
32148
|
-
React$1.createElement("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
32149
|
-
React$1.createElement("div", { className: "xa-spinner" })),
|
|
32150
|
-
connectionStatus === "offline" && React$1.createElement(ServerOffline, null),
|
|
32151
|
-
React$1.createElement(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_x = config === null || config === void 0 ? void 0 : config.input) === null || _x === void 0 ? void 0 : _x.placeholder, sendButtonIcon: (_z = (_y = config === null || config === void 0 ? void 0 : config.footer) === null || _y === void 0 ? void 0 : _y.sendButton) === null || _z === void 0 ? void 0 : _z.icon, sendButtonIconHover: (_1 = (_0 = config === null || config === void 0 ? void 0 : config.footer) === null || _0 === void 0 ? void 0 : _0.sendButton) === null || _1 === void 0 ? void 0 : _1.iconHover, sendButtonIconDisabled: (_3 = (_2 = config === null || config === void 0 ? void 0 : config.footer) === null || _2 === void 0 ? void 0 : _2.sendButton) === null || _3 === void 0 ? void 0 : _3.iconDisabled, visible: visible, menuConfig: props.config.menu, footerConfig: (_4 = props.config) === null || _4 === void 0 ? void 0 : _4.footer, inputConfig: (_5 = props.config) === null || _5 === void 0 ? void 0 : _5.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }),
|
|
32152
|
-
React$1.createElement("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick },
|
|
32153
|
-
React$1.createElement(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }))),
|
|
32154
|
-
React$1.createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: config === null || config === void 0 ? void 0 : config.cta, imageUrl: (_6 = config === null || config === void 0 ? void 0 : config.chatButton) === null || _6 === void 0 ? void 0 : _6.imageUrl, visible: visible, hasInteracted: (_7 = chatState.visuals) === null || _7 === void 0 ? void 0 : _7.hasInteracted, onCtaDismiss: handleCtaDismiss }),
|
|
32155
|
-
React$1.createElement(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })));
|
|
32342
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), require$$0.jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, onSubmit: handleOnSubmit }), require$$0.jsx(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.typingStatus) === null || _w === void 0 ? void 0 : _w.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }), require$$0.jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: require$$0.jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && require$$0.jsx(ServerOffline, {}), chatState.wsButton && visible && (require$$0.jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), require$$0.jsx(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_x = config === null || config === void 0 ? void 0 : config.input) === null || _x === void 0 ? void 0 : _x.placeholder, sendButtonIcon: (_z = (_y = config === null || config === void 0 ? void 0 : config.footer) === null || _y === void 0 ? void 0 : _y.sendButton) === null || _z === void 0 ? void 0 : _z.icon, sendButtonIconHover: (_1 = (_0 = config === null || config === void 0 ? void 0 : config.footer) === null || _0 === void 0 ? void 0 : _0.sendButton) === null || _1 === void 0 ? void 0 : _1.iconHover, sendButtonIconDisabled: (_3 = (_2 = config === null || config === void 0 ? void 0 : config.footer) === null || _2 === void 0 ? void 0 : _2.sendButton) === null || _3 === void 0 ? void 0 : _3.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: props.config.menu, footerConfig: (_4 = props.config) === null || _4 === void 0 ? void 0 : _4.footer, inputConfig: (_5 = props.config) === null || _5 === void 0 ? void 0 : _5.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }), require$$0.jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: require$$0.jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), require$$0.jsx(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: config === null || config === void 0 ? void 0 : config.cta, imageUrl: (_6 = config === null || config === void 0 ? void 0 : config.chatButton) === null || _6 === void 0 ? void 0 : _6.imageUrl, visible: visible, hasInteracted: (_7 = chatState.visuals) === null || _7 === void 0 ? void 0 : _7.hasInteracted, onCtaDismiss: handleCtaDismiss }), require$$0.jsx(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })] }));
|
|
32156
32343
|
};
|
|
32157
32344
|
|
|
32158
32345
|
// src/utils/formatProdErrorMessage.ts
|
|
@@ -32174,7 +32361,7 @@ var ActionTypes = {
|
|
|
32174
32361
|
var actionTypes_default = ActionTypes;
|
|
32175
32362
|
|
|
32176
32363
|
// src/utils/isPlainObject.ts
|
|
32177
|
-
function isPlainObject(obj) {
|
|
32364
|
+
function isPlainObject$1(obj) {
|
|
32178
32365
|
if (typeof obj !== "object" || obj === null)
|
|
32179
32366
|
return false;
|
|
32180
32367
|
let proto = obj;
|
|
@@ -32247,7 +32434,7 @@ function createStore(reducer, preloadedState, enhancer) {
|
|
|
32247
32434
|
};
|
|
32248
32435
|
}
|
|
32249
32436
|
function dispatch(action) {
|
|
32250
|
-
if (!isPlainObject(action)) {
|
|
32437
|
+
if (!isPlainObject$1(action)) {
|
|
32251
32438
|
throw new Error(formatProdErrorMessage$1(7) );
|
|
32252
32439
|
}
|
|
32253
32440
|
if (typeof action.type === "undefined") {
|
|
@@ -32410,6 +32597,726 @@ function applyMiddleware(...middlewares) {
|
|
|
32410
32597
|
};
|
|
32411
32598
|
}
|
|
32412
32599
|
|
|
32600
|
+
// src/utils/env.ts
|
|
32601
|
+
var NOTHING = Symbol.for("immer-nothing");
|
|
32602
|
+
var DRAFTABLE = Symbol.for("immer-draftable");
|
|
32603
|
+
var DRAFT_STATE = Symbol.for("immer-state");
|
|
32604
|
+
function die(error, ...args) {
|
|
32605
|
+
throw new Error(
|
|
32606
|
+
`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
|
|
32607
|
+
);
|
|
32608
|
+
}
|
|
32609
|
+
|
|
32610
|
+
// src/utils/common.ts
|
|
32611
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
32612
|
+
function isDraft(value) {
|
|
32613
|
+
return !!value && !!value[DRAFT_STATE];
|
|
32614
|
+
}
|
|
32615
|
+
function isDraftable(value) {
|
|
32616
|
+
if (!value)
|
|
32617
|
+
return false;
|
|
32618
|
+
return isPlainObject(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
|
|
32619
|
+
}
|
|
32620
|
+
var objectCtorString = Object.prototype.constructor.toString();
|
|
32621
|
+
var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
|
|
32622
|
+
function isPlainObject(value) {
|
|
32623
|
+
if (!value || typeof value !== "object")
|
|
32624
|
+
return false;
|
|
32625
|
+
const proto = Object.getPrototypeOf(value);
|
|
32626
|
+
if (proto === null || proto === Object.prototype)
|
|
32627
|
+
return true;
|
|
32628
|
+
const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
32629
|
+
if (Ctor === Object)
|
|
32630
|
+
return true;
|
|
32631
|
+
if (typeof Ctor !== "function")
|
|
32632
|
+
return false;
|
|
32633
|
+
let ctorString = cachedCtorStrings.get(Ctor);
|
|
32634
|
+
if (ctorString === void 0) {
|
|
32635
|
+
ctorString = Function.toString.call(Ctor);
|
|
32636
|
+
cachedCtorStrings.set(Ctor, ctorString);
|
|
32637
|
+
}
|
|
32638
|
+
return ctorString === objectCtorString;
|
|
32639
|
+
}
|
|
32640
|
+
function each(obj, iter, strict = true) {
|
|
32641
|
+
if (getArchtype(obj) === 0 /* Object */) {
|
|
32642
|
+
const keys = strict ? Reflect.ownKeys(obj) : Object.keys(obj);
|
|
32643
|
+
keys.forEach((key) => {
|
|
32644
|
+
iter(key, obj[key], obj);
|
|
32645
|
+
});
|
|
32646
|
+
} else {
|
|
32647
|
+
obj.forEach((entry, index) => iter(index, entry, obj));
|
|
32648
|
+
}
|
|
32649
|
+
}
|
|
32650
|
+
function getArchtype(thing) {
|
|
32651
|
+
const state = thing[DRAFT_STATE];
|
|
32652
|
+
return state ? state.type_ : Array.isArray(thing) ? 1 /* Array */ : isMap(thing) ? 2 /* Map */ : isSet(thing) ? 3 /* Set */ : 0 /* Object */;
|
|
32653
|
+
}
|
|
32654
|
+
function has(thing, prop) {
|
|
32655
|
+
return getArchtype(thing) === 2 /* Map */ ? thing.has(prop) : Object.prototype.hasOwnProperty.call(thing, prop);
|
|
32656
|
+
}
|
|
32657
|
+
function set(thing, propOrOldValue, value) {
|
|
32658
|
+
const t = getArchtype(thing);
|
|
32659
|
+
if (t === 2 /* Map */)
|
|
32660
|
+
thing.set(propOrOldValue, value);
|
|
32661
|
+
else if (t === 3 /* Set */) {
|
|
32662
|
+
thing.add(value);
|
|
32663
|
+
} else
|
|
32664
|
+
thing[propOrOldValue] = value;
|
|
32665
|
+
}
|
|
32666
|
+
function is(x, y) {
|
|
32667
|
+
if (x === y) {
|
|
32668
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
32669
|
+
} else {
|
|
32670
|
+
return x !== x && y !== y;
|
|
32671
|
+
}
|
|
32672
|
+
}
|
|
32673
|
+
function isMap(target) {
|
|
32674
|
+
return target instanceof Map;
|
|
32675
|
+
}
|
|
32676
|
+
function isSet(target) {
|
|
32677
|
+
return target instanceof Set;
|
|
32678
|
+
}
|
|
32679
|
+
function latest(state) {
|
|
32680
|
+
return state.copy_ || state.base_;
|
|
32681
|
+
}
|
|
32682
|
+
function shallowCopy(base, strict) {
|
|
32683
|
+
if (isMap(base)) {
|
|
32684
|
+
return new Map(base);
|
|
32685
|
+
}
|
|
32686
|
+
if (isSet(base)) {
|
|
32687
|
+
return new Set(base);
|
|
32688
|
+
}
|
|
32689
|
+
if (Array.isArray(base))
|
|
32690
|
+
return Array.prototype.slice.call(base);
|
|
32691
|
+
const isPlain = isPlainObject(base);
|
|
32692
|
+
if (strict === true || strict === "class_only" && !isPlain) {
|
|
32693
|
+
const descriptors = Object.getOwnPropertyDescriptors(base);
|
|
32694
|
+
delete descriptors[DRAFT_STATE];
|
|
32695
|
+
let keys = Reflect.ownKeys(descriptors);
|
|
32696
|
+
for (let i = 0; i < keys.length; i++) {
|
|
32697
|
+
const key = keys[i];
|
|
32698
|
+
const desc = descriptors[key];
|
|
32699
|
+
if (desc.writable === false) {
|
|
32700
|
+
desc.writable = true;
|
|
32701
|
+
desc.configurable = true;
|
|
32702
|
+
}
|
|
32703
|
+
if (desc.get || desc.set)
|
|
32704
|
+
descriptors[key] = {
|
|
32705
|
+
configurable: true,
|
|
32706
|
+
writable: true,
|
|
32707
|
+
// could live with !!desc.set as well here...
|
|
32708
|
+
enumerable: desc.enumerable,
|
|
32709
|
+
value: base[key]
|
|
32710
|
+
};
|
|
32711
|
+
}
|
|
32712
|
+
return Object.create(getPrototypeOf(base), descriptors);
|
|
32713
|
+
} else {
|
|
32714
|
+
const proto = getPrototypeOf(base);
|
|
32715
|
+
if (proto !== null && isPlain) {
|
|
32716
|
+
return { ...base };
|
|
32717
|
+
}
|
|
32718
|
+
const obj = Object.create(proto);
|
|
32719
|
+
return Object.assign(obj, base);
|
|
32720
|
+
}
|
|
32721
|
+
}
|
|
32722
|
+
function freeze(obj, deep = false) {
|
|
32723
|
+
if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
|
|
32724
|
+
return obj;
|
|
32725
|
+
if (getArchtype(obj) > 1) {
|
|
32726
|
+
Object.defineProperties(obj, {
|
|
32727
|
+
set: dontMutateMethodOverride,
|
|
32728
|
+
add: dontMutateMethodOverride,
|
|
32729
|
+
clear: dontMutateMethodOverride,
|
|
32730
|
+
delete: dontMutateMethodOverride
|
|
32731
|
+
});
|
|
32732
|
+
}
|
|
32733
|
+
Object.freeze(obj);
|
|
32734
|
+
if (deep)
|
|
32735
|
+
Object.values(obj).forEach((value) => freeze(value, true));
|
|
32736
|
+
return obj;
|
|
32737
|
+
}
|
|
32738
|
+
function dontMutateFrozenCollections() {
|
|
32739
|
+
die(2);
|
|
32740
|
+
}
|
|
32741
|
+
var dontMutateMethodOverride = {
|
|
32742
|
+
value: dontMutateFrozenCollections
|
|
32743
|
+
};
|
|
32744
|
+
function isFrozen(obj) {
|
|
32745
|
+
if (obj === null || typeof obj !== "object")
|
|
32746
|
+
return true;
|
|
32747
|
+
return Object.isFrozen(obj);
|
|
32748
|
+
}
|
|
32749
|
+
|
|
32750
|
+
// src/utils/plugins.ts
|
|
32751
|
+
var plugins = {};
|
|
32752
|
+
function getPlugin(pluginKey) {
|
|
32753
|
+
const plugin = plugins[pluginKey];
|
|
32754
|
+
if (!plugin) {
|
|
32755
|
+
die(0, pluginKey);
|
|
32756
|
+
}
|
|
32757
|
+
return plugin;
|
|
32758
|
+
}
|
|
32759
|
+
|
|
32760
|
+
// src/core/scope.ts
|
|
32761
|
+
var currentScope;
|
|
32762
|
+
function getCurrentScope() {
|
|
32763
|
+
return currentScope;
|
|
32764
|
+
}
|
|
32765
|
+
function createScope(parent_, immer_) {
|
|
32766
|
+
return {
|
|
32767
|
+
drafts_: [],
|
|
32768
|
+
parent_,
|
|
32769
|
+
immer_,
|
|
32770
|
+
// Whenever the modified draft contains a draft from another scope, we
|
|
32771
|
+
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
32772
|
+
canAutoFreeze_: true,
|
|
32773
|
+
unfinalizedDrafts_: 0
|
|
32774
|
+
};
|
|
32775
|
+
}
|
|
32776
|
+
function usePatchesInScope(scope, patchListener) {
|
|
32777
|
+
if (patchListener) {
|
|
32778
|
+
getPlugin("Patches");
|
|
32779
|
+
scope.patches_ = [];
|
|
32780
|
+
scope.inversePatches_ = [];
|
|
32781
|
+
scope.patchListener_ = patchListener;
|
|
32782
|
+
}
|
|
32783
|
+
}
|
|
32784
|
+
function revokeScope(scope) {
|
|
32785
|
+
leaveScope(scope);
|
|
32786
|
+
scope.drafts_.forEach(revokeDraft);
|
|
32787
|
+
scope.drafts_ = null;
|
|
32788
|
+
}
|
|
32789
|
+
function leaveScope(scope) {
|
|
32790
|
+
if (scope === currentScope) {
|
|
32791
|
+
currentScope = scope.parent_;
|
|
32792
|
+
}
|
|
32793
|
+
}
|
|
32794
|
+
function enterScope(immer2) {
|
|
32795
|
+
return currentScope = createScope(currentScope, immer2);
|
|
32796
|
+
}
|
|
32797
|
+
function revokeDraft(draft) {
|
|
32798
|
+
const state = draft[DRAFT_STATE];
|
|
32799
|
+
if (state.type_ === 0 /* Object */ || state.type_ === 1 /* Array */)
|
|
32800
|
+
state.revoke_();
|
|
32801
|
+
else
|
|
32802
|
+
state.revoked_ = true;
|
|
32803
|
+
}
|
|
32804
|
+
|
|
32805
|
+
// src/core/finalize.ts
|
|
32806
|
+
function processResult(result, scope) {
|
|
32807
|
+
scope.unfinalizedDrafts_ = scope.drafts_.length;
|
|
32808
|
+
const baseDraft = scope.drafts_[0];
|
|
32809
|
+
const isReplaced = result !== void 0 && result !== baseDraft;
|
|
32810
|
+
if (isReplaced) {
|
|
32811
|
+
if (baseDraft[DRAFT_STATE].modified_) {
|
|
32812
|
+
revokeScope(scope);
|
|
32813
|
+
die(4);
|
|
32814
|
+
}
|
|
32815
|
+
if (isDraftable(result)) {
|
|
32816
|
+
result = finalize(scope, result);
|
|
32817
|
+
if (!scope.parent_)
|
|
32818
|
+
maybeFreeze(scope, result);
|
|
32819
|
+
}
|
|
32820
|
+
if (scope.patches_) {
|
|
32821
|
+
getPlugin("Patches").generateReplacementPatches_(
|
|
32822
|
+
baseDraft[DRAFT_STATE].base_,
|
|
32823
|
+
result,
|
|
32824
|
+
scope.patches_,
|
|
32825
|
+
scope.inversePatches_
|
|
32826
|
+
);
|
|
32827
|
+
}
|
|
32828
|
+
} else {
|
|
32829
|
+
result = finalize(scope, baseDraft, []);
|
|
32830
|
+
}
|
|
32831
|
+
revokeScope(scope);
|
|
32832
|
+
if (scope.patches_) {
|
|
32833
|
+
scope.patchListener_(scope.patches_, scope.inversePatches_);
|
|
32834
|
+
}
|
|
32835
|
+
return result !== NOTHING ? result : void 0;
|
|
32836
|
+
}
|
|
32837
|
+
function finalize(rootScope, value, path) {
|
|
32838
|
+
if (isFrozen(value))
|
|
32839
|
+
return value;
|
|
32840
|
+
const useStrictIteration = rootScope.immer_.shouldUseStrictIteration();
|
|
32841
|
+
const state = value[DRAFT_STATE];
|
|
32842
|
+
if (!state) {
|
|
32843
|
+
each(
|
|
32844
|
+
value,
|
|
32845
|
+
(key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path),
|
|
32846
|
+
useStrictIteration
|
|
32847
|
+
);
|
|
32848
|
+
return value;
|
|
32849
|
+
}
|
|
32850
|
+
if (state.scope_ !== rootScope)
|
|
32851
|
+
return value;
|
|
32852
|
+
if (!state.modified_) {
|
|
32853
|
+
maybeFreeze(rootScope, state.base_, true);
|
|
32854
|
+
return state.base_;
|
|
32855
|
+
}
|
|
32856
|
+
if (!state.finalized_) {
|
|
32857
|
+
state.finalized_ = true;
|
|
32858
|
+
state.scope_.unfinalizedDrafts_--;
|
|
32859
|
+
const result = state.copy_;
|
|
32860
|
+
let resultEach = result;
|
|
32861
|
+
let isSet2 = false;
|
|
32862
|
+
if (state.type_ === 3 /* Set */) {
|
|
32863
|
+
resultEach = new Set(result);
|
|
32864
|
+
result.clear();
|
|
32865
|
+
isSet2 = true;
|
|
32866
|
+
}
|
|
32867
|
+
each(
|
|
32868
|
+
resultEach,
|
|
32869
|
+
(key, childValue) => finalizeProperty(
|
|
32870
|
+
rootScope,
|
|
32871
|
+
state,
|
|
32872
|
+
result,
|
|
32873
|
+
key,
|
|
32874
|
+
childValue,
|
|
32875
|
+
path,
|
|
32876
|
+
isSet2
|
|
32877
|
+
),
|
|
32878
|
+
useStrictIteration
|
|
32879
|
+
);
|
|
32880
|
+
maybeFreeze(rootScope, result, false);
|
|
32881
|
+
if (path && rootScope.patches_) {
|
|
32882
|
+
getPlugin("Patches").generatePatches_(
|
|
32883
|
+
state,
|
|
32884
|
+
path,
|
|
32885
|
+
rootScope.patches_,
|
|
32886
|
+
rootScope.inversePatches_
|
|
32887
|
+
);
|
|
32888
|
+
}
|
|
32889
|
+
}
|
|
32890
|
+
return state.copy_;
|
|
32891
|
+
}
|
|
32892
|
+
function finalizeProperty(rootScope, parentState, targetObject, prop, childValue, rootPath, targetIsSet) {
|
|
32893
|
+
if (childValue == null) {
|
|
32894
|
+
return;
|
|
32895
|
+
}
|
|
32896
|
+
if (typeof childValue !== "object" && !targetIsSet) {
|
|
32897
|
+
return;
|
|
32898
|
+
}
|
|
32899
|
+
const childIsFrozen = isFrozen(childValue);
|
|
32900
|
+
if (childIsFrozen && !targetIsSet) {
|
|
32901
|
+
return;
|
|
32902
|
+
}
|
|
32903
|
+
if (isDraft(childValue)) {
|
|
32904
|
+
const path = rootPath && parentState && parentState.type_ !== 3 /* Set */ && // Set objects are atomic since they have no keys.
|
|
32905
|
+
!has(parentState.assigned_, prop) ? rootPath.concat(prop) : void 0;
|
|
32906
|
+
const res = finalize(rootScope, childValue, path);
|
|
32907
|
+
set(targetObject, prop, res);
|
|
32908
|
+
if (isDraft(res)) {
|
|
32909
|
+
rootScope.canAutoFreeze_ = false;
|
|
32910
|
+
} else
|
|
32911
|
+
return;
|
|
32912
|
+
} else if (targetIsSet) {
|
|
32913
|
+
targetObject.add(childValue);
|
|
32914
|
+
}
|
|
32915
|
+
if (isDraftable(childValue) && !childIsFrozen) {
|
|
32916
|
+
if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
|
|
32917
|
+
return;
|
|
32918
|
+
}
|
|
32919
|
+
if (parentState && parentState.base_ && parentState.base_[prop] === childValue && childIsFrozen) {
|
|
32920
|
+
return;
|
|
32921
|
+
}
|
|
32922
|
+
finalize(rootScope, childValue);
|
|
32923
|
+
if ((!parentState || !parentState.scope_.parent_) && typeof prop !== "symbol" && (isMap(targetObject) ? targetObject.has(prop) : Object.prototype.propertyIsEnumerable.call(targetObject, prop)))
|
|
32924
|
+
maybeFreeze(rootScope, childValue);
|
|
32925
|
+
}
|
|
32926
|
+
}
|
|
32927
|
+
function maybeFreeze(scope, value, deep = false) {
|
|
32928
|
+
if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
|
|
32929
|
+
freeze(value, deep);
|
|
32930
|
+
}
|
|
32931
|
+
}
|
|
32932
|
+
|
|
32933
|
+
// src/core/proxy.ts
|
|
32934
|
+
function createProxyProxy(base, parent) {
|
|
32935
|
+
const isArray = Array.isArray(base);
|
|
32936
|
+
const state = {
|
|
32937
|
+
type_: isArray ? 1 /* Array */ : 0 /* Object */,
|
|
32938
|
+
// Track which produce call this is associated with.
|
|
32939
|
+
scope_: parent ? parent.scope_ : getCurrentScope(),
|
|
32940
|
+
// True for both shallow and deep changes.
|
|
32941
|
+
modified_: false,
|
|
32942
|
+
// Used during finalization.
|
|
32943
|
+
finalized_: false,
|
|
32944
|
+
// Track which properties have been assigned (true) or deleted (false).
|
|
32945
|
+
assigned_: {},
|
|
32946
|
+
// The parent draft state.
|
|
32947
|
+
parent_: parent,
|
|
32948
|
+
// The base state.
|
|
32949
|
+
base_: base,
|
|
32950
|
+
// The base proxy.
|
|
32951
|
+
draft_: null,
|
|
32952
|
+
// set below
|
|
32953
|
+
// The base copy with any updated values.
|
|
32954
|
+
copy_: null,
|
|
32955
|
+
// Called by the `produce` function.
|
|
32956
|
+
revoke_: null,
|
|
32957
|
+
isManual_: false
|
|
32958
|
+
};
|
|
32959
|
+
let target = state;
|
|
32960
|
+
let traps = objectTraps;
|
|
32961
|
+
if (isArray) {
|
|
32962
|
+
target = [state];
|
|
32963
|
+
traps = arrayTraps;
|
|
32964
|
+
}
|
|
32965
|
+
const { revoke, proxy } = Proxy.revocable(target, traps);
|
|
32966
|
+
state.draft_ = proxy;
|
|
32967
|
+
state.revoke_ = revoke;
|
|
32968
|
+
return proxy;
|
|
32969
|
+
}
|
|
32970
|
+
var objectTraps = {
|
|
32971
|
+
get(state, prop) {
|
|
32972
|
+
if (prop === DRAFT_STATE)
|
|
32973
|
+
return state;
|
|
32974
|
+
const source = latest(state);
|
|
32975
|
+
if (!has(source, prop)) {
|
|
32976
|
+
return readPropFromProto(state, source, prop);
|
|
32977
|
+
}
|
|
32978
|
+
const value = source[prop];
|
|
32979
|
+
if (state.finalized_ || !isDraftable(value)) {
|
|
32980
|
+
return value;
|
|
32981
|
+
}
|
|
32982
|
+
if (value === peek(state.base_, prop)) {
|
|
32983
|
+
prepareCopy(state);
|
|
32984
|
+
return state.copy_[prop] = createProxy(value, state);
|
|
32985
|
+
}
|
|
32986
|
+
return value;
|
|
32987
|
+
},
|
|
32988
|
+
has(state, prop) {
|
|
32989
|
+
return prop in latest(state);
|
|
32990
|
+
},
|
|
32991
|
+
ownKeys(state) {
|
|
32992
|
+
return Reflect.ownKeys(latest(state));
|
|
32993
|
+
},
|
|
32994
|
+
set(state, prop, value) {
|
|
32995
|
+
const desc = getDescriptorFromProto(latest(state), prop);
|
|
32996
|
+
if (desc?.set) {
|
|
32997
|
+
desc.set.call(state.draft_, value);
|
|
32998
|
+
return true;
|
|
32999
|
+
}
|
|
33000
|
+
if (!state.modified_) {
|
|
33001
|
+
const current2 = peek(latest(state), prop);
|
|
33002
|
+
const currentState = current2?.[DRAFT_STATE];
|
|
33003
|
+
if (currentState && currentState.base_ === value) {
|
|
33004
|
+
state.copy_[prop] = value;
|
|
33005
|
+
state.assigned_[prop] = false;
|
|
33006
|
+
return true;
|
|
33007
|
+
}
|
|
33008
|
+
if (is(value, current2) && (value !== void 0 || has(state.base_, prop)))
|
|
33009
|
+
return true;
|
|
33010
|
+
prepareCopy(state);
|
|
33011
|
+
markChanged(state);
|
|
33012
|
+
}
|
|
33013
|
+
if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
|
|
33014
|
+
(value !== void 0 || prop in state.copy_) || // special case: NaN
|
|
33015
|
+
Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
|
|
33016
|
+
return true;
|
|
33017
|
+
state.copy_[prop] = value;
|
|
33018
|
+
state.assigned_[prop] = true;
|
|
33019
|
+
return true;
|
|
33020
|
+
},
|
|
33021
|
+
deleteProperty(state, prop) {
|
|
33022
|
+
if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
|
|
33023
|
+
state.assigned_[prop] = false;
|
|
33024
|
+
prepareCopy(state);
|
|
33025
|
+
markChanged(state);
|
|
33026
|
+
} else {
|
|
33027
|
+
delete state.assigned_[prop];
|
|
33028
|
+
}
|
|
33029
|
+
if (state.copy_) {
|
|
33030
|
+
delete state.copy_[prop];
|
|
33031
|
+
}
|
|
33032
|
+
return true;
|
|
33033
|
+
},
|
|
33034
|
+
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
33035
|
+
// the same guarantee in ES5 mode.
|
|
33036
|
+
getOwnPropertyDescriptor(state, prop) {
|
|
33037
|
+
const owner = latest(state);
|
|
33038
|
+
const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
33039
|
+
if (!desc)
|
|
33040
|
+
return desc;
|
|
33041
|
+
return {
|
|
33042
|
+
writable: true,
|
|
33043
|
+
configurable: state.type_ !== 1 /* Array */ || prop !== "length",
|
|
33044
|
+
enumerable: desc.enumerable,
|
|
33045
|
+
value: owner[prop]
|
|
33046
|
+
};
|
|
33047
|
+
},
|
|
33048
|
+
defineProperty() {
|
|
33049
|
+
die(11);
|
|
33050
|
+
},
|
|
33051
|
+
getPrototypeOf(state) {
|
|
33052
|
+
return getPrototypeOf(state.base_);
|
|
33053
|
+
},
|
|
33054
|
+
setPrototypeOf() {
|
|
33055
|
+
die(12);
|
|
33056
|
+
}
|
|
33057
|
+
};
|
|
33058
|
+
var arrayTraps = {};
|
|
33059
|
+
each(objectTraps, (key, fn) => {
|
|
33060
|
+
arrayTraps[key] = function() {
|
|
33061
|
+
arguments[0] = arguments[0][0];
|
|
33062
|
+
return fn.apply(this, arguments);
|
|
33063
|
+
};
|
|
33064
|
+
});
|
|
33065
|
+
arrayTraps.deleteProperty = function(state, prop) {
|
|
33066
|
+
return arrayTraps.set.call(this, state, prop, void 0);
|
|
33067
|
+
};
|
|
33068
|
+
arrayTraps.set = function(state, prop, value) {
|
|
33069
|
+
return objectTraps.set.call(this, state[0], prop, value, state[0]);
|
|
33070
|
+
};
|
|
33071
|
+
function peek(draft, prop) {
|
|
33072
|
+
const state = draft[DRAFT_STATE];
|
|
33073
|
+
const source = state ? latest(state) : draft;
|
|
33074
|
+
return source[prop];
|
|
33075
|
+
}
|
|
33076
|
+
function readPropFromProto(state, source, prop) {
|
|
33077
|
+
const desc = getDescriptorFromProto(source, prop);
|
|
33078
|
+
return desc ? `value` in desc ? desc.value : (
|
|
33079
|
+
// This is a very special case, if the prop is a getter defined by the
|
|
33080
|
+
// prototype, we should invoke it with the draft as context!
|
|
33081
|
+
desc.get?.call(state.draft_)
|
|
33082
|
+
) : void 0;
|
|
33083
|
+
}
|
|
33084
|
+
function getDescriptorFromProto(source, prop) {
|
|
33085
|
+
if (!(prop in source))
|
|
33086
|
+
return void 0;
|
|
33087
|
+
let proto = getPrototypeOf(source);
|
|
33088
|
+
while (proto) {
|
|
33089
|
+
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
33090
|
+
if (desc)
|
|
33091
|
+
return desc;
|
|
33092
|
+
proto = getPrototypeOf(proto);
|
|
33093
|
+
}
|
|
33094
|
+
return void 0;
|
|
33095
|
+
}
|
|
33096
|
+
function markChanged(state) {
|
|
33097
|
+
if (!state.modified_) {
|
|
33098
|
+
state.modified_ = true;
|
|
33099
|
+
if (state.parent_) {
|
|
33100
|
+
markChanged(state.parent_);
|
|
33101
|
+
}
|
|
33102
|
+
}
|
|
33103
|
+
}
|
|
33104
|
+
function prepareCopy(state) {
|
|
33105
|
+
if (!state.copy_) {
|
|
33106
|
+
state.copy_ = shallowCopy(
|
|
33107
|
+
state.base_,
|
|
33108
|
+
state.scope_.immer_.useStrictShallowCopy_
|
|
33109
|
+
);
|
|
33110
|
+
}
|
|
33111
|
+
}
|
|
33112
|
+
|
|
33113
|
+
// src/core/immerClass.ts
|
|
33114
|
+
var Immer2 = class {
|
|
33115
|
+
constructor(config) {
|
|
33116
|
+
this.autoFreeze_ = true;
|
|
33117
|
+
this.useStrictShallowCopy_ = false;
|
|
33118
|
+
this.useStrictIteration_ = true;
|
|
33119
|
+
/**
|
|
33120
|
+
* The `produce` function takes a value and a "recipe function" (whose
|
|
33121
|
+
* return value often depends on the base state). The recipe function is
|
|
33122
|
+
* free to mutate its first argument however it wants. All mutations are
|
|
33123
|
+
* only ever applied to a __copy__ of the base state.
|
|
33124
|
+
*
|
|
33125
|
+
* Pass only a function to create a "curried producer" which relieves you
|
|
33126
|
+
* from passing the recipe function every time.
|
|
33127
|
+
*
|
|
33128
|
+
* Only plain objects and arrays are made mutable. All other objects are
|
|
33129
|
+
* considered uncopyable.
|
|
33130
|
+
*
|
|
33131
|
+
* Note: This function is __bound__ to its `Immer` instance.
|
|
33132
|
+
*
|
|
33133
|
+
* @param {any} base - the initial state
|
|
33134
|
+
* @param {Function} recipe - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
33135
|
+
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
33136
|
+
* @returns {any} a new state, or the initial state if nothing was modified
|
|
33137
|
+
*/
|
|
33138
|
+
this.produce = (base, recipe, patchListener) => {
|
|
33139
|
+
if (typeof base === "function" && typeof recipe !== "function") {
|
|
33140
|
+
const defaultBase = recipe;
|
|
33141
|
+
recipe = base;
|
|
33142
|
+
const self = this;
|
|
33143
|
+
return function curriedProduce(base2 = defaultBase, ...args) {
|
|
33144
|
+
return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
|
|
33145
|
+
};
|
|
33146
|
+
}
|
|
33147
|
+
if (typeof recipe !== "function")
|
|
33148
|
+
die(6);
|
|
33149
|
+
if (patchListener !== void 0 && typeof patchListener !== "function")
|
|
33150
|
+
die(7);
|
|
33151
|
+
let result;
|
|
33152
|
+
if (isDraftable(base)) {
|
|
33153
|
+
const scope = enterScope(this);
|
|
33154
|
+
const proxy = createProxy(base, void 0);
|
|
33155
|
+
let hasError = true;
|
|
33156
|
+
try {
|
|
33157
|
+
result = recipe(proxy);
|
|
33158
|
+
hasError = false;
|
|
33159
|
+
} finally {
|
|
33160
|
+
if (hasError)
|
|
33161
|
+
revokeScope(scope);
|
|
33162
|
+
else
|
|
33163
|
+
leaveScope(scope);
|
|
33164
|
+
}
|
|
33165
|
+
usePatchesInScope(scope, patchListener);
|
|
33166
|
+
return processResult(result, scope);
|
|
33167
|
+
} else if (!base || typeof base !== "object") {
|
|
33168
|
+
result = recipe(base);
|
|
33169
|
+
if (result === void 0)
|
|
33170
|
+
result = base;
|
|
33171
|
+
if (result === NOTHING)
|
|
33172
|
+
result = void 0;
|
|
33173
|
+
if (this.autoFreeze_)
|
|
33174
|
+
freeze(result, true);
|
|
33175
|
+
if (patchListener) {
|
|
33176
|
+
const p = [];
|
|
33177
|
+
const ip = [];
|
|
33178
|
+
getPlugin("Patches").generateReplacementPatches_(base, result, p, ip);
|
|
33179
|
+
patchListener(p, ip);
|
|
33180
|
+
}
|
|
33181
|
+
return result;
|
|
33182
|
+
} else
|
|
33183
|
+
die(1, base);
|
|
33184
|
+
};
|
|
33185
|
+
this.produceWithPatches = (base, recipe) => {
|
|
33186
|
+
if (typeof base === "function") {
|
|
33187
|
+
return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
|
|
33188
|
+
}
|
|
33189
|
+
let patches, inversePatches;
|
|
33190
|
+
const result = this.produce(base, recipe, (p, ip) => {
|
|
33191
|
+
patches = p;
|
|
33192
|
+
inversePatches = ip;
|
|
33193
|
+
});
|
|
33194
|
+
return [result, patches, inversePatches];
|
|
33195
|
+
};
|
|
33196
|
+
if (typeof config?.autoFreeze === "boolean")
|
|
33197
|
+
this.setAutoFreeze(config.autoFreeze);
|
|
33198
|
+
if (typeof config?.useStrictShallowCopy === "boolean")
|
|
33199
|
+
this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
33200
|
+
if (typeof config?.useStrictIteration === "boolean")
|
|
33201
|
+
this.setUseStrictIteration(config.useStrictIteration);
|
|
33202
|
+
}
|
|
33203
|
+
createDraft(base) {
|
|
33204
|
+
if (!isDraftable(base))
|
|
33205
|
+
die(8);
|
|
33206
|
+
if (isDraft(base))
|
|
33207
|
+
base = current(base);
|
|
33208
|
+
const scope = enterScope(this);
|
|
33209
|
+
const proxy = createProxy(base, void 0);
|
|
33210
|
+
proxy[DRAFT_STATE].isManual_ = true;
|
|
33211
|
+
leaveScope(scope);
|
|
33212
|
+
return proxy;
|
|
33213
|
+
}
|
|
33214
|
+
finishDraft(draft, patchListener) {
|
|
33215
|
+
const state = draft && draft[DRAFT_STATE];
|
|
33216
|
+
if (!state || !state.isManual_)
|
|
33217
|
+
die(9);
|
|
33218
|
+
const { scope_: scope } = state;
|
|
33219
|
+
usePatchesInScope(scope, patchListener);
|
|
33220
|
+
return processResult(void 0, scope);
|
|
33221
|
+
}
|
|
33222
|
+
/**
|
|
33223
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
33224
|
+
*
|
|
33225
|
+
* By default, auto-freezing is enabled.
|
|
33226
|
+
*/
|
|
33227
|
+
setAutoFreeze(value) {
|
|
33228
|
+
this.autoFreeze_ = value;
|
|
33229
|
+
}
|
|
33230
|
+
/**
|
|
33231
|
+
* Pass true to enable strict shallow copy.
|
|
33232
|
+
*
|
|
33233
|
+
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
33234
|
+
*/
|
|
33235
|
+
setUseStrictShallowCopy(value) {
|
|
33236
|
+
this.useStrictShallowCopy_ = value;
|
|
33237
|
+
}
|
|
33238
|
+
/**
|
|
33239
|
+
* Pass false to use faster iteration that skips non-enumerable properties
|
|
33240
|
+
* but still handles symbols for compatibility.
|
|
33241
|
+
*
|
|
33242
|
+
* By default, strict iteration is enabled (includes all own properties).
|
|
33243
|
+
*/
|
|
33244
|
+
setUseStrictIteration(value) {
|
|
33245
|
+
this.useStrictIteration_ = value;
|
|
33246
|
+
}
|
|
33247
|
+
shouldUseStrictIteration() {
|
|
33248
|
+
return this.useStrictIteration_;
|
|
33249
|
+
}
|
|
33250
|
+
applyPatches(base, patches) {
|
|
33251
|
+
let i;
|
|
33252
|
+
for (i = patches.length - 1; i >= 0; i--) {
|
|
33253
|
+
const patch = patches[i];
|
|
33254
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
33255
|
+
base = patch.value;
|
|
33256
|
+
break;
|
|
33257
|
+
}
|
|
33258
|
+
}
|
|
33259
|
+
if (i > -1) {
|
|
33260
|
+
patches = patches.slice(i + 1);
|
|
33261
|
+
}
|
|
33262
|
+
const applyPatchesImpl = getPlugin("Patches").applyPatches_;
|
|
33263
|
+
if (isDraft(base)) {
|
|
33264
|
+
return applyPatchesImpl(base, patches);
|
|
33265
|
+
}
|
|
33266
|
+
return this.produce(
|
|
33267
|
+
base,
|
|
33268
|
+
(draft) => applyPatchesImpl(draft, patches)
|
|
33269
|
+
);
|
|
33270
|
+
}
|
|
33271
|
+
};
|
|
33272
|
+
function createProxy(value, parent) {
|
|
33273
|
+
const draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent);
|
|
33274
|
+
const scope = parent ? parent.scope_ : getCurrentScope();
|
|
33275
|
+
scope.drafts_.push(draft);
|
|
33276
|
+
return draft;
|
|
33277
|
+
}
|
|
33278
|
+
|
|
33279
|
+
// src/core/current.ts
|
|
33280
|
+
function current(value) {
|
|
33281
|
+
if (!isDraft(value))
|
|
33282
|
+
die(10, value);
|
|
33283
|
+
return currentImpl(value);
|
|
33284
|
+
}
|
|
33285
|
+
function currentImpl(value) {
|
|
33286
|
+
if (!isDraftable(value) || isFrozen(value))
|
|
33287
|
+
return value;
|
|
33288
|
+
const state = value[DRAFT_STATE];
|
|
33289
|
+
let copy;
|
|
33290
|
+
let strict = true;
|
|
33291
|
+
if (state) {
|
|
33292
|
+
if (!state.modified_)
|
|
33293
|
+
return state.base_;
|
|
33294
|
+
state.finalized_ = true;
|
|
33295
|
+
copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
|
|
33296
|
+
strict = state.scope_.immer_.shouldUseStrictIteration();
|
|
33297
|
+
} else {
|
|
33298
|
+
copy = shallowCopy(value, true);
|
|
33299
|
+
}
|
|
33300
|
+
each(
|
|
33301
|
+
copy,
|
|
33302
|
+
(key, childValue) => {
|
|
33303
|
+
set(copy, key, currentImpl(childValue));
|
|
33304
|
+
},
|
|
33305
|
+
strict
|
|
33306
|
+
);
|
|
33307
|
+
if (state) {
|
|
33308
|
+
state.finalized_ = false;
|
|
33309
|
+
}
|
|
33310
|
+
return copy;
|
|
33311
|
+
}
|
|
33312
|
+
|
|
33313
|
+
// src/immer.ts
|
|
33314
|
+
var immer = new Immer2();
|
|
33315
|
+
immer.produce;
|
|
33316
|
+
var setUseStrictIteration = /* @__PURE__ */ immer.setUseStrictIteration.bind(
|
|
33317
|
+
immer
|
|
33318
|
+
);
|
|
33319
|
+
|
|
32413
33320
|
// src/index.ts
|
|
32414
33321
|
function createThunkMiddleware(extraArgument) {
|
|
32415
33322
|
const middleware = ({ dispatch, getState }) => (next) => (action) => {
|
|
@@ -32424,6 +33331,8 @@ var thunk = createThunkMiddleware();
|
|
|
32424
33331
|
var withExtraArgument = createThunkMiddleware;
|
|
32425
33332
|
|
|
32426
33333
|
// src/index.ts
|
|
33334
|
+
|
|
33335
|
+
// src/devtoolsExtension.ts
|
|
32427
33336
|
var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
|
|
32428
33337
|
if (arguments.length === 0) return void 0;
|
|
32429
33338
|
if (typeof arguments[0] === "object") return compose;
|
|
@@ -32554,7 +33463,7 @@ function configureStore(options) {
|
|
|
32554
33463
|
let rootReducer;
|
|
32555
33464
|
if (typeof reducer === "function") {
|
|
32556
33465
|
rootReducer = reducer;
|
|
32557
|
-
} else if (isPlainObject(reducer)) {
|
|
33466
|
+
} else if (isPlainObject$1(reducer)) {
|
|
32558
33467
|
rootReducer = combineReducers(reducer);
|
|
32559
33468
|
} else {
|
|
32560
33469
|
throw new Error(formatProdErrorMessage(1) );
|
|
@@ -32580,6 +33489,9 @@ function configureStore(options) {
|
|
|
32580
33489
|
return createStore(rootReducer, preloadedState, composedEnhancer);
|
|
32581
33490
|
}
|
|
32582
33491
|
|
|
33492
|
+
// src/createReducer.ts
|
|
33493
|
+
setUseStrictIteration(false);
|
|
33494
|
+
|
|
32583
33495
|
// src/formatProdErrorMessage.ts
|
|
32584
33496
|
function formatProdErrorMessage(code) {
|
|
32585
33497
|
return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
|
@@ -32744,11 +33656,26 @@ function memberJoin(state, detail) {
|
|
|
32744
33656
|
// }
|
|
32745
33657
|
var agents = __assign({}, state.agents);
|
|
32746
33658
|
var prevAgentInfo = state.agents[detail.user.nick];
|
|
32747
|
-
agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false });
|
|
33659
|
+
agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false, hideUserInfo: detail.hideUserInfo });
|
|
32748
33660
|
if (isAgent(detail.user.nick)) {
|
|
32749
|
-
|
|
33661
|
+
// Always show join messages with special visual features (divider or custom message)
|
|
33662
|
+
// These are important conversation markers, not routine join notifications
|
|
33663
|
+
var hasSpecialVisuals = detail.showDivider || detail.message;
|
|
33664
|
+
if ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) {
|
|
33665
|
+
log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already joined. NOT adding duplicate join message to chat."));
|
|
33666
|
+
}
|
|
33667
|
+
else {
|
|
33668
|
+
if (hasSpecialVisuals) {
|
|
33669
|
+
log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining with special visuals (divider or custom message). Adding join message to chat."));
|
|
33670
|
+
}
|
|
33671
|
+
else {
|
|
33672
|
+
log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
|
|
33673
|
+
}
|
|
33674
|
+
}
|
|
33675
|
+
return __assign(__assign({}, state), { isChatting: true, chats: ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) ? state.chats : joinMessages(state.chats, detail), agents: agents });
|
|
32750
33676
|
}
|
|
32751
33677
|
else {
|
|
33678
|
+
log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
|
|
32752
33679
|
return __assign(__assign({}, state), { isChatting: true, chats: joinMessages(state.chats, detail), agents: agents });
|
|
32753
33680
|
}
|
|
32754
33681
|
}
|
|
@@ -32761,25 +33688,51 @@ function memberLeave(state, detail) {
|
|
|
32761
33688
|
var agentsJoined = Object.values(agents).filter(function (agent) { return agent.joined; });
|
|
32762
33689
|
var isChatting = agentsJoined.length > 0;
|
|
32763
33690
|
if (isAgent(detail.user.nick)) {
|
|
33691
|
+
var hasSpecialVisuals = detail.showDivider || detail.message;
|
|
33692
|
+
if (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) {
|
|
33693
|
+
if (hasSpecialVisuals) {
|
|
33694
|
+
log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving with special visuals (divider or custom message). Adding leave message to chat."));
|
|
33695
|
+
}
|
|
33696
|
+
else {
|
|
33697
|
+
log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
|
|
33698
|
+
}
|
|
33699
|
+
}
|
|
33700
|
+
else {
|
|
33701
|
+
log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already left. NOT adding duplicate leave message to chat."));
|
|
33702
|
+
}
|
|
32764
33703
|
return __assign(__assign({}, state), { isChatting: isChatting, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? joinMessages(state.chats, detail) : state.chats, agents: agents });
|
|
32765
33704
|
}
|
|
32766
33705
|
else {
|
|
33706
|
+
log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
|
|
32767
33707
|
return __assign(__assign({}, state), { isChatting: isChatting, chats: joinMessages(state.chats, detail), agents: agents });
|
|
32768
33708
|
}
|
|
32769
33709
|
}
|
|
32770
33710
|
|
|
32771
33711
|
function resetReducer(state) {
|
|
32772
33712
|
if (state === void 0) { state = DEFAULT_STATE; }
|
|
32773
|
-
|
|
33713
|
+
var defaultState = createDefaultState({
|
|
32774
33714
|
accessToken: state.accessToken,
|
|
32775
33715
|
userId: state.userId,
|
|
32776
33716
|
attributes: state.attributes,
|
|
32777
33717
|
sessionExpiration: state.sessionExpiration
|
|
32778
|
-
})
|
|
33718
|
+
});
|
|
33719
|
+
// If we have an active connection, preserve status to avoid showing offline during reconnect
|
|
33720
|
+
var wasOnline = state.connection.connectionStatus === 'online';
|
|
33721
|
+
return __assign(__assign({}, defaultState), { connection: __assign(__assign({}, defaultState.connection), { greetingRequested: false,
|
|
33722
|
+
// Generate new nonce to trigger server recreation and start fresh session
|
|
33723
|
+
nonce: uuid_1(),
|
|
33724
|
+
// Preserve connection status during transition if we were online
|
|
33725
|
+
connectionStatus: wasOnline ? 'online' : defaultState.connection.connectionStatus }),
|
|
33726
|
+
// Preserve accountStatus if we were online to avoid showing offline message during reconnect
|
|
33727
|
+
accountStatus: wasOnline ? 'online' : defaultState.accountStatus, visitor: state.visitor, visitorId: state.visitorId,
|
|
32779
33728
|
// Explicitly reset visuals to clear hasInteracted flag for widget refresh
|
|
32780
33729
|
visuals: {} });
|
|
32781
33730
|
}
|
|
32782
33731
|
|
|
33732
|
+
// Type guard for ChatSystemMessageDetail
|
|
33733
|
+
function isChatSystemMessage(chat) {
|
|
33734
|
+
return chat.type === "chat.systemmessage";
|
|
33735
|
+
}
|
|
32783
33736
|
// todo: create reducer (requires redux-thunk dependency)
|
|
32784
33737
|
function appendMessageToState(state, msg) {
|
|
32785
33738
|
state.chats = joinMessages(state.chats, msg);
|
|
@@ -32789,7 +33742,7 @@ function appendMessageToState(state, msg) {
|
|
|
32789
33742
|
}
|
|
32790
33743
|
function update(state, action) {
|
|
32791
33744
|
var _a, _b, _c, _d;
|
|
32792
|
-
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
33745
|
+
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
32793
33746
|
if (state === void 0) { state = DEFAULT_STATE; }
|
|
32794
33747
|
log("action", action);
|
|
32795
33748
|
if (action.type === "reset") {
|
|
@@ -32818,21 +33771,50 @@ function update(state, action) {
|
|
|
32818
33771
|
window.localStorage.setItem('xaErrorOverlay', newDebugMode ? 'enabled' : 'disabled');
|
|
32819
33772
|
}
|
|
32820
33773
|
return __assign(__assign({}, state), { debugMode: newDebugMode });
|
|
33774
|
+
case "ws_button_display":
|
|
33775
|
+
return __assign(__assign({}, state), { lastTimestamp: (_j = action.detail) === null || _j === void 0 ? void 0 : _j.timestamp, wsButton: {
|
|
33776
|
+
id: action.detail.id,
|
|
33777
|
+
// Preserve existing text if new text is empty (e.g., during dismiss animation)
|
|
33778
|
+
text: action.detail.text || ((_k = state.wsButton) === null || _k === void 0 ? void 0 : _k.text) || '',
|
|
33779
|
+
pressBehavior: action.detail.pressBehavior,
|
|
33780
|
+
isPressed: (_l = action.detail.isPressed) !== null && _l !== void 0 ? _l : false,
|
|
33781
|
+
isDismissing: (_m = action.detail.isDismissing) !== null && _m !== void 0 ? _m : false
|
|
33782
|
+
} });
|
|
33783
|
+
case "ws_button_dismiss":
|
|
33784
|
+
// Only dismiss if the id matches
|
|
33785
|
+
if (((_o = state.wsButton) === null || _o === void 0 ? void 0 : _o.id) === action.detail.id) {
|
|
33786
|
+
return __assign(__assign({}, state), { lastTimestamp: (_p = action.detail) === null || _p === void 0 ? void 0 : _p.timestamp, wsButton: undefined });
|
|
33787
|
+
}
|
|
33788
|
+
return state;
|
|
32821
33789
|
case "department_update":
|
|
32822
|
-
return __assign(__assign({}, state), { lastTimestamp: (
|
|
33790
|
+
return __assign(__assign({}, state), { lastTimestamp: (_q = action.detail) === null || _q === void 0 ? void 0 : _q.timestamp, departments: __assign(__assign({}, state.departments), (_a = {}, _a[action.detail.id] = __assign({}, action.detail), _a)) });
|
|
32823
33791
|
case "visitor_update":
|
|
32824
|
-
return __assign(__assign({}, state), { lastTimestamp: (
|
|
33792
|
+
return __assign(__assign({}, state), { lastTimestamp: (_r = action.detail) === null || _r === void 0 ? void 0 : _r.timestamp, visitor: __assign(__assign({}, state.visitor), action.detail) });
|
|
32825
33793
|
case "agent_update":
|
|
32826
33794
|
var prevUpdateAgent = state.agents[action.detail.nick];
|
|
32827
|
-
return __assign(__assign({}, state), { lastTimestamp: (
|
|
33795
|
+
return __assign(__assign({}, state), { lastTimestamp: (_s = action.detail) === null || _s === void 0 ? void 0 : _s.timestamp, agents: __assign(__assign({}, state.agents), (_b = {}, _b[action.detail.nick] = __assign(__assign({}, prevUpdateAgent), { user: __assign(__assign({}, prevUpdateAgent.user), action.detail), typing: (prevUpdateAgent || { typing: false }).typing // if we had it - keep it
|
|
32828
33796
|
}), _b)) });
|
|
32829
33797
|
case "chat":
|
|
32830
|
-
var newState = __assign(__assign({}, state), { lastTimestamp: (
|
|
33798
|
+
var newState = __assign(__assign({}, state), { lastTimestamp: (_t = action.detail) === null || _t === void 0 ? void 0 : _t.timestamp });
|
|
32831
33799
|
switch (action.detail.type) {
|
|
32832
33800
|
case "chat.memberjoin":
|
|
32833
33801
|
return memberJoin(state, action.detail);
|
|
32834
33802
|
case "chat.memberleave":
|
|
32835
33803
|
return memberLeave(state, action.detail);
|
|
33804
|
+
case "chat.systemmessage":
|
|
33805
|
+
// Add the system message to the chat
|
|
33806
|
+
appendMessageToState(newState, action.detail);
|
|
33807
|
+
return newState;
|
|
33808
|
+
case "chat.systemmessagedismiss":
|
|
33809
|
+
// Remove system message(s) with the specified id
|
|
33810
|
+
var dismissId_1 = action.detail.id;
|
|
33811
|
+
return __assign(__assign({}, newState), { chats: newState.chats.filter(function (chat) {
|
|
33812
|
+
// Keep all non-system messages, and system messages that don't match the id
|
|
33813
|
+
if (isChatSystemMessage(chat)) {
|
|
33814
|
+
return chat.id !== dismissId_1;
|
|
33815
|
+
}
|
|
33816
|
+
return true;
|
|
33817
|
+
}) });
|
|
32836
33818
|
case "chat.queue.position":
|
|
32837
33819
|
newState.queuePosition = action.detail.queuePosition;
|
|
32838
33820
|
return newState;
|
|
@@ -32847,7 +33829,7 @@ function update(state, action) {
|
|
|
32847
33829
|
appendMessageToState(newState, action.detail);
|
|
32848
33830
|
var detail = action.detail;
|
|
32849
33831
|
var msg = detail.type === "chat.msg" ? detail.msg : null;
|
|
32850
|
-
newState.chips = ((
|
|
33832
|
+
newState.chips = ((_u = msg === null || msg === void 0 ? void 0 : msg.options) === null || _u === void 0 ? void 0 : _u.length) ? msg.options : [];
|
|
32851
33833
|
return newState;
|
|
32852
33834
|
case "chat.failureMsg":
|
|
32853
33835
|
var agentDetails = newState.agents[action.detail.user.nick];
|
|
@@ -32867,7 +33849,7 @@ function update(state, action) {
|
|
|
32867
33849
|
return __assign(__assign({}, finalState), { agents: __assign(__assign({}, finalState.agents), (_c = {}, _c[action.detail.user.nick] = __assign(__assign({}, agentDetails), { typing: false, requestFailed: true }), _c)), failureMsg: action.detail.failureMsg });
|
|
32868
33850
|
case "chat.typing":
|
|
32869
33851
|
var agent = state.agents[action.detail.user.nick];
|
|
32870
|
-
return __assign(__assign({}, state), { lastTimestamp: (
|
|
33852
|
+
return __assign(__assign({}, state), { lastTimestamp: (_v = action.detail) === null || _v === void 0 ? void 0 : _v.timestamp, agents: __assign(__assign({}, state.agents), (_d = {}, _d[action.detail.user.nick] = __assign(__assign({}, agent), { typing: action.detail.typing }), _d)) });
|
|
32871
33853
|
default:
|
|
32872
33854
|
return state;
|
|
32873
33855
|
}
|
|
@@ -33012,7 +33994,7 @@ var ChatWidgetContainer = function (props) {
|
|
|
33012
33994
|
var _a, _b, _c, _d, _e, _f;
|
|
33013
33995
|
var messageMiddleware = useStandardMiddleware();
|
|
33014
33996
|
var connection = useServerConfig(props.config);
|
|
33015
|
-
var chatStore =
|
|
33997
|
+
var chatStore = require$$1.useMemo(function () {
|
|
33016
33998
|
var _a, _b, _c, _d, _e;
|
|
33017
33999
|
return createChatStore({
|
|
33018
34000
|
connection: connection,
|
|
@@ -33024,12 +34006,11 @@ var ChatWidgetContainer = function (props) {
|
|
|
33024
34006
|
});
|
|
33025
34007
|
}, [connection, (_a = props.config) === null || _a === void 0 ? void 0 : _a.userId, (_b = props.config) === null || _b === void 0 ? void 0 : _b.accessToken, (_c = props.config) === null || _c === void 0 ? void 0 : _c.attributes, (_d = props.config) === null || _d === void 0 ? void 0 : _d.sessionExpiration, (_e = props.config) === null || _e === void 0 ? void 0 : _e.enableErrorOverlay]);
|
|
33026
34008
|
if ((_f = props.config) === null || _f === void 0 ? void 0 : _f.disabled) {
|
|
33027
|
-
return
|
|
34009
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
33028
34010
|
}
|
|
33029
34011
|
var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware, getConfig: props.getConfig // Pass through getConfig callback
|
|
33030
34012
|
});
|
|
33031
|
-
return (
|
|
33032
|
-
React$1.createElement(ChatWidgetWrapper, __assign({}, widgetProps))));
|
|
34013
|
+
return (require$$0.jsx(reactRedux.Provider, { store: chatStore, children: require$$0.jsx(ChatWidgetWrapper, __assign({}, widgetProps)) }));
|
|
33033
34014
|
};
|
|
33034
34015
|
|
|
33035
34016
|
// Function to create a static reducer
|
|
@@ -33057,17 +34038,16 @@ function createStaticStore(state) {
|
|
|
33057
34038
|
|
|
33058
34039
|
var StaticChatWidgetContainer = function (props) {
|
|
33059
34040
|
var state = props.state;
|
|
33060
|
-
var store =
|
|
34041
|
+
var store = require$$1.useMemo(function () {
|
|
33061
34042
|
return createStaticStore(state);
|
|
33062
34043
|
}, [state]);
|
|
33063
|
-
var config =
|
|
34044
|
+
var config = require$$1.useMemo(function () {
|
|
33064
34045
|
return __assign(__assign({}, props.config), { connection: {
|
|
33065
34046
|
serverUrl: "",
|
|
33066
|
-
type: "local"
|
|
34047
|
+
type: "local",
|
|
33067
34048
|
} });
|
|
33068
34049
|
}, [props.config]);
|
|
33069
|
-
return (
|
|
33070
|
-
React$1.createElement(ChatWidgetWrapper, __assign({}, props, { config: config }))));
|
|
34050
|
+
return (require$$0.jsx(reactRedux.Provider, { store: store, children: require$$0.jsx(ChatWidgetWrapper, __assign({}, props, { config: config })) }));
|
|
33071
34051
|
};
|
|
33072
34052
|
|
|
33073
34053
|
function createStateFromMessages(messages) {
|
|
@@ -33077,13 +34057,13 @@ function createStateFromMessages(messages) {
|
|
|
33077
34057
|
|
|
33078
34058
|
var StaticMessagesChatWidgetContainer = function (props) {
|
|
33079
34059
|
var messages = props.messages;
|
|
33080
|
-
var state =
|
|
34060
|
+
var state = require$$1.useMemo(function () {
|
|
33081
34061
|
return createStateFromMessages(messages);
|
|
33082
34062
|
}, [messages]);
|
|
33083
|
-
return
|
|
34063
|
+
return require$$0.jsx(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config });
|
|
33084
34064
|
};
|
|
33085
34065
|
|
|
33086
|
-
exports.React =
|
|
34066
|
+
exports.React = require$$1;
|
|
33087
34067
|
exports.ActionButton = ActionButton;
|
|
33088
34068
|
exports.Avatar = Avatar;
|
|
33089
34069
|
exports.CardMiddleware = CardMiddleware;
|