@xapp/chat-widget 1.94.0 → 1.94.1
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/WidgetStylesheet/WidgetStylesheet.d.ts +0 -0
- package/dist/index.css +1 -1
- package/dist/index.es.js +62 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +267 -219
- package/dist/index.js.map +1 -1
- package/dist/xapp-chat-widget.js +4 -4
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
var require$$0 = require('react/jsx-runtime');
|
|
5
5
|
var reactRedux = require('react-redux');
|
|
6
6
|
|
|
@@ -234,7 +234,7 @@ var defaultLabels = {
|
|
|
234
234
|
var ActionBarButton = function (_a) {
|
|
235
235
|
var _b;
|
|
236
236
|
var button = _a.button, chatActive = _a.chatActive, onChatClick = _a.onChatClick, onChatMinimize = _a.onChatMinimize, onFormClick = _a.onFormClick, isMobile = _a.isMobile;
|
|
237
|
-
var handleClick =
|
|
237
|
+
var handleClick = React.useCallback(function () {
|
|
238
238
|
if (lib.isActionBarChatButton(button)) {
|
|
239
239
|
// Toggle chat: if active, minimize; if not active, open
|
|
240
240
|
if (chatActive) {
|
|
@@ -311,9 +311,9 @@ var ActionBarButton = function (_a) {
|
|
|
311
311
|
var ActionBarCta = function (_a) {
|
|
312
312
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
313
313
|
var config = _a.config, isMobile = _a.isMobile, onClick = _a.onClick, onDismiss = _a.onDismiss, hasUserInteracted = _a.hasUserInteracted;
|
|
314
|
-
var _m =
|
|
315
|
-
var _o =
|
|
316
|
-
var _p =
|
|
314
|
+
var _m = React.useState(false), isVisible = _m[0], setIsVisible = _m[1];
|
|
315
|
+
var _o = React.useState(false), isAnimating = _o[0], setIsAnimating = _o[1];
|
|
316
|
+
var _p = React.useState(false), isDismissed = _p[0], setIsDismissed = _p[1];
|
|
317
317
|
// For mobile overrides: null means "explicitly disabled", undefined means "use desktop default"
|
|
318
318
|
var mobileMessage = isMobile ? (_b = config.mobile) === null || _b === void 0 ? void 0 : _b.message : undefined;
|
|
319
319
|
var message = mobileMessage !== undefined ? mobileMessage : config.message;
|
|
@@ -332,7 +332,7 @@ var ActionBarCta = function (_a) {
|
|
|
332
332
|
? config.mobile.dismissible
|
|
333
333
|
: ((_l = config.dismissible) !== null && _l !== void 0 ? _l : true);
|
|
334
334
|
// Show CTA after delay
|
|
335
|
-
|
|
335
|
+
React.useEffect(function () {
|
|
336
336
|
if (!message || hasUserInteracted || isDismissed) {
|
|
337
337
|
setIsVisible(false);
|
|
338
338
|
return undefined;
|
|
@@ -343,7 +343,7 @@ var ActionBarCta = function (_a) {
|
|
|
343
343
|
return function () { return clearTimeout(showTimer); };
|
|
344
344
|
}, [message, delay, hasUserInteracted, isDismissed]);
|
|
345
345
|
// Hide CTA after timeout
|
|
346
|
-
|
|
346
|
+
React.useEffect(function () {
|
|
347
347
|
if (!isVisible || !timeout) {
|
|
348
348
|
return undefined;
|
|
349
349
|
}
|
|
@@ -353,7 +353,7 @@ var ActionBarCta = function (_a) {
|
|
|
353
353
|
return function () { return clearTimeout(hideTimer); };
|
|
354
354
|
}, [isVisible, timeout]);
|
|
355
355
|
// Start animation after animationDelay
|
|
356
|
-
|
|
356
|
+
React.useEffect(function () {
|
|
357
357
|
if (!animation || hasUserInteracted || isDismissed) {
|
|
358
358
|
setIsAnimating(false);
|
|
359
359
|
return undefined;
|
|
@@ -364,7 +364,7 @@ var ActionBarCta = function (_a) {
|
|
|
364
364
|
return function () { return clearTimeout(animateTimer); };
|
|
365
365
|
}, [animation, animationDelay, hasUserInteracted, isDismissed]);
|
|
366
366
|
// Stop animation after animationTimeout
|
|
367
|
-
|
|
367
|
+
React.useEffect(function () {
|
|
368
368
|
if (!isAnimating || !animationTimeout) {
|
|
369
369
|
return undefined;
|
|
370
370
|
}
|
|
@@ -400,12 +400,12 @@ var RESIZE_DEBOUNCE_MS = 150;
|
|
|
400
400
|
var ActionBar = function (_a) {
|
|
401
401
|
var _b, _c, _d;
|
|
402
402
|
var config = _a.config, visible = _a.visible, chatDisabled = _a.chatDisabled, _e = _a.hasUserInteracted, hasUserInteracted = _e === void 0 ? false : _e, onChatClick = _a.onChatClick, onChatMinimize = _a.onChatMinimize, onFormClick = _a.onFormClick, onCtaDismiss = _a.onCtaDismiss;
|
|
403
|
-
var _f =
|
|
403
|
+
var _f = React.useState(false), isMobile = _f[0], setIsMobile = _f[1];
|
|
404
404
|
var mobileBreakpoint = (_b = config.mobileBreakpoint) !== null && _b !== void 0 ? _b : DEFAULT_MOBILE_BREAKPOINT;
|
|
405
405
|
var position = (_c = config.position) !== null && _c !== void 0 ? _c : "right";
|
|
406
|
-
var resizeTimeoutRef =
|
|
406
|
+
var resizeTimeoutRef = React.useRef(null);
|
|
407
407
|
// Debounced resize handler
|
|
408
|
-
var handleResize =
|
|
408
|
+
var handleResize = React.useCallback(function () {
|
|
409
409
|
if (resizeTimeoutRef.current) {
|
|
410
410
|
window.clearTimeout(resizeTimeoutRef.current);
|
|
411
411
|
}
|
|
@@ -413,7 +413,7 @@ var ActionBar = function (_a) {
|
|
|
413
413
|
setIsMobile(window.innerWidth <= mobileBreakpoint);
|
|
414
414
|
}, RESIZE_DEBOUNCE_MS);
|
|
415
415
|
}, [mobileBreakpoint]);
|
|
416
|
-
|
|
416
|
+
React.useEffect(function () {
|
|
417
417
|
// Initial check (immediate, not debounced)
|
|
418
418
|
setIsMobile(window.innerWidth <= mobileBreakpoint);
|
|
419
419
|
window.addEventListener("resize", handleResize);
|
|
@@ -477,13 +477,13 @@ var ActionBar = function (_a) {
|
|
|
477
477
|
var ActionBarPreview = function (_a) {
|
|
478
478
|
var config = _a.config, _b = _a.chatActive, chatActive = _b === void 0 ? false : _b;
|
|
479
479
|
// No-op handlers for preview mode
|
|
480
|
-
var handleChatClick =
|
|
480
|
+
var handleChatClick = React.useCallback(function () {
|
|
481
481
|
// Preview only - no action
|
|
482
482
|
}, []);
|
|
483
|
-
var handleChatMinimize =
|
|
483
|
+
var handleChatMinimize = React.useCallback(function () {
|
|
484
484
|
// Preview only - no action
|
|
485
485
|
}, []);
|
|
486
|
-
var handleFormClick =
|
|
486
|
+
var handleFormClick = React.useCallback(function (_button) {
|
|
487
487
|
// Preview only - no action
|
|
488
488
|
}, []);
|
|
489
489
|
return (require$$0.jsx(ActionBar, { config: config, visible: chatActive, chatDisabled: false, onChatClick: handleChatClick, onChatMinimize: handleChatMinimize, onFormClick: handleFormClick }));
|
|
@@ -689,14 +689,14 @@ function isAgent(nick) {
|
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
function useIsMounted() {
|
|
692
|
-
var ref =
|
|
693
|
-
|
|
692
|
+
var ref = React.useRef(false);
|
|
693
|
+
React.useEffect(function () {
|
|
694
694
|
ref.current = true;
|
|
695
695
|
return function () {
|
|
696
696
|
ref.current = false;
|
|
697
697
|
};
|
|
698
698
|
}, []);
|
|
699
|
-
return
|
|
699
|
+
return React.useCallback(function () { return ref.current; }, []);
|
|
700
700
|
}
|
|
701
701
|
|
|
702
702
|
var RetryOptions = /** @class */ (function () {
|
|
@@ -1064,9 +1064,9 @@ var defaultWidgetButtonWidth = "48";
|
|
|
1064
1064
|
var defaultMobileWidgetButtonWidth = "30";
|
|
1065
1065
|
var defaultNonMobileScreenWidth = "400";
|
|
1066
1066
|
var scheduleWidgetUrl = "ScheduleButton";
|
|
1067
|
-
var ChatConfigContext =
|
|
1067
|
+
var ChatConfigContext = React.createContext(null);
|
|
1068
1068
|
function useWidgetEnv() {
|
|
1069
|
-
var ctx =
|
|
1069
|
+
var ctx = React.useContext(ChatConfigContext);
|
|
1070
1070
|
return ctx === null || ctx === void 0 ? void 0 : ctx.env;
|
|
1071
1071
|
}
|
|
1072
1072
|
function getServerConfig(env) {
|
|
@@ -1085,7 +1085,7 @@ function useServerConfig(env, nonce) {
|
|
|
1085
1085
|
// channelId lives at the WidgetEnv level; fold it into the mcp config so MCPChat
|
|
1086
1086
|
// can send it for event/lead attribution.
|
|
1087
1087
|
var channelId = env === null || env === void 0 ? void 0 : env.channelId;
|
|
1088
|
-
return
|
|
1088
|
+
return React.useMemo(function () { return ({
|
|
1089
1089
|
accountKey: accountKey,
|
|
1090
1090
|
serverUrl: serverUrl,
|
|
1091
1091
|
timeout: timeout,
|
|
@@ -1115,7 +1115,7 @@ var Avatar = function (props) {
|
|
|
1115
1115
|
var style = {};
|
|
1116
1116
|
var child;
|
|
1117
1117
|
var entity = props.entity;
|
|
1118
|
-
var chatConfig =
|
|
1118
|
+
var chatConfig = React.useContext(ChatConfigContext);
|
|
1119
1119
|
var avatarPath = entity === null || entity === void 0 ? void 0 : entity.avatarPath;
|
|
1120
1120
|
if (!avatarPath) {
|
|
1121
1121
|
var avatarImage = GenerateAvatar({
|
|
@@ -1150,7 +1150,7 @@ function GenerateAvatar(props) {
|
|
|
1150
1150
|
var size = (props === null || props === void 0 ? void 0 : props.size) || 40;
|
|
1151
1151
|
var backgroundColor = (props === null || props === void 0 ? void 0 : props.backgroundColor) || "#007bff";
|
|
1152
1152
|
var textColor = (props === null || props === void 0 ? void 0 : props.textColor) || "#ffffff";
|
|
1153
|
-
var image =
|
|
1153
|
+
var image = React.useMemo(function () {
|
|
1154
1154
|
return generateImage(initials, size, backgroundColor, textColor);
|
|
1155
1155
|
}, [initials, size, backgroundColor, textColor]);
|
|
1156
1156
|
return image;
|
|
@@ -1194,7 +1194,7 @@ var OptionalLink = function (props) {
|
|
|
1194
1194
|
var chatDispatch = useChatDispatch();
|
|
1195
1195
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
1196
1196
|
var url = props.url, className = props.className, onOpen = props.onOpen;
|
|
1197
|
-
var handleOpenUrl =
|
|
1197
|
+
var handleOpenUrl = React.useCallback(function () {
|
|
1198
1198
|
if (onOpen) {
|
|
1199
1199
|
onOpen(url, chatDispatch, visuals);
|
|
1200
1200
|
}
|
|
@@ -1211,7 +1211,7 @@ var ActionItem = function (props) {
|
|
|
1211
1211
|
var _a;
|
|
1212
1212
|
var item = props.item, onButtonClick = props.onButtonClick, onExecute = props.onExecute;
|
|
1213
1213
|
var singleButton = ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) === 1;
|
|
1214
|
-
var handleClick =
|
|
1214
|
+
var handleClick = React.useCallback(function () {
|
|
1215
1215
|
var _a;
|
|
1216
1216
|
var btns = (_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length;
|
|
1217
1217
|
// If there is only one button, it takes precedent
|
|
@@ -1255,19 +1255,19 @@ var ActionItemImage = function (props) {
|
|
|
1255
1255
|
|
|
1256
1256
|
var ChatActionButtonInner = function (props) {
|
|
1257
1257
|
var button = props.button, onClick = props.onClick;
|
|
1258
|
-
var handleButton =
|
|
1258
|
+
var handleButton = React.useCallback(function () {
|
|
1259
1259
|
onClick(button);
|
|
1260
1260
|
}, [button, onClick]);
|
|
1261
1261
|
return require$$0.jsx(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label });
|
|
1262
1262
|
};
|
|
1263
|
-
var ChatActionButton =
|
|
1263
|
+
var ChatActionButton = React.memo(ChatActionButtonInner);
|
|
1264
1264
|
|
|
1265
1265
|
var ChatActionButtonsInner = function (props) {
|
|
1266
1266
|
return (require$$0.jsx("div", { className: "buttons-container " + (props.className || ""), children: props.buttons.map(function (button, i) {
|
|
1267
1267
|
return require$$0.jsx(ChatActionButton, { button: button, onClick: props.onClick }, i);
|
|
1268
1268
|
}) }));
|
|
1269
1269
|
};
|
|
1270
|
-
var ChatActionButtons =
|
|
1270
|
+
var ChatActionButtons = React.memo(ChatActionButtonsInner);
|
|
1271
1271
|
|
|
1272
1272
|
var CarouselItem = function (props) {
|
|
1273
1273
|
var _a;
|
|
@@ -1290,8 +1290,8 @@ var ChevronRight = function (props) {
|
|
|
1290
1290
|
};
|
|
1291
1291
|
|
|
1292
1292
|
var Carousel = function (props) {
|
|
1293
|
-
var listRef =
|
|
1294
|
-
var _a =
|
|
1293
|
+
var listRef = React.useRef(null);
|
|
1294
|
+
var _a = React.useState(0), visibleIndex = _a[0], setSetVisibleIndex = _a[1];
|
|
1295
1295
|
function scrollMe(direction) {
|
|
1296
1296
|
var _a, _b;
|
|
1297
1297
|
var scrollArea = listRef.current;
|
|
@@ -1331,9 +1331,9 @@ var Carousel = function (props) {
|
|
|
1331
1331
|
};
|
|
1332
1332
|
|
|
1333
1333
|
function useDimensions() {
|
|
1334
|
-
var ref =
|
|
1335
|
-
var _a =
|
|
1336
|
-
|
|
1334
|
+
var ref = React.useRef(null);
|
|
1335
|
+
var _a = React.useState(), dimensions = _a[0], setDimensions = _a[1];
|
|
1336
|
+
React.useLayoutEffect(function () {
|
|
1337
1337
|
var _a, _b;
|
|
1338
1338
|
setDimensions((_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.toJSON());
|
|
1339
1339
|
}, []);
|
|
@@ -1466,14 +1466,14 @@ var CtaBubbleContainer = function (props) {
|
|
|
1466
1466
|
hasChildren: !!children,
|
|
1467
1467
|
childrenContent: children,
|
|
1468
1468
|
});
|
|
1469
|
-
var startTime =
|
|
1469
|
+
var startTime = React.useMemo(function () {
|
|
1470
1470
|
var time = visible ? new Date().valueOf() : undefined;
|
|
1471
1471
|
log("[CtaBubbleContainer] StartTime calculated: visible=".concat(visible, ", startTime=").concat(time));
|
|
1472
1472
|
return time;
|
|
1473
1473
|
}, [visible]);
|
|
1474
|
-
var _a =
|
|
1474
|
+
var _a = React.useState(false), showBubble = _a[0], setShowBubble = _a[1];
|
|
1475
1475
|
log("[CtaBubbleContainer] Current state: showBubble=".concat(showBubble));
|
|
1476
|
-
|
|
1476
|
+
React.useEffect(function () {
|
|
1477
1477
|
log("[CtaBubbleContainer] useEffect triggered with:", {
|
|
1478
1478
|
startTime: startTime,
|
|
1479
1479
|
startTimeExists: !!startTime,
|
|
@@ -1549,8 +1549,8 @@ var CtaBubbleContainer = function (props) {
|
|
|
1549
1549
|
var ChatButton = function (_a) {
|
|
1550
1550
|
var _b;
|
|
1551
1551
|
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;
|
|
1552
|
-
var _c =
|
|
1553
|
-
var _d =
|
|
1552
|
+
var _c = React.useState(defaultWidgetButtonWidth), buttonWidth = _c[0], setButtonWidth = _c[1];
|
|
1553
|
+
var _d = React.useState(false), animate = _d[0], setAnimate = _d[1];
|
|
1554
1554
|
var mobileWidth = ((_b = config === null || config === void 0 ? void 0 : config.mobile) === null || _b === void 0 ? void 0 : _b.applyAtLessThanWidth) || defaultNonMobileScreenWidth;
|
|
1555
1555
|
// Determines mobile or normal
|
|
1556
1556
|
var getConfigToApply = function () {
|
|
@@ -1563,7 +1563,7 @@ var ChatButton = function (_a) {
|
|
|
1563
1563
|
}
|
|
1564
1564
|
};
|
|
1565
1565
|
var configToApply = getConfigToApply();
|
|
1566
|
-
|
|
1566
|
+
React.useEffect(function () {
|
|
1567
1567
|
var _a;
|
|
1568
1568
|
var delayTimer;
|
|
1569
1569
|
var timeoutTimer;
|
|
@@ -1606,7 +1606,7 @@ var ChatButton = function (_a) {
|
|
|
1606
1606
|
};
|
|
1607
1607
|
}, [configToApply, setAnimate, hasInteracted]);
|
|
1608
1608
|
var animation = animate && !hasInteracted ? (configToApply === null || configToApply === void 0 ? void 0 : configToApply.animation) || "wiggle" : "none";
|
|
1609
|
-
|
|
1609
|
+
React.useEffect(function () {
|
|
1610
1610
|
var handleResize = function () {
|
|
1611
1611
|
var screenWidth = window.innerWidth;
|
|
1612
1612
|
var newButtonWidth = screenWidth < parseInt(mobileWidth, 10)
|
|
@@ -1788,7 +1788,7 @@ function execute(url, dispatch, visuals, behavior) {
|
|
|
1788
1788
|
}
|
|
1789
1789
|
function useOpenUrlCallback() {
|
|
1790
1790
|
var env = useWidgetEnv();
|
|
1791
|
-
return
|
|
1791
|
+
return React.useCallback(function (url, dispatch, visuals, behavior) {
|
|
1792
1792
|
if (!behavior) {
|
|
1793
1793
|
behavior = (env === null || env === void 0 ? void 0 : env.urls) ? resolveUrlPolicy(url, env.urls) : defaultBehavior;
|
|
1794
1794
|
}
|
|
@@ -2105,7 +2105,7 @@ var LogChat = /** @class */ (function () {
|
|
|
2105
2105
|
}());
|
|
2106
2106
|
|
|
2107
2107
|
var jsxRuntime = require$$0;
|
|
2108
|
-
var react =
|
|
2108
|
+
var react = React;
|
|
2109
2109
|
|
|
2110
2110
|
var IconButton = function (props) {
|
|
2111
2111
|
var Icon = props.icon;
|
|
@@ -10586,16 +10586,16 @@ function createChatServerCore(config, options) {
|
|
|
10586
10586
|
function createChatServer(config, options) {
|
|
10587
10587
|
return new LogChat(createChatServerCore(config, options));
|
|
10588
10588
|
}
|
|
10589
|
-
var ChatServerContext =
|
|
10589
|
+
var ChatServerContext = React.createContext(null);
|
|
10590
10590
|
function useChatServer(config, options) {
|
|
10591
|
-
var _a =
|
|
10591
|
+
var _a = React.useState(), server = _a[0], setServer = _a[1];
|
|
10592
10592
|
var dispatch = useChatDispatch();
|
|
10593
10593
|
var deps = [options, config, dispatch];
|
|
10594
10594
|
// Track previous values to detect what changed
|
|
10595
|
-
var prevDepsRef =
|
|
10595
|
+
var prevDepsRef = React.useRef(undefined);
|
|
10596
10596
|
// Log what caused the "effect"
|
|
10597
10597
|
// useWhatChanged(deps, "options, config, dispatch");
|
|
10598
|
-
|
|
10598
|
+
React.useEffect(function () {
|
|
10599
10599
|
// Log when effect runs and what changed (for debugging connection issues)
|
|
10600
10600
|
if (prevDepsRef.current) {
|
|
10601
10601
|
var _a = prevDepsRef.current, prevOptions = _a[0], prevConfig = _a[1], prevDispatch = _a[2];
|
|
@@ -10634,8 +10634,8 @@ function useChatServer(config, options) {
|
|
|
10634
10634
|
|
|
10635
10635
|
function useChatServerDispatch() {
|
|
10636
10636
|
var inner = useChatDispatch();
|
|
10637
|
-
var chatServer =
|
|
10638
|
-
return
|
|
10637
|
+
var chatServer = React.useContext(ChatServerContext);
|
|
10638
|
+
return React.useCallback(function (action) {
|
|
10639
10639
|
if (!action) {
|
|
10640
10640
|
console.warn("react bug? Someone invokes with null");
|
|
10641
10641
|
return;
|
|
@@ -10947,14 +10947,14 @@ var ChatHeader = function (props) {
|
|
|
10947
10947
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
10948
10948
|
var innerDispatch = useChatDispatch();
|
|
10949
10949
|
var menuConfig = props.menuConfig, onSubmit = props.onSubmit, debugMode = props.debugMode;
|
|
10950
|
-
var _r =
|
|
10950
|
+
var _r = React.useState(false), drawerOpen = _r[0], setDrawerState = _r[1]; // false initially
|
|
10951
10951
|
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
10952
10952
|
var showMenuLeft = menuPosition === "HEADER_LEFT";
|
|
10953
10953
|
var showMenuRight = menuPosition === "HEADER_RIGHT";
|
|
10954
10954
|
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items;
|
|
10955
10955
|
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex;
|
|
10956
10956
|
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex;
|
|
10957
|
-
var menuItems =
|
|
10957
|
+
var menuItems = React.useMemo(function () { return (menuItemsRaw ? menuItemsRaw : []); }, [menuItemsRaw]);
|
|
10958
10958
|
// Check if we have a right-side menu
|
|
10959
10959
|
var hasRightMenu = showMenuRight && menuItems.length > 0;
|
|
10960
10960
|
function toggleDrawer() {
|
|
@@ -11009,7 +11009,7 @@ var ChatMessagePart = function (props) {
|
|
|
11009
11009
|
|
|
11010
11010
|
function useExecuteActionCallback() {
|
|
11011
11011
|
var dispatch = useChatServerDispatch();
|
|
11012
|
-
return
|
|
11012
|
+
return React.useCallback(function (text, meta) {
|
|
11013
11013
|
dispatch(executeAction(text, meta));
|
|
11014
11014
|
}, [dispatch]);
|
|
11015
11015
|
}
|
|
@@ -11019,7 +11019,7 @@ function useButtonCallback() {
|
|
|
11019
11019
|
var chatDispatch = useChatDispatch();
|
|
11020
11020
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
11021
11021
|
var executeAction = useExecuteActionCallback();
|
|
11022
|
-
return
|
|
11022
|
+
return React.useCallback(function (button) {
|
|
11023
11023
|
if (button.actionUrl) {
|
|
11024
11024
|
handleOpenUrl(button.actionUrl, chatDispatch, visuals);
|
|
11025
11025
|
}
|
|
@@ -11060,7 +11060,7 @@ function isTable(display) {
|
|
|
11060
11060
|
|
|
11061
11061
|
var CardMiddlewareWidget = function (props) {
|
|
11062
11062
|
var msg = props.msg, ctx = props.ctx;
|
|
11063
|
-
var card =
|
|
11063
|
+
var card = React.useMemo(function () { return convertFromCardDisplay(msg); }, [msg]);
|
|
11064
11064
|
var user = ctx.user;
|
|
11065
11065
|
var handleButton = useButtonCallback();
|
|
11066
11066
|
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 }) }) }));
|
|
@@ -11110,9 +11110,9 @@ function createSubscribableArray(originalValue) {
|
|
|
11110
11110
|
};
|
|
11111
11111
|
}
|
|
11112
11112
|
function useSubscribableArray(array) {
|
|
11113
|
-
var _a =
|
|
11113
|
+
var _a = React.useState(array.getArray()), res = _a[0], setRes = _a[1];
|
|
11114
11114
|
var mounted = useIsMounted();
|
|
11115
|
-
|
|
11115
|
+
React.useEffect(function () {
|
|
11116
11116
|
var subscription = array.subscribe(function (newVal) {
|
|
11117
11117
|
if (mounted()) {
|
|
11118
11118
|
setRes(newVal);
|
|
@@ -11144,7 +11144,7 @@ function useGlobalSubscribableArray(storage) {
|
|
|
11144
11144
|
}
|
|
11145
11145
|
function useLateMiddlewaresBuilder(storage) {
|
|
11146
11146
|
var middlewares = useGlobalSubscribableArray(storage);
|
|
11147
|
-
return
|
|
11147
|
+
return React.useMemo(function () { return joinMiddlewares(middlewares); }, [middlewares]);
|
|
11148
11148
|
}
|
|
11149
11149
|
var storage = createStorage(globalThis, "xappMsgMiddlewares");
|
|
11150
11150
|
function useLateMiddleware() {
|
|
@@ -11156,7 +11156,7 @@ function getSvg() {
|
|
|
11156
11156
|
}
|
|
11157
11157
|
var ExternalLink = function (props) {
|
|
11158
11158
|
var url = props.url;
|
|
11159
|
-
var handleClick =
|
|
11159
|
+
var handleClick = React.useCallback(function (ev) {
|
|
11160
11160
|
ev.preventDefault();
|
|
11161
11161
|
}, []);
|
|
11162
11162
|
return (require$$0.jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick, children: getSvg() }));
|
|
@@ -11269,7 +11269,7 @@ function reduceLink(url, maxLength) {
|
|
|
11269
11269
|
|
|
11270
11270
|
var SmartLink = function (props) {
|
|
11271
11271
|
var url = props.url, className = props.className;
|
|
11272
|
-
var handleClick =
|
|
11272
|
+
var handleClick = React.useCallback(function (ev) {
|
|
11273
11273
|
ev.preventDefault();
|
|
11274
11274
|
}, []);
|
|
11275
11275
|
return (require$$0.jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: className, onClick: handleClick, children: reduceLink(url, 40) }));
|
|
@@ -11285,7 +11285,7 @@ var ListItem = function (props) {
|
|
|
11285
11285
|
|
|
11286
11286
|
var List = function (props) {
|
|
11287
11287
|
var list = props.list;
|
|
11288
|
-
var listRef =
|
|
11288
|
+
var listRef = React.useRef(null);
|
|
11289
11289
|
var hasImage = list.items.some(function (item) { return item.imageUrl; });
|
|
11290
11290
|
var titlesOnly = !list.items.some(function (item) { var _a; return item.subTitle || ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length); });
|
|
11291
11291
|
var listItems = list.items.map(function (item, itemIndex) {
|
|
@@ -11299,9 +11299,9 @@ var ListMiddlewareWidget = function (props) {
|
|
|
11299
11299
|
if (!ctx) {
|
|
11300
11300
|
throw new TypeError("ctx not provided to ".concat(ListMiddlewareWidget.name));
|
|
11301
11301
|
}
|
|
11302
|
-
var list =
|
|
11302
|
+
var list = React.useMemo(function () { return convertFromListDisplay(msg); }, [msg]);
|
|
11303
11303
|
var executeActionCallback = useExecuteActionCallback();
|
|
11304
|
-
var handleExecute =
|
|
11304
|
+
var handleExecute = React.useCallback(function (ui, text, token) {
|
|
11305
11305
|
executeActionCallback(text, { token: token, action: "click", ui: ui });
|
|
11306
11306
|
}, [executeActionCallback]);
|
|
11307
11307
|
var handleButton = useButtonCallback();
|
|
@@ -11318,7 +11318,7 @@ var ListMiddleware = function (next) { return function (props) {
|
|
|
11318
11318
|
|
|
11319
11319
|
var MultiSelect = function (props) {
|
|
11320
11320
|
var items = props.items, checked = props.checked, onChange = props.onChange;
|
|
11321
|
-
var handleToggle =
|
|
11321
|
+
var handleToggle = React.useCallback(function (ev) {
|
|
11322
11322
|
var _a;
|
|
11323
11323
|
var id = ev.target.value;
|
|
11324
11324
|
onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
|
|
@@ -11334,10 +11334,10 @@ function convertToMultiSelectItems(display) {
|
|
|
11334
11334
|
}
|
|
11335
11335
|
var MultiSelectMiddlewareWidget = function (props) {
|
|
11336
11336
|
var msg = props.msg, ctx = props.ctx;
|
|
11337
|
-
var items =
|
|
11337
|
+
var items = React.useMemo(function () { return convertToMultiSelectItems(msg); }, [msg]);
|
|
11338
11338
|
var user = ctx.user;
|
|
11339
|
-
var _a =
|
|
11340
|
-
var handleSubmit =
|
|
11339
|
+
var _a = React.useState({}), checked = _a[0], setChecked = _a[1];
|
|
11340
|
+
var handleSubmit = React.useCallback(function () {
|
|
11341
11341
|
ctx.send({
|
|
11342
11342
|
type: "custom",
|
|
11343
11343
|
payload: JSON.stringify({
|
|
@@ -11385,14 +11385,14 @@ var StandardMiddlewaresBuilder = joinMiddlewares([
|
|
|
11385
11385
|
]);
|
|
11386
11386
|
function useStandardMiddlewareBuilder() {
|
|
11387
11387
|
var lateMiddleware = useLateMiddleware();
|
|
11388
|
-
return
|
|
11388
|
+
return React.useMemo(function () { return joinMiddlewares([
|
|
11389
11389
|
lateMiddleware,
|
|
11390
11390
|
StandardMiddlewaresBuilder,
|
|
11391
11391
|
]); }, [lateMiddleware]);
|
|
11392
11392
|
}
|
|
11393
11393
|
function useStandardMiddleware() {
|
|
11394
11394
|
var builder = useStandardMiddlewareBuilder();
|
|
11395
|
-
return
|
|
11395
|
+
return React.useMemo(function () { return builder(UnknownMessage); }, [builder]);
|
|
11396
11396
|
}
|
|
11397
11397
|
var StandardMiddlewares = StandardMiddlewaresBuilder(UnknownMessage);
|
|
11398
11398
|
|
|
@@ -11407,7 +11407,7 @@ function getTailSvg(owner) {
|
|
|
11407
11407
|
}
|
|
11408
11408
|
var ChatMessageBubble = function (props) {
|
|
11409
11409
|
var owner = props.owner, onClick = props.onClick;
|
|
11410
|
-
var handleClick =
|
|
11410
|
+
var handleClick = React.useCallback(function () {
|
|
11411
11411
|
if (onClick) {
|
|
11412
11412
|
onClick();
|
|
11413
11413
|
}
|
|
@@ -11418,18 +11418,18 @@ var ChatMessageBubble = function (props) {
|
|
|
11418
11418
|
var ChatMarkdownMessage = function (props) {
|
|
11419
11419
|
var onOpenUrl = props.onOpenUrl;
|
|
11420
11420
|
var agentMessage = isAgent(props.message.user.nick);
|
|
11421
|
-
var ref =
|
|
11421
|
+
var ref = React.useRef(null);
|
|
11422
11422
|
var chatDispatch = useChatDispatch();
|
|
11423
11423
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
11424
11424
|
var html = props.message.msg.html;
|
|
11425
|
-
var handleLinkClick =
|
|
11425
|
+
var handleLinkClick = React.useCallback(function (ev) {
|
|
11426
11426
|
if (onOpenUrl) {
|
|
11427
11427
|
var link = ev.target;
|
|
11428
11428
|
ev.preventDefault();
|
|
11429
11429
|
onOpenUrl(link.href, chatDispatch, visuals);
|
|
11430
11430
|
}
|
|
11431
11431
|
}, [onOpenUrl]);
|
|
11432
|
-
|
|
11432
|
+
React.useEffect(function () {
|
|
11433
11433
|
if (ref.current) {
|
|
11434
11434
|
ref.current.innerHTML = html;
|
|
11435
11435
|
if (onOpenUrl) {
|
|
@@ -11460,21 +11460,21 @@ var ChatPermissionMessage = function (props) {
|
|
|
11460
11460
|
var author = message.user;
|
|
11461
11461
|
var allowLabel = "Allow";
|
|
11462
11462
|
var denyLabel = "Deny";
|
|
11463
|
-
var writeAsAgent =
|
|
11463
|
+
var writeAsAgent = React.useCallback(function (msg) {
|
|
11464
11464
|
ctx.write({
|
|
11465
11465
|
type: "msg",
|
|
11466
11466
|
user: author,
|
|
11467
11467
|
msg: msg,
|
|
11468
11468
|
});
|
|
11469
11469
|
}, [ctx, author]);
|
|
11470
|
-
var writeAsUser =
|
|
11470
|
+
var writeAsUser = React.useCallback(function (msg) {
|
|
11471
11471
|
ctx.write({
|
|
11472
11472
|
type: "msg",
|
|
11473
11473
|
user: user,
|
|
11474
11474
|
msg: msg,
|
|
11475
11475
|
});
|
|
11476
11476
|
}, [ctx, user]);
|
|
11477
|
-
var handleFail =
|
|
11477
|
+
var handleFail = React.useCallback(function () {
|
|
11478
11478
|
ctx.send({
|
|
11479
11479
|
type: "msg",
|
|
11480
11480
|
user: undefined,
|
|
@@ -11483,14 +11483,14 @@ var ChatPermissionMessage = function (props) {
|
|
|
11483
11483
|
},
|
|
11484
11484
|
});
|
|
11485
11485
|
}, [ctx]);
|
|
11486
|
-
var handleSend =
|
|
11486
|
+
var handleSend = React.useCallback(function (msg) {
|
|
11487
11487
|
ctx.send({
|
|
11488
11488
|
type: "permissionGrant",
|
|
11489
11489
|
user: author,
|
|
11490
11490
|
msg: msg,
|
|
11491
11491
|
});
|
|
11492
11492
|
}, [author, ctx]);
|
|
11493
|
-
var handleResult =
|
|
11493
|
+
var handleResult = React.useCallback(function (position, userMsg) {
|
|
11494
11494
|
handleSend({
|
|
11495
11495
|
text: userMsg,
|
|
11496
11496
|
location: position
|
|
@@ -11509,10 +11509,10 @@ var ChatPermissionMessage = function (props) {
|
|
|
11509
11509
|
writeAsAgent(agentMsg);
|
|
11510
11510
|
}
|
|
11511
11511
|
}, [permissionRequest, writeAsUser, writeAsAgent, handleSend]);
|
|
11512
|
-
var handleDeny =
|
|
11512
|
+
var handleDeny = React.useCallback(function (label) {
|
|
11513
11513
|
handleResult(undefined, label);
|
|
11514
11514
|
}, [handleResult]);
|
|
11515
|
-
var handleAllow =
|
|
11515
|
+
var handleAllow = React.useCallback(function (label) {
|
|
11516
11516
|
if (navigator.geolocation) {
|
|
11517
11517
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
11518
11518
|
handleResult(position, label);
|
|
@@ -11529,7 +11529,7 @@ var ChatPermissionMessage = function (props) {
|
|
|
11529
11529
|
|
|
11530
11530
|
var CopyButton = function (_a) {
|
|
11531
11531
|
var text = _a.text;
|
|
11532
|
-
var _b =
|
|
11532
|
+
var _b = React.useState(false), copied = _b[0], setCopied = _b[1];
|
|
11533
11533
|
var handleCopy = function (e) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
11534
11534
|
var textarea;
|
|
11535
11535
|
return __generator$1(this, function (_b) {
|
|
@@ -11585,7 +11585,7 @@ var ToolProgressItem = function (_a) {
|
|
|
11585
11585
|
*/
|
|
11586
11586
|
var ToolCallItem = function (_a) {
|
|
11587
11587
|
var toolCall = _a.toolCall;
|
|
11588
|
-
var _b =
|
|
11588
|
+
var _b = React.useState(false), isExpanded = _b[0], setIsExpanded = _b[1];
|
|
11589
11589
|
var toggleExpanded = function () { return setIsExpanded(!isExpanded); };
|
|
11590
11590
|
var formatJson = function (data) {
|
|
11591
11591
|
if (data === undefined || data === null)
|
|
@@ -11760,7 +11760,7 @@ var ChatTextMessage = function (props) {
|
|
|
11760
11760
|
var agentMessage = isAgent((_a = props.message.user) === null || _a === void 0 ? void 0 : _a.nick);
|
|
11761
11761
|
var isStreaming = message.isStreaming;
|
|
11762
11762
|
// Parse markdown for agent messages
|
|
11763
|
-
var parsedHtml =
|
|
11763
|
+
var parsedHtml = React.useMemo(function () {
|
|
11764
11764
|
if (agentMessage && message.msg.text) {
|
|
11765
11765
|
return parseMarkdown(message.msg.text);
|
|
11766
11766
|
}
|
|
@@ -11815,7 +11815,7 @@ var avaKeys = ["text", "html", "card", "list"];
|
|
|
11815
11815
|
var ChatMessage = function (props) {
|
|
11816
11816
|
var _a, _b, _c;
|
|
11817
11817
|
var middleware = props.messageMiddleware || StandardMiddlewares;
|
|
11818
|
-
var chatConfig =
|
|
11818
|
+
var chatConfig = React.useContext(ChatConfigContext);
|
|
11819
11819
|
// console.log(`########### chatConfig: ${JSON.stringify(chatConfig, null, 2)}`);
|
|
11820
11820
|
var ctx = props.middlewareContext;
|
|
11821
11821
|
var user = props.agent;
|
|
@@ -11910,7 +11910,7 @@ function checkSessionExpiration(duration, lastMessageTimestamp, _lastTimestamp)
|
|
|
11910
11910
|
}
|
|
11911
11911
|
|
|
11912
11912
|
function useExternalScript(url) {
|
|
11913
|
-
|
|
11913
|
+
React.useEffect(function () {
|
|
11914
11914
|
if (!url) {
|
|
11915
11915
|
return;
|
|
11916
11916
|
}
|
|
@@ -11952,7 +11952,7 @@ function useChatServerVisitorId() {
|
|
|
11952
11952
|
});
|
|
11953
11953
|
var visitorAccessToken = reactRedux.useSelector(function (state) { return state.accessToken; });
|
|
11954
11954
|
var attributes = reactRedux.useSelector(function (state) { return state.attributes; });
|
|
11955
|
-
return
|
|
11955
|
+
return React.useMemo(function () { return ({
|
|
11956
11956
|
dispatch: dispatch,
|
|
11957
11957
|
visitorId: clientVisitorId,
|
|
11958
11958
|
accessToken: visitorAccessToken,
|
|
@@ -11964,12 +11964,12 @@ function useChatServerVisitorId() {
|
|
|
11964
11964
|
function useGreeting(active) {
|
|
11965
11965
|
var _a, _b;
|
|
11966
11966
|
var curr = useChatServerVisitorId();
|
|
11967
|
-
var snapshotRef =
|
|
11968
|
-
var ctx =
|
|
11967
|
+
var snapshotRef = React.useRef(null);
|
|
11968
|
+
var ctx = React.useContext(ChatConfigContext);
|
|
11969
11969
|
// Handle null context (e.g., in preview mode)
|
|
11970
11970
|
var isAdmin = (_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.env) === null || _a === void 0 ? void 0 : _a.isAdmin) !== null && _b !== void 0 ? _b : false;
|
|
11971
11971
|
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
11972
|
-
|
|
11972
|
+
React.useEffect(function () {
|
|
11973
11973
|
if (active) {
|
|
11974
11974
|
if (snapshotRef.current !== curr) {
|
|
11975
11975
|
snapshotRef.current = curr;
|
|
@@ -12014,18 +12014,18 @@ function norm(index, len) {
|
|
|
12014
12014
|
return (index + len) % len;
|
|
12015
12015
|
}
|
|
12016
12016
|
function useSuggestions(search, context) {
|
|
12017
|
-
var _a =
|
|
12018
|
-
var _b =
|
|
12019
|
-
var _c =
|
|
12020
|
-
var _d =
|
|
12021
|
-
|
|
12017
|
+
var _a = React.useState(), suggestions = _a[0], setSuggestions = _a[1];
|
|
12018
|
+
var _b = React.useState(-1), suggestionIndex = _b[0], setSuggestionIndex = _b[1];
|
|
12019
|
+
var _c = React.useState(search), query = _c[0], setQuery = _c[1];
|
|
12020
|
+
var _d = React.useState(context), contextState = _d[0], setContextState = _d[1];
|
|
12021
|
+
React.useEffect(function () {
|
|
12022
12022
|
setQuery(search);
|
|
12023
12023
|
}, [search]);
|
|
12024
|
-
|
|
12024
|
+
React.useEffect(function () {
|
|
12025
12025
|
setContextState(context);
|
|
12026
12026
|
}, [context]);
|
|
12027
|
-
var suggestionItem =
|
|
12028
|
-
var shift =
|
|
12027
|
+
var suggestionItem = React.useMemo(function () { return suggestions ? findItemByIndex_1(suggestions, suggestionIndex) : undefined; }, [suggestions, suggestionIndex]);
|
|
12028
|
+
var shift = React.useCallback(function (delta) {
|
|
12029
12029
|
if (suggestions) {
|
|
12030
12030
|
var len_1 = getItemsLength_1(suggestions);
|
|
12031
12031
|
setSuggestionIndex(function (index) { return norm(index + delta + ((index < 0 && delta <= 0) ? 1 : 0), len_1); });
|
|
@@ -12034,7 +12034,7 @@ function useSuggestions(search, context) {
|
|
|
12034
12034
|
setSuggestionIndex(-1);
|
|
12035
12035
|
}
|
|
12036
12036
|
}, [suggestions]);
|
|
12037
|
-
var execute =
|
|
12037
|
+
var execute = React.useCallback(function (cmd) {
|
|
12038
12038
|
switch (cmd) {
|
|
12039
12039
|
case "prev":
|
|
12040
12040
|
shift(-1);
|
|
@@ -12051,7 +12051,7 @@ function useSuggestions(search, context) {
|
|
|
12051
12051
|
}, [shift]);
|
|
12052
12052
|
var suggestionsResponse = useSuggestionsFetch(query || "", contextState);
|
|
12053
12053
|
var suggestionsData = suggestionsResponse.state === "success" ? suggestionsResponse.data : undefined;
|
|
12054
|
-
var raw =
|
|
12054
|
+
var raw = React.useMemo(function () {
|
|
12055
12055
|
return suggestionsData ?
|
|
12056
12056
|
parseSuggestionsResponse_1(suggestionsData, -1).map(function (suggestion) {
|
|
12057
12057
|
return {
|
|
@@ -12060,14 +12060,14 @@ function useSuggestions(search, context) {
|
|
|
12060
12060
|
};
|
|
12061
12061
|
}) : undefined;
|
|
12062
12062
|
}, [suggestionsData]);
|
|
12063
|
-
|
|
12063
|
+
React.useEffect(function () {
|
|
12064
12064
|
var prev = suggestionItem;
|
|
12065
12065
|
setSuggestions(raw);
|
|
12066
12066
|
if (!prev || !raw) {
|
|
12067
12067
|
setSuggestionIndex(-1);
|
|
12068
12068
|
}
|
|
12069
12069
|
}, [raw, suggestionItem]);
|
|
12070
|
-
return
|
|
12070
|
+
return React.useMemo(function () { return ({
|
|
12071
12071
|
suggestions: suggestions,
|
|
12072
12072
|
index: suggestionIndex,
|
|
12073
12073
|
execute: execute,
|
|
@@ -12077,11 +12077,11 @@ function useSuggestions(search, context) {
|
|
|
12077
12077
|
|
|
12078
12078
|
var AdminBar = function (_a) {
|
|
12079
12079
|
var onAdminJoin = _a.onAdminJoin;
|
|
12080
|
-
var name =
|
|
12080
|
+
var name = React.useRef(null);
|
|
12081
12081
|
// We can manage this locally
|
|
12082
12082
|
// const hasAdminJoined = useSelector<ChatState, boolean | undefined>(state => state.hasAdminJoined);
|
|
12083
|
-
var _b =
|
|
12084
|
-
var _c =
|
|
12083
|
+
var _b = React.useState(false), joined = _b[0], setJoined = _b[1];
|
|
12084
|
+
var _c = React.useState(""), inputName = _c[0], setInputName = _c[1];
|
|
12085
12085
|
function handleInputChange(event) {
|
|
12086
12086
|
setInputName(event.target.value);
|
|
12087
12087
|
}
|
|
@@ -12232,7 +12232,7 @@ var SendIcon = function () {
|
|
|
12232
12232
|
|
|
12233
12233
|
var SendButton = function (props) {
|
|
12234
12234
|
var _a = props.disabled, disabled = _a === void 0 ? false : _a;
|
|
12235
|
-
var _b =
|
|
12235
|
+
var _b = React.useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
12236
12236
|
// Determine which icon to show based on state
|
|
12237
12237
|
var getIconSrc = function () {
|
|
12238
12238
|
if (disabled && props.sendButtonIconDisabled) {
|
|
@@ -12251,7 +12251,7 @@ var COUNTER_THRESHOLD_PERCENT = 0.8;
|
|
|
12251
12251
|
var Input = function (props) {
|
|
12252
12252
|
var _a, _b;
|
|
12253
12253
|
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;
|
|
12254
|
-
var _c =
|
|
12254
|
+
var _c = React.useState(false), dragover = _c[0], setDragover = _c[1];
|
|
12255
12255
|
var maxLength = inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.maxLength;
|
|
12256
12256
|
var currentLength = value.text.length;
|
|
12257
12257
|
var isAtLimit = maxLength !== undefined && currentLength >= maxLength;
|
|
@@ -12268,17 +12268,17 @@ var Input = function (props) {
|
|
|
12268
12268
|
function onDragLeave() {
|
|
12269
12269
|
setDragover(false);
|
|
12270
12270
|
}
|
|
12271
|
-
var handleOnSubmit =
|
|
12271
|
+
var handleOnSubmit = React.useCallback(function (event) {
|
|
12272
12272
|
event && event.preventDefault();
|
|
12273
12273
|
onSubmit(value); // send to the widget
|
|
12274
12274
|
}, [value, onSubmit]);
|
|
12275
|
-
var handleClear =
|
|
12275
|
+
var handleClear = React.useCallback(function () {
|
|
12276
12276
|
onChange({
|
|
12277
12277
|
text: "",
|
|
12278
12278
|
formats: [],
|
|
12279
12279
|
});
|
|
12280
12280
|
}, [onChange]);
|
|
12281
|
-
var handleKeyDown =
|
|
12281
|
+
var handleKeyDown = React.useCallback(function (event) {
|
|
12282
12282
|
if (suggestion) {
|
|
12283
12283
|
if (event.key === "End" || event.key === "ArrowRight" || event.key === "Enter") {
|
|
12284
12284
|
onChange(suggestion);
|
|
@@ -12312,7 +12312,7 @@ function createActions(onItemUse) {
|
|
|
12312
12312
|
return function (innerProps) {
|
|
12313
12313
|
var data = innerProps.data;
|
|
12314
12314
|
var canUse = data.type !== "FAQ";
|
|
12315
|
-
var handleUse =
|
|
12315
|
+
var handleUse = React.useCallback(function (ev) {
|
|
12316
12316
|
onItemUse(data);
|
|
12317
12317
|
ev.stopPropagation();
|
|
12318
12318
|
}, [data]);
|
|
@@ -12324,9 +12324,9 @@ function createActions(onItemUse) {
|
|
|
12324
12324
|
}
|
|
12325
12325
|
var Suggestions = function (props) {
|
|
12326
12326
|
var data = props.data, onItemUse = props.onItemUse, searchTerms = props.searchTerms;
|
|
12327
|
-
var _a =
|
|
12328
|
-
var _b =
|
|
12329
|
-
|
|
12327
|
+
var _a = React.useState(), fixedSuggestions = _a[0], setFixedSuggestions = _a[1];
|
|
12328
|
+
var _b = React.useState(), activeItem = _b[0], setActiveItem = _b[1];
|
|
12329
|
+
React.useEffect(function () {
|
|
12330
12330
|
if (data) {
|
|
12331
12331
|
setFixedSuggestions(data);
|
|
12332
12332
|
}
|
|
@@ -12337,8 +12337,8 @@ var Suggestions = function (props) {
|
|
|
12337
12337
|
}, [data, searchTerms]);
|
|
12338
12338
|
var len = data === null || data === void 0 ? void 0 : data.length;
|
|
12339
12339
|
var currentIndex = len > 0 ? props.index : NaN;
|
|
12340
|
-
var item =
|
|
12341
|
-
var handleSpanClick =
|
|
12340
|
+
var item = React.useMemo(function () { return findItemByIndex_1(data, currentIndex); }, [data, currentIndex]);
|
|
12341
|
+
var handleSpanClick = React.useCallback(function (target, span) {
|
|
12342
12342
|
if (span.type === "inputText") {
|
|
12343
12343
|
onItemUse(target);
|
|
12344
12344
|
setActiveItem(undefined);
|
|
@@ -12346,10 +12346,10 @@ var Suggestions = function (props) {
|
|
|
12346
12346
|
}
|
|
12347
12347
|
return undefined;
|
|
12348
12348
|
}, [onItemUse]);
|
|
12349
|
-
|
|
12349
|
+
React.useEffect(function () {
|
|
12350
12350
|
setActiveItem(item);
|
|
12351
12351
|
}, [item]);
|
|
12352
|
-
var actions =
|
|
12352
|
+
var actions = React.useMemo(function () { return createActions(onItemUse); }, [onItemUse]);
|
|
12353
12353
|
var transformContent = function (content) {
|
|
12354
12354
|
var lines = content.split('\n');
|
|
12355
12355
|
return lines.map(function (line) {
|
|
@@ -12368,8 +12368,8 @@ var ChatFooter = function (props) {
|
|
|
12368
12368
|
var _a, _b, _c;
|
|
12369
12369
|
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, disabled = props.disabled, onSubmit = props.onSubmit;
|
|
12370
12370
|
var innerDispatch = useChatDispatch();
|
|
12371
|
-
var _d =
|
|
12372
|
-
var _e =
|
|
12371
|
+
var _d = React.useState(false), drawerOpen = _d[0], setDrawerState = _d[1]; // false initially
|
|
12372
|
+
var _e = React.useState(), suggestionSearch = _e[0], setSuggestionSearch = _e[1];
|
|
12373
12373
|
var contexts = reactRedux.useSelector(function (state) { return state.activeContexts; });
|
|
12374
12374
|
var suggestions = useSuggestions(suggestionSearch, contexts);
|
|
12375
12375
|
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
@@ -12377,12 +12377,12 @@ var ChatFooter = function (props) {
|
|
|
12377
12377
|
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items;
|
|
12378
12378
|
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex;
|
|
12379
12379
|
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex;
|
|
12380
|
-
var menuItems =
|
|
12380
|
+
var menuItems = React.useMemo(function () { return menuItemsRaw ? menuItemsRaw : []; }, [menuItemsRaw]);
|
|
12381
12381
|
var brandingEnabled = (_b = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.branding) === null || _b === void 0 ? void 0 : _b.enabled;
|
|
12382
12382
|
var brandingText = (_c = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.branding) === null || _c === void 0 ? void 0 : _c.text;
|
|
12383
12383
|
// If they are NOT an admin, automatically enabled the input
|
|
12384
|
-
var _f =
|
|
12385
|
-
var _g =
|
|
12384
|
+
var _f = React.useState(!isAdmin), enableInput = _f[0], setEnableInput = _f[1];
|
|
12385
|
+
var _g = React.useState({
|
|
12386
12386
|
text: "",
|
|
12387
12387
|
formats: []
|
|
12388
12388
|
}), input = _g[0], setInput = _g[1];
|
|
@@ -12403,7 +12403,7 @@ var ChatFooter = function (props) {
|
|
|
12403
12403
|
setSuggestionSearch(val.text);
|
|
12404
12404
|
}
|
|
12405
12405
|
// Clears out suggestion and input text
|
|
12406
|
-
var handleSubmit =
|
|
12406
|
+
var handleSubmit = React.useCallback(function (message) {
|
|
12407
12407
|
// Clears out the suggestions
|
|
12408
12408
|
setSuggestionSearch("");
|
|
12409
12409
|
// Clears out the input
|
|
@@ -12413,10 +12413,10 @@ var ChatFooter = function (props) {
|
|
|
12413
12413
|
});
|
|
12414
12414
|
onSubmit(message.text);
|
|
12415
12415
|
}, [onSubmit]);
|
|
12416
|
-
var handleItemClick =
|
|
12416
|
+
var handleItemClick = React.useCallback(function (data) {
|
|
12417
12417
|
handleSubmit(data);
|
|
12418
12418
|
}, [handleSubmit]);
|
|
12419
|
-
var handleItemUse =
|
|
12419
|
+
var handleItemUse = React.useCallback(function (data) {
|
|
12420
12420
|
setInput(data);
|
|
12421
12421
|
setSuggestionSearch(data.text);
|
|
12422
12422
|
}, []);
|
|
@@ -12459,15 +12459,15 @@ function buildFormConfig(buttonConfig, widgetEnv) {
|
|
|
12459
12459
|
var FormModal = function (_a) {
|
|
12460
12460
|
var _b, _c;
|
|
12461
12461
|
var config = _a.config, widgetEnv = _a.widgetEnv, onClose = _a.onClose;
|
|
12462
|
-
var modalRef =
|
|
12463
|
-
var contentRef =
|
|
12462
|
+
var modalRef = React.useRef(null);
|
|
12463
|
+
var contentRef = React.useRef(null);
|
|
12464
12464
|
var formConfig = buildFormConfig(config, widgetEnv);
|
|
12465
|
-
var _d =
|
|
12466
|
-
var _e =
|
|
12465
|
+
var _d = React.useState("idle"), loadingState = _d[0], setLoadingState = _d[1];
|
|
12466
|
+
var _e = React.useState(""), errorMessage = _e[0], setErrorMessage = _e[1];
|
|
12467
12467
|
// Get the form widget key from config or widgetEnv
|
|
12468
12468
|
var formWidgetKey = ((_c = (_b = config.formConfig) === null || _b === void 0 ? void 0 : _b.api) === null || _c === void 0 ? void 0 : _c.key) || (widgetEnv === null || widgetEnv === void 0 ? void 0 : widgetEnv.formWidgetKey);
|
|
12469
12469
|
// Attempt to load and open the form widget
|
|
12470
|
-
var attemptOpenFormWidget =
|
|
12470
|
+
var attemptOpenFormWidget = React.useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
12471
12471
|
var options, opened, options, opened;
|
|
12472
12472
|
return __generator$1(this, function (_a) {
|
|
12473
12473
|
switch (_a.label) {
|
|
@@ -12524,11 +12524,11 @@ var FormModal = function (_a) {
|
|
|
12524
12524
|
});
|
|
12525
12525
|
}); }, [config.preselectChipLabel, formWidgetKey, onClose]);
|
|
12526
12526
|
// Attempt to open form widget on mount
|
|
12527
|
-
|
|
12527
|
+
React.useEffect(function () {
|
|
12528
12528
|
attemptOpenFormWidget();
|
|
12529
12529
|
}, [attemptOpenFormWidget]);
|
|
12530
12530
|
// Handle Escape key to close
|
|
12531
|
-
|
|
12531
|
+
React.useEffect(function () {
|
|
12532
12532
|
var handleKeyDown = function (event) {
|
|
12533
12533
|
if (event.key === "Escape") {
|
|
12534
12534
|
onClose();
|
|
@@ -12540,7 +12540,7 @@ var FormModal = function (_a) {
|
|
|
12540
12540
|
};
|
|
12541
12541
|
}, [onClose]);
|
|
12542
12542
|
// Prevent body scroll when modal is open
|
|
12543
|
-
|
|
12543
|
+
React.useEffect(function () {
|
|
12544
12544
|
var originalOverflow = document.body.style.overflow;
|
|
12545
12545
|
document.body.style.overflow = "hidden";
|
|
12546
12546
|
return function () {
|
|
@@ -12548,18 +12548,18 @@ var FormModal = function (_a) {
|
|
|
12548
12548
|
};
|
|
12549
12549
|
}, []);
|
|
12550
12550
|
// Focus trap - focus the modal content on mount
|
|
12551
|
-
|
|
12551
|
+
React.useEffect(function () {
|
|
12552
12552
|
if (contentRef.current) {
|
|
12553
12553
|
contentRef.current.focus();
|
|
12554
12554
|
}
|
|
12555
12555
|
}, []);
|
|
12556
|
-
var handleBackdropClick =
|
|
12556
|
+
var handleBackdropClick = React.useCallback(function (event) {
|
|
12557
12557
|
// Only close if clicking the backdrop, not the content
|
|
12558
12558
|
if (event.target === modalRef.current) {
|
|
12559
12559
|
onClose();
|
|
12560
12560
|
}
|
|
12561
12561
|
}, [onClose]);
|
|
12562
|
-
var handleRetry =
|
|
12562
|
+
var handleRetry = React.useCallback(function () {
|
|
12563
12563
|
setLoadingState("idle");
|
|
12564
12564
|
setErrorMessage("");
|
|
12565
12565
|
attemptOpenFormWidget();
|
|
@@ -12613,13 +12613,13 @@ var ChatRating = function (_a) {
|
|
|
12613
12613
|
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 () {
|
|
12614
12614
|
// no-op
|
|
12615
12615
|
} : _e;
|
|
12616
|
-
var rateBadButtonOnClick =
|
|
12616
|
+
var rateBadButtonOnClick = React.useCallback(function () {
|
|
12617
12617
|
onRate("bad");
|
|
12618
12618
|
}, [onRate]);
|
|
12619
|
-
var rateGoodButtonOnClick =
|
|
12619
|
+
var rateGoodButtonOnClick = React.useCallback(function () {
|
|
12620
12620
|
onRate("good");
|
|
12621
12621
|
}, [onRate]);
|
|
12622
|
-
var rateAgainButtonOnClick =
|
|
12622
|
+
var rateAgainButtonOnClick = React.useCallback(function () {
|
|
12623
12623
|
onRate(undefined);
|
|
12624
12624
|
}, [onRate]);
|
|
12625
12625
|
// Do not think this prop should be here
|
|
@@ -12636,7 +12636,7 @@ var ChatRating = function (_a) {
|
|
|
12636
12636
|
|
|
12637
12637
|
var ChatRatingContainer = function (props) {
|
|
12638
12638
|
var dispatch = useChatServerDispatch();
|
|
12639
|
-
var handleRate =
|
|
12639
|
+
var handleRate = React.useCallback(function (rating) {
|
|
12640
12640
|
dispatch(sendChatRating(rating));
|
|
12641
12641
|
}, [dispatch]);
|
|
12642
12642
|
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 })] }));
|
|
@@ -34135,9 +34135,9 @@ function compileSlotValues(responseOutput, slots, replaceWhenUndefined) {
|
|
|
34135
34135
|
|
|
34136
34136
|
var FailureMessage = function (props) {
|
|
34137
34137
|
var agents = props.agents, text = props.text, delay = props.delay, time = props.time;
|
|
34138
|
-
var _a =
|
|
34138
|
+
var _a = React.useState(delay), countdown = _a[0], setCountdown = _a[1];
|
|
34139
34139
|
var agent_names = Object.values(agents).filter(function (agent) { return agent.requestFailed; });
|
|
34140
|
-
|
|
34140
|
+
React.useEffect(function () {
|
|
34141
34141
|
if (delay !== 0) {
|
|
34142
34142
|
var countdownValue_1 = delay;
|
|
34143
34143
|
var myInterval_1 = setInterval(function () {
|
|
@@ -34152,7 +34152,7 @@ var FailureMessage = function (props) {
|
|
|
34152
34152
|
setCountdown(5);
|
|
34153
34153
|
}
|
|
34154
34154
|
}, [delay]);
|
|
34155
|
-
var slots =
|
|
34155
|
+
var slots = React.useMemo(function () {
|
|
34156
34156
|
return {
|
|
34157
34157
|
sec: {
|
|
34158
34158
|
name: "sec",
|
|
@@ -34160,7 +34160,7 @@ var FailureMessage = function (props) {
|
|
|
34160
34160
|
},
|
|
34161
34161
|
};
|
|
34162
34162
|
}, [countdown]);
|
|
34163
|
-
var failureMessage =
|
|
34163
|
+
var failureMessage = React.useMemo(function () {
|
|
34164
34164
|
return compileSlotValues(text, slots);
|
|
34165
34165
|
}, [text, slots]);
|
|
34166
34166
|
if (countdown === 0) {
|
|
@@ -34179,11 +34179,11 @@ var MessageSvg = function (_) {
|
|
|
34179
34179
|
};
|
|
34180
34180
|
|
|
34181
34181
|
var MessageForm = function (props) {
|
|
34182
|
-
var name =
|
|
34183
|
-
var email =
|
|
34184
|
-
var message =
|
|
34185
|
-
var form =
|
|
34186
|
-
var _a =
|
|
34182
|
+
var name = React.useRef(null);
|
|
34183
|
+
var email = React.useRef(null);
|
|
34184
|
+
var message = React.useRef(null);
|
|
34185
|
+
var form = React.useRef(null);
|
|
34186
|
+
var _a = React.useState(false), sent = _a[0], setSent = _a[1];
|
|
34187
34187
|
function emailChanged() {
|
|
34188
34188
|
var _a, _b, _c;
|
|
34189
34189
|
if ((_a = email.current) === null || _a === void 0 ? void 0 : _a.validity.patternMismatch) {
|
|
@@ -34225,16 +34225,16 @@ var OfflineForm = function (props) {
|
|
|
34225
34225
|
|
|
34226
34226
|
var OfflineFormContainer = function (props) {
|
|
34227
34227
|
var dispatch = useChatServerDispatch();
|
|
34228
|
-
var handleSubmit =
|
|
34228
|
+
var handleSubmit = React.useCallback(function (data) {
|
|
34229
34229
|
dispatch(sendOfflineMsg(data));
|
|
34230
34230
|
}, [dispatch]);
|
|
34231
34231
|
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 })] }));
|
|
34232
34232
|
};
|
|
34233
34233
|
|
|
34234
34234
|
var PrechatForm = function (props) {
|
|
34235
|
-
var _a =
|
|
34235
|
+
var _a = React.useState(false), sent = _a[0], setSent = _a[1];
|
|
34236
34236
|
var onSubmit = props.onSubmit;
|
|
34237
|
-
var handleSubmit =
|
|
34237
|
+
var handleSubmit = React.useCallback(function (msg) {
|
|
34238
34238
|
onSubmit(msg);
|
|
34239
34239
|
setSent(true);
|
|
34240
34240
|
}, [onSubmit]);
|
|
@@ -34244,7 +34244,7 @@ var PrechatForm = function (props) {
|
|
|
34244
34244
|
var PrechatFormContainer = function (props) {
|
|
34245
34245
|
var dispatch = useChatServerDispatch();
|
|
34246
34246
|
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
34247
|
-
var handleSubmit =
|
|
34247
|
+
var handleSubmit = React.useCallback(function (data) {
|
|
34248
34248
|
// Don't send empty messages
|
|
34249
34249
|
if (!data.message)
|
|
34250
34250
|
return;
|
|
@@ -34329,31 +34329,31 @@ var TypingStatus = function (props) {
|
|
|
34329
34329
|
|
|
34330
34330
|
var MessageList = function (_a) {
|
|
34331
34331
|
_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.disableAutoScroll, disableAutoScroll = _l === void 0 ? false : _l, _m = _a.onSend, onSend = _m === void 0 ? function () { return Promise.resolve(); } : _m, _o = _a.onWrite, onWrite = _o === void 0 ? function () { return Promise.resolve(); } : _o, _p = _a.onOpenUrl, onOpenUrl = _p === void 0 ? function () { } : _p, _q = _a.minimizeOnClick, minimizeOnClick = _q === void 0 ? function () { } : _q; _a.children;
|
|
34332
|
-
var messagesEndRef =
|
|
34333
|
-
var containerRef =
|
|
34334
|
-
var prevHasWsButtonRef =
|
|
34332
|
+
var messagesEndRef = React.useRef(null);
|
|
34333
|
+
var containerRef = React.useRef(null);
|
|
34334
|
+
var prevHasWsButtonRef = React.useRef(hasWsButton);
|
|
34335
34335
|
// Check if user is scrolled to bottom
|
|
34336
|
-
var isAtBottom =
|
|
34336
|
+
var isAtBottom = React.useCallback(function () {
|
|
34337
34337
|
if (!containerRef.current)
|
|
34338
34338
|
return true;
|
|
34339
34339
|
var _a = containerRef.current, scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
34340
34340
|
return Math.abs(scrollHeight - clientHeight - scrollTop) < 10;
|
|
34341
34341
|
}, []);
|
|
34342
34342
|
// Scroll to bottom
|
|
34343
|
-
var scrollToBottom =
|
|
34343
|
+
var scrollToBottom = React.useCallback(function (behavior) {
|
|
34344
34344
|
if (behavior === void 0) { behavior = "smooth"; }
|
|
34345
34345
|
if (messagesEndRef.current) {
|
|
34346
34346
|
messagesEndRef.current.scrollIntoView({ behavior: behavior });
|
|
34347
34347
|
}
|
|
34348
34348
|
}, []);
|
|
34349
34349
|
// Always scroll to bottom when messages change (unless disabled)
|
|
34350
|
-
|
|
34350
|
+
React.useEffect(function () {
|
|
34351
34351
|
if (!disableAutoScroll) {
|
|
34352
34352
|
scrollToBottom("smooth");
|
|
34353
34353
|
}
|
|
34354
34354
|
}, [messages, agents, scrollToBottom, disableAutoScroll]);
|
|
34355
34355
|
// Handle WS button dismissal - only scroll when button is removed (unless disabled)
|
|
34356
|
-
|
|
34356
|
+
React.useEffect(function () {
|
|
34357
34357
|
if (disableAutoScroll) {
|
|
34358
34358
|
return undefined;
|
|
34359
34359
|
}
|
|
@@ -34374,19 +34374,19 @@ var MessageList = function (_a) {
|
|
|
34374
34374
|
}
|
|
34375
34375
|
return undefined;
|
|
34376
34376
|
}, [hasWsButton, isAtBottom, scrollToBottom, disableAutoScroll]);
|
|
34377
|
-
var handleSend =
|
|
34377
|
+
var handleSend = React.useCallback(function (msg) {
|
|
34378
34378
|
onSend(msg);
|
|
34379
34379
|
if (!disableAutoScroll && messagesEndRef.current) {
|
|
34380
34380
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
34381
34381
|
}
|
|
34382
34382
|
}, [onSend, disableAutoScroll]);
|
|
34383
|
-
var handleWrite =
|
|
34383
|
+
var handleWrite = React.useCallback(function (msg) {
|
|
34384
34384
|
onWrite(msg);
|
|
34385
34385
|
if (!disableAutoScroll && messagesEndRef.current) {
|
|
34386
34386
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
34387
34387
|
}
|
|
34388
34388
|
}, [onWrite, disableAutoScroll]);
|
|
34389
|
-
var ctxCache =
|
|
34389
|
+
var ctxCache = React.useMemo(function () {
|
|
34390
34390
|
return new MiddlewareContextFactory({
|
|
34391
34391
|
send: handleSend,
|
|
34392
34392
|
write: handleWrite,
|
|
@@ -34502,26 +34502,74 @@ var ServerOffline = function () {
|
|
|
34502
34502
|
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" })] }));
|
|
34503
34503
|
};
|
|
34504
34504
|
|
|
34505
|
-
|
|
34505
|
+
/**
|
|
34506
|
+
* Generates the [cssVariableName, value] pairs for a theme, e.g.
|
|
34507
|
+
* ["--xapp-primary-color", "#0096d3"].
|
|
34508
|
+
*/
|
|
34509
|
+
function themeVariables(theme) {
|
|
34506
34510
|
var _a, _b, _c, _d, _e;
|
|
34507
|
-
return
|
|
34508
|
-
}
|
|
34509
|
-
function WidgetStylesheet(props) {
|
|
34510
|
-
var theme = props.theme;
|
|
34511
|
-
var stylesContent = buildStyleContent(theme);
|
|
34512
|
-
return require$$0.jsx("style", { children: stylesContent });
|
|
34511
|
+
return withPrefix("--xapp-", union(single("primary-color", theme === null || theme === void 0 ? void 0 : theme.primaryColor), withPrefix("widget-", union(getSize(theme === null || theme === void 0 ? void 0 : theme.size), getMargins(theme === null || theme === void 0 ? void 0 : theme.margin), getBorderStyle(theme === null || theme === void 0 ? void 0 : theme.border), getZIndex(theme === null || theme === void 0 ? void 0 : theme.zIndex))), getChatButtonStyle(theme === null || theme === void 0 ? void 0 : theme.chatButton), withPrefix("header-", getHeaderStyle(theme === null || theme === void 0 ? void 0 : theme.header)), withPrefix("footer-", getFooterStyle(theme === null || theme === void 0 ? void 0 : theme.footer)), withPrefix("content-", union(getBackgroundStyle((_a = theme === null || theme === void 0 ? void 0 : theme.content) === null || _a === void 0 ? void 0 : _a.background))), withPrefix("messages-", getMessagesStyle(theme === null || theme === void 0 ? void 0 : theme.messages)), withPrefix("text-typing-status-", getTextStyle((_b = theme === null || theme === void 0 ? void 0 : theme.textTypingStatus) === null || _b === void 0 ? void 0 : _b.text)), withPrefix("send-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.sendButton)), withPrefix("menu-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.menuButton)), withPrefix("menu-", getMenuStyle(theme === null || theme === void 0 ? void 0 : theme.menu)), withPrefix("refresh-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.refreshButton)), withPrefix("minimize-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.minimizeButton)), withPrefix("cancel-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.cancelButton)), withPrefix("carousel-", union(withPrefix("title-", getTextStyle((_c = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _c === void 0 ? void 0 : _c.title)), withPrefix("subtitle-", getTextStyle((_d = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _d === void 0 ? void 0 : _d.subtitle)), withPrefix("action-", getButtonStyle((_e = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _e === void 0 ? void 0 : _e.button)))), withPrefix("input-", getInputStyle(theme === null || theme === void 0 ? void 0 : theme.input)), withPrefix("cta-", getCtaStyle(theme === null || theme === void 0 ? void 0 : theme.cta)), withPrefix("action-bar-", getActionBarStyle(theme === null || theme === void 0 ? void 0 : theme.actionBar))));
|
|
34513
34512
|
}
|
|
34514
|
-
|
|
34513
|
+
/**
|
|
34514
|
+
* Collects the defined theme CSS variables as [name, value] entries, skipping
|
|
34515
|
+
* empty values.
|
|
34516
|
+
*/
|
|
34517
|
+
function buildStyleVariables(theme) {
|
|
34518
|
+
var entries = [];
|
|
34519
|
+
var gen = themeVariables(theme);
|
|
34515
34520
|
var result = gen.next();
|
|
34516
|
-
var res = "";
|
|
34517
34521
|
while (result.done === false) {
|
|
34518
34522
|
var _a = result.value, key = _a[0], value = _a[1];
|
|
34519
34523
|
if (value !== undefined && value !== null && value !== "") {
|
|
34520
|
-
|
|
34524
|
+
entries.push([key, value]);
|
|
34521
34525
|
}
|
|
34522
34526
|
result = gen.next();
|
|
34523
34527
|
}
|
|
34524
|
-
return
|
|
34528
|
+
return entries;
|
|
34529
|
+
}
|
|
34530
|
+
// All instances apply their theme variables to the same target (:root), so a
|
|
34531
|
+
// per-variable ref-count ensures an unmounting instance only removes a variable
|
|
34532
|
+
// when no other mounted instance still relies on it.
|
|
34533
|
+
var appliedVariableCounts = new Map();
|
|
34534
|
+
function applyThemeVariables(entries) {
|
|
34535
|
+
var _a;
|
|
34536
|
+
var root = document.documentElement;
|
|
34537
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
34538
|
+
var _b = entries_1[_i], key = _b[0], value = _b[1];
|
|
34539
|
+
root.style.setProperty(key, value);
|
|
34540
|
+
appliedVariableCounts.set(key, ((_a = appliedVariableCounts.get(key)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
34541
|
+
}
|
|
34542
|
+
}
|
|
34543
|
+
function removeThemeVariables(entries) {
|
|
34544
|
+
var _a;
|
|
34545
|
+
var root = document.documentElement;
|
|
34546
|
+
for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
|
|
34547
|
+
var key = entries_2[_i][0];
|
|
34548
|
+
var remaining = ((_a = appliedVariableCounts.get(key)) !== null && _a !== void 0 ? _a : 1) - 1;
|
|
34549
|
+
if (remaining <= 0) {
|
|
34550
|
+
appliedVariableCounts.delete(key);
|
|
34551
|
+
root.style.removeProperty(key);
|
|
34552
|
+
}
|
|
34553
|
+
else {
|
|
34554
|
+
appliedVariableCounts.set(key, remaining);
|
|
34555
|
+
}
|
|
34556
|
+
}
|
|
34557
|
+
}
|
|
34558
|
+
function WidgetStylesheet(props) {
|
|
34559
|
+
var theme = props.theme;
|
|
34560
|
+
// Apply the theme as CSS custom properties on :root via the CSSOM instead of
|
|
34561
|
+
// injecting a <style> tag: setProperty() is not governed by CSP style-src, so
|
|
34562
|
+
// the widget themes correctly under a strict policy (style-src 'self', no
|
|
34563
|
+
// 'unsafe-inline') without needing a nonce.
|
|
34564
|
+
var entriesKey = JSON.stringify(buildStyleVariables(theme));
|
|
34565
|
+
// Keyed on the resolved variables (not the theme reference) so a caller passing
|
|
34566
|
+
// an inline theme object doesn't re-fire the effect on every render.
|
|
34567
|
+
React.useLayoutEffect(function () {
|
|
34568
|
+
var entries = JSON.parse(entriesKey);
|
|
34569
|
+
applyThemeVariables(entries);
|
|
34570
|
+
return function () { return removeThemeVariables(entries); };
|
|
34571
|
+
}, [entriesKey]);
|
|
34572
|
+
return null;
|
|
34525
34573
|
}
|
|
34526
34574
|
function withPrefix(prefix, gen) {
|
|
34527
34575
|
var result;
|
|
@@ -34859,13 +34907,13 @@ var safeStringify = function (arg) {
|
|
|
34859
34907
|
};
|
|
34860
34908
|
var ErrorOverlay = function (_a) {
|
|
34861
34909
|
var enableErrorOverlay = _a.enableErrorOverlay;
|
|
34862
|
-
var _b =
|
|
34863
|
-
var _c =
|
|
34864
|
-
var _d =
|
|
34865
|
-
var _e =
|
|
34866
|
-
var _f =
|
|
34910
|
+
var _b = React.useState([]), errors = _b[0], setErrors = _b[1];
|
|
34911
|
+
var _c = React.useState(false), isMinimized = _c[0], setIsMinimized = _c[1];
|
|
34912
|
+
var _d = React.useState(true), isVisible = _d[0], setIsVisible = _d[1];
|
|
34913
|
+
var _e = React.useState(false), isEnabled = _e[0], setIsEnabled = _e[1];
|
|
34914
|
+
var _f = React.useState("bottom"), position = _f[0], setPosition = _f[1];
|
|
34867
34915
|
// Check if error overlay should be enabled and load position
|
|
34868
|
-
|
|
34916
|
+
React.useEffect(function () {
|
|
34869
34917
|
var _a;
|
|
34870
34918
|
var checkEnabled = function () {
|
|
34871
34919
|
var _a;
|
|
@@ -34904,7 +34952,7 @@ var ErrorOverlay = function (_a) {
|
|
|
34904
34952
|
console.log("[ErrorOverlay] Component mounted, enabled:", enabled, "position:", savedPosition || "bottom");
|
|
34905
34953
|
}, [enableErrorOverlay]);
|
|
34906
34954
|
// Define addError with useCallback to prevent stale closures
|
|
34907
|
-
var addError =
|
|
34955
|
+
var addError = React.useCallback(function (error) {
|
|
34908
34956
|
console.log("[ErrorOverlay] Adding error:", error);
|
|
34909
34957
|
setErrors(function (prev) {
|
|
34910
34958
|
var timestamp = new Date().toISOString();
|
|
@@ -34923,7 +34971,7 @@ var ErrorOverlay = function (_a) {
|
|
|
34923
34971
|
return updated.slice(-50);
|
|
34924
34972
|
});
|
|
34925
34973
|
}, []);
|
|
34926
|
-
|
|
34974
|
+
React.useEffect(function () {
|
|
34927
34975
|
if (!isEnabled) {
|
|
34928
34976
|
console.log("[ErrorOverlay] Not enabled, skipping error interception");
|
|
34929
34977
|
return undefined;
|
|
@@ -35073,12 +35121,12 @@ var ErrorOverlay = function (_a) {
|
|
|
35073
35121
|
|
|
35074
35122
|
var WsButton = function (_a) {
|
|
35075
35123
|
var button = _a.button, onPress = _a.onPress;
|
|
35076
|
-
var handleClick =
|
|
35124
|
+
var handleClick = React.useCallback(function () {
|
|
35077
35125
|
if (button.pressBehavior !== "disabled" && !button.isPressed) {
|
|
35078
35126
|
onPress(button.id);
|
|
35079
35127
|
}
|
|
35080
35128
|
}, [button.pressBehavior, button.isPressed, button.id, onPress]);
|
|
35081
|
-
var className =
|
|
35129
|
+
var className = React.useMemo(function () {
|
|
35082
35130
|
var classes = ["ws-button"];
|
|
35083
35131
|
if (button.pressBehavior === "disabled" || button.isPressed) {
|
|
35084
35132
|
classes.push("ws-button--disabled");
|
|
@@ -35088,7 +35136,7 @@ var WsButton = function (_a) {
|
|
|
35088
35136
|
}
|
|
35089
35137
|
return classes.join(" ");
|
|
35090
35138
|
}, [button.pressBehavior, button.isPressed]);
|
|
35091
|
-
var containerClassName =
|
|
35139
|
+
var containerClassName = React.useMemo(function () {
|
|
35092
35140
|
var classes = ["ws-button-container"];
|
|
35093
35141
|
if (button.isDismissing) {
|
|
35094
35142
|
classes.push("ws-button-container--dismissing");
|
|
@@ -35622,10 +35670,10 @@ function createStaticStore(state) {
|
|
|
35622
35670
|
|
|
35623
35671
|
var StaticChatWidgetContainer = function (props) {
|
|
35624
35672
|
var state = props.state;
|
|
35625
|
-
var store =
|
|
35673
|
+
var store = React.useMemo(function () {
|
|
35626
35674
|
return createStaticStore(state);
|
|
35627
35675
|
}, [state]);
|
|
35628
|
-
var config =
|
|
35676
|
+
var config = React.useMemo(function () {
|
|
35629
35677
|
return __assign(__assign({}, props.config), { connection: {
|
|
35630
35678
|
serverUrl: "",
|
|
35631
35679
|
type: "local",
|
|
@@ -35636,7 +35684,7 @@ var StaticChatWidgetContainer = function (props) {
|
|
|
35636
35684
|
|
|
35637
35685
|
var StaticMessagesChatWidgetContainer = function (props) {
|
|
35638
35686
|
var messages = props.messages;
|
|
35639
|
-
var state =
|
|
35687
|
+
var state = React.useMemo(function () {
|
|
35640
35688
|
return createStateFromMessages(messages);
|
|
35641
35689
|
}, [messages]);
|
|
35642
35690
|
return require$$0.jsx(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config, disableAutoScroll: props.disableAutoScroll, preview: props.preview });
|
|
@@ -35720,7 +35768,7 @@ var ChatWidgetPreview = function (props) {
|
|
|
35720
35768
|
var _a;
|
|
35721
35769
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "preview";
|
|
35722
35770
|
// Memoize preview message conversion to avoid recalculating on every render
|
|
35723
|
-
var previewChatDetails =
|
|
35771
|
+
var previewChatDetails = React.useMemo(function () {
|
|
35724
35772
|
return convertPreviewMessagesToChatDetails(props.previewMessages || [], props.config);
|
|
35725
35773
|
}, [props.previewMessages, props.config]);
|
|
35726
35774
|
return (require$$0.jsx(StaticMessagesChatWidgetContainer, { messages: previewChatDetails, mode: mode, config: props.config, disableAutoScroll: props.disableAutoScroll, preview: true }));
|
|
@@ -35731,11 +35779,11 @@ var ChatWidgetPreview = function (props) {
|
|
|
35731
35779
|
var ChatWidgetConnected = function (props) {
|
|
35732
35780
|
var _a;
|
|
35733
35781
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
35734
|
-
var _b =
|
|
35735
|
-
var _c =
|
|
35736
|
-
var _d =
|
|
35782
|
+
var _b = React.useState(props.config), rawConfig = _b[0], setRawConfig = _b[1];
|
|
35783
|
+
var _c = React.useState(!!props.getConfig), configLoading = _c[0], setConfigLoading = _c[1];
|
|
35784
|
+
var _d = React.useState(), configError = _d[0], setConfigError = _d[1];
|
|
35737
35785
|
// Load config from callback if provided
|
|
35738
|
-
|
|
35786
|
+
React.useEffect(function () {
|
|
35739
35787
|
var cancelled = false;
|
|
35740
35788
|
if (props.getConfig) {
|
|
35741
35789
|
setConfigLoading(true);
|
|
@@ -35769,12 +35817,12 @@ var ChatWidgetConnected = function (props) {
|
|
|
35769
35817
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35770
35818
|
}, [props.getConfig, props.config]);
|
|
35771
35819
|
var connection = useConnectionInfo(rawConfig);
|
|
35772
|
-
var config =
|
|
35820
|
+
var config = React.useMemo(function () {
|
|
35773
35821
|
var _a;
|
|
35774
35822
|
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 }));
|
|
35775
35823
|
}, [connection, rawConfig]);
|
|
35776
35824
|
var token = reactRedux.useSelector(function (state) { return state.connection.token; });
|
|
35777
|
-
var options =
|
|
35825
|
+
var options = React.useMemo(function () {
|
|
35778
35826
|
var configurableMessages = getConfigurableMessages();
|
|
35779
35827
|
if ((rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.configurableMessages) &&
|
|
35780
35828
|
Array.isArray(rawConfig.configurableMessages.items) &&
|
|
@@ -35824,7 +35872,7 @@ var ChatWidgetUI = function (props) {
|
|
|
35824
35872
|
// From Redux
|
|
35825
35873
|
var chatState = reactRedux.useSelector(function (state) { return state; });
|
|
35826
35874
|
// Refresh modalReference
|
|
35827
|
-
var modalRef =
|
|
35875
|
+
var modalRef = React.useRef({});
|
|
35828
35876
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
35829
35877
|
var dockedMode = mode === "docked";
|
|
35830
35878
|
var staticMode = mode === "static";
|
|
@@ -35855,24 +35903,24 @@ var ChatWidgetUI = function (props) {
|
|
|
35855
35903
|
var autoOpenOnWidthMatch = !isNaN(autoOpenOnWidthValue) && window.innerWidth >= autoOpenOnWidthValue;
|
|
35856
35904
|
// When autoOpenOnWidth is configured, use width check instead of persisted visible state
|
|
35857
35905
|
// to prevent greeting requests on viewports below the threshold
|
|
35858
|
-
var _14 =
|
|
35906
|
+
var _14 = React.useState((!canMinimize && !canCancel) ||
|
|
35859
35907
|
// !!get("visible") ||
|
|
35860
35908
|
(!isNaN(autoOpenOnWidthValue) ? autoOpenOnWidthMatch : chatState.visuals.visible)), visible = _14[0], setVisibleState = _14[1];
|
|
35861
|
-
var _15 =
|
|
35909
|
+
var _15 = React.useState(false); _15[0]; var setTypingState = _15[1]; // false initially - state kept for potential external observers
|
|
35862
35910
|
// Ref to track typing state for use in timeout callbacks
|
|
35863
|
-
var typingRef =
|
|
35911
|
+
var typingRef = React.useRef(false);
|
|
35864
35912
|
// Timeout ref for debouncing "stop typing" events
|
|
35865
|
-
var stopTypingTimeoutRef =
|
|
35913
|
+
var stopTypingTimeoutRef = React.useRef(null);
|
|
35866
35914
|
// Track whether autoOpenOnWidth has already fired so it doesn't re-open after user closes
|
|
35867
|
-
var autoOpenFiredRef =
|
|
35868
|
-
var chatServer =
|
|
35915
|
+
var autoOpenFiredRef = React.useRef(autoOpenOnWidthMatch);
|
|
35916
|
+
var chatServer = React.useContext(ChatServerContext);
|
|
35869
35917
|
var patternsConfig = (_p = (_o = props.config) === null || _o === void 0 ? void 0 : _o.autoOpenOnPattern) === null || _p === void 0 ? void 0 : _p.patterns;
|
|
35870
35918
|
var currentUrl = window.location.href;
|
|
35871
35919
|
var patternExist = patternsConfig && patternsConfig.length > 0;
|
|
35872
35920
|
var patternMatches = patternsConfig === null || patternsConfig === void 0 ? void 0 : patternsConfig.some(function (pattern) { return currentUrl.includes(pattern); });
|
|
35873
35921
|
var configWidth = (_r = (_q = props.config) === null || _q === void 0 ? void 0 : _q.autoOpenOnPattern) === null || _r === void 0 ? void 0 : _r.minimumWidth;
|
|
35874
35922
|
var currentWidth = window.innerWidth;
|
|
35875
|
-
var setVisible =
|
|
35923
|
+
var setVisible = React.useCallback(function (newVisible) {
|
|
35876
35924
|
if (staticMode || previewMode) {
|
|
35877
35925
|
return;
|
|
35878
35926
|
}
|
|
@@ -35882,7 +35930,7 @@ var ChatWidgetUI = function (props) {
|
|
|
35882
35930
|
visible: newVisible,
|
|
35883
35931
|
}));
|
|
35884
35932
|
}, [innerDispatch, staticMode, previewMode]);
|
|
35885
|
-
|
|
35933
|
+
React.useEffect(function () {
|
|
35886
35934
|
var _a, _b;
|
|
35887
35935
|
var handleKeyDown = function (event) {
|
|
35888
35936
|
var body = document.getElementsByTagName("body")[0];
|
|
@@ -35905,8 +35953,8 @@ var ChatWidgetUI = function (props) {
|
|
|
35905
35953
|
};
|
|
35906
35954
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35907
35955
|
}, []);
|
|
35908
|
-
var _16 =
|
|
35909
|
-
|
|
35956
|
+
var _16 = React.useState(!document.hidden), isTabVisible = _16[0], setIsTabVisible = _16[1];
|
|
35957
|
+
React.useEffect(function () {
|
|
35910
35958
|
var handleVisibilityChange = function () {
|
|
35911
35959
|
setIsTabVisible(!document.hidden);
|
|
35912
35960
|
};
|
|
@@ -35915,7 +35963,7 @@ var ChatWidgetUI = function (props) {
|
|
|
35915
35963
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
35916
35964
|
};
|
|
35917
35965
|
}, []);
|
|
35918
|
-
|
|
35966
|
+
React.useEffect(function () {
|
|
35919
35967
|
// Too early?
|
|
35920
35968
|
if (!chatServer) {
|
|
35921
35969
|
log("Tab visibility changed but no chatServer yet");
|
|
@@ -35931,7 +35979,7 @@ var ChatWidgetUI = function (props) {
|
|
|
35931
35979
|
}
|
|
35932
35980
|
}, [chatServer, innerDispatch, isTabVisible]);
|
|
35933
35981
|
// Handle beforeunload to notify router when user is leaving
|
|
35934
|
-
|
|
35982
|
+
React.useEffect(function () {
|
|
35935
35983
|
if (!chatServer) {
|
|
35936
35984
|
return undefined;
|
|
35937
35985
|
}
|
|
@@ -35946,7 +35994,7 @@ var ChatWidgetUI = function (props) {
|
|
|
35946
35994
|
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
35947
35995
|
};
|
|
35948
35996
|
}, [chatServer]);
|
|
35949
|
-
|
|
35997
|
+
React.useEffect(function () {
|
|
35950
35998
|
// For reopen widget after move on same window
|
|
35951
35999
|
// if (get("opened")) {
|
|
35952
36000
|
// setVisible(true);
|
|
@@ -35977,7 +36025,7 @@ var ChatWidgetUI = function (props) {
|
|
|
35977
36025
|
mode,
|
|
35978
36026
|
autoOpenOnWidthMatch,
|
|
35979
36027
|
]);
|
|
35980
|
-
var stopTyping =
|
|
36028
|
+
var stopTyping = React.useCallback(function () {
|
|
35981
36029
|
if (!typingRef.current)
|
|
35982
36030
|
return;
|
|
35983
36031
|
// Clear the timeout if it exists
|
|
@@ -35989,7 +36037,7 @@ var ChatWidgetUI = function (props) {
|
|
|
35989
36037
|
setTypingState(false);
|
|
35990
36038
|
typingRef.current = false;
|
|
35991
36039
|
}, [dispatch]);
|
|
35992
|
-
var handleOnChange =
|
|
36040
|
+
var handleOnChange = React.useCallback(function () {
|
|
35993
36041
|
// Send "typing" event only on first keystroke
|
|
35994
36042
|
if (!typingRef.current) {
|
|
35995
36043
|
dispatch(sendTyping(true));
|
|
@@ -36123,9 +36171,9 @@ var ChatWidgetUI = function (props) {
|
|
|
36123
36171
|
}));
|
|
36124
36172
|
}
|
|
36125
36173
|
// Action Bar state and handlers
|
|
36126
|
-
var _17 =
|
|
36127
|
-
var _18 =
|
|
36128
|
-
var handleFormButtonClick =
|
|
36174
|
+
var _17 = React.useState(false), formModalOpen = _17[0], setFormModalOpen = _17[1];
|
|
36175
|
+
var _18 = React.useState(null), activeFormConfig = _18[0], setActiveFormConfig = _18[1];
|
|
36176
|
+
var handleFormButtonClick = React.useCallback(function (formButton) {
|
|
36129
36177
|
// If form-widget is configured, use its openForm API
|
|
36130
36178
|
// The form-widget script should already be pre-loaded
|
|
36131
36179
|
var options = formButton.preselectChipLabel
|
|
@@ -36140,7 +36188,7 @@ var ChatWidgetUI = function (props) {
|
|
|
36140
36188
|
}
|
|
36141
36189
|
});
|
|
36142
36190
|
}, []);
|
|
36143
|
-
var handleFormModalClose =
|
|
36191
|
+
var handleFormModalClose = React.useCallback(function () {
|
|
36144
36192
|
setFormModalOpen(false);
|
|
36145
36193
|
setActiveFormConfig(null);
|
|
36146
36194
|
}, []);
|
|
@@ -36195,21 +36243,21 @@ var ChatWidgetUI = function (props) {
|
|
|
36195
36243
|
// Disable greeting in preview mode
|
|
36196
36244
|
useGreeting(!isOffline && !props.preChatFormEnabled && visible && !previewMode);
|
|
36197
36245
|
var connectionStatus = chatState.connection.connectionStatus;
|
|
36198
|
-
|
|
36246
|
+
React.useEffect(function () {
|
|
36199
36247
|
if (onConnectionStatusChange) {
|
|
36200
36248
|
onConnectionStatusChange(connectionStatus);
|
|
36201
36249
|
}
|
|
36202
36250
|
}, [connectionStatus, onConnectionStatusChange]);
|
|
36203
36251
|
useExternalScript((_t = props.config) === null || _t === void 0 ? void 0 : _t.middlewareUrl);
|
|
36204
36252
|
// Pre-load form-widget script if formWidgetKey is provided
|
|
36205
|
-
|
|
36253
|
+
React.useEffect(function () {
|
|
36206
36254
|
if (config === null || config === void 0 ? void 0 : config.formWidgetKey) {
|
|
36207
36255
|
preloadFormWidgetScript(config.formWidgetKey);
|
|
36208
36256
|
}
|
|
36209
36257
|
}, [config === null || config === void 0 ? void 0 : config.formWidgetKey]);
|
|
36210
36258
|
// Set body attribute when actionBar is enabled (used by CSS to hide form-widget side button on mobile)
|
|
36211
36259
|
// Uses reference counting to handle multiple widget instances
|
|
36212
|
-
|
|
36260
|
+
React.useEffect(function () {
|
|
36213
36261
|
if (actionBarEnabled) {
|
|
36214
36262
|
// Increment reference count
|
|
36215
36263
|
var currentCount = parseInt(document.body.getAttribute("data-xapp-action-bar-count") || "0", 10);
|
|
@@ -36912,7 +36960,7 @@ var ChatWidgetConnectedContainer = function (props) {
|
|
|
36912
36960
|
var _a, _b, _c, _d, _e, _f;
|
|
36913
36961
|
var messageMiddleware = useStandardMiddleware();
|
|
36914
36962
|
var connection = useServerConfig(props.config);
|
|
36915
|
-
var chatStore =
|
|
36963
|
+
var chatStore = React.useMemo(function () {
|
|
36916
36964
|
var _a, _b, _c, _d, _e;
|
|
36917
36965
|
return createChatStore({
|
|
36918
36966
|
connection: connection,
|
|
@@ -36944,7 +36992,7 @@ var ChatWidgetContainer = function (props) {
|
|
|
36944
36992
|
return require$$0.jsx(ChatWidgetConnectedContainer, __assign({}, props));
|
|
36945
36993
|
};
|
|
36946
36994
|
|
|
36947
|
-
exports.React =
|
|
36995
|
+
exports.React = React;
|
|
36948
36996
|
exports.ActionBar = ActionBar;
|
|
36949
36997
|
exports.ActionBarPreview = ActionBarPreview;
|
|
36950
36998
|
exports.ActionButton = ActionButton;
|