@channelhub/widget 0.1.6 → 0.1.8
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/ChannelHubNotificationBell.d.ts +17 -0
- package/dist/ChannelHubNotificationBell.d.ts.map +1 -0
- package/dist/index.cjs +31 -26
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1023 -738
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChannelHubInbox.tsx +51 -16
- package/src/ChannelHubNotificationBell.tsx +348 -0
- package/src/index.ts +2 -0
- package/src/types.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as e, jsxs as n, Fragment as
|
|
2
|
-
import { forwardRef as Le, createElement as Pe, createContext as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsx as e, jsxs as n, Fragment as ne } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Le, createElement as Pe, createContext as rt, useRef as Z, useState as y, useMemo as Ee, useCallback as ke, useEffect as V, useImperativeHandle as mt, useContext as Ne, Component as xt } from "react";
|
|
3
|
+
import { createPortal as ot } from "react-dom";
|
|
4
4
|
/**
|
|
5
5
|
* @license lucide-react v0.468.0 - ISC
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the ISC license.
|
|
8
8
|
* See the LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const vt = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), at = (...t) => t.filter((i, r, o) => !!i && i.trim() !== "" && o.indexOf(i) === r).join(" ").trim();
|
|
11
11
|
/**
|
|
12
12
|
* @license lucide-react v0.468.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/
|
|
17
|
-
var
|
|
17
|
+
var kt = {
|
|
18
18
|
xmlns: "http://www.w3.org/2000/svg",
|
|
19
19
|
width: 24,
|
|
20
20
|
height: 24,
|
|
@@ -31,31 +31,31 @@ var xt = {
|
|
|
31
31
|
* This source code is licensed under the ISC license.
|
|
32
32
|
* See the LICENSE file in the root directory of this source tree.
|
|
33
33
|
*/
|
|
34
|
-
const
|
|
34
|
+
const wt = Le(
|
|
35
35
|
({
|
|
36
36
|
color: t = "currentColor",
|
|
37
37
|
size: i = 24,
|
|
38
38
|
strokeWidth: r = 2,
|
|
39
39
|
absoluteStrokeWidth: o,
|
|
40
40
|
className: s = "",
|
|
41
|
-
children:
|
|
42
|
-
iconNode:
|
|
43
|
-
|
|
41
|
+
children: k,
|
|
42
|
+
iconNode: g,
|
|
43
|
+
...$
|
|
44
44
|
}, f) => Pe(
|
|
45
45
|
"svg",
|
|
46
46
|
{
|
|
47
47
|
ref: f,
|
|
48
|
-
...
|
|
48
|
+
...kt,
|
|
49
49
|
width: i,
|
|
50
50
|
height: i,
|
|
51
51
|
stroke: t,
|
|
52
52
|
strokeWidth: o ? Number(r) * 24 / Number(i) : r,
|
|
53
|
-
className:
|
|
54
|
-
|
|
53
|
+
className: at("lucide", s),
|
|
54
|
+
...$
|
|
55
55
|
},
|
|
56
56
|
[
|
|
57
|
-
...
|
|
58
|
-
...Array.isArray(
|
|
57
|
+
...g.map(([x, R]) => Pe(x, R)),
|
|
58
|
+
...Array.isArray(k) ? k : [k]
|
|
59
59
|
]
|
|
60
60
|
)
|
|
61
61
|
);
|
|
@@ -65,12 +65,12 @@ const vt = Le(
|
|
|
65
65
|
* This source code is licensed under the ISC license.
|
|
66
66
|
* See the LICENSE file in the root directory of this source tree.
|
|
67
67
|
*/
|
|
68
|
-
const
|
|
68
|
+
const G = (t, i) => {
|
|
69
69
|
const r = Le(
|
|
70
|
-
({ className: o, ...s },
|
|
71
|
-
ref:
|
|
70
|
+
({ className: o, ...s }, k) => Pe(wt, {
|
|
71
|
+
ref: k,
|
|
72
72
|
iconNode: i,
|
|
73
|
-
className:
|
|
73
|
+
className: at(`lucide-${vt(t)}`, o),
|
|
74
74
|
...s
|
|
75
75
|
})
|
|
76
76
|
);
|
|
@@ -82,7 +82,7 @@ const X = (t, i) => {
|
|
|
82
82
|
* This source code is licensed under the ISC license.
|
|
83
83
|
* See the LICENSE file in the root directory of this source tree.
|
|
84
84
|
*/
|
|
85
|
-
const
|
|
85
|
+
const Xe = G("CheckCheck", [
|
|
86
86
|
["path", { d: "M18 6 7 17l-5-5", key: "116fxf" }],
|
|
87
87
|
["path", { d: "m22 10-7.5 7.5L13 16", key: "ke71qq" }]
|
|
88
88
|
]);
|
|
@@ -92,14 +92,14 @@ const Ge = X("CheckCheck", [
|
|
|
92
92
|
* This source code is licensed under the ISC license.
|
|
93
93
|
* See the LICENSE file in the root directory of this source tree.
|
|
94
94
|
*/
|
|
95
|
-
const
|
|
95
|
+
const lt = G("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
|
|
96
96
|
/**
|
|
97
97
|
* @license lucide-react v0.468.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
101
|
*/
|
|
102
|
-
const
|
|
102
|
+
const St = G("ChevronDown", [
|
|
103
103
|
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
|
|
104
104
|
]);
|
|
105
105
|
/**
|
|
@@ -108,7 +108,7 @@ const kt = X("ChevronDown", [
|
|
|
108
108
|
* This source code is licensed under the ISC license.
|
|
109
109
|
* See the LICENSE file in the root directory of this source tree.
|
|
110
110
|
*/
|
|
111
|
-
const
|
|
111
|
+
const Ct = G("ChevronRight", [
|
|
112
112
|
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
|
|
113
113
|
]);
|
|
114
114
|
/**
|
|
@@ -117,7 +117,7 @@ const wt = X("ChevronRight", [
|
|
|
117
117
|
* This source code is licensed under the ISC license.
|
|
118
118
|
* See the LICENSE file in the root directory of this source tree.
|
|
119
119
|
*/
|
|
120
|
-
const
|
|
120
|
+
const It = G("CircleAlert", [
|
|
121
121
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
122
122
|
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
|
|
123
123
|
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
|
|
@@ -128,7 +128,7 @@ const St = X("CircleAlert", [
|
|
|
128
128
|
* This source code is licensed under the ISC license.
|
|
129
129
|
* See the LICENSE file in the root directory of this source tree.
|
|
130
130
|
*/
|
|
131
|
-
const
|
|
131
|
+
const dt = G("Ellipsis", [
|
|
132
132
|
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
|
|
133
133
|
["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
|
|
134
134
|
["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
|
|
@@ -139,7 +139,7 @@ const at = X("Ellipsis", [
|
|
|
139
139
|
* This source code is licensed under the ISC license.
|
|
140
140
|
* See the LICENSE file in the root directory of this source tree.
|
|
141
141
|
*/
|
|
142
|
-
const
|
|
142
|
+
const zt = G("Image", [
|
|
143
143
|
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
|
|
144
144
|
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
|
|
145
145
|
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
|
|
@@ -150,7 +150,7 @@ const Ct = X("Image", [
|
|
|
150
150
|
* This source code is licensed under the ISC license.
|
|
151
151
|
* See the LICENSE file in the root directory of this source tree.
|
|
152
152
|
*/
|
|
153
|
-
const
|
|
153
|
+
const Tt = G("Inbox", [
|
|
154
154
|
["polyline", { points: "22 12 16 12 14 15 10 15 8 12 2 12", key: "o97t9d" }],
|
|
155
155
|
[
|
|
156
156
|
"path",
|
|
@@ -166,7 +166,7 @@ const It = X("Inbox", [
|
|
|
166
166
|
* This source code is licensed under the ISC license.
|
|
167
167
|
* See the LICENSE file in the root directory of this source tree.
|
|
168
168
|
*/
|
|
169
|
-
const
|
|
169
|
+
const Rt = G("Info", [
|
|
170
170
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
171
171
|
["path", { d: "M12 16v-4", key: "1dtifu" }],
|
|
172
172
|
["path", { d: "M12 8h.01", key: "e9boi3" }]
|
|
@@ -177,7 +177,7 @@ const zt = X("Info", [
|
|
|
177
177
|
* This source code is licensed under the ISC license.
|
|
178
178
|
* See the LICENSE file in the root directory of this source tree.
|
|
179
179
|
*/
|
|
180
|
-
const
|
|
180
|
+
const ct = G("LoaderCircle", [
|
|
181
181
|
["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
|
|
182
182
|
]);
|
|
183
183
|
/**
|
|
@@ -186,7 +186,16 @@ const lt = X("LoaderCircle", [
|
|
|
186
186
|
* This source code is licensed under the ISC license.
|
|
187
187
|
* See the LICENSE file in the root directory of this source tree.
|
|
188
188
|
*/
|
|
189
|
-
const
|
|
189
|
+
const Ye = G("MessageCircle", [
|
|
190
|
+
["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
|
|
191
|
+
]);
|
|
192
|
+
/**
|
|
193
|
+
* @license lucide-react v0.468.0 - ISC
|
|
194
|
+
*
|
|
195
|
+
* This source code is licensed under the ISC license.
|
|
196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
+
*/
|
|
198
|
+
const Wt = G("Paperclip", [
|
|
190
199
|
["path", { d: "M13.234 20.252 21 12.3", key: "1cbrk9" }],
|
|
191
200
|
[
|
|
192
201
|
"path",
|
|
@@ -202,7 +211,7 @@ const Tt = X("Paperclip", [
|
|
|
202
211
|
* This source code is licensed under the ISC license.
|
|
203
212
|
* See the LICENSE file in the root directory of this source tree.
|
|
204
213
|
*/
|
|
205
|
-
const
|
|
214
|
+
const Bt = G("Play", [
|
|
206
215
|
["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
|
|
207
216
|
]);
|
|
208
217
|
/**
|
|
@@ -211,7 +220,7 @@ const Rt = X("Play", [
|
|
|
211
220
|
* This source code is licensed under the ISC license.
|
|
212
221
|
* See the LICENSE file in the root directory of this source tree.
|
|
213
222
|
*/
|
|
214
|
-
const
|
|
223
|
+
const Je = G("Search", [
|
|
215
224
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
|
|
216
225
|
["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
|
|
217
226
|
]);
|
|
@@ -221,7 +230,7 @@ const Xe = X("Search", [
|
|
|
221
230
|
* This source code is licensed under the ISC license.
|
|
222
231
|
* See the LICENSE file in the root directory of this source tree.
|
|
223
232
|
*/
|
|
224
|
-
const
|
|
233
|
+
const $t = G("Send", [
|
|
225
234
|
[
|
|
226
235
|
"path",
|
|
227
236
|
{
|
|
@@ -237,7 +246,7 @@ const Bt = X("Send", [
|
|
|
237
246
|
* This source code is licensed under the ISC license.
|
|
238
247
|
* See the LICENSE file in the root directory of this source tree.
|
|
239
248
|
*/
|
|
240
|
-
const
|
|
249
|
+
const Lt = G("SlidersHorizontal", [
|
|
241
250
|
["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
|
|
242
251
|
["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
|
|
243
252
|
["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
|
|
@@ -254,7 +263,7 @@ const Wt = X("SlidersHorizontal", [
|
|
|
254
263
|
* This source code is licensed under the ISC license.
|
|
255
264
|
* See the LICENSE file in the root directory of this source tree.
|
|
256
265
|
*/
|
|
257
|
-
const
|
|
266
|
+
const Mt = G("Smile", [
|
|
258
267
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
259
268
|
["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
|
|
260
269
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
@@ -266,7 +275,7 @@ const $t = X("Smile", [
|
|
|
266
275
|
* This source code is licensed under the ISC license.
|
|
267
276
|
* See the LICENSE file in the root directory of this source tree.
|
|
268
277
|
*/
|
|
269
|
-
const je =
|
|
278
|
+
const je = G("X", [
|
|
270
279
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
271
280
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
272
281
|
]);
|
|
@@ -276,7 +285,7 @@ const je = X("X", [
|
|
|
276
285
|
* This source code is licensed under the ISC license.
|
|
277
286
|
* See the LICENSE file in the root directory of this source tree.
|
|
278
287
|
*/
|
|
279
|
-
const
|
|
288
|
+
const Ht = G("Zap", [
|
|
280
289
|
[
|
|
281
290
|
"path",
|
|
282
291
|
{
|
|
@@ -285,7 +294,7 @@ const Lt = X("Zap", [
|
|
|
285
294
|
}
|
|
286
295
|
]
|
|
287
296
|
]);
|
|
288
|
-
class
|
|
297
|
+
class st {
|
|
289
298
|
constructor(i, r) {
|
|
290
299
|
this.apiUrl = i, this.token = r;
|
|
291
300
|
}
|
|
@@ -294,12 +303,12 @@ class Mt {
|
|
|
294
303
|
authorization: `Bearer ${this.token}`,
|
|
295
304
|
...o ? {} : { "content-type": "application/json" },
|
|
296
305
|
...r == null ? void 0 : r.headers
|
|
297
|
-
},
|
|
306
|
+
}, k = await fetch(`${this.apiUrl}${i}`, {
|
|
298
307
|
...r,
|
|
299
308
|
headers: s
|
|
300
|
-
}),
|
|
301
|
-
if (!
|
|
302
|
-
return
|
|
309
|
+
}), g = await k.json().catch(() => null);
|
|
310
|
+
if (!k.ok) throw new Error((g == null ? void 0 : g.message) ?? `Request failed (${k.status})`);
|
|
311
|
+
return g;
|
|
303
312
|
}
|
|
304
313
|
listConnections() {
|
|
305
314
|
return this.request("/v1/connections");
|
|
@@ -356,38 +365,38 @@ class Mt {
|
|
|
356
365
|
}
|
|
357
366
|
connectSSE(i) {
|
|
358
367
|
const r = `${this.apiUrl}/v1/events?token=${encodeURIComponent(this.token)}`;
|
|
359
|
-
let o, s,
|
|
360
|
-
const
|
|
361
|
-
o = new EventSource(r), o.addEventListener("message.new", (
|
|
362
|
-
i("message.new", JSON.parse(
|
|
363
|
-
}), o.addEventListener("conversation.updated", (
|
|
364
|
-
i("conversation.updated", JSON.parse(
|
|
368
|
+
let o, s, k = !1;
|
|
369
|
+
const g = () => {
|
|
370
|
+
o = new EventSource(r), o.addEventListener("message.new", ($) => {
|
|
371
|
+
i("message.new", JSON.parse($.data));
|
|
372
|
+
}), o.addEventListener("conversation.updated", ($) => {
|
|
373
|
+
i("conversation.updated", JSON.parse($.data));
|
|
365
374
|
}), o.onerror = () => {
|
|
366
|
-
o.close(),
|
|
375
|
+
o.close(), k || (s = setTimeout(g, 5e3));
|
|
367
376
|
};
|
|
368
377
|
};
|
|
369
|
-
return
|
|
370
|
-
|
|
378
|
+
return g(), () => {
|
|
379
|
+
k = !0, clearTimeout(s), o == null || o.close();
|
|
371
380
|
};
|
|
372
381
|
}
|
|
373
382
|
}
|
|
374
|
-
function
|
|
383
|
+
function qe({ src: t, alt: i = "", fallback: r, style: o }) {
|
|
375
384
|
return t ? /* @__PURE__ */ e("img", { src: t, alt: i, style: { width: 38, height: 38, borderRadius: "50%", objectFit: "cover", ...o } }) : /* @__PURE__ */ e("span", { style: { display: "grid", placeItems: "center", width: 38, height: 38, borderRadius: "50%", ...o }, children: r });
|
|
376
385
|
}
|
|
377
|
-
function
|
|
386
|
+
function Et({ variant: t = "ghost", style: i, ...r }) {
|
|
378
387
|
return /* @__PURE__ */ e("button", { ...r, style: { display: "inline-flex", alignItems: "center", justifyContent: "center", border: t === "outline" ? "1px solid #e7ebf2" : 0, borderRadius: 8, cursor: "pointer", font: "inherit", background: t === "default" ? "#2563eb" : "transparent", ...i } });
|
|
379
388
|
}
|
|
380
|
-
function
|
|
389
|
+
function jt({ style: t, ...i }) {
|
|
381
390
|
return /* @__PURE__ */ e("input", { ...i, style: { width: "100%", minWidth: 0, border: 0, outline: 0, background: "transparent", font: "inherit", ...t } });
|
|
382
391
|
}
|
|
383
|
-
const
|
|
392
|
+
const ht = Le(
|
|
384
393
|
({ children: t, style: i }, r) => /* @__PURE__ */ e("div", { ref: r, style: { minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", ...i }, children: t })
|
|
385
|
-
),
|
|
394
|
+
), At = Le(
|
|
386
395
|
function({ style: i, ...r }, o) {
|
|
387
396
|
return /* @__PURE__ */ e("textarea", { ref: o, ...r, style: { display: "block", width: "100%", minWidth: 0, boxSizing: "border-box", resize: "vertical", border: 0, outline: 0, background: "transparent", font: "inherit", ...i } });
|
|
388
397
|
}
|
|
389
398
|
);
|
|
390
|
-
function
|
|
399
|
+
function Ot(t) {
|
|
391
400
|
return {
|
|
392
401
|
id: t.contactId ?? t.providerConversationKey,
|
|
393
402
|
name: t.contactName,
|
|
@@ -399,7 +408,7 @@ function At(t) {
|
|
|
399
408
|
function Ae(t, i) {
|
|
400
409
|
return {
|
|
401
410
|
conversation: t,
|
|
402
|
-
contact:
|
|
411
|
+
contact: Ot(t),
|
|
403
412
|
provider: i == null ? void 0 : i.provider,
|
|
404
413
|
recentMessages: i == null ? void 0 : i.recentMessages,
|
|
405
414
|
linkContact: (i == null ? void 0 : i.linkContact) ?? (async () => {
|
|
@@ -410,7 +419,7 @@ function Ae(t, i) {
|
|
|
410
419
|
})
|
|
411
420
|
};
|
|
412
421
|
}
|
|
413
|
-
class
|
|
422
|
+
class Dt extends xt {
|
|
414
423
|
constructor() {
|
|
415
424
|
super(...arguments), this.state = { caught: !1 };
|
|
416
425
|
}
|
|
@@ -421,14 +430,14 @@ class Ot extends mt {
|
|
|
421
430
|
return this.state.caught ? null : this.props.children;
|
|
422
431
|
}
|
|
423
432
|
}
|
|
424
|
-
const d = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc", white: "#fff" },
|
|
433
|
+
const d = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc", white: "#fff" }, Ze = [
|
|
425
434
|
{ icon: "😊", emojis: ["😀", "😁", "😂", "🤣", "😊", "😇", "🙂", "😉", "😍", "🥰", "😘", "😋", "😎", "🤩", "😏", "😒", "😔", "😢", "😭", "😤", "😠", "🤯", "😱", "🥳", "😴", "🤔", "🤗", "🫡", "😮", "🤧", "🥺", "😶", "🫠", "🤭", "🤫"] },
|
|
426
435
|
{ icon: "👋", emojis: ["👍", "👎", "👏", "🙏", "🤝", "✌️", "🤞", "🫡", "💪", "🤜", "👊", "✊", "🖐", "👌", "🤌", "🤏", "☝️", "👆", "👇", "👉", "👈", "🤙", "💅", "🫶", "❤️", "🧡", "💛", "💚", "💙", "💜", "🖤", "💔", "❣️", "💕", "💯"] },
|
|
427
436
|
{ icon: "🐱", emojis: ["🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯", "🦁", "🐮", "🐷", "🐸", "🐵", "🙈", "🐔", "🐧", "🐦", "🦆", "🦅", "🦉", "🦋", "🐝", "🐛", "🐢", "🦎", "🐬", "🦈", "🐳", "🐙", "🦑"] },
|
|
428
437
|
{ icon: "🍕", emojis: ["🍎", "🍊", "🍋", "🍇", "🍓", "🍒", "🥝", "🥑", "🍔", "🍕", "🌮", "🍜", "🍣", "🍦", "🎂", "🍰", "🧁", "☕", "🧋", "🥤", "🍺", "🥂", "🍾", "🧃", "🧊"] },
|
|
429
438
|
{ icon: "⚽", emojis: ["⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏓", "🎮", "🎲", "🎯", "🎳", "🏆", "🥇", "🎖", "🎁", "🎉", "🎊", "🎈", "🎭", "🎨", "🎬", "🎵", "🎸", "🎹", "🎺", "🪗", "🎻"] },
|
|
430
439
|
{ icon: "🌍", emojis: ["🌍", "🌈", "⭐", "🌙", "☀️", "⛅", "🌊", "🔥", "💧", "🌿", "🌸", "🌺", "🌻", "🍀", "🌴", "🏔", "🏖", "🏕", "🌃", "🏙", "🌅", "🌄", "🌠", "🌌", "🌋", "🏝"] }
|
|
431
|
-
],
|
|
440
|
+
], Ve = rt(""), pt = rt("");
|
|
432
441
|
function Ut() {
|
|
433
442
|
try {
|
|
434
443
|
const t = new AudioContext(), i = t.createOscillator(), r = t.createGain();
|
|
@@ -436,18 +445,18 @@ function Ut() {
|
|
|
436
445
|
} catch {
|
|
437
446
|
}
|
|
438
447
|
}
|
|
439
|
-
function
|
|
448
|
+
function Pt(t) {
|
|
440
449
|
if (!(t != null && t.metadata)) return;
|
|
441
450
|
const i = t.metadata, r = i.pageName ?? i.displayName ?? i.username ?? i.name;
|
|
442
451
|
return typeof r == "string" && r ? r : void 0;
|
|
443
452
|
}
|
|
444
|
-
function
|
|
453
|
+
function ut(t) {
|
|
445
454
|
return t === "facebook" ? "Facebook Messenger" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo OA" : t === "livechat" ? "Live Chat" : "Channel";
|
|
446
455
|
}
|
|
447
|
-
function
|
|
456
|
+
function _e(t) {
|
|
448
457
|
return t === "facebook" ? "Facebook" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo" : t === "livechat" ? "Live Chat" : String(t ?? "");
|
|
449
458
|
}
|
|
450
|
-
const
|
|
459
|
+
const Nt = (t) => {
|
|
451
460
|
var r;
|
|
452
461
|
const i = {
|
|
453
462
|
"application/pdf": "PDF",
|
|
@@ -458,85 +467,85 @@ const Pt = (t) => {
|
|
|
458
467
|
};
|
|
459
468
|
return t ? i[t] ?? ((r = t.split("/")[1]) == null ? void 0 : r.toUpperCase()) ?? "Tệp" : "Tệp đính kèm";
|
|
460
469
|
};
|
|
461
|
-
function
|
|
462
|
-
return t === "read" ? /* @__PURE__ */ e(
|
|
470
|
+
function Qe({ status: t }) {
|
|
471
|
+
return t === "read" ? /* @__PURE__ */ e(Xe, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : t === "delivered" ? /* @__PURE__ */ e(Xe, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle", opacity: 0.5 } }) : t === "sent" ? /* @__PURE__ */ e(lt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : null;
|
|
463
472
|
}
|
|
464
|
-
const
|
|
465
|
-
var
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
}, []),
|
|
469
|
-
|
|
470
|
-
}, []),
|
|
471
|
-
const
|
|
472
|
-
return ["facebook", "instagram", "telegram", "zalo", "livechat"].filter((u) =>
|
|
473
|
-
}, [
|
|
473
|
+
const yn = Le(function({ apiUrl: i, token: r, theme: o, height: s, defaultConversationId: k, disableAttachments: g, disableNotificationSound: $, hideKeyboardHint: f, locale: x = "vi", extensions: R, onNewMessage: I, onConversationSelect: E }, W) {
|
|
474
|
+
var l, m, v, A, Q;
|
|
475
|
+
const O = Z(new st(i, r)), [D, L] = y([]), [P, K] = y([]), [ee, U] = y(), [S, z] = y(), b = Z(void 0), [T, ie] = y(""), [B, N] = y({ provider: "all", unreadOnly: !1 }), [de, C] = y(!1), te = Z(null), q = Z(null), [w, _] = y(null), [he, h] = y(!0), [H, F] = y(""), [X, re] = y(() => !!(R != null && R.length)), [oe, Y] = y(280), [ye, we] = y(!1), [me, fe] = y(0), J = (o == null ? void 0 : o.primaryColor) ?? "#2563eb", ce = Ee(() => new Map(P.map((c) => [c.id, c])), [P]), be = Z(null), [Se, Oe] = y(0), Ce = ke(async (c, u) => {
|
|
476
|
+
c.contactId && await O.current.patchContact(c.contactId, u), L((M) => M.map((j) => j.id === c.id ? { ...j, contactExternalId: u ?? void 0 } : j)), z((M) => M && M.id === c.id ? { ...M, contactExternalId: u ?? void 0 } : M), fe((M) => M + 1);
|
|
477
|
+
}, []), Ie = ke(() => {
|
|
478
|
+
fe((c) => c + 1);
|
|
479
|
+
}, []), ze = Ee(() => {
|
|
480
|
+
const c = new Set(P.map((u) => u.provider));
|
|
481
|
+
return ["facebook", "instagram", "telegram", "zalo", "livechat"].filter((u) => c.has(u));
|
|
482
|
+
}, [P]), ue = Ee(() => {
|
|
474
483
|
var u;
|
|
475
|
-
const
|
|
476
|
-
for (const
|
|
477
|
-
const
|
|
478
|
-
|
|
484
|
+
const c = {};
|
|
485
|
+
for (const M of D) {
|
|
486
|
+
const j = ((u = ce.get(M.connectionId)) == null ? void 0 : u.provider) ?? "unknown";
|
|
487
|
+
c[j] = (c[j] ?? 0) + 1;
|
|
479
488
|
}
|
|
480
|
-
return
|
|
481
|
-
}, [
|
|
482
|
-
function Me(
|
|
483
|
-
const u =
|
|
484
|
-
|
|
485
|
-
function
|
|
486
|
-
const
|
|
487
|
-
|
|
489
|
+
return c;
|
|
490
|
+
}, [D, ce]);
|
|
491
|
+
function Me(c) {
|
|
492
|
+
const u = c.clientX, M = oe;
|
|
493
|
+
we(!0), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
494
|
+
function j(xe) {
|
|
495
|
+
const We = Math.max(200, Math.min(480, M + (u - xe.clientX)));
|
|
496
|
+
Y(We);
|
|
488
497
|
}
|
|
489
|
-
function
|
|
490
|
-
|
|
498
|
+
function se() {
|
|
499
|
+
we(!1), document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", j), document.removeEventListener("mouseup", se);
|
|
491
500
|
}
|
|
492
|
-
document.addEventListener("mousemove",
|
|
501
|
+
document.addEventListener("mousemove", j), document.addEventListener("mouseup", se);
|
|
493
502
|
}
|
|
494
|
-
const
|
|
503
|
+
const ae = ke(async (c) => {
|
|
495
504
|
try {
|
|
496
|
-
const u = await
|
|
497
|
-
|
|
505
|
+
const u = await O.current.listConversations(c);
|
|
506
|
+
L((M) => c ? [...M, ...u.items] : u.items), U(u.nextCursor), !c && u.items.length && z((M) => M ?? (k ? u.items.find((j) => j.id === k) ?? u.items[0] : u.items[0])), F("");
|
|
498
507
|
} catch (u) {
|
|
499
|
-
|
|
508
|
+
F(u instanceof Error ? u.message : "Không tải được hội thoại");
|
|
500
509
|
} finally {
|
|
501
510
|
h(!1);
|
|
502
511
|
}
|
|
503
|
-
}, [
|
|
504
|
-
|
|
505
|
-
}),
|
|
512
|
+
}, [k]);
|
|
513
|
+
V(() => (O.current.listConnections().then(K).catch(() => {
|
|
514
|
+
}), ae(), O.current.connectSSE((u, M) => {
|
|
506
515
|
if (u === "message.new" || u === "conversation.updated") {
|
|
507
|
-
if (
|
|
508
|
-
const
|
|
509
|
-
if ((
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
516
|
+
if (ae(), u === "message.new") {
|
|
517
|
+
const j = typeof M == "object" && M ? M : {}, se = j.conversationId ? String(j.conversationId) : "", xe = j.messageId ? String(j.messageId) : "";
|
|
518
|
+
if ((j.direction ? String(j.direction) : "") === "inbound" && !$ && Ut(), se && se === b.current && xe && be.current) {
|
|
519
|
+
const yt = be.current;
|
|
520
|
+
O.current.getMessage(xe).then((bt) => {
|
|
521
|
+
yt(bt);
|
|
513
522
|
}).catch(() => {
|
|
514
523
|
});
|
|
515
524
|
}
|
|
516
|
-
I == null || I(
|
|
525
|
+
I == null || I(se || b.current || "");
|
|
517
526
|
}
|
|
518
|
-
} else u === "message.status_updated" && Oe((
|
|
519
|
-
})), [
|
|
520
|
-
|
|
521
|
-
}, [
|
|
522
|
-
|
|
527
|
+
} else u === "message.status_updated" && Oe((j) => j + 1);
|
|
528
|
+
})), [ae, I]), V(() => {
|
|
529
|
+
b.current = S == null ? void 0 : S.id;
|
|
530
|
+
}, [S]), V(() => {
|
|
531
|
+
S != null && S.unreadCount && O.current.markRead(S.id).then(() => ae()).catch(() => {
|
|
523
532
|
});
|
|
524
|
-
}, [
|
|
525
|
-
if (!
|
|
526
|
-
function
|
|
527
|
-
var
|
|
528
|
-
(
|
|
533
|
+
}, [S == null ? void 0 : S.id]), V(() => {
|
|
534
|
+
if (!de) return;
|
|
535
|
+
function c(u) {
|
|
536
|
+
var M, j;
|
|
537
|
+
(M = te.current) != null && M.contains(u.target) || (j = q.current) != null && j.contains(u.target) || C(!1);
|
|
529
538
|
}
|
|
530
|
-
return document.addEventListener("mousedown",
|
|
531
|
-
}, [
|
|
532
|
-
const
|
|
533
|
-
const
|
|
534
|
-
return
|
|
535
|
-
var
|
|
536
|
-
const
|
|
537
|
-
return
|
|
539
|
+
return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
|
|
540
|
+
}, [de]);
|
|
541
|
+
const Te = Ee(() => {
|
|
542
|
+
const c = T.toLowerCase().trim();
|
|
543
|
+
return D.filter((u) => {
|
|
544
|
+
var We;
|
|
545
|
+
const M = `${u.contactName ?? ""} ${u.subject ?? ""} ${u.providerConversationKey}`.toLowerCase(), j = ((We = ce.get(u.connectionId)) == null ? void 0 : We.provider) ?? "unknown", se = B.provider === "all" || j === B.provider, xe = !B.unreadOnly || (u.unreadCount ?? 0) > 0;
|
|
546
|
+
return se && xe && (!c || M.includes(c));
|
|
538
547
|
});
|
|
539
|
-
}, [
|
|
548
|
+
}, [D, ce, B, T]), Re = B.provider !== "all" || B.unreadOnly, le = x === "en" ? {
|
|
540
549
|
today: "TODAY",
|
|
541
550
|
loadOlder: "↑ Load older messages",
|
|
542
551
|
loading: "Loading messages…",
|
|
@@ -557,315 +566,315 @@ const pn = Le(function({ apiUrl: i, token: r, theme: o, height: s, defaultConver
|
|
|
557
566
|
send: "Gửi",
|
|
558
567
|
all: "Tất cả"
|
|
559
568
|
};
|
|
560
|
-
|
|
561
|
-
openConversation: (
|
|
562
|
-
const u =
|
|
563
|
-
u &&
|
|
569
|
+
mt(W, () => ({
|
|
570
|
+
openConversation: (c) => {
|
|
571
|
+
const u = D.find((M) => M.id === c);
|
|
572
|
+
u && z(u);
|
|
564
573
|
},
|
|
565
|
-
refresh: () => void
|
|
566
|
-
}), [
|
|
574
|
+
refresh: () => void ae()
|
|
575
|
+
}), [D, ae]);
|
|
567
576
|
const He = {
|
|
568
577
|
...p.frame,
|
|
569
578
|
height: s ?? 620,
|
|
570
579
|
...s ? { maxHeight: "none" } : {},
|
|
571
580
|
fontFamily: (o == null ? void 0 : o.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif",
|
|
572
581
|
borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px",
|
|
573
|
-
gridTemplateColumns:
|
|
582
|
+
gridTemplateColumns: X ? `minmax(260px, 300px) minmax(0, 1fr) ${oe}px` : "minmax(260px, 300px) minmax(0, 1fr)",
|
|
574
583
|
transition: ye ? "none" : "grid-template-columns 220ms ease"
|
|
575
584
|
};
|
|
576
|
-
return
|
|
585
|
+
return he ? /* @__PURE__ */ n("div", { style: { ...p.state, borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
|
|
577
586
|
/* @__PURE__ */ e(Fe, {}),
|
|
578
587
|
" Đang tải hộp thư…"
|
|
579
|
-
] }) :
|
|
580
|
-
/* @__PURE__ */ e(
|
|
588
|
+
] }) : H && !D.length ? /* @__PURE__ */ n("div", { style: { ...p.state, color: "#b42318", borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
|
|
589
|
+
/* @__PURE__ */ e(It, { size: 16, strokeWidth: 2 }),
|
|
581
590
|
" ",
|
|
582
|
-
|
|
591
|
+
H,
|
|
583
592
|
/* @__PURE__ */ e("button", { style: p.retry, onClick: () => {
|
|
584
|
-
h(!0),
|
|
593
|
+
h(!0), ae();
|
|
585
594
|
}, children: "Thử lại" })
|
|
586
|
-
] }) : /* @__PURE__ */ e(
|
|
587
|
-
const
|
|
595
|
+
] }) : /* @__PURE__ */ e(Ve.Provider, { value: i, children: /* @__PURE__ */ e(pt.Provider, { value: r, children: /* @__PURE__ */ n("div", { style: He, onFocusCapture: () => {
|
|
596
|
+
const c = window.scrollY;
|
|
588
597
|
requestAnimationFrame(() => {
|
|
589
|
-
window.scrollY !==
|
|
598
|
+
window.scrollY !== c && window.scrollTo({ top: c, behavior: "instant" });
|
|
590
599
|
});
|
|
591
600
|
}, children: [
|
|
592
601
|
/* @__PURE__ */ n("aside", { style: p.sidebar, children: [
|
|
593
602
|
/* @__PURE__ */ n("div", { style: p.brand, children: [
|
|
594
|
-
/* @__PURE__ */ e("div", { style: { ...p.brandMark, background:
|
|
603
|
+
/* @__PURE__ */ e("div", { style: { ...p.brandMark, background: J, overflow: "hidden", padding: 0 }, children: (l = o == null ? void 0 : o.branding) != null && l.logoUrl ? /* @__PURE__ */ e("img", { src: o.branding.logoUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : ((m = o == null ? void 0 : o.branding) == null ? void 0 : m.mark) ?? "C" }),
|
|
595
604
|
/* @__PURE__ */ n("div", { children: [
|
|
596
|
-
/* @__PURE__ */ e("strong", { children: ((
|
|
597
|
-
!((
|
|
605
|
+
/* @__PURE__ */ e("strong", { children: ((v = o == null ? void 0 : o.branding) == null ? void 0 : v.name) ?? "Hộp thư" }),
|
|
606
|
+
!((A = o == null ? void 0 : o.branding) != null && A.name) && /* @__PURE__ */ e("span", { style: p.eyebrow, children: "CHANNELHUB" })
|
|
598
607
|
] }),
|
|
599
|
-
/* @__PURE__ */ e(
|
|
608
|
+
/* @__PURE__ */ e(Et, { "aria-label": "Tùy chọn", style: p.iconButton, children: /* @__PURE__ */ e(dt, { size: 16, strokeWidth: 2 }) })
|
|
600
609
|
] }),
|
|
601
610
|
/* @__PURE__ */ n("div", { style: p.search, children: [
|
|
602
|
-
/* @__PURE__ */ e(
|
|
603
|
-
/* @__PURE__ */ e(
|
|
604
|
-
|
|
611
|
+
/* @__PURE__ */ e(Je, { size: 16, strokeWidth: 2 }),
|
|
612
|
+
/* @__PURE__ */ e(jt, { "aria-label": le.searchPlaceholder, value: T, onChange: (c) => ie(c.target.value), placeholder: le.searchPlaceholder }),
|
|
613
|
+
T && /* @__PURE__ */ e("button", { style: p.clear, onClick: () => ie(""), "aria-label": "Xóa tìm kiếm", children: "×" })
|
|
605
614
|
] }),
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
/* @__PURE__ */ e($e, { provider:
|
|
609
|
-
|
|
610
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color:
|
|
615
|
+
Re && /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", padding: "0 14px 8px" }, children: [
|
|
616
|
+
B.provider !== "all" && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: J, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
|
|
617
|
+
/* @__PURE__ */ e($e, { provider: B.provider }),
|
|
618
|
+
_e(B.provider),
|
|
619
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: J, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => N((c) => ({ ...c, provider: "all" })), "aria-label": "Xóa filter kênh", children: /* @__PURE__ */ e(je, { size: 10 }) })
|
|
611
620
|
] }),
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color:
|
|
621
|
+
B.unreadOnly && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: J, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
|
|
622
|
+
le.unreadOnly,
|
|
623
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: J, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => N((c) => ({ ...c, unreadOnly: !1 })), "aria-label": "Xóa filter chưa đọc", children: /* @__PURE__ */ e(je, { size: 10 }) })
|
|
615
624
|
] }),
|
|
616
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: d.muted, fontSize: 11, padding: "2px 4px" }, onClick: () =>
|
|
625
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: d.muted, fontSize: 11, padding: "2px 4px" }, onClick: () => N({ provider: "all", unreadOnly: !1 }), children: "Xóa tất cả" })
|
|
617
626
|
] }),
|
|
618
627
|
/* @__PURE__ */ n("div", { style: p.listHeader, children: [
|
|
619
628
|
/* @__PURE__ */ n("span", { children: [
|
|
620
|
-
|
|
629
|
+
Te.length,
|
|
621
630
|
" hội thoại"
|
|
622
631
|
] }),
|
|
623
632
|
/* @__PURE__ */ e(
|
|
624
633
|
"button",
|
|
625
634
|
{
|
|
626
|
-
ref:
|
|
627
|
-
style: { ...p.iconButton, background:
|
|
635
|
+
ref: te,
|
|
636
|
+
style: { ...p.iconButton, background: Re ? `${J}14` : "transparent", color: Re ? J : d.muted },
|
|
628
637
|
"aria-label": "Bộ lọc",
|
|
629
638
|
onClick: () => {
|
|
630
|
-
var
|
|
631
|
-
if (!
|
|
632
|
-
const u = (
|
|
633
|
-
u &&
|
|
639
|
+
var c;
|
|
640
|
+
if (!de) {
|
|
641
|
+
const u = (c = te.current) == null ? void 0 : c.getBoundingClientRect();
|
|
642
|
+
u && _({ top: u.bottom + 6, left: u.left });
|
|
634
643
|
}
|
|
635
|
-
|
|
644
|
+
C((u) => !u);
|
|
636
645
|
},
|
|
637
|
-
children: /* @__PURE__ */ e(
|
|
646
|
+
children: /* @__PURE__ */ e(Lt, { size: 15, strokeWidth: 2 })
|
|
638
647
|
}
|
|
639
648
|
)
|
|
640
649
|
] }),
|
|
641
|
-
|
|
650
|
+
de && w && ot(
|
|
642
651
|
/* @__PURE__ */ n(
|
|
643
652
|
"div",
|
|
644
653
|
{
|
|
645
|
-
ref:
|
|
646
|
-
style: { position: "fixed", top:
|
|
654
|
+
ref: q,
|
|
655
|
+
style: { position: "fixed", top: w.top, left: w.left, zIndex: 9999, background: d.white, border: `1px solid ${d.line}`, borderRadius: 10, padding: "12px 14px", boxShadow: "0 8px 24px rgba(23,32,51,.14)", minWidth: 210, fontFamily: (o == null ? void 0 : o.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif", fontSize: 13 },
|
|
647
656
|
children: [
|
|
648
657
|
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, color: d.muted, letterSpacing: 1, textTransform: "uppercase", marginBottom: 8 }, children: "Kênh" }),
|
|
649
|
-
["all", ...
|
|
650
|
-
/* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked:
|
|
651
|
-
|
|
652
|
-
|
|
658
|
+
["all", ...ze].map((c) => /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: B.provider === c ? `${J}0f` : "transparent" }, children: [
|
|
659
|
+
/* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked: B.provider === c, onChange: () => N((u) => ({ ...u, provider: c })), style: { accentColor: J } }),
|
|
660
|
+
c === "all" ? /* @__PURE__ */ n("span", { style: { color: d.ink }, children: [
|
|
661
|
+
le.all,
|
|
653
662
|
" (",
|
|
654
|
-
|
|
663
|
+
D.length,
|
|
655
664
|
")"
|
|
656
665
|
] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color: d.ink }, children: [
|
|
657
|
-
/* @__PURE__ */ e($e, { provider:
|
|
658
|
-
|
|
666
|
+
/* @__PURE__ */ e($e, { provider: c }),
|
|
667
|
+
_e(c),
|
|
659
668
|
" ",
|
|
660
669
|
/* @__PURE__ */ n("span", { style: { color: d.muted }, children: [
|
|
661
670
|
"(",
|
|
662
|
-
|
|
671
|
+
ue[c] ?? 0,
|
|
663
672
|
")"
|
|
664
673
|
] })
|
|
665
674
|
] })
|
|
666
|
-
] },
|
|
675
|
+
] }, c)),
|
|
667
676
|
/* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${d.line}`, margin: "8px 0 6px" } }),
|
|
668
|
-
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background:
|
|
669
|
-
/* @__PURE__ */ e("input", { type: "checkbox", checked:
|
|
670
|
-
/* @__PURE__ */ e("span", { style: { color: d.ink }, children:
|
|
677
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: B.unreadOnly ? `${J}0f` : "transparent" }, children: [
|
|
678
|
+
/* @__PURE__ */ e("input", { type: "checkbox", checked: B.unreadOnly, onChange: (c) => N((u) => ({ ...u, unreadOnly: c.target.checked })), style: { accentColor: J } }),
|
|
679
|
+
/* @__PURE__ */ e("span", { style: { color: d.ink }, children: le.unreadOnly })
|
|
671
680
|
] })
|
|
672
681
|
]
|
|
673
682
|
}
|
|
674
683
|
),
|
|
675
684
|
document.body
|
|
676
685
|
),
|
|
677
|
-
/* @__PURE__ */ n(
|
|
678
|
-
|
|
686
|
+
/* @__PURE__ */ n(ht, { style: p.conversationList, children: [
|
|
687
|
+
Te.map((c) => {
|
|
679
688
|
var u;
|
|
680
|
-
return /* @__PURE__ */ e(
|
|
681
|
-
|
|
689
|
+
return /* @__PURE__ */ e(Ft, { conversation: c, provider: (u = ce.get(c.connectionId)) == null ? void 0 : u.provider, selected: (S == null ? void 0 : S.id) === c.id, primary: J, onSelect: () => {
|
|
690
|
+
z(c), E == null || E(c.id), O.current.markRead(c.id).then(() => ae()).catch(() => {
|
|
682
691
|
});
|
|
683
|
-
} },
|
|
692
|
+
} }, c.id);
|
|
684
693
|
}),
|
|
685
|
-
!
|
|
686
|
-
/* @__PURE__ */ e("div", { style: p.emptyIcon, children: /* @__PURE__ */ e(
|
|
694
|
+
!Te.length && /* @__PURE__ */ n("div", { style: p.emptySmall, children: [
|
|
695
|
+
/* @__PURE__ */ e("div", { style: p.emptyIcon, children: /* @__PURE__ */ e(Je, { size: 16, strokeWidth: 2 }) }),
|
|
687
696
|
/* @__PURE__ */ e("strong", { children: "Không tìm thấy" }),
|
|
688
697
|
/* @__PURE__ */ e("span", { children: "Thử từ khóa hoặc bộ lọc khác." })
|
|
689
698
|
] }),
|
|
690
|
-
|
|
699
|
+
ee && /* @__PURE__ */ e("button", { style: p.loadMore, onClick: () => void ae(ee), children: "Xem thêm hội thoại" })
|
|
691
700
|
] })
|
|
692
701
|
] }),
|
|
693
|
-
/* @__PURE__ */ e("main", { style: p.main, children:
|
|
694
|
-
|
|
702
|
+
/* @__PURE__ */ e("main", { style: p.main, children: S ? /* @__PURE__ */ e(
|
|
703
|
+
Kt,
|
|
695
704
|
{
|
|
696
|
-
conversation:
|
|
697
|
-
provider: (
|
|
698
|
-
connection:
|
|
699
|
-
client:
|
|
700
|
-
primary:
|
|
701
|
-
error:
|
|
702
|
-
onRegisterAppend: (
|
|
703
|
-
|
|
705
|
+
conversation: S,
|
|
706
|
+
provider: (Q = ce.get(S.connectionId)) == null ? void 0 : Q.provider,
|
|
707
|
+
connection: ce.get(S.connectionId),
|
|
708
|
+
client: O.current,
|
|
709
|
+
primary: J,
|
|
710
|
+
error: H,
|
|
711
|
+
onRegisterAppend: (c) => {
|
|
712
|
+
be.current = c;
|
|
704
713
|
},
|
|
705
|
-
refreshKey:
|
|
706
|
-
infoOpen:
|
|
707
|
-
onToggleInfo: () =>
|
|
708
|
-
t:
|
|
709
|
-
disableAttachments:
|
|
714
|
+
refreshKey: Se,
|
|
715
|
+
infoOpen: X,
|
|
716
|
+
onToggleInfo: () => re((c) => !c),
|
|
717
|
+
t: le,
|
|
718
|
+
disableAttachments: g,
|
|
710
719
|
hideKeyboardHint: f,
|
|
711
|
-
extensions:
|
|
712
|
-
onLinkContact: (
|
|
713
|
-
onRefreshContactInfo:
|
|
720
|
+
extensions: R,
|
|
721
|
+
onLinkContact: (c) => Ce(S, c),
|
|
722
|
+
onRefreshContactInfo: Ie
|
|
714
723
|
},
|
|
715
|
-
|
|
716
|
-
) : /* @__PURE__ */ e(
|
|
717
|
-
|
|
718
|
-
|
|
724
|
+
S.id
|
|
725
|
+
) : /* @__PURE__ */ e(Xt, {}) }),
|
|
726
|
+
X && S && /* @__PURE__ */ e(
|
|
727
|
+
Vt,
|
|
719
728
|
{
|
|
720
|
-
conversation:
|
|
721
|
-
connection:
|
|
722
|
-
primary:
|
|
723
|
-
onClose: () =>
|
|
724
|
-
client:
|
|
729
|
+
conversation: S,
|
|
730
|
+
connection: ce.get(S.connectionId),
|
|
731
|
+
primary: J,
|
|
732
|
+
onClose: () => re(!1),
|
|
733
|
+
client: O.current,
|
|
725
734
|
onStartResize: Me,
|
|
726
|
-
extensions:
|
|
727
|
-
extRefreshKey:
|
|
728
|
-
onLinkContact: (
|
|
729
|
-
onRefreshContactInfo:
|
|
735
|
+
extensions: R,
|
|
736
|
+
extRefreshKey: me,
|
|
737
|
+
onLinkContact: (c) => Ce(S, c),
|
|
738
|
+
onRefreshContactInfo: Ie
|
|
730
739
|
}
|
|
731
740
|
)
|
|
732
741
|
] }) }) });
|
|
733
742
|
});
|
|
734
|
-
function
|
|
735
|
-
const [
|
|
736
|
-
let
|
|
737
|
-
r ?
|
|
738
|
-
const
|
|
743
|
+
function Ft({ conversation: t, provider: i, selected: r, primary: o, onSelect: s }) {
|
|
744
|
+
const [k, g] = y(!1), $ = t.contactName ?? t.subject ?? t.providerConversationKey, f = t.unreadCount ?? 0, x = t.lastMessageText ?? "", R = t.lastMessageDirection === "outbound" ? "Bạn: " : "", I = x.length > 60 ? x.slice(0, 60) + "…" : x, E = x ? R + I : "";
|
|
745
|
+
let W = "transparent";
|
|
746
|
+
r ? W = "#eef2ff" : k ? W = "#f7f9fc" : f > 0 && (W = "#f0f4ff");
|
|
747
|
+
const O = {
|
|
739
748
|
...p.row,
|
|
740
|
-
background:
|
|
741
|
-
...r ? { boxShadow: `inset 3px 0 0 ${o}` } : f > 0 && !
|
|
749
|
+
background: W,
|
|
750
|
+
...r ? { boxShadow: `inset 3px 0 0 ${o}` } : f > 0 && !k ? { boxShadow: `inset 3px 0 0 ${o}` } : {}
|
|
742
751
|
};
|
|
743
752
|
return /* @__PURE__ */ n(
|
|
744
753
|
"button",
|
|
745
754
|
{
|
|
746
755
|
onClick: s,
|
|
747
|
-
style:
|
|
748
|
-
onMouseEnter: () =>
|
|
749
|
-
onMouseLeave: () =>
|
|
756
|
+
style: O,
|
|
757
|
+
onMouseEnter: () => g(!0),
|
|
758
|
+
onMouseLeave: () => g(!1),
|
|
750
759
|
children: [
|
|
751
|
-
/* @__PURE__ */ e(
|
|
760
|
+
/* @__PURE__ */ e(ft, { name: $, color: o, image: t.contactPictureUrl, provider: i }),
|
|
752
761
|
/* @__PURE__ */ n("span", { style: p.rowBody, children: [
|
|
753
762
|
/* @__PURE__ */ n("span", { style: p.rowTop, children: [
|
|
754
|
-
/* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: f > 0 ? 700 : 500 }, children:
|
|
763
|
+
/* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: f > 0 ? 700 : 500 }, children: $ }),
|
|
755
764
|
/* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, flexShrink: 0 }, children: [
|
|
756
765
|
/* @__PURE__ */ e("time", { style: { color: d.muted, fontSize: 11, whiteSpace: "nowrap" }, children: Ke(t.lastMessageAt) }),
|
|
757
766
|
f > 0 && /* @__PURE__ */ e("span", { "aria-label": `${f} tin nhắn chưa đọc`, style: p.unreadBadge, children: f > 99 ? "99+" : f })
|
|
758
767
|
] })
|
|
759
768
|
] }),
|
|
760
|
-
/* @__PURE__ */ e("span", { style: { ...p.rowBottom, color: f > 0 && !r ? "#4a5568" : d.muted }, children: /* @__PURE__ */ e("span", { style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: "100%" }, children:
|
|
769
|
+
/* @__PURE__ */ e("span", { style: { ...p.rowBottom, color: f > 0 && !r ? "#4a5568" : d.muted }, children: /* @__PURE__ */ e("span", { style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: "100%" }, children: E || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" }) }) })
|
|
761
770
|
] })
|
|
762
771
|
]
|
|
763
772
|
}
|
|
764
773
|
);
|
|
765
774
|
}
|
|
766
|
-
function
|
|
775
|
+
function Kt({ conversation: t, provider: i, connection: r, client: o, primary: s, error: k, onRegisterAppend: g, refreshKey: $, infoOpen: f, onToggleInfo: x, t: R, disableAttachments: I, hideKeyboardHint: E, extensions: W, onLinkContact: O, onRefreshContactInfo: D }) {
|
|
767
776
|
var He;
|
|
768
|
-
const [
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}, [
|
|
772
|
-
if (!
|
|
773
|
-
function
|
|
774
|
-
var
|
|
775
|
-
(
|
|
777
|
+
const [L, P] = y([]), [K, ee] = y(), [U, S] = y(""), [z, b] = y(!0), [T, ie] = y(!1), [B, N] = y(""), de = Z(null), C = t.contactName ?? t.subject ?? t.providerConversationKey, te = Z(null), q = Z(null), [w, _] = y(null), [he, h] = y(!1), [H, F] = y(!1), [X, re] = y(!1), [oe, Y] = y(0), ye = Z(null), we = Z(null), me = Z(null), [fe, J] = y(!1), [ce, be] = y(""), [Se, Oe] = y([]), Ce = Z(null), Ie = Z(null);
|
|
778
|
+
V(() => () => {
|
|
779
|
+
w != null && w.objectUrl && URL.revokeObjectURL(w.objectUrl);
|
|
780
|
+
}, [w == null ? void 0 : w.objectUrl]), V(() => {
|
|
781
|
+
if (!X) return;
|
|
782
|
+
function l(m) {
|
|
783
|
+
var v, A;
|
|
784
|
+
(v = we.current) != null && v.contains(m.target) || (A = ye.current) != null && A.contains(m.target) || re(!1);
|
|
776
785
|
}
|
|
777
|
-
return document.addEventListener("mousedown",
|
|
778
|
-
}, [
|
|
786
|
+
return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
|
|
787
|
+
}, [X]), V(() => {
|
|
779
788
|
o.listCannedResponses().then(Oe).catch(() => {
|
|
780
789
|
});
|
|
781
|
-
}, [o]),
|
|
782
|
-
if (!
|
|
783
|
-
function
|
|
784
|
-
var
|
|
785
|
-
(
|
|
790
|
+
}, [o]), V(() => {
|
|
791
|
+
if (!fe) return;
|
|
792
|
+
function l(m) {
|
|
793
|
+
var v, A;
|
|
794
|
+
(v = Ie.current) != null && v.contains(m.target) || (A = Ce.current) != null && A.contains(m.target) || J(!1);
|
|
786
795
|
}
|
|
787
|
-
return document.addEventListener("mousedown",
|
|
788
|
-
}, [
|
|
789
|
-
const
|
|
790
|
-
|
|
796
|
+
return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
|
|
797
|
+
}, [fe]);
|
|
798
|
+
const ze = Z(!0), ue = ke(async (l, m) => {
|
|
799
|
+
m || (ze.current = !l);
|
|
791
800
|
try {
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
} catch (
|
|
795
|
-
|
|
801
|
+
const v = await o.listMessages(t.id, l);
|
|
802
|
+
P((A) => l ? [...v.items, ...A] : v.items), ee(v.nextCursor);
|
|
803
|
+
} catch (v) {
|
|
804
|
+
N(v instanceof Error ? v.message : "Không tải được tin nhắn");
|
|
796
805
|
} finally {
|
|
797
|
-
|
|
806
|
+
m || b(!1);
|
|
798
807
|
}
|
|
799
808
|
}, [o, t.id]);
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}, [
|
|
803
|
-
|
|
804
|
-
}, [
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
|
|
809
|
+
V(() => {
|
|
810
|
+
b(!0), ue();
|
|
811
|
+
}, [ue]), V(() => {
|
|
812
|
+
$ && ue(void 0, !0);
|
|
813
|
+
}, [$]), V(() => {
|
|
814
|
+
ze.current && requestAnimationFrame(() => {
|
|
815
|
+
const l = de.current;
|
|
816
|
+
l && (l.scrollTop = l.scrollHeight);
|
|
808
817
|
});
|
|
809
|
-
}, [
|
|
810
|
-
|
|
818
|
+
}, [L]), V(() => (g == null || g((l) => {
|
|
819
|
+
ze.current = !0, P((m) => m.some((v) => v.id === l.id) ? m : [...m, l]);
|
|
811
820
|
}), () => {
|
|
812
|
-
|
|
813
|
-
}), [
|
|
814
|
-
async function Me(
|
|
815
|
-
var
|
|
816
|
-
const
|
|
817
|
-
if (!
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
+
g == null || g(null);
|
|
822
|
+
}), [g]);
|
|
823
|
+
async function Me(l) {
|
|
824
|
+
var A;
|
|
825
|
+
const m = (A = l.target.files) == null ? void 0 : A[0];
|
|
826
|
+
if (!m) return;
|
|
827
|
+
l.target.value = "";
|
|
828
|
+
const v = URL.createObjectURL(m);
|
|
829
|
+
_({ file: m, uploading: !0, objectUrl: v });
|
|
821
830
|
try {
|
|
822
|
-
const
|
|
823
|
-
|
|
831
|
+
const Q = await o.uploadAttachment(m);
|
|
832
|
+
_({ file: m, uploading: !1, url: Q.url, mimeType: Q.mimeType, attachmentType: Q.attachmentType, objectUrl: v });
|
|
824
833
|
} catch {
|
|
825
|
-
URL.revokeObjectURL(
|
|
834
|
+
URL.revokeObjectURL(v), _(null), N("Không tải lên được tệp đính kèm");
|
|
826
835
|
}
|
|
827
836
|
}
|
|
828
|
-
async function
|
|
829
|
-
|
|
830
|
-
const
|
|
831
|
-
if (!(!
|
|
832
|
-
|
|
837
|
+
async function ae(l) {
|
|
838
|
+
l.preventDefault();
|
|
839
|
+
const m = U.trim(), v = w != null && w.url ? [{ url: w.url, mimeType: w.mimeType ?? "application/octet-stream", type: w.attachmentType }] : [];
|
|
840
|
+
if (!(!m && !v.length || T)) {
|
|
841
|
+
ie(!0), N("");
|
|
833
842
|
try {
|
|
834
|
-
await o.sendMessage(t.id,
|
|
835
|
-
} catch (
|
|
836
|
-
|
|
843
|
+
await o.sendMessage(t.id, m || void 0, v.length ? v : void 0), w != null && w.objectUrl && URL.revokeObjectURL(w.objectUrl), S(""), _(null), await ue();
|
|
844
|
+
} catch (A) {
|
|
845
|
+
N(A instanceof Error ? A.message : "Không gửi được tin nhắn");
|
|
837
846
|
} finally {
|
|
838
|
-
|
|
847
|
+
ie(!1);
|
|
839
848
|
}
|
|
840
849
|
}
|
|
841
850
|
}
|
|
842
|
-
function
|
|
843
|
-
const
|
|
844
|
-
if (!
|
|
845
|
-
|
|
851
|
+
function Te(l) {
|
|
852
|
+
const m = me.current;
|
|
853
|
+
if (!m) {
|
|
854
|
+
S((c) => c + l), re(!1);
|
|
846
855
|
return;
|
|
847
856
|
}
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
|
|
857
|
+
const v = m.selectionStart ?? U.length, A = m.selectionEnd ?? U.length, Q = U.slice(0, v) + l + U.slice(A);
|
|
858
|
+
S(Q), re(!1), requestAnimationFrame(() => {
|
|
859
|
+
m.focus(), m.selectionStart = m.selectionEnd = v + l.length;
|
|
851
860
|
});
|
|
852
861
|
}
|
|
853
|
-
function
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
862
|
+
function Re(l) {
|
|
863
|
+
S(l), J(!1), be(""), requestAnimationFrame(() => {
|
|
864
|
+
const m = me.current;
|
|
865
|
+
m && (m.focus(), m.selectionStart = m.selectionEnd = l.length);
|
|
857
866
|
});
|
|
858
867
|
}
|
|
859
|
-
const
|
|
868
|
+
const le = !T && (U.trim().length > 0 || (w == null ? void 0 : w.url) != null && !w.uploading);
|
|
860
869
|
return /* @__PURE__ */ n("section", { style: p.chat, children: [
|
|
861
870
|
/* @__PURE__ */ n("header", { style: p.chatHeader, children: [
|
|
862
|
-
/* @__PURE__ */ e(
|
|
871
|
+
/* @__PURE__ */ e(ft, { name: C, color: s, image: t.contactPictureUrl, provider: i }),
|
|
863
872
|
/* @__PURE__ */ n("div", { style: p.contact, children: [
|
|
864
|
-
/* @__PURE__ */ e("strong", { style: p.contactName, children:
|
|
865
|
-
/* @__PURE__ */ e("span", { style: p.contactMeta, children:
|
|
873
|
+
/* @__PURE__ */ e("strong", { style: p.contactName, children: C }),
|
|
874
|
+
/* @__PURE__ */ e("span", { style: p.contactMeta, children: Pt(r) ?? ut(i) })
|
|
866
875
|
] }),
|
|
867
876
|
/* @__PURE__ */ n("div", { style: p.headerActions, children: [
|
|
868
|
-
/* @__PURE__ */ e("button", { style: p.iconButton, "aria-label": "Thêm tùy chọn", children: /* @__PURE__ */ e(
|
|
877
|
+
/* @__PURE__ */ e("button", { style: p.iconButton, "aria-label": "Thêm tùy chọn", children: /* @__PURE__ */ e(dt, { size: 16, strokeWidth: 2 }) }),
|
|
869
878
|
/* @__PURE__ */ e(
|
|
870
879
|
"button",
|
|
871
880
|
{
|
|
@@ -875,46 +884,46 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
875
884
|
color: f ? s : d.muted
|
|
876
885
|
},
|
|
877
886
|
"aria-label": "Thông tin liên hệ",
|
|
878
|
-
onClick:
|
|
879
|
-
children: /* @__PURE__ */ e(
|
|
887
|
+
onClick: x,
|
|
888
|
+
children: /* @__PURE__ */ e(Rt, { size: 16, strokeWidth: 2 })
|
|
880
889
|
}
|
|
881
890
|
)
|
|
882
891
|
] })
|
|
883
892
|
] }),
|
|
884
|
-
/* @__PURE__ */ n(
|
|
885
|
-
/* @__PURE__ */ e("div", { style: p.day, children:
|
|
886
|
-
K && /* @__PURE__ */ e("button", { onClick: () => void
|
|
887
|
-
|
|
893
|
+
/* @__PURE__ */ n(ht, { ref: de, style: p.messageArea, children: [
|
|
894
|
+
/* @__PURE__ */ e("div", { style: p.day, children: R.today }),
|
|
895
|
+
K && /* @__PURE__ */ e("button", { onClick: () => void ue(K), style: p.historyButton, children: R.loadOlder }),
|
|
896
|
+
z && /* @__PURE__ */ n("div", { style: p.messageHint, children: [
|
|
888
897
|
/* @__PURE__ */ e(Fe, {}),
|
|
889
898
|
" ",
|
|
890
|
-
|
|
899
|
+
R.loading
|
|
891
900
|
] }),
|
|
892
|
-
!
|
|
893
|
-
|
|
894
|
-
const
|
|
901
|
+
!z && !L.length && /* @__PURE__ */ e("div", { style: p.messageHint, children: R.noMessages }),
|
|
902
|
+
L.map((l, m) => {
|
|
903
|
+
const v = (W == null ? void 0 : W.flatMap((u) => u.messageEnrichments ?? [])) ?? [], A = l.direction === "inbound" && v.length > 0 && m >= L.length - 15, Q = A ? Ae(t, {
|
|
895
904
|
provider: i,
|
|
896
|
-
recentMessages:
|
|
897
|
-
linkContact:
|
|
898
|
-
refreshContactInfo:
|
|
899
|
-
sendMessage: async (
|
|
900
|
-
await o.sendMessage(t.id,
|
|
905
|
+
recentMessages: L.slice(-10),
|
|
906
|
+
linkContact: O,
|
|
907
|
+
refreshContactInfo: D,
|
|
908
|
+
sendMessage: async (u, M) => {
|
|
909
|
+
await o.sendMessage(t.id, u, M), await ue(void 0, !0);
|
|
901
910
|
}
|
|
902
|
-
}) : null
|
|
911
|
+
}) : null, c = A && Q ? v.map((u, M) => {
|
|
912
|
+
var se;
|
|
913
|
+
const j = (se = l.text) == null ? void 0 : se.match(u.pattern);
|
|
914
|
+
return j ? /* @__PURE__ */ e(Dt, { children: u.render(j, Q, l) }, `${l.id}-${M}`) : null;
|
|
915
|
+
}).filter(Boolean) : [];
|
|
903
916
|
return /* @__PURE__ */ n("div", { children: [
|
|
904
|
-
/* @__PURE__ */ e(
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
const R = (W = c.text) == null ? void 0 : W.match(l.pattern);
|
|
908
|
-
return R ? /* @__PURE__ */ e(Ot, { children: l.render(R, Z, c) }, `${c.id}-${u}`) : null;
|
|
909
|
-
})
|
|
910
|
-
] }, c.id);
|
|
917
|
+
/* @__PURE__ */ e(qt, { message: l, primary: s }),
|
|
918
|
+
c.length > 0 && /* @__PURE__ */ e("div", { style: { maxWidth: "min(70%, 480px)", marginTop: -4, marginBottom: 10, display: "flex", flexDirection: "column", gap: 6 }, children: c })
|
|
919
|
+
] }, l.id);
|
|
911
920
|
})
|
|
912
921
|
] }),
|
|
913
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 6, flexWrap: "wrap", padding: "6px 14px 2px", borderTop: `1px solid ${d.line}` }, children: ["Cảm ơn bạn đã liên hệ 🙏", "Mình sẽ kiểm tra ngay", "Vui lòng chờ 1-2 phút"].map((
|
|
922
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", gap: 6, flexWrap: "wrap", padding: "6px 14px 2px", borderTop: `1px solid ${d.line}` }, children: ["Cảm ơn bạn đã liên hệ 🙏", "Mình sẽ kiểm tra ngay", "Vui lòng chờ 1-2 phút"].map((l) => /* @__PURE__ */ e(
|
|
914
923
|
"button",
|
|
915
924
|
{
|
|
916
925
|
type: "button",
|
|
917
|
-
onClick: () =>
|
|
926
|
+
onClick: () => S(l),
|
|
918
927
|
style: {
|
|
919
928
|
fontSize: 11,
|
|
920
929
|
padding: "3px 10px",
|
|
@@ -925,12 +934,12 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
925
934
|
cursor: "pointer",
|
|
926
935
|
whiteSpace: "nowrap"
|
|
927
936
|
},
|
|
928
|
-
children:
|
|
937
|
+
children: l
|
|
929
938
|
},
|
|
930
|
-
|
|
939
|
+
l
|
|
931
940
|
)) }),
|
|
932
|
-
/* @__PURE__ */ n("form", { onSubmit:
|
|
933
|
-
|
|
941
|
+
/* @__PURE__ */ n("form", { onSubmit: ae, style: { flex: "0 0 auto", padding: "8px 14px 12px", borderTop: `1px solid ${d.line}`, background: d.white, position: "relative" }, children: [
|
|
942
|
+
X && /* @__PURE__ */ n(
|
|
934
943
|
"div",
|
|
935
944
|
{
|
|
936
945
|
ref: ye,
|
|
@@ -948,11 +957,11 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
948
957
|
fontFamily: "inherit"
|
|
949
958
|
},
|
|
950
959
|
children: [
|
|
951
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children:
|
|
960
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children: Ze.map((l, m) => /* @__PURE__ */ e(
|
|
952
961
|
"button",
|
|
953
962
|
{
|
|
954
963
|
type: "button",
|
|
955
|
-
onClick: () =>
|
|
964
|
+
onClick: () => Y(m),
|
|
956
965
|
style: {
|
|
957
966
|
flex: 1,
|
|
958
967
|
border: 0,
|
|
@@ -961,19 +970,19 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
961
970
|
fontSize: 16,
|
|
962
971
|
cursor: "pointer",
|
|
963
972
|
lineHeight: 1,
|
|
964
|
-
borderBottom:
|
|
965
|
-
opacity:
|
|
973
|
+
borderBottom: oe === m ? `2px solid ${s}` : "2px solid transparent",
|
|
974
|
+
opacity: oe === m ? 1 : 0.5,
|
|
966
975
|
transition: "opacity 100ms ease"
|
|
967
976
|
},
|
|
968
|
-
children:
|
|
977
|
+
children: l.icon
|
|
969
978
|
},
|
|
970
|
-
|
|
979
|
+
m
|
|
971
980
|
)) }),
|
|
972
|
-
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (He =
|
|
981
|
+
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (He = Ze[oe]) == null ? void 0 : He.emojis.map((l, m) => /* @__PURE__ */ e(
|
|
973
982
|
"button",
|
|
974
983
|
{
|
|
975
984
|
type: "button",
|
|
976
|
-
onClick: () =>
|
|
985
|
+
onClick: () => Te(l),
|
|
977
986
|
style: {
|
|
978
987
|
border: 0,
|
|
979
988
|
background: "transparent",
|
|
@@ -984,23 +993,23 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
984
993
|
lineHeight: 1,
|
|
985
994
|
transition: "background 80ms ease"
|
|
986
995
|
},
|
|
987
|
-
onMouseEnter: (
|
|
988
|
-
|
|
996
|
+
onMouseEnter: (v) => {
|
|
997
|
+
v.target.style.background = "#f3f4f6";
|
|
989
998
|
},
|
|
990
|
-
onMouseLeave: (
|
|
991
|
-
|
|
999
|
+
onMouseLeave: (v) => {
|
|
1000
|
+
v.target.style.background = "transparent";
|
|
992
1001
|
},
|
|
993
|
-
children:
|
|
1002
|
+
children: l
|
|
994
1003
|
},
|
|
995
|
-
|
|
1004
|
+
m
|
|
996
1005
|
)) })
|
|
997
1006
|
]
|
|
998
1007
|
}
|
|
999
1008
|
),
|
|
1000
|
-
|
|
1009
|
+
fe && /* @__PURE__ */ n(
|
|
1001
1010
|
"div",
|
|
1002
1011
|
{
|
|
1003
|
-
ref:
|
|
1012
|
+
ref: Ce,
|
|
1004
1013
|
style: {
|
|
1005
1014
|
position: "absolute",
|
|
1006
1015
|
bottom: "calc(100% + 6px)",
|
|
@@ -1021,90 +1030,90 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
1021
1030
|
autoFocus: !0,
|
|
1022
1031
|
type: "text",
|
|
1023
1032
|
placeholder: "Tìm template…",
|
|
1024
|
-
value:
|
|
1025
|
-
onChange: (
|
|
1033
|
+
value: ce,
|
|
1034
|
+
onChange: (l) => be(l.target.value),
|
|
1026
1035
|
style: { width: "100%", boxSizing: "border-box", border: `1px solid ${d.line}`, borderRadius: 7, padding: "5px 8px", fontSize: 12, outline: "none", fontFamily: "inherit", color: d.ink }
|
|
1027
1036
|
}
|
|
1028
1037
|
) }),
|
|
1029
1038
|
/* @__PURE__ */ e("div", { style: { maxHeight: 220, overflowY: "auto" }, children: (() => {
|
|
1030
|
-
const
|
|
1031
|
-
return
|
|
1039
|
+
const l = ce.trim().toLowerCase(), m = l ? Se.filter((v) => v.title.toLowerCase().includes(l) || v.content.toLowerCase().includes(l) || (v.shortcut ?? "").toLowerCase().includes(l)) : Se;
|
|
1040
|
+
return m.length ? m.map((v) => /* @__PURE__ */ n(
|
|
1032
1041
|
"button",
|
|
1033
1042
|
{
|
|
1034
1043
|
type: "button",
|
|
1035
|
-
onClick: () =>
|
|
1044
|
+
onClick: () => Re(v.content),
|
|
1036
1045
|
style: { display: "block", width: "100%", textAlign: "left", border: 0, borderBottom: `1px solid ${d.line}`, background: "transparent", padding: "9px 12px", cursor: "pointer", fontFamily: "inherit" },
|
|
1037
|
-
onMouseEnter: (
|
|
1038
|
-
|
|
1046
|
+
onMouseEnter: (A) => {
|
|
1047
|
+
A.currentTarget.style.background = "#f7f9fc";
|
|
1039
1048
|
},
|
|
1040
|
-
onMouseLeave: (
|
|
1041
|
-
|
|
1049
|
+
onMouseLeave: (A) => {
|
|
1050
|
+
A.currentTarget.style.background = "transparent";
|
|
1042
1051
|
},
|
|
1043
1052
|
children: [
|
|
1044
1053
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 }, children: [
|
|
1045
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: d.ink }, children:
|
|
1046
|
-
|
|
1054
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: d.ink }, children: v.title }),
|
|
1055
|
+
v.shortcut && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: s, background: `${s}18`, borderRadius: 4, padding: "1px 5px" }, children: v.shortcut })
|
|
1047
1056
|
] }),
|
|
1048
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: d.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children:
|
|
1057
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: d.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: v.content })
|
|
1049
1058
|
]
|
|
1050
1059
|
},
|
|
1051
|
-
|
|
1052
|
-
)) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color: d.muted, fontSize: 12 }, children:
|
|
1060
|
+
v.id
|
|
1061
|
+
)) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color: d.muted, fontSize: 12 }, children: Se.length === 0 ? "Chưa có template nào" : "Không tìm thấy" });
|
|
1053
1062
|
})() })
|
|
1054
1063
|
]
|
|
1055
1064
|
}
|
|
1056
1065
|
),
|
|
1057
1066
|
/* @__PURE__ */ n("div", { style: { border: `1.5px solid ${d.line}`, borderRadius: 12, background: d.white, overflow: "hidden" }, children: [
|
|
1058
|
-
|
|
1059
|
-
|
|
1067
|
+
w && /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: `1px solid ${d.line}`, fontSize: 12 }, children: [
|
|
1068
|
+
w.uploading ? /* @__PURE__ */ n(ne, { children: [
|
|
1060
1069
|
/* @__PURE__ */ e(Fe, {}),
|
|
1061
1070
|
/* @__PURE__ */ e("span", { style: { color: d.muted }, children: "Đang tải lên…" })
|
|
1062
|
-
] }) :
|
|
1071
|
+
] }) : w.attachmentType === "image" && w.objectUrl ? /* @__PURE__ */ e("img", { src: w.objectUrl, alt: "", style: { height: 48, width: 48, objectFit: "cover", borderRadius: 6 } }) : /* @__PURE__ */ n("span", { style: { color: d.muted }, children: [
|
|
1063
1072
|
"📎 ",
|
|
1064
|
-
|
|
1073
|
+
w.file.name,
|
|
1065
1074
|
" (",
|
|
1066
|
-
Math.round(
|
|
1075
|
+
Math.round(w.file.size / 1024),
|
|
1067
1076
|
" KB)"
|
|
1068
1077
|
] }),
|
|
1069
|
-
!
|
|
1070
|
-
|
|
1078
|
+
!w.uploading && /* @__PURE__ */ e("button", { type: "button", onClick: () => {
|
|
1079
|
+
w != null && w.objectUrl && URL.revokeObjectURL(w.objectUrl), _(null);
|
|
1071
1080
|
}, style: { marginLeft: "auto", border: 0, background: "none", color: d.muted, cursor: "pointer", fontSize: 16 }, "aria-label": "Xóa tệp đính kèm", children: "✕" })
|
|
1072
1081
|
] }),
|
|
1073
1082
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 2, padding: "4px 8px", borderBottom: "1px solid #f3f4f6" }, children: [
|
|
1074
1083
|
/* @__PURE__ */ e(
|
|
1075
1084
|
"button",
|
|
1076
1085
|
{
|
|
1077
|
-
ref:
|
|
1086
|
+
ref: we,
|
|
1078
1087
|
type: "button",
|
|
1079
1088
|
title: "Chèn emoji",
|
|
1080
|
-
onClick: () =>
|
|
1081
|
-
style: { ...p.toolbarBtn, background:
|
|
1082
|
-
children: /* @__PURE__ */ e(
|
|
1089
|
+
onClick: () => re((l) => !l),
|
|
1090
|
+
style: { ...p.toolbarBtn, background: X ? `${s}18` : "transparent", color: X ? s : "#9ca3af" },
|
|
1091
|
+
children: /* @__PURE__ */ e(Mt, { size: 13, strokeWidth: 2 })
|
|
1083
1092
|
}
|
|
1084
1093
|
),
|
|
1085
1094
|
!I && /* @__PURE__ */ e("button", { type: "button", title: "Gửi ảnh / video", "aria-label": "Gửi ảnh hoặc video", style: p.toolbarBtn, onClick: () => {
|
|
1086
|
-
var
|
|
1087
|
-
return (
|
|
1088
|
-
}, children: /* @__PURE__ */ e(
|
|
1095
|
+
var l;
|
|
1096
|
+
return (l = te.current) == null ? void 0 : l.click();
|
|
1097
|
+
}, children: /* @__PURE__ */ e(zt, { size: 13, strokeWidth: 2 }) }),
|
|
1089
1098
|
!I && /* @__PURE__ */ e("button", { type: "button", title: "Gửi tệp đính kèm", "aria-label": "Gửi tệp đính kèm", style: p.toolbarBtn, onClick: () => {
|
|
1090
|
-
var
|
|
1091
|
-
return (
|
|
1092
|
-
}, children: /* @__PURE__ */ e(
|
|
1093
|
-
!I && /* @__PURE__ */ n(
|
|
1094
|
-
/* @__PURE__ */ e("input", { ref:
|
|
1095
|
-
/* @__PURE__ */ e("input", { ref:
|
|
1099
|
+
var l;
|
|
1100
|
+
return (l = q.current) == null ? void 0 : l.click();
|
|
1101
|
+
}, children: /* @__PURE__ */ e(Wt, { size: 13, strokeWidth: 2 }) }),
|
|
1102
|
+
!I && /* @__PURE__ */ n(ne, { children: [
|
|
1103
|
+
/* @__PURE__ */ e("input", { ref: te, type: "file", style: { display: "none" }, onChange: Me, accept: "image/*,video/mp4" }),
|
|
1104
|
+
/* @__PURE__ */ e("input", { ref: q, type: "file", style: { display: "none" }, onChange: Me, accept: ".pdf,audio/mpeg,audio/ogg,application/octet-stream,application/zip,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" })
|
|
1096
1105
|
] }),
|
|
1097
1106
|
/* @__PURE__ */ e(
|
|
1098
1107
|
"button",
|
|
1099
1108
|
{
|
|
1100
|
-
ref:
|
|
1109
|
+
ref: Ie,
|
|
1101
1110
|
type: "button",
|
|
1102
1111
|
title: "Template nhanh",
|
|
1103
1112
|
onClick: () => {
|
|
1104
|
-
|
|
1113
|
+
J((l) => !l), be("");
|
|
1105
1114
|
},
|
|
1106
|
-
style: { ...p.toolbarBtn, background:
|
|
1107
|
-
children: /* @__PURE__ */ e(
|
|
1115
|
+
style: { ...p.toolbarBtn, background: fe ? `${s}18` : "transparent", color: fe ? s : "#9ca3af" },
|
|
1116
|
+
children: /* @__PURE__ */ e(Ht, { size: 13, strokeWidth: 2 })
|
|
1108
1117
|
}
|
|
1109
1118
|
),
|
|
1110
1119
|
/* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 2px" } }),
|
|
@@ -1113,8 +1122,8 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
1113
1122
|
{
|
|
1114
1123
|
type: "button",
|
|
1115
1124
|
title: "In đậm",
|
|
1116
|
-
onClick: () => h((
|
|
1117
|
-
style: { ...p.toolbarBtn, fontWeight: 700, fontSize: 12, background:
|
|
1125
|
+
onClick: () => h((l) => !l),
|
|
1126
|
+
style: { ...p.toolbarBtn, fontWeight: 700, fontSize: 12, background: he ? `${s}18` : "transparent", color: he ? s : "#9ca3af", border: he ? `1px solid ${s}33` : "1px solid transparent" },
|
|
1118
1127
|
children: "B"
|
|
1119
1128
|
}
|
|
1120
1129
|
),
|
|
@@ -1123,52 +1132,73 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
1123
1132
|
{
|
|
1124
1133
|
type: "button",
|
|
1125
1134
|
title: "Nghiêng",
|
|
1126
|
-
onClick: () =>
|
|
1127
|
-
style: { ...p.toolbarBtn, fontStyle: "italic", fontSize: 12, background:
|
|
1135
|
+
onClick: () => F((l) => !l),
|
|
1136
|
+
style: { ...p.toolbarBtn, fontStyle: "italic", fontSize: 12, background: H ? `${s}18` : "transparent", color: H ? s : "#9ca3af", border: H ? `1px solid ${s}33` : "1px solid transparent" },
|
|
1128
1137
|
children: "I"
|
|
1129
1138
|
}
|
|
1130
1139
|
),
|
|
1131
|
-
|
|
1140
|
+
!!(W != null && W.some((l) => {
|
|
1141
|
+
var m;
|
|
1142
|
+
return (((m = l.toolbarActions) == null ? void 0 : m.length) ?? 0) > 0;
|
|
1143
|
+
})) && /* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 4px" } }),
|
|
1144
|
+
W == null ? void 0 : W.flatMap((l) => l.toolbarActions ?? []).map((l, m) => /* @__PURE__ */ n(
|
|
1132
1145
|
"button",
|
|
1133
1146
|
{
|
|
1134
1147
|
type: "button",
|
|
1135
|
-
title:
|
|
1136
|
-
style:
|
|
1148
|
+
title: l.tooltip,
|
|
1149
|
+
style: l.label ? {
|
|
1150
|
+
display: "inline-flex",
|
|
1151
|
+
alignItems: "center",
|
|
1152
|
+
gap: 5,
|
|
1153
|
+
padding: "3px 9px",
|
|
1154
|
+
borderRadius: 999,
|
|
1155
|
+
border: `1px solid ${s}33`,
|
|
1156
|
+
background: `${s}0f`,
|
|
1157
|
+
color: s,
|
|
1158
|
+
fontSize: 11.5,
|
|
1159
|
+
fontWeight: 600,
|
|
1160
|
+
cursor: "pointer",
|
|
1161
|
+
lineHeight: 1.2,
|
|
1162
|
+
whiteSpace: "nowrap"
|
|
1163
|
+
} : p.toolbarBtn,
|
|
1137
1164
|
onClick: () => {
|
|
1138
|
-
const
|
|
1139
|
-
|
|
1140
|
-
`) ? `${
|
|
1141
|
-
var
|
|
1142
|
-
return (
|
|
1165
|
+
const v = (Q) => {
|
|
1166
|
+
S((c) => c && !c.endsWith(" ") && !c.endsWith(`
|
|
1167
|
+
`) ? `${c} ${Q}` : `${c}${Q}`), requestAnimationFrame(() => {
|
|
1168
|
+
var c;
|
|
1169
|
+
return (c = me.current) == null ? void 0 : c.focus();
|
|
1143
1170
|
});
|
|
1144
|
-
},
|
|
1171
|
+
}, A = Ae(t, {
|
|
1145
1172
|
provider: i,
|
|
1146
|
-
recentMessages:
|
|
1147
|
-
linkContact:
|
|
1148
|
-
refreshContactInfo:
|
|
1149
|
-
sendMessage: async (
|
|
1150
|
-
await o.sendMessage(t.id,
|
|
1173
|
+
recentMessages: L.slice(-10),
|
|
1174
|
+
linkContact: O,
|
|
1175
|
+
refreshContactInfo: D,
|
|
1176
|
+
sendMessage: async (Q, c) => {
|
|
1177
|
+
await o.sendMessage(t.id, Q, c), await ue(void 0, !0);
|
|
1151
1178
|
}
|
|
1152
1179
|
});
|
|
1153
|
-
|
|
1180
|
+
l.onClick({ ...A, insertText: v });
|
|
1154
1181
|
},
|
|
1155
|
-
children:
|
|
1182
|
+
children: [
|
|
1183
|
+
l.icon,
|
|
1184
|
+
l.label && /* @__PURE__ */ e("span", { children: l.label })
|
|
1185
|
+
]
|
|
1156
1186
|
},
|
|
1157
|
-
|
|
1187
|
+
m
|
|
1158
1188
|
))
|
|
1159
1189
|
] }),
|
|
1160
1190
|
/* @__PURE__ */ e(
|
|
1161
|
-
|
|
1191
|
+
At,
|
|
1162
1192
|
{
|
|
1163
|
-
ref:
|
|
1193
|
+
ref: me,
|
|
1164
1194
|
"aria-label": "Soạn tin nhắn",
|
|
1165
1195
|
rows: 2,
|
|
1166
1196
|
value: U,
|
|
1167
|
-
onChange: (
|
|
1168
|
-
onKeyDown: (
|
|
1169
|
-
|
|
1197
|
+
onChange: (l) => S(l.target.value),
|
|
1198
|
+
onKeyDown: (l) => {
|
|
1199
|
+
l.key === "Enter" && !l.shiftKey && (l.preventDefault(), ae(l));
|
|
1170
1200
|
},
|
|
1171
|
-
placeholder:
|
|
1201
|
+
placeholder: R.sendPlaceholder,
|
|
1172
1202
|
style: {
|
|
1173
1203
|
display: "block",
|
|
1174
1204
|
width: "100%",
|
|
@@ -1185,8 +1215,8 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
1185
1215
|
font: "inherit",
|
|
1186
1216
|
fontSize: 13,
|
|
1187
1217
|
lineHeight: 1.45,
|
|
1188
|
-
fontStyle:
|
|
1189
|
-
fontWeight:
|
|
1218
|
+
fontStyle: H ? "italic" : "normal",
|
|
1219
|
+
fontWeight: he ? 700 : 400
|
|
1190
1220
|
}
|
|
1191
1221
|
}
|
|
1192
1222
|
),
|
|
@@ -1200,11 +1230,11 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
1200
1230
|
"/1000"
|
|
1201
1231
|
] }),
|
|
1202
1232
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
1203
|
-
!
|
|
1233
|
+
!E && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#9ca3af" }, children: "↵ Gửi · ⇧↵ Xuống dòng" }),
|
|
1204
1234
|
/* @__PURE__ */ n(
|
|
1205
1235
|
"button",
|
|
1206
1236
|
{
|
|
1207
|
-
disabled: !
|
|
1237
|
+
disabled: !le,
|
|
1208
1238
|
"aria-label": "Gửi tin nhắn",
|
|
1209
1239
|
style: {
|
|
1210
1240
|
display: "flex",
|
|
@@ -1215,15 +1245,15 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
1215
1245
|
borderRadius: 999,
|
|
1216
1246
|
fontSize: 12,
|
|
1217
1247
|
fontWeight: 600,
|
|
1218
|
-
background:
|
|
1219
|
-
color:
|
|
1220
|
-
cursor:
|
|
1221
|
-
boxShadow:
|
|
1248
|
+
background: le ? `linear-gradient(135deg,${s},#0ea5e9)` : "#e5e7eb",
|
|
1249
|
+
color: le ? "#fff" : "#9ca3af",
|
|
1250
|
+
cursor: le ? "pointer" : "not-allowed",
|
|
1251
|
+
boxShadow: le ? "0 2px 8px rgba(37,99,235,0.25)" : "none",
|
|
1222
1252
|
transition: "all 150ms ease"
|
|
1223
1253
|
},
|
|
1224
1254
|
children: [
|
|
1225
|
-
|
|
1226
|
-
|
|
1255
|
+
T ? /* @__PURE__ */ e(ct, { size: 12, style: { animation: "channelhub-spin .7s linear infinite" } }) : /* @__PURE__ */ e($t, { size: 12, strokeWidth: 2 }),
|
|
1256
|
+
R.send
|
|
1227
1257
|
]
|
|
1228
1258
|
}
|
|
1229
1259
|
)
|
|
@@ -1231,105 +1261,105 @@ function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s
|
|
|
1231
1261
|
] })
|
|
1232
1262
|
] })
|
|
1233
1263
|
] }),
|
|
1234
|
-
(
|
|
1264
|
+
(B || k) && /* @__PURE__ */ e("div", { role: "alert", style: p.error, children: B || k })
|
|
1235
1265
|
] });
|
|
1236
1266
|
}
|
|
1237
|
-
function
|
|
1238
|
-
var K,
|
|
1239
|
-
const r = Ne(
|
|
1267
|
+
function qt({ message: t, primary: i }) {
|
|
1268
|
+
var K, ee, U, S, z;
|
|
1269
|
+
const r = Ne(Ve), o = Ne(pt), s = (b) => b.startsWith("/v1/media/proxy") ? `${r}${b}&tok=${encodeURIComponent(o)}` : b, k = t.direction === "outbound", g = ((K = t.attachments) == null ? void 0 : K.filter((b) => b.type === "image")) ?? [], $ = ((ee = t.attachments) == null ? void 0 : ee.filter((b) => b.type === "sticker")) ?? [], f = ((U = t.attachments) == null ? void 0 : U.filter((b) => b.type === "video")) ?? [], x = ((S = t.attachments) == null ? void 0 : S.filter((b) => b.type === "audio")) ?? [], R = ((z = t.attachments) == null ? void 0 : z.filter((b) => b.type === "file")) ?? [], [I, E] = y(null), W = k ? "flex-end" : "flex-start", O = /* @__PURE__ */ n("time", { style: { display: "block", marginTop: 4, fontSize: 10, opacity: 0.65, textAlign: "right", letterSpacing: 0.2, userSelect: "none" }, children: [
|
|
1240
1270
|
Ke(t.occurredAt, !0),
|
|
1241
|
-
|
|
1271
|
+
k && /* @__PURE__ */ n(ne, { children: [
|
|
1242
1272
|
" ",
|
|
1243
|
-
/* @__PURE__ */ e(
|
|
1273
|
+
/* @__PURE__ */ e(Qe, { status: t.status })
|
|
1244
1274
|
] })
|
|
1245
|
-
] }),
|
|
1275
|
+
] }), D = /* @__PURE__ */ e("div", { style: { position: "absolute", bottom: 6, right: 8 }, children: /* @__PURE__ */ n("time", { style: { fontSize: 10, color: "#fff", textShadow: "0 1px 3px rgba(0,0,0,.5)", letterSpacing: 0.2, userSelect: "none" }, children: [
|
|
1246
1276
|
Ke(t.occurredAt, !0),
|
|
1247
|
-
|
|
1277
|
+
k && /* @__PURE__ */ n(ne, { children: [
|
|
1248
1278
|
" ",
|
|
1249
|
-
/* @__PURE__ */ e(
|
|
1279
|
+
/* @__PURE__ */ e(Qe, { status: t.status })
|
|
1250
1280
|
] })
|
|
1251
|
-
] }) }),
|
|
1252
|
-
return /* @__PURE__ */ n("div", { style: { ...p.messageLine, justifyContent:
|
|
1253
|
-
|
|
1254
|
-
/* @__PURE__ */ e("img", { src: s(
|
|
1255
|
-
|
|
1256
|
-
] }, `s${
|
|
1257
|
-
|
|
1258
|
-
/* @__PURE__ */ e("img", { src: s(
|
|
1259
|
-
|
|
1260
|
-
] },
|
|
1261
|
-
f.map((
|
|
1262
|
-
/* @__PURE__ */ e("video", { src: s(
|
|
1263
|
-
/* @__PURE__ */ e("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", borderRadius: 12, background: "rgba(0,0,0,.25)" }, children: /* @__PURE__ */ e("div", { style: { width: 40, height: 40, borderRadius: "50%", background: "rgba(255,255,255,.9)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(
|
|
1264
|
-
|
|
1265
|
-
] },
|
|
1266
|
-
(
|
|
1267
|
-
|
|
1268
|
-
|
|
1281
|
+
] }) }), L = k ? { ...p.bubbleOut, background: i, color: "#fff", border: "1px solid transparent" } : p.bubbleIn, P = !t.text && x.length === 0 && R.length === 0;
|
|
1282
|
+
return /* @__PURE__ */ n("div", { style: { ...p.messageLine, justifyContent: W, flexDirection: "column", alignItems: W }, children: [
|
|
1283
|
+
$.map((b, T) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2 }, children: [
|
|
1284
|
+
/* @__PURE__ */ e("img", { src: s(b.url), alt: "sticker", style: { display: "block", maxWidth: 128, maxHeight: 128, objectFit: "contain" } }),
|
|
1285
|
+
P && g.length === 0 && f.length === 0 && T === $.length - 1 && D
|
|
1286
|
+
] }, `s${T}`)),
|
|
1287
|
+
g.map((b, T) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "zoom-in" }, onClick: () => E({ url: s(b.url), kind: "image" }), children: [
|
|
1288
|
+
/* @__PURE__ */ e("img", { src: s(b.url), alt: "", style: { display: "block", maxWidth: 260, maxHeight: 260, borderRadius: 12, objectFit: "cover" } }),
|
|
1289
|
+
P && T === g.length - 1 && f.length === 0 && D
|
|
1290
|
+
] }, T)),
|
|
1291
|
+
f.map((b, T) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "pointer" }, onClick: () => E({ url: s(b.url), kind: "video" }), children: [
|
|
1292
|
+
/* @__PURE__ */ e("video", { src: s(b.url), style: { display: "block", maxWidth: 260, maxHeight: 200, borderRadius: 12, objectFit: "cover" } }),
|
|
1293
|
+
/* @__PURE__ */ e("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", borderRadius: 12, background: "rgba(0,0,0,.25)" }, children: /* @__PURE__ */ e("div", { style: { width: 40, height: 40, borderRadius: "50%", background: "rgba(255,255,255,.9)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(Bt, { size: 16, fill: "#172033", color: "#172033", style: { marginLeft: 2 } }) }) }),
|
|
1294
|
+
P && T === f.length - 1 && D
|
|
1295
|
+
] }, T)),
|
|
1296
|
+
(x.length > 0 || R.length > 0 || t.text || !g.length && !f.length && !$.length && !t.text) && /* @__PURE__ */ n("div", { style: L, children: [
|
|
1297
|
+
x.map((b, T) => /* @__PURE__ */ e("audio", { src: s(b.url), controls: !0, style: { display: "block", width: "100%", marginBottom: 4 } }, T)),
|
|
1298
|
+
R.map((b, T) => /* @__PURE__ */ n("a", { href: s(b.url), target: "_blank", rel: "noreferrer", style: { display: "block", fontSize: 12, color: k ? "#fff" : "#2563eb", textDecoration: "underline", marginBottom: 4 }, children: [
|
|
1269
1299
|
"📎 ",
|
|
1270
|
-
|
|
1271
|
-
] },
|
|
1300
|
+
Nt(b.mimeType)
|
|
1301
|
+
] }, T)),
|
|
1272
1302
|
t.text && /* @__PURE__ */ e("p", { style: { margin: 0, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: t.text }),
|
|
1273
|
-
!
|
|
1274
|
-
|
|
1303
|
+
!x.length && !R.length && !t.text && /* @__PURE__ */ e("p", { style: { margin: 0, opacity: 0.5 }, children: "[attachment]" }),
|
|
1304
|
+
O
|
|
1275
1305
|
] }),
|
|
1276
|
-
I &&
|
|
1277
|
-
/* @__PURE__ */ n("div", { onClick: () =>
|
|
1278
|
-
I.kind === "image" ? /* @__PURE__ */ e("img", { src: I.url, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, objectFit: "contain", boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (
|
|
1279
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
1306
|
+
I && ot(
|
|
1307
|
+
/* @__PURE__ */ n("div", { onClick: () => E(null), style: { position: "fixed", inset: 0, zIndex: 1e4, background: "rgba(0,0,0,.88)", display: "flex", alignItems: "center", justifyContent: "center", cursor: "zoom-out" }, children: [
|
|
1308
|
+
I.kind === "image" ? /* @__PURE__ */ e("img", { src: I.url, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, objectFit: "contain", boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (b) => b.stopPropagation() }) : /* @__PURE__ */ e("video", { src: I.url, controls: !0, autoPlay: !0, style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (b) => b.stopPropagation() }),
|
|
1309
|
+
/* @__PURE__ */ e("button", { onClick: () => E(null), style: { position: "absolute", top: 16, right: 16, background: "rgba(255,255,255,.15)", border: "none", borderRadius: "50%", width: 36, height: 36, cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", color: "#fff" }, children: /* @__PURE__ */ e(je, { size: 18 }) })
|
|
1280
1310
|
] }),
|
|
1281
1311
|
document.body
|
|
1282
1312
|
)
|
|
1283
1313
|
] });
|
|
1284
1314
|
}
|
|
1285
|
-
function
|
|
1315
|
+
function Vt({
|
|
1286
1316
|
conversation: t,
|
|
1287
1317
|
connection: i,
|
|
1288
1318
|
primary: r,
|
|
1289
1319
|
onClose: o,
|
|
1290
1320
|
client: s,
|
|
1291
|
-
onStartResize:
|
|
1292
|
-
extensions:
|
|
1293
|
-
extRefreshKey:
|
|
1321
|
+
onStartResize: k,
|
|
1322
|
+
extensions: g,
|
|
1323
|
+
extRefreshKey: $,
|
|
1294
1324
|
onLinkContact: f,
|
|
1295
|
-
onRefreshContactInfo:
|
|
1325
|
+
onRefreshContactInfo: x
|
|
1296
1326
|
}) {
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1327
|
+
const R = t.contactName ?? t.subject ?? t.providerConversationKey, I = i == null ? void 0 : i.provider, E = !!(g != null && g.some((C) => C.contactInfoRows)), [W, O] = y({ channel: !0, stats: !1, extra: !0 }), D = (C) => O((te) => ({ ...te, [C]: !te[C] })), [L, P] = y(""), [K, ee] = y(!1), [U, S] = y(!1), [z, b] = y(""), [T, ie] = y([]), [B, N] = y(!1);
|
|
1328
|
+
V(() => {
|
|
1329
|
+
P(""), S(!1), b(""), s.getNote(t.id).then((C) => {
|
|
1330
|
+
C && P(C.content);
|
|
1301
1331
|
}).catch(() => {
|
|
1302
1332
|
});
|
|
1303
|
-
}, [t.id, s]),
|
|
1304
|
-
if (!
|
|
1305
|
-
let
|
|
1306
|
-
const
|
|
1333
|
+
}, [t.id, s]), V(() => {
|
|
1334
|
+
if (!E || !g) return;
|
|
1335
|
+
let C = !1;
|
|
1336
|
+
const te = Ae(t, {
|
|
1307
1337
|
provider: I,
|
|
1308
1338
|
linkContact: f,
|
|
1309
|
-
refreshContactInfo:
|
|
1310
|
-
sendMessage: async (
|
|
1311
|
-
await s.sendMessage(t.id,
|
|
1339
|
+
refreshContactInfo: x,
|
|
1340
|
+
sendMessage: async (q, w) => {
|
|
1341
|
+
await s.sendMessage(t.id, q, w);
|
|
1312
1342
|
}
|
|
1313
1343
|
});
|
|
1314
|
-
return
|
|
1315
|
-
|
|
1316
|
-
).then((
|
|
1317
|
-
if (
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1344
|
+
return N(!0), Promise.allSettled(
|
|
1345
|
+
g.filter((q) => q.contactInfoRows).map((q) => q.contactInfoRows(te))
|
|
1346
|
+
).then((q) => {
|
|
1347
|
+
if (C) return;
|
|
1348
|
+
const w = q.filter((_) => _.status === "fulfilled").flatMap((_) => _.value);
|
|
1349
|
+
ie(w), N(!1);
|
|
1320
1350
|
}), () => {
|
|
1321
|
-
|
|
1351
|
+
C = !0;
|
|
1322
1352
|
};
|
|
1323
|
-
}, [t.id, t.contactExternalId,
|
|
1324
|
-
async function
|
|
1325
|
-
if (!(!
|
|
1326
|
-
|
|
1353
|
+
}, [t.id, t.contactExternalId, g, $, E, I, f, x, s]);
|
|
1354
|
+
async function de() {
|
|
1355
|
+
if (!(!L.trim() || K)) {
|
|
1356
|
+
ee(!0), b("");
|
|
1327
1357
|
try {
|
|
1328
|
-
await s.upsertNote(t.id,
|
|
1358
|
+
await s.upsertNote(t.id, L.trim()), S(!0), setTimeout(() => S(!1), 2e3);
|
|
1329
1359
|
} catch {
|
|
1330
|
-
|
|
1360
|
+
b("Lưu thất bại");
|
|
1331
1361
|
} finally {
|
|
1332
|
-
|
|
1362
|
+
ee(!1);
|
|
1333
1363
|
}
|
|
1334
1364
|
}
|
|
1335
1365
|
}
|
|
@@ -1337,13 +1367,13 @@ function qt({
|
|
|
1337
1367
|
/* @__PURE__ */ e(
|
|
1338
1368
|
"div",
|
|
1339
1369
|
{
|
|
1340
|
-
onMouseDown:
|
|
1370
|
+
onMouseDown: k,
|
|
1341
1371
|
style: { position: "absolute", left: 0, top: 0, bottom: 0, width: 4, cursor: "col-resize", zIndex: 1 },
|
|
1342
|
-
onMouseEnter: (
|
|
1343
|
-
|
|
1372
|
+
onMouseEnter: (C) => {
|
|
1373
|
+
C.currentTarget.style.background = "rgba(0,0,0,0.07)";
|
|
1344
1374
|
},
|
|
1345
|
-
onMouseLeave: (
|
|
1346
|
-
|
|
1375
|
+
onMouseLeave: (C) => {
|
|
1376
|
+
C.currentTarget.style.background = "";
|
|
1347
1377
|
}
|
|
1348
1378
|
}
|
|
1349
1379
|
),
|
|
@@ -1355,61 +1385,61 @@ function qt({
|
|
|
1355
1385
|
/* @__PURE__ */ n("div", { style: p.infoPanelIdentity, children: [
|
|
1356
1386
|
/* @__PURE__ */ n("span", { style: { ...p.avatarWrap, width: 48, height: 48 }, children: [
|
|
1357
1387
|
/* @__PURE__ */ e(
|
|
1358
|
-
|
|
1388
|
+
qe,
|
|
1359
1389
|
{
|
|
1360
1390
|
src: t.contactPictureUrl,
|
|
1361
|
-
fallback:
|
|
1391
|
+
fallback: gt(R),
|
|
1362
1392
|
style: { ...p.avatar, width: 48, height: 48, fontSize: 16 }
|
|
1363
1393
|
}
|
|
1364
1394
|
),
|
|
1365
1395
|
/* @__PURE__ */ e("span", { style: { ...p.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e($e, { provider: I }) })
|
|
1366
1396
|
] }),
|
|
1367
|
-
/* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: d.ink, textAlign: "center" }, children:
|
|
1397
|
+
/* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: d.ink, textAlign: "center" }, children: R }),
|
|
1368
1398
|
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: d.muted, fontFamily: "monospace", textAlign: "center" }, children: t.providerConversationKey })
|
|
1369
1399
|
] }),
|
|
1370
|
-
/* @__PURE__ */ n(
|
|
1371
|
-
/* @__PURE__ */ e(
|
|
1400
|
+
/* @__PURE__ */ n(De, { label: "KÊNH", sectionKey: "channel", expanded: W.channel, onToggle: () => D("channel"), children: [
|
|
1401
|
+
/* @__PURE__ */ e(pe, { label: "Nền tảng", children: /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
|
|
1372
1402
|
/* @__PURE__ */ e($e, { provider: I }),
|
|
1373
|
-
/* @__PURE__ */ e("span", { children:
|
|
1403
|
+
/* @__PURE__ */ e("span", { children: ut(I) })
|
|
1374
1404
|
] }) }),
|
|
1375
|
-
/* @__PURE__ */ n(
|
|
1405
|
+
/* @__PURE__ */ n(pe, { label: "ID hội thoại", children: [
|
|
1376
1406
|
/* @__PURE__ */ n("span", { style: { fontFamily: "monospace", fontSize: 11 }, children: [
|
|
1377
1407
|
t.id.slice(0, 8),
|
|
1378
1408
|
"…"
|
|
1379
1409
|
] }),
|
|
1380
|
-
/* @__PURE__ */ e(
|
|
1410
|
+
/* @__PURE__ */ e(Gt, { value: t.id })
|
|
1381
1411
|
] })
|
|
1382
1412
|
] }),
|
|
1383
|
-
/* @__PURE__ */ n(
|
|
1384
|
-
/* @__PURE__ */ e(
|
|
1385
|
-
(t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(
|
|
1413
|
+
/* @__PURE__ */ n(De, { label: "THỐNG KÊ", sectionKey: "stats", expanded: W.stats, onToggle: () => D("stats"), children: [
|
|
1414
|
+
/* @__PURE__ */ e(pe, { label: "Tin nhắn", value: String(t.messageCount ?? 0) }),
|
|
1415
|
+
(t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(pe, { label: "Chưa đọc", value: String(t.unreadCount), valueColor: "#ef4444" }),
|
|
1386
1416
|
/* @__PURE__ */ e(
|
|
1387
|
-
|
|
1417
|
+
pe,
|
|
1388
1418
|
{
|
|
1389
1419
|
label: "Gần nhất",
|
|
1390
1420
|
value: t.lastMessageAt ? new Date(t.lastMessageAt).toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit", year: "numeric" }) : "—"
|
|
1391
1421
|
}
|
|
1392
1422
|
),
|
|
1393
|
-
/* @__PURE__ */ e(
|
|
1423
|
+
/* @__PURE__ */ e(pe, { label: "Lần đầu", value: "—" })
|
|
1394
1424
|
] }),
|
|
1395
|
-
/* @__PURE__ */ n(
|
|
1396
|
-
!
|
|
1397
|
-
/* @__PURE__ */ e(
|
|
1398
|
-
/* @__PURE__ */ e(
|
|
1399
|
-
/* @__PURE__ */ e(
|
|
1425
|
+
/* @__PURE__ */ n(De, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: W.extra, onToggle: () => D("extra"), children: [
|
|
1426
|
+
!E && /* @__PURE__ */ n(ne, { children: [
|
|
1427
|
+
/* @__PURE__ */ e(pe, { label: "Điện thoại", value: "— chưa có", valueMuted: !0 }),
|
|
1428
|
+
/* @__PURE__ */ e(pe, { label: "Email", value: "— chưa có", valueMuted: !0 }),
|
|
1429
|
+
/* @__PURE__ */ e(pe, { label: "Nhãn", value: "— chưa có", valueMuted: !0 })
|
|
1400
1430
|
] }),
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1431
|
+
B && T.length === 0 && /* @__PURE__ */ e("div", { style: { fontSize: 12, color: d.muted, padding: "6px 0" }, children: "Đang tải hồ sơ CRM…" }),
|
|
1432
|
+
T.map((C) => /* @__PURE__ */ e(pe, { label: C.label, children: /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap", justifyContent: "flex-end" }, children: [
|
|
1433
|
+
C.onClick ? /* @__PURE__ */ e(
|
|
1404
1434
|
"button",
|
|
1405
1435
|
{
|
|
1406
1436
|
type: "button",
|
|
1407
|
-
onClick:
|
|
1437
|
+
onClick: C.onClick,
|
|
1408
1438
|
style: { border: 0, background: "none", padding: 0, color: r, fontSize: 12, fontWeight: 600, cursor: "pointer", textDecoration: "underline" },
|
|
1409
|
-
children:
|
|
1439
|
+
children: C.value
|
|
1410
1440
|
}
|
|
1411
|
-
) :
|
|
1412
|
-
|
|
1441
|
+
) : C.href ? /* @__PURE__ */ e("a", { href: C.href, target: "_blank", rel: "noopener noreferrer", style: { color: r, fontSize: 12, fontWeight: 600 }, children: C.value }) : /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 500, color: d.ink }, children: C.value }),
|
|
1442
|
+
C.badge && /* @__PURE__ */ e(
|
|
1413
1443
|
"span",
|
|
1414
1444
|
{
|
|
1415
1445
|
style: {
|
|
@@ -1417,58 +1447,58 @@ function qt({
|
|
|
1417
1447
|
fontWeight: 700,
|
|
1418
1448
|
padding: "1px 7px",
|
|
1419
1449
|
borderRadius: 999,
|
|
1420
|
-
color:
|
|
1421
|
-
background:
|
|
1450
|
+
color: C.badge.color ?? r,
|
|
1451
|
+
background: C.badge.bg ?? `${r}14`
|
|
1422
1452
|
},
|
|
1423
|
-
children:
|
|
1453
|
+
children: C.badge.text
|
|
1424
1454
|
}
|
|
1425
1455
|
)
|
|
1426
|
-
] }) },
|
|
1456
|
+
] }) }, C.label))
|
|
1427
1457
|
] }),
|
|
1428
1458
|
/* @__PURE__ */ n("div", { style: { padding: "12px 16px", display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
1429
|
-
!(
|
|
1430
|
-
|
|
1431
|
-
const
|
|
1459
|
+
!(g != null && g.length) && /* @__PURE__ */ e("button", { style: { ...p.ghostButton, color: r, borderColor: `${r}33` }, children: "Xem lịch sử" }),
|
|
1460
|
+
g == null ? void 0 : g.flatMap((C) => C.sidebarActions ?? []).map((C, te) => {
|
|
1461
|
+
const q = C.variant === "primary";
|
|
1432
1462
|
return /* @__PURE__ */ n(
|
|
1433
1463
|
"button",
|
|
1434
1464
|
{
|
|
1435
1465
|
style: {
|
|
1436
1466
|
...p.ghostButton,
|
|
1437
|
-
background:
|
|
1438
|
-
color:
|
|
1439
|
-
borderColor:
|
|
1440
|
-
fontWeight:
|
|
1467
|
+
background: q ? r : "#fff",
|
|
1468
|
+
color: q ? "#fff" : d.ink,
|
|
1469
|
+
borderColor: q ? r : d.line,
|
|
1470
|
+
fontWeight: q ? 700 : 600,
|
|
1441
1471
|
display: "flex",
|
|
1442
1472
|
alignItems: "center",
|
|
1443
1473
|
justifyContent: "center",
|
|
1444
1474
|
gap: 6
|
|
1445
1475
|
},
|
|
1446
1476
|
onClick: () => {
|
|
1447
|
-
const
|
|
1477
|
+
const w = Ae(t, {
|
|
1448
1478
|
provider: I,
|
|
1449
1479
|
linkContact: f,
|
|
1450
|
-
refreshContactInfo:
|
|
1451
|
-
sendMessage: async (
|
|
1452
|
-
await s.sendMessage(t.id,
|
|
1480
|
+
refreshContactInfo: x,
|
|
1481
|
+
sendMessage: async (_, he) => {
|
|
1482
|
+
await s.sendMessage(t.id, _, he);
|
|
1453
1483
|
}
|
|
1454
1484
|
});
|
|
1455
|
-
|
|
1485
|
+
C.onClick(w);
|
|
1456
1486
|
},
|
|
1457
1487
|
children: [
|
|
1458
|
-
|
|
1459
|
-
|
|
1488
|
+
C.icon,
|
|
1489
|
+
C.label
|
|
1460
1490
|
]
|
|
1461
1491
|
},
|
|
1462
|
-
|
|
1492
|
+
te
|
|
1463
1493
|
);
|
|
1464
1494
|
}),
|
|
1465
|
-
/* @__PURE__ */ n("div", { style: { border:
|
|
1466
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "7px 10px", borderBottom: "1px solid #fde68a", fontSize: 11, fontWeight: 600, color: "#92400e" }, children: "Ghi chú nội bộ" }),
|
|
1495
|
+
/* @__PURE__ */ n("div", { style: { border: `1px solid ${d.line}`, borderRadius: 10, background: "#fff", overflow: "hidden" }, children: [
|
|
1496
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "7px 10px", borderBottom: "1px solid #fde68a", background: "#fffbeb", fontSize: 11, fontWeight: 600, color: "#92400e" }, children: "Ghi chú nội bộ" }),
|
|
1467
1497
|
/* @__PURE__ */ e(
|
|
1468
1498
|
"textarea",
|
|
1469
1499
|
{
|
|
1470
|
-
value:
|
|
1471
|
-
onChange: (
|
|
1500
|
+
value: L,
|
|
1501
|
+
onChange: (C) => P(C.target.value),
|
|
1472
1502
|
placeholder: "Nhập ghi chú...",
|
|
1473
1503
|
rows: 3,
|
|
1474
1504
|
style: { display: "block", width: "100%", boxSizing: "border-box", border: 0, outline: 0, background: "transparent", resize: "none", padding: "8px 10px", font: "inherit", fontSize: 12, color: d.ink, lineHeight: 1.5 }
|
|
@@ -1476,18 +1506,18 @@ function qt({
|
|
|
1476
1506
|
),
|
|
1477
1507
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 10px 6px" }, children: [
|
|
1478
1508
|
U ? /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#16a34a" }, children: [
|
|
1479
|
-
/* @__PURE__ */ e(
|
|
1509
|
+
/* @__PURE__ */ e(lt, { size: 11, strokeWidth: 2.5 }),
|
|
1480
1510
|
" Đã lưu"
|
|
1481
|
-
] }) :
|
|
1511
|
+
] }) : z ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: z }) : /* @__PURE__ */ e("span", {}),
|
|
1482
1512
|
/* @__PURE__ */ e(
|
|
1483
1513
|
"button",
|
|
1484
1514
|
{
|
|
1485
1515
|
type: "button",
|
|
1486
1516
|
onClick: () => {
|
|
1487
|
-
|
|
1517
|
+
de();
|
|
1488
1518
|
},
|
|
1489
|
-
disabled: !
|
|
1490
|
-
style: { padding: "4px 12px", border: 0, borderRadius: 7, fontSize: 12, fontWeight: 600, background:
|
|
1519
|
+
disabled: !L.trim() || K,
|
|
1520
|
+
style: { padding: "4px 12px", border: 0, borderRadius: 7, fontSize: 12, fontWeight: 600, background: L.trim() && !K ? "linear-gradient(135deg,#f59e0b,#fbbf24)" : "#e5e7eb", color: L.trim() && !K ? "#fff" : "#9ca3af", cursor: L.trim() && !K ? "pointer" : "not-allowed" },
|
|
1491
1521
|
children: K ? "Đang lưu…" : "Lưu ghi chú"
|
|
1492
1522
|
}
|
|
1493
1523
|
)
|
|
@@ -1497,31 +1527,31 @@ function qt({
|
|
|
1497
1527
|
] })
|
|
1498
1528
|
] });
|
|
1499
1529
|
}
|
|
1500
|
-
function
|
|
1501
|
-
const
|
|
1530
|
+
function De({ label: t, children: i, sectionKey: r, expanded: o, onToggle: s }) {
|
|
1531
|
+
const k = !!s, g = o ?? !0;
|
|
1502
1532
|
return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${d.line}` }, children: [
|
|
1503
1533
|
/* @__PURE__ */ n(
|
|
1504
1534
|
"div",
|
|
1505
1535
|
{
|
|
1506
|
-
style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "10px 16px 6px", fontSize: 10, fontWeight: 700, letterSpacing: 1, color: d.muted, textTransform: "uppercase", cursor:
|
|
1536
|
+
style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "10px 16px 6px", fontSize: 10, fontWeight: 700, letterSpacing: 1, color: d.muted, textTransform: "uppercase", cursor: k ? "pointer" : "default" },
|
|
1507
1537
|
onClick: s,
|
|
1508
1538
|
children: [
|
|
1509
1539
|
/* @__PURE__ */ e("span", { children: t }),
|
|
1510
|
-
|
|
1540
|
+
k && (g ? /* @__PURE__ */ e(St, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(Ct, { size: 12, strokeWidth: 2 }))
|
|
1511
1541
|
]
|
|
1512
1542
|
}
|
|
1513
1543
|
),
|
|
1514
|
-
|
|
1544
|
+
g && i
|
|
1515
1545
|
] });
|
|
1516
1546
|
}
|
|
1517
|
-
function
|
|
1518
|
-
return /* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "
|
|
1519
|
-
/* @__PURE__ */ e("span", { style: { color: d.muted, flexShrink: 0 }, children: t }),
|
|
1520
|
-
/* @__PURE__ */ e("span", { style: { color: o ?? (s ? d.muted : d.ink), textAlign: "right", minWidth: 0,
|
|
1547
|
+
function pe({ label: t, value: i, children: r, valueColor: o, valueMuted: s }) {
|
|
1548
|
+
return /* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", padding: "5px 16px", fontSize: 12, gap: 10 }, children: [
|
|
1549
|
+
/* @__PURE__ */ e("span", { style: { color: d.muted, flexShrink: 0, lineHeight: 1.4 }, children: t }),
|
|
1550
|
+
/* @__PURE__ */ e("span", { style: { color: o ?? (s ? d.muted : d.ink), textAlign: "right", minWidth: 0, display: "flex", alignItems: "center", justifyContent: "flex-end", flexWrap: "wrap", gap: 4, lineHeight: 1.4 }, children: r ?? i })
|
|
1521
1551
|
] });
|
|
1522
1552
|
}
|
|
1523
|
-
function
|
|
1524
|
-
const [i, r] =
|
|
1553
|
+
function Gt({ value: t }) {
|
|
1554
|
+
const [i, r] = y(!1);
|
|
1525
1555
|
return /* @__PURE__ */ e(
|
|
1526
1556
|
"button",
|
|
1527
1557
|
{
|
|
@@ -1537,31 +1567,31 @@ function Vt({ value: t }) {
|
|
|
1537
1567
|
}
|
|
1538
1568
|
);
|
|
1539
1569
|
}
|
|
1540
|
-
function
|
|
1570
|
+
function Xt() {
|
|
1541
1571
|
return /* @__PURE__ */ n("div", { style: p.empty, children: [
|
|
1542
|
-
/* @__PURE__ */ e("div", { style: p.emptyHero, children: /* @__PURE__ */ e(
|
|
1572
|
+
/* @__PURE__ */ e("div", { style: p.emptyHero, children: /* @__PURE__ */ e(Tt, { size: 16, strokeWidth: 2 }) }),
|
|
1543
1573
|
/* @__PURE__ */ e("h2", { children: "Chọn một hội thoại" }),
|
|
1544
1574
|
/* @__PURE__ */ e("p", { children: "Chọn hội thoại bên trái để xem và trả lời tin nhắn." })
|
|
1545
1575
|
] });
|
|
1546
1576
|
}
|
|
1547
|
-
function
|
|
1577
|
+
function ft({ name: t, color: i, image: r, provider: o }) {
|
|
1548
1578
|
return /* @__PURE__ */ n("span", { style: p.avatarWrap, children: [
|
|
1549
|
-
/* @__PURE__ */ e(
|
|
1579
|
+
/* @__PURE__ */ e(Yt, { name: t, color: i, image: r }),
|
|
1550
1580
|
o && /* @__PURE__ */ e("span", { style: p.providerBadge, children: /* @__PURE__ */ e($e, { provider: o }) })
|
|
1551
1581
|
] });
|
|
1552
1582
|
}
|
|
1553
|
-
function
|
|
1554
|
-
return /* @__PURE__ */ e(
|
|
1583
|
+
function Yt({ name: t, color: i, image: r }) {
|
|
1584
|
+
return /* @__PURE__ */ e(qe, { src: r, fallback: gt(t), style: { ...p.avatar, background: `${i}18`, color: i } });
|
|
1555
1585
|
}
|
|
1556
1586
|
function Fe() {
|
|
1557
|
-
return /* @__PURE__ */ e(
|
|
1587
|
+
return /* @__PURE__ */ e(ct, { size: 14, style: p.spinner, "aria-hidden": "true" });
|
|
1558
1588
|
}
|
|
1559
|
-
function
|
|
1589
|
+
function gt(t) {
|
|
1560
1590
|
return t.split(/\s+/).filter(Boolean).slice(-2).map((i) => i[0]).join("").toUpperCase() || "?";
|
|
1561
1591
|
}
|
|
1562
1592
|
const Jt = { livechat: "web" };
|
|
1563
1593
|
function $e({ provider: t }) {
|
|
1564
|
-
const i = Ne(
|
|
1594
|
+
const i = Ne(Ve), r = 14;
|
|
1565
1595
|
if (!t) return null;
|
|
1566
1596
|
const o = Jt[t] ?? t;
|
|
1567
1597
|
return /* @__PURE__ */ e("img", { src: `${i}/static/logos/${o}.avif`, alt: t, width: r, height: r, style: { borderRadius: "50%", objectFit: "cover", display: "block" } });
|
|
@@ -1582,13 +1612,13 @@ const p = {
|
|
|
1582
1612
|
clear: { border: 0, background: "none", color: d.muted, cursor: "pointer", fontSize: 18 },
|
|
1583
1613
|
listHeader: { display: "flex", alignItems: "center", padding: "10px 18px", borderTop: `1px solid ${d.line}`, borderBottom: `1px solid ${d.line}`, color: d.muted, fontSize: 11, fontWeight: 700, letterSpacing: 0.4, textTransform: "uppercase" },
|
|
1584
1614
|
conversationList: { overflowY: "auto", flex: 1, minHeight: 0 },
|
|
1585
|
-
row: { display: "flex", width: "100%", gap: 11, padding: "
|
|
1586
|
-
avatarWrap: { position: "relative", flex: "0 0 auto", width:
|
|
1587
|
-
avatar: { flex: "0 0 auto", width:
|
|
1615
|
+
row: { display: "flex", width: "100%", gap: 11, padding: "16px 14px", border: 0, borderBottom: `1px solid ${d.line}`, background: "transparent", textAlign: "left", cursor: "pointer", transition: "background 120ms ease" },
|
|
1616
|
+
avatarWrap: { position: "relative", flex: "0 0 auto", width: 44, height: 44 },
|
|
1617
|
+
avatar: { flex: "0 0 auto", width: 44, height: 44, display: "grid", placeItems: "center", borderRadius: "50%", objectFit: "cover", fontSize: 14, fontWeight: 800 },
|
|
1588
1618
|
providerBadge: { position: "absolute", left: -3, bottom: -3, display: "grid", placeItems: "center", width: 17, height: 17, border: "2px solid #fff", borderRadius: "50%", background: "#fff", color: "#64748b" },
|
|
1589
1619
|
rowBody: { minWidth: 0, flex: 1 },
|
|
1590
|
-
rowTop: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 8, fontSize:
|
|
1591
|
-
rowBottom: { display: "flex", marginTop: 4, fontSize:
|
|
1620
|
+
rowTop: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 8, fontSize: 14 },
|
|
1621
|
+
rowBottom: { display: "flex", marginTop: 4, fontSize: 12, minWidth: 0, overflow: "hidden", lineHeight: 1.4 },
|
|
1592
1622
|
unreadBadge: { display: "inline-grid", placeItems: "center", minWidth: 18, height: 18, borderRadius: 999, background: "#ef4444", color: "#fff", fontSize: 10, fontWeight: 800, padding: "0 5px" },
|
|
1593
1623
|
loadMore: { width: "100%", border: 0, background: "transparent", color: "#4c72ca", padding: 14, cursor: "pointer", fontSize: 12 },
|
|
1594
1624
|
emptySmall: { display: "grid", justifyItems: "center", gap: 7, padding: "56px 24px", color: d.muted, fontSize: 12, textAlign: "center" },
|
|
@@ -1618,7 +1648,7 @@ const p = {
|
|
|
1618
1648
|
infoPanelHeader: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 16px 12px", borderBottom: `1px solid ${d.line}`, flex: "0 0 auto" },
|
|
1619
1649
|
infoPanelIdentity: { display: "flex", flexDirection: "column", alignItems: "center", padding: "20px 16px 16px", gap: 4 },
|
|
1620
1650
|
ghostButton: { width: "100%", padding: "8px 12px", border: `1px solid ${d.line}`, borderRadius: 8, background: "transparent", fontSize: 12, cursor: "pointer", textAlign: "center" }
|
|
1621
|
-
},
|
|
1651
|
+
}, Zt = {
|
|
1622
1652
|
facebook: "#dbeafe",
|
|
1623
1653
|
zalo: "#e0f2fe",
|
|
1624
1654
|
instagram: "#fce7f3",
|
|
@@ -1634,7 +1664,7 @@ const p = {
|
|
|
1634
1664
|
whatsapp: "web"
|
|
1635
1665
|
};
|
|
1636
1666
|
function ge({ provider: t, apiUrl: i, size: r = 40 }) {
|
|
1637
|
-
const o =
|
|
1667
|
+
const o = Zt[t] ?? "#f1f5f9", s = _t[t], k = i.replace(/\/$/, "");
|
|
1638
1668
|
return /* @__PURE__ */ e(
|
|
1639
1669
|
"div",
|
|
1640
1670
|
{
|
|
@@ -1652,7 +1682,7 @@ function ge({ provider: t, apiUrl: i, size: r = 40 }) {
|
|
|
1652
1682
|
children: s ? /* @__PURE__ */ e(
|
|
1653
1683
|
"img",
|
|
1654
1684
|
{
|
|
1655
|
-
src: `${
|
|
1685
|
+
src: `${k}/static/logos/${s}.avif`,
|
|
1656
1686
|
alt: t,
|
|
1657
1687
|
width: Math.round(r * 0.65),
|
|
1658
1688
|
height: Math.round(r * 0.65),
|
|
@@ -1669,7 +1699,7 @@ const Be = {
|
|
|
1669
1699
|
telegram: "Telegram",
|
|
1670
1700
|
livechat: "Live Chat",
|
|
1671
1701
|
whatsapp: "WhatsApp"
|
|
1672
|
-
},
|
|
1702
|
+
}, Qt = {
|
|
1673
1703
|
facebook: "#dbeafe",
|
|
1674
1704
|
zalo: "#e0f2fe",
|
|
1675
1705
|
instagram: "#fce7f3",
|
|
@@ -1677,11 +1707,11 @@ const Be = {
|
|
|
1677
1707
|
livechat: "#ede9fe",
|
|
1678
1708
|
whatsapp: "#dcfce7"
|
|
1679
1709
|
};
|
|
1680
|
-
function
|
|
1710
|
+
function Ge(t) {
|
|
1681
1711
|
const i = t.metadata;
|
|
1682
1712
|
return String(i.displayName ?? i.pageName ?? i.username ?? i.name ?? t.externalAccountId);
|
|
1683
1713
|
}
|
|
1684
|
-
function
|
|
1714
|
+
function en(t) {
|
|
1685
1715
|
const i = Be[t.provider] ?? t.provider, r = String(t.metadata.username ?? t.metadata.pageName ?? "");
|
|
1686
1716
|
return r ? `${i} · ${r}` : i;
|
|
1687
1717
|
}
|
|
@@ -1960,68 +1990,68 @@ const a = {
|
|
|
1960
1990
|
fontFamily: "inherit"
|
|
1961
1991
|
}
|
|
1962
1992
|
};
|
|
1963
|
-
function
|
|
1993
|
+
function et() {
|
|
1964
1994
|
return /* @__PURE__ */ e("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ e("path", { d: "M7 1v12M1 7h12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) });
|
|
1965
1995
|
}
|
|
1966
1996
|
function ve() {
|
|
1967
1997
|
return /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ e("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1968
1998
|
}
|
|
1969
|
-
function
|
|
1999
|
+
function tt() {
|
|
1970
2000
|
return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: [
|
|
1971
2001
|
/* @__PURE__ */ e("rect", { x: "4", y: "4", width: "7", height: "7", rx: "1.5", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
1972
2002
|
/* @__PURE__ */ e("path", { d: "M2.5 8H2a1 1 0 01-1-1V2a1 1 0 011-1h5a1 1 0 011 1v.5", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
|
|
1973
2003
|
] });
|
|
1974
2004
|
}
|
|
1975
|
-
function
|
|
2005
|
+
function nt() {
|
|
1976
2006
|
return /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ e("path", { d: "M2 6l3 3 5-5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1977
2007
|
}
|
|
1978
|
-
function
|
|
2008
|
+
function tn() {
|
|
1979
2009
|
return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0 }, children: [
|
|
1980
2010
|
/* @__PURE__ */ e("circle", { cx: "5", cy: "6", r: "3.5", stroke: "#ca8a04", strokeWidth: "1.4" }),
|
|
1981
2011
|
/* @__PURE__ */ e("path", { d: "M8 7.5l4.5 4.5M10.5 10l1.5 1.5", stroke: "#ca8a04", strokeWidth: "1.4", strokeLinecap: "round" })
|
|
1982
2012
|
] });
|
|
1983
2013
|
}
|
|
1984
|
-
function
|
|
2014
|
+
function nn() {
|
|
1985
2015
|
return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0, marginTop: 1 }, children: [
|
|
1986
2016
|
/* @__PURE__ */ e("circle", { cx: "7", cy: "7", r: "6", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1987
2017
|
/* @__PURE__ */ e("path", { d: "M7 6v5M7 4.5v.01", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
1988
2018
|
] });
|
|
1989
2019
|
}
|
|
1990
|
-
let
|
|
1991
|
-
function
|
|
1992
|
-
if (
|
|
1993
|
-
|
|
2020
|
+
let it = !1;
|
|
2021
|
+
function rn() {
|
|
2022
|
+
if (it || typeof document > "u") return;
|
|
2023
|
+
it = !0;
|
|
1994
2024
|
const t = document.createElement("style");
|
|
1995
2025
|
t.textContent = "@keyframes ch-spin{to{transform:rotate(360deg)}}", document.head.appendChild(t);
|
|
1996
2026
|
}
|
|
1997
|
-
function
|
|
1998
|
-
const o = t.replace(/\/$/, ""), [s,
|
|
1999
|
-
|
|
2000
|
-
const
|
|
2027
|
+
function bn({ apiUrl: t, token: i, onConnectionChange: r }) {
|
|
2028
|
+
const o = t.replace(/\/$/, ""), [s, k] = y([]), [g, $] = y(!0), [f, x] = y({ name: "list" }), [R, I] = y(null), [E, W] = y(!1), [O, D] = y(""), [L, P] = y(""), [K, ee] = y(""), [U, S] = y(""), [z, b] = y(!1), [T, ie] = y(!1), B = Z(null);
|
|
2029
|
+
rn();
|
|
2030
|
+
const N = ke(async () => {
|
|
2001
2031
|
try {
|
|
2002
2032
|
const h = await fetch(`${o}/v1/connections`, {
|
|
2003
2033
|
headers: { authorization: `Bearer ${i}` }
|
|
2004
2034
|
});
|
|
2005
2035
|
if (!h.ok) throw new Error("Không tải được kênh");
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2036
|
+
const H = await h.json();
|
|
2037
|
+
k(H), r == null || r(H);
|
|
2008
2038
|
} catch (h) {
|
|
2009
2039
|
I(h instanceof Error ? h.message : "Lỗi tải dữ liệu");
|
|
2010
2040
|
} finally {
|
|
2011
|
-
|
|
2041
|
+
$(!1);
|
|
2012
2042
|
}
|
|
2013
2043
|
}, [o, i, r]);
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
}, [
|
|
2017
|
-
if (!
|
|
2044
|
+
V(() => {
|
|
2045
|
+
N();
|
|
2046
|
+
}, [N]), V(() => {
|
|
2047
|
+
if (!R) return;
|
|
2018
2048
|
const h = setTimeout(() => I(null), 5e3);
|
|
2019
2049
|
return () => clearTimeout(h);
|
|
2020
|
-
}, [
|
|
2021
|
-
|
|
2050
|
+
}, [R]), V(() => () => {
|
|
2051
|
+
B.current && window.removeEventListener("message", B.current);
|
|
2022
2052
|
}, []);
|
|
2023
|
-
async function
|
|
2024
|
-
if (confirm(`Bạn chắc chắn muốn ngắt kết nối "${
|
|
2053
|
+
async function de(h, H) {
|
|
2054
|
+
if (confirm(`Bạn chắc chắn muốn ngắt kết nối "${H}"?
|
|
2025
2055
|
|
|
2026
2056
|
Hành động này không thể hoàn tác.`))
|
|
2027
2057
|
try {
|
|
@@ -2029,194 +2059,194 @@ Hành động này không thể hoàn tác.`))
|
|
|
2029
2059
|
method: "DELETE",
|
|
2030
2060
|
headers: { authorization: `Bearer ${i}` }
|
|
2031
2061
|
})).ok) throw new Error("Không thể ngắt kết nối");
|
|
2032
|
-
await
|
|
2033
|
-
} catch (
|
|
2034
|
-
I(
|
|
2062
|
+
await N();
|
|
2063
|
+
} catch (F) {
|
|
2064
|
+
I(F instanceof Error ? F.message : "Lỗi ngắt kết nối");
|
|
2035
2065
|
}
|
|
2036
2066
|
}
|
|
2037
|
-
async function
|
|
2038
|
-
if (!
|
|
2067
|
+
async function C() {
|
|
2068
|
+
if (!O.trim()) {
|
|
2039
2069
|
I("Vui lòng nhập Bot Token");
|
|
2040
2070
|
return;
|
|
2041
2071
|
}
|
|
2042
|
-
if (!/^\d+:[A-Za-z0-9_-]+$/.test(
|
|
2072
|
+
if (!/^\d+:[A-Za-z0-9_-]+$/.test(O.trim())) {
|
|
2043
2073
|
I("Token không đúng định dạng");
|
|
2044
2074
|
return;
|
|
2045
2075
|
}
|
|
2046
|
-
|
|
2076
|
+
W(!0), I(null);
|
|
2047
2077
|
try {
|
|
2048
2078
|
const h = await fetch(`${o}/v1/connect/telegram/start`, {
|
|
2049
2079
|
method: "POST",
|
|
2050
2080
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2051
|
-
body: JSON.stringify({ botToken:
|
|
2052
|
-
}),
|
|
2053
|
-
if (!h.ok || !
|
|
2054
|
-
|
|
2081
|
+
body: JSON.stringify({ botToken: O.trim(), displayName: L.trim() || void 0 })
|
|
2082
|
+
}), H = await h.json();
|
|
2083
|
+
if (!h.ok || !H.connectionId) throw new Error(H.message ?? "Không thể kết nối Telegram");
|
|
2084
|
+
D(""), P(""), await N(), x({ name: "list" });
|
|
2055
2085
|
} catch (h) {
|
|
2056
2086
|
I(h instanceof Error ? h.message : "Lỗi kết nối");
|
|
2057
2087
|
} finally {
|
|
2058
|
-
|
|
2088
|
+
W(!1);
|
|
2059
2089
|
}
|
|
2060
2090
|
}
|
|
2061
|
-
async function
|
|
2091
|
+
async function te() {
|
|
2062
2092
|
if (!K.trim()) {
|
|
2063
2093
|
I("Vui lòng nhập tên widget");
|
|
2064
2094
|
return;
|
|
2065
2095
|
}
|
|
2066
|
-
|
|
2096
|
+
W(!0), I(null);
|
|
2067
2097
|
try {
|
|
2068
|
-
const h = U.split(/[\n,]+/).map((
|
|
2098
|
+
const h = U.split(/[\n,]+/).map((X) => X.trim()).filter(Boolean), H = await fetch(`${o}/v1/connect/livechat/start`, {
|
|
2069
2099
|
method: "POST",
|
|
2070
2100
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2071
2101
|
body: JSON.stringify({ displayName: K.trim(), allowedDomains: h.length ? h : void 0 })
|
|
2072
|
-
}),
|
|
2073
|
-
if (!
|
|
2074
|
-
|
|
2102
|
+
}), F = await H.json();
|
|
2103
|
+
if (!H.ok || !F.connectionId || !F.embedScript) throw new Error(F.message ?? "Không thể tạo widget");
|
|
2104
|
+
ee(""), S(""), await N(), x({
|
|
2075
2105
|
name: "livechat-result",
|
|
2076
|
-
connectionId:
|
|
2077
|
-
embedScript:
|
|
2078
|
-
identitySecret:
|
|
2079
|
-
allowedDomains:
|
|
2106
|
+
connectionId: F.connectionId,
|
|
2107
|
+
embedScript: F.embedScript,
|
|
2108
|
+
identitySecret: F.identitySecret ?? "",
|
|
2109
|
+
allowedDomains: F.allowedDomains ?? []
|
|
2080
2110
|
});
|
|
2081
2111
|
} catch (h) {
|
|
2082
2112
|
I(h instanceof Error ? h.message : "Lỗi tạo widget");
|
|
2083
2113
|
} finally {
|
|
2084
|
-
|
|
2114
|
+
W(!1);
|
|
2085
2115
|
}
|
|
2086
2116
|
}
|
|
2087
|
-
async function
|
|
2117
|
+
async function q(h) {
|
|
2088
2118
|
I(null);
|
|
2089
2119
|
try {
|
|
2090
|
-
const
|
|
2120
|
+
const H = `${o}/static/oauth-popup.html`, F = await fetch(`${o}/v1/connect/${h}/start`, {
|
|
2091
2121
|
method: "POST",
|
|
2092
2122
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2093
|
-
body: JSON.stringify({ callbackUrl:
|
|
2094
|
-
}),
|
|
2095
|
-
if (!
|
|
2096
|
-
const
|
|
2097
|
-
|
|
2098
|
-
const
|
|
2099
|
-
if (
|
|
2100
|
-
if (
|
|
2101
|
-
|
|
2123
|
+
body: JSON.stringify({ callbackUrl: H })
|
|
2124
|
+
}), X = await F.json();
|
|
2125
|
+
if (!F.ok || !X.authorizationUrl) throw new Error(X.message ?? "Không thể bắt đầu kết nối");
|
|
2126
|
+
const re = window.open(X.authorizationUrl, "channelhub-oauth", "width=600,height=700,scrollbars=yes,resizable=yes");
|
|
2127
|
+
x({ name: "oauth-waiting", provider: h, popup: re }), B.current && window.removeEventListener("message", B.current);
|
|
2128
|
+
const oe = (Y) => {
|
|
2129
|
+
if (Y.data) {
|
|
2130
|
+
if (Y.data.type === "channelhub:oauth-select") {
|
|
2131
|
+
x({
|
|
2102
2132
|
name: "oauth-select",
|
|
2103
|
-
provider:
|
|
2104
|
-
sessionId: String(
|
|
2105
|
-
pages:
|
|
2106
|
-
popup:
|
|
2133
|
+
provider: Y.data.provider,
|
|
2134
|
+
sessionId: String(Y.data.sessionId ?? ""),
|
|
2135
|
+
pages: Y.data.pages ?? [],
|
|
2136
|
+
popup: re
|
|
2107
2137
|
});
|
|
2108
2138
|
return;
|
|
2109
2139
|
}
|
|
2110
|
-
|
|
2140
|
+
Y.data.type === "channelhub:oauth" && (window.removeEventListener("message", oe), B.current = null, Y.data.status === "active" ? (N(), x({ name: "list" })) : (I("Kết nối thất bại: " + String(Y.data.error ?? "Không xác định")), x({ name: "list" })));
|
|
2111
2141
|
}
|
|
2112
2142
|
};
|
|
2113
|
-
|
|
2114
|
-
} catch (
|
|
2115
|
-
I(
|
|
2143
|
+
B.current = oe, window.addEventListener("message", oe);
|
|
2144
|
+
} catch (H) {
|
|
2145
|
+
I(H instanceof Error ? H.message : "Lỗi kết nối"), x({ name: "list" });
|
|
2116
2146
|
}
|
|
2117
2147
|
}
|
|
2118
|
-
function
|
|
2148
|
+
function w(h, H) {
|
|
2119
2149
|
navigator.clipboard.writeText(h).then(() => {
|
|
2120
|
-
|
|
2150
|
+
H === "script" ? (b(!0), setTimeout(() => b(!1), 2e3)) : (ie(!0), setTimeout(() => ie(!1), 2e3));
|
|
2121
2151
|
});
|
|
2122
2152
|
}
|
|
2123
|
-
function
|
|
2153
|
+
function _() {
|
|
2124
2154
|
const h = f.name === "oauth-waiting" || f.name === "oauth-select" ? f.popup : null;
|
|
2125
2155
|
if (h)
|
|
2126
2156
|
try {
|
|
2127
2157
|
h.close();
|
|
2128
2158
|
} catch {
|
|
2129
2159
|
}
|
|
2130
|
-
|
|
2160
|
+
B.current && (window.removeEventListener("message", B.current), B.current = null), x({ name: "add" });
|
|
2131
2161
|
}
|
|
2132
|
-
async function
|
|
2162
|
+
async function he(h) {
|
|
2133
2163
|
if (f.name !== "oauth-select") return;
|
|
2134
|
-
const { provider:
|
|
2135
|
-
|
|
2136
|
-
const
|
|
2164
|
+
const { provider: H, sessionId: F, popup: X } = f;
|
|
2165
|
+
W(!0), I(null);
|
|
2166
|
+
const re = {
|
|
2137
2167
|
facebook: `${o}/v1/connect/facebook/select-page`,
|
|
2138
2168
|
instagram: `${o}/v1/connect/instagram/select-account`,
|
|
2139
2169
|
zalo: `${o}/v1/connect/zalo/select-oa`
|
|
2140
|
-
},
|
|
2170
|
+
}, oe = {
|
|
2141
2171
|
facebook: "pageId",
|
|
2142
2172
|
instagram: "accountId",
|
|
2143
2173
|
zalo: "oaId"
|
|
2144
2174
|
};
|
|
2145
2175
|
try {
|
|
2146
|
-
const
|
|
2176
|
+
const Y = await fetch(re[H] ?? `${o}/v1/connect/${H}/select-page`, {
|
|
2147
2177
|
method: "POST",
|
|
2148
2178
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
2149
|
-
body: JSON.stringify({ sessionId:
|
|
2150
|
-
}), ye = await
|
|
2151
|
-
if (!
|
|
2152
|
-
if (
|
|
2179
|
+
body: JSON.stringify({ sessionId: F, [oe[H] ?? "pageId"]: h })
|
|
2180
|
+
}), ye = await Y.json();
|
|
2181
|
+
if (!Y.ok || !ye.connectionId) throw new Error(ye.message ?? "Không thể kết nối");
|
|
2182
|
+
if (X)
|
|
2153
2183
|
try {
|
|
2154
|
-
|
|
2184
|
+
X.postMessage({ type: "channelhub:close-popup" }, "*");
|
|
2155
2185
|
} catch {
|
|
2156
2186
|
}
|
|
2157
|
-
|
|
2158
|
-
} catch (
|
|
2159
|
-
I(
|
|
2187
|
+
B.current && (window.removeEventListener("message", B.current), B.current = null), await N(), x({ name: "list" });
|
|
2188
|
+
} catch (Y) {
|
|
2189
|
+
I(Y instanceof Error ? Y.message : "Lỗi kết nối");
|
|
2160
2190
|
} finally {
|
|
2161
|
-
|
|
2191
|
+
W(!1);
|
|
2162
2192
|
}
|
|
2163
2193
|
}
|
|
2164
2194
|
return /* @__PURE__ */ n("div", { style: a.root, children: [
|
|
2165
|
-
|
|
2166
|
-
f.name === "list" && /* @__PURE__ */ n(
|
|
2195
|
+
R && /* @__PURE__ */ e("div", { style: a.errorBanner, children: R }),
|
|
2196
|
+
f.name === "list" && /* @__PURE__ */ n(ne, { children: [
|
|
2167
2197
|
/* @__PURE__ */ n("div", { style: a.header, children: [
|
|
2168
2198
|
/* @__PURE__ */ e("div", { style: a.headerLeft, children: /* @__PURE__ */ n("div", { children: [
|
|
2169
2199
|
/* @__PURE__ */ e("div", { style: a.title, children: "Kênh kết nối" }),
|
|
2170
|
-
/* @__PURE__ */ e("div", { style: a.subtitle, children:
|
|
2200
|
+
/* @__PURE__ */ e("div", { style: a.subtitle, children: g ? "Đang tải…" : `${s.filter((h) => h.status === "active").length} kênh đang hoạt động` })
|
|
2171
2201
|
] }) }),
|
|
2172
|
-
/* @__PURE__ */ n("button", { style: a.addBtn, onClick: () =>
|
|
2173
|
-
/* @__PURE__ */ e(
|
|
2202
|
+
/* @__PURE__ */ n("button", { style: a.addBtn, onClick: () => x({ name: "add" }), children: [
|
|
2203
|
+
/* @__PURE__ */ e(et, {}),
|
|
2174
2204
|
/* @__PURE__ */ e("span", { children: "Thêm kênh" })
|
|
2175
2205
|
] })
|
|
2176
2206
|
] }),
|
|
2177
2207
|
/* @__PURE__ */ e("div", { style: a.divider }),
|
|
2178
|
-
/* @__PURE__ */ e("div", { style: a.body, children: !
|
|
2208
|
+
/* @__PURE__ */ e("div", { style: a.body, children: !g && s.length === 0 ? /* @__PURE__ */ n("div", { style: a.empty, children: [
|
|
2179
2209
|
/* @__PURE__ */ e("div", { style: { width: 64, height: 64, borderRadius: 16, background: "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(ge, { provider: "livechat", apiUrl: o, size: 40 }) }),
|
|
2180
2210
|
/* @__PURE__ */ e("div", { style: a.emptyTitle, children: "Chưa có kênh nào được kết nối" }),
|
|
2181
2211
|
/* @__PURE__ */ e("div", { style: a.emptyDesc, children: "Kết nối Facebook, Zalo OA, Telegram hoặc Live Chat để bắt đầu nhận tin nhắn từ khách hàng." }),
|
|
2182
|
-
/* @__PURE__ */ n("button", { style: a.emptyCta, onClick: () =>
|
|
2183
|
-
/* @__PURE__ */ e(
|
|
2212
|
+
/* @__PURE__ */ n("button", { style: a.emptyCta, onClick: () => x({ name: "add" }), children: [
|
|
2213
|
+
/* @__PURE__ */ e(et, {}),
|
|
2184
2214
|
"Kết nối kênh đầu tiên"
|
|
2185
2215
|
] })
|
|
2186
2216
|
] }) : /* @__PURE__ */ e("div", { children: s.map((h) => /* @__PURE__ */ e(
|
|
2187
|
-
|
|
2217
|
+
ln,
|
|
2188
2218
|
{
|
|
2189
2219
|
conn: h,
|
|
2190
2220
|
apiUrl: o,
|
|
2191
|
-
onDisconnect: () => void
|
|
2221
|
+
onDisconnect: () => void de(h.id, Ge(h))
|
|
2192
2222
|
},
|
|
2193
2223
|
h.id
|
|
2194
2224
|
)) }) })
|
|
2195
2225
|
] }),
|
|
2196
|
-
f.name === "add" && /* @__PURE__ */ n(
|
|
2226
|
+
f.name === "add" && /* @__PURE__ */ n(ne, { children: [
|
|
2197
2227
|
/* @__PURE__ */ e("div", { style: a.header, children: /* @__PURE__ */ n("div", { style: a.headerLeft, children: [
|
|
2198
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2228
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => x({ name: "list" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
2199
2229
|
/* @__PURE__ */ n("div", { children: [
|
|
2200
2230
|
/* @__PURE__ */ e("div", { style: a.title, children: "Thêm kênh mới" }),
|
|
2201
2231
|
/* @__PURE__ */ e("div", { style: a.subtitle, children: "Chọn nền tảng bạn muốn kết nối" })
|
|
2202
2232
|
] })
|
|
2203
2233
|
] }) }),
|
|
2204
2234
|
/* @__PURE__ */ e("div", { style: a.divider }),
|
|
2205
|
-
/* @__PURE__ */ e("div", { style: a.body, children: /* @__PURE__ */ e("div", { style: a.providerGrid, children:
|
|
2206
|
-
|
|
2235
|
+
/* @__PURE__ */ e("div", { style: a.body, children: /* @__PURE__ */ e("div", { style: a.providerGrid, children: dn.map((h) => /* @__PURE__ */ e(
|
|
2236
|
+
cn,
|
|
2207
2237
|
{
|
|
2208
2238
|
provider: h,
|
|
2209
2239
|
apiUrl: o,
|
|
2210
2240
|
onClick: () => {
|
|
2211
|
-
h.type === "oauth" ?
|
|
2241
|
+
h.type === "oauth" ? q(h.id) : h.id === "telegram" ? x({ name: "connect-telegram" }) : x({ name: "connect-livechat" });
|
|
2212
2242
|
}
|
|
2213
2243
|
},
|
|
2214
2244
|
h.id
|
|
2215
2245
|
)) }) })
|
|
2216
2246
|
] }),
|
|
2217
|
-
f.name === "connect-telegram" && /* @__PURE__ */ n(
|
|
2247
|
+
f.name === "connect-telegram" && /* @__PURE__ */ n(ne, { children: [
|
|
2218
2248
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2219
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2249
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => x({ name: "add" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
2220
2250
|
/* @__PURE__ */ e(ge, { provider: "telegram", apiUrl: o, size: 44 }),
|
|
2221
2251
|
/* @__PURE__ */ n("div", { children: [
|
|
2222
2252
|
/* @__PURE__ */ e("div", { style: a.connectTitle, children: "Kết nối Telegram Bot" }),
|
|
@@ -2225,7 +2255,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2225
2255
|
] }),
|
|
2226
2256
|
/* @__PURE__ */ n("div", { style: a.form, children: [
|
|
2227
2257
|
/* @__PURE__ */ n("div", { style: a.infoBox, children: [
|
|
2228
|
-
/* @__PURE__ */ e(
|
|
2258
|
+
/* @__PURE__ */ e(nn, {}),
|
|
2229
2259
|
/* @__PURE__ */ n("div", { children: [
|
|
2230
2260
|
"Tạo bot mới bằng cách nhắn tin cho ",
|
|
2231
2261
|
/* @__PURE__ */ e("strong", { children: "@BotFather" }),
|
|
@@ -2244,8 +2274,8 @@ Hành động này không thể hoàn tác.`))
|
|
|
2244
2274
|
{
|
|
2245
2275
|
style: a.input,
|
|
2246
2276
|
type: "text",
|
|
2247
|
-
value:
|
|
2248
|
-
onChange: (h) =>
|
|
2277
|
+
value: O,
|
|
2278
|
+
onChange: (h) => D(h.target.value),
|
|
2249
2279
|
placeholder: "1234567890:AAExxxxxxxxxxxxxxxxxxxxxxxx",
|
|
2250
2280
|
autoComplete: "off",
|
|
2251
2281
|
spellCheck: !1
|
|
@@ -2268,21 +2298,21 @@ Hành động này không thể hoàn tác.`))
|
|
|
2268
2298
|
{
|
|
2269
2299
|
style: a.input,
|
|
2270
2300
|
type: "text",
|
|
2271
|
-
value:
|
|
2272
|
-
onChange: (h) =>
|
|
2301
|
+
value: L,
|
|
2302
|
+
onChange: (h) => P(h.target.value),
|
|
2273
2303
|
placeholder: "VD: Bot hỗ trợ cửa hàng"
|
|
2274
2304
|
}
|
|
2275
2305
|
)
|
|
2276
2306
|
] }),
|
|
2277
2307
|
/* @__PURE__ */ n("div", { style: a.formActions, children: [
|
|
2278
|
-
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () =>
|
|
2279
|
-
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled:
|
|
2308
|
+
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () => x({ name: "add" }), children: "Hủy" }),
|
|
2309
|
+
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled: E, onClick: () => void C(), children: E ? "Đang kết nối…" : "Kết nối Telegram" })
|
|
2280
2310
|
] })
|
|
2281
2311
|
] })
|
|
2282
2312
|
] }),
|
|
2283
|
-
f.name === "connect-livechat" && /* @__PURE__ */ n(
|
|
2313
|
+
f.name === "connect-livechat" && /* @__PURE__ */ n(ne, { children: [
|
|
2284
2314
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2285
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2315
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => x({ name: "add" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
2286
2316
|
/* @__PURE__ */ e(ge, { provider: "livechat", apiUrl: o, size: 44 }),
|
|
2287
2317
|
/* @__PURE__ */ n("div", { children: [
|
|
2288
2318
|
/* @__PURE__ */ e("div", { style: a.connectTitle, children: "Tạo Live Chat Widget" }),
|
|
@@ -2301,7 +2331,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2301
2331
|
style: a.input,
|
|
2302
2332
|
type: "text",
|
|
2303
2333
|
value: K,
|
|
2304
|
-
onChange: (h) =>
|
|
2334
|
+
onChange: (h) => ee(h.target.value),
|
|
2305
2335
|
placeholder: "VD: Hỗ trợ website hanashop.vn"
|
|
2306
2336
|
}
|
|
2307
2337
|
)
|
|
@@ -2316,7 +2346,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2316
2346
|
{
|
|
2317
2347
|
style: { ...a.input, resize: "vertical", minHeight: 80, lineHeight: 1.5 },
|
|
2318
2348
|
value: U,
|
|
2319
|
-
onChange: (h) =>
|
|
2349
|
+
onChange: (h) => S(h.target.value),
|
|
2320
2350
|
placeholder: `https://myshop.com
|
|
2321
2351
|
https://www.myshop.com`,
|
|
2322
2352
|
spellCheck: !1
|
|
@@ -2325,14 +2355,14 @@ https://www.myshop.com`,
|
|
|
2325
2355
|
/* @__PURE__ */ e("div", { style: a.inputHint, children: "Mỗi domain một dòng. Để trống để cho phép tất cả." })
|
|
2326
2356
|
] }),
|
|
2327
2357
|
/* @__PURE__ */ n("div", { style: a.formActions, children: [
|
|
2328
|
-
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () =>
|
|
2329
|
-
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled:
|
|
2358
|
+
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () => x({ name: "add" }), children: "Hủy" }),
|
|
2359
|
+
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled: E, onClick: () => void te(), children: E ? "Đang tạo…" : "Tạo widget" })
|
|
2330
2360
|
] })
|
|
2331
2361
|
] })
|
|
2332
2362
|
] }),
|
|
2333
|
-
f.name === "livechat-result" && /* @__PURE__ */ n(
|
|
2363
|
+
f.name === "livechat-result" && /* @__PURE__ */ n(ne, { children: [
|
|
2334
2364
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2335
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2365
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => x({ name: "list" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
2336
2366
|
/* @__PURE__ */ e(ge, { provider: "livechat", apiUrl: o, size: 44 }),
|
|
2337
2367
|
/* @__PURE__ */ n("div", { children: [
|
|
2338
2368
|
/* @__PURE__ */ e("div", { style: a.connectTitle, children: "Widget đã được tạo!" }),
|
|
@@ -2353,11 +2383,11 @@ https://www.myshop.com`,
|
|
|
2353
2383
|
/* @__PURE__ */ e("div", { style: a.codeLabel, children: "Mã nhúng" }),
|
|
2354
2384
|
/* @__PURE__ */ n("div", { style: a.codeBlock, children: [
|
|
2355
2385
|
/* @__PURE__ */ e("pre", { style: a.codePre, children: f.embedScript }),
|
|
2356
|
-
/* @__PURE__ */ e("button", { style: { ...a.copyBtn, ...
|
|
2357
|
-
/* @__PURE__ */ e(
|
|
2386
|
+
/* @__PURE__ */ e("button", { style: { ...a.copyBtn, ...z ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () => w(f.embedScript, "script"), children: z ? /* @__PURE__ */ n(ne, { children: [
|
|
2387
|
+
/* @__PURE__ */ e(nt, {}),
|
|
2358
2388
|
" Đã sao chép"
|
|
2359
|
-
] }) : /* @__PURE__ */ n(
|
|
2360
|
-
/* @__PURE__ */ e(
|
|
2389
|
+
] }) : /* @__PURE__ */ n(ne, { children: [
|
|
2390
|
+
/* @__PURE__ */ e(tt, {}),
|
|
2361
2391
|
" Sao chép"
|
|
2362
2392
|
] }) })
|
|
2363
2393
|
] })
|
|
@@ -2368,29 +2398,29 @@ https://www.myshop.com`,
|
|
|
2368
2398
|
/* @__PURE__ */ e("span", { style: { ...a.labelHint, color: "#dc2626", fontWeight: 600 }, children: "Lưu ngay — chỉ hiển thị một lần" })
|
|
2369
2399
|
] }),
|
|
2370
2400
|
/* @__PURE__ */ n("div", { style: a.secretRow, children: [
|
|
2371
|
-
/* @__PURE__ */ e(
|
|
2401
|
+
/* @__PURE__ */ e(tn, {}),
|
|
2372
2402
|
/* @__PURE__ */ e("span", { style: a.secretLabel, children: "Secret:" }),
|
|
2373
2403
|
/* @__PURE__ */ e("span", { style: a.secretValue, children: f.identitySecret }),
|
|
2374
2404
|
/* @__PURE__ */ e(
|
|
2375
2405
|
"button",
|
|
2376
2406
|
{
|
|
2377
|
-
onClick: () =>
|
|
2378
|
-
style: { border: "none", background: "transparent", cursor: "pointer", color:
|
|
2379
|
-
children:
|
|
2407
|
+
onClick: () => w(f.identitySecret, "secret"),
|
|
2408
|
+
style: { border: "none", background: "transparent", cursor: "pointer", color: T ? "#059669" : "#ca8a04", padding: 2, display: "flex", alignItems: "center" },
|
|
2409
|
+
children: T ? /* @__PURE__ */ e(nt, {}) : /* @__PURE__ */ e(tt, {})
|
|
2380
2410
|
}
|
|
2381
2411
|
)
|
|
2382
2412
|
] }),
|
|
2383
2413
|
/* @__PURE__ */ e("div", { style: { ...a.inputHint, marginTop: 6 }, children: "Dùng secret này để xác thực danh tính người dùng (HMAC). Giữ bí mật — không chia sẻ nơi công khai." })
|
|
2384
2414
|
] }),
|
|
2385
2415
|
/* @__PURE__ */ n("div", { style: a.formActions, children: [
|
|
2386
|
-
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () =>
|
|
2387
|
-
/* @__PURE__ */ e("button", { style: a.btnPrimary, onClick: () =>
|
|
2416
|
+
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () => x({ name: "list" }), children: "Về danh sách" }),
|
|
2417
|
+
/* @__PURE__ */ e("button", { style: a.btnPrimary, onClick: () => x({ name: "add" }), children: "Thêm kênh khác" })
|
|
2388
2418
|
] })
|
|
2389
2419
|
] })
|
|
2390
2420
|
] }),
|
|
2391
|
-
f.name === "oauth-waiting" && /* @__PURE__ */ n(
|
|
2421
|
+
f.name === "oauth-waiting" && /* @__PURE__ */ n(ne, { children: [
|
|
2392
2422
|
/* @__PURE__ */ e("div", { style: a.header, children: /* @__PURE__ */ n("div", { style: a.headerLeft, children: [
|
|
2393
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick:
|
|
2423
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: _, children: /* @__PURE__ */ e(ve, {}) }),
|
|
2394
2424
|
/* @__PURE__ */ n("div", { children: [
|
|
2395
2425
|
/* @__PURE__ */ n("div", { style: a.title, children: [
|
|
2396
2426
|
"Đang xác thực ",
|
|
@@ -2401,7 +2431,7 @@ https://www.myshop.com`,
|
|
|
2401
2431
|
] }) }),
|
|
2402
2432
|
/* @__PURE__ */ n("div", { style: a.oauthWaiting, children: [
|
|
2403
2433
|
/* @__PURE__ */ n("div", { style: { position: "relative", width: 72, height: 72 }, children: [
|
|
2404
|
-
/* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background:
|
|
2434
|
+
/* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background: Qt[f.provider] ?? "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(ge, { provider: f.provider, apiUrl: o, size: 48 }) }),
|
|
2405
2435
|
/* @__PURE__ */ n(
|
|
2406
2436
|
"svg",
|
|
2407
2437
|
{
|
|
@@ -2434,16 +2464,16 @@ https://www.myshop.com`,
|
|
|
2434
2464
|
] }),
|
|
2435
2465
|
/* @__PURE__ */ e("div", { style: a.oauthDesc, children: "Một cửa sổ đăng nhập đã được mở. Vui lòng đăng nhập và cấp quyền truy cập để hoàn tất kết nối." }),
|
|
2436
2466
|
/* @__PURE__ */ n("div", { style: { display: "flex", flexDirection: "column", gap: 8, alignItems: "flex-start", width: "100%", maxWidth: 280 }, children: [
|
|
2437
|
-
/* @__PURE__ */ e(
|
|
2438
|
-
/* @__PURE__ */ e(
|
|
2439
|
-
/* @__PURE__ */ e(
|
|
2467
|
+
/* @__PURE__ */ e(Ue, { done: !0, label: `Đã mở cửa sổ ${Be[f.provider]}` }),
|
|
2468
|
+
/* @__PURE__ */ e(Ue, { active: !0, label: "Đang chờ bạn đăng nhập & cấp quyền" }),
|
|
2469
|
+
/* @__PURE__ */ e(Ue, { label: "Lưu kết nối & quay về" })
|
|
2440
2470
|
] }),
|
|
2441
|
-
/* @__PURE__ */ e("button", { style: a.oauthCancel, onClick:
|
|
2471
|
+
/* @__PURE__ */ e("button", { style: a.oauthCancel, onClick: _, children: "Hủy và quay lại" })
|
|
2442
2472
|
] })
|
|
2443
2473
|
] }),
|
|
2444
|
-
f.name === "oauth-select" && /* @__PURE__ */ n(
|
|
2474
|
+
f.name === "oauth-select" && /* @__PURE__ */ n(ne, { children: [
|
|
2445
2475
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2446
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick:
|
|
2476
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: _, children: /* @__PURE__ */ e(ve, {}) }),
|
|
2447
2477
|
/* @__PURE__ */ e(ge, { provider: f.provider, apiUrl: o, size: 44 }),
|
|
2448
2478
|
/* @__PURE__ */ n("div", { children: [
|
|
2449
2479
|
/* @__PURE__ */ n("div", { style: a.connectTitle, children: [
|
|
@@ -2460,8 +2490,8 @@ https://www.myshop.com`,
|
|
|
2460
2490
|
/* @__PURE__ */ e("div", { style: a.body, children: f.pages.length === 0 ? /* @__PURE__ */ e("div", { style: { textAlign: "center", color: "#94a3b8", fontSize: 13, padding: "24px 0" }, children: "Không tìm thấy trang/tài khoản nào. Hãy thử lại." }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: f.pages.map((h) => /* @__PURE__ */ n(
|
|
2461
2491
|
"button",
|
|
2462
2492
|
{
|
|
2463
|
-
disabled:
|
|
2464
|
-
onClick: () => void
|
|
2493
|
+
disabled: E,
|
|
2494
|
+
onClick: () => void he(h.id),
|
|
2465
2495
|
style: {
|
|
2466
2496
|
display: "flex",
|
|
2467
2497
|
alignItems: "center",
|
|
@@ -2470,8 +2500,8 @@ https://www.myshop.com`,
|
|
|
2470
2500
|
borderRadius: 12,
|
|
2471
2501
|
border: "1.5px solid #e2e8f0",
|
|
2472
2502
|
background: "#fff",
|
|
2473
|
-
cursor:
|
|
2474
|
-
opacity:
|
|
2503
|
+
cursor: E ? "not-allowed" : "pointer",
|
|
2504
|
+
opacity: E ? 0.6 : 1,
|
|
2475
2505
|
textAlign: "left",
|
|
2476
2506
|
fontFamily: "inherit",
|
|
2477
2507
|
transition: "border-color .15s, background .15s"
|
|
@@ -2481,7 +2511,7 @@ https://www.myshop.com`,
|
|
|
2481
2511
|
/* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children: h.name }),
|
|
2482
2512
|
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children: h.id })
|
|
2483
2513
|
] }),
|
|
2484
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children:
|
|
2514
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children: E ? "Đang kết nối…" : "Chọn →" })
|
|
2485
2515
|
]
|
|
2486
2516
|
},
|
|
2487
2517
|
h.id
|
|
@@ -2489,7 +2519,7 @@ https://www.myshop.com`,
|
|
|
2489
2519
|
] })
|
|
2490
2520
|
] });
|
|
2491
2521
|
}
|
|
2492
|
-
function
|
|
2522
|
+
function on(t) {
|
|
2493
2523
|
const i = t.metadata;
|
|
2494
2524
|
if (typeof i.pictureUrl == "string") return i.pictureUrl;
|
|
2495
2525
|
if (t.provider === "facebook")
|
|
@@ -2500,26 +2530,26 @@ function rn(t) {
|
|
|
2500
2530
|
}
|
|
2501
2531
|
return null;
|
|
2502
2532
|
}
|
|
2503
|
-
function
|
|
2504
|
-
const [o, s] =
|
|
2505
|
-
return
|
|
2533
|
+
function an({ conn: t, apiUrl: i, size: r = 40 }) {
|
|
2534
|
+
const [o, s] = y(!1), k = on(t), g = Math.round(r * 0.28);
|
|
2535
|
+
return k && !o ? /* @__PURE__ */ e(
|
|
2506
2536
|
"img",
|
|
2507
2537
|
{
|
|
2508
|
-
src:
|
|
2509
|
-
alt:
|
|
2538
|
+
src: k,
|
|
2539
|
+
alt: Ge(t),
|
|
2510
2540
|
referrerPolicy: "no-referrer",
|
|
2511
2541
|
onError: () => s(!0),
|
|
2512
|
-
style: { width: r, height: r, borderRadius:
|
|
2542
|
+
style: { width: r, height: r, borderRadius: g, objectFit: "cover", flexShrink: 0, display: "block" }
|
|
2513
2543
|
}
|
|
2514
2544
|
) : /* @__PURE__ */ e(ge, { provider: t.provider, apiUrl: i, size: r });
|
|
2515
2545
|
}
|
|
2516
|
-
function
|
|
2517
|
-
const [o, s] =
|
|
2546
|
+
function ln({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
2547
|
+
const [o, s] = y(!1);
|
|
2518
2548
|
return /* @__PURE__ */ n("div", { style: a.channelItem, children: [
|
|
2519
|
-
/* @__PURE__ */ e(
|
|
2549
|
+
/* @__PURE__ */ e(an, { conn: t, apiUrl: i, size: 40 }),
|
|
2520
2550
|
/* @__PURE__ */ n("div", { style: a.channelInfo, children: [
|
|
2521
|
-
/* @__PURE__ */ e("div", { style: a.channelName, children:
|
|
2522
|
-
/* @__PURE__ */ e("div", { style: a.channelMeta, children:
|
|
2551
|
+
/* @__PURE__ */ e("div", { style: a.channelName, children: Ge(t) }),
|
|
2552
|
+
/* @__PURE__ */ e("div", { style: a.channelMeta, children: en(t) })
|
|
2523
2553
|
] }),
|
|
2524
2554
|
/* @__PURE__ */ n("div", { style: a.channelActions, children: [
|
|
2525
2555
|
/* @__PURE__ */ e("span", { style: t.status === "active" ? a.badgeActive : a.badgeInactive, children: t.status === "active" ? "Hoạt động" : t.status }),
|
|
@@ -2539,15 +2569,15 @@ function an({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
|
2539
2569
|
] })
|
|
2540
2570
|
] });
|
|
2541
2571
|
}
|
|
2542
|
-
const
|
|
2572
|
+
const dn = [
|
|
2543
2573
|
{ id: "facebook", name: "Facebook", desc: "Fanpage & Messenger", type: "oauth" },
|
|
2544
2574
|
{ id: "zalo", name: "Zalo OA", desc: "Official Account", type: "oauth" },
|
|
2545
2575
|
{ id: "instagram", name: "Instagram", desc: "DM & Comments", type: "oauth" },
|
|
2546
2576
|
{ id: "telegram", name: "Telegram", desc: "Bot token", type: "token" },
|
|
2547
2577
|
{ id: "livechat", name: "Live Chat", desc: "Website widget", type: "livechat" }
|
|
2548
2578
|
];
|
|
2549
|
-
function
|
|
2550
|
-
const [o, s] =
|
|
2579
|
+
function cn({ provider: t, apiUrl: i, onClick: r }) {
|
|
2580
|
+
const [o, s] = y(!1);
|
|
2551
2581
|
return /* @__PURE__ */ n(
|
|
2552
2582
|
"div",
|
|
2553
2583
|
{
|
|
@@ -2568,7 +2598,7 @@ function dn({ provider: t, apiUrl: i, onClick: r }) {
|
|
|
2568
2598
|
}
|
|
2569
2599
|
);
|
|
2570
2600
|
}
|
|
2571
|
-
function
|
|
2601
|
+
function Ue({ done: t, active: i, label: r }) {
|
|
2572
2602
|
return /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 10, fontSize: 13, color: t ? "#059669" : i ? "#0f172a" : "#94a3b8" }, children: [
|
|
2573
2603
|
/* @__PURE__ */ e("div", { style: {
|
|
2574
2604
|
width: 10,
|
|
@@ -2581,9 +2611,264 @@ function De({ done: t, active: i, label: r }) {
|
|
|
2581
2611
|
r
|
|
2582
2612
|
] });
|
|
2583
2613
|
}
|
|
2584
|
-
|
|
2614
|
+
function sn(t) {
|
|
2615
|
+
return t.split(/\s+/).filter(Boolean).slice(-2).map((i) => i[0]).join("").toUpperCase() || "?";
|
|
2616
|
+
}
|
|
2617
|
+
function hn(t) {
|
|
2618
|
+
if (!t) return "";
|
|
2619
|
+
const i = new Date(t);
|
|
2620
|
+
return i.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? i.toLocaleTimeString("vi-VN", { hour: "2-digit", minute: "2-digit" }) : i.toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit" });
|
|
2621
|
+
}
|
|
2622
|
+
function mn({
|
|
2623
|
+
apiUrl: t,
|
|
2624
|
+
token: i,
|
|
2625
|
+
theme: r,
|
|
2626
|
+
locale: o = "vi",
|
|
2627
|
+
icon: s,
|
|
2628
|
+
onConversationSelect: k
|
|
2629
|
+
}) {
|
|
2630
|
+
const g = (r == null ? void 0 : r.primaryColor) ?? "#2563eb", $ = typeof s == "function" ? s({ size: 20, color: "currentColor" }) : s ?? /* @__PURE__ */ e(Ye, { size: 20, strokeWidth: 1.8 }), f = Z(new st(t, i)), [x, R] = y(!1), [I, E] = y([]), W = Z(null), O = Z(null), D = I.filter((z) => (z.unreadCount ?? 0) > 0), L = D.reduce((z, b) => z + (b.unreadCount ?? 0), 0), P = ke(async () => {
|
|
2631
|
+
try {
|
|
2632
|
+
const z = await f.current.listConversations();
|
|
2633
|
+
E(z.items);
|
|
2634
|
+
} catch {
|
|
2635
|
+
}
|
|
2636
|
+
}, []);
|
|
2637
|
+
V(() => (P(), f.current.connectSSE((b) => {
|
|
2638
|
+
(b === "message.new" || b === "conversation.updated") && P();
|
|
2639
|
+
})), [P]), V(() => {
|
|
2640
|
+
if (!x) return;
|
|
2641
|
+
const z = (b) => {
|
|
2642
|
+
var T, ie;
|
|
2643
|
+
(T = W.current) != null && T.contains(b.target) || (ie = O.current) != null && ie.contains(b.target) || R(!1);
|
|
2644
|
+
};
|
|
2645
|
+
return document.addEventListener("mousedown", z), () => document.removeEventListener("mousedown", z);
|
|
2646
|
+
}, [x]);
|
|
2647
|
+
const K = async (z) => {
|
|
2648
|
+
if (R(!1), k == null || k(z.id, z), (z.unreadCount ?? 0) > 0)
|
|
2649
|
+
try {
|
|
2650
|
+
await f.current.markRead(z.id), E(
|
|
2651
|
+
(b) => b.map((T) => T.id === z.id ? { ...T, unreadCount: 0 } : T)
|
|
2652
|
+
);
|
|
2653
|
+
} catch {
|
|
2654
|
+
}
|
|
2655
|
+
}, ee = o === "en" ? `${L} unread message${L !== 1 ? "s" : ""}` : `${L} tin nhắn chưa đọc`, U = o === "en" ? "No unread messages" : "Không có tin nhắn mới", S = o === "en" ? "Messages" : "Tin nhắn";
|
|
2656
|
+
return /* @__PURE__ */ n("div", { style: { position: "relative", display: "inline-block", fontFamily: (r == null ? void 0 : r.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif" }, children: [
|
|
2657
|
+
/* @__PURE__ */ n(
|
|
2658
|
+
"button",
|
|
2659
|
+
{
|
|
2660
|
+
ref: W,
|
|
2661
|
+
"aria-label": ee,
|
|
2662
|
+
"aria-haspopup": "true",
|
|
2663
|
+
"aria-expanded": x,
|
|
2664
|
+
onClick: () => R((z) => !z),
|
|
2665
|
+
style: {
|
|
2666
|
+
position: "relative",
|
|
2667
|
+
display: "inline-grid",
|
|
2668
|
+
placeItems: "center",
|
|
2669
|
+
width: 40,
|
|
2670
|
+
height: 40,
|
|
2671
|
+
border: 0,
|
|
2672
|
+
borderRadius: "50%",
|
|
2673
|
+
background: x ? `${g}18` : "transparent",
|
|
2674
|
+
color: x ? g : "#6b7280",
|
|
2675
|
+
cursor: "pointer",
|
|
2676
|
+
transition: "background 150ms ease, color 150ms ease"
|
|
2677
|
+
},
|
|
2678
|
+
children: [
|
|
2679
|
+
$,
|
|
2680
|
+
L > 0 && /* @__PURE__ */ e(
|
|
2681
|
+
"span",
|
|
2682
|
+
{
|
|
2683
|
+
"aria-hidden": "true",
|
|
2684
|
+
style: {
|
|
2685
|
+
position: "absolute",
|
|
2686
|
+
top: 4,
|
|
2687
|
+
right: 4,
|
|
2688
|
+
minWidth: 16,
|
|
2689
|
+
height: 16,
|
|
2690
|
+
borderRadius: 999,
|
|
2691
|
+
background: "#ef4444",
|
|
2692
|
+
color: "#fff",
|
|
2693
|
+
fontSize: 10,
|
|
2694
|
+
fontWeight: 800,
|
|
2695
|
+
lineHeight: "16px",
|
|
2696
|
+
textAlign: "center",
|
|
2697
|
+
padding: "0 4px",
|
|
2698
|
+
border: "2px solid #fff",
|
|
2699
|
+
boxSizing: "border-box"
|
|
2700
|
+
},
|
|
2701
|
+
children: L > 99 ? "99+" : L
|
|
2702
|
+
}
|
|
2703
|
+
)
|
|
2704
|
+
]
|
|
2705
|
+
}
|
|
2706
|
+
),
|
|
2707
|
+
x && /* @__PURE__ */ n(
|
|
2708
|
+
"div",
|
|
2709
|
+
{
|
|
2710
|
+
ref: O,
|
|
2711
|
+
role: "dialog",
|
|
2712
|
+
"aria-label": S,
|
|
2713
|
+
style: {
|
|
2714
|
+
position: "absolute",
|
|
2715
|
+
top: "calc(100% + 8px)",
|
|
2716
|
+
right: 0,
|
|
2717
|
+
zIndex: 9999,
|
|
2718
|
+
width: 360,
|
|
2719
|
+
maxHeight: 480,
|
|
2720
|
+
background: "#fff",
|
|
2721
|
+
border: "1px solid #e7ebf2",
|
|
2722
|
+
borderRadius: 14,
|
|
2723
|
+
boxShadow: "0 12px 40px rgba(23,32,51,.14)",
|
|
2724
|
+
overflow: "hidden",
|
|
2725
|
+
display: "flex",
|
|
2726
|
+
flexDirection: "column"
|
|
2727
|
+
},
|
|
2728
|
+
children: [
|
|
2729
|
+
/* @__PURE__ */ n("div", { style: {
|
|
2730
|
+
display: "flex",
|
|
2731
|
+
alignItems: "center",
|
|
2732
|
+
justifyContent: "space-between",
|
|
2733
|
+
padding: "14px 16px 10px",
|
|
2734
|
+
borderBottom: "1px solid #e7ebf2"
|
|
2735
|
+
}, children: [
|
|
2736
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 16, fontWeight: 700, color: "#172033" }, children: S }),
|
|
2737
|
+
L > 0 && /* @__PURE__ */ n("span", { style: {
|
|
2738
|
+
fontSize: 11,
|
|
2739
|
+
fontWeight: 600,
|
|
2740
|
+
background: `${g}14`,
|
|
2741
|
+
color: g,
|
|
2742
|
+
borderRadius: 999,
|
|
2743
|
+
padding: "2px 8px"
|
|
2744
|
+
}, children: [
|
|
2745
|
+
L,
|
|
2746
|
+
" ",
|
|
2747
|
+
o === "en" ? "unread" : "chưa đọc"
|
|
2748
|
+
] })
|
|
2749
|
+
] }),
|
|
2750
|
+
/* @__PURE__ */ e("div", { style: { overflowY: "auto", flex: 1 }, children: D.length === 0 ? /* @__PURE__ */ n("div", { style: {
|
|
2751
|
+
display: "flex",
|
|
2752
|
+
flexDirection: "column",
|
|
2753
|
+
alignItems: "center",
|
|
2754
|
+
gap: 8,
|
|
2755
|
+
padding: "40px 24px",
|
|
2756
|
+
color: "#9aa5b5"
|
|
2757
|
+
}, children: [
|
|
2758
|
+
/* @__PURE__ */ e(Ye, { size: 28, strokeWidth: 1.5 }),
|
|
2759
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 13 }, children: U })
|
|
2760
|
+
] }) : D.map((z) => /* @__PURE__ */ e(
|
|
2761
|
+
pn,
|
|
2762
|
+
{
|
|
2763
|
+
conversation: z,
|
|
2764
|
+
primary: g,
|
|
2765
|
+
apiUrl: t,
|
|
2766
|
+
onSelect: K
|
|
2767
|
+
},
|
|
2768
|
+
z.id
|
|
2769
|
+
)) })
|
|
2770
|
+
]
|
|
2771
|
+
}
|
|
2772
|
+
)
|
|
2773
|
+
] });
|
|
2774
|
+
}
|
|
2775
|
+
function pn({
|
|
2776
|
+
conversation: t,
|
|
2777
|
+
primary: i,
|
|
2778
|
+
apiUrl: r,
|
|
2779
|
+
onSelect: o
|
|
2780
|
+
}) {
|
|
2781
|
+
const [s, k] = y(!1), g = t.contactName ?? t.providerConversationKey, $ = t.unreadCount ?? 0;
|
|
2782
|
+
return /* @__PURE__ */ n(
|
|
2783
|
+
"button",
|
|
2784
|
+
{
|
|
2785
|
+
onClick: () => o(t),
|
|
2786
|
+
onMouseEnter: () => k(!0),
|
|
2787
|
+
onMouseLeave: () => k(!1),
|
|
2788
|
+
style: {
|
|
2789
|
+
display: "flex",
|
|
2790
|
+
width: "100%",
|
|
2791
|
+
gap: 12,
|
|
2792
|
+
padding: "10px 16px",
|
|
2793
|
+
border: 0,
|
|
2794
|
+
borderBottom: "1px solid #f1f5f9",
|
|
2795
|
+
background: s ? "#f7f9fc" : $ > 0 ? "#f0f4ff" : "#fff",
|
|
2796
|
+
textAlign: "left",
|
|
2797
|
+
cursor: "pointer",
|
|
2798
|
+
transition: "background 100ms ease",
|
|
2799
|
+
alignItems: "center"
|
|
2800
|
+
},
|
|
2801
|
+
children: [
|
|
2802
|
+
/* @__PURE__ */ n("span", { style: { position: "relative", flex: "0 0 auto", width: 42, height: 42 }, children: [
|
|
2803
|
+
/* @__PURE__ */ e(
|
|
2804
|
+
qe,
|
|
2805
|
+
{
|
|
2806
|
+
src: t.contactPictureUrl,
|
|
2807
|
+
fallback: sn(g),
|
|
2808
|
+
style: {
|
|
2809
|
+
width: 42,
|
|
2810
|
+
height: 42,
|
|
2811
|
+
borderRadius: "50%",
|
|
2812
|
+
objectFit: "cover",
|
|
2813
|
+
display: "grid",
|
|
2814
|
+
placeItems: "center",
|
|
2815
|
+
fontSize: 13,
|
|
2816
|
+
fontWeight: 800,
|
|
2817
|
+
background: `${i}18`,
|
|
2818
|
+
color: i
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
),
|
|
2822
|
+
void 0
|
|
2823
|
+
] }),
|
|
2824
|
+
/* @__PURE__ */ n("span", { style: { flex: 1, minWidth: 0 }, children: [
|
|
2825
|
+
/* @__PURE__ */ n("span", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 6 }, children: [
|
|
2826
|
+
/* @__PURE__ */ e("span", { style: {
|
|
2827
|
+
fontSize: 13,
|
|
2828
|
+
fontWeight: $ > 0 ? 700 : 500,
|
|
2829
|
+
color: "#172033",
|
|
2830
|
+
overflow: "hidden",
|
|
2831
|
+
textOverflow: "ellipsis",
|
|
2832
|
+
whiteSpace: "nowrap"
|
|
2833
|
+
}, children: g }),
|
|
2834
|
+
/* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, flexShrink: 0 }, children: [
|
|
2835
|
+
/* @__PURE__ */ e("time", { style: { fontSize: 11, color: "#9aa5b5", whiteSpace: "nowrap" }, children: hn(t.lastMessageAt) }),
|
|
2836
|
+
$ > 0 && /* @__PURE__ */ e("span", { style: {
|
|
2837
|
+
display: "inline-grid",
|
|
2838
|
+
placeItems: "center",
|
|
2839
|
+
minWidth: 18,
|
|
2840
|
+
height: 18,
|
|
2841
|
+
borderRadius: 999,
|
|
2842
|
+
background: "#ef4444",
|
|
2843
|
+
color: "#fff",
|
|
2844
|
+
fontSize: 10,
|
|
2845
|
+
fontWeight: 800,
|
|
2846
|
+
padding: "0 4px"
|
|
2847
|
+
}, children: $ > 99 ? "99+" : $ })
|
|
2848
|
+
] })
|
|
2849
|
+
] }),
|
|
2850
|
+
/* @__PURE__ */ n("span", { style: {
|
|
2851
|
+
display: "block",
|
|
2852
|
+
marginTop: 2,
|
|
2853
|
+
fontSize: 12,
|
|
2854
|
+
color: $ > 0 ? "#374151" : "#9aa5b5",
|
|
2855
|
+
fontWeight: $ > 0 ? 500 : 400,
|
|
2856
|
+
overflow: "hidden",
|
|
2857
|
+
textOverflow: "ellipsis",
|
|
2858
|
+
whiteSpace: "nowrap"
|
|
2859
|
+
}, children: [
|
|
2860
|
+
t.lastMessageDirection === "outbound" && /* @__PURE__ */ e("span", { style: { color: "#9aa5b5" }, children: "Bạn: " }),
|
|
2861
|
+
t.lastMessageText || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" })
|
|
2862
|
+
] })
|
|
2863
|
+
] })
|
|
2864
|
+
]
|
|
2865
|
+
}
|
|
2866
|
+
);
|
|
2867
|
+
}
|
|
2868
|
+
console.log("[ChannelHub] widget v0.1.8 loaded");
|
|
2585
2869
|
export {
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2870
|
+
bn as ChannelHubChannels,
|
|
2871
|
+
st as ChannelHubClient,
|
|
2872
|
+
yn as ChannelHubInbox,
|
|
2873
|
+
mn as ChannelHubNotificationBell
|
|
2589
2874
|
};
|