@xapp/chat-widget 1.29.2 → 1.32.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/ChatMedia/ChatMedia.d.ts +4 -1
- package/dist/components/Input/Input.d.ts +5 -5
- package/dist/components/Input/Input.stories.d.ts +2 -1
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/SendButton/SendButton.d.ts +1 -0
- package/dist/components/Suggestions/Suggestions.d.ts +5 -4
- package/dist/components/Suggestions/Suggestions.stories.d.ts +0 -1
- package/dist/components/Suggestions/data.d.ts +2 -23
- package/dist/components/WidgetStylesheet/WidgetStylesheet.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.es.js +1123 -717
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1224 -818
- package/dist/index.js.map +1 -1
- package/dist/store/ChatStore.d.ts +1 -1
- package/dist/storybook/RichTextValues.d.ts +2 -0
- package/dist/utils/useDimensions.d.ts +2 -2
- package/dist/utils/useSuggestions.d.ts +4 -4
- package/dist/utils/useSuggestionsFetch.d.ts +2 -19
- package/package.json +25 -24
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useMemo, useContext, useCallback, useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
1
|
+
import React$1, { createContext, useMemo, useContext, useCallback, useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
2
2
|
export { default as React } from 'react';
|
|
3
3
|
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
4
4
|
import { createStore as createStore$1, applyMiddleware, compose } from 'redux';
|
|
@@ -11,25 +11,9 @@ var ActionButton = function (props) {
|
|
|
11
11
|
props.onClick(props.label);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
return (React.createElement("button", { type: props.type, className: "action-button "
|
|
14
|
+
return (React$1.createElement("button", { type: props.type, className: "action-button ".concat(props.addClass), onClick: handleClick }, props.label));
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
var paramsObj = {};
|
|
18
|
-
// todo: read only from xappScriptNode?
|
|
19
|
-
for (var _i = 0, _a = document.scripts; _i < _a.length; _i++) {
|
|
20
|
-
var script = _a[_i];
|
|
21
|
-
if (!script.src) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
var params = script.src.split("?");
|
|
25
|
-
if (params.length < 2) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
var searchParams = new URLSearchParams(params[1]);
|
|
29
|
-
searchParams.forEach(function (value, key) {
|
|
30
|
-
paramsObj[key] = value;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
17
|
var defaultServerUrl = process.env.SERVER_URL;
|
|
34
18
|
process.env.ACCOUNT_KEY;
|
|
35
19
|
var ChatConfigContext = createContext(null);
|
|
@@ -88,7 +72,7 @@ var __assign = function() {
|
|
|
88
72
|
return __assign.apply(this, arguments);
|
|
89
73
|
};
|
|
90
74
|
|
|
91
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
75
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
92
76
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
93
77
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
94
78
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -98,7 +82,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
98
82
|
});
|
|
99
83
|
}
|
|
100
84
|
|
|
101
|
-
function __generator(thisArg, body) {
|
|
85
|
+
function __generator$1(thisArg, body) {
|
|
102
86
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
103
87
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
104
88
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -126,7 +110,7 @@ function __generator(thisArg, body) {
|
|
|
126
110
|
}
|
|
127
111
|
}
|
|
128
112
|
|
|
129
|
-
function __spreadArray(to, from, pack) {
|
|
113
|
+
function __spreadArray$1(to, from, pack) {
|
|
130
114
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
131
115
|
if (ar || !(i in from)) {
|
|
132
116
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -1466,14 +1450,14 @@ function log() {
|
|
|
1466
1450
|
args[_i] = arguments[_i];
|
|
1467
1451
|
}
|
|
1468
1452
|
// TODO: only log in debug
|
|
1469
|
-
console.log.apply(console, __spreadArray([getCurrentDateString()], args, false));
|
|
1453
|
+
console.log.apply(console, __spreadArray$1([getCurrentDateString()], args, false));
|
|
1470
1454
|
}
|
|
1471
1455
|
function err() {
|
|
1472
1456
|
var args = [];
|
|
1473
1457
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1474
1458
|
args[_i] = arguments[_i];
|
|
1475
1459
|
}
|
|
1476
|
-
console.error.apply(console, __spreadArray([getCurrentDateString()], args, false));
|
|
1460
|
+
console.error.apply(console, __spreadArray$1([getCurrentDateString()], args, false));
|
|
1477
1461
|
}
|
|
1478
1462
|
var logOnce = function (key) {
|
|
1479
1463
|
var args = [];
|
|
@@ -1488,8 +1472,8 @@ var logOnce = function (key) {
|
|
|
1488
1472
|
};
|
|
1489
1473
|
|
|
1490
1474
|
function getVisitorSvg() {
|
|
1491
|
-
return (React.createElement("svg", { width: "16", height: "19", viewBox: "0 0 16 19" },
|
|
1492
|
-
React.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" })));
|
|
1475
|
+
return (React$1.createElement("svg", { width: "16", height: "19", viewBox: "0 0 16 19" },
|
|
1476
|
+
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" })));
|
|
1493
1477
|
}
|
|
1494
1478
|
var Avatar = function (props) {
|
|
1495
1479
|
var _a, _b;
|
|
@@ -1503,20 +1487,20 @@ var Avatar = function (props) {
|
|
|
1503
1487
|
if (avatarPath) {
|
|
1504
1488
|
// absolute or relative url (chat server may send relative, if it hosts the file)
|
|
1505
1489
|
if (avatarPath.startsWith("http")) {
|
|
1506
|
-
style.backgroundImage = "url('"
|
|
1490
|
+
style.backgroundImage = "url('".concat(avatarPath, "')");
|
|
1507
1491
|
}
|
|
1508
1492
|
else if (ctx === null || ctx === void 0 ? void 0 : ctx.assetUrl) {
|
|
1509
|
-
style.backgroundImage = "url('"
|
|
1493
|
+
style.backgroundImage = "url('".concat(ctx === null || ctx === void 0 ? void 0 : ctx.assetUrl, "/").concat(avatarPath, "')");
|
|
1510
1494
|
}
|
|
1511
1495
|
style.backgroundColor = "none";
|
|
1512
1496
|
}
|
|
1513
|
-
(_a = style.backgroundImage) !== null && _a !== void 0 ? _a : (style.backgroundImage = "url('"
|
|
1497
|
+
(_a = style.backgroundImage) !== null && _a !== void 0 ? _a : (style.backgroundImage = "url('".concat((_b = ctx === null || ctx === void 0 ? void 0 : ctx.env) === null || _b === void 0 ? void 0 : _b.avatarUrl, "')"));
|
|
1514
1498
|
}
|
|
1515
1499
|
else {
|
|
1516
1500
|
child = getVisitorSvg();
|
|
1517
1501
|
}
|
|
1518
1502
|
var hasImage = !!style.backgroundImage || !!child;
|
|
1519
|
-
return (React.createElement("div", { className: "avatar "
|
|
1503
|
+
return (React$1.createElement("div", { className: "avatar ".concat(agentAva ? "avatar--agent" : "avatar--visitor", " ").concat(!hasImage ? "avatar--empty" : ""), style: style, title: entity ? entity.display_name : "Agent" }, child));
|
|
1520
1504
|
};
|
|
1521
1505
|
|
|
1522
1506
|
/**
|
|
@@ -1543,10 +1527,10 @@ var OptionalLink = function (props) {
|
|
|
1543
1527
|
}
|
|
1544
1528
|
}, [url, onOpen]);
|
|
1545
1529
|
if (url) {
|
|
1546
|
-
return (React.createElement("div", { onClick: handleOpenUrl, className: className }, props.children));
|
|
1530
|
+
return (React$1.createElement("div", { onClick: handleOpenUrl, className: className }, props.children));
|
|
1547
1531
|
}
|
|
1548
1532
|
else {
|
|
1549
|
-
return (React.createElement("div", { onClick: props.onClick, className: className }, props.children));
|
|
1533
|
+
return (React$1.createElement("div", { onClick: props.onClick, className: className }, props.children));
|
|
1550
1534
|
}
|
|
1551
1535
|
};
|
|
1552
1536
|
|
|
@@ -1566,18 +1550,18 @@ var ActionItem = function (props) {
|
|
|
1566
1550
|
onExecute(item.title, item.token);
|
|
1567
1551
|
}
|
|
1568
1552
|
}, [item, onExecute, onButtonClick]);
|
|
1569
|
-
var className = "xappw-chat-action-item "
|
|
1570
|
-
return (React.createElement(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl }, props.children));
|
|
1553
|
+
var className = "xappw-chat-action-item ".concat(singleButton ? "xappw-chat-action-item--action" : "", " ").concat(props.className);
|
|
1554
|
+
return (React$1.createElement(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl }, props.children));
|
|
1571
1555
|
};
|
|
1572
1556
|
|
|
1573
1557
|
var ChatImage = function (props) {
|
|
1574
1558
|
var cleanUrl = props.imageUrl.replace(/'/g, "%27");
|
|
1575
|
-
var content = React.createElement("div", { className: "chat-card-img__content", style: { backgroundImage: "url("
|
|
1559
|
+
var content = React$1.createElement("div", { className: "chat-card-img__content", style: { backgroundImage: "url(".concat(cleanUrl, ")") } });
|
|
1576
1560
|
if (!props.imageActionUrl) {
|
|
1577
|
-
return (React.createElement("div", { className: "chat-card-img" }, content));
|
|
1561
|
+
return (React$1.createElement("div", { className: "chat-card-img" }, content));
|
|
1578
1562
|
}
|
|
1579
1563
|
else {
|
|
1580
|
-
return (React.createElement("a", { href: props.imageActionUrl, target: "_blank", rel: "noopener noreferrer", className: "chat-card-img" }, content));
|
|
1564
|
+
return (React$1.createElement("a", { href: props.imageActionUrl, target: "_blank", rel: "noopener noreferrer", className: "chat-card-img" }, content));
|
|
1581
1565
|
}
|
|
1582
1566
|
};
|
|
1583
1567
|
|
|
@@ -1588,13 +1572,13 @@ var ActionItemImage = function (props) {
|
|
|
1588
1572
|
var itemUrl = getItemUrl(item);
|
|
1589
1573
|
if (item.imageUrl) {
|
|
1590
1574
|
var imageActionUrl = !singleButton ? item.imageActionUrl : null;
|
|
1591
|
-
return (React.createElement("div", { className: props.className },
|
|
1592
|
-
React.createElement(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl })));
|
|
1575
|
+
return (React$1.createElement("div", { className: props.className },
|
|
1576
|
+
React$1.createElement(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl })));
|
|
1593
1577
|
}
|
|
1594
1578
|
else if (props.emptyImageVisible) {
|
|
1595
|
-
return (React.createElement("div", { className: props.className }));
|
|
1579
|
+
return (React$1.createElement("div", { className: props.className }));
|
|
1596
1580
|
}
|
|
1597
|
-
return React.createElement(React.Fragment, null);
|
|
1581
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
1598
1582
|
};
|
|
1599
1583
|
|
|
1600
1584
|
var ChatActionButtonInner = function (props) {
|
|
@@ -1602,44 +1586,44 @@ var ChatActionButtonInner = function (props) {
|
|
|
1602
1586
|
var handleButton = useCallback(function () {
|
|
1603
1587
|
onClick(button);
|
|
1604
1588
|
}, [button, onClick]);
|
|
1605
|
-
return (React.createElement(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label }));
|
|
1589
|
+
return (React$1.createElement(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label }));
|
|
1606
1590
|
};
|
|
1607
|
-
var ChatActionButton = React.memo(ChatActionButtonInner);
|
|
1591
|
+
var ChatActionButton = React$1.memo(ChatActionButtonInner);
|
|
1608
1592
|
|
|
1609
1593
|
var ChatActionButtonsInner = function (props) {
|
|
1610
|
-
return (React.createElement("div", { className: "buttons-container " + (props.className || "") }, props.buttons.map(function (button, i) {
|
|
1611
|
-
return React.createElement(ChatActionButton, { button: button, onClick: props.onClick, key: i });
|
|
1594
|
+
return (React$1.createElement("div", { className: "buttons-container " + (props.className || "") }, props.buttons.map(function (button, i) {
|
|
1595
|
+
return React$1.createElement(ChatActionButton, { button: button, onClick: props.onClick, key: i });
|
|
1612
1596
|
})));
|
|
1613
1597
|
};
|
|
1614
|
-
var ChatActionButtons = React.memo(ChatActionButtonsInner);
|
|
1598
|
+
var ChatActionButtons = React$1.memo(ChatActionButtonsInner);
|
|
1615
1599
|
|
|
1616
1600
|
var CarouselItem = function (props) {
|
|
1617
1601
|
var _a;
|
|
1618
1602
|
var item = props.item;
|
|
1619
|
-
return (React.createElement(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
1620
|
-
React.createElement("div", { className: "chat-list-item" },
|
|
1621
|
-
React.createElement(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }),
|
|
1622
|
-
item.title && React.createElement("div", { className: "chat-list-item__title" },
|
|
1623
|
-
React.createElement("span", null, item.title)),
|
|
1624
|
-
item.subTitle && React.createElement("div", { className: "chat-list-item__subtitle" },
|
|
1625
|
-
React.createElement("span", null, item.subTitle)),
|
|
1626
|
-
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(ChatActionButtons, { className: "chat-list-item__actions", buttons: item.buttons, onClick: props.onButtonClick }))));
|
|
1603
|
+
return (React$1.createElement(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
1604
|
+
React$1.createElement("div", { className: "chat-list-item" },
|
|
1605
|
+
React$1.createElement(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }),
|
|
1606
|
+
item.title && React$1.createElement("div", { className: "chat-list-item__title" },
|
|
1607
|
+
React$1.createElement("span", null, item.title)),
|
|
1608
|
+
item.subTitle && React$1.createElement("div", { className: "chat-list-item__subtitle" },
|
|
1609
|
+
React$1.createElement("span", null, item.subTitle)),
|
|
1610
|
+
!!((_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 }))));
|
|
1627
1611
|
};
|
|
1628
1612
|
|
|
1629
1613
|
function getLeftArrowSvg() {
|
|
1630
|
-
return (React.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1631
|
-
React.createElement("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
1614
|
+
return (React$1.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1615
|
+
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" })));
|
|
1632
1616
|
}
|
|
1633
1617
|
var ChevronLeft = function (props) {
|
|
1634
|
-
return (React.createElement("div", { onClick: props.onClick, className: "chevron" }, getLeftArrowSvg()));
|
|
1618
|
+
return (React$1.createElement("div", { onClick: props.onClick, className: "chevron" }, getLeftArrowSvg()));
|
|
1635
1619
|
};
|
|
1636
1620
|
|
|
1637
1621
|
function getRightArrowSvg() {
|
|
1638
|
-
return (React.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1639
|
-
React.createElement("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
1622
|
+
return (React$1.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1623
|
+
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" })));
|
|
1640
1624
|
}
|
|
1641
1625
|
var ChevronRight = function (props) {
|
|
1642
|
-
return (React.createElement("div", { onClick: props.onClick, className: "chevron" }, getRightArrowSvg()));
|
|
1626
|
+
return (React$1.createElement("div", { onClick: props.onClick, className: "chevron" }, getRightArrowSvg()));
|
|
1643
1627
|
};
|
|
1644
1628
|
|
|
1645
1629
|
var Carousel = function (props) {
|
|
@@ -1677,19 +1661,19 @@ var Carousel = function (props) {
|
|
|
1677
1661
|
}
|
|
1678
1662
|
var hasImage = props.list.items.some(function (item) { return item.imageUrl; });
|
|
1679
1663
|
var listItems = props.list.items.map(function (item, itemIndex) {
|
|
1680
|
-
return (React.createElement("div", { className: "xappw-carousel-items__item", key: "item-key-"
|
|
1681
|
-
React.createElement(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
1664
|
+
return (React$1.createElement("div", { className: "xappw-carousel-items__item", key: "item-key-".concat(itemIndex) },
|
|
1665
|
+
React$1.createElement(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
1682
1666
|
});
|
|
1683
|
-
return (React.createElement("div", { className: "xappw-carousel" },
|
|
1684
|
-
React.createElement("div", { className: "xappw-carousel__prev" },
|
|
1685
|
-
React.createElement(ChevronLeft, { onClick: function () { return scrollMe(-1); } })),
|
|
1686
|
-
React.createElement("div", { ref: listRef, className: "xappw-carousel-items" }, listItems),
|
|
1687
|
-
React.createElement("div", { className: "xappw-carousel__next" },
|
|
1688
|
-
React.createElement(ChevronRight, { onClick: function () { return scrollMe(1); } }))));
|
|
1667
|
+
return (React$1.createElement("div", { className: "xappw-carousel" },
|
|
1668
|
+
React$1.createElement("div", { className: "xappw-carousel__prev" },
|
|
1669
|
+
React$1.createElement(ChevronLeft, { onClick: function () { return scrollMe(-1); } })),
|
|
1670
|
+
React$1.createElement("div", { ref: listRef, className: "xappw-carousel-items" }, listItems),
|
|
1671
|
+
React$1.createElement("div", { className: "xappw-carousel__next" },
|
|
1672
|
+
React$1.createElement(ChevronRight, { onClick: function () { return scrollMe(1); } }))));
|
|
1689
1673
|
};
|
|
1690
1674
|
|
|
1691
1675
|
function useDimensions() {
|
|
1692
|
-
var ref = useRef();
|
|
1676
|
+
var ref = useRef(null);
|
|
1693
1677
|
var _a = useState(), dimensions = _a[0], setDimensions = _a[1];
|
|
1694
1678
|
useLayoutEffect(function () {
|
|
1695
1679
|
var _a, _b;
|
|
@@ -1778,22 +1762,22 @@ function getTailSvgPath$1(props, viewport) {
|
|
|
1778
1762
|
start: far,
|
|
1779
1763
|
direction: rightDirection
|
|
1780
1764
|
});
|
|
1781
|
-
return "m "
|
|
1765
|
+
return "m ".concat(far.x, " ").concat(far.y, " L ").concat(left.x, " ").concat(left.y, " L ").concat(right.x, " ").concat(right.y, " z");
|
|
1782
1766
|
}
|
|
1783
1767
|
var CtaBubbleTail = function (props) {
|
|
1784
1768
|
var _a, _b;
|
|
1785
1769
|
var _c = useDimensions(), ref = _c[0], rect = _c[1];
|
|
1786
1770
|
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 };
|
|
1787
|
-
return React.createElement("div", { ref: ref, className: "cta-bubble__tail" },
|
|
1788
|
-
React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 "
|
|
1789
|
-
React.createElement("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" })));
|
|
1771
|
+
return React$1.createElement("div", { ref: ref, className: "cta-bubble__tail" },
|
|
1772
|
+
React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y) },
|
|
1773
|
+
React$1.createElement("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" })));
|
|
1790
1774
|
};
|
|
1791
1775
|
var CtaBubble = function (props) {
|
|
1792
1776
|
var _a, _b;
|
|
1793
1777
|
var _c = useDimensions(), ref = _c[0], rect = _c[1];
|
|
1794
|
-
return (React.createElement("div", { ref: ref, className: "cta-bubble", onClick: props.onClick },
|
|
1795
|
-
React.createElement(CtaBubbleTail, { width: (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0, height: (_b = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _b !== void 0 ? _b : 0, direction: 60, angle: 45, length: 16 }),
|
|
1796
|
-
React.createElement("div", { className: "cta-bubble__content" }, props.children)));
|
|
1778
|
+
return (React$1.createElement("div", { ref: ref, className: "cta-bubble", onClick: props.onClick },
|
|
1779
|
+
React$1.createElement(CtaBubbleTail, { width: (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0, height: (_b = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _b !== void 0 ? _b : 0, direction: 60, angle: 45, length: 16 }),
|
|
1780
|
+
React$1.createElement("div", { className: "cta-bubble__content" }, props.children)));
|
|
1797
1781
|
};
|
|
1798
1782
|
|
|
1799
1783
|
var CtaBubbleContainer = function (props) {
|
|
@@ -1824,16 +1808,16 @@ var CtaBubbleContainer = function (props) {
|
|
|
1824
1808
|
clearTimeout(handle);
|
|
1825
1809
|
};
|
|
1826
1810
|
}, [startTime, timeout]);
|
|
1827
|
-
return (React.createElement(React.Fragment, null, props.visible && !pastDue && React.createElement(CtaBubble, { onClick: props.onClick }, props.children)));
|
|
1811
|
+
return (React$1.createElement(React$1.Fragment, null, props.visible && !pastDue && React$1.createElement(CtaBubble, { onClick: props.onClick }, props.children)));
|
|
1828
1812
|
};
|
|
1829
1813
|
|
|
1830
1814
|
var ChatButton = function (props) {
|
|
1831
|
-
return (React.createElement("div", { className: "chat-button "
|
|
1832
|
-
React.createElement("div", { className: "chat-button__btn", onClick: props.onClick },
|
|
1833
|
-
React.createElement("svg", { width: "22", height: "22", viewBox: "0 0 22 22" },
|
|
1834
|
-
React.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" }))),
|
|
1835
|
-
props.config && props.config.message && (React.createElement("div", { className: "chat-button__cta" },
|
|
1836
|
-
React.createElement(CtaBubbleContainer, { timeout: props.config.timeout, visible: !props.visible, onClick: props.onClick }, props.config.message)))));
|
|
1815
|
+
return (React$1.createElement("div", { className: "chat-button ".concat(props.addClass) },
|
|
1816
|
+
React$1.createElement("div", { className: "chat-button__btn", onClick: props.onClick },
|
|
1817
|
+
React$1.createElement("svg", { width: "22", height: "22", viewBox: "0 0 22 22" },
|
|
1818
|
+
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" }))),
|
|
1819
|
+
props.config && props.config.message && (React$1.createElement("div", { className: "chat-button__cta" },
|
|
1820
|
+
React$1.createElement(CtaBubbleContainer, { timeout: props.config.timeout, visible: !props.visible, onClick: props.onClick }, props.config.message)))));
|
|
1837
1821
|
};
|
|
1838
1822
|
|
|
1839
1823
|
var ChatCard = function (props) {
|
|
@@ -1843,39 +1827,39 @@ var ChatCard = function (props) {
|
|
|
1843
1827
|
var image;
|
|
1844
1828
|
var content;
|
|
1845
1829
|
if (card.imageUrl) {
|
|
1846
|
-
image = React.createElement("div", { className: "chat-card-container__img" },
|
|
1847
|
-
React.createElement(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }));
|
|
1830
|
+
image = React$1.createElement("div", { className: "chat-card-container__img" },
|
|
1831
|
+
React$1.createElement(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }));
|
|
1848
1832
|
}
|
|
1849
1833
|
if (card.title) {
|
|
1850
1834
|
title =
|
|
1851
|
-
React.createElement("div", { className: "chat-card-title" },
|
|
1852
|
-
React.createElement("span", null, card.title));
|
|
1835
|
+
React$1.createElement("div", { className: "chat-card-title" },
|
|
1836
|
+
React$1.createElement("span", null, card.title));
|
|
1853
1837
|
}
|
|
1854
1838
|
if (card.content) {
|
|
1855
1839
|
content =
|
|
1856
|
-
React.createElement("div", { className: "chat-card-sub-title" },
|
|
1857
|
-
React.createElement("span", null, card.content));
|
|
1840
|
+
React$1.createElement("div", { className: "chat-card-sub-title" },
|
|
1841
|
+
React$1.createElement("span", null, card.content));
|
|
1858
1842
|
}
|
|
1859
|
-
return (React.createElement("div", { className: "chat-card-container" },
|
|
1843
|
+
return (React$1.createElement("div", { className: "chat-card-container" },
|
|
1860
1844
|
image,
|
|
1861
1845
|
title,
|
|
1862
1846
|
content,
|
|
1863
|
-
!!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick })));
|
|
1847
|
+
!!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick })));
|
|
1864
1848
|
};
|
|
1865
1849
|
|
|
1866
1850
|
var ChatChip = function (props) {
|
|
1867
1851
|
var option = props.option;
|
|
1868
1852
|
var className = option.actionUrl ? "chat-chip chat-chip-link" : "chat-chip";
|
|
1869
|
-
return (React.createElement("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className },
|
|
1870
|
-
React.createElement("span", null, option.label || option)));
|
|
1853
|
+
return (React$1.createElement("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className },
|
|
1854
|
+
React$1.createElement("span", null, option.label || option)));
|
|
1871
1855
|
};
|
|
1872
1856
|
|
|
1873
1857
|
/**
|
|
1874
1858
|
* Render option list. We just follow the order.
|
|
1875
1859
|
*/
|
|
1876
1860
|
var ChatChips = function (props) {
|
|
1877
|
-
return (React.createElement("div", { className: "chat-chips" }, props.options.map(function (option, i) {
|
|
1878
|
-
return React.createElement(ChatChip, { key: i, onClick: props.onOptionClick, option: option });
|
|
1861
|
+
return (React$1.createElement("div", { className: "chat-chips" }, props.options.map(function (option, i) {
|
|
1862
|
+
return React$1.createElement(ChatChip, { key: i, onClick: props.onOptionClick, option: option });
|
|
1879
1863
|
})));
|
|
1880
1864
|
};
|
|
1881
1865
|
|
|
@@ -1900,7 +1884,7 @@ function resolveUrlPolicy(url, config) {
|
|
|
1900
1884
|
}
|
|
1901
1885
|
|
|
1902
1886
|
// compile time full switch-case verification
|
|
1903
|
-
function throwBadKind(x) {
|
|
1887
|
+
function throwBadKind$1(x) {
|
|
1904
1888
|
throw new Error("Unknown kind " + x);
|
|
1905
1889
|
}
|
|
1906
1890
|
|
|
@@ -1908,7 +1892,7 @@ function execute(url, behavior) {
|
|
|
1908
1892
|
var type = behavior.type;
|
|
1909
1893
|
switch (type) {
|
|
1910
1894
|
case "newWindow":
|
|
1911
|
-
window.open(url, "callout-option", "toolbar=0,status=0,width="
|
|
1895
|
+
window.open(url, "callout-option", "toolbar=0,status=0,width=".concat(behavior.width || 1000, ",height=").concat(behavior.height || 700));
|
|
1912
1896
|
break;
|
|
1913
1897
|
case "newTab":
|
|
1914
1898
|
window.open(url, "_blank");
|
|
@@ -1917,7 +1901,7 @@ function execute(url, behavior) {
|
|
|
1917
1901
|
window.open(url, "_self");
|
|
1918
1902
|
break;
|
|
1919
1903
|
default:
|
|
1920
|
-
throwBadKind(type);
|
|
1904
|
+
throwBadKind$1(type);
|
|
1921
1905
|
}
|
|
1922
1906
|
}
|
|
1923
1907
|
function useOpenUrlCallback() {
|
|
@@ -1950,7 +1934,7 @@ function executeAction(text, token) {
|
|
|
1950
1934
|
});
|
|
1951
1935
|
var visitor = getState().visitor;
|
|
1952
1936
|
dispatch(writeMessage({
|
|
1953
|
-
text: !token ? text : text
|
|
1937
|
+
text: !token ? text : "".concat(text, " (from the list)")
|
|
1954
1938
|
}, visitor));
|
|
1955
1939
|
}; };
|
|
1956
1940
|
}
|
|
@@ -2090,31 +2074,31 @@ var LogChat = /** @class */ (function () {
|
|
|
2090
2074
|
this.inner.init(dispatch);
|
|
2091
2075
|
};
|
|
2092
2076
|
LogChat.prototype.sendOfflineMsg = function (message, cb) {
|
|
2093
|
-
log("CLIENT: sendOfflineMsg: "
|
|
2077
|
+
log("CLIENT: sendOfflineMsg: ".concat(JSON.stringify(message)));
|
|
2094
2078
|
this.inner.sendOfflineMsg(message, cb);
|
|
2095
2079
|
};
|
|
2096
2080
|
LogChat.prototype.sendChatMsg = function (message, cb) {
|
|
2097
|
-
log("CLIENT: sendChatMsg: "
|
|
2081
|
+
log("CLIENT: sendChatMsg: ".concat(JSON.stringify(message)));
|
|
2098
2082
|
this.inner.sendChatMsg(message, cb);
|
|
2099
2083
|
};
|
|
2100
2084
|
LogChat.prototype.sendChatMsgRequest = function (message, cb) {
|
|
2101
|
-
log("CLIENT: sendChatMsgRequest: "
|
|
2085
|
+
log("CLIENT: sendChatMsgRequest: ".concat(JSON.stringify(message)));
|
|
2102
2086
|
this.inner.sendChatMsgRequest(message, cb);
|
|
2103
2087
|
};
|
|
2104
2088
|
LogChat.prototype.sendTyping = function (isTyping) {
|
|
2105
|
-
log("CLIENT: sendTyping: "
|
|
2089
|
+
log("CLIENT: sendTyping: ".concat(JSON.stringify(isTyping)));
|
|
2106
2090
|
this.inner.sendTyping(isTyping);
|
|
2107
2091
|
};
|
|
2108
2092
|
LogChat.prototype.setVisitorInfo = function (visitorInfo, cb) {
|
|
2109
|
-
log("CLIENT: setVisitorInfo: "
|
|
2093
|
+
log("CLIENT: setVisitorInfo: ".concat(JSON.stringify(visitorInfo)));
|
|
2110
2094
|
this.inner.setVisitorInfo(visitorInfo, cb);
|
|
2111
2095
|
};
|
|
2112
2096
|
LogChat.prototype.sendChatRating = function (rating) {
|
|
2113
|
-
log("CLIENT: sendChatRating: "
|
|
2097
|
+
log("CLIENT: sendChatRating: ".concat(JSON.stringify(rating)));
|
|
2114
2098
|
this.inner.sendChatRating(rating);
|
|
2115
2099
|
};
|
|
2116
2100
|
LogChat.prototype.sendFile = function (file, cb) {
|
|
2117
|
-
log("CLIENT: sendFile: "
|
|
2101
|
+
log("CLIENT: sendFile: ".concat(JSON.stringify(file)));
|
|
2118
2102
|
this.inner.sendFile(file, cb);
|
|
2119
2103
|
};
|
|
2120
2104
|
LogChat.prototype.markAsRead = function () {
|
|
@@ -2132,20 +2116,651 @@ var LogChat = /** @class */ (function () {
|
|
|
2132
2116
|
return LogChat;
|
|
2133
2117
|
}());
|
|
2134
2118
|
|
|
2119
|
+
var dist = {};
|
|
2120
|
+
|
|
2121
|
+
Object.defineProperty(dist, '__esModule', { value: true });
|
|
2122
|
+
|
|
2123
|
+
var React = React$1;
|
|
2124
|
+
|
|
2125
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
2126
|
+
|
|
2127
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
2128
|
+
|
|
2129
|
+
var IconButton = function (props) {
|
|
2130
|
+
var type = props.type || "button";
|
|
2131
|
+
var Icon = props.icon;
|
|
2132
|
+
return (React__default["default"].createElement("button", { type: type, className: "xapp-search-icon-button ".concat(props.className || ""), onClick: props.onClick },
|
|
2133
|
+
React__default["default"].createElement("div", { className: "xapp-search-icon-button__content" },
|
|
2134
|
+
React__default["default"].createElement(Icon, null))));
|
|
2135
|
+
};
|
|
2136
|
+
|
|
2137
|
+
var MessageBubble = function (props) {
|
|
2138
|
+
return (React__default["default"].createElement("div", { className: "xappw-message-bubble" }, props.children));
|
|
2139
|
+
};
|
|
2140
|
+
|
|
2141
|
+
// compile time full switch-case verification
|
|
2142
|
+
function throwBadKind(x) {
|
|
2143
|
+
throw new Error("Unknown kind " + x);
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
var RichTextBoldSpan = function (props) {
|
|
2147
|
+
var format = props.format, text = props.text;
|
|
2148
|
+
return (React__default["default"].createElement("span", { "data-rich-text-type": "bold", className: "xapp-search-rich-text-bold-span" }, text.substring(format.start, format.end)));
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
var RichTextInputSpan = function (props) {
|
|
2152
|
+
var format = props.format, text = props.text, readOnly = props.readOnly;
|
|
2153
|
+
var defaultValue = format.text || text.substring(format.start, format.end);
|
|
2154
|
+
var _a = React.useState(defaultValue), value = _a[0], setValue = _a[1];
|
|
2155
|
+
var handleChange = React.useCallback(function (ev) {
|
|
2156
|
+
setValue(ev.target.value);
|
|
2157
|
+
}, []);
|
|
2158
|
+
if (readOnly) {
|
|
2159
|
+
return (React__default["default"].createElement("span", { className: "xapp-search-rich-text-input-span xapp-search-rich-text-input-span--readonly" }, defaultValue));
|
|
2160
|
+
}
|
|
2161
|
+
return (React__default["default"].createElement("input", { type: "text", value: value, className: "xapp-search-rich-text-input-span", "data-rich-text-type": "inputText", onChange: handleChange, readOnly: readOnly }));
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
var RichTextNormalSpan = function (props) {
|
|
2165
|
+
var format = props.format, text = props.text;
|
|
2166
|
+
return (React__default["default"].createElement("span", { "data-rich-text-type": "normal", className: "xapp-search-rich-text-normal-span" }, text.substring(format.start, format.end)));
|
|
2167
|
+
};
|
|
2168
|
+
|
|
2169
|
+
var RichTextSpan = function (props) {
|
|
2170
|
+
var format = props.format, text = props.text, readOnly = props.readOnly;
|
|
2171
|
+
var type = format.type;
|
|
2172
|
+
switch (type) {
|
|
2173
|
+
case "normal":
|
|
2174
|
+
return (React__default["default"].createElement(RichTextNormalSpan, { text: text, format: format, readOnly: readOnly }));
|
|
2175
|
+
case "bold":
|
|
2176
|
+
return (React__default["default"].createElement(RichTextBoldSpan, { text: text, format: format, readOnly: readOnly }));
|
|
2177
|
+
case "inputText":
|
|
2178
|
+
return (React__default["default"].createElement(RichTextInputSpan, { text: text, format: format, readOnly: readOnly }));
|
|
2179
|
+
default:
|
|
2180
|
+
throwBadKind(type);
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
|
|
2184
|
+
function cleanRichTextValue(value) {
|
|
2185
|
+
var text = value.text, formats = value.formats;
|
|
2186
|
+
var newFormats = [];
|
|
2187
|
+
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
|
|
2188
|
+
var format = formats_1[_i];
|
|
2189
|
+
var type = format.type;
|
|
2190
|
+
switch (type) {
|
|
2191
|
+
case "normal":
|
|
2192
|
+
continue;
|
|
2193
|
+
case "inputText":
|
|
2194
|
+
newFormats.push(format);
|
|
2195
|
+
break;
|
|
2196
|
+
case "bold":
|
|
2197
|
+
if (newFormats.length > 0) {
|
|
2198
|
+
var prev = newFormats[newFormats.length - 1];
|
|
2199
|
+
if (prev.type === type && prev.end === format.start) {
|
|
2200
|
+
newFormats.pop();
|
|
2201
|
+
newFormats.push({
|
|
2202
|
+
type: type,
|
|
2203
|
+
start: prev.start,
|
|
2204
|
+
end: format.end
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
else {
|
|
2209
|
+
newFormats.push(format);
|
|
2210
|
+
}
|
|
2211
|
+
break;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
return {
|
|
2215
|
+
text: text,
|
|
2216
|
+
formats: newFormats
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
function extendFormat(formats, length) {
|
|
2221
|
+
var res = [];
|
|
2222
|
+
var walkerIndex = 0;
|
|
2223
|
+
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
|
|
2224
|
+
var format = formats_1[_i];
|
|
2225
|
+
var start = format.start, end = format.end, type = format.type, text = format.text;
|
|
2226
|
+
if (walkerIndex < start) {
|
|
2227
|
+
res.push({
|
|
2228
|
+
type: "normal",
|
|
2229
|
+
start: walkerIndex,
|
|
2230
|
+
end: start
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
res.push({
|
|
2234
|
+
type: type,
|
|
2235
|
+
start: start,
|
|
2236
|
+
end: end,
|
|
2237
|
+
text: text
|
|
2238
|
+
});
|
|
2239
|
+
walkerIndex = end;
|
|
2240
|
+
}
|
|
2241
|
+
if (walkerIndex < length) {
|
|
2242
|
+
res.push({
|
|
2243
|
+
type: "normal",
|
|
2244
|
+
start: walkerIndex,
|
|
2245
|
+
end: length
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
return res;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
function parseContent(node) {
|
|
2252
|
+
var children = node.childNodes;
|
|
2253
|
+
var formats = [];
|
|
2254
|
+
var text = "";
|
|
2255
|
+
children.forEach(function (child) {
|
|
2256
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
2257
|
+
var node_1 = child;
|
|
2258
|
+
var innerText = node_1.tagName === "INPUT" ? node_1.value : node_1.innerText;
|
|
2259
|
+
var type = node_1.dataset.richTextType;
|
|
2260
|
+
formats.push({
|
|
2261
|
+
type: type,
|
|
2262
|
+
start: text.length,
|
|
2263
|
+
end: text.length + innerText.length
|
|
2264
|
+
});
|
|
2265
|
+
text += innerText;
|
|
2266
|
+
}
|
|
2267
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
2268
|
+
var node_2 = child;
|
|
2269
|
+
var innerText = node_2.nodeValue;
|
|
2270
|
+
if (innerText) {
|
|
2271
|
+
formats.push({
|
|
2272
|
+
type: "normal",
|
|
2273
|
+
start: text.length,
|
|
2274
|
+
end: text.length + innerText.length
|
|
2275
|
+
});
|
|
2276
|
+
text += innerText;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
return cleanRichTextValue({
|
|
2281
|
+
text: text,
|
|
2282
|
+
formats: formats
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
function cleanContent(node) {
|
|
2286
|
+
var _a;
|
|
2287
|
+
var trash = [];
|
|
2288
|
+
var raw = node.childNodes;
|
|
2289
|
+
for (var i = 0; i < raw.length; i++) {
|
|
2290
|
+
var c = raw.item(i);
|
|
2291
|
+
if ((c === null || c === void 0 ? void 0 : c.nodeType) === Node.TEXT_NODE) {
|
|
2292
|
+
trash.push(c);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
for (var _i = 0, trash_1 = trash; _i < trash_1.length; _i++) {
|
|
2296
|
+
var c = trash_1[_i];
|
|
2297
|
+
try {
|
|
2298
|
+
(_a = c.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(c);
|
|
2299
|
+
}
|
|
2300
|
+
catch (_b) {
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
var RichText = function (props) {
|
|
2305
|
+
var value = props.value, className = props.className, readOnly = props.readOnly, onInput = props.onInput, onChange = props.onChange;
|
|
2306
|
+
var formatsRaw = value.formats, text = value.text;
|
|
2307
|
+
var formats = React.useMemo(function () { return extendFormat(formatsRaw, text.length); }, [formatsRaw, text.length]);
|
|
2308
|
+
var handleInput = React.useCallback(function (ev) {
|
|
2309
|
+
var target = ev.currentTarget;
|
|
2310
|
+
var newValue = parseContent(target);
|
|
2311
|
+
if (onInput) {
|
|
2312
|
+
onInput(newValue);
|
|
2313
|
+
}
|
|
2314
|
+
}, [onInput]);
|
|
2315
|
+
var handleBlur = React.useCallback(function (ev) {
|
|
2316
|
+
var target = ev.currentTarget;
|
|
2317
|
+
var newValue = parseContent(target);
|
|
2318
|
+
cleanContent(target);
|
|
2319
|
+
if (onChange) {
|
|
2320
|
+
onChange(newValue);
|
|
2321
|
+
}
|
|
2322
|
+
}, [onChange]);
|
|
2323
|
+
return (React__default["default"].createElement("div", { id: props.id, className: "xapp-search-rich-text ".concat(className || ""), contentEditable: !readOnly, suppressContentEditableWarning: true, onInput: handleInput, onBlur: handleBlur }, formats.map(function (format, index) { return (React__default["default"].createElement(RichTextSpan, { format: format, text: text, key: index, readOnly: readOnly })); })));
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
var RichInput = function (props) {
|
|
2327
|
+
var id = props.id, value = props.value, type = props.type, autoFocus = props.autoFocus, onChange = props.onChange, onInput = props.onInput, onKeyDown = props.onKeyDown, onSearch = props.onSearch;
|
|
2328
|
+
var rich = value.formats.some(function (f) { return f.type === "inputText"; });
|
|
2329
|
+
var handleChange = React.useCallback(function (ev) {
|
|
2330
|
+
onChange({
|
|
2331
|
+
text: ev.target.value,
|
|
2332
|
+
formats: []
|
|
2333
|
+
});
|
|
2334
|
+
}, [onChange]);
|
|
2335
|
+
var handleRichChange = React.useCallback(function (val) {
|
|
2336
|
+
onChange(val);
|
|
2337
|
+
}, [onChange]);
|
|
2338
|
+
var handleInput = React.useCallback(function (ev) {
|
|
2339
|
+
if (onInput) {
|
|
2340
|
+
onInput({
|
|
2341
|
+
text: ev.target.value,
|
|
2342
|
+
formats: []
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
}, [onInput]);
|
|
2346
|
+
var handleRichInput = React.useCallback(function (val) {
|
|
2347
|
+
if (onInput) {
|
|
2348
|
+
onInput(val);
|
|
2349
|
+
}
|
|
2350
|
+
}, [onInput]);
|
|
2351
|
+
var handleKeyDown = React.useCallback(function (event) {
|
|
2352
|
+
if (onKeyDown) {
|
|
2353
|
+
onKeyDown(event);
|
|
2354
|
+
}
|
|
2355
|
+
}, [onKeyDown]);
|
|
2356
|
+
var inputRef = React.useRef(null);
|
|
2357
|
+
var inputNode = inputRef.current;
|
|
2358
|
+
React.useEffect(function () {
|
|
2359
|
+
if (inputNode && onSearch) {
|
|
2360
|
+
var handler_1 = function (ev) {
|
|
2361
|
+
var target = ev.target;
|
|
2362
|
+
if (target) {
|
|
2363
|
+
onSearch({
|
|
2364
|
+
text: target.value,
|
|
2365
|
+
formats: []
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
inputNode.addEventListener("search", handler_1);
|
|
2370
|
+
return function () {
|
|
2371
|
+
inputNode.removeEventListener("search", handler_1);
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
return undefined;
|
|
2375
|
+
}, [inputNode, onSearch]);
|
|
2376
|
+
return (React__default["default"].createElement("div", { className: "xappw-rich-input ".concat(props.className) }, rich ?
|
|
2377
|
+
React__default["default"].createElement(RichText, { id: id, value: value, onChange: handleRichChange, onInput: handleRichInput, className: "xappw-rich-input__input ".concat(props.className, "__input") }) : React__default["default"].createElement("input", { id: id, ref: inputRef, type: type, value: value.text, autoFocus: autoFocus, placeholder: props.placeholder, className: "xappw-rich-input__input ".concat(props.className, "__input"), onFocus: props.onFocus, onChange: handleChange, onInput: handleInput, onKeyDown: handleKeyDown })));
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2380
|
+
var SuggestionsGroupHeading = function (props) {
|
|
2381
|
+
return (React__default["default"].createElement("div", { className: "xappw-suggestions-group-heading" }, props.label));
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2384
|
+
function getScrollContainer(node) {
|
|
2385
|
+
var walker = node;
|
|
2386
|
+
while (walker && !walker.classList.contains("xapp-search-result__suggestions")) {
|
|
2387
|
+
walker = walker.parentElement;
|
|
2388
|
+
}
|
|
2389
|
+
return walker || undefined;
|
|
2390
|
+
}
|
|
2391
|
+
var SuggestionsItem = function (props) {
|
|
2392
|
+
var data = props.data, current = props.current, ActionsComponent = props.actions, onClick = props.onClick, onHover = props.onHover;
|
|
2393
|
+
var handleClick = React.useCallback(function () {
|
|
2394
|
+
onClick(data);
|
|
2395
|
+
}, [data, onClick]);
|
|
2396
|
+
var handleHover = React.useCallback(function () {
|
|
2397
|
+
if (onHover) {
|
|
2398
|
+
onHover(data);
|
|
2399
|
+
}
|
|
2400
|
+
}, [data, onHover]);
|
|
2401
|
+
var ref = React.useRef(null);
|
|
2402
|
+
React.useEffect(function () {
|
|
2403
|
+
var node = ref.current;
|
|
2404
|
+
if (current && node) {
|
|
2405
|
+
var scrollContainer = getScrollContainer(node);
|
|
2406
|
+
if (scrollContainer) {
|
|
2407
|
+
var scrollBox = scrollContainer.getBoundingClientRect();
|
|
2408
|
+
var nodeBox = node.getBoundingClientRect();
|
|
2409
|
+
var maxTop = Math.max(scrollBox.top, nodeBox.top);
|
|
2410
|
+
var minBottom = Math.min(scrollBox.bottom, nodeBox.bottom);
|
|
2411
|
+
var visibleHeight = minBottom - maxTop;
|
|
2412
|
+
var actualHeight = nodeBox.height;
|
|
2413
|
+
if (visibleHeight < actualHeight * 0.99) {
|
|
2414
|
+
node.scrollIntoView({ behavior: "smooth" });
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
}, [current]);
|
|
2419
|
+
return (React__default["default"].createElement("div", { ref: ref, className: "xappw-suggestions-item ".concat(current ? "xappw-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover },
|
|
2420
|
+
React__default["default"].createElement(RichText, { value: data, className: "xappw-suggestions-item__texts", readOnly: true }),
|
|
2421
|
+
ActionsComponent &&
|
|
2422
|
+
React__default["default"].createElement("div", { className: "xappw-suggestions-item__actions" },
|
|
2423
|
+
React__default["default"].createElement(ActionsComponent, { data: data, current: current }))));
|
|
2424
|
+
};
|
|
2425
|
+
|
|
2426
|
+
var SuggestionsGroup = function (props) {
|
|
2427
|
+
var group = props.group, currentIndex = props.currentIndex, itemActions = props.itemActions;
|
|
2428
|
+
var heading = group.heading, items = group.items;
|
|
2429
|
+
return (React__default["default"].createElement("div", { className: "xappw-suggestions-group" },
|
|
2430
|
+
React__default["default"].createElement("div", { className: "xappw-suggestions-group__heading" },
|
|
2431
|
+
React__default["default"].createElement(SuggestionsGroupHeading, { label: heading })),
|
|
2432
|
+
React__default["default"].createElement("div", { className: "xappw-suggestions-group__items" }, items.map(function (item, itemIndex) {
|
|
2433
|
+
return React__default["default"].createElement(SuggestionsItem, { key: itemIndex, data: item, current: currentIndex === itemIndex, actions: itemActions, onClick: props.onItemClick, onHover: props.onItemHover });
|
|
2434
|
+
}))));
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2437
|
+
function getItemsLength(result) {
|
|
2438
|
+
return result.reduce(function (prev, cur) { return prev + cur.items.length; }, 0);
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
var SuggestionsList = function (props) {
|
|
2442
|
+
var suggestions = props.suggestions, itemActions = props.itemActions, className = props.className;
|
|
2443
|
+
var length = React.useMemo(function () { return getItemsLength(suggestions); }, [suggestions]);
|
|
2444
|
+
var currentIndex = length >= 0 ? props.index : NaN;
|
|
2445
|
+
var indexWalker = 0;
|
|
2446
|
+
return (React__default["default"].createElement("div", { className: "xappw-suggestions-list ".concat(className || "") }, suggestions.map(function (group, index) {
|
|
2447
|
+
var res = (React__default["default"].createElement(SuggestionsGroup, { key: index, group: group, currentIndex: currentIndex - indexWalker, itemActions: itemActions, onItemClick: props.onItemClick, onItemHover: props.onItemHover }));
|
|
2448
|
+
indexWalker += group.items.length;
|
|
2449
|
+
return res;
|
|
2450
|
+
})));
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
function findItemByIndex(groups, index) {
|
|
2454
|
+
if (index >= 0) {
|
|
2455
|
+
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
|
2456
|
+
var group = groups_1[_i];
|
|
2457
|
+
for (var _a = 0, _b = group.items; _a < _b.length; _a++) {
|
|
2458
|
+
var item = _b[_a];
|
|
2459
|
+
if (index <= 0) {
|
|
2460
|
+
return item;
|
|
2461
|
+
}
|
|
2462
|
+
index--;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
return undefined;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
function parseSuggestionsFormat(format) {
|
|
2470
|
+
var types = Object.keys(format);
|
|
2471
|
+
var type = types[0];
|
|
2472
|
+
var item = format[type];
|
|
2473
|
+
if (!item) {
|
|
2474
|
+
throw new Error();
|
|
2475
|
+
}
|
|
2476
|
+
return {
|
|
2477
|
+
type: type,
|
|
2478
|
+
start: item.start,
|
|
2479
|
+
end: item.end
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2482
|
+
function parseSuggestionsFormats(formats) {
|
|
2483
|
+
return formats.map(parseSuggestionsFormat);
|
|
2484
|
+
}
|
|
2485
|
+
function parseSuggestionsResponseItem(item) {
|
|
2486
|
+
return {
|
|
2487
|
+
text: item.suggestion,
|
|
2488
|
+
content: item.answer,
|
|
2489
|
+
formats: parseSuggestionsFormats(item.format),
|
|
2490
|
+
type: item.type
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
function getHeading(type) {
|
|
2494
|
+
switch (type) {
|
|
2495
|
+
case "FAQ":
|
|
2496
|
+
return "FAQs";
|
|
2497
|
+
case "INTENT":
|
|
2498
|
+
return "Suggestions";
|
|
2499
|
+
case "HISTORICAL":
|
|
2500
|
+
return "Suggestions";
|
|
2501
|
+
default:
|
|
2502
|
+
return type;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
function parseSuggestionsResponse(response, direction) {
|
|
2506
|
+
if (direction === void 0) { direction = 1; }
|
|
2507
|
+
if (!response) {
|
|
2508
|
+
return undefined;
|
|
2509
|
+
}
|
|
2510
|
+
var items = sortSuggestionItems(response.suggestions, direction);
|
|
2511
|
+
return items.reduce(function (result, current) {
|
|
2512
|
+
var mappedItem = parseSuggestionsResponseItem(current);
|
|
2513
|
+
if (result.length) {
|
|
2514
|
+
var prevGroup = result[result.length - 1];
|
|
2515
|
+
if (prevGroup.heading === getHeading(current.type)) {
|
|
2516
|
+
prevGroup.items.push(mappedItem);
|
|
2517
|
+
return result;
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
result.push({
|
|
2521
|
+
heading: getHeading(current.type),
|
|
2522
|
+
items: [mappedItem]
|
|
2523
|
+
});
|
|
2524
|
+
return result;
|
|
2525
|
+
}, []);
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
/*! *****************************************************************************
|
|
2529
|
+
Copyright (c) Microsoft Corporation.
|
|
2530
|
+
|
|
2531
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
2532
|
+
purpose with or without fee is hereby granted.
|
|
2533
|
+
|
|
2534
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2535
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2536
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2537
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2538
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2539
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2540
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
2541
|
+
***************************************************************************** */
|
|
2542
|
+
|
|
2543
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
2544
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2545
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2546
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2547
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2548
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2549
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
function __generator(thisArg, body) {
|
|
2554
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2555
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2556
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2557
|
+
function step(op) {
|
|
2558
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2559
|
+
while (_) try {
|
|
2560
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2561
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2562
|
+
switch (op[0]) {
|
|
2563
|
+
case 0: case 1: t = op; break;
|
|
2564
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
2565
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2566
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2567
|
+
default:
|
|
2568
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2569
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2570
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2571
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2572
|
+
if (t[2]) _.ops.pop();
|
|
2573
|
+
_.trys.pop(); continue;
|
|
2574
|
+
}
|
|
2575
|
+
op = body.call(thisArg, _);
|
|
2576
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2577
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
function __spreadArray(to, from, pack) {
|
|
2582
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2583
|
+
if (ar || !(i in from)) {
|
|
2584
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2585
|
+
ar[i] = from[i];
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
var order = ["FAQ", "INTENT", "HISTORICAL"];
|
|
2592
|
+
var ordersMap = order.reduce(function (prev, cur, index) {
|
|
2593
|
+
prev[cur] = index;
|
|
2594
|
+
return prev;
|
|
2595
|
+
}, {});
|
|
2596
|
+
function compareSuggestionItems(left, right, direction) {
|
|
2597
|
+
return direction * (ordersMap[right.type] - ordersMap[left.type]);
|
|
2598
|
+
}
|
|
2599
|
+
function sortSuggestionItems(items, direction) {
|
|
2600
|
+
return __spreadArray([], items, true).sort(function (left, right) { return compareSuggestionItems(left, right, direction); });
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
/**
|
|
2604
|
+
* Append the provided query params to the URL
|
|
2605
|
+
*
|
|
2606
|
+
* It will overwrite existing params on the URL if there are conflicts
|
|
2607
|
+
* @param url
|
|
2608
|
+
* @param params
|
|
2609
|
+
*/
|
|
2610
|
+
function addQueryParametersToURL(url, params) {
|
|
2611
|
+
var existingParams = new URL(url).searchParams;
|
|
2612
|
+
params.forEach(function (value, key) {
|
|
2613
|
+
existingParams.append(key, value);
|
|
2614
|
+
});
|
|
2615
|
+
var newUrl = new URL(url);
|
|
2616
|
+
newUrl.search = existingParams.toString();
|
|
2617
|
+
return newUrl;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
var defaultOptions = {};
|
|
2621
|
+
function noop$1() {
|
|
2622
|
+
}
|
|
2623
|
+
function useJsonFetch(url, options) {
|
|
2624
|
+
if (options === void 0) { options = defaultOptions; }
|
|
2625
|
+
var _a = React.useState({
|
|
2626
|
+
state: "paused"
|
|
2627
|
+
}), value = _a[0], setValue = _a[1];
|
|
2628
|
+
var pause = options.pause;
|
|
2629
|
+
React.useEffect(function () {
|
|
2630
|
+
if (pause) {
|
|
2631
|
+
setValue({
|
|
2632
|
+
state: "paused"
|
|
2633
|
+
});
|
|
2634
|
+
return noop$1;
|
|
2635
|
+
}
|
|
2636
|
+
var controller = new AbortController();
|
|
2637
|
+
var signal = controller.signal;
|
|
2638
|
+
var mounted = true;
|
|
2639
|
+
(function () {
|
|
2640
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2641
|
+
var response, json, e_1;
|
|
2642
|
+
return __generator(this, function (_a) {
|
|
2643
|
+
switch (_a.label) {
|
|
2644
|
+
case 0:
|
|
2645
|
+
_a.trys.push([0, 4, , 5]);
|
|
2646
|
+
setValue({
|
|
2647
|
+
state: "fetching"
|
|
2648
|
+
});
|
|
2649
|
+
return [4 /*yield*/, fetch(url, { signal: signal })];
|
|
2650
|
+
case 1:
|
|
2651
|
+
response = _a.sent();
|
|
2652
|
+
if (!mounted) return [3 /*break*/, 3];
|
|
2653
|
+
return [4 /*yield*/, response.json()];
|
|
2654
|
+
case 2:
|
|
2655
|
+
json = _a.sent();
|
|
2656
|
+
if (response.ok) {
|
|
2657
|
+
setValue({
|
|
2658
|
+
state: "success",
|
|
2659
|
+
data: json
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
else {
|
|
2663
|
+
setValue({
|
|
2664
|
+
state: "error",
|
|
2665
|
+
error: json
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
_a.label = 3;
|
|
2669
|
+
case 3: return [3 /*break*/, 5];
|
|
2670
|
+
case 4:
|
|
2671
|
+
e_1 = _a.sent();
|
|
2672
|
+
if (e_1.name === "AbortError") {
|
|
2673
|
+
setValue({
|
|
2674
|
+
state: "paused"
|
|
2675
|
+
});
|
|
2676
|
+
return [2 /*return*/];
|
|
2677
|
+
}
|
|
2678
|
+
throw e_1;
|
|
2679
|
+
case 5: return [2 /*return*/];
|
|
2680
|
+
}
|
|
2681
|
+
});
|
|
2682
|
+
});
|
|
2683
|
+
})();
|
|
2684
|
+
return function () {
|
|
2685
|
+
mounted = false;
|
|
2686
|
+
controller.abort();
|
|
2687
|
+
};
|
|
2688
|
+
}, [url, pause]);
|
|
2689
|
+
return value;
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
function useSuggestionsFetch$1(options) {
|
|
2693
|
+
var baseUrl = options.url, context = options.context, query = options.query;
|
|
2694
|
+
var url = React.useMemo(function () {
|
|
2695
|
+
if (!baseUrl) {
|
|
2696
|
+
return undefined;
|
|
2697
|
+
}
|
|
2698
|
+
var params = new URLSearchParams();
|
|
2699
|
+
params.append("size", "5");
|
|
2700
|
+
params.append("queryText", query);
|
|
2701
|
+
if (context === null || context === void 0 ? void 0 : context.length) {
|
|
2702
|
+
params.append("activeContexts", context.join(","));
|
|
2703
|
+
}
|
|
2704
|
+
return addQueryParametersToURL(baseUrl, params);
|
|
2705
|
+
}, [query, context, baseUrl]);
|
|
2706
|
+
var response = useJsonFetch(url ? "".concat(url.toString()) : "", {
|
|
2707
|
+
pause: !query || !baseUrl
|
|
2708
|
+
});
|
|
2709
|
+
return response;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
/**
|
|
2713
|
+
* Quicker configurable uuid
|
|
2714
|
+
*
|
|
2715
|
+
* @export
|
|
2716
|
+
* @returns {string}
|
|
2717
|
+
*/
|
|
2718
|
+
function uuid() {
|
|
2719
|
+
var d = new Date().getTime();
|
|
2720
|
+
var newUuid = "xxxxxxxx-xxxx-65xx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
2721
|
+
/* tslint:disable:no-magic-numbers */
|
|
2722
|
+
/* tslint:disable:no-bitwise */
|
|
2723
|
+
var r = (d + Math.random() * 16) % 16 | 0;
|
|
2724
|
+
d = Math.floor(d / 16);
|
|
2725
|
+
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
2726
|
+
/* tslint:enable:no-magic-numbers */
|
|
2727
|
+
/* tslint:disable:no-bitwise */
|
|
2728
|
+
});
|
|
2729
|
+
return newUuid;
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
var IconButton_1 = dist.IconButton = IconButton;
|
|
2733
|
+
dist.MessageBubble = MessageBubble;
|
|
2734
|
+
var RichInput_1 = dist.RichInput = RichInput;
|
|
2735
|
+
dist.RichText = RichText;
|
|
2736
|
+
dist.SuggestionsGroup = SuggestionsGroup;
|
|
2737
|
+
dist.SuggestionsGroupHeading = SuggestionsGroupHeading;
|
|
2738
|
+
dist.SuggestionsItem = SuggestionsItem;
|
|
2739
|
+
var SuggestionsList_1 = dist.SuggestionsList = SuggestionsList;
|
|
2740
|
+
dist.addQueryParametersToURL = addQueryParametersToURL;
|
|
2741
|
+
dist.extendFormat = extendFormat;
|
|
2742
|
+
var findItemByIndex_1 = dist.findItemByIndex = findItemByIndex;
|
|
2743
|
+
var getItemsLength_1 = dist.getItemsLength = getItemsLength;
|
|
2744
|
+
var parseSuggestionsResponse_1 = dist.parseSuggestionsResponse = parseSuggestionsResponse;
|
|
2745
|
+
dist.sortSuggestionItems = sortSuggestionItems;
|
|
2746
|
+
dist.useJsonFetch = useJsonFetch;
|
|
2747
|
+
var useSuggestionsFetch_1 = dist.useSuggestionsFetch = useSuggestionsFetch$1;
|
|
2748
|
+
var uuid_1 = dist.uuid = uuid;
|
|
2749
|
+
|
|
2135
2750
|
function postMessageToStentor(data, url, key) {
|
|
2136
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2751
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
2137
2752
|
var body, response;
|
|
2138
|
-
return __generator(this, function (_a) {
|
|
2753
|
+
return __generator$1(this, function (_a) {
|
|
2139
2754
|
switch (_a.label) {
|
|
2140
2755
|
case 0:
|
|
2141
2756
|
body = JSON.stringify(data);
|
|
2142
|
-
log("URL: "
|
|
2143
|
-
log("BODY: "
|
|
2757
|
+
log("URL: ".concat(url));
|
|
2758
|
+
log("BODY: ".concat(body));
|
|
2144
2759
|
return [4 /*yield*/, fetch(url, {
|
|
2145
2760
|
method: "POST",
|
|
2146
2761
|
headers: {
|
|
2147
2762
|
"Content-Type": "application/json",
|
|
2148
|
-
"Authorization": "Bearer "
|
|
2763
|
+
"Authorization": "Bearer ".concat(key),
|
|
2149
2764
|
"User-Agent": "Stentor Chat Server"
|
|
2150
2765
|
},
|
|
2151
2766
|
body: body,
|
|
@@ -2154,7 +2769,7 @@ function postMessageToStentor(data, url, key) {
|
|
|
2154
2769
|
case 1:
|
|
2155
2770
|
response = _a.sent();
|
|
2156
2771
|
if (!response.ok) {
|
|
2157
|
-
throw new Error("Status "
|
|
2772
|
+
throw new Error("Status ".concat(response.status, ", Text: ").concat(response.statusText));
|
|
2158
2773
|
}
|
|
2159
2774
|
return [2 /*return*/, response.json()];
|
|
2160
2775
|
}
|
|
@@ -2222,7 +2837,7 @@ function getOutput(value) {
|
|
|
2222
2837
|
* @returns
|
|
2223
2838
|
*/
|
|
2224
2839
|
function responseToMessage(botResponse, now) {
|
|
2225
|
-
var _a, _b, _c, _d;
|
|
2840
|
+
var _a, _b, _c, _d, _e;
|
|
2226
2841
|
if (now === void 0) { now = new Date().getTime(); }
|
|
2227
2842
|
var responseMessage;
|
|
2228
2843
|
if (!botResponse) {
|
|
@@ -2268,24 +2883,20 @@ function responseToMessage(botResponse, now) {
|
|
|
2268
2883
|
if (html) {
|
|
2269
2884
|
responseMessage.msg = __assign(__assign({}, responseMessage.msg), { html: html });
|
|
2270
2885
|
}
|
|
2271
|
-
if (
|
|
2272
|
-
responseMessage.msg.options =
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
if (typeof suggestion === "string") {
|
|
2277
|
-
// Simple chips (strings)
|
|
2278
|
-
responseMessage.msg.options.push(suggestion);
|
|
2279
|
-
}
|
|
2280
|
-
else {
|
|
2281
|
-
// "call out" chips
|
|
2282
|
-
responseMessage.msg.options.push({
|
|
2283
|
-
label: suggestion.title,
|
|
2284
|
-
actionUrl: suggestion.url
|
|
2285
|
-
});
|
|
2286
|
-
}
|
|
2886
|
+
if ((_e = outputSpeech.suggestions) === null || _e === void 0 ? void 0 : _e.length) {
|
|
2887
|
+
responseMessage.msg.options = outputSpeech.suggestions.map(function (suggestion) {
|
|
2888
|
+
if (typeof suggestion === "string") {
|
|
2889
|
+
// Simple chips (strings)
|
|
2890
|
+
return suggestion;
|
|
2287
2891
|
}
|
|
2288
|
-
|
|
2892
|
+
else {
|
|
2893
|
+
// "call out" chips
|
|
2894
|
+
return {
|
|
2895
|
+
label: suggestion.title,
|
|
2896
|
+
actionUrl: suggestion.url
|
|
2897
|
+
};
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2289
2900
|
}
|
|
2290
2901
|
}
|
|
2291
2902
|
return responseMessage;
|
|
@@ -2297,7 +2908,7 @@ function getPermissionRequestType(type) {
|
|
|
2297
2908
|
case "PERMISSION_LOCATION_PRECISE":
|
|
2298
2909
|
return "LOCATION_PRECISE";
|
|
2299
2910
|
default:
|
|
2300
|
-
throw new Error("Unsupported permission: "
|
|
2911
|
+
throw new Error("Unsupported permission: ".concat(type));
|
|
2301
2912
|
}
|
|
2302
2913
|
}
|
|
2303
2914
|
function getPermissionResponse(botResponse, now) {
|
|
@@ -2310,7 +2921,7 @@ function getPermissionResponse(botResponse, now) {
|
|
|
2310
2921
|
type: "permissionRequest",
|
|
2311
2922
|
timestamp: now,
|
|
2312
2923
|
msg: {
|
|
2313
|
-
text: (_a = outputSpeech === null || outputSpeech === void 0 ? void 0 : outputSpeech.displayText) !== null && _a !== void 0 ? _a : ""
|
|
2924
|
+
text: (_a = outputSpeech === null || outputSpeech === void 0 ? void 0 : outputSpeech.displayText) !== null && _a !== void 0 ? _a : "".concat(botResponse.data.permissionRequestTTSContext),
|
|
2314
2925
|
permissionRequest: {
|
|
2315
2926
|
time: now,
|
|
2316
2927
|
type: type,
|
|
@@ -2327,26 +2938,6 @@ function getPermissionResponse(botResponse, now) {
|
|
|
2327
2938
|
};
|
|
2328
2939
|
}
|
|
2329
2940
|
|
|
2330
|
-
/**
|
|
2331
|
-
* Quicker configurable uuid
|
|
2332
|
-
*
|
|
2333
|
-
* @export
|
|
2334
|
-
* @returns {string}
|
|
2335
|
-
*/
|
|
2336
|
-
function uuid() {
|
|
2337
|
-
var d = new Date().getTime();
|
|
2338
|
-
var newUuid = "xxxxxxxx-xxxx-65xx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
2339
|
-
/* tslint:disable:no-magic-numbers */
|
|
2340
|
-
/* tslint:disable:no-bitwise */
|
|
2341
|
-
var r = (d + Math.random() * 16) % 16 | 0;
|
|
2342
|
-
d = Math.floor(d / 16);
|
|
2343
|
-
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
2344
|
-
/* tslint:enable:no-magic-numbers */
|
|
2345
|
-
/* tslint:disable:no-bitwise */
|
|
2346
|
-
});
|
|
2347
|
-
return newUuid;
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
2941
|
var PERMISSION_QUESTION_EXPIRATION_MS = 300000; // 5 minutes
|
|
2351
2942
|
var StentorDirectChat = /** @class */ (function () {
|
|
2352
2943
|
function StentorDirectChat(config) {
|
|
@@ -2358,15 +2949,15 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2358
2949
|
*/
|
|
2359
2950
|
this.widget = {
|
|
2360
2951
|
setConnectionStatus: function (status) {
|
|
2361
|
-
log("SERVER: connection_update: "
|
|
2952
|
+
log("SERVER: connection_update: ".concat(JSON.stringify(status)));
|
|
2362
2953
|
_this.dispatch(setConnectionStatus(status));
|
|
2363
2954
|
},
|
|
2364
2955
|
setAccountStatus: function (status) {
|
|
2365
|
-
log("SERVER: account_status: "
|
|
2956
|
+
log("SERVER: account_status: ".concat(JSON.stringify(status)));
|
|
2366
2957
|
_this.dispatch(setAccountStatus(status));
|
|
2367
2958
|
},
|
|
2368
2959
|
sendNewMessage: function (data) {
|
|
2369
|
-
log("SERVER: new message: "
|
|
2960
|
+
log("SERVER: new message: ".concat(JSON.stringify(data)));
|
|
2370
2961
|
_this.dispatch({
|
|
2371
2962
|
type: "chat",
|
|
2372
2963
|
detail: {
|
|
@@ -2378,7 +2969,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2378
2969
|
});
|
|
2379
2970
|
},
|
|
2380
2971
|
userJoined: function (data) {
|
|
2381
|
-
log("SERVER: user joined: "
|
|
2972
|
+
log("SERVER: user joined: ".concat(JSON.stringify(data)));
|
|
2382
2973
|
_this.visitorInfo.token = data.token;
|
|
2383
2974
|
_this.dispatch({
|
|
2384
2975
|
type: "chat",
|
|
@@ -2390,7 +2981,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2390
2981
|
});
|
|
2391
2982
|
},
|
|
2392
2983
|
userLeft: function (data) {
|
|
2393
|
-
log("SERVER: user left: "
|
|
2984
|
+
log("SERVER: user left: ".concat(JSON.stringify(data)));
|
|
2394
2985
|
_this.dispatch({
|
|
2395
2986
|
type: "chat",
|
|
2396
2987
|
detail: {
|
|
@@ -2449,7 +3040,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2449
3040
|
StentorDirectChat.prototype.init = function (dispatch) {
|
|
2450
3041
|
this.dispatch = dispatch;
|
|
2451
3042
|
// TODO: Authenticate - or at least tell the server who you are
|
|
2452
|
-
log("got init auth: "
|
|
3043
|
+
log("got init auth: ".concat(this.config.key));
|
|
2453
3044
|
// We are connected
|
|
2454
3045
|
this.widget.setConnectionStatus("online");
|
|
2455
3046
|
this.widget.setAccountStatus("online");
|
|
@@ -2461,8 +3052,8 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2461
3052
|
cb();
|
|
2462
3053
|
};
|
|
2463
3054
|
StentorDirectChat.prototype.sendChatMsg = function (message, cb) {
|
|
2464
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2465
|
-
return __generator(this, function (_a) {
|
|
3055
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
3056
|
+
return __generator$1(this, function (_a) {
|
|
2466
3057
|
return [2 /*return*/, this.sendChatMsgRequest({
|
|
2467
3058
|
msg: message,
|
|
2468
3059
|
timestamp: new Date().getTime(),
|
|
@@ -2475,9 +3066,9 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2475
3066
|
};
|
|
2476
3067
|
StentorDirectChat.prototype.sendChatMsgRequest = function (serviceRequest, cb) {
|
|
2477
3068
|
var _a;
|
|
2478
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3069
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
2479
3070
|
var agentResponse;
|
|
2480
|
-
return __generator(this, function (_b) {
|
|
3071
|
+
return __generator$1(this, function (_b) {
|
|
2481
3072
|
switch (_b.label) {
|
|
2482
3073
|
case 0: return [4 /*yield*/, this.postMessage(serviceRequest)];
|
|
2483
3074
|
case 1:
|
|
@@ -2520,9 +3111,9 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2520
3111
|
};
|
|
2521
3112
|
StentorDirectChat.prototype.postMessage = function (message) {
|
|
2522
3113
|
var _a, _b, _c, _d;
|
|
2523
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3114
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
2524
3115
|
var request, now, permissionRequest, expired, text, granted, userProfile, isEmail, botResponse, responseMessage;
|
|
2525
|
-
return __generator(this, function (_e) {
|
|
3116
|
+
return __generator$1(this, function (_e) {
|
|
2526
3117
|
switch (_e.label) {
|
|
2527
3118
|
case 0:
|
|
2528
3119
|
now = new Date().getTime();
|
|
@@ -2609,20 +3200,20 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2609
3200
|
};
|
|
2610
3201
|
}
|
|
2611
3202
|
}
|
|
2612
|
-
log("Visitor says: "
|
|
3203
|
+
log("Visitor says: ".concat(JSON.stringify(request, undefined, 2)));
|
|
2613
3204
|
// Bot is "typing"
|
|
2614
3205
|
this.widget.typing();
|
|
2615
3206
|
return [4 /*yield*/, postMessageToStentor(request, this.config.url, this.config.key).catch(function (postError) {
|
|
2616
|
-
err("POST failed: "
|
|
3207
|
+
err("POST failed: ".concat(postError.message));
|
|
2617
3208
|
return {
|
|
2618
|
-
text: "Bot doesn't respond. Reason: "
|
|
3209
|
+
text: "Bot doesn't respond. Reason: ".concat(postError.message)
|
|
2619
3210
|
};
|
|
2620
3211
|
})];
|
|
2621
3212
|
case 1:
|
|
2622
3213
|
botResponse = _e.sent();
|
|
2623
3214
|
// Bot stopped "typing"
|
|
2624
3215
|
this.widget.stopTyping();
|
|
2625
|
-
log("Bot says: "
|
|
3216
|
+
log("Bot says: ".concat(JSON.stringify(botResponse, undefined, 2)));
|
|
2626
3217
|
// Now translate the response to server dialect
|
|
2627
3218
|
// new session no more
|
|
2628
3219
|
this.isNewSession = false;
|
|
@@ -2646,15 +3237,15 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2646
3237
|
};
|
|
2647
3238
|
StentorDirectChat.prototype.startSession = function () {
|
|
2648
3239
|
if (this.visitorInfo.visitorId) {
|
|
2649
|
-
this._userId = "stentor-widget-user-"
|
|
3240
|
+
this._userId = "stentor-widget-user-".concat(this.visitorInfo.visitorId);
|
|
2650
3241
|
}
|
|
2651
3242
|
else if (this.visitorInfo.email) {
|
|
2652
|
-
this._userId = "stentor-widget-user-"
|
|
3243
|
+
this._userId = "stentor-widget-user-".concat(this.visitorInfo.email);
|
|
2653
3244
|
}
|
|
2654
3245
|
else {
|
|
2655
|
-
this._userId = "stentor-widget-user-"
|
|
3246
|
+
this._userId = "stentor-widget-user-".concat(uuid_1());
|
|
2656
3247
|
}
|
|
2657
|
-
this._sessionId = "stentor-widget-session-"
|
|
3248
|
+
this._sessionId = "stentor-widget-session-".concat(uuid_1());
|
|
2658
3249
|
this.isNewSession = true;
|
|
2659
3250
|
};
|
|
2660
3251
|
Object.defineProperty(StentorDirectChat.prototype, "userId", {
|
|
@@ -5176,8 +5767,10 @@ class Socket extends Emitter_1 {
|
|
|
5176
5767
|
packet.options.compress = this.flags.compress !== false;
|
|
5177
5768
|
// event ack callback
|
|
5178
5769
|
if ("function" === typeof args[args.length - 1]) {
|
|
5179
|
-
|
|
5180
|
-
|
|
5770
|
+
const id = this.ids++;
|
|
5771
|
+
const ack = args.pop();
|
|
5772
|
+
this._registerAckCallback(id, ack);
|
|
5773
|
+
packet.id = id;
|
|
5181
5774
|
}
|
|
5182
5775
|
const isTransportWritable = this.io.engine &&
|
|
5183
5776
|
this.io.engine.transport &&
|
|
@@ -5193,6 +5786,31 @@ class Socket extends Emitter_1 {
|
|
|
5193
5786
|
this.flags = {};
|
|
5194
5787
|
return this;
|
|
5195
5788
|
}
|
|
5789
|
+
/**
|
|
5790
|
+
* @private
|
|
5791
|
+
*/
|
|
5792
|
+
_registerAckCallback(id, ack) {
|
|
5793
|
+
const timeout = this.flags.timeout;
|
|
5794
|
+
if (timeout === undefined) {
|
|
5795
|
+
this.acks[id] = ack;
|
|
5796
|
+
return;
|
|
5797
|
+
}
|
|
5798
|
+
// @ts-ignore
|
|
5799
|
+
const timer = this.io.setTimeoutFn(() => {
|
|
5800
|
+
delete this.acks[id];
|
|
5801
|
+
for (let i = 0; i < this.sendBuffer.length; i++) {
|
|
5802
|
+
if (this.sendBuffer[i].id === id) {
|
|
5803
|
+
this.sendBuffer.splice(i, 1);
|
|
5804
|
+
}
|
|
5805
|
+
}
|
|
5806
|
+
ack.call(this, new Error("operation has timed out"));
|
|
5807
|
+
}, timeout);
|
|
5808
|
+
this.acks[id] = (...args) => {
|
|
5809
|
+
// @ts-ignore
|
|
5810
|
+
this.io.clearTimeoutFn(timer);
|
|
5811
|
+
ack.apply(this, [null, ...args]);
|
|
5812
|
+
};
|
|
5813
|
+
}
|
|
5196
5814
|
/**
|
|
5197
5815
|
* Sends a packet.
|
|
5198
5816
|
*
|
|
@@ -5277,6 +5895,7 @@ class Socket extends Emitter_1 {
|
|
|
5277
5895
|
this.ondisconnect();
|
|
5278
5896
|
break;
|
|
5279
5897
|
case PacketType.CONNECT_ERROR:
|
|
5898
|
+
this.destroy();
|
|
5280
5899
|
const err = new Error(packet.data.message);
|
|
5281
5900
|
// @ts-ignore
|
|
5282
5901
|
err.data = packet.data.data;
|
|
@@ -5440,6 +6059,25 @@ class Socket extends Emitter_1 {
|
|
|
5440
6059
|
this.flags.volatile = true;
|
|
5441
6060
|
return this;
|
|
5442
6061
|
}
|
|
6062
|
+
/**
|
|
6063
|
+
* Sets a modifier for a subsequent event emission that the callback will be called with an error when the
|
|
6064
|
+
* given number of milliseconds have elapsed without an acknowledgement from the server:
|
|
6065
|
+
*
|
|
6066
|
+
* ```
|
|
6067
|
+
* socket.timeout(5000).emit("my-event", (err) => {
|
|
6068
|
+
* if (err) {
|
|
6069
|
+
* // the server did not acknowledge the event in the given delay
|
|
6070
|
+
* }
|
|
6071
|
+
* });
|
|
6072
|
+
* ```
|
|
6073
|
+
*
|
|
6074
|
+
* @returns self
|
|
6075
|
+
* @public
|
|
6076
|
+
*/
|
|
6077
|
+
timeout(timeout) {
|
|
6078
|
+
this.flags.timeout = timeout;
|
|
6079
|
+
return this;
|
|
6080
|
+
}
|
|
5443
6081
|
/**
|
|
5444
6082
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
5445
6083
|
* callback.
|
|
@@ -5846,13 +6484,7 @@ class Manager extends Emitter_1 {
|
|
|
5846
6484
|
_close() {
|
|
5847
6485
|
this.skipReconnect = true;
|
|
5848
6486
|
this._reconnecting = false;
|
|
5849
|
-
|
|
5850
|
-
// `onclose` will not fire because
|
|
5851
|
-
// an open event never happened
|
|
5852
|
-
this.cleanup();
|
|
5853
|
-
}
|
|
5854
|
-
this.backoff.reset();
|
|
5855
|
-
this._readyState = "closed";
|
|
6487
|
+
this.onclose("forced close");
|
|
5856
6488
|
if (this.engine)
|
|
5857
6489
|
this.engine.close();
|
|
5858
6490
|
}
|
|
@@ -5995,12 +6627,12 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
5995
6627
|
// TODO: Authenticate - or at least tell the server who you are
|
|
5996
6628
|
// Socket events
|
|
5997
6629
|
this.socket.on("account_status", function (data) {
|
|
5998
|
-
log("SERVER: account_status: "
|
|
6630
|
+
log("SERVER: account_status: ".concat(JSON.stringify(data)));
|
|
5999
6631
|
// Register the "communication" with the server
|
|
6000
6632
|
if (!_this.token) {
|
|
6001
|
-
_this.token =
|
|
6633
|
+
_this.token = uuid_1();
|
|
6002
6634
|
dispatch(receiveToken(_this.token));
|
|
6003
|
-
log("CLIENT: created token: "
|
|
6635
|
+
log("CLIENT: created token: ".concat(_this.token));
|
|
6004
6636
|
}
|
|
6005
6637
|
_this.socket.emit("connection update", _this.token);
|
|
6006
6638
|
dispatch({
|
|
@@ -6012,7 +6644,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6012
6644
|
});
|
|
6013
6645
|
});
|
|
6014
6646
|
this.socket.on("new message", function (data) {
|
|
6015
|
-
log("SERVER: new message: "
|
|
6647
|
+
log("SERVER: new message: ".concat(JSON.stringify(data)));
|
|
6016
6648
|
_this.dispatch({
|
|
6017
6649
|
type: "chat",
|
|
6018
6650
|
detail: {
|
|
@@ -6027,7 +6659,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6027
6659
|
});
|
|
6028
6660
|
});
|
|
6029
6661
|
this.socket.on("user joined", function (data) {
|
|
6030
|
-
log("SERVER: user joined: "
|
|
6662
|
+
log("SERVER: user joined: ".concat(JSON.stringify(data)));
|
|
6031
6663
|
_this.visitorInfo.token = data.token;
|
|
6032
6664
|
_this.dispatch({
|
|
6033
6665
|
type: "chat",
|
|
@@ -6043,7 +6675,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6043
6675
|
});
|
|
6044
6676
|
});
|
|
6045
6677
|
this.socket.on("user left", function (data) {
|
|
6046
|
-
log("SERVER: user left: "
|
|
6678
|
+
log("SERVER: user left: ".concat(JSON.stringify(data)));
|
|
6047
6679
|
_this.dispatch({
|
|
6048
6680
|
type: "chat",
|
|
6049
6681
|
detail: {
|
|
@@ -6057,7 +6689,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6057
6689
|
});
|
|
6058
6690
|
});
|
|
6059
6691
|
this.socket.on("typing", function (data) {
|
|
6060
|
-
log("SERVER: typing: "
|
|
6692
|
+
log("SERVER: typing: ".concat(JSON.stringify(data)));
|
|
6061
6693
|
_this.dispatch({
|
|
6062
6694
|
type: "chat",
|
|
6063
6695
|
detail: {
|
|
@@ -6071,7 +6703,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6071
6703
|
});
|
|
6072
6704
|
});
|
|
6073
6705
|
this.socket.on("stop typing", function (data) {
|
|
6074
|
-
log("SERVER: stop typing: "
|
|
6706
|
+
log("SERVER: stop typing: ".concat(JSON.stringify(data)));
|
|
6075
6707
|
_this.dispatch({
|
|
6076
6708
|
type: "chat",
|
|
6077
6709
|
detail: {
|
|
@@ -6155,7 +6787,7 @@ function createChatServerCore(config, token) {
|
|
|
6155
6787
|
case "local":
|
|
6156
6788
|
return new StentorLocalChat();
|
|
6157
6789
|
default:
|
|
6158
|
-
throw throwBadKind(config.type);
|
|
6790
|
+
throw throwBadKind$1(config.type);
|
|
6159
6791
|
}
|
|
6160
6792
|
}
|
|
6161
6793
|
function createChatServer(config, token) {
|
|
@@ -6204,8 +6836,8 @@ var ChatChipsContainer = function (_) {
|
|
|
6204
6836
|
dispatch(executeAction(getChatServerActionLinkLabel(option)));
|
|
6205
6837
|
}
|
|
6206
6838
|
}
|
|
6207
|
-
return (React.createElement("div", { className: "message-list-container__chips "
|
|
6208
|
-
React.createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
|
|
6839
|
+
return (React$1.createElement("div", { className: "message-list-container__chips ".concat(!(chips === null || chips === void 0 ? void 0 : chips.length) ? "message-list-container__chips--empty" : "") },
|
|
6840
|
+
React$1.createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
|
|
6209
6841
|
};
|
|
6210
6842
|
|
|
6211
6843
|
var ChatMenuItem = function (props) {
|
|
@@ -6214,24 +6846,24 @@ var ChatMenuItem = function (props) {
|
|
|
6214
6846
|
props.onClick(props.label);
|
|
6215
6847
|
}
|
|
6216
6848
|
}
|
|
6217
|
-
return (React.createElement("button", { type: "button", className: "chat-menu-item", onClick: handleClick }, props.label));
|
|
6849
|
+
return (React$1.createElement("button", { type: "button", className: "chat-menu-item", onClick: handleClick }, props.label));
|
|
6218
6850
|
};
|
|
6219
6851
|
|
|
6220
6852
|
var ChatMenu = function (props) {
|
|
6221
6853
|
var items = props.items;
|
|
6222
|
-
return (React.createElement("div", { className: "chat-menu "
|
|
6223
|
-
return React.createElement(ChatMenuItem, { key: i, onClick: props.onItemClick, label: label });
|
|
6854
|
+
return (React$1.createElement("div", { className: "chat-menu ".concat(props.opened ? "chat-menu--opened" : "chat-menu--closed") }, items.map(function (label, i) {
|
|
6855
|
+
return React$1.createElement(ChatMenuItem, { key: i, onClick: props.onItemClick, label: label });
|
|
6224
6856
|
})));
|
|
6225
6857
|
};
|
|
6226
6858
|
|
|
6227
|
-
var UnknownMessage = function () { return React.createElement(React.Fragment, null); };
|
|
6859
|
+
var UnknownMessage = function () { return React$1.createElement(React$1.Fragment, null); };
|
|
6228
6860
|
|
|
6229
6861
|
function renderAvatar(entity) {
|
|
6230
|
-
return (React.createElement("div", { className: "xappw-chat-msg-part__avatar" },
|
|
6231
|
-
React.createElement(Avatar, { entity: entity })));
|
|
6862
|
+
return (React$1.createElement("div", { className: "xappw-chat-msg-part__avatar" },
|
|
6863
|
+
React$1.createElement(Avatar, { entity: entity })));
|
|
6232
6864
|
}
|
|
6233
6865
|
var ChatMessagePart = function (props) {
|
|
6234
|
-
return (React.createElement("div", { className: "xappw-chat-msg-part" },
|
|
6866
|
+
return (React$1.createElement("div", { className: "xappw-chat-msg-part" },
|
|
6235
6867
|
props.showAvatar && renderAvatar(props.user),
|
|
6236
6868
|
props.children));
|
|
6237
6869
|
};
|
|
@@ -6282,14 +6914,14 @@ var CardMiddlewareWidget = function (props) {
|
|
|
6282
6914
|
var card = useMemo(function () { return convertFromCardDisplay(msg); }, [msg]);
|
|
6283
6915
|
var user = ctx.user;
|
|
6284
6916
|
var handleButton = useButtonCallback();
|
|
6285
|
-
return (React.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6286
|
-
React.createElement("div", { className: "chat-msg" },
|
|
6287
|
-
React.createElement(ChatCard, { card: card, onButtonClick: handleButton }))));
|
|
6917
|
+
return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6918
|
+
React$1.createElement("div", { className: "chat-msg" },
|
|
6919
|
+
React$1.createElement(ChatCard, { card: card, onButtonClick: handleButton }))));
|
|
6288
6920
|
};
|
|
6289
6921
|
var CardMiddleware = function (next) { return function (props) {
|
|
6290
6922
|
var msg = props.msg, ctx = props.ctx;
|
|
6291
6923
|
if (isCard(msg)) {
|
|
6292
|
-
return React.createElement(CardMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6924
|
+
return React$1.createElement(CardMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6293
6925
|
}
|
|
6294
6926
|
return next(props);
|
|
6295
6927
|
}; };
|
|
@@ -6310,11 +6942,11 @@ function createSubscribableArray(originalValue) {
|
|
|
6310
6942
|
return {
|
|
6311
6943
|
getArray: function () { return cache; },
|
|
6312
6944
|
push: function (val) {
|
|
6313
|
-
cache = __spreadArray(__spreadArray([], cache, true), [val], false);
|
|
6945
|
+
cache = __spreadArray$1(__spreadArray$1([], cache, true), [val], false);
|
|
6314
6946
|
notify();
|
|
6315
6947
|
},
|
|
6316
6948
|
unshift: function (val) {
|
|
6317
|
-
cache = __spreadArray([val], cache, true);
|
|
6949
|
+
cache = __spreadArray$1([val], cache, true);
|
|
6318
6950
|
notify();
|
|
6319
6951
|
},
|
|
6320
6952
|
subscribe: function (callback) {
|
|
@@ -6367,22 +6999,22 @@ function useLateMiddlewaresBuilder(storage) {
|
|
|
6367
6999
|
var middlewares = useGlobalSubscribableArray(storage);
|
|
6368
7000
|
return useMemo(function () { return joinMiddlewares(middlewares); }, [middlewares]);
|
|
6369
7001
|
}
|
|
6370
|
-
var storage = createStorage(
|
|
7002
|
+
var storage = createStorage(globalThis, "xappMsgMiddlewares");
|
|
6371
7003
|
function useLateMiddleware() {
|
|
6372
7004
|
return useLateMiddlewaresBuilder(storage);
|
|
6373
7005
|
}
|
|
6374
7006
|
|
|
6375
7007
|
function getSvg() {
|
|
6376
|
-
return (React.createElement("svg", { viewBox: "0 0 20 20" },
|
|
6377
|
-
React.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" }),
|
|
6378
|
-
React.createElement("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })));
|
|
7008
|
+
return (React$1.createElement("svg", { viewBox: "0 0 20 20" },
|
|
7009
|
+
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" }),
|
|
7010
|
+
React$1.createElement("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })));
|
|
6379
7011
|
}
|
|
6380
7012
|
var ExternalLink = function (props) {
|
|
6381
7013
|
var url = props.url;
|
|
6382
7014
|
var handleClick = useCallback(function (ev) {
|
|
6383
7015
|
ev.preventDefault();
|
|
6384
7016
|
}, []);
|
|
6385
|
-
return (React.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick }, getSvg()));
|
|
7017
|
+
return (React$1.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick }, getSvg()));
|
|
6386
7018
|
};
|
|
6387
7019
|
|
|
6388
7020
|
function firstIndex(val, patterns) {
|
|
@@ -6434,7 +7066,7 @@ var parsers = [
|
|
|
6434
7066
|
pathParser,
|
|
6435
7067
|
queryParser
|
|
6436
7068
|
];
|
|
6437
|
-
function parse
|
|
7069
|
+
function parse(val) {
|
|
6438
7070
|
var parts = [];
|
|
6439
7071
|
var rest = val;
|
|
6440
7072
|
for (var _i = 0, parsers_1 = parsers; _i < parsers_1.length; _i++) {
|
|
@@ -6453,7 +7085,7 @@ var ellipsis = "/...";
|
|
|
6453
7085
|
function reduceLink(url, maxLength) {
|
|
6454
7086
|
if (url.length < maxLength)
|
|
6455
7087
|
return url;
|
|
6456
|
-
var parts = parse
|
|
7088
|
+
var parts = parse(url); // [scheme, domain, port, path, query, hash]
|
|
6457
7089
|
function getText() {
|
|
6458
7090
|
return parts.join("");
|
|
6459
7091
|
}
|
|
@@ -6495,7 +7127,7 @@ var SmartLink = function (props) {
|
|
|
6495
7127
|
var handleClick = useCallback(function (ev) {
|
|
6496
7128
|
ev.preventDefault();
|
|
6497
7129
|
}, []);
|
|
6498
|
-
return (React.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: className, onClick: handleClick }, reduceLink(url, 40)));
|
|
7130
|
+
return (React$1.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: className, onClick: handleClick }, reduceLink(url, 40)));
|
|
6499
7131
|
};
|
|
6500
7132
|
|
|
6501
7133
|
var ListItem = function (props) {
|
|
@@ -6503,18 +7135,18 @@ var ListItem = function (props) {
|
|
|
6503
7135
|
var item = props.item;
|
|
6504
7136
|
var layout = props.layout || "normal";
|
|
6505
7137
|
var url = item.url || item.imageActionUrl;
|
|
6506
|
-
return (React.createElement(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
6507
|
-
React.createElement("div", { className: "xappw-vlist-item xappw-vlist-item--"
|
|
6508
|
-
React.createElement("div", { className: "xappw-vlist-item__description" },
|
|
6509
|
-
item.title && React.createElement("div", { className: "xappw-vlist-item__title" },
|
|
6510
|
-
React.createElement("span", null, item.title)),
|
|
6511
|
-
url && React.createElement(SmartLink, { url: url, className: "xappw-vlist-item__link" }),
|
|
6512
|
-
item.subTitle && React.createElement("div", { className: "xappw-vlist-item__subtitle" },
|
|
6513
|
-
React.createElement("span", null, item.subTitle)),
|
|
6514
|
-
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick })),
|
|
6515
|
-
React.createElement("div", { className: "xappw-vlist-item__side" },
|
|
6516
|
-
url && React.createElement(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }),
|
|
6517
|
-
React.createElement(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })))));
|
|
7138
|
+
return (React$1.createElement(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
7139
|
+
React$1.createElement("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout) },
|
|
7140
|
+
React$1.createElement("div", { className: "xappw-vlist-item__description" },
|
|
7141
|
+
item.title && React$1.createElement("div", { className: "xappw-vlist-item__title" },
|
|
7142
|
+
React$1.createElement("span", null, item.title)),
|
|
7143
|
+
url && React$1.createElement(SmartLink, { url: url, className: "xappw-vlist-item__link" }),
|
|
7144
|
+
item.subTitle && React$1.createElement("div", { className: "xappw-vlist-item__subtitle" },
|
|
7145
|
+
React$1.createElement("span", null, item.subTitle)),
|
|
7146
|
+
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick })),
|
|
7147
|
+
React$1.createElement("div", { className: "xappw-vlist-item__side" },
|
|
7148
|
+
url && React$1.createElement(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }),
|
|
7149
|
+
React$1.createElement(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })))));
|
|
6518
7150
|
};
|
|
6519
7151
|
|
|
6520
7152
|
var List = function (props) {
|
|
@@ -6523,12 +7155,12 @@ var List = function (props) {
|
|
|
6523
7155
|
var hasImage = list.items.some(function (item) { return item.imageUrl; });
|
|
6524
7156
|
var titlesOnly = !list.items.some(function (item) { var _a; return item.subTitle || ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length); });
|
|
6525
7157
|
var listItems = list.items.map(function (item, itemIndex) {
|
|
6526
|
-
return (React.createElement("div", { className: "xappw-vlist-container__item", key: "item-key-"
|
|
6527
|
-
React.createElement(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
7158
|
+
return (React$1.createElement("div", { className: "xappw-vlist-container__item", key: "item-key-".concat(itemIndex) },
|
|
7159
|
+
React$1.createElement(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
6528
7160
|
});
|
|
6529
|
-
return (React.createElement("div", { className: "xappw-vlist" },
|
|
6530
|
-
React.createElement("div", { ref: listRef, className: "xappw-vlist-container" },
|
|
6531
|
-
props.list.title && React.createElement("div", { className: "xappw-vlist__header" }, props.list.title),
|
|
7161
|
+
return (React$1.createElement("div", { className: "xappw-vlist" },
|
|
7162
|
+
React$1.createElement("div", { ref: listRef, className: "xappw-vlist-container" },
|
|
7163
|
+
props.list.title && React$1.createElement("div", { className: "xappw-vlist__header" }, props.list.title),
|
|
6532
7164
|
listItems)));
|
|
6533
7165
|
};
|
|
6534
7166
|
|
|
@@ -6538,16 +7170,16 @@ var ListMiddlewareWidget = function (props) {
|
|
|
6538
7170
|
var handleExecute = useExecuteActionCallback();
|
|
6539
7171
|
var handleButton = useButtonCallback();
|
|
6540
7172
|
var user = ctx.user;
|
|
6541
|
-
return (React.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6542
|
-
list.type === "CAROUSEL" && React.createElement("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava" },
|
|
6543
|
-
React.createElement(Carousel, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl })),
|
|
6544
|
-
list.type === "LIST" && React.createElement("div", { className: "chat-msg chat-msg--expand" },
|
|
6545
|
-
React.createElement(List, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl }))));
|
|
7173
|
+
return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
7174
|
+
list.type === "CAROUSEL" && React$1.createElement("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava" },
|
|
7175
|
+
React$1.createElement(Carousel, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl })),
|
|
7176
|
+
list.type === "LIST" && React$1.createElement("div", { className: "chat-msg chat-msg--expand" },
|
|
7177
|
+
React$1.createElement(List, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl }))));
|
|
6546
7178
|
};
|
|
6547
7179
|
var ListMiddleware = function (next) { return function (props) {
|
|
6548
7180
|
var msg = props.msg, ctx = props.ctx;
|
|
6549
7181
|
if (isList(msg)) {
|
|
6550
|
-
return React.createElement(ListMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
7182
|
+
return React$1.createElement(ListMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6551
7183
|
}
|
|
6552
7184
|
return next(props);
|
|
6553
7185
|
}; };
|
|
@@ -6559,10 +7191,10 @@ var MultiSelect = function (props) {
|
|
|
6559
7191
|
var id = ev.target.value;
|
|
6560
7192
|
onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
|
|
6561
7193
|
}, [checked, onChange]);
|
|
6562
|
-
return (React.createElement("ul", { className: "xappw-multiselect" }, items.map(function (item) { return (React.createElement("li", { key: item.id },
|
|
6563
|
-
React.createElement("label", null,
|
|
6564
|
-
React.createElement("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }),
|
|
6565
|
-
React.createElement("span", null, item.title)))); })));
|
|
7194
|
+
return (React$1.createElement("ul", { className: "xappw-multiselect" }, items.map(function (item) { return (React$1.createElement("li", { key: item.id },
|
|
7195
|
+
React$1.createElement("label", null,
|
|
7196
|
+
React$1.createElement("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }),
|
|
7197
|
+
React$1.createElement("span", null, item.title)))); })));
|
|
6566
7198
|
};
|
|
6567
7199
|
|
|
6568
7200
|
function isMultiSelect(display) {
|
|
@@ -6586,16 +7218,16 @@ var MultiSelectMiddlewareWidget = function (props) {
|
|
|
6586
7218
|
})
|
|
6587
7219
|
});
|
|
6588
7220
|
}, [ctx, checked]);
|
|
6589
|
-
return (React.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6590
|
-
React.createElement("div", { className: "chat-msg" },
|
|
6591
|
-
React.createElement("div", null,
|
|
6592
|
-
React.createElement(MultiSelect, { items: items, checked: checked, onChange: setChecked }),
|
|
6593
|
-
React.createElement(ActionButton, { label: "Submit", onClick: handleSubmit })))));
|
|
7221
|
+
return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
7222
|
+
React$1.createElement("div", { className: "chat-msg" },
|
|
7223
|
+
React$1.createElement("div", null,
|
|
7224
|
+
React$1.createElement(MultiSelect, { items: items, checked: checked, onChange: setChecked }),
|
|
7225
|
+
React$1.createElement(ActionButton, { label: "Submit", onClick: handleSubmit })))));
|
|
6594
7226
|
};
|
|
6595
7227
|
var MultiSelectMiddleware = function (next) { return function (props) {
|
|
6596
7228
|
var msg = props.msg, ctx = props.ctx;
|
|
6597
7229
|
if (isMultiSelect(msg)) {
|
|
6598
|
-
return React.createElement(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
7230
|
+
return React$1.createElement(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6599
7231
|
}
|
|
6600
7232
|
return next(props);
|
|
6601
7233
|
}; };
|
|
@@ -6625,8 +7257,8 @@ function getTailSvgPath(owner) {
|
|
|
6625
7257
|
return "m 0 0 v 240 h 60 c -40 -40 -60 -160 -60 -240";
|
|
6626
7258
|
}
|
|
6627
7259
|
function getTailSvg(owner) {
|
|
6628
|
-
return (React.createElement("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240" },
|
|
6629
|
-
React.createElement("path", { d: getTailSvgPath(owner), fill: "currentColor" })));
|
|
7260
|
+
return (React$1.createElement("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240" },
|
|
7261
|
+
React$1.createElement("path", { d: getTailSvgPath(owner), fill: "currentColor" })));
|
|
6630
7262
|
}
|
|
6631
7263
|
var ChatMessageBubble = function (props) {
|
|
6632
7264
|
var owner = props.owner, onClick = props.onClick;
|
|
@@ -6635,7 +7267,7 @@ var ChatMessageBubble = function (props) {
|
|
|
6635
7267
|
onClick();
|
|
6636
7268
|
}
|
|
6637
7269
|
}, [onClick]);
|
|
6638
|
-
return (React.createElement("div", { onClick: handleClick, className: "chat-text-bubble "
|
|
7270
|
+
return (React$1.createElement("div", { onClick: handleClick, className: "chat-text-bubble ".concat(owner === "mine" ? "chat-text-bubble--mine" : "chat-text-bubble--others") },
|
|
6639
7271
|
(props.hasTail) && getTailSvg(owner),
|
|
6640
7272
|
props.children));
|
|
6641
7273
|
};
|
|
@@ -6669,10 +7301,10 @@ var ChatMarkdownMessage = function (props) {
|
|
|
6669
7301
|
}
|
|
6670
7302
|
return undefined;
|
|
6671
7303
|
}, [ref, html, onOpenUrl, handleLinkClick]);
|
|
6672
|
-
return (React.createElement("div", { className: "chat-msg" },
|
|
6673
|
-
React.createElement("div", { className: "chat-text-container" },
|
|
6674
|
-
React.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
6675
|
-
React.createElement("div", { ref: ref })))));
|
|
7304
|
+
return (React$1.createElement("div", { className: "chat-msg" },
|
|
7305
|
+
React$1.createElement("div", { className: "chat-text-container" },
|
|
7306
|
+
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
7307
|
+
React$1.createElement("div", { ref: ref })))));
|
|
6676
7308
|
};
|
|
6677
7309
|
|
|
6678
7310
|
var ChatPermissionMessage = function (props) {
|
|
@@ -6742,20 +7374,20 @@ var ChatPermissionMessage = function (props) {
|
|
|
6742
7374
|
}
|
|
6743
7375
|
}, [handleFail, handleResult]);
|
|
6744
7376
|
if (!permissionRequest) {
|
|
6745
|
-
return React.createElement(React.Fragment, null);
|
|
7377
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
6746
7378
|
}
|
|
6747
|
-
return (React.createElement("div", { className: "chat-msg" },
|
|
6748
|
-
React.createElement("div", { className: "buttons-container" },
|
|
6749
|
-
React.createElement(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }),
|
|
6750
|
-
React.createElement(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny }))));
|
|
7379
|
+
return (React$1.createElement("div", { className: "chat-msg" },
|
|
7380
|
+
React$1.createElement("div", { className: "buttons-container" },
|
|
7381
|
+
React$1.createElement(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }),
|
|
7382
|
+
React$1.createElement(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny }))));
|
|
6751
7383
|
};
|
|
6752
7384
|
|
|
6753
7385
|
var ChatTextMessage = function (props) {
|
|
6754
7386
|
var agentMessage = isAgent(props.message.user.nick);
|
|
6755
|
-
return (React.createElement("div", { className: "chat-msg" },
|
|
6756
|
-
React.createElement("div", { className: "chat-text-container" },
|
|
6757
|
-
React.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
6758
|
-
React.createElement("span", null, props.message.msg.text)))));
|
|
7387
|
+
return (React$1.createElement("div", { className: "chat-msg" },
|
|
7388
|
+
React$1.createElement("div", { className: "chat-text-container" },
|
|
7389
|
+
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
7390
|
+
React$1.createElement("span", null, props.message.msg.text)))));
|
|
6759
7391
|
};
|
|
6760
7392
|
|
|
6761
7393
|
function getClassName(msg) {
|
|
@@ -6779,26 +7411,26 @@ var ChatMessage = function (props) {
|
|
|
6779
7411
|
// Here is the deal. If we have text (output speech), then text - card - list - options
|
|
6780
7412
|
// OR card OR list only. Avatar with text bubble.
|
|
6781
7413
|
var avaKey = avaKeys.find(function (key) { return !!msg[key]; });
|
|
6782
|
-
return (React.createElement(React.Fragment, null,
|
|
7414
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
6783
7415
|
msg.text &&
|
|
6784
|
-
React.createElement(ChatMessagePart, { showAvatar: avaKey === "text", user: user },
|
|
6785
|
-
React.createElement(ChatTextMessage, { message: props.message, sibling: props.sibling })),
|
|
7416
|
+
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "text", user: user },
|
|
7417
|
+
React$1.createElement(ChatTextMessage, { message: props.message, sibling: props.sibling })),
|
|
6786
7418
|
msg.html &&
|
|
6787
|
-
React.createElement(ChatMessagePart, { showAvatar: avaKey === "html", user: user },
|
|
6788
|
-
React.createElement(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_a = props.middlewareContext) === null || _a === void 0 ? void 0 : _a.openUrl })),
|
|
7419
|
+
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "html", user: user },
|
|
7420
|
+
React$1.createElement(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_a = props.middlewareContext) === null || _a === void 0 ? void 0 : _a.openUrl })),
|
|
6789
7421
|
msg.displays && middleware && msg.displays.map(function (display, index) {
|
|
6790
7422
|
var Middleware = middleware;
|
|
6791
|
-
return React.createElement(Middleware, { key: index, msg: display, ctx: props.middlewareContext });
|
|
7423
|
+
return React$1.createElement(Middleware, { key: index, msg: display, ctx: props.middlewareContext });
|
|
6792
7424
|
}),
|
|
6793
7425
|
msg.permissionRequest &&
|
|
6794
|
-
React.createElement(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user },
|
|
6795
|
-
React.createElement(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: props.middlewareContext }))));
|
|
7426
|
+
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user },
|
|
7427
|
+
React$1.createElement(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: props.middlewareContext }))));
|
|
6796
7428
|
}
|
|
6797
|
-
return (React.createElement(React.Fragment, null));
|
|
7429
|
+
return (React$1.createElement(React$1.Fragment, null));
|
|
6798
7430
|
}
|
|
6799
7431
|
// empty
|
|
6800
|
-
return (React.createElement("div", { className: "chat-msg-container-wrapper "
|
|
6801
|
-
React.createElement("div", { className: "chat-msg-container "
|
|
7432
|
+
return (React$1.createElement("div", { className: "chat-msg-container-wrapper ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor", " ").concat(props.sibling ? "sibling" : "") },
|
|
7433
|
+
React$1.createElement("div", { className: "chat-msg-container ".concat(getClassName(props.message)) }, renderByType())));
|
|
6802
7434
|
};
|
|
6803
7435
|
|
|
6804
7436
|
function useExternalScript(url) {
|
|
@@ -6826,7 +7458,7 @@ function getSafeCh(ch) {
|
|
|
6826
7458
|
if (ch >= "A" && ch <= "Z") {
|
|
6827
7459
|
return ch;
|
|
6828
7460
|
}
|
|
6829
|
-
return "_"
|
|
7461
|
+
return "_".concat(ch.charCodeAt(0), "_");
|
|
6830
7462
|
}
|
|
6831
7463
|
function getSrcId(url) {
|
|
6832
7464
|
var res = "es-";
|
|
@@ -6872,191 +7504,26 @@ function useGreeting(active) {
|
|
|
6872
7504
|
}
|
|
6873
7505
|
|
|
6874
7506
|
function match(item, pattern) {
|
|
6875
|
-
var value = item.
|
|
7507
|
+
var value = item.text;
|
|
6876
7508
|
return value.toLocaleLowerCase().indexOf(pattern.toLocaleLowerCase()) >= 0;
|
|
6877
|
-
}
|
|
6878
|
-
function mapFormat$1(formats, length) {
|
|
6879
|
-
var res = [];
|
|
6880
|
-
var walkerIndex = 0;
|
|
6881
|
-
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
|
|
6882
|
-
var format = formats_1[_i];
|
|
6883
|
-
var start = format.start, end = format.end, type = format.type;
|
|
6884
|
-
if (walkerIndex < start) {
|
|
6885
|
-
res.push({
|
|
6886
|
-
type: "normal",
|
|
6887
|
-
start: walkerIndex,
|
|
6888
|
-
end: start
|
|
6889
|
-
});
|
|
6890
|
-
}
|
|
6891
|
-
res.push({
|
|
6892
|
-
type: type,
|
|
6893
|
-
start: start,
|
|
6894
|
-
end: end
|
|
6895
|
-
});
|
|
6896
|
-
walkerIndex = end;
|
|
6897
|
-
}
|
|
6898
|
-
if (walkerIndex < length) {
|
|
6899
|
-
res.push({
|
|
6900
|
-
type: "normal",
|
|
6901
|
-
start: walkerIndex,
|
|
6902
|
-
end: length
|
|
6903
|
-
});
|
|
6904
|
-
}
|
|
6905
|
-
return res;
|
|
6906
|
-
}
|
|
6907
|
-
|
|
6908
|
-
/**
|
|
6909
|
-
* Append the provided query params to the URL
|
|
6910
|
-
*
|
|
6911
|
-
* It will overwrite existing params on the URL if there are conflicts
|
|
6912
|
-
* @param url
|
|
6913
|
-
* @param params
|
|
6914
|
-
*/
|
|
6915
|
-
function addQueryParametersToURL(url, params) {
|
|
6916
|
-
if (!url) {
|
|
6917
|
-
return undefined;
|
|
6918
|
-
}
|
|
6919
|
-
var existingParams = new URL(url).searchParams;
|
|
6920
|
-
params.forEach(function (value, key) {
|
|
6921
|
-
existingParams.append(key, value);
|
|
6922
|
-
});
|
|
6923
|
-
var newUrl = new URL(url);
|
|
6924
|
-
newUrl.search = existingParams.toString();
|
|
6925
|
-
return newUrl;
|
|
6926
|
-
}
|
|
6927
|
-
|
|
6928
|
-
var defaultOptions = {};
|
|
6929
|
-
function noop$1() {
|
|
6930
|
-
}
|
|
6931
|
-
function useJsonFetch(url, options) {
|
|
6932
|
-
if (options === void 0) { options = defaultOptions; }
|
|
6933
|
-
var _a = useState({
|
|
6934
|
-
fetching: true
|
|
6935
|
-
}), value = _a[0], setValue = _a[1];
|
|
6936
|
-
var pause = options.pause;
|
|
6937
|
-
useEffect(function () {
|
|
6938
|
-
if (pause) {
|
|
6939
|
-
setValue({
|
|
6940
|
-
fetching: true
|
|
6941
|
-
});
|
|
6942
|
-
return noop$1;
|
|
6943
|
-
}
|
|
6944
|
-
var controller = new AbortController();
|
|
6945
|
-
var signal = controller.signal;
|
|
6946
|
-
var mounted = true;
|
|
6947
|
-
(function () {
|
|
6948
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
6949
|
-
var response, json, e_1;
|
|
6950
|
-
return __generator(this, function (_a) {
|
|
6951
|
-
switch (_a.label) {
|
|
6952
|
-
case 0:
|
|
6953
|
-
_a.trys.push([0, 4, , 5]);
|
|
6954
|
-
return [4 /*yield*/, fetch(url, { signal: signal })];
|
|
6955
|
-
case 1:
|
|
6956
|
-
response = _a.sent();
|
|
6957
|
-
if (!mounted) return [3 /*break*/, 3];
|
|
6958
|
-
return [4 /*yield*/, response.json()];
|
|
6959
|
-
case 2:
|
|
6960
|
-
json = _a.sent();
|
|
6961
|
-
if (response.ok) {
|
|
6962
|
-
setValue({
|
|
6963
|
-
fetching: false,
|
|
6964
|
-
success: true,
|
|
6965
|
-
data: json
|
|
6966
|
-
});
|
|
6967
|
-
}
|
|
6968
|
-
else {
|
|
6969
|
-
setValue({
|
|
6970
|
-
fetching: false,
|
|
6971
|
-
success: false,
|
|
6972
|
-
error: json
|
|
6973
|
-
});
|
|
6974
|
-
}
|
|
6975
|
-
_a.label = 3;
|
|
6976
|
-
case 3: return [3 /*break*/, 5];
|
|
6977
|
-
case 4:
|
|
6978
|
-
e_1 = _a.sent();
|
|
6979
|
-
if (e_1.name === "AbortError") {
|
|
6980
|
-
return [2 /*return*/];
|
|
6981
|
-
}
|
|
6982
|
-
throw e_1;
|
|
6983
|
-
case 5: return [2 /*return*/];
|
|
6984
|
-
}
|
|
6985
|
-
});
|
|
6986
|
-
});
|
|
6987
|
-
})();
|
|
6988
|
-
return function () {
|
|
6989
|
-
mounted = false;
|
|
6990
|
-
controller.abort();
|
|
6991
|
-
};
|
|
6992
|
-
}, [url, pause]);
|
|
6993
|
-
return value;
|
|
6994
7509
|
}
|
|
6995
7510
|
|
|
6996
7511
|
function useSuggestionsFetch(search, context) {
|
|
6997
7512
|
var env = useWidgetEnv();
|
|
6998
7513
|
var baseUrl = env === null || env === void 0 ? void 0 : env.autocompleteSuggestionsUrl;
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
if (context === null || context === void 0 ? void 0 : context.length) {
|
|
7004
|
-
params.append("activeContexts", context.join(","));
|
|
7005
|
-
}
|
|
7006
|
-
return addQueryParametersToURL(baseUrl, params);
|
|
7007
|
-
}, [search, context, baseUrl]);
|
|
7008
|
-
var response = useJsonFetch(url ? "" + url.toString() : "", {
|
|
7009
|
-
pause: !search || !baseUrl
|
|
7514
|
+
return useSuggestionsFetch_1({
|
|
7515
|
+
url: baseUrl,
|
|
7516
|
+
query: search,
|
|
7517
|
+
context: context
|
|
7010
7518
|
});
|
|
7011
|
-
return useMemo(function () {
|
|
7012
|
-
if (!search) {
|
|
7013
|
-
return undefined;
|
|
7014
|
-
}
|
|
7015
|
-
if (response.fetching === false) {
|
|
7016
|
-
if (response.success) {
|
|
7017
|
-
return response.data;
|
|
7018
|
-
}
|
|
7019
|
-
else {
|
|
7020
|
-
return undefined;
|
|
7021
|
-
}
|
|
7022
|
-
}
|
|
7023
|
-
return undefined;
|
|
7024
|
-
}, [search, response]);
|
|
7025
7519
|
}
|
|
7026
7520
|
|
|
7027
7521
|
function norm(index, len) {
|
|
7028
7522
|
return (index + len) % len;
|
|
7029
7523
|
}
|
|
7030
|
-
function mapFormat(format) {
|
|
7031
|
-
var types = Object.keys(format);
|
|
7032
|
-
var type = types[0];
|
|
7033
|
-
var item = format[type];
|
|
7034
|
-
return {
|
|
7035
|
-
type: type,
|
|
7036
|
-
start: item.start,
|
|
7037
|
-
end: item.end
|
|
7038
|
-
};
|
|
7039
|
-
}
|
|
7040
|
-
function mapFormats(formats) {
|
|
7041
|
-
return formats.map(mapFormat);
|
|
7042
|
-
}
|
|
7043
|
-
function parseItem(responseItem) {
|
|
7044
|
-
var suggestion = responseItem.suggestion;
|
|
7045
|
-
return {
|
|
7046
|
-
suggestion: suggestion,
|
|
7047
|
-
answer: responseItem.answer,
|
|
7048
|
-
type: responseItem.type,
|
|
7049
|
-
format: mapFormats(responseItem.format)
|
|
7050
|
-
};
|
|
7051
|
-
}
|
|
7052
|
-
function parse(response) {
|
|
7053
|
-
return {
|
|
7054
|
-
items: response.suggestions.map(parseItem)
|
|
7055
|
-
};
|
|
7056
|
-
}
|
|
7057
7524
|
function useSuggestions(search, context) {
|
|
7058
7525
|
var _a = useState(), suggestions = _a[0], setSuggestions = _a[1];
|
|
7059
|
-
var _b = useState(
|
|
7526
|
+
var _b = useState(-1), suggestionIndex = _b[0], setSuggestionIndex = _b[1];
|
|
7060
7527
|
var _c = useState(search), query = _c[0], setQuery = _c[1];
|
|
7061
7528
|
var _d = useState(context), contextState = _d[0], setContextState = _d[1];
|
|
7062
7529
|
useEffect(function () {
|
|
@@ -7065,15 +7532,10 @@ function useSuggestions(search, context) {
|
|
|
7065
7532
|
useEffect(function () {
|
|
7066
7533
|
setContextState(context);
|
|
7067
7534
|
}, [context]);
|
|
7068
|
-
var suggestionItem = useMemo(function () {
|
|
7069
|
-
if (suggestionIndex >= 0 && suggestions) {
|
|
7070
|
-
return suggestions.items[suggestionIndex];
|
|
7071
|
-
}
|
|
7072
|
-
return undefined;
|
|
7073
|
-
}, [suggestions, suggestionIndex]);
|
|
7535
|
+
var suggestionItem = useMemo(function () { return suggestions ? findItemByIndex_1(suggestions, suggestionIndex) : undefined; }, [suggestions, suggestionIndex]);
|
|
7074
7536
|
var shift = useCallback(function (delta) {
|
|
7075
7537
|
if (suggestions) {
|
|
7076
|
-
var len_1 = suggestions
|
|
7538
|
+
var len_1 = getItemsLength_1(suggestions);
|
|
7077
7539
|
setSuggestionIndex(function (index) { return norm(index + delta + ((index < 0 && delta <= 0) ? 1 : 0), len_1); });
|
|
7078
7540
|
}
|
|
7079
7541
|
else {
|
|
@@ -7095,20 +7557,26 @@ function useSuggestions(search, context) {
|
|
|
7095
7557
|
break;
|
|
7096
7558
|
}
|
|
7097
7559
|
}, [shift]);
|
|
7098
|
-
var suggestionsResponse = useSuggestionsFetch(query, contextState);
|
|
7560
|
+
var suggestionsResponse = useSuggestionsFetch(query || "", contextState);
|
|
7561
|
+
var suggestionsData = suggestionsResponse.state === "success" ? suggestionsResponse.data : undefined;
|
|
7099
7562
|
var raw = useMemo(function () {
|
|
7100
|
-
return
|
|
7101
|
-
}, [
|
|
7563
|
+
return suggestionsData ? parseSuggestionsResponse_1(suggestionsData, -1) : undefined;
|
|
7564
|
+
}, [suggestionsData]);
|
|
7102
7565
|
useEffect(function () {
|
|
7103
7566
|
var prev = suggestionItem;
|
|
7104
7567
|
setSuggestions(raw);
|
|
7105
7568
|
if (prev && raw) {
|
|
7106
|
-
var prevValue = prev.
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7569
|
+
var prevValue = prev.text;
|
|
7570
|
+
var index = 0;
|
|
7571
|
+
for (var _i = 0, raw_1 = raw; _i < raw_1.length; _i++) {
|
|
7572
|
+
var group = raw_1[_i];
|
|
7573
|
+
for (var _a = 0, _b = group.items; _a < _b.length; _a++) {
|
|
7574
|
+
var item = _b[_a];
|
|
7575
|
+
if (match(item, prevValue)) {
|
|
7576
|
+
setSuggestionIndex(index);
|
|
7577
|
+
break;
|
|
7578
|
+
}
|
|
7579
|
+
index++;
|
|
7112
7580
|
}
|
|
7113
7581
|
}
|
|
7114
7582
|
}
|
|
@@ -7125,42 +7593,35 @@ function useSuggestions(search, context) {
|
|
|
7125
7593
|
}
|
|
7126
7594
|
|
|
7127
7595
|
var DrawerBars = function (props) {
|
|
7128
|
-
return (React.createElement("div", { className: "drawer-bars", onClick: props.onToggle },
|
|
7129
|
-
React.createElement("div", { className: "drawer-bar bar1" }),
|
|
7130
|
-
React.createElement("div", { className: "drawer-bar bar2" })));
|
|
7131
|
-
};
|
|
7132
|
-
|
|
7133
|
-
var IconButton = function (props) {
|
|
7134
|
-
var type = props.type || "button";
|
|
7135
|
-
var Icon = props.icon;
|
|
7136
|
-
return (React.createElement("button", { type: type, className: "xappw-icon-button " + (props.className || ""), onClick: props.onClick },
|
|
7137
|
-
React.createElement(Icon, null)));
|
|
7596
|
+
return (React$1.createElement("div", { className: "drawer-bars", onClick: props.onToggle },
|
|
7597
|
+
React$1.createElement("div", { className: "drawer-bar bar1" }),
|
|
7598
|
+
React$1.createElement("div", { className: "drawer-bar bar2" })));
|
|
7138
7599
|
};
|
|
7139
7600
|
|
|
7140
7601
|
var CloseIcon = function () {
|
|
7141
7602
|
// Sergey, I added this style, you will probably want to change it to be more appropriate
|
|
7142
|
-
return (React.createElement("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7143
|
-
React.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" })));
|
|
7603
|
+
return (React$1.createElement("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7604
|
+
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" })));
|
|
7144
7605
|
};
|
|
7145
7606
|
|
|
7146
7607
|
var LeftDownArrowIcon = function () {
|
|
7147
|
-
return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7148
|
-
React.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" })));
|
|
7608
|
+
return (React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7609
|
+
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" })));
|
|
7149
7610
|
};
|
|
7150
7611
|
|
|
7151
7612
|
var SendIcon = function () {
|
|
7152
|
-
return (React.createElement("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg" },
|
|
7153
|
-
React.createElement("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none" },
|
|
7154
|
-
React.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" }),
|
|
7155
|
-
React.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" }))));
|
|
7613
|
+
return (React$1.createElement("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg" },
|
|
7614
|
+
React$1.createElement("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none" },
|
|
7615
|
+
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" }),
|
|
7616
|
+
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" }))));
|
|
7156
7617
|
};
|
|
7157
7618
|
|
|
7158
7619
|
var SendButton = function (props) {
|
|
7159
|
-
return (React.createElement(
|
|
7620
|
+
return (React$1.createElement(IconButton_1, { className: "xappw-send-button ".concat(props.className || ""), onClick: props.onClick, icon: SendIcon }));
|
|
7160
7621
|
};
|
|
7161
7622
|
|
|
7162
7623
|
var Input = function (props) {
|
|
7163
|
-
var value = props.value, suggestion = props.suggestion, onChange = props.onChange, onSuggestionCommand = props.onSuggestionCommand;
|
|
7624
|
+
var value = props.value, suggestion = props.suggestion, onChange = props.onChange, onSubmit = props.onSubmit, onSuggestionCommand = props.onSuggestionCommand;
|
|
7164
7625
|
var _a = useState(false), dragover = _a[0], setDragover = _a[1];
|
|
7165
7626
|
function onDragOver(event) {
|
|
7166
7627
|
setDragover(true);
|
|
@@ -7174,32 +7635,30 @@ var Input = function (props) {
|
|
|
7174
7635
|
function onDragLeave() {
|
|
7175
7636
|
setDragover(false);
|
|
7176
7637
|
}
|
|
7177
|
-
|
|
7638
|
+
var handleOnSubmit = useCallback(function (event) {
|
|
7178
7639
|
event && event.preventDefault();
|
|
7179
|
-
|
|
7180
|
-
}
|
|
7181
|
-
var handleOnChange = useCallback(function (event) {
|
|
7182
|
-
var val = event.target.value;
|
|
7183
|
-
onChange(val);
|
|
7184
|
-
}, [onChange]);
|
|
7640
|
+
onSubmit(value); // send to the widget
|
|
7641
|
+
}, [value, onSubmit]);
|
|
7185
7642
|
var handleClear = useCallback(function () {
|
|
7186
|
-
onChange(
|
|
7643
|
+
onChange({
|
|
7644
|
+
text: "",
|
|
7645
|
+
formats: []
|
|
7646
|
+
});
|
|
7187
7647
|
}, [onChange]);
|
|
7188
7648
|
var handleKeyDown = useCallback(function (event) {
|
|
7189
7649
|
if (suggestion) {
|
|
7190
7650
|
if (event.key === "End" || event.key === "ArrowRight" || event.key === "Enter") {
|
|
7191
|
-
|
|
7192
|
-
onChange(newVal);
|
|
7651
|
+
onChange(suggestion);
|
|
7193
7652
|
return;
|
|
7194
7653
|
}
|
|
7195
7654
|
}
|
|
7196
7655
|
if (onSuggestionCommand) {
|
|
7197
7656
|
if (event.key === "ArrowUp") {
|
|
7198
|
-
onSuggestionCommand("
|
|
7657
|
+
onSuggestionCommand("prev");
|
|
7199
7658
|
event.preventDefault();
|
|
7200
7659
|
}
|
|
7201
7660
|
else if (event.key === "ArrowDown") {
|
|
7202
|
-
onSuggestionCommand("
|
|
7661
|
+
onSuggestionCommand("next");
|
|
7203
7662
|
event.preventDefault();
|
|
7204
7663
|
}
|
|
7205
7664
|
else if (event.key === "Escape") {
|
|
@@ -7208,116 +7667,59 @@ var Input = function (props) {
|
|
|
7208
7667
|
}
|
|
7209
7668
|
}
|
|
7210
7669
|
}, [suggestion, onChange, onSuggestionCommand]);
|
|
7211
|
-
return (React.createElement("div", { className: "xappw-input-container "
|
|
7212
|
-
React.createElement("form", { className: "xappw-input-form", onSubmit: handleOnSubmit },
|
|
7213
|
-
|
|
7214
|
-
React.createElement("input", { key: "input", className: "xappw-input", placeholder: "Type your question here...", onChange: handleOnChange, onKeyDown: handleKeyDown,
|
|
7670
|
+
return (React$1.createElement("div", { className: "xappw-input-container ".concat(props.addClass, " ").concat(dragover ? "drag-drop-zone" : ""), onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave },
|
|
7671
|
+
React$1.createElement("form", { className: "xappw-input-form", onSubmit: handleOnSubmit },
|
|
7672
|
+
React$1.createElement(RichInput_1, { key: "input", className: "xappw-input", placeholder: "Type your question here...", onInput: onChange, onChange: onChange, onKeyDown: handleKeyDown,
|
|
7215
7673
|
// onFocus={onFocus}
|
|
7216
|
-
value: value
|
|
7217
|
-
React.createElement("div", { className: "xappw-input-form__buttons" },
|
|
7218
|
-
value && React.createElement(
|
|
7219
|
-
React.createElement(SendButton, { onClick: handleOnSubmit })))));
|
|
7220
|
-
};
|
|
7221
|
-
|
|
7222
|
-
var SuggestionsItem = function (props) {
|
|
7223
|
-
var data = props.data, onClick = props.onClick, onUse = props.onUse, onHover = props.onHover;
|
|
7224
|
-
var suggestion = data.suggestion;
|
|
7225
|
-
var handleClick = useCallback(function () {
|
|
7226
|
-
onClick(data);
|
|
7227
|
-
}, [data, onClick]);
|
|
7228
|
-
var handleUse = useCallback(function (ev) {
|
|
7229
|
-
onUse(data);
|
|
7230
|
-
ev.stopPropagation();
|
|
7231
|
-
}, [data, onUse]);
|
|
7232
|
-
var handleHover = useCallback(function () {
|
|
7233
|
-
onHover(data);
|
|
7234
|
-
}, [data, onHover]);
|
|
7235
|
-
var formats = useMemo(function () { return mapFormat$1(data.format, suggestion.length); }, [data.format, suggestion]);
|
|
7236
|
-
var canUse = data.type !== "FAQ";
|
|
7237
|
-
return (React.createElement("div", { className: "xappw-suggestions-item " + (props.current ? "xappw-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover },
|
|
7238
|
-
React.createElement("div", { className: "xappw-suggestions-item__texts" }, formats.map(function (format, index) { return (React.createElement("span", { className: "xappw-suggestions-item__text xappw-suggestions-item__text--" + format.type, key: index }, suggestion.substring(format.start, format.end))); })),
|
|
7239
|
-
canUse && React.createElement(IconButton, { className: "xappw-suggestions-item__use", onClick: handleUse, icon: LeftDownArrowIcon })));
|
|
7674
|
+
value: value }),
|
|
7675
|
+
React$1.createElement("div", { className: "xappw-input-form__buttons" },
|
|
7676
|
+
value.text && React$1.createElement(IconButton_1, { icon: CloseIcon, className: "xappw-input-form__btn", onClick: handleClear }),
|
|
7677
|
+
React$1.createElement(SendButton, { className: "xappw-input-form__btn", onClick: handleOnSubmit })))));
|
|
7240
7678
|
};
|
|
7241
7679
|
|
|
7242
|
-
function
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
}
|
|
7254
|
-
|
|
7255
|
-
var group = props.group, currentIndex = props.currentIndex;
|
|
7256
|
-
var type = group.type, items = group.items, startIndex = group.startIndex;
|
|
7257
|
-
return (React.createElement("div", { className: "xappw-suggestions-group" },
|
|
7258
|
-
React.createElement("label", { className: "xappw-suggestions-group__label" }, getLabel(type)),
|
|
7259
|
-
React.createElement("div", { className: "xappw-suggestions-group__items" }, items.map(function (item, itemIndex) {
|
|
7260
|
-
return React.createElement(SuggestionsItem, { key: itemIndex, data: item, current: currentIndex === itemIndex + startIndex, onClick: props.onItemClick, onUse: props.onItemUse, onHover: props.onItemHover });
|
|
7261
|
-
}))));
|
|
7262
|
-
};
|
|
7263
|
-
|
|
7264
|
-
function normalizeType(type) {
|
|
7265
|
-
switch (type) {
|
|
7266
|
-
case "HISTORICAL":
|
|
7267
|
-
return "INTENT";
|
|
7268
|
-
default:
|
|
7269
|
-
return type;
|
|
7270
|
-
}
|
|
7271
|
-
}
|
|
7272
|
-
var order = ["FAQ", "INTENT", "HISTORICAL"];
|
|
7273
|
-
var ordersMap = order.reduce(function (prev, cur, index) {
|
|
7274
|
-
prev[cur] = index;
|
|
7275
|
-
return prev;
|
|
7276
|
-
}, {});
|
|
7277
|
-
function compareSuggestionItems(left, right) {
|
|
7278
|
-
return (ordersMap[right.type] - ordersMap[left.type]);
|
|
7680
|
+
function createActions(onItemUse) {
|
|
7681
|
+
return function (innerProps) {
|
|
7682
|
+
var data = innerProps.data;
|
|
7683
|
+
var canUse = data.type !== "FAQ";
|
|
7684
|
+
var handleUse = useCallback(function (ev) {
|
|
7685
|
+
onItemUse(data);
|
|
7686
|
+
ev.stopPropagation();
|
|
7687
|
+
}, [data]);
|
|
7688
|
+
if (!canUse) {
|
|
7689
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
7690
|
+
}
|
|
7691
|
+
return (React$1.createElement(IconButton_1, { className: "xappw-suggestions__use", onClick: handleUse, icon: LeftDownArrowIcon }));
|
|
7692
|
+
};
|
|
7279
7693
|
}
|
|
7280
7694
|
var Suggestions = function (props) {
|
|
7281
|
-
var
|
|
7695
|
+
var data = props.data, onItemUse = props.onItemUse;
|
|
7696
|
+
var len = data.length;
|
|
7282
7697
|
var currentIndex = len > 0 ? props.index : NaN;
|
|
7283
7698
|
var _a = useState(), activeItem = _a[0], setActiveItem = _a[1];
|
|
7284
|
-
var item =
|
|
7699
|
+
var item = useMemo(function () { return findItemByIndex_1(data, currentIndex); }, [data, currentIndex]);
|
|
7285
7700
|
useEffect(function () {
|
|
7286
7701
|
setActiveItem(item);
|
|
7287
7702
|
}, [item]);
|
|
7288
|
-
var
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
if (prevGroup.type === normalizeType(current.type)) {
|
|
7294
|
-
prevGroup.items.push(current);
|
|
7295
|
-
return result;
|
|
7296
|
-
}
|
|
7297
|
-
}
|
|
7298
|
-
result.push({
|
|
7299
|
-
type: normalizeType(current.type),
|
|
7300
|
-
items: [current],
|
|
7301
|
-
startIndex: index
|
|
7302
|
-
});
|
|
7303
|
-
return result;
|
|
7304
|
-
}, []);
|
|
7305
|
-
}, [props.data]);
|
|
7306
|
-
return (React.createElement("div", { className: "xappw-suggestions " + (props.className || "") },
|
|
7307
|
-
(activeItem === null || activeItem === void 0 ? void 0 : activeItem.answer) && React.createElement("div", { className: "xappw-suggestions__answer" }, activeItem.answer),
|
|
7308
|
-
!!groups.length && React.createElement("div", { className: "xappw-suggestions__groups" }, groups.map(function (group, index) { return (React.createElement(SuggestionsGroupItem, { key: index, group: group, currentIndex: currentIndex, onItemClick: props.onItemClick, onItemUse: props.onItemUse, onItemHover: setActiveItem })); }))));
|
|
7703
|
+
var actions = useMemo(function () { return createActions(onItemUse); }, [onItemUse]);
|
|
7704
|
+
return (React$1.createElement("div", { className: "xappw-suggestions ".concat(props.className || "") },
|
|
7705
|
+
(activeItem === null || activeItem === void 0 ? void 0 : activeItem.content) && React$1.createElement("div", { className: "xappw-suggestions__answer" }, activeItem.content),
|
|
7706
|
+
!!data.length &&
|
|
7707
|
+
React$1.createElement(SuggestionsList_1, { suggestions: data, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem })));
|
|
7309
7708
|
};
|
|
7310
7709
|
|
|
7311
7710
|
var ChatFooter = function (props) {
|
|
7312
|
-
var _a, _b, _c
|
|
7711
|
+
var _a, _b, _c;
|
|
7313
7712
|
var onSubmit = props.onSubmit;
|
|
7314
|
-
var
|
|
7315
|
-
var
|
|
7713
|
+
var _d = useState(false), drawer = _d[0], setDrawerState = _d[1]; // false initially
|
|
7714
|
+
var _e = useState(), suggestionSearch = _e[0], setSuggestionSearch = _e[1];
|
|
7316
7715
|
var contexts = useSelector(function (state) { return state.activeContexts; });
|
|
7317
7716
|
var suggestions = useSuggestions(suggestionSearch, contexts);
|
|
7318
7717
|
var menuItemsRaw = (_b = (_a = useWidgetEnv()) === null || _a === void 0 ? void 0 : _a.menu) === null || _b === void 0 ? void 0 : _b.items;
|
|
7319
7718
|
var menuItems = useMemo(function () { return menuItemsRaw ? menuItemsRaw.map(function (item) { return item.label; }) : []; }, [menuItemsRaw]);
|
|
7320
|
-
var
|
|
7719
|
+
var _f = useState({
|
|
7720
|
+
text: "",
|
|
7721
|
+
formats: []
|
|
7722
|
+
}), input = _f[0], setInput = _f[1];
|
|
7321
7723
|
function toggleDrawer() {
|
|
7322
7724
|
var newDrawer = !drawer;
|
|
7323
7725
|
setDrawerState(newDrawer);
|
|
@@ -7329,29 +7731,32 @@ var ChatFooter = function (props) {
|
|
|
7329
7731
|
}
|
|
7330
7732
|
function handleChange(val) {
|
|
7331
7733
|
setInput(val);
|
|
7332
|
-
props.onChange(val);
|
|
7333
|
-
setSuggestionSearch(val);
|
|
7734
|
+
props.onChange(val.text);
|
|
7735
|
+
setSuggestionSearch(val.text);
|
|
7334
7736
|
}
|
|
7335
7737
|
var handleSubmit = useCallback(function (message) {
|
|
7336
7738
|
setSuggestionSearch("");
|
|
7337
|
-
setInput(
|
|
7338
|
-
|
|
7739
|
+
setInput({
|
|
7740
|
+
text: "",
|
|
7741
|
+
formats: []
|
|
7742
|
+
});
|
|
7743
|
+
onSubmit(message.text);
|
|
7339
7744
|
}, [onSubmit]);
|
|
7340
7745
|
var handleItemClick = useCallback(function (data) {
|
|
7341
|
-
handleSubmit(data
|
|
7746
|
+
handleSubmit(data);
|
|
7342
7747
|
}, [handleSubmit]);
|
|
7343
7748
|
var handleItemUse = useCallback(function (data) {
|
|
7344
|
-
setInput(data
|
|
7345
|
-
setSuggestionSearch(data.
|
|
7749
|
+
setInput(data);
|
|
7750
|
+
setSuggestionSearch(data.text);
|
|
7346
7751
|
}, []);
|
|
7347
|
-
return (React.createElement("div", { className: "chat-footer" },
|
|
7752
|
+
return (React$1.createElement("div", { className: "chat-footer" },
|
|
7348
7753
|
menuItems.length ?
|
|
7349
|
-
React.createElement(React.Fragment, null,
|
|
7350
|
-
React.createElement(ChatMenu, { opened: drawer, onItemClick: handleMenuItem, items: menuItems }),
|
|
7351
|
-
React.createElement("div", { className: "chat-footer__menu-icon" },
|
|
7352
|
-
React.createElement(DrawerBars, { onToggle: toggleDrawer }))) : React.createElement(React.Fragment, null),
|
|
7353
|
-
((
|
|
7354
|
-
React.createElement(Input, { addClass: "chat-footer__input " + (props.isChatting ? "visible" : ""), suggestion: suggestions.item, value: input, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
|
|
7754
|
+
React$1.createElement(React$1.Fragment, null,
|
|
7755
|
+
React$1.createElement(ChatMenu, { opened: drawer, onItemClick: handleMenuItem, items: menuItems }),
|
|
7756
|
+
React$1.createElement("div", { className: "chat-footer__menu-icon" },
|
|
7757
|
+
React$1.createElement(DrawerBars, { onToggle: toggleDrawer }))) : React$1.createElement(React$1.Fragment, null),
|
|
7758
|
+
((_c = suggestions.suggestions) === null || _c === void 0 ? void 0 : _c.length) > 0 && React$1.createElement(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, onItemClick: handleItemClick, onItemUse: handleItemUse }),
|
|
7759
|
+
React$1.createElement(Input, { addClass: "chat-footer__input " + (props.isChatting ? "visible" : ""), suggestion: suggestions.item, value: input, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
|
|
7355
7760
|
// onFocus={this.inputOnFocus}
|
|
7356
7761
|
onFileUpload: props.onFileUpload })));
|
|
7357
7762
|
};
|
|
@@ -7387,12 +7792,12 @@ var MiddlewareContextFactory = /** @class */ (function () {
|
|
|
7387
7792
|
var CardContainer = function (props) {
|
|
7388
7793
|
function renderIcon() {
|
|
7389
7794
|
var isString = typeof (props.icon) === "string";
|
|
7390
|
-
return (React.createElement("div", { className: "card-container__icon" }, !isString && props.icon));
|
|
7795
|
+
return (React$1.createElement("div", { className: "card-container__icon" }, !isString && props.icon));
|
|
7391
7796
|
}
|
|
7392
|
-
return (React.createElement("div", { className: "card-container "
|
|
7797
|
+
return (React$1.createElement("div", { className: "card-container ".concat(props.addClass) },
|
|
7393
7798
|
renderIcon(),
|
|
7394
|
-
React.createElement("div", { className: "card-container__content "
|
|
7395
|
-
React.createElement("div", { className: "card-container__title" }, props.title),
|
|
7799
|
+
React$1.createElement("div", { className: "card-container__content ".concat(props.contentAddClass) },
|
|
7800
|
+
React$1.createElement("div", { className: "card-container__title" }, props.title),
|
|
7396
7801
|
props.children)));
|
|
7397
7802
|
};
|
|
7398
7803
|
|
|
@@ -7421,18 +7826,18 @@ var ChatRating = function (props) {
|
|
|
7421
7826
|
return null;
|
|
7422
7827
|
}
|
|
7423
7828
|
if (!props.hasRating) {
|
|
7424
|
-
return (React.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7829
|
+
return (React$1.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7425
7830
|
props.agent.displayName,
|
|
7426
7831
|
" has requested you to rate the chat service.",
|
|
7427
|
-
React.createElement("div", { className: "buttons-container" },
|
|
7428
|
-
React.createElement(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }),
|
|
7429
|
-
React.createElement(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick }))));
|
|
7832
|
+
React$1.createElement("div", { className: "buttons-container" },
|
|
7833
|
+
React$1.createElement(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }),
|
|
7834
|
+
React$1.createElement(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick }))));
|
|
7430
7835
|
}
|
|
7431
7836
|
else {
|
|
7432
|
-
return (React.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7837
|
+
return (React$1.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7433
7838
|
"You have rated the chat service.",
|
|
7434
|
-
React.createElement("div", { className: "buttons-container" },
|
|
7435
|
-
React.createElement(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }))));
|
|
7839
|
+
React$1.createElement("div", { className: "buttons-container" },
|
|
7840
|
+
React$1.createElement(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }))));
|
|
7436
7841
|
}
|
|
7437
7842
|
};
|
|
7438
7843
|
|
|
@@ -7441,12 +7846,12 @@ var ChatRatingContainer = function (props) {
|
|
|
7441
7846
|
var handleRate = useCallback(function (rating) {
|
|
7442
7847
|
dispatch(sendChatRating(rating));
|
|
7443
7848
|
}, [dispatch]);
|
|
7444
|
-
return React.createElement(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate });
|
|
7849
|
+
return React$1.createElement(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate });
|
|
7445
7850
|
};
|
|
7446
7851
|
|
|
7447
7852
|
var MessageSvg = function (_) {
|
|
7448
|
-
return (React.createElement("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12" },
|
|
7449
|
-
React.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" })));
|
|
7853
|
+
return (React$1.createElement("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12" },
|
|
7854
|
+
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" })));
|
|
7450
7855
|
};
|
|
7451
7856
|
|
|
7452
7857
|
var MessageForm = function (props) {
|
|
@@ -7482,30 +7887,30 @@ var MessageForm = function (props) {
|
|
|
7482
7887
|
setSent(false);
|
|
7483
7888
|
}
|
|
7484
7889
|
function renderSent() {
|
|
7485
|
-
return (React.createElement("div", { key: "sent", className: "message-form--sent" },
|
|
7890
|
+
return (React$1.createElement("div", { key: "sent", className: "message-form--sent" },
|
|
7486
7891
|
"Your message has been sent. We will get back to you as soon as possible.",
|
|
7487
|
-
React.createElement(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })));
|
|
7892
|
+
React$1.createElement(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })));
|
|
7488
7893
|
}
|
|
7489
7894
|
function renderForm() {
|
|
7490
|
-
return (React.createElement("form", { ref: form, key: "not-sent", className: "message-form", onSubmit: send },
|
|
7491
|
-
React.createElement("div", { className: "content" },
|
|
7492
|
-
React.createElement("div", { className: "section" },
|
|
7493
|
-
React.createElement("label", { className: "label" }, "Name"),
|
|
7494
|
-
React.createElement("input", { ref: name, maxLength: 255 })),
|
|
7495
|
-
React.createElement("div", { className: "section" },
|
|
7496
|
-
React.createElement("label", { className: "label" }, "Email"),
|
|
7497
|
-
React.createElement("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })),
|
|
7498
|
-
React.createElement("div", { className: "section" },
|
|
7499
|
-
React.createElement("label", { className: "label" }, "Message"),
|
|
7500
|
-
React.createElement("textarea", { required: true, ref: message }))),
|
|
7501
|
-
React.createElement("div", { className: "button-container" },
|
|
7502
|
-
React.createElement(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }))));
|
|
7503
|
-
}
|
|
7504
|
-
return (React.createElement(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: React.createElement(MessageSvg, null) }, sent ? renderSent() : renderForm()));
|
|
7895
|
+
return (React$1.createElement("form", { ref: form, key: "not-sent", className: "message-form", onSubmit: send },
|
|
7896
|
+
React$1.createElement("div", { className: "content" },
|
|
7897
|
+
React$1.createElement("div", { className: "section" },
|
|
7898
|
+
React$1.createElement("label", { className: "label" }, "Name"),
|
|
7899
|
+
React$1.createElement("input", { ref: name, maxLength: 255 })),
|
|
7900
|
+
React$1.createElement("div", { className: "section" },
|
|
7901
|
+
React$1.createElement("label", { className: "label" }, "Email"),
|
|
7902
|
+
React$1.createElement("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })),
|
|
7903
|
+
React$1.createElement("div", { className: "section" },
|
|
7904
|
+
React$1.createElement("label", { className: "label" }, "Message"),
|
|
7905
|
+
React$1.createElement("textarea", { required: true, ref: message }))),
|
|
7906
|
+
React$1.createElement("div", { className: "button-container" },
|
|
7907
|
+
React$1.createElement(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }))));
|
|
7908
|
+
}
|
|
7909
|
+
return (React$1.createElement(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: React$1.createElement(MessageSvg, null) }, sent ? renderSent() : renderForm()));
|
|
7505
7910
|
};
|
|
7506
7911
|
|
|
7507
7912
|
var OfflineForm = function (props) {
|
|
7508
|
-
return React.createElement(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
|
|
7913
|
+
return React$1.createElement(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
|
|
7509
7914
|
};
|
|
7510
7915
|
|
|
7511
7916
|
var OfflineFormContainer = function (_) {
|
|
@@ -7513,7 +7918,7 @@ var OfflineFormContainer = function (_) {
|
|
|
7513
7918
|
var handleSubmit = useCallback(function (data) {
|
|
7514
7919
|
dispatch(sendOfflineMsg(data));
|
|
7515
7920
|
}, [dispatch]);
|
|
7516
|
-
return React.createElement(OfflineForm, { onSubmit: handleSubmit });
|
|
7921
|
+
return React$1.createElement(OfflineForm, { onSubmit: handleSubmit });
|
|
7517
7922
|
};
|
|
7518
7923
|
|
|
7519
7924
|
var PrechatForm = function (props) {
|
|
@@ -7523,7 +7928,7 @@ var PrechatForm = function (props) {
|
|
|
7523
7928
|
onSubmit(msg);
|
|
7524
7929
|
setSent(true);
|
|
7525
7930
|
}, [onSubmit]);
|
|
7526
|
-
return (React.createElement(React.Fragment, null, !sent && React.createElement(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit })));
|
|
7931
|
+
return (React$1.createElement(React$1.Fragment, null, !sent && React$1.createElement(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit })));
|
|
7527
7932
|
};
|
|
7528
7933
|
|
|
7529
7934
|
var PrechatFormContainer = function (_) {
|
|
@@ -7538,7 +7943,7 @@ var PrechatFormContainer = function (_) {
|
|
|
7538
7943
|
}));
|
|
7539
7944
|
dispatch(executeAction(data.message));
|
|
7540
7945
|
}, [dispatch]);
|
|
7541
|
-
return React.createElement(PrechatForm, { onSubmit: handleSubmit });
|
|
7946
|
+
return React$1.createElement(PrechatForm, { onSubmit: handleSubmit });
|
|
7542
7947
|
};
|
|
7543
7948
|
|
|
7544
7949
|
var defaultProps$1 = {
|
|
@@ -7548,8 +7953,8 @@ var QueuePosition = function (props) {
|
|
|
7548
7953
|
if (props === void 0) { props = defaultProps$1; }
|
|
7549
7954
|
if (props.position <= 0)
|
|
7550
7955
|
return null;
|
|
7551
|
-
return (React.createElement("div", { className: "system-msg-container" },
|
|
7552
|
-
React.createElement("span", { className: "system-msg" },
|
|
7956
|
+
return (React$1.createElement("div", { className: "system-msg-container" },
|
|
7957
|
+
React$1.createElement("span", { className: "system-msg" },
|
|
7553
7958
|
"Queue position: ",
|
|
7554
7959
|
props.position)));
|
|
7555
7960
|
};
|
|
@@ -7557,34 +7962,34 @@ var QueuePosition = function (props) {
|
|
|
7557
7962
|
function getMessageByType(msg) {
|
|
7558
7963
|
switch (msg.type) {
|
|
7559
7964
|
case "chat.memberjoin":
|
|
7560
|
-
return msg.user.displayName
|
|
7965
|
+
return "".concat(msg.user.displayName, " has joined the chat");
|
|
7561
7966
|
case "chat.memberleave":
|
|
7562
|
-
return msg.user.displayName
|
|
7967
|
+
return "".concat(msg.user.displayName, " has left the chat");
|
|
7563
7968
|
case "chat.rating":
|
|
7564
7969
|
if (!msg.newRating) {
|
|
7565
7970
|
return "You have removed the chat rating";
|
|
7566
7971
|
}
|
|
7567
7972
|
else {
|
|
7568
7973
|
var rating = convertToSentenceCase(msg.newRating);
|
|
7569
|
-
return "You have rated the chat service "
|
|
7974
|
+
return "You have rated the chat service ".concat(rating);
|
|
7570
7975
|
}
|
|
7571
7976
|
default:
|
|
7572
7977
|
return JSON.stringify(msg);
|
|
7573
7978
|
}
|
|
7574
7979
|
}
|
|
7575
7980
|
var SystemMessage = function (props) {
|
|
7576
|
-
return (React.createElement("div", { className: "system-msg-container" },
|
|
7577
|
-
React.createElement("span", { className: "system-msg" }, getMessageByType(props.message))));
|
|
7981
|
+
return (React$1.createElement("div", { className: "system-msg-container" },
|
|
7982
|
+
React$1.createElement("span", { className: "system-msg" }, getMessageByType(props.message))));
|
|
7578
7983
|
};
|
|
7579
7984
|
function convertToSentenceCase(s) {
|
|
7580
7985
|
return s[0].toUpperCase() + s.slice(1);
|
|
7581
7986
|
}
|
|
7582
7987
|
|
|
7583
7988
|
var TypingIndicator = function (_) {
|
|
7584
|
-
return (React.createElement("div", { className: "typing-indicator" },
|
|
7585
|
-
React.createElement("div", { className: "typing-indicator-part" }),
|
|
7586
|
-
React.createElement("div", { className: "typing-indicator-part" }),
|
|
7587
|
-
React.createElement("div", { className: "typing-indicator-part" })));
|
|
7989
|
+
return (React$1.createElement("div", { className: "typing-indicator" },
|
|
7990
|
+
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
7991
|
+
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
7992
|
+
React$1.createElement("div", { className: "typing-indicator-part" })));
|
|
7588
7993
|
};
|
|
7589
7994
|
|
|
7590
7995
|
/**
|
|
@@ -7593,13 +7998,13 @@ var TypingIndicator = function (_) {
|
|
|
7593
7998
|
var TypingStatus = function (props) {
|
|
7594
7999
|
var agent_names = Object.values(props.agents)
|
|
7595
8000
|
.filter(function (agent) { return agent.typing; });
|
|
7596
|
-
return (React.createElement(React.Fragment, null, agent_names.map(function (agent) {
|
|
7597
|
-
return (React.createElement("div", { className: "chat-msg-container-wrapper", key: "typing-status-"
|
|
7598
|
-
React.createElement("div", { key: agent.user.nick, className: "chat-msg-container agent chat-typing-progress" },
|
|
7599
|
-
React.createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
|
|
7600
|
-
React.createElement("div", { className: "chat-msg" },
|
|
7601
|
-
React.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
7602
|
-
React.createElement(TypingIndicator, null)))))));
|
|
8001
|
+
return (React$1.createElement(React$1.Fragment, null, agent_names.map(function (agent) {
|
|
8002
|
+
return (React$1.createElement("div", { className: "chat-msg-container-wrapper", key: "typing-status-".concat(agent.user.nick) },
|
|
8003
|
+
React$1.createElement("div", { key: agent.user.nick, className: "chat-msg-container agent chat-typing-progress" },
|
|
8004
|
+
React$1.createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
|
|
8005
|
+
React$1.createElement("div", { className: "chat-msg" },
|
|
8006
|
+
React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
8007
|
+
React$1.createElement(TypingIndicator, null)))))));
|
|
7603
8008
|
})));
|
|
7604
8009
|
};
|
|
7605
8010
|
|
|
@@ -7649,20 +8054,20 @@ var MessageList = function (props) {
|
|
|
7649
8054
|
switch (msg.type) {
|
|
7650
8055
|
case "chat.file":
|
|
7651
8056
|
case "chat.msg":
|
|
7652
|
-
return (React.createElement(ChatMessage, { key: msg.type + msg.timestamp, message: msg, sibling: sibling, agent: user, messageMiddleware: props.messageMiddleware, middlewareContext: ctxCache.resolve(user) }));
|
|
8057
|
+
return (React$1.createElement(ChatMessage, { key: msg.type + msg.timestamp, message: msg, sibling: sibling, agent: user, messageMiddleware: props.messageMiddleware, middlewareContext: ctxCache.resolve(user) }));
|
|
7653
8058
|
case "chat.memberjoin":
|
|
7654
8059
|
case "chat.memberleave":
|
|
7655
8060
|
case "chat.rating":
|
|
7656
8061
|
case "chat.typing":
|
|
7657
|
-
return (React.createElement(SystemMessage, { key: msg.type + msg.timestamp, message: msg }));
|
|
8062
|
+
return (React$1.createElement(SystemMessage, { key: msg.type + msg.timestamp, message: msg }));
|
|
7658
8063
|
case "chat.request.rating":
|
|
7659
|
-
return (React.createElement(ChatRatingContainer, { key: msg.type + msg.timestamp, agent: user, hasRating: props.hasRating, shouldDisplay: msg.timestamp === props.lastRatingRequestTimestamp }));
|
|
8064
|
+
return (React$1.createElement(ChatRatingContainer, { key: msg.type + msg.timestamp, agent: user, hasRating: props.hasRating, shouldDisplay: msg.timestamp === props.lastRatingRequestTimestamp }));
|
|
7660
8065
|
case "chat.offline":
|
|
7661
|
-
return React.createElement(OfflineFormContainer, { key: "offline-"
|
|
8066
|
+
return React$1.createElement(OfflineFormContainer, { key: "offline-".concat(msg.timestamp) });
|
|
7662
8067
|
case "chat.prechat":
|
|
7663
|
-
return React.createElement(PrechatFormContainer, { key: "prechat" });
|
|
8068
|
+
return React$1.createElement(PrechatFormContainer, { key: "prechat" });
|
|
7664
8069
|
default:
|
|
7665
|
-
return React.createElement("div", { key: +new Date() },
|
|
8070
|
+
return React$1.createElement("div", { key: +new Date() },
|
|
7666
8071
|
"Unhandled message: ",
|
|
7667
8072
|
JSON.stringify(msg));
|
|
7668
8073
|
}
|
|
@@ -7685,23 +8090,23 @@ var MessageList = function (props) {
|
|
|
7685
8090
|
});
|
|
7686
8091
|
}
|
|
7687
8092
|
var agents = props.agents, queuePosition = props.queuePosition;
|
|
7688
|
-
return (React.createElement("div", { className: "message-list-container" },
|
|
7689
|
-
React.createElement("div", { className: "message-list-container__msgs" },
|
|
8093
|
+
return (React$1.createElement("div", { className: "message-list-container" },
|
|
8094
|
+
React$1.createElement("div", { className: "message-list-container__msgs" },
|
|
7690
8095
|
renderAll(),
|
|
7691
|
-
React.createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
|
|
7692
|
-
React.createElement(QueuePosition, { position: queuePosition }),
|
|
7693
|
-
React.createElement(TypingStatus, { agents: agents })),
|
|
7694
|
-
React.createElement(ChatChipsContainer, null)));
|
|
8096
|
+
React$1.createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
|
|
8097
|
+
React$1.createElement(QueuePosition, { position: queuePosition }),
|
|
8098
|
+
React$1.createElement(TypingStatus, { agents: agents })),
|
|
8099
|
+
React$1.createElement(ChatChipsContainer, null)));
|
|
7695
8100
|
};
|
|
7696
8101
|
|
|
7697
8102
|
var ServerOffline = function () {
|
|
7698
|
-
return React.createElement("div", { className: "server-offline" },
|
|
7699
|
-
React.createElement("h2", null, "Chat is currently unavailable"),
|
|
7700
|
-
React.createElement("h3", null, "Server is offline"));
|
|
8103
|
+
return React$1.createElement("div", { className: "server-offline" },
|
|
8104
|
+
React$1.createElement("h2", null, "Chat is currently unavailable"),
|
|
8105
|
+
React$1.createElement("h3", null, "Server is offline"));
|
|
7701
8106
|
};
|
|
7702
8107
|
|
|
7703
8108
|
var MinimizeButton = function (props) {
|
|
7704
|
-
return React.createElement("div", { className: "minimize-button", onClick: props.onClick });
|
|
8109
|
+
return React$1.createElement("div", { className: "minimize-button", onClick: props.onClick });
|
|
7705
8110
|
};
|
|
7706
8111
|
|
|
7707
8112
|
var DEFAULT_STATUS_CONFIG = {
|
|
@@ -7721,23 +8126,23 @@ function getStatusText(status, config) {
|
|
|
7721
8126
|
}
|
|
7722
8127
|
var StatusContainer = function (props) {
|
|
7723
8128
|
var _a;
|
|
7724
|
-
return (React.createElement("div", { className: "status-container" },
|
|
7725
|
-
React.createElement("div", { className: "status-container__avatar" },
|
|
7726
|
-
React.createElement(Avatar, { entity: props.agent })),
|
|
7727
|
-
React.createElement("div", { className: "status-text" },
|
|
7728
|
-
React.createElement("span", null, getStatusText(props.accountStatus, (_a = props.config) === null || _a === void 0 ? void 0 : _a.status))),
|
|
8129
|
+
return (React$1.createElement("div", { className: "status-container" },
|
|
8130
|
+
React$1.createElement("div", { className: "status-container__avatar" },
|
|
8131
|
+
React$1.createElement(Avatar, { entity: props.agent })),
|
|
8132
|
+
React$1.createElement("div", { className: "status-text" },
|
|
8133
|
+
React$1.createElement("span", null, getStatusText(props.accountStatus, (_a = props.config) === null || _a === void 0 ? void 0 : _a.status))),
|
|
7729
8134
|
props.canMinimize &&
|
|
7730
|
-
React.createElement(MinimizeButton, { onClick: props.minimizeOnClick })));
|
|
8135
|
+
React$1.createElement(MinimizeButton, { onClick: props.minimizeOnClick })));
|
|
7731
8136
|
};
|
|
7732
8137
|
|
|
7733
8138
|
function buildStyleContent(theme) {
|
|
7734
8139
|
var _a, _b, _c, _d;
|
|
7735
|
-
return "\n:root {\n"
|
|
8140
|
+
return "\n:root {\n".concat(buildVariables(withPrefix("\t--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))), 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("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("minimize-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.minimizeButton)), withPrefix("carousel-", union(withPrefix("title-", getTextStyle((_b = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _b === void 0 ? void 0 : _b.title)), withPrefix("subtitle-", getTextStyle((_c = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _c === void 0 ? void 0 : _c.subtitle)), withPrefix("action-", getButtonStyle((_d = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _d === void 0 ? void 0 : _d.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))))), "\n}");
|
|
7736
8141
|
}
|
|
7737
8142
|
function WidgetStylesheet(props) {
|
|
7738
8143
|
var theme = props.theme;
|
|
7739
8144
|
var stylesContent = buildStyleContent(theme);
|
|
7740
|
-
return (React.createElement("style", null, stylesContent));
|
|
8145
|
+
return (React$1.createElement("style", null, stylesContent));
|
|
7741
8146
|
}
|
|
7742
8147
|
function buildVariables(gen) {
|
|
7743
8148
|
var result = gen.next();
|
|
@@ -7745,7 +8150,7 @@ function buildVariables(gen) {
|
|
|
7745
8150
|
while (result.done === false) {
|
|
7746
8151
|
var _a = result.value, key = _a[0], value = _a[1];
|
|
7747
8152
|
if (value !== undefined && value !== null && value !== "") {
|
|
7748
|
-
res += key
|
|
8153
|
+
res += "".concat(key, ": ").concat(value, ";\n\r");
|
|
7749
8154
|
}
|
|
7750
8155
|
result = gen.next();
|
|
7751
8156
|
}
|
|
@@ -7753,14 +8158,14 @@ function buildVariables(gen) {
|
|
|
7753
8158
|
}
|
|
7754
8159
|
function withPrefix(prefix, gen) {
|
|
7755
8160
|
var result;
|
|
7756
|
-
return __generator(this, function (_a) {
|
|
8161
|
+
return __generator$1(this, function (_a) {
|
|
7757
8162
|
switch (_a.label) {
|
|
7758
8163
|
case 0:
|
|
7759
8164
|
result = gen.next();
|
|
7760
8165
|
_a.label = 1;
|
|
7761
8166
|
case 1:
|
|
7762
8167
|
if (!!result.done) return [3 /*break*/, 3];
|
|
7763
|
-
return [4 /*yield*/, [""
|
|
8168
|
+
return [4 /*yield*/, ["".concat(prefix).concat(result.value[0]), result.value[1]]];
|
|
7764
8169
|
case 2:
|
|
7765
8170
|
_a.sent();
|
|
7766
8171
|
result = gen.next();
|
|
@@ -7775,7 +8180,7 @@ function union() {
|
|
|
7775
8180
|
for (_i = 0; _i < arguments.length; _i++) {
|
|
7776
8181
|
children[_i] = arguments[_i];
|
|
7777
8182
|
}
|
|
7778
|
-
return __generator(this, function (_b) {
|
|
8183
|
+
return __generator$1(this, function (_b) {
|
|
7779
8184
|
switch (_b.label) {
|
|
7780
8185
|
case 0:
|
|
7781
8186
|
_a = 0, children_1 = children;
|
|
@@ -7800,7 +8205,7 @@ function union() {
|
|
|
7800
8205
|
});
|
|
7801
8206
|
}
|
|
7802
8207
|
function single(key, value) {
|
|
7803
|
-
return __generator(this, function (_a) {
|
|
8208
|
+
return __generator$1(this, function (_a) {
|
|
7804
8209
|
switch (_a.label) {
|
|
7805
8210
|
case 0: return [4 /*yield*/, [key, value]];
|
|
7806
8211
|
case 1:
|
|
@@ -7810,7 +8215,7 @@ function single(key, value) {
|
|
|
7810
8215
|
});
|
|
7811
8216
|
}
|
|
7812
8217
|
function empty() {
|
|
7813
|
-
return __generator(this, function (_a) {
|
|
8218
|
+
return __generator$1(this, function (_a) {
|
|
7814
8219
|
return [2 /*return*/];
|
|
7815
8220
|
});
|
|
7816
8221
|
}
|
|
@@ -7830,7 +8235,7 @@ function getMessageStyle(style) {
|
|
|
7830
8235
|
return union(single('bubble-color', style === null || style === void 0 ? void 0 : style.bubbleColor), getTextStyle(style === null || style === void 0 ? void 0 : style.text));
|
|
7831
8236
|
}
|
|
7832
8237
|
function getSize(style) {
|
|
7833
|
-
return __generator(this, function (_a) {
|
|
8238
|
+
return __generator$1(this, function (_a) {
|
|
7834
8239
|
switch (_a.label) {
|
|
7835
8240
|
case 0: return [4 /*yield*/, ['width', style === null || style === void 0 ? void 0 : style.width]];
|
|
7836
8241
|
case 1:
|
|
@@ -7843,7 +8248,7 @@ function getSize(style) {
|
|
|
7843
8248
|
});
|
|
7844
8249
|
}
|
|
7845
8250
|
function getMargins(style) {
|
|
7846
|
-
return __generator(this, function (_a) {
|
|
8251
|
+
return __generator$1(this, function (_a) {
|
|
7847
8252
|
switch (_a.label) {
|
|
7848
8253
|
case 0:
|
|
7849
8254
|
if (!style) return [3 /*break*/, 5];
|
|
@@ -7865,7 +8270,7 @@ function getMargins(style) {
|
|
|
7865
8270
|
});
|
|
7866
8271
|
}
|
|
7867
8272
|
function getPaddings(style) {
|
|
7868
|
-
return __generator(this, function (_a) {
|
|
8273
|
+
return __generator$1(this, function (_a) {
|
|
7869
8274
|
switch (_a.label) {
|
|
7870
8275
|
case 0:
|
|
7871
8276
|
if (!style) return [3 /*break*/, 5];
|
|
@@ -7887,7 +8292,7 @@ function getPaddings(style) {
|
|
|
7887
8292
|
});
|
|
7888
8293
|
}
|
|
7889
8294
|
function getTextStyle(style) {
|
|
7890
|
-
return __generator(this, function (_a) {
|
|
8295
|
+
return __generator$1(this, function (_a) {
|
|
7891
8296
|
switch (_a.label) {
|
|
7892
8297
|
case 0:
|
|
7893
8298
|
if (!style) return [3 /*break*/, 6];
|
|
@@ -7912,7 +8317,7 @@ function getTextStyle(style) {
|
|
|
7912
8317
|
});
|
|
7913
8318
|
}
|
|
7914
8319
|
function getBackgroundStyle(style) {
|
|
7915
|
-
return __generator(this, function (_a) {
|
|
8320
|
+
return __generator$1(this, function (_a) {
|
|
7916
8321
|
switch (_a.label) {
|
|
7917
8322
|
case 0: return [4 /*yield*/, ["background", style]];
|
|
7918
8323
|
case 1:
|
|
@@ -7922,7 +8327,7 @@ function getBackgroundStyle(style) {
|
|
|
7922
8327
|
});
|
|
7923
8328
|
}
|
|
7924
8329
|
function getButtonStyle(style) {
|
|
7925
|
-
return __generator(this, function (_a) {
|
|
8330
|
+
return __generator$1(this, function (_a) {
|
|
7926
8331
|
switch (_a.label) {
|
|
7927
8332
|
case 0: return [4 /*yield*/, ['button-color', style === null || style === void 0 ? void 0 : style.color]];
|
|
7928
8333
|
case 1:
|
|
@@ -7938,7 +8343,7 @@ function getMenuStyle(style) {
|
|
|
7938
8343
|
return union(withPrefix("item-", getMenuItemStyle(style === null || style === void 0 ? void 0 : style.item)));
|
|
7939
8344
|
}
|
|
7940
8345
|
function getBorderStyle(style) {
|
|
7941
|
-
return __generator(this, function (_a) {
|
|
8346
|
+
return __generator$1(this, function (_a) {
|
|
7942
8347
|
switch (_a.label) {
|
|
7943
8348
|
case 0:
|
|
7944
8349
|
if (!style) return [3 /*break*/, 4];
|
|
@@ -7989,9 +8394,9 @@ var ChatWidgetWrapper = function (props) {
|
|
|
7989
8394
|
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 }));
|
|
7990
8395
|
}, [connection, rawConfig]);
|
|
7991
8396
|
var chatServer = useChatServer(connection);
|
|
7992
|
-
return (React.createElement(ChatConfigContext.Provider, { value: config },
|
|
7993
|
-
React.createElement(ChatServerContext.Provider, { value: chatServer },
|
|
7994
|
-
React.createElement(ChatWidget, __assign({}, props)))));
|
|
8397
|
+
return (React$1.createElement(ChatConfigContext.Provider, { value: config },
|
|
8398
|
+
React$1.createElement(ChatServerContext.Provider, { value: chatServer },
|
|
8399
|
+
React$1.createElement(ChatWidget, __assign({}, props)))));
|
|
7995
8400
|
};
|
|
7996
8401
|
var ChatWidget = function (props) {
|
|
7997
8402
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -8002,10 +8407,10 @@ var ChatWidget = function (props) {
|
|
|
8002
8407
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
8003
8408
|
var dockedMode = mode === "docked";
|
|
8004
8409
|
var staticMode = mode === "static";
|
|
8005
|
-
var modeClass = "widget-container--"
|
|
8410
|
+
var modeClass = "widget-container--".concat(mode);
|
|
8006
8411
|
var canMinimize = !dockedMode && !staticMode;
|
|
8007
8412
|
// Our state - pull from storage
|
|
8008
|
-
var _g = useState(!canMinimize || !!get("visible)") || (((_b = props.config) === null || _b === void 0 ? void 0 : _b.autoOpenOnWidth) && window.matchMedia("(min-width: "
|
|
8413
|
+
var _g = useState(!canMinimize || !!get("visible)") || (((_b = props.config) === null || _b === void 0 ? void 0 : _b.autoOpenOnWidth) && window.matchMedia("(min-width: ".concat((_c = props.config) === null || _c === void 0 ? void 0 : _c.autoOpenOnWidth, ")")).matches)), visible = _g[0], setVisibleState = _g[1];
|
|
8009
8414
|
var _h = useState(false), typing = _h[0], setTypingState = _h[1]; // false initially
|
|
8010
8415
|
var chatServer = useContext(ChatServerContext);
|
|
8011
8416
|
function setVisible(newVisible) {
|
|
@@ -8107,16 +8512,16 @@ var ChatWidget = function (props) {
|
|
|
8107
8512
|
}
|
|
8108
8513
|
}, [connectionStatus, onConnectionStatusChange]);
|
|
8109
8514
|
useExternalScript((_d = props.config) === null || _d === void 0 ? void 0 : _d.middlewareUrl);
|
|
8110
|
-
return (React.createElement(React.Fragment, null,
|
|
8111
|
-
React.createElement("div", { className: "widget-container "
|
|
8112
|
-
React.createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
8113
|
-
React.createElement(StatusContainer, { accountStatus: chatState.accountStatus, minimizeOnClick: minimizeOnClick, agent: (_e = chatState.agents["agent:robot"]) === null || _e === void 0 ? void 0 : _e.user, canMinimize: canMinimize, config: config === null || config === void 0 ? void 0 : config.header }),
|
|
8114
|
-
React.createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
8115
|
-
React.createElement("div", { className: "spinner-container "
|
|
8116
|
-
React.createElement("div", { className: "spinner" })),
|
|
8117
|
-
connectionStatus === "offline" && React.createElement(ServerOffline, null),
|
|
8118
|
-
React.createElement(ChatFooter, { isChatting: chatState.isChatting, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
|
|
8119
|
-
React.createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_f = props.config) === null || _f === void 0 ? void 0 : _f.cta, visible: visible })));
|
|
8515
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
8516
|
+
React$1.createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
8517
|
+
React$1.createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
8518
|
+
React$1.createElement(StatusContainer, { accountStatus: chatState.accountStatus, minimizeOnClick: minimizeOnClick, agent: (_e = chatState.agents["agent:robot"]) === null || _e === void 0 ? void 0 : _e.user, canMinimize: canMinimize, config: config === null || config === void 0 ? void 0 : config.header }),
|
|
8519
|
+
React$1.createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
8520
|
+
React$1.createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
8521
|
+
React$1.createElement("div", { className: "spinner" })),
|
|
8522
|
+
connectionStatus === "offline" && React$1.createElement(ServerOffline, null),
|
|
8523
|
+
React$1.createElement(ChatFooter, { isChatting: chatState.isChatting, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
|
|
8524
|
+
React$1.createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_f = props.config) === null || _f === void 0 ? void 0 : _f.cta, visible: visible })));
|
|
8120
8525
|
};
|
|
8121
8526
|
|
|
8122
8527
|
function tryParseJson(str) {
|
|
@@ -8155,7 +8560,7 @@ var BrowserStateStorage = /** @class */ (function () {
|
|
|
8155
8560
|
* @returns {string}
|
|
8156
8561
|
*/
|
|
8157
8562
|
function visitorFingerprint() {
|
|
8158
|
-
return
|
|
8563
|
+
return uuid_1();
|
|
8159
8564
|
}
|
|
8160
8565
|
|
|
8161
8566
|
var DEFAULT_VISITOR = {
|
|
@@ -8211,7 +8616,7 @@ function connectionReducer(state, action) {
|
|
|
8211
8616
|
}
|
|
8212
8617
|
|
|
8213
8618
|
function joinMessages(messages, msg) {
|
|
8214
|
-
return insertSorted(__spreadArray([], messages, true), msg, function (left, right) { return left.timestamp - right.timestamp; });
|
|
8619
|
+
return insertSorted(__spreadArray$1([], messages, true), msg, function (left, right) { return left.timestamp - right.timestamp; });
|
|
8215
8620
|
}
|
|
8216
8621
|
|
|
8217
8622
|
function memberJoin(state, detail) {
|
|
@@ -8242,7 +8647,7 @@ function memberLeave(state, detail) {
|
|
|
8242
8647
|
|
|
8243
8648
|
function resetReducer(state) {
|
|
8244
8649
|
if (state === void 0) { state = DEFAULT_STATE; }
|
|
8245
|
-
return __assign(__assign({}, createDefaultState()), { connection: __assign(__assign({}, state.connection), { nonce:
|
|
8650
|
+
return __assign(__assign({}, createDefaultState()), { connection: __assign(__assign({}, state.connection), { nonce: uuid_1() }), visitor: state.visitor, visitorId: state.visitorId });
|
|
8246
8651
|
}
|
|
8247
8652
|
|
|
8248
8653
|
// todo: create reducer (requires redux-thunk dependncy)
|
|
@@ -8341,7 +8746,7 @@ function mapSynthetic(state, action) {
|
|
|
8341
8746
|
}
|
|
8342
8747
|
};
|
|
8343
8748
|
default:
|
|
8344
|
-
throw new Error("Unknown synthetic action. Detail type: "
|
|
8749
|
+
throw new Error("Unknown synthetic action. Detail type: ".concat(action.detail.type));
|
|
8345
8750
|
}
|
|
8346
8751
|
}
|
|
8347
8752
|
function storeHandler(state, action) {
|
|
@@ -8356,13 +8761,14 @@ function storeHandler(state, action) {
|
|
|
8356
8761
|
}
|
|
8357
8762
|
}
|
|
8358
8763
|
|
|
8359
|
-
function createChatStore(config) {
|
|
8360
|
-
|
|
8764
|
+
function createChatStore(config, dataStorage) {
|
|
8765
|
+
if (dataStorage === void 0) { dataStorage = sessionStorage; }
|
|
8766
|
+
var storage = new BrowserStateStorage(dataStorage, "xappchat.".concat(config.serverUrl, ".").concat(config.accountKey));
|
|
8361
8767
|
var chatReducer = persistStateReducer(storage, DEFAULT_STATE, storeHandler);
|
|
8362
8768
|
var middlewares = [
|
|
8363
8769
|
thunk
|
|
8364
8770
|
];
|
|
8365
|
-
var composeEnhancers =
|
|
8771
|
+
var composeEnhancers = globalThis.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
8366
8772
|
return createStore$1(chatReducer, composeEnhancers(applyMiddleware.apply(void 0, middlewares)));
|
|
8367
8773
|
}
|
|
8368
8774
|
|
|
@@ -8372,11 +8778,11 @@ var ChatWidgetContainer = function (props) {
|
|
|
8372
8778
|
var connection = useServerConfig(props.config);
|
|
8373
8779
|
var chatStore = useMemo(function () { return createChatStore(connection); }, [connection]);
|
|
8374
8780
|
if ((_a = props.config) === null || _a === void 0 ? void 0 : _a.disabled) {
|
|
8375
|
-
return React.createElement(React.Fragment, null);
|
|
8781
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
8376
8782
|
}
|
|
8377
8783
|
var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware });
|
|
8378
|
-
return (React.createElement(Provider, { store: chatStore },
|
|
8379
|
-
React.createElement(ChatWidgetWrapper, __assign({}, widgetProps))));
|
|
8784
|
+
return (React$1.createElement(Provider, { store: chatStore },
|
|
8785
|
+
React$1.createElement(ChatWidgetWrapper, __assign({}, widgetProps))));
|
|
8380
8786
|
};
|
|
8381
8787
|
|
|
8382
8788
|
function createStaticReducer(state) {
|
|
@@ -8406,13 +8812,13 @@ var StaticChatWidgetContainer = function (props) {
|
|
|
8406
8812
|
type: "local"
|
|
8407
8813
|
} });
|
|
8408
8814
|
}, [props.config]);
|
|
8409
|
-
return (React.createElement(Provider, { store: store },
|
|
8410
|
-
React.createElement(ChatWidgetWrapper, __assign({}, props, { config: config }))));
|
|
8815
|
+
return (React$1.createElement(Provider, { store: store },
|
|
8816
|
+
React$1.createElement(ChatWidgetWrapper, __assign({}, props, { config: config }))));
|
|
8411
8817
|
};
|
|
8412
8818
|
|
|
8413
8819
|
function createStateFromMessages(messages) {
|
|
8414
8820
|
var def = createDefaultState();
|
|
8415
|
-
return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray([], messages, true), isChatting: true });
|
|
8821
|
+
return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), isChatting: true });
|
|
8416
8822
|
}
|
|
8417
8823
|
|
|
8418
8824
|
var StaticMessagesChatWidgetContainer = function (props) {
|
|
@@ -8420,7 +8826,7 @@ var StaticMessagesChatWidgetContainer = function (props) {
|
|
|
8420
8826
|
var state = useMemo(function () {
|
|
8421
8827
|
return createStateFromMessages(messages);
|
|
8422
8828
|
}, [messages]);
|
|
8423
|
-
return (React.createElement(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config }));
|
|
8829
|
+
return (React$1.createElement(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config }));
|
|
8424
8830
|
};
|
|
8425
8831
|
|
|
8426
8832
|
export { ActionButton, Avatar, CardMiddleware, Carousel, CarouselItem, ChatWidgetContainer as Chat, ChatButton, ChatCard, ChatChip, ChatChips, ChatMenu, ChatMessage, ChatMessageBubble, ChatMessagePart, ChatWidgetWrapper as ChatWidget, CtaBubble, CtaBubbleContainer, List, ListItem, ListMiddleware, MessageList, MiddlewareContextFactory, StaticChatWidgetContainer, StaticMessagesChatWidgetContainer, joinMiddlewares, responseToMessage, useLateMiddleware, useStandardMiddleware };
|