@elqnt/chat 1.0.1 → 1.0.2
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/chunk-3PXNBY7J.js +73 -0
- package/dist/chunk-3PXNBY7J.js.map +1 -0
- package/dist/chunk-AC5J5LX5.mjs +529 -0
- package/dist/chunk-AC5J5LX5.mjs.map +1 -0
- package/dist/chunk-DTFTLFSY.js +637 -0
- package/dist/chunk-DTFTLFSY.js.map +1 -0
- package/dist/chunk-E2FJX52R.js +529 -0
- package/dist/chunk-E2FJX52R.js.map +1 -0
- package/dist/chunk-F6OOS4ZM.mjs +637 -0
- package/dist/chunk-F6OOS4ZM.mjs.map +1 -0
- package/dist/chunk-XVYABY2Z.mjs +73 -0
- package/dist/chunk-XVYABY2Z.mjs.map +1 -0
- package/dist/hooks/use-websocket-chat-admin.d.mts +16 -0
- package/dist/hooks/use-websocket-chat-admin.d.ts +16 -0
- package/dist/hooks/use-websocket-chat-admin.js +9 -0
- package/dist/hooks/use-websocket-chat-admin.js.map +1 -0
- package/dist/hooks/use-websocket-chat-admin.mjs +9 -0
- package/dist/hooks/use-websocket-chat-admin.mjs.map +1 -0
- package/dist/hooks/use-websocket-chat-base.d.mts +4 -0
- package/dist/hooks/use-websocket-chat-base.d.ts +4 -0
- package/dist/hooks/use-websocket-chat-base.js +8 -0
- package/dist/hooks/use-websocket-chat-base.js.map +1 -0
- package/dist/hooks/use-websocket-chat-base.mjs +8 -0
- package/dist/hooks/use-websocket-chat-base.mjs.map +1 -0
- package/dist/hooks/use-websocket-chat-customer.d.mts +23 -0
- package/dist/hooks/use-websocket-chat-customer.d.ts +23 -0
- package/dist/hooks/use-websocket-chat-customer.js +9 -0
- package/dist/hooks/use-websocket-chat-customer.js.map +1 -0
- package/dist/hooks/use-websocket-chat-customer.mjs +9 -0
- package/dist/hooks/use-websocket-chat-customer.mjs.map +1 -0
- package/dist/index.d.mts +10 -1015
- package/dist/index.d.ts +10 -1015
- package/dist/index.js +616 -1710
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +198 -1063
- package/dist/index.mjs.map +1 -1
- package/dist/use-websocket-chat-base-CZDONnTz.d.mts +989 -0
- package/dist/use-websocket-chat-base-CZDONnTz.d.ts +989 -0
- package/package.json +16 -1
package/dist/index.js
CHANGED
|
@@ -1,237 +1,192 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
GetActiveChatsSubject: () => GetActiveChatsSubject,
|
|
184
|
-
GetAgentQueuesSubject: () => GetAgentQueuesSubject,
|
|
185
|
-
GetAgentSessionSubject: () => GetAgentSessionSubject,
|
|
186
|
-
GetChatSubject: () => GetChatSubject,
|
|
187
|
-
GetDailyChatCountSubject: () => GetDailyChatCountSubject,
|
|
188
|
-
GetOnlineAgentCountSubject: () => GetOnlineAgentCountSubject,
|
|
189
|
-
GetOnlineAgentsSubject: () => GetOnlineAgentsSubject,
|
|
190
|
-
GetOnlineUsersSubject: () => GetOnlineUsersSubject,
|
|
191
|
-
GetQueueChatCountSubject: () => GetQueueChatCountSubject,
|
|
192
|
-
GetQueueChatsSubject: () => GetQueueChatsSubject,
|
|
193
|
-
GetUserChatsSubject: () => GetUserChatsSubject,
|
|
194
|
-
GetWaitingForAgentChatCountSubject: () => GetWaitingForAgentChatCountSubject,
|
|
195
|
-
GetWaitingForAgentChatsSubject: () => GetWaitingForAgentChatsSubject,
|
|
196
|
-
MessageStatusDelivered: () => MessageStatusDelivered,
|
|
197
|
-
MessageStatusFailed: () => MessageStatusFailed,
|
|
198
|
-
MessageStatusRead: () => MessageStatusRead,
|
|
199
|
-
MessageStatusSending: () => MessageStatusSending,
|
|
200
|
-
MessageStatusSent: () => MessageStatusSent,
|
|
201
|
-
QueueTypeComplexity: () => QueueTypeComplexity,
|
|
202
|
-
QueueTypeDepartment: () => QueueTypeDepartment,
|
|
203
|
-
QueueTypePriority: () => QueueTypePriority,
|
|
204
|
-
QueueTypeSkill: () => QueueTypeSkill,
|
|
205
|
-
QueueTypes: () => QueueTypes,
|
|
206
|
-
SetupOrgSubject: () => SetupOrgSubject,
|
|
207
|
-
StartAgentSessionSubject: () => StartAgentSessionSubject,
|
|
208
|
-
TriggerAnalyticsScanSubject: () => TriggerAnalyticsScanSubject,
|
|
209
|
-
UpdateAgentLastActivitySubject: () => UpdateAgentLastActivitySubject,
|
|
210
|
-
UpdateAgentQueueSubject: () => UpdateAgentQueueSubject,
|
|
211
|
-
UpdateAgentStatusSubject: () => UpdateAgentStatusSubject,
|
|
212
|
-
UpdateUserStatusSubject: () => UpdateUserStatusSubject,
|
|
213
|
-
UserStatusAway: () => UserStatusAway,
|
|
214
|
-
UserStatusBusy: () => UserStatusBusy,
|
|
215
|
-
UserStatusOffline: () => UserStatusOffline,
|
|
216
|
-
UserStatusOnline: () => UserStatusOnline,
|
|
217
|
-
WebSocketChatAdminContext: () => WebSocketChatAdminContext,
|
|
218
|
-
WebSocketChatAdminProvider: () => WebSocketChatAdminProvider,
|
|
219
|
-
WebSocketChatCustomerContext: () => WebSocketChatCustomerContext,
|
|
220
|
-
WebSocketChatCustomerProvider: () => WebSocketChatCustomerProvider,
|
|
221
|
-
useWebSocketChatAdmin: () => useWebSocketChatAdmin,
|
|
222
|
-
useWebSocketChatAdminContext: () => useWebSocketChatAdminContext,
|
|
223
|
-
useWebSocketChatBase: () => useWebSocketChatBase,
|
|
224
|
-
useWebSocketChatCustomer: () => useWebSocketChatCustomer,
|
|
225
|
-
useWebSocketChatCustomerContext: () => useWebSocketChatCustomerContext
|
|
226
|
-
});
|
|
227
|
-
module.exports = __toCommonJS(index_exports);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
var _chunkE2FJX52Rjs = require('./chunk-E2FJX52R.js');
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
var _chunk3PXNBY7Jjs = require('./chunk-3PXNBY7J.js');
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
var _chunkDTFTLFSYjs = require('./chunk-DTFTLFSY.js');
|
|
228
183
|
|
|
229
184
|
// components/admin/admin-chat-input.tsx
|
|
230
|
-
var
|
|
231
|
-
var
|
|
185
|
+
var _auth = require('@elqnt/auth');
|
|
186
|
+
var _ksuid = require('ksuid'); var _ksuid2 = _interopRequireDefault(_ksuid);
|
|
232
187
|
|
|
233
188
|
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
234
|
-
var
|
|
189
|
+
var _react = require('react');
|
|
235
190
|
|
|
236
191
|
// ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
|
|
237
192
|
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
@@ -240,7 +195,7 @@ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
|
240
195
|
}).join(" ").trim();
|
|
241
196
|
|
|
242
197
|
// ../../node_modules/lucide-react/dist/esm/Icon.js
|
|
243
|
-
|
|
198
|
+
|
|
244
199
|
|
|
245
200
|
// ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
|
|
246
201
|
var defaultAttributes = {
|
|
@@ -256,7 +211,7 @@ var defaultAttributes = {
|
|
|
256
211
|
};
|
|
257
212
|
|
|
258
213
|
// ../../node_modules/lucide-react/dist/esm/Icon.js
|
|
259
|
-
var Icon = (0,
|
|
214
|
+
var Icon = _react.forwardRef.call(void 0,
|
|
260
215
|
({
|
|
261
216
|
color = "currentColor",
|
|
262
217
|
size = 24,
|
|
@@ -267,7 +222,7 @@ var Icon = (0, import_react.forwardRef)(
|
|
|
267
222
|
iconNode,
|
|
268
223
|
...rest
|
|
269
224
|
}, ref) => {
|
|
270
|
-
return (0,
|
|
225
|
+
return _react.createElement.call(void 0,
|
|
271
226
|
"svg",
|
|
272
227
|
{
|
|
273
228
|
ref,
|
|
@@ -280,7 +235,7 @@ var Icon = (0, import_react.forwardRef)(
|
|
|
280
235
|
...rest
|
|
281
236
|
},
|
|
282
237
|
[
|
|
283
|
-
...iconNode.map(([tag, attrs]) => (0,
|
|
238
|
+
...iconNode.map(([tag, attrs]) => _react.createElement.call(void 0, tag, attrs)),
|
|
284
239
|
...Array.isArray(children) ? children : [children]
|
|
285
240
|
]
|
|
286
241
|
);
|
|
@@ -289,8 +244,8 @@ var Icon = (0, import_react.forwardRef)(
|
|
|
289
244
|
|
|
290
245
|
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
291
246
|
var createLucideIcon = (iconName, iconNode) => {
|
|
292
|
-
const Component = (0,
|
|
293
|
-
({ className, ...props }, ref) => (0,
|
|
247
|
+
const Component = _react.forwardRef.call(void 0,
|
|
248
|
+
({ className, ...props }, ref) => _react.createElement.call(void 0, Icon, {
|
|
294
249
|
ref,
|
|
295
250
|
iconNode,
|
|
296
251
|
className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
|
|
@@ -402,1097 +357,49 @@ var __iconNode12 = [
|
|
|
402
357
|
["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
|
|
403
358
|
["polyline", { points: "16 11 18 13 22 9", key: "1pwet4" }]
|
|
404
359
|
];
|
|
405
|
-
var UserCheck = createLucideIcon("UserCheck", __iconNode12);
|
|
406
|
-
|
|
407
|
-
// ../../node_modules/lucide-react/dist/esm/icons/user-cog.js
|
|
408
|
-
var __iconNode13 = [
|
|
409
|
-
["circle", { cx: "18", cy: "15", r: "3", key: "gjjjvw" }],
|
|
410
|
-
["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
|
|
411
|
-
["path", { d: "M10 15H6a4 4 0 0 0-4 4v2", key: "1nfge6" }],
|
|
412
|
-
["path", { d: "m21.7 16.4-.9-.3", key: "12j9ji" }],
|
|
413
|
-
["path", { d: "m15.2 13.9-.9-.3", key: "1fdjdi" }],
|
|
414
|
-
["path", { d: "m16.6 18.7.3-.9", key: "heedtr" }],
|
|
415
|
-
["path", { d: "m19.1 12.2.3-.9", key: "1af3ki" }],
|
|
416
|
-
["path", { d: "m19.6 18.7-.4-1", key: "1x9vze" }],
|
|
417
|
-
["path", { d: "m16.8 12.3-.4-1", key: "vqeiwj" }],
|
|
418
|
-
["path", { d: "m14.3 16.6 1-.4", key: "1qlj63" }],
|
|
419
|
-
["path", { d: "m20.7 13.8 1-.4", key: "1v5t8k" }]
|
|
420
|
-
];
|
|
421
|
-
var UserCog = createLucideIcon("UserCog", __iconNode13);
|
|
422
|
-
|
|
423
|
-
// ../../node_modules/lucide-react/dist/esm/icons/user.js
|
|
424
|
-
var __iconNode14 = [
|
|
425
|
-
["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
|
|
426
|
-
["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
|
|
427
|
-
];
|
|
428
|
-
var User = createLucideIcon("User", __iconNode14);
|
|
429
|
-
|
|
430
|
-
// components/admin/admin-chat-input.tsx
|
|
431
|
-
var import_react7 = require("react");
|
|
432
|
-
|
|
433
|
-
// context/websocket-chat-admin-context.tsx
|
|
434
|
-
var import_react6 = require("react");
|
|
435
|
-
|
|
436
|
-
// hooks/use-websocket-chat-admin.ts
|
|
437
|
-
var import_react4 = require("react");
|
|
438
|
-
|
|
439
|
-
// models/chat-models.ts
|
|
440
|
-
var ChatStatusActive = "active";
|
|
441
|
-
var ChatStatusDisconnected = "disconnected";
|
|
442
|
-
var ChatStatusAbandoned = "abandoned";
|
|
443
|
-
var ChatStatusClosed = "closed";
|
|
444
|
-
var ChatStatusArchived = "archived";
|
|
445
|
-
var ChatTypeCustomerSupport = "customer_support";
|
|
446
|
-
var ChatTypePublicRoom = "public_room";
|
|
447
|
-
var ChatTypePrivateRoom = "private_room";
|
|
448
|
-
var ChatTypeDirect = "direct";
|
|
449
|
-
var ChatTypeGroup = "group";
|
|
450
|
-
var ChatRoleUser = "user";
|
|
451
|
-
var ChatRoleAI = "ai";
|
|
452
|
-
var ChatRoleEvent = "event";
|
|
453
|
-
var ChatRoleHumanAgent = "humanAgent";
|
|
454
|
-
var ChatRoleObserver = "observer";
|
|
455
|
-
var ChatRoleDataQuery = "dataQuery";
|
|
456
|
-
var ChatRoleSystem = "system";
|
|
457
|
-
var ChatRoleTool = "tool";
|
|
458
|
-
var AgentStatusOnline = "online";
|
|
459
|
-
var AgentStatusAway = "away";
|
|
460
|
-
var AgentStatusBusy = "busy";
|
|
461
|
-
var AgentStatusOffline = "offline";
|
|
462
|
-
var ChatEventTypeUserJoined = "user_joined";
|
|
463
|
-
var ChatEventTypeUserLeft = "user_left";
|
|
464
|
-
var ChatEventTypeTyping = "typing";
|
|
465
|
-
var ChatEventTypeStoppedTyping = "stopped_typing";
|
|
466
|
-
var ChatEventTypeRead = "read";
|
|
467
|
-
var ChatEventTypeDelivered = "delivered";
|
|
468
|
-
var ChatEventTypeReconnected = "reconnected";
|
|
469
|
-
var ChatEventTypeError = "error";
|
|
470
|
-
var ChatEventTypeWaiting = "waiting";
|
|
471
|
-
var ChatEventTypeLoadChat = "load_chat";
|
|
472
|
-
var ChatEventTypeLoadChatResponse = "load_chat_response";
|
|
473
|
-
var ChatEventTypeMessage = "message";
|
|
474
|
-
var ChatEventTypeWaitingForAgent = "waiting_for_agent";
|
|
475
|
-
var ChatEventTypeMessageStatusUpdate = "message_status_update";
|
|
476
|
-
var ChatEventTypeHumanAgentJoined = "human_agent_joined";
|
|
477
|
-
var ChatEventTypeHumanAgentLeft = "human_agent_left";
|
|
478
|
-
var ChatEventTypeObserverJoined = "observer_joined";
|
|
479
|
-
var ChatEventTypeObserverLeft = "observer_left";
|
|
480
|
-
var ChatEventTypeListChats = "list_chats";
|
|
481
|
-
var ChatEventTypeChatUpdated = "chat_updated";
|
|
482
|
-
var ChatEventTypeChatRemoved = "chat_removed";
|
|
483
|
-
var ChatEventTypeSyncMetadata = "sync_metadata";
|
|
484
|
-
var ChatEventTypeSyncMetadataResponse = "sync_metadata_response";
|
|
485
|
-
var ChatEventTypeSyncUserSession = "sync_user_session";
|
|
486
|
-
var ChatEventTypeSyncUserSessionResponse = "sync_user_session_response";
|
|
487
|
-
var ChatEventTypeClientAction = "client_action";
|
|
488
|
-
var ChatEventTypeClientActionCallback = "client_action_callback";
|
|
489
|
-
var ChatEventTypeBlockUser = "block_user";
|
|
490
|
-
var ChatEventTypeCreateRoom = "create_room";
|
|
491
|
-
var ChatEventTypeRoomCreated = "room_created";
|
|
492
|
-
var ChatEventTypeJoinRoom = "join_room";
|
|
493
|
-
var ChatEventTypeLeaveRoom = "leave_room";
|
|
494
|
-
var ChatEventTypeDeleteRoom = "delete_room";
|
|
495
|
-
var ChatEventTypeRoomDeleted = "room_deleted";
|
|
496
|
-
var ChatEventTypeUpdateRoom = "update_room";
|
|
497
|
-
var ChatEventTypeRoomUpdated = "room_updated";
|
|
498
|
-
var ChatEventTypeInviteUser = "invite_user";
|
|
499
|
-
var ChatEventTypeUserInvited = "user_invited";
|
|
500
|
-
var ChatEventTypeRoomUserJoined = "room_user_joined";
|
|
501
|
-
var ChatEventTypeRoomUserLeft = "room_user_left";
|
|
502
|
-
var ChatEventTypeUserRemoved = "user_removed";
|
|
503
|
-
var ChatEventTypeListRooms = "list_rooms";
|
|
504
|
-
var ChatEventTypeRoomsResponse = "rooms_response";
|
|
505
|
-
var ChatEventTypeMessageEdited = "message_edited";
|
|
506
|
-
var ChatEventTypeMessageDeleted = "message_deleted";
|
|
507
|
-
var ChatEventTypeMessageReaction = "message_reaction";
|
|
508
|
-
var ChatEventTypeMessageReply = "message_reply";
|
|
509
|
-
var ChatEventTypeMentionUser = "mention_user";
|
|
510
|
-
var ChatEventTypeMessageEditedResponse = "message_edited_response";
|
|
511
|
-
var ChatEventTypeMessageDeletedResponse = "message_deleted_response";
|
|
512
|
-
var ChatEventTypeMessageReactionResponse = "message_reaction_response";
|
|
513
|
-
var ChatEventTypeUserPresenceStart = "user_presence_start";
|
|
514
|
-
var ChatEventTypeUserPresenceEnd = "user_presence_end";
|
|
515
|
-
var ChatEventTypeUserStatusChange = "user_status_change";
|
|
516
|
-
var ChatEventTypeUserActivity = "user_activity";
|
|
517
|
-
var ChatEventTypeUserPresenceChanged = "user_presence_changed";
|
|
518
|
-
var ChatEventTypeUserActivityUpdate = "user_activity_update";
|
|
519
|
-
var ChatEventTypeGetOnlineUsers = "get_online_users";
|
|
520
|
-
var ChatEventTypeOnlineUsersResponse = "online_users";
|
|
521
|
-
var ChatEventTypeEndChat = "end_chat";
|
|
522
|
-
var ChatEventTypeChatEnded = "chat_ended";
|
|
523
|
-
var ChatEventTypeAgentSessionStart = "agent_session_start";
|
|
524
|
-
var ChatEventTypeAgentSessionEnd = "agent_session_end";
|
|
525
|
-
var ChatEventTypeAgentStatusChange = "agent_status_change";
|
|
526
|
-
var ChatEventTypeAgentActivityPing = "agent_activity_ping";
|
|
527
|
-
var ChatEventTypeAgentChatAssigned = "agent_chat_assigned";
|
|
528
|
-
var ChatEventTypeAgentChatCompleted = "agent_chat_completed";
|
|
529
|
-
var ChatEventTypeGetAgents = "get_agents";
|
|
530
|
-
var ChatEventTypeGetAgentsResponse = "get_agents_response";
|
|
531
|
-
var ChatEventTypeCSATRequest = "csat_request";
|
|
532
|
-
var ChatEventTypeCSATSurvey = "show_csat_survey";
|
|
533
|
-
var ChatEventTypeCSATResponse = "csat_response";
|
|
534
|
-
var ChatEventTypeUserSuggestedActions = "user_suggested_actions";
|
|
535
|
-
var ChatEventTypeUserSuggestedActionSelected = "user_suggested_action_selected";
|
|
536
|
-
var ChatEventTypeSummaryUpdate = "summary_update";
|
|
537
|
-
var ChatEventTypeAgentContextUpdate = "agent_context_update";
|
|
538
|
-
var ChatEventTypeAgentExecutionStarted = "agent_execution_started";
|
|
539
|
-
var ChatEventTypeAgentExecutionEnded = "agent_execution_ended";
|
|
540
|
-
var ChatEventTypeLoadAgentContext = "load_agent_context";
|
|
541
|
-
var ChatEventTypeLoadAgentContextResponse = "load_agent_context_response";
|
|
542
|
-
var ChatEventTypePlanPendingApproval = "plan_pending_approval";
|
|
543
|
-
var ChatEventTypePlanApproved = "plan_approved";
|
|
544
|
-
var ChatEventTypePlanRejected = "plan_rejected";
|
|
545
|
-
var ChatEventTypePlanCompleted = "plan_completed";
|
|
546
|
-
var ChatEventTypeStepStarted = "step_started";
|
|
547
|
-
var ChatEventTypeStepCompleted = "step_completed";
|
|
548
|
-
var ChatEventTypeStepFailed = "step_failed";
|
|
549
|
-
var ChatEventTypeNewChat = "new_chat";
|
|
550
|
-
var ChatEventTypeNewChatCreated = "new_chat_created";
|
|
551
|
-
var ChatEventTypePing = "ping";
|
|
552
|
-
var ChatEventTypePong = "pong";
|
|
553
|
-
var MessageStatusSending = "sending";
|
|
554
|
-
var MessageStatusSent = "sent";
|
|
555
|
-
var MessageStatusDelivered = "delivered";
|
|
556
|
-
var MessageStatusRead = "read";
|
|
557
|
-
var MessageStatusFailed = "failed";
|
|
558
|
-
var AttachmentTypeDocument = "document";
|
|
559
|
-
var AttachmentTypeDocumentAnalysis = "document_analysis";
|
|
560
|
-
var AttachmentTypeImage = "image";
|
|
561
|
-
var AttachmentTypeAudio = "audio";
|
|
562
|
-
var AttachmentTypeVideo = "video";
|
|
563
|
-
var AttachmentTypeLocation = "location";
|
|
564
|
-
var AttachmentTypeReferences = "references";
|
|
565
|
-
var AttachmentTypeSubsections = "subsections";
|
|
566
|
-
var AttachmentTypeArticles = "articles";
|
|
567
|
-
var AttachmentTypeRecords = "records";
|
|
568
|
-
var AttachmentTypeActions = "actions";
|
|
569
|
-
var AttachmentTypeBullets = "bullets";
|
|
570
|
-
var AttachmentTypeSticker = "sticker";
|
|
571
|
-
var AttachmentTypeData = "data";
|
|
572
|
-
var AttachmentTypeKGNodes = "kgNodes";
|
|
573
|
-
var AttachmentTypeDocumentSources = "document_sources";
|
|
574
|
-
var ChatSessionStatusActive = "active";
|
|
575
|
-
var ChatSessionStatusIdle = "idle";
|
|
576
|
-
var ChatSessionStatusExpired = "expired";
|
|
577
|
-
var UserStatusOnline = "online";
|
|
578
|
-
var UserStatusAway = "away";
|
|
579
|
-
var UserStatusBusy = "busy";
|
|
580
|
-
var UserStatusOffline = "offline";
|
|
581
|
-
var QueueTypes = {
|
|
582
|
-
skill: { value: "skill", label: "Skill-based", description: "Route by agent expertise and skills" },
|
|
583
|
-
priority: { value: "priority", label: "Priority-based", description: "Route by customer tier and urgency level" },
|
|
584
|
-
department: { value: "department", label: "Department-based", description: "Route by business function alignment" },
|
|
585
|
-
complexity: { value: "complexity", label: "Complexity-based", description: "Route by issue difficulty assessment" }
|
|
586
|
-
};
|
|
587
|
-
var QueueTypeSkill = "skill";
|
|
588
|
-
var QueueTypePriority = "priority";
|
|
589
|
-
var QueueTypeDepartment = "department";
|
|
590
|
-
var QueueTypeComplexity = "complexity";
|
|
591
|
-
var GetWaitingForAgentChatCountSubject = "chat.get_waiting_for_agent_chat_count";
|
|
592
|
-
var GetActiveChatCountSubject = "chat.get_active_chat_count";
|
|
593
|
-
var GetWaitingForAgentChatsSubject = "chat.get_waiting_for_agent_chats";
|
|
594
|
-
var GetActiveChatsSubject = "chat.get_active_chats";
|
|
595
|
-
var GetUserChatsSubject = "chat.get_user_chats";
|
|
596
|
-
var GetChatSubject = "chat.get_chat";
|
|
597
|
-
var ChatArchiveSubjectPattern = "chat.archive.%s.server";
|
|
598
|
-
var StartAgentSessionSubject = "chat.agent_session.start";
|
|
599
|
-
var EndAgentSessionSubject = "chat.agent_session.end";
|
|
600
|
-
var UpdateAgentStatusSubject = "chat.agent_session.update_status";
|
|
601
|
-
var UpdateAgentLastActivitySubject = "chat.agent_session.update_last_activity";
|
|
602
|
-
var AssignChatToAgentSubject = "chat.agent_session.assign_chat";
|
|
603
|
-
var CompleteChatByAgentSubject = "chat.agent_session.complete_chat";
|
|
604
|
-
var GetAgentSessionSubject = "chat.agent_session.get";
|
|
605
|
-
var GetOnlineAgentsSubject = "chat.agent_session.get_online_agents";
|
|
606
|
-
var GetOnlineAgentCountSubject = "chat.agent_session.get_online_agent_count";
|
|
607
|
-
var CreateAgentQueueSubject = "chat.agent_queue.create";
|
|
608
|
-
var GetAgentQueuesSubject = "chat.agent_queue.get";
|
|
609
|
-
var UpdateAgentQueueSubject = "chat.agent_queue.update";
|
|
610
|
-
var DeleteAgentQueueSubject = "chat.agent_queue.delete";
|
|
611
|
-
var GetQueueChatsSubject = "chat.queue.get_chats";
|
|
612
|
-
var GetQueueChatCountSubject = "chat.queue.get_chat_count";
|
|
613
|
-
var GetDailyChatCountSubject = "chat.get_daily_chat_count";
|
|
614
|
-
var UpdateUserStatusSubject = "chat.user.status.update";
|
|
615
|
-
var GetOnlineUsersSubject = "chat.users.online.get";
|
|
616
|
-
var TriggerAnalyticsScanSubject = "chat.analytics.trigger-scan";
|
|
617
|
-
var SetupOrgSubject = "chat.org.setup";
|
|
618
|
-
|
|
619
|
-
// hooks/use-websocket-chat-base.ts
|
|
620
|
-
var import_react3 = require("react");
|
|
621
|
-
var createDefaultLogger = (debug) => ({
|
|
622
|
-
debug: debug ? console.log : () => {
|
|
623
|
-
},
|
|
624
|
-
info: console.info,
|
|
625
|
-
warn: console.warn,
|
|
626
|
-
error: console.error
|
|
627
|
-
});
|
|
628
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
629
|
-
maxRetries: 10,
|
|
630
|
-
intervals: [1e3, 2e3, 5e3],
|
|
631
|
-
backoffMultiplier: 1.5,
|
|
632
|
-
maxBackoffTime: 3e4
|
|
633
|
-
};
|
|
634
|
-
var DEFAULT_QUEUE_CONFIG = {
|
|
635
|
-
maxSize: 100,
|
|
636
|
-
dropStrategy: "oldest"
|
|
637
|
-
};
|
|
638
|
-
var DEFAULT_HEARTBEAT_INTERVAL = 3e4;
|
|
639
|
-
var DEFAULT_HEARTBEAT_TIMEOUT = 5e3;
|
|
640
|
-
function isChatEvent(data) {
|
|
641
|
-
return data && typeof data === "object" && (typeof data.type === "string" || data.message);
|
|
642
|
-
}
|
|
643
|
-
var useWebSocketChatBase = ({
|
|
644
|
-
serverBaseUrl,
|
|
645
|
-
orgId,
|
|
646
|
-
clientType,
|
|
647
|
-
product,
|
|
648
|
-
onMessage,
|
|
649
|
-
retryConfig = DEFAULT_RETRY_CONFIG,
|
|
650
|
-
queueConfig = DEFAULT_QUEUE_CONFIG,
|
|
651
|
-
debug = false,
|
|
652
|
-
logger = createDefaultLogger(debug),
|
|
653
|
-
heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL,
|
|
654
|
-
heartbeatTimeout = DEFAULT_HEARTBEAT_TIMEOUT
|
|
655
|
-
}) => {
|
|
656
|
-
const [connectionState, setConnectionState] = (0, import_react3.useState)("disconnected");
|
|
657
|
-
const [error, setError] = (0, import_react3.useState)(void 0);
|
|
658
|
-
const [startTime, setStartTime] = (0, import_react3.useState)(void 0);
|
|
659
|
-
const [metrics, setMetrics] = (0, import_react3.useState)({
|
|
660
|
-
latency: 0,
|
|
661
|
-
messagesSent: 0,
|
|
662
|
-
messagesReceived: 0,
|
|
663
|
-
messagesQueued: 0,
|
|
664
|
-
reconnectCount: 0
|
|
665
|
-
});
|
|
666
|
-
const wsRef = (0, import_react3.useRef)(void 0);
|
|
667
|
-
const reconnectTimeoutRef = (0, import_react3.useRef)(void 0);
|
|
668
|
-
const retryCountRef = (0, import_react3.useRef)(0);
|
|
669
|
-
const messageQueueRef = (0, import_react3.useRef)([]);
|
|
670
|
-
const mountedRef = (0, import_react3.useRef)(false);
|
|
671
|
-
const currentChatKeyRef = (0, import_react3.useRef)(void 0);
|
|
672
|
-
const currentUserIdRef = (0, import_react3.useRef)(void 0);
|
|
673
|
-
const intentionalDisconnectRef = (0, import_react3.useRef)(false);
|
|
674
|
-
const eventHandlersRef = (0, import_react3.useRef)(
|
|
675
|
-
/* @__PURE__ */ new Map()
|
|
676
|
-
);
|
|
677
|
-
const onMessageRef = (0, import_react3.useRef)(onMessage);
|
|
678
|
-
const pendingMessagesRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
679
|
-
const heartbeatIntervalRef = (0, import_react3.useRef)(void 0);
|
|
680
|
-
const heartbeatTimeoutRef = (0, import_react3.useRef)(void 0);
|
|
681
|
-
const lastPongRef = (0, import_react3.useRef)(Date.now());
|
|
682
|
-
const chatCreationPromiseRef = (0, import_react3.useRef)(null);
|
|
683
|
-
const loadChatRetryMapRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
684
|
-
(0, import_react3.useEffect)(() => {
|
|
685
|
-
onMessageRef.current = onMessage;
|
|
686
|
-
}, [onMessage]);
|
|
687
|
-
const isConnected = connectionState === "connected";
|
|
688
|
-
const on = (0, import_react3.useCallback)((eventType, handler) => {
|
|
689
|
-
if (!eventHandlersRef.current.has(eventType)) {
|
|
690
|
-
eventHandlersRef.current.set(eventType, /* @__PURE__ */ new Set());
|
|
691
|
-
}
|
|
692
|
-
eventHandlersRef.current.get(eventType).add(handler);
|
|
693
|
-
return () => off(eventType, handler);
|
|
694
|
-
}, []);
|
|
695
|
-
const off = (0, import_react3.useCallback)((eventType, handler) => {
|
|
696
|
-
const handlers = eventHandlersRef.current.get(eventType);
|
|
697
|
-
if (handlers) {
|
|
698
|
-
handlers.delete(handler);
|
|
699
|
-
if (handlers.size === 0) {
|
|
700
|
-
eventHandlersRef.current.delete(eventType);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}, []);
|
|
704
|
-
const emit = (0, import_react3.useCallback)(
|
|
705
|
-
(eventType, data) => {
|
|
706
|
-
const handlers = eventHandlersRef.current.get(eventType);
|
|
707
|
-
if (handlers) {
|
|
708
|
-
handlers.forEach((handler) => {
|
|
709
|
-
try {
|
|
710
|
-
handler(data);
|
|
711
|
-
} catch (error2) {
|
|
712
|
-
logger.error(`Error in event handler for ${eventType}:`, error2);
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
},
|
|
717
|
-
[logger]
|
|
718
|
-
);
|
|
719
|
-
const updateMetrics = (0, import_react3.useCallback)((updates) => {
|
|
720
|
-
setMetrics((prev) => ({ ...prev, ...updates }));
|
|
721
|
-
}, []);
|
|
722
|
-
const addToQueue = (0, import_react3.useCallback)(
|
|
723
|
-
(event) => {
|
|
724
|
-
const currentQueueSize = messageQueueRef.current.length;
|
|
725
|
-
const maxSize = queueConfig.maxSize || DEFAULT_QUEUE_CONFIG.maxSize;
|
|
726
|
-
if (currentQueueSize >= maxSize) {
|
|
727
|
-
if (queueConfig.dropStrategy === "newest") {
|
|
728
|
-
logger.warn("Message queue full, dropping new message");
|
|
729
|
-
return false;
|
|
730
|
-
} else {
|
|
731
|
-
const dropped = messageQueueRef.current.shift();
|
|
732
|
-
logger.warn("Message queue full, dropped oldest message", dropped);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
messageQueueRef.current.push(event);
|
|
736
|
-
updateMetrics({ messagesQueued: messageQueueRef.current.length });
|
|
737
|
-
return true;
|
|
738
|
-
},
|
|
739
|
-
[queueConfig, logger, updateMetrics]
|
|
740
|
-
);
|
|
741
|
-
const calculateRetryInterval = (0, import_react3.useCallback)(
|
|
742
|
-
(retryCount) => {
|
|
743
|
-
const config = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };
|
|
744
|
-
const {
|
|
745
|
-
intervals = [],
|
|
746
|
-
backoffMultiplier = 1.5,
|
|
747
|
-
maxBackoffTime = 3e4
|
|
748
|
-
} = config;
|
|
749
|
-
if (retryCount < intervals.length) {
|
|
750
|
-
return intervals[retryCount];
|
|
751
|
-
}
|
|
752
|
-
const baseInterval = intervals[intervals.length - 1] || 5e3;
|
|
753
|
-
const backoffTime = baseInterval * Math.pow(backoffMultiplier, retryCount - intervals.length + 1);
|
|
754
|
-
return Math.min(backoffTime, maxBackoffTime);
|
|
755
|
-
},
|
|
756
|
-
[retryConfig]
|
|
757
|
-
);
|
|
758
|
-
const startHeartbeat = (0, import_react3.useCallback)(() => {
|
|
759
|
-
if (!heartbeatInterval || heartbeatInterval <= 0) return;
|
|
760
|
-
const sendPing = () => {
|
|
761
|
-
if (wsRef.current?.readyState === WebSocket.OPEN) {
|
|
762
|
-
const pingTime = Date.now();
|
|
763
|
-
wsRef.current.send(
|
|
764
|
-
JSON.stringify({ type: "ping", timestamp: pingTime })
|
|
765
|
-
);
|
|
766
|
-
heartbeatTimeoutRef.current = setTimeout(() => {
|
|
767
|
-
logger.warn("Heartbeat timeout - no pong received");
|
|
768
|
-
if (wsRef.current) {
|
|
769
|
-
wsRef.current.close(4e3, "Heartbeat timeout");
|
|
770
|
-
}
|
|
771
|
-
}, heartbeatTimeout);
|
|
772
|
-
}
|
|
773
|
-
};
|
|
774
|
-
if (heartbeatIntervalRef.current) {
|
|
775
|
-
clearInterval(heartbeatIntervalRef.current);
|
|
776
|
-
}
|
|
777
|
-
heartbeatIntervalRef.current = setInterval(sendPing, heartbeatInterval);
|
|
778
|
-
logger.debug("Heartbeat started");
|
|
779
|
-
}, [heartbeatInterval, heartbeatTimeout, logger]);
|
|
780
|
-
const stopHeartbeat = (0, import_react3.useCallback)(() => {
|
|
781
|
-
if (heartbeatIntervalRef.current) {
|
|
782
|
-
clearInterval(heartbeatIntervalRef.current);
|
|
783
|
-
heartbeatIntervalRef.current = void 0;
|
|
784
|
-
}
|
|
785
|
-
if (heartbeatTimeoutRef.current) {
|
|
786
|
-
clearTimeout(heartbeatTimeoutRef.current);
|
|
787
|
-
heartbeatTimeoutRef.current = void 0;
|
|
788
|
-
}
|
|
789
|
-
logger.debug("Heartbeat stopped");
|
|
790
|
-
}, [logger]);
|
|
791
|
-
const cleanup = (0, import_react3.useCallback)(() => {
|
|
792
|
-
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
|
793
|
-
wsRef.current.close(1e3, "Cleanup");
|
|
794
|
-
}
|
|
795
|
-
wsRef.current = void 0;
|
|
796
|
-
if (reconnectTimeoutRef.current) {
|
|
797
|
-
clearTimeout(reconnectTimeoutRef.current);
|
|
798
|
-
reconnectTimeoutRef.current = void 0;
|
|
799
|
-
}
|
|
800
|
-
stopHeartbeat();
|
|
801
|
-
pendingMessagesRef.current.forEach(({ reject, timeout }) => {
|
|
802
|
-
clearTimeout(timeout);
|
|
803
|
-
reject(new Error("Connection closed"));
|
|
804
|
-
});
|
|
805
|
-
pendingMessagesRef.current.clear();
|
|
806
|
-
loadChatRetryMapRef.current.forEach((retryState) => {
|
|
807
|
-
if (retryState.timeoutId) {
|
|
808
|
-
clearTimeout(retryState.timeoutId);
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
loadChatRetryMapRef.current.clear();
|
|
812
|
-
}, [stopHeartbeat]);
|
|
813
|
-
const connect = (0, import_react3.useCallback)(
|
|
814
|
-
async (userId) => {
|
|
815
|
-
if (!mountedRef.current) {
|
|
816
|
-
mountedRef.current = true;
|
|
817
|
-
}
|
|
818
|
-
if (!orgId) {
|
|
819
|
-
const error2 = {
|
|
820
|
-
code: "CONNECTION_FAILED",
|
|
821
|
-
message: "Cannot connect: orgId is undefined",
|
|
822
|
-
retryable: false,
|
|
823
|
-
timestamp: Date.now()
|
|
824
|
-
};
|
|
825
|
-
logger.error("Cannot connect: orgId is undefined");
|
|
826
|
-
setError(error2);
|
|
827
|
-
return Promise.reject(error2);
|
|
828
|
-
}
|
|
829
|
-
if (wsRef.current?.readyState === WebSocket.OPEN) {
|
|
830
|
-
logger.debug("Already connected");
|
|
831
|
-
return Promise.resolve();
|
|
832
|
-
}
|
|
833
|
-
if (connectionState === "connecting" || connectionState === "reconnecting") {
|
|
834
|
-
logger.debug("Connection already in progress");
|
|
835
|
-
return Promise.resolve();
|
|
836
|
-
}
|
|
837
|
-
const maxRetries = retryConfig.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries;
|
|
838
|
-
if (retryCountRef.current >= maxRetries && !intentionalDisconnectRef.current) {
|
|
839
|
-
const error2 = {
|
|
840
|
-
code: "CONNECTION_FAILED",
|
|
841
|
-
message: `Max retries (${maxRetries}) exceeded`,
|
|
842
|
-
retryable: false,
|
|
843
|
-
timestamp: Date.now()
|
|
844
|
-
};
|
|
845
|
-
setError(error2);
|
|
846
|
-
updateMetrics({ lastError: error2 });
|
|
847
|
-
return Promise.reject(error2);
|
|
848
|
-
}
|
|
849
|
-
cleanup();
|
|
850
|
-
setConnectionState(
|
|
851
|
-
retryCountRef.current > 0 ? "reconnecting" : "connecting"
|
|
852
|
-
);
|
|
853
|
-
intentionalDisconnectRef.current = false;
|
|
854
|
-
return new Promise((resolve, reject) => {
|
|
855
|
-
try {
|
|
856
|
-
const wsUrl = `${serverBaseUrl}?orgId=${orgId}&userId=${userId}&clientType=${clientType}&product=${product}`;
|
|
857
|
-
const connectionStartTime = Date.now();
|
|
858
|
-
logger.debug("Connecting to WebSocket:", wsUrl);
|
|
859
|
-
console.log(`\u23F3 Initiating WebSocket connection to ${serverBaseUrl}...`);
|
|
860
|
-
const ws = new WebSocket(wsUrl);
|
|
861
|
-
ws.onopen = () => {
|
|
862
|
-
if (!mountedRef.current) {
|
|
863
|
-
ws.close(1e3, "Component unmounted");
|
|
864
|
-
reject(new Error("Component unmounted"));
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
const connectionTimeMs = Date.now() - connectionStartTime;
|
|
868
|
-
const connectionTimeSec = (connectionTimeMs / 1e3).toFixed(2);
|
|
869
|
-
logger.info("\u2705 WebSocket connected", {
|
|
870
|
-
userId,
|
|
871
|
-
retryCount: retryCountRef.current,
|
|
872
|
-
connectionTime: `${connectionTimeSec}s (${connectionTimeMs}ms)`
|
|
873
|
-
});
|
|
874
|
-
console.log(`\u{1F50C} WebSocket connection established in ${connectionTimeSec} seconds`);
|
|
875
|
-
setConnectionState("connected");
|
|
876
|
-
setError(void 0);
|
|
877
|
-
const wasReconnecting = retryCountRef.current > 0;
|
|
878
|
-
retryCountRef.current = 0;
|
|
879
|
-
updateMetrics({
|
|
880
|
-
connectedAt: Date.now(),
|
|
881
|
-
latency: connectionTimeMs,
|
|
882
|
-
reconnectCount: wasReconnecting ? metrics.reconnectCount + 1 : metrics.reconnectCount
|
|
883
|
-
});
|
|
884
|
-
while (messageQueueRef.current.length > 0 && ws.readyState === WebSocket.OPEN) {
|
|
885
|
-
const event = messageQueueRef.current.shift();
|
|
886
|
-
if (event) {
|
|
887
|
-
ws.send(JSON.stringify({ ...event, timestamp: Date.now() }));
|
|
888
|
-
updateMetrics({
|
|
889
|
-
messagesSent: metrics.messagesSent + 1,
|
|
890
|
-
messagesQueued: messageQueueRef.current.length
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
currentUserIdRef.current = userId;
|
|
895
|
-
if (currentChatKeyRef.current) {
|
|
896
|
-
if (!orgId) {
|
|
897
|
-
logger.error("Cannot resubscribe to chat: orgId is undefined");
|
|
898
|
-
} else {
|
|
899
|
-
logger.info(
|
|
900
|
-
"Resubscribing to chat after reconnection:",
|
|
901
|
-
currentChatKeyRef.current
|
|
902
|
-
);
|
|
903
|
-
const resubscribeEvent = {
|
|
904
|
-
type: "load_chat",
|
|
905
|
-
orgId,
|
|
906
|
-
chatKey: currentChatKeyRef.current,
|
|
907
|
-
userId,
|
|
908
|
-
timestamp: Date.now(),
|
|
909
|
-
data: {}
|
|
910
|
-
};
|
|
911
|
-
ws.send(JSON.stringify(resubscribeEvent));
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
startHeartbeat();
|
|
915
|
-
emit("connected", { userId, wasReconnecting });
|
|
916
|
-
resolve();
|
|
917
|
-
};
|
|
918
|
-
ws.onmessage = (event) => {
|
|
919
|
-
if (!mountedRef.current) return;
|
|
920
|
-
try {
|
|
921
|
-
const data = JSON.parse(event.data);
|
|
922
|
-
if (!isChatEvent(data)) {
|
|
923
|
-
logger.warn("Received invalid message format:", data);
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
926
|
-
const chatEvent = data;
|
|
927
|
-
logger.debug("Message received:", chatEvent.type);
|
|
928
|
-
updateMetrics({
|
|
929
|
-
messagesReceived: metrics.messagesReceived + 1,
|
|
930
|
-
lastMessageAt: Date.now()
|
|
931
|
-
});
|
|
932
|
-
if (chatEvent.type === "pong") {
|
|
933
|
-
if (heartbeatTimeoutRef.current) {
|
|
934
|
-
clearTimeout(heartbeatTimeoutRef.current);
|
|
935
|
-
heartbeatTimeoutRef.current = void 0;
|
|
936
|
-
}
|
|
937
|
-
const latency = Date.now() - (chatEvent.timestamp || Date.now());
|
|
938
|
-
lastPongRef.current = Date.now();
|
|
939
|
-
updateMetrics({ latency });
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
switch (chatEvent.type) {
|
|
943
|
-
case "new_chat_created":
|
|
944
|
-
const newChatKey = chatEvent.data?.chatKey;
|
|
945
|
-
if (newChatKey) {
|
|
946
|
-
logger.info("New chat created with key:", newChatKey);
|
|
947
|
-
currentChatKeyRef.current = newChatKey;
|
|
948
|
-
if (chatCreationPromiseRef.current) {
|
|
949
|
-
chatCreationPromiseRef.current.resolve(newChatKey);
|
|
950
|
-
chatCreationPromiseRef.current = null;
|
|
951
|
-
}
|
|
952
|
-
if (!orgId) {
|
|
953
|
-
logger.error("Cannot send load_chat: orgId is undefined");
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
const loadChatEvent = {
|
|
957
|
-
type: "load_chat",
|
|
958
|
-
orgId,
|
|
959
|
-
chatKey: newChatKey,
|
|
960
|
-
userId: currentUserIdRef.current || userId,
|
|
961
|
-
timestamp: Date.now(),
|
|
962
|
-
data: {}
|
|
963
|
-
};
|
|
964
|
-
ws.send(JSON.stringify(loadChatEvent));
|
|
965
|
-
}
|
|
966
|
-
break;
|
|
967
|
-
case "load_chat_response":
|
|
968
|
-
const chat = chatEvent.data?.chat;
|
|
969
|
-
if (chat && chat.key) {
|
|
970
|
-
logger.info("Chat loaded with key:", chat.key);
|
|
971
|
-
currentChatKeyRef.current = chat.key;
|
|
972
|
-
const retryState = loadChatRetryMapRef.current.get(chat.key);
|
|
973
|
-
if (retryState) {
|
|
974
|
-
if (retryState.timeoutId) {
|
|
975
|
-
clearTimeout(retryState.timeoutId);
|
|
976
|
-
}
|
|
977
|
-
loadChatRetryMapRef.current.delete(chat.key);
|
|
978
|
-
}
|
|
979
|
-
} else if (!chat) {
|
|
980
|
-
logger.warn("Chat load failed, clearing key");
|
|
981
|
-
currentChatKeyRef.current = void 0;
|
|
982
|
-
}
|
|
983
|
-
break;
|
|
984
|
-
case "chat_ended":
|
|
985
|
-
logger.info("Chat ended, clearing key");
|
|
986
|
-
currentChatKeyRef.current = void 0;
|
|
987
|
-
break;
|
|
988
|
-
case "error":
|
|
989
|
-
const errorMessage = chatEvent.data?.message || "Unknown error";
|
|
990
|
-
logger.error("Received error from server:", errorMessage);
|
|
991
|
-
if (errorMessage.includes("nats: key not found") || errorMessage.includes("Failed to load chat")) {
|
|
992
|
-
const chatKeyFromError = currentChatKeyRef.current;
|
|
993
|
-
if (chatKeyFromError) {
|
|
994
|
-
const maxRetries2 = 5;
|
|
995
|
-
let retryState = loadChatRetryMapRef.current.get(chatKeyFromError);
|
|
996
|
-
if (!retryState) {
|
|
997
|
-
retryState = { retryCount: 0, timeoutId: null };
|
|
998
|
-
loadChatRetryMapRef.current.set(chatKeyFromError, retryState);
|
|
999
|
-
}
|
|
1000
|
-
if (retryState.retryCount < maxRetries2) {
|
|
1001
|
-
const delay = 200 * Math.pow(2, retryState.retryCount);
|
|
1002
|
-
retryState.retryCount++;
|
|
1003
|
-
logger.info(
|
|
1004
|
-
`Chat load failed, retrying (${retryState.retryCount}/${maxRetries2}) in ${delay}ms...`,
|
|
1005
|
-
chatKeyFromError
|
|
1006
|
-
);
|
|
1007
|
-
retryState.timeoutId = setTimeout(() => {
|
|
1008
|
-
if (!wsRef.current || !mountedRef.current) return;
|
|
1009
|
-
if (!orgId) {
|
|
1010
|
-
logger.error("Cannot retry load_chat: orgId is undefined", chatKeyFromError);
|
|
1011
|
-
loadChatRetryMapRef.current.delete(chatKeyFromError);
|
|
1012
|
-
return;
|
|
1013
|
-
}
|
|
1014
|
-
logger.debug("Retrying load_chat:", chatKeyFromError);
|
|
1015
|
-
const retryLoadEvent = {
|
|
1016
|
-
type: "load_chat",
|
|
1017
|
-
orgId,
|
|
1018
|
-
chatKey: chatKeyFromError,
|
|
1019
|
-
userId: currentUserIdRef.current || "",
|
|
1020
|
-
timestamp: Date.now(),
|
|
1021
|
-
data: {}
|
|
1022
|
-
};
|
|
1023
|
-
ws.send(JSON.stringify(retryLoadEvent));
|
|
1024
|
-
}, delay);
|
|
1025
|
-
} else {
|
|
1026
|
-
logger.error("Max retries reached for loading chat:", chatKeyFromError);
|
|
1027
|
-
loadChatRetryMapRef.current.delete(chatKeyFromError);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
const wsError = {
|
|
1032
|
-
code: "NETWORK_ERROR",
|
|
1033
|
-
message: errorMessage,
|
|
1034
|
-
retryable: true,
|
|
1035
|
-
timestamp: Date.now()
|
|
1036
|
-
};
|
|
1037
|
-
setError(wsError);
|
|
1038
|
-
updateMetrics({ lastError: wsError });
|
|
1039
|
-
break;
|
|
1040
|
-
}
|
|
1041
|
-
emit(chatEvent.type || "message", chatEvent);
|
|
1042
|
-
if (onMessageRef.current) {
|
|
1043
|
-
onMessageRef.current(chatEvent);
|
|
1044
|
-
}
|
|
1045
|
-
} catch (error2) {
|
|
1046
|
-
logger.error("Failed to parse WebSocket message:", error2);
|
|
1047
|
-
const parseError = {
|
|
1048
|
-
code: "PARSE_ERROR",
|
|
1049
|
-
message: "Failed to parse message",
|
|
1050
|
-
retryable: false,
|
|
1051
|
-
timestamp: Date.now()
|
|
1052
|
-
};
|
|
1053
|
-
setError(parseError);
|
|
1054
|
-
updateMetrics({ lastError: parseError });
|
|
1055
|
-
}
|
|
1056
|
-
};
|
|
1057
|
-
ws.onclose = (event) => {
|
|
1058
|
-
if (!mountedRef.current) return;
|
|
1059
|
-
logger.info("WebSocket closed", {
|
|
1060
|
-
code: event.code,
|
|
1061
|
-
reason: event.reason
|
|
1062
|
-
});
|
|
1063
|
-
setConnectionState("disconnected");
|
|
1064
|
-
wsRef.current = void 0;
|
|
1065
|
-
stopHeartbeat();
|
|
1066
|
-
emit("disconnected", { code: event.code, reason: event.reason });
|
|
1067
|
-
if (event.code !== 1e3 && !intentionalDisconnectRef.current && mountedRef.current) {
|
|
1068
|
-
const retryInterval = calculateRetryInterval(
|
|
1069
|
-
retryCountRef.current
|
|
1070
|
-
);
|
|
1071
|
-
retryCountRef.current++;
|
|
1072
|
-
logger.info(
|
|
1073
|
-
`Reconnecting in ${retryInterval}ms (attempt ${retryCountRef.current})`
|
|
1074
|
-
);
|
|
1075
|
-
if (reconnectTimeoutRef.current) {
|
|
1076
|
-
clearTimeout(reconnectTimeoutRef.current);
|
|
1077
|
-
}
|
|
1078
|
-
reconnectTimeoutRef.current = setTimeout(() => {
|
|
1079
|
-
connect(userId);
|
|
1080
|
-
}, retryInterval);
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
ws.onerror = (error2) => {
|
|
1084
|
-
logger.error("WebSocket error:", error2);
|
|
1085
|
-
if (!mountedRef.current) return;
|
|
1086
|
-
const wsError = {
|
|
1087
|
-
code: "CONNECTION_FAILED",
|
|
1088
|
-
message: "WebSocket connection failed",
|
|
1089
|
-
retryable: true,
|
|
1090
|
-
timestamp: Date.now()
|
|
1091
|
-
};
|
|
1092
|
-
setError(wsError);
|
|
1093
|
-
updateMetrics({ lastError: wsError });
|
|
1094
|
-
reject(wsError);
|
|
1095
|
-
};
|
|
1096
|
-
wsRef.current = ws;
|
|
1097
|
-
} catch (error2) {
|
|
1098
|
-
logger.error("Failed to create WebSocket:", error2);
|
|
1099
|
-
const wsError = {
|
|
1100
|
-
code: "CONNECTION_FAILED",
|
|
1101
|
-
message: error2 instanceof Error ? error2.message : "Failed to create connection",
|
|
1102
|
-
retryable: true,
|
|
1103
|
-
timestamp: Date.now()
|
|
1104
|
-
};
|
|
1105
|
-
setError(wsError);
|
|
1106
|
-
updateMetrics({ lastError: wsError });
|
|
1107
|
-
reject(wsError);
|
|
1108
|
-
}
|
|
1109
|
-
});
|
|
1110
|
-
},
|
|
1111
|
-
[
|
|
1112
|
-
serverBaseUrl,
|
|
1113
|
-
orgId,
|
|
1114
|
-
clientType,
|
|
1115
|
-
product,
|
|
1116
|
-
connectionState,
|
|
1117
|
-
logger,
|
|
1118
|
-
retryConfig,
|
|
1119
|
-
metrics,
|
|
1120
|
-
updateMetrics,
|
|
1121
|
-
cleanup,
|
|
1122
|
-
calculateRetryInterval,
|
|
1123
|
-
startHeartbeat,
|
|
1124
|
-
emit
|
|
1125
|
-
]
|
|
1126
|
-
);
|
|
1127
|
-
const sendMessage = (0, import_react3.useCallback)(
|
|
1128
|
-
(event, overrideUserId) => {
|
|
1129
|
-
return new Promise((resolve, reject) => {
|
|
1130
|
-
if (!mountedRef.current) {
|
|
1131
|
-
reject(new Error("Component not mounted"));
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
const fullEvent = {
|
|
1135
|
-
...event,
|
|
1136
|
-
timestamp: Date.now()
|
|
1137
|
-
};
|
|
1138
|
-
const messageId = `${fullEvent.type}_${fullEvent.timestamp}_${Math.random()}`;
|
|
1139
|
-
logger.debug("Sending message:", fullEvent.type);
|
|
1140
|
-
if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
|
|
1141
|
-
if (addToQueue(fullEvent)) {
|
|
1142
|
-
logger.debug("Message queued, attempting to connect");
|
|
1143
|
-
if (connectionState === "disconnected" && overrideUserId) {
|
|
1144
|
-
connect(overrideUserId).then(() => resolve()).catch(reject);
|
|
1145
|
-
} else {
|
|
1146
|
-
resolve();
|
|
1147
|
-
}
|
|
1148
|
-
} else {
|
|
1149
|
-
reject(new Error("Message queue full"));
|
|
1150
|
-
}
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
try {
|
|
1154
|
-
wsRef.current.send(JSON.stringify(fullEvent));
|
|
1155
|
-
updateMetrics({ messagesSent: metrics.messagesSent + 1 });
|
|
1156
|
-
logger.debug("Message sent successfully");
|
|
1157
|
-
resolve();
|
|
1158
|
-
} catch (error2) {
|
|
1159
|
-
logger.error("Failed to send message:", error2);
|
|
1160
|
-
if (addToQueue(fullEvent)) {
|
|
1161
|
-
resolve();
|
|
1162
|
-
} else {
|
|
1163
|
-
const sendError = {
|
|
1164
|
-
code: "SEND_FAILED",
|
|
1165
|
-
message: error2 instanceof Error ? error2.message : "Failed to send message",
|
|
1166
|
-
retryable: true,
|
|
1167
|
-
timestamp: Date.now()
|
|
1168
|
-
};
|
|
1169
|
-
setError(sendError);
|
|
1170
|
-
updateMetrics({ lastError: sendError });
|
|
1171
|
-
reject(sendError);
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
});
|
|
1175
|
-
},
|
|
1176
|
-
[connectionState, connect, addToQueue, logger, metrics, updateMetrics]
|
|
1177
|
-
);
|
|
1178
|
-
const startNewChat = (0, import_react3.useCallback)(
|
|
1179
|
-
(userId, data) => {
|
|
1180
|
-
return new Promise((resolve, reject) => {
|
|
1181
|
-
if (!userId) {
|
|
1182
|
-
reject(new Error("User ID is required"));
|
|
1183
|
-
return;
|
|
1184
|
-
}
|
|
1185
|
-
logger.info("Requesting new chat from server with userId:", userId);
|
|
1186
|
-
setStartTime(/* @__PURE__ */ new Date());
|
|
1187
|
-
chatCreationPromiseRef.current = { resolve, reject };
|
|
1188
|
-
sendMessage(
|
|
1189
|
-
{
|
|
1190
|
-
type: "new_chat",
|
|
1191
|
-
orgId,
|
|
1192
|
-
chatKey: "",
|
|
1193
|
-
// Server will generate
|
|
1194
|
-
userId,
|
|
1195
|
-
data: data ?? {}
|
|
1196
|
-
},
|
|
1197
|
-
userId
|
|
1198
|
-
).catch((error2) => {
|
|
1199
|
-
chatCreationPromiseRef.current = null;
|
|
1200
|
-
reject(error2);
|
|
1201
|
-
});
|
|
1202
|
-
setTimeout(() => {
|
|
1203
|
-
if (chatCreationPromiseRef.current) {
|
|
1204
|
-
chatCreationPromiseRef.current = null;
|
|
1205
|
-
reject(new Error("Chat creation timed out"));
|
|
1206
|
-
}
|
|
1207
|
-
}, 3e4);
|
|
1208
|
-
});
|
|
1209
|
-
},
|
|
1210
|
-
[sendMessage, orgId, logger]
|
|
1211
|
-
);
|
|
1212
|
-
const disconnect = (0, import_react3.useCallback)(
|
|
1213
|
-
(intentional = true) => {
|
|
1214
|
-
logger.info("Disconnecting WebSocket", { intentional });
|
|
1215
|
-
intentionalDisconnectRef.current = intentional;
|
|
1216
|
-
cleanup();
|
|
1217
|
-
setConnectionState("disconnected");
|
|
1218
|
-
messageQueueRef.current = [];
|
|
1219
|
-
retryCountRef.current = 0;
|
|
1220
|
-
mountedRef.current = false;
|
|
1221
|
-
currentChatKeyRef.current = void 0;
|
|
1222
|
-
currentUserIdRef.current = void 0;
|
|
1223
|
-
},
|
|
1224
|
-
[cleanup, logger]
|
|
1225
|
-
);
|
|
1226
|
-
const clearError = (0, import_react3.useCallback)(() => {
|
|
1227
|
-
setError(void 0);
|
|
1228
|
-
}, []);
|
|
1229
|
-
(0, import_react3.useEffect)(() => {
|
|
1230
|
-
mountedRef.current = true;
|
|
1231
|
-
return () => {
|
|
1232
|
-
mountedRef.current = false;
|
|
1233
|
-
disconnect(true);
|
|
1234
|
-
};
|
|
1235
|
-
}, []);
|
|
1236
|
-
return {
|
|
1237
|
-
connectionState,
|
|
1238
|
-
isConnected,
|
|
1239
|
-
sendMessage,
|
|
1240
|
-
error,
|
|
1241
|
-
connect,
|
|
1242
|
-
startNewChat,
|
|
1243
|
-
startTime,
|
|
1244
|
-
disconnect,
|
|
1245
|
-
metrics,
|
|
1246
|
-
on,
|
|
1247
|
-
off,
|
|
1248
|
-
clearError
|
|
1249
|
-
};
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
|
-
// hooks/use-websocket-chat-admin.ts
|
|
1253
|
-
var useWebSocketChatAdmin = ({
|
|
1254
|
-
serverBaseUrl,
|
|
1255
|
-
orgId,
|
|
1256
|
-
product
|
|
1257
|
-
}) => {
|
|
1258
|
-
const [chats, setChats] = (0, import_react4.useState)(/* @__PURE__ */ new Map());
|
|
1259
|
-
const [selectedChat, setSelectedChat] = (0, import_react4.useState)(void 0);
|
|
1260
|
-
const handleMessage = (0, import_react4.useCallback)(
|
|
1261
|
-
(chatEvent) => {
|
|
1262
|
-
switch (chatEvent.type) {
|
|
1263
|
-
case "message":
|
|
1264
|
-
if (!selectedChat || !chatEvent.message) return;
|
|
1265
|
-
setChats((prev) => {
|
|
1266
|
-
const newMap = new Map(prev);
|
|
1267
|
-
newMap.set(selectedChat.key, {
|
|
1268
|
-
...selectedChat,
|
|
1269
|
-
messages: [...selectedChat.messages, chatEvent.message]
|
|
1270
|
-
});
|
|
1271
|
-
return newMap;
|
|
1272
|
-
});
|
|
1273
|
-
setSelectedChat((prev) => {
|
|
1274
|
-
if (!prev) return prev;
|
|
1275
|
-
return {
|
|
1276
|
-
...prev,
|
|
1277
|
-
messages: [...prev.messages, chatEvent.message]
|
|
1278
|
-
};
|
|
1279
|
-
});
|
|
1280
|
-
break;
|
|
1281
|
-
case "list_chats":
|
|
1282
|
-
const chatList = chatEvent.data?.chats;
|
|
1283
|
-
if (!chatList) return;
|
|
1284
|
-
setChats(new Map(chatList.map((chat) => [chat.key, chat])));
|
|
1285
|
-
break;
|
|
1286
|
-
case "chat_updated":
|
|
1287
|
-
const updatedChat = chatEvent.data?.chat?.value;
|
|
1288
|
-
if (updatedChat) {
|
|
1289
|
-
setChats((prev) => new Map(prev).set(updatedChat.key, updatedChat));
|
|
1290
|
-
}
|
|
1291
|
-
break;
|
|
1292
|
-
case "chat_removed":
|
|
1293
|
-
const chatKey = chatEvent.data?.chatKey?.value;
|
|
1294
|
-
if (chatKey) {
|
|
1295
|
-
setChats((prev) => {
|
|
1296
|
-
const newMap = new Map(prev);
|
|
1297
|
-
newMap.delete(chatKey);
|
|
1298
|
-
return newMap;
|
|
1299
|
-
});
|
|
1300
|
-
}
|
|
1301
|
-
break;
|
|
1302
|
-
case "load_chat":
|
|
1303
|
-
const history = chatEvent.data?.chat?.value;
|
|
1304
|
-
if (history) {
|
|
1305
|
-
setChats((prev) => {
|
|
1306
|
-
const existingChat = prev.get(history.key);
|
|
1307
|
-
if (!existingChat) return prev;
|
|
1308
|
-
return new Map(prev).set(history.key, {
|
|
1309
|
-
...existingChat,
|
|
1310
|
-
messages: history.messages
|
|
1311
|
-
});
|
|
1312
|
-
});
|
|
1313
|
-
}
|
|
1314
|
-
break;
|
|
1315
|
-
}
|
|
1316
|
-
},
|
|
1317
|
-
[selectedChat]
|
|
1318
|
-
);
|
|
1319
|
-
const base = useWebSocketChatBase({
|
|
1320
|
-
serverBaseUrl,
|
|
1321
|
-
orgId,
|
|
1322
|
-
clientType: "humanAgent",
|
|
1323
|
-
onMessage: handleMessage,
|
|
1324
|
-
product
|
|
1325
|
-
});
|
|
1326
|
-
const selectChat = (0, import_react4.useCallback)(
|
|
1327
|
-
(chatKey) => {
|
|
1328
|
-
const chat = chats.get(chatKey);
|
|
1329
|
-
if (!chat) {
|
|
1330
|
-
console.error("Unable to select chat", chatKey);
|
|
1331
|
-
return;
|
|
1332
|
-
}
|
|
1333
|
-
setSelectedChat(chat);
|
|
1334
|
-
},
|
|
1335
|
-
[chats, orgId, base.sendMessage]
|
|
1336
|
-
);
|
|
1337
|
-
const addUserToChat = (0, import_react4.useCallback)(
|
|
1338
|
-
(orgId2, chatKey, user) => {
|
|
1339
|
-
base.sendMessage({
|
|
1340
|
-
type: "human_agent_joined",
|
|
1341
|
-
orgId: orgId2,
|
|
1342
|
-
chatKey,
|
|
1343
|
-
userId: user.email,
|
|
1344
|
-
data: { user }
|
|
1345
|
-
});
|
|
1346
|
-
setChats((prev) => {
|
|
1347
|
-
const newMap = new Map(prev);
|
|
1348
|
-
const chat = newMap.get(chatKey);
|
|
1349
|
-
if (!chat) return prev;
|
|
1350
|
-
newMap.set(chatKey, {
|
|
1351
|
-
...chat,
|
|
1352
|
-
humanAgentEngaged: user.role === ChatRoleHumanAgent,
|
|
1353
|
-
users: [...chat?.users ?? [], user]
|
|
1354
|
-
});
|
|
1355
|
-
return newMap;
|
|
1356
|
-
});
|
|
1357
|
-
setSelectedChat((prev) => {
|
|
1358
|
-
if (!prev) return prev;
|
|
1359
|
-
return {
|
|
1360
|
-
...prev,
|
|
1361
|
-
humanAgentEngaged: user.role === ChatRoleHumanAgent,
|
|
1362
|
-
users: [...prev.users ?? [], user]
|
|
1363
|
-
};
|
|
1364
|
-
});
|
|
1365
|
-
},
|
|
1366
|
-
[base.sendMessage]
|
|
1367
|
-
);
|
|
1368
|
-
const removeUserFromChat = (0, import_react4.useCallback)(
|
|
1369
|
-
(orgId2, chatKey, userId) => {
|
|
1370
|
-
const chat = chats.get(chatKey);
|
|
1371
|
-
if (!chat) return;
|
|
1372
|
-
const user = chat.users?.find((u) => u.id === userId);
|
|
1373
|
-
if (!user) return;
|
|
1374
|
-
base.sendMessage({
|
|
1375
|
-
type: "human_agent_left",
|
|
1376
|
-
orgId: orgId2,
|
|
1377
|
-
chatKey,
|
|
1378
|
-
userId,
|
|
1379
|
-
data: { user }
|
|
1380
|
-
});
|
|
1381
|
-
setChats((prev) => {
|
|
1382
|
-
const newMap = new Map(prev);
|
|
1383
|
-
const chat2 = newMap.get(chatKey);
|
|
1384
|
-
if (!chat2) return prev;
|
|
1385
|
-
newMap.set(chatKey, {
|
|
1386
|
-
...chat2,
|
|
1387
|
-
humanAgentEngaged: false,
|
|
1388
|
-
users: chat2.users?.filter((u) => u.id !== userId)
|
|
1389
|
-
});
|
|
1390
|
-
return newMap;
|
|
1391
|
-
});
|
|
1392
|
-
},
|
|
1393
|
-
[chats, base.sendMessage]
|
|
1394
|
-
);
|
|
1395
|
-
const blockUser = (0, import_react4.useCallback)(
|
|
1396
|
-
(orgId2, chatKey, userId) => {
|
|
1397
|
-
base.sendMessage({
|
|
1398
|
-
type: "block_user",
|
|
1399
|
-
orgId: orgId2,
|
|
1400
|
-
chatKey,
|
|
1401
|
-
userId
|
|
1402
|
-
});
|
|
1403
|
-
},
|
|
1404
|
-
[base.sendMessage]
|
|
1405
|
-
);
|
|
1406
|
-
return {
|
|
1407
|
-
...base,
|
|
1408
|
-
chats,
|
|
1409
|
-
selectedChat,
|
|
1410
|
-
selectChat,
|
|
1411
|
-
addUserToChat,
|
|
1412
|
-
removeUserFromChat,
|
|
1413
|
-
blockUser
|
|
1414
|
-
};
|
|
1415
|
-
};
|
|
360
|
+
var UserCheck = createLucideIcon("UserCheck", __iconNode12);
|
|
361
|
+
|
|
362
|
+
// ../../node_modules/lucide-react/dist/esm/icons/user-cog.js
|
|
363
|
+
var __iconNode13 = [
|
|
364
|
+
["circle", { cx: "18", cy: "15", r: "3", key: "gjjjvw" }],
|
|
365
|
+
["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
|
|
366
|
+
["path", { d: "M10 15H6a4 4 0 0 0-4 4v2", key: "1nfge6" }],
|
|
367
|
+
["path", { d: "m21.7 16.4-.9-.3", key: "12j9ji" }],
|
|
368
|
+
["path", { d: "m15.2 13.9-.9-.3", key: "1fdjdi" }],
|
|
369
|
+
["path", { d: "m16.6 18.7.3-.9", key: "heedtr" }],
|
|
370
|
+
["path", { d: "m19.1 12.2.3-.9", key: "1af3ki" }],
|
|
371
|
+
["path", { d: "m19.6 18.7-.4-1", key: "1x9vze" }],
|
|
372
|
+
["path", { d: "m16.8 12.3-.4-1", key: "vqeiwj" }],
|
|
373
|
+
["path", { d: "m14.3 16.6 1-.4", key: "1qlj63" }],
|
|
374
|
+
["path", { d: "m20.7 13.8 1-.4", key: "1v5t8k" }]
|
|
375
|
+
];
|
|
376
|
+
var UserCog = createLucideIcon("UserCog", __iconNode13);
|
|
377
|
+
|
|
378
|
+
// ../../node_modules/lucide-react/dist/esm/icons/user.js
|
|
379
|
+
var __iconNode14 = [
|
|
380
|
+
["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
|
|
381
|
+
["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
|
|
382
|
+
];
|
|
383
|
+
var User = createLucideIcon("User", __iconNode14);
|
|
384
|
+
|
|
385
|
+
// components/admin/admin-chat-input.tsx
|
|
1416
386
|
|
|
1417
|
-
// hooks/use-websocket-chat-customer.ts
|
|
1418
|
-
var import_react5 = require("react");
|
|
1419
|
-
var useWebSocketChatCustomer = ({
|
|
1420
|
-
serverBaseUrl,
|
|
1421
|
-
orgId,
|
|
1422
|
-
chatKey,
|
|
1423
|
-
product
|
|
1424
|
-
}) => {
|
|
1425
|
-
const [currentChat, setCurrentChat] = (0, import_react5.useState)(void 0);
|
|
1426
|
-
const handleMessage = (0, import_react5.useCallback)((chatEvent) => {
|
|
1427
|
-
console.log("Received event:", chatEvent.type);
|
|
1428
|
-
switch (chatEvent.type) {
|
|
1429
|
-
case "message":
|
|
1430
|
-
if (!chatEvent.message) return;
|
|
1431
|
-
console.log(
|
|
1432
|
-
"got message:",
|
|
1433
|
-
chatEvent.message.role,
|
|
1434
|
-
":",
|
|
1435
|
-
chatEvent.message.content
|
|
1436
|
-
);
|
|
1437
|
-
setCurrentChat((prev) => {
|
|
1438
|
-
if (!prev) return prev;
|
|
1439
|
-
return {
|
|
1440
|
-
...prev,
|
|
1441
|
-
messages: [...prev.messages, chatEvent.message]
|
|
1442
|
-
};
|
|
1443
|
-
});
|
|
1444
|
-
break;
|
|
1445
|
-
case "chat_updated":
|
|
1446
|
-
const chat = chatEvent.data?.chat?.value;
|
|
1447
|
-
if (chat) {
|
|
1448
|
-
setCurrentChat(chat);
|
|
1449
|
-
}
|
|
1450
|
-
break;
|
|
1451
|
-
case "load_chat":
|
|
1452
|
-
const history = chatEvent.data?.chat;
|
|
1453
|
-
if (!history) return;
|
|
1454
|
-
setCurrentChat(history);
|
|
1455
|
-
break;
|
|
1456
|
-
default:
|
|
1457
|
-
break;
|
|
1458
|
-
}
|
|
1459
|
-
}, []);
|
|
1460
|
-
const base = useWebSocketChatBase({
|
|
1461
|
-
serverBaseUrl,
|
|
1462
|
-
orgId,
|
|
1463
|
-
clientType: "customer",
|
|
1464
|
-
onMessage: handleMessage,
|
|
1465
|
-
product
|
|
1466
|
-
});
|
|
1467
|
-
return {
|
|
1468
|
-
...base,
|
|
1469
|
-
chatKey,
|
|
1470
|
-
title: currentChat?.title,
|
|
1471
|
-
messages: currentChat?.messages ?? [],
|
|
1472
|
-
users: currentChat?.users ?? [],
|
|
1473
|
-
isWaiting: currentChat?.isWaiting ?? false,
|
|
1474
|
-
isWaitingForAgent: currentChat?.isWaitingForAgent ?? false,
|
|
1475
|
-
aiEngaged: currentChat?.aiEngaged ?? false,
|
|
1476
|
-
humanAgentEngaged: currentChat?.humanAgentEngaged ?? false,
|
|
1477
|
-
metadata: currentChat?.metadata ?? {},
|
|
1478
|
-
status: currentChat?.status
|
|
1479
|
-
};
|
|
1480
|
-
};
|
|
1481
387
|
|
|
1482
388
|
// context/websocket-chat-admin-context.tsx
|
|
1483
|
-
|
|
1484
|
-
var
|
|
389
|
+
|
|
390
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
391
|
+
var WebSocketChatAdminContext = _react.createContext.call(void 0, void 0);
|
|
1485
392
|
function WebSocketChatAdminProvider(props) {
|
|
1486
393
|
const { children, serverBaseUrl, orgId, userId, product } = props;
|
|
1487
|
-
const webSocket = useWebSocketChatAdmin({
|
|
394
|
+
const webSocket = _chunkE2FJX52Rjs.useWebSocketChatAdmin.call(void 0, {
|
|
1488
395
|
serverBaseUrl,
|
|
1489
396
|
orgId,
|
|
1490
397
|
product
|
|
1491
398
|
});
|
|
1492
|
-
return /* @__PURE__ */ (0,
|
|
399
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WebSocketChatAdminContext.Provider, { value: webSocket, children });
|
|
1493
400
|
}
|
|
1494
401
|
var useWebSocketChatAdminContext = () => {
|
|
1495
|
-
const context = (0,
|
|
402
|
+
const context = _react.useContext.call(void 0, WebSocketChatAdminContext);
|
|
1496
403
|
if (context === void 0) {
|
|
1497
404
|
throw new Error(
|
|
1498
405
|
"useWebSocketChatAdminContext must be used within a WebSocketChatAdminProvider"
|
|
@@ -1502,21 +409,21 @@ var useWebSocketChatAdminContext = () => {
|
|
|
1502
409
|
};
|
|
1503
410
|
|
|
1504
411
|
// components/admin/admin-chat-input.tsx
|
|
1505
|
-
|
|
412
|
+
|
|
1506
413
|
var AdminChatInput = ({
|
|
1507
414
|
onFileUpload,
|
|
1508
415
|
chatKey
|
|
1509
416
|
}) => {
|
|
1510
417
|
const { sendMessage } = useWebSocketChatAdminContext();
|
|
1511
|
-
const { user, selectedOrgId } = (0,
|
|
1512
|
-
const [input, setInput] = (0,
|
|
1513
|
-
const [isUploading, setIsUploading] = (0,
|
|
1514
|
-
const [isSending, setIsSending] = (0,
|
|
1515
|
-
const fileInputRef = (0,
|
|
418
|
+
const { user, selectedOrgId } = _auth.useUserContext.call(void 0, );
|
|
419
|
+
const [input, setInput] = _react.useState.call(void 0, "");
|
|
420
|
+
const [isUploading, setIsUploading] = _react.useState.call(void 0, false);
|
|
421
|
+
const [isSending, setIsSending] = _react.useState.call(void 0, false);
|
|
422
|
+
const fileInputRef = _react.useRef.call(void 0, null);
|
|
1516
423
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
1517
424
|
const handleSend = async () => {
|
|
1518
425
|
if (!input.trim() && !isUploading || isSending) return;
|
|
1519
|
-
if (!chatKey || !selectedOrgId || !user
|
|
426
|
+
if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _ => _.id])) {
|
|
1520
427
|
console.error("chatKey, orgId, or userId is not defined");
|
|
1521
428
|
return;
|
|
1522
429
|
}
|
|
@@ -1526,12 +433,12 @@ var AdminChatInput = ({
|
|
|
1526
433
|
type: "message",
|
|
1527
434
|
chatKey,
|
|
1528
435
|
orgId: selectedOrgId,
|
|
1529
|
-
userId: user
|
|
436
|
+
userId: _optionalChain([user, 'optionalAccess', _2 => _2.id]),
|
|
1530
437
|
message: {
|
|
1531
|
-
id:
|
|
438
|
+
id: _ksuid2.default.randomSync().string,
|
|
1532
439
|
content: input,
|
|
1533
440
|
role: "user",
|
|
1534
|
-
senderId: user
|
|
441
|
+
senderId: _optionalChain([user, 'optionalAccess', _3 => _3.id]),
|
|
1535
442
|
time: Date.now(),
|
|
1536
443
|
status: "sending",
|
|
1537
444
|
createdAt: Date.now()
|
|
@@ -1567,7 +474,7 @@ var AdminChatInput = ({
|
|
|
1567
474
|
url: file.url,
|
|
1568
475
|
title: file.name
|
|
1569
476
|
}));
|
|
1570
|
-
if (!chatKey || !selectedOrgId || !user
|
|
477
|
+
if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _4 => _4.id])) {
|
|
1571
478
|
console.error("chatKey, orgId, or userId is not defined");
|
|
1572
479
|
return;
|
|
1573
480
|
}
|
|
@@ -1578,9 +485,9 @@ var AdminChatInput = ({
|
|
|
1578
485
|
}
|
|
1579
486
|
}
|
|
1580
487
|
};
|
|
1581
|
-
return /* @__PURE__ */ (0,
|
|
1582
|
-
/* @__PURE__ */ (0,
|
|
1583
|
-
/* @__PURE__ */ (0,
|
|
488
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border-t bg-white rounded-b-lg", children: [
|
|
489
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
|
|
490
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1584
491
|
"input",
|
|
1585
492
|
{
|
|
1586
493
|
type: "file",
|
|
@@ -1591,17 +498,17 @@ var AdminChatInput = ({
|
|
|
1591
498
|
accept: "image/*,.pdf,.doc,.docx,.txt"
|
|
1592
499
|
}
|
|
1593
500
|
),
|
|
1594
|
-
/* @__PURE__ */ (0,
|
|
501
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1595
502
|
"button",
|
|
1596
503
|
{
|
|
1597
|
-
onClick: () => fileInputRef.current
|
|
504
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _5 => _5.current, 'optionalAccess', _6 => _6.click, 'call', _7 => _7()]),
|
|
1598
505
|
className: "p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100 transition-colors",
|
|
1599
506
|
disabled: isUploading,
|
|
1600
507
|
"aria-label": "Attach file",
|
|
1601
|
-
children: isUploading ? /* @__PURE__ */ (0,
|
|
508
|
+
children: isUploading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Paperclip, { className: "w-5 h-5" })
|
|
1602
509
|
}
|
|
1603
510
|
),
|
|
1604
|
-
/* @__PURE__ */ (0,
|
|
511
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 relative", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1605
512
|
"textarea",
|
|
1606
513
|
{
|
|
1607
514
|
value: input,
|
|
@@ -1621,40 +528,40 @@ var AdminChatInput = ({
|
|
|
1621
528
|
}
|
|
1622
529
|
}
|
|
1623
530
|
) }),
|
|
1624
|
-
/* @__PURE__ */ (0,
|
|
531
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1625
532
|
"button",
|
|
1626
533
|
{
|
|
1627
534
|
onClick: handleSend,
|
|
1628
535
|
disabled: !input.trim() && !isUploading || isSending,
|
|
1629
536
|
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"}`,
|
|
1630
537
|
"aria-label": "Send message",
|
|
1631
|
-
children: isSending ? /* @__PURE__ */ (0,
|
|
538
|
+
children: isSending ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Send, { className: "w-5 h-5" })
|
|
1632
539
|
}
|
|
1633
540
|
)
|
|
1634
541
|
] }),
|
|
1635
|
-
isUploading && /* @__PURE__ */ (0,
|
|
542
|
+
isUploading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full bg-gray-200 rounded-full h-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "bg-blue-500 h-1 rounded-full animate-pulse" }) }) })
|
|
1636
543
|
] });
|
|
1637
544
|
};
|
|
1638
545
|
|
|
1639
546
|
// components/admin/chat-human-agent-actions.tsx
|
|
1640
|
-
|
|
547
|
+
|
|
1641
548
|
|
|
1642
549
|
// context/websocket-chat-customer-context.tsx
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
var WebSocketChatCustomerContext = (0,
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
var WebSocketChatCustomerContext = _react.createContext.call(void 0, void 0);
|
|
1646
553
|
function WebSocketChatCustomerProvider(props) {
|
|
1647
554
|
const { children, serverBaseUrl, orgId, userId, chatKey, product } = props;
|
|
1648
|
-
const webSocket = useWebSocketChatCustomer({
|
|
555
|
+
const webSocket = _chunk3PXNBY7Jjs.useWebSocketChatCustomer.call(void 0, {
|
|
1649
556
|
serverBaseUrl,
|
|
1650
557
|
orgId,
|
|
1651
558
|
chatKey,
|
|
1652
559
|
product
|
|
1653
560
|
});
|
|
1654
|
-
return /* @__PURE__ */ (0,
|
|
561
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WebSocketChatCustomerContext.Provider, { value: webSocket, children });
|
|
1655
562
|
}
|
|
1656
563
|
var useWebSocketChatCustomerContext = () => {
|
|
1657
|
-
const context = (0,
|
|
564
|
+
const context = _react.useContext.call(void 0, WebSocketChatCustomerContext);
|
|
1658
565
|
if (context === void 0) {
|
|
1659
566
|
throw new Error(
|
|
1660
567
|
"useWebSocketChatCustomerContext must be used within a WebSocketChatCustomerProvider"
|
|
@@ -1664,9 +571,9 @@ var useWebSocketChatCustomerContext = () => {
|
|
|
1664
571
|
};
|
|
1665
572
|
|
|
1666
573
|
// components/admin/chat-human-agent-actions.tsx
|
|
1667
|
-
|
|
574
|
+
|
|
1668
575
|
var ChatHumanAgentActions = ({}) => {
|
|
1669
|
-
const { user, selectedOrgId } = (0,
|
|
576
|
+
const { user, selectedOrgId } = _auth.useUserContext.call(void 0, );
|
|
1670
577
|
const { selectedChat, addUserToChat, removeUserFromChat, blockUser } = useWebSocketChatAdminContext();
|
|
1671
578
|
const handleJoinChat = () => {
|
|
1672
579
|
if (!selectedChat || !user || !selectedOrgId) return;
|
|
@@ -1697,78 +604,78 @@ var ChatHumanAgentActions = ({}) => {
|
|
|
1697
604
|
blockUser(selectedOrgId, selectedChat.key, user.id);
|
|
1698
605
|
};
|
|
1699
606
|
if (!selectedChat) return null;
|
|
1700
|
-
return /* @__PURE__ */ (0,
|
|
1701
|
-
/* @__PURE__ */ (0,
|
|
1702
|
-
/* @__PURE__ */ (0,
|
|
1703
|
-
selectedChat.humanAgentEngaged && /* @__PURE__ */ (0,
|
|
1704
|
-
/* @__PURE__ */ (0,
|
|
607
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border-b bg-white flex items-center justify-between", children: [
|
|
608
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-4", children: [
|
|
609
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "font-semibold text-lg", children: selectedChat.title || `Chat ${selectedChat.key}` }),
|
|
610
|
+
selectedChat.humanAgentEngaged && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "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: [
|
|
611
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, User, { className: "mr-1 h-4 w-4" }),
|
|
1705
612
|
"Agent Engaged"
|
|
1706
613
|
] })
|
|
1707
614
|
] }),
|
|
1708
|
-
/* @__PURE__ */ (0,
|
|
1709
|
-
!selectedChat.humanAgentEngaged ? /* @__PURE__ */ (0,
|
|
615
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
|
|
616
|
+
!selectedChat.humanAgentEngaged ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1710
617
|
"button",
|
|
1711
618
|
{
|
|
1712
619
|
onClick: handleJoinChat,
|
|
1713
620
|
className: "bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1714
621
|
children: [
|
|
1715
|
-
/* @__PURE__ */ (0,
|
|
1716
|
-
/* @__PURE__ */ (0,
|
|
622
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, User, { className: "h-4 w-4" }),
|
|
623
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Join Chat" })
|
|
1717
624
|
]
|
|
1718
625
|
}
|
|
1719
|
-
) : /* @__PURE__ */ (0,
|
|
626
|
+
) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1720
627
|
"button",
|
|
1721
628
|
{
|
|
1722
629
|
onClick: handleLeaveChat,
|
|
1723
630
|
className: "bg-orange-500 hover:bg-orange-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1724
631
|
children: [
|
|
1725
|
-
/* @__PURE__ */ (0,
|
|
1726
|
-
/* @__PURE__ */ (0,
|
|
632
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, LogOut, { className: "h-4 w-4" }),
|
|
633
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Leave Chat" })
|
|
1727
634
|
]
|
|
1728
635
|
}
|
|
1729
636
|
),
|
|
1730
|
-
/* @__PURE__ */ (0,
|
|
637
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1731
638
|
"button",
|
|
1732
639
|
{
|
|
1733
640
|
onClick: handleEndChat,
|
|
1734
641
|
className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1735
642
|
children: [
|
|
1736
|
-
/* @__PURE__ */ (0,
|
|
1737
|
-
/* @__PURE__ */ (0,
|
|
643
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleX, { className: "h-4 w-4" }),
|
|
644
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "End Chat" })
|
|
1738
645
|
]
|
|
1739
646
|
}
|
|
1740
647
|
),
|
|
1741
|
-
/* @__PURE__ */ (0,
|
|
648
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1742
649
|
"button",
|
|
1743
650
|
{
|
|
1744
651
|
onClick: handleBlockUser,
|
|
1745
652
|
className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1746
653
|
children: [
|
|
1747
|
-
/* @__PURE__ */ (0,
|
|
1748
|
-
/* @__PURE__ */ (0,
|
|
654
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleX, { className: "h-4 w-4" }),
|
|
655
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Block User" })
|
|
1749
656
|
]
|
|
1750
657
|
}
|
|
1751
658
|
),
|
|
1752
|
-
/* @__PURE__ */ (0,
|
|
659
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1753
660
|
"button",
|
|
1754
661
|
{
|
|
1755
662
|
onClick: handleStartCall,
|
|
1756
663
|
disabled: !selectedChat.humanAgentEngaged,
|
|
1757
664
|
className: "bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1758
665
|
children: [
|
|
1759
|
-
/* @__PURE__ */ (0,
|
|
1760
|
-
/* @__PURE__ */ (0,
|
|
666
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Phone, { className: "h-4 w-4" }),
|
|
667
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Start Call" })
|
|
1761
668
|
]
|
|
1762
669
|
}
|
|
1763
670
|
),
|
|
1764
|
-
/* @__PURE__ */ (0,
|
|
671
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1765
672
|
"button",
|
|
1766
673
|
{
|
|
1767
674
|
onClick: handleCreateCase,
|
|
1768
675
|
className: "bg-purple-500 hover:bg-purple-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
|
|
1769
676
|
children: [
|
|
1770
|
-
/* @__PURE__ */ (0,
|
|
1771
|
-
/* @__PURE__ */ (0,
|
|
677
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Plus, { className: "h-4 w-4" }),
|
|
678
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Create Case" })
|
|
1772
679
|
]
|
|
1773
680
|
}
|
|
1774
681
|
)
|
|
@@ -1777,20 +684,20 @@ var ChatHumanAgentActions = ({}) => {
|
|
|
1777
684
|
};
|
|
1778
685
|
|
|
1779
686
|
// components/admin/admin-chat-list.tsx
|
|
1780
|
-
var
|
|
1781
|
-
|
|
687
|
+
var _react3 = require('@elqnt/react');
|
|
688
|
+
|
|
1782
689
|
var AdminChatList = ({ className }) => {
|
|
1783
690
|
const { chats, selectedChat, selectChat } = useWebSocketChatAdminContext();
|
|
1784
691
|
const sortedChats = Array.from(chats.values()).sort(
|
|
1785
692
|
(a, b) => b.lastUpdated - a.lastUpdated
|
|
1786
693
|
);
|
|
1787
|
-
return /* @__PURE__ */ (0,
|
|
1788
|
-
/* @__PURE__ */ (0,
|
|
1789
|
-
/* @__PURE__ */ (0,
|
|
694
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
695
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border-b", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "font-semibold text-lg", children: "Active Chats" }) }),
|
|
696
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 overflow-y-auto", children: sortedChats.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 text-center text-gray-500", children: "No active chats" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "divide-y", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.ScrollArea, { className: "h-[calc(100vh-15rem)]", children: sortedChats.map((chat, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1790
697
|
AdminChatListItem,
|
|
1791
698
|
{
|
|
1792
699
|
chat,
|
|
1793
|
-
isSelected: chat.key === selectedChat
|
|
700
|
+
isSelected: chat.key === _optionalChain([selectedChat, 'optionalAccess', _8 => _8.key]),
|
|
1794
701
|
onSelect: () => selectChat(chat.key)
|
|
1795
702
|
},
|
|
1796
703
|
index
|
|
@@ -1803,31 +710,31 @@ var AdminChatListItem = ({
|
|
|
1803
710
|
onSelect
|
|
1804
711
|
}) => {
|
|
1805
712
|
const lastMessage = chat.messages[chat.messages.length - 1];
|
|
1806
|
-
return /* @__PURE__ */ (0,
|
|
713
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1807
714
|
"button",
|
|
1808
715
|
{
|
|
1809
716
|
onClick: onSelect,
|
|
1810
717
|
className: `w-full p-4 text-left hover:bg-gray-50 focus:outline-none focus:bg-gray-50 ${isSelected ? "bg-blue-50" : ""}`,
|
|
1811
|
-
children: /* @__PURE__ */ (0,
|
|
1812
|
-
/* @__PURE__ */ (0,
|
|
1813
|
-
chat.aiEngaged && /* @__PURE__ */ (0,
|
|
1814
|
-
chat.isWaitingForAgent && /* @__PURE__ */ (0,
|
|
1815
|
-
chat.humanAgentEngaged && /* @__PURE__ */ (0,
|
|
718
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-start space-x-3", children: [
|
|
719
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "shrink-0", children: [
|
|
720
|
+
chat.aiEngaged && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Bot, { className: "w-6 h-6 text-blue-500" }),
|
|
721
|
+
chat.isWaitingForAgent && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoaderCircle, { className: "w-6 h-6 text-blue-500 animate-spin text-orange-500" }),
|
|
722
|
+
chat.humanAgentEngaged && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserCheck, { className: "w-6 h-6 text-blue-500 text-green-500" })
|
|
1816
723
|
] }),
|
|
1817
|
-
/* @__PURE__ */ (0,
|
|
1818
|
-
/* @__PURE__ */ (0,
|
|
1819
|
-
lastMessage && /* @__PURE__ */ (0,
|
|
1820
|
-
/* @__PURE__ */ (0,
|
|
1821
|
-
chat.isWaiting && /* @__PURE__ */ (0,
|
|
1822
|
-
/* @__PURE__ */ (0,
|
|
724
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1 min-w-0", children: [
|
|
725
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-between", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-medium text-gray-900 truncate", children: chat.title || `Chat ${chat.key}` }) }),
|
|
726
|
+
lastMessage && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mt-1 text-sm text-gray-500 truncate", children: lastMessage.content }),
|
|
727
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1 flex items-center space-x-2", children: [
|
|
728
|
+
chat.isWaiting && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center rounded-full bg-yellow-100 px-2 py-0.5 text-xs font-medium text-yellow-800", children: [
|
|
729
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleAlert, { className: "mr-1 h-3 w-3" }),
|
|
1823
730
|
"Waiting"
|
|
1824
731
|
] }),
|
|
1825
|
-
chat.humanAgentEngaged && /* @__PURE__ */ (0,
|
|
732
|
+
chat.humanAgentEngaged && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800", children: [
|
|
1826
733
|
"Agent Engaged:",
|
|
1827
734
|
" ",
|
|
1828
|
-
chat.users
|
|
735
|
+
_optionalChain([chat, 'access', _9 => _9.users, 'optionalAccess', _10 => _10.find, 'call', _11 => _11((u) => u.role === _chunkE2FJX52Rjs.ChatRoleHumanAgent), 'optionalAccess', _12 => _12.name])
|
|
1829
736
|
] }),
|
|
1830
|
-
chat.isWaitingForAgent && /* @__PURE__ */ (0,
|
|
737
|
+
chat.isWaitingForAgent && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "inline-flex items-center rounded-full bg-orange-100 px-2 py-0.5 text-xs font-medium text-orange-800", children: "Waiting For Agent" })
|
|
1831
738
|
] })
|
|
1832
739
|
] })
|
|
1833
740
|
] })
|
|
@@ -1836,27 +743,27 @@ var AdminChatListItem = ({
|
|
|
1836
743
|
};
|
|
1837
744
|
|
|
1838
745
|
// components/admin/admin-chat-header.tsx
|
|
1839
|
-
|
|
746
|
+
|
|
1840
747
|
var AdminChatHeader = ({
|
|
1841
748
|
className
|
|
1842
749
|
}) => {
|
|
1843
750
|
const { isConnected, chats } = useWebSocketChatAdminContext();
|
|
1844
|
-
return /* @__PURE__ */ (0,
|
|
1845
|
-
/* @__PURE__ */ (0,
|
|
751
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border-b", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
|
|
752
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1846
753
|
"div",
|
|
1847
754
|
{
|
|
1848
755
|
className: `w-2 h-2 rounded-full ${isConnected ? "bg-green-500" : "bg-red-500"}`
|
|
1849
756
|
}
|
|
1850
757
|
),
|
|
1851
|
-
/* @__PURE__ */ (0,
|
|
758
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-sm text-gray-600", children: [
|
|
1852
759
|
"Active Chats: ",
|
|
1853
|
-
/* @__PURE__ */ (0,
|
|
760
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-bold", children: chats.size })
|
|
1854
761
|
] }),
|
|
1855
|
-
/* @__PURE__ */ (0,
|
|
1856
|
-
/* @__PURE__ */ (0,
|
|
762
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-gray-500", children: "|" }),
|
|
763
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-sm text-gray-600", children: [
|
|
1857
764
|
"Waiting For Agent:",
|
|
1858
765
|
" ",
|
|
1859
|
-
/* @__PURE__ */ (0,
|
|
766
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-bold", children: Array.from(chats.values()).filter(
|
|
1860
767
|
(chat) => chat.isWaitingForAgent
|
|
1861
768
|
).length })
|
|
1862
769
|
] })
|
|
@@ -1864,10 +771,10 @@ var AdminChatHeader = ({
|
|
|
1864
771
|
};
|
|
1865
772
|
|
|
1866
773
|
// components/customer/chat-status-customer-ui.tsx
|
|
1867
|
-
|
|
774
|
+
|
|
1868
775
|
var ChatStatusCustomerUI = ({ isConnected }) => {
|
|
1869
|
-
return /* @__PURE__ */ (0,
|
|
1870
|
-
/* @__PURE__ */ (0,
|
|
776
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
|
|
777
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1871
778
|
"span",
|
|
1872
779
|
{
|
|
1873
780
|
className: `w-3 h-3 rounded-full ${isConnected ? "bg-green-500" : "bg-red-500"}`,
|
|
@@ -1875,36 +782,36 @@ var ChatStatusCustomerUI = ({ isConnected }) => {
|
|
|
1875
782
|
"aria-label": isConnected ? "Connected" : "Disconnected"
|
|
1876
783
|
}
|
|
1877
784
|
),
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
785
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-gray-500", children: isConnected ? "Connected" : "Reconnecting..." })
|
|
1879
786
|
] });
|
|
1880
787
|
};
|
|
1881
788
|
|
|
1882
789
|
// components/customer/chat-header.tsx
|
|
1883
|
-
|
|
790
|
+
|
|
1884
791
|
var ChatHeader = () => {
|
|
1885
792
|
const { isConnected, title } = useWebSocketChatCustomerContext();
|
|
1886
|
-
return /* @__PURE__ */ (0,
|
|
1887
|
-
/* @__PURE__ */ (0,
|
|
1888
|
-
/* @__PURE__ */ (0,
|
|
793
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border-b bg-white rounded-t-lg", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
|
|
794
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "font-bold text-lg", children: title || "Chat" }),
|
|
795
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatStatusCustomerUI, { isConnected })
|
|
1889
796
|
] }) });
|
|
1890
797
|
};
|
|
1891
798
|
|
|
1892
799
|
// components/customer/chat-input.tsx
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
1897
804
|
var ChatInput = ({ onFileUpload }) => {
|
|
1898
805
|
const { sendMessage, chatKey } = useWebSocketChatCustomerContext();
|
|
1899
|
-
const { user, selectedOrgId } = (0,
|
|
1900
|
-
const [input, setInput] = (0,
|
|
1901
|
-
const [isUploading, setIsUploading] = (0,
|
|
1902
|
-
const [isSending, setIsSending] = (0,
|
|
1903
|
-
const fileInputRef = (0,
|
|
806
|
+
const { user, selectedOrgId } = _auth.useUserContext.call(void 0, );
|
|
807
|
+
const [input, setInput] = _react.useState.call(void 0, "");
|
|
808
|
+
const [isUploading, setIsUploading] = _react.useState.call(void 0, false);
|
|
809
|
+
const [isSending, setIsSending] = _react.useState.call(void 0, false);
|
|
810
|
+
const fileInputRef = _react.useRef.call(void 0, null);
|
|
1904
811
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
1905
812
|
const handleSend = async () => {
|
|
1906
813
|
if (!input.trim() && !isUploading || isSending) return;
|
|
1907
|
-
if (!chatKey || !selectedOrgId || !user
|
|
814
|
+
if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _13 => _13.id])) {
|
|
1908
815
|
console.error("chatKey, orgId, or userId is not defined");
|
|
1909
816
|
return;
|
|
1910
817
|
}
|
|
@@ -1914,12 +821,12 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
1914
821
|
type: "message",
|
|
1915
822
|
chatKey,
|
|
1916
823
|
orgId: selectedOrgId,
|
|
1917
|
-
userId: user
|
|
824
|
+
userId: _optionalChain([user, 'optionalAccess', _14 => _14.id]),
|
|
1918
825
|
message: {
|
|
1919
|
-
id:
|
|
826
|
+
id: _ksuid2.default.randomSync().string,
|
|
1920
827
|
content: input,
|
|
1921
828
|
role: "user",
|
|
1922
|
-
senderId: user
|
|
829
|
+
senderId: _optionalChain([user, 'optionalAccess', _15 => _15.id]),
|
|
1923
830
|
time: Date.now(),
|
|
1924
831
|
status: "sending",
|
|
1925
832
|
createdAt: Date.now()
|
|
@@ -1955,7 +862,7 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
1955
862
|
url: file.url,
|
|
1956
863
|
title: file.name
|
|
1957
864
|
}));
|
|
1958
|
-
if (!chatKey || !selectedOrgId || !user
|
|
865
|
+
if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _16 => _16.id])) {
|
|
1959
866
|
console.error("chatKey, orgId, or userId is not defined");
|
|
1960
867
|
return;
|
|
1961
868
|
}
|
|
@@ -1966,9 +873,9 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
1966
873
|
}
|
|
1967
874
|
}
|
|
1968
875
|
};
|
|
1969
|
-
return /* @__PURE__ */ (0,
|
|
1970
|
-
/* @__PURE__ */ (0,
|
|
1971
|
-
/* @__PURE__ */ (0,
|
|
876
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border-t bg-white rounded-b-lg", children: [
|
|
877
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
|
|
878
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1972
879
|
"input",
|
|
1973
880
|
{
|
|
1974
881
|
type: "file",
|
|
@@ -1979,17 +886,17 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
1979
886
|
accept: "image/*,.pdf,.doc,.docx,.txt"
|
|
1980
887
|
}
|
|
1981
888
|
),
|
|
1982
|
-
/* @__PURE__ */ (0,
|
|
889
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1983
890
|
"button",
|
|
1984
891
|
{
|
|
1985
|
-
onClick: () => fileInputRef.current
|
|
892
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.click, 'call', _19 => _19()]),
|
|
1986
893
|
className: "p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100 transition-colors",
|
|
1987
894
|
disabled: isUploading,
|
|
1988
895
|
"aria-label": "Attach file",
|
|
1989
|
-
children: isUploading ? /* @__PURE__ */ (0,
|
|
896
|
+
children: isUploading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Paperclip, { className: "w-5 h-5" })
|
|
1990
897
|
}
|
|
1991
898
|
),
|
|
1992
|
-
/* @__PURE__ */ (0,
|
|
899
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 relative", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1993
900
|
"textarea",
|
|
1994
901
|
{
|
|
1995
902
|
value: input,
|
|
@@ -2009,23 +916,23 @@ var ChatInput = ({ onFileUpload }) => {
|
|
|
2009
916
|
}
|
|
2010
917
|
}
|
|
2011
918
|
) }),
|
|
2012
|
-
/* @__PURE__ */ (0,
|
|
919
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2013
920
|
"button",
|
|
2014
921
|
{
|
|
2015
922
|
onClick: handleSend,
|
|
2016
923
|
disabled: !input.trim() && !isUploading || isSending,
|
|
2017
924
|
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"}`,
|
|
2018
925
|
"aria-label": "Send message",
|
|
2019
|
-
children: isSending ? /* @__PURE__ */ (0,
|
|
926
|
+
children: isSending ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Send, { className: "w-5 h-5" })
|
|
2020
927
|
}
|
|
2021
928
|
)
|
|
2022
929
|
] }),
|
|
2023
|
-
isUploading && /* @__PURE__ */ (0,
|
|
930
|
+
isUploading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full bg-gray-200 rounded-full h-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "bg-blue-500 h-1 rounded-full animate-pulse" }) }) })
|
|
2024
931
|
] });
|
|
2025
932
|
};
|
|
2026
933
|
|
|
2027
934
|
// components/customer/chat-messages.tsx
|
|
2028
|
-
|
|
935
|
+
|
|
2029
936
|
|
|
2030
937
|
// ../../node_modules/date-fns/constants.js
|
|
2031
938
|
var daysInYear = 365.2425;
|
|
@@ -2064,8 +971,8 @@ function getDefaultOptions() {
|
|
|
2064
971
|
// ../../node_modules/date-fns/startOfWeek.js
|
|
2065
972
|
function startOfWeek(date, options) {
|
|
2066
973
|
const defaultOptions2 = getDefaultOptions();
|
|
2067
|
-
const weekStartsOn = options
|
|
2068
|
-
const _date = toDate(date, options
|
|
974
|
+
const weekStartsOn = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.weekStartsOn]), () => ( _optionalChain([options, 'optionalAccess', _21 => _21.locale, 'optionalAccess', _22 => _22.options, 'optionalAccess', _23 => _23.weekStartsOn]))), () => ( defaultOptions2.weekStartsOn)), () => ( _optionalChain([defaultOptions2, 'access', _24 => _24.locale, 'optionalAccess', _25 => _25.options, 'optionalAccess', _26 => _26.weekStartsOn]))), () => ( 0));
|
|
975
|
+
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _27 => _27.in]));
|
|
2069
976
|
const day = _date.getDay();
|
|
2070
977
|
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
2071
978
|
_date.setDate(_date.getDate() - diff);
|
|
@@ -2080,7 +987,7 @@ function startOfISOWeek(date, options) {
|
|
|
2080
987
|
|
|
2081
988
|
// ../../node_modules/date-fns/getISOWeekYear.js
|
|
2082
989
|
function getISOWeekYear(date, options) {
|
|
2083
|
-
const _date = toDate(date, options
|
|
990
|
+
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _28 => _28.in]));
|
|
2084
991
|
const year = _date.getFullYear();
|
|
2085
992
|
const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
|
|
2086
993
|
fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
|
|
@@ -2128,7 +1035,7 @@ function normalizeDates(context, ...dates) {
|
|
|
2128
1035
|
|
|
2129
1036
|
// ../../node_modules/date-fns/startOfDay.js
|
|
2130
1037
|
function startOfDay(date, options) {
|
|
2131
|
-
const _date = toDate(date, options
|
|
1038
|
+
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _29 => _29.in]));
|
|
2132
1039
|
_date.setHours(0, 0, 0, 0);
|
|
2133
1040
|
return _date;
|
|
2134
1041
|
}
|
|
@@ -2136,7 +1043,7 @@ function startOfDay(date, options) {
|
|
|
2136
1043
|
// ../../node_modules/date-fns/differenceInCalendarDays.js
|
|
2137
1044
|
function differenceInCalendarDays(laterDate, earlierDate, options) {
|
|
2138
1045
|
const [laterDate_, earlierDate_] = normalizeDates(
|
|
2139
|
-
options
|
|
1046
|
+
_optionalChain([options, 'optionalAccess', _30 => _30.in]),
|
|
2140
1047
|
laterDate,
|
|
2141
1048
|
earlierDate
|
|
2142
1049
|
);
|
|
@@ -2150,7 +1057,7 @@ function differenceInCalendarDays(laterDate, earlierDate, options) {
|
|
|
2150
1057
|
// ../../node_modules/date-fns/startOfISOWeekYear.js
|
|
2151
1058
|
function startOfISOWeekYear(date, options) {
|
|
2152
1059
|
const year = getISOWeekYear(date, options);
|
|
2153
|
-
const fourthOfJanuary = constructFrom(options
|
|
1060
|
+
const fourthOfJanuary = constructFrom(_optionalChain([options, 'optionalAccess', _31 => _31.in]) || date, 0);
|
|
2154
1061
|
fourthOfJanuary.setFullYear(year, 0, 4);
|
|
2155
1062
|
fourthOfJanuary.setHours(0, 0, 0, 0);
|
|
2156
1063
|
return startOfISOWeek(fourthOfJanuary);
|
|
@@ -2168,7 +1075,7 @@ function isValid(date) {
|
|
|
2168
1075
|
|
|
2169
1076
|
// ../../node_modules/date-fns/startOfYear.js
|
|
2170
1077
|
function startOfYear(date, options) {
|
|
2171
|
-
const date_ = toDate(date, options
|
|
1078
|
+
const date_ = toDate(date, _optionalChain([options, 'optionalAccess', _32 => _32.in]));
|
|
2172
1079
|
date_.setFullYear(date_.getFullYear(), 0, 1);
|
|
2173
1080
|
date_.setHours(0, 0, 0, 0);
|
|
2174
1081
|
return date_;
|
|
@@ -2248,7 +1155,7 @@ var formatDistance = (token, count, options) => {
|
|
|
2248
1155
|
} else {
|
|
2249
1156
|
result = tokenValue.other.replace("{{count}}", count.toString());
|
|
2250
1157
|
}
|
|
2251
|
-
if (options
|
|
1158
|
+
if (_optionalChain([options, 'optionalAccess', _33 => _33.addSuffix])) {
|
|
2252
1159
|
if (options.comparison && options.comparison > 0) {
|
|
2253
1160
|
return "in " + result;
|
|
2254
1161
|
} else {
|
|
@@ -2315,15 +1222,15 @@ var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale
|
|
|
2315
1222
|
// ../../node_modules/date-fns/locale/_lib/buildLocalizeFn.js
|
|
2316
1223
|
function buildLocalizeFn(args) {
|
|
2317
1224
|
return (value, options) => {
|
|
2318
|
-
const context = options
|
|
1225
|
+
const context = _optionalChain([options, 'optionalAccess', _34 => _34.context]) ? String(options.context) : "standalone";
|
|
2319
1226
|
let valuesArray;
|
|
2320
1227
|
if (context === "formatting" && args.formattingValues) {
|
|
2321
1228
|
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
|
|
2322
|
-
const width = options
|
|
1229
|
+
const width = _optionalChain([options, 'optionalAccess', _35 => _35.width]) ? String(options.width) : defaultWidth;
|
|
2323
1230
|
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
2324
1231
|
} else {
|
|
2325
1232
|
const defaultWidth = args.defaultWidth;
|
|
2326
|
-
const width = options
|
|
1233
|
+
const width = _optionalChain([options, 'optionalAccess', _36 => _36.width]) ? String(options.width) : args.defaultWidth;
|
|
2327
1234
|
valuesArray = args.values[width] || args.values[defaultWidth];
|
|
2328
1235
|
}
|
|
2329
1236
|
const index = args.argumentCallback ? args.argumentCallback(value) : value;
|
|
@@ -2685,7 +1592,7 @@ var enUS = {
|
|
|
2685
1592
|
|
|
2686
1593
|
// ../../node_modules/date-fns/getDayOfYear.js
|
|
2687
1594
|
function getDayOfYear(date, options) {
|
|
2688
|
-
const _date = toDate(date, options
|
|
1595
|
+
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _37 => _37.in]));
|
|
2689
1596
|
const diff = differenceInCalendarDays(_date, startOfYear(_date));
|
|
2690
1597
|
const dayOfYear = diff + 1;
|
|
2691
1598
|
return dayOfYear;
|
|
@@ -2693,22 +1600,22 @@ function getDayOfYear(date, options) {
|
|
|
2693
1600
|
|
|
2694
1601
|
// ../../node_modules/date-fns/getISOWeek.js
|
|
2695
1602
|
function getISOWeek(date, options) {
|
|
2696
|
-
const _date = toDate(date, options
|
|
1603
|
+
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _38 => _38.in]));
|
|
2697
1604
|
const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
|
|
2698
1605
|
return Math.round(diff / millisecondsInWeek) + 1;
|
|
2699
1606
|
}
|
|
2700
1607
|
|
|
2701
1608
|
// ../../node_modules/date-fns/getWeekYear.js
|
|
2702
1609
|
function getWeekYear(date, options) {
|
|
2703
|
-
const _date = toDate(date, options
|
|
1610
|
+
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _39 => _39.in]));
|
|
2704
1611
|
const year = _date.getFullYear();
|
|
2705
1612
|
const defaultOptions2 = getDefaultOptions();
|
|
2706
|
-
const firstWeekContainsDate = options
|
|
2707
|
-
const firstWeekOfNextYear = constructFrom(options
|
|
1613
|
+
const firstWeekContainsDate = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.firstWeekContainsDate]), () => ( _optionalChain([options, 'optionalAccess', _41 => _41.locale, 'optionalAccess', _42 => _42.options, 'optionalAccess', _43 => _43.firstWeekContainsDate]))), () => ( defaultOptions2.firstWeekContainsDate)), () => ( _optionalChain([defaultOptions2, 'access', _44 => _44.locale, 'optionalAccess', _45 => _45.options, 'optionalAccess', _46 => _46.firstWeekContainsDate]))), () => ( 1));
|
|
1614
|
+
const firstWeekOfNextYear = constructFrom(_optionalChain([options, 'optionalAccess', _47 => _47.in]) || date, 0);
|
|
2708
1615
|
firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
|
|
2709
1616
|
firstWeekOfNextYear.setHours(0, 0, 0, 0);
|
|
2710
1617
|
const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
|
|
2711
|
-
const firstWeekOfThisYear = constructFrom(options
|
|
1618
|
+
const firstWeekOfThisYear = constructFrom(_optionalChain([options, 'optionalAccess', _48 => _48.in]) || date, 0);
|
|
2712
1619
|
firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
|
|
2713
1620
|
firstWeekOfThisYear.setHours(0, 0, 0, 0);
|
|
2714
1621
|
const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
|
|
@@ -2724,9 +1631,9 @@ function getWeekYear(date, options) {
|
|
|
2724
1631
|
// ../../node_modules/date-fns/startOfWeekYear.js
|
|
2725
1632
|
function startOfWeekYear(date, options) {
|
|
2726
1633
|
const defaultOptions2 = getDefaultOptions();
|
|
2727
|
-
const firstWeekContainsDate = options
|
|
1634
|
+
const firstWeekContainsDate = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.firstWeekContainsDate]), () => ( _optionalChain([options, 'optionalAccess', _50 => _50.locale, 'optionalAccess', _51 => _51.options, 'optionalAccess', _52 => _52.firstWeekContainsDate]))), () => ( defaultOptions2.firstWeekContainsDate)), () => ( _optionalChain([defaultOptions2, 'access', _53 => _53.locale, 'optionalAccess', _54 => _54.options, 'optionalAccess', _55 => _55.firstWeekContainsDate]))), () => ( 1));
|
|
2728
1635
|
const year = getWeekYear(date, options);
|
|
2729
|
-
const firstWeek = constructFrom(options
|
|
1636
|
+
const firstWeek = constructFrom(_optionalChain([options, 'optionalAccess', _56 => _56.in]) || date, 0);
|
|
2730
1637
|
firstWeek.setFullYear(year, 0, firstWeekContainsDate);
|
|
2731
1638
|
firstWeek.setHours(0, 0, 0, 0);
|
|
2732
1639
|
const _date = startOfWeek(firstWeek, options);
|
|
@@ -2735,7 +1642,7 @@ function startOfWeekYear(date, options) {
|
|
|
2735
1642
|
|
|
2736
1643
|
// ../../node_modules/date-fns/getWeek.js
|
|
2737
1644
|
function getWeek(date, options) {
|
|
2738
|
-
const _date = toDate(date, options
|
|
1645
|
+
const _date = toDate(date, _optionalChain([options, 'optionalAccess', _57 => _57.in]));
|
|
2739
1646
|
const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
|
|
2740
1647
|
return Math.round(diff / millisecondsInWeek) + 1;
|
|
2741
1648
|
}
|
|
@@ -3538,10 +2445,10 @@ var doubleQuoteRegExp = /''/g;
|
|
|
3538
2445
|
var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
|
3539
2446
|
function format(date, formatStr, options) {
|
|
3540
2447
|
const defaultOptions2 = getDefaultOptions();
|
|
3541
|
-
const locale = options
|
|
3542
|
-
const firstWeekContainsDate = options
|
|
3543
|
-
const weekStartsOn = options
|
|
3544
|
-
const originalDate = toDate(date, options
|
|
2448
|
+
const locale = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _58 => _58.locale]), () => ( defaultOptions2.locale)), () => ( enUS));
|
|
2449
|
+
const firstWeekContainsDate = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _59 => _59.firstWeekContainsDate]), () => ( _optionalChain([options, 'optionalAccess', _60 => _60.locale, 'optionalAccess', _61 => _61.options, 'optionalAccess', _62 => _62.firstWeekContainsDate]))), () => ( defaultOptions2.firstWeekContainsDate)), () => ( _optionalChain([defaultOptions2, 'access', _63 => _63.locale, 'optionalAccess', _64 => _64.options, 'optionalAccess', _65 => _65.firstWeekContainsDate]))), () => ( 1));
|
|
2450
|
+
const weekStartsOn = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _66 => _66.weekStartsOn]), () => ( _optionalChain([options, 'optionalAccess', _67 => _67.locale, 'optionalAccess', _68 => _68.options, 'optionalAccess', _69 => _69.weekStartsOn]))), () => ( defaultOptions2.weekStartsOn)), () => ( _optionalChain([defaultOptions2, 'access', _70 => _70.locale, 'optionalAccess', _71 => _71.options, 'optionalAccess', _72 => _72.weekStartsOn]))), () => ( 0));
|
|
2451
|
+
const originalDate = toDate(date, _optionalChain([options, 'optionalAccess', _73 => _73.in]));
|
|
3545
2452
|
if (!isValid(originalDate)) {
|
|
3546
2453
|
throw new RangeError("Invalid time value");
|
|
3547
2454
|
}
|
|
@@ -3581,7 +2488,7 @@ function format(date, formatStr, options) {
|
|
|
3581
2488
|
return parts.map((part) => {
|
|
3582
2489
|
if (!part.isToken) return part.value;
|
|
3583
2490
|
const token = part.value;
|
|
3584
|
-
if (!options
|
|
2491
|
+
if (!_optionalChain([options, 'optionalAccess', _74 => _74.useAdditionalWeekYearTokens]) && isProtectedWeekYearToken(token) || !_optionalChain([options, 'optionalAccess', _75 => _75.useAdditionalDayOfYearTokens]) && isProtectedDayOfYearToken(token)) {
|
|
3585
2492
|
warnOrThrowProtectedError(token, formatStr, String(date));
|
|
3586
2493
|
}
|
|
3587
2494
|
const formatter = formatters[token[0]];
|
|
@@ -3597,16 +2504,16 @@ function cleanEscapedString(input) {
|
|
|
3597
2504
|
}
|
|
3598
2505
|
|
|
3599
2506
|
// components/markdown-renderer.tsx
|
|
3600
|
-
var
|
|
3601
|
-
var
|
|
3602
|
-
|
|
2507
|
+
var _reactmarkdown = require('react-markdown'); var _reactmarkdown2 = _interopRequireDefault(_reactmarkdown);
|
|
2508
|
+
var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
|
|
2509
|
+
|
|
3603
2510
|
function MarkdownRenderer({ content }) {
|
|
3604
|
-
return /* @__PURE__ */ (0,
|
|
3605
|
-
|
|
2511
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2512
|
+
_reactmarkdown2.default,
|
|
3606
2513
|
{
|
|
3607
|
-
remarkPlugins: [
|
|
2514
|
+
remarkPlugins: [_remarkgfm2.default],
|
|
3608
2515
|
components: {
|
|
3609
|
-
a: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
2516
|
+
a: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3610
2517
|
"a",
|
|
3611
2518
|
{
|
|
3612
2519
|
target: "_blank",
|
|
@@ -3615,20 +2522,20 @@ function MarkdownRenderer({ content }) {
|
|
|
3615
2522
|
...props
|
|
3616
2523
|
}
|
|
3617
2524
|
),
|
|
3618
|
-
h1: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
3619
|
-
h2: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
3620
|
-
h3: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
3621
|
-
code: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
2525
|
+
h1: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-2xl font-bold mt-6 mb-4", ...props }),
|
|
2526
|
+
h2: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "text-xl font-semibold mt-5 mb-3", ...props }),
|
|
2527
|
+
h3: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-lg font-semibold mt-4 mb-2", ...props }),
|
|
2528
|
+
code: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3622
2529
|
"code",
|
|
3623
2530
|
{
|
|
3624
2531
|
className: "block bg-gray-100 p-3 rounded font-mono",
|
|
3625
2532
|
...props
|
|
3626
2533
|
}
|
|
3627
2534
|
),
|
|
3628
|
-
ul: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
3629
|
-
ol: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
3630
|
-
p: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
3631
|
-
blockquote: ({ node, ...props }) => /* @__PURE__ */ (0,
|
|
2535
|
+
ul: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "list-disc pl-6 my-4", ...props }),
|
|
2536
|
+
ol: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "list-decimal pl-6 my-4", ...props }),
|
|
2537
|
+
p: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "my-4", ...props }),
|
|
2538
|
+
blockquote: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3632
2539
|
"blockquote",
|
|
3633
2540
|
{
|
|
3634
2541
|
className: "border-l-4 border-gray-200 pl-4 my-4 italic",
|
|
@@ -3642,13 +2549,13 @@ function MarkdownRenderer({ content }) {
|
|
|
3642
2549
|
}
|
|
3643
2550
|
|
|
3644
2551
|
// components/customer/chat-message.tsx
|
|
3645
|
-
|
|
2552
|
+
|
|
3646
2553
|
var Message = ({
|
|
3647
2554
|
message: message2,
|
|
3648
2555
|
isConsecutive,
|
|
3649
2556
|
onRetry
|
|
3650
2557
|
}) => {
|
|
3651
|
-
const renderAttachment = (attachment, index) => /* @__PURE__ */ (0,
|
|
2558
|
+
const renderAttachment = (attachment, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-2", children: attachment.type === "image" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3652
2559
|
"img",
|
|
3653
2560
|
{
|
|
3654
2561
|
src: attachment.url,
|
|
@@ -3656,7 +2563,7 @@ var Message = ({
|
|
|
3656
2563
|
className: "max-w-full rounded",
|
|
3657
2564
|
loading: "lazy"
|
|
3658
2565
|
}
|
|
3659
|
-
) : /* @__PURE__ */ (0,
|
|
2566
|
+
) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3660
2567
|
"a",
|
|
3661
2568
|
{
|
|
3662
2569
|
href: attachment.url,
|
|
@@ -3664,12 +2571,12 @@ var Message = ({
|
|
|
3664
2571
|
target: "_blank",
|
|
3665
2572
|
rel: "noopener noreferrer",
|
|
3666
2573
|
children: [
|
|
3667
|
-
/* @__PURE__ */ (0,
|
|
3668
|
-
/* @__PURE__ */ (0,
|
|
2574
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Paperclip, { className: "w-4 h-4" }),
|
|
2575
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: attachment.title })
|
|
3669
2576
|
]
|
|
3670
2577
|
}
|
|
3671
2578
|
) }, index);
|
|
3672
|
-
return /* @__PURE__ */ (0,
|
|
2579
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3673
2580
|
"div",
|
|
3674
2581
|
{
|
|
3675
2582
|
className: "flex justify-start gap-2",
|
|
@@ -3677,33 +2584,33 @@ var Message = ({
|
|
|
3677
2584
|
role: "article",
|
|
3678
2585
|
"aria-label": `Message from ${message2.senderId}`,
|
|
3679
2586
|
children: [
|
|
3680
|
-
/* @__PURE__ */ (0,
|
|
3681
|
-
message2.role === "user" && /* @__PURE__ */ (0,
|
|
3682
|
-
message2.role === "ai" && /* @__PURE__ */ (0,
|
|
3683
|
-
message2.role === "humanAgent" && /* @__PURE__ */ (0,
|
|
2587
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex pt-10 w-10", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "w-8 h-8 rounded-full flex justify-center", children: [
|
|
2588
|
+
message2.role === "user" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, User, {}),
|
|
2589
|
+
message2.role === "ai" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Bot, {}),
|
|
2590
|
+
message2.role === "humanAgent" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserCog, {})
|
|
3684
2591
|
] }) }),
|
|
3685
|
-
/* @__PURE__ */ (0,
|
|
2592
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3686
2593
|
"div",
|
|
3687
2594
|
{
|
|
3688
2595
|
className: `p-3 rounded-lg max-w-[80%] bg-gray-100 text-primary-900 ${isConsecutive ? "mt-1" : "mt-4"}`,
|
|
3689
2596
|
children: [
|
|
3690
|
-
/* @__PURE__ */ (0,
|
|
3691
|
-
message2.attachments
|
|
2597
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "break-words", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MarkdownRenderer, { content: message2.content }) }),
|
|
2598
|
+
_optionalChain([message2, 'access', _76 => _76.attachments, 'optionalAccess', _77 => _77.map, 'call', _78 => _78(
|
|
3692
2599
|
(attachment, i) => renderAttachment(attachment, i)
|
|
3693
|
-
),
|
|
3694
|
-
/* @__PURE__ */ (0,
|
|
3695
|
-
/* @__PURE__ */ (0,
|
|
3696
|
-
message2.role === "user" && /* @__PURE__ */ (0,
|
|
3697
|
-
message2.status === "sending" && /* @__PURE__ */ (0,
|
|
3698
|
-
message2.status === "sent" && /* @__PURE__ */ (0,
|
|
3699
|
-
message2.status === "delivered" && /* @__PURE__ */ (0,
|
|
3700
|
-
message2.status === "failed" && /* @__PURE__ */ (0,
|
|
2600
|
+
)]),
|
|
2601
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-end space-x-1 mt-1", children: [
|
|
2602
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs opacity-70", children: format(message2.time, "HH:mm") }),
|
|
2603
|
+
message2.role === "user" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2604
|
+
message2.status === "sending" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-4 h-4 animate-spin rounded-full border-2 border-gray-300 border-t-white" }),
|
|
2605
|
+
message2.status === "sent" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Check, { className: "w-4 h-4" }),
|
|
2606
|
+
message2.status === "delivered" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckCheck, { className: "w-4 h-4" }),
|
|
2607
|
+
message2.status === "failed" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3701
2608
|
"button",
|
|
3702
2609
|
{
|
|
3703
2610
|
onClick: () => onRetry(message2.id),
|
|
3704
2611
|
className: "text-red-300 hover:text-red-400",
|
|
3705
2612
|
"aria-label": "Retry sending message",
|
|
3706
|
-
children: /* @__PURE__ */ (0,
|
|
2613
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleAlert, { className: "w-4 h-4" })
|
|
3707
2614
|
}
|
|
3708
2615
|
)
|
|
3709
2616
|
] })
|
|
@@ -3717,19 +2624,19 @@ var Message = ({
|
|
|
3717
2624
|
};
|
|
3718
2625
|
|
|
3719
2626
|
// components/customer/chat-messages.tsx
|
|
3720
|
-
|
|
2627
|
+
|
|
3721
2628
|
var ChatMessages = ({
|
|
3722
2629
|
onRetry,
|
|
3723
2630
|
messages
|
|
3724
2631
|
}) => {
|
|
3725
|
-
const messageEndRef = (0,
|
|
2632
|
+
const messageEndRef = _react.useRef.call(void 0, null);
|
|
3726
2633
|
const scrollToBottom = () => {
|
|
3727
|
-
messageEndRef.current
|
|
2634
|
+
_optionalChain([messageEndRef, 'access', _79 => _79.current, 'optionalAccess', _80 => _80.scrollIntoView, 'call', _81 => _81({ behavior: "smooth" })]);
|
|
3728
2635
|
};
|
|
3729
|
-
(0,
|
|
2636
|
+
_react.useEffect.call(void 0, () => {
|
|
3730
2637
|
scrollToBottom();
|
|
3731
2638
|
}, [messages]);
|
|
3732
|
-
return /* @__PURE__ */ (0,
|
|
2639
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3733
2640
|
"div",
|
|
3734
2641
|
{
|
|
3735
2642
|
className: "flex-1 overflow-y-auto p-4 space-y-4 bg-white min-h-[calc(100vh-290px)]",
|
|
@@ -3737,10 +2644,10 @@ var ChatMessages = ({
|
|
|
3737
2644
|
"aria-label": "Chat messages",
|
|
3738
2645
|
children: [
|
|
3739
2646
|
messages.filter(
|
|
3740
|
-
(msg) => (!msg.toolCalls
|
|
2647
|
+
(msg) => (!_optionalChain([msg, 'access', _82 => _82.toolCalls, 'optionalAccess', _83 => _83.length]) || msg.toolCalls.length === 0) && !msg.toolCallId
|
|
3741
2648
|
).map((msg, index) => {
|
|
3742
2649
|
const isConsecutive = index > 0 && messages[index - 1].senderId === msg.senderId && msg.time - messages[index - 1].time < 3e5;
|
|
3743
|
-
return /* @__PURE__ */ (0,
|
|
2650
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3744
2651
|
Message,
|
|
3745
2652
|
{
|
|
3746
2653
|
message: msg,
|
|
@@ -3750,247 +2657,246 @@ var ChatMessages = ({
|
|
|
3750
2657
|
msg.id
|
|
3751
2658
|
);
|
|
3752
2659
|
}),
|
|
3753
|
-
/* @__PURE__ */ (0,
|
|
2660
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: messageEndRef })
|
|
3754
2661
|
]
|
|
3755
2662
|
}
|
|
3756
2663
|
);
|
|
3757
2664
|
};
|
|
3758
2665
|
|
|
3759
2666
|
// components/customer/chat-typing-indicator.tsx
|
|
3760
|
-
|
|
2667
|
+
|
|
3761
2668
|
var ChatTypingIndicator = ({
|
|
3762
2669
|
typingUsers
|
|
3763
2670
|
}) => {
|
|
3764
2671
|
if (typingUsers.size === 0) return null;
|
|
3765
|
-
return /* @__PURE__ */ (0,
|
|
2672
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "px-4 py-2 text-sm text-gray-500 italic", role: "status", children: [
|
|
3766
2673
|
Array.from(typingUsers).join(", "),
|
|
3767
2674
|
" typing..."
|
|
3768
2675
|
] });
|
|
3769
2676
|
};
|
|
3770
2677
|
|
|
3771
2678
|
// components/customer/generic-chat-widget.tsx
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
2679
|
+
|
|
2680
|
+
|
|
2681
|
+
|
|
3775
2682
|
var GenericChatWidget = ({
|
|
3776
2683
|
onFileUpload
|
|
3777
2684
|
}) => {
|
|
3778
|
-
const [typingUsers] = (0,
|
|
2685
|
+
const [typingUsers] = _react.useState.call(void 0, /* @__PURE__ */ new Set());
|
|
3779
2686
|
const { error, messages } = useWebSocketChatCustomerContext();
|
|
3780
2687
|
const handleRetry = (messageId) => {
|
|
3781
2688
|
};
|
|
3782
|
-
return /* @__PURE__ */ (0,
|
|
2689
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3783
2690
|
"div",
|
|
3784
2691
|
{
|
|
3785
2692
|
className: "flex flex-col w-full max-w-lg border rounded-lg shadow-lg",
|
|
3786
2693
|
role: "region",
|
|
3787
2694
|
"aria-label": "Chat interface",
|
|
3788
2695
|
children: [
|
|
3789
|
-
/* @__PURE__ */ (0,
|
|
3790
|
-
error && /* @__PURE__ */ (0,
|
|
3791
|
-
/* @__PURE__ */ (0,
|
|
3792
|
-
/* @__PURE__ */ (0,
|
|
3793
|
-
/* @__PURE__ */ (0,
|
|
2696
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatHeader, {}),
|
|
2697
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.Alert, { title: "Error", description: error.message }),
|
|
2698
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatMessages, { onRetry: handleRetry, messages }),
|
|
2699
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatTypingIndicator, { typingUsers }),
|
|
2700
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatInput, { onFileUpload })
|
|
3794
2701
|
]
|
|
3795
2702
|
}
|
|
3796
2703
|
);
|
|
3797
2704
|
};
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
useWebSocketChatCustomerContext
|
|
3993
|
-
});
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2712
|
+
|
|
2713
|
+
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
|
|
2718
|
+
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
|
|
2725
|
+
|
|
2726
|
+
|
|
2727
|
+
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
|
|
2734
|
+
|
|
2735
|
+
|
|
2736
|
+
|
|
2737
|
+
|
|
2738
|
+
|
|
2739
|
+
|
|
2740
|
+
|
|
2741
|
+
|
|
2742
|
+
|
|
2743
|
+
|
|
2744
|
+
|
|
2745
|
+
|
|
2746
|
+
|
|
2747
|
+
|
|
2748
|
+
|
|
2749
|
+
|
|
2750
|
+
|
|
2751
|
+
|
|
2752
|
+
|
|
2753
|
+
|
|
2754
|
+
|
|
2755
|
+
|
|
2756
|
+
|
|
2757
|
+
|
|
2758
|
+
|
|
2759
|
+
|
|
2760
|
+
|
|
2761
|
+
|
|
2762
|
+
|
|
2763
|
+
|
|
2764
|
+
|
|
2765
|
+
|
|
2766
|
+
|
|
2767
|
+
|
|
2768
|
+
|
|
2769
|
+
|
|
2770
|
+
|
|
2771
|
+
|
|
2772
|
+
|
|
2773
|
+
|
|
2774
|
+
|
|
2775
|
+
|
|
2776
|
+
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
|
|
2786
|
+
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
|
|
2790
|
+
|
|
2791
|
+
|
|
2792
|
+
|
|
2793
|
+
|
|
2794
|
+
|
|
2795
|
+
|
|
2796
|
+
|
|
2797
|
+
|
|
2798
|
+
|
|
2799
|
+
|
|
2800
|
+
|
|
2801
|
+
|
|
2802
|
+
|
|
2803
|
+
|
|
2804
|
+
|
|
2805
|
+
|
|
2806
|
+
|
|
2807
|
+
|
|
2808
|
+
|
|
2809
|
+
|
|
2810
|
+
|
|
2811
|
+
|
|
2812
|
+
|
|
2813
|
+
|
|
2814
|
+
|
|
2815
|
+
|
|
2816
|
+
|
|
2817
|
+
|
|
2818
|
+
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
|
|
2822
|
+
|
|
2823
|
+
|
|
2824
|
+
|
|
2825
|
+
|
|
2826
|
+
|
|
2827
|
+
|
|
2828
|
+
|
|
2829
|
+
|
|
2830
|
+
|
|
2831
|
+
|
|
2832
|
+
|
|
2833
|
+
|
|
2834
|
+
|
|
2835
|
+
|
|
2836
|
+
|
|
2837
|
+
|
|
2838
|
+
|
|
2839
|
+
|
|
2840
|
+
|
|
2841
|
+
|
|
2842
|
+
|
|
2843
|
+
|
|
2844
|
+
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
|
|
2848
|
+
|
|
2849
|
+
|
|
2850
|
+
|
|
2851
|
+
|
|
2852
|
+
|
|
2853
|
+
|
|
2854
|
+
|
|
2855
|
+
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
|
|
2859
|
+
|
|
2860
|
+
|
|
2861
|
+
|
|
2862
|
+
|
|
2863
|
+
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
|
|
2867
|
+
|
|
2868
|
+
|
|
2869
|
+
|
|
2870
|
+
|
|
2871
|
+
|
|
2872
|
+
|
|
2873
|
+
|
|
2874
|
+
|
|
2875
|
+
|
|
2876
|
+
|
|
2877
|
+
|
|
2878
|
+
|
|
2879
|
+
|
|
2880
|
+
|
|
2881
|
+
|
|
2882
|
+
|
|
2883
|
+
|
|
2884
|
+
|
|
2885
|
+
|
|
2886
|
+
|
|
2887
|
+
|
|
2888
|
+
|
|
2889
|
+
|
|
2890
|
+
|
|
2891
|
+
|
|
2892
|
+
|
|
2893
|
+
|
|
2894
|
+
|
|
2895
|
+
|
|
2896
|
+
|
|
2897
|
+
|
|
2898
|
+
|
|
2899
|
+
exports.AdminChatHeader = AdminChatHeader; exports.AdminChatInput = AdminChatInput; exports.AdminChatList = AdminChatList; exports.AdminChatListItem = AdminChatListItem; exports.AgentStatusAway = _chunkE2FJX52Rjs.AgentStatusAway; exports.AgentStatusBusy = _chunkE2FJX52Rjs.AgentStatusBusy; exports.AgentStatusOffline = _chunkE2FJX52Rjs.AgentStatusOffline; exports.AgentStatusOnline = _chunkE2FJX52Rjs.AgentStatusOnline; exports.AssignChatToAgentSubject = _chunkE2FJX52Rjs.AssignChatToAgentSubject; exports.AttachmentTypeActions = _chunkE2FJX52Rjs.AttachmentTypeActions; exports.AttachmentTypeArticles = _chunkE2FJX52Rjs.AttachmentTypeArticles; exports.AttachmentTypeAudio = _chunkE2FJX52Rjs.AttachmentTypeAudio; exports.AttachmentTypeBullets = _chunkE2FJX52Rjs.AttachmentTypeBullets; exports.AttachmentTypeData = _chunkE2FJX52Rjs.AttachmentTypeData; exports.AttachmentTypeDocument = _chunkE2FJX52Rjs.AttachmentTypeDocument; exports.AttachmentTypeDocumentAnalysis = _chunkE2FJX52Rjs.AttachmentTypeDocumentAnalysis; exports.AttachmentTypeDocumentSources = _chunkE2FJX52Rjs.AttachmentTypeDocumentSources; exports.AttachmentTypeImage = _chunkE2FJX52Rjs.AttachmentTypeImage; exports.AttachmentTypeKGNodes = _chunkE2FJX52Rjs.AttachmentTypeKGNodes; exports.AttachmentTypeLocation = _chunkE2FJX52Rjs.AttachmentTypeLocation; exports.AttachmentTypeRecords = _chunkE2FJX52Rjs.AttachmentTypeRecords; exports.AttachmentTypeReferences = _chunkE2FJX52Rjs.AttachmentTypeReferences; exports.AttachmentTypeSticker = _chunkE2FJX52Rjs.AttachmentTypeSticker; exports.AttachmentTypeSubsections = _chunkE2FJX52Rjs.AttachmentTypeSubsections; exports.AttachmentTypeVideo = _chunkE2FJX52Rjs.AttachmentTypeVideo; exports.ChatArchiveSubjectPattern = _chunkE2FJX52Rjs.ChatArchiveSubjectPattern; exports.ChatEventTypeAgentActivityPing = _chunkE2FJX52Rjs.ChatEventTypeAgentActivityPing; exports.ChatEventTypeAgentChatAssigned = _chunkE2FJX52Rjs.ChatEventTypeAgentChatAssigned; exports.ChatEventTypeAgentChatCompleted = _chunkE2FJX52Rjs.ChatEventTypeAgentChatCompleted; exports.ChatEventTypeAgentContextUpdate = _chunkE2FJX52Rjs.ChatEventTypeAgentContextUpdate; exports.ChatEventTypeAgentExecutionEnded = _chunkE2FJX52Rjs.ChatEventTypeAgentExecutionEnded; exports.ChatEventTypeAgentExecutionStarted = _chunkE2FJX52Rjs.ChatEventTypeAgentExecutionStarted; exports.ChatEventTypeAgentSessionEnd = _chunkE2FJX52Rjs.ChatEventTypeAgentSessionEnd; exports.ChatEventTypeAgentSessionStart = _chunkE2FJX52Rjs.ChatEventTypeAgentSessionStart; exports.ChatEventTypeAgentStatusChange = _chunkE2FJX52Rjs.ChatEventTypeAgentStatusChange; exports.ChatEventTypeBlockUser = _chunkE2FJX52Rjs.ChatEventTypeBlockUser; exports.ChatEventTypeCSATRequest = _chunkE2FJX52Rjs.ChatEventTypeCSATRequest; exports.ChatEventTypeCSATResponse = _chunkE2FJX52Rjs.ChatEventTypeCSATResponse; exports.ChatEventTypeCSATSurvey = _chunkE2FJX52Rjs.ChatEventTypeCSATSurvey; exports.ChatEventTypeChatEnded = _chunkE2FJX52Rjs.ChatEventTypeChatEnded; exports.ChatEventTypeChatRemoved = _chunkE2FJX52Rjs.ChatEventTypeChatRemoved; exports.ChatEventTypeChatUpdated = _chunkE2FJX52Rjs.ChatEventTypeChatUpdated; exports.ChatEventTypeClientAction = _chunkE2FJX52Rjs.ChatEventTypeClientAction; exports.ChatEventTypeClientActionCallback = _chunkE2FJX52Rjs.ChatEventTypeClientActionCallback; exports.ChatEventTypeCreateRoom = _chunkE2FJX52Rjs.ChatEventTypeCreateRoom; exports.ChatEventTypeDeleteRoom = _chunkE2FJX52Rjs.ChatEventTypeDeleteRoom; exports.ChatEventTypeDelivered = _chunkE2FJX52Rjs.ChatEventTypeDelivered; exports.ChatEventTypeEndChat = _chunkE2FJX52Rjs.ChatEventTypeEndChat; exports.ChatEventTypeError = _chunkE2FJX52Rjs.ChatEventTypeError; exports.ChatEventTypeGetAgents = _chunkE2FJX52Rjs.ChatEventTypeGetAgents; exports.ChatEventTypeGetAgentsResponse = _chunkE2FJX52Rjs.ChatEventTypeGetAgentsResponse; exports.ChatEventTypeGetOnlineUsers = _chunkE2FJX52Rjs.ChatEventTypeGetOnlineUsers; exports.ChatEventTypeHumanAgentJoined = _chunkE2FJX52Rjs.ChatEventTypeHumanAgentJoined; exports.ChatEventTypeHumanAgentLeft = _chunkE2FJX52Rjs.ChatEventTypeHumanAgentLeft; exports.ChatEventTypeInviteUser = _chunkE2FJX52Rjs.ChatEventTypeInviteUser; exports.ChatEventTypeJoinRoom = _chunkE2FJX52Rjs.ChatEventTypeJoinRoom; exports.ChatEventTypeLeaveRoom = _chunkE2FJX52Rjs.ChatEventTypeLeaveRoom; exports.ChatEventTypeListChats = _chunkE2FJX52Rjs.ChatEventTypeListChats; exports.ChatEventTypeListRooms = _chunkE2FJX52Rjs.ChatEventTypeListRooms; exports.ChatEventTypeLoadAgentContext = _chunkE2FJX52Rjs.ChatEventTypeLoadAgentContext; exports.ChatEventTypeLoadAgentContextResponse = _chunkE2FJX52Rjs.ChatEventTypeLoadAgentContextResponse; exports.ChatEventTypeLoadChat = _chunkE2FJX52Rjs.ChatEventTypeLoadChat; exports.ChatEventTypeLoadChatResponse = _chunkE2FJX52Rjs.ChatEventTypeLoadChatResponse; exports.ChatEventTypeMentionUser = _chunkE2FJX52Rjs.ChatEventTypeMentionUser; exports.ChatEventTypeMessage = _chunkE2FJX52Rjs.ChatEventTypeMessage; exports.ChatEventTypeMessageDeleted = _chunkE2FJX52Rjs.ChatEventTypeMessageDeleted; exports.ChatEventTypeMessageDeletedResponse = _chunkE2FJX52Rjs.ChatEventTypeMessageDeletedResponse; exports.ChatEventTypeMessageEdited = _chunkE2FJX52Rjs.ChatEventTypeMessageEdited; exports.ChatEventTypeMessageEditedResponse = _chunkE2FJX52Rjs.ChatEventTypeMessageEditedResponse; exports.ChatEventTypeMessageReaction = _chunkE2FJX52Rjs.ChatEventTypeMessageReaction; exports.ChatEventTypeMessageReactionResponse = _chunkE2FJX52Rjs.ChatEventTypeMessageReactionResponse; exports.ChatEventTypeMessageReply = _chunkE2FJX52Rjs.ChatEventTypeMessageReply; exports.ChatEventTypeMessageStatusUpdate = _chunkE2FJX52Rjs.ChatEventTypeMessageStatusUpdate; exports.ChatEventTypeNewChat = _chunkE2FJX52Rjs.ChatEventTypeNewChat; exports.ChatEventTypeNewChatCreated = _chunkE2FJX52Rjs.ChatEventTypeNewChatCreated; exports.ChatEventTypeObserverJoined = _chunkE2FJX52Rjs.ChatEventTypeObserverJoined; exports.ChatEventTypeObserverLeft = _chunkE2FJX52Rjs.ChatEventTypeObserverLeft; exports.ChatEventTypeOnlineUsersResponse = _chunkE2FJX52Rjs.ChatEventTypeOnlineUsersResponse; exports.ChatEventTypePing = _chunkE2FJX52Rjs.ChatEventTypePing; exports.ChatEventTypePlanApproved = _chunkE2FJX52Rjs.ChatEventTypePlanApproved; exports.ChatEventTypePlanCompleted = _chunkE2FJX52Rjs.ChatEventTypePlanCompleted; exports.ChatEventTypePlanPendingApproval = _chunkE2FJX52Rjs.ChatEventTypePlanPendingApproval; exports.ChatEventTypePlanRejected = _chunkE2FJX52Rjs.ChatEventTypePlanRejected; exports.ChatEventTypePong = _chunkE2FJX52Rjs.ChatEventTypePong; exports.ChatEventTypeRead = _chunkE2FJX52Rjs.ChatEventTypeRead; exports.ChatEventTypeReconnected = _chunkE2FJX52Rjs.ChatEventTypeReconnected; exports.ChatEventTypeRoomCreated = _chunkE2FJX52Rjs.ChatEventTypeRoomCreated; exports.ChatEventTypeRoomDeleted = _chunkE2FJX52Rjs.ChatEventTypeRoomDeleted; exports.ChatEventTypeRoomUpdated = _chunkE2FJX52Rjs.ChatEventTypeRoomUpdated; exports.ChatEventTypeRoomUserJoined = _chunkE2FJX52Rjs.ChatEventTypeRoomUserJoined; exports.ChatEventTypeRoomUserLeft = _chunkE2FJX52Rjs.ChatEventTypeRoomUserLeft; exports.ChatEventTypeRoomsResponse = _chunkE2FJX52Rjs.ChatEventTypeRoomsResponse; exports.ChatEventTypeStepCompleted = _chunkE2FJX52Rjs.ChatEventTypeStepCompleted; exports.ChatEventTypeStepFailed = _chunkE2FJX52Rjs.ChatEventTypeStepFailed; exports.ChatEventTypeStepStarted = _chunkE2FJX52Rjs.ChatEventTypeStepStarted; exports.ChatEventTypeStoppedTyping = _chunkE2FJX52Rjs.ChatEventTypeStoppedTyping; exports.ChatEventTypeSummaryUpdate = _chunkE2FJX52Rjs.ChatEventTypeSummaryUpdate; exports.ChatEventTypeSyncMetadata = _chunkE2FJX52Rjs.ChatEventTypeSyncMetadata; exports.ChatEventTypeSyncMetadataResponse = _chunkE2FJX52Rjs.ChatEventTypeSyncMetadataResponse; exports.ChatEventTypeSyncUserSession = _chunkE2FJX52Rjs.ChatEventTypeSyncUserSession; exports.ChatEventTypeSyncUserSessionResponse = _chunkE2FJX52Rjs.ChatEventTypeSyncUserSessionResponse; exports.ChatEventTypeTyping = _chunkE2FJX52Rjs.ChatEventTypeTyping; exports.ChatEventTypeUpdateRoom = _chunkE2FJX52Rjs.ChatEventTypeUpdateRoom; exports.ChatEventTypeUserActivity = _chunkE2FJX52Rjs.ChatEventTypeUserActivity; exports.ChatEventTypeUserActivityUpdate = _chunkE2FJX52Rjs.ChatEventTypeUserActivityUpdate; exports.ChatEventTypeUserInvited = _chunkE2FJX52Rjs.ChatEventTypeUserInvited; exports.ChatEventTypeUserJoined = _chunkE2FJX52Rjs.ChatEventTypeUserJoined; exports.ChatEventTypeUserLeft = _chunkE2FJX52Rjs.ChatEventTypeUserLeft; exports.ChatEventTypeUserPresenceChanged = _chunkE2FJX52Rjs.ChatEventTypeUserPresenceChanged; exports.ChatEventTypeUserPresenceEnd = _chunkE2FJX52Rjs.ChatEventTypeUserPresenceEnd; exports.ChatEventTypeUserPresenceStart = _chunkE2FJX52Rjs.ChatEventTypeUserPresenceStart; exports.ChatEventTypeUserRemoved = _chunkE2FJX52Rjs.ChatEventTypeUserRemoved; exports.ChatEventTypeUserStatusChange = _chunkE2FJX52Rjs.ChatEventTypeUserStatusChange; exports.ChatEventTypeUserSuggestedActionSelected = _chunkE2FJX52Rjs.ChatEventTypeUserSuggestedActionSelected; exports.ChatEventTypeUserSuggestedActions = _chunkE2FJX52Rjs.ChatEventTypeUserSuggestedActions; exports.ChatEventTypeWaiting = _chunkE2FJX52Rjs.ChatEventTypeWaiting; exports.ChatEventTypeWaitingForAgent = _chunkE2FJX52Rjs.ChatEventTypeWaitingForAgent; exports.ChatHeader = ChatHeader; exports.ChatHumanAgentActions = ChatHumanAgentActions; exports.ChatInput = ChatInput; exports.ChatMessages = ChatMessages; exports.ChatRoleAI = _chunkE2FJX52Rjs.ChatRoleAI; exports.ChatRoleDataQuery = _chunkE2FJX52Rjs.ChatRoleDataQuery; exports.ChatRoleEvent = _chunkE2FJX52Rjs.ChatRoleEvent; exports.ChatRoleHumanAgent = _chunkE2FJX52Rjs.ChatRoleHumanAgent; exports.ChatRoleObserver = _chunkE2FJX52Rjs.ChatRoleObserver; exports.ChatRoleSystem = _chunkE2FJX52Rjs.ChatRoleSystem; exports.ChatRoleTool = _chunkE2FJX52Rjs.ChatRoleTool; exports.ChatRoleUser = _chunkE2FJX52Rjs.ChatRoleUser; exports.ChatSessionStatusActive = _chunkE2FJX52Rjs.ChatSessionStatusActive; exports.ChatSessionStatusExpired = _chunkE2FJX52Rjs.ChatSessionStatusExpired; exports.ChatSessionStatusIdle = _chunkE2FJX52Rjs.ChatSessionStatusIdle; exports.ChatStatusAbandoned = _chunkE2FJX52Rjs.ChatStatusAbandoned; exports.ChatStatusActive = _chunkE2FJX52Rjs.ChatStatusActive; exports.ChatStatusArchived = _chunkE2FJX52Rjs.ChatStatusArchived; exports.ChatStatusClosed = _chunkE2FJX52Rjs.ChatStatusClosed; exports.ChatStatusCustomerUI = ChatStatusCustomerUI; exports.ChatStatusDisconnected = _chunkE2FJX52Rjs.ChatStatusDisconnected; exports.ChatTypeCustomerSupport = _chunkE2FJX52Rjs.ChatTypeCustomerSupport; exports.ChatTypeDirect = _chunkE2FJX52Rjs.ChatTypeDirect; exports.ChatTypeGroup = _chunkE2FJX52Rjs.ChatTypeGroup; exports.ChatTypePrivateRoom = _chunkE2FJX52Rjs.ChatTypePrivateRoom; exports.ChatTypePublicRoom = _chunkE2FJX52Rjs.ChatTypePublicRoom; exports.ChatTypingIndicator = ChatTypingIndicator; exports.CompleteChatByAgentSubject = _chunkE2FJX52Rjs.CompleteChatByAgentSubject; exports.CreateAgentQueueSubject = _chunkE2FJX52Rjs.CreateAgentQueueSubject; exports.DeleteAgentQueueSubject = _chunkE2FJX52Rjs.DeleteAgentQueueSubject; exports.EndAgentSessionSubject = _chunkE2FJX52Rjs.EndAgentSessionSubject; exports.GenericChatWidget = GenericChatWidget; exports.GetActiveChatCountSubject = _chunkE2FJX52Rjs.GetActiveChatCountSubject; exports.GetActiveChatsSubject = _chunkE2FJX52Rjs.GetActiveChatsSubject; exports.GetAgentQueuesSubject = _chunkE2FJX52Rjs.GetAgentQueuesSubject; exports.GetAgentSessionSubject = _chunkE2FJX52Rjs.GetAgentSessionSubject; exports.GetChatSubject = _chunkE2FJX52Rjs.GetChatSubject; exports.GetDailyChatCountSubject = _chunkE2FJX52Rjs.GetDailyChatCountSubject; exports.GetOnlineAgentCountSubject = _chunkE2FJX52Rjs.GetOnlineAgentCountSubject; exports.GetOnlineAgentsSubject = _chunkE2FJX52Rjs.GetOnlineAgentsSubject; exports.GetOnlineUsersSubject = _chunkE2FJX52Rjs.GetOnlineUsersSubject; exports.GetQueueChatCountSubject = _chunkE2FJX52Rjs.GetQueueChatCountSubject; exports.GetQueueChatsSubject = _chunkE2FJX52Rjs.GetQueueChatsSubject; exports.GetUserChatsSubject = _chunkE2FJX52Rjs.GetUserChatsSubject; exports.GetWaitingForAgentChatCountSubject = _chunkE2FJX52Rjs.GetWaitingForAgentChatCountSubject; exports.GetWaitingForAgentChatsSubject = _chunkE2FJX52Rjs.GetWaitingForAgentChatsSubject; exports.MessageStatusDelivered = _chunkE2FJX52Rjs.MessageStatusDelivered; exports.MessageStatusFailed = _chunkE2FJX52Rjs.MessageStatusFailed; exports.MessageStatusRead = _chunkE2FJX52Rjs.MessageStatusRead; exports.MessageStatusSending = _chunkE2FJX52Rjs.MessageStatusSending; exports.MessageStatusSent = _chunkE2FJX52Rjs.MessageStatusSent; exports.QueueTypeComplexity = _chunkE2FJX52Rjs.QueueTypeComplexity; exports.QueueTypeDepartment = _chunkE2FJX52Rjs.QueueTypeDepartment; exports.QueueTypePriority = _chunkE2FJX52Rjs.QueueTypePriority; exports.QueueTypeSkill = _chunkE2FJX52Rjs.QueueTypeSkill; exports.QueueTypes = _chunkE2FJX52Rjs.QueueTypes; exports.SetupOrgSubject = _chunkE2FJX52Rjs.SetupOrgSubject; exports.StartAgentSessionSubject = _chunkE2FJX52Rjs.StartAgentSessionSubject; exports.TriggerAnalyticsScanSubject = _chunkE2FJX52Rjs.TriggerAnalyticsScanSubject; exports.UpdateAgentLastActivitySubject = _chunkE2FJX52Rjs.UpdateAgentLastActivitySubject; exports.UpdateAgentQueueSubject = _chunkE2FJX52Rjs.UpdateAgentQueueSubject; exports.UpdateAgentStatusSubject = _chunkE2FJX52Rjs.UpdateAgentStatusSubject; exports.UpdateUserStatusSubject = _chunkE2FJX52Rjs.UpdateUserStatusSubject; exports.UserStatusAway = _chunkE2FJX52Rjs.UserStatusAway; exports.UserStatusBusy = _chunkE2FJX52Rjs.UserStatusBusy; exports.UserStatusOffline = _chunkE2FJX52Rjs.UserStatusOffline; exports.UserStatusOnline = _chunkE2FJX52Rjs.UserStatusOnline; exports.WebSocketChatAdminContext = WebSocketChatAdminContext; exports.WebSocketChatAdminProvider = WebSocketChatAdminProvider; exports.WebSocketChatCustomerContext = WebSocketChatCustomerContext; exports.WebSocketChatCustomerProvider = WebSocketChatCustomerProvider; exports.useWebSocketChatAdmin = _chunkE2FJX52Rjs.useWebSocketChatAdmin; exports.useWebSocketChatAdminContext = useWebSocketChatAdminContext; exports.useWebSocketChatBase = _chunkDTFTLFSYjs.useWebSocketChatBase; exports.useWebSocketChatCustomer = _chunk3PXNBY7Jjs.useWebSocketChatCustomer; exports.useWebSocketChatCustomerContext = useWebSocketChatCustomerContext;
|
|
3994
2900
|
/*! Bundled license information:
|
|
3995
2901
|
|
|
3996
2902
|
lucide-react/dist/esm/shared/src/utils.js:
|