@elqnt/chat 1.0.21 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/use-websocket-chat-admin.d.mts +0 -2
- package/dist/hooks/use-websocket-chat-admin.d.ts +0 -2
- package/dist/hooks/use-websocket-chat-admin.js.map +1 -1
- package/dist/hooks/use-websocket-chat-admin.mjs.map +1 -1
- package/dist/hooks/use-websocket-chat-base.d.mts +0 -2
- package/dist/hooks/use-websocket-chat-base.d.ts +0 -2
- package/dist/hooks/use-websocket-chat-customer.d.mts +0 -2
- package/dist/hooks/use-websocket-chat-customer.d.ts +0 -2
- package/dist/index.d.mts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +134 -355
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -268
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.mts +1 -3
- package/dist/models/index.d.ts +1 -3
- package/dist/models/index.js.map +1 -1
- package/dist/models/index.mjs.map +1 -1
- package/package.json +2 -6
package/dist/index.mjs
CHANGED
|
@@ -1,207 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// components/admin/admin-chat-input.tsx
|
|
4
|
-
import { useUserContext } from "@elqnt/auth";
|
|
5
4
|
import KSUID from "ksuid";
|
|
6
|
-
|
|
7
|
-
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
8
|
-
import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
|
|
9
|
-
|
|
10
|
-
// ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
|
|
11
|
-
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
12
|
-
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
13
|
-
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
14
|
-
}).join(" ").trim();
|
|
15
|
-
|
|
16
|
-
// ../../node_modules/lucide-react/dist/esm/Icon.js
|
|
17
|
-
import { forwardRef, createElement } from "react";
|
|
18
|
-
|
|
19
|
-
// ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
|
|
20
|
-
var defaultAttributes = {
|
|
21
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
22
|
-
width: 24,
|
|
23
|
-
height: 24,
|
|
24
|
-
viewBox: "0 0 24 24",
|
|
25
|
-
fill: "none",
|
|
26
|
-
stroke: "currentColor",
|
|
27
|
-
strokeWidth: 2,
|
|
28
|
-
strokeLinecap: "round",
|
|
29
|
-
strokeLinejoin: "round"
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// ../../node_modules/lucide-react/dist/esm/Icon.js
|
|
33
|
-
var Icon = forwardRef(
|
|
34
|
-
({
|
|
35
|
-
color = "currentColor",
|
|
36
|
-
size = 24,
|
|
37
|
-
strokeWidth = 2,
|
|
38
|
-
absoluteStrokeWidth,
|
|
39
|
-
className = "",
|
|
40
|
-
children,
|
|
41
|
-
iconNode,
|
|
42
|
-
...rest
|
|
43
|
-
}, ref) => {
|
|
44
|
-
return createElement(
|
|
45
|
-
"svg",
|
|
46
|
-
{
|
|
47
|
-
ref,
|
|
48
|
-
...defaultAttributes,
|
|
49
|
-
width: size,
|
|
50
|
-
height: size,
|
|
51
|
-
stroke: color,
|
|
52
|
-
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
|
|
53
|
-
className: mergeClasses("lucide", className),
|
|
54
|
-
...rest
|
|
55
|
-
},
|
|
56
|
-
[
|
|
57
|
-
...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
|
|
58
|
-
...Array.isArray(children) ? children : [children]
|
|
59
|
-
]
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
65
|
-
var createLucideIcon = (iconName, iconNode) => {
|
|
66
|
-
const Component = forwardRef2(
|
|
67
|
-
({ className, ...props }, ref) => createElement2(Icon, {
|
|
68
|
-
ref,
|
|
69
|
-
iconNode,
|
|
70
|
-
className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
|
|
71
|
-
...props
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
Component.displayName = `${iconName}`;
|
|
75
|
-
return Component;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// ../../node_modules/lucide-react/dist/esm/icons/bot.js
|
|
79
|
-
var __iconNode = [
|
|
80
|
-
["path", { d: "M12 8V4H8", key: "hb8ula" }],
|
|
81
|
-
["rect", { width: "16", height: "12", x: "4", y: "8", rx: "2", key: "enze0r" }],
|
|
82
|
-
["path", { d: "M2 14h2", key: "vft8re" }],
|
|
83
|
-
["path", { d: "M20 14h2", key: "4cs60a" }],
|
|
84
|
-
["path", { d: "M15 13v2", key: "1xurst" }],
|
|
85
|
-
["path", { d: "M9 13v2", key: "rq6x2g" }]
|
|
86
|
-
];
|
|
87
|
-
var Bot = createLucideIcon("Bot", __iconNode);
|
|
88
|
-
|
|
89
|
-
// ../../node_modules/lucide-react/dist/esm/icons/check-check.js
|
|
90
|
-
var __iconNode2 = [
|
|
91
|
-
["path", { d: "M18 6 7 17l-5-5", key: "116fxf" }],
|
|
92
|
-
["path", { d: "m22 10-7.5 7.5L13 16", key: "ke71qq" }]
|
|
93
|
-
];
|
|
94
|
-
var CheckCheck = createLucideIcon("CheckCheck", __iconNode2);
|
|
95
|
-
|
|
96
|
-
// ../../node_modules/lucide-react/dist/esm/icons/check.js
|
|
97
|
-
var __iconNode3 = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
98
|
-
var Check = createLucideIcon("Check", __iconNode3);
|
|
99
|
-
|
|
100
|
-
// ../../node_modules/lucide-react/dist/esm/icons/circle-alert.js
|
|
101
|
-
var __iconNode4 = [
|
|
102
|
-
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
103
|
-
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
|
|
104
|
-
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
|
|
105
|
-
];
|
|
106
|
-
var CircleAlert = createLucideIcon("CircleAlert", __iconNode4);
|
|
107
|
-
|
|
108
|
-
// ../../node_modules/lucide-react/dist/esm/icons/circle-x.js
|
|
109
|
-
var __iconNode5 = [
|
|
110
|
-
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
111
|
-
["path", { d: "m15 9-6 6", key: "1uzhvr" }],
|
|
112
|
-
["path", { d: "m9 9 6 6", key: "z0biqf" }]
|
|
113
|
-
];
|
|
114
|
-
var CircleX = createLucideIcon("CircleX", __iconNode5);
|
|
115
|
-
|
|
116
|
-
// ../../node_modules/lucide-react/dist/esm/icons/loader-circle.js
|
|
117
|
-
var __iconNode6 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
|
|
118
|
-
var LoaderCircle = createLucideIcon("LoaderCircle", __iconNode6);
|
|
119
|
-
|
|
120
|
-
// ../../node_modules/lucide-react/dist/esm/icons/log-out.js
|
|
121
|
-
var __iconNode7 = [
|
|
122
|
-
["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", key: "1uf3rs" }],
|
|
123
|
-
["polyline", { points: "16 17 21 12 16 7", key: "1gabdz" }],
|
|
124
|
-
["line", { x1: "21", x2: "9", y1: "12", y2: "12", key: "1uyos4" }]
|
|
125
|
-
];
|
|
126
|
-
var LogOut = createLucideIcon("LogOut", __iconNode7);
|
|
127
|
-
|
|
128
|
-
// ../../node_modules/lucide-react/dist/esm/icons/paperclip.js
|
|
129
|
-
var __iconNode8 = [
|
|
130
|
-
["path", { d: "M13.234 20.252 21 12.3", key: "1cbrk9" }],
|
|
131
|
-
[
|
|
132
|
-
"path",
|
|
133
|
-
{
|
|
134
|
-
d: "m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",
|
|
135
|
-
key: "1pkts6"
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
];
|
|
139
|
-
var Paperclip = createLucideIcon("Paperclip", __iconNode8);
|
|
140
|
-
|
|
141
|
-
// ../../node_modules/lucide-react/dist/esm/icons/phone.js
|
|
142
|
-
var __iconNode9 = [
|
|
143
|
-
[
|
|
144
|
-
"path",
|
|
145
|
-
{
|
|
146
|
-
d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",
|
|
147
|
-
key: "foiqr5"
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
];
|
|
151
|
-
var Phone = createLucideIcon("Phone", __iconNode9);
|
|
152
|
-
|
|
153
|
-
// ../../node_modules/lucide-react/dist/esm/icons/plus.js
|
|
154
|
-
var __iconNode10 = [
|
|
155
|
-
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
156
|
-
["path", { d: "M12 5v14", key: "s699le" }]
|
|
157
|
-
];
|
|
158
|
-
var Plus = createLucideIcon("Plus", __iconNode10);
|
|
159
|
-
|
|
160
|
-
// ../../node_modules/lucide-react/dist/esm/icons/send.js
|
|
161
|
-
var __iconNode11 = [
|
|
162
|
-
[
|
|
163
|
-
"path",
|
|
164
|
-
{
|
|
165
|
-
d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
|
|
166
|
-
key: "1ffxy3"
|
|
167
|
-
}
|
|
168
|
-
],
|
|
169
|
-
["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
|
|
170
|
-
];
|
|
171
|
-
var Send = createLucideIcon("Send", __iconNode11);
|
|
172
|
-
|
|
173
|
-
// ../../node_modules/lucide-react/dist/esm/icons/user-check.js
|
|
174
|
-
var __iconNode12 = [
|
|
175
|
-
["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
|
|
176
|
-
["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
|
|
177
|
-
["polyline", { points: "16 11 18 13 22 9", key: "1pwet4" }]
|
|
178
|
-
];
|
|
179
|
-
var UserCheck = createLucideIcon("UserCheck", __iconNode12);
|
|
180
|
-
|
|
181
|
-
// ../../node_modules/lucide-react/dist/esm/icons/user-cog.js
|
|
182
|
-
var __iconNode13 = [
|
|
183
|
-
["circle", { cx: "18", cy: "15", r: "3", key: "gjjjvw" }],
|
|
184
|
-
["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
|
|
185
|
-
["path", { d: "M10 15H6a4 4 0 0 0-4 4v2", key: "1nfge6" }],
|
|
186
|
-
["path", { d: "m21.7 16.4-.9-.3", key: "12j9ji" }],
|
|
187
|
-
["path", { d: "m15.2 13.9-.9-.3", key: "1fdjdi" }],
|
|
188
|
-
["path", { d: "m16.6 18.7.3-.9", key: "heedtr" }],
|
|
189
|
-
["path", { d: "m19.1 12.2.3-.9", key: "1af3ki" }],
|
|
190
|
-
["path", { d: "m19.6 18.7-.4-1", key: "1x9vze" }],
|
|
191
|
-
["path", { d: "m16.8 12.3-.4-1", key: "vqeiwj" }],
|
|
192
|
-
["path", { d: "m14.3 16.6 1-.4", key: "1qlj63" }],
|
|
193
|
-
["path", { d: "m20.7 13.8 1-.4", key: "1v5t8k" }]
|
|
194
|
-
];
|
|
195
|
-
var UserCog = createLucideIcon("UserCog", __iconNode13);
|
|
196
|
-
|
|
197
|
-
// ../../node_modules/lucide-react/dist/esm/icons/user.js
|
|
198
|
-
var __iconNode14 = [
|
|
199
|
-
["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
|
|
200
|
-
["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
|
|
201
|
-
];
|
|
202
|
-
var User = createLucideIcon("User", __iconNode14);
|
|
203
|
-
|
|
204
|
-
// components/admin/admin-chat-input.tsx
|
|
5
|
+
import { Paperclip, Send } from "lucide-react";
|
|
205
6
|
import { useRef as useRef2, useState as useState4 } from "react";
|
|
206
7
|
|
|
207
8
|
// context/websocket-chat-admin-context.tsx
|
|
@@ -1643,11 +1444,12 @@ var useWebSocketChatAdminContext = () => {
|
|
|
1643
1444
|
// components/admin/admin-chat-input.tsx
|
|
1644
1445
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1645
1446
|
var AdminChatInput = ({
|
|
1447
|
+
userId,
|
|
1448
|
+
orgId,
|
|
1646
1449
|
onFileUpload,
|
|
1647
1450
|
chatKey
|
|
1648
1451
|
}) => {
|
|
1649
1452
|
const { sendMessage } = useWebSocketChatAdminContext();
|
|
1650
|
-
const { user, selectedOrgId } = useUserContext();
|
|
1651
1453
|
const [input, setInput] = useState4("");
|
|
1652
1454
|
const [isUploading, setIsUploading] = useState4(false);
|
|
1653
1455
|
const [isSending, setIsSending] = useState4(false);
|
|
@@ -1655,7 +1457,7 @@ var AdminChatInput = ({
|
|
|
1655
1457
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
1656
1458
|
const handleSend = async () => {
|
|
1657
1459
|
if (!input.trim() && !isUploading || isSending) return;
|
|
1658
|
-
if (!chatKey || !
|
|
1460
|
+
if (!chatKey || !orgId || !userId) {
|
|
1659
1461
|
console.error("chatKey, orgId, or userId is not defined");
|
|
1660
1462
|
return;
|
|
1661
1463
|
}
|
|
@@ -1664,13 +1466,13 @@ var AdminChatInput = ({
|
|
|
1664
1466
|
sendMessage({
|
|
1665
1467
|
type: "message",
|
|
1666
1468
|
chatKey,
|
|
1667
|
-
orgId
|
|
1668
|
-
userId
|
|
1469
|
+
orgId,
|
|
1470
|
+
userId,
|
|
1669
1471
|
message: {
|
|
1670
1472
|
id: KSUID.randomSync().string,
|
|
1671
1473
|
content: input,
|
|
1672
1474
|
role: "user",
|
|
1673
|
-
senderId:
|
|
1475
|
+
senderId: userId,
|
|
1674
1476
|
time: Date.now(),
|
|
1675
1477
|
status: "sending",
|
|
1676
1478
|
createdAt: Date.now()
|
|
@@ -1706,7 +1508,7 @@ var AdminChatInput = ({
|
|
|
1706
1508
|
url: file.url,
|
|
1707
1509
|
title: file.name
|
|
1708
1510
|
}));
|
|
1709
|
-
if (!chatKey || !
|
|
1511
|
+
if (!chatKey || !orgId || !userId) {
|
|
1710
1512
|
console.error("chatKey, orgId, or userId is not defined");
|
|
1711
1513
|
return;
|
|
1712
1514
|
}
|
|
@@ -1776,7 +1578,7 @@ var AdminChatInput = ({
|
|
|
1776
1578
|
};
|
|
1777
1579
|
|
|
1778
1580
|
// components/admin/chat-human-agent-actions.tsx
|
|
1779
|
-
import {
|
|
1581
|
+
import { LogOut, Phone, Plus, User as UserIcon, XCircle } from "lucide-react";
|
|
1780
1582
|
|
|
1781
1583
|
// context/websocket-chat-customer-context.tsx
|
|
1782
1584
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
@@ -1804,43 +1606,42 @@ var useWebSocketChatCustomerContext = () => {
|
|
|
1804
1606
|
|
|
1805
1607
|
// components/admin/chat-human-agent-actions.tsx
|
|
1806
1608
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1807
|
-
var ChatHumanAgentActions = ({}) => {
|
|
1808
|
-
const { user, selectedOrgId } = useUserContext2();
|
|
1609
|
+
var ChatHumanAgentActions = ({ user, orgId }) => {
|
|
1809
1610
|
const { selectedChat, addUserToChat, removeUserFromChat, blockUser } = useWebSocketChatAdminContext();
|
|
1810
1611
|
const handleJoinChat = () => {
|
|
1811
|
-
if (!selectedChat || !user || !
|
|
1812
|
-
addUserToChat(
|
|
1612
|
+
if (!selectedChat || !user || !orgId) return;
|
|
1613
|
+
addUserToChat(orgId, selectedChat.key, {
|
|
1813
1614
|
id: user.id,
|
|
1814
1615
|
role: "humanAgent",
|
|
1815
|
-
name: user.firstName
|
|
1616
|
+
name: [user.firstName, user.lastName].filter(Boolean).join(" ") || user.email,
|
|
1816
1617
|
email: user.email,
|
|
1817
1618
|
authProvider: "tbd",
|
|
1818
1619
|
authToken: "tbd"
|
|
1819
1620
|
});
|
|
1820
1621
|
};
|
|
1821
1622
|
const handleLeaveChat = () => {
|
|
1822
|
-
if (!selectedChat || !user || !
|
|
1823
|
-
removeUserFromChat(
|
|
1623
|
+
if (!selectedChat || !user || !orgId) return;
|
|
1624
|
+
removeUserFromChat(orgId, selectedChat.key, user.id);
|
|
1824
1625
|
};
|
|
1825
1626
|
const handleEndChat = () => {
|
|
1826
|
-
if (!selectedChat || !user || !
|
|
1627
|
+
if (!selectedChat || !user || !orgId) return;
|
|
1827
1628
|
};
|
|
1828
1629
|
const handleStartCall = () => {
|
|
1829
|
-
if (!selectedChat || !user || !
|
|
1630
|
+
if (!selectedChat || !user || !orgId) return;
|
|
1830
1631
|
};
|
|
1831
1632
|
const handleCreateCase = () => {
|
|
1832
|
-
if (!selectedChat || !user || !
|
|
1633
|
+
if (!selectedChat || !user || !orgId) return;
|
|
1833
1634
|
};
|
|
1834
1635
|
const handleBlockUser = () => {
|
|
1835
|
-
if (!selectedChat || !user || !
|
|
1836
|
-
blockUser(
|
|
1636
|
+
if (!selectedChat || !user || !orgId) return;
|
|
1637
|
+
blockUser(orgId, selectedChat.key, user.id);
|
|
1837
1638
|
};
|
|
1838
1639
|
if (!selectedChat) return null;
|
|
1839
1640
|
return /* @__PURE__ */ jsxs2("div", { className: "p-4 border-b bg-white flex items-center justify-between", children: [
|
|
1840
1641
|
/* @__PURE__ */ jsxs2("div", { className: "flex items-center space-x-4", children: [
|
|
1841
1642
|
/* @__PURE__ */ jsx4("h2", { className: "font-semibold text-lg", children: selectedChat.title || `Chat ${selectedChat.key}` }),
|
|
1842
1643
|
selectedChat.humanAgentEngaged && /* @__PURE__ */ jsxs2("span", { className: "inline-flex items-center rounded-full bg-green-100 px-2.5 py-0.5 text-sm font-medium text-green-800", children: [
|
|
1843
|
-
/* @__PURE__ */ jsx4(
|
|
1644
|
+
/* @__PURE__ */ jsx4(UserIcon, { className: "mr-1 h-4 w-4" }),
|
|
1844
1645
|
"Agent Engaged"
|
|
1845
1646
|
] })
|
|
1846
1647
|
] }),
|
|
@@ -1851,7 +1652,7 @@ var ChatHumanAgentActions = ({}) => {
|
|
|
1851
1652
|
onClick: handleJoinChat,
|
|
1852
1653
|
className: "bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1853
1654
|
children: [
|
|
1854
|
-
/* @__PURE__ */ jsx4(
|
|
1655
|
+
/* @__PURE__ */ jsx4(UserIcon, { className: "h-4 w-4" }),
|
|
1855
1656
|
/* @__PURE__ */ jsx4("span", { children: "Join Chat" })
|
|
1856
1657
|
]
|
|
1857
1658
|
}
|
|
@@ -1872,7 +1673,7 @@ var ChatHumanAgentActions = ({}) => {
|
|
|
1872
1673
|
onClick: handleEndChat,
|
|
1873
1674
|
className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1874
1675
|
children: [
|
|
1875
|
-
/* @__PURE__ */ jsx4(
|
|
1676
|
+
/* @__PURE__ */ jsx4(XCircle, { className: "h-4 w-4" }),
|
|
1876
1677
|
/* @__PURE__ */ jsx4("span", { children: "End Chat" })
|
|
1877
1678
|
]
|
|
1878
1679
|
}
|
|
@@ -1883,7 +1684,7 @@ var ChatHumanAgentActions = ({}) => {
|
|
|
1883
1684
|
onClick: handleBlockUser,
|
|
1884
1685
|
className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1885
1686
|
children: [
|
|
1886
|
-
/* @__PURE__ */ jsx4(
|
|
1687
|
+
/* @__PURE__ */ jsx4(XCircle, { className: "h-4 w-4" }),
|
|
1887
1688
|
/* @__PURE__ */ jsx4("span", { children: "Block User" })
|
|
1888
1689
|
]
|
|
1889
1690
|
}
|
|
@@ -1916,8 +1717,9 @@ var ChatHumanAgentActions = ({}) => {
|
|
|
1916
1717
|
};
|
|
1917
1718
|
|
|
1918
1719
|
// components/admin/admin-chat-list.tsx
|
|
1919
|
-
import {
|
|
1720
|
+
import { AlertCircle, Bot, Loader2, UserCheck } from "lucide-react";
|
|
1920
1721
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1722
|
+
var ScrollArea = ({ className, children }) => /* @__PURE__ */ jsx5("div", { className: `overflow-auto ${className || ""}`, children });
|
|
1921
1723
|
var AdminChatList = ({ className }) => {
|
|
1922
1724
|
const { chats, selectedChat, selectChat } = useWebSocketChatAdminContext();
|
|
1923
1725
|
const sortedChats = Array.from(chats.values()).sort(
|
|
@@ -1950,7 +1752,7 @@ var AdminChatListItem = ({
|
|
|
1950
1752
|
children: /* @__PURE__ */ jsxs3("div", { className: "flex items-start space-x-3", children: [
|
|
1951
1753
|
/* @__PURE__ */ jsxs3("div", { className: "shrink-0", children: [
|
|
1952
1754
|
chat.aiEngaged && /* @__PURE__ */ jsx5(Bot, { className: "w-6 h-6 text-blue-500" }),
|
|
1953
|
-
chat.isWaitingForAgent && /* @__PURE__ */ jsx5(
|
|
1755
|
+
chat.isWaitingForAgent && /* @__PURE__ */ jsx5(Loader2, { className: "w-6 h-6 text-blue-500 animate-spin text-orange-500" }),
|
|
1954
1756
|
chat.humanAgentEngaged && /* @__PURE__ */ jsx5(UserCheck, { className: "w-6 h-6 text-blue-500 text-green-500" })
|
|
1955
1757
|
] }),
|
|
1956
1758
|
/* @__PURE__ */ jsxs3("div", { className: "flex-1 min-w-0", children: [
|
|
@@ -1958,7 +1760,7 @@ var AdminChatListItem = ({
|
|
|
1958
1760
|
lastMessage && /* @__PURE__ */ jsx5("p", { className: "mt-1 text-sm text-gray-500 truncate", children: lastMessage.content }),
|
|
1959
1761
|
/* @__PURE__ */ jsxs3("div", { className: "mt-1 flex items-center space-x-2", children: [
|
|
1960
1762
|
chat.isWaiting && /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center rounded-full bg-yellow-100 px-2 py-0.5 text-xs font-medium text-yellow-800", children: [
|
|
1961
|
-
/* @__PURE__ */ jsx5(
|
|
1763
|
+
/* @__PURE__ */ jsx5(AlertCircle, { className: "mr-1 h-3 w-3" }),
|
|
1962
1764
|
"Waiting"
|
|
1963
1765
|
] }),
|
|
1964
1766
|
chat.humanAgentEngaged && /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800", children: [
|
|
@@ -2029,13 +1831,12 @@ var ChatHeader = () => {
|
|
|
2029
1831
|
};
|
|
2030
1832
|
|
|
2031
1833
|
// components/customer/chat-input.tsx
|
|
2032
|
-
import { useUserContext as useUserContext3 } from "@elqnt/auth";
|
|
2033
1834
|
import KSUID2 from "ksuid";
|
|
1835
|
+
import { Paperclip as Paperclip2, Send as Send2 } from "lucide-react";
|
|
2034
1836
|
import { useRef as useRef3, useState as useState5 } from "react";
|
|
2035
1837
|
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2036
|
-
var ChatInput = ({ onFileUpload }) => {
|
|
1838
|
+
var ChatInput = ({ userId, orgId, onFileUpload }) => {
|
|
2037
1839
|
const { sendMessage, chatKey } = useWebSocketChatCustomerContext();
|
|
2038
|
-
const { user, selectedOrgId } = useUserContext3();
|
|
2039
1840
|
const [input, setInput] = useState5("");
|
|
2040
1841
|
const [isUploading, setIsUploading] = useState5(false);
|
|
2041
1842
|
const [isSending, setIsSending] = useState5(false);
|
|
@@ -2043,7 +1844,7 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
2043
1844
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
2044
1845
|
const handleSend = async () => {
|
|
2045
1846
|
if (!input.trim() && !isUploading || isSending) return;
|
|
2046
|
-
if (!chatKey || !
|
|
1847
|
+
if (!chatKey || !orgId || !userId) {
|
|
2047
1848
|
console.error("chatKey, orgId, or userId is not defined");
|
|
2048
1849
|
return;
|
|
2049
1850
|
}
|
|
@@ -2052,13 +1853,13 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
2052
1853
|
sendMessage({
|
|
2053
1854
|
type: "message",
|
|
2054
1855
|
chatKey,
|
|
2055
|
-
orgId
|
|
2056
|
-
userId
|
|
1856
|
+
orgId,
|
|
1857
|
+
userId,
|
|
2057
1858
|
message: {
|
|
2058
1859
|
id: KSUID2.randomSync().string,
|
|
2059
1860
|
content: input,
|
|
2060
1861
|
role: "user",
|
|
2061
|
-
senderId:
|
|
1862
|
+
senderId: userId,
|
|
2062
1863
|
time: Date.now(),
|
|
2063
1864
|
status: "sending",
|
|
2064
1865
|
createdAt: Date.now()
|
|
@@ -2094,7 +1895,7 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
2094
1895
|
url: file.url,
|
|
2095
1896
|
title: file.name
|
|
2096
1897
|
}));
|
|
2097
|
-
if (!chatKey || !
|
|
1898
|
+
if (!chatKey || !orgId || !userId) {
|
|
2098
1899
|
console.error("chatKey, orgId, or userId is not defined");
|
|
2099
1900
|
return;
|
|
2100
1901
|
}
|
|
@@ -2125,7 +1926,7 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
2125
1926
|
className: "p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100 transition-colors",
|
|
2126
1927
|
disabled: isUploading,
|
|
2127
1928
|
"aria-label": "Attach file",
|
|
2128
|
-
children: isUploading ? /* @__PURE__ */ jsx9("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ jsx9(
|
|
1929
|
+
children: isUploading ? /* @__PURE__ */ jsx9("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ jsx9(Paperclip2, { className: "w-5 h-5" })
|
|
2129
1930
|
}
|
|
2130
1931
|
),
|
|
2131
1932
|
/* @__PURE__ */ jsx9("div", { className: "flex-1 relative", children: /* @__PURE__ */ jsx9(
|
|
@@ -2155,7 +1956,7 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
2155
1956
|
disabled: !input.trim() && !isUploading || isSending,
|
|
2156
1957
|
className: `p-2 rounded-full transition-colors ${!input.trim() && !isUploading || isSending ? "text-gray-400 bg-gray-100" : "text-white bg-blue-500 hover:bg-blue-600"}`,
|
|
2157
1958
|
"aria-label": "Send message",
|
|
2158
|
-
children: isSending ? /* @__PURE__ */ jsx9("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ jsx9(
|
|
1959
|
+
children: isSending ? /* @__PURE__ */ jsx9("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ jsx9(Send2, { className: "w-5 h-5" })
|
|
2159
1960
|
}
|
|
2160
1961
|
)
|
|
2161
1962
|
] }),
|
|
@@ -3735,6 +3536,17 @@ function cleanEscapedString(input) {
|
|
|
3735
3536
|
return matched[1].replace(doubleQuoteRegExp, "'");
|
|
3736
3537
|
}
|
|
3737
3538
|
|
|
3539
|
+
// components/customer/chat-message.tsx
|
|
3540
|
+
import {
|
|
3541
|
+
AlertCircle as AlertCircle2,
|
|
3542
|
+
Bot as Bot2,
|
|
3543
|
+
Check,
|
|
3544
|
+
CheckCheck,
|
|
3545
|
+
Paperclip as Paperclip3,
|
|
3546
|
+
User,
|
|
3547
|
+
UserCog
|
|
3548
|
+
} from "lucide-react";
|
|
3549
|
+
|
|
3738
3550
|
// components/markdown-renderer.tsx
|
|
3739
3551
|
import ReactMarkdown from "react-markdown";
|
|
3740
3552
|
import remarkGfm from "remark-gfm";
|
|
@@ -3803,7 +3615,7 @@ var Message = ({
|
|
|
3803
3615
|
target: "_blank",
|
|
3804
3616
|
rel: "noopener noreferrer",
|
|
3805
3617
|
children: [
|
|
3806
|
-
/* @__PURE__ */ jsx11(
|
|
3618
|
+
/* @__PURE__ */ jsx11(Paperclip3, { className: "w-4 h-4" }),
|
|
3807
3619
|
/* @__PURE__ */ jsx11("span", { children: attachment.title })
|
|
3808
3620
|
]
|
|
3809
3621
|
}
|
|
@@ -3818,7 +3630,7 @@ var Message = ({
|
|
|
3818
3630
|
children: [
|
|
3819
3631
|
/* @__PURE__ */ jsx11("div", { className: "flex pt-10 w-10", children: /* @__PURE__ */ jsxs8("div", { className: "w-8 h-8 rounded-full flex justify-center", children: [
|
|
3820
3632
|
message2.role === "user" && /* @__PURE__ */ jsx11(User, {}),
|
|
3821
|
-
message2.role === "ai" && /* @__PURE__ */ jsx11(
|
|
3633
|
+
message2.role === "ai" && /* @__PURE__ */ jsx11(Bot2, {}),
|
|
3822
3634
|
message2.role === "humanAgent" && /* @__PURE__ */ jsx11(UserCog, {})
|
|
3823
3635
|
] }) }),
|
|
3824
3636
|
/* @__PURE__ */ jsxs8(
|
|
@@ -3842,7 +3654,7 @@ var Message = ({
|
|
|
3842
3654
|
onClick: () => onRetry(message2.id),
|
|
3843
3655
|
className: "text-red-300 hover:text-red-400",
|
|
3844
3656
|
"aria-label": "Retry sending message",
|
|
3845
|
-
children: /* @__PURE__ */ jsx11(
|
|
3657
|
+
children: /* @__PURE__ */ jsx11(AlertCircle2, { className: "w-4 h-4" })
|
|
3846
3658
|
}
|
|
3847
3659
|
)
|
|
3848
3660
|
] })
|
|
@@ -3908,9 +3720,12 @@ var ChatTypingIndicator = ({
|
|
|
3908
3720
|
};
|
|
3909
3721
|
|
|
3910
3722
|
// components/customer/generic-chat-widget.tsx
|
|
3911
|
-
import { Alert } from "@elqnt/react";
|
|
3912
3723
|
import { useState as useState6 } from "react";
|
|
3913
3724
|
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3725
|
+
var Alert = ({ title, description }) => /* @__PURE__ */ jsxs11("div", { className: "p-4 bg-red-50 border border-red-200 rounded-lg", role: "alert", children: [
|
|
3726
|
+
/* @__PURE__ */ jsx13("p", { className: "font-medium text-red-800", children: title }),
|
|
3727
|
+
/* @__PURE__ */ jsx13("p", { className: "text-sm text-red-600", children: description })
|
|
3728
|
+
] });
|
|
3914
3729
|
var GenericChatWidget = ({
|
|
3915
3730
|
onFileUpload
|
|
3916
3731
|
}) => {
|
|
@@ -4132,32 +3947,4 @@ export {
|
|
|
4132
3947
|
useWebSocketChatCustomer,
|
|
4133
3948
|
useWebSocketChatCustomerContext
|
|
4134
3949
|
};
|
|
4135
|
-
/*! Bundled license information:
|
|
4136
|
-
|
|
4137
|
-
lucide-react/dist/esm/shared/src/utils.js:
|
|
4138
|
-
lucide-react/dist/esm/defaultAttributes.js:
|
|
4139
|
-
lucide-react/dist/esm/Icon.js:
|
|
4140
|
-
lucide-react/dist/esm/createLucideIcon.js:
|
|
4141
|
-
lucide-react/dist/esm/icons/bot.js:
|
|
4142
|
-
lucide-react/dist/esm/icons/check-check.js:
|
|
4143
|
-
lucide-react/dist/esm/icons/check.js:
|
|
4144
|
-
lucide-react/dist/esm/icons/circle-alert.js:
|
|
4145
|
-
lucide-react/dist/esm/icons/circle-x.js:
|
|
4146
|
-
lucide-react/dist/esm/icons/loader-circle.js:
|
|
4147
|
-
lucide-react/dist/esm/icons/log-out.js:
|
|
4148
|
-
lucide-react/dist/esm/icons/paperclip.js:
|
|
4149
|
-
lucide-react/dist/esm/icons/phone.js:
|
|
4150
|
-
lucide-react/dist/esm/icons/plus.js:
|
|
4151
|
-
lucide-react/dist/esm/icons/send.js:
|
|
4152
|
-
lucide-react/dist/esm/icons/user-check.js:
|
|
4153
|
-
lucide-react/dist/esm/icons/user-cog.js:
|
|
4154
|
-
lucide-react/dist/esm/icons/user.js:
|
|
4155
|
-
lucide-react/dist/esm/lucide-react.js:
|
|
4156
|
-
(**
|
|
4157
|
-
* @license lucide-react v0.483.0 - ISC
|
|
4158
|
-
*
|
|
4159
|
-
* This source code is licensed under the ISC license.
|
|
4160
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
4161
|
-
*)
|
|
4162
|
-
*/
|
|
4163
3950
|
//# sourceMappingURL=index.mjs.map
|